truss

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSecretFileConfigInvalidYaml = errors.New("Unable to parse secret as yaml or missing required root element `secrets`")

ErrSecretFileConfigInvalidYaml error if invalid yaml

Functions

func GetGlobalConfigS3 added in v0.0.8

func GetGlobalConfigS3(input *GetGlobalConfigS3Input) (string, error)

GetGlobalConfigS3 fetch global config from S3 and put it in home dir

func NewAWSSession added in v0.0.9

func NewAWSSession(region string, assumeRole string) *session.Session

NewAWSSession creates an AWS session with role assumed

func Setup

func Setup(dependencies *[]string) error

Setup set up

func Wrap added in v0.0.8

func Wrap(input *WrapInput, bin string, arg ...string) error

Wrap exports relevant kubeconfig and runs command

Types

type ASGFilterFunc added in v0.1.0

type ASGFilterFunc func(*autoscaling.Group) bool

ASGFilterFunc filters ASGs

type BootstrapConfig added in v0.1.0

type BootstrapConfig struct {
	TemplateSource struct {
		Type  string `default:"local"`
		Local struct {
			Directory string `default:"./bootstrap-templates"`
		}
		S3 struct {
			Bucket string `default:"truss-cli-global-config"`
			Region string `default:"us-east-2"`
			Prefix string `default:"bootstrap-templates"`
			Role   string `default:"arn:aws:iam::127178877223:role/xacct/ops-admin"`
		}
		Git struct {
			CloneURL    string `default:"git@github.com:instructure-bridge/truss-cli.git" yaml:"clone_url"`
			Directory   string `default:"bootstrap-templates"`
			CheckoutRef string `yaml:"checkout_ref"`
		}
	} `yaml:"templateSource"`
	TrussDir string `default:"truss" yaml:"trussDir"`
	Template string `default:"default"`
	Params   map[string]interface{}
}

BootstrapConfig represetns a Bootstrap configuration

func LoadBootstrapConfig added in v0.1.0

func LoadBootstrapConfig(name string) (*BootstrapConfig, error)

LoadBootstrapConfig loads a config from disk

func (BootstrapConfig) GetBootstrapper added in v0.1.0

func (c BootstrapConfig) GetBootstrapper() (b *Bootstrapper, err error)

GetBootstrapper gets a Bootstrapper from a configuration

func (BootstrapConfig) GetTemplateSource added in v0.1.0

func (c BootstrapConfig) GetTemplateSource() (t TemplateSource, err error)

GetTemplateSource gets a TemplateSource from a configuration

type BootstrapManifest added in v0.1.0

type BootstrapManifest struct {
	Params []struct {
		Name    string      `yaml:"name"`
		Type    string      `yaml:"type"`
		Prompt  string      `yaml:"prompt"`
		Default interface{} `yaml:"default"`
	} `yaml:"params"`
}

BootstrapManifest represents the manifest thingy

type BootstrapParameter added in v0.1.1

type BootstrapParameter struct {
	Type  string
	Value string

	PascalCase string
	CamelCase  string
	KebabCase  string
	SnakeCase  string
	FlatCase   string
}

BootstrapParameter - struct to handle types and case conversions

func NewBootstrapParameter added in v0.1.1

func NewBootstrapParameter(value string) *BootstrapParameter

NewBootstrapParameter - create a bootstrap parameter with the type string

func NewBootstrapParameterBool added in v0.1.1

func NewBootstrapParameterBool(value bool) *BootstrapParameter

NewBootstrapParameterBool - create a bootstrap parameter with the type bool

func (*BootstrapParameter) String added in v0.1.1

func (c *BootstrapParameter) String() string

type BootstrapParams added in v0.1.0

type BootstrapParams map[string]*BootstrapParameter

BootstrapParams represents user-provided parameters for a template

func (*BootstrapParams) LoadFromConfig added in v0.1.0

func (p *BootstrapParams) LoadFromConfig(c *BootstrapConfig) error

LoadFromConfig reads params from a given configuration

func (*BootstrapParams) LoadFromFlags added in v0.1.0

func (p *BootstrapParams) LoadFromFlags(s map[string]string) error

LoadFromFlags reads params from a collection of flag values

func (BootstrapParams) Validate added in v0.1.0

func (p BootstrapParams) Validate(m *BootstrapManifest) (errs []string, err error)

Validate validates the given parameters against a manifest

type Bootstrapper added in v0.1.0

type Bootstrapper struct {
	TemplateSource
	TrussDir string
	Template string
}

Bootstrapper bootstraps a deployment

func NewBootstrapper added in v0.1.0

func NewBootstrapper(ts TemplateSource, trussDir, template string) *Bootstrapper

NewBootstrapper returns a new TemplateSource

func (Bootstrapper) Bootstrap added in v0.1.0

func (b Bootstrapper) Bootstrap(params *BootstrapParams) error

Bootstrap does the thing!

func (Bootstrapper) GetTemplateManifest added in v0.1.0

func (b Bootstrapper) GetTemplateManifest() *BootstrapManifest

GetTemplateManifest gets a template's manifest

type EnvInput added in v0.0.8

type EnvInput struct {
	Env         string
	Kubeconfigs map[string]interface{}
	KubeDir     string
}

EnvInput input

type EnvironmentVars added in v0.0.8

type EnvironmentVars struct {
	Kubeconfig string
}

EnvironmentVars key/value pairs of environment variables that should be set in the shell

func Env added in v0.0.8

func Env(input *EnvInput) (EnvironmentVars, error)

Env configures environment variables that should be set in the bash shell

func (*EnvironmentVars) BashFormat added in v0.0.8

func (environmentVars *EnvironmentVars) BashFormat(env string) string

BashFormat formats environment variables for bash

type GetGlobalConfigS3Input added in v0.0.8

type GetGlobalConfigS3Input struct {
	Bucket string
	Region string
	Key    string
	Role   string
	Dir    string
}

GetGlobalConfigS3Input input for GetGlobalConfigS3

type GetKubeconfigCmd

type GetKubeconfigCmd interface {
	Fetch() error
}

GetKubeconfigCmd command for managing kubeconfigs

func GetKubeconfigS3

func GetKubeconfigS3(awsRole string, bucket string, dest string, region string) GetKubeconfigCmd

GetKubeconfigS3 return command

type GetKubeconfigS3Cmd

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

GetKubeconfigS3Cmd command for managing kubeconfigs

func (*GetKubeconfigS3Cmd) Fetch

func (config *GetKubeconfigS3Cmd) Fetch() error

Fetch kubeconfigs

type GitTemplateSource added in v0.1.0

type GitTemplateSource struct {
	TemplateSource
	CloneURL    string `default:"git@github.com:instructure-bridge/truss-cli.git" yaml:"clone_url"`
	Directory   string `default:"bootstrap-templates"`
	CheckoutRef string `yaml:"checkout_ref"`
	// contains filtered or unexported fields
}

GitTemplateSource is a Local Filesystem Template Source

func NewGitTemplateSource added in v0.1.0

func NewGitTemplateSource(cloneURL, directory, checkoutRef string) (*GitTemplateSource, error)

NewGitTemplateSource returns a new TemplateSource

func (GitTemplateSource) Cleanup added in v0.1.0

func (s GitTemplateSource) Cleanup()

Cleanup cleans up

type KubectlCmd

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

KubectlCmd wrapper for kubectl

func Kubectl

func Kubectl(kubeconfig string) *KubectlCmd

Kubectl wrapper for kubectl

func (*KubectlCmd) ClosePortForward

func (kubectl *KubectlCmd) ClosePortForward() error

ClosePortForward sigterm kubectl port-forward

func (*KubectlCmd) PortForward

func (kubectl *KubectlCmd) PortForward(port, listen, namespace, target string, timeoutSeconds int) error

PortForward kubectl port-forward

func (*KubectlCmd) Run

func (kubectl *KubectlCmd) Run(arg ...string) ([]byte, error)

Run kubectl

type LocalTemplateSource added in v0.1.0

type LocalTemplateSource struct {
	Directory string
}

