use empty policy flag values to unset · Entire
use empty policy flag values to unset
Treat provided empty checkpoint policy flag values as field removal.
This keeps the command surface smaller while preserving the ability to distinguish omitted flags from explicit empty values.
Sessions
Changes
5
cmd/entire/cli
Mcheckpoint_policy.go+22/-19
Mcheckpoint_policy_test.go+3/-8
checkpointpolicy
Mupdate.go+9/-28
Mupdate_test.go+33/-17
10 unmodified lines
```go
type checkpointPolicyOptions struct {
version string
minVersion string
unsetVersion bool
unsetMinVersion bool
force bool
version string
minVersion string
force bool
}
const (
checkpointVersionFlag = "checkpoint-version"
checkpointMinVersionFlag = "checkpoint-min-version"
)
func newCheckpointPolicyCmd() *cobra.Command {
var opts checkpointPolicyOptions
cmd := &cobra.Command{
Hidden: true,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, _ []string) error {
},
}
cmd.Flags().StringVar(&opts.version, "checkpoint-version", "", "Set the checkpoint version used for new writes")
cmd.Flags().StringVar(&opts.minVersion, "checkpoint-min-version", "", "Set the checkpoint version used for upgrade warnings")
cmd.Flags().BoolVar(&opts.unsetVersion, "unset-checkpoint-version", false, "Unset checkpoint_version so new writes use the CLI default")
cmd.Flags().BoolVar(&opts.unsetMinVersion, "unset-checkpoint-min-version", false, "Unset checkpoint_min_version so upgrade warnings use the CLI default")
cmd.Flags().StringVar(&opts.version, checkpointVersionFlag, "", `Set the checkpoint version used for new writes. Use "" to unset`)
cmd.Flags().StringVar(&opts.minVersion, checkpointMinVersionFlag, "", `Set the checkpoint version used for upgrade warnings. Use "" to unset`)
cmd.Flags().BoolVar(&opts.force, "force", false, "Allow checkpoint policy version downgrades")
return cmd
}
checkpoint_version selects the checkpoint metadata format used for new writes. If no policy is configured, Entire uses the CLI default. If this CLI reads a configured checkpoint_version it cannot write, it warns and writes the default version instead. Unset checkpoint_version to inherit the CLI default.
checkpoint_min_version is an upgrade nudge. Clients that cannot read that version warn users to upgrade, but policy alone does not block checkpoint writes or app usage. Unset checkpoint_min_version to inherit the CLI default.
func hasCheckpointPolicyUpdate(opts checkpointPolicyOptions) bool {
return opts.version != "" || opts.minVersion != "" || opts.unsetVersion || opts.unsetMinVersion
}
Either field may be omitted. An empty policy file means both fields inherit the CLI defaults:
{}
checkpoint_version selects the checkpoint format for new writes. If no policy
is configured, or a policy omits checkpoint_version, the CLI writes its
default checkpoint version. If another client configures a checkpoint_version
this CLI cannot write, the CLI warns and writes the default checkpoint version instead.
checkpoint_min_version is a soft upgrade nudge. Clients that cannot read that
version warn users to upgrade, but policy alone does not block checkpoint
writes or app usage. Missing policy fields default to branch-v1.