Skip to content

Commit adebe21

Browse files
d2285mvasl
authored andcommitted
add standalone image
Signed-off-by: Denisenko Dmitry <[email protected]>
1 parent 33e12d9 commit adebe21

File tree

6 files changed

+57
-12
lines changed

6 files changed

+57
-12
lines changed

internal/mirror/cmd/pull/pull.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ func PullDeckhouseToLocalFS(
328328
return fmt.Errorf("pull installers: %w", err)
329329
}
330330

331+
if err = layouts.PullStandaloneInstallers(pullCtx, imageLayouts); err != nil {
332+
return fmt.Errorf("pull standalone installers: %w", err)
333+
}
334+
331335
logger.InfoF("Searching for Deckhouse built-in modules digests")
332336
for imageTag := range imageLayouts.InstallImages {
333337
digests, err := images.ExtractImageDigestsFromDeckhouseInstaller(pullCtx, imageTag, imageLayouts.Install)

pkg/libmirror/layouts/layouts.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ type ImageLayouts struct {
4646
Install layout.Path
4747
InstallImages map[string]struct{}
4848

49+
InstallStandalone layout.Path
50+
InstallStandaloneImages map[string]struct{}
51+
4952
ReleaseChannel layout.Path
5053
ReleaseChannelImages map[string]struct{}
5154

@@ -80,12 +83,13 @@ func CreateOCIImageLayoutsForDeckhouse(
8083
}
8184

8285
fsPaths := map[*layout.Path]string{
83-
&layouts.Deckhouse: rootFolder,
84-
&layouts.Install: filepath.Join(rootFolder, "install"),
85-
&layouts.ReleaseChannel: filepath.Join(rootFolder, "release-channel"),
86-
&layouts.TrivyDB: filepath.Join(rootFolder, "security", "trivy-db"),
87-
&layouts.TrivyBDU: filepath.Join(rootFolder, "security", "trivy-bdu"),
88-
&layouts.TrivyJavaDB: filepath.Join(rootFolder, "security", "trivy-java-db"),
86+
&layouts.Deckhouse: rootFolder,
87+
&layouts.Install: filepath.Join(rootFolder, "install"),
88+
&layouts.InstallStandalone: filepath.Join(rootFolder, "install-standalone"),
89+
&layouts.ReleaseChannel: filepath.Join(rootFolder, "release-channel"),
90+
&layouts.TrivyDB: filepath.Join(rootFolder, "security", "trivy-db"),
91+
&layouts.TrivyBDU: filepath.Join(rootFolder, "security", "trivy-bdu"),
92+
&layouts.TrivyJavaDB: filepath.Join(rootFolder, "security", "trivy-java-db"),
8993
}
9094
for layoutPtr, fsPath := range fsPaths {
9195
*layoutPtr, err = CreateEmptyImageLayoutAtPath(fsPath)
@@ -173,6 +177,7 @@ func FillLayoutsWithBasicDeckhouseImages(
173177
) {
174178
layouts.DeckhouseImages = map[string]struct{}{}
175179
layouts.InstallImages = map[string]struct{}{}
180+
layouts.InstallStandaloneImages = map[string]struct{}{}
176181
layouts.ReleaseChannelImages = map[string]struct{}{}
177182
layouts.TrivyDBImages = map[string]struct{}{
178183
mirrorCtx.DeckhouseRegistryRepo + "/security/trivy-db:2": {},
@@ -183,6 +188,7 @@ func FillLayoutsWithBasicDeckhouseImages(
183188
for _, version := range deckhouseVersions {
184189
layouts.DeckhouseImages[fmt.Sprintf("%s:v%s", mirrorCtx.DeckhouseRegistryRepo, version.String())] = struct{}{}
185190
layouts.InstallImages[fmt.Sprintf("%s/install:v%s", mirrorCtx.DeckhouseRegistryRepo, version.String())] = struct{}{}
191+
layouts.InstallStandaloneImages[fmt.Sprintf("%s/install-standalone:v%s", mirrorCtx.DeckhouseRegistryRepo, version.String())] = struct{}{}
186192
layouts.ReleaseChannelImages[fmt.Sprintf("%s/release-channel:v%s", mirrorCtx.DeckhouseRegistryRepo, version.String())] = struct{}{}
187193
}
188194

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

212+
layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:alpha"] = struct{}{}
213+
layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:beta"] = struct{}{}
214+
layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:early-access"] = struct{}{}
215+
layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:stable"] = struct{}{}
216+
layouts.InstallStandaloneImages[mirrorCtx.DeckhouseRegistryRepo+"/install-standalone:rock-solid"] = struct{}{}
217+
206218
layouts.ReleaseChannelImages[mirrorCtx.DeckhouseRegistryRepo+"/release-channel:alpha"] = struct{}{}
207219
layouts.ReleaseChannelImages[mirrorCtx.DeckhouseRegistryRepo+"/release-channel:beta"] = struct{}{}
208220
layouts.ReleaseChannelImages[mirrorCtx.DeckhouseRegistryRepo+"/release-channel:early-access"] = struct{}{}

pkg/libmirror/layouts/pull.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ func PullInstallers(mirrorCtx *contexts.PullContext, layouts *ImageLayouts) erro
4848
return nil
4949
}
5050

51+
func PullStandaloneInstallers(mirrorCtx *contexts.PullContext, layouts *ImageLayouts) error {
52+
mirrorCtx.Logger.InfoLn("Beginning to pull standalone installers")
53+
if err := PullImageSet(
54+
mirrorCtx,
55+
layouts.InstallStandalone,
56+
layouts.InstallStandaloneImages,
57+
WithTagToDigestMapper(layouts.TagsResolver.GetTagDigest),
58+
WithAllowMissingTags(true),
59+
); err != nil {
60+
return err
61+
}
62+
mirrorCtx.Logger.InfoLn("✅ All required standalone installers are pulled!")
63+
return nil
64+
}
65+
5166
func PullDeckhouseReleaseChannels(mirrorCtx *contexts.PullContext, layouts *ImageLayouts) error {
5267
mirrorCtx.Logger.InfoLn("Beginning to pull Deckhouse release channels information")
5368
if err := PullImageSet(

pkg/libmirror/layouts/tag_resolver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (r *TagsResolver) ResolveTagsDigestsForImageLayouts(mirrorCtx *contexts.Bas
4848
layouts.DeckhouseImages,
4949
layouts.ReleaseChannelImages,
5050
layouts.InstallImages,
51+
layouts.InstallStandaloneImages,
5152
}
5253

5354
for _, moduleImageLayout := range layouts.Modules {

pkg/libmirror/operations/push.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ func pushModulesTags(mirrorCtx *contexts.BaseContext, modulesList []string) erro
137137
func findLayoutsToPush(mirrorCtx *contexts.PushContext) (map[string]layout.Path, []string, error) {
138138
deckhouseIndexRef := mirrorCtx.RegistryHost + mirrorCtx.RegistryPath
139139
installersIndexRef := path.Join(deckhouseIndexRef, "install")
140+
installersStandaloneIndexRef := path.Join(deckhouseIndexRef, "install-standalone")
140141
releasesIndexRef := path.Join(deckhouseIndexRef, "release-channel")
141142
trivyDBIndexRef := path.Join(deckhouseIndexRef, "security", "trivy-db")
142143
trivyBDUIndexRef := path.Join(deckhouseIndexRef, "security", "trivy-bdu")
143144
trivyJavaDBIndexRef := path.Join(deckhouseIndexRef, "security", "trivy-java-db")
144145

145146
deckhouseLayoutPath := mirrorCtx.UnpackedImagesPath
146147
installersLayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "install")
148+
installersStandaloneLayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "install-standalone")
147149
releasesLayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "release-channel")
148150
trivyDBLayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "security", "trivy-db")
149151
trivyBDULayoutPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "security", "trivy-bdu")
@@ -157,6 +159,10 @@ func findLayoutsToPush(mirrorCtx *contexts.PushContext) (map[string]layout.Path,
157159
if err != nil {
158160
return nil, nil, err
159161
}
162+
installersStandaloneLayout, err := layout.FromPath(installersStandaloneLayoutPath)
163+
if err != nil {
164+
return nil, nil, err
165+
}
160166
releasesLayout, err := layout.FromPath(releasesLayoutPath)
161167
if err != nil {
162168
return nil, nil, err
@@ -176,12 +182,13 @@ func findLayoutsToPush(mirrorCtx *contexts.PushContext) (map[string]layout.Path,
176182

177183
modulesPath := filepath.Join(mirrorCtx.UnpackedImagesPath, "modules")
178184
ociLayouts := map[string]layout.Path{
179-
deckhouseIndexRef: deckhouseLayout,
180-
installersIndexRef: installersLayout,
181-
releasesIndexRef: releasesLayout,
182-
trivyDBIndexRef: trivyDBLayout,
183-
trivyBDUIndexRef: trivyBDULayout,
184-
trivyJavaDBIndexRef: trivyJavaDBLayout,
185+
deckhouseIndexRef: deckhouseLayout,
186+
installersIndexRef: installersLayout,
187+
installersStandaloneIndexRef: installersStandaloneLayout,
188+
releasesIndexRef: releasesLayout,
189+
trivyDBIndexRef: trivyDBLayout,
190+
trivyBDUIndexRef: trivyBDULayout,
191+
trivyJavaDBIndexRef: trivyJavaDBLayout,
185192
}
186193

187194
modulesNames := make([]string, 0)

testing/e2e/mirror/mirror_e2e_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ func createDeckhouseControllersAndInstallersInRegistry(t *testing.T, repo string
189189

190190
err = remote.Write(ref, installer, remoteOpts...)
191191
require.NoError(t, err)
192+
193+
ref, err = name.ParseReference(repo+"/install-standalone:"+shortTag, nameOpts...)
194+
require.NoError(t, err)
195+
196+
err = remote.Write(ref, installer, remoteOpts...)
197+
require.NoError(t, err)
192198
}
193199
}
194200

0 commit comments

Comments
 (0)