Skip to content

Substitutions for setters #97

@squaremo

Description

@squaremo

Sometimes the image ref or tag (or digest) is part of a longer string in a field value. For example, in a container argument:

kind: Pod
spec:
  containers:
  - name: hello
    image: helloworld
    args:
    - --tag-argument=1.9.0 # <-- here

Using a setter won't work, since it'll replace the whole value. What's needed is a way to give a template for the whole value.

The existing solution to this in kyaml is "substitutions": you define a substitution in your schema file, which has a template with references to setter names; then, you name the substitution alongside the field. This is tricky in image-update-automation for a couple of reasons:

  • there's no schema file in which to put substitutions; possibly they could go in the automation, but this is distant to the point at which it is applied, so seems like the wrong place;
  • with simple setters, any that aren't defined (because they aren't in the namespace, or don't exist) will be ignored. How do you restrict what can be referred to in the template?

For these reasons, I propose a scheme like this:

  • the template is given in the marker
  • image policies are named in the same format as for simple setters; anything that refers to policies in different namespaces is ignored

This will mean implementing a kyaml filter, since the kyaml setters2 code won't handle templates given in the marker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions