diff --git a/pkg/apis/noobaa/v1alpha1/noobaaaccount_types.go b/pkg/apis/noobaa/v1alpha1/noobaaaccount_types.go index e54b35969d..603c4dd53a 100644 --- a/pkg/apis/noobaa/v1alpha1/noobaaaccount_types.go +++ b/pkg/apis/noobaa/v1alpha1/noobaaaccount_types.go @@ -69,7 +69,7 @@ type NooBaaAccountSpec struct { // ForceMd5Etag specifies whether MD5 Etags should be calculated for the account or not // +optional - ForceMd5Etag bool `json:"force_md5_etag,omitempty"` + ForceMd5Etag *bool `json:"force_md5_etag,omitempty"` } // AccountNsfsConfig is the configuration of NSFS of CreateAccountParams diff --git a/pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go index 926afca48e..0cccbe7a8f 100644 --- a/pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go @@ -983,6 +983,11 @@ func (in *NooBaaAccountSpec) DeepCopyInto(out *NooBaaAccountSpec) { *out = new(AccountNsfsConfig) **out = **in } + if in.ForceMd5Etag != nil { + in, out := &in.ForceMd5Etag, &out.ForceMd5Etag + *out = new(bool) + **out = **in + } return } diff --git a/pkg/nb/types.go b/pkg/nb/types.go index c39831f2f3..311277f2fa 100644 --- a/pkg/nb/types.go +++ b/pkg/nb/types.go @@ -589,7 +589,7 @@ type UpdateAccountS3AccessParams struct { Email string `json:"email"` S3Access bool `json:"s3_access"` DefaultResource *string `json:"default_resource,omitempty"` - ForceMd5Etag bool `json:"force_md5_etag,omitempty"` + ForceMd5Etag *bool `json:"force_md5_etag,omitempty"` AllowBucketCreation *bool `json:"allow_bucket_creation,omitempty"` NsfsAccountConfig *nbv1.AccountNsfsConfig `json:"nsfs_account_config,omitempty"` } diff --git a/pkg/noobaaaccount/noobaaaccount.go b/pkg/noobaaaccount/noobaaaccount.go index 40a388f495..cd7f6ea7ef 100644 --- a/pkg/noobaaaccount/noobaaaccount.go +++ b/pkg/noobaaaccount/noobaaaccount.go @@ -72,6 +72,7 @@ func CmdUpdate() *cobra.Command { Run: RunUpdate, } cmd.Flags().String("new_default_resource", "", "(must be provided) update the default resource on which new buckets will be created") + cmd.Flags().Bool("force_md5_etag", false, "This flag enables md5 etag calculation for account") return cmd } @@ -178,7 +179,7 @@ func RunCreate(cmd *cobra.Command, args []string) { noobaaAccount.Name = name noobaaAccount.Namespace = options.Namespace noobaaAccount.Spec.AllowBucketCreate = allowBucketCreate - noobaaAccount.Spec.ForceMd5Etag = forceMd5Etag + noobaaAccount.Spec.ForceMd5Etag = &forceMd5Etag if nsfsAccountConfig { nsfsUID := util.GetFlagIntOrPrompt(cmd, "uid") @@ -252,7 +253,11 @@ func RunUpdate(cmd *cobra.Command, args []string) { name := args[0] newDefaultResource := util.GetFlagStringOrPrompt(cmd, "new_default_resource") - forceMd5Etag, _ := cmd.Flags().GetBool("force_md5_etag") + var forceMd5EtagPtr *bool = nil + if cmd.Flags().Changed("force_md5_etag") { + forceMd5Etag, _ := cmd.Flags().GetBool("force_md5_etag") + forceMd5EtagPtr = &forceMd5Etag + } o := util.KubeObject(bundle.File_deploy_crds_noobaa_io_v1alpha1_noobaaaccount_cr_yaml) noobaaAccount := o.(*nbv1.NooBaaAccount) @@ -280,7 +285,7 @@ func RunUpdate(cmd *cobra.Command, args []string) { } noobaaAccount.Spec.DefaultResource = newDefaultResource - noobaaAccount.Spec.ForceMd5Etag = forceMd5Etag + noobaaAccount.Spec.ForceMd5Etag = forceMd5EtagPtr if !util.KubeUpdate(noobaaAccount) { log.Fatalf(`❌ Unable to update account`) @@ -311,7 +316,7 @@ func RunUpdate(cmd *cobra.Command, args []string) { updateAccountS3AccessParams := nb.UpdateAccountS3AccessParams{ Email: name, DefaultResource: &newDefaultResource, - ForceMd5Etag: forceMd5Etag, + ForceMd5Etag: forceMd5EtagPtr, S3Access: accountInfo.HasS3Access, } diff --git a/pkg/noobaaaccount/reconciler.go b/pkg/noobaaaccount/reconciler.go index 85ef83c28a..a3320f0dc4 100644 --- a/pkg/noobaaaccount/reconciler.go +++ b/pkg/noobaaaccount/reconciler.go @@ -333,6 +333,7 @@ func (r *Reconciler) CreateNooBaaAccount() error { DefaultResource: r.NooBaaAccount.Spec.DefaultResource, HasLogin: false, S3Access: true, + ForceMd5Etag: *r.NooBaaAccount.Spec.ForceMd5Etag, AllowBucketCreate: r.NooBaaAccount.Spec.AllowBucketCreate, } @@ -391,6 +392,7 @@ func (r *Reconciler) UpdateNooBaaAccount() error { Email: r.NooBaaAccount.Name, DefaultResource: &r.NooBaaAccount.Spec.DefaultResource, S3Access: true, + ForceMd5Etag: r.NooBaaAccount.Spec.ForceMd5Etag, AllowBucketCreation: &r.NooBaaAccount.Spec.AllowBucketCreate, }