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

add template funcs #212

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

add template funcs #212

wants to merge 2 commits into from

Conversation

coryb
Copy link
Contributor

@coryb coryb commented Nov 25, 2020

This adds the sprig template funcs for general usage
Also I have added several docker image parsing template funcs which I have needed for various docker image publishing routines.

return map[string]interface{}{
// dockerDomain returns the domain/host information for the provided
// docker image
"dockerDomain": func(in string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it have to be dockerFoo? Could this be imageRefDomain or something a bit more OCI-friendly? 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

Was chatting on slack, but I was suggesting since we had interpolation support in heredocs, I prefer if we use regular string functions rather than template functions.

Along with the array support proposal, you could do something like:

[]string dockerRegistries() {
	"titusregistry.us-east-1.netflix.net"
	"titusregistry.us-west-2.netflix.net"
}

[]string pushTargets(string ref) {
	for (string registry in dockerRegistries) {
		"${registry}/${dockerPath(ref)}:${dockerTag(ref)}
	}
}

fs titusPush(string ref) {
	for (string target in pushTargets(ref)) {
		dockerPush target
	}
}

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.

3 participants