Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions cmd/installer/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,43 @@ const (
flagAnnotationTargetValueKubernetes = "kubernetes"
)

// TODO: Remove this and use defaultUsageTemplateV3 when kubernetes support is added
const (
upgradeUsageTemplateV3Linux = `Usage:{{if .Runnable}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}

Aliases:
{{.NameAndAliases}}{{end}}{{if .HasAvailableSubCommands}}{{$cmds := .Commands}}{{if eq (len .Groups) 0}}

Available Commands:{{range $cmds}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{else}}{{range $group := .Groups}}

{{.Title}}{{range $cmds}}{{if (and (eq .GroupID $group.ID) (or .IsAvailableCommand (eq .Name "help")))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if not .AllChildCommandsHaveGroup}}

Additional Commands:{{range $cmds}}{{if (and (eq .GroupID "") (or .IsAvailableCommand (eq .Name "help")))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}{{if (usesTargetFlagMenu .LocalFlags)}}

Flags:
{{(commonFlags .LocalFlags).FlagUsages | trimTrailingWhitespaces}}{{else}}

Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{end}}{{if .HasAvailableInheritedFlags}}

Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasExample}}

Examples:
{{.Example}}{{end}}{{if .HasHelpSubCommands}}

Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}

Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`
)

const (
defaultUsageTemplateV3 = `Usage:{{if .Runnable}}
{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}
Expand Down
44 changes: 44 additions & 0 deletions cmd/installer/cli/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,50 @@ func (r *installReporter) ReportSignalAborted(ctx context.Context, sig os.Signal
r.reporter.ReportSignalAborted(ctx, sig)
}

type upgradeReporter struct {
reporter metrics.ReporterInterface
licenseID string
appSlug string
targetVersion string
initialVersion string
}

func newUpgradeReporter(baseURL string, cmd string, flags []string, licenseID string, clusterID string, appSlug string, targetVersion string, initialVersion string) *upgradeReporter {
executionID := uuid.New().String()
reporter := metrics.NewReporter(executionID, baseURL, clusterID, cmd, flags)
return &upgradeReporter{
reporter: reporter,
licenseID: licenseID,
appSlug: appSlug,
targetVersion: targetVersion,
initialVersion: initialVersion,
}
}

func (ur *upgradeReporter) ReportUpgradeStarted(ctx context.Context) {
ur.reporter.ReportUpgradeStarted(ctx, ur.licenseID, ur.appSlug, ur.targetVersion, ur.initialVersion)
}

func (ur *upgradeReporter) ReportUpgradeSucceeded(ctx context.Context) {
ur.reporter.ReportUpgradeSucceeded(ctx, ur.targetVersion, ur.initialVersion)
}

func (ur *upgradeReporter) ReportUpgradeFailed(ctx context.Context, err error) {
ur.reporter.ReportUpgradeFailed(ctx, err, ur.targetVersion, ur.initialVersion)
}

func (ur *upgradeReporter) ReportPreflightsFailed(ctx context.Context, output *apitypes.PreflightsOutput) {
ur.reporter.ReportHostPreflightsFailed(ctx, output)
}

func (ur *upgradeReporter) ReportPreflightsBypassed(ctx context.Context, output *apitypes.PreflightsOutput) {
ur.reporter.ReportHostPreflightsBypassed(ctx, output)
}

func (ur *upgradeReporter) ReportSignalAborted(ctx context.Context, sig os.Signal) {
ur.reporter.ReportSignalAborted(ctx, sig)
}

type joinReporter struct {
reporter metrics.ReporterInterface
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/installer/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func RootCmd(ctx context.Context) *cobra.Command {
}

cmd.AddCommand(InstallCmd(ctx, appSlug, appTitle))
// The upgrade command should only be visible in V3
if isV3Enabled() {
cmd.AddCommand(UpgradeCmd(ctx, appSlug, appTitle))
}
cmd.AddCommand(JoinCmd(ctx, appSlug, appTitle))
cmd.AddCommand(ShellCmd(ctx, appTitle))
cmd.AddCommand(NodeCmd(ctx, appSlug, appTitle))
Expand Down
Loading
Loading