Skip to content

Disable profiles with the command line#4054

Merged
balopat merged 1 commit intoGoogleContainerTools:masterfrom
dgageot:fix-3988
May 1, 2020
Merged

Disable profiles with the command line#4054
balopat merged 1 commit intoGoogleContainerTools:masterfrom
dgageot:fix-3988

Conversation

@dgageot
Copy link
Copy Markdown
Contributor

@dgageot dgageot commented Apr 29, 2020

Fixes #3988

Signed-off-by: David Gageot david@gageot.net

Fixes GoogleContainerTools#3988

Signed-off-by: David Gageot <david@gageot.net>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 29, 2020

Codecov Report

Merging #4054 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted Files Coverage Δ
cmd/skaffold/app/cmd/flags.go 100.00% <ø> (ø)
pkg/skaffold/schema/profiles.go 91.44% <100.00%> (+0.48%) ⬆️
...affold/kubernetes/portforward/kubectl_forwarder.go 65.85% <0.00%> (-2.44%) ⬇️

@balopat balopat merged commit efee084 into GoogleContainerTools:master May 1, 2020
@pierreyves-lebrun
Copy link
Copy Markdown

How does that work?

Things like skaffold dev -p db,-dev or skaffold dev -p db -p dev fail.

@briandealwis
Copy link
Copy Markdown
Member

You can use multiple -p arguments, and/or provide a comma-separated list.

I tried the Skaffold examples/profiles project. I use a minikube cluster, so the normal build would automatically activate the minikube-profile and so Skaffold will build skaffold-world:

$ skaffold build
Generating tags...
 - skaffold-hello -> skaffold-hello:v1.12.0-37-g6af3198f3
Checking cache...
 - skaffold-hello: Not found. Building
Found [minikube] context, using local docker daemon.
Building [skaffold-hello]...

I explicitly disable both the staging-profile (which was never active anyways) and the minikube-profile, then I see the skaffold-world project is built, as expected:

$ skaffold build -p -staging-profile,-minikube-profile
Generating tags...
 - skaffold-world -> skaffold-world:v1.12.0-37-g6af3198f3
Checking cache...
 - skaffold-world: Not found. Building
Found [minikube] context, using local docker daemon.
Building [skaffold-world]...

And with separate -p arguments:

$ skaffold build -p -minikube-profile -p -staging-profile 
Generating tags...
 - skaffold-world -> skaffold-world:v1.12.0-37-g6af3198f3
Checking cache...
 - skaffold-world: Not found. Building
Found [minikube] context, using local docker daemon.
Building [skaffold-world]...

@pierreyves-lebrun
Copy link
Copy Markdown

@briandealwis Thanks for confirming.

It seems profiles prefixed with - cause Skaffold to generate invalid manifests.

Below is the error I am getting when running things likeskaffold dev -p db,-dev:

 - Error from server (Invalid): error when creating "STDIN": Service "db" is invalid: metadata.labels: Invalid value: "-dev": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
 - Error from server (Invalid): error when creating "STDIN": Deployment.apps "db" is invalid: [metadata.labels: Invalid value: "-dev": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?'), spec.template.labels: Invalid value: "-dev": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')]
Cleaning up...
exiting dev mode because first deploy failed: kubectl error: kubectl apply: exit status 1

@briandealwis
Copy link
Copy Markdown
Member

@pierreyves-lebrun could you please open a new issue, link to this issue, and include your skaffold.yaml so that we can reproduce?

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.

Explicit deactivation of profile via CLI argument

5 participants