Documentation
¶
Index ¶
- func WithHTTPSGitOpsTargetOptions(user, password, caPath, tlsSkipVerify string) func(*Sync)
- func WithOnSyncCompleted(callback func() error) func(*Sync)
- func WithRepoInfo(remote, branch string, tag string) func(*Sync)
- func WithSSHInfo(privateKeyPath, password string) func(*Sync)
- type GMObjectRef
- type K8sObjectRef
- type SidecarObjectRef
- type Sync
- type SyncOption
- type SyncState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithHTTPSGitOpsTargetOptions ¶ added in v0.15.0
WithHTTPSGitOpsTargetOptions pulls the username and password from environment variables. If the password is empty, Basic Auth will not be used.
func WithOnSyncCompleted ¶
WithOnSyncCompleted will inject a callback function in the sync configuration.
func WithRepoInfo ¶
WithRepoInfo will set target repository information on a sync configuration object.
func WithSSHInfo ¶
WithSSHInfo will set a users ssh information on sync config. Passwords are not required.
Types ¶
type GMObjectRef ¶
type GMObjectRef struct { // The name of the greymatter zone to which this object belongs Zone string `json:"zone"` // domain, listener, route, cluster, proxy, zone, or catalogservice Kind string `json:"kind"` // The contents of this object's domain_key, listener_key, route_key, cluster_key, proxy_key, zone_key, or service_id // based on the object kind (stored separately, below) ID string `json:"id"` // A deterministic hash of the source object content Hash uint64 `json:"hash"` }
GMObjectRef contains enough information to know whether an object has changed, and delete it if removed
func NewGMObjectRef ¶
func NewGMObjectRef(objBytes []byte, kind string) *GMObjectRef
func (*GMObjectRef) HashKey ¶
func (obj *GMObjectRef) HashKey() (key string)
type K8sObjectRef ¶
type K8sObjectRef struct { Namespace string `json:"namespace"` Kind schema.GroupVersionKind `json:"kind"` Name string `json:"name"` Hash uint64 `json:"hash"` }
func NewK8sObjectRef ¶
func NewK8sObjectRef(object client.Object) *K8sObjectRef
func (*K8sObjectRef) HashKey ¶
func (obj *K8sObjectRef) HashKey() (key string)
type SidecarObjectRef ¶
type SidecarObjectRef struct { }
type Sync ¶
type Sync struct { GitDir string SSHPrivateKey string SSHPassphrase string GitUser string GitPassword string GitTLSSkipVerify bool GitRemoteCA string Remote string Branch string Tag string Interval int SyncState *SyncState // Internal callback that is executed at the end // of every sync iteration. OnSyncCompleted func() error // contains filtered or unexported fields }
func New ¶
New will build a sync with provided constructor options. A remote should be specified if attempting to fetch config from a remote repo. If not specified, operator will use its default bundled config.
func (*Sync) Bootstrap ¶
Bootstrap will fetch a provided repository from the configured bootstrap flags. Once that repository is fetched it will write out its contents to disk where the operator expects its configuration to live. If no bootstrap flags were provided on startup, we ignore and use a bundled local configuration tree for defaults.
func (*Sync) Close ¶
Close cleans up open sync connections when the operator dies so it doesn't linger and waste resources.
func (*Sync) StartStateBackup ¶
func (s *Sync) StartStateBackup(ctx context.Context, operatorCUE *cuemodule.OperatorCUE, mesh *meshv1.Mesh)
StartStateBackup creates and maintains the SyncState object and connection to Redis, which is responsible for ensuring that we only apply objects that have actually *changed* during GitOps updates.
func (*Sync) Watch ¶
func (s *Sync) Watch()
Watch will kick off a loop that will pull a git project for changes on an interval provided by the user's configuration. The default watch interval is 10s. A callback is exposed in the sync configuration object that is called on a successful completion of a pull. This can be used to reconcile mesh changes internally to the operator. Watch uses the internal sync context to handle routine cancellation. This means that the callback can also cancel this routine.
type SyncOption ¶ added in v0.17.0
type SyncOption func(*Sync)
type SyncState ¶
type SyncState struct {
// contains filtered or unexported fields
}
SyncState is the machinery responsible for managing operator internal state.
On startup a connection to redis is initialized, if state already exists we sync, if it doesn't we create.
During operations the operator will consistently reconcile with redis given hashes of objects it receives from its git repos. If it detects changes in hashes, it updates the state and the subsequent control-plane with ONLY the changed objects.
func NewMockSyncState ¶ added in v0.11.0
func NewMockSyncState() *SyncState
func (*SyncState) FilterChangedGM ¶
func (ss *SyncState) FilterChangedGM(configObjects []json.RawMessage, kinds []string) (filteredConf []json.RawMessage, filteredKinds []string, deleted []GMObjectRef)
FilterChangedGM takes greymatter config objects and their kinds, and returned filtered versions of those lists which don't contain any objects that are the same since the last update, as well as updating the stored hashes as a side effect. The purpose is to return only objects that need to be applied to the environment.
func (*SyncState) FilterChangedK8s ¶
func (ss *SyncState) FilterChangedK8s(manifestObjects []client.Object) (filtered []client.Object, deleted []K8sObjectRef)
FilterChangedK8s takes greymatter config objects, and returns a filtered version of that list, updating the stored hashes as a side effect which don't contain any objects that are the same since the last update. The purpose is to return only objects that need to be applied to the environment.