-
Notifications
You must be signed in to change notification settings - Fork 493
chore: Update Golang version to 1.26.1 for v2.5.0 release #4602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2.5.0_release
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -72,18 +72,18 @@ func providePermissionToManagedFolder(bucket, managedFolderPath, serviceAccount, | |||||||||||
| // Indent for readability | ||||||||||||
| jsonData, err := json.MarshalIndent(policy, "", " ") | ||||||||||||
| if err != nil { | ||||||||||||
| t.Fatalf(fmt.Sprintf("Error in marshal the data into JSON format: %v", err)) | ||||||||||||
| t.Fatalf("Error in marshal the data into JSON format: %v", err) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| localIAMPolicyFilePath := path.Join(os.Getenv("HOME"), "iam_policy.json") | ||||||||||||
| // Write the JSON to a FileInNonEmptyManagedFoldersTest | ||||||||||||
| err = os.WriteFile(localIAMPolicyFilePath, jsonData, setup.FilePermission_0600) | ||||||||||||
| if err != nil { | ||||||||||||
| t.Fatalf(fmt.Sprintf("Error in writing iam policy in json FileInNonEmptyManagedFoldersTest : %v", err)) | ||||||||||||
| t.Fatalf("Error in writing iam policy in json FileInNonEmptyManagedFoldersTest : %v", err) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| gcloudProvidePermissionCmd := fmt.Sprintf("alpha storage managed-folders set-iam-policy gs://%s/%s %s", bucket, managedFolderPath, localIAMPolicyFilePath) | ||||||||||||
| _, err = operations.ExecuteGcloudCommandf(gcloudProvidePermissionCmd) | ||||||||||||
| _, err = operations.ExecuteGcloudCommandf("%s", gcloudProvidePermissionCmd) | ||||||||||||
| if err != nil { | ||||||||||||
| t.Fatalf("Error in providing permission to managed folder: %v", err) | ||||||||||||
| } | ||||||||||||
|
|
@@ -92,7 +92,7 @@ func providePermissionToManagedFolder(bucket, managedFolderPath, serviceAccount, | |||||||||||
| func revokePermissionToManagedFolder(bucket, managedFolderPath, serviceAccount, iamRole string, t *testing.T) { | ||||||||||||
| gcloudRevokePermissionCmd := fmt.Sprintf("alpha storage managed-folders remove-iam-policy-binding gs://%s/%s --member=%s --role=%s", bucket, managedFolderPath, serviceAccount, iamRole) | ||||||||||||
|
|
||||||||||||
| _, err := operations.ExecuteGcloudCommandf(gcloudRevokePermissionCmd) | ||||||||||||
| _, err := operations.ExecuteGcloudCommandf("%s", gcloudRevokePermissionCmd) | ||||||||||||
|
Comment on lines
93
to
+95
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The command can be passed directly to
Suggested change
References
|
||||||||||||
| if err != nil && !strings.Contains(err.Error(), "Policy binding with the specified principal, role, and condition not found!") && !strings.Contains(err.Error(), "The specified managed folder does not exist.") { | ||||||||||||
| t.Fatalf("Error in removing permission to managed folder: %v", err) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -58,7 +58,7 @@ func CreateCredentials() (serviceAccount, localKeyFilePath string) { | |||||||||
|
|
||||||||||
| // Download credentials | ||||||||||
| gcloudSecretAccessCmd := fmt.Sprintf("secrets versions access latest --secret %s", CredentialsSecretName) | ||||||||||
| creds, err := operations.ExecuteGcloudCommandf(gcloudSecretAccessCmd) | ||||||||||
| creds, err := operations.ExecuteGcloudCommandf("%s", gcloudSecretAccessCmd) | ||||||||||
|
Comment on lines
60
to
+61
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify the command execution by passing the format string and arguments directly to
Suggested change
References
|
||||||||||
| if err != nil { | ||||||||||
| setup.LogAndExit(fmt.Sprintf("Error while fetching key file %v", err)) | ||||||||||
| } | ||||||||||
|
|
@@ -79,7 +79,7 @@ func CreateCredentials() (serviceAccount, localKeyFilePath string) { | |||||||||
|
|
||||||||||
| func ApplyPermissionToServiceAccount(serviceAccount, permission, bucket string) { | ||||||||||
| // Provide permission to service account for testing. | ||||||||||
| _, err := operations.ExecuteGcloudCommandf(fmt.Sprintf("storage buckets add-iam-policy-binding gs://%s --member=serviceAccount:%s --role=roles/storage.%s", bucket, serviceAccount, permission)) | ||||||||||
| _, err := operations.ExecuteGcloudCommandf("storage buckets add-iam-policy-binding gs://%s --member=serviceAccount:%s --role=roles/storage.%s", bucket, serviceAccount, permission) | ||||||||||
| if err != nil { | ||||||||||
| setup.LogAndExit(fmt.Sprintf("Error while setting permissions to SA: %v", err)) | ||||||||||
| } | ||||||||||
|
|
@@ -91,7 +91,7 @@ func ApplyPermissionToServiceAccount(serviceAccount, permission, bucket string) | |||||||||
| func RevokePermission(serviceAccount, permission, bucket string) { | ||||||||||
| // Revoke the permission to service account after testing. | ||||||||||
| cmd := fmt.Sprintf("storage buckets remove-iam-policy-binding gs://%s --member=serviceAccount:%s --role=roles/storage.%s", bucket, serviceAccount, permission) | ||||||||||
| _, err := operations.ExecuteGcloudCommandf(cmd) | ||||||||||
| _, err := operations.ExecuteGcloudCommandf("%s", cmd) | ||||||||||
|
Comment on lines
93
to
+94
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid redundant formatting by passing the arguments directly to
Suggested change
References
|
||||||||||
| if err != nil { | ||||||||||
| setup.LogAndExit(fmt.Sprintf("Error in unsetting permissions to SA: %v", err)) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -172,26 +172,26 @@ func DirSizeMiB(dirPath string) (dirSizeMB int64, err error) { | |||||||||||
| func DeleteManagedFoldersInBucket(managedFolderPath, bucket string) { | ||||||||||||
| gcloudDeleteManagedFolderCmd := fmt.Sprintf("alpha storage rm -r gs://%s/%s", bucket, managedFolderPath) | ||||||||||||
|
|
||||||||||||
| _, err := ExecuteGcloudCommandf(gcloudDeleteManagedFolderCmd) | ||||||||||||
| _, err := ExecuteGcloudCommandf("%s", gcloudDeleteManagedFolderCmd) | ||||||||||||
|
Comment on lines
173
to
+175
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify by passing the format string and arguments directly to
Suggested change
References
|
||||||||||||
| if err != nil && !strings.Contains(err.Error(), "The following URLs matched no objects or files") { | ||||||||||||
| log.Fatalf(fmt.Sprintf("Error while deleting managed folder: %v", err)) | ||||||||||||
| log.Fatalf("Error while deleting managed folder: %v", err) | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| func CreateManagedFoldersInBucket(managedFolderPath, bucket string) { | ||||||||||||
| gcloudCreateManagedFolderCmd := fmt.Sprintf("alpha storage managed-folders create gs://%s/%s", bucket, managedFolderPath) | ||||||||||||
|
|
||||||||||||
| _, err := ExecuteGcloudCommandf(gcloudCreateManagedFolderCmd) | ||||||||||||
| _, err := ExecuteGcloudCommandf("%s", gcloudCreateManagedFolderCmd) | ||||||||||||
|
Comment on lines
182
to
+184
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify by passing the format string and arguments directly to
Suggested change
References
|
||||||||||||
| if err != nil && !strings.Contains(err.Error(), "The specified managed folder already exists") { | ||||||||||||
| log.Fatalf(fmt.Sprintf("Error while creating managed folder: %v", err)) | ||||||||||||
| log.Fatalf("Error while creating managed folder: %v", err) | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| func CopyFileInBucket(srcfilePath, destFilePath, bucket string, t *testing.T) { | ||||||||||||
| gcloudCopyFileCmd := fmt.Sprintf("alpha storage cp %s gs://%s/%s/", srcfilePath, bucket, destFilePath) | ||||||||||||
|
|
||||||||||||
| _, err := ExecuteGcloudCommandf(gcloudCopyFileCmd) | ||||||||||||
| _, err := ExecuteGcloudCommandf("%s", gcloudCopyFileCmd) | ||||||||||||
|
Comment on lines
191
to
+193
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplify by passing the format string and arguments directly to
Suggested change
References
|
||||||||||||
| if err != nil { | ||||||||||||
| t.Fatalf(fmt.Sprintf("Error while copying file in bucket: %v", err)) | ||||||||||||
| t.Fatalf("Error while copying file in bucket: %v", err) | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of pre-formatting the command string with
fmt.Sprintfand then passing it toExecuteGcloudCommandfwith a"%s"format, you can pass the arguments directly toExecuteGcloudCommandf. This is cleaner and avoids redundant formatting.References