- 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.goto translate. - Add the new field with a random value to both the JSON and HCL blobs in
TestFullConfiginagent/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
TestSanitizein 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
TestConfigFlagsAndEdgeCasesinruntime_test.go.
- Add validation to Validate in
- If your new config field needs a non-zero-value default.
- Add that to
DefaultSourceindefaults.go. - Add a test case to the table test
TestConfigFlagsAndEdgeCasesinruntime_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:
ReloadConfiginagent/agent.goif it needs to affect the local client state or another client agent component.ReloadConfiginagent/consul/client.goif it needs to affect state for client agent's RPC client.
- Add a test to
agent/agent_test.gosimilar 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.PatchSliceOfMapsin Parse inconfig.go. - If none of the tests in
runtime_test.gofailed 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