mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
2336c340c4
In this PR, we implement (but do not use yet, pending #13727 review) a syspolicy/source.Store that reads policy settings from environment variables. It converts a CamelCase setting.Key, such as AuthKey or ExitNodeID, to a SCREAMING_SNAKE_CASE, TS_-prefixed environment variable name, such as TS_AUTH_KEY and TS_EXIT_NODE_ID. It then looks up the variable and attempts to parse it according to the expected value type. If the environment variable is not set, the policy setting is considered not configured in this store (the syspolicy package will still read it from other sources). Similarly, if the environment variable has an invalid value for the setting type, it won't be used (though the reported/logged error will differ). Updates #13193 Updates #12687 Signed-off-by: Nick Khyl <nickk@tailscale.com>
14 lines
503 B
Go
14 lines
503 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package setting
|
|
|
|
// Key is a string that uniquely identifies a policy and must remain unchanged
|
|
// once established and documented for a given policy setting. It may contain
|
|
// alphanumeric characters and zero or more [KeyPathSeparator]s to group
|
|
// individual policy settings into categories.
|
|
type Key string
|
|
|
|
// KeyPathSeparator allows logical grouping of policy settings into categories.
|
|
const KeyPathSeparator = '/'
|