Cover what Dokploy v0.30 added
build / build (push) Successful in 3m56s
release / release (push) Successful in 15m2s

Six new resources, all backed by endpoints that did not exist before v0.30.0
and verified end-to-end against a live v0.30.2 instance:

  dokploy_network         Docker networks, now first-class. Services attach
                          through network_ids, which is what deprecates
                          Compose's isolated_deployment upstream.
  dokploy_dns_provider    Cloudflare or Route53, so adding a domain creates
                          its DNS record.
  dokploy_vault_provider  Env values resolved from HashiCorp Vault, Infisical,
                          AWS, Doppler, Azure or Scaleway at deploy time, so
                          the secret never lands in Dokploy or in state.
  dokploy_schedule        Cron jobs in a container, a stack, or on a server.
  dokploy_volume_backup   Scheduled backups of a named volume — the companion
                          to a mount that persists.
  dokploy_libsql          The sixth managed database engine.

libsql.create is the strictest endpoint in the API: eleven keys required to
be present, several only meaningfully null, no generated service name, and it
returns `true` rather than the row. CreateDefaults and ListIDs absorb all
three so the resource behaves like every other database.

Also filled the gaps a field-by-field diff against the live schema turned up:
domain gains `enabled` (the v0.30.0 park-a-domain toggle), compose gains
create_env_file, icon and service_networks, application gains icon and
preview_require_collaborator_permissions, and mounts accept libsql.

