context

package
v0.0.0-...-7c77b90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareMaps

func CompareMaps(m, n map[string]string) bool

func CreateCompApp

func CreateCompApp(ca CompositeApp) (string, error)

CreateCompApp creates a AppContext for a composite app, for testing

func DeleteActiveContextRecord

func DeleteActiveContextRecord(acID string) (bool, error)

DeleteActiveContextRecord deletes an active contextID

func DeleteAppContextData

func DeleteAppContextData(key string) error

Delete per AppContext thread data

func FindApp

func FindApp(ca CompositeApp, app string) bool

FindApp finds app in the appcontext and returns true or false

func FindCluster

func FindCluster(ca CompositeApp, app string, cluster string) bool

FindCluster finds cluster in an app in the appcontext and returns true or false

func FindResource

func FindResource(ca CompositeApp, app, cluster, res string) bool

FindCluster finds resource in a cluster in an app in the appcontext and returns true or false

func GetAllActiveContext

func GetAllActiveContext() ([]string, error)

GetAllActiveContext shall return all the active contextIDs

func GetAppContextStatus

func GetAppContextStatus(cid interface{}, key string) (string, error)

func HandleAppContext

func HandleAppContext(a interface{}, ucid interface{}, e RsyncEvent, con Connector) error

HandleAppContext adds event to queue and starts main thread

func LoadMap

func LoadMap(str string) map[string]string

func PrintCompositeApp

func PrintCompositeApp(ca CompositeApp)

PrintCompositeApp prints the composite app

func ReadAppContext

func ReadAppContext(contextID interface{}) (CompositeApp, error)

ReadAppContext reads a composite app for AppContext

func RecordActiveContext

func RecordActiveContext(acID string) (bool, error)

RecordActiveContext shall insert into contextDB a key and value like /activecontext/99999999888/->99999999888. 99999999888 is sample AppcontextID It shall take in activeContextID

func RestartAppContext

func RestartAppContext(a interface{}, con Connector) error

RestartAppContext called in Restart scenario to handle an AppContext

func RestoreActiveContext

func RestoreActiveContext() error

RestoreActiveContext shall be called everytime the rsync restarts. It makes sure that the AppContexts which were in active state before rsync got cancelled, are restored and queued up again for processing.

func UpdateAppContextFlag

func UpdateAppContextFlag(cid interface{}, key string, b bool) error

Types

type AppContextData

type AppContextData struct {
	Data map[string]*Context
	sync.Mutex
}

AppContextData struct

type AppContextQueueUtils

type AppContextQueueUtils struct {
	// contains filtered or unexported fields
}

func (*AppContextQueueUtils) CreateQueue

func (aq *AppContextQueueUtils) CreateQueue(qElement types.AppContextQueueElement) (bool, error)

func (*AppContextQueueUtils) Enqueue

func (aq *AppContextQueueUtils) Enqueue(qElement types.AppContextQueueElement) (bool, error)

Enqueue shall append new Q-Elemenet in the string format

func (*AppContextQueueUtils) FindFirstPending

func (aq *AppContextQueueUtils) FindFirstPending() (int, types.AppContextQueueElement)

func (*AppContextQueueUtils) GetAppContextQueue

func (aq *AppContextQueueUtils) GetAppContextQueue() (types.AppContextQueue, error)

GetAppContextQueue shall return the AppContextQueue

func (*AppContextQueueUtils) GetAppContextQueueLength

func (aq *AppContextQueueUtils) GetAppContextQueueLength() (int, error)

GetAppContextQueueLength shall return the length of the AppContextQueue

func (*AppContextQueueUtils) GetAppContextQueuePeek

func (aq *AppContextQueueUtils) GetAppContextQueuePeek() (types.AppContextQueueElement, error)

GetAppContextQueuePeek shall return the String value at the peak of the AppContextQueue

func (*AppContextQueueUtils) UpdateQueue

func (*AppContextQueueUtils) UpdateStatus

func (aq *AppContextQueueUtils) UpdateStatus(index int, status string) error

type AppContextUtils

type AppContextUtils struct {
	// contains filtered or unexported fields
}

func (*AppContextUtils) AddResourceStatus

func (a *AppContextUtils) AddResourceStatus(name string, app string, cluster string, status interface{}, acID string) error

Add resource level for a status Function adds any missing levels to AppContext

func (*AppContextUtils) GetAppContextFlag

func (a *AppContextUtils) GetAppContextFlag(key string) (bool, error)

GetAppContextFlag gets the stop flag

func (*AppContextUtils) GetAppContextStatus

func (a *AppContextUtils) GetAppContextStatus(key string) (appcontext.AppContextStatus, error)

GetAppContextStatus gets the status

func (*AppContextUtils) GetClusterReadyStatus

func (a *AppContextUtils) GetClusterReadyStatus(app, cluster string) appcontext.StatusValue