LocalTemplateSource is a Local Filesystem Template Source

func NewLocalTemplateSource added in v0.1.0

func NewLocalTemplateSource(directory string) *LocalTemplateSource

NewLocalTemplateSource returns a new TemplateSource

func (LocalTemplateSource) Cleanup added in v0.1.0

func (s LocalTemplateSource) Cleanup()

Cleanup doesn't do anything

func (LocalTemplateSource) GetTemplateManifest added in v0.1.0

func (s LocalTemplateSource) GetTemplateManifest(t string) *BootstrapManifest

GetTemplateManifest gets the template's manifest

func (LocalTemplateSource) ListTemplates added in v0.1.0

func (s LocalTemplateSource) ListTemplates() ([]string, error)

ListTemplates returns a list of temlpates in the local directory

func (LocalTemplateSource) LocalDirectory added in v0.1.0

func (s LocalTemplateSource) LocalDirectory(template string) (string, error)

LocalDirectory returns a local directory for the template

type NetworkRouteProvider added in v0.0.10

type NetworkRouteProvider struct {
	Routes      []string
	OpenConnect *OpenConnect
}

NetworkRouteProvider provides routes by provisioning them directly with the OS

func (NetworkRouteProvider) Setup added in v0.0.10

func (n NetworkRouteProvider) Setup() error

Setup creates the routes

func (NetworkRouteProvider) Teardown added in v0.0.10

func (n NetworkRouteProvider) Teardown() error

Teardown destroys the routes

type OpenConnect added in v0.0.10

type OpenConnect struct {
	User      string
	Authgroup string
	Server    string
	Env       []string
	Script    *string
	// contains filtered or unexported fields
}

OpenConnect represents an OpenConnect Connection

func NewOpenConnect added in v0.0.10

func NewOpenConnect(user, server, authGroup string) *OpenConnect

NewOpenConnect returns a default OpenConnect instance

func (*OpenConnect) AddHook added in v0.0.10

func (c *OpenConnect) AddHook(k OpenConnectEvent, h OpenConnectHook)

AddHook adds an event hook

func (*OpenConnect) Start added in v0.0.10

func (c *OpenConnect) Start() error

Start interactively starts the tunnel

func (OpenConnect) Stop added in v0.0.10

func (c OpenConnect) Stop() error

Stop stops the tunnel

type OpenConnectEvent added in v0.0.10

type OpenConnectEvent int

OpenConnectEvent represents a connection event

const (
	OpenConnectConnecting   OpenConnectEvent = iota
	OpenConnectConnected    OpenConnectEvent = iota
	OpenConnectDisconnected OpenConnectEvent = iota
)

type OpenConnectHook added in v0.0.10

type OpenConnectHook func() error

OpenConnectHook is a function that can be invoked when an event occurs

type RefreshNodesCmd added in v0.1.0

type RefreshNodesCmd struct {
	ASC autoscalingiface.AutoScalingAPI
}

RefreshNodesCmd is used to refresh Truss nodes

func NewRefreshNodesCmd added in v0.1.0

func NewRefreshNodesCmd(role, arn string) *RefreshNodesCmd

NewRefreshNodesCmd instantiates a RefreshNodesCmd

func (RefreshNodesCmd) GetFilteredAutoscalingGroups added in v0.1.0

func (c RefreshNodesCmd) GetFilteredAutoscalingGroups(ff ASGFilterFunc) ([]*autoscaling.Group, error)

GetFilteredAutoscalingGroups returns a filtered list of ASGs

func (RefreshNodesCmd) RefreshNodes added in v0.1.0

func (c RefreshNodesCmd) RefreshNodes(g *autoscaling.Group) error

RefreshNodes triggers an Instance Refresh on the provided ASG

type S3TemplateSource added in v0.1.0

type S3TemplateSource struct {
	Bucket string
	Folder string
	Region string
	Role   string
	// contains filtered or unexported fields
}

S3TemplateSource is an Amazon S3 Template Source

func NewS3TemplateSource added in v0.1.0

func NewS3TemplateSource(bucket, folder, region, role string) *S3TemplateSource

