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

feat: add support for labels in func.yaml #373

Merged
merged 3 commits into from Aug 3, 2021

Conversation

lance
Copy link
Member

@lance lance commented Jun 3, 2021

This change adds support for setting labels on deployed functions via func.yaml. The CLI will assume that func.yaml is the definitive source of information about what labels should exist on the deployed Service, and each deploy ensures that the labels in the deployed Service and what's in func.yaml are in sync.

Fixes: #261

Signed-off-by: Lance Ball lball@redhat.com

@lance lance requested a review from a team June 3, 2021 20:48
@lance lance self-assigned this Jun 3, 2021
Copy link
Contributor

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

Looking good, minor nit: do we want to validate the specified labels in the func.yaml or do we want to keep the validation on the actual deployment process via Knative?

Documentation is missing for this field.

@zroubalik
Copy link
Contributor

zroubalik commented Jun 4, 2021

kn allows users to set and unset labels this way, I wonder whether there is possibility for us to use something similar:

  -l, --label stringArray                 Labels to set for both Service and Revision. name=value; you may provide this flag any number of times to set multiple labels.
                                          To unset, specify the label name followed by a "-" (e.g., name-).

@lance
Copy link
Member Author

lance commented Jun 4, 2021

Looking good, minor nit: do we want to validate the specified labels in the func.yaml or do we want to keep the validation on the actual deployment process via Knative?

What kind of validation are you thinking of?

@lance
Copy link
Member Author

lance commented Jun 4, 2021

kn allows users to set and unset labels this way,

For us, I suppose the -l flag would be only on deploy. Is this what you had in mind?

@zroubalik
Copy link
Contributor

Looking good, minor nit: do we want to validate the specified labels in the func.yaml or do we want to keep the validation on the actual deployment process via Knative?

What kind of validation are you thinking of?

Just a check that the input value is a valid k8s label, as per: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

But that's just a question, if we don't do the check it will fail during the deployment anyway.

@zroubalik
Copy link
Contributor

zroubalik commented Jun 7, 2021

kn allows users to set and unset labels this way,

For us, I suppose the -l flag would be only on deploy. Is this what you had in mind?

I just want to give users way how to remove a label, because the current solution allows only adding/updating labels, not removing (they would have to undeploy and deploy the function again in order to get rid of labels that were specified before).

I am not sure that the flag is the best solution, but what else do we have? 🤷‍♂️
(Maybe func config labels which would fetch all labels and then allow users to remove the specific ones?...)

@lance lance marked this pull request as draft June 21, 2021 19:08
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 14, 2021
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 19, 2021
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 19, 2021
@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance, lkingland

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 19, 2021
@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 19, 2021
@lance lance marked this pull request as ready for review July 19, 2021 21:20
@lance
Copy link
Member Author

lance commented Jul 19, 2021

I've updated this so that it's integrated with the interactive prompt that Zbynek recently introduced, and I have added tests. I think it should be ready for review. PTAL

/cc @zroubalik @lkingland @matejvasek

@matejvasek
Copy link
Contributor

why is pkged.go modified?

cmd/config_labels.go Outdated Show resolved Hide resolved
cmd/config_labels.go Outdated Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 27, 2021
@lance lance marked this pull request as draft July 27, 2021 17:36
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 27, 2021
config.go Show resolved Hide resolved
@lance lance marked this pull request as ready for review July 30, 2021 14:35
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 30, 2021
@lance
Copy link
Member Author

lance commented Jul 30, 2021

OK - one more time @lkingland @zroubalik and @matejvasek - sorry this has been so long in the making. I think finally it's good for a final review.

@lkingland
Copy link
Member

/lgtm

@knative-prow-robot knative-prow-robot added lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 1, 2021
@lkingland
Copy link
Member

@lance a recent PR fixes the Makefile such that build again correctly omits updating pkged.go unless there has been changes in ./templates.

Copy link
Contributor

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

Lookin good, just a minor nit

config.go Outdated Show resolved Hide resolved
This change adds support for setting labels on deployed functions. It uses
the interactive CLI prompt introduced by Zbynek to add, remove and list
labels applied on a deployed function.

Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Lance Ball <lball@redhat.com>
@knative-prow-robot knative-prow-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 2, 2021
@matejvasek
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 3, 2021
@knative-prow-robot knative-prow-robot merged commit 0dba677 into knative:main Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. kind/enhancement lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add additional labels to function deployments
5 participants