Skip to content

Commit

Permalink
add standalone image
Browse files Browse the repository at this point in the history
Signed-off-by: Denisenko Dmitry <[email protected]>
  • Loading branch information
dmitry.denisenko authored and mvasl committed Sep 30, 2024
1 parent 33e12d9 commit adebe21
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 12 deletions.
4 changes: 4 additions & 0 deletions internal/mirror/cmd/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ func PullDeckhouseToLocalFS(
return fmt.Errorf("pull installers: %w", err)
}

if err = layouts.PullStandaloneInstallers(pullCtx, imageLayouts); err != nil {
return fmt.Errorf("pull standalone installers: %w", err)
}

logger.InfoF("Searching for Deckhouse built-in modules digests")
for imageTag := range imageLayouts.InstallImages {
digests, err := images.ExtractImageDigestsFromDeckhouseInstaller(pullCtx, imageTag, imageLayouts.Install)
Expand Down
24 changes: 18 additions & 6 deletions pkg/libmirror/layouts/layouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ type ImageLayouts struct {
Install layout.Path
InstallImages map[string]struct{}

InstallStandalone layout.Path
InstallStandaloneImages map[string]struct{}

ReleaseChannel layout.Path
ReleaseChannelImages map[string]struct{}

Expand Down Expand Up @@ -80,12 +83,13 @@ func CreateOCIImageLayoutsForDeckhouse(
}

fsPaths := map[*layout.Path]string{
&layouts.Deckhouse: rootFolder,
&layouts.Install: filepath.Join(rootFolder, "install"),
&layouts.ReleaseChannel: filepath.Join(rootFolder, "release-channel"),
&layouts.TrivyDB: filepath.Join(rootFolder, "security", "trivy-db"),
&layouts.TrivyBDU: filepath.Join(rootFolder, "security", "trivy-bdu"),
&layouts.TrivyJavaDB: filepath.Join(rootFolder, "security", "trivy-java-db"),
&layouts.Deckhouse: rootFolder,
&layouts.Install: filepath.Join(rootFolder, "install"),
&layouts.InstallStandalone: filepath.Join(rootFolder, "install-standalone"),
&layouts.ReleaseChannel: filepath.Join(rootFolder, "release-channel"),
&layouts.TrivyDB: filepath.Join(rootFolder, "security", "trivy-db"),
&layouts.TrivyBDU: filepath.Join(rootFolder, "security", "trivy-bdu"),
&layouts.TrivyJavaDB: filepath.Join(rootFolder, "security", "trivy-java-db"),
}
for layoutPtr, fsPath := range fsPaths {
*layoutPtr, err = CreateEmptyImageLayoutAtPath(fsPath)
Expand Down Expand Up @@ -173,6 +177,7 @@ func FillLayoutsWithBasicDeckhouseImages(
) {
layouts.DeckhouseImages = map[string]struct{}{}
layouts.InstallImages = map[string]struct{}{}
layouts.InstallStandaloneImages = map[string]struct{}{}
layouts.ReleaseChannelImages = map[string]struct{}{}
layouts.TrivyDBImages = map[string]struct{}{
mirrorCtx.DeckhouseRegistryRepo + "/security/trivy-db:2": {},
Expand All @@ -183,6 +188,7 @@ func FillLayoutsWithBasicDeckhouseImages(
for _, version := range deckhouseVersions {
layouts.DeckhouseImages[fmt.Sprintf("%s:v%s", mirrorCtx.DeckhouseRegistryRepo, version.String())] = struct{}{}
layouts.InstallImages[fmt.Sprintf("%s/install:v%s", mirrorCtx.DeckhouseRegistryRepo, version.String())] = struct{}{}
layouts.InstallStandaloneImages[fmt.Sprintf("%s/install-standalone:v%s", mirrorCtx.DeckhouseRegistryRepo, version.String())] = struct{}{}
layouts.ReleaseChannelImages[fmt.Sprintf("%s/release-channel:v%s", mirrorCtx.DeckhouseRegistryRepo, version.String())] = struct{}{}
}

Expand All @@ -203,6 +209,12 @@ func FillLayoutsWithBasicDeckhouseImages(
layouts.InstallImages[mirrorCtx.DeckhouseRegistryRepo+"/install:stable"] = struct{}{}
layouts.InstallImages[mirrorCtx.DeckhouseRegistryRepo+"/install:rock-solid"] = struct{}{}

layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:alpha"] = struct{}{}
layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:beta"] = struct{}{}
layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:early-access"] = struct{}{}
layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:stable"] = struct{}{}
layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:rock-solid"] = struct{}{}

layouts.ReleaseChannelImages[mirrorCtx.DeckhouseRegistryRepo+"/release-channel:alpha"] = struct{}{}
layouts.ReleaseChannelImages[mirrorCtx.DeckhouseRegistryRepo+"/release-channel:beta"] = struct{}{}
layouts.ReleaseChannelImages[mirrorCtx.DeckhouseRegistryRepo+"/release-channel:early-access"] = struct{}{}
Expand Down
15 changes: 15 additions & 0 deletions pkg/libmirror/layouts/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ func PullInstallers(mirrorCtx *contexts.PullContext, layouts *ImageLayouts) erro
return nil
}

func PullStandaloneInstallers(mirrorCtx *contexts.PullContext, layouts *ImageLayouts) error {
mirrorCtx.Logger.InfoLn("Beginning to pull standalone installers")
if err := PullImageSet(
mirrorCtx,
layouts.InstallStandalone,
layouts.InstallStandaloneImages,
WithTagToDigestMapper(layouts.TagsResolver.GetTagDigest),
WithAllowMissingTags(true),
); err != nil {
return err
}
mirrorCtx.Logger.InfoLn("✅ All required standalone installers are pulled!")
return nil
}

func PullDeckhouseReleaseChannels(mirrorCtx *contexts.PullContext, layouts *ImageLayouts) error {
mirrorCtx.Logger.InfoLn("Beginning to pull Deckhouse release channels information")
if err := PullImageSet(
Expand Down
1 change: 1 addition & 0 deletions pkg/libmirror/layouts/tag_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (r *TagsResolver) ResolveTagsDigestsForImageLayouts(mirrorCtx *contexts.Bas
layouts.DeckhouseImages,
layouts.ReleaseChannelImages,
layouts.InstallImages,
layouts.InstallStandaloneImages,
}

for _, moduleImageLayout := range layouts.Modules {
Expand Down
19 changes: 13 additions & 6 deletions pkg/libmirror/operations/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ func pushModulesTags(mirrorCtx *contexts.BaseContext, modulesList []string) erro
func findLayoutsToPush(mirrorCtx *contexts.PushContext) (map[string]layout.Path, []string, error) {
deckhouseIndexRef := mirrorCtx.RegistryHost + mirrorCtx.RegistryPath
installersIndexRef := path.Join(deckhouseIndexRef, "install")
installersStandaloneIndexRef := path.Join(deckhouseIndexRef, "install-standalone")
releasesIndexRef := path.Join(deckhouseIndexRef, "release-channel")
trivyDBIndexRef := path.Join(deckhouseIndexRef, "security", "trivy-db")
trivyBDUIndexRef := path.Join(deckhouseIndexRef, "security", "trivy-bdu")
trivyJavaDBIndexRef := path.Join(deckhouseIndexRef, "security", "trivy-java-db")

deckhouseLayoutPath := mirrorCtx.UnpackedImagesPath
installersLayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "install")
installersStandaloneLayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "install-standalone")
releasesLayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "release-channel")
trivyDBLayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "security", "trivy-db")
trivyBDULayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "security", "trivy-bdu")
Expand All @@ -157,6 +159,10 @@ func findLayoutsToPush(mirrorCtx *contexts.PushContext) (map[string]layout.Path,
if err != nil {
return nil, nil, err
}
installersStandaloneLayout, err := layout.FromPath(installersStandaloneLayoutPath)
if err != nil {
return nil, nil, err
}
releasesLayout, err := layout.FromPath(releasesLayoutPath)
if err != nil {
return nil, nil, err
Expand All @@ -176,12 +182,13 @@ func findLayoutsToPush(mirrorCtx *contexts.PushContext) (map[string]layout.Path,

modulesPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "modules")
ociLayouts := map[string]layout.Path{
deckhouseIndexRef: deckhouseLayout,
installersIndexRef: installersLayout,
releasesIndexRef: releasesLayout,
trivyDBIndexRef: trivyDBLayout,
trivyBDUIndexRef: trivyBDULayout,
trivyJavaDBIndexRef: trivyJavaDBLayout,
deckhouseIndexRef: deckhouseLayout,
installersIndexRef: installersLayout,
installersStandaloneIndexRef: installersStandaloneLayout,
releasesIndexRef: releasesLayout,
trivyDBIndexRef: trivyDBLayout,
trivyBDUIndexRef: trivyBDULayout,
trivyJavaDBIndexRef: trivyJavaDBLayout,
}

modulesNames := make([]string, 0)
Expand Down
6 changes: 6 additions & 0 deletions testing/e2e/mirror/mirror_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ func createDeckhouseControllersAndInstallersInRegistry(t *testing.T, repo string

err = remote.Write(ref, installer, remoteOpts...)
require.NoError(t, err)

ref, err = name.ParseReference(repo+"/install-standalone:"+shortTag, nameOpts...)
require.NoError(t, err)

err = remote.Write(ref, installer, remoteOpts...)
require.NoError(t, err)
}
}

Expand Down

0 comments on commit adebe21

Please sign in to comment.