Skip to content

Commit

Permalink
Add --log-steps flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuGongpu committed Sep 3, 2020
1 parent 980f407 commit 39a8798
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cmd/config/internal/commands/run-fns.go
Expand Up @@ -9,11 +9,13 @@ import (
"strings"

"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/commands"

"sigs.k8s.io/kustomize/kyaml/errors"
"sigs.k8s.io/kustomize/kyaml/fn/runtime/runtimeutil"
"sigs.k8s.io/kustomize/kyaml/runfn"
"sigs.k8s.io/kustomize/kyaml/yaml"

"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/commands"
)

// GetCatRunner returns a RunFnRunner.
Expand Down Expand Up @@ -65,6 +67,8 @@ func GetRunFnRunner(name string) *RunFnRunner {
r.Command.Flags().StringArrayVar(
&r.Mounts, "mount", []string{},
"a list of storage options read from the filesystem")
r.Command.Flags().BoolVar(
&r.LogSteps, "log-steps", false, "log steps to stderr")
return r
}

Expand All @@ -91,6 +95,7 @@ type RunFnRunner struct {
Network bool
NetworkName string
Mounts []string
LogSteps bool
}

func (r *RunFnRunner) runE(c *cobra.Command, args []string) error {
Expand Down Expand Up @@ -305,6 +310,7 @@ func (r *RunFnRunner) preRunE(c *cobra.Command, args []string) error {
EnableExec: r.EnableExec,
StorageMounts: storageMounts,
ResultsDir: r.ResultsDir,
LogSteps: r.LogSteps,
}

// don't consider args for the function
Expand Down
12 changes: 11 additions & 1 deletion cmd/config/internal/commands/run_test.go
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"

"sigs.k8s.io/kustomize/kyaml/runfn"
)

Expand Down Expand Up @@ -283,6 +284,16 @@ apiVersion: v1
args: []string{"run", "dir", "--image", "foo:bar", "--", "a=b", "c", "e=f"},
err: "must have keys and values separated by",
},
{
name: "log steps",
args: []string{"run", "dir", "--log-steps"},
path: "dir",
expectedStruct: &runfn.RunFns{
Path: "dir",
NetworkName: "bridge",
LogSteps: true,
},
},
}

for i := range tests {
Expand Down Expand Up @@ -385,5 +396,4 @@ apiVersion: v1

})
}

}

0 comments on commit 39a8798

Please sign in to comment.