Skip to content

Conversation

@renatovassao
Copy link
Contributor

@renatovassao renatovassao commented Dec 18, 2025

Summary

Adding support for ExternalArtifact as an ArtifactGenerator source.

Fixes #259.

Changes

  • Updates ArtifactGenerator API to accept ExternalArtifact as source.
  • Updates ArtifactGenerator Controller to handle ExternalArtifact source.

Testing

  1. Deploying controller in kind cluster:
kind create cluster
make dev-deploy
make docker-build
kind load docker-image fluxcd/source-watcher:latest
  1. Create GitRepository as initial source:
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: podinfo
  namespace: default
spec:
  interval: 5m0s
  url: https://github.com/stefanprodan/podinfo
  ref:
    branch: master
  1. Create ArtifactGenerator to generate an ExternalArtifact from the GitRepo:
apiVersion: source.extensions.fluxcd.io/v1beta1
kind: ArtifactGenerator
metadata:
  name: my-app
spec:
  sources:
    - alias: podinfo
      kind: GitRepository
      name: podinfo
  artifacts:
    - name: my-app-composite
      copy:
        - from: "@podinfo/**"
          to: "@artifact/my-app/"
  1. Create another ArtifactGenerator which uses previous generated ExternalArtifact as a source:
apiVersion: source.extensions.fluxcd.io/v1beta1
kind: ArtifactGenerator
metadata:
  name: my-other-app
spec:
  sources:
    - alias: my-app-composite
      kind: ExternalArtifact
      name: my-app-composite
  artifacts:
    - name: my-other-app-composite
      copy:
        - from: "@my-app-composite/my-app/**"
          to: "@artifact/my-other-app/"
  1. Check both ExternalArtifacts:
❯ kubectl get externalartifacts  -o yaml

apiVersion: v1
items:
- apiVersion: source.toolkit.fluxcd.io/v1
  kind: ExternalArtifact
  metadata:
    creationTimestamp: "2025-12-18T13:19:59Z"
    generation: 1
    labels:
      app.kubernetes.io/managed-by: source-watcher
      source.extensions.fluxcd.io/generator: 3446316a-273e-44ce-9332-b1664a7d313b
    name: my-app-composite
    namespace: default
    resourceVersion: "839"
    uid: 654d63f2-af23-4767-9dc1-080e9f55563e
  spec:
    sourceRef:
      apiVersion: source.extensions.fluxcd.io/v1beta1
      kind: ArtifactGenerator
      name: my-app
      namespace: default
  status:
    artifact:
      digest: sha256:dddd57b74c457ad4d793c050a5e89a910d3a0f079781bea50a6991a483c1b5e7
      lastUpdateTime: "2025-12-18T13:19:59Z"
      path: externalartifact/default/my-app-composite/2126722516.tar.gz
      revision: latest@sha256:dddd57b74c457ad4d793c050a5e89a910d3a0f079781bea50a6991a483c1b5e7
      size: 301888
      url: http://source-watcher.source-system.svc.cluster.local./externalartifact/default/my-app-composite/2126722516.tar.gz
    conditions:
    - lastTransitionTime: "2025-12-18T13:19:59Z"
      message: Artifact is ready
      observedGeneration: 1
      reason: Succeeded
      status: "True"
      type: Ready
- apiVersion: source.toolkit.fluxcd.io/v1
  kind: ExternalArtifact
  metadata:
    creationTimestamp: "2025-12-18T13:20:48Z"
    generation: 1
    labels:
      app.kubernetes.io/managed-by: source-watcher
      source.extensions.fluxcd.io/generator: 2311bcfb-aa1e-42ac-803b-286cfa170d40
    name: my-other-app-composite
    namespace: default
    resourceVersion: "945"
    uid: 2e37ac0a-6fc7-4d4c-a3bd-c54b318e5ef3
  spec:
    sourceRef:
      apiVersion: source.extensions.fluxcd.io/v1beta1
      kind: ArtifactGenerator
      name: my-other-app
      namespace: default
  status:
    artifact:
      digest: sha256:1477513624e338e26180e9f634f4964b8ff773313a63504db63b82a3172aa89d
      lastUpdateTime: "2025-12-18T13:20:48Z"
      path: externalartifact/default/my-other-app-composite/3216428403.tar.gz
      revision: latest@sha256:1477513624e338e26180e9f634f4964b8ff773313a63504db63b82a3172aa89d
      size: 301932
      url: http://source-watcher.source-system.svc.cluster.local./externalartifact/default/my-other-app-composite/3216428403.tar.gz
    conditions:
    - lastTransitionTime: "2025-12-18T13:20:48Z"
      message: Artifact is ready
      observedGeneration: 1
      reason: Succeeded
      status: "True"
      type: Ready
kind: List
metadata:
  resourceVersion: ""
  1. Inspect generated artifacts
kubectl port-forward -n source-system svc/source-watcher 8000:http
wget localhost:8000/externalartifact/default/my-app-composite/2126722516.tar.gz
tar xvf 2126722516.tar.gz my-app/charts/podinfo/Chart.yaml
cat my-app/charts/podinfo/Chart.yaml | grep version
version: 6.9.4
wget localhost:8000/externalartifact/default/my-app-composite/3216428403.tar.gz
tar xvf 3216428403.tar.gz my-other-app/charts/podinfo/Chart.yaml
cat my-other-app/charts/podinfo/Chart.yaml | grep version
version: 6.9.4
  1. Update GitRepo
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: podinfo
  namespace: default
spec:
  interval: 5m0s
  url: https://github.com/stefanprodan/podinfo
  ref:
    tag: "6.9.3"
  1. Check that both ExternalArtifacts have been updated:
kubectl get externalartifacts -o yaml | yq '.items[].status'
artifact:
  digest: sha256:228aa8c35c5e03c9581a6b06c1adf5e137457d2aa2cef5c7e52b8ac33d6fd772
  lastUpdateTime: "2025-12-18T13:30:31Z"
  path: externalartifact/default/my-app-composite/2150512031.tar.gz
  revision: latest@sha256:228aa8c35c5e03c9581a6b06c1adf5e137457d2aa2cef5c7e52b8ac33d6fd772
  size: 301729
  url: http://source-watcher.source-system.svc.cluster.local./externalartifact/default/my-app-composite/2150512031.tar.gz
conditions:
  - lastTransitionTime: "2025-12-18T13:30:31Z"
    message: Artifact is ready
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: Ready
artifact:
  digest: sha256:0ee72da2ab2e07f91006aa138b6b4ce049d82f6bdde503f14ae820e27dfb78f6
  lastUpdateTime: "2025-12-18T13:30:31Z"
  path: externalartifact/default/my-other-app-composite/229690686.tar.gz
  revision: latest@sha256:0ee72da2ab2e07f91006aa138b6b4ce049d82f6bdde503f14ae820e27dfb78f6
  size: 301769
  url: http://source-watcher.source-system.svc.cluster.local./externalartifact/default/my-other-app-composite/229690686.tar.gz
conditions:
  - lastTransitionTime: "2025-12-18T13:30:31Z"
    message: Artifact is ready
    observedGeneration: 1
    reason: Succeeded
    status: "True"
    type: Ready
  1. Inspect updated artifacts:
wget localhost:8000/externalartifact/default/my-app-composite/2150512031.tar.gz
tar xvf 2150512031.tar.gz my-app/charts/podinfo/Chart.yaml
cat my-app/charts/podinfo/Chart.yaml | grep version
version: 6.9.3
wget localhost:8000/externalartifact/default/my-other-app-composite/229690686.tar.gz
tar xvf 229690686.tar.gz my-other-app/charts/podinfo/Chart.yaml
cat my-other-app/charts/podinfo/Chart.yaml | grep version
version: 6.9.3

@renatovassao renatovassao changed the title Add support for using ExternalArtifact as an ArtifactGenerator source. WIP: Add support for using ExternalArtifact as an ArtifactGenerator source. Dec 18, 2025
@renatovassao renatovassao changed the title WIP: Add support for using ExternalArtifact as an ArtifactGenerator source. Add support for using ExternalArtifact as an ArtifactGenerator source. Dec 18, 2025
@stefanprodan stefanprodan added area/api API related issues and pull requests area/generator Artifact generation related issues and pull requests labels Dec 23, 2025
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @renatovassao 🏅

@stefanprodan stefanprodan merged commit 37a803a into fluxcd:main Dec 23, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API related issues and pull requests area/generator Artifact generation related issues and pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow ExternalArtifact as a source in ArtifactGenerator

2 participants