Skip to content

Commit 71b7c53

Browse files
authored
chore: (cloudbuild) add configurable source bucket (#9441)
This pull request introduces a new configurable parameter for specifying a custom bucket. For example, the bucket name could follow the format `gs://[PROJECT_ID]_[builds/region]_cloudbuild`.
1 parent 4c6bfe5 commit 71b7c53

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

docs-v2/content/en/schemas/v4beta12.json

+6
Original file line numberDiff line numberDiff line change
@@ -2051,6 +2051,11 @@
20512051
},
20522052
"GoogleCloudBuild": {
20532053
"properties": {
2054+
"bucket": {
2055+
"type": "string",
2056+
"description": "specifies the Cloud Storage bucket to store the staged build sources.",
2057+
"x-intellij-html-description": "specifies the Cloud Storage bucket to store the staged build sources."
2058+
},
20542059
"concurrency": {
20552060
"type": "integer",
20562061
"description": "how many artifacts can be built concurrently. 0 means \"no-limit\".",
@@ -2167,6 +2172,7 @@
21672172
"gradleImage",
21682173
"packImage",
21692174
"koImage",
2175+
"bucket",
21702176
"concurrency",
21712177
"workerPool",
21722178
"region",

pkg/skaffold/build/gcb/cloud_build.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ func (b *Builder) buildArtifactWithCloudBuild(ctx context.Context, out io.Writer
106106
}
107107
log.Entry(ctx).Debugf("project id set to %s", projectID)
108108

109-
cbBucket := fmt.Sprintf("%s%s", projectID, constants.GCSBucketSuffix)
109+
cbBucket := b.Bucket
110+
if cbBucket == "" {
111+
cbBucket = fmt.Sprintf("%s%s", projectID, constants.GCSBucketSuffix)
112+
}
113+
log.Entry(ctx).Debugf("bucket set to %s", cbBucket)
114+
110115
buildObject := fmt.Sprintf("source/%s-%s.tar.gz", projectID, uuid.New().String())
111116

112117
if err := b.createBucketIfNotExists(ctx, c, projectID, cbBucket); err != nil {

pkg/skaffold/schema/latest/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ type GoogleCloudBuild struct {
450450
// Defaults to `gcr.io/k8s-skaffold/skaffold`.
451451
KoImage string `yaml:"koImage,omitempty"`
452452

453+
// Bucket specifies the Cloud Storage bucket to store the staged build sources.
454+
Bucket string `yaml:"bucket,omitempty"`
455+
453456
// Concurrency is how many artifacts can be built concurrently. 0 means "no-limit".
454457
// Defaults to `0`.
455458
Concurrency int `yaml:"concurrency,omitempty"`

0 commit comments

Comments
 (0)