Documentation ¶
Index ¶
- type Client
- type TestClient
- func (c TestClient) Close()
- func (c TestClient) GetBoolean(key string, defaultVal bool) bool
- func (c TestClient) GetByte(key string, defaultVal uint8) uint8
- func (c TestClient) GetFloat64(key string, defaultVal float64) float64
- func (c TestClient) GetInt64(key string, defaultVal int64) int64
- func (c TestClient) GetRaw(key string) ([]byte, error)
- func (c TestClient) GetString(key string, defaultVal string) string
- func (c TestClient) IsFeatureEnabled(key string, enabledByDefault bool) bool
- func (c TestClient) IsProjectWhitelisted(key string, projectID int64, defaultVal bool) bool
- func (c TestClient) IsTokenWhitelisted(key string, token string, defaultVal bool) bool
- func (t *TestClient) SetBoolean(key string, val bool) *TestClient
- func (t *TestClient) SetByte(key string, val uint8) *TestClient
- func (t *TestClient) SetFloat64(key string, val float64) *TestClient
- func (t *TestClient) SetInt64(key string, val int64) *TestClient
- func (t *TestClient) SetProjectsWhitelist(key string, projects ...int) *TestClient
- func (t *TestClient) SetRaw(key string, raw []byte) *TestClient
- func (t *TestClient) SetString(key string, val string) *TestClient
- func (c TestClient) Unmarshal(key string, val interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Unmarshal(key string, val interface{}) error GetBoolean(key string, defaultVal bool) bool GetInt64(key string, defaultVal int64) int64 GetByte(key string, defaultVal uint8) uint8 GetFloat64(key string, defaultVal float64) float64 GetString(key string, defaultVal string) string GetRaw(key string) ([]byte, error) IsFeatureEnabled(key string, enabledByDefault bool) bool // we use project whitelisting quite a lot. This expects // map [int64]struct{} IsProjectWhitelisted(key string, projectID int64, defaultVal bool) bool IsTokenWhitelisted(key string, token string, defaultVal bool) bool Close() }
Client is the interface for reading configs stored in configmap. It has helper methods for different data types so the user does not have to care about the structure of configs.
func NewClient ¶
NewClient returns a config manager client for a scope specified. If you created the configs from the jsonnet config helper then your configs will be placed like /etc/configs/storage-server/configs. This client assumes that there will a file called configs.json for a scope and inside the file there will be configs specified in the model If there is an error initing the client, it will become a null client, return an error and just return default values on the Gets For your services instead of creating one type of config in a configmap, group all of your configs into logical scope and create the configmap using the jsonnet helper. With adoption of this client, you will at least every single service having one scope with bunch of configs that are relevant to that service.
func NewNullClient ¶
func NewNullClient() Client
NewNullClient returns a client that will just echo back the default value you set in your Gets
type TestClient ¶
type TestClient struct {
// contains filtered or unexported fields
}
TestClient is to be used only for tests It is threadsafe but it can NOT be used for production Values can be set on the test client using the set methods and then it echoes back those values in the Get methods
func (TestClient) GetBoolean ¶
func (TestClient) GetFloat64 ¶
func (TestClient) IsFeatureEnabled ¶
func (TestClient) IsProjectWhitelisted ¶
func (TestClient) IsTokenWhitelisted ¶
func (*TestClient) SetBoolean ¶
func (t *TestClient) SetBoolean(key string, val bool) *TestClient
func (*TestClient) SetByte ¶
func (t *TestClient) SetByte(key string, val uint8) *TestClient
func (*TestClient) SetFloat64 ¶
func (t *TestClient) SetFloat64(key string, val float64) *TestClient
func (*TestClient) SetInt64 ¶
func (t *TestClient) SetInt64(key string, val int64) *TestClient
func (*TestClient) SetProjectsWhitelist ¶
func (t *TestClient) SetProjectsWhitelist(key string, projects ...int) *TestClient
func (*TestClient) SetRaw ¶
func (t *TestClient) SetRaw(key string, raw []byte) *TestClient
func (*TestClient) SetString ¶
func (t *TestClient) SetString(key string, val string) *TestClient