github.com/werf/3p-helm@v2.8.1+incompatible/cmd/helm/get.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors All rights reserved. 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 "errors" 21 "io" 22 23 "github.com/spf13/cobra" 24 25 "k8s.io/helm/pkg/helm" 26 ) 27 28 var getHelp = ` 29 This command shows the details of a named release. 30 31 It can be used to get extended information about the release, including: 32 33 - The values used to generate the release 34 - The chart used to generate the release 35 - The generated manifest file 36 37 By default, this prints a human readable collection of information about the 38 chart, the supplied values, and the generated manifest file. 39 ` 40 41 var errReleaseRequired = errors.New("release name is required") 42 43 type getCmd struct { 44 release string 45 out io.Writer 46 client helm.Interface 47 version int32 48 } 49 50 func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command { 51 get := &getCmd{ 52 out: out, 53 client: client, 54 } 55 56 cmd := &cobra.Command{ 57 Use: "get [flags] RELEASE_NAME", 58 Short: "download a named release", 59 Long: getHelp, 60 PreRunE: setupConnection, 61 RunE: func(cmd *cobra.Command, args []string) error { 62 if len(args) == 0 { 63 return errReleaseRequired 64 } 65 get.release = args[0] 66 if get.client == nil { 67 get.client = newClient() 68 } 69 return get.run() 70 }, 71 } 72 73 cmd.Flags().Int32Var(&get.version, "revision", 0, "get the named release with revision") 74 75 cmd.AddCommand(addFlagsTLS(newGetValuesCmd(nil, out))) 76 cmd.AddCommand(addFlagsTLS(newGetManifestCmd(nil, out))) 77 cmd.AddCommand(addFlagsTLS(newGetHooksCmd(nil, out))) 78 79 return cmd 80 } 81 82 // getCmd is the command that implements 'helm get' 83 func (g *getCmd) run() error { 84 res, err := g.client.ReleaseContent(g.release, helm.ContentReleaseVersion(g.version)) 85 if err != nil { 86 return prettyError(err) 87 } 88 return printRelease(g.out, res.Release) 89 }