Skip to content

Commit

Permalink
Get functions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejressel committed Sep 26, 2024
1 parent 3b6e8b6 commit 72a84e1
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,21 @@ interface register-interface {
}

register: func(request: register-resource-request) -> register-resource-result;

record resource-invoke-result-field {
name: string,
output: output
}

record resource-invoke-request {
token: string,
object: list<object-field>,
results: list<result-field>
}

record resource-invoke-result {
fields: list<resource-invoke-result-field>
}

invoke: func(request: resource-invoke-request) -> resource-invoke-result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,21 @@ interface register-interface {
}

register: func(request: register-resource-request) -> register-resource-result;

record resource-invoke-result-field {
name: string,
output: output
}

record resource-invoke-request {
token: string,
object: list<object-field>,
results: list<result-field>
}

record resource-invoke-result {
fields: list<resource-invoke-result-field>
}

invoke: func(request: resource-invoke-request) -> resource-invoke-result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,21 @@ interface register-interface {
}

register: func(request: register-resource-request) -> register-resource-result;

record resource-invoke-result-field {
name: string,
output: output
}

record resource-invoke-request {
token: string,
object: list<object-field>,
results: list<result-field>
}

record resource-invoke-result {
fields: list<resource-invoke-result-field>
}

invoke: func(request: resource-invoke-request) -> resource-invoke-result;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;
use crate::bindings::exports::pulumi::mypkg::func_with_secrets;
use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, register, RegisterResourceRequest, ResultField};
use crate::bindings::component::pulumi_wasm::register_interface::{ObjectField, invoke, ResourceInvokeRequest, ResultField};
use crate::Component;

impl func_with_secrets::Guest for Component {
Expand All @@ -9,9 +9,8 @@ impl func_with_secrets::Guest for Component {
args: func_with_secrets::Args
) -> func_with_secrets::Res {
pulumi_wasm_common::setup_logger();
let request = RegisterResourceRequest {
type_: "mypkg::funcWithSecrets".into(),
name,
let request = ResourceInvokeRequest {
token: "mypkg::funcWithSecrets".into(),
object: vec![
ObjectField { name: "cryptoKey".into(), value: args.crypto_key },
ObjectField { name: "plaintext".into(), value: args.plaintext },
Expand All @@ -24,7 +23,7 @@ impl func_with_secrets::Guest for Component {
],
};

let o = register(&request);
let o = invoke(&request);

let mut hashmap: HashMap<String, _> = o.fields.into_iter().map(|f| (f.name, f.output)).collect();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod resource;
mod function;

#[allow(unused_braces)]
mod bindings;
bindings::export!(Component with_types_in bindings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,21 @@ interface register-interface {
}

register: func(request: register-resource-request) -> register-resource-result;

record resource-invoke-result-field {
name: string,
output: output
}

record resource-invoke-request {
token: string,
object: list<object-field>,
results: list<result-field>
}

record resource-invoke-result {
fields: list<resource-invoke-result-field>
}

invoke: func(request: resource-invoke-request) -> resource-invoke-result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,21 @@ interface register-interface {
}

register: func(request: register-resource-request) -> register-resource-result;

record resource-invoke-result-field {
name: string,
output: output
}

record resource-invoke-request {
token: string,
object: list<object-field>,
results: list<result-field>
}

record resource-invoke-result {
fields: list<resource-invoke-result-field>
}

invoke: func(request: resource-invoke-request) -> resource-invoke-result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,21 @@ interface register-interface {
}

register: func(request: register-resource-request) -> register-resource-result;

record resource-invoke-result-field {
name: string,
output: output
}

record resource-invoke-request {
token: string,
object: list<object-field>,
results: list<result-field>
}

record resource-invoke-result {
fields: list<resource-invoke-result-field>
}

invoke: func(request: resource-invoke-request) -> resource-invoke-result;
}

0 comments on commit 72a84e1

Please sign in to comment.