NewS3TemplateSource returns a new TemplateSource

func (*S3TemplateSource) Cleanup added in v0.1.0

func (s *S3TemplateSource) Cleanup()

Cleanup removes tmpDirs

func (S3TemplateSource) GetTemplateManifest added in v0.1.0

func (s S3TemplateSource) GetTemplateManifest(t string) *BootstrapManifest

GetTemplateManifest parses the template's manifest

func (S3TemplateSource) ListTemplates added in v0.1.0

func (s S3TemplateSource) ListTemplates() ([]string, error)

ListTemplates returns a list of temlpates in the template bucket

func (*S3TemplateSource) LocalDirectory added in v0.1.0

func (s *S3TemplateSource) LocalDirectory(template string) (string, error)

LocalDirectory returns a local cache of the S3 Template

type SecretConfig added in v0.0.4

type SecretConfig interface {
	Name() string
	Kubeconfig() string
	VaultPath() string
	// contains filtered or unexported methods
}

SecretConfig interface for secret config can be a file or directory or anything!

type SecretConfigList added in v0.0.4

type SecretConfigList struct {
	Secrets        []SecretConfig `yaml:"secrets"`
	TransitKeyName string         `yaml:"transit-key-name"`
}

SecretConfigList represents a list of named SecretConfigs

func SecretConfigListFromFile added in v0.0.4

func SecretConfigListFromFile(path string) (*SecretConfigList, error)

SecretConfigListFromFile reads a config file

func (SecretConfigList) Secret added in v0.0.5

func (l SecretConfigList) Secret(name, kubeconfig string) (SecretConfig, error)

Secret locates a secret by name and kubeconfig

func (SecretConfigList) SecretKubeconfigs added in v0.0.5

func (l SecretConfigList) SecretKubeconfigs(name string) []string

SecretKubeconfigs returns a list of kubeconfigs defined for a given secret

func (SecretConfigList) SecretNames added in v0.0.5

func (l SecretConfigList) SecretNames() []string

SecretNames returns a list of secret names provided in the list

type SecretDirConfig added in v0.1.0

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

SecretDirConfig represents a desired Vault synchronization

func (SecretDirConfig) Kubeconfig added in v0.1.0

func (s SecretDirConfig) Kubeconfig() string

Kubeconfig Kubeconfig

func (SecretDirConfig) Name added in v0.1.0

func (s SecretDirConfig) Name() string

Name name

func (SecretDirConfig) VaultPath added in v0.1.0

func (s SecretDirConfig) VaultPath() string

VaultPath VaultPath

type SecretFileConfig added in v0.1.0

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

SecretFileConfig represents a desired Vault synchronization

func (SecretFileConfig) Kubeconfig added in v0.1.0

func (s SecretFileConfig) Kubeconfig() string

Kubeconfig Kubeconfig

func (SecretFileConfig) Name added in v0.1.0

func (s SecretFileConfig) Name() string

Name name

func (SecretFileConfig) VaultPath added in v0.1.0

func (s SecretFileConfig) VaultPath() string

VaultPath VaultPath

type SecretsManager added in v0.0.4

type SecretsManager struct {
	*SecretConfigList
	VaultAuth VaultAuth
	Editor    string
}

SecretsManager syncrhonizes secrets between the filesystem and Vault

func NewSecretsManager added in v0.0.4

func NewSecretsManager(secretsFile string, editor string, vaultAuth VaultAuth) (*SecretsManager, error)

NewSecretsManager creates a new SecretsManager

func (SecretsManager) Edit added in v0.0.4

func (m SecretsManager) Edit(secret SecretConfig) (bool, error)

Edit edits an environments's secrets Returns true if $EDITOR wrote to the temp file

func (SecretsManager) EncryptSecret added in v0.1.0

func (m SecretsManager) EncryptSecret(secret SecretConfig) error

EncryptSecret on disk with cypher text from vault

func (SecretsManager) Pull added in v0.0.4

func (m SecretsManager) Pull(secret SecretConfig) error

Pull updates the file on disk with the vaules from Vault (destructive)

