Skip to content

Commit

Permalink
add feature flag gate to apply/plan stubs
Browse files Browse the repository at this point in the history
Signed-off-by: catsby <clint@defenseunicorns.com>
  • Loading branch information
catsby committed Jan 16, 2025
1 parent 53e3e79 commit b769946
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 22 deletions.
17 changes: 0 additions & 17 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ func init() {
rootCmd.PersistentFlags().StringVar(&cliFeatures, "feature", "", "Comma-separated list of features to enable (e.g., 'tofu')")

rootCmd.AddCommand(monitor.Cmd)
// apply cmd
rootCmd.AddCommand(applyCmd)
}

// loadViperConfig reads the config file and unmarshals the relevant config into DeployOpts.Variables
Expand Down Expand Up @@ -180,18 +178,3 @@ func unmarshalAndValidateConfig(configFile []byte, bundleCfg *types.BundleConfig
}
return nil
}

var applyCmd = &cobra.Command{
Use: "apply",
Short: lang.CmdBundleApplyShort,
Args: cobra.MaximumNArgs(0),
RunE: func(_ *cobra.Command, _ []string) error {
if !featureflags.IsEnabled("tofu") {
fmt.Println("The 'apply' command is not enabled. Use the '--feature=tofu' flag or set the FEATURE_FLAG environment variable.")
return nil
}
fmt.Println("Executing 'apply' command...")
return nil
},
DisableFlagParsing: true,
}
11 changes: 10 additions & 1 deletion src/cmd/vendored.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/defenseunicorns/uds-cli/src/config"
"github.com/defenseunicorns/uds-cli/src/config/lang"
"github.com/defenseunicorns/uds-cli/src/pkg/featureflags"
"github.com/spf13/cobra"
zarfCLI "github.com/zarf-dev/zarf/src/cmd"
zarfConfig "github.com/zarf-dev/zarf/src/config"
Expand Down Expand Up @@ -119,6 +120,10 @@ var planCmd = &cobra.Command{
Short: lang.CmdBundlePlanShort,
// Args: cobra.MaximumNArgs(0),
RunE: func(_ *cobra.Command, args []string) error {
if !featureflags.IsEnabled("tofu") {
fmt.Println("The 'plan' command is not enabled. Use the '--feature=tofu' flag or set the FEATURE_FLAG environment variable.")
return nil
}
return useEmbeddedTofu()
},
DisableFlagParsing: true,
Expand All @@ -128,7 +133,11 @@ var applyCmd = &cobra.Command{
Use: "apply",
Short: lang.CmdBundleApplyShort,
Args: cobra.MaximumNArgs(0),
RunE: func(_ *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
if !featureflags.IsEnabled("tofu") {
fmt.Println("The 'apply' command is not enabled. Use the '--feature=tofu' flag or set the FEATURE_FLAG environment variable.")
return nil
}
return useEmbeddedTofu()
},
DisableFlagParsing: true,
Expand Down
5 changes: 1 addition & 4 deletions src/config/lang/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const (
//TODO: @JPERRY come up with better strings for here..
CmdBundlePlanShort = "Generate a Tofu execution plan"

// bundle plan
// bundle apply
CmdBundleApplyShort = "Create or update infrastructure with Tofu"

// bundle inspect
Expand All @@ -66,9 +66,6 @@ const (
CmdBundleInspectFlagFindImages = "Derive images from a uds-bundle.yaml file and list them"
CmdBundleInspectFlagListVariables = "List all configurable variables in a bundle (including zarf variables)"

// bundle apply
CmdBundleApplyShort = "Create or update infrastructure with Tofu"

// bundle remove
CmdBundleRemoveShort = "Remove a bundle that has been deployed already"
CmdBundleRemoveFlagConfirm = "REQUIRED. Confirm the removal action to prevent accidental deletions"
Expand Down

0 comments on commit b769946

Please # to comment.