cli: add --config and --toggle options to override api configs/toggles#142
cli: add --config and --toggle options to override api configs/toggles#142sam-shift72 merged 3 commits intomasterfrom
Conversation
You can also do this via kibble.json as a side effect of how this is implemented. This is primarily intended for testing template features locally -- it's all just stuff you could do by modifying your jets
|
Re: overrides in kibble.json, I could possibly take out the json serialization tags so that these could only be set via command line. I had to tap into the Kibble config as it's the way the app passes stuff around, and I figured it might be useful to be able to put local settings into your kibble.json rather than modifying application.jet or whatever directly. I don't think it's desirable to deploy site templates with these overrides (seeing as we could set them via the APIs) but probably harmless? |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for overriding API configuration values and feature toggles via command-line flags (--config, --toggle) and kibble.json (configOverrides, toggleOverrides), and merges those overrides into both the CLI render command and the API-loading functions.
- Introduce
ConfigOverridesandToggleOverridesin themodels.Configstruct. - Initialize override maps in default config loading and in
kibble.json. - Add
--configand--toggleflags to therendercommand and merge overrides in both CLI and API paths.
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| kibble/models/config.go | Added ConfigOverrides and ToggleOverrides fields to the model |
| kibble/go.mod | Bumped github.com/spf13/pflag to v1.0.6 |
| kibble/config/config.go | Initialized override maps in default LoadConfig |
| kibble/cmd/render.go | Defined CLI flags, parsed and applied config/toggle overrides |
| kibble/api/config.go | Merged override maps into API-loaded configs and feature toggles |
Comments suppressed due to low confidence (1)
kibble/models/config.go:40
- Add a comment for the
ToggleOverridesfield (e.g.,// allows overriding feature toggles) to match the style used forConfigOverrides.
ToggleOverrides map[string]bool `json:"toggleOverrides"`
l0ud0gg
left a comment
There was a problem hiding this comment.
not tested directly but looks good to me. super useful espec for testing new features / site upgrades locally.
Lets you override API config and toggle values when running a template render / dev server to help with testing.
You can also specify these in kibble.json
{ "configOverrides": { "foo": "bar" }, "toggleOverrides": { "test": true } }Command line args > kibble.json > api
Obviously, this only affects the site template, and any configs/toggles that might get passed through to the frontend JS!
The command line args are only supported on the
rendercommand, however the kibble.json settings should affect all places in the code that render the site. If you deployed a site with kibble.json overrides, those overrides would be applied to the built site too!