-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 317_labels_to_volumes
- Loading branch information
Showing
21 changed files
with
170 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// +build benchmarks | ||
|
||
package benchmarks | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"path/filepath" | ||
"testing" | ||
|
||
dockerCli "github.com/docker/docker/client" | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/buildpacks/pack" | ||
"github.com/buildpacks/pack/internal/commands" | ||
cfg "github.com/buildpacks/pack/internal/config" | ||
ilogging "github.com/buildpacks/pack/internal/logging" | ||
h "github.com/buildpacks/pack/testhelpers" | ||
) | ||
|
||
var ( | ||
baseImg = "some-org/" + h.RandString(10) | ||
trustedImg = baseImg + "-trusted-" | ||
builder = "cnbs/sample-builder:bionic" | ||
mockAppPath = filepath.Join("..", "acceptance", "testdata", "mock_app") | ||
) | ||
|
||
func BenchmarkBuild(b *testing.B) { | ||
dockerClient, err := dockerCli.NewClientWithOpts(dockerCli.FromEnv, dockerCli.WithVersion("1.38")) | ||
if err != nil { | ||
b.Error(errors.Wrap(err, "creating docker client")) | ||
} | ||
|
||
if err = h.PullImageWithAuth(dockerClient, builder, ""); err != nil { | ||
b.Error(errors.Wrapf(err, "pulling builder %s", builder)) | ||
} | ||
|
||
cmd := createCmd(b, dockerClient) | ||
|
||
b.Run("with Untrusted Builder", func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
// perform the operation we're analyzing | ||
cmd.SetArgs([]string{fmt.Sprintf("%s%d", baseImg, i), "-p", mockAppPath, "-B", builder}) | ||
if err = cmd.Execute(); err != nil { | ||
b.Error(errors.Wrapf(err, "running build #%d", i)) | ||
} | ||
} | ||
}) | ||
|
||
b.Run("with Trusted Builder", func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
// perform the operation we're analyzing | ||
cmd.SetArgs([]string{fmt.Sprintf("%s%d", trustedImg, i), "-p", mockAppPath, "-B", builder, "--trust-builder"}) | ||
if err = cmd.Execute(); err != nil { | ||
b.Error(errors.Wrapf(err, "running build #%d", i)) | ||
} | ||
} | ||
}) | ||
|
||
// Cleanup | ||
for i := 0; i < b.N; i++ { | ||
if err = h.DockerRmi(dockerClient, fmt.Sprintf("%s%d", baseImg, i)); err != nil { | ||
b.Error(errors.Wrapf(err, "deleting image #%d", i)) | ||
} | ||
|
||
if err = h.DockerRmi(dockerClient, fmt.Sprintf("%s%d", trustedImg, i)); err != nil { | ||
b.Error(errors.Wrapf(err, "deleting image #%d", i)) | ||
} | ||
} | ||
|
||
if err = h.DockerRmi(dockerClient, builder); err != nil { | ||
b.Error(errors.Wrapf(err, "deleting builder %s", builder)) | ||
} | ||
} | ||
|
||
func createCmd(b *testing.B, docker *dockerCli.Client) *cobra.Command { | ||
outBuf := bytes.Buffer{} | ||
logger := ilogging.NewLogWithWriters(&outBuf, &outBuf) | ||
packClient, err := pack.NewClient(pack.WithLogger(logger), pack.WithDockerClient(docker), pack.WithExperimental(true)) | ||
if err != nil { | ||
b.Error(errors.Wrap(err, "creating packClient")) | ||
} | ||
return commands.Build(logger, cfg.Config{}, packClient) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ func BuildpackPull(logger logging.Logger, cfg config.Config, client PackClient) | |
cmd := &cobra.Command{ | ||
Use: "pull <uri>", | ||
Args: cobra.ExactArgs(1), | ||
Short: prependExperimental("Pull a buildpack from a registry and store it locally"), | ||
Short: "Pull a buildpack from a registry and store it locally", | ||
Example: "pack buildpack pull example/[email protected]", | ||
RunE: logError(logger, func(cmd *cobra.Command, args []string) error { | ||
registry, err := config.GetRegistry(cfg, flags.BuildpackRegistry) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ func BuildpackYank(logger logging.Logger, cfg config.Config, client PackClient) | |
cmd := &cobra.Command{ | ||
Use: "yank <buildpack-id-and-version>", | ||
Args: cobra.ExactArgs(1), | ||
Short: prependExperimental("Yank a buildpack from a registry"), | ||
Short: "Yank a buildpack from a registry", | ||
Example: "pack yank [email protected]", | ||
RunE: logError(logger, func(cmd *cobra.Command, args []string) error { | ||
buildpackIDVersion := args[0] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.