Documentation ¶
Overview ¶
Package rtcservice provides utility functions for the cloudprober project used when dealing with the Runtime Configurator API. https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/ This API essentially provides a small key/val store for GCE projects. Cloudprober uses this for things like maintaining a lameduck list, listing probing hosts in the projects, and in general any shared state that cloudprober instances might require.
Because RTC requires a GCE project, this package provides all functionality as methods on the Config interface. This allows the behavior to be more easily mocked for testing.
rtcservice.Config is meant to represent a configuration or resource in the RTC sense (see https://cloud.google.com/deployment-manager/runtime-configurator/). If one needs to interact with multiple configurations, they will need multiple instances of rtc.Config.
Index ¶
- type Config
- type Stub
- func (s *Stub) Delete(key string) error
- func (s *Stub) FilterList(filter string) ([]*runtimeconfig.Variable, error)
- func (s *Stub) GetProject() string
- func (s *Stub) List() ([]*runtimeconfig.Variable, error)
- func (s *Stub) Val(v *runtimeconfig.Variable) ([]byte, error)
- func (s *Stub) Write(key string, val []byte) error
- func (s *Stub) WriteTime(key string, val string, time string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config interface { // GetProject returns the project name for the configuration GetProject() string // Write adds or changes a key value pair to a configuration. Write(key string, val []byte) error // Delete removes a variable from a configuration. Delete(key string) error // Val returns the Value stored by a variable. Val(v *runtimeconfig.Variable) ([]byte, error) // List lists all variables in a configuration. List() ([]*runtimeconfig.Variable, error) // FilterList will list all variables in a configuration, filtering variable // names by the filter string. This mirrors the behavior found in // https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables/list FilterList(filter string) ([]*runtimeconfig.Variable, error) }
The Config interface provides communication to the Runtime Configurator API. It represents a single runtime configuration, allowing one to read and write variables to the configuration.
func New ¶
New provides an interface to the RTC API for a given project. The string proj represents the project name (such as "google.com:bbmc-test"), and the string "cfg" will represent the name of the RTC resource.
In order to provide fail-fast sanitation, New will check that the provided project string and cfg string are reachable. If not, an error will be returned. Note that this means New cannot be used to establish a new RTC configuration --- the configuration must already exist.
New also takes an OAuth2.0 enabled *http.Client for API access. If a nil *http.Client is provided, a new http.Client is created using google.DefaultClient, which uses default credentials.
type Stub ¶
type Stub struct {
// contains filtered or unexported fields
}
Stub provides a stubbed version of RTC that can be used for testing larger components.
func NewStub ¶
func NewStub() *Stub
NewStub returns a Stub interface to RTC which will store all variables in an in-memory map.
func (*Stub) FilterList ¶
func (s *Stub) FilterList(filter string) ([]*runtimeconfig.Variable, error)
FilterList is not supported by this Stub. Simply returns s.List().
func (*Stub) GetProject ¶
GetProject is needed in order to correctly implement the Configuration interface
func (*Stub) List ¶
func (s *Stub) List() ([]*runtimeconfig.Variable, error)
List provides all vals in the map.
func (*Stub) Val ¶
func (s *Stub) Val(v *runtimeconfig.Variable) ([]byte, error)
Val gets the value associated with a variable.