- Add the field to the Config struct (or an appropriate sub-struct) in
agent/config/config.go
. - Add the field to the actual RuntimeConfig struct in
agent/config/runtime.go
. - Add an appropriate parser/setter in
agent/config/builder.go
to translate. - Add the new field with a random value to both the JSON and HCL blobs in
TestFullConfig
inagent/config/runtime_test.go
, it should fail now, then add the same random value to the expected struct in that test so it passes again. - Add the new field and it's default value to
TestSanitize
in the same file. (Running the test first gives you a nice diff which can save working out where etc.) - If your new config field needed some validation as it's only valid in
some cases or with some values (often true).
- Add validation to Validate in
builder.go
. - Add a test case to the table test
TestConfigFlagsAndEdgeCases
inruntime_test.go
.
- Add validation to Validate in
- If your new config field needs a non-zero-value default.
- Add that to
DefaultSource
indefaults.go
. - Add a test case to the table test
TestConfigFlagsAndEdgeCases
inruntime_test.go
.
- Add that to
- If your config should take effect on a reload/HUP.
- Add necessary code to to trigger a safe (locked or atomic) update to
any state the feature needs changing. This needs to be added to one or
more of the following places:
ReloadConfig
inagent/agent.go
if it needs to affect the local client state or another client agent component.ReloadConfig
inagent/consul/client.go
if it needs to affect state for client agent's RPC client.
- Add a test to
agent/agent_test.go
similar to others with prefixTestAgent_reloadConfig*
.
- Add necessary code to to trigger a safe (locked or atomic) update to
any state the feature needs changing. This needs to be added to one or
more of the following places:
- If the new config field(s) include an array of structs or maps.
- Add the path to the call to
lib.PatchSliceOfMaps
in Parse inconfig.go
. - If none of the tests in
runtime_test.go
failed before you did that, then you didn't actually test the slice part yet, go back and add tests that populate that slice.
- Add the path to the call to
- Add documentation to
website/source/docs/agent/options.html.md
.
Created
January 10, 2020 14:55
-
-
Save banks/35e4af7feb4c8f0db7a8a645de29bde9 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment