auth

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginCmdName = "auth login"
)
View Source
const OIDCCmdName = "auth oidc"

Variables

View Source
var (
	// ErrConfigNotFound describes a missing nctl config in the kubeconfig
	ErrConfigNotFound configError = "nctl config not found"
)

Functions

func ContextName

func ContextName(cluster *infrastructure.KubernetesCluster) string

func IsConfigNotFoundError added in v1.1.0

func IsConfigNotFoundError(err error) bool

IsConfigNotFoundError returns true if the nctl config could not be found in the kubconfig context

func ReloginNeeded added in v1.1.0

func ReloginNeeded(err error) error

ReloginNeeded returns an error which outputs the given err with a message saying that a re-login is needed.

func RemoveClusterFromKubeConfig added in v1.1.0

func RemoveClusterFromKubeConfig(client *api.Client, clusterContext string) error

func SetContextProject added in v1.1.0

func SetContextProject(kubeconfigPath string, contextName string, project string) error

SetContextProject sets the given project in the given context of the kubeconfig

Types

type ClusterCmd

type ClusterCmd struct {
	Name       string `arg:"" help:"Name of the cluster to authenticate with. Also accepts 'name/project' format."`
	ExecPlugin bool   `help:"Automatically run exec plugin after writing the kubeconfig."`
}

func (*ClusterCmd) Run

func (a *ClusterCmd) Run(ctx context.Context, client *api.Client) error

type Cmd

type Cmd struct {
	Login      LoginCmd      `cmd:"" help:"Login to nineapis.ch."`
	Cluster    ClusterCmd    `cmd:"" help:"Authenticate with Kubernetes Cluster."`
	OIDC       OIDCCmd       `cmd:"" help:"Perform interactive OIDC login." hidden:""`
	SetProject SetProjectCmd `cmd:"" help:"Set the default project to be used."`
}

type Config added in v1.1.0

type Config struct {
	metav1.TypeMeta `json:",inline"`
	Organization    string `json:"organization"`
}

Config is used to store information in the kubeconfig context created

func NewConfig added in v1.1.0

func NewConfig(organization string) *Config

func ReadConfig added in v1.1.0

func ReadConfig(kubeconfigPath string, contextName string) (*Config, error)

func (*Config) ToObject added in v1.1.0

func (e *Config) ToObject() (runtime.Object, error)

ToObject wraps a Config in a runtime.Unknown object which implements runtime.Object.

type LoginCmd

type LoginCmd struct {
	Organization string `arg:"" help:"Name of the organization to login to."`
	APIURL       string `help:"The URL of the Nine API" default:"https://nineapis.ch" env:"NCTL_API_URL" name:"api-url"`
	APIToken     string `help:"Use a static API token instead of using an OIDC login." env:"NCTL_API_TOKEN"`
	IssuerURL    string `help:"Issuer URL is the OIDC issuer URL of the API." default:"https://auth.nine.ch/auth/realms/pub"`
	ClientID     string `help:"Client ID is the OIDC client ID of the API." default:"nineapis.ch-f178254"`
	ExecPlugin   bool   `help:"Automatically run exec plugin after writing the kubeconfig." hidden:"" default:"true"`
}

func (*LoginCmd) Run

func (l *LoginCmd) Run(ctx context.Context, command string) error

type OIDCCmd

type OIDCCmd struct {
	IssuerURL string
	ClientID  string
	UsePKCE   bool
}

func (*OIDCCmd) Run

func (o *OIDCCmd) Run(ctx context.Context, out io.Writer) error

type SetProjectCmd added in v1.1.0

type SetProjectCmd struct {
	Name string `arg:"" help:"Name of the default project to be used."`
}

func (*SetProjectCmd) Run added in v1.1.0

func (s *SetProjectCmd) Run(ctx context.Context, client *api.Client) error

Jump to

Keyboard shortcuts

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