Skip to content

Conversation

@qboileau
Copy link
Member

Context

Add a new opt-in stateful mode to the CLI apply/delete commands to keep track of managed resources.
This will be useful to keep in-sync a Conduktor resources living in yaml files inside a directory.

Behavior

When opt-in using either --enable-state flag or CDK_STATE_ENABLED env var.
On first apply, all successfully created/updated/not changed resources found will be stored into a state file on CLI exit.
During following apply calls, state file is read back and list of managed resources are compared against list of resources found in yaml files.
If a resource is missing (removed from yaml source) it will be deleted from API and removed from the state.
Then remaining resources found and successfully applied are saved new updated state file.
Dry-run will not delete resources and change state file

State file

First implementation use a local json state file that track resources KVM (Kind/apiVersion/Medatada).
Default state file location depend on system :

  • Linux : $XDG_DATA_HOME/.local/share/conduktor/cli-state.json or $HOME/.config/conduktor/cli-state.json
  • Darwin (MacOS) : $HOME/Library/Application\ Support/conduktor/cli-state.json
  • Windows : $APPDATA/conduktor/cli-state.json or $USERPROFILE/AppData/Roaming/conduktor/cli-state.json
    Path for state file can be configured using either --state-file arg or env var CDK_STATE_FILE

Note : Future implementation will allow storage of the state file in external object storage like S3

What this PR do

  • Add new package internal/state with a state service / models / local storage backend
  • Implement state flag and configuration in apply and delete command
  • Add integration tests on apply/delete command with state
  • Avoid os.Exit in commands and let cobra handle forwarded errors
  • Add new verbosity level trace to show HTTP client request/response ( -v = debug / -vv = debug+trace )
  • Update go toolchain to 1.24.9
  • Implement --dry-run support for delete command

@qboileau qboileau marked this pull request as ready for review December 2, 2025 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants