Skip to content

add command skaffold inspect build-env add local #5944

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

Merged
merged 1 commit into from
Jun 4, 2021

Conversation

gsquared94
Copy link
Contributor

@gsquared94 gsquared94 commented Jun 4, 2021

Fixes: #5998
Related: #5758
Description

User facing changes (remove if N/A)

❯ skaffold inspect build-env add local --help
Add a new local build environment definition.
Without the '--profile' flag the new environment definition is added to the default pipeline. With the '--profile' flag
it will create a new profile with this build env definition. 
In these respective scenarios, it will fail if the build env definition for the default pipeline or the named profile
already exists. To override an existing definition use 'skaffold inspect build-env modify' command instead. 
Use the '--module' filter to specify the individual module to target. Otherwise, it'll be applied to all modules defined
in the target file. Also, with the '--profile' flag if the target config imports other configs as dependencies, then the
new profile will be recursively created in all the imported configs also.

Examples:
  # Add a new profile named 'local' targeting the local build environment with option to push images and using buildkit
  skaffold inspect build-env add local --profile local --push true --useBuildkit true -f skaffold.yaml

Options:
      --concurrency=-1: number of artifacts to build concurrently. 0 means "no-limit"
      --push=: Set to true to push images to a registry
      --tryImportMissing=: Set to true to to attempt importing artifacts from Docker (either a local or remote registry)
if not in the build cache
      --useBuildkit=: Set to true to use BuildKit to build Docker images
      --useDockerCLI=: Set to true to use 'docker' command-line interface instead of Docker Engine APIs

Usage:
  skaffold inspect build-env add local [flags] [options]

Use "skaffold options" for a list of global command-line options (applies to all commands).

@gsquared94 gsquared94 requested a review from a team as a code owner June 4, 2021 09:41
@gsquared94 gsquared94 requested a review from tejal29 June 4, 2021 09:41
@google-cla google-cla bot added the cla: yes label Jun 4, 2021
@gsquared94 gsquared94 enabled auto-merge (squash) June 4, 2021 09:43
@gsquared94 gsquared94 requested a review from MarlonGamez June 4, 2021 09:44
@codecov
Copy link

codecov bot commented Jun 4, 2021

Codecov Report

Merging #5944 (d9f8aec) into master (9647c41) will decrease coverage by 0.00%.
The diff coverage is 69.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5944      +/-   ##
==========================================
- Coverage   70.66%   70.65%   -0.01%     
==========================================
  Files         454      455       +1     
  Lines       17403    17471      +68     
==========================================
+ Hits        12297    12344      +47     
- Misses       4197     4214      +17     
- Partials      909      913       +4     
Impacted Files Coverage Δ
pkg/skaffold/inspect/types.go 100.00% <ø> (ø)
cmd/skaffold/app/cmd/cmd.go 68.39% <50.00%> (ø)
cmd/skaffold/app/cmd/inspect_build_env.go 55.83% <56.66%> (-0.22%) ⬇️
pkg/skaffold/inspect/buildEnv/add_local.go 79.48% <79.48%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9647c41...d9f8aec. Read the comment docs.

Comment on lines +101 to +102
WithDescription("Add a new Local build environment definition").
WithLongDescription(`Add a new Local build environment definition.
Copy link
Member

Choose a reason for hiding this comment

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

Do we use camel case elsewhere? Maybe a single quote would be better 'local' to reflect what's actually added?

WithLongDescription(`Add a new Local build environment definition.
Without the '--profile' flag the new environment definition is added to the default pipeline. With the '--profile' flag it will create a new profile with this build env definition.
In these respective scenarios, it will fail if the build env definition for the default pipeline or the named profile already exists. To override an existing definition use 'skaffold inspect build-env modify' command instead.
Use the '--module' filter to specify the individual module to target. Otherwise, it'll be applied to all modules defined in the target file. Also, with the '--profile' flag if the target config imports other configs as dependencies, then the new profile will be recursively created in all the imported configs also.`).
Copy link
Member

Choose a reason for hiding this comment

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

The target file isn't actually defined — and there's no option to provide (--filename).

The recursive --profile behaviour is surprising and feels like it should be controlled with a --recursive flag?

Suggested change
Use the '--module' filter to specify the individual module to target. Otherwise, it'll be applied to all modules defined in the target file. Also, with the '--profile' flag if the target config imports other configs as dependencies, then the new profile will be recursively created in all the imported configs also.`).
Use the '--module' filter to target specific modules. Otherwise, it will be applied to all modules defined in the target file. Also, with the '--profile' flag if the target config imports other configs as dependencies, then the new profile will be recursively created in all the imported configs also.`).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There actually is a --filename flag. It seems like a bug (or I missed it) that flags added via cobra.Command.PersistentFlags don't show up in the --help text.


func AddLocalBuildEnv(ctx context.Context, out io.Writer, opts inspect.Options) error {
formatter := inspect.OutputFormatter(out, opts.OutFormat)
cfgs, err := inspect.ConfigSetFunc(config.SkaffoldOptions{ConfigurationFile: opts.Filename, ConfigurationFilter: opts.Modules, SkipConfigDefaults: true, MakePathsAbsolute: util.BoolPtr(false)})
Copy link
Member

Choose a reason for hiding this comment

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

ConfigSetFunc() seems an odd name. Shouldn't it be ConfigSet?


func localBuildEnvOptions() inspect.Options {
return inspect.Options{
Filename: inspectFlags.fileName,
Copy link
Member

Choose a reason for hiding this comment

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

Capitalization should be consistent: n vs N

cfgs = cfgs.SelectRootConfigs()
for _, cfg := range cfgs {
if cfg.Build.LocalBuild != nil && (*cfg.Build.LocalBuild != latestV1.LocalBuild{}) {
return formatter.WriteErr(inspect.BuildEnvAlreadyExists(inspect.BuildEnvs.Local, cfg.SourceFile, ""))
Copy link
Member

Choose a reason for hiding this comment

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

Huh, I thought To override an existing definition use 'skaffold inspect build-env modify' command instead meant if there were GCB or Cluster builds set.

@gsquared94 gsquared94 merged commit 6a7d2b9 into GoogleContainerTools:master Jun 4, 2021
@gsquared94
Copy link
Contributor Author

The auto-merge bot merged it before I could look at the review comments. I'll make the changes in a follow-up PR. Also the auto-merge should probably wait on unresolved comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't change build environment to local using skaffold inspect build-env add
2 participants