|
| 1 | +package image |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/spf13/cobra" |
| 5 | + |
| 6 | + "github.com/konflux-ci/konflux-build-cli/pkg/commands" |
| 7 | + "github.com/konflux-ci/konflux-build-cli/pkg/common" |
| 8 | + l "github.com/konflux-ci/konflux-build-cli/pkg/logger" |
| 9 | +) |
| 10 | + |
| 11 | +var BuildImageIndexCmd = &cobra.Command{ |
| 12 | + Use: "build-image-index", |
| 13 | + Short: "Build a multi-architecture image index", |
| 14 | + Long: `Build a multi-architecture image index (manifest list) from multiple platform-specific images. |
| 15 | +
|
| 16 | +This command combines multiple container images into a single image index, enabling |
| 17 | +multi-platform container image support. |
| 18 | +
|
| 19 | +Examples: |
| 20 | + # Build an image index from multiple platform images |
| 21 | + konflux-build-cli image build-image-index \ |
| 22 | + --image quay.io/myorg/myapp:latest \ |
| 23 | + --images quay.io/myorg/myapp@sha256:amd64digest... quay.io/myorg/myapp@sha256:arm64digest... |
| 24 | +
|
| 25 | + # Build and push to additional tags (e.g., TaskRun name, commit SHA) |
| 26 | + konflux-build-cli image build-image-index \ |
| 27 | + --image quay.io/myorg/myapp:latest \ |
| 28 | + --images quay.io/myorg/myapp@sha256:amd64digest... quay.io/myorg/myapp@sha256:arm64digest... \ |
| 29 | + --additional-tags taskrun-xyz-12345 commit-abc123 |
| 30 | +
|
| 31 | + # Write results to files (useful for Tekton tasks) |
| 32 | + konflux-build-cli image build-image-index \ |
| 33 | + --image quay.io/myorg/myapp:latest \ |
| 34 | + --images quay.io/myorg/myapp@sha256:amd64digest... quay.io/myorg/myapp@sha256:arm64digest... \ |
| 35 | + --result-path-image-digest /tekton/results/IMAGE_DIGEST \ |
| 36 | + --result-path-image-url /tekton/results/IMAGE_URL \ |
| 37 | + --result-path-image-ref /tekton/results/IMAGE_REF \ |
| 38 | + --result-path-images /tekton/results/IMAGES |
| 39 | +`, |
| 40 | + Run: func(cmd *cobra.Command, args []string) { |
| 41 | + l.Logger.Debug("Starting build-image-index") |
| 42 | + buildImageIndex, err := commands.NewBuildImageIndex(cmd) |
| 43 | + if err != nil { |
| 44 | + l.Logger.Fatal(err) |
| 45 | + } |
| 46 | + if err := buildImageIndex.Run(); err != nil { |
| 47 | + l.Logger.Fatal(err) |
| 48 | + } |
| 49 | + l.Logger.Debug("Finished build-image-index") |
| 50 | + }, |
| 51 | +} |
| 52 | + |
| 53 | +func init() { |
| 54 | + common.RegisterParameters(BuildImageIndexCmd, commands.BuildImageIndexParamsConfig) |
| 55 | +} |
0 commit comments