Documentation ¶
Index ¶
- Constants
- func GetClusterID(r *http.Request) string
- type Cache
- type CanaryConfig
- type ClusterMapping
- type ContainerLogRequest
- type ErrorResponse
- type GatheringRulesResponse
- type Handler
- type RemoteConfiguration
- type Repository
- type RepositoryInterface
- type Rule
- type Rules
- type RulesProvider
- type Service
- type Storage
- type StorageConfig
- type StorageInterface
- type UnleashClient
- type UnleashClientInterface
Constants ¶
const ( // V1Prefix is the version prefix used in the console-dot environment V1Prefix = "/v1" // V2Prefix is the version prefix used for the newer API v2 V2Prefix = "/v2" )
const APIPrefix = "/api/gathering"
APIPrefix is the prefix used in the console-dot environment
const CanaryVersion = "canary"
CanaryVersion describes subdirectory with canary version of conditions and remote configurations
const StableVersion = "stable"
StableVersion describes subdirectory with stable version of conditions and remote configurations
Variables ¶
This section is empty.
Functions ¶
func GetClusterID ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache type represents thread safe map for storing loaded configurations
type CanaryConfig ¶
type CanaryConfig struct { UnleashURL string `mapstructure:"unleash_url" toml:"unleash_url"` UnleashToken string `mapstructure:"unleash_token" toml:"unleash_token"` UnleashApp string `mapstructure:"unleash_app" toml:"unleash_app"` UnleashToggle string `mapstructure:"unleash_toggle" toml:"unleash_toggle"` UnleashEnabled bool `mapstructure:"unleash_enabled" toml:"unleash_enabled"` }
CanaryConfig structure contains configuration for canary rollout
type ClusterMapping ¶
type ClusterMapping struct {
// contains filtered or unexported fields
}
ClusterMapping map OCP versions to remote configurations
func NewClusterMapping ¶
func NewClusterMapping(version string, mapping [][]string) *ClusterMapping
func (ClusterMapping) GetFilepathForVersion ¶
func (cm ClusterMapping) GetFilepathForVersion(ocpVersionParsed semver.Version) (string, error)
GetFilepathForVersion iterates over the cluster map returning the first filepath corresponding to the ocp version. Example:
[
["1.0.0", "first.json"], ["2.0.0", "second.json"], ["3.0.0", "third.json"]
] would return first.json for versions between 1.0.0 and 2.0.0, second.json for versions between 2.0.0 and 3.0.0 and third.json for versions greater than 3.0.0
func (ClusterMapping) IsValid ¶
func (cm ClusterMapping) IsValid(remoteConfigurationPath string) bool
IsValid check the list is in order (based on the versions), that the versions can be parsed and that the remote configurations are accessible
type ContainerLogRequest ¶
type ContainerLogRequest struct { Namespace string `json:"namespace"` PodNameRegex string `json:"pod_name_regex"` Previous bool `json:"previous,omitempty"` Messages []string `json:"messages"` }
ContainerLogRequest defines a type for requesting container log data
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
}
ErrorResponse structure represents HTTP response with error message.
type GatheringRulesResponse ¶
type GatheringRulesResponse struct { Version string `json:"version"` Rules interface{} `json:"rules"` }
GatheringRulesResponse structure represents HTTP response with rules-related content.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler structure represents HTTP request handler.
func NewHandler ¶
func NewHandler(svc RulesProvider) *Handler
NewHandler function constructs new HTTP request handler.
type RemoteConfiguration ¶
type RemoteConfiguration struct { ConditionalRules []Rule `json:"conditional_gathering_rules"` ContainerLogsRequests []ContainerLogRequest `json:"container_logs"` Version string `json:"version"` }
RemoteConfiguration represents the new data structure served by the v2 API
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository is definition of objects that implement the RepositoryInterface
func NewRepository ¶
func NewRepository(s StorageInterface) *Repository
NewRepository constructs new instance of Repository
func (*Repository) RemoteConfiguration ¶
func (r *Repository) RemoteConfiguration(request *http.Request, ocpVersion string) (*RemoteConfiguration, error)
RemoteConfiguration returns a remote configuration for v2 endpoint based on the cluster map defined in the settings and loaded on startup
type RepositoryInterface ¶
type RepositoryInterface interface { Rules(r *http.Request) (*Rules, error) RemoteConfiguration(r *http.Request, ocpVersion string) (*RemoteConfiguration, error) }
RepositoryInterface defines methods to be implemented by any rules providers
type Rule ¶
type Rule struct { Conditions []interface{} `json:"conditions,omitempty"` GatheringFunctions interface{} `json:"gathering_functions,omitempty"` }
Rule data type definition based on original JSON schema
type Rules ¶
type Rules struct { Items []Rule `json:"rules,omitempty"` Version string `json:"version,omitempty"` }
Rules data type definition based on original JSON schema
type RulesProvider ¶
type RulesProvider interface { Rules(r *http.Request) (*Rules, error) RemoteConfiguration(r *http.Request, ocpVersion string) (*RemoteConfiguration, error) }
RulesProvider defines methods to be implemented by any rules provider
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service data type represents the whole service for repository interface.
func New ¶
func New(repo RepositoryInterface) *Service
New function constructs new service for given repository interface.
func (*Service) RemoteConfiguration ¶
func (s *Service) RemoteConfiguration(r *http.Request, ocpVersion string) (*RemoteConfiguration, error)
RemoteConfiguration method returns the remote configuration provided by the service.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage type represents container for resources.
func NewStorage ¶
func NewStorage(storageConfig StorageConfig, unleashEnabled bool, unleashClient UnleashClientInterface) (*Storage, error)
NewStorage constructs new storage object.
func (*Storage) GetRemoteConfigurationFilepath ¶
GetRemoteConfigurationFilepath returns the filepath to the remote configuration that should be returned for the given OCP version based on the cluster map
func (*Storage) IsCanary ¶
IsCanary queries UnleashClient to determine which version of configurations to serve
func (*Storage) ReadConditionalRules ¶
ReadConditionalRules tries to find conditional rule with given name in the storage.
type StorageConfig ¶
type StorageConfig struct { RulesPath string `mapstructure:"rules_path" toml:"rules_path"` RemoteConfigurationPath string `mapstructure:"remote_configuration" toml:"remote_configuration"` ClusterMappingPath string `mapstructure:"cluster_mapping" toml:"cluster_mapping"` ClusterMappingFile string `mapstructure:"cluster_mapping_file" toml:"cluster_mapping_file"` }
StorageConfig structure contains configuration for resource storage.
type StorageInterface ¶
type StorageInterface interface { IsCanary(request *http.Request) bool ReadConditionalRules(isCanary bool, res string) []byte ReadRemoteConfig(isCanary bool, p string) []byte GetRemoteConfigurationFilepath(isCanary bool, ocpVersion string) (string, error) }
StorageInterface describe interface to be implemented by resource storage implementations.
type UnleashClient ¶
type UnleashClient struct {
// contains filtered or unexported fields
}
UnleashClient initializes Unleash on its creation and provides interface to query it
func NewUnleashClient ¶
func NewUnleashClient(cfg CanaryConfig) (*UnleashClient, error)
NewUnleashClient constructs new Unleash client along with Unleash initialization
func (*UnleashClient) IsCanary ¶
func (c *UnleashClient) IsCanary(canaryArgument string) bool
IsCanary queries Unleash to determine whether to serve stable or canary version of data
type UnleashClientInterface ¶
UnleashClientInterface describes interface for using Unleash in canary rollouts