MCPcopy
hub / github.com/helm/helm / newGetHooksCmd

Function newGetHooksCmd

pkg/cmd/get_hooks.go:37–84  ·  view source on GitHub ↗
(cfg *action.Configuration, out io.Writer)

Source from the content-addressed store, hash-verified

35`
36
37func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
38 client := action.NewGet(cfg)
39
40 cmd := &cobra.Command{
41 Use: "hooks RELEASE_NAME",
42 Short: "download all hooks for a named release",
43 Long: getHooksHelp,
44 Args: require.ExactArgs(1),
45 ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
46 if len(args) != 0 {
47 return noMoreArgsComp()
48 }
49 return compListReleases(toComplete, args, cfg)
50 },
51 RunE: func(_ *cobra.Command, args []string) error {
52 res, err := client.Run(args[0])
53 if err != nil {
54 return err
55 }
56 rac, err := release.NewAccessor(res)
57 if err != nil {
58 return err
59 }
60 for _, hook := range rac.Hooks() {
61 hac, err := release.NewHookAccessor(hook)
62 if err != nil {
63 return err
64 }
65 fmt.Fprintf(out, "---\n# Source: %s\n%s\n", hac.Path(), hac.Manifest())
66 }
67 return nil
68 },
69 }
70
71 cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision")
72 err := cmd.RegisterFlagCompletionFunc("revision", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
73 if len(args) == 1 {
74 return compListRevisions(toComplete, cfg, args[0])
75 }
76 return nil, cobra.ShellCompDirectiveNoFileComp
77 })
78
79 if err != nil {
80 log.Fatal(err)
81 }
82
83 return cmd
84}

Callers 1

newGetCmdFunction · 0.85

Calls 10

RunMethod · 0.95
HooksMethod · 0.95
PathMethod · 0.95
ManifestMethod · 0.95
NewGetFunction · 0.92
ExactArgsFunction · 0.92
noMoreArgsCompFunction · 0.85
compListReleasesFunction · 0.85
compListRevisionsFunction · 0.85
FatalMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…