@@ -39,10 +39,13 @@ import (
3939 "github.com/deckhouse/deckhouse-cli/internal/mirror/operations"
4040 "github.com/deckhouse/deckhouse-cli/internal/mirror/releases"
4141 "github.com/deckhouse/deckhouse-cli/internal/version"
42+ "github.com/deckhouse/deckhouse-cli/pkg"
4243 "github.com/deckhouse/deckhouse-cli/pkg/libmirror/modules"
4344 "github.com/deckhouse/deckhouse-cli/pkg/libmirror/operations/params"
4445 "github.com/deckhouse/deckhouse-cli/pkg/libmirror/util/log"
4546 "github.com/deckhouse/deckhouse-cli/pkg/libmirror/validation"
47+ "github.com/deckhouse/deckhouse-cli/pkg/registry"
48+ dkplog "github.com/deckhouse/deckhouse/pkg/log"
4649)
4750
4851var ErrPullFailed = errors .New ("pull failed, see the log for details" )
@@ -143,13 +146,13 @@ func setupLogger() *log.SLogger {
143146 return log .NewSLogger (logLevel )
144147}
145148
146- func findTagsToMirror (pullParams * params.PullParams , logger * log.SLogger ) ([]string , error ) {
149+ func findTagsToMirror (pullParams * params.PullParams , logger * log.SLogger , client pkg. RegistryClient ) ([]string , error ) {
147150 if pullParams .DeckhouseTag != "" {
148151 logger .InfoF ("Skipped releases lookup as tag %q is specifically requested with --deckhouse-tag" , pullParams .DeckhouseTag )
149152 return []string {pullParams .DeckhouseTag }, nil
150153 }
151154
152- versionsToMirror , err := versionsToMirrorFunc (pullParams )
155+ versionsToMirror , err := versionsToMirrorFunc (pullParams , client )
153156 if err != nil {
154157 return nil , fmt .Errorf ("Find versions to mirror: %w" , err )
155158 }
@@ -287,17 +290,42 @@ func (p *Puller) pullPlatform() error {
287290 return nil
288291 }
289292
293+ logger := dkplog .NewNop ()
294+
295+ if log .DebugLogLevel () >= 3 {
296+ logger = dkplog .NewLogger (dkplog .WithLevel (slog .LevelDebug ))
297+ }
298+
299+ // Create registry client for module operations
300+ clientOpts := & registry.ClientOptions {
301+ Insecure : p .params .Insecure ,
302+ TLSSkipVerify : p .params .SkipTLSVerification ,
303+ Logger : logger ,
304+ }
305+
306+ if p .params .RegistryAuth != nil {
307+ clientOpts .Auth = p .params .RegistryAuth
308+ }
309+
310+ var client pkg.RegistryClient
311+ client = registry .NewClientWithOptions (p .params .DeckhouseRegistryRepo , clientOpts )
312+
313+ // Scope to the registry path and modules suffix
314+ if p .params .RegistryPath != "" {
315+ client = client .WithSegment (p .params .RegistryPath )
316+ }
317+
290318 return p .logger .Process ("Pull Deckhouse Kubernetes Platform" , func () error {
291319 if err := p .validatePlatformAccess (); err != nil {
292320 return err
293321 }
294322
295- tagsToMirror , err := findTagsToMirror (p .params , p .logger )
323+ tagsToMirror , err := findTagsToMirror (p .params , p .logger , client )
296324 if err != nil {
297325 return fmt .Errorf ("Find tags to mirror: %w" , err )
298326 }
299327
300- if err = operations .PullDeckhousePlatform (p .params , tagsToMirror ); err != nil {
328+ if err = operations .PullDeckhousePlatform (p .params , tagsToMirror , client ); err != nil {
301329 return err
302330 }
303331 return nil
@@ -327,6 +355,31 @@ func (p *Puller) pullSecurityDatabases() error {
327355 return nil
328356 }
329357
358+ logger := dkplog .NewNop ()
359+
360+ if log .DebugLogLevel () >= 3 {
361+ logger = dkplog .NewLogger (dkplog .WithLevel (slog .LevelDebug ))
362+ }
363+
364+ // Create registry client for module operations
365+ clientOpts := & registry.ClientOptions {
366+ Insecure : p .params .Insecure ,
367+ TLSSkipVerify : p .params .SkipTLSVerification ,
368+ Logger : logger ,
369+ }
370+
371+ if p .params .RegistryAuth != nil {
372+ clientOpts .Auth = p .params .RegistryAuth
373+ }
374+
375+ var client pkg.RegistryClient
376+ client = registry .NewClientWithOptions (p .params .DeckhouseRegistryRepo , clientOpts )
377+
378+ // Scope to the registry path and modules suffix
379+ if p .params .RegistryPath != "" {
380+ client = client .WithSegment (p .params .RegistryPath )
381+ }
382+
330383 return p .logger .Process ("Pull Security Databases" , func () error {
331384 ctx , cancel := context .WithTimeout (p .cmd .Context (), 15 * time .Second )
332385 defer cancel ()
@@ -341,7 +394,7 @@ func (p *Puller) pullSecurityDatabases() error {
341394 return fmt .Errorf ("Source registry is not accessible: %w" , err )
342395 }
343396
344- if err := operations .PullSecurityDatabases (p .params ); err != nil {
397+ if err := operations .PullSecurityDatabases (p .params , client ); err != nil {
345398 return err
346399 }
347400 return nil
@@ -359,6 +412,35 @@ func (p *Puller) pullModules() error {
359412 processName = "Pull Extra Images"
360413 }
361414
415+ logger := dkplog .NewNop ()
416+
417+ if log .DebugLogLevel () >= 3 {
418+ logger = dkplog .NewLogger (dkplog .WithLevel (slog .LevelDebug ))
419+ }
420+
421+ // Create registry client for module operations
422+ clientOpts := & registry.ClientOptions {
423+ Insecure : p .params .Insecure ,
424+ TLSSkipVerify : p .params .SkipTLSVerification ,
425+ Logger : logger ,
426+ }
427+
428+ if p .params .RegistryAuth != nil {
429+ clientOpts .Auth = p .params .RegistryAuth
430+ }
431+
432+ var client pkg.RegistryClient
433+ client = registry .NewClientWithOptions (p .params .DeckhouseRegistryRepo , clientOpts )
434+
435+ // Scope to the registry path and modules suffix
436+ if p .params .RegistryPath != "" {
437+ client = client .WithSegment (p .params .RegistryPath )
438+ }
439+
440+ if p .params .ModulesPathSuffix != "" {
441+ client = client .WithSegment (p .params .ModulesPathSuffix )
442+ }
443+
362444 return p .logger .Process (processName , func () error {
363445 if err := p .validateModulesAccess (); err != nil {
364446 return err
@@ -369,7 +451,7 @@ func (p *Puller) pullModules() error {
369451 return err
370452 }
371453
372- return operations .PullModules (p .params , filter )
454+ return operations .PullModules (p .params , filter , client )
373455 })
374456}
375457
0 commit comments