-
Notifications
You must be signed in to change notification settings - Fork 199
/
logs.go
50 lines (41 loc) · 1.37 KB
/
logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"get.porter.sh/porter/pkg/porter"
"github.com/spf13/cobra"
)
func buildInstallationLogCommands(p *porter.Porter) *cobra.Command {
cmd := &cobra.Command{
Use: "logs",
Aliases: []string{"log"},
Short: "Installation Logs commands",
Long: "Commands for working with installation logs",
}
cmd.Annotations = map[string]string{
"group": "resource",
}
cmd.AddCommand(buildInstallationLogShowCommand(p))
return cmd
}
func buildInstallationLogShowCommand(p *porter.Porter) *cobra.Command {
opts := &porter.LogsShowOptions{}
cmd := &cobra.Command{
Use: "show",
Short: "Show the logs from an installation",
Long: `Show the logs from an installation.
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.`,
Example: ` porter installation logs show --installation wordpress
porter installations logs show --run 01EZSWJXFATDE24XDHS5D5PWK6`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return opts.Validate(p.Context)
},
RunE: func(cmd *cobra.Command, args []string) error {
return p.ShowInstallationLogs(opts)
},
}
f := cmd.Flags()
f.StringVarP(&opts.Name, "installation", "i", "",
"The installation that generated the logs.")
f.StringVarP(&opts.ClaimID, "run", "r", "",
"The bundle run that generated the logs.")
return cmd
}