ops

package
v0.0.0-...-21350ee Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const ACCOUNT_ENV_VAR = "AWS_ACCOUNT_CREDENTIALS"
View Source
const AWS_ID_ENV_VAR = "AWS_ACCESS_KEY_ID"

AWS_ID_ENV_VAR Default AWS SDK env var for AWS_ACCESS_KEY_ID

View Source
const AWS_REGION_ENV_VAR = "AWS_REGION"

AWS_REGION_ENV_VAR Default AWS SDK env var for AWS_REGION

View Source
const AWS_SECRET_ENV_VAR = "AWS_SECRET_ACCESS_KEY"

AWS_SECRET_ENV_VAR Default AWS SDK env var for AWS_SECRET_ACCESS_KEY

View Source
const BETA_TEMPLATE_URL = "https://orion-ptt-system-beta.s3.amazonaws.com/orion-ptt-system.yaml"

BETA_TEMPLATE_URL S3 URL for CloudFormation Template

View Source
const CONFIG_FILE_TEMPLATE = `` /* 299-byte string literal not displayed */

CONFIG_FILE_TEMPLATE Blank default config file template for the 'config' command.

View Source
const DEFAULT_CONFIG_FILE = ".orion-ptt-system.json"

DEFAULT_CONFIG_FILE Default config file name.

View Source
const DEFAULT_INSTANCE_NAME = "orion-ptt-system"

DEFAULT_INSTANCE_NAME Default name for EC2 instance

View Source
const DEFAULT_INSTANCE_TYPE = "m5.2xlarge"

DEFAULT_INSTANCE_TYPE Default instance type

View Source
const DEFAULT_NETWORK_CONFIG_FILE = ".orion-ptt-system-network.json"
View Source
const DEFAULT_TEMPLATE_FILE = ".orion-ptt-system.tmpl"
View Source
const DEFAULT_TEMPLATE_URL = "https://orion-ptt-system.s3.amazonaws.com/orion-ptt-system.yaml"

DEFAULT_TEMPLATE_URL S3 URL for CloudFormation Template

View Source
const DEFAULT_VOLUME_SIZE = 50

DEFAULT_VOLUME_SIZE Default EBS Volume size in Gigs.

View Source
const ERR_SSH_GENERAL = "SSH error.  Is your ssh-agent running?  Keys loaded?  Can't bootstrap Orion PTT System without it."
View Source
const ERR_TO_MANY_STACKS = "Multiple stacks of supplied name found"

ERR_TO_MANY_STACKS Error thrown when more than one stack of a given name is found. Should be impossible.

Variables

View Source
var TESTING bool

Functions

func AskForValue

func AskForValue(parameter string) (value string)

AskForValue Asks the user for any value not found in the config file.

func DefaultSession

func DefaultSession() (awssession *session.Session, err error)

DefaultSession creates a default AWS session from local config path.

func FetchFileS3

func FetchFileS3(s3Meta S3Meta, filePath string) (err error)

FetchFileS3 fetches the config template from an s3 url.

func GitContent

func GitContent(repo string, path string) (content []byte, err error)

func PingEndpoint

func PingEndpoint(address string) (err error)

func RetryUntil

func RetryUntil(thing func() (err error), timeoutMinutes int) (elapsed time.Duration, err error)

RetryUntil takes a function, and calls it every 20 seconds until it succeeds. Useful for polling endpoints in k8s that will eventually start working. Returns an error if the provided timeoutMinutes elapses. Otherwise returns the elapsed duration from start to finish.

func SSHAgent

func SSHAgent() ssh.AuthMethod

SSHAgent is a programmatic client that talks to the ssh agent.

func SplitRepoPath

func SplitRepoPath(uri string) (repo, path string)

func StringInSlice

func StringInSlice(a string, list []string) bool

StringInSlice returns true if the given string is in the given slice

Types

type Account

type Account struct {
	Number    string `json:"account_number"`
	KeyId     string `json:"aws_access_key_id"`
	SecretKey string `json:"aws_secret_access_key"`
	Region    string `json:"aws_region"`
}

type OnpremConfig

type OnpremConfig struct {
	Keystore  string
	StackName string
	Domain    string
}

type OnpremDetails

type OnpremDetails struct {
	Account     string `json:"account" binding:"required"`
	Kubernetes  string `json:"kubernetes" binding:"required"`
	Kotsadm     string `json:"kotsadm" binding:"required"`
	CFStatus    string `json:"cfstatus" binding:"required"`
	Name        string `json:"name" binding:"required"`
	Address     string `json:"address" binding:"required"`
	Datastore   string `json:"datastore" binding:"required"`
	EventStream string `json:"eventstream" binding:"required"`
	Media       string `json:"media" binding:"required"`
	Login       string `json:"login" binding:"required"`
	Api         string `json:"api" binding:"required"`
	CDN         string `json:"cdn" binding:"required"`
	CA          string `json:"ca" binding:"required"`
	Created     string `json:"created" binding:"required"`
	Uptime      string `json:"uptime" binding:"required"`
}

type OpsServer

type OpsServer struct {
	Address  string
	Port     int
	Accounts []Account
}

func NewOpsServer

func NewOpsServer(address string, port int) (server *OpsServer, err error)

func (*OpsServer) DeleteStack

func (s *OpsServer) DeleteStack(accountNumber string, stackName string) (err error)

func (*OpsServer) GetDetails

func (s *OpsServer) GetDetails(accountNum string, stackName string) (deets OnpremDetails, err error)

func (*OpsServer) GetInstances

func (s *OpsServer) GetInstances() (instances []OnpremDetails, err error)

func (*OpsServer) GetStack

func (s *OpsServer) GetStack(accountNumber string, stackName string) (stack *Stack, err error)

GetStack retrieves a configured stack object for a given account and name based on credentials we have available.

func (*OpsServer) InstanceCaHandler

func (s *OpsServer) InstanceCaHandler(c *gin.Context)

InstanceCaHandler fetches the CA cert for a specific instance and sends it back to the client.

func (*OpsServer) InstanceDeleteHandler

func (s *OpsServer) InstanceDeleteHandler(c *gin.Context)

InstanceDeleteHandler deletes a specific instance

func (*OpsServer) InstancesHandler

func (s *OpsServer) InstancesHandler(c *gin.Context)

InstancesHandler returns json with all instances, though the instances themselves will only have account numbers and names. Details need to be fetched later. This is done to speed response time on the webpage.

func (*OpsServer) Run

func (s *OpsServer) Run() (err error)

func (*OpsServer) Serve

func (s *OpsServer) Serve(urlPrefix string, efs embed.FS) gin.HandlerFunc

func (*OpsServer) SingleInstanceHandler

func (s *OpsServer) SingleInstanceHandler(c *gin.Context)

SingleInstanceHandler returns details for a particular instance.

type S3Meta

type S3Meta struct {
	Bucket string
	Region string
	Key    string
	Url    string
}

S3Meta a struct for holding metadata for S3 Objects. There's probably already a struct that holds this, but this is all I need.

func S3Url

func S3Url(url string) (ok bool, meta S3Meta)

S3Url returns true, and a metadata struct if the url given appears to be in s3

type SimpleCFTemplate

type SimpleCFTemplate struct {
	Description string `yaml:"Description"`
}

type SshProgClient

type SshProgClient struct {
	Host   string
	Port   int
	Config *ssh.ClientConfig
}

SshProgClient is an ssh client designed to do remote commands or RPC's

func NewSshProgClient

func NewSshProgClient(host string, port int, config *ssh.ClientConfig) (client *SshProgClient)

NewSshProgClient creates a client for the given host, port, and config.

func SshClient

func SshClient(hostname string, port int, username string) (client *SshProgClient, err error)

SshClient generates an SSH client for talking to the provisioning server

func (*SshProgClient) RpcCall

func (c *SshProgClient) RpcCall(input []byte, stdout, stderr io.Writer) (err error)

RpcCall flings bytes at a remote server over SSH to STDIN, and receives whatever that server decides to send back on STDOUT and STDERR. What you send it, and what you do with the reply is between you and the server.

func (*SshProgClient) SCPFile

func (c *SshProgClient) SCPFile(content string, filename string) (err error)

SCPFile copies a file via SCP to the remote host.

type Stack

type Stack struct {
	Config       *StackConfig
	AwsSession   *session.Session
	AutoRollback bool
}

Stack Programmatic representation of an Orion PTT System CloudFormation stack.

func NewStack

func NewStack(config *StackConfig, awsSession *session.Session, autorollback bool) (stack *Stack, err error)

NewStack Creates a new programmatic representation of a Stack. Creates the object/interface. Doesn't actually create it in AWS until you call Init().

func (*Stack) Create

func (s *Stack) Create(stageOnly bool) (err error)

Create Instantiates an instance of the Orion PTT System in AWS via CloudFormation

func (*Stack) CreateCFStackInput

func (s *Stack) CreateCFStackInput() (input cloudformation.CreateStackInput, err error)

func (*Stack) CreateConfig

func (s *Stack) CreateConfig() (content string, err error)

CreateConfig Creates an orion-ptt-system kots config file from a local template. The template itself is not distributed with this package to avoid leaking sensitive information. To get one, you'll have to purchase an Orion PTT System license.

func (*Stack) Created

func (s *Stack) Created() (created *time.Time, err error)

Status Fetches stack events from AWS.

func (*Stack) Delete

func (s *Stack) Delete() (err error)

Delete Destroys a stack in AWS.

func (*Stack) Destroy

func (s *Stack) Destroy() (err error)

func (*Stack) Exists

func (s *Stack) Exists() (exists bool)

Exists Returns true or false depending on whether the stack exists.

func (*Stack) Init

func (s *Stack) Init() (id string, err error)

Init hits the AWS API to create a Cloudformation stack.

func (*Stack) KotsInstall

func (s *Stack) KotsInstall(sshClient *SshProgClient) (err error)

func (*Stack) ListStacks

func (s *Stack) ListStacks() (stacks []*cloudformation.Stack, err error)

ListStacks Queries the CF Yaml, and AWS, returning a list of stacks with a description that matches the description in the yaml template.

func (*Stack) LookupAmiID

func (s *Stack) LookupAmiID() (id string, err error)

func (*Stack) LookupNetwork

func (s *Stack) LookupNetwork() (vpcID string, subnetID string, err error)

LookupNetwork looks up VPC and subnetID based on allowable subnets supplied by config file. Returns first match. Basically a crude means of detecting which VPC we're running in.

func (*Stack) LookupZoneID

func (s *Stack) LookupZoneID() (id string, err error)

func (*Stack) Outputs

func (s *Stack) Outputs() (outputs []*cloudformation.Output, err error)

Outputs Fetches stack outputs from AWS

func (*Stack) Params

func (s *Stack) Params() (parameters []*cloudformation.Parameter, err error)

Params Fetches stack parameters from AWS.

func (*Stack) PollEndpoint

func (s *Stack) PollEndpoint(address string) (err error)

func (*Stack) PollKotsadm

func (s *Stack) PollKotsadm(sshClient *SshProgClient) (err error)

func (*Stack) PollKotsadmConsole

func (s *Stack) PollKotsadmConsole(address string) (err error)

func (*Stack) PrintOutputs

func (s *Stack) PrintOutputs(outputs []*cloudformation.Output)

func (*Stack) StageConfig

func (s *Stack) StageConfig(sshClient *SshProgClient) (err error)

func (*Stack) StageLicense

func (s *Stack) StageLicense(sshClient *SshProgClient) (err error)

func (*Stack) Status

func (s *Stack) Status() (status string, err error)

Status Fetches stack events from AWS.

func (*Stack) TrustCA

func (s *Stack) TrustCA(host string) (err error)

type StackConfig

type StackConfig struct {
	StackName       string `json:"stack_name"`
	KeyName         string `json:"key_name"`
	DNSDomain       string `json:"dns_domain"`
	InstanceType    string `json:"instance_type"`
	Username        string `json:"user_name"`
	LicenseFile     string `json:"license_file"`
	ConfigTemplate  string `json:"config_template"`
	KotsadmPassword string `json:"kotsadm_password"`
	AMIName         string `json:"ami_name"`
	Beta            bool
	SubnetIDs       []string `json:"subnet_ids"`
}

StackConfig Config information for an Orion PTT System CloudFormation stack.

func LoadConfig

func LoadConfig(configPath string) (config *StackConfig, err error)

LoadConfig Loads a config file from the filesystem.

func (*StackConfig) AskForMissingParams

func (c *StackConfig) AskForMissingParams(keyNeeded bool) (err error)

AskForMissingParams Examines the config object and calls AskForValue() on any misisng value.

Jump to

Keyboard shortcuts

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