Skip to content

Commit

Permalink
gke-gcloud-auth-plugin compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
gartnera committed Jun 19, 2022
1 parent 3b12230 commit 49f0118
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ archives:
- src: scripts/docker-credential-gcloud
dst: "."
strip_parent: true
- src: scripts/gke-gcloud-auth-plugin
dst: "."
strip_parent: true
changelog:
sort: asc
filters:
Expand Down
1 change: 1 addition & 0 deletions auth/application_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func (a *ApplicationCredentials) Token() (*oauth2.Token, error) {
if !a.AccessTokenExpiry.IsZero() && a.AccessTokenExpiry.After(time.Now()) {
return &oauth2.Token{
AccessToken: a.AccessToken,
Expiry: a.AccessTokenExpiry,
}, nil
}

Expand Down
7 changes: 1 addition & 6 deletions container/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,9 @@ var clustersGetCredentialsCmd = &cobra.Command{
}
kubeConfig.AuthInfos[kName] = &clientcmdapi.AuthInfo{
Exec: &clientcmdapi.ExecConfig{
Command: "gcloud",
Command: "gke-gcloud-auth-plugin",
APIVersion: "client.authentication.k8s.io/v1",
InteractiveMode: clientcmdapi.NeverExecInteractiveMode,
Args: []string{
"config",
"config-helper",
"--format=client.authentication.k8s.io/v1",
},
},
}
kubeConfig.Contexts[kName] = &clientcmdapi.Context{
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.18

require (
cloud.google.com/go/container v1.2.0
github.com/docker/cli v20.10.17+incompatible
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb
Expand All @@ -15,7 +16,6 @@ require (
require (
cloud.google.com/go/compute v1.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v20.10.17+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.4 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand Down Expand Up @@ -43,6 +43,7 @@ require (
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools/v3 v3.3.0 // indirect
k8s.io/apimachinery v0.24.2 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
Expand Down Expand Up @@ -729,6 +730,8 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
2 changes: 1 addition & 1 deletion scripts/docker-credential-gcloud
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

gcloud auth docker-helper $@
exec gcloud auth docker-helper $@
3 changes: 3 additions & 0 deletions scripts/gke-gcloud-auth-plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

exec gcloud config config-helper --format=client.authentication.k8s.io/v1

0 comments on commit 49f0118

Please sign in to comment.