az

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

README

POSH az provider

Usage

This provider requires az to be installed on your system.

Plugin
package main

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

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

  // ...

  inst.commands.Add(az.NewCommand(l, inst.az, inst.kubectl))

  // ...

  return inst, nil
}
Config
## az
az:
  configPath: devops/config/azure
  resourceGroups:
    prod:
      name: rg-my-prod
      subscription: xxxxx
      clusters:
        prod:
          name: aks-my-prod
Ownbrew

To install binary locally, add:

ownbrew:
  packages:
    ## https://github.com/Azure/kubelogin/releases
    - name: kubelogin
      tap: foomo/tap/azure/kubelogin
      version: 0.1.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AZ

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

func New

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

func (*AZ) Config added in v0.8.0

func (a *AZ) Config() Config

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, az *AZ, 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"`
	ResourceGroups map[string]ResourceGroup `json:"resourceGroups" yaml:"resourceGroups"`
}

func (Config) ResourceGroup

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

func (Config) ResourceGroupNames

func (c Config) ResourceGroupNames() []string

type Option

type Option func(*AZ) error

func CommandWithConfigKey

func CommandWithConfigKey(v string) Option

type ResourceGroup

type ResourceGroup struct {
	Name         string             `json:"name" yaml:"name"`
	Subscription string             `json:"subscription" yaml:"subscription"`
	Clusters     map[string]Cluster `json:"clusters" yaml:"clusters"`
}

func (ResourceGroup) Cluster

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

func (ResourceGroup) ClusterNames

func (c ResourceGroup) ClusterNames() []string

Jump to

Keyboard shortcuts

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