Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add builder subcommand #965

Merged
merged 5 commits into from
Dec 4, 2020
Merged

Add builder subcommand #965

merged 5 commits into from
Dec 4, 2020

Conversation

dfreilich
Copy link
Member

Summary

  • Deprecate pack create-builder in favor of pack builder create
  • Deprecate pack suggest-builders in favor of pack builder suggest

Output

Before

After

Documentation

  • Should this change be documented?
    • Yes

Related

Resolves #917
Relates to #597

@dfreilich dfreilich requested a review from a team as a code owner November 25, 2020 15:18
@dfreilich dfreilich changed the base branch from main to general-subcommand-fixes November 25, 2020 15:19
@dfreilich dfreilich added this to the 0.16.0 milestone Nov 25, 2020
@dfreilich dfreilich added status/blocked Issue or PR that is blocked. See comments. type/enhancement Issue that requests a new feature or improvement. labels Nov 25, 2020
@dfreilich
Copy link
Member Author

Blocked on #964

@dfreilich dfreilich changed the base branch from general-subcommand-fixes to main December 1, 2020 13:14
@codecov
Copy link

codecov bot commented Dec 1, 2020

Codecov Report

Merging #965 (9caf489) into main (4715cec) will increase coverage by 0.13%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #965      +/-   ##
==========================================
+ Coverage   77.92%   78.04%   +0.13%     
==========================================
  Files         107      110       +3     
  Lines        5116     5172      +56     
==========================================
+ Hits         3986     4036      +50     
- Misses        730      734       +4     
- Partials      400      402       +2     
Flag Coverage Δ
os_linux 78.04% <87.50%> (+0.19%) ⬆️
os_macos 75.08% <87.50%> (+0.16%) ⬆️
os_windows 100.00% <ø> (ø)
unit 78.04% <87.50%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@dfreilich dfreilich force-pushed the 917-builder-subcommand branch 2 times, most recently from 34fd64e to 258d14d Compare December 1, 2020 14:19
@dfreilich dfreilich removed the status/blocked Issue or PR that is blocked. See comments. label Dec 1, 2020
…ng to subcommands

Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
@dfreilich dfreilich force-pushed the 917-builder-subcommand branch 3 times, most recently from 297f274 to 987c556 Compare December 3, 2020 13:10
Signed-off-by: David Freilich <dfreilich@vmware.com>

output, err := i.baseCmd(cmdParts...).CombinedOutput()
i.assert.Nil(err)

return strings.Contains(string(output), search)
return strings.Contains(string(output), search) && !strings.Contains(string(output), "Unknown help topic")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since many of the command descriptions include "builder", it was falsely returning true, even though the initial line said "Unknown help topic". This ensures that we don't get false positives.

Signed-off-by: David Freilich <dfreilich@vmware.com>

