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 config trusted-builders subcommands #959

Merged
merged 12 commits into from
Dec 3, 2020
Merged

Conversation

dfreilich
Copy link
Member

Summary

This PR adds 4 pack config trusted-builders subcommands:

  • pack config trusted-builders → Lists trusted builders
  • pack config trusted-builders list
  • pack config trusted-builders add <builder>
  • pack config trusted-builders remove <builder>

As part of it, it also hid the commands pack trust-builder, pack untrust-builder, and pack list-trusted-builders, and aliased them to the respective new commands.

In order to accomplish this cleanly, I also made some of the funcs/items in the commands package public, which changed a fair number of files.

Output

Before

After

Documentation

  • Should this change be documented?
    • Yes, and it will be generated automatically

Related

Resolves #921
Relates to (and partially accomplishes) #597

@dfreilich dfreilich marked this pull request as ready for review November 16, 2020 14:58
@dfreilich dfreilich requested a review from a team as a code owner November 16, 2020 14:58
@dfreilich dfreilich force-pushed the 921-config-t-builders branch 2 times, most recently from d48010b to b5162dc Compare November 17, 2020 16:01
Copy link
Member

@jromero jromero left a comment

Choose a reason for hiding this comment

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

Looking great! Functionality I think is there. My request for changes are primarily cleanup.

acceptance/acceptance_test.go Outdated Show resolved Hide resolved
acceptance/acceptance_test.go Outdated Show resolved Hide resolved
acceptance/acceptance_test.go Outdated Show resolved Hide resolved
acceptance/acceptance_test.go Outdated Show resolved Hide resolved
acceptance/acceptance_test.go Outdated Show resolved Hide resolved
internal/commands/config/trusted_builder_test.go Outdated Show resolved Hide resolved
internal/commands/config/trusted_builder_test.go Outdated Show resolved Hide resolved
internal/commands/stack/suggest_stacks.go Outdated Show resolved Hide resolved
"github.com/buildpacks/pack/logging"
)

