Six new resources from terraform-provider-dokploy v0.2.0 -- Network, DnsProvider, VaultProvider, Schedule, VolumeBackup and Libsql -- plus the new properties on Domain (`enabled`), Compose (`serviceNetworks`, `createEnvFile`, `icon`) and Application. Verified with `pulumi up` against a live v0.30.2 instance: create, preview-clean, and destroy. The upstream provider also now refuses a volume Mount with no `volumeName`, which Dokploy would otherwise turn into an anonymous Docker volume recreated on every deploy. That surfaces here at preview time, before anything exists. Two things made that fix nearly invisible to Pulumi users, so this commit fixes the second one: the bridge resolves the upstream `docs/` through the Go module cache, where a locally `replace`d dependency never lands, so tfgen was emitting every resource with no description at all. UpstreamRepoPath now points at the checkout and all 445 inputs carry documentation -- with names rendered per language, so Python readers see `volume_name` where TypeScript readers see `volumeName`.
204 lines
7.1 KiB
Go
204 lines
7.1 KiB
Go
// Package dokploy bridges the Dokploy Terraform provider into a Pulumi
|
|
// provider. The Terraform provider itself lives in
|
|
// github.com/maxvojtkov/terraform-provider-dokploy; everything in this file is
|
|
// mapping — Terraform type names to Pulumi tokens, and Terraform provider
|
|
// configuration to Pulumi configuration.
|
|
package dokploy
|
|
|
|
import (
|
|
_ "embed"
|
|
"os"
|
|
|
|
pfbridge "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/pf/tfbridge"
|
|
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
|
|
|
|
tfshim "github.com/maxvojtkov/terraform-provider-dokploy/shim"
|
|
)
|
|
|
|
// bridgeMetadata carries auto-aliasing state between tfgen runs so that token
|
|
// renames stay backwards compatible. tfgen rewrites it; the checked-in `{}`
|
|
// placeholder keeps the package compiling before the first generation.
|
|
//
|
|
//go:embed cmd/pulumi-resource-dokploy/bridge-metadata.json
|
|
var bridgeMetadata []byte
|
|
|
|
// mainPkg is the single module every resource and data source lands in, giving
|
|
// tokens of the form `dokploy:index:Project`.
|
|
const mainPkg = "index"
|
|
|
|
func res(name string) *tfbridge.ResourceInfo {
|
|
return &tfbridge.ResourceInfo{Tok: tfbridge.MakeResource("dokploy", mainPkg, name)}
|
|
}
|
|
|
|
func ds(name string) *tfbridge.DataSourceInfo {
|
|
return &tfbridge.DataSourceInfo{Tok: tfbridge.MakeDataSource("dokploy", mainPkg, name)}
|
|
}
|
|
|
|
// Provider returns the bridged Pulumi provider definition for Dokploy.
|
|
func Provider(version string) tfbridge.ProviderInfo {
|
|
if version == "" {
|
|
version = "0.0.0-dev"
|
|
}
|
|
|
|
prov := tfbridge.ProviderInfo{
|
|
P: pfbridge.ShimProvider(tfshim.NewProvider(version)),
|
|
Name: "dokploy",
|
|
|
|
DisplayName: "Dokploy",
|
|
Publisher: "maxvojtkov",
|
|
Description: "A Pulumi package for creating and managing Dokploy resources",
|
|
Keywords: []string{
|
|
"pulumi", "dokploy", "paas", "docker", "deployment",
|
|
"category/cloud", "category/infrastructure",
|
|
},
|
|
License: "MPL-2.0",
|
|
Homepage: "https://gitea.coolify.vojtkov.dev/usr_unknown/pulumi-dokploy",
|
|
Repository: "https://gitea.coolify.vojtkov.dev/usr_unknown/pulumi-dokploy",
|
|
GitHubOrg: "maxvojtkov",
|
|
Version: version,
|
|
|
|
// This is not a Pulumi-published provider, so the plugin binary comes
|
|
// from this repository's Gitea releases rather than the Pulumi CDN.
|
|
// Pulumi interpolates ${VERSION}, trims the trailing slash, then
|
|
// appends pulumi-resource-dokploy-v<version>-<os>-<arch>.tar.gz -- so
|
|
// this has to stay in step with the archive name_template in
|
|
// .goreleaser.yml.
|
|
PluginDownloadURL: "https://gitea.coolify.vojtkov.dev/usr_unknown/pulumi-dokploy/releases/download/v${VERSION}",
|
|
|
|
TFProviderVersion: version,
|
|
MetadataInfo: tfbridge.NewProviderMetadata(bridgeMetadata),
|
|
|
|
// Where tfgen reads the upstream `docs/` from when generating schema
|
|
// descriptions. Without it the bridge looks in the Go module cache,
|
|
// finds nothing for a `replace`d local dependency, and every resource
|
|
// reaches Pulumi users undocumented -- including the warnings that
|
|
// matter, such as a volume mount needing a name to persist anything.
|
|
//
|
|
// Only read at tfgen time, and the result is baked into the
|
|
// checked-in schema.json, so a consumer never needs this path.
|
|
UpstreamRepoPath: upstreamRepoPath(),
|
|
|
|
// The upstream provider is plugin-framework based, so opt in to the
|
|
// bridge's accurate preview and raw state handling.
|
|
EnableAccurateBridgePreview: true,
|
|
EnableAccuratePFBridgePreview: true,
|
|
EnableRawStateDelta: true,
|
|
|
|
Config: map[string]*tfbridge.SchemaInfo{
|
|
"host": {
|
|
Default: &tfbridge.DefaultInfo{EnvVars: []string{"DOKPLOY_HOST"}},
|
|
},
|
|
"api_key": {
|
|
Secret: tfbridge.True(),
|
|
Default: &tfbridge.DefaultInfo{EnvVars: []string{"DOKPLOY_API_KEY"}},
|
|
},
|
|
"timeout_seconds": {
|
|
Default: &tfbridge.DefaultInfo{EnvVars: []string{"DOKPLOY_TIMEOUT_SECONDS"}},
|
|
},
|
|
},
|
|
|
|
Resources: map[string]*tfbridge.ResourceInfo{
|
|
// Core hierarchy.
|
|
"dokploy_project": res("Project"),
|
|
"dokploy_environment": res("Environment"),
|
|
"dokploy_application": res("Application"),
|
|
"dokploy_compose": res("Compose"),
|
|
|
|
// Databases.
|
|
"dokploy_postgres": res("Postgres"),
|
|
"dokploy_mysql": res("MySql"),
|
|
"dokploy_mariadb": res("MariaDb"),
|
|
"dokploy_mongo": res("Mongo"),
|
|
"dokploy_redis": res("Redis"),
|
|
"dokploy_libsql": res("Libsql"),
|
|
|
|
// Networking and service attachments.
|
|
"dokploy_domain": res("Domain"),
|
|
"dokploy_mount": res("Mount"),
|
|
"dokploy_port": res("Port"),
|
|
"dokploy_redirect": res("Redirect"),
|
|
"dokploy_security": res("Security"),
|
|
|
|
// Account-level settings.
|
|
"dokploy_registry": res("Registry"),
|
|
"dokploy_ssh_key": res("SshKey"),
|
|
"dokploy_certificate": res("Certificate"),
|
|
"dokploy_destination": res("Destination"),
|
|
|
|
// Docker networks, added in Dokploy v0.30.0. Services attach to
|
|
// them through `networkIds`.
|
|
"dokploy_network": res("Network"),
|
|
|
|
// Scheduling, added in Dokploy v0.30.0.
|
|
"dokploy_schedule": res("Schedule"),
|
|
"dokploy_volume_backup": res("VolumeBackup"),
|
|
|
|
// External integrations, added in Dokploy v0.30.0.
|
|
"dokploy_dns_provider": res("DnsProvider"),
|
|
"dokploy_vault_provider": res("VaultProvider"),
|
|
},
|
|
|
|
DataSources: map[string]*tfbridge.DataSourceInfo{
|
|
"dokploy_project": ds("getProject"),
|
|
"dokploy_projects": ds("getProjects"),
|
|
"dokploy_environment": ds("getEnvironment"),
|
|
"dokploy_application": ds("getApplication"),
|
|
"dokploy_servers": ds("getServers"),
|
|
},
|
|
|
|
JavaScript: &tfbridge.JavaScriptInfo{
|
|
PackageName: "@maxvojtkov/pulumi-dokploy",
|
|
Dependencies: map[string]string{"@pulumi/pulumi": "^3.0.0"},
|
|
DevDependencies: map[string]string{"@types/node": "^18", "typescript": "^4.6.0"},
|
|
RespectSchemaVersion: true,
|
|
},
|
|
|
|
Python: pythonInfo(),
|
|
|
|
Golang: &tfbridge.GolangInfo{
|
|
ImportBasePath: "github.com/maxvojtkov/pulumi-dokploy/sdk/go/dokploy",
|
|
GenerateResourceContainerTypes: true,
|
|
RespectSchemaVersion: true,
|
|
},
|
|
|
|
CSharp: &tfbridge.CSharpInfo{
|
|
RootNamespace: "Maxvojtkov",
|
|
PackageReferences: map[string]string{"Pulumi": "3.*"},
|
|
RespectSchemaVersion: true,
|
|
},
|
|
}
|
|
|
|
// Every Dokploy resource carries a user-visible `name`; let Pulumi
|
|
// auto-generate one when the program does not supply it.
|
|
prov.SetAutonaming(255, "-")
|
|
|
|
// Keeps tokens stable if a future release renames or re-modules anything.
|
|
if err := prov.ApplyAutoAliases(); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return prov
|
|
}
|
|
|
|
// upstreamRepoPath locates the terraform-provider-dokploy checkout that
|
|
// `go.mod` replaces in. It is overridable so a CI job that lays the two repos
|
|
// out differently can still generate documented schemas.
|
|
func upstreamRepoPath() string {
|
|
if override := os.Getenv("DOKPLOY_TF_PROVIDER_PATH"); override != "" {
|
|
return override
|
|
}
|
|
return "../dokploy-teraform"
|
|
}
|
|
|
|
// pythonInfo exists because PyProject is an anonymous struct field and cannot
|
|
// be set inside a composite literal.
|
|
func pythonInfo() *tfbridge.PythonInfo {
|
|
info := &tfbridge.PythonInfo{
|
|
PackageName: "pulumi_dokploy",
|
|
Requires: map[string]string{"pulumi": ">=3.0.0,<4.0.0"},
|
|
RespectSchemaVersion: true,
|
|
}
|
|
info.PyProject.Enabled = true
|
|
return info
|
|
}
|