Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove image-syncer amd64Only flag #12417

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions cmd/image-syncer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Contents:

## Overview

Image-syncer is used to copy container images between two registries.
Image-syncer is used to copy container images between two registries. Sync the whole index if possible. Otherwise, sync a single image.
It copies images **only when they are not present** in the target repository.
The tool guarantees that **tags are immutable** in the target repository.
That means that if the image tag is already present in the target registry, it is not overwritten by the new image.
Expand Down Expand Up @@ -94,8 +94,6 @@ As an input parameter, image-syncer takes a file having the following structure:

- **source**: The source image to be copied. It can be an image name with a tag or a digest.
- **tag**: The tag of the image in the target repository, which is required when the source uses digest to identify the image.
- **amd64Only**: A boolean value that indicates if it's allowed to synchronize the image manifest instead of the image index.
This is required when the source image is not a multi-platform image.

```yaml
images:
Expand All @@ -104,10 +102,8 @@ images:
- source: "busybox@sha256:31a54a0cf86d7354788a8265f60ae6acb4b348a67efbcf7c1007dd3cf7af05ab"
tag: "1.32.0-v1"
- source: "bitnami/postgres-exporter:0.11.1-debian-11-r69"
amd64Only: true
- source: "postgres@sha256:9d7ec48fe46e8bbce55deafff58080e49d161a3ed92e67f645014bb50dc599fd"
tag: "v20230508-11.19-alpine3.17"
amd64Only: true
```

## Developer Guide
Expand All @@ -124,10 +120,6 @@ The image-syncer binary is responsible for synchronizing images between two regi
The binary is released as a container image.
See the [Dockerfile](https://github.com/kyma-project/test-infra/blob/main/cmd/image-syncer/Dockerfile) for the image-syncer binary.

> [!WARNING]
> The **amd64Only** field in the images list file allows syncing the image manifest instead of the image index.
> The flag does not prevent syncing other platforms.

#### Flags

The image-syncer binary accepts flags to configure the synchronization process.
Expand Down
26 changes: 10 additions & 16 deletions cmd/image-syncer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,17 @@ func SyncImages(ctx context.Context, cfg *Config, images *imagesync.SyncDef, aut
return err
}
log.WithField("image", img.Source).Info("Start sync")
if img.AMD64Only {
// sync whole index if possible, otherwise sync singular image
// we force users to set explicit info about single-arch images
var isIndex bool
isIndex, err = isImageIndex(ctx, img.Source)
if err != nil {
return err
}
if isIndex {
_, err = SyncIndex(ctx, img.Source, target, cfg.DryRun, auth)
} else {
imageType = "Image"
_, err = SyncImage(ctx, img.Source, target, cfg.DryRun, auth)
}
} else {
// sync whole index
// Sync the whole index if possible. Otherwise, sync a single image.
var isIndex bool
isIndex, err = isImageIndex(ctx, img.Source)
if err != nil {
return err
}
if isIndex {
_, err = SyncIndex(ctx, img.Source, target, cfg.DryRun, auth)
} else {
imageType = "Image"
_, err = SyncImage(ctx, img.Source, target, cfg.DryRun, auth)
}
if err != nil {
return err
Expand Down
5 changes: 2 additions & 3 deletions pkg/imagesync/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ type SyncDef struct {

// Image stores image location
type Image struct {
Source string
Tag string `yaml:"tag,omitempty"`
AMD64Only bool `yaml:"amd64Only,omitempty"`
Source string
Tag string `yaml:"tag,omitempty"`
}
Loading