GeezerVison is showing github.com — Override with environment variables · stackbuilders/func@9125bcd
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: pkg/k8s/keychains.go +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,6 +3,7 @@ package k8s |
3 | 3 | import ( |
4 | 4 | "context" |
5 | 5 | "fmt" |
| 6 | + "os" |
6 | 7 | "strings" |
7 | 8 |
|
8 | 9 | "github.com/google/go-containerregistry/pkg/name" |
@@ -56,6 +57,23 @@ func GetACRCredentialLoader() []creds.CredentialsCallback { |
56 | 57 | return oci.Credentials{}, nil |
57 | 58 | } |
58 | 59 |
|
| 60 | + // HACK: Override credentials if they were given in environment |
| 61 | + if acrToken := os.Getenv("ACR_TOKEN"); acrToken != "" { |
| 62 | + return oci.Credentials{ |
| 63 | + Username: "00000000-0000-0000-0000-000000000000", |
| 64 | + Password: acrToken, |
| 65 | + }, nil |
| 66 | + } else { |
| 67 | + acrUser := os.Getenv("ACR_USERNAME") |
| 68 | + acrPassword := os.Getenv("ACR_PASSWORD") |
| 69 | + if acrUser != "" && acrPassword != "" { |
| 70 | + return oci.Credentials{ |
| 71 | + Username: acrUser, |
| 72 | + Password: acrPassword, |
| 73 | + }, nil |
| 74 | + } |
| 75 | + } |
| 76 | + |
59 | 77 | // TODO: Save token somewhere and check expiration before asking for a new one |
60 | 78 |
|
61 | 79 | azCredential, err := azidentity.NewDefaultAzureCredential(nil) |
|