@@ -223,6 +223,7 @@ func traceKustomization(ctx context.Context, kubeClient client.Client, ksName ty
223223
224224 var gitRepository * sourcev1.GitRepository
225225 var ociRepository * sourcev1.OCIRepository
226+ var externalArtifact * sourcev1.ExternalArtifact
226227 var ksRepositoryReady * metav1.Condition
227228 switch ks .Spec .SourceRef .Kind {
228229 case sourcev1 .GitRepositoryKind :
@@ -253,6 +254,23 @@ func traceKustomization(ctx context.Context, kubeClient client.Client, ksName ty
253254 return "" , fmt .Errorf ("failed to find OCIRepository: %w" , err )
254255 }
255256 ksRepositoryReady = meta .FindStatusCondition (ociRepository .Status .Conditions , fluxmeta .ReadyCondition )
257+ case sourcev1 .ExternalArtifactKind :
258+ externalArtifact = & sourcev1.ExternalArtifact {}
259+ sourceNamespace := ks .Namespace
260+ if ks .Spec .SourceRef .Namespace != "" {
261+ sourceNamespace = ks .Spec .SourceRef .Namespace
262+ }
263+ err = kubeClient .Get (ctx , types.NamespacedName {
264+ Namespace : sourceNamespace ,
265+ Name : ks .Spec .SourceRef .Name ,
266+ }, externalArtifact )
267+ if err != nil {
268+ return "" , fmt .Errorf ("failed to find ExternalArtifact: %w" , err )
269+ }
270+ if externalArtifact .Spec .SourceRef == nil {
271+ return "" , fmt .Errorf ("ExternalArtifact %s/%s is missing spec.sourceRef" , externalArtifact .Namespace , externalArtifact .Name )
272+ }
273+ ksRepositoryReady = meta .FindStatusCondition (externalArtifact .Status .Conditions , fluxmeta .ReadyCondition )
256274 }
257275
258276 var traceTmpl = `
@@ -339,6 +357,31 @@ Message: {{.RepositoryReady.Message}}
339357Status: Unknown
340358{{- end }}
341359{{- end }}
360+ {{- if .ExternalArtifact }}
361+ ---
362+ ExternalArtifact:{{.ExternalArtifact.Name}}
363+ Namespace: {{.ExternalArtifact.Namespace}}
364+ Source: {{.ExternalArtifact.Spec.SourceRef.Kind}}/{{.ExternalArtifact.Spec.SourceRef.Namespace}}/{{.ExternalArtifact.Spec.SourceRef.Name}}
365+ {{- if .ExternalArtifact.Status.Artifact }}
366+ Revision: {{.ExternalArtifact.Status.Artifact.Revision}}
367+ {{- if .ExternalArtifact.Status.Artifact.Metadata }}
368+ {{- $metadata := .ExternalArtifact.Status.Artifact.Metadata }}
369+ {{- range $k, $v := .Annotations }}
370+ {{ with (index $metadata $v) }}{{ $k }}{{ . }}{{ end }}
371+ {{- end }}
372+ {{- end }}
373+ {{- end }}
374+ {{- if .RepositoryReady }}
375+ {{- if eq .RepositoryReady.Status "False" }}
376+ Status: Last reconciliation failed at {{.RepositoryReady.LastTransitionTime}}
377+ {{- else }}
378+ Status: Last reconciled at {{.RepositoryReady.LastTransitionTime}}
379+ {{- end }}
380+ Message: {{.RepositoryReady.Message}}
381+ {{- else }}
382+ Status: Unknown
383+ {{- end }}
384+ {{- end }}
342385`
343386
344387 traceResult := struct {
@@ -348,6 +391,7 @@ Status: Unknown
348391 KustomizationReady * metav1.Condition
349392 GitRepository * sourcev1.GitRepository
350393 OCIRepository * sourcev1.OCIRepository
394+ ExternalArtifact * sourcev1.ExternalArtifact
351395 RepositoryReady * metav1.Condition
352396 Annotations map [string ]string
353397 }{
@@ -357,6 +401,7 @@ Status: Unknown
357401 KustomizationReady : ksReady ,
358402 GitRepository : gitRepository ,
359403 OCIRepository : ociRepository ,
404+ ExternalArtifact : externalArtifact ,
360405 RepositoryReady : ksRepositoryReady ,
361406 Annotations : map [string ]string {"Origin Source: " : oci .SourceAnnotation , "Origin Revision: " : oci .RevisionAnnotation },
362407 }
@@ -404,6 +449,8 @@ func traceHelm(ctx context.Context, kubeClient client.Client, hrName types.Names
404449 var hrHelmRepositoryReady * metav1.Condition
405450 var hrOCIRepository * sourcev1.OCIRepository
406451 var hrOCIRepositoryReady * metav1.Condition
452+ var hrExternalArtifact * sourcev1.ExternalArtifact
453+ var hrExternalArtifactReady * metav1.Condition
407454 if hr .Spec .Chart == nil {
408455 if hr .Spec .ChartRef != nil {
409456 switch hr .Spec .ChartRef .Kind {
@@ -421,11 +468,24 @@ func traceHelm(ctx context.Context, kubeClient client.Client, hrName types.Names
421468 return "" , fmt .Errorf ("failed to find OCIRepository: %w" , err )
422469 }
423470 hrOCIRepositoryReady = meta .FindStatusCondition (hrOCIRepository .Status .Conditions , fluxmeta .ReadyCondition )
471+ case sourcev1 .ExternalArtifactKind :
472+ hrExternalArtifact = & sourcev1.ExternalArtifact {}
473+ sourceNamespace := hr .Namespace
474+ if hr .Spec .ChartRef .Namespace != "" {
475+ sourceNamespace = hr .Spec .ChartRef .Namespace
476+ }
477+ err = kubeClient .Get (ctx , types.NamespacedName {
478+ Namespace : sourceNamespace ,
479+ Name : hr .Spec .ChartRef .Name ,
480+ }, hrExternalArtifact )
481+ if err != nil {
482+ return "" , fmt .Errorf ("failed to find ExternalArtifact: %w" , err )
483+ }
484+ if hrExternalArtifact .Spec .SourceRef == nil {
485+ return "" , fmt .Errorf ("ExternalArtifact %s/%s is missing spec.sourceRef" , hrExternalArtifact .Namespace , hrExternalArtifact .Name )
486+ }
487+ hrExternalArtifactReady = meta .FindStatusCondition (hrExternalArtifact .Status .Conditions , fluxmeta .ReadyCondition )
424488 }
425- kubeClient .Get (ctx , types.NamespacedName {
426- Namespace : hr .Spec .ChartRef .Namespace ,
427- Name : hr .Spec .ChartRef .Name ,
428- }, hrOCIRepository )
429489 }
430490 } else {
431491 if hr .Spec .Chart .Spec .SourceRef .Kind == sourcev1 .GitRepositoryKind {
@@ -569,35 +629,58 @@ Message: {{.OCIRepositoryReady.Message}}
569629Status: Unknown
570630{{- end }}
571631{{- end }}
632+ {{- if .ExternalArtifact }}
633+ ---
634+ ExternalArtifact:{{.ExternalArtifact.Name}}
635+ Namespace: {{.ExternalArtifact.Namespace}}
636+ Source: {{.ExternalArtifact.Spec.SourceRef.Kind}}/{{.ExternalArtifact.Spec.SourceRef.Namespace}}/{{.ExternalArtifact.Spec.SourceRef.Name}}
637+ {{- if .ExternalArtifact.Status.Artifact }}
638+ Revision: {{.ExternalArtifact.Status.Artifact.Revision}}
639+ {{- end }}
640+ {{- if .ExternalArtifactReady }}
641+ {{- if eq .ExternalArtifactReady.Status "False" }}
642+ Status: Last reconciliation failed at {{.ExternalArtifactReady.LastTransitionTime}}
643+ {{- else }}
644+ Status: Last reconciled at {{.ExternalArtifactReady.LastTransitionTime}}
645+ {{- end }}
646+ Message: {{.ExternalArtifactReady.Message}}
647+ {{- else }}
648+ Status: Unknown
649+ {{- end }}
650+ {{- end }}
572651`
573652
574653 traceResult := struct {
575- ObjectName string
576- ObjectNamespace string
577- HelmRelease * helmv2.HelmRelease
578- HelmReleaseReady * metav1.Condition
579- HelmChart * sourcev1.HelmChart
580- HelmChartReady * metav1.Condition
581- GitRepository * sourcev1.GitRepository
582- GitRepositoryReady * metav1.Condition
583- HelmRepository * sourcev1.HelmRepository
584- HelmRepositoryReady * metav1.Condition
585- OCIRepository * sourcev1.OCIRepository
586- OCIRepositoryReady * metav1.Condition
587- Annotations map [string ]string
654+ ObjectName string
655+ ObjectNamespace string
656+ HelmRelease * helmv2.HelmRelease
657+ HelmReleaseReady * metav1.Condition
658+ HelmChart * sourcev1.HelmChart
659+ HelmChartReady * metav1.Condition
660+ GitRepository * sourcev1.GitRepository
661+ GitRepositoryReady * metav1.Condition
662+ HelmRepository * sourcev1.HelmRepository
663+ HelmRepositoryReady * metav1.Condition
664+ OCIRepository * sourcev1.OCIRepository
665+ OCIRepositoryReady * metav1.Condition
666+ ExternalArtifact * sourcev1.ExternalArtifact
667+ ExternalArtifactReady * metav1.Condition
668+ Annotations map [string ]string
588669 }{
589- ObjectName : obj .GetKind () + "/" + obj .GetName (),
590- ObjectNamespace : obj .GetNamespace (),
591- HelmRelease : hr ,
592- HelmReleaseReady : hrReady ,
593- HelmChart : hrChart ,
594- HelmChartReady : hrChartReady ,
595- GitRepository : hrGitRepository ,
596- GitRepositoryReady : hrGitRepositoryReady ,
597- HelmRepository : hrHelmRepository ,
598- HelmRepositoryReady : hrHelmRepositoryReady ,
599- OCIRepository : hrOCIRepository ,
600- OCIRepositoryReady : hrOCIRepositoryReady ,
670+ ObjectName : obj .GetKind () + "/" + obj .GetName (),
671+ ObjectNamespace : obj .GetNamespace (),
672+ HelmRelease : hr ,
673+ HelmReleaseReady : hrReady ,
674+ HelmChart : hrChart ,
675+ HelmChartReady : hrChartReady ,
676+ GitRepository : hrGitRepository ,
677+ GitRepositoryReady : hrGitRepositoryReady ,
678+ HelmRepository : hrHelmRepository ,
679+ HelmRepositoryReady : hrHelmRepositoryReady ,
680+ OCIRepository : hrOCIRepository ,
681+ OCIRepositoryReady : hrOCIRepositoryReady ,
682+ ExternalArtifact : hrExternalArtifact ,
683+ ExternalArtifactReady : hrExternalArtifactReady ,
601684 }
602685
603686 t , err := template .New ("tmpl" ).Parse (traceTmpl )
0 commit comments