gitlab.azmi.pl/azmi-open-source/helm@v3.0.0-beta.3+incompatible/cmd/helm/show.go (about) 1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "fmt" 21 "io" 22 23 "github.com/spf13/cobra" 24 25 "helm.sh/helm/cmd/helm/require" 26 "helm.sh/helm/pkg/action" 27 ) 28 29 const showDesc = ` 30 This command inspects a chart and displays information. It takes a chart reference 31 ('example/drupal'), a full path to a directory or packaged chart, or a URL. 32 33 Inspect prints the contents of the Chart.yaml file and the values.yaml file. 34 ` 35 36 const showValuesDesc = ` 37 This command inspects a chart (directory, file, or URL) and displays the contents 38 of the values.yaml file 39 ` 40 41 const showChartDesc = ` 42 This command inspects a chart (directory, file, or URL) and displays the contents 43 of the Charts.yaml file 44 ` 45 46 const readmeChartDesc = ` 47 This command inspects a chart (directory, file, or URL) and displays the contents 48 of the README file 49 ` 50 51 func newShowCmd(out io.Writer) *cobra.Command { 52 client := action.NewShow(action.ShowAll) 53 54 showCommand := &cobra.Command{ 55 Use: "show [CHART]", 56 Short: "inspect a chart", 57 Aliases: []string{"inspect"}, 58 Long: showDesc, 59 Args: require.ExactArgs(1), 60 RunE: func(cmd *cobra.Command, args []string) error { 61 cp, err := client.ChartPathOptions.LocateChart(args[0], settings) 62 if err != nil { 63 return err 64 } 65 output, err := client.Run(cp) 66 if err != nil { 67 return err 68 } 69 fmt.Fprint(out, output) 70 return nil 71 }, 72 } 73 74 valuesSubCmd := &cobra.Command{ 75 Use: "values [CHART]", 76 Short: "shows values for this chart", 77 Long: showValuesDesc, 78 Args: require.ExactArgs(1), 79 RunE: func(cmd *cobra.Command, args []string) error { 80 client.OutputFormat = action.ShowValues 81 cp, err := client.ChartPathOptions.LocateChart(args[0], settings) 82 if err != nil { 83 return err 84 } 85 output, err := client.Run(cp) 86 if err != nil { 87 return err 88 } 89 fmt.Fprint(out, output) 90 return nil 91 }, 92 } 93 94 chartSubCmd := &cobra.Command{ 95 Use: "chart [CHART]", 96 Short: "shows the chart", 97 Long: showChartDesc, 98 Args: require.ExactArgs(1), 99 RunE: func(cmd *cobra.Command, args []string) error { 100 client.OutputFormat = action.ShowChart 101 cp, err := client.ChartPathOptions.LocateChart(args[0], settings) 102 if err != nil { 103 return err 104 } 105 output, err := client.Run(cp) 106 if err != nil { 107 return err 108 } 109 fmt.Fprint(out, output) 110 return nil 111 }, 112 } 113 114 readmeSubCmd := &cobra.Command{ 115 Use: "readme [CHART]", 116 Short: "shows the chart's README", 117 Long: readmeChartDesc, 118 Args: require.ExactArgs(1), 119 RunE: func(cmd *cobra.Command, args []string) error { 120 client.OutputFormat = action.ShowReadme 121 cp, err := client.ChartPathOptions.LocateChart(args[0], settings) 122 if err != nil { 123 return err 124 } 125 output, err := client.Run(cp) 126 if err != nil { 127 return err 128 } 129 fmt.Fprint(out, output) 130 return nil 131 }, 132 } 133 134 cmds := []*cobra.Command{showCommand, readmeSubCmd, valuesSubCmd, chartSubCmd} 135 for _, subCmd := range cmds { 136 addChartPathOptionsFlags(subCmd.Flags(), &client.ChartPathOptions) 137 } 138 139 for _, subCmd := range cmds[1:] { 140 showCommand.AddCommand(subCmd) 141 } 142 143 return showCommand 144 }