id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c165100
end of the string. marshaledPublicKey = bytes.TrimSpace(marshaledPublicKey) if len(strings.TrimSpace(comment)) > 0 { marshaledPublicKey = append(marshaledPublicKey, ' ') marshaledPublicKey = append(marshaledPublicKey, comment...) } return marshaledPublicKey }
c165101
v.Key) } for k, v := range t.Variables { if out.Variables == nil { out.Variables = make(map[string]interface{}) } out.Variables[k] = v } if t.Push.Name != "" { b, _ := json.Marshal(t.Push) var m map[string]interface{} _ = json.Unmarshal(b, &m) out.Push = m } return &out, nil }
c165102
// Flatten Config delete(m, "config") for k, v := range b.Config { out, _ = json.Marshal(v) m[k] = out } return json.Marshal(m) }
c165103
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] = out } return json.Marshal(m) }
c165104
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] = out } return json.Marshal(m) }
c165105
len(o.Except) > 0 { for _, v := range o.Except { if v == n { return true } } return false } return false }
c165106
range o.Except { if _, ok := t.Builders[n]; !ok { err = multierror.Append(err, fmt.Errorf( "'except' specified builder '%s' not found", n)) } } return err }
c165107
err != nil { return err } return interpolate.Validate(string(data), &c.ctx) }
c165108
{ err := os.MkdirAll(dstDir, 0755) if err != nil { return err } } dstF, err := os.Create(dst) if err != nil { return err } defer dstF.Close() if _, err := io.Copy(dstF, srcF); err != nil { return err } return nil }
c165109
// We have to set the Name explicitly because it is supposed to // be a relative path to the root. Otherwise, the tar ends up // being a bunch of files in the root, even if they're actually // nested in a dir in the original "dir" param. header.Name, err = filepath.Rel(dir, path) if err != nil { return er...
c165110
return err } defer f.Close() enc := json.NewEncoder(f) return enc.Encode(contents) } return nil }
c165111
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[8:]) }
c165112
k, v := range ctx.Funcs { result[k] = v } } return template.FuncMap(result) }
c165113
cfg.Tries != 0 && try == cfg.Tries { return &RetryExhaustedError{err} } if err = fn(ctx); err == nil { return nil } if !shouldRetry(err) { return err } log.Print(fmt.Errorf("Retryable error: %s", err)) select { case <-ctx.Done(): return err case <-startTimeout: return err default: ...
c165114
if !strings.ContainsAny(s, random.PossibleUpperCase) { continue } return s } // if an acceptable password cannot be generated in 100 tries, give up return s }
c165115
nil { if vm, ok := ref.(*object.VirtualMachine); ok { return vm.Unregister(context.Background()) } else { return fmt.Errorf("an object name '%v' already exists", name) } } return nil }
c165116
err) state.Put("error", "Can't get the VM switch name") ui.Error(err.Error()) return multistep.ActionHalt } ui.Say("External switch name is: '" + switchName + "'") if switchName != packerExternalSwitchName { s.SwitchName = "" } else { s.SwitchName = packerExternalSwitchName s.oldSwitchName = state.Ge...
c165117
len(c1); idx++ { if len(c1[idx]) == 0 && len(c2[idx]) != 0 { break } if c1[idx] != c2[idx] { return "", fmt.Errorf("Path %s is not prefixed by Base %s", path, base) } } return strings.Join(c2[idx:], string(os.PathSeparator)), nil }
c165118
PrlsrvctlPath: prlsrvctlPath, dhcpLeaseFile: DHCPLeaseFile, }, }, "10": &Parallels10Driver{ Parallels9Driver: Parallels9Driver{ PrlctlPath: prlctlPath, PrlsrvctlPath: prlsrvctlPath, dhcpLeaseFile: DHCPLeaseFile, }, }, "9": &Parallels9Driver{ PrlctlPath: prlctlPath, Prlsrvc...
c165119
log.Printf("Error in Ui.NewTrackProgress RPC call: %s", err) return stream } cli := &ProgressTrackingClient{ id: trackingID, client: u.client, stream: stream, } return cli }
c165120
nil { host = *i.PrivateDnsName } default: panic(fmt.Sprintf("Unknown interface type: %s", sshInterface)) } } else if i.VpcId != nil && *i.VpcId != "" { if i.PublicIpAddress != nil && *i.PublicIpAddress != "" { host = *i.PublicIpAddress } else if i.PrivateIpAddress != nil && *i.P...
c165121
var id uint32 if err := binary.Read(stream, binary.LittleEndian, &id); err != nil { stream.Close() continue } // Initialize the waiter p := m.getStream(id) select { case p.ch <- stream: default: } // Wait for a timeout go m.timeoutWait(id, p) } }
c165122
for scanner.Scan() { ch <- scanner.Text() } }() return ch }
c165123
return nil, fmt.Errorf("Failed to load token from file: %v", err) } spt, err := adal.NewServicePrincipalTokenFromManualToken(oauthCfg, clientID, resource, *token, callback) if err != nil { return nil, fmt.Errorf("Error constructing service principal token: %v", err) } return spt, nil }
c165124
nil, fmt.Errorf("Failed to complete device auth: %v", err) } spt, err := adal.NewServicePrincipalTokenFromManualToken(oauthCfg, clientID, resource, *token) if err != nil { return nil, fmt.Errorf("Error constructing service principal token: %v", err) } return spt, nil }
c165125
} return filepath.Join(dir, ".azure", "packer", fmt.Sprintf("oauth-%s.json", tenantID)) }
c165126
0600, t); err != nil { return err } return nil } }
c165127
read the header if subs.StatusCode != http.StatusUnauthorized { return "", fmt.Errorf("Unexpected response from Get Subscription: %v", err) } hdr := subs.Header.Get(hdrKey) if hdr == "" { return "", fmt.Errorf("Header %v not found in Get Subscription response", hdrKey) } // Example value for hdr: // Bear...
c165128
r := range s { if t, _ := utf16.EncodeRune(r); t != 0xfffd { return nil, errors.New("pkcs12: string contains characters that cannot be encoded in UCS-2") } ret = append(ret, byte(r/256), byte(r%256)) } return append(ret, 0, 0), nil }
c165129
newb[i] = b[i] } else { newb[i] = '-' } } newb = bytes.TrimRight(newb, "-_.") return string(newb) }
c165130
if h > 0 { res = fmt.Sprintf("%s%dH", res, h) } if m > 0 { res = fmt.Sprintf("%s%dM", res, m) } if s > 0 { res = fmt.Sprintf("%s%dS", res, s) } return res }
c165131
target.Name())) bytes, err := io.Copy(target, source) if err != nil { return nil, err } ui.Say(fmt.Sprintf("Copied %d bytes", bytes)) artifact.filename = target.Name() } else { // We're going to write Contents; if it's empty we'll just create an // empty file. err := ioutil.WriteFile(b.config.Targe...
c165132
out while waiting for instance to delete") } } if err != nil { ui.Error(fmt.Sprintf( "Error deleting instance. Please delete it manually.\n\n"+ "Name: %s\n"+ "Error: %s", name, err)) return multistep.ActionHalt } ui.Message("Instance has been deleted!") state.Put("instance_name", "") return mu...
c165133
} if err != nil { ui.Error(fmt.Sprintf( "Error deleting disk. Please delete it manually.\n\n"+ "DiskName: %s\n"+ "Zone: %s\n"+ "Error: %s", config.DiskName, config.Zone, err)) } ui.Message("Disk has been deleted!") return }
c165134
if err = result.reconnect(); err != nil { result = nil return } return }
c165135
c.PrlctlPost = make([][]string, 0) } return nil }
c165136
return d.DeleteImageErr } d.DeleteImageID = id return nil }
c165137
&b.config.Comm, Host: commHost, SSHConfig: b.config.Comm.SSHConfigFunc(), SSHPort: commPort, WinRMPort: commPort, }, &common.StepProvision{}, &common.StepCleanupTempKeys{ Comm: &b.config.Comm, }, &stepShutdownInstance{}, &stepCreateTemplate{}, } // Configure the runner and run th...
c165138
&artifact{ OutputDir: dir, BoxName: "package.box", Provider: provider, } }
c165139
return multistep.ActionHalt } if err := driver.CompactDisk(diskPath); err != nil { state.Put("error", fmt.Errorf("Error compacting disk: %s", err)) ui.Error(err.Error()) return multistep.ActionHalt } return multistep.ActionContinue }
c165140
password := state.Get("winrm_password").(string) return &communicator.WinRMConfig{ Username: config.Comm.WinRMUser, Password: password, }, nil }
c165141
dstDir) if err != nil { return err } err = d.Prlctl("unregister", srcID) if err != nil { return err } err = d.Prlctl("set", name, "--device-set", "net0", "--mac", srcMAC) if err != nil { return err } return nil }
c165142
"compact", "--hdd", diskPath, } if err := exec.Command(prlDiskToolPath, command...).Run(); err != nil { return err } // Remove null blocks command = []string{ "compact", "--buildmap", "--hdd", diskPath, } if err := exec.Command(prlDiskToolPath, command...).Run(); err != nil { return err } return n...
c165143
regexp.MustCompile(`\s+(cdrom\d+)\s+`) matches := deviceRe.FindStringSubmatch(string(out)) if matches == nil { return "", fmt.Errorf( "Could not determine cdrom device name in the output:\n%s", string(out)) } deviceName := matches[1] return deviceName, nil }
c165144
regexp.MustCompile("hdd0.* image='(.*)' type=*") matches := HDDRe.FindStringSubmatch(string(out)) if matches == nil { return "", fmt.Errorf( "Could not determine hdd image path in the output:\n%s", string(out)) } HDDPath := matches[1] return HDDPath, nil }
c165145
} log.Printf("Checking VM state: %s\n", strings.TrimSpace(stdout.String())) for _, line := range strings.Split(stdout.String(), "\n") { if line == "running" { return true, nil } if line == "suspended" { return true, nil } if line == "paused" { return true, nil } if line == "stopping" { r...
c165146
little bit to let the session "unlock" time.Sleep(2 * time.Second) return nil }
c165147
(\d+\.\d+.\d+)`) matches := versionRe.FindStringSubmatch(string(out)) if matches == nil { return "", fmt.Errorf( "Could not find Parallels Desktop version in output:\n%s", string(out)) } version := matches[1] return version, nil }
c165148
macMatch := re.FindAllStringSubmatch(stdoutString, 1) if len(macMatch) != 1 { return "", fmt.Errorf("MAC address for NIC: nic0 on Virtual Machine: %s not found!\n", vmName) } mac := macMatch[0][1] log.Printf("Found MAC address for NIC: net0 - %s\n", mac) return mac, nil }
c165149
if i+shift == len(a) { break } shift++ } return a[:shift] + b }
c165150
wrapConfig.Handler = panicHandler(logTempFile) wrapConfig.Writer = io.MultiWriter(logTempFile, &packer.LogSecretFilter) wrapConfig.Stdout = outW wrapConfig.DetectDuration = 500 * time.Millisecond wrapConfig.ForwardSignals = []os.Signal{syscall.SIGTERM} exitStatus, err := panicwrap.Wrap(&wrapConfig) if err...
c165151
err := tty.Open(); err != nil { fmt.Fprintf(os.Stderr, "No tty available: %s\n", err) } else { basicUi.TTY = TTY defer TTY.Close() } } } // Create the CLI meta CommandMeta = &command.Meta{ CoreConfig: &packer.CoreConfig{ Components: packer.ComponentFinder{ Builder: config.LoadBuil...
c165152
for _, item := range exclude { excludes[item] = nil } // Create filtered list of commands helpCommands := []string{} for command := range commands { if _, found := excludes[command]; !found { helpCommands = append(helpCommands, command) } } return cli.FilteredHelpFunc(helpCommands, cli.BasicHelpFunc("...
c165153
copy(result, args[:i]) copy(result[i:], args[i+1:]) return result, true } } return args, false }
c165154
if region == "" { continue } found := false for _, validRegion := range validRegions { if region == validRegion { found = true break } } if !found { invalidRegions = append(invalidRegions, region) } } if len(invalidRegions) > 0 { return fmt.Errorf("Invalid region(s): %v, available ...
c165155
matches == nil { return fmt.Errorf( "Could not determine your Parallels Desktop edition using: %s info --license", d.PrlsrvctlPath) } switch matches[1] { case "pro", "business": break default: return fmt.Errorf("Packer can be used only with Parallels Desktop 11 Pro or Business edition. You use: %s edition...
c165156
if path != "" { paths = append(paths, path) } if os.Getenv("ProgramFiles(x86)") != "" { paths = append(paths, filepath.Join(os.Getenv("ProgramFiles(x86)"), "/VMware/VMware Workstation")) } if os.Getenv("ProgramFiles") != "" { paths = append(paths, filepath.Join(os.Getenv("ProgramFiles"), "/VMware/V...
c165157
= append(paths, filepath.Join(os.Getenv("ProgramData"), "/VMware")) } if os.Getenv("ALLUSERSPROFILE") != "" { paths = append(paths, filepath.Join(os.Getenv("ALLUSERSPROFILE"), "/Application Data/VMware")) } return paths }
c165158
aws.String(accountId), }, } resp, err := service.GetAuthorizationToken(params) if err != nil { return "", "", fmt.Errorf(err.Error()) } auth, err := base64.StdEncoding.DecodeString(*resp.AuthorizationData[0].AuthorizationToken) if err != nil { return "", "", fmt.Errorf("Error decoding ECR AuthorizationT...
c165159
return rawConfigurationProvider{tenancy, user, region, fingerprint, privateKey, privateKeyPassphrase} }
c165160
} client.AppendUserAgent(Packer, version.FormattedVersion()) client.SetReadTimeout(DefaultRequestReadTimeout) c.client = &ClientWrapper{client} return c.client, nil }
c165161
return nil, fmt.Errorf("Can't connect to the proxy: %s", err) } c, err := dialer.Dial(network, addr) if err != nil { return nil, err } return c, nil } }
c165162
err := lock.Unlock(); err != nil { log.Fatalf("Could not unlock file lock for port %d: %v", port, err) } return &ErrPortBusy{ Port: port, Err: err, } } log.Printf("Found available port: %d on IP: %s", port, lc.Addr) listener = &Listener{ Address: lc.Addr, Port: port, Listener...
c165163
connect result = &comm{ config: config, } return }
c165164
{ return errors.New("pkcs12: trailing data found") } return nil }
c165165
err = errors.New("pkcs12: expected exactly one certificate in the certBag") return nil, nil, err } certificate = certs[0] case bag.Id.Equal(oidPKCS8ShroudedKeyBag): if privateKey != nil { err = errors.New("pkcs12: expected exactly one key bag") } if privateKey, err = decodePkcs8ShroudedKeyBa...
c165166
json.NewDecoder(r) return decoder.Decode(c) }
c165167
log.Printf("[ERR] Error loading config directory: %s", err) } else { if err := c.discover(filepath.Join(dir, "plugins")); err != nil { return err } } // Next, look in the CWD. if err := c.discover("."); err != nil { return err } // Finally, try to use an internal plugin. Note that this will not overr...
c165168
{ log.Printf("Builder not found: %s\n", name) return nil, nil } return c.pluginClient(bin).Builder() }
c165169
%s\n", name) return c.pluginClient(name).Hook() }
c165170
!ok { log.Printf("Post-processor not found: %s", name) return nil, nil } return c.pluginClient(bin).PostProcessor() }
c165171
{ log.Printf("Provisioner not found: %s\n", name) return nil, nil } return c.pluginClient(bin).Provisioner() }
c165172
}, } if _, exists := b.config.Metadata[StartupScriptKey]; exists || b.config.StartupScriptFile != "" { steps = append(steps, new(StepWaitStartupScript)) } steps = append(steps, new(StepTeardownInstance), new(StepCreateImage)) // Run the steps. b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) b.r...
c165173
errCh := a.driver.DeleteImage(a.image.Name) return <-errCh }
c165174
the unnumbered // device and the first numbered one must be available. // E.g. /dev/xvdf and /dev/xvdf1 numbered_device := fmt.Sprintf("%s%d", device, 1) if _, err := os.Stat(numbered_device); err != nil { return device, nil } } return "", errors.New("available device could not be found") }
c165175
defers // inside are handled more quickly so we can give up file handles. err = func() error { path := filepath.Join(dir, info.Name()) output, err := os.Create(path) if err != nil { return err } defer output.Close() os.Chmod(path, info.Mode()) os.Chtimes(path, hdr.AccessTime, hdr.ModTime)...
c165176
filepath.Join(os.TempDir(), fmt.Sprintf("packer-%s-%s-%s", uuid, suffix, buildName)) }
c165177
c.Comm.SSHTimeout = c.SSHWaitTimeout } return c.Comm.Prepare(ctx) }
c165178
fmt.Sprintf("%s ", indent) var aer azureErrorResponse err := json.Unmarshal([]byte(x.Message), &aer) if err == nil { buf.WriteString(fmt.Sprintf("ERROR: %s-> %s\n", newIndent, x.Code)) formatAzureErrorResponse(aer.ErrorDetails, buf, newIndent) } else { buf.WriteString(fmt.Sprintf("ERROR: %s-> %s : %...
c165179
stateBag.Put(constants.ArmManagedImageLocation, b.config.manageImageLocation) }
c165180
session.NewSessionWithOptions(opts) if err != nil { return nil, err } log.Printf("Found region %s", *sess.Config.Region) c.session = sess cp, err := c.session.Config.Credentials.Get() if err != nil { if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "NoCredentialProviders" { return nil, fmt.Err...
c165181
// An empty subnetwork is only valid for networks in legacy mode or // auto-subnet mode. We could make an API call to get that information // about the network, but it's common for the caller to not have // permission to that API. We'll proceed assuming they're correct in // omitting the subnetwork and let t...
c165182
a.driver.DeleteImage(context.TODO(), *a.Image.Id) }
c165183
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(s), nil }
c165184
os.Getenv("QEMU_HOME")) } if os.Getenv("ProgramFiles(x86)") != "" { paths = append(paths, filepath.Join(os.Getenv("ProgramFiles(x86)"), "/QEMU")) } if os.Getenv("ProgramFiles") != "" { paths = append(paths, filepath.Join(os.Getenv("ProgramFiles"), "/QEMU")) } if os.Getenv("SystemDrive") != "" { pa...
c165185
= append(paths, filepath.Join(os.Getenv("ProgramData"), "/VMware")) } if os.Getenv("ALLUSERSPROFILE") != "" { paths = append(paths, filepath.Join(os.Getenv("ALLUSERSPROFILE"), "/Application Data/VMware")) } return paths }
c165186
newb := make([]byte, len(b)) for i := range newb { if isalphanumeric(b[i]) { newb[i] = b[i] } else { newb[i] = '-' } } return string(newb) }
c165187
// just return as it is. Otherwise the Scanner will keep trying // to scan, blocking forever. return } return advance, append(token, '\n'), err }
c165188
} // Run the steps b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // Report any errors if rawErr, ok := state.GetOk("error"); ok { return nil, rawErr.(error) } image, ok := state.GetOk("image") if !ok { return nil, fmt.Errorf("Failed to find 'image' in state. Bug...
c165189
ESXi. data["remotedisplay.vnc.enabled"] = "TRUE" data["remotedisplay.vnc.port"] = fmt.Sprintf("%d", port) if len(password) > 0 { data["remotedisplay.vnc.password"] = password } }
c165190
_, line := range strings.Split(contents, "\n") { matches := lineRe.FindStringSubmatch(line) if matches == nil { continue } key := strings.ToLower(matches[1]) results[key] = matches[2] } return results }
c165191
// a list of VMX key fragments that are case sensitive // fragments are used to cover multiples (i.e. multiple disks) caseSensitive := []string{ ".virtualSSD", } sort.Strings(keys) for _, k := range keys { pat := "%s = \"%s\"\n" // items with no quotes for _, q := range noQuotes { if strings.Contains(...
c165192
bytes.Buffer buf.WriteString(EncodeVMX(data)) if _, err = io.Copy(f, &buf); err != nil { return } return }
c165193
(&I{Value: v}).Render(ctx) }
c165194
(&I{Value: v}).Validate(ctx) }
c165195
} if err := tpl.Execute(&result, data); err != nil { return "", err } return result.String(), nil }
c165196
err := i.template(ctx) return err }
c165197
from a snapshot, so we unset the Encrypted field if set, // otherwise AWS API will return InvalidParameter if newDevice.Ebs != nil && newDevice.Ebs.Encrypted != nil { newDevice.Ebs.Encrypted = nil } newMappings[i] = newDevice } if config.FromScratch { return &ec2.RegisterImageInput{ Name: ...
c165198
return nil, fmt.Errorf( "Failed to read key '%s': password protected keys are\n"+ "not supported. Please decrypt the key prior to use.", path) } signer, err := ssh.ParsePrivateKey(keyBytes) if err != nil { return nil, fmt.Errorf("Error setting up SSH config: %s", err) } return signer, nil }
c165199
c.Region, ServiceAccountEmail: c.ServiceAccountEmail, Scopes: c.Scopes, Subnetwork: c.Subnetwork, Tags: c.Tags, Zone: c.Zone, }) if err == nil { ui.Message("Waiting for creation operati...