Skip to content

Commit

Permalink
String const
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejressel committed Dec 15, 2024
1 parent 27131a6 commit 8fb5d97
Show file tree
Hide file tree
Showing 22 changed files with 39 additions and 30 deletions.
4 changes: 2 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.

Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ fn remove_option(type_: &Type) -> TypeWithoutOption {
Type::Integer => TypeWithoutOption::Integer,
Type::Number => TypeWithoutOption::Number,
Type::String => TypeWithoutOption::String,
Type::ConstString(s) => TypeWithoutOption::String,
Type::ConstString(_) => TypeWithoutOption::String,
Type::Array(a) => TypeWithoutOption::Array(Box::new(remove_option(a))),
Type::Object(o) => TypeWithoutOption::Object(Box::new(remove_option(o))),
Type::Ref(r) => TypeWithoutOption::Ref(r.clone()),
Expand Down
5 changes: 4 additions & 1 deletion pulumi_wasm_generator_lib/src/model.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::utils::{escape_rust_name, escape_wit_identifier, replace_multiple_dashes};
use anyhow::{Context, Result};
use convert_case::Case;
use convert_case::Case::UpperCamel;
use convert_case::Casing;
use std::collections::BTreeMap;

Expand Down Expand Up @@ -49,7 +50,9 @@ impl Type {
.collect::<Vec<_>>()
.join(", ")
),
Type::ConstString(s) => format!("crate::ConstString_{}", s).to_string(),
Type::ConstString(s) => {
format!("crate::ConstString{}", s.to_case(UpperCamel)).to_string()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ fn into_domain<F: serde::Serialize>(output: WitOutput) -> Output<F> {
}
{{/if}}
{{#each package.const_strings}}
pulumi_wasm_provider_common::generate_string_const!(ConstString_{{&this}}, "{{&this}}");
pulumi_wasm_provider_common::generate_string_const!(ConstString{{&this}}, "{{&this}}");
{{/each}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::model::GlobalType;
use crate::output::get_main_version;
use convert_case::Case::UpperCamel;
use convert_case::Casing;
use handlebars::Handlebars;
use itertools::Itertools;
use serde::Serialize;
Expand Down Expand Up @@ -59,7 +61,11 @@ fn find_consts(package: &crate::model::Package) -> Vec<String> {
}
}
}
consts.into_iter().sorted().collect()
consts
.into_iter()
.map(|s| s.to_case(UpperCamel))
.sorted()
.collect()
}

pub(crate) fn generate_source_code(package: &crate::model::Package) -> String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ mod bindings {
fn into_domain<F: serde::Serialize>(output: WitOutput) -> Output<F> {
unsafe { Output::<F>::new_from_handle(output) }
}
pulumi_wasm_provider_common::generate_string_const!(ConstString_Pav2, "Pav2");
pulumi_wasm_provider_common::generate_string_const!(ConstString_Purchase, "Purchase");
pulumi_wasm_provider_common::generate_string_const!(ConstStringPav2, "Pav2");
pulumi_wasm_provider_common::generate_string_const!(ConstStringPurchase, "Purchase");
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct Pav2MeterDetailsResponse {
/// Expected value is 'Pav2'.
#[builder(into, default)]
#[serde(rename = "billingType")]
pub r#billing_type: Box<crate::ConstString_Pav2>,
pub r#billing_type: Box<crate::ConstStringPav2>,
/// Charging type.
#[builder(into)]
#[serde(rename = "chargingType")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct PurchaseMeterDetailsResponse {
/// Expected value is 'Purchase'.
#[builder(into, default)]
#[serde(rename = "billingType")]
pub r#billing_type: Box<crate::ConstString_Purchase>,
pub r#billing_type: Box<crate::ConstStringPurchase>,
/// Charging type.
#[builder(into)]
#[serde(rename = "chargingType")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[builder(finish_fn = build_struct)]
pub struct FuncWithConstInputArgs {
#[builder(into, default)]
pub plain_input: pulumi_wasm_rust::Output<Option<crate::ConstString_fixed>>,
pub plain_input: pulumi_wasm_rust::Output<Option<crate::ConstStringFixed>>,
}

pub struct FuncWithConstInputResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ mod bindings {
fn into_domain<F: serde::Serialize>(output: WitOutput) -> Output<F> {
unsafe { Output::<F>::new_from_handle(output) }
}
pulumi_wasm_provider_common::generate_string_const!(ConstString_Environment, "Environment");
pulumi_wasm_provider_common::generate_string_const!(ConstString_Folder, "Folder");
pulumi_wasm_provider_common::generate_string_const!(ConstString_Package, "Package");
pulumi_wasm_provider_common::generate_string_const!(ConstString_Project, "Project");
pulumi_wasm_provider_common::generate_string_const!(ConstString_fixed, "fixed");
pulumi_wasm_provider_common::generate_string_const!(ConstStringEnvironment, "Environment");
pulumi_wasm_provider_common::generate_string_const!(ConstStringFixed, "Fixed");
pulumi_wasm_provider_common::generate_string_const!(ConstStringFolder, "Folder");
pulumi_wasm_provider_common::generate_string_const!(ConstStringPackage, "Package");
pulumi_wasm_provider_common::generate_string_const!(ConstStringProject, "Project");
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct SsisEnvironmentResponse {
/// Expected value is 'Environment'.
#[builder(into, default)]
#[serde(rename = "type")]
pub r#type: Box<crate::ConstString_Environment>,
pub r#type: Box<crate::ConstStringEnvironment>,
/// Variable in environment
#[builder(into, default)]
#[serde(rename = "variables")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ pub struct SsisFolderResponse {
/// Expected value is 'Folder'.
#[builder(into, default)]
#[serde(rename = "type")]
pub r#type: Box<crate::ConstString_Folder>,
pub r#type: Box<crate::ConstStringFolder>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ pub struct SsisPackageResponse {
/// Expected value is 'Package'.
#[builder(into, default)]
#[serde(rename = "type")]
pub r#type: Box<crate::ConstString_Package>,
pub r#type: Box<crate::ConstStringPackage>,
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct SsisProjectResponse {
/// Expected value is 'Project'.
#[builder(into, default)]
#[serde(rename = "type")]
pub r#type: Box<crate::ConstString_Project>,
pub r#type: Box<crate::ConstStringProject>,
/// Project version.
#[builder(into, default)]
#[serde(rename = "version")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ mod bindings {
fn into_domain<F: serde::Serialize>(output: WitOutput) -> Output<F> {
unsafe { Output::<F>::new_from_handle(output) }
}
pulumi_wasm_provider_common::generate_string_const!(ConstString_PointInTimeRestore, "PointInTimeRestore");
pulumi_wasm_provider_common::generate_string_const!(ConstString_Replica, "Replica");
pulumi_wasm_provider_common::generate_string_const!(ConstStringPointInTimeRestore, "PointInTimeRestore");
pulumi_wasm_provider_common::generate_string_const!(ConstStringReplica, "Replica");
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub struct ServerPropertiesForReplica {
#[builder(into, default)]
#[serde(rename = "createMode")]
pub r#create_mode: Box<crate::ConstString_Replica>,
pub r#create_mode: Box<crate::ConstStringReplica>,
#[builder(into, default)]
#[serde(rename = "version")]
pub r#version: Box<Option<String>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub struct ServerPropertiesForRestore {
#[builder(into, default)]
#[serde(rename = "createMode")]
pub r#create_mode: Box<crate::ConstString_PointInTimeRestore>,
pub r#create_mode: Box<crate::ConstStringPointInTimeRestore>,
#[builder(into)]
#[serde(rename = "restorePointInTime")]
pub r#restore_point_in_time: Box<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ mod bindings {
fn into_domain<F: serde::Serialize>(output: WitOutput) -> Output<F> {
unsafe { Output::<F>::new_from_handle(output) }
}
pulumi_wasm_provider_common::generate_string_const!(ConstString_PointInTimeRestore, "PointInTimeRestore");
pulumi_wasm_provider_common::generate_string_const!(ConstString_Replica, "Replica");
pulumi_wasm_provider_common::generate_string_const!(ConstStringPointInTimeRestore, "PointInTimeRestore");
pulumi_wasm_provider_common::generate_string_const!(ConstStringReplica, "Replica");
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub struct ServerPropertiesForReplica {
#[builder(into, default)]
#[serde(rename = "createMode")]
pub r#create_mode: Box<crate::ConstString_Replica>,
pub r#create_mode: Box<crate::ConstStringReplica>,
#[builder(into, default)]
#[serde(rename = "version")]
pub r#version: Box<Option<String>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub struct ServerPropertiesForRestore {
#[builder(into, default)]
#[serde(rename = "createMode")]
pub r#create_mode: Box<crate::ConstString_PointInTimeRestore>,
pub r#create_mode: Box<crate::ConstStringPointInTimeRestore>,
#[builder(into)]
#[serde(rename = "restorePointInTime")]
pub r#restore_point_in_time: Box<String>,
Expand Down

0 comments on commit 8fb5d97

Please sign in to comment.