Skip to content

Commit

Permalink
Add auto mapping (#51)
Browse files Browse the repository at this point in the history
* Set up auto aliasing
* Let Pulumi auto-name when now value for `name` property is given.
  • Loading branch information
ringods authored Nov 4, 2024
1 parent de88ea4 commit 2879aae
Show file tree
Hide file tree
Showing 27 changed files with 288 additions and 165 deletions.
169 changes: 169 additions & 0 deletions provider/cmd/pulumi-resource-cockroach/bridge-metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,173 @@
{
"auto-aliasing": {
"resources": {
"cockroach_allow_list": {
"current": "cockroach:index/allowList:AllowList"
},
"cockroach_api_key": {
"current": "cockroach:index/apiKey:ApiKey"
},
"cockroach_api_oidc_config": {
"current": "cockroach:index/apiOidcConfig:ApiOidcConfig",
"fields": {
"identity_map": {
"maxItemsOne": false
}
}
},
"cockroach_client_ca_cert": {
"current": "cockroach:index/caCert:CaCert"
},
"cockroach_cluster": {
"current": "cockroach:index/cluster:Cluster",
"fields": {
"regions": {
"maxItemsOne": false
}
}
},
"cockroach_cmek": {
"current": "cockroach:index/cmek:Cmek",
"fields": {
"additional_regions": {
"maxItemsOne": false
},
"regions": {
"maxItemsOne": false
}
}
},
"cockroach_database": {
"current": "cockroach:index/database:Database"
},
"cockroach_finalize_version_upgrade": {
"current": "cockroach:index/finalizeVersionUpgrade:FinalizeVersionUpgrade"
},
"cockroach_folder": {
"current": "cockroach:index/folder:Folder"
},
"cockroach_log_export_config": {
"current": "cockroach:index/logExportConfig:LogExportConfig",
"fields": {
"groups": {
"maxItemsOne": false,
"elem": {
"fields": {
"channels": {
"maxItemsOne": false
}
}
}
},
"omitted_channels": {
"maxItemsOne": false
}
}
},
"cockroach_maintenance_window": {
"current": "cockroach:index/maintenanceWindow:MaintenanceWindow"
},
"cockroach_metric_export_cloudwatch_config": {
"current": "cockroach:index/metricExportCloudwatchConfig:MetricExportCloudwatchConfig"
},
"cockroach_metric_export_datadog_config": {
"current": "cockroach:index/metricExportDatadogConfig:MetricExportDatadogConfig"
},
"cockroach_metric_export_prometheus_config": {
"current": "cockroach:index/metricExportPrometheusConfig:MetricExportPrometheusConfig"
},
"cockroach_private_endpoint_connection": {
"current": "cockroach:index/privateEndpointConnection:PrivateEndpointConnection"
},
"cockroach_private_endpoint_services": {
"current": "cockroach:index/privateEndpointServices:PrivateEndpointServices",
"fields": {
"services": {
"maxItemsOne": false,
"elem": {
"fields": {
"availability_zone_ids": {
"maxItemsOne": false
},
"aws": {
"fields": {
"availability_zone_ids": {
"maxItemsOne": false
}
}
}
}
}
},
"services_map": {
"elem": {
"fields": {
"availability_zone_ids": {
"maxItemsOne": false
},
"aws": {
"fields": {
"availability_zone_ids": {
"maxItemsOne": false
}
}
}
}
}
}
}
},
"cockroach_private_endpoint_trusted_owner": {
"current": "cockroach:index/privateEndpointTrustedOwner:PrivateEndpointTrustedOwner"
},
"cockroach_service_account": {
"current": "cockroach:index/serviceAccount:ServiceAccount"
},
"cockroach_sql_user": {
"current": "cockroach:index/sqlUser:SqlUser"
},
"cockroach_user_role_grant": {
"current": "cockroach:index/userRoleGrant:UserRoleGrant"
},
"cockroach_user_role_grants": {
"current": "cockroach:index/userRoleGrants:UserRoleGrants",
"fields": {
"roles": {
"maxItemsOne": false
}
}
},
"cockroach_version_deferral": {
"current": "cockroach:index/versionDeferral:VersionDeferral"
}
},
"datasources": {
"cockroach_cluster": {
"current": "cockroach:index/getCockroachCluster:getCockroachCluster",
"fields": {
"regions": {
"maxItemsOne": false
}
}
},
"cockroach_cluster_cert": {
"current": "cockroach:index/getClusterCert:getClusterCert"
},
"cockroach_connection_string": {
"current": "cockroach:index/getConnectionString:getConnectionString"
},
"cockroach_folder": {
"current": "cockroach:index/getFolder:getFolder"
},
"cockroach_organization": {
"current": "cockroach:index/getOrganization:getOrganization"
},
"cockroach_person_user": {
"current": "cockroach:index/getPersonUser:getPersonUser"
}
}
},
"auto-settings": {},
"renames": {
"resources": {
"cockroach:index/allowList:AllowList": "cockroach_allow_list",
Expand Down
12 changes: 2 additions & 10 deletions provider/cmd/pulumi-resource-cockroach/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,6 @@
}
},
"requiredInputs": [
"name",
"serviceAccountId"
],
"stateInputs": {
Expand Down Expand Up @@ -1202,7 +1201,6 @@
},
"requiredInputs": [
"cloudProvider",
"name",
"regions"
],
"stateInputs": {
Expand Down Expand Up @@ -1385,8 +1383,7 @@
}
},
"requiredInputs": [
"clusterId",
"name"
"clusterId"
],
"stateInputs": {
"description": "Input properties used for looking up and filtering Database resources.\n",
Expand Down Expand Up @@ -1479,7 +1476,6 @@
}
},
"requiredInputs": [
"name",
"parentId"
],
"stateInputs": {
Expand Down Expand Up @@ -2180,9 +2176,6 @@
"description": "Name of the service account.\n"
}
},
"requiredInputs": [
"name"
],
"stateInputs": {
"description": "Input properties used for looking up and filtering ServiceAccount resources.\n",
"properties": {
Expand Down Expand Up @@ -2239,8 +2232,7 @@
}
},
"requiredInputs": [
"clusterId",
"name"
"clusterId"
],
"stateInputs": {
"description": "Input properties used for looking up and filtering SqlUser resources.\n",
Expand Down
9 changes: 7 additions & 2 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

tfpfbridge "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/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"

Expand Down Expand Up @@ -59,7 +60,7 @@ func computeIDField(field resource.PropertyKey) tfbridge.ComputeID {

// Provider returns additional overlaid schema and metadata associated with the tls package.
func Provider() tfbridge.ProviderInfo {
info := tfbridge.ProviderInfo{
prov := tfbridge.ProviderInfo{
P: tfpfbridge.ShimProvider(shim.NewProvider(version.Version)),
Name: "cockroach",
DisplayName: "CockroachDB",
Expand Down Expand Up @@ -231,5 +232,9 @@ func Provider() tfbridge.ProviderInfo {
},
}

return info
prov.MustComputeTokens(tks.SingleModule("cockroach_", cockroachMod, tks.MakeStandard(cockroachPkg)))
prov.SetAutonaming(255, "-")
prov.MustApplyAutoAliases()

return prov
}
4 changes: 2 additions & 2 deletions sdk/dotnet/ApiKey.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/dotnet/Cluster.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/dotnet/Database.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/dotnet/Folder.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions sdk/dotnet/ServiceAccount.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/dotnet/SqlUser.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions sdk/go/cockroach/apiKey.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions sdk/go/cockroach/cluster.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2879aae

Please sign in to comment.