-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add labels to templates #982
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
Conversation
|
@bparees fyi |
|
awesome! can we get a test case? |
0051005 to
2059d7a
Compare
|
Added test case to template/registry |
|
lgtm, you want anyone else to review or more edits before merging? |
pkg/template/api/types.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Labels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we can't just re-use the ObjectMeta labels? And apply/merge them with labels defined for the items?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfojtik that seems slightly abusive, particularly once we have a template repository and might want templates to actually have their own labels for their own purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bparees how about making it more explicit then? ItemLabels as they are intended to apply to all 'items' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfojtik it's ok with me, but i think @smarterclayton is going to reply with "Labels" again :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, none of these objects should really be in the root of the template - a template should have a section that is specifically for the items, and one specifically for the things to change.
It should really be something like:
{
"metadata": { // meta about the template },
"objects": [] // not "items", because then Template is interpreted by generic behavior to be a List
"spec": {
"parameters": [], // environment substitution
"label": {
"operation": "Add",
"labels": {} // these get added
}
}
}
We don't have to do that in v1beta1, but for v1beta2 it should be easy to clear the "spec" (or whatever it should be called) in one operation.
----- Original Message -----
@@ -16,6 +16,10 @@ type Template struct {
// Optional: Parameters is an array of Parameters used during the
// Template to Config transformation.
Parameters []Parameterjson:"parameters,omitempty"
+
- // Optional: ObjectLabels is a set of labels that are applied to every
- // object during the Template to Config transformation
- ObjectLabels map[string]string
json:"objectlabels,omitempty"@mfojtik it's ok with me, but i think @smarterclayton is going to reply with
"Labels" again :)
Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/982/files#r24756230
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarterclayton @bparees @mfojtik - if the change suggested above is for v1beta2, then for now should it be called ObjectLabels? or ItemLabels? (I'm ok with either one). We can't call it Labels because it overrides the one in ObjectMetadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call it Labels externally and ObjectLabels internally.
----- Original Message -----
@@ -16,6 +16,10 @@ type Template struct {
// Optional: Parameters is an array of Parameters used during the
// Template to Config transformation.
Parameters []Parameterjson:"parameters,omitempty"
+
- // Optional: ObjectLabels is a set of labels that are applied to every
- // object during the Template to Config transformation
- ObjectLabels map[string]string
json:"objectlabels,omitempty"@smarterclayton @bparees @mfojtik - if the change suggested above is for
v1beta2, then for now should it be called ObjectLabels? or ItemLabels? (I'm
ok with either one). We can't call it Labels because it overrides the one in
ObjectMetadata.
Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/982/files#r24821525
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smarterclayton - by externally vs internally do you mean internal api vs versioned api ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the versioned API can be labels (since that's JSON, and in JSON it's clear) and internally you can use ObjectLabels.
----- Original Message -----
@@ -16,6 +16,10 @@ type Template struct {
// Optional: Parameters is an array of Parameters used during the
// Template to Config transformation.
Parameters []Parameterjson:"parameters,omitempty"
+
- // Optional: ObjectLabels is a set of labels that are applied to every
- // object during the Template to Config transformation
- ObjectLabels map[string]string
json:"objectlabels,omitempty"@smarterclayton - by externally vs internally do you mean internal api vs
versioned api ?
Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/982/files#r24905989
2012291 to
c4ec466
Compare
|
Updated json annotation to use 'labels' for ObjectLabels |
c4ec466 to
845a635
Compare
|
Please change the field name in the Go struct in the external version. |
845a635 to
4dd6bc0
Compare
|
done. |
|
Add it to the Resource printer for templates as a column and to the describer and you're good |
|
Actually, don't put it in the printer. In the describer be sure to associate it with the objects (since labels gets shown at the top |
bfdf64e to
608f6ca
Compare
608f6ca to
22541e1
Compare
|
@smarterclayton - I'll look into the upstream code to find out why DefaultConvert is overwriting Labels on the base object and not just the one in ObjectMetadata. For now, the ordering of the convert calls is important. I added a comment to that part of the code. |
|
LGTM [merge] |
|
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_openshift3/980/) (Image: devenv-fedora_851) |
|
Evaluated for origin up to 22541e1 |
Merged by openshift-bot
Adds a new field to templates that includes a set of labels to apply to all objects during template processing.