Skip to content

Commit c5d5241

Browse files
committed
some small refactoring
1 parent 8cc71c1 commit c5d5241

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cli_tools/common/utils/storage/scratch_bucket_creator.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (c *ScratchBucketCreator) getBucketAttrsOnFallbackZone(project string, fall
128128

129129
func (c *ScratchBucketCreator) createBucketIfNotExisting(project string,
130130
bucketAttrs *storage.BucketAttrs) (string, error) {
131-
131+
bucketLocation := bucketAttrs.Location
132132
foundBucketAttrs, err := c.getBucketAttrsIfInProject(project, bucketAttrs.Name)
133133
if err != nil {
134134
return "", err
@@ -139,15 +139,16 @@ func (c *ScratchBucketCreator) createBucketIfNotExisting(project string,
139139
if err := c.StorageClient.CreateBucket(bucketAttrs.Name, project, bucketAttrs); err != nil {
140140
return "", err
141141
}
142+
} else {
143+
bucketLocation = foundBucketAttrs.Location
142144
}
145+
143146
log.Printf("Updating soft delete property of scratch bucket `%v` in %v region", bucketAttrs.Name, bucketAttrs.Location)
144147
if err = c.removeSoftDeleteFromBucket(bucketAttrs.Name); err != nil {
145148
return "", err
146149
}
147-
if foundBucketAttrs != nil {
148-
return foundBucketAttrs.Location, nil
149-
}
150-
return bucketAttrs.Location, nil
150+
151+
return bucketLocation, nil
151152
}
152153

153154
func (c *ScratchBucketCreator) removeSoftDeleteFromBucket(bucketName string) error {

0 commit comments

Comments
 (0)