GetClusterReadyStatus sets the cluster ready status does not return an error, just a status of Unknown if the cluster readystatus key does not exist or any other error occurs.

func (*AppContextUtils) GetNamespace

func (a *AppContextUtils) GetNamespace() (string, string)

GetNamespace reads namespace from metadata

func (*AppContextUtils) GetRes

func (a *AppContextUtils) GetRes(name string, app string, cluster string) ([]byte, interface{}, error)

GetRes Reads resource

func (*AppContextUtils) GetStatusAppContext

func (a *AppContextUtils) GetStatusAppContext(key string) (string, error)

GetAppContextFlag gets the statusappctxid

func (*AppContextUtils) GetSubResApprove

func (a *AppContextUtils) GetSubResApprove(name string, app string, cluster string) ([]byte, interface{}, error)

GetSubResApprove Reads sub resource

func (*AppContextUtils) PutRes

func (a *AppContextUtils) PutRes(name string, app string, cluster string, data []byte) error

PutRes copies resource into appContext

func (*AppContextUtils) SetClusterReadyStatus

func (a *AppContextUtils) SetClusterReadyStatus(app, cluster string, status appcontext.StatusValue)

SetClusterReadyStatus gets the cluster ready status

func (*AppContextUtils) UpdateAppContextFlag

func (a *AppContextUtils) UpdateAppContextFlag(key string, b bool) error

UpdateAppContextFlag to update flags

func (*AppContextUtils) UpdateAppContextStatus

func (a *AppContextUtils) UpdateAppContextStatus(key string, status interface{}) error

UpdateAppContextStatus updates a field in AppContext

type CompositeAppContext

type CompositeAppContext struct {
	// contains filtered or unexported fields
}

CompositeAppContext represents composite app

func (*CompositeAppContext) InstantiateComApp

func (instca *CompositeAppContext) InstantiateComApp(cid interface{}) error

InstantiateComApp Instantiatep Aps in Composite App

func (*CompositeAppContext) ReadComApp

func (instca *CompositeAppContext) ReadComApp(cid interface{}) error

ReadComApp Reads resources in AppContext

func (*CompositeAppContext) TerminateComApp

func (instca *CompositeAppContext) TerminateComApp(cid interface{}) error

TerminateComApp Terminates Apps in Composite App

func (*CompositeAppContext) UpdateComApp

func (instca *CompositeAppContext) UpdateComApp(cid interface{}, ucid interface{}) error

UpdateComApp Updates Apps in Composite App

type Context

type Context struct {
	Lock    *sync.Mutex
	Running bool
	Channel chan RsyncEvent
	// contains filtered or unexported fields
}

Context is Per AppContext struct

func CreateAppContextData

func CreateAppContextData(key string) (bool, *Context)

Create per AppContext thread data

func (*Context) EnqueueToAppContext

func (c *Context) EnqueueToAppContext(a interface{}, ucid interface{}, e RsyncEvent) error

EnqueueToAppContext adds the event to the appContext Queue

func (*Context) UpdateQStatus

func (c *Context) UpdateQStatus(index int, status string) error

UpdateQStatus updates status of an element in the queue

type Match

type Match struct {
	// Collects all resources that are deleted
	DeleteMatchList sync.Map
	// Collects all resources that are applied
	ApplyMatchList sync.Map
	// Collects all resources that are currently applied on the cluster
	ResourceList sync.Map
}

Match stores information about resources applied in clusters

var MatchList Match

MatchList to collect resources

type MockClient

type MockClient struct {
	// contains filtered or unexported fields
}

MockClient mocks client

func (*MockClient) Apply

func (m *MockClient) Apply(content []byte) error

Apply Collects resources applied to cluster

func (*MockClient) Approve

func (m *MockClient) Approve(name string, sa []byte) error

func (*MockClient) Delete

func (m *MockClient) Delete(content []byte) error

Delete Collects resources deleted from cluster

func (*MockClient) Get

func (m *MockClient) Get(gvkRes []byte, namespace string) ([]byte, error)

func (*MockClient) IsReachable

func (m *MockClient) IsReachable() error

func (*MockClient) TagResource

func (m *MockClient) TagResource(res []byte, label string) ([]byte, error)

type MockConnector

type MockConnector struct {
	sync.Mutex

	Clients *sync.Map
	// contains filtered or unexported fields
}

MockConnector mocks connector interface

func (*MockConnector) GetClientInternal

func (c *MockConnector) GetClientInternal(cluster string, level string, namespace string) (ClientProvider, error)

func (*MockConnector) GetStatusCR

func (c *MockConnector) GetStatusCR(label string) ([]byte, error)

func (*MockConnector) Init

func (c *MockConnector) Init(id interface{}) error

func (*MockConnector) RemoveClient

func (c *MockConnector) RemoveClient()

func (*MockConnector) StartClusterWatcher

func (c *MockConnector) StartClusterWatcher(cluster string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL