Skip to content
Closed
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
13 changes: 9 additions & 4 deletions internal/commands/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewResultsPredicatesCommand(resultsPredicatesWrapper wrappers.ResultsPredic
}
triageShowCmd := triageShowSubCommand(resultsPredicatesWrapper)
triageUpdateCmd := triageUpdateSubCommand(resultsPredicatesWrapper, featureFlagsWrapper)
triageGetStatesCmd := triageGetStatesSubCommand(customStatesWrapper)
triageGetStatesCmd := triageGetStatesSubCommand(customStatesWrapper, featureFlagsWrapper )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space before the closing parenthesis. Please remove it for consistency.



addFormatFlagToMultipleCommands(
Expand All @@ -32,7 +32,7 @@ func NewResultsPredicatesCommand(resultsPredicatesWrapper wrappers.ResultsPredic
return triageCmd
}

func triageGetStatesSubCommand(customStatesWrapper wrappers.CustomStatesWrapper) *cobra.Command {
func triageGetStatesSubCommand(customStatesWrapper wrappers.CustomStatesWrapper, featureFlagsWrapper wrappers.FeatureFlagsWrapper) *cobra.Command {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function signature for triageGetStatesSubCommand has been changed to include featureFlagsWrapper. Ensure that all callers of this function are updated to pass the new argument.

triageGetStatesCmd := &cobra.Command{
Use: "get-states",
Short: "Show the custom states that have been configured in your tenant",
Expand All @@ -43,16 +43,21 @@ func triageGetStatesSubCommand(customStatesWrapper wrappers.CustomStatesWrapper)
$ cx triage get-states --all
`,
),
RunE: runTriageGetStates(customStatesWrapper),
RunE: runTriageGetStates(customStatesWrapper, featureFlagsWrapper),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The featureFlagsWrapper parameter is added to the runTriageGetStates function, but the corresponding function definition and the usage within the function body are not provided in the diff. Ensure that the function definition is updated to accept this new parameter and that it is utilized properly within the function.

}

triageGetStatesCmd.PersistentFlags().Bool(params.AllStatesFlag, false, "Show all custom states, including the ones that have been deleted")

return triageGetStatesCmd
}

func runTriageGetStates(customStatesWrapper wrappers.CustomStatesWrapper) func(*cobra.Command, []string) error {
func runTriageGetStates(customStatesWrapper wrappers.CustomStatesWrapper, featureFlagsWrapper wrappers.FeatureFlagsWrapper,) func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, _ []string) error {
flagResponse, _ := wrappers.GetSpecificFeatureFlag(featureFlagsWrapper, wrappers.CustomStatesFeatureFlag)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling for wrappers.GetSpecificFeatureFlag is missing. Consider handling the error to avoid ignoring potential issues when retrieving the feature flag status.

if !flagResponse.Status {
return errors.Errorf("%s", "Fetching custom states is not available for your tenant")
}

includeDeleted, _ := cmd.Flags().GetBool(params.AllStatesFlag)
states, err := customStatesWrapper.GetAllCustomStates(includeDeleted)
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions internal/wrappers/feature-flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ContainerEngineCLIEnabled = "CONTAINER_ENGINE_CLI_ENABLED"
const SCSEngineCLIEnabled = "NEW_2MS_SCORECARD_RESULTS_CLI_ENABLED"
const NewScanReportEnabled = "NEW_SAST_SCAN_REPORT_ENABLED"
const maxRetries = 3
const CustomStatesFeatureFlag = "CUSTOM_STATES_ENABLED"

var DefaultFFLoad bool = false

Expand All @@ -31,6 +32,15 @@ var FeatureFlagsBaseMap = []CommandFlags{
},
},
},
{
CommandName: "cx triage get-states",
FeatureFlags: []FlagBase{
{
Name: CustomStatesFeatureFlag,
Default: false,
},
},
},
{
CommandName: "cx project create",
},
Expand Down
Loading