Skip to content

Commit 065acaa

Browse files
committed
Update max env value size to match GCP. Update env check to expose error result instead of number.
1 parent 4fb24a1 commit 065acaa

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Local Builder is not 100% feature-compatible with the hosted Google Cloud Build
55

66

77
### Community Fork
8-
This Google Cloud Build Local (fork) is maintained by volunteers, which at best, makes this ok for a local debugging
8+
This Google Cloud Build Local fork is maintained by volunteers, which at best, makes this ok for a local debugging
99
tool for Google Cloud Build. It does not support 100% feature parity with the hosted Cloud Build service and should
1010
not be used for production workloads.
1111

localbuilder_main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func run(ctx context.Context, source string) error {
163163
for k, v := range envMap {
164164
index := slices.Index(s.SecretEnv, k)
165165
if index >= 0 {
166-
s.Env = append(s.Env, fmt.Sprintf("%s=%s", k, v))
166+
s.Env = append(s.Env, fmt.Sprintf("%s=%s", k, strings.ReplaceAll(v, "\n", "\\n")))
167167
s.SecretEnv = slices.Delete(s.SecretEnv, index, index+1)
168168
log.Printf("Found secretEnv '%s' matching env file key and replaced it.", k)
169169
}

validate/validate.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import (
2626
"time"
2727
"unicode"
2828

29-
pb "google.golang.org/genproto/googleapis/devtools/cloudbuild/v1"
30-
"github.com/golang/protobuf/ptypes"
3129
"github.com/GoogleCloudPlatform/cloud-build-local/subst"
3230
"github.com/docker/distribution/reference"
31+
"github.com/golang/protobuf/ptypes"
32+
pb "google.golang.org/genproto/googleapis/devtools/cloudbuild/v1"
3333
)
3434

3535
const (
@@ -38,12 +38,12 @@ const (
3838
// MaxTimeout is the maximum allowable timeout for a build or build step.
3939
MaxTimeout = 24 * time.Hour
4040

41-
maxNumSteps = 100 // max number of steps.
42-
maxStepNameLength = 1000 // max length of step name.
43-
maxNumEnvs = 100 // max number of envs per step.
44-
maxEnvLength = 1000 // max length of env value.
45-
maxNumArgs = 100 // max number of args per step.
46-
41+
maxNumSteps = 100 // max number of steps.
42+
maxStepNameLength = 1000 // max length of step name.
43+
maxNumEnvs = 100 // max number of envs per step.
44+
maxEnvLength = 65536 // max length of env value.
45+
maxNumArgs = 100 // max number of args per step.
46+
4747
maxArgLength = 4000 // max length of arg value.
4848
maxDirLength = 1000 // max length of dir value.
4949
maxNumImages = 100 // max number of images.
@@ -357,7 +357,6 @@ func CheckArtifacts(b *pb.Build) error {
357357
}
358358
}
359359

360-
361360
if len(b.GetArtifacts().GetImages()) > 0 {
362361
b.Images = b.GetArtifacts().GetImages()
363362
}
@@ -619,7 +618,7 @@ func checkEnvVars(b *pb.Build) error {
619618
// build step local env vars
620619
for i, s := range b.GetSteps() {
621620
if err := runCommonEnvChecks(s.GetEnv()); err != nil {
622-
return fmt.Errorf("invalid .steps.env field: build step %d %v", i, maxNumEnvs)
621+
return fmt.Errorf("invalid .steps.env field: build step %d %v", i, err)
623622

624623
}
625624
}

0 commit comments

Comments
 (0)