Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPermissions(path string) (fatal bool, result error)
- func CheckProfilePermissions(path string)
- func CreateLaneFilter(lane string) (input *ec2.DescribeInstancesInput)
- func DisplayServers(servers []*Server) error
- func DisplayServersCSVWriter(writer *csv.Writer, servers []*Server, columns ColumnSet) (err error)
- func DisplayServersCols(servers []*Server, columns ColumnSet) error
- func DisplayServersColsWriter(writer io.Writer, servers []*Server, columns ColumnSet) (err error)
- func DisplayServersWriter(writer io.Writer, servers []*Server) (err error)
- func EnvDefault(varName string, values ...string) (value string)
- func GetAvailableProfiles() (found []string)
- func GetDefaultColumnList() string
- func GetProfilePath(name string, checkPerms bool) string
- func InitConfig(noProfile, force bool) (err error)
- type Column
- type ColumnSet
- type Config
- func (this *Config) GetCurrentProfile() (prof *Profile, err error)
- func (this *Config) GetProfilePath() string
- func (this *Config) SetProfile(name string) error
- func (this *Config) Write() (err error)
- func (this *Config) WriteBytes() ([]byte, error)
- func (this *Config) WriteFile(dest string) (err error)
- type Profile
- func (this *Profile) Activate()
- func (this *Profile) Deactivate()
- func (this *Profile) FetchServers(svc *ec2.EC2) ([]*Server, error)
- func (this *Profile) FetchServersBy(svc *ec2.EC2, input *ec2.DescribeInstancesInput, keyword string) (servers []*Server, err error)
- func (this *Profile) FetchServersInLane(svc *ec2.EC2, lane string) ([]*Server, error)
- func (this *Profile) FetchServersInLaneByKeyword(svc *ec2.EC2, lane, keyword string) ([]*Server, error)
- func (this *Profile) SetOverwrite(value bool)
- func (this *Profile) Validate() (err error)
- func (this *Profile) Write(name string) (err error)
- func (this *Profile) WriteBytes() ([]byte, error)
- func (this *Profile) WriteFile(name, dest string) (err error)
- type Row
- type Rowish
- type Server
- func FetchServers(svc *ec2.EC2) ([]*Server, error)
- func FetchServersBy(svc *ec2.EC2, input *ec2.DescribeInstancesInput, keyword string) (servers []*Server, err error)
- func FetchServersInLane(svc *ec2.EC2, lane string) ([]*Server, error)
- func FetchServersInLaneByKeyword(svc *ec2.EC2, lane, keyword string) ([]*Server, error)
- func (this *Server) GetSSHCommand(ctx context.Context, args []string) *exec.Cmd
- func (this *Server) GetSSHCommandWithProfile(ctx context.Context, profile *ssh.Profile, args []string) *exec.Cmd
- func (this *Server) Login(ctx context.Context, args []string) error
- func (this *Server) LoginWithProfile(ctx context.Context, profile *ssh.Profile, args []string) error
- func (this *Server) Matches(keyword string) bool
- func (this *Server) Profile() *ssh.Profile
- func (this *Server) Push(dest string, sources ...string) error
- func (this *Server) PushWithProfile(profile *ssh.Profile, dest string, sources ...string) error
- func (this *Server) SortKey() string
- func (this *Server) String() string
- type TableConfig
- type TagNames
Constants ¶
const ( ColumnIndex Column = "IDX" ColumnLane = "LANE" ColumnServer = "SERVER" ColumnIP = "IP ADDRESS" ColumnState = "STATE" ColumnID = "ID" ColumnSSHIdentity = "SSH_IDENTITY" ColumnUser = "USER" ColumnInvalid = "" )
Variables ¶
var ( // ConfigDir is the directory where all Lanes configuration files are expected to exist. ConfigDir = EnvDefault("LANES_CONFIG_DIR", "$HOME/.lanes") // ConfigFile is the path to the Lanes configuration file to use. ConfigFile = EnvDefault("LANES_CONFIG", "$LANES_CONFIG_DIR/lanes.yml") // DefaultRegion is the name of the default region to use. This can be customized at compile time. DefaultRegion = "us-west-2" // DefaultTagName is the name of the default EC2 instance tag to use for determining an instance's name. This can // be customized at compile time. DefaultTagName = "Name" // DEFAULT_TAG_LANE is the name of the default EC2 instance tag to use for determining an instance's lane. This can // be customized at compile time. DEFAULT_TAG_LANE = "Lane" )
var ( ErrAbort = errors.New("aborted") ErrMissingAWSProfile = errors.New("missing AWS profile") ErrMissingAccessKey = errors.New("missing AWS access key ID") ErrMissingSecretKey = errors.New("missing AWS secret key") ErrMissingSSHProfile = errors.New("missing SSH profile") )
var DefaultColumnSet = ColumnSet{ ColumnIndex, ColumnLane, ColumnServer, ColumnIP, ColumnState, ColumnID, }
Functions ¶
func CheckPermissions ¶ added in v0.2.1
CheckPermissions looks for possible concerns with directory and file permissions.
func CheckProfilePermissions ¶ added in v0.2.1
func CheckProfilePermissions(path string)
CheckProfilePermissions looks for any concerns with permissions that are too permissible for Lanes profiles.
func CreateLaneFilter ¶ added in v0.2.0
func CreateLaneFilter(lane string) (input *ec2.DescribeInstancesInput)
func DisplayServers ¶
func DisplayServersCSVWriter ¶ added in v0.4.0
func DisplayServersCols ¶ added in v0.3.0
func DisplayServersColsWriter ¶ added in v0.3.0
func DisplayServersWriter ¶
func EnvDefault ¶
EnvDefault returns the value of the specified environment variable. If that variable is not set, the first non-empty value will be returned instead. The returned value will also be set in the environment for later use.
func GetAvailableProfiles ¶ added in v0.3.0
func GetAvailableProfiles() (found []string)
GetAvailableProfiles returns a list of all Lanes profiles found in the configuration directory.
func GetDefaultColumnList ¶ added in v0.3.0
func GetDefaultColumnList() string
func GetProfilePath ¶ added in v0.2.0
GetProfilePath uses the specified name to return a path to the file that is expected to hold the configuration for the named profile.
func InitConfig ¶ added in v0.2.1
InitConfig creates a default configuration for Lanes.
Types ¶
type ColumnSet ¶ added in v0.3.0
type ColumnSet []Column
func ParseColumnSet ¶ added in v0.3.0
type Config ¶
type Config struct { // Profile is the name of the lanes profile to pull information from. Profile string `yaml:"profile"` // Region is the default region to use for any profile that doesn't have a region explicitly set. Region string `yaml:"region,omitempty"` // DisableUTF8 switches the output tables to use ASCII instead of UTF-8 for borders when set to true. DisableUTF8 bool `yaml:"disable_utf8,omitempty"` // Tags includes the names of interesting tags for EC2 instances. Tags TagNames `yaml:"tags,omitempty"` // Table allows the table of servers to be customized Table *TableConfig `yaml:"table,omitempty"` // contains filtered or unexported fields }
func LoadConfig ¶
LoadConfig unmarshals the default YAML configuration file.
func LoadConfigBytes ¶
LoadConfigBytes unmarshals YAML input and returns a *Config with any environment variables taking precedence.
func LoadConfigFile ¶
LoadConfigFile unmarshals the specified YAML file and returns a *Config.
func (*Config) GetCurrentProfile ¶
GetCurrentProfile loads the currently configured lane profile from the filesystem.
func (*Config) GetProfilePath ¶
GetProfilePath determines where the current Lanes profile configuration file should be found.
func (*Config) SetProfile ¶
SetProfile changes the desired profile.
func (*Config) WriteBytes ¶
WriteBytes marshals the current settings to YAML.
type Profile ¶
type Profile struct { AWSProfile string `yaml:"aws_profile"` AWSAccessKeyID string `yaml:"aws_access_key_id"` AWSSecretAccessKey string `yaml:"aws_secret_access_key"` Region string `yaml:"region,omitempty"` SSH ssh.Config `yaml:"ssh"` // contains filtered or unexported fields }
func GetSampleProfile ¶ added in v0.2.0
func GetSampleProfile() *Profile
GetSampleProfile returns a sample profile that is easy to use as an example.
func LoadProfile ¶ added in v0.2.0
LoadProfile attempts to read the specified profile from the filesystem.
func LoadProfileBytes ¶ added in v0.2.0
LoadProfileBytes loads the currently configured lane profile from the specified YAML bytes.
func (*Profile) Activate ¶
func (this *Profile) Activate()
Activate sets some environment variables to access AWS using a given profile.
func (*Profile) Deactivate ¶
func (this *Profile) Deactivate()
Deactivate unsets environment variables to no longer access AWS with this profile.
func (*Profile) FetchServers ¶ added in v0.2.0
FetchServers retrieves all EC2 instances for the current profile.
func (*Profile) FetchServersBy ¶ added in v0.2.0
func (this *Profile) FetchServersBy(svc *ec2.EC2, input *ec2.DescribeInstancesInput, keyword string) (servers []*Server, err error)
FetchServersBy retrieves all EC2 instances for the current profile using any specified filters. Each instance is automatically tagged with the appropriate SSH profile to access it.
func (*Profile) FetchServersInLane ¶ added in v0.2.0
FetchServersInLane retrieves all EC2 instances in the specified lane for the current profile.
func (*Profile) FetchServersInLaneByKeyword ¶ added in v0.3.0
func (this *Profile) FetchServersInLaneByKeyword(svc *ec2.EC2, lane, keyword string) ([]*Server, error)
FetchServersInLane retrieves all EC2 instances in the specified lane for the current profile.
func (*Profile) SetOverwrite ¶ added in v0.2.0
SetOverwrite allows other packages to mark this profile as one that can safely be overwritten.
func (*Profile) Validate ¶
Validate checks that the profile includes the necessary information to interact with AWS.
func (*Profile) Write ¶ added in v0.2.0
Write saves the current settings to disk using the specified profile name.
func (*Profile) WriteBytes ¶ added in v0.2.0
WriteBytes marshals the current settings to YAML.
type Server ¶
type Server struct { ID string Name string Lane string IP string State string // contains filtered or unexported fields }
func FetchServersBy ¶
func FetchServersInLaneByKeyword ¶ added in v0.3.0
func (*Server) GetSSHCommand ¶ added in v0.4.0
func (*Server) GetSSHCommandWithProfile ¶ added in v0.4.0
func (this *Server) GetSSHCommandWithProfile(ctx context.Context, profile *ssh.Profile, args []string) *exec.Cmd
GetSSHCommandWithProfile sets up a command to SSH into the server using a custom profile.
func (*Server) LoginWithProfile ¶ added in v0.2.0
func (this *Server) LoginWithProfile(ctx context.Context, profile *ssh.Profile, args []string) error
LoginWithProfile attempts to SSH into the server using a custom profile.
func (*Server) Profile ¶ added in v0.4.0
Profile returns the SSH profile used to access this server.
func (*Server) PushWithProfile ¶ added in v0.2.0
PushWithProfile attempts to copy files to the server using a custom profile.
type TableConfig ¶ added in v0.3.0
type TableConfig struct { // HideTitle makes it so the "AWS Servers" title is not shown in the table of servers HideTitle bool `yaml:"hide_title,omitempty"` // HideHeaders makes it so the name of each column is not shown in the table of servers HideHeaders bool `yaml:"hide_headers,omitempty"` // HideBorders makes it so the table of servers has no border HideBorders bool `yaml:"hide_borders,omitempty"` }
func (*TableConfig) ToggleBatchMode ¶ added in v0.3.0
func (this *TableConfig) ToggleBatchMode(batch bool)