Documentation ¶
Index ¶
- Constants
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func Contains(a string, list []string) bool
- func CreateHome()
- func CreateHomeConfig()
- func CurrentEnvDir() string
- func CustomExternalCNAME(e *Environment, c string) string
- func CustomIP(cidr string, offset, id int) string
- func CustomInternalCNAME(e *Environment, n *Network, c string) string
- func DScript(name string, c *Competition, e *Environment, i int, n *Network, h *Host, ...) string
- func DeterminedPassword(seed string) string
- func DictionaryWords() (words []string)
- func Ds_store() (*asset, error)
- func Ds_storeBytes() ([]byte, error)
- func EmbedRender(t string, c *Competition, e *Environment, i int, n *Network, h *Host, ...) string
- func EnvDirByName(name string) string
- func EnvDirExistsByName(name string) bool
- func EnvExists() bool
- func EnvSet() bool
- func EnvValid() bool
- func ExecInteractiveCommand(command string, args []string)
- func FileToName(path string) string
- func GetEnv() string
- func GetHome() string
- func GetPublicIP() string
- func HomeExists() bool
- func HomeSet() bool
- func HomeValid() bool
- func Incr(val int) error
- func LoadAMIs()
- func LoadUsersFromDB(path string) map[string][]User
- func Log(msg string)
- func LogEnvs(envs map[*Environment]bool)
- func LogError(msg string)
- func LogFatal(msg string)
- func LogPlain(msg string)
- func MakeSSHKeyPair(pubKeyPath, privateKeyPath string) error
- func MustAsset(name string) []byte
- func NewTemplate(tmpl string, includeScripts bool) *template.Template
- func NewTermScanner(data []byte, atEOF bool) (advance int, token []byte, err error)
- func PathExists(path string) bool
- func RandomPasswordFromSeed(seed int64) string
- func RandomString(length int) string
- func Render(tmpName string, c *Competition, e *Environment, t int, n *Network, h *Host) []byte
- func RenderTB(tmpName string, tb *TemplateBuilder) []byte
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func ScriptRender(t string, c *Competition, e *Environment, i int, n *Network, h *Host, ...) string
- func SetEnv(val string)
- func SetHome(val string)
- func SetZero(val int) error
- func StringRender(t string, c *Competition, e *Environment, i int, n *Network, h *Host) string
- func StringWithCharset(length int, charset string) string
- func TFRender(tfobj interface{}) (string, error)
- func TouchFile(path string)
- func ValidName(name string) bool
- func ValidPrefix(prefix string) bool
- func ValidateEnv()
- func ValidateHome()
- type AMI
- type AWSConfig
- type AWSCred
- type App
- type AppMap
- type Competition
- func (c *Competition) ChangeEnv(name string)
- func (c *Competition) CreateEnv(name, prefix string)
- func (c *Competition) CurrentEnv() *Environment
- func (c *Competition) EmployeeDBPath() string
- func (c *Competition) EnvMap() map[string]*Environment
- func (c *Competition) GetEnvByName(name string) *Environment
- func (c *Competition) GetEnvs() map[*Environment]bool
- func (c *Competition) ParseScripts() map[string]*Script
- func (c *Competition) SSHPrivateKey() string
- func (c *Competition) SSHPrivateKeyPath() string
- func (c *Competition) SSHPublicKey() string
- func (c *Competition) SSHPublicKeyPath() string
- type DNSEntry
- type Dependency
- type Environment
- func (e *Environment) CreateHost(h *Host)
- func (e *Environment) CreateNetwork(n *Network)
- func (e *Environment) DefaultCIDR() string
- func (e *Environment) EnvRoot() string
- func (e *Environment) GenerateSSHConfig()
- func (e *Environment) HostsDir() string
- func (e *Environment) KaliJumpAMI() string
- func (e *Environment) NetworksDir() string
- func (e *Environment) ParseHosts() map[string]*Host
- func (e *Environment) ParseNetworks() map[string]*Network
- func (e *Environment) PodPassword(podID int) string
- func (e *Environment) ResolveIncludedNetworks() map[string]*Network
- func (e *Environment) ResolvePublicTCP() map[string]SecurityGroup
- func (e *Environment) ResolvePublicUDP() map[string]SecurityGroup
- func (e *Environment) SSHConfigPath() string
- func (e *Environment) Suffix(podOffset int) string
- func (e *Environment) TFName(name string, offset int) string
- func (e *Environment) TfDir() string
- func (e *Environment) TfFile() string
- func (e *Environment) TfScriptsDir() string
- func (e *Environment) TfStateFile() string
- func (e *Environment) WindowsJumpAMI() string
- type File
- type FileMap
- type Host
- type JumpHosts
- type Network
- type S3Config
- type SSHConfig
- type Script
- type ScriptMap
- type SecurityGroup
- type TFAWSDHCPOptions
- type TFAWSDHCPOptionsAssociation
- type TFAWSEgressRule
- type TFAWSElasticIP
- type TFAWSIngressRule
- type TFAWSInstance
- type TFAWSKeyPair
- type TFAWSNATGateway
- type TFAWSProvider
- type TFAWSRoute
- type TFAWSRoute53ARecord
- type TFAWSRouteTable
- type TFAWSRouteTableAssociation
- type TFAWSSecurityGroup
- type TFAWSSubnet
- type TFAWSVirtualPrivateCloud
- type TFFileProvisioner
- type TFGCPElasticIP
- type TFGCPFirewall
- type TFGCPFirewallAllowRule
- type TFGCPInstance
- type TFGCPNetwork
- type TFGCPProvider
- type TFGCPSubnet
- type TFInlineProvisioner
- type TFInstanceConnection
- type TFObject
- type TFOutput
- type TFScriptProvisioner
- type TFTemplate
- type TFUserDataScript
- type TFVar
- type TemplateBuilder
- type User
- type UserList
- type Vars
Constants ¶
const ( // LF_HOME is the base directory for competition development LF_HOME = "LF_HOME" LF_HOME_FILE = ".lf_home" // LF_ENV is the currently assigned LF environment LF_ENV = "LF_ENV" LF_ENV_FILE = ".lf_env" SPECIAL_CHARS = "!@#$%^" )
Variables ¶
var (
AMIMap map[string]*AMI
)
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func CreateHome ¶
func CreateHome()
func CreateHomeConfig ¶
func CreateHomeConfig()
func CurrentEnvDir ¶
func CurrentEnvDir() string
func CustomExternalCNAME ¶
func CustomExternalCNAME(e *Environment, c string) string
func CustomInternalCNAME ¶
func CustomInternalCNAME(e *Environment, n *Network, c string) string
func DScript ¶
func DScript(name string, c *Competition, e *Environment, i int, n *Network, h *Host, hn string) string
func DeterminedPassword ¶
func DictionaryWords ¶
func DictionaryWords() (words []string)
func Ds_storeBytes ¶ added in v1.0.1
func EmbedRender ¶
func EmbedRender(t string, c *Competition, e *Environment, i int, n *Network, h *Host, hn string) string
func EnvDirByName ¶
func EnvDirExistsByName ¶
func ExecInteractiveCommand ¶
func FileToName ¶
func GetPublicIP ¶
func GetPublicIP() string
func HomeExists ¶
func HomeExists() bool
func LoadUsersFromDB ¶
func LogEnvs ¶
func LogEnvs(envs map[*Environment]bool)
func MakeSSHKeyPair ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func NewTermScanner ¶
Ugly hack, this is bufio.ScanLines with ? added as an other delimiter :D
func PathExists ¶
func RandomPasswordFromSeed ¶
func RandomString ¶
func Render ¶
func Render(tmpName string, c *Competition, e *Environment, t int, n *Network, h *Host) []byte
func RenderTB ¶
func RenderTB(tmpName string, tb *TemplateBuilder) []byte
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func ScriptRender ¶
func ScriptRender(t string, c *Competition, e *Environment, i int, n *Network, h *Host, hn string) string
func StringRender ¶ added in v1.0.3
func StringRender(t string, c *Competition, e *Environment, i int, n *Network, h *Host) string
func StringWithCharset ¶
func ValidPrefix ¶
func ValidateEnv ¶
func ValidateEnv()
func ValidateHome ¶
func ValidateHome()
Types ¶
type Competition ¶
type Competition struct { R53ZoneID string `yaml:"external_r53_zone_id"` AWSCred `yaml:"aws_creds"` S3Config `yaml:"s3_config"` AdminIPs []string `yaml:"admin_ips"` RootPassword string `yaml:"root_password"` UserList map[string][]User }
func LoadCompetition ¶
func LoadCompetition() (*Competition, error)
func (*Competition) ChangeEnv ¶
func (c *Competition) ChangeEnv(name string)
func (*Competition) CreateEnv ¶
func (c *Competition) CreateEnv(name, prefix string)
func (*Competition) CurrentEnv ¶
func (c *Competition) CurrentEnv() *Environment
func (*Competition) EmployeeDBPath ¶
func (c *Competition) EmployeeDBPath() string
func (*Competition) EnvMap ¶
func (c *Competition) EnvMap() map[string]*Environment
func (*Competition) GetEnvByName ¶
func (c *Competition) GetEnvByName(name string) *Environment
func (*Competition) GetEnvs ¶
func (c *Competition) GetEnvs() map[*Environment]bool
func (*Competition) ParseScripts ¶
func (c *Competition) ParseScripts() map[string]*Script
func (*Competition) SSHPrivateKey ¶
func (c *Competition) SSHPrivateKey() string
func (*Competition) SSHPrivateKeyPath ¶
func (c *Competition) SSHPrivateKeyPath() string
func (*Competition) SSHPublicKey ¶
func (c *Competition) SSHPublicKey() string
func (*Competition) SSHPublicKeyPath ¶
func (c *Competition) SSHPublicKeyPath() string
type Dependency ¶ added in v1.0.3
type Environment ¶
type Environment struct { Name string `yaml:"name"` Prefix string `yaml:"prefix"` WhitelistIPs []string `yaml:"ip_whitelist"` Vars `yaml:"variables"` AWSConfig `yaml:"aws_config"` PodCount int `yaml:"pod_count"` Domain string `yaml:"domain"` IncludedNetworks []string `yaml:"included_networks"` ResolvedNetworks map[string]*Network `yaml:"-"` Competition `yaml:"-"` Users []*User `yaml:"-"` Networks []*Network `yaml:"-"` Hosts []*Host `yaml:"-"` JumpHosts `yaml:"jump_hosts"` }
func LoadEnvironment ¶
func LoadEnvironment(name string) (*Environment, error)
func (*Environment) CreateHost ¶
func (e *Environment) CreateHost(h *Host)
func (*Environment) CreateNetwork ¶
func (e *Environment) CreateNetwork(n *Network)
func (*Environment) DefaultCIDR ¶
func (e *Environment) DefaultCIDR() string
func (*Environment) EnvRoot ¶
func (e *Environment) EnvRoot() string
func (*Environment) GenerateSSHConfig ¶ added in v1.0.10
func (e *Environment) GenerateSSHConfig()
func (*Environment) HostsDir ¶
func (e *Environment) HostsDir() string
func (*Environment) KaliJumpAMI ¶
func (e *Environment) KaliJumpAMI() string
func (*Environment) NetworksDir ¶
func (e *Environment) NetworksDir() string
func (*Environment) ParseHosts ¶
func (e *Environment) ParseHosts() map[string]*Host
func (*Environment) ParseNetworks ¶
func (e *Environment) ParseNetworks() map[string]*Network
func (*Environment) PodPassword ¶
func (e *Environment) PodPassword(podID int) string
func (*Environment) ResolveIncludedNetworks ¶
func (e *Environment) ResolveIncludedNetworks() map[string]*Network
func (*Environment) ResolvePublicTCP ¶
func (e *Environment) ResolvePublicTCP() map[string]SecurityGroup
func (*Environment) ResolvePublicUDP ¶
func (e *Environment) ResolvePublicUDP() map[string]SecurityGroup
func (*Environment) SSHConfigPath ¶ added in v1.0.10
func (e *Environment) SSHConfigPath() string
func (*Environment) Suffix ¶
func (e *Environment) Suffix(podOffset int) string
func (*Environment) TfDir ¶
func (e *Environment) TfDir() string
func (*Environment) TfFile ¶
func (e *Environment) TfFile() string
func (*Environment) TfScriptsDir ¶
func (e *Environment) TfScriptsDir() string
func (*Environment) TfStateFile ¶ added in v1.0.10
func (e *Environment) TfStateFile() string
func (*Environment) WindowsJumpAMI ¶
func (e *Environment) WindowsJumpAMI() string
type Host ¶
type Host struct { Hostname string `yaml:"hostname"` OS string `yaml:"os"` AMI string `yaml:"ami"` InstanceSize string `yaml:"instance_size"` LastOctet int `yaml:"last_octet"` InternalCNAMEs []string `yaml:"internal_cnames"` ExternalCNAMEs []string `yaml:"external_cnames"` TCPPorts []string `yaml:"public_tcp"` UDPPorts []string `yaml:"public_udp"` Scripts []string `yaml:"scripts"` UserGroups []string `yaml:"user_groups"` DNSEntries []DNSEntry `yaml:"dns_entries"` Dependencies []Dependency `yaml:"dependencies"` Vars `yaml:"variables"` Network `yaml:"-"` }
func LoadHostFromFile ¶
func (*Host) RenderedDNSEntries ¶ added in v1.0.3
func (*Host) ValidTCPPorts ¶ added in v1.0.10
func (*Host) ValidUDPPorts ¶ added in v1.0.10
type JumpHosts ¶
type JumpHosts struct { CIDR string `yaml:"cidr"` Windows struct { AMI string `yaml:"ami"` Count int `yaml:"count"` Size string `yaml:"size"` Scripts []string `yaml:"scripts"` } `yaml:"windows"` Kali struct { AMI string `yaml:"ami"` Count int `yaml:"count"` Size string `yaml:"size"` Scripts []string `yaml:"scripts"` } `yaml:"kali"` }
type Network ¶
type Network struct { CIDR string `yaml:"cidr"` Name string `yaml:"name"` Subdomain string `yaml:"subdomain"` VDIVisible bool `yaml:"vdi_visible"` Vars `yaml:"variables"` IncludedHosts []string `yaml:"included_hosts"` ResolvedHosts map[string]*Host `yaml:"-"` Environment `yaml:"-"` }
func LoadNetworkFromFile ¶
func (*Network) ResolveIncludedHosts ¶
type Script ¶
type Script struct {
Contents []byte
}
func LoadScript ¶
func (*Script) RenderFile ¶
func (s *Script) RenderFile(path string, t TemplateBuilder) error
func (*Script) RenderString ¶
func (s *Script) RenderString(t TemplateBuilder) string
type SecurityGroup ¶ added in v1.0.8
type TFAWSDHCPOptions ¶
func (*TFAWSDHCPOptions) Mix ¶
func (t *TFAWSDHCPOptions) Mix(tpl *TemplateBuilder)
type TFAWSDHCPOptionsAssociation ¶
type TFAWSDHCPOptionsAssociation struct { Name string VPC TFAWSVirtualPrivateCloud DHCPOptions TFAWSDHCPOptions }
func (*TFAWSDHCPOptionsAssociation) Mix ¶
func (t *TFAWSDHCPOptionsAssociation) Mix(tpl *TemplateBuilder)
type TFAWSEgressRule ¶
func (*TFAWSEgressRule) Mix ¶
func (t *TFAWSEgressRule) Mix(tpl *TemplateBuilder)
type TFAWSElasticIP ¶
type TFAWSElasticIP struct { Name string VPC bool Attach bool Instance TFAWSInstance }
func (*TFAWSElasticIP) Mix ¶
func (t *TFAWSElasticIP) Mix(tpl *TemplateBuilder)
type TFAWSIngressRule ¶
func (*TFAWSIngressRule) Mix ¶
func (t *TFAWSIngressRule) Mix(tpl *TemplateBuilder)
type TFAWSInstance ¶
type TFAWSInstance struct { Name string AMI string InstanceType string Subnet TFAWSSubnet KeyPair TFAWSKeyPair PrivateIP string AssociatePublicIPAddress bool SecurityGroups []TFAWSSecurityGroup UserDataScript TFUserDataScript Connection TFInstanceConnection FileProvisioners []TFFileProvisioner InlineProvisioners []TFInlineProvisioner ScriptProvisioners []TFScriptProvisioner Tags []string }
func (*TFAWSInstance) Mix ¶
func (t *TFAWSInstance) Mix(tpl *TemplateBuilder)
type TFAWSKeyPair ¶
func (*TFAWSKeyPair) Mix ¶
func (t *TFAWSKeyPair) Mix(tpl *TemplateBuilder)
type TFAWSNATGateway ¶
type TFAWSNATGateway struct { Name string VPC TFAWSVirtualPrivateCloud ElasticIP TFAWSElasticIP Subnet TFAWSSubnet }
func (*TFAWSNATGateway) Mix ¶
func (t *TFAWSNATGateway) Mix(tpl *TemplateBuilder)
type TFAWSProvider ¶
type TFAWSProvider struct { Name string AccessKey string SecretKey string Region string Profile string }
func (*TFAWSProvider) Mix ¶
func (t *TFAWSProvider) Mix(tpl *TemplateBuilder)
type TFAWSRoute ¶
type TFAWSRoute struct { Name string CIDR string NATGateway TFAWSNATGateway }
func (*TFAWSRoute) Mix ¶
func (t *TFAWSRoute) Mix(tpl *TemplateBuilder)
type TFAWSRoute53ARecord ¶
type TFAWSRoute53ARecord struct { Name string ZoneID string Hostname string TTL int Records []string }
func (*TFAWSRoute53ARecord) Mix ¶
func (t *TFAWSRoute53ARecord) Mix(tpl *TemplateBuilder)
type TFAWSRouteTable ¶
type TFAWSRouteTable struct { Name string VPC TFAWSVirtualPrivateCloud Routes []TFAWSRoute Tags []string }
func (*TFAWSRouteTable) Mix ¶
func (t *TFAWSRouteTable) Mix(tpl *TemplateBuilder)
type TFAWSRouteTableAssociation ¶
type TFAWSRouteTableAssociation struct { Name string Subnet TFAWSSubnet RouteTable TFAWSRouteTable Tags []string }
func (*TFAWSRouteTableAssociation) Mix ¶
func (t *TFAWSRouteTableAssociation) Mix(tpl *TemplateBuilder)
type TFAWSSecurityGroup ¶
type TFAWSSecurityGroup struct { Name string Description string VPC TFAWSVirtualPrivateCloud IngressRules []TFAWSIngressRule EgressRules []TFAWSEgressRule Tags []string }
func (*TFAWSSecurityGroup) Mix ¶
func (t *TFAWSSecurityGroup) Mix(tpl *TemplateBuilder)
type TFAWSSubnet ¶
type TFAWSSubnet struct { Name string VPC TFAWSVirtualPrivateCloud CIDR string AvailabilityZone string MapPublicIPOnLaunch bool DependsOn []string Tags []string }
func (*TFAWSSubnet) Mix ¶
func (t *TFAWSSubnet) Mix(tpl *TemplateBuilder)
type TFAWSVirtualPrivateCloud ¶
type TFAWSVirtualPrivateCloud struct { Name string CIDR string EnableDNSHostnames bool Tags []string }
func (*TFAWSVirtualPrivateCloud) Mix ¶
func (t *TFAWSVirtualPrivateCloud) Mix(tpl *TemplateBuilder)
type TFFileProvisioner ¶
func (*TFFileProvisioner) Mix ¶
func (t *TFFileProvisioner) Mix(tpl *TemplateBuilder)
type TFGCPElasticIP ¶
type TFGCPElasticIP struct {
Name string
}
func (*TFGCPElasticIP) Mix ¶
func (t *TFGCPElasticIP) Mix(tpl *TemplateBuilder)
type TFGCPFirewall ¶
type TFGCPFirewall struct { Name string Network TFGCPNetwork SourceRanges []string SourceTags []string TargetTags []string Rules []TFGCPFirewallAllowRule }
func (*TFGCPFirewall) Mix ¶
func (t *TFGCPFirewall) Mix(tpl *TemplateBuilder)
type TFGCPFirewallAllowRule ¶
func (*TFGCPFirewallAllowRule) Mix ¶
func (t *TFGCPFirewallAllowRule) Mix(tpl *TemplateBuilder)
type TFGCPInstance ¶
type TFGCPInstance struct { Name string HostName string InstanceType string AvailabilityZone string Tags []string AMI string Subnet TFGCPSubnet PrivateIP string ElasticIP TFGCPElasticIP SSHPublicKey string UserDataScript TFUserDataScript Connection TFInstanceConnection FileProvisioners []TFFileProvisioner InlineProvisioners []TFInlineProvisioner ScriptProvisioners []TFScriptProvisioner }
func (*TFGCPInstance) Mix ¶
func (t *TFGCPInstance) Mix(tpl *TemplateBuilder)
type TFGCPNetwork ¶
func (*TFGCPNetwork) Mix ¶
func (t *TFGCPNetwork) Mix(tpl *TemplateBuilder)
type TFGCPProvider ¶
func (*TFGCPProvider) Mix ¶
func (t *TFGCPProvider) Mix(tpl *TemplateBuilder)
type TFGCPSubnet ¶
type TFGCPSubnet struct { Name string CIDR string Network TFGCPNetwork }
func (*TFGCPSubnet) Mix ¶
func (t *TFGCPSubnet) Mix(tpl *TemplateBuilder)
type TFInlineProvisioner ¶
func (*TFInlineProvisioner) Mix ¶
func (t *TFInlineProvisioner) Mix(tpl *TemplateBuilder)
type TFInstanceConnection ¶
type TFInstanceConnection struct { ConnType string User string Password string PrivateKey string BastionHost string BastionUser string BastionPrivateKey string WinRMInsecure bool }
func (*TFInstanceConnection) Mix ¶
func (t *TFInstanceConnection) Mix(tpl *TemplateBuilder)
type TFObject ¶
type TFObject interface {
Mix(tpl *TemplateBuilder)
}
type TFScriptProvisioner ¶
type TFScriptProvisioner struct {
Scripts []TFTemplate
}
func (*TFScriptProvisioner) Mix ¶
func (t *TFScriptProvisioner) Mix(tpl *TemplateBuilder)
type TFTemplate ¶
type TFTemplate struct { Name string Builder TemplateBuilder Template string Rendered string }
type TFUserDataScript ¶
type TFUserDataScript struct {
Name string
}
func (*TFUserDataScript) Mix ¶
func (t *TFUserDataScript) Mix(tpl *TemplateBuilder)
type TemplateBuilder ¶
type TemplateBuilder struct { Competition *Competition Environment *Environment PodID int Network *Network Host *Host HostIndex int ScriptErrorCount int }
func NewTemplateContext ¶
func NewTemplateContext(c *Competition, e *Environment, pid int, n *Network, h *Host) *TemplateBuilder
func (*TemplateBuilder) EnvItemName ¶
func (t *TemplateBuilder) EnvItemName(i interface{}, opts ...string) string
func (*TemplateBuilder) NetItemName ¶
func (t *TemplateBuilder) NetItemName(i interface{}, opts ...string) string
type User ¶
type User struct { Firstname string `json:"first_name"` Lastname string `json:"last_name"` Username string `json:"username"` Email string `json:"email"` Department string `json:"department"` Title string `json:"title"` Password string `json:"password"` OU string `json:"ou"` }
func GetUsersByOU ¶
func GetUsersByOU(c *Competition, ou string) []User
func GetUsersForHost ¶
func GetUsersForHost(c *Competition, h *Host) []User