Skip to content

Commit

Permalink
Add helm-install and kurl-install to customer update
Browse files Browse the repository at this point in the history
  • Loading branch information
divolgin committed Jan 17, 2025
1 parent 39ff9b7 commit b5228d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cli/cmd/customer_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ type updateCustomerOpts struct {
IsDeveloperModeEnabled bool
Email string
Type string
IsHelmInstallEnabled bool
IsKurlInstallEnabled bool
}

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

cmd := &cobra.Command{
Use: "update --customer <id> --name <name> [options]",
Expand Down Expand Up @@ -66,7 +67,7 @@ func (r *runners) InitCustomerUpdateCommand(parent *cobra.Command) *cobra.Comman
# Update a customer and output the result in JSON format
replicated customer update --customer cus_abcdef123456 --name "JSON Corp" --output json`,
RunE: func(cmd *cobra.Command, args []string) error {
return r.updateCustomer(cmd, opts, outputFormat)
return r.updateCustomer(cmd, opts)
},
SilenceUsage: false,
SilenceErrors: false,
Expand All @@ -85,6 +86,8 @@ func (r *runners) InitCustomerUpdateCommand(parent *cobra.Command) *cobra.Comman
cmd.Flags().BoolVar(&opts.IsGitopsSupported, "gitops", false, "If set, the license will allow the GitOps usage.")
cmd.Flags().BoolVar(&opts.IsSnapshotSupported, "snapshot", false, "If set, the license will allow Snapshots.")
cmd.Flags().BoolVar(&opts.IsKotsInstallEnabled, "kots-install", true, "If set, the license will allow KOTS install. Otherwise license will allow Helm CLI installs only.")
cmd.Flags().BoolVar(&opts.IsHelmInstallEnabled, "helm-install", false, "If set, the license will allow Helm installs.")
cmd.Flags().BoolVar(&opts.IsKurlInstallEnabled, "kurl-install", false, "If set, the license will allow kURL installs.")
cmd.Flags().BoolVar(&opts.IsEmbeddedClusterEnabled, "embedded-cluster-download", false, "If set, the license will allow embedded cluster downloads.")
cmd.Flags().BoolVar(&opts.IsGeoaxisSupported, "geo-axis", false, "If set, the license will allow Geo Axis usage.")
cmd.Flags().BoolVar(&opts.IsHelmVMDownloadEnabled, "helmvm-cluster-download", false, "If set, the license will allow helmvm cluster downloads.")
Expand All @@ -93,7 +96,7 @@ func (r *runners) InitCustomerUpdateCommand(parent *cobra.Command) *cobra.Comman
cmd.Flags().BoolVar(&opts.IsDeveloperModeEnabled, "developer-mode", false, "If set, Replicated SDK installed in dev mode will use mock data.")
cmd.Flags().StringVar(&opts.Email, "email", "", "Email address of the customer that is to be updated.")
cmd.Flags().StringVar(&opts.Type, "type", "dev", "The license type to update. One of: dev|trial|paid|community|test (default: dev)")
cmd.Flags().StringVar(&outputFormat, "output", "table", "The output format to use. One of: json|table (default: table)")
cmd.Flags().StringVar(&r.outputFormat, "output", "table", "The output format to use. One of: json|table (default: table)")

cmd.MarkFlagRequired("customer")
cmd.MarkFlagRequired("channel")
Expand All @@ -102,7 +105,7 @@ func (r *runners) InitCustomerUpdateCommand(parent *cobra.Command) *cobra.Comman
return cmd
}

func (r *runners) updateCustomer(cmd *cobra.Command, opts updateCustomerOpts, outputFormat string) (err error) {
func (r *runners) updateCustomer(cmd *cobra.Command, opts updateCustomerOpts) (err error) {
defer func() {
printIfError(cmd, err)
}()
Expand Down Expand Up @@ -193,12 +196,19 @@ func (r *runners) updateCustomer(cmd *cobra.Command, opts updateCustomerOpts, ou
Email: opts.Email,
}

if cmd.Flags().Changed("helm-install") {
updateOpts.IsHelmInstallEnabled = &opts.IsHelmInstallEnabled
}
if cmd.Flags().Changed("kurl-install") {
updateOpts.IsKurlInstallEnabled = &opts.IsKurlInstallEnabled
}

customer, err := r.api.UpdateCustomer(r.appType, opts.CustomerID, updateOpts)
if err != nil {
return errors.Wrap(err, "update customer")
}

err = print.Customer(outputFormat, r.w, customer)
err = print.Customer(r.outputFormat, r.w, customer)
if err != nil {
return errors.Wrap(err, "print customer")
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/kotsclient/customer_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type UpdateCustomerRequest struct {
IsGitopsSupported bool `json:"is_gitops_supported"`
IsSnapshotSupported bool `json:"is_snapshot_supported"`
IsKotsInstallEnabled bool `json:"is_kots_install_enabled"`
IsHelmInstallEnabled *bool `json:"is_helm_install_enabled,omitempty"`
IsKurlInstallEnabled *bool `json:"is_kurl_install_enabled,omitempty"`
IsEmbeddedClusterDownloadEnabled bool `json:"is_embedded_cluster_download_enabled"`
IsGeoaxisSupported bool `json:"is_geoaxis_supported"`
IsHelmVMDownloadEnabled bool `json:"is_helm_vm_download_enabled"`
Expand All @@ -46,6 +48,8 @@ type UpdateCustomerOpts struct {
IsGitopsSupported bool
IsSnapshotSupported bool
IsKotsInstallEnabled bool
IsHelmInstallEnabled *bool
IsKurlInstallEnabled *bool
IsEmbeddedClusterDownloadEnabled bool
IsGeoaxisSupported bool
IsHelmVMDownloadEnabled bool
Expand All @@ -68,6 +72,8 @@ func (c *VendorV3Client) UpdateCustomer(customerID string, opts UpdateCustomerOp
IsGitopsSupported: opts.IsGitopsSupported,
IsSnapshotSupported: opts.IsSnapshotSupported,
IsKotsInstallEnabled: opts.IsKotsInstallEnabled,
IsHelmInstallEnabled: opts.IsHelmInstallEnabled,
IsKurlInstallEnabled: opts.IsKurlInstallEnabled,
IsEmbeddedClusterDownloadEnabled: opts.IsEmbeddedClusterDownloadEnabled,
IsGeoaxisSupported: opts.IsGeoaxisSupported,
IsHelmVMDownloadEnabled: opts.IsHelmVMDownloadEnabled,
Expand Down

0 comments on commit b5228d1

Please sign in to comment.