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

Image tag marker doesn't work in top-level yaml array #624

Open
antonosmond opened this issue Jan 11, 2024 · 5 comments
Open

Image tag marker doesn't work in top-level yaml array #624

antonosmond opened this issue Jan 11, 2024 · 5 comments

Comments

@antonosmond
Copy link

I was trying to use the image update automation to update a tag in a generic YAML file in git.
I found it doesn't update the image tag in the YAML if the YAML file has a top-level array.
A file like this doesn't work i.e. the image automation never updates the tag:

- serviceName: busybox
  containerName: busybox
  tag: 0.0.1 # {"$imagepolicy":"flux-system:busybox:tag"}

But this works:

serviceName: busybox
containerName: busybox
tag: 0.0.1 # {"$imagepolicy":"flux-system:busybox:tag"}

And this also works:

tags:
  - serviceName: busybox
    containerName: busybox
    tag: 0.0.1 # {"$imagepolicy":"flux-system:busybox:tag"}

I'm not sure what versions of flux this applies to but I'm using:

$ flux -v
flux version 2.0.1

And the image automation controller tag is:

image: ghcr.io/fluxcd/image-automation-controller:v0.35.0
@stefanprodan
Copy link
Member

Image automation only works for YAML files which start with apiVersion and kind.

@antonosmond
Copy link
Author

antonosmond commented Jan 12, 2024

Hey @stefanprodan

Maybe it's unexpected then but it does actually work for generic YAML files too.
In my testing, the entire YAML file I used in a case where it works was:

serviceName: busybox
containerName: busybox
tag: 0.0.1 # {"$imagepolicy":"flux-system:busybox:tag"}

So it's not a k8s resource but works just fine.
Feel free to try it.
And here's a commit from the image automation in my test repo:
https://github.com/antonosmond/flux/commit/6399612d9e1a47742aed70c0a46086041e8d7d58
It's updated the k8s deployment and also updated the generic YAML file.

@errordeveloper
Copy link

@antonosmond I think there is an incidental case, perhaps we can say it happens to recognise resources that have an object at root, perhaps apiVersion and kind are inferred or something.
I have to say, I find that YAML with an array at the top level is a little unorthodox ;)

@antonosmond
Copy link
Author

@antonosmond I think there is an incidental case, perhaps we can say it happens to recognise resources that have an object at root, perhaps apiVersion and kind are inferred or something. I have to say, I find that YAML with an array at the top level is a little unorthodox ;)

I agree. I didn't come up with that format but it's something I can change anyway so gonna change it. Just raised the issue in case it was something that would be expected to work.

@kimyvgy
Copy link

kimyvgy commented Aug 3, 2024

Image automation only works for YAML files which start with apiVersion and kind.

That's why my patch-image.yaml file didn't get new container image update. For example:

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../base
patches:
- path: patch-image.yaml
  target:
    kind: HelmRelease
    name: nginx

# patch-image.yaml
- op: replace
  path: /spec/values/containers/0/image # {"$imagepolicy": "flux-system:nginx-staging"}
  value: nginx:alpine

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

No branches or pull requests

4 participants