PluginDownloadURL moves off github:// to a templated Gitea release URL.
Pulumi interpolates ${VERSION}, then appends
pulumi-resource-dokploy-v<version>-<os>-<arch>.tar.gz -- which is what
the GoReleaser archive template already produces. Schema, bridge
metadata and all four SDKs regenerated to carry it.
Releases publish to this instance's npm, PyPI, NuGet and Go registries
using the GITEA_TOKEN that Gitea injects, so no secrets need
configuring.
The Go SDK keeps its github.com module path, which is exactly why it
goes to Gitea's Go registry: pointing GOPROXY there is what makes that
path resolve at all. Verified locally by serving the module zip from a
file proxy and building a consumer against it -- note zip -D, without
which go get rejects the archive's directory entries.
170 lines
5.7 KiB
Go
170 lines
5.7 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"
|
|
|
|
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),
|
|
|
|
// 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"),
|
|
|
|
// 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"),
|
|
},
|
|
|
|
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
|
|
}
|
|
|
|
// 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
|
|
}
|