From 874407defb400499a25df02b9edf63b348627679 Mon Sep 17 00:00:00 2001 From: dbw7 Date: Mon, 15 Apr 2024 13:58:20 -0400 Subject: [PATCH 1/2] remove writeHaulerManifest, its template, and its tests --- pkg/combustion/registry.go | 22 --------------- pkg/combustion/registry_test.go | 27 ------------------- .../templates/hauler-manifest.yaml.tpl | 9 ------- 3 files changed, 58 deletions(-) delete mode 100644 pkg/combustion/templates/hauler-manifest.yaml.tpl diff --git a/pkg/combustion/registry.go b/pkg/combustion/registry.go index 79fc8da8..25edcd6c 100644 --- a/pkg/combustion/registry.go +++ b/pkg/combustion/registry.go @@ -36,9 +36,6 @@ const ( ) var ( - //go:embed templates/hauler-manifest.yaml.tpl - haulerManifest string - //go:embed templates/26-embedded-registry.sh.tpl registryScript string @@ -74,25 +71,6 @@ func configureRegistry(ctx *image.Context) ([]string, error) { return []string{script}, nil } -func writeHaulerManifest(ctx *image.Context, images []string) error { - haulerManifestYamlFile := filepath.Join(ctx.BuildDir, haulerManifestYamlName) - haulerDef := struct { - ContainerImages []string - }{ - ContainerImages: images, - } - data, err := template.Parse(haulerManifestYamlName, haulerManifest, haulerDef) - if err != nil { - return fmt.Errorf("applying template to %s: %w", haulerManifestYamlName, err) - } - - if err = os.WriteFile(haulerManifestYamlFile, []byte(data), fileio.NonExecutablePerms); err != nil { - return fmt.Errorf("writing file %s: %w", haulerManifestYamlName, err) - } - - return nil -} - func addImageToHauler(ctx *image.Context, containerImage string) error { args := []string{"store", "add", "image", containerImage, "-p", fmt.Sprintf("linux/%s", ctx.ImageDefinition.Image.Arch.Short())} diff --git a/pkg/combustion/registry_test.go b/pkg/combustion/registry_test.go index 85b76bdc..e9dfd839 100644 --- a/pkg/combustion/registry_test.go +++ b/pkg/combustion/registry_test.go @@ -11,33 +11,6 @@ import ( "github.com/suse-edge/edge-image-builder/pkg/registry" ) -func TestWriteHaulerManifestValidManifest(t *testing.T) { - // Setup - ctx, teardown := setupContext(t) - defer teardown() - - images := []string{ - "hello-world:latest", - "ghcr.io/fluxcd/flux-cli@sha256:02aa820c3a9c57d67208afcfc4bce9661658c17d15940aea369da259d2b976dd", - } - - // Test - err := writeHaulerManifest(ctx, images) - - // Verify - require.NoError(t, err) - - manifestFileName := filepath.Join(ctx.BuildDir, haulerManifestYamlName) - _, err = os.Stat(manifestFileName) - require.NoError(t, err) - - foundBytes, err := os.ReadFile(manifestFileName) - require.NoError(t, err) - found := string(foundBytes) - assert.Contains(t, found, "- name: hello-world:latest") - assert.Contains(t, found, "- name: ghcr.io/fluxcd/flux-cli@sha256:02aa820c3a9c57d67208afcfc4bce9661658c17d15940aea369da259d2b976dd") -} - func TestCreateRegistryCommand(t *testing.T) { // Setup ctx, teardown := setupContext(t) diff --git a/pkg/combustion/templates/hauler-manifest.yaml.tpl b/pkg/combustion/templates/hauler-manifest.yaml.tpl deleted file mode 100644 index a30007f8..00000000 --- a/pkg/combustion/templates/hauler-manifest.yaml.tpl +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: content.hauler.cattle.io/v1alpha1 -kind: Images -metadata: - name: embedded-registry-images -spec: - images: - {{- range .ContainerImages }} - - name: {{ . }} - {{- end }} From d8f3e034cfd4a1e09cebe315e8c0411885a5d43c Mon Sep 17 00:00:00 2001 From: dbw7 Date: Mon, 15 Apr 2024 14:29:55 -0400 Subject: [PATCH 2/2] add image log statement --- pkg/combustion/registry.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/combustion/registry.go b/pkg/combustion/registry.go index 25edcd6c..bfba8659 100644 --- a/pkg/combustion/registry.go +++ b/pkg/combustion/registry.go @@ -339,6 +339,7 @@ func registryArtefactsPath(ctx *image.Context) string { func populateRegistry(ctx *image.Context, images []string) error { bar := progressbar.Default(int64(len(images)), "Populating Embedded Artifact Registry...") + zap.S().Infof("Adding the following images to the embedded artifact registry:\n%s", images) for _, i := range images { if err := addImageToHauler(ctx, i); err != nil {