id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
165,100
hashicorp/packer
helper/ssh/key_pair.go
authorizedKeysLine
func authorizedKeysLine(key gossh.PublicKey, comment string) []byte { marshaledPublicKey := gossh.MarshalAuthorizedKey(key) // Remove the mandatory unix new line. Awful, but the go // ssh library automatically appends a unix new line. // We remove it so a key comment can be safely appended to the // end of the st...
go
func authorizedKeysLine(key gossh.PublicKey, comment string) []byte { marshaledPublicKey := gossh.MarshalAuthorizedKey(key) // Remove the mandatory unix new line. Awful, but the go // ssh library automatically appends a unix new line. // We remove it so a key comment can be safely appended to the // end of the st...
[ "func", "authorizedKeysLine", "(", "key", "gossh", ".", "PublicKey", ",", "comment", "string", ")", "[", "]", "byte", "{", "marshaledPublicKey", ":=", "gossh", ".", "MarshalAuthorizedKey", "(", "key", ")", "\n\n", "// Remove the mandatory unix new line. Awful, but the...
// authorizedKeysLine serializes key for inclusion in an OpenSSH // authorized_keys file. The return value ends without newline so // a comment can be appended to the end.
[ "authorizedKeysLine", "serializes", "key", "for", "inclusion", "in", "an", "OpenSSH", "authorized_keys", "file", ".", "The", "return", "value", "ends", "without", "newline", "so", "a", "comment", "can", "be", "appended", "to", "the", "end", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/helper/ssh/key_pair.go#L243-L258
165,101
hashicorp/packer
template/template.go
Raw
func (t *Template) Raw() (*rawTemplate, error) { var out rawTemplate out.MinVersion = t.MinVersion out.Description = t.Description for k, v := range t.Comments { out.Comments = append(out.Comments, map[string]string{k: v}) } for _, b := range t.Builders { out.Builders = append(out.Builders, b) } for _, ...
go
func (t *Template) Raw() (*rawTemplate, error) { var out rawTemplate out.MinVersion = t.MinVersion out.Description = t.Description for k, v := range t.Comments { out.Comments = append(out.Comments, map[string]string{k: v}) } for _, b := range t.Builders { out.Builders = append(out.Builders, b) } for _, ...
[ "func", "(", "t", "*", "Template", ")", "Raw", "(", ")", "(", "*", "rawTemplate", ",", "error", ")", "{", "var", "out", "rawTemplate", "\n\n", "out", ".", "MinVersion", "=", "t", ".", "MinVersion", "\n", "out", ".", "Description", "=", "t", ".", "D...
// Raw converts a Template struct back into the raw Packer template structure
[ "Raw", "converts", "a", "Template", "struct", "back", "into", "the", "raw", "Packer", "template", "structure" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/template.go#L35-L79
165,102
hashicorp/packer
template/template.go
MarshalJSON
func (b *Builder) MarshalJSON() ([]byte, error) { // Avoid recursion type Builder_ Builder out, _ := json.Marshal(Builder_(*b)) var m map[string]json.RawMessage _ = json.Unmarshal(out, &m) // Flatten Config delete(m, "config") for k, v := range b.Config { out, _ = json.Marshal(v) m[k] = out } return js...
go
func (b *Builder) MarshalJSON() ([]byte, error) { // Avoid recursion type Builder_ Builder out, _ := json.Marshal(Builder_(*b)) var m map[string]json.RawMessage _ = json.Unmarshal(out, &m) // Flatten Config delete(m, "config") for k, v := range b.Config { out, _ = json.Marshal(v) m[k] = out } return js...
[ "func", "(", "b", "*", "Builder", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Avoid recursion", "type", "Builder_", "Builder", "\n", "out", ",", "_", ":=", "json", ".", "Marshal", "(", "Builder_", "(", "*", "b", ...
// MarshalJSON conducts the necessary flattening of the Builder struct // to provide valid Packer template JSON
[ "MarshalJSON", "conducts", "the", "necessary", "flattening", "of", "the", "Builder", "struct", "to", "provide", "valid", "Packer", "template", "JSON" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/template.go#L90-L106
165,103
hashicorp/packer
template/template.go
MarshalJSON
func (p *PostProcessor) MarshalJSON() ([]byte, error) { // Early exit for simple definitions if len(p.Config) == 0 && len(p.OnlyExcept.Only) == 0 && len(p.OnlyExcept.Except) == 0 && p.KeepInputArtifact == nil { return json.Marshal(p.Type) } // Avoid recursion type PostProcessor_ PostProcessor out, _ := json.Ma...
go
func (p *PostProcessor) MarshalJSON() ([]byte, error) { // Early exit for simple definitions if len(p.Config) == 0 && len(p.OnlyExcept.Only) == 0 && len(p.OnlyExcept.Except) == 0 && p.KeepInputArtifact == nil { return json.Marshal(p.Type) } // Avoid recursion type PostProcessor_ PostProcessor out, _ := json.Ma...
[ "func", "(", "p", "*", "PostProcessor", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Early exit for simple definitions", "if", "len", "(", "p", ".", "Config", ")", "==", "0", "&&", "len", "(", "p", ".", "OnlyExcept",...
// MarshalJSON conducts the necessary flattening of the PostProcessor struct // to provide valid Packer template JSON
[ "MarshalJSON", "conducts", "the", "necessary", "flattening", "of", "the", "PostProcessor", "struct", "to", "provide", "valid", "Packer", "template", "JSON" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/template.go#L120-L141
165,104
hashicorp/packer
template/template.go
MarshalJSON
func (p *Provisioner) MarshalJSON() ([]byte, error) { // Avoid recursion type Provisioner_ Provisioner out, _ := json.Marshal(Provisioner_(*p)) var m map[string]json.RawMessage _ = json.Unmarshal(out, &m) // Flatten Config delete(m, "config") for k, v := range p.Config { out, _ = json.Marshal(v) m[k] = ou...
go
func (p *Provisioner) MarshalJSON() ([]byte, error) { // Avoid recursion type Provisioner_ Provisioner out, _ := json.Marshal(Provisioner_(*p)) var m map[string]json.RawMessage _ = json.Unmarshal(out, &m) // Flatten Config delete(m, "config") for k, v := range p.Config { out, _ = json.Marshal(v) m[k] = ou...
[ "func", "(", "p", "*", "Provisioner", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Avoid recursion", "type", "Provisioner_", "Provisioner", "\n", "out", ",", "_", ":=", "json", ".", "Marshal", "(", "Provisioner_", "(",...
// MarshalJSON conducts the necessary flattening of the Provisioner struct // to provide valid Packer template JSON
[ "MarshalJSON", "conducts", "the", "necessary", "flattening", "of", "the", "Provisioner", "struct", "to", "provide", "valid", "Packer", "template", "JSON" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/template.go#L156-L172
165,105
hashicorp/packer
template/template.go
Skip
func (o *OnlyExcept) Skip(n string) bool { if len(o.Only) > 0 { for _, v := range o.Only { if v == n { return false } } return true } if len(o.Except) > 0 { for _, v := range o.Except { if v == n { return true } } return false } return false }
go
func (o *OnlyExcept) Skip(n string) bool { if len(o.Only) > 0 { for _, v := range o.Only { if v == n { return false } } return true } if len(o.Except) > 0 { for _, v := range o.Except { if v == n { return true } } return false } return false }
[ "func", "(", "o", "*", "OnlyExcept", ")", "Skip", "(", "n", "string", ")", "bool", "{", "if", "len", "(", "o", ".", "Only", ")", ">", "0", "{", "for", "_", ",", "v", ":=", "range", "o", ".", "Only", "{", "if", "v", "==", "n", "{", "return",...
// Skip says whether or not to skip the build with the given name.
[ "Skip", "says", "whether", "or", "not", "to", "skip", "the", "build", "with", "the", "given", "name", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/template.go#L264-L286
165,106
hashicorp/packer
template/template.go
Validate
func (o *OnlyExcept) Validate(t *Template) error { if len(o.Only) > 0 && len(o.Except) > 0 { return errors.New("only one of 'only' or 'except' may be specified") } var err error for _, n := range o.Only { if _, ok := t.Builders[n]; !ok { err = multierror.Append(err, fmt.Errorf( "'only' specified builder...
go
func (o *OnlyExcept) Validate(t *Template) error { if len(o.Only) > 0 && len(o.Except) > 0 { return errors.New("only one of 'only' or 'except' may be specified") } var err error for _, n := range o.Only { if _, ok := t.Builders[n]; !ok { err = multierror.Append(err, fmt.Errorf( "'only' specified builder...
[ "func", "(", "o", "*", "OnlyExcept", ")", "Validate", "(", "t", "*", "Template", ")", "error", "{", "if", "len", "(", "o", ".", "Only", ")", ">", "0", "&&", "len", "(", "o", ".", "Except", ")", ">", "0", "{", "return", "errors", ".", "New", "...
// Validate validates that the OnlyExcept settings are correct for a thing.
[ "Validate", "validates", "that", "the", "OnlyExcept", "settings", "are", "correct", "for", "a", "thing", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/template.go#L289-L309
165,107
hashicorp/packer
builder/vmware/iso/config.go
validateVMXTemplatePath
func (c *Config) validateVMXTemplatePath() error { f, err := os.Open(c.VMXTemplatePath) if err != nil { return err } defer f.Close() data, err := ioutil.ReadAll(f) if err != nil { return err } return interpolate.Validate(string(data), &c.ctx) }
go
func (c *Config) validateVMXTemplatePath() error { f, err := os.Open(c.VMXTemplatePath) if err != nil { return err } defer f.Close() data, err := ioutil.ReadAll(f) if err != nil { return err } return interpolate.Validate(string(data), &c.ctx) }
[ "func", "(", "c", "*", "Config", ")", "validateVMXTemplatePath", "(", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "c", ".", "VMXTemplatePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer"...
// Make sure custom vmx template exists and that data can be read from it
[ "Make", "sure", "custom", "vmx", "template", "exists", "and", "that", "data", "can", "be", "read", "from", "it" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/iso/config.go#L245-L258
165,108
hashicorp/packer
post-processor/vagrant/util.go
CopyContents
func CopyContents(dst, src string) error { srcF, err := os.Open(src) if err != nil { return err } defer srcF.Close() dstDir, _ := filepath.Split(dst) if dstDir != "" { err := os.MkdirAll(dstDir, 0755) if err != nil { return err } } dstF, err := os.Create(dst) if err != nil { return err } defer...
go
func CopyContents(dst, src string) error { srcF, err := os.Open(src) if err != nil { return err } defer srcF.Close() dstDir, _ := filepath.Split(dst) if dstDir != "" { err := os.MkdirAll(dstDir, 0755) if err != nil { return err } } dstF, err := os.Create(dst) if err != nil { return err } defer...
[ "func", "CopyContents", "(", "dst", ",", "src", "string", ")", "error", "{", "srcF", ",", "err", ":=", "os", ".", "Open", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "srcF", ".", "Close", "(", ...
// Copies a file by copying the contents of the file to another place.
[ "Copies", "a", "file", "by", "copying", "the", "contents", "of", "the", "file", "to", "another", "place", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/post-processor/vagrant/util.go#L26-L52
165,109
hashicorp/packer
post-processor/vagrant/util.go
DirToBox
func DirToBox(dst, dir string, ui packer.Ui, level int) error { log.Printf("Turning dir into box: %s => %s", dir, dst) // Make the containing directory, if it does not already exist err := os.MkdirAll(filepath.Dir(dst), 0755) if err != nil { return err } dstF, err := os.Create(dst) if err != nil { return e...
go
func DirToBox(dst, dir string, ui packer.Ui, level int) error { log.Printf("Turning dir into box: %s => %s", dir, dst) // Make the containing directory, if it does not already exist err := os.MkdirAll(filepath.Dir(dst), 0755) if err != nil { return err } dstF, err := os.Create(dst) if err != nil { return e...
[ "func", "DirToBox", "(", "dst", ",", "dir", "string", ",", "ui", "packer", ".", "Ui", ",", "level", "int", ")", "error", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "dir", ",", "dst", ")", "\n\n", "// Make the containing directory, if it does not alre...
// DirToBox takes the directory and compresses it into a Vagrant-compatible // box. This function does not perform checks to verify that dir is // actually a proper box. This is an expected precondition.
[ "DirToBox", "takes", "the", "directory", "and", "compresses", "it", "into", "a", "Vagrant", "-", "compatible", "box", ".", "This", "function", "does", "not", "perform", "checks", "to", "verify", "that", "dir", "is", "actually", "a", "proper", "box", ".", "...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/post-processor/vagrant/util.go#L74-L159
165,110
hashicorp/packer
post-processor/vagrant/util.go
WriteMetadata
func WriteMetadata(dir string, contents interface{}) error { if _, err := os.Stat(filepath.Join(dir, "metadata.json")); os.IsNotExist(err) { f, err := os.Create(filepath.Join(dir, "metadata.json")) if err != nil { return err } defer f.Close() enc := json.NewEncoder(f) return enc.Encode(contents) } r...
go
func WriteMetadata(dir string, contents interface{}) error { if _, err := os.Stat(filepath.Join(dir, "metadata.json")); os.IsNotExist(err) { f, err := os.Create(filepath.Join(dir, "metadata.json")) if err != nil { return err } defer f.Close() enc := json.NewEncoder(f) return enc.Encode(contents) } r...
[ "func", "WriteMetadata", "(", "dir", "string", ",", "contents", "interface", "{", "}", ")", "error", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "filepath", ".", "Join", "(", "dir", ",", "\"", "\"", ")", ")", ";", "os", ".", "IsNotE...
// WriteMetadata writes the "metadata.json" file for a Vagrant box.
[ "WriteMetadata", "writes", "the", "metadata", ".", "json", "file", "for", "a", "Vagrant", "box", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/post-processor/vagrant/util.go#L162-L175
165,111
hashicorp/packer
common/uuid/uuid.go
TimeOrderedUUID
func TimeOrderedUUID() string { unix := uint32(time.Now().UTC().Unix()) b := make([]byte, 12) n, err := rand.Read(b) if n != len(b) { err = fmt.Errorf("Not enough entropy available") } if err != nil { panic(err) } return fmt.Sprintf("%08x-%04x-%04x-%04x-%04x%08x", unix, b[0:2], b[2:4], b[4:6], b[6:8], b[...
go
func TimeOrderedUUID() string { unix := uint32(time.Now().UTC().Unix()) b := make([]byte, 12) n, err := rand.Read(b) if n != len(b) { err = fmt.Errorf("Not enough entropy available") } if err != nil { panic(err) } return fmt.Sprintf("%08x-%04x-%04x-%04x-%04x%08x", unix, b[0:2], b[2:4], b[4:6], b[6:8], b[...
[ "func", "TimeOrderedUUID", "(", ")", "string", "{", "unix", ":=", "uint32", "(", "time", ".", "Now", "(", ")", ".", "UTC", "(", ")", ".", "Unix", "(", ")", ")", "\n\n", "b", ":=", "make", "(", "[", "]", "byte", ",", "12", ")", "\n", "n", ",",...
// Generates a time ordered UUID. Top 32 bits are a timestamp, // bottom 96 are random.
[ "Generates", "a", "time", "ordered", "UUID", ".", "Top", "32", "bits", "are", "a", "timestamp", "bottom", "96", "are", "random", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/common/uuid/uuid.go#L11-L24
165,112
hashicorp/packer
template/interpolate/funcs.go
Funcs
func Funcs(ctx *Context) template.FuncMap { result := make(map[string]interface{}) for k, v := range FuncGens { result[k] = v(ctx) } if ctx != nil { for k, v := range ctx.Funcs { result[k] = v } } return template.FuncMap(result) }
go
func Funcs(ctx *Context) template.FuncMap { result := make(map[string]interface{}) for k, v := range FuncGens { result[k] = v(ctx) } if ctx != nil { for k, v := range ctx.Funcs { result[k] = v } } return template.FuncMap(result) }
[ "func", "Funcs", "(", "ctx", "*", "Context", ")", "template", ".", "FuncMap", "{", "result", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "for", "k", ",", "v", ":=", "range", "FuncGens", "{", "result", "[", "k", ...
// Funcs returns the functions that can be used for interpolation given // a context.
[ "Funcs", "returns", "the", "functions", "that", "can", "be", "used", "for", "interpolation", "given", "a", "context", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/interpolate/funcs.go#L56-L68
165,113
hashicorp/packer
common/retry/retry.go
Run
func (cfg Config) Run(ctx context.Context, fn func(context.Context) error) error { retryDelay := func() time.Duration { return 2 * time.Second } if cfg.RetryDelay != nil { retryDelay = cfg.RetryDelay } shouldRetry := func(error) bool { return true } if cfg.ShouldRetry != nil { shouldRetry = cfg.ShouldRetry } ...
go
func (cfg Config) Run(ctx context.Context, fn func(context.Context) error) error { retryDelay := func() time.Duration { return 2 * time.Second } if cfg.RetryDelay != nil { retryDelay = cfg.RetryDelay } shouldRetry := func(error) bool { return true } if cfg.ShouldRetry != nil { shouldRetry = cfg.ShouldRetry } ...
[ "func", "(", "cfg", "Config", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "fn", "func", "(", "context", ".", "Context", ")", "error", ")", "error", "{", "retryDelay", ":=", "func", "(", ")", "time", ".", "Duration", "{", "return", "2", ...
// Run fn until context is cancelled up until StartTimeout time has passed.
[ "Run", "fn", "until", "context", "is", "cancelled", "up", "until", "StartTimeout", "time", "has", "passed", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/common/retry/retry.go#L40-L77
165,114
hashicorp/packer
builder/azure/arm/tempname.go
generatePassword
func generatePassword() string { var s string for i := 0; i < 100; i++ { s := random.AlphaNum(32) if !strings.ContainsAny(s, random.PossibleNumbers) { continue } if !strings.ContainsAny(s, random.PossibleLowerCase) { continue } if !strings.ContainsAny(s, random.PossibleUpperCase) { continue }...
go
func generatePassword() string { var s string for i := 0; i < 100; i++ { s := random.AlphaNum(32) if !strings.ContainsAny(s, random.PossibleNumbers) { continue } if !strings.ContainsAny(s, random.PossibleLowerCase) { continue } if !strings.ContainsAny(s, random.PossibleUpperCase) { continue }...
[ "func", "generatePassword", "(", ")", "string", "{", "var", "s", "string", "\n", "for", "i", ":=", "0", ";", "i", "<", "100", ";", "i", "++", "{", "s", ":=", "random", ".", "AlphaNum", "(", "32", ")", "\n", "if", "!", "strings", ".", "ContainsAny...
// generate a password that is acceptable to Azure // Three of the four items must be met. // 1. Contains an uppercase character // 2. Contains a lowercase character // 3. Contains a numeric digit // 4. Contains a special character
[ "generate", "a", "password", "that", "is", "acceptable", "to", "Azure", "Three", "of", "the", "four", "items", "must", "be", "met", ".", "1", ".", "Contains", "an", "uppercase", "character", "2", ".", "Contains", "a", "lowercase", "character", "3", ".", ...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/arm/tempname.go#L50-L71
165,115
hashicorp/packer
post-processor/vsphere-template/step_mark_as_template.go
unregisterPreviousVM
func unregisterPreviousVM(cli *govmomi.Client, folder *object.Folder, name string) error { si := object.NewSearchIndex(cli.Client) fullPath := path.Join(folder.InventoryPath, name) ref, err := si.FindByInventoryPath(context.Background(), fullPath) if err != nil { return err } if ref != nil { if vm, ok := re...
go
func unregisterPreviousVM(cli *govmomi.Client, folder *object.Folder, name string) error { si := object.NewSearchIndex(cli.Client) fullPath := path.Join(folder.InventoryPath, name) ref, err := si.FindByInventoryPath(context.Background(), fullPath) if err != nil { return err } if ref != nil { if vm, ok := re...
[ "func", "unregisterPreviousVM", "(", "cli", "*", "govmomi", ".", "Client", ",", "folder", "*", "object", ".", "Folder", ",", "name", "string", ")", "error", "{", "si", ":=", "object", ".", "NewSearchIndex", "(", "cli", ".", "Client", ")", "\n", "fullPath...
// If in the target folder a virtual machine or template already exists // it will be removed to maintain consistency
[ "If", "in", "the", "target", "folder", "a", "virtual", "machine", "or", "template", "already", "exists", "it", "will", "be", "removed", "to", "maintain", "consistency" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/post-processor/vsphere-template/step_mark_as_template.go#L150-L169
165,116
hashicorp/packer
builder/hyperv/common/step_create_external_switch.go
Run
func (s *StepCreateExternalSwitch) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) errorMsg := "Error creating external switch: %s" var err error ui.Say("Creating external sw...
go
func (s *StepCreateExternalSwitch) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) errorMsg := "Error creating external switch: %s" var err error ui.Say("Creating external sw...
[ "func", "(", "s", "*", "StepCreateExternalSwitch", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "state", "multistep", ".", "StateBag", ")", "multistep", ".", "StepAction", "{", "driver", ":=", "state", ".", "Get", "(", "\"", "\"", ")", ".", ...
// Run runs the step required to create an external switch. Depending on // the connectivity of the host machine, the external switch will allow the // build VM to connect to the outside world.
[ "Run", "runs", "the", "step", "required", "to", "create", "an", "external", "switch", ".", "Depending", "on", "the", "connectivity", "of", "the", "host", "machine", "the", "external", "switch", "will", "allow", "the", "build", "VM", "to", "connect", "to", ...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/hyperv/common/step_create_external_switch.go#L24-L75
165,117
hashicorp/packer
common/step_create_floppy.go
removeBase
func removeBase(base string, path string) (string, error) { var idx int var err error if res, err := filepath.Abs(path); err == nil { path = res } path = filepath.Clean(path) if base, err = filepath.Abs(base); err != nil { return path, err } c1, c2 := strings.Split(base, string(os.PathSeparator)), string...
go
func removeBase(base string, path string) (string, error) { var idx int var err error if res, err := filepath.Abs(path); err == nil { path = res } path = filepath.Clean(path) if base, err = filepath.Abs(base); err != nil { return path, err } c1, c2 := strings.Split(base, string(os.PathSeparator)), string...
[ "func", "removeBase", "(", "base", "string", ",", "path", "string", ")", "(", "string", ",", "error", ")", "{", "var", "idx", "int", "\n", "var", "err", "error", "\n\n", "if", "res", ",", "err", ":=", "filepath", ".", "Abs", "(", "path", ")", ";", ...
// removeBase will take a regular os.PathSeparator-separated path and remove the // prefix directory base from it. Both paths are converted to their absolute // formats before the stripping takes place.
[ "removeBase", "will", "take", "a", "regular", "os", ".", "PathSeparator", "-", "separated", "path", "and", "remove", "the", "prefix", "directory", "base", "from", "it", ".", "Both", "paths", "are", "converted", "to", "their", "absolute", "formats", "before", ...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/common/step_create_floppy.go#L311-L334
165,118
hashicorp/packer
builder/parallels/common/driver.go
NewDriver
func NewDriver() (Driver, error) { var drivers map[string]Driver var prlctlPath string var prlsrvctlPath string var supportedVersions []string DHCPLeaseFile := "/Library/Preferences/Parallels/parallels_dhcp_leases" if runtime.GOOS != "darwin" { return nil, fmt.Errorf( "Parallels builder works only on \"darw...
go
func NewDriver() (Driver, error) { var drivers map[string]Driver var prlctlPath string var prlsrvctlPath string var supportedVersions []string DHCPLeaseFile := "/Library/Preferences/Parallels/parallels_dhcp_leases" if runtime.GOOS != "darwin" { return nil, fmt.Errorf( "Parallels builder works only on \"darw...
[ "func", "NewDriver", "(", ")", "(", "Driver", ",", "error", ")", "{", "var", "drivers", "map", "[", "string", "]", "Driver", "\n", "var", "prlctlPath", "string", "\n", "var", "prlsrvctlPath", "string", "\n", "var", "supportedVersions", "[", "]", "string", ...
// NewDriver returns a new driver implementation for this version of Parallels // Desktop, or an error if the driver couldn't be initialized.
[ "NewDriver", "returns", "a", "new", "driver", "implementation", "for", "this", "version", "of", "Parallels", "Desktop", "or", "an", "error", "if", "the", "driver", "couldn", "t", "be", "initialized", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver.go#L66-L143
165,119
hashicorp/packer
packer/rpc/ui_progress_tracking.go
TrackProgress
func (u *Ui) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser { pl := &TrackProgressParameters{ Src: src, CurrentSize: currentSize, TotalSize: totalSize, } var trackingID string if err := u.client.Call("Ui.NewTrackProgress", pl, &trackingID); err != nil { ...
go
func (u *Ui) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser { pl := &TrackProgressParameters{ Src: src, CurrentSize: currentSize, TotalSize: totalSize, } var trackingID string if err := u.client.Call("Ui.NewTrackProgress", pl, &trackingID); err != nil { ...
[ "func", "(", "u", "*", "Ui", ")", "TrackProgress", "(", "src", "string", ",", "currentSize", ",", "totalSize", "int64", ",", "stream", "io", ".", "ReadCloser", ")", "io", ".", "ReadCloser", "{", "pl", ":=", "&", "TrackProgressParameters", "{", "Src", ":"...
// TrackProgress starts a pair of ProgressTrackingClient and ProgressProgressTrackingServer // that will send the size of each read bytes of stream. // In order to track an operation on the terminal side.
[ "TrackProgress", "starts", "a", "pair", "of", "ProgressTrackingClient", "and", "ProgressProgressTrackingServer", "that", "will", "send", "the", "size", "of", "each", "read", "bytes", "of", "stream", ".", "In", "order", "to", "track", "an", "operation", "on", "th...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/packer/rpc/ui_progress_tracking.go#L14-L31
165,120
hashicorp/packer
builder/amazon/common/ssh.go
SSHHost
func SSHHost(e ec2Describer, sshInterface string) func(multistep.StateBag) (string, error) { return func(state multistep.StateBag) (string, error) { const tries = 2 // <= with current structure to check result of describing `tries` times for j := 0; j <= tries; j++ { var host string i := state.Get("instanc...
go
func SSHHost(e ec2Describer, sshInterface string) func(multistep.StateBag) (string, error) { return func(state multistep.StateBag) (string, error) { const tries = 2 // <= with current structure to check result of describing `tries` times for j := 0; j <= tries; j++ { var host string i := state.Get("instanc...
[ "func", "SSHHost", "(", "e", "ec2Describer", ",", "sshInterface", "string", ")", "func", "(", "multistep", ".", "StateBag", ")", "(", "string", ",", "error", ")", "{", "return", "func", "(", "state", "multistep", ".", "StateBag", ")", "(", "string", ",",...
// SSHHost returns a function that can be given to the SSH communicator // for determining the SSH address based on the instance DNS name.
[ "SSHHost", "returns", "a", "function", "that", "can", "be", "given", "to", "the", "SSH", "communicator", "for", "determining", "the", "SSH", "address", "based", "on", "the", "instance", "DNS", "name", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/amazon/common/ssh.go#L23-L82
165,121
hashicorp/packer
packer/rpc/mux_broker.go
Run
func (m *muxBroker) Run() { for { stream, err := m.session.AcceptStream() if err != nil { // Once we receive an error, just exit break } // Read the stream ID from the stream var id uint32 if err := binary.Read(stream, binary.LittleEndian, &id); err != nil { stream.Close() continue } // I...
go
func (m *muxBroker) Run() { for { stream, err := m.session.AcceptStream() if err != nil { // Once we receive an error, just exit break } // Read the stream ID from the stream var id uint32 if err := binary.Read(stream, binary.LittleEndian, &id); err != nil { stream.Close() continue } // I...
[ "func", "(", "m", "*", "muxBroker", ")", "Run", "(", ")", "{", "for", "{", "stream", ",", "err", ":=", "m", ".", "session", ".", "AcceptStream", "(", ")", "\n", "if", "err", "!=", "nil", "{", "// Once we receive an error, just exit", "break", "\n", "}"...
// Run starts the brokering and should be executed in a goroutine, since it // blocks forever, or until the session closes.
[ "Run", "starts", "the", "brokering", "and", "should", "be", "executed", "in", "a", "goroutine", "since", "it", "blocks", "forever", "or", "until", "the", "session", "closes", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/packer/rpc/mux_broker.go#L124-L149
165,122
hashicorp/packer
common/iochan/iochan.go
LineReader
func LineReader(r io.Reader) <-chan string { ch := make(chan string) go func() { scanner := bufio.NewScanner(r) defer close(ch) for scanner.Scan() { ch <- scanner.Text() } }() return ch }
go
func LineReader(r io.Reader) <-chan string { ch := make(chan string) go func() { scanner := bufio.NewScanner(r) defer close(ch) for scanner.Scan() { ch <- scanner.Text() } }() return ch }
[ "func", "LineReader", "(", "r", "io", ".", "Reader", ")", "<-", "chan", "string", "{", "ch", ":=", "make", "(", "chan", "string", ")", "\n\n", "go", "func", "(", ")", "{", "scanner", ":=", "bufio", ".", "NewScanner", "(", "r", ")", "\n", "defer", ...
// LineReader takes an io.Reader and produces the contents of the reader on the // returned channel. Internally bufio.NewScanner is used, io.ScanLines parses // lines and returns them without carriage return. Scan can panic if the split // function returns too many empty tokens without advancing the input. // // The ch...
[ "LineReader", "takes", "an", "io", ".", "Reader", "and", "produces", "the", "contents", "of", "the", "reader", "on", "the", "returned", "channel", ".", "Internally", "bufio", ".", "NewScanner", "is", "used", "io", ".", "ScanLines", "parses", "lines", "and", ...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/common/iochan/iochan.go#L15-L28
165,123
hashicorp/packer
builder/azure/common/devicelogin.go
tokenFromFile
func tokenFromFile(say func(string), oauthCfg adal.OAuthConfig, tokenPath, clientID, resource string, callback adal.TokenRefreshCallback) (*adal.ServicePrincipalToken, error) { say(fmt.Sprintf("Loading auth token from file: %s", tokenPath)) if _, err := os.Stat(tokenPath); err != nil { if os.IsNotExist(err) { // f...
go
func tokenFromFile(say func(string), oauthCfg adal.OAuthConfig, tokenPath, clientID, resource string, callback adal.TokenRefreshCallback) (*adal.ServicePrincipalToken, error) { say(fmt.Sprintf("Loading auth token from file: %s", tokenPath)) if _, err := os.Stat(tokenPath); err != nil { if os.IsNotExist(err) { // f...
[ "func", "tokenFromFile", "(", "say", "func", "(", "string", ")", ",", "oauthCfg", "adal", ".", "OAuthConfig", ",", "tokenPath", ",", "clientID", ",", "resource", "string", ",", "callback", "adal", ".", "TokenRefreshCallback", ")", "(", "*", "adal", ".", "S...
// tokenFromFile returns a token from the specified file if it is found, otherwise // returns nil. Any error retrieving or creating the token is returned as an error.
[ "tokenFromFile", "returns", "a", "token", "from", "the", "specified", "file", "if", "it", "is", "found", "otherwise", "returns", "nil", ".", "Any", "error", "retrieving", "or", "creating", "the", "token", "is", "returned", "as", "an", "error", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/common/devicelogin.go#L99-L119
165,124
hashicorp/packer
builder/azure/common/devicelogin.go
tokenFromDeviceFlow
func tokenFromDeviceFlow(say func(string), oauthCfg adal.OAuthConfig, clientID, resource string) (*adal.ServicePrincipalToken, error) { cl := autorest.NewClientWithUserAgent(useragent.String()) deviceCode, err := adal.InitiateDeviceAuth(&cl, oauthCfg, clientID, resource) if err != nil { return nil, fmt.Errorf("Fai...
go
func tokenFromDeviceFlow(say func(string), oauthCfg adal.OAuthConfig, clientID, resource string) (*adal.ServicePrincipalToken, error) { cl := autorest.NewClientWithUserAgent(useragent.String()) deviceCode, err := adal.InitiateDeviceAuth(&cl, oauthCfg, clientID, resource) if err != nil { return nil, fmt.Errorf("Fai...
[ "func", "tokenFromDeviceFlow", "(", "say", "func", "(", "string", ")", ",", "oauthCfg", "adal", ".", "OAuthConfig", ",", "clientID", ",", "resource", "string", ")", "(", "*", "adal", ".", "ServicePrincipalToken", ",", "error", ")", "{", "cl", ":=", "autore...
// tokenFromDeviceFlow prints a message to the screen for user to take action to // consent application on a browser and in the meanwhile the authentication // endpoint is polled until user gives consent, denies or the flow times out. // Returned token must be saved.
[ "tokenFromDeviceFlow", "prints", "a", "message", "to", "the", "screen", "for", "user", "to", "take", "action", "to", "consent", "application", "on", "a", "browser", "and", "in", "the", "meanwhile", "the", "authentication", "endpoint", "is", "polled", "until", ...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/common/devicelogin.go#L125-L146
165,125
hashicorp/packer
builder/azure/common/devicelogin.go
tokenCachePath
func tokenCachePath(tenantID string) string { var dir string u, err := user.Current() if err != nil || u.HomeDir == "" { dir, _ = filepath.Abs(os.Args[0]) } else { dir = u.HomeDir } return filepath.Join(dir, ".azure", "packer", fmt.Sprintf("oauth-%s.json", tenantID)) }
go
func tokenCachePath(tenantID string) string { var dir string u, err := user.Current() if err != nil || u.HomeDir == "" { dir, _ = filepath.Abs(os.Args[0]) } else { dir = u.HomeDir } return filepath.Join(dir, ".azure", "packer", fmt.Sprintf("oauth-%s.json", tenantID)) }
[ "func", "tokenCachePath", "(", "tenantID", "string", ")", "string", "{", "var", "dir", "string", "\n\n", "u", ",", "err", ":=", "user", ".", "Current", "(", ")", "\n", "if", "err", "!=", "nil", "||", "u", ".", "HomeDir", "==", "\"", "\"", "{", "dir...
// tokenCachePath returns the full path the OAuth 2.0 token should be saved at // for given tenant ID.
[ "tokenCachePath", "returns", "the", "full", "path", "the", "OAuth", "2", ".", "0", "token", "should", "be", "saved", "at", "for", "given", "tenant", "ID", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/common/devicelogin.go#L150-L161
165,126
hashicorp/packer
builder/azure/common/devicelogin.go
mkTokenCallback
func mkTokenCallback(path string) adal.TokenRefreshCallback { return func(t adal.Token) error { if err := adal.SaveToken(path, 0600, t); err != nil { return err } return nil } }
go
func mkTokenCallback(path string) adal.TokenRefreshCallback { return func(t adal.Token) error { if err := adal.SaveToken(path, 0600, t); err != nil { return err } return nil } }
[ "func", "mkTokenCallback", "(", "path", "string", ")", "adal", ".", "TokenRefreshCallback", "{", "return", "func", "(", "t", "adal", ".", "Token", ")", "error", "{", "if", "err", ":=", "adal", ".", "SaveToken", "(", "path", ",", "0600", ",", "t", ")", ...
// mkTokenCallback returns a callback function that can be used to save the // token initially or register to the Azure SDK to be called when the token is // refreshed.
[ "mkTokenCallback", "returns", "a", "callback", "function", "that", "can", "be", "used", "to", "save", "the", "token", "initially", "or", "register", "to", "the", "Azure", "SDK", "to", "be", "called", "when", "the", "token", "is", "refreshed", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/common/devicelogin.go#L166-L173
165,127
hashicorp/packer
builder/azure/common/devicelogin.go
FindTenantID
func FindTenantID(env azure.Environment, subscriptionID string) (string, error) { const hdrKey = "WWW-Authenticate" c := subscriptions.NewClientWithBaseURI(env.ResourceManagerEndpoint) // we expect this request to fail (err != nil), but we are only interested // in headers, so surface the error if the Response is ...
go
func FindTenantID(env azure.Environment, subscriptionID string) (string, error) { const hdrKey = "WWW-Authenticate" c := subscriptions.NewClientWithBaseURI(env.ResourceManagerEndpoint) // we expect this request to fail (err != nil), but we are only interested // in headers, so surface the error if the Response is ...
[ "func", "FindTenantID", "(", "env", "azure", ".", "Environment", ",", "subscriptionID", "string", ")", "(", "string", ",", "error", ")", "{", "const", "hdrKey", "=", "\"", "\"", "\n", "c", ":=", "subscriptions", ".", "NewClientWithBaseURI", "(", "env", "."...
// FindTenantID figures out the AAD tenant ID of the subscription by making an // unauthenticated request to the Get Subscription Details endpoint and parses // the value from WWW-Authenticate header.
[ "FindTenantID", "figures", "out", "the", "AAD", "tenant", "ID", "of", "the", "subscription", "by", "making", "an", "unauthenticated", "request", "to", "the", "Get", "Subscription", "Details", "endpoint", "and", "parses", "the", "value", "from", "WWW", "-", "Au...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/common/devicelogin.go#L178-L207
165,128
hashicorp/packer
builder/azure/pkcs12/bmp-string.go
bmpString
func bmpString(s string) ([]byte, error) { // References: // https://tools.ietf.org/html/rfc7292#appendix-B.1 // http://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane // - non-BMP characters are encoded in UTF 16 by using a surrogate pair of 16-bit codes // EncodeRune returns 0xfffd if the rune ...
go
func bmpString(s string) ([]byte, error) { // References: // https://tools.ietf.org/html/rfc7292#appendix-B.1 // http://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane // - non-BMP characters are encoded in UTF 16 by using a surrogate pair of 16-bit codes // EncodeRune returns 0xfffd if the rune ...
[ "func", "bmpString", "(", "s", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// References:", "// https://tools.ietf.org/html/rfc7292#appendix-B.1", "// http://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane", "// - non-BMP characters are encoded in...
// bmpString returns s encoded in UCS-2 with a zero terminator.
[ "bmpString", "returns", "s", "encoded", "in", "UCS", "-", "2", "with", "a", "zero", "terminator", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/pkcs12/bmp-string.go#L13-L31
165,129
hashicorp/packer
builder/azure/arm/template_funcs.go
templateCleanImageName
func templateCleanImageName(s string) string { if ok, _ := assertManagedImageName(s, ""); ok { return s } b := []byte(s) newb := make([]byte, len(b)) for i := range newb { if isValidByteValue(b[i]) { newb[i] = b[i] } else { newb[i] = '-' } } newb = bytes.TrimRight(newb, "-_.") return string(newb)...
go
func templateCleanImageName(s string) string { if ok, _ := assertManagedImageName(s, ""); ok { return s } b := []byte(s) newb := make([]byte, len(b)) for i := range newb { if isValidByteValue(b[i]) { newb[i] = b[i] } else { newb[i] = '-' } } newb = bytes.TrimRight(newb, "-_.") return string(newb)...
[ "func", "templateCleanImageName", "(", "s", "string", ")", "string", "{", "if", "ok", ",", "_", ":=", "assertManagedImageName", "(", "s", ",", "\"", "\"", ")", ";", "ok", "{", "return", "s", "\n", "}", "\n", "b", ":=", "[", "]", "byte", "(", "s", ...
// Clean up image name by replacing invalid characters with "-" // Names are not allowed to end in '.', '-', or '_' and are trimmed.
[ "Clean", "up", "image", "name", "by", "replacing", "invalid", "characters", "with", "-", "Names", "are", "not", "allowed", "to", "end", "in", ".", "-", "or", "_", "and", "are", "trimmed", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/arm/template_funcs.go#L25-L41
165,130
hashicorp/packer
communicator/winrm/time.go
formatDuration
func formatDuration(duration time.Duration) string { // We're not supporting negative durations if duration.Seconds() <= 0 { return "PT0S" } h := int(duration.Hours()) m := int(duration.Minutes()) - (h * 60) s := int(duration.Seconds()) - (h*3600 + m*60) res := "PT" if h > 0 { res = fmt.Sprintf("%s%dH", r...
go
func formatDuration(duration time.Duration) string { // We're not supporting negative durations if duration.Seconds() <= 0 { return "PT0S" } h := int(duration.Hours()) m := int(duration.Minutes()) - (h * 60) s := int(duration.Seconds()) - (h*3600 + m*60) res := "PT" if h > 0 { res = fmt.Sprintf("%s%dH", r...
[ "func", "formatDuration", "(", "duration", "time", ".", "Duration", ")", "string", "{", "// We're not supporting negative durations", "if", "duration", ".", "Seconds", "(", ")", "<=", "0", "{", "return", "\"", "\"", "\n", "}", "\n\n", "h", ":=", "int", "(", ...
// formatDuration formats the given time.Duration into an ISO8601 // duration string.
[ "formatDuration", "formats", "the", "given", "time", ".", "Duration", "into", "an", "ISO8601", "duration", "string", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/communicator/winrm/time.go#L10-L32
165,131
hashicorp/packer
builder/file/builder.go
Run
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { artifact := new(FileArtifact) if b.config.Source != "" { source, err := os.Open(b.config.Source) defer source.Close() if err != nil { return nil, err } // Create will truncate an existing file target...
go
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { artifact := new(FileArtifact) if b.config.Source != "" { source, err := os.Open(b.config.Source) defer source.Close() if err != nil { return nil, err } // Create will truncate an existing file target...
[ "func", "(", "b", "*", "Builder", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "ui", "packer", ".", "Ui", ",", "hook", "packer", ".", "Hook", ")", "(", "packer", ".", "Artifact", ",", "error", ")", "{", "artifact", ":=", "new", "(", "F...
// Run is where the actual build should take place. It takes a Build and a Ui.
[ "Run", "is", "where", "the", "actual", "build", "should", "take", "place", ".", "It", "takes", "a", "Build", "and", "a", "Ui", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/file/builder.go#L37-L78
165,132
hashicorp/packer
builder/googlecompute/step_teardown_instance.go
Run
func (s *StepTeardownInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) name := config.InstanceName if name == "" { return multistep.ActionHalt } ui.Say("Deleting ...
go
func (s *StepTeardownInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) name := config.InstanceName if name == "" { return multistep.ActionHalt } ui.Say("Deleting ...
[ "func", "(", "s", "*", "StepTeardownInstance", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "state", "multistep", ".", "StateBag", ")", "multistep", ".", "StepAction", "{", "config", ":=", "state", ".", "Get", "(", "\"", "\"", ")", ".", "(",...
// Run executes the Packer build step that tears down a GCE instance.
[ "Run", "executes", "the", "Packer", "build", "step", "that", "tears", "down", "a", "GCE", "instance", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/googlecompute/step_teardown_instance.go#L20-L53
165,133
hashicorp/packer
builder/googlecompute/step_teardown_instance.go
Cleanup
func (s *StepTeardownInstance) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) ui.Say("Deleting disk...") errCh, err := driver.DeleteDisk(config.Zone, config.DiskName) if err == nil { select { case err = <-er...
go
func (s *StepTeardownInstance) Cleanup(state multistep.StateBag) { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) ui.Say("Deleting disk...") errCh, err := driver.DeleteDisk(config.Zone, config.DiskName) if err == nil { select { case err = <-er...
[ "func", "(", "s", "*", "StepTeardownInstance", ")", "Cleanup", "(", "state", "multistep", ".", "StateBag", ")", "{", "config", ":=", "state", ".", "Get", "(", "\"", "\"", ")", ".", "(", "*", "Config", ")", "\n", "driver", ":=", "state", ".", "Get", ...
// Deleting the instance does not remove the boot disk. This cleanup removes // the disk.
[ "Deleting", "the", "instance", "does", "not", "remove", "the", "boot", "disk", ".", "This", "cleanup", "removes", "the", "disk", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/googlecompute/step_teardown_instance.go#L57-L83
165,134
hashicorp/packer
communicator/ssh/communicator.go
New
func New(address string, config *Config) (result *comm, err error) { // Establish an initial connection and connect result = &comm{ config: config, address: address, } if err = result.reconnect(); err != nil { result = nil return } return }
go
func New(address string, config *Config) (result *comm, err error) { // Establish an initial connection and connect result = &comm{ config: config, address: address, } if err = result.reconnect(); err != nil { result = nil return } return }
[ "func", "New", "(", "address", "string", ",", "config", "*", "Config", ")", "(", "result", "*", "comm", ",", "err", "error", ")", "{", "// Establish an initial connection and connect", "result", "=", "&", "comm", "{", "config", ":", "config", ",", "address",...
// Creates a new packer.Communicator implementation over SSH. This takes // an already existing TCP connection and SSH configuration.
[ "Creates", "a", "new", "packer", ".", "Communicator", "implementation", "over", "SSH", ".", "This", "takes", "an", "already", "existing", "TCP", "connection", "and", "SSH", "configuration", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/communicator/ssh/communicator.go#L71-L84
165,135
hashicorp/packer
builder/parallels/common/prlctl_post_config.go
Prepare
func (c *PrlctlPostConfig) Prepare(ctx *interpolate.Context) []error { if c.PrlctlPost == nil { c.PrlctlPost = make([][]string, 0) } return nil }
go
func (c *PrlctlPostConfig) Prepare(ctx *interpolate.Context) []error { if c.PrlctlPost == nil { c.PrlctlPost = make([][]string, 0) } return nil }
[ "func", "(", "c", "*", "PrlctlPostConfig", ")", "Prepare", "(", "ctx", "*", "interpolate", ".", "Context", ")", "[", "]", "error", "{", "if", "c", ".", "PrlctlPost", "==", "nil", "{", "c", ".", "PrlctlPost", "=", "make", "(", "[", "]", "[", "]", ...
// Prepare sets the default value of "PrlctlPost" property.
[ "Prepare", "sets", "the", "default", "value", "of", "PrlctlPost", "property", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/prlctl_post_config.go#L14-L20
165,136
hashicorp/packer
builder/oracle/oci/driver_mock.go
DeleteImage
func (d *driverMock) DeleteImage(ctx context.Context, id string) error { if d.DeleteImageErr != nil { return d.DeleteImageErr } d.DeleteImageID = id return nil }
go
func (d *driverMock) DeleteImage(ctx context.Context, id string) error { if d.DeleteImageErr != nil { return d.DeleteImageErr } d.DeleteImageID = id return nil }
[ "func", "(", "d", "*", "driverMock", ")", "DeleteImage", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "error", "{", "if", "d", ".", "DeleteImageErr", "!=", "nil", "{", "return", "d", ".", "DeleteImageErr", "\n", "}", "\n\n", "d", ...
// DeleteImage mocks deleting a custom image.
[ "DeleteImage", "mocks", "deleting", "a", "custom", "image", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/oracle/oci/driver_mock.go#L54-L62
165,137
hashicorp/packer
builder/cloudstack/builder.go
Run
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { b.ui = ui // Create a CloudStack API client. client := cloudstack.NewAsyncClient( b.config.APIURL, b.config.APIKey, b.config.SecretKey, !b.config.SSLNoVerify, ) // Set the time to wait before timing out ...
go
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { b.ui = ui // Create a CloudStack API client. client := cloudstack.NewAsyncClient( b.config.APIURL, b.config.APIKey, b.config.SecretKey, !b.config.SSLNoVerify, ) // Set the time to wait before timing out ...
[ "func", "(", "b", "*", "Builder", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "ui", "packer", ".", "Ui", ",", "hook", "packer", ".", "Hook", ")", "(", "packer", ".", "Artifact", ",", "error", ")", "{", "b", ".", "ui", "=", "ui", "\n...
// Run implements the packer.Builder interface.
[ "Run", "implements", "the", "packer", ".", "Builder", "interface", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/cloudstack/builder.go#L35-L116
165,138
hashicorp/packer
builder/vagrant/artifact.go
NewArtifact
func NewArtifact(provider, dir string) packer.Artifact { return &artifact{ OutputDir: dir, BoxName: "package.box", Provider: provider, } }
go
func NewArtifact(provider, dir string) packer.Artifact { return &artifact{ OutputDir: dir, BoxName: "package.box", Provider: provider, } }
[ "func", "NewArtifact", "(", "provider", ",", "dir", "string", ")", "packer", ".", "Artifact", "{", "return", "&", "artifact", "{", "OutputDir", ":", "dir", ",", "BoxName", ":", "\"", "\"", ",", "Provider", ":", "provider", ",", "}", "\n", "}" ]
// NewArtifact returns a vagrant artifact containing the .box file
[ "NewArtifact", "returns", "a", "vagrant", "artifact", "containing", "the", ".", "box", "file" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vagrant/artifact.go#L22-L28
165,139
hashicorp/packer
builder/parallels/common/step_compact_disk.go
Run
func (s *StepCompactDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) ui := state.Get("ui").(packer.Ui) if s.Skip { ui.Say("Skipping disk compaction step...") return multistep.ActionContinue } ui.Say(...
go
func (s *StepCompactDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) ui := state.Get("ui").(packer.Ui) if s.Skip { ui.Say("Skipping disk compaction step...") return multistep.ActionContinue } ui.Say(...
[ "func", "(", "s", "*", "StepCompactDisk", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "state", "multistep", ".", "StateBag", ")", "multistep", ".", "StepAction", "{", "driver", ":=", "state", ".", "Get", "(", "\"", "\"", ")", ".", "(", "D...
// Run runs the compaction of the virtual disk attached to the VM.
[ "Run", "runs", "the", "compaction", "of", "the", "virtual", "disk", "attached", "to", "the", "VM", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/step_compact_disk.go#L26-L52
165,140
hashicorp/packer
builder/googlecompute/winrm.go
winrmConfig
func winrmConfig(state multistep.StateBag) (*communicator.WinRMConfig, error) { config := state.Get("config").(*Config) password := state.Get("winrm_password").(string) return &communicator.WinRMConfig{ Username: config.Comm.WinRMUser, Password: password, }, nil }
go
func winrmConfig(state multistep.StateBag) (*communicator.WinRMConfig, error) { config := state.Get("config").(*Config) password := state.Get("winrm_password").(string) return &communicator.WinRMConfig{ Username: config.Comm.WinRMUser, Password: password, }, nil }
[ "func", "winrmConfig", "(", "state", "multistep", ".", "StateBag", ")", "(", "*", "communicator", ".", "WinRMConfig", ",", "error", ")", "{", "config", ":=", "state", ".", "Get", "(", "\"", "\"", ")", ".", "(", "*", "Config", ")", "\n", "password", "...
// winrmConfig returns the WinRM configuration.
[ "winrmConfig", "returns", "the", "WinRM", "configuration", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/googlecompute/winrm.go#L9-L17
165,141
hashicorp/packer
builder/parallels/common/driver_9.go
Import
func (d *Parallels9Driver) Import(name, srcPath, dstDir string, reassignMAC bool) error { err := d.Prlctl("register", srcPath, "--preserve-uuid") if err != nil { return err } srcID, err := getVMID(srcPath) if err != nil { return err } srcMAC := "auto" if !reassignMAC { srcMAC, err = getFirstMACAddress(s...
go
func (d *Parallels9Driver) Import(name, srcPath, dstDir string, reassignMAC bool) error { err := d.Prlctl("register", srcPath, "--preserve-uuid") if err != nil { return err } srcID, err := getVMID(srcPath) if err != nil { return err } srcMAC := "auto" if !reassignMAC { srcMAC, err = getFirstMACAddress(s...
[ "func", "(", "d", "*", "Parallels9Driver", ")", "Import", "(", "name", ",", "srcPath", ",", "dstDir", "string", ",", "reassignMAC", "bool", ")", "error", "{", "err", ":=", "d", ".", "Prlctl", "(", "\"", "\"", ",", "srcPath", ",", "\"", "\"", ")", "...
// Import creates a clone of the source VM and reassigns the MAC address if needed.
[ "Import", "creates", "a", "clone", "of", "the", "source", "VM", "and", "reassigns", "the", "MAC", "address", "if", "needed", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver_9.go#L34-L68
165,142
hashicorp/packer
builder/parallels/common/driver_9.go
CompactDisk
func (d *Parallels9Driver) CompactDisk(diskPath string) error { prlDiskToolPath, err := exec.LookPath("prl_disk_tool") if err != nil { return err } // Analyze the disk content and remove unused blocks command := []string{ "compact", "--hdd", diskPath, } if err := exec.Command(prlDiskToolPath, command...)....
go
func (d *Parallels9Driver) CompactDisk(diskPath string) error { prlDiskToolPath, err := exec.LookPath("prl_disk_tool") if err != nil { return err } // Analyze the disk content and remove unused blocks command := []string{ "compact", "--hdd", diskPath, } if err := exec.Command(prlDiskToolPath, command...)....
[ "func", "(", "d", "*", "Parallels9Driver", ")", "CompactDisk", "(", "diskPath", "string", ")", "error", "{", "prlDiskToolPath", ",", "err", ":=", "exec", ".", "LookPath", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n",...
// CompactDisk performs the compaction of the specified virtual disk image.
[ "CompactDisk", "performs", "the", "compaction", "of", "the", "specified", "virtual", "disk", "image", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver_9.go#L124-L149
165,143
hashicorp/packer
builder/parallels/common/driver_9.go
DeviceAddCDROM
func (d *Parallels9Driver) DeviceAddCDROM(name string, image string) (string, error) { command := []string{ "set", name, "--device-add", "cdrom", "--image", image, "--enable", "--connect", } out, err := exec.Command(d.PrlctlPath, command...).Output() if err != nil { return "", err } deviceRe := regexp...
go
func (d *Parallels9Driver) DeviceAddCDROM(name string, image string) (string, error) { command := []string{ "set", name, "--device-add", "cdrom", "--image", image, "--enable", "--connect", } out, err := exec.Command(d.PrlctlPath, command...).Output() if err != nil { return "", err } deviceRe := regexp...
[ "func", "(", "d", "*", "Parallels9Driver", ")", "DeviceAddCDROM", "(", "name", "string", ",", "image", "string", ")", "(", "string", ",", "error", ")", "{", "command", ":=", "[", "]", "string", "{", "\"", "\"", ",", "name", ",", "\"", "\"", ",", "\...
// DeviceAddCDROM adds a virtual CDROM device and attaches the specified image.
[ "DeviceAddCDROM", "adds", "a", "virtual", "CDROM", "device", "and", "attaches", "the", "specified", "image", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver_9.go#L152-L174
165,144
hashicorp/packer
builder/parallels/common/driver_9.go
DiskPath
func (d *Parallels9Driver) DiskPath(name string) (string, error) { out, err := exec.Command(d.PrlctlPath, "list", "-i", name).Output() if err != nil { return "", err } HDDRe := regexp.MustCompile("hdd0.* image='(.*)' type=*") matches := HDDRe.FindStringSubmatch(string(out)) if matches == nil { return "", fmt...
go
func (d *Parallels9Driver) DiskPath(name string) (string, error) { out, err := exec.Command(d.PrlctlPath, "list", "-i", name).Output() if err != nil { return "", err } HDDRe := regexp.MustCompile("hdd0.* image='(.*)' type=*") matches := HDDRe.FindStringSubmatch(string(out)) if matches == nil { return "", fmt...
[ "func", "(", "d", "*", "Parallels9Driver", ")", "DiskPath", "(", "name", "string", ")", "(", "string", ",", "error", ")", "{", "out", ",", "err", ":=", "exec", ".", "Command", "(", "d", ".", "PrlctlPath", ",", "\"", "\"", ",", "\"", "\"", ",", "n...
// DiskPath returns a full path to the first virtual disk drive.
[ "DiskPath", "returns", "a", "full", "path", "to", "the", "first", "virtual", "disk", "drive", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver_9.go#L177-L192
165,145
hashicorp/packer
builder/parallels/common/driver_9.go
IsRunning
func (d *Parallels9Driver) IsRunning(name string) (bool, error) { var stdout bytes.Buffer cmd := exec.Command(d.PrlctlPath, "list", name, "--no-header", "--output", "status") cmd.Stdout = &stdout if err := cmd.Run(); err != nil { return false, err } log.Printf("Checking VM state: %s\n", strings.TrimSpace(stdo...
go
func (d *Parallels9Driver) IsRunning(name string) (bool, error) { var stdout bytes.Buffer cmd := exec.Command(d.PrlctlPath, "list", name, "--no-header", "--output", "status") cmd.Stdout = &stdout if err := cmd.Run(); err != nil { return false, err } log.Printf("Checking VM state: %s\n", strings.TrimSpace(stdo...
[ "func", "(", "d", "*", "Parallels9Driver", ")", "IsRunning", "(", "name", "string", ")", "(", "bool", ",", "error", ")", "{", "var", "stdout", "bytes", ".", "Buffer", "\n\n", "cmd", ":=", "exec", ".", "Command", "(", "d", ".", "PrlctlPath", ",", "\""...
// IsRunning determines whether the VM is running or not.
[ "IsRunning", "determines", "whether", "the", "VM", "is", "running", "or", "not", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver_9.go#L195-L223
165,146
hashicorp/packer
builder/parallels/common/driver_9.go
Stop
func (d *Parallels9Driver) Stop(name string) error { if err := d.Prlctl("stop", name, "--kill"); err != nil { return err } // We sleep here for a little bit to let the session "unlock" time.Sleep(2 * time.Second) return nil }
go
func (d *Parallels9Driver) Stop(name string) error { if err := d.Prlctl("stop", name, "--kill"); err != nil { return err } // We sleep here for a little bit to let the session "unlock" time.Sleep(2 * time.Second) return nil }
[ "func", "(", "d", "*", "Parallels9Driver", ")", "Stop", "(", "name", "string", ")", "error", "{", "if", "err", ":=", "d", ".", "Prlctl", "(", "\"", "\"", ",", "name", ",", "\"", "\"", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}...
// Stop forcibly stops the VM.
[ "Stop", "forcibly", "stops", "the", "VM", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver_9.go#L226-L235
165,147
hashicorp/packer
builder/parallels/common/driver_9.go
Version
func (d *Parallels9Driver) Version() (string, error) { out, err := exec.Command(d.PrlctlPath, "--version").Output() if err != nil { return "", err } versionRe := regexp.MustCompile(`prlctl version (\d+\.\d+.\d+)`) matches := versionRe.FindStringSubmatch(string(out)) if matches == nil { return "", fmt.Errorf(...
go
func (d *Parallels9Driver) Version() (string, error) { out, err := exec.Command(d.PrlctlPath, "--version").Output() if err != nil { return "", err } versionRe := regexp.MustCompile(`prlctl version (\d+\.\d+.\d+)`) matches := versionRe.FindStringSubmatch(string(out)) if matches == nil { return "", fmt.Errorf(...
[ "func", "(", "d", "*", "Parallels9Driver", ")", "Version", "(", ")", "(", "string", ",", "error", ")", "{", "out", ",", "err", ":=", "exec", ".", "Command", "(", "d", ".", "PrlctlPath", ",", "\"", "\"", ")", ".", "Output", "(", ")", "\n", "if", ...
// Version returns the version of Parallels Desktop installed on that host.
[ "Version", "returns", "the", "version", "of", "Parallels", "Desktop", "installed", "on", "that", "host", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver_9.go#L266-L281
165,148
hashicorp/packer
builder/parallels/common/driver_9.go
MAC
func (d *Parallels9Driver) MAC(vmName string) (string, error) { var stdout bytes.Buffer cmd := exec.Command(d.PrlctlPath, "list", "-i", vmName) cmd.Stdout = &stdout if err := cmd.Run(); err != nil { log.Printf("MAC address for NIC: nic0 on Virtual Machine: %s not found!\n", vmName) return "", err } stdoutSt...
go
func (d *Parallels9Driver) MAC(vmName string) (string, error) { var stdout bytes.Buffer cmd := exec.Command(d.PrlctlPath, "list", "-i", vmName) cmd.Stdout = &stdout if err := cmd.Run(); err != nil { log.Printf("MAC address for NIC: nic0 on Virtual Machine: %s not found!\n", vmName) return "", err } stdoutSt...
[ "func", "(", "d", "*", "Parallels9Driver", ")", "MAC", "(", "vmName", "string", ")", "(", "string", ",", "error", ")", "{", "var", "stdout", "bytes", ".", "Buffer", "\n\n", "cmd", ":=", "exec", ".", "Command", "(", "d", ".", "PrlctlPath", ",", "\"", ...
// MAC returns the MAC address of the VM's first network interface.
[ "MAC", "returns", "the", "MAC", "address", "of", "the", "VM", "s", "first", "network", "interface", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver_9.go#L353-L374
165,149
hashicorp/packer
builder/azure/common/gluestrings.go
GlueStrings
func GlueStrings(a, b string) string { shift := 0 for shift < len(a) { i := 0 for (i+shift < len(a)) && (i < len(b)) && (a[i+shift] == b[i]) { i++ } if i+shift == len(a) { break } shift++ } return a[:shift] + b }
go
func GlueStrings(a, b string) string { shift := 0 for shift < len(a) { i := 0 for (i+shift < len(a)) && (i < len(b)) && (a[i+shift] == b[i]) { i++ } if i+shift == len(a) { break } shift++ } return a[:shift] + b }
[ "func", "GlueStrings", "(", "a", ",", "b", "string", ")", "string", "{", "shift", ":=", "0", "\n", "for", "shift", "<", "len", "(", "a", ")", "{", "i", ":=", "0", "\n", "for", "(", "i", "+", "shift", "<", "len", "(", "a", ")", ")", "&&", "(...
// removes overlap between the end of a and the start of b and // glues them together
[ "removes", "overlap", "between", "the", "end", "of", "a", "and", "the", "start", "of", "b", "and", "glues", "them", "together" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/common/gluestrings.go#L5-L19
165,150
hashicorp/packer
main.go
realMain
func realMain() int { var wrapConfig panicwrap.WrapConfig // When following env variable is set, packer // wont panic wrap itself as it's already wrapped. // i.e.: when terraform runs it. wrapConfig.CookieKey = "PACKER_WRAP_COOKIE" wrapConfig.CookieValue = "49C22B1A-3A93-4C98-97FA-E07D18C787B5" if !panicwrap.Wr...
go
func realMain() int { var wrapConfig panicwrap.WrapConfig // When following env variable is set, packer // wont panic wrap itself as it's already wrapped. // i.e.: when terraform runs it. wrapConfig.CookieKey = "PACKER_WRAP_COOKIE" wrapConfig.CookieValue = "49C22B1A-3A93-4C98-97FA-E07D18C787B5" if !panicwrap.Wr...
[ "func", "realMain", "(", ")", "int", "{", "var", "wrapConfig", "panicwrap", ".", "WrapConfig", "\n", "// When following env variable is set, packer", "// wont panic wrap itself as it's already wrapped.", "// i.e.: when terraform runs it.", "wrapConfig", ".", "CookieKey", "=", "...
// realMain is executed from main and returns the exit status to exit with.
[ "realMain", "is", "executed", "from", "main", "and", "returns", "the", "exit", "status", "to", "exit", "with", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/main.go#L39-L128
165,151
hashicorp/packer
main.go
wrappedMain
func wrappedMain() int { // If there is no explicit number of Go threads to use, then set it if os.Getenv("GOMAXPROCS") == "" { runtime.GOMAXPROCS(runtime.NumCPU()) } packer.LogSecretFilter.SetOutput(os.Stderr) log.SetOutput(&packer.LogSecretFilter) log.Printf("[INFO] Packer version: %s", version.FormattedVer...
go
func wrappedMain() int { // If there is no explicit number of Go threads to use, then set it if os.Getenv("GOMAXPROCS") == "" { runtime.GOMAXPROCS(runtime.NumCPU()) } packer.LogSecretFilter.SetOutput(os.Stderr) log.SetOutput(&packer.LogSecretFilter) log.Printf("[INFO] Packer version: %s", version.FormattedVer...
[ "func", "wrappedMain", "(", ")", "int", "{", "// If there is no explicit number of Go threads to use, then set it", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "==", "\"", "\"", "{", "runtime", ".", "GOMAXPROCS", "(", "runtime", ".", "NumCPU", "(", ")", "...
// wrappedMain is called only when we're wrapped by panicwrap and // returns the exit status to exit with.
[ "wrappedMain", "is", "called", "only", "when", "we", "re", "wrapped", "by", "panicwrap", "and", "returns", "the", "exit", "status", "to", "exit", "with", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/main.go#L132-L241
165,152
hashicorp/packer
main.go
excludeHelpFunc
func excludeHelpFunc(commands map[string]cli.CommandFactory, exclude []string) cli.HelpFunc { // Make search slice into a map so we can use use the `if found` idiom // instead of a nested loop. var excludes = make(map[string]interface{}, len(exclude)) for _, item := range exclude { excludes[item] = nil } // Cr...
go
func excludeHelpFunc(commands map[string]cli.CommandFactory, exclude []string) cli.HelpFunc { // Make search slice into a map so we can use use the `if found` idiom // instead of a nested loop. var excludes = make(map[string]interface{}, len(exclude)) for _, item := range exclude { excludes[item] = nil } // Cr...
[ "func", "excludeHelpFunc", "(", "commands", "map", "[", "string", "]", "cli", ".", "CommandFactory", ",", "exclude", "[", "]", "string", ")", "cli", ".", "HelpFunc", "{", "// Make search slice into a map so we can use use the `if found` idiom", "// instead of a nested loo...
// excludeHelpFunc filters commands we don't want to show from the list of // commands displayed in packer's help text.
[ "excludeHelpFunc", "filters", "commands", "we", "don", "t", "want", "to", "show", "from", "the", "list", "of", "commands", "displayed", "in", "packer", "s", "help", "text", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/main.go#L245-L262
165,153
hashicorp/packer
main.go
extractMachineReadable
func extractMachineReadable(args []string) ([]string, bool) { for i, arg := range args { if arg == "-machine-readable" { // We found it. Slice it out. result := make([]string, len(args)-1) copy(result, args[:i]) copy(result[i:], args[i+1:]) return result, true } } return args, false }
go
func extractMachineReadable(args []string) ([]string, bool) { for i, arg := range args { if arg == "-machine-readable" { // We found it. Slice it out. result := make([]string, len(args)-1) copy(result, args[:i]) copy(result[i:], args[i+1:]) return result, true } } return args, false }
[ "func", "extractMachineReadable", "(", "args", "[", "]", "string", ")", "(", "[", "]", "string", ",", "bool", ")", "{", "for", "i", ",", "arg", ":=", "range", "args", "{", "if", "arg", "==", "\"", "\"", "{", "// We found it. Slice it out.", "result", "...
// extractMachineReadable checks the args for the machine readable // flag and returns whether or not it is on. It modifies the args // to remove this flag.
[ "extractMachineReadable", "checks", "the", "args", "for", "the", "machine", "readable", "flag", "and", "returns", "whether", "or", "not", "it", "is", "on", ".", "It", "modifies", "the", "args", "to", "remove", "this", "flag", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/main.go#L267-L279
165,154
hashicorp/packer
builder/amazon/common/regions.go
ValidateRegion
func (c *AccessConfig) ValidateRegion(regions ...string) error { ec2conn, err := c.NewEC2Connection() if err != nil { return err } validRegions, err := listEC2Regions(ec2conn) if err != nil { return err } var invalidRegions []string for _, region := range regions { if region == "" { continue } fo...
go
func (c *AccessConfig) ValidateRegion(regions ...string) error { ec2conn, err := c.NewEC2Connection() if err != nil { return err } validRegions, err := listEC2Regions(ec2conn) if err != nil { return err } var invalidRegions []string for _, region := range regions { if region == "" { continue } fo...
[ "func", "(", "c", "*", "AccessConfig", ")", "ValidateRegion", "(", "regions", "...", "string", ")", "error", "{", "ec2conn", ",", "err", ":=", "c", ".", "NewEC2Connection", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\...
// ValidateRegion returns an nil if the regions are valid // and exists; otherwise an error. // ValidateRegion calls ec2conn.DescribeRegions to get the list of // regions available to this account.
[ "ValidateRegion", "returns", "an", "nil", "if", "the", "regions", "are", "valid", "and", "exists", ";", "otherwise", "an", "error", ".", "ValidateRegion", "calls", "ec2conn", ".", "DescribeRegions", "to", "get", "the", "list", "of", "regions", "available", "to...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/amazon/common/regions.go#L26-L58
165,155
hashicorp/packer
builder/parallels/common/driver_11.go
Verify
func (d *Parallels11Driver) Verify() error { stdout, err := exec.Command(d.PrlsrvctlPath, "info", "--license").Output() if err != nil { return err } editionRe := regexp.MustCompile(`edition="(\w+)"`) matches := editionRe.FindStringSubmatch(string(stdout)) if matches == nil { return fmt.Errorf( "Could not...
go
func (d *Parallels11Driver) Verify() error { stdout, err := exec.Command(d.PrlsrvctlPath, "info", "--license").Output() if err != nil { return err } editionRe := regexp.MustCompile(`edition="(\w+)"`) matches := editionRe.FindStringSubmatch(string(stdout)) if matches == nil { return fmt.Errorf( "Could not...
[ "func", "(", "d", "*", "Parallels11Driver", ")", "Verify", "(", ")", "error", "{", "stdout", ",", "err", ":=", "exec", ".", "Command", "(", "d", ".", "PrlsrvctlPath", ",", "\"", "\"", ",", "\"", "\"", ")", ".", "Output", "(", ")", "\n", "if", "er...
// Verify raises an error if the builder could not be used on that host machine.
[ "Verify", "raises", "an", "error", "if", "the", "builder", "could", "not", "be", "used", "on", "that", "host", "machine", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/driver_11.go#L16-L37
165,156
hashicorp/packer
builder/vmware/common/driver_workstation9_windows.go
workstationProgramFilePaths
func workstationProgramFilePaths() []string { path, err := workstationVMwareRoot() if err != nil { log.Printf("Error finding VMware root: %s", err) } paths := make([]string, 0, 5) if os.Getenv("VMWARE_HOME") != "" { paths = append(paths, os.Getenv("VMWARE_HOME")) } if path != "" { paths = append(paths, p...
go
func workstationProgramFilePaths() []string { path, err := workstationVMwareRoot() if err != nil { log.Printf("Error finding VMware root: %s", err) } paths := make([]string, 0, 5) if os.Getenv("VMWARE_HOME") != "" { paths = append(paths, os.Getenv("VMWARE_HOME")) } if path != "" { paths = append(paths, p...
[ "func", "workstationProgramFilePaths", "(", ")", "[", "]", "string", "{", "path", ",", "err", ":=", "workstationVMwareRoot", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "pa...
// workstationProgramFilesPaths returns a list of paths that are eligible // to contain program files we may want just as vmware.exe.
[ "workstationProgramFilesPaths", "returns", "a", "list", "of", "paths", "that", "are", "eligible", "to", "contain", "program", "files", "we", "may", "want", "just", "as", "vmware", ".", "exe", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/common/driver_workstation9_windows.go#L166-L192
165,157
hashicorp/packer
builder/vmware/common/driver_workstation9_windows.go
workstationDataFilePaths
func workstationDataFilePaths() []string { leasesPath, err := workstationDhcpLeasesPathRegistry() if err != nil { log.Printf("Error getting DHCP leases path: %s", err) } if leasesPath != "" { leasesPath = filepath.Dir(leasesPath) } paths := make([]string, 0, 5) if os.Getenv("VMWARE_DATA") != "" { paths =...
go
func workstationDataFilePaths() []string { leasesPath, err := workstationDhcpLeasesPathRegistry() if err != nil { log.Printf("Error getting DHCP leases path: %s", err) } if leasesPath != "" { leasesPath = filepath.Dir(leasesPath) } paths := make([]string, 0, 5) if os.Getenv("VMWARE_DATA") != "" { paths =...
[ "func", "workstationDataFilePaths", "(", ")", "[", "]", "string", "{", "leasesPath", ",", "err", ":=", "workstationDhcpLeasesPathRegistry", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "err", ")", "\n", "}", ...
// workstationDataFilePaths returns a list of paths that are eligible // to contain data files we may want such as vmnet NAT configuration files.
[ "workstationDataFilePaths", "returns", "a", "list", "of", "paths", "that", "are", "eligible", "to", "contain", "data", "files", "we", "may", "want", "such", "as", "vmnet", "NAT", "configuration", "files", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/common/driver_workstation9_windows.go#L196-L226
165,158
hashicorp/packer
builder/docker/ecr_login.go
EcrGetLogin
func (c *AwsAccessConfig) EcrGetLogin(ecrUrl string) (string, string, error) { exp := regexp.MustCompile(`(?:http://|https://|)([0-9]*)\.dkr\.ecr\.(.*)\.amazonaws\.com.*`) splitUrl := exp.FindStringSubmatch(ecrUrl) if len(splitUrl) != 3 { return "", "", fmt.Errorf("Failed to parse the ECR URL: %s it should be on ...
go
func (c *AwsAccessConfig) EcrGetLogin(ecrUrl string) (string, string, error) { exp := regexp.MustCompile(`(?:http://|https://|)([0-9]*)\.dkr\.ecr\.(.*)\.amazonaws\.com.*`) splitUrl := exp.FindStringSubmatch(ecrUrl) if len(splitUrl) != 3 { return "", "", fmt.Errorf("Failed to parse the ECR URL: %s it should be on ...
[ "func", "(", "c", "*", "AwsAccessConfig", ")", "EcrGetLogin", "(", "ecrUrl", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "exp", ":=", "regexp", ".", "MustCompile", "(", "`(?:http://|https://|)([0-9]*)\\.dkr\\.ecr\\.(.*)\\.amazonaws\\.com.*`"...
// Get a login token for Amazon AWS ECR. Returns username and password // or an error.
[ "Get", "a", "login", "token", "for", "Amazon", "AWS", "ECR", ".", "Returns", "username", "and", "password", "or", "an", "error", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/docker/ecr_login.go#L25-L71
165,159
hashicorp/packer
builder/oracle/oci/config_provider.go
NewRawConfigurationProvider
func NewRawConfigurationProvider(tenancy, user, region, fingerprint, privateKey string, privateKeyPassphrase *string) common.ConfigurationProvider { return rawConfigurationProvider{tenancy, user, region, fingerprint, privateKey, privateKeyPassphrase} }
go
func NewRawConfigurationProvider(tenancy, user, region, fingerprint, privateKey string, privateKeyPassphrase *string) common.ConfigurationProvider { return rawConfigurationProvider{tenancy, user, region, fingerprint, privateKey, privateKeyPassphrase} }
[ "func", "NewRawConfigurationProvider", "(", "tenancy", ",", "user", ",", "region", ",", "fingerprint", ",", "privateKey", "string", ",", "privateKeyPassphrase", "*", "string", ")", "common", ".", "ConfigurationProvider", "{", "return", "rawConfigurationProvider", "{",...
// NewRawConfigurationProvider will create a rawConfigurationProvider.
[ "NewRawConfigurationProvider", "will", "create", "a", "rawConfigurationProvider", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/oracle/oci/config_provider.go#L23-L25
165,160
hashicorp/packer
builder/alicloud/ecs/access_config.go
Client
func (c *AlicloudAccessConfig) Client() (*ClientWrapper, error) { if c.client != nil { return c.client, nil } if c.SecurityToken == "" { c.SecurityToken = os.Getenv("SECURITY_TOKEN") } client, err := ecs.NewClientWithStsToken(c.AlicloudRegion, c.AlicloudAccessKey, c.AlicloudSecretKey, c.SecurityToken) if e...
go
func (c *AlicloudAccessConfig) Client() (*ClientWrapper, error) { if c.client != nil { return c.client, nil } if c.SecurityToken == "" { c.SecurityToken = os.Getenv("SECURITY_TOKEN") } client, err := ecs.NewClientWithStsToken(c.AlicloudRegion, c.AlicloudAccessKey, c.AlicloudSecretKey, c.SecurityToken) if e...
[ "func", "(", "c", "*", "AlicloudAccessConfig", ")", "Client", "(", ")", "(", "*", "ClientWrapper", ",", "error", ")", "{", "if", "c", ".", "client", "!=", "nil", "{", "return", "c", ".", "client", ",", "nil", "\n", "}", "\n", "if", "c", ".", "Sec...
// Client for AlicloudClient
[ "Client", "for", "AlicloudClient" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/alicloud/ecs/access_config.go#L28-L47
165,161
hashicorp/packer
communicator/ssh/connect.go
ProxyConnectFunc
func ProxyConnectFunc(socksProxy string, socksAuth *proxy.Auth, network, addr string) func() (net.Conn, error) { return func() (net.Conn, error) { // create a socks5 dialer dialer, err := proxy.SOCKS5("tcp", socksProxy, socksAuth, proxy.Direct) if err != nil { return nil, fmt.Errorf("Can't connect to the prox...
go
func ProxyConnectFunc(socksProxy string, socksAuth *proxy.Auth, network, addr string) func() (net.Conn, error) { return func() (net.Conn, error) { // create a socks5 dialer dialer, err := proxy.SOCKS5("tcp", socksProxy, socksAuth, proxy.Direct) if err != nil { return nil, fmt.Errorf("Can't connect to the prox...
[ "func", "ProxyConnectFunc", "(", "socksProxy", "string", ",", "socksAuth", "*", "proxy", ".", "Auth", ",", "network", ",", "addr", "string", ")", "func", "(", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "return", "func", "(", ")", "(", "net...
// ProxyConnectFunc is a convenience method for returning a function // that connects to a host using SOCKS5 proxy
[ "ProxyConnectFunc", "is", "a", "convenience", "method", "for", "returning", "a", "function", "that", "connects", "to", "a", "host", "using", "SOCKS5", "proxy" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/communicator/ssh/connect.go#L33-L48
165,162
hashicorp/packer
common/net/configure_port.go
Listen
func (lc ListenRangeConfig) Listen(ctx context.Context) (*Listener, error) { if lc.Network == "" { lc.Network = "tcp" } portRange := lc.Max - lc.Min var listener *Listener err := retry.Config{ RetryDelay: func() time.Duration { return 1 * time.Millisecond }, }.Run(ctx, func(context.Context) error { port :...
go
func (lc ListenRangeConfig) Listen(ctx context.Context) (*Listener, error) { if lc.Network == "" { lc.Network = "tcp" } portRange := lc.Max - lc.Min var listener *Listener err := retry.Config{ RetryDelay: func() time.Duration { return 1 * time.Millisecond }, }.Run(ctx, func(context.Context) error { port :...
[ "func", "(", "lc", "ListenRangeConfig", ")", "Listen", "(", "ctx", "context", ".", "Context", ")", "(", "*", "Listener", ",", "error", ")", "{", "if", "lc", ".", "Network", "==", "\"", "\"", "{", "lc", ".", "Network", "=", "\"", "\"", "\n", "}", ...
// Listen tries to Listen to a random open TCP port in the [min, max) range // until ctx is cancelled. // Listen uses net.ListenConfig.Listen internally.
[ "Listen", "tries", "to", "Listen", "to", "a", "random", "open", "TCP", "port", "in", "the", "[", "min", "max", ")", "range", "until", "ctx", "is", "cancelled", ".", "Listen", "uses", "net", ".", "ListenConfig", ".", "Listen", "internally", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/common/net/configure_port.go#L54-L105
165,163
hashicorp/packer
communicator/none/communicator.go
New
func New(config string) (result *comm, err error) { // Establish an initial connection and connect result = &comm{ config: config, } return }
go
func New(config string) (result *comm, err error) { // Establish an initial connection and connect result = &comm{ config: config, } return }
[ "func", "New", "(", "config", "string", ")", "(", "result", "*", "comm", ",", "err", "error", ")", "{", "// Establish an initial connection and connect", "result", "=", "&", "comm", "{", "config", ":", "config", ",", "}", "\n\n", "return", "\n", "}" ]
// Creates a null packer.Communicator implementation. This takes // an already existing configuration.
[ "Creates", "a", "null", "packer", ".", "Communicator", "implementation", ".", "This", "takes", "an", "already", "existing", "configuration", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/communicator/none/communicator.go#L18-L25
165,164
hashicorp/packer
builder/azure/pkcs12/pkcs12.go
unmarshal
func unmarshal(in []byte, out interface{}) error { trailing, err := asn1.Unmarshal(in, out) if err != nil { return err } if len(trailing) != 0 { return errors.New("pkcs12: trailing data found") } return nil }
go
func unmarshal(in []byte, out interface{}) error { trailing, err := asn1.Unmarshal(in, out) if err != nil { return err } if len(trailing) != 0 { return errors.New("pkcs12: trailing data found") } return nil }
[ "func", "unmarshal", "(", "in", "[", "]", "byte", ",", "out", "interface", "{", "}", ")", "error", "{", "trailing", ",", "err", ":=", "asn1", ".", "Unmarshal", "(", "in", ",", "out", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n"...
// unmarshal calls asn1.Unmarshal, but also returns an error if there is any // trailing data after unmarshalling.
[ "unmarshal", "calls", "asn1", ".", "Unmarshal", "but", "also", "returns", "an", "error", "if", "there", "is", "any", "trailing", "data", "after", "unmarshalling", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/pkcs12/pkcs12.go#L96-L105
165,165
hashicorp/packer
builder/azure/pkcs12/pkcs12.go
Decode
func Decode(pfxData []byte, password string) (privateKey interface{}, certificate *x509.Certificate, err error) { encodedPassword, err := bmpString(password) if err != nil { return nil, nil, err } bags, encodedPassword, err := getSafeContents(pfxData, encodedPassword) if err != nil { return nil, nil, err } ...
go
func Decode(pfxData []byte, password string) (privateKey interface{}, certificate *x509.Certificate, err error) { encodedPassword, err := bmpString(password) if err != nil { return nil, nil, err } bags, encodedPassword, err := getSafeContents(pfxData, encodedPassword) if err != nil { return nil, nil, err } ...
[ "func", "Decode", "(", "pfxData", "[", "]", "byte", ",", "password", "string", ")", "(", "privateKey", "interface", "{", "}", ",", "certificate", "*", "x509", ".", "Certificate", ",", "err", "error", ")", "{", "encodedPassword", ",", "err", ":=", "bmpStr...
// Decode extracts a certificate and private key from pfxData. This function // assumes that there is only one certificate and only one private key in the // pfxData.
[ "Decode", "extracts", "a", "certificate", "and", "private", "key", "from", "pfxData", ".", "This", "function", "assumes", "that", "there", "is", "only", "one", "certificate", "and", "only", "one", "private", "key", "in", "the", "pfxData", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/pkcs12/pkcs12.go#L212-L267
165,166
hashicorp/packer
config.go
decodeConfig
func decodeConfig(r io.Reader, c *config) error { decoder := json.NewDecoder(r) return decoder.Decode(c) }
go
func decodeConfig(r io.Reader, c *config) error { decoder := json.NewDecoder(r) return decoder.Decode(c) }
[ "func", "decodeConfig", "(", "r", "io", ".", "Reader", ",", "c", "*", "config", ")", "error", "{", "decoder", ":=", "json", ".", "NewDecoder", "(", "r", ")", "\n", "return", "decoder", ".", "Decode", "(", "c", ")", "\n", "}" ]
// Decodes configuration in JSON format from the given io.Reader into // the config object pointed to.
[ "Decodes", "configuration", "in", "JSON", "format", "from", "the", "given", "io", ".", "Reader", "into", "the", "config", "object", "pointed", "to", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/config.go#L37-L40
165,167
hashicorp/packer
config.go
Discover
func (c *config) Discover() error { // If we are already inside a plugin process we should not need to // discover anything. if os.Getenv(plugin.MagicCookieKey) == plugin.MagicCookieValue { return nil } // First, look in the same directory as the executable. exePath, err := osext.Executable() if err != nil { ...
go
func (c *config) Discover() error { // If we are already inside a plugin process we should not need to // discover anything. if os.Getenv(plugin.MagicCookieKey) == plugin.MagicCookieValue { return nil } // First, look in the same directory as the executable. exePath, err := osext.Executable() if err != nil { ...
[ "func", "(", "c", "*", "config", ")", "Discover", "(", ")", "error", "{", "// If we are already inside a plugin process we should not need to", "// discover anything.", "if", "os", ".", "Getenv", "(", "plugin", ".", "MagicCookieKey", ")", "==", "plugin", ".", "Magic...
// Discover discovers plugins. // // Search the directory of the executable, then the plugins directory, and // finally the CWD, in that order. Any conflicts will overwrite previously // found plugins, in that order. // Hence, the priority order is the reverse of the search order - i.e., the // CWD has the highest prio...
[ "Discover", "discovers", "plugins", ".", "Search", "the", "directory", "of", "the", "executable", "then", "the", "plugins", "directory", "and", "finally", "the", "CWD", "in", "that", "order", ".", "Any", "conflicts", "will", "overwrite", "previously", "found", ...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/config.go#L49-L88
165,168
hashicorp/packer
config.go
LoadBuilder
func (c *config) LoadBuilder(name string) (packer.Builder, error) { log.Printf("Loading builder: %s\n", name) bin, ok := c.Builders[name] if !ok { log.Printf("Builder not found: %s\n", name) return nil, nil } return c.pluginClient(bin).Builder() }
go
func (c *config) LoadBuilder(name string) (packer.Builder, error) { log.Printf("Loading builder: %s\n", name) bin, ok := c.Builders[name] if !ok { log.Printf("Builder not found: %s\n", name) return nil, nil } return c.pluginClient(bin).Builder() }
[ "func", "(", "c", "*", "config", ")", "LoadBuilder", "(", "name", "string", ")", "(", "packer", ".", "Builder", ",", "error", ")", "{", "log", ".", "Printf", "(", "\"", "\\n", "\"", ",", "name", ")", "\n", "bin", ",", "ok", ":=", "c", ".", "Bui...
// This is a proper packer.BuilderFunc that can be used to load packer.Builder // implementations from the defined plugins.
[ "This", "is", "a", "proper", "packer", ".", "BuilderFunc", "that", "can", "be", "used", "to", "load", "packer", ".", "Builder", "implementations", "from", "the", "defined", "plugins", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/config.go#L92-L101
165,169
hashicorp/packer
config.go
LoadHook
func (c *config) LoadHook(name string) (packer.Hook, error) { log.Printf("Loading hook: %s\n", name) return c.pluginClient(name).Hook() }
go
func (c *config) LoadHook(name string) (packer.Hook, error) { log.Printf("Loading hook: %s\n", name) return c.pluginClient(name).Hook() }
[ "func", "(", "c", "*", "config", ")", "LoadHook", "(", "name", "string", ")", "(", "packer", ".", "Hook", ",", "error", ")", "{", "log", ".", "Printf", "(", "\"", "\\n", "\"", ",", "name", ")", "\n", "return", "c", ".", "pluginClient", "(", "name...
// This is a proper implementation of packer.HookFunc that can be used // to load packer.Hook implementations from the defined plugins.
[ "This", "is", "a", "proper", "implementation", "of", "packer", ".", "HookFunc", "that", "can", "be", "used", "to", "load", "packer", ".", "Hook", "implementations", "from", "the", "defined", "plugins", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/config.go#L105-L108
165,170
hashicorp/packer
config.go
LoadPostProcessor
func (c *config) LoadPostProcessor(name string) (packer.PostProcessor, error) { log.Printf("Loading post-processor: %s", name) bin, ok := c.PostProcessors[name] if !ok { log.Printf("Post-processor not found: %s", name) return nil, nil } return c.pluginClient(bin).PostProcessor() }
go
func (c *config) LoadPostProcessor(name string) (packer.PostProcessor, error) { log.Printf("Loading post-processor: %s", name) bin, ok := c.PostProcessors[name] if !ok { log.Printf("Post-processor not found: %s", name) return nil, nil } return c.pluginClient(bin).PostProcessor() }
[ "func", "(", "c", "*", "config", ")", "LoadPostProcessor", "(", "name", "string", ")", "(", "packer", ".", "PostProcessor", ",", "error", ")", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "name", ")", "\n", "bin", ",", "ok", ":=", "c", ".", "...
// This is a proper packer.PostProcessorFunc that can be used to load // packer.PostProcessor implementations from defined plugins.
[ "This", "is", "a", "proper", "packer", ".", "PostProcessorFunc", "that", "can", "be", "used", "to", "load", "packer", ".", "PostProcessor", "implementations", "from", "defined", "plugins", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/config.go#L112-L121
165,171
hashicorp/packer
config.go
LoadProvisioner
func (c *config) LoadProvisioner(name string) (packer.Provisioner, error) { log.Printf("Loading provisioner: %s\n", name) bin, ok := c.Provisioners[name] if !ok { log.Printf("Provisioner not found: %s\n", name) return nil, nil } return c.pluginClient(bin).Provisioner() }
go
func (c *config) LoadProvisioner(name string) (packer.Provisioner, error) { log.Printf("Loading provisioner: %s\n", name) bin, ok := c.Provisioners[name] if !ok { log.Printf("Provisioner not found: %s\n", name) return nil, nil } return c.pluginClient(bin).Provisioner() }
[ "func", "(", "c", "*", "config", ")", "LoadProvisioner", "(", "name", "string", ")", "(", "packer", ".", "Provisioner", ",", "error", ")", "{", "log", ".", "Printf", "(", "\"", "\\n", "\"", ",", "name", ")", "\n", "bin", ",", "ok", ":=", "c", "."...
// This is a proper packer.ProvisionerFunc that can be used to load // packer.Provisioner implementations from defined plugins.
[ "This", "is", "a", "proper", "packer", ".", "ProvisionerFunc", "that", "can", "be", "used", "to", "load", "packer", ".", "Provisioner", "implementations", "from", "defined", "plugins", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/config.go#L125-L134
165,172
hashicorp/packer
builder/googlecompute/builder.go
Run
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { driver, err := NewDriverGCE( ui, b.config.ProjectId, &b.config.Account) if err != nil { return nil, err } // Set up the state. state := new(multistep.BasicStateBag) state.Put("config", b.config) state.Put("...
go
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { driver, err := NewDriverGCE( ui, b.config.ProjectId, &b.config.Account) if err != nil { return nil, err } // Set up the state. state := new(multistep.BasicStateBag) state.Put("config", b.config) state.Put("...
[ "func", "(", "b", "*", "Builder", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "ui", "packer", ".", "Ui", ",", "hook", "packer", ".", "Hook", ")", "(", "packer", ".", "Artifact", ",", "error", ")", "{", "driver", ",", "err", ":=", "New...
// Run executes a googlecompute Packer build and returns a packer.Artifact // representing a GCE machine image.
[ "Run", "executes", "a", "googlecompute", "Packer", "build", "and", "returns", "a", "packer", ".", "Artifact", "representing", "a", "GCE", "machine", "image", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/googlecompute/builder.go#L37-L103
165,173
hashicorp/packer
builder/googlecompute/artifact.go
Destroy
func (a *Artifact) Destroy() error { log.Printf("Destroying image: %s", a.image.Name) errCh := a.driver.DeleteImage(a.image.Name) return <-errCh }
go
func (a *Artifact) Destroy() error { log.Printf("Destroying image: %s", a.image.Name) errCh := a.driver.DeleteImage(a.image.Name) return <-errCh }
[ "func", "(", "a", "*", "Artifact", ")", "Destroy", "(", ")", "error", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "a", ".", "image", ".", "Name", ")", "\n", "errCh", ":=", "a", ".", "driver", ".", "DeleteImage", "(", "a", ".", "image", "."...
// Destroy destroys the GCE image represented by the artifact.
[ "Destroy", "destroys", "the", "GCE", "image", "represented", "by", "the", "artifact", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/googlecompute/artifact.go#L21-L25
165,174
hashicorp/packer
builder/amazon/chroot/device.go
AvailableDevice
func AvailableDevice() (string, error) { prefix, err := devicePrefix() if err != nil { return "", err } letters := "fghijklmnop" for _, letter := range letters { device := fmt.Sprintf("/dev/%s%c", prefix, letter) // If the block device itself, i.e. /dev/sf, exists, then we // can't use any of the numbers...
go
func AvailableDevice() (string, error) { prefix, err := devicePrefix() if err != nil { return "", err } letters := "fghijklmnop" for _, letter := range letters { device := fmt.Sprintf("/dev/%s%c", prefix, letter) // If the block device itself, i.e. /dev/sf, exists, then we // can't use any of the numbers...
[ "func", "AvailableDevice", "(", ")", "(", "string", ",", "error", ")", "{", "prefix", ",", "err", ":=", "devicePrefix", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "letters", ":=", "\"", "\"",...
// AvailableDevice finds an available device and returns it. Note that // you should externally hold a flock or something in order to guarantee // that this device is available across processes.
[ "AvailableDevice", "finds", "an", "available", "device", "and", "returns", "it", ".", "Note", "that", "you", "should", "externally", "hold", "a", "flock", "or", "something", "in", "order", "to", "guarantee", "that", "this", "device", "is", "available", "across...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/amazon/chroot/device.go#L14-L40
165,175
hashicorp/packer
post-processor/vagrant/virtualbox.go
DecompressOva
func DecompressOva(dir, src string) error { log.Printf("Turning ova to dir: %s => %s", src, dir) srcF, err := os.Open(src) if err != nil { return err } defer srcF.Close() tarReader := tar.NewReader(srcF) for { hdr, err := tarReader.Next() if hdr == nil || err == io.EOF { break } if err != nil { ...
go
func DecompressOva(dir, src string) error { log.Printf("Turning ova to dir: %s => %s", src, dir) srcF, err := os.Open(src) if err != nil { return err } defer srcF.Close() tarReader := tar.NewReader(srcF) for { hdr, err := tarReader.Next() if hdr == nil || err == io.EOF { break } if err != nil { ...
[ "func", "DecompressOva", "(", "dir", ",", "src", "string", ")", "error", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "src", ",", "dir", ")", "\n", "srcF", ",", "err", ":=", "os", ".", "Open", "(", "src", ")", "\n", "if", "err", "!=", "nil"...
// DecompressOva takes an ova file and decompresses it into the target // directory.
[ "DecompressOva", "takes", "an", "ova", "file", "and", "decompresses", "it", "into", "the", "target", "directory", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/post-processor/vagrant/virtualbox.go#L122-L173
165,176
hashicorp/packer
helper/common/shared_state.go
sharedStateFilename
func sharedStateFilename(suffix string, buildName string) string { uuid := os.Getenv("PACKER_RUN_UUID") return filepath.Join(os.TempDir(), fmt.Sprintf("packer-%s-%s-%s", uuid, suffix, buildName)) }
go
func sharedStateFilename(suffix string, buildName string) string { uuid := os.Getenv("PACKER_RUN_UUID") return filepath.Join(os.TempDir(), fmt.Sprintf("packer-%s-%s-%s", uuid, suffix, buildName)) }
[ "func", "sharedStateFilename", "(", "suffix", "string", ",", "buildName", "string", ")", "string", "{", "uuid", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "return", "filepath", ".", "Join", "(", "os", ".", "TempDir", "(", ")", ",", "fmt", ...
// Used to set variables which we need to access later in the build, where // state bag and config information won't work
[ "Used", "to", "set", "variables", "which", "we", "need", "to", "access", "later", "in", "the", "build", "where", "state", "bag", "and", "config", "information", "won", "t", "work" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/helper/common/shared_state.go#L12-L15
165,177
hashicorp/packer
builder/parallels/common/ssh_config.go
Prepare
func (c *SSHConfig) Prepare(ctx *interpolate.Context) []error { // TODO: backwards compatibility, write fixer instead if c.SSHWaitTimeout != 0 { c.Comm.SSHTimeout = c.SSHWaitTimeout } return c.Comm.Prepare(ctx) }
go
func (c *SSHConfig) Prepare(ctx *interpolate.Context) []error { // TODO: backwards compatibility, write fixer instead if c.SSHWaitTimeout != 0 { c.Comm.SSHTimeout = c.SSHWaitTimeout } return c.Comm.Prepare(ctx) }
[ "func", "(", "c", "*", "SSHConfig", ")", "Prepare", "(", "ctx", "*", "interpolate", ".", "Context", ")", "[", "]", "error", "{", "// TODO: backwards compatibility, write fixer instead", "if", "c", ".", "SSHWaitTimeout", "!=", "0", "{", "c", ".", "Comm", ".",...
// Prepare sets the default values for SSH communicator properties.
[ "Prepare", "sets", "the", "default", "values", "for", "SSH", "communicator", "properties", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/parallels/common/ssh_config.go#L20-L27
165,178
hashicorp/packer
builder/azure/arm/azure_error_response.go
formatAzureErrorResponse
func formatAzureErrorResponse(error azureErrorDetails, buf *bytes.Buffer, indent string) { if error.isEmpty() { return } buf.WriteString(fmt.Sprintf("ERROR: %s-> %s : %s\n", indent, error.Code, error.Message)) for _, x := range error.Details { newIndent := fmt.Sprintf("%s ", indent) var aer azureErrorRespo...
go
func formatAzureErrorResponse(error azureErrorDetails, buf *bytes.Buffer, indent string) { if error.isEmpty() { return } buf.WriteString(fmt.Sprintf("ERROR: %s-> %s : %s\n", indent, error.Code, error.Message)) for _, x := range error.Details { newIndent := fmt.Sprintf("%s ", indent) var aer azureErrorRespo...
[ "func", "formatAzureErrorResponse", "(", "error", "azureErrorDetails", ",", "buf", "*", "bytes", ".", "Buffer", ",", "indent", "string", ")", "{", "if", "error", ".", "isEmpty", "(", ")", "{", "return", "\n", "}", "\n\n", "buf", ".", "WriteString", "(", ...
// format a Azure Error Response by recursing through the JSON structure. // // Errors may contain nested errors, which are JSON documents that have been // serialized and escaped. Keep following this nesting all the way down...
[ "format", "a", "Azure", "Error", "Response", "by", "recursing", "through", "the", "JSON", "structure", ".", "Errors", "may", "contain", "nested", "errors", "which", "are", "JSON", "documents", "that", "have", "been", "serialized", "and", "escaped", ".", "Keep"...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/arm/azure_error_response.go#L49-L67
165,179
hashicorp/packer
builder/azure/arm/builder.go
setRuntimeParameters
func (b *Builder) setRuntimeParameters(stateBag multistep.StateBag) { stateBag.Put(constants.ArmLocation, b.config.Location) stateBag.Put(constants.ArmManagedImageLocation, b.config.manageImageLocation) }
go
func (b *Builder) setRuntimeParameters(stateBag multistep.StateBag) { stateBag.Put(constants.ArmLocation, b.config.Location) stateBag.Put(constants.ArmManagedImageLocation, b.config.manageImageLocation) }
[ "func", "(", "b", "*", "Builder", ")", "setRuntimeParameters", "(", "stateBag", "multistep", ".", "StateBag", ")", "{", "stateBag", ".", "Put", "(", "constants", ".", "ArmLocation", ",", "b", ".", "config", ".", "Location", ")", "\n", "stateBag", ".", "P...
// Parameters that are only known at runtime after querying Azure.
[ "Parameters", "that", "are", "only", "known", "at", "runtime", "after", "querying", "Azure", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/azure/arm/builder.go#L375-L378
165,180
hashicorp/packer
builder/amazon/common/access_config.go
Session
func (c *AccessConfig) Session() (*session.Session, error) { if c.session != nil { return c.session, nil } config := aws.NewConfig().WithCredentialsChainVerboseErrors(true) staticCreds := credentials.NewStaticCredentials(c.AccessKey, c.SecretKey, c.Token) if _, err := staticCreds.Get(); err != credentials.ErrS...
go
func (c *AccessConfig) Session() (*session.Session, error) { if c.session != nil { return c.session, nil } config := aws.NewConfig().WithCredentialsChainVerboseErrors(true) staticCreds := credentials.NewStaticCredentials(c.AccessKey, c.SecretKey, c.Token) if _, err := staticCreds.Get(); err != credentials.ErrS...
[ "func", "(", "c", "*", "AccessConfig", ")", "Session", "(", ")", "(", "*", "session", ".", "Session", ",", "error", ")", "{", "if", "c", ".", "session", "!=", "nil", "{", "return", "c", ".", "session", ",", "nil", "\n", "}", "\n\n", "config", ":=...
// Config returns a valid aws.Config object for access to AWS services, or // an error if the authentication and region couldn't be resolved
[ "Config", "returns", "a", "valid", "aws", ".", "Config", "object", "for", "access", "to", "AWS", "services", "or", "an", "error", "if", "the", "authentication", "and", "region", "couldn", "t", "be", "resolved" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/amazon/common/access_config.go#L54-L123
165,181
hashicorp/packer
builder/googlecompute/networking.go
getNetworking
func getNetworking(c *InstanceConfig) (string, string, error) { networkId := c.Network subnetworkId := c.Subnetwork // Apply network naming requirements per // https://cloud.google.com/compute/docs/reference/latest/instances#resource switch c.Network { // It is possible to omit the network property as long as a ...
go
func getNetworking(c *InstanceConfig) (string, string, error) { networkId := c.Network subnetworkId := c.Subnetwork // Apply network naming requirements per // https://cloud.google.com/compute/docs/reference/latest/instances#resource switch c.Network { // It is possible to omit the network property as long as a ...
[ "func", "getNetworking", "(", "c", "*", "InstanceConfig", ")", "(", "string", ",", "string", ",", "error", ")", "{", "networkId", ":=", "c", ".", "Network", "\n", "subnetworkId", ":=", "c", ".", "Subnetwork", "\n\n", "// Apply network naming requirements per", ...
// This method will build a network and subnetwork ID from the provided // instance config, and return them in that order.
[ "This", "method", "will", "build", "a", "network", "and", "subnetwork", "ID", "from", "the", "provided", "instance", "config", "and", "return", "them", "in", "that", "order", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/googlecompute/networking.go#L10-L59
165,182
hashicorp/packer
builder/oracle/oci/artifact.go
Destroy
func (a *Artifact) Destroy() error { return a.driver.DeleteImage(context.TODO(), *a.Image.Id) }
go
func (a *Artifact) Destroy() error { return a.driver.DeleteImage(context.TODO(), *a.Image.Id) }
[ "func", "(", "a", "*", "Artifact", ")", "Destroy", "(", ")", "error", "{", "return", "a", ".", "driver", ".", "DeleteImage", "(", "context", ".", "TODO", "(", ")", ",", "*", "a", ".", "Image", ".", "Id", ")", "\n", "}" ]
// Destroy deletes the custom image associated with the artifact.
[ "Destroy", "deletes", "the", "custom", "image", "associated", "with", "the", "artifact", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/oracle/oci/artifact.go#L51-L53
165,183
hashicorp/packer
builder/vmware/common/driver_player5_windows.go
playerVMwareRoot
func playerVMwareRoot() (s string, err error) { key := `SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\vmplayer.exe` subkey := "Path" s, err = readRegString(syscall.HKEY_LOCAL_MACHINE, key, subkey) if err != nil { log.Printf(`Unable to read registry key %s\%s`, key, subkey) return } return normalizePath...
go
func playerVMwareRoot() (s string, err error) { key := `SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\vmplayer.exe` subkey := "Path" s, err = readRegString(syscall.HKEY_LOCAL_MACHINE, key, subkey) if err != nil { log.Printf(`Unable to read registry key %s\%s`, key, subkey) return } return normalizePath...
[ "func", "playerVMwareRoot", "(", ")", "(", "s", "string", ",", "err", "error", ")", "{", "key", ":=", "`SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\vmplayer.exe`", "\n", "subkey", ":=", "\"", "\"", "\n", "s", ",", "err", "=", "readRegString", "(", "...
// This reads the VMware installation path from the Windows registry.
[ "This", "reads", "the", "VMware", "installation", "path", "from", "the", "Windows", "registry", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/common/driver_player5_windows.go#L84-L94
165,184
hashicorp/packer
builder/vmware/common/driver_player5_windows.go
playerProgramFilePaths
func playerProgramFilePaths() []string { path, err := playerVMwareRoot() if err != nil { log.Printf("Error finding VMware root: %s", err) } paths := make([]string, 0, 5) if os.Getenv("VMWARE_HOME") != "" { paths = append(paths, os.Getenv("VMWARE_HOME")) } if path != "" { paths = append(paths, path) } ...
go
func playerProgramFilePaths() []string { path, err := playerVMwareRoot() if err != nil { log.Printf("Error finding VMware root: %s", err) } paths := make([]string, 0, 5) if os.Getenv("VMWARE_HOME") != "" { paths = append(paths, os.Getenv("VMWARE_HOME")) } if path != "" { paths = append(paths, path) } ...
[ "func", "playerProgramFilePaths", "(", ")", "[", "]", "string", "{", "path", ",", "err", ":=", "playerVMwareRoot", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "paths", ":...
// playerProgramFilesPaths returns a list of paths that are eligible // to contain program files we may want just as vmware.exe.
[ "playerProgramFilesPaths", "returns", "a", "list", "of", "paths", "that", "are", "eligible", "to", "contain", "program", "files", "we", "may", "want", "just", "as", "vmware", ".", "exe", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/common/driver_player5_windows.go#L122-L167
165,185
hashicorp/packer
builder/vmware/common/driver_player5_windows.go
playerDataFilePaths
func playerDataFilePaths() []string { leasesPath, err := playerDhcpLeasesPathRegistry() if err != nil { log.Printf("Error getting DHCP leases path: %s", err) } if leasesPath != "" { leasesPath = filepath.Dir(leasesPath) } paths := make([]string, 0, 5) if os.Getenv("VMWARE_DATA") != "" { paths = append(pa...
go
func playerDataFilePaths() []string { leasesPath, err := playerDhcpLeasesPathRegistry() if err != nil { log.Printf("Error getting DHCP leases path: %s", err) } if leasesPath != "" { leasesPath = filepath.Dir(leasesPath) } paths := make([]string, 0, 5) if os.Getenv("VMWARE_DATA") != "" { paths = append(pa...
[ "func", "playerDataFilePaths", "(", ")", "[", "]", "string", "{", "leasesPath", ",", "err", ":=", "playerDhcpLeasesPathRegistry", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", ...
// playerDataFilePaths returns a list of paths that are eligible // to contain data files we may want such as vmnet NAT configuration files.
[ "playerDataFilePaths", "returns", "a", "list", "of", "paths", "that", "are", "eligible", "to", "contain", "data", "files", "we", "may", "want", "such", "as", "vmnet", "NAT", "configuration", "files", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/common/driver_player5_windows.go#L171-L201
165,186
hashicorp/packer
builder/yandex/template_func.go
templateCleanImageName
func templateCleanImageName(s string) string { if reImageFamily.MatchString(s) { return s } b := []byte(strings.ToLower(s)) newb := make([]byte, len(b)) for i := range newb { if isalphanumeric(b[i]) { newb[i] = b[i] } else { newb[i] = '-' } } return string(newb) }
go
func templateCleanImageName(s string) string { if reImageFamily.MatchString(s) { return s } b := []byte(strings.ToLower(s)) newb := make([]byte, len(b)) for i := range newb { if isalphanumeric(b[i]) { newb[i] = b[i] } else { newb[i] = '-' } } return string(newb) }
[ "func", "templateCleanImageName", "(", "s", "string", ")", "string", "{", "if", "reImageFamily", ".", "MatchString", "(", "s", ")", "{", "return", "s", "\n", "}", "\n", "b", ":=", "[", "]", "byte", "(", "strings", ".", "ToLower", "(", "s", ")", ")", ...
// Clean up image name by replacing invalid characters with "-" // and converting upper cases to lower cases
[ "Clean", "up", "image", "name", "by", "replacing", "invalid", "characters", "with", "-", "and", "converting", "upper", "cases", "to", "lower", "cases" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/yandex/template_func.go#L18-L32
165,187
hashicorp/packer
provisioner/shell/unix_reader.go
scanUnixLine
func scanUnixLine(data []byte, atEOF bool) (advance int, token []byte, err error) { advance, token, err = bufio.ScanLines(data, atEOF) if advance == 0 { // If we reached the end of a line without a newline, then // just return as it is. Otherwise the Scanner will keep trying // to scan, blocking forever. retu...
go
func scanUnixLine(data []byte, atEOF bool) (advance int, token []byte, err error) { advance, token, err = bufio.ScanLines(data, atEOF) if advance == 0 { // If we reached the end of a line without a newline, then // just return as it is. Otherwise the Scanner will keep trying // to scan, blocking forever. retu...
[ "func", "scanUnixLine", "(", "data", "[", "]", "byte", ",", "atEOF", "bool", ")", "(", "advance", "int", ",", "token", "[", "]", "byte", ",", "err", "error", ")", "{", "advance", ",", "token", ",", "err", "=", "bufio", ".", "ScanLines", "(", "data"...
// scanUnixLine is a bufio.Scanner SplitFunc. It tokenizes on lines, but // only returns unix-style lines. So even if the line is "one\r\n", the // token returned will be "one\n".
[ "scanUnixLine", "is", "a", "bufio", ".", "Scanner", "SplitFunc", ".", "It", "tokenizes", "on", "lines", "but", "only", "returns", "unix", "-", "style", "lines", ".", "So", "even", "if", "the", "line", "is", "one", "\\", "r", "\\", "n", "the", "token", ...
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/provisioner/shell/unix_reader.go#L55-L65
165,188
hashicorp/packer
builder/yandex/builder.go
Run
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { driver, err := NewDriverYC(ui, b.config) if err != nil { return nil, err } // Set up the state state := &multistep.BasicStateBag{} state.Put("config", b.config) state.Put("driver", driver) state.Put("sdk", ...
go
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { driver, err := NewDriverYC(ui, b.config) if err != nil { return nil, err } // Set up the state state := &multistep.BasicStateBag{} state.Put("config", b.config) state.Put("driver", driver) state.Put("sdk", ...
[ "func", "(", "b", "*", "Builder", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "ui", "packer", ".", "Ui", ",", "hook", "packer", ".", "Hook", ")", "(", "packer", ".", "Artifact", ",", "error", ")", "{", "driver", ",", "err", ":=", "New...
// Run executes a yandex Packer build and returns a packer.Artifact // representing a Yandex.Cloud compute image.
[ "Run", "executes", "a", "yandex", "Packer", "build", "and", "returns", "a", "packer", ".", "Artifact", "representing", "a", "Yandex", ".", "Cloud", "compute", "image", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/yandex/builder.go#L36-L94
165,189
hashicorp/packer
builder/vmware/common/driver_esx5.go
UpdateVMX
func (ESX5Driver) UpdateVMX(_, password string, port int, data map[string]string) { // Do not set remotedisplay.vnc.ip - this breaks ESXi. data["remotedisplay.vnc.enabled"] = "TRUE" data["remotedisplay.vnc.port"] = fmt.Sprintf("%d", port) if len(password) > 0 { data["remotedisplay.vnc.password"] = password } }
go
func (ESX5Driver) UpdateVMX(_, password string, port int, data map[string]string) { // Do not set remotedisplay.vnc.ip - this breaks ESXi. data["remotedisplay.vnc.enabled"] = "TRUE" data["remotedisplay.vnc.port"] = fmt.Sprintf("%d", port) if len(password) > 0 { data["remotedisplay.vnc.password"] = password } }
[ "func", "(", "ESX5Driver", ")", "UpdateVMX", "(", "_", ",", "password", "string", ",", "port", "int", ",", "data", "map", "[", "string", "]", "string", ")", "{", "// Do not set remotedisplay.vnc.ip - this breaks ESXi.", "data", "[", "\"", "\"", "]", "=", "\"...
// UpdateVMX, adds the VNC port to the VMX data.
[ "UpdateVMX", "adds", "the", "VNC", "port", "to", "the", "VMX", "data", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/common/driver_esx5.go#L430-L437
165,190
hashicorp/packer
builder/vmware/common/vmx.go
ParseVMX
func ParseVMX(contents string) map[string]string { results := make(map[string]string) lineRe := regexp.MustCompile(`^(.+?)\s*=\s*"?(.*?)"?\s*$`) for _, line := range strings.Split(contents, "\n") { matches := lineRe.FindStringSubmatch(line) if matches == nil { continue } key := strings.ToLower(matches[...
go
func ParseVMX(contents string) map[string]string { results := make(map[string]string) lineRe := regexp.MustCompile(`^(.+?)\s*=\s*"?(.*?)"?\s*$`) for _, line := range strings.Split(contents, "\n") { matches := lineRe.FindStringSubmatch(line) if matches == nil { continue } key := strings.ToLower(matches[...
[ "func", "ParseVMX", "(", "contents", "string", ")", "map", "[", "string", "]", "string", "{", "results", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n\n", "lineRe", ":=", "regexp", ".", "MustCompile", "(", "`^(.+?)\\s*=\\s*\"?(.*?)\"?\\s*$...
// ParseVMX parses the keys and values from a VMX file and returns // them as a Go map.
[ "ParseVMX", "parses", "the", "keys", "and", "values", "from", "a", "VMX", "file", "and", "returns", "them", "as", "a", "Go", "map", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/common/vmx.go#L17-L33
165,191
hashicorp/packer
builder/vmware/common/vmx.go
EncodeVMX
func EncodeVMX(contents map[string]string) string { var buf bytes.Buffer i := 0 keys := make([]string, len(contents)) for k := range contents { keys[i] = k i++ } // a list of VMX key fragments that the value must not be quoted // fragments are used to cover multiples (i.e. multiple disks) // keys are stil...
go
func EncodeVMX(contents map[string]string) string { var buf bytes.Buffer i := 0 keys := make([]string, len(contents)) for k := range contents { keys[i] = k i++ } // a list of VMX key fragments that the value must not be quoted // fragments are used to cover multiples (i.e. multiple disks) // keys are stil...
[ "func", "EncodeVMX", "(", "contents", "map", "[", "string", "]", "string", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n\n", "i", ":=", "0", "\n", "keys", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "contents", ")", ")",...
// EncodeVMX takes a map and turns it into valid VMX contents.
[ "EncodeVMX", "takes", "a", "map", "and", "turns", "it", "into", "valid", "VMX", "contents", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/common/vmx.go#L36-L78
165,192
hashicorp/packer
builder/vmware/common/vmx.go
WriteVMX
func WriteVMX(path string, data map[string]string) (err error) { log.Printf("Writing VMX to: %s", path) f, err := os.Create(path) if err != nil { return } defer f.Close() var buf bytes.Buffer buf.WriteString(EncodeVMX(data)) if _, err = io.Copy(f, &buf); err != nil { return } return }
go
func WriteVMX(path string, data map[string]string) (err error) { log.Printf("Writing VMX to: %s", path) f, err := os.Create(path) if err != nil { return } defer f.Close() var buf bytes.Buffer buf.WriteString(EncodeVMX(data)) if _, err = io.Copy(f, &buf); err != nil { return } return }
[ "func", "WriteVMX", "(", "path", "string", ",", "data", "map", "[", "string", "]", "string", ")", "(", "err", "error", ")", "{", "log", ".", "Printf", "(", "\"", "\"", ",", "path", ")", "\n", "f", ",", "err", ":=", "os", ".", "Create", "(", "pa...
// WriteVMX takes a path to a VMX file and contents in the form of a // map and writes it out.
[ "WriteVMX", "takes", "a", "path", "to", "a", "VMX", "file", "and", "contents", "in", "the", "form", "of", "a", "map", "and", "writes", "it", "out", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/vmware/common/vmx.go#L82-L97
165,193
hashicorp/packer
template/interpolate/i.go
Render
func Render(v string, ctx *Context) (string, error) { return (&I{Value: v}).Render(ctx) }
go
func Render(v string, ctx *Context) (string, error) { return (&I{Value: v}).Render(ctx) }
[ "func", "Render", "(", "v", "string", ",", "ctx", "*", "Context", ")", "(", "string", ",", "error", ")", "{", "return", "(", "&", "I", "{", "Value", ":", "v", "}", ")", ".", "Render", "(", "ctx", ")", "\n", "}" ]
// Render is shorthand for constructing an I and calling Render.
[ "Render", "is", "shorthand", "for", "constructing", "an", "I", "and", "calling", "Render", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/interpolate/i.go#L40-L42
165,194
hashicorp/packer
template/interpolate/i.go
Validate
func Validate(v string, ctx *Context) error { return (&I{Value: v}).Validate(ctx) }
go
func Validate(v string, ctx *Context) error { return (&I{Value: v}).Validate(ctx) }
[ "func", "Validate", "(", "v", "string", ",", "ctx", "*", "Context", ")", "error", "{", "return", "(", "&", "I", "{", "Value", ":", "v", "}", ")", ".", "Validate", "(", "ctx", ")", "\n", "}" ]
// Validate is shorthand for constructing an I and calling Validate.
[ "Validate", "is", "shorthand", "for", "constructing", "an", "I", "and", "calling", "Validate", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/interpolate/i.go#L45-L47
165,195
hashicorp/packer
template/interpolate/i.go
Render
func (i *I) Render(ictx *Context) (string, error) { tpl, err := i.template(ictx) if err != nil { return "", err } var result bytes.Buffer var data interface{} if ictx != nil { data = ictx.Data } if err := tpl.Execute(&result, data); err != nil { return "", err } return result.String(), nil }
go
func (i *I) Render(ictx *Context) (string, error) { tpl, err := i.template(ictx) if err != nil { return "", err } var result bytes.Buffer var data interface{} if ictx != nil { data = ictx.Data } if err := tpl.Execute(&result, data); err != nil { return "", err } return result.String(), nil }
[ "func", "(", "i", "*", "I", ")", "Render", "(", "ictx", "*", "Context", ")", "(", "string", ",", "error", ")", "{", "tpl", ",", "err", ":=", "i", ".", "template", "(", "ictx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",...
// Render renders the interpolation with the given context.
[ "Render", "renders", "the", "interpolation", "with", "the", "given", "context", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/interpolate/i.go#L56-L72
165,196
hashicorp/packer
template/interpolate/i.go
Validate
func (i *I) Validate(ctx *Context) error { _, err := i.template(ctx) return err }
go
func (i *I) Validate(ctx *Context) error { _, err := i.template(ctx) return err }
[ "func", "(", "i", "*", "I", ")", "Validate", "(", "ctx", "*", "Context", ")", "error", "{", "_", ",", "err", ":=", "i", ".", "template", "(", "ctx", ")", "\n", "return", "err", "\n", "}" ]
// Validate validates that the template is syntactically valid.
[ "Validate", "validates", "that", "the", "template", "is", "syntactically", "valid", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/template/interpolate/i.go#L75-L78
165,197
hashicorp/packer
builder/amazon/chroot/step_register_ami.go
buildBaseRegisterOpts
func buildBaseRegisterOpts(config *Config, sourceImage *ec2.Image, rootVolumeSize int64, snapshotID string) *ec2.RegisterImageInput { var ( mappings []*ec2.BlockDeviceMapping rootDeviceName string ) generatingNewBlockDeviceMappings := config.FromScratch || len(config.AMIMappings) > 0 if generatingNewBloc...
go
func buildBaseRegisterOpts(config *Config, sourceImage *ec2.Image, rootVolumeSize int64, snapshotID string) *ec2.RegisterImageInput { var ( mappings []*ec2.BlockDeviceMapping rootDeviceName string ) generatingNewBlockDeviceMappings := config.FromScratch || len(config.AMIMappings) > 0 if generatingNewBloc...
[ "func", "buildBaseRegisterOpts", "(", "config", "*", "Config", ",", "sourceImage", "*", "ec2", ".", "Image", ",", "rootVolumeSize", "int64", ",", "snapshotID", "string", ")", "*", "ec2", ".", "RegisterImageInput", "{", "var", "(", "mappings", "[", "]", "*", ...
// Builds the base register opts with architecture, name, root block device, mappings, virtualizationtype
[ "Builds", "the", "base", "register", "opts", "with", "architecture", "name", "root", "block", "device", "mappings", "virtualizationtype" ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/amazon/chroot/step_register_ami.go#L77-L128
165,198
hashicorp/packer
helper/ssh/ssh.go
FileSigner
func FileSigner(path string) (ssh.Signer, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() keyBytes, err := ioutil.ReadAll(f) if err != nil { return nil, err } // We parse the private key on our own first so that we can // show a nicer error if the private key has a pass...
go
func FileSigner(path string) (ssh.Signer, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() keyBytes, err := ioutil.ReadAll(f) if err != nil { return nil, err } // We parse the private key on our own first so that we can // show a nicer error if the private key has a pass...
[ "func", "FileSigner", "(", "path", "string", ")", "(", "ssh", ".", "Signer", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", ...
// FileSigner returns an ssh.Signer for a key file.
[ "FileSigner", "returns", "an", "ssh", ".", "Signer", "for", "a", "key", "file", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/helper/ssh/ssh.go#L13-L44
165,199
hashicorp/packer
builder/googlecompute/step_create_instance.go
Run
func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) d := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) sourceImage, err := getImage(c, d) if err != nil { err := fmt.Errorf("Error getting source image for inst...
go
func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) d := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) sourceImage, err := getImage(c, d) if err != nil { err := fmt.Errorf("Error getting source image for inst...
[ "func", "(", "s", "*", "StepCreateInstance", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "state", "multistep", ".", "StateBag", ")", "multistep", ".", "StepAction", "{", "c", ":=", "state", ".", "Get", "(", "\"", "\"", ")", ".", "(", "*",...
// Run executes the Packer build step that creates a GCE instance.
[ "Run", "executes", "the", "Packer", "build", "step", "that", "creates", "a", "GCE", "instance", "." ]
d343852c15da050ee3ad039cc4cadfbf7f9b1759
https://github.com/hashicorp/packer/blob/d343852c15da050ee3ad039cc4cadfbf7f9b1759/builder/googlecompute/step_create_instance.go#L76-L157