-
Notifications
You must be signed in to change notification settings - Fork 8
Implement Cloud Run no build feature. #171
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: main
Are you sure you want to change the base?
Changes from 2 commits
5a11991
59058ce
31d75b6
c21b881
5d134fd
db5ebba
7b88645
1a901bc
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 |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ type CloudRunClient interface { | |
| UpdateService(ctx context.Context, projectID, location, serviceName, imageURL, revisionName string, port int32, service *cloudrunpb.Service) (*cloudrunpb.Service, error) | ||
| GetRevision(ctx context.Context, service *cloudrunpb.Service) (*cloudrunpb.Revision, error) | ||
| DeployFromSource(ctx context.Context, projectID, location, serviceName, source string, port int32, allowPublicAccess bool) error | ||
| DeployNoBuild(ctx context.Context, projectID, location, serviceName, source, baseImage, command string, cmdArgs []string, envVars map[string]string, port int32, allowPublicAccess bool) error | ||
| DeleteService(ctx context.Context, projectID, location, serviceName string) error | ||
| SetServiceAccess(ctx context.Context, serviceName string, allowPublicAccess bool) error | ||
| } | ||
|
|
@@ -202,6 +203,56 @@ func (c *CloudRunClientImpl) DeployFromSource(ctx context.Context, projectID, lo | |
| return nil | ||
| } | ||
|
|
||
| // DeployNoBuild deploys a Cloud Run service from source without a build step, using a base image. | ||
| func (c *CloudRunClientImpl) DeployNoBuild(ctx context.Context, projectID, location, serviceName, source, baseImage, command string, cmdArgs []string, envVars map[string]string, port int32, allowPublicAccess bool) error { | ||
| args := []string{"beta", "run", "deploy", serviceName, "--project", projectID, "--region", location, "--source", source, "--no-build", "--base-image", baseImage, "--format", "json", "--quiet"} | ||
| if command != "" { | ||
| args = append(args, "--command", command) | ||
| } | ||
| if len(cmdArgs) > 0 { | ||
| var argStr string | ||
| for i, a := range cmdArgs { | ||
| if i > 0 { | ||
| argStr += "," | ||
| } | ||
| argStr += a | ||
| } | ||
| if argStr != "" { | ||
| args = append(args, "--args", argStr) | ||
|
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 |
||
| } | ||
| } | ||
| if len(envVars) > 0 { | ||
| var envStr string | ||
| i := 0 | ||
| for k, v := range envVars { | ||
| if i > 0 { | ||
| envStr += "," | ||
| } | ||
| envStr += fmt.Sprintf("%s=%s", k, v) | ||
| i++ | ||
| } | ||
|
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. |
||
| if envStr != "" { | ||
| args = append(args, "--set-env-vars", envStr) | ||
| } | ||
| } | ||
| if port != 0 { | ||
| args = append(args, "--port", fmt.Sprintf("%d", port)) | ||
| } | ||
| if allowPublicAccess { | ||
| args = append(args, "--allow-unauthenticated") | ||
| } else { | ||
| args = append(args, "--no-allow-unauthenticated") | ||
| } | ||
|
|
||
| cmd := c.execer.Command("gcloud", args...) | ||
| out, err := cmd.CombinedOutput() | ||
| if err != nil { | ||
| return fmt.Errorf("failed to deploy no-build: %w, output: %s", err, out) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
|
|
||
| // DeleteService deletes a Cloud Run service. | ||
| func (c *CloudRunClientImpl) DeleteService(ctx context.Context, projectID, location, serviceName string) error { | ||
| name := fmt.Sprintf("projects/%s/locations/%s/services/%s", projectID, location, serviceName) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| go 1.25.5 | ||
|
|
||
| use ( | ||
| ./cicd-mcp-server | ||
| ./lib/bm25 | ||
| ./local-kb-index-builder | ||
| ) |
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.
Using
strings.Joinis more idiomatic and efficient than manual string concatenation in a loop, as it avoids multiple allocations. Note that this requires importing thestringspackage.