diff --git a/pulumi_rust_wasm/src/bindings.rs b/pulumi_rust_wasm/src/bindings.rs index 2a75e4c11..84796e333 100644 --- a/pulumi_rust_wasm/src/bindings.rs +++ b/pulumi_rust_wasm/src/bindings.rs @@ -193,6 +193,28 @@ pub mod component { } } } + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn duplicate(&self,) -> Output{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.duplicate"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + Output::from_handle(ret as u32) + } + } + } } @@ -202,7 +224,7 @@ pub mod component { #[cfg(target_arch = "wasm32")] #[link_section = "component-type:pulumi-rust"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 412] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 155, 2, 1, 65, 2, 1, 65, 2, 1, 66, 15, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 111, 2, 115, 4, 1, 112, 8, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 9, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 10, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 114, 117, 115, 116, 64, 48, 46, 49, 46, 48, 4, 0, 11, 17, 1, 0, 11, 112, 117, 108, 117, 109, 105, 45, 114, 117, 115, 116, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 452] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 195, 2, 1, 65, 2, 1, 65, 2, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 114, 117, 115, 116, 64, 48, 46, 49, 46, 48, 4, 0, 11, 17, 1, 0, 11, 112, 117, 108, 117, 109, 105, 45, 114, 117, 115, 116, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; #[inline(never)] #[doc(hidden)] diff --git a/pulumi_rust_wasm/src/output.rs b/pulumi_rust_wasm/src/output.rs index 23d18c034..8dd92a15d 100644 --- a/pulumi_rust_wasm/src/output.rs +++ b/pulumi_rust_wasm/src/output.rs @@ -8,7 +8,14 @@ pub struct Output { // pulumi: Rc, } + + impl Output { + + pub fn get_inner(&self) -> &output_interface::Output { + &self.future + } + pub fn new(value: &F) -> Self { let binding = rmp_serde::to_vec(value).unwrap(); let arg = binding.as_slice(); diff --git a/pulumi_wasm/src/bindings.rs b/pulumi_wasm/src/bindings.rs index e6c79c405..7c6a556d8 100644 --- a/pulumi_wasm/src/bindings.rs +++ b/pulumi_wasm/src/bindings.rs @@ -279,6 +279,33 @@ pub mod exports { } }; }; + const _: () = { + + #[doc(hidden)] + #[export_name = "component:pulumi-wasm/output-interface@0.1.0#[method]output.duplicate"] + #[allow(non_snake_case)] + unsafe extern "C" fn __export_method_output_duplicate(arg0: i32,) -> i32 { + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + + // Before executing any other code, use this function to run all static + // constructors, if they have not yet been run. This is a hack required + // to work around wasi-libc ctors calling import functions to initialize + // the environment. + // + // This functionality will be removed once rust 1.69.0 is stable, at which + // point wasi-libc will no longer have this behavior. + // + // See + // https://github.com/bytecodealliance/preview2-prototyping/issues/99 + // for more details. + #[cfg(target_arch="wasm32")] + wit_bindgen::rt::run_ctors_once(); + + let result0 = <_OutputImpl as GuestOutput>::duplicate(wit_bindgen::rt::Resource::::lift_borrow(arg0 as u32 as usize)); + wit_bindgen::rt::Resource::into_handle(result0) as i32 + } + }; use super::super::super::super::super::Component as _GuestImpl; pub trait Guest { fn create_struct(fields: wit_bindgen::rt::vec::Vec::<(wit_bindgen::rt::string::String,&Output,)>,) -> OwnOutput; @@ -288,6 +315,7 @@ pub mod exports { fn new(value: wit_bindgen::rt::vec::Vec::,) -> Self; fn map(&self,function_name: wit_bindgen::rt::string::String,) -> OwnOutput; fn get(&self,) -> Option>; + fn duplicate(&self,) -> OwnOutput; } #[allow(unused_imports)] @@ -308,14 +336,24 @@ pub mod exports { static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_section; pub type OwnOutput = super::super::super::super::exports::component::pulumi_wasm::output_interface::OwnOutput; pub type Output = super::super::super::super::exports::component::pulumi_wasm::output_interface::Output; + pub struct ObjectField<'a,> { + /// name: list, //FIXME: String does not work + pub object: &'a Output, + } + impl<'a,> ::core::fmt::Debug for ObjectField<'a,> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ObjectField").field("object", &self.object).finish() + } + } pub struct RegisterResourceRequest<'a,> { pub type_: wit_bindgen::rt::string::String, pub name: wit_bindgen::rt::string::String, - pub object: &'a Output, + pub object_names: wit_bindgen::rt::vec::Vec::, + pub object: wit_bindgen::rt::vec::Vec::>, } impl<'a,> ::core::fmt::Debug for RegisterResourceRequest<'a,> { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RegisterResourceRequest").field("type", &self.type_).field("name", &self.name).field("object", &self.object).finish() + f.debug_struct("RegisterResourceRequest").field("type", &self.type_).field("name", &self.name).field("object-names", &self.object_names).field("object", &self.object).finish() } } const _: () = { @@ -323,7 +361,7 @@ pub mod exports { #[doc(hidden)] #[export_name = "component:pulumi-wasm/register-interface@0.1.0#register"] #[allow(non_snake_case)] - unsafe extern "C" fn __export_register(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,) { + unsafe extern "C" fn __export_register(arg0: i32,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: i32,arg7: i32,) { #[allow(unused_imports)] use wit_bindgen::rt::{alloc, vec::Vec, string::String}; @@ -345,10 +383,42 @@ pub mod exports { let bytes0 = Vec::from_raw_parts(arg0 as *mut _, len0, len0); let len1 = arg3 as usize; let bytes1 = Vec::from_raw_parts(arg2 as *mut _, len1, len1); + let base5 = arg4; + let len5 = arg5; + let mut result5 = Vec::with_capacity(len5 as usize); + for i in 0..len5 { + let base = base5 + i * 8; + let e5 = { + let l2 = *((base + 0) as *const i32); + let l3 = *((base + 4) as *const i32); + let len4 = l3 as usize; + let bytes4 = Vec::from_raw_parts(l2 as *mut _, len4, len4); + + wit_bindgen::rt::string_lift(bytes4) + }; + result5.push(e5); + } + wit_bindgen::rt::dealloc(base5, (len5 as usize) * 8, 4); + let base7 = arg6; + let len7 = arg7; + let mut result7 = Vec::with_capacity(len7 as usize); + for i in 0..len7 { + let base = base7 + i * 4; + let e7 = { + let l6 = *((base + 0) as *const i32); + + ObjectField{ + object: wit_bindgen::rt::Resource::::lift_borrow(l6 as u32 as usize), + } + }; + result7.push(e7); + } + wit_bindgen::rt::dealloc(base7, (len7 as usize) * 4, 4); <_GuestImpl as Guest>::register(RegisterResourceRequest{ type_: wit_bindgen::rt::string_lift(bytes0), name: wit_bindgen::rt::string_lift(bytes1), - object: wit_bindgen::rt::Resource::::lift_borrow(arg4 as u32 as usize), + object_names: result5, + object: result7, }); } }; @@ -545,7 +615,7 @@ pub mod exports { #[cfg(target_arch = "wasm32")] #[link_section = "component-type:pulumi-wasm"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 929] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 160, 6, 1, 65, 2, 1, 65, 9, 1, 66, 3, 1, 112, 125, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 0, 0, 0, 4, 0, 17, 114, 101, 103, 105, 115, 116, 101, 114, 45, 114, 101, 115, 111, 117, 114, 99, 101, 1, 1, 3, 1, 42, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 101, 120, 116, 101, 114, 110, 97, 108, 45, 119, 111, 114, 108, 100, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 15, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 111, 2, 115, 4, 1, 112, 8, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 9, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 10, 4, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 1, 2, 3, 0, 1, 6, 111, 117, 116, 112, 117, 116, 1, 66, 7, 2, 3, 2, 1, 2, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 104, 1, 1, 114, 3, 4, 116, 121, 112, 101, 115, 4, 110, 97, 109, 101, 115, 6, 111, 98, 106, 101, 99, 116, 2, 4, 0, 25, 114, 101, 103, 105, 115, 116, 101, 114, 45, 114, 101, 115, 111, 117, 114, 99, 101, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 3, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 4, 1, 0, 4, 0, 8, 114, 101, 103, 105, 115, 116, 101, 114, 1, 5, 4, 1, 46, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 114, 101, 103, 105, 115, 116, 101, 114, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 3, 1, 66, 15, 2, 3, 2, 1, 2, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 105, 1, 1, 112, 125, 1, 114, 3, 2, 105, 100, 2, 11, 102, 117, 110, 99, 116, 105, 111, 110, 45, 105, 100, 115, 5, 118, 97, 108, 117, 101, 3, 4, 0, 27, 102, 117, 110, 99, 116, 105, 111, 110, 45, 105, 110, 118, 111, 99, 97, 116, 105, 111, 110, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 4, 1, 104, 1, 1, 114, 2, 2, 105, 100, 6, 5, 118, 97, 108, 117, 101, 3, 4, 0, 26, 102, 117, 110, 99, 116, 105, 111, 110, 45, 105, 110, 118, 111, 99, 97, 116, 105, 111, 110, 45, 114, 101, 115, 117, 108, 116, 3, 0, 7, 1, 112, 5, 1, 64, 1, 6, 115, 111, 117, 114, 99, 101, 115, 0, 9, 4, 0, 13, 103, 101, 116, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 10, 1, 112, 8, 1, 64, 1, 7, 114, 101, 115, 117, 108, 116, 115, 11, 1, 0, 4, 0, 13, 115, 101, 116, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 12, 4, 1, 53, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 102, 117, 110, 99, 116, 105, 111, 110, 45, 114, 101, 118, 101, 114, 115, 101, 45, 99, 97, 108, 108, 98, 97, 99, 107, 64, 48, 46, 49, 46, 48, 5, 4, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 64, 48, 46, 49, 46, 48, 4, 0, 11, 17, 1, 0, 11, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1018] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 249, 6, 1, 65, 2, 1, 65, 9, 1, 66, 3, 1, 112, 125, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 0, 0, 0, 4, 0, 17, 114, 101, 103, 105, 115, 116, 101, 114, 45, 114, 101, 115, 111, 117, 114, 99, 101, 1, 1, 3, 1, 42, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 101, 120, 116, 101, 114, 110, 97, 108, 45, 119, 111, 114, 108, 100, 64, 48, 46, 49, 46, 48, 5, 0, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 4, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 1, 2, 3, 0, 1, 6, 111, 117, 116, 112, 117, 116, 1, 66, 11, 2, 3, 2, 1, 2, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 104, 1, 1, 114, 1, 6, 111, 98, 106, 101, 99, 116, 2, 4, 0, 12, 111, 98, 106, 101, 99, 116, 45, 102, 105, 101, 108, 100, 3, 0, 3, 1, 112, 115, 1, 112, 4, 1, 114, 4, 4, 116, 121, 112, 101, 115, 4, 110, 97, 109, 101, 115, 12, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 115, 5, 6, 111, 98, 106, 101, 99, 116, 6, 4, 0, 25, 114, 101, 103, 105, 115, 116, 101, 114, 45, 114, 101, 115, 111, 117, 114, 99, 101, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 7, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 8, 1, 0, 4, 0, 8, 114, 101, 103, 105, 115, 116, 101, 114, 1, 9, 4, 1, 46, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 114, 101, 103, 105, 115, 116, 101, 114, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 3, 1, 66, 15, 2, 3, 2, 1, 2, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 105, 1, 1, 112, 125, 1, 114, 3, 2, 105, 100, 2, 11, 102, 117, 110, 99, 116, 105, 111, 110, 45, 105, 100, 115, 5, 118, 97, 108, 117, 101, 3, 4, 0, 27, 102, 117, 110, 99, 116, 105, 111, 110, 45, 105, 110, 118, 111, 99, 97, 116, 105, 111, 110, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 4, 1, 104, 1, 1, 114, 2, 2, 105, 100, 6, 5, 118, 97, 108, 117, 101, 3, 4, 0, 26, 102, 117, 110, 99, 116, 105, 111, 110, 45, 105, 110, 118, 111, 99, 97, 116, 105, 111, 110, 45, 114, 101, 115, 117, 108, 116, 3, 0, 7, 1, 112, 5, 1, 64, 1, 6, 115, 111, 117, 114, 99, 101, 115, 0, 9, 4, 0, 13, 103, 101, 116, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 10, 1, 112, 8, 1, 64, 1, 7, 114, 101, 115, 117, 108, 116, 115, 11, 1, 0, 4, 0, 13, 115, 101, 116, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 12, 4, 1, 53, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 102, 117, 110, 99, 116, 105, 111, 110, 45, 114, 101, 118, 101, 114, 115, 101, 45, 99, 97, 108, 108, 98, 97, 99, 107, 64, 48, 46, 49, 46, 48, 5, 4, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 64, 48, 46, 49, 46, 48, 4, 0, 11, 17, 1, 0, 11, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; #[inline(never)] #[doc(hidden)] diff --git a/pulumi_wasm/src/lib.rs b/pulumi_wasm/src/lib.rs index 5a34ecdac..7e9983f09 100644 --- a/pulumi_wasm/src/lib.rs +++ b/pulumi_wasm/src/lib.rs @@ -3,16 +3,17 @@ use std::collections::BTreeMap; use std::fmt::Formatter; use std::ops::Deref; use prost::Message; +use rmpv::Value; +use bindings::component::pulumi_wasm::external_world; use crate::bindings::exports::component::pulumi_wasm::function_reverse_callback::{ FunctionInvocationRequest, FunctionInvocationResult, }; use crate::bindings::exports::component::pulumi_wasm::output_interface::{GuestOutput, OwnOutput}; -use crate::bindings::exports::component::pulumi_wasm::register_interface::RegisterResourceRequest; +use crate::bindings::exports::component::pulumi_wasm::register_interface::{ObjectField, RegisterResourceRequest}; use crate::bindings::exports::component::pulumi_wasm::{ function_reverse_callback, output_interface, register_interface, }; -use crate::output::OutputContent::Done; use crate::output::{access_map, FunctionId, FunctionSource, OutputContent}; mod bindings; @@ -25,7 +26,7 @@ impl output_interface::Guest for Component { fn create_struct(_fields: Vec<(String, &Output)>) -> OwnOutput { //FIXME let cell = output::create_nothing(); - OwnOutput::new(Output { output: cell }) + OwnOutput::new(Output { output: cell, tags: vec![] }) // todo!() // let mut field_names = vec![]; // let mut field_values = vec![]; @@ -72,12 +73,12 @@ impl output_interface::Guest for Component { pub struct Output { output: output::OutputContentRefCell, - // output: OutputWrapper, + tags: Vec, } impl Debug for Output { fn fmt(&self, _f: &mut Formatter<'_>) -> std::fmt::Result { - todo!() + std::fmt::Result::Ok(()) // TODO: Implement Debug for Output } } @@ -85,14 +86,14 @@ impl GuestOutput for Output { fn new(value: Vec) -> Self { let value = rmpv::decode::read_value(&mut value.as_slice()).unwrap(); let cell = output::create_new(value); - Output { output: cell } + Output { output: cell, tags: vec![] } } fn map(&self, function_name: String) -> OwnOutput { - let function_id = FunctionId(function_name); - let function_source = FunctionSource("source".to_string()); + let function_id = FunctionId::from_string(&function_name); + let function_source = FunctionSource::from_str("source"); let output = output::map_external(function_id, function_source, self.output.clone()); - OwnOutput::new(Output { output }) + OwnOutput::new(Output { output, tags: vec![] }) } fn get(&self) -> Option> { @@ -110,6 +111,14 @@ impl GuestOutput for Output { } } } + + fn duplicate(&self) -> OwnOutput { + OwnOutput::new(Output { + output: self.output.clone(), + tags: self.tags.clone(), + }) + // self.output + } // fn new(value: Vec) -> Self { // let value = rmpv::decode::read_value(&mut value.as_slice()).unwrap(); // let output = create_output(value); @@ -165,21 +174,21 @@ impl GuestOutput for Output { impl function_reverse_callback::Guest for Component { fn get_functions(source: String) -> Vec { + let function_source = &FunctionSource::from_string(&source); access_map() .iter() .flat_map(|f| { let f1 = &*f.borrow(); match f1 { - OutputContent::Mapped(id, s, prev) if s == &FunctionSource(source.clone()) => { + OutputContent::Mapped(id, s, prev) if s == function_source => { match &*prev.borrow() { OutputContent::Done(v) => { - println!("DONE"); let mut vec = vec![]; rmpv::encode::write_value(&mut vec, v).unwrap(); Some(FunctionInvocationRequest { - id: OwnOutput::new(Output { output: f.clone() }), - function_id: id.0.clone(), + id: OwnOutput::new(Output { output: f.clone(), tags: vec![] }), + function_id: id.get(), value: vec, }) } @@ -201,28 +210,43 @@ impl function_reverse_callback::Guest for Component { for x in results { let value = rmpv::decode::read_value(&mut x.value.as_slice()).unwrap(); let borrowed = &x.id.output; - borrowed.replace(Done(value)); + borrowed.replace(OutputContent::Done(value)); } } } +fn messagepack_to_protoc(v: &Value) -> prost_types::Value { + match v { + Value::Integer(i) => prost_types::Value { + kind: Option::from(prost_types::value::Kind::NumberValue(i.as_f64().unwrap())), + }, + _ => todo!() + } +} + impl register_interface::Guest for Component { fn register(request: RegisterResourceRequest) { + + let pairs = request.object_names.iter().zip(request.object.iter()); + + let pairs= pairs.map(|(name, object )| { + let s: String = "length".to_string(); + // let s: String = String::from_utf8(name.clone()).unwrap(); + + let v = match &*object.object.output.borrow() { + OutputContent::Done(vec) => messagepack_to_protoc(vec), + OutputContent::Mapped(_, _, _) => todo!(), + OutputContent::Func(_, _) => todo!(), + OutputContent::Nothing => todo!() + }; + + (s, v) + }); + + + let object = prost_types::Struct { - fields: BTreeMap::from([ - ( - "length".to_string(), - prost_types::Value { - kind: Option::from(prost_types::value::Kind::NumberValue(10.into())), - }, - ), - ( - "minNumeric".to_string(), - prost_types::Value { - kind: Option::from(prost_types::value::Kind::NumberValue(5.into())), - }, - ), - ]), + fields: BTreeMap::from_iter(pairs) }; let request = grpc::RegisterResourceRequest { @@ -260,8 +284,6 @@ impl register_interface::Guest for Component { let vec_request = request.encode_to_vec(); - crate::bindings::component::pulumi_wasm::external_world::register_resource( - vec_request.as_slice(), - ); + external_world::register_resource(vec_request.as_slice()); } } diff --git a/pulumi_wasm/src/output.rs b/pulumi_wasm/src/output.rs index 6427ee110..82608b960 100644 --- a/pulumi_wasm/src/output.rs +++ b/pulumi_wasm/src/output.rs @@ -5,9 +5,37 @@ use std::rc::Rc; pub(crate) type OutputContentRefCell = Rc>; #[derive(Clone, Debug, Eq, PartialEq)] -pub(crate) struct FunctionId(pub(crate) String); +pub(crate) struct FunctionId(String); + +impl FunctionId { + pub(crate) fn from_string(s: &String) -> FunctionId { + FunctionId(s.to_string()) + } + pub(crate) fn from_str(s: &str) -> FunctionId { + FunctionId(s.to_string()) + } + pub(crate) fn get(&self) -> String { + self.0.clone() + } +} + #[derive(Clone, Debug, Eq, PartialEq)] -pub(crate) struct FunctionSource(pub(crate) String); +pub(crate) struct FunctionSource(String); + +impl Into for FunctionSource { + fn into(self) -> String { + self.0 + } +} + +impl FunctionSource { + pub(crate) fn from_string(s: &String) -> FunctionSource { + FunctionSource(s.to_string()) + } + pub(crate) fn from_str(s: &str) -> FunctionSource { + FunctionSource(s.to_string()) + } +} static mut GLOBAL_MAP: Option> = None; @@ -72,8 +100,8 @@ pub(crate) fn map_external( } pub(crate) fn map_internal(ref_cell: OutputContentRefCell, f: F) -> Rc> -where - F: Fn(Vec) -> Vec + 'static, + where + F: Fn(Vec) -> Vec + 'static, { create_wrapper(OutputContent::Func(ref_cell, Box::new(f))) } diff --git a/pulumi_wasm_main/src/bindings.rs b/pulumi_wasm_main/src/bindings.rs index fac7331a4..848b240c4 100644 --- a/pulumi_wasm_main/src/bindings.rs +++ b/pulumi_wasm_main/src/bindings.rs @@ -193,6 +193,28 @@ pub mod component { } } } + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn duplicate(&self,) -> Output{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.duplicate"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + Output::from_handle(ret as u32) + } + } + } } @@ -314,7 +336,7 @@ pub mod exports { #[cfg(target_arch = "wasm32")] #[link_section = "component-type:new-main"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 763] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 253, 4, 1, 65, 2, 1, 65, 7, 1, 66, 15, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 111, 2, 115, 4, 1, 112, 8, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 9, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 10, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 6, 111, 117, 116, 112, 117, 116, 1, 66, 17, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 107, 121, 1, 104, 1, 1, 107, 3, 1, 113, 2, 7, 108, 105, 116, 101, 114, 97, 108, 1, 2, 0, 3, 114, 101, 115, 1, 4, 0, 4, 0, 10, 101, 105, 116, 104, 101, 114, 45, 117, 51, 50, 3, 0, 5, 1, 106, 1, 121, 1, 3, 1, 114, 2, 4, 110, 97, 109, 101, 115, 6, 108, 101, 110, 103, 116, 104, 7, 4, 0, 18, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 97, 114, 103, 115, 3, 0, 8, 1, 105, 1, 1, 114, 2, 3, 117, 114, 108, 10, 6, 114, 101, 115, 117, 108, 116, 10, 4, 0, 20, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 114, 101, 115, 117, 108, 116, 3, 0, 11, 1, 64, 1, 4, 97, 114, 103, 115, 9, 1, 0, 4, 0, 20, 99, 114, 101, 97, 116, 101, 45, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 1, 13, 1, 64, 0, 1, 0, 4, 0, 16, 104, 97, 110, 100, 108, 101, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 14, 3, 1, 60, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 2, 1, 66, 2, 1, 64, 0, 1, 0, 4, 0, 4, 109, 97, 105, 110, 1, 0, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 5, 3, 4, 1, 36, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 110, 101, 119, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 4, 0, 11, 14, 1, 0, 8, 110, 101, 119, 45, 109, 97, 105, 110, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 803] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 165, 5, 1, 65, 2, 1, 65, 7, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 6, 111, 117, 116, 112, 117, 116, 1, 66, 17, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 107, 121, 1, 104, 1, 1, 107, 3, 1, 113, 2, 7, 108, 105, 116, 101, 114, 97, 108, 1, 2, 0, 3, 114, 101, 115, 1, 4, 0, 4, 0, 10, 101, 105, 116, 104, 101, 114, 45, 117, 51, 50, 3, 0, 5, 1, 106, 1, 121, 1, 3, 1, 114, 2, 4, 110, 97, 109, 101, 115, 6, 108, 101, 110, 103, 116, 104, 7, 4, 0, 18, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 97, 114, 103, 115, 3, 0, 8, 1, 105, 1, 1, 114, 2, 3, 117, 114, 108, 10, 6, 114, 101, 115, 117, 108, 116, 10, 4, 0, 20, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 114, 101, 115, 117, 108, 116, 3, 0, 11, 1, 64, 1, 4, 97, 114, 103, 115, 9, 1, 0, 4, 0, 20, 99, 114, 101, 97, 116, 101, 45, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 1, 13, 1, 64, 0, 1, 0, 4, 0, 16, 104, 97, 110, 100, 108, 101, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 14, 3, 1, 60, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 2, 1, 66, 2, 1, 64, 0, 1, 0, 4, 0, 4, 109, 97, 105, 110, 1, 0, 4, 1, 39, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 5, 3, 4, 1, 36, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 110, 101, 119, 45, 109, 97, 105, 110, 64, 48, 46, 49, 46, 48, 4, 0, 11, 14, 1, 0, 8, 110, 101, 119, 45, 109, 97, 105, 110, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; #[inline(never)] #[doc(hidden)] diff --git a/pulumi_wasm_main/src/lib.rs b/pulumi_wasm_main/src/lib.rs index fd321bd29..58a9b57fd 100644 --- a/pulumi_wasm_main/src/lib.rs +++ b/pulumi_wasm_main/src/lib.rs @@ -3,6 +3,7 @@ use bindings::component::pulumi_wasm::pulumi_provider_random_interface::{ create_random_string, RandomStringArgs, }; use pulumi_rust_wasm::output::Output; +use crate::bindings::component::pulumi_wasm::pulumi_provider_random_interface; mod bindings; @@ -10,11 +11,15 @@ struct Component {} impl Guest for Component { fn main() { - let _output: Output = Output::new(&123); + let length: Output = Output::new(&1234); + + let output_1 = length.get_inner(); + let output_2 = output_1.duplicate(); + let output_2 = unsafe { pulumi_provider_random_interface::Output::from_handle(output_2.into_handle()) }; let abc = RandomStringArgs { - name: "test123".to_string(), - length: Ok(1), + name: "test1234".to_string(), + length: Err(&output_2), }; create_random_string(abc); } diff --git a/pulumi_wasm_random/src/bindings.rs b/pulumi_wasm_random/src/bindings.rs index 61eef2d7f..090909b91 100644 --- a/pulumi_wasm_random/src/bindings.rs +++ b/pulumi_wasm_random/src/bindings.rs @@ -193,6 +193,28 @@ pub mod component { } } } + impl Output { + #[allow(unused_unsafe, clippy::all)] + pub fn duplicate(&self,) -> Output{ + + #[allow(unused_imports)] + use wit_bindgen::rt::{alloc, vec::Vec, string::String}; + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "component:pulumi-wasm/output-interface@0.1.0")] + extern "C" { + #[link_name = "[method]output.duplicate"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + Output::from_handle(ret as u32) + } + } + } } @@ -204,14 +226,24 @@ pub mod component { #[cfg(target_arch = "wasm32")] static __FORCE_SECTION_REF: fn() = super::super::super::__link_section; pub type Output = super::super::super::component::pulumi_wasm::output_interface::Output; + pub struct ObjectField<'a,> { + /// name: list, //FIXME: String does not work + pub object: &'a Output, + } + impl<'a,> ::core::fmt::Debug for ObjectField<'a,> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ObjectField").field("object", &self.object).finish() + } + } pub struct RegisterResourceRequest<'a,> { pub type_: wit_bindgen::rt::string::String, pub name: wit_bindgen::rt::string::String, - pub object: &'a Output, + pub object_names: wit_bindgen::rt::vec::Vec::, + pub object: wit_bindgen::rt::vec::Vec::>, } impl<'a,> ::core::fmt::Debug for RegisterResourceRequest<'a,> { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("RegisterResourceRequest").field("type", &self.type_).field("name", &self.name).field("object", &self.object).finish() + f.debug_struct("RegisterResourceRequest").field("type", &self.type_).field("name", &self.name).field("object-names", &self.object_names).field("object", &self.object).finish() } } #[allow(unused_unsafe, clippy::all)] @@ -220,24 +252,75 @@ pub mod component { #[allow(unused_imports)] use wit_bindgen::rt::{alloc, vec::Vec, string::String}; unsafe { - let RegisterResourceRequest{ type_:type_0, name:name0, object:object0, } = request; + let RegisterResourceRequest{ type_:type_0, name:name0, object_names:object_names0, object:object0, } = request; let vec1 = type_0; let ptr1 = vec1.as_ptr() as i32; let len1 = vec1.len() as i32; let vec2 = name0; let ptr2 = vec2.as_ptr() as i32; let len2 = vec2.len() as i32; + let vec4 = object_names0; + let len4 = vec4.len() as i32; + let layout4 = alloc::Layout::from_size_align_unchecked(vec4.len() * 8, 4); + let result4 = if layout4.size() != 0 + { + let ptr = alloc::alloc(layout4); + if ptr.is_null() + { + alloc::handle_alloc_error(layout4); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4 as i32 + (i as i32) * 8; + { + let vec3 = e; + let ptr3 = vec3.as_ptr() as i32; + let len3 = vec3.len() as i32; + *((base + 4) as *mut i32) = len3; + *((base + 0) as *mut i32) = ptr3; + } + } + let vec6 = object0; + let len6 = vec6.len() as i32; + let layout6 = alloc::Layout::from_size_align_unchecked(vec6.len() * 4, 4); + let result6 = if layout6.size() != 0 + { + let ptr = alloc::alloc(layout6); + if ptr.is_null() + { + alloc::handle_alloc_error(layout6); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec6.into_iter().enumerate() { + let base = result6 as i32 + (i as i32) * 4; + { + let ObjectField{ object:object5, } = e; + *((base + 0) as *mut i32) = (object5).handle() as i32; + } + } #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "component:pulumi-wasm/register-interface@0.1.0")] extern "C" { #[link_name = "register"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ); + fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } - wit_import(ptr1, len1, ptr2, len2, (object0).handle() as i32); + fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, ){ unreachable!() } + wit_import(ptr1, len1, ptr2, len2, result4 as i32, len4, result6 as i32, len6); + if layout4.size() != 0 { + alloc::dealloc(result4, layout4); + } + if layout6.size() != 0 { + alloc::dealloc(result6, layout6); + } } } @@ -353,7 +436,7 @@ pub mod exports { #[cfg(target_arch = "wasm32")] #[link_section = "component-type:pulumi-provider-random"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 885] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 233, 5, 1, 65, 2, 1, 65, 7, 1, 66, 15, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 111, 2, 115, 4, 1, 112, 8, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 9, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 10, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 6, 111, 117, 116, 112, 117, 116, 1, 66, 7, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 104, 1, 1, 114, 3, 4, 116, 121, 112, 101, 115, 4, 110, 97, 109, 101, 115, 6, 111, 98, 106, 101, 99, 116, 2, 4, 0, 25, 114, 101, 103, 105, 115, 116, 101, 114, 45, 114, 101, 115, 111, 117, 114, 99, 101, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 3, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 4, 1, 0, 4, 0, 8, 114, 101, 103, 105, 115, 116, 101, 114, 1, 5, 3, 1, 46, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 114, 101, 103, 105, 115, 116, 101, 114, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 2, 1, 66, 17, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 107, 121, 1, 104, 1, 1, 107, 3, 1, 113, 2, 7, 108, 105, 116, 101, 114, 97, 108, 1, 2, 0, 3, 114, 101, 115, 1, 4, 0, 4, 0, 10, 101, 105, 116, 104, 101, 114, 45, 117, 51, 50, 3, 0, 5, 1, 106, 1, 121, 1, 3, 1, 114, 2, 4, 110, 97, 109, 101, 115, 6, 108, 101, 110, 103, 116, 104, 7, 4, 0, 18, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 97, 114, 103, 115, 3, 0, 8, 1, 105, 1, 1, 114, 2, 3, 117, 114, 108, 10, 6, 114, 101, 115, 117, 108, 116, 10, 4, 0, 20, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 114, 101, 115, 117, 108, 116, 3, 0, 11, 1, 64, 1, 4, 97, 114, 103, 115, 9, 1, 0, 4, 0, 20, 99, 114, 101, 97, 116, 101, 45, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 1, 13, 1, 64, 0, 1, 0, 4, 0, 16, 104, 97, 110, 100, 108, 101, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 14, 4, 1, 60, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 3, 4, 1, 50, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 64, 48, 46, 49, 46, 48, 4, 0, 11, 28, 1, 0, 22, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 974] = [0, 97, 115, 109, 13, 0, 1, 0, 0, 25, 22, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 4, 0, 7, 194, 6, 1, 65, 2, 1, 65, 7, 1, 66, 17, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 1, 1, 112, 125, 1, 105, 0, 1, 64, 1, 5, 118, 97, 108, 117, 101, 1, 0, 2, 4, 0, 19, 91, 99, 111, 110, 115, 116, 114, 117, 99, 116, 111, 114, 93, 111, 117, 116, 112, 117, 116, 1, 3, 1, 104, 0, 1, 64, 2, 4, 115, 101, 108, 102, 4, 13, 102, 117, 110, 99, 116, 105, 111, 110, 45, 110, 97, 109, 101, 115, 0, 2, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 109, 97, 112, 1, 5, 1, 107, 1, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 6, 4, 0, 18, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 103, 101, 116, 1, 7, 1, 64, 1, 4, 115, 101, 108, 102, 4, 0, 2, 4, 0, 24, 91, 109, 101, 116, 104, 111, 100, 93, 111, 117, 116, 112, 117, 116, 46, 100, 117, 112, 108, 105, 99, 97, 116, 101, 1, 8, 1, 111, 2, 115, 4, 1, 112, 9, 1, 64, 1, 6, 102, 105, 101, 108, 100, 115, 10, 0, 2, 4, 0, 13, 99, 114, 101, 97, 116, 101, 45, 115, 116, 114, 117, 99, 116, 1, 11, 3, 1, 44, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 111, 117, 116, 112, 117, 116, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 0, 2, 3, 0, 0, 6, 111, 117, 116, 112, 117, 116, 1, 66, 11, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 104, 1, 1, 114, 1, 6, 111, 98, 106, 101, 99, 116, 2, 4, 0, 12, 111, 98, 106, 101, 99, 116, 45, 102, 105, 101, 108, 100, 3, 0, 3, 1, 112, 115, 1, 112, 4, 1, 114, 4, 4, 116, 121, 112, 101, 115, 4, 110, 97, 109, 101, 115, 12, 111, 98, 106, 101, 99, 116, 45, 110, 97, 109, 101, 115, 5, 6, 111, 98, 106, 101, 99, 116, 6, 4, 0, 25, 114, 101, 103, 105, 115, 116, 101, 114, 45, 114, 101, 115, 111, 117, 114, 99, 101, 45, 114, 101, 113, 117, 101, 115, 116, 3, 0, 7, 1, 64, 1, 7, 114, 101, 113, 117, 101, 115, 116, 8, 1, 0, 4, 0, 8, 114, 101, 103, 105, 115, 116, 101, 114, 1, 9, 3, 1, 46, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 114, 101, 103, 105, 115, 116, 101, 114, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 2, 1, 66, 17, 2, 3, 2, 1, 1, 4, 0, 6, 111, 117, 116, 112, 117, 116, 3, 0, 0, 1, 107, 121, 1, 104, 1, 1, 107, 3, 1, 113, 2, 7, 108, 105, 116, 101, 114, 97, 108, 1, 2, 0, 3, 114, 101, 115, 1, 4, 0, 4, 0, 10, 101, 105, 116, 104, 101, 114, 45, 117, 51, 50, 3, 0, 5, 1, 106, 1, 121, 1, 3, 1, 114, 2, 4, 110, 97, 109, 101, 115, 6, 108, 101, 110, 103, 116, 104, 7, 4, 0, 18, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 97, 114, 103, 115, 3, 0, 8, 1, 105, 1, 1, 114, 2, 3, 117, 114, 108, 10, 6, 114, 101, 115, 117, 108, 116, 10, 4, 0, 20, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 45, 114, 101, 115, 117, 108, 116, 3, 0, 11, 1, 64, 1, 4, 97, 114, 103, 115, 9, 1, 0, 4, 0, 20, 99, 114, 101, 97, 116, 101, 45, 114, 97, 110, 100, 111, 109, 45, 115, 116, 114, 105, 110, 103, 1, 13, 1, 64, 0, 1, 0, 4, 0, 16, 104, 97, 110, 100, 108, 101, 45, 102, 117, 110, 99, 116, 105, 111, 110, 115, 1, 14, 4, 1, 60, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 45, 105, 110, 116, 101, 114, 102, 97, 99, 101, 64, 48, 46, 49, 46, 48, 5, 3, 4, 1, 50, 99, 111, 109, 112, 111, 110, 101, 110, 116, 58, 112, 117, 108, 117, 109, 105, 45, 119, 97, 115, 109, 47, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 64, 48, 46, 49, 46, 48, 4, 0, 11, 28, 1, 0, 22, 112, 117, 108, 117, 109, 105, 45, 112, 114, 111, 118, 105, 100, 101, 114, 45, 114, 97, 110, 100, 111, 109, 3, 0, 0, 0, 70, 9, 112, 114, 111, 100, 117, 99, 101, 114, 115, 1, 12, 112, 114, 111, 99, 101, 115, 115, 101, 100, 45, 98, 121, 2, 13, 119, 105, 116, 45, 99, 111, 109, 112, 111, 110, 101, 110, 116, 6, 48, 46, 50, 49, 46, 48, 16, 119, 105, 116, 45, 98, 105, 110, 100, 103, 101, 110, 45, 114, 117, 115, 116, 6, 48, 46, 49, 56, 46, 48]; #[inline(never)] #[doc(hidden)] diff --git a/pulumi_wasm_random/src/lib.rs b/pulumi_wasm_random/src/lib.rs index 631453b56..6ca3814bb 100644 --- a/pulumi_wasm_random/src/lib.rs +++ b/pulumi_wasm_random/src/lib.rs @@ -1,7 +1,5 @@ use crate::bindings::component::pulumi_wasm::output_interface::create_struct; -use crate::bindings::component::pulumi_wasm::register_interface::{ - register, RegisterResourceRequest, -}; +use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, register, RegisterResourceRequest}; use crate::bindings::exports::component::pulumi_wasm::pulumi_provider_random_interface::{ Guest, Output, RandomStringArgs, }; @@ -23,12 +21,18 @@ impl Guest for Component { Err(output) => output, }; - let object = create_struct(vec![("length".to_string(), length)].as_slice()); + // let object = vec![ + // ObjectField { + // name: "length".to_string().into_bytes(), + // object: length, + // } + // ]; let request = RegisterResourceRequest { type_: r#type, name: args.name, - object: &object, + object_names: vec!["length".to_string()], + object: vec![ObjectField { object: length }], }; register(request); diff --git a/wits/world.wit b/wits/world.wit index 7262297d8..93f1c36ed 100644 --- a/wits/world.wit +++ b/wits/world.wit @@ -1,18 +1,10 @@ package component:pulumi-wasm@0.1.0; -world pulumi-entrypoint { - export pulumi-main; - import external-world; -// import function-holder; -// export function-holder; -} - world pulumi-wasm { export output-interface; export register-interface; export function-reverse-callback; - // import function-holder; import external-world; } @@ -23,6 +15,7 @@ world main { world new-main { import pulumi-provider-random-interface; + import output-interface; export pulumi-main; } @@ -35,8 +28,6 @@ world pulumi-provider-random { world pulumi-rust { import output-interface; - -// export function-holder; } interface output-interface { @@ -47,16 +38,23 @@ interface output-interface { constructor(value: list); map: func(function-name: string) -> output; get: func() -> option>; + duplicate: func() -> output; } } interface register-interface { use output-interface.{output}; + record object-field { + // name: list, //FIXME: String does not work + object: borrow + } + record register-resource-request { %type: string, name: string, - object: borrow + object-names: list, + object: list, } register: func(request: register-resource-request); @@ -95,10 +93,6 @@ interface pulumi-main { main: func(); } -//interface function-holder { -// invoke-function: func(function-name: string, arg: list) -> list; -//} - interface function-reverse-callback { use output-interface.{output};