Skip to content

Commit

Permalink
Merge pull request #20 from stackbrew/fix-ecr
Browse files Browse the repository at this point in the history
Fix ecr and gcr auth
  • Loading branch information
samalba committed May 7, 2020
2 parents 5c51ce4 + b65e056 commit e690022
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions .script/hack.sh
Expand Up @@ -15,7 +15,7 @@ case "${1}" in
fmt)
for component in ${COMPONENTS}; do
(
echo "+++ FMT ${component}"
echo "+++ FMT ${component}" >&2
cd "${PKGDIR}/${component}"
# FIXME: fmt is broken with _test.cue files
#cue fmt -s
Expand All @@ -27,7 +27,7 @@ case "${1}" in
lint)
for component in ${COMPONENTS}; do
(
echo "+++ LINTING ${component}"
echo "+++ LINTING ${component}" >&2
cd "${PKGDIR}/${component}"
cue fmt -s
cue trim -s
Expand All @@ -38,7 +38,7 @@ case "${1}" in
test)
for component in ${COMPONENTS}; do
(
echo "+++ TESTING ${component}"
echo "+++ TESTING ${component}" >&2
cd "${PKGDIR}/${component}"
bl-runtime test -f "$TEST_CONFIG" -t "$TEST_TARGET:${component/\//.}"
)
Expand All @@ -47,7 +47,7 @@ case "${1}" in
publish)
for component in ${COMPONENTS}; do
(
echo "+++ PUBLISH stackbrew.io/${component}"
echo "+++ PUBLISH stackbrew.io/${component}" >&2
cd "${PKGDIR}/${component}"
bl-runtime publish "stackbrew.io/${component}"
)
Expand All @@ -59,7 +59,7 @@ case "${1}" in
echo "# Stackbrew Packages" > "$docs"
for component in ${COMPONENTS}; do
(
echo "+++ DOCUMENTING ${component}"
echo "+++ DOCUMENTING ${component}" >&2
cd "${PKGDIR}"
echo >> "$docs"
bl-runtime doc -c "${component}" -o md >> "$docs"
Expand Down
13 changes: 6 additions & 7 deletions pkg/aws/ecr/ecr.cue
Expand Up @@ -17,24 +17,23 @@ Credentials :: {

// ECR credentials
credentials: bl.RegistryCredentials & {
username: run.output["/outputs/username"]
username: output["/outputs/username"]
secret: bl.Secret & {
// FIXME: we should be able to output a bl.Secret directly
value: base64.Encode(null, run.output["/outputs/secret"])
value: base64.Encode(null, output["/outputs/secret"])
}
}

// ECR registry name associated with target
registry: run.output["/outputs/registry"]

// Authentication for ECR Registries
auth: bl.RegistryAuth
auth: registry: credentials
auth: "\(target)": credentials

helperUrl:
"https://amazon-ecr-credential-helper-releases.s3.us-east-2.amazonaws.com/0.4.0/linux-amd64/docker-credential-ecr-login"

run: bl.BashScript & {
output: _

bl.BashScript & {
runPolicy: "always"

input: {
Expand Down
8 changes: 7 additions & 1 deletion pkg/aws/ecr/ecr_test.cue
Expand Up @@ -39,10 +39,16 @@ TestECR: {
target: image
}

debug: {
source: build.image
target: image
auth: login.auth
}

// Push the image
export: bl.Push & {
source: build.image
target: image
target: login.target
auth: login.auth
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/bl.sum
@@ -1,3 +1,4 @@
{
"b.l/bl": "sha256:28fa84c1663a754209f89fd97197805cf79e2ef6c48aeecb58227edee3422b37"
"b.l/bl": "sha256:28fa84c1663a754209f89fd97197805cf79e2ef6c48aeecb58227edee3422b37",
"blocklayer.dev/bl": "sha256:28fa84c1663a754209f89fd97197805cf79e2ef6c48aeecb58227edee3422b37"
}
16 changes: 5 additions & 11 deletions pkg/googlecloud/gcr/gcr.cue
Expand Up @@ -17,28 +17,22 @@ Credentials :: {

// Registry Credentials
credentials: bl.RegistryCredentials & {
username: run.output["/outputs/username"]
username: output["/outputs/username"]
secret: bl.Secret & {
// FIXME: we should be able to output a bl.Secret directly
value: base64.Encode(null, run.output["/outputs/secret"])
value: base64.Encode(null, output["/outputs/secret"])
}
}

// Authentication for GCR Registries
// This list is hardcoded from:
// https://github.com/GoogleCloudPlatform/docker-credential-gcr/blob/be7633a109f04f19953c4d830ec5788709c16df4/config/const.go#L50
auth: bl.RegistryAuth
auth: "gcr.io": credentials
auth: "asia.gcr.io": credentials
auth: "eu.gcr.io": credentials
auth: "marketplace.gcr.io": credentials
auth: "staging-k8s.gcr.io": credentials
auth: "us.gcr.io": credentials
auth: "\(target)": credentials

helperUrl:
"https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v2.0.1/docker-credential-gcr_linux_amd64-2.0.1.tar.gz"

run: bl.BashScript & {
output: _
bl.BashScript & {
runPolicy: "always"

input: {
Expand Down
2 changes: 1 addition & 1 deletion pkg/googlecloud/gcr/gcr_test.cue
Expand Up @@ -42,7 +42,7 @@ TestGCR: {
// Push the image
export: bl.Push & {
source: build.image
target: image
target: login.target
auth: login.auth
}

Expand Down

0 comments on commit e690022

Please sign in to comment.