Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ vendor/
.claude
do-not-commit/
pkg/tools/embedded/
docs/plans/
10 changes: 3 additions & 7 deletions cli/cmd/app_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ type createAppOpts struct {

func (r *runners) InitAppCreate(parent *cobra.Command) *cobra.Command {
opts := createAppOpts{}
var outputFormat string

cmd := &cobra.Command{
Use: "create NAME",
Short: "Create a new application",
Expand All @@ -44,17 +42,15 @@ replicated app create "Custom App" --output table`,
return errors.New("missing app name")
}
opts.name = args[0]
return r.createApp(ctx, cmd, opts, outputFormat)
return r.createApp(ctx, cmd, opts)
},
SilenceUsage: true,
}
parent.AddCommand(cmd)
cmd.Flags().StringVarP(&outputFormat, "output", "o", "table", "The output format to use. One of: json|table")

return cmd
}

func (r *runners) createApp(ctx context.Context, cmd *cobra.Command, opts createAppOpts, outputFormat string) error {
func (r *runners) createApp(ctx context.Context, cmd *cobra.Command, opts createAppOpts) error {
kotsRestClient := kotsclient.VendorV3Client{
HTTPClient: *r.platformAPI,
}
Expand All @@ -75,5 +71,5 @@ func (r *runners) createApp(ctx context.Context, cmd *cobra.Command, opts create
},
}

return print.Apps(outputFormat, r.w, apps)
return print.Apps(r.outputFormat, r.w, apps)
}
16 changes: 6 additions & 10 deletions cli/cmd/app_hostname_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
)

func (r *runners) InitAppHostnameListCommand(parent *cobra.Command) *cobra.Command {
var outputFormat string

cmd := &cobra.Command{
Use: "ls",
Aliases: []string{"list"},
Expand Down Expand Up @@ -65,20 +63,18 @@ replicated app hostname ls --app myapp --output json`,
},
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
return r.listAppHostnames(ctx, outputFormat)
return r.listAppHostnames(ctx)
},
SilenceUsage: true,
}
parent.AddCommand(cmd)

cmd.Flags().StringVarP(&outputFormat, "output", "o", "table", "The output format to use. One of: json|table")

return cmd
}

