MCPcopy
hub / github.com/helm/helm / newReleaseTestCmd

Function newReleaseTestCmd

pkg/cmd/release_testing.go:41–117  ·  view source on GitHub ↗
(cfg *action.Configuration, out io.Writer)

Source from the content-addressed store, hash-verified

39`
40
41func newReleaseTestCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
42 client := action.NewReleaseTesting(cfg)
43 outfmt := output.Table
44 var outputLogs bool
45 var filter []string
46
47 cmd := &cobra.Command{
48 Use: "test [RELEASE]",
49 Short: "run tests for a release",
50 Long: releaseTestHelp,
51 Args: require.ExactArgs(1),
52 ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
53 if len(args) != 0 {
54 return noMoreArgsComp()
55 }
56 return compListReleases(toComplete, args, cfg)
57 },
58 RunE: func(_ *cobra.Command, args []string) (returnError error) {
59 client.Namespace = settings.Namespace()
60 notName := regexp.MustCompile(`^!\s?name=`)
61 for _, f := range filter {
62 if after, ok := strings.CutPrefix(f, "name="); ok {
63 client.Filters[action.IncludeNameFilter] = append(client.Filters[action.IncludeNameFilter], after)
64 } else if notName.MatchString(f) {
65 client.Filters[action.ExcludeNameFilter] = append(client.Filters[action.ExcludeNameFilter], notName.ReplaceAllLiteralString(f, ""))
66 }
67 }
68
69 reli, shutdown, runErr := client.Run(args[0])
70 defer func() {
71 if shutdownErr := shutdown(); shutdownErr != nil {
72 if returnError == nil {
73 returnError = shutdownErr
74 }
75 }
76 }()
77
78 // We only return an error if we weren't even able to get the
79 // release, otherwise we keep going so we can print status and logs
80 // if requested
81 if runErr != nil && reli == nil {
82 return runErr
83 }
84 rel, err := releaserToV1Release(reli)
85 if err != nil {
86 return err
87 }
88
89 if err := outfmt.Write(out, &statusPrinter{
90 release: rel,
91 debug: settings.Debug,
92 showMetadata: false,
93 hideNotes: true,
94 noColor: settings.ShouldDisableColor(),
95 }); err != nil {
96 return err
97 }
98

Callers 2

newRootCmdWithConfigFunction · 0.85

Calls 10

RunMethod · 0.95
GetPodLogsMethod · 0.95
NewReleaseTestingFunction · 0.92
ExactArgsFunction · 0.92
noMoreArgsCompFunction · 0.85
compListReleasesFunction · 0.85
ShouldDisableColorMethod · 0.80
releaserToV1ReleaseFunction · 0.70
NamespaceMethod · 0.65
WriteMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…