client

package
v0.0.0-...-5a253b8 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

package client contains the data types and functions that Liqo Tray-Agent exploits in order to access user's cluster and perform operations on Liqo CRDs

Index

Constants

View Source
const (

	//EnvLiqoDashHost defines the env var for the HOST part of the LiqoDash address.
	EnvLiqoDashHost = "LIQODASH_HOST"
	//EnvLiqoDashPort defines the env var for the PORT part of the LiqoDash address.
	EnvLiqoDashPort = "LIQODASH_PORT"
)
View Source
const (
	//EnvLiqoKConfig defines the env var containing the path of the kubeconfig file of the
	//cluster associated to Liqo Agent.
	EnvLiqoKConfig = "LIQO_KCONFIG"
)

Variables

This section is empty.

Functions

func AcquireKubeconfig

func AcquireKubeconfig() bool

AcquireKubeconfig sets the LIQO_KCONFIG env variable. LIQO_KCONFIG represents the location of a kubeconfig file in order to let the client connect to the local cluster.

The file path - if not expressed with the 'kubeconf' program argument - is set to $HOME/.kube/config .

It returns whether a valid file path for a possible kubeconfig has been set.

func DescribeAdvertisement

func DescribeAdvertisement(adv *advtypes.Advertisement) string

DescribeAdvertisement provides a textual representation of an Advertisement CR that can be displayed in a MenuNode.

func DestroyMockedAgentController

func DestroyMockedAgentController()

DestroyMockedAgentController destroys the AgentController singleton for testing purposes. It works only after calling UseMockedAgentController().

func UseMockedAgentController

func UseMockedAgentController()

UseMockedAgentController enables a mocked AgentController that does not interacts with the kubernetes cluster.

Function MUST be called before GetAgentController in order to be effective.

Types

type AdvertisementCache

type AdvertisementCache struct {
	// kubernetes cache for the Advertisement CRD.
	Store cache.Store
	// controller of the cache. Close() this channel to stop it.
	Controller chan struct{}
	// specifies whether the AdvertisementCache is up and running
	Running bool
	// set of the channels used by the AdvertisementCache logic to notify a watched event
	NotifyChannels map[NotifyChannelType]chan string
}

AdvertisementCache defines a data structure that provides a kubernetes cache for the Advertisement CRD along with related status information and a controller.

func (*AdvertisementCache) StartCache

func (c *AdvertisementCache) StartCache(client *crdClient.CRDClient) error

StartCache starts a watch (if not already running) on the Advertisement CRD in the cluster, storing data in the AdvertisementCache.

func (*AdvertisementCache) StopCache

func (c *AdvertisementCache) StopCache()

StopCache stops (if running) the watch on the Advertisement CRD associated with the cache. Moreover, all the associated NotifyChannels are closed.

type AgentController

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

AgentController is the data structure that manages Tray Agent interaction with the cluster.

func GetAgentController

func GetAgentController() *AgentController

GetAgentController returns an initialized AgentController singleton.

func (*AgentController) AcquireDashboardConfig

func (ctrl *AgentController) AcquireDashboardConfig() error

AcquireDashboardConfig tries to retrieve required data to access the LiqoDash service.

If a valid configuration is found, the EnvLiqoDashHost and EnvLiqoDashPort env vars are set.

func (*AgentController) AdvCache

func (ctrl *AgentController) AdvCache() *AdvertisementCache

AdvCache returns the Advertisement cache of the controller.

func (*AgentController) Client

func (ctrl *AgentController) Client() *crdClient.CRDClient

Client returns the controller Client used for cluster interaction.

func (*AgentController) Connected

func (ctrl *AgentController) Connected() bool

Connected returns if the controller client is actually connected to the cluster.

func (*AgentController) ConnectionTest

func (ctrl *AgentController) ConnectionTest() bool

ConnectionTest tests if the AgentController can connect to the cluster.

func (*AgentController) GetLiqoDashSecret

func (ctrl *AgentController) GetLiqoDashSecret() (*string, error)

GetLiqoDashSecret returns the access token for the LiqoDash service.

func (*AgentController) KubeClient

func (ctrl *AgentController) KubeClient() kubernetes.Interface

KubeClient returns a Kubernetes client to interact with the cluster.

func (*AgentController) Mocked

func (ctrl *AgentController) Mocked() bool

Mocked returns if the AgentController is mocked (true).

func (*AgentController) StartCaches

func (ctrl *AgentController) StartCaches()

StartCaches starts all the CR caches of the AgentController.

func (*AgentController) StopCaches

func (ctrl *AgentController) StopCaches()

StopCaches stops all the CR caches running for the AgentController.

type NotifyChannelType

type NotifyChannelType int

NotifyChannelType identifies a notification channel for a specific event

const (
	//Notification channel id for the creation of an Advertisement
	ChanAdvNew NotifyChannelType = iota
	//Notification channel id for the acceptance of an Advertisement
	ChanAdvAccepted
	//Notification channel id for the deletion of an Advertisement
	ChanAdvDeleted
	//Notification channel id for the revocation of the 'ACCEPTED' status of an Advertisement
	ChanAdvRevoked
)

NotifyChannelType identifiers

Jump to

Keyboard shortcuts

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