From cfe218b77ac38ba2732771eaea8b662eeb2dfa86 Mon Sep 17 00:00:00 2001 From: Ilya Dmitrichenko Date: Fri, 22 Sep 2023 10:17:51 +0100 Subject: [PATCH] oci/client: drop custom platfrom from default client options In OCI terms having platform `flux/flux/v2` implies that the image is runnable on some OS called "flux" on architecture called "flux". In reality there is no such platform and there is no good reason for Flux to pretend. OCI 1.1 (albeit still and RC at the moment), doesn't mandate artifact to define a platform at all. When client is constructed with a platform selector, many functions will apply the selector, which is often undesirable. The `flux/flux/v2` platform was only defined in client options, so it wasn't set on any images and is safe to drop; source-controller doesn't use `DefaultOptions`, so there is no concern. Another inconvenient behaviour of GGCR is that some functions will pick just the very first element that matches the platform and ignore any additional elements, e.g. elements with same platform, but different media type. That behaviour prevents searching for artefacts by media type. Signed-off-by: Ilya Dmitrichenko --- oci/client/client.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/oci/client/client.go b/oci/client/client.go index b5c5d6cc8..b3cd257a0 100644 --- a/oci/client/client.go +++ b/oci/client/client.go @@ -20,7 +20,6 @@ import ( "context" "github.com/google/go-containerregistry/pkg/crane" - gcrv1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/fluxcd/pkg/oci" @@ -41,16 +40,9 @@ func NewClient(opts []crane.Option) *Client { return &Client{options: options} } -// DefaultOptions returns an array containing crane.WithPlatform -// to set the platform to flux. +// DefaultOptions returns an empty list of client options. func DefaultOptions() []crane.Option { - return []crane.Option{ - crane.WithPlatform(&gcrv1.Platform{ - Architecture: "flux", - OS: "flux", - OSVersion: "v2", - }), - } + return []crane.Option{} } // GetOptions returns the list of crane.Option used by this Client.