From ce663ca2ba370536a1fd6e16245e4e4789ae8119 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 7 Jun 2021 15:39:11 +0000 Subject: [PATCH] stdlib: aws/ecr: simplify Signed-off-by: Solomon Hykes --- docs/reference/universe/aws/ecr.md | 19 +++++------ stdlib/aws/ecr/ecr.cue | 52 +++++++++--------------------- 2 files changed, 25 insertions(+), 46 deletions(-) diff --git a/docs/reference/universe/aws/ecr.md b/docs/reference/universe/aws/ecr.md index 90ea3225..4bb7d777 100644 --- a/docs/reference/universe/aws/ecr.md +++ b/docs/reference/universe/aws/ecr.md @@ -6,18 +6,19 @@ sidebar_label: ecr ## #Credentials -Credentials retriever for ECR +Convert AWS credentials to Docker Registry credentials for ECR ### #Credentials Inputs -| Name | Type | Description | -| ------------- |:-------------: |:-------------: | -|*config.region* | `string` |AWS region | -|*config.accessKey* | `dagger.#Secret` |AWS access key | -|*config.secretKey* | `dagger.#Secret` |AWS secret key | +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*config.region* | `string` |AWS region | +|*config.accessKey* | `dagger.#Secret` |AWS access key | +|*config.secretKey* | `dagger.#Secret` |AWS secret key | +|*ctr.image.config.region* | `string` |AWS region | +|*ctr.image.config.accessKey* | `dagger.#Secret` |AWS access key | +|*ctr.image.config.secretKey* | `dagger.#Secret` |AWS secret key | ### #Credentials Outputs -| Name | Type | Description | -| ------------- |:-------------: |:-------------: | -|*secret* | `string` |- | +_No output._ diff --git a/stdlib/aws/ecr/ecr.cue b/stdlib/aws/ecr/ecr.cue index 7a240018..267fceab 100644 --- a/stdlib/aws/ecr/ecr.cue +++ b/stdlib/aws/ecr/ecr.cue @@ -1,52 +1,30 @@ package ecr import ( - "dagger.io/dagger" - "dagger.io/dagger/op" "dagger.io/aws" + "dagger.io/os" ) -// Credentials retriever for ECR +// Convert AWS credentials to Docker Registry credentials for ECR #Credentials: { // AWS Config config: aws.#Config - out: dagger.#Secret - // ECR credentials username: "AWS" - secret: { - @dagger(output) - string - - #up: [ - op.#Load & { - from: aws.#CLI & { - "config": config - } - }, - - op.#Exec & { - always: true - - args: [ - "/bin/bash", - "--noprofile", - "--norc", - "-eo", - "pipefail", - "-c", - #""" - aws ecr get-login-password > /out - """#, - ] - }, - - op.#Export & { - source: "/out" - format: "string" - }, - ] + ctr: os.#Container & { + image: aws.#CLI & { + "config": config + } + always: true + command: "aws ecr get-login-password > /out" } + + secret: { + os.#File & { + from: ctr + path: "/out" + } + }.read.data }