From 8d1802cbc2f0dee009bb204555524c5a2c7d9920 Mon Sep 17 00:00:00 2001 From: Tore Martin Hagen Date: Thu, 30 Jul 2026 07:40:31 +0200 Subject: [PATCH 1/5] feat(create environment): deprecate the scaling flags Scaling events no longer create environment snapshots, so --include-scaling and --exclude-scaling are on their way out. Mark both deprecated and drop the scaling paragraph from the long description, since MarkDeprecated also hides the flags from help and generated docs. See https://github.com/kosli-dev/server/issues/6327 Co-Authored-By: Claude Opus 5 (1M context) --- cmd/kosli/createEnvironment.go | 13 +++++++------ cmd/kosli/createEnvironment_test.go | 24 ++++++++++++------------ cmd/kosli/root.go | 1 + 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cmd/kosli/createEnvironment.go b/cmd/kosli/createEnvironment.go index c927f5ea1..f679c74c5 100644 --- a/cmd/kosli/createEnvironment.go +++ b/cmd/kosli/createEnvironment.go @@ -24,12 +24,9 @@ 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). +kosli does 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. @@ -103,9 +100,13 @@ 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.") + 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": scalingFlagDeprecationMsg, + "exclude-scaling": scalingFlagDeprecationMsg, + }) 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) diff --git a/cmd/kosli/createEnvironment_test.go b/cmd/kosli/createEnvironment_test.go index 0d822607d..4a623108f 100644 --- a/cmd/kosli/createEnvironment_test.go +++ b/cmd/kosli/createEnvironment_test.go @@ -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", @@ -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, diff --git a/cmd/kosli/root.go b/cmd/kosli/root.go index 88d8c0d3b..8279b6bdd 100644 --- a/cmd/kosli/root.go +++ b/cmd/kosli/root.go @@ -280,6 +280,7 @@ The ^.kosli_ignore^ will be treated as part of the artifact like any other file, attestationDecisionControlFlag = "The control identifier being evaluated (e.g. RCTL-043)." excludeScalingFlag = "[optional] Exclude scaling events for snapshots. Snapshots with scaling changes will not result in new environment records." includeScalingFlag = "[optional] Include scaling events for snapshots. Snapshots with scaling changes will result in new environment records." + scalingFlagDeprecationMsg = "this flag is deprecated and will be removed in a future version. Scaling events no longer create environment snapshots." includedEnvironments = "[optional] Comma separated list of environments to include in logical environment" autoEnvironmentFlag = "[optional] Create the environment (with the type inferred from the snapshot subcommand) if it does not already exist, before reporting the snapshot." requireProvenanceFlag = "[defaulted] Require provenance for all artifacts running in environment snapshots." From 1c3eb281c5a73f0b637139f84b305a464ab74a82 Mon Sep 17 00:00:00 2001 From: Tore Martin Hagen Date: Thu, 30 Jul 2026 07:44:29 +0200 Subject: [PATCH 2/5] feat(snapshot): deprecate the scaling flags on --auto-environment Mirror the deprecation on kosli create environment for the group-wide --include-scaling and --exclude-scaling flags of the snapshot commands. See https://github.com/kosli-dev/server/issues/6327 Co-Authored-By: Claude Opus 5 (1M context) --- cmd/kosli/snapshotAutoEnvironment.go | 6 ++++++ cmd/kosli/snapshotAutoEnvironment_test.go | 16 ++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cmd/kosli/snapshotAutoEnvironment.go b/cmd/kosli/snapshotAutoEnvironment.go index c5f227166..f6cf1d574 100644 --- a/cmd/kosli/snapshotAutoEnvironment.go +++ b/cmd/kosli/snapshotAutoEnvironment.go @@ -39,6 +39,12 @@ func addAutoEnvironmentFlags(cmd *cobra.Command) { cmd.PersistentFlags().BoolVar(&snapshotAutoEnv.includeScaling, "include-scaling", false, includeScalingFlag) cmd.PersistentFlags().BoolVar(&snapshotAutoEnv.excludeScaling, "exclude-scaling", false, excludeScalingFlag) + for _, name := range []string{"include-scaling", "exclude-scaling"} { + if err := cmd.PersistentFlags().MarkDeprecated(name, scalingFlagDeprecationMsg); err != nil { + logger.Error("failed to mark %s as deprecated: %v", name, err) + } + } + // 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 { diff --git a/cmd/kosli/snapshotAutoEnvironment_test.go b/cmd/kosli/snapshotAutoEnvironment_test.go index d72036fad..248e3a00a 100644 --- a/cmd/kosli/snapshotAutoEnvironment_test.go +++ b/cmd/kosli/snapshotAutoEnvironment_test.go @@ -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", From 4bd84e4ad25176138dd1c1b4a43fe607979c272b Mon Sep 17 00:00:00 2001 From: Tore Martin Hagen Date: Thu, 30 Jul 2026 07:57:49 +0200 Subject: [PATCH 3/5] Updated comment --- cmd/kosli/createEnvironment.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmd/kosli/createEnvironment.go b/cmd/kosli/createEnvironment.go index f679c74c5..04f1f77e5 100644 --- a/cmd/kosli/createEnvironment.go +++ b/cmd/kosli/createEnvironment.go @@ -24,9 +24,6 @@ The following types are supported: - server - Generic type - logical - Logical grouping of real environments -kosli does 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. - 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. From 27c88bc6ef34f7d8ffff73e92138bef76d6591e6 Mon Sep 17 00:00:00 2001 From: Tore Martin Hagen Date: Thu, 30 Jul 2026 08:01:46 +0200 Subject: [PATCH 4/5] refactor: inline the scaling deprecation message at each use site The message was sitting in root.go among the flag usage strings, which is not what that block is for. Keep it local to each command instead. Co-Authored-By: Claude Opus 5 (1M context) --- cmd/kosli/createEnvironment.go | 5 +++-- cmd/kosli/root.go | 1 - cmd/kosli/snapshotAutoEnvironment.go | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/kosli/createEnvironment.go b/cmd/kosli/createEnvironment.go index 04f1f77e5..7675eb345 100644 --- a/cmd/kosli/createEnvironment.go +++ b/cmd/kosli/createEnvironment.go @@ -97,10 +97,11 @@ 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) + scalingDeprecationMsg := "this flag is deprecated and will be removed in a future version. Scaling events no longer create environment snapshots." 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": scalingFlagDeprecationMsg, - "exclude-scaling": scalingFlagDeprecationMsg, + "include-scaling": scalingDeprecationMsg, + "exclude-scaling": scalingDeprecationMsg, }) if err != nil { logger.Error("failed to configure deprecated flags: %v", err) diff --git a/cmd/kosli/root.go b/cmd/kosli/root.go index 8279b6bdd..88d8c0d3b 100644 --- a/cmd/kosli/root.go +++ b/cmd/kosli/root.go @@ -280,7 +280,6 @@ The ^.kosli_ignore^ will be treated as part of the artifact like any other file, attestationDecisionControlFlag = "The control identifier being evaluated (e.g. RCTL-043)." excludeScalingFlag = "[optional] Exclude scaling events for snapshots. Snapshots with scaling changes will not result in new environment records." includeScalingFlag = "[optional] Include scaling events for snapshots. Snapshots with scaling changes will result in new environment records." - scalingFlagDeprecationMsg = "this flag is deprecated and will be removed in a future version. Scaling events no longer create environment snapshots." includedEnvironments = "[optional] Comma separated list of environments to include in logical environment" autoEnvironmentFlag = "[optional] Create the environment (with the type inferred from the snapshot subcommand) if it does not already exist, before reporting the snapshot." requireProvenanceFlag = "[defaulted] Require provenance for all artifacts running in environment snapshots." diff --git a/cmd/kosli/snapshotAutoEnvironment.go b/cmd/kosli/snapshotAutoEnvironment.go index f6cf1d574..f045588a2 100644 --- a/cmd/kosli/snapshotAutoEnvironment.go +++ b/cmd/kosli/snapshotAutoEnvironment.go @@ -39,8 +39,9 @@ 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 no longer create environment snapshots." for _, name := range []string{"include-scaling", "exclude-scaling"} { - if err := cmd.PersistentFlags().MarkDeprecated(name, scalingFlagDeprecationMsg); err != nil { + if err := cmd.PersistentFlags().MarkDeprecated(name, scalingDeprecationMsg); err != nil { logger.Error("failed to mark %s as deprecated: %v", name, err) } } From d82aa7a3099103f87b665bc65ea3312599b825bf Mon Sep 17 00:00:00 2001 From: Tore Martin Hagen Date: Thu, 30 Jul 2026 09:09:05 +0200 Subject: [PATCH 5/5] fix: correct the scaling deprecation message The old wording claimed scaling events no longer create environment snapshots, which is not true for the grandfathered environments that still capture scaling. State the plain fact instead: scaling events do not trigger new snapshots. Co-Authored-By: Claude Opus 5 (1M context) --- cmd/kosli/createEnvironment.go | 2 +- cmd/kosli/snapshotAutoEnvironment.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/kosli/createEnvironment.go b/cmd/kosli/createEnvironment.go index 7675eb345..a19bfbce3 100644 --- a/cmd/kosli/createEnvironment.go +++ b/cmd/kosli/createEnvironment.go @@ -97,7 +97,7 @@ 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) - scalingDeprecationMsg := "this flag is deprecated and will be removed in a future version. Scaling events no longer create environment snapshots." + scalingDeprecationMsg := "this flag is deprecated and will be removed in a future version. Scaling events do not trigger new snapshots." 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, diff --git a/cmd/kosli/snapshotAutoEnvironment.go b/cmd/kosli/snapshotAutoEnvironment.go index f045588a2..fdcb4df2e 100644 --- a/cmd/kosli/snapshotAutoEnvironment.go +++ b/cmd/kosli/snapshotAutoEnvironment.go @@ -39,7 +39,7 @@ 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 no longer create environment snapshots." + 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)