Documentation ¶
Index ¶
- type APIConfig
- type Config
- func (c *Config) AddAPI(logger log.Logger, name string, apiURL string) error
- func (c *Config) AddTenant(logger log.Logger, name string, api string, tenant string, oidcCfg *OIDCConfig) error
- func (c *Config) Client(ctx context.Context, logger log.Logger) (*http.Client, error)
- func (c *Config) GetContext(api string, tenant string) (TenantConfig, APIConfig, error)
- func (c *Config) GetCurrentContext() (TenantConfig, APIConfig, error)
- func (c *Config) RemoveAPI(logger log.Logger, name string) error
- func (c *Config) RemoveTenant(logger log.Logger, name string, api string) error
- func (c *Config) Save(logger log.Logger) error
- func (c *Config) SetCurrentContext(logger log.Logger, api string, tenant string) error
- type OIDCConfig
- type TenantConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIConfig ¶
type APIConfig struct { URL string `json:"url"` Contexts map[string]TenantConfig `json:"contexts"` }
APIConfig represents configuration for an instance of Observatorium.
type Config ¶
type Config struct { APIs map[string]APIConfig `json:"apis"` Current struct { API string `json:"api"` Tenant string `json:"tenant"` } `json:"current"` // contains filtered or unexported fields }
Config represents the structure of the configuration file.
func (*Config) AddAPI ¶
AddAPI adds a new Observatorium API to the configuration and saves the config to disk. In case no name is provided, the hostname of the API URL is used instead.
func (*Config) AddTenant ¶
func (c *Config) AddTenant(logger log.Logger, name string, api string, tenant string, oidcCfg *OIDCConfig) error
AddTenant adds configuration for a tenant under an API and saves it to disk. Also, sets new tenant to current in case current config is empty.
func (*Config) Client ¶
Client returns an OAuth2 HTTP client based on the current context configuration.
func (*Config) GetContext ¶
func (*Config) GetCurrentContext ¶
func (c *Config) GetCurrentContext() (TenantConfig, APIConfig, error)
GetCurrentContext returns the currently set context i.e, the current API and tenant configuration.
func (*Config) RemoveAPI ¶
RemoveAPI removes a locally saved Observatorium API config as well as its tenants. If the current context is pointing to the API being removed, the context is emptied.
func (*Config) RemoveTenant ¶
RemoveTenant removes configuration of a tenant under an API and saves changes to disk.
type OIDCConfig ¶
type OIDCConfig struct { Token *oauth2.Token `json:"token"` Audience string `json:"audience"` ClientID string `json:"clientID"` ClientSecret string `json:"clientSecret"` IssuerURL string `json:"issuerURL"` }
OIDCConfig represents OIDC auth config for a tenant.
type TenantConfig ¶
type TenantConfig struct { Tenant string `json:"tenant"` CAFile []byte `json:"ca"` OIDC *OIDCConfig `json:"oidc"` }
TenantConfig represents configuration for a tenant.