Skip to content

Support osc new-app from stored template - #1716

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
fabianofranz:new_app_from_template
Apr 20, 2015
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
fabianofranz:new_app_from_template

Conversation

@fabianofranz

Copy link
Copy Markdown
Contributor

No description provided.

@fabianofranz
fabianofranz force-pushed the new_app_from_template branch 2 times, most recently from 49d347a to ad9ff65 Compare April 13, 2015 21:54
Comment thread pkg/generate/app/cmd/newapp.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@smarterclayton I wasn't sure about the correct strategy here:

  1. Break down the template and handle each of its objects as one individual pipeline here in buildPipelines. I think this is the right approach, but I will need to figure out how to handle Services, Routes, etc.
  2. Break down the template before, maybe in validate and make each separate object a ComponentInput (I think it's wrong).
  3. Handle the Template as one single pipeline element returned by buildPipelines and break it down later.

Thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you describe a scenario where it would make sense for a reasonably complex template to be paired with the input of other components?

I.e.:

# mysql-cluster is a template
$ osc new-app php~somegitrepo mysql-cluster
# no overlap between components

# mysql-cluster is a template, mysql is an image
$ osc new-app mysql-cluster mysql
# doesn't seem like the two should overlap, but they might conflict on their service name

The only case I can think of is when you have a template and a git repo:

# eap is a template with a build config
$ osc new-app <gitrepo> eap

In this case, the "eap" template would have to define a build config (or at least an input image) and we'd need to know to link those up. So EAP's pipeline might be mutated to take the git repo as input... but that seems like a special case.

If the user specifies a single template, I don't think we should be breaking out the pipelines. In the case above, it seems almost like a special case. I would say that it's possible that templates should be given a chance to absorb arguments prior to execution, but then are added after the pipelines are joined. Templates should probably be kept together as long as possible, but we should identify conflicts with the other arguments as soon as possible.

Honestly, at this point it might be better to disallow any mixing, and simply focus on getting the validation and checking behavior right.

----- Original Message -----

  •       if ref.Input().ExpectToBuild {
    
  •           glog.V(2).Infof("will use %q as the base image for a source build of
    
    %q", ref, ref.Input().Uses)
  •           input, err := app.InputImageFromMatch(ref.Input().Match)
    
  •           if err != nil {
    
  •               return nil, fmt.Errorf("can't build %q: %v", ref.Input(), err)
    
  •           }
    
  •           strategy, source, err :=
    
    app.StrategyAndSourceForRepository(ref.Input().Uses)
  •           if err != nil {
    
  •               return nil, fmt.Errorf("can't build %q: %v", ref.Input(), err)
    
  •           }
    
  •           if pipeline, err = app.NewBuildPipeline(ref.Input().String(), input,
    
    strategy, source); err != nil {
  •               return nil, fmt.Errorf("can't build %q: %v", ref.Input(), err)
    
  •       // TODO template and other individual matches are mutually exclusive,
    
  •       // need to investigate the side-effects of having them together
    
  •       if ref.Input().Match.Template != nil {
    
  •           glog.V(2).Infof("will include objects from template %q", ref)
    

@smarterclayton I wasn't sure about the correct strategy here:

  1. Break down the template and handle each of its objects as one individual
    pipeline here in buildPipelines. I think this is the right approach, but I
    will need to figure out how to handle Services, Routes, etc.
  2. Break down the template before, maybe in validate and make each separate
    object a ComponentInput (I think it's wrong).
  3. Handle the Template as one single pipeline element returned by
    buildPipelines and break it down later.

Thoughts?


Reply to this email directly or view it on GitHub:
https://github.com/openshift/origin/pull/1716/files#r28283935

@fabianofranz
fabianofranz force-pushed the new_app_from_template branch 5 times, most recently from f70ea91 to 4f27b8f Compare April 14, 2015 23:33
@fabianofranz fabianofranz mentioned this pull request Apr 15, 2015
@fabianofranz
fabianofranz force-pushed the new_app_from_template branch from 4f27b8f to 435a450 Compare April 15, 2015 21:55
@fabianofranz

Copy link
Copy Markdown
Contributor Author

This pull request adds the ability to create apps based on stored templates using osc new-app. The command will first process the stored template and then create based on it.

Provided that you first run osc create -f examples/sample-app/application-template-stibuild.json from the origin root dir to store the stibuild template from sample-app, here are a few usage examples.

Create based in the ruby-helloworld-sample template (currently 8 objects and 5 parameters).

osc new-app ruby-helloworld-sample

Same, overriding 2 of the 8 parameters specified by the template:

osc new-app ruby-helloworld-sample --stored-template-parameters=MYSQL_USER=myuser,MYSQL_PASSWORD=mypass

Different kinds of inputs can be mixed (templates, images, source code, etc); but at the moment the command does not accept templates with source code explicitly attached to it (e.g. [template]~[code]). Also, every input component is handled individually, we don't break the template to verify dependencies between components (e.g. source code was provided so the template should provide a build config). Also, object names can conflict, we don't do prior validation against individual component names to check that (e.g. both the template and source code result in the creation of services with equal names).

osc new-app ruby-helloworld-sample mysql // OK
osc new-app ruby-helloworld-sample [email protected]/mfojtik/sinatra-app-example // OK, will create all components not attached to each other 
osc new-app [email protected]/mfojtik/sinatra-app-example // NOT SUPPORTED, the component before ~ can't be a template

@fabianofranz

Copy link
Copy Markdown
Contributor Author

@smarterclayton How does it sound (comment above)? We still could make it more restrictive (e.g. simply not allow templates and source to be provided together), but since it doesn't break in most scenarios other than eventual naming conflicts, I'm allowing multiple kinds of inputs to be provided together as long as they are not explicitly attached to templates through the use of ~.

@fabianofranz

Copy link
Copy Markdown
Contributor Author

[test]

@fabianofranz
fabianofranz force-pushed the new_app_from_template branch from 435a450 to aa559f7 Compare April 15, 2015 23:18
@fabianofranz fabianofranz changed the title WIP: support osc new-app from stored template Support osc new-app from stored template Apr 15, 2015
@fabianofranz
fabianofranz force-pushed the new_app_from_template branch from aa559f7 to eb33d18 Compare April 16, 2015 00:21
@fabianofranz

Copy link
Copy Markdown
Contributor Author

@csrwng please review

@fabianofranz
fabianofranz force-pushed the new_app_from_template branch 3 times, most recently from 0af79b8 to 1eaa3f0 Compare April 16, 2015 19:44
@fabianofranz

Copy link
Copy Markdown
Contributor Author

@csrwng All comments addressed. I ended up not using the same flag name --value used in osc process because in that command we are already in the context of manipulating templates, so "values" already implies "values to be set in the template". Here we are more generic so we have to be more specific in flag names.
Thanks for the review!

@fabianofranz
fabianofranz force-pushed the new_app_from_template branch from 1eaa3f0 to 72479c5 Compare April 16, 2015 20:41
@smarterclayton

Copy link
Copy Markdown
Contributor

Hold on merge of this until I have a chance to review tomorrow

On Apr 16, 2015, at 3:49 PM, Fabiano Franz [email protected] wrote:

@csrwng All comments addressed. I ended up not using the same flag name --value used in osc process because in that command we are already in the context of manipulating templates, so "values" already implies "values to be set in the template". Here we are more generic so we have to be more specific in flag names.
Thanks for the review!

—
Reply to this email directly or view it on GitHub.

@fabianofranz
fabianofranz force-pushed the new_app_from_template branch from 72479c5 to fde82d1 Compare April 17, 2015 14:03
@fabianofranz

Copy link
Copy Markdown
Contributor Author

@smarterclayton ok, thanks. already accepted by QE.

Comment thread hack/test-cmd.sh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you should not use my repo ;-) I managed to break people several times as I used it for my testing or testing features in STI :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's a negative test (command will fail in validations), so the repo is there just for your own fame and profit. :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually we use it in osc help. We need a good ootb example we can use in the docs - what's a good one?

On Apr 17, 2015, at 10:52 AM, Michal Fojtik [email protected] wrote:

In hack/test-cmd.sh:

@@ -343,6 +343,16 @@ echo "imageRepositoryMappings: ok"

the local image repository takes precedence over the Docker Hub "mysql" image

[ "$(osc new-app mysql -o yaml | grep mysql-55-centos7)" ]
osc new-app php mysql
+# check if we can create from a stored template
+osc create -f examples/sample-app/application-template-stibuild.json
+osc get template ruby-helloworld-sample
+[ "$(osc new-app ruby-helloworld-sample -o yaml | grep MYSQL_USER)" ]
+[ "$(osc new-app ruby-helloworld-sample -o yaml | grep MYSQL_PASSWORD)" ]
+[ "$(osc new-app ruby-helloworld-sample -o yaml | grep ADMIN_USERNAME)" ]
+[ "$(osc new-app ruby-helloworld-sample -o yaml | grep ADMIN_PASSWORD)" ]
+# create from template with code explicitly set is not supported
+[ ! "$(osc new-app ruby-helloworld-sample~[email protected]/mfojtik/sinatra-app-example)" ]

—
Reply to this email directly or view it on GitHub.

@fabianofranz
fabianofranz force-pushed the new_app_from_template branch from fde82d1 to 79770ff Compare April 17, 2015 15:17
@openshift-bot

Copy link
Copy Markdown
Contributor

Comment thread pkg/cmd/cli/cmd/newapp.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You need the Oxford comma (a, b, and c)

Comment thread pkg/cmd/cli/cmd/newapp.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These names are too long. --template should be used (and the output version should be renamed --output-template for this command, or for now, just dropped).

--stored-template-parameters is about 20 characters too long. I think this should be --param and -p

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also "TemplateParameters", not "TemplatesParameters"

@fabianofranz
fabianofranz force-pushed the new_app_from_template branch 2 times, most recently from 476bcd1 to f816e47 Compare April 20, 2015 20:18
@fabianofranz

Copy link
Copy Markdown
Contributor Author

@smarterclayton all comments addressed.

@smarterclayton

Copy link
Copy Markdown
Contributor

One comment, then squash and I'll merge

@fabianofranz
fabianofranz force-pushed the new_app_from_template branch from f816e47 to 887afed Compare April 20, 2015 21:05
@fabianofranz
fabianofranz force-pushed the new_app_from_template branch from 887afed to 90451df Compare April 20, 2015 21:05
@fabianofranz

Copy link
Copy Markdown
Contributor Author

@smarterclayton fixed and squashed.

@smarterclayton

Copy link
Copy Markdown
Contributor

LGTM [merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_openshift3/1620/) (Image: devenv-fedora_1313)

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin up to 90451df

openshift-bot pushed a commit that referenced this pull request Apr 20, 2015
@openshift-bot
openshift-bot merged commit d6028d1 into openshift:master Apr 20, 2015
@smarterclayton smarterclayton modified the milestone: 0.5.0 (beta3) Apr 23, 2015
jboyd01 pushed a commit to jboyd01/origin that referenced this pull request Feb 15, 2018
…service-catalog/' changes from b69b4a6c80..b758460ba7

b758460ba7 origin build: modify hard coded path
871582f73a origin build: add origin tooling
9fa4e70 chart changes for v0.1.8 (openshift#1741)
cada49c handle instance deletion that occurs during async provisioning or async update (openshift#1587) (openshift#1708)
3032f01 phony output binaries (openshift#1729)
0c98a72 remove last vestiges of glide (openshift#1696)
8435935 Prune vendor (openshift#1739)
0f657ec allow setting go version, clean up alignment
08af73f Disable test-dep target temporarily
41984a5 Check for existing bindings only for instances with DeprovisionStatus == ServiceInstanceDeprovisionStatusRequired. (openshift#1640)
706e555 chart changes for v0.1.7 (openshift#1721)
23644db we inconsistently rm thing with and without docker (openshift#1713)
a38092d Chart changes for Release v0.1.6 (openshift#1718)
2fd4ecf Add PodPreset into settings api group (openshift#1694)
bac68f4 update docs of developer's guide (openshift#1716)
3200b16 add integration test for proper async binding retry (openshift#1688)
6d809c3 Add custom columns to OpenAPI schema (openshift#1597)
fcdefa6 Workaround spf13/viper stringarray bug (openshift#1700)
ebbeb8c undo 6bad71d358ad3ad39eb8c003f5807cca1ec1d1e7 (openshift#1714)
1ee9659 Load all client auth plugins in the cli (openshift#1695)
b9ad10d must run tests (openshift#1698)
c621cdc add stages to Travis
REVERT: b69b4a6c80 origin build: modify hard coded path
REVERT: 527fac4d02 origin build: add origin tooling

git-subtree-dir: cmd/service-catalog/go/src/github.com/kubernetes-incubator/service-catalog
git-subtree-split: b758460ba7a45d370da9d5d634e71c16e9eb282a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants