doctl

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 18 Imported by: 0

README

POSH doctl provider

Usage

Plugin
package main

type Plugin struct {
  l        log.Logger
  cache    cache.Cache
  doctl    *doctl.Doctl
  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.cache)
  if err != nil {
    return nil, errors.Wrap(err, "failed to create kubectl")
  }

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

  // ...

  inst.commands.Add(doctl.NewCommand(l, inst.cache, inst.doctl, inst.kubectl))

  // ...

  return inst, nil
}
Config
## doctl
doctl:
  configPath: .posh/config/doctl.yaml
  clusters:
    prod:
      name: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Ownbrew

To install binary locally, add:

ownbrew:
  packages:
    ## https://github.com/digitalocean/doctl/releases
    - name: doctl
      tap: foomo/tap/digitalocean/doctl
      version: 1.100.0

Documentation

Index

Constants

This section is empty.

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 {
	Name string `json:"name" yaml:"name"`
}

type ClusterNameFn

type ClusterNameFn func(name string, cluster Cluster) string

type Command

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

func NewCommand

func NewCommand(l log.Logger, cache cache.Cache, doctl *Doctl, kubectl *kubectl.Kubectl, opts ...CommandOption) *Command

func (*Command) Complete

func (c *Command) Complete(ctx context.Context, r *readline.Readline) []goprompt.Suggest

func (*Command) Description

func (c *Command) Description() string

func (*Command) Execute

func (c *Command) Execute(ctx context.Context, r *readline.Readline) error

func (*Command) Help

func (c *Command) Help(ctx context.Context, r *readline.Readline) string

func (*Command) Name

func (c *Command) Name() string

type CommandOption

type CommandOption func(*Command)

func CommandWithClusterNameFn

func CommandWithClusterNameFn(v ClusterNameFn) CommandOption

func CommandWithName

func CommandWithName(v string) CommandOption

type Config

type Config struct {
	ConfigPath string             `json:"configPath" yaml:"configPath"`
	Clusters   map[string]Cluster `json:"clusters" yaml:"clusters"`
}

func (Config) Cluster

func (c Config) Cluster(name string) (Cluster, error)

func (Config) ClusterNames

func (c Config) ClusterNames() []string

type Doctl

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

func New

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

func (*Doctl) AccessToken

func (k *Doctl) AccessToken() (string, error)

func (*Doctl) Client

func (k *Doctl) Client() (*godo.Client, error)

func (*Doctl) Cluster

func (k *Doctl) Cluster(ctx context.Context, name string) (*godo.KubernetesCluster, error)

func (*Doctl) Clusters

func (k *Doctl) Clusters(ctx context.Context) []*godo.KubernetesCluster

type Option

type Option func(*Doctl) 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