Skip to content

Commit

Permalink
Update GGCR to K8s 1.18 libs (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmoor committed Sep 10, 2020
1 parent 2a19315 commit d42b6a2
Show file tree
Hide file tree
Showing 979 changed files with 85,907 additions and 115,021 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ language:
- go

go:
- "1.13"
- "1.14"
- "1.15"

env:
- "GO111MODULE=off"
Expand Down
23 changes: 17 additions & 6 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 43 additions & 40 deletions go.sum

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions pkg/authn/k8schain/k8schain.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package k8schain

import (
"context"
"fmt"
"sync"

Expand Down Expand Up @@ -49,7 +50,7 @@ var (
// New returns a new authn.Keychain suitable for resolving image references as
// scoped by the provided Options. It speaks to Kubernetes through the provided
// client interface.
func New(client kubernetes.Interface, opt Options) (authn.Keychain, error) {
func New(ctx context.Context, client kubernetes.Interface, opt Options) (authn.Keychain, error) {
if opt.Namespace == "" {
opt.Namespace = "default"
}
Expand All @@ -68,20 +69,20 @@ func New(client kubernetes.Interface, opt Options) (authn.Keychain, error) {
var pullSecrets []v1.Secret
if client != nil {
for _, name := range opt.ImagePullSecrets {
ps, err := client.CoreV1().Secrets(opt.Namespace).Get(name, metav1.GetOptions{})
ps, err := client.CoreV1().Secrets(opt.Namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return nil, err
}
pullSecrets = append(pullSecrets, *ps)
}

// Second, fetch all of the pull secrets attached to our service account.
sa, err := client.CoreV1().ServiceAccounts(opt.Namespace).Get(opt.ServiceAccountName, metav1.GetOptions{})
sa, err := client.CoreV1().ServiceAccounts(opt.Namespace).Get(ctx, opt.ServiceAccountName, metav1.GetOptions{})
if err != nil {
return nil, err
}
for _, localObj := range sa.ImagePullSecrets {
ps, err := client.CoreV1().Secrets(opt.Namespace).Get(localObj.Name, metav1.GetOptions{})
ps, err := client.CoreV1().Secrets(opt.Namespace).Get(ctx, localObj.Name, metav1.GetOptions{})
if err != nil {
return nil, err
}
Expand All @@ -106,7 +107,7 @@ func New(client kubernetes.Interface, opt Options) (authn.Keychain, error) {
// NewInCluster returns a new authn.Keychain suitable for resolving image references as
// scoped by the provided Options, constructing a kubernetes.Interface based on in-cluster
// authentication.
func NewInCluster(opt Options) (authn.Keychain, error) {
func NewInCluster(ctx context.Context, opt Options) (authn.Keychain, error) {
clusterConfig, err := rest.InClusterConfig()
if err != nil {
return nil, err
Expand All @@ -116,7 +117,7 @@ func NewInCluster(opt Options) (authn.Keychain, error) {
if err != nil {
return nil, err
}
return New(client, opt)
return New(ctx, client, opt)
}

// NewNoClient returns a new authn.Keychain that supports the portions of the K8s keychain
Expand All @@ -127,8 +128,8 @@ func NewInCluster(opt Options) (authn.Keychain, error) {
// for Kubernetes authentication, but this actually targets a different use-case. What
// remains is an interesting sweet spot: this variant can serve as a credential provider
// for all of the major public clouds, but in library form (vs. an executable you exec).
func NewNoClient() (authn.Keychain, error) {
return New(nil, Options{})
func NewNoClient(ctx context.Context) (authn.Keychain, error) {
return New(ctx, nil, Options{})
}

type lazyProvider struct {
Expand Down
7 changes: 4 additions & 3 deletions pkg/authn/k8schain/k8schain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package k8schain

import (
"context"
"encoding/base64"
"fmt"
"reflect"
Expand All @@ -35,7 +36,7 @@ func TestAnonymousFallback(t *testing.T) {
},
})

kc, err := New(client, Options{})
kc, err := New(context.Background(), client, Options{})
if err != nil {
t.Errorf("New() = %v", err)
}
Expand Down Expand Up @@ -78,7 +79,7 @@ func TestAttachedServiceAccount(t *testing.T) {
},
})

kc, err := New(client, Options{
kc, err := New(context.Background(), client, Options{
Namespace: "ns",
ServiceAccountName: "svcacct",
})
Expand Down Expand Up @@ -131,7 +132,7 @@ func TestImagePullSecrets(t *testing.T) {
},
})

kc, err := New(client, Options{
kc, err := New(context.Background(), client, Options{
Namespace: "ns",
ImagePullSecrets: []string{"secret"},
})
Expand Down
3 changes: 2 additions & 1 deletion pkg/authn/k8schain/tests/explicit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
"context"
"log"

"github.com/google/go-containerregistry/pkg/authn/k8schain"
Expand All @@ -28,7 +29,7 @@ func main() {
log.Fatalf("NewTag() = %v", err)
}

kc, err := k8schain.NewInCluster(k8schain.Options{
kc, err := k8schain.NewInCluster(context.Background(), k8schain.Options{
Namespace: "explicit-namespace",
ImagePullSecrets: []string{
"explicit-secret",
Expand Down
3 changes: 2 additions & 1 deletion pkg/authn/k8schain/tests/implicit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
"context"
"log"
"os"

Expand All @@ -28,7 +29,7 @@ func main() {
log.Fatalf("expected usage: <command> <arg>, got: %v", os.Args)
}

kc, err := k8schain.NewInCluster(k8schain.Options{})
kc, err := k8schain.NewInCluster(context.Background(), k8schain.Options{})
if err != nil {
log.Fatalf("k8schain.New() = %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/authn/k8schain/tests/noauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
"context"
"log"

"github.com/google/go-containerregistry/pkg/authn/k8schain"
Expand All @@ -23,7 +24,7 @@ import (
)

func main() {
kc, err := k8schain.NewInCluster(k8schain.Options{})
kc, err := k8schain.NewInCluster(context.Background(), k8schain.Options{})
if err != nil {
log.Fatalf("k8schain.New() = %v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/authn/k8schain/tests/serviceaccount/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
"context"
"log"

"github.com/google/go-containerregistry/pkg/authn/k8schain"
Expand All @@ -28,7 +29,7 @@ func main() {
log.Fatalf("NewTag() = %v", err)
}

kc, err := k8schain.NewInCluster(k8schain.Options{
kc, err := k8schain.NewInCluster(context.Background(), k8schain.Options{
Namespace: "serviceaccount-namespace",
ServiceAccountName: "serviceaccount",
// This is the name of the imagePullSecrets attached to this service account.
Expand Down
65 changes: 35 additions & 30 deletions vendor/cloud.google.com/go/compute/metadata/metadata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/Azure/azure-sdk-for-go/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d42b6a2

Please sign in to comment.