Skip to content

Commit 3eecc29

Browse files
committed
Remove depreciated architectures and move to platforms instead.
1 parent 817e5c0 commit 3eecc29

File tree

5 files changed

+669
-156
lines changed

5 files changed

+669
-156
lines changed

examples/config-sync-architectures.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"maxRetries": 3,
2727
"retryDelay": "5m",
2828
"onlySigned": true,
29-
"architectures": ["amd64", "arm64"],
30-
"platforms": ["linux/amd64", "linux/arm64"],
29+
"platforms": ["amd64", "arm64", "linux/amd64", "linux/arm64"],
3130
"content": [
3231
{
3332
"prefix": "/repo1/repo",
@@ -60,8 +59,7 @@
6059
"pollInterval": "12h",
6160
"tlsVerify": false,
6261
"onDemand": false,
63-
"architectures": ["amd64"],
64-
"platforms": ["linux/amd64", "windows/amd64"],
62+
"platforms": ["amd64", "linux/amd64", "windows/amd64"],
6563
"content": [
6664
{
6765
"prefix": "**",
@@ -79,8 +77,7 @@
7977
"tlsVerify": true,
8078
"maxRetries": 5,
8179
"retryDelay": "30s",
82-
"architectures": ["amd64", "arm64", "arm"],
83-
"platforms": ["linux/amd64", "linux/arm64", "linux/arm"]
80+
"platforms": ["amd64", "arm64", "arm", "linux/amd64", "linux/arm64", "linux/arm"]
8481
},
8582
{
8683
"urls": [

examples/config-sync-platforms.json

-109
This file was deleted.

pkg/extensions/sync/destination.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,6 @@ func (registry *DestinationRegistry) copyManifest(repo string, desc ispec.Descri
301301
Str("repository", repo).
302302
Str("reference", reference).
303303
Msg("filtering manifest list by platforms")
304-
} else if len(registry.config.Architectures) > 0 {
305-
platformSpecs = registry.config.Architectures
306-
registry.log.Info().
307-
Strs("architectures", registry.config.Architectures).
308-
Str("repository", repo).
309-
Str("reference", reference).
310-
Msg("filtering manifest list by architectures (deprecated)")
311304
}
312305
}
313306

@@ -377,7 +370,7 @@ func (registry *DestinationRegistry) copyManifest(repo string, desc ispec.Descri
377370

378371
// If we've filtered the manifest list, we need to update it
379372
if registry.config != nil &&
380-
(len(registry.config.Architectures) > 0 || len(registry.config.Platforms) > 0) &&
373+
len(registry.config.Platforms) > 0 &&
381374
len(filteredManifests) != len(indexManifest.Manifests) && len(filteredManifests) > 0 {
382375
// Create a new index with the filtered manifests
383376
indexManifest.Manifests = filteredManifests

pkg/extensions/sync/service.go

+10-33
Original file line numberDiff line numberDiff line change
@@ -451,19 +451,16 @@ func (service *BaseService) SyncRepo(ctx context.Context, repo string) error {
451451
}
452452

453453
// shouldIncludePlatform determines if a platform should be included in the sync
454-
// based on the configured platforms or architectures
454+
// based on the configured platforms
455455
func (service *BaseService) shouldIncludePlatform(platform *ispec.Platform) bool {
456456
// Get platform specifications from the configuration
457457
var platformSpecs []string
458458

459459
// Check if we have platform specifications
460460
if len(service.config.Platforms) > 0 {
461461
platformSpecs = service.config.Platforms
462-
} else if len(service.config.Architectures) > 0 {
463-
// Fall back to architectures for backward compatibility
464-
platformSpecs = service.config.Architectures
465462
} else {
466-
// If no platforms or architectures are configured, include all
463+
// If no platforms are configured, include all
467464
return true
468465
}
469466

@@ -503,30 +500,15 @@ func (service *BaseService) shouldIncludePlatform(platform *ispec.Platform) bool
503500
}
504501

505502
// shouldIncludeArchitecture determines if an architecture should be included in the sync
506-
// based on the configured architectures (if any)
507503
// DEPRECATED: Use shouldIncludePlatform instead
508504
func (service *BaseService) shouldIncludeArchitecture(arch string) bool {
509-
// If no architectures are configured, include all architectures
510-
if len(service.config.Architectures) > 0 && len(service.config.Platforms) == 0 {
511-
// Check if the architecture is in the configured list
512-
for _, configArch := range service.config.Architectures {
513-
if configArch == arch {
514-
return true
515-
}
516-
}
517-
return false
518-
}
519-
520-
// When using the Platforms field, we need a different check
521-
if len(service.config.Platforms) > 0 {
522-
platform := &ispec.Platform{
523-
Architecture: arch,
524-
}
525-
return service.shouldIncludePlatform(platform)
505+
// Create a platform with just the architecture field
506+
platform := &ispec.Platform{
507+
Architecture: arch,
526508
}
527509

528-
// No filters configured, include all
529-
return true
510+
// Use the platform-based filtering method
511+
return service.shouldIncludePlatform(platform)
530512
}
531513

532514
func (service *BaseService) syncRef(ctx context.Context, localRepo string, remoteImageRef, localImageRef ref.Ref,
@@ -558,11 +540,6 @@ func (service *BaseService) syncRef(ctx context.Context, localRepo string, remot
558540
Strs("platforms", service.config.Platforms).
559541
Str("image", remoteImageRef.CommonName()).
560542
Msg("filtering platforms during sync")
561-
} else if len(service.config.Architectures) > 0 {
562-
service.log.Info().
563-
Strs("architectures", service.config.Architectures).
564-
Str("image", remoteImageRef.CommonName()).
565-
Msg("filtering architectures during sync (deprecated)")
566543
}
567544

568545
// check if image is already synced
@@ -577,8 +554,8 @@ func (service *BaseService) syncRef(ctx context.Context, localRepo string, remot
577554
service.log.Info().Str("remote image", remoteImageRef.CommonName()).
578555
Str("local image", fmt.Sprintf("%s:%s", localRepo, remoteImageRef.Tag)).Msg("syncing image")
579556

580-
// When architectures are specified, we need to filter the manifest list
581-
if len(service.config.Architectures) > 0 {
557+
// When platforms are specified, we need to filter the manifest list
558+
if len(service.config.Platforms) > 0 {
582559
// Get the manifest to check if it's a manifest list
583560
man, err := service.rc.ManifestGet(ctx, remoteImageRef)
584561
if err != nil {
@@ -593,7 +570,7 @@ func (service *BaseService) syncRef(ctx context.Context, localRepo string, remot
593570
if isIndexer {
594571
service.log.Info().
595572
Str("remote image", remoteImageRef.CommonName()).
596-
Msg("filtering architectures for multi-arch image")
573+
Msg("filtering platforms for multi-arch image")
597574

598575
// Use ImageCopy with the architecture filtering options
599576
err = service.rc.ImageCopy(ctx, remoteImageRef, localImageRef, copyOpts...)

0 commit comments

Comments
 (0)