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 labels to render #3558

Merged

Conversation

arminbuerkle
Copy link
Contributor

Fixes #3482.

Description
Adds the --label option to skaffold render.

@nkubala didn't have much time the last weeks, but here is the follow up of #3110 (comment)

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 --label option to skaffold render

@codecov
Copy link

codecov bot commented Jan 22, 2020

Codecov Report

Merging #3558 into master will increase coverage by 0.07%.
The diff coverage is 76.92%.

Impacted Files Coverage Δ
pkg/skaffold/deploy/deploy.go 100% <ø> (ø) ⬆️
cmd/skaffold/app/cmd/flags.go 100% <ø> (ø) ⬆️
pkg/skaffold/runner/render.go 0% <0%> (ø) ⬆️
pkg/skaffold/deploy/kustomize.go 71.62% <100%> (ø) ⬆️
pkg/skaffold/deploy/deploy_mux.go 89.13% <100%> (ø) ⬆️
pkg/skaffold/deploy/helm.go 78.64% <100%> (ø) ⬆️
pkg/skaffold/deploy/kubectl.go 66.4% <71.42%> (+0.52%) ⬆️
pkg/skaffold/schema/defaults/defaults.go 91.44% <0%> (-2.97%) ⬇️
pkg/skaffold/initializer/init.go 64.81% <0%> (ø) ⬆️
cmd/skaffold/app/cmd/init.go 100% <0%> (ø) ⬆️
... and 6 more

input: `apiVersion: v1
kind: Pod
metadata:
Copy link
Member

Choose a reason for hiding this comment

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

was there a reason for adding this in input?

  metadata
     namespace: default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! If metadata doesn't exist, the default labeller doesn't execute, therefore not adding any labels.

Without it skaffold.dev/deployer: kubectl won't be added.

@tejal29 tejal29 added the kokoro:run runs the kokoro jobs on a PR label Jan 27, 2020
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Jan 27, 2020
arminbuerkle and others added 5 commits January 27, 2020 13:48
Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>
@tejal29
Copy link
Member

tejal29 commented Jan 27, 2020

@arminbuerkle i rebased your branch on latest master and added another test

+               {
+                       description: "single kustomization with user labels",
+                       builds: []build.Artifact{
+                               {
+                                       ImageName: "gcr.io/project/image1",
+                                       Tag:       "gcr.io/project/image1:tag1",
+                               },
+                               {
+                                       ImageName: "gcr.io/project/image2",
+                                       Tag:       "gcr.io/project/image2:tag2",
+                               },
+                       },
+                       labels: []Labeller{
+                               &testLabels{
+                                       labels: map[string]string{
+                                               "user/label": "test",
+                                       }},
+                       },
+                       kustomizations: []kustomizationCall{
+                               {
+                                       folder: ".",
+                                       buildResult: `apiVersion: v1
+kind: Pod
+metadata:
+  namespace: default
+spec:
+  containers:
+  - image: gcr.io/project/image1
+    name: image1
+  - image: gcr.io/project/image2
+    name: image2
+`,
+                               },
+                       },
+                       expected: `apiVersion: v1
+kind: Pod
+metadata:
+  labels:
+    skaffold.dev/deployer: kustomize
+    user/label: test
+  namespace: default

If you give me permission to push to your branch, i can update this PR and merge it.

@arminbuerkle
Copy link
Contributor Author

If you give me permission to push to your branch, i can update this PR and merge it.

@tejal29 i added you as a collaborator to our repository. For some reason i don't have the allow maintainers to edit checkbox in this PR?

@tejal29
Copy link
Member

tejal29 commented Jan 28, 2020

@arminbuerkle i got the request! Thanks!

@tejal29 tejal29 added the kokoro:run runs the kokoro jobs on a PR label Jan 28, 2020
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Jan 28, 2020
@dgageot dgageot merged commit fad917c into GoogleContainerTools:master Jan 30, 2020
kissmikijr pushed a commit to kissmikijr/skaffold that referenced this pull request Feb 3, 2020
* Add labeller to render

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>

* Add labeller to integration test

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>

* Add kustomize render labeller unit test

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>

* Add kubectl render labeller unit test

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>

* rebase from master and add one more test

Co-authored-by: Tejal Desai <tejal29@gmail.com>
kissmikijr pushed a commit to kissmikijr/skaffold that referenced this pull request Feb 3, 2020
* Add labeller to render

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>

* Add labeller to integration test

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>

* Add kustomize render labeller unit test

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>

* Add kubectl render labeller unit test

Signed-off-by: Armin Buerkle <armin.buerkle@alfatraining.de>

* rebase from master and add one more test

Co-authored-by: Tejal Desai <tejal29@gmail.com>
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.

Support setting labels in skaffold render
6 participants