Skip to content

Commit

Permalink
Get functions (#413)
Browse files Browse the repository at this point in the history
Closes #340
  • Loading branch information
andrzejressel authored Sep 29, 2024
1 parent da2e3eb commit 1a709bf
Show file tree
Hide file tree
Showing 158 changed files with 13,682 additions and 1,190 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/rust-clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ jobs:
with:
version: "25.3"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: extractions/setup-just@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install required cargo
run: |
cargo install clippy-sarif || clippy-sarif --version
cargo install sarif-fmt || sarif-fmt --version
- name: Run rust-clippy
run:
cargo clippy
--all
--all-features
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
just clippy-to-file
continue-on-error: true
- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v3
Expand Down
3 changes: 2 additions & 1 deletion examples/dependencies/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ local-test:
$PSNativeCommandUseErrorActionPreference = $true

cargo build -p pulumi_wasm_runner --release
cargo component build -p pulumi_wasm_example_multiple_providers --release
cargo component build -p pulumi_wasm --release
cargo component build -p pulumi_wasm_example_dependencies --release
cargo component build -p pulumi_wasm_random_provider --release
$env:PULUMI_CONFIG_PASSPHRASE=" "
pulumi destroy -y
Expand Down
5 changes: 3 additions & 2 deletions examples/docker/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ local-test:
$PSNativeCommandUseErrorActionPreference = $true

cargo build -p pulumi_wasm_runner --release
cargo component build -p pulumi_wasm_example_multiple_providers --release
cargo component build -p pulumi_wasm_random_provider --release
cargo component build -p pulumi_wasm --release
cargo component build -p pulumi_wasm_example_docker --release
cargo component build -p pulumi_wasm_docker_provider --release
$env:PULUMI_CONFIG_PASSPHRASE=" "
pulumi destroy -y
pulumi up -y
8 changes: 8 additions & 0 deletions examples/docker/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Error;

use pulumi_wasm_docker::get_remote_image::GetRemoteImageArgs;
use pulumi_wasm_docker::{container, image, ContainerLabel, DockerBuild};
use pulumi_wasm_rust::{add_export, pulumi_main};

Expand Down Expand Up @@ -33,8 +34,15 @@ fn test_main() -> Result<(), Error> {
.build_struct(),
);

let remote_image = pulumi_wasm_docker::get_remote_image::invoke(
GetRemoteImageArgs::builder()
.name("public.ecr.aws/ubuntu/ubuntu:latest")
.build_struct(),
);

add_export("logs", &cont.container_logs);
add_export("image_id", &image.image_name);
add_export("labels", &cont.labels.map(|f| f[0].value.clone()));
add_export("remote_image_id", &remote_image.repo_digest);
Ok(())
}
7 changes: 7 additions & 0 deletions examples/docker/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,16 @@ fn test_integration() -> Result<(), anyhow::Error> {
.as_str()
.ok_or(anyhow!("[labels] is not a string"))?;

let remote_image_id = stack
.pointer("/remote_image_id")
.ok_or(anyhow!("Cannot find [remote_image_id] in stack export"))?
.as_str()
.ok_or(anyhow!("[remote_image_id] is not a string"))?;

assert!(logs.contains("Hello World!"));
assert!(!image_id.is_empty());
assert!(labels.contains("value_1"));
assert!(remote_image_id.starts_with("public.ecr.aws/ubuntu/ubuntu@sha256:"));

Ok(())
}
1 change: 1 addition & 0 deletions examples/multiple_providers/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local-test:
$PSNativeCommandUseErrorActionPreference = $true

cargo build -p pulumi_wasm_runner --release
cargo component build -p pulumi_wasm --release
cargo component build -p pulumi_wasm_example_multiple_providers --release
cargo component build -p pulumi_wasm_docker_provider --release
cargo component build -p pulumi_wasm_random_provider --release
Expand Down
3 changes: 2 additions & 1 deletion examples/simple/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ local-test:
$PSNativeCommandUseErrorActionPreference = $true

cargo build -p pulumi_wasm_runner --release
cargo component build -p pulumi_wasm_example_multiple_providers --release
cargo component build -p pulumi_wasm --release
cargo component build -p pulumi_wasm_example_simple --release
cargo component build -p pulumi_wasm_random_provider --release
$env:PULUMI_CONFIG_PASSPHRASE=" "
pulumi destroy -y
Expand Down
6 changes: 3 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ fmt-clippy:
cargo clippy --all-features --fix --allow-dirty --allow-staged {{FORMATTABLE_PROJECTS}}
just fmt

clippy-to-file:
cargo clippy --all-features --message-format=json {{FORMATTABLE_PROJECTS}} | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt

regenerate-provider-list:
cargo run -p regenerate_providers

Expand All @@ -98,9 +101,6 @@ regenerate-providers:
cargo run -p pulumi_wasm_generator -- gen-rust --remove true --schema providers/cloudflare.json --output providers/pulumi_wasm_provider_cloudflare_rust
# DO NOT EDIT - REGENERATE-PROVIDERS - END

regenerate-and-fmt:
just regenerate-providers build-wasm-components fmt

publish:
cargo publish -p pulumi_wasm_wit --all-features
cargo publish -p pulumi_wasm_proto --all-features
Expand Down
Loading

0 comments on commit 1a709bf

Please sign in to comment.