client

package
v0.0.0-...-6988055 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MCA          = "managedclusteractions"
	MCV          = "managedclusterviews"
	Failed       = "FAILED"
	Done         = "DONE"
	NExist       = "NON-EXISTENT"
	NErr         = "NO ERROR"
	TimeInterval = 5
	TimeOut      = 120
	Launch       = "launched"
	Complete     = "completed"
)

MCA, MCV represnts the corresponding resources

View Source
var ActionCreateTemplates = []ResourceTemplate{
	{"backup-create-namespace", mngClusterActCreateNS},
	{"backup-create-serviceaccount", mngClusterActCreateSA},
	{"backup-create-rolebinding", mngClusterActCreateRB},
	{"backup-create-job", mngClusterActCreateJob},
}

ActionCreateTemplates populates templates for creation of managedclusteraction resources

View Source
var JobDeleteTemplates = []ResourceTemplate{
	{"backup-delete-ns", mngClusterActDeleteNS},
}

JobDeleteTemplates populates templates for creation of managedclusteraction resource to delete the namespace in the spoke

View Source
var ViewCreateTemplates = []ResourceTemplate{
	{"backup-create-clusterview", mngClusterViewJob},
}

ViewCreateTemplates populates templates for creation of managedclusterview resource

Functions

This section is empty.

Types

type Client

type Client struct {
	Spoke            []string
	BackupPath       string
	KubeconfigPath   string
	KubernetesClient dynamic.Interface
}

Client provides a k8s dynamic client

func New

func New(Spoke []string, BackupPath string, KubeconfigPath string) (Client, error)

New creates a new instance of k8s client returns: client, error

func (Client) CheckStatus

func (c Client) CheckStatus(resourceType string, clusterName string, action string) error

CheckStatus checks whether the job launched on the spoke was successfully launched and finished returns: error

func (Client) CreateKubernetesObjects

func (c Client) CreateKubernetesObjects(clusterName string, obj *unstructured.Unstructured, resource schema.GroupVersionResource) error

CreateKubernetesObjects creates specific mca and mcv object targeted to spoke cluster based on unstructured object and gvr returns: error

func (Client) GetConfig

func (c Client) GetConfig() (*rest.Config, error)

GetConfig verifies providedkubeconfig returns: *rest.Config, error

func (Client) JobStatus

func (c Client) JobStatus(clusterName string, action string) error

JobStatus uses timeout to verify the state of the job in a predefined window returns: error

func (Client) LaunchKubernetesObjects

func (c Client) LaunchKubernetesObjects(clusterName string, template []ResourceTemplate) error

LaunchKubernetesObjects creates managedclusteraction and managedclusterview resources from template returns: error

func (Client) ManageObjects

func (c Client) ManageObjects(clusterName string, template []ResourceTemplate, resourceType string, action string) (*unstructured.Unstructured, error)

ManageObjects can query and delete k8s resource returns: *unstructured.Unstructured (view data)

error

func (Client) RenderYamlTemplate

func (c Client) RenderYamlTemplate(resourceName string, templatebody string, data TemplateData) (*bytes.Buffer, error)

RenderYamlTemplate renders a single yaml template

resourceName - resource name
templateBody - template body

returns: bytes.Buffer rendered template

error

func (Client) SpokeClusterExists

func (c Client) SpokeClusterExists(name string) bool

SpokeClusterExists verifies if a provided spoke cluster do exist or not returns: bool

func (Client) ViewProcessing

func (c Client) ViewProcessing(viewConditions []interface{}) (string, string)

ViewProcessing checks whether managedclusterview is processing or complete returns: processing bool

type ResourceTemplate

type ResourceTemplate struct {
	// Must always correspond the Action or View resource name
	ResourceName string
	Template     string
}

ResourceTemplate define a resource template structure

type TemplateData

type TemplateData struct {
	ResourceName string
	ClusterName  string
	RecoveryPath string
}

TemplateData provides template rendering data

Jump to

Keyboard shortcuts

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