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

Adds GoCD template support #81

Closed
wants to merge 1 commit into from

Conversation

lobsterdore
Copy link

Adds ability to specify GoCD templates from YAML, not working
currently.

Adds ability to specify GoCD templates from YAML, not working
currently.
@lobsterdore
Copy link
Author

lobsterdore commented Oct 7, 2018

@tomzo I can't seem to get this functionality working so perhaps you can point me in the right direction?

I've copied and paired down the pipeline parser in order to support templates, however I cannot get templates to appear in GoCD using this test repo - https://github.com/lobsterdore/gocd-yaml-tester/blob/master/template.gocd.yaml.

I've done some debugging and I can see that the YAML config plugin is indeed collecting all the template configuration from the test repo, however it never seems to wind up in GoCD,

I don't know much about GoCD or it's plugin architecture so I feel like I am missing a piece of the puzzle here, do I need to update an API request somewhere? I've searched through this plugin and I can't seem to find the answer.

@tomzo
Copy link
Owner

tomzo commented Oct 8, 2018

Hi @lobsterdore

I don't know much about GoCD or it's plugin architecture so I feel like I am missing a piece of the puzzle here, do I need to update an API request somewhere? I've searched through this plugin and I can't seem to find the answer.

I'm afraid there is much more to be changed on the server side than in the plugin. Most of config-repo functionally is actually implemented there as part of https://github.com/gocd/gocd/issues//1133 and all PRs related.
For start, the current model of a config-repo on server side defines configuration as a merge of XML elements and exactly one external source control repository. So introducing templates requires to start at changing that assumption.
There is an issue of handling parameters too, I don't see any in your example repository - https://github.com/lobsterdore/gocd-yaml-tester/blob/master/template.gocd.yaml

We have an on-going discussion on improvements to the config-repos in gocd/gocd#5175, including the templates. You should also see #2

@lobsterdore
Copy link
Author

lobsterdore commented Oct 8, 2018

@tomzo I had a feeling it would be way more complicated than this tiny PR :)

Could we utilise the REST API template endpoints to handle this? I know it's a bit of a hack, but it could get templates working whilst we wait for the necessary updates to GoCD, we could extract the parsed templates JSON, use this to update the templates via API calls and then process the rest of the JSON via the plugin APIs.

@tomzo
Copy link
Owner

tomzo commented Oct 8, 2018

we could extract the parsed templates JSON, use this to update the templates via API calls and then process the rest of the JSON via the plugin APIs.

It could work. But I think that is a hack with possibly a lot of unintended consequences.
If you want to go this way, you can try. I wouldn't merge that into master, because it would introduce a template model which is likely not maintainable in the future.

If I commit to implementing templates support, I would do it the right way. That was my approach in gocd/gocd#1133 and I stick to this. Otherwise its a lot of workarounds and wasted work in the end.
Btw, I would appreciate your ideas and feedback on how templates should look like, my last thoughts were in this comment.

For your particular needs - If you are already willing to use API to create templates, then perhaps consider using gomatic or terraform GoCD provider to do that.

@lobsterdore
Copy link
Author

@tomzo thanks for the feedback, it's much appreciated. I wasn't aware of Gomatic so I think I will head down that route for now, I will take a look at your comments as well.

Gonna close this PR for now since it's now useful as it stands.

@lobsterdore lobsterdore closed this Oct 8, 2018
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.

2 participants