builderConfig, warns, err := builder.ReadConfig(flags.BuilderTomlPath)
if err != nil {
return errors.Wrap(err, "invalid builder toml")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
return errors.Wrap(err, "invalid builder toml")
return errors.Wrap(err, "invalid builder TOML")

@jromero
Copy link
Member

jromero commented Dec 4, 2020

✅ Accepted

❯ pack-dev help
CLI for building apps using Cloud Native Buildpacks

Usage:
  pack [command]

Available Commands:
  build                 Generate app image from source code
  rebase                Rebase app image with latest run image
  inspect-image         Show information about a built image
  inspect-buildpack     Show information about a buildpack
  set-run-image-mirrors Set mirrors to other repositories for a given run image
  set-default-builder   Set default builder used by other commands
  inspect-builder       Show information about a builder
  package-buildpack     Package buildpack in OCI format.
  version               Show current 'pack' version
  report                Display useful information for reporting an issue
  completion            Outputs completion script location
  config                Interact with Pack's configuration
  stack                 Displays stack information
  builder               Interact with builders
  help                  Help about any command

Flags:
  -h, --help         Help for 'pack'
      --no-color     Disable color output
  -q, --quiet        Show less output
      --timestamps   Enable timestamps in output
  -v, --verbose      Show more output
      --version      Show current 'pack' version

Use "pack [command] --help" for more information about a command.

❯ pack-dev builder help
Interact with builders

Usage:
  pack builder [command]

Aliases:
  builder, builders

Available Commands:
  create      Create builder image
  suggest     Display list of recommended builders

Flags:
  -h, --help   Help for 'builder'

Global Flags:
      --no-color     Disable color output
  -q, --quiet        Show less output
      --timestamps   Enable timestamps in output
  -v, --verbose      Show more output

Use "pack builder [command] --help" for more information about a command.

❯ pack-dev builder create
Error: accepts 1 arg(s), received 0
Usage:
  pack builder create <image-name> --config <builder-config-path> [flags]

Examples:
pack builder create my-builder:bionic --config ./builder.toml

Flags:
  -c, --config string        Path to builder TOML file (required)
  -h, --help                 Help for 'create'
      --publish              Publish to registry
      --pull-policy string   Pull policy to use. Accepted values are always, never, and if-not-present. The default is always

Global Flags:
      --no-color     Disable color output
  -q, --quiet        Show less output
      --timestamps   Enable timestamps in output
  -v, --verbose      Show more output


❯ pack-dev builder create my-builder --config ~/dev/buildpacks/samples/builders/alpine/
ERROR: invalid builder toml: parse contents of '/Users/jromero/dev/buildpacks/samples/builders/alpine/': decoding toml contents: read /Users/jromero/dev/buildpacks/samples/builders/alpine/: is a directory

❯ pack-dev builder create my-builder --config ~/dev/buildpacks/samples/builders/alpine/builder.toml 
alpine: Pulling from cnbs/sample-stack-run
21c83c524219: Already exists 
7ea9c6a720bd: Pull complete 
60862e58eded: Pull complete 
Digest: sha256:eb15ae52be6b06fb1de4749055713cda0aed23a76a88084ef7c19d45630d3008
Status: Downloaded newer image for cnbs/sample-stack-run:alpine
alpine: Pulling from cnbs/sample-stack-build
21c83c524219: Already exists 
7ea9c6a720bd: Already exists 
60862e58eded: Already exists 
91d9bb374e1a: Pull complete 
950c5e600f58: Pull complete 
Digest: sha256:ad1cc1514c2b33ffa13ce4a15ef2810b7fb4982edefe140fa9ead9b3a8f43f1d
Status: Downloaded newer image for cnbs/sample-stack-build:alpine
Warning: The 'image' key is deprecated. Use 'uri="docker://..."' instead.
hello-universe: Pulling from cnbs/sample-package
Digest: sha256:7f0a86fdd00bf15de5d06930fe704e03eeead2b368ab282f68aa793033609270
Status: Image is up to date for cnbs/sample-package:hello-universe
Successfully created builder image my-builder
Tip: Run pack build <image-name> --builder my-builder to use this builder

❯ pack-dev create-builder my-builder --config ~/dev/buildpacks/samples/builders/alpine/builder.toml
Warning: Command 'pack create-builder' has been deprecated, please use 'pack builder create' instead
alpine: Pulling from cnbs/sample-stack-run
Digest: sha256:eb15ae52be6b06fb1de4749055713cda0aed23a76a88084ef7c19d45630d3008
Status: Image is up to date for cnbs/sample-stack-run:alpine
alpine: Pulling from cnbs/sample-stack-build
Digest: sha256:ad1cc1514c2b33ffa13ce4a15ef2810b7fb4982edefe140fa9ead9b3a8f43f1d
Status: Image is up to date for cnbs/sample-stack-build:alpine
Warning: The 'image' key is deprecated. Use 'uri="docker://..."' instead.
hello-universe: Pulling from cnbs/sample-package
Digest: sha256:7f0a86fdd00bf15de5d06930fe704e03eeead2b368ab282f68aa793033609270
Status: Image is up to date for cnbs/sample-package:hello-universe
Successfully created builder image my-builder
Tip: Run pack build <image-name> --builder my-builder to use this builder

@jromero jromero added the status/user-accepted Pull Request that has passed user acceptance. label Dec 4, 2020
@jromero jromero merged commit f3f5397 into main Dec 4, 2020
@jromero jromero deleted the 917-builder-subcommand branch December 4, 2020 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/user-accepted Pull Request that has passed user acceptance. type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pack builder subcommand
2 participants