Add --log-steps flag

This commit is contained in:
Gongpu Zhu
2020-09-01 22:40:03 -07:00
parent 980f407552
commit 39a8798a87
2 changed files with 18 additions and 2 deletions

View File

@@ -9,11 +9,13 @@ import (
"strings" "strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/commands"
"sigs.k8s.io/kustomize/kyaml/errors" "sigs.k8s.io/kustomize/kyaml/errors"
"sigs.k8s.io/kustomize/kyaml/fn/runtime/runtimeutil" "sigs.k8s.io/kustomize/kyaml/fn/runtime/runtimeutil"
"sigs.k8s.io/kustomize/kyaml/runfn" "sigs.k8s.io/kustomize/kyaml/runfn"
"sigs.k8s.io/kustomize/kyaml/yaml" "sigs.k8s.io/kustomize/kyaml/yaml"
"sigs.k8s.io/kustomize/cmd/config/internal/generateddocs/commands"
) )
// GetCatRunner returns a RunFnRunner. // GetCatRunner returns a RunFnRunner.
@@ -65,6 +67,8 @@ func GetRunFnRunner(name string) *RunFnRunner {
r.Command.Flags().StringArrayVar( r.Command.Flags().StringArrayVar(
&r.Mounts, "mount", []string{}, &r.Mounts, "mount", []string{},
"a list of storage options read from the filesystem") "a list of storage options read from the filesystem")
r.Command.Flags().BoolVar(
&r.LogSteps, "log-steps", false, "log steps to stderr")
return r return r
} }
@@ -91,6 +95,7 @@ type RunFnRunner struct {
Network bool Network bool
NetworkName string NetworkName string
Mounts []string Mounts []string
LogSteps bool
} }
func (r *RunFnRunner) runE(c *cobra.Command, args []string) error { 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, EnableExec: r.EnableExec,
StorageMounts: storageMounts, StorageMounts: storageMounts,
ResultsDir: r.ResultsDir, ResultsDir: r.ResultsDir,
LogSteps: r.LogSteps,
} }
// don't consider args for the function // don't consider args for the function

View File

@@ -11,6 +11,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"sigs.k8s.io/kustomize/kyaml/runfn" "sigs.k8s.io/kustomize/kyaml/runfn"
) )
@@ -283,6 +284,16 @@ apiVersion: v1
args: []string{"run", "dir", "--image", "foo:bar", "--", "a=b", "c", "e=f"}, args: []string{"run", "dir", "--image", "foo:bar", "--", "a=b", "c", "e=f"},
err: "must have keys and values separated by", 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 { for i := range tests {
@@ -385,5 +396,4 @@ apiVersion: v1
}) })
} }
} }