func (r *runners) listAppHostnames(ctx context.Context, outputFormat string) error {
func (r *runners) listAppHostnames(ctx context.Context) error {
// Only show spinners for table output
showSpinners := outputFormat == "table"
showSpinners := r.outputFormat == "table"
log := logger.NewLogger(r.w).SetIsTerminal(r.stdoutIsTTY)

// Resolve app ID from slug or ID
Expand Down Expand Up @@ -141,7 +137,7 @@ func (r *runners) listAppHostnames(ctx context.Context, outputFormat string) err
hostnameStrings := extractHostnameStrings(mergedHostnames)

// Output based on format
if outputFormat == "json" {
if r.outputFormat == "json" {
jsonBytes, err := json.MarshalIndent(hostnameStrings, "", " ")
if err != nil {
return errors.Wrap(err, "marshal json")
Expand All @@ -153,11 +149,11 @@ func (r *runners) listAppHostnames(ctx context.Context, outputFormat string) err
return nil
}

if outputFormat == "table" {
if r.outputFormat == "table" {
return printHostnamesTable(r.w, hostnameStrings)
}

return errors.Errorf("unsupported output format: %s", outputFormat)
return errors.Errorf("unsupported output format: %s", r.outputFormat)
}

// extractHostnameStrings extracts just the hostname strings from the merged hostnames
Expand Down
12 changes: 4 additions & 8 deletions cli/cmd/app_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
)

func (r *runners) InitAppList(parent *cobra.Command) *cobra.Command {
var outputFormat string

cmd := &cobra.Command{
Use: "ls [NAME]",
Aliases: []string{"list"},
Expand All @@ -39,24 +37,22 @@ replicated app ls --output json
replicated app ls "App Name" --output table`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := context.Background()
return r.listApps(ctx, cmd, args, outputFormat)
return r.listApps(ctx, cmd, args)
},
SilenceUsage: true,
}
parent.AddCommand(cmd)
cmd.Flags().StringVarP(&outputFormat, "output", "o", "table", "The output format to use. One of: json|table")

return cmd
}

func (r *runners) listApps(ctx context.Context, cmd *cobra.Command, args []string, outputFormat string) error {
func (r *runners) listApps(ctx context.Context, cmd *cobra.Command, args []string) error {
kotsApps, err := r.kotsAPI.ListApps(ctx, false)
if err != nil {
return errors.Wrap(err, "list apps")
}

if len(args) == 0 {
return print.Apps(outputFormat, r.w, kotsApps)
return print.Apps(r.outputFormat, r.w, kotsApps)
}

appSearch := args[0]
Expand All @@ -66,5 +62,5 @@ func (r *runners) listApps(ctx context.Context, cmd *cobra.Command, args []strin
resultApps = append(resultApps, app)
}
}
return print.Apps(outputFormat, r.w, resultApps)
return print.Apps(r.outputFormat, r.w, resultApps)
}
11 changes: 4 additions & 7 deletions cli/cmd/app_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ type deleteAppOpts struct {

func (r *runners) InitAppRm(parent *cobra.Command) *cobra.Command {
opts := deleteAppOpts{}
var outputFormat string

cmd := &cobra.Command{
Use: "rm NAME",
Aliases: []string{"delete"},
Expand All @@ -42,20 +40,19 @@ replicated app delete "Custom App" --output json`,
if len(args) != 1 {
return errors.New("missing app slug or id")
}
return r.deleteApp(ctx, cmd, args[0], opts, outputFormat)
return r.deleteApp(ctx, cmd, args[0], opts)
},
SilenceUsage: true,
}
parent.AddCommand(cmd)
cmd.Flags().BoolVarP(&opts.force, "force", "f", false, "Skip confirmation prompt. There is no undo for this action.")
cmd.Flags().StringVarP(&outputFormat, "output", "o", "table", "The output format to use. One of: json|table")

return cmd
}

func (r *runners) deleteApp(ctx context.Context, cmd *cobra.Command, appName string, opts deleteAppOpts, outputFormat string) error {
func (r *runners) deleteApp(ctx context.Context, cmd *cobra.Command, appName string, opts deleteAppOpts) error {
log := logger.NewLogger(r.w).SetIsTerminal(r.stdoutIsTTY)
showSpinners := outputFormat == "table"
showSpinners := r.outputFormat == "table"

if showSpinners {
log.ActionWithSpinner("Fetching App")
Expand All @@ -77,7 +74,7 @@ func (r *runners) deleteApp(ctx context.Context, cmd *cobra.Command, appName str
},
}

err = print.Apps(outputFormat, r.w, apps)
err = print.Apps(r.outputFormat, r.w, apps)
if err != nil {
return errors.Wrap(err, "print app")
}
Expand Down
9 changes: 5 additions & 4 deletions cli/cmd/channel_adoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (

func (r *runners) InitChannelAdoption(parent *cobra.Command) {
cmd := &cobra.Command{
Use: "adoption CHANNEL_ID",
Short: "Print channel adoption statistics by license type",
Long: "Print channel adoption statistics by license type",
Use: "adoption CHANNEL_ID",
Short: "Print channel adoption statistics by license type",
Long: "Print channel adoption statistics by license type",
SilenceUsage: true,
}
cmd.Hidden = true // Not supported in KOTS
parent.AddCommand(cmd)
Expand All @@ -34,7 +35,7 @@ func (r *runners) channelAdoption(cmd *cobra.Command, args []string) error {
return err
}

if err = print.ChannelAdoption(r.w, appChan.Adoption); err != nil {
if err = print.ChannelAdoption(r.outputFormat, r.w, appChan.Adoption); err != nil {
return err
}

Expand Down
9 changes: 5 additions & 4 deletions cli/cmd/channel_counts.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (

func (r *runners) InitChannelCounts(parent *cobra.Command) {
cmd := &cobra.Command{
Use: "counts CHANNEL_ID",
Short: "Print channel license counts",
Long: "Print channel license counts",
Use: "counts CHANNEL_ID",
Short: "Print channel license counts",
Long: "Print channel license counts",
SilenceUsage: true,
}
cmd.Hidden = true // Not supported in KOTS
parent.AddCommand(cmd)
Expand All @@ -34,7 +35,7 @@ func (r *runners) channelCounts(cmd *cobra.Command, args []string) error {
return err
}

if err = print.LicenseCounts(r.w, appChan.LicenseCounts); err != nil {
if err = print.LicenseCounts(r.outputFormat, r.w, appChan.LicenseCounts); err != nil {
return err
}
} else if r.appType == "kots" {
Expand Down
1 change: 0 additions & 1 deletion cli/cmd/channel_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func (r *runners) InitChannelCreate(parent *cobra.Command) {

cmd.Flags().StringVar(&r.args.channelCreateName, "name", "", "The name of this channel")
cmd.Flags().StringVar(&r.args.channelCreateDescription, "description", "", "A longer description of this channel")
cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table")

cmd.RunE = r.channelCreate
}
Expand Down
1 change: 0 additions & 1 deletion cli/cmd/channel_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func (r *runners) InitChannelInspect(parent *cobra.Command) {
Long: "Show full details for a channel",
}
parent.AddCommand(cmd)
cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table")

cmd.RunE = r.channelInspect
}
Expand Down
1 change: 0 additions & 1 deletion cli/cmd/channel_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func (r *runners) InitChannelList(parent *cobra.Command) {
}

parent.AddCommand(cmd)
cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table")

cmd.RunE = r.channelList
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/channel_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ replicated channel releases Stable --output json
replicated channel releases Stable --page 1 --page-size 50`,
}
parent.AddCommand(cmd)
cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table")

cmd.Flags().IntVar(&r.args.channelReleasesPage, "page", 0, "The page to fetch (KOTS apps only).")
cmd.Flags().IntVar(&r.args.channelReleasesPageSize, "page-size", 0, "The number of releases per page (KOTS apps only).")

Expand Down
3 changes: 1 addition & 2 deletions cli/cmd/cluster_addon_create_objectstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func (r *runners) clusterAddonCreateObjectStoreFlags(cmd *cobra.Command) error {
}
cmd.Flags().DurationVar(&r.args.clusterAddonCreateObjectStoreDuration, "wait", 0, "Wait duration for add-on to be ready before exiting (leave empty to not wait)")
cmd.Flags().BoolVar(&r.args.clusterAddonCreateObjectStoreDryRun, "dry-run", false, "Simulate creation to verify that your inputs are valid without actually creating an add-on")
cmd.Flags().StringVarP(&r.args.clusterAddonCreateObjectStoreOutput, "output", "o", "table", "The output format to use. One of: json|table|wide")
return nil
}

Expand All @@ -86,7 +85,7 @@ func (r *runners) clusterAddonCreateObjectStoreCreateRun() error {
return err
}

return print.Addon(r.args.clusterAddonCreateObjectStoreOutput, r.w, addon)
return print.Addon(r.outputFormat, r.w, addon)
}

func (r *runners) createAndWaitForClusterAddonCreateObjectStore(opts kotsclient.CreateClusterAddonObjectStoreOpts, waitDuration time.Duration) (*types.ClusterAddon, error) {
Expand Down
21 changes: 5 additions & 16 deletions cli/cmd/cluster_addon_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
)

type clusterAddonLsArgs struct {
clusterID string
outputFormat string
clusterID string
}

func (r *runners) InitClusterAddonLs(parent *cobra.Command) *cobra.Command {
Expand All @@ -31,30 +30,20 @@ replicated cluster addon ls CLUSTER_ID_OR_NAME --output wide`,
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, cmdArgs []string) error {
args.clusterID = cmdArgs[0]
return r.addonClusterLsRun(args)
return r.addonClusterLsRun(args.clusterID)
},
ValidArgsFunction: r.completeClusterIDs,
}
parent.AddCommand(cmd)

err := clusterAddonLsFlags(cmd, &args)
if err != nil {
panic(err)
}

return cmd
}

func clusterAddonLsFlags(cmd *cobra.Command, args *clusterAddonLsArgs) error {
cmd.Flags().StringVarP(&args.outputFormat, "output", "o", "table", "The output format to use. One of: json|table|wide")
return nil
}

func (r *runners) addonClusterLsRun(args clusterAddonLsArgs) error {
addons, err := r.kotsAPI.ListClusterAddons(args.clusterID)
func (r *runners) addonClusterLsRun(clusterID string) error {
addons, err := r.kotsAPI.ListClusterAddons(clusterID)
if err != nil {
return err
}

return print.Addons(args.outputFormat, r.w, addons, true)
return print.Addons(r.outputFormat, r.w, addons, true)
}
3 changes: 0 additions & 3 deletions cli/cmd/cluster_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ replicated cluster create --distribution eks --version 1.21 --nodes 3 --addon ob

cmd.Flags().BoolVar(&r.args.createClusterDryRun, "dry-run", false, "Dry run")

cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table|wide")

_ = cmd.MarkFlagRequired("distribution")

return cmd
Expand Down Expand Up @@ -205,7 +203,6 @@ func (r *runners) createAndWaitForAddons(clusterID string) error {
r.args.clusterAddonCreateObjectStoreClusterID = clusterID
r.args.clusterAddonCreateObjectStoreDryRun = r.args.createClusterDryRun
r.args.clusterAddonCreateObjectStoreDuration = r.args.createClusterWaitDuration
r.args.clusterAddonCreateObjectStoreOutput = r.outputFormat

err := r.clusterAddonCreateObjectStoreCreateRun()
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion cli/cmd/cluster_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ replicated cluster ls --output wide`,
cmd.Flags().BoolVar(&r.args.lsClusterShowTerminated, "show-terminated", false, "when set, only show terminated clusters")
cmd.Flags().StringVar(&r.args.lsClusterStartTime, "start-time", "", "start time for the query (Format: 2006-01-02T15:04:05Z)")
cmd.Flags().StringVar(&r.args.lsClusterEndTime, "end-time", "", "end time for the query (Format: 2006-01-02T15:04:05Z)")
cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table|wide")
cmd.Flags().BoolVarP(&r.args.lsClusterWatch, "watch", "w", false, "watch clusters")

return cmd
Expand Down
2 changes: 0 additions & 2 deletions cli/cmd/cluster_nodegroup_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ replicated cluster nodegroup ls CLUSTER_ID_OR_NAME --output wide`,
}
parent.AddCommand(cmd)

cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table|wide")

return cmd
}

Expand Down
1 change: 0 additions & 1 deletion cli/cmd/cluster_port_expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ replicated cluster port expose CLUSTER_ID_OR_NAME --port 8080 --protocol https -
}
cmd.Flags().StringSliceVar(&r.args.clusterExposePortProtocols, "protocol", []string{"http", "https"}, `Protocol to expose (valid values are "http", "https", "ws" and "wss")`)
cmd.Flags().BoolVar(&r.args.clusterExposePortIsWildcard, "wildcard", false, "Create a wildcard DNS entry and TLS certificate for this port")
cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table|wide")

return cmd
}
Expand Down
2 changes: 0 additions & 2 deletions cli/cmd/cluster_port_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ replicated cluster port ls CLUSTER_ID_OR_NAME --output wide`,
}
parent.AddCommand(cmd)

cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table|wide")

return cmd
}

Expand Down
1 change: 0 additions & 1 deletion cli/cmd/cluster_port_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ replicated cluster port rm CLUSTER_ID_OR_NAME --id PORT_ID --output json`,
parent.AddCommand(cmd)

cmd.Flags().StringVar(&r.args.clusterPortRemoveAddonID, "id", "", "ID of the port to remove (required)")
cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table|wide")

// Deprecated flags
cmd.Flags().IntVar(&r.args.clusterPortRemovePort, "port", 0, "Port to remove")
Expand Down
2 changes: 0 additions & 2 deletions cli/cmd/cluster_update_nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ replicated cluster update nodegroup CLUSTER_ID_OR_NAME --nodegroup-id NODEGROUP_
cmd.Flags().StringVar(&r.args.updateClusterNodeGroupMinCount, "min-nodes", "", "The minimum number of nodes in the nodegroup")
cmd.Flags().StringVar(&r.args.updateClusterNodeGroupMaxCount, "max-nodes", "", "The maximum number of nodes in the nodegroup")

cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table|wide")

return cmd
}

Expand Down
1 change: 0 additions & 1 deletion cli/cmd/cluster_update_ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ replicated cluster update ttl CLUSTER_ID_OR_NAME --ttl 24h`,
parent.AddCommand(cmd)

cmd.Flags().StringVar(&r.args.updateClusterTTL, "ttl", "", "Update TTL which starts from the moment the cluster is running (duration, max 48h).")
cmd.Flags().StringVarP(&r.outputFormat, "output", "o", "table", "The output format to use. One of: json|table")

cmd.MarkFlagRequired("ttl")

Expand Down
Loading