id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c178600 | Expect(strings.Split(req.Header.Get("Content-Type"), ";")[0]).Should(Equal(mimeType))
}
} | |
c178601 | err := base64.StdEncoding.DecodeString(auth[6:])
Expect(err).ShouldNot(HaveOccurred())
Expect(string(decoded)).Should(Equal(fmt.Sprintf("%s:%s", username, password)), "Authorization mismatch")
}
} | |
c178602 |
Expect(err).ShouldNot(HaveOccurred())
return CombineHandlers(
VerifyContentType("application/json"),
VerifyJSON(string(data)),
)
} | |
c178603 | VerifyForm(url.Values{key: values})
} | |
c178604 | _, found := headers["Content-Type"]; !found {
headers["Content-Type"] = []string{"application/x-protobuf"}
}
copyHeader(headers, w.Header())
w.WriteHeader(statusCode)
w.Write(data)
}
} | |
c178605 | nil {
globalFailWrapper = nil
return
}
globalFailWrapper = &types.GomegaFailWrapper{
Fail: handler,
TWithHelper: t,
}
} | |
c178606 | > 1 {
pollingInterval = toDuration(intervals[1])
}
return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, actual, globalFailWrapper, timeoutInterval, pollingInterval, offset)
} | |
c178607 | > 1 {
pollingInterval = toDuration(intervals[1])
}
return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, globalFailWrapper, timeoutInterval, pollingInterval, offset)
} | |
c178608 | testingtsupport.BuildTestingTGomegaFailWrapper(g.t), 0, extra...)
} | |
c178609 | pollingInterval = toDuration(intervals[1])
}
return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, pollingInterval, 0)
} | |
c178610 | pollingInterval = toDuration(intervals[1])
}
return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, pollingInterval, 0)
} | |
c178611 | timeoutReaderWriterCloser{c: c, d: timeout}
} | |
c178612 | timeoutReaderWriterCloser{r: r, d: timeout}
} | |
c178613 | timeoutReaderWriterCloser{w: w, d: timeout}
} | |
c178614 | ok {
return &NestedError{
Path: path + ne.Path,
Err: ne.Err,
}
}
return &NestedError{
Path: path,
Err: err,
}
} | |
c178615 |
servicemanager.PlatformImage = m.PlatformImage
servicemanager.Team = m.Team
servicemanager.UserQuota = m.UserQuota
servicemanager.AppQuota = m.AppQuota
servicemanager.Cluster = m.Cluster
servicemanager.ServiceBroker = m.ServiceBroker
servicemanager.ServiceBrokerCatalogCache = m.ServiceBrokerCatalogCache
} | |
c178616 | id
} else {
query["address"] = address
}
err = coll.Find(query).One(&result)
if err == mgo.ErrNotFound {
err = ErrMachineNotFound
}
return result, err
} | |
c178617 | msg := fmt.Sprintf("Error recovered on flushing writer: %#v", r)
log.Debugf(msg)
err = errors.Errorf(msg)
}
}()
f.Flush()
}
return
} | |
c178618 | := w.ResponseWriter.(http.Hijacker); ok {
return hijacker.Hijack()
}
return nil, nil, errors.New("cannot hijack connection")
} | |
c178619 | skip,
})
if err != nil {
return nil, err
}
validImages, err := findValidImages(appsList...)
if err != nil {
return nil, err
}
list := make([]DeployData, len(evts))
for i := range evts {
list[i] = *eventToDeployData(&evts[i], validImages, false)
}
return list, nil
} | |
c178620 | r.addRoute(version, path, h, "GET", "POST", "PUT", "DELETE")
} | |
c178621 | schemeData["request_timeout"]
timeout, _ := strconv.Atoi(p)
return timeout
} | |
c178622 | RegisterHandlerVersion("1.0", path, method, h)
} | |
c178623 | th.method = method
th.h = h
tsuruHandlerList = append(tsuruHandlerList, th)
} | |
c178624 | "fail - " + err.Error(),
Duration: time.Since(startTime),
})
} else if err == nil {
results = append(results, Result{
Name: checker.name,
Status: HealthCheckOK,
Duration: time.Since(startTime),
})
}
}
return results
} | |
c178625 | err == nil && fi.IsDir() {
return dir, nil
}
dir = filepath.Join(dir, "..", "..", ".git")
}
return "", ErrRepositoryNotFound
} | |
c178626 |
}
p = strings.TrimRight(p, "/")
fi, err := os.Stat(filepath.Join(p, "config"))
if err == nil && !fi.IsDir() {
return &Repository{path: p}, nil
}
return nil, ErrRepositoryNotFound
} | |
c178627 | fmt.Sprintf("[remote %q]", name)
scanner := bufio.NewScanner(config)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
if scanner.Text() == line {
scanner.Scan()
return strings.Split(scanner.Text(), " = ")[1], nil
}
}
return "", errRemoteNotFound{name}
} | |
c178628 | selector, func(m interface{}) {
ret = append(ret, m.(*v1.App))
})
return ret, err
} | |
c178629 | {
return appNamespaceLister{indexer: s.indexer, namespace: namespace}
} | |
c178630 | func(m interface{}) {
ret = append(ret, m.(*v1.App))
})
return ret, err
} | |
c178631 | for n := int64(1); n > 0 && err == nil; n, err = io.Copy(output, response.Body) {
}
if err != nil {
return err
}
unparsed := output.Remaining()
if len(unparsed) > 0 {
return errors.Errorf("unparsed message error: %s", string(unparsed))
}
return nil
} | |
c178632 | s.session.DB(name).DropDatabase()
} | |
c178633 | {
return &Collection{Collection: s.session.DB(s.dbname).C(name)}
} | |
c178634 | defer t.mut.Unlock()
t.logger = l
} | |
c178635 | != nil {
t.logger.Errorf("%+v", v)
}
} | |
c178636 | _, hasStack := item.(withStack); hasStack {
t.logger.Errorf("stack for error: %+v", item)
}
}
}
} | |
c178637 | if t.logger != nil {
t.logger.Fatal(v)
}
} | |
c178638 | if t.logger != nil {
t.logger.Debugf(format, v...)
}
} | |
c178639 | return t.logger.GetStdLogger()
}
return nil
} | |
c178640 | c.CustomData[namespaceClusterKey] != "" {
return c.CustomData[namespaceClusterKey]
}
return "tsuru"
} | |
c178641 | return ensureContainersStarted(p, w, true, nil, nodes...)
} | |
c178642 | value == "" {
return checkDocker()
}
return nil
} | |
c178643 |
err = checkScheduler()
if err != nil {
return err
}
err = checkRouter()
if err != nil {
return err
}
return checkCluster()
} | |
c178644 | if isSegregate {
return config.NewWarning(`Setting "docker:segregate" is not necessary anymore, this is the default behavior from now on.`)
} else {
return errors.Errorf(`You must remove "docker:segregate" from your config.`)
}
}
return nil
} | |
c178645 | return config.NewWarning(`Setting "hipache:*" config entries is deprecated. You should configure your router with "routers:*". See http://docs.tsuru.io/en/latest/reference/config.html#routers for more details.`)
}
if routerConf == nil {
return errors.Errorf(`You must configure your default router %q in "routers:%s".`, defaultRouter, defaultRouter)
}
routerType, _ := config.Get("routers:" + defaultRouter + ":type")
if routerType == nil {
return errors.Errorf(`You must configure your default router type in "routers:%s:type".`, defaultRouter)
}
return nil
} | |
c178646 | u.Status == StatusStarting ||
u.Status == StatusError
} | |
c178647 |
if !ok {
return nil, errors.Errorf("unknown provisioner: %q", name)
}
return pFunc()
} | |
c178648 |
return nil, err
}
registry = append(registry, p)
}
return registry, nil
} | |
c178649 | " + e.Reason
} else {
err = e.Reason
}
return err
} | |
c178650 | if err != nil {
return false
}
vCurrent, err := goVersion.NewVersion(current)
if err != nil {
return false
}
return vCurrent.Compare(vSupported) >= 0
} | |
c178651 | := JoinWithUserDir(".tsuru", "target")
target, err := readTarget(targetPath)
if err == errUndefinedTarget {
copyTargetFiles()
target, err = readTarget(JoinWithUserDir(".tsuru_target"))
}
return target, err
} | |
c178652 | err := targetFile.WriteString(t)
if n != len(t) || err != nil {
return errors.New("Failed to write the target file")
}
return nil
} | |
c178653 | nil {
return err
}
defer targetsFile.Close()
content := label + "\t" + target + "\n"
n, err := targetsFile.WriteString(content)
if n != len(content) || err != nil {
return errors.New("Failed to write the target file")
}
return nil
} | |
c178654 | err = storage.Open(url, dbname)
return &strg, err
} | |
c178655 | c := s.Collection("apps")
c.EnsureIndex(nameIndex)
return c
} | |
c178656 | []string{"poolexpr", "field"}, Unique: true}
c := s.Collection("pool_constraints")
c.EnsureIndex(poolConstraintIndex)
return c
} | |
c178657 | c := s.Collection("users")
c.EnsureIndex(emailIndex)
return c
} | |
c178658 | s.Collection("saml_requests")
coll.EnsureIndex(id)
return coll
} | |
c178659 | return nil
}
return s.Collection("logs_" + appName)
} | |
c178660 | := s.AppLogCollection(appName)
err := c.Create(&logCappedInfo)
return c, err
} | |
c178661 | nil, err
}
var colls []*storage.Collection
for _, name := range names {
colls = append(colls, s.Collection("logs_"+name.Name))
}
return colls, nil
} | |
c178662 | return buildCmds(app, "build", "archive", archiveURL)
} | |
c178663 | return buildCmds(app, "deploy", "archive", archiveURL)
} | |
c178664 | finalCmd := strings.Join(uaCmds, " ")
return []string{"/bin/sh", "-lc", finalCmd}
} | |
c178665 | runCmd = "/var/lib/tsuru/start"
}
host, _ := config.GetString("host")
token := app.Envs()["TSURU_APP_TOKEN"].Value
return []string{"tsuru_unit_agent", host, token, app.GetName(), runCmd}, nil
} | |
c178666 | {
return &apps{
client: c.RESTClient(),
ns: namespace,
}
} | |
c178667 | %s\n", imgSize)
log.Debugf("image %s generated from container %s", image.ID, c.ID)
for _, tag := range tags {
maxTry, _ := config.GetInt("docker:registry-max-try")
if maxTry <= 0 {
maxTry = 3
}
for i := 0; i < maxTry; i++ {
err = dockercommon.PushImage(client, repository, tag, dockercommon.RegistryAuthConfig(repository))
if err != nil {
fmt.Fprintf(writer, "Could not send image, trying again. Original error: %s\n", err.Error())
log.Errorf("error in push image %s: %s", c.BuildingImage, err)
time.Sleep(time.Second)
continue
}
break
}
if err != nil {
return "", log.WrapError(errors.Wrapf(err, "error in push image %s", c.BuildingImage))
}
}
return c.BuildingImage, nil
} | |
c178668 | 0 && !usedTags[tag] {
processedTags = append(processedTags, tag)
usedTags[tag] = true
}
}
return processedTags
} | |
c178669 | != nil {
return nil, err
}
countMap := make(map[string]int)
for _, result := range results {
countMap[result.HostAddr] = result.Count
}
return countMap, nil
} | |
c178670 | := s.minMaxNodes(nodes, appName, process)
if err != nil {
return "", err
}
log.Debugf("[scheduler] Chosen node for container %s: %#v", contName, chosenNode)
if contName != "" {
coll := s.provisioner.Collection()
defer coll.Close()
err = coll.Update(bson.M{"name": contName}, bson.M{"$set": bson.M{"hostaddr": net.URLToHost(chosenNode)}})
}
return chosenNode, err
} | |
c178671 | remove a container: %#v", chosenNode)
containerID, err := s.getContainerPreferablyFromHost(chosenNode, appName, process)
if err != nil {
return "", err
}
return containerID, err
} | |
c178672 | routerType)
}
r, err := factory(name, prefix)
if err != nil {
return nil, err
}
return r, nil
} | |
c178673 | p := range plans {
if p.Default {
return p.Name, nil
}
}
return "", ErrDefaultRouterNotFound
} | |
c178674 | coll.Close()
data := routerAppEntry{
App: appName,
Router: routerName,
Kind: kind,
}
_, err = coll.Upsert(bson.M{"app": appName}, data)
return err
} | |
c178675 | {
return &faketsuruv1.FakeTsuruV1{Fake: &c.Fake}
} | |
c178676 | {
return &faketsuruv1.FakeTsuruV1{Fake: &c.Fake}
} | |
c178677 |
return NewFilteredAppInformer(client, namespace, resyncPeriod, indexers, nil)
} | |
c178678 | WatchFunc: func(options meta_v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.TsuruV1().Apps(namespace).Watch(options)
},
},
&tsuru_v1.App{},
resyncPeriod,
indexers,
)
} | |
c178679 | error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(appsResource, c.ns, opts))
} | |
c178680 | subresources...), &tsuru_v1.App{})
if obj == nil {
return nil, err
}
return obj.(*tsuru_v1.App), err
} | |
c178681 | NewFilteredSharedInformerFactory(client, defaultResync, v1.NamespaceAll, nil)
} | |
c178682 | return &sharedInformerFactory{
client: client,
namespace: namespace,
tweakListOptions: tweakListOptions,
defaultResync: defaultResync,
informers: make(map[reflect.Type]cache.SharedIndexInformer),
startedInformers: make(map[reflect.Type]bool),
}
} | |
c178683 |
return fmt.Errorf("service proxy is not available for broker services")
} | |
c178684 | unit bind.Unit) error {
return nil
} | |
c178685 | 0 && plan.Memory < 4194304 {
return appTypes.ErrLimitOfMemory
}
return s.storage.Insert(plan)
} | |
c178686 | s.storage.Delete(appTypes.Plan{Name: planName})
} | |
c178687 | Memory: int64(configMemory) * 1024 * 1024,
Swap: int64(configSwap-configMemory) * 1024 * 1024,
CpuShare: 100,
Default: true,
}
return s.storage.Insert(dp)
} | |
c178688 | requestID)
}
conn, err := db.Conn()
if err != nil {
return err
}
defer conn.Close()
return conn.ServiceInstances().Remove(bson.M{"name": si.Name, "service_name": si.ServiceName})
} | |
c178689 | PlanName: si.PlanName,
Apps: si.Apps,
ServiceName: si.ServiceName,
Info: info,
TeamOwner: si.TeamOwner,
}, nil
} | |
c178690 | }
actions := []*action.Action{&updateServiceInstance, ¬ifyUpdateServiceInstance}
pipeline := action.NewPipeline(actions...)
return pipeline.Execute(service, *si, updateData, evt, requestID)
} | |
c178691 | evt,
requestID: requestID,
}
actions := []*action.Action{
bindAppDBAction,
bindAppEndpointAction,
setBoundEnvsAction,
bindUnitsAction,
}
pipeline := action.NewPipeline(actions...)
return pipeline.Execute(&args)
} | |
c178692 | = conn.ServiceInstances().Update(bson.M{"name": si.Name, "service_name": si.ServiceName, "bound_units.id": bson.M{"$ne": unit.GetID()}}, updateOp)
conn.Close()
if err != nil {
if err == mgo.ErrNotFound {
return nil
}
return err
}
err = endpoint.BindUnit(si, app, unit)
if err != nil {
updateOp = bson.M{
"$pull": bson.M{
"bound_units": bson.D([]bson.DocElem{
{Name: "appname", Value: app.GetName()},
{Name: "id", Value: unit.GetID()},
{Name: "ip", Value: unit.GetIp()},
}),
},
}
rollbackErr := si.updateData(updateOp)
if rollbackErr != nil {
log.Errorf("[bind unit] could not remove stil unbound unit from db after failure: %s", rollbackErr)
}
return err
}
return nil
} | |
c178693 | forceRemove: unbindArgs.ForceRemove,
}
actions := []*action.Action{
&unbindUnits,
&unbindAppDB,
&unbindAppEndpoint,
&removeBoundEnvs,
}
pipeline := action.NewPipeline(actions...)
return pipeline.Execute(&args)
} | |
c178694 | != nil {
return "", err
}
endpoint, err := s.getClient("production")
if err != nil {
return "", err
}
return endpoint.Status(si, requestID)
} | |
c178695 | := range reservedProxyPaths {
if path == reserved && r.Method != "GET" {
return &tsuruErrors.ValidationError{
Message: fmt.Sprintf("proxy request %s %q is forbidden", r.Method, path),
}
}
}
return endpoint.Proxy(fmt.Sprintf("%s%s", prefix, path), evt, requestID, w, r)
} | |
c178696 | if err != nil {
return err
}
return s.Storage.Inc(appName, quantity)
} | |
c178697 |
} else if limit < q.InUse {
return quota.ErrLimitLowerThanAllocated
}
return s.Storage.SetLimit(appName, limit)
} | |
c178698 | return quota.ErrLessThanZero
}
if !q.IsUnlimited() && inUse > q.Limit {
return "a.QuotaExceededError{
Requested: uint(inUse),
Available: uint(q.Limit),
}
}
return s.Storage.Set(appName, inUse)
} | |
c178699 | return s.Storage.Get(appName)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.