Skip to content

Commit

Permalink
updates based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dbw7 committed May 20, 2024
1 parent f1a12d6 commit 3358e20
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
15 changes: 1 addition & 14 deletions pkg/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"os/exec"
"path/filepath"
"slices"
"strings"

"github.com/suse-edge/edge-image-builder/pkg/fileio"
Expand Down Expand Up @@ -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 == "" {
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions pkg/registry/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"
"path/filepath"
"slices"
"strings"

"github.com/suse-edge/edge-image-builder/pkg/http"
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/testdata/sample-crd.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: "custom.example.com/v1"
kind: ComplexApplication
kind: Deployment
metadata:
name: my-complex-app
labels:
Expand Down

0 comments on commit 3358e20

Please sign in to comment.