selector

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package selector provides functionality for users to select an application, environment, or service name.

Package selector provides functionality for users to select an application, environment, or service name.

Index

Constants

View Source
const (

	// DockerfilePromptUseImage is the option for using existing image instead of Dockerfile.
	DockerfilePromptUseImage = "Use an existing image instead"
)

Variables

View Source
var (
	// ErrVPCNotFound is returned when no existing VPCs are found.
	ErrVPCNotFound = errors.New("no existing VPCs found")
	// ErrSubnetsNotFound is returned when no existing subnets are found.
	ErrSubnetsNotFound = errors.New("no existing subnets found")
)

Functions

This section is empty.

Types

type AppEnvLister

type AppEnvLister interface {
	ListEnvironments(appName string) ([]*config.Environment, error)
	ListApplications() ([]*config.Application, error)
}

AppEnvLister wraps methods to list apps and envs in config store.

type CFTaskSelect added in v1.1.0

type CFTaskSelect struct {
	*Select
	// contains filtered or unexported fields
}

CFTaskSelect is a selector based on CF methods to get deployed one off tasks.

func NewCFTaskSelect added in v1.1.0

func NewCFTaskSelect(prompt Prompter, store ConfigLister, cf TaskStackDescriber) *CFTaskSelect

func (*CFTaskSelect) Task added in v1.1.0

func (s *CFTaskSelect) Task(prompt, help string, opts ...GetDeployedTaskOpts) (string, error)

Task has the user select a task. Callers can provide an environment, an app, or a "use default cluster" option to filter the returned tasks.

type ConfigLister

type ConfigLister interface {
	AppEnvLister
	ConfigWorkloadLister
}

ConfigLister wraps config store listing methods.

type ConfigSelect

type ConfigSelect struct {
	*Select
	// contains filtered or unexported fields
}

ConfigSelect is an application and environment selector, but can also choose a service from the config store.

func NewConfigSelect

func NewConfigSelect(prompt Prompter, store ConfigLister) *ConfigSelect

NewConfigSelect returns a new selector that chooses applications, environments, or services from the config store.

func (*ConfigSelect) Job added in v1.6.0

func (s *ConfigSelect) Job(prompt, help, app string) (string, error)

Job fetches all jobs in an app and prompts the user to select one.

func (*ConfigSelect) Service

func (s *ConfigSelect) Service(prompt, help, app string) (string, error)

Service fetches all services in an app and prompts the user to select one.

type ConfigWorkloadLister added in v0.5.0

type ConfigWorkloadLister interface {
	ListServices(appName string) ([]*config.Workload, error)
	ListJobs(appName string) ([]*config.Workload, error)
	ListWorkloads(appName string) ([]*config.Workload, error)
}

ConfigWorkloadLister wraps the method to list workloads in config store.

type CredsSelect added in v0.3.0

type CredsSelect struct {
	Prompt  Prompter
	Profile Names
	Session SessionProvider
}

CredsSelect prompts users for credentials.

func (*CredsSelect) Creds added in v0.3.0

func (s *CredsSelect) Creds(prompt, help string) (*session.Session, error)

Creds prompts users to choose either use temporary credentials or choose from one of their existing AWS named profiles.

type DeploySelect

type DeploySelect struct {
	*Select
	// contains filtered or unexported fields
}

DeploySelect is a service and environment selector from the deploy store.

func NewDeploySelect

func NewDeploySelect(prompt Prompter, configStore ConfigLister, deployStore DeployStoreClient) *DeploySelect

NewDeploySelect returns a new selector that chooses services and environments from the deploy store.

func (*DeploySelect) DeployedService

func (s *DeploySelect) DeployedService(prompt, help string, app string, opts ...GetDeployedServiceOpts) (*DeployedService, error)

DeployedService has the user select a deployed service. Callers can provide either a particular environment, a particular service to filter on, or both.

type DeployStoreClient

type DeployStoreClient interface {
	ListDeployedServices(appName string, envName string) ([]string, error)
	ListDeployedJobs(appName, envName string) ([]string, error)
	IsServiceDeployed(appName string, envName string, svcName string) (bool, error)
	IsJobDeployed(appName, envName, jobName string) (bool, error)
}

DeployStoreClient wraps methods of deploy store.

type DeployedService

type DeployedService struct {
	Svc     string
	Env     string
	SvcType string
}

DeployedService contains the service name and environment name of the deployed service.

func (*DeployedService) String

