Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions cmd/kosli/createEnvironment.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ The following types are supported:
- server - Generic type
- logical - Logical grouping of real environments

By default, kosli will not make new snapshots for scaling events (change in number of instances running).
For large clusters the scaling events will often outnumber the actual change of SW.

It is possible to enable new snapshots for scaling events with the --include-scaling flag, or turn
it off again with the --exclude-scaling.

Logical environments are used for grouping of physical environments. For instance **prod-aws** and **prod-s3** can
be grouped into logical environment **prod**. Logical environments are view-only, you can not report snapshots
to them.
Expand Down Expand Up @@ -103,9 +97,14 @@ func newCreateEnvironmentCmd(out io.Writer) *cobra.Command {
cmd.Flags().BoolVar(&o.requireProvenance, "require-provenance", false, requireProvenanceFlag)
cmd.Flags().StringSliceVar(&o.payload.IncludedEnvironments, "included-environments", []string{}, includedEnvironments)

err := cmd.Flags().MarkDeprecated("require-provenance", "this flag is deprecated and will be removed in a future version. Use policies instead.")
scalingDeprecationMsg := "this flag is deprecated and will be removed in a future version. Scaling events do not trigger new snapshots."
Comment thread
ToreMerkely marked this conversation as resolved.
err := DeprecateFlags(cmd, map[string]string{
"require-provenance": "this flag is deprecated and will be removed in a future version. Use policies instead.",
"include-scaling": scalingDeprecationMsg,
"exclude-scaling": scalingDeprecationMsg,
})
if err != nil {
logger.Error("failed to mark require-provenance as deprecated: %v", err)
logger.Error("failed to configure deprecated flags: %v", err)
}

addDryRunFlag(cmd)
Expand Down
24 changes: 12 additions & 12 deletions cmd/kosli/createEnvironment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ func (suite *CreateEnvironmentCommandTestSuite) TestCreateEnvironmentCmd() {
golden: "environment newEnv2 was created\n",
},
{
wantError: false,
name: "can create K8S env with include-scaling",
cmd: "create env newEnv1 --type K8S --include-scaling" + suite.defaultKosliArguments,
golden: "environment newEnv1 was created\n",
wantError: false,
name: "can create K8S env with include-scaling",
cmd: "create env newEnv1 --type K8S --include-scaling" + suite.defaultKosliArguments,
goldenRegex: "Flag --include-scaling has been deprecated.*\nenvironment newEnv1 was created",
},
{
wantError: false,
name: "can create K8S env with exclude-scaling",
cmd: "create env newEnv1 --type K8S --exclude-scaling" + suite.defaultKosliArguments,
golden: "environment newEnv1 was created\n",
wantError: false,
name: "can create K8S env with exclude-scaling",
cmd: "create env newEnv1 --type K8S --exclude-scaling" + suite.defaultKosliArguments,
goldenRegex: "Flag --exclude-scaling has been deprecated.*\nenvironment newEnv1 was created",
},
{
name: "can create K8S env with --require-provenance",
Expand All @@ -61,10 +61,10 @@ func (suite *CreateEnvironmentCommandTestSuite) TestCreateEnvironmentCmd() {
goldenRegex: "Flag --require-provenance has been deprecated.*\nenvironment relaxedEnv was created",
},
{
wantError: true,
name: "fail if both exclude-scaling an include-scaling is provided",
cmd: "create env newEnv1 --type K8S --exclude-scaling --include-scaling" + suite.defaultKosliArguments,
golden: "Error: only one of --exclude-scaling, --include-scaling is allowed\n",
wantError: true,
name: "fail if both exclude-scaling an include-scaling is provided",
cmd: "create env newEnv1 --type K8S --exclude-scaling --include-scaling" + suite.defaultKosliArguments,
goldenRegex: "Flag --exclude-scaling has been deprecated.*\nFlag --include-scaling has been deprecated.*\nError: only one of --exclude-scaling, --include-scaling is allowed\n",
},
{
wantError: true,
Expand Down
7 changes: 7 additions & 0 deletions cmd/kosli/snapshotAutoEnvironment.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ func addAutoEnvironmentFlags(cmd *cobra.Command) {
cmd.PersistentFlags().BoolVar(&snapshotAutoEnv.includeScaling, "include-scaling", false, includeScalingFlag)
cmd.PersistentFlags().BoolVar(&snapshotAutoEnv.excludeScaling, "exclude-scaling", false, excludeScalingFlag)

scalingDeprecationMsg := "this flag is deprecated and will be removed in a future version. Scaling events do not trigger new snapshots."
for _, name := range []string{"include-scaling", "exclude-scaling"} {
if err := cmd.PersistentFlags().MarkDeprecated(name, scalingDeprecationMsg); err != nil {
logger.Error("failed to mark %s as deprecated: %v", name, err)
}
}
Comment thread
ToreMerkely marked this conversation as resolved.

// Accept --auto-env as an alias for --auto-environment. SetGlobalNormalizationFunc
// propagates to all subcommands of the snapshot group.
cmd.SetGlobalNormalizationFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
Expand Down
16 changes: 8 additions & 8 deletions cmd/kosli/snapshotAutoEnvironment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,16 @@ func (suite *SnapshotAutoEnvironmentTestSuite) TestSnapshotAutoEnvironment() {
golden: fmt.Sprintf("Error: environment %s already exists with type server, which does not match the snapshot type docker\n", suite.existingServerEnv),
},
{
wantError: true,
name: "errors when both scaling flags are set",
cmd: fmt.Sprintf(`snapshot paths %s --auto-environment --include-scaling --exclude-scaling %s %s`, suite.newEnv, suite.pathsFileArg, suite.defaultKosliArguments),
golden: "Error: only one of --include-scaling, --exclude-scaling is allowed\n",
wantError: true,
name: "errors when both scaling flags are set",
cmd: fmt.Sprintf(`snapshot paths %s --auto-environment --include-scaling --exclude-scaling %s %s`, suite.newEnv, suite.pathsFileArg, suite.defaultKosliArguments),
goldenRegex: "Flag --include-scaling has been deprecated.*\nFlag --exclude-scaling has been deprecated.*\nError: only one of --include-scaling, --exclude-scaling is allowed\n",
},
{
wantError: true,
name: "errors when both scaling flags are set even without --auto-environment",
cmd: fmt.Sprintf(`snapshot paths %s --include-scaling --exclude-scaling %s %s`, suite.existingServerEnv, suite.pathsFileArg, suite.defaultKosliArguments),
golden: "Error: only one of --include-scaling, --exclude-scaling is allowed\n",
wantError: true,
name: "errors when both scaling flags are set even without --auto-environment",
cmd: fmt.Sprintf(`snapshot paths %s --include-scaling --exclude-scaling %s %s`, suite.existingServerEnv, suite.pathsFileArg, suite.defaultKosliArguments),
goldenRegex: "Flag --include-scaling has been deprecated.*\nFlag --exclude-scaling has been deprecated.*\nError: only one of --include-scaling, --exclude-scaling is allowed\n",
},
{
name: "warns and ignores optional flags when --auto-environment is not set",
Expand Down
Loading