-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"email": "[email protected]", | ||
"name": "Elad Ben-Israel" | ||
}, | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/winglang/winglibs.git", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
bring expect; | ||
bring util; | ||
bring "./provider.w" as tf; | ||
|
||
if util.env("WING_TARGET").startsWith("tf") { | ||
let provider = new tf.Provider( | ||
name: "dnsimple", | ||
source: "dnsimple/dnsimple", | ||
version: "1.6.0", | ||
attributes: { | ||
token: "dnsimple_token", | ||
} | ||
) as "DnsimpleProvider"; | ||
|
||
let tfconfig: Json = provider.toTerraform(); | ||
expect.equal(tfconfig["terraform"]["required_providers"], { "dnsimple": { "source": "dnsimple/dnsimple", "version": "1.6.0" } }); | ||
expect.equal(tfconfig["provider"], { "dnsimple": [{ "token": "dnsimple_token" }] }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
bring "cdktf" as cdktf; | ||
|
||
pub struct ProviderProps { | ||
/// The name of the provider in Terraform - this is the prefix used for all resources in the provider. | ||
/// @example "aws" | ||
name: str; | ||
/// The source of the provider on the Terraform Registry. | ||
/// @example "hashicorp/aws" | ||
source: str; | ||
/// The version of the provider to use. | ||
/// @example "2.0" | ||
version: str; | ||
/// The provider-specific configuration options. | ||
/// @default {} | ||
attributes: Json?; | ||
} | ||
|
||
pub class Provider extends cdktf.TerraformProvider { | ||
attributes: Json; | ||
|
||
new(props: ProviderProps) { | ||
super( | ||
terraformResourceType: props.name, | ||
terraformGeneratorMetadata: { | ||
providerName: props.name, | ||
providerVersion: props.version, | ||
}, | ||
terraformProviderSource: props.source, | ||
); | ||
|
||
this.attributes = props.attributes ?? {}; | ||
} | ||
|
||
protected synthesizeAttributes(): Json { | ||
return this.attributes; | ||
} | ||
} |