stdlib: aws/ecr: simplify

Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
Solomon Hykes 2021-06-07 15:39:11 +00:00 committed by Solomon Hykes
parent 336f1aecc4
commit ce663ca2ba
2 changed files with 25 additions and 46 deletions

View File

@ -6,18 +6,19 @@ sidebar_label: ecr
## #Credentials ## #Credentials
Credentials retriever for ECR Convert AWS credentials to Docker Registry credentials for ECR
### #Credentials Inputs ### #Credentials Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.region* | `string` |AWS region | |*config.region* | `string` |AWS region |
|*config.accessKey* | `dagger.#Secret` |AWS access key | |*config.accessKey* | `dagger.#Secret` |AWS access key |
|*config.secretKey* | `dagger.#Secret` |AWS secret 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 ### #Credentials Outputs
| Name | Type | Description | _No output._
| ------------- |:-------------: |:-------------: |
|*secret* | `string` |- |

View File

@ -1,52 +1,30 @@
package ecr package ecr
import ( import (
"dagger.io/dagger"
"dagger.io/dagger/op"
"dagger.io/aws" "dagger.io/aws"
"dagger.io/os"
) )
// Credentials retriever for ECR // Convert AWS credentials to Docker Registry credentials for ECR
#Credentials: { #Credentials: {
// AWS Config // AWS Config
config: aws.#Config config: aws.#Config
out: dagger.#Secret
// ECR credentials // ECR credentials
username: "AWS" username: "AWS"
secret: { ctr: os.#Container & {
@dagger(output) image: aws.#CLI & {
string "config": config
}
#up: [ always: true
op.#Load & { command: "aws ecr get-login-password > /out"
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"
},
]
} }
secret: {
os.#File & {
from: ctr
path: "/out"
}
}.read.data
} }