stackit

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: 13 Imported by: 0

README

POSH stackit provider

Usage

Plugin
package main

import (
  "github.com/foomo/posh-providers/kubernets/kubectl"
  "github.com/foomo/posh-providers/stackitcloud/stackit"
  "github.com/foomo/posh/pkg/cache"
  "github.com/foomo/posh/pkg/command"
)

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

  // ...

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

  // ...

  return inst, nil
}

Config
## stackit
stackit:
  projects:
    my-project:
      id: 123456-123456-123456
      clusters:
        dev:
          name: my-project-dev-cluster
Ownbrew

To install binary locally, add:

ownbrew:
  packages:
    ## https://github.com/stackitcloud/stackit-cli/releases
    - name: stackit
      tap: foomo/tap/stackitcloud/stackit-cli
      version: 0.9.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"`
}

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, stackit *Stackit, 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 {
	Projects map[string]Project `json:"projects" yaml:"projects"`
}

func (Config) Project

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

func (Config) ProjectNames

func (c Config) ProjectNames() []string

type Option

type Option func(*Stackit) error

func CommandWithConfigKey

func CommandWithConfigKey(v string) Option

type Project

type Project struct {
	ID       string             `json:"id" yaml:"id"`
	Clusters map[string]Cluster `json:"clusters" yaml:"clusters"`
}

func (Project) Cluster

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

func (Project) ClusterNames

func (c Project) ClusterNames() []string

type Stackit

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

func New

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

func (*Stackit) ClusterNames

func (s *Stackit) ClusterNames(projectName string) ([]string, error)

func (*Stackit) Config

func (s *Stackit) Config() Config

Jump to

Keyboard shortcuts

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