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

cleaning up label keys 🧹 #4154

Merged
merged 1 commit into from
Aug 17, 2021
Merged

Conversation

pritidesai
Copy link
Member

@pritidesai pritidesai commented Aug 13, 2021

Changes

We have defined GroupName as a constant which is set to tekon.dev in register.go. We have other label keys defined in the same go file which are used by the controller to set the appropriate labels. These keys are TaskLabelKey, PipelineLabelKey, etc. These keys are set to "/task", "/pipeline", etc. Now while adding such labels in the Tekton
resources, we join GroupName to the constant label key. Instead, this commit changes the way we have defined a label key to include GroupName as part of the label key and use just the label key instead of concatenating GroupName everywhere. This cleans up the code and makes it simple to add tekton internal labels and at the same time retrieve them.

Most of the changes here are done using these two commands:

find . -type f -name "*.go" -print0 | xargs -0 sed -i '' -e 's/pipeline.GroupName+//g'
find . -type f -name "*.go" -print0 | xargs -0 sed -i '' -e 's/pipeline.GroupName +//g'

And I ran a sample pipeline to make sure the labels still have tekton.dev 🤣

kubectl get tr  pipelinerun-print-hello-print-hello-ppbfh -o json | jq .metadata.labels
{
  "app.kubernetes.io/managed-by": "tekton-pipelines",
  "tekton.dev/memberOf": "tasks",
  "tekton.dev/pipeline": "pipeline-print-hello",
  "tekton.dev/pipelineRun": "pipelinerun-print-hello",
  "tekton.dev/pipelineTask": "print-hello",
  "tekton.dev/task": "print-hello"
}

This cleanup was motivated while resuming work on #2891 😜

/kind cleanup

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in or deleted (only if no user facing changes)

Release Notes

The constants defined for the Tekton specific labels now include GroupName(tekton.dev) in the definition, for example:

Before this change:
const TaskLabelKey = "/task"

After this change:
const TaskLabelKey =  GroupName + "/task"

If you are importing these constants in your application from the pipeline source, you don't need to add GroupName anymore. 

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Aug 13, 2021
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 13, 2021
We have defined GroupName as a constant which is set to tekon.dev in
register.go. We have other label keys defined in the same go file which
are used by the controller to set the appropriate labels. These keys
are TaskLabelKey, PipelineLabelKey, etc. These keys are set to
"/task", "/pipeline", etc. Now while adding such labels in the tekton
resources, we join GroupName to the key. Instead, this commit changes the way
we have defined a label key to include GroupName as part of the label key and
use just the label key instead of concatinating while using the key. This
cleansup the code and makes it simple to add tekton internal labels and
retrieve them.
@ghost
Copy link

ghost commented Aug 13, 2021

I think it might be worth including a release note for this. If anyone's maintaining their own code that imports and uses these constants from the pipelines codebase then they'll need to be aware of the change.

/approve

Looks like the integration failure was just a flake.

/test pull-tekton-pipeline-integration-tests

@tekton-robot tekton-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesnt merit a release note. labels Aug 13, 2021
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 17, 2021
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbwsg, vdemeester

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

@tekton-robot tekton-robot merged commit f0a2f00 into tektoncd:main Aug 17, 2021
@pritidesai pritidesai deleted the cleanup-labels branch August 25, 2021 17:13
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants