populator

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package populator is a package that will help us to populate the kubernetes config file with the right credentials

Index

Constants

View Source
const (
	// DirPermissions are the output directory's permissions.
	DirPermissions = 0755

	//Prefix is used to know if a context comes from the cli.
	Prefix = "nerdalize"
)

Variables

This section is empty.

Functions

func Namespace

func Namespace(filename string) (string, error)

Namespace get the namespace of the current context from the kube config file

func NerdContext

func NerdContext(filename string) bool

NerdContext defines if the current context from the kube config file comes from the cli

func ReadConfig

func ReadConfig(filename string) (*api.Config, error)

ReadConfig retrieves Kubernetes client configuration from a file. If no files exists, it returns an error.

func ReadConfigOrNew

func ReadConfigOrNew(filename string) (*api.Config, error)

ReadConfigOrNew retrieves Kubernetes client configuration from a file. If no files exists, an empty configuration is returned.

func UseConfig

func UseConfig(context string, filename string) error

UseConfig ...

func WriteConfig

func WriteConfig(config *api.Config, filename string) error

WriteConfig encodes the configuration and writes it to the given file. If the file exists, it's contents will be overwritten.

Types

type Auth

type Auth struct {
	User     string `long:"user" description:"user to use for this configuration"`
	Password string `long:"password" description:"password for the user entry in kubeconfig"`
	Token    string `long:"token" description:"token for the user entry in kubeconfig"`
	Username string `long:"username" description:"username for the user entry in kubeconfig"`

	AuthProvider      string   `long:"auth-provider" description:""`
	AuthProviderArgs  []string `long:"auth-provider-arg" description:"key=value"`
	ClientCertificate string   `long:"client-certificate" description:"Path to client-certificate file for the user entry in kubeconfig"`
	ClientKey         string   `long:"client-key" description:"Path to client-key file for the user entry in kubeconfig"`
	EmbedCerts        string   `long:"embed-certs" description:"Embed client cert/key for the user entry in kubeconfig"`

	SecureClientSecret string `long:"secure-client-secret" description:"mandatory to setup OIDC"`
	SecureClientID     string `long:"secure-client-id" description:"mandatory to setup OIDC"`
	IDPIssuerURL       string `long:"idp-issuer-url" description:"mandatory to setup OIDC"`
	IDPCaPath          string `long:"idp-ca-path" description:"path to your ca certificate"`
	RefreshToken       string `long:"refresh-token" description:"mandatory to setup OIDC"`
	IDToken            string `long:"id-token" description:"mandatory to setup OIDC"`
}

Auth information

type Cluster

type Cluster struct {
	Name   string `long:"cluster" description:"name of the cluster configuration entry"`
	Server string `long:"server" short:"s" description:"url of the cluster to reach"`
	CA     string `long:"certificate-authority" description:""`
	CAPath string `long:"certificate-authority-path" description:""`
}

Cluster information

type Context

type Context struct {
	Name      string `long:"context" description:"context to use for this configuration"`
	Namespace string `long:"context-ns" description:"" default:"default"`
	Server    string `long:"context-server" description:"if not provided, will use the cluster name"`
	User      string `long:"context-user" description:" If not provided, will use the info from the next options"`
}

Context information

type EndpointPopulator

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

EndpointPopulator is an implementation of the P interface based on the retrieval of a conf file.

func (*EndpointPopulator) GetKubeConfigFile

func (e *EndpointPopulator) GetKubeConfigFile() string

GetKubeConfigFile returns the path where the kube config is stored

func (*EndpointPopulator) PopulateKubeConfig

func (e *EndpointPopulator) PopulateKubeConfig(project string) error

PopulateKubeConfig populates an api.Config object and set the current context to the provided project.

func (*EndpointPopulator) RemoveConfig

func (e *EndpointPopulator) RemoveConfig(project string) error

RemoveConfig deletes the precised project context and cluster info.

type EnvPopulator

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

EnvPopulator is a populator implementation based on env variables.

func (*EnvPopulator) GetKubeConfigFile

func (e *EnvPopulator) GetKubeConfigFile() string

GetKubeConfigFile returns the path where the kube config is stored.

func (*EnvPopulator) PopulateKubeConfig

func (e *EnvPopulator) PopulateKubeConfig(project string) error

PopulateKubeConfig populates the kube config file with the info found in the environment.

func (*EnvPopulator) RemoveConfig

func (e *EnvPopulator) RemoveConfig(project string) error

RemoveConfig deletes the precised project context and cluster info.

type ErrNoSuchPopulator

type ErrNoSuchPopulator string

ErrNoSuchPopulator implements the error interface

func (ErrNoSuchPopulator) Error

func (e ErrNoSuchPopulator) Error() string

type GenericPopulator

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

GenericPopulator is an implementation of the P interface using on Open ID Connect credentials.

func (*GenericPopulator) GetKubeConfigFile

func (o *GenericPopulator) GetKubeConfigFile() string

GetKubeConfigFile returns the path where the kube config is stored.

func (*GenericPopulator) PopulateKubeConfig

func (o *GenericPopulator) PopulateKubeConfig(namespace string) error

PopulateKubeConfig populates an api.Config object and set the current context to the provided cluster.

func (*GenericPopulator) RemoveConfig

func (o *GenericPopulator) RemoveConfig(cluster string) error

RemoveConfig deletes the precised cluster context and cluster info.

type P

type P interface {
	PopulateKubeConfig(string) error
	RemoveConfig(string) error
}

P is an interface that we can use to read from and to write to the kube config file.

func New

func New(conf, kubeConfigFile string, cluster *v1payload.GetClusterOutput) (P, error)

New instantiates a new P interface using the conf parameter. It can return a env, endpoint or oidc populator.

Jump to

Keyboard shortcuts

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