diff --git a/internal/pkg/service/cli/cmd/ci/workflow/cmd.go b/internal/pkg/service/cli/cmd/ci/workflow/cmd.go index 26379eb931..82578ce4b2 100644 --- a/internal/pkg/service/cli/cmd/ci/workflow/cmd.go +++ b/internal/pkg/service/cli/cmd/ci/workflow/cmd.go @@ -19,8 +19,8 @@ type Flags struct { CIPush configmap.Value[bool] `configKey:"ci-push" configUsage:"create workflow to push change in main branch to the project"` } -func DefaultFlags() *Flags { - return &Flags{ +func DefaultFlags() Flags { + return Flags{ CI: configmap.NewValue(true), CIValidate: configmap.NewValue(true), CIPush: configmap.NewValue(true), @@ -35,8 +35,8 @@ func WorkflowsCommand(p dependencies.Provider) *cobra.Command { Short: helpmsg.Read(`ci/workflows/short`), Long: helpmsg.Read(`ci/workflows/long`), RunE: func(cmd *cobra.Command, args []string) (err error) { + // Bind flags to struct f := DefaultFlags() - // bind flags to struct if err := configmap.Bind(utils.GetBindConfig(cmd.Flags(), args), f); err != nil { return err } @@ -52,7 +52,7 @@ func WorkflowsCommand(p dependencies.Provider) *cobra.Command { } // Ask options - options := AskWorkflowsOptions(*f, d.Dialogs()) + options := AskWorkflowsOptions(f, d.Dialogs()) // Generate workflows return workflowsGen.Run(cmd.Context(), prj.Fs(), options, d) diff --git a/internal/pkg/service/cli/dialog/workflows_test.go b/internal/pkg/service/cli/dialog/workflows_test.go index 04f0fee084..8c52617a9e 100644 --- a/internal/pkg/service/cli/dialog/workflows_test.go +++ b/internal/pkg/service/cli/dialog/workflows_test.go @@ -44,7 +44,7 @@ func TestAskWorkflowsOptionsInteractive(t *testing.T) { }() // Run - out := workflow.AskWorkflowsOptions(*f, dialog) + out := workflow.AskWorkflowsOptions(f, dialog) assert.Equal(t, genWorkflows.Options{ Validate: false, Push: true, @@ -67,12 +67,11 @@ func TestAskWorkflowsOptionsByFlag(t *testing.T) { o.Set(`ci-pull`, `false`) o.Set(`ci-main-branch`, `main`) - f := workflow.Flags{ - CIValidate: configmap.NewValue(false), - CIPull: configmap.NewValue(false), - CIMainBranch: configmap.NewValue("main"), - CIPush: configmap.NewValue(true), - } + f := workflow.DefaultFlags() + f.CIValidate = configmap.NewValueWithOrigin(false, configmap.SetByFlag) + f.CIPull = configmap.NewValueWithOrigin(false, configmap.SetByFlag) + f.CIMainBranch = configmap.NewValueWithOrigin("main", configmap.SetByFlag) + f.CIPush = configmap.NewValueWithOrigin(true, configmap.SetByFlag) // Run out := workflow.AskWorkflowsOptions(f, dialog)