github.com/appscode/helm@v3.0.0-alpha.1+incompatible/cmd/helm/history.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 var historyHelp = ` 30 History prints historical revisions for a given release. 31 32 A default maximum of 256 revisions will be returned. Setting '--max' 33 configures the maximum length of the revision list returned. 34 35 The historical release set is printed as a formatted table, e.g: 36 37 $ helm history angry-bird --max=4 38 REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION 39 1 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Initial install 40 2 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Upgraded successfully 41 3 Mon Oct 3 10:15:13 2016 superseded alpine-0.1.0 1.0 Rolled back to 2 42 4 Mon Oct 3 10:15:13 2016 deployed alpine-0.1.0 1.0 Upgraded successfully 43 ` 44 45 func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { 46 client := action.NewHistory(cfg) 47 48 cmd := &cobra.Command{ 49 Use: "history RELEASE_NAME", 50 Long: historyHelp, 51 Short: "fetch release history", 52 Aliases: []string{"hist"}, 53 Args: require.ExactArgs(1), 54 RunE: func(cmd *cobra.Command, args []string) error { 55 history, err := client.Run(args[0]) 56 if err != nil { 57 return err 58 } 59 fmt.Fprintln(out, history) 60 return nil 61 }, 62 } 63 64 f := cmd.Flags() 65 f.StringVarP(&client.OutputFormat, "output", "o", action.Table.String(), "prints the output in the specified format (json|table|yaml)") 66 f.IntVar(&client.Max, "max", 256, "maximum number of revision to include in history") 67 68 return cmd 69 }