Skip to content

Commit

Permalink
stdlib: aws/ecr: simplify
Browse files Browse the repository at this point in the history
Signed-off-by: Solomon Hykes <solomon@dagger.io>
  • Loading branch information
shykes committed Jun 9, 2021
1 parent 336f1ae commit ce663ca
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 46 deletions.
19 changes: 10 additions & 9 deletions docs/reference/universe/aws/ecr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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._
52 changes: 15 additions & 37 deletions stdlib/aws/ecr/ecr.cue
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit ce663ca

Please sign in to comment.