kubectl

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 12 Imported by: 0

README

POSH kubectl provider

Usage

Plugin
package main

type Plugin struct {
  l        log.Logger
  cache    cache.Cache
  kubectl  *kubectl.Kubectl
  commands command.Commands
}

func New(l log.Logger) (plugin.Plugin, error) {
  var err error
  inst := &Plugin{
    l:        l,
    cache:    &cache.MemoryCache{},
    commands: command.Commands{},
  }

  // ...

  inst.kubectl, err = kubectl.New(l, inst.c)
  if err != nil {
    return nil, errors.Wrap(err, "failed to create kubectl")
  }

  // ...

  return inst, nil
}
Config
## kubectl
kubectl:
  configPath: devops/config/kubectl
Ownbrew

To install binary locally, add:

ownbrew:
  packages:
    ## https://kubernetes.io/releases/
    - name: kubectl
      tap: foomo/tap/kubernetes/kubectl
      version: 1.28.4

Documentation

Index

Constants

View Source
const None string = "_"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthTokenProvider

type AuthTokenProvider func(ctx context.Context, kubeContext string) (token string, err error)

type Cluster

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

func NewCluster

func NewCluster(kubectl *Kubectl, name string) *Cluster

func (*Cluster) Config

func (c *Cluster) Config(profile string) string

func (*Cluster) ConfigExists

func (c *Cluster) ConfigExists(profile string) bool

func (*Cluster) DeleteConfig

func (c *Cluster) DeleteConfig(profile string) error

func (*Cluster) Env

func (c *Cluster) Env(profile string) string

func (*Cluster) IsNone

func (c *Cluster) IsNone() bool

func (*Cluster) Name

func (c *Cluster) Name() string

func (*Cluster) Namespaces

func (c *Cluster) Namespaces(ctx context.Context, profile string) []string

func (*Cluster) Pods

func (c *Cluster) Pods(ctx context.Context, profile, namespace string) []string

func (*Cluster) Profiles added in v0.3.0

func (c *Cluster) Profiles(ctx context.Context) []string

func (*Cluster) String

func (c *Cluster) String() string

type Clusters

type Clusters []*Cluster

type Config

type Config struct {
	ConfigPath string `json:"configPath" yaml:"configPath"`
}

type Kubectl

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

func New

func New(l log.Logger, cache cache.Cache, opts ...Option) (*Kubectl, error)

func (*Kubectl) Cluster

func (k *Kubectl) Cluster(name string) *Cluster

func (*Kubectl) Clusters

func (k *Kubectl) Clusters() Clusters

func (*Kubectl) Config added in v0.15.0

func (k *Kubectl) Config() Config

type Option

type Option func(*Kubectl) error

func CommandWithAuthTokenProvider

func CommandWithAuthTokenProvider(provider AuthTokenProvider) Option

func CommandWithConfigKey

func CommandWithConfigKey(v string) Option

Jump to

Keyboard shortcuts

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