k8s

package
v0.0.0-...-80dd117 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	KubeconfigFile string
	Context        ClusterContext
}

Cluster : Everything needed to talk to a K8s cluster TODO: Maybe make a constructor so these can be private

func (*Cluster) CreateKubeconfigUsingKubectl

func (c *Cluster) CreateKubeconfigUsingKubectl(ctx diagnostics.Handler, filename string, sa ServiceAccount, verbose bool) (string, string, error)

CreateKubeconfigUsingKubectl : Creates the kubeconfig, by doing the following: * Get the token for the service account * Clone the current kubeconfig * Update the kubeconfig with the following:

  • Rename relevant context to spinnaker
  • Switching to spinnaker context
  • Adding the token to the kubeconfig as a new user
  • Updating the spinnaker context to use the new user
  • Updating the spinnaker context to the correct namespace

* Generates a minified kubeconfig from the above Returns full path to created kubeconfig file, string error, error

func (*Cluster) CreateServiceAccount

func (c *Cluster) CreateServiceAccount(ctx diagnostics.Handler, sa *ServiceAccount, verbose bool) (string, error)

CreateServiceAccount : Creates the service account (and namespace, if it doesn't already exist) TODO: Handle non-admin service account TODO: Handle pre-existing service account

func (*Cluster) DefineCluster

func (c *Cluster) DefineCluster(ctx diagnostics.Handler, verbose bool) (string, error)

DefineCluster looks at the kubeconfig and allows you to select a context (cluster) to start with May come in with a KubeconfigFile (defaults to regular if not) May come in with a contextName; otherwise prompt for one TODO: Use KUBECONFIG env variable

func (*Cluster) DefineKubeconfig

func (c *Cluster) DefineKubeconfig(filename string, sa *ServiceAccount, verbose bool) (string, string, error)

DefineOutputFile : Prompts for a path for the file to be created (if it is not already set up) TODO: switch to multiple errors

func (*Cluster) DefineServiceAccount

func (c *Cluster) DefineServiceAccount(ctx diagnostics.Handler, sa *ServiceAccount, verbose bool) (string, error)

DefineServiceAccount : Populates all fields of ServiceAccount sa, including the following: * If Namespace is not specified, gets the list of namespaces and prompts to select one or use a new one * If ServiceAccountName is not specified, prompts for the service account name

TODO: Be able to pass in values for these at start of execution TODO: Prompt for non-admin service account perms

func (*Cluster) SelectServiceAccount

func (c *Cluster) SelectServiceAccount(ctx diagnostics.Handler, sa *ServiceAccount, verbose bool) (string, error)

SelectServiceAccount : Populates all fields of ServiceAccount sa, including the following: * If Namespace is not specified, gets the list of namespaces and prompts to select one * If ServiceAccountName is not specified, prompts for the service account name

TODO: Be able to pass in values for these at start of execution TODO: Prompt for non-admin service account perms

type ClusterContext

type ClusterContext struct {
	ClusterName string
	ContextName string
}

TODO: make these either public or private

type KubectlVersion

type KubectlVersion struct {
	ClientVersion KubectlVersionDetails `json:"clientVersion"`
}

func GetKubectlVersion

func GetKubectlVersion(verbose bool) (KubectlVersion, error)

GetKubectlVersion gets a machine readable version of kubectl version

type KubectlVersionDetails

type KubectlVersionDetails struct {
	Minor string `json:"minor"`
	Major string `json:"major"`
}

func (*KubectlVersionDetails) GetMinorVersionInt

func (kvd *KubectlVersionDetails) GetMinorVersionInt() (int, error)

TODO: Error handle regexp Compile

type ServiceAccount

type ServiceAccount struct {
	Namespace string

	ServiceAccountName string

	// TODO handle non-cluster-admin service account
	// Admin bool
	TargetNamespaces []string
	// contains filtered or unexported fields
}

ServiceAccount : Information about the ServiceAccount to use

Jump to

Keyboard shortcuts

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