Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Standardize use of templates #353

Merged
merged 14 commits into from Jan 6, 2017
Merged

Conversation

chungers
Copy link
Contributor

@chungers chungers commented Jan 6, 2017

This PR aims to standardize on a common wrapper around the golang templates library. This is necessary to provide a common set of functions for all use cases of templating in this project. We expect to leverage templates more heavily to make the plugins more cusomizable without code change.

  • Previously the vagrant and swarm plugins all use lots of boilerplate code for template processing, this PR creates a common layer and changed the plugins to follow a consistent pattern of externalizing the templates (e.g. the vagrant file used by the Vagrant plugin and the userdata / init bootscript generated by the swarm flavor) as resources that can be located via a URL:
    • as local files - file:///abs/path/to/the/template
    • as http resources - http://host:port/path/to/template
  • A new template package provides common abstractions on using templates, with support for
    • inclusion of other templates (similar to Helm Charts)
    • useful template functions from Sprig
    • see integration_test.go for examples.
  • Updated the plugins to use a common drop-in replacement of text/template; updated the main.go in each to support specification of template URL with command-line flags.
  • Added tests

David Chung added 13 commits January 1, 2017 23:54
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
Signed-off-by: David Chung <david.chung@docker.com>
…al file and http remotes, plus json encoding/decoding

Signed-off-by: David Chung <david.chung@docker.com>
@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "templates" git@github.com:chungers/infrakit.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842353402680
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

Signed-off-by: David Chung <david.chung@docker.com>
@codecov-io
Copy link

codecov-io commented Jan 6, 2017

Current coverage is 64.88% (diff: 50.24%)

Merging #353 into master will decrease coverage by 1.86%

@@             master       #353   diff @@
==========================================
  Files            33         38     +5   
  Lines          1753       1942   +189   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           1170       1260    +90   
- Misses          467        548    +81   
- Partials        116        134    +18   

Powered by Codecov. Last update a144077...46fbe81

@chungers chungers merged commit a5967a1 into docker-archive:master Jan 6, 2017
@chungers chungers deleted the templates branch January 6, 2017 07:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants