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 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._

View File

@ -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
}