Skip to content

Commit

Permalink
add setEnv()
Browse files Browse the repository at this point in the history
Signed-off-by: edithwuly <edithwuly@163.com>
  • Loading branch information
edithwuly committed Apr 27, 2023
1 parent 14d541a commit c740838
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions benchmarks/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import (
)

var (
baseImg = "some-org/" + h.RandString(10)
trustedImg = baseImg + "-trusted-"
builder = "cnbs/sample-builder:bionic"
mockAppPath = filepath.Join("..", "acceptance", "testdata", "mock_app")
paketoBuilder = "paketobuildpacks/builder:base"
additionalBuildapck = "docker://cnbs/sample-package:hello-universe"
baseImg string
trustedImg string
builder string
mockAppPath string
paketoBuilder string
additionalBuildapck string
)

func BenchmarkBuild(b *testing.B) {
setEnv()
dockerClient, err := dockerCli.NewClientWithOpts(dockerCli.FromEnv, dockerCli.WithVersion("1.38"))
if err != nil {
b.Error(errors.Wrap(err, "creating docker client"))
Expand Down Expand Up @@ -96,3 +97,22 @@ func createCmd(b *testing.B, docker *dockerCli.Client) *cobra.Command {
}
return commands.Build(logger, cfg.Config{}, packClient)
}

func setEnv() {
if baseImg = os.Getenv("baseImg"); baseImg == "" {
baseImg = "some-org/" + h.RandString(10)
}
trustedImg = baseImg + "-trusted-"
if builder = os.Getenv("builder"); builder == "" {
builder = "cnbs/sample-builder:bionic"
}
if mockAppPath = os.Getenv("mockAppPath"); mockAppPath == "" {
mockAppPath = filepath.Join("..", "acceptance", "testdata", "mock_app")
}
if paketoBuilder = os.Getenv("paketoBuilder"); paketoBuilder == "" {
paketoBuilder = "paketobuildpacks/builder:base"
}
if additionalBuildapck = os.Getenv("additionalBuildapck"); additionalBuildapck == "" {
additionalBuildapck = "docker://cnbs/sample-package:hello-universe"
}
}

0 comments on commit c740838

Please sign in to comment.