commit
3dba19d9a0
@ -56,6 +56,9 @@ import (
|
||||
// Always execute the script?
|
||||
always?: bool
|
||||
|
||||
// Directory
|
||||
dir?: dagger.#Artifact
|
||||
|
||||
out: {
|
||||
string
|
||||
|
||||
@ -101,6 +104,9 @@ import (
|
||||
AWS_PAGER: ""
|
||||
}
|
||||
mount: "/cache/aws": "cache"
|
||||
if dir != _|_ {
|
||||
mount: "/inputs/source": from: dir
|
||||
}
|
||||
},
|
||||
op.#Export & {
|
||||
source: export
|
||||
|
@ -42,20 +42,21 @@ import (
|
||||
|
||||
code: #"""
|
||||
opts=""
|
||||
op=cp
|
||||
if [ -d /inputs/source ]; then
|
||||
opts="--recursive"
|
||||
op=sync
|
||||
fi
|
||||
if [ -f /inputs/content_type ]; then
|
||||
opts="--content-type $(cat /inputs/content_type)"
|
||||
fi
|
||||
aws s3 cp $opts /inputs/source "$(cat /inputs/target)"
|
||||
aws s3 $op $opts /inputs/source "$(cat /inputs/target)"
|
||||
cat /inputs/target \
|
||||
| sed -E 's=^s3://([^/]*)/=https://\1.s3.amazonaws.com/=' \
|
||||
> /url
|
||||
"""#
|
||||
|
||||
if sourceInline == _|_ {
|
||||
mount: "/inputs/source": from: source
|
||||
dir: source
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,3 +37,9 @@ setup() {
|
||||
|
||||
"$DAGGER" compute "$TESTDIR"/stdlib/kubernetes/helm --input-dir kubeconfig=~/.kube --input-dir TestHelmSimpleChart.deploy.chartSource="$TESTDIR"/stdlib/kubernetes/helm/testdata/mychart
|
||||
}
|
||||
|
||||
@test "stdlib: s3" {
|
||||
skip_unless_secrets_available "$TESTDIR"/stdlib/aws/inputs.yaml
|
||||
|
||||
"$DAGGER" compute "$TESTDIR"/stdlib/aws/s3 --input-dir TestDirectory="$TESTDIR"/stdlib/aws/s3/testdata --input-yaml "$TESTDIR"/stdlib/aws/inputs.yaml
|
||||
}
|
45
tests/stdlib/aws/s3/s3.cue
Normal file
45
tests/stdlib/aws/s3/s3.cue
Normal file
@ -0,0 +1,45 @@
|
||||
package s3
|
||||
|
||||
import (
|
||||
"dagger.io/dagger"
|
||||
"dagger.io/aws"
|
||||
"dagger.io/aws/s3"
|
||||
)
|
||||
|
||||
TestConfig: awsConfig: aws.#Config & {
|
||||
region: "us-east-2"
|
||||
}
|
||||
|
||||
bucket: "dagger-ci"
|
||||
|
||||
content: "A simple test sentence"
|
||||
|
||||
TestS3UploadFile: {
|
||||
deploy: s3.#Put & {
|
||||
config: TestConfig.awsConfig
|
||||
sourceInline: content
|
||||
target: "s3://\(bucket)/test.txt"
|
||||
}
|
||||
|
||||
verify: #VerifyS3 & {
|
||||
file: "test.txt"
|
||||
}
|
||||
}
|
||||
|
||||
TestDirectory: dagger.#Artifact
|
||||
|
||||
TestS3UploadDir: {
|
||||
deploy: s3.#Put & {
|
||||
config: TestConfig.awsConfig
|
||||
source: TestDirectory
|
||||
target: "s3://\(bucket)/"
|
||||
}
|
||||
|
||||
verifyFile: #VerifyS3 & {
|
||||
file: "dirFile.txt"
|
||||
}
|
||||
|
||||
verifyDir: #VerifyS3 & {
|
||||
file: "foo.txt"
|
||||
}
|
||||
}
|
1
tests/stdlib/aws/s3/testdata/bar/foo.txt
vendored
Normal file
1
tests/stdlib/aws/s3/testdata/bar/foo.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
Test recursivity
|
1
tests/stdlib/aws/s3/testdata/dirFile.txt
vendored
Normal file
1
tests/stdlib/aws/s3/testdata/dirFile.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
Test directory
|
69
tests/stdlib/aws/s3/verify.cue
Normal file
69
tests/stdlib/aws/s3/verify.cue
Normal file
@ -0,0 +1,69 @@
|
||||
package s3
|
||||
|
||||
import (
|
||||
"dagger.io/aws"
|
||||
"dagger.io/alpine"
|
||||
"dagger.io/dagger/op"
|
||||
)
|
||||
|
||||
#List: {
|
||||
// AWS Config
|
||||
config: aws.#Config
|
||||
|
||||
// Target S3 URL (e.g. s3://<bucket-name>/<path>/<sub-path>)
|
||||
target?: string
|
||||
|
||||
// Export folder
|
||||
export: "/contents"
|
||||
|
||||
// Script
|
||||
aws.#Script & {
|
||||
code: """
|
||||
aws s3 ls --recursive \(target) >> /contents
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
#VerifyS3: {
|
||||
file: string
|
||||
|
||||
lists: #List & {
|
||||
config: TestConfig.awsConfig
|
||||
target: "s3://\(bucket)"
|
||||
}
|
||||
|
||||
#CheckFiles:
|
||||
"""
|
||||
grep -q \(file) /test
|
||||
"""
|
||||
|
||||
test: #up: [
|
||||
op.#Load & {
|
||||
from: alpine.#Image & {
|
||||
package: bash: "~5.1"
|
||||
}
|
||||
},
|
||||
|
||||
op.#WriteFile & {
|
||||
dest: "/test"
|
||||
content: lists.out
|
||||
},
|
||||
|
||||
op.#WriteFile & {
|
||||
dest: "/checkFiles.sh"
|
||||
content: #CheckFiles
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
always: true
|
||||
args: [
|
||||
"/bin/bash",
|
||||
"--noprofile",
|
||||
"--norc",
|
||||
"-eo",
|
||||
"pipefail",
|
||||
"/checkFiles.sh",
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user