func Config(logger logging.Logger, cfg config.Config, cfgPath string) *cobra.Command {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func Config(logger logging.Logger, cfg config.Config, cfgPath string) *cobra.Command {
func NewConfigCommand(logger logging.Logger, cfg config.Config, cfgPath string) *cobra.Command {

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm happy to change that, but in my initial comment
to the stack cmd PR (#937 (comment)), I had urged away from doing that.

Our command pattern is typically to do the command name itself (e.g. command.Build), so I think this would fit the pattern a bit more.

Just want to confirm whether this should be the new pattern. It does make more sense (because then it will be used as rootCmd.AddCommand(config.NewCommand(...))

internal/commands/config/trusted_builder.go Outdated Show resolved Hide resolved
@dfreilich dfreilich added the type/enhancement Issue that requests a new feature or improvement. label Nov 18, 2020
@dfreilich dfreilich added this to the 0.16.0 milestone Nov 18, 2020
@dfreilich dfreilich force-pushed the 921-config-t-builders branch from e0d9378 to 03975ae Compare November 24, 2020 10:40
@dfreilich dfreilich force-pushed the 921-config-t-builders branch 3 times, most recently from 2d18b9c to 8f17f9c Compare November 25, 2020 15:29
@dfreilich dfreilich changed the base branch from main to general-subcommand-fixes November 25, 2020 15:29
@dfreilich dfreilich added the status/blocked Issue or PR that is blocked. See comments. label 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 11:00
@dfreilich dfreilich force-pushed the 921-config-t-builders branch from 8f17f9c to 8d10749 Compare December 1, 2020 12:34
@codecov
Copy link

codecov bot commented Dec 1, 2020

Codecov Report

Merging #959 (6b4dc4f) into main (51e0263) will increase coverage by 0.29%.
The diff coverage is 96.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #959      +/-   ##
==========================================
+ Coverage   77.63%   77.92%   +0.29%     
==========================================
  Files         105      107       +2     
  Lines        5060     5116      +56     
==========================================
+ Hits         3928     3986      +58     
+ Misses        731      730       -1     
+ Partials      401      400       -1     
Flag Coverage Δ
os_linux 77.86% <96.94%> (+0.29%) ⬆️
os_macos 74.93% <96.94%> (+0.28%) ⬆️
os_windows 100.00% <ø> (?)
unit 77.92% <96.94%> (+0.29%) ⬆️

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

@dfreilich dfreilich force-pushed the 921-config-t-builders branch from 8d10749 to 9023079 Compare December 1, 2020 12:45
@dfreilich dfreilich removed the status/blocked Issue or PR that is blocked. See comments. label Dec 1, 2020
@dfreilich dfreilich changed the title Add pack config trusted-builders subcommands Add config trusted-builders subcommands Dec 1, 2020
}

// Technically the creator is supported as of platform API version 0.3 (lifecycle version 0.7.0+) but earlier versions
// have bugs that make using the creator problematic.
creatorSupported := lifecycle.SupportsFeature(config.CreatorInLifecycle) &&
pack.SupportsFeature(invoke.CreatorInPack)

usingCreator = creatorSupported && trustBuilder
usingCreator = creatorSupported
Copy link
Member Author

Choose a reason for hiding this comment

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

trust-builder is supported by all versions tested

@dfreilich dfreilich force-pushed the 921-config-t-builders branch from 9023079 to 48483b6 Compare December 1, 2020 16:33
…ng to subcommands

Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
* Create config command generators, and replace list-trusted/trust/untrust builder funcs

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

Signed-off-by: David Freilich <dfreilich@vmware.com>
* Add acceptance test for deprecation warning
* Fix linting errors
* Add command to rootCmd

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

Signed-off-by: David Freilich <dfreilich@vmware.com>
* Rename trusted-builder to trusted-builders, to follow RFC
* Change Config to NewConfigCommand

Signed-off-by: David Freilich <dfreilich@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
@dfreilich dfreilich force-pushed the 921-config-t-builders branch from 48483b6 to c67b0fb Compare December 3, 2020 12:36
@jromero jromero self-requested a review December 3, 2020 14:24
@@ -73,13 +72,17 @@ func NewPackCommand(logger ConfigurableLogger) (*cobra.Command, error) {
rootCmd.AddCommand(commands.SetDefaultBuilder(logger, cfg, &packClient))
rootCmd.AddCommand(commands.InspectBuilder(logger, cfg, &packClient, writer.NewFactory()))
rootCmd.AddCommand(commands.SuggestBuilders(logger, &packClient))
//nolint:staticcheck
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity, what lint warning are we suppressing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Using a deprecated command.

internal/commands/config.go Outdated Show resolved Hide resolved
@jromero
Copy link
Member

jromero commented Dec 3, 2020

✅ Accepted

❯ pack-dev config
Interact with pack config

Usage:
  pack config [command]

Available Commands:
  trusted-builders Interact with trusted builders

Flags:
  -h, --help   help for config

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

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

pack on  921-config-t-builders via 🐹 v1.15.3 on ☁️ jromero@pivotal.io 
❯ pack-dev config trusted-builders
Trusted Builders:
  gcr.io/buildpacks/builder:v1
  heroku/buildpacks:18
  paketobuildpacks/builder:base
  paketobuildpacks/builder:full
  paketobuildpacks/builder:tiny

pack on  921-config-t-builders via 🐹 v1.15.3 on ☁️ jromero@pivotal.io 
❯ pack-dev config trusted-builders --help
Interact with trusted builders

Usage:
  pack config trusted-builders [flags]
  pack config trusted-builders [command]

Aliases:
  trusted-builders, trusted-builder

Available Commands:
  add         Add a trusted-builders
  remove      Remove a trusted-builders
  list        List trusted-builders

Flags:
  -h, --help   help for trusted-builders

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

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

pack on  921-config-t-builders via 🐹 v1.15.3 on ☁️ jromero@pivotal.io 
❯ pack-dev config trusted-builders
Trusted Builders:
  gcr.io/buildpacks/builder:v1
  heroku/buildpacks:18
  paketobuildpacks/builder:base
  paketobuildpacks/builder:full
  paketobuildpacks/builder:tiny

pack on  921-config-t-builders via 🐹 v1.15.3 on ☁️ jromero@pivotal.io 
❯ pack-dev config trusted-builders remove paketobuildpacks/builder:base
ERROR: Builder paketobuildpacks/builder:base is a suggested builder, and is trusted by default. Currently pack doesn't support making these builders untrusted

pack on  921-config-t-builders via 🐹 v1.15.3 on ☁️ jromero@pivotal.io 
❯ pack-dev config trusted-builders
Trusted Builders:
  gcr.io/buildpacks/builder:v1
  heroku/buildpacks:18
  paketobuildpacks/builder:base
  paketobuildpacks/builder:full
  paketobuildpacks/builder:tiny

pack on  921-config-t-builders via 🐹 v1.15.3 on ☁️ jromero@pivotal.io 
❯ pack-dev config trusted-builders add paketobuildpacks/builder:base1
Builder paketobuildpacks/builder:base1 is now trusted

pack on  921-config-t-builders via 🐹 v1.15.3 on ☁️ jromero@pivotal.io 
❯ pack-dev config trusted-builders list
Trusted Builders:
  gcr.io/buildpacks/builder:v1
  heroku/buildpacks:18
  paketobuildpacks/builder:base
  paketobuildpacks/builder:base1
  paketobuildpacks/builder:full
  paketobuildpacks/builder:tiny

pack on  921-config-t-builders via 🐹 v1.15.3 on ☁️ jromero@pivotal.io 
❯ pack-dev config trusted-builders remove paketobuildpacks/builder:base1
Builder paketobuildpacks/builder:base1 is no longer trusted

pack on  921-config-t-builders via 🐹 v1.15.3 on ☁️ jromero@pivotal.io 
❯ pack-dev config trusted-builders
Trusted Builders:
  gcr.io/buildpacks/builder:v1
  heroku/buildpacks:18
  paketobuildpacks/builder:base
  paketobuildpacks/builder:full
  paketobuildpacks/builder:tiny

@jromero jromero added the status/user-accepted Pull Request that has passed user acceptance. label Dec 3, 2020
dfreilich and others added 3 commits December 3, 2020 17:57
Signed-off-by: David Freilich <dfreilich@vmware.com>

Co-authored-by: Javier Romero <rjavier@vmware.com>
Signed-off-by: David Freilich <dfreilich@vmware.com>
@dfreilich dfreilich merged commit 4715cec into main Dec 3, 2020
@dfreilich dfreilich deleted the 921-config-t-builders branch December 3, 2020 18:08
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 config trusted-builders subcommands
2 participants