Description
This is a followup for the discussion in #71
Lets imagine
BUILD:
k8s_object(
name = "deployment",
template = ":deployment.yaml",
images = {
"web-frontend": "//src/docker/web_frontend:web_frontend",
},
)
deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
spec:
replicas: 1
template:
spec:
containers:
- name: web-frontend
image: web-frontend
Since the rules are using a simple expand_template action and the substitution keys are simple words, this will replace web-frontend in both name and image.
A naive approach would be to make the key in the substitution something like "image: " + spec
so that it only applies to image tags. But this would not be robust for whilespaces and formatting variants (template can be yaml and json).
A better approach would be to mark the substitutions (this is what we do). That is in the file write e.g. "${web-frontend}" you wrap the substitutions keys with '${' + '}', but this won't be backwards compatible. I think this would be a much better approach though. Maybe we can add a boolean flag to enable substitution_guards
. Or if people write the key in images as '${web-frondend}' you remove the guards to get the actual image name. Then we don't need the flag.