Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove writeHaulerManifest, its template, and its tests #387

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions pkg/combustion/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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())}

Expand Down Expand Up @@ -361,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 {
Expand Down
27 changes: 0 additions & 27 deletions pkg/combustion/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions pkg/combustion/templates/hauler-manifest.yaml.tpl

This file was deleted.

Loading