Skip to content

Add kubectl config flag to disable validation#3512

Merged
dgageot merged 1 commit intoGoogleContainerTools:masterfrom
zmb3:zb-add-kubectl-validate-flag
Jan 22, 2020
Merged

Add kubectl config flag to disable validation#3512
dgageot merged 1 commit intoGoogleContainerTools:masterfrom
zmb3:zb-add-kubectl-validate-flag

Conversation

@zmb3
Copy link
Copy Markdown
Contributor

@zmb3 zmb3 commented Jan 16, 2020

Fixes #3222

Relates to n/a

Should merge before : n/a

Should merge after : n/a

Description

Add config flag to disable validation when using the kubectl deployer.
When enabled, --validate=false is passed to the kubectl apply and kubectl create commands.

User facing changes

n/a

Before

n/a

After

n/a

Next PRs.

n/a

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
  • Mentions any output changes.
  • Adds documentation as needed: user docs, YAML reference, CLI reference.
  • Adds integration tests if needed.

Reviewer Notes

  • The code flow looks good.
  • Unit test added.
  • User facing changes look good.

Release Notes

  • Add config option to disable validation when using the kubectl deployer.

@dgageot dgageot self-assigned this Jan 16, 2020
@dgageot dgageot added the kokoro:run runs the kokoro jobs on a PR label Jan 16, 2020
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Jan 16, 2020
// RemoteManifests lists Kubernetes manifests in remote clusters.
RemoteManifests []string `yaml:"remoteManifests,omitempty"`

// DisableValidation passes the `--valdiate=false` flag to supported
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

validate

DisableValidation bool `yaml:"validate,omitempty"`

// Flags are additional flags passed to `kubectl`.
Flags KubectlFlags `yaml:"flags,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if DisableValidation could be under KubectlFlags somehow?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think we want it under KubectlFlags, because those flags are applied for any kubectl command we run, and --validate is only a valid option on some commands.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I meant, could we add a DisableValidation field to KubectlFlags and apply that to supported kubectl commands.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, right. That makes a lot of sense!

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 16, 2020

Codecov Report

Merging #3512 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted Files Coverage Δ
pkg/skaffold/schema/latest/config.go 100% <ø> (ø) ⬆️
pkg/skaffold/deploy/kubectl/cli.go 94.73% <100%> (+0.61%) ⬆️

@dgageot dgageot added pr/changes-requested kokoro:run runs the kokoro jobs on a PR labels Jan 16, 2020
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Jan 16, 2020
CLI: kubectl.NewFromRunContext(runCtx),
Flags: runCtx.Cfg.Deploy.KubectlDeploy.Flags,
ForceDeploy: runCtx.Opts.Force,
DisableValidation: runCtx.Cfg.Deploy.KubectlDeploy.Flags.DisableValidation,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line is not required, now

ForceDeploy bool
previousApply ManifestList
ForceDeploy bool
DisableValidation bool
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is included in Flags

args = append(args, "--force", "--grace-period=0")
}

if c.DisableValidation {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

c. Flags. DisableValidation

}

args := c.args([]string{"--dry-run", "-oyaml"}, list...)
if c.DisableValidation {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

c. Flags. DisableValidation


// DisableValidation passes the `--validate=false` flag to supported
// `kubectl` commands when enabled.
DisableValidation bool `yaml:"validate,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for making all the changes!
One more problem and we should be good to go:
DisableValidation can't be called validate in the yaml. The first one is a negation. disableValidation seems an ok name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review and patience as I try to squeeze this in my mornings :-)

@dgageot
Copy link
Copy Markdown
Contributor

dgageot commented Jan 17, 2020

Oh, I'm sorry @zmb3, we released the v2alpha2 schema yesterday. I'll have to prepare a new v2alpha3 schema that you can rebase on top of. I won't do it before Monday, though.

@dgageot
Copy link
Copy Markdown
Contributor

dgageot commented Jan 17, 2020

@zmb3 Should be ready for a rebase

@zmb3
Copy link
Copy Markdown
Contributor Author

zmb3 commented Jan 17, 2020

Thanks @dgageot, that was fast for not before Monday!

@dgageot dgageot added the kokoro:run runs the kokoro jobs on a PR label Jan 22, 2020
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Jan 22, 2020
@dgageot
Copy link
Copy Markdown
Contributor

dgageot commented Jan 22, 2020

\o/

@dgageot dgageot merged commit 7d7f3c1 into GoogleContainerTools:master Jan 22, 2020
@zmb3 zmb3 deleted the zb-add-kubectl-validate-flag branch January 27, 2020 18:06
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.

kubectl deployer doesn't offer a way to skip validation

4 participants