Skip to content

Commit

Permalink
Namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejressel committed Dec 22, 2024
1 parent f0dacb0 commit e8354c7
Show file tree
Hide file tree
Showing 110 changed files with 677 additions and 910 deletions.
8 changes: 4 additions & 4 deletions examples/docker/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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(),
Expand Down
24 changes: 22 additions & 2 deletions examples/typesystem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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();
}
}
6 changes: 2 additions & 4 deletions providers/pulumi_wasm_provider_cloudflare_rust/src/lib.rs

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

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

6 changes: 2 additions & 4 deletions providers/pulumi_wasm_provider_docker_rust/src/lib.rs

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

Empty file.

This file was deleted.

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

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

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

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

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

5 changes: 3 additions & 2 deletions providers/pulumi_wasm_provider_typesystem_rust/src/lib.rs

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

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

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

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

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

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

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

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

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

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

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

29 changes: 29 additions & 0 deletions providers/pulumi_wasm_provider_typesystem_rust/wit/world.wit

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

14 changes: 14 additions & 0 deletions providers/typesystem.json

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

48 changes: 6 additions & 42 deletions pulumi_wasm_generator_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
}
Expand Down
5 changes: 1 addition & 4 deletions pulumi_wasm_generator_lib/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit e8354c7

Please sign in to comment.