client

package
v0.0.0-...-1ca1153 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 11 Imported by: 1

Documentation

Overview

Package client provides methods to authenticate to various third party packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadS3Kubeconfig

func DownloadS3Kubeconfig(fileName, kubeconfig string, awsOpt AwsOptions) (string, error)

DownloadS3Kubeconfig takes a file name, the path of a kubeconfig file and an AwsOptions type. It will download the fileName in the awsOpts.Bucket and create a kubeconfig file in the path specified. The function returns the location of the newly created kubconfig.

Types

type AwsOptions

type AwsOptions struct {
	// Profile relates to the AWS profile you'd set.
	// In MoJ Cloud Platform this is standardised as "moj-cp".
	Profile string
	// Key refers to the AWS_ACCESS_KEY_ID, usually set in an environment variable.
	Key string
	// Secret is the AWS_SECRET_ACCESS_KEY for an AWS account.
	Secret string
	// Region relates to the AWS Region you wish to use. The default for MoJ
	// Cloud Platform should be "eu-west-2".
	Region string
	// Bucket name that holds credential file, if you wish to use one.
	Bucket string
}

AwsOptions is used to pass aws options to functions/methods that need them

type KubeClient

type KubeClient struct {
	// Path is an optional filepath to a kubeconfig file.
	// Usually this is set to ~/.kube/config.
	Path string
	// Context is the name of the context to use in the kubeconfig file.
	Context string
	// Clientset is the kubernetes client set required to interact with the kubernetes api.
	Clientset kubernetes.Interface
	// VersionedClientset allows you to communicate with the kubernetes api to get metrics data.
	VersionedClientset versioned.Interface
}

KubeClient is used to pass kubeconfig options to methods that need to interact with the kubernetes api

func NewKubeClientWithValues

func NewKubeClientWithValues(configFilePath, context string) (*KubeClient, error)

NewKubeClientWithValues takes the path of a kubeconfig file and a Kubernetes context as a string and returns a populated KubeClient type with the Kubernetes Clientset.

func NewMetricsKubeClientWithValues

func NewMetricsKubeClientWithValues(configFilePath, context string) (*KubeClient, error)

NewMetricsKubeClientWithValues takes the path of a kubeconfig file and a Kubernetes context and returns a populated KubeClient type with the Kubernetes versioned.Clientset, which allows you to communicate with the kube metrics api.

func (*KubeClient) BuildClientSet

func (kube *KubeClient) BuildClientSet() (err error)

BuildClientSet method builds a clientset depending on whether the KubeClient type has a non empty Context defined. If defined the clientset will have the context set to its value.

func (*KubeClient) BuildClientSetFromS3

func (kube *KubeClient) BuildClientSetFromS3(filepath string, awsOpt AwsOptions) error

BuildClientSetFromS3 takes a string representing the kubeconfig file to download. The method uses an AwsOptions type to download said kubeconfig to the path set by the KubeClient. It then builds and sets a clientset.

func (*KubeClient) BuildVersionedClientset

func (kube *KubeClient) BuildVersionedClientset() (err error)

BuildClientSet method builds a versioned clientset depending on whether the KubeClient type has a non empty Context defined. If defined the clientset will have the context set to its value. A versioned clientset is used to communicate with the metrics api.

func (*KubeClient) NewConfigFromContext

func (kube *KubeClient) NewConfigFromContext() (*rest.Config, error)

NewConfigFromContext returns a config type ready to create a Kubernetes interface.

func (*KubeClient) SwitchKubeContext

func (kube *KubeClient) SwitchKubeContext() error

SwitchKubeContext takes the KubeClient context type and ensures it is set appropriately.

Jump to

Keyboard shortcuts

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