Skip to content

Commit 5123f59

Browse files
authored
Upgrade imgpkg version and authn/kubernetes/keychain (#25)
* chore: Upgrade imgpkg version and authn/kubernetes/keychain * chore: Upgrade imgpkg version v0.36.0 Signed-off-by: Rashed Kamal <[email protected]>
1 parent 9adbfd0 commit 5123f59

File tree

6 files changed

+135
-813
lines changed

6 files changed

+135
-813
lines changed

controllers/imagerepository_controller.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ import (
3131
"path/filepath"
3232
"strings"
3333

34-
"github.com/cppforlife/go-cli-ui/ui"
3534
"github.com/go-logr/logr"
36-
"github.com/google/go-containerregistry/pkg/authn/k8schain"
35+
"github.com/google/go-containerregistry/pkg/authn/kubernetes"
3736
"github.com/google/go-containerregistry/pkg/name"
3837
"github.com/google/go-containerregistry/pkg/v1/remote"
3938
"github.com/vmware-labs/reconciler-runtime/apis"
@@ -172,7 +171,7 @@ func ImageRepositoryImageDigestSyncReconciler() reconcilers.SubReconciler {
172171
if pullSecrets == nil {
173172
return nil
174173
}
175-
keychain, err := k8schain.NewFromPullSecrets(ctx, pullSecrets)
174+
keychain, err := kubernetes.NewFromPullSecrets(ctx, pullSecrets)
176175
if err != nil {
177176
return err
178177
}
@@ -245,22 +244,20 @@ func ImageRepositoryPullImageSyncReconciler(httpRootDir, httpHost string, now fu
245244
if pullSecrets == nil {
246245
return nil
247246
}
248-
keychain, err := k8schain.NewFromPullSecrets(ctx, pullSecrets)
247+
keychain, err := kubernetes.NewFromPullSecrets(ctx, pullSecrets)
249248
if err != nil {
250249
return err
251250
}
252-
253-
reg, err := registry.NewSimpleRegistry(
254-
// TODO support more registry options
255-
registry.Opts{VerifyCerts: true},
251+
reg, err := registry.NewBasicRegistry(
256252
remote.WithContext(ctx),
257253
remote.WithAuthFromKeychain(keychain),
258254
remote.WithTransport(RetrieveHttpRoundTripper(ctx)),
259255
)
256+
260257
if err != nil {
261258
return err
262259
}
263-
if err := plainimage.NewPlainImage(imageRef, reg).Pull(artifactDir, ui.NewNoopUI()); err != nil {
260+
if err := plainimage.NewPlainImage(imageRef, reg).Pull(artifactDir, NewNoopLogger()); err != nil {
264261
// TODO distinguish forbidden and not found errors
265262
log.Error(err, "unable to pull imgpkg image", "image", imageRef)
266263
parent.ManageConditions().MarkFalse(sourcev1alpha1.ImageRepositoryConditionImageResolved, "RemoteError", "unable to pull image %q: %s", parent.Spec.Image, err)

controllers/imagerepository_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestImageRepositoryReconciler(t *testing.T) {
5959

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

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

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

898898
var pullsecrets = []corev1.Secret{}

controllers/internal.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"net/http"
88
"strings"
99

10+
"github.com/vmware-tanzu/carvel-imgpkg/pkg/imgpkg/plainimage"
11+
1012
sourcev1alpha1 "github.com/vmware-tanzu/tanzu-source-controller/apis/source/v1alpha1"
1113
)
1214

@@ -180,3 +182,18 @@ func (r *MavenResolver) processReleaseVersion(ctx context.Context, client *http.
180182
r.DownloadURL = fmt.Sprintf("%s/%s/%s/%s", r.RepositoryURL, r.RequestPath, r.ResolvedVersion, r.ResolvedFilename)
181183
return nil
182184
}
185+
186+
// imgpkg logger
187+
188+
var _ plainimage.Logger = &NoopLogger{}
189+
190+
// NewNoopLogger creates a new noop logger
191+
func NewNoopLogger() *NoopLogger {
192+
return &NoopLogger{}
193+
}
194+
195+
// NoopLogger this logger will not print
196+
type NoopLogger struct{}
197+
198+
// Logf does nothing
199+
func (n NoopLogger) Logf(string, ...interface{}) {}

go.mod

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ go 1.19
44

55
require (
66
dies.dev v0.7.0
7-
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14
87
github.com/go-logr/logr v1.2.3
98
github.com/google/go-cmp v0.5.9
109
github.com/google/go-containerregistry v0.13.0
11-
github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20220105220605-d9bfbcb99e52
10+
github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20230209165335-3624968304fd
1211
github.com/vmware-labs/reconciler-runtime v0.11.0
13-
github.com/vmware-tanzu/carvel-imgpkg v0.25.0
12+
github.com/vmware-tanzu/carvel-imgpkg v0.36.0
1413
go.uber.org/zap v1.24.0
1514
k8s.io/api v0.26.1
1615
k8s.io/apimachinery v0.26.1
@@ -19,23 +18,39 @@ require (
1918
)
2019

2120
require (
21+
cloud.google.com/go/compute v1.14.0 // indirect
22+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
2223
github.com/Azure/azure-sdk-for-go v55.0.0+incompatible // indirect
2324
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
2425
github.com/Azure/go-autorest/autorest v0.11.27 // indirect
2526
github.com/Azure/go-autorest/autorest/adal v0.9.20 // indirect
27+
github.com/Azure/go-autorest/autorest/azure/auth v0.5.2 // indirect
28+
github.com/Azure/go-autorest/autorest/azure/cli v0.4.1 // indirect
2629
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
27-
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
28-
github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect
2930
github.com/Azure/go-autorest/logger v0.2.1 // indirect
3031
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
3132
github.com/VividCortex/ewma v1.1.1 // indirect
32-
github.com/aws/aws-sdk-go v1.39.4 // indirect
33+
github.com/aws/aws-sdk-go-v2 v1.7.1 // indirect
34+
github.com/aws/aws-sdk-go-v2/config v1.5.0 // indirect
35+
github.com/aws/aws-sdk-go-v2/credentials v1.3.1 // indirect
36+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.3.0 // indirect
37+
github.com/aws/aws-sdk-go-v2/internal/ini v1.1.1 // indirect
38+
github.com/aws/aws-sdk-go-v2/service/ecr v1.4.1 // indirect
39+
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.4.1 // indirect
40+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.2.1 // indirect
41+
github.com/aws/aws-sdk-go-v2/service/sso v1.3.1 // indirect
42+
github.com/aws/aws-sdk-go-v2/service/sts v1.6.0 // indirect
43+
github.com/aws/smithy-go v1.6.0 // indirect
44+
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20220517224237-e6f29200ae04 // indirect
3345
github.com/beorn7/perks v1.0.1 // indirect
3446
github.com/cespare/xxhash/v2 v2.1.2 // indirect
35-
github.com/cheggaaa/pb/v3 v3.0.8 // indirect
47+
github.com/cheggaaa/pb/v3 v3.1.0 // indirect
48+
github.com/chrismellard/docker-credential-acr-env v0.0.0-20220327082430-c57b701bfc08 // indirect
3649
github.com/containerd/stargz-snapshotter/estargz v0.12.1 // indirect
3750
github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835 // indirect
51+
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14 // indirect
3852
github.com/davecgh/go-spew v1.1.1 // indirect
53+
github.com/dimchansky/utfbom v1.1.0 // indirect
3954
github.com/docker/cli v20.10.20+incompatible // indirect
4055
github.com/docker/distribution v2.8.1+incompatible // indirect
4156
github.com/docker/docker v20.10.20+incompatible // indirect
@@ -48,28 +63,30 @@ require (
4863
github.com/go-logr/zapr v1.2.3 // indirect
4964
github.com/go-openapi/jsonpointer v0.19.5 // indirect
5065
github.com/go-openapi/jsonreference v0.20.0 // indirect
51-
github.com/go-openapi/swag v0.19.14 // indirect
66+
github.com/go-openapi/swag v0.22.3 // indirect
5267
github.com/gogo/protobuf v1.3.2 // indirect
5368
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
5469
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5570
github.com/golang/protobuf v1.5.2 // indirect
56-
github.com/google/gnostic v0.5.7-v3refs // indirect
71+
github.com/google/gnostic v0.6.9 // indirect
5772
github.com/google/gofuzz v1.2.0 // indirect
5873
github.com/google/uuid v1.3.0 // indirect
5974
github.com/imdario/mergo v0.3.12 // indirect
6075
github.com/jmespath/go-jmespath v0.4.0 // indirect
6176
github.com/josharian/intern v1.0.0 // indirect
6277
github.com/json-iterator/go v1.1.12 // indirect
6378
github.com/klauspost/compress v1.15.11 // indirect
64-
github.com/mailru/easyjson v0.7.6 // indirect
79+
github.com/kr/pretty v0.2.1 // indirect
80+
github.com/mailru/easyjson v0.7.7 // indirect
6581
github.com/mattn/go-colorable v0.1.12 // indirect
66-
github.com/mattn/go-isatty v0.0.14 // indirect
82+
github.com/mattn/go-isatty v0.0.17 // indirect
6783
github.com/mattn/go-runewidth v0.0.12 // indirect
6884
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
6985
github.com/mitchellh/go-homedir v1.1.0 // indirect
7086
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
7187
github.com/modern-go/reflect2 v1.0.2 // indirect
7288
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
89+
github.com/onsi/ginkgo v1.14.0 // indirect
7390
github.com/opencontainers/go-digest v1.0.0 // indirect
7491
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
7592
github.com/pkg/errors v0.9.1 // indirect
@@ -81,17 +98,16 @@ require (
8198
github.com/sirupsen/logrus v1.9.0 // indirect
8299
github.com/spf13/pflag v1.0.5 // indirect
83100
github.com/vbatts/tar-split v0.11.2 // indirect
84-
github.com/vdemeester/k8s-pkg-credentialprovider v1.22.4 // indirect
85101
github.com/vito/go-interact v1.0.1 // indirect
86102
go.uber.org/atomic v1.7.0 // indirect
87103
go.uber.org/multierr v1.6.0 // indirect
88104
golang.org/x/crypto v0.1.0 // indirect
89-
golang.org/x/net v0.3.1-0.20221206200815-1e63c2f08a10 // indirect
105+
golang.org/x/net v0.5.0 // indirect
90106
golang.org/x/oauth2 v0.1.0 // indirect
91107
golang.org/x/sync v0.1.0 // indirect
92-
golang.org/x/sys v0.3.0 // indirect
93-
golang.org/x/term v0.3.0 // indirect
94-
golang.org/x/text v0.5.0 // indirect
108+
golang.org/x/sys v0.4.0 // indirect
109+
golang.org/x/term v0.4.0 // indirect
110+
golang.org/x/text v0.6.0 // indirect
95111
golang.org/x/time v0.3.0 // indirect
96112
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
97113
gomodules.xyz/jsonpatch/v3 v3.0.1 // indirect
@@ -102,11 +118,9 @@ require (
102118
gopkg.in/yaml.v2 v2.4.0 // indirect
103119
gopkg.in/yaml.v3 v3.0.1 // indirect
104120
k8s.io/apiextensions-apiserver v0.26.1 // indirect
105-
k8s.io/cloud-provider v0.22.4 // indirect
106121
k8s.io/component-base v0.26.1 // indirect
107122
k8s.io/klog/v2 v2.80.1 // indirect
108123
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
109-
k8s.io/legacy-cloud-providers v0.22.4 // indirect
110124
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
111125
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
112126
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect

0 commit comments

Comments
 (0)