Skip to content

Commit

Permalink
oci/client: drop custom platfrom from default client options
Browse files Browse the repository at this point in the history
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 <errordeveloper@gmail.com>
  • Loading branch information
errordeveloper committed Sep 26, 2023
1 parent 575eb33 commit cfe218b
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions oci/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down

0 comments on commit cfe218b

Please sign in to comment.