Skip to content

Commit

Permalink
Add auto-mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Ringo De Smet <ringo@de-smet.name>
  • Loading branch information
ringods committed Nov 5, 2024
1 parent 486238b commit 3ce7ae5
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 11 deletions.
65 changes: 65 additions & 0 deletions provider/cmd/pulumi-resource-talos/bridge-metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,69 @@
{
"auto-aliasing": {
"resources": {
"talos_machine_bootstrap": {
"current": "talos:machine/bootstrap:Bootstrap"
},
"talos_machine_configuration_apply": {
"current": "talos:machine/configurationApply:ConfigurationApply",
"fields": {
"config_patches": {
"maxItemsOne": false
}
}
},
"talos_machine_secrets": {
"current": "talos:machine/secrets:Secrets"
}
},
"datasources": {
"talos_client_configuration": {
"current": "talos:client/getConfiguration:getConfiguration",
"fields": {
"endpoints": {
"maxItemsOne": false
},
"nodes": {
"maxItemsOne": false
}
}
},
"talos_cluster_health": {
"current": "talos:cluster/getHealth:getHealth",
"fields": {
"control_plane_nodes": {
"maxItemsOne": false
},
"endpoints": {
"maxItemsOne": false
},
"worker_nodes": {
"maxItemsOne": false
}
}
},
"talos_cluster_kubeconfig": {
"current": "talos:cluster/getKubeconfig:getKubeconfig"
},
"talos_machine_configuration": {
"current": "talos:machine/getConfiguration:getConfiguration",
"fields": {
"config_patches": {
"maxItemsOne": false
}
}
},
"talos_machine_disks": {
"current": "talos:machine/getDisks:getDisks",
"fields": {
"disks": {
"maxItemsOne": false
}
}
}
}
},
"auto-settings": {},
"functions": {
"talos:client/configuration:Configuration": "talos_client_configuration",
"talos:cluster/kubeconfig:Kubeconfig": "talos_cluster_kubeconfig",
Expand Down
28 changes: 17 additions & 11 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

pf "github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
tks "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens"
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"

"github.com/pulumiverse/pulumi-talos/provider/pkg/version"
Expand All @@ -35,7 +36,7 @@ var metadata []byte

// Provider returns additional overlaid schema and metadata associated with the provider..
func Provider() tfbridge.ProviderInfo {
info := tfbridge.ProviderInfo{
prov := tfbridge.ProviderInfo{
P: pf.ShimProvider(talos.New()),
Name: talosPkg,
Description: "A Pulumi package for creating and managing Talos Linux machines and clusters.",
Expand Down Expand Up @@ -254,7 +255,6 @@ func Provider() tfbridge.ProviderInfo {
},
Resources: map[string]*tfbridge.ResourceInfo{
"talos_machine_bootstrap": {
Tok: tfbridge.MakeResource(talosPkg, machineMod, "Bootstrap"),
Fields: map[string]*tfbridge.SchemaInfo{
"client_configuration": {
Elem: &tfbridge.SchemaInfo{
Expand All @@ -264,7 +264,6 @@ func Provider() tfbridge.ProviderInfo {
},
},
"talos_machine_configuration_apply": {
Tok: tfbridge.MakeResource(talosPkg, machineMod, "ConfigurationApply"),
Fields: map[string]*tfbridge.SchemaInfo{
"timeouts": {
Elem: &tfbridge.SchemaInfo{
Expand All @@ -279,7 +278,6 @@ func Provider() tfbridge.ProviderInfo {
},
},
"talos_machine_secrets": {
Tok: tfbridge.MakeResource(talosPkg, machineMod, "Secrets"),
Fields: map[string]*tfbridge.SchemaInfo{
"client_configuration": {
Elem: &tfbridge.SchemaInfo{
Expand All @@ -295,11 +293,7 @@ func Provider() tfbridge.ProviderInfo {
},
},
DataSources: map[string]*tfbridge.DataSourceInfo{
"talos_client_configuration": {Tok: tfbridge.MakeDataSource(talosPkg, clientMod, "getConfiguration")},
"talos_cluster_health": {Tok: tfbridge.MakeDataSource(talosPkg, clusterMod, "getHealth")},
"talos_cluster_kubeconfig": {Tok: tfbridge.MakeDataSource(talosPkg, clusterMod, "getKubeconfig")},
"talos_machine_configuration": {
Tok: tfbridge.MakeDataSource(talosPkg, machineMod, "getConfiguration"),
Fields: map[string]*tfbridge.SchemaInfo{
"machine_secrets": {
Elem: &tfbridge.SchemaInfo{
Expand All @@ -308,7 +302,6 @@ func Provider() tfbridge.ProviderInfo {
},
},
},
"talos_machine_disks": {Tok: tfbridge.MakeDataSource(talosPkg, machineMod, "getDisks")},
},
JavaScript: &tfbridge.JavaScriptInfo{
PackageName: "@pulumiverse/talos",
Expand Down Expand Up @@ -350,7 +343,20 @@ func Provider() tfbridge.ProviderInfo {
},
}

info.SetAutonaming(255, "-")
prov.MustComputeTokens(
tks.KnownModules(
"talos_",
"index",
[]string{
clientMod,
clusterMod,
machineMod,
},
tks.MakeStandard(talosPkg),
),
)
prov.SetAutonaming(255, "-")
prov.MustApplyAutoAliases()

return info
return prov
}

0 comments on commit 3ce7ae5

Please sign in to comment.