github.com/liuming-dev/helm@v3.0.0-beta.3+incompatible/cmd/helm/list.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 listHelp = ` 30 This command lists all of the releases. 31 32 By default, it lists only releases that are deployed or failed. Flags like 33 '--uninstalled' and '--all' will alter this behavior. Such flags can be combined: 34 '--uninstalled --failed'. 35 36 By default, items are sorted alphabetically. Use the '-d' flag to sort by 37 release date. 38 39 If the --filter flag is provided, it will be treated as a filter. Filters are 40 regular expressions (Perl compatible) that are applied to the list of releases. 41 Only items that match the filter will be returned. 42 43 $ helm list --filter 'ara[a-z]+' 44 NAME UPDATED CHART 45 maudlin-arachnid Mon May 9 16:07:08 2016 alpine-0.1.0 46 47 If no results are found, 'helm list' will exit 0, but with no output (or in 48 the case of no '-q' flag, only headers). 49 50 By default, up to 256 items may be returned. To limit this, use the '--max' flag. 51 Setting '--max' to 0 will not return all results. Rather, it will return the 52 server's default, which may be much higher than 256. Pairing the '--max' 53 flag with the '--offset' flag allows you to page through results. 54 ` 55 56 func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { 57 client := action.NewList(cfg) 58 59 cmd := &cobra.Command{ 60 Use: "list", 61 Short: "list releases", 62 Long: listHelp, 63 Aliases: []string{"ls"}, 64 Args: require.NoArgs, 65 RunE: func(cmd *cobra.Command, args []string) error { 66 if client.AllNamespaces { 67 initActionConfig(cfg, true) 68 } 69 client.SetStateMask() 70 71 results, err := client.Run() 72 73 if client.Short { 74 for _, res := range results { 75 fmt.Fprintln(out, res.Name) 76 } 77 return err 78 } 79 80 fmt.Fprintln(out, action.FormatList(results)) 81 return err 82 }, 83 } 84 85 f := cmd.Flags() 86 f.BoolVarP(&client.Short, "short", "q", false, "output short (quiet) listing format") 87 f.BoolVarP(&client.ByDate, "date", "d", false, "sort by release date") 88 f.BoolVarP(&client.SortReverse, "reverse", "r", false, "reverse the sort order") 89 f.BoolVarP(&client.All, "all", "a", false, "show all releases, not just the ones marked deployed or failed") 90 f.BoolVar(&client.Uninstalled, "uninstalled", false, "show uninstalled releases") 91 f.BoolVar(&client.Superseded, "superseded", false, "show superseded releases") 92 f.BoolVar(&client.Uninstalling, "uninstalling", false, "show releases that are currently being uninstalled") 93 f.BoolVar(&client.Deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled") 94 f.BoolVar(&client.Failed, "failed", false, "show failed releases") 95 f.BoolVar(&client.Pending, "pending", false, "show pending releases") 96 f.BoolVar(&client.AllNamespaces, "all-namespaces", false, "list releases across all namespaces") 97 f.IntVarP(&client.Limit, "max", "m", 256, "maximum number of releases to fetch") 98 f.IntVarP(&client.Offset, "offset", "o", 0, "next release name in the list, used to offset from start value") 99 f.StringVarP(&client.Filter, "filter", "f", "", "a regular expression (Perl compatible). Any releases that match the expression will be included in the results") 100 101 return cmd 102 }