func (s *DeployedService) String() string

type DeployedServiceFilter added in v1.7.0

type DeployedServiceFilter func(*DeployedService) (bool, error)

DeployedServiceFilter determines if a service should be included in the results.

type EC2Select added in v0.3.0

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

EC2Select is a selector for Ec2 resources.

func NewEC2Select added in v0.3.0

func NewEC2Select(prompt Prompter, ec2Client VPCSubnetLister) *EC2Select

NewEC2Select returns a new selector that chooses Ec2 resources.

func (*EC2Select) PrivateSubnets added in v0.3.0

func (s *EC2Select) PrivateSubnets(prompt, help, vpcID string) ([]string, error)

PrivateSubnets has the user multiselect private subnets given the VPC ID.

func (*EC2Select) PublicSubnets added in v0.3.0

func (s *EC2Select) PublicSubnets(prompt, help, vpcID string) ([]string, error)

PublicSubnets has the user multiselect public subnets given the VPC ID.

func (*EC2Select) VPC added in v0.3.0

func (s *EC2Select) VPC(prompt, help string) (string, error)

VPC has the user select an available VPC.

type GetDeployedServiceOpts

type GetDeployedServiceOpts func(*DeploySelect)

GetDeployedServiceOpts sets up optional parameters for GetDeployedServiceOpts function.

func WithEnv

func WithEnv(env string) GetDeployedServiceOpts

WithEnv sets up the env name for DeploySelect.

func WithFilter added in v1.7.0

WithFilter sets up filters for DeploySelect

func WithServiceTypesFilter added in v1.7.0

func WithServiceTypesFilter(svcTypes []string) GetDeployedServiceOpts

WithServiceTypesFilter sets up a ServiceType filter for DeploySelect

func WithSvc

func WithSvc(svc string) GetDeployedServiceOpts

WithSvc sets up the svc name for DeploySelect.

type GetDeployedTaskOpts added in v1.1.0

type GetDeployedTaskOpts func(*CFTaskSelect)

GetDeployedTaskOpts sets up optional parameters for GetDeployedTaskOpts function.

func TaskWithAppEnv added in v1.1.0

func TaskWithAppEnv(app, env string) GetDeployedTaskOpts

TaskWithAppEnv sets up the env name for TaskSelect.

func TaskWithDefaultCluster added in v1.1.0

func TaskWithDefaultCluster() GetDeployedTaskOpts

WithDefaultCluster sets up whether CFTaskSelect should use only the default cluster.

type Names added in v0.3.0

type Names interface {
	Names() []string
}

Names wraps the method that returns a list of names.

type Prompter

type Prompter interface {
	Get(message, help string, validator prompt.ValidatorFunc, promptOpts ...prompt.PromptConfig) (string, error)
	SelectOne(message, help string, options []string, promptOpts ...prompt.PromptConfig) (string, error)
	MultiSelect(message, help string, options []string, promptOpts ...prompt.PromptConfig) ([]string, error)
	Confirm(message, help string, promptOpts ...prompt.PromptConfig) (bool, error)
}

Prompter wraps the methods to ask for inputs from the terminal.

type Select

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

Select prompts users to select the name of an application or environment.

func NewSelect

func NewSelect(prompt Prompter, store ConfigLister) *Select

NewSelect returns a selector that chooses applications or environments.

func (*Select) Application

func (s *Select) Application(prompt, help string, additionalOpts ...string) (string, error)

Application fetches all the apps in an account/region and prompts the user to select one.

func (*Select) Environment

func (s *Select) Environment(prompt, help, app string, additionalOpts ...string) (string, error)

Environment fetches all the environments in an app and prompts the user to select one.

func (*Select) Environments added in v1.1.0

func (s *Select) Environments(prompt, help, app string, finalMsgFunc func(int) prompt.PromptConfig) ([]string, error)

Environments fetches all the environments in an app and prompts the user to select one OR MORE. The List of options decreases as envs are chosen. Chosen envs displayed above with the finalMsg.

type SessionProvider added in v0.3.0

type SessionProvider interface {
	Default() (*session.Session, error)
	FromProfile(name string) (*session.Session, error)
	FromStaticCreds(accessKeyID, secretAccessKey, sessionToken string) (*session.Session, error)
}

SessionProvider wraps the methods to create AWS sessions.

type TaskLister added in v1.1.0

