customize resources
This commit is contained in:
@@ -32,10 +32,8 @@ providerDefaultBranch: main
|
|||||||
|
|
||||||
# Explicit list of languages to support for SDKs. Java is currently excluded because it doesn't yet work well for non-internal providers.
|
# Explicit list of languages to support for SDKs. Java is currently excluded because it doesn't yet work well for non-internal providers.
|
||||||
languages:
|
languages:
|
||||||
- dotnet
|
|
||||||
- go
|
- go
|
||||||
- nodejs
|
- nodejs
|
||||||
- python
|
|
||||||
|
|
||||||
# Disable Java publishing and pushing the provider binary to the CDN as these only work internally within Pulumi.
|
# Disable Java publishing and pushing the provider binary to the CDN as these only work internally within Pulumi.
|
||||||
publish:
|
publish:
|
||||||
|
|||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -16,6 +16,7 @@ Pulumi.*.yaml
|
|||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
|
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
pnpm-lock.yaml
|
||||||
**/pulumiManifest.go
|
**/pulumiManifest.go
|
||||||
|
|
||||||
ci-scripts
|
ci-scripts
|
||||||
@@ -35,5 +36,9 @@ sdk/python/venv
|
|||||||
go.work
|
go.work
|
||||||
go.work.sum
|
go.work.sum
|
||||||
|
|
||||||
|
*.pem
|
||||||
|
*.key
|
||||||
|
*.crt
|
||||||
|
|
||||||
# Ignore local build tracking directory
|
# Ignore local build tracking directory
|
||||||
.make
|
.make
|
||||||
|
|||||||
1
LICENSE
Normal file
1
LICENSE
Normal file
@@ -0,0 +1 @@
|
|||||||
|
This SDK is © 2025 Brandon Kalinowski. No license is provided to users other than the author.
|
||||||
14
Makefile
14
Makefile
@@ -50,9 +50,9 @@ only_build: build
|
|||||||
prepare_local_workspace: install_plugins upstream
|
prepare_local_workspace: install_plugins upstream
|
||||||
# Creates all generated files which need to be committed
|
# Creates all generated files which need to be committed
|
||||||
generate: generate_sdks schema
|
generate: generate_sdks schema
|
||||||
generate_sdks: generate_dotnet generate_go generate_nodejs generate_python
|
generate_sdks: generate_go generate_nodejs
|
||||||
build_sdks: build_dotnet build_go build_nodejs build_python
|
build_sdks: build_go build_nodejs
|
||||||
install_sdks: install_dotnet_sdk install_go_sdk install_nodejs_sdk install_python_sdk
|
install_sdks: install_go_sdk install_nodejs_sdk
|
||||||
.PHONY: development only_build build generate generate_sdks build_sdks install_sdks
|
.PHONY: development only_build build generate generate_sdks build_sdks install_sdks
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@@ -146,9 +146,9 @@ build_nodejs: .make/build_nodejs
|
|||||||
@touch $@
|
@touch $@
|
||||||
.make/build_nodejs: .make/generate_nodejs
|
.make/build_nodejs: .make/generate_nodejs
|
||||||
cd sdk/nodejs/ && \
|
cd sdk/nodejs/ && \
|
||||||
yarn install && \
|
pnpm install && \
|
||||||
yarn run tsc && \
|
pnpm tsc && \
|
||||||
cp ../../README.md ../../LICENSE* package.json yarn.lock ./bin/
|
cp ../../README.md ../../LICENSE* package.json pnpm-lock.yaml ./bin/
|
||||||
@touch $@
|
@touch $@
|
||||||
.PHONY: generate_nodejs build_nodejs
|
.PHONY: generate_nodejs build_nodejs
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ install_go_sdk:
|
|||||||
install_java_sdk:
|
install_java_sdk:
|
||||||
install_nodejs_sdk: .make/install_nodejs_sdk
|
install_nodejs_sdk: .make/install_nodejs_sdk
|
||||||
.make/install_nodejs_sdk: .make/build_nodejs
|
.make/install_nodejs_sdk: .make/build_nodejs
|
||||||
yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin
|
pnpm link --global $(WORKING_DIR)/sdk/nodejs/bin
|
||||||
@touch $@
|
@touch $@
|
||||||
install_python_sdk:
|
install_python_sdk:
|
||||||
.PHONY: install_dotnet_sdk install_go_sdk install_java_sdk install_nodejs_sdk install_python_sdk
|
.PHONY: install_dotnet_sdk install_go_sdk install_java_sdk install_nodejs_sdk install_python_sdk
|
||||||
|
|||||||
35
README.md
35
README.md
@@ -8,48 +8,21 @@ This package is available for several languages/platforms:
|
|||||||
|
|
||||||
### Node.js (JavaScript/TypeScript)
|
### Node.js (JavaScript/TypeScript)
|
||||||
|
|
||||||
To use from JavaScript or TypeScript in Node.js, install using either `npm`:
|
To use from JavaScript or TypeScript in Node.js, install using `pnpm`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install @kiterun/incus
|
pnpm install @kiterun/incus
|
||||||
```
|
```
|
||||||
|
|
||||||
or `yarn`:
|
### Go (unsupported)
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn add @kiterun/incus
|
|
||||||
```
|
|
||||||
|
|
||||||
### Python
|
|
||||||
|
|
||||||
To use from Python, install using `pip`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install pulumi_incus
|
|
||||||
```
|
|
||||||
|
|
||||||
### Go
|
|
||||||
|
|
||||||
To use from Go, use `go get` to grab the latest version of the library:
|
To use from Go, use `go get` to grab the latest version of the library:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go get github.com/pulumi/pulumi-incus/sdk/go/...
|
go get git.kalinow.ski/nimbus/pulumi-incus/sdk/go/...
|
||||||
```
|
```
|
||||||
|
|
||||||
### .NET
|
|
||||||
|
|
||||||
To use from .NET, install using `dotnet add package`:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
dotnet add package Pulumi.Incus
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
The following configuration points are available for the `incus` provider:
|
|
||||||
|
|
||||||
- `incus:region` (environment: `INCUS_REGION`) - the region in which to deploy resources
|
|
||||||
|
|
||||||
## Reference
|
## Reference
|
||||||
|
|
||||||
For detailed reference documentation, please visit [the Pulumi registry](https://www.pulumi.com/registry/packages/incus/api-docs/).
|
For detailed reference documentation, please visit [the Pulumi registry](https://www.pulumi.com/registry/packages/incus/api-docs/).
|
||||||
|
|||||||
2
examples/basic-ts/.gitignore
vendored
2
examples/basic-ts/.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
/bin/
|
/bin/
|
||||||
/node_modules/
|
/node_modules/
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import * as pulumi from "@pulumi/pulumi";
|
import * as incus from "@kiterun/incus";
|
||||||
import * as xyz from "@pulumi/xyz";
|
|
||||||
|
|
||||||
const resource = new xyz.Resource("Resource", { sampleAttribute: "attr" });
|
const resource = new incus.Instance("instance1", {
|
||||||
|
image: "images:ubuntu/22.04",
|
||||||
|
project: "default",
|
||||||
|
config: {
|
||||||
|
"limits.cpu": "4",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
export const sampleAttribute = resource.sampleAttribute;
|
export const ip1 = resource.ipv4Address;
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
"@types/node": "^18"
|
"@types/node": "^18"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@kiterun/incus": "link:../../../../../../Library/pnpm/global/5/node_modules/@kiterun/incus",
|
||||||
"@pulumi/pulumi": "^3.0.0"
|
"@pulumi/pulumi": "^3.0.0"
|
||||||
|
},
|
||||||
|
"pnpm": {
|
||||||
|
"overrides": {
|
||||||
|
"@kiterun/incus": "link:../../../../../../Library/pnpm/global/5/node_modules/@kiterun/incus"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ require (
|
|||||||
github.com/lxc/terraform-provider-incus/shim v0.0.0-00010101000000-000000000000
|
github.com/lxc/terraform-provider-incus/shim v0.0.0-00010101000000-000000000000
|
||||||
github.com/pulumi/pulumi-terraform-bridge/v3 v3.106.0
|
github.com/pulumi/pulumi-terraform-bridge/v3 v3.106.0
|
||||||
github.com/pulumi/pulumi/pkg/v3 v3.160.0
|
github.com/pulumi/pulumi/pkg/v3 v3.160.0
|
||||||
|
github.com/pulumi/pulumi/sdk/v3 v3.160.0
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -143,7 +144,6 @@ require (
|
|||||||
github.com/pulumi/inflector v0.1.1 // indirect
|
github.com/pulumi/inflector v0.1.1 // indirect
|
||||||
github.com/pulumi/pulumi-java/pkg v1.8.0 // indirect
|
github.com/pulumi/pulumi-java/pkg v1.8.0 // indirect
|
||||||
github.com/pulumi/pulumi-yaml v1.15.1 // indirect
|
github.com/pulumi/pulumi-yaml v1.15.1 // indirect
|
||||||
github.com/pulumi/pulumi/sdk/v3 v3.160.0 // indirect
|
|
||||||
github.com/pulumi/schema-tools v0.1.2 // indirect
|
github.com/pulumi/schema-tools v0.1.2 // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||||
|
|||||||
@@ -15,7 +15,10 @@
|
|||||||
package incus
|
package incus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
// Allow embedding bridge-metadata.json in the provider.
|
// Allow embedding bridge-metadata.json in the provider.
|
||||||
_ "embed"
|
_ "embed"
|
||||||
@@ -23,8 +26,10 @@ import (
|
|||||||
incus "github.com/lxc/terraform-provider-incus/shim" // Import the upstream provider
|
incus "github.com/lxc/terraform-provider-incus/shim" // Import the upstream provider
|
||||||
pfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge"
|
pfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge"
|
||||||
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
|
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
|
||||||
|
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
|
||||||
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens"
|
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens"
|
||||||
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
|
"github.com/pulumi/pulumi/pkg/v3/codegen/schema"
|
||||||
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
||||||
|
|
||||||
"github.com/brandonkal/pulumi-incus/provider/pkg/version"
|
"github.com/brandonkal/pulumi-incus/provider/pkg/version"
|
||||||
)
|
)
|
||||||
@@ -38,9 +43,7 @@ const (
|
|||||||
mainMod = "index" // the incus module
|
mainMod = "index" // the incus module
|
||||||
)
|
)
|
||||||
|
|
||||||
// Temporarily comment out the bridge-metadata.json embedding
|
//go:embed cmd/pulumi-resource-incus/bridge-metadata.json
|
||||||
// //go:embed cmd/pulumi-resource-incus/bridge-metadata.json
|
|
||||||
// var metadata []byte
|
|
||||||
var metadata []byte
|
var metadata []byte
|
||||||
|
|
||||||
// Provider returns additional overlaid schema and metadata associated with the provider.
|
// Provider returns additional overlaid schema and metadata associated with the provider.
|
||||||
@@ -131,37 +134,40 @@ func Provider() tfbridge.ProviderInfo {
|
|||||||
// category/cloud tag helps with categorizing the package in the Pulumi Registry.
|
// category/cloud tag helps with categorizing the package in the Pulumi Registry.
|
||||||
// For all available categories, see `Keywords` in
|
// For all available categories, see `Keywords` in
|
||||||
// https://www.pulumi.com/docs/guides/pulumi-packages/schema/#package.
|
// https://www.pulumi.com/docs/guides/pulumi-packages/schema/#package.
|
||||||
Keywords: []string{"incus", "category/cloud"},
|
Keywords: []string{"incus", "category/cloud", "containers", "nimbus"},
|
||||||
License: "Apache-2.0",
|
License: "Apache-2.0",
|
||||||
Homepage: "https://linuxcontainers.org",
|
Homepage: "https://linuxcontainers.org",
|
||||||
Repository: "https://github.com/brandonkal/pulumi-incus",
|
Repository: "https://git.kalinow.ski/nimbus/pulumi-incus",
|
||||||
// The GitHub Org for the provider - defaults to `terraform-providers`. Note that this should
|
// The GitHub Org for the provider - defaults to `terraform-providers`. Note that this should
|
||||||
// match the TF provider module's require directive, not any replace directives.
|
// match the TF provider module's require directive, not any replace directives.
|
||||||
GitHubOrg: "lxc",
|
GitHubOrg: "lxc",
|
||||||
// Temporarily comment out the MetadataInfo
|
// Temporarily comment out the MetadataInfo
|
||||||
MetadataInfo: tfbridge.NewProviderMetadata(metadata),
|
MetadataInfo: tfbridge.NewProviderMetadata(metadata),
|
||||||
Config: map[string]*tfbridge.SchemaInfo{
|
Config: map[string]*tfbridge.SchemaInfo{
|
||||||
// Add any required configuration here, or remove the example below if
|
// Add any required configuration here, or remove the example below if
|
||||||
// no additional points are required.
|
// no additional points are required.
|
||||||
"region": {
|
// "region": {
|
||||||
Type: "incus:region/region:Region",
|
// Type: "incus:region/region:Region",
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
// If extra types are needed for configuration, they can be added here.
|
// If extra types are needed for configuration, they can be added here.
|
||||||
ExtraTypes: map[string]schema.ComplexTypeSpec{
|
ExtraTypes: map[string]schema.ComplexTypeSpec{
|
||||||
"incus:region/region:Region": {
|
// "incus:region/region:Region": {
|
||||||
ObjectTypeSpec: schema.ObjectTypeSpec{
|
// ObjectTypeSpec: schema.ObjectTypeSpec{
|
||||||
Type: "string",
|
// Type: "string",
|
||||||
},
|
// },
|
||||||
Enum: []schema.EnumValueSpec{
|
// Enum: []schema.EnumValueSpec{
|
||||||
{Name: "here", Value: "HERE"},
|
// {Name: "here", Value: "HERE"},
|
||||||
{Name: "overThere", Value: "OVER_THERE"},
|
// {Name: "overThere", Value: "OVER_THERE"},
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
JavaScript: &tfbridge.JavaScriptInfo{
|
JavaScript: &tfbridge.JavaScriptInfo{
|
||||||
// RespectSchemaVersion ensures the SDK is generated linking to the correct version of the provider.
|
// RespectSchemaVersion ensures the SDK is generated linking to the correct version of the provider.
|
||||||
RespectSchemaVersion: true,
|
RespectSchemaVersion: true,
|
||||||
|
PackageName: "@kiterun/incus",
|
||||||
|
TypeScriptVersion: "^5.8.3",
|
||||||
|
UseTypeOnlyReferences: true,
|
||||||
},
|
},
|
||||||
Python: &tfbridge.PythonInfo{
|
Python: &tfbridge.PythonInfo{
|
||||||
// RespectSchemaVersion ensures the SDK is generated linking to the correct version of the provider.
|
// RespectSchemaVersion ensures the SDK is generated linking to the correct version of the provider.
|
||||||
@@ -199,11 +205,155 @@ func Provider() tfbridge.ProviderInfo {
|
|||||||
//
|
//
|
||||||
// You shouldn't need to override anything, but if you do, use the [tfbridge.ProviderInfo.Resources]
|
// You shouldn't need to override anything, but if you do, use the [tfbridge.ProviderInfo.Resources]
|
||||||
// and [tfbridge.ProviderInfo.DataSources].
|
// and [tfbridge.ProviderInfo.DataSources].
|
||||||
prov.MustComputeTokens(tokens.SingleModule("incus_", mainMod,
|
prov.MustComputeTokens(tokens.SingleModule("incus_", mainMod, tokens.MakeStandard(mainPkg)))
|
||||||
tokens.MakeStandard(mainPkg)))
|
|
||||||
|
// Add special ID handling for the incus_instance resource
|
||||||
|
// Docs here https://registry.terraform.io/providers/lxc/incus/latest/docs/resources/certificate
|
||||||
|
|
||||||
|
defaultProjectField := map[string]*info.Schema{
|
||||||
|
"project": {
|
||||||
|
Default: &info.Default{
|
||||||
|
Value: "default",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_certificate"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "Certificate"),
|
||||||
|
ComputeID: tfbridge.DelegateIDField("name", prov.Name, prov.Repository),
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_cluster_group"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "ClusterGroup"),
|
||||||
|
ComputeID: tfbridge.DelegateIDField("name", prov.Name, prov.Repository),
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_image"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "Image"),
|
||||||
|
// Does this work if source image is used?
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "fingerprint"}, prov.Name, prov.Repository),
|
||||||
|
// DREAM: default project
|
||||||
|
// Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_instance"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "Instance"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
DeleteBeforeReplace: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_instance_snapshot"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "InstanceSnapshot"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_network"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "Network"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_network_acl"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "NetworkAcl"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_network_forward"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "NetworkForward"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "network", "listen_address"}, prov.Name, prov.Repository),
|
||||||
|
// DREAM: project
|
||||||
|
// Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_network_integration"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "NetworkIntegration"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "name", "type"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_network_lb"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "NetworkLoadBalancer"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "network", "listen_address"}, prov.Name, prov.Repository),
|
||||||
|
// Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_network_peer"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "NetworkPeer"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "name", "network"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_network_zone"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "NetworkZone"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_network_zone_record"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "NetworkZoneRecord"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "zone", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_profile"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "Profile"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_project"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "Project"),
|
||||||
|
ComputeID: tfbridge.DelegateIDField("name", prov.Name, prov.Repository),
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_storage_bucket"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "StorageBucket"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "pool", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_storage_bucket_key"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "StorageBucketKey"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "pool", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_storage_pool"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "StoragePool"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
|
prov.Resources["incus_storage_volume"] = &tfbridge.ResourceInfo{
|
||||||
|
Tok: tfbridge.MakeResource(mainPkg, mainMod, "StorageVolume"),
|
||||||
|
ComputeID: delegateIDFields([]resource.PropertyKey{"project", "pool", "name"}, prov.Name, prov.Repository),
|
||||||
|
Fields: defaultProjectField,
|
||||||
|
}
|
||||||
|
|
||||||
prov.MustApplyAutoAliases()
|
prov.MustApplyAutoAliases()
|
||||||
prov.SetAutonaming(255, "-")
|
prov.SetAutonaming(255, "-")
|
||||||
|
|
||||||
return prov
|
return prov
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func delegateIDFields(fields []resource.PropertyKey, providerName, repoURL string) tfbridge.ComputeID {
|
||||||
|
return func(ctx context.Context, state resource.PropertyMap) (resource.ID, error) {
|
||||||
|
if len(fields) == 0 {
|
||||||
|
return "", fmt.Errorf("no fields provided for ID computation")
|
||||||
|
}
|
||||||
|
|
||||||
|
var idParts []string
|
||||||
|
for _, field := range fields {
|
||||||
|
id, err := tfbridge.DelegateIDProperty(resource.PropertyPath{string(field)}, providerName, repoURL)(ctx, state)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
idParts = append(idParts, string(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
return resource.ID(strings.Join(idParts, "/")), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user