{"modulePath":"github.com/worklydev/workly","version":"v0.5.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package deploy\n\nPackage deploy reads a workly.yaml, which declares queues, workflows and schedules, and works out the changes that make a server match it. The CLI's validate, plan and deploy commands are built on it.\n\n## Constants\n\n```go\nconst Version = 1\n```\nVersion is the file format version this package reads.\n\n## Types\n\n```go\ntype Action int\n```\n\n```go\nconst (\n\tUnchanged Action = iota\n\tCreate\n\tUpdate\n\t// Delete is planned only with prune: true, for what the file leaves out.\n\tDelete\n)\n```\n\n```go\ntype Change struct {\n\tKind   string // \"queue\", \"workflow\" or \"schedule\"\n\tName   string\n\tAction Action\n\t// Diffs lists the settings an update changes.\n\tDiffs []Diff\n\t// Paused is set for an existing queue or schedule that is paused.\n\t// Deploying leaves it paused.\n\tPaused bool\n\t// Body is the PUT request body: an api.QueueConfig, api.WorkflowConfig\n\t// or api.ScheduleConfig. Deletes have none.\n\tBody any\n\t// Failed counts the failed tasks a queue's delete takes with it.\n\tFailed int\n}\n```\nChange is what deploying does to one declared queue, workflow or schedule.\n\n```go\ntype Default struct {\n\tLine  int\n\tField string\n\tName  string\n\tValue string\n}\n```\nDefault is a ${NAME:-value} reference whose variable wasn't set (or was empty), so value was used for it in Field.\n\n```go\ntype Diff struct {\n\tField  string\n\tChange string\n}\n```\nDiff is one changed setting. Change reads \"old → new\", or for header values and bodies, which may hold secrets, just \"changed\", \"added\" or \"removed\".\n\n```go\ntype File struct {\n\tPath                                  string\n\tQueues                                []Queue\n\tWorkflows                             []Workflow\n\tSchedules                             []Schedule\n\tHasQueues, HasWorkflows, HasSchedules bool\n\t// Prune deletes what a managed section leaves out (prune: true).\n\tPrune bool\n\t// Defaults lists the ${NAME:-default} references that took their\n\t// default, in file order, so plan can show them: a variable CI forgot\n\t// to set would otherwise deploy a local default without a word.\n\tDefaults []Default\n}\n```\nFile is a valid workly.yaml. A section left out of the file isn't managed by it (HasQueues, HasWorkflows, HasSchedules); an empty one declares nothing.\n\n```go\nfunc Load(path string, getenv func(string) (string, bool)) (*File, error)\n```\nLoad reads and validates the file at path, replacing ${NAME} in values with environment variables looked up by getenv (os.LookupEnv in the CLI).\n\n```go\nfunc Parse(path string, data []byte, getenv func(string) (string, bool)) (*File, error)\n```\nParse is Load for a file already read.\n\n```go\nfunc (f *File) Plan(queues []api.Queue, workflows []api.Workflow, schedules []api.Schedule) (Plan, error)\n```\nPlan compares the file with the queues, workflows and schedules on the server. With prune, it fails if a queue it would delete still has tasks to deliver: those tasks would be lost, and the next enqueue would bring the queue back anyway.\n\n```go\ntype InvalidError struct {\n\tPath     string\n\tProblems []Problem\n}\n```\nInvalidError lists every problem found in a file.\n\n```go\nfunc (e *InvalidError) Error() string\n```\n\n```go\ntype Plan struct {\n\t// Changes has every declared queue, then every declared workflow, then\n\t// every declared schedule, in file order, unchanged ones included. That\n\t// is the order they are applied in, so a schedule's workflow exists by\n\t// the time the schedule is put. With prune, the deletes follow, in the\n\t// reverse order (schedules, workflows, queues), so nothing is deleted\n\t// while something left on the server still points at it.\n\tChanges []Change\n\t// Undeclared lists the schedules on the server the file doesn't\n\t// declare, if it has a schedules section and doesn't prune. Deploying\n\t// leaves them alone. Queues aren't listed: enqueueing creates them, so\n\t// most aren't in a file.\n\tUndeclared []string\n\t// UndeclaredWorkflows does the same for workflows.\n\tUndeclaredWorkflows []string\n}\n```\n\n```go\nfunc (p Plan) Count(a Action) int\n```\n\n```go\ntype Problem struct {\n\tLine    int\n\tField   string\n\tMessage string\n}\n```\nProblem is one thing wrong with a file: where, which field (a path such as schedules.nightly.cron) and what.\n\n```go\ntype Queue struct {\n\tName   string\n\tConfig api.QueueConfig\n\t// contains filtered or unexported fields\n}\n```\nQueue is a declared queue: Config is the PUT body, settings what it becomes with defaults applied.\n\n```go\ntype Schedule struct {\n\tName   string\n\tConfig api.ScheduleConfig\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype Workflow struct {\n\tName   string\n\tConfig api.WorkflowConfig\n\t// contains filtered or unexported fields\n}\n```\n\n","path":"github.com/worklydev/workly/internal/deploy","name":"deploy","synopsis":"Package deploy reads a workly.yaml, which declares queues, workflows and schedules, and works out the changes that make a server match it.","isRedistributable":true}
