Skip to content

Commit

Permalink
Upgrade imgpkg version and authn/kubernetes/keychain (#25)
Browse files Browse the repository at this point in the history
* chore: Upgrade imgpkg version and authn/kubernetes/keychain
* chore: Upgrade imgpkg version v0.36.0

Signed-off-by: Rashed Kamal <krashed@vmware.com>
  • Loading branch information
rashedkvm authored Feb 16, 2023
1 parent 9adbfd0 commit 5123f59
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 813 deletions.
15 changes: 6 additions & 9 deletions controllers/imagerepository_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ import (
"path/filepath"
"strings"

"github.com/cppforlife/go-cli-ui/ui"
"github.com/go-logr/logr"
"github.com/google/go-containerregistry/pkg/authn/k8schain"
"github.com/google/go-containerregistry/pkg/authn/kubernetes"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/vmware-labs/reconciler-runtime/apis"
Expand Down Expand Up @@ -172,7 +171,7 @@ func ImageRepositoryImageDigestSyncReconciler() reconcilers.SubReconciler {
if pullSecrets == nil {
return nil
}
keychain, err := k8schain.NewFromPullSecrets(ctx, pullSecrets)
keychain, err := kubernetes.NewFromPullSecrets(ctx, pullSecrets)
if err != nil {
return err
}
Expand Down Expand Up @@ -245,22 +244,20 @@ func ImageRepositoryPullImageSyncReconciler(httpRootDir, httpHost string, now fu
if pullSecrets == nil {
return nil
}
keychain, err := k8schain.NewFromPullSecrets(ctx, pullSecrets)
keychain, err := kubernetes.NewFromPullSecrets(ctx, pullSecrets)
if err != nil {
return err
}

reg, err := registry.NewSimpleRegistry(
// TODO support more registry options
registry.Opts{VerifyCerts: true},
reg, err := registry.NewBasicRegistry(
remote.WithContext(ctx),
remote.WithAuthFromKeychain(keychain),
remote.WithTransport(RetrieveHttpRoundTripper(ctx)),
)

if err != nil {
return err
}
if err := plainimage.NewPlainImage(imageRef, reg).Pull(artifactDir, ui.NewNoopUI()); err != nil {
if err := plainimage.NewPlainImage(imageRef, reg).Pull(artifactDir, NewNoopLogger()); err != nil {
// TODO distinguish forbidden and not found errors
log.Error(err, "unable to pull imgpkg image", "image", imageRef)
parent.ManageConditions().MarkFalse(sourcev1alpha1.ImageRepositoryConditionImageResolved, "RemoteError", "unable to pull image %q: %s", parent.Spec.Image, err)
Expand Down
6 changes: 3 additions & 3 deletions controllers/imagerepository_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestImageRepositoryReconciler(t *testing.T) {

helloImage := fmt.Sprintf("%s/%s", registryHost, "hello")
helloDigest := "66201d7a2285b74eef3221c5f548ebcaba03f9891eef305be94f4d51c661d933"
helloChecksum := "d0ab7a6a9af1c8d60aa7d0fc1392853c9b7ccade"
helloChecksum := "00a04fda65d6d2c7924a2729b8369efbe3f4e978"
utilruntime.Must(btesting.LoadImage(registry, "fixtures/hello.tar", helloImage))

artifactRootDir, err := ioutil.TempDir(os.TempDir(), "artifacts.*")
Expand Down Expand Up @@ -668,7 +668,7 @@ func TestImageRepositoryPullImageSyncReconciler(t *testing.T) {
helloImage := fmt.Sprintf("%s/%s", registryHost, "hello")
utilruntime.Must(btesting.LoadImage(registry, "fixtures/hello.tar", helloImage))
helloDigest := "66201d7a2285b74eef3221c5f548ebcaba03f9891eef305be94f4d51c661d933"
helloChecksum := "d0ab7a6a9af1c8d60aa7d0fc1392853c9b7ccade"
helloChecksum := "00a04fda65d6d2c7924a2729b8369efbe3f4e978"
image := fmt.Sprintf("%s@sha256:%s", helloImage, helloDigest)

artifactRootDir, err := ioutil.TempDir(os.TempDir(), "artifacts.*")
Expand Down Expand Up @@ -892,7 +892,7 @@ func TestImageRepositoryPullImageSyncReconcilerWithAuth(t *testing.T) {
helloImage := fmt.Sprintf("%s/%s", registryHost, "hello")
utilruntime.Must(btesting.LoadImageWithAuth(registry, "fixtures/hello.tar", helloImage, reg_user, reg_pwd))
helloDigest := "66201d7a2285b74eef3221c5f548ebcaba03f9891eef305be94f4d51c661d933"
helloChecksum := "d0ab7a6a9af1c8d60aa7d0fc1392853c9b7ccade"
helloChecksum := "00a04fda65d6d2c7924a2729b8369efbe3f4e978"
image := fmt.Sprintf("%s@sha256:%s", helloImage, helloDigest)

var pullsecrets = []corev1.Secret{}
Expand Down
17 changes: 17 additions & 0 deletions controllers/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"net/http"
"strings"

"github.com/vmware-tanzu/carvel-imgpkg/pkg/imgpkg/plainimage"

sourcev1alpha1 "github.com/vmware-tanzu/tanzu-source-controller/apis/source/v1alpha1"
)

Expand Down Expand Up @@ -180,3 +182,18 @@ func (r *MavenResolver) processReleaseVersion(ctx context.Context, client *http.
r.DownloadURL = fmt.Sprintf("%s/%s/%s/%s", r.RepositoryURL, r.RequestPath, r.ResolvedVersion, r.ResolvedFilename)
return nil
}

// imgpkg logger

var _ plainimage.Logger = &NoopLogger{}

// NewNoopLogger creates a new noop logger
func NewNoopLogger() *NoopLogger {
return &NoopLogger{}
}

// NoopLogger this logger will not print
type NoopLogger struct{}

// Logf does nothing
func (n NoopLogger) Logf(string, ...interface{}) {}
50 changes: 32 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ go 1.19

require (
dies.dev v0.7.0
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14
github.com/go-logr/logr v1.2.3
github.com/google/go-cmp v0.5.9
github.com/google/go-containerregistry v0.13.0
github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20220105220605-d9bfbcb99e52
github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20230209165335-3624968304fd
github.com/vmware-labs/reconciler-runtime v0.11.0
github.com/vmware-tanzu/carvel-imgpkg v0.25.0
github.com/vmware-tanzu/carvel-imgpkg v0.36.0
go.uber.org/zap v1.24.0
k8s.io/api v0.26.1
k8s.io/apimachinery v0.26.1
Expand All @@ -19,23 +18,39 @@ require (
)

require (
cloud.google.com/go/compute v1.14.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/Azure/azure-sdk-for-go v55.0.0+incompatible // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
github.com/Azure/go-autorest/autorest/azure/auth v0.5.2 // indirect
github.com/Azure/go-autorest/autorest/azure/cli v0.4.1 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/VividCortex/ewma v1.1.1 // indirect
github.com/aws/aws-sdk-go v1.39.4 // indirect
github.com/aws/aws-sdk-go-v2 v1.7.1 // indirect
github.com/aws/aws-sdk-go-v2/config v1.5.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.3.1 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.3.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.1.1 // indirect
github.com/aws/aws-sdk-go-v2/service/ecr v1.4.1 // indirect
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.4.1 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.2.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.3.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.6.0 // indirect
github.com/aws/smithy-go v1.6.0 // indirect
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220517224237-e6f29200ae04 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cheggaaa/pb/v3 v3.0.8 // indirect
github.com/cheggaaa/pb/v3 v3.1.0 // indirect
github.com/chrismellard/docker-credential-acr-env v0.0.0-20220327082430-c57b701bfc08 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.12.1 // indirect
github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835 // indirect
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.0 // indirect
github.com/docker/cli v20.10.20+incompatible // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.20+incompatible // indirect
Expand All @@ -48,28 +63,30 @@ require (
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo v1.14.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -81,17 +98,16 @@ require (
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
github.com/vdemeester/k8s-pkg-credentialprovider v1.22.4 // indirect
github.com/vito/go-interact v1.0.1 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/net v0.3.1-0.20221206200815-1e63c2f08a10 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/oauth2 v0.1.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/term v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/term v0.4.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/jsonpatch/v3 v3.0.1 // indirect
Expand All @@ -102,11 +118,9 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/cloud-provider v0.22.4 // indirect
k8s.io/component-base v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/legacy-cloud-providers v0.22.4 // indirect
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
Expand Down
Loading

0 comments on commit 5123f59

Please sign in to comment.