kubeconfig

package module
v4.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 12

README

Go Reference CircleCI

kubeconfig

The kubeconfig package implements a library for creating k8s clientsets from a kubeconfig.

Getting Project

Clone the git repository: https://github.com/giantswarm/kubeconfig.git

How to build

Build it using the standard go build command.

go build github.com/giantswarm/kubeconfig

Contact

Contributing & Reporting Bugs

See CONTRIBUTING for details on submitting patches, the contribution workflow as well as reporting bugs.

License

kubeconfig is under the Apache 2.0 license. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsExecutionError

func IsExecutionError(err error) bool

IsExecutionError asserts executionError.

func IsInvalidConfigError

func IsInvalidConfigError(err error) bool

IsInvalidConfigError asserts invalidConfigError.

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError asserts notFoundError.

func NewKubeConfigForRESTConfig

func NewKubeConfigForRESTConfig(ctx context.Context, config *rest.Config, clusterName, namespace string) ([]byte, error)

NewKubeConfigForRESTConfig returns a kubeConfig bytes for the given REST Config.

func NewRESTConfigForKubeConfig

func NewRESTConfigForKubeConfig(ctx context.Context, kubeConfig []byte) (*rest.Config, error)

NewRESTConfigForKubeConfig returns a REST Config for the given KubeConfigValue.

Types

type Config

type Config struct {
	Logger    micrologger.Logger
	K8sClient kubernetes.Interface
}

Config represents the configuration used to create a new kubeconfig library instance.

func (*Config) Validate

func (c *Config) Validate() error

type Interface

type Interface interface {
	// NewRESTConfigForApp returns a Kubernetes REST Config for the cluster configured
	// in the secrets objects.
	NewRESTConfigForApp(ctx context.Context, secretName, secretNamespace string) (*rest.Config, error)
}

type KubeConfig

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

KubeConfig provides functionality for connecting to remote clusters based on the specified kubeconfig.

func New

func New(config Config) (*KubeConfig, error)

New creates a new KubeConfig service.

func (*KubeConfig) NewRESTConfigForApp

func (k *KubeConfig) NewRESTConfigForApp(ctx context.Context, secretName, secretNamespace string) (*rest.Config, error)

NewRESTConfigForApp returns a Kubernetes REST config for the cluster configured in the kubeconfig section of the app CR.

type KubeConfigValue

type KubeConfigValue struct {
	APIVersion     string                   `yaml:"apiVersion"`
	Kind           string                   `yaml:"kind"`
	Clusters       []KubeconfigNamedCluster `yaml:"clusters"`
	Users          []KubeconfigUser         `yaml:"users"`
	Contexts       []KubeconfigNamedContext `yaml:"contexts"`
	CurrentContext string                   `yaml:"current-context"`
	Preferences    struct{}                 `yaml:"preferences"`
}

KubeConfigValue is a struct used to create a kubectl configuration YAML file.

type KubeconfigAuthProvider

type KubeconfigAuthProvider struct {
	Name   string            `yaml:"name"`
	Config map[string]string `yaml:"config"`
}

KubeconfigAuthProvider is a struct used to create a kubectl authentication provider

type KubeconfigCluster

type KubeconfigCluster struct {
	Server                   string `yaml:"server"`
	CertificateAuthorityData string `yaml:"certificate-authority-data"`
	CertificateAuthority     string `yaml:"certificate-authority"`
}

KubeconfigCluster is a struct used to create a kubectl configuration YAML file

type KubeconfigContext

type KubeconfigContext struct {
	Cluster   string `yaml:"cluster"`
	Namespace string `yaml:"namespace,omitempty"`
	User      string `yaml:"user"`
}

KubeconfigContext is a struct used to create a kubectl configuration YAML file

type KubeconfigNamedCluster

type KubeconfigNamedCluster struct {
	Name    string            `yaml:"name"`
	Cluster KubeconfigCluster `yaml:"cluster"`
}

KubeconfigNamedCluster is a struct used to create a kubectl configuration YAML file

type KubeconfigNamedContext

type KubeconfigNamedContext struct {
	Name    string            `yaml:"name"`
	Context KubeconfigContext `yaml:"context"`
}

KubeconfigNamedContext is a struct used to create a kubectl configuration YAML file

type KubeconfigUser

type KubeconfigUser struct {
	Name string                `yaml:"name"`
	User KubeconfigUserKeyPair `yaml:"user"`
}

KubeconfigUser is a struct used to create a kubectl configuration YAML file

type KubeconfigUserKeyPair

type KubeconfigUserKeyPair struct {
	ClientCertificateData string                 `yaml:"client-certificate-data"`
	ClientKeyData         string                 `yaml:"client-key-data"`
	AuthProvider          KubeconfigAuthProvider `yaml:"auth-provider,omitempty"`
}

KubeconfigUserKeyPair is a struct used to create a kubectl configuration YAML file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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