mirror of
https://github.com/imjasonh/gke-auth
synced 2026-07-07 00:23:18 +00:00
make registry auth optional, must specify location
Signed-off-by: Jason Hall <jason@chainguard.dev>
This commit is contained in:
parent
3517929a83
commit
d07111e3f5
5 changed files with 22 additions and 13 deletions
6
.github/workflows/test-action.yaml
vendored
6
.github/workflows/test-action.yaml
vendored
|
|
@ -34,5 +34,9 @@ jobs:
|
|||
project: imjasonh-autopilot
|
||||
location: us-east1
|
||||
cluster: autopilot
|
||||
|
||||
registry_location: us-east1
|
||||
- run: kubectl get pods
|
||||
|
||||
- uses: imjasonh/setup-crane@main
|
||||
- run: crane catalog us-east1-docker.pkg.dev
|
||||
|
||||
|
|
|
|||
4
.github/workflows/using-gcloud.yaml
vendored
4
.github/workflows/using-gcloud.yaml
vendored
|
|
@ -24,8 +24,12 @@ jobs:
|
|||
- uses: google-github-actions/setup-gcloud@98ddc00a17442e89a24bbf282954a3b65ce6d200 # v2.1.0
|
||||
with:
|
||||
project_id: imjasonh-autopilot
|
||||
install_components: gke-gcloud-auth-plugin
|
||||
- run: |
|
||||
gcloud container clusters get-credentials autopilot \
|
||||
--region us-east1
|
||||
|
||||
- run: kubectl get pods
|
||||
|
||||
- run: gcloud auth configure-docker us-east1-docker.pkg.dev
|
||||
- run: crane catalog us-east1-docker.pkg.dev
|
||||
|
|
|
|||
|
|
@ -48,12 +48,13 @@ This will set up a Docker credential helper for interacting with `[REGION]-docke
|
|||
|
||||
This is similar to [`docker-credential-gcr`](https://github.com/GoogleCloudPlatform/docker-credential-gcr) except much simpler.
|
||||
|
||||
This is configured by default when using the GitHub Action. You can disable this behavior with:
|
||||
This can also be configured with the GitHub Action:
|
||||
|
||||
```
|
||||
```yaml
|
||||
uses: imjasonh/gke-auth@XYZ
|
||||
with:
|
||||
configure-docker: false
|
||||
location: us-central1-a
|
||||
registry_location: us-central1
|
||||
```
|
||||
|
||||
### Why?
|
||||
|
|
|
|||
14
action.yaml
14
action.yaml
|
|
@ -17,10 +17,10 @@ inputs:
|
|||
cluster:
|
||||
description: "Name of the cluster"
|
||||
required: true
|
||||
configure-docker:
|
||||
description: "Set up Artifact Registry auth for the project and location"
|
||||
required: true
|
||||
default: "true"
|
||||
registry_location:
|
||||
description: "Region or multi-region of the Artifact Registry instance"
|
||||
required: false
|
||||
default: ""
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
|
|
@ -29,7 +29,7 @@ runs:
|
|||
set -ex
|
||||
|
||||
# Install gke-auth:
|
||||
# - if version is "tip", install from tip of main.
|
||||
# - if version is "tip", `go install` from tip of main.
|
||||
# - if version is "latest-release", look up latest release.
|
||||
# - otherwise, install the specified version.
|
||||
case ${{ inputs.version }} in
|
||||
|
|
@ -49,8 +49,8 @@ runs:
|
|||
curl -fsL https://github.com/imjasonh/gke-auth/releases/download/${tag}/gke-auth_${tag:1}_Linux_x86_64.tar.gz | sudo tar xzf - -C /usr/local/bin gke-auth
|
||||
fi
|
||||
|
||||
if [[ "${{ inputs.configure-docker }}" == "true" ]]; then
|
||||
gke-auth --location=${{ inputs.location }} --configure-docker
|
||||
if [[ "${{ inputs.registry_location }}" != "" ]]; then
|
||||
gke-auth --location=${{ inputs.registry_location }} --configure-docker
|
||||
fi
|
||||
|
||||
gke-auth --project=${{ inputs.project }} \
|
||||
|
|
|
|||
4
main.go
4
main.go
|
|
@ -23,8 +23,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
project = flag.String("project", "", "Name of the project (empty means look it up)")
|
||||
location = flag.String("location", "", "Location of the cluster (empty means look it up)")
|
||||
project = flag.String("project", "", "Name of the project")
|
||||
location = flag.String("location", "", "Location of the cluster")
|
||||
clusterName = flag.String("cluster", "", "Name of the cluster")
|
||||
|
||||
get = flag.Bool("get", false, "If true, print auth information")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue