context

package
v0.0.0-...-bb2f907 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HelmHookRelevantKindSet map[string]bool = map[string]bool{"Job": true, "Pod": true, "Deployment": true, "DaemonSet": true, "StatefulSet": true}

Hook Kinds that require wait

Functions

func CompareMaps

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

func DeleteActiveContextRecord

func DeleteActiveContextRecord(ctx context.Context, acID string) (bool, error)

DeleteActiveContextRecord deletes an active contextID

func DeleteAppContextData

func DeleteAppContextData(key string) error

Delete per AppContext thread data

func GetAllActiveContext

func GetAllActiveContext(ctx context.Context) ([]string, error)

GetAllActiveContext shall return all the active contextIDs

func GetAppContextStatus

func GetAppContextStatus(ctx context.Context, cid interface{}, key string) (string, error)

func HandleAppContext

func HandleAppContext(ctx context.Context, 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 RecordActiveContext

func RecordActiveContext(ctx context.Context, 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(ctx context.Context, a interface{}, con Connector) error

RestartAppContext called in Restart scenario to handle an AppContext

func RestoreActiveContext

func RestoreActiveContext(ctx context.Context) 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 ScheduleDeleteStatusTracker

func ScheduleDeleteStatusTracker(ctx context.Context, acID, app, cluster, level, namespace string, con Connector) *time.Timer

Schedule delete status tracker to run after 2 mins This gives time for delete status to be recorded in the monitor CR

func UpdateAppContextFlag

func UpdateAppContextFlag(ctx context.Context, 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(ctx context.Context, qElement types.AppContextQueueElement) (bool, error)

func (*AppContextQueueUtils) Enqueue

Enqueue shall append new Q-Elemenet in the string format

func (*AppContextQueueUtils) FindFirstPending

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

func (*AppContextQueueUtils) GetAppContextQueue

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

GetAppContextQueue shall return the AppContextQueue

func (*AppContextQueueUtils) GetAppContextQueueLength

func (aq *AppContextQueueUtils) GetAppContextQueueLength(ctx context.Context) (int, error)

GetAppContextQueueLength shall return the length of the AppContextQueue

func (*AppContextQueueUtils) GetAppContextQueuePeek

func (aq *AppContextQueueUtils) GetAppContextQueuePeek(ctx context.Context) (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(ctx context.Context, index int, status string) error

type CompositeAppContext

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

CompositeAppContext represents composite app

func (*CompositeAppContext) InstantiateComApp

func (instca *CompositeAppContext) InstantiateComApp(ctx context.Context, cid interface{}) error

InstantiateComApp Instantiatep Aps in Composite App

func (*CompositeAppContext) ReadComApp

func (instca *CompositeAppContext) ReadComApp(ctx context.Context, cid interface{}) error

ReadComApp Reads resources in AppContext

func (*CompositeAppContext) TerminateComApp

func (instca *CompositeAppContext) TerminateComApp(ctx context.Context, cid interface{}) error

TerminateComApp Terminates Apps in Composite App

func (*CompositeAppContext) UpdateComApp

func (instca *CompositeAppContext) UpdateComApp(ctx context.Context, 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(ctx context.Context, a interface{}, ucid interface{}, e RsyncEvent) error

EnqueueToAppContext adds the event to the appContext Queue

func (*Context) StopDeleteStatusCRTimer

func (c *Context) StopDeleteStatusCRTimer(key string)

func (*Context) UpdateDeleteStatusCRTimer

func (c *Context) UpdateDeleteStatusCRTimer(key string, timer *time.Timer)

func (*Context) UpdateQStatus

func (c *Context) UpdateQStatus(ctx context.Context, 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
	// Resources committed
	CommitList 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) AddLabel

func (m *MockClient) AddLabel(res []byte, l map[string]string) ([]byte, error)

func (*MockClient) Apply

func (m *MockClient) Apply(ctx context.Context, name string, ref interface{}, content []byte) (interface{}, error)

Apply Collects resources applied to cluster

func (*MockClient) ApplyConfig

func (m *MockClient) ApplyConfig(ctx context.Context, config interface{}) error

func (*MockClient) ApplyStatusCR

func (m *MockClient) ApplyStatusCR(ctx context.Context, name string, content []byte) error

func (*MockClient) CleanClientProvider

func (m *MockClient) CleanClientProvider() error

func (*MockClient) Commit

func (m *MockClient) Commit(ctx context.Context, ref interface{}) error

func (*MockClient) Create

func (m *MockClient) Create(name string, ref interface{}, content []byte) (interface{}, error)

func (*MockClient) Delete

func (m *MockClient) Delete(name string, ref interface{}, content []byte) (interface{}, error)

Delete Collects resources deleted from cluster

func (*MockClient) DeleteConfig

func (m *MockClient) DeleteConfig(ctx context.Context, config interface{}) error

func (*MockClient) DeleteStatusCR

func (m *MockClient) DeleteStatusCR(ctx context.Context, name string, content []byte) error

func (*MockClient) Get

func (m *MockClient) Get(ctx context.Context, name string, gvkRes []byte) ([]byte, error)

func (*MockClient) IsReachable

func (m *MockClient) IsReachable() error

func (*MockClient) StartClusterWatcher

func (m *MockClient) StartClusterWatcher(ctx context.Context) error

func (*MockClient) TagResource

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

type MockConnector

type MockConnector struct {
	sync.Mutex
	Clients *sync.Map
	// contains filtered or unexported fields
}

MockConnector mocks connector interface

func NewProvider

func NewProvider(id interface{}) MockConnector

func (*MockConnector) GetClientProviders

func (c *MockConnector) GetClientProviders(ctx context.Context, app, cluster, level, namespace string) (ClientProvider, error)

Jump to

Keyboard shortcuts

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