feat: make the export machinery usable from Go - #521
Merged
Conversation
Closes #425. Closes #518. The export is the only part of docket that reads current server state back as structured data, and three things kept a Go caller from using it. `ExportResult.plays` was unexported, so the only ways out were `MarshalRecipe` and `MarshalVars` - a caller wanting data had to marshal to YAML and parse it straight back, or call `ExportApp` directly and reimplement the ordering, warnings and sensitive-value handling the engine already does. `Plays()` returns the plays as exported values whose task bodies are still their own Go types. They are stored that way rather than converted on the way out, so the structured view and the marshalled recipe cannot describe different exports; the recipe is byte-identical. An address naming a global resource is now honoured alongside `--app`. Reading one back required exporting the whole server, and the combination was worse than absent: the global play was skipped and the address was then reported as missing from a server that had it, so the command exported nothing and exited non-zero. `NewTask` allocates a task from the registry with its `default:` tags applied, and `DecodeTask` does the same from a YAML body. Building a task by struct literal skips those defaults, so one with no `State` got "" and fell into the invalid-state branch rather than behaving as present - a foot-gun the loader avoided only through an unexported function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #425. Closes #518. The export is the only part of docket that reads current server state back as structured data, and three things kept a Go caller from using it.
ExportResult.playswas unexported, so the only ways out wereMarshalRecipeandMarshalVars- a caller wanting data had to marshal to YAML and parse it straight back, or callExportAppdirectly and reimplement the ordering, warnings and sensitive-value handling the engine already does.Plays()returns the plays as exported values whose task bodies are still their own Go types, sodokku_configcomes back as aConfigTask. They are stored that way rather than converted on the way out, so the structured view and the marshalled recipe cannot describe different exports; the recipe output is byte-identical.An address naming a global resource is now honoured alongside
--app. Reading one back used to require exporting the whole server, and the combination was worse than absent: the global play was skipped and the address was then reported as missing from a server that had it, sodocket export --app foo --resource 'dokku_plugin[name=redis]'exported nothing and exited non-zero.NewTaskallocates a task from the registry with itsdefault:tags applied, andDecodeTaskdoes the same from a YAML body. Building a task by struct literal skips those defaults, so one with noStategot""and fell into the invalid-state branch rather than behaving as present - a foot-gun the loader avoided only through an unexported function.docs/embedding.mddocuments the resulting surface, including the run context, the narrowing options, and the sensitive values a caller has to register before printing anything.