func (SecretsManager) PullAll added in v0.0.4

func (m SecretsManager) PullAll() error

PullAll pulls all environments

func (SecretsManager) Push added in v0.0.4

func (m SecretsManager) Push(secret SecretConfig) error

Push pushes secrets to Vaut

func (SecretsManager) PushAll added in v0.0.4

func (m SecretsManager) PushAll() error

PushAll pushes all secrets for all environments

func (SecretsManager) Vault added in v0.0.4

func (m SecretsManager) Vault(secret SecretConfig) (*VaultCmd, error)

Vault creates a proxied Vault client

func (SecretsManager) View added in v0.1.0

func (m SecretsManager) View(secret SecretConfig) (localContent string, remoteContent string, err error)

View Secret

type SshuttleRouteProvider added in v0.0.10

type SshuttleRouteProvider struct {
	Host   string
	Routes []string
}

SshuttleRouteProvider provides routes by tunneling with sshuttle

func (SshuttleRouteProvider) Setup added in v0.0.10

func (n SshuttleRouteProvider) Setup() error

Setup creates the routes

func (SshuttleRouteProvider) Teardown added in v0.0.10

func (n SshuttleRouteProvider) Teardown() error

Teardown destroys the routes

type TemplateSource added in v0.1.0

type TemplateSource interface {
	ListTemplates() ([]string, error)
	LocalDirectory(template string) (string, error)
	GetTemplateManifest(t string) *BootstrapManifest
	Cleanup()
}

TemplateSource sources templates

type VaultAuth

type VaultAuth interface {
	Login(data interface{}, port string) (token string, err error)
	LoadCreds() (data interface{}, err error)
}

VaultAuth vault auth

func VaultAuthAWS

func VaultAuthAWS(vaultRole, awsRole, awsRegion string) VaultAuth

VaultAuthAWS vault auth

type VaultCmd

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

VaultCmd wrapper implementation for hashicorp vault

func Vault

func Vault(kubeconfig string, auth VaultAuth) *VaultCmd

Vault wrapper for hashicorp vault

func VaultWithToken added in v0.1.0

func VaultWithToken(kubeconfig string, authToken string) *VaultCmd

VaultWithToken wrapper for hashicorp vault with token for auth

func (*VaultCmd) ClosePortForward added in v0.0.4

func (vault *VaultCmd) ClosePortForward() error

ClosePortForward closes the port forward, if any

func (*VaultCmd) Decrypt added in v0.1.0

func (vault *VaultCmd) Decrypt(transitKeyName string, encrypted []byte) ([]byte, error)

Decrypt bytes using transit key

func (*VaultCmd) Encrypt added in v0.1.0

func (vault *VaultCmd) Encrypt(transitKeyName string, raw []byte) ([]byte, error)

Encrypt bytes using transit key

func (*VaultCmd) GetMap added in v0.1.0

func (vault *VaultCmd) GetMap(vaultPath string) (map[string]interface{}, error)

GetMap returns a vaultPath as a map

func (*VaultCmd) GetWrappingToken added in v0.1.0

func (vault *VaultCmd) GetWrappingToken() (string, error)

GetWrappingToken gets a Vault wrapping token Caller is responsible for closing port

func (*VaultCmd) ListPath added in v0.1.0

func (vault *VaultCmd) ListPath(vaultPath string) ([]string, error)

ListPath returns a vaultPath as a map

func (*VaultCmd) PortForward added in v0.0.4

func (vault *VaultCmd) PortForward() (string, error)

PortForward instantiates a port-forward for Vault

func (*VaultCmd) Run

func (vault *VaultCmd) Run(args []string) ([]byte, error)

Run run command

func (*VaultCmd) Write added in v0.1.0

func (vault *VaultCmd) Write(vaultPath string, data map[string]interface{}) (*api.Secret, error)

Write to vault

type WrapInput added in v0.0.8

type WrapInput struct {
	Kubeconfig string
	Stdout     io.Writer
	Stderr     io.Writer
	Stdin      io.Reader
}

WrapInput input for Wrap

Jump to

Keyboard shortcuts

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