Skip to content

Commit

Permalink
Set profile as an optional parameter in the cli (#59)
Browse files Browse the repository at this point in the history
* fix: allow profile to be empty to use env

* Add the parameter split

* fix linting

* debug: add -x to alpine executor

* debug: add -x to alpine executor

* Fix: update aws-cli version

* Fix: apply same change to copy

* Add test with arguments

* Fix: names and dependencies on tests

* Fix: names and dependencies on tests
  • Loading branch information
marboledacci authored Oct 15, 2024
1 parent d199b2e commit 7c18f79
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 16 deletions.
15 changes: 11 additions & 4 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1
orbs:
orb-tools: circleci/orb-tools@12.0
aws-cli: circleci/aws-cli@4.0
orb-tools: circleci/orb-tools@12.1.1
aws-cli: circleci/aws-cli@5.1.1
aws-s3: {}
filters: &filters
tags:
Expand All @@ -13,6 +13,7 @@ release-filters: &release-filters
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
executors:
alpine:
shell: sh -eox pipefail
docker:
- image: alpine:latest
docker-base:
Expand Down Expand Up @@ -50,6 +51,7 @@ workflows:
context: [CPE-OIDC]
filters: *filters
matrix:
alias: integration-test
parameters:
executor: ["alpine", "docker-base"]
- aws-s3/sync:
Expand All @@ -63,7 +65,12 @@ workflows:
from: "$HOME/bucket"
to: "s3://orb-testing-1/s3-orb"
profile_name: "OIDC-User"
arguments:
context: [CPE-OIDC]
matrix:
alias: sync
parameters:
arguments: ["'--exclude *.hmtl' '--cache-control public,max-age=31536000,immutable'", ""]
filters: *filters
- aws-s3/copy:
pre-steps:
Expand All @@ -79,14 +86,14 @@ workflows:
context: [CPE-OIDC]
filters: *filters
requires:
- aws-s3/sync
- sync
- orb-tools/pack:
filters: *release-filters
- orb-tools/publish:
orb_name: circleci/aws-s3
vcs_type: << pipeline.project.type >>
pub_type: production
enable_pr_comment: true
requires: [orb-tools/pack, integration-test-alpine, integration-test-docker-base, aws-s3/copy, aws-s3/sync]
requires: [orb-tools/pack, integration-test, aws-s3/copy, sync]
context: orb-publisher
filters: *release-filters
2 changes: 1 addition & 1 deletion src/commands/copy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ parameters:
profile_name:
description: AWS profile name to be configured.
type: string
default: "default"
default: ""
role_arn:
description: |
The Amazon Resource Name (ARN) of the role that the caller is assuming.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ parameters:
profile_name:
description: AWS profile name to be configured.
type: string
default: "default"
default: ""
when:
description: |
Add the when attribute to a job step to override its default behavior
Expand Down
2 changes: 1 addition & 1 deletion src/examples/authentication_with_jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ usage:
orbs:
aws-s3: circleci/[email protected]
# Importing aws-cli orb is required
aws-cli: circleci/aws-cli@4.0
aws-cli: circleci/aws-cli@5.1.1
workflows:
s3-example:
jobs:
Expand Down
2 changes: 1 addition & 1 deletion src/examples/override_credentials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ usage:
orbs:
aws-s3: circleci/[email protected]
# Importing aws-cli orb is required
aws-cli: circleci/aws-cli@4.0
aws-cli: circleci/aws-cli@5.1.1
jobs:
build:
docker:
Expand Down
2 changes: 1 addition & 1 deletion src/examples/sync_and_copy_with_oidc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ usage:
orbs:
aws-s3: circleci/[email protected]
# Importing aws-cli orb is required
aws-cli: circleci/aws-cli@4.0
aws-cli: circleci/aws-cli@5.1.1
jobs:
sync_and_copy:
docker:
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/copy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ parameters:
profile_name:
description: AWS profile name to be configured.
type: string
default: "default"
default: ""
auth:
description: |
The authentication method used to access your AWS account. Import the aws-cli orb in your config and
Expand Down
2 changes: 1 addition & 1 deletion src/jobs/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ parameters:
profile_name:
description: AWS profile name to be configured.
type: string
default: "default"
default: ""
auth:
description: |
The authentication method used to access your AWS account. Import the aws-cli orb in your config and
Expand Down
8 changes: 5 additions & 3 deletions src/scripts/copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ if [ -n "${ORB_STR_ARGUMENTS}" ]; then
IFS=' '
set --
for arg in $(echo "${ORB_STR_ARGUMENTS}" | sed 's/,[ ]*/,/g'); do
set -- "$@" "$arg"
set -- "$@" "$arg"
done
fi

if [ -n "${ORB_STR_PROFILE_NAME}" ]; then
set -- "$@" --profile "${ORB_STR_PROFILE_NAME}"
fi
set -x
aws s3 cp "${ORB_EVAL_FROM}" "${ORB_EVAL_TO}" --profile "${ORB_STR_PROFILE_NAME}" "$@"
aws s3 cp "${ORB_EVAL_FROM}" "${ORB_EVAL_TO}" "$@"
set +x
7 changes: 5 additions & 2 deletions src/scripts/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ if [ -n "${ORB_STR_ARGUMENTS}" ]; then
IFS=' '
set --
for arg in $(echo "${ORB_STR_ARGUMENTS}" | sed 's/,[ ]*/,/g'); do
set -- "$@" "$arg"
set -- "$@" "$arg"
done
fi
if [ -n "${ORB_STR_PROFILE_NAME}" ]; then
set -- "$@" --profile "${ORB_STR_PROFILE_NAME}"
fi
set -x
aws s3 sync "${ORB_EVAL_FROM}" "${ORB_EVAL_TO}" --profile "${ORB_STR_PROFILE_NAME}" "$@"
aws s3 sync "${ORB_EVAL_FROM}" "${ORB_EVAL_TO}" "$@"
set +x

0 comments on commit 7c18f79

Please sign in to comment.