type TaskLister interface {
	ListActiveAppEnvTasks(opts ecs.ListActiveAppEnvTasksOpts) ([]*awsecs.Task, error)
	ListActiveDefaultClusterTasks(filter ecs.ListTasksFilter) ([]*awsecs.Task, error)
}

TaskLister wraps methods of listing tasks.

type TaskOpts added in v1.1.0

type TaskOpts func(*TaskSelect)

TaskOpts sets up optional parameters for Task function.

func WithAppEnv added in v1.1.0

func WithAppEnv(app, env string) TaskOpts

WithAppEnv sets up the app name and env name for TaskSelect.

func WithDefault added in v1.1.0

func WithDefault() TaskOpts

WithDefault uses default cluster for TaskSelect.

func WithTaskGroup added in v1.1.0

func WithTaskGroup(taskGroup string) TaskOpts

WithTaskGroup sets up the task group name for TaskSelect.

func WithTaskID added in v1.1.0

func WithTaskID(id string) TaskOpts

WithTaskID sets up the task ID for TaskSelect.

type TaskSelect added in v1.1.0

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

TaskSelect is a Copilot running task selector.

func NewTaskSelect added in v1.1.0

func NewTaskSelect(prompt Prompter, lister TaskLister) *TaskSelect

NewTaskSelect returns a new selector that chooses a running task.

func (*TaskSelect) RunningTask added in v1.1.0

func (s *TaskSelect) RunningTask(prompt, help string, opts ...TaskOpts) (*awsecs.Task, error)

RunningTask has the user select a running task. Callers can provide either app and env names, or use default cluster.

type TaskStackDescriber added in v1.1.0

type TaskStackDescriber interface {
	ListDefaultTaskStacks() ([]deploy.TaskStackInfo, error)
	ListTaskStacks(appName, envName string) ([]deploy.TaskStackInfo, error)
}

TaskStackDescriber wraps cloudformation client methods to describe task stacks

type VPCSubnetLister added in v0.3.0

type VPCSubnetLister interface {
	ListVPCs() ([]ec2.VPC, error)
	ListVPCSubnets(vpcID string) (*ec2.VPCSubnets, error)
}

VPCSubnetLister list VPCs and subnets.

type WorkspaceRetriever added in v0.5.0

type WorkspaceRetriever interface {
	WsWorkloadLister
	Summary() (*workspace.Summary, error)
	ListDockerfiles() ([]string, error)
}

WorkspaceRetriever wraps methods to get workload names, app names, and Dockerfiles from the workspace.

type WorkspaceSelect

type WorkspaceSelect struct {
	*Select
	// contains filtered or unexported fields
}

WorkspaceSelect is an application and environment selector, but can also choose a service from the workspace.

func NewWorkspaceSelect

func NewWorkspaceSelect(prompt Prompter, store ConfigLister, ws WorkspaceRetriever) *WorkspaceSelect

NewWorkspaceSelect returns a new selector that chooses applications and environments from the config store, but services from the local workspace.

func (*WorkspaceSelect) Dockerfile added in v0.5.0

func (s *WorkspaceSelect) Dockerfile(selPrompt, notFoundPrompt, selHelp, notFoundHelp string, pathValidator prompt.ValidatorFunc) (string, error)

Dockerfile asks the user to select from a list of Dockerfiles in the current directory or one level down. If no dockerfiles are found, it asks for a custom path.

func (*WorkspaceSelect) Job added in v0.5.0

func (s *WorkspaceSelect) Job(msg, help string) (string, error)

Job fetches all jobs in the workspace and then prompts the user to select one.

func (*WorkspaceSelect) Schedule added in v0.5.0

func (s *WorkspaceSelect) Schedule(scheduleTypePrompt, scheduleTypeHelp string, scheduleValidator, rateValidator prompt.ValidatorFunc) (string, error)

Schedule asks the user to select either a rate, preset cron, or custom cron.

func (*WorkspaceSelect) Service

func (s *WorkspaceSelect) Service(msg, help string) (string, error)

Service fetches all services in the workspace and then prompts the user to select one.

func (*WorkspaceSelect) Workload added in v0.6.0

func (s *WorkspaceSelect) Workload(msg, help string) (wl string, err error)

Workload fetches all jobs and services in an app and prompts the user to select one.

type WsWorkloadLister added in v0.5.0

type WsWorkloadLister interface {
	ServiceNames() ([]string, error)
	JobNames() ([]string, error)
	WorkloadNames() ([]string, error)
}

WsWorkloadLister wraps the method to get workloads in current workspace.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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