id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c168200
return ip, nil } time.Sleep(1 * time.Second) } }
c168201
if s != state.Running { return nil } time.Sleep(1 * time.Second) } }
c168202
err != nil { return err } d.IPAddress = ip return nil }
c168203
!= nil { return err } if err := d.waitStopped(); err != nil { return err } d.IPAddress = "" return nil }
c168204
err } } return cmd("Hyper-V\\Remove-VM", d.MachineName, "-Force") }
c168205
{ return "", err } file.Close() if err := cmd("Hyper-V\\Convert-VHD", "-Path", quote(fixed), "-DestinationPath", quote(diskImage), "-VHDType", "Dynamic", "-DeleteSource"); err != nil { return "", err } if isWindowsAdmin { if err := cmd("Hyper-V\\Resize-VHD", "-Path", quote(diskImage), "-SizeBytes", toMb(d...
c168206
== "" { return "", errors.New("IP address is not set") } return d.IPAddress, nil }
c168207
== "" { d.SSHKeyPath = d.ResolveStorePath("id_rsa") } return d.SSHKeyPath }
c168208
d.SSHPort == 0 { d.SSHPort = DefaultSSHPort } return d.SSHPort, nil }
c168209
d.SSHUser == "" { d.SSHUser = DefaultSSHUser } return d.SSHUser }
c168210
{ return filepath.Join(d.StorePath, "machines", d.MachineName, file) }
c168211
= flags.String("swarm-host") d.SwarmDiscovery = flags.String("swarm-discovery") }
c168212
nil } if strings.Contains(line, "VERR_VMX_UNABLE_TO_START_VM") { return true, nil } if strings.Contains(line, "Power up failed") && strings.Contains(line, "VERR_VMX_NO_VMX") { return true, nil } } return false, nil }
c168213
} t := tags[0] if t.TagName == "" { return "", errGitHubAPIResponse } return t.TagName, nil } // Otherwise, we get back just one release, which we can decode to get // the tag. var t struct { TagName string `json:"tag_name"` } if err := json.NewDecoder(rsp.Body).Decode(&t); err != nil { return "...
c168214
return apiURL, nil } scheme, host, org, repo := matches[1], matches[2], matches[4], matches[5] if host == "api.github.com" { host = "github.com" } tag, err := b.getReleaseTag(apiURL) if err != nil { return "", err } log.Infof("Latest release for %s/%s/%s is %s", host, org, repo, tag) bugURL, ok := AUFS...
c168215
versionIndex := strings.Index(trimmedVersion, versionPrefix) if versionIndex == -1 { return "", fmt.Errorf("Did not find prefix %q in version string", versionPrefix) } // Original magic file string looks similar to this: "Boot2Docker-v0.1.0 " // This will return "v0.1.0" given the above string v...
c168216
%s...", b.path(), isoURL) return b.download(dir, file, isoURL) }
c168217
Username: d.Username, APIKey: apiKey, } provider, err := rackspace.NewClient(rackspace.RackspaceUSIdentity) if err != nil { return err } provider.UserAgent.Prepend(fmt.Sprintf("docker-machine/v%d", version.APIVersion)) err = rackspace.Authenticate(provider, opts) if err != nil { return err } c.Pro...
c168218
{ Network: "public", Address: server.AccessIPv4, AddressType: openstack.Fixed, }, }, nil }
c168219
} if defaultExists { return defaultMachineName, nil } return "", ErrNoDefault } return c.Args()[0], nil }
c168220
host.Start, "stop": host.Stop, "restart": host.Restart, "kill": host.Kill, "upgrade": host.Upgrade, "ip": printIP(host), "provision": host.Provision, } log.Debugf("command=%s machine=%s", actionName, host.Name) errorChan <- comma...
c168221
of these // at a time, since otherwise cloud providers might // rate limit us. for i := 0; i < numConcurrentActions; i++ { if err := <-errorChan; err != nil { errs = append(errs, err) } } close(errorChan) return errs }
c168222
before attempting creation: %s", err) } log.Info("Creating machine...") if err := api.performCreate(h); err != nil { return fmt.Errorf("Error creating machine: %s", err) } log.Debug("Reticulating splines...") return nil }
c168223
// if we try to parse the truncated for as an int and we don't have // an error then the value is all numeric and causes issues when // used as a hostname. ref #3869 if _, err := strconv.ParseInt(TruncateID(value), 10, 64); err == nil { continue } return value } }
c168224
mcnflag.StringFlag{ EnvVar: "OS_SSH_USER", Name: "rackspace-ssh-user", Usage: "SSH user for the newly booted machine. Set to root by default", Value: defaultSSHUser, }, mcnflag.IntFlag{ EnvVar: "OS_SSH_PORT", Name: "rackspace-ssh-port", Usage: "SSH port for the newly booted machine. Se...
c168225
:= &Driver{ Driver: inner, } inner.SetClient(&Client{ driver: driver, }) return driver }
c168226
== "" { return missingEnvOrOption("Region", "OS_REGION_NAME", "--rackspace-region") } if d.Username == "" { return missingEnvOrOption("Username", "OS_USERNAME", "--rackspace-username") } if d.APIKey == "" { return missingEnvOrOption("API key", "OS_API_KEY", "--rackspace-api-key") } if d.ImageId == "" { ...
c168227
== "" { return "", fmt.Errorf("Docker Host URL not set") } return rd.HostURL, nil }
c168228
nil, fmt.Errorf("Failed to authenticate using service principal credentials: %+v", err) } } else { // use browser-based device auth log.Debug("Using Azure device flow authentication.") token, err = azureutil.AuthenticateDeviceFlow(env, d.SubscriptionID) if err != nil { return nil, fmt.Errorf("Error creatin...
c168229
!= nil { return err } log.Debug("SSH key pair generated.") publicKey, err := ioutil.ReadFile(pubPath) ctx.SSHPublicKey = string(publicKey) return err }
c168230
return network.Asterisk, nil default: return "", fmt.Errorf("invalid protocol %s", proto) } }
c168231
return states[s] } return "" }
c168232
{ b[i] = alphabet[r.Intn(len(alphabet))] } return string(b) }
c168233
Name: "vmwarevsphere-folder", Usage: "vSphere folder for the docker VM. This folder must already exist in the datacenter.", }, mcnflag.StringFlag{ EnvVar: "VSPHERE_POOL", Name: "vmwarevsphere-pool", Usage: "vSphere resource pool for docker VM", }, mcnflag.StringFlag{ EnvVar: "VSPHERE_HOSTS...
c168234
:= tw.Write([]byte(magicString)); err != nil { return err } // .ssh/key.pub => authorized_keys file = &tar.Header{Name: ".ssh", Typeflag: tar.TypeDir, Mode: 0700} if err := tw.WriteHeader(file); err != nil { return err } pubKey, err := ioutil.ReadFile(d.publicSSHKeyPath()) if err != nil { return err } f...
c168235
HostOnlyCIDR: defaultHostOnlyCIDR, HostOnlyNicType: defaultHostOnlyNictype, HostOnlyPromiscMode: defaultHostOnlyPromiscMode, UIType: defaultUIType, HostOnlyNoDHCP: defaultHostOnlyNoDHCP, DNSProxy: defaultDNSProxy, HostDNSResolver: defaultDNSResolver, BaseDriver...
c168236
to make sure // that a download failure will not leave a machine half created. if err := d.b2dUpdater.UpdateISOCache(d.StorePath, d.Boot2DockerURL); err != nil { return err } // Check that Host-only interfaces are ok if _, err = listHostOnlyAdapters(d.VBoxManager); err != nil { return err } return nil }
c168237
hostOnlyByCIDR[ipnet.String()] = n } m, err := listHostInterfaces(hif, hostOnlyByCIDR) if err != nil { return err } collision, err := checkIPNetCollision(hostOnlyNet, m) if err != nil { return err } if collision { return ErrNetworkAddrCollision } return nil }
c168238
port = p return port, nil } port = 0 // Throw away the port hint before trying again time.Sleep(1) } return 0, fmt.Errorf("unable to allocate tcp port") }
c168239
desiredHostPort, actualHostPort) } cmd := fmt.Sprintf("--natpf%d", interfaceNum) d.vbm("modifyvm", d.MachineName, cmd, "delete", mapName) if err := d.vbm("modifyvm", d.MachineName, cmd, fmt.Sprintf("%s,%s,127.0.0.1,%d,,%d", mapName, protocol, actualHostPort, guestPort)); err != nil { return -1, err } return ...
c168240
net.IPv4(nAddr[0], nAddr[1], nAddr[2], byte(n)) break } } if dhcpAddr == nil { return nil, ErrUnableToGenerateRandomIP } return dhcpAddr, nil }
c168241
shell you're using, with the --shell flag.\n\n") return "", ErrUnknownShell } return filepath.Base(shell), nil }
c168242
if vaultSecretRenewable(s) { // Renew at 1/3 the remaining lease. This will give us an opportunity to retry // at least one more time should the first renewal fail. sleep = sleep / 3.0 // Use some randomness so many clients do not hit Vault simultaneously. sleep = sleep * (rand.Float64() + 1) / 2.0 } else ...
c168243
log.Printf("[WARN] %s: %s", d, w) } }
c168244
s.Auth != nil { return s.Auth.Renewable } return s.Renewable }
c168245
Secret updateSecret(&ours, theirs) return &ours }
c168246
theirs.Auth.Renewable { ours.Auth.Renewable = theirs.Auth.Renewable } } if theirs.WrapInfo != nil { if ours.WrapInfo == nil { ours.WrapInfo = &SecretWrapInfo{} } if theirs.WrapInfo.Token != "" { ours.WrapInfo.Token = theirs.WrapInfo.Token } if theirs.WrapInfo.TTL != 0 { ours.WrapInfo.TTL =...
c168247
return fmt.Sprintf("%q => %q", StringVal(source), StringVal(c.Destination), ) }
c168248
return &VaultWriteQuery{ stopCh: make(chan struct{}, 1), path: s, data: d, dataHash: sha1Map(d), }, nil }
c168249
io.WriteString(h, fmt.Sprintf("%s=%q", k, m[k])) } return fmt.Sprintf("%.4x", h.Sum(nil)) }
c168250
retryFunc: i.RetryFunc, stopCh: make(chan struct{}, 1), vaultGrace: i.VaultGrace, }, nil }
c168251
v.dataLock.RUnlock() return v.data }
c168252
defer v.dataLock.RUnlock() return v.data, v.lastIndex }
c168253
log.Printf("[TRACE] (view) %s successful contact, resetting retries", v.dependency) retries = 0 goto WAIT case err := <-fetchErrCh: if v.retryFunc != nil { retry, sleep := v.retryFunc(retries) if retry { log.Printf("[WARN] (view) %s (retry attempt %d after %q)", err, retries+1, sleep) ...
c168254
same)", v.dependency) continue } v.dataLock.Lock() if rm.LastIndex < v.lastIndex { log.Printf("[TRACE] (view) %s had a lower index, resetting", v.dependency) v.lastIndex = 0 v.dataLock.Unlock() continue } v.lastIndex = rm.LastIndex if v.receivedData && reflect.DeepEqual(data, v.data) { ...
c168255
:= regexpMatch(CatalogNodeQueryRe, s) return &CatalogNodeQuery{ dc: m["dc"], name: m["name"], stopCh: make(chan struct{}, 1), }, nil }
c168256
response", d) rm := &ResponseMetadata{ LastIndex: qm.LastIndex, LastContact: qm.LastContact, } if node == nil { log.Printf("[WARN] %s: no node exists with the name %q", d, name) var node CatalogNode return &node, rm, nil } services := make([]*CatalogNodeService, 0, len(node.Services)) for _, v := ...
c168257
!= nil { return fmt.Sprintf("%s:%s", StringVal(c.Username), StringVal(c.Password)) } return StringVal(c.Username) }
c168258
return &VaultListQuery{ stopCh: make(chan struct{}, 1), path: s, }, nil }
c168259
b.data[d.String()] = data b.receivedData[d.String()] = struct{}{} }
c168260
if _, ok := b.receivedData[d.String()]; !ok { return nil, false } return b.data[d.String()], true }
c168261
b.Lock() defer b.Unlock() b.data[hashCode] = data b.receivedData[hashCode] = struct{}{} }
c168262
d.String()) delete(b.receivedData, d.String()) }
c168263
{ return &CatalogDatacentersQuery{ ignoreFailing: ignoreFailing, stopCh: make(chan struct{}, 1), }, nil }
c168264
nil, errors.Wrapf(err, d.String()) } // If the user opted in for skipping "down" datacenters, figure out which // datacenters are down. if d.ignoreFailing { dcs := make([]string, 0, len(result)) for _, dc := range result { if _, _, err := clients.Consul().Catalog().Services(&api.QueryOptions{ Datacente...
c168265
:= regexpMatch(CatalogNodesQueryRe, s) return &CatalogNodesQuery{ dc: m["dc"], near: m["near"], stopCh: make(chan struct{}, 1), }, nil }
c168266
node.Node, Address: node.Address, Datacenter: node.Datacenter, TaggedAddresses: node.TaggedAddresses, Meta: node.Meta, }) } // Sort unless the user explicitly asked for nearness if d.near == "" { sort.Stable(ByNode(nodes)) } rm := &ResponseMetadata{ LastIndex: qm...
c168267
signal %q - valid signals are %q", s, ValidSignals) } return sig, nil }
c168268
DefaultSSLConfig(), Transport: DefaultTransportConfig(), } // Force SSL when communicating with Vault. v.SSL.Enabled = Bool(true) return v }
c168269
contents, err := ioutil.ReadFile(i.Source) if err != nil { return nil, errors.Wrap(err, "failed to read template") } t.contents = string(contents) } // Compute the MD5, encode as hex hash := md5.Sum([]byte(t.contents)) t.hexMD5 = hex.EncodeToString(hash[:]) return &t, nil }
c168270
errors.Wrap(err, "parse") } // Execute the template into the writer var b bytes.Buffer if err := tmpl.Execute(&b, nil); err != nil { return nil, errors.Wrap(err, "execute") } return &ExecuteResult{ Used: &used, Missing: &missing, Output: b.Bytes(), }, nil }
c168271
"indent": indent, "loop": loop, "join": join, "trimSpace": trimSpace, "parseBool": parseBool, "parseFloat": parseFloat, "parseInt": parseInt, "parseJSON": parseJSON, "parseUint": parseUint, "plugin": plugin, "regexReplaceAl...
c168272
return data, nil } if t != reflect.TypeOf(os.FileMode(0)) { return data, nil } // Convert it by parsing v, err := strconv.ParseUint(data.(string), 8, 12) if err != nil { return data, err } return os.FileMode(v), nil } }
c168273
if t != reflect.TypeOf(WaitConfig{}) { return data, nil } // Convert it by parsing return ParseWaitConfig(data.(string)) } }
c168274
"Update your configuration files and change consul = \"\" to " + "consul { } instead.") return &ConsulConfig{ Address: String(data.(string)), }, nil } return data, nil } }
c168275
_, ok := s.values[k] return ok }
c168276
defer s.RUnlock() return s.values[k] }
c168277
{ s.init() s.Lock() defer s.Unlock() s.values[k] = v return "" }
c168278
ok := s.values[k]; !ok { s.values[k] = v } return "" }
c168279
s.Unlock() return s.mapSet(k, mk, v, true) }
c168280
s.Unlock() return s.mapSet(k, mk, v, false) }
c168281
} typed, ok := s.values[k].(map[string]interface{}) if !ok { return "", fmt.Errorf("%q is not a map", k) } if _, ok := typed[mk]; o || !ok { typed[mk] = v } return "", nil }
c168282
!ok { return nil, nil } keys := make([]string, 0, len(typed)) for k := range typed { keys = append(keys, k) } sort.Strings(keys) sorted := make([]interface{}, len(keys)) for i, k := range keys { sorted[i] = typed[k] } return sorted, nil }
c168283
== nil { s.values = make(map[string]interface{}) } }
c168284
if err := AtomicWrite(i.Path, i.CreateDestDirs, i.Contents, i.Perms, i.Backup); err != nil { return nil, errors.Wrap(err, "failed writing file") } } return &RenderResult{ DidRender: true, WouldRender: true, Contents: i.Contents, }, nil }
c168285
if err != nil { return err } if _, err := io.Copy(d, s); err != nil { d.Close() return err } if err := d.Close(); err != nil { return err } // io.Copy can restrict file permissions based on umask. return os.Chmod(dst, stat.Mode()) }
c168286
o.LogLevel = c.LogLevel o.MaxStale = c.MaxStale o.PidFile = c.PidFile o.ReloadSignal = c.ReloadSignal if c.Syslog != nil { o.Syslog = c.Syslog.Copy() } if c.Templates != nil { o.Templates = c.Templates.Copy() } if c.Vault != nil { o.Vault = c.Vault.Copy() } if c.Wait != nil { o.Wait = c.Wait...
c168287
r.KillSignal = o.KillSignal } if o.LogLevel != nil { r.LogLevel = o.LogLevel } if o.MaxStale != nil { r.MaxStale = o.MaxStale } if o.PidFile != nil { r.PidFile = o.PidFile } if o.ReloadSignal != nil { r.ReloadSignal = o.ReloadSignal } if o.Syslog != nil { r.Syslog = r.Syslog.Merge(o.Syslog) ...
c168288
Config // Use mapstructure to populate the basic config fields var md mapstructure.Metadata decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ DecodeHook: mapstructure.ComposeDecodeHookFunc( ConsulStringToStructFunc(), StringToFileModeFunc(), signals.StringToSignalFunc(), StringToWa...
c168289
log.Fatal(err) } return c }
c168290
:= Parse(string(c)) if err != nil { return nil, errors.Wrap(err, "from file: "+path) } return config, nil }
c168291
err != nil { return err } // Do nothing for directories if info.IsDir() { return nil } // Parse and merge the config newConfig, err := FromFile(path) if err != nil { return err } c = c.Merge(newConfig) return nil }) if err != nil { return nil, errors.Wrap(err, "walk...
c168292
DefaultExecConfig(), Syslog: DefaultSyslogConfig(), Templates: DefaultTemplateConfigs(), Vault: DefaultVaultConfig(), Wait: DefaultWaitConfig(), } }
c168293
i.VaultGrace, } // Start a watcher for the Vault renew if that config was specified if i.RenewVault { vt, err := dep.NewVaultTokenQuery(i.VaultToken) if err != nil { return nil, errors.Wrap(err, "watcher") } if _, err := w.Add(vt); err != nil { return nil, errors.Wrap(err, "watcher") } } if...
c168294
:= w.depViewMap[d.String()] return ok }
c168295
w.depViewMap[d.String()] = nil } else { delete(w.depViewMap, d.String()) } }
c168296
{ log.Printf("[TRACE] (watcher) actually removing %s", d) view.stop() delete(w.depViewMap, d.String()) return true } log.Printf("[TRACE] (watcher) %s did not exist, skipping", d) return false }
c168297
return len(w.depViewMap) }
c168298
view.stop() } // Reset the map to have no views w.depViewMap = make(map[string]*View) // Close any idle TCP connections w.clients.Stop() }
c168299
append(s.list, d.String()) s.set[d.String()] = d return true } return false }