diff --git a/.github/workflows/image-deps-updater.yaml b/.github/workflows/image-deps-updater.yaml index c65323d68..9ebc31acc 100644 --- a/.github/workflows/image-deps-updater.yaml +++ b/.github/workflows/image-deps-updater.yaml @@ -80,6 +80,7 @@ jobs: INPUT_VELERO_AWS_PLUGIN_VERSION: ${{ github.event.inputs.velero_aws_plugin_version }} INPUT_KUBECTL_VERSION: ${{ github.event.inputs.kubectl_version }} INPUT_SEAWEEDFS_VERSION: ${{ github.event.inputs.seaweedfs_version }} + ARCHS: "amd64,arm64" run: | chmod +x ./output/bin/buildtools ./output/bin/buildtools update images ${{ matrix.addon }} diff --git a/.github/workflows/update-addons.yaml b/.github/workflows/update-addons.yaml index da1c227b7..ac59b6b40 100644 --- a/.github/workflows/update-addons.yaml +++ b/.github/workflows/update-addons.yaml @@ -69,6 +69,7 @@ jobs: INPUT_OPENEBS_CHART_VERSION: ${{ github.event.inputs.openebs_chart_version }} INPUT_VELERO_CHART_VERSION: ${{ github.event.inputs.velero_chart_version }} INPUT_SEAWEEDFS_CHART_VERSION: ${{ github.event.inputs.seaweedfs_chart_version }} + ARCHS: "amd64,arm64" run: | chmod 755 ./output/bin/buildtools ./output/bin/buildtools update addon ${{ matrix.addon }} diff --git a/cmd/buildtools/addon.go b/cmd/buildtools/addon.go index 6e098a415..fae70ef66 100644 --- a/cmd/buildtools/addon.go +++ b/cmd/buildtools/addon.go @@ -26,14 +26,37 @@ type addonComponentOptions struct { latestK8sVersion *semver.Version } -func (c *addonComponent) resolveImageRepoAndTag(ctx context.Context, image string) (string, string, error) { +func (c *addonComponent) buildImage(ctx context.Context, image string, archs string) (string, error) { + if c.useUpstreamImage || c.getCustomImageName != nil { + return "", nil + } + builtImage, err := c.buildApkoImage(ctx, image, archs) + if err != nil { + return "", fmt.Errorf("build apko image: %w", err) + } + return builtImage, nil +} + +func (c *addonComponent) resolveImageRepoAndTag(ctx context.Context, image string, arch string) (repo string, tag string, err error) { if c.useUpstreamImage { - return c.resolveUpstreamImageRepoAndTag(ctx, image) + repo, tag, err = c.resolveUpstreamImageRepoAndTag(ctx, image, arch) + if err != nil { + err = fmt.Errorf("resolve upstream image repo and tag: %w", err) + } + return } if c.getCustomImageName != nil { - return c.resolveCustomImageRepoAndTag(ctx, c.getUpstreamVersion(image)) + repo, tag, err = c.resolveCustomImageRepoAndTag(ctx, image, arch) + if err != nil { + err = fmt.Errorf("resolve custom image repo and tag: %w", err) + } + return } - return c.resolveApkoImageRepoAndTag(ctx, c.getUpstreamVersion(image)) + repo, tag, err = c.resolveApkoImageRepoAndTag(ctx, image, arch) + if err != nil { + err = fmt.Errorf("resolve apko image repo and tag: %w", err) + } + return } func (c *addonComponent) getUpstreamVersion(image string) string { @@ -46,17 +69,19 @@ func (c *addonComponent) getUpstreamVersion(image string) string { return TagFromImage(image) } -func (c *addonComponent) resolveUpstreamImageRepoAndTag(ctx context.Context, image string) (string, string, error) { - digest, err := GetImageDigest(ctx, image) +func (c *addonComponent) resolveUpstreamImageRepoAndTag(ctx context.Context, image string, arch string) (string, string, error) { + digest, err := GetImageDigest(ctx, image, arch) if err != nil { return "", "", fmt.Errorf("failed to get image %s digest: %w", image, err) } - tag := fmt.Sprintf("%s@%s", TagFromImage(image), digest) + tag := fmt.Sprintf("%s-%s@%s", TagFromImage(image), arch, digest) repo := fmt.Sprintf("proxy.replicated.com/anonymous/%s", FamiliarImageName(RemoveTagFromImage(image))) return repo, tag, nil } -func (c *addonComponent) resolveCustomImageRepoAndTag(ctx context.Context, upstreamVersion string) (string, string, error) { +func (c *addonComponent) resolveCustomImageRepoAndTag(ctx context.Context, image string, arch string) (string, string, error) { + upstreamVersion := c.getUpstreamVersion(image) + k0sVersion, err := getK0sVersion() if err != nil { return "", "", fmt.Errorf("get k0s version: %w", err) @@ -74,38 +99,53 @@ func (c *addonComponent) resolveCustomImageRepoAndTag(ctx context.Context, upstr if err != nil { return "", "", fmt.Errorf("failed to get image name for %s: %w", c.name, err) } - digest, err := GetImageDigest(ctx, customImage) + digest, err := GetImageDigest(ctx, customImage, arch) if err != nil { return "", "", fmt.Errorf("failed to get image %s digest: %w", customImage, err) } - tag := fmt.Sprintf("%s@%s", TagFromImage(customImage), digest) + tag := fmt.Sprintf("%s-%s@%s", TagFromImage(customImage), arch, digest) repo := fmt.Sprintf("proxy.replicated.com/anonymous/%s", FamiliarImageName(RemoveTagFromImage(customImage))) return repo, tag, nil } -func (c *addonComponent) resolveApkoImageRepoAndTag(ctx context.Context, upstreamVersion string) (string, string, error) { +func (c *addonComponent) resolveApkoImageRepoAndTag(ctx context.Context, image string, arch string) (string, string, error) { + builtImage, err := GetImageNameFromBuildFile("build/image") + if err != nil { + return "", "", fmt.Errorf("failed to get digest from build file: %w", err) + } + + digest, err := GetImageDigest(ctx, builtImage, arch) + if err != nil { + return "", "", fmt.Errorf("failed to get image %s digest: %w", builtImage, err) + } + tag := fmt.Sprintf("%s-%s@%s", TagFromImage(builtImage), arch, digest) + repo := fmt.Sprintf("proxy.replicated.com/anonymous/%s", FamiliarImageName(RemoveTagFromImage(builtImage))) + return repo, tag, nil +} + +func (c *addonComponent) buildApkoImage(ctx context.Context, image string, archs string) (string, error) { + upstreamVersion := c.getUpstreamVersion(image) + packageName, packageVersion, err := c.getPackageNameAndVersion(ctx, upstreamVersion) if err != nil { - return "", "", fmt.Errorf("failed to get package name and version constraint for %s: %w", c.name, err) + return "", fmt.Errorf("get package name and version constraint for %s: %w", c.name, err) } logrus.Infof("building and publishing %s", c.name) - if err := ApkoBuildAndPublish(c.name, packageName, packageVersion); err != nil { - return "", "", fmt.Errorf("failed to apko build and publish for %s: %w", c.name, err) + if err := ApkoLogin(); err != nil { + return "", fmt.Errorf("apko login: %w", err) } - builtImage, err := GetImageNameFromBuildFile("build/image") - if err != nil { - return "", "", fmt.Errorf("failed to get digest from build file: %w", err) + if err := ApkoBuildAndPublish(c.name, packageName, packageVersion, archs); err != nil { + return "", fmt.Errorf("apko build and publish for %s: %w", c.name, err) } - parts := strings.SplitN(builtImage, ":", 2) - if len(parts) != 2 { - return "", "", fmt.Errorf("invalid image name: %s", builtImage) + builtImage, err := GetImageNameFromBuildFile("build/image") + if err != nil { + return "", fmt.Errorf("get image name from build file: %w", err) } - - return fmt.Sprintf("proxy.replicated.com/anonymous/%s", FamiliarImageName(parts[0])), parts[1], nil + return builtImage, nil } func (c *addonComponent) getPackageNameAndVersion(ctx context.Context, upstreamVersion string) (string, string, error) { diff --git a/cmd/buildtools/adminconsole.go b/cmd/buildtools/adminconsole.go index 46b95f2eb..2402db971 100644 --- a/cmd/buildtools/adminconsole.go +++ b/cmd/buildtools/adminconsole.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "runtime" "strings" "github.com/replicatedhq/embedded-cluster/pkg/addons/adminconsole" @@ -70,20 +69,11 @@ var updateAdminConsoleAddonCommand = &cli.Command{ return fmt.Errorf("failed to get images from admin console chart: %w", err) } - for _, image := range images { - component, ok := adminconsoleImageComponents[RemoveTagFromImage(image)] - if !ok { - return fmt.Errorf("no component found for image %s", image) - } - repo, tag, err := component.resolveImageRepoAndTag(c.Context, image) - if err != nil { - return fmt.Errorf("failed to resolve image and tag for %s: %w", image, err) - } - newimage := adminconsole.Metadata.Images[component.name] - newimage.Repo = repo - newimage.Tag[runtime.GOARCH] = tag - newmeta.Images[component.name] = newimage + metaImages, err := UpdateImages(c.Context, adminconsoleImageComponents, adminconsole.Metadata.Images, images) + if err != nil { + return fmt.Errorf("failed to update images: %w", err) } + newmeta.Images = metaImages logrus.Infof("saving addon manifest") if err := newmeta.Save("adminconsole"); err != nil { diff --git a/cmd/buildtools/embeddedclusteroperator.go b/cmd/buildtools/embeddedclusteroperator.go index d158a4e39..fa41028a8 100644 --- a/cmd/buildtools/embeddedclusteroperator.go +++ b/cmd/buildtools/embeddedclusteroperator.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "os/exec" - "runtime" "strings" "github.com/replicatedhq/embedded-cluster/pkg/addons/embeddedclusteroperator" @@ -123,24 +122,11 @@ func updateOperatorAddonImages(ctx context.Context, chartURL string, chartVersio // chart. images = append(images, "docker.io/library/busybox:latest") - if err := ApkoLogin(); err != nil { - return fmt.Errorf("failed to apko login: %w", err) - } - - for _, image := range images { - component, ok := operatorImageComponents[RemoveTagFromImage(image)] - if !ok { - return fmt.Errorf("no component found for image %s", image) - } - repo, tag, err := component.resolveImageRepoAndTag(ctx, image) - if err != nil { - return fmt.Errorf("failed to resolve image and tag for %s: %w", image, err) - } - newimage := embeddedclusteroperator.Metadata.Images[component.name] - newimage.Repo = repo - newimage.Tag[runtime.GOARCH] = tag - newmeta.Images[component.name] = newimage + metaImages, err := UpdateImages(ctx, operatorImageComponents, embeddedclusteroperator.Metadata.Images, images) + if err != nil { + return fmt.Errorf("failed to update images: %w", err) } + newmeta.Images = metaImages logrus.Infof("saving addon manifest") if err := newmeta.Save("embeddedclusteroperator"); err != nil { diff --git a/cmd/buildtools/k0s.go b/cmd/buildtools/k0s.go index ba952e59f..dcbc97df1 100644 --- a/cmd/buildtools/k0s.go +++ b/cmd/buildtools/k0s.go @@ -3,7 +3,6 @@ package main import ( "fmt" "os" - "runtime" "github.com/Masterminds/semver/v3" k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1" @@ -78,29 +77,16 @@ var updateK0sImagesCommand = &cli.Command{ logrus.Infof("updating k0s images") newmeta := release.K0sMetadata{ - Images: make(map[string]release.K0sImage), + Images: make(map[string]release.AddonImage), } k0sImages := config.ListK0sImages(k0sv1beta1.DefaultClusterConfig()) - if err := ApkoLogin(); err != nil { - return fmt.Errorf("failed to apko login: %w", err) - } - - for _, image := range k0sImages { - component, ok := k0sImageComponents[RemoveTagFromImage(image)] - if !ok { - return fmt.Errorf("no component found for image %s", image) - } - repo, tag, err := component.resolveImageRepoAndTag(c.Context, image) - if err != nil { - return fmt.Errorf("failed to resolve image and tag for %s: %w", image, err) - } - newimage := config.Metadata.Images[component.name] - newimage.Image = repo - newimage.Version[runtime.GOARCH] = tag - newmeta.Images[component.name] = newimage + metaImages, err := UpdateImages(c.Context, k0sImageComponents, config.Metadata.Images, k0sImages) + if err != nil { + return fmt.Errorf("failed to update images: %w", err) } + newmeta.Images = metaImages logrus.Infof("saving k0s metadata") if err := newmeta.Save(); err != nil { diff --git a/cmd/buildtools/openebs.go b/cmd/buildtools/openebs.go index 1f9abae96..bd429911b 100644 --- a/cmd/buildtools/openebs.go +++ b/cmd/buildtools/openebs.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "os" - "runtime" "strings" "github.com/replicatedhq/embedded-cluster/pkg/addons/openebs" @@ -129,24 +128,11 @@ func updateOpenEBSAddonImages(ctx context.Context, chartURL string, chartVersion // make sure we include the linux-utils image. images = append(images, fmt.Sprintf("docker.io/openebs/linux-utils:%s", linuxUtilsVersion)) - if err := ApkoLogin(); err != nil { - return fmt.Errorf("failed to apko login: %w", err) - } - - for _, image := range images { - component, ok := openebsImageComponents[RemoveTagFromImage(image)] - if !ok { - return fmt.Errorf("no component found for image %s", image) - } - repo, tag, err := component.resolveImageRepoAndTag(ctx, image) - if err != nil { - return fmt.Errorf("failed to resolve image and tag for %s: %w", image, err) - } - newimage := openebs.Metadata.Images[component.name] - newimage.Repo = repo - newimage.Tag[runtime.GOARCH] = tag - newmeta.Images[component.name] = newimage + metaImages, err := UpdateImages(ctx, openebsImageComponents, openebs.Metadata.Images, images) + if err != nil { + return fmt.Errorf("failed to update images: %w", err) } + newmeta.Images = metaImages logrus.Infof("saving addon manifest") if err := newmeta.Save("openebs"); err != nil { diff --git a/cmd/buildtools/registry.go b/cmd/buildtools/registry.go index f7289ebaa..c3dff016f 100644 --- a/cmd/buildtools/registry.go +++ b/cmd/buildtools/registry.go @@ -3,7 +3,6 @@ package main import ( "fmt" "os" - "runtime" "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" @@ -70,20 +69,11 @@ var updateRegistryAddonCommand = &cli.Command{ return fmt.Errorf("failed to get images from chart: %w", err) } - for _, image := range images { - component, ok := registryImageComponents[RemoveTagFromImage(image)] - if !ok { - return fmt.Errorf("no component found for image %s", image) - } - repo, tag, err := component.resolveImageRepoAndTag(c.Context, image) - if err != nil { - return fmt.Errorf("failed to resolve image and tag for %s: %w", image, err) - } - newimage := registry.Metadata.Images[component.name] - newimage.Repo = repo - newimage.Tag[runtime.GOARCH] = tag - newmeta.Images[component.name] = newimage + metaImages, err := UpdateImages(c.Context, registryImageComponents, registry.Metadata.Images, images) + if err != nil { + return fmt.Errorf("failed to update images: %w", err) } + newmeta.Images = metaImages logrus.Infof("saving addon manifest") if err := newmeta.Save("registry"); err != nil { diff --git a/cmd/buildtools/seaweedfs.go b/cmd/buildtools/seaweedfs.go index cd5ffc020..71aa7c6ca 100644 --- a/cmd/buildtools/seaweedfs.go +++ b/cmd/buildtools/seaweedfs.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "os" - "runtime" "strings" "github.com/replicatedhq/embedded-cluster/pkg/addons/seaweedfs" @@ -114,24 +113,11 @@ func updateSeaweedFSAddonImages(ctx context.Context, chartURL string, chartVersi return fmt.Errorf("failed to get images from seaweedfs chart: %w", err) } - if err := ApkoLogin(); err != nil { - return fmt.Errorf("failed to apko login: %w", err) - } - - for _, image := range images { - component, ok := seaweedfsImageComponents[RemoveTagFromImage(image)] - if !ok { - return fmt.Errorf("no component found for image %s", image) - } - repo, tag, err := component.resolveImageRepoAndTag(ctx, image) - if err != nil { - return fmt.Errorf("failed to resolve image and tag for %s: %w", image, err) - } - newimage := seaweedfs.Metadata.Images[component.name] - newimage.Repo = repo - newimage.Tag[runtime.GOARCH] = tag - newmeta.Images[component.name] = newimage + metaImages, err := UpdateImages(ctx, seaweedfsImageComponents, seaweedfs.Metadata.Images, images) + if err != nil { + return fmt.Errorf("failed to update images: %w", err) } + newmeta.Images = metaImages logrus.Infof("saving addon manifest") if err := newmeta.Save("seaweedfs"); err != nil { diff --git a/cmd/buildtools/update.go b/cmd/buildtools/update.go index 21fc26807..d05114a69 100644 --- a/cmd/buildtools/update.go +++ b/cmd/buildtools/update.go @@ -23,12 +23,12 @@ var updateAddonCommand = &cli.Command{ }, }, Subcommands: []*cli.Command{ + updateAdminConsoleAddonCommand, updateOpenEBSAddonCommand, - updateSeaweedFSAddonCommand, + updateOperatorAddonCommand, updateRegistryAddonCommand, updateVeleroAddonCommand, - updateOperatorAddonCommand, - updateAdminConsoleAddonCommand, + updateSeaweedFSAddonCommand, }, } @@ -38,8 +38,8 @@ var updateImagesCommand = &cli.Command{ Subcommands: []*cli.Command{ updateK0sImagesCommand, updateOpenEBSImagesCommand, - updateVeleroImagesCommand, updateOperatorImagesCommand, updateSeaweedFSImagesCommand, + updateVeleroImagesCommand, }, } diff --git a/cmd/buildtools/utils.go b/cmd/buildtools/utils.go index 1cc8327de..54541a83e 100644 --- a/cmd/buildtools/utils.go +++ b/cmd/buildtools/utils.go @@ -3,14 +3,15 @@ package main import ( "bufio" "context" + "errors" "fmt" "net/http" "os" "os/exec" "path/filepath" "regexp" - "runtime" "strings" + "sync" "github.com/Masterminds/semver/v3" "github.com/containers/image/v5/docker" @@ -19,31 +20,41 @@ import ( "github.com/distribution/reference" "github.com/google/go-github/v62/github" "github.com/replicatedhq/embedded-cluster/pkg/helm" + "github.com/replicatedhq/embedded-cluster/pkg/release" "github.com/sirupsen/logrus" "helm.sh/helm/v3/pkg/repo" ) +var ( + apkoLoginOnce sync.Once +) + func ApkoLogin() error { - cmd := exec.Command("make", "apko") - if err := RunCommand(cmd); err != nil { - return fmt.Errorf("make apko: %w", err) - } - if os.Getenv("IMAGES_REGISTRY_USER") != "" && os.Getenv("IMAGES_REGISTRY_PASS") != "" { - cmd := exec.Command( - "make", - "apko-login", - fmt.Sprintf("REGISTRY=%s", os.Getenv("IMAGES_REGISTRY_SERVER")), - fmt.Sprintf("USERNAME=%s", os.Getenv("IMAGES_REGISTRY_USER")), - fmt.Sprintf("PASSWORD=%s", os.Getenv("IMAGES_REGISTRY_PASS")), - ) + var retErr error + apkoLoginOnce.Do(func() { + cmd := exec.Command("make", "apko") if err := RunCommand(cmd); err != nil { - return err + retErr = fmt.Errorf("make apko: %w", err) + return } - } - return nil + if os.Getenv("IMAGES_REGISTRY_USER") != "" && os.Getenv("IMAGES_REGISTRY_PASS") != "" { + cmd := exec.Command( + "make", + "apko-login", + fmt.Sprintf("REGISTRY=%s", os.Getenv("IMAGES_REGISTRY_SERVER")), + fmt.Sprintf("USERNAME=%s", os.Getenv("IMAGES_REGISTRY_USER")), + fmt.Sprintf("PASSWORD=%s", os.Getenv("IMAGES_REGISTRY_PASS")), + ) + if err := RunCommand(cmd); err != nil { + retErr = fmt.Errorf("run make apko-login: %w", err) + return + } + } + }) + return retErr } -func ApkoBuildAndPublish(componentName, packageName, packageVersion string) error { +func ApkoBuildAndPublish(componentName, packageName, packageVersion string, archs string) error { image, err := ComponentImageName(componentName, packageName, packageVersion) if err != nil { return fmt.Errorf("component image name: %w", err) @@ -53,14 +64,54 @@ func ApkoBuildAndPublish(componentName, packageName, packageVersion string) erro fmt.Sprintf("IMAGE=%s", image), fmt.Sprintf("APKO_CONFIG=%s", filepath.Join("deploy", "images", componentName, "apko.tmpl.yaml")), fmt.Sprintf("PACKAGE_VERSION=%s", packageVersion), + fmt.Sprintf("ARCHS=%s", archs), } cmd := exec.Command("make", args...) if err := RunCommand(cmd); err != nil { - return err + return fmt.Errorf("run make apko-build-and-publish: %w", err) } return nil } +func UpdateImages(ctx context.Context, imageComponents map[string]addonComponent, metaImages map[string]release.AddonImage, images []string) (map[string]release.AddonImage, error) { + nextImages := map[string]release.AddonImage{} + + for _, image := range images { + component, ok := imageComponents[RemoveTagFromImage(image)] + if !ok { + return nil, fmt.Errorf("no component found for image %s", image) + } + + newimage := metaImages[component.name] + if newimage.Tag == nil { + newimage.Tag = make(map[string]string) + } + + archs := GetSupportedArchs() + + _, err := component.buildImage(ctx, image, strings.Join(archs, ",")) + if err != nil { + return nil, fmt.Errorf("build image: %w", err) + } + + for _, arch := range archs { + repo, tag, err := component.resolveImageRepoAndTag(ctx, image, arch) + var tmp *DockerManifestNotFoundError + if errors.As(err, &tmp) { + logrus.Warnf("skipping image %s (%s) as no manifest found: %v", image, arch, err) + continue + } else if err != nil { + return nil, fmt.Errorf("resolve image and tag for %s (%s): %w", image, arch, err) + } + newimage.Repo = repo + newimage.Tag[arch] = tag + } + nextImages[component.name] = newimage + } + + return nextImages, nil +} + func ComponentImageName(componentName, packageName, packageVersion string) (string, error) { registryServer := os.Getenv("IMAGES_REGISTRY_SERVER") if registryServer == "" { @@ -77,11 +128,11 @@ func ComponentImageTag(componentName, packageName, packageVersion string) (strin if packageName == "" { return packageVersion, nil } - tag, err := ResolveApkoPackageVersion(componentName, packageName, packageVersion) + packageVersion, err := ResolveApkoPackageVersion(componentName, packageName, packageVersion) if err != nil { return "", fmt.Errorf("apko output tag: %w", err) } - return tag, nil + return packageVersion, nil } // ResolveApkoPackageVersion resolves the fuzzy version matching in the apko config file to a specific version. @@ -279,12 +330,28 @@ func LatestChartVersion(repo *repo.Entry, name string) (string, error) { return hcli.Latest(repo.Name, name) } -func GetImageDigest(ctx context.Context, image string) (string, error) { - ref, err := docker.ParseReference("//" + image) +type DockerManifestNotFoundError struct { + image, arch string + err error +} + +func (e *DockerManifestNotFoundError) Error() string { + return fmt.Sprintf("docker manifest not found for image %s and arch %s: %v", e.image, e.arch, e.err) +} + +func GetImageDigest(ctx context.Context, img string, arch string) (string, error) { + img, err := NormalizeDigestAndTag(img) + if err != nil { + return "", fmt.Errorf("normalize digest and tag: %w", err) + } + ref, err := docker.ParseReference("//" + img) if err != nil { - return "", fmt.Errorf("parse image reference: %w", err) + return "", fmt.Errorf("parse reference: %w", err) + } + sysctx := &types.SystemContext{ + OSChoice: "linux", + ArchitectureChoice: arch, } - sysctx := &types.SystemContext{} src, err := ref.NewImageSource(ctx, sysctx) if err != nil { return "", fmt.Errorf("create image source: %w", err) @@ -297,8 +364,11 @@ func GetImageDigest(ctx context.Context, image string) (string, error) { } if !manifest.MIMETypeIsMultiImage(maniftype) { - digest, err := docker.GetDigest(ctx, nil, ref) - return string(digest), err + digest, err := manifest.Digest(manifraw) + if err != nil { + return "", fmt.Errorf("get manifest digest: %w", err) + } + return digest.String(), nil } manifestList, err := manifest.ListFromBlob(manifraw, maniftype) @@ -312,7 +382,7 @@ func GetImageDigest(ctx context.Context, image string) (string, error) { if err != nil { return "", fmt.Errorf("get manifest instance: %w", err) } - if manifest.ReadOnly.Platform.Architecture != runtime.GOARCH { + if manifest.ReadOnly.Platform.Architecture != arch { continue } if manifest.ReadOnly.Platform.OS != "linux" { @@ -320,12 +390,26 @@ func GetImageDigest(ctx context.Context, image string) (string, error) { } return string(descriptor), nil } - return "", fmt.Errorf("failed to locate linux/amd64 manifest") + return "", &DockerManifestNotFoundError{image: img, arch: arch, err: err} +} + +// NormalizeDigestAndTag returns the image name with the digest only if it has both a digest and a tag. +func NormalizeDigestAndTag(img string) (string, error) { + ref, err := reference.ParseNormalizedNamed(img) + if err != nil { + return "", fmt.Errorf("parse normalized named: %w", err) + } + digested, ok := ref.(reference.Digested) + if !ok { + return img, nil + } + return fmt.Sprintf("%s@%s", ref.Name(), digested.Digest()), nil } // XXX we need to revisit this as a registry may have a port number. func TagFromImage(image string) string { _, tag, _ := strings.Cut(image, ":") + tag, _, _ = strings.Cut(tag, "@") return tag } @@ -428,3 +512,7 @@ func GetLatestKubernetesVersion() (*semver.Version, error) { } return semver.NewVersion(scanner.Text()) } + +func GetSupportedArchs() []string { + return []string{"amd64", "arm64"} +} diff --git a/cmd/buildtools/velero.go b/cmd/buildtools/velero.go index 00b69498e..c6bcb87eb 100644 --- a/cmd/buildtools/velero.go +++ b/cmd/buildtools/velero.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "os" - "runtime" "strings" "github.com/Masterminds/semver/v3" @@ -130,14 +129,16 @@ var updateVeleroImagesCommand = &cli.Command{ if !ok { return fmt.Errorf("failed to find velero restore helper image") } - restoreHelperVersion, _, _ := strings.Cut(image.Tag[runtime.GOARCH], "@") + restoreHelperVersion, _, _ := strings.Cut(image.Tag["amd64"], "@") + restoreHelperVersion = strings.TrimSuffix(restoreHelperVersion, "-amd64") restoreHelperVersion = strings.TrimPrefix(restoreHelperVersion, "v") image, ok = velero.Metadata.Images["velero-plugin-for-aws"] if !ok { return fmt.Errorf("failed to find velero plugin for aws image") } - awsPluginVersion, _, _ := strings.Cut(image.Tag[runtime.GOARCH], "@") + awsPluginVersion, _, _ := strings.Cut(image.Tag["amd64"], "@") + awsPluginVersion = strings.TrimSuffix(awsPluginVersion, "-amd64") awsPluginVersion = strings.TrimPrefix(awsPluginVersion, "v") err := updateVeleroAddonImages(c.Context, current.Location, current.Version, restoreHelperVersion, awsPluginVersion) @@ -210,24 +211,11 @@ func updateVeleroAddonImages(ctx context.Context, chartURL string, chartVersion images = append(images, fmt.Sprintf("docker.io/velero/velero-restore-helper:%s", restoreHelperVersion)) images = append(images, fmt.Sprintf("docker.io/velero/velero-plugin-for-aws:%s", awsPluginVersion)) - if err := ApkoLogin(); err != nil { - return fmt.Errorf("failed to apko login: %w", err) - } - - for _, image := range images { - component, ok := veleroImageComponents[RemoveTagFromImage(image)] - if !ok { - return fmt.Errorf("no component found for image %s", image) - } - repo, tag, err := component.resolveImageRepoAndTag(ctx, image) - if err != nil { - return fmt.Errorf("failed to resolve image and tag for %s: %w", image, err) - } - newimage := velero.Metadata.Images[component.name] - newimage.Repo = repo - newimage.Tag[runtime.GOARCH] = tag - newmeta.Images[component.name] = newimage + metaImages, err := UpdateImages(ctx, veleroImageComponents, velero.Metadata.Images, images) + if err != nil { + return fmt.Errorf("failed to update images: %w", err) } + newmeta.Images = metaImages logrus.Infof("saving addon manifest") if err := newmeta.Save("velero"); err != nil { diff --git a/common.mk b/common.mk index c19e894f0..a061ae16d 100644 --- a/common.mk +++ b/common.mk @@ -103,6 +103,7 @@ apko-output-image: melange-build: ARCHS ?= $(ARCH) melange-build: MELANGE_SOURCE_DIR ?= . melange-build: $(MELANGE_CACHE_DIR) melange-template + mkdir -p build ${MELANGE_CMD} \ keygen build/melange.rsa ${MELANGE_CMD} \ diff --git a/kinds/go.mod b/kinds/go.mod index 2c026d2cf..65c8e3994 100644 --- a/kinds/go.mod +++ b/kinds/go.mod @@ -13,7 +13,7 @@ require ( ) require ( - github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/Masterminds/semver/v3 v3.3.0 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/containerd/containerd v1.7.20 // indirect github.com/cyphar/filepath-securejoin v0.3.1 // indirect @@ -28,6 +28,8 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/onsi/ginkgo/v2 v2.20.2 // indirect + github.com/onsi/gomega v1.34.2 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect @@ -36,11 +38,10 @@ require ( github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect - golang.org/x/mod v0.20.0 // indirect golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect - golang.org/x/tools v0.22.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect + golang.org/x/tools v0.24.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/kinds/go.sum b/kinds/go.sum index 7e5d8165f..5730dce2e 100644 --- a/kinds/go.sum +++ b/kinds/go.sum @@ -1,5 +1,5 @@ -github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= -github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= +github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/containerd/containerd v1.7.20 h1:Sl6jQYk3TRavaU83h66QMbI2Nqg9Jm6qzwX57Vsn1SQ= @@ -28,8 +28,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2Rrd27c3VGxi6a/6HNq8QmHRKM= -github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/k0sproject/k0s v1.29.9-0.20240821114611-d76eb6bb05a7 h1:pxtk/512ibsry6nNx8EfBhFOeeJ/gad1Igjr+7Th6A0= @@ -49,10 +49,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= -github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= -github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= -github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= +github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= +github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= +github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= +github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -104,18 +104,18 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= -golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/local-artifact-mirror/Makefile b/local-artifact-mirror/Makefile index 5b32b80f9..ee098a9ec 100644 --- a/local-artifact-mirror/Makefile +++ b/local-artifact-mirror/Makefile @@ -1,5 +1,7 @@ SHELL := /bin/bash +export PATH := $(shell pwd)/bin:$(PATH) + include ../common.mk OS ?= linux diff --git a/pkg/addons/adminconsole/static/metadata.yaml b/pkg/addons/adminconsole/static/metadata.yaml index fdc4c31b3..8d6704125 100644 --- a/pkg/addons/adminconsole/static/metadata.yaml +++ b/pkg/addons/adminconsole/static/metadata.yaml @@ -11,20 +11,20 @@ images: kotsadm: repo: proxy.replicated.com/anonymous/kotsadm/kotsadm tag: - amd64: v1.117.0@sha256:e37857af2859d76da5628ef0b0ef3fd6a9646770b6a541995f99cbdd9cefa5fc - arm64: v1.116.1@sha256:ac5bedc507ba421334989fe6afd67a832ec36e940a7370eb736d2581ecf3bd07 + amd64: v1.117.0-amd64@sha256:e37857af2859d76da5628ef0b0ef3fd6a9646770b6a541995f99cbdd9cefa5fc + arm64: v1.117.0-arm64@sha256:83b4c38c3c3069890cf43b6db72f1ce6711338e0e728db0e38d341d74a5cd657 kotsadm-migrations: repo: proxy.replicated.com/anonymous/kotsadm/kotsadm-migrations tag: - amd64: v1.117.0@sha256:cd56ca38d33497f5d597a2a540e2db23d2d4123a0696b0146f6289852861c3fb - arm64: v1.116.1@sha256:8b18d9be6ef3fa5b27984c9df7347bcbddde3ef3607d51210e34eb7b949b9106 + amd64: v1.117.0-amd64@sha256:cd56ca38d33497f5d597a2a540e2db23d2d4123a0696b0146f6289852861c3fb + arm64: v1.117.0-arm64@sha256:91c2d038c76fcc15b895919e7eee033921fc4edaa4478f7c349d22074c257237 kurl-proxy: repo: proxy.replicated.com/anonymous/kotsadm/kurl-proxy tag: - amd64: v1.117.0@sha256:b49c9535261e17869200485ca18995a737a8b75e5aec411a0a3043e86d15a7a7 - arm64: v1.116.1@sha256:7fe12b25f55593c94fd3c03b4319585c04ef56c97bf89b9cea084971f1153c54 + amd64: v1.117.0-amd64@sha256:b49c9535261e17869200485ca18995a737a8b75e5aec411a0a3043e86d15a7a7 + arm64: v1.117.0-arm64@sha256:f39013b26ec36d6e8611d841c55332df8de1e2ab5a40e1e2ab1f647785b0ef60 rqlite: repo: proxy.replicated.com/anonymous/kotsadm/rqlite tag: - amd64: 8.30.2-r0@sha256:fe5dbe72a2da1b4d6fb5d2e68a6bfb4c49bae72ba6332dbca5b6e36f298fdbf2 - arm64: 8.30.2-r0@sha256:daf63e77b9ee4611291c37b438a75a1327d84054a3352d8215333d72054a7d3e + amd64: 8.30.2-r0-amd64@sha256:fe5dbe72a2da1b4d6fb5d2e68a6bfb4c49bae72ba6332dbca5b6e36f298fdbf2 + arm64: 8.30.2-r0-arm64@sha256:daf63e77b9ee4611291c37b438a75a1327d84054a3352d8215333d72054a7d3e diff --git a/pkg/addons/embeddedclusteroperator/static/metadata.yaml b/pkg/addons/embeddedclusteroperator/static/metadata.yaml index 5e04baa80..1fe1dee97 100644 --- a/pkg/addons/embeddedclusteroperator/static/metadata.yaml +++ b/pkg/addons/embeddedclusteroperator/static/metadata.yaml @@ -5,16 +5,16 @@ # $ make buildtools # $ output/bin/buildtools update addon # -version: 0.42.1 +version: 1.12.1+k8s-1.29 location: oci://proxy.replicated.com/anonymous/registry.replicated.com/library/embedded-cluster-operator images: embedded-cluster-operator: repo: proxy.replicated.com/anonymous/replicated/embedded-cluster-operator-image tag: - amd64: v1.11.1-k8s-1.29@sha256:7c52b5c4a19004b31988c4b24123b7dfe227d1744d505379f6b232b01f284af1 + amd64: v1.12.1-k8s-1.29-amd64@sha256:eeed01216b5d18dd05ac4f39351a055b4aebe5a9e35ed287595391b6988c8950 arm64: v1.11.1-k8s-1.29@sha256:2520e1593a323d5f7218d9501c6f6f08ef34d8eee4dbc4a7306878e3572aa4cb utils: repo: proxy.replicated.com/anonymous/replicated/ec-utils tag: - amd64: latest@sha256:12a38ef9783948e310e09675cdbfcf5a1bc661d4f9312ee7327dd80af0640e68 - arm64: latest@sha256:0d15c71704bc63e69008912f0dc4a4bb10efa4bb8f3a3f0c95b9e9a330255e8b + amd64: latest-amd64@sha256:92dec6e167ff57b35953da389ceffca0227056368d369a5b20a36fb2fe7e3e11 + arm64: latest-arm64@sha256:a9ab9db181f9898283a8778070ef7945299ffc933d7da081b5326f3296da6d0a diff --git a/pkg/addons/openebs/static/metadata.yaml b/pkg/addons/openebs/static/metadata.yaml index 9eb222291..92c0a4936 100644 --- a/pkg/addons/openebs/static/metadata.yaml +++ b/pkg/addons/openebs/static/metadata.yaml @@ -11,15 +11,15 @@ images: kubectl: repo: proxy.replicated.com/anonymous/replicated/ec-kubectl tag: - amd64: 1.31.0-r2@sha256:df5a0eac8915bf61edbc05e3e9cd31772a565eee72163965c547acf8665ff3b3 - arm64: 1.31.0-r1@sha256:8e0463ce20811f258ef75a858dd2590b2c3c76a3c9670fe443ef23da70cc47ee + amd64: 1.31.1-r0-amd64@sha256:c8d69b540a3a5ce86ab130d312a3fde2871922fe78b2b716e4ddd3c1c6ebcbdd + arm64: 1.31.1-r0-arm64@sha256:b50c038b413baae9496a9ed5ccb297dd5c38e5f7a7eb20e8d39e53432b9ca662 openebs-linux-utils: repo: proxy.replicated.com/anonymous/replicated/ec-openebs-linux-utils tag: - amd64: 4.1.0@sha256:cdd81a500be0f14bdf7cd3853b289e69ad77f0f80dd9bd73040dc7246b3b04ef - arm64: 4.1.0@sha256:a1947ec08fcede8cf38fc7d940dbdd1c08bb5435c0ff71e6382def08c8fe7e1f + amd64: 4.1.0-amd64@sha256:197e6bec20ebc3048abdde22b27fd35d60925ea5f80bea4e54430d37e1fe043f + arm64: 4.1.0-arm64@sha256:903a44b816a68f79f2642817edc11e241cbd57290a6edcdabce4c9c211229c64 openebs-provisioner-localpv: repo: proxy.replicated.com/anonymous/replicated/ec-openebs-provisioner-localpv tag: - amd64: 4.1.0-r0@sha256:77f54b4935376a4fe460853eb1eb3582ec1301f94ff61929444ddae2e8473972 - arm64: 4.1.0-r0@sha256:9432a4e648a976e88d13cc56de6fcbbb03dac5d908a451db30fc6d95e78bd427 + amd64: 4.1.1-r0-amd64@sha256:9749c63b4ff9bca46bb43f900553e4bbc8f81cec5f829d37330a48c8c5570c84 + arm64: 4.1.1-r0-arm64@sha256:d7bafb6afef4bff42d9b39bf4bd66dadcb8232f91994a78e5fe3fe8fe801612d diff --git a/pkg/addons/registry/static/metadata.yaml b/pkg/addons/registry/static/metadata.yaml index af59f8692..4d1605efa 100644 --- a/pkg/addons/registry/static/metadata.yaml +++ b/pkg/addons/registry/static/metadata.yaml @@ -12,4 +12,4 @@ images: repo: proxy.replicated.com/anonymous/replicated/ec-registry tag: amd64: 2.8.3-r0@sha256:5b76ebd0a362009e31a05ac487c690f5ece0e11f6c4d9261ca63a3f162b57660 - arm64: 2.8.3-r0@sha256:b6b7345a1455ae1decd79f39e9ee9f8dff4dedf9fc52acebeba0903779c37cc3 + arm64: 2.8.3-r0-arm64@sha256:e9841478ded46f9ed3f258ea7b291718954cecce2d6907df778d223dded2dd9d diff --git a/pkg/addons/seaweedfs/static/metadata.yaml b/pkg/addons/seaweedfs/static/metadata.yaml index 38a31eedd..f946e4416 100644 --- a/pkg/addons/seaweedfs/static/metadata.yaml +++ b/pkg/addons/seaweedfs/static/metadata.yaml @@ -11,5 +11,5 @@ images: seaweedfs: repo: proxy.replicated.com/anonymous/replicated/ec-seaweedfs tag: - amd64: 3.71-r1@sha256:7f56eaf2a75b77b38d26949a722436ba13c11336347d7a3ba59304c1e982f02d - arm64: 3.71-r1@sha256:e33c698100b2ed65d572099a730ab96e13b0b53124997239a24d9a6891b84046 + amd64: 3.71-r1-amd64@sha256:230abd104726d8e3dbbc634b7bbeee724b86ed1ed923752fabbc40426ea268ec + arm64: 3.71-r1-arm64@sha256:0a99a625edf757fdb64d51add4b5dd66167f9e5491ce6a5bb4f6850f08e53ffb diff --git a/pkg/addons/velero/static/metadata.yaml b/pkg/addons/velero/static/metadata.yaml index 8c260aee1..a41e10c37 100644 --- a/pkg/addons/velero/static/metadata.yaml +++ b/pkg/addons/velero/static/metadata.yaml @@ -11,20 +11,20 @@ images: kubectl: repo: proxy.replicated.com/anonymous/replicated/ec-kubectl tag: - amd64: 1.31.0-r2@sha256:df5a0eac8915bf61edbc05e3e9cd31772a565eee72163965c547acf8665ff3b3 - arm64: 1.31.0-r1@sha256:8e0463ce20811f258ef75a858dd2590b2c3c76a3c9670fe443ef23da70cc47ee + amd64: 1.31.1-r0-amd64@sha256:c8d69b540a3a5ce86ab130d312a3fde2871922fe78b2b716e4ddd3c1c6ebcbdd + arm64: 1.31.1-r0-arm64@sha256:b50c038b413baae9496a9ed5ccb297dd5c38e5f7a7eb20e8d39e53432b9ca662 velero: repo: proxy.replicated.com/anonymous/replicated/ec-velero tag: - amd64: 1.14.1-r0@sha256:4ebaed0b985f5b3d6560a4fe8f9108efa7e7c09a69f73ce4db7118c91495f822 - arm64: 1.14.1-r0@sha256:378b53024050a7defd66703d774d5b45cf0d575db4241a8963e16759066e8ec1 + amd64: 1.14.1-r1-amd64@sha256:d368152662046701d11d51f3a5c736abd0da240ca0800a1b6b22f501718ba91e + arm64: 1.14.1-r1-arm64@sha256:6e8519bca539f1c1bc960e5994ba38e82fed5062b07cd9bbed50396daffe4035 velero-plugin-for-aws: repo: proxy.replicated.com/anonymous/replicated/ec-velero-plugin-for-aws tag: - amd64: 1.10.1-r0@sha256:c8555cc7874caaef9b4da3bb5c88f247612aee9d55ab131057419c62e5be8209 - arm64: 1.10.1-r0@sha256:06195f10a9c1afbebbbf9a3375375badbb7dfe6849bf2b578fdc75c6b3e41c06 + amd64: 1.10.1-r1-amd64@sha256:976739a20069a376845ad58ae5304f938a0a300001939736462f5850459d55cc + arm64: 1.10.1-r1-arm64@sha256:667684ecf851521f46f09988c67610ade8f558aba567cfa2d8b5e11c5ee65583 velero-restore-helper: repo: proxy.replicated.com/anonymous/replicated/ec-velero-restore-helper tag: - amd64: 1.14.1-r0@sha256:012de383146efe94acf73271827bfc69183c500d1ff0ab6312425b7aff7d4031 - arm64: 1.14.1-r0@sha256:43e7be79105b7f8cfcf4472ee26203576b83d52dc18a77514f9a3cb44e8b893e + amd64: 1.14.1-r1-amd64@sha256:3d95cd9120f43b4859d214a8b96f06a2d6466f94d0a2164f2964fe04c107fe71 + arm64: 1.14.1-r1-arm64@sha256:373241730e885ccdf86de8f91c6582e0c0006cfd5d2cfc11ad11d96cab312b49 diff --git a/pkg/config/images.go b/pkg/config/images.go index cfecb5a23..d30c6c217 100644 --- a/pkg/config/images.go +++ b/pkg/config/images.go @@ -54,24 +54,24 @@ func overrideK0sImages(cfg *k0sv1beta1.ClusterConfig) { cfg.Spec.Images = &k0sv1beta1.ClusterImages{} } - cfg.Spec.Images.CoreDNS.Image = Metadata.Images["coredns"].Image - cfg.Spec.Images.CoreDNS.Version = Metadata.Images["coredns"].Version[runtime.GOARCH] + cfg.Spec.Images.CoreDNS.Image = Metadata.Images["coredns"].Repo + cfg.Spec.Images.CoreDNS.Version = Metadata.Images["coredns"].Tag[runtime.GOARCH] - cfg.Spec.Images.Calico.Node.Image = Metadata.Images["calico-node"].Image - cfg.Spec.Images.Calico.Node.Version = Metadata.Images["calico-node"].Version[runtime.GOARCH] + cfg.Spec.Images.Calico.Node.Image = Metadata.Images["calico-node"].Repo + cfg.Spec.Images.Calico.Node.Version = Metadata.Images["calico-node"].Tag[runtime.GOARCH] - cfg.Spec.Images.Calico.CNI.Image = Metadata.Images["calico-cni"].Image - cfg.Spec.Images.Calico.CNI.Version = Metadata.Images["calico-cni"].Version[runtime.GOARCH] + cfg.Spec.Images.Calico.CNI.Image = Metadata.Images["calico-cni"].Repo + cfg.Spec.Images.Calico.CNI.Version = Metadata.Images["calico-cni"].Tag[runtime.GOARCH] - cfg.Spec.Images.Calico.KubeControllers.Image = Metadata.Images["calico-kube-controllers"].Image - cfg.Spec.Images.Calico.KubeControllers.Version = Metadata.Images["calico-kube-controllers"].Version[runtime.GOARCH] + cfg.Spec.Images.Calico.KubeControllers.Image = Metadata.Images["calico-kube-controllers"].Repo + cfg.Spec.Images.Calico.KubeControllers.Version = Metadata.Images["calico-kube-controllers"].Tag[runtime.GOARCH] - cfg.Spec.Images.MetricsServer.Image = Metadata.Images["metrics-server"].Image - cfg.Spec.Images.MetricsServer.Version = Metadata.Images["metrics-server"].Version[runtime.GOARCH] + cfg.Spec.Images.MetricsServer.Image = Metadata.Images["metrics-server"].Repo + cfg.Spec.Images.MetricsServer.Version = Metadata.Images["metrics-server"].Tag[runtime.GOARCH] - cfg.Spec.Images.KubeProxy.Image = Metadata.Images["kube-proxy"].Image - cfg.Spec.Images.KubeProxy.Version = Metadata.Images["kube-proxy"].Version[runtime.GOARCH] + cfg.Spec.Images.KubeProxy.Image = Metadata.Images["kube-proxy"].Repo + cfg.Spec.Images.KubeProxy.Version = Metadata.Images["kube-proxy"].Tag[runtime.GOARCH] - cfg.Spec.Images.Pause.Image = Metadata.Images["pause"].Image - cfg.Spec.Images.Pause.Version = Metadata.Images["pause"].Version[runtime.GOARCH] + cfg.Spec.Images.Pause.Image = Metadata.Images["pause"].Repo + cfg.Spec.Images.Pause.Version = Metadata.Images["pause"].Tag[runtime.GOARCH] } diff --git a/pkg/config/images_test.go b/pkg/config/images_test.go index 280a988c5..688e64b19 100644 --- a/pkg/config/images_test.go +++ b/pkg/config/images_test.go @@ -49,13 +49,13 @@ func TestListK0sImages(t *testing.T) { for _, i := range Metadata.Images { found := false for _, f := range filtered { - if f == i.URI() { + if f == i.String() { found = true break } } if !found { - t.Errorf("ListK0sImages() = %v, want to contain %s", filtered, i.URI()) + t.Errorf("ListK0sImages() = %v, want to contain %s", filtered, i.String()) } } diff --git a/pkg/config/static/metadata.yaml b/pkg/config/static/metadata.yaml index d514fc1b9..82f22aeff 100644 --- a/pkg/config/static/metadata.yaml +++ b/pkg/config/static/metadata.yaml @@ -7,37 +7,37 @@ # images: calico-cni: - image: proxy.replicated.com/anonymous/replicated/ec-calico-cni - version: - amd64: 3.28.1-r0@sha256:65a10af6dbfaf616ae237cec7d9b438727d8167415b698b858235c5c3897dcec - arm64: 3.28.1-r0@sha256:c4632af2c6f85642201ac4dfb498304b700773f89f0a724abb0e3367d069eaeb + repo: proxy.replicated.com/anonymous/replicated/ec-calico-cni + tag: + amd64: 3.28.1-r1-amd64@sha256:0dcd11e06521b128febc3197813f29822226bf2bb7f77c6d103f84c86f2486b8 + arm64: 3.28.1-r1-arm64@sha256:b405a215d3db0bbea5af929c11482d9490d9245f00ee7f40dd74b07e1c53baf4 calico-kube-controllers: - image: proxy.replicated.com/anonymous/replicated/ec-calico-kube-controllers - version: - amd64: 3.28.1-r0@sha256:2c38dff2446170033eedcba11370621feaa6048efc220f9c64d3253d1d3cc790 - arm64: 3.28.1-r0@sha256:083ee435ffd24675a730bb5e73d58d9985514917dd433226b71b8e8ebd3ebffc + repo: proxy.replicated.com/anonymous/replicated/ec-calico-kube-controllers + tag: + amd64: 3.28.1-r1-amd64@sha256:eb3ab9b627a59eace8cda3e181fce2f5170c42d7d63e0aacf635b4d1b469b6be + arm64: 3.28.1-r1-arm64@sha256:fe7c2b2006ffee1bfcd36d2c52fae05d24f6eb3fa120fa8ad5956cef6b789d36 calico-node: - image: proxy.replicated.com/anonymous/replicated/ec-calico-node - version: - amd64: 3.28.1-r0@sha256:9420c9271eae9a8329478fdad79817a4c381096e553bfecfea7e8a470a103145 - arm64: 3.28.1-r0@sha256:892e1c6cd5462c1d901ef2f550e8bffd6b60e81029f675297a4a3f3165bedef4 + repo: proxy.replicated.com/anonymous/replicated/ec-calico-node + tag: + amd64: 3.28.1-r1-amd64@sha256:d290f159a79af275fb2bd2d72c18716b2c883532f24f5650c7a4fa5bc2d11db1 + arm64: 3.28.1-r1-arm64@sha256:d77e8818f5ad3bd649bd22c4ed0d7d051aba8ddb9823d3b5af9ff889485f11df coredns: - image: proxy.replicated.com/anonymous/replicated/ec-coredns - version: - amd64: 1.11.3-r6@sha256:d6964b8206f1bd14e41ddd4db5f3f5e8d8fd68616216aec2f8b80a4f9771a0fe - arm64: 1.11.3-r6@sha256:73243fae35d0097d8330ac66f053051de46e8a6d3ddc5bf31796996fad9c6574 + repo: proxy.replicated.com/anonymous/replicated/ec-coredns + tag: + amd64: 1.11.3-r7-amd64@sha256:1258b039d78e85c17bec40e587f5cb963998c6039a7d727bef09a84d7eedddba + arm64: 1.11.3-r7-arm64@sha256:668b0c2f611b420df19554f0df08caa4ac4a92fd8fafc6b28ae9e6bc12ecfa71 kube-proxy: - image: proxy.replicated.com/anonymous/registry.k8s.io/kube-proxy - version: - amd64: v1.29.8@sha256:c257d390d3fa14c3ff6617852c91eaf75b2f16033899438a17e3e13fff798712 - arm64: v1.29.8@sha256:59a1968e6265351883beed31b69dad15528d15ae6da66e069093301e0574c6b2 + repo: proxy.replicated.com/anonymous/registry.k8s.io/kube-proxy + tag: + amd64: v1.29.9-amd64@sha256:eb9e12af6de3613c05afcb9743a30589c16454bfa085c3091248a6f55b799304 + arm64: v1.29.9-arm64@sha256:030bea0a09a10bbc84380a0e529d4fb969f15218384939fc832dfd2f221a5643 metrics-server: - image: proxy.replicated.com/anonymous/replicated/ec-metrics-server - version: - amd64: 0.7.2-r0@sha256:1ed93939ecf3111d031c36a6b3ab1349b8d42facb7666209ae13e51fc5a29a17 - arm64: 0.7.2-r0@sha256:a08666ad195198c031ec196d33a74d300188f11515ca1e637375fa9eabd35a42 + repo: proxy.replicated.com/anonymous/replicated/ec-metrics-server + tag: + amd64: 0.7.2-r1-amd64@sha256:05e3db63e7ecce0a543fad1a3c7292ce14e49efbc2ef65524266990df52c95a5 + arm64: 0.7.2-r1-arm64@sha256:f6cf5333630c436e22a4f4693dc0bd376b589a2f3705f5cc8b45b465eb4d7d83 pause: - image: proxy.replicated.com/anonymous/registry.k8s.io/pause - version: - amd64: 3.9@sha256:8d4106c88ec0bd28001e34c975d65175d994072d65341f62a8ab0754b0fafe10 - arm64: 3.9@sha256:3ec98b8452dc8ae265a6917dfb81587ac78849e520d5dbba6de524851d20eca6 + repo: proxy.replicated.com/anonymous/registry.k8s.io/pause + tag: + amd64: 3.9-amd64@sha256:8d4106c88ec0bd28001e34c975d65175d994072d65341f62a8ab0754b0fafe10 + arm64: 3.9-arm64@sha256:3ec98b8452dc8ae265a6917dfb81587ac78849e520d5dbba6de524851d20eca6 diff --git a/pkg/release/k0s.go b/pkg/release/k0s.go index 77ddc9766..b786d49bb 100644 --- a/pkg/release/k0s.go +++ b/pkg/release/k0s.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "path/filepath" - "runtime" "gopkg.in/yaml.v3" ) @@ -20,16 +19,7 @@ const k0sMetadataPreface = `# ` type K0sMetadata struct { - Images map[string]K0sImage `yaml:"images"` -} - -type K0sImage struct { - Image string `yaml:"image"` - Version map[string]string `yaml:"version"` -} - -func (i K0sImage) URI() string { - return fmt.Sprintf("%s:%s", i.Image, i.Version[runtime.GOARCH]) + Images map[string]AddonImage `yaml:"images"` } func (a *K0sMetadata) Save() error {