DNS and vault credentials are masked by Dokploy on read, so `config` is
tagged noread and keeps the configured value, as the basic-auth password
already does.
This commit is contained in:
max-voitcov
2026-08-26 00:40:27 +03:00
parent 3ddce62647
commit 2d1caf6e73
23 changed files with 1297 additions and 12 deletions
+146
View File
@@ -0,0 +1,146 @@
package provider
import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
)
// ------------------------------------------------------------- Schedule
type scheduleModel struct {
ID types.String `tfsdk:"id" dokploy:"scheduleId,id"`
Name types.String `tfsdk:"name" dokploy:"name"`
Description types.String `tfsdk:"description" dokploy:"description,nullable"`
CronExpression types.String `tfsdk:"cron_expression" dokploy:"cronExpression"`
Command types.String `tfsdk:"command" dokploy:"command"`
Script types.String `tfsdk:"script" dokploy:"script,nullable"`
ShellType types.String `tfsdk:"shell_type" dokploy:"shellType"`
ScheduleType types.String `tfsdk:"schedule_type" dokploy:"scheduleType"`
Timezone types.String `tfsdk:"timezone" dokploy:"timezone,nullable"`
Enabled types.Bool `tfsdk:"enabled" dokploy:"enabled"`
AppName types.String `tfsdk:"app_name" dokploy:"appName,nullable"`
ServiceName types.String `tfsdk:"service_name" dokploy:"serviceName,nullable"`
ApplicationID types.String `tfsdk:"application_id" dokploy:"applicationId,nullable"`
ComposeID types.String `tfsdk:"compose_id" dokploy:"composeId,nullable"`
ServerID types.String `tfsdk:"server_id" dokploy:"serverId,nullable"`
CreatedAt types.String `tfsdk:"created_at" dokploy:"createdAt,ro"`
}
func scheduleResource() ResourceSpec {
return ResourceSpec{
Name: "schedule",
CreateProc: "schedule.create",
ReadProc: "schedule.one",
UpdateProc: "schedule.update",
DeleteProc: "schedule.delete",
NewModel: func() any { return &scheduleModel{} },
Schema: schema.Schema{
MarkdownDescription: "A cron job Dokploy runs on a schedule.\n\n" +
"`schedule_type` selects where the command runs:\n\n" +
"* `application` — inside a running application container; set `application_id`.\n" +
"* `compose` — inside one service of a Compose stack; set `compose_id` and `service_name`.\n" +
"* `server` — on a remote server; set `server_id`.\n" +
"* `dokploy-server` — on the Dokploy host itself.\n\n" +
"~> A schedule targeting an application runs inside its container, so the container has to be " +
"running when the cron fires.",
Attributes: map[string]schema.Attribute{
"id": computedID("Unique schedule identifier."),
"name": requiredString("Display name of the schedule."),
"description": optionalString("Free-form description."),
"cron_expression": requiredString("Standard five-field cron expression, for example `0 3 * * *`."),
"command": requiredString("Command to run."),
"script": optionalString("Multi-line script to run instead of a single command."),
"shell_type": enumStringWithDefault("Shell used to interpret the command.", shellTypes, "bash"),
"schedule_type": enumStringWithDefault("Where the command runs.", scheduleTypes, "application"),
"timezone": optionalString("IANA timezone the cron expression is evaluated in, for example `Europe/Berlin`."),
"enabled": optionalComputedBool("Whether the schedule is active."),
"app_name": optionalComputedString("Docker service name the schedule targets. Derived by Dokploy when omitted."),
"service_name": optionalString("Service inside a Compose stack to run the command in."),
"application_id": optionalReplaceString("Application this schedule belongs to."),
"compose_id": optionalReplaceString("Compose stack this schedule belongs to."),
"server_id": optionalReplaceString("Server this schedule runs on."),
"created_at": computedString("RFC 3339 timestamp of when the schedule was created."),
},
},
}
}
// -------------------------------------------------------- Volume backup
type volumeBackupModel struct {
ID types.String `tfsdk:"id" dokploy:"volumeBackupId,id"`
Name types.String `tfsdk:"name" dokploy:"name"`
VolumeName types.String `tfsdk:"volume_name" dokploy:"volumeName"`
Prefix types.String `tfsdk:"prefix" dokploy:"prefix"`
CronExpression types.String `tfsdk:"cron_expression" dokploy:"cronExpression"`
DestinationID types.String `tfsdk:"destination_id" dokploy:"destinationId"`
ServiceType types.String `tfsdk:"service_type" dokploy:"serviceType"`
AppName types.String `tfsdk:"app_name" dokploy:"appName,nullable"`
ServiceName types.String `tfsdk:"service_name" dokploy:"serviceName,nullable"`
TurnOff types.Bool `tfsdk:"turn_off" dokploy:"turnOff"`
KeepLatestCount types.Int64 `tfsdk:"keep_latest_count" dokploy:"keepLatestCount,nullable"`
Enabled types.Bool `tfsdk:"enabled" dokploy:"enabled"`
ApplicationID types.String `tfsdk:"application_id" dokploy:"applicationId,nullable"`
ComposeID types.String `tfsdk:"compose_id" dokploy:"composeId,nullable"`
PostgresID types.String `tfsdk:"postgres_id" dokploy:"postgresId,nullable"`
MySQLID types.String `tfsdk:"mysql_id" dokploy:"mysqlId,nullable"`
MariaDBID types.String `tfsdk:"mariadb_id" dokploy:"mariadbId,nullable"`
MongoID types.String `tfsdk:"mongo_id" dokploy:"mongoId,nullable"`
RedisID types.String `tfsdk:"redis_id" dokploy:"redisId,nullable"`
LibsqlID types.String `tfsdk:"libsql_id" dokploy:"libsqlId,nullable"`
CreatedAt types.String `tfsdk:"created_at" dokploy:"createdAt,ro"`
}
func volumeBackupResource() ResourceSpec {
return ResourceSpec{
Name: "volume_backup",
CreateProc: "volumeBackups.create",
ReadProc: "volumeBackups.one",
UpdateProc: "volumeBackups.update",
DeleteProc: "volumeBackups.delete",
NewModel: func() any { return &volumeBackupModel{} },
Schema: schema.Schema{
MarkdownDescription: "A scheduled backup of a Docker volume to a configured " +
"`dokploy_destination`.\n\n" +
"This is the counterpart to a `dokploy_mount` with `type = \"volume\"`: the mount gives the " +
"volume a stable name, and this resource copies its contents off the host on a schedule.\n\n" +
"Set exactly one of the `*_id` attributes to say which service owns the volume.",
Attributes: map[string]schema.Attribute{
"id": computedID("Unique volume backup identifier."),
"name": requiredString("Display name of the backup job."),
"volume_name": requiredString("Name of the Docker volume to back up."),
"prefix": requiredString("Path prefix inside the destination bucket, for example `backups/shop/`."),
"cron_expression": requiredString("Standard five-field cron expression, for example `0 4 * * *`."),
"destination_id": requiredString("Backup destination (S3-compatible bucket) to upload to."),
"service_type": enumStringWithDefault("The kind of service that owns the volume.", volumeBackupServiceTypes, "application"),
"app_name": optionalComputedString("Docker service name that owns the volume. Derived by Dokploy when omitted."),
"service_name": optionalString("Service inside a Compose stack that owns the volume."),
"turn_off": optionalComputedBool("Stop the service while the backup runs. Slower, but guarantees a " +
"consistent copy of data that is being written to."),
"keep_latest_count": optionalComputedInt("Number of backups to retain. Older ones are pruned."),
"enabled": optionalComputedBool("Whether the backup schedule is active."),
"application_id": optionalReplaceString("Application that owns the volume."),
"compose_id": optionalReplaceString("Compose stack that owns the volume."),
"postgres_id": optionalReplaceString("PostgreSQL instance that owns the volume."),
"mysql_id": optionalReplaceString("MySQL instance that owns the volume."),
"mariadb_id": optionalReplaceString("MariaDB instance that owns the volume."),
"mongo_id": optionalReplaceString("MongoDB instance that owns the volume."),
"redis_id": optionalReplaceString("Redis instance that owns the volume."),
"libsql_id": optionalReplaceString("libSQL instance that owns the volume."),
"created_at": computedString("RFC 3339 timestamp of when the backup job was created."),
},
},
}
}