Documentation
¶
Overview ¶
Package sdk is the supported way to drive docket's engine from Go: build and run tasks, read a server back as a recipe, and describe the registered task types.
Everything else in the module lives under internal/ and cannot be imported from outside it. The recipe loader, the codecs, template rendering and the CLI are docket's own business; this package is the part meant to be built on.
Stability ¶
The exported identifiers in this package are stable from the release they first ship in. While docket is at 0.x, a change that breaks a caller only ships in a release that bumps the minor version, and the release notes call it out. From 1.0 on, only in a major version.
The one exception is the fields of the task types (AppTask, ConfigTask and so on). They mirror the recipe format, and change when it does: a field added, renamed or removed in a recipe is added, renamed or removed here in the same release.
Types are aliases of the engine's own, so a value built here is the value the engine runs. Every type their exported fields and methods take or return is named here too.
Runs ¶
Every call takes a context.Context, and the context carries what a run needs: the server to send dokku commands to and the values to mask. Build it from a Session, which also owns the SSH connections made under it:
session := sdk.NewSession(sdk.NewMasker("s3cr3t"))
defer func() { _ = session.Close() }()
ctx := session.Context(context.Background(), sdk.Target{Host: "dokku@dokku.example.com"})
The zero Target runs dokku locally.
Testing ¶
A test can drive tasks without a server by installing a fake runner with ContextWithRunner. The fake answers every command a call makes, and since it travels on the context, tests with different fakes can run in parallel. Production code must not use it.
Index ¶
- Constants
- Variables
- func As[T Task](e ExportedTask) (T, bool)
- func CheckMinimumVersions(ctx context.Context, typeKey string, task Task) error
- func ContextWithRunner(ctx context.Context, fn ExecRunner) context.Context
- func ContextWithTarget(ctx context.Context, target Target) context.Context
- func ContextWithVersionGate(ctx context.Context) context.Context
- func IdentityAddress(typeKey string, t Task) string
- func ParseIdentityAddress(address string) (string, map[string]string, error)
- func TaskDeprecation(t Task) string
- func TaskSensitiveValues(t Task) []string
- func TaskSynopsis(t Task) string
- func TaskTypes() []string
- func ValidateSSHOptions(opts []string) error
- type AclAppTask
- type AclServiceTask
- type AppCloneTask
- type AppJsonPropertyTask
- type AppLockTask
- type AppTask
- type AppsPropertyTask
- type BuilderDockerfilePropertyTask
- type BuilderHerokuishPropertyTask
- type BuilderLambdaPropertyTask
- type BuilderNixpacksPropertyTask
- type BuilderPackPropertyTask
- type BuilderPropertyTask
- type BuilderRailpackPropertyTask
- type BuildpacksPropertyTask
- type BuildpacksTask
- type BuildsPropertyTask
- type CaddyPropertyTask
- type CertsTask
- type ChecksPropertyTask
- type ChecksToggleTask
- type ConfigTask
- type CronPropertyTask
- type DockerOptionsTask
- type DomainsTask
- type DomainsToggleTask
- type DynamicPropertySchema
- type ExampleSchema
- type ExecCommandInput
- type ExecCommandResponse
- type ExecError
- type ExecRunner
- type ExportOptions
- type ExportReport
- type ExportResult
- type ExportStatus
- type ExportSupport
- type ExportedPlay
- type ExportedTask
- type FieldSchema
- type GitAuthTask
- type GitFromArchiveTask
- type GitFromImageTask
- type GitPropertyTask
- type GitSyncTask
- type HaproxyPropertyTask
- type HttpAuthAllowedIpTask
- type HttpAuthDomainTask
- type HttpAuthTask
- type HttpAuthUser
- type HttpAuthUserTask
- type IdentityCollectionSchema
- type IdentitySchema
- type ItemIdentity
- type ItemSchema
- type LetsencryptPropertyTask
- type LetsencryptTask
- type LogsPropertyTask
- type MaintenanceCustomPageTask
- type MaintenanceTask
- type Masker
- type NetworkPropertyTask
- type NetworkTask
- type NginxPropertyTask
- type OpenrestyPropertyTask
- type PlanResult
- type PlanStatus
- type PlanWarning
- type PluginRequirement
- type PluginRequirementSchema
- type PluginTask
- type PortMapping
- type PortsTask
- type ProbeStatus
- type ProbeSupport
- type PropertyEntrySchema
- type PropertySchema
- type ProxyPropertyTask
- type ProxyToggleTask
- type PsPropertyTask
- type PsScaleTask
- type RegistryAuthTask
- type RegistryPropertyTask
- type RejectedPropertySchema
- type ResourceLimitTask
- type ResourceReserveTask
- type ResourceSelector
- type SchedulerDockerLocalPropertyTask
- type SchedulerK3sAnnotationsTask
- type SchedulerK3sAutoscalingAuthTask
- type SchedulerK3sChartTask
- type SchedulerK3sLabelsTask
- type SchedulerK3sNodeSysctlsTask
- type SchedulerK3sProfileTask
- type SchedulerK3sPropertyTask
- type SchedulerPropertyTask
- type ServiceBackupTask
- type ServiceCreateTask
- type ServiceExposeTask
- type ServiceLinkTask
- type ServicePropertyTask
- type Session
- type SshKeyTask
- type State
- type StorageEnsureTask
- type StorageEntryTask
- type StorageMount
- type StorageMountTask
- type Target
- type Task
- type TaskCatalog
- type TaskOutputState
- type TaskSchema
- type TraefikPropertyTask
- type VersionError
- type VersionSupport
Examples ¶
Constants ¶
const ( TypeString = tasks.TypeString TypeBool = tasks.TypeBool TypeInt = tasks.TypeInt TypeFloat = tasks.TypeFloat TypeList = tasks.TypeList TypeDict = tasks.TypeDict TypeObject = tasks.TypeObject TypeAny = tasks.TypeAny TypeUnknown = tasks.TypeUnknown )
Field and item type names used in FieldSchema.Type and ItemSchema.Type.
const ( IdentityRoleKey = tasks.IdentityRoleKey IdentityRoleCollection = tasks.IdentityRoleCollection )
Identity roles a FieldSchema can carry.
const ( ItemIdentityValue = tasks.ItemIdentityValue ItemIdentityMapKey = tasks.ItemIdentityMapKey ItemIdentityFields = tasks.ItemIdentityFields )
How a collection's items are told apart.
const ( PropertyScopeApp = tasks.PropertyScopeApp PropertyScopeGlobal = tasks.PropertyScopeGlobal )
Scopes a property can be set in.
const ( ProbeSupported = tasks.ProbeSupported ProbePartial = tasks.ProbePartial ProbeUnsupported = tasks.ProbeUnsupported ExportSupported = tasks.ExportSupported ExportPartial = tasks.ExportPartial ExportUnsupported = tasks.ExportUnsupported )
Probe and export support levels.
const ( FormatYAML = tasks.FormatYAML FormatJSON5 = tasks.FormatNameJSON5 FormatHCL = tasks.FormatNameHCL )
Recipe formats ExportResult.MarshalRecipe accepts.
const ( StatePresent = tasks.StatePresent StateAbsent = tasks.StateAbsent StateDeployed = tasks.StateDeployed StateSet = tasks.StateSet StateClear = tasks.StateClear )
Task states.
const ( PlanStatusOK = tasks.PlanStatusOK PlanStatusModify = tasks.PlanStatusModify PlanStatusCreate = tasks.PlanStatusCreate PlanStatusDestroy = tasks.PlanStatusDestroy PlanStatusError = tasks.PlanStatusError )
Plan statuses, as PlanResult.Status.
const ( WarnReasonUnknownProperty = tasks.WarnReasonUnknownProperty WarnReasonProbeRejected = tasks.WarnReasonProbeRejected WarnReasonProbeIndeterminate = tasks.WarnReasonProbeIndeterminate WarnReasonServiceImageDrift = tasks.WarnReasonServiceImageDrift )
PlanWarning reasons.
const CatalogVersion = tasks.CatalogVersion
CatalogVersion is the TaskCatalog.Version this release emits. It changes only when the catalog's shape does, so a consumer can branch on it.
const MaskPlaceholder = subprocess.MaskPlaceholder
MaskPlaceholder is what a Masker replaces a sensitive value with.
const PropertyFieldName = tasks.PropertyFieldName
PropertyFieldName is the recipe key every property table constrains.
Variables ¶
var ErrSessionClosed = subprocess.ErrSessionClosed
ErrSessionClosed is the error a call made under a closed session fails with. Test for it with errors.Is.
Functions ¶
func As ¶
func As[T Task](e ExportedTask) (T, bool)
As returns an exported task's body as T, the value type registered under e.Type (ConfigTask, not *ConfigTask). It reports false for any other type.
func CheckMinimumVersions ¶ added in v0.9.1
CheckMinimumVersions returns a *VersionError when the server ctx targets, or an installed plugin task needs, is older than the floor task declares. Call it before a task's Plan or Execute. It returns nil when ctx carries no gate, when task declares no floor, and when a plugin task needs is not installed, which the task's own probe reports. typeKey names the task in the error, such as "dokku_app".
func ContextWithRunner ¶ added in v0.9.1
func ContextWithRunner(ctx context.Context, fn ExecRunner) context.Context
ContextWithRunner returns a copy of ctx whose commands go to fn instead of to a real process or server. The runner travels on the context rather than in a package variable, so two tests can install different fakes at the same time and both can call t.Parallel().
Production code must not use it. The seam exists so a test can drive a task without a server; a caller that wants to change where commands actually run sets a Target.
fn receives every command a call makes, not only dokku's, with its arguments as they would have run: unmasked, and without the sudo or SSH wrapping a Target adds. A Target on ctx has no effect while fn is installed.
A command that ran and exited non-zero is a response carrying that ExitCode. A probe reads it as its answer whether fn returns a nil error alongside it or, as the real runner does, an *ExecError with Ran set. An apply fails only on an error, so return the *ExecError to fail one. Any other error is a command that could not run, which a probe reports as an error rather than as absence.
The response's Command is what an apply records in TaskOutputState.Commands, so set it when a test reads that.
Example ¶
Planning and applying a task against a fake dokku in a test, with no server.
package main
import (
"context"
"fmt"
"strings"
"github.com/dokku/docket/sdk"
)
func main() {
var calls []string
ctx := sdk.ContextWithRunner(context.Background(), func(_ context.Context, in sdk.ExecCommandInput) (sdk.ExecCommandResponse, error) {
calls = append(calls, strings.Join(in.Args, " "))
if len(in.Args) > 1 && in.Args[1] == "apps:exists" {
// The app is absent: the command ran and exited non-zero.
return sdk.ExecCommandResponse{ExitCode: 1}, nil
}
return sdk.ExecCommandResponse{}, nil
})
task, _ := sdk.NewTask("dokku_app")
app := task.(*sdk.AppTask)
app.App = "api"
plan := app.Plan(ctx)
fmt.Println(plan.Reason, plan.Commands)
state := sdk.ExecutePlan(ctx, plan)
fmt.Println(state.Changed, calls)
}
Output: app missing [dokku --quiet apps:create api] true [--quiet apps:exists api --quiet apps:create api]
func ContextWithTarget ¶
ContextWithTarget returns a copy of ctx that sends dokku commands to target. A context derived from a session context still belongs to that session.
func ContextWithVersionGate ¶ added in v0.9.1
ContextWithVersionGate returns a copy of ctx on which CheckMinimumVersions compares a task's floor with the server. The versions it reads are cached per target for as long as the context lives, so install it once per run. A context that already carries a gate is returned as-is.
func IdentityAddress ¶
IdentityAddress renders the resource t addresses, such as `dokku_config[app=api]`. It is the form ParseIdentityAddress and ParseResourceSelectors read back.
func ParseIdentityAddress ¶
ParseIdentityAddress parses `dokku_config[app=api]` into its type key and key map. A bare type key parses to an empty map.
func TaskDeprecation ¶
TaskDeprecation returns t's deprecation notice, or "" when t is current.
func TaskSensitiveValues ¶ added in v0.9.1
TaskSensitiveValues returns the values the CLI masks for t before a run: its `sensitive:"true"` fields, including those of nested items, the value of a property marked sensitive, and whatever t's own SensitiveValues method returns. Pass them to NewMasker. Empty values are dropped and duplicates removed; the order is unspecified.
A value only known once the server is read, such as a secret property's current value, is added to the context's masker during Plan.
Example ¶
Building a masker for one task before planning it, so nothing rendered for it carries a secret.
package main
import (
"fmt"
"github.com/dokku/docket/sdk"
)
func main() {
task, err := sdk.DecodeTask("dokku_http_auth_user", []byte(`
app: api
users:
- username: admin
password: s3cr3t
`))
if err != nil {
panic(err)
}
masker := sdk.NewMasker(sdk.TaskSensitiveValues(task)...)
fmt.Println(masker.String("http-auth:add-user api admin s3cr3t"))
}
Output: http-auth:add-user api admin ***
func TaskSynopsis ¶
TaskSynopsis returns t's description, or "" when it has none.
func TaskTypes ¶
func TaskTypes() []string
TaskTypes returns every registered task type, sorted. The slice is the caller's own.
Example ¶
package main
import (
"fmt"
"github.com/dokku/docket/sdk"
)
func main() {
for _, typeKey := range sdk.TaskTypes() {
task, _ := sdk.Lookup(typeKey)
if typeKey == "dokku_app" {
fmt.Println(typeKey, "-", sdk.TaskSynopsis(task))
}
}
}
Output: dokku_app - Creates or destroys an app
func ValidateSSHOptions ¶ added in v0.9.1
ValidateSSHOptions reports whether opts can be a Target's SSHOptions, without contacting anything: each must be non-empty, free of control characters, and must not set an option docket manages itself.
Types ¶
type AclServiceTask ¶
type AclServiceTask = tasks.AclServiceTask
AclServiceTask is tasks.AclServiceTask.
type AppJsonPropertyTask ¶
type AppJsonPropertyTask = tasks.AppJsonPropertyTask
AppJsonPropertyTask is tasks.AppJsonPropertyTask.
type AppsPropertyTask ¶
type AppsPropertyTask = tasks.AppsPropertyTask
AppsPropertyTask is tasks.AppsPropertyTask.
type BuilderDockerfilePropertyTask ¶
type BuilderDockerfilePropertyTask = tasks.BuilderDockerfilePropertyTask
BuilderDockerfilePropertyTask is tasks.BuilderDockerfilePropertyTask.
type BuilderHerokuishPropertyTask ¶
type BuilderHerokuishPropertyTask = tasks.BuilderHerokuishPropertyTask
BuilderHerokuishPropertyTask is tasks.BuilderHerokuishPropertyTask.
type BuilderLambdaPropertyTask ¶
type BuilderLambdaPropertyTask = tasks.BuilderLambdaPropertyTask
BuilderLambdaPropertyTask is tasks.BuilderLambdaPropertyTask.
type BuilderNixpacksPropertyTask ¶
type BuilderNixpacksPropertyTask = tasks.BuilderNixpacksPropertyTask
BuilderNixpacksPropertyTask is tasks.BuilderNixpacksPropertyTask.
type BuilderPackPropertyTask ¶
type BuilderPackPropertyTask = tasks.BuilderPackPropertyTask
BuilderPackPropertyTask is tasks.BuilderPackPropertyTask.
type BuilderPropertyTask ¶
type BuilderPropertyTask = tasks.BuilderPropertyTask
BuilderPropertyTask is tasks.BuilderPropertyTask.
type BuilderRailpackPropertyTask ¶
type BuilderRailpackPropertyTask = tasks.BuilderRailpackPropertyTask
BuilderRailpackPropertyTask is tasks.BuilderRailpackPropertyTask.
type BuildpacksPropertyTask ¶
type BuildpacksPropertyTask = tasks.BuildpacksPropertyTask
BuildpacksPropertyTask is tasks.BuildpacksPropertyTask.
type BuildpacksTask ¶
type BuildpacksTask = tasks.BuildpacksTask
BuildpacksTask is tasks.BuildpacksTask.
type BuildsPropertyTask ¶
type BuildsPropertyTask = tasks.BuildsPropertyTask
BuildsPropertyTask is tasks.BuildsPropertyTask.
type CaddyPropertyTask ¶
type CaddyPropertyTask = tasks.CaddyPropertyTask
CaddyPropertyTask is tasks.CaddyPropertyTask.
type ChecksPropertyTask ¶
type ChecksPropertyTask = tasks.ChecksPropertyTask
ChecksPropertyTask is tasks.ChecksPropertyTask.
type ChecksToggleTask ¶
type ChecksToggleTask = tasks.ChecksToggleTask
ChecksToggleTask is tasks.ChecksToggleTask.
type CronPropertyTask ¶
type CronPropertyTask = tasks.CronPropertyTask
CronPropertyTask is tasks.CronPropertyTask.
type DockerOptionsTask ¶
type DockerOptionsTask = tasks.DockerOptionsTask
DockerOptionsTask is tasks.DockerOptionsTask.
type DomainsToggleTask ¶
type DomainsToggleTask = tasks.DomainsToggleTask
DomainsToggleTask is tasks.DomainsToggleTask.
type DynamicPropertySchema ¶
type DynamicPropertySchema = tasks.DynamicPropertySchema
DynamicPropertySchema is tasks.DynamicPropertySchema.
type ExecCommandInput ¶ added in v0.9.1
type ExecCommandInput = subprocess.ExecCommandInput
ExecCommandInput is subprocess.ExecCommandInput.
type ExecCommandResponse ¶ added in v0.9.1
type ExecCommandResponse = subprocess.ExecCommandResponse
ExecCommandResponse is subprocess.ExecCommandResponse.
type ExecError ¶ added in v0.9.1
type ExecError = subprocess.ExecError
ExecError is subprocess.ExecError.
type ExecRunner ¶ added in v0.9.1
type ExecRunner = subprocess.ExecRunner
ExecRunner is subprocess.ExecRunner.
type ExportResult ¶
type ExportResult = tasks.ExportResult
ExportResult is tasks.ExportResult.
func ExportRecipe ¶
func ExportRecipe(ctx context.Context, opts ExportOptions) (*ExportResult, error)
ExportRecipe reads the server ctx targets and returns the recipe that describes it. An export that finds nothing is not an error: check Report.MissingApps and Report.MissingResources.
An exporter whose task declares a floor newer than the server is skipped with a warning and listed in Report.VersionErrors. Set ExportOptions.IgnoreVersion to read it anyway.
Example ¶
Reading a server back and picking out one task type.
package main
import (
"context"
"fmt"
"os"
"github.com/dokku/docket/sdk"
)
func main() {
session := sdk.NewSession(nil)
defer func() { _ = session.Close() }()
ctx := session.Context(context.Background(), sdk.Target{Host: "dokku@dokku.example.com"})
res, err := sdk.ExportRecipe(ctx, sdk.ExportOptions{Inline: true})
if err != nil {
panic(err)
}
// Register what the export read before printing anything it produced.
masker := sdk.NewMasker(res.SensitiveValues()...)
for _, w := range res.Report.Warnings {
fmt.Fprintln(os.Stderr, masker.String(w))
}
for _, play := range res.Plays() {
for _, task := range play.Tasks {
cfg, ok := sdk.As[sdk.ConfigTask](task)
if !ok {
continue
}
fmt.Println(play.Name, cfg.App, len(cfg.Config))
}
}
}
Output:
type ExportSupport ¶
type ExportSupport = tasks.ExportSupport
ExportSupport is tasks.ExportSupport.
func TaskExportSupport ¶
func TaskExportSupport(t Task) (ExportSupport, bool)
TaskExportSupport reports whether ExportRecipe can reconstruct t from a server. The bool is false when t declares nothing.
type GitFromArchiveTask ¶
type GitFromArchiveTask = tasks.GitFromArchiveTask
GitFromArchiveTask is tasks.GitFromArchiveTask.
type GitFromImageTask ¶
type GitFromImageTask = tasks.GitFromImageTask
GitFromImageTask is tasks.GitFromImageTask.
type GitPropertyTask ¶
type GitPropertyTask = tasks.GitPropertyTask
GitPropertyTask is tasks.GitPropertyTask.
type HaproxyPropertyTask ¶
type HaproxyPropertyTask = tasks.HaproxyPropertyTask
HaproxyPropertyTask is tasks.HaproxyPropertyTask.
type HttpAuthAllowedIpTask ¶
type HttpAuthAllowedIpTask = tasks.HttpAuthAllowedIpTask
HttpAuthAllowedIpTask is tasks.HttpAuthAllowedIpTask.
type HttpAuthDomainTask ¶
type HttpAuthDomainTask = tasks.HttpAuthDomainTask
HttpAuthDomainTask is tasks.HttpAuthDomainTask.
type HttpAuthUserTask ¶
type HttpAuthUserTask = tasks.HttpAuthUserTask
HttpAuthUserTask is tasks.HttpAuthUserTask.
type IdentityCollectionSchema ¶
type IdentityCollectionSchema = tasks.IdentityCollectionSchema
IdentityCollectionSchema is tasks.IdentityCollectionSchema.
type IdentitySchema ¶
type IdentitySchema = tasks.IdentitySchema
IdentitySchema is tasks.IdentitySchema.
type LetsencryptPropertyTask ¶
type LetsencryptPropertyTask = tasks.LetsencryptPropertyTask
LetsencryptPropertyTask is tasks.LetsencryptPropertyTask.
type LetsencryptTask ¶
type LetsencryptTask = tasks.LetsencryptTask
LetsencryptTask is tasks.LetsencryptTask.
type LogsPropertyTask ¶
type LogsPropertyTask = tasks.LogsPropertyTask
LogsPropertyTask is tasks.LogsPropertyTask.
type MaintenanceCustomPageTask ¶
type MaintenanceCustomPageTask = tasks.MaintenanceCustomPageTask
MaintenanceCustomPageTask is tasks.MaintenanceCustomPageTask.
type MaintenanceTask ¶
type MaintenanceTask = tasks.MaintenanceTask
MaintenanceTask is tasks.MaintenanceTask.
type NetworkPropertyTask ¶
type NetworkPropertyTask = tasks.NetworkPropertyTask
NetworkPropertyTask is tasks.NetworkPropertyTask.
type NginxPropertyTask ¶
type NginxPropertyTask = tasks.NginxPropertyTask
NginxPropertyTask is tasks.NginxPropertyTask.
type OpenrestyPropertyTask ¶
type OpenrestyPropertyTask = tasks.OpenrestyPropertyTask
OpenrestyPropertyTask is tasks.OpenrestyPropertyTask.
type PluginRequirement ¶
type PluginRequirement = tasks.PluginRequirement
PluginRequirement is tasks.PluginRequirement.
type PluginRequirementSchema ¶
type PluginRequirementSchema = tasks.PluginRequirementSchema
PluginRequirementSchema is tasks.PluginRequirementSchema.
type ProbeSupport ¶
type ProbeSupport = tasks.ProbeSupport
ProbeSupport is tasks.ProbeSupport.
func TaskProbeSupport ¶
func TaskProbeSupport(t Task) (ProbeSupport, bool)
TaskProbeSupport reports how much of its own state t's Plan can read back. The bool is false when t declares nothing.
type PropertyEntrySchema ¶
type PropertyEntrySchema = tasks.PropertyEntrySchema
PropertyEntrySchema is tasks.PropertyEntrySchema.
type PropertySchema ¶
type PropertySchema = tasks.PropertySchema
PropertySchema is tasks.PropertySchema.
type ProxyPropertyTask ¶
type ProxyPropertyTask = tasks.ProxyPropertyTask
ProxyPropertyTask is tasks.ProxyPropertyTask.
type ProxyToggleTask ¶
type ProxyToggleTask = tasks.ProxyToggleTask
ProxyToggleTask is tasks.ProxyToggleTask.
type PsPropertyTask ¶
type PsPropertyTask = tasks.PsPropertyTask
PsPropertyTask is tasks.PsPropertyTask.
type RegistryAuthTask ¶
type RegistryAuthTask = tasks.RegistryAuthTask
RegistryAuthTask is tasks.RegistryAuthTask.
type RegistryPropertyTask ¶
type RegistryPropertyTask = tasks.RegistryPropertyTask
RegistryPropertyTask is tasks.RegistryPropertyTask.
type RejectedPropertySchema ¶
type RejectedPropertySchema = tasks.RejectedPropertySchema
RejectedPropertySchema is tasks.RejectedPropertySchema.
type ResourceLimitTask ¶
type ResourceLimitTask = tasks.ResourceLimitTask
ResourceLimitTask is tasks.ResourceLimitTask.
type ResourceReserveTask ¶
type ResourceReserveTask = tasks.ResourceReserveTask
ResourceReserveTask is tasks.ResourceReserveTask.
type ResourceSelector ¶
type ResourceSelector = tasks.ResourceSelector
ResourceSelector is tasks.ResourceSelector.
func ParseResourceSelectors ¶
func ParseResourceSelectors(addresses []string) ([]ResourceSelector, error)
ParseResourceSelectors parses addresses for ExportOptions.Resources. Each must name a registered, exportable task type and only keys it declares.
type SchedulerDockerLocalPropertyTask ¶
type SchedulerDockerLocalPropertyTask = tasks.SchedulerDockerLocalPropertyTask
SchedulerDockerLocalPropertyTask is tasks.SchedulerDockerLocalPropertyTask.
type SchedulerK3sAnnotationsTask ¶
type SchedulerK3sAnnotationsTask = tasks.SchedulerK3sAnnotationsTask
SchedulerK3sAnnotationsTask is tasks.SchedulerK3sAnnotationsTask.
type SchedulerK3sAutoscalingAuthTask ¶
type SchedulerK3sAutoscalingAuthTask = tasks.SchedulerK3sAutoscalingAuthTask
SchedulerK3sAutoscalingAuthTask is tasks.SchedulerK3sAutoscalingAuthTask.
type SchedulerK3sChartTask ¶
type SchedulerK3sChartTask = tasks.SchedulerK3sChartTask
SchedulerK3sChartTask is tasks.SchedulerK3sChartTask.
type SchedulerK3sLabelsTask ¶
type SchedulerK3sLabelsTask = tasks.SchedulerK3sLabelsTask
SchedulerK3sLabelsTask is tasks.SchedulerK3sLabelsTask.
type SchedulerK3sNodeSysctlsTask ¶
type SchedulerK3sNodeSysctlsTask = tasks.SchedulerK3sNodeSysctlsTask
SchedulerK3sNodeSysctlsTask is tasks.SchedulerK3sNodeSysctlsTask.
type SchedulerK3sProfileTask ¶
type SchedulerK3sProfileTask = tasks.SchedulerK3sProfileTask
SchedulerK3sProfileTask is tasks.SchedulerK3sProfileTask.
type SchedulerK3sPropertyTask ¶
type SchedulerK3sPropertyTask = tasks.SchedulerK3sPropertyTask
SchedulerK3sPropertyTask is tasks.SchedulerK3sPropertyTask.
type SchedulerPropertyTask ¶
type SchedulerPropertyTask = tasks.SchedulerPropertyTask
SchedulerPropertyTask is tasks.SchedulerPropertyTask.
type ServiceBackupTask ¶
type ServiceBackupTask = tasks.ServiceBackupTask
ServiceBackupTask is tasks.ServiceBackupTask.
type ServiceCreateTask ¶
type ServiceCreateTask = tasks.ServiceCreateTask
ServiceCreateTask is tasks.ServiceCreateTask.
type ServiceExposeTask ¶
type ServiceExposeTask = tasks.ServiceExposeTask
ServiceExposeTask is tasks.ServiceExposeTask.
type ServiceLinkTask ¶
type ServiceLinkTask = tasks.ServiceLinkTask
ServiceLinkTask is tasks.ServiceLinkTask.
type ServicePropertyTask ¶
type ServicePropertyTask = tasks.ServicePropertyTask
ServicePropertyTask is tasks.ServicePropertyTask.
type Session ¶
type Session = subprocess.Session
Session is subprocess.Session.
func NewSession ¶
NewSession returns a session whose contexts carry masker. A nil masker leaves any masker already on the parent context in place.
Example ¶
A session installs the masker and target a run needs, and closes the SSH connections made under it.
package main
import (
"context"
"github.com/dokku/docket/sdk"
)
func main() {
session := sdk.NewSession(sdk.NewMasker("s3cr3t"))
defer func() { _ = session.Close() }()
ctx := session.Context(context.Background(), sdk.Target{
Host: "deploy@dokku.example.com",
Sudo: true,
})
_ = ctx
}
Output:
type StorageEnsureTask ¶
type StorageEnsureTask = tasks.StorageEnsureTask
StorageEnsureTask is tasks.StorageEnsureTask.
type StorageEntryTask ¶
type StorageEntryTask = tasks.StorageEntryTask
StorageEntryTask is tasks.StorageEntryTask.
type StorageMountTask ¶
type StorageMountTask = tasks.StorageMountTask
StorageMountTask is tasks.StorageMountTask.
type Task ¶
Task is tasks.Task.
func DecodeTask ¶
DecodeTask builds a task of the registered type typeKey from a YAML task body, with defaults applied.
func Lookup ¶
Lookup reports whether typeKey is a registered task type and, when it is, returns a new zero-value instance of it for reading metadata. It has no defaults applied; use NewTask for a task to run.
func NewTask ¶
NewTask returns a new task of the registered type typeKey, such as "dokku_app", with its `default:` values applied. Use it rather than a struct literal, which leaves State as "" instead of the default the field documents.
The task is a pointer to the registered type, so fields are set through a type assertion:
task, err := sdk.NewTask("dokku_app")
app := task.(*sdk.AppTask)
app.App = "api"
Example ¶
package main
import (
"fmt"
"github.com/dokku/docket/sdk"
)
func main() {
task, err := sdk.NewTask("dokku_app")
if err != nil {
panic(err)
}
app := task.(*sdk.AppTask)
app.App = "api"
fmt.Println(sdk.IdentityAddress("dokku_app", app), app.State)
}
Output: dokku_app[app=api] present
type TaskCatalog ¶
type TaskCatalog = tasks.TaskCatalog
TaskCatalog is tasks.TaskCatalog.
func Catalog ¶
func Catalog() (TaskCatalog, error)
Catalog describes every registered task type. It is what `docket schema` emits.
func CatalogFor ¶
func CatalogFor(typeKeys []string) (TaskCatalog, error)
CatalogFor describes only the given task types. An unregistered type is an error.
Example ¶
package main
import (
"fmt"
"github.com/dokku/docket/sdk"
)
func main() {
catalog, err := sdk.CatalogFor([]string{"dokku_app"})
if err != nil {
panic(err)
}
for _, schema := range catalog.Tasks {
fmt.Println(schema.Type, "-", schema.Synopsis)
}
}
Output: dokku_app - Creates or destroys an app
type TaskOutputState ¶
type TaskOutputState = tasks.TaskOutputState
TaskOutputState is tasks.TaskOutputState.
func ExecutePlan ¶
func ExecutePlan(ctx context.Context, p PlanResult) TaskOutputState
ExecutePlan applies p, the result of a task's Plan, without probing the server again. A plan that is already in sync applies nothing.
type TraefikPropertyTask ¶
type TraefikPropertyTask = tasks.TraefikPropertyTask
TraefikPropertyTask is tasks.TraefikPropertyTask.
type VersionError ¶ added in v0.9.1
type VersionError = tasks.VersionError
VersionError is tasks.VersionError.
type VersionSupport ¶
type VersionSupport = tasks.VersionSupport
VersionSupport is tasks.VersionSupport.
func TaskMinimumVersions ¶ added in v0.9.1
func TaskMinimumVersions(t Task) (VersionSupport, bool)
TaskMinimumVersions reports the oldest Dokku, and the plugins, t declares it runs on. The bool is false when t declares nothing.