From 0d5f41ee31938d899a09bfce84b79b0e9792c264 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Tue, 15 Jun 2021 18:42:51 +0200 Subject: [PATCH] docs: s3 lib: deprecated #Put in favor #Object Signed-off-by: Sam Alba --- docs/reference/universe/aws/s3.md | 33 ++------- examples/simple-s3/main.cue | 2 +- stdlib/.dagger/env/aws-s3/plan/s3.cue | 38 +--------- stdlib/aws/s3/s3.cue | 99 ++------------------------- 4 files changed, 14 insertions(+), 158 deletions(-) diff --git a/docs/reference/universe/aws/s3.md b/docs/reference/universe/aws/s3.md index 91de6fd1..7209809d 100644 --- a/docs/reference/universe/aws/s3.md +++ b/docs/reference/universe/aws/s3.md @@ -6,32 +6,11 @@ sidebar_label: s3 AWS Simple Storage Service -## #Put +## #Object -S3 Bucket upload (file or directory) +S3 Bucket object(s) sync -### #Put Inputs - -| Name | Type | Description | -| ------------- |:-------------: |:-------------: | -|*config.region* | `string` |AWS region | -|*config.accessKey* | `dagger.#Secret` |AWS access key | -|*config.secretKey* | `dagger.#Secret` |AWS secret key | -|*target* | `string` |Target S3 URL (eg. s3://\/\/\) | -|*contentType* | `*"" \| string` |Object content type | -|*always* | `*true \| bool` |Always write the object to S3 | - -### #Put Outputs - -| Name | Type | Description | -| ------------- |:-------------: |:-------------: | -|*url* | `string` |URL of the uploaded S3 object | - -## #Sync - -S3 Bucket sync - -### #Sync Inputs +### #Object Inputs | Name | Type | Description | | ------------- |:-------------: |:-------------: | @@ -40,11 +19,11 @@ S3 Bucket sync |*config.secretKey* | `dagger.#Secret` |AWS secret key | |*source* | `dagger.#Artifact` |Source Artifact to upload to S3 | |*target* | `string` |Target S3 URL (eg. s3://\/\/\) | -|*delete* | `*false \| bool` |Delete files that already exist on remote destination | +|*delete* | `false` |Delete files that already exist on remote destination | |*contentType* | `*"" \| string` |Object content type | -|*always* | `*true \| bool` |Always write the object to S3 | +|*always* | `*true \| false` |Always write the object to S3 | -### #Sync Outputs +### #Object Outputs | Name | Type | Description | | ------------- |:-------------: |:-------------: | diff --git a/examples/simple-s3/main.cue b/examples/simple-s3/main.cue index 3301655b..7235ab19 100644 --- a/examples/simple-s3/main.cue +++ b/examples/simple-s3/main.cue @@ -20,7 +20,7 @@ source: dagger.#Artifact @dagger(input) // Deployed URL url: "\(deploy.url)index.html" @dagger(output) -deploy: s3.#Put & { +deploy: s3.#Object & { always: true config: awsConfig "source": source diff --git a/stdlib/.dagger/env/aws-s3/plan/s3.cue b/stdlib/.dagger/env/aws-s3/plan/s3.cue index 8968493c..73f9a425 100644 --- a/stdlib/.dagger/env/aws-s3/plan/s3.cue +++ b/stdlib/.dagger/env/aws-s3/plan/s3.cue @@ -14,44 +14,10 @@ bucket: "dagger-ci" content: "A simple test sentence" -TestS3UploadFile: { - deploy: s3.#Put & { - config: TestConfig.awsConfig - sourceInline: content - target: "s3://\(bucket)/test.txt" - } - - verify: #VerifyS3 & { - config: TestConfig.awsConfig - target: deploy.target - file: "test.txt" - } -} - TestDirectory: dagger.#Artifact -TestS3UploadDir: { - deploy: s3.#Put & { - config: TestConfig.awsConfig - source: TestDirectory - target: "s3://\(bucket)/" - } - - verifyFile: #VerifyS3 & { - config: TestConfig.awsConfig - target: deploy.target - file: "dirFile.txt" - } - - verifyDir: #VerifyS3 & { - config: TestConfig.awsConfig - target: deploy.target - file: "foo.txt" - } -} - -TestS3Sync: { - deploy: s3.#Sync & { +TestS3Object: { + deploy: s3.#Object & { config: TestConfig.awsConfig source: TestDirectory target: "s3://\(bucket)/" diff --git a/stdlib/aws/s3/s3.cue b/stdlib/aws/s3/s3.cue index 2312f89e..54386a9d 100644 --- a/stdlib/aws/s3/s3.cue +++ b/stdlib/aws/s3/s3.cue @@ -7,96 +7,8 @@ import ( "dagger.io/aws" ) -// S3 Bucket upload (file or directory) -// FIXME: rename #Put to use a noun -// FIXME: deprecate in favor of #Sync -#Put: { - - // AWS Config - config: aws.#Config - - // Source Artifact to upload to S3 - source?: dagger.#Artifact @dagger(input) - - // Source inlined as a string to upload to S3 - sourceInline?: string @dagger(input) - - // Target S3 URL (eg. s3:////) - target: string @dagger(input) - - // Object content type - contentType: string | *"" @dagger(input) - - // Always write the object to S3 - always: bool | *true @dagger(input) - - // URL of the uploaded S3 object - url: { - @dagger(output) - string - - #up: [ - op.#Load & { - from: aws.#CLI & { - "config": config - } - }, - - if sourceInline != _|_ { - op.#WriteFile & { - dest: "/source" - content: sourceInline - } - }, - - op.#Exec & { - if always != _|_ { - "always": always - } - env: { - TARGET: target - CONTENT_TYPE: contentType - } - - if sourceInline == _|_ { - mount: "/source": from: source - } - - args: [ - "/bin/bash", - "--noprofile", - "--norc", - "-eo", - "pipefail", - "-c", - #""" - opts="" - op=cp - if [ -d /source ]; then - op=sync - fi - if [ -n "$CONTENT_TYPE" ]; then - opts="--content-type $CONTENT_TYPE" - fi - aws s3 $op $opts /source "$TARGET" - echo -n "$TARGET" \ - | sed -E 's=^s3://([^/]*)/=https://\1.s3.amazonaws.com/=' \ - > /url - """#, - ] - }, - - op.#Export & { - source: "/url" - format: "string" - }, - ] - } -} - -// S3 Bucket sync -// FIXME: rename #Sync to use a noun -#Sync: { +// S3 Bucket object(s) sync +#Object: { // AWS Config config: aws.#Config @@ -108,17 +20,16 @@ import ( target: string @dagger(input) // Delete files that already exist on remote destination - delete: *false | bool @dagger(input) + delete: *false | false @dagger(input) // Object content type contentType: string | *"" @dagger(input) // Always write the object to S3 - always: bool | *true @dagger(input) + always: *true | false @dagger(input) // URL of the uploaded S3 object url: { - @dagger(output) string #up: [ @@ -169,5 +80,5 @@ import ( format: "string" }, ] - } + } @dagger(output) }