Skip to content

Commit

Permalink
Remove unused pull secret configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Mikalai Radchuk <[email protected]>
  • Loading branch information
Mikalai Radchuk committed Aug 28, 2024
1 parent 1c6a839 commit 4803465
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 41 deletions.
4 changes: 1 addition & 3 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ func main() {
os.Exit(1)
}
unpacker := &source.ImageRegistry{
BaseCachePath: filepath.Join(cachePath, "unpack"),
// TODO: This needs to be derived per extension via ext.Spec.InstallNamespace
AuthNamespace: systemNamespace,
BaseCachePath: filepath.Join(cachePath, "unpack"),
CertPoolWatcher: certPoolWatcher,
}

Expand Down
26 changes: 2 additions & 24 deletions internal/rukpak/source/image_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"strings"

"github.com/containerd/containerd/archive"
"github.com/google/go-containerregistry/pkg/authn/k8schain"
gcrkube "github.com/google/go-containerregistry/pkg/authn/kubernetes"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
apimacherrors "k8s.io/apimachinery/pkg/util/errors"
Expand All @@ -29,8 +27,6 @@ const SourceTypeImage SourceType = "image"
type ImageSource struct {
// Ref contains the reference to a container image containing Bundle contents.
Ref string
// ImagePullSecretName contains the name of the image pull secret in the namespace that the provisioner is deployed.
ImagePullSecretName string
// InsecureSkipTLSVerify indicates that TLS certificate validation should be skipped.
// If this option is specified, the HTTPS protocol will still be used to
// fetch the specified image reference.
Expand All @@ -53,7 +49,6 @@ func NewUnrecoverable(err error) *Unrecoverable {

type ImageRegistry struct {
BaseCachePath string
AuthNamespace string
CertPoolWatcher *httputil.CertPoolWatcher
}

Expand All @@ -72,24 +67,6 @@ func (i *ImageRegistry) Unpack(ctx context.Context, bundle *BundleSource) (*Resu
return nil, NewUnrecoverable(fmt.Errorf("error parsing image reference: %w", err))
}

remoteOpts := []remote.Option{}
if bundle.Image.ImagePullSecretName != "" {
chainOpts := k8schain.Options{
ImagePullSecrets: []string{bundle.Image.ImagePullSecretName},
Namespace: i.AuthNamespace,
// TODO: Do we want to use any secrets that are included in the rukpak service account?
// If so, we will need to add the permission to get service accounts and specify
// the rukpak service account name here.
ServiceAccountName: gcrkube.NoServiceAccount,
}
authChain, err := k8schain.NewInCluster(ctx, chainOpts)
if err != nil {
return nil, fmt.Errorf("error getting auth keychain: %w", err)
}

remoteOpts = append(remoteOpts, remote.WithAuthFromKeychain(authChain))
}

transport := remote.DefaultTransport.(*http.Transport).Clone()
if transport.TLSClientConfig == nil {
transport.TLSClientConfig = &tls.Config{
Expand All @@ -107,6 +84,8 @@ func (i *ImageRegistry) Unpack(ctx context.Context, bundle *BundleSource) (*Resu
}
transport.TLSClientConfig.RootCAs = pool
}

remoteOpts := []remote.Option{}
remoteOpts = append(remoteOpts, remote.WithTransport(transport))

digest, isDigest := imgRef.(name.Digest)
Expand Down Expand Up @@ -175,7 +154,6 @@ func unpackedResult(fsys fs.FS, bundle *BundleSource, ref string) *Result {
Type: SourceTypeImage,
Image: &ImageSource{
Ref: ref,
ImagePullSecretName: bundle.Image.ImagePullSecretName,
InsecureSkipTLSVerify: bundle.Image.InsecureSkipTLSVerify,
},
},
Expand Down
14 changes: 0 additions & 14 deletions internal/rukpak/source/unpacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"fmt"
"io/fs"

"sigs.k8s.io/controller-runtime/pkg/manager"
)

// Unpacker unpacks bundle content, either synchronously or asynchronously and
Expand Down Expand Up @@ -102,15 +100,3 @@ func (s *unpacker) Cleanup(ctx context.Context, bundle *BundleSource) error {
}
return source.Cleanup(ctx, bundle)
}

// NewDefaultUnpacker returns a new composite Source that unpacks bundles using
// a default source mapping with built-in implementations of all of the supported
// source types.
func NewDefaultUnpacker(mgr manager.Manager, namespace, cacheDir string) (Unpacker, error) {
return NewUnpacker(map[SourceType]Unpacker{
SourceTypeImage: &ImageRegistry{
BaseCachePath: cacheDir,
AuthNamespace: namespace,
},
}), nil
}

0 comments on commit 4803465

Please sign in to comment.