diff --git a/pkg/helm/helm.go b/pkg/helm/helm.go index 0e77eb11..202c0742 100644 --- a/pkg/helm/helm.go +++ b/pkg/helm/helm.go @@ -7,7 +7,6 @@ import ( "os" "os/exec" "path/filepath" - "slices" "strings" "github.com/suse-edge/edge-image-builder/pkg/fileio" @@ -271,15 +270,6 @@ func templateCommand(chart, repository, version, valuesFilePath, kubeVersion, ta func parseChartContents(chartContents string) ([]map[string]any, error) { var resources []map[string]any - var k8sKinds = []string{ - "Pod", - "Deployment", - "StatefulSet", - "DaemonSet", - "ReplicaSet", - "Job", - "CronJob", - } for _, resource := range strings.Split(chartContents, "---\n") { if resource == "" { @@ -302,10 +292,7 @@ func parseChartContents(chartContents string) ([]map[string]any, error) { return nil, fmt.Errorf("decoding resource from source '%s': %w", source, err) } - kind, _ := r["kind"].(string) - if slices.Contains(k8sKinds, kind) { - resources = append(resources, r) - } + resources = append(resources, r) } return resources, nil diff --git a/pkg/registry/manifests.go b/pkg/registry/manifests.go index a0a833fb..63826a8b 100644 --- a/pkg/registry/manifests.go +++ b/pkg/registry/manifests.go @@ -7,6 +7,7 @@ import ( "io" "os" "path/filepath" + "slices" "strings" "github.com/suse-edge/edge-image-builder/pkg/http" @@ -85,6 +86,21 @@ func readManifest(manifestPath string) ([]map[string]any, error) { } func storeManifestImages(resource map[string]any, images map[string]bool) { + var k8sKinds = []string{ + "Pod", + "Deployment", + "StatefulSet", + "DaemonSet", + "ReplicaSet", + "Job", + "CronJob", + } + + kind, _ := resource["kind"].(string) + if !slices.Contains(k8sKinds, kind) { + return + } + var findImages func(data any) findImages = func(data any) { diff --git a/pkg/registry/testdata/sample-crd.yaml b/pkg/registry/testdata/sample-crd.yaml index 710b7425..8864e9a6 100644 --- a/pkg/registry/testdata/sample-crd.yaml +++ b/pkg/registry/testdata/sample-crd.yaml @@ -1,5 +1,5 @@ apiVersion: "custom.example.com/v1" -kind: ComplexApplication +kind: Deployment metadata: name: my-complex-app labels: