Skip to content

Commit

Permalink
Update max env value size to match GCP. Update env check to expose er…
Browse files Browse the repository at this point in the history
…ror result instead of number.
  • Loading branch information
chriseaton committed May 23, 2023
1 parent 4fb24a1 commit 065acaa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Local Builder is not 100% feature-compatible with the hosted Google Cloud Build


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

Expand Down
2 changes: 1 addition & 1 deletion localbuilder_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func run(ctx context.Context, source string) error {
for k, v := range envMap {
index := slices.Index(s.SecretEnv, k)
if index >= 0 {
s.Env = append(s.Env, fmt.Sprintf("%s=%s", k, v))
s.Env = append(s.Env, fmt.Sprintf("%s=%s", k, strings.ReplaceAll(v, "\n", "\\n")))
s.SecretEnv = slices.Delete(s.SecretEnv, index, index+1)
log.Printf("Found secretEnv '%s' matching env file key and replaced it.", k)
}
Expand Down
19 changes: 9 additions & 10 deletions validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
"time"
"unicode"

pb "google.golang.org/genproto/googleapis/devtools/cloudbuild/v1"
"github.com/golang/protobuf/ptypes"
"github.com/GoogleCloudPlatform/cloud-build-local/subst"
"github.com/docker/distribution/reference"
"github.com/golang/protobuf/ptypes"
pb "google.golang.org/genproto/googleapis/devtools/cloudbuild/v1"
)

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

maxNumSteps = 100 // max number of steps.
maxStepNameLength = 1000 // max length of step name.
maxNumEnvs = 100 // max number of envs per step.
maxEnvLength = 1000 // max length of env value.
maxNumArgs = 100 // max number of args per step.
maxNumSteps = 100 // max number of steps.
maxStepNameLength = 1000 // max length of step name.
maxNumEnvs = 100 // max number of envs per step.
maxEnvLength = 65536 // max length of env value.
maxNumArgs = 100 // max number of args per step.

maxArgLength = 4000 // max length of arg value.
maxDirLength = 1000 // max length of dir value.
maxNumImages = 100 // max number of images.
Expand Down Expand Up @@ -357,7 +357,6 @@ func CheckArtifacts(b *pb.Build) error {
}
}


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

}
}
Expand Down

0 comments on commit 065acaa

Please sign in to comment.