Skip to content

Commit

Permalink
build-config-env layer oly added when it is not empty
Browse files Browse the repository at this point in the history
Signed-off-by: WYGIN <[email protected]>
  • Loading branch information
WYGIN committed Oct 12, 2023
1 parent 6e085ae commit 5e9ce4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
15 changes: 7 additions & 8 deletions internal/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,14 @@ func (b *Builder) Save(logger logging.Logger, creatorMetadata CreatorMetadata) e

if len(b.buildConfigEnv) > 0 {
logger.Debugf("Provided Build Config Environment Variables\n %s", style.Map(b.env, " ", "\n"))
}

buildConfigEnvTar, err := b.buildConfigEnvLayer(tmpDir, b.buildConfigEnv)
if err != nil {
return errors.Wrap(err, "retrieving build-config-env layer")
}
buildConfigEnvTar, err := b.buildConfigEnvLayer(tmpDir, b.buildConfigEnv)
if err != nil {
return errors.Wrap(err, "retrieving build-config-env layer")
}

Check warning on line 542 in internal/builder/builder.go

View check run for this annotation

Codecov / codecov/patch

internal/builder/builder.go#L541-L542

Added lines #L541 - L542 were not covered by tests

if err := b.image.AddLayer(buildConfigEnvTar); err != nil {
return errors.Wrap(err, "adding build-config-env layer")
if err := b.image.AddLayer(buildConfigEnvTar); err != nil {
return errors.Wrap(err, "adding build-config-env layer")
}

Check warning on line 546 in internal/builder/builder.go

View check run for this annotation

Codecov / codecov/patch

internal/builder/builder.go#L545-L546

Added lines #L545 - L546 were not covered by tests
}

if len(b.env) > 0 {
Expand Down
6 changes: 1 addition & 5 deletions pkg/client/create_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ func (c *Client) CreateBuilder(ctx context.Context, opts CreateBuilderOptions) e
bldr.SetStack(opts.Config.Stack)
}
bldr.SetRunImage(opts.Config.Run)
if opts.BuildConfigEnv == nil || len(opts.BuildConfigEnv) == 0 {
bldr.SetBuildConfigEnv(make(map[string]string))
} else {
bldr.SetBuildConfigEnv(opts.BuildConfigEnv)
}
bldr.SetBuildConfigEnv(opts.BuildConfigEnv)

return bldr.Save(c.logger, builder.CreatorMetadata{Version: c.version})
}
Expand Down

0 comments on commit 5e9ce4c

Please sign in to comment.