Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:

jobs:
fetch:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: swatinem/rust-cache@v2
Expand All @@ -25,23 +25,23 @@ jobs:
run: git diff --exit-code || (echo 'Cargo.lock needs updated' && exit 1)

clippy:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: swatinem/rust-cache@v2
- name: Check
run: cargo clippy --all-targets --locked

doc-check:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: swatinem/rust-cache@v2
- name: Doc check
run: cargo doc --no-deps --locked

test:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: swatinem/rust-cache@v2
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
# we specify bash to get pipefail; it guards against the `curl` command
# failing. otherwise `sh` won't catch that `curl` returned non-0
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.1/cargo-dist-installer.sh | sh"
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.2/cargo-dist-installer.sh | sh"
# sure would be cool if github gave us proper conditionals...
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
# functionality based on whether this is a pull_request, and whether it's from a fork.
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
needs:
- plan
- build-local-artifacts
runs-on: "ubuntu-20.04"
runs-on: ubuntu-24.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
Expand All @@ -164,7 +164,7 @@ jobs:
submodules: recursive
- name: Install cargo-dist
shell: bash
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.1/cargo-dist-installer.sh | sh"
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.2/cargo-dist-installer.sh | sh"
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
- name: Fetch local artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -201,15 +201,15 @@ jobs:
if: ${{ always() && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: "ubuntu-20.04"
runs-on: ubuntu-24.04
outputs:
val: ${{ steps.host.outputs.manifest }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install cargo-dist
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.1/cargo-dist-installer.sh | sh"
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.2/cargo-dist-installer.sh | sh"
# Fetch artifacts from scratch-storage
- name: Fetch artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -256,7 +256,7 @@ jobs:
# still allowing individual publish jobs to skip themselves (for prereleases).
# "host" however must run to completion, no skipping allowed!
if: ${{ always() && needs.host.result == 'success' && (needs.custom-cargo-publish.result == 'skipped' || needs.custom-cargo-publish.result == 'success') }}
runs-on: "ubuntu-20.04"
runs-on: ubuntu-24.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
Expand Down
72 changes: 38 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ path = "src/main.rs"

[dependencies]
async_zip = { version = "0.0.9", default-features = false, features = ["deflate"] }
atty = "0.2.14"
aws-config = "1.1.10"
aws-credential-types = "1.2.0"
aws-sdk-s3 = "1.22.0"
Expand Down Expand Up @@ -41,8 +40,10 @@ lto = "thin"

# Config for 'cargo dist'
[workspace.metadata.dist]
# Skip checking whether the specified configuration files are up to date
allow-dirty = ["ci"]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
cargo-dist-version = "0.13.1"
cargo-dist-version = "0.13.2"
# CI backends to support
ci = ["github"]
# The installers to generate for each app
Expand Down
13 changes: 7 additions & 6 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use aws_types::region::Region;

use crate::Error;

pub async fn get_config(region: Option<Region>) -> Result<SdkConfig, Error> {
let sso = aws_sso_flow::SsoFlow::builder().verification_prompt(|url| async move {
if atty::is(atty::Stream::Stdin) && atty::is(atty::Stream::Stdout) {
pub async fn get_config(region: Option<Region>, no_input: bool) -> Result<SdkConfig, Error> {
let sso = aws_sso_flow::SsoFlow::builder().verification_prompt(move |url| async move {
if no_input {
Err(NonInteractiveSsoError)
} else {
eprintln!("Using SSO an profile – go to {url} to authenticate");
Ok(())
} else {
Err(NonInteractiveSsoError)
}
});
let credentials = CredentialsProviderChain::first_try("SsoFlow", sso)
Expand All @@ -38,8 +38,9 @@ pub async fn get_config(region: Option<Region>) -> Result<SdkConfig, Error> {
pub async fn get_client<C>(
ctor: impl FnOnce(&SdkConfig) -> C,
region: Option<Region>,
no_input: bool,
) -> Result<C, Error> {
let config = get_config(region).await?;
let config = get_config(region, no_input).await?;
Ok(ctor(&config))
}

Expand Down
11 changes: 9 additions & 2 deletions src/command/apply_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ pub struct Args {
#[clap(long)]
client_request_token: Option<String>,

/// A flag to indicate that no input can be obtained.
///
/// For example, this will cause the operation to fail if SSO authentication is configured and
/// not refereshed.
#[clap(long, default_value_t)]
no_input: bool,

/// The Simple Notification Service (SNS) topic ARNs to publish stack related events.
#[clap(long, num_args(1..))]
notification_arns: Vec<String>,
Expand Down Expand Up @@ -134,7 +141,7 @@ pub async fn main(region: Option<Region>, args: Args) -> Result<(), Error> {
let mut template = Template::open(args.template_path.clone()).await?;
preprocess(region.as_ref(), &args, &mut template).await?;

let config = get_config(region).await?;
let config = get_config(region, args.no_input).await?;
let client = cloudformatious::Client::new(&config);
let input = args.into_input(&template);
let mut apply = client.apply_stack(input.clone());
Expand Down Expand Up @@ -215,7 +222,7 @@ async fn preprocess(
)));
};

let client = s3::Client::new(region.cloned()).await?;
let client = s3::Client::new(region.cloned(), args.no_input).await?;

package::process(
&client,
Expand Down
9 changes: 8 additions & 1 deletion src/command/delete_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ pub struct Args {
#[clap(long)]
client_request_token: Option<String>,

/// A flag to indicate that no input can be obtained.
///
/// For example, this will cause the operation to fail if SSO authentication is configured and
/// not refereshed.
#[clap(long, default_value_t)]
no_input: bool,

/// Disable informational output to STDERR.
#[clap(long)]
quiet: bool,
Expand Down Expand Up @@ -80,7 +87,7 @@ impl TryFrom<Args> for DeleteStackInput {
pub async fn main(region: Option<Region>, args: Args) -> Result<(), Error> {
let quiet = args.quiet;

let config = get_config(region).await?;
let config = get_config(region, args.no_input).await?;
let client = cloudformatious::Client::new(&config);
let mut delete = client.delete_stack(args.try_into()?);
let sizing = Sizing::default();
Expand Down
9 changes: 8 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ impl fmt::Display for Error {

Ok(())
}
Self::Other(error) => error.fmt(f),
Self::Other(error) => {
write!(f, "{}", error)?;
let chain = std::iter::successors(error.source(), |error| error.source());
for error in chain {
write!(f, ": {}", error)?;
}
Ok(())
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ pub struct Client {
}

impl Client {
pub async fn new(region: Option<Region>) -> Result<Self, Error> {
let inner = get_client(aws_sdk_s3::Client::new, region).await?;
pub async fn new(region: Option<Region>, no_input: bool) -> Result<Self, Error> {
let inner = get_client(aws_sdk_s3::Client::new, region, no_input).await?;
Ok(Self { inner })
}

pub async fn upload<'a>(&self, request: UploadRequest<'a>) -> Result<UploadOutput, Error> {
pub async fn upload(&self, request: UploadRequest<'_>) -> Result<UploadOutput, Error> {
let meta = request
.file
.metadata()
Expand Down