Skip to content

Commit 0def276

Browse files
committed
Fix skaffold inspect tests flags and help message
skaffold inspect tests did not display its flag in its help message initially, the changes here fix this. Additionally the profile and modules flags were not wired up/plumbed properly initially. They are now tested and working as expected
1 parent 8303f00 commit 0def276

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

cmd/skaffold/app/cmd/inspect_tests.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
func cmdTests() *cobra.Command {
3131
return NewCmd("tests").
3232
WithDescription("View skaffold test information").
33-
WithPersistentFlagAdder(cmdTestsFlags).
3433
WithCommands(cmdTestsList())
3534
}
3635

@@ -39,6 +38,7 @@ func cmdTestsList() *cobra.Command {
3938
WithExample("Get list of tests", "inspect tests list --format json").
4039
WithExample("Get list of tests targeting a specific configuration", "inspect tests list --profile local --format json").
4140
WithDescription("Print the list of tests that would be run for a given configuration (default skaffold configuration, specific module, specific profile, etc).").
41+
WithFlagAdder(cmdTestsListFlags).
4242
NoArgs(listTests)
4343
}
4444

@@ -48,10 +48,11 @@ func listTests(ctx context.Context, out io.Writer) error {
4848
RepoCacheDir: inspectFlags.repoCacheDir,
4949
OutFormat: inspectFlags.outFormat,
5050
Modules: inspectFlags.modules,
51+
TestsOptions: inspect.TestsOptions{TestsProfiles: inspectFlags.profiles},
5152
})
5253
}
5354

54-
func cmdTestsFlags(f *pflag.FlagSet) {
55-
f.StringSliceVarP(&inspectFlags.modules, "module", "m", nil, "Names of modules to filter target action by.")
55+
func cmdTestsListFlags(f *pflag.FlagSet) {
5656
f.StringSliceVarP(&inspectFlags.profiles, "profile", "p", nil, `Profile names to activate`)
57+
f.StringSliceVarP(&inspectFlags.modules, "module", "m", nil, "Names of modules to filter target action by.")
5758
}

pkg/skaffold/inspect/tests/list.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ type structureTestEntry struct {
3636

3737
func PrintTestsList(ctx context.Context, out io.Writer, opts inspect.Options) error {
3838
formatter := inspect.OutputFormatter(out, opts.OutFormat)
39-
cfgs, err := inspect.GetConfigSet(ctx, config.SkaffoldOptions{ConfigurationFile: opts.Filename, ConfigurationFilter: opts.Modules, RepoCacheDir: opts.RepoCacheDir})
39+
cfgs, err := inspect.GetConfigSet(ctx, config.SkaffoldOptions{
40+
ConfigurationFile: opts.Filename,
41+
ConfigurationFilter: opts.Modules,
42+
RepoCacheDir: opts.RepoCacheDir,
43+
Profiles: opts.TestsProfiles,
44+
})
4045
if err != nil {
4146
return formatter.WriteErr(err)
4247
}

pkg/skaffold/inspect/types.go

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ type Options struct {
3737
ModulesOptions
3838
ProfilesOptions
3939
BuildEnvOptions
40+
TestsOptions
41+
}
42+
43+
// TestsOptions holds flag values for various `skaffold inspect tests` commands
44+
type TestsOptions struct {
45+
// Profiles is the slice of profile names to activate.
46+
TestsProfiles []string
47+
// Profile is a target profile to create or edit
48+
TestsProfile string
4049
}
4150

4251
// ModulesOptions holds flag values for various `skaffold inspect modules` commands

0 commit comments

Comments
 (0)