-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Project Template #18
Project Template #18
Conversation
// s := generate.Template("[GET:http://example.com/new]") | ||
// // s: <body from the GET request> | ||
func (p *Template) ProcessParameters() { | ||
rand.Seed(p.RandomSeed) |
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.
The template should have a *rand.Rand that is initialized at creation time. Methods should never change the seed
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.
How are you going to handle passed parameters? What if I want to pass a parameter that is listed as generate? Needs to be a way to do that - remember that this is a transition process - so either the p is the process, or the method call is the process and the method call would need to take a thing to transform.
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.
All parameters in parameters
definition in JSON are used automatically, so you don't need to pass a list of them as an argument to transformation.
If the JSON defines parameter that has generate
then the value is generated when this method is invoked for the first time.
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.
So I think template transformations should create a new object just as a general cleanliness issue. You're loading a template and transforming it - it should be clear what is user input (override parameters) and what is part of the template (defaults / generation). When you invoke the transformation, those overrides should be explicitly passed, checked, then resolved. I just don't think process is a method on templates, it's a method on a transformation object
@smarterclayton PR updated, Once we agree on the JSON template example, I will update the structs in this PR and processing of env vars. |
@smarterclayton updated, I added @smarterclayton any additional comments/review? |
// | ||
// s := generate.Template("[GET:http://example.com/new]") | ||
// // s: <body from the GET request> | ||
func (p *Template) ProcessParameters(customParams []Parameter) { |
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.
In the API model, no methods can be defined on API model objects (they are DAO or value objects). So you need to create a templateProcessor object or something similar to handle taking a template and transforming it into a new template
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.
This is just processing the parameters, iow. generate will produce parameter 'value'. I do agree that the 'Transform' method should be probably defined on templateProcessor
which should be most likely interfaced OR as a non-struct method (TransformTemplate(t *Template))
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.
Again, this is answering my later question in pull/18. :)
@smarterclayton I revamped this PR into a new PR: #27 The new PR use the latest JSON schema (updating this PR was not so hard as I thought, so no reason to postpone it for the next sprint I think). I'm going to close this PR, is it OK? |
More rebase fixes to Template and Config
Use library function to get hostname.
Automatic merge from submit-queue. CLI: add support for deployments in oc status @smarterclayton this is a long overdue... current state: ``` $ oc status In project My Project (myproject) on server https://127.0.0.1:8443 svc/ruby-deploy - 172.30.174.234:8080 deployment/ruby-deploy deploys istag/ruby-deploy:latest <- bc/ruby-deploy source builds https://github.com/openshift/ruby-ex.git on istag/ruby-22-centos7:latest build #1 failed 5 hours ago - bbb6701: Merge pull request #18 from durandom/master (Ben Parees <[email protected]>) deployment #2 running for 4 hours - 0/1 pods (warning: 53 restarts) deployment #1 deployed 5 hours ago ``` TODO: - [x] Add rollouts similar to deployment configs - [x] Fix unit tests / Add unit tests - [x] Deal with HPA
This is an WIP of the Project Template work.
The code below define the Project structs and implement parameters substitution for the JSON.
Changelog
Parameter
more effective by converting theParameters
to HashPValue#Substitute
function now modifies the value of itselfServiceLinks
toSubstituteEnvValues
rand.Seed
toProcessParameters
ServiceLinks
resolving in terms that environment variables exported by the ServiceLink are copied into target service.