id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c176500 | triggered or pending jobs that are now complete.
prowJobs.Reset()
for job, jobMap := range metricMap {
for jobType, typeMap := range jobMap {
for state, count := range typeMap {
prowJobs.WithLabelValues(job, jobType, state).Set(count)
}
}
}
} | |
c176501 | return defaultValue
}
return option
} | |
c176502 | tokens[len(tokens)-2]
return &gcsJobSource{
source: src,
linkPrefix: "gs://",
bucket: gcsPath.Bucket(),
jobPrefix: path.Clean(gcsPath.Object()) + "/",
jobName: name,
buildID: buildID,
}, nil
} | |
c176503 | 128, 256, 256, 512, 512}
for i := 0; ; {
oAttrs, err := objIter.Next()
if err == iterator.Done {
break
}
if err != nil {
logrus.WithFields(fieldsForJob(src)).WithError(err).Error("Error accessing GCS artifact.")
if i >= len(wait) {
return artifacts, fmt.Errorf("timed out: error accessing GCS artifact: %v", err)
}
time.Sleep((wait[i] + time.Duration(rand.Intn(10))) * time.Millisecond)
i++
continue
}
artifacts = append(artifacts, strings.TrimPrefix(oAttrs.Name, prefix))
i = 0
}
listElapsed := time.Since(listStart)
logrus.WithField("duration", listElapsed).Infof("Listed %d artifacts.", len(artifacts))
return artifacts, nil
} | |
c176504 | {
return path.Join(src.linkPrefix, src.bucket, src.jobPrefix)
} | |
c176505 | {
return fmt.Sprintf("%s/%s", src.bucket, src.jobPrefix)
} | |
c176506 | if err != nil {
log.WithError(err).Error("Failed to parse PR status base URL")
} else {
prQuery := fmt.Sprintf("is:pr repo:%s author:%s head:%s", pr.Repository.NameWithOwner, pr.Author.Login, pr.HeadRefName)
values := parseURL.Query()
values.Set("query", prQuery)
parseURL.RawQuery = values.Encode()
link = parseURL.String()
}
}
return link
} | |
c176507 | if err != nil {
return nil, err
}
// Assume watches receive updates, but resync every 30m in case something wonky happens
bif := buildinfo.NewSharedInformerFactory(bc, 30*time.Minute)
bif.Build().V1alpha1().Builds().Lister()
go bif.Start(stop)
return &buildConfig{
client: bc,
informer: bif.Build().V1alpha1().Builds(),
}, nil
} | |
c176508 | client.PullRequests,
repoService: client.Repositories,
userService: client.Users,
retries: 5,
retryInitialBackoff: time.Second,
tokenReserve: 50,
dryRun: dryRun,
}
} | |
c176509 | case *retryAbort:
return resp, err
}
if retryCount == c.retries {
return resp, err
}
glog.Errorf("error %s: %v. Will retry.\n", action, err)
c.sleepForAttempt(retryCount)
}
return resp, err
} | |
c176510 | {
resp, err := c.retry(action, wrapper)
if err != nil {
return allItems, fmt.Errorf("error while depaginating page %d/%d: %v", opts.Page, lastPage, err)
}
if resp.LastPage > 0 {
lastPage = resp.LastPage
}
}
return allItems, nil
} | |
c176511 | pa: pa,
oa: newOrgAgent(l, ghc, newRepoDetectionLimit),
}
} | |
c176512 | for repo, exts := range config.ExternalPlugins {
for _, ext := range exts {
repoExternalPlugins[repo] = append(repoExternalPlugins[repo], ext.Name)
}
}
return &pluginhelp.Help{
AllRepos: allRepos(config, orgToRepos),
RepoPlugins: repoPlugins,
RepoExternalPlugins: repoExternalPlugins,
PluginHelp: pluginHelp,
ExternalPluginHelp: externalPluginHelp,
}
} | |
c176513 | return "", fmt.Errorf("unable to parse pull %q (expected %q)", pull, expected)
}
return match[1], nil
} | |
c176514 | path.Base(jobPrefix),
buildPrefixes: buildPrefixes,
}
}(i, jobPrefix)
}
jobs := []jobBuilds{}
for range jobPrefixes {
job := <-jobch
jobs = append(jobs, job)
}
return jobs
} | |
c176515 | build.jobName = jobName
build.prefix = buildPrefix
build.index = j
buildch <- build
}(j, job.name, buildPrefix)
expected++
}
}
builds := []buildData{}
for k := 0; k < expected; k++ {
build := <-buildch
builds = append(builds, build)
}
return builds
} | |
c176516 | gcsPath, _, _ := gcsupload.PathsForJob(gcsConfig, &downwardapi.JobSpec{
Type: v1.PresubmitJob,
Job: presubmit.Name,
Refs: &v1.Refs{
Repo: repo,
Org: org,
Pulls: []v1.Pull{
{Number: pr},
},
},
}, "")
gcsPath, _ = path.Split(path.Clean(gcsPath))
if _, ok := toSearch[gcsConfig.Bucket]; !ok {
toSearch[gcsConfig.Bucket] = sets.String{}
}
toSearch[gcsConfig.Bucket].Insert(gcsPath)
}
return toSearch, nil
} | |
c176517 | file for the image.
fname = shared.VarPath("images", fingerprint) + ".rootfs"
if shared.PathExists(fname) {
err := os.Remove(fname)
if err != nil && !os.IsNotExist(err) {
logger.Errorf("Error deleting image file %s: %s", fname, err)
}
}
} | |
c176518 | = n.Start()
if err != nil {
n.Delete(withDatabase)
return err
}
return nil
} | |
c176519 | s, id: id, name: name, description: dbInfo.Description, config: dbInfo.Config}
return &n, nil
} | |
c176520 | *sql.Tx) error {
nodeTx.tx = tx
return f(nodeTx)
})
} | |
c176521 |
return nil, errors.Wrap(err, "Prepare database statements")
}
c.stmts = stmts
return c, nil
} | |
c176522 | c.db.Driver().(*dqlite.Driver)
driver.SetContextTimeout(timeout)
} | |
c176523 |
defer c.mu.RUnlock()
return c.transaction(f)
} | |
c176524 | time.Second
select {
case <-ch:
return nil
case <-time.After(timeout):
return fmt.Errorf("timeout (%s)", timeout)
}
} | |
c176525 | db")
defer c.mu.Unlock()
return c.transaction(f)
} | |
c176526 |
stmt.Close()
}
return c.db.Close()
} | |
c176527 | nil || err == sql.ErrTxDone { // Ignore duplicate commits/rollbacks
return nil
}
return err
} | |
c176528 | shared.IsSnapshot(raw) && shared.IsSnapshot(result[0]) {
return c.DefaultRemote, raw, nil
}
return "", "", fmt.Errorf("The remote \"%s\" doesn't exist", result[0])
}
return result[0], result[1], nil
} | |
c176529 |
// HTTPs
if remote.AuthType != "candid" && (args.TLSClientCert == "" || args.TLSClientKey == "") {
return nil, fmt.Errorf("Missing TLS client certificate and key")
}
d, err := lxd.ConnectLXD(remote.Addr, args)
if err != nil {
return nil, err
}
if remote.Project != "" && remote.Project != "default" {
d = d.UseProject(remote.Project)
}
if c.ProjectOverride != "" {
d = d.UseProject(c.ProjectOverride)
}
return d, nil
} | |
c176530 | }
return d, nil
}
// HTTPs (public LXD)
if remote.Public {
d, err := lxd.ConnectPublicLXD(remote.Addr, args)
if err != nil {
return nil, err
}
return d, nil
}
// HTTPs (private LXD)
d, err := lxd.ConnectLXD(remote.Addr, args)
if err != nil {
return nil, err
}
if remote.Project != "" && remote.Project != "default" {
d = d.UseProject(remote.Project)
}
if c.ProjectOverride != "" {
d = d.UseProject(c.ProjectOverride)
}
return d, nil
} | |
c176531 |
if s.AppArmorAvailable {
logger.Warnf("Per-container AppArmor profiles are disabled because LXD is running in an unprivileged container without stacking")
}
} else {
s.AppArmorAdmin = true
}
/* Detect AppArmor confinment */
profile := util.AppArmorProfile()
if profile != "unconfined" && profile != "" {
if s.AppArmorAvailable {
logger.Warnf("Per-container AppArmor profiles are disabled because LXD is already protected by AppArmor")
}
s.AppArmorConfined = true
}
} | |
c176532 | != nil {
logger.Warn("Unknown apparmor domain version", log.Ctx{"version": content})
return false
}
minor := 0
if len(parts) == 2 {
minor, err = strconv.Atoi(parts[1])
if err != nil {
logger.Warn("Unknown apparmor domain version", log.Ctx{"version": content})
return false
}
}
return major >= 1 && minor >= 2
} | |
c176533 | if ok {
return fmt.Errorf(i18n.G("Device already exists: %s"), devName)
}
container.Devices[devName] = dev
op, err := client.UpdateContainer(name, container.Writable(), etag)
if err != nil {
return err
}
return op.Wait()
} | |
c176534 | if the device already exists
_, ok := profile.Devices[devName]
if ok {
return fmt.Errorf(i18n.G("Device already exists: %s"), devName)
}
// Add the device to the container
profile.Devices[devName] = dev
err = client.UpdateProfile(name, profile.Writable(), profileEtag)
if err != nil {
return err
}
return nil
} | |
c176535 | }
}
// Create new aliases
for _, alias := range aliases {
aliasPost := api.ImageAliasesPost{}
aliasPost.Name = alias.Name
aliasPost.Target = fingerprint
err := client.CreateImageAlias(aliasPost)
if err != nil {
fmt.Println(fmt.Sprintf(i18n.G("Failed to create alias %s"), alias.Name))
}
}
return nil
} | |
c176536 | name)
if pos < len(aliases) && aliases[pos] == name {
existing = append(existing, alias)
}
}
return existing
} | |
c176537 | "Pending",
Success: "Success",
Failure: "Failure",
Cancelled: "Cancelled",
Starting: "Starting",
Stopping: "Stopping",
Aborting: "Aborting",
Freezing: "Freezing",
Frozen: "Frozen",
Thawed: "Thawed",
Error: "Error",
}[o]
} | |
c176538 | r[1] != "" {
timestamp = r[1]
}
var imageExpiry time.Time
err = imageExpiry.UnmarshalText([]byte(timestamp.(string)))
if err != nil {
return []string{}, err
}
imageExpiry = imageExpiry.Add(time.Duration(expiry*24) * time.Hour)
// Check if expired
if imageExpiry.After(time.Now()) {
continue
}
results = append(results, r[0].(string))
}
return results, nil
} | |
c176539 | if protocolInt == -1 {
return fmt.Errorf("Invalid protocol: %s", protocol)
}
err := exec(c.db, stmt, id, server, protocolInt, certificate, alias)
return err
} | |
c176540 | return -1, api.ImageSource{}, err
}
protocol, found := ImageSourceProtocol[protocolInt]
if !found {
return -1, api.ImageSource{}, fmt.Errorf("Invalid protocol: %d", protocolInt)
}
result.Protocol = protocol
return id, result, nil
} | |
c176541 | FROM images
JOIN projects ON projects.id = images.project_id
WHERE projects.name = ? AND fingerprint=?
`
inargs := []interface{}{project, fingerprint}
outargs := []interface{}{&exists}
err = dbQueryRowScan(c.db, query, inargs, outargs)
if err == sql.ErrNoRows {
return exists, ErrNoSuchObject
}
return exists, err
} | |
c176542 | return -1, nil, err // Likely: there are no rows for this fingerprint
}
// Validate we only have a single match
if !strictMatching {
query = `
SELECT COUNT(images.id)
FROM images
JOIN projects ON projects.id = images.project_id
WHERE projects.name = ?
AND fingerprint LIKE ?
`
count := 0
outfmt := []interface{}{&count}
err = dbQueryRowScan(c.db, query, inargs, outfmt)
if err != nil {
return -1, nil, err
}
if count > 1 {
return -1, nil, fmt.Errorf("Partial fingerprint matches more than one image")
}
}
err = c.imageFill(id, &image, create, expire, used, upload, arch)
if err != nil {
return -1, nil, errors.Wrapf(err, "Fill image details")
}
return id, &image, nil
} | |
c176543 | WHERE fingerprint = ?
LIMIT 1`
err := dbQueryRowScan(c.db, query, inargs, outfmt)
if err != nil {
if err == sql.ErrNoRows {
return -1, nil, ErrNoSuchObject
}
return -1, nil, err // Likely: there are no rows for this fingerprint
}
err = c.imageFill(id, &image, create, expire, used, upload, arch)
if err != nil {
return -1, nil, errors.Wrapf(err, "Fill image details")
}
return id, &image, nil
} | |
c176544 |
image.Properties = properties
// Get the aliases
q = "SELECT name, description FROM images_aliases WHERE image_id=?"
inargs = []interface{}{id}
outfmt = []interface{}{name, desc}
results, err = queryScan(c.db, q, inargs, outfmt)
if err != nil {
return err
}
aliases := []api.ImageAlias{}
for _, r := range results {
name = r[0].(string)
desc = r[1].(string)
a := api.ImageAlias{Name: name, Description: desc}
aliases = append(aliases, a)
}
image.Aliases = aliases
_, source, err := c.ImageSourceGet(id)
if err == nil {
image.UpdateSource = &source
}
return nil
} | |
c176545 | if err != nil {
return err
}
if address != localAddress && node.IsOffline(offlineThreshold) {
continue
}
addresses = append(addresses, address)
}
return err
})
if err != nil {
return "", err
}
if len(addresses) == 0 {
return "", fmt.Errorf("image not available on any online node")
}
for _, address := range addresses {
if address == localAddress {
return "", nil
}
}
return addresses[0], nil
} | |
c176546 |
_, err := tx.tx.Exec("INSERT INTO images_nodes(image_id, node_id) VALUES(?, ?)", imageID, c.nodeID)
return err
})
return err
} | |
c176547 | "DELETE FROM images WHERE id=?", id)
if err != nil {
return err
}
return nil
} | |
c176548 |
inargs := []interface{}{project}
outfmt := []interface{}{name}
results, err := queryScan(c.db, q, inargs, outfmt)
if err != nil {
return nil, err
}
names := []string{}
for _, res := range results {
names = append(names, res[0].(string))
}
return names, nil
} | |
c176549 | ON images_aliases.project_id=projects.id
WHERE projects.name=? AND images_aliases.name=?`
if !isTrustedClient {
q = q + ` AND images.public=1`
}
var fingerprint, description string
arg1 := []interface{}{project, name}
arg2 := []interface{}{&id, &fingerprint, &description}
err = dbQueryRowScan(c.db, q, arg1, arg2)
if err != nil {
if err == sql.ErrNoRows {
return -1, entry, ErrNoSuchObject
}
return -1, entry, err
}
entry.Name = name
entry.Target = fingerprint
entry.Description = description
return id, entry, nil
} | |
c176550 | {
err := exec(c.db, "UPDATE images_aliases SET name=? WHERE id=?", name, id)
return err
} | |
c176551 | return err
}
err = exec(c.db, `
DELETE
FROM images_aliases
WHERE project_id = (SELECT id FROM projects WHERE name = ?) AND name = ?
`, project, name)
return err
} | |
c176552 | images_aliases SET image_id=? WHERE image_id=?", destination, source)
return err
} | |
c176553 | return err
}
stmt := `
INSERT INTO images_aliases (name, image_id, description, project_id)
VALUES (?, ?, ?, (SELECT id FROM projects WHERE name = ?))
`
err = exec(c.db, stmt, name, imageID, desc, project)
return err
} | |
c176554 | description=? WHERE id=?`
err := exec(c.db, stmt, imageID, desc, id)
return err
} | |
c176555 |
stmt := `UPDATE images SET last_use_date=? WHERE fingerprint=?`
err := exec(c.db, stmt, date, fingerprint)
return err
} | |
c176556 | WHERE fingerprint=?`
err := exec(c.db, stmt, fingerprint)
return err
} | |
c176557 | architecture=?, creation_date=?, expiry_date=? WHERE id=?`)
if err != nil {
return err
}
defer stmt.Close()
_, err = stmt.Exec(fname, sz, publicInt, autoUpdateInt, arch, createdAt, expiresAt, id)
if err != nil {
return err
}
_, err = tx.tx.Exec(`DELETE FROM images_properties WHERE image_id=?`, id)
if err != nil {
return err
}
stmt2, err := tx.tx.Prepare(`INSERT INTO images_properties (image_id, type, key, value) VALUES (?, ?, ?, ?)`)
if err != nil {
return err
}
defer stmt2.Close()
for key, value := range properties {
_, err = stmt2.Exec(id, 0, key, value)
if err != nil {
return err
}
}
return nil
})
return err
} | |
c176558 | {
return err
}
id64, err := result.LastInsertId()
if err != nil {
return err
}
id := int(id64)
if len(properties) > 0 {
pstmt, err := tx.tx.Prepare(`INSERT INTO images_properties (image_id, type, key, value) VALUES (?, 0, ?, ?)`)
if err != nil {
return err
}
defer pstmt.Close()
for k, v := range properties {
// we can assume, that there is just one
// value per key
_, err = pstmt.Exec(id, k, v)
if err != nil {
return err
}
}
}
_, err = tx.tx.Exec("INSERT INTO images_nodes(image_id, node_id) VALUES(?, ?)", id, c.nodeID)
if err != nil {
return err
}
return nil
})
return err
} | |
c176559 | StoragePoolVolumeTypeImage}
outargs := []interface{}{poolID}
result, err := queryScan(c.db, query, inargs, outargs)
if err != nil {
return []int64{}, err
}
poolIDs := []int64{}
for _, r := range result {
poolIDs = append(poolIDs, r[0].(int64))
}
return poolIDs, nil
} | |
c176560 | queryScan(c.db, query, inargs, outargs)
if err != nil {
return []string{}, err
}
for _, r := range result {
poolNames = append(poolNames, r[0].(string))
}
}
return poolNames, nil
} | |
c176561 | {
err := exec(c.db, "UPDATE images SET upload_date=? WHERE id=?", uploadedAt, id)
return err
} | |
c176562 | error) {
return c.ImagesGetByNodeID(c.nodeID)
} | |
c176563 | tx.tx.Query(stmt, id)
if err != nil {
return err
}
var fingerprint string
var projectName string
for rows.Next() {
err := rows.Scan(&fingerprint, &projectName)
if err != nil {
return err
}
images[fingerprint] = append(images[fingerprint], projectName)
}
return rows.Err()
})
return images, err
} | |
c176564 | JOIN images ON images_nodes.image_id = images.id
WHERE images.fingerprint = ?
`
return c.getNodesByImageFingerprint(q, fingerprint)
} | |
c176565 | LEFT JOIN images ON images_nodes.image_id = images.id
WHERE images.fingerprint = ?)
`
return c.getNodesByImageFingerprint(q, fingerprint)
} | |
c176566 | reset: make(chan struct{}, 16), // Buffered to not block senders
})
return &g.tasks[i]
} | |
c176567 | // Local variable for the closure below.
g.mu.Unlock()
go func(i int) {
task.loop(ctx)
g.wg.Done()
g.mu.Lock()
g.running[i] = false
g.mu.Unlock()
}(i)
}
} | |
c176568 |
if err != nil || len(out) == 0 {
return false
}
return true
} | |
c176569 | "--showformat=${Version}", "--show", "zfsutils-linux")
if err != nil {
return "", err
}
return strings.TrimSpace(string(out)), nil
} | |
c176570 |
out, err := shared.RunCommand("modinfo", "-F", "version", "zfs")
if err != nil {
return "", fmt.Errorf("Could not determine ZFS module version")
}
zfsVersion = out
}
return strings.TrimSpace(zfsVersion), nil
} | |
c176571 | = append(cmd, []string{"-p", dataset}...)
return shared.RunCommand(cmd[0], cmd[1:]...)
} | |
c176572 | _, name := range strings.Split(output, "\n") {
if name == dataset {
return true, nil
}
}
return false, nil
} | |
c176573 |
}
stmt, err := c.tx.Prepare("SELECT id, name FROM networks WHERE NOT state=?")
if err != nil {
return nil, err
}
defer stmt.Close()
err = query.SelectObjects(stmt, dest, networkPending)
if err != nil {
return nil, err
}
ids := map[string]int64{}
for _, network := range networks {
ids[network.name] = network.id
}
return ids, nil
} | |
c176574 | return networkConfigAdd(c.tx, networkID, nodeID, config)
} | |
c176575 | := query.UpsertObject(c.tx, "networks_nodes", columns, values)
return err
} | |
c176576 | == 0 {
// No existing network with the given name was found, let's create
// one.
columns := []string{"name"}
values := []interface{}{name}
networkID, err = query.UpsertObject(c.tx, "networks", columns, values)
if err != nil {
return err
}
} else {
// Check that the existing network is in the pending state.
if network.state != networkPending {
return fmt.Errorf("network is not in pending state")
}
}
// Get the ID of the node with the given name.
nodeInfo, err := c.NodeByName(node)
if err != nil {
return err
}
// Check that no network entry for this node and network exists yet.
count, err := query.Count(
c.tx, "networks_nodes", "network_id=? AND node_id=?", networkID, nodeInfo.ID)
if err != nil {
return err
}
if count != 0 {
return ErrAlreadyDefined
}
// Insert the node-specific configuration.
columns := []string{"network_id", "node_id"}
values := []interface{}{networkID, nodeInfo.ID}
_, err = query.UpsertObject(c.tx, "networks_nodes", columns, values)
if err != nil {
return err
}
err = c.NetworkConfigAdd(networkID, nodeInfo.ID, conf)
if err != nil {
return err
}
return nil
} | |
c176577 | c.networkState(name, networkCreated)
} | |
c176578 | c.networkState(name, networkErrored)
} | |
c176579 |
return -1, nil, err
}
config, err := c.NetworkConfigGet(id)
if err != nil {
return -1, nil, err
}
network := api.Network{
Name: name,
Managed: true,
Type: "bridge",
}
network.Description = description.String
network.Config = config
switch state {
case networkPending:
network.Status = "Pending"
case networkCreated:
network.Status = "Created"
default:
network.Status = "Unknown"
}
nodes, err := c.networkNodes(id)
if err != nil {
return -1, nil, err
}
network.Locations = nodes
return id, &network, nil
} | |
c176580 | err error
nodes, err = query.SelectStrings(tx.tx, stmt, networkID)
return err
})
if err != nil {
return nil, err
}
return nodes, nil
} | |
c176581 | }
}
}
if id == -1 {
return -1, nil, fmt.Errorf("No network found for interface: %s", devName)
}
config, err := c.NetworkConfigGet(id)
if err != nil {
return -1, nil, err
}
network := api.Network{
Name: name,
Managed: true,
Type: "bridge",
}
network.Config = config
return id, &network, nil
} | |
c176582 | := queryScan(c.db, query, []interface{}{id}, []interface{}{r})
if err != nil {
return nil, err
}
if len(results) == 0 {
return nil, ErrNoSuchObject
}
}
config := map[string]string{}
for _, r := range results {
key = r[0].(string)
value = r[1].(string)
config[key] = value
}
return config, nil
} | |
c176583 |
columns := []string{"network_id", "node_id"}
values := []interface{}{id, c.nodeID}
_, err = query.UpsertObject(tx.tx, "networks_nodes", columns, values)
if err != nil {
return err
}
err = networkConfigAdd(tx.tx, id, c.nodeID, config)
if err != nil {
return err
}
return nil
})
if err != nil {
id = -1
}
return id, err
} | |
c176584 | err = NetworkUpdateDescription(tx.tx, id, description)
if err != nil {
return err
}
err = NetworkConfigClear(tx.tx, id, c.nodeID)
if err != nil {
return err
}
err = networkConfigAdd(tx.tx, id, c.nodeID, config)
if err != nil {
return err
}
return nil
})
return err
} | |
c176585 | description=? WHERE id=?", description, id)
return err
} | |
c176586 | NULL)",
networkID, nodeID)
if err != nil {
return err
}
return nil
} | |
c176587 | != nil {
return err
}
err = exec(c.db, "DELETE FROM networks WHERE id=?", id)
if err != nil {
return err
}
return nil
} | |
c176588 | _, err = tx.tx.Exec("UPDATE networks SET name=? WHERE id=?", newName, id)
return err
})
return err
} | |
c176589 | nil, "", &containers)
if err != nil {
return nil, err
}
return containers, nil
} | |
c176590 | _, err := r.queryStruct("GET", "/containers?recursion=2", nil, "", &containers)
if err != nil {
return nil, err
}
return containers, nil
} | |
c176591 | value
etag, err := r.queryStruct("GET", fmt.Sprintf("/containers/%s", url.QueryEscape(name)), nil, "", &container)
if err != nil {
return nil, "", err
}
return &container, etag, nil
} | |
c176592 | request
resp, err := r.do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
// Handle errors
response, _, err := lxdParseResponse(resp)
if err != nil {
return nil, err
}
// Get to the operation
respOperation, err := response.MetadataAsOperation()
if err != nil {
return nil, err
}
// Setup an Operation wrapper
op := operation{
Operation: *respOperation,
r: r,
chActive: make(chan bool),
}
return &op, nil
} | |
c176593 | }
// Send the request
op, _, err := r.queryOperation("POST", "/containers", container, "")
if err != nil {
return nil, err
}
return op, nil
} | |
c176594 | req.Source.Fingerprint = image.Fingerprint
req.Source.Alias = ""
}
// Get source server connection information
info, err := source.GetConnectionInfo()
if err != nil {
return nil, err
}
req.Source.Protocol = info.Protocol
req.Source.Certificate = info.Certificate
// Generate secret token if needed
if !image.Public {
secret, err := source.GetImageSecret(image.Fingerprint)
if err != nil {
return nil, err
}
req.Source.Secret = secret
}
return r.tryCreateContainer(req, info.Addresses)
} | |
c176595 | url.QueryEscape(name)), container, ETag)
if err != nil {
return nil, err
}
return op, nil
} | |
c176596 | := r.queryOperation("POST", fmt.Sprintf("/containers/%s", url.QueryEscape(name)), container, "")
if err != nil {
return nil, err
}
return op, nil
} | |
c176597 | err
}
// And attach stdin and stdout to it
go func() {
shared.WebsocketSendStream(conn, args.Stdin, -1)
<-shared.WebsocketRecvStream(args.Stdout, conn)
conn.Close()
if args.DataDone != nil {
close(args.DataDone)
}
}()
} else {
if args.DataDone != nil {
close(args.DataDone)
}
}
} else {
// Handle non-interactive sessions
dones := map[int]chan bool{}
conns := []*websocket.Conn{}
// Handle stdin
if fds["0"] != "" {
conn, err := r.GetOperationWebsocket(opAPI.ID, fds["0"])
if err != nil {
return nil, err
}
conns = append(conns, conn)
dones[0] = shared.WebsocketSendStream(conn, args.Stdin, -1)
}
// Handle stdout
if fds["1"] != "" {
conn, err := r.GetOperationWebsocket(opAPI.ID, fds["1"])
if err != nil {
return nil, err
}
conns = append(conns, conn)
dones[1] = shared.WebsocketRecvStream(args.Stdout, conn)
}
// Handle stderr
if fds["2"] != "" {
conn, err := r.GetOperationWebsocket(opAPI.ID, fds["2"])
if err != nil {
return nil, err
}
conns = append(conns, conn)
dones[2] = shared.WebsocketRecvStream(args.Stderr, conn)
}
// Wait for everything to be done
go func() {
for i, chDone := range dones {
// Skip stdin, dealing with it separately below
if i == 0 {
continue
}
<-chDone
}
if fds["0"] != "" {
if args.Stdin != nil {
args.Stdin.Close()
}
// Empty the stdin channel but don't block on it as
// stdin may be stuck in Read()
go func() {
<-dones[0]
}()
}
for _, conn := range conns {
conn.Close()
}
if args.DataDone != nil {
close(args.DataDone)
}
}()
}
}
return op, nil
} | |
c176598 | // Parse the headers
uid, gid, mode, fileType, _ := shared.ParseLXDFileHeaders(resp.Header)
fileResp := ContainerFileResponse{
UID: uid,
GID: gid,
Mode: mode,
Type: fileType,
}
if fileResp.Type == "directory" {
// Decode the response
response := api.Response{}
decoder := json.NewDecoder(resp.Body)
err = decoder.Decode(&response)
if err != nil {
return nil, nil, err
}
// Get the file list
entries := []string{}
err = response.MetadataAsStruct(&entries)
if err != nil {
return nil, nil, err
}
fileResp.Entries = entries
return nil, &fileResp, err
}
return resp.Body, &fileResp, err
} | |
c176599 |
req.Header.Set("X-LXD-uid", fmt.Sprintf("%d", args.UID))
}
if args.GID > -1 {
req.Header.Set("X-LXD-gid", fmt.Sprintf("%d", args.GID))
}
if args.Mode > -1 {
req.Header.Set("X-LXD-mode", fmt.Sprintf("%04o", args.Mode))
}
if args.Type != "" {
req.Header.Set("X-LXD-type", args.Type)
}
if args.WriteMode != "" {
req.Header.Set("X-LXD-write", args.WriteMode)
}
// Send the request
resp, err := r.do(req)
if err != nil {
return err
}
// Check the return value for a cleaner error
_, _, err = lxdParseResponse(resp)
if err != nil {
return err
}
return nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.