From e8354c7f39380ae346941ca7d002f03b81cf9942 Mon Sep 17 00:00:00 2001 From: Andrzej Ressel Date: Sun, 22 Dec 2024 02:28:36 +0100 Subject: [PATCH] Namespaces --- examples/docker/src/lib.rs | 8 +- examples/typesystem/src/lib.rs | 24 ++- .../src/lib.rs | 6 +- .../{d1_database.rs => d_1_database.rs} | 0 .../src/resource/mod.rs | 6 +- .../resource/{r2_bucket.rs => r_2_bucket.rs} | 0 .../{web3_hostname.rs => web_3_hostname.rs} | 0 .../src/lib.rs | 6 +- .../src/function/mod.rs | 0 .../src/types/mod.rs | 1 - .../src/function/deep/mod.rs | 1 + .../src/function/deep/nested/mod.rs | 1 + .../src/function/deep/nested/module/mod.rs | 1 + .../deep/nested/module/some_function.rs | 17 ++ .../src/function/mod.rs | 1 + .../src/lib.rs | 5 +- .../src/resource/deep/mod.rs | 1 + .../src/resource/deep/nested/mod.rs | 1 + .../src/resource/deep/nested/module/mod.rs | 1 + .../deep/nested/module/some_resource.rs | 23 +++ .../src/resource/mod.rs | 1 + .../src/types/deep/mod.rs | 1 + .../src/types/deep/nested/mod.rs | 1 + .../src/types/deep/nested/module/mod.rs | 2 + .../src/types/deep/nested/module/some_type.rs | 4 + .../src/types/mod.rs | 1 + .../wit/world.wit | 29 +++ providers/typesystem.json | 14 ++ pulumi_wasm_generator_lib/src/lib.rs | 48 +---- pulumi_wasm_generator_lib/src/model.rs | 5 +- .../functions/function_code.rs.handlebars | 58 ++++++ .../src/output/rust/functions/mod.rs | 46 +++++ .../functions/source_code_function_code.rs | 97 ++++++++++ .../functions/source_code_function_mod.rs | 32 ++++ .../src/output/rust/lib.rs.handlebars | 6 +- .../src/output/rust/mod.rs | 47 +---- .../output/rust/resource_mod.rs.handlebars | 3 - .../src/output/rust/resources/mod.rs | 52 +++++ .../resource_code.rs.handlebars | 20 +- .../resources/source_code_resource_code.rs | 93 +++++++++ .../resources/source_code_resource_mod.rs | 32 ++++ .../output/rust/source_code_resource_code.rs | 149 --------------- .../output/rust/source_code_resource_mod.rs | 42 ---- .../src/output/rust/types/mod.rs | 49 +++++ .../{ => types}/source_code_types_code.rs | 179 +++--------------- .../rust/{ => types}/source_code_types_mod.rs | 0 .../rust/{ => types}/types_code.rs.handlebars | 0 .../types_code_integer_enum.rs.handlebars | 0 .../types_code_number_enum.rs.handlebars | 0 .../types_code_string_enum.rs.handlebars | 0 .../src/output/rust/types_mod.rs.handlebars | 4 - .../templates/function_mod.rs.jinja | 6 + .../templates/resource_mod.rs.jinja | 6 + .../array-of-enum-map/lib/src/function/mod.rs | 0 .../output/array-of-enum-map/lib/src/lib.rs | 3 +- .../lib/src/resource/ExampleServer.rs | 25 --- .../cyclic-types/lib/src/function/mod.rs | 0 .../tests/output/cyclic-types/lib/src/lib.rs | 3 +- .../cyclic-types/lib/src/resource/mod.rs | 0 .../different-enum/lib/src/function/mod.rs | 0 .../output/different-enum/lib/src/lib.rs | 3 +- .../different-enum/lib/src/resource/mod.rs | 3 +- .../lib/src/resource/tree/mod.rs | 1 + .../lib/src/resource/tree/v1/mod.rs | 2 + .../v1/nursery.rs} | 0 .../v1/rubber_tree.rs} | 0 .../lib/src/resource/tree_nursery.rs | 28 --- .../lib/src/resource/tree_rubber_tree.rs | 45 ----- .../lib/src/types/tree/diameter.rs | 32 ---- .../different-enum/lib/src/types/tree/farm.rs | 7 - .../lib/src/types/tree/rubber_tree_variety.rs | 11 -- .../lib/src/types/tree/tree_size.rs | 9 - .../provider/src/resource/tree_nursery.rs | 26 --- .../provider/src/resource/tree_rubber_tree.rs | 41 ---- .../output/functions-secrets/lib/src/lib.rs | 3 +- .../functions-secrets/lib/src/resource/mod.rs | 0 .../functions-secrets/lib/src/types/mod.rs | 1 - .../mini-awsnative/lib/src/function/mod.rs | 0 .../output/mini-awsnative/lib/src/lib.rs | 3 +- .../mini-awsnative/lib/src/resource/mod.rs | 0 .../lib/src/types/ignore_tags.rs | 14 -- .../lib/src/function/mod.rs | 0 .../lib/src/resource/deeply/mod.rs | 1 + .../lib/src/resource/deeply/nested/mod.rs | 1 + .../src/resource/deeply/nested/module/mod.rs | 1 + .../nested/module/resource.rs} | 0 .../lib/src/resource/mod.rs | 2 +- .../lib/src/types/mod.rs | 1 - .../nested-module/lib/src/function/mod.rs | 0 .../nested-module/lib/src/resource/mod.rs | 2 +- .../lib/src/resource/nested/mod.rs | 1 + .../lib/src/resource/nested/module/mod.rs | 1 + .../module/resource.rs} | 0 .../lib/src/resource/nested_resource.rs | 25 --- .../output/nested-module/lib/src/types/mod.rs | 1 - .../provider/src/resource/nested_resource.rs | 29 --- .../output-funcs-edgeorder/lib/src/lib.rs | 6 +- .../lib/src/resource/mod.rs | 0 .../tests/output/output-funcs/lib/src/lib.rs | 6 +- .../output-funcs/lib/src/resource/mod.rs | 0 .../plain-object-defaults/lib/src/lib.rs | 6 +- .../lib/src/resource/moduleTest.rs | 26 --- .../lib/src/lib.rs | 6 +- .../lib/src/resource/moduleTest.rs | 26 --- .../unions-inline/lib/src/function/mod.rs | 0 .../tests/output/unions-inline/lib/src/lib.rs | 3 +- .../lib/src/resource/ExampleServer.rs | 25 --- .../lib/src/function/mod.rs | 0 .../unions-inside-arrays/lib/src/lib.rs | 3 +- .../lib/src/resource/ExampleServer.rs | 25 --- 110 files changed, 677 insertions(+), 910 deletions(-) rename providers/pulumi_wasm_provider_cloudflare_rust/src/resource/{d1_database.rs => d_1_database.rs} (100%) rename providers/pulumi_wasm_provider_cloudflare_rust/src/resource/{r2_bucket.rs => r_2_bucket.rs} (100%) rename providers/pulumi_wasm_provider_cloudflare_rust/src/resource/{web3_hostname.rs => web_3_hostname.rs} (100%) delete mode 100644 providers/pulumi_wasm_provider_random_rust/src/function/mod.rs delete mode 100644 providers/pulumi_wasm_provider_random_rust/src/types/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/module/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/module/some_function.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/module/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/module/some_resource.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/module/mod.rs create mode 100644 providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/module/some_type.rs create mode 100644 pulumi_wasm_generator_lib/src/output/rust/functions/function_code.rs.handlebars create mode 100644 pulumi_wasm_generator_lib/src/output/rust/functions/mod.rs create mode 100644 pulumi_wasm_generator_lib/src/output/rust/functions/source_code_function_code.rs create mode 100644 pulumi_wasm_generator_lib/src/output/rust/functions/source_code_function_mod.rs delete mode 100644 pulumi_wasm_generator_lib/src/output/rust/resource_mod.rs.handlebars create mode 100644 pulumi_wasm_generator_lib/src/output/rust/resources/mod.rs rename pulumi_wasm_generator_lib/src/output/rust/{ => resources}/resource_code.rs.handlebars (56%) create mode 100644 pulumi_wasm_generator_lib/src/output/rust/resources/source_code_resource_code.rs create mode 100644 pulumi_wasm_generator_lib/src/output/rust/resources/source_code_resource_mod.rs delete mode 100644 pulumi_wasm_generator_lib/src/output/rust/source_code_resource_code.rs delete mode 100644 pulumi_wasm_generator_lib/src/output/rust/source_code_resource_mod.rs create mode 100644 pulumi_wasm_generator_lib/src/output/rust/types/mod.rs rename pulumi_wasm_generator_lib/src/output/rust/{ => types}/source_code_types_code.rs (58%) rename pulumi_wasm_generator_lib/src/output/rust/{ => types}/source_code_types_mod.rs (100%) rename pulumi_wasm_generator_lib/src/output/rust/{ => types}/types_code.rs.handlebars (100%) rename pulumi_wasm_generator_lib/src/output/rust/{ => types}/types_code_integer_enum.rs.handlebars (100%) rename pulumi_wasm_generator_lib/src/output/rust/{ => types}/types_code_number_enum.rs.handlebars (100%) rename pulumi_wasm_generator_lib/src/output/rust/{ => types}/types_code_string_enum.rs.handlebars (100%) delete mode 100644 pulumi_wasm_generator_lib/src/output/rust/types_mod.rs.handlebars create mode 100644 pulumi_wasm_generator_lib/templates/function_mod.rs.jinja create mode 100644 pulumi_wasm_generator_lib/templates/resource_mod.rs.jinja delete mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/function/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/ExampleServer.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/function/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/resource/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/function/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/v1/mod.rs rename pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/{tree_v1_nursery.rs => tree/v1/nursery.rs} (100%) rename pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/{tree_v1_rubber_tree.rs => tree/v1/rubber_tree.rs} (100%) delete mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_nursery.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_rubber_tree.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/diameter.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/farm.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/rubber_tree_variety.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/tree_size.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_nursery.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_rubber_tree.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/resource/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/types/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/function/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/resource/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/types/ignore_tags.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/function/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/module/mod.rs rename pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/{deeply_nested_module_resource.rs => deeply/nested/module/resource.rs} (100%) delete mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/types/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/function/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/mod.rs create mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/module/mod.rs rename pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/{nested_module_resource.rs => nested/module/resource.rs} (100%) delete mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested_resource.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/types/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/nested-module/provider/src/resource/nested_resource.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/output-funcs-edgeorder/lib/src/resource/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/output-funcs/lib/src/resource/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/plain-object-defaults/lib/src/resource/moduleTest.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/plain-object-disable-defaults/lib/src/resource/moduleTest.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/function/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/resource/ExampleServer.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/function/mod.rs delete mode 100644 pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/resource/ExampleServer.rs diff --git a/examples/docker/src/lib.rs b/examples/docker/src/lib.rs index fd6e15332..14e8e9f42 100644 --- a/examples/docker/src/lib.rs +++ b/examples/docker/src/lib.rs @@ -1,7 +1,7 @@ use anyhow::Error; - -use pulumi_wasm_docker::get_remote_image::GetRemoteImageArgs; -use pulumi_wasm_docker::{container, image, ContainerLabel, DockerBuild}; +use pulumi_wasm_docker::function::get_remote_image::GetRemoteImageArgs; +use pulumi_wasm_docker::types::{ContainerLabel, DockerBuild}; +use pulumi_wasm_docker::{container, image}; use pulumi_wasm_rust::{add_export, pulumi_main}; #[pulumi_main] @@ -34,7 +34,7 @@ fn test_main() -> Result<(), Error> { .build_struct(), ); - let remote_image = pulumi_wasm_docker::get_remote_image::invoke( + let remote_image = pulumi_wasm_docker::function::get_remote_image::invoke( GetRemoteImageArgs::builder() .name("public.ecr.aws/ubuntu/ubuntu:latest") .build_struct(), diff --git a/examples/typesystem/src/lib.rs b/examples/typesystem/src/lib.rs index b9f09bb8f..21105f32c 100644 --- a/examples/typesystem/src/lib.rs +++ b/examples/typesystem/src/lib.rs @@ -2,16 +2,20 @@ mod tests { use pulumi_wasm_provider_common::OneOf2; use pulumi_wasm_rust::Output; - use pulumi_wasm_typesystem::typesystem_server::TypesystemServerArgs; - use pulumi_wasm_typesystem::{ + use pulumi_wasm_typesystem::deep::nested::module::some_resource::SomeResourceArgs; + use pulumi_wasm_typesystem::types::{ IntegerEnum, MyEnum, NumberEnum, UnionCase1, UnionCase2, UnionCaseWithConst1, UnionCaseWithConst2, }; + use pulumi_wasm_typesystem::typesystem_server::TypesystemServerArgs; use std::panic::catch_unwind; #[test] fn test_compilation() { let _ = catch_unwind(compilation_test); + let _ = catch_unwind(function_compilation_test); + let _ = catch_unwind(resource_compilation_test); + let _ = catch_unwind(types_compilation_test); } #[test] @@ -180,4 +184,20 @@ mod tests { // let _ = TypesystemServerArgs::builder() // .required_string_input(true); } + + fn resource_compilation_test() { + let _ = pulumi_wasm_typesystem::deep::nested::module::some_resource::create( + "test", + SomeResourceArgs::builder().build_struct(), + ); + } + + fn function_compilation_test() { + let _ = pulumi_wasm_typesystem::function::deep::nested::module::some_function::invoke(); + } + + fn types_compilation_test() { + let _ = + pulumi_wasm_typesystem::types::deep::nested::module::SomeType::builder().build_struct(); + } } diff --git a/providers/pulumi_wasm_provider_cloudflare_rust/src/lib.rs b/providers/pulumi_wasm_provider_cloudflare_rust/src/lib.rs index ec5e19cd7..0e20730b2 100644 --- a/providers/pulumi_wasm_provider_cloudflare_rust/src/lib.rs +++ b/providers/pulumi_wasm_provider_cloudflare_rust/src/lib.rs @@ -4,11 +4,9 @@ use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface:: mod resource; pub use resource::*; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod function; -pub use function::*; +pub mod function; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/d1_database.rs b/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/d_1_database.rs similarity index 100% rename from providers/pulumi_wasm_provider_cloudflare_rust/src/resource/d1_database.rs rename to providers/pulumi_wasm_provider_cloudflare_rust/src/resource/d_1_database.rs diff --git a/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/mod.rs b/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/mod.rs index 3244c1767..f7edc96fc 100644 --- a/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/mod.rs +++ b/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/mod.rs @@ -31,7 +31,7 @@ pub mod custom_hostname; pub mod custom_hostname_fallback_origin; pub mod custom_pages; pub mod custom_ssl; -pub mod d1_database; +pub mod d_1_database; pub mod device_dex_test; pub mod device_managed_networks; pub mod device_policy_certificates; @@ -76,7 +76,7 @@ pub mod page_rule; pub mod pages_domain; pub mod pages_project; pub mod queue; -pub mod r2_bucket; +pub mod r_2_bucket; pub mod rate_limit; pub mod record; pub mod regional_hostname; @@ -104,7 +104,7 @@ pub mod waiting_room; pub mod waiting_room_event; pub mod waiting_room_rules; pub mod waiting_room_settings; -pub mod web3_hostname; +pub mod web_3_hostname; pub mod web_analytics_rule; pub mod web_analytics_site; pub mod worker_cron_trigger; diff --git a/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/r2_bucket.rs b/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/r_2_bucket.rs similarity index 100% rename from providers/pulumi_wasm_provider_cloudflare_rust/src/resource/r2_bucket.rs rename to providers/pulumi_wasm_provider_cloudflare_rust/src/resource/r_2_bucket.rs diff --git a/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/web3_hostname.rs b/providers/pulumi_wasm_provider_cloudflare_rust/src/resource/web_3_hostname.rs similarity index 100% rename from providers/pulumi_wasm_provider_cloudflare_rust/src/resource/web3_hostname.rs rename to providers/pulumi_wasm_provider_cloudflare_rust/src/resource/web_3_hostname.rs diff --git a/providers/pulumi_wasm_provider_docker_rust/src/lib.rs b/providers/pulumi_wasm_provider_docker_rust/src/lib.rs index c6b679f5c..732464d67 100644 --- a/providers/pulumi_wasm_provider_docker_rust/src/lib.rs +++ b/providers/pulumi_wasm_provider_docker_rust/src/lib.rs @@ -4,11 +4,9 @@ use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface:: mod resource; pub use resource::*; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod function; -pub use function::*; +pub mod function; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/providers/pulumi_wasm_provider_random_rust/src/function/mod.rs b/providers/pulumi_wasm_provider_random_rust/src/function/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/providers/pulumi_wasm_provider_random_rust/src/types/mod.rs b/providers/pulumi_wasm_provider_random_rust/src/types/mod.rs deleted file mode 100644 index 8b1378917..000000000 --- a/providers/pulumi_wasm_provider_random_rust/src/types/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/mod.rs new file mode 100644 index 000000000..e5f480ded --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/mod.rs @@ -0,0 +1 @@ +pub mod nested; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/mod.rs new file mode 100644 index 000000000..cc57a848e --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/mod.rs @@ -0,0 +1 @@ +pub mod module; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/module/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/module/mod.rs new file mode 100644 index 000000000..d81749220 --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/module/mod.rs @@ -0,0 +1 @@ +pub mod some_function; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/module/some_function.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/module/some_function.rs new file mode 100644 index 000000000..07e44852f --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/function/deep/nested/module/some_function.rs @@ -0,0 +1,17 @@ + + +pub struct SomeFunctionResult { +} + +/// +/// Registers a new resource with the given unique name and arguments +/// +pub fn invoke( +) -> SomeFunctionResult { + + let result = crate::bindings::pulumi::typesystem::deep_nested_module_some_function::invoke( + ); + + SomeFunctionResult { + } +} diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/function/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/function/mod.rs index e69de29bb..0e6a95b8a 100644 --- a/providers/pulumi_wasm_provider_typesystem_rust/src/function/mod.rs +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/function/mod.rs @@ -0,0 +1 @@ +pub mod deep; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/lib.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/lib.rs index c76535d8a..766d1e283 100644 --- a/providers/pulumi_wasm_provider_typesystem_rust/src/lib.rs +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/lib.rs @@ -4,8 +4,9 @@ use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface:: mod resource; pub use resource::*; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod function; +#[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/mod.rs new file mode 100644 index 000000000..e5f480ded --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/mod.rs @@ -0,0 +1 @@ +pub mod nested; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/mod.rs new file mode 100644 index 000000000..cc57a848e --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/mod.rs @@ -0,0 +1 @@ +pub mod module; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/module/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/module/mod.rs new file mode 100644 index 000000000..ae5527841 --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/module/mod.rs @@ -0,0 +1 @@ +pub mod some_resource; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/module/some_resource.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/module/some_resource.rs new file mode 100644 index 000000000..7fbf1d0b9 --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/deep/nested/module/some_resource.rs @@ -0,0 +1,23 @@ + +#[derive(bon::Builder, Clone)] +#[builder(finish_fn = build_struct)] +pub struct SomeResourceArgs { + #[builder(into, default)] + pub string_input: pulumi_wasm_rust::Output>, +} + +pub struct SomeResourceResult { +} + +/// +/// Registers a new resource with the given unique name and arguments +/// +pub fn create(name: &str, args: SomeResourceArgs) -> SomeResourceResult { + + let result = crate::bindings::pulumi::typesystem::deep_nested_module_some_resource::invoke(name, &crate::bindings::pulumi::typesystem::deep_nested_module_some_resource::Args { + string_input: &args.string_input.get_inner(), + }); + + SomeResourceResult { + } +} diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/resource/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/mod.rs index cd4926b1b..157f91dcd 100644 --- a/providers/pulumi_wasm_provider_typesystem_rust/src/resource/mod.rs +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/resource/mod.rs @@ -1 +1,2 @@ pub mod typesystem_server; +pub mod deep; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/mod.rs new file mode 100644 index 000000000..e5f480ded --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/mod.rs @@ -0,0 +1 @@ +pub mod nested; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/mod.rs new file mode 100644 index 000000000..cc57a848e --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/mod.rs @@ -0,0 +1 @@ +pub mod module; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/module/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/module/mod.rs new file mode 100644 index 000000000..4c38013ef --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/module/mod.rs @@ -0,0 +1,2 @@ +mod some_type; +pub use some_type::*; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/module/some_type.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/module/some_type.rs new file mode 100644 index 000000000..664956f08 --- /dev/null +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/types/deep/nested/module/some_type.rs @@ -0,0 +1,4 @@ +#[derive(serde::Deserialize, serde::Serialize, bon::Builder, Debug, PartialEq, Clone)] +#[builder(finish_fn = build_struct)] +pub struct SomeType { +} diff --git a/providers/pulumi_wasm_provider_typesystem_rust/src/types/mod.rs b/providers/pulumi_wasm_provider_typesystem_rust/src/types/mod.rs index 63f8d24a7..d90def464 100644 --- a/providers/pulumi_wasm_provider_typesystem_rust/src/types/mod.rs +++ b/providers/pulumi_wasm_provider_typesystem_rust/src/types/mod.rs @@ -12,3 +12,4 @@ mod union_case_with_const_1; pub use union_case_with_const_1::*; mod union_case_with_const_2; pub use union_case_with_const_2::*; +pub mod deep; diff --git a/providers/pulumi_wasm_provider_typesystem_rust/wit/world.wit b/providers/pulumi_wasm_provider_typesystem_rust/wit/world.wit index 8180d219a..83a133eb9 100644 --- a/providers/pulumi_wasm_provider_typesystem_rust/wit/world.wit +++ b/providers/pulumi_wasm_provider_typesystem_rust/wit/world.wit @@ -3,10 +3,14 @@ package pulumi:typesystem@1.0.0--0.0.0-DEV; world typesystem-pulumi { import component:pulumi-wasm/register-interface@0.0.0-DEV; export typesystem-server; + export deep-nested-module-some-resource; + export deep-nested-module-some-function; } world typesystem-pulumi-client { import typesystem-server; + import deep-nested-module-some-resource; + import deep-nested-module-some-function; } interface typesystem-server { @@ -30,4 +34,29 @@ interface typesystem-server { ); } +interface deep-nested-module-some-resource { + use component:pulumi-wasm/output-interface@0.0.0-DEV.{output}; + + record args { + string-input: borrow, + } + + + invoke: func( + name: string, + args: args + ); + +} + +interface deep-nested-module-some-function { + + use component:pulumi-wasm/output-interface@0.0.0-DEV.{output}; + + + + invoke: func( + ); + +} diff --git a/providers/typesystem.json b/providers/typesystem.json index 0d69890e3..5327e7d1c 100644 --- a/providers/typesystem.json +++ b/providers/typesystem.json @@ -68,6 +68,13 @@ "required_string_array", "required_union" ] + }, + "typesystem:deep/nested/module:SomeResource": { + "inputProperties": { + "string_input": { + "type": "string" + } + } } }, "types": { @@ -164,6 +171,13 @@ "value": 2 } ] + }, + "typesystem:deep/nested/module:SomeType": { + "type": "object" + } + }, + "functions": { + "typesystem:deep/nested/module:someFunction": { } }, "language": { diff --git a/pulumi_wasm_generator_lib/src/lib.rs b/pulumi_wasm_generator_lib/src/lib.rs index 749df22b7..9ec0d10aa 100644 --- a/pulumi_wasm_generator_lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/src/lib.rs @@ -3,9 +3,12 @@ use std::fs::File; use std::io::{BufReader, Write}; use std::path::Path; -use crate::output::rust::generate_types_code; +use crate::output::rust::functions::generate_function_code; +use crate::output::rust::resources::generate_resources_code; use crate::schema::Package; use anyhow::{Context, Result}; +use output::rust::types::generate_types_code; + mod code_generation; mod description; mod model; @@ -37,48 +40,9 @@ pub fn generate_rust_library(schema_json: &Path, result_path: &Path) -> Result<( lib_file .write_all(output::rust::source_code_librs::generate_source_code(&package).as_bytes())?; - let mut source_file = File::create(result_path.join("src").join("resource").join("mod.rs"))?; - source_file.write_all( - output::rust::source_code_resource_mod::generate_source_code(&package).as_bytes(), - )?; - - let mut source_file = File::create(result_path.join("src").join("function").join("mod.rs"))?; - source_file.write_all( - output::rust::source_code_function_mod::generate_source_code(&package).as_bytes(), - )?; - generate_types_code(&package, result_path); - - // output::rust::source_code_types_code::generate_source_code(&package) - // .iter() - // .for_each(|(path, content)| { - // let mut lib_file = - // File::create(result_path.join("src").join("types").join(path)).unwrap(); - // lib_file.write_all(content.as_bytes()).unwrap(); - // }); - - // let mut types_file = File::create(result_path.join("src").join("types.rs"))?; - // types_file - // .write_all(output::rust::source_code_types::generate_source_code(&package).as_ref())?; - - // File::create(result_path.join("src").join("types").join("mod.rs"))? - // .write_all(output::rust::source_code_types_mod::generate_source_code(&package).as_ref())?; - - output::rust::source_code_resource_code::generate_source_code(&package) - .iter() - .for_each(|(path, content)| { - let mut lib_file = - File::create(result_path.join("src").join("resource").join(path)).unwrap(); - lib_file.write_all(content.as_bytes()).unwrap(); - }); - - output::rust::source_code_function_code::generate_source_code(&package) - .iter() - .for_each(|(path, content)| { - let mut lib_file = - File::create(result_path.join("src").join("function").join(path)).unwrap(); - lib_file.write_all(content.as_bytes()).unwrap(); - }); + generate_resources_code(&package, result_path); + generate_function_code(&package, result_path); Ok(()) } diff --git a/pulumi_wasm_generator_lib/src/model.rs b/pulumi_wasm_generator_lib/src/model.rs index d960c5276..8114216b6 100644 --- a/pulumi_wasm_generator_lib/src/model.rs +++ b/pulumi_wasm_generator_lib/src/model.rs @@ -228,10 +228,7 @@ impl ElementId { } pub(crate) fn get_rust_function_name(&self) -> String { - self.name - .clone() - .from_case(Case::UpperCamel) - .to_case(Case::Snake) + self.name.clone().from_case(UpperCamel).to_case(Case::Snake) } pub(crate) fn get_rust_namespace_name(&self) -> String { diff --git a/pulumi_wasm_generator_lib/src/output/rust/functions/function_code.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/functions/function_code.rs.handlebars new file mode 100644 index 000000000..ecca1b5be --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/functions/function_code.rs.handlebars @@ -0,0 +1,58 @@ +{{#each function.description_lines}} +//! {{&this}} +{{/each}} + +{{#if function.input_properties}} +#[derive(bon::Builder, Clone)] +#[builder(finish_fn = build_struct)] +pub struct {{function.struct_name}}Args { +{{#each function.input_properties}} + {{#each description_lines}} + /// {{&this}} + {{/each}} + {{#if default}} + #[builder(into, default)] + {{else if skip}} + #[builder(skip)] + {{else}} + #[builder(into)] + {{/if}} + {{#unless private}}pub {{/unless}}{{arg_name}}: pulumi_wasm_rust::Output<{{&type_}}>, +{{/each}} +} +{{/if}} + +pub struct {{function.struct_name}}Result { +{{#each function.output_properties}} + {{#each description_lines}} + /// {{&this}} + {{/each}} + pub {{arg_name}}: pulumi_wasm_rust::Output<{{&type_}}>, +{{/each}} +} + +/// +/// Registers a new resource with the given unique name and arguments +/// +pub fn invoke( +{{#if function.input_properties}} + args: {{function.struct_name}}Args +{{/if}} +) -> {{function.struct_name}}Result { + + let result = crate::bindings::pulumi::{{function.package_name}}::{{function.name}}::invoke( +{{#if function.input_properties}} + &crate::bindings::pulumi::{{function.package_name}}::{{function.name}}::Args { + {{#each function.input_properties}} + {{arg_name}}: &args.{{arg_name}}.get_inner(), + {{/each}} + } +{{/if}} + ); + + {{function.struct_name}}Result { + {{#each function.output_properties}} + {{arg_name}}: crate::into_domain(result.{{arg_name}}), + {{/each}} + } +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/functions/mod.rs b/pulumi_wasm_generator_lib/src/output/rust/functions/mod.rs new file mode 100644 index 000000000..c97e16996 --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/functions/mod.rs @@ -0,0 +1,46 @@ +use crate::model::{ElementId, Package}; +use crate::output::rust::functions::source_code_function_code::generate_single_function_source_code; +use crate::output::rust::functions::source_code_function_mod::generate_mod; +use crate::output::rust::TreeNode; +use convert_case::{Case, Casing}; +use std::fs::File; +use std::io::Write; + +mod source_code_function_code; +mod source_code_function_mod; + +pub(crate) fn generate_function_code(package: &Package, result_path: &std::path::Path) { + if package.functions.is_empty() { + return; + } + let mut tree = TreeNode::new(); + + for element_id in package.functions.keys() { + tree.insert(element_id.clone()); + } + + let root = result_path.join("src").join("function"); + + generate_files(package, &tree, &root); +} + +fn generate_files(package: &Package, tree_node: &TreeNode, current_path: &std::path::Path) { + match tree_node { + TreeNode::Namespace(ns) => { + for (name, node) in ns { + generate_files(package, node, ¤t_path.join(name)); + } + let content = generate_mod(ns); + let mut file = File::create(current_path.join("mod.rs")).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + TreeNode::Leaf(ref leaf) => { + let file_name = format!("{}.rs", leaf.get_rust_struct_name().to_case(Case::Snake)); + let content = generate_single_function_source_code(package, leaf); + let dir = current_path.parent().unwrap(); + std::fs::create_dir_all(dir).unwrap(); + let mut file = File::create(current_path.parent().unwrap().join(file_name)).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + } +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/functions/source_code_function_code.rs b/pulumi_wasm_generator_lib/src/output/rust/functions/source_code_function_code.rs new file mode 100644 index 000000000..79960af94 --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/functions/source_code_function_code.rs @@ -0,0 +1,97 @@ +use crate::model::{ElementId, Type}; +use convert_case::{Case, Casing}; +use handlebars::Handlebars; +use serde::Serialize; +use serde_json::json; +use std::collections::HashMap; +use std::path::PathBuf; + +static TEMPLATE: &str = include_str!("function_code.rs.handlebars"); + +#[derive(Serialize)] +struct InputProperty { + name: String, + arg_name: String, + type_: String, + description_lines: Vec, + default: bool, + skip: bool, + private: bool, +} + +#[derive(Serialize)] +struct OutputProperty { + name: String, + arg_name: String, + type_: String, + description_lines: Vec, +} + +#[derive(Serialize)] +struct Function { + name: String, + package_name: String, + input_properties: Vec, + output_properties: Vec, + struct_name: String, + function_name: String, + description_lines: Vec, +} + +fn convert_function(package: &crate::model::Package, element_id: &ElementId) -> Function { + let function = package.functions.get(element_id).unwrap(); + Function { + name: element_id.get_rust_namespace_name(), + package_name: package.name.clone().replace("-", "_"), + struct_name: element_id.name.clone().to_case(Case::Pascal), + function_name: element_id.get_rust_function_name(), + description_lines: crate::utils::to_lines( + function.description.clone(), + package, + Some(element_id.clone()), + ), + input_properties: function + .input_properties + .iter() + .map(|input_property| InputProperty { + name: input_property.name.clone(), + arg_name: input_property.get_rust_argument_name(), + default: matches!(input_property.r#type, Type::Option(_)), + skip: matches!(input_property.r#type, Type::ConstString(_)), + private: matches!(input_property.r#type, Type::ConstString(_)), + type_: input_property.r#type.get_rust_type(), + description_lines: crate::utils::to_lines( + input_property.description.clone(), + package, + None, + ), + }) + .collect(), + output_properties: function + .output_properties + .iter() + .map(|output_property| OutputProperty { + name: output_property.name.clone(), + arg_name: output_property.get_rust_argument_name(), + type_: output_property.r#type.get_rust_type(), + description_lines: crate::utils::to_lines( + output_property.description.clone(), + package, + None, + ), + }) + .collect(), + } +} + +pub(crate) fn generate_single_function_source_code( + package: &crate::model::Package, + element_id: &ElementId, +) -> String { + let handlebars = Handlebars::new(); + let function = convert_function(package, element_id); + + handlebars + .render_template(TEMPLATE, &json!({"function": function})) + .unwrap() +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/functions/source_code_function_mod.rs b/pulumi_wasm_generator_lib/src/output/rust/functions/source_code_function_mod.rs new file mode 100644 index 000000000..9c6c33e77 --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/functions/source_code_function_mod.rs @@ -0,0 +1,32 @@ +use crate::output::rust::TreeNode; +use convert_case::{Case, Casing}; +use rinja::Template; +use std::collections::BTreeMap; + +#[derive(Template)] +#[template(path = "function_mod.rs.jinja")] +struct TemplateModel { + files: Vec, + directories: Vec, +} + +pub(crate) fn generate_mod(tree_nodes: &BTreeMap) -> String { + let mut files = Vec::new(); + let mut directories = Vec::new(); + + for (name, tree_node) in tree_nodes { + match tree_node { + TreeNode::Namespace(_) => directories.push(name.clone()), + TreeNode::Leaf(l) => { + files.push(l.get_rust_struct_name().to_case(Case::Snake)); + } + } + } + + TemplateModel { files, directories } + .render() + .unwrap() + .trim() + .to_string() + + "\n" +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/lib.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/lib.rs.handlebars index d3f4d29be..bef062cc0 100644 --- a/pulumi_wasm_generator_lib/src/output/rust/lib.rs.handlebars +++ b/pulumi_wasm_generator_lib/src/output/rust/lib.rs.handlebars @@ -9,13 +9,11 @@ pub use resource::*; {{/if}} {{#if package.contains_functions}} #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod function; -pub use function::*; +pub mod function; {{/if}} {{#if package.contains_types}} #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; {{/if}} mod bindings { diff --git a/pulumi_wasm_generator_lib/src/output/rust/mod.rs b/pulumi_wasm_generator_lib/src/output/rust/mod.rs index 1c39a497f..5cc327e79 100644 --- a/pulumi_wasm_generator_lib/src/output/rust/mod.rs +++ b/pulumi_wasm_generator_lib/src/output/rust/mod.rs @@ -1,18 +1,13 @@ use crate::model::ElementId; -use crate::output::rust::source_code_types_code::generate_single_source_file; -use crate::output::rust::source_code_types_mod::generate_mod; use std::collections::BTreeMap; -use std::fs::File; -use std::io::Write; pub(crate) mod cargo; +pub(crate) mod functions; +pub(crate) mod resources; pub(crate) mod source_code_function_code; pub(crate) mod source_code_function_mod; pub(crate) mod source_code_librs; -pub(crate) mod source_code_resource_code; -pub(crate) mod source_code_resource_mod; -pub(crate) mod source_code_types_code; -pub(crate) mod source_code_types_mod; +pub(crate) mod types; #[derive(Debug)] enum TreeNode { @@ -49,39 +44,3 @@ impl TreeNode { } } } - -pub(crate) fn generate_types_code(package: &crate::model::Package, result_path: &std::path::Path) { - let mut tree = TreeNode::new(); - - for element_id in package.types.keys() { - tree.insert(element_id.clone()); - } - - let root = result_path.join("src").join("types"); - - generate_files(package, &tree, &root); -} - -fn generate_files( - package: &crate::model::Package, - tree_node: &TreeNode, - current_path: &std::path::Path, -) { - match tree_node { - TreeNode::Namespace(ns) => { - for (name, node) in ns { - generate_files(package, node, ¤t_path.join(name)); - } - let content = generate_mod(ns); - let mut file = File::create(current_path.join("mod.rs")).unwrap(); - file.write_all(content.as_bytes()).unwrap(); - } - TreeNode::Leaf(ref leaf) => { - let (file_name, content) = generate_single_source_file(package, leaf); - let dir = current_path.parent().unwrap(); - std::fs::create_dir_all(dir).unwrap(); - let mut file = File::create(current_path.parent().unwrap().join(file_name)).unwrap(); - file.write_all(content.as_bytes()).unwrap(); - } - } -} diff --git a/pulumi_wasm_generator_lib/src/output/rust/resource_mod.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/resource_mod.rs.handlebars deleted file mode 100644 index aac055a22..000000000 --- a/pulumi_wasm_generator_lib/src/output/rust/resource_mod.rs.handlebars +++ /dev/null @@ -1,3 +0,0 @@ -{{#each package.interfaces as |interface|}} -pub mod {{interface.name}}; -{{/each}} \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/src/output/rust/resources/mod.rs b/pulumi_wasm_generator_lib/src/output/rust/resources/mod.rs new file mode 100644 index 000000000..69b214643 --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/resources/mod.rs @@ -0,0 +1,52 @@ +mod source_code_resource_code; +mod source_code_resource_mod; + +use crate::output::rust::resources::source_code_resource_code::generate_single_resource_source_code; +use crate::output::rust::resources::source_code_resource_mod::generate_mod; +use crate::output::rust::TreeNode; +use convert_case::{Case, Casing}; +use std::fs::File; +use std::io::Write; + +pub(crate) fn generate_resources_code( + package: &crate::model::Package, + result_path: &std::path::Path, +) { + if package.resources.is_empty() { + return; + } + let mut tree = TreeNode::new(); + + for element_id in package.resources.keys() { + tree.insert(element_id.clone()); + } + + let root = result_path.join("src").join("resource"); + + generate_files(package, &tree, &root); +} + +fn generate_files( + package: &crate::model::Package, + tree_node: &TreeNode, + current_path: &std::path::Path, +) { + match tree_node { + TreeNode::Namespace(ns) => { + for (name, node) in ns { + generate_files(package, node, ¤t_path.join(name)); + } + let content = generate_mod(ns); + let mut file = File::create(current_path.join("mod.rs")).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + TreeNode::Leaf(ref leaf) => { + let file_name = format!("{}.rs", leaf.get_rust_struct_name().to_case(Case::Snake)); + let content = generate_single_resource_source_code(package, leaf); + let dir = current_path.parent().unwrap(); + std::fs::create_dir_all(dir).unwrap(); + let mut file = File::create(current_path.parent().unwrap().join(file_name)).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + } +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/resource_code.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/resources/resource_code.rs.handlebars similarity index 56% rename from pulumi_wasm_generator_lib/src/output/rust/resource_code.rs.handlebars rename to pulumi_wasm_generator_lib/src/output/rust/resources/resource_code.rs.handlebars index 186146ae5..cd16cf396 100644 --- a/pulumi_wasm_generator_lib/src/output/rust/resource_code.rs.handlebars +++ b/pulumi_wasm_generator_lib/src/output/rust/resources/resource_code.rs.handlebars @@ -1,11 +1,11 @@ -{{#each interface.description_lines}} +{{#each resource.description_lines}} //! {{&this}} {{/each}} #[derive(bon::Builder, Clone)] #[builder(finish_fn = build_struct)] -pub struct {{interface.struct_name}}Args { -{{#each interface.input_properties}} +pub struct {{resource.struct_name}}Args { +{{#each resource.input_properties}} {{#each description_lines}} /// {{&this}} {{/each}} @@ -20,8 +20,8 @@ pub struct {{interface.struct_name}}Args { {{/each}} } -pub struct {{interface.struct_name}}Result { -{{#each interface.output_properties}} +pub struct {{resource.struct_name}}Result { +{{#each resource.output_properties}} {{#each description_lines}} /// {{&this}} {{/each}} @@ -32,16 +32,16 @@ pub struct {{interface.struct_name}}Result { /// /// Registers a new resource with the given unique name and arguments /// -pub fn create(name: &str, args: {{interface.struct_name}}Args) -> {{interface.struct_name}}Result { +pub fn create(name: &str, args: {{resource.struct_name}}Args) -> {{resource.struct_name}}Result { - let result = crate::bindings::pulumi::{{package_name}}::{{interface.name}}::invoke(name, &crate::bindings::pulumi::{{package_name}}::{{interface.name}}::Args { -{{#each interface.input_properties}} + let result = crate::bindings::pulumi::{{resource.package_name}}::{{resource.name}}::invoke(name, &crate::bindings::pulumi::{{resource.package_name}}::{{resource.name}}::Args { +{{#each resource.input_properties}} {{arg_name}}: &args.{{arg_name}}.get_inner(), {{/each}} }); - {{interface.struct_name}}Result { - {{#each interface.output_properties}} + {{resource.struct_name}}Result { + {{#each resource.output_properties}} {{arg_name}}: crate::into_domain(result.{{arg_name}}), {{/each}} } diff --git a/pulumi_wasm_generator_lib/src/output/rust/resources/source_code_resource_code.rs b/pulumi_wasm_generator_lib/src/output/rust/resources/source_code_resource_code.rs new file mode 100644 index 000000000..8a2fb6faa --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/resources/source_code_resource_code.rs @@ -0,0 +1,93 @@ +use crate::model::{ElementId, Type}; +use handlebars::Handlebars; +use serde::Serialize; +use serde_json::json; + +static TEMPLATE: &str = include_str!("resource_code.rs.handlebars"); + +#[derive(Serialize)] +struct InputProperty { + name: String, + arg_name: String, + type_: String, + description_lines: Vec, + default: bool, + skip: bool, + private: bool, +} + +#[derive(Serialize)] +struct OutputProperty { + name: String, + arg_name: String, + type_: String, + description_lines: Vec, +} + +#[derive(Serialize)] +struct Resource { + name: String, + package_name: String, + input_properties: Vec, + output_properties: Vec, + struct_name: String, + function_name: String, + description_lines: Vec, +} + +fn convert_resource(package: &crate::model::Package, element_id: &ElementId) -> Resource { + let resource = package.resources.get(element_id).unwrap(); + Resource { + name: element_id.get_rust_namespace_name(), + package_name: package.name.clone().replace("-", "_"), + struct_name: element_id.name.clone(), + function_name: element_id.get_rust_function_name(), + description_lines: crate::utils::to_lines( + resource.description.clone(), + package, + Some(element_id.clone()), + ), + input_properties: resource + .input_properties + .iter() + .map(|input_property| InputProperty { + name: input_property.name.clone(), + arg_name: input_property.get_rust_argument_name(), + default: matches!(input_property.r#type, Type::Option(_)), + skip: matches!(input_property.r#type, Type::ConstString(_)), + private: matches!(input_property.r#type, Type::ConstString(_)), + type_: input_property.r#type.get_rust_type(), + description_lines: crate::utils::to_lines( + input_property.description.clone(), + package, + None, + ), + }) + .collect(), + output_properties: resource + .output_properties + .iter() + .map(|output_property| OutputProperty { + name: output_property.name.clone(), + arg_name: output_property.get_rust_argument_name(), + type_: output_property.r#type.get_rust_type(), + description_lines: crate::utils::to_lines( + output_property.description.clone(), + package, + None, + ), + }) + .collect(), + } +} + +pub(crate) fn generate_single_resource_source_code( + package: &crate::model::Package, + element_id: &ElementId, +) -> String { + let handlebars = Handlebars::new(); + let resource = convert_resource(package, element_id); + handlebars + .render_template(TEMPLATE, &json!({"resource": resource})) + .unwrap() +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/resources/source_code_resource_mod.rs b/pulumi_wasm_generator_lib/src/output/rust/resources/source_code_resource_mod.rs new file mode 100644 index 000000000..25728b1c0 --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/resources/source_code_resource_mod.rs @@ -0,0 +1,32 @@ +use crate::output::rust::TreeNode; +use convert_case::{Case, Casing}; +use rinja::Template; +use std::collections::BTreeMap; + +#[derive(Template)] +#[template(path = "resource_mod.rs.jinja")] +struct TemplateModel { + files: Vec, + directories: Vec, +} + +pub(crate) fn generate_mod(tree_nodes: &BTreeMap) -> String { + let mut files = Vec::new(); + let mut directories = Vec::new(); + + for (name, tree_node) in tree_nodes { + match tree_node { + TreeNode::Namespace(_) => directories.push(name.clone()), + TreeNode::Leaf(l) => { + files.push(l.get_rust_struct_name().to_case(Case::Snake)); + } + } + } + + TemplateModel { files, directories } + .render() + .unwrap() + .trim() + .to_string() + + "\n" +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/source_code_resource_code.rs b/pulumi_wasm_generator_lib/src/output/rust/source_code_resource_code.rs deleted file mode 100644 index c1bb8f98d..000000000 --- a/pulumi_wasm_generator_lib/src/output/rust/source_code_resource_code.rs +++ /dev/null @@ -1,149 +0,0 @@ -use crate::model::{Resource, Type}; -use convert_case::{Case, Casing}; -use handlebars::Handlebars; -use serde::Serialize; -use serde_json::json; -use std::collections::HashMap; -use std::path::PathBuf; - -static TEMPLATE: &str = include_str!("resource_code.rs.handlebars"); - -#[derive(Serialize)] -struct InputProperty { - name: String, - arg_name: String, - type_: String, - description_lines: Vec, - default: bool, - skip: bool, - private: bool, -} - -#[derive(Serialize)] -struct OutputProperty { - name: String, - arg_name: String, - type_: String, - description_lines: Vec, -} - -#[derive(Serialize)] -struct Interface { - name: String, - input_properties: Vec, - output_properties: Vec, - struct_name: String, - function_name: String, - description_lines: Vec, - discriminated_unions: Vec, -} - -#[derive(Serialize)] -struct Package { - name: String, - interfaces: Vec, -} - -fn convert_model(package: &crate::model::Package) -> Package { - Package { - name: package.name.clone(), - interfaces: package - .resources - .iter() - .map(|(element_id, resource)| Interface { - name: element_id.get_rust_namespace_name(), - struct_name: element_id.name.clone(), - function_name: element_id.get_rust_function_name(), - description_lines: crate::utils::to_lines( - resource.description.clone(), - package, - Some(element_id.clone()), - ), - input_properties: resource - .input_properties - .iter() - .map(|input_property| InputProperty { - name: input_property.name.clone(), - arg_name: input_property.get_rust_argument_name(), - default: matches!(input_property.r#type, Type::Option(_)), - skip: matches!(input_property.r#type, Type::ConstString(_)), - private: matches!(input_property.r#type, Type::ConstString(_)), - type_: input_property.r#type.get_rust_type(), - description_lines: crate::utils::to_lines( - input_property.description.clone(), - package, - None, - ), - }) - .collect(), - output_properties: resource - .output_properties - .iter() - .map(|output_property| OutputProperty { - name: output_property.name.clone(), - arg_name: output_property.get_rust_argument_name(), - type_: output_property.r#type.get_rust_type(), - description_lines: crate::utils::to_lines( - output_property.description.clone(), - package, - None, - ), - }) - .collect(), - discriminated_unions: get_discriminated_unions(resource), - }) - .collect(), - } -} - -fn get_discriminated_unions(res: &Resource) -> Vec { - let mut code: Vec = Vec::new(); - - res.input_properties.iter().for_each(|input_property| { - let tpe = &input_property.r#type; - let name = format!("{}_{}", "input", input_property.name).to_case(Case::Pascal); - if let Some(vec) = tpe.get_internal_discriminated_union() { - code.push(create_discriminated_union(name, &vec)); - } - }); - - code -} - -fn create_discriminated_union(name: String, types: &Vec) -> String { - let mut code = String::new(); - - code.push_str("#[derive(serde::Serialize, serde::Deserialize)]\n"); - code.push_str("#[serde(untagged)]"); - code.push_str(&format!("pub enum {} {{", name)); - - types.iter().enumerate().for_each(|(id, tpe)| { - code.push_str(&format!(" El{}(Box<{}>),", id, tpe.get_rust_type())); - }); - - code.push_str("}\n"); - - code -} - -pub(crate) fn generate_source_code(package: &crate::model::Package) -> HashMap { - let handlebars = Handlebars::new(); - let package = convert_model(package); - - package - .interfaces - .iter() - .map(|interface| { - let rendered_file = handlebars - .render_template( - TEMPLATE, - &json!({"package_name": package.name.replace("-", "_"), "interface": interface}), - ) - .unwrap(); - ( - PathBuf::from(format!("{}.rs", interface.name)), - rendered_file, - ) - }) - .collect() -} diff --git a/pulumi_wasm_generator_lib/src/output/rust/source_code_resource_mod.rs b/pulumi_wasm_generator_lib/src/output/rust/source_code_resource_mod.rs deleted file mode 100644 index ac5629f45..000000000 --- a/pulumi_wasm_generator_lib/src/output/rust/source_code_resource_mod.rs +++ /dev/null @@ -1,42 +0,0 @@ -use handlebars::Handlebars; -use serde::Serialize; -use serde_json::json; - -static TEMPLATE: &str = include_str!("resource_mod.rs.handlebars"); - -#[derive(Serialize)] -struct Interface { - name: String, -} - -#[derive(Serialize)] -struct Package { - name: String, - interfaces: Vec, -} - -fn convert_model(package: &crate::model::Package) -> Package { - Package { - name: package.name.clone(), - interfaces: package - .resources - .keys() - .map(|element_id| Interface { - name: element_id.get_rust_namespace_name(), - }) - .collect(), - } -} - -pub(crate) fn generate_source_code(package: &crate::model::Package) -> String { - let package = convert_model(package); - - let content = { - let handlebars = Handlebars::new(); - handlebars - .render_template(TEMPLATE, &json!({"package": &package})) - .unwrap() - }; - - content -} diff --git a/pulumi_wasm_generator_lib/src/output/rust/types/mod.rs b/pulumi_wasm_generator_lib/src/output/rust/types/mod.rs new file mode 100644 index 000000000..78d53a608 --- /dev/null +++ b/pulumi_wasm_generator_lib/src/output/rust/types/mod.rs @@ -0,0 +1,49 @@ +mod source_code_types_code; +mod source_code_types_mod; + +use crate::output::rust::types::source_code_types_code::generate_single_type_source_file; +use crate::output::rust::types::source_code_types_mod::generate_mod; +use crate::output::rust::TreeNode; +use convert_case::{Case, Casing}; +use std::fs::File; +use std::io::Write; + +pub(crate) fn generate_types_code(package: &crate::model::Package, result_path: &std::path::Path) { + if package.types.is_empty() { + return; + } + let mut tree = TreeNode::new(); + + for element_id in package.types.keys() { + tree.insert(element_id.clone()); + } + + let root = result_path.join("src").join("types"); + + generate_files(package, &tree, &root); +} + +fn generate_files( + package: &crate::model::Package, + tree_node: &TreeNode, + current_path: &std::path::Path, +) { + match tree_node { + TreeNode::Namespace(ns) => { + for (name, node) in ns { + generate_files(package, node, ¤t_path.join(name)); + } + let content = generate_mod(ns); + let mut file = File::create(current_path.join("mod.rs")).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + TreeNode::Leaf(ref leaf) => { + let file_name = format!("{}.rs", leaf.get_rust_struct_name().to_case(Case::Snake)); + let content = generate_single_type_source_file(package, leaf); + let dir = current_path.parent().unwrap(); + std::fs::create_dir_all(dir).unwrap(); + let mut file = File::create(current_path.parent().unwrap().join(file_name)).unwrap(); + file.write_all(content.as_bytes()).unwrap(); + } + } +} diff --git a/pulumi_wasm_generator_lib/src/output/rust/source_code_types_code.rs b/pulumi_wasm_generator_lib/src/output/rust/types/source_code_types_code.rs similarity index 58% rename from pulumi_wasm_generator_lib/src/output/rust/source_code_types_code.rs rename to pulumi_wasm_generator_lib/src/output/rust/types/source_code_types_code.rs index 37fbe12db..e68b6c81b 100644 --- a/pulumi_wasm_generator_lib/src/output/rust/source_code_types_code.rs +++ b/pulumi_wasm_generator_lib/src/output/rust/types/source_code_types_code.rs @@ -83,40 +83,6 @@ struct AliasType { type_: String, } -#[derive(Serialize)] -struct Package { - name: String, - types: Vec, - string_enums: Vec, - number_enums: Vec, - integer_enums: Vec, -} - -fn convert_model(package: &crate::model::Package) -> Package { - let mut real_types = Vec::new(); - let mut string_enums = Vec::new(); - let mut number_enums = Vec::new(); - let mut integer_enums = Vec::new(); - - package - .types - .keys() - .for_each(|element_id| match convert_resource(package, element_id) { - GenerateResource::RealType(ref_type) => real_types.push(ref_type), - GenerateResource::StringEnum(string_enum) => string_enums.push(string_enum), - GenerateResource::NumberEnum(number_enum) => number_enums.push(number_enum), - GenerateResource::IntegerEnum(integer_enum) => integer_enums.push(integer_enum), - }); - - Package { - name: package.name.clone(), - types: real_types, - string_enums, - number_enums, - integer_enums, - } -} - enum GenerateResource { RealType(RefType), StringEnum(StringEnum), @@ -222,133 +188,32 @@ fn convert_resource(package: &crate::model::Package, element_id: &ElementId) -> } } -pub(crate) fn generate_source_code(package: &crate::model::Package) -> HashMap { - let handlebars = Handlebars::new(); - let package = convert_model(package); - - let types: HashMap<_, _> = package - .types - .iter() - .map(|type_| { - let rendered_file = handlebars - .render_template(TEMPLATE, &json!({"type": type_})) - .unwrap() - .trim_start() - .to_string(); //FIXME - ( - PathBuf::from(format!("{}.rs", type_.file_name)), - rendered_file, - ) - }) - .collect(); - - let string_enums: HashMap<_, _> = package - .string_enums - .iter() - .map(|enum_| { - let rendered_file = handlebars - .render_template(STRING_ENUM_TEMPLATE, &json!({"enum": enum_})) - .unwrap() - .trim_start() - .to_string(); //FIXME - ( - PathBuf::from(format!("{}.rs", enum_.file_name)), - rendered_file, - ) - }) - .collect(); - - let number_enums: HashMap<_, _> = package - .number_enums - .iter() - .map(|enum_| { - let rendered_file = handlebars - .render_template(NUMBER_ENUM_TEMPLATE, &json!({"enum": enum_})) - .unwrap() - .trim_start() - .to_string(); //FIXME - ( - PathBuf::from(format!("{}.rs", enum_.file_name)), - rendered_file, - ) - }) - .collect(); - - let integer_enums: HashMap<_, _> = package - .integer_enums - .iter() - .map(|enum_| { - let rendered_file = handlebars - .render_template(INTEGER_ENUM_TEMPLATE, &json!({"enum": enum_})) - .unwrap() - .trim_start() - .to_string(); //FIXME - ( - PathBuf::from(format!("{}.rs", enum_.file_name)), - rendered_file, - ) - }) - .collect(); - - let mut result = HashMap::new(); - result.extend(types); - result.extend(string_enums); - result.extend(number_enums); - result.extend(integer_enums); - - result -} - -pub(crate) fn generate_single_source_file( +pub(crate) fn generate_single_type_source_file( package: &crate::model::Package, element_id: &ElementId, -) -> (PathBuf, String) { +) -> String { let handlebars = Handlebars::new(); match convert_resource(package, element_id) { - GenerateResource::RealType(type_) => { - let rendered_file = handlebars - .render_template(TEMPLATE, &json!({"type": type_})) - .unwrap() - .trim_start() - .to_string(); //FIXME - ( - PathBuf::from(format!("{}.rs", type_.file_name)), - rendered_file, - ) - } - GenerateResource::StringEnum(enum_) => { - let rendered_file = handlebars - .render_template(STRING_ENUM_TEMPLATE, &json!({"enum": enum_})) - .unwrap() - .trim_start() - .to_string(); //FIXME - ( - PathBuf::from(format!("{}.rs", enum_.file_name)), - rendered_file, - ) - } - GenerateResource::NumberEnum(enum_) => { - let rendered_file = handlebars - .render_template(NUMBER_ENUM_TEMPLATE, &json!({"enum": enum_})) - .unwrap() - .trim_start() - .to_string(); //FIXME - ( - PathBuf::from(format!("{}.rs", enum_.file_name)), - rendered_file, - ) - } - GenerateResource::IntegerEnum(enum_) => { - let rendered_file = handlebars - .render_template(INTEGER_ENUM_TEMPLATE, &json!({"enum": enum_})) - .unwrap() - .trim_start() - .to_string(); //FIXME - ( - PathBuf::from(format!("{}.rs", enum_.file_name)), - rendered_file, - ) - } + GenerateResource::RealType(type_) => handlebars + .render_template(TEMPLATE, &json!({"type": type_})) + .unwrap() + .trim_start() + .to_string(), + GenerateResource::StringEnum(enum_) => handlebars + .render_template(STRING_ENUM_TEMPLATE, &json!({"enum": enum_})) + .unwrap() + .trim_start() + .to_string(), + GenerateResource::NumberEnum(enum_) => handlebars + .render_template(NUMBER_ENUM_TEMPLATE, &json!({"enum": enum_})) + .unwrap() + .trim_start() + .to_string(), + GenerateResource::IntegerEnum(enum_) => handlebars + .render_template(INTEGER_ENUM_TEMPLATE, &json!({"enum": enum_})) + .unwrap() + .trim_start() + .to_string(), } } diff --git a/pulumi_wasm_generator_lib/src/output/rust/source_code_types_mod.rs b/pulumi_wasm_generator_lib/src/output/rust/types/source_code_types_mod.rs similarity index 100% rename from pulumi_wasm_generator_lib/src/output/rust/source_code_types_mod.rs rename to pulumi_wasm_generator_lib/src/output/rust/types/source_code_types_mod.rs diff --git a/pulumi_wasm_generator_lib/src/output/rust/types_code.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/types/types_code.rs.handlebars similarity index 100% rename from pulumi_wasm_generator_lib/src/output/rust/types_code.rs.handlebars rename to pulumi_wasm_generator_lib/src/output/rust/types/types_code.rs.handlebars diff --git a/pulumi_wasm_generator_lib/src/output/rust/types_code_integer_enum.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/types/types_code_integer_enum.rs.handlebars similarity index 100% rename from pulumi_wasm_generator_lib/src/output/rust/types_code_integer_enum.rs.handlebars rename to pulumi_wasm_generator_lib/src/output/rust/types/types_code_integer_enum.rs.handlebars diff --git a/pulumi_wasm_generator_lib/src/output/rust/types_code_number_enum.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/types/types_code_number_enum.rs.handlebars similarity index 100% rename from pulumi_wasm_generator_lib/src/output/rust/types_code_number_enum.rs.handlebars rename to pulumi_wasm_generator_lib/src/output/rust/types/types_code_number_enum.rs.handlebars diff --git a/pulumi_wasm_generator_lib/src/output/rust/types_code_string_enum.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/types/types_code_string_enum.rs.handlebars similarity index 100% rename from pulumi_wasm_generator_lib/src/output/rust/types_code_string_enum.rs.handlebars rename to pulumi_wasm_generator_lib/src/output/rust/types/types_code_string_enum.rs.handlebars diff --git a/pulumi_wasm_generator_lib/src/output/rust/types_mod.rs.handlebars b/pulumi_wasm_generator_lib/src/output/rust/types_mod.rs.handlebars deleted file mode 100644 index de7a4f82c..000000000 --- a/pulumi_wasm_generator_lib/src/output/rust/types_mod.rs.handlebars +++ /dev/null @@ -1,4 +0,0 @@ -{{#each package.types as |type|}} -mod {{file_name}}; -pub use {{file_name}}::*; -{{/each}} diff --git a/pulumi_wasm_generator_lib/templates/function_mod.rs.jinja b/pulumi_wasm_generator_lib/templates/function_mod.rs.jinja new file mode 100644 index 000000000..1c3b6a251 --- /dev/null +++ b/pulumi_wasm_generator_lib/templates/function_mod.rs.jinja @@ -0,0 +1,6 @@ +{% for file in files +%} +pub mod {{+ file }}; +{% endfor %} +{% for directory in directories +%} +pub mod {{+ directory }}; +{% endfor %} \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/templates/resource_mod.rs.jinja b/pulumi_wasm_generator_lib/templates/resource_mod.rs.jinja new file mode 100644 index 000000000..1c3b6a251 --- /dev/null +++ b/pulumi_wasm_generator_lib/templates/resource_mod.rs.jinja @@ -0,0 +1,6 @@ +{% for file in files +%} +pub mod {{+ file }}; +{% endfor %} +{% for directory in directories +%} +pub mod {{+ directory }}; +{% endfor %} \ No newline at end of file diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/function/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/lib.rs index 760081ab4..a4b4d989f 100644 --- a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/lib.rs @@ -4,8 +4,7 @@ use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface:: mod resource; pub use resource::*; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/ExampleServer.rs b/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/ExampleServer.rs deleted file mode 100644 index 5b129dce6..000000000 --- a/pulumi_wasm_generator_lib/tests/output/array-of-enum-map/lib/src/resource/ExampleServer.rs +++ /dev/null @@ -1,25 +0,0 @@ - -#[derive(bon::Builder, Clone)] -#[builder(finish_fn = build_struct)] -pub struct ExampleServerArgs { - #[builder(into, default)] - pub map_array_enum: pulumi_wasm_rust::Output>>>, -} - -pub struct ExampleServerResult { - pub map_array_enum: pulumi_wasm_rust::Output>>>, -} - -/// -/// Registers a new resource with the given unique name and arguments -/// -pub fn create(name: &str, args: ExampleServerArgs) -> ExampleServerResult { - - let result = crate::bindings::pulumi::example::ExampleServer::invoke(name, &crate::bindings::pulumi::example::ExampleServer::Args { - map_array_enum: &args.map_array_enum.get_inner(), - }); - - ExampleServerResult { - map_array_enum: crate::into_domain(result.map_array_enum), - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/function/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/lib.rs index 8dc018f94..128ab7304 100644 --- a/pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/lib.rs @@ -1,7 +1,6 @@ use pulumi_wasm_rust::Output; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/cyclic-types/lib/src/resource/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/function/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/lib.rs index b11cc0671..f3e5d9f0b 100644 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/lib.rs @@ -4,8 +4,7 @@ use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface:: mod resource; pub use resource::*; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/mod.rs index 8642100ce..87821cc70 100644 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/mod.rs +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/mod.rs @@ -1,2 +1 @@ -pub mod tree_v1_nursery; -pub mod tree_v1_rubber_tree; +pub mod tree; diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/mod.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/mod.rs new file mode 100644 index 000000000..a3a6d96c3 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/mod.rs @@ -0,0 +1 @@ +pub mod v1; diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/v1/mod.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/v1/mod.rs new file mode 100644 index 000000000..84284e348 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/v1/mod.rs @@ -0,0 +1,2 @@ +pub mod nursery; +pub mod rubber_tree; diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_v1_nursery.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/v1/nursery.rs similarity index 100% rename from pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_v1_nursery.rs rename to pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/v1/nursery.rs diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_v1_rubber_tree.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/v1/rubber_tree.rs similarity index 100% rename from pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_v1_rubber_tree.rs rename to pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree/v1/rubber_tree.rs diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_nursery.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_nursery.rs deleted file mode 100644 index 03d0df9cd..000000000 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_nursery.rs +++ /dev/null @@ -1,28 +0,0 @@ - -#[derive(bon::Builder, Clone)] -#[builder(finish_fn = build_struct)] -pub struct NurseryArgs { - /// The sizes of trees available - #[builder(into, default)] - pub sizes: pulumi_wasm_rust::Output>>, - /// The varieties available - #[builder(into)] - pub varieties: pulumi_wasm_rust::Output>, -} - -pub struct NurseryResult { -} - -/// -/// Registers a new resource with the given unique name and arguments -/// -pub fn create(name: &str, args: NurseryArgs) -> NurseryResult { - - let result = crate::bindings::pulumi::plant::tree_nursery::invoke(name, &crate::bindings::pulumi::plant::tree_nursery::Args { - sizes: &args.sizes.get_inner(), - varieties: &args.varieties.get_inner(), - }); - - NurseryResult { - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_rubber_tree.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_rubber_tree.rs deleted file mode 100644 index 8eb5ee093..000000000 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/resource/tree_rubber_tree.rs +++ /dev/null @@ -1,45 +0,0 @@ - -#[derive(bon::Builder, Clone)] -#[builder(finish_fn = build_struct)] -pub struct RubberTreeArgs { - #[builder(into, default)] - pub container: pulumi_wasm_rust::Output>, - #[builder(into)] - pub diameter: pulumi_wasm_rust::Output, - #[builder(into, default)] - pub farm: pulumi_wasm_rust::Output>>, - #[builder(into, default)] - pub size: pulumi_wasm_rust::Output>, - #[builder(into)] - pub type_: pulumi_wasm_rust::Output, -} - -pub struct RubberTreeResult { - pub container: pulumi_wasm_rust::Output>, - pub diameter: pulumi_wasm_rust::Output, - pub farm: pulumi_wasm_rust::Output>>, - pub size: pulumi_wasm_rust::Output>, - pub type_: pulumi_wasm_rust::Output, -} - -/// -/// Registers a new resource with the given unique name and arguments -/// -pub fn create(name: &str, args: RubberTreeArgs) -> RubberTreeResult { - - let result = crate::bindings::pulumi::plant::tree_rubber_tree::invoke(name, &crate::bindings::pulumi::plant::tree_rubber_tree::Args { - container: &args.container.get_inner(), - diameter: &args.diameter.get_inner(), - farm: &args.farm.get_inner(), - size: &args.size.get_inner(), - type_: &args.type_.get_inner(), - }); - - RubberTreeResult { - container: crate::into_domain(result.container), - diameter: crate::into_domain(result.diameter), - farm: crate::into_domain(result.farm), - size: crate::into_domain(result.size), - type_: crate::into_domain(result.type_), - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/diameter.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/diameter.rs deleted file mode 100644 index 8e1a580fb..000000000 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/diameter.rs +++ /dev/null @@ -1,32 +0,0 @@ -#[derive(Debug, PartialEq, Clone)] -pub enum Diameter { - sixinch, - twelveinch, -} - -impl serde::Serialize for Diameter { - fn serialize(&self, serializer: S) -> Result - where - S: serde::Serializer, - { - let value = match self { - Diameter::sixinch => 6.0, - Diameter::twelveinch => 12.0, - }; - serializer.serialize_f64(value) - } -} - -impl<'de> serde::Deserialize<'de> for Diameter { - fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let f = f64::deserialize(deserializer)?; - match f { - 6.0 => Ok(Diameter::sixinch), - 12.0 => Ok(Diameter::twelveinch), - _ => Err(serde::de::Error::custom(format!("Invalid enum value: {}", f))), - } - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/farm.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/farm.rs deleted file mode 100644 index 69d04ea31..000000000 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/farm.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] -pub enum Farm { - #[serde(rename = "Pulumi Planters Inc.")] - PulumiPlantersInc, - #[serde(rename = "Plants'R'Us")] - PlantsRUs, -} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/rubber_tree_variety.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/rubber_tree_variety.rs deleted file mode 100644 index 39491e530..000000000 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/rubber_tree_variety.rs +++ /dev/null @@ -1,11 +0,0 @@ -//! types of rubber trees - -#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] -pub enum RubberTreeVariety { - /// A burgundy rubber tree. - Burgundy, - /// A ruby rubber tree. - Ruby, - /// A tineke rubber tree. - Tineke, -} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/tree_size.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/tree_size.rs deleted file mode 100644 index f6908d0d7..000000000 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/lib/src/types/tree/tree_size.rs +++ /dev/null @@ -1,9 +0,0 @@ -#[derive(serde::Deserialize, serde::Serialize, Debug, PartialEq, Clone)] -pub enum TreeSize { - #[serde(rename = "small")] - Small, - #[serde(rename = "medium")] - Medium, - #[serde(rename = "large")] - Large, -} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_nursery.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_nursery.rs deleted file mode 100644 index b9a225824..000000000 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_nursery.rs +++ /dev/null @@ -1,26 +0,0 @@ -use std::collections::HashMap; -use crate::bindings::exports::pulumi::plant::tree_nursery; -use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, register, RegisterResourceRequest, ResultField}; -use crate::Component; - -impl tree_nursery::Guest for Component { - fn invoke(name: String, args: tree_nursery::Args) { - pulumi_wasm_common::setup_logger(); - let request = RegisterResourceRequest { - type_: "plant:tree/v1:Nursery".into(), - name, - object: vec![ - ObjectField { name: "sizes".into(), value: args.sizes }, - ObjectField { name: "varieties".into(), value: args.varieties }, - ], - results: vec![ - ], - }; - - let o = register(&request); - - let mut hashmap: HashMap = o.fields.into_iter().map(|f| (f.name, f.output)).collect(); - - - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_rubber_tree.rs b/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_rubber_tree.rs deleted file mode 100644 index 9226520df..000000000 --- a/pulumi_wasm_generator_lib/tests/output/different-enum/provider/src/resource/tree_rubber_tree.rs +++ /dev/null @@ -1,41 +0,0 @@ -use std::collections::HashMap; -use crate::bindings::exports::pulumi::plant::tree_rubber_tree; -use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, register, RegisterResourceRequest, ResultField}; -use crate::Component; - -impl tree_rubber_tree::Guest for Component { - fn invoke(name: String, args: tree_rubber_tree::Args) -> tree_rubber_tree::Res { - pulumi_wasm_common::setup_logger(); - let request = RegisterResourceRequest { - type_: "plant:tree/v1:RubberTree".into(), - name, - object: vec![ - ObjectField { name: "container".into(), value: args.container }, - ObjectField { name: "diameter".into(), value: args.diameter }, - ObjectField { name: "farm".into(), value: args.farm }, - ObjectField { name: "size".into(), value: args.size }, - ObjectField { name: "type".into(), value: args.type_ }, - ], - results: vec![ - ResultField { name: "container".into() }, - ResultField { name: "diameter".into() }, - ResultField { name: "farm".into() }, - ResultField { name: "size".into() }, - ResultField { name: "type".into() }, - ], - }; - - let o = register(&request); - - let mut hashmap: HashMap = o.fields.into_iter().map(|f| (f.name, f.output)).collect(); - - tree_rubber_tree::Res { - container: hashmap.remove("container").unwrap(), - diameter: hashmap.remove("diameter").unwrap(), - farm: hashmap.remove("farm").unwrap(), - size: hashmap.remove("size").unwrap(), - type_: hashmap.remove("type").unwrap(), - } - - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/lib.rs index b5dc0f53f..93cf860fe 100644 --- a/pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/lib.rs @@ -1,8 +1,7 @@ use pulumi_wasm_rust::Output; use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface::Output as WitOutput; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod function; -pub use function::*; +pub mod function; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/resource/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/types/mod.rs b/pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/types/mod.rs deleted file mode 100644 index 8b1378917..000000000 --- a/pulumi_wasm_generator_lib/tests/output/functions-secrets/lib/src/types/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/function/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/lib.rs index 78aa47b07..ad64a78b1 100644 --- a/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/lib.rs @@ -1,7 +1,6 @@ use pulumi_wasm_rust::Output; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/resource/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/types/ignore_tags.rs b/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/types/ignore_tags.rs deleted file mode 100644 index b0000b062..000000000 --- a/pulumi_wasm_generator_lib/tests/output/mini-awsnative/lib/src/types/ignore_tags.rs +++ /dev/null @@ -1,14 +0,0 @@ -//! The configuration with resource tag settings to ignore across all resources handled by this provider (except any individual service tag resources such as `ec2.Tag`) for situations where external systems are managing certain resource tags. - -#[derive(serde::Deserialize, serde::Serialize, bon::Builder, Debug, PartialEq, Clone)] -#[builder(finish_fn = build_struct)] -pub struct IgnoreTags { - /// List of exact resource tag keys to ignore across all resources handled by this provider. This configuration prevents Pulumi from returning the tag in any `tags` attributes and displaying any configuration difference for the tag value. If any resource configuration still has this tag key configured in the `tags` argument, it will display a perpetual difference until the tag is removed from the argument or `ignoreChanges` is also used. - #[builder(into, default)] - #[serde(rename = "keyPrefixes")] - pub r#key_prefixes: Box>>, - /// List of resource tag key prefixes to ignore across all resources handled by this provider. This configuration prevents Pulumi from returning any tag key matching the prefixes in any `tags` attributes and displaying any configuration difference for those tag values. If any resource configuration still has a tag matching one of the prefixes configured in the `tags` argument, it will display a perpetual difference until the tag is removed from the argument or `ignoreChanges` is also used. - #[builder(into, default)] - #[serde(rename = "keys")] - pub r#keys: Box>>, -} diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/function/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/mod.rs new file mode 100644 index 000000000..e5f480ded --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/mod.rs @@ -0,0 +1 @@ +pub mod nested; diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/mod.rs new file mode 100644 index 000000000..cc57a848e --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/mod.rs @@ -0,0 +1 @@ +pub mod module; diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/module/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/module/mod.rs new file mode 100644 index 000000000..c6bee0532 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/module/mod.rs @@ -0,0 +1 @@ +pub mod resource; diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply_nested_module_resource.rs b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/module/resource.rs similarity index 100% rename from pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply_nested_module_resource.rs rename to pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/deeply/nested/module/resource.rs diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/mod.rs index c5043998e..1d7e3b920 100644 --- a/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/mod.rs +++ b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/resource/mod.rs @@ -1 +1 @@ -pub mod deeply_nested_module_resource; +pub mod deeply; diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/types/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/types/mod.rs deleted file mode 100644 index 8b1378917..000000000 --- a/pulumi_wasm_generator_lib/tests/output/nested-module-thirdparty/lib/src/types/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/function/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/mod.rs index 57d7800cb..e5f480ded 100644 --- a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/mod.rs +++ b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/mod.rs @@ -1 +1 @@ -pub mod nested_module_resource; +pub mod nested; diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/mod.rs new file mode 100644 index 000000000..cc57a848e --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/mod.rs @@ -0,0 +1 @@ +pub mod module; diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/module/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/module/mod.rs new file mode 100644 index 000000000..c6bee0532 --- /dev/null +++ b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/module/mod.rs @@ -0,0 +1 @@ +pub mod resource; diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested_module_resource.rs b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/module/resource.rs similarity index 100% rename from pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested_module_resource.rs rename to pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested/module/resource.rs diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested_resource.rs b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested_resource.rs deleted file mode 100644 index 025a93d3c..000000000 --- a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/resource/nested_resource.rs +++ /dev/null @@ -1,25 +0,0 @@ - -#[derive(bon::Builder, Clone)] -#[builder(finish_fn = build_struct)] -pub struct ResourceArgs { - #[builder(into, default)] - pub bar: pulumi_wasm_rust::Output>, -} - -pub struct ResourceResult { - pub bar: pulumi_wasm_rust::Output>, -} - -/// -/// Registers a new resource with the given unique name and arguments -/// -pub fn create(name: &str, args: ResourceArgs) -> ResourceResult { - - let result = crate::bindings::pulumi::foo::nested_resource::invoke(name, &crate::bindings::pulumi::foo::nested_resource::Args { - bar: &args.bar.get_inner(), - }); - - ResourceResult { - bar: crate::into_domain(result.bar), - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/types/mod.rs b/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/types/mod.rs deleted file mode 100644 index 8b1378917..000000000 --- a/pulumi_wasm_generator_lib/tests/output/nested-module/lib/src/types/mod.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pulumi_wasm_generator_lib/tests/output/nested-module/provider/src/resource/nested_resource.rs b/pulumi_wasm_generator_lib/tests/output/nested-module/provider/src/resource/nested_resource.rs deleted file mode 100644 index 2abcb9433..000000000 --- a/pulumi_wasm_generator_lib/tests/output/nested-module/provider/src/resource/nested_resource.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::collections::HashMap; -use crate::bindings::exports::pulumi::foo::nested_resource; -use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, register, RegisterResourceRequest, ResultField}; -use crate::Component; - -impl nested_resource::Guest for Component { - fn invoke(name: String, args: nested_resource::Args) -> nested_resource::Res { - pulumi_wasm_common::setup_logger(); - let request = RegisterResourceRequest { - type_: "foo:nested/module:Resource".into(), - name, - object: vec![ - ObjectField { name: "bar".into(), value: args.bar }, - ], - results: vec![ - ResultField { name: "bar".into() }, - ], - }; - - let o = register(&request); - - let mut hashmap: HashMap = o.fields.into_iter().map(|f| (f.name, f.output)).collect(); - - nested_resource::Res { - bar: hashmap.remove("bar").unwrap(), - } - - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/output-funcs-edgeorder/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/output-funcs-edgeorder/lib/src/lib.rs index 60ff489ce..0702685cf 100644 --- a/pulumi_wasm_generator_lib/tests/output/output-funcs-edgeorder/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/output-funcs-edgeorder/lib/src/lib.rs @@ -1,11 +1,9 @@ use pulumi_wasm_rust::Output; use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface::Output as WitOutput; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod function; -pub use function::*; +pub mod function; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/output-funcs-edgeorder/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/output-funcs-edgeorder/lib/src/resource/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/output-funcs/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/output-funcs/lib/src/lib.rs index 7a928d867..3adbae40e 100644 --- a/pulumi_wasm_generator_lib/tests/output/output-funcs/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/output-funcs/lib/src/lib.rs @@ -1,11 +1,9 @@ use pulumi_wasm_rust::Output; use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface::Output as WitOutput; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod function; -pub use function::*; +pub mod function; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/output-funcs/lib/src/resource/mod.rs b/pulumi_wasm_generator_lib/tests/output/output-funcs/lib/src/resource/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/plain-object-defaults/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/plain-object-defaults/lib/src/lib.rs index fee1f6393..e2a431b8e 100644 --- a/pulumi_wasm_generator_lib/tests/output/plain-object-defaults/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/plain-object-defaults/lib/src/lib.rs @@ -4,11 +4,9 @@ use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface:: mod resource; pub use resource::*; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod function; -pub use function::*; +pub mod function; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/plain-object-defaults/lib/src/resource/moduleTest.rs b/pulumi_wasm_generator_lib/tests/output/plain-object-defaults/lib/src/resource/moduleTest.rs deleted file mode 100644 index 13fbb8c99..000000000 --- a/pulumi_wasm_generator_lib/tests/output/plain-object-defaults/lib/src/resource/moduleTest.rs +++ /dev/null @@ -1,26 +0,0 @@ - -#[derive(bon::Builder, Clone)] -#[builder(finish_fn = build_struct)] -pub struct moduleTestArgs { - #[builder(into, default)] - pub mod1: pulumi_wasm_rust::Output>, - #[builder(into, default)] - pub val: pulumi_wasm_rust::Output>, -} - -pub struct moduleTestResult { -} - -/// -/// Registers a new resource with the given unique name and arguments -/// -pub fn create(name: &str, args: moduleTestArgs) -> moduleTestResult { - - let result = crate::bindings::pulumi::example::moduleTest::invoke(name, &crate::bindings::pulumi::example::moduleTest::Args { - mod1: &args.mod1.get_inner(), - val: &args.val.get_inner(), - }); - - moduleTestResult { - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/plain-object-disable-defaults/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/plain-object-disable-defaults/lib/src/lib.rs index fee1f6393..e2a431b8e 100644 --- a/pulumi_wasm_generator_lib/tests/output/plain-object-disable-defaults/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/plain-object-disable-defaults/lib/src/lib.rs @@ -4,11 +4,9 @@ use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface:: mod resource; pub use resource::*; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod function; -pub use function::*; +pub mod function; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/plain-object-disable-defaults/lib/src/resource/moduleTest.rs b/pulumi_wasm_generator_lib/tests/output/plain-object-disable-defaults/lib/src/resource/moduleTest.rs deleted file mode 100644 index 13fbb8c99..000000000 --- a/pulumi_wasm_generator_lib/tests/output/plain-object-disable-defaults/lib/src/resource/moduleTest.rs +++ /dev/null @@ -1,26 +0,0 @@ - -#[derive(bon::Builder, Clone)] -#[builder(finish_fn = build_struct)] -pub struct moduleTestArgs { - #[builder(into, default)] - pub mod1: pulumi_wasm_rust::Output>, - #[builder(into, default)] - pub val: pulumi_wasm_rust::Output>, -} - -pub struct moduleTestResult { -} - -/// -/// Registers a new resource with the given unique name and arguments -/// -pub fn create(name: &str, args: moduleTestArgs) -> moduleTestResult { - - let result = crate::bindings::pulumi::example::moduleTest::invoke(name, &crate::bindings::pulumi::example::moduleTest::Args { - mod1: &args.mod1.get_inner(), - val: &args.val.get_inner(), - }); - - moduleTestResult { - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/function/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/lib.rs index c9ee6a4e6..104822953 100644 --- a/pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/lib.rs @@ -4,8 +4,7 @@ use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface:: mod resource; pub use resource::*; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/resource/ExampleServer.rs b/pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/resource/ExampleServer.rs deleted file mode 100644 index 85402152e..000000000 --- a/pulumi_wasm_generator_lib/tests/output/unions-inline/lib/src/resource/ExampleServer.rs +++ /dev/null @@ -1,25 +0,0 @@ - -#[derive(bon::Builder, Clone)] -#[builder(finish_fn = build_struct)] -pub struct ExampleServerArgs { - #[builder(into, default)] - pub properties: pulumi_wasm_rust::Output>>, -} - -pub struct ExampleServerResult { - pub name: pulumi_wasm_rust::Output>, -} - -/// -/// Registers a new resource with the given unique name and arguments -/// -pub fn create(name: &str, args: ExampleServerArgs) -> ExampleServerResult { - - let result = crate::bindings::pulumi::example::ExampleServer::invoke(name, &crate::bindings::pulumi::example::ExampleServer::Args { - properties: &args.properties.get_inner(), - }); - - ExampleServerResult { - name: crate::into_domain(result.name), - } -} diff --git a/pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/function/mod.rs b/pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/function/mod.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/lib.rs b/pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/lib.rs index c9ee6a4e6..104822953 100644 --- a/pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/lib.rs +++ b/pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/lib.rs @@ -4,8 +4,7 @@ use pulumi_wasm_wit::client_bindings::component::pulumi_wasm::output_interface:: mod resource; pub use resource::*; #[allow(clippy::doc_lazy_continuation, clippy::tabs_in_doc_comments)] -mod types; -pub use types::*; +pub mod types; mod bindings { wit_bindgen::generate!({ diff --git a/pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/resource/ExampleServer.rs b/pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/resource/ExampleServer.rs deleted file mode 100644 index 1ce38c7c6..000000000 --- a/pulumi_wasm_generator_lib/tests/output/unions-inside-arrays/lib/src/resource/ExampleServer.rs +++ /dev/null @@ -1,25 +0,0 @@ - -#[derive(bon::Builder, Clone)] -#[builder(finish_fn = build_struct)] -pub struct ExampleServerArgs { - #[builder(into, default)] - pub properties_collection: pulumi_wasm_rust::Output>>>, -} - -pub struct ExampleServerResult { - pub name: pulumi_wasm_rust::Output>, -} - -/// -/// Registers a new resource with the given unique name and arguments -/// -pub fn create(name: &str, args: ExampleServerArgs) -> ExampleServerResult { - - let result = crate::bindings::pulumi::example::ExampleServer::invoke(name, &crate::bindings::pulumi::example::ExampleServer::Args { - properties_collection: &args.properties_collection.get_inner(), - }); - - ExampleServerResult { - name: crate::into_domain(result.name), - } -}