Skip to content

Conversation

@dgunzy
Copy link
Contributor

@dgunzy dgunzy commented Oct 10, 2025

Part of: #5504
[RFC-0012] Add command flux export source external

@stefanprodan - I added this, one thing I am not sure about is there is no SecretRef so I am just returning nil
let me know if there is a better way to go about this.

~/OpenSource/flux/flux2-fork add-export-source-external ?1 ❯ ./bin/flux export source external --all -n decomposition                                                     ⎈ kind-flux-test
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: ExternalArtifact
metadata:
  labels:
    app.kubernetes.io/managed-by: source-watcher
    source.extensions.fluxcd.io/generator: 4b83e39f-4032-4808-a66f-3adea8878a37
  name: podinfo-backend
  namespace: decomposition
spec:
  sourceRef:
    apiVersion: source.extensions.fluxcd.io/v1beta1
    kind: ArtifactGenerator
    name: app-gen
    namespace: decomposition
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: ExternalArtifact
metadata:
  labels:
    app.kubernetes.io/managed-by: source-watcher
    source.extensions.fluxcd.io/generator: 4b83e39f-4032-4808-a66f-3adea8878a37
  name: podinfo-cache
  namespace: decomposition
spec:
  sourceRef:
    apiVersion: source.extensions.fluxcd.io/v1beta1
    kind: ArtifactGenerator
    name: app-gen
    namespace: decomposition
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: ExternalArtifact
metadata:
  labels:
    app.kubernetes.io/managed-by: source-watcher
    source.extensions.fluxcd.io/generator: 4b83e39f-4032-4808-a66f-3adea8878a37
  name: podinfo-frontend
  namespace: decomposition
spec:
  sourceRef:
    apiVersion: source.extensions.fluxcd.io/v1beta1
    kind: ArtifactGenerator
    name: app-gen
    namespace: decomposition

@dgunzy dgunzy force-pushed the add-export-source-external branch from c4851aa to 2709794 Compare October 20, 2025 12:31
Copy link
Member

@matheuscscp matheuscscp left a comment

Choose a reason for hiding this comment

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

The most interesting parts of an ExternalArtifact are in .status 🤔

@dgunzy dgunzy force-pushed the add-export-source-external branch from 2709794 to 4f349ea Compare October 20, 2025 13:56
@dgunzy
Copy link
Contributor Author

dgunzy commented Oct 20, 2025

@matheuscscp - updated to any

I agree, do you think I should change export to also export the status? It is a bit of a different pattern then I have seen elsewhere, but happy to do it!

@matheuscscp
Copy link
Member

@matheuscscp - updated to any

I agree, do you think I should change export to also export the status? It is a bit of a different pattern then I have seen elsewhere, but happy to do it!

Maybe only for ExternalArtifact... @stefanprodan Thoughts?

@dgunzy dgunzy force-pushed the add-export-source-external branch from 4f349ea to 8074402 Compare October 20, 2025 18:41
@matheuscscp
Copy link
Member

On a second thought, I'm not quite sure if exporting .status makes sense depending on the use cases of this command. I think flux export is supposed to be used for getting resources out of the cluster for checking them into Git, and .status is always managed by something else (e.g. a controller), and not by the Flux appliers, as they don't patch the status subresource of the applied objects.

One could also end up thinking: "Well, ExternalArtifact is automatically created by source-watcher as a result of reconciling ArtifactGenerator, so what's the point of exporting ExternalArtifact objects anyway?" And I guess the use case here lies in the .spec.sourceRef field. An external source controller could respond to an ExternalArtifact object with .spec.sourceRef.kind set to a kind that it manages by patching the status of this EA.

@stefanprodan I guess this is what we discussed before, right?

@stefanprodan
Copy link
Member

The export functions shouldn't print the status. In the case of EA, export is useful when the generation and reconciliation is decoupled, e.g. there is a dedicated controller that watcher external artifacts and sets their status.

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.

@dgunzy could you please add tests for this.

@dgunzy dgunzy force-pushed the add-export-source-external branch from 8074402 to cdc37c3 Compare October 24, 2025 17:52
@dgunzy
Copy link
Contributor Author

dgunzy commented Oct 24, 2025

@stefanprodan @matheuscscp - I added a test in export_test.go - if there is a good place to add some additional tests let me know!

@dgunzy dgunzy requested a review from stefanprodan October 27, 2025 23:32
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 @dgunzy

@stefanprodan stefanprodan added the area/source Source API related issues and pull requests label Oct 28, 2025
@stefanprodan stefanprodan merged commit 5f2a6eb into fluxcd:main Oct 28, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/source Source API related issues and pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants