support registry auth

HACK: the way buildkit works, we can only supply an Auth Provider for the entirety of the build session (`dagger up`). Therefore, we start by scanning all auth in the entire Cue tree and supply an auth provider for all of them.

Drawbacks:
- As soon as you add `auth` in a Pipeline for a registry, all other Pipelines have access to the same registry
- You can't use different credentials for the same registry

Fixes #301

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2021-04-19 18:04:18 -07:00
parent 5e90c1a11e
commit 692bd72095
9 changed files with 204 additions and 18 deletions

View File

@@ -5,6 +5,8 @@ import (
"dagger.io/alpine"
)
TestAuth: op.#RegistryAuth
TestPushContainer: {
// Generate a random number
random: {
@@ -13,6 +15,7 @@ TestPushContainer: {
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "echo -n $RANDOM > /rand"]
always: true
},
op.#Export & {
source: "/rand"
@@ -30,6 +33,7 @@ TestPushContainer: {
},
op.#PushContainer & {
"ref": ref
auth: TestAuth
},
]
}
@@ -64,6 +68,7 @@ TestPushContainerMetadata: {
op.#Load & {from: alpine.#Image},
op.#Exec & {
args: ["sh", "-c", "echo -n $RANDOM > /rand"]
always: true
},
op.#Export & {
source: "/rand"
@@ -83,6 +88,7 @@ TestPushContainerMetadata: {
},
op.#PushContainer & {
"ref": ref
auth: TestAuth
},
]
}
@@ -113,6 +119,7 @@ TestPushContainerMetadata: {
},
op.#PushContainer & {
"ref": ref
auth: TestAuth
},
]
}