Merge pull request #2939 from ZhuGongpu/master

Add --log-steps flag
This commit is contained in:
Kubernetes Prow Robot
2020-09-09 19:05:44 -07:00
committed by GitHub
2 changed files with 18 additions and 2 deletions

View File

@@ -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.
@@ -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
}
@@ -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 {
@@ -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

View File

@@ -11,6 +11,7 @@ import (
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/kustomize/kyaml/runfn"
)
@@ -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 {
@@ -385,5 +396,4 @@ apiVersion: v1
})
}
}