Skip to content

Commit

Permalink
chore(cloudbuild): add configurable source bucket
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
shikanime committed Jun 19, 2024
1 parent 3967f5c commit a20542b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs-v2/content/en/schemas/v4beta11.json
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,11 @@
},
"GoogleCloudBuild": {
"properties": {
"bucket": {
"type": "string",
"description": "specifies the Cloud Storage bucket to store the staged build sources.",
"x-intellij-html-description": "specifies the Cloud Storage bucket to store the staged build sources."
},
"concurrency": {
"type": "integer",
"description": "how many artifacts can be built concurrently. 0 means \"no-limit\".",
Expand Down Expand Up @@ -2157,6 +2162,7 @@
"gradleImage",
"packImage",
"koImage",
"bucket",
"concurrency",
"workerPool",
"region",
Expand Down
7 changes: 6 additions & 1 deletion pkg/skaffold/build/gcb/cloud_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ func (b *Builder) buildArtifactWithCloudBuild(ctx context.Context, out io.Writer
}
log.Entry(ctx).Debugf("project id set to %s", projectID)

cbBucket := fmt.Sprintf("%s%s", projectID, constants.GCSBucketSuffix)
cbBucket := b.Bucket
if cbBucket == "" {
cbBucket = fmt.Sprintf("%s%s", projectID, constants.GCSBucketSuffix)
}
log.Entry(ctx).Debugf("bucket set to %s", cbBucket)

buildObject := fmt.Sprintf("source/%s-%s.tar.gz", projectID, uuid.New().String())

if err := b.createBucketIfNotExists(ctx, c, projectID, cbBucket); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ type GoogleCloudBuild struct {
// Defaults to `gcr.io/k8s-skaffold/skaffold`.
KoImage string `yaml:"koImage,omitempty"`

// Bucket specifies the Cloud Storage bucket to store the staged build sources.
Bucket string `yaml:"bucket,omitempty"`

// Concurrency is how many artifacts can be built concurrently. 0 means "no-limit".
// Defaults to `0`.
Concurrency int `yaml:"concurrency,omitempty"`
Expand Down

0 comments on commit a20542b

Please sign in to comment.