Skip to content

Commit

Permalink
Fix - Added force_md5_etag in NoobaaAccount Update command
Browse files Browse the repository at this point in the history
Signed-off-by: Aayush Chouhan <[email protected]>
  • Loading branch information
achouhan09 committed Dec 6, 2023
1 parent 840f68f commit 9759679
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/noobaa/v1alpha1/noobaaaccount_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/noobaa/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/nb/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
13 changes: 9 additions & 4 deletions pkg/noobaaaccount/noobaaaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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`)
Expand Down Expand Up @@ -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,
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/noobaaaccount/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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,
}

Expand Down

0 comments on commit 9759679

Please sign in to comment.