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

allow namespace specification via parameter in templates #12918

Merged
merged 1 commit into from
Feb 18, 2017

Conversation

bparees
Copy link
Contributor

@bparees bparees commented Feb 10, 2017

with this change it's now possible to set a namespace on objects in a template and have them created in that namespace. (prior to this change, any namespace value in the template object was cleared and the objects were created in the target namespace for the template instantiation).

notice that we're intentionally still clearing hardcoded namespace values to provide some level of backwards compatibility, but if the namespace value comes from parameter substitution, we respect the parameter value for the object creation.

@bparees bparees changed the title [DO_NOT_MERGE] allow namespace specification via parameter in templates allow namespace specification via parameter in templates Feb 13, 2017
@bparees bparees force-pushed the template_namespace branch 2 times, most recently from d259a09 to 2ecca27 Compare February 13, 2017 20:50
@bparees
Copy link
Contributor Author

bparees commented Feb 13, 2017

[testextended][extended:core(image_ecosystem)]

@smarterclayton ptal + sign off on api change
@openshift/devex ptal

@bparees
Copy link
Contributor Author

bparees commented Feb 13, 2017

@smarterclayton also weigh in on whether you want to take the risk of putting this in 3.5 because you have plans for it, or hold it until 3.6.

@bparees
Copy link
Contributor Author

bparees commented Feb 13, 2017

[test]

Copy link
Contributor

@gabemontero gabemontero left a comment

Choose a reason for hiding this comment

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

A few minor suggestions / questions.

// If an object definition's metadata includes a namespace field, the field will be stripped out of
// the definition during template instantiation. This is necessary because all objects created during
// instantiation are placed into the target namespace, so it would be invalid for the object to declare
//a different namespace.
stripNamespace(newItem)
stripNamespace(item)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't either the comment above be tweaked, or a new comment added after this line, to equally reflect the new caveat of a parameter being able to override, even though the user still cannot explicitly set the namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup, thanks

"apiVersion": "v1",
"metadata": {
"name": "route-edge4",
"namespace": "prefix-${{SUBSTITUTED}}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would an additional Route object with a namespace of the form "${SUBSTITUED}-suffix" provide additional test coverage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really, no. i mean "yes it would provide additional coverage" but not of a scenario i'm particularly worried about us breaking. (even doing the prefix testing at all is probably overkill)

Copy link
Contributor

Choose a reason for hiding this comment

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

ok cool

@@ -50,6 +52,23 @@ os::cmd::expect_failure 'oc get dc/mysql'
os::cmd::expect_failure 'oc get dc/php'
os::cmd::expect_success_and_text 'oc new-app -f test/testdata/template-without-app-label.json -o yaml' 'app: ruby-helloworld-sample'

# check object namespace handling
# hardcoded values should be stripped
os::cmd::expect_success_and_not_text 'oc new-app -f test/testdata/template-with-namespaces.json -o yaml' 'namespace: STRIPPED'
Copy link
Contributor

Choose a reason for hiding this comment

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

Use of -o jsonpath would be a more precise way to verify the namespace field for all of these new additions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea.

@smarterclayton
Copy link
Contributor

Risk seems low. Add to the Godoc for templates a description of this behavior (how namespace is handled). Also make a comment on the "objects" fied

@bparees
Copy link
Contributor Author

bparees commented Feb 15, 2017

Add to the Godoc for templates a description of this behavior (how namespace is handled). Also make a comment on the "objects" fied

I doc'd the objects field to fully explain the namespace handling behavior. Putting it in the template godoc feels redundant.

@smarterclayton @gabemontero updates made.

@gabemontero
Copy link
Contributor

igtm

@@ -26,6 +26,11 @@ type Template struct {
Parameters []Parameter

// objects is an array of resources to include in this template.
// If a namespace value is hardcoded in the object, it will be removed
// during template instantiation, however if the namespace value
// is, or container, a ${PARAMETER_REFERENCE}, the resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Contains

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops, thanks.

@smarterclayton
Copy link
Contributor

Lgtm, swagger needs to be regen'd after your typo, let's put this in now since it's low risk and opens the door for templates for infra tools. Add a release note

@bparees
Copy link
Contributor Author

bparees commented Feb 15, 2017

@smarterclayton typo fixed, will push in a second. Where are we tracking release notes these days?

@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 15, 2017 via email

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 2dfefb2

@bparees
Copy link
Contributor Author

bparees commented Feb 15, 2017

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin testextended up to 2dfefb2

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_future/247/) (Base Commit: a0ea9b5)

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin_extended/1110/) (Base Commit: efab088) (Extended Tests: core(image_ecosystem))

@bparees
Copy link
Contributor Author

bparees commented Feb 16, 2017

[merge]

@bparees
Copy link
Contributor Author

bparees commented Feb 16, 2017

flake #12993

@bparees
Copy link
Contributor Author

bparees commented Feb 17, 2017

pretty sure this is not a flake, but:
#12995

[merge]

@bparees
Copy link
Contributor Author

bparees commented Feb 17, 2017

[merge]

@bparees
Copy link
Contributor Author

bparees commented Feb 17, 2017

[merge]

@bparees
Copy link
Contributor Author

bparees commented Feb 17, 2017

(flake #10773)

@smarterclayton
Copy link
Contributor

smarterclayton commented Feb 17, 2017 via email

@bparees
Copy link
Contributor Author

bparees commented Feb 17, 2017

flake #9845
[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 2dfefb2

@openshift-bot
Copy link
Contributor

openshift-bot commented Feb 18, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_future/317/) (Base Commit: e4300b3) (Image: devenv-rhel7_5931)

@openshift-bot openshift-bot merged commit aa49370 into openshift:master Feb 18, 2017
@bparees bparees deleted the template_namespace branch February 21, 2017 19:41
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.

4 participants