get.porter.sh/porter@v1.3.0/cmd/porter/logs.go (about)

     1  package main
     2  
     3  import (
     4  	"get.porter.sh/porter/pkg/porter"
     5  	"github.com/spf13/cobra"
     6  )
     7  
     8  func buildInstallationLogCommands(p *porter.Porter) *cobra.Command {
     9  	cmd := &cobra.Command{
    10  		Use:     "logs",
    11  		Aliases: []string{"log"},
    12  		Short:   "Installation Logs commands",
    13  		Long:    "Commands for working with installation logs",
    14  	}
    15  	cmd.Annotations = map[string]string{
    16  		"group": "resource",
    17  	}
    18  
    19  	cmd.AddCommand(buildInstallationLogShowCommand(p))
    20  
    21  	return cmd
    22  }
    23  
    24  func buildInstallationLogShowCommand(p *porter.Porter) *cobra.Command {
    25  	opts := &porter.LogsShowOptions{}
    26  
    27  	cmd := &cobra.Command{
    28  		Use:   "show",
    29  		Short: "Show the logs from an installation",
    30  		Long: `Show the logs from an installation.
    31  
    32  Either display the logs from a specific run of a bundle with --run, or use --installation to display the logs from its most recent run.`,
    33  		Example: `  porter installation logs show --installation wordpress --namespace dev
    34    porter installations logs show --run 01EZSWJXFATDE24XDHS5D5PWK6`,
    35  		PreRunE: func(cmd *cobra.Command, args []string) error {
    36  			return opts.Validate(p.Context)
    37  		},
    38  		RunE: func(cmd *cobra.Command, args []string) error {
    39  			return p.ShowInstallationLogs(cmd.Context(), opts)
    40  		},
    41  	}
    42  
    43  	f := cmd.Flags()
    44  	f.StringVarP(&opts.Namespace, "namespace", "n", "",
    45  		"Namespace in which the installation is defined. Defaults to the global namespace.")
    46  	f.StringVarP(&opts.Name, "installation", "i", "",
    47  		"The installation that generated the logs.")
    48  	f.StringVarP(&opts.RunID, "run", "r", "",
    49  		"The bundle run that generated the logs.")
    50  
    51  	return cmd
    52  }