query
stringlengths
7
3.85k
document
stringlengths
11
430k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Remove all timeout Entries
func (c *TimeoutCache) autoEvict() { c.lock.Lock() defer c.lock.Unlock() time := time.Now().Unix() for e := c.evictList.Back(); e != nil; e = e.Prev() { kv := e.Value.(*entry) if time > kv.evict { c.removeElement(e) } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *PruneTask) ClearTimeout() {}", "func (m *LocalExecutorManager) purgeExpiredEntries() {\n\tfor {\n\t\tfunc() {\n\t\t\tm.Lock()\n\t\t\tcutoverLimit := time.Now().Add(-24 * time.Hour)\n\t\t\tfor id, executorStatus := range m.id2ExecutorStatus {\n\t\t\t\tif executorStatus.LastAccessTime.Before(cutoverLimit) {\n\t\t\t\t\tdelete(m.id2ExecutorStatus, id)\n\t\t\t\t}\n\t\t\t}\n\t\t\tm.Unlock()\n\t\t\ttime.Sleep(1 * time.Hour)\n\t\t}()\n\t}\n}", "func (db *queueDatabase) removeFromTimeoutIndex(m *persistence.QueueMessage) {\n\tif m.Envelope.GetScheduledFor() == \"\" {\n\t\treturn\n\t}\n\n\tkey := instanceKey{\n\t\tm.Envelope.GetSourceHandler().GetKey(),\n\t\tm.Envelope.GetSourceInstanceId(),\n\t}\n\n\ttimeouts := db.timeouts[key]\n\tdelete(timeouts, m.ID())\n\n\tif len(timeouts) == 0 {\n\t\tdelete(db.timeouts, key)\n\t}\n}", "func (c *Cache) CleanupExpired() {\n\tgo func() {\n\t\tfor {\n\t\t\tfor k, v := range c.Map {\n\t\t\t\tif v.RegTime.Add(time.Minute * 1).Before(time.Now()) {\n\t\t\t\t\tc.Remove(k)\n\t\t\t\t}\n\t\t\t}\n\t\t\ttime.Sleep(time.Second * 10)\n\t\t}\n\t}()\n}", "func (a *ApplyTask) ClearTimeout() {}", "func (d *Datastore) cleanup() {\n\tn := time.Now()\n\tfor key, item := range d.items {\n\t\tif item.time.Add(d.threshold).Before(n) {\n\t\t\tdelete(d.items, key)\n\t\t}\n\t}\n}", "func (s *CacheLastPasswordSent) cleanup() {\n\ttickEvery := time.NewTicker(1 * time.Minute)\n\tdefer tickEvery.Stop()\n\n\tclearOutAfter := time.Duration(10 * time.Minute)\n\nLoop:\n\tfor {\n\t\tselect {\n\t\tcase <-s.stop:\n\t\t\tbreak Loop\n\t\tcase <-tickEvery.C:\n\t\t}\n\n\t\ts.mu.Lock()\n\t\tnow := time.Now().UTC()\n\t\tfor key, t := range s.data {\n\t\t\tif now.Sub(t) >= clearOutAfter {\n\t\t\t\tdelete(s.data, key)\n\t\t\t}\n\t\t}\n\t\ts.mu.Unlock()\n\t}\n}", "func (tm *TimerManager) ClearTimeout(id int) bool {\n\n\tfor pos, t := range tm.timers {\n\t\tif t.id == id {\n\t\t\tcopy(tm.timers[pos:], tm.timers[pos+1:])\n\t\t\ttm.timers[len(tm.timers)-1] = timeout{}\n\t\t\ttm.timers = tm.timers[:len(tm.timers)-1]\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (r *Registry) Clean(d time.Duration) {\n\tnow := clock.SyncedTime()\n\n\tfor _, v := range r.NodesView() {\n\t\tv.cMutex.Lock()\n\t\t// loop over the conflicts\n\t\tfor id, c := range v.Conflicts {\n\t\t\tif c.Timestamp.Add(d).Before(now) {\n\t\t\t\tdelete(v.Conflicts, id)\n\t\t\t}\n\t\t}\n\t\tv.cMutex.Unlock()\n\n\t\tv.tMutex.Lock()\n\t\t// loop over the timestamps\n\t\tfor id, t := range v.Timestamps {\n\t\t\tif t.Timestamp.Add(d).Before(now) {\n\t\t\t\tdelete(v.Timestamps, id)\n\t\t\t}\n\t\t}\n\t\tv.tMutex.Unlock()\n\t}\n}", "func (mdb *db) DeleteAllFromTimerInfoMaps(\n\tctx context.Context,\n\tfilter sqlplugin.TimerInfoMapsAllFilter,\n) (sql.Result, error) {\n\treturn mdb.conn.ExecContext(ctx,\n\t\tdeleteTimerInfoMapSQLQuery,\n\t\tfilter.ShardID,\n\t\tfilter.NamespaceID,\n\t\tfilter.WorkflowID,\n\t\tfilter.RunID,\n\t)\n}", "func (c *ttlCache) purge() {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\tfor key, value := range c.entries {\n\t\tif value.expireTime.Before(time.Now()) {\n\t\t\tdelete(c.entries, key)\n\t\t}\n\t}\n\n}", "func (e *eventManager) cleanup() {\n\tnow := time.Now()\n\n\tif now.Sub(e.lastRun).Seconds() < eventExpiry {\n\t\treturn\n\t}\n\n\tfor s, ev := range e.events {\n\t\tif now.Sub(ev.at).Seconds() > eventExpiry {\n\t\t\tdelete(e.events, s)\n\t\t}\n\t}\n\n\te.lastRun = now\n}", "func (db *queueDatabase) removeTimeoutsByProcessInstance(key instanceKey) {\n\ttimeouts := db.timeouts[key]\n\tdelete(db.timeouts, key)\n\n\tfor id, m := range timeouts {\n\t\tdelete(db.messages, id)\n\t\tdb.removeFromOrderIndex(m)\n\t}\n}", "func (c *CacheTable) Clean() {\r\n\tif nil != c.cleanTime {\r\n\t\tc.cleanTime.Stop()\r\n\t}\r\n\r\n\t//Copy map\r\n\titems := c.pool\r\n\r\n\t//Get min duration\r\n\tminDuration := 0 * time.Second\r\n\tclean_st := time.Now()\r\n\tfor key, item := range items {\r\n\t\tnowTime := time.Now()\r\n\t\tif item.lifeSpan <= nowTime.Sub(item.accessOn) {\r\n\t\t\tc.Delete(key)\r\n\t\t} else {\r\n\t\t\tif 0 == minDuration || item.lifeSpan-nowTime.Sub(item.accessOn) < minDuration {\r\n\t\t\t\tminDuration = item.lifeSpan - nowTime.Sub(item.accessOn)\r\n\t\t\t\t//log.Println(\"innnn %f\", minDuration.Seconds())\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif minDuration <= 0 {\r\n\t\treturn\r\n\t}\r\n\r\n\tlog.Println(\"LoopCost %f\", time.Now().Sub(clean_st).Seconds())\r\n\tc.cleanInterval = minDuration\r\n\t//Check if need do clean\r\n\tc.cleanTime = time.AfterFunc(minDuration, func() {\r\n\t\tgo c.Clean()\r\n\t})\r\n}", "func (c *Cache) cleanup(ttl time.Duration) {\n\tvalids := map[string]*cacheEntry{}\n\tnow := time.Now()\n\tfor token, entry := range c.entries {\n\t\tif entry.jwt.IsValid(c.leeway) {\n\t\t\tif entry.accessed.Add(ttl).After(now) {\n\t\t\t\t// Everything fine.\n\t\t\t\tvalids[token] = entry\n\t\t\t}\n\t\t}\n\t}\n\tc.entries = valids\n}", "func (bl *blackList) clear() {\n\tfor _ = range time.Tick(time.Minute * 10) {\n\t\tkeys := make([]interface{}, 0, 100)\n\n\t\tfor item := range bl.list.Iter() {\n\t\t\tif time.Now().Sub(\n\t\t\t\titem.val.(*blockedItem).createTime) > bl.expiredAfter {\n\n\t\t\t\tkeys = append(keys, item.key)\n\t\t\t}\n\t\t}\n\n\t\tbl.list.DeleteMulti(keys)\n\t}\n}", "func (et EventTime) Clear(p Provider) {\n\tp.Set(TimerMap{Family: et.Family, Clear: true})\n}", "func (m *MemoryStorer) Clean() {\n\tt := time.Now().UTC()\n\tm.mut.Lock()\n\tfor id, session := range m.sessions {\n\t\tif t.After(session.expires) {\n\t\t\tdelete(m.sessions, id)\n\t\t}\n\t}\n\tm.mut.Unlock()\n}", "func (r *TimeBucketResults) Clear() {\n\tr.buckets = nil\n}", "func cleanupLoop(maxAgeSeconds float64) {\n\tfor {\n\t\ttime.Sleep(60 * time.Second)\n\t\tt := time.Now()\n\t\tfor project, creationTime := range dataTimestamp {\n\t\t\tmutex.Lock()\n\t\t\tif t.Sub(creationTime).Seconds() >= maxAgeSeconds {\n\t\t\t\tdelete(projectStatus, project)\n\t\t\t\tdelete(dataTimestamp, project)\n\t\t\t}\n\t\t\tmutex.Unlock()\n\t\t}\n\t}\n}", "func (w *watcher) cleanupWorker() {\n\tfor {\n\t\t// Wait a full period\n\t\ttime.Sleep(w.cleanupTimeout)\n\n\t\tselect {\n\t\tcase <-w.ctx.Done():\n\t\t\tw.stopped.Done()\n\t\t\treturn\n\t\tdefault:\n\t\t\t// Check entries for timeout\n\t\t\tvar toDelete []string\n\t\t\ttimeout := time.Now().Add(-w.cleanupTimeout)\n\t\t\tw.RLock()\n\t\t\tfor key, lastSeen := range w.deleted {\n\t\t\t\tif lastSeen.Before(timeout) {\n\t\t\t\t\tlogp.Debug(\"docker\", \"Removing container %s after cool down timeout\", key)\n\t\t\t\t\ttoDelete = append(toDelete, key)\n\t\t\t\t}\n\t\t\t}\n\t\t\tw.RUnlock()\n\n\t\t\t// Delete timed out entries:\n\t\t\tfor _, key := range toDelete {\n\t\t\t\tcontainer := w.Container(key)\n\t\t\t\tif container != nil {\n\t\t\t\t\tw.bus.Publish(bus.Event{\n\t\t\t\t\t\t\"delete\": true,\n\t\t\t\t\t\t\"container\": container,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tw.Lock()\n\t\t\tfor _, key := range toDelete {\n\t\t\t\tdelete(w.deleted, key)\n\t\t\t\tdelete(w.containers, key)\n\t\t\t\tif w.shortID {\n\t\t\t\t\tdelete(w.containers, key[:shortIDLen])\n\t\t\t\t}\n\t\t\t}\n\t\t\tw.Unlock()\n\t\t}\n\t}\n}", "func (u *TimerUpdate) Clear() {\n\titerOptionalFields(reflect.ValueOf(u).Elem(), nil, func(name string, val optionalVal) bool {\n\t\tval.Clear()\n\t\treturn true\n\t})\n}", "func (p *perfStoreManager) delContainerPerfs() {\n\tp.lock.Lock()\n\tdefer p.lock.Unlock()\n\n\tfor c, cache := range p.caches {\n\t\t// get last elements\n\t\tstats := cache.InTimeRange(time.Now().Add(-10*time.Minute), time.Now(), -1)\n\t\tif len(stats) == 0 {\n\t\t\tklog.Warningf(\"delete container(%s) perf cache for time expired\", c)\n\t\t\tdelete(p.caches, c)\n\t\t}\n\t}\n}", "func FlushTimeout(timeout time.Duration) {\n\tsentry.Flush(timeout)\n}", "func (rq *requestQueue) cleanup(now metav1.Time) {\n\trq.lock.Lock()\n\tdefer rq.lock.Unlock()\n\tnewRequestList := &requestLinkedList{}\n\tnewRequestMap := map[string]request{}\n\trq.requestList.Range(func(requestID string) bool {\n\t\treq := rq.requestMap[requestID]\n\t\t// Checking expiration\n\t\tif now.After(req.expiration.Time) {\n\t\t\tlogrus.Infof(\"request id %s expired\", req.id)\n\t\t\treturn true\n\t\t}\n\t\t// Keeping\n\t\tnewRequestList.Append(requestID)\n\t\tnewRequestMap[requestID] = req\n\t\treturn true\n\t})\n\trq.requestMap = newRequestMap\n\trq.requestList = newRequestList\n}", "func handleTimeoutNotification(task *task.MessageTask, env *task.Env) {\n\tkey := fmt.Sprintf(\"%x\", task.GetMessage().Token)\n\tdelete(env.Requests(), key)\n\tlog.Info(\"<<< handleTimeout Notification>>>\")\n}", "func (p *Strings) PurgeOldRecords() {\n\tp.mu.Lock()\n\tdefer p.mu.Unlock()\n\tnow := time.Now()\n\tfor t := range p.set {\n\t\tif now.Sub(t).Hours() > 2 {\n\t\t\tdelete(p.set, t)\n\t\t}\n\t}\n}", "func (c *cache) purge() {\n\tp := make([]item, c.maxSize)\n\tt := time.Now()\n\tn := 0\n\tfor i := 0; i < c.curSize; i++ {\n\t\tif t.Sub(c.stories[i].t) < c.timeout {\n\t\t\tp[n] = c.stories[i]\n\t\t\tn++\n\t\t}\n\t}\n\tc.mutx.Lock()\n\tdefer c.mutx.Unlock()\n\tc.stories = p\n\tc.curSize = n\n}", "func (tm *ServiceTracerouteManager) ClearLogsMap() {\n\ttm.logsMapMutex.Lock()\n\n\tfor _, v := range tm.LogsMap {\n\t\tnow := time.Now().UnixNano()\n\n\t\tif v.FinishedAt <= 0 || v.IsRunning {\n\t\t\tcontinue\n\t\t}\n\n\t\tif ((now-v.FinishedAt)/int64(time.Second)) > tm.LogsMapTTL && tm.LogsMapTTL >= 0 {\n\t\t\ttm.RemoveLogsMap(v)\n\t\t}\n\t}\n\n\ttm.logsMapMutex.Unlock()\n}", "func handleTimeout(task *task.MessageTask, env *task.Env) {\n\tkey := fmt.Sprintf(\"%x\", task.GetMessage().Token)\n\tdelete(env.Requests(), key)\n\tlog.Info(\"<<< handleTimeout >>>\")\n}", "func (th *TxHistory) Clear() {\n\tfor i := 0; i < dbtypes.NumIntervals; i++ {\n\t\tth.TypeByInterval[i] = nil\n\t\tth.AmtFlowByInterval[i] = nil\n\t}\n}", "func (f *Sink) resetTimeoutTimer() {\n\tif f.timeoutList.Len() == 0 {\n\t\tf.timeoutTimer.Stop()\n\t\treturn\n\t}\n\n\ttimeout := f.timeoutList.Front().Value.(*Timeout)\n\tlog.Debug(\"Timeout timer reset - due at %v\", timeout.timeoutDue)\n\tf.timeoutTimer.Reset(timeout.timeoutDue.Sub(time.Now()))\n}", "func Clean(s *store.Store, p consensus.Proposer, t <-chan int64) {\n\tfor now := range t {\n\t\tdelAll(p, expired(s, now))\n\t}\n}", "func (k *Kuzzle) cleanQueue() {\n\tnow := time.Now()\n\tnow = now.Add(-k.queueTTL * time.Millisecond)\n\n\t// Clean queue of timed out query\n\tif k.queueTTL > 0 {\n\t\tvar query *types.QueryObject\n\t\tfor _, query = range k.offlineQueue {\n\t\t\tif query.Timestamp.Before(now) {\n\t\t\t\tk.offlineQueue = k.offlineQueue[1:]\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif k.queueMaxSize > 0 && len(k.offlineQueue) > k.queueMaxSize {\n\t\tfor len(k.offlineQueue) > k.queueMaxSize {\n\t\t\teventListener := k.eventListeners[event.OfflineQueuePop]\n\t\t\tfor c := range eventListener {\n\t\t\t\tjson, _ := json.Marshal(k.offlineQueue[0])\n\t\t\t\tc <- json\n\t\t\t}\n\n\t\t\teventListener = k.eventListenersOnce[event.OfflineQueuePop]\n\t\t\tfor c := range eventListener {\n\t\t\t\tjson, _ := json.Marshal(k.offlineQueue[0])\n\t\t\t\tc <- json\n\t\t\t\tdelete(k.eventListenersOnce[event.OfflineQueuePop], c)\n\t\t\t}\n\n\t\t\tk.offlineQueue = k.offlineQueue[1:]\n\t\t}\n\t}\n}", "func (client *clientInfo) cleanUpHandlers() {\n\tclient.mtx.Lock()\n\tdefer client.mtx.Unlock()\n\tvar expired []uint64\n\tfor id, handler := range client.respHandlers {\n\t\tif time.Until(handler.expiration) < 0 {\n\t\t\texpired = append(expired, id)\n\t\t}\n\t}\n\tfor _, id := range expired {\n\t\tdelete(client.respHandlers, id)\n\t}\n}", "func (rmc *RMakeConf) Clean() {\n\tfor _, v := range rmc.Files {\n\t\tv.LastTime = time.Now().AddDate(-20, 0, 0)\n\t}\n\trmc.Session = \"\"\n}", "func (e *etcdCacheEntry) RemoveAllObservers() {\n e.Lock()\n defer e.Unlock()\n e.observers = make([]etcdObserver, 0)\n}", "func (m *MemLimiter) CleanUp() {\n\tfor {\n\t\ttime.Sleep(m.cfg.SweepInterval * time.Second)\n\t\tm.l.Lock()\n\t\tfor t, l := range m.limiters {\n\t\t\tfor val, cl := range l {\n\t\t\t\tif time.Now().Sub(cl.lastSeen) > m.cfg.Age*time.Second {\n\t\t\t\t\tdelete(m.limiters[t], val)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tm.l.Unlock()\n\t}\n}", "func (c *AssertionImpl) RemoveExpiredValues() {\n\tfor _, v := range c.cache.GetAll() {\n\t\tvalue := v.(*assertionCacheValue)\n\t\tdeleteCount := 0\n\t\tvalue.mux.Lock()\n\t\tif value.deleted {\n\t\t\tvalue.mux.Unlock()\n\t\t\tcontinue\n\t\t}\n\t\tfor key, va := range value.assertions {\n\t\t\tif va.expiration < time.Now().Unix() {\n\t\t\t\tc.mux.Lock()\n\t\t\t\tc.entriesPerAssertionMap[va.assertion.Hash()]--\n\t\t\t\tc.mux.Unlock()\n\t\t\t\tdelete(value.assertions, key)\n\t\t\t\tdeleteCount++\n\t\t\t}\n\t\t}\n\t\tif len(value.assertions) == 0 {\n\t\t\tvalue.deleted = true\n\t\t\tc.cache.Remove(value.cacheKey)\n\t\t\tif set, ok := c.zoneMap.Get(value.zone); ok {\n\t\t\t\tset.(*safeHashMap.Map).Remove(value.cacheKey)\n\t\t\t}\n\t\t}\n\t\tvalue.mux.Unlock()\n\t\tc.counter.Sub(deleteCount)\n\t}\n}", "func (r *registry) cleanUpFinished() time.Duration {\n\tstartTime := time.Now()\n\tif r.entries.taskCount.Load() == 0 {\n\t\tif r.entries.len() <= entriesSizeHW {\n\t\t\treturn cleanupInterval\n\t\t}\n\t}\n\tanyTaskDeleted := false\n\ttoRemove := make([]string, 0, 100)\n\tr.entries.forEach(func(entry baseEntry) bool {\n\t\tvar (\n\t\t\txact = entry.Get()\n\t\t\teID = xact.ID()\n\t\t)\n\n\t\tif !xact.Finished() {\n\t\t\treturn true\n\t\t}\n\n\t\t// if entry is type of task the task must be cleaned up always - no extra\n\t\t// checks besides it is finished at least entryOldAge ago.\n\t\t//\n\t\t// We need to check if the entry is not the most recent entry for\n\t\t// given kind. If it is we want to keep it anyway.\n\t\tswitch cmn.XactsMeta[entry.Kind()].Type {\n\t\tcase cmn.XactTypeGlobal:\n\t\t\tentry := r.entries.findUnlocked(XactQuery{Kind: entry.Kind(), OnlyRunning: true})\n\t\t\tif entry != nil && entry.Get().ID() == eID {\n\t\t\t\treturn true\n\t\t\t}\n\t\tcase cmn.XactTypeBck:\n\t\t\tbck := cluster.NewBckEmbed(xact.Bck())\n\t\t\tcmn.Assert(bck.HasProvider())\n\t\t\tentry := r.entries.findUnlocked(XactQuery{Kind: entry.Kind(), Bck: bck, OnlyRunning: true})\n\t\t\tif entry != nil && entry.Get().ID() == eID {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\n\t\tif xact.EndTime().Add(entryOldAge).Before(startTime) {\n\t\t\t// xaction has finished more than entryOldAge ago\n\t\t\ttoRemove = append(toRemove, eID.String())\n\t\t\tif cmn.XactsMeta[entry.Kind()].Type == cmn.XactTypeTask {\n\t\t\t\tanyTaskDeleted = true\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t\treturn true\n\t})\n\n\tfor _, id := range toRemove {\n\t\tr.entries.remove(id)\n\t}\n\n\t// free all memory taken by cleaned up tasks\n\t// Tasks like ListObjects ones may take up huge amount of memory, so they\n\t// must be cleaned up as soon as possible\n\tif anyTaskDeleted {\n\t\tcmn.FreeMemToOS(time.Second)\n\t}\n\treturn cleanupInterval\n}", "func (ca *myCache) DeleteExpiredData() {\n now := time.Now().UnixNano()\n ca.mu.Lock()\n defer ca.mu.Unlock()\n\n for k,v := range ca.dataBlocks {\n if v.ExpirateTime >0 && now > v.ExpirateTime {\n ca.delete(k)\n }\n }\n}", "func (s *HttpServer) jobRemover() {\n\tfor id:=range job.RemoveJob{\n\t\ts.cron.Remove(cron.EntryID(id))\n\t\tlog.Printf(\"entry %v is expired and removed \\n\",id)\n\t}\n}", "func (a *AzureMonitor) Reset() {\n\tfor tbucket := range a.cache {\n\t\t// Remove aggregates older than 30 minutes\n\t\tif tbucket.Before(a.timeFunc().Add(-time.Minute * 30)) {\n\t\t\tdelete(a.cache, tbucket)\n\t\t\tcontinue\n\t\t}\n\t\t// Metrics updated within the latest 1m have not been pushed and should\n\t\t// not be cleared.\n\t\tif tbucket.After(a.timeFunc().Add(-time.Minute)) {\n\t\t\tcontinue\n\t\t}\n\t\tfor id := range a.cache[tbucket] {\n\t\t\ta.cache[tbucket][id].updated = false\n\t\t}\n\t}\n}", "func (c DeferDirCollector) Clear() {\n\tfor k := range c {\n\t\tdelete(c, k)\n\t}\n}", "func (m *TrxMgr) cleanExpiredWaiting() {\n\t// when the waiting pool is small, we don't need cleaning\n\tif len(m.waiting) < sWaitingCountWaterMark {\n\t\treturn\n\t}\n\t// we avoid frequent cleaning\n\tif headBlockTime := atomic.LoadUint32(&m.headTime); headBlockTime > 0 && time.Since(m.lastCleanTime) > sMinCleanupInterval {\n\t\tm.lastCleanTime = time.Now()\n\t\tfor k, e := range m.waiting {\n\t\t\tif err := e.CheckExpiration(headBlockTime); err != nil {\n\t\t\t\tm.deliverEntry(e)\n\t\t\t}\n\t\t\tdelete(m.waiting, k)\n\t\t}\n\t}\n}", "func CleanupTimer(t *time.Timer) {\n\t// prevent the timer from firing\n\tt.Stop()\n\n\tselect {\n\tcase <-t.C:\n\t\t// drain the channel in case the timer fired\n\tdefault:\n\t\t// do not block if channel is already empty\n\t}\n}", "func (m *MailboxMemoryCache) CleanUp(Duration time.Duration) {\n\t// acquire lock\n\tm.Mutex.Lock()\n\tdefer m.Mutex.Unlock()\n\t// walk all mailboxes\n\tthreshold := time.Now().Add(-Duration)\n\tfor name, mailbox := range m.Data {\n\t\t// blocked mailboxes should stay blocked\n\t\tif mailbox.Blocked {\n\t\t\tcontinue\n\t\t}\n\t\t// clean up expired records\n\t\tvar Messages []Message\n\t\tfor _, message := range mailbox.Messages {\n\t\t\tif threshold.Before(message.QueueTime) {\n\t\t\t\tMessages = append(Messages, message)\n\t\t\t}\n\t\t}\n\t\t// remove cache for expired records\n\t\tif len(Messages) == 0 {\n\t\t\tdelete(m.Data, name)\n\t\t\tcontinue\n\t\t}\n\t\t// set new log\n\t\tmailbox.Messages = Messages\n\t\tm.Data[name] = mailbox\n\t}\n}", "func (rp *Pool) StopTimers() {\n\trp.lock.Lock()\n\tdefer rp.lock.Unlock()\n\n\trp.stopped = true\n\n\tfor _, element := range rp.existMap {\n\t\titem := element.Value.(*requestItem)\n\t\titem.timeout.Stop()\n\t}\n\n\trp.logger.Debugf(\"Stopped all timers: size=%d\", len(rp.existMap))\n}", "func (c *TimerCond) Clear() {\n\titerOptionalFields(reflect.ValueOf(c).Elem(), nil, func(name string, val optionalVal) bool {\n\t\tval.Clear()\n\t\treturn true\n\t})\n\tc.KeyPrefix = false\n}", "func (collector *Collector) resetTimeout() {\n\t// We only need to do something if there actually is a ticker (ie: if an interval was specified)\n\tif collector.ticker != nil {\n\t\t// Stop the ticker so it can be garbage collected\n\t\tcollector.ticker.Stop()\n\n\t\t// From everything I've read the only real way to reset a ticker is to recreate it\n\t\tcollector.ticker = time.NewTicker(collector.config.Timeout.Interval)\n\t\tcollector.timeoutChannel = collector.ticker.C\n\t}\n}", "func (wr *WatchList) Clear() {\n\tfor wr.First(); wr.Remove() != nil; {\n\t}\n}", "func (s *storage) cleanExpired(sources pb.SyncMapping, actives pb.SyncMapping) {\nnext:\n\tfor _, entry := range sources {\n\t\tfor _, act := range actives {\n\t\t\tif act.CurInstanceID == entry.CurInstanceID {\n\t\t\t\tcontinue next\n\t\t\t}\n\t\t}\n\n\t\tdelOp := delMappingOp(entry.ClusterName, entry.OrgInstanceID)\n\t\tif _, err := s.engine.Do(context.Background(), delOp); err != nil {\n\t\t\tlog.Errorf(err, \"Delete instance clusterName=%s instanceID=%s failed\", entry.ClusterName, entry.OrgInstanceID)\n\t\t}\n\n\t\ts.deleteInstance(entry.CurInstanceID)\n\t}\n}", "func DeleteEntry(interval float64) {\n\tfor {\n\t\tvar nodes []string\n\t\ttable.Range(func(key, value interface{}) bool {\n\t\t\tnewkey := fmt.Sprintf(\"%v\", key)\n\t\t\tnewvalue := value.(membership)\n\t\t\tif (float64(time.Now().Unix()-newvalue.Time) > interval && key != myid) || newvalue.Status == false {\n\t\t\t\tnodes = append(nodes, newkey)\n\t\t\t\tif newvalue.Status == true {\n\t\t\t\t\tFailuredet.Println(newkey)\n\t\t\t\t}\n\t\t\t\tChangeStatus(newkey)\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t\t//the time between time out and clean\n\t\ttime.Sleep(2e9)\n\t\tfor _, node := range nodes {\n\t\t\ttable.Delete(node)\n\t\t\tip := getIpFromID(node)\n\t\t\treReplicate(indexOfstring(ip, straddr))\n\t\t}\n\t}\n}", "func (s *Memory) CleanEntries() {\n\tdefer s.lock()()\n\ts.entries = []logger.Entry{}\n}", "func (pt ProcessingTime) Clear(p Provider) {\n\tp.Set(TimerMap{Family: pt.Family, Clear: true})\n}", "func (c *Cache) Cleanup() error {\n\treturn c.doSync(func() {\n\t\tif c.entries == nil {\n\t\t\treturn\n\t\t}\n\t\tc.cleanup(c.ttl)\n\t}, defaultTimeout)\n}", "func CacheEvictionScheadular(interval time.Duration) {\r\n\r\n\tfor {\r\n\r\n\t\tfor collection := range twoLevelMap {\r\n\r\n\t\t\tfor key := range twoLevelMap[collection] {\r\n\r\n\t\t\t\tmutex.Lock()\r\n\r\n\t\t\t\tif twoLevelMap[collection][key].IsExpired() {\r\n\r\n\t\t\t\t\tdelete(twoLevelMap[collection], key)\r\n\r\n\t\t\t\t\tlog.Printf(\"Key %q has been removed from collection %q by go routine \", key, collection)\r\n\t\t\t\t}\r\n\r\n\t\t\t\tmutex.Unlock()\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\ttime.Sleep(time.Minute * interval)\r\n\t}\r\n}", "func (c *Cron) clear() error {\n\tconn := c.pool.Get()\n\tdefer conn.Close()\n\treply, err := redis.String(conn.Do(\"SET\", c.keyCleared, 1, \"NX\", \"EX\", 180))\n\tif err != nil && err != redis.ErrNil {\n\t\treturn err\n\t}\n\tif reply != \"OK\" {\n\t\treturn nil\n\t}\n\trunningKeys := make([]interface{}, 0, len(c.entries))\n\tfor _, e := range c.entries {\n\t\tjobKey := c.constructKey(e)\n\t\trunningKeys = append(runningKeys, jobRunningKey(jobKey))\n\t}\n\t_, err = conn.Do(\"DEL\", runningKeys...)\n\treturn err\n}", "func (s *Scheduler) Clear() {\n\tfor i := 0; i < s.size; i++ {\n\t\ts.jobs[i] = nil\n\t}\n\ts.size = 0\n}", "func (r *singleRule) deleteExpired() {\n\tfor range time.Tick(r.cleanupInterval) {\n\t\tr.deleteExpiredOnce()\n\t\tr.recovery()\n\t}\n}", "func (ms *MemStore) CleanupSessionKeys(t uint64) error {\n\tvar oldKeys []string\n\tfor hash, sk := range ms.sessionKeys {\n\t\tif sk.cleanupTime < t {\n\t\t\toldKeys = append(oldKeys, hash)\n\t\t}\n\t}\n\tfor _, hash := range oldKeys {\n\t\tdelete(ms.sessionKeys, hash)\n\t}\n\treturn nil\n}", "func (e *eventsBatcher) clear() {\n\te.meta = map[string]int{}\n\te.evts = []*evtsapi.Event{}\n\te.expiredEvts = []*evtsapi.Event{}\n}", "func (p *IdlePool) Evict(dur time.Duration) {\n\tp.Lock()\n\tdefer p.Unlock()\n\tdeadline := time.Now().Add(-dur)\n\tfor i, t := range p.times {\n\t\te := p.elems[i]\n\t\tif e == nil || t.After(deadline) {\n\t\t\tcontinue\n\t\t}\n\t\te.Close()\n\t\tp.elems[i] = nil\n\t}\n}", "func (t *BackoffTreeTimer) Clear() {\n\tt.slk.Lock()\n\tdefer t.slk.Unlock()\n\tt.state.Clear(time.Now())\n}", "func (m ConcurrentMap[T]) Clear() {\n\tfor _, shard := range m.shards {\n\t\tshard.Lock()\n\t\tshard.items = make(map[string]T)\n\t\tshard.Unlock()\n\t}\n}", "func (h *TunnelHandler) Clean() {\n\th.mu.Lock()\n\tremoved := make([]string, 0, len(h.tunnels))\n\tfor id, tunnel := range h.tunnels {\n\t\tselect {\n\t\tcase <-tunnel.chDone:\n\t\t\tremoved = append(removed, id)\n\t\tdefault:\n\t\t}\n\t}\n\th.mu.Unlock()\n\n\tfor _, id := range removed {\n\t\th.remove(id)\n\t}\n}", "func (rate *Ratelimiter) cleanup() (empty bool) {\n\trate.mu.Lock()\n\tdefer rate.mu.Unlock()\n\n\tfor key, entry := range rate.tableIPv4 {\n\t\tentry.mu.Lock()\n\t\tif rate.timeNow().Sub(entry.lastTime) > garbageCollectTime {\n\t\t\tdelete(rate.tableIPv4, key)\n\t\t}\n\t\tentry.mu.Unlock()\n\t}\n\n\tfor key, entry := range rate.tableIPv6 {\n\t\tentry.mu.Lock()\n\t\tif rate.timeNow().Sub(entry.lastTime) > garbageCollectTime {\n\t\t\tdelete(rate.tableIPv6, key)\n\t\t}\n\t\tentry.mu.Unlock()\n\t}\n\n\treturn len(rate.tableIPv4) == 0 && len(rate.tableIPv6) == 0\n}", "func CleanCache(t *testing.T) {\n\tt.Cleanup(func() {\n\t\tevents = events.Clone()\n\t})\n}", "func (l *GoLimiter) cleanupVisitors() {\n\texpiration, _ := strconv.ParseInt(os.Getenv(environment.RateLimitExpirationSecond), 10, 64)\n\tfor {\n\t\ttime.Sleep(time.Minute)\n\n\t\tl.mu.Lock()\n\t\tfor ip, v := range l.visitors {\n\t\t\tif time.Since(v.lastSeen) > time.Duration(expiration)*time.Second {\n\t\t\t\tdelete(l.visitors, ip)\n\t\t\t}\n\t\t}\n\t\tl.mu.Unlock()\n\t}\n}", "func (f *Frontend) EvictAll(t time.Duration) {\n\tf.cache.evictFrontend(f.id, t)\n}", "func (c *cache) DeleteExpired() {\n\tnow := time.Now().UnixNano()\n\tfor i := range c.shards {\n\t\tsh := c.shards[i]\n\t\tsh.l.Lock()\n\t\tfor k, v := range sh.m {\n\t\t\tif v.Expiration > 0 && now > v.Expiration {\n\t\t\t\tatomic.AddInt32(&c.Statistic.DeleteExpired, 1)\n\t\t\t\tatomic.AddInt32(&c.Statistic.ItemsCount, -1)\n\t\t\t\tatomic.AddInt32(&c.Statistic.ItemsCount, -v.Size)\n\t\t\t\tdelete(sh.m, k)\n\t\t\t}\n\t\t}\n\t\tsh.l.Unlock()\n\t}\n\n}", "func (m *Manager) RemoveAllAndWait() {\n\tctrls := m.removeAll()\n\tfor _, ctrl := range ctrls {\n\t\t<-ctrl.terminated\n\t}\n}", "func (m *Manager) RemoveAllAndWait() {\n\tctrls := m.removeAll()\n\tfor _, ctrl := range ctrls {\n\t\t<-ctrl.terminated\n\t}\n}", "func (t *CleanupTasks) Clear() {\n\t*t = nil\n}", "func cleanUpSubmittedTxs(ctx context.Context, db pg.DB) {\n\tticker := time.NewTicker(15 * time.Minute)\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\t// TODO(jackson): We could avoid expensive bulk deletes by partitioning\n\t\t\t// the table and DROP-ing tables of expired rows. Partitioning doesn't\n\t\t\t// play well with ON CONFLICT clauses though, so we would need to rework\n\t\t\t// how we guarantee uniqueness.\n\t\t\tconst q = `DELETE FROM submitted_txs WHERE submitted_at < now() - interval '1 day'`\n\t\t\t_, err := db.Exec(ctx, q)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(ctx, err)\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\tticker.Stop()\n\t\t\treturn\n\t\t}\n\t}\n}", "func (c *Counter) removeExpiredBuckets() {\n\tnow := time.Now().Unix() - c.MaxSize\n\n\tfor timestamp := range c.Buckets {\n\t\tif timestamp <= now {\n\t\t\tc.Sum-=c.Buckets[timestamp].Value\n\t\t\tdelete(c.Buckets, timestamp)\n\t\t}\n\t}\n}", "func (tt *TtTable) Clear() {\n\t// Create new slice/array - garbage collections takes care of cleanup\n\ttt.data = make([]TtEntry, tt.maxNumberOfEntries, tt.maxNumberOfEntries)\n\ttt.numberOfEntries = 0\n\ttt.Stats = TtStats{}\n}", "func cacheCleanService(t *Cache) {\n\tticker := time.NewTicker(t.cleanupPeriod).C\n\tfor range ticker {\n\t\tt.Lock()\n\t\tt.txnsMaps[1] = t.txnsMaps[0]\n\t\tt.txnsMaps[0] = make(txnsMap)\n\t\tt.Unlock()\n\t}\n}", "func (c *Cache) EvictAll(t time.Duration) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tfor i := range c.frontends {\n\t\tc.evictFrontendWithLock(i, t)\n\t}\n}", "func (m MessageDescriptorMap) Cleanup() (deleted []string) {\n\tfor id, descriptor := range m {\n\t\tif !descriptor.Touched() {\n\t\t\tdelete(m, id)\n\t\t\tdeleted = append(deleted, id)\n\t\t}\n\t}\n\treturn\n}", "func Cleaner(done chan bool) {\n\ttime.Sleep(8 * time.Second)\n\tfmt.Println(\"hi from clean\")\n\t//worst case scenario where all are not completed\n\tfor i := 0; i < 10; i++ {\n\n\t\tif len(list) == 0 {\n\t\t\tfmt.Println(\"waiting for added to add tasks\")\n\t\t\tbreak\n\t\t}\n\n\t\telement := list[k]\n\t\tif element.IsCompleted == true {\n\t\t\tremoveIndex(k)\n\t\t\t//k = k + 1\n\t\t} else {\n\t\t\tif element.Status == \"timeout\" && element.Timeout > 3 {\n\t\t\t\tremoveIndex(k)\n\t\t\t\tlog.Printf(\"removing the Task %v with description %v because timeout was %v\", element.Id, element.TaskData, element.Timeout)\n\t\t\t} else {\n\t\t\t\tremoveIndex(k)\n\t\t\t\t// sudo case just making this status as completed\n\t\t\t\t//asumption that after retry task got completed\n\t\t\t\telement.IsCompleted = true\n\t\t\t\telement.Status = \"completed\"\n\t\t\t\tcompletedTask++\n\t\t\t\tmutex.Lock()\n\t\t\t\tlist = append(list, element)\n\t\t\t\tmutex.Unlock()\n\t\t\t\t//log.Printf(\"Removed data %v with id %v \", element.TaskData, element.Id)\n\t\t\t}\n\t\t}\n\t}\n\tdone <- true\n\n}", "func DeleteAfter(t Time, L *list.List) {\n\tif L.Len() == 0 {\n\t\treturn\n\t}\n\tfront := L.Front()\n\tif front.Value.(Elem).GetTime() >= t {\n\t\tL = L.Init()\n\t\treturn\n\t}\nLoop:\n\tfor {\n\t\tel := L.Back()\n\t\tif el.Value.(Elem).GetTime() >= t {\n\t\t\tL.Remove(el)\n\t\t} else {\n\t\t\tbreak Loop\n\t\t}\n\t}\n}", "func (c Collector) Clear() {\n\tfor k := range c {\n\t\tdelete(c, k)\n\t}\n}", "func (c *CIFImporter) cleanup() error {\n log.Println(\"Removing historic associations\")\n res, err := c.db.Exec(\"DELETE FROM timetable.assoc WHERE enddate < NOW()::DATE\")\n if err != nil {\n return err\n }\n rc, err := res.RowsAffected()\n if err != nil {\n return err\n }\n if rc > 0 {\n log.Printf(\"Removed %d associations\", rc)\n }\n\n log.Println(\"Removing historic schedules\")\n res, err = c.db.Exec(\"DELETE FROM timetable.schedule WHERE enddate < NOW()::DATE\")\n if err != nil {\n return err\n }\n rc, err = res.RowsAffected()\n if err != nil {\n return err\n }\n if rc > 0 {\n log.Printf(\"Removed %d schedules\", rc)\n }\n\n log.Println(\"Fixing tiploc crs codes\")\n _, err = c.db.Exec(\"SELECT timetable.fixtiploccrs()\")\n if err != nil {\n return err\n }\n\n return nil\n}", "func (conn *Conn) Clear() {\n\tdb := conn.db\n\tfor i := 0; i < 15; i++ {\n\t\t_, err := db.Exec(\"TRUNCATE TABLE unsub_\" + strconv.Itoa(i))\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error clearing tables: %v\\n\", err)\n\t\t\treturn\n\t\t}\n\t}\n}", "func (s *ShardMap) CleanUp(clock int32) {\n\tfClock := float64(clock)\n\tfor i := range s.mutexes {\n\t\tm := &s.mutexes[i]\n\t\tm.Lock()\n\n\t\tfor k := range s.shards[i] {\n\t\t\tif s.shards[i][k].FrontTile < fClock {\n\t\t\t\tdelete(s.shards[i], k)\n\t\t\t}\n\t\t}\n\n\t\tm.Unlock()\n\t}\n}", "func (p *HbaseClient) DeleteAllTs(tableName Text, row Text, column Text, timestamp int64, attributes map[string]Text) (err error) {\n\tif err = p.sendDeleteAllTs(tableName, row, column, timestamp, attributes); err != nil {\n\t\treturn\n\t}\n\treturn p.recvDeleteAllTs()\n}", "func (c *DictCache) Pop() {\n\tfor k, t := range c.entries {\n\t\tif time.Since(t) > c.timeout {\n\t\t\tdelete(c.entries, k)\n\t\t\tc.count--\n\t\t}\n\t}\n}", "func (e *Event) ClearAllHandlers() {\n e.mu.Lock()\n defer e.mu.Unlock()\n e.events = make(map[string][]EventHandler)\n e.syncEvents = make(map[string][]EventHandler)\n}", "func (c *TimeoutChan) Clear() int {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tc.pushCtrl.Shutdown()\n\tc.popCtrl.Shutdown()\n\tl := c.pq.Clear()\n\tif c.limit > 0 && l == c.limit {\n\t\tdefer func() { c.resumePush <- nil }() // queue is not full, resume\n\t}\n\tc.cleared += l\n\tc.pushCtrl = NewController(c.ctx, \"TimeoutChan Push\")\n\tc.popCtrl = NewController(c.ctx, \"TimeoutChan Pop\")\n\tc.popCtrl.Go(c.popProcess)\n\tc.pushCtrl.Go(c.pushProcess)\n\treturn l\n}", "func (s *signatureCache) Evict(currRound uint64) {\n\tfor round := range s.cache {\n\t\tif round < (currRound - maxRoundDelta) {\n\t\t\tdelete(s.cache, round)\n\t\t}\n\t}\n}", "func CleanTask() {\n\tfor taskID, t := range kv.DefaultClient.GetStorage().Tasks {\n\t\tflag := true\n\t\tfor nid := range kv.DefaultClient.GetStorage().Nodes {\n\t\t\tif t.NodeID == nid {\n\t\t\t\tflag = false\n\t\t\t}\n\t\t}\n\t\tif flag {\n\t\t\tif t.Timer {\n\t\t\t\tlog.Info(\"clean timer:\", taskID)\n\t\t\t\tormTimer := new(orm.Timer)\n\t\t\t\tormTimer.ID = taskID\n\t\t\t\tormTimer.Status = false\n\t\t\t\terr := orm.UpdateTimerStatus(ormTimer)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Error(err)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlog.Info(\"clean task:\", taskID)\n\t\t\t\tormTask := new(orm.Task)\n\t\t\t\tormTask.ID = taskID\n\t\t\t\tormTask.Status = \"error\"\n\t\t\t\terr := orm.UpdateTask(ormTask)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Error(err)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tkv.DefaultClient.DeleteTask(taskID)\n\t\t}\n\t}\n}", "func (o *Objects) gc() {\n\to.RLock()\n\tgcInterval := o.gcInterval\n\to.RUnlock()\n\n\tt := time.NewTicker(time.Duration(gcInterval) * time.Second)\n\tfor {\n\t\tselect {\n\t\tcase <-o.gcExit:\n\t\t\tt.Stop()\n\t\t\treturn\n\t\tcase <-t.C:\n\t\t\to.RLock()\n\t\t\te := []string{}\n\t\t\tfor k, v := range o.values {\n\t\t\t\tif v.expired() {\n\t\t\t\t\te = append(e, k)\n\t\t\t\t\tif len(e) >= o.gcMaxOnce {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\to.RUnlock()\n\t\t\to.Lock()\n\t\t\tfor _, k := range e {\n\t\t\t\tdelete(o.values, k)\n\t\t\t}\n\t\t\to.Unlock()\n\t\t}\n\t}\n}", "func (diffStore *utxoDiffStore) clearOldEntries() {\n\tdiffStore.mtx.HighPriorityWriteLock()\n\tdefer diffStore.mtx.HighPriorityWriteUnlock()\n\n\tvirtualBlueScore := diffStore.dag.VirtualBlueScore()\n\tminBlueScore := virtualBlueScore - maxBlueScoreDifferenceToKeepLoaded\n\tif maxBlueScoreDifferenceToKeepLoaded > virtualBlueScore {\n\t\tminBlueScore = 0\n\t}\n\n\ttips := diffStore.dag.virtual.tips()\n\n\ttoRemove := make(map[*blockNode]struct{})\n\tfor node := range diffStore.loaded {\n\t\tif node.blueScore < minBlueScore && !tips.contains(node) {\n\t\t\ttoRemove[node] = struct{}{}\n\t\t}\n\t}\n\tfor node := range toRemove {\n\t\tdelete(diffStore.loaded, node)\n\t}\n}", "func getStalePortEntriesForDeletion(ids []string) []string {\n\n\tvar deletePortList []string\n\n\tcurrentTime := (time.Now().UnixNano()) / 1000000\n\tfor _, staleID := range ids {\n\t\tif _, ok := stalePortMap[staleID]; !ok {\n\t\t\tstalePortMap[staleID] = currentTime\n\t\t}\n\n\t\ttimeDiff := (currentTime - stalePortMap[staleID]) / 1000\n\t\tif timeDiff >= staleEntryTimeout {\n\t\t\tdeletePortList = append(deletePortList, staleID)\n\t\t}\n\t}\n\n\t// Delete resolved alubr0 ports earlier marked as stale\n\t// from stale port map\n\tkeyFound := false\n\tfor key := range stalePortMap {\n\t\tfor _, staleID := range ids {\n\t\t\tif key == staleID {\n\t\t\t\tlog.Debugf(\"Entry %s is still not resolved or is a stale entry\", key)\n\t\t\t\tkeyFound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !keyFound {\n\t\t\tdelete(staleEntityMap, key)\n\t\t} else {\n\t\t\tkeyFound = false\n\t\t}\n\t}\n\n\treturn deletePortList\n}", "func (ttlmap *TTLMap) clearSchedule(key interface{}) {\n\tttlmap.sMutex.Lock()\n\tdefer ttlmap.sMutex.Unlock()\n\tdelete(ttlmap.schedule, key)\n}", "func (r *RouteTable) cleanUpPendingConntrackDeletions() {\n\tfor ipAddr, c := range r.pendingConntrackCleanups {\n\t\tselect {\n\t\tcase <-c:\n\t\t\tlog.WithField(\"ip\", ipAddr).Debug(\n\t\t\t\t\"Background goroutine finished deleting conntrack entries\")\n\t\t\tdelete(r.pendingConntrackCleanups, ipAddr)\n\t\tdefault:\n\t\t\tlog.WithField(\"ip\", ipAddr).Debug(\n\t\t\t\t\"Background goroutine yet to finish deleting conntrack entries\")\n\t\t\tcontinue\n\t\t}\n\t}\n}", "func (w *WindowedMap) ExpireOldEntries() {\n\tif len(w.uidList) != len(w.uidMap) {\n\t\tpanic(*w)\n\t}\n\tnow := w.clock.Now()\n\tfor len(w.uidList) > 0 && !w.uidList[0].expire.After(now) {\n\t\tdelete(w.uidMap, w.uidList[0].uid)\n\t\theap.Remove(&w.uidList, 0)\n\t}\n}", "func cleanCron() {\n\tfor _, entry := range mainCron.Entries() {\n\t\tif entry.Schedule.Next(Now()).IsZero() {\n\t\t\tmainCron.Remove(entry.ID)\n\t\t\tremoveJob(entry.ID, true)\n\t\t}\n\t}\n}", "func (s *section) Flush() {\n\tfor k := range s.tm.container {\n\t\tif k.sec == s.sec {\n\t\t\ts.tm.remove(k.key, k.sec)\n\t\t}\n\t}\n}" ]
[ "0.69287455", "0.6554908", "0.6453934", "0.6440446", "0.64257973", "0.63104635", "0.6260074", "0.62492746", "0.61692584", "0.6131255", "0.6068482", "0.604764", "0.5971219", "0.59709215", "0.5851706", "0.58517045", "0.57964075", "0.5794167", "0.57497156", "0.57259923", "0.5690517", "0.5673349", "0.56444806", "0.562886", "0.5625827", "0.5619624", "0.5608379", "0.56031376", "0.5593123", "0.55741906", "0.5561569", "0.5547961", "0.55399054", "0.55308837", "0.5530017", "0.5526097", "0.55167973", "0.5504536", "0.5504098", "0.5496916", "0.5490614", "0.547607", "0.5464647", "0.54582286", "0.54507434", "0.5449742", "0.54468834", "0.54449147", "0.543712", "0.5436896", "0.5432942", "0.54141384", "0.5410997", "0.5404695", "0.5398557", "0.53972185", "0.5393005", "0.5391475", "0.53685", "0.536156", "0.53594214", "0.5351973", "0.5347509", "0.53369373", "0.5326201", "0.53156275", "0.5309145", "0.5307471", "0.52885044", "0.5283439", "0.5278718", "0.5277829", "0.5277829", "0.526043", "0.52541417", "0.525066", "0.52396697", "0.5236773", "0.5227174", "0.5226595", "0.52259296", "0.5222075", "0.52098256", "0.52033913", "0.51922", "0.5190074", "0.5182607", "0.51722527", "0.5168162", "0.5166637", "0.5165414", "0.5155673", "0.5155062", "0.515439", "0.51531166", "0.515275", "0.51397145", "0.5128286", "0.5114264", "0.5110075" ]
0.55146873
37
Add adds a value to the cache.
func (c *TimeoutCache) Add(key, value interface{}) { c.lock.Lock() defer c.lock.Unlock() // Check for existing item if ent, ok := c.items[key]; ok && ent != nil { c.items[key] = value return } // Add new item ent := &entry{key, value, time.Now().Add(time.Duration(c.evictAfter * int64(time.Second))).Unix()} c.evictList.PushFront(ent) c.items[key] = value }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Cache) Add(key lru.Key, value interface{}) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tc.cache.Add(key, value)\n}", "func (c *Cache) Add(key string, value []byte, ttl int64) error {\n\tif err := c.exists(key); err == nil {\n\t\treturn errors.NewAlreadyExistingKey(key)\n\t}\n\n\treturn c.Set(key, value, ttl)\n}", "func (c *Cache) Add(key string, value Value) {\n\tif item, ok := c.cache[key]; ok {\n\t\tc.ll.MoveToFront(item)\n\t\tkv := item.Value.(*entry)\n\t\tc.nBytes += int64(value.Len()) - int64(kv.value.Len())\n\t\tkv.value = value\n\t} else {\n\t\titem := c.ll.PushFront(&entry{key, value})\n\t\tc.cache[key] = item\n\t\tc.nBytes += int64(len(key)) + int64(value.Len())\n\t}\n\tfor c.maxBytes != 0 && c.maxBytes < c.nBytes {\n\t\tc.RemoveOldest()\n\t}\n}", "func (c *LRU) Add(key, value interface{}) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\t// Already in cache?\n\tif ee, ok := c.cache[key]; ok {\n\t\tc.ll.MoveToFront(ee)\n\t\tee.Value.(*entry).value = value\n\t\treturn\n\t}\n\n\t// Add to cache if not present\n\tele := c.ll.PushFront(&entry{key, value})\n\tc.cache[key] = ele\n\n\tif c.ll.Len() > c.maxEntries {\n\t\tc.removeOldest(runEvictionNotifier)\n\t}\n}", "func (c *Cache) Add(key Key, value interface{}, ttl int) {\r\n\tc.Lock()\r\n\tdefer c.Unlock()\r\n\r\n\tif c.cache == nil {\r\n\t\tc.cache = make(map[interface{}]*list.Element)\r\n\t\tc.ll = list.New()\r\n\t}\r\n\r\n\tif ee, ok := c.cache[key]; ok {\r\n\t\tc.ll.MoveToFront(ee)\r\n\t\te := ee.Value.(*entry)\r\n\r\n\t\te.value = value\r\n\t\te.born = time.Now().Unix()\r\n\t\te.ttl = int64(ttl)\r\n\t\te.hits++\r\n\t\treturn\r\n\t}\r\n\r\n\tele := c.ll.PushFront(&entry{key, value, time.Now().Unix(), int64(ttl), 0})\r\n\tc.cache[key] = ele\r\n\tif c.MaxEntries != 0 && c.ll.Len() > c.MaxEntries {\r\n\t\tc.removeOldest()\r\n\t}\r\n}", "func (mc *MemCache) Add(key string, value interface{}) {\n\t_, expTime, found := mc.c.GetWithExpiration(key)\n\tif found { // do not reset expiration if the key already exists\n\t\tmc.c.Set(key, value, time.Until(expTime))\n\t\treturn\n\t}\n\n\tmc.c.Set(key, value, mc.expiration)\n}", "func (c *Cache) Add(key string, data interface{}) error{\n c.cacheMutex.Lock()\n defer c.cacheMutex.Unlock()\n\n if !cache.isValid {\n return errors.New(\"The cache is now invalid.\")\n }\n\n c.cache[key] = value{\n time: time.Now(),\n value: data}\n\n return nil\n}", "func (j *Cache) Add(key string, value []byte) error {\n\treturn j.client.Add(&memcache.Item{Key: key, Value: value})\n}", "func (c *LRUExpireCache) Add(key interface{}, value interface{}, ttl time.Duration) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\tc.cache.Add(key, &cacheEntry{value, c.clock.Now().Add(ttl)})\n}", "func (c *Cache) Add(key interface{}, value interface{}) {\n\tif c.capacity == 0 {\n\t\treturn\n\t}\n\n\tif item, ok := c.items[key]; ok { // already exists\n\t\tc.items[key].value = value\n\t\theap.Fix(c.heap, item.index)\n\t\treturn\n\t}\n\n\tif len(c.items) >= c.capacity {\n\t\tc.evict(1)\n\t}\n\n\tw := wrapper{key: key, value: value}\n\n\theap.Push(c.heap, &w)\n\tc.items[w.key] = &w\n}", "func (c *ExpireCache) Add(key, value interface{}) {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\n\trecord := expireRecord{\n\t\tValue: value,\n\t\tExpireAt: clock.Now().UTC().Add(c.ttl),\n\t}\n\t// Add the record to the cache\n\tc.cache[key] = &record\n}", "func (c *cache) Add(k string, x []byte, d time.Duration) error {\n\t_, found := c.Get(k)\n\tif found {\n\t\treturn fmt.Errorf(\"Item %s already exists\", k)\n\t}\n\tatomic.AddInt32(&c.Statistic.AddCount, 1)\n\tatomic.AddInt32(&c.Statistic.ItemsCount, 1)\n\tatomic.AddInt32(&c.Statistic.Size, int32(len(x)))\n\tc.set(k, x, d)\n\treturn nil\n}", "func (c *cache) Add(k string, x interface{}, d time.Duration) error {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\t_, found := c.get(k)\n\tif found {\n\t\treturn fmt.Errorf(\"Item %s already exists\", k)\n\t}\n\tc.set(k, x, d)\n\treturn nil\n}", "func (hc *HybridCache) Add(key string, value []byte) {\n\t// Only add to memcache\n\thc.mc.Add(key, value)\n}", "func (c *CodeReviewCache) Add(key int64, value *Issue) {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\tc.cache.Add(key, value)\n}", "func (c Redis) Add(key string, value interface{}, expire time.Duration) error {\n\tif !c.conn.SetNX(key, value, expire).Val() {\n\t\treturn cache.ErrNotStored\n\t}\n\treturn nil\n}", "func (storage *Storage) Add(key string, value interface{}) (err error) {\n\ttimeNow := time.Now().Unix()\n\n\tstorage.mutex.Lock()\n\tif e, hit := storage.cache[key]; hit {\n\t\tif payload := e.Value.(*payload); timeNow > payload.Expiration {\n\t\t\t// payload.Key = key\n\t\t\tpayload.Value = value\n\t\t\tpayload.Expiration = timeNow + storage.maxAge\n\t\t\tstorage.lruList.MoveToFront(e)\n\n\t\t\tstorage.mutex.Unlock()\n\t\t\treturn\n\n\t\t} else {\n\t\t\terr = ErrNotStored\n\n\t\t\tstorage.mutex.Unlock()\n\t\t\treturn\n\t\t}\n\n\t} else {\n\t\terr = storage.add(key, value, timeNow)\n\n\t\tstorage.mutex.Unlock()\n\t\treturn\n\t}\n}", "func (c *Cache) Add(key Key, value interface{}) *Cache {\n\tif el, hit := c.cache[key]; hit {\n\t\tel.Value.(*entry).value = value\n\t\tc.ddl.MoveToFront(el)\n\t\treturn c\n\t}\n\n\tif c.ddl.Len() >= c.maxEntries {\n\t\tlel := c.ddl.Back()\n\t\tc.remove(lel)\n\t}\n\n\te := entry{key: key, value: value}\n\tel := c.ddl.PushFront(&e)\n\tc.cache[key] = el\n\treturn c\n}", "func (c *Cache) Add(key interface{}, item caching.Item) {\n\t_, ok := c.load(key)\n\tif ok {\n\t\treturn\n\t}\n\n\tc.store(key, item)\n}", "func (c nullCache) Add(k string, v interface{}, expire time.Duration) error {\n\treturn nil\n}", "func (c *LRUCache) Add(key string, value interface{}) (cachedValue interface{}, done func(), added bool) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif o, ok := c.cache.Get(key); ok {\n\t\trc := o.(*refCounter)\n\t\trc.inc()\n\t\treturn rc.v, c.decreaseOnceFunc(rc), false\n\t}\n\trc := &refCounter{\n\t\tkey: key,\n\t\tv: value,\n\t\tonEvicted: c.OnEvicted,\n\t}\n\trc.initialize() // Keep this object having at least 1 ref count (will be decreased in OnEviction)\n\trc.inc() // The client references this object (will be decreased on \"done\")\n\tc.cache.Add(key, rc)\n\treturn rc.v, c.decreaseOnceFunc(rc), true\n}", "func (c *Cache) Add(cr CrawlResult) {\n\tc.mutex.Lock()\n\tc.c[cr.url] = cr\n\tc.mutex.Unlock()\n}", "func (m *mcache) Add(key string, val []byte, expiration time.Duration) (err error) {\n\terr = m.conn.Add(&memcache.Item{Key: key, Value: val})\n\n\tif err == nil {\n\t\tm.conn.Touch(key, int32(expiration*time.Second))\n\t}\n\n\tif err == memcache.ErrNotStored {\n\t\t//Skip error if value exist\n\t\terr = nil\n\t}\n\n\tif err != nil {\n\t\tm.logError(\"Add\", err)\n\t\treturn\n\t}\n\n\tm.logInfo(\"Add \"+key, string(val))\n\n\treturn\n}", "func ( handle *MemcacheClient) Add(key string, value []byte) error {\n\n\tif len(key) <= 0 {\n\t\tlog.Printf(\"Error: passed key to be placd in memcache in blank\\n\")\n\t\treturn fmt.Errorf(\"passed key to be placd in memcache in blank\")\n\t}\n\tlog.Printf(\"Info: memcache set key:%s value:%s\\n\",key , string(value))\n\tit := memcache.Item{Key:key, Value:value, Expiration: defTTL}\n\terr := handle.mc.Set(&it)\n\tif err != nil{\n\t\tlog.Printf(\"Error: unable to set data:%s:%s\\n\",key,err.Error())\n\t\treturn fmt.Errorf(\"unable to set data:%s\\n\",err.Error())\n\t}\n\n\treturn nil\n}", "func (c *Cache) Add(buildid int64, hash string) {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\n\tc.hashes[buildid] = hash\n}", "func Add(c context.Context, key string, data []byte) {\n\tmemcache.Add(c, &memcache.Item{\n\t\tKey: key,\n\t\tValue: data,\n\t})\n}", "func (c *Cache) Add(key, value interface{}) bool {\n\t// Check the existence\n\tif entry, ok := c.mapping[key]; ok {\n\t\tc.evictList.MoveToFront(entry)\n\t\tentry.Value.(*Entry).value = value\n\t\treturn false\n\t}\n\n\t// Add new entry\n\tentry := Entry{\n\t\tkey: key,\n\t\tvalue: value,\n\t}\n\te := c.evictList.PushFront(entry)\n\tc.mapping[key] = e\n\n\t// Check the eviction\n\tif c.evictList.Len() > c.size {\n\t\tc.removeOldest()\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (cache Cache) Add(key string, value string, costFunc func(m map[string]*list.Element, capacity int) int) bool {\n\tlock.Lock()\n\tdefer lock.Unlock()\n\ttotalCost := 0\n\telem, found := cache.cacheMap[key]\n\tif found {\n\t\telem.Value = value\n\t\tcache.linkedList.MoveBefore(elem, cache.linkedList.Front())\n\t\treturn true\n\t} else {\n\t\tif len(cache.cacheMap) >= cache.capacity {\n\t\t\ttotalCost = costFunc(cache.cacheMap, cache.capacity)\n\t\t\tfmt.Println(\"Cost : \", totalCost)\n\t\t\tel := cache.linkedList.Back()\n\t\t\tcache.linkedList.Remove(el)\n\t\t\tnewKey := el.Value.(CacheStruct).key\n\t\t\tdelete(cache.cacheMap, newKey)\n\t\t}\n\t\tentry := CacheStruct{key: key, value: value}\n\t\tnewItem := cache.linkedList.PushFront(entry)\n\t\tcache.cacheMap[key] = newItem\n\t\treturn true\n\t}\n\n}", "func (s *BoltCache) Add(key []byte, value models.Company) error {\n\ts.Lock.Lock()\n\tdefer s.Lock.Unlock()\n\treturn nil\n}", "func (c *idempotentTimeCache) Add(s string) {\n\tc.mut.Lock()\n\tdefer c.mut.Unlock()\n\tif !c.cache.Has(s) {\n\t\tc.cache.Add(s)\n\t}\n}", "func (c *Cache) Add(key string, value []byte) bool {\n\tkh := c.hash64([]byte(key))\n\n\tc.mutex.Lock()\n\t_, addFail := c.chunkMap[kh]\n\n\tif addFail == false {\n\t\t// cache miss: we can write to the index of nextChunk\n\t\tchunk := c.nextChunk\n\t\t// this index will be changed -> update in-memory struct\n\t\toldMeta := c.metaMap[chunk]\n\t\tnewMeta := MetaEntry{Key: kh, Len: uint32(len(value)), Checksum: c.hash32(value)}\n\n\t\tc.replaceMeta(oldMeta.Key, newMeta, false)\n\n\t\tc.seekToData(chunk)\n\t\tbinary.Write(c.fh, binary.LittleEndian, value)\n\n\t\tc.nextChunk++\n\t\tif c.nextChunk >= c.chunkCount {\n\t\t\tc.nextChunk = 0 // overflowed -> next chunk shall be 0\n\t\t}\n\t}\n\tc.mutex.Unlock()\n\treturn !addFail\n}", "func (l *LRU) Add(k, v interface{}) {\n\tl.lazyInit()\n\tl.shard(k).add(k, v)\n}", "func (c *Cache) Add(key Key, value interface{}, size int64) bool {\n\tif c.cache == nil {\n\t\tc.cache = make(map[interface{}]*list.Element)\n\t\tc.ll = list.New()\n\t}\n\n\tif ee, ok := c.cache[key]; ok {\n\t\tc.ll.MoveToFront(ee)\n\t\tee.Value.(*entry).value = value\n\t\treturn true\n\t}\n\n\tif size < 0 {\n\t\treturn false\n\t}\n\n\t// Entry by itself is over the max capacity\n\tif c.MaxSize > 0 && size > c.MaxSize {\n\t\treturn false\n\t}\n\n\t// Adding the entry would lead to integer overflow\n\tif c.MaxSize > 0 && math.MaxInt64-c.Size < size {\n\t\treturn false\n\t}\n\n\t// Add item to cache\n\tele := c.ll.PushFront(&entry{key, value, size})\n\tc.Size += size\n\tc.cache[key] = ele\n\n\tif c.MaxSize <= 0 {\n\t\treturn true\n\t}\n\n\t//remove old entries\n\tfor c.Size > c.MaxSize {\n\t\tc.RemoveOldest()\n\t}\n\treturn true\n}", "func (d Data) Add(key uint32, value interface{}) {\n\td.mutex.Lock()\n\tdefer d.mutex.Unlock()\n\td.data[key] = value\n\td.counts[key] = d.counts[key] + 1\n}", "func (c *Cache) Add(key string, item IWorker) {\n\tc.Lock()\n\tdefer c.Unlock()\n\tc.Items[key] = item\n}", "func (_m *Cache) Add(ctx context.Context, hash string, query string) {\n\t_m.Called(ctx, hash, query)\n}", "func (c *cache) cacheAdd(index []string, frac float64,\n\tfixcost Cost, varcost Cost, approach any) {\n\tassert.Msg(\"cache fixcost < 0\").That(fixcost >= 0)\n\tassert.Msg(\"cache varcost < 0\").That(varcost >= 0)\n\tc.entries = append(c.entries,\n\t\tcacheEntry{index: index, frac: float32(frac),\n\t\t\tfixcost: fixcost, varcost: varcost, approach: approach})\n}", "func (s SecretWatchableSet) CacheAdd(cache *Cache, item WatchableResource) {\n\tsecret := item.(*Secret)\n\tcache.Secrets[item.ID()] = secret\n}", "func (m *CacheStore) Add(node forest.Node) error {\n\tif err := m.Back.Add(node); err != nil {\n\t\treturn err\n\t}\n\tif err := m.Cache.Add(node); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s *Store) Add(key []byte, value []byte) error {\n\tif s.HasKey(key) {\n\t\treturn fmt.Errorf(\"key already exists\")\n\t}\n\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\n\ts.addRec(key, value)\n\n\ts.count++\n\ts.rCount++\n\ts.txCount++\n\n\treturn s.updateHeader()\n}", "func (mc *MemCache) Add(id *xi.NodeID, b []byte) (err error) {\n\n\tkey := id.Value()\n\n\t// XXX POSSIBLE DEADLOCK\n\tmc.mu.Lock()\n\tdefer mc.mu.Unlock()\n\n\tvalue, err := mc.idMap.Find(key)\n\tif err == nil {\n\t\tif value == nil {\n\t\t\tmc.idMap.Insert(key, b)\n\t\t\tmc.itemCount++\n\t\t\tmc.byteCount += uint64(len(b))\n\t\t}\n\t}\n\treturn\n}", "func (ds *DataStore) Add(key uint64, value []byte) error {\n\tds.dataStoreLock.Lock()\n\tdefer ds.dataStoreLock.Unlock()\n\tif _, present := ds.kvSet[key]; present {\n\t\tds.kvTime[key] = time.Now().UnixNano()\n\t\treturn fmt.Errorf(\"Key %d already exists\", key)\n\t}\n\tds.kvSet[key] = value\n\treturn nil\n}", "func (r *RecordCache) Add(response Response) {\n\tr.Lock()\n\tdefer r.Unlock()\n\tr.cache[response.FormatKey()] = response\n\tCacheSizeGauge.Set(float64(len(r.cache)))\n}", "func (cs cacheSize) add(bytes, entries int32) cacheSize {\n\treturn newCacheSize(cs.bytes()+bytes, cs.entries()+entries)\n}", "func (s *Store) Add(ctx context.Context, key interface{}, v json.Marshaler) error {\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tdefault:\n\t}\n\n\tb, err := v.MarshalJSON()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tdefault:\n\t}\n\n\tif _, ok := s.m[key]; ok {\n\t\treturn store.ErrKeyExists\n\t}\n\n\ts.m[key] = entry{data: b}\n\treturn nil\n}", "func (c *Counter) Add(key string, value int64) int64 {\n\tcount, loaded := c.m.LoadOrStore(key, &value)\n\tif loaded {\n\t\treturn atomic.AddInt64(count.(*int64), value)\n\t}\n\treturn *count.(*int64)\n}", "func (s *CacheServer) Add(ctx context.Context, in *pb.CacheRequest) (*pb.CacheResponse, error) {\n\tin.Operation = pb.CacheRequest_ADD\n\treturn s.Call(ctx, in)\n}", "func (storage *Storage) add(key string, value interface{}, timeNow int64) (err error) {\n\t// Check the last element of lruList expired; if so, reused it\n\tif e := storage.lruList.Back(); e != nil {\n\t\tif payload := e.Value.(*payload); timeNow > payload.Expiration {\n\t\t\tdelete(storage.cache, payload.Key)\n\n\t\t\tpayload.Key = key\n\t\t\tpayload.Value = value\n\t\t\tpayload.Expiration = timeNow + storage.maxAge\n\n\t\t\tstorage.cache[key] = e\n\t\t\tstorage.lruList.MoveToFront(e)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Check whether storage.lruList.Len() has reached the maximum of int.\n\tif storage.lruList.Len()<<1 == -2 {\n\t\treturn ErrNotStored\n\t}\n\n\t// now create new\n\tstorage.cache[key] = storage.lruList.PushFront(&payload{\n\t\tKey: key,\n\t\tValue: value,\n\t\tExpiration: timeNow + storage.maxAge,\n\t})\n\treturn\n}", "func (tc *sklImpl) Add(start, end roachpb.Key, ts hlc.Timestamp, txnID uuid.UUID) {\n\tstart, end = tc.boundKeyLengths(start, end)\n\n\tval := cacheValue{ts: ts, txnID: txnID}\n\tif len(end) == 0 {\n\t\ttc.cache.Add(nonNil(start), val)\n\t} else {\n\t\ttc.cache.AddRange(nonNil(start), end, excludeTo, val)\n\t}\n}", "func (m *redisDB) Add(key string, val []byte, expiration time.Duration) (err error) {\n\n\t//NX -- Only set the key if it does not already exist.\n\t_, err = m.client.SetNX(m.ctx, key, string(val), expiration).Result()\n\n\treturn\n}", "func (d *dao) AddCacheToken(c context.Context, id int64, val *vrfapi.Token) (err error) {\n\tif val == nil {\n\t\treturn\n\t}\n\tkey := keyArt(id)\n\titem := &memcache.Item{Key: key, Object: val, Expiration: d.demoExpire, Flags: memcache.FlagJSON}\n\tif err = d.mc.Set(c, item); err != nil {\n\t\tlog.Errorv(c, log.KV(\"AddCacheToken\", fmt.Sprintf(\"%+v\", err)), log.KV(\"key\", key))\n\t\treturn\n\t}\n\treturn\n}", "func AddCache(newData Data) {\n\tstore.mu.RLock()\n\tdefer store.mu.RUnlock()\n\n\tif CACHE_LIMIT <= len(store.items) {\n\t\tfor key, item := range store.items {\n\t\t\tif 0 < item.Counter {\n\t\t\t\tGetData(item.Content.ShortURL, item.Counter)\n\t\t\t}\n\t\t\tdelete(store.items, key)\n\t\t\tlog.Printf(\"-- CACHE DELETED %s\", key)\n\t\t}\n\t} else {\n\t\tfor key, item := range store.items {\n\t\t\tisHasViewToSave := 0 < item.Counter\n\t\t\texpired := item.isExpired()\n\n\t\t\tif expired && isHasViewToSave {\n\t\t\t\tGetData(item.Content.ShortURL, item.Counter)\n\t\t\t}\n\t\t\tif expired {\n\t\t\t\tlog.Printf(\"-- CACHE EXPIRED %s with %vviews\",\n\t\t\t\t\titem.Content.ShortURL,\n\t\t\t\t\titem.Counter)\n\t\t\t\tdelete(store.items, key)\n\t\t\t}\n\t\t}\n\t}\n\n\tstore.items[newData.ShortURL] = Item{\n\t\tContent: newData,\n\t\tCounter: 0,\n\t\tExpiration: time.Now().Add(CACHE_DURATION_S).UnixNano(),\n\t}\n\tlog.Printf(\"-- CACHE SET %s\\n\", newData.ShortURL)\n}", "func (q Query) Add(key string, value interface{}) Query {\n\tq[key] = value\n\treturn q\n}", "func (file *File) Add(name, value, author string, time time.Time) {\n\talias := &Alias{}\n\talias.Name = name\n\talias.Value = value\n\talias.Author = author\n\talias.CreationTime = time\n\tfile.cache[alias.Name] = alias\n}", "func (a v3ioAppender) Add(lset utils.Labels, t int64, v float64) (uint64, error) {\n\treturn a.metricsCache.Add(lset, t, v)\n}", "func (t *Tree) add(key []byte, value []byte) ([]byte, error) {\n\terr := t.leaves.Add(key, value)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn t.toCache(key, value, rootPosition(t.digestLength)), nil\n}", "func (client *Client) Add(vb uint16, key string, flags int, exp int,\n\tbody []byte) (*gomemcached.MCResponse, error) {\n\treturn client.store(gomemcached.ADD, vb, key, flags, exp, body)\n}", "func (c *TwoQueueCache[K, V]) Add(key K, value V) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\n\t// Check if the value is frequently used already,\n\t// and just update the value\n\tif c.frequent.Contains(key) {\n\t\tc.frequent.Add(key, value)\n\t\treturn\n\t}\n\n\t// Check if the value is recently used, and promote\n\t// the value into the frequent list\n\tif c.recent.Contains(key) {\n\t\tc.recent.Remove(key)\n\t\tc.frequent.Add(key, value)\n\t\treturn\n\t}\n\n\t// If the value was recently evicted, add it to the\n\t// frequently used list\n\tif c.recentEvict.Contains(key) {\n\t\tc.ensureSpace(true)\n\t\tc.recentEvict.Remove(key)\n\t\tc.frequent.Add(key, value)\n\t\treturn\n\t}\n\n\t// Add to the recently seen list\n\tc.ensureSpace(false)\n\tc.recent.Add(key, value)\n}", "func (c *DiskCache) Add(key string, val *cacheobj.CacheObj) bool {\n\tlog.Debugf(\"DiskCache Add CALLED key '%+v' size '%+v'\\n\", key, val.Size)\n\teviction := false\n\n\tbuf := bytes.Buffer{}\n\tif err := gob.NewEncoder(&buf).Encode(val); err != nil {\n\t\tlog.Errorln(\"DiskCache.Add encoding cache object: \" + err.Error())\n\t\treturn eviction\n\t}\n\tvalBytes := buf.Bytes()\n\n\terr := c.db.Update(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket([]byte(BucketName))\n\t\tif b == nil {\n\t\t\treturn errors.New(\"bucket does not exist\")\n\t\t}\n\t\treturn b.Put([]byte(key), valBytes)\n\t})\n\tif err != nil {\n\t\tlog.Errorln(\"DiskCache.Add inserting '\" + key + \"' in database: \" + err.Error())\n\t\treturn eviction\n\t}\n\n\tc.lru.Add(key, uint64(len(valBytes)))\n\n\tnewSizeBytes := atomic.AddUint64(&c.sizeBytes, uint64(len(valBytes)))\n\tif newSizeBytes > c.maxSizeBytes {\n\t\tgo c.gc(newSizeBytes)\n\t}\n\n\tlog.Debugf(\"DiskCache Add SUCCESS key '%+v' size '%+v' valBytes '%+v' c.sizeBytes '%+v'\\n\", key, val.Size, len(valBytes), c.sizeBytes)\n\treturn eviction\n}", "func (c *Cache) Add(p common.MetricPoint) {\n\tc.logger.DebugFilter( fiterCpuTotal(p.Key), \"Cache add \", p)\n\t//if c.SizeLimit > 0 && c.Size() > c.SizeLimit {\n\t//\tc.stat.CounterInc(\"overflow-count\", 1)\n\t//\tc.logger.DebugFilter( fiterCpuTotal(p.Key), \"Cache add overflow\", p)\n\t//\treturn\n\t//}\n\t// Get map shard.\n\tshard := c.GetShard(p.Key)\n\n\tshard.Lock()\n\tif _, exists := shard.items[p.Key]; !exists {\n\t\tshard.items[p.Key] = &CachePointBag{\n\t\t\tPointBag: *common.NewPointsBag(p.Key),\n\t\t\tPointsToDb: make([]common.Point, 0),\n\t\t\tduration: 3600,\n\t\t}\n\t}\n\texpiredNum := shard.items[p.Key].Add(common.Point{p.Value, p.Timestamp})\n\tshard.Unlock()\n\t\n\tif expiredNum > 0 {\n\t\tatomic.AddInt64(&c.size, 0-int64(expiredNum))\n\t}\n\t\n\tatomic.AddInt64(&c.size, 1)\n\tc.stat.GaugeUpdate(\"point-count\", atomic.LoadInt64(&c.size))\n}", "func (be InmemBackend) Add(key []byte, value []byte) error {\n\treturn be.Put(key, value, false, false)\n}", "func (c *CountResult) Add(k string, v int) {\n\tif c.m == nil {\n\t\tc.m = make(map[string]int)\n\t}\n\tc.m[k] = v\n}", "func (client *MemcachedClient4T) Add(e *common.Element) error {\n\treturn client.store(\"add\", e)\n}", "func (set *SetString) Add(string string) {\n\tset.lock.Lock()\n\tset.cache[string] = true\n\tset.lock.Unlock()\n}", "func (client *Client) Add(vb uint16, key string, flags int, exp int,\n\tbody []byte) (gomemcached.MCResponse, error) {\n\treturn client.store(gomemcached.ADD, vb, key, flags, exp, body)\n}", "func (c *randomEvictedCache) Add(key Measurable, data Measurable) {\n\tmemoizedKey := memoizedMeasurable{m: key}\n\tmemoizedData := memoizedMeasurable{m: data}\n\tincrease := c.entrySize(memoizedKey, memoizedData)\n\tif increase > c.maxBytes {\n\t\treturn\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif v, ok := c.data[key]; ok {\n\t\tdecrease := c.entrySize(memoizedKey, v)\n\t\tc.cachedBytes -= decrease\n\t}\n\tc.cachedBytes += increase\n\tfor c.cachedBytes > c.maxBytes {\n\t\tc.evictOneLocked()\n\t}\n\tc.data[key] = memoizedData\n\tc.keys = append(c.keys, memoizedKey)\n}", "func (c Context) Add(key string, value interface{}) {\n\tc.data[key] = value\n}", "func (c *lruEvictedCache) Add(key Measurable, data Measurable) {\n\tmemoized := memoizedMeasurable{m: data}\n\tkeySize := key.Size()\n\tif keySize+memoized.Size() > c.maxBytes {\n\t\treturn\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif v, ok := c.data.Get(lru.Key(key)); ok {\n\t\tif m, ok := v.(memoizedMeasurable); ok {\n\t\t\tc.cachedBytes -= keySize + m.Size()\n\t\t}\n\t}\n\tc.cachedBytes += keySize + memoized.Size()\n\tfor c.cachedBytes > c.maxBytes {\n\t\tc.data.RemoveOldest()\n\t}\n\tc.data.Add(lru.Key(key), memoized)\n}", "func (c *C) Add(session *Session, d *CachedData) {\n\tif session.highMissRatio() {\n\t\t// If the recent miss ratio in this session is high, we want to avoid the\n\t\t// overhead of moving things in and out of the cache. But we do want the\n\t\t// cache to \"recover\" if the workload becomes cacheable again. So we still\n\t\t// add the entry, but only once in a while.\n\t\tif session.r == nil {\n\t\t\tsession.r = rand.New(rand.NewSource(1 /* seed */))\n\t\t}\n\t\tif session.r.Intn(100) != 0 {\n\t\t\treturn\n\t\t}\n\t}\n\tmem := d.memoryEstimate()\n\tif d.SQL == \"\" || mem > maxCachedSize || mem > c.totalMem {\n\t\treturn\n\t}\n\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\te, ok := c.mu.m[d.SQL]\n\tif ok {\n\t\t// The query already exists in the cache.\n\t\te.remove()\n\t\tc.mu.availableMem += e.memoryEstimate()\n\t} else {\n\t\t// Get an entry to use for this query.\n\t\te = c.getEntry()\n\t\tc.mu.m[d.SQL] = e\n\t}\n\n\te.CachedData = *d\n\n\t// Evict more entries if necessary.\n\tc.makeSpace(mem)\n\tc.mu.availableMem -= mem\n\n\t// Insert the entry at the front of the used list.\n\te.insertAfter(&c.mu.used)\n}", "func (dc *DigestCache) Add(hash []byte, text []byte) {\n\tdc.Records[string(hash)] = text\n}", "func (c *Config) Add(key string, value interface{}) {\n\tc.Lock()\n\tdefer c.Unlock()\n\tc.m[key] = value\n}", "func (k Keeper) Add(ctx sdk.Context, address sdk.AccAddress, amount sdk.Int) (sdk.Int, error) {\n\tvalue, err := k.Get(ctx, address)\n\tif err != nil {\n\t\treturn sdk.Int{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, err.Error())\n\t}\n\tres := value.Add(amount)\n\t// emit event\n\tctx.EventManager().EmitEvent(\n\t\tsdk.NewEvent(\n\t\t\ttypes.EventType,\n\t\t\tsdk.NewAttribute(sdk.AttributeKeyAction, types.AttributeActionAdded),\n\t\t\tsdk.NewAttribute(types.AttributeKeyAddress, address.String()),\n\t\t\tsdk.NewAttribute(types.AttributeKeyAmount, amount.String()),\n\t\t),\n\t)\n\treturn k.set(ctx, address, res)\n}", "func (c *EntryCache) add(e *Entry) error {\n\thashes, err := allHashes(e, c.hashes)\n\tif err != nil {\n\t\treturn err\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif _, present := c.entries[e.name]; present {\n\t\t// log or fail...?\n\t\tc.log.Warning(\"[cache] Overwriting cache entry '%s'\", e.name)\n\t} else {\n\t\tc.log.Info(\"[cache] Adding entry for '%s'\", e.name)\n\t}\n\tc.entries[e.name] = e\n\tfor _, h := range hashes {\n\t\tc.lookupMap[h] = e\n\t}\n\treturn nil\n}", "func (mc *MemoryStorage) Add(key string, data interface{}) {\n\tmc.Lock()\n\tif _, found := mc.bucket[key]; found {\n\t\tdelete(mc.bucket, key)\n\t}\n\tmc.bucket[key] = entity{object: data}\n\tmc.Unlock()\n}", "func (set *SetUI) Add(uint uint) {\n\tset.lock.Lock()\n\tset.cache[uint] = true\n\tset.lock.Unlock()\n}", "func (sl *Skiplist) Add(num int) {\n\tsl.cache[num]++\n}", "func (lru *KeyLRU) Add(key interface{}) error {\n\tlru.lazyInit()\n\tele := lru.ll.PushFront(key)\n\tif _, ok := lru.m[key]; ok {\n\t\treturn errors.New(\"key was already in LRU\")\n\t}\n\tlru.m[key] = ele\n\treturn nil\n}", "func (c *metricCache) Add(metric lp.CCMetric) {\n\tif c.curPeriod >= 0 && c.curPeriod < c.numPeriods {\n\t\tc.lock.Lock()\n\t\tp := c.intervals[c.curPeriod]\n\t\tif p.numMetrics < p.sizeMetrics {\n\t\t\tp.metrics[p.numMetrics] = metric\n\t\t\tp.numMetrics = p.numMetrics + 1\n\t\t\tp.stopstamp = metric.Time()\n\t\t} else {\n\t\t\tp.metrics = append(p.metrics, metric)\n\t\t\tp.numMetrics = p.numMetrics + 1\n\t\t\tp.sizeMetrics = p.sizeMetrics + 1\n\t\t\tp.stopstamp = metric.Time()\n\t\t}\n\t\tc.lock.Unlock()\n\t}\n}", "func (c *Cache) add(value interface{}) bool {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\n\tc.evictList.PushFront(value)\n\tevict := c.evictList.Len() > c.size\n\t// Verify size not exceeded\n\tif evict {\n\t\tevicted := c.removeOldest()\n\t\tif evicted != nil && c.onEvicted != nil {\n\t\t\tc.onEvicted(evicted.Value)\n\t\t}\n\t}\n\treturn evict\n}", "func (s *Set) Add(val interface{}) {\n\ts.set[val] = true\n}", "func (ttlmap *TTLMap) Add(key, value interface{}) {\n\tttlmap.AddWithTTL(key, value, ttlmap.defaultTTL)\n}", "func (t *TrieNode) Add(key string, value int64) {\n\tt.mx.Lock()\n\tdefer t.mx.Unlock()\n\trunes := []rune(key)\n\tt.add(runes, value)\n}", "func (c *Container) Add(value interface{}) {\n\tc.AddValue(ValueOf(value))\n}", "func (t *LRUCache) Put(key int, value int) {\n\n}", "func (m *ttlMap) Add(key interface{}, value interface{}) {\n\tm.AddWithTTL(key, value, m.defaultTTL)\n}", "func (h *Heap) Add(obj interface{}) error {\n\tkey, err := h.data.keyFunc(obj)\n\tif err != nil {\n\t\treturn cache.KeyError{Obj: obj, Err: err}\n\t}\n\tif _, exists := h.data.items[key]; exists {\n\t\th.data.items[key].obj = obj\n\t\theap.Fix(h.data, h.data.items[key].index)\n\t} else {\n\t\theap.Push(h.data, &itemKeyValue{key, obj})\n\t\tif h.metricRecorder != nil {\n\t\t\th.metricRecorder.Inc()\n\t\t}\n\t}\n\treturn nil\n}", "func (date Nakamura) Add(value int, format string) Nakamura {\n\treturn Add(date, value, format)\n}", "func (mmap *stateSyncMap) add(key string, value interface{}) error {\n\treturn mmap.Add(key, value)\n}", "func (self *Store) Add(k string) []byte {\n\tself.mu.Lock()\n\tself.mu.Unlock()\n\treturn nil\n}", "func (c cache) Put(flightNumber string, data flightdata.LiveData) {\n\tc[flightNumber] = data\n}", "func (cache *FileCache) Add(key string, length int64, r io.Reader) error {\n\tdata := make([]byte, length)\n\t_, err := io.ReadFull(r, data)\n\tif err != nil && (err == io.EOF || err == io.ErrUnexpectedEOF) {\n\t\treturn io.ErrUnexpectedEOF\n\t}\n\n\tpath := filepath.Join(cache.dir, key)\n\tif _, err := os.Stat(path); err == nil {\n\t\treturn nil\n\t}\n\n\tfile, err := os.Create(path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\n\tif _, err := file.Write(data); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (s Set) Add(value interface{}) {\n\thash, err := hashstructure.Hash(value, nil)\n\tif err != nil {\n\t\tlog.Errorf(\"type could not be hashed: %+v\", value)\n\t}\n\ts[hash] = value\n}", "func (lru *LruCache) Set(key string, value interface{}) {\n\titem := &lruItem{\n\t\tkey: key,\n\t\tval: value,\n\t\texpiredTimestamp: magicNumber,\n\t}\n\t//lru.lock.Lock()\n\telement := lru.list.PushFront(item)\n\t//lru.lock.Unlock()\n\tlru.cache.Set(key, element)\n}", "func (this *List) Add(c Counter) error {\n this.lock.Lock()\n defer this.lock.Unlock()\n\n _, ok := this.counters[c.Name()]\n if ok {\n return fmt.Errorf(\"Counter already exists\")\n }\n\n this.counters[c.Name()] = c\n\n return nil\n}", "func (c *cache) Store(key string, value interface{}) {\n\tstart := time.Now()\n\n\tc.store(key, value)\n\n\tc.logger.Debug(\"store value in cache\",\n\t\tzap.String(\"key\", key),\n\t\tzap.Reflect(\"value\", value),\n\t\tzap.Duration(\"duration\", time.Since(start)),\n\t)\n}", "func Add(h string, service string, blocks []detect.TextBlock) {\n\tlog.Debugf(\"Adding new image to cache. sha256:%v\", h)\n\tcacheData := read()\n\n\tcachePath, err := filepath.Abs(filepath.Dir(os.Args[0]))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tcachePath = filepath.Join(cachePath, \"mtl-cache.bin\")\n\tcacheFile, err := os.OpenFile(cachePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer cacheFile.Close()\n\n\tnewData := Data{\n\t\tHash: h,\n\t\tService: service,\n\t\tBlocks: blocks,\n\t}\n\tcacheData = append(cacheData, newData)\n\tenc := gob.NewEncoder(cacheFile)\n\tif err := enc.Encode(cacheData); err != nil {\n\t\tlog.Fatalf(\"Cache write failed: %v\", err)\n\t}\n}", "func TestLRUAdd(t *testing.T) {\n\tc := NewLRUCache(10)\n\n\tkey, value := \"key1\", \"abcd\"\n\tv, _, added := c.Add(key, value)\n\tif !added {\n\t\tt.Fatalf(\"failed to add %q\", key)\n\t} else if v.(string) != value {\n\t\tt.Fatalf(\"returned different object for %q; want %q; got %q\", key, value, v.(string))\n\t}\n\n\tkey, newvalue := \"key1\", \"dummy\"\n\tv, _, added = c.Add(key, newvalue)\n\tif added || v.(string) != value {\n\t\tt.Fatalf(\"%q must be originally stored one; want %q; got %q (added:%v)\",\n\t\t\tkey, value, v.(string), added)\n\t}\n}", "func (hpc *HashPeersCache) Add(hash types.Hash32, peer p2p.Peer) {\n\thpc.mu.Lock()\n\tdefer hpc.mu.Unlock()\n\n\thpc.add(hash, peer)\n}", "func (m *Uint64) Add(key interface{}, delta uint64) (new uint64) {\n\treturn m.Value(key).Add(delta)\n}", "func (s *Set) Add(val interface{}) {\n\ts.vals[val] = true\n}" ]
[ "0.81868863", "0.79647106", "0.79207206", "0.78305393", "0.78196764", "0.7802301", "0.77938324", "0.77886504", "0.77825737", "0.7774307", "0.7767963", "0.76871604", "0.768334", "0.7654828", "0.75728226", "0.7562211", "0.7535825", "0.75247765", "0.75128514", "0.7450597", "0.742726", "0.7403037", "0.73975706", "0.7253079", "0.72410065", "0.72387165", "0.72371924", "0.71661174", "0.7162951", "0.70463735", "0.70373374", "0.70312274", "0.70012814", "0.6936618", "0.692995", "0.69282234", "0.6913343", "0.69125926", "0.68975514", "0.6852852", "0.68459994", "0.6820322", "0.6816288", "0.6807934", "0.6806903", "0.6761928", "0.6757777", "0.67303276", "0.6724536", "0.66834074", "0.66777205", "0.66703576", "0.6667155", "0.66612995", "0.6659716", "0.66142863", "0.66043204", "0.65935194", "0.6592146", "0.6579295", "0.65777457", "0.6560835", "0.6560756", "0.6557934", "0.65468", "0.65467125", "0.651923", "0.6513804", "0.65075994", "0.6492218", "0.6488856", "0.64829373", "0.6440181", "0.64380544", "0.6436335", "0.6429096", "0.64179903", "0.6408094", "0.6404156", "0.64037097", "0.6398154", "0.6396756", "0.63730836", "0.63725996", "0.6342982", "0.63386786", "0.6338645", "0.6329994", "0.63298213", "0.63257957", "0.63058937", "0.6295443", "0.62836605", "0.62660784", "0.6239033", "0.62390184", "0.62337345", "0.6228971", "0.62192863", "0.6218048" ]
0.7510035
19
removeElement is used to remove a given list element from the cache
func (c *TimeoutCache) removeElement(e *list.Element) { c.evictList.Remove(e) kv := e.Value.(*entry) delete(c.items, kv.key) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Cache) removeElement(e *list.Element) {\n\tc.evictList.Remove(e)\n}", "func (c *LruCache) removeElement(e *list.Element) {\n\tc.evictList.Remove(e)\n\tkv := e.Value.(*entry)\n\tdelete(c.cache, kv.key)\n\tif c.onEvict != nil {\n\t\tc.onEvict(kv.key, kv.value)\n\t}\n}", "func (c *Cache) removeElement(e *list.Element) {\n\tc.evictList.Remove(e)\n\tkv := e.Value.(*Entry)\n\tdelete(c.mapping, kv.key)\n\tif c.onEvict != nil {\n\t\tc.onEvict(kv.key, kv.value)\n\t}\n}", "func (fs *memoryCacheFilesystem) removeElement(ent *list.Element) {\n\tfs.evictList.Remove(ent)\n\tcent := ent.Value.(*centry)\n\tfs.size -= cent.file.fi.Size()\n\tdelete(fs.cache, cent.name)\n\tfs.invalidator.Del(cent)\n}", "func (c *LRU) removeElement(e *list.Element) {\n\tc.Lock()\n\tdefer c.Unlock()\n\tc.removeElementNoLock(e)\n}", "func (storage *Storage) remove(e *list.Element) {\n\tdelete(storage.cache, e.Value.(*payload).Key)\n\tstorage.lruList.Remove(e)\n}", "func (c *LRU) remove(ele *list.Element) (key, value interface{}) {\n\tc.ll.Remove(ele)\n\tent := ele.Value.(*entry)\n\tdelete(c.cache, ent.key)\n\treturn ent.key, ent.value\n}", "func (list *List) Remove(element interface{}) error {\n\tidx := list.Index(element)\n\tif idx == -1 {\n\t\treturn fmt.Errorf(\"element not found\")\n\t}\n\treturn list.removeByIndex(idx)\n}", "func deleteElementFromLRU(elemento *list.Element) {\n\n\t//Decrement the byte counter, decrease the Key * 2 + Value\n\tn := (*elemento).Value.(*node)\n\n\tb, _ := json.Marshal(n.V)\n\tfmt.Println(\"b: \", string(b))\n\tfmt.Println(\"Resta: \", int64(len(b)))\n\n\tatomic.AddInt64(&memBytes, -int64(len(b)))\n\n\t//Delete the element in the LRU List\n\tlruList.Remove(elemento)\n\n\tfmt.Println(\"Dec Bytes: \", len(b))\n\n}", "func DeleteElement(l *list.List, mark *list.Element) *list.List {\r\n\tmark.Value = mark.Next.Value\r\n\tmark.Next = mark.Next.Next\r\n\tl.N--\r\n\treturn l\r\n}", "func (l *idList) remove(e *idElement) *idElement {\n\te.prev.next = e.next\n\te.next.prev = e.prev\n\te.next = nil // avoid memory leaks\n\te.prev = nil // avoid memory leaks\n\te.list = nil\n\tl.len--\n\treturn e\n}", "func (vector *Vector) RemoveElement(element interface{}) {\n\tindex := vector.Peek(element)\n\tif index >= 0 {\n\t\t// Only try to remove the element if it exists in the Vector.\n\t\tvector.Delete(index)\n\t}\n}", "func deleteElement(col string, clave string) bool {\n\n\t//Get the element collection\n\tcc := collections[col]\n\n\t//Get the element from the map\n\telemento := cc.Mapa[clave]\n\n\t//checks if the element exists in the cache\n\tif elemento != nil {\n\n\t\t//if it is marked as deleted, return a not-found directly without checking the disk\n\t\tif elemento.Value.(*node).Deleted == true {\n\t\t\tfmt.Println(\"Not-Found cached detected on deleting, ID: \", clave)\n\t\t\treturn false\n\t\t}\n\n\t\t//the node was not previously deleted....so exists in the disk\n\n\t\t//if not-found cache is enabled, mark the element as deleted\n\t\tif cacheNotFound == true {\n\n\t\t\t//created a new node and asign it to the element\n\t\t\telemento.Value = &node{nil, false, true}\n\t\t\tfmt.Println(\"Caching Not-found for, ID: \", clave)\n\n\t\t} else {\n\t\t\t//if it is not enabled, delete the element from the memory\n\t\t\tcc.Canal <- 1\n\t\t\tdelete(cc.Mapa, clave)\n\t\t\t<-cc.Canal\n\t\t}\n\n\t\t//In both cases, remove the element from the list and from disk in a separated gorutine\n\t\tgo func() {\n\n\t\t\tlisChan <- 1\n\t\t\tdeleteElementFromLRU(elemento)\n\t\t\t<-lisChan\n\n\t\t\tdeleteJSONFromDisk(col, clave)\n\n\t\t\t//Print message\n\t\t\tif enablePrint {\n\t\t\t\tfmt.Println(\"Delete successfull, ID: \", clave)\n\t\t\t}\n\t\t}()\n\n\t} else {\n\n\t\tfmt.Println(\"Delete element not in memory, ID: \", clave)\n\n\t\t//Create a new element with the key in the cache, to save a not-found if it is enable\n\t\tcreateElement(col, clave, \"\", false, true)\n\n\t\t//Check is the element exist in the disk\n\t\terr := deleteJSONFromDisk(col, clave)\n\n\t\t//if exists, direcly remove it and return true\n\t\t//if it not exist return false (because it was not found)\n\t\tif err == nil {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\n\t}\n\n\treturn true\n\n}", "func RemoveElementFromList(list []string, element string) []string {\n\tout := []string{}\n\tfor _, item := range list {\n\t\tif item != element {\n\t\t\tout = append(out, item)\n\t\t}\n\t}\n\treturn out\n}", "func RemoveElementFromList(list []string, element string) []string {\n\tout := []string{}\n\tfor _, item := range list {\n\t\tif item != element {\n\t\t\tout = append(out, item)\n\t\t}\n\t}\n\treturn out\n}", "func (s *slot) remove(c interface{}) {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\tdelete(s.elements, c)\n}", "func (list *SkipList) Remove(key uint64) (el *Element) {\n\tlist.mutex.Lock()\n\tdefer list.mutex.Unlock()\n\n\tpath := list.searchPath(key)\n\n\tif el = path[0].next[0]; el != nil && el.key == key {\n\t\tfor level, element := range el.next {\n\t\t\tpath[level].next[level] = element\n\t\t}\n\t\tlist.length--\n\t\treturn el\n\t}\n\treturn\n}", "func (lru *LruCache) Delete(key string) error {\n\tlru.cache.Delete(key)\n\n\tval, err := lru.cache.Get(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\telement := val.(*list.Element)\n\tlru.list.Remove(element)\n\n\treturn nil\n}", "func (l *idList) Remove(e *idElement) doc.Metadata {\n\t// read the value before returning to the pool to avoid a data race with another goroutine getting access to the\n\t// list after it has been put back into the pool.\n\tv := e.Value\n\tif e.list == l {\n\t\t// if e.list == l, l must have been initialized when e was inserted\n\t\t// in l or l == nil (e is a zero Element) and l.remove will crash.\n\t\tl.remove(e)\n\t\tl.Pool.put(e)\n\t}\n\treturn v\n}", "func (list *List) DeleteElement(data int) {\n // 1. Provide message to user if the list is empty and return\n if list.Size() == 0 {\n fmt.Println(\"Nothing to delete, the list is empty\")\n return\n }\n\n // 2. Get the current head of the list\n current := list.Head()\n\n // 3. Update the head if current head is the requested element and return\n if current.data == data {\n list.head = current.next\n current.next = nil\n list.size--\n return\n }\n\n // 4. Traverse the list, remove the requested element and return\n for current.next != nil {\n if current.next.data == data {\n tmp := current.next.next\n current.next.next = nil\n current.next = tmp\n list.size--\n return\n }\n current = current.next\n }\n\n // 5. Provide a message to user if the requested element is not found in list\n fmt.Println(\"Could not delete since the element requested does not exist in list\")\n}", "func RemoveElement(s []string, element string) []string {\n\tlist := make([]string, 0)\n\tfor _, e := range s {\n\t\tif e != element {\n\t\t\tlist = append(list, e)\n\t\t}\n\t}\n\treturn list\n}", "func (q *Queue) Remove(element *list.Element) *Order {\n\tq.quantity -= element.Value.(*Order).quantity\n\treturn q.orders.Remove(element).(*Order) // todo: if found ??\n}", "func (rp *resourcePool) remove(e *resourcePoolElement) {\n\tif e == nil {\n\t\treturn\n\t}\n\n\tif e.prev != nil {\n\t\te.prev.next = e.next\n\t}\n\tif e.next != nil {\n\t\te.next.prev = e.prev\n\t}\n\tif e == rp.start {\n\t\trp.start = e.next\n\t}\n\tif e == rp.end {\n\t\trp.end = e.prev\n\t}\n\tatomicSubtract1Uint64(&rp.size)\n}", "func (list *ArrayList) Remove(index int) {\n\tif !list.boundCheck(index) {\n\t\treturn\n\t}\n\n\tlist.elements[index] = nil\n\tcopy(list.elements[index:], list.elements[index+1:list.size])\n\tlist.size -= 1\n\t//shirnk if necessary\n\tlist.shrink()\n}", "func Fremove(lista *[]string, elema string) {\n\tlistx := *lista\n\tlisty := []string{}\n\tfor _, i := range listx {\n\t\tif elema != i {\n\t\t\tlisty = append(listy, i)\n\t\t}\n\t}\n\t*lista = listy\n}", "func (c *Cache) evictFromCache(db *pebble.DB) error {\n\tc.lock.Lock()\n\tvaluesRemoved := 0\n\tvalsToRemove := [][]byte{}\n\telementsToRemove := []*list.Element{}\n\tfor e := c.evictList.Back(); e != nil; e = e.Prev() {\n\t\t// Item Value is stored as a listEl.\n\t\t//The val in there (an interface) is a byte array\n\t\tval := e.Value.(listEl).val.([]byte)\n\t\tvalsToRemove = append(valsToRemove, val)\n\t\telementsToRemove = append(elementsToRemove, e)\n\t\t// Alerts if a key is being deleted\n\t\tif bytes.Equal(val, []byte(\"a\")) {\n\t\t\tfmt.Println(\"Deleting A\")\n\t\t}\n\t\tdelete(c.listOfEvictList, string(val))\n\t\tvaluesRemoved += 1\n\t\tif valuesRemoved >= c.RemoveThisManyItemsFromTheCache {\n\t\t\tbreak\n\t\t}\n\t}\n\tfor _, val := range elementsToRemove {\n\t\tc.evictList.Remove(val)\n\t}\n\tc.lock.Unlock()\n\tfor _, val := range valsToRemove {\n\t\terr := db.Delete(val, pebble.Sync)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n\treturn nil\n}", "func (fc *fasterCache) removeTail() {\n\te := fc.evictList.Back()\n\tif e != nil {\n\t\tfc.removeElement(e)\n\t}\n}", "func (q *Queue) RemoveElement() interface{} {\n\te := q.root.next\n\te.next.prev = q.root\n\tq.root.next = e.next\n\te.queue = nil\n\tq.len--\n\n\treturn e.value\n}", "func removeElFromlist(p PointStruct, listp *[]PointStruct) {\n\n\tcopyInput := *listp\n\tfor idx, val := range copyInput{\n\n\t\tif val == p{\n\t\t\ttemp1:= copyInput[:idx]\n\t\t\ttemp2:= copyInput[idx:]\n\t\t\tif len(temp2) == 1{\n\t\t\t\t*listp = temp1\n\t\t\t\treturn\n\t\t\t}else{\n\t\t\t\ttemp2 = temp2[1:]\n\t\t\t\t*listp = append(temp1, temp2...)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n}", "func (c *Cache) removeOldest() *list.Element {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\tent := c.evictList.Back()\n\tif ent != nil {\n\t\tc.removeElement(ent)\n\t}\n\treturn ent\n}", "func (l *List) Remove(index int) error {\n\t// Does it make sense to make index as uint? On the other hand it's inconvenient to use uint everywhere\n\tif index < 0 || index > l.Len-1 {\n\t\treturn errors.New(\"index is put of range\")\n\t}\n\titem := l.First\n\tfor i := 0; i <= index; i++ {\n\t\tif i != index {\n\t\t\titem = item.Next\n\t\t\tcontinue\n\t\t}\n\t\tif i == 0 {\n\t\t\t// Set element as first and update the reference to the first element\n\t\t\tl.First = l.First.Next\n\t\t\t// check if element exists in case, when on previous step it was the last one\n\t\t\tif l.First != nil {\n\t\t\t\tl.First.Prev = nil\n\t\t\t}\n\t\t}\n\t\tif i == l.Len-1 {\n\t\t\t// Set element as last and update the reference to the last element\n\t\t\tl.Last = l.Last.Prev\n\t\t\t// check if element exists in case, when on previous step it was the first one\n\t\t\tif l.Last != nil {\n\t\t\t\tl.Last.Next = nil\n\t\t\t}\n\t\t}\n\t\tif i > 0 && i < l.Len-1 {\n\t\t\t// As far as I understood, item should be removed by GC from the memory, right?\n\t\t\titem.Prev = item.Next\n\t\t}\n\t\tl.Len--\n\t\treturn nil\n\t}\n\t// actually, impossible case\n\treturn errors.New(\"element with provided index was not found\")\n}", "func removeElement(nums []int, val int) int {\n\tnewtail := 0\n\tfor i := 0; i < len(nums); i++ {\n\t\tif nums[i] != val {\n\t\t\tnums[newtail] = nums[i]\n\t\t\tnewtail++\n\t\t}\n\t}\n\treturn newtail\n\n}", "func (s *StrSet) Remove(element string) {\n\tdelete(s.els, element)\n}", "func (c *LruCache) removeOldest() {\n\tent := c.evictList.Back()\n\tif ent != nil {\n\t\tc.removeElement(ent)\n\t}\n}", "func (c *Cache) removeOldest() {\n\tent := c.evictList.Back()\n\tif ent != nil {\n\t\tc.removeElement(ent)\n\t}\n}", "func (s *ConcurrentSlice) Remove(e int64) {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\ti := s.index(e)\n\ts.items = append(s.items[0:i], s.items[i+1:]...)\n}", "func (ht *ValueHashtable) Remove(k [HashSize]byte) {\r\n\tht.lock.Lock()\r\n\tdefer ht.lock.Unlock()\r\n\tdelete(ht.items, k)\r\n}", "func (c *Consistent) remove(elt string) {\n\tfor i := 0; i < c.NumberOfReplicas; i++ {\n\t\tdelete(c.circle, c.hashKey(c.eltKey(elt, i)))\n\t}\n\tdelete(c.members, elt)\n\tc.updateSortedHashes()\n\tc.count--\n}", "func (c *Consistent) Remove(elt string) {\n\tc.Lock()\n\tdefer c.Unlock()\n\tc.remove(elt)\n}", "func (c *Consistent) Remove(elt string) {\n\tc.Lock()\n\tdefer c.Unlock()\n\tc.remove(elt)\n}", "func removeElement(elementArray []int, val int) int {\n\tif len(elementArray) == 0 {\n\t\treturn 0\n\t}\n\tj := 0\n\tfor i := 0; i < len(elementArray); i++ {\n\t\tif elementArray[i] != val {\n\t\t\tif i != j {\n\t\t\t\telementArray[i], elementArray[j] = elementArray[j], elementArray[i]\n\t\t\t}\n\t\t\tj++\n\t\t}\n\t}\n\treturn j\n}", "func RemoveItemAt(list *List, index uint64) *uint64 {\n var returnPtr *uint64;\n var returnAddr uint64;\n var newReturnPtr uint64;\n var actualReturnPtr *uint64;\n var i uint64;\n returnPtr = GetItemAt(list, index); //Get the correspondig value value from the list\n newReturnPtr = Alloc(list.itemSize); //Allocate memory to store the item to be removed\n returnAddr = ToUint64FromUint64Ptr(returnPtr);\n CopyMem(returnAddr, newReturnPtr, list.itemSize); //Save item to be removed in order to return it\n for i = index; i < list.itemCount - 1; i = i + 1 { //Remove item by moving the following ones \"backwards\" in order to fill the gap caused by the deleted item\n CopyMem(list.baseAddress + (i + 1) * list.itemSize, list.baseAddress + list.itemSize * i, list.itemSize); //Move item at position i + 1 to position i\n }\n list.itemCount = list.itemCount - 1; //Update (decrease) item count\n actualReturnPtr = ToUint64PtrFromUint64(newReturnPtr);\n return actualReturnPtr; //Return value removed from list\n}", "func (tb *tableManager) remove(keyIn uint64) error {\n\tkey, ok := CleanKey(keyIn)\n\tif !ok {\n\t\tlog.Println(\"Key out of range.\")\n\t\treturn errors.New(\"Key out of range.\")\n\t}\n\tentry, ok := tb.data[key]\n\tif !ok {\n\t\tlog.Println(\"Key not found in table.\")\n\t\treturn errors.New(\"Key not found in table.\")\n\t}\n\n\ttb.removeFromLRUCache(entry)\n\tdelete(tb.data, key)\n\treturn nil\n}", "func (l *SkippedSequenceList) _remove(x uint64) error {\n\tif listElement, ok := l.skippedMap[x]; ok {\n\t\tl.skippedList.Remove(listElement)\n\t\tdelete(l.skippedMap, x)\n\t\treturn nil\n\t} else {\n\t\treturn errors.New(\"Value not found\")\n\t}\n}", "func (mu *MuHash) Remove(data []byte) {\n\tvar element num3072\n\tdataToElement(data, &element)\n\tmu.removeElement(&element)\n}", "func (c *Consistent) Remove(elt string) {\n\tc.Mu.Lock()\n\tdefer c.Mu.Unlock()\n\tc.remove(elt)\n}", "func (list *SkipList) Remove(key decimal.Decimal) *Element {\n\tlist.mutex.Lock()\n\tdefer list.mutex.Unlock()\n\tprevs := list.getPrevElementNodes(key)\n\n\t// found the element, remove it\n\tif element := prevs[0].next[0]; element != nil && list.cmp(element.key, key) {\n\t\tfor k, v := range element.next {\n\t\t\tprevs[k].next[k] = v\n\t\t}\n\n\t\tlist.Length--\n\t\treturn element\n\t}\n\n\treturn nil\n}", "func (c *Cache) removeOldest() {\r\n\tif c.cache == nil {\r\n\t\treturn\r\n\t}\r\n\tele := c.ll.Back()\r\n\tif ele != nil {\r\n\t\tc.removeElement(ele)\r\n\t}\r\n}", "func (l *LRUCache) evictItem(element *list.Element) {\n l.base.rwLock.Lock()\n defer l.base.rwLock.Unlock()\n\n itemKey := element.Value.(*cacheItem).Key\n\n delete(l.items, itemKey )\n l.evictionList.Remove(element)\n}", "func (this *List) Remove(counterName string) {\n this.lock.Lock()\n defer this.lock.Unlock()\n\n delete(this.counters, counterName)\n}", "func (s Set) Remove(element string) {\n\te := strings.ToLower(element)\n\n\tif _, ok := s[e]; ok {\n\t\tdelete(s, e)\n\t}\n}", "func (c *TimeoutCache) Remove(key interface{}) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\n\tif ele := c.searchElement(key); ele != nil {\n\t\tc.removeElement(ele)\n\t}\n}", "func (l *List) Remove(value interface{}) {\n\tl.Lock()\n\tfor n := l.head; n != nil; n = n.next {\n\t\tif n.value == value {\n\t\t\tn.prev.next = n.next\n\t\t\tn.next.prev = n.prev\n\t\t\tl.length--\n\t\t}\n\t}\n\tl.Unlock()\n}", "func RemoveElement(nums []int, val int) int {\n\tfor i := 0; i < len(nums); i++ {\n\t\tif nums[i] == val {\n\t\t\tnums = append(nums[:i], nums[i+1:]...)\n\t\t\ti--\n\t\t}\n\t}\n\n\treturn len(nums)\n}", "func (this *LinkedList) RemoveAt(index int) interface{} {\n\tif index < 0 || index >= this.Size() {\n\t\tpanic(\"index out of bound\")\n\t}\n\tpe := this.head\n\tvar ps *entry\n\tvar ele interface{}\n\tps = nil\n\tfor i := 0; i < index; i++ {\n\t\tps = pe\n\t\tpe = pe.next\n\t}\n\tif ps != nil {\n\t\tele = pe.elem\n\t\tps.next = pe.next\n\t\tif pe == this.tail {\n\t\t\t// remove the last element\n\t\t\tthis.tail = ps\n\t\t}\n\t} else {\n\t\t// remove the first element\n\t\tele = pe.elem\n\t\tthis.head = this.head.next\n\t\t// if remove the only one element, tail must be change to nil\n\t\tif this.tail == pe {\n\t\t\tthis.tail = nil\n\t\t}\n\t}\n\tthis.size--\n\treturn ele\n}", "func DeleteElement(del string, hash [][]string, x int) [][]string {\n\ta := len(hash[x])\n\tvar i int\n\tfor i = 0; i < a; i++ {\n\t\tif hash[x][i] == del {\n\t\t\tbreak\n\t\t} else {\n\t\t\tcontinue\n\t\t}\n\t}\n\tif i == a {\n\t\tfmt.Println(\"element not found\")\n\t} else if i == (a - 1) {\n\t\thash[x][i] = \"\"\n\n\t} else {\n\t\tfor j := i; j < (a - 1); j++ {\n\t\t\thash[x][j] = hash[x][j+1]\n\t\t}\n\t\thash[x][a-1] = \"\"\n\t}\n\treturn hash\n}", "func (s StringSet) Remove(element string) {\n\tif s.Has(element) {\n\t\tdelete(s.Set, element)\n\t}\n}", "func (sset *SSet) Remove(value interface{}) {\n\tkey := sset.f(value)\n\tif index, found := sset.m_index[key]; found {\n\t\tsset.list.Remove(index)\n\t\tsset.m.Remove(key)\n\t\tdelete(sset.m_index, key)\n\t\tsset.fixIndex()\n\t}\n}", "func (c *QueuedChan) remove(cmd *queuedChanRemoveCmd) {\n\t// Get object count before remove.\n\tcount := c.List.Len()\n\t// Iterate list.\n\tfor i := c.Front(); i != nil; {\n\t\tvar re *list.Element\n\t\t// Filter object.\n\t\tok, cont := cmd.f(i.Value)\n\t\tif ok {\n\t\t\tre = i\n\t\t}\n\t\t// Next element.\n\t\ti = i.Next()\n\t\t// Remove element\n\t\tif nil != re {\n\t\t\tc.List.Remove(re)\n\t\t}\n\t\t// Continue\n\t\tif !cont {\n\t\t\tbreak\n\t\t}\n\t}\n\t// Update channel length\n\tatomic.StoreInt32(&c.len, int32(c.List.Len()))\n\t// Return removed object number.\n\tcmd.r <- count - c.List.Len()\n}", "func (r *RecordCache) remove(response Response) {\n\tkey := response.FormatKey()\n\tLogger.Log(NewLogMessage(\n\t\tDEBUG,\n\t\tLogContext{\n\t\t\t\"what\": \"removing cache entry\",\n\t\t\t\"key\": key,\n\t\t},\n\t\tfunc() string { return fmt.Sprintf(\"resp [%v] cache [%v]\", response, r) },\n\t))\n\tdelete(r.cache, key)\n\tCacheSizeGauge.Set(float64(len(r.cache)))\n}", "func (list *List) Remove(e Entity) {\n\tdelete(list.m, e.Index())\n}", "func (m *clistModel) Remove(t *rapid.T) {\n\tif len(m.model) == 0 {\n\t\treturn\n\t}\n\tix := rapid.IntRange(0, len(m.model)-1).Draw(t, \"index\").(int)\n\tvalue := m.model[ix]\n\tm.model = append(m.model[:ix], m.model[ix+1:]...)\n\tm.clist.Remove(value)\n}", "func (fs *memoryCacheFilesystem) removeOldest() {\n\tent := fs.evictList.Back()\n\n\tif ent != nil {\n\t\tfs.removeElement(ent)\n\t}\n}", "func (ss *StringSet) Remove(element string) *StringSet {\n\tdelete(ss.set, element)\n\treturn ss\n}", "func (cell * SpaceMapCell) Remove(el SpaceMapElement) (SpaceMapElement) {\n var e *list.Element\n for e = cell.Shapes.Front() ; e != nil ; e = e.Next() {\n val := e.Value\n if val.(SpaceMapElement) == el {\n cell.Shapes.Remove(e)\n return el\n }\n }\n return nil\n}", "func (al *ArrayList) RemoveItem(value interface{}) {\n\tfor i := 0; i < al.Size(); i++ {\n\t\tif al.slice[i] == value {\n\t\t\tal.RemoveItemAtIndex(i)\n\t\t}\n\t}\n}", "func (cache *Cache) removeNodeInfoFromList(name string) {\n\tni, ok := cache.nodes[name]\n\tif !ok {\n\t\tklog.Errorf(\"No NodeInfo with name %v found in the cache\", name)\n\t\treturn\n\t}\n\n\tif ni.prev != nil {\n\t\tni.prev.next = ni.next\n\t}\n\tif ni.next != nil {\n\t\tni.next.prev = ni.prev\n\t}\n\t// if the removed item was at the head, we must update the head.\n\tif ni == cache.headNode {\n\t\tcache.headNode = ni.next\n\t}\n\n\tdelete(cache.nodes, name)\n}", "func (set *SetUI) Remove(uint uint) {\n\tset.lock.Lock()\n\tdelete(set.cache, uint)\n\tset.lock.Unlock()\n}", "func (list *List) removeByIndex(idx int) error {\n\tlist_ := []interface{}(*list)\n\t*list = append(list_[:idx], list_[idx+1:]...)\n\treturn nil\n}", "func (sw *SW) Remove(name string) error {\n\tsw.mtx.Lock()\n\n\tif sw.elems == nil || len(sw.elems) == 0 {\n\t\tsw.mtx.Unlock()\n\t\treturn fmt.Errorf(\"smooth weight list is empty\")\n\t}\n\n\tfor idx, elem := range sw.elems {\n\t\tif elem.name == name {\n\t\t\tsw.elems = append(sw.elems[0:idx-1], sw.elems[idx+1:]...)\n\n\t\t\tsw.mtx.Unlock()\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tsw.mtx.Unlock()\n\treturn fmt.Errorf(\"element not exist\")\n}", "func (e *entry) remove() {\n\tif e.logical != noAnchor {\n\t\tlog.Fatalf(\"may not remove anchor %q\", e.str)\n\t}\n\t// TODO: need to set e.prev.level to e.level if e.level is smaller?\n\te.elems = nil\n\tif !e.skipRemove {\n\t\tif e.prev != nil {\n\t\t\te.prev.next = e.next\n\t\t}\n\t\tif e.next != nil {\n\t\t\te.next.prev = e.prev\n\t\t}\n\t}\n\te.skipRemove = false\n}", "func (s *Set) Remove(elements ...interface{}) {\n\tif len(elements) == 0 {\n\t\treturn\n\t}\n\n\ts.mutex.Lock()\n\tfor _, element := range elements {\n\t\tdelete(s.m, element)\n\t}\n\ts.mutex.Unlock()\n}", "func (l *List) Remove(element interface{}) bool {\n\titem, found := l.find(element)\n\tif !found {\n\t\treturn false\n\t}\n\tif l.Len() == 1 {\n\t\tl.firstElement = nil\n\t\tl.lastElement = nil\n\t}\n\tif item.Prev != nil {\n\t\titem.Prev.Next = item.Next\n\t} else {\n\t\tl.firstElement = item.Next\n\t\tl.firstElement.Prev = nil\n\t}\n\tif item.Next != nil {\n\t\titem.Next.Prev = item.Prev\n\t} else {\n\t\tl.lastElement = item.Prev\n\t\tl.lastElement.Next = nil\n\t}\n\tl.len = l.len - 1\n\treturn true\n}", "func (c *EntryCache) Remove(name string) error {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\te, present := c.entries[name]\n\tif !present {\n\t\treturn fmt.Errorf(\"entry '%s' is not in the cache\", name)\n\t}\n\te.mu.Lock()\n\tdelete(c.entries, name)\n\thashes, err := allHashes(e, c.hashes)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, h := range hashes {\n\t\tdelete(c.lookupMap, h)\n\t}\n\tc.log.Info(\"[cache] Removed entry for '%s' from cache\", name)\n\treturn nil\n}", "func (list *MyArrayList) removeAtIndex(idx int) (int, error) {\n\tif idx >= list.currSize {\n\t\treturn 0, errors.New(\"index out of bounds\")\n\t}\n\toldVal := list.array[idx]\n\tfor i := idx; i< (list.currSize -1); i++ {\n\t\tlist.array[i] = list.array[i+1]\n\t}\n\tlist.currSize--\n\treturn oldVal, nil\n}", "func (k *MutableKey) Remove(val uint64) {\n\tdelete(k.vals, val)\n\tk.synced = false\n}", "func (d *Dispatcher) Remove(key []byte) {\n\tlru := d.getLRU(key)\n\tlru.Lock()\n\tdefer lru.Unlock()\n\tlru.Remove(util.ByteSliceToString(key))\n}", "func (q *dStarLiteQueue) remove(n *dStarLiteNode) {\n\theap.Remove(q, n.idx)\n\tn.key = badKey\n\tn.idx = -1\n}", "func (this *MyHashMap) Remove(key int) {\n\tindex := key & (this.b - 1)\n\tremoveIndex := 0\n\tremove := false\n\tfor e := range this.bucket[index] {\n\t\tif this.bucket[index][e].key == key {\n\t\t\tremoveIndex = e\n\t\t\tremove = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif remove {\n\t\tthis.bucket[index] = append(this.bucket[index][:removeIndex], this.bucket[index][removeIndex+1:]...)\n\t}\n}", "func (list *ArrayList[T]) RemoveAt(index int) (T, bool) {\n\tif index < 0 || index >= list.Size() {\n\t\tvar zero T\n\t\treturn zero, false\n\t}\n\tele := list.elems[index]\n\tlist.elems = append(list.elems[:index], list.elems[index+1:]...)\n\treturn ele, true\n}", "func (list *ArrayList[T]) Remove(ele T) bool {\n\tfor i := 0; i < len(list.elems); i++ {\n\t\to := list.elems[i]\n\t\tif o == ele {\n\t\t\tlist.elems = append(list.elems[:i], list.elems[i+1:]...)\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (l *List) remove(n *Node) {\n\tn.prev.next = n.next\n\tn.next.prev = n.prev\n\tn.next = nil\n\tn.prev = nil\n\tn.list = nil\n\tl.Size--\n}", "func (l *LinkedList) Remove() *Element {\n\telement := l.Head\n\tl.Head = element.Next\n\telement.Next = nil\n\treturn element\n}", "func (rht *RHT) Remove(k string) Element {\n\tif queue, ok := rht.elementQueueMapByKey[k]; ok {\n\t\titem := queue.Peek()\n\t\titem.Remove()\n\t\treturn item.value\n\t}\n\treturn nil\n}", "func (i *ImmediateCron) Remove(id cron.EntryID) {}", "func (p *ClockPolicy) Remove(key CacheKey) {\n\tnode, ok := p.keyNode[key]\n\tif !ok {\n\t\treturn\n\t}\n\n\tif p.clockHand == node {\n\t\tp.clockHand = p.clockHand.Prev()\n\t}\n\tp.list.Remove(node)\n\tdelete(p.keyNode, key)\n}", "func (sb *shardBuffer) remove(toRemove *entry) {\n\tsb.mu.Lock()\n\tdefer sb.mu.Unlock()\n\n\tif sb.queue == nil {\n\t\t// Queue is cleared because we're already in the DRAIN phase.\n\t\treturn\n\t}\n\n\t// If entry is still in the queue, delete it and cancel it internally.\n\tfor i, e := range sb.queue {\n\t\tif e == toRemove {\n\t\t\t// Delete entry at index \"i\" from slice.\n\t\t\tsb.queue = append(sb.queue[:i], sb.queue[i+1:]...)\n\n\t\t\t// Cancel the entry's \"bufferCtx\".\n\t\t\t// The usual drain or eviction code would unblock the request and then\n\t\t\t// wait for the \"bufferCtx\" to be done.\n\t\t\t// But this code path is different because it's going to return an error\n\t\t\t// to the request and not the \"e.bufferCancel\" function i.e. the request\n\t\t\t// cannot cancel the \"bufferCtx\" itself.\n\t\t\t// Therefore, we call \"e.bufferCancel\". This also avoids that the\n\t\t\t// context's Go routine could leak.\n\t\t\te.bufferCancel()\n\t\t\t// Release the buffer slot and close the \"e.done\" channel.\n\t\t\t// By closing \"e.done\", we finish it explicitly and timeoutThread will\n\t\t\t// find out about it as well.\n\t\t\tsb.unblockAndWait(e, nil /* err */, true /* releaseSlot */, false /* blockingWait */)\n\n\t\t\t// Track it as \"ContextDone\" eviction.\n\t\t\tstatsKeyWithReason := append(sb.statsKey, string(evictedContextDone))\n\t\t\trequestsEvicted.Add(statsKeyWithReason, 1)\n\t\t\treturn\n\t\t}\n\t}\n\n\t// Entry was already removed. Keep the queue as it is.\n}", "func (*BackupList) remove(b []*BackupInfo, index int) ([]*BackupInfo, error) {\n\tif b == nil {\n\t\treturn nil, fmt.Errorf(\"empty list\")\n\t}\n\tif index >= len(b) || index < 0 {\n\t\treturn nil, fmt.Errorf(\"BUG: attempting to delete an out of range index entry from backupList\")\n\t}\n\treturn append(b[:index], b[index+1:]...), nil\n}", "func (s *Set) Remove(element interface{}) bool {\n\tif _, exists := (*s)[element]; exists {\n\t\tdelete(*s, element)\n\t\treturn true\n\t}\n\treturn false\n}", "func (list *List) Remove(index int) {\n\n\tif !list.withinRange(index) {\n\t\treturn\n\t}\n\n\tif list.size == 1 {\n\t\tlist.Clear()\n\t\treturn\n\t}\n\n\tvar beforeElement *element\n\telement := list.first\n\tfor e := 0; e != index; e, element = e+1, element.next {\n\t\tbeforeElement = element\n\t}\n\n\tif element == list.first {\n\t\tlist.first = element.next\n\t}\n\tif element == list.last {\n\t\tlist.last = beforeElement\n\t}\n\tif beforeElement != nil {\n\t\tbeforeElement.next = element.next\n\t}\n\n\telement = nil\n\n\tlist.size--\n}", "func TestHashRemove(t *testing.T){\n\tlist := hashlist.NewHashList(10)\n\tfor i:= 1 ; i < 10 ;i ++ {\n\t\tlist.Insert(string(i), string(i))\n\t}\n\tlist.Remove(\"3\")\n\tres := list.Get(\"3\")\n\tif res != nil {\n\t\tt.Error(\"Hash list Set 更新失败\")\n\t}\n}", "func (e *entry) remove() {\n\te.prev.next = e.next\n\te.next.prev = e.prev\n\te.prev = nil\n\te.next = nil\n}", "func (c *LRU) removeOldest() {\n\tc.RLock()\n\tent := c.evictList.Back()\n\tc.RUnlock()\n\n\tif ent != nil {\n\t\tc.removeElement(ent)\n\t}\n}", "func (l *DcmList) Remove() *DcmObject {\n\tif l.Empty() {\n\t\treturn nil\n\t} else if l.Valid() != true {\n\t\treturn nil\n\t} else {\n\t\ttmpnode := l.currentNode\n\t\tif l.currentNode.prevNode == nil {\n\t\t\tl.firstNode = l.currentNode.nextNode // delete first element\n\t\t} else {\n\t\t\tl.currentNode.prevNode.nextNode = l.currentNode.nextNode\n\t\t}\n\t\tif l.currentNode.nextNode == nil {\n\t\t\tl.lastNode = l.currentNode.prevNode // delete last element\n\t\t} else {\n\t\t\tl.currentNode.nextNode.prevNode = l.currentNode.prevNode\n\t\t}\n\t\tl.currentNode = l.currentNode.nextNode\n\t\ttmpobj := tmpnode.Value()\n\t\tl.cardinality = l.cardinality - 1\n\t\treturn tmpobj\n\t}\n}", "func removeElementFromStringSlice(list []string, elem string) []string {\n\tfor i, e := range list {\n\t\tif e == elem {\n\t\t\treturn append(list[:i], list[i+1:]...)\n\t\t}\n\t}\n\treturn list\n}", "func remove(arr []string, element string) []string {\n\tvar remaining []string\n\n\tfor i := 0; i < len(arr); i++ {\n\t\tif element != arr[i] {\n\t\t\tremaining = append(remaining, arr[i])\n\t\t}\n\t}\n\n\treturn remaining\n}", "func (c *LRU) Remove(key interface{}) interface{} {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif ele, found := c.cache[key]; found {\n\t\t_, value := c.remove(ele)\n\t\treturn value\n\t}\n\treturn nil\n}", "func (hm *HashMap) Remove(key []byte) error {\n\t// validate hashKey\n\terr := hm.np.validateKey(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\t//1. calculate the hash num\n\thashNum := hm.hashFunc(key) % uint64(hm.haSize)\n\n\t//2. remove key from hashNode\n\thead := hm.ha[hashNum]\n\tif head == -1 {\n\t\treturn nil\n\t}\n\tnewHead := hm.np.del(head, key)\n\n\t//3. point to the new list head node\n\thm.ha[hashNum] = newHead\n\n\treturn nil\n}", "func (c *Cache) Remove(key Key) {\r\n\tc.Lock()\r\n\tdefer c.Unlock()\r\n\r\n\tif c.cache == nil {\r\n\t\treturn\r\n\t}\r\n\tif ele, hit := c.cache[key]; hit {\r\n\t\tc.removeElement(ele)\r\n\t} else {\r\n\t\tswitch key.(type) {\r\n\t\tcase string:\r\n\t\t\tre := regexp.MustCompile(key.(string))\r\n\t\t\tfor k, v := range c.cache {\r\n\t\t\t\tif re.MatchString(k.(string)) {\r\n\t\t\t\t\tc.removeElement(v)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}", "func (t *TaskList) Remove(name string) {\n\tt.Lock()\n\tdefer t.Unlock()\n\tdelete(t.taskSet, name)\n}" ]
[ "0.8320907", "0.81145364", "0.7983885", "0.7678603", "0.76477677", "0.7279263", "0.66169834", "0.66034144", "0.6571837", "0.6543601", "0.65129757", "0.6481357", "0.6479635", "0.63942623", "0.63942623", "0.6362943", "0.6305739", "0.6297719", "0.62013304", "0.6185396", "0.61736536", "0.6159539", "0.6135888", "0.6131067", "0.6103831", "0.60754776", "0.6072785", "0.6061989", "0.6020575", "0.6015762", "0.6009745", "0.60096365", "0.6003839", "0.59976995", "0.5972413", "0.5959947", "0.5936971", "0.5922477", "0.5922183", "0.5922183", "0.59172297", "0.5879516", "0.5875553", "0.58742416", "0.58576906", "0.5855211", "0.5833622", "0.58329505", "0.57964253", "0.57840455", "0.57647926", "0.5747297", "0.57449085", "0.5727634", "0.5719341", "0.57056874", "0.5688709", "0.56754565", "0.5665672", "0.566482", "0.56647015", "0.5656577", "0.5654348", "0.56540847", "0.5648885", "0.56469727", "0.5635801", "0.56342584", "0.563389", "0.5631959", "0.5628297", "0.56169975", "0.56134564", "0.56127024", "0.5603925", "0.55821896", "0.55787975", "0.55728245", "0.55695164", "0.55634874", "0.5556332", "0.5552627", "0.5549192", "0.5544668", "0.5538646", "0.5535893", "0.55184424", "0.55105674", "0.5507914", "0.5501333", "0.5499245", "0.5497395", "0.5495096", "0.54950273", "0.54870147", "0.54788345", "0.5477466", "0.5476432", "0.5475562", "0.5468191" ]
0.787609
3
Search for an element with a key
func (c *TimeoutCache) searchElement(key interface{}) *list.Element { for e := c.evictList.Back(); e != nil; e = e.Prev() { kv := e.Value.(*entry) if kv.key == key { return e } } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (l *LinkedList) SearchKey(v rtype.String) rtype.ListElement {\n\tfor e := l.Front(); e != nil; e = e.Next() {\n\t\tif rstring.EqualStringObjects(e.Value(), v) {\n\t\t\treturn e\n\t\t}\n\t}\n\treturn nil\n}", "func (t *openAddressing) Search(key string) interface{} {\n\tround := 0\n\tfor round != len(t.values) {\n\t\thash := t.hash(key, round)\n\t\tslot := t.values[hash]\n\t\tif slot != nil && !slot.deleted && slot.key == key {\n\t\t\treturn slot.value\n\t\t}\n\t\tround++\n\t}\n\treturn nil\n}", "func (t *chaining) Search(key string) interface{} {\n\thash := t.hash(key)\n\tlist := t.values[hash]\n\tif list == nil || list.Len == 0 {\n\t\treturn nil\n\t}\n\thead := list.Start().Prev\n\tfor head != list.End() {\n\t\thead = head.Next\n\t\tpair := head.Value.(*pair)\n\t\tif pair.key == key {\n\t\t\treturn pair.value\n\t\t}\n\t}\n\treturn nil\n}", "func (n *Node) search(key interface{}) interface{} {\n\tif n.key == key {\n\t\treturn n.value\n\t}\n\tif n.parent != nil {\n\t\treturn n.parent.search(key)\n\t}\n\treturn nil\n}", "func (table Table) searchByKey(key string)(Field, int){\n\tmuForTable.RLock()\n\tdefer muForTable.RUnlock()\n\tif len(table) == 0 {\n\t\treturn Field{0,\"\",\"\"}, -1\n\t}\n\tvar i int\n\tfor i = 0; i<len(table); i++{\n\t\tif table[i].Key == key{\n\t\t\treturn table[i], i\n\t\t}\n\t}\n\treturn Field{0,\"\",\"\"}, -1\n}", "func (n *Node) locate(key string) (*models.Node, error) {\n\tid, err := n.hashKey(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsucc, err := n.findSuccessor(id)\n\treturn succ, err\n}", "func FindByKey(key string) (*Ingredient, error) {\n\treturn FindBy(\"_key\", key)\n}", "func (t Tags) FindByKey(key string) string {\n\tfor _, tag := range t {\n\t\tif aws.StringValue(tag.Key) == key {\n\t\t\treturn aws.StringValue(tag.Value)\n\t\t}\n\t}\n\treturn \"\"\n}", "func (st *SlimTrie) Search(key string) (lVal, eqVal, rVal interface{}) {\n\n\tlID, eqID, rID := st.searchID(key)\n\n\tif lID != -1 {\n\t\tlVal, _ = st.Leaves.Get(lID)\n\t}\n\tif eqID != -1 {\n\t\teqVal, _ = st.Leaves.Get(eqID)\n\t}\n\tif rID != -1 {\n\t\trVal, _ = st.Leaves.Get(rID)\n\t}\n\n\treturn\n}", "func (t *ArtTree) Search(key []byte) interface{} {\n\tkey = ensureNullTerminatedKey(key)\n\tfoundNode := t.searchHelper(t.root, key, 0)\n\tif foundNode != nil && foundNode.IsMatch(key) {\n\t\treturn foundNode.value\n\t}\n\treturn nil\n}", "func (n *Node) Find(key string) (*api.Node, error) {\n\treturn n.locate(key)\n}", "func (n *Node) Find(key string) (*models.Node, error) {\n\treturn n.locate(key)\n}", "func (cm CMap) FindBy(key interface{}, mf MatchF) *CMapEntry {\n\tfor _, entry := range cm.Entries {\n\t\tif mf(key, entry.Key) {\n\t\t\treturn &entry\n\t\t}\n\t}\n\treturn nil\n}", "func (n *node) search(key int) (*node, bool) {\n\t// idx is first largerOrEquals than key\n\tidx, found := n.find(key)\n\tif found {\n\t\treturn n, true\n\t}\n\n\tif n.isLeaf {\n\t\treturn nil, false\n\t}\n\n\t// search left child\n\treturn n.children[idx].search(key)\n}", "func searchForKey[K ~[]byte, O Ordering[K]](key K, order O) SearchFn {\n\treturn func(nd Node) (idx int) {\n\t\tn := int(nd.Count())\n\t\t// Define f(-1) == false and f(n) == true.\n\t\t// Invariant: f(i-1) == false, f(j) == true.\n\t\ti, j := 0, n\n\t\tfor i < j {\n\t\t\th := int(uint(i+j) >> 1) // avoid overflow when computing h\n\t\t\tless := order.Compare(key, K(nd.GetKey(h))) <= 0\n\t\t\t// i ≤ h < j\n\t\t\tif !less {\n\t\t\t\ti = h + 1 // preserves f(i-1) == false\n\t\t\t} else {\n\t\t\t\tj = h // preserves f(j) == true\n\t\t\t}\n\t\t}\n\t\t// i == j, f(i-1) == false, and\n\t\t// f(j) (= f(i)) == true => answer is i.\n\t\treturn i\n\t}\n}", "func (c *SentencesUnitCollection) Find(key string) (*SentencesUnit, bool) {\n\tfor _, v := range *c {\n\t\tif v.Key == key {\n\t\t\treturn &v, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (sh *ServerHandler)FindByKey(ctx context.Context, req *pb.FindRequest) (*pb.FindResult, error) {\r\n\tdata, next, err := sh.readonly.GetNValsByKey(*req.Start, *req.Num)\r\n\tvar res pb.FindResult\r\n\tvar errcode int32\r\n\tif(err != nil){\r\n\t\terrcode = 1\r\n\t\tres.Err = &errcode\r\n\t}else{\r\n\t\tres.Err = &errcode\r\n\t\tres.Kvpairs = data\r\n\t}\r\n\tres.Nextindex = &next\r\n\treturn &res, nil\r\n}", "func (q *Queue) SearchElement(v interface{}) *Element {\n\te := q.root\n\tfor e.next != q.root {\n\t\tif e.next.value == v {\n\t\t\treturn e.next\n\t\t}\n\t\te = e.next\n\t}\n\n\treturn nil\n}", "func (d *DirectAddress) Search(key int) (interface{}, error) {\n\tif err := d.validateKey(key); err != nil {\n\t\treturn nil, err\n\t}\n\treturn d.array[key-d.uMin], nil\n}", "func (v *Venom) Find(key string) (interface{}, bool) {\n\treturn v.Store.Find(key)\n}", "func (b *bucket) find(key string) (*node, bool) {\n\tif b.nodes == nil {\n\t\treturn nil, false\n\t}\n\n\tvar n *node\n\tfor n = b.nodes; n.next != nil; n = n.next {\n\t\tif n.key == key {\n\t\t\treturn n, true\n\t\t}\n\t}\n\n\tif n != nil && n.key == key {\n\t\treturn n, true\n\t}\n\n\treturn n, false\n}", "func (st *SequentialSearchST) Get(key interface{}) interface{} {\n\tfor x := st.first; x != nil; x = x.next {\n\t\tif x.key == key {\n\t\t\treturn x.val\n\t\t}\n\t}\n\treturn nil\n}", "func (entries Entries) get(key uint64) Entry {\n\ti := entries.search(key)\n\tif i == len(entries) {\n\t\treturn nil\n\t}\n\n\tif entries[i].Key() == key {\n\t\treturn entries[i]\n\t}\n\n\treturn nil\n}", "func (r *reflectorStore) GetByKey(key string) (item interface{}, exists bool, err error) {\n\tpanic(\"not implemented\")\n}", "func (entries Entries) search(key uint64) int {\n\treturn sort.Search(len(entries), func(i int) bool {\n\t\treturn entries[i].Key() >= key\n\t})\n}", "func (r *Ring) search(key string) int {\n\treturn sort.Search(len(r.Nodes), func(i int) bool {\n\t\treturn r.Nodes[i].HashID > r.Hasher(key)\n\t})\n}", "func (r *RadixTrie) Find(key string) (interface{}, bool) {\n\tif len(key) == 0 {\n\t\treturn r.val, r.ok\n\t}\n\tif r.nodes == nil {\n\t\treturn nil, false\n\t}\n\tns := r.nodes\nsearch:\n\tfor {\n\t\tfor i := 0; i < len(ns); i++ {\n\t\t\tif key[0] == ns[i].str[0] {\n\t\t\t\tif len(key) < len(ns[i].str) {\n\t\t\t\t\treturn nil, false\n\t\t\t\t}\n\t\t\t\tfor j := 1; j < len(ns[i].str); j++ {\n\t\t\t\t\tif key[j] != ns[i].str[j] {\n\t\t\t\t\t\treturn nil, false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif len(key) == len(ns[i].str) {\n\t\t\t\t\treturn ns[i].val, ns[i].ok\n\t\t\t\t}\n\t\t\t\tkey = key[len(ns[i].str):]\n\t\t\t\tns = ns[i].nodes\n\t\t\t\tcontinue search\n\t\t\t}\n\t\t}\n\t\treturn nil, false\n\t}\n}", "func (node Node) Search(key int) bool {\n\tvar status bool\n\n\tif node.Key == key {\n\t\tstatus = true\n\t} else if node.Key > key && node.LeftChild != nil {\n\t\treturn node.LeftChild.Search(key)\n\t} else if node.Key < key && node.RightChild != nil {\n\t\treturn node.RightChild.Search(key)\n\t} else {\n\t\tstatus = false\n\t}\n\n\treturn status\n}", "func (t *Tree) search(k Key) Value {\n\tx := t.root\n\tfor x != nil {\n\t\tcmp := x.key.Compare(k)\n\t\tif cmp == 0 {\n\t\t\treturn x.value\n\t\t}\n\t\tif cmp < 0 {\n\t\t\tx = x.left\n\t\t}\n\t\tif cmp > 0 {\n\t\t\tx = x.right\n\t\t}\n\t}\n\treturn nil\n}", "func (t tagSet) Search(key string) int {\n\ti, j := 0, len(t)\n\tfor i < j {\n\t\th := (i + j) / 2\n\t\tif t[h].key < key {\n\t\t\ti = h + 1\n\t\t} else {\n\t\t\tj = h\n\t\t}\n\t}\n\treturn i\n}", "func (n *Node) locate(key []byte) int {\n\ti := 0\n\tsize := len(n.Keys)\n\tfor {\n\t\tmid := (i + size) / 2\n\t\tif i == size {\n\t\t\tbreak\n\t\t}\n\t\tif bytes.Compare(n.Keys[mid], key) <= 0 {\n\t\t\ti = mid + 1\n\t\t} else {\n\t\t\tsize = mid\n\t\t}\n\t}\n\treturn i\n}", "func findValue(n node, key string) (node, bool) {\n\tif n.Kind != yamlast.MappingNode {\n\t\tpanic(\"findValue requires a mapping node\")\n\t}\n\tfor i := 0; i < len(n.Children)-1; i += 2 {\n\t\tk := n.Children[i]\n\t\tv := n.Children[i+1]\n\t\tif strings.ToLower(k.Value) == strings.ToLower(key) {\n\t\t\treturn v, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (d Dictionary) Search(key string) (string, error) {\n\tvalue, err := d[key]\n\tif !err {\n\t\treturn \"\", ErrNotFound\n\t}\n\treturn value, nil\n}", "func (h *Header) Contains(key string) (value string, ok bool) {\n\tvar i int\n\tif i, ok = h.index(key); ok {\n\t\tvalue = h.slice[i+1]\n\t}\n\treturn\n}", "func (tree *Trie) ContainsKey(key string) bool {\n\t_, found := tree.Find(key)\n\treturn found\n}", "func (a *PushKeyAPI) find(params interface{}) (resp *rpc.Response) {\n\to := objx.New(params)\n\tkeyID := o.Get(\"id\").Str()\n\tblockHeight := cast.ToUint64(o.Get(\"height\").Inter())\n\tkey := a.mods.PushKey.Find(keyID, blockHeight)\n\treturn rpc.Success(key)\n}", "func (t *RbTree[K, V]) Find(key K) (V, error) {\n\tn := t.findFirstNode(key)\n\tif n != nil {\n\t\treturn n.value, nil\n\t}\n\treturn *new(V), ErrorNotFound\n}", "func (dict *Dictionary) Find(key DictKey) DictVal {\n\tdict.lock.RLock()\n\tdefer dict.lock.RUnlock()\n\treturn dict.elements[key]\n}", "func Search(key, subject interface{}) interface{} {\n\tvar searchResult interface{}\n\n\t//log.Debugf(\"deep searching, key %s\", key)\n\tswitch ReflectKind(subject) {\n\tcase reflect.Slice:\n\t\t//log.Debug(\"subject is a slice\")\n\t\tsubjectSlice := subject.([]interface{})\n\t\t//log.Debugf(\"slice size %d\", len(subjectSlice))\n\t\tfor _, sliceValue := range subjectSlice {\n\t\t\t//log.Debugf(\"deep searching slice @ index %d\", index)\n\t\t\tsearchResult = Search(key, sliceValue)\n\t\t}\n\n\t\tbreak\n\tcase reflect.Map:\n\t\t//log.Debug(\"subject is a map\")\n\t\tsubjectMap := subject.(map[string]interface{})\n\t\tfor index, value := range subjectMap {\n\t\t\t//log.Debugf(\"iterating map keys, @ key %v value %v\", index, value)\n\t\t\t//maps can have a varse number of values array, slice, map, so their values are subjected to possibly recursive\n\t\t\tif index == key {\n\t\t\t\t//log.Debugf(\"found value %v @ index %v\", value, index)\n\t\t\t\tsearchResult = value\n\t\t\t}\n\t\t}\n\t\tbreak\n\t}\n\n\treturn searchResult\n}", "func findItem(id string) Item {\n\tfor _, I := range items {\n\t\tfound := getXidString(I)\n\t\tif id == found {\n\t\t\treturn I\n\t\t}\n\t}\n\t// return empty item if not found\n\treturn Item{}\n}", "func (m *Memtable) Find(key string) (value []byte, found bool) {\n\tif key == \"\" {\n\t\tglog.Fatal(\"Invalid empty key.\")\n\t}\n\n\tn := m.findGreaterOrEqual(key, math.MaxInt64, nil)\n\n\tif n != nil && n.key == key {\n\t\treturn n.value, true\n\t}\n\treturn nil, false\n}", "func Get(m Map, key Key) (val Value, ok bool) {\n\thash := key.Hash()\n\tval, ok = m.find(0, hash, key)\n\treturn val, ok\n}", "func find(msi interface{}, key string) (interface{}, error) {\n\tms, ok := msi.(yaml.MapSlice)\n\tif !ok {\n\t\treturn nil, errors.New(\"find: cannot cast to yaml.MapSlice\")\n\t}\n\tfor _, mi := range ms {\n\t\tif k, ok := mi.Key.(string); ok && k == key {\n\t\t\treturn mi.Value, nil\n\t\t}\n\t}\n\treturn nil, errors.New(\"find: cannot find a key '\" + key + \"'\")\n}", "func (root *TreeNode) search(key interface{}) *TreeNode {\n\tif root.key == key {\n\t\treturn root\n\t}\n\n\tif root.issmaller(key, root.key) {\n\t\tif root.left == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn root.left.search(key)\n\t}\n\n\tif root.right == nil {\n\t\treturn nil\n\t}\n\treturn root.right.search(key)\n}", "func (hn *HeadNode) Search(key interface{}) bool {\n\treturn hn.Get(key) != Node(nil)\n}", "func find(element string, data []string) (int) {\n\tfor k, v := range data {\n\t\tif element == v {\n\t\t\treturn k\n\t\t}\n\t}\n\treturn -1\n}", "func (tree *Trie) Find(key string) (value interface{}, found bool) {\n\tnode, found := tree.findNodeByMask(key)\n\n\tif found && node.terminal {\n\t\treturn node.data, true\n\t}\n\n\treturn nil, false\n}", "func (e *Element) Get(key string) (interface{}, bool) {\n\tif e.items == nil {\n\t\te.items = make(map[string]interface{})\n\t}\n\tv, ok := e.items[key]\n\treturn v, ok\n}", "func (l *PackageList) SearchByKey(arch, name, version string) (result *PackageList) {\n\tresult = NewPackageListWithDuplicates(l.duplicatesAllowed, 0)\n\n\tpkg := l.packages[\"P\"+arch+\" \"+name+\" \"+version]\n\tif pkg != nil {\n\t\tresult.Add(pkg)\n\t}\n\n\treturn\n}", "func (this *Map) Find(key interface{}) ConstKvIterator {\n\tnode := this.tree.FindNode(key)\n\treturn &MapIterator{node: node}\n}", "func contains(key string, search []string) bool {\n\tfor _, val := range search {\n\t\tif val == key {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (dst *Bravo) search(key uint64) (*bnode, uint64) {\n\tvar node *bnode\n\tnext := dst.root\n\tmask := initialMask\n\n\tfor ; mask != 0; mask >>= 1 {\n\t\tnode = next\n\t\tif key&mask != 0 {\n\t\t\tnext = node.right\n\t\t} else {\n\t\t\tnext = node.left\n\t\t}\n\t\tif next == nil {\n\t\t\treturn node, mask\n\t\t}\n\t}\n\n\treturn node, mask\n}", "func (this *WordDictionary) Search(word string) bool {\n \n}", "func (e *env) find(key string) (*env, error) {\n\t_, ok := e.m[key]\n\tif ok {\n\t\treturn e, nil\n\t}\n\tif e.outer != nil {\n\t\treturn e.outer.find(key)\n\t}\n\treturn nil, fmt.Errorf(\"%q not found\", key)\n}", "func (m *Map) Find(key interface{}) (value interface{}, found bool) {\n\troot := m.root\n\tfor root != nil {\n\t\tif m.less(key, root.key) {\n\t\t\troot = root.left\n\t\t} else if m.less(root.key, key) {\n\t\t\troot = root.right\n\t\t} else {\n\t\t\treturn root.value, true\n\t\t}\n\t}\n\treturn nil, false\n}", "func (this *MultiMap) Find(key interface{}) ConstKvIterator {\n\tnode := this.tree.FindNode(key)\n\treturn &MapIterator{node: node}\n}", "func (m *MetadataCachedS3Backend) findKey(node *gproto.NodeMetadata, paths []string, level int) *gproto.NodeMetadata {\n\t// If listing the root path, return the root cache\n\tif level == 1 && len(paths) == 1 && paths[0] == \"\" {\n\t\treturn node\n\t}\n\n\tif !node.GetDirectory() {\n\t\treturn nil\n\t}\n\n\tcurrentPath := paths[level-1]\n\n\tchild, ok := node.Children[currentPath]\n\tif !ok {\n\t\treturn nil\n\t}\n\n\tif len(paths) == level {\n\t\treturn child\n\t}\n\n\treturn m.findKey(child, paths, level+1)\n}", "func (sm safeMap) Find(key string) (value interface{}, found bool) {\n\treply := make(chan interface{})\n\tsm <- commandData{action: FIND, key: key, result: reply}\n\tresult := (<-reply).(findResult)\n\treturn result.value, result.found\n}", "func (p *MemDB) Find(key []byte) (rkey, value []byte, err error) {\n\tif node, _ := p.findGE(key, false); node != 0 {\n\t\tn := p.nodeData[node]\n\t\tm := n + p.nodeData[node+nKey]\n\t\trkey = p.kvData[n:m]\n\t\tvalen := p.nodeData[node+nVal]\n\t\tif valen != 0 {\n\t\t\tvalue = p.kvData[m : m+valen]\n\t\t}\n\t} else {\n\t\terr = ErrNotFound\n\t}\n\treturn\n}", "func (sl *genericSkipList) Find(key Key) (Value, bool) {\n\tvar current = sl.head\n\n\tfor level := sl.height - 1; level >= 0; level-- {\n\t\tfor next := current.next[level]; next != nil && next.key.LessEq(key); {\n\t\t\tcurrent = next\n\t\t\tnext = current.next[level]\n\t\t}\n\t}\n\n\tif current == sl.head || !current.key.Eq(key) {\n\t\treturn defaultValue, false\n\t}\n\n\treturn current.value, true\n}", "func KeyContains(v string) predicate.Blob {\n\treturn predicate.Blob(\n\t\tfunc(s *sql.Selector) {\n\t\t\ts.Where(sql.Contains(s.C(FieldKey), v))\n\t\t},\n\t)\n}", "func (t *BinarySearch[T]) Get(key T) (Node[T], bool) {\n\treturn searchTreeHelper[T](t.Root, t._NIL, key)\n}", "func search(n *Node, key int) bool {\n\tif n == nil {\n\t\treturn false\n\t}\n\tif key < n.key {\n\t\treturn search(n.left, key)\n\t}\n\tif key > n.key {\n\t\treturn search(n.right, key)\n\t}\n\treturn true\n}", "func (x *Node) searchKey(sentinelT *Node, key int64) *Node {\n\n\tif x == sentinelT || key == x.key {\n\n\t\treturn x\n\t}\n\tif key < x.key {\n\t\treturn x.left.searchKey(sentinelT, key)\n\t}\n\treturn x.right.searchKey(sentinelT, key)\n\n}", "func findObjectWithKey(root interface{}, key string) interface{} {\n // if (typeof root !== 'object') {\n // return;\n // }\n\n switch root.(type) {\n default:\n \treturn nil\n case []interface{}:\n \tfor _, item := range root.([]interface{}) {\n \t\tanswer := findObjectWithKey(item, key)\n \t\tif answer != nil {\n \t\t\treturn answer\n \t\t}\n \t}\n case map[string]interface{}:\n }\n \n if _, ok := root.(map[string]interface{})[key]; ok {\n\t\t\n\t\treturn root\n\t}\n\n\tfor subkey, _ := range root.(map[string]interface{}) {\n\t\tanswer := findObjectWithKey(root.(map[string]interface{})[subkey], key)\n\t\tif answer != nil {\n\t\t\treturn answer\n\t\t}\n\t}\n \n return nil\n}", "func (t *Tree) Search(key string, compare func(interface{}, interface{}) bool,\n\tvalues ...string) (*Node, bool) {\n\treturn t.Root.Search(key, compare, values...)\n}", "func (s *SkipList) Get(key interface{}) (interface{}, bool) {\n\tcandidateNode := s.getPath(s.header, nil, key)\n\t//for candidateNode != nil && s.lessThan(candidateNode.key, key) {\n\t//\tcandidateNode = candidateNode.forwards[0]\n\t//}\n\tif candidateNode != nil && candidateNode.key == key {\n\t\treturn candidateNode.value, true\n\t}\n\treturn nil, false\n}", "func searchInDataFile(r io.ReadSeeker, offset int, searchKey []byte) ([]byte, bool, error) {\n\tif _, err := r.Seek(int64(offset), io.SeekStart); err != nil {\n\t\treturn nil, false, fmt.Errorf(\"failed to seek: %w\", err)\n\t}\n\n\tfor {\n\t\tkey, value, err := decode(r)\n\t\tif err != nil && err != io.EOF {\n\t\t\treturn nil, false, fmt.Errorf(\"failed to read: %w\", err)\n\t\t}\n\t\tif err == io.EOF {\n\t\t\treturn nil, false, nil\n\t\t}\n\n\t\tif bytes.Equal(key, searchKey) {\n\t\t\treturn value, true, nil\n\t\t}\n\t}\n}", "func (t *ObjectTree) Find(key Interface) interface{} {\n\treturn t.Tree.Find(key)\n}", "func (this *Map) Contains(key interface{}) bool {\n\tif this.tree.Find(key) != nil {\n\t\treturn true\n\t}\n\treturn false\n}", "func (t tagSet) Contains(key string) bool {\n\tif len(t) == 0 {\n\t\treturn false\n\t}\n\ti := t.Search(key)\n\treturn i < len(t) && t[i].key == key\n}", "func (m *TMap) Find(key interface{}) (value interface{}, exists bool) {\n\tv, ok := m.root.Find(entry{key: key})\n\tif !ok {\n\t\treturn nil, ok\n\t}\n\tent := v.(entry)\n\treturn ent.value, ok\n}", "func (this *Map) Get(key interface{}) interface{} {\n\tnode := this.tree.FindNode(key)\n\tif node != nil {\n\t\treturn node.Value()\n\t}\n\treturn nil\n}", "func (c *Cache) Contains(key interface{}) (bool, error) {\n\treturn c.adapter.Contains(c.getCtx(), key)\n}", "func (c *AdapterMemory) Contains(ctx context.Context, key interface{}) (bool, error) {\n\tv, err := c.Get(ctx, key)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn v != nil, nil\n}", "func findIndexByItem(keyName string, items []string) (int, bool) {\n\n\tfor index := range items {\n\t\tif keyName == items[index] {\n\t\t\treturn index, true\n\t\t}\n\t}\n\n\treturn -1, false\n}", "func Search(node *TrieNode, key string) bool {\n\tfor i := 0; i < len(key); i++ {\n\t\tindex := key[i] - 'a'\n\t\tif node.children[index] == nil {\n\t\t\treturn false\n\t\t}\n\t\tnode = node.children[index]\n\t}\n\treturn (node != nil && node.isEndOfWord)\n}", "func search(col, key, value string) ([]byte, error) {\n\n\tarr := make([]interface{}, 0)\n\tcc := collections[col]\n\n\t//Search the Map for the value\n\tfor _, v := range cc.Mapa {\n\t\t//TODO: This is absolutely inefficient, I'm creating a new array for each iteration. Fix this.\n\t\t//Is this possible to have something like java ArrayLists ?\n\t\tnod := v.Value.(*node)\n\n\t\t//Only check if field exists in document\n\t\tif nodeValue, ok := nod.V[key]; ok {\n\t\t\t//In case field is json.Number conver to string, otherwise check directly.\n\t\t\tif reflect.TypeOf(nodeValue).String() == \"json.Number\" {\n\t\t\t\tif value == string(nodeValue.(json.Number)) {\n\t\t\t\t\tarr = append(arr, nod.V)\n\t\t\t\t}\n\t\t\t} else if nodeValue == value {\n\t\t\t\tarr = append(arr, nod.V)\n\t\t\t}\n\t\t}\n\t}\n\n\t//Create the Json object\n\tb, err := json.Marshal(arr)\n\n\treturn b, err\n}", "func (ur *URLRepo) FindByKey(key string) (*models.URL, error) {\n\turl := &models.URL{}\n\n\terr := ur.Database.QueryRow(\"SELECT id, short_url, url, created_at, updated_at FROM urls WHERE short_url = ?\", key).\n\t\tScan(&url.ID, &url.Short, &url.Long, &url.CreatedAt, &url.UpdatedAt)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn url, nil\n}", "func (t *HashTable) Search(k string) (string, bool) {\n\tindex := t.hash(k)\n\tb := t.array[index]\n\tn, exist := b.search(k)\n\tif !exist {\n\t\treturn \"\", false\n\t}\n\treturn n.key, true\n}", "func (tree *Tree) Get(key interface{}) (value interface{}, found bool) {\n\tnode := tree.lookup(key)\n\tif node != nil {\n\t\treturn node.Value, true\n\t}\n\treturn nil, false\n}", "func Search(nv *[]NamedValue, name string) string {\n\tfor _, element := range *nv {\n\t\tif element.ValueName == name {\n\t\t\treturn element.Value\n\t\t}\n\t}\n\treturn \"\"\n}", "func (this *MultiMap) Get(key interface{}) interface{} {\n\tnode := this.tree.FindNode(key)\n\tif node != nil {\n\t\treturn node.Value()\n\t}\n\treturn nil\n}", "func (nl *NodeLister) ByKey(key string) (*apiv1.Node, error) {\n\tn, exists, err := nl.GetByKey(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !exists {\n\t\treturn nil, err\n\t}\n\treturn n.(*apiv1.Node), nil\n}", "func (l *InfosT) ByKey(argKey string) Info {\n\tfor i := 0; i < len(*l); i++ {\n\t\tfor _, key := range (*l)[i].Keys {\n\t\t\tif argKey == key {\n\t\t\t\treturn (*l)[i]\n\t\t\t}\n\t\t}\n\t}\n\tlog.Panicf(\"unknown link key %v\", argKey)\n\treturn Info{}\n}", "func (l *Leaf) locate(key []byte) int {\n\ti := 0\n\tsize := len(l.Keys)\n\tfor {\n\t\tmid := (i + size) / 2\n\t\tif i == size {\n\t\t\tbreak\n\t\t}\n\t\tif bytes.Compare(l.Keys[mid], key) <= 0 {\n\t\t\ti = mid + 1\n\t\t} else {\n\t\t\tsize = mid\n\t\t}\n\t}\n\treturn i\n}", "func (t *BPTree) Find(key []byte) (*Record, error) {\n\tvar (\n\t\tleaf *Node\n\t\ti int\n\t)\n\n\t// Find leaf by key.\n\tleaf = t.FindLeaf(key)\n\n\tif leaf == nil {\n\t\treturn nil, ErrKeyNotFound\n\t}\n\n\tfor i = 0; i < leaf.KeysNum; i++ {\n\t\tif compare(key, leaf.Keys[i]) == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif i == leaf.KeysNum {\n\t\treturn nil, ErrKeyNotFound\n\t}\n\n\treturn leaf.pointers[i].(*Record), nil\n}", "func (r *FlagRepository) FindByKey(ctx context.Context, key string) (*flaggio.Flag, error) {\n\tspan, ctx := opentracing.StartSpanFromContext(ctx, \"MongoFlagRepository.FindByKey\")\n\tdefer span.Finish()\n\n\t// filter for the flag key\n\tfilter := bson.M{\"key\": key}\n\n\tvar f flagModel\n\tif err := r.col.FindOne(ctx, filter).Decode(&f); err != nil {\n\t\tif err == mongo.ErrNoDocuments {\n\t\t\treturn nil, errors.NotFound(\"flag\")\n\t\t}\n\t\treturn nil, err\n\t}\n\treturn f.asFlag(), nil\n}", "func SearchKey(s Server, password string) (*Key, error) {\n\t// list all keys\n\tids, err := s.List(backend.Key)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// try all keys in repo\n\tvar key *Key\n\tfor _, id := range ids {\n\t\tkey, err = OpenKey(s, id, password)\n\t\tif err != nil {\n\t\t\tcontinue\n\t\t}\n\n\t\treturn key, nil\n\t}\n\n\treturn nil, ErrNoKeyFound\n}", "func (cell * SpaceMapCell) Find(el SpaceMapElement) (SpaceMapElement){\n finder := func (val interface {}) (bool) { \n\t testel := val.(SpaceMapElement)\n\t return el == testel\n } \n found := iterable.Find((cell.Shapes), finder)\n if found == nil { return nil } \n return found.(SpaceMapElement)\n}", "func (n *Node) Get(key string) *Node {\n\tfor _, node := range n.nodes {\n\t\tif node.key == key {\n\t\t\treturn node\n\t\t}\n\t}\n\treturn nil\n}", "func (bpt *BplusTree) Search(ss SearchSpecifier) ([]Element, error) {\n\tresult := make([]Element, 0) // We don't know the size.\n\t// Lets initialize the lock. We only need a read lock here.\n\tkeys := getKeysToLock(ss.searchKey)\n\tbpt.context.lockMgr.Lock(keys, nil)\n\tdefer bpt.context.lockMgr.Unlock(keys, nil)\n\n\t// Return error if not initialized.\n\tif !bpt.initialized {\n\t\tglog.Errorf(\"tree is not initialized\\n\")\n\t\treturn nil, common.ErrNotInitialized\n\t}\n\n\t// XXX: Do some more sanity check for the input parameters.\n\t// What should be the max limit of # of elements? Using 50 for now.\n\t// Better would be to curtail the elems to 50? For now, return error.\n\tif ss.maxElems > 50 {\n\t\tglog.Warning(\"max elements too large, should be less than 50\")\n\t\treturn nil, common.ErrTooLarge\n\t}\n\n\t// Get the leaf node where the element should be.\n\tnodes, _, err := bpt.searchFinder(ss.searchKey)\n\tif err != nil {\n\t\tglog.Errorf(\"failed to find key: %v (err: %v)\", ss.searchKey, err)\n\t\treturn nil, err\n\t}\n\n\tif len(nodes) != 1 {\n\t\tpanic(\"unexpected length\")\n\t}\n\n\tnode := nodes[0]\n\n\t// Do binary search in the leaf node.\n\tindex, exactMatch := node.find(ss.searchKey)\n\tif index >= len(node.Children) || exactMatch != true {\n\t\tglog.V(2).Infof(\"index: %d, exactMatch: %v, node: %v\", index, exactMatch, node)\n\t\tglog.Errorf(\"failed to find key: %v\", ss.searchKey)\n\t\treturn nil, common.ErrNotFound\n\t}\n\n\tmatchingElem := node.Children[index]\n\n\t// If search is exact then we already found the element. Return that.\n\t// TODO: Return the key as well intead of just data. SS needs updating.\n\tresult = append(result, matchingElem.Data)\n\tif ss.direction == Exact {\n\t\treturn result, nil\n\t}\n\n\t// Figure out how many elements to the left and/or right are to be\n\t// accumulated.\n\tnumElemsLeft := 0\n\tnumElemsRight := 0\n\tswitch {\n\tcase ss.direction == Right:\n\t\tnumElemsRight = ss.maxElems\n\tcase ss.direction == Left:\n\t\tnumElemsLeft = ss.maxElems\n\tcase ss.direction == Both:\n\t\tnumElemsLeft = ss.maxElems / 2\n\t\tnumElemsRight = ss.maxElems / 2\n\t}\n\n\t// Check to see if evaluator is in use.\n\tignoreEvaluator := false\n\tif ss.evaluator == nil {\n\t\tignoreEvaluator = true\n\t}\n\tevaluatorLeftExhausted := false\n\tevaluatorRightExhausted := false\n\n\t// Setup the left index/markers to start accumulating elements.\n\tleftStart := 0\n\tleftEnd := index\n\tleftNode := node\n\tleftIndex := leftEnd - 1\n\t// If the exact match is at the beginning of a leaf, then the elements\n\t// to the left are in 'prev' leaf. Adjust for that.\n\tif index == 0 {\n\t\tleftNode, err = bpt.fetch(node.PrevKey)\n\t\tif leftNode != nil {\n\t\t\tleftEnd = len(leftNode.Children)\n\t\t\tleftIndex = len(leftNode.Children) - 1\n\t\t} else if err != nil {\n\t\t\tglog.Errorf(\"failed to fetch key %v (err: %v)\", node.PrevKey, err)\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Setup right index/markers.\n\trightStart := index + 1\n\trightNode := node\n\trightIndex := index + 1\n\t// If the exact match is at the end of a leaf, then the elements\n\t// to the right are in 'next' leaf. Adjust for that.\n\tif index == len(node.Children)-1 {\n\t\trightNode, err = bpt.fetch(node.NextKey)\n\t\tif rightNode != nil {\n\t\t\trightStart = 0\n\t\t\trightIndex = 0\n\t\t} else if err != nil {\n\t\t\tglog.Errorf(\"failed to fetch key %v (err: %v)\", node.NextKey, err)\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// If we are not using the evaluator, we can accumulate in batches until\n\t// we have accumulated enough to meet the left and right width\n\tif ignoreEvaluator {\n\t\t// accumulating as many elements as needed to the left of exact match\n\t\tfor numElemsLeft > 0 && leftNode != nil {\n\t\t\tif leftEnd == -1 {\n\t\t\t\tleftEnd = len(leftNode.Children)\n\t\t\t}\n\t\t\tif (leftEnd - leftStart) < numElemsLeft {\n\t\t\t\tresult = append(bpt.accumulate(leftNode, leftStart, leftEnd),\n\t\t\t\t\tresult...)\n\t\t\t\tnumElemsLeft -= leftEnd - leftStart\n\t\t\t\tleftEnd = -1 // We need to reset it.\n\t\t\t\tleftNode, err = bpt.fetch(leftNode.PrevKey)\n\t\t\t\tif leftNode == nil && err != nil {\n\t\t\t\t\tglog.Errorf(\"failed to fetch key %v (err: %v)\",\n\t\t\t\t\t\tleftNode.PrevKey, err)\n\t\t\t\t\treturn result, err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresult = append(bpt.accumulate(leftNode, leftEnd-numElemsLeft,\n\t\t\t\t\tleftEnd), result...)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t// accumulating as many elements as needed to the right of exact match\n\t\tfor numElemsRight > 0 && rightNode != nil {\n\t\t\trightEnd := len(rightNode.Children)\n\t\t\tif (rightEnd - rightStart) < numElemsRight {\n\t\t\t\tresult = append(result, bpt.accumulate(rightNode, rightStart,\n\t\t\t\t\trightEnd)...)\n\t\t\t\tnumElemsRight -= rightEnd - rightStart\n\t\t\t\trightStart = 0\n\t\t\t\trightNode, err = bpt.fetch(rightNode.NextKey)\n\t\t\t\tif rightNode == nil && err != nil {\n\t\t\t\t\tglog.Errorf(\"failed to fetch key %v (err: %v)\",\n\t\t\t\t\t\trightNode.NextKey, err)\n\t\t\t\t\treturn result, err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresult = append(result, bpt.accumulate(rightNode, rightStart,\n\t\t\t\t\trightStart+numElemsRight)...)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// Else case: If the evaluator is specified however, we need to\n\t\t// traverse linearly from the exact match to either accumulate as many\n\t\t// elements (as per the maxElems from left and/or right) or stop when\n\t\t// the evaluator stops evaluating to true even if we haven't\n\t\t// accumulated 'maxElems'.\n\n\t\t// Do it for the left side\n\t\tfor numElemsLeft > 0 && leftNode != nil {\n\t\t\telemToLeft := leftNode.Children[leftIndex]\n\t\t\tevaluatorLeftExhausted = !ss.evaluator(ss.searchKey,\n\t\t\t\telemToLeft.DataKey)\n\t\t\tif evaluatorLeftExhausted {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tresult = append([]Element{elemToLeft.Data}, result...)\n\t\t\tleftIndex--\n\t\t\tnumElemsLeft--\n\t\t\tif leftIndex < 0 && !leftNode.PrevKey.IsNil() {\n\t\t\t\tleftNode, err = bpt.fetch(leftNode.PrevKey)\n\t\t\t\tif leftNode != nil {\n\t\t\t\t\tleftIndex = len(leftNode.Children) - 1\n\t\t\t\t} else {\n\t\t\t\t\tglog.Errorf(\"failed to fetch key %v (err: %v)\",\n\t\t\t\t\t\tleftNode.PrevKey, err)\n\t\t\t\t\treturn result, err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Do it for the right side.\n\t\tfor numElemsRight > 0 && rightNode != nil {\n\t\t\telemToRight := rightNode.Children[rightIndex]\n\t\t\tevaluatorRightExhausted = !ss.evaluator(ss.searchKey,\n\t\t\t\telemToRight.DataKey)\n\t\t\tif evaluatorRightExhausted {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tresult = append(result, elemToRight.Data)\n\t\t\trightIndex++\n\t\t\tnumElemsRight--\n\t\t\tif rightIndex >= len(rightNode.Children) && !rightNode.NextKey.IsNil() {\n\t\t\t\trightNode, err = bpt.fetch(rightNode.NextKey)\n\t\t\t\tif rightNode != nil {\n\t\t\t\t\trightIndex = 0\n\t\t\t\t} else {\n\t\t\t\t\tglog.Errorf(\"failed to fetch key %v (err: %v)\",\n\t\t\t\t\t\tleftNode.PrevKey, err)\n\t\t\t\t\treturn result, err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result, nil\n}", "func (sl *List) Get(k interface{}) interface{} {\n\tn := sl.find(k)\n\tif sl.cmpFn(n.k, k) == 0 {\n\t\treturn n.v\n\t}\n\treturn nil\n}", "func (t *binarySearchTree) Search(key int) (*string, int, error) {\n\tnode, dep, err := search(t.root, key, 1)\n\tif err != nil {\n\t\treturn nil, 0, err\n\t}\n\tif node == nil {\n\t\treturn nil, 0, nil\n\t}\n\treturn &node.value, dep, nil\n}", "func (i *ItemInventory) Search(alias string, num int) *Item {\n\tif i == nil {\n\t\treturn nil\n\t}\n\n\tpass := 1\n\tfor _, c := range i.Contents {\n\t\tif strings.Contains(c.Name, alias){\n\t\t\tif pass == num {\n\t\t\t\treturn c\n\t\t\t}else{\n\t\t\t\tpass++\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (hm HashMap) findEntry(key string, l *list.List) (*hashMapEntry, *list.Element) {\n\tfor node := l.Front(); node != nil; node = node.Next() {\n\t\tentry := node.Value.(hashMapEntry)\n\t\tif entry.key == key {\n\t\t\treturn &entry, node\n\t\t}\n\t}\n\treturn nil, nil\n}", "func (n *node) find(key int) (int, bool) {\n\tidx := sort.Search(n.count, func(i int) bool {\n\t\treturn n.keys[i] >= key\n\t})\n\n\tif idx < n.count && key == n.keys[idx] {\n\t\treturn idx, true\n\t}\n\treturn idx, false\n}", "func (t *Tree) Get(key string) interface{} {\n tree := t.find(key)\n if tree == nil {\n return nil\n }\n return tree.value\n}", "func (n *NodeManager) GetByKey(nodekey string) (OsqueryNode, error) {\n\tvar node OsqueryNode\n\tif err := n.DB.Where(\"node_key = ?\", strings.ToLower(nodekey)).First(&node).Error; err != nil {\n\t\treturn node, err\n\t}\n\treturn node, nil\n}", "func (c *LRU) Containkey(key interface{}) (ok bool) {\n\t_, ok = c.items[key]\n\treturn ok\n}" ]
[ "0.6915992", "0.682426", "0.67780536", "0.6669392", "0.65178764", "0.6517613", "0.64264435", "0.6406645", "0.6319205", "0.63091713", "0.62814724", "0.62469506", "0.6210012", "0.61996335", "0.6088753", "0.60856813", "0.60808617", "0.6080386", "0.6076286", "0.60488224", "0.60426724", "0.60368943", "0.6031761", "0.6011881", "0.59954447", "0.59874", "0.5987157", "0.5981436", "0.59809446", "0.5974271", "0.59737796", "0.5954514", "0.5945749", "0.5942097", "0.591415", "0.5913793", "0.59085083", "0.5904418", "0.59041137", "0.5900234", "0.58869195", "0.5885966", "0.5875288", "0.5872497", "0.58566105", "0.58560413", "0.58527476", "0.58511084", "0.5849109", "0.5832098", "0.5831999", "0.5812823", "0.580608", "0.57956517", "0.5778807", "0.5759462", "0.574808", "0.5726836", "0.57226866", "0.57207584", "0.5719358", "0.5719005", "0.57175905", "0.5707957", "0.5707712", "0.5701021", "0.56884", "0.56844485", "0.5680671", "0.5673128", "0.5672683", "0.56712234", "0.56709594", "0.56707174", "0.5664092", "0.5650228", "0.56498355", "0.5645543", "0.5640307", "0.56250256", "0.5614993", "0.561133", "0.56089187", "0.5607948", "0.5605882", "0.5600759", "0.5593256", "0.5588291", "0.55823106", "0.5581971", "0.55815583", "0.5568469", "0.55647767", "0.556288", "0.5555912", "0.55551994", "0.5553688", "0.554979", "0.55460894", "0.5535236" ]
0.67521054
3
Remove removes the provided key from the cache.
func (c *TimeoutCache) Remove(key interface{}) { c.lock.Lock() defer c.lock.Unlock() if ele := c.searchElement(key); ele != nil { c.removeElement(ele) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Cache) Remove(key string) {\n\tc.Lock()\n\tdelete(c.data, key)\n\tc.Unlock()\n}", "func (c *Cache) Remove(ctx context.Context, key string) error {\n\treturn c.rdb.Do(ctx, \"del\", key).Err()\n}", "func (c *Cache) Remove(key string) {\n\tc.mu.Lock()\n\tdelete(c.backend, key)\n\tc.mu.Unlock()\n}", "func (mc *MemCache) Remove(key string) {\n\tmc.c.Delete(key)\n}", "func (c *Cache) Remove(key string) {\n\tc.Lock.Lock()\n\tdelete(c.Map, key)\n\tc.Lock.Unlock()\n}", "func (c *Cache) Remove(key string) error {\n c.cacheMutex.Lock()\n defer c.cacheMutex.Unlock()\n\n if !cache.isValid {\n return errors.New(\"The cache is now invalid.\")}\n\n delete(c.cache, key)\n\n return nil\n}", "func (rc *ResourceCacheMap) Remove(key object.ObjMetadata) {\n\tdelete(rc.cache, key)\n}", "func (c *LRUExpireCache) Remove(key interface{}) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\tc.cache.Remove(key)\n}", "func (c *Cache) Remove(key Key) {\r\n\tc.Lock()\r\n\tdefer c.Unlock()\r\n\r\n\tif c.cache == nil {\r\n\t\treturn\r\n\t}\r\n\tif ele, hit := c.cache[key]; hit {\r\n\t\tc.removeElement(ele)\r\n\t} else {\r\n\t\tswitch key.(type) {\r\n\t\tcase string:\r\n\t\t\tre := regexp.MustCompile(key.(string))\r\n\t\t\tfor k, v := range c.cache {\r\n\t\t\t\tif re.MatchString(k.(string)) {\r\n\t\t\t\t\tc.removeElement(v)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}", "func (c *LRUCache) Remove(key string) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tc.cache.Remove(key)\n}", "func (c *BlockCache) Remove(key string) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tkey = strings.ToLower(key)\n\tdelete(c.m, key)\n}", "func (c *Cache) Remove(key Key) {\n\tif el, hit := c.cache[key]; hit {\n\t\tc.remove(el)\n\t\treturn\n\t}\n\treturn\n}", "func (c *Cache) Remove(key lru.Key) {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tc.cache.Remove(key)\n}", "func (c *Cache) Remove(key Key) {\n\tif c.cache == nil {\n\t\treturn\n\t}\n\tif ele, hit := c.cache[key]; hit {\n\t\tc.removeElement(ele)\n\t}\n}", "func (l *LRU) Remove(key interface{}) {\n\tl.shard(key).removeKey(key)\n}", "func (d *Dispatcher) Remove(key []byte) {\n\tlru := d.getLRU(key)\n\tlru.Lock()\n\tdefer lru.Unlock()\n\tlru.Remove(util.ByteSliceToString(key))\n}", "func (m *ViewModelCache) Remove(key string) {\n\t// Try to get shard.\n\tshard := m.GetShard(key)\n\tshard.Lock()\n\tdefer shard.Unlock()\n\tdelete(shard.items, key)\n}", "func (c *memoryCache) Del(key string) {\n\tdelete(c.data, key)\n}", "func Del(key string) {\n\tdelete(cacher, key)\n}", "func (c *ETCDCache) Remove(key string) (err error) {\n\tlogger := log.WithFields(log.Fields{\"class\": \"ETCDCache\", \"method\": \"Remove\"})\n\tkapi := client.NewKeysAPI(c.client)\n\t_, err = kapi.Delete(context.Background(), c.prefix+\"/\"+key, nil)\n\n\tif _, ok := err.(*client.ClusterError); ok {\n\t\terr = ErrStorageConnectionFailed\n\t\tlogger.Errorf(\"%v\", err.Error())\n\t}\n\n\treturn\n}", "func (c *Cache) Remove(cacheKey string) {\n\tlog.Debug(\"redis cache remove\", log.Pairs{\"key\": cacheKey})\n\tc.client.Del(cacheKey)\n\tcache.ObserveCacheDel(c.Name, c.Config.CacheType, 0)\n}", "func (lc *lfuCache) Remove(key string) (removedValue interface{}) {\n\tlc.lock.Lock()\n\tdefer lc.lock.Unlock()\n\n\treturn lc.remove(key)\n}", "func (tsm *ThreadSafeMap) Remove(key string) {\n\ttsm.Lock()\n\tdefer tsm.Unlock()\n\n\tdelete(tsm.items, key)\n}", "func (lc *LocalCache) Remove(key interface{}) (value interface{}, hit bool) {\n\tlc.Lock()\n\tvalueData, ok := lc.Data[key]\n\tif ok {\n\t\tdelete(lc.Data, key)\n\t\tlc.LRU.Remove(key)\n\t}\n\tlc.Unlock()\n\tif !ok {\n\t\treturn\n\t}\n\n\tvalue = valueData.Value\n\thit = true\n\n\tif valueData.OnRemove != nil {\n\t\tvalueData.OnRemove(key, Removed)\n\t}\n\treturn\n}", "func (ms *MemStore) Remove(key string) error {\n\tms.mu.Lock()\n\t_, ok := ms.data[key]\n\tif !ok {\n\t\tms.mu.Unlock()\n\t\treturn ErrUnknownKey\n\t}\n\tdelete(ms.data, key)\n\tms.mu.Unlock()\n\treturn nil\n}", "func (c cache) Delete(key string) {\n\tc.Delete(c.key(key))\n}", "func (c *LRU) Remove(key interface{}) interface{} {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif ele, found := c.cache[key]; found {\n\t\t_, value := c.remove(ele)\n\t\treturn value\n\t}\n\treturn nil\n}", "func (c *Cache) Del(key string) error {\n\tc.gc.Delete(key)\n\treturn nil\n}", "func (c *layerCache) Remove(key interface{}) (err error) {\n\terr = c.Storage.Remove(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif c.next == nil {\n\t\t// This is bottom layer\n\t\treturn nil\n\t}\n\t// Queue to flush\n\tc.log <- log{key, &Message{Value: nil, Message: MessageRemove}}\n\tc.Sync() // Remove must be synced\n\treturn nil\n}", "func (m ConcurrentMap[T]) Remove(key string) {\n\tshard := m.getShard(key)\n\tshard.Lock()\n\tdelete(shard.items, key)\n\tshard.Unlock()\n}", "func (st *Store) Remove(key []byte) {\n\tst.store.Delete(key)\n}", "func (this *GoCache) Delete(key string) {\n\tthis.Cache.Delete(key)\n\n}", "func (c *RedisCache) Del(ctx context.Context, key string) error {\n\treturn c.client.Del(ctx, key).Err()\n}", "func (kv *LevelDBKV) Remove(key string) error {\n\treturn errors.WithStack(kv.Delete([]byte(key), nil))\n}", "func (ds *DataStore) Remove(key uint64) error {\n\tds.dataStoreLock.Lock()\n\tdefer ds.dataStoreLock.Unlock()\n\tif _, present := ds.kvSet[key]; !present {\n\t\treturn fmt.Errorf(\"Key %d not present\", key)\n\t}\n\tdelete(ds.kvTime, key)\n\tdelete(ds.kvSet, key)\n\treturn nil\n}", "func (c *LruCache) Remove(key interface{}) bool {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\tif ent, ok := c.cache[key]; ok {\n\t\tc.removeElement(ent)\n\t\treturn true\n\t}\n\treturn false\n}", "func (m BoolMemConcurrentMap) Remove(key string) {\n\t// Try to get shard.\n\tshard := m.getShard(key)\n\tshard.Lock()\n\tdelete(shard.items, key)\n\tshard.Unlock()\n}", "func (m *ConcurrentMap) Remove(key string) {\n\t// Try to get shard.\n\tshard := m.GetShard(key)\n\tshard.Lock()\n\tdelete(shard.items, key)\n\tshard.Unlock()\n}", "func (ttlmap *TTLMap) Remove(key interface{}) {\n\tttlmap.eMutex.Lock()\n\tdefer ttlmap.eMutex.Unlock()\n\tdelete(ttlmap.entries, key)\n\n\t// remember to clean up the schedule\n\tttlmap.clearSchedule(key)\n}", "func (pc *PrioCache) Remove(key interface{}) *PrioEntry {\n\tpc.lock.Lock()\n\tdefer pc.lock.Unlock()\n\tif ent, ok := pc.m[key]; ok {\n\t\tdelete(pc.m, key)\n\t\theap.Remove(&pc.s, ent.index)\n\t\treturn &ent.PrioEntry\n\t}\n\treturn nil\n}", "func (hm *HashMap) Remove(key string) {\n\tl := hm.findList(key)\n\t_, node := hm.findEntry(key, l)\n\tif node != nil {\n\t\tl.Remove(node)\n\t\thm.len--\n\t}\n}", "func (m *MockCache) Del(key string) error {\n\treturn nil\n}", "func (s *RedisStore) Remove(key string) error {\n\treturn s.Client.Del(key).Err()\n}", "func (c *Cache) Remove(key interface{}) bool {\n\tif entry, ok := c.mapping[key]; ok {\n\t\tc.removeElement(entry)\n\t\treturn true\n\t}\n\treturn false\n}", "func (s Set) Remove(key string) {\n\tdelete(s, key)\n}", "func (c *cache) Del(key string) error {\n\terr := c.cacheConn.Del(key).Err()\n\tif err != nil {\n\t\tlogger.Log().Error(\"Error while deleting key\", zap.String(\"key\", key), zap.Error(err))\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *MapCache) Delete(key interface{}) {\n\tdelete(c.entries, key)\n}", "func (c *Cache) Remove(key string) (interface{}, bool) {\n\tv, ok := c.data[key]\n\n\tif !ok {\n\t\treturn nil, false\n\t}\n\n\titem := v.Value.(*cacheItem)\n\n\tc.lists[item.lidx].Remove(v)\n\n\tdelete(c.data, key)\n\n\treturn item.value, true\n}", "func (m ConcurrentMap[K, V]) Remove(key K) {\n\t// Try to get shard.\n\tshard := m.GetShard(key)\n\tshard.Lock()\n\tdelete(shard.items, key)\n\tshard.Unlock()\n}", "func (lru *KeyLRU) Remove(key interface{}) interface{} {\n\tif ele, ok := lru.m[key]; ok {\n\t\tv := lru.ll.Remove(ele)\n\t\tdelete(lru.m, key)\n\t\treturn v\n\t}\n\treturn nil\n}", "func (g *GCache) Del(key string) error {\n\tg.db.Remove(key)\n\treturn nil\n}", "func (lru *LRUMap) Remove(key int) {\n\tif node, ok := lru.dict[key]; ok {\n\t\tlru.removeFromQueue(node)\n\t\tdelete(lru.dict, key)\n\t\tlru.len--\n\t}\n}", "func Delete(key string) (err error) {\n\treturn DefaultCache.Delete(key)\n}", "func (c *Cache) Delete(key string) {\n\tif element, ok := c.cache[key]; ok {\n\t\tkv := element.Value.(*entry)\n\t\tc.l.Remove(element)\n\t\tdelete(c.cache, kv.key)\n\t\treturn\n\t}\n\treturn\n}", "func (c *etcdCache) Delete(key string) {\n c.Lock()\n defer c.Unlock()\n delete(c.props, key)\n}", "func (r Repository) Remove(ctx context.Context, key string) error {\n\treturn r.client.Del(key).Err()\n}", "func (fs *FileStore) Remove(key string) error {\n\tkey = fs.mangleKey(key, false)\n\tif os.IsNotExist((os.Remove(filepath.Join(fs.baseDir, key)))) {\n\t\treturn ErrUnknownKey\n\t}\n\treturn nil\n}", "func (this *MyHashMap) Remove(key int) {\n\tthis.v[key] = -1\n}", "func (cc CollectionCache) removeByKey(key interface{}) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tlog.Println(\"Panic Recovered at dbServices.collectionCache.removeByKey(): \", r)\n\t\t\treturn\n\t\t}\n\t}()\n\n\t_, ok := collectionCache.Load(key)\n\tif ok {\n\t\tcollectionCache.Delete(key)\n\t\tcount := collectionCacheCount.Get()\n\t\tcount--\n\t\tcollectionCacheCount.Set(count)\n\t}\n}", "func (mmap *stateSyncMap) remove(key string) error {\n\treturn mmap.Remove(key)\n}", "func (c *Cache) Delete(key string) {\n\tif el, hit := c.cacheByKey[key]; hit {\n\t\tc.delete(el)\n\t}\n}", "func (c *Cache) Delete(key interface{}) error {\n\tc.Lock()\n\n\tif _, found := c.items[key]; !found {\n\t\tc.Unlock()\n\t\treturn errNotFound\n\t}\n\n\tdelete(c.items, key)\n\n\tc.Unlock()\n\n\treturn nil\n}", "func (hm *HashMap) Remove(key []byte) error {\n\t// validate hashKey\n\terr := hm.np.validateKey(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\t//1. calculate the hash num\n\thashNum := hm.hashFunc(key) % uint64(hm.haSize)\n\n\t//2. remove key from hashNode\n\thead := hm.ha[hashNum]\n\tif head == -1 {\n\t\treturn nil\n\t}\n\tnewHead := hm.np.del(head, key)\n\n\t//3. point to the new list head node\n\thm.ha[hashNum] = newHead\n\n\treturn nil\n}", "func (m *cidsMap) Remove(key string) {\n\tm.mu.Lock()\n\tdefer m.mu.Unlock()\n\tif cid, exist := m.cids[key]; exist {\n\t\tdelete(m.reverse, cid)\n\t\tdelete(m.cids, key)\n\t}\n}", "func (s *Storage)Remove(key interface{}) {\n s.data.Delete(key)\n atomic.AddUint32(&s.total,uint32(int32(1)))\n}", "func (tb *tableManager) remove(keyIn uint64) error {\n\tkey, ok := CleanKey(keyIn)\n\tif !ok {\n\t\tlog.Println(\"Key out of range.\")\n\t\treturn errors.New(\"Key out of range.\")\n\t}\n\tentry, ok := tb.data[key]\n\tif !ok {\n\t\tlog.Println(\"Key not found in table.\")\n\t\treturn errors.New(\"Key not found in table.\")\n\t}\n\n\ttb.removeFromLRUCache(entry)\n\tdelete(tb.data, key)\n\treturn nil\n}", "func (c *Cache) Delete(key string) (err error) {\n\tc.mutex.Lock()\n\t_, err = c.repo.Delete(key)\n\tc.mutex.Unlock()\n\tif err != nil {\n\t\treturn\n\t}\n\treturn\n}", "func (p *ClockPolicy) Remove(key CacheKey) {\n\tnode, ok := p.keyNode[key]\n\tif !ok {\n\t\treturn\n\t}\n\n\tif p.clockHand == node {\n\t\tp.clockHand = p.clockHand.Prev()\n\t}\n\tp.list.Remove(node)\n\tdelete(p.keyNode, key)\n}", "func (i StringHashMap[T, V]) Remove(key T) {\n\thash := key.Hash()\n\tdelete(i.hashToKey, hash)\n\tdelete(i.hashToVal, hash)\n}", "func (c *StringValueMap) Remove(key string) {\n\tdelete(c.value, key)\n}", "func (cache *Cache) Delete(key string) error {\n\n\tconn := cache.Pool.Get()\n\tdefer conn.Close()\n\n\t_, err := conn.Do(\"DEL\", key)\n\treturn err\n}", "func (t *TrieNode) Remove(key string, value int64) {\n\tt.mx.Lock()\n\tdefer t.mx.Unlock()\n\trunes := []rune(key)\n\tt.remove(runes, value)\n}", "func (c *Cache) Delete(key string) error {\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tif _, found := c.items[key]; !found {\n\t\treturn fmt.Errorf(\"Key %s not found\", key)\n\t}\n\n\tdelete(c.items, key)\n\treturn nil\n}", "func (ht *ValueHashtable) Remove(k [HashSize]byte) {\r\n\tht.lock.Lock()\r\n\tdefer ht.lock.Unlock()\r\n\tdelete(ht.items, k)\r\n}", "func (j *Cache) Delete(key string) error {\n\treturn j.client.Delete(key)\n}", "func (mm Uint64Uint64Map) Remove(k uint64) {\n\tdelete(mm, k)\n}", "func (s *Session) Remove(key string) {\n\ts.removed = append(s.removed, key)\n\tdelete(s.values, key)\n}", "func (s *CacheServer) Delete(ctx context.Context, args *pb.GetKey) (*pb.Success, error) {\n\tkey := args.Key\n\terr := cache.Delete(key)\n\tif err != nil {\n\t\treturn &pb.Success{\n\t\t\tSuccess: false,\n\t\t}, err\n\t}\n\tlog.Printf(\"delete item with key: %v\", key)\n\treturn &pb.Success{\n\t\tSuccess: true,\n\t}, nil\n}", "func (u *UdMap) Del(key string) { delete(u.Data, key) }", "func (c Collector) Remove(k string) {\n\tif c.Has(k) {\n\t\tdelete(c, k)\n\t}\n}", "func (m *Map) Remove(key string) {\n\tif l, ok := m.keys[key]; ok {\n\t\tfor _, n := range l {\n\t\t\tm.nodes.Delete(n)\n\t\t}\n\t\tdelete(m.keys, key)\n\t}\n}", "func (scp *ConfigCache) Delete(key string) {\n\tscp.cache.Remove(key)\n}", "func (fc *fileCache) Delete(key string) {\n\tfc.cache.Delete(key)\n\tfc.dirty = true\n}", "func (m *ttlMap) Remove(key interface{}) (Item, bool) {\n\top := &opRemove{\n\t\tkey: key,\n\t\tchanResponse: make(chan *opFetchResult, 1),\n\t}\n\tgo func() {\n\t\tm.processOnce()\n\t\tm.chanOp <- op\n\t}()\n\tr := <-op.chanResponse\n\treturn r.item, r.existed\n}", "func (i IntHashMap[T, V]) Remove(key T) {\n\thash := key.Hash()\n\tdelete(i.hashToKey, hash)\n\tdelete(i.hashToVal, hash)\n}", "func (m *OrderedMap) Remove(key, val string) {\n\tm.Lock()\n\tdefer m.Unlock()\n\tm.remove(key, val)\n}", "func (c MemoryCache) Delete(key string) error {\n\tdelete(c, key)\n\treturn nil\n}", "func (k *MutableKey) Remove(val uint64) {\n\tdelete(k.vals, val)\n\tk.synced = false\n}", "func (r *RedisCache) Delete(key string) (err error) {\n\tif _, err = r.do(\"DEL\", r.key(key)); err != nil {\n\t\treturn\n\t}\n\tif r.occupyMode {\n\t\treturn\n\t}\n\n\t_, err = r.do(\"HDEL\", r.key(GC_HASH_KEY), r.key(key))\n\treturn\n}", "func Remove(ctx context.Context, db *sql.DB, key []byte) error {\n\tctx, cancel := context.WithDeadline(ctx, time.Now().Add(3*time.Second))\n\tdefer cancel()\n\tquery := \"DELETE FROM keys WHERE key=?\"\n\t_, err := db.ExecContext(ctx, query, string(key))\n\tif err != nil {\n\t\treturn errors.Errorf(\"could not delete key=%q: %w\", string(key), err).WithField(\"query\", query)\n\t}\n\n\treturn nil\n}", "func (m NMap) Remove(key uint32) {\n\tinterMap := m.getInternalNMap(key)\n\tinterMap.Lock()\n\tdelete(interMap.objs, key)\n\tinterMap.Unlock()\n}", "func (p *RefCache) Delete(key string) {\n\tp.mu.RLock()\n\titem := p.items[key]\n\tp.mu.RUnlock()\n\tif item == nil {\n\t\treturn\n\t}\n\tp.mu.Lock()\n\titem = p.items[key]\n\tdelete(p.items, key)\n\tp.mu.Unlock()\n\tif item == nil {\n\t\treturn\n\t}\n\titem.closer()\n}", "func (that *StrAnyMap) Remove(key string) (value interface{}) {\n\tthat.mu.Lock()\n\tif that.data != nil {\n\t\tvar ok bool\n\t\tif value, ok = that.data[key]; ok {\n\t\t\tdelete(that.data, key)\n\t\t}\n\t}\n\tthat.mu.Unlock()\n\treturn\n}", "func (s *Session) Remove(key *Key) (err error) {\n\tatomic.AddUint64(&cDeletes, 1)\n\n\tvar cflags C.uint64_t\n\tvar ioflags C.uint64_t\n\terr = Error(C.dnet_remove_object_now(s.session, &key.id, cflags, ioflags))\n\treturn\n}", "func (c *Cache) Delete(key string) {\r\n\tdelete(c.MagicKeys, key)\r\n}", "func (lc *LruCache) lruRemove(key string) error {\n\tlc.Logger.Debug(\"LruStore is evicting \", key)\n\treturn lc.LruStore.Remove(key)\n}", "func (c *Cache) Delete(key string) error {\n\tv, err := c.client.Do(\"DEL\", key)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif v.(int64) != 1 {\n\t\terrors.NewNotFound(key)\n\t}\n\n\treturn nil\n}", "func (rc *Cache) Delete(command string, key ...interface{}) error {\n\tvar err error\n\tif _, err = rc.do(command, key...); err != nil {\n\t\treturn err\n\t}\n\treturn err\n}", "func (this *MyHashMap) Remove(key int) {\n\thashCode := key % 1111\n\ttemp := &Node{\n\t\t0,\n\t\t0,\n\t\tthis.buckets[hashCode],\n\t}\n\tpre := temp\n\tcur := temp.Next\n\tfor cur != nil {\n\t\tif cur.K == key {\n\t\t\tpre.Next = cur.Next\n\t\t\tbreak\n\t\t}\n\t\tpre, cur = cur, cur.Next\n\t}\n\tthis.buckets[hashCode] = temp.Next\n}", "func (sm sharedMap) Remove(k string) {\n\tsm.c <- command{action: remove, key: k}\n}" ]
[ "0.822", "0.8102971", "0.801383", "0.7985025", "0.79449236", "0.7943648", "0.7913574", "0.77698255", "0.77670026", "0.77565044", "0.77431804", "0.77037156", "0.76926464", "0.76572436", "0.7602669", "0.75644475", "0.7478781", "0.74458176", "0.74336135", "0.74051994", "0.7380754", "0.7344683", "0.7312646", "0.72881794", "0.72522604", "0.7227991", "0.72033125", "0.7198271", "0.7185759", "0.7168021", "0.7082212", "0.70782274", "0.7077803", "0.7064429", "0.70609325", "0.70473456", "0.70421004", "0.70087004", "0.69914526", "0.69481146", "0.69414586", "0.69385153", "0.69315404", "0.69220287", "0.6908535", "0.69023806", "0.68597746", "0.6843481", "0.68338406", "0.68184924", "0.68180454", "0.6809336", "0.680708", "0.6800961", "0.67974794", "0.6793334", "0.67774713", "0.6773714", "0.676221", "0.67519796", "0.6751805", "0.6734654", "0.67133665", "0.6710599", "0.6706466", "0.670292", "0.66960275", "0.66816896", "0.6675469", "0.666795", "0.66615427", "0.662054", "0.6610204", "0.6609423", "0.6605546", "0.66029274", "0.66005844", "0.6599938", "0.6573265", "0.6569739", "0.65673083", "0.6564391", "0.6564086", "0.6563968", "0.655752", "0.6554239", "0.6552465", "0.6552244", "0.65506095", "0.6548851", "0.6546945", "0.654295", "0.65312064", "0.6529242", "0.65247184", "0.65180457", "0.65066767", "0.6494204", "0.6493912", "0.64841884" ]
0.76683784
13
Len returns the number of items in the cache.
func (c *TimeoutCache) Len() int { c.lock.RLock() defer c.lock.RUnlock() return c.evictList.Len() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Cache) Len() int {\n\tc.mutex.RLock()\n\tdefer c.mutex.RUnlock()\n\n\treturn len(c.items)\n}", "func (c *Cache) Len() int {\n\tif c == nil {\n\t\treturn 0\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\treturn c.lru.Len() + c.mfa.Len()\n}", "func (c *Cache) Len() int {\n\treturn len(c.entries)\n}", "func (c *Cache) Len() int {\n\treturn c.cache.Len()\n}", "func (c *Cache) Len() int {\r\n\tc.Lock()\r\n\tdefer c.Unlock()\r\n\r\n\tif c.cache == nil {\r\n\t\treturn 0\r\n\t}\r\n\treturn c.ll.Len()\r\n}", "func (c *NoReplKeyCache) Len() int {\n\tc.lock.RLock()\n\tlength := len(c.cache)\n\tc.lock.RUnlock()\n\treturn length\n}", "func (c *Cache) Len() int {\n\tif c.cache == nil {\n\t\treturn 0\n\t}\n\treturn c.ll.Len()\n}", "func (c *Cache) Len() int {\n\treturn c.ll.Len()\n}", "func (c *Cache) Len() int {\n\treturn len(c.data)\n}", "func (tc *TimedCache) Len() int {\n\ttc.mu.RLock()\n\tl := len(tc.items)\n\ttc.mu.RUnlock()\n\treturn l\n}", "func (c *UnlimitedCache) Len() int {\n\treturn len(c.m)\n}", "func (c *Cache) Len() int {\n\treturn len(c.keyMap)\n}", "func (c *Cache) len() int {\n\tc.lock.RLock()\n\tdefer c.lock.RUnlock()\n\treturn c.evictList.Len()\n}", "func (lc *LruCache) Len() uint {\n\treturn lc.LruStore.Len()\n}", "func (c *LruCache) Len() int {\n\tc.lock.RLock()\n\tdefer c.lock.RUnlock()\n\treturn c.evictList.Len()\n}", "func (hc *HybridCache) Len() int64 {\n\treturn hc.mc.Len() + hc.dc.Len()\n}", "func (c *Cache) Len() int {\n\tn := 0\n\tfor _, shard := range c.shards {\n\t\tn += shard.Len()\n\t}\n\treturn n\n}", "func (c *Cache) Length(k string) int {\n\treturn len(c.entries[k])\n}", "func (c *Cache) Len() int {\n\tvar len int\n\tfor _, shard := range c.shards {\n\t\tlen += shard.policy.Len()\n\t}\n\n\treturn len\n}", "func (db *MemoryCache) Len() int {\n\tdb.lock.RLock()\n\tdefer db.lock.RUnlock()\n\n\treturn len(db.db)\n}", "func (pc *PrioCache) Len() int {\n\tpc.lock.Lock()\n\tdefer pc.lock.Unlock()\n\treturn len(pc.s)\n}", "func (c *Cache) Len() int32 {\n\tl := 0\n\tfor i := 0; i < shardCount; i++ {\n\t\tshard := c.data[i]\n\t\tshard.Lock()\n\t\tl += len(shard.items)\n\t\tshard.Unlock()\n\t}\n\treturn int32(l)\n}", "func (r *RowCache) Len() int {\n\tr.mutex.Lock()\n\tdefer r.mutex.Unlock()\n\treturn len(r.cache)\n}", "func (c *Cache) Size() int {\n\treturn len(c.data)\n}", "func (c *Cache) Size() int {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\treturn len(c.data)\n}", "func (c *BlockCache) Length() int {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\n\treturn len(c.m)\n}", "func (c *Cache) Size() uint64 {\n\tvar size uint64 = 0\n\tfor _, v := range c._cache {\n\t\tsize += v.GetSize()\n\t}\n\treturn size\n}", "func (lru *KeyLRU) Len() int {\n\treturn len(lru.m)\n}", "func (c *LRU) Len() int {\n\treturn c.evictList.Len()\n}", "func (c *LRU) Len() int {\n\tc.RLock()\n\tresult := c.evictList.Len()\n\tc.RUnlock()\n\treturn result\n}", "func (c *LRU) Len() int {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\treturn c.ll.Len()\n}", "func (fi *FastIntegerHashMap) Len() uint64 {\n\treturn fi.count\n}", "func (lc *lfuCache) Size() (size int) {\n\tlc.lock.RLock()\n\tdefer lc.lock.RUnlock()\n\n\treturn lc.size()\n}", "func (storage *Storage) Len() (n int) {\n\tstorage.mutex.Lock()\n\tn = storage.lruList.Len()\n\tstorage.mutex.Unlock()\n\treturn\n}", "func (c *TwoQueueCache[K, V]) Len() int {\n\tc.lock.RLock()\n\tdefer c.lock.RUnlock()\n\treturn c.recent.Len() + c.frequent.Len()\n}", "func (lru *LRU) Len() int {\n\treturn lru.list.Len()\n}", "func (r *Redis) Len() (int, error) {\n\treturn r.store.SetCard(redisLruKeyCacheKey)\n}", "func (s *Store) Len(ctx context.Context) (int64, error) {\n\tvar nb int64\n\tif err := s.List(ctx, \"\", func(string) error {\n\t\tnb++\n\t\treturn nil\n\t}); err != nil {\n\t\treturn 0, err\n\t}\n\treturn nb, nil\n}", "func (l *LRU) Len() int {\n\tl.lazyInit()\n\tvar len int\n\tfor i := 0; i < l.nshards; i++ {\n\t\tlen += l.shards[i].Len()\n\t}\n\treturn len\n}", "func (c *Cache) Size() (n int) {\n\terr := c.DB.Model(&quandl.Record{}).Count(&n).Error\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}", "func (c *Cache) Size() int {\n\tc.mu.RLock()\n\tdefer c.mu.RUnlock()\n\n\treturn len(c.order)\n}", "func (hm HashMap) Len(ctx context.Context) (int64, error) {\n\treq := newRequest(\"*2\\r\\n$4\\r\\nHLEN\\r\\n$\")\n\treq.addString(hm.name)\n\treturn hm.c.cmdInt(ctx, req)\n}", "func (m *Map) Len() int {\n\tm.store.RLock()\n\tdefer m.store.RUnlock()\n\tn := len(m.store.kv)\n\treturn n\n}", "func (c *Cache) Size() int64 {\n\treturn c.size\n}", "func (uc *UserCache) Size() int {\n\treturn len(uc.cache)\n}", "func (this *List) Len() int {\n this.lock.RLock()\n this.lock.RUnlock()\n\n return len(this.counters)\n}", "func (c *ExpireCache) Size() int64 {\n\tdefer c.mutex.Unlock()\n\tc.mutex.Lock()\n\treturn int64(len(c.cache))\n}", "func (c *Cache) Size() (size int, err error) {\n\treturn c.adapter.Size(c.getCtx())\n}", "func LLEN() int {\n\treturn globalListCache.countKeys()\n}", "func (sc *Scavenger) Len() int {\n\tsc.mu.Lock()\n\tn := len(sc.entries)\n\tsc.mu.Unlock()\n\treturn n\n}", "func (c *globalServiceCache) size() (num int) {\n\tc.mutex.RLock()\n\tnum = len(c.byName)\n\tc.mutex.RUnlock()\n\treturn\n}", "func Size() (int, error) {\n\treturn defaultCache.Size()\n}", "func (c *MQCache) Len() (totalLen int64, queuesLen []int64) {\n\tc.lock.Lock()\n\tdefer c.lock.Unlock()\n\tfor i := 0; i < c.queues; i++ {\n\t\tc.queuesLen[i] = c.q[i].len()\n\t\ttotalLen += c.queuesLen[i]\n\t}\n\treturn totalLen, c.queuesLen\n}", "func (s *Int64Map) Len() int {\n\treturn int(atomic.LoadInt64(&s.length))\n}", "func (m *HashMap) Len() int {\n\tm.lock.RLock()\n\tdefer m.lock.RUnlock()\n\treturn len(m.data)\n}", "func (ac *AddressCache) Length() (numAddrs, numTxns, numUTXOs int) {\n\tac.mtx.RLock()\n\tdefer ac.mtx.RUnlock()\n\treturn ac.length()\n}", "func (c *Cache) GetCount() int {\n\treturn len(c.items)\n}", "func (a ByKey) Len() int {\n\treturn len(a)\n}", "func (this *LruMap) Len() (size int) {\n\treturn this.m.Len()\n}", "func (s *Store) Len() int {\n\ts.access.RLock()\n\tdefer s.access.RUnlock()\n\n\treturn len(s.data)\n}", "func (counter *Counter) Len() int {\n\tcounter.mutex.Lock()\n\tdefer counter.mutex.Unlock()\n\treturn len(counter.entries)\n}", "func (m *Map) Len() int {\n\tm.RLock()\n\tl := len(m.Items)\n\tm.RUnlock()\n\treturn l\n}", "func (mc *MemCache) Size() int {\n\n\treturn mc.c.ItemCount()\n}", "func (r *Redis) Size() (int64, error) {\n\tlenght, err := r.Len()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif lenght == 0 {\n\t\treturn 0, nil\n\t}\n\n\tvar itemIDs []string\n\tif err := r.store.ScoredSetRange(context.Background(), redisLruKeyCacheKey, 0, -1, &itemIDs); err != nil {\n\t\treturn 0, err\n\t}\n\n\t// DB Request\n\treturn item.ComputeSizeByIDs(r.db, itemIDs)\n}", "func (this *Hash) Len() int {\n\tif this == nil {\n\t\treturn 0\n\t}\n\n\tif this.lock {\n\t\tthis.mu.RLock()\n\t\tn := len(this.compact.a)\n\t\tthis.mu.RUnlock()\n\t\treturn n\n\t}\n\n\treturn len(this.compact.a)\n}", "func (s cacheSettingsByName) Len() int { return len(s) }", "func (qi *Items) Len() int {\n\tqi.RLock()\n\tc := qi.Length\n\tlog.Printf(\"queue length: %d\\n\", c)\n\tqi.RUnlock()\n\treturn c\n}", "func (tcsl TabletsCacheStatusList) Len() int {\n\treturn len(tcsl)\n}", "func (m OrderedMap[K, V]) Len() int {\n\treturn len(m.items)\n}", "func (oc *ossCache) Size() int64 {\n\treturn oc.size\n}", "func (r *KeyRing) Len() int {\n\treturn len(r.entities)\n}", "func (l *List) Len() int {\n return l.size\n}", "func (s *Pool) Len() int { return int(atomic.LoadUint32(&s.avail)) }", "func (blt Bolt) Length() int {\n\tvar len int\n\tblt.db.View(func(tx *b.Tx) error { //nolint:errcheck\n\t\tlen = tx.Bucket(blt.Bucket).Stats().KeyN\n\t\treturn nil\n\t})\n\treturn len\n}", "func (h CRConfigHistoryThreadsafe) Len() uint64 {\n\tif h.length == nil {\n\t\treturn 0\n\t}\n\treturn *h.length\n}", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (a ByKey) Len() int { return len(a) }", "func (m *Map[K, V]) Len() int {\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\n\treturn len(m.inner)\n}", "func (obj object) Len() int {\n\treturn len(obj.keys)\n}", "func (cache *Cache) Count() int {\n\tcache.mutex.RLock()\n\tcount := len(cache.items)\n\tcache.mutex.RUnlock()\n\treturn count\n}", "func (mc *minioCache) Size() int64 {\n\treturn mc.size\n}" ]
[ "0.8649642", "0.8636436", "0.85773957", "0.8575803", "0.8565341", "0.8560323", "0.85048", "0.84949386", "0.84835863", "0.84353757", "0.84268105", "0.8358988", "0.83543485", "0.82246524", "0.82083863", "0.8183323", "0.8019507", "0.7983756", "0.7982027", "0.7956781", "0.79077905", "0.7904244", "0.78821915", "0.7831007", "0.7810612", "0.78025734", "0.7775949", "0.77229255", "0.7668266", "0.7666106", "0.7661562", "0.7638288", "0.7614283", "0.75948375", "0.7557886", "0.75154877", "0.7515406", "0.7515315", "0.7488077", "0.7423047", "0.73960596", "0.73923355", "0.7389847", "0.7376115", "0.73329705", "0.73260766", "0.73226094", "0.7322177", "0.7312876", "0.73061794", "0.7290427", "0.728906", "0.7287662", "0.7284939", "0.72702247", "0.72657305", "0.7250095", "0.72284645", "0.7217491", "0.72100186", "0.7208193", "0.7200415", "0.7198136", "0.71481", "0.7132061", "0.71282566", "0.7110158", "0.7106234", "0.7094255", "0.7077427", "0.7071629", "0.70708066", "0.70686877", "0.70659906", "0.70628595", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.70625865", "0.7055458", "0.7034829", "0.70308596", "0.7013035" ]
0.78357387
23
NewEnvironment creates new type environment with current analysis pass.
func NewEnvironment(pass *analysis.Pass) *Environment { return &Environment{ //TODO make it private and reject object named __val ExplicitRefinementMap: map[types.Object]types.Type{}, ImplicitRefinementMap: map[types.Object]types.Type{}, funArgRefinementMap: map[string]types.Type{}, Scope: nil, Pos: token.NoPos, Pass: pass, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewEnvironment(name string, parent *Environment) *Environment {\n\treturn &Environment{\n\t\tname: name,\n\t\tparent: parent,\n\t\tdict: make(map[string]*Symbol),\n\t}\n}", "func NewEnvironment() *Environment {\n\ts := make(map[string]Object)\n\treturn &Environment{store: s, outer: nil}\n}", "func NewEnvironment(ctx *pulumi.Context,\n\tname string, args *EnvironmentArgs, opts ...pulumi.ResourceOption) (*Environment, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.EnvironmentId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'EnvironmentId'\")\n\t}\n\tif args.InfrastructureSpec == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'InfrastructureSpec'\")\n\t}\n\tif args.LakeId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'LakeId'\")\n\t}\n\treplaceOnChanges := pulumi.ReplaceOnChanges([]string{\n\t\t\"environmentId\",\n\t\t\"lakeId\",\n\t\t\"location\",\n\t\t\"project\",\n\t})\n\topts = append(opts, replaceOnChanges)\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Environment\n\terr := ctx.RegisterResource(\"google-native:dataplex/v1:Environment\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewEnvironment() *Environment {\n\ts := make(map[string]Object)\n\treturn &Environment{store: s}\n}", "func NewEnvironment() Environment {\n\tvalues := make(map[string]interface{})\n\treturn Environment{Values: values}\n}", "func NewEnvironment(input Environment) *Environment {\n\treturn &input\n}", "func NewEnvironment() *Environment {\n\ts := make(map[string]Variable)\n\treturn &Environment{store: s, outer: nil}\n}", "func NewEnvironment() *Environment {\n\tptr := C.m3_NewEnvironment()\n\treturn &Environment{\n\t\tptr: (EnvironmentT)(ptr),\n\t}\n}", "func NewEnvironment() *Environment {\n\tptr := C.m3_NewEnvironment()\n\treturn &Environment{\n\t\tptr: (EnvironmentT)(ptr),\n\t}\n}", "func (e *Env) NewEnv() *Env {\n\treturn &Env{\n\t\tenv: make(map[string]interface{}),\n\t\tparent: e,\n\t\tbuiltin: e.builtin,\n\t\tglobal: e.global,\n\t\tfuncArg: make(map[string]interface{}),\n\t\t//importFunc: e.importFunc,\n\t\tfileInfo: e.fileInfo,\n\t}\n}", "func NewEnvironment() *Environment {\n\tvar env Environment\n\tenv = Environment{\n\t\tvars{\n\t\t\t\"+\": add,\n\t\t\t\"-\": sub,\n\t\t\t\"*\": mult,\n\t\t\t\"/\": div,\n\t\t\t\"<=\": lteq,\n\t\t\t\"equal?\": eq,\n\t\t\t\"not\": not,\n\t\t\t\"and\": and,\n\t\t\t\"or\": or,\n\t\t\t\"cons\": construct,\n\t\t\t\"car\": head,\n\t\t\t\"cdr\": tail,\n\t\t\t\"list\": Eval(parser.Parse(\"(lambda z z)\"), &env),\n\t\t},\n\t\tnil}\n\treturn &env\n}", "func NewEnvironment() *Environment {\n\treturn &Environment{\n\t\tdata: map[data.Name]Namespace{},\n\t}\n}", "func NewEnvironment(env ...string) *Environment {\n\te := Environment{\n\t\tHidden: &Environment{},\n\t}\n\tfor _, keyvalue := range env {\n\t\tpair := strings.SplitN(keyvalue, \"=\", 2)\n\t\te.Add(pair[0], pair[1])\n\t}\n\n\treturn &e\n}", "func NewEnv(context *libcoap.Context) *Env {\n return &Env{\n context,\n nil,\n make(chan Event, 32),\n nil,\n }\n}", "func NewEnvironment(name string) *Environment {\n\tthis := Environment{}\n\tthis.Name = name\n\treturn &this\n}", "func newEnv(envPath, provider, name, tfStatePath string, logger hclog.Logger) (*environment, error) {\n\t// Make sure terraform is on the PATH\n\ttf, err := exec.LookPath(\"terraform\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to lookup terraform binary: %v\", err)\n\t}\n\n\tlogger = logger.Named(\"provision\").With(\"provider\", provider, \"name\", name)\n\n\t// set the path to the terraform module\n\ttfPath := path.Join(envPath, provider, name)\n\tlogger.Debug(\"using tf path\", \"path\", tfPath)\n\tif _, err := os.Stat(tfPath); os.IsNotExist(err) {\n\t\treturn nil, fmt.Errorf(\"failed to lookup terraform configuration dir %s: %v\", tfPath, err)\n\t}\n\n\t// set the path to state file\n\ttfState := path.Join(tfStatePath, fmt.Sprintf(\"e2e.%s.%s.tfstate\", provider, name))\n\n\tenv := &environment{\n\t\tprovider: provider,\n\t\tname: name,\n\t\ttf: tf,\n\t\ttfPath: tfPath,\n\t\ttfState: tfState,\n\t\tlogger: logger,\n\t}\n\treturn env, nil\n}", "func NewEnvironment(jsonData string) (*Environment, error) {\n\t// initialize env with input data\n\tenv := new(Environment)\n\terr := serialize.CopyFromJSON(jsonData, env)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn env, nil\n}", "func NewEnv(t *testing.T) *Env {\n\treturn &Env{t, make(chan struct{}), sync.Mutex{}, make([]string, 0)}\n}", "func New(env *Environment) *Environment {\n\treturn NewSized(env, 0)\n}", "func NewEnvironment() *Environment {\n\tenv := &Environment{}\n\tenv.SetUp()\n\treturn env\n}", "func NewEnvironment() *Environment {\n\treturn &Environment{\n\t\tprotos: make(map[string]Fetcher),\n\t\torigins: make(map[string]Fetcher),\n\t}\n}", "func NewEnvironment() *Environment {\n\tvm := NewVM()\n\tenv := &Environment{\n\t\tVM: vm,\n\t}\n\treturn env\n}", "func NewEnv(files []string) *Env {\n\tglobal := make(map[string]interface{})\n\tglobal[\"ENVIRON\"] = getEnvVars()\n\n\treturn &Env{\n\t\tenv: make(map[string]interface{}),\n\t\tparent: nil,\n\t\tbuiltin: newBuiltIn(files),\n\t\tglobal: global,\n\t\tfuncArg: make(map[string]interface{}),\n\t\t//importFunc: make(map[string]func(*Env) (reflect.Value, error)),\n\t\tfileInfo: &FileInfo{\n\t\t\tfiles: files,\n\t\t\tcurFileIndex: 0,\n\t\t\treadCloser: make(map[string]*io.ReadCloser),\n\t\t\tscanner: make(map[string]*bufio.Scanner),\n\t\t},\n\t}\n}", "func NewEnvironment() *Environment {\n\tenv := Environment{\n\t\tstate: lua.NewState(),\n\t}\n\tluajson.Preload(env.state)\n\n\treturn &env\n}", "func newTestEnv(ctx context.Context, t *testing.T, pipelineInfo *pps.PipelineInfo, realEnv *realenv.RealEnv) *testEnv {\n\tlogger := logs.New(pctx.Child(ctx, t.Name()))\n\tworkerDir := filepath.Join(realEnv.Directory, \"worker\")\n\tdriver, err := driver.NewDriver(\n\t\tctx,\n\t\trealEnv.ServiceEnv,\n\t\trealEnv.PachClient,\n\t\tpipelineInfo,\n\t\tworkerDir,\n\t)\n\trequire.NoError(t, err)\n\n\tctx, cancel := pctx.WithCancel(realEnv.PachClient.Ctx())\n\tt.Cleanup(cancel)\n\tdriver = driver.WithContext(ctx)\n\n\treturn &testEnv{\n\t\tRealEnv: realEnv,\n\t\tlogger: logger,\n\t\tdriver: &testDriver{driver},\n\t}\n}", "func NewEnv(loader *ScriptLoader, debugging bool) *Env {\n\tenv := &Env{\n\t\tvm: otto.New(),\n\t\tloader: loader,\n\t\tdebugging: debugging,\n\t\tbuiltinModules: make(map[string]otto.Value),\n\t\tbuiltinModuleFactories: make(map[string]BuiltinModuleFactory),\n\t}\n\tenv.vm.Set(\"__getModulePath\", func(call otto.FunctionCall) otto.Value {\n\t\tvm := call.Otto\n\t\tvar cwd, moduleID string\n\t\tvar err error\n\t\tif cwd, err = call.Argument(0).ToString(); err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__getModulePath error\", err.Error()))\n\t\t}\n\t\tif moduleID, err = call.Argument(1).ToString(); err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__getModulePath error\", err.Error()))\n\t\t}\n\t\tif _, found := env.builtinModules[moduleID]; found {\n\t\t\tret, _ := otto.ToValue(moduleID)\n\t\t\treturn ret\n\t\t}\n\t\tif _, found := env.builtinModuleFactories[moduleID]; found {\n\t\t\tret, _ := otto.ToValue(moduleID)\n\t\t\treturn ret\n\t\t}\n\t\tif ap, err := env.loader.GetModuleAbs(cwd, moduleID); err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__getModulePath error\", err.Error()))\n\t\t} else {\n\t\t\tret, _ := otto.ToValue(ap)\n\t\t\treturn ret\n\t\t}\n\t})\n\tvar requireSrc string\n\tif env.debugging {\n\t\trequireSrc = debugRequireSrc\n\t} else {\n\t\trequireSrc = releaseRequireSrc\n\t}\n\tenv.vm.Set(\"__loadSource\", func(call otto.FunctionCall) otto.Value {\n\t\tvar mp string\n\t\tvar err error\n\t\tvm := call.Otto\n\t\t// reading arguments\n\t\tif mp, err = call.Argument(0).ToString(); err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__loadSource error\", err.Error()))\n\t\t}\n\t\t// finding built builtin modules\n\t\tif mod, found := env.builtinModules[mp]; found {\n\t\t\tretObj, _ := vm.Object(\"({isBuiltin: true})\")\n\t\t\tretObj.Set(\"builtin\", mod)\n\t\t\treturn retObj.Value()\n\t\t}\n\t\t// finding unbuilt builtin modules\n\t\tif mf, found := env.builtinModuleFactories[mp]; found {\n\t\t\tretObj, _ := vm.Object(\"({isBuiltin: true})\")\n\t\t\tmod := mf.CreateModule(vm)\n\t\t\tretObj.Set(\"builtin\", mod)\n\t\t\tenv.builtinModules[mp] = mod\n\t\t\treturn retObj.Value()\n\t\t}\n\t\t// loading module on file system\n\t\tsrc, err := env.loader.LoadScript(mp)\n\t\tif err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__loadSource error\", err.Error()))\n\t\t}\n\t\tscript, err := vm.Compile(mp, src)\n\t\tif err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__loadSource error\", err.Error()))\n\t\t}\n\t\tmodValue, err := vm.Run(script)\n\t\tif err != nil {\n\t\t\tpanic(vm.MakeCustomError(\"__loadSource error\", err.Error()))\n\t\t}\n\t\tretObj, _ := vm.Object(\"({})\")\n\t\tretObj.Set(\"src\", modValue)\n\t\tretObj.Set(\"filename\", path.Base(mp))\n\t\tretObj.Set(\"dirname\", path.Dir(mp))\n\t\treturn retObj.Value()\n\t})\n\t_, err := env.vm.Run(requireSrc)\n\tif err != nil {\n\t\tswitch err.(type) {\n\t\tcase *otto.Error:\n\t\t\tpanic(err.(otto.Error).String())\n\t\tdefault:\n\t\t\tpanic(err)\n\t\t}\n\t}\n\treturn env\n}", "func NewEnvironment(testKeys []string) Environment {\n\tvars := make(map[string]string)\n\tfor _, key := range testKeys {\n\t\tvars[key] = os.Getenv(key)\n\t}\n\treturn Environment{backup: vars}\n}", "func NewEnvironment(options ...Option) Environment {\n\te := &environment{\n\t\tdefaultScheme: DefaultScheme,\n\t\taccessorFactory: DefaultAccessorFactory,\n\t\tcloser: NopCloser,\n\t\tclosed: make(chan struct{}),\n\t}\n\n\tfor _, o := range options {\n\t\to(e)\n\t}\n\n\treturn e\n}", "func NewEnv(ps ...*Env) *Env {\n\treturn &Env{\n\t\tBindings: Bindings{},\n\t\tDocs: Docs{},\n\n\t\t// XXX(hack): allocate a slice to prevent comparing w/ nil in tests\n\t\tParents: append([]*Env{}, ps...),\n\t}\n}", "func NewEnv(name string, gp *pool.GoroutinePool) adapter.Env {\n\treturn env{\n\t\t// logger: newLogger(name),\n\t\tgp: gp,\n\t\tdaemons: new(int64),\n\t\tworkers: new(int64),\n\t}\n}", "func New(mgr manager.Manager, namespace, buildprefix string) (*Environment, error) {\n\treturn &Environment{mgr.GetClient(), mgr.GetScheme(), namespace, buildprefix}, nil\n}", "func NewEnv() Env {\n\tenv := Env{}\n\tenv.LoadEnv()\n\treturn env\n}", "func NewGlobal() *Environment {\n\treturn New(nil)\n}", "func NewEnvironment(maxMemoryPages int, maxTableSize int, maxValueSlots int, maxCallStackDepth int, defaultMemoryPages int, defaultTableSize int, gasLimit uint64, disableFloatingPoint bool, returnOnGasLimitExceeded bool) *Environment {\n\treturn &Environment{ // Return initialized vm config\n\t\tMaxMemoryPages: maxMemoryPages,\n\t\tMaxTableSize: maxTableSize,\n\t\tMaxValueSlots: maxValueSlots,\n\t\tMaxCallStackDepth: maxCallStackDepth,\n\t\tDefaultMemoryPages: defaultMemoryPages,\n\t\tDefaultTableSize: defaultTableSize,\n\t\tGasLimit: gasLimit,\n\t\tDisableFloatingPoint: disableFloatingPoint,\n\t\tReturnOnGasLimitExceeded: returnOnGasLimitExceeded,\n\t}\n}", "func newTestEnvironment(eventJSONFilePath string, shipyardPath string, jobConfigPath string) (*testEnvironment, error) {\n\n\t// Create K8s clientset\n\tclientset, err := NewK8sClient()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to build k8s clientset: %w\", err)\n\t}\n\n\t// Create a new Keptn api for the use of the E2E test\n\tkeptnAPI, err := NewKeptnAPI(readKeptnConnectionDetailsFromEnv())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create the keptn API: %w\", err)\n\t}\n\n\t// Read the event we want to trigger and extract the project, service and stage\n\tkeptnEvent, err := readKeptnContextExtendedCE(eventJSONFilePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable parse JSON event file: %w\", err)\n\t}\n\n\teventData, err := parseKeptnEventData(keptnEvent)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable parse event data of the JSON event: %w\", err)\n\t}\n\n\t// Load shipyard file and create the project in Keptn\n\tshipyardFile, err := ioutil.ReadFile(shipyardPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to read the shipyard file: %w\", err)\n\t}\n\n\t// Load the job configuration for the E2E test\n\tjobConfigYaml, err := ioutil.ReadFile(jobConfigPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to read the job configuration file: %w\", err)\n\t}\n\n\treturn &testEnvironment{\n\t\tK8s: clientset,\n\t\tAPI: keptnAPI,\n\t\tEventData: eventData,\n\t\tEvent: keptnEvent,\n\t\tNamespace: \"keptn\",\n\t\tshipyard: shipyardFile,\n\t\tjobConfig: jobConfigYaml,\n\t}, nil\n}", "func NewProgramEnv() *ProgramEnv {\n\tretval := ProgramEnv{}\n\n\t// all done\n\treturn &retval\n}", "func NewEnvironment() Environment {\n\treturn &environ{\n\t\tuid: uuid.New().String(),\n\t}\n}", "func NewEnvironment(kubeConfig *rest.Config) *Environment {\n\tatomic.AddInt32(&namespaceCounter, portPerTest)\n\tnamespaceID := gomegaConfig.GinkgoConfig.ParallelNode*testPerNode + int(namespaceCounter)\n\t// the single namespace used by this test\n\tns := utils.GetNamespaceName(namespaceID)\n\n\tenv := &Environment{\n\t\tEnvironment: &utils.Environment{\n\t\t\tID: namespaceID,\n\t\t\tNamespace: ns,\n\t\t\tKubeConfig: kubeConfig,\n\t\t\tConfig: &config.Config{\n\t\t\t\tCtxTimeOut: 10 * time.Second,\n\t\t\t\tMeltdownDuration: defaultTestMeltdownDuration * time.Second,\n\t\t\t\tMeltdownRequeueAfter: defaultTestMeltdownRequeueAfter * time.Second,\n\t\t\t\tMonitoredID: ns,\n\t\t\t\tOperatorNamespace: ns,\n\t\t\t\tFs: afero.NewOsFs(),\n\t\t\t},\n\t\t},\n\t\tMachine: Machine{\n\t\t\tMachine: machine.NewMachine(),\n\t\t},\n\t}\n\tgomega.SetDefaultEventuallyTimeout(env.PollTimeout)\n\tgomega.SetDefaultEventuallyPollingInterval(env.PollInterval)\n\n\treturn env\n}", "func NewEnv() (*Env, error) {\n\tctx := context.Background()\n\tdomainID := fmt.Sprintf(\"domain %d\", rand.Int()) // nolint: gas\n\tdb, err := testdb.New(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: failed to open database: %v\", err)\n\t}\n\n\t// Map server\n\tmapEnv, err := maptest.NewMapEnv(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: failed to create trillian map server: %v\", err)\n\t}\n\n\ttlog := fake.NewTrillianLogClient()\n\n\t// Configure domain, which creates new map and log trees.\n\tdomainStorage, err := domain.NewStorage(db)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: failed to create domain storage: %v\", err)\n\t}\n\tadminSvr := adminserver.New(tlog, mapEnv.Map, mapEnv.Admin, mapEnv.Admin, domainStorage, vrfKeyGen)\n\tdomainPB, err := adminSvr.CreateDomain(ctx, &pb.CreateDomainRequest{\n\t\tDomainId: domainID,\n\t\tMinInterval: ptypes.DurationProto(1 * time.Second),\n\t\tMaxInterval: ptypes.DurationProto(5 * time.Second),\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: CreateDomain(): %v\", err)\n\t}\n\n\tmapID := domainPB.Map.TreeId\n\tlogID := domainPB.Log.TreeId\n\tmapPubKey, err := der.UnmarshalPublicKey(domainPB.Map.GetPublicKey().GetDer())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: Failed to load signing keypair: %v\", err)\n\t}\n\tvrfPub, err := p256.NewVRFVerifierFromRawKey(domainPB.Vrf.GetDer())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: Failed to load vrf pubkey: %v\", err)\n\t}\n\n\t// Common data structures.\n\tmutations, err := mutationstorage.New(db)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"env: Failed to create mutations object: %v\", err)\n\t}\n\tauth := authentication.NewFake()\n\tauthz := authorization.New()\n\n\tqueue := mutator.MutationQueue(mutations)\n\tserver := keyserver.New(tlog, mapEnv.Map, mapEnv.Admin, mapEnv.Admin,\n\t\tentry.New(), auth, authz, domainStorage, queue, mutations)\n\tgsvr := grpc.NewServer()\n\tpb.RegisterKeyTransparencyServer(gsvr, server)\n\n\t// Sequencer\n\tseq := sequencer.New(tlog, mapEnv.Map, entry.New(), domainStorage, mutations, queue)\n\t// Only sequence when explicitly asked with receiver.Flush()\n\td := &domaindef.Domain{\n\t\tDomainID: domainID,\n\t\tLogID: logID,\n\t\tMapID: mapID,\n\t}\n\treceiver := seq.NewReceiver(ctx, d, 60*time.Hour, 60*time.Hour)\n\treceiver.Flush(ctx)\n\n\taddr, lis, err := Listen()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tgo gsvr.Serve(lis)\n\n\t// Client\n\tcc, err := grpc.Dial(addr, grpc.WithInsecure())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Dial(%v) = %v\", addr, err)\n\t}\n\tktClient := pb.NewKeyTransparencyClient(cc)\n\tclient := grpcc.New(ktClient, domainID, vrfPub, mapPubKey, coniks.Default, fake.NewFakeTrillianLogVerifier())\n\tclient.RetryCount = 0\n\n\treturn &Env{\n\t\tEnv: &integration.Env{\n\t\t\tClient: client,\n\t\t\tCli: ktClient,\n\t\t\tDomain: domainPB,\n\t\t\tReceiver: receiver,\n\t\t},\n\t\tmapEnv: mapEnv,\n\t\tgrpcServer: gsvr,\n\t\tgrpcCC: cc,\n\t\tdb: db,\n\t}, nil\n}", "func newRuntimeContext(env string, logger *zap.Logger, scope tally.Scope, service workflowserviceclient.Interface) *RuntimeContext {\n\treturn &RuntimeContext{\n\t\tEnv: env,\n\t\tlogger: logger,\n\t\tmetrics: scope,\n\t\tservice: service,\n\t}\n}", "func newTestEnvironment() *environment {\n\tdir, err := ioutil.TempDir(\"\", uuid.NewUUID().String())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ttestAccounts := account.GenAccounts(usersNumber)\n\towner := testAccounts[0]\n\n\tserver := backend.NewSimulatedBackend(account.Addresses(testAccounts))\n\n\tmAddr, _, err := mediator.Deploy(owner.TransactOpts, server)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tmSession, err := mediator.NewMediatorSession(*owner.TransactOpts,\n\t\tmAddr, server)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\trAddr, err := mSession.RootChain()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tparsed, err := abi.JSON(strings.NewReader(rootchain.RootChainABI))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tmParsed, err := abi.JSON(strings.NewReader(mediator.MediatorABI))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\ttAddr, _ := deployToken(owner.TransactOpts, server)\n\n\ttOwnerSession := tokenSession(owner.TransactOpts,\n\t\ttAddr, server)\n\n\tvar users []*user\n\n\t// mint and approval to Mediator contract.\n\tfor _, acc := range testAccounts {\n\t\tmint(tOwnerSession, acc.From, supply, server)\n\n\t\ttSession := tokenSession(acc.TransactOpts,\n\t\t\ttAddr, server)\n\t\tincreaseApproval(tSession, mAddr, supply, server)\n\n\t\tusers = append(users, &user{acc: acc})\n\t}\n\n\t// get free port\n\tport := getPort()\n\n\t// creates new Plasma server.\n\tsrv := newServer(\n\t\t*testAccounts[0], rAddr, mAddr, parsed,\n\t\tmParsed, server, dir, port)\n\tgo srv.ListenAndServe()\n\n\ttime.Sleep(time.Microsecond * 200)\n\n\treturn &environment{\n\t\tdir: dir,\n\t\taccounts: users,\n\t\tmediatorAddress: mAddr,\n\t\trootChainAddress: rAddr,\n\t\ttokenAddress: tAddr,\n\t\tmediatorABI: mParsed,\n\t\trootChainABI: parsed,\n\t\tbackend: server,\n\t\tserver: srv,\n\t\tport: port,\n\t}\n}", "func (e *Environment) New(n data.Name) Namespace {\n\treturn &namespace{\n\t\tenvironment: e,\n\t\tentries: entries{},\n\t\tdomain: n,\n\t}\n}", "func CreateTestEnv(t *testing.T) TestInput {\n\tt.Helper()\n\n\t// Initialize store keys\n\tkeyGravity := sdk.NewKVStoreKey(gravitytypes.StoreKey)\n\tkeyAcc := sdk.NewKVStoreKey(authtypes.StoreKey)\n\tkeyStaking := sdk.NewKVStoreKey(stakingtypes.StoreKey)\n\tkeyBank := sdk.NewKVStoreKey(banktypes.StoreKey)\n\tkeyDistro := sdk.NewKVStoreKey(distrtypes.StoreKey)\n\tkeyParams := sdk.NewKVStoreKey(paramstypes.StoreKey)\n\ttkeyParams := sdk.NewTransientStoreKey(paramstypes.TStoreKey)\n\tkeyGov := sdk.NewKVStoreKey(govtypes.StoreKey)\n\tkeySlashing := sdk.NewKVStoreKey(slashingtypes.StoreKey)\n\tkeyAllocation := sdk.NewKVStoreKey(types.StoreKey)\n\n\t// Initialize memory database and mount stores on it\n\tdb := dbm.NewMemDB()\n\tms := store.NewCommitMultiStore(db)\n\tms.MountStoreWithDB(keyGravity, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyAcc, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyParams, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyStaking, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyBank, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyDistro, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(tkeyParams, sdk.StoreTypeTransient, db)\n\tms.MountStoreWithDB(keyGov, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keySlashing, sdk.StoreTypeIAVL, db)\n\tms.MountStoreWithDB(keyAllocation, sdk.StoreTypeIAVL, db)\n\terr := ms.LoadLatestVersion()\n\trequire.Nil(t, err)\n\n\t// Create sdk.Context\n\tctx := sdk.NewContext(ms, tmproto.Header{\n\t\tHeight: 1234567,\n\t\tTime: time.Date(2020, time.April, 22, 12, 0, 0, 0, time.UTC),\n\t}, false, log.TestingLogger())\n\n\tcdc := MakeTestCodec()\n\tmarshaler := MakeTestMarshaler()\n\n\tparamsKeeper := paramskeeper.NewKeeper(marshaler, cdc, keyParams, tkeyParams)\n\tparamsKeeper.Subspace(authtypes.ModuleName)\n\tparamsKeeper.Subspace(banktypes.ModuleName)\n\tparamsKeeper.Subspace(stakingtypes.ModuleName)\n\tparamsKeeper.Subspace(distrtypes.ModuleName)\n\tparamsKeeper.Subspace(govtypes.ModuleName)\n\tparamsKeeper.Subspace(types.DefaultParamspace)\n\tparamsKeeper.Subspace(slashingtypes.ModuleName)\n\tparamsKeeper.Subspace(gravitytypes.ModuleName)\n\n\t// this is also used to initialize module accounts for all the map keys\n\tmaccPerms := map[string][]string{\n\t\tauthtypes.FeeCollectorName: nil,\n\t\tdistrtypes.ModuleName: nil,\n\t\tstakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},\n\t\tstakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},\n\t\tgovtypes.ModuleName: {authtypes.Burner},\n\t\ttypes.ModuleName: {authtypes.Minter, authtypes.Burner},\n\t}\n\n\taccountKeeper := authkeeper.NewAccountKeeper(\n\t\tmarshaler,\n\t\tkeyAcc, // target store\n\t\tgetSubspace(paramsKeeper, authtypes.ModuleName),\n\t\tauthtypes.ProtoBaseAccount, // prototype\n\t\tmaccPerms,\n\t)\n\n\tblockedAddr := make(map[string]bool, len(maccPerms))\n\tfor acc := range maccPerms {\n\t\tblockedAddr[authtypes.NewModuleAddress(acc).String()] = true\n\t}\n\n\tbankKeeper := bankkeeper.NewBaseKeeper(\n\t\tmarshaler,\n\t\tkeyBank,\n\t\taccountKeeper,\n\t\tgetSubspace(paramsKeeper, banktypes.ModuleName),\n\t\tblockedAddr,\n\t)\n\tbankKeeper.SetParams(ctx, banktypes.Params{DefaultSendEnabled: true})\n\n\tstakingKeeper := stakingkeeper.NewKeeper(marshaler, keyStaking, accountKeeper, bankKeeper, getSubspace(paramsKeeper, stakingtypes.ModuleName))\n\tstakingKeeper.SetParams(ctx, TestingStakeParams)\n\n\tdistKeeper := distrkeeper.NewKeeper(marshaler, keyDistro, getSubspace(paramsKeeper, distrtypes.ModuleName), accountKeeper, bankKeeper, stakingKeeper, authtypes.FeeCollectorName, nil)\n\tdistKeeper.SetParams(ctx, distrtypes.DefaultParams())\n\n\t// set genesis items required for distribution\n\tdistKeeper.SetFeePool(ctx, distrtypes.InitialFeePool())\n\n\t// total supply to track this\n\ttotalSupply := sdk.NewCoins(sdk.NewInt64Coin(\"stake\", 100000000))\n\n\t// set up initial accounts\n\tfor name, perms := range maccPerms {\n\t\tmod := authtypes.NewEmptyModuleAccount(name, perms...)\n\t\tif name == stakingtypes.NotBondedPoolName {\n\t\t\trequire.NoError(t, fundModAccount(ctx, bankKeeper, mod.GetName(), totalSupply))\n\t\t} else if name == distrtypes.ModuleName {\n\t\t\t// some big pot to pay out\n\t\t\tamt := sdk.NewCoins(sdk.NewInt64Coin(\"stake\", 500000))\n\t\t\trequire.NoError(t, fundModAccount(ctx, bankKeeper, mod.GetName(), amt))\n\t\t}\n\n\t\taccountKeeper.SetModuleAccount(ctx, mod)\n\t}\n\n\tstakeAddr := authtypes.NewModuleAddress(stakingtypes.BondedPoolName)\n\tmoduleAcct := accountKeeper.GetAccount(ctx, stakeAddr)\n\trequire.NotNil(t, moduleAcct)\n\n\trouter := baseapp.NewRouter()\n\trouter.AddRoute(bank.AppModule{}.Route())\n\trouter.AddRoute(staking.AppModule{}.Route())\n\trouter.AddRoute(distribution.AppModule{}.Route())\n\n\t// Load default wasm config\n\n\tgovRouter := govtypes.NewRouter().\n\t\tAddRoute(paramsproposal.RouterKey, params.NewParamChangeProposalHandler(paramsKeeper)).\n\t\tAddRoute(govtypes.RouterKey, govtypes.ProposalHandler)\n\n\tgovKeeper := govkeeper.NewKeeper(\n\t\tmarshaler, keyGov, getSubspace(paramsKeeper, govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()), accountKeeper, bankKeeper, stakingKeeper, govRouter,\n\t)\n\n\tgovKeeper.SetProposalID(ctx, govtypes.DefaultStartingProposalID)\n\tgovKeeper.SetDepositParams(ctx, govtypes.DefaultDepositParams())\n\tgovKeeper.SetVotingParams(ctx, govtypes.DefaultVotingParams())\n\tgovKeeper.SetTallyParams(ctx, govtypes.DefaultTallyParams())\n\n\tslashingKeeper := slashingkeeper.NewKeeper(\n\t\tmarshaler,\n\t\tkeySlashing,\n\t\t&stakingKeeper,\n\t\tgetSubspace(paramsKeeper, slashingtypes.ModuleName).WithKeyTable(slashingtypes.ParamKeyTable()),\n\t)\n\n\tgravityKeeper := gravitykeeper.NewKeeper(\n\t\tmarshaler,\n\t\tkeyGravity,\n\t\tgetSubspace(paramsKeeper, gravitytypes.DefaultParamspace),\n\t\taccountKeeper,\n\t\tstakingKeeper,\n\t\tbankKeeper,\n\t\tslashingKeeper,\n\t\tsdk.DefaultPowerReduction,\n\t)\n\n\tstakingKeeper = *stakingKeeper.SetHooks(\n\t\tstakingtypes.NewMultiStakingHooks(\n\t\t\tdistKeeper.Hooks(),\n\t\t\tslashingKeeper.Hooks(),\n\t\t\tgravityKeeper.Hooks(),\n\t\t),\n\t)\n\n\tk := NewKeeper(\n\t\tmarshaler,\n\t\tkeyAllocation,\n\t\tgetSubspace(paramsKeeper, types.DefaultParamspace),\n\t\tstakingKeeper,\n\t\tgravityKeeper,\n\t)\n\n\tk.setParams(ctx, TestingAllocationParams)\n\n\treturn TestInput{\n\t\tAllocationKeeper: k,\n\t\tGravityKeeper: gravityKeeper,\n\t\tAccountKeeper: accountKeeper,\n\t\tBankKeeper: bankKeeper,\n\t\tStakingKeeper: stakingKeeper,\n\t\tSlashingKeeper: slashingKeeper,\n\t\tDistKeeper: distKeeper,\n\t\tGovKeeper: govKeeper,\n\t\tContext: ctx,\n\t\tMarshaler: marshaler,\n\t\tLegacyAmino: cdc,\n\t}\n}", "func MakeEnv(outer *Env) Env {\n\tframe := map[Symbol]LangType{}\n\treturn Env{\n\t\touter: outer,\n\t\tframe: frame,\n\t}\n}", "func NewEnvironmentViewer(ctx *common.Context, format string, environmentName string, viewTasks bool, writer io.Writer) Executor {\n\n\tworkflow := new(environmentWorkflow)\n\n\tvar environmentViewer func() error\n\tif format == JSON {\n\t\tenvironmentViewer = workflow.environmentViewerJSON(ctx.Config.Namespace, environmentName, ctx.StackManager, ctx.StackManager, ctx.ClusterManager, writer)\n\t} else if format == SHELL {\n\t\tenvironmentViewer = workflow.environmentViewerSHELL(ctx.Config.Namespace, environmentName, ctx.StackManager, ctx.StackManager, ctx.ClusterManager, writer)\n\t} else {\n\t\tenvironmentViewer = workflow.environmentViewerCli(ctx.Config.Namespace, environmentName, ctx.StackManager, ctx.StackManager, ctx.ClusterManager, ctx.InstanceManager, ctx.TaskManager, viewTasks, writer)\n\t}\n\n\treturn newPipelineExecutor(\n\t\tenvironmentViewer,\n\t)\n}", "func NewEnv() *Env {\n\tenv := new(Env)\n\t// env.EnvParams.DefaultEnv()\n\t// env.EnvParams.Initialize()\n\treturn env\n}", "func New() {\n\ttypeOfProject()\n}", "func NewEnv(r io.Reader, varReader tpl.VariableReader, parser tpl.Parser) (EnvSource, error) {\n\tenv, err := parseEnvironment(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tsecretTemplates := make([]envvarTpls, len(env))\n\tfor i, envvar := range env {\n\t\tkeyTpl, err := parser.Parse(envvar.key, envvar.lineNumber, envvar.columnNumberKey)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\terr = validation.ValidateEnvarName(envvar.key)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvalTpl, err := parser.Parse(envvar.value, envvar.lineNumber, envvar.columnNumberValue)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tsecretTemplates[i] = envvarTpls{\n\t\t\tkey: keyTpl,\n\t\t\tvalue: valTpl,\n\t\t\tlineNo: envvar.lineNumber,\n\t\t}\n\t}\n\n\treturn envTemplate{\n\t\tenvVars: secretTemplates,\n\t\ttemplateVarReader: varReader,\n\t}, nil\n}", "func CreateEnv(testchain *model.Testchain) (*model.Response, error) {\n\turl := helpers.BuildURL(connectionString(), \"environments\", \"start\")\n\tjson, err := testchain.ToReader()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn client.Post(url, json)\n}", "func NewFromCurrentEnvironment() (p *Project, err error) {\n\tvar found bool\n\tp = &Project{}\n\n\tif p.GoRootPath, found = os.LookupEnv(\"GOROOT\"); !found {\n\t\treturn nil, fmt.Errorf(\"GOROOT is not set\")\n\t}\n\n\tif p.GoPath, found = os.LookupEnv(\"GOPATH\"); !found {\n\t\treturn nil, fmt.Errorf(\"GOPATH is not set\")\n\t}\n\n\tif p.Name, found = os.LookupEnv(\"GOVENV_PROJECT\"); !found {\n\t\treturn nil, fmt.Errorf(\"GOVENV_PROJECT is not set\")\n\t}\n\n\tif p.ManagementDirPath, found = os.LookupEnv(\"GOVENV_MANAGEMENT_DIR\"); !found {\n\t\treturn nil, fmt.Errorf(\"GOVENV_MANAGEMET_DIR is not set\")\n\t}\n\n\treturn p, nil\n}", "func NewEnvironmentService(sling *sling.Sling, uriTemplate string, sortOrderPath string, summaryPath string) *EnvironmentService {\n\treturn &EnvironmentService{\n\t\tsortOrderPath: sortOrderPath,\n\t\tsummaryPath: summaryPath,\n\t\tCanDeleteService: services.CanDeleteService{\n\t\t\tService: services.NewService(constants.ServiceEnvironmentService, sling, uriTemplate),\n\t\t},\n\t}\n}", "func NewSized(env *Environment, size int) *Environment {\n\treturn &Environment{values: make(map[string]interface{}), enclosing: env, indexedValues: make([]interface{}, size)}\n}", "func New(name string) (*ChefEnvironment, util.Gerror) {\n\tif !util.ValidateEnvName(name) {\n\t\terr := util.Errorf(\"Field 'name' invalid\")\n\t\terr.SetStatus(http.StatusBadRequest)\n\t\treturn nil, err\n\t}\n\n\tvar found bool\n\tif config.UsingDB() {\n\t\tvar eerr error\n\t\tfound, eerr = checkForEnvironmentSQL(datastore.Dbh, name)\n\t\tif eerr != nil {\n\t\t\terr := util.CastErr(eerr)\n\t\t\terr.SetStatus(http.StatusInternalServerError)\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tds := datastore.New()\n\t\t_, found = ds.Get(\"env\", name)\n\t}\n\tif found || name == \"_default\" {\n\t\terr := util.Errorf(\"Environment already exists\")\n\t\treturn nil, err\n\t}\n\n\tenv := &ChefEnvironment{\n\t\tName: name,\n\t\tChefType: \"environment\",\n\t\tJSONClass: \"Chef::Environment\",\n\t\tDefault: map[string]interface{}{},\n\t\tOverride: map[string]interface{}{},\n\t\tCookbookVersions: map[string]string{},\n\t}\n\treturn env, nil\n}", "func (client *Client) CreateEnvironment(req *Request) (*Response, error) {\n\treturn client.Execute(&Request{\n\t\tMethod: \"POST\",\n\t\tPath: EnvironmentsPath,\n\t\tQueryParams: req.QueryParams,\n\t\tBody: req.Body,\n\t\tResult: &CreateEnvironmentResult{},\n\t})\n}", "func CreateEnvironment(host string, verifyTLS bool, apiKey string, project string, name string, slug string) (models.EnvironmentInfo, Error) {\n\tpostBody := map[string]string{\"project\": project, \"name\": name, \"slug\": slug}\n\tbody, err := json.Marshal(postBody)\n\tif err != nil {\n\t\treturn models.EnvironmentInfo{}, Error{Err: err, Message: \"Invalid environment info\"}\n\t}\n\n\turl, err := generateURL(host, \"/v3/environments\", nil)\n\tif err != nil {\n\t\treturn models.EnvironmentInfo{}, Error{Err: err, Message: \"Unable to generate url\"}\n\t}\n\n\tstatusCode, _, response, err := PostRequest(url, verifyTLS, apiKeyHeader(apiKey), body)\n\tif err != nil {\n\t\treturn models.EnvironmentInfo{}, Error{Err: err, Message: \"Unable to create environment\", Code: statusCode}\n\t}\n\n\tvar result map[string]interface{}\n\terr = json.Unmarshal(response, &result)\n\tif err != nil {\n\t\treturn models.EnvironmentInfo{}, Error{Err: err, Message: \"Unable to parse API response\", Code: statusCode}\n\t}\n\n\tenvironmentInfo, ok := result[\"environment\"].(map[string]interface{})\n\tif !ok {\n\t\treturn models.EnvironmentInfo{}, Error{Err: fmt.Errorf(\"Unexpected type parsing environment, expected map[string]interface{}, got %T\", result[\"environment\"]), Message: \"Unable to parse API response\", Code: statusCode}\n\t}\n\n\tinfo := models.ParseEnvironmentInfo(environmentInfo)\n\n\treturn info, Error{}\n}", "func NewContext(env map[string]string) *ContextImpl {\n\tcntx := &ContextImpl{\n\t\tenv: env,\n\t\ttest: make(map[string]string),\n\t\ttestNumber: 0,\n\t\tcorrelationId: \"\",\n\t}\n\tif cntx.env == nil {\n\t\tcntx.env = make(map[string]string)\n\t}\n\treturn cntx\n}", "func (t *DeploymentEnvironment_DeploymentEnvironment) NewDeploymentEnvironment(Id string) (*DeploymentEnvironment_DeploymentEnvironment_DeploymentEnvironment, error){\n\n\t// Initialise the list within the receiver struct if it has not already been\n\t// created.\n\tif t.DeploymentEnvironment == nil {\n\t\tt.DeploymentEnvironment = make(map[string]*DeploymentEnvironment_DeploymentEnvironment_DeploymentEnvironment)\n\t}\n\n\tkey := Id\n\n\t// Ensure that this key has not already been used in the\n\t// list. Keyed YANG lists do not allow duplicate keys to\n\t// be created.\n\tif _, ok := t.DeploymentEnvironment[key]; ok {\n\t\treturn nil, fmt.Errorf(\"duplicate key %v for list DeploymentEnvironment\", key)\n\t}\n\n\tt.DeploymentEnvironment[key] = &DeploymentEnvironment_DeploymentEnvironment_DeploymentEnvironment{\n\t\tId: &Id,\n\t}\n\n\treturn t.DeploymentEnvironment[key], nil\n}", "func NewSimpleEnv() *Env {\n\tenv := new(Env)\n\t// env.EnvParams.DefaultEnv()\n\t// env.EnvParams.Initialize()\n\treturn env\n}", "func (client *Client) NewTestEnvironment(bucketKey string, testID string, environment Environment) (Environment, error) {\n\tvar newEnvironment = Environment{}\n\n\tpath := fmt.Sprintf(\"buckets/%s/tests/%s/environments\", bucketKey, testID)\n\tdata, err := json.Marshal(&environment)\n\tif err != nil {\n\t\treturn newEnvironment, err\n\t}\n\n\tcontent, err := client.Post(path, data)\n\tif err != nil {\n\t\treturn newEnvironment, err\n\t}\n\n\terr = unmarshal(content, &newEnvironment)\n\treturn newEnvironment, err\n}", "func CreateMainTestEnv(opts *CreateMainTestEnvOpts) (env *EnvT, tearDown func()) {\n\tglobalMutex.Lock()\n\tpackageLevelVirtualTest := newVirtualTest(opts)\n\tglobalMutex.Unlock()\n\n\tenv = NewEnv(packageLevelVirtualTest) // register global test for env\n\treturn env, packageLevelVirtualTest.cleanup\n}", "func NewEnclosedEnvironment(outer *Environment) *Environment {\n\tenv := NewEnvironment()\n\tenv.outer = outer\n\treturn env\n}", "func NewEnclosedEnvironment(outer *Environment) *Environment {\n\tenv := NewEnvironment()\n\tenv.outer = outer\n\treturn env\n}", "func (s *Store) CreateEnvironment(environment *archer.Environment) error {\n\tif _, err := s.GetProject(environment.Project); err != nil {\n\t\treturn err\n\t}\n\n\tenvironmentPath := fmt.Sprintf(fmtEnvParamPath, environment.Project, environment.Name)\n\tdata, err := marshal(environment)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"serializing environment %s: %w\", environment.Name, err)\n\t}\n\n\t_, err = s.ssmClient.PutParameter(&ssm.PutParameterInput{\n\t\tName: aws.String(environmentPath),\n\t\tDescription: aws.String(fmt.Sprintf(\"The %s deployment stage\", environment.Name)),\n\t\tType: aws.String(ssm.ParameterTypeString),\n\t\tValue: aws.String(data),\n\t})\n\tif err != nil {\n\t\tif aerr, ok := err.(awserr.Error); ok {\n\t\t\tswitch aerr.Code() {\n\t\t\tcase ssm.ErrCodeParameterAlreadyExists:\n\t\t\t\treturn &ErrEnvironmentAlreadyExists{\n\t\t\t\t\tEnvironmentName: environment.Name,\n\t\t\t\t\tProjectName: environment.Project}\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"create environment %s in project %s: %w\", environment.Name, environment.Project, err)\n\t}\n\treturn nil\n}", "func (client LabClient) CreateEnvironmentPreparer(ctx context.Context, resourceGroupName string, name string, labVirtualMachine LabVirtualMachine) (*http.Request, error) {\n\tpathParameters := map[string]interface{}{\n\t\t\"name\": autorest.Encode(\"path\", name),\n\t\t\"resourceGroupName\": autorest.Encode(\"path\", resourceGroupName),\n\t\t\"subscriptionId\": autorest.Encode(\"path\", client.SubscriptionID),\n\t}\n\n\tconst APIVersion = \"2015-05-21-preview\"\n\tqueryParameters := map[string]interface{}{\n\t\t\"api-version\": APIVersion,\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsContentType(\"application/json; charset=utf-8\"),\n\t\tautorest.AsPost(),\n\t\tautorest.WithBaseURL(client.BaseURI),\n\t\tautorest.WithPathParameters(\"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{name}/createEnvironment\", pathParameters),\n\t\tautorest.WithJSON(labVirtualMachine),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func NewEnclosedEnvironment(outer *Environment) *Environment {\n\tenv := NewEnvironment()\n\tenv.outer = outer\n\n\treturn env\n}", "func InitEnvironment(e *Environment) {\n\te.SetCommand(\"print\", _stdPrint)\n\te.SetCommand(\"set\", _stdSet)\n\te.SetCommand(\"get\", _stdGet)\n\te.SetCommand(\"math\", _stdMath)\n\te.SetCommand(\"push\", _stdPush)\n\te.SetCommand(\"pop\", _stdPop)\n\n\t// ================\n\t// Special Commands\n\t// ================\n\n\t// Function creation\n\t// ===================\n\tvar functioner *Functioner\n\tvar functionerName string\n\te.SetCommand(\"func\", func(e *Environment, args string) int64 {\n\t\tif args == \"\" {\n\t\t\treturn 0\n\t\t}\n\t\tfunctionerName = args\n\t\tfunctioner = NewFunctioner(e)\n\t\treturn 1\n\t})\n\te.SetCommand(\"+\", func(e *Environment, args string) int64 {\n\t\tif args == \"\" {\n\t\t\treturn 0\n\t\t}\n\t\tfunctioner.Append(args)\n\t\treturn 1\n\t})\n\te.SetCommand(\"endfunc\", func(e *Environment, args string) int64 {\n\t\tif functioner == nil || functionerName == \"\" {\n\t\t\treturn 0\n\t\t}\n\t\tf := functioner.GetFunction()\n\t\te.SetCommand(functionerName, f)\n\n\t\tfunctioner = nil\n\t\tfunctionerName = \"\"\n\t\treturn 1\n\t})\n}", "func NewExecuteEnv(req Request, reports []Report) *ExecuteEnv {\n\tenvReports := make(map[string]map[ExternalID]RawReport)\n\tfor _, report := range reports {\n\t\tvalReports := make(map[ExternalID]RawReport)\n\t\tfor _, each := range report.RawReports {\n\t\t\tvalReports[each.ExternalID] = each\n\t\t}\n\t\tenvReports[report.Validator.String()] = valReports\n\t}\n\treturn &ExecuteEnv{\n\t\tBaseEnv: BaseEnv{\n\t\t\trequest: req,\n\t\t},\n\t\treports: envReports,\n\t}\n}", "func newScope(ast *parser.Thrift) *Scope {\n\treturn &Scope{\n\t\tast: ast,\n\t\timports: newImportManager(),\n\t\tglobals: namespace.NewNamespace(namespace.UnderscoreSuffix),\n\t\tnamespace: ast.GetNamespaceOrReferenceName(\"go\"),\n\t}\n}", "func NewEnv(dsn string) (*Env, error) {\n\tdb, err := sql.Open(\"postgres\", dsn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err = db.Ping(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Env{db}, nil\n}", "func newContext(config *Config) (*Context, error) {\n\tctx := &Context{Env: make(map[string]string)}\n\n\tfor _, envVarName := range config.Envvars {\n\t\tvalue := os.Getenv(envVarName)\n\t\tif value != \"\" {\n\t\t\t//log.Printf(\"Env var %s found with value '%s'\", envVarName, value)\n\t\t\tctx.Env[envVarName] = value\n\t\t} else {\n\t\t\treturn nil, errors.New(fmt.Sprintf(\"Env var %s not defined!\", envVarName))\n\t\t}\n\t}\n\n\treturn ctx, nil\n}", "func (c *Client) CreateTemporaryEnvironment(runDescription string, urlString string, webhook string) (*Environment, error) {\n\tname := \"temporary-env-for-custom-url-via-CLI\"\n\tif runDescription != \"\" {\n\t\tif len(runDescription) > 241 {\n\t\t\trunDescription = runDescription[:241]\n\t\t}\n\t\tname = fmt.Sprintf(\"%v-temporary-env\", runDescription)\n\t}\n\n\tbody := EnvironmentParams{\n\t\tName: name,\n\t\tURL: urlString,\n\t\tIsTemporary: true,\n\t\tWebhook: webhook,\n\t\tWebhookEnabled: webhook != \"\",\n\t}\n\treq, err := c.NewRequest(\"POST\", \"environments\", &body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar env Environment\n\t_, err = c.Do(req, &env)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &env, nil\n}", "func NewEnv(rctx context.Context, t testing.TB) *Env {\n\t// Use an error group with a cancelable context to supervise every component\n\t// and cancel everything if one fails\n\tctx, cancel := pctx.WithCancel(rctx)\n\teg, ctx := errgroup.WithContext(ctx)\n\tt.Cleanup(func() {\n\t\trequire.NoError(t, eg.Wait())\n\t})\n\tt.Cleanup(cancel)\n\n\tenv := &Env{Context: ctx, Directory: t.TempDir()}\n\n\t// NOTE: this is changing a GLOBAL variable in etcd. This function should not\n\t// be run in the same process as production code where this may affect\n\t// performance (but there should be little risk of that as this is only for\n\t// test code).\n\tetcdwal.SegmentSizeBytes = 1 * 1000 * 1000 // 1 MB\n\n\tetcdConfig := embed.NewConfig()\n\tetcdConfig.MaxTxnOps = 10000\n\n\t// Create test dirs for etcd data\n\tetcdConfig.Dir = path.Join(env.Directory, \"etcd_data\")\n\tetcdConfig.WalDir = path.Join(env.Directory, \"etcd_wal\")\n\n\t// Speed up initial election, hopefully this has no other impact since there\n\t// is only one etcd instance\n\tetcdConfig.InitialElectionTickAdvance = false\n\tetcdConfig.TickMs = 10\n\tetcdConfig.ElectionMs = 50\n\n\t// Log to the test log.\n\tlevel := log.AddLoggerToEtcdServer(ctx, etcdConfig)\n\t// We want to assign a random unused port to etcd, but etcd doesn't give us a\n\t// way to read it back out later. We can work around this by creating our own\n\t// listener on a random port, find out which port was used, close that\n\t// listener, and pass that port down for etcd to use. There is a small race\n\t// condition here where someone else can steal the port between these steps,\n\t// but it should be fairly minimal and depends on how the OS assigns\n\t// unallocated ports.\n\tlistener, err := net.Listen(\"tcp\", \"localhost:0\")\n\trequire.NoError(t, err)\n\trequire.NoError(t, listener.Close())\n\n\tclientURL, err := url.Parse(fmt.Sprintf(\"http://%s\", listener.Addr().String()))\n\trequire.NoError(t, err)\n\n\tetcdConfig.ListenPeerUrls = []url.URL{}\n\tetcdConfig.ListenClientUrls = []url.URL{*clientURL}\n\n\t// Throw away noisy messages from etcd - comment these out if you need to debug\n\t// a failed start\n\tlevel.SetLevel(zapcore.ErrorLevel)\n\n\tenv.Etcd, err = embed.StartEtcd(etcdConfig)\n\trequire.NoError(t, err)\n\tt.Cleanup(env.Etcd.Close)\n\n\teg.Go(func() error {\n\t\treturn errorWait(ctx, env.Etcd.Err())\n\t})\n\n\t// Wait for the server to become ready, then restore the log level.\n\tselect {\n\tcase <-env.Etcd.Server.ReadyNotify():\n\t\t// This used to be DebugLevel. It's a lot of noise to sort through and I'm not sure\n\t\t// anyone has ever wanted to read them. Feel free to change this back to DebugLevel\n\t\t// if it helps you, though.\n\t\tlevel.SetLevel(zapcore.InfoLevel)\n\tcase <-time.After(30 * time.Second):\n\t\tt.Fatal(\"etcd did not start after 30 seconds\")\n\t}\n\n\tcfg := log.GetEtcdClientConfig(env.Context)\n\tcfg.Endpoints = []string{clientURL.String()}\n\tcfg.DialOptions = client.DefaultDialOptions()\n\tenv.EtcdClient, err = etcd.New(cfg)\n\trequire.NoError(t, err)\n\tt.Cleanup(func() {\n\t\trequire.NoError(t, env.EtcdClient.Close())\n\t})\n\n\t// TODO: supervise the EtcdClient connection and error the errgroup if they\n\t// go down\n\n\treturn env\n}", "func NewEnv(host string) (Env, error) {\n\n\tconfig := strings.Split(host, \"-\")\n\n\tif len(config) != 3 {\n\t\tlog.Errorf(\"Host %s format is invalid\", host)\n\t\treturn Env{}, fmt.Errorf(service.EnvNotAvailable)\n\t}\n\n\tif strings.Index(config[2], \"env\") > -1 {\n\t\t//check container id and expose port\n\t\tport, err := service.GetEndpoint(config[0], config[1])\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t\treturn Env{}, fmt.Errorf(service.EnvNotAvailable)\n\t\t}\n\t\treturn Env{ContainerID: config[0], Port: port.HostPort, PrivateIP: port.HostIP, Region: config[2]}, nil\n\t} else {\n\t\tlog.Errorf(\"Host %s format is invalid\", host)\n\t\treturn Env{}, fmt.Errorf(service.EnvNotAvailable)\n\t}\n\n}", "func TestNew(t *testing.T) {\n\te := newTestEnvr()\n\tif e.Name != envName {\n\t\tt.Errorf(\".Name = %s, want %s\", e.Name, envName)\n\t}\n\tfor i, v := range testVars {\n\t\tif e.RequiredVars[i] != v {\n\t\t\tt.Errorf(\"RequiredVars[%d] = %s, want %s\", i, e.RequiredVars[i], v)\n\t\t}\n\t}\n}", "func newClassWithEnv(\n\tname string,\n\tsuperClass RubyClass,\n\tinstanceMethods,\n\tclassMethods map[string]RubyMethod,\n\tbuilder func(RubyClassObject, ...RubyObject) (RubyObject, error),\n\tenv Environment,\n) *class {\n\tvar superclassClass RubyClass = classClass\n\tif superClass != nil {\n\t\tsuperclassClass = superClass.(RubyClassObject).Class()\n\t}\n\treturn &class{\n\t\tname: name,\n\t\tsuperClass: superClass,\n\t\tinstanceMethods: NewMethodSet(instanceMethods),\n\t\tclass: newEigenclass(superclassClass, classMethods),\n\t\tbuilder: builder,\n\t\tEnvironment: NewEnclosedEnvironment(env),\n\t}\n}", "func NewWorkspace(name string, environment map[string]string, columns map[string]map[string][]string, inheritEnv bool) *Workspace {\n\tif environment == nil {\n\t\tenvironment = make(map[string]string)\n\t}\n\tws := &Workspace{\n\t\tName: name,\n\t\tEnvironment: environment,\n\t\tTasks: make(map[string]*Task),\n\t\tFunctions: make(map[string]*Function),\n\t\tColumns: columns,\n\t\tInheritEnvironment: inheritEnv,\n\t}\n\tif _, ok := ws.Environment[\"WORKSPACE\"]; !ok {\n\t\tws.Environment[\"WORKSPACE\"] = name\n\t}\n\treturn ws\n}", "func (env *Environment) New(testFn TestFunc) *Fixture {\n\treturn &Fixture{\n\t\tname: runtime.FuncForPC(reflect.ValueOf(testFn).Pointer()).Name(),\n\t\ttestFn: testFn,\n\t\tenv: env,\n\t}\n}", "func NewFinalEnvironment(env *Environment, Ds *HoppingEV) *FinalEnvironment {\n\tDco := Ds.Dco(env)\n\tFreeEnergy := env.FreeEnergy(Ds)\n\tfenv := FinalEnvironment{*env, Dco, FreeEnergy}\n\treturn &fenv\n}", "func NewEnv() (*Env, error) {\n\tvar _env *C.MDB_env\n\tret := C.mdb_env_create(&_env)\n\tif ret != SUCCESS {\n\t\treturn nil, Errno(ret)\n\t}\n\treturn &Env{_env}, nil\n}", "func NewEnvProvider() envProvider {\n\treturn envProvider{}\n}", "func NewLongTermEnvironment(ctx *pulumi.Context,\n\tname string, args *LongTermEnvironmentArgs, opts ...pulumi.ResourceOption) (*LongTermEnvironment, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.Kind == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Kind'\")\n\t}\n\tif args.ResourceGroupName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ResourceGroupName'\")\n\t}\n\tif args.Sku == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Sku'\")\n\t}\n\tif args.StorageConfiguration == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'StorageConfiguration'\")\n\t}\n\tif args.TimeSeriesIdProperties == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'TimeSeriesIdProperties'\")\n\t}\n\targs.Kind = pulumi.String(\"LongTerm\")\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:timeseriesinsights/v20180815preview:LongTermEnvironment\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:timeseriesinsights:LongTermEnvironment\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:timeseriesinsights:LongTermEnvironment\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:timeseriesinsights/v20170228preview:LongTermEnvironment\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:timeseriesinsights/v20170228preview:LongTermEnvironment\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:timeseriesinsights/v20171115:LongTermEnvironment\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:timeseriesinsights/v20171115:LongTermEnvironment\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:timeseriesinsights/v20200515:LongTermEnvironment\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:timeseriesinsights/v20200515:LongTermEnvironment\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource LongTermEnvironment\n\terr := ctx.RegisterResource(\"azure-native:timeseriesinsights/v20180815preview:LongTermEnvironment\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func newTestGlobals() *router.ApplicationGlobals {\n\treturn &router.ApplicationGlobals{\n\t\tStorage: newTestModel(),\n\t\tFetcher: newTestFetcher(),\n\t\tWriter: newResponseWriter(),\n\t}\n}", "func (code *InterpCode) NewContext(cfg *ContextConfig) (ictx Context, err error) {\n\tdefer func() {\n\t\tierr := recover()\n\t\tif ierr == nil {\n\t\t\treturn\n\t\t}\n\t\tif v, ok := ierr.(error); ok {\n\t\t\terr = v\n\t\t}\n\t\terr = fmt.Errorf(\"%s\", ierr)\n\t}()\n\tdefer CaptureTrap(&err)\n\tvm, err := exec.NewVM(code.module,\n\t\texec.WithLazyCompile(true),\n\t\texec.WithGasMapper(new(GasMapper)),\n\t\texec.WithGasLimit(cfg.GasLimit))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvm.RecoverPanic = true\n\tctx := &wagonContext{\n\t\tmodule: code.module,\n\t\tvm: vm,\n\t\tuserData: make(map[string]interface{}),\n\t}\n\tvm.UserData = ctx\n\tictx = ctx\n\treturn\n}", "func newBuildPipeline(t gaia.PipelineType) BuildPipeline {\n\tvar bP BuildPipeline\n\n\t// Create build pipeline for given pipeline type\n\tswitch t {\n\tcase gaia.PTypeGolang:\n\t\tbP = &BuildPipelineGolang{\n\t\t\tType: t,\n\t\t}\n\tcase gaia.PTypeJava:\n\t\tbP = &BuildPipelineJava{\n\t\t\tType: t,\n\t\t}\n\tcase gaia.PTypePython:\n\t\tbP = &BuildPipelinePython{\n\t\t\tType: t,\n\t\t}\n\tcase gaia.PTypeCpp:\n\t\tbP = &BuildPipelineCpp{\n\t\t\tType: t,\n\t\t}\n\tcase gaia.PTypeRuby:\n\t\tbP = &BuildPipelineRuby{\n\t\t\tType: t,\n\t\t}\n\tcase gaia.PTypeNodeJS:\n\t\tbP = &BuildPipelineNodeJS{\n\t\t\tType: t,\n\t\t}\n\t}\n\n\treturn bP\n}", "func (cfg *Config) makeEnv(c context.Context, e *vpython.Environment) (*Env, error) {\n\t// We MUST have a package loader.\n\tif cfg.Loader == nil {\n\t\treturn nil, errors.New(\"no package loader provided\")\n\t}\n\n\t// Resolve our base directory, if one is not supplied.\n\tif cfg.BaseDir == \"\" {\n\t\t// Use one in a temporary directory.\n\t\tcfg.BaseDir = filepath.Join(os.TempDir(), \"vpython\")\n\t\tlogging.Debugf(c, \"Using tempdir-relative environment root: %s\", cfg.BaseDir)\n\t}\n\tif err := filesystem.AbsPath(&cfg.BaseDir); err != nil {\n\t\treturn nil, errors.Annotate(err, \"failed to resolve absolute path of base directory\").Err()\n\t}\n\n\t// Enforce maximum path length.\n\tif cfg.MaxScriptPathLen > 0 {\n\t\tif longestPath := longestGeneratedScriptPath(cfg.BaseDir); longestPath != \"\" {\n\t\t\tlongestPathLen := utf8.RuneCountInString(longestPath)\n\t\t\tif longestPathLen > cfg.MaxScriptPathLen {\n\t\t\t\treturn nil, errors.Reason(\n\t\t\t\t\t\"expected deepest path length (%d) exceeds threshold (%d)\",\n\t\t\t\t\tlongestPathLen, cfg.MaxScriptPathLen,\n\t\t\t\t).InternalReason(\"longestPath(%q)\", longestPath).Err()\n\t\t\t}\n\t\t}\n\t}\n\n\t// Construct a new, independent Environment for this Env.\n\te = e.Clone()\n\tif cfg.Spec != nil {\n\t\te.Spec = cfg.Spec.Clone()\n\t}\n\tif err := spec.NormalizeEnvironment(e); err != nil {\n\t\treturn nil, errors.Annotate(err, \"invalid environment\").Err()\n\t}\n\n\t// If the environment doesn't specify a VirtualEnv package (expected), use\n\t// our default.\n\tif e.Spec.Virtualenv == nil {\n\t\te.Spec.Virtualenv = &cfg.Package\n\t}\n\n\tif err := cfg.Loader.Resolve(c, e); err != nil {\n\t\treturn nil, errors.Annotate(err, \"failed to resolve packages\").Err()\n\t}\n\n\tif err := cfg.resolvePythonInterpreter(c, e.Spec); err != nil {\n\t\treturn nil, errors.Annotate(err, \"failed to resolve system Python interpreter\").Err()\n\t}\n\te.Runtime.Path = cfg.si.Python\n\te.Runtime.Version = e.Spec.PythonVersion\n\n\tvar err error\n\tif e.Runtime.Hash, err = cfg.si.Hash(); err != nil {\n\t\treturn nil, err\n\t}\n\tlogging.Debugf(c, \"Resolved system Python runtime (%s @ %s): %s\",\n\t\te.Runtime.Version, e.Runtime.Hash, e.Runtime.Path)\n\n\t// Ensure that our base directory exists.\n\tif err := filesystem.MakeDirs(cfg.BaseDir); err != nil {\n\t\treturn nil, errors.Annotate(err, \"could not create environment root: %s\", cfg.BaseDir).Err()\n\t}\n\n\t// Generate our environment name based on the deterministic hash of its\n\t// fully-resolved specification.\n\tenvName := cfg.OverrideName\n\tif envName == \"\" {\n\t\tenvName = cfg.envNameForSpec(e.Spec, e.Runtime)\n\t}\n\tenv := cfg.envForName(envName, e)\n\treturn env, nil\n}", "func newTestEnvr() *Envr {\n\tfor _, v := range testVars {\n\t\tif err := os.Unsetenv(v); err != nil {\n\t\t\tlog.Fatalf(\"os.Unsetenv() err = %s\", err)\n\t\t}\n\t}\n\treturn New(envName, testVars)\n}", "func NewEnv() *Env {\n\treturn &Env{\n\t\tos.Getenv(clusterRoot),\n\t\tos.Getenv(kubeConfig),\n\t}\n}", "func makeTestEnv(t *testing.T, name string) testEnv {\n\tctx := context.Background()\n\n\tlocalRegistry, err := storage.NewRegistry(ctx, inmemory.New(), storage.BlobDescriptorCacheProvider(memory.NewInMemoryBlobDescriptorCacheProvider()), storage.EnableRedirect, storage.DisableDigestResumption)\n\tif err != nil {\n\t\tt.Fatalf(\"error creating registry: %v\", err)\n\t}\n\tlocalRepo, err := localRegistry.Repository(ctx, name)\n\tif err != nil {\n\t\tt.Fatalf(\"unexpected error getting repo: %v\", err)\n\t}\n\n\ttruthRegistry, err := storage.NewRegistry(ctx, inmemory.New(), storage.BlobDescriptorCacheProvider(memory.NewInMemoryBlobDescriptorCacheProvider()))\n\tif err != nil {\n\t\tt.Fatalf(\"error creating registry: %v\", err)\n\t}\n\ttruthRepo, err := truthRegistry.Repository(ctx, name)\n\tif err != nil {\n\t\tt.Fatalf(\"unexpected error getting repo: %v\", err)\n\t}\n\n\ttruthBlobs := statsBlobStore{\n\t\tstats: make(map[string]int),\n\t\tblobs: truthRepo.Blobs(ctx),\n\t}\n\n\tlocalBlobs := statsBlobStore{\n\t\tstats: make(map[string]int),\n\t\tblobs: localRepo.Blobs(ctx),\n\t}\n\n\ts := scheduler.New(ctx, inmemory.New(), \"/scheduler-state.json\")\n\n\tproxyBlobStore := proxyBlobStore{\n\t\tremoteStore: truthBlobs,\n\t\tlocalStore: localBlobs,\n\t\tscheduler: s,\n\t}\n\n\tte := testEnv{\n\t\tstore: proxyBlobStore,\n\t\tctx: ctx,\n\t}\n\treturn te\n}", "func New(t *testing.T, cfg Config) *Environment {\n\te := &Environment{\n\t\thelmPath: \"../kubernetes_helm/helm\",\n\t\tsynkPath: \"src/go/cmd/synk/synk_/synk\",\n\t\tt: t,\n\t\tcfg: cfg,\n\t\tscheme: k8sruntime.NewScheme(),\n\t\tclusters: map[string]*cluster{},\n\t}\n\tif cfg.SchemeFunc != nil {\n\t\tcfg.SchemeFunc(e.scheme)\n\t}\n\tscheme.AddToScheme(e.scheme)\n\n\tvar g errgroup.Group\n\t// Setup cluster concurrently.\n\tfor _, cfg := range cfg.Clusters {\n\t\t// Make name unique to avoid collisions across parallel tests.\n\t\tuniqName := fmt.Sprintf(\"%s-%x\", cfg.Name, time.Now().UnixNano())\n\t\tt.Logf(\"Assigned unique name %q to cluster %q\", uniqName, cfg.Name)\n\n\t\tcluster := &cluster{\n\t\t\tgenName: uniqName,\n\t\t\tcfg: cfg,\n\t\t}\n\t\te.clusters[cfg.Name] = cluster\n\n\t\tg.Go(func() error {\n\t\t\tif err := setupCluster(e.synkPath, cluster); err != nil {\n\t\t\t\t// If cluster has already been created, delete it.\n\t\t\t\tif cluster.kind != nil && os.Getenv(\"NO_TEARDOWN\") == \"\" {\n\t\t\t\t\tcluster.kind.Delete(cfg.Name, \"\")\n\t\t\t\t\tif cluster.kubeConfigPath != \"\" {\n\t\t\t\t\t\tos.Remove(cluster.kubeConfigPath)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn errors.Wrapf(err, \"Create cluster %q\", cfg.Name)\n\t\t\t}\n\t\t\tlog.Printf(\"Created cluster %q\", cfg.Name)\n\t\t\treturn nil\n\t\t})\n\t}\n\tif err := g.Wait(); err != nil {\n\t\tt.Fatal(err)\n\t}\n\treturn e\n}", "func NewTestContext(t *testing.T) *TestContext {\n\t// Provide a way for tests to provide and capture stdin and stdout\n\t// Copy output to the test log simultaneously, use go test -v to see the output\n\terr := &bytes.Buffer{}\n\taggErr := io.MultiWriter(err, test.Logger{T: t})\n\tout := &bytes.Buffer{}\n\taggOut := io.MultiWriter(out, test.Logger{T: t})\n\n\tinnerContext := New()\n\tinnerContext.correlationId = \"0\"\n\tinnerContext.timestampLogs = false\n\tinnerContext.environ = getEnviron()\n\tinnerContext.FileSystem = aferox.NewAferox(\"/\", afero.NewMemMapFs())\n\tinnerContext.In = &bytes.Buffer{}\n\tinnerContext.Out = aggOut\n\tinnerContext.Err = aggErr\n\tinnerContext.ConfigureLogging(context.Background(), LogConfiguration{\n\t\tLogLevel: zapcore.DebugLevel,\n\t\tVerbosity: zapcore.DebugLevel,\n\t})\n\tinnerContext.PlugInDebugContext = &PluginDebugContext{\n\t\tDebuggerPort: \"2735\",\n\t\tRunPlugInInDebugger: \"\",\n\t\tPlugInWorkingDirectory: \"\",\n\t}\n\n\tc := &TestContext{\n\t\tContext: innerContext,\n\t\tcapturedOut: out,\n\t\tcapturedErr: err,\n\t\tT: t,\n\t}\n\n\tc.NewCommand = c.NewTestCommand\n\n\treturn c\n}", "func NewEnvironmentProvider() *EnvironmentProvider {\n\treturn &EnvironmentProvider{\n\t\tlookup: os.LookupEnv,\n\t}\n}", "func (client *Client) NewSharedEnvironment(bucketKey string, environment Environment) (Environment, error) {\n\tvar newEnvironment = Environment{}\n\n\tpath := fmt.Sprintf(\"buckets/%s/environments\", bucketKey)\n\tdata, err := json.Marshal(&environment)\n\tif err != nil {\n\t\treturn newEnvironment, err\n\t}\n\n\tcontent, err := client.Post(path, data)\n\tif err != nil {\n\t\treturn newEnvironment, err\n\t}\n\n\terr = unmarshal(content, &newEnvironment)\n\treturn newEnvironment, err\n}", "func newScope(parent *scope) scope {\n\treturn scope{objects: map[string]objectAndSource{}, parent: parent}\n}", "func (env *Environment) Clone() ext.Environment {\n\tclone := NewEnvironment()\n\tclone.goCallbacks = env.goCallbacks\n\treturn clone\n}", "func execNewScope(_ int, p *gop.Context) {\n\targs := p.GetArgs(4)\n\tret := types.NewScope(args[0].(*types.Scope), token.Pos(args[1].(int)), token.Pos(args[2].(int)), args[3].(string))\n\tp.Ret(4, ret)\n}", "func NewEnvStorage(prefix string, uppercase bool) *EnvStorage {\n\tes := &EnvStorage{prefix, uppercase}\n\tstorage = es\n\treturn es\n}", "func (client LabClient) CreateEnvironment(ctx context.Context, resourceGroupName string, name string, labVirtualMachine LabVirtualMachine) (result LabCreateEnvironmentFuture, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/LabClient.CreateEnvironment\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response() != nil {\n\t\t\t\tsc = result.Response().StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\treq, err := client.CreateEnvironmentPreparer(ctx, resourceGroupName, name, labVirtualMachine)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"dtl.LabClient\", \"CreateEnvironment\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresult, err = client.CreateEnvironmentSender(req)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"dtl.LabClient\", \"CreateEnvironment\", result.Response(), \"Failure sending request\")\n\t\treturn\n\t}\n\n\treturn\n}", "func NewType() Type {}", "func NewEnvProvider(pub *ecdsa.PublicKey, session conf.SessionInterface, client v1auth.TokenClientInterface) *EnvProvider {\n\treturn &EnvProvider{\n\t\tProviderBasis: &ProviderBasis{\n\t\t\tExpireWindow: DefaultExpireWindow,\n\t\t\tPub: pub,\n\t\t},\n\t\tSession: session,\n\t\tClient: client,\n\t}\n}", "func NewInterpreter(lox *Lox, global env) Interpreter {\n\tinterpreter := Interpreter{\n\t\tlox,\n\t\tglobal,\n\t\tglobal,\n\t\tmake(map[Expr]int, 0),\n\t}\n\n\tinterpreter.init()\n\treturn interpreter\n}" ]
[ "0.6802027", "0.6662787", "0.6633159", "0.6615684", "0.6584132", "0.657267", "0.6483676", "0.6449514", "0.6449514", "0.6340193", "0.62803227", "0.6262485", "0.6236817", "0.6187867", "0.61719394", "0.61681217", "0.61587524", "0.61014456", "0.60950303", "0.6028156", "0.6007955", "0.598239", "0.5940723", "0.5926037", "0.58576983", "0.5851898", "0.58388686", "0.58104336", "0.5809", "0.57580715", "0.5735858", "0.56955254", "0.56705415", "0.56609523", "0.5650344", "0.5643218", "0.559436", "0.5481446", "0.54764366", "0.5461393", "0.54553026", "0.54057974", "0.5385194", "0.53761625", "0.53344643", "0.5317075", "0.53095263", "0.5210989", "0.5185879", "0.5114672", "0.5107421", "0.51028216", "0.509882", "0.50582486", "0.50445503", "0.5043563", "0.5041337", "0.5035036", "0.49907923", "0.4979247", "0.4974648", "0.4974648", "0.49704933", "0.49640328", "0.49542436", "0.4939402", "0.4930497", "0.49216104", "0.49195525", "0.4916684", "0.49119532", "0.49058124", "0.48884198", "0.48872113", "0.48851854", "0.48557413", "0.48542297", "0.48530164", "0.4847718", "0.48386425", "0.4834988", "0.48337156", "0.48288724", "0.48269606", "0.48245615", "0.48208556", "0.4808768", "0.48065257", "0.47979945", "0.4794312", "0.4790062", "0.47896102", "0.47895336", "0.47837305", "0.478256", "0.47699955", "0.47683263", "0.4768155", "0.4755569", "0.47555262" ]
0.727
0
EmailExists check if a given email is found
func (pr *PsqlDonorRepository) EmailExists(email string) bool { var name string err := pr.conn.QueryRow("SELECT firstname FROM donor WHERE email=$1", email).Scan(&name) if err != nil { return false } return true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func EmailExists(e string) bool {\n\tsqlStmt := `SELECT \n\t\t\t\t\tfldEmail \n\t\t\t\tFROM tblUsers \n\t\t\t\tWHERE fldEmail = ?;`\n\n\tstmt, err := globals.Db.Prepare(sqlStmt)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer stmt.Close()\n\n\tvar email string\n\terr = stmt.QueryRow(e).Scan(&email)\n\tif err != nil {\n\t\t// No rows found\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn false\n\t\t}\n\t\t// Something else went wrong\n\t\tlog.Fatal(err)\n\t}\n\n\treturn true\n}", "func (pr *PsqlRecipientRepository) EmailExists(email string) bool {\n\tvar name string\n\terr := pr.conn.QueryRow(\"SELECT firstname FROM recipient WHERE email=$1\",email).Scan(&name)\n\n\tif err != nil {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (repo UserRepository) EmailExists(email string) bool {\n\temailLowercase := strings.ToLower(email)\n\tuserCount, _ := repo.c.Find(bson.M{\"email\": emailLowercase}).Count()\n\treturn userCount > 0\n}", "func DoesEmailExist(email string) (bool, error) {\n\n\tlog.Printf(\"helper\t|\tchecking email %s exists\\n\", email)\n\n\tquery := \"SELECT * FROM users WHERE email=$1;\"\n\n\tif rows, err := config.DB.Query(context.Background(), query, email); err != nil {\n\t\treturn false, err\n\t} else {\n\n\t\t// Don't forget to close the rows after calling Query()\n\t\tdefer rows.Close()\n\n\t\tfor rows.Next() {\n\t\t\t// If enters the loop it means email exists in the database, hence return true\n\t\t\treturn true, nil\n\t\t}\n\n\t\t// If control reaches here, email doesn't exist\n\t\treturn false, nil\n\t}\n\n}", "func (jss *CompanyGormRepositoryImpl) EmailExists(email string) bool {\n\tuser := entity.Company{}\n\terrs := jss.conn.Find(&user, \"email=?\", email).GetErrors()\n\tif len(errs) > 0 {\n\t\treturn false\n\t}\n\treturn true\n}", "func EmailExists(ctx context.Context, exec boil.ContextExecutor, iD int64) (bool, error) {\n\tvar exists bool\n\tsql := \"select exists(select 1 from `email` where `id`=? limit 1)\"\n\n\tif boil.DebugMode {\n\t\tfmt.Fprintln(boil.DebugWriter, sql)\n\t\tfmt.Fprintln(boil.DebugWriter, iD)\n\t}\n\n\trow := exec.QueryRowContext(ctx, sql, iD)\n\n\terr := row.Scan(&exists)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"mysql: unable to check if email exists\")\n\t}\n\n\treturn exists, nil\n}", "func CheckExistingEmail(email string) (bool, error) {\n\tdb, err := sql.Open(\"mysql\", os.Getenv(\"MYSQL_CONNECT_STR\"))\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer db.Close()\n\tstmt, err := db.Prepare(\"SELECT email FROM user WHERE email=? LIMIT 1\")\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tdefer stmt.Close()\n\tvar emailFromDB []byte\n\terr = stmt.QueryRow(email).Scan(&emailFromDB)\n\tif err == sql.ErrNoRows {\n\t\treturn false, nil\n\t}\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func IsExistingEmail(email string) bool {\n\n\tif len(email) < 6 || len(email) > 254 {\n\t\treturn false\n\t}\n\tat := strings.LastIndex(email, \"@\")\n\tif at <= 0 || at > len(email)-3 {\n\t\treturn false\n\t}\n\tuser := email[:at]\n\thost := email[at+1:]\n\tif len(user) > 64 {\n\t\treturn false\n\t}\n\tif userDotRegexp.MatchString(user) || !userRegexp.MatchString(user) || !hostRegexp.MatchString(host) {\n\t\treturn false\n\t}\n\tswitch host {\n\tcase \"localhost\", \"example.com\":\n\t\treturn true\n\t}\n\tif _, err := net.LookupMX(host); err != nil {\n\t\tif _, err := net.LookupIP(host); err != nil {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func CheckEmailExists(email string) (bool, error) {\n\t// Check if the email address is already in our system\n\tdbQuery := `\n\t\tSELECT count(user_name)\n\t\tFROM users\n\t\tWHERE email = $1`\n\tvar emailCount int\n\terr := pdb.QueryRow(dbQuery, email).Scan(&emailCount)\n\tif err != nil {\n\t\tlog.Printf(\"Database query failed: %v\\n\", err)\n\t\treturn true, err\n\t}\n\tif emailCount == 0 {\n\t\t// Email address isn't yet in our system\n\t\treturn false, nil\n\t}\n\n\t// Email address IS already in our system\n\treturn true, nil\n\n}", "func (u *UserService) CheckEmail(email string) (bool, error) {\n\tvar ok bool\n\terr := u.QueryRow(\"SELECT EXISTS (SELECT 1 FROM users WHERE email=$1)\", email).Scan(&ok)\n\treturn ok, err\n}", "func ExistEmail(email string) bool {\n\tdb := GetConnect()\n\tdefer db.Close()\n\n\tuserr := db.Model(new(Userr)).Where(\"email = ?\", email).Select()\n\treturn userr == nil\n}", "func EmailExist(email string) bool {\n\torm := get_DBFront()\n\tvar user User\n\terr := orm.SetTable(\"user\").Where(\"email=?\", email).Find(&user)\n\tif !check_err(err) {\n\t\tLog(Log_Struct{\"error\", \"DB_Error_Line_199\", err})\n\t\treturn false\n\t}\n\treturn true\n}", "func (adminrepo *AdminRepo) AdminEmailExist( email string ) error{\n\tfilter := bson.D{{\"email\", email}}\n\treturn adminrepo.DB.Collection( entity.ADMIN ).FindOne(context.TODO(), filter).Err()\n}", "func checkUserByEmail(email string) bool {\n\trows, err := db.Query(\"SELECT * FROM users WHERE email = $1;\", email)\n\tif err != nil {\n\t\tfmt.Println(\"error in checkUserByEmail\")\n\t}\n\tdefer rows.Close()\n\n\t// return true if user is found\n\treturn rows.Next()\n}", "func CheckEmail(email string) bool {\n\tif len(email) == 0 {\n\t\treturn false\n\t}\n\tvar count int\n\tmodels.ORM.Model(models.User{}).Where(\"email = ?\", email).Count(&count)\n\n\treturn count != 0\n}", "func (database *Database) IsEmailRegistered(email string) (bool, string, error) {\n\ttx, err := database.db.Begin(false)\n\tif err != nil {\n\t\treturn false, \"\", err\n\t}\n\n\tuserID, err := tx.Get(fmt.Sprintf(EmailToUser, email))\n\t_ = tx.Rollback()\n\tif err == buntdb.ErrNotFound {\n\t\treturn false, \"\", nil\n\t} else if err != nil {\n\t\treturn false, \"\", err\n\t} else {\n\t\treturn true, userID, nil\n\t}\n}", "func checkEmail(mode bool, email string) error {\r\n\tfilter := bson.M{\"email\": email}\r\n\tres, e := db.GetOneByFilter(db.GetUsersColl(), filter)\r\n\tif res != nil && e == nil && res[\"email\"] == email {\r\n\t\tif !mode {\r\n\t\t\treturn errors.New(\"this email is not empty\")\r\n\t\t} else if mode && !res[\"ok\"].(bool) {\r\n\t\t\treturn errors.New(\"you are not valid your account\")\r\n\t\t} else if mode && res[\"ok\"].(bool) {\r\n\t\t\treturn nil\r\n\t\t}\r\n\t}\r\n\tif mode {\r\n\t\treturn errors.New(\"this email is not correct\")\r\n\t}\r\n\treturn nil\r\n}", "func (dbservice *UserDbservice) CheckUserByEmail(email string) (bool, error) {\n\tuser := &( model.User{})\n\tresult := dbservice.DbConnection.Where(\"email = ?\", email).First(&user)\n\tif errors.Is(result.Error, gorm.ErrRecordNotFound) {\n\t\treturn false, nil\n\t}\n\treturn true, result.Error\n}", "func (q emailQuery) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error) {\n\tvar count int64\n\n\tqueries.SetSelect(q.Query, nil)\n\tqueries.SetCount(q.Query)\n\tqueries.SetLimit(q.Query, 1)\n\n\terr := q.Query.QueryRowContext(ctx, exec).Scan(&count)\n\tif err != nil {\n\t\treturn false, errors.Wrap(err, \"mysql: failed to check if email exists\")\n\t}\n\n\treturn count > 0, nil\n}", "func (sp *ScyllaUserProvider) Exists(email string) (bool, derrors.Error) {\n\n\tsp.Lock()\n\tdefer sp.Unlock()\n\n\tvar returnedEmail string\n\n\t// check connection\n\tif err := sp.checkAndConnect(); err != nil {\n\t\treturn false, err\n\t}\n\n\tstmt, names := qb.Select(userTable).Columns(userTablePK).Where(qb.Eq(userTablePK)).ToCql()\n\tq := gocqlx.Query(sp.Session.Query(stmt), names).BindMap(qb.M{\n\t\tuserTablePK: email})\n\n\terr := q.GetRelease(&returnedEmail)\n\tif err != nil {\n\t\tif err.Error() == rowNotFound {\n\t\t\treturn false, nil\n\t\t} else {\n\t\t\treturn false, derrors.AsError(err, \"cannot determinate if user exists\")\n\t\t}\n\t}\n\n\tstmt, names = qb.Select(userPhotoTable).Columns(userPhotoTablePK).Where(qb.Eq(userPhotoTablePK)).ToCql()\n\tq = gocqlx.Query(sp.Session.Query(stmt), names).BindMap(qb.M{\n\t\tuserPhotoTablePK: email})\n\n\terr = q.GetRelease(&returnedEmail)\n\tif err != nil {\n\t\tif err.Error() == rowNotFound {\n\t\t\treturn false, nil\n\t\t} else {\n\t\t\treturn false, derrors.AsError(err, \"there seems to be an issue with the user in the userphotos table\")\n\t\t}\n\t}\n\n\treturn true, nil\n}", "func (m *MultiDB) ExistingEmail(email string) bool {\n\tresult := m.isExisting(\"Email\", email)\n\treturn result\n}", "func (uv *userValidator) emailIsAvail(user *User) error {\n\texisting, err := uv.ByEmail(user.Email)\n\tif err == ErrNotFound {\n\t\t// Email address is available if we don't find\n\t\t// a user with that email address.\n\t\treturn nil\n\t}\n\t// We can't continue our validation without a successful\n\t// query, so if we get any error other than ErrNotFound we\n\t// should return it.\n\tif err != nil {\n\t\treturn err\n\t}\n\t// If we get here that means we found a user w/ this email\n\t// address, so we need to see if this is the same user we\n\t// are updating, or if we have a conflict.\n\tif user.ID != existing.ID {\n\t\treturn ErrEmailTaken\n\t}\n\treturn nil\n}", "func IsEmailAlreadyExists(err error) bool {\n\treturn internal.HasErrorCode(err, emailAlreadyExists)\n}", "func (p *Plex) CheckUsernameOrEmail(usernameOrEmail string) (bool, error) {\n\trequestInfo.headers.Token = p.token\n\n\tusernameOrEmail = url.QueryEscape(usernameOrEmail)\n\n\tquery := fmt.Sprintf(\"%s/api/users/validate?invited_email=%s\", plexURL, usernameOrEmail)\n\n\tresp, respErr := requestInfo.post(query, nil)\n\n\tif respErr != nil {\n\t\treturn false, respErr\n\t}\n\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 && resp.StatusCode != 400 {\n\t\treturn false, errors.New(resp.Status)\n\t}\n\n\tresult := new(resultResponse)\n\n\tif err := xml.NewDecoder(resp.Body).Decode(result); err != nil {\n\t\treturn false, err\n\t}\n\n\treturn result.Code == 0, nil\n}", "func EmailMatch(username, email string) bool {\n\torm := get_DBFront()\n\tvar user User\n\terr := orm.SetTable(\"user\").Where(\"username=?\", username).Find(&user)\n\tif !check_err(err) {\n\t\tLog(Log_Struct{\"error\", \"DB_Error_Line_231\", err})\n\t\treturn false\n\t}\n\n\tif user.Email == email {\n\t\treturn true\n\t}\n\treturn false\n}", "func (r *PostgresUserRepository) CheckUserExists(email string) (bool, error) {\n\tuser := new(models.User)\n\n\trow := r.db.QueryRow(\"SELECT * FROM user WHERE email=?\", email)\n\terr := row.Scan(&user.Id, &user.Email, &user.Name, &user.NotificationEndpoint)\n\n\tswitch {\n\tcase err == sql.ErrNoRows:\n\t\treturn false, err\n\tcase err != nil:\n\t\tlog.Fatal(err)\n\t\treturn true, err\n\t}\n\treturn true, nil\n}", "func FindEmail(c *fiber.Ctx) error {\n\tvar req dto.SendEmail\n\tif err := c.BodyParser(&req); err != nil {\n\t\tgetStatus(c, 422, err)\n\t} else {\n\t\tresp := service.FindIfEmailExists(req.Email)\n\t\tif resp.Status != true {\n\t\t\tgetStatus(c, 500, resp)\n\t\t} else {\n\t\t\tgetStatus(c, 200, resp)\n\t\t}\n\t}\n\treturn nil\n}", "func Email(email string) bool {\n\t// TODO: Add email check\n\treturn email != \"\"\n}", "func IsEmail(val interface{}) bool {\n\treturn isMatch(email, val)\n}", "func (o *UserDisco) HasEmail() bool {\n\tif o != nil && o.Email != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func EmailContains(v string) predicate.User {\n\treturn predicate.User(sql.FieldContains(FieldEmail, v))\n}", "func IsEmail(email string) bool {\n\tregexEmail := regexp.MustCompile(regexEmailPattern)\n\treturn regexEmail.MatchString(email)\n}", "func validateEmail(email string) bool {\n\treturn regx.Email.MatchString(email)\n}", "func EmailContains(v string) predicate.Patient {\n\treturn predicate.Patient(func(s *sql.Selector) {\n\t\ts.Where(sql.Contains(s.C(FieldEmail), v))\n\t})\n}", "func CheckUserExists(email string) (models.User, bool, string) {\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\tdefer cancel()\n\n\tdb := MongoConnection.Database(\"cardinal\")\n\tusers := db.Collection(\"users\")\n\n\tcondition := bson.M{\"email\": email}\n\tvar result models.User\n\terr := users.FindOne(ctx, condition).Decode(&result)\n\tID := result.ID.Hex()\n\tif err != nil {\n\t\treturn result, false, ID\n\t}\n\treturn result, true, ID\n}", "func IsValidEmail(email string) bool {\n\treturn emailPattern.MatchString(email)\n}", "func userExist(mail string) bool {\n count, err := db.user.Find(bson.M{\"mail\": mail}).Count()\n if err != nil || count != 0 {\n return true\n }\n return false\n}", "func EmailContains(v string) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.Contains(s.C(FieldEmail), v))\n\t})\n}", "func EmailContains(v string) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.Contains(s.C(FieldEmail), v))\n\t})\n}", "func EmailContains(v string) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.Contains(s.C(FieldEmail), v))\n\t})\n}", "func EmailContains(v string) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.Contains(s.C(FieldEmail), v))\n\t})\n}", "func (p *Person) HasEmail() bool {\n\tif len(p.Emails) > 0 {\n\t\tfor _, email := range p.Emails {\n\t\t\tif email.Address != \"\" {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}", "func Valid_email(email string) bool {\n _, err := mail.ParseAddress(email)\n return err == nil\n}", "func IsUserExist(qr db.Queryer, email string) bool {\n\tstr := \"SELECT count(*) as cnt FROM users WHERE email = ?\"\n\tuid := int64(0)\n\terr := qr.Get(&uid, str, email)\n\tif err != nil {\n\t\tlog.Println(\"err\", err)\n\t\treturn false\n\t}\n\tlog.Println(\"uid\", err)\n\tif uid > 0 {\n\t\treturn true\n\t}\n\n\treturn false\n\n}", "func VerifyEmail(w http.ResponseWriter, r *http.Request) {\n\tvalidationKey := strings.Split(r.RequestURI, \"/\")[2]\n\tstmt, _ := db.Prepare(\"select username, email, password from signup where validationKey = ?\")\n\tvar username string\n\tvar email string\n\tvar password string\n\tres := stmt.QueryRow(validationKey)\n\terr := res.Scan(&username, &email, &password)\n\tif err != nil {\n\t\thttp.Redirect(w, r, \"/validationFailed\", 302)\n\t}\n\tlog.Println(\"Validating Email\")\n\tstmt, _ = db.Prepare(\"insert into users (username, email, password) values (?,?,?)\")\n\trow, err := stmt.Exec(username, email, password)\n\tif err == nil {\n\t\tid64, _ := row.LastInsertId()\n\t\tid := int(id64)\n\t\t// Login user and delete signup record\n\t\tvar sess session.Store\n\t\tsessionCookie, err := r.Cookie(\"session_id\")\n\t\tif err == nil {\n\t\t\tsess, _ = globalSessions.GetSessionStore(sessionCookie.Value)\n\t\t} else {\n\t\t\tsess, _ = globalSessions.SessionStart(w, r)\n\t\t}\n\t\tdefer sess.SessionRelease(w)\n\n\t\t_ = sess.Set(\"user_id\", id)\n\t\t_ = sess.Set(\"username\", username)\n\t\tsetUserCookies(w, id, sess.SessionID())\n\t\tsaveSession(w, r, sess.SessionID(), id)\n\t\taddRemoteAddress(r, id)\n\t\tdb.Prepare(\"delete from signup where validationKey = ?\")\n\t\tdb.Exec(validationKey)\n\t\thttp.Redirect(w, r, \"/\", 302)\n\t} else {\n\t\tlog.Println(err)\n\t}\n}", "func IsEmail(s string) bool {\n\treturn s != \"\" && rxEmail.MatchString(s)\n}", "func IsUserEmailInDb(u *User) (bool, int64) {\n\trows := db.DbClient.QueryRow(`select user_id from reg_users where email=$1;`, u.Email)\n\tvar user = User{}\n\tvar isUser bool\n\tisUser = false\n\tswitch err := rows.Scan(&user.ID); err {\n\tcase sql.ErrNoRows:\n\t\tlog.Warn(\"User not found\")\n\tcase nil:\n\t\tlog.Warn(\"User found\")\n\t\tisUser = true\n\tdefault:\n\t\tlog.Error(\"Error getting user \", err)\n\t\tisUser = true\n\t}\n\treturn isUser, user.ID\n}", "func IsValidEmail(email string) bool {\n\treturn emailRegex.MatchString(email)\n}", "func (dao *DAO) UserExists(email string) (bool, error) {\r\n\tn, err := db.C(dao.UserCollection).Find(bson.M{\"email\": email}).Limit(1).Count()\r\n\r\n\tif err != nil && err != mgo.ErrNotFound {\r\n\t\treturn true, err\r\n\t}\r\n\r\n\tif n > 0 {\r\n\t\treturn true, nil\r\n\t}\r\n\r\n\treturn false, nil\r\n}", "func isTestEmail(email string) bool {\n\tfor _, suf := range []string{\"@example.com\", \"@example.net\", \"@example.org\"} {\n\t\tif strings.HasSuffix(email, suf) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (uv *userValidator) emailAvailable(user *User) error {\n\texistingUser, err := uv.ByEmail(user.Email)\n\t//Email address is available if we don't find a user\n\tif err == ErrNotFound {\n\t\treturn nil\n\t}\n\n\t//Legitimate lookup error\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// If we get here that means we found a user with this email\n\t// address, so we need to see if this is the same user we\n\t// are updating, or if we have a conflict.\n\t//check if this is the same user trying to update their email\n\tif existingUser.ID == user.ID {\n\t\treturn nil\n\t}\n\t//if its not the same user, then someone is trying to get an email\n\t//that exists\n\treturn ErrEmailTaken\n}", "func EmailHasSuffix(v string) predicate.Patient {\n\treturn predicate.Patient(func(s *sql.Selector) {\n\t\ts.Where(sql.HasSuffix(s.C(FieldEmail), v))\n\t})\n}", "func UserExists(db *sql.DB, email string) (bool, error) {\n\tvar count int64\n\tif err := db.QueryRow(`select count(*) as count from users where email = ?`, email).Scan(&count); err != nil {\n\t\treturn false, err\n\t}\n\treturn count == 1, nil\n}", "func Email(s string) bool {\n\treturn regexFactory(`\\A[\\w\\d\\.]{3,}@[\\w\\d]+\\.[\\w]{2,}\\z`, s)\n}", "func (d UserData) HasEmail() bool {\n\treturn d.ModelData.Has(models.NewFieldName(\"Email\", \"email\"))\n}", "func EmailHasSuffix(v string) predicate.User {\n\treturn predicate.User(sql.FieldHasSuffix(FieldEmail, v))\n}", "func isValidEmail(input string) bool {\n\n\tindex := strings.Index(input, \"@\")\n\tif index < 1 {\n\t\treturn false\n\t}\n\n\tindex = strings.Index(input[index:], \".\")\n\tif index < 1 {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (o *ModelsUser) HasEmail() bool {\n\tif o != nil && o.Email != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func ValidEmail(email string) (err error) {\n\tconst apiURL = \"https://isitarealemail.com/api/email/validate?email=\"\n\n\turl := apiURL + url.QueryEscape(email)\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn ErrEmailVerifFail.Wrap(err)\n\t}\n\n\tdefer res.Body.Close()\n\n\tbody, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn ErrEmailVerifFail.Wrap(err)\n\t}\n\n\tvar es EmailStatus\n\terr = json.Unmarshal(body, &es)\n\tif err != nil {\n\t\treturn ErrEmailVerifFail.Wrap(err)\n\t}\n\n\tif es.Status != \"valid\" {\n\t\treturn ErrInvalidEmail\n\t}\n\n\treturn nil\n}", "func ValidateEmail(email string) bool {\n\treturn emailRegexp.MatchString(email)\n}", "func (user *User) FindByEmail(email string) (err error) {\n\terr = database.SQL.QueryRow(\"SELECT id, name, email, password FROM users WHERE deleted_at is null AND email = $1\", email).Scan(&user.ID, &user.Name, &user.Email, &user.Password)\n\treturn err\n}", "func EmailHasSuffix(v string) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.HasSuffix(s.C(FieldEmail), v))\n\t})\n}", "func EmailHasSuffix(v string) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.HasSuffix(s.C(FieldEmail), v))\n\t})\n}", "func EmailHasSuffix(v string) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.HasSuffix(s.C(FieldEmail), v))\n\t})\n}", "func EmailHasSuffix(v string) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.HasSuffix(s.C(FieldEmail), v))\n\t})\n}", "func TestEmailExists(t *testing.T) {\n handle := \"test_handleexists\"\n email := \"test_handleexists@test.com\"\n\n var account UserAccount\n if err := Create(handle, email, \"timisadork\", &account); err != nil {\n t.Error(err)\n }\n\n if err := EmailExists(email); err == nil {\n t.Error(\"Handle exists failed\")\n }\n\n if err := Delete(account.Key); err != nil {\n t.Error(err)\n }\n}", "func (o *MemberResponse) HasEmail() bool {\n\tif o != nil && o.Email != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (u *User) FindByEmail(tx *pop.Connection, email string) error {\n\tif err := tx.Where(\"email = ?\", email).First(u); err != nil {\n\t\treturn fmt.Errorf(\"error finding user by email: %s, ... %s\",\n\t\t\temail, err.Error())\n\t}\n\n\treturn nil\n}", "func ValidateEmail(email string) bool {\n\tif !mailRegexp.MatchString(email){\n\t\treturn false\n\t}\n\treturn true\n}", "func tokenEmail(s string) (string, bool) {\n\tjwt, err := token.ParseInsecure(s)\n\tif err != nil {\n\t\treturn \"\", false\n\t}\n\treturn jwt.Payload.Email, jwt.Payload.Email != \"\"\n}", "func (obj *MessengerUser) HasEmail() bool {\n\tproxyResult := /*pr4*/ C.vssq_messenger_user_has_email(obj.cCtx)\n\n\truntime.KeepAlive(obj)\n\n\treturn bool(proxyResult) /* r9 */\n}", "func ValidateEmail(r *http.Request, name string) bool {\n\treturn ValidateString(r, name, validEmail)\n}", "func validateEmail(email string) bool {\n\tRe := regexp.MustCompile(`^[a-z0-9._%+\\-]+@[a-z0-9.\\-]+\\.[a-z]{2,4}$`)\n\treturn Re.MatchString(email)\n}", "func IsEmail(str string) bool {\n\treg, _ := regexp.Compile(`^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$`)\n\treturn reg.MatchString(str)\n}", "func IsEmail(s string) bool {\n\tvar rxEmail = regexp.MustCompile(\"^[a-zA-Z0-9.!#$%&'*+\\\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$\")\n\n\treturn !(len(s) > 254 || !rxEmail.Match([]byte(s)))\n}", "func (m *ProfileMutation) Email() (r string, exists bool) {\n\tv := m.email\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func isValidEmail(s string) bool {\n\t_, err := mail.ParseAddress(s)\n\treturn err == nil\n}", "func (rep rep_users) FindForEmail(email string) (models.Usuario, error) {\n\trows, erro := rep.db.Query(\"SELECT id, senha FROM usuarios WHERE email = ?\", email)\n\n\tif erro != nil {\n\t\treturn models.Usuario{}, erro\n\t}\n\n\tdefer rows.Close()\n\n\tvar user models.Usuario\n\n\tif rows.Next() {\n\t\tif erro = rows.Scan(&user.ID, &user.Senha); erro != nil {\n\t\t\treturn models.Usuario{}, erro\n\t\t}\n\t}\n\n\treturn user, nil\n}", "func (v *Validator) IsEmail(field, email string) bool {\n\tif _, ok := v.Errors[field]; ok {\n\t\treturn false\n\t}\n\tif !emailRegexp.MatchString(email) {\n\t\tv.Errors[field] = \"not a valid email\"\n\t\treturn false\n\t}\n\treturn true\n}", "func CheckExistUser(email string) (models.User, bool, string) {\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\n\t//When end instruction remove timeout operation and liberate context\n\tdefer cancel()\n\n\tdb := MongoConnection.Database(\"socialnetwork\")\n\tcollection := db.Collection(\"Users\")\n\n\tobject := bson.M{\"Email\": email}\n\n\tvar result models.User\n\n\terr := collection.FindOne(ctx, object).Decode(&result)\n\n\tID := result.ID.Hex()\n\n\tif err != nil {\n\t\treturn result, false, ID\n\t}\n\n\treturn result, true, ID\n\n}", "func (db *PSQL) OrganizationExists(organizationEmail string) (bool, error) {\n\treturn true, nil\n}", "func EmailEQ(v string) predicate.User {\n\treturn predicate.User(sql.FieldEQ(FieldEmail, v))\n}", "func (userRepo FakeUser) FindByEmail(email string) (*user.User, error) {\n\tvar user user.User\n\n\tfor _, anUser := range userRepo.data {\n\t\tif anUser.Email == email {\n\t\t\treturn &anUser, nil\n\t\t}\n\t}\n\n\treturn &user, nil\n}", "func isEmailOfflineUser(email string) bool {\n\tif !config.OfflineMode {\n\t\treturn false\n\t}\n\treturn config.OfflineUser.Email == email\n}", "func CheckEmailOnCustomer(email string) (interface{}, error) {\n\tvar customer models.Customer\n\n\tif err := config.DB.Model(&customer).Select(\"email\").Where(\"email=?\", email).First(&customer.Email).Error; err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn customer, nil\n}", "func (userservice Userservice) FindbyEmail(email string) (*entity.User, error) {\n\n\tctx, _ := context.WithTimeout(context.Background(), 10*time.Second)\n\n\tdb := db.ConfigDB()\n\n\tvar user entity.User\n\n\terr := db.Collection(\"users\").FindOne(ctx, bson.M{\"email\": email}).Decode(&user)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfmt.Print(user)\n\n\treturn &user, nil\n\n}", "func (o *InlineResponse2004People) HasEmail() bool {\n\tif o != nil && o.Email != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func Email(v string) predicate.User {\n\treturn predicate.User(sql.FieldEQ(FieldEmail, v))\n}", "func Email(v string) predicate.Patient {\n\treturn predicate.Patient(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldEmail), v))\n\t})\n}", "func (m *UserMutation) Email() (r string, exists bool) {\n\tv := m.email\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func (m *UserMutation) Email() (r string, exists bool) {\n\tv := m.email\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func (m *UserMutation) Email() (r string, exists bool) {\n\tv := m.email\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func (m *UserMutation) Email() (r string, exists bool) {\n\tv := m.email\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func (o *IdentityChangeUserEmailRequest) HasEmail() bool {\n\tif o != nil && o.Email != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (repository Users) SearchByEmail(email string) (models.User, error) {\n\tline, error := repository.db.Query(\"SELECT id, password FROM users where email = ?\", email)\n\n\tif error != nil {\n\t\treturn models.User{}, error\n\t}\n\n\tdefer line.Close()\n\n\tvar user models.User\n\n\tif line.Next() {\n\t\tif error = line.Scan(&user.ID, &user.Password); error != nil {\n\t\t\treturn models.User{}, error\n\t\t}\n\t}\n\n\treturn user, nil\n}", "func TestGetByEmail(t *testing.T) {\n\tdb := database.Connect()\n\tu := User{\n\t\tEmail: \"test5.5@example.com\",\n\t\tPassword: \"123\",\n\t}\n\tr := u.Create(db)\n\tif r != true {\n\t\tt.Errorf(\"Expected successful create, got %t\", r)\n\t}\n\n\tnu := User{\n\t\tEmail: \"test5.5@example.com\",\n\t}\n\tnu.GetByEmail(db)\n\tif nu.ID == 0 {\n\t\tt.Errorf(\"Expected successful get by email, got nothing\")\n\t}\n}", "func (m *InviteeMutation) Email() (r string, exists bool) {\n\tv := m.email\n\tif v == nil {\n\t\treturn\n\t}\n\treturn *v, true\n}", "func (s *UserStoreFile) ByEmail(email string) (*app.User, error) {\r\n\tusers, err := s.retrieveUsers()\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\tfor _, u := range users {\r\n\t\tif strings.EqualFold(u.Email, email) {\r\n\t\t\treturn &u, nil\r\n\t\t}\r\n\t}\r\n\treturn nil, errNotFound\r\n}", "func (o *GroupInviteRequest) HasEmail() bool {\n\tif o != nil && o.Email != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (db *UserDB) LookupByEmail(email string) *User {\n\tfor _, user := range db.Users {\n\t\tif user.Email == email {\n\t\t\treturn &user\n\t\t}\n\t}\n\treturn nil\n}" ]
[ "0.830488", "0.8195364", "0.81667626", "0.81086147", "0.80071926", "0.7953825", "0.7936496", "0.78109884", "0.7755118", "0.7736038", "0.7681008", "0.7576873", "0.7245693", "0.72339445", "0.7222948", "0.71316254", "0.7029018", "0.69840485", "0.69827086", "0.69254166", "0.68928504", "0.68319964", "0.67730486", "0.670028", "0.66774064", "0.6631945", "0.6625502", "0.6599053", "0.6566786", "0.65508807", "0.6541366", "0.65214866", "0.6519522", "0.6469513", "0.6457747", "0.6451628", "0.64186805", "0.6415168", "0.6415168", "0.6415168", "0.6415168", "0.64123124", "0.64095384", "0.636533", "0.6358889", "0.6354147", "0.63389546", "0.63389176", "0.6335834", "0.6308319", "0.630066", "0.629111", "0.6287307", "0.62852556", "0.62672526", "0.6253364", "0.62527514", "0.6242849", "0.623156", "0.6208144", "0.6202678", "0.6179313", "0.6179313", "0.6179313", "0.6179313", "0.6143196", "0.6133242", "0.6128082", "0.61172503", "0.6105114", "0.60952675", "0.60893667", "0.6087514", "0.60871816", "0.6086618", "0.6082449", "0.6081346", "0.607991", "0.6079168", "0.6066279", "0.60628116", "0.6057153", "0.605136", "0.60506386", "0.6036352", "0.603587", "0.6033866", "0.6031633", "0.60187525", "0.60150015", "0.60150015", "0.60150015", "0.60150015", "0.60097814", "0.60063326", "0.60028976", "0.6002221", "0.5999879", "0.59977984", "0.59843045" ]
0.8110711
3
ToQuery converts the Request to URL Query.
func (r AnnounceRequest) ToQuery() (vs url.Values) { vs = make(url.Values, 9) vs.Set("info_hash", r.InfoHash.BytesString()) vs.Set("peer_id", r.PeerID.BytesString()) vs.Set("uploaded", strconv.FormatInt(r.Uploaded, 10)) vs.Set("downloaded", strconv.FormatInt(r.Downloaded, 10)) vs.Set("left", strconv.FormatInt(r.Left, 10)) if r.IP != "" { vs.Set("ip", r.IP) } if r.Event > 0 { vs.Set("event", strconv.FormatInt(int64(r.Event), 10)) } if r.Port > 0 { vs.Set("port", strconv.FormatUint(uint64(r.Port), 10)) } if r.NumWant != 0 { vs.Set("numwant", strconv.FormatUint(uint64(r.NumWant), 10)) } if r.Key != 0 { vs.Set("key", strconv.FormatInt(int64(r.Key), 10)) } // BEP 23 if r.Compact { vs.Set("compact", "1") } else { vs.Set("compact", "0") } return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *Filter) ToQuery() string {\n\treturn fmt.Sprintf(\"last_knowledge_of_server=%d\", f.LastKnowledgeOfServer)\n}", "func (p SearchParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (p SpaceParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (p ExpandParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (o AvailablePhoneNumbersOptions) ToQueryString() (url.Values, error) {\n\treturn query.Values(o)\n}", "func (p WatchParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (p UserParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (req *Request) Query() string {\n\treturn req.q\n}", "func (r *Request) Query(q map[string]string) *Request {\n\tr.query = q\n\treturn r\n}", "func (p EmptyParameters) ToQuery() string {\n\treturn \"\"\n}", "func (p ContentSearchParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (p AuditSinceParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (opts ShowOpts) ToShowQuery() (string, error) {\n\tq, err := gophercloud.BuildQueryString(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn q.String(), nil\n}", "func (p *Params) EncodeToQuery() string {\n\treturn \"\"\n}", "func (p ContentParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (p LabelParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (p ContentIDParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (r *BaseRequest) Query() url.Values {\n\tif r.query == nil {\n\t\tr.query = url.Values{}\n\t}\n\treturn r.query\n}", "func (p AuditParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (p AttachmentParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func Query(req *http.Request, name string) string {\n\treturn req.URL.Query().Get(name)\n}", "func (p ListWatchersParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func GetRequestQueryString(query string) map[string]string {\n\tpairs := strings.Split(query, \"&\")\n\tparams := make(map[string]string, len(pairs))\n\n\tif len(query) < 1 {\n\t\treturn params\n\t}\n\n\tfor i := 0; i < len(pairs); i++ {\n\t\tketValuePair := strings.Split(pairs[i], \"=\")\n\t\tparams[ketValuePair[0]] = ketValuePair[1]\n\t}\n\n\treturn params\n}", "func (p CollectionParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func (r *Request) GetQuery(p string) string {\n\treturn r.natReqObj.QueryStringParameters[p]\n}", "func Query(q Mappable) *QueryRequest {\n\treturn &QueryRequest{q}\n}", "func (p ChildrenParameters) ToQuery() string {\n\treturn paramsToQuery(p)\n}", "func QueryToJSON(queryString string) ([]byte, error) {\r\n\r\n\tparsedQuery, err := url.ParseQuery(queryString)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\tjsonString, err := json.Marshal(parsedQuery)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\treturn jsonString, nil\r\n}", "func (opts DeleteOpts) ToDeleteQuery() (string, error) {\n\tq, err := golangsdk.BuildQueryString(opts)\n\treturn q.String(), err\n}", "func (c *Context) RequestQuery() *orm.RequestQuery {\n\trq := &orm.RequestQuery{\n\t\tOffset: 0,\n\t\tLimit: -1,\n\t\tConditions: make([]map[string]string, 0),\n\t}\n\n\treturn rq.ReadFromContext(c.QueryParams())\n}", "func (opts GetOpts) ToObjectGetQuery() (string, error) {\n\tq, err := gophercloud.BuildQueryString(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn q.String(), nil\n}", "func (u *URL) Query(name string) string {\n\tif u.query == nil {\n\t\tu.query = u.URL.Query()\n\t}\n\n\treturn u.query.Get(name)\n}", "func (f *modQuery) Request(ctx filters.FilterContext) {\n\treq := ctx.Request()\n\tparams := req.URL.Query()\n\n\tswitch f.behavior {\n\tcase drop:\n\t\tname, _ := f.name.ApplyContext(ctx)\n\t\tparams.Del(name)\n\tcase set:\n\t\tif f.value == nil {\n\t\t\treq.URL.RawQuery, _ = f.name.ApplyContext(ctx)\n\t\t\treturn\n\t\t} else {\n\t\t\tname, _ := f.name.ApplyContext(ctx)\n\t\t\tvalue, _ := f.value.ApplyContext(ctx)\n\t\t\tparams.Set(name, value)\n\t\t}\n\tdefault:\n\t\tpanic(\"unspecified behavior\")\n\t}\n\n\treq.URL.RawQuery = params.Encode()\n}", "func ToQueryMap(req Common) (map[string]string, error) {\n\treturn EncodeForm(req)\n}", "func (r *Search) Query(query *types.Query) *Search {\n\n\tr.req.Query = query\n\n\treturn r\n}", "func (o *QueryDirectoryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.DirectoryQuery != nil {\n\t\tif err := r.SetBodyParam(o.DirectoryQuery); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param QueryPath\n\tif err := r.SetPathParam(\"QueryPath\", o.QueryPath); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Detail != nil {\n\n\t\t// query param detail\n\t\tvar qrDetail string\n\t\tif o.Detail != nil {\n\t\t\tqrDetail = *o.Detail\n\t\t}\n\t\tqDetail := qrDetail\n\t\tif qDetail != \"\" {\n\t\t\tif err := r.SetQueryParam(\"detail\", qDetail); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Dir != nil {\n\n\t\t// query param dir\n\t\tvar qrDir string\n\t\tif o.Dir != nil {\n\t\t\tqrDir = *o.Dir\n\t\t}\n\t\tqDir := qrDir\n\t\tif qDir != \"\" {\n\t\t\tif err := r.SetQueryParam(\"dir\", qDir); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Hidden != nil {\n\n\t\t// query param hidden\n\t\tvar qrHidden bool\n\t\tif o.Hidden != nil {\n\t\t\tqrHidden = *o.Hidden\n\t\t}\n\t\tqHidden := swag.FormatBool(qrHidden)\n\t\tif qHidden != \"\" {\n\t\t\tif err := r.SetQueryParam(\"hidden\", qHidden); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.MaxDepth != nil {\n\n\t\t// query param max-depth\n\t\tvar qrMaxDepth int64\n\t\tif o.MaxDepth != nil {\n\t\t\tqrMaxDepth = *o.MaxDepth\n\t\t}\n\t\tqMaxDepth := swag.FormatInt64(qrMaxDepth)\n\t\tif qMaxDepth != \"\" {\n\t\t\tif err := r.SetQueryParam(\"max-depth\", qMaxDepth); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param query\n\tqrQuery := o.Query\n\tqQuery := swag.FormatBool(qrQuery)\n\tif qQuery != \"\" {\n\t\tif err := r.SetQueryParam(\"query\", qQuery); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Resume != nil {\n\n\t\t// query param resume\n\t\tvar qrResume string\n\t\tif o.Resume != nil {\n\t\t\tqrResume = *o.Resume\n\t\t}\n\t\tqResume := qrResume\n\t\tif qResume != \"\" {\n\t\t\tif err := r.SetQueryParam(\"resume\", qResume); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Type != nil {\n\n\t\t// query param type\n\t\tvar qrType string\n\t\tif o.Type != nil {\n\t\t\tqrType = *o.Type\n\t\t}\n\t\tqType := qrType\n\t\tif qType != \"\" {\n\t\t\tif err := r.SetQueryParam(\"type\", qType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func NewRequestQuery() *RequestQuery {\n\treturn &RequestQuery{\n\t\tPage: 0,\n\t\tLimit: 100,\n\t}\n}", "func (opts ListOpts) ToListQuery() (string, error) {\n\tq, err := golangsdk.BuildQueryString(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn q.String(), err\n}", "func (v *MatchingQueryWorkflowRequest) GetQueryRequest() (o *QueryWorkflowRequest) {\n\tif v != nil && v.QueryRequest != nil {\n\t\treturn v.QueryRequest\n\t}\n\treturn\n}", "func (o *Request) WithQuery(query url.Values) *Request {\n\to.Query = query\n\treturn o\n}", "func (z RequestData) Query() interface{} {\n\treturn z.q\n}", "func (u *User) QueryRequest() *RequestQuery {\n\treturn NewUserClient(u.config).QueryRequest(u)\n}", "func (v *MatchingServiceQueryWorkflowArgs) GetQueryRequest() (o *MatchingQueryWorkflowRequest) {\n\tif v != nil && v.QueryRequest != nil {\n\t\treturn v.QueryRequest\n\t}\n\treturn\n}", "func (opts MeterStatisticsOpts) ToMeterStatisticsQuery() (string, error) {\n\tq, err := gophercloud.BuildQueryString(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn q.String(), nil\n}", "func buildQuery (req *http.Request, args map[string]string) (*http.Request) {\n\tq := req.URL.Query()\n\t// build query from map\n\tfor key, _ := range args {\n\t\tif key == \"q\" {\n\t\t\tparts := strings.Split(args[key],\" \")\n\t\t\tq.Add(\"q\", strings.Join(parts, \"+\"))\n\t\t} else {\n\t\t\tq.Add(key, args[key])\n\t\t}\n\t}\n\treq.URL.RawQuery = q.Encode()\n\treturn req\n}", "func urlQueryToString(options interface{}) (string, error) {\n\tv, err := query.Values(options)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn v.Encode(), nil\n}", "func EncodeQueryRequest(encoder func(*http.Request) goahttp.Encoder) func(*http.Request, interface{}) error {\n\treturn func(req *http.Request, v interface{}) error {\n\t\tp, ok := v.(*resource.QueryPayload)\n\t\tif !ok {\n\t\t\treturn goahttp.ErrInvalidType(\"resource\", \"Query\", \"*resource.QueryPayload\", v)\n\t\t}\n\t\tvalues := req.URL.Query()\n\t\tvalues.Add(\"name\", p.Name)\n\t\tfor _, value := range p.Catalogs {\n\t\t\tvalues.Add(\"catalogs\", value)\n\t\t}\n\t\tfor _, value := range p.Categories {\n\t\t\tvalues.Add(\"categories\", value)\n\t\t}\n\t\tfor _, value := range p.Kinds {\n\t\t\tvalues.Add(\"kinds\", value)\n\t\t}\n\t\tfor _, value := range p.Tags {\n\t\t\tvalues.Add(\"tags\", value)\n\t\t}\n\t\tfor _, value := range p.Platforms {\n\t\t\tvalues.Add(\"platforms\", value)\n\t\t}\n\t\tvalues.Add(\"limit\", fmt.Sprintf(\"%v\", p.Limit))\n\t\tvalues.Add(\"match\", p.Match)\n\t\treq.URL.RawQuery = values.Encode()\n\t\treturn nil\n\t}\n}", "func (f *FastURL) GetQuery() *Query {\n\tif !f.parsequery {\n\t\tf.query.Decode(f.rawquery)\n\t\tf.parsequery = true\n\t}\n\treturn &f.query\n}", "func (r *Request) SetQueryString(query string) *Request {\n\tparams, err := url.ParseQuery(strings.TrimSpace(query))\n\tif err == nil {\n\t\tfor p, v := range params {\n\t\t\tfor _, pv := range v {\n\t\t\t\tr.QueryParam.Add(p, pv)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tr.client.log.Errorf(\"%v\", err)\n\t}\n\treturn r\n}", "func (r *request) toHTTP() (*http.Request, error) {\n\t// Encode the query parameters\n\tr.body = strings.NewReader(r.params.Encode())\n\n\t// Create the HTTP request\n\treq, err := http.NewRequest(r.method, r.url.RequestURI(), r.body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treq.URL.Host = r.url.Host\n\treq.URL.Scheme = r.url.Scheme\n\treq.Host = r.url.Host\n\treq.Header.Add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\treq.Header.Add(\"cache-control\", \"no-cache\")\n\n\treturn req, nil\n}", "func (o *DnsEventAllOf) GetQuery() string {\n\tif o == nil || o.Query == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Query\n}", "func (r *IntervalFilterInput) MakeQueryString(command string, measurement string) string {\n\tvar b bytes.Buffer\n\tb.WriteString(command)\n\tb.WriteString(\" FROM \")\n\tb.WriteString(measurement)\n\n\tcheck_empty := r == &IntervalFilterInput{}\n\tif check_empty {\n\t\treturn b.String()\n\t}\n\n\tflag := true\n\tb, flag = query.HandleTagFieldQuery(b, \"unique_meter_seqid\", r.UniqueMeterSeqid, flag)\n\tb, flag = query.HandleDateQuery(b, r.ExactTime, \"=\", flag)\n\tb, flag = query.HandleDateQuery(b, r.StartDate, \">=\", flag)\n\tb, _ = query.HandleDateQuery(b, r.EndDate, \"<\", flag)\n\n\treturn b.String()\n}", "func (c *SearchCall) Query(query string) *SearchCall {\n\tc.urlParams_.Set(\"query\", query)\n\treturn c\n}", "func (opts ListOpts) ToListOptsQuery() (string, error) {\n\tq, err := golangsdk.BuildQueryString(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn q.String(), err\n}", "func LoadRequestFromQuery(query string) Request {\n\tparsedQuery, _ := url.ParseQuery(query)\n\trequest := Request{}\n\trequest.Token = parsedQuery.Get(\"token\")\n\trequest.TeamID = parsedQuery.Get(\"team_id\")\n\trequest.TeamDomain = parsedQuery.Get(\"team_domain\")\n\trequest.ChannelID = parsedQuery.Get(\"channel_id\")\n\trequest.ChannelName = parsedQuery.Get(\"channel_name\")\n\trequest.UserID = parsedQuery.Get(\"user_id\")\n\trequest.UserName = parsedQuery.Get(\"user_name\")\n\trequest.Command = parsedQuery.Get(\"command\")\n\trequest.Text = parsedQuery.Get(\"text\")\n\trequest.ResponseURL = parsedQuery.Get(\"response_url\")\n\treturn request\n}", "func (opts DeleteOpts) ToObjectDeleteQuery() (string, error) {\n\tq, err := gophercloud.BuildQueryString(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn q.String(), nil\n}", "func (ar *AdapterRequest) ToRequest() (*http.Request, error) {\n\tdecodedBody := []byte(ar.Body)\n\tif ar.IsBase64Encoded {\n\t\tbase64Body, err := base64.StdEncoding.DecodeString(ar.Body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdecodedBody = base64Body\n\t}\n\n\tpath := ar.Path\n\tif ar.stripBasePath != \"\" && len(ar.stripBasePath) > 1 {\n\t\tif strings.HasPrefix(path, ar.stripBasePath) {\n\t\t\tpath = strings.Replace(path, ar.stripBasePath, \"\", 1)\n\t\t}\n\t}\n\tif !strings.HasPrefix(path, \"/\") {\n\t\tpath = \"/\" + path\n\t}\n\tserverAddress := DefaultServerAddress\n\tif customAddress, ok := os.LookupEnv(CustomHostVariable); ok {\n\t\tserverAddress = customAddress\n\t}\n\tpath = serverAddress + path\n\n\tif len(ar.MultiValueQueryStringParameters) > 0 {\n\t\tqueryString := \"\"\n\t\tfor q, l := range ar.MultiValueQueryStringParameters {\n\t\t\tfor _, v := range l {\n\t\t\t\tif queryString != \"\" {\n\t\t\t\t\tqueryString += \"&\"\n\t\t\t\t}\n\t\t\t\tqueryString += url.QueryEscape(q) + \"=\" + url.QueryEscape(v)\n\t\t\t}\n\t\t}\n\t\tar.Path += \"?\" + queryString\n\t} else if len(ar.QueryStringParameters) > 0 {\n\t\t// Support `QueryStringParameters` for backward compatibility.\n\t\t// https://github.com/awslabs/aws-lambda-go-api-proxy/issues/37\n\t\tqueryString := \"\"\n\t\tfor q := range ar.QueryStringParameters {\n\t\t\tif queryString != \"\" {\n\t\t\t\tqueryString += \"&\"\n\t\t\t}\n\t\t\tqueryString += url.QueryEscape(q) + \"=\" + url.QueryEscape(ar.QueryStringParameters[q])\n\t\t}\n\t\tar.Path += \"?\" + queryString\n\t}\n\n\thttpRequest, err := http.NewRequest(\n\t\tstrings.ToUpper(ar.HTTPMethod),\n\t\tar.Path,\n\t\tbytes.NewReader(decodedBody),\n\t)\n\tif err != nil {\n\t\tfmt.Printf(\"Could not convert request %s:%s to http.Request\\n\", ar.HTTPMethod, ar.Path)\n\t\tlog.Println(err)\n\t\treturn nil, err\n\t}\n\n\tfor h := range ar.Headers {\n\t\thttpRequest.Header.Add(h, ar.Headers[h])\n\t}\n\treturn httpRequest, nil\n}", "func (o *QueryChangesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (s *Result) SetRequestQuery(v string) *Result {\n\ts.RequestQuery = &v\n\treturn s\n}", "func ReparseQuery(r *http.Request) {\n\tif !strings.ContainsRune(r.URL.Path, '?') {\n\t\treturn\n\t}\n\tq := r.URL.Query()\n\ttmpURL, err := url.Parse(r.URL.Path)\n\tdebug.AssertNoErr(err)\n\tfor k, v := range tmpURL.Query() {\n\t\tq.Add(k, strings.Join(v, \",\"))\n\t}\n\tr.URL.Path = tmpURL.Path\n\tr.URL.RawQuery = q.Encode()\n}", "func VizierQueryRequestToPlannerQueryRequest(vpb *vizierpb.ExecuteScriptRequest) (*plannerpb.QueryRequest, error) {\n\treturn &plannerpb.QueryRequest{\n\t\tQueryStr: vpb.QueryStr,\n\t\tExecFuncs: convertExecFuncs(vpb.ExecFuncs),\n\t\tConfigs: convertConfigs(vpb.Configs),\n\t}, nil\n}", "func (ctx *Context) Query(name string) string {\n\treturn ctx.QueryParams().Get(name)\n}", "func Query(q string) func(r *Zego) {\n\treturn func(r *Zego) {\n\t\tr.query = q\n\t}\n}", "func (opts BandwidthLimitRulesListOpts) ToBandwidthLimitRulesListQuery() (string, error) {\n\tq, err := gophercloud.BuildQueryString(opts)\n\treturn q.String(), err\n}", "func (p *Param) QueryTo() (sqlbuilder.Iterator, error) {\n\treturn p.T().QueryTo(p)\n}", "func (cq *changesQuery) GetQuery() (url.Values, error) {\n\tvals := url.Values{}\n\tif cq.Conflicts {\n\t\tvals.Set(\"conflicts\", \"true\")\n\t}\n\tif cq.Descending {\n\t\tvals.Set(\"descending\", \"true\")\n\t}\n\tif len(cq.DocIDs) > 0 {\n\t\tdata, err := json.Marshal(cq.DocIDs)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tvals.Set(\"doc_ids\", string(data[:]))\n\t}\n\tif cq.IncludeDocs {\n\t\tvals.Set(\"include_docs\", \"true\")\n\t}\n\tif cq.Feed != \"\" {\n\t\tvals.Set(\"feed\", cq.Feed)\n\t}\n\tif cq.Filter != \"\" {\n\t\tvals.Set(\"filter\", cq.Filter)\n\t}\n\tif cq.Heartbeat > 0 {\n\t\tvals.Set(\"heartbeat\", strconv.Itoa(cq.Heartbeat))\n\t}\n\tif cq.Limit > 0 {\n\t\tvals.Set(\"limit\", strconv.Itoa(cq.Limit))\n\t}\n\tif cq.SeqInterval > 0 {\n\t\tvals.Set(\"seq_interval\", strconv.Itoa(cq.SeqInterval))\n\t}\n\tif cq.Style != \"\" {\n\t\tvals.Set(\"style\", cq.Style)\n\t}\n\tif cq.Since != \"\" {\n\t\tvals.Set(\"since\", cq.Since)\n\t}\n\tif cq.Timeout > 0 {\n\t\tvals.Set(\"timeout\", strconv.Itoa(cq.Timeout))\n\t}\n\treturn vals, nil\n}", "func (o *KillQueryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tr.SetTimeout(o.timeout)\n\tvar res []error\n\n\t// path param query_slug\n\tif err := r.SetPathParam(\"query_slug\", o.QuerySlug); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (r *BasicRequest) QueryArgs() (url.Values, error) {\n\treturn url.ParseQuery(r.Query)\n}", "func decodeRequestQuery(r *http.Request, v interface{}) error {\n\tif err := schema.NewDecoder().Decode(v, r.URL.Query()); err != nil {\n\t\tlog.WithField(\"err\", err).Info(\"Invalid request query\")\n\t\treturn err\n\t}\n\treturn nil\n}", "func (opts ListOpts) ToReceiverListQuery() (string, error) {\n\tq, err := gophercloud.BuildQueryString(opts)\n\treturn q.String(), err\n}", "func (options PaginationOption) MakeQueryString() string {\n\tvalues := make(url.Values)\n\tif options.order != PaginationOrderDesc {\n\t\tvalues.Set(\"order\", string(options.order))\n\t}\n\tif options.limit != 25 {\n\t\tvalues.Set(\"limit\", string(options.limit))\n\t}\n\tif options.startingAfter != \"\" {\n\t\tvalues.Set(\"starting_after\", options.startingAfter)\n\t}\n\tif options.endingBefore != \"\" {\n\t\tvalues.Set(\"ending_before\", options.endingBefore)\n\t}\n\treturn values.Encode()\n}", "func getQuery(request *http.Request, c context.Context) (string, error) {\n\tresult := request.URL.Query().Get(queryParam)\n\n\tif result == \"\" {\n\t\treturn \"\", errors.New(\"No query specified.\")\n\t}\n\tlog.Infof(c, \"Recived query parameter: %v\", result)\n\treturn result, nil\n}", "func (r *RegressionDetectionRequest) SetQuery(q string) {\n\tr.query = q\n}", "func (opts ListOpts) ToMeterListQuery() (string, error) {\n\tq, err := gophercloud.BuildQueryString(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn q.String(), nil\n}", "func (s *ValidateService) Query(query Query) *ValidateService {\n\tsrc, err := query.Source()\n\tif err != nil {\n\t\t// Do nothing in case of an error\n\t\treturn s\n\t}\n\tbody := make(map[string]interface{})\n\tbody[\"query\"] = src\n\ts.bodyJson = body\n\treturn s\n}", "func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) {\n\tpath := splitPath(req.Path)\n\tif len(path) == 0 {\n\t\tmsg := \"no query path provided\"\n\t\treturn types.ErrUnknownRequest(msg).QueryResult()\n\t}\n\tswitch path[0] {\n\tcase \"app\":\n\t\treturn handleQueryApp(app, path, req)\n\tcase \"store\":\n\t\treturn handleQueryStore(app, path, req)\n\tcase \"custom\":\n\t\treturn handlerCustomQuery(app, path, req)\n\t}\n\n\tmsg := \"unknown query path\"\n\treturn types.ErrUnknownRequest(msg).QueryResult()\n}", "func (r *RegressionDetectionRequest) Query() string {\n\tif r.query != \"\" {\n\t\treturn r.query\n\t}\n\tif r.Alert != nil {\n\t\treturn r.Alert.Query\n\t}\n\treturn \"\"\n}", "func FilterQuery(fq string) func(url.Values) {\n\treturn func(p url.Values) {\n\t\tp[\"fq\"] = append(p[\"fq\"], fq)\n\t}\n}", "func (r InboundRequest) QueryParams() map[string][]string {\n return r.URL.Query()\n}", "func (r *Request) GraphQLQuery(query string, variables ...map[string]interface{}) *Request {\n\tq := GraphQLRequestBody{\n\t\tQuery: query,\n\t}\n\n\tif len(variables) > 0 {\n\t\tq.Variables = variables[0]\n\t}\n\n\treturn r.GraphQLRequest(q)\n}", "func (z RequestData) ParamQuery() string {\n\tl := esl.Default()\n\tif z.q == nil {\n\t\treturn \"\"\n\t}\n\tq, err := query.Values(z.q)\n\tif err != nil {\n\t\tl.Debug(\"unable to make query\", esl.Error(err), esl.Any(\"q\", z.q))\n\t\treturn \"\"\n\t} else {\n\t\treturn \"?\" + q.Encode()\n\t}\n}", "func (opts ListOpts) ToListenerListQuery() (string, error) {\n\tq, err := golangsdk.BuildQueryString(opts)\n\treturn q.String(), err\n}", "func (b *addPushNotificationsOnChannelsBuilder) QueryParam(queryParam map[string]string) *addPushNotificationsOnChannelsBuilder {\n\tb.opts.QueryParam = queryParam\n\n\treturn b\n}", "func MarshalQueryString(v interface{}) (string, error) {\n\tvalues, err := query.Values(v)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn values.Encode(), nil\n}", "func (q *NumberQuery) GetQuery() interface{} {\n\treturn q\n}", "func FilterToQuery(f *entity.Filter) (q bson.M, err error) {\n\tq = bson.M{}\n\tfor _, cond := range f.Conditions {\n\t\tswitch cond.Op {\n\t\tcase constants.FilterOpNotSet:\n\t\t\t// do nothing\n\t\tcase constants.FilterOpEqual:\n\t\t\tq[cond.Key] = cond.Value\n\t\tcase constants.FilterOpNotEqual:\n\t\t\tq[cond.Key] = bson.M{\"$ne\": cond.Value}\n\t\tcase constants.FilterOpContains, constants.FilterOpRegex, constants.FilterOpSearch:\n\t\t\tq[cond.Key] = bson.M{\"$regex\": cond.Value, \"$options\": \"i\"}\n\t\tcase constants.FilterOpNotContains:\n\t\t\tq[cond.Key] = bson.M{\"$not\": bson.M{\"$regex\": cond.Value}}\n\t\tcase constants.FilterOpIn:\n\t\t\tq[cond.Key] = bson.M{\"$in\": cond.Value}\n\t\tcase constants.FilterOpNotIn:\n\t\t\tq[cond.Key] = bson.M{\"$nin\": cond.Value}\n\t\tcase constants.FilterOpGreaterThan:\n\t\t\tq[cond.Key] = bson.M{\"$gt\": cond.Value}\n\t\tcase constants.FilterOpGreaterThanEqual:\n\t\t\tq[cond.Key] = bson.M{\"$gte\": cond.Value}\n\t\tcase constants.FilterOpLessThan:\n\t\t\tq[cond.Key] = bson.M{\"$lt\": cond.Value}\n\t\tcase constants.FilterOpLessThanEqual:\n\t\t\tq[cond.Key] = bson.M{\"$lte\": cond.Value}\n\t\tdefault:\n\t\t\treturn nil, errors.ErrorFilterInvalidOperation\n\t\t}\n\t}\n\treturn q, nil\n}", "func (x *PostSearchesRequest) GetQuery() *Query {\n\tif x != nil {\n\t\treturn x.Query\n\t}\n\treturn nil\n}", "func (r *Request) Request() (*http.Request, error) {\n\tvar req *http.Request\n\tvar err error\n\n\tif r.body != nil {\n\t\tbody, err := json.Marshal(r.body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tbuff := bytes.NewBuffer(body)\n\n\t\treq, err = http.NewRequest(r.method, r.url, buff)\n\t} else {\n\t\treq, err = http.NewRequest(r.method, r.url, nil)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tv, err := query.Values(r.query)\n\tif err == nil {\n\t\treq.URL.RawQuery = v.Encode()\n\t}\n\n\treturn req, nil\n}", "func (c *Client) BuildQueryRequest(ctx context.Context, v interface{}) (*http.Request, error) {\n\tu := &url.URL{Scheme: c.scheme, Host: c.host, Path: QueryResourcePath()}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn nil, goahttp.ErrInvalidURL(\"resource\", \"Query\", u.String(), err)\n\t}\n\tif ctx != nil {\n\t\treq = req.WithContext(ctx)\n\t}\n\n\treturn req, nil\n}", "func (l *Lambda) RequestQueryStringParameter(parameter string) string {\n\treturn l.r.URL.Query().Get(parameter)\n}", "func (q *Query) ToFilter() string {\n\treturn fmt.Sprintf(`\nresource.type=k8s_container\nAND (\n\tlogName=projects/%s/logs/stderr\n\tOR logName=projects/%s/logs/stdout\n)\nAND resource.labels.cluster_name=%q\nAND resource.labels.namespace_name=%q\nAND labels.%q=%q\n`,\n\t\tq.Project,\n\t\tq.Project,\n\t\tq.Cluster,\n\t\tq.Namespace,\n\t\tStackdriverBuildIDLabel,\n\t\tq.BuildID,\n\t)\n}", "func (o *Aliyun) makeURLQuery(_url string) string {\n\tquery, _ := url.Parse(_url)\n\tparam := query.Query()\n\tquerys, arr := o.makeDictionarySort(param)\n\tstr := \"\"\n\tfor _, k := range querys {\n\t\tstr += k + \"=\" + o.percentEncode(arr[k][0]) + \"&\"\n\t}\n\treturn str[:len(str)-1]\n}", "func ToRequest(httpRequest *http.Request) *Request {\n\tif httpRequest == nil {\n\t\treturn nil\n\t}\n\n\t// deal with body first because Trailers are sent after Body.Read returns io.EOF and Body.Close() was called.\n\tbodyClone := cloneHTTPRequestBody(httpRequest)\n\theaderClone := httpRequest.Header.Clone()\n\ttrailerClone := httpRequest.Trailer.Clone()\n\ttsfEncodingClone := cloneStringSlice(httpRequest.TransferEncoding)\n\n\treturn &Request{\n\t\tMethod: httpRequest.Method,\n\t\tURL: cloneURL(httpRequest.URL),\n\t\tProto: httpRequest.Proto,\n\t\tProtoMajor: httpRequest.ProtoMajor,\n\t\tProtoMinor: httpRequest.ProtoMinor,\n\t\tHeader: headerClone,\n\t\tBody: bodyClone,\n\t\tContentLength: httpRequest.ContentLength,\n\t\tTransferEncoding: tsfEncodingClone,\n\t\tClose: httpRequest.Close,\n\t\tHost: httpRequest.Host,\n\t\tForm: cloneMapOfSlices(httpRequest.Form),\n\t\tPostForm: cloneMapOfSlices(httpRequest.PostForm),\n\t\tMultipartForm: cloneMultipartForm(httpRequest.MultipartForm),\n\t\tTrailer: trailerClone,\n\t\tRemoteAddr: httpRequest.RemoteAddr,\n\t\tRequestURI: httpRequest.RequestURI,\n\t}\n}", "func (c *Context) Query(key string) string {\n\treturn c.Req.URL.Query().Get(key)\n}", "func QueryRequestFromProxyRequest(req *query.ProxyRequest) (*QueryRequest, error) {\n\tqr := new(QueryRequest)\n\tswitch c := req.Request.Compiler.(type) {\n\tcase lang.FluxCompiler:\n\t\tqr.Type = \"flux\"\n\t\tqr.Query = c.Query\n\tcase lang.SpecCompiler:\n\t\tqr.Type = \"flux\"\n\t\tqr.Spec = c.Spec\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported compiler %T\", c)\n\t}\n\tswitch d := req.Dialect.(type) {\n\tcase *csv.Dialect:\n\t\tvar header = !d.ResultEncoderConfig.NoHeader\n\t\tqr.Dialect.Header = &header\n\t\tqr.Dialect.Delimiter = string(d.ResultEncoderConfig.Delimiter)\n\t\tqr.Dialect.CommentPrefix = \"#\"\n\t\tqr.Dialect.DateTimeFormat = \"RFC3339\"\n\t\tqr.Dialect.Annotations = d.ResultEncoderConfig.Annotations\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported dialect %T\", d)\n\t}\n\n\treturn qr, nil\n}", "func (o *DnsEventAllOf) SetQuery(v string) {\n\to.Query = &v\n}", "func (u *URL) QueryString() string {\n\treturn u.URL.RawQuery\n}", "func (opts ListOpts) ToOrderListQuery() (string, error) {\n\tq, err := gophercloud.BuildQueryString(opts)\n\treturn q.String(), err\n}", "func (ctx *Context) GetQuery() url.Values {\n\treturn ctx.Query\n}", "func (g *GetChatEventLogRequest) GetQuery() (value string) {\n\tif g == nil {\n\t\treturn\n\t}\n\treturn g.Query\n}" ]
[ "0.6419699", "0.6291177", "0.6282017", "0.61848676", "0.6141613", "0.6093184", "0.60806036", "0.6045012", "0.60266846", "0.6002443", "0.59969157", "0.59797895", "0.59552836", "0.5908155", "0.5877254", "0.5868933", "0.58650696", "0.58616143", "0.5818987", "0.5784606", "0.57737947", "0.5767542", "0.5767029", "0.5745375", "0.5743967", "0.57294124", "0.572601", "0.57159746", "0.56832266", "0.56158996", "0.5568711", "0.55174685", "0.5512966", "0.5492129", "0.54655796", "0.5461247", "0.5384776", "0.5380622", "0.5354261", "0.534284", "0.53387314", "0.53246754", "0.53132707", "0.52841365", "0.5278563", "0.5273913", "0.5272721", "0.52696013", "0.52526337", "0.5251937", "0.52511954", "0.52310777", "0.5221065", "0.5205417", "0.52046454", "0.5203686", "0.5189527", "0.5165494", "0.5162303", "0.51580036", "0.51547664", "0.51522547", "0.5149222", "0.51366055", "0.5126534", "0.511302", "0.51043534", "0.509819", "0.5096458", "0.5096053", "0.50790554", "0.5066625", "0.50605875", "0.50478303", "0.5034982", "0.502978", "0.5025671", "0.50199115", "0.50185156", "0.5016933", "0.50157416", "0.5009614", "0.50074077", "0.50028485", "0.500284", "0.50021255", "0.50008076", "0.49943402", "0.49929875", "0.49877065", "0.49821454", "0.49758828", "0.49709868", "0.49604145", "0.49578637", "0.4955326", "0.4955017", "0.4953867", "0.4952208", "0.4944407" ]
0.6414736
1
FromQuery converts URL Query to itself.
func (r *AnnounceRequest) FromQuery(vs url.Values) (err error) { if err = r.InfoHash.FromString(vs.Get("info_hash")); err != nil { return } if err = r.PeerID.FromString(vs.Get("peer_id")); err != nil { return } v, err := strconv.ParseInt(vs.Get("uploaded"), 10, 64) if err != nil { return } r.Uploaded = v v, err = strconv.ParseInt(vs.Get("downloaded"), 10, 64) if err != nil { return } r.Downloaded = v v, err = strconv.ParseInt(vs.Get("left"), 10, 64) if err != nil { return } r.Left = v if s := vs.Get("event"); s != "" { v, err := strconv.ParseUint(s, 10, 64) if err != nil { return err } r.Event = uint32(v) } if s := vs.Get("port"); s != "" { v, err := strconv.ParseUint(s, 10, 64) if err != nil { return err } r.Port = uint16(v) } if s := vs.Get("numwant"); s != "" { v, err := strconv.ParseUint(s, 10, 64) if err != nil { return err } r.NumWant = int32(v) } if s := vs.Get("key"); s != "" { v, err := strconv.ParseInt(s, 10, 64) if err != nil { return err } r.Key = int32(v) } r.IP = vs.Get("ip") switch vs.Get("compact") { case "1": r.Compact = true case "0": r.Compact = false } return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func FromQuery(key string) TokenExtractor {\n\treturn func(r *http.Request) (string, error) {\n\t\treturn r.URL.Query().Get(key), nil\n\t}\n}", "func NewFromURL(url *url.URL) *QueryString {\n\treturn NewFromRawQuery(url.RawQuery)\n}", "func NewFromRawQuery(rawQuery string) *QueryString {\n\tqs := new(QueryString)\n\tqs.fields = make(map[string]string)\n\n\tfor {\n\t\ti := strings.IndexRune(rawQuery, '=')\n\t\tif i == -1 {\n\t\t\tbreak\n\t\t}\n\t\tname := rawQuery[:i]\n\t\trawQuery = rawQuery[i+1:]\n\n\t\ti = strings.IndexFunc(rawQuery, charClassDetector(1, 1))\n\t\tvar value string\n\t\tif i == -1 {\n\t\t\tvalue = rawQuery\n\t\t} else {\n\t\t\tvalue = rawQuery[:i]\n\t\t\trawQuery = rawQuery[i+1:]\n\t\t}\n\n\t\tqs.fields[name] = value\n\n\t\tif i == -1 {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn qs\n}", "func NewQuery(query string) (*Query, error) {\n\tif query == \"\" {\n\t\treturn nil, errors.New(\"USQL query should not be empty\")\n\t}\n\treturn &Query{\n\t\tquery: query,\n\t}, nil\n}", "func LoadRequestFromQuery(query string) Request {\n\tparsedQuery, _ := url.ParseQuery(query)\n\trequest := Request{}\n\trequest.Token = parsedQuery.Get(\"token\")\n\trequest.TeamID = parsedQuery.Get(\"team_id\")\n\trequest.TeamDomain = parsedQuery.Get(\"team_domain\")\n\trequest.ChannelID = parsedQuery.Get(\"channel_id\")\n\trequest.ChannelName = parsedQuery.Get(\"channel_name\")\n\trequest.UserID = parsedQuery.Get(\"user_id\")\n\trequest.UserName = parsedQuery.Get(\"user_name\")\n\trequest.Command = parsedQuery.Get(\"command\")\n\trequest.Text = parsedQuery.Get(\"text\")\n\trequest.ResponseURL = parsedQuery.Get(\"response_url\")\n\treturn request\n}", "func (a *GetHistogramsArgs) SetQuery(query string) *GetHistogramsArgs {\n\ta.Query = &query\n\treturn a\n}", "func XaFromQuery(qs url.Values) (*Xa, error) {\n\txa := &Xa{TransBase: *dtmimp.TransBaseFromQuery(qs)}\n\tif xa.Gid == \"\" || xa.BranchID == \"\" {\n\t\treturn nil, fmt.Errorf(\"bad xa info: gid: %s branchid: %s\", xa.Gid, xa.BranchID)\n\t}\n\treturn xa, nil\n}", "func (a *API) ParseQuery(ctx *fasthttp.RequestCtx) map[string]string {\n\tqs, _ := url.ParseQuery(string(ctx.URI().QueryString()))\n\tvalues := make(map[string]string)\n\tfor key, val := range qs {\n\t\tvalues[key] = val[0]\n\t}\n\n\treturn values\n}", "func ReparseQuery(r *http.Request) {\n\tif !strings.ContainsRune(r.URL.Path, '?') {\n\t\treturn\n\t}\n\tq := r.URL.Query()\n\ttmpURL, err := url.Parse(r.URL.Path)\n\tdebug.AssertNoErr(err)\n\tfor k, v := range tmpURL.Query() {\n\t\tq.Add(k, strings.Join(v, \",\"))\n\t}\n\tr.URL.Path = tmpURL.Path\n\tr.URL.RawQuery = q.Encode()\n}", "func (o *DnsEventAllOf) SetQuery(v string) {\n\to.Query = &v\n}", "func (u *URL) Query(name string) string {\n\tif u.query == nil {\n\t\tu.query = u.URL.Query()\n\t}\n\n\treturn u.query.Get(name)\n}", "func (o *GetV1FunctionalitiesParams) SetQuery(query *string) {\n\to.Query = query\n}", "func (c *V2CompleteCall) Query(query string) *V2CompleteCall {\n\tc.urlParams_.Set(\"query\", query)\n\treturn c\n}", "func (r *Request) SetQuery(query interface{}) *Request {\n\tr.query = query\n\treturn r\n}", "func marshalQuery(q url.Values) map[string]string {\n\t// flatten url.Values by dropping others but the first one\n\tvalues := make(map[string]string, len(q))\n\tfor k, arr := range q {\n\t\tvalues[k] = arr[0]\n\t}\n\treturn values\n}", "func (o *GetOutagesParams) SetQuery(query *string) {\n\to.Query = query\n}", "func (s *ValidateService) Query(query Query) *ValidateService {\n\tsrc, err := query.Source()\n\tif err != nil {\n\t\t// Do nothing in case of an error\n\t\treturn s\n\t}\n\tbody := make(map[string]interface{})\n\tbody[\"query\"] = src\n\ts.bodyJson = body\n\treturn s\n}", "func decodeRequestQuery(r *http.Request, v interface{}) error {\n\tif err := schema.NewDecoder().Decode(v, r.URL.Query()); err != nil {\n\t\tlog.WithField(\"err\", err).Info(\"Invalid request query\")\n\t\treturn err\n\t}\n\treturn nil\n}", "func ParseQueryString(q string) (map[string]interface{}, error) {\n\tuv, err := url.ParseQuery(q)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmp := map[string]interface{}{}\n\tfor k, v := range uv {\n\t\tmp[k] = v[0]\n\t}\n\treturn mp, err\n}", "func (o *SearchAbsoluteParams) SetQuery(query string) {\n\to.Query = query\n}", "func (c *SearchCall) Query(query string) *SearchCall {\n\tc.urlParams_.Set(\"query\", query)\n\treturn c\n}", "func (o OffsetPaginatorOpts) PaginatorFromQuery(query url.Values) OffsetPaginator {\n\t// TODO pull out order asc|desc\n\treturn OffsetPaginator{\n\t\tOffset: uint64(o.Offset(query.Get(\"offset\"))),\n\t\tLimit: uint64(o.Limit(query.Get(\"limit\"))),\n\t\tOrderBy: o.OrderByColumn(query.Get(\"orderBy\")),\n\t\tOrder: o.Order(query.Get(\"order\")),\n\t}\n}", "func FilterQuery(fq string) func(url.Values) {\n\treturn func(p url.Values) {\n\t\tp[\"fq\"] = append(p[\"fq\"], fq)\n\t}\n}", "func (r *RegressionDetectionRequest) SetQuery(q string) {\n\tr.query = q\n}", "func (o *MetricsQueryResponse) SetQuery(v string) {\n\to.Query = &v\n}", "func (r *Request) SetQueryString(query string) *Request {\n\tparams, err := url.ParseQuery(strings.TrimSpace(query))\n\tif err == nil {\n\t\tfor p, v := range params {\n\t\t\tfor _, pv := range v {\n\t\t\t\tr.QueryParam.Add(p, pv)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tr.client.log.Errorf(\"%v\", err)\n\t}\n\treturn r\n}", "func (f *FastURL) GetQuery() *Query {\n\tif !f.parsequery {\n\t\tf.query.Decode(f.rawquery)\n\t\tf.parsequery = true\n\t}\n\treturn &f.query\n}", "func ReadQueryIntoStruct(request *http.Request, dest interface{}, ignoreMissing bool) error {\n\tquery := request.URL.Query()\n\tif query == nil {\n\t\treturn errors.New(\"Request has no query parameters\")\n\t}\n\tfor k, v := range query {\n\t\tif len(v) == 1 {\n\t\t\tquery[k] = strings.Split(v[0], \",\")\n\t\t}\n\t}\n\treturn ReadMapIntoStruct(query, dest, ignoreMissing)\n}", "func (o *Aliyun) makeURLQuery(_url string) string {\n\tquery, _ := url.Parse(_url)\n\tparam := query.Query()\n\tquerys, arr := o.makeDictionarySort(param)\n\tstr := \"\"\n\tfor _, k := range querys {\n\t\tstr += k + \"=\" + o.percentEncode(arr[k][0]) + \"&\"\n\t}\n\treturn str[:len(str)-1]\n}", "func ProcessQuery(query cqr.CommonQueryRepresentation, processor QueryProcessor) cqr.CommonQueryRepresentation {\n\tswitch q := query.(type) {\n\tcase cqr.Keyword:\n\t\tq.QueryString = processor(q.QueryString)\n\t\treturn q\n\tcase cqr.BooleanQuery:\n\t\tfor i, child := range q.Children {\n\t\t\tq.Children[i] = ProcessQuery(child, processor)\n\t\t}\n\t\treturn q\n\t}\n\treturn query\n}", "func (o *QueryDirectoryParams) SetQuery(query bool) {\n\to.Query = query\n}", "func (o *MonitorSearchResult) SetQuery(v string) {\n\to.Query = &v\n}", "func (o *FieldHistogramKeywordParams) SetQuery(query string) {\n\to.Query = query\n}", "func (o *AdminSearchUserV3Params) SetQuery(query *string) {\n\to.Query = query\n}", "func AsQuery(q *generator.Query) *Query {\n\treturn &Query{Query: q}\n}", "func UnmarshalQuery(b []byte, v interface{}) *backend.DataResponse {\n\tif err := json.Unmarshal(b, v); err != nil {\n\t\treturn &backend.DataResponse{\n\t\t\tError: errors.Wrap(err, \"failed to unmarshal JSON request into query\"),\n\t\t}\n\t}\n\treturn nil\n}", "func (o *SearchKeywordChunkedParams) SetQuery(query string) {\n\to.Query = query\n}", "func ParseQuery(query string) (QueryParams, error) {\n\tmatch, _ := ValidateQuery(query)\n\tif !match {\n\t\treturn QueryParams{}, errors.New(\"Not a valid SQL query\")\n\t}\n\twords := strings.Fields(query[0 : len(query)-1])\n\tselectVal := words[1]\n\tfromVal := words[3]\n\torderByVal := \"\"\n\tfor i := 0; i < len(words); i++ {\n\t\tif strings.EqualFold(words[i], \"orderby\") {\n\t\t\torderByVal = strings.ToLower(words[i+1])\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn QueryParams{Select: selectVal, From: fromVal, OrderBy: orderByVal}, nil\n}", "func (o *Request) WithQuery(query url.Values) *Request {\n\to.Query = query\n\treturn o\n}", "func (q *NumberQuery) GetQuery() interface{} {\n\treturn q\n}", "func ParseQuery(schema *graphql.Schema, query string, name string) (*ast.Document, []gqlerrors.FormattedError) {\n\tsource := source.NewSource(&source.Source{\n\t\tBody: []byte(query),\n\t\tName: name,\n\t})\n\tAST, err := parser.Parse(parser.ParseParams{Source: source})\n\tif err != nil {\n\t\treturn nil, gqlerrors.FormatErrors(err)\n\t}\n\n\tvalidationResult := graphql.ValidateDocument(schema, AST, nil)\n\tif validationResult.IsValid {\n\t\treturn AST, nil\n\t}\n\n\treturn nil, validationResult.Errors\n}", "func NewQuery(m map[string]string) Query {\n\treturn Query(m)\n}", "func ParseQuery(query string) (OrderedValues, error) {\n\tov := OrderedValues{}\n\tfor query != \"\" {\n\t\tif err := parseQuery(&ov, &query); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn ov, nil\n}", "func NewQuery(transport *transport.Transport) *Query {\n\treturn &Query{\n\t\ttransport: transport,\n\t}\n}", "func (builder *TsQueryCommandBuilder) WithQuery(query string) *TsQueryCommandBuilder {\n\tbuilder.protobuf.Query = &riak_ts.TsInterpolation{Base: []byte(query)}\n\treturn builder\n}", "func (r *Request) Query(q map[string]string) *Request {\n\tr.query = q\n\treturn r\n}", "func addQuery(u *url.URL, q map[string]string) url.URL {\n\tquery := u.Query()\n\tif q == nil {\n\t\treturn *u\n\t}\n\n\tfor key, value := range q {\n\t\tquery.Add(key, value)\n\t}\n\tu.RawQuery = query.Encode()\n\treturn *u\n}", "func (c *Client) NewQuery(params map[string]string) (*http.Request, error) {\n\tu := *c.baseURL\n\n\tq, err := url.ParseQuery(u.RawQuery)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor key, value := range params {\n\t\tq.Add(key, value)\n\t}\n\tq.Add(\"apikey\", c.apiKey)\n\n\tu.RawQuery = q.Encode()\n\n\treq, err := http.NewRequest(\"GET\", u.String(), http.NoBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Create a request specific headers map.\n\treqHeaders := make(http.Header)\n\treqHeaders.Set(\"Accept\", \"application/json\")\n\n\tfor k, v := range reqHeaders {\n\t\treq.Header[k] = v\n\t}\n\n\treturn req, nil\n}", "func QueryParser(key string) Parser {\n\tfn := func(r *http.Request) (string, error) {\n\t\treturn internal.ParseQuery(key, r, ErrMissingPin)\n\t}\n\n\treturn pinFn(fn)\n}", "func (s *ExecuteScriptInput) SetQuery(v string) *ExecuteScriptInput {\n\ts.Query = &v\n\treturn s\n}", "func RewriteQuery(u url.URL) url.URL {\n\t// query is a copy which we will modify using Set() and use in the result\n\tquery := u.Query()\n\n\tquerystr := query.Get(\"q\")\n\tqueryWords := []string{}\n\tfor _, word := range strings.Split(querystr, \" \") {\n\t\tfmt.Printf(\"word = %v\\n\", word)\n\t\tlower := strings.ToLower(word)\n\t\tif strings.HasPrefix(lower, \"filetype:\") {\n\t\t\tquery.Add(\"filetype\", strings.ToLower(word[len(\"filetype:\"):]))\n\t\t} else if strings.HasPrefix(lower, \"-filetype:\") {\n\t\t\tquery.Add(\"nfiletype\", strings.ToLower(word[len(\"-filetype:\"):]))\n\t\t} else if strings.HasPrefix(lower, \"package:\") {\n\t\t\tquery.Set(\"package\", word[len(\"package:\"):])\n\t\t} else if strings.HasPrefix(lower, \"pkg:\") {\n\t\t\tquery.Set(\"package\", word[len(\"pkg:\"):])\n\t\t} else if strings.HasPrefix(lower, \"-package:\") {\n\t\t\tquery.Add(\"npackage\", word[len(\"-package:\"):])\n\t\t} else if strings.HasPrefix(lower, \"-pkg:\") {\n\t\t\tquery.Add(\"npackage\", word[len(\"-pkg:\"):])\n\t\t} else if strings.HasPrefix(lower, \"path:\") || strings.HasPrefix(lower, \"file:\") {\n\t\t\tquery.Add(\"path\", word[len(\"path:\"):])\n\t\t} else if strings.HasPrefix(lower, \"-path:\") || strings.HasPrefix(lower, \"-file:\") {\n\t\t\tquery.Add(\"npath\", word[len(\"-path:\"):])\n\t\t} else {\n\t\t\tqueryWords = append(queryWords, word)\n\t\t}\n\t}\n\tquery.Set(\"q\", strings.Join(queryWords, \" \"))\n\tu.RawQuery = query.Encode()\n\n\treturn u\n}", "func (loc Location) Query() url.Values {\n\tvs, err := url.ParseQuery(loc[\"query\"])\n\tif err != nil {\n\t\tvs = make(url.Values)\n\t}\n\treturn vs\n}", "func NewQuery(qt types.QueryType, c runner.Client) *Query {\n\treturn &Query{\n\t\tqueryType: qt,\n\t\trunner: runner.New(c),\n\t\targs: make([]interface{}, 0),\n\t}\n}", "func (o *DataExportQuery) SetQuery(v string) {\n\to.Query = &v\n}", "func (c *ClaimsSearchCall) Query(query string) *ClaimsSearchCall {\n\tc.urlParams_.Set(\"query\", query)\n\treturn c\n}", "func MethodFromQuery(param string) MethodOverrideGetter {\n\treturn func(c echo.Context) string {\n\t\treturn c.QueryParam(param)\n\t}\n}", "func (query *Query) CleanQuery() *Query {\n\tquery.content = make(map[string]interface{})\n\treturn query\n}", "func parseQuery(owner *user_model.User, query string) *conan_model.RecipeSearchOptions {\n\topts := &conan_model.RecipeSearchOptions{\n\t\tOwnerID: owner.ID,\n\t}\n\n\tif query != \"\" {\n\t\tparts := strings.Split(strings.ReplaceAll(query, \"@\", \"/\"), \"/\")\n\n\t\topts.Name = parts[0]\n\t\tif len(parts) > 1 && parts[1] != \"*\" {\n\t\t\topts.Version = parts[1]\n\t\t}\n\t\tif len(parts) > 2 && parts[2] != \"*\" {\n\t\t\topts.User = parts[2]\n\t\t}\n\t\tif len(parts) > 3 && parts[3] != \"*\" {\n\t\t\topts.Channel = parts[3]\n\t\t}\n\t}\n\n\treturn opts\n}", "func NewQuery(svcs QueryServices) Query {\n\treturn Query{\n\t\tTransit: transgql.NewQuery(svcs.Transit),\n\t}\n}", "func (o *StatsKeywordParams) SetQuery(query string) {\n\to.Query = query\n}", "func CsrfFromQuery(param string) func(c *fiber.Ctx) (string, error) {\n\treturn func(c *fiber.Ctx) (string, error) {\n\t\ttoken := c.Query(param)\n\t\tif token == \"\" {\n\t\t\treturn \"\", errMissingQuery\n\t\t}\n\t\treturn token, nil\n\t}\n}", "func (builder QueryBuilder) EdgeFromQuery(edge QueryBuilder) QueryBuilder {\n\treturn builder.addEdgeFn(edge, nil)\n}", "func (opts *DiscussionThreadsListOptions) SetFromQuery(ctx context.Context, query string) {\n\tuserList := func(value string) (users []*types.User) {\n\t\tfor _, username := range strings.Fields(value) {\n\t\t\tusername = strings.TrimSpace(strings.TrimPrefix(username, \"@\"))\n\t\t\tuser, err := Users.GetByUsername(ctx, username)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tusers = append(users, user)\n\t\t}\n\t\treturn\n\t}\n\tuserIDsList := func(value string) (users []int32) {\n\t\tfor _, user := range userList(value) {\n\t\t\tusers = append(users, user.ID)\n\t\t}\n\t\treturn\n\t}\n\n\tfindInvolvedThreadIDs := func(value string) (threadIDs []int64) {\n\t\tset := map[int64]struct{}{}\n\t\tfor _, user := range userList(value) {\n\t\t\tcomments, err := DiscussionComments.List(ctx, &DiscussionCommentsListOptions{\n\t\t\t\tAuthorUserID: &user.ID,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor _, comment := range comments {\n\t\t\t\tif _, ok := set[comment.ThreadID]; !ok {\n\t\t\t\t\tset[comment.ThreadID] = struct{}{}\n\t\t\t\t\tthreadIDs = append(threadIDs, comment.ThreadID)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\n\tparseTimeOrDuration := func(value string) *time.Time {\n\t\t// Try parsing as RFC3339 / ISO 8601 first.\n\t\tt, err := time.Parse(time.RFC3339, value)\n\t\tif err == nil {\n\t\t\treturn &t\n\t\t}\n\n\t\t// Try parsing as a relative duration, e.g. \"3d ago\", \"3h4m\", etc.\n\t\tvalue = strings.TrimSuffix(value, \" ago\")\n\t\tt, err = tparse.ParseNow(time.RFC3339, \"now-\"+value)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &t\n\t}\n\n\tvar reported bool\n\toperators := map[string]func(value string){\n\t\t// syntax: `title:\"some title\"` or \"title:sometitle\"\n\t\t// Primarily exists for the negation mode.\n\t\t\"title\": func(value string) {\n\t\t\topts.TitleQuery = &value\n\t\t},\n\t\t\"-title\": func(value string) {\n\t\t\topts.NotTitleQuery = &value\n\t\t},\n\n\t\t// syntax: \"involves:slimsag\" or \"involves:@slimsag\" or \"involves:slimsag @jack\"\n\t\t\"involves\": func(value string) {\n\t\t\topts.ThreadIDs = append(opts.ThreadIDs, findInvolvedThreadIDs(value)...)\n\t\t\tif len(opts.ThreadIDs) == 0 {\n\t\t\t\topts.ThreadIDs = []int64{-1}\n\t\t\t}\n\t\t},\n\t\t\"-involves\": func(value string) {\n\t\t\topts.NotThreadIDs = append(opts.NotThreadIDs, findInvolvedThreadIDs(value)...)\n\t\t},\n\n\t\t// syntax: \"author:slimsag\" or \"author:@slimsag\" or `author:\"slimsag @jack\"`\n\t\t\"author\": func(value string) {\n\t\t\topts.AuthorUserIDs = userIDsList(value)\n\t\t\tif len(opts.AuthorUserIDs) == 0 {\n\t\t\t\topts.AuthorUserIDs = []int32{-1}\n\t\t\t}\n\t\t},\n\t\t\"-author\": func(value string) {\n\t\t\topts.NotAuthorUserIDs = userIDsList(value)\n\t\t},\n\n\t\t// syntax: \"repo:github.com/gorilla/mux\" or \"repo:some/repo\"\n\t\t// TODO(slimsag:discussions): support list syntax here.\n\t\t\"repo\": func(value string) {\n\t\t\trepo, err := Repos.GetByName(ctx, api.RepoName(value))\n\t\t\tif err != nil {\n\t\t\t\ttmp := api.RepoID(-1)\n\t\t\t\topts.TargetRepoID = &tmp\n\t\t\t\treturn\n\t\t\t}\n\t\t\topts.TargetRepoID = &repo.ID\n\t\t},\n\t\t\"-repo\": func(value string) {\n\t\t\trepo, err := Repos.GetByName(ctx, api.RepoName(value))\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\topts.NotTargetRepoID = &repo.ID\n\t\t},\n\n\t\t// syntax: \"file:dir/file.go\" or \"file:something.go\"\n\t\t// TODO(slimsag:discussions): support list syntax here.\n\t\t\"file\": func(value string) {\n\t\t\topts.TargetRepoPath = &value\n\t\t},\n\t\t\"-file\": func(value string) {\n\t\t\topts.NotTargetRepoPath = &value\n\t\t},\n\n\t\t// syntax: \"file:dir/file.go\" or \"file:something.go\"\n\t\t\"before\": func(value string) {\n\t\t\topts.CreatedBefore = parseTimeOrDuration(value)\n\t\t},\n\t\t\"after\": func(value string) {\n\t\t\topts.CreatedAfter = parseTimeOrDuration(value)\n\t\t},\n\n\t\t// syntax: \"order:oldest\" OR \"order:ascending\" etc.\n\t\t\"order\": func(value string) {\n\t\t\tvalue = strings.ToLower(value)\n\t\t\topts.AscendingOrder = value == \"oldest\" || value == \"oldest-first\" || value == \"asc\" || value == \"ascending\"\n\t\t},\n\n\t\t\"reported\": func(value string) {\n\t\t\treported, _ = strconv.ParseBool(value)\n\t\t},\n\t}\n\tremaining, operations := searchquery.Parse(query)\n\tfor _, operation := range operations {\n\t\toperation, value := operation[0], operation[1]\n\t\tif handler, ok := operators[operation]; ok {\n\t\t\thandler(value)\n\t\t\tcontinue\n\t\t}\n\t\t// Since we don't have an operator for this, consider it part of\n\t\t// the remaining search query.\n\t\tremaining = strings.Join([]string{remaining, operation + \":\" + value}, \" \")\n\t}\n\topts.TitleQuery = &remaining\n\n\tif reported {\n\t\t// Searching only for reported threads.\n\t\tif len(opts.ThreadIDs) > 0 {\n\t\t\t// Already have a list of threads we're interested in, e.g. from `involves:slimsag`.\n\t\t\t// Narrow the list down.\n\t\t\tvar newThreads []int64\n\t\t\tfor _, threadID := range opts.ThreadIDs {\n\t\t\t\treportedComments, err := DiscussionComments.Count(ctx, &DiscussionCommentsListOptions{\n\t\t\t\t\tThreadID: &threadID,\n\t\t\t\t\tReported: true,\n\t\t\t\t})\n\t\t\t\tif err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif reportedComments == 0 {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tnewThreads = append(newThreads, threadID)\n\t\t\t}\n\t\t\topts.ThreadIDs = newThreads\n\t\t\tif len(opts.ThreadIDs) == 0 {\n\t\t\t\topts.ThreadIDs = []int64{-1}\n\t\t\t}\n\t\t} else {\n\t\t\t// We don't have an existing list of threads we're interested in.\n\t\t\t// Compile it now.\n\t\t\tcomments, _ := DiscussionComments.List(ctx, &DiscussionCommentsListOptions{\n\t\t\t\tReported: true,\n\t\t\t})\n\t\t\tset := map[int64]struct{}{}\n\t\t\tfor _, comment := range comments {\n\t\t\t\tif _, ok := set[comment.ThreadID]; ok {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tset[comment.ThreadID] = struct{}{}\n\t\t\t\topts.ThreadIDs = append(opts.ThreadIDs, comment.ThreadID)\n\t\t\t}\n\t\t\tif len(opts.ThreadIDs) == 0 {\n\t\t\t\topts.ThreadIDs = []int64{-1}\n\t\t\t}\n\t\t}\n\t}\n}", "func (o *QueryLambdaSql) SetQuery(v string) {\n\to.Query = v\n}", "func (r *BaseRequest) Query() url.Values {\n\tif r.query == nil {\n\t\tr.query = url.Values{}\n\t}\n\treturn r.query\n}", "func (f HyperlinkQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {\n\tif q, ok := q.(*ent.HyperlinkQuery); ok {\n\t\treturn f(ctx, q)\n\t}\n\treturn Denyf(\"ent/privacy: unexpected query type %T, expect *ent.HyperlinkQuery\", q)\n}", "func NewQuery(query *gocql.Query) QueryInterface {\n\treturn &Query{\n\t\tquery,\n\t}\n}", "func (r ApiGetBitlinksByGroupRequest) Query(query string) ApiGetBitlinksByGroupRequest {\n\tr.query = &query\n\treturn r\n}", "func (r AnnounceRequest) ToQuery() (vs url.Values) {\n\tvs = make(url.Values, 9)\n\tvs.Set(\"info_hash\", r.InfoHash.BytesString())\n\tvs.Set(\"peer_id\", r.PeerID.BytesString())\n\tvs.Set(\"uploaded\", strconv.FormatInt(r.Uploaded, 10))\n\tvs.Set(\"downloaded\", strconv.FormatInt(r.Downloaded, 10))\n\tvs.Set(\"left\", strconv.FormatInt(r.Left, 10))\n\n\tif r.IP != \"\" {\n\t\tvs.Set(\"ip\", r.IP)\n\t}\n\tif r.Event > 0 {\n\t\tvs.Set(\"event\", strconv.FormatInt(int64(r.Event), 10))\n\t}\n\tif r.Port > 0 {\n\t\tvs.Set(\"port\", strconv.FormatUint(uint64(r.Port), 10))\n\t}\n\tif r.NumWant != 0 {\n\t\tvs.Set(\"numwant\", strconv.FormatUint(uint64(r.NumWant), 10))\n\t}\n\tif r.Key != 0 {\n\t\tvs.Set(\"key\", strconv.FormatInt(int64(r.Key), 10))\n\t}\n\n\t// BEP 23\n\tif r.Compact {\n\t\tvs.Set(\"compact\", \"1\")\n\t} else {\n\t\tvs.Set(\"compact\", \"0\")\n\t}\n\n\treturn\n}", "func GetFromQuery(c *gin.Context) {\n\tname := c.Query(\"name\")\n\tage := c.Query(\"age\")\n\n\tc.JSON(200, gin.H{\n\t\t\"name\": name,\n\t\t\"age\": age,\n\t})\n}", "func NewQuery(svc productivity.Service) Query {\n\treturn Query{svc: svc}\n}", "func BuildQuery(baseURL string, queryParams ...[]string) string {\n\tbase, err := url.Parse(baseURL)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t\treturn \"\"\n\t}\n\tparams := url.Values{}\n\tfor _, queryParam := range queryParams {\n\t\tparams.Add(queryParam[0], queryParam[1])\n\t}\n\tbase.RawQuery = params.Encode()\n\treturn base.String()\n}", "func (opts ShowOpts) ToShowQuery() (string, error) {\n\tq, err := gophercloud.BuildQueryString(opts)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn q.String(), nil\n}", "func Query(q Mappable) *QueryRequest {\n\treturn &QueryRequest{q}\n}", "func (r *Search) Query(query *types.Query) *Search {\n\n\tr.req.Query = query\n\n\treturn r\n}", "func (l *Middleware) sanitizeQuery(inp string) string {\n\n\tinHiddenWords := func(str string) bool {\n\t\tfor _, w := range hideWords {\n\t\t\tif strings.EqualFold(w, str) {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t\treturn false\n\t}\n\n\tparts := strings.SplitN(inp, \"?\", 2)\n\tif len(parts) < 2 {\n\t\treturn inp\n\t}\n\n\tq, e := url.ParseQuery(parts[1])\n\tif e != nil || len(q) == 0 {\n\t\treturn inp\n\t}\n\n\tres := []string{}\n\tfor k, v := range q {\n\t\tif inHiddenWords(k) {\n\t\t\tres = append(res, fmt.Sprintf(\"%s=********\", k))\n\t\t} else {\n\t\t\tres = append(res, fmt.Sprintf(\"%s=%v\", k, v[0]))\n\t\t}\n\t}\n\tsort.Strings(res) // to make testing persistent\n\treturn parts[0] + \"?\" + strings.Join(res, \"&\")\n}", "func (o HttpRedirectActionOutput) StripQuery() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v HttpRedirectAction) *bool { return v.StripQuery }).(pulumi.BoolPtrOutput)\n}", "func (ig *Instagram) BuildQuery(u *url.URL, qs *url.Values) string {\n\t//Combine the query strings\n\tuQueryString := u.Query()\n\tfor k, v := range uQueryString {\n\t\tfor _, realVal := range v {\n\t\t\tqs.Add(k, realVal)\n\t\t}\n\t}\n\t//TODO(james) toggle based on whether or not user has logged in\n\tqs.Set(\"client_id\", ig.OauthConfig.ClientId)\n\n\treturn u.Scheme + `://` + u.Host + u.Path + `?` + qs.Encode()\n}", "func NewQuerySortOrderFromValue(v string) (*QuerySortOrder, error) {\n\tev := QuerySortOrder(v)\n\tif ev.IsValid() {\n\t\treturn &ev, nil\n\t}\n\treturn nil, fmt.Errorf(\"invalid value '%v' for QuerySortOrder: valid values are %v\", v, allowedQuerySortOrderEnumValues)\n}", "func DeserializeQuery(query *Query, buffer *Buffer, serializationType SerializationType, clientSide bool) error {\n\tvar cClientSide C.int32_t\n\tif clientSide {\n\t\tcClientSide = 1\n\t} else {\n\t\tcClientSide = 0\n\t}\n\n\tret := C.tiledb_deserialize_query(query.context.tiledbContext, buffer.tiledbBuffer, C.tiledb_serialization_type_t(serializationType), cClientSide, query.tiledbQuery)\n\tif ret != C.TILEDB_OK {\n\t\treturn fmt.Errorf(\"Error deserializing query: %s\", query.context.LastError())\n\t}\n\n\treturn nil\n}", "func (pagination *Pagination) ParsingQuery() Where {\n\twhere := make(Where)\n\tquery := pagination.ctx.URL.Query()\n\tfor key, val := range query {\n\t\tif v, ok := pagination.fieldMapping[key]; ok {\n\t\t\tkey = v\n\t\t}\n\n\t\tif len(val) == 1 {\n\t\t\tif val[0] != \"\" {\n\t\t\t\twhere[key] = val[0]\n\t\t\t}\n\t\t}\n\t\tif len(val) > 1 {\n\t\t\twhere[key] = val\n\t\t}\n\t}\n\treturn where\n}", "func (c *Client) ParseTimeRangeQuery(\n\tr *http.Request) (*timeseries.TimeRangeQuery, error) {\n\n\trsc := request.GetResources(r)\n\tif rsc == nil || rsc.PathConfig == nil {\n\t\treturn nil, errors.New(\"missing path config\")\n\t}\n\n\tvar trq *timeseries.TimeRangeQuery\n\tvar err error\n\n\tif f, ok := c.trqParsers[rsc.PathConfig.HandlerName]; ok {\n\t\ttrq, err = f(r)\n\t} else {\n\t\ttrq = nil\n\t\terr = terr.ErrNotTimeRangeQuery\n\t}\n\trsc.TimeRangeQuery = trq\n\treturn trq, err\n}", "func NewQuery() *Query {\n\treturn &Query{targets: make([]string, 0)}\n}", "func (c *OrganizationsDevelopersAppsGetCall) Query(query string) *OrganizationsDevelopersAppsGetCall {\n\tc.urlParams_.Set(\"query\", query)\n\treturn c\n}", "func QueryToJSON(queryString string) ([]byte, error) {\r\n\r\n\tparsedQuery, err := url.ParseQuery(queryString)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\tjsonString, err := json.Marshal(parsedQuery)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\treturn jsonString, nil\r\n}", "func ParseQueryString(values map[string][]string) *NgGrid {\n\tg := &NgGrid{}\n\tif value := values[QS_SORT_DIRECTION]; len(value) != 0 {\n\t\tg.SortDirection = value[0]\n\t}\n\tif value := values[QS_SORT_FIELD]; len(value) != 0 {\n\t\tg.SortField = value[0]\n\t}\n\tif value := values[QS_QUERY]; len(value) != 0 {\n\t\tg.Query = value[0]\n\t}\n\tif value := values[QS_PAGE_NUMBER]; len(value) != 0 {\n\t\tpn, err := strconv.Atoi(value[0])\n\t\tif err == nil {\n\t\t\tg.PageNumber = int64(pn)\n\t\t}\n\t}\n\tif value := values[QS_PAGE_SIZE]; len(value) != 0 {\n\t\tpn, err := strconv.Atoi(value[0])\n\t\tif err == nil {\n\t\t\tg.PageSize = int64(pn)\n\t\t}\n\t}\n\n\tif g.PageNumber < 1 {\n\t\tg.PageNumber = 1\n\t}\n\n\treturn g\n}", "func preprocessQuery(userQuery string) (preprocessedString string) {\n\treg, err := regexp.Compile(\"[^a-zA-Z+#_]+\")\n\tif err != nil {\n\t\t// on failure return original query\n\t\treturn userQuery\n\t}\n\tpreprocessedString = reg.ReplaceAllString(userQuery, \" \")\n\n\treturn preprocessedString\n}", "func (req *Request) SetQuery(key, value string) {\n\treq.query.Set(key, value)\n}", "func QueryInputString(rd *bufio.Reader, query string) string {\n\tfmt.Println(query)\n\tfmt.Printf(\">\")\n\treturn strings.TrimSpace(ReadInputString(rd))\n}", "func (o HttpRedirectActionPtrOutput) StripQuery() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *HttpRedirectAction) *bool {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.StripQuery\n\t}).(pulumi.BoolPtrOutput)\n}", "func (f EquipmentPortQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {\n\tif q, ok := q.(*ent.EquipmentPortQuery); ok {\n\t\treturn f(ctx, q)\n\t}\n\treturn Denyf(\"ent/privacy: unexpected query type %T, expect *ent.EquipmentPortQuery\", q)\n}", "func (f ServiceEndpointQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {\n\tif q, ok := q.(*ent.ServiceEndpointQuery); ok {\n\t\treturn f(ctx, q)\n\t}\n\treturn Denyf(\"ent/privacy: unexpected query type %T, expect *ent.ServiceEndpointQuery\", q)\n}", "func (r *BasicRequest) QueryArgs() (url.Values, error) {\n\treturn url.ParseQuery(r.Query)\n}", "func (c *SubscriptionsListCall) Query(query string) *SubscriptionsListCall {\n\tc.urlParams_.Set(\"query\", query)\n\treturn c\n}", "func NewQuery(ql string, currentTime time.Time) (*influxql.Query, error) {\n\treturn newQuery(ql, currentTime)\n}", "func (f LocationQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {\n\tif q, ok := q.(*ent.LocationQuery); ok {\n\t\treturn f(ctx, q)\n\t}\n\treturn Denyf(\"ent/privacy: unexpected query type %T, expect *ent.LocationQuery\", q)\n}", "func (o *IscsiInitiatorGetIterRequest) SetQuery(newValue IscsiInitiatorGetIterRequestQuery) *IscsiInitiatorGetIterRequest {\n\to.QueryPtr = &newValue\n\treturn o\n}", "func GetPostsFromQuery(context appengine.Context, query *datastore.Query) (*[]Post, error) {\n\n\tvar posts []Post\n\tkeys, err := query.GetAll(context, &posts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor i, key := range keys {\n\t\tposts[i].Id = key.IntID()\n\t}\n\treturn &posts, nil\n}", "func (f TransportQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {\n\tif q, ok := q.(*ent.TransportQuery); ok {\n\t\treturn f(ctx, q)\n\t}\n\treturn Denyf(\"ent/privacy: unexpected query type %T, expect *ent.TransportQuery\", q)\n}", "func (f CarCheckInOutQueryRuleFunc) EvalQuery(ctx context.Context, q ent.Query) error {\n\tif q, ok := q.(*ent.CarCheckInOutQuery); ok {\n\t\treturn f(ctx, q)\n\t}\n\treturn Denyf(\"ent/privacy: unexpected query type %T, expect *ent.CarCheckInOutQuery\", q)\n}" ]
[ "0.71520704", "0.64354426", "0.6182071", "0.6001235", "0.59581524", "0.58681786", "0.58105767", "0.5795819", "0.57879084", "0.57442814", "0.5689765", "0.56753343", "0.56536025", "0.5652858", "0.5604047", "0.5601572", "0.5599599", "0.55983126", "0.55980057", "0.55894464", "0.5588747", "0.5544894", "0.55333894", "0.5520677", "0.5518974", "0.55120087", "0.55098474", "0.5501832", "0.5479742", "0.54698145", "0.54607135", "0.54436517", "0.54338074", "0.5429794", "0.5423033", "0.541512", "0.5385248", "0.5381684", "0.5379911", "0.5360781", "0.5354316", "0.5349316", "0.5348052", "0.5347821", "0.53268117", "0.53218746", "0.53049505", "0.5289194", "0.52866155", "0.527677", "0.527649", "0.5257515", "0.52522767", "0.5250793", "0.5241167", "0.5240408", "0.5215158", "0.5204375", "0.52033776", "0.51866287", "0.5185075", "0.518498", "0.5179735", "0.5170576", "0.51674646", "0.51592505", "0.5157601", "0.51346874", "0.5127451", "0.5122412", "0.512203", "0.5116067", "0.51144296", "0.51137185", "0.51087165", "0.51021296", "0.510184", "0.5094356", "0.508577", "0.50851065", "0.5077697", "0.50670344", "0.50581425", "0.50490224", "0.5045887", "0.5043429", "0.5039161", "0.5037995", "0.5034458", "0.5034174", "0.50299436", "0.50202143", "0.50088674", "0.50022775", "0.49982297", "0.4997934", "0.4995095", "0.49869573", "0.49863276", "0.49790904" ]
0.639297
2
DecodeFrom reads the []byte data from r and decodes them to sr by bencode. r may be the body of the request from the http client.
func (sr *ScrapeResponse) DecodeFrom(r io.Reader) (err error) { return bencode.NewDecoder(r).Decode(sr) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b ByteArray) Decode(r io.Reader) (interface{}, error) {\n\tl, err := util.ReadVarInt(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuf := make([]byte, int(l))\n\t_, err = io.ReadFull(r, buf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buf, nil\n}", "func decodeRequest(_ context.Context, r *http.Request) (request interface{}, err error) {\n\tdefer r.Body.Close()\n\treturn nil, nil\n}", "func Decode(r BytesReader) (interface{}, error) {\n\treturn decodeValue(r)\n}", "func (f *linkFrame) Decode(r io.Reader) (err error) {\n var m map[string]interface{}\n m, err = BencodeReadMap(r)\n if err == nil {\n v, ok := m[\"m\"]\n if ok {\n switch v.(type) {\n case int64:\n f.method = v.(int64)\n break\n default:\n err = errors.New(\"bad method type\")\n return\n }\n } else {\n // no method?\n err = errors.New(\"no method specified\")\n return\n }\n v, ok = m[\"r\"]\n if ok {\n switch v.(type) {\n case int64:\n f.response = v.(int64)\n break\n default:\n err = errors.New(\"bad response type\")\n return\n }\n }\n v, ok = m[\"p\"]\n if ok {\n switch v.(type) {\n case map[string]interface{}:\n f.param = v.(map[string]interface{})\n break\n default:\n err = errors.New(\"Bad parameters type\")\n return\n }\n } else {\n // no parameters?\n err = errors.New(\"no parameters\")\n return\n }\n }\n return\n}", "func (subr *SRRecordResponse) Decode(b []byte) (err error) {\n\tbuffer := bytes.NewReader(b)\n\tcrn := make([]byte, 2)\n\tif _, err = buffer.Read(crn); err != nil {\n\t\treturn fmt.Errorf(\"EGTS_SR_RECORD_RESPONSE; Error reading CRN\")\n\t}\n\tsubr.ConfirmedRecordNumber = binary.LittleEndian.Uint16(crn)\n\tif subr.RecordStatus, err = buffer.ReadByte(); err != nil {\n\t\tlog.Println(err, b)\n\t\treturn fmt.Errorf(\"EGTS_SR_RECORD_RESPONSE; Error reading RST\")\n\t}\n\n\treturn nil\n}", "func decodeRequest(r io.Reader) *plugin.CodeGeneratorRequest {\n\tvar req plugin.CodeGeneratorRequest\n\tinput, err := ioutil.ReadAll(r)\n\tif err != nil {\n\t\tlog.Fatal(\"unable to read stdin: \" + err.Error())\n\t}\n\tif err := proto.Unmarshal(input, &req); err != nil {\n\t\tlog.Fatal(\"unable to marshal stdin as protobuf: \" + err.Error())\n\t}\n\treturn &req\n}", "func Decode(r *http.Request, v interface{}) error {\n\tbodyBytes, err := io.ReadAll(io.LimitReader(r.Body, 1024*1024))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Decode: read body: %w\", err)\n\t}\n\terr = json.Unmarshal(bodyBytes, v)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Decode: json.Unmarshal: %w\", err)\n\t}\n\treturn nil\n}", "func (d *Decoder) Decode() (b B, e error) {\n\tif d.r != nil {\n\t\tbody, e := ioutil.ReadAll(d.r)\n\t\tif e != nil {\n\t\t\treturn b, e\n\t\t}\n\t\td.buf = body\n\t}\n\td.bufLen = len(d.buf)\n\n\td.decode(&b, 1)\n\n\treturn\n}", "func (m *ModifyBearerRequest) DecodeFromBytes(b []byte) error {\n\tlog.Println(\"ModifyBearerRequest.DecodeFromBytes is deprecated. use ModifyBearerRequest.UnmarshalBinary instead\")\n\treturn m.UnmarshalBinary(b)\n}", "func Decode(r *http.Request, v interface{}) error {\n\tbuf, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\trdr := ioutil.NopCloser(bytes.NewBuffer(buf))\n\tr.Body = ioutil.NopCloser(bytes.NewBuffer(buf))\n\n\tif err := json.NewDecoder(rdr).Decode(v); err != nil {\n\t\tfmt.Println(\"json\", err)\n\t\treturn err\n\t}\n\treturn nil\n}", "func Decode(r io.Reader) (image.Image, error)", "func Decode(r io.Reader) (image.Image, error)", "func (broadcast *Broadcast) decodeFromDecrypted(r io.Reader) error {\n\tbroadcast.bm = &Bitmessage{}\n\terr := broadcast.bm.decodeBroadcast(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar sigLength uint64\n\tif sigLength, err = bmutil.ReadVarInt(r); err != nil {\n\t\treturn err\n\t}\n\tif sigLength > obj.SignatureMaxLength {\n\t\tstr := fmt.Sprintf(\"signature length exceeds max length - \"+\n\t\t\t\"indicates %d, but max length is %d\",\n\t\t\tsigLength, obj.SignatureMaxLength)\n\t\treturn wire.NewMessageError(\"DecodeFromDecrypted\", str)\n\t}\n\tbroadcast.sig = make([]byte, sigLength)\n\t_, err = io.ReadFull(r, broadcast.sig)\n\treturn err\n}", "func Decode(body []byte) (B, error) {\n\treturn (&Decoder{\n\t\tr: nil,\n\t\t//buf: append(body[:0:0], body...),\n\t\tbuf: body,\n\t}).Decode()\n}", "func Decode(r io.Reader) (image.Image, error) {}", "func DecodeReqBody(reqBody io.ReadCloser, v interface{}) error {\n\tbody, _ := ioutil.ReadAll(reqBody)\n\terr := json.Unmarshal(body, v)\n\tif err != nil {\n\t\tlog.Printf(\"Error unmarshaling request body: %s\", err)\n\t}\n\n\treqBody.Close()\n\treturn err\n}", "func (r *ReleaseAccessBearersRequest) DecodeFromBytes(b []byte) error {\n\tlog.Println(\"ReleaseAccessBearersRequest.DecodeFromBytes is deprecated. use ReleaseAccessBearersRequest.UnmarshalBinary instead\")\n\treturn r.UnmarshalBinary(b)\n}", "func (m *Unmarshaller) Decode(r io.Reader, obj interface{}) (err error) {\n\tm.reader.r = r\n\tselfUnmarshaler, ok := obj.(cborUnmarshaler)\n\tif ok {\n\t\terr = selfUnmarshaler.UnmarshalCBOR(r)\n\t} else {\n\t\terr = m.unmarshal.Unmarshal(obj)\n\t}\n\tm.reader.r = nil\n\treturn err\n}", "func decode(r *http.Request, v ok) error {\n\tif r.Body == nil {\n\t\treturn errors.New(\"Invalid Body\")\n\t}\n\tif err := json.NewDecoder(r.Body).Decode(v); err != nil {\n\t\treturn err\n\t}\n\treturn v.OK()\n}", "func (b Byte) Decode(r io.Reader) (interface{}, error) {\n\ti, err := util.ReadInt8(r)\n\treturn Byte(i), err\n}", "func readBody(t *testing.T, r io.ReadCloser) *bytes.Buffer {\n\tdefer r.Close()\n\n\tvar b []byte\n\tbuf := bytes.NewBuffer(b)\n\t_, err := buf.ReadFrom(r)\n\tcheck(t, err)\n\n\treturn buf\n}", "func decodeBody(resp *http.Response, out interface{}) error {\n\tbody, err := ioutil.ReadAll(resp.Body)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = json.Unmarshal(body, &out); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (t *EndEntry) decode(r io.Reader) error {\n\treturn nil\n}", "func Decode(r io.Reader, val interface{}) error {\n\treturn NewStream(r, 0).Decode(val)\n}", "func Decode(r []io.Reader) []byte {\n\tp := make([]Pair, len(r))\n\tfor i, v := range r {\n\t\tp[i] = parse(v)\n\t}\n\n\treturn Interleave(p)\n}", "func (c *CreateBearerResponse) DecodeFromBytes(b []byte) error {\n\tlog.Println(\"CreateBearerResponse.DecodeFromBytes is deprecated. use CreateBearerResponse.UnmarshalBinary instead\")\n\treturn c.UnmarshalBinary(b)\n}", "func (r *ReleaseAccessBearersResponse) DecodeFromBytes(b []byte) error {\n\tlog.Println(\"ReleaseAccessBearersResponse.DecodeFromBytes is deprecated. use ReleaseAccessBearersResponse.UnmarshalBinary instead\")\n\treturn r.UnmarshalBinary(b)\n}", "func Base64Decode(b []byte) ([]byte, error) {\r\n\tbuf := make([]byte, base64.RawURLEncoding.DecodedLen(len(b)))\r\n\tn, err := base64.RawURLEncoding.Decode(buf, b)\r\n\treturn buf[:n], err\r\n}", "func (r *Request) Decode(v interface{}) error {\n\treturn r.decode(r.Raw, v)\n}", "func DecodeRequestString(r *http.Request) (string, error) {\n\tif r.Body == http.NoBody || r.Body == nil {\n\t\treturn \"\", errdefs.InvalidParameter(errors.New(\"http body is required\"))\n\t}\n\n\tb, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn \"\", errdefs.InvalidParameter(fmt.Errorf(\"failed to decode request body: %w\", err))\n\t}\n\n\treturn string(b), nil\n}", "func (e *RegisterRequest) ReadFrom(r io.ReadCloser) error {\n\tb, err := ioutil.ReadAll(r)\n\tif err == nil {\n\t\tif b != nil && len(b) != 0 {\n\t\t\terr = json.Unmarshal(b, &e)\n\t\t}\n\t}\n\te.SetDefaults()\n\treturn err\n}", "func Decode(r io.Reader) (Archive, string, error) {\n\tb, _ := ioutil.ReadAll(r)\n\tf := sniff(bytes.NewReader(b))\n\tif f.decode == nil {\n\t\treturn nil, \"\", ErrFormat\n\t}\n\tm := f.decode(bytes.NewReader(b))\n\treturn m, f.name, nil\n}", "func (b UnsignedByte) Decode(r io.Reader) (interface{}, error) {\n\ti, err := util.ReadUint8(r)\n\treturn UnsignedByte(i), err\n}", "func readBody(r *http.Request, v interface{}) error {\n\tbody, err := ioutil.ReadAll(r.Body)\n\t_ = r.Body.Close()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"body read: %w\", err)\n\t}\n\n\terr = json.Unmarshal(body, v)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"json decode: %w\", err)\n\t}\n\n\treturn nil\n}", "func NewDecoder(enc *Encoding, r io.Reader) io.Reader {\n\treturn &decoder{enc: enc, r: r}\n}", "func decodeBody(resp *http.Response, out interface{}) error {\n\tdefer resp.Body.Close()\n\tdec := json.NewDecoder(resp.Body)\n\treturn dec.Decode(out)\n}", "func Decode(s string, l int) ([]byte, error) {\n\tr, err := base64.RawURLEncoding.DecodeString(s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(r) != l {\n\t\treturn nil, fmt.Errorf(\"base64: wrong length %d (expecting %d): %s\", 2*len(r), 2*l, s)\n\t}\n\treturn r, nil\n}", "func (a *Authorization) ReadFrom(r io.Reader) (int64, error) {\n\tvar n int64\n\tvar err error\n\tr = base64.NewDecoder(base64.StdEncoding, r)\n\tbuf := bufio.NewReader(r)\n\t// timestamp\n\ttimestamp, err := buf.ReadBytes('|')\n\tif err != nil {\n\t\treturn n, err\n\t}\n\tn += int64(len(timestamp))\n\t// remove delimiter\n\ttimestamp = timestamp[:len(timestamp)-1]\n\ta.timestamp, err = strconv.ParseInt(string(timestamp), 10, 64)\n\tif err != nil {\n\t\treturn n, err\n\t}\n\t// read buffer parts\n\tvar read int\n\tfor _, binBuf := range [][]byte{a.salt, a.signature} {\n\t\tread, err = buf.Read(binBuf)\n\t\tif err != nil {\n\t\t\treturn n, err\n\t\t}\n\t\tn += int64(read)\n\t}\n\ta.rawMsg, err = ioutil.ReadAll(buf)\n\tif err != nil {\n\t\treturn n, err\n\t}\n\tn += int64(len(a.rawMsg))\n\treturn n, err\n}", "func (p *DubboCodec) DecodeDubboReqBodyForRegstry(req *Request, bodyBuf *util.ReadBuffer) int {\n\tvar obj interface{}\n\tvar err error\n\tif req.IsHeartbeat() {\n\t\t//decodeHeartbeatData\n\t\tobj, err = bodyBuf.ReadObject()\n\t\tif err != nil {\n\t\t\treq.SetData(err.Error())\n\t\t\treq.SetBroken(true)\n\t\t\treturn -1\n\t\t}\n\t} else if req.IsEvent() {\n\t\t//decodeEventData\n\t\tobj, err = bodyBuf.ReadObject()\n\t\tif err != nil {\n\t\t\treq.SetData(err.Error())\n\t\t\treq.SetBroken(true)\n\t\t\treturn -1\n\t\t}\n\t} else {\n\t\treq.SetAttachment(DubboVersionKey, bodyBuf.ReadString())\n\t\treq.SetAttachment(PathKey, bodyBuf.ReadString())\n\t\treq.SetAttachment(VersionKey, bodyBuf.ReadString())\n\t\treq.SetVersion(req.GetAttachment(VersionKey, \"\"))\n\t\treq.SetMethodName(bodyBuf.ReadString())\n\n\t\t//解析参数\n\t\ttypeDesc := string(bodyBuf.ReadString())\n\t\tagrsArry := util.TypeDesToArgsObjArry(typeDesc)\n\t\tif typeDesc == \"\" {\n\t\t\tagrsArry = nil\n\t\t} else {\n\t\t\tsize := len(agrsArry)\n\t\t\tif req.GetMethodName() == \"subscribe\" {\n\t\t\t\tsize = 1\n\t\t\t}\n\t\t\tfor i := 0; i < size; i++ {\n\t\t\t\tval, err := bodyBuf.ReadObject()\n\t\t\t\tif err != nil {\n\t\t\t\t\treq.SetBroken(true)\n\t\t\t\t\treq.SetData(err.Error())\n\t\t\t\t\treturn -1\n\t\t\t\t} else {\n\t\t\t\t\tagrsArry[i].SetValue(val)\n\t\t\t\t}\n\t\t\t}\n\t\t\treq.SetArguments(agrsArry)\n\t\t}\n\n\t\tif err == nil {\n\t\t\treq.SetAttachments(nil)\n\t\t} else {\n\t\t\treq.SetBroken(true)\n\t\t\treq.SetData(err.Error())\n\t\t\treturn -1\n\t\t}\n\t\treq.SetBroken(false)\n\t\treq.SetData(obj)\n\t}\n\n\treturn 0\n}", "func (d *Decoder) Reset(r io.Reader) error {\n\tif d.current.err == ErrDecoderClosed {\n\t\treturn d.current.err\n\t}\n\n\td.drainOutput()\n\n\td.syncStream.br.r = nil\n\tif r == nil {\n\t\td.current.err = ErrDecoderNilInput\n\t\tif len(d.current.b) > 0 {\n\t\t\td.current.b = d.current.b[:0]\n\t\t}\n\t\td.current.flushed = true\n\t\treturn nil\n\t}\n\n\t// If bytes buffer and < 5MB, do sync decoding anyway.\n\tif bb, ok := r.(byter); ok && bb.Len() < d.o.decodeBufsBelow && !d.o.limitToCap {\n\t\tbb2 := bb\n\t\tif debugDecoder {\n\t\t\tprintln(\"*bytes.Buffer detected, doing sync decode, len:\", bb.Len())\n\t\t}\n\t\tb := bb2.Bytes()\n\t\tvar dst []byte\n\t\tif cap(d.syncStream.dstBuf) > 0 {\n\t\t\tdst = d.syncStream.dstBuf[:0]\n\t\t}\n\n\t\tdst, err := d.DecodeAll(b, dst)\n\t\tif err == nil {\n\t\t\terr = io.EOF\n\t\t}\n\t\t// Save output buffer\n\t\td.syncStream.dstBuf = dst\n\t\td.current.b = dst\n\t\td.current.err = err\n\t\td.current.flushed = true\n\t\tif debugDecoder {\n\t\t\tprintln(\"sync decode to\", len(dst), \"bytes, err:\", err)\n\t\t}\n\t\treturn nil\n\t}\n\t// Remove current block.\n\td.stashDecoder()\n\td.current.decodeOutput = decodeOutput{}\n\td.current.err = nil\n\td.current.flushed = false\n\td.current.d = nil\n\td.syncStream.dstBuf = nil\n\n\t// Ensure no-one else is still running...\n\td.streamWg.Wait()\n\tif d.frame == nil {\n\t\td.frame = newFrameDec(d.o)\n\t}\n\n\tif d.o.concurrent == 1 {\n\t\treturn d.startSyncDecoder(r)\n\t}\n\n\td.current.output = make(chan decodeOutput, d.o.concurrent)\n\tctx, cancel := context.WithCancel(context.Background())\n\td.current.cancel = cancel\n\td.streamWg.Add(1)\n\tgo d.startStreamDecoder(ctx, r, d.current.output)\n\n\treturn nil\n}", "func DecodeRequest(source io.Reader, format wrp.Format) (*Request, error) {\n\tcontents, err := io.ReadAll(source)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// nolint: typecheck\n\tmessage := new(wrp.Message)\n\tif err := wrp.NewDecoderBytes(contents, format).Decode(message); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// nolint: typecheck\n\terr = wrp.UTF8(message)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Request{\n\t\tMessage: message,\n\t\tFormat: format,\n\t\tContents: contents,\n\t}, nil\n}", "func DecodeFrom(d encoding.Decoder, x interface{}, typ reflect.Type) error {\n\tfrom := reflect.New(typ)\n\tif err := d.Decode(from.Interface()); err != nil {\n\t\treturn err\n\t}\n\treturn convertFrom(reflect.ValueOf(x), from)\n}", "func NewDecoder(r io.Reader) *Decoder {\n\td := &Decoder{}\n\tif rr, ok := r.(*bufio.Reader); ok {\n\t\td.r = rr\n\t} else {\n\t\td.r = bufio.NewReader(r)\n\t}\n\treturn d\n}", "func NewDecoder(enc *Encoding, r io.Reader) io.Reader {\n\treturn &decoder{enc: enc, r: &newlineFilteringReader{r}}\n}", "func decode(r *http.Response) (MsgResponse, error) {\n\tdefer r.Body.Close()\n\tvar res MsgRawResponse\n\terr := json.NewDecoder(r.Body).Decode(&res)\n\tif err != nil {\n\t\treturn MsgResponse{}, err\n\t}\n\n\t// if the response has an error\n\tif res.Error != nil {\n\t\treturn MsgResponse{}, errors.New(res.Error.Message)\n\t}\n\n\treturn MsgResponse{\n\t\tMessageID: res.MessageID,\n\t\tRecipientID: res.RecipientID,\n\t}, nil\n}", "func decodeVerifyRequest(_ context.Context, r interface{}) (interface{}, error) {\n\trq := r.(*pb.VerifyRequest)\n\n\treturn endpoint.VerifyRequest{\n\t\tToken: rq.Token,\n\t\tType: rq.Type,\n\t\tCode: rq.Code,\n\t}, nil\n}", "func Decode(src []byte) (dst [10]byte)", "func NewDecoder(r io.Reader) *Decoder {\n\th := sha1.New()\n\treturn &Decoder{\n\t\tr: io.TeeReader(r, h),\n\t\thash: h,\n\t\textReader: bufio.NewReader(nil),\n\t}\n}", "func NewDecoder(b []byte) *Decoder {\n\treturn &Decoder{orig: b, in: b}\n}", "func NewDecoder(r io.Reader) goa.Decoder {\n\treturn codec.NewDecoder(r, &Handle)\n}", "func decodeBody(resp *http.Response, out interface{}) error {\n\tdec := json.NewDecoder(resp.Body)\n\treturn dec.Decode(out)\n}", "func decodeBody(resp *http.Response, out interface{}) error {\n\tswitch resp.ContentLength {\n\tcase 0:\n\t\tif out == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.New(\"Got 0 byte response with non-nil decode object\")\n\tdefault:\n\t\tdec := json.NewDecoder(resp.Body)\n\t\treturn dec.Decode(out)\n\t}\n}", "func decodeReq(r *http.Request, to interface{}) error {\n\tif err := json.NewDecoder(r.Body).Decode(to); err != nil {\n\t\tif err != io.EOF {\n\t\t\treturn errors.WithStack(err)\n\t\t}\n\t}\n\treturn nil\n}", "func decodeBody(resp *http.Response, out interface{}) (error) {\n\tswitch resp.ContentLength {\n\tcase 0:\n\t\tif out == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.New(\"Got 0 byte response with non-nil decode object\")\n\tdefault:\n\t\tdec := json.NewDecoder(resp.Body)\n\t\treturn dec.Decode(out)\n\t}\n}", "func (tbr *TransportBaseReqquesst) DecodePOSTRequest(ctx context.Context, r *http.Request) (interface{}, error) {\n\tbodyBytes, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn nil, errors.New(\"read body data error\")\n\t}\n\trouterPath := ctx.Value(auth.HttpPATH)\n\trequestMethodName := fmt.Sprintf(\"Decode%sRequest\", fmt.Sprintf(\"%v\", routerPath))\n\tif callResult := core.CallReflect(tbr, requestMethodName, bodyBytes); callResult != nil {\n\t\treturn callResult[0].Interface(), nil\n\t}\n\treturn nil, errors.New(\"read body data error\")\n}", "func RibFromBytes(b []byte) ([]*RIBMessage, error) {\n\tvar ribs []*RIBMessage\n\treader := bufio.NewReader(bytes.NewReader(b))\n\tfor {\n\t\tl, _, err := reader.ReadLine()\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tr, err := RibEntryFromString(string(l))\n\t\tif err != nil {\n\t\t\treturn ribs, err\n\t\t}\n\t\tribs = append(ribs, r)\n\t}\n\n\treturn ribs, nil\n}", "func NewDecoder(r io.Reader) (*Decoder, error) {\n\tdata, err := ioutil.ReadAll(r)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"reading data before decoding\")\n\t}\n\n\treturn &Decoder{buf: bytes.NewReader(data)}, nil\n}", "func decodeJsonBody(target interface{}, r *http.Request) error {\n\tbody, err := ioutil.ReadAll(io.LimitReader(r.Body, 1048576))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.Body.Close(); err != nil {\n\t\treturn err\n\t}\n\tif err := json.Unmarshal(body, target); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func DecodePushRequest(b io.Reader, r *logproto.PushRequest) error {\n\tvar request loghttp.PushRequest\n\n\terr := json.NewDecoder(b).Decode(&request)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t*r = NewPushRequest(request)\n\n\treturn nil\n}", "func decodeFromBase64(encodedXdr string) *b.TransactionEnvelopeBuilder {\n // Unmarshall from base64 encoded XDR format\n var decoded xdr.TransactionEnvelope\n e := xdr.SafeUnmarshalBase64(encodedXdr, &decoded)\n if e != nil {\n log.Fatal(e)\n }\n\n // convert to TransactionEnvelopeBuilder\n txEnvelopeBuilder := b.TransactionEnvelopeBuilder{E: &decoded}\n txEnvelopeBuilder.Init()\n\n return &txEnvelopeBuilder\n}", "func decodeFromBase64(encodedXdr string) *b.TransactionEnvelopeBuilder {\n // Unmarshall from base64 encoded XDR format\n var decoded xdr.TransactionEnvelope\n e := xdr.SafeUnmarshalBase64(encodedXdr, &decoded)\n if e != nil {\n log.Fatal(e)\n }\n\n // convert to TransactionEnvelopeBuilder\n txEnvelopeBuilder := b.TransactionEnvelopeBuilder{E: &decoded}\n txEnvelopeBuilder.Init()\n\n return &txEnvelopeBuilder\n}", "func (p *DubboCodec) DecodeDubboRspBody(buffer *util.ReadBuffer, rsp *DubboRsp) int {\n\tvar obj interface{}\n\tvar err error\n\n\tif rsp.IsHeartbeat() {\n\t\trsp.SetValue(HeartBeatEvent)\n\t}\n\t//获取状态\n\tif rsp.GetStatus() == Ok {\n\t\tif rsp.IsHeartbeat() && (HeartBeatEvent == rsp.GetValue()) {\n\t\t\t//decodeHeartbeatData\n\t\t\tobj, err = buffer.ReadObject()\n\t\t\tif err != nil {\n\t\t\t\trsp.SetStatus(ServerError)\n\t\t\t\trsp.SetErrorMsg(err.Error())\n\t\t\t\treturn 0\n\t\t\t}\n\t\t} else if rsp.mEvent {\n\t\t\t//decodeEventData\n\t\t\tobj, err = buffer.ReadObject()\n\t\t\tif err != nil {\n\t\t\t\trsp.SetStatus(ServerError)\n\t\t\t\trsp.SetErrorMsg(err.Error())\n\t\t\t\treturn 0\n\t\t\t}\n\t\t} else {\n\t\t\t//decodeResult\n\t\t\tvar valueType byte = buffer.ReadByte()\n\t\t\tswitch valueType {\n\t\t\tcase ResponseNullValue:\n\t\t\t\t//do nothing\n\t\t\t\trsp.SetValue(nil)\n\t\t\t\treturn 0\n\t\t\tcase ResponseValue:\n\t\t\t\tobj, err = buffer.ReadObject()\n\t\t\t\tif err != nil {\n\t\t\t\t\trsp.SetStatus(ServerError)\n\t\t\t\t\trsp.SetErrorMsg(err.Error())\n\t\t\t\t\treturn -1\n\t\t\t\t}\n\t\t\tcase ResponseWithException:\n\t\t\t\t//readObject,设置异常\n\t\t\t\trsp.SetStatus(ServiceError)\n\t\t\t\tobj, err = buffer.ReadObject()\n\t\t\t\tif err != nil {\n\t\t\t\t\trsp.SetStatus(ServerError)\n\t\t\t\t\trsp.SetErrorMsg(err.Error())\n\t\t\t\t\treturn 0\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\trsp.SetValue(obj)\n\t} else {\n\t\tobj, err = buffer.ReadObject()\n\t\tif err != nil {\n\t\t\trsp.SetErrorMsg(err.Error())\n\t\t} else {\n\t\t\tif s, ok := obj.(string); !ok {\n\t\t\t\trsp.SetErrorMsg(\"unknown error\")\n\t\t\t} else {\n\t\t\t\trsp.SetErrorMsg(s)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 0\n}", "func (sysLogConn *Connection) Decode(r io.Reader) error {\n\tif sysLogConn.bufferedReader == nil {\n\t\tsysLogConn.bufferedReader = bufio.NewReader(r)\n\t}\n\n\tstringmessage, err := sysLogConn.bufferedReader.ReadString(0)\n\tif err != nil {\n\t\treturn err\n\t}\n\tselect {\n\tcase sysLogConn.logReader <- stringmessage:\n\tdefault:\n\n\t}\n\treturn nil\n}", "func decodeFromBase64(encodedXdr string) *b.TransactionEnvelopeBuilder {\n\t// Unmarshall from base64 encoded XDR format\n\tvar decoded xdr.TransactionEnvelope\n\te := xdr.SafeUnmarshalBase64(encodedXdr, &decoded)\n\tif e != nil {\n\t\tlog.Fatal(e)\n\t}\n\n\t// convert to TransactionEnvelopeBuilder\n\ttxEnvelopeBuilder := b.TransactionEnvelopeBuilder{E: &decoded}\n\ttxEnvelopeBuilder.Init()\n\n\treturn &txEnvelopeBuilder\n}", "func NewDecoder(r io.Reader) *Decoder {\n\treturn &Decoder{\n\t\tr: r,\n\t\torder: binary.LittleEndian,\n\t}\n}", "func Decode(reader io.Reader, boundary string) (Type, error) {\n\tr := bufio.NewReader(reader)\n\tif len(boundary) > 0 {\n\t\treturn decodeform(r, boundary)\n\t}\n\tpeek, err := r.Peek(2)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tswitch string(peek) {\n\tcase `--`:\n\t\treturn decodeform(r, boundary)\n\t}\n\treturn decodevars(r)\n}", "func (t *LeaveEntry) decode(r io.Reader) error {\n\treturn nil\n}", "func (o *CloseSessionResponse) DecodeFromBytes(b []byte) error {\n\tvar offset = 0\n\to.TypeID = &datatypes.ExpandedNodeID{}\n\tif err := o.TypeID.DecodeFromBytes(b[offset:]); err != nil {\n\t\treturn err\n\t}\n\toffset += o.TypeID.Len()\n\n\to.ResponseHeader = &ResponseHeader{}\n\treturn o.ResponseHeader.DecodeFromBytes(b[offset:])\n}", "func BodyToReader(r *http.Request) (Reader, error) {\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\treturn Reader{}, WrapErr(\"failed to read request body\", err)\n\t}\n\n\treturn NewReader(body), nil\n}", "func (d *Decoder) Decode(m interface{}) error {\n\tvar (\n\t\tbuf = d.buf\n\t\treadlen = 0\n\t)\n\tfor {\n\t\teof, nr, err := d.r.ReadFrame(buf)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treadlen += nr\n\t\tif readlen > MaxSize {\n\t\t\treturn ErrSize\n\t\t}\n\n\t\tif eof {\n\t\t\treturn d.uf(d.buf[:readlen], m)\n\t\t}\n\n\t\tif len(buf) == nr {\n\t\t\t// readlen and len(d.buf) are the same here\n\t\t\tnewbuf := make([]byte, readlen+4096)\n\t\t\tcopy(newbuf, d.buf)\n\t\t\td.buf = newbuf\n\t\t\tbuf = d.buf[readlen:]\n\t\t} else {\n\t\t\tbuf = buf[nr:]\n\t\t}\n\t}\n}", "func (v *HandshakeRequest) Decode(sr stream.Reader) error {\n\n\tif err := sr.ReadStructBegin(); err != nil {\n\t\treturn err\n\t}\n\n\tfh, ok, err := sr.ReadFieldBegin()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor ok {\n\t\tswitch {\n\t\tdefault:\n\t\t\tif err := sr.Skip(fh.Type); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tif err := sr.ReadFieldEnd(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif fh, ok, err = sr.ReadFieldBegin(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif err := sr.ReadStructEnd(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (msg *RegisterRMRequest) Decode(buf *goetty.ByteBuf) {\n\tmsg.abstractIdentifyRequest.Decode(buf)\n\tmsg.ResourceIDs = ReadBigString(buf)\n}", "func (d *Decoder) Decode(r io.Reader) io.Reader {\n\tdec := newVideoDecryptor(r)\n\treturn &dec\n}", "func Decode(mediaType string, body io.Reader, v interface{}) error {\n\tdecodersMu.RLock()\n\td, ok := decoders[mediaType]\n\tdecodersMu.RUnlock()\n\tif ok {\n\t\treturn d(body, v)\n\t}\n\treturn errors.New(\"http client: decoder by media type '\" + mediaType + \"' not found\")\n}", "func decode(ch channel.Receiver, v interface{}) error {\n\tbits, err := ch.Recv()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn json.Unmarshal(bits, v)\n}", "func Decode(r io.Reader, v any) error {\n\tdecoder := json.NewDecoder(r)\n\n\tfor {\n\t\tif err := decoder.Decode(v); errors.Is(err, io.EOF) {\n\t\t\tbreak\n\t\t} else if err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func base64Decode(b string) string {\n\tdata, err := base64.StdEncoding.DecodeString(b)\n\tif err != nil {\n\t\treturn string(b)\n\t}\n\treturn string(data)\n}", "func decodeBody(resp *http.Response, out interface{}) error {\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//fmt.Println(\"response Body:\", string(body))\n\n\t// Unmarshal the XML.\n\tif err = xml.Unmarshal(body, &out); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (r *KubeCover) decodeInput(req *http.Request, data interface{}) (string, error) {\n\t// step: read in the content payload\n\tcontent, err := ioutil.ReadAll(req.Body)\n\tif err != nil {\n\t\tglog.Errorf(\"unable to read in the content, error: %s\", err)\n\t\treturn \"\", err\n\t}\n\tdefer func() {\n\t\t// we need to set the content back\n\t\treq.Body = ioutil.NopCloser(bytes.NewReader(content))\n\t}()\n\n\trdr := strings.NewReader(string(content))\n\n\t// step: decode the json\n\terr = json.NewDecoder(rdr).Decode(data)\n\tif err != nil {\n\t\tglog.Errorf(\"unable to decode the request body, error: %s\", err)\n\t\treturn \"\", err\n\t}\n\n\treturn string(content), nil\n}", "func (d *raptorDecoder) Decode() []byte {\n\tif !d.matrix.determined() {\n\t\treturn nil\n\t}\n\n\td.matrix.reduce()\n\n\t// Now the intermediate blocks are held in d.matrix.v. Use the encoder function\n\t// to recover the source blocks.\n\tintermediate := d.matrix.v\n\tsource := make([]block, d.codec.NumSourceSymbols)\n\tfor i := 0; i < d.codec.NumSourceSymbols; i++ {\n\t\tsource[i] = ltEncode(d.codec.NumSourceSymbols, uint16(i), intermediate)\n\t}\n\n\tlenLong, lenShort, numLong, numShort := partition(d.messageLength, d.codec.NumSourceSymbols)\n\tout := make([]byte, d.messageLength)\n\tout = out[0:0]\n\tfor i := 0; i < numLong; i++ {\n\t\tout = append(out, source[i].data[0:lenLong]...)\n\t}\n\tfor i := numLong; i < numLong+numShort; i++ {\n\t\tout = append(out, source[i].data[0:lenShort]...)\n\t}\n\treturn out\n}", "func decodeResponse(r io.Reader, reply interface{}) error {\n\tvar c response\n\tbuf := new(bytes.Buffer)\n\tbuf.ReadFrom(r)\n\tif err := json.Unmarshal(buf.Bytes(), &c); err != nil {\n\t\treturn fmt.Errorf(\"cannot decode response body = %s, err = %v\", buf.String(), err)\n\t}\n\tif c.Error != nil {\n\t\treturn &errObj{Data: c.Error}\n\t}\n\tif c.Result == nil {\n\t\treturn ErrNullResult\n\t}\n\treturn json.Unmarshal(*c.Result, reply)\n}", "func decodeStringRequest(_ context.Context, r *http.Request) (interface{}, error) {\n\tvars := mux.Vars(r)\n\trequestType, ok := vars[\"type\"]\n\tif !ok {\n\t\treturn nil, ErrorBadRequest\n\t}\n\n\tpa, ok := vars[\"a\"]\n\tif !ok {\n\t\treturn nil, ErrorBadRequest\n\t}\n\n\tpb, ok := vars[\"b\"]\n\tif !ok {\n\t\treturn nil, ErrorBadRequest\n\t}\n\n\treturn endpoint.StringRequest{\n\t\tRequestType: requestType,\n\t\tA: pa,\n\t\tB: pb,\n\t}, nil\n}", "func DecodeBody(ctx context.Context, req *http.Request, m interface{}) error {\n\tif err := json.NewDecoder(req.Body).Decode(m); err != nil {\n\t\treturn errors.New(http.StatusText(http.StatusBadRequest))\n\t}\n\treturn nil\n}", "func (tbr *TransportBaseReqquesst) DecodeGETRequest(ctx context.Context, r *http.Request) (interface{}, error) {\n\t//首字母设为大写\n\trequestMethodName := fmt.Sprintf(\"Decode%sRequest\", fmt.Sprintf(\"%v\", ctx.Value(auth.HttpPATH)))\n\tdata := []byte{}\n\tif callResult := core.CallReflect(tbr, requestMethodName, data); callResult != nil {\n\t\treturn callResult[0].Interface(), nil\n\t}\n\treturn nil, errors.New(\"read body data error\")\n}", "func NewDecoder(r io.Reader) *Decoder {\n\tdec := new(Decoder)\n\t// We use the ability to read bytes as a plausible surrogate for buffering.\n\tif _, ok := r.(io.ByteReader); !ok {\n\t\tr = bufio.NewReader(r)\n\t}\n\tdec.r = r\n\treturn dec\n}", "func (d RawDataDecoder) Decode(v interface{}) error {\n\tdata, err := ioutil.ReadAll(d.reader)\n\tif err != nil {\n\t\treturn err\n\t}\n\tswitch v.(type) {\n\tcase FromBytes:\n\t\t(v.(FromBytes)).SetBytes(data)\n\tdefault:\n\t\treturn errors.New(\"RawDataDecoder only admits FromBytes interface\")\n\t}\n\treturn nil\n}", "func decodeBody(req *http.Request, out interface{}, cb func(interface{}) error) error {\n\t// This generally only happens in tests since real HTTP requests set\n\t// a non-nil body with no content. We guard against it anyways to prevent\n\t// a panic. The EOF response is the same behavior as an empty reader.\n\tif req.Body == nil {\n\t\treturn io.EOF\n\t}\n\n\tvar raw interface{}\n\tdec := json.NewDecoder(req.Body)\n\tif err := dec.Decode(&raw); err != nil {\n\t\treturn err\n\t}\n\n\t// Invoke the callback prior to decode\n\tif cb != nil {\n\t\tif err := cb(raw); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tdecodeConf := &mapstructure.DecoderConfig{\n\t\tDecodeHook: mapstructure.ComposeDecodeHookFunc(\n\t\t\tmapstructure.StringToTimeDurationHookFunc(),\n\t\t\tstringToReadableDurationFunc(),\n\t\t),\n\t\tResult: &out,\n\t}\n\n\tdecoder, err := mapstructure.NewDecoder(decodeConf)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn decoder.Decode(raw)\n}", "func (msg *BranchRegisterRequest) Decode(buf *goetty.ByteBuf) {\n\tmsg.XID = ReadXID(buf)\n\tmsg.BranchType = BranchType(ReadByte(buf))\n\tmsg.ResourceID = ReadString(buf)\n\tmsg.LockKey = ReadBigString(buf)\n\tmsg.ApplicationData = ReadBigString(buf)\n}", "func (r *Request) ReadFrom(rd io.Reader) (n int64, err error) {\n\t// On the first step we will read the OpenFlow header, so\n\t// we could get the total length of the OpenFlow message.\n\tn, err = r.Header.ReadFrom(rd)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Decode the protocol version major and minor number to\n\t// make the request interface more or less friendly.\n\tr.ProtoMajor = 1\n\tr.ProtoMinor = int(r.Header.Version - 1)\n\n\t// FIXME: wrong for version 2\n\tr.Proto = fmt.Sprintf(\"OFP/1.%d\", r.ProtoMinor)\n\n\tcontentlen := int64(r.Header.Len() - headerlen)\n\tif contentlen < 0 {\n\t\tfmt.Println(\"!!! %s\", contentlen)\n\t\treturn n, ErrCorruptedHeader\n\t}\n\n\t// Define a buffer to fit the content of the OpenFlow package.\n\tn, buf := 0, make([]byte, int(contentlen))\n\n\t// Read all data the from the stream into the allocated buffer.\n\t//\n\t// Due to bufferized nature of the reader, it can take multiple\n\t// reads from the reader to retrieve the body completely.\n\tfor n < contentlen {\n\t\tnn, err := rd.Read(buf[n:])\n\t\tif n += int64(nn); err != nil {\n\t\t\treturn n + headerlen, err\n\t\t}\n\t}\n\n\tr.Body = bytes.NewBuffer(buf)\n\tr.ContentLength = contentlen\n\treturn n + headerlen, nil\n}", "func (s String) Decode(r io.Reader) (interface{}, error) {\n\tstr, err := util.ReadString(r)\n\treturn String(str), err\n}", "func (d Decoder) Decode(dst interface{}) error {\n\td1 := json.NewDecoder(d.r)\n\n\terr1 := d1.Decode(dst)\n\tif err1 != nil {\n\t\td2 := form.NewDecoder(d.r)\n\n\t\terr2 := d2.Decode(dst)\n\t\tif err2 != nil {\n\t\t\treturn fmt.Errorf(\"%v; %v\", err1, err2)\n\t\t}\n\t}\n\n\treturn nil\n}", "func decodeString(b byteReader) (string, error) {\n\tlength, err := binary.ReadVarint(b)\n\tif length < 0 {\n\t\terr = fmt.Errorf(\"found negative string length during decoding: %d\", length)\n\t}\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tbuf := getBuf(int(length))\n\tdefer putBuf(buf)\n\n\tif _, err := io.ReadFull(b, buf); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn string(buf), nil\n}", "func DecodeReader(r io.Reader, ptr interface{}) error {\n\treturn json.NewDecoder(r).Decode(ptr)\n}", "func NewDecoder(\n\tr io.Reader,\n\tminimumTelomereLength int,\n\tmaximumTelomereLength int,\n\tbufferSize int,\n) *Decoder {\n\tif minimumTelomereLength == 0 {\n\t\tpanic(\"minimum telomere length cannot be 0\")\n\t}\n\tif maximumTelomereLength == 0 {\n\t\tpanic(\"maximum telomere length cannot be 0\")\n\t}\n\tif minimumTelomereLength > maximumTelomereLength {\n\t\tpanic(\"minimum telomere length cannot be greater than the maximum\")\n\t}\n\tif minimumTelomereLength >= bufferSize {\n\t\tpanic(\"telomere length must be less than the allocated buffer size\")\n\t}\n\treturn &Decoder{\n\t\tminimum: minimumTelomereLength,\n\t\tmaximum: maximumTelomereLength,\n\t\tb: make([]byte, bufferSize),\n\t\tr: r,\n\t}\n}", "func NewDecoder(r io.Reader) *Decoder {\n\td := new(Decoder)\n\td.src = textproto.NewReader(bufio.NewReader(r))\n\td.attrs = make(map[string]struct{}, 8)\n\td.multi = make(map[string]struct{}, 8)\n\td.finfo = make(map[string][]int, 8)\n\treturn d\n}", "func decodePostAcceptDealRequest(_ context.Context, r *http1.Request) (interface{}, error) {\n\treq := endpoint.PostAcceptDealRequest{}\n\terr := json.NewDecoder(r.Body).Decode(&req)\n\treturn req, err\n}", "func (d *decoder) Decode(s *bufio.Scanner) (obj interface{}, err error) {\n\tb, err := ReadBytes(s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(b) == 0 {\n\t\tlog.Err(\"empty or malformed payload: %q\", b)\n\t\treturn nil, ErrBadMsg\n\t}\n\n\tswitch b[0] {\n\tcase STRING:\n\t\treturn decodeString(b)\n\tcase INT:\n\t\treturn decodeInt(b)\n\tcase NIL:\n\t\treturn nil, decodeNil(s)\n\tcase SLICE:\n\t\treturn d.decodeSlice(b, s)\n\tcase MAP:\n\t\treturn d.decodeMap(b, s)\n\tcase ERROR:\n\t\treturn decodeErr(b)\n\t}\n\n\tlog.Err(\"unsupported payload type: %q\", b)\n\treturn nil, ErrUnsupportedType\n}", "func NewDecoder(r io.Reader) (d *Decoder) {\n scanner := bufio.NewScanner(r)\n return &Decoder{\n scanner: scanner,\n lineno: 0,\n }\n}", "func Decode(r io.Reader, w io.Writer) {\n\td := decoder{}\n\n\td.w = w\n\td.r = bitstream.NewReader(r)\n\n\td.decode()\n}", "func decodeJSON(r *http.Request, obj interface{}) ([]byte, error) {\n\tfuncTag := \"decodeJSON\"\n\n\tif obj == nil {\n\t\treturn nil, nil\n\t}\n\n\tbody, err := ioutil.ReadAll(io.LimitReader(r.Body, 1048576))\n\tif err != nil {\n\t\treturn nil, apierr.Errorf(err, funcTag, \"cannot decode json\")\n\t}\n\n\t// Restore the io.ReadCloser to its original state\n\tr.Body = ioutil.NopCloser(bytes.NewBuffer(body))\n\n\t/*\n\t\tif err := r.Body.Close(); err != nil {\n\t\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\t\"err\": err,\n\t\t\t}).Warn(\"Error closing request body\")\n\n\t\t\treturn nil, pipoerr.NewCannotCloseRequestBodyError(tag, err)\n\t\t}\n\t*/\n\n\t// Unmarshal body into obj interface\n\tif err := json.Unmarshal(body, obj); err != nil {\n\t\treturn nil, apierr.Errorf(err, funcTag, \"error marshaling JSON to struct\")\n\t}\n\n\treturn body, nil\n}" ]
[ "0.59442586", "0.59435", "0.5875654", "0.57637095", "0.5762973", "0.57587105", "0.57179385", "0.5701968", "0.56631243", "0.5660476", "0.56205285", "0.56205285", "0.5595051", "0.5578567", "0.5553057", "0.55511975", "0.55382675", "0.5473444", "0.5471069", "0.54231274", "0.54012084", "0.538057", "0.53779393", "0.5374678", "0.53462213", "0.53373986", "0.53371257", "0.5319208", "0.5310471", "0.52859306", "0.5284536", "0.5279196", "0.5273174", "0.52390426", "0.52324855", "0.52182186", "0.5212067", "0.5208781", "0.52060926", "0.5193851", "0.51808715", "0.5173932", "0.51675737", "0.5164333", "0.5161804", "0.5160858", "0.51608115", "0.515919", "0.5137727", "0.5133774", "0.5120477", "0.5114628", "0.51121426", "0.50876623", "0.5084925", "0.5084133", "0.5083404", "0.5082524", "0.5080091", "0.5075444", "0.5075444", "0.50665855", "0.50659066", "0.5061541", "0.5061001", "0.5058868", "0.5057907", "0.50489193", "0.5046555", "0.50451666", "0.5044", "0.50423306", "0.5039164", "0.5036577", "0.5032328", "0.50314504", "0.50251365", "0.49957788", "0.49872592", "0.4975603", "0.49721718", "0.49697655", "0.4959912", "0.49562335", "0.49554676", "0.49514297", "0.49471918", "0.49452806", "0.49416384", "0.49393472", "0.49332207", "0.49330258", "0.49295118", "0.49258244", "0.49248263", "0.49235466", "0.4923338", "0.49186474", "0.49121612", "0.4911864" ]
0.66547966
0
EncodeTo encodes the response to []byte by bencode and write the result into w. w may be http.ResponseWriter.
func (sr ScrapeResponse) EncodeTo(w io.Writer) (err error) { return bencode.NewEncoder(w).Encode(sr) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (resp *Response) WriteTo(w http.ResponseWriter) {\n\tif resp.buf != nil {\n\t\tresp.Body = resp.buf.Bytes()\n\t\tresp.buf = nil\n\t}\n\n\tif w != nil {\n\t\t// Write the headers\n\t\tfor k, vs := range resp.Header {\n\t\t\t// Reset existing values\n\t\t\tw.Header().Del(k)\n\t\t\tif len(vs) == 1 {\n\t\t\t\tw.Header().Set(k, resp.Header.Get(k))\n\t\t\t}\n\t\t\tif len(vs) > 1 {\n\t\t\t\tfor _, v := range vs {\n\t\t\t\t\tw.Header().Add(k, v)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif resp.redirect != \"\" {\n\t\t\thttp.Redirect(w, resp.req, resp.redirect, resp.StatusCode)\n\t\t\treturn\n\t\t}\n\n\t\tw.WriteHeader(resp.StatusCode)\n\t\tw.Write(resp.Body)\n\t}\n}", "func (res Responder) WriteTo(w io.Writer) (int64, error) {\n\treturn res.b.WriteTo(w)\n}", "func (w responseWriter) Write(b []byte) (int, error) {\n\t// 向一个bytes.buffer中写一份数据来为获取body使用\n\tw.b.Write(b)\n\t// 完成http.ResponseWriter.Write()原有功能\n\treturn w.ResponseWriter.Write(b)\n}", "func (p *Poll) EncodeToByte() []byte {\n\tb, _ := json.Marshal(p)\n\treturn b\n}", "func writeHTTPResponseInWriter(httpRes http.ResponseWriter, httpReq *http.Request, nobelPrizeWinnersResponse []byte, err error) {\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\thttp.Error(httpRes, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tlog.Printf(\"Request %s Succesfully Completed\", httpReq.RequestURI)\n\thttpRes.Header().Set(\"Content-Type\", \"application/json\")\n\thttpRes.Write(nobelPrizeWinnersResponse)\n}", "func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) (err error) {\n\tresp := response.(*common.XmidtResponse)\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Header().Set(common.HeaderWPATID, ctx.Value(common.ContextKeyRequestTID).(string))\n\tcommon.ForwardHeadersByPrefix(\"\", resp.ForwardedHeaders, w.Header())\n\n\tw.WriteHeader(resp.Code)\n\t_, err = w.Write(resp.Body)\n\treturn\n}", "func encodeResponse(resp *plugin.CodeGeneratorResponse, w io.Writer) {\n\toutBytes, err := proto.Marshal(resp)\n\tif err != nil {\n\t\tlog.Fatal(\"unable to marshal response to protobuf: \" + err.Error())\n\t}\n\n\tif _, err := w.Write(outBytes); err != nil {\n\t\tlog.Fatal(\"unable to write protobuf to stdout: \" + err.Error())\n\t}\n}", "func encodeGetUserResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func (r *Response) Write(w io.Writer) error", "func (e *RegisterRequest) WriteTo(w http.ResponseWriter) error {\n\tb, err := json.Marshal(e)\n\tif err != nil {\n\t\treturn err\n\t}\n\tw.Header().Set(\"content-type\", \"application/json\")\n\tw.Write(b)\n\treturn nil\n}", "func encodeGetResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func encodeGetResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func (w *WriterInterceptor) Write(b []byte) (int, error) {\n\tlength := w.response.Header.Get(\"Content-Length\")\n\tif length == \"\" || length == \"0\" {\n\t\tw.buf = b\n\t\treturn w.DoWrite()\n\t}\n\n\tw.response.ContentLength += int64(len(b))\n\tw.buf = append(w.buf, b...)\n\n\t// If not EOF\n\tif cl, _ := strconv.Atoi(length); w.response.ContentLength != int64(cl) {\n\t\treturn len(b), nil\n\t}\n\n\tw.response.Body = ioutil.NopCloser(bytes.NewReader(w.buf))\n\tresm := NewResponseModifier(w.response.Request, w.response)\n\tw.modifier(resm)\n\treturn w.DoWrite()\n}", "func Encode(w http.ResponseWriter, r *http.Request, status int, v interface{}) error {\n\tb, err := json.Marshal(v)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"encode json\")\n\t}\n\tvar out io.Writer = w\n\tif strings.Contains(r.Header.Get(\"Accept-Encoding\"), \"gzip\") {\n\t\tw.Header().Set(\"Content-Encoding\", \"gzip\")\n\t\tgzw := gzip.NewWriter(w)\n\t\tout = gzw\n\t\tdefer gzw.Close()\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tw.WriteHeader(status)\n\tif _, err := out.Write(b); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func EncodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n return json.NewEncoder(w).Encode(response)\n}", "func (res *pbResponse) MarshalTo(buf []byte) (int, error) {\n\tvar size = uint64(res.Size())\n\tif uint64(cap(buf)) >= size {\n\t\tbuf = buf[:size]\n\t} else {\n\t\treturn 0, fmt.Errorf(\"proto: pbResponse: buf is too short\")\n\t}\n\tvar offset uint64\n\tvar n uint64\n\tif res.Seq != 0 {\n\t\tbuf[offset] = 1<<3 | 0\n\t\toffset++\n\t\t//n = code.EncodeVarint(buf[offset:], res.Seq)\n\t\t{\n\t\t\tvar t = res.Seq\n\t\t\tvar size = code.SizeofVarint(t)\n\t\t\tfor i := uint64(0); i < size-1; i++ {\n\t\t\t\tbuf[offset+i] = byte(t) | 0x80\n\t\t\t\tt >>= 7\n\t\t\t}\n\t\t\tbuf[offset+size-1] = byte(t)\n\t\t\tn = size\n\t\t}\n\t\toffset += n\n\t}\n\tif len(res.Error) > 0 {\n\t\tbuf[offset] = 2<<3 | 2\n\t\toffset++\n\t\t//n = code.EncodeString(buf[offset:], res.Error)\n\t\t{\n\t\t\tvar length = uint64(len(res.Error))\n\t\t\tvar lengthSize = code.SizeofVarint(length)\n\t\t\tvar s = lengthSize + length\n\t\t\tt := length\n\t\t\tfor i := uint64(0); i < lengthSize-1; i++ {\n\t\t\t\tbuf[offset+i] = byte(t) | 0x80\n\t\t\t\tt >>= 7\n\t\t\t}\n\t\t\tbuf[offset+lengthSize-1] = byte(t)\n\t\t\tcopy(buf[offset+lengthSize:], res.Error)\n\t\t\tn = s\n\t\t}\n\t\toffset += n\n\t}\n\tif len(res.Reply) > 0 {\n\t\tbuf[offset] = 3<<3 | 2\n\t\toffset++\n\t\t//n = code.EncodeBytes(buf[offset:], res.Reply)\n\t\t{\n\t\t\tvar length = uint64(len(res.Reply))\n\t\t\tvar lengthSize = code.SizeofVarint(length)\n\t\t\tvar s = lengthSize + length\n\t\t\tt := length\n\t\t\tfor i := uint64(0); i < lengthSize-1; i++ {\n\t\t\t\tbuf[offset+i] = byte(t) | 0x80\n\t\t\t\tt >>= 7\n\t\t\t}\n\t\t\tbuf[offset+lengthSize-1] = byte(t)\n\t\t\tcopy(buf[offset+lengthSize:], res.Reply)\n\t\t\tn = s\n\t\t}\n\t\toffset += n\n\t}\n\treturn int(offset), nil\n}", "func (bs endecBytes) WriteTo(w io.Writer) (int64, error) {\n\tn, err := w.Write(bs)\n\treturn int64(n), err\n}", "func writeResponse(body []byte, w *http.ResponseWriter) {\n\t(*w).Header().Set(\"Content-Type\", \"text/plain; charset=utf-8\")\n\t_, err := (*w).Write(body)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\t(*w).WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func writeResponse(data interface{}, w http.ResponseWriter) error {\n\tvar (\n\t\tenc []byte\n\t\terr error\n\t)\n\tenc, err = json.Marshal(data)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to marshal, err = %s\", err)\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tn, err := w.Write(enc)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Failure to write, err = %s\", err)\n\t}\n\tif n != len(enc) {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn fmt.Errorf(\"Short write sent = %d, wrote = %d\", len(enc), n)\n\t}\n\treturn nil\n}", "func (w *ResponseWriterTee) Write(b []byte) (int, error) {\n\tw.Buffer.Write(b)\n\treturn w.w.Write(b)\n}", "func encodeByteSlice(w io.Writer, bz []byte) (err error) {\n\terr = encodeVarint(w, int64(len(bz)))\n\tif err != nil {\n\t\treturn\n\t}\n\t_, err = w.Write(bz)\n\treturn\n}", "func EncodeDoublySecureResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {\n\treturn func(ctx context.Context, w http.ResponseWriter, v any) error {\n\t\tres, _ := v.(string)\n\t\tenc := encoder(ctx, w)\n\t\tbody := res\n\t\tw.WriteHeader(http.StatusOK)\n\t\treturn enc.Encode(body)\n\t}\n}", "func encode(i interface{}, w http.ResponseWriter) {\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\n\tenc := json.NewEncoder(w)\n\terr := enc.Encode(i)\n\t// Problems encoding\n\tif err != nil {\n\t\tLoggingClient.Error(\"Error encoding the data: \" + err.Error())\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func encodeGetUserDealByStateResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func (o *SearchTournamentsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make([]*models.Tournament, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func encodeGetDealByStateResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tif e, ok := response.(errorer); ok && e.error() != nil {\n\t\t// Not a Go kit transport error, but a business-logic error.\n\t\t// Provide those as HTTP errors.\n\t\tencodeError(ctx, e.error(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", ContentType)\n\treturn json.NewEncoder(w).Encode(response)\n}", "func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tif e, ok := response.(errorer); ok && e.error() != nil {\n\t\tEncodeError(ctx, e.error(), w)\n\t\treturn nil\n\t}\n\n\tw.WriteHeader(http.StatusOK)\n\treturn nil\n}", "func WriteBytes(w http.ResponseWriter, status int, text []byte) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(status)\n\tw.Write(text)\n}", "func (DefaultDispatcher) Write(rw http.ResponseWriter, resp Response) error {\n\tswitch x := resp.(type) {\n\tcase JSONResponse:\n\t\trw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\tio.WriteString(rw, \")]}',\\n\") // Break parsing of JavaScript in order to prevent XSSI.\n\t\treturn json.NewEncoder(rw).Encode(x.Data)\n\tcase *TemplateResponse:\n\t\tt, ok := (x.Template).(*template.Template)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%T is not a safe template and it cannot be parsed and written\", t)\n\t\t}\n\t\trw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\t\tif len(x.FuncMap) == 0 {\n\t\t\tif x.Name == \"\" {\n\t\t\t\treturn t.Execute(rw, x.Data)\n\t\t\t}\n\t\t\treturn t.ExecuteTemplate(rw, x.Name, x.Data)\n\t\t}\n\t\tcloned, err := t.Clone()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcloned = cloned.Funcs(x.FuncMap)\n\t\tif x.Name == \"\" {\n\t\t\treturn cloned.Execute(rw, x.Data)\n\t\t}\n\t\treturn cloned.ExecuteTemplate(rw, x.Name, x.Data)\n\tcase safehtml.HTML:\n\t\trw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\t\t_, err := io.WriteString(rw, x.String())\n\t\treturn err\n\tcase FileServerResponse:\n\t\trw.Header().Set(\"Content-Type\", x.ContentType())\n\t\t// The http package will take care of writing the file body.\n\t\treturn nil\n\tcase RedirectResponse:\n\t\thttp.Redirect(rw, x.Request.req, x.Location, int(x.Code))\n\t\treturn nil\n\tcase NoContentResponse:\n\t\trw.WriteHeader(int(StatusNoContent))\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"%T is not a safe response type and it cannot be written\", resp)\n\t}\n}", "func (j *JSendWriterBuffer) Write(b []byte) (int, error) {\n\treturn j.responseWriter.Write(b)\n}", "func (w *customResponseWriter) Write(b []byte) (int, error) {\n\tif w.status == 0 {\n\t\tw.status = http.StatusOK\n\t}\n\tn, err := w.ResponseWriter.Write(b)\n\tw.length += n\n\treturn n, err\n}", "func EncodeProcessingResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {\n\treturn func(ctx context.Context, w http.ResponseWriter, v any) error {\n\t\tres, _ := v.([]string)\n\t\tenc := encoder(ctx, w)\n\t\tbody := res\n\t\tw.WriteHeader(http.StatusOK)\n\t\treturn enc.Encode(body)\n\t}\n}", "func (r tokenResponseWriter) Write(b []byte) (int, error) {\n\treturn r.w.Write(b) // pass it to the original ResponseWriter\n}", "func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\treturn json.NewEncoder(w).Encode(response)\n}", "func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\treturn json.NewEncoder(w).Encode(response)\n}", "func JsonEncodeAndWriteResponse(response http.ResponseWriter, value interface{}) error {\n\n\tif value == nil {\n\t\treturn NewStackError(\"Nil value passed\")\n\t}\n\n\trawJson, err := json.Marshal(value)\n\tif err != nil {\n\t\thttp.Error(response, \"Error\", 500)\n\t\treturn NewStackError(\"Unable to marshal json: %v\", err)\n\t}\n\n\tresponse.Header().Set(ContentTypeHeader, ContentTypeJson)\n\n\twritten, err := response.Write(rawJson)\n\tif err != nil {\n\t\treturn NewStackError(\"Unable to write response: %v\", err)\n\t}\n\n\tif written != len(rawJson) {\n\t\treturn NewStackError(\"Unable to write full response - wrote: %d - expected: %d\", written, len(rawJson))\n\t}\n\n\treturn nil\n}", "func ToBytes(inter interface{}) []byte {\n\treqBodyBytes := new(bytes.Buffer)\n\tjson.NewEncoder(reqBodyBytes).Encode(inter)\n\tfmt.Println(reqBodyBytes.Bytes()) // this is the []byte\n\tfmt.Println(string(reqBodyBytes.Bytes())) // converted back to show it's your original object\n\treturn reqBodyBytes.Bytes()\n}", "func EncodeAlsoDoublySecureResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {\n\treturn func(ctx context.Context, w http.ResponseWriter, v any) error {\n\t\tres, _ := v.(string)\n\t\tenc := encoder(ctx, w)\n\t\tbody := res\n\t\tw.WriteHeader(http.StatusOK)\n\t\treturn enc.Encode(body)\n\t}\n}", "func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\t// Set JSON type\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\n\t// Check error\n\tif e, ok := response.(errorer); ok {\n\t\t// This is a errorer class, now check for error\n\t\tif err := e.error(); err != nil {\n\t\t\tencodeError(ctx, e.error(), w)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// cast to dataHolder to get Data, otherwise just encode the resposne\n\tif holder, ok := response.(dataHolder); ok {\n\t\treturn json.NewEncoder(w).Encode(holder.getData())\n\t} else {\n\t\treturn json.NewEncoder(w).Encode(response)\n\t}\n}", "func encodeGetByCreteriaResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func (o *GetBackendsBackendIDTestOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func encodeTextResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tif r, ok := response.(io.Reader); ok {\n\t\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\t_, err := io.Copy(w, r)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (handler Handler) Write(w http.ResponseWriter, b []byte) (int, error) {\n\treturn w.Write(b)\n}", "func (request *RequestResponseFrame) WriteTo(w io.Writer) (wrote int64, err error) {\n\tif wrote, err = request.Header.WriteTo(w); err != nil {\n\t\treturn\n\t}\n\n\tvar n int64\n\n\tif request.HasMetadata() {\n\t\tif n, err = request.Metadata.WriteTo(w); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\twrote += n\n\t}\n\n\tif n, err = writeExact(w, []byte(request.Data)); err != nil {\n\t\treturn\n\t}\n\n\twrote += n\n\n\treturn\n}", "func (e *RegistryV2Error) WriteAsRegistryV2ResponseTo(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tfor k, v := range e.Headers {\n\t\tw.Header()[k] = v\n\t}\n\tif e.Status == 0 {\n\t\tw.WriteHeader(apiErrorStatusCodes[e.Code])\n\t} else {\n\t\tw.WriteHeader(e.Status)\n\t}\n\tif r.Method != http.MethodHead {\n\t\tbuf, _ := json.Marshal(struct {\n\t\t\tErrors []*RegistryV2Error `json:\"errors\"`\n\t\t}{\n\t\t\tErrors: []*RegistryV2Error{e},\n\t\t})\n\t\tw.Write(append(buf, '\\n'))\n\t}\n}", "func (w *multiWriter) Write(b []byte) (int, error) {\n\tvar resp logrus.Fields\n\tif w.isJSONResponse() {\n\t\tif err := json.Unmarshal(b, &resp); err != nil {\n\t\t\treturn 0, err\n\t\t}\n\t\tw.ctx.Set(\"response\", resp)\n\t} else {\n\t\tw.ctx.Set(\"response\", b)\n\t}\n\treturn w.ResponseWriter.Write(b)\n}", "func writeResponse(w http.ResponseWriter, code int, object interface{}) {\n\tfmt.Println(\"writing response:\", code, object)\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tw.Header().Set(\"content-type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func EncodeGetResponse(_ context.Context, w http.ResponseWriter, response interface{}) (err error) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\te := json.NewEncoder(w)\n\te.SetIndent(\"\", \"\\t\")\n\terr = e.Encode(response)\n\treturn err\n}", "func (res *AddResponse) Encode(_ context.Context, w ResponseWriter) error {\n\treturn w.WriteError(ldaputil.ApplicationAddResponse, errors.New(\"not implemented\"))\n}", "func (o *GetWhaleTranfersOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\t// return empty array\n\t\tpayload = make([]*models.OperationsRow, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n}", "func encodeTransactionOutputsToBuffer(buf []byte, obj *transactionOutputs) error {\n\tif uint64(len(buf)) < encodeSizeTransactionOutputs(obj) {\n\t\treturn encoder.ErrBufferUnderflow\n\t}\n\n\te := &encoder.Encoder{\n\t\tBuffer: buf[:],\n\t}\n\n\t// obj.Out maxlen check\n\tif len(obj.Out) > 65535 {\n\t\treturn encoder.ErrMaxLenExceeded\n\t}\n\n\t// obj.Out length check\n\tif uint64(len(obj.Out)) > math.MaxUint32 {\n\t\treturn errors.New(\"obj.Out length exceeds math.MaxUint32\")\n\t}\n\n\t// obj.Out length\n\te.Uint32(uint32(len(obj.Out)))\n\n\t// obj.Out\n\tfor _, x := range obj.Out {\n\n\t\t// x.Address.Version\n\t\te.Uint8(x.Address.Version)\n\n\t\t// x.Address.Key\n\t\te.CopyBytes(x.Address.Key[:])\n\n\t\t// x.Coins\n\t\te.Uint64(x.Coins)\n\n\t\t// x.Hours\n\t\te.Uint64(x.Hours)\n\n\t}\n\n\treturn nil\n}", "func (w *responseWriter) Write(b []byte) (int, error) {\n\tif w.Status == 0 {\n\t\tw.Status = 200\n\t}\n\tn, err := w.ResponseWriter.Write(b)\n\tw.Length += n\n\treturn n, err\n}", "func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tif e, ok := response.(errorer); ok && e.error() != nil {\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\tw.WriteHeader(codeFrom(e.error()))\n\t\treturn marshalStructWithError(response, w)\n\t}\n\n\t// Used for pagination\n\tif e, ok := response.(counter); ok {\n\t\tw.Header().Set(\"X-Total-Count\", strconv.Itoa(e.count()))\n\t}\n\n\t// Don't overwrite a header (i.e. called from encodeTextResponse)\n\tif v := w.Header().Get(\"Content-Type\"); v == \"\" {\n\t\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\t// Only write json body if we're setting response as json\n\t\treturn json.NewEncoder(w).Encode(response)\n\t}\n\treturn nil\n}", "func (r *TotalBalanceStateContext) EncodeToEth(resp *iotexapi.ReadStateResponse) (string, error) {\n\ttotal, ok := new(big.Int).SetString(string(resp.Data), 10)\n\tif !ok {\n\t\treturn \"\", errConvertBigNumber\n\t}\n\n\tdata, err := _totalBalanceMethod.Outputs.Pack(total)\n\tif err != nil {\n\t\treturn \"\", nil\n\t}\n\n\treturn hex.EncodeToString(data), nil\n}", "func (r *Tracker) Write(b []byte) (int, error) {\n\tif !r.Written() {\n\t\tr.WriteHeader(http.StatusOK)\n\t}\n\tif !r.Response.Discard {\n\t\tr.Response.Body.Write(b)\n\t}\n\treturn r.ResponseWriter.Write(b)\n}", "func (r *ResponseReverter) Write(buf []byte) (int, error) {\n\tn, err := r.ResponseWriter.Write(buf)\n\treturn n, err\n}", "func (b ByteArray) Encode(w io.Writer) error {\n\terr := util.WriteVarInt(w, len(b))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = w.Write(b)\n\treturn err\n}", "func EncodeCreateResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, interface{}) error {\n\treturn func(ctx context.Context, w http.ResponseWriter, v interface{}) error {\n\t\tres := v.(*inventoryviews.Inventory)\n\t\tenc := encoder(ctx, w)\n\t\tbody := NewCreateResponseBody(res.Projected)\n\t\tw.WriteHeader(http.StatusOK)\n\t\treturn enc.Encode(body)\n\t}\n}", "func WriteResponse(w http.ResponseWriter, code int, object interface{}) {\n\tdata, err := json.Marshal(object)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tw.Write(data)\n}", "func (c *Context) WriteResponse(obj interface{}, statusCode int) os.Error {\n\n\tvar error os.Error\n\n\t// get the formatter\n\tformatter, error := GetFormatter(c.Format)\n\n\tif error != nil {\n\t\tc.writeInternalServerError(error, http.StatusNotFound)\n\t\treturn error\n\t} else {\n\n\t\t// set the content type\n\t\tc.ResponseWriter.Header()[\"Content-Type\"] = []string{formatter.ContentType()}\n\n\t\t// format the output\n\t\toutput, error := formatter.Format(obj)\n\n\t\tif error != nil {\n\t\t\tc.writeInternalServerError(error, http.StatusInternalServerError)\n\t\t\treturn error\n\t\t} else {\n\n\t\t\toutputString := string(output)\n\n\t\t\t/*\n\t\t\t\tJSONP\n\t\t\t*/\n\t\t\tcallback := c.GetCallback()\n\t\t\tif callback != \"\" {\n\n\t\t\t\t// wrap with function call\n\n\t\t\t\trequestContext := c.GetRequestContext()\n\n\t\t\t\toutputString = callback + \"(\" + outputString\n\n\t\t\t\tif requestContext != \"\" {\n\t\t\t\t\toutputString = outputString + \", \\\"\" + requestContext + \"\\\")\"\n\t\t\t\t} else {\n\t\t\t\t\toutputString = outputString + \")\"\n\t\t\t\t}\n\n\t\t\t\t// set the new content type\n\t\t\t\tc.ResponseWriter.Header()[\"Content-Type\"] = []string{JSONP_CONTENT_TYPE}\n\n\t\t\t}\n\n\t\t\t// write the status code\n\t\t\tif strings.Index(c.Request.URL.Raw, REQUEST_ALWAYS200_PARAMETER) > -1 {\n\n\t\t\t\t// \"always200\"\n\t\t\t\t// write a fake 200 status code (regardless of what the actual code was)\n\t\t\t\tc.ResponseWriter.WriteHeader(http.StatusOK)\n\n\t\t\t} else {\n\n\t\t\t\t// write the actual status code\n\t\t\t\tc.ResponseWriter.WriteHeader(statusCode)\n\n\t\t\t}\n\n\t\t\t// write the output\n\t\t\tc.ResponseWriter.Write([]uint8(outputString))\n\n\t\t}\n\n\t}\n\n\t// success - no errors\n\treturn nil\n\n}", "func encodeStringResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tw.Header().Set(\"Content-Type\", \"application/json;charset=utf-8\")\n\treturn json.NewEncoder(w).Encode(response)\n}", "func EncodeChangeResponse(_ context.Context, w http.ResponseWriter, response interface{}) (err error) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\te := json.NewEncoder(w)\n\te.SetIndent(\"\", \"\\t\")\n\terr = e.Encode(response)\n\treturn err\n}", "func responseToCLient(w http.ResponseWriter, str string) {\n\tw.Write([]byte(str)) // writing back to response writer\n}", "func encodeResponse(w http.ResponseWriter, resp interface{}) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(resp)\n}", "func encodeResponse(ctx context.Context, responseWriter http.ResponseWriter, response interface{}) error {\n\tif err, ok := response.(errorer); ok && err.error() != nil {\n\t\t// Not a Go kit transport error, but a business-logic error.\n\t\t// Provide those as HTTP errors.\n\t\tencodeError(ctx, err.error(), responseWriter)\n\t\treturn nil\n\t}\n\tresponseWriter.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\treturn json.NewEncoder(responseWriter).Encode(response)\n}", "func EncodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\n\tif e, ok := response.(Errorer); ok {\n\t\t// Not a Go kit transport error, but a business-logic error.\n\t\t// Provide those as HTTP errors.\n\t\tEncodeError(ctx, e.Error, w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\tw.WriteHeader(http.StatusOK)\n\treturn json.NewEncoder(w).Encode(response)\n}", "func encode(i interface{}, w http.ResponseWriter) {\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\n\tenc := json.NewEncoder(w)\n\terr := enc.Encode(i)\n\n\tif err != nil {\n\t\tLoggingClient.Error(\"Error encoding the data: \" + err.Error())\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n}", "func (ti TypeItem) ToBytes() []byte {\n\treqBodyBytes := new(bytes.Buffer)\n\tjson.NewEncoder(reqBodyBytes).Encode(ti)\n\treturn reqBodyBytes.Bytes()\n}", "func (o *GetTradesByAccountOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tpayload := o.Payload\n\tif payload == nil {\n\t\tpayload = make(models.GetTradesByAccountOKBody, 0, 50)\n\t}\n\n\tif err := producer.Produce(rw, payload); err != nil {\n\t\tpanic(err) // let the recovery middleware deal with this\n\t}\n\n}", "func (e *Encoder) WriteTo(w io.Writer, data interface{}) error {\n\te.Reset(w)\n\treturn e.WriteObject(data)\n}", "func (a *Authorization) WriteTo(w io.Writer) (int64, error) {\n\tvar n int64\n\tvar err error\n\twr := base64.NewEncoder(base64.StdEncoding, w)\n\tdefer wr.Close()\n\tts := a.timestampBytes()\n\twritten, err := wr.Write(append(ts, '|'))\n\tif err != nil {\n\t\treturn n, err\n\t}\n\tn += int64(written)\n\tfor _, binBuf := range [][]byte{a.salt, a.signature, a.rawMsg} {\n\t\twritten, err = wr.Write(binBuf)\n\t\tif err != nil {\n\t\t\treturn n, err\n\t\t}\n\t\tn += int64(written)\n\t}\n\treturn n, err\n}", "func (request *RequestFireAndForgetFrame) WriteTo(w io.Writer) (wrote int64, err error) {\n\tif wrote, err = request.Header.WriteTo(w); err != nil {\n\t\treturn\n\t}\n\n\tvar n int64\n\n\tif request.HasMetadata() {\n\t\tif n, err = request.Metadata.WriteTo(w); err != nil {\n\t\t\treturn\n\t\t}\n\n\t\twrote += n\n\t}\n\n\tif n, err = writeExact(w, []byte(request.Data)); err != nil {\n\t\treturn\n\t}\n\n\twrote += n\n\n\treturn\n}", "func encodeGetDealByDIDResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func (bf *BloomFilter) ToBytes(binBuf *bytes.Buffer) error {\n\n\tbinary.Write(binBuf, binary.LittleEndian, bf.errorRate)\n\tbinary.Write(binBuf, binary.LittleEndian, uint64(bf.numSlices))\n\tbinary.Write(binBuf, binary.LittleEndian, uint64(bf.bitsPerSlice))\n\tbinary.Write(binBuf, binary.LittleEndian, uint64(bf.capacity))\n\tbinary.Write(binBuf, binary.LittleEndian, uint64(bf.count))\n\n\treturn bf.bitarray.ToBytes(binBuf)\n}", "func EncodeSecureResponse(encoder func(context.Context, http.ResponseWriter) goahttp.Encoder) func(context.Context, http.ResponseWriter, any) error {\n\treturn func(ctx context.Context, w http.ResponseWriter, v any) error {\n\t\tres, _ := v.(string)\n\t\tenc := encoder(ctx, w)\n\t\tbody := res\n\t\tw.WriteHeader(http.StatusOK)\n\t\treturn enc.Encode(body)\n\t}\n}", "func Write(w http.ResponseWriter, btes []byte, status int, contentType string) error {\n\tw.Header().Add(\"Content-Type\", contentType)\n\tw.Header().Add(\"Content-Length\", fmt.Sprintf(\"%d\", len(btes)))\n\tWriteProcessTime(w)\n\tw.WriteHeader(status)\n\t_, err := w.Write(btes)\n\treturn err\n}", "func (r *responseInfoRecorder) Write(b []byte) (int, error) {\n\tr.ContentLength += int64(len(b))\n\tif r.statusCode == 0 {\n\t\tr.statusCode = http.StatusOK\n\t}\n\treturn r.ResponseWriter.Write(b)\n}", "func encodeUploadResponse(ctx context.Context, w http.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\tif err != nil {\n\t\t\tlogrus.Warn(err.Error())\n\t\t}\n\treturn\n}", "func (o WebhookOutput) EncodeAs() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Webhook) pulumi.StringOutput { return v.EncodeAs }).(pulumi.StringOutput)\n}", "func BindToResponse(result reflect.Value, header http.Header, scope string, acceptLanguage string) (output []byte, ge gomerr.Gomerr) {\n\ttc := structs.ToolContextWithScope(scope).Put(headersKey, header).Put(AcceptLanguageKey, acceptLanguage)\n\n\toutBodyBinding := hasOutBodyBinding[result.Type().String()]\n\tif !outBodyBinding {\n\t\ttc.Put(bind2.OutKey, make(map[string]interface{}))\n\t}\n\n\tif ge = structs.ApplyTools(result, tc, DefaultBindToResponseTool); ge != nil {\n\t\treturn nil, ge\n\t}\n\n\tif outBodyBinding {\n\t\treturn tc.Get(bodyBytesKey).([]byte), nil\n\t} else {\n\t\t// based on content type, and the absence of any \"body\" attributes use the proper marshaler to put the\n\t\t// data into the response bytes\n\t\t// TODO:p3 Allow applications to provide alternative means to choose a marshaler\n\t\tcontentType := header.Get(AcceptsHeader) // TODO:p4 support multi-options\n\t\tmarshal, ok := responseConfig.perContentTypeMarshalFunctions[contentType]\n\t\tif !ok {\n\t\t\tif responseConfig.defaultMarshalFunction == nil {\n\t\t\t\treturn nil, gomerr.Marshal(\"Unsupported Accepts content type\", contentType)\n\t\t\t}\n\t\t\tmarshal = responseConfig.defaultMarshalFunction\n\t\t\tcontentType = DefaultContentType\n\t\t}\n\n\t\toutMap := tc.Get(bind2.OutKey).(map[string]interface{})\n\t\tif len(outMap) == 0 && responseConfig.EmptyValueHandlingDefault == OmitEmpty {\n\t\t\treturn nil, ge\n\t\t}\n\n\t\tbytes, err := marshal(outMap)\n\t\tif err != nil {\n\t\t\treturn nil, gomerr.Marshal(\"Unable to marshal data\", outMap).AddAttribute(\"ContentType\", contentType).Wrap(err)\n\t\t}\n\t\theader.Set(ContentTypeHeader, contentType)\n\n\t\treturn bytes, nil\n\t}\n}", "func writeResponse(data []byte, size int64, ctype string, w http.ResponseWriter) {\n\tw.Header().Set(\"Content-Type\", ctype)\n\tw.Header().Set(\"Content-Length\", fmt.Sprintf(\"%d\", size))\n\tw.Header().Set(\"Cache-Control\", \"no-transform,public,max-age=86400,s-maxage=2592000\")\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(data)\n}", "func WriteResponse(w http.ResponseWriter, code int, err error, data interface{}, t0 time.Time) {\n\tw.WriteHeader(code)\n\tresp := &Response{Data: data, Dur: fmt.Sprint(time.Since(t0)), OK: false}\n\tif code < 300 {\n\t\tresp.OK = true\n\t}\n\tif err != nil {\n\t\tresp.Err = err.Error()\n\t}\n\terr = json.NewEncoder(w).Encode(resp)\n\tif err != nil {\n\t\tlog.Infof(\"failed to json encode response: %v\", err)\n\t\tif _, err = w.Write([]byte(spew.Sdump(resp))); err != nil {\n\t\t\tlog.Infof(\"failed to write dump of response: %v\", err)\n\t\t}\n\t}\n}", "func (o *GetBackendOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\t// response header Configuration-Version\n\n\tconfigurationVersion := o.ConfigurationVersion\n\tif configurationVersion != \"\" {\n\t\trw.Header().Set(\"Configuration-Version\", configurationVersion)\n\t}\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func (h BaseHandler) SendMarshalResponse(w http.ResponseWriter, v interface{}) {\n\tb, err := json.Marshal(v)\n\tif err != nil {\n\t\th.SendInternalError(w, err, \"parsing output data failed\")\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tif _, err = w.Write(b); err != nil {\n\t\th.Log.Errorf(\"Error while sending response: %v\", err)\n\t}\n}", "func (r *response) Write(b []byte) (n int, err error) {\n\tif !r.headersSend {\n\t\tif r.status == 0 {\n\t\t\tr.status = http.StatusOK\n\t\t}\n\t\tr.WriteHeader(r.status)\n\t}\n\tn, err = r.ResponseWriter.Write(b)\n\tr.size += int64(n)\n\treturn\n}", "func (o *GetIBAServerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func MarshalToWriter(v Marshaler, w io.Writer) (written int, err error) {\n\tif isNilInterface(v) {\n\t\treturn w.Write(nullBytes)\n\t}\n\n\tjw := jwriter.Writer{}\n\tv.MarshalTinyJSON(&jw)\n\treturn jw.DumpTo(w)\n}", "func (w *Writer) Encode(data interface{}) []byte {\n\tb, _ := w.encode(data)\n\n\treturn b\n}", "func (cbcr *CardBinCheckResponse) WriteResponse(w io.Writer, c ContentType) error {\n\tvar err error\n\tswitch c {\n\tcase JSONContentType:\n\t\t_, err = io.WriteString(w, cbcr.toJSON())\n\tcase TextContentType:\n\t\t_, err = io.WriteString(w, cbcr.toText())\n\tdefault:\n\t\terr = errors.New(\"No supporting content type\")\n\t}\n\treturn err\n}", "func NewHttpResponseEncodeWriter(w http.ResponseWriter, opts ...ResponseWriterOption) func(error) *httpResponseEncoder {\n\treturn func(gRPCErr error) *httpResponseEncoder {\n\t\treturn &httpResponseEncoder{\n\t\t\tgRPCErr: gRPCErr,\n\t\t\tw: w,\n\t\t\topts: opts,\n\t\t}\n\t}\n}", "func (o *GetTournamentOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {\n\n\trw.WriteHeader(200)\n\tif o.Payload != nil {\n\t\tpayload := o.Payload\n\t\tif err := producer.Produce(rw, payload); err != nil {\n\t\t\tpanic(err) // let the recovery middleware deal with this\n\t\t}\n\t}\n}", "func encodeGenericResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\treturn json.NewEncoder(w).Encode(response)\n}", "func encodeAddResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func encodeAddResponse(ctx context.Context, w http1.ResponseWriter, response interface{}) (err error) {\n\tif f, ok := response.(endpoint.Failure); ok && f.Failed() != nil {\n\t\tErrorEncoder(ctx, f.Failed(), w)\n\t\treturn nil\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")\n\terr = json.NewEncoder(w).Encode(response)\n\treturn\n}", "func ServerEncodeResponseBody(timeLayout string, format wrp.Format) gokithttp.EncodeResponseFunc {\n\treturn func(ctx context.Context, httpResponse http.ResponseWriter, value interface{}) error {\n\t\tvar (\n\t\t\twrpResponse = value.(wrpendpoint.Response)\n\t\t\toutput bytes.Buffer\n\t\t)\n\n\t\ttracinghttp.HeadersForSpans(timeLayout, httpResponse.Header(), wrpResponse.Spans()...)\n\n\t\tif err := wrpResponse.Encode(&output, format); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\thttpResponse.Header().Set(\"Content-Type\", format.ContentType())\n\t\t_, err := output.WriteTo(httpResponse)\n\t\treturn err\n\t}\n}", "func writeResponse(w http.ResponseWriter, h int, p interface{}) {\n\t// I set the content type...\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\t// ... I write the specified status code...\n\tw.WriteHeader(h)\n\t// ... and I write the response\n\tb, _ := json.Marshal(p)\n\tw.Write(b)\n}", "func (b *Bytes) WriteTo(w io.Writer) (int64, error) {\n\tn, err := w.Write(b.Bytes())\n\treturn int64(n), err\n}", "func EncodeInto(buf *[]byte, val interface{}, opts Options) error {\n err := encodeInto(buf, val, opts)\n if err != nil {\n return err\n }\n *buf = encodeFinish(*buf, opts)\n return err\n}", "func (e *RegistryV2Error) WriteAsTextTo(w http.ResponseWriter) {\n\tfor k, v := range e.Headers {\n\t\tw.Header()[k] = v\n\t}\n\tif e.Status == 0 {\n\t\tw.WriteHeader(apiErrorStatusCodes[e.Code])\n\t} else {\n\t\tw.WriteHeader(e.Status)\n\t}\n\tw.Write([]byte(e.Error() + \"\\n\"))\n}" ]
[ "0.5900893", "0.5624768", "0.55791545", "0.55571955", "0.5534204", "0.5395386", "0.5389386", "0.53571355", "0.5337786", "0.5306685", "0.53040093", "0.53040093", "0.5280645", "0.5271151", "0.52391887", "0.52389556", "0.52290684", "0.5228518", "0.5228017", "0.5222941", "0.52040625", "0.5184524", "0.5161609", "0.5151505", "0.5143536", "0.51308846", "0.5127131", "0.51243466", "0.5121752", "0.5121217", "0.5117821", "0.51145566", "0.51098806", "0.510693", "0.50986546", "0.50986546", "0.50977683", "0.50927156", "0.50898856", "0.5087563", "0.5087424", "0.5076182", "0.5057497", "0.50531393", "0.50520444", "0.50509095", "0.5049908", "0.5042409", "0.5041549", "0.5035074", "0.50177705", "0.50120425", "0.5004887", "0.4998467", "0.49973452", "0.49827343", "0.49753347", "0.4972825", "0.49615037", "0.4955579", "0.49536756", "0.49515578", "0.49504453", "0.49486277", "0.4945848", "0.49453077", "0.4942654", "0.4939615", "0.49346673", "0.4927198", "0.49263903", "0.49145964", "0.49105346", "0.49080187", "0.48904613", "0.48885065", "0.48879188", "0.48832357", "0.48832023", "0.48801583", "0.48738685", "0.48704308", "0.4868418", "0.48539102", "0.48526874", "0.4850809", "0.48507416", "0.484555", "0.4843058", "0.48420173", "0.48411793", "0.48400533", "0.48385903", "0.48274988", "0.48274988", "0.48262972", "0.4824994", "0.48220414", "0.48142797", "0.48139644" ]
0.7092946
0
NewClient returns a new HTTPClient. scrapeURL may be empty, which will replace the "announce" in announceURL with "scrape" to generate the scrapeURL.
func NewClient(announceURL, scrapeURL string) *Client { if scrapeURL == "" { scrapeURL = strings.Replace(announceURL, "announce", "scrape", -1) } id := metainfo.NewRandomHash() return &Client{AnnounceURL: announceURL, ScrapeURL: scrapeURL, ID: id} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func New(url string) *Client {\n\treturn &Client{&http.Client{}, url, func(r *http.Request) *http.Request { return r }}\n}", "func New(url string) *Client {\n\treturn &Client{url: url, httpC: http.DefaultClient}\n}", "func New() (crawl *Crawl) {\n\tc := &http.Client{\n\t\tTransport: http.DefaultTransport,\n\t}\n\tc.Jar, _ = cookiejar.New(nil)\n\n\tcrawl = &Crawl{\n\t\tClient: c,\n\t\tmutex: new(sync.RWMutex),\n\t\thandlers: make(map[interface{}]Handler),\n\t\tcloseCh: make(chan bool, 1),\n\t\tdoneCh: make(chan bool, 1),\n\t}\n\tcrawl.SetOptions(DefaultOptions)\n\treturn\n}", "func New() *Scraper {\n\treturn &Scraper{\n\t\tclient: &http.Client{Timeout: 10 * time.Second},\n\t}\n}", "func New(url string) *Client {\n\treturn &Client{\n\t\tclient: http2.NewClient(nil),\n\t\turl: url,\n\t}\n}", "func NewClient(url string) *Client {\n\n\thttpClient := http.DefaultClient\n\tbaseURL := fmt.Sprintf(\"%s%s/\", url, APIVersion)\n\treturn &Client{\n\t\tsling: sling.New().Client(httpClient).Base(baseURL),\n\t}\n}", "func NewClient() *Client {\n baseURL, _ := url.Parse(defaultBaseURL)\n return &Client{client: http.DefaultClient, BaseURL: baseURL, UserAgent: userAgent}\n}", "func NewClient(url string) *Client {\n\treturn &Client{URL: url, Default: true}\n}", "func NewClient(baseurl string) (cl *Client, err error) {\n\tcl = new(Client)\n\t_, err = url.Parse(baseurl)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcl.BaseURL = baseurl\n\treturn cl, nil\n}", "func New(url string) Client {\n\treturn &client{\n\t\tbaseURL: url,\n\t}\n}", "func NewClient(u string) *Client {\n\treturn &Client{URL: u}\n}", "func New(url string) *Client {\n\treturn NewWithHTTP(url, http.DefaultClient)\n}", "func NewClient(url string) *Client {\n\treturn &Client{&http.Client{}, url}\n}", "func NewClient(url string) *Client {\n\treturn &Client{\n\t\thttpClient: &http.Client{Timeout: time.Minute},\n\t\turl: url,\n\t\tminVersion: minVersion,\n\t}\n}", "func NewClient(url, token string) *Client {\n\treturn &Client{\n\t\turl: strings.TrimSuffix(url, \"/\"),\n\t\tclient: &http.Client{},\n\t\ttoken: token,\n\t}\n}", "func NewClient(baseurl string) *Client {\n\treturn &Client{\n\t\tbaseurl: baseurl,\n\t\tclient: &http.Client{Timeout: 20 * time.Second},\n\t}\n}", "func NewClient(apiKey string, options ...OptionFunc) *Client {\n\tbaseURL, _ := url.Parse(defaultBaseURL)\n\tc := &Client{\n\t\tclient: &http.Client{\n\t\t\tTimeout: time.Second * 10,\n\t\t},\n\t\tbaseURL: baseURL,\n\t\tapiKey: apiKey,\n\t\tuserAgent: \"github.com/barthr/newsapi\",\n\t}\n\n\tfor _, opt := range options {\n\t\topt(c)\n\t}\n\treturn c\n}", "func New(url string, httpClient *http.Client, customHeaders http.Header) *Client {\n\tif httpClient == nil {\n\t\thttpClient = &http.Client{\n\t\t\tTimeout: defaultHTTPTimeout,\n\t\t}\n\t}\n\n\treturn &Client{\n\t\turl: url,\n\t\thttpClient: httpClient,\n\t\tcustomHeaders: customHeaders,\n\t}\n}", "func NewClient(httpClient *http.Client) *Client {\n\tu, _ := url.Parse(BaseURL)\n\treturn &Client{\n\t\tBaseURL: u,\n\t\tHTTPClient: httpClient,\n\t}\n}", "func NewClient(url string) *Client {\n\treturn &Client{url: url}\n}", "func NewClient() (*Client, error) {\n\tvar seedTickers = []string{\"AAPL\", \"GOOG\", \"MSFT\"}\n\tjar, err := cookiejar.New(nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\thttpClient := &http.Client{Jar: jar}\n\tc := Client{httpClient: httpClient}\n\n\ti := rand.Intn(len(seedTickers))\n\tticker := seedTickers[i]\n\tcrumb, err := getCrumb(c.httpClient, ticker)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc.crumb = crumb\n\n\treturn &c, nil\n\n}", "func New() *Scraper {\n\tseedURL, _ := env.GetCrawlerVars(env.SeedURL)\n\treturn &Scraper{\n\t\tlock: &sync.RWMutex{},\n\t\tvisitsCount: 0,\n\t\tseedURL: seedURL.(string),\n\t\trequests: make(scrapingRequests, 0),\n\t\tacquiredProducts: make(item.Items, 0),\n\t}\n}", "func NewClient(url string) *Client {\n\treturn &Client{\n\t\tURL: url,\n\t\tclient: http.DefaultClient,\n\t}\n}", "func NewClient(baseURL string) (*Client, error) {\n\tu, err := url.Parse(baseURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tu.Path = path.Join(u.Path, \"/\"+version)\n\n\treturn &Client{\n\t\turl: u,\n\t\thttp: &http.Client{\n\t\t\tTimeout: 5 * time.Second,\n\t\t},\n\t}, nil\n}", "func NewClient(url string) *Client {\n\ttr := http.DefaultTransport\n\thttp := &http.Client{Transport: tr}\n\tclient := &Client{http: http, url: url}\n\treturn client\n}", "func NewScrape(cfg *domain.Config) *Scrape {\n\treturn &Scrape{\n\t\tcfg: cfg,\n\t}\n}", "func NewClient(with ...ClientOption) *Client {\n\ttimeout := DefaultTimeout\n\n\tclient := &Client{\n\t\tclient: &http.Client{\n\t\t\tTimeout: timeout,\n\t\t},\n\t\tbase: getBaseURL(url.URL{\n\t\t\tScheme: \"https\",\n\t\t\tHost: \"api.secrethub.io\",\n\t\t}),\n\t\tuserAgent: DefaultUserAgent,\n\t}\n\tclient.Options(with...)\n\treturn client\n}", "func NewClient(URL, token string) *Client {\n\tc := &Client{\n\t\tToken: token,\n\t\tclient: http.DefaultClient,\n\t}\n\n\tif !strings.HasSuffix(URL, \"/\") {\n\t\tURL += \"/\"\n\t}\n\n\tvar err error\n\tc.URL, err = url.Parse(URL)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn c\n}", "func NewClient(url string, token oauth2.Token, insecure bool) Client {\n\tclient := &http.Client{}\n\n\tif insecure {\n\t\tclient.Transport = &http.Transport{\n\t\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\n\t\t}\n\t}\n\n\treturn Client{url, token, client}\n}", "func NewClient(u string) (*Client, error) {\n\tif len(u) == 0 {\n\t\treturn nil, fmt.Errorf(\"client: missing url\")\n\t}\n\n\tparsedURL, err := url.Parse(u)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc := &Client{\n\t\tURL: parsedURL,\n\t\tDefaultHeader: make(http.Header),\n\t}\n\n\tif err := c.init(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func NewClient(httpClient *http.Client, URL string, Token string, Source string, SourceType string, Index string) (*Client) {\n\t// Create a new client\n\tif httpClient == nil {\n\t\ttr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} // turn off certificate checking\n\t\thttpClient = &http.Client{Timeout: time.Second * 20, Transport: tr}\n\t}\n\n\tc := &Client{HTTPClient: httpClient, URL: URL, Token: Token, Source: Source, SourceType: SourceType, Index: Index}\n\n\treturn c\n}", "func New(endpoint *url.URL, client *http.Client) *Client {\n\tif client == nil {\n\t\tclient = httpClient\n\t}\n\n\tif len(endpoint.Path) > 0 && !strings.HasSuffix(endpoint.Path, \"/\") {\n\t\tendpoint.Path = endpoint.Path + \"/\"\n\t}\n\n\treturn &Client{client, endpoint, make(http.Header), endpoint.Query()}\n}", "func NewClient(url, token string) *Client {\n\treturn &Client{\n\t\turl: strings.TrimSuffix(url, \"/\"),\n\t\taccessToken: token,\n\t\tclient: &http.Client{},\n\t}\n}", "func NewFromURL(base *url.URL) *Client {\n\n\tif baseStr := base.String(); len(baseStr) > 0 {\n\n\t\tLogger.Debug(\"Creating Marathon Client from url.URL = %s\", base.String())\n\t\tbaseURL, err := url.Parse(baseStr)\n\t\tif err != nil {\n\t\t\tLogger.Debug(\"Invalid baseURL\")\n\t\t\treturn nil\n\t\t}\n\n\t\t_client := &Client{}\n\t\treturn _client.New(baseURL)\n\t}\n\treturn nil\n}", "func NewClient(owner string, url string) *Client {\n\n\tclient := &Client{\n\t\turl: url,\n\t\towner: owner,\n\t}\n\n\treturn client\n}", "func NewClient(address string) *Client {\n\t// bootstrap the config\n\tc := &Client{\n\t\tAddress: address,\n\t\tScheme: \"http\",\n\t}\n\n\t// Make sure IPAM connection is alive, with retries\n\tfor i := 0; i < 5; i++ {\n\t\t_, err := c.IndexPools()\n\t\tif err == nil {\n\t\t\treturn c\n\t\t}\n\t\tlog.Println(\"Could not connect to IPAM, retrying in 5 Seconds...\")\n\t\ttime.Sleep(5 * time.Second)\n\t}\n\n\treturn nil\n}", "func NewClient(casterURL string) (client *Client, err error) {\n\tu, err := url.Parse(casterURL)\n\tclient = &Client{\n\t\tRequest: &http.Request{\n\t\t\tURL: u,\n\t\t\tMethod: \"GET\",\n\t\t\tProtoMajor: 1,\n\t\t\tProtoMinor: 1,\n\t\t\tHeader: make(map[string][]string),\n\t\t},\n\t}\n\tclient.Header.Set(\"User-Agent\", \"NTRIP GoClient\")\n\tclient.Header.Set(\"Ntrip-Version\", \"Ntrip/2.0\")\n\treturn client, err\n}", "func NewClient(httpClient *http.Client, baseURL string) (*Client, error) {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tbase, err := url.Parse(baseURL)\n\tif err != nil {\n\t\treturn nil, errors.New(\"Could not parse base URL\")\n\t}\n\n\tc := &Client{client: httpClient, baseURL: base}\n\treturn c, nil\n}", "func NewScraper(opts ...Option) *Scraper {\n\tm := &Scraper{\n\t\turl: \"\",\n\t\texpectedStatusCode: http.StatusOK,\n\t\ttargetPrice: DefaultTargetPrice,\n\t\tselector: DefaultSelector,\n\t\tfindText: DefaultFindText,\n\t\tmaxRetries: DefaultMaxRetries,\n\t\tretrySeconds: DefaultRetrySeconds,\n\t\tLogger: &utils.DefaultLogger{},\n\t\tclient: new(http.Client),\n\t}\n\tfor _, opt := range opts {\n\t\topt(m)\n\t}\n\treturn m\n}", "func New(logger *log.Logger, cfg Config) (*Scraper, error) {\n\tvar errs []error\n\n\tu, err := url.Parse(cfg.URL)\n\tif err != nil {\n\t\terrs = append(errs, err)\n\t}\n\n\tincludes, err := compileRegexps(cfg.Includes)\n\tif err != nil {\n\t\terrs = append(errs, err)\n\t}\n\n\texcludes, err := compileRegexps(cfg.Excludes)\n\tif err != nil {\n\t\terrs = append(errs, err)\n\t}\n\n\tproxyURL, err := url.Parse(cfg.Proxy)\n\tif err != nil {\n\t\terrs = append(errs, err)\n\t}\n\n\tif errs != nil {\n\t\treturn nil, errors.Join(errs...)\n\t}\n\n\tif u.Scheme == \"\" {\n\t\tu.Scheme = \"http\" // if no URL scheme was given default to http\n\t}\n\n\tif cfg.UserAgent == \"\" {\n\t\tcfg.UserAgent = agent.GoogleBot()\n\t}\n\n\tb := surf.NewBrowser()\n\tb.SetUserAgent(cfg.UserAgent)\n\tb.SetTimeout(time.Duration(cfg.Timeout) * time.Second)\n\n\tif cfg.Proxy != \"\" {\n\t\tdialer, err := proxy.FromURL(proxyURL, proxy.Direct)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tb.SetTransport(&http.Transport{\n\t\t\tDial: dialer.Dial,\n\t\t})\n\t}\n\n\ts := &Scraper{\n\t\tconfig: cfg,\n\n\t\tbrowser: b,\n\t\tlogger: logger,\n\t\tprocessed: make(map[string]struct{}),\n\t\tURL: u,\n\t\tcssURLRe: regexp.MustCompile(`^url\\(['\"]?(.*?)['\"]?\\)$`),\n\t\tincludes: includes,\n\t\texcludes: excludes,\n\t}\n\treturn s, nil\n}", "func New(httpClient *http.Client, config Config) (*Client, error) {\n\tc := NewClient(httpClient)\n\tc.Config = config\n\n\tbaseURL, err := url.Parse(\"https://\" + config.Host)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc.BaseURL = baseURL\n\treturn c, nil\n}", "func NewClient(address string, httpService httpservice.HTTPService) (*Client, error) {\n\tvar httpClient *http.Client\n\taddressURL, err := url.Parse(address)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to parse marketplace address\")\n\t}\n\tif addressURL.Hostname() == \"localhost\" || addressURL.Hostname() == \"127.0.0.1\" {\n\t\thttpClient = httpService.MakeClient(true)\n\t} else {\n\t\thttpClient = httpService.MakeClient(false)\n\t}\n\n\treturn &Client{\n\t\taddress: address,\n\t\thttpClient: httpClient,\n\t}, nil\n}", "func newClientWithURL(url string, apiKey string, apiSecret string) (Client, error) {\n\treturn newClientWithURLs(apiKey, apiSecret, url, url, url, url)\n}", "func New(base string) *Client {\n\n\tLogger.Debug(\"Creating Marathon Client with baseURL = %s\", base)\n\tbaseURL, err := url.Parse(base)\n\tif len(base) == 0 || err != nil {\n\t\tLogger.Debug(\"Invalid baseURL\")\n\t\treturn nil\n\t}\n\n\t_client := &Client{}\n\treturn _client.New(baseURL)\n}", "func NewClient() (c *Client) {\n\tvar (\n\t\tcookie *cookiejar.Jar\n\t)\n\n\tcookie, _ = cookiejar.New(nil)\n\n\tc = &Client{\n\t\tClient: &http.Client{\n\t\t\tJar: cookie,\n\t\t},\n\t\tUserAgent: \"Sbss-Client\",\n\t}\n\n\treturn\n}", "func NewClient(apiKey string) *Client {\n\tu, _ := url.ParseRequestURI(DefaultBaseURL)\n\treturn &Client{\n\t\tclient: &http.Client{},\n\t\tapiKey: apiKey,\n\t\tbaseURL: u,\n\t}\n}", "func NewClient(profURL *url.URL) Client {\n\tc := &client{\n\t\tc: &http.Client{},\n\t\tprofURL: profURL,\n\t}\n\n\treturn c\n}", "func (mc *Client) New(base *url.URL) *Client {\n\n\tmarathon := mc\n\tmarathon.Session = requist.New(base.String())\n\n\tif marathon.Session != nil {\n\t\trequist.Logger = Logger\n\t\tmarathon.baseURL = base.String()\n\t\tmarathon.info = &data.Info{}\n\t\tmarathon.fail = &data.FailureMessage{}\n\n\t\tif base.User.String() != \"\" {\n\t\t\tif pass, check := base.User.Password(); check {\n\t\t\t\tmarathon.Session.SetBasicAuth(base.User.Username(), pass)\n\t\t\t}\n\t\t\tmarathon.auth = marathon.Session.GetBasicAuth()\n\t\t}\n\t\tmarathon.SetTimeout(DeploymentTimeout)\n\t\tmarathon.Session.Accept(\"application/json\")\n\t\tmarathon.Session.SetHeader(\"Cache-Control\", \"no-cache\")\n\t\tmarathon.Session.SetHeader(\"Accept-Encoding\", \"identity\")\n\n\t\tLogger.Debug(\"Marathon Client = %+v\", marathon)\n\t\treturn marathon\n\t}\n\treturn nil\n}", "func NewClient(c Configuration) (Client, error) {\n\tcli := Client{\n\t\tName: \"splunk-http-collector-client\",\n\t}\n\tif err := cli.Configure(c.Collector.Proto, c.Collector.Host, c.Collector.Port); err != nil {\n\t\treturn cli, err\n\t}\n\tlog.Debugf(\"%s: proto=%s\", cli.Name, c.Collector.Proto)\n\tlog.Debugf(\"%s: host=%s\", cli.Name, c.Collector.Host)\n\tlog.Debugf(\"%s: port=%d\", cli.Name, c.Collector.Port)\n\tlog.Debugf(\"%s: token=%s\", cli.Name, c.Collector.Token)\n\tlog.Debugf(\"%s: timeout=%d\", cli.Name, c.Collector.Timeout)\n\tlog.Debugf(\"%s: endpoint.health=%s\", cli.Name, cli.Endpoints.Health)\n\tlog.Debugf(\"%s: endpoint.event=%s\", cli.Name, cli.Endpoints.Event)\n\tlog.Debugf(\"%s: endpoint.raw=%s\", cli.Name, cli.Endpoints.Raw)\n\tt := &http.Transport{\n\t\tTLSClientConfig: &tls.Config{\n\t\t\tInsecureSkipVerify: true,\n\t\t},\n\t}\n\tcli.client = &http.Client{\n\t\tTimeout: time.Duration(c.Collector.Timeout) * time.Second,\n\t\tTransport: t,\n\t}\n\tcli.Token = c.Collector.Token\n\tif err := cli.HealthCheck(); err != nil {\n\t\treturn cli, err\n\t}\n\treturn cli, nil\n}", "func NewClient(apiKey string) *Client {\n\treturn &Client{\n\t\tC: http.Client{\n\t\t\tTimeout: 5 * time.Second,\n\t\t},\n\t\tService: \"https://saucenao.com\",\n\t\tAPIKey: apiKey,\n\t}\n}", "func New(url string, client *http.Client) *Rietveld {\n\turl = strings.TrimRight(url, \"/\")\n\tif client == nil {\n\t\tclient = http.DefaultClient\n\t}\n\treturn &Rietveld{\n\t\turl: url,\n\t\tclient: client,\n\t}\n}", "func NewClient(cacher Cacher) *Client {\n\tvar newClient Client\n\n\tnewClient.BaseURL = DefaultBaseURL\n\tnewClient.Retries = 5\n\tnewClient.cacher = cacher\n\tnewClient.maxIdleConns = 2\n\n\t// Also sets up our initial http client\n\tnewClient.SetTimeout(60 * time.Second)\n\n\tif client == nil {\n\t\tclient = &newClient\n\t}\n\treturn &newClient\n}", "func NewClient(connectionstring, pooluser string) (sc GenericClient) {\n\tif strings.HasPrefix(connectionstring, \"stratum+tcp://\") {\n\t\tsc = &StratumClient{\n\t\t\tconnectionstring: strings.TrimPrefix(connectionstring, \"stratum+tcp://\"),\n\t\t\tUser: pooluser,\n\t\t}\n\t} else {\n\t\ts := SiadClient{}\n\t\ts.siadurl = \"http://\" + connectionstring + \"/miner/header\"\n\t\tsc = &s\n\t}\n\treturn\n}", "func NewClient(baseURL string, defaultHeaders map[string]string) *Client {\n\turl, _ := url.Parse(baseURL)\n\tif defaultHeaders == nil {\n\t\tdefaultHeaders = make(map[string]string)\n\t}\n\treturn &Client{httpClient: &http.Client{}, baseURL: url, defaultHeaders: defaultHeaders}\n}", "func New() (Scraper, error) {\n\treturn &scraper{}, nil\n}", "func NewClient(httpClient *http.Client) *Client {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tbaseURL, _ := url.Parse(defaultBaseURL)\n\n\tc := &Client{\n\t\tclient: httpClient,\n\t\tBaseURL: baseURL,\n\t}\n\n\tc.Draws = &drawsService{\n\t\tclient: c,\n\t\tEndpoint: defaultDrawsEndpoint,\n\t}\n\treturn c\n}", "func NewClient(baseURL string, httpClient *http.Client) (*Client, error) {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tbaseEndpoint, err := url.Parse(baseURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !strings.HasSuffix(baseEndpoint.Path, \"/\") {\n\t\tbaseEndpoint.Path += \"/\"\n\t}\n\n\tc := &Client{\n\t\tclient: httpClient,\n\t\tBaseURL: baseEndpoint,\n\t}\n\tc.common.client = c\n\tc.Boards = (*BoardsService)(&c.common)\n\tc.Epics = (*EpicsService)(&c.common)\n\tc.Issues = (*IssuesService)(&c.common)\n\tc.Sprints = (*SprintsService)(&c.common)\n\tc.Backlog = (*BacklogService)(&c.common)\n\n\treturn c, nil\n}", "func NewClient(c *http.Client, baseURL *url.URL) *client {\n\treturn &client{\n\t\tbaseURL: baseURL,\n\t\tclient: c,\n\t}\n}", "func New(startURL string, host string) *Crawler {\n\treturn &Crawler{\n\t\tRequester: request.HTTPRequest{},\n\t\tStartURL: startURL,\n\t\tLinks: make(PageLinks),\n\t\thost: host,\n\t\tmaxGoRoutines: 20,\n\t}\n}", "func NewClient(config *ClientConfig) *Client {\n\tvar client *Client\n\n\thttpClient := &fasthttp.Client{\n\t\tName: \"Gocursive\",\n\t\tMaxConnsPerHost: 10240,\n\t}\n\n\tif !strings.HasSuffix(config.url.Path, \"/\") {\n\t\tconfig.url.Path += \"/\"\n\t}\n\n\tconfig.outputDir, _ = filepath.Abs(config.outputDir)\n\n\tclient = &Client{\n\t\tconfig: config,\n\t\thttpClient: httpClient,\n\t\tdirectories: []string{},\n\t\tfiles: []*url.URL{},\n\t\tbytesTotal: 0,\n\t\tbytesRecv: 0,\n\t}\n\n\treturn client\n}", "func NewClient(url, apiKey string) *Client {\n\treturn &Client{\n\t\turl: url,\n\t\tapiKey: apiKey,\n\t}\n}", "func NewClient(addr string, insecure bool) *Client {\n\ttransport := &http.Transport{}\n\tif insecure {\n\t\ttransport = &http.Transport{\n\t\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\n\t\t}\n\t}\n\n\thttpClient := &http.Client{Transport: transport}\n\n\treturn &Client{\n\t\taddr: addr,\n\t\thttpClient: httpClient,\n\t}\n}", "func New(baseURL *url.URL) *Client {\n\treturn &Client{\n\t\tu: baseURL,\n\t}\n}", "func (c *baseClient) New() *baseClient {\n\t// Copy headers\n\theader := make(http.Header)\n\tfor k, v := range c.header {\n\t\theader[k] = v\n\t}\n\n\treturn &baseClient{\n\t\thttpClient: c.httpClient,\n\t\tmethod: c.method,\n\t\turl: c.url,\n\t\theader: header,\n\t}\n}", "func NewClient(accessToken string, version string, httpClient *http.Client) *Client {\n\ttype Params struct {\n\t\tAccessToken string `url:\"access_token,omitempty\"`\n\t\tLocale string `url:\"locale,omitempty\"`\n\t}\n\n\tparams := &Params{AccessToken: accessToken, Locale: \"*\"}\n\n\tclient := &Client{\n\t\tAccessToken: accessToken,\n\t\tsling: sling.New().Client(httpClient).Base(baseURL).\n\t\t\tSet(\"Content-Type\", contentTypeHeader(version)).\n\t\t\tQueryStruct(params),\n\t}\n\n\tclient.rl = rate.New(10, time.Second*1)\n\n\treturn client\n}", "func NewClient(addr *url.URL) (Client, error) {\n\tif addr == nil || addr.Host == \"\" {\n\t\tlogging.Info(\"Using nop metricd client.\")\n\t\treturn newNopClient(), nil\n\t}\n\tlogging.Infof(\"Using metricd at: %s\", addr.Host)\n\treturn newRealClient(addr, nil)\n}", "func New(h, o string, s *State) (*Crawler, error) {\n\tm, err := url.Parse(h)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif m.Host == \"\" {\n\t\treturn nil, errors.New(\"empty main host\")\n\t}\n\treturn &Crawler{\n\t\tendpoint: h,\n\t\tmainURL: m,\n\t\toutput: o,\n\t\tuploadPageCh: make(chan string, 1024),\n\t\tuploadAssetCh: make(chan string, 1024),\n\t\tsaveCh: make(chan File, 128),\n\t\tUploadWorkers: DefaultWorkersCount,\n\t\tSaveWorkers: DefaultWorkersCount,\n\t\tIncludeSubDomains: false,\n\t\tEnableGzip: true,\n\t\tstate: s,\n\t\thttpClient: &http.Client{\n\t\t\tTransport: &http.Transport{\n\t\t\t\tDial: (&net.Dialer{\n\t\t\t\t\tTimeout: 15 * time.Second,\n\t\t\t\t\tKeepAlive: 180 * time.Second,\n\t\t\t\t}).Dial,\n\t\t\t\tTLSHandshakeTimeout: 10 * time.Second,\n\t\t\t\tResponseHeaderTimeout: 10 * time.Second,\n\t\t\t\tExpectContinueTimeout: 1 * time.Second,\n\t\t\t},\n\t\t},\n\t}, nil\n}", "func NewClient(endpoint string, cli *http.Client) (*Client, error) {\n\tu, err := url.ParseRequestURI(endpoint)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"gaurun: failed to parse url - endpoint = %s: %w\", endpoint, err)\n\t}\n\n\tif cli == nil {\n\t\tcli = http.DefaultClient\n\t}\n\n\treturn &Client{\n\t\tEndpoint: u,\n\t\tHTTPClient: cli,\n\t}, nil\n}", "func NewClient(host, version, userAgent string) (*Client, error) {\n\tbaseURL, err := url.Parse(host)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif baseURL.Path == \"\" {\n\t\tbaseURL.Path = \"/\"\n\t}\n\tunix2HTTP(baseURL)\n\thClient := getHTTPClient(host)\n\tif hClient == nil {\n\t\treturn nil, fmt.Errorf(\"Unable to parse provided url: %v\", host)\n\t}\n\tc := &Client{\n\t\tbase: baseURL,\n\t\tversion: version,\n\t\thttpClient: hClient,\n\t\tauthstring: \"\",\n\t\taccesstoken: \"\",\n\t\tuserAgent: fmt.Sprintf(\"%v/%v\", userAgent, version),\n\t}\n\treturn c, nil\n}", "func New(credhubURL string, hc HTTPClient) (*Client, error) {\n\tc := &Client{\n\t\turl: credhubURL,\n\t\thc: hc,\n\t}\n\n\tc.Log = log.New(os.Stderr, log.Prefix(), log.Flags())\n\n\terr := c.setVersion()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c, nil\n}", "func NewClient(accessToken string, version string, httpClient *http.Client) *Client {\n\tclient := &Client{\n\t\tAccessToken: accessToken,\n\t\tsling: sling.New().Client(httpClient).Base(baseURL).\n\t\t\tSet(\"Content-Type\", contentTypeHeader(version)).\n\t\t\tSet(\"Authorization\", authorizationHeader(accessToken)),\n\t}\n\n\tclient.rl = rate.New(10, time.Second*1)\n\n\treturn client\n}", "func NewClient(key, url string) *Client {\n\treturn &Client{\n\t\turl: url,\n\t\theader: req.Header{\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\"Accept\": \"application/json\",\n\t\t\t\"X-Api-Key\": key,\n\t\t},\n\t}\n}", "func New(p policy) (*retryablehttp.Client, error) {\n\tlogger := p.CreateLogger()\n\n\tinnerHTTPClient, err := createInnerHTTPClient(logger)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\thttpClient := retryablehttp.NewClient()\n\tp.ConfigureHTTP(httpClient)\n\n\thttpClient.Logger = loggerAdapter{logger}\n\thttpClient.HTTPClient = innerHTTPClient\n\n\treturn httpClient, nil\n}", "func newClient(apiKey string) *Client {\n\tvar url *url.URL\n\turl, _ = url.Parse(\"https://vulners.com/api/v3\")\n\treturn &Client{baseURL: url, apiKey: apiKey}\n}", "func New(client *http.Client, req *http.Request, check RespCheck, urls []*url.URL) *FastestURL {\n\tif client == nil {\n\t\tclient = http.DefaultClient\n\t}\n\tif req == nil {\n\t\treq = &http.Request{}\n\t}\n\tif check == nil {\n\t\tcheck = func(resp *http.Response) bool {\n\t\t\treturn resp.StatusCode == http.StatusOK\n\t\t}\n\t}\n\treturn &FastestURL{\n\t\tClient: client,\n\t\tURLs: urls,\n\t\tRequest: req,\n\t\tRespCheck: check,\n\t}\n}", "func New(context *contexter.Context) (*Client) {\n return &Client {\n urlBaseIndex: 0,\n\t\tcontext: context,\n }\n}", "func NewHTTPScraper() *HTTPScraper {\n\treturn &HTTPScraper{client: &http.Client{}}\n}", "func NewClient(httpClient *http.Client) *Client {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\tbaseURL, _ := url.Parse(defaultBaseURL)\n\tc := Client{\n\t\tBaseURL: baseURL,\n\t\tclient: httpClient,\n\t\tUserAgent: userAgent,\n\t}\n\treturn &c\n}", "func (_ *_Crawler) New(_ *cli.Context, client http.Client, logger glog.Log) (crawler.Crawler, error) {\n\tc := _Crawler{\n\t\thttpClient: client,\n\t\t// this regular used to match category page url path\n\t\tcategoryPathMatcher: regexp.MustCompile(`^/en-us/shop(.*)`),\n\t\t// this regular used to match product page url path\n\t\tproductPathMatcher: regexp.MustCompile(`^(/en-us/p(.*)(&lvrid=_p)(.*)) | (/en-us/p(.*))$`),\n\t\tlogger: logger.New(\"_Crawler\"),\n\t}\n\treturn &c, nil\n}", "func NewClient(httpClient *http.Client, username string, password string) *Client {\n\tbase := sling.New().Client(httpClient).Base(msfUrl)\n\tbase.SetBasicAuth(username, password)\n\treturn &Client{\n\t\tsling: base,\n\t\tNBA: newNBAService(base.New()),\n\t}\n}", "func New(addr string) (*Client, error) {\n\treturn &Client{\n\t\taddr: addr,\n\t\thttpClient: &http.Client{},\n\t}, nil\n}", "func New(addr string) (*Client, error) {\n\treturn &Client{\n\t\taddr: addr,\n\t\thttpClient: &http.Client{},\n\t}, nil\n}", "func NewClient(url, token string) (*Client, chan error, error) {\n\tsocket, err := dialar.Dial(url, http.Header{})\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tc := &Client{\n\t\tDone: make(chan struct{}),\n\t\ttoken: token,\n\t\tsocket: socket,\n\t\ttasks: make(chan client.Task, buffSize),\n\t\tprogress: make(chan []byte, buffSize),\n\t\tresult: make(chan []byte, buffSize),\n\t\tfinish: make(chan client.JudgeResult, buffSize),\n\t\trequest: make(chan struct{}, 1),\n\t\tack: make(chan ack, 1),\n\t\tencoder: parser.NewEncoder(socket),\n\t\tdecoder: parser.NewDecoder(socket),\n\t\terrCh: make(chan error),\n\t}\n\n\tgo c.readLoop()\n\tgo c.writeLoop()\n\n\treturn c, c.errCh, nil\n}", "func (_ *_Crawler) New(_ *cli.Context, client http.Client, logger glog.Log) (crawler.Crawler, error) {\n\tc := _Crawler{\n\t\thttpClient: client,\n\t\t// this regular used to match category page url path\n\t\tcategoryPathMatcher: regexp.MustCompile(`^/collections(/[a-zA-Z0-9_-]+){1,6}$`),\n\t\t// this regular used to match product page url path\n\t\tproductPathMatcher: regexp.MustCompile(`^(/[/a-zA-Z0-9_-]+)?/products(/[a-zA-Z0-9_-]+){1,3}$`),\n\t\tlogger: logger.New(\"_Crawler\"),\n\t}\n\treturn &c, nil\n}", "func New(u url.URL, ignoreRobotsTxt bool, maxWorkers int, userAgent string) *Crawler {\n\tu.Path = \"/\"\n\treturn &Crawler{\n\t\turl: u,\n\t\tignoreRobotsTxt: ignoreRobotsTxt,\n\t\tqueued: sync.Map{},\n\t\tpool: worker.NewPool(maxWorkers),\n\t\tpagesWithErr: make(map[string]bool),\n\t\tSiteMap: make(map[string]*Page),\n\t\tuserAgent: userAgent,\n\t}\n}", "func New(addr string) *Client {\n\treturn &Client{\n\t\taddr: addr,\n\t\tHTTPClient: &http.Client{\n\t\t\tTimeout: 1 * time.Minute,\n\t\t},\n\t}\n}", "func NewClient(cfg *Config) (*Client, error) {\r\n\tBaseURL := new(url.URL)\r\n\tvar err error\r\n\r\n\tviper.SetEnvPrefix(\"TS\")\r\n\tviper.BindEnv(\"LOG\")\r\n\r\n\tswitch l := viper.Get(\"LOG\"); l {\r\n\tcase \"trace\":\r\n\t\tlog.SetLevel(log.TraceLevel)\r\n\tcase \"debug\":\r\n\t\tlog.SetLevel(log.DebugLevel)\r\n\tcase \"info\":\r\n\t\tlog.SetLevel(log.InfoLevel)\r\n\tcase \"warn\":\r\n\t\tlog.SetLevel(log.WarnLevel)\r\n\tcase \"fatal\":\r\n\t\tlog.SetLevel(log.FatalLevel)\r\n\tcase \"panic\":\r\n\t\tlog.SetLevel(log.PanicLevel)\r\n\t}\r\n\r\n\tif cfg.BaseURL != \"\" {\r\n\t\tBaseURL, err = url.Parse(cfg.BaseURL)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t} else {\r\n\t\tBaseURL, err = url.Parse(defaultBaseURL)\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t}\r\n\r\n\tnewClient := &Client{\r\n\t\tBaseURL: BaseURL,\r\n\t\tclient: http.DefaultClient,\r\n\t\tcreds: &Credentials{\r\n\t\t\tAPIKey: cfg.APIKey,\r\n\t\t\tOrganizationID: cfg.OrganizationID,\r\n\t\t\tUserID: cfg.UserID,\r\n\t\t},\r\n\t}\r\n\r\n\tnewClient.Rulesets = &RulesetService{newClient}\r\n\tnewClient.Rules = &RuleService{newClient}\r\n\r\n\treturn newClient, nil\r\n}", "func New(opts ...Option) *Client {\n\tbaseURL, _ := url.Parse(defaultBaseURL)\n\tc := &Client{\n\t\tHTTPClient: &http.Client{Timeout: time.Second * 5},\n\t\tBaseURL: *baseURL,\n\t\tUserAgent: userAgent,\n\t}\n\tfor _, opt := range opts {\n\t\topt(c)\n\t}\n\treturn c\n}", "func NewClient(httpClient *http.Client) (*Client, error) {\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\n\tc := &Client{}\n\n\tbaseURL, _ := url.Parse(DefaultBaseURL)\n\tvsspsBaseURL, _ := url.Parse(DefaultVsspsBaseURL)\n\tvsaexBaseURL, _ := url.Parse(DefaultVsaexBaseURL)\n\n\tc.client = httpClient\n\tc.BaseURL = *baseURL\n\tc.VsspsBaseURL = *vsspsBaseURL\n\tc.VsaexBaseURL = *vsaexBaseURL\n\tc.UserAgent = userAgent\n\n\tc.Boards = &BoardsService{client: c}\n\tc.BuildDefinitions = &BuildDefinitionsService{client: c}\n\tc.Builds = &BuildsService{client: c}\n\tc.DeliveryPlans = &DeliveryPlansService{client: c}\n\tc.Favourites = &FavouritesService{client: c}\n\tc.Git = &GitService{client: c}\n\tc.Iterations = &IterationsService{client: c}\n\tc.PolicyEvaluations = &PolicyEvaluationsService{client: c}\n\tc.PullRequests = &PullRequestsService{client: c}\n\tc.Teams = &TeamsService{client: c}\n\tc.Tests = &TestsService{client: c}\n\tc.Users = &UsersService{client: c}\n\tc.UserEntitlements = &UserEntitlementsService{client: c}\n\tc.WorkItems = &WorkItemsService{client: c}\n\n\treturn c, nil\n}", "func NewClient() *Client {\n\tbaseURL, _ := url.Parse(defaultBaseURL)\n\n\tc := &Client{client: http.DefaultClient, BaseURL: baseURL, UserAgent: userAgent}\n\tc.Schedule = &ScheduleServiceOp{client: c}\n\tc.Time = &TimeServiceOp{client: c}\n\n\treturn c\n}", "func NewClient(baseURL string) (*Client, error) {\n\turl, err := url.Parse(baseURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc := &Client{\n\t\tclient: &http.Client{\n\t\t\tTimeout: time.Second * 30, // Max of 30 secs\n\t\t},\n\t\tBaseURL: url,\n\t\tUserAgent: userAgent,\n\t}\n\n\tc.Games = &GameService{client: c}\n\tc.Teams = &TeamService{client: c}\n\tc.Players = &PlayerService{client: c}\n\tc.Stats = &StatService{client: c}\n\n\treturn c, nil\n}", "func NewClient(config *Config) (*Client, error) {\n\n\tconfig = DefaultConfig().Merge(config)\n\n\tif !strings.HasPrefix(config.Address, \"http\") {\n\t\tconfig.Address = \"http://\" + config.Address\n\t}\n\n\tif err := config.Validate(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient := &Client{\n\t\tconfig: *config,\n\t\theaders: map[string]string{},\n\t\thttpClient: cleanhttp.DefaultClient(),\n\t}\n\n\treturn client, nil\n}", "func newScraper(u *url.URL, timeout int) (*scraper, error) {\n\tvar title string\n\tvar language string\n\tvar author string\n\tvar description string\n\tvar generator string\n\tvar feed string\n\tcharset := \"utf-8\"\n\tlinks := make([]string, 0)\n\timages := make([]string, 0)\n\tkeywords := make([]string, 0)\n\tcompatibility := make(map[string]string)\n\n\tscrpr := func(n *html.Node) {\n\t\tswitch n.Data {\n\t\tcase \"html\":\n\t\t\tlanguage = findAttribute(n, \"lang\")\n\t\tcase \"title\":\n\t\t\ttitle = n.FirstChild.Data\n\t\tcase \"a\":\n\t\t\tlinks = addElement(links, u, n, \"href\")\n\t\tcase \"img\":\n\t\t\timages = addElement(images, u, n, \"src\")\n\t\tcase \"link\":\n\t\t\ttyp := findAttribute(n, \"type\")\n\t\t\tswitch typ {\n\t\t\tcase \"application/rss+xml\":\n\t\t\t\tfeed = findAttribute(n, \"href\")\n\t\t\t}\n\t\tcase \"meta\":\n\t\t\tname := findAttribute(n, \"name\")\n\t\t\tswitch name {\n\t\t\tcase \"author\":\n\t\t\t\tauthor = findAttribute(n, \"content\")\n\t\t\tcase \"keywords\":\n\t\t\t\tkeywords = strings.Split(findAttribute(n, \"content\"), \", \")\n\t\t\tcase \"description\":\n\t\t\t\tdescription = findAttribute(n, \"content\")\n\t\t\tcase \"generator\":\n\t\t\t\tgenerator = findAttribute(n, \"content\")\n\t\t\t}\n\n\t\t\thttpEquiv := findAttribute(n, \"http-equiv\")\n\t\t\tswitch httpEquiv {\n\t\t\tcase \"Content-Type\":\n\t\t\t\tcharset = findCharset(findAttribute(n, \"content\"))\n\t\t\tcase \"X-UA-Compatible\":\n\t\t\t\tcompatibility = mapifyStr(findAttribute(n, \"content\"))\n\t\t\t}\n\t\t}\n\t}\n\n\tcl := http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tDial: timeoutDialer(timeout),\n\t\t},\n\t}\n\n\tresp, err := cl.Get(u.String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\ttree, err := h5.New(resp.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttree.Walk(scrpr)\n\n\treturn &scraper{title,\n\t\tlanguage,\n\t\tauthor,\n\t\tdescription,\n\t\tgenerator,\n\t\tfeed,\n\t\tcharset,\n\t\tlinks,\n\t\timages,\n\t\tkeywords,\n\t\tcompatibility}, nil\n}", "func New(filepath string, opts ...Option) (*Client, error) {\n\tvar options Options\n\tfor _, o := range opts {\n\t\to(&options)\n\t}\n\n\tc := &Client{filepath: filepath}\n\tif strings.HasPrefix(filepath, \"http://\") || strings.HasPrefix(filepath, \"https://\") {\n\t\tc.isURL = true\n\t\tc.httpClient = http.Client{\n\t\t\tTimeout: 5 * time.Second,\n\t\t\tTransport: &transport{\n\t\t\t\tHeaders: options.Headers,\n\t\t\t},\n\t\t}\n\t}\n\treturn c, nil\n}", "func NewClient(registryURL string) *Client {\n\treturn &Client{\n\t\turl: registryURL + \"/sgulreg/services\",\n\t\thttpClient: http.DefaultClient,\n\t\treqMux: &sync.RWMutex{},\n\t\tregistered: false,\n\t}\n}", "func NewClient(httpClient *http.Client, atlasSubdomain string) (*Client, error) {\n\tif httpClient == nil {\n\t\thttpClient = &http.Client{}\n\t}\n\n\tvar baseURLStr strings.Builder\n\tbaseURLStr.WriteString(\"https://\")\n\tbaseURLStr.WriteString(atlasSubdomain)\n\tbaseURLStr.WriteString(\".\")\n\tbaseURLStr.WriteString(defaultBaseURL)\n\n\tbaseURL, err := url.Parse(baseURLStr.String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc := &Client{client: httpClient, BaseURL: baseURL}\n\tc.common.client = c\n\tc.ApplicationRole = (*ApplicationRoleService)(&c.common)\n\tc.AuditRecords = (*AuditRecordsService)(&c.common)\n\tc.AvatarsService = (*AvatarsService)(&c.common)\n\treturn c, nil\n}", "func NewClient(sugar *zap.SugaredLogger, url, signingKey string) (*Client, error) {\n\tconst timeout = time.Minute\n\tclient := &http.Client{Timeout: timeout}\n\treturn &Client{sugar: sugar, url: url, client: client, signingKey: signingKey}, nil\n}", "func NewClient(url, usr, pwd string, mods ...func(*Client)) (Client, error) {\n\n\t// Normalize the URL\n\tif !strings.HasPrefix(url, \"http://\") && !strings.HasPrefix(url, \"https://\") {\n\t\turl = \"https://\" + url\n\t}\n\n\ttr := &http.Transport{\n\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\n\t}\n\n\tcookieJar, _ := cookiejar.New(nil)\n\thttpClient := http.Client{\n\t\tTimeout: 60 * time.Second,\n\t\tTransport: tr,\n\t\tJar: cookieJar,\n\t}\n\n\tclient := Client{\n\t\tHttpClient: &httpClient,\n\t\tUrl: url,\n\t\tUsr: usr,\n\t\tPwd: pwd,\n\t}\n\tfor _, mod := range mods {\n\t\tmod(&client)\n\t}\n\treturn client, nil\n}", "func NewClient(host string) *Client {\n\tc := &Client{}\n\tc.URL.Host = host\n\treturn c\n}", "func newTestClient(fn RoundTripFunc) *http.Client {\n\treturn &http.Client{\n\t\tTransport: fn,\n\t}\n}" ]
[ "0.6308598", "0.6222202", "0.6097972", "0.6060751", "0.6043418", "0.604116", "0.5992147", "0.5986665", "0.5968273", "0.59570366", "0.5919546", "0.59144855", "0.59128547", "0.5904674", "0.5874914", "0.58727384", "0.58473456", "0.5841087", "0.58391356", "0.5830302", "0.5823845", "0.5815095", "0.5804614", "0.5800183", "0.5796186", "0.5795588", "0.57711905", "0.5763741", "0.5753981", "0.57287747", "0.5712433", "0.57012725", "0.56978256", "0.5692709", "0.56791", "0.56674045", "0.565989", "0.564957", "0.56408155", "0.5632043", "0.5631362", "0.56286025", "0.5625796", "0.5624589", "0.5599554", "0.55965966", "0.5592429", "0.55880785", "0.55741847", "0.5560923", "0.5559902", "0.55595577", "0.5537816", "0.55329883", "0.55228436", "0.55169463", "0.55051345", "0.5503144", "0.548703", "0.5482654", "0.54718596", "0.5468862", "0.54663694", "0.5466146", "0.54604673", "0.5457545", "0.54533696", "0.54507905", "0.54492724", "0.54453605", "0.5443859", "0.5435001", "0.54324573", "0.5432445", "0.54248315", "0.54221255", "0.54093087", "0.54060847", "0.54058945", "0.5403997", "0.5401059", "0.5401059", "0.53993934", "0.5399327", "0.5398481", "0.5398267", "0.53973943", "0.5395777", "0.5394296", "0.5392406", "0.53896695", "0.538825", "0.5388043", "0.53799886", "0.5373203", "0.53694224", "0.53693706", "0.53581595", "0.53557223", "0.5348011" ]
0.76326865
0
Close closes the client, which does nothing at present.
func (t *Client) Close() error { return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Close() {\n\t_ = client.Close()\n}", "func (c *Client) Close() {}", "func (c *Client) Close() {}", "func (c *client) Close() error { return c.c.Close() }", "func (c *Client) Close() error {\n\treturn nil\n}", "func (c *Client) Close() {\n}", "func (c *Client) Close() {\n}", "func (c *Client) Close() error {\n\tc.client = nil\n\treturn nil\n}", "func (fic *FakeClient) Close() {\n}", "func Close() {\n\tdefaultClient.Close()\n}", "func (c *clientImpl) Close() {\r\n\tif c != nil {\r\n\t\tc.Close()\r\n\t}\r\n}", "func (rpc BitcoinRPC) Close() {\n\trpc.client.Close()\n}", "func (c *Client) Close() {\n\tc.close()\n}", "func (self *Client) close() {\n\t// TODO: Cleanly close connection to remote\n}", "func (c *InfluxClient) Close() {\n\tc.Client.Close()\n\tc.connected = false\n}", "func (client *Client) Close() {\n\tclient.conn.Close()\n\tclient.conn = nil\n}", "func (c *GethClient) Close() {\n\tc.Close()\n}", "func (c *Client) Close() {\n\tc.Client.Close()\n\tif c.clientConfig != \"\" {\n\t\tos.Remove(c.clientConfig)\n\t}\n\tc.Server.Close()\n}", "func (c *Client) Close() error {\n\tc.tunnel.Close()\n\treturn nil\n}", "func (client *Client) Close() (err error) {\n\tif !client.connected {\n\t\treturn\n\t}\n\tid := client.ID\n\tif client.ID == \"\" {\n\t\tid = client.Name\n\t}\n\tif err = client.Agent().ServiceDeregister(id); err != nil {\n\t\treturn errors.Wrap(err, \"deregistering service\")\n\t}\n\treturn errors.Wrap(client.Close(), \"closing client\")\n}", "func (client *client) Close() error {\n\treturn client.closeSocket()\n}", "func (c *Client) Close() error {\n\n\treturn c.close()\n}", "func (ec *Client) Close() {\n\tec.c.Close()\n}", "func (client *Client) Close() {\n\tclient.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.close()\n}", "func (c *SodaClient) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.ec.Close()\n}", "func (c *Client) Close() {\n\t_ = c.conn.Close()\n}", "func (c *NATSTestClient) Close() {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tif !c.connected {\n\t\treturn\n\t}\n\tclose(c.reqs)\n\tc.connected = false\n}", "func (client *Client) Close() {\n\t// Set halting flag and then close our socket to server.\n\t// This will cause the blocked getIO() in readReplies() to return.\n\tclient.Lock()\n\tclient.halting = true\n\tif client.connection.state == CONNECTED {\n\t\tclient.connection.state = INITIAL\n\t\tclient.connection.Close()\n\t}\n\tclient.Unlock()\n\n\t// Wait for the goroutines to return\n\tclient.goroutineWG.Wait()\n\tbucketstats.UnRegister(bucketStatsPkgName, client.GetStatsGroupName())\n}", "func (c *Client) Close() error {\n\tc.stop(false)\n\treturn nil\n}", "func (c *Client) Close() error {\n\treturn c.s.Close()\n}", "func (c *client) Close() {\n\tc.exit <- 1\n}", "func (c *Client) Close() error {\n\tif c.rpc == nil {\n\t\treturn nil // Nothing to do\n\t}\n\n\treturn c.rpc.Close()\n}", "func (cl *Client) Close() (err error) {\n\tcl.url = nil\n\treturn cl.conn.Close()\n}", "func (svc *Client) Close() {\n\tsvc.Conn.Disconnect()\n}", "func (c *Client) Close() (err error) {\n\tc.writer = nil\n\tc.events = nil\n\treturn\n}", "func (pc *Client) Close() {\n\tpc.connected = false\n\tpc.connection.Close()\n}", "func (cli *Client) Close() {\n\tcli.ref.Call(\"close\")\n\tcli.listener.Release()\n}", "func (gc *GokuyamaClient) Close() error {\n\tvar err error\n\terr = gc.conn.Close()\n\treturn err\n}", "func (self *Echo_Client) Close() {\n\tself.cc.Close()\n}", "func (_m *Client) Close() {\n\t_m.Called()\n}", "func (_m *Client) Close() {\n\t_m.Called()\n}", "func (c *Client) Close() error {\n\treturn c.internalClient.Close()\n}", "func (c *Client) Close() error {\n\treturn c.internalClient.Close()\n}", "func (c *Client) Close() error {\n\treturn c.internalClient.Close()\n}", "func (c *Client) Close() error {\n\treturn c.internalClient.Close()\n}", "func (c *Client) Close() error {\n\treturn c.internalClient.Close()\n}", "func (c *Client) Close() error {\n\treturn c.internalClient.Close()\n}", "func (c *Client) Close() error {\n\treturn c.internalClient.Close()\n}", "func (c *FakeEtcdClient) Close() error {\n\treturn nil\n}", "func (c *Client) Close() {\n\tc.quit <- struct{}{}\n}", "func (b *BIRDClient) Close() error { return b.conn.Close() }", "func (s *SSHClient) Close() error {\n\ts.lock.Lock()\n\tdefer s.lock.Unlock()\n\n\tif s.client == nil {\n\t\treturn nil\n\t}\n\tdefer func() {\n\t\ts.client.Close()\n\t\ts.client = nil\n\t}()\n\n\t// some vendors have issues with the bmc if you don't do it\n\tif _, err := s.run(\"exit\"); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c *Client) Close() { c.streamLayer.Close() }", "func (client *StatsdClient) Close() {\n\tclient.conn.Close()\n}", "func (client *AMIClient) Close() {\n\tif client.loggedIn {\n\t\tclient.Action(\"Logoff\", nil, time.Second*3)\n\t}\n\tclient.connRaw.Close()\n}", "func (client *Client) Close() (err error) {\n\t// defer func() {\n\t// \tif e := recover(); e != nil {\n\t// \t\terr = fmt.Errorf(\"%v\", e)\n\t// \t}\n\t// }()\n\tC.Clear(client.api)\n\tC.Free(client.api)\n\tif client.pixImage != nil {\n\t\tC.DestroyPixImage(client.pixImage)\n\t\tclient.pixImage = nil\n\t}\n\treturn err\n}", "func (r *client) Close() error {\n\treturn r.conn.Close()\n}", "func (c *TensorboardClient) Close() error {\n\treturn c.internalClient.Close()\n}", "func (client *Client) Close() {\n\tclient.done <- struct{}{}\n\tclient.BaseClient.Close()\n\tplog.Info(\"pos33 consensus closed\")\n}", "func (c *Client) Close() error {\n\treturn c.Text.Close()\n}", "func (clt *client) Close() {\n\t// Apply exclusive lock\n\tclt.apiLock.Lock()\n\n\t// Disable autoconnect and set status to disabled\n\tatomic.CompareAndSwapInt32(\n\t\t&clt.autoconnect,\n\t\tautoconnectEnabled,\n\t\tautoconnectDeactivated,\n\t)\n\n\tclt.close()\n\n\tclt.apiLock.Unlock()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n}", "func (c *Client) Close() error {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\t// check if closed\n\tif !c.connected {\n\t\treturn status.ErrNotConnected\n\t}\n\t// if not clean up and free resources\n\n\t// first exit the loop\n\tclose(c.shutdown)\n\t// wait for the main loop to exit\n\t<-c.loopExit\n\t// close ethereum client\n\tc.client.Close()\n\t// send shutdown error to listener\n\tc.sendError(status.ErrShutdown)\n\t// set closed to false\n\tc.connected = false\n\t// return\n\treturn nil\n}", "func (self *SPC_Client) Close() {\n\tself.cc.Close()\n}", "func (c *clientImpl) Close() error {\n\tif c.conn != nil {\n\t\tif err := c.conn.Close(); err != nil {\n\t\t\treturn errors.Wrap(err, \"conn.Close() failed\")\n\t\t}\n\t\tc.pbClient = nil\n\t\tc.conn = nil\n\t\tc.stream = nil\n\t\treturn nil\n\t}\n\treturn errors.Errorf(\"already Closed\")\n}", "func (c *Client) Close() {\n\tc.conn.Close()\n\tclose(c.In)\n\tclose(c.Out)\n}", "func (c *Client) Close() {\n\tif c.closed {\n\t\treturn\n\t}\n\n\tc.closed = true\n\tc.ws.Close()\n\tclose(c.sent)\n\tif c.room != nil {\n\t\tc.room.unregister <- c\n\t}\n}", "func (c *Client) Close() {\n\n\tc.status = Closing\n\n\tif c.conn != nil {\n\t\tc.conn.Close()\n\t}\n}", "func (c *Client) Close() {\n\tif c.watcher != nil {\n\t\tc.watcher.Close()\n\t}\n}", "func (c *Client) Close() error { return c.redis.Close() }", "func (c *Client) Close() {\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\tc.cancel()\n\tc.subs.destroy()\n\tc.conn.Close()\n\tclose(c.err)\n\tc.err = nil\n}", "func (t *SSHTester) Close() error {\n\treturn t.client.Close()\n}", "func (w *Client) Close() error {\n\treturn w.connection.Close()\n}", "func (c *Client) Close() {\n\tif c.conn == nil {\n\t\treturn\n\t}\n\n\tc.conn.Close()\n}", "func (c *Client) Close() error {\n\treturn c.p.Close()\n}", "func (cf *ClientFactory) Close() {\n\tcf.mux.Lock()\n\tdefer cf.mux.Unlock()\n\tif cf.client != nil {\n\t\tcf.client.close()\n\t}\n}", "func (c *Client) Close() {\n\t_, _ = c.Send(\"EXIT\")\n\tif c.connected {\n\t\tc.Socket.Close()\n\t}\n\tc.connected = false\n\treturn\n}", "func (c *Client) Close() error {\n\tif c.AStream != nil {\n\t\tif err := c.AStream.Close(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tc.AStream = nil\n\t}\n\n\tif c.PStream != nil {\n\t\tif err := c.PStream.Close(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tc.PStream = nil\n\t}\n\n\treturn nil\n}", "func (c Client) Close() error {\n\tif c.opened {\n\t\treturn c.conn.Close()\n\t}\n\n\treturn nil\n}", "func (c Client) Close() error {\n\tif c.opened {\n\t\treturn c.conn.Close()\n\t}\n\n\treturn nil\n}", "func (c *Client) Close() {\n\tc.mux.Lock()\n\tclient := c.gettyClient\n\tc.gettyClient = nil\n\tc.clientClosed = true\n\tc.mux.Unlock()\n\tif client != nil {\n\t\tclient.close()\n\t}\n}", "func (c *DVMClient) Close() error {\n\tc.Lock()\n\tdefer c.Unlock()\n\n\tif c.connection == nil {\n\t\treturn nil\n\t}\n\n\treturn c.connection.Close()\n}", "func (client *Client) Close() error {\n\treturn client.conn.Close()\n}", "func Close() error {\n\tif defaultClient == nil {\n\t\treturn nil\n\t}\n\treturn defaultClient.Close()\n}", "func (w *Watcher) Close() {\n\t_ = w.Client.Close()\n}", "func (client *Client) Close() error {\n\tclient.mutex.Lock()\n\tif client.closing {\n\t\tclient.mutex.Unlock()\n\t\treturn ErrShutdown\n\t}\n\tclient.closing = true\n\tclient.mutex.Unlock()\n\treturn client.codec.Close()\n}", "func (c *BaseClient) Close() error {\n\treturn c.close()\n}", "func (c *Client) Close() {\n\tif c.conn != nil {\n\t\tc.conn.Close()\n\t}\n}", "func (s *SSHer) Close() error {\n\treturn s.client.Close()\n}", "func (client *gRPCVtctldClient) Close() error {\n\terr := client.cc.Close()\n\tif err == nil {\n\t\tclient.c = nil\n\t}\n\n\treturn err\n}", "func (srv *InfluxSrv) Close() {\n\tsrv.client.Close()\n}", "func (c *Client) Close() error {\n\treturn c.connection.Close()\n}", "func (c *RuntimeSecurityClient) Close() {\n\tc.conn.Close()\n}" ]
[ "0.82270104", "0.8103801", "0.8103801", "0.8057519", "0.77404964", "0.7740057", "0.7740057", "0.7638049", "0.75866705", "0.7498036", "0.7448545", "0.74184066", "0.7416859", "0.74093086", "0.7403107", "0.7399654", "0.7392202", "0.7379306", "0.73588985", "0.7358413", "0.73463386", "0.73426104", "0.7342528", "0.7327643", "0.7310794", "0.7307894", "0.72999823", "0.72998804", "0.7298758", "0.7296355", "0.72951925", "0.7287979", "0.728127", "0.7277123", "0.7273756", "0.72626936", "0.7260742", "0.7255844", "0.72550136", "0.72463447", "0.7229975", "0.7227558", "0.7227558", "0.72239673", "0.72239673", "0.72239673", "0.72239673", "0.72239673", "0.72239673", "0.72239673", "0.72194237", "0.72175443", "0.7212796", "0.7206945", "0.72032934", "0.7194861", "0.71945345", "0.71941197", "0.7194038", "0.71712935", "0.71685845", "0.7153656", "0.7153655", "0.7152822", "0.7152822", "0.7152822", "0.7152822", "0.7152822", "0.7152822", "0.71517235", "0.71368444", "0.71347", "0.713203", "0.71282107", "0.7124221", "0.71233183", "0.7119305", "0.71185714", "0.7117628", "0.7116788", "0.71110255", "0.7108174", "0.7107162", "0.71062875", "0.7102925", "0.7098168", "0.7098168", "0.709633", "0.7094971", "0.7090664", "0.70872575", "0.7086487", "0.7085845", "0.7079192", "0.7074077", "0.707357", "0.70700336", "0.70526373", "0.7051886", "0.7051613" ]
0.7930484
4
Announce sends a Announce request to the tracker.
func (t *Client) Announce(c context.Context, req AnnounceRequest) ( resp AnnounceResponse, err error) { if req.PeerID.IsZero() { if t.ID.IsZero() { req.PeerID = metainfo.NewRandomHash() } else { req.PeerID = t.ID } } err = t.send(c, t.AnnounceURL, req.ToQuery(), &resp) return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b *Builder) Announce() (err error) {\n\targs := &rpc.AnnounceArgs{\n\t\tGOOS: b.b.GOOS(),\n\t\tGOARCH: b.b.GOARCH(),\n\t\tType: \"Builder\",\n\t\tURL: b.base,\n\t}\n\treply := new(rpc.AnnounceReply)\n\tif err = b.tcl.Call(\"Tracker.Announce\", args, reply); err != nil {\n\t\treturn\n\t}\n\tb.key = reply.Key\n\treturn\n}", "func (r *Runner) Announce() (err error) {\n\targs := &rpc.AnnounceArgs{\n\t\tGOOS: runtime.GOOS,\n\t\tGOARCH: runtime.GOARCH,\n\t\tType: \"Runner\",\n\t\tURL: r.base,\n\t}\n\treply := new(rpc.AnnounceReply)\n\tif err = r.tcl.Call(\"Tracker.Announce\", args, reply); err != nil {\n\t\treturn\n\t}\n\tr.key = reply.Key\n\treturn\n}", "func (cc *ClientConn) Announce(u *base.URL, tracks Tracks) (*base.Response, error) {\n\terr := cc.checkState(map[clientConnState]struct{}{\n\t\tclientConnStateInitial: {},\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// in case of ANNOUNCE, the base URL doesn't have a trailing slash.\n\t// (tested with ffmpeg and gstreamer)\n\tbaseURL := u.Clone()\n\n\t// set id, base url and control attribute on tracks\n\tfor i, t := range tracks {\n\t\tt.ID = i\n\t\tt.BaseURL = baseURL\n\t\tt.Media.Attributes = append(t.Media.Attributes, psdp.Attribute{\n\t\t\tKey: \"control\",\n\t\t\tValue: \"trackID=\" + strconv.FormatInt(int64(i), 10),\n\t\t})\n\t}\n\n\tres, err := cc.Do(&base.Request{\n\t\tMethod: base.Announce,\n\t\tURL: u,\n\t\tHeader: base.Header{\n\t\t\t\"Content-Type\": base.HeaderValue{\"application/sdp\"},\n\t\t},\n\t\tBody: tracks.Write(),\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif res.StatusCode != base.StatusOK {\n\t\treturn nil, liberrors.ErrClientWrongStatusCode{\n\t\t\tCode: res.StatusCode, Message: res.StatusMessage}\n\t}\n\n\tcc.streamBaseURL = baseURL\n\tcc.state = clientConnStatePreRecord\n\n\treturn res, nil\n}", "func SendAnnounce() {\n\tvar pkt MeshPkt\n\tvar annc AnnouncePkt\n\n\tpkt.PktPayload = TypeAnnounce\n\tpkt.SenderID = MySID\n\n\tannc.NumServices = 3\n\tannc.Services = [32]int8{ServiceLookup, ServicePubChat, ServicePrivMsg}\n\n\tvar buffer bytes.Buffer\n\n\tbinary.Write(&buffer, binary.BigEndian, &pkt)\n\tbinary.Write(&buffer, binary.BigEndian, &annc)\n\n\tsendPkt(\"255.255.255.255\", 8032, buffer.Bytes())\n}", "func NewAnnounce(c *gin.Context) (*AnnounceRequest, error) {\n\tq, err := QueryStringParser(c.Request.RequestURI)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcompact := q.Params[\"compact\"] != \"0\"\n\n\tevent := ANNOUNCE\n\tevent_name, _ := q.Params[\"event\"]\n\tswitch event_name {\n\tcase \"started\":\n\t\tevent = STARTED\n\tcase \"stopped\":\n\t\tevent = STOPPED\n\tcase \"completed\":\n\t\tevent = COMPLETED\n\t}\n\n\tnumWant := getNumWant(q, 30)\n\n\tinfo_hash, exists := q.Params[\"info_hash\"]\n\tif !exists {\n\t\treturn nil, errors.New(\"Info hash not supplied\")\n\t}\n\n\tpeerID, exists := q.Params[\"peer_id\"]\n\tif !exists {\n\t\treturn nil, errors.New(\"Peer id not supplied\")\n\t}\n\n\tipv4, err := getIP(q.Params[\"ip\"])\n\tif err != nil {\n\t\t// Look for forwarded ip in header then default to remote address\n\t\tforwarded_ip := c.Request.Header.Get(\"X-Forwarded-For\")\n\t\tif forwarded_ip != \"\" {\n\t\t\tipv4_new, err := getIP(forwarded_ip)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(\"NewAnnounce: Failed to parse header supplied IP\", err)\n\t\t\t\treturn nil, errors.New(\"Invalid ip header\")\n\t\t\t}\n\t\t\tipv4 = ipv4_new\n\t\t} else {\n\t\t\ts := strings.Split(c.Request.RemoteAddr, \":\")\n\t\t\tip_req, _ := s[0], s[1]\n\t\t\tipv4_new, err := getIP(ip_req)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(\"NewAnnounce: Failed to parse detected IP\", err)\n\t\t\t\treturn nil, errors.New(\"Invalid ip hash\")\n\t\t\t}\n\t\t\tipv4 = ipv4_new\n\t\t}\n\t}\n\n\tport, err := q.Uint64(\"port\")\n\tif err != nil || port < 1024 || port > 65535 {\n\t\treturn nil, errors.New(\"Invalid port, must be between 1024 and 65535\")\n\t}\n\n\tleft, err := q.Uint64(\"left\")\n\tif err != nil {\n\t\treturn nil, errors.New(\"No left value\")\n\t} else {\n\t\tleft = util.UMax(0, left)\n\t}\n\n\tdownloaded, err := q.Uint64(\"downloaded\")\n\tif err != nil {\n\t\tdownloaded = 0\n\t} else {\n\t\tdownloaded = util.UMax(0, downloaded)\n\t}\n\n\tuploaded, err := q.Uint64(\"uploaded\")\n\tif err != nil {\n\t\tuploaded = 0\n\t} else {\n\t\tuploaded = util.UMax(0, uploaded)\n\t}\n\n\tcorrupt, err := q.Uint64(\"corrupt\")\n\tif err != nil {\n\t\t// Assume we just don't have the param\n\t\tcorrupt = 0\n\t} else {\n\t\tcorrupt = util.UMax(0, corrupt)\n\t}\n\n\treturn &AnnounceRequest{\n\t\tCompact: compact,\n\t\tCorrupt: corrupt,\n\t\tDownloaded: downloaded,\n\t\tEvent: event,\n\t\tIPv4: ipv4,\n\t\tInfoHash: info_hash,\n\t\tLeft: left,\n\t\tNumWant: numWant,\n\t\tPeerID: peerID,\n\t\tPort: port,\n\t\tUploaded: uploaded,\n\t}, nil\n}", "func (tracker *Tracker) HandleAnnounce(ctx *gin.Context) {\n\tstats.RegisterEvent(stats.EV_ANNOUNCE)\n\tr := db.Pool.Get()\n\tdefer r.Close()\n\tif r.Err() != nil {\n\t\tstats.RegisterEvent(stats.EV_ANNOUNCE_FAIL)\n\t\tctx.Error(r.Err()).SetMeta(errMeta(\n\t\t\tMSG_GENERIC_ERROR,\n\t\t\t\"Internal error, HALP\",\n\t\t\tlog.Fields{\"fn\": \"HandleAnnounce\"},\n\t\t\tlog.ErrorLevel,\n\t\t))\n\t\treturn\n\t}\n\n\tlog.Debugln(ctx.Request.RequestURI)\n\tann, err := NewAnnounce(ctx)\n\tif err != nil {\n\t\tstats.RegisterEvent(stats.EV_ANNOUNCE_FAIL)\n\t\tctx.Error(err).SetMeta(errMeta(\n\t\t\tMSG_QUERY_PARSE_FAIL,\n\t\t\t\"Failed to parse announce\",\n\t\t\tlog.Fields{\n\t\t\t\t\"fn\": \"HandleAnnounce\",\n\t\t\t\t\"remote_ip\": ctx.Request.RemoteAddr,\n\t\t\t\t\"uri\": ctx.Request.RequestURI,\n\t\t\t},\n\t\t\tlog.ErrorLevel,\n\t\t))\n\t\treturn\n\t}\n\n\tinfo_hash_hex := fmt.Sprintf(\"%x\", ann.InfoHash)\n\tlog.WithFields(log.Fields{\n\t\t\"ih\": info_hash_hex,\n\t\t\"ip\": ann.IPv4,\n\t\t\"port\": ann.Port,\n\t\t\"up\": util.Bytes(ann.Uploaded),\n\t\t\"dn\": util.Bytes(ann.Downloaded),\n\t\t\"left\": util.Bytes(ann.Left),\n\t\t\"event\": ann.Event,\n\t}).Debug(\"Announce event\")\n\n\tpasskey := ctx.Param(\"passkey\")\n\n\tuser_id := tracker.findUserID(passkey)\n\tif user_id == 0 {\n\t\tstats.RegisterEvent(stats.EV_INVALID_PASSKEY)\n\t\tctx.Error(errors.New(\"Invalid passkey\")).SetMeta(errMeta(\n\t\t\tMSG_INVALID_AUTH,\n\t\t\t\"Invalid passkey supplied\",\n\t\t\tlog.Fields{\"fn\": \"HandleAnnounce\", \"passkey\": passkey},\n\t\t\tlog.ErrorLevel,\n\t\t))\n\t\treturn\n\t}\n\n\tuser := tracker.FindUserByID(user_id)\n\tif !user.CanLeech && ann.Left > 0 {\n\t\tctx.Error(errors.New(\"Leech disabled for user\")).SetMeta(errMeta(\n\t\t\tMSG_GENERIC_ERROR,\n\t\t\t\"Leeching not allowed for user\",\n\t\t\tlog.Fields{\"fn\": \"HandleAnnounce\", \"passkey\": passkey},\n\t\t\tlog.ErrorLevel,\n\t\t))\n\t\treturn\n\t}\n\tif !user.Enabled {\n\t\tctx.Error(errors.New(\"Disabled user\")).SetMeta(errMeta(\n\t\t\tMSG_GENERIC_ERROR,\n\t\t\t\"User disabled\",\n\t\t\tlog.Fields{\"fn\": \"HandleAnnounce\", \"passkey\": passkey},\n\t\t\tlog.ErrorLevel,\n\t\t))\n\t\treturn\n\t}\n\n\tif !tracker.IsValidClient(ann.PeerID) {\n\t\tstats.RegisterEvent(stats.EV_INVALID_CLIENT)\n\t\tctx.Error(errors.New(\"Banned client\")).SetMeta(errMeta(\n\t\t\tMSG_GENERIC_ERROR,\n\t\t\t\"Banned client, check wiki for whitelisted clients\",\n\t\t\tlog.Fields{\n\t\t\t\t\"fn\": \"HandleAnnounce\",\n\t\t\t\t\"user_id\": user.UserID,\n\t\t\t\t\"user_name\": user.Username,\n\t\t\t\t\"peer_id\": ann.PeerID[0:8],\n\t\t\t},\n\t\t\tlog.ErrorLevel,\n\t\t))\n\t\treturn\n\t}\n\n\ttorrent := tracker.FindTorrentByInfoHash(info_hash_hex)\n\tif torrent == nil {\n\t\tstats.RegisterEvent(stats.EV_INVALID_INFOHASH)\n\t\tctx.Error(errors.New(\"Invalid info hash\")).SetMeta(errMeta(\n\t\t\tMSG_INFO_HASH_NOT_FOUND,\n\t\t\t\"Torrent not found, try TPB\",\n\t\t\tlog.Fields{\n\t\t\t\t\"fn\": \"HandleAnnounce\",\n\t\t\t\t\"user_id\": user.UserID,\n\t\t\t\t\"user_name\": user.Username,\n\t\t\t\t\"info_hash\": info_hash_hex,\n\t\t\t},\n\t\t\tlog.WarnLevel,\n\t\t))\n\t\treturn\n\t} else if !torrent.Enabled {\n\t\tstats.RegisterEvent(stats.EV_INVALID_INFOHASH)\n\t\tctx.Error(errors.New(\"Torrent not enabled\")).SetMeta(errMeta(\n\t\t\tMSG_INFO_HASH_NOT_FOUND,\n\t\t\ttorrent.DelReason(),\n\t\t\tlog.Fields{\n\t\t\t\t\"fn\": \"HandleAnnounce\",\n\t\t\t\t\"user_id\": user.UserID,\n\t\t\t\t\"user_name\": user.Username,\n\t\t\t\t\"info_hash\": info_hash_hex,\n\t\t\t},\n\t\t\tlog.WarnLevel,\n\t\t))\n\t\treturn\n\t}\n\n\tpeer := torrent.findPeer(ann.PeerID)\n\tif peer == nil {\n\t\tlog.Debug(\"No existing peer found\")\n\t\tpeer = NewPeer(ann.PeerID, ann.IPv4.String(), ann.Port, torrent, user)\n\t\t// torrent.AddPeer(r, peer)\n\t}\n\n\tpeer_diff := PeerDiff{User: user, Torrent: torrent}\n\t// user update MUST happen after peer update since we rely on the old dl/ul values\n\tpeer.Update(ann, &peer_diff, torrent.Seeders)\n\ttorrent.Update(ann)\n\tuser.Update(ann, &peer_diff, torrent.MultiUp, torrent.MultiDn)\n\n\tif ann.Event == STOPPED {\n\t\tlog.Debug(\"Removing peer due to stop announce\")\n\t\ttorrent.DelPeer(r, peer)\n\t} else {\n\t\tif !torrent.HasPeer(peer) {\n\t\t\ttorrent.AddPeer(r, peer)\n\t\t}\n\t}\n\n\tif ann.Event == STOPPED {\n\t\t// Remove from torrents active peer set\n\t\tr.Send(\"SREM\", torrent.TorrentPeersKey, ann.PeerID)\n\n\t\tr.Send(\"SREM\", user.KeyActive, torrent.TorrentID)\n\n\t\t// Mark the peer as inactive\n\t\tr.Send(\"HSET\", peer.KeyPeer, \"active\", 0)\n\n\t\tr.Send(\"DEL\", peer.KeyTimer)\n\n\t\tif peer.IsHNR() {\n\t\t\tuser.AddHNR(r, torrent.TorrentID)\n\t\t}\n\t} else if ann.Event == COMPLETED {\n\n\t\t// Remove the torrent from the users incomplete set\n\t\tr.Send(\"SREM\", user.KeyIncomplete, torrent.TorrentID)\n\n\t\t// Remove the torrent from the users incomplete set\n\t\tr.Send(\"SADD\", user.KeyComplete, torrent.TorrentID)\n\n\t\t// Remove from the users hnr list if it exists\n\t\tr.Send(\"SREM\", user.KeyHNR, torrent.TorrentID)\n\n\t} else if ann.Event == STARTED {\n\t\t// Make sure we account for a user completing a torrent outside of\n\t\t// our view, or resuming from previously completions\n\t\tif peer.IsSeeder() {\n\t\t\tr.Send(\"SREM\", user.KeyHNR, torrent.TorrentID)\n\t\t\tr.Send(\"SREM\", user.KeyIncomplete, torrent.TorrentID)\n\t\t\tr.Send(\"SADD\", user.KeyComplete, torrent.TorrentID)\n\t\t} else {\n\t\t\tr.Send(\"SREM\", user.KeyComplete, torrent.TorrentID)\n\t\t\tr.Send(\"SADD\", user.KeyIncomplete, torrent.TorrentID)\n\t\t}\n\t}\n\n\tif ann.Event != STOPPED {\n\n\t\t// Add peer to torrent active peers\n\t\tr.Send(\"SADD\", torrent.TorrentPeersKey, ann.PeerID)\n\n\t\t// Add to users active torrent set\n\t\tr.Send(\"SADD\", user.KeyActive, torrent.TorrentID)\n\n\t\t// Refresh the peers expiration timer\n\t\t// If this expires, the peer reaper takes over and removes the\n\t\t// peer from torrents in the case of a non-clean client shutdown\n\t\tr.Send(\"SETEX\", peer.KeyTimer, conf.Config.ReapInterval, 1)\n\t}\n\tr.Flush()\n\n\tSyncEntityC <- torrent\n\tSyncEntityC <- user\n\n\tdict := bencode.Dict{\n\t\t\"complete\": torrent.Seeders,\n\t\t\"incomplete\": torrent.Leechers,\n\t\t\"interval\": conf.Config.AnnInterval,\n\t\t\"min interval\": conf.Config.AnnIntervalMin,\n\t}\n\n\tpeers := torrent.GetPeers(ann.NumWant, peer.GetCoord())\n\tif peers != nil {\n\t\tdict[\"peers\"] = MakeCompactPeers(peers, ann.PeerID)\n\t} else {\n\t\tdict[\"peers\"] = []byte{}\n\t}\n\tvar out_bytes bytes.Buffer\n\tencoder := bencode.NewEncoder(&out_bytes)\n\n\ter_msg_encoded := encoder.Encode(dict)\n\tif er_msg_encoded != nil {\n\t\tstats.RegisterEvent(stats.EV_ANNOUNCE_FAIL)\n\t\tctx.Error(er_msg_encoded).SetMeta(errMeta(\n\t\t\tMSG_GENERIC_ERROR,\n\t\t\t\"Internal error\",\n\t\t\tlog.Fields{\n\t\t\t\t\"fn\": \"HandleAnnounce\",\n\t\t\t\t\"user_id\": user.UserID,\n\t\t\t\t\"user_name\": user.Username,\n\t\t\t\t\"info_hash\": info_hash_hex,\n\t\t\t},\n\t\t\tlog.DebugLevel,\n\t\t))\n\t\treturn\n\t}\n\n\tctx.String(MSG_OK, out_bytes.String())\n}", "func Announce(url string) (*AnnounceResponse, error) {\n\tres, err := http.Get(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbuf := new(bytes.Buffer)\n\tbuf.ReadFrom(res.Body)\n\tannRes := new(AnnounceResponse)\n\terr = bencode.Unmarshal(buf, annRes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn annRes, nil\n}", "func (u UDPTracker) Announce(query url.Values, file data.FileRecord) []byte {\n\t// Create UDP announce response\n\tannounce := udp.AnnounceResponse{\n\t\tAction: 1,\n\t\tTransID: u.TransID,\n\t\tInterval: uint32(common.Static.Config.Interval),\n\t\tLeechers: uint32(file.Leechers()),\n\t\tSeeders: uint32(file.Seeders()),\n\t}\n\n\t// Convert to UDP byte buffer\n\tannounceBuf, err := announce.MarshalBinary()\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\treturn u.Error(\"Could not create UDP announce response\")\n\t}\n\n\t// Numwant\n\tnumwant, err := strconv.Atoi(query.Get(\"numwant\"))\n\tif err != nil {\n\t\tnumwant = 50\n\t}\n\n\t// Add compact peer list\n\tres := bytes.NewBuffer(announceBuf)\n\terr = binary.Write(res, binary.BigEndian, file.PeerList(query.Get(\"ip\"), numwant))\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\treturn u.Error(\"Could not create UDP announce response\")\n\t}\n\n\treturn res.Bytes()\n}", "func (c *Conn) Announce(msg string) {\n\tc.announce(msg, c.username)\n}", "func (m *DHTModule) Announce(key string) {\n\n\tif m.IsAttached() {\n\t\tif err := m.Client.DHT().Announce(key); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\treturn\n\t}\n\n\tm.dht.Announce(announcer.ObjTypeAny, \"\", []byte(key), nil)\n}", "func (t *UDPTracker) Announce(hash meta.Hash, id []byte, ip net.IP, port int, event int, status *DownloadStatus) ([]string, error) {\n\tif t.conn == nil {\n\t\terr := t.connect()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tdata, err := t.announce(hash, event, status)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpeers := convAddrs(data)\n\tif peers == nil {\n\t\treturn nil, errUDPResp\n\t}\n\treturn peers, nil\n}", "func (teamID TeamID) SendAnnounce(message string) error {\n\t// for each agent on the team\n\t// determine which messaging protocols are enabled for gid\n\t// pick optimal\n\n\t// ok, err := SendMessage(gid, message)\n\treturn nil\n}", "func (n *Interface) StartAnnounce() {\n\tn.ad.StartAnnounceDaemon()\n}", "func (c *chatRoom) announce(msg string) {\n\tc.messages <- \"* \" + msg + \" *\"\n}", "func (g *GateKeeper) announce() error {\n\tm, err := json.Marshal(g.Meta)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Debug().Msg(\"Starting to announce API to etcd\")\n\t_, err = (*g.etcd).Set(context.Background(), \"/meta/gatekeeper\", string(m), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Info().Msg(\"Gatekeeper registered in etcd.\")\n\treturn nil\n}", "func (tracker *UDP) Announce(ctx context.Context, hash []byte, myid []byte,\n\twant int, size int64, port4, port6 int, proxy string,\n\tf func(net.IP, int) bool) error {\n\tok := tracker.tryLock()\n\tif !ok {\n\t\treturn ErrNotReady\n\t}\n\tdefer tracker.unlock()\n\n\tif !tracker.ready() {\n\t\treturn ErrNotReady\n\t}\n\n\turl, err := nurl.Parse(tracker.url)\n\tif err != nil {\n\t\ttracker.updateInterval(0, err)\n\t\treturn err\n\t}\n\n\ttracker.time = time.Now()\n\n\tvar i4, i6 time.Duration\n\tvar e4, e6 error\n\tvar wg sync.WaitGroup\n\twg.Add(2)\n\tgo func() {\n\t\ti4, e4 = announceUDP(ctx, \"udp4\", f,\n\t\t\turl, hash, myid, want, size, port4, proxy)\n\t\twg.Done()\n\t}()\n\tgo func() {\n\t\ti6, e6 = announceUDP(ctx, \"udp6\", f,\n\t\t\turl, hash, myid, want, size, port6, proxy)\n\t\twg.Done()\n\t}()\n\twg.Wait()\n\tif e4 != nil && e6 != nil {\n\t\terr = e4\n\t}\n\tinterval := i4\n\tif interval < i6 {\n\t\tinterval = i6\n\t}\n\n\ttracker.updateInterval(interval, err)\n\treturn err\n}", "func (a *Announcer) Announce(\n\tctx context.Context,\n\tmemberIndex group.MemberIndex,\n\tsessionID string,\n) (\n\t[]group.MemberIndex,\n\terror,\n) {\n\tmessagesChan := make(chan net.Message, announceReceiveBuffer)\n\n\ta.broadcastChannel.Recv(ctx, func(message net.Message) {\n\t\tmessagesChan <- message\n\t})\n\n\terr := a.broadcastChannel.Send(ctx, &announcementMessage{\n\t\tsenderID: memberIndex,\n\t\tprotocolID: a.protocolID,\n\t\tsessionID: sessionID,\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot send announcement message: [%w]\", err)\n\t}\n\n\treadyMembersIndexesSet := make(map[group.MemberIndex]bool)\n\t// Mark itself as ready.\n\treadyMembersIndexesSet[memberIndex] = true\n\nloop:\n\tfor {\n\t\tselect {\n\t\tcase netMessage := <-messagesChan:\n\t\t\tannouncement, ok := netMessage.Payload().(*announcementMessage)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif announcement.senderID == memberIndex {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !a.membershipValidator.IsValidMembership(\n\t\t\t\tannouncement.senderID,\n\t\t\t\tnetMessage.SenderPublicKey(),\n\t\t\t) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif announcement.protocolID != a.protocolID {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif announcement.sessionID != sessionID {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\treadyMembersIndexesSet[announcement.senderID] = true\n\t\tcase <-ctx.Done():\n\t\t\tbreak loop\n\t\t}\n\t}\n\n\treadyMembersIndexes := make([]group.MemberIndex, 0)\n\tfor memberIndex := range readyMembersIndexesSet {\n\t\treadyMembersIndexes = append(readyMembersIndexes, memberIndex)\n\t}\n\n\tsort.Slice(readyMembersIndexes, func(i, j int) bool {\n\t\treturn readyMembersIndexes[i] < readyMembersIndexes[j]\n\t})\n\n\treturn readyMembersIndexes, nil\n}", "func (bft *ProtocolBFTCoSi) startAnnouncement(t RoundType) error {\n\tbft.announceChan <- announceChan{Announce: Announce{TYPE: t, Timeout: bft.Timeout}}\n\treturn nil\n}", "func (c *Caller) Announce() (Card, error) {\n\t// XXX Must have at least one player to start the game.\n\tif c.gameFinished {\n\t\treturn blankCard, fmt.Errorf(\"game already finished\")\n\t}\n\n\tc.gameStarted = true\n\tcard, err := c.deck.Select()\n\tif err != nil {\n\t\tc.gameFinished = true\n\t\treturn card, err\n\t}\n\n\t// We update our internal boards to use them later in `Loteria` for\n\t// confirming the player really won.\n\tfor name, board := range c.players {\n\t\tif board.Mark(card) == nil {\n\t\t\tc.players[name] = board\n\t\t}\n\t}\n\n\treturn card, nil\n}", "func (inn *LocalNode) consulAnnounce(conf *Config) (err error) {\n\tcheckID := inn.ID() + \"_ttl\"\n\n\taddrParts := strings.Split(conf.RPCAddress, \":\")\n\tif len(addrParts) < 2 {\n\t\treturn errors.New(\"address format should be HOST:PORT\")\n\t}\n\tport, err := strconv.ParseInt(addrParts[1], 10, 64)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcheckInterval, err := time.ParseDuration(conf.Health.CheckInterval)\n\tif err != nil {\n\t\treturn err\n\t}\n\tcheckTimeout, err := time.ParseDuration(conf.Health.CheckTimeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Create heartbeat check\n\tacc := consulapi.AgentServiceCheck{\n\t\tCheckID: checkID,\n\t\tName: checkID,\n\t\tStatus: consulapi.HealthCritical,\n\t\tDeregisterCriticalServiceAfter: conf.Health.DeregisterCriticalServiceAfter,\n\t\tTTL: (checkInterval + checkTimeout).String(),\n\t}\n\n\tservice := &consulapi.AgentServiceRegistration{\n\t\tID: conf.Consul.Service,\n\t\tName: conf.Consul.Service,\n\t\t//Tags: nil,\n\t\tPort: int(port),\n\t\tAddress: addrParts[0],\n\t\tCheck: &acc,\n\t\tNamespace: conf.Consul.Namespace,\n\t}\n\n\tif err := inn.consul.Agent().ServiceRegister(service); err != nil {\n\t\treturn err\n\t}\n\n\t// Run TTL updater\n\tgo inn.updateTTLConsul(checkInterval, checkID)\n\n\treturn nil\n}", "func announce() {\n\tif isCoordinator {\n\t\tlogrus.Info(\"Coordinator: \", isCoordinator)\n\t\trevealIP()\n\n\t\tlogrus.Info(\"Running on port: \", karaiPort)\n\t} else {\n\t\tlogrus.Debug(\"launching as normal user on port: \", karaiPort)\n\t}\n}", "func TestHeartbeatAnnounce(t *testing.T) {\n\tt.Parallel()\n\n\ttests := []struct {\n\t\tmode HeartbeatMode\n\t\tkind string\n\t}{\n\t\t{mode: HeartbeatModeProxy, kind: types.KindProxy},\n\t\t{mode: HeartbeatModeAuth, kind: types.KindAuthServer},\n\t}\n\tfor _, tt := range tests {\n\t\tt.Run(tt.mode.String(), func(t *testing.T) {\n\t\t\tctx, cancel := context.WithCancel(context.Background())\n\t\t\tdefer cancel()\n\t\t\tclock := clockwork.NewFakeClock()\n\n\t\t\tannouncer := newFakeAnnouncer(ctx)\n\t\t\thb, err := NewHeartbeat(HeartbeatConfig{\n\t\t\t\tContext: ctx,\n\t\t\t\tMode: tt.mode,\n\t\t\t\tComponent: \"test\",\n\t\t\t\tAnnouncer: announcer,\n\t\t\t\tCheckPeriod: time.Second,\n\t\t\t\tAnnouncePeriod: 60 * time.Second,\n\t\t\t\tKeepAlivePeriod: 10 * time.Second,\n\t\t\t\tServerTTL: 600 * time.Second,\n\t\t\t\tClock: clock,\n\t\t\t\tGetServerInfo: func() (types.Resource, error) {\n\t\t\t\t\tsrv := &types.ServerV2{\n\t\t\t\t\t\tKind: tt.kind,\n\t\t\t\t\t\tVersion: types.V2,\n\t\t\t\t\t\tMetadata: types.Metadata{\n\t\t\t\t\t\t\tNamespace: apidefaults.Namespace,\n\t\t\t\t\t\t\tName: \"1\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\tSpec: types.ServerSpecV2{\n\t\t\t\t\t\t\tAddr: \"127.0.0.1:1234\",\n\t\t\t\t\t\t\tHostname: \"2\",\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t\tsrv.SetExpiry(clock.Now().UTC().Add(apidefaults.ServerAnnounceTTL))\n\t\t\t\t\treturn srv, nil\n\t\t\t\t},\n\t\t\t})\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, hb.state, HeartbeatStateInit)\n\n\t\t\t// on the first run, heartbeat will move to announce state,\n\t\t\t// will call announce right away\n\t\t\terr = hb.fetch()\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, hb.state, HeartbeatStateAnnounce)\n\n\t\t\terr = hb.announce()\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, announcer.upsertCalls[hb.Mode], 1)\n\t\t\trequire.Equal(t, hb.state, HeartbeatStateAnnounceWait)\n\t\t\trequire.Equal(t, hb.nextAnnounce, clock.Now().UTC().Add(hb.AnnouncePeriod))\n\n\t\t\t// next call will not move to announce, because time is not up yet\n\t\t\terr = hb.fetchAndAnnounce()\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, hb.state, HeartbeatStateAnnounceWait)\n\n\t\t\t// advance time, and heartbeat will move to announce\n\t\t\tclock.Advance(hb.AnnouncePeriod + time.Second)\n\t\t\terr = hb.fetch()\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, hb.state, HeartbeatStateAnnounce)\n\t\t\terr = hb.announce()\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, announcer.upsertCalls[hb.Mode], 2)\n\t\t\trequire.Equal(t, hb.state, HeartbeatStateAnnounceWait)\n\t\t\trequire.Equal(t, hb.nextAnnounce, clock.Now().UTC().Add(hb.AnnouncePeriod))\n\n\t\t\t// in case of error, system will move to announce wait state,\n\t\t\t// with next attempt scheduled on the next keep alive period\n\t\t\tannouncer.err = trace.ConnectionProblem(nil, \"boom\")\n\t\t\tclock.Advance(hb.AnnouncePeriod + time.Second)\n\t\t\terr = hb.fetchAndAnnounce()\n\t\t\trequire.Error(t, err)\n\t\t\trequire.True(t, trace.IsConnectionProblem(err))\n\t\t\trequire.Equal(t, announcer.upsertCalls[hb.Mode], 3)\n\t\t\trequire.Equal(t, hb.state, HeartbeatStateAnnounceWait)\n\t\t\trequire.Equal(t, hb.nextAnnounce, clock.Now().UTC().Add(hb.KeepAlivePeriod))\n\n\t\t\t// once announce is successful, next announce is set on schedule\n\t\t\tannouncer.err = nil\n\t\t\tclock.Advance(hb.KeepAlivePeriod + time.Second)\n\t\t\terr = hb.fetchAndAnnounce()\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, announcer.upsertCalls[hb.Mode], 4)\n\t\t\trequire.Equal(t, hb.state, HeartbeatStateAnnounceWait)\n\t\t\trequire.Equal(t, hb.nextAnnounce, clock.Now().UTC().Add(hb.AnnouncePeriod))\n\t\t})\n\t}\n}", "func multicastAnnounce(addr string) error {\n\tif addr == \"\" {\n\t\taddr = guessMulticastAddress()\n\t}\n\n\tfullAddr := addr + \":\" + strconv.FormatInt(int64(GetMulticastPort()), 10)\n\n\tlogInfo(\"Announcing presence on\", fullAddr)\n\n\taddress, err := net.ResolveUDPAddr(\"udp\", fullAddr)\n\tif err != nil {\n\t\tlogError(err)\n\t\treturn err\n\t}\n\tladdr := &net.UDPAddr{\n\t\tIP: GetListenIP(),\n\t\tPort: 0,\n\t}\n\tfor {\n\t\tc, err := net.DialUDP(\"udp\", laddr, address)\n\t\tif err != nil {\n\t\t\tlogError(err)\n\t\t\treturn err\n\t\t}\n\t\t// Compose and send the multicast announcement\n\t\tmsgBytes := encodeMulticastAnnounceBytes()\n\t\t_, err = c.Write(msgBytes)\n\t\tif err != nil {\n\t\t\tlogError(err)\n\t\t\treturn err\n\t\t}\n\n\t\tlogfTrace(\"Sent announcement multicast from %v to %v\", laddr, fullAddr)\n\n\t\tif GetMulticastAnnounceIntervalSeconds() > 0 {\n\t\t\ttime.Sleep(time.Second * time.Duration(GetMulticastAnnounceIntervalSeconds()))\n\t\t} else {\n\t\t\treturn nil\n\t\t}\n\t}\n}", "func (p *Provider) AnnounceDealToIndexer(ctx context.Context, proposalCid cid.Cid) error {\n\tvar deal storagemarket.MinerDeal\n\tif err := p.deals.Get(proposalCid).Get(&deal); err != nil {\n\t\treturn xerrors.Errorf(\"failed getting deal %s: %w\", proposalCid, err)\n\t}\n\n\tif err := p.meshCreator.Connect(ctx); err != nil {\n\t\treturn fmt.Errorf(\"cannot publish index record as indexer host failed to connect to the full node: %w\", err)\n\t}\n\n\tannCid, err := p.indexProvider.NotifyPut(ctx, nil, deal.ProposalCid.Bytes(), p.metadataForDeal(deal))\n\tif err == nil {\n\t\tlog.Infow(\"deal announcement sent to index provider\", \"advertisementCid\", annCid, \"shard-key\", deal.Proposal.PieceCID,\n\t\t\t\"proposalCid\", deal.ProposalCid)\n\t}\n\treturn err\n}", "func AnnounceTournament(ctx AppContext) error {\n\tform := new(Announce)\n\tif err := ctx.Bind(form); err != nil {\n\t\treturn ctx.JSON(http.StatusBadRequest, Error(err))\n\t}\n\n\tservice := services.NewTournamentService(\n\t\tdb.NewTournamentRepo(ctx.Session),\n\t\tdb.NewPlayerRepo(ctx.Session),\n\t)\n\n\ttournament, err := service.Announce(form.TournamentID, int64(form.Deposit))\n\tif err != nil {\n\t\treturn ctx.JSON(http.StatusBadRequest, Error(err))\n\t}\n\n\treturn ctx.JSON(http.StatusOK, tournament)\n}", "func (p *Note) Announcement(mt, msg, buid string, out interface{}) error {\n\tctx, cancel := context.WithTimeout(context.Background(), p.Timeout)\n\tdefer cancel()\n\treturn p.client.Do(p.announce(ctx, mt, msg, buid, 1), out)\n}", "func (a *PeriodicalAnnouncer) Run() {\n\tdefer close(a.doneC)\n\ta.backoff.Reset()\n\n\ttimer := time.NewTimer(math.MaxInt64)\n\tdefer timer.Stop()\n\n\tresetTimer := func(interval time.Duration) {\n\t\ttimer.Reset(interval)\n\t\tif interval < 0 {\n\t\t\ta.nextAnnounce = time.Now()\n\t\t} else {\n\t\t\ta.nextAnnounce = time.Now().Add(interval)\n\t\t}\n\t}\n\n\tctx, cancel := context.WithCancel(context.Background())\n\n\t// BEP 0003: No completed is sent if the file was complete when started.\n\tselect {\n\tcase <-a.completedC:\n\t\ta.completedC = nil\n\tdefault:\n\t}\n\n\ta.doAnnounce(ctx, tracker.EventStarted, a.numWant)\n\tfor {\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\tif a.status == Contacting {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\ta.doAnnounce(ctx, tracker.EventNone, a.numWant)\n\t\tcase resp := <-a.responseC:\n\t\t\ta.status = Working\n\t\t\ta.seeders = int(resp.Seeders)\n\t\t\ta.leechers = int(resp.Leechers)\n\t\t\ta.warningMsg = resp.WarningMessage\n\t\t\tif a.warningMsg != \"\" {\n\t\t\t\ta.log.Debugln(\"announce warning:\", a.warningMsg)\n\t\t\t}\n\t\t\ta.interval = resp.Interval\n\t\t\tif resp.MinInterval > 0 {\n\t\t\t\ta.minInterval = resp.MinInterval\n\t\t\t}\n\t\t\ta.HasAnnounced = true\n\t\t\ta.lastError = nil\n\t\t\ta.backoff.Reset()\n\t\t\tinterval := a.getNextInterval()\n\t\t\tresetTimer(interval)\n\t\t\tgo func() {\n\t\t\t\tselect {\n\t\t\t\tcase a.newPeers <- resp.Peers:\n\t\t\t\tcase <-a.closeC:\n\t\t\t\t}\n\t\t\t}()\n\t\tcase err := <-a.errC:\n\t\t\ta.status = NotWorking\n\t\t\t// Give more friendly error to the user\n\t\t\ta.lastError = a.newAnnounceError(err)\n\t\t\tif a.lastError.Unknown {\n\t\t\t\ta.log.Errorln(\"announce error:\", a.lastError.ErrorWithType())\n\t\t\t} else {\n\t\t\t\ta.log.Debugln(\"announce error:\", a.lastError.Err.Error())\n\t\t\t}\n\t\t\tinterval := a.getNextIntervalFromError(a.lastError)\n\t\t\tresetTimer(interval)\n\t\tcase <-a.needMorePeersC:\n\t\t\tif a.status == Contacting || a.status == NotWorking {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tinterval := time.Until(a.lastAnnounce.Add(a.getNextInterval()))\n\t\t\tresetTimer(interval)\n\t\tcase <-a.completedC:\n\t\t\tif a.status == Contacting {\n\t\t\t\tcancel()\n\t\t\t\tctx, cancel = context.WithCancel(context.Background())\n\t\t\t}\n\t\t\ta.doAnnounce(ctx, tracker.EventCompleted, 0)\n\t\t\ta.completedC = nil // do not send more than one \"completed\" event\n\t\tcase req := <-a.statsCommandC:\n\t\t\treq.Response <- a.stats()\n\t\tcase <-a.closeC:\n\t\t\tcancel()\n\t\t\treturn\n\t\t}\n\t}\n}", "func (s *swiper) announce(ctx context.Context, topic, seed []byte) (<-chan bool, <-chan error) {\n\tannounces := make(chan bool)\n\terrs := make(chan error)\n\n\tgo func() {\n\t\tdefer close(announces)\n\t\tdefer close(errs)\n\t\tdefer func() { errs <- io.EOF }()\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\tperiodAnnounces, periodErrs := s.announceForPeriod(ctx, topic, seed, time.Now())\n\n\t\t\t\tselect {\n\t\t\t\tcase announce := <-periodAnnounces:\n\t\t\t\t\tannounces <- announce\n\t\t\t\t\tbreak\n\n\t\t\t\tcase err := <-periodErrs:\n\t\t\t\t\terrs <- err\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn announces, errs\n}", "func TestTrackerAnnouncer(t *testing.T) {\n\tcfg := testingConfig()\n\tcfg.DisableTrackers = false\n\tcfg.BaseDir = \".testdata/utopia\"\n\tcl, err := NewClient(cfg)\n\trequire.NoError(t, err)\n\tdt := &dummyTracker{\n\t\tmyAddr: localhost + \":8081\",\n\t\tt: t,\n\t\t//tracker will always respond with the client's ip/port pair\n\t\tpeer: tracker.Peer{\n\t\t\tID: cl.ID(),\n\t\t\tIP: []byte(getOutboundIP().String()),\n\t\t\tPort: uint16(cl.port),\n\t\t},\n\t}\n\tdt.serve()\n\ttr, err := cl.AddFromFile(helloWorldTorrentFile)\n\trequire.NoError(t, err)\n\ttr.mi.Announce = dt.addr()\n\trequire.NoError(t, tr.StartDataTransfer())\n\t//we want to announce multiple times so sleep for a bit\n\ttime.Sleep(4 * time.Second)\n\tdefer cl.Close()\n\t//Assert that we filtered duplicate ip/port pairs\n\t//We should have established only 2 connections (in essence 1 but actually, because we\n\t//have connected to ourselves there are 2 - one becaused we dialed in `client.connectToPeer` and that\n\t//triggered us to accept another one in `client.handleConn`.)\n\tassert.Equal(t, 2, len(tr.conns))\n}", "func (s *swiper) announceForPeriod(ctx context.Context, topic, seed []byte, t time.Time) (<-chan bool, <-chan error) {\n\tannounces := make(chan bool)\n\terrs := make(chan error)\n\n\troundedTime := roundTimePeriod(t, s.interval)\n\ttopicForTime := generateRendezvousPointForPeriod(topic, seed, roundedTime)\n\n\tnextStart := nextTimePeriod(roundedTime, s.interval)\n\n\tgo func() {\n\t\tctx, cancel := context.WithDeadline(ctx, nextStart)\n\t\tdefer cancel()\n\n\t\tdefer close(errs)\n\t\tdefer close(announces)\n\t\tdefer func() { errs <- io.EOF }()\n\n\t\tfor {\n\t\t\tduration, err := s.tinder.Advertise(ctx, string(topicForTime))\n\t\t\tif err != nil {\n\t\t\t\terrs <- err\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tannounces <- true\n\n\t\t\tif ctx.Err() != nil || time.Now().Add(duration).UnixNano() > nextStart.UnixNano() {\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn announces, errs\n}", "func (o *objStore) EmitEventAnnounce(event *EventAnnounce) {\n\tif event.Type == cluster.EventStopAnnounce {\n\t\treturn\n\t}\n\to.outboundPump <- event\n}", "func (t *Torrent) GetAnnounceURL() string {\n\tv := url.Values{}\n\tv.Add(\"peer_id\", t.PeerID)\n\tv.Add(\"port\", t.LocalPort[1:]) // TODO: This is a bad solution...\n\tv.Add(\"event\", t.Event)\n\tv.Add(\"info_hash\", t.MetaInfo.InfoHash)\n\t// These are int64s so we have to use FormatInt.\n\tdownloaded := strconv.FormatInt(t.Downloaded, 10)\n\tuploaded := strconv.FormatInt(t.Uploaded, 10)\n\tleft := strconv.FormatInt(t.Left, 10)\n\tv.Add(\"downloaded\", downloaded)\n\tv.Add(\"uploaded\", uploaded)\n\tv.Add(\"left\", left)\n\tv.Add(\"numwant\", strconv.Itoa(5))\n\tv.Add(\"compact\", \"1\") // We will always make compact requests.\n\n\treturn fmt.Sprintf(\"%s?%s\", t.AnnounceURL, v.Encode())\n}", "func (f *lightFetcher) announce(p *peer, head *announceData) {\n\tf.lock.Lock()\n\tdefer f.lock.Unlock()\n\tp.Log().Debug(\"Received new announcement\", \"number\", head.Number, \"hash\", head.Hash, \"reorg\", head.ReorgDepth)\n\n\tfp := f.peers[p]\n\tif fp == nil {\n\t\tp.Log().Debug(\"Announcement from unknown peer\")\n\t\treturn\n\t}\n\n\tif fp.lastAnnounced != nil && head.Td.Cmp(fp.lastAnnounced.td) <= 0 {\n\t\t// announced tds should be strictly monotonic\n\t\tp.Log().Debug(\"Received non-monotonic td\", \"current\", head.Td, \"previous\", fp.lastAnnounced.td)\n\t\tgo f.handler.removePeer(p.id)\n\t\treturn\n\t}\n\n\tn := fp.lastAnnounced\n\tfor i := uint64(0); i < head.ReorgDepth; i++ {\n\t\tif n == nil {\n\t\t\tbreak\n\t\t}\n\t\tn = n.parent\n\t}\n\t// n is now the reorg common ancestor, add a new branch of nodes\n\tif n != nil && (head.Number >= n.number+maxNodeCount || head.Number <= n.number) {\n\t\t// if announced head block height is lower or same as n or too far from it to add\n\t\t// intermediate nodes then discard previous announcement info and trigger a resync\n\t\tn = nil\n\t\tfp.nodeCnt = 0\n\t\tfp.nodeByHash = make(map[common.Hash]*fetcherTreeNode)\n\t}\n\t// check if the node count is too high to add new nodes, discard oldest ones if necessary\n\tif n != nil {\n\t\t// n is now the reorg common ancestor, add a new branch of nodes\n\t\t// check if the node count is too high to add new nodes\n\t\tlocked := false\n\t\tfor uint64(fp.nodeCnt)+head.Number-n.number > maxNodeCount && fp.root != nil {\n\t\t\tif !locked {\n\t\t\t\tf.chain.LockChain()\n\t\t\t\tdefer f.chain.UnlockChain()\n\t\t\t\tlocked = true\n\t\t\t}\n\t\t\t// if one of root's children is canonical, keep it, delete other branches and root itself\n\t\t\tvar newRoot *fetcherTreeNode\n\t\t\tfor i, nn := range fp.root.children {\n\t\t\t\tif rawdb.ReadCanonicalHash(f.handler.backend.chainDb, nn.number) == nn.hash {\n\t\t\t\t\tfp.root.children = append(fp.root.children[:i], fp.root.children[i+1:]...)\n\t\t\t\t\tnn.parent = nil\n\t\t\t\t\tnewRoot = nn\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tfp.deleteNode(fp.root)\n\t\t\tif n == fp.root {\n\t\t\t\tn = newRoot\n\t\t\t}\n\t\t\tfp.root = newRoot\n\t\t\tif newRoot == nil || !f.checkKnownNode(p, newRoot) {\n\t\t\t\tfp.bestConfirmed = nil\n\t\t\t\tfp.confirmedTd = nil\n\t\t\t}\n\n\t\t\tif n == nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif n != nil {\n\t\t\tfor n.number < head.Number {\n\t\t\t\tnn := &fetcherTreeNode{number: n.number + 1, parent: n}\n\t\t\t\tn.children = append(n.children, nn)\n\t\t\t\tn = nn\n\t\t\t\tfp.nodeCnt++\n\t\t\t}\n\t\t\tn.hash = head.Hash\n\t\t\tn.td = head.Td\n\t\t\tfp.nodeByHash[n.hash] = n\n\t\t}\n\t}\n\n\tif n == nil {\n\t\t// could not find reorg common ancestor or had to delete entire tree, a new root and a resync is needed\n\t\tif fp.root != nil {\n\t\t\tfp.deleteNode(fp.root)\n\t\t}\n\t\tn = &fetcherTreeNode{hash: head.Hash, number: head.Number, td: head.Td}\n\t\tfp.root = n\n\t\tfp.nodeCnt++\n\t\tfp.nodeByHash[n.hash] = n\n\t\tfp.bestConfirmed = nil\n\t\tfp.confirmedTd = nil\n\t}\n\n\tf.checkKnownNode(p, n)\n\tp.lock.Lock()\n\tp.headInfo = head\n\tfp.lastAnnounced = n\n\tp.lock.Unlock()\n\tf.checkUpdateStats(p, nil)\n\tif !f.requestTriggered {\n\t\tf.requestTriggered = true\n\t\tf.requestTrigger <- struct{}{}\n\t}\n}", "func (herald *Herald) AnnounceSamples() error {\n\therald.Lock()\n\tdefer herald.Unlock()\n\tif herald.announcementQueue.Len() == 0 {\n\t\treturn fmt.Errorf(\"announcement queue is empty\")\n\t}\n\n\t// iterate once over the queue and process all the runs first\n\tfor request := herald.announcementQueue.Front(); request != nil; request = request.Next() {\n\t\tswitch v := request.Value.(type) {\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unexpected type in queue: %T\", v)\n\t\tcase *records.Sample:\n\t\t\tcontinue\n\t\tcase *records.Run:\n\t\t\t// make the service requests\n\t\t\tfor tag, complete := range v.Metadata.GetTags() {\n\n\t\t\t\t// check it's not been completed already\n\t\t\t\tif complete {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t// get the service and submit the request\n\t\t\t\tservice := services.ServiceRegister[tag]\n\t\t\t\tif service.CheckAccess() == false {\n\t\t\t\t\treturn fmt.Errorf(\"%v: %v\", ErrServiceOffline, tag)\n\t\t\t\t}\n\t\t\t\tif err := service.SendRequest(v); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// set the status to announced\n\t\t\tv.Metadata.SetStatus(records.Status_announced)\n\n\t\t\t// dequeue the sample\n\t\t\tv.Metadata.AddComment(\"run announced.\")\n\t\t\tv.Metadata.SetStatus(records.Status_announced)\n\t\t\tif err := herald.updateRecord(v); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\therald.announcementQueue.Remove(request)\n\t\t}\n\t}\n\n\t// process the remaining queue (should just be samples now)\n\tfor request := herald.announcementQueue.Front(); request != nil; request = request.Next() {\n\n\t\t// grab the sample that is first in the queue\n\t\tsample := request.Value.(*records.Sample)\n\n\t\t// TODO:\n\t\t// evalute the sample\n\t\t// update fields and propogate to linked data\n\t\t// decide if it should be dequeued\n\n\t\t// make the service requests\n\t\tfor tag, complete := range sample.Metadata.GetTags() {\n\n\t\t\t// check it's not been completed already\n\t\t\tif complete {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// get the service and submit the request\n\t\t\tservice := services.ServiceRegister[tag]\n\t\t\tif service.CheckAccess() == false {\n\t\t\t\treturn fmt.Errorf(\"%v: %v\", ErrServiceOffline, tag)\n\t\t\t}\n\t\t\tif err := service.SendRequest(sample); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\t// update the status of the sample and dequeue it\n\t\tsample.Metadata.AddComment(\"sample announced.\")\n\t\tsample.Metadata.SetStatus(records.Status_announced)\n\t\tif err := herald.updateRecord(sample); err != nil {\n\t\t\treturn err\n\t\t}\n\t\therald.announcementQueue.Remove(request)\n\t}\n\n\tif herald.announcementQueue.Len() != 0 {\n\t\treturn fmt.Errorf(\"announcements sent but queue still contains %d requests\", herald.announcementQueue.Len())\n\t}\n\treturn nil\n}", "func AnnounceServeAndAllocate(etcd EtcdContext, srv ServerContext, state *allocator.State, spec memberSpec) {\n\tMust(spec.Validate(), \"member specification validation error\")\n\n\tvar ann = allocator.Announce(etcd.Etcd, state.LocalKey, spec.MarshalString(), etcd.Session.Lease())\n\tMust(state.KS.Load(context.Background(), etcd.Etcd, ann.Revision), \"failed to load KeySpace\")\n\n\t// Register a signal handler which zeros our advertised limit in Etcd.\n\t// Upon seeing this, Allocator will work to discharge all of our assigned\n\t// items, and Allocate will exit gracefully when none remain.\n\tvar signalCh = make(chan os.Signal, 1)\n\tsignal.Notify(signalCh, syscall.SIGTERM, syscall.SIGINT)\n\n\tgo func() {\n\t\tvar sig = <-signalCh\n\t\tlog.WithField(\"signal\", sig).Info(\"caught signal\")\n\n\t\tspec.ZeroLimit()\n\t\tMust(ann.Update(spec.MarshalString()), \"failed to update member announcement\", \"key\", state.LocalKey)\n\t}()\n\n\t// Now that the KeySpace has been loaded, we can begin serving requests.\n\tgo srv.Serve()\n\tgo func() { Must(state.KS.Watch(context.Background(), etcd.Etcd), \"keyspace Watch failed\") }()\n\n\tMust(allocator.Allocate(allocator.AllocateArgs{\n\t\tContext: context.Background(),\n\t\tEtcd: etcd.Etcd,\n\t\tState: state,\n\t}), \"Allocate failed\")\n\n\t// Close our session to remove our member key. If we were leader,\n\t// this notifies peers that we are no longer allocating.\n\tetcd.Session.Close()\n\tsrv.GracefulStop()\n}", "func (d *Domain) Announce(service string, handler func([]byte, uint64) ([]byte, uint64)) error {\n\tlis, err := net.Listen(\"tcp\", \":8000\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//\n\t// TODO: Optimize with batching like the client side, with two goroutines\n\t// The define callback can do whatever the user wants, to send the\n\t// request to a worker pool through a channel o handle it directly on the\n\t// goroutine that receive the messages.\n\t//\n\n\tgo func() {\n\t\tfor {\n\t\t\tnetconn, err := lis.Accept()\n\t\t\tif err != nil {\n\t\t\t\tlog.Debug(err)\n\t\t\t}\n\t\t\tlog.Debug(\"Connection accepted from\", netconn.RemoteAddr())\n\n\t\t\tconn := newConn(netconn)\n\t\t\tgo func() {\n\t\t\t\treqs := make([]*Request, 0, maxBatchLen)\n\t\t\t\tfor {\n\t\t\t\t\treqs = reqs[:0:cap(reqs)]\n\t\t\t\t\tfor i := 0; i < maxBatchLen; i++ {\n\t\t\t\t\t\tpayld, seq, err := conn.recv()\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tlog.Debug(err)\n\t\t\t\t\t\t\tExit()\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlog.Debug(\"RECV(\", seq, \") \", string(payld))\n\n\t\t\t\t\t\tpayld, seq = handler(payld, seq)\n\n\t\t\t\t\t\treq := newRequest(payld, seq)\n\n\t\t\t\t\t\treqs = append(reqs, req)\n\t\t\t\t\t}\n\n\t\t\t\t\tif err := conn.sendBatch(reqs); err != nil {\n\t\t\t\t\t\tlog.Debug(err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}()\n\t\t}\n\t}()\n\n\treturn nil\n}", "func (s *Server) sendJetStreamAPIAuditAdvisory(ci *ClientInfo, acc *Account, subject, request, response string) {\n\ts.publishAdvisory(acc, JSAuditAdvisory, JSAPIAudit{\n\t\tTypedEvent: TypedEvent{\n\t\t\tType: JSAPIAuditType,\n\t\t\tID: nuid.Next(),\n\t\t\tTime: time.Now().UTC(),\n\t\t},\n\t\tServer: s.Name(),\n\t\tClient: ci,\n\t\tSubject: subject,\n\t\tRequest: request,\n\t\tResponse: response,\n\t\tDomain: s.getOpts().JetStreamDomain,\n\t})\n}", "func (s *PeerStore) AnnouncePeers(infoHash bittorrent.InfoHash, seeder bool, numWant int, announcingPeer bittorrent.Peer) ([]bittorrent.Peer, error) {\n\tselect {\n\tcase <-s.closed:\n\t\tpanic(\"attempted to interact with closed store\")\n\tdefault:\n\t}\n\n\tif announcingPeer.IP.AddressFamily != bittorrent.IPv4 && announcingPeer.IP.AddressFamily != bittorrent.IPv6 {\n\t\treturn nil, ErrInvalidIP\n\t}\n\n\tih := infohash(infoHash)\n\ts0, s1 := deriveEntropyFromRequest(infoHash, announcingPeer)\n\n\tp := &peer{}\n\tp.setPort(announcingPeer.Port)\n\tp.setIP(announcingPeer.IP.To16())\n\treturn s.announceSingleStack(ih, seeder, numWant, p, announcingPeer.IP.AddressFamily, s0, s1)\n}", "func (c *ChannelAnnouncement) Encode(w io.Writer, pver uint32) error {\n\terr := writeElements(w,\n\t\tc.FirstNodeSig,\n\t\tc.SecondNodeSig,\n\t\tc.ChannelID,\n\t\tc.FirstBitcoinSig,\n\t\tc.SecondBitcoinSig,\n\t\tc.FirstNodeID,\n\t\tc.SecondNodeID,\n\t\tc.FirstBitcoinKey,\n\t\tc.SecondBitcoinKey,\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (mr *MockDHTKeeperMockRecorder) AddToAnnounceList(key, repo, objType, announceTime interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"AddToAnnounceList\", reflect.TypeOf((*MockDHTKeeper)(nil).AddToAnnounceList), key, repo, objType, announceTime)\n}", "func (consensus *Consensus) constructAnnounceMessage() []byte {\n\tmessage := &msg_pb.Message{\n\t\tServiceType: msg_pb.ServiceType_CONSENSUS,\n\t\tType: msg_pb.MessageType_ANNOUNCE,\n\t\tRequest: &msg_pb.Message_Consensus{\n\t\t\tConsensus: &msg_pb.ConsensusRequest{},\n\t\t},\n\t}\n\tconsensusMsg := message.GetConsensus()\n\tconsensus.populateMessageFields(consensusMsg)\n\tconsensusMsg.Payload = consensus.blockHeader\n\n\tmarshaledMessage, err := consensus.signAndMarshalConsensusMessage(message)\n\tif err != nil {\n\t\tutils.Logger().Error().Err(err).Msg(\"Failed to sign and marshal the Announce message\")\n\t}\n\treturn proto.ConstructConsensusMessage(marshaledMessage)\n}", "func (a *Client) StartCallAnnouncement(params *StartCallAnnouncementParams, authInfo runtime.ClientAuthInfoWriter) (*StartCallAnnouncementNoContent, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewStartCallAnnouncementParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"startCallAnnouncement\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/calls/{callId}/announcements\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &StartCallAnnouncementReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*StartCallAnnouncementNoContent)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for startCallAnnouncement: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func (a *Add) Tracker(announce string, addresses []string, dryRun bool) error {\n\tvar tracker *Tracker\n\tvar probe *Probe\n\tvar reacheableAddresses []string\n\tvar err error\n\n\tlog.Printf(\"Adding Tracker '%s' with addresses '[%s]'\", announce, strings.Join(addresses, \", \"))\n\n\tif tracker, err = NewTracker(announce); err != nil {\n\t\treturn err\n\t}\n\n\tprobe = NewProbe(tracker, a.config.Probe.Timeout)\n\n\tif len(addresses) == 0 {\n\t\tif err = probe.LookupAddresses(); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tprobe.SetAddresses(addresses)\n\t}\n\n\tif reacheableAddresses, err = probe.ReachableAddresses(); err != nil {\n\t\treturn err\n\t}\n\n\tif len(reacheableAddresses) == 0 {\n\t\tlog.Printf(\"[WARN] No reachable addresses found!\")\n\t\ttracker.Addresses = []string{\"0.0.0.0\"}\n\t\ttracker.Status = 99\n\t} else {\n\t\tlog.Printf(\"Reachable addresses: '[%s]'\", strings.Join(reacheableAddresses, \", \"))\n\t\ttracker.Addresses = reacheableAddresses\n\t\ttracker.Status = 3\n\t}\n\n\treturn a.storage.Write([]*Tracker{tracker})\n}", "func (h *Handler) Alive(w http.ResponseWriter, r *http.Request) {\n\th.srv.Writer().Write(w, r, &healthStatus{\n\t\tStatus: \"ok\",\n\t})\n}", "func (ntmgr *NotifyMgr) AnnounceNewTransactions(newTxs []*types.TxDesc, filters []peer.ID) {\n\tif len(newTxs) <= 0 {\n\t\treturn\n\t}\n\tfor _, tx := range newTxs {\n\t\tlog.Trace(fmt.Sprintf(\"Announce new transaction :hash=%s height=%d add=%s\", tx.Tx.Hash().String(), tx.Height, tx.Added.String()))\n\t}\n\t// reply to p2p\n\tfor _, tx := range newTxs {\n\t\tntmgr.RelayInventory(tx, filters)\n\t}\n\n\tif ntmgr.RpcServer != nil {\n\t\tntmgr.RpcServer.NotifyNewTransactions(newTxs)\n\t}\n}", "func (r *Redis) AnnounceDeath(node string) error {\n\treturn r.c.Publish(string(keys.NodeDeaths), node).Err()\n}", "func (s *Server) announceText(service *ServiceEntry) {\n\tresp := new(dns.Msg)\n\tresp.MsgHdr.Response = true\n\n\ttxt := &dns.TXT{\n\t\tHdr: dns.RR_Header{\n\t\t\tName: service.ServiceInstanceName(),\n\t\t\tRrtype: dns.TypeTXT,\n\t\t\tClass: dns.ClassINET | 1<<15,\n\t\t\tTtl: s.ttl,\n\t\t},\n\t\tTxt: service.Text,\n\t}\n\n\tresp.Answer = []dns.RR{txt}\n\ts.multicastResponse(resp)\n}", "func (buf *Buffer) ACK(leased *Batch) {\n\tbuf.removeLease(leased)\n}", "func (o *objStore) ReceiveEventAnnounce(event *EventAnnounce) {\n\tif event.Type == cluster.EventStopAnnounce {\n\t\treturn\n\t}\n\to.inboundPump <- event\n}", "func New(\n\tprotocolID string,\n\tbroadcastChannel net.BroadcastChannel,\n\tmembershipValidator *group.MembershipValidator,\n) *Announcer {\n\tbroadcastChannel.SetUnmarshaler(func() net.TaggedUnmarshaler {\n\t\treturn &announcementMessage{}\n\t})\n\n\treturn &Announcer{\n\t\tprotocolID: protocolID,\n\t\tbroadcastChannel: broadcastChannel,\n\t\tmembershipValidator: membershipValidator,\n\t}\n}", "func (mr *MockWatcherMockRecorder) AnnounceInterval() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"AnnounceInterval\", reflect.TypeOf((*MockWatcher)(nil).AnnounceInterval))\n}", "func (p2p *P2P) Advertise(service string) {\n\t// Advertise the availabilty of the service on this node\n\tttl, err := p2p.Discovery.Advertise(p2p.Ctx, service)\n\tif err != nil {\n\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Fatalln(\"Failed to Announce Service CID!\")\n\t}\n\t// Debug log\n\tlogrus.Debugln(\"Advertised:\", service)\n\tlogrus.Debugln(\"TTL:\", ttl)\n}", "func (ann *announcer) Run(args interface{}, shutdown <-chan struct{}) {\n\n\tlog := ann.log\n\n\tlog.Info(\"starting…\")\n\n\tdelay := time.After(announceInitial)\nloop:\n\tfor {\n\t\tlog.Info(\"waiting…\")\n\t\tselect {\n\t\tcase <-shutdown:\n\t\t\tbreak loop\n\t\tcase <-delay:\n\t\t\tdelay = time.After(announceInterval)\n\t\t\tann.process()\n\t\t}\n\t}\n}", "func (cli *OpsGenieAlertV2Client) Acknowledge(req alertsv2.AcknowledgeRequest) (*AsyncRequestResponse, error) {\n\treturn cli.sendAsyncPostRequest(&req)\n}", "func (t *BeatTracker) Do(input *SimpleBuffer) {\n\tif t.o == nil {\n\t\treturn\n\t}\n\tC.aubio_beattracking_do(t.o, input.vec, t.buf.vec)\n}", "func (s *BaseSpeaker) DecideAnnouncement(ruleMatrix rules.RuleMatrix, result bool) shared.SpeakerReturnContent {\n\treturn shared.SpeakerReturnContent{\n\t\tContentType: shared.SpeakerAnnouncement,\n\t\tRuleMatrix: ruleMatrix,\n\t\tVotingResult: result,\n\t\tActionTaken: true,\n\t}\n}", "func NewPeriodicalAnnouncer(trk tracker.Tracker, numWant int, minInterval time.Duration, getTorrent func() tracker.Torrent, completedC chan struct{}, newPeers chan []*net.TCPAddr, l logger.Logger) *PeriodicalAnnouncer {\n\treturn &PeriodicalAnnouncer{\n\t\tTracker: trk,\n\t\tstatus: NotContactedYet,\n\t\tstatsCommandC: make(chan statsRequest),\n\t\tnumWant: numWant,\n\t\tminInterval: minInterval,\n\t\tlog: l,\n\t\tcompletedC: completedC,\n\t\tnewPeers: newPeers,\n\t\tgetTorrent: getTorrent,\n\t\tneedMorePeersC: make(chan struct{}, 1),\n\t\tresponseC: make(chan *tracker.AnnounceResponse),\n\t\terrC: make(chan error),\n\t\tcloseC: make(chan struct{}),\n\t\tdoneC: make(chan struct{}),\n\t\tbackoff: &backoff.ExponentialBackOff{\n\t\t\tInitialInterval: 5 * time.Second,\n\t\t\tRandomizationFactor: 0.5,\n\t\t\tMultiplier: 2,\n\t\t\tMaxInterval: 30 * time.Minute,\n\t\t\tMaxElapsedTime: 0, // never stop\n\t\t\tClock: backoff.SystemClock,\n\t\t},\n\t}\n}", "func (c *localClient) announcementPkt(instanceID int64, msg []byte) ([]byte, bool) {\n\taddrs := c.addrList.AllAddresses()\n\tif len(addrs) == 0 {\n\t\t// Nothing to announce\n\t\treturn msg, false\n\t}\n\n\tif cap(msg) >= 4 {\n\t\tmsg = msg[:4]\n\t} else {\n\t\tmsg = make([]byte, 4)\n\t}\n\tbinary.BigEndian.PutUint32(msg, Magic)\n\n\tpkt := Announce{\n\t\tID: c.myID,\n\t\tAddresses: addrs,\n\t\tInstanceID: instanceID,\n\t}\n\tbs, _ := pkt.Marshal()\n\tmsg = append(msg, bs...)\n\n\treturn msg, true\n}", "func (r *Relay) HostAnnouncement(pubkey hostdb.HostPublicKey) ([]byte, bool) {\n\tr.mu.Lock()\n\tann, ok := r.hosts[pubkey]\n\tr.mu.Unlock()\n\treturn ann, ok\n}", "func (m MarkerID) Acknowledge(o *Operation, gid GoogleID) error {\n\tvar ns sql.NullString\n\terr := db.QueryRow(\"SELECT gid FROM marker WHERE ID = ? and opID = ?\", m, o.ID).Scan(&ns)\n\tif err != nil && err != sql.ErrNoRows {\n\t\tLog.Notice(err)\n\t\treturn err\n\t}\n\tif err != nil && err == sql.ErrNoRows {\n\t\terr = fmt.Errorf(\"no such marker\")\n\t\tLog.Error(err)\n\t\treturn err\n\t}\n\tif !ns.Valid {\n\t\terr = fmt.Errorf(\"marker not assigned\")\n\t\tLog.Error(err)\n\t\treturn err\n\t}\n\tmarkerGid := GoogleID(ns.String)\n\tif gid != markerGid {\n\t\terr = fmt.Errorf(\"marker assigned to someone else\")\n\t\tLog.Error(err)\n\t\treturn err\n\t}\n\t_, err = db.Exec(\"UPDATE marker SET state = ? WHERE ID = ? AND opID = ?\", \"acknowledged\", m, o.ID)\n\tif err != nil {\n\t\tLog.Error(err)\n\t\treturn err\n\t}\n\tif err = o.Touch(); err != nil {\n\t\tLog.Error(err)\n\t}\n\n\to.firebaseMarkerStatus(m, \"acknowledged\")\n\treturn nil\n}", "func (m *MysqlDriver) AddAnnouncement(announcement *model.Announcement) error {\n\tvar (\n\t\terr error\n\t\taffected int64\n\t)\n\tif announcement.ClassId == 0 {\n\t\taffected, err = m.conn.Omit(\"class_id\").Insert(announcement)\n\t} else {\n\t\taffected, err = m.conn.Insert(announcement)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tif affected == 0 {\n\t\treturn ErrNoRowsAffected\n\t}\n\treturn nil\n}", "func NewAnnouncer(relay *Relay, wg sync.WaitGroup) (Announcer, error) {\n\tbusConfig := relay.Config.Cog\n\tannouncer := &relayAnnouncer{\n\t\tid: relay.Config.ID,\n\t\treceiptTopic: fmt.Sprintf(\"bot/relays/%s/announcer\", relay.Config.ID),\n\t\trelay: relay,\n\t\toptions: mqtt.NewClientOptions(),\n\t\tstate: relayAnnouncerStoppedState,\n\t\tcontrol: make(chan relayAnnouncerCommand, 2),\n\t\tcoordinator: wg,\n\t\tannouncementPending: false,\n\t}\n\tannouncer.options.SetAutoReconnect(false)\n\tannouncer.options.SetKeepAlive(time.Duration(60) * time.Second)\n\tannouncer.options.SetPingTimeout(time.Duration(15) * time.Second)\n\tannouncer.options.SetCleanSession(true)\n\tannouncer.options.SetClientID(fmt.Sprintf(\"%s-a\", announcer.id))\n\tannouncer.options.SetUsername(announcer.id)\n\tannouncer.options.SetPassword(busConfig.Token)\n\tannouncer.options.AddBroker(busConfig.URL())\n\tif busConfig.SSLEnabled == true {\n\t\tannouncer.options.TLSConfig = tls.Config{\n\t\t\tServerName: busConfig.Host,\n\t\t\tSessionTicketsDisabled: true,\n\t\t\tInsecureSkipVerify: false,\n\t\t}\n\t}\n\n\treturn announcer, nil\n}", "func NewWeaviatePeersAnnounceOK() *WeaviatePeersAnnounceOK {\n\treturn &WeaviatePeersAnnounceOK{}\n}", "func (s *speaker) DecideAnnouncement(ruleMatrix rules.RuleMatrix, result bool) shared.SpeakerReturnContent {\n\t//(there are more important things to do) or (there is no result to announce)\n\tif s.getSpeakerBudget() < s.getHigherPriorityActionsCost(\"AnnounceVotingResult\") || ruleMatrix.RuleMatrixIsEmpty() {\n\t\treturn shared.SpeakerReturnContent{\n\t\t\tActionTaken: false,\n\t\t}\n\t}\n\treturn shared.SpeakerReturnContent{\n\t\tContentType: shared.SpeakerAnnouncement,\n\t\tRuleMatrix: ruleMatrix,\n\t\tVotingResult: result,\n\t\tActionTaken: true,\n\t}\n}", "func (mr *MockDHTKeeperMockRecorder) IterateAnnounceList(it interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"IterateAnnounceList\", reflect.TypeOf((*MockDHTKeeper)(nil).IterateAnnounceList), it)\n}", "func (ec *executionContext) _Announcement(ctx context.Context, sel []query.Selection, obj *model.Announcement) graphql.Marshaler {\n\tfields := graphql.CollectFields(ec.Doc, sel, announcementImplementors, ec.Variables)\n\n\tout := graphql.NewOrderedMap(len(fields))\n\tfor i, field := range fields {\n\t\tout.Keys[i] = field.Alias\n\n\t\tswitch field.Name {\n\t\tcase \"__typename\":\n\t\t\tout.Values[i] = graphql.MarshalString(\"Announcement\")\n\t\tcase \"id\":\n\t\t\tout.Values[i] = ec._Announcement_id(ctx, field, obj)\n\t\tcase \"user\":\n\t\t\tout.Values[i] = ec._Announcement_user(ctx, field, obj)\n\t\tcase \"card\":\n\t\t\tout.Values[i] = ec._Announcement_card(ctx, field, obj)\n\t\tcase \"message\":\n\t\t\tout.Values[i] = ec._Announcement_message(ctx, field, obj)\n\t\tcase \"createdAt\":\n\t\t\tout.Values[i] = ec._Announcement_createdAt(ctx, field, obj)\n\t\tcase \"updatedAt\":\n\t\t\tout.Values[i] = ec._Announcement_updatedAt(ctx, field, obj)\n\t\tdefault:\n\t\t\tpanic(\"unknown field \" + strconv.Quote(field.Name))\n\t\t}\n\t}\n\n\treturn out\n}", "func (s *EventsService) Acknowledge(event *Event) (*EventResponse, error) {\n\treturn s.postEvent(event, EventTypeAcknowledge)\n}", "func (bft *ProtocolBFTCoSi) handleAnnouncement(msg announceChan) error {\n\tann := msg.Announce\n\tif bft.isClosing() {\n\t\tlog.Lvl3(\"Closing\")\n\t\treturn nil\n\t}\n\tif bft.IsLeaf() {\n\t\tbft.Timeout = ann.Timeout\n\t\treturn bft.startCommitment(ann.TYPE)\n\t}\n\treturn bft.sendToChildren(&ann)\n}", "func Alive(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"alive\")\n}", "func (b *Builder) PublishActivationTx(ctx context.Context) error {\n\tb.discardChallengeIfStale()\n\tif b.challenge != nil {\n\t\tb.log.With().Info(\"using existing atx challenge\", b.currentEpoch())\n\t} else {\n\t\tb.log.With().Info(\"building new atx challenge\", b.currentEpoch())\n\t\terr := b.buildNipstChallenge(ctx)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to build new atx challenge: %w\", err)\n\t\t}\n\t}\n\n\tif b.pendingATX == nil {\n\t\tvar err error\n\t\tb.pendingATX, err = b.createAtx(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tatx := b.pendingATX\n\tatxReceived := b.db.AwaitAtx(atx.ID())\n\tdefer b.db.UnsubscribeAtx(atx.ID())\n\tsize, err := b.signAndBroadcast(ctx, atx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tb.log.Event().Info(\"atx published\", atx.Fields(size)...)\n\tevents.ReportAtxCreated(true, uint64(b.currentEpoch()), atx.ShortString())\n\n\tselect {\n\tcase <-atxReceived:\n\t\tb.log.With().Info(\"received atx in db\", atx.ID())\n\tcase <-b.layerClock.AwaitLayer((atx.TargetEpoch() + 1).FirstLayer()):\n\t\tsyncedCh := make(chan struct{})\n\t\tb.syncer.RegisterChForSynced(ctx, syncedCh)\n\t\tselect {\n\t\tcase <-atxReceived:\n\t\t\tb.log.With().Info(\"received atx in db (in the last moment)\", atx.ID())\n\t\tcase <-syncedCh: // ensure we've seen all blocks before concluding that the ATX was lost\n\t\t\tb.discardChallenge()\n\t\t\treturn fmt.Errorf(\"%w: target epoch has passed\", ErrATXChallengeExpired)\n\t\tcase <-ctx.Done():\n\t\t\treturn ErrStopRequested\n\t\t}\n\tcase <-ctx.Done():\n\t\treturn ErrStopRequested\n\t}\n\tb.discardChallenge()\n\treturn nil\n}", "func (p *protocol) Acknowledge(nonce *string, sequence uint32) error {\n\tlog.Debugf(\"[R %s > %s] Sending acknowledgement for nonce %x with sequence %d\", p.conn.LocalAddr().String(), p.conn.RemoteAddr().String(), *nonce, sequence)\n\treturn p.conn.SendMessage(&protocolACKN{nonce: nonce, sequence: sequence})\n}", "func (o *InlineResponse20014Projects) SetShowAnnouncement(v bool) {\n\to.ShowAnnouncement = &v\n}", "func notify(ctx context.Context, report string) error {\n\t_, err := sendRequest(ctx, \"POST\", notifyAddr, report)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (p *DiscoveryProtocol) onNotify() {\n\tlog.Println(\" pending requests: \", p.pendingReq)\n\tfor req := range p.pendingReq {\n\t\tif !p.requestExpired(req) {\n\t\t\tlog.Println(\"Request not expired, trying to send response\")\n\t\t\tif p.createSendResponse(req) {\n\t\t\t\tdelete(p.pendingReq, req)\n\t\t\t}\n\t\t}\n\t}\n}", "func Notify(err interface{}, req *http.Request) error {\n\tif Airbrake != nil {\n\t\treturn Airbrake.Notify(err, req)\n\t}\n\tlog.Printf(\"[AIRBRAKE] %v\", err)\n\treturn nil\n}", "func (coord *Coordinator) AcknowledgePacket(\n\tsource, counterparty *TestChain,\n\tcounterpartyClient string,\n\tpacket packettypes.Packet, ack []byte,\n) error {\n\t// get proof of acknowledgement on counterparty\n\tpacketKey := host.PacketAcknowledgementKey(packet.GetSourceChain(), packet.GetDestChain(), packet.GetSequence())\n\tproof, proofHeight := counterparty.QueryProof(packetKey)\n\n\t// Increment time and commit block so that 5 second delay period passes between send and receive\n\tcoord.IncrementTime()\n\tcoord.CommitBlock(source, counterparty)\n\n\tackMsg := packettypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, source.SenderAccount.GetAddress())\n\treturn coord.SendMsgs(source, counterparty, counterpartyClient, []sdk.Msg{ackMsg})\n}", "func (o *InlineResponse20014Projects) SetAnnouncement(v string) {\n\to.Announcement = &v\n}", "func (q *Queue) ACK(n uint) error {\n\treturn q.getAcker().handle(n)\n}", "func (as *ASService) OnAddrRequest(ctx context.Context, req *requests.AddrRequest) {\n\tif r := as.sys.Cache().AddrSearch(req.Address); r != nil {\n\t\tas.Graph.InsertInfrastructure(r.ASN, r.Description, r.Address, r.Prefix, r.Source, r.Tag, as.uuid)\n\t\treturn\n\t}\n\n\tfor _, src := range as.sys.DataSources() {\n\t\tsrc.ASNRequest(ctx, &requests.ASNRequest{Address: req.Address})\n\t}\n\n\tfor i := 0; i < 30; i++ {\n\t\tif as.sys.Cache().AddrSearch(req.Address) != nil {\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(time.Second)\n\t}\n\n\tif r := as.sys.Cache().AddrSearch(req.Address); r != nil && as.Graph != nil && as.uuid != \"\" {\n\t\tgo as.Graph.InsertInfrastructure(r.ASN, r.Description, r.Address, r.Prefix, r.Source, r.Tag, as.uuid)\n\t}\n}", "func (n *Node) AnnounceSignerPresence(\n\tctx context.Context,\n\toperatorPublicKey *operator.PublicKey,\n\tkeepAddress common.Address,\n\tkeepMembersAddresses []common.Address,\n) ([]tss.MemberID, error) {\n\tbroadcastChannel, err := n.networkProvider.BroadcastChannelFor(keepAddress.Hex())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to initialize broadcast channel: [%v]\", err)\n\t}\n\n\ttss.RegisterUnmarshalers(broadcastChannel)\n\n\tif err := broadcastChannel.SetFilter(\n\t\tcreateAddressFilter(keepMembersAddresses),\n\t); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to set broadcast channel filter: [%v]\", err)\n\t}\n\n\t// TODO: Use generic type for representing address in node.go instead of\n\t// common.Address from go-ethereum. The current implementation is not\n\t// host-chain implementation agnostic.\n\t// To do not propagate ethereum-specific types any further, we convert\n\t// addresses to strings before passing them to AnnounceProtocol.\n\tkeepAddressString := keepAddress.Hex()\n\tkeepMembersAddressesStrings := make([]string, len(keepMembersAddresses))\n\tfor i, address := range keepMembersAddresses {\n\t\tkeepMembersAddressesStrings[i] = address.Hex()\n\t}\n\treturn tss.AnnounceProtocol(\n\t\tctx,\n\t\toperatorPublicKey,\n\t\tkeepAddressString,\n\t\tkeepMembersAddressesStrings,\n\t\tbroadcastChannel,\n\t\tn.ethereumChain.Signing().PublicKeyToAddress,\n\t)\n}", "func (s *Server) Article(ctx context.Context, in *pb.ArticleRequest) (*pb.ArticleReply, error) {\n\ta, err := s.db.Get(ctx, in.Id)\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Internal, fmt.Sprintf(\"failed to get article: %v\", err))\n\t}\n\treturn &pb.ArticleReply{Article: a}, nil\n}", "func (auo *AnnouncementUpdateOne) Save(ctx context.Context) (*Announcement, error) {\n\tif v, ok := auo.mutation.Title(); ok {\n\t\tif err := announcement.TitleValidator(v); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"ent: validator failed for field \\\"title\\\": %v\", err)\n\t\t}\n\t}\n\tif v, ok := auo.mutation.Description(); ok {\n\t\tif err := announcement.DescriptionValidator(v); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"ent: validator failed for field \\\"description\\\": %v\", err)\n\t\t}\n\t}\n\tif v, ok := auo.mutation.Time(); ok {\n\t\tif err := announcement.TimeValidator(v); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"ent: validator failed for field \\\"time\\\": %v\", err)\n\t\t}\n\t}\n\n\tvar (\n\t\terr error\n\t\tnode *Announcement\n\t)\n\tif len(auo.hooks) == 0 {\n\t\tnode, err = auo.sqlSave(ctx)\n\t} else {\n\t\tvar mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {\n\t\t\tmutation, ok := m.(*AnnouncementMutation)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected mutation type %T\", m)\n\t\t\t}\n\t\t\tauo.mutation = mutation\n\t\t\tnode, err = auo.sqlSave(ctx)\n\t\t\treturn node, err\n\t\t})\n\t\tfor i := len(auo.hooks) - 1; i >= 0; i-- {\n\t\t\tmut = auo.hooks[i](mut)\n\t\t}\n\t\tif _, err := mut.Mutate(ctx, auo.mutation); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn node, err\n}", "func (cli *FakeDatabaseClient) BounceListener(ctx context.Context, in *dbdpb.BounceListenerRequest, opts ...grpc.CallOption) (*dbdpb.BounceListenerResponse, error) {\n\tpanic(\"implement me\")\n}", "func (a acknowledger) Ack(multiple bool) (err error) {\n\tastilog.Debugf(\"astiamqp: ack %v with multiple %v\", a.deliveryTag, multiple)\n\tif err = a.acknowledger.Ack(a.deliveryTag, multiple); err != nil {\n\t\terr = errors.Wrapf(err, \"astiamqp: ack %v with multiple %v failed\", a.deliveryTag, multiple)\n\t\treturn\n\t}\n\treturn\n}", "func (pipeline *ReceivePipeline) Enqueue(response announced.Response) {\n\tpipeline.head <- response\n}", "func (s *raftServer) sendHeartBeat() {\n\tae := &AppendEntry{Term: s.Term(), LeaderId: s.server.Pid()}\n\tae.LeaderCommit = s.commitIndex.Get()\n\te := &cluster.Envelope{Pid: cluster.BROADCAST, Msg: ae}\n\ts.server.Outbox() <- e\n}", "func (c *Chain) advertiseBlock(b block.Block) error {\n\tmsg := &peermsg.Inv{}\n\tmsg.AddItem(peermsg.InvTypeBlock, b.Header.Hash)\n\n\tbuf := new(bytes.Buffer)\n\tif err := msg.Encode(buf); err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tif err := topics.Prepend(buf, topics.Inv); err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tm := message.New(topics.Inv, *buf)\n\tc.eventBus.Publish(topics.Gossip, m)\n\treturn nil\n}", "func (nh *NodeHost) RequestAddObserver(clusterID uint64,\n\tnodeID uint64, address string, configChangeIndex uint64,\n\ttimeout time.Duration) (*RequestState, error) {\n\tv, ok := nh.getCluster(clusterID)\n\tif !ok {\n\t\treturn nil, ErrClusterNotFound\n\t}\n\treq, err := v.requestAddObserverWithOrderID(nodeID,\n\t\taddress, configChangeIndex, timeout)\n\tnh.execEngine.setNodeReady(clusterID)\n\treturn req, err\n}", "func (m *MockDHTKeeper) AddToAnnounceList(key []byte, repo string, objType int, announceTime int64) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"AddToAnnounceList\", key, repo, objType, announceTime)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (c *client) Activate(u *model.User, r *model.Repo, link string) error {\n\tconfig := map[string]string{\n\t\t\"url\": link,\n\t\t\"secret\": r.Hash,\n\t\t\"content_type\": \"json\",\n\t}\n\thook := gitea.CreateHookOption{\n\t\tType: \"gitea\",\n\t\tConfig: config,\n\t\tEvents: []string{\"push\", \"create\", \"pull_request\"},\n\t\tActive: true,\n\t}\n\n\tclient := c.newClientToken(u.Token)\n\t_, err := client.CreateRepoHook(r.Owner, r.Name, hook)\n\treturn err\n}", "func (incident *Incident) Send(cfg *CachetMonitor) error {\n\tswitch incident.Status {\n\t\tcase 1, 2, 3:\n\t\t\t// partial outage\n\t\t\tincident.ComponentStatus = 3\n\n\t\t\tcompInfo := cfg.API.GetComponentData(incident.ComponentID)\n\t\t\tif compInfo.Status == 3 {\n\t\t\t\t// major outage\n\t\t\t\tincident.ComponentStatus = 4\n\t\t\t}\n\t\tcase 4:\n\t\t\t// fixed\n\t\t\tincident.ComponentStatus = 1\n\t}\n\n\trequestType := \"POST\"\n\trequestURL := \"/incidents\"\n\tif incident.ID > 0 {\n\t\trequestType = \"PUT\"\n\t\trequestURL += \"/\" + strconv.Itoa(incident.ID)\n\t}\n\n\tjsonBytes, _ := json.Marshal(incident)\n\n\tresp, body, err := cfg.API.NewRequest(requestType, requestURL, jsonBytes)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar data struct {\n\t\tID int `json:\"id\"`\n\t}\n\tif err := json.Unmarshal(body.Data, &data); err != nil {\n\t\treturn fmt.Errorf(\"Cannot parse incident body: %v, %v\", err, string(body.Data))\n\t}\n\n\tincident.ID = data.ID\n\tif resp.StatusCode != 200 {\n\t\treturn fmt.Errorf(\"Could not create/update incident!\")\n\t}\n\n\treturn nil\n}", "func (p *PacketCryptAnn) GetAnnounceHeader() []byte {\n\treturn p.Header[:PcAnnHeaderLen]\n}", "func (au *AnnouncementUpdate) Exec(ctx context.Context) error {\n\t_, err := au.Save(ctx)\n\treturn err\n}", "func (r *SubscriptionsService) Acknowledge(acknowledgerequest *AcknowledgeRequest) *SubscriptionsAcknowledgeCall {\n\tc := &SubscriptionsAcknowledgeCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.acknowledgerequest = acknowledgerequest\n\treturn c\n}", "func (u *Umbrella) OnASNRequest(ctx context.Context, req *requests.ASNRequest) {\n\tbus := ctx.Value(requests.ContextEventBus).(*eventbus.EventBus)\n\tif bus == nil {\n\t\treturn\n\t}\n\n\tif u.API == nil || u.API.Key == \"\" {\n\t\treturn\n\t}\n\n\tif req.Address == \"\" && req.ASN == 0 {\n\t\treturn\n\t}\n\n\tu.CheckRateLimit()\n\tbus.Publish(requests.SetActiveTopic, u.String())\n\n\tif req.Address != \"\" {\n\t\tu.executeASNAddrQuery(ctx, req)\n\t\treturn\n\t}\n\n\tu.executeASNQuery(ctx, req)\n}", "func (a *Announcement) Dial(p *pool.Pool) (*grpc.ClientConn, error) {\n\tif p == nil {\n\t\tp = pool.Global\n\t}\n\tif a.NetAddress == \"\" {\n\t\treturn nil, errors.New(\"No address known for this component\")\n\t}\n\tnetAddress := strings.Split(a.NetAddress, \",\")[0]\n\tif a.Certificate == \"\" {\n\t\treturn p.DialInsecure(netAddress)\n\t}\n\ttlsConfig, _ := a.TLSConfig()\n\treturn p.DialSecure(netAddress, credentials.NewTLS(tlsConfig))\n}", "func solicit(w dhcp6server.ResponseSender, r *dhcp6server.Request) {\n\tw.Send(dhcp6.MessageTypeAdvertise)\n}", "func (o *os) RequestAttention() {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.RequestAttention()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"request_attention\")\n\n\t// Call the parent method.\n\t// void\n\tretPtr := gdnative.NewEmptyVoid()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n}", "func (s *server) Approve(ctx context.Context, request *event.ApproveParam) (*event.Response, error) {\n\treturn &event.Response{Status: int32(200), Message: string(\"Approve\"), Data: []*event.Deposit{}}, nil\n}", "func (info *Info) Publish(aconf *config.AmqpConfig) error {\n\tblob, err := info.Marshal()\n\tif err != nil {\n\t\treturn err\n\t}\n\tmsg := amqp.Publishing{\n\t\tDeliveryMode: amqp.Persistent,\n\t\tTimestamp: time.Now(),\n\t\tContentType: \"application/json\",\n\t\tBody: blob,\n\t}\n\tconn, err := Connect(aconf)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\tch, err := conn.Channel()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer ch.Close()\n\tif err := ch.ExchangeDeclare(aconf.ExchangeName(), amqp.ExchangeFanout, true, false, false, false, nil); err != nil {\n\t\treturn err\n\t}\n\tif err := ch.Confirm(false); err != nil {\n\t\treturn err\n\t}\n\tnotify := ch.NotifyPublish(make(chan amqp.Confirmation, 1))\n\tif err := ch.Publish(aconf.ExchangeName(), aconf.RoutingKey(), false, false, msg); err != nil {\n\t\treturn err\n\t}\n\tconfirm := <-notify\n\tif !confirm.Ack {\n\t\treturn errors.New(\"message was NACKed\")\n\t}\n\treturn nil\n}" ]
[ "0.7591315", "0.7542612", "0.7309203", "0.73045576", "0.70813364", "0.69591624", "0.6934339", "0.6784179", "0.6711855", "0.6598236", "0.62005067", "0.62001413", "0.6174527", "0.61571336", "0.60925037", "0.6053757", "0.59826213", "0.58398366", "0.58314586", "0.5807263", "0.5769014", "0.5679035", "0.5677883", "0.55432546", "0.5483456", "0.54690355", "0.545733", "0.5435622", "0.54049134", "0.5387384", "0.53676146", "0.52061415", "0.5154094", "0.51468045", "0.51374036", "0.51116014", "0.50264746", "0.49962726", "0.4955779", "0.4921116", "0.48973036", "0.48640665", "0.4816884", "0.47856435", "0.47344035", "0.46511728", "0.4649638", "0.45649105", "0.4529858", "0.45230997", "0.44898707", "0.44857168", "0.44742575", "0.4470449", "0.4444967", "0.44409084", "0.44406727", "0.44277054", "0.44209912", "0.4402811", "0.44026414", "0.43855524", "0.43716735", "0.43627167", "0.4339651", "0.43348467", "0.42505905", "0.42419755", "0.42277637", "0.4218835", "0.42109603", "0.42108628", "0.42056227", "0.4203666", "0.41895732", "0.4174102", "0.41655934", "0.4159386", "0.41435334", "0.41410056", "0.41400093", "0.41321713", "0.41290787", "0.40966254", "0.40866238", "0.40839007", "0.40696397", "0.40559402", "0.40524468", "0.40452683", "0.40382823", "0.40360516", "0.40313375", "0.40218168", "0.4020831", "0.39836273", "0.39834684", "0.39767784", "0.39757335", "0.39729798" ]
0.7839598
0
Scrape sends a Scrape request to the tracker.
func (t *Client) Scrape(c context.Context, infohashes []metainfo.Hash) ( resp ScrapeResponse, err error) { hs := make([]string, len(infohashes)) for i, h := range infohashes { hs[i] = h.BytesString() } err = t.send(c, t.ScrapeURL, url.Values{"info_hash": hs}, &resp) return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Client) Scrape() {\n\tfor range time.Tick(c.interval) {\n\n\t\tallstats := c.getStatistics()\n\t\t//Set the metrics\n\t\tc.setMetrics(allstats.status, allstats.stats, allstats.logStats)\n\n\t\tlog.Printf(\"New tick of statistics: %s\", allstats.stats.ToString())\n\t}\n}", "func (n *NewsPaper) Scrape() {\n\tvar err error\n\tvar resp *http.Response\n\tvar fd *os.File\n\tvar out string\n\tclog := logrus.WithField(\"newspaper\", n.Name)\n\n\tc := &http.Client{\n\t\tTimeout: time.Second * 10,\n\t}\n\tif resp, err = c.Get(n.URL); err != nil {\n\t\tclog.WithError(err).Error(\"Couldn't scrape\")\n\t\treturn\n\t}\n\tdefer resp.Body.Close()\n\n\tif fd, err = n.CreateDumpFile(); err != nil {\n\t\tclog.WithError(err).Error(\"Couldn't create dump file\")\n\t\treturn\n\t}\n\tout, err = html2text.FromReader(resp.Body)\n\tif _, err = fd.WriteString(out); err != nil {\n\t\tclog.WithError(err).Error(\"Couldn't copy ouput\")\n\t}\n}", "func (scraper *Scraper) Scrape(sess *session.Session) map[string][]*ScrapeResult {\n\tstatus := \"success\"\n\tstart := time.Now()\n\n\tresponse, err := scraper.Fn(sess)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\tstatus = \"error\"\n\t}\n\n\tduration := time.Since(start)\n\tmetrics.ScrapeDurationHistogram.WithLabelValues(scraper.ID, status).Observe(duration.Seconds())\n\n\treturn response\n}", "func (n *scraper) Scrape(ctx context.Context) <-chan PeerStat {\n\tch := make(chan PeerStat, peerStatChannelSize)\n\n\tgo func() {\n\t\tfor {\n\t\t\tif err := runScrape(ctx, ch); err != nil {\n\t\t\t\tif ctx.Err() != nil {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tlog.Error(\"scrape failed: \", err)\n\t\t\t}\n\t\t}\n\t}()\n\n\treturn ch\n}", "func (t *trackerTorrent) scrape() (response bmap) {\n\tresponse = make(bmap)\n\tcompleteCount, incompleteCount := t.countPeers()\n\tresponse[\"complete\"] = completeCount\n\tresponse[\"incomplete\"] = incompleteCount\n\tresponse[\"downloaded\"] = t.downloaded\n\tif t.name != \"\" {\n\t\tresponse[\"name\"] = t.name\n\t}\n\treturn\n}", "func (akt AkKvartScraper) Scrape(doc *goquery.Document, ch chan<- scrape.Listing) {\n\tfmt.Println(\"Beginning to scrape a site...\")\n\tvar wg sync.WaitGroup\n\n\tfindings := doc.Find(\"#listings li.template\")\n\n\tfindings.Each(func(i int, s *goquery.Selection) {\n\t\twg.Add(1)\n\t\tgo func(wg *sync.WaitGroup) {\n\t\t\tch <- akt.FillListing(s)\n\t\t\twg.Done()\n\t\t}(&wg)\n\t})\n\n\twg.Wait()\n\tfmt.Println(\"Scrape finished...\")\n}", "func scrape(u string, p string, selector string, ch chan string, chFinished chan bool) {\n\n\tfmt.Printf(\"Scraping url with POST args %s \\n\", p)\n\n\t// I think there's probably a better way to get the query in proper format -- I am using this for POST requests\n\tuv, err := url.ParseQuery(p)\n\tcheck(err, \"ERROR: Could not do url.ParseQuery for \\\"\"+p+\"\\\"\")\n\n\t// POST to the desired url\n\tresp, err := http.PostForm(\n\t\tu,\n\t\tuv)\n\tem := \"ERROR: Failed to scrape \\\"\" + u + \"\\\"\"\n\tcheck(err, em)\n\n\tdefer func() {\n\t\t// Notify that we're done after this function\n\t\tchFinished <- true\n\t}()\n\n\t// get the response ready for goquery\n\tdoc, err := goquery.NewDocumentFromResponse(resp)\n\tcheck(err, \"ERROR: There was an issue making the doc. \\n\")\n\n\t// get the html in the selector from the doc\n\ttext, err := doc.Find(selector).Html()\n\tcheck(err, \"ERROR: There was an issue selection \" + selector + \" from the doc. \\n\")\n\n\t// send it to the channel\n\tch <- text\n}", "func (ns *NewsPapers) Scrape() {\n\tlogrus.Info(\"Started scraping\")\n\tns.CreateDirectories()\n\tvar wg sync.WaitGroup\n\tfor _, n := range ns.NewsPapers {\n\t\twg.Add(1)\n\t\tgo func(n *NewsPaper) {\n\t\t\tdefer wg.Done()\n\t\t\tn.Scrape()\n\t\t}(n)\n\t}\n\twg.Wait()\n\tlogrus.Info(\"Done scraping\")\n}", "func (c *Crawler) CrawlAndScrape() {\n\n\tvar wg sync.WaitGroup\n\n\t//Crawl BaseURL to find the urls\n\tc.crawlURL(c.BaseURL)\n\n\tfor {\n\t\te := c.CrawlQueue.Front()\n\n\t\tif e == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tc.crawlURL(e.Value.(string))\n\n\t\tc.CrawlQueue.Remove(e)\n\n\t\tfmt.Printf(\"URLS Queue: %d \\n\", c.CrawlQueue.Len())\n\t\tfmt.Printf(\"URLS Crawled: %d \\n\", c.CrawledCount)\n\n\t\t//Save progress every 20 crawls\n\t\tif c.CrawledCount%20 == 0 {\n\t\t\tgo c.saveProgress(&wg)\n\t\t\twg.Add(1)\n\t\t}\n\t}\n\n\t//Save progress one last time\n\tgo c.saveProgress(&wg)\n\twg.Add(1)\n\n\twg.Wait()\n\n}", "func scrape(location string) {\n\tscr := scraper.NewLpScraper(location)\n\n\tresp, err := scr.Load()\n\tif err != nil {\n\t\tlog.Info.Printf(\"Could not open webpage %s: %v\\n\", scr.OID(), err)\n\t\tpanic(Exit{Code: 1})\n\t}\n\tlog.Info.Printf(\"Loaded webpage %s\\n\", scr.OID())\n\tdefer resp.Body.Close()\n\n\terr = scr.Parse(resp)\n\tif err != nil {\n\t\tlog.Info.Printf(\"Could not parse webpage %s: %v\\n\", scr.OID(), err)\n\t\tpanic(Exit{Code: 1})\n\t}\n\tlog.Info.Printf(\"Parsed webpage %s\\n\", scr.OID())\n\n\tscr.Download()\n\twg.Done()\n}", "func (s *snowflakeMetricsScraper) scrape(ctx context.Context) (pmetric.Metrics, error) {\n\terrs := &scrapererror.ScrapeErrors{}\n\n\tnow := pcommon.NewTimestampFromTime(time.Now())\n\n\t// each client call has its own scrape function\n\n\ts.scrapeBillingMetrics(ctx, now, *errs)\n\ts.scrapeWarehouseBillingMetrics(ctx, now, *errs)\n\ts.scrapeLoginMetrics(ctx, now, *errs)\n\ts.scrapeHighLevelQueryMetrics(ctx, now, *errs)\n\ts.scrapeDBMetrics(ctx, now, *errs)\n\ts.scrapeSessionMetrics(ctx, now, *errs)\n\ts.scrapeSnowpipeMetrics(ctx, now, *errs)\n\ts.scrapeStorageMetrics(ctx, now, *errs)\n\n\trb := s.mb.NewResourceBuilder()\n\trb.SetSnowflakeAccountName(s.conf.Account)\n\treturn s.mb.Emit(metadata.WithResource(rb.Emit())), errs.Combine()\n}", "func (c CustomScraper) Scrape(_ *http.Request, closer io.ReadCloser) ([]*url.URL, error) {\n\tdefer closer.Close()\n\n\tvar links []*url.URL\n\n\tz := html.NewTokenizer(closer)\n\n\tfor {\n\t\ttt := z.Next()\n\n\t\tif tt == html.ErrorToken {\n\t\t\treturn links, nil\n\t\t}\n\n\t\tif tt == html.TextToken {\n\t\t\ttoken := z.Token()\n\n\t\t\tfmt.Println(strings.TrimSpace(token.Data))\n\t\t}\n\t}\n}", "func (c *crawling) crawl(s site) {\n\turls := c.crawlSite(s) // the core crawl process\n\tc.Feed(urls, s.URL, s.Depth-1) // new urls enter crawling - circular feedback\n\ttime.Sleep(c.Delay) // have a gentle nap\n}", "func (sc *controller) startScraping() {\n\tgo func() {\n\t\tif sc.tickerCh == nil {\n\t\t\tticker := time.NewTicker(sc.collectionInterval)\n\t\t\tdefer ticker.Stop()\n\n\t\t\tsc.tickerCh = ticker.C\n\t\t}\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-sc.tickerCh:\n\t\t\t\tsc.scrapeMetricsAndReport(context.Background())\n\t\t\tcase <-sc.done:\n\t\t\t\tsc.terminated <- struct{}{}\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n}", "func Scrape(url string) {\n\tc := colly.NewCollector()\n\n\t// Send a nice user agent\n\tc.UserAgent = \"CoronaCount/1.0.0 (+https://github.com/tsak/coronacount)\"\n\n\tc.OnHTML(\"html\", func(e *colly.HTMLElement) {\n\t\tcontent := e.DOM.Find(\"body\").Find(\"h1,h2,h3,h4,h5,h6,h7,p,ul,ol\").Text()\n\n\t\tcount := 0\n\t\t// Quick and dirty\n\t\tfor _, s := range []string{\"Corona\", \"Covid-19\", \"SARS-CoV-2\"} {\n\t\t\tcount += strings.Count(content, s) // Count matches of Corona, ...\n\t\t\tcount += strings.Count(content, strings.ToUpper(s)) // Count matches of CORONA, ...\n\t\t\tcount += strings.Count(content, strings.ToLower(s)) // Count matches of corona, ...\n\t\t}\n\n\t\tif !siteMap.UpdateCount(url, count) {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"URL\": url,\n\t\t\t\t\"Count\": count,\n\t\t\t}).Warn(\"Count not updated\")\n\t\t\treturn\n\t\t}\n\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"URL\": url,\n\t\t\t\"Count\": count,\n\t\t}).Info(\"Scraped\")\n\n\t\tall := siteMap.All()\n\n\t\t// Update frontend\n\t\tfrontend.Render(all)\n\n\t\t// Save state\n\t\tstate.Save(all)\n\t})\n\n\t// Load URL\n\terr := c.Visit(url)\n\tif err != nil {\n\t\tlog.WithField(\"URL\", url).WithError(err).Error(\"Unable to scrape\")\n\t\treturn\n\t}\n}", "func (r *aerospikeReceiver) scrape(_ context.Context) (pmetric.Metrics, error) {\n\tr.logger.Debug(\"beginning scrape\")\n\terrs := &scrapererror.ScrapeErrors{}\n\n\tif r.client == nil {\n\t\tvar err error\n\t\tr.logger.Debug(\"client is nil, attempting to create a new client\")\n\t\tr.client, err = r.clientFactory()\n\t\tif err != nil {\n\t\t\tr.client = nil\n\t\t\taddPartialIfError(errs, fmt.Errorf(\"client creation failed: %w\", err))\n\t\t\treturn r.mb.Emit(), errs.Combine()\n\t\t}\n\t}\n\n\tnow := pcommon.NewTimestampFromTime(time.Now().UTC())\n\tclient := r.client\n\n\tinfo := client.Info()\n\tfor _, nodeInfo := range info {\n\t\tr.emitNode(nodeInfo, now, errs)\n\t}\n\tr.scrapeNamespaces(client, now, errs)\n\n\treturn r.mb.Emit(), errs.Combine()\n}", "func (api *API) launchCrawler(done chan bool) error {\n\t// location of the crawler script wrt localgoogoo root dir\n\tvar path = \"/php/start_crawler.php\"\n\n\tvar formData = url.Values{\n\t\t\"web_name\": {api.Payload.siteName},\n\t\t\"web_url\": {api.Payload.siteURL},\n\t}\n\n\tvar urlString = fmt.Sprintf(\"%s%s\", api.BaseURL, path)\n\n\tfmt.Print(\"\\nCrawling website...\\n\\n\")\n\n\t_, err := api.Client.PostForm(urlString, formData)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdone <- true\n\treturn nil\n}", "func scrape(tmsearchURL string, numResults int) {\n\tclient := &http.Client{\n\t\tCheckRedirect: http.DefaultClient.CheckRedirect,\n\t}\n\tcsvWriter := csv.NewWriter(os.Stdout)\n\n\tfor i := 1; i <= numResults; i++ {\n\t\turl := tmsearchURL + strconv.Itoa(i)\n\t\treq := newRequest(url)\n\t\tlog.Println(\"Scraping results from url\", url)\n\t\tresp, err := client.Do(req)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"Error reading response\", err)\n\t\t}\n\t\tdefer resp.Body.Close()\n\n\t\tif resp.StatusCode == http.StatusOK {\n\t\t\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\t\t\tif err != nil {\n\t\t\t\tlog.Fatal(err)\n\t\t\t}\n\t\t\tbodyString := string(bodyBytes)\n\t\t\tprocessResult(i, csvWriter, bodyString)\n\t\t}\n\t\ttime.Sleep(2 * time.Second)\n\t}\n}", "func (dv *LagonikaScraper) Scrape(ch chan Item) {\n\tc := colly.NewCollector()\n\n\tc.OnHTML(\".lagonika-offer-main\", func(e *colly.HTMLElement) {\n\t\ttemp := Item{}\n\t\ttemp.URL = e.ChildAttr(\".la-listview-title a\", \"href\")\n\t\ttemp.Title = e.ChildText(\".la-listview-title\")\n\t\ttemp.Source = \"Lagonika\"\n\t\t// keep only numbers.\n\t\tre := regexp.MustCompile(`[-]?\\d[\\d,]*[\\.]?[\\d{2}]*`)\n\t\tfl := re.FindAllString(e.ChildText(\".la-offer-price\"), -1)\n\t\tif len(fl) > 0 {\n\t\t\tif s, err := strconv.ParseFloat(fl[0], 64); err == nil {\n\t\t\t\ttemp.Price = &s\n\t\t\t}\n\t\t}\n\t\tch <- temp\n\t})\n\tc.OnRequest(func(r *colly.Request) {\n\t\tfmt.Println(\"Visiting\", r.URL)\n\t})\n\tc.OnScraped(func(response *colly.Response) {\n\t\treturn\n\t})\n\tc.Visit(\"https://www.lagonika.gr/?dtype=prosfata\")\n}", "func Scraper(request Request) (Response, error) {\n\tresponse := Response{\n\t\trequest.Element,\n\t\trequest.Attribute,\n\t}\n\terr := url.ParseRequestURI(request.Url)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdocument, err := initializeDocument(document_url)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\telements := findAllElements(request.Element, document)\n\tattributes := getAllAttributes(elements, request.Attribute)\n\tresponse.Attributes = attributes\n\treturn response\n}", "func crawl(ctx context.Context, url string, label map[string]string, sources chan string, results chan string) {\n\tselect {\n\tcase <-ctx.Done():\n\t\tfmt.Println(\"request timeout, stop http request\")\n\t\treturn\n\tdefault:\n\t}\n\tlimiter(func() {\n\t\tfmt.Printf(\"start crawl url: %s\\n\", url)\n\t\tresp, err := proxyGet(url)\n\t\tif err != nil && err == ErrProxyMayNotWork {\n\t\t\t// 重新放入channel\n\t\t\tfmt.Printf(\"proxy not work, put url back into channel: %s\\n\", url)\n\t\t\ttime.Sleep(time.Second)\n\t\t\tsources <- url\n\t\t\treturn\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Println(errors.Wrap(err, \"crawl url error\"))\n\t\t\treturn\n\t\t}\n\t\tgo parse(ctx, resp.Body, label, results)\n\t})\n}", "func (e *Exporter) scrape(ch chan<- prometheus.Metric) error {\n\t// Meassure scrape duration.\n\tdefer func(begun time.Time) {\n\t\te.scrapeDuration.Set(time.Since(begun).Seconds())\n\t}(time.Now())\n\n\te.totalScrapes.Inc()\n\n\t// Extract station IDs for price request.\n\tids := make([]string, 0, len(e.stations))\n\tfor id := range e.stations {\n\t\tids = append(ids, id)\n\t}\n\n\t// Retrieve prices for specified stations. Since the API will only allow for\n\t// ten stations to be queried with one request, we work them of in batches\n\t// of ten.\n\tconst batchSize = 10\n\tvar (\n\t\tprices = make(map[string]tankerkoenig.Price, len(ids))\n\t\tpricesMu sync.Mutex\n\t\terrGroup errgroup.Group\n\t)\n\tfor i := 0; i < len(ids); i += batchSize {\n\t\tj := i + batchSize\n\t\tif j > len(ids) {\n\t\t\tj = len(ids)\n\t\t}\n\n\t\terrGroup.Go(func(batch []string) func() error {\n\t\t\treturn func() error {\n\t\t\t\tbatchPrices, _, err := e.client.Prices.Get(batch...)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tpricesMu.Lock()\n\t\t\t\tfor k, v := range batchPrices {\n\t\t\t\t\tprices[k] = v\n\t\t\t\t}\n\t\t\t\tpricesMu.Unlock()\n\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}(ids[i:j]))\n\t}\n\n\tif err := errGroup.Wait(); err != nil {\n\t\te.up.Set(0)\n\t\te.failedScrapes.Inc()\n\t\treturn err\n\t}\n\n\t// Set metric values.\n\tfor id, price := range prices {\n\t\tstation := e.stations[id]\n\n\t\t// Station metadata. We do some string manipulation on the address and\n\t\t// city to make it look nicer as the come in all uppercase.\n\t\tcity := strings.TrimSpace(caser.String(station.Place))\n\t\tstreet := strings.TrimSpace(caser.String(station.Street))\n\t\tno := strings.TrimSpace(station.HouseNumber)\n\t\taddress := fmt.Sprintf(\"%s %s\", street, no)\n\t\tch <- prometheus.MustNewConstMetric(e.detailsDesc, prometheus.GaugeValue, 1, id,\n\t\t\tstation.Name,\n\t\t\taddress,\n\t\t\tcity,\n\t\t\tgeohash.Encode(station.Lat, station.Lng),\n\t\t\tstation.Brand,\n\t\t)\n\n\t\t// Station status.\n\t\tif stat := price.Status; stat == \"no prices\" {\n\t\t\te.logger.Printf(\"warning: station %q (%s) has no prices, skipping...\", id, station.Name)\n\t\t\tcontinue\n\t\t} else if stat == \"open\" {\n\t\t\tch <- prometheus.MustNewConstMetric(e.openDesc, prometheus.GaugeValue, 1, id)\n\t\t} else {\n\t\t\tch <- prometheus.MustNewConstMetric(e.openDesc, prometheus.GaugeValue, 0, id)\n\t\t}\n\n\t\t// Station prices.\n\t\tif v, ok := price.Diesel.(float64); ok {\n\t\t\tch <- prometheus.MustNewConstMetric(e.priceDesc, prometheus.GaugeValue, v, id, \"diesel\")\n\t\t}\n\t\tif v, ok := price.E5.(float64); ok {\n\t\t\tch <- prometheus.MustNewConstMetric(e.priceDesc, prometheus.GaugeValue, v, id, \"e5\")\n\t\t}\n\t\tif v, ok := price.E10.(float64); ok {\n\t\t\tch <- prometheus.MustNewConstMetric(e.priceDesc, prometheus.GaugeValue, v, id, \"e10\")\n\t\t}\n\t}\n\n\t// Scrape was successful.\n\te.up.Set(1)\n\n\treturn nil\n}", "func (d DefaultScrapper) Scrap(selector ScrapSelector) (string, chan ItemResult, error) {\n\twg := &sync.WaitGroup{}\n\terr := validateSelector(selector)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\titems := make(chan ItemResult, bufferItemsSize)\n\n\tjobId := \"D\" + GenerateStringKey(selector)\n\tlog.Printf(\"INFO: Scrap [%s] started\\n\", jobId)\n\tdata := NewRedisScrapdata()\n\tdata.StartJob(jobId, selector)\n\n\tpages := paginatedUrlSelector(selector)\n\n\twg.Add(len(pages))\n\tfor i, _ := range pages {\n\t\tgo doScrapFromUrl(jobId, pages[i], items, wg)\n\t}\n\n\tgo closeItemsChannel(jobId, items, wg)\n\n\treturn jobId, items, err\n}", "func (s *server) Crawl(ctx context.Context, in *pb.LinkRequest) (*pb.CrawlerResponse, error) {\n\tmapLock.RLock()\n\t// given a URL checks to see if its currently being crawled\n\t_, exists := s.spiderPtr.siteURLIndex[in.Url]\n\tmapLock.RUnlock()\n\tif exists {\n\t\tmsg := fmt.Sprintf(\"Site %s is already being crawled\", in.Url)\n\t\treturn &pb.CrawlerResponse{Message: msg}, nil\n\t}\n\t// put new site on channel\n\tnewsites <- in.Url\n\treturn &pb.CrawlerResponse{Message: \"Crawler started crawling\"}, nil\n}", "func StartScraper(\n\tctx context.Context,\n\trepo repository.Repository,\n\tclients []api.ExchangeAPIClient) error {\n\tlog.Println(\"Starting Scraper\")\n\tdefer log.Println(\"Stopping Scraper\")\n\tvar waitGroup sync.WaitGroup\n\n\tfor index := range clients {\n\t\tclient := clients[index]\n\t\t// TODO(Zahin): Handle Errors\n\t\twaitGroup.Add(1)\n\t\tgo func(wg *sync.WaitGroup) {\n\t\t\t// Decrement the counter when the goroutine completes.\n\t\t\tdefer wg.Done()\n\t\t\terr := ScrapeExchange(ctx, repo, client)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"ERROR SCRAPING %s\\n\", client.GetExchangeIdentifier())\n\t\t\t}\n\t\t}(&waitGroup)\n\t\t//go ScrapeExchange(ctx, secrets, db, influxDBClient, clients[i])\n\t}\n\twaitGroup.Wait()\n\treturn nil\n}", "func Crawl(id int, userAgent string, waiting <-chan *url.URL, processed chan<- *url.URL, content chan<- string) {\n\n\tvar u *url.URL\n\tvar open bool\n\tvar httpClient = utils.NewHttpClient(userAgent)\n\n\tfor {\n\t\tselect {\n\t\tcase u, open = <-waiting:\n\n\t\t\tif open {\n\n\t\t\t\tc, err := httpClient.RetrieveContent(u.String())\n\n\t\t\t\tlog.Printf(\"Crawl Worker-[%v] parsed content for [%v]\", id, u.String())\n\n\t\t\t\t//TODO: deal with failed crawls, e.g. log with special value in key-store\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(err)\n\t\t\t\t} else {\n\n\t\t\t\t\tcontent <- c\n\t\t\t\t\tlog.Printf(\"Crawl Worker-[%v] added html from [%v] to content\", id, u.String())\n\n\t\t\t\t\tprocessed <- u\n\t\t\t\t\tlog.Printf(\"Crawl Worker-[%v] added [%v] to crawled pages\", id, u.String())\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"Crawl Worker-[%v] is exiting\", id)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\ttime.Sleep(500 * time.Millisecond)\n\t\t}\n\t}\n}", "func Scrape(mtID, camID int, cfg *ScrapedConfig) func(time.Time) {\n\t// TODO: this is kinda a shitshow (is it?) and could use refactoring\n\n\treturn func(now time.Time) {\n\n\t\t// create new scrape record\n\t\tscrape := model.Scrape{\n\t\t\tCameraID: camID,\n\t\t\tCreated: now,\n\t\t\tResult: model.Failure,\n\t\t}\n\t\t// defer to end to always make an attempt at writing a scrape\n\t\t// record even when failing during scrape\n\t\tdefer func() {\n\t\t\terr := db.InsertScrape(&scrape)\n\t\t\tif err != nil {\n\t\t\t\terr = errors.Wrapf(err, \"(mtID=%d camID=%d) failed to insert scrape into db\", mtID, camID)\n\t\t\t\tlog.Print(log.Critical, err)\n\t\t\t\t// can't do anything now... total failure\n\t\t\t}\n\t\t}()\n\n\t\t// func to simplify life\n\t\tvar err error // used throughout Scrape()\n\t\tsetDetailAndLog := func(detail string) {\n\t\t\tscrape.Detail = detail\n\t\t\tmsg := fmt.Sprintf(\"(mtID=%d camID=%d) %s\", mtID, camID, detail)\n\t\t\tif err != nil {\n\t\t\t\terr = errors.Wrapf(err, msg)\n\t\t\t} else {\n\t\t\t\terr = errors.New(msg)\n\t\t\t}\n\t\t\tlog.Print(log.Error, err)\n\t\t}\n\n\t\t// read mt and cam\n\t\tmt, err := db.Mountain(mtID)\n\t\tcam, err := db.Camera(camID)\n\t\tif err != nil {\n\t\t\tsetDetailAndLog(\"could't read db\")\n\t\t\treturn\n\t\t}\n\n\t\t// wait cam delay\n\t\ttime.Sleep(time.Duration(cam.Delay) * time.Second)\n\n\t\t// process the url template\n\t\ttz, err := time.LoadLocation(mt.TzLocation)\n\t\tdata := UrlData{\n\t\t\tCamera: cam,\n\t\t\tMountain: mt,\n\t\t\tNow: now.In(tz)} // send the url template the local time\n\t\turl, err := cam.ExecuteUrl(data)\n\t\tif err != nil {\n\t\t\tsetDetailAndLog(\"couldn't execute url template\")\n\t\t\treturn\n\t\t}\n\n\t\t// perform the scrape\n\t\t// setting a custom timeout and useragent\n\t\tclient := http.Client{Timeout: time.Duration(cfg.RequestTimeoutSec) * time.Second}\n\t\trequest, err := http.NewRequest(http.MethodGet, url, nil)\n\t\trequest.Header.Set(useragent, cfg.UserAgent)\n\t\tresp, err := client.Do(request)\n\t\tif err != nil {\n\t\t\tsetDetailAndLog(\"trouble downloading image\")\n\t\t\treturn\n\t\t}\n\t\tdefer resp.Body.Close()\n\t\tif resp.StatusCode != http.StatusOK {\n\t\t\terr = errors.Errorf(\"status code %s\", resp.Status)\n\t\t\tsetDetailAndLog(\"trouble downloading image\")\n\t\t\treturn\n\t\t}\n\t\t// if !strings.Contains(resp.Header.Get(contenttype), \"image\") {\n\t\t// \terr = errors.Errorf(\"non-image content type: %s\", resp.Header[contenttype])\n\t\t// \tsetDetailAndLog(\"trouble downloading image\")\n\t\t// \treturn\n\t\t// }\n\n\t\t// extract the image\n\t\timg, err := imaging.Decode(resp.Body)\n\t\tif err != nil {\n\t\t\tsetDetailAndLog(\"couldn't decode downloaded image\")\n\t\t\treturn\n\t\t}\n\n\t\t// resize the image, using the minimum of image size vs cfg size\n\t\t// so that the image will be resized only if it's larger than the\n\t\t// configured size\n\t\tw, h := img.Bounds().Dx(), img.Bounds().Dy()\n\t\tif cfg.Image.Width < w {\n\t\t\tw = cfg.Image.Width\n\t\t}\n\t\tif cfg.Image.Height < h {\n\t\t\th = cfg.Image.Height\n\t\t}\n\t\timg = imaging.Resize(img, w, h, imaging.Lanczos)\n\n\t\t// build (and create if necessary) the directory where the scraped\n\t\t// images will live\n\t\tcamImgDir := filepath.Join(cfg.ImageRoot, mt.Pathname, cam.Pathname)\n\t\t// check if directory exists and create if not\n\t\terr = os.MkdirAll(camImgDir, 0755)\n\t\tif err != nil {\n\t\t\t// NOTE: this is once case where it would not be appropriate to\n\t\t\t// save a (failed) scrape to the database\n\t\t\terr = errors.Wrapf(err, \"couldn't make path %s\", camImgDir)\n\t\t\tlog.Print(log.Critical, err)\n\t\t\treturn\n\t\t}\n\t\t// NOTE: no way to determine if MkDirAll() made a dir or not =(\n\t\t// log.Printf(log.Info, \"created directory %s\", camImgDir)\n\n\t\tif cfg.Image.EqualityTesting {\n\t\t\t// a function to \"encapsulate\" getting the previously scraped image\n\t\t\tgetPreviousImage := func() image.Image {\n\t\t\t\t// fetch previously (successfully) scraped image\n\t\t\t\tprevScrape, err := db.MostRecentScrape(camID, model.Success)\n\t\t\t\tif err != nil {\n\t\t\t\t\terr = errors.Wrapf(err, \"(mtID=%d camID=%d) couldn't get previous scrape from db\", mtID, camID)\n\t\t\t\t\tlog.Print(log.Error, err)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tprevImgPath := filepath.Join(camImgDir, prevScrape.Filename)\n\t\t\t\tprevImg, err := imaging.Open(prevImgPath)\n\t\t\t\tif err != nil {\n\t\t\t\t\terr = errors.Wrapf(err, \"(mtID=%d camID=%d) couldn't open previous image\", mtID, camID)\n\t\t\t\t\tlog.Print(log.Error, err)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\treturn prevImg\n\t\t\t}\n\n\t\t\t// a function to \"encapsulate\" processing of the downloaded image\n\t\t\t// so it can be tested against previously scraped image\n\t\t\tgetTestImage := func() image.Image {\n\t\t\t\t// NOTE: !important! the JPEG quality setting alters the scraped images\n\t\t\t\t// beyond resizing, which prevents simple equality testing from working.\n\t\t\t\t//\n\t\t\t\t// Fix: encode to a memory buffer and decode back to image.Image. This will\n\t\t\t\t// perform the same processing on the freshly downloaded image as was\n\t\t\t\t// previously preformed on the prior images.\n\t\t\t\t//\n\t\t\t\t// Question: given the same input, will jpeg compression produce\n\t\t\t\t// identical output?? Minor testing shows same-in-same-out.\n\t\t\t\tbuf := new(bytes.Buffer)\n\t\t\t\terr = imaging.Encode(buf, img, imaging.JPEG, imaging.JPEGQuality(cfg.Image.Quality))\n\t\t\t\ttestimg, err := imaging.Decode(buf)\n\t\t\t\tif err != nil {\n\t\t\t\t\terr = errors.Wrapf(err, \"(mtID=%d camID=%d) mem encode/decode of downloaded img\", mtID, camID)\n\t\t\t\t\tlog.Print(log.Error, err)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\treturn testimg\n\t\t\t}\n\n\t\t\tprev, cur := getPreviousImage(), getTestImage()\n\t\t\t// actually test for equality\n\t\t\tif equal(prev, cur, cfg.Image.EqualityTolerance) {\n\t\t\t\tsetDetailAndLog(\"image identical to previously scraped image\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\t// save image to disk\n\t\t// filename is sec since unix epoc in UTC\n\t\tscrape.Filename = strings.ToLower(fmt.Sprintf(\"%d.%s\", now.UTC().Unix(), cam.FileExtension))\n\t\timgPath := filepath.Join(camImgDir, scrape.Filename)\n\t\terr = imaging.Save(img, imgPath, imaging.JPEGQuality(cfg.Image.Quality))\n\t\tif err != nil {\n\t\t\tsetDetailAndLog(\"couldn't save image \" + scrape.Filename + \" to disk\")\n\t\t\treturn\n\t\t}\n\t\tlog.Printf(log.Info, \"(mtID=%d camID=%d) wrote %s\", mtID, camID, imgPath)\n\n\t\t// if we make it this far, everything was ok\n\t\tscrape.Result = model.Success\n\t\tscrape.Detail = \"\"\n\n\t}\n}", "func (httpcalls) PrometheusMetricsScrape(url string, client http.Client) (*http.Response, error) {\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tresp, err := client.Do(req)\n\treturn resp, err\n}", "func (s *Spider) crawl(fetcher Fetcher) error {\n\tfor !s.Queue.IsEmpty() {\n\t\t// get next item from queue\n\t\tp, ok := s.Queue.Dequeue()\n\t\tif !ok {\n\t\t\treturn errors.New(\"crawl dequeue error: expected a page, got none\")\n\t\t}\n\t\t// if a depth value was passed and the distance is > depth, we are done\n\t\t// depth of 0 means no limit\n\t\tif s.maxDepth != -1 && p.(Page).distance > s.maxDepth {\n\t\t\treturn nil\n\t\t}\n\t\tpage := p.(Page)\n\t\t// see if this is an external url\n\t\tif s.externalURL(page.URL) {\n\t\t\tif s.Config.CheckExternalLinks {\n\t\t\t\ts.fetchExternalLink(page.URL)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\t// check to see if this url should be skipped for other reasons\n\t\tif s.skip(page.URL) {\n\t\t\t// see if the skipped is external and process accordingly\n\t\t\tcontinue\n\t\t}\n\t\ts.foundURLs[page.URL.String()] = struct{}{}\n\t\t// get the url\n\t\tr := ResponseInfo{}\n\t\tpage.body, r, page.links = fetcher.Fetch(page.URL.String())\n\t\t// add the page and status to the map. map isn't checked for membership becuase we don't\n\t\t// fetch found urls.\n\t\ts.Lock()\n\t\ts.Pages[page.URL.String()] = page\n\t\ts.fetchedURLs[page.URL.String()] = r\n\t\ts.Unlock()\n\t\t// add the urls that the node contains to the queue\n\t\tfor _, l := range page.links {\n\t\t\tu, _ := url.Parse(l)\n\t\t\ts.Queue.Enqueue(Page{URL: u, distance: page.distance + 1})\n\t\t}\n\t\t// if there is a wait between fetches, sleep for that + random jitter\n\t\tif s.Config.FetchInterval > 0 {\n\t\t\twait := s.Config.FetchInterval\n\t\t\t// if there is a value for jitter, add a random jitter\n\t\t\tif s.Config.Jitter > 0 {\n\t\t\t\tn := s.Config.Jitter.Nanoseconds()\n\t\t\t\tn = rand.Int63n(n)\n\t\t\t\twait += time.Duration(n) * time.Nanosecond\n\t\t\t}\n\t\t\ttime.Sleep(wait)\n\t\t}\n\t}\n\treturn nil\n}", "func scrape(collector *Collector, ch chan<- prometheus.Metric) {\n\tvar wg sync.WaitGroup\n\tfor _, task := range collector.Tasks {\n\t\twg.Add(1)\n\t\tgo scrapeTask(collector, ch, task, &wg)\n\t}\n\twg.Wait()\n}", "func (s *Scraper) scrapeloop() {\n\n\ts.logger.Infof(\"Execute scraper loop\")\n\n\tfor _, url := range s.feeds {\n\t\ts.articleCollector.Visit(url)\n\t}\n\n}", "func Scrape(proxlist []m.ProxySource) []string {\n\n\tfor _, p := range proxlist { // turn to go routine\n\t\tfmt.Println(p.Reg + \"\\t\" + p.Url)\n\n\t\tresponse, err := http.Get(p.Url)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tdefer response.Body.Close()\n\n\t\t// convert io page to string\n\t\tbuf := new(bytes.Buffer)\n\t\tbuf.ReadFrom(response.Body)\n\t\tnewStr := buf.String()\n\n\t\t//fmt.Printf(newStr)\n\t\t//setup reg match\n\t\tre := regexp.MustCompile(p.Reg)\n\n\t\t//find all that match\n\t\tmatch := re.FindAllString(newStr, -1)\n\n\t\trawlist = append(rawlist, match...)\n\n\t\t//if rawlist != nil {\n\t\t//\treturn rawlist\n\t\t//}\n\n\t}\n\n\treturn rawlist\n}", "func scrape(url string) ([]byte, error) {\n\t// Retrieve the feed\n\tresponse, err := http.Get(url)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\tdefer response.Body.Close()\n\n\t// Read the contents\n\tcontents, err := ioutil.ReadAll(response.Body)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\treturn contents, nil\n}", "func Crawl(url string, depth int, fetcher Fetcher) {\n\t// TODO: Fetch URLs in parallel.\n\t// TODO: Don't fetch the same URL twice.\n\t// This implementation doesn't do either:\n\tch1 := make(chan *Fetch)\n\tvisited := map[string]bool {url:true}\n\tgo Collect(url, depth, fetcher, ch1)\n\tfor f := range ch1 {\n\t\tif (!visited[f.url]) {\n\t\t\tvisited[f.url] = true\n\t\t\tfmt.Printf(\"%s : %s\\n\", f.url, f.body)\n\t\t}\n\t}\n}", "func RunWebCrawler() {\n\tCrawl(\"https://golang.org/\", 4, fetcher)\n}", "func (o *Operator) Scrape(sub, sort, after, before string, lim uint) ([]*redditproto.Link, error) {\n\treq, err := request.New(\n\t\t\"GET\",\n\t\tfmt.Sprintf(\"https://oauth.reddit.com/r/%s/%s.json\", sub, sort),\n\t\t&url.Values{\n\t\t\t\"limit\": []string{strconv.Itoa(int(lim))},\n\t\t\t\"after\": []string{after},\n\t\t\t\"before\": []string{before},\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse, err := o.cli.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn parser.ParseLinkListing(response)\n}", "func (u UDPTracker) Scrape(files []data.FileRecord) []byte {\n\t// Iterate all files, grabbing their statistics\n\tstats := make([]udp.ScrapeStats, 0)\n\tfor _, file := range files {\n\t\tstat := udp.ScrapeStats{}\n\n\t\t// Seeders\n\t\tstat.Seeders = uint32(file.Seeders())\n\n\t\t// Completed\n\t\tstat.Completed = uint32(file.Completed())\n\n\t\t// Leechers\n\t\tstat.Leechers = uint32(file.Leechers())\n\n\t\t// Append to slice\n\t\tstats = append(stats[:], stat)\n\t}\n\n\t// Create UDP scrape response\n\tscrape := udp.ScrapeResponse{\n\t\tAction: 2,\n\t\tTransID: u.TransID,\n\t\tFileStats: stats,\n\t}\n\n\t// Convert to UDP byte buffer\n\tbuf, err := scrape.MarshalBinary()\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\treturn u.Error(\"Could not create UDP scrape response\")\n\t}\n\n\treturn buf\n}", "func Scrape(url string, date string, element string) string {\n\tdoc, _ := Loader(url)\n\ts := doc.Find(element).First()\n\ttext := s.Find(\"p\").Text()\n\treturn text\n}", "func Scrape(urls []string) Result {\n\tch = make(chan Partner, len(urls))\n\n\tresult := Result{}\n\n\tfor _, url := range urls {\n\t\twg.Add(1)\n\t\tgo getPartner(host+url)\n\t}\n\twg.Wait()\n\tclose(ch)\n\n\tfor item := range ch {\n\t\tresult.Partners = append(result.Partners, item)\n\t}\n\n\treturn result\n}", "func Crawl(url string, depth int, fetcher Fetcher) {\n\twaitGroup := &sync.WaitGroup{}\n\twaitGroup.Add(1)\n\tgo crawlInner(url, depth, fetcher, waitGroup)\n\twaitGroup.Wait()\n}", "func Crawl(link string) *bytes.Buffer {\n\n\tresp, err := http.Get(link)\n\n\tif err != nil {\n\t\tlog.Fatal(\"failed ro connect to the endpoint\")\n\t}\n\n\tdefer resp.Body.Close()\n\tdata, err := ioutil.ReadAll(resp.Body)\n\n\tif err != nil {\n\t\tlog.Fatal(\"failed ro connect to the endpoint\", err)\n\t}\n\n\tlog.Printf(\"Read data %s\", link)\n\treturn bytes.NewBuffer(data)\n}", "func crawl(parent context.Context, label map[string]string, ch chan string) chan string {\n\tresults := make(chan string)\n\t// set timeout context\n\tctx, _ := context.WithTimeout(parent, timeout)\n\tgo func() {\n\t\tfor u := range ch {\n\t\t\tgo func(url string) {\n\t\t\t\tselect {\n\t\t\t\tcase <-ctx.Done():\n\t\t\t\t\tfmt.Println(\"request timeout, stop http request\")\n\t\t\t\t\treturn\n\t\t\t\tdefault:\n\t\t\t\t}\n\t\t\t\tfmt.Printf(\"start crawl url: %s\\n\", url)\n\t\t\t\tresp, err := http.Get(url)\n\t\t\t\tif err != nil {\n\t\t\t\t\tfmt.Printf(\"crawl url error: %s\\n\", url)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tgo parse(ctx, resp.Body, label, results)\n\t\t\t}(u)\n\t\t}\n\t}()\n\treturn results\n}", "func ScrapeShit(searchTerm string) {\n\tvar baseURL string = \"https://www.indeed.ca/jobs?q=\" + searchTerm + \"&l=Calgary%2C+AB\"\n\n\tvar jobs []extractedJob\n\tc := make(chan []extractedJob)\n\n\ttotalPages := getPages(baseURL)\n\n\tfor i := 0; i < totalPages; i++ {\n\t\tgo getPage(i, baseURL, c)\n\t}\n\n\tfor i := 0; i < totalPages; i++ {\n\t\textractedJobs := <-c\n\t\tjobs = append(jobs, extractedJobs...)\n\n\t}\n\n\tdefer fmt.Println(\"All requests are successfully done\")\n\twriteJobs(jobs)\n}", "func (this *Node) StartCrawl() {\n\tgo this.Crawler.Start()\n}", "func scrapePage(url string, messageCh chan string) {\n\tswitch {\n\t// Commented out youtube since we have another bot that does this in channel\n\t//\tcase strings.Contains(url, \"youtu.be\"):\n\t//\t\tyoutubeScrape(url, messageCh)\n\t//\tcase strings.Contains(url, \"youtube\"):\n\t//\t\tyoutubeScrape(url, messageCh)\n\n\tcase strings.Contains(url, \"imgur.com/a\"):\n\t\timgurScrape(url, messageCh)\n\tcase strings.Contains(url, \"imgur.com/gallery\"):\n\t\tvimgurScrape(url, messageCh)\n\tcase strings.Contains(url, \".gifv\"): // .gifv images are actually pages\n\t\tvimgurScrape(url, messageCh)\n\tcase imgurExtRegex.MatchString(url): // has an extension (ex. .jpg) but not a .gifv\n\t\tvimgurScrape(url[:len(url)-3]+\"gifv\", messageCh) // Remove the extension and add a .gifv which seems to work\n\n\tcase strings.Contains(url, \"jira2.advance.net\"):\n\t\tjiraScrape(url, messageCh)\n\tdefault:\n\t\tlog.Printf(\"Unknown url type: %s\\n\", url)\n\t}\n}", "func (sc *controller) scrapeMetricsAndReport(ctx context.Context) {\n\tctx = obsreport.ReceiverContext(ctx, sc.name, \"\")\n\n\tmetrics := pdata.NewMetrics()\n\n\tfor _, rms := range sc.resourceMetricScrapers {\n\t\tresourceMetrics, err := rms.Scrape(ctx, sc.name)\n\t\tif err != nil {\n\t\t\tsc.logger.Error(\"Error scraping metrics\", zap.Error(err))\n\n\t\t\tif !consumererror.IsPartialScrapeError(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tresourceMetrics.MoveAndAppendTo(metrics.ResourceMetrics())\n\t}\n\n\t_, dataPointCount := metrics.MetricAndDataPointCount()\n\n\tctx = obsreport.StartMetricsReceiveOp(ctx, sc.name, \"\")\n\terr := sc.nextConsumer.ConsumeMetrics(ctx, metrics)\n\tobsreport.EndMetricsReceiveOp(ctx, \"\", dataPointCount, err)\n}", "func (s *Scraper) GetAllUrls() {\n\tshopDriver := Mixup\n\tvar shop shopCrawler = shopFactory(shopDriver)\n\n\tc := colly.NewCollector(\n\t\tcolly.AllowedDomains(shop.GetAllowedDomains()...),\n\t\t//colly.MaxDepth(5),\n\t\tcolly.Async(true),\n\t\tcolly.UserAgent(\"Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0\"),\n\t\tcolly.URLFilters(\n\t\t\tregexp.MustCompile(shop.GetLinkExtractionQuery()),\n\t\t),\n\t\tcolly.Debugger(&debug.LogDebugger{}),\n\t)\n\n\textensions.Referer(c)\n\n\tc.SetRequestTimeout(30 * time.Second)\n\n\tc.WithTransport(&http.Transport{\n\t\tDial: (&net.Dialer{\n\t\t\tTimeout: 30 * time.Second,\n\t\t}).Dial,\n\t\tTLSHandshakeTimeout: 30 * time.Second,\n\t})\n\n\terr := c.Limit(&colly.LimitRule{\n\t\tDomainGlob: shop.GetDomainGlob(),\n\t\tParallelism: 4,\n\t\tRandomDelay: 6 * time.Second,\n\t})\n\tif err != nil {\n\t\tlogging.ErrorLogger.Fatalf(\"Ocurrio un error al establecer los limites para el colector: %v\", err)\n\t}\n\n\t// Se ejecuta antes de realizar la solicitud\n\tc.OnRequest(func(r *colly.Request) {\n\t\treqID, _ := ciphersuite.GetMD5Hash(r.URL.String())\n\t\tlogging.InfoLogger.Printf(\"[%s]Visitando el sitio: %s\\n\", reqID, r.URL.String())\n\t\thds := GetHeaders()\n\t\tfor key, value := range hds {\n\t\t\tr.Headers.Set(key, value)\n\t\t}\n\t\tr.Ctx.Put(\"ID\", reqID)\n\t\tr.Ctx.Put(\"StartAt\", time.Now().Format(time.UnixDate))\n\t})\n\n\t// Se ejecuta si ocurre un error durante la petición\n\tc.OnError(func(r *colly.Response, e error) {\n\t\treqID := r.Ctx.Get(\"ID\")\n\t\tstrStartAt := r.Ctx.Get(\"StartAt\")\n\t\ttimeStartAt, err := time.Parse(time.UnixDate, strStartAt)\n\t\tif err != nil {\n\t\t\tlogging.WarningLogger.Printf(\"Error al parsear la fecha: %v\", err)\n\t\t}\n\t\tlogging.ErrorLogger.Printf(\"OnError:%s\\n\\tID: %s,\\n\\tStartAt: %s\", e, r.Ctx.Get(\"ID\"), strStartAt)\n\n\t\tdebugReq, err := env.GetCrawlerVars(env.DebugRequests)\n\t\tif err != nil {\n\t\t\tlogging.ErrorLogger.Printf(\"Error la obtener la bandera de debug\")\n\t\t}\n\n\t\tif ok := debugReq.(bool); ok {\n\t\t\trt := newRequestTracker(\n\t\t\t\treqID,\n\t\t\t\tr.Request.AbsoluteURL(r.Request.URL.String()),\n\t\t\t\t\"OnError\",\n\t\t\t\tr.Request,\n\t\t\t\tr,\n\t\t\t\ttimeStartAt,\n\t\t\t\ttime.Now(),\n\t\t\t\te,\n\t\t\t)\n\t\t\ts.addRequest(rt)\n\t\t}\n\t})\n\n\t// Se ejecuta después de recibir la respuesta\n\tc.OnResponse(func(r *colly.Response) {\n\t\tre := regexp.MustCompile(shop.GetLinkExtractionQuery())\n\t\turl := r.Request.URL.String()\n\t\tif !re.MatchString(url) && !strings.Contains(url, \"?sku=\") {\n\t\t\tlogging.WarningLogger.Printf(\"OnResponse. La URL no cumple las reglas para ser visitada: %s\", url)\n\t\t\treturn\n\t\t}\n\t\treqID := r.Ctx.Get(\"ID\")\n\t\tstrStartAt := r.Ctx.Get(\"StartAt\")\n\t\ttimeStartAt, err := time.Parse(time.UnixDate, strStartAt)\n\t\tif err != nil {\n\t\t\tlogging.WarningLogger.Printf(\"Error al parsear la fecha: %v\", err)\n\t\t}\n\t\tdebugReq, err := env.GetCrawlerVars(env.DebugRequests)\n\t\tif err != nil {\n\t\t\tlogging.ErrorLogger.Printf(\"Error la obtener la bandera de debug\")\n\t\t}\n\n\t\tif ok := debugReq.(bool); ok {\n\t\t\trt := newRequestTracker(\n\t\t\t\treqID,\n\t\t\t\tr.Request.AbsoluteURL(r.Request.URL.String()),\n\t\t\t\t\"OnResponse\",\n\t\t\t\tr.Request,\n\t\t\t\tr,\n\t\t\t\ttimeStartAt,\n\t\t\t\ttime.Now(),\n\t\t\t\tnil,\n\t\t\t)\n\t\t\ts.addRequest(rt)\n\t\t}\n\t\tlogging.InfoLogger.Printf(\"OnResponse:\\n\\tID: %s,\\nStartAt: %s\", r.Ctx.Get(\"ID\"), strStartAt)\n\t})\n\n\tfuncNames := []string{\"ExtractLinks\", \"GetMetaTags\", \"GetProductDetails\", \"GetProductInformation\", \"GetProductReviews\", \"DetectCaptcha\", \"GetProductPrice\"}\n\tcallbacks := []colly.HTMLCallback{\n\t\tfunc(e *colly.HTMLElement) {\n\t\t\tlink := e.Request.AbsoluteURL(e.Attr(\"href\"))\n\t\t\tsiteCookies := c.Cookies(link)\n\t\t\tif err := c.SetCookies(link, siteCookies); err != nil {\n\t\t\t\tlogging.ErrorLogger.Println(\"SET COOKIES ERROR: \", err)\n\t\t\t}\n\t\t\ts.visitsCount++\n\t\t\terr := c.Visit(link)\n\t\t\tif err != nil {\n\t\t\t\tlogging.ErrorLogger.Printf(\"[%s][%s]Ocurrio un error al crear la petición: %v\", e.Request.Ctx.Get(\"ID\"), e.Request.AbsoluteURL(link), err)\n\t\t\t}\n\t\t},\n\t}\n\tevents := shop.HTMLEvents(funcNames...)\n\tfor i, e := range events {\n\t\tif i >= len(callbacks) {\n\t\t\tc.OnHTML(e(nil))\n\t\t} else {\n\t\t\tc.OnHTML(e(callbacks[i]))\n\t\t}\n\t}\n\n\t// Se ejecuta justo después de OnResponse si el contenido recibido es HTML\n\t/* c.OnHTML(shop.ExtractLinks(func(e *colly.HTMLElement) {\n\t\tlink := e.Attr(\"href\")\n\t\tsiteCookies := c.Cookies(link)\n\t\tif err := c.SetCookies(link, siteCookies); err != nil {\n\t\t\tlogging.ErrorLogger.Println(\"SET COOKIES ERROR: \", err)\n\t\t}\n\t\ts.visitsCount++\n\t\terr := c.Visit(link)\n\t\tif err != nil {\n\t\t\tlogging.ErrorLogger.Printf(\"[%s][%s]Ocurrio un error al crear la petición: %v\", e.Request.Ctx.Get(\"ID\"), e.Request.AbsoluteURL(link), err)\n\t\t}\n\t}))\n\tc.OnHTML(\"html\", shop.GetMetaTags)\n\tc.OnHTML(\"div.detail\", shop.GetProductDetails)\n\tc.OnHTML(\"div#centerCol\", shop.GetProductDetails) */\n\n\t// Es el último callback en ejecutarse\n\tc.OnScraped(func(r *colly.Response) {\n\t\t/* fmt.Println(\"finalizo el scraping del producto\")\n\t\tproductJSON := r.Request.Ctx.Get(\"Product\")\n\t\tfmt.Println(\"productJSON\", productJSON) */\n\t\ts.setSeedURL(r.Request.URL.String())\n\t})\n\n\t// sitio inicial a visitar\n\ts.visitsCount++\n\terr = c.Visit(s.seedURL)\n\tif err != nil {\n\t\tlogging.ErrorLogger.Printf(\"Ocurrio un error al crear la petición de la URL semilla: %v\", err)\n\t}\n\tc.Wait()\n\n\tdebugReq, err := env.GetCrawlerVars(env.DebugRequests)\n\tif err != nil {\n\t\tlogging.ErrorLogger.Printf(\"Error la obtener la bandera de debug\")\n\t}\n\n\tif ok := debugReq.(bool); ok {\n\t\tlogging.InfoLogger.Println(\"Escribiendo los resultados\")\n\t\ts.SaveScrapingData()\n\t} else {\n\t\tlogging.InfoLogger.Println(\"Sin guardar la información del scraping\")\n\t}\n\n}", "func (s *Spider) Crawl(depth int) (message string, err error) {\n\ts.maxDepth = depth\n\tS := Site{URL: s.URL}\n\t// if we are to respect the robots.txt, set up the info\n\tif s.Config.RespectRobots {\n\t\ts.getRobotsTxt()\n\t}\n\ts.Queue.Enqueue(Page{URL: s.URL})\n\terr = s.crawl(S)\n\treturn fmt.Sprintf(\"%d nodes were processed; %d external links linking to %d external hosts were not processed\", len(s.Pages), len(s.externalLinks), len(s.externalHosts)), err\n}", "func Crawl(url string, depth int, fetcher Fetcher) {\n\t// Fetch URLs in parallel.\n\t// Don't fetch the same URL twice.\n\t// This implementation doesn't do either:\n\tch := make(chan Url, 100)\n\tvisited := make(map[string]bool)\n\tgo func() {\n\t\tfor v := range ch {\n\t\t\tDoCrawl(v, fetcher, ch, visited)\n\t\t}\n\t}()\n\tch <- Url{url, 4}\n\ttime.Sleep(100000000000)\n}", "func Crawl(url string, depth int, fetcher Fetcher, ch chan Res, errs chan error, visited map[string]bool) {\n\tbody, urls, err := fetcher.Fetch(url)\n\tvisited[url] = true\n\tif err != nil {\n\t\terrs <- err\n\t\treturn\n\t}\n\n\tnewUrls := 0\n\tif depth > 1 {\n\t\tfor _, u := range urls {\n\t\t\tif !visited[u] {\n\t\t\t\tnewUrls++\n\t\t\t\tgo Crawl(u, depth-1, fetcher, ch, errs, visited)\n\t\t\t}\n\t\t}\n\t}\n\n\t// Send the result along with number of urls to be fetched\n\tch <- Res{url, body, newUrls}\n\n\treturn\n}", "func Crawl(url string, depth int, fetcher crawler.Fetcher, visitUrl func(string, string)) {\n\t// TODO: Fetch URLs in parallel.\n\t// TODO: Don't fetch the same URL twice.\n\t// This implementation doesn't do either:\n\tif depth <= 0 {\n\t\treturn\n\t}\n\tbody, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tvisitUrl(url, body)\n\tfor _, u := range urls {\n\t\tCrawl(u, depth-1, fetcher, visitUrl)\n\t}\n\treturn\n}", "func (e *Exporter) scrape(ch chan<- prometheus.Metric) {\n\te.totalScrapes.Inc()\n\tvar err error\n\tdefer func(begun time.Time) {\n\t\te.duration.Set(time.Since(begun).Seconds())\n\t\tif err == nil {\n\t\t\te.error.Set(0)\n\t\t} else {\n\t\t\te.error.Set(1)\n\t\t}\n\t}(time.Now())\n\n\tfor _, fw := range e.folderWatcher {\n\t\tlog.Println(\"reporting \", fw.filesCreated, fw.filesModified, fw.filesDeleted)\n\n\t\t// race conditions waiting here...\n\t\te.filesCreated.WithLabelValues(cleanName(fw.path)).Add(float64(fw.filesCreated))\n\t\tfw.filesCreated = 0\n\t\te.filesModified.WithLabelValues(cleanName(fw.path)).Add(float64(fw.filesModified))\n\t\tfw.filesModified = 0\n\t\te.filesDeleted.WithLabelValues(cleanName(fw.path)).Add(float64(fw.filesDeleted))\n\t\tfw.filesDeleted = 0\n\t\te.filesInPath.WithLabelValues(cleanName(fw.path)).Set(float64(fw.CountFilesInPath()))\n\t}\n\n\te.up.Set(1)\n}", "func (s *schedulesCrawler) Visit(ctx *gocrawl.URLContext, res *http.Response, doc *goquery.Document) (interface{}, bool) {\n\tscheduleID := convertToScheduleID(ctx.URL().Path)\n\tscheduleTimes := getScheduleTimes(doc)\n\t(*s.schedules)[scheduleID] = scheduleTimes\n\treturn nil, false\n}", "func doCrawl(url string, depth int, fetcher Fetcher) {\n\tif depth <= 0 {\n\t\treturn\n\t}\n\n\tif keeper.getOrAdd(url) {\n\n\t\tbody, urls, err := fetcher.Fetch(url)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\treturn\n\t\t}\n\t\turlChannel <- Document{url: url, body: body}\n\t\t// fmt.Printf(\"found: %s %q\\n\", url, body)\n\t\tfor _, u := range urls {\n\t\t\tdoCrawl(u, depth-1, fetcher)\n\t\t}\n\t} else {\n\t\tfmt.Printf(\" SKIPPING already processed: %s\\n\", url)\n\t}\n\treturn\n}", "func crawl(\n\tfetcher Fetcher, initUrl *url.URL, out chan<- Page, follower Follower,\n) {\n\tlogger.Info(\"Starting crawl\", \"url\", initUrl)\n\n\tunexplored := sync.WaitGroup{}\n\tunexplored.Add(1)\n\n\t// Seed the work queue.\n\tpending := make(chan Task, 100)\n\tpending <- Task{initUrl, 0}\n\n\t// Request pending, and requeue discovered pages.\n\tgo func() {\n\t\tfor task := range pending {\n\t\t\tgo func(task Task) {\n\t\t\t\tlogger.Debug(\"Starting\", \"url\", task.URL)\n\t\t\t\tpage := fetcher.Fetch(&task)\n\t\t\t\tout <- page\n\n\t\t\t\tfor _, link := range page.Links {\n\t\t\t\t\tif err := follower.Follow(link); err != nil {\n\t\t\t\t\t\tlogger.Debug(\"Not following link\", \"link\", link, \"reason\", err)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tunexplored.Add(1)\n\t\t\t\t\t\tpending <- LinkTask(link)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tunexplored.Done()\n\t\t\t}(task)\n\t\t}\n\t}()\n\n\t// Tie eveything off so that we exit clearly.\n\tunexplored.Wait()\n\tclose(pending)\n}", "func worker(cr *Crawler) {\n\tfor url := range cr.input {\n\t\tfmt.Println(url)\n\t\tcontent := downloadWebPage(url)\n\t\tsaveWebPage(cr, url, \"saved\", content)\n\t\tprepareChildWebPages(cr, cleanUrls(url, parseWebPage(url, string(content))))\n\t\tsaveWebPage(cr, url, \"done\", content)\n\t\tcr.availableWorkers++\n\t}\n}", "func Crawler(ticker string) {\n\t// Instantiate default collector\n\tc := colly.NewCollector(\n\t\tcolly.Async(true),\n\t)\n\t// On every a element which has href attribute call callback\n\tc.OnHTML(\"a[href]\", func(e *colly.HTMLElement) {\n\t\tlink := e.Attr(\"href\")\n\t\t// Print link\n\t\tfmt.Printf(\"Link found: %q -> %s\\n\", e.Text, link)\n\t})\n\t// Before making a request print \"Visiting ...\"\n\tc.OnRequest(func(r *colly.Request) {\n\t\tfmt.Println(\"Visiting\", r.URL.String())\n\t})\n\t// Start scraping\n\tc.Visit(wsjURL + ticker)\n\tc.Wait()\n}", "func NewScrape(cfg *domain.Config) *Scrape {\n\treturn &Scrape{\n\t\tcfg: cfg,\n\t}\n}", "func crawl(urlSet *concurrentStorage, ch chan url.URL){\n\tfor {\n\t\tselect {\n\t\tcase u := <- ch:\n\t\t\tif ok := urlSet.add(u); ok {\n\t\t\t\tlog.Printf(\"Received url=%s\", u.String())\n\t\t\t\turls, err := scrape(u)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Printf(\"Could not scrape url=%s.\\nError: %s\", u.String(), err)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\tfor _, url := range urls {\n\t\t\t\t\tgo \tfunc() {ch <- url}()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func (this *DefaultNode) StartCrawl() {\n\tgo this.Crawler.Start()\n}", "func (this *Reporter) Run() {\n\tlog.Println(\"start reporter\")\n\tfor {\n\t\tif this.IsPause() {\n\t\t\ttime.Sleep(1 * time.Second)\n\t\t\tcontinue\n\t\t}\n\t\tif this.Status != REPORT_STATUS_RUNNING {\n\t\t\tthis.Status = REPORT_STATUS_STOPED\n\t\t\tbreak\n\t\t}\n\t\tresult := this.ResultQuene.Pop()\n\t\tif result == nil {\n\t\t\ttime.Sleep(1 * time.Second)\n\t\t\tcontinue\n\t\t}\n\t\tnodeName := this.Node.NodeInfo.Name\n\t\tif result.ScrapedRequests != nil {\n\t\t\tfor _, request := range result.ScrapedRequests {\n\t\t\t\trequest.NodeName = nodeName\n\t\t\t}\n\t\t}\n\t\tlog.Println(result.Request.SpiderName, \":report request to master:\", result.Request.GoRequest.URL.String())\n\t\tif this.Node.IsMasterNode() {\n\t\t\tthis.Node.ReportToMaster(result)\n\t\t\tthis.JudgeAndStopNode()\n\t\t} else {\n\t\t\tthis.rpcClient.ReportResult(this.Node.GetMasterName(), result)\n\t\t}\n\t}\n\tlog.Println(\"stop reporter\")\n}", "func (f *Fetcher) handle(req *UrlRequest) {\n\t// get the crawler of the req, if not found return.\n\tcrawler := GetNodeInstance().GetCrawler(req.Crawler)\n\tclient := f.getClient(req)\n\t// set proxy for this client\n\tif req.Proxy != \"\" {\n\t\turl, _ := url.Parse(req.Url)\n\t\tclient.Transport = &http.Transport{\n\t\t\tProxy: http.ProxyURL(url),\n\t\t}\n\t} else {\n\t\t// use the default Transport\n\t\tclient.Transport = nil\n\t}\n\t// Set node name\n\treq.Node = GetNodeInstance().GetName()\n\trequest, err := req.ToRequest()\n\tif err != nil {\n\t\tError.Println(\"create request failed, \", err, req.Url)\n\t\treturn\n\t}\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tError.Println(\"http request error, \", err)\n\t\tif req.Retry < crawler.Retry {\n\t\t\treq.Incr()\n\t\t\tf.pop.push(req)\n\t\t\treturn\n\t\t} else {\n\t\t\tLog.Println(\"dropped url: \", req.Url)\n\t\t\treturn\n\t\t}\n\t}\n\tif response.StatusCode != 200 {\n\t\tLog.Println(\"status of the response: \", response.StatusCode)\n\t\treturn\n\t}\n\tStat.AddCrawledCount(req.Crawler)\n\tresp := NewResponse(req, response)\n\n\t// store the resp body\n\tif crawler.store != nil {\n\t\tgo crawler.store.Store(resp)\n\t}\n\t//Add the url to Redis, to mark as crawled\n\tredisCli := GetRedisClient().GetClient(req.Url)\n\tredisCli.SAdd(KeyForCrawlByDay(), req.Url)\n\tif req.Depth >= crawler.Depth {\n\t\tLog.Println(\"this request is reach the Max depth, so stop creating new requests\")\n\t\treturn\n\t}\n\tf.push.push(resp)\n}", "func Crawl(url string, depth int, fetcher Fetcher) {\n\n\tdefer func() { channel <- url }()\n\n\tif depth <= 0 {\n\t\treturn\n\t}\n\n\tbody, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tfmt.Printf(\"found: %s %q\\n\", url, body)\n\tmux.Lock()\n\turlmap[url]++\n\tvar newUrl = urlmap[url] == 1\n\tmux.Unlock()\n\tif newUrl {\n\t\tfor _, u := range urls {\n\t\t\tthreads++\n\t\t\tgo Crawl(u, depth-1, fetcher)\n\t\t}\n\t}\n\treturn\n}", "func scrapewebpages(selection *goquery.Selection, request *models.Request, movies *models.Result, wg *sync.WaitGroup) {\n\ttitle := selection.Find(\"td.titleColumn a\").Text()\n\trank := selection.Find(\"td.titleColumn\").Text()\n\tyear := selection.Find(\"td.titleColumn span\").Text()\n\trating := selection.Find(\"td.imdbRating strong\").Text()\n\tpath, ok := selection.Find(\"td.titleColumn a\").Attr(\"href\")\n\tvar duration, summary, genre string\n\t// Only if the Href value is present for the record.\n\tif ok {\n\t\t// Create new request instance for subdocument crawling.\n\t\tsubDocumentRequest := services.CreateRequest(request.GetURLScheme()+\"://\"+request.GetHostName()+path, 0)\n\t\t// Call the helper for with mechanism for calling request.\n\t\tsubDocument := subDocumentRequest.GetUrlResponse()\n\t\tduration = strings.TrimSpace(subDocument.Find(\"div.subtext time\").Text())\n\t\tsummary = strings.TrimSpace(subDocument.Find(\"div.summary_text\").Text())\n\t\tchildren := subDocument.Find(\"div.subtext\")\n\t\t// Extracting the data from 1 '|' and 3 '|' as genre in between them.\n\t\tSpan1 := children.Find(\"span.ghost\").Eq(1).NextAllFiltered(\"a\")\n\t\tSpan2 := children.Find(\"span.ghost\").Eq(2).PrevAllFiltered(\"a\")\n\t\ttext := Span1.Intersection(Span2).Text()\n\t\tpattern := regexp.MustCompile(\"[A-Z][a-z]+\")\n\t\tbyteSlice := pattern.FindAll([]byte(text), -1)\n\t\t// Multiple genres are joined together by comma in single string.\n\t\tgenre = string(bytes.Join(byteSlice, []byte(\", \")))\n\t}\n\n\t// To Get the movie instance with required data filled.\n\tmovie := services.GetMovieDetailsInstance(rank, title, year, rating, duration, summary, genre)\n\tmutex.Lock()\n\tmovies.AppendMovie(movie)\n\tmutex.Unlock()\n\twg.Done()\n}", "func Crawl(url string, depth int, f fetcher) {\n\tch := make(chan message)\n\tm := &mapSafe{m: make(map[string]byte)}\n\n\tgo crawl(url, depth, f, ch, m)\n\n\tvar r message\n\tcnt := 1\n\tfor {\n\t\tr = <-ch\n\t\tif !r.Nil() {\n\t\t\tfmt.Println(r)\n\t\t}\n\n\t\tcnt += r.Cnt - 1\n\t\tif cnt <= 0 {\n\t\t\treturn\n\t\t}\n\t}\n}", "func CrawlEachURLFound(url string, fetcher Fetcher, ch chan []string) {\n\tbody, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t} else {\n\t\tfmt.Printf(\"Found: %s %q\\n\", url, body)\n\t}\n\tch <- urls\n}", "func Crawl(url string, depth int, fetcher Fetcher) {\n\tvar wg sync.WaitGroup\n\t// This implementation doesn't do either:\n\tif depth <= 0 {\n\t\treturn\n\t}\n\t// Don't fetch the same URL twice\n\tif defaultCrawler.Crawled(url) {\n\t\treturn\n\t}\n\tbody, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefaultCrawler.MarkAsCrawled(url)\n\tfmt.Printf(\"found: %s %q\\n\", url, body)\n\tfor _, u := range urls {\n\t\t// Fetch URLs in parallel\n\t\twg.Add(1)\n\t\tgo func(u string) {\n\t\t\tdefer wg.Done()\n\t\t\tCrawl(u, depth-1, fetcher)\n\t\t}(u)\n\t}\n\twg.Wait()\n}", "func (s *Scout) Report(title string) error {\n\t// Heavily based on http://play.golang.org/p/65P0tZOZe0\n\tvar n int\n\tbuf := make([]byte, 1<<20) // 1 MB buffer\n\tfor i := 0; ; i++ {\n\t\tn = runtime.Stack(buf, true)\n\t\tif n < len(buf) {\n\t\t\tbuf = buf[:n]\n\t\t\tbreak\n\t\t}\n\t\tif len(buf) >= 64<<20 {\n\t\t\t// Filled 64 MB - stop here\n\t\t\tbreak\n\t\t}\n\t\tbuf = make([]byte, 2*len(buf))\n\t}\n\tvalues := url.Values{\n\t\t\"ScoutUserName\": {s.UserName},\n\t\t\"ScoutProject\": {s.Project},\n\t\t\"ScoutArea\": {s.Area},\n\t\t\"Description\": {s.Prefix + title},\n\t\t\"ForceNewBug\": {\"0\"},\n\t\t\"Extra\": {string(buf[:n])}, // stack trace\n\t\t\"Email\": {s.Email},\n\t\t\"ScoutDefaultMessage\": {s.ScoutDefaultMessage},\n\t\t\"FriendlyResponse\": {s.FriendlyResponse},\n\t}\n\tresp, err := http.PostForm(s.URL, values)\n\tif err != nil {\n\t\tlog.Print(err)\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\treturn nil\n}", "func (this *MyPageProcesser) Process(p *page.Page) {\n\tif !p.IsSucc() {\n\t\tprintln(p.Errormsg())\n\t\treturn\n\t}\n\tvar crawok bool\n\tcrawok = false\n\t//query := p.GetHtmlParser()\n\t//var urls []string\n\n\t//fmt.Println(p.GetBodyStr())\n\tre := regexp.MustCompile(`<a href=\"(.*?)\">(.*?)`)\n\n\tsectUrlsTemp := re.FindAllSubmatch([]byte(p.GetBodyStr()), -1)\n\n\tfor _, url := range sectUrlsTemp {\n\t\tfor _, url1 := range url {\n\t\t\tcrawok = true\n\n\t\t\thttp_index := strings.Index(string(url1), \"http://shinichr.diandian.com\")\n\n\t\t\thttp_note := strings.Index(string(url1), \"\\\"\")\n\t\t\thttp_quote := strings.Index(string(url1), \"#\")\n\n\t\t\tif http_index >= 0 && http_quote < 0 {\n\t\t\t\tif http_note > 0 && http_note < http_index {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tvar http_url string\n\t\t\t\tif http_note <= 0 {\n\t\t\t\t\thttp_url = string(url1)[http_index:]\n\t\t\t\t} else {\n\t\t\t\t\thttp_url = string(url1)[http_index:http_note]\n\t\t\t\t}\n\n\t\t\t\tif this.visit_url[http_url] == 0 {\n\t\t\t\t\tthis.visit_url[http_url] = 1\n\n\t\t\t\t\tfmt.Println(\"####unvisited:\", http_url)\n\t\t\t\t\t//fmt.Println(\"###AddTargetRequest:\", http_url)\n\t\t\t\t\tp.AddTargetRequest(http_url, \"html\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif crawok == false {\n\t\tfmt.Println(\"crawl false:*****************\", p.GetRequest().GetUrl())\n\t\thttp_page := strings.Index(p.GetRequest().GetUrl(), \"http://shinichr.diandian.com/page\")\n\t\thttp_post := strings.Index(p.GetRequest().GetUrl(), \"http://shinichr.diandian.com/post\")\n\t\tfmt.Println(\"http_page:\", http_page, \"http_post:\", http_post)\n\t\tif http_page >= 0 || http_post >= 0 {\n\t\t\t//this.visit_url[p.GetRequest().GetUrl()] = 0\n\t\t\tp.AddTargetRequest(p.GetRequest().GetUrl(), \"html\")\n\t\t}\n\t}\n\thttp_index := strings.Index(p.GetRequest().GetUrl(), \"http://shinichr.diandian.com/post/\")\n\n\t//\trex, _ := regexp.Compile(\"\\\\/\")\n\t//replaceurl := rex.ReplaceAllString(p.GetRequest().GetUrl(), \".\")\n\t//fmt.Println(\"http_index=\", http_index)\n\t//fmt.Println(\"replaceurl=\", p.GetRequest().GetUrl()[http_index:], \"....\", http_index)\n\tif http_index >= 0 {\n\n\t\tcuturl := p.GetRequest().GetUrl()[34:]\n\t\t//fmt.Println(\"replaceurl=\", cuturl)\n\t\trex, _ := regexp.Compile(\"\\\\/\")\n\t\treplaceurl := rex.ReplaceAllString(cuturl, \".\")\n\n\t\tfiledir := fmt.Sprintf(\"/home/shinichr/diandian_post/%s\", replaceurl)\n\n\t\tfout, err := os.Create(filedir)\n\t\tif err != nil {\n\t\t\tfmt.Println(filedir, err)\n\t\t\treturn\n\t\t}\n\t\tdefer fout.Close()\n\n\t\tsrc := p.GetBodyStr()\n\t\tre, _ := regexp.Compile(\"\\\\<[\\\\S\\\\s]+?\\\\>\")\n\t\tsrc = re.ReplaceAllStringFunc(src, strings.ToLower)\n\n\t\t//去除STYLE\n\t\tre, _ = regexp.Compile(\"\\\\<style[\\\\S\\\\s]+?\\\\</style\\\\>\")\n\t\tsrc = re.ReplaceAllString(src, \"\")\n\n\t\t//去除SCRIPT\n\t\tre, _ = regexp.Compile(\"\\\\<script[\\\\S\\\\s]+?\\\\</script\\\\>\")\n\t\tsrc = re.ReplaceAllString(src, \"\")\n\n\t\t//去除所有尖括号内的HTML代码,并换成换行符\n\t\tre, _ = regexp.Compile(\"\\\\<[\\\\S\\\\s]+?\\\\>\")\n\t\tsrc = re.ReplaceAllString(src, \"\\n\")\n\n\t\t//去除连续的换行符\n\t\tre, _ = regexp.Compile(\"\\\\s{2,}\")\n\t\tsrc = re.ReplaceAllString(src, \"\\n\")\n\n\t\t//fmt.Println(strings.TrimSpace(src))\n\n\t\tfout.WriteString(html.UnescapeString(src))\n\t\tfmt.Println(\"save file \", filedir)\n\t}\n\t//query.Find(`div[class=\"rich-content] div[class=\"post\"] div[class=\"post-top\"] div[class=\"post-content post-text\"] a`).Each(func(i int, s *goquery.Selection) {\n\t/*query.Find(\"div.content\").Each(func(i int, s *goquery.Selection) {\n\t\thref, _ := s.Attr(\"href\")\n\t\thttp_index := strings.Index(href, \"http\")\n\t\thttp_url := href[http_index:]\n\n\t\t//fmt.Println(\"###url:\\n\", http_url, \"=\", this.visit_url[http_url])\n\t\t//this.newurl <- http_url\n\t\tif this.visit_url[http_url] == 0 {\n\t\t\tthis.visit_url[http_url] = 1\n\t\t\tfmt.Println(\"###AddTargetRequest:\", http_url)\n\t\t\tp.AddTargetRequest(http_url, \"html\")\n\t\t}\n\t\turls = append(urls, href)\n\t})*/\n\t// these urls will be saved and crawed by other coroutines.\n\t/*doc, _ := goquery.NewDocument(\"http://shinichr.diandian.com\")\n\n\tdoc.Find(\"a\").Each(func(i int, s *goquery.Selection) {\n\t\thref, _ := s.Attr(\"href\")\n\t\tfmt.Println(\"####href=\", href)\n\t})*/\n\t//p.AddField(\"readme\", readme)\n}", "func Crawl(url string, depth int, fetcher Fetcher,\n\tstartCrawl func(string) bool, crawlComplete chan string) {\n\n\tif depth <= 0 {\n\t\tcrawlComplete <- url\n\t\treturn\n\t}\n\n\tbody, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tcrawlComplete <- url\n\t\treturn\n\t}\n\n\tfmt.Printf(\"found: %s %q\\n\", url, body)\n\tfor _, u := range urls {\n\t\tif startCrawl(u) {\n\t\t\tgo Crawl(u, depth-1, fetcher, startCrawl, crawlComplete)\n\t\t}\n\t}\n\tcrawlComplete <- url\n}", "func crawl(src string, srcID int64, parentID int64, ch chan UrlData, chFinished chan bool) {\n\t//Retrieve the webpage\n\tresp, err := http.Get(src)\n\n\tdefer func() {\n\t\t// Notify that we're done after this function\n\t\tchFinished <- true\n\t}()\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\t// fmt.Println(\"ERROR: Failed to crawl \\\"\" + src + \"\\\"\")\n\t\treturn\n\t}\n\n\turlResult := UrlData{sourceUrl: src, sourceID: srcID}\n\n\tb := resp.Body\n\tdefer b.Close() // close Body when the function returns\n\n\t//Open a secondary stream\n\n\tres, err := http.Get(src)\n\n\tc := res.Body\n\tdefer c.Close()\n\n\thtmlData, err := ioutil.ReadAll(c)\n\n\tif err != nil {\n\t\tfmt.Println(\"Error cannot open\")\n\t\treturn\n\t}\n\n\t// Get page size in bytes\n\turlResult.pageSize = len(htmlData)\n\t// Get raw HTML\n\turlResult.rawHTML = string(htmlData)\n\n\ttimeString, err := getLastModifiedTime(src)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\turlResult.lastModified = timeString\n\n\tz := html.NewTokenizer(b)\n\n\tfor {\n\t\ttt := z.Next()\n\n\t\tswitch {\n\t\tcase tt == html.ErrorToken:\n\t\t\t// End of the document, we're done, increment explored pages and return result\n\t\t\tch <- urlResult\n\t\t\tfeedToIndexer(src, srcID, &urlResult, parentID)\n\t\t\texploredPages++\n\t\t\treturn\n\t\tcase tt == html.StartTagToken:\n\t\t\tt := z.Token()\n\n\t\t\t// Check the token tags\n\t\t\tif t.Data == \"a\" {\n\t\t\t\t// Extract the href value, if there is one\n\t\t\t\tok, url := getHref(t)\n\t\t\t\tif !ok {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\t//Fix the URL into a absolute and valid form\n\t\t\t\turl = fixURL(url, src)\n\t\t\t\t// Make sure the url begins in http**\n\t\t\t\thasProto := strings.Index(url, \"http\") == 0\n\t\t\t\tif hasProto && len(url) > 0 {\n\t\t\t\t\turlResult.foundUrl = append(urlResult.foundUrl, url)\n\t\t\t\t}\n\t\t\t} else if t.Data == \"title\" {\n\t\t\t\tfor {\n\t\t\t\t\t//Extract the title tag content\n\t\t\t\t\tt := z.Next()\n\t\t\t\t\tif t == html.TextToken {\n\t\t\t\t\t\tu := z.Token()\n\t\t\t\t\t\turlResult.pageTitle += u.Data\n\t\t\t\t\t} else if t == html.EndTagToken {\n\t\t\t\t\t\tu := z.Token()\n\t\t\t\t\t\tif u.Data == \"title\" {\n\t\t\t\t\t\t\t//Finished, end extraction\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t}\n}", "func Crawl(url string, depth int, fetcher Fetcher) {\n\t// The implementation of Fetch URLs in parallel done\n\t// The implementation of \"Don't fetch the same URL twice.\" is done\n\tdefer wg.Done()\n\tvisitedUrls.RLock()\n\t_, visited := visitedUrls.urls[url]\n\tvisitedUrls.RUnlock()\n\n\tif visited {\n\t\treturn\n\t}\n\tif depth <= 0 {\n\t\treturn\n\t}\n\n\tbody, urls, err := fetcher.Fetch(url)\n\tvisitedUrls.Lock()\n\tvisitedUrls.urls[url] = true\n\tvisitedUrls.Unlock()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tfmt.Printf(\"found: %s %q\\n\", url, body)\n\tfor _, u := range urls {\n\t\twg.Add(1)\n\t\tgo Crawl(u, depth-1, fetcher)\n\t}\n\treturn\n}", "func Scrape(searchTerm string, shortURL string) ([]Structure, error) {\r\n\r\n\tmURL := buildURL(searchTerm, shortURL)\r\n\r\n\tresponse, err := request(mURL)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\tScrapes, err := resultParser(response, shortURL)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\treturn Scrapes, nil\r\n}", "func visit(url string) {\n\n\tc := getCollector()\n\n\tpage := GetPage(url)\n\tloge := log.WithFields(log.Fields{\n\t\t\"Site\": url,\n\t\t\"State\": page.State,\n\t})\n\tloge.Infoln(\"Entered visit .. \")\n\n\t// OnRequest is called just before the request is sent, we will create\n\t// our page\n\tc.OnRequest(func(r *colly.Request) {\n\t\tpage.Start = time.Now()\n\t\tpage.State = PageStateVisiting\n\t\tloge.Infof(\" onRequest page starts now \")\n\t})\n\n\t// OnHTML+a[href] matches <a href=\"link\">e.Text</a> tags\n\tc.OnHTML(\"a[href]\", func(e *colly.HTMLElement) {\n\t\turl := e.Attr(\"href\")\n\t\tif url == \"\" {\n\t\t\treturn\n\t\t}\n\t\tloge.Infoln(\" link found \", url)\n\t\tif p := purifyAndFilter(url); p != nil {\n\t\t\tloge.Infof(\" new visit request \", p.URL)\n\t\t\te.Request.Visit(p.URL)\n\t\t}\n\t})\n\n\tlog.Infoln(\"Visit URL \", page.URL)\n\tc.Visit(page.URL)\n\n\tt := time.Now()\n\tloge.Infof(\" visit complete after %v \", time.Since(t))\n\tloge.Infoln(\" waiting for threads ...\")\n\tc.Wait()\n\tloge.Infof(\"The wait is over after %v GoodBYE!!!\", time.Since(t))\n}", "func Crawl(url string, depth int, fetcher Fetcher) {\n\t// Fetch URLs in parallel.\n\t// Don't fetch the same URL twice.\n\n\tn := 3\n\tworkToDoCh := make(chan data, 10)\n\tworkDoneCh := make(chan data, 10)\n\tdoneCh := make(chan bool, 1)\n\tquitCh := make(chan bool, 1)\n\n\tgo broker(workToDoCh, workDoneCh, doneCh)\n\n\tfor i := 0; i < n; i++ {\n\t\tgo worker(i+1, workToDoCh, workDoneCh, quitCh)\n\t}\n\n\tworkToDoCh <- data{url: url, depth: depth}\n\n\t<-doneCh\n\tfor i := 0; i < n; i++ {\n\t\tquitCh <- true\n\t}\n\ttime.Sleep(10 * time.Millisecond)\n}", "func Crawl(url string, depth int, fetcher Fetcher) {\n\t// TODO: Fetch URLs in parallel.\n\t// TODO: Don't fetch the same URL twice.\n\n\tdefer wg.Done()\n\t\n\tif depth <= 0 {\n\t\treturn\n\t}\n\t\n\tcache.mux.Lock()\n\tcache.visited[url] = true\n\tcache.mux.Unlock()\n\t\n\tbody, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tfmt.Printf(\"found: %s %q\\n\", url, body)\n\tfor _, u := range urls {\n\t\n\t\tcache.mux.Lock()\n\t\tif !cache.visited[u] {\n\t\t\twg.Add(1)\n\t\t\tgo Crawl(u, depth-1, fetcher)\n\t\t}\n\t\tcache.mux.Unlock()\n\t}\n}", "func Scrape(url string) string {\n\tre := regexp.MustCompile(`([\\w-]+)\\/([\\w-]+$)`)\n\tmatch := re.FindStringSubmatch(url)\n\tprogram := match[2]\n\tendpoint := \"https://api.yeswehack.com/programs/\" + program\n\n\t// clear global slice\n\tscope = nil\n\n\t// GET request to endpoint\n\tresp, status := req.GET(endpoint)\n\n\t// check bad status code\n\tif status != 200 {\n\t\terrors.BadStatusCode(url, status)\n\t}\n\n\t// map interfaces\n\tm := map[string]interface{}{}\n\n\t// unmarshal\n\terr := json.Unmarshal([]byte(resp), &m)\n\t_ = err\n\n\t// check for errors\n\tif err != nil {\n\t\terrors.BadJSON()\n\t}\n\n\t// parse map\n\tparseMap(m)\n\n\t// throw error if scope array is empty\n\tif scope == nil {\n\t\terrors.NoScope(url)\n\t}\n\n\treturn strings.Join(scope, \"\\n\")\n}", "func Crawl(url string, depth int, fetcher Fetcher, ch chan int) {\r\n\t// TODO: Fetch URLs in parallel.\r\n\t// TODO: Don't fetch the same URL twice.\r\n\t// This implementation doesn't do either:\r\n\r\n\tif cache.crawled(url) {\r\n\t\tch <- 1\r\n\t\treturn \r\n\t}\r\n\r\n\tif depth <= 0 {\r\n\t\tch <- 1\r\n\t\treturn\r\n\t}\r\n\r\n\tbody, urls, err := fetcher.Fetch(url)\r\n\tif err != nil {\r\n\t\tfmt.Println(err)\r\n\t\tch <- 1\r\n\t\treturn\r\n\t}\r\n\tfmt.Printf(\"found: %s %q\\n\", url, body)\r\n\r\n\tctl := make(chan int)\r\n\tcounter := 0\r\n\tfor _, u := range urls {\r\n\t\tgo Crawl(u, depth-1, fetcher, ctl)\r\n\t\tcounter++\r\n\t}\r\n\tfor i := 0; i < counter; i++ {\r\n\t\t<-ctl\r\n\t}\r\n\tch <- 1\r\n\treturn\r\n}", "func Crawl(wg *sync.WaitGroup, url string, depth int, fetcher Fetcher, output chan string) {\n\tdefer wg.Done()\n\t// TODO: Fetch URLs in parallel.\n\tif depth <= 0 {\n\t\treturn\n\t}\n\n\tbody, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\toutput <- err.Error()\n\t\treturn\n\t}\n\n\toutput <- fmt.Sprintf(\"found: %s %q\", url, body)\n\tfor _, u := range urls {\n\t\twg.Add(1)\n\t\tgo Crawl(wg, u, depth-1, fetcher, output)\n\t}\n\treturn\n}", "func crawl(url string, ch chan string, chFinished chan bool) {\n\tresp, err := http.Get(url)\n\n\tdefer func() {\n\t// Notify that we're done after this function\n\tchFinished <- true\n\t}()\n\n\tif err != nil {\n\tfmt.Println(\"ERROR: Failed to crawl \\\"\" + url + \"\\\"\")\n\treturn\n\t}\n\n\tb := resp.Body\n\tdefer b.Close() // close Body when the function returns\n\n\tz := html.NewTokenizer(b)\n\n\tfor {\n\ttt := z.Next()\n\n\tswitch {\n\tcase tt == html.ErrorToken:\n\t\t// End of the document, we're done\n\t\treturn\n\tcase tt == html.StartTagToken:\n\t\tt := z.Token()\n\n\t\t// Check if the token is an <a> tag\n\t\tisAnchor := t.Data == \"a\"\n\t\tif !isAnchor {\t\tcontinue\n\t\t}\n\n\t\tvar url string\n\n\t\t// Extract the href value, if there is one\n\t\tfor _, a := range t.Attr {\n\t\tif a.Key == \"href\" {\n\t\t\turl = a.Val\n\t\t\tbreak\n\t\t}\n\t\t}\n\n\t\tif len(string(url)) > 8 {\n\t\t\tif string(url)[:7] == \"/detail\" {\n\t\t\t\tch <- strings.Replace(url, \"#akce\", \"\", -1)\n\t\t\t}\n\t\t}\n\t}\n\t}\n}", "func Crawl(url string, depth int, fetcher Fetcher, cache *Cache) {\n\t// TODO: Fetch URLs in parallel.\n\t// TODO: Don't fetch the same URL twice.\n\t// This implementation doesn't do either:\n\tif depth <= 0 {\n\t\treturn\n\t}\n\n\t// determine if fetched\n\tif cache.Fetched(url) {\n\t\tlog.Println(\"url is fetched\", url)\n\t\treturn\n\t}\n\n\tbody, urls, err := fetcher.Fetch(url)\n\t// construct CrawlResult\n\tcr := CrawlResult{url, body, urls, err}\n\tcache.Add(cr)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tfmt.Printf(\"found: %s %q\\n\", url, body)\n\n\tfor _, u := range urls {\n\t\t// goroutine\n\t\tgo Crawl(u, depth-1, fetcher, cache)\n\t}\n\treturn\n}", "func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tproxyTotal.WithLabelValues().Inc()\n\tstopReason := p.getCurCfg().ExtraConfig.StopScrapeReason\n\n\tjob, hashStr, realURL := translateURL(*r.URL)\n\tjobInfo := p.getJob(job)\n\tif jobInfo == nil {\n\t\tp.log.Errorf(\"can not found job client of %s\", job)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\thash, err := strconv.ParseUint(hashStr, 10, 64)\n\tif err != nil {\n\t\tp.log.Errorf(\"unexpected hash string %s\", hashStr)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\ttar := p.getStatus()[hash]\n\n\tstart := time.Now()\n\tvar scrapErr error\n\tdefer func() {\n\t\tif scrapErr != nil {\n\t\t\tp.log.Errorf(scrapErr.Error())\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tif tar != nil {\n\t\t\t\ttar.LastScrapeStatistics = scrape.NewStatisticsSeriesResult()\n\t\t\t}\n\t\t} else if stopReason != \"\" {\n\t\t\tp.log.Warnf(stopReason)\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tscrapErr = fmt.Errorf(stopReason)\n\t\t}\n\n\t\tif tar != nil {\n\t\t\ttar.ScrapeTimes++\n\t\t\ttar.SetScrapeErr(start, scrapErr)\n\t\t}\n\t}()\n\n\tscraper := scrape.NewScraper(jobInfo, realURL.String(), p.log)\n\tif stopReason == \"\" {\n\t\tscraper.WithRawWriter(w)\n\t}\n\n\tif err := scraper.RequestTo(); err != nil {\n\t\tscrapErr = fmt.Errorf(\"RequestTo %s %s %v\", job, realURL.String(), err)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", scraper.HTTPResponse.Header.Get(\"Content-Type\"))\n\n\trs := scrape.NewStatisticsSeriesResult()\n\tif err := scraper.ParseResponse(func(rows []parser.Row) error {\n\t\tscrape.StatisticSeries(rows, jobInfo.Config.MetricRelabelConfigs, rs)\n\t\treturn nil\n\t}); err != nil {\n\t\tscrapErr = fmt.Errorf(\"copy data to prometheus failed %v\", err)\n\t\tif time.Since(start) > time.Duration(jobInfo.Config.ScrapeTimeout) {\n\t\t\tscrapErr = fmt.Errorf(\"scrape timeout\")\n\t\t}\n\t\treturn\n\t}\n\n\tproxySeries.WithLabelValues(jobInfo.Config.JobName, realURL.String()).Set(float64(rs.ScrapedTotal))\n\tproxyScrapeDurtion.WithLabelValues(jobInfo.Config.JobName, realURL.String()).Set(float64(time.Now().Sub(start)))\n\tif tar != nil {\n\t\ttar.UpdateScrapeResult(rs)\n\t}\n}", "func crawl(url string, depth int, fetcher Fetcher, r *result) {\n\tif depth <= 0 {\n\t\tr.Give(url)\n\t\treturn\n\t}\n\tbody, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\tr.Error(url)\n\t\treturn\n\t}\n\tfor _, u := range urls {\n\t\tif r.Take(u) {\n\t\t\tgo crawl(u, depth-1, fetcher, r)\n\t\t}\n\t}\n\tr.Add(url, body)\n}", "func (c *Creepy) callCrawlers() {\n\tfor _, crawler := range c.Crawlers {\n\t\tsi, err := crawler.Crawl()\n\t\tif err != nil {\n\t\t\tc.logger.Error(err)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Index the searchitems\n\t\tc.Searcher.Index(si...)\n\t}\n}", "func scrape(u url.URL) ([]url.URL, error) {\n\n\tif strings.Trim(u.String(), \" \") == \"\"{\n\t\treturn []url.URL{}, errors.New(\"empty url\")\n\t}\n\n\tpageReadCloser, err := getHttp(u)\n\tdefer pageReadCloser.Close()\n\tif err != nil {\n\t\tlog.Printf(\"failed to get pageReadCloser at u=%s. err=%s\\n\", u, err)\n\t\treturn []url.URL{}, nil\n\t}\n\n\tpage, err := ioutil.ReadAll(pageReadCloser)\n\tif err != nil {\n\t\tlog.Printf(\"Could not read page buffer for url=%s\\n\", u.String())\n\t\treturn []url.URL{}, err\n\t}\n\n\tsavePage(u, page)\n\n\turls, err := getUrls(page, u.Host)\n\tif err != nil {\n\t\tlog.Printf(\"failed to extract valid urls for pageReadCloser at u=%s. err=%s\\n\", u, err)\n\t\treturn []url.URL{}, err\n\t}\n\n\treturn urls, nil\n}", "func Crawl(url string, depth int, fetcher Ffetcher) {\n\t// TODO: Fetch URLs in parallel.\n\tif depth <= 0 {\n\t\treturn\n\t}\n\t_, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\tfor _, u := range urls {\n\t\tfmt.Printf(\"from: [%s], fetching: [%s]\\n\", url, u)\n\t\tCrawl(u, depth-1, fetcher)\n\t}\n\n\treturn\n}", "func Crawl(crawler spider.Spiderer) http.HandlerFunc {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\ttarget := r.URL.Query().Get(targetParam)\n\t\t// Check params provided\n\t\tif target == \"\" {\n\t\t\tapi.Error(w, \"The target URL field 'target' is required.\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\n\t\turi, err := url.Parse(target)\n\t\tif err != nil {\n\t\t\tapi.Error(w, fmt.Sprintf(\"'%s' is not a valid URL\", target), http.StatusBadRequest)\n\t\t}\n\n\t\terr = crawler.Crawl(uri.Host, target)\n\t\tif err != nil {\n\t\t\tapi.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t}\n\n\t\tw.WriteHeader(http.StatusOK)\n\t})\n}", "func Crawl(url string, depth int, fetcher Fetcher, g *sync.WaitGroup) {\r\n\t// Fetch URLs in parallel.\r\n\t// Don't fetch the same URL twice.\r\n\tdefer g.Done()\r\n\r\n\tif depth <= 0 {\r\n\t\treturn\r\n\t}\r\n\tm.Mark(url)\r\n\t\r\n\tbody, urls, err := fetcher.Fetch(url)\r\n\tif err != nil {\r\n\t\tfmt.Println(err)\r\n\t\treturn\r\n\t}\r\n\tfmt.Printf(\"found: %s %q\\n\", url, body)\r\n\tfor _, u := range urls {\r\n\t\tif m.Already(u){\r\n\t\t\tcontinue\r\n\t\t}\r\n\t\tg.Add(1)\r\n\t\tgo Crawl(u, depth-1, fetcher, g)\r\n\t}\r\n\treturn\r\n}", "func Scrape(url string) string {\n\tvar scope []string\n\tre := regexp.MustCompile(`([\\w-]+)\\/([\\w-]+$)`)\n\tmatch := re.FindStringSubmatch(url)\n\tprogram := match[2]\n\tendpoint := \"https://bugbounty.jp/program/\" + program\n\n\t// GET request to endpoint\n\trespBody, _ := req.GET(endpoint)\n\n\t// parse response body to xQuery doc\n\tdoc, _ := htmlquery.Parse(strings.NewReader(respBody))\n\n\t// xQuery to grab scope section\n\tresp := htmlquery.Find(doc, \"//dt[contains(text(), 'Scope')]/following-sibling::dd[@class='targetDesc']\")\n\n\t// get scope contents\n\tif resp != nil {\n\t\tfor _, item := range resp {\n\t\t\tscope = append(scope, htmlquery.InnerText(item))\n\t\t}\n\t} else {\n\t\terrors.NoScope(url)\n\t}\n\n\treturn strings.Join(scope, \"\\n\")\n}", "func Crawl(url string, depth int, fetcher Fetcher) {\n\tif depth <= 0 {\n\t\treturn\n\t}\n\n\tvisitedSafe.Lock()\n\tif visitedSafe.IsVisited(url) {\n\t\tvisitedSafe.Unlock()\n\t\treturn\n\t}\n\tvisitedSafe.AddVisit(url)\n\tvisitedSafe.Unlock()\n\n\tbody, urls, err := fetcher.Fetch(url)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tfmt.Printf(\"found: %s %q\\n\", url, body)\n\n\tcomplete := make(chan bool)\n\n\tfor _, u := range urls {\n\t\tgo func(url string) {\n\t\t\tCrawl(url, depth-1, fetcher)\n\t\t\tcomplete <- true\n\t\t}(u)\n\t}\n\n\tfor range urls {\n\t\t<-complete\n\t}\n\n\treturn\n}", "func (c *Crawler) Crawl(baseUrl string, callbackFunc func(*FoundUrls)) {\n\tw := newCrawlWorker(c, baseUrl, callbackFunc)\n\tc.crawlInternal(w)\n}", "func Crawl(url string, depth int, fetcher Fetcher, parentChan chan struct{}, resultsChan chan graphNode, startTime time.Time, urlMap *SafeMap) {\n\t// Once we're done we inform our parent\n\tdefer func() {\n\t\tparentChan <- struct{}{}\n\t}()\n\n\tif depth <= 0 {\n\t\treturn\n\t}\n\n\t// First we check if this url has already been visited\n\tif urlMap.flip(url) {\n\t\treturn\n\t}\n\t_, urls, err := fetcher.Fetch(url)\n\n\tif err != nil {\n\t\t// If we can't find the url, return (future iterations)\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tresultsChan <- graphNode{Parent: url, Children: urls, TimeFound: time.Since(startTime), Depth: depth}\n\n\t// fmt.Printf(\"Crawling: %s %q, child length: %d\\n\", url, body, len(urls))\n\n\tdoneCh := make(chan struct{}, len(urls))\n\n\tnumToExplore := len(urls)\n\n\tfor _, u := range urls {\n\n\t\tgo Crawl(u, depth-1, fetcher, doneCh, resultsChan, startTime, urlMap)\n\t}\n\n\tnumFin := 0\n\tfor {\n\t\tif numFin >= numToExplore {\n\t\t\tbreak\n\t\t}\n\t\t<-doneCh\n\t\tnumFin++\n\n\t}\n\tclose(doneCh)\n\treturn\n}", "func main() {\n\t// Create a HTTP client with Timeout\n\tclient := &http.Client {\n\t\tTimeout: 30 * time.Second,\n\t}\n\n\t// Define a Request in order to change the Header but\n\t// not send it yet.\n\trequest, err := http.NewRequest(\"GET\", \"http://webscraper.io/test-sites/e-commerce/allinone\", nil)\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\t// Now that the Request is defined, override the Header!\n\trequest.Header.Set(\"User-Agent\", \"MyScraperBot v1.0 https://www.github.com/gitCMDR/\")\n\n\tfmt.Println(request)\n\t// Now let's make a Request\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer response.Body.Close()\n\n\n\t// Print the response to StdOut\n\t_, err = io.Copy(os.Stdout, response.Body)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n}", "func Crawl(\n\tendpoint string,\n\tapproximateMaxNodes int32,\n\tparallelism int,\n\tmsDelay int,\n\tisValidCrawlLink IsValidCrawlLinkFunction,\n\taddEdgesIfDoNotExist AddEdgeFunction,\n\tfilterPage FilterPageFunction,\n) {\n\t// Instantiate default collector\n\tc := colly.NewCollector(\n\t\tcolly.Async(true),\n\t\tcolly.CacheDir(\"/tmp/crawlercache\"),\n\t)\n\tc.Limit(&colly.LimitRule{\n\t\tDomainGlob: \"*\",\n\t\tParallelism: parallelism,\n\t\tDelay: time.Duration(msDelay) * time.Millisecond,\n\t})\n\n\tc.OnError(func(r *colly.Response, err error) {\n\t\tlogErr(\"Error parsing page %s: %v\", r.Request.URL, err)\n\t})\n\n\t// On every a element which has href attribute call callback\n\tc.OnHTML(\"html\", func(e *colly.HTMLElement) {\n\t\tlogMsg(\"parsing %s\", e.Request.URL.String())\n\t\t// find specific portion in page, if needed\n\t\tfilteredPage, err := filterPage(e)\n\t\tif err != nil {\n\t\t\tlogErr(\"Could not filter page %s, %v\", e.Request.URL.String(), err)\n\t\t}\n\t\t// loop through all href attributes adding links\n\t\tvalidURLs := []string{}\n\t\tfilteredPage.ForEach(\"a[href]\", func(_ int, e *colly.HTMLElement) {\n\t\t\t// add links which match the schema\n\t\t\tlink := e.Attr(\"href\")\n\t\t\tif isValidCrawlLink(link) {\n\t\t\t\tvalidURLs = append(validURLs, link)\n\t\t\t}\n\t\t})\n\t\tlogMsg(\"found %v neighbors for %v\", len(validURLs), e.Request.URL.String())\n\t\t// add new nodes to current request URL\n\t\tnodesAdded, err := addEdgesIfDoNotExist(e.Request.URL.String(), validURLs)\n\t\tif err != nil {\n\t\t\tlogErr(\"error adding '%s': %s\", e.Request.URL.String(), err.Error())\n\t\t} else {\n\t\t\t// update metrics\n\t\t\tUpdateMetrics(len(nodesAdded), e.Request.Depth)\n\t\t}\n\t\t// stopping condition\n\t\tif approximateMaxNodes != -1 && (totalNodesAdded.get() >= approximateMaxNodes) {\n\t\t\tlogMsg(\"Stopping condition reached: %v nodes added >= %v approximateMaxNodes\", totalNodesAdded.get(), approximateMaxNodes)\n\t\t\tos.Exit(0)\n\t\t\treturn\n\t\t}\n\t\t// recurse on new nodes if no stopping condition yet\n\t\tfor _, url := range nodesAdded {\n\t\t\terr = filteredPage.Request.Visit(url)\n\t\t\tif err != nil {\n\t\t\t\tlogWarn(\"Error visiting '%s', %v\", url, err)\n\t\t\t}\n\t\t}\n\t})\n\t// Start scraping on endpoint\n\tlogMsg(\"starting at %s\", endpoint)\n\tc.Visit(endpoint)\n\t// Wait until threads are finished\n\tc.Wait()\n}", "func (ScrapeVserver) Scrape(netappClient *netapp.Client, ch chan<- prometheus.Metric) error {\n\n\tfor _, VserverInfo := range GetVserverData(netappClient) {\n\t\tvserverLabelValues := append(BaseLabelValues, VserverInfo.VserverName, VserverInfo.VserverType)\n\t\tch <- prometheus.MustNewConstMetric(VServerVolumeDeleteRetentionHoursDesc, prometheus.GaugeValue, float64(VserverInfo.VolumeDeleteRetentionHours), vserverLabelValues...)\n\t\tif len(VserverInfo.State) > 0 {\n\t\t\tif stateVal, ok := parseStatus(VserverInfo.State); ok {\n\t\t\t\tch <- prometheus.MustNewConstMetric(VServerAdminStateDesc, prometheus.GaugeValue, stateVal, vserverLabelValues...)\n\t\t\t}\n\t\t}\n\t\tif len(VserverInfo.OperationalState) > 0 {\n\t\t\tif opsStateVal, ok := parseStatus(VserverInfo.OperationalState); ok {\n\t\t\t\tch <- prometheus.MustNewConstMetric(VServerOperationalStateDesc, prometheus.GaugeValue, opsStateVal, vserverLabelValues...)\n\t\t\t}\n\t\t}\n\n\t}\n\treturn nil\n}", "func (ScrapeStatusAccount) Scrape(ctx context.Context, db *sql.DB, ch chan<- prometheus.Metric, logger log.Logger) error {\n\tglobalStatusRows, err := db.QueryContext(ctx, statusAccountQuery)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer globalStatusRows.Close()\n\n\tvar user, host, key string\n\tvar val uint64\n\n\tfor globalStatusRows.Next() {\n\t\tif err := globalStatusRows.Scan(&user, &host, &key, &val); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tch <- prometheus.MustNewConstMetric(StatusAccountDesc, prometheus.CounterValue, float64(val), user, host, strings.ToLower(key))\n\t}\n\n\treturn nil\n}", "func (c *Crawler) Run() error {\n\tif !c.ignoreRobotsTxt {\n\t\terr := c.robotsInit()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tc.queue = make(chan url.URL)\n\tdefer close(c.queue)\n\n\tc.results = make(chan Page)\n\tdefer close(c.results)\n\n\tc.pool.Start()\n\tc.addJob(c.url)\n\n\tc.waitForResults()\n\tc.cleanUpResults()\n\n\tc.generateLinksFrom()\n\n\treturn nil\n}", "func (reporter *ProgressReporter) sendUpdates() {\n\tb := reporter.serialize()\n\tfmt.Println(string(b))\n\tgo reporter.postProgressToURL(b)\n}", "func main() {\n\n\tlog.SetOutput(os.Stdout)\n\n\ttoCrawl, _ := url.Parse(\"http://www.monzo.com\")\n\tvar filter crawler.Restriction = func(url *url.URL) bool {\n\t\treturn url.Host == toCrawl.Host\n\t}\n\tvar op1 crawler.Operation = func(in *url.URL) *url.URL {\n\t\tif in != nil {\n\t\t\thashIndex := strings.Index(in.String(), \"#\")\n\t\t\tif hashIndex > 0 {\n\t\t\t\tout, err := url.Parse(in.String()[:hashIndex])\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn in\n\t\t\t\t}\n\t\t\t\treturn out\n\t\t\t}\n\t\t}\n\t\treturn in\n\t}\n\n\twg := sync.WaitGroup{}\n\twg.Add(1)\n\tout := make(chan model.CrawlerOutput, 100)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tfor each := range out {\n\t\t\tconsumer.CreateSiteMap(path, each.URL, each.PageLinks, each.ResponseBody)\n\t\t}\n\t}()\n\tdone := make(chan struct{})\n\n\tc := crawler.NewCrawler(nil, crawler.Setting{\n\t\tRestrictions: []crawler.Restriction{filter},\n\t\tOperation: op1,\n\t\tWaitTimes: 100 * time.Millisecond,\n\t\tWorkers: 10,\n\t\tGetResponseBody: true,\n\t})\n\tgo c.Crawl(toCrawl, out, done)\n\n\tselect {\n\tcase <-time.After(10 * time.Second):\n\t\tdone <- struct{}{}\n\t}\n\twg.Wait()\n}", "func Crawl(url_str string, fetcher fetcher.Fetcher, sitemap *sitemap.Sitemap) {\n\tlog.Debug(\"Crawling: \", url_str)\n\n\tif sitemap.Contains(url_str) {\n\t\tlog.Debug(url_str, \" already visited\")\n\t\treturn\n\t}\n\n\tsitemap.MarkVisited(url_str)\n\n\tcurrent_url, err := url.Parse(url_str)\n\n\tif err != nil {\n\t\tlog.Warning(\"Unable to get URL of \", url_str, err)\n\n\t\tsitemap.SetError(url_str, err)\n\t\treturn\n\t}\n\n\tresponse, err := fetcher.Get(url_str)\n\n\tif err != nil {\n\t\tlog.Warning(\"Unable to fetch from \", url_str, err)\n\n\t\tsitemap.SetError(url_str, err)\n\t\treturn\n\t}\n\n\tlinks, err := parser.ExtractLinksWithCurrentHost(current_url, response)\n\n\tif err != nil {\n\t\tlog.Warning(\"Unable to extract links from \", url_str, err)\n\n\t\tsitemap.SetError(url_str, err)\n\t\treturn\n\t}\n\n\tsitemap.SetLinks(url_str, links)\n\n\tcrawlChilderLinks(links, fetcher, sitemap)\n}" ]
[ "0.6658562", "0.6417914", "0.61811036", "0.6163045", "0.6151265", "0.6086038", "0.6052761", "0.5954972", "0.59331214", "0.5889761", "0.57729805", "0.5772844", "0.57702506", "0.57451177", "0.57327914", "0.5702998", "0.56800026", "0.5679486", "0.56670076", "0.5659346", "0.5642536", "0.56379867", "0.55854666", "0.5569749", "0.5542479", "0.5530319", "0.5528835", "0.55116296", "0.5487364", "0.54799503", "0.54777104", "0.54432815", "0.5415007", "0.5408141", "0.53924996", "0.53900373", "0.5389104", "0.5364686", "0.5344608", "0.52977735", "0.52970976", "0.5287773", "0.52797246", "0.5271032", "0.52593446", "0.52444303", "0.52393436", "0.52293986", "0.52142185", "0.5192668", "0.51758116", "0.51640403", "0.51591897", "0.51586527", "0.5154536", "0.51526374", "0.515139", "0.51482964", "0.5141158", "0.5133562", "0.51289064", "0.51270056", "0.5125169", "0.5113051", "0.5110846", "0.51014173", "0.5099211", "0.5092624", "0.5090522", "0.50892264", "0.5086514", "0.5080144", "0.5076782", "0.50752133", "0.50632095", "0.50601834", "0.50574505", "0.5056308", "0.5052625", "0.5052582", "0.5047574", "0.504536", "0.50431794", "0.502905", "0.5024741", "0.50234497", "0.50223565", "0.5021591", "0.50149757", "0.5011847", "0.5007169", "0.49994493", "0.4999147", "0.49874642", "0.49787992", "0.4975302", "0.49706337", "0.49697158", "0.49649698", "0.49577194" ]
0.64453244
1
build state function that will check if a job responsible for building function image succeeded or failed; if a job is not running start one
func buildStateFnCheckImageJob(expectedJob batchv1.Job) stateFn { return func(ctx context.Context, r *reconciler, s *systemState) (stateFn, error) { labels := s.internalFunctionLabels() err := r.client.ListByLabel(ctx, s.instance.GetNamespace(), labels, &s.jobs) if err != nil { return nil, errors.Wrap(err, "while listing jobs") } jobLen := len(s.jobs.Items) if jobLen == 0 { return buildStateFnInlineCreateJob(expectedJob), nil } jobFailed := s.jobFailed(backoffLimitExceeded) conditionStatus := getConditionStatus( s.instance.Status.Conditions, serverlessv1alpha2.ConditionBuildReady, ) if jobFailed && conditionStatus == corev1.ConditionFalse { return stateFnInlineDeleteJobs, nil } if jobFailed { r.result = ctrl.Result{ RequeueAfter: time.Minute * 5, Requeue: true, } condition := serverlessv1alpha2.Condition{ Type: serverlessv1alpha2.ConditionBuildReady, Status: corev1.ConditionFalse, LastTransitionTime: metav1.Now(), Reason: serverlessv1alpha2.ConditionReasonJobFailed, Message: fmt.Sprintf("Job %s failed, it will be re-run", s.jobs.Items[0].Name), } return buildStatusUpdateStateFnWithCondition(condition), nil } s.image = s.buildImageAddress(r.cfg.docker.PullAddress) jobChanged := s.fnJobChanged(expectedJob) if !jobChanged { return stateFnCheckDeployments, nil } if jobLen > 1 || !equalJobs(s.jobs.Items[0], expectedJob) { return stateFnInlineDeleteJobs, nil } expectedLabels := expectedJob.GetLabels() if !mapsEqual(s.jobs.Items[0].GetLabels(), expectedLabels) { return buildStateFnInlineUpdateJobLabels(expectedLabels), nil } return stateFnUpdateJobStatus, nil } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (st *buildStatus) start() {\n\tsetStatus(st.BuilderRev, st)\n\tgo func() {\n\t\terr := st.build()\n\t\tif err == errSkipBuildDueToDeps {\n\t\t\tst.setDone(true)\n\t\t} else {\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintf(st, \"\\n\\nError: %v\\n\", err)\n\t\t\t\tlog.Println(st.BuilderRev, \"failed:\", err)\n\t\t\t}\n\t\t\tst.setDone(err == nil)\n\t\t\tpool.CoordinatorProcess().PutBuildRecord(st.buildRecord())\n\t\t}\n\t\tmarkDone(st.BuilderRev)\n\t}()\n}", "func checkForJobSuccess(org, repo string, targetBuildNum int, client *circleci.Client) (err error) {\n\tcheckAttempts := 0\n\tcheckLimit := 60\n\tcheckInterval := 5 * time.Second\n\tlogger.Infof(\"Polling CircleCI for status of build: %d\", targetBuildNum)\n\tfor {\n\t\tvar build *circleci.Build\n\t\tif build, err = client.GetBuild(org, repo, targetBuildNum); err != nil {\n\t\t\treturn\n\t\t}\n\t\tif build.Status == \"success\" {\n\t\t\tlogger.Infof(\"Detected success of CircleCI build: %d\", targetBuildNum)\n\t\t\tbreak\n\t\t} else if build.Status == \"failed\" {\n\t\t\treturn fmt.Errorf(\"CircleCI job: %d has failed\", targetBuildNum)\n\t\t}\n\t\tcheckAttempts++\n\t\tif checkAttempts == checkLimit {\n\t\t\treturn fmt.Errorf(\"Unable to verify CircleCI job was a success: https://circleci.com/gh/%s/%s/%d\",\n\t\t\t\torg, repo, targetBuildNum)\n\t\t}\n\t\ttime.Sleep(checkInterval)\n\t}\n\treturn\n}", "func tryBuild(funcBinary string, runtime string, template string, builderImg string) error {\n\tscript := fmt.Sprintf(`set -ex\ncd $(mktemp -d)\n%[1]s create fn%[2]s%[3]s --runtime %[2]s --template %[3]s\ncd fn%[2]s%[3]s\n%[1]s build --builder %[4]s -v`, funcBinary, runtime, template, builderImg)\n\treturn runBash(script)\n}", "func CfnJob_IsConstruct(x interface{}) *bool {\n\t_init_.Initialize()\n\n\tvar returns *bool\n\n\t_jsii_.StaticInvoke(\n\t\t\"aws-cdk-lib.aws_glue.CfnJob\",\n\t\t\"isConstruct\",\n\t\t[]interface{}{x},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "func Check(conf *config.Config, queue *Queue, running *Running, manager manager.Driver) error {\n\tlog.Println(\"Checking for a job to run\")\n\tlog.Println(\"Queue: \", *queue)\n\trunning.Watch(&manager)\n\tnext := queue.Pop(running, conf.Server.MaxBuilds)\n\tif next != nil {\n\t\tlog.Println(\"About to build: \", next.Project, next.Branch)\n\t\tfor i := range conf.Projects {\n\t\t\tif next.Project == conf.Projects[i].Name {\n\t\t\t\tshouldDeploy := false\n\t\t\t\tlog.Println(\"Found a job to run\")\n\t\t\t\tfor j := range conf.Projects[i].DeployBranches {\n\t\t\t\t\tif next.Branch == conf.Projects[i].DeployBranches[j] {\n\t\t\t\t\t\tlog.Println(\"Will Deploy\")\n\t\t\t\t\t\tshouldDeploy = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconfPath := conf.Projects[i].MaestroConfPath\n\t\t\t\tlog.Println(\"Running build\")\n\t\t\t\trunErr := manager.Run(\n\t\t\t\t\tfmt.Sprintf(\"%s-%s-%s\", next.Project, next.Branch, next.CurrCommit),\n\t\t\t\t\tconfDir(confPath),\n\t\t\t\t\tconfDir(confPath),\n\t\t\t\t\t[]string{\n\t\t\t\t\t\t\"maestro\",\n\t\t\t\t\t\tfmt.Sprintf(\"--branch=%s\", next.Branch),\n\t\t\t\t\t\tfmt.Sprintf(\"--deploy=%v\", shouldDeploy),\n\t\t\t\t\t\tfmt.Sprintf(\"--prev-commit=%s\", next.PrevCommit),\n\t\t\t\t\t\tfmt.Sprintf(\"--curr-commit=%s\", next.CurrCommit),\n\t\t\t\t\t\tfmt.Sprintf(\"--config=%s\", confPath),\n\t\t\t\t\t\tfmt.Sprintf(\"--clone-path=%s\", conf.Server.WorkspaceDir),\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t\treturn runErr\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (builder *Layered) Build(config *api.Config) (*api.Result, error) {\n\tbuildResult := &api.Result{}\n\n\tif config.HasOnBuild && config.BlockOnBuild {\n\t\tbuildResult.BuildInfo.FailureReason = utilstatus.NewFailureReason(\n\t\t\tutilstatus.ReasonOnBuildForbidden,\n\t\t\tutilstatus.ReasonMessageOnBuildForbidden,\n\t\t)\n\t\treturn buildResult, errors.New(\"builder image uses ONBUILD instructions but ONBUILD is not allowed\")\n\t}\n\n\tif config.BuilderImage == \"\" {\n\t\tbuildResult.BuildInfo.FailureReason = utilstatus.NewFailureReason(\n\t\t\tutilstatus.ReasonGenericS2IBuildFailed,\n\t\t\tutilstatus.ReasonMessageGenericS2iBuildFailed,\n\t\t)\n\t\treturn buildResult, errors.New(\"builder image name cannot be empty\")\n\t}\n\n\tif err := builder.CreateDockerfile(config); err != nil {\n\t\tbuildResult.BuildInfo.FailureReason = utilstatus.NewFailureReason(\n\t\t\tutilstatus.ReasonDockerfileCreateFailed,\n\t\t\tutilstatus.ReasonMessageDockerfileCreateFailed,\n\t\t)\n\t\treturn buildResult, err\n\t}\n\n\tglog.V(2).Info(\"Creating application source code image\")\n\ttarStream := builder.tar.CreateTarStreamReader(filepath.Join(config.WorkingDir, \"upload\"), false)\n\tdefer tarStream.Close()\n\n\tnewBuilderImage := fmt.Sprintf(\"s2i-layered-temp-image-%d\", time.Now().UnixNano())\n\n\toutReader, outWriter := io.Pipe()\n\topts := docker.BuildImageOptions{\n\t\tName: newBuilderImage,\n\t\tStdin: tarStream,\n\t\tStdout: outWriter,\n\t\tCGroupLimits: config.CGroupLimits,\n\t}\n\tdocker.StreamContainerIO(outReader, nil, func(s string) { glog.V(2).Info(s) })\n\n\tglog.V(2).Infof(\"Building new image %s with scripts and sources already inside\", newBuilderImage)\n\tstartTime := time.Now()\n\terr := builder.docker.BuildImage(opts)\n\tbuildResult.BuildInfo.Stages = api.RecordStageAndStepInfo(buildResult.BuildInfo.Stages, api.StageBuild, api.StepBuildDockerImage, startTime, time.Now())\n\tif err != nil {\n\t\tbuildResult.BuildInfo.FailureReason = utilstatus.NewFailureReason(\n\t\t\tutilstatus.ReasonDockerImageBuildFailed,\n\t\t\tutilstatus.ReasonMessageDockerImageBuildFailed,\n\t\t)\n\t\treturn buildResult, err\n\t}\n\n\t// upon successful build we need to modify current config\n\tbuilder.config.LayeredBuild = true\n\t// new image name\n\tbuilder.config.BuilderImage = newBuilderImage\n\t// see CreateDockerfile, conditional copy, location of scripts\n\tscriptsIncluded := checkValidDirWithContents(path.Join(config.WorkingDir, constants.UploadScripts))\n\tglog.V(2).Infof(\"Scripts dir has contents %v\", scriptsIncluded)\n\tif scriptsIncluded {\n\t\tbuilder.config.ScriptsURL = \"image://\" + path.Join(getDestination(config), \"scripts\")\n\t} else {\n\t\tvar err error\n\t\tbuilder.config.ScriptsURL, err = builder.docker.GetScriptsURL(newBuilderImage)\n\t\tif err != nil {\n\t\t\tbuildResult.BuildInfo.FailureReason = utilstatus.NewFailureReason(\n\t\t\t\tutilstatus.ReasonGenericS2IBuildFailed,\n\t\t\t\tutilstatus.ReasonMessageGenericS2iBuildFailed,\n\t\t\t)\n\t\t\treturn buildResult, err\n\t\t}\n\t}\n\n\tglog.V(2).Infof(\"Building %s using sti-enabled image\", builder.config.Tag)\n\tstartTime = time.Now()\n\terr = builder.scripts.Execute(constants.Assemble, config.AssembleUser, builder.config)\n\tbuildResult.BuildInfo.Stages = api.RecordStageAndStepInfo(buildResult.BuildInfo.Stages, api.StageAssemble, api.StepAssembleBuildScripts, startTime, time.Now())\n\tif err != nil {\n\t\tbuildResult.BuildInfo.FailureReason = utilstatus.NewFailureReason(\n\t\t\tutilstatus.ReasonAssembleFailed,\n\t\t\tutilstatus.ReasonMessageAssembleFailed,\n\t\t)\n\t\tswitch e := err.(type) {\n\t\tcase s2ierr.ContainerError:\n\t\t\treturn buildResult, s2ierr.NewAssembleError(builder.config.Tag, e.Output, e)\n\t\tdefault:\n\t\t\treturn buildResult, err\n\t\t}\n\t}\n\tbuildResult.Success = true\n\n\treturn buildResult, nil\n}", "func (st *buildStatus) start() {\n\tsetStatus(st.builderRev, st)\n\tgo func() {\n\t\terr := st.build()\n\t\tif err != nil {\n\t\t\tfmt.Fprintf(st, \"\\n\\nError: %v\\n\", err)\n\t\t\tlog.Println(st.builderRev, \"failed:\", err)\n\t\t}\n\t\tst.setDone(err == nil)\n\t\tst.buildRecord().put()\n\t\tmarkDone(st.builderRev)\n\t}()\n}", "func (pkgw *packageWatcher) build(buildCache *cache.Cache, srcpkg *crd.Package) {\n\n\t// Ignore non-pending state packages.\n\tif srcpkg.Status.BuildStatus != fission.BuildStatusPending {\n\t\treturn\n\t}\n\n\t// Ignore duplicate build requests\n\tkey := fmt.Sprintf(\"%v-%v\", srcpkg.Metadata.Name, srcpkg.Metadata.ResourceVersion)\n\terr, _ := buildCache.Set(key, srcpkg)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer buildCache.Delete(key)\n\n\tlog.Printf(\"Start build for package %v with resource version %v\", srcpkg.Metadata.Name, srcpkg.Metadata.ResourceVersion)\n\n\tpkg, err := updatePackage(pkgw.fissionClient, srcpkg, fission.BuildStatusRunning, \"\", nil)\n\tif err != nil {\n\t\te := fmt.Sprintf(\"Error setting package pending state: %v\", err)\n\t\tlog.Println(e)\n\t\tupdatePackage(pkgw.fissionClient, srcpkg, fission.BuildStatusFailed, e, nil)\n\t\treturn\n\t}\n\n\tenv, err := pkgw.fissionClient.Environments(pkg.Spec.Environment.Namespace).Get(pkg.Spec.Environment.Name)\n\tif errors.IsNotFound(err) {\n\t\tupdatePackage(pkgw.fissionClient, pkg,\n\t\t\tfission.BuildStatusFailed, \"Environment not existed\", nil)\n\t\treturn\n\t}\n\n\t// Do health check for environment builder pod\n\tfor i := 0; i < 15; i++ {\n\t\t// Informer store is not able to use label to find the pod,\n\t\t// iterate all available environment builders.\n\t\titems := pkgw.podStore.List()\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error retrieving pod information for env %v: %v\", err, env.Metadata.Name)\n\t\t\treturn\n\t\t}\n\n\t\tif len(items) == 0 {\n\t\t\tlog.Printf(\"Environment \\\"%v\\\" builder pod is not existed yet, retry again later.\", pkg.Spec.Environment.Name)\n\t\t\ttime.Sleep(time.Duration(i*1) * time.Second)\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, item := range items {\n\t\t\tpod := item.(*apiv1.Pod)\n\n\t\t\t// In order to support backward compatibility, for all builder images created in default env,\n\t\t\t// the pods will be created in fission-builder namespace\n\t\t\tbuilderNs := pkgw.builderNamespace\n\t\t\tif env.Metadata.Namespace != metav1.NamespaceDefault {\n\t\t\t\tbuilderNs = env.Metadata.Namespace\n\t\t\t}\n\n\t\t\t// Filter non-matching pods\n\t\t\tif pod.ObjectMeta.Labels[LABEL_ENV_NAME] != env.Metadata.Name ||\n\t\t\t\tpod.ObjectMeta.Labels[LABEL_ENV_NAMESPACE] != builderNs ||\n\t\t\t\tpod.ObjectMeta.Labels[LABEL_ENV_RESOURCEVERSION] != env.Metadata.ResourceVersion {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Pod may become \"Running\" state but still failed at health check, so use\n\t\t\t// pod.Status.ContainerStatuses instead of pod.Status.Phase to check pod readiness states.\n\t\t\tpodIsReady := true\n\n\t\t\tfor _, cStatus := range pod.Status.ContainerStatuses {\n\t\t\t\tpodIsReady = podIsReady && cStatus.Ready\n\t\t\t}\n\n\t\t\tif !podIsReady {\n\t\t\t\tlog.Printf(\"Environment \\\"%v\\\" builder pod is not ready, retry again later.\", pkg.Spec.Environment.Name)\n\t\t\t\ttime.Sleep(time.Duration(i*1) * time.Second)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// Add the package getter rolebinding to builder sa\n\t\t\t// we continue here if role binding was not setup succeesffully. this is because without this, the fetcher wont be able to fetch the source pkg into the container and\n\t\t\t// the build will fail eventually\n\t\t\terr := fission.SetupRoleBinding(pkgw.k8sClient, fission.PackageGetterRB, pkg.Metadata.Namespace, fission.PackageGetterCR, fission.ClusterRole, fission.FissionBuilderSA, builderNs)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Error : %v in setting up the role binding %s for pkg : %s.%s\", err, fission.PackageGetterRB, pkg.Metadata.Name, pkg.Metadata.Namespace)\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"Setup rolebinding for sa : %s.%s for pkg : %s.%s\", fission.FissionBuilderSA, builderNs, pkg.Metadata.Name, pkg.Metadata.Namespace)\n\t\t\t}\n\n\t\t\tctx := context.Background()\n\t\t\tuploadResp, buildLogs, err := buildPackage(ctx, pkgw.fissionClient, builderNs, pkgw.storageSvcUrl, pkg)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Error building package %v: %v\", pkg.Metadata.Name, err)\n\t\t\t\tupdatePackage(pkgw.fissionClient, pkg, fission.BuildStatusFailed, buildLogs, nil)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlog.Printf(\"Start updating info of package: %v\", pkg.Metadata.Name)\n\n\t\t\tfnList, err := pkgw.fissionClient.\n\t\t\t\tFunctions(metav1.NamespaceAll).List(metav1.ListOptions{})\n\t\t\tif err != nil {\n\t\t\t\te := fmt.Sprintf(\"Error getting function list: %v\", err)\n\t\t\t\tlog.Println(e)\n\t\t\t\tbuildLogs += fmt.Sprintf(\"%v\\n\", e)\n\t\t\t\tupdatePackage(pkgw.fissionClient, pkg, fission.BuildStatusFailed, buildLogs, nil)\n\t\t\t}\n\n\t\t\t// A package may be used by multiple functions. Update\n\t\t\t// functions with old package resource version\n\t\t\tfor _, fn := range fnList.Items {\n\t\t\t\tif fn.Spec.Package.PackageRef.Name == pkg.Metadata.Name &&\n\t\t\t\t\tfn.Spec.Package.PackageRef.Namespace == pkg.Metadata.Namespace &&\n\t\t\t\t\tfn.Spec.Package.PackageRef.ResourceVersion != pkg.Metadata.ResourceVersion {\n\t\t\t\t\tfn.Spec.Package.PackageRef.ResourceVersion = pkg.Metadata.ResourceVersion\n\t\t\t\t\t// update CRD\n\t\t\t\t\t_, err = pkgw.fissionClient.Functions(fn.Metadata.Namespace).Update(&fn)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\te := fmt.Sprintf(\"Error updating function package resource version: %v\", err)\n\t\t\t\t\t\tlog.Println(e)\n\t\t\t\t\t\tbuildLogs += fmt.Sprintf(\"%v\\n\", e)\n\t\t\t\t\t\tupdatePackage(pkgw.fissionClient, pkg, fission.BuildStatusFailed, buildLogs, nil)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_, err = updatePackage(pkgw.fissionClient, pkg,\n\t\t\t\tfission.BuildStatusSucceeded, buildLogs, uploadResp)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Error update package info: %v\", err)\n\t\t\t\tupdatePackage(pkgw.fissionClient, pkg, fission.BuildStatusFailed, buildLogs, nil)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlog.Printf(\"Completed build request for package: %v\", pkg.Metadata.Name)\n\t\t\treturn\n\t\t}\n\t}\n\t// build timeout\n\tupdatePackage(pkgw.fissionClient, pkg,\n\t\tfission.BuildStatusFailed, \"Build timeout due to environment builder not ready\", nil)\n\n\tlog.Printf(\"Max retries exceeded in building the source pkg : %s.%s, timeout due to environment builder not ready\",\n\t\tpkg.Metadata.Name, pkg.Metadata.Namespace)\n\n\treturn\n}", "func (a *App) BuildImage(ctx context.Context, name, dockerfile string, tags []string) error {\n\ta.scheduler.mu.Lock()\n\tvar worker *Worker\n\t// TODO: find more available worker, not just first one.\n\tfor _, w := range a.scheduler.workers {\n\t\tworker = w\n\t\tbreak\n\t}\n\ta.scheduler.mu.Unlock()\n\n\tif worker == nil {\n\t\treturn fmt.Errorf(\"no worker available\")\n\t}\n\n\treturn worker.buildImage(ctx, name, dockerfile, tags)\n}", "func validateBuildRunToSucceed(testBuild *utils.TestBuild, testBuildRun *buildv1alpha1.BuildRun) {\n\ttrueCondition := corev1.ConditionTrue\n\tfalseCondition := corev1.ConditionFalse\n\n\t// Ensure the BuildRun has been created\n\terr := testBuild.CreateBR(testBuildRun)\n\tExpect(err).ToNot(HaveOccurred(), \"Failed to create BuildRun\")\n\n\t// Ensure a BuildRun eventually moves to a succeeded TRUE status\n\tnextStatusLog := time.Now().Add(60 * time.Second)\n\tEventually(func() corev1.ConditionStatus {\n\t\ttestBuildRun, err = testBuild.LookupBuildRun(types.NamespacedName{Name: testBuildRun.Name, Namespace: testBuild.Namespace})\n\t\tExpect(err).ToNot(HaveOccurred(), \"Error retrieving a buildRun\")\n\n\t\tif testBuildRun.Status.GetCondition(buildv1alpha1.Succeeded) == nil {\n\t\t\treturn corev1.ConditionUnknown\n\t\t}\n\n\t\tExpect(testBuildRun.Status.GetCondition(buildv1alpha1.Succeeded).Status).ToNot(Equal(falseCondition), \"BuildRun status doesn't move to Succeeded\")\n\n\t\tnow := time.Now()\n\t\tif now.After(nextStatusLog) {\n\t\t\tLogf(\"Still waiting for build run '%s' to succeed.\", testBuildRun.Name)\n\t\t\tnextStatusLog = time.Now().Add(60 * time.Second)\n\t\t}\n\n\t\treturn testBuildRun.Status.GetCondition(buildv1alpha1.Succeeded).Status\n\n\t}, time.Duration(1100*getTimeoutMultiplier())*time.Second, 5*time.Second).Should(Equal(trueCondition), \"BuildRun did not succeed\")\n\n\t// Verify that the BuildSpec is still available in the status\n\tExpect(testBuildRun.Status.BuildSpec).ToNot(BeNil(), \"BuildSpec is not available in the status\")\n\n\tLogf(\"Test build '%s' is completed after %v !\", testBuildRun.GetName(), testBuildRun.Status.CompletionTime.Time.Sub(testBuildRun.Status.StartTime.Time))\n}", "func (s *githubHook) buildStatus(eventType, commit string, payload []byte, proj *brigade.Project, status *github.RepoStatus) {\n\t// If we need an SSH key, set it here\n\tif proj.Repo.SSHKey != \"\" {\n\t\tkey, err := ioutil.TempFile(\"\", \"\")\n\t\tif err != nil {\n\t\t\tlog.Printf(\"error creating ssh key cache: %s\", err)\n\t\t\treturn\n\t\t}\n\t\tkeyfile := key.Name()\n\t\tdefer os.Remove(keyfile)\n\t\tif _, err := key.WriteString(proj.Repo.SSHKey); err != nil {\n\t\t\tlog.Printf(\"error writing ssh key cache: %s\", err)\n\t\t\treturn\n\t\t}\n\t\tos.Setenv(\"BRIGADE_REPO_KEY\", keyfile)\n\t\tdefer os.Unsetenv(\"BRIGADE_REPO_KEY\") // purely defensive... not really necessary\n\t}\n\n\tmsg := \"Building\"\n\tsvc := StatusContext\n\tstatus.State = &StatePending\n\tstatus.Description = &msg\n\tstatus.Context = &svc\n\tif err := s.createStatus(commit, proj, status); err != nil {\n\t\t// For this one, we just log an error and continue.\n\t\tlog.Printf(\"Error setting status to %s: %s\", *status.State, err)\n\t}\n\tif err := s.build(eventType, commit, payload, proj); err != nil {\n\t\tlog.Printf(\"Build failed: %s\", err)\n\t\tmsg = truncAt(err.Error(), 140)\n\t\tstatus.State = &StateFailure\n\t\tstatus.Description = &msg\n\t} else {\n\t\tmsg = \"Brigade build passed\"\n\t\tstatus.State = &StateSuccess\n\t\tstatus.Description = &msg\n\t}\n\tif err := s.createStatus(commit, proj, status); err != nil {\n\t\t// For this one, we just log an error and continue.\n\t\tlog.Printf(\"After build, error setting status to %s: %s\", *status.State, err)\n\t}\n}", "func (st *buildStatus) isTry() bool { return st.trySet != nil }", "func (r *ClusterInstallationReconciler) checkUpdateJob(\n\tmattermost *mattermostv1alpha1.ClusterInstallation,\n\tdesired *appsv1.Deployment,\n\treqLogger logr.Logger,\n) (*batchv1.Job, error) {\n\treqLogger.Info(fmt.Sprintf(\"Running Mattermost update image job check for image %s\", mattermost.GetMattermostAppContainerFromDeployment(desired).Image))\n\tjob, err := r.Resources.FetchMattermostUpdateJob(mattermost.Namespace)\n\tif err != nil {\n\t\t// Unable to fetch job\n\t\tif k8sErrors.IsNotFound(err) {\n\t\t\t// Job is not running, let's launch\n\t\t\treqLogger.Info(\"Launching update image job\")\n\t\t\tif err = r.Resources.LaunchMattermostUpdateJob(mattermost, mattermost.Namespace, desired, reqLogger, nil); err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"Launching update image job failed\")\n\t\t\t}\n\t\t\treturn nil, errors.New(\"Began update image job\")\n\t\t}\n\n\t\treturn nil, errors.Wrap(err, \"failed to determine if an update image job is already running\")\n\t}\n\n\t// Job is either running or completed\n\n\t// If desired deployment image does not match the one used by update job, restart it.\n\tisSameImage, err := r.isMainContainerImageSame(\n\t\tmattermost,\n\t\tdesired.Spec.Template.Spec.Containers,\n\t\tjob.Spec.Template.Spec.Containers,\n\t)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to compare image of update job and desired deployment\")\n\t}\n\tif !isSameImage {\n\t\treqLogger.Info(\"Mattermost image changed, restarting update job\")\n\t\terr := r.Resources.RestartMattermostUpdateJob(mattermost, job, desired, reqLogger, nil)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to restart update job\")\n\t\t}\n\n\t\treturn nil, errors.New(\"Restarted update image job\")\n\t}\n\n\tif job.Status.CompletionTime == nil {\n\t\treturn nil, errors.New(\"update image job still running\")\n\t}\n\n\t// Job is completed, can check completion status\n\n\tif job.Status.Failed > 0 {\n\t\treturn job, errors.New(\"update image job failed\")\n\t}\n\n\treqLogger.Info(\"Update image job ran successfully\")\n\n\treturn job, nil\n}", "func checkJobStatus(jobQueue *jobqueue.Client, t *jobqueue.Task) (bool, error) {\n\tif t.Job.Status != jobqueue.JobStatusNew {\n\t\treturn true, fmt.Errorf(\"bad job status: %s\", t.Job.Status)\n\t}\n\tif t.Job.Action != \"select-hypervisor\" {\n\t\treturn true, fmt.Errorf(\"bad action: %s\", t.Job.Action)\n\t}\n\treturn false, nil\n}", "func jobCompleted(job JobType) bool {\n\t// Call numerxData server to check the status of this job\n\t// return true if we get:\n\t// \t\t[“step”=”metaindexstatus”, “status”=”success”]\n\t//\tor [“step”=“eventindexstatus”, “status” = “success”]\n\t/*\n\t\t[\n\t\t\t{\"ID\":\"0.0.LqO~iOvJV3sdUOd8\",\"Step\":\"metaindexstatus\",\"Status\":\"success\",\"Timestamp\":1465589455508,\"Notes\":\"\"},\n\t\t\t{\"ID\":\"0.0.LqO~iOvJV3sdUOd8\",\"Step\":\"parsedmeta\",\"Status\":\"success\",\"Timestamp\":1465588843502,\"Notes\":\"\"},\n\t\t\t{\"ID\":\"0.0.LqO~iOvJV3sdUOd8\",\"Step\":\"rawmeta\",\"Status\":\"success\",\"Timestamp\":1465588543502,\"Notes\":\"\"}\n\t\t]\n\t*/\n\t// uri string, resource string, params map[string]string\n\tvar params map[string]string = make(map[string]string)\n\tparams[\"id\"] = job.JobId\n\trequest, err := fileUploadStatusRequest(baseUrl, \"/status\", params)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false // let the caller func to handle retries\n\t}\n\n\tif verbose {\n\t\tlog.Println(\"RQ URL: \", request.URL)\n\t\tlog.Println(\"RQ Headers: \", request.Header)\n\t\tlog.Println(\"RQ Body: \", request)\n\t}\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(request)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn false // let the caller func to handle retries\n\t} else {\n\t\t/* JSON\n\t\t[\n\t\t\t{\"ID\":\"0.0.LqO~iOvJV3sdUOd8\",\"Step\":\"metaindexstatus\",\"Status\":\"success\",\"Timestamp\":1465589455508,\"Notes\":\"\"},\n\t\t\t{\"ID\":\"0.0.LqO~iOvJV3sdUOd8\",\"Step\":\"parsedmeta\",\"Status\":\"success\",\"Timestamp\":1465588843502,\"Notes\":\"\"},\n\t\t\t{\"ID\":\"0.0.LqO~iOvJV3sdUOd8\",\"Step\":\"rawmeta\",\"Status\":\"success\",\"Timestamp\":1465588543502,\"Notes\":\"\"}\n\t\t]\n\t\t*/\n\t\tdefer resp.Body.Close()\n\n\t\tvar bodyContent []byte\n\t\tif verbose {\n\t\t\tlog.Println(\"Status RS Status: \", resp.StatusCode)\n\t\t\tlog.Println(\"Status RS Headers: \", resp.Header)\n\t\t}\n\n\t\tbodyContent, err := ioutil.ReadAll(resp.Body)\n\n\t\tif verbose {\n\t\t\tlog.Println(\"Status RS Content: error? :\", err)\n\t\t\tlog.Println(\"Status RS Content: body: bytes: \", bodyContent)\n\t\t\tlog.Println(\"Status RS Content: body: string: \", string(bodyContent))\n\t\t}\n\t\tif resp.StatusCode == 200 {\n\t\t\t// Check the step's status\n\t\t\tstatus, err := getStatusResponse(bodyContent)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Error %v while checking status for %v, file: %v \\n\", err, job.JobId, job.Filename)\n\t\t\t\treturn false // let the caller func to handle retries\n\t\t\t} else {\n\t\t\t\tswitch requestType {\n\t\t\t\tcase RQ_Viewership:\n\t\t\t\t\tfor _, entry := range status {\n\t\t\t\t\t\tswitch entry.Step {\n\t\t\t\t\t\tcase string(IndexEventData): // \"eventindexstatus\":\n\t\t\t\t\t\t\tswitch entry.Status {\n\t\t\t\t\t\t\tcase string(Success): // \"success\":\n\t\t\t\t\t\t\t\tif verbose {\n\t\t\t\t\t\t\t\t\tlog.Printf(\"Complete for: %s, file: %s\\n\", job.JobId, job.Filename)\n\t\t\t\t\t\t\t\t\tlog.Println(\"Current state: \", status)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\tcase string(Failure): // \"failure\":\n\t\t\t\t\t\t\t\tfailedJobsChan <- job\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase string(ParsedEventData), string(RawEventData):\n\t\t\t\t\t\t\tif entry.Status == string(Failure) {\n\t\t\t\t\t\t\t\tfailedJobsChan <- job\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif verbose {\n\t\t\t\t\t\tlog.Printf(\"Not yet: %s, file: %s\\n\", job.JobId, job.Filename)\n\t\t\t\t\t\tlog.Println(\"Current state: \", status)\n\t\t\t\t\t}\n\n\t\t\t\t//\t(actually the new struct with file-name, id, and retry-number)\n\t\t\t\tcase RQ_MetaBilling, RQ_MetaProgram, RQ_MetaChanMap, RQ_MetaEventMap:\n\t\t\t\t\tfor _, entry := range status {\n\t\t\t\t\t\tswitch entry.Step {\n\t\t\t\t\t\tcase string(IndexMetaData): // \"metaindexstatus\":\n\t\t\t\t\t\t\tswitch entry.Status {\n\t\t\t\t\t\t\tcase string(Success): // \"success\":\n\t\t\t\t\t\t\t\tif verbose {\n\t\t\t\t\t\t\t\t\tlog.Printf(\"Complete for: %s, file: %s\\n\", job.JobId, job.Filename)\n\t\t\t\t\t\t\t\t\tlog.Println(\"Current state: \", status)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\tcase string(Failure): // \"failure\":\n\t\t\t\t\t\t\t\tfailedJobsChan <- job\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tcase string(ParsedMetaData), string(RawMetaData):\n\t\t\t\t\t\t\tif entry.Status == string(Failure) {\n\t\t\t\t\t\t\t\tfailedJobsChan <- job\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif verbose {\n\t\t\t\t\t\tlog.Printf(\"Not yet: %s, file: %s\\n\", job.JobId, job.Filename)\n\t\t\t\t\t\tlog.Println(\"Current state: \", status)\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Println(\"Error Status %v while checking status for %v, file: %s \\n\", err, job.JobId, job.Filename)\n\t\t\tfailedJobsChan <- job\n\t\t\tif verbose {\n\t\t\t\tlog.Println(\"Error Status %v while checking status for %v, file: %s \\n\", err, job.JobId, job.Filename)\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (cc *ConfigsController) needsBuild(ctx context.Context, st store.RStore) (*ctrltiltfile.BuildEntry, bool) {\n\tstate := st.RLockState()\n\tdefer st.RUnlockState()\n\n\t// Don't start the next build until the previous action has been recorded,\n\t// so that we don't accidentally repeat the same build.\n\tif cc.loadStartedCount != state.StartedTiltfileLoadCount {\n\t\treturn nil, false\n\t}\n\n\t// Don't start the next build if the last completion hasn't been recorded yet.\n\tfor _, ms := range state.TiltfileStates {\n\t\tisRunning := !ms.CurrentBuild.StartTime.IsZero()\n\t\tif isRunning {\n\t\t\treturn nil, false\n\t\t}\n\t}\n\n\tfor _, name := range state.TiltfileDefinitionOrder {\n\t\ttf, ok := state.Tiltfiles[name.String()]\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\ttfState, ok := state.TiltfileStates[name]\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar reason model.BuildReason\n\t\tlastStartTime := tfState.LastBuild().StartTime\n\t\tif !tfState.StartedFirstBuild() {\n\t\t\treason = reason.With(model.BuildReasonFlagInit)\n\t\t}\n\n\t\thasPendingChanges, _ := tfState.HasPendingChanges()\n\t\tif hasPendingChanges {\n\t\t\treason = reason.With(model.BuildReasonFlagChangedFiles)\n\t\t}\n\n\t\tif state.UserConfigState.ArgsChangeTime.After(lastStartTime) {\n\t\t\treason = reason.With(model.BuildReasonFlagTiltfileArgs)\n\t\t}\n\n\t\tif state.ManifestInTriggerQueue(name) {\n\t\t\treason = reason.With(tfState.TriggerReason)\n\t\t}\n\n\t\tif reason == model.BuildReasonNone {\n\t\t\tcontinue\n\t\t}\n\n\t\tfilesChanged := []string{}\n\t\tfor _, st := range tfState.BuildStatuses {\n\t\t\tfor k := range st.PendingFileChanges {\n\t\t\t\tfilesChanged = append(filesChanged, k)\n\t\t\t}\n\t\t}\n\t\tfilesChanged = sliceutils.DedupedAndSorted(filesChanged)\n\n\t\treturn &ctrltiltfile.BuildEntry{\n\t\t\tName: name,\n\t\t\tFilesChanged: filesChanged,\n\t\t\tBuildReason: reason,\n\t\t\tUserConfigState: state.UserConfigState,\n\t\t\tTiltfilePath: tf.Spec.Path,\n\t\t\tCheckpointAtExecStart: state.LogStore.Checkpoint(),\n\t\t}, true\n\t}\n\n\treturn nil, false\n}", "func build() bool {\n\tlog.Println(okColor(\"Running build commands!\"))\n\n\tfor _, c := range flagBuildCommandList.commands {\n\t\terr := runBuildCommand(c)\n\t\tif err != nil {\n\t\t\tlog.Println(failColor(\"Command failed: \"), failColor(c))\n\t\t\treturn false\n\t\t}\n\t}\n\tlog.Println(okColor(\"Build ok.\"))\n\n\treturn true\n}", "func TestCannotExecuteStatusImage(t *testing.T) {\n\tbuf := setLogBuffer()\n\tdefer func() {\n\t\tif t.Failed() {\n\t\t\tt.Log(buf.String())\n\t\t}\n\t}()\n\n\tif StatusImage == \"\" {\n\t\tt.Skip(\"no status image defined\")\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\n\tapp := &models.App{Name: id.New().String()}\n\tapp = ensureApp(t, app)\n\n\tfn := &models.Fn{\n\t\tAppID: app.ID,\n\t\tName: id.New().String(),\n\t\tImage: StatusImage,\n\t\tResourceConfig: models.ResourceConfig{\n\t\t\tMemory: memory,\n\t\t},\n\t}\n\tfn = ensureFn(t, fn)\n\n\tlb, err := LB()\n\tif err != nil {\n\t\tt.Fatalf(\"Got unexpected error: %v\", err)\n\t}\n\tu := url.URL{\n\t\tScheme: \"http\",\n\t\tHost: lb,\n\t}\n\tu.Path = path.Join(u.Path, \"invoke\", fn.ID)\n\n\tcontent := bytes.NewBuffer([]byte(`status`))\n\toutput := &bytes.Buffer{}\n\n\tresp, err := callFN(ctx, u.String(), content, output, models.TypeSync)\n\tif err != nil {\n\t\tt.Fatalf(\"Got unexpected error: %v\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusBadRequest {\n\t\tt.Fatalf(\"StatusCode check failed on %v\", resp.StatusCode)\n\t}\n}", "func getCIJobStatus(outputFile, branch string, htmlize bool) error {\n\tvar result error\n\tlog.Print(\"Getting CI job status (this may take a while)...\")\n\n\tred := \"<span style=\\\"color:red\\\">\"\n\tgreen := \"<span style=\\\"color:green\\\">\"\n\toff := \"</span>\"\n\n\tif htmlize {\n\t\tred = \"<FONT COLOR=RED>\"\n\t\tgreen = \"<FONT COLOR=GREEN>\"\n\t\toff = \"</FONT>\"\n\t}\n\n\tvar extraFlag string\n\n\tif strings.Contains(branch, \"release-\") {\n\t\t// If working on a release branch assume --official for the purpose of displaying\n\t\t// find_green_build output\n\t\textraFlag = \"--official\"\n\t} else {\n\t\t// For master branch, limit the analysis to 30 primary ci jobs. This is necessary\n\t\t// due to the recently expanded blocking test list for master. The expanded test\n\t\t// list is often unable to find a complete passing set and find_green_build runs\n\t\t// unbounded for hours\n\t\textraFlag = \"--limit=30\"\n\t}\n\n\tf, err := os.OpenFile(outputFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif err = f.Close(); err != nil {\n\t\t\tresult = fmt.Errorf(\"failed to close file %s, %v\", outputFile, err)\n\t\t}\n\t}()\n\n\tf.WriteString(fmt.Sprintf(\"## State of %s branch\\n\", branch))\n\n\t// Call script find_green_build to get CI job status\n\tcontent, err := u.Shell(os.Getenv(\"GOPATH\")+\"/src/k8s.io/release/find_green_build\", \"-v\", extraFlag, branch)\n\tif err == nil {\n\t\tf.WriteString(fmt.Sprintf(\"%sGOOD TO GO!%s\\n\\n\", green, off))\n\t} else {\n\t\tf.WriteString(fmt.Sprintf(\"%sNOT READY%s\\n\\n\", red, off))\n\t}\n\n\tf.WriteString(\"### Details\\n```\\n\")\n\tf.WriteString(content)\n\tf.WriteString(\"```\\n\")\n\n\tlog.Print(\"CI job status fetched.\")\n\treturn result\n}", "func onRunIsResolved(target *api.Container, run *api.Container) bool {\n\tif target.DesiredStatus >= api.ContainerCreated {\n\t\treturn run.KnownStatus >= api.ContainerRunning\n\t}\n\treturn false\n}", "func (c *client) startNewJob(ctx context.Context, opts launcher.LaunchOptions, jobInterface v12.JobInterface, ns string, safeName string, safeSha string) ([]runtime.Object, error) {\n\tlog.Logger().Infof(\"about to create a new job for name %s and sha %s\", safeName, safeSha)\n\n\t// lets see if we are using a version stream to store the git operator configuration\n\tfolder := filepath.Join(opts.Dir, \"versionStream\", \"git-operator\")\n\texists, err := files.DirExists(folder)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to check if folder exists %s\", folder)\n\t}\n\tif !exists {\n\t\t// lets try the original location\n\t\tfolder = filepath.Join(opts.Dir, \".jx\", \"git-operator\")\n\t}\n\n\tjobFileName := \"job.yaml\"\n\n\tfileNamePath := filepath.Join(opts.Dir, \".jx\", \"git-operator\", \"filename.txt\")\n\texists, err = files.FileExists(fileNamePath)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to check for file %s\", fileNamePath)\n\t}\n\tif exists {\n\t\tdata, err := ioutil.ReadFile(fileNamePath)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to load file %s\", fileNamePath)\n\t\t}\n\t\tjobFileName = strings.TrimSpace(string(data))\n\t\tif jobFileName == \"\" {\n\t\t\treturn nil, errors.Errorf(\"the job name file %s is empty\", fileNamePath)\n\t\t}\n\t}\n\n\tfileName := filepath.Join(folder, jobFileName)\n\texists, err = files.FileExists(fileName)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to find file %s in repository %s\", fileName, safeName)\n\t}\n\tif !exists {\n\t\treturn nil, errors.Errorf(\"repository %s does not have a Job file: %s\", safeName, fileName)\n\t}\n\n\tresource := &v1.Job{}\n\terr = yamls.LoadFile(fileName, resource)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to load Job file %s in repository %s\", fileName, safeName)\n\t}\n\n\tif !opts.NoResourceApply {\n\t\t// now lets check if there is a resources dir\n\t\tresourcesDir := filepath.Join(folder, \"resources\")\n\t\texists, err = files.DirExists(resourcesDir)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to check if resources directory %s exists in repository %s\", resourcesDir, safeName)\n\t\t}\n\t\tif exists {\n\t\t\tabsDir, err := filepath.Abs(resourcesDir)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"failed to get absolute resources dir %s\", resourcesDir)\n\t\t\t}\n\n\t\t\tcmd := &cmdrunner.Command{\n\t\t\t\tName: \"kubectl\",\n\t\t\t\tArgs: []string{\"apply\", \"-f\", absDir},\n\t\t\t}\n\t\t\tlog.Logger().Infof(\"running command: %s\", cmd.CLI())\n\t\t\t_, err = c.runner(cmd)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"failed to apply resources in dir %s\", absDir)\n\t\t\t}\n\t\t}\n\t}\n\n\t// lets try use a maximum of 31 characters and a minimum of 10 for the sha\n\tnamePrefix := trimLength(safeName, 20)\n\n\tid := uuid.New().String()\n\tresourceName := namePrefix + \"-\" + id\n\n\tresource.Name = resourceName\n\n\tif resource.Labels == nil {\n\t\tresource.Labels = map[string]string{}\n\t}\n\tresource.Labels[constants.DefaultSelectorKey] = constants.DefaultSelectorValue\n\tresource.Labels[launcher.RepositoryLabelKey] = safeName\n\tresource.Labels[launcher.CommitShaLabelKey] = safeSha\n\n\tr2, err := jobInterface.Create(ctx, resource, metav1.CreateOptions{})\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to create Job %s in namespace %s\", resourceName, ns)\n\t}\n\tlog.Logger().Infof(\"created Job %s in namespace %s\", resourceName, ns)\n\treturn []runtime.Object{r2}, nil\n}", "func (fc *FederatedController) syncFLJob(key string) (bool, error) {\n\tstartTime := time.Now()\n\tdefer func() {\n\t\tklog.V(4).Infof(\"Finished syncing federatedlearning job %q (%v)\", key, time.Since(startTime))\n\t}()\n\n\tns, name, err := cache.SplitMetaNamespaceKey(key)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif len(ns) == 0 || len(name) == 0 {\n\t\treturn false, fmt.Errorf(\"invalid federatedlearning job key %q: either namespace or name is missing\", key)\n\t}\n\tsharedFLJob, err := fc.jobLister.FederatedLearningJobs(ns).Get(name)\n\tif err != nil {\n\t\tif errors.IsNotFound(err) {\n\t\t\tklog.V(4).Infof(\"FLJob has been deleted: %v\", key)\n\t\t\treturn true, nil\n\t\t}\n\t\treturn false, err\n\t}\n\tflJob := *sharedFLJob\n\t// set kind for flJob in case that the kind is None\n\tflJob.SetGroupVersionKind(neptunev1.SchemeGroupVersion.WithKind(\"FederatedLearningJob\"))\n\t// if flJob was finished previously, we don't want to redo the termination\n\tif IsFLJobFinished(&flJob) {\n\t\treturn true, nil\n\t}\n\tselector, _ := GenerateSelector(&flJob)\n\tpods, err := fc.podStore.Pods(flJob.Namespace).List(selector)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tactivePods := k8scontroller.FilterActivePods(pods)\n\tactive := int32(len(activePods))\n\tsucceeded, failed := getStatus(pods)\n\tconditions := len(flJob.Status.Conditions)\n\t// flJob first start\n\tif flJob.Status.StartTime == nil {\n\t\tnow := metav1.Now()\n\t\tflJob.Status.StartTime = &now\n\t}\n\n\tvar manageJobErr error\n\tjobFailed := false\n\tvar failureReason string\n\tvar failureMessage string\n\tphase := flJob.Status.Phase\n\n\tif failed > 0 {\n\t\tjobFailed = true\n\t\tfailureReason = \"workerFailed\"\n\t\tfailureMessage = \"the worker of FLJob failed\"\n\t}\n\n\tif jobFailed {\n\t\tflJob.Status.Conditions = append(flJob.Status.Conditions, NewFLJobCondition(neptunev1.FLJobCondFailed, failureReason, failureMessage))\n\t\tflJob.Status.Phase = neptunev1.FLJobFailed\n\t\tfc.recorder.Event(&flJob, v1.EventTypeWarning, failureReason, failureMessage)\n\t} else {\n\t\t// in the First time, we create the pods\n\t\tif len(pods) == 0 {\n\t\t\tactive, manageJobErr = fc.createPod(&flJob)\n\t\t}\n\t\tcomplete := false\n\t\tif succeeded > 0 && active == 0 {\n\t\t\tcomplete = true\n\t\t}\n\t\tif complete {\n\t\t\tflJob.Status.Conditions = append(flJob.Status.Conditions, NewFLJobCondition(neptunev1.FLJobCondComplete, \"\", \"\"))\n\t\t\tnow := metav1.Now()\n\t\t\tflJob.Status.CompletionTime = &now\n\t\t\tfc.recorder.Event(&flJob, v1.EventTypeNormal, \"Completed\", \"FLJob completed\")\n\t\t\tflJob.Status.Phase = neptunev1.FLJobSucceeded\n\t\t} else {\n\t\t\tflJob.Status.Phase = neptunev1.FLJobRunning\n\t\t}\n\t}\n\n\tforget := false\n\t// Check if the number of jobs succeeded increased since the last check. If yes \"forget\" should be true\n\t// This logic is linked to the issue: https://github.com/kubernetes/kubernetes/issues/56853 that aims to\n\t// improve the FLJob backoff policy when parallelism > 1 and few FLJobs failed but others succeed.\n\t// In this case, we should clear the backoff delay.\n\tif flJob.Status.Succeeded < succeeded {\n\t\tforget = true\n\t}\n\n\t// no need to update the flJob if the status hasn't changed since last time\n\tif flJob.Status.Active != active || flJob.Status.Succeeded != succeeded || flJob.Status.Failed != failed || len(flJob.Status.Conditions) != conditions || flJob.Status.Phase != phase {\n\t\tflJob.Status.Active = active\n\t\tflJob.Status.Succeeded = succeeded\n\t\tflJob.Status.Failed = failed\n\n\t\tif jobFailed && !IsFLJobFinished(&flJob) {\n\t\t\t// returning an error will re-enqueue FLJob after the backoff period\n\t\t\treturn forget, fmt.Errorf(\"failed pod(s) detected for flJob key %q\", key)\n\t\t}\n\n\t\tforget = true\n\t}\n\n\treturn forget, manageJobErr\n}", "func (bc *OktetoBuilder) isImageBuilt(tags []string) (string, error) {\n\tfor _, tag := range tags {\n\t\timageWithDigest, err := bc.Registry.GetImageTagWithDigest(tag)\n\n\t\tif err != nil {\n\t\t\tif oktetoErrors.IsNotFound(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// return error if the registry doesn't send a not found error\n\t\t\treturn \"\", fmt.Errorf(\"error checking image at registry %s: %v\", tag, err)\n\t\t}\n\t\treturn imageWithDigest, nil\n\t}\n\treturn \"\", fmt.Errorf(\"not found\")\n}", "func (scw *JobFuncWrapper) ensureNooneElseRunning(job *que.Job, tx *pgx.Tx, key string) (bool, error) {\n\tvar lastCompleted time.Time\n\tvar nextScheduled time.Time\n\terr := tx.QueryRow(\"SELECT last_completed, next_scheduled FROM cron_metadata WHERE id = $1 FOR UPDATE\", key).Scan(&lastCompleted, &nextScheduled)\n\tif err != nil {\n\t\tif err == pgx.ErrNoRows {\n\t\t\t_, err = tx.Exec(\"INSERT INTO cron_metadata (id) VALUES ($1)\", key)\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t\treturn false, ErrImmediateReschedule\n\t\t}\n\t\treturn false, err\n\t}\n\n\tif time.Now().Before(nextScheduled) {\n\t\tvar futureJobs int\n\t\t// make sure we don't regard ourself as a future job. Sometimes clock skew makes us think we can't run yet.\n\t\terr = tx.QueryRow(\"SELECT count(*) FROM que_jobs WHERE job_class = $1 AND args::jsonb = $2::jsonb AND run_at >= $3 AND job_id != $4\", job.Type, job.Args, nextScheduled, job.ID).Scan(&futureJobs)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\n\t\tif futureJobs > 0 {\n\t\t\treturn false, nil\n\t\t}\n\n\t\treturn false, scw.QC.EnqueueInTx(&que.Job{\n\t\t\tType: job.Type,\n\t\t\tArgs: job.Args,\n\t\t\tRunAt: nextScheduled,\n\t\t}, tx)\n\t}\n\n\t// Continue\n\treturn true, nil\n}", "func checkState() {\n\tlist := listContainers()\n\tallup := true\n\tfor _, cfgCon := range clusterConfig {\n\t\tfound := false\n\t\tfor _, con := range list {\n\t\t\tif con.Name == cfgCon.Name {\n\t\t\t\tif !con.State.Running {\n\t\t\t\t\tallup = false\n\t\t\t\t}\n\t\t\t\tcheckContainerState(con, cfgCon)\n\t\t\t\tfound = true\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tlog.Println(\"No container found for\", cfgCon.Name)\n\t\t\tcreateContainer(cfgCon)\n\t\t\tupdateConfig()\n\t\t}\n\t}\n\tif allup {\n\t\tlog.Println(\"All containers are up\")\n\t}\n}", "func isRunning(on_node, operation, rcCode string) bool {\n\treturn on_node != \"\" && (operation == \"start\" || (operation == \"monitor\" && rcCode == \"0\"))\n}", "func newGoldTryjobProcessor(vcs vcsinfo.VCS, config *sharedconfig.IngesterConfig, ignoreClient *http.Client, eventBus eventbus.EventBus) (ingestion.Processor, error) {\n\tgerritURL := config.ExtraParams[CONFIG_GERRIT_CODE_REVIEW_URL]\n\tif strings.TrimSpace(gerritURL) == \"\" {\n\t\treturn nil, fmt.Errorf(\"Missing URL for the Gerrit code review systems. Got value: '%s'\", gerritURL)\n\t}\n\n\t// Get the config options.\n\tsvcAccountFile := config.ExtraParams[CONFIG_SERVICE_ACCOUNT_FILE]\n\tsklog.Infof(\"Got service account file '%s'\", svcAccountFile)\n\n\tpollInterval, err := parseDuration(config.ExtraParams[CONFIG_BUILD_BUCKET_POLL_INTERVAL], bbstate.DefaultPollInterval)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttimeWindow, err := parseDuration(config.ExtraParams[CONFIG_BUILD_BUCKET_TIME_WINDOW], bbstate.DefaultTimeWindow)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbuildBucketURL := config.ExtraParams[CONFIG_BUILD_BUCKET_URL]\n\tbuildBucketName := config.ExtraParams[CONFIG_BUILD_BUCKET_NAME]\n\tif (buildBucketURL == \"\") || (buildBucketName == \"\") {\n\t\treturn nil, fmt.Errorf(\"BuildBucketName and BuildBucketURL must not be empty.\")\n\t}\n\n\tbuilderRegExp := config.ExtraParams[CONFIG_BUILDER_REGEX]\n\tif builderRegExp == \"\" {\n\t\tbuilderRegExp = bbstate.DefaultTestBuilderRegex\n\t}\n\n\t// Get the config file in the repo that should be parsed to determine whether a\n\t// bot uploads results. Currently only applies to the Skia repo.\n\tcfgFile := config.ExtraParams[CONFIG_JOB_CFG_FILE]\n\n\t_, expStoreFactory, err := ds_expstore.New(ds.DS, eventBus)\n\tif err != nil {\n\t\treturn nil, sklog.FmtErrorf(\"Unable to create cloud expectations store: %s\", err)\n\t}\n\tsklog.Infof(\"Cloud Expectations Store created\")\n\n\t// Create the cloud tryjob store.\n\ttryjobStore, err := tryjobstore.NewCloudTryjobStore(ds.DS, expStoreFactory, eventBus)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Error creating tryjob store: %s\", err)\n\t}\n\tsklog.Infof(\"Cloud Tryjobstore Store created\")\n\n\t// Instantiate the Gerrit API client.\n\tts, err := auth.NewJWTServiceAccountTokenSource(\"\", svcAccountFile, gstorage.CloudPlatformScope, \"https://www.googleapis.com/auth/userinfo.email\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to authenticate service account: %s\", err)\n\t}\n\tclient := httputils.DefaultClientConfig().WithTokenSource(ts).With2xxOnly().Client()\n\tsklog.Infof(\"HTTP client instantiated\")\n\n\tgerritReview, err := gerrit.NewGerrit(gerritURL, \"\", client)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsklog.Infof(\"Gerrit client instantiated\")\n\n\tbbConf := &bbstate.Config{\n\t\tBuildBucketURL: buildBucketURL,\n\t\tBuildBucketName: buildBucketName,\n\t\tClient: client,\n\t\tTryjobStore: tryjobStore,\n\t\tGerritClient: gerritReview,\n\t\tPollInterval: pollInterval,\n\t\tTimeWindow: timeWindow,\n\t\tBuilderRegexp: builderRegExp,\n\t}\n\n\tbbGerritClient, err := bbstate.NewBuildBucketState(bbConf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsklog.Infof(\"BuildBucketState created\")\n\n\tret := &goldTryjobProcessor{\n\t\tbuildIssueSync: bbGerritClient,\n\t\ttryjobStore: tryjobStore,\n\t\tvcs: vcs,\n\t\tcfgFile: cfgFile,\n\n\t\t// The argument to NewCondMonitor is 1 because we always want exactly one go-routine per unique\n\t\t// issue ID to enter the critical section. See the syncIssueAndTryjob function.\n\t\tsyncMonitor: util.NewCondMonitor(1),\n\t}\n\teventBus.SubscribeAsync(tryjobstore.EV_TRYJOB_UPDATED, ret.tryjobUpdatedHandler)\n\n\treturn ret, nil\n}", "func verifyCircleCIJobSuccess(orgRepo, gitHash, circleCIDeployJobName, circleCIAPIToken string) (err error) {\n\tclient := &circleci.Client{Token: circleCIAPIToken}\n\tsplitOrgRepo := strings.Split(orgRepo, \"/\")\n\torg := splitOrgRepo[0]\n\trepo := splitOrgRepo[1]\n\tvar targetBuildNum int\n\tif targetBuildNum, err = obtainBuildNum(org, repo, gitHash, circleCIDeployJobName,\n\t\tclient); err != nil {\n\t\treturn\n\t}\n\treturn checkForJobSuccess(org, repo, targetBuildNum, client)\n}", "func OfflineBuild(request *http.Request) (string, interface{}) {\n\tdecoder := json.NewDecoder(request.Body)\n\tbuilder := &build.Build{}\n\terr := decoder.Decode(builder)\n\tif err != nil {\n\t\tlog.Errorf(\"decode the request body err:%v\", err)\n\t\treturn r.StatusBadRequest, \"json format error\"\n\t}\n\n\tdockerfile := fmt.Sprintf(\"%s/%s/%s\", TARBALL_ROOT_DIR, builder.UserId, \"Dockerfile\")\n\tif !file.FileExsit(dockerfile) {\n\t\t//TODO generate the Dockerfile by Dockerfile template\n\t}\n\tprojects := fmt.Sprintf(\"%s/%s/%s\", TARBALL_ROOT_DIR, builder.UserId, builder.Tarball)\n\timgBuildTar := fmt.Sprintf(\"%s/%s/%s\", BUILD_IMAGE_TAR_DIR, builder.UserId, builder.Tarball)\n\tif err = file.Tar(imgBuildTar, true, dockerfile, projects); err != nil {\n\t\treturn r.StatusInternalServerError, err\n\t}\n\tbuildContext, err := os.Open(imgBuildTar)\n\tif err != nil {\n\t\treturn r.StatusInternalServerError, err\n\t}\n\tdefer buildContext.Close()\n\timage_repo := fmt.Sprintf(\"%s/%s:%s\", DEFAULT_REGISTRY, builder.AppName, builder.Version)\n\toptions := types.ImageBuildOptions{\n\t\tTags: []string{image_repo},\n\t\tDockerfile: \"Dockerfile\",\n\t}\n\n\tbuildResponse, err := client.DockerClient.ImageBuild(context.Background(), buildContext, options)\n\tif err != nil {\n\t\tlog.Errorf(\"build image err: %v\", err)\n\t\treturn r.StatusInternalServerError, err.Error()\n\t}\n\tres, err := ioutil.ReadAll(buildResponse.Body)\n\tif err != nil {\n\t\tlog.Errorf(\"read the build image response err: %v\", err)\n\t\treturn r.StatusInternalServerError, err.Error()\n\t}\n\n\tbuilder.Image = image_repo\n\tbuilder.Status = build.BUILD_SUCCESS\n\tbuilder.BuildLog = string(res)\n\tif err = builder.Insert(); err != nil {\n\t\tlog.Errorf(\"insert the build to db err: %v\", err)\n\t}\n\n\tpushRes, err := pushImage(image_repo)\n\tif err != nil {\n\t\treturn r.StatusInternalServerError, \"build image successed,but push image to registry err :\" + err.Error()\n\t}\n\tlog.Debugf(\"push result ==%v\", pushRes)\n\treturn r.StatusCreated, string(res)\n}", "func (sia *statefulsetInitAwaiter) checkAndLogStatus() bool {\n\tif sia.replicasReady && sia.revisionReady {\n\t\tsia.config.logStatus(diag.Info,\n\t\t\tfmt.Sprintf(\"%sStatefulSet initialization complete\", cmdutil.EmojiOr(\"✅ \", \"\")))\n\t\treturn true\n\t}\n\n\tisInitialDeployment := sia.currentGeneration <= 1\n\n\t// For initial generation, the revision doesn't need to be updated, so skip that step in the log.\n\tif isInitialDeployment {\n\t\tsia.config.logStatus(diag.Info, fmt.Sprintf(\"[1/2] Waiting for StatefulSet to create Pods (%d/%d Pods ready)\",\n\t\t\tsia.currentReplicas, sia.targetReplicas))\n\t} else {\n\t\tswitch {\n\t\tcase !sia.replicasReady:\n\t\t\tsia.config.logStatus(diag.Info, fmt.Sprintf(\"[1/3] Waiting for StatefulSet update to roll out (%d/%d Pods ready)\",\n\t\t\t\tsia.currentReplicas, sia.targetReplicas))\n\t\tcase !sia.revisionReady:\n\t\t\tsia.config.logStatus(diag.Info,\n\t\t\t\t\"[2/3] Waiting for StatefulSet to update .status.currentRevision\")\n\t\t}\n\t}\n\n\treturn false\n}", "func main() {\n jsv.Run(true, job_verification_function, jsv_on_start_function)\n}", "func launchCondition(logger *zap.Logger, client *elastic.Client) func(context.Context, *lifecycle.Event) (bool, error) {\n\treturn func(ctx context.Context, event *lifecycle.Event) (bool, error) {\n\t\t// Check cluster health\n\t\tresp, err := client.ClusterHealth().Do(ctx)\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\treturn false, err\n\t\tcase resp.TimedOut:\n\t\t\treturn false, errors.New(\"request to cluster master node timed out\")\n\t\tcase resp.RelocatingShards > 0:\n\t\t\t// Shards are being relocated. This is the activity lifecycler was designed to protect.\n\t\t\tlogger.Info(\"condition failed: RelocatingShards > 0\")\n\t\t\treturn false, nil\n\t\t}\n\n\t\tlogger.Info(\"condition passed\")\n\t\treturn true, nil\n\t}\n}", "func (s *Worker) prepare(jobName string, f Job) func() {\n\treturn func() {\n\t\ts.logger.Info(fmt.Sprintf(\"job '%s' is started\", jobName))\n\t\terr := f()\n\t\tif err == nil {\n\t\t\ts.logger.Info(fmt.Sprintf(\"job '%s' is finished\", jobName))\n\t\t\treturn\n\t\t}\n\n\t\ts.logger.Error(\"cannot execute job\", \"job\", jobName, \"err\", err)\n\t}\n}", "func (v *johndictTasker) Status() common.Job {\n\tlog.WithField(\"task\", v.job.UUID).Debug(\"Gathering task status\")\n\tv.mux.Lock()\n\tdefer v.mux.Unlock()\n\n\t// Run john --status command\n\tstatusExec := exec.Command(config.BinPath, \"--status=\"+v.job.UUID)\n\tstatusExec.Dir = v.wd\n\tstatus, err := statusExec.CombinedOutput()\n\tif err != nil {\n\t\tv.job.Error = err.Error()\n\t\tlog.WithField(\"Error\", err.Error()).Debug(\"Error running john status command.\")\n\t\t// Do not return the job now. Keep running the check so the hashes will be parsed \n\t\t// even if the job has quit before a status was pulled.\n\t\t// return v.job \n\t}\n\n\tlog.WithField(\"StatusStdout\", string(status)).Debug(\"Stdout status return of john call\")\n\n\ttimestamp := fmt.Sprintf(\"%d\", time.Now().Unix())\n\n\tmatch := regStatusLine.FindStringSubmatch(string(status))\n\tlog.WithField(\"StatusMatch\", match).Debug(\"Regex match of john status call\")\n\n\tif len(match) == 7 {\n\t\t// Get # of cracked hashes\n\t\tcrackedHashes, err := strconv.ParseInt(match[1], 10, 64)\n\t\tif err == nil {\n\t\t\tv.job.CrackedHashes = crackedHashes\n\t\t}\n\n\t\t// Get % complete\n\t\tprogress, err := strconv.ParseFloat(match[3], 64)\n\t\tif err == nil {\n\t\t\tv.job.Progress = progress\n\t\t}\n\n\t\t// Get ETA\n\t\teta, err := parseJohnETA(match[4])\n\t\tif err == nil {\n\t\t\tv.job.ETC = printTimeUntil(eta)\n\t\t} else {\n\t\t\tv.job.ETC = \"Not Available\"\n\t\t}\n\n\t\t// Get guesses / second\n\t\tif v.job.PerformanceTitle == \"\" {\n\t\t\t// We need to set the units the first time\n\t\t\tv.job.PerformanceTitle = match[6]\n\t\t}\n\n\t\tvar mag float64\n\t\tswitch v.job.PerformanceTitle {\n\t\tcase \"C/s\":\n\t\t\tmag = speedMagH[match[6]]\n\t\tcase \"KC/s\":\n\t\t\tmag = speedMagK[match[6]]\n\t\tcase \"MC/s\":\n\t\t\tmag = speedMagM[match[6]]\n\t\tcase \"GC/s\":\n\t\t\tmag = speedMagG[match[6]]\n\t\t}\n\n\t\t// convert our string into a float\n\t\tspeed, err := strconv.ParseFloat(match[5], 64)\n\t\tif err == nil {\n\t\t\tv.job.PerformanceData[timestamp] = fmt.Sprintf(\"%f\", speed*mag)\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"speed\": speed,\n\t\t\t\t\"mag\": mag,\n\t\t\t}).Debug(\"Speed calculated.\")\n\t\t}\n\n\t} else {\n\t\tlog.WithField(\"MatchCount\", len(match)).Debug(\"Did not match enough items in the status\")\n\t}\n\n\t// Now get any hashes we might have cracked. Because of how John works we will\n\t// need to read in all the hashes provied and then search the .pot file in this\n\t// working directory to find any cracked passwords.\n\tvar hash2D [][]string\n\n\t// Read in hashes.txt file & pot file\n\thashFile, err := ioutil.ReadFile(filepath.Join(v.wd, \"hashes.txt\"))\n\tpotFile, err := ioutil.ReadFile(filepath.Join(v.wd, v.job.UUID+\".pot\"))\n\tpotHashes := strings.Split(string(potFile), \"\\n\")\n\tif err == nil {\n\t\thashes := strings.Split(string(hashFile), \"\\n\")\n\t\tfor _, hash := range hashes {\n\t\t\t// Check for existence in potHashes\n\t\t\tfor _, potHash := range potHashes {\n\t\t\t\tif strings.Contains(potHash, strings.ToLower(hash)) {\n\t\t\t\t\t// We have a hash match so let's add it to our output\n\t\t\t\t\thashIndex := strings.Index(potHash, strings.ToLower(hash))\n\t\t\t\t\tvar hashKeyPair []string\n\t\t\t\t\thashKeyPair = append(hashKeyPair, potHash[hashIndex+1:])\n\t\t\t\t\thashKeyPair = append(hashKeyPair, hash)\n\n\t\t\t\t\thash2D = append(hash2D, hashKeyPair)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tv.job.OutputData = hash2D\n\t}\n\n\tlog.WithFields(log.Fields{\n\t\t\"task\": v.job.UUID,\n\t\t\"status\": v.job.Status,\n\t}).Info(\"Ongoing task status\")\n\n\treturn v.job\n}", "func (s ScheduledJob) validate() error {\n\tvar err error\n\tif err = s.ScheduledJobConfig.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = s.Workload.validate(); err != nil {\n\t\treturn err\n\t}\n\tif err = validateContainerDeps(validateDependenciesOpts{\n\t\tsidecarConfig: s.Sidecars,\n\t\timageConfig: s.ImageConfig.Image,\n\t\tmainContainerName: aws.StringValue(s.Name),\n\t\tlogging: s.Logging,\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"validate container dependencies: %w\", err)\n\t}\n\tif err = validateExposedPorts(validateExposedPortsOpts{\n\t\tsidecarConfig: s.Sidecars,\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"validate unique exposed ports: %w\", err)\n\t}\n\treturn nil\n}", "func builder(jobs <-chan string, buildStarted chan<- string, buildDone chan<- bool) {\n\tcreateThreshold := func() <-chan time.Time {\n\t\treturn time.After(time.Duration(WorkDelay * time.Millisecond))\n\t}\n\n\tthreshold := createThreshold()\n\teventPath := \"\"\n\n\tfor {\n\t\tselect {\n\t\tcase eventPath = <-jobs:\n\t\t\tthreshold = createThreshold()\n\t\tcase <-threshold:\n\t\t\tbuildStarted <- eventPath\n\t\t\tbuildDone <- build()\n\t\t}\n\t}\n}", "func (t *Tileset) CheckJobStatus() error {\n\tfmt.Println(\"Awaiting job completion. This may take some time...\")\n\tfor {\n\t\tstatusResponse := &StatusResponse{}\n\t\tres, err := t.base.SimpleGET(t.postURL() + \"/status\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tjson.Unmarshal(res, statusResponse)\n\t\tif statusResponse.Status == \"failed\" {\n\t\t\tfmt.Println(\"Job failed\")\n\t\t\treturn nil\n\t\t}\n\t\tif statusResponse.Status == \"success\" {\n\t\t\tfmt.Println(\"Job complete\")\n\t\t\treturn nil\n\t\t}\n\t\tfmt.Println(statusResponse.Status)\n\t\ttime.Sleep(5 * time.Second)\n\n\t}\n\n}", "func CfnJobTemplate_IsConstruct(x interface{}) *bool {\n\t_init_.Initialize()\n\n\tvar returns *bool\n\n\t_jsii_.StaticInvoke(\n\t\t\"monocdk.aws_mediaconvert.CfnJobTemplate\",\n\t\t\"isConstruct\",\n\t\t[]interface{}{x},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "func makeJob(c context.Context, j *engine.Job) *schedulerJob {\n\ttraits, err := presentation.GetJobTraits(c, config(c).Catalog, j)\n\tif err != nil {\n\t\tlogging.WithError(err).Warningf(c, \"Failed to get task traits for %s\", j.JobID)\n\t}\n\n\tnow := clock.Now(c).UTC()\n\tnextRun := \"\"\n\tswitch ts := j.State.TickTime; {\n\tcase ts == schedule.DistantFuture:\n\t\tnextRun = \"-\"\n\tcase !ts.IsZero():\n\t\tnextRun = humanize.RelTime(ts, now, \"ago\", \"from now\")\n\tdefault:\n\t\tnextRun = \"not scheduled yet\"\n\t}\n\n\t// Internal state names aren't very user friendly. Introduce some aliases.\n\tstate := presentation.GetPublicStateKind(j, traits)\n\tlabelClass := stateToLabelClass[state]\n\tif j.State.State == engine.JobStateSlowQueue {\n\t\t// Job invocation is still in the task queue, but new invocation should be\n\t\t// starting now (so the queue is lagging for some reason).\n\t\tlabelClass = \"label-warning\"\n\t}\n\t// Put triggers after regular jobs.\n\tsortGroup := \"A\"\n\tif j.Flavor == catalog.JobFlavorTrigger {\n\t\tsortGroup = \"B\"\n\t}\n\n\treturn &schedulerJob{\n\t\tProjectID: j.ProjectID,\n\t\tJobName: j.GetJobName(),\n\t\tSchedule: j.Schedule,\n\t\tDefinition: taskToText(j.Task),\n\t\tRevision: j.Revision,\n\t\tRevisionURL: j.RevisionURL,\n\t\tState: string(state),\n\t\tOverruns: j.State.Overruns,\n\t\tNextRun: nextRun,\n\t\tPaused: j.Paused,\n\t\tLabelClass: labelClass,\n\t\tJobFlavorIcon: flavorToIconClass[j.Flavor],\n\t\tJobFlavorTitle: flavorToTitle[j.Flavor],\n\n\t\tsortGroup: sortGroup,\n\t\tnow: now,\n\t\ttraits: traits,\n\t}\n}", "func buildImage(t *testing.T, projectID string, workingPackerDir string) {\n\t// Variables to pass to our Packer build using -var options\n\tPKR_VAR_project := os.Getenv(\"PKR_VAR_project\")\n\tPKR_VAR_zone := os.Getenv(\"PKR_VAR_zone\")\n\tPKR_VAR_airbyte_build_script := os.Getenv(\"PKR_VAR_airbyte_build_script\")\n\tairbyte_build_script := workingPackerDir + PKR_VAR_airbyte_build_script\n\n\tpackerOptions := &packer.Options{\n\t\t// The path to where the Packer template is located\n\t\tTemplate: workingPackerDir + \"airbyte_gce_image.pkr.hcl\",\n\n\t\tVars: map[string]string{\n\t\t\t\"project\": PKR_VAR_project,\n\t\t\t\"zone\": PKR_VAR_zone,\n\t\t\t\"airbyte_build_script\": airbyte_build_script,\n\t\t},\n\n\t\t// Configure retries for intermittent errors\n\t\tRetryableErrors: DefaultRetryablePackerErrors,\n\t\tTimeBetweenRetries: DefaultTimeBetweenPackerRetries,\n\t\tMaxRetries: DefaultMaxPackerRetries,\n\t}\n\n\t// Save the Packer Options so future test stages can use them\n\ttest_structure.SavePackerOptions(t, workingPackerDir, packerOptions)\n\n\t// Make sure the Packer build completes successfully\n\timageName := packer.BuildArtifact(t, packerOptions)\n\n\t// Save the imageName as a string so future test stages can use them\n\ttest_structure.SaveString(t, workingPackerDir, \"imageName\", imageName)\n}", "func (this *Job) State() int {\n\tanyRunningTasks := false\n\tfor _, task := range this.Tasks {\n\t\tif task.IsRunning() {\n\t\t\tanyRunningTasks = true\n\t\t\tbreak\n\t\t}\n\t}\n\treturn JobState(this.Started, this.Finished, this.Suspended, this.Error, anyRunningTasks)\n}", "func (c *chain) JobIsReady(jobId string) bool {\n\tisReady := true\n\tfor _, job := range c.PreviousJobs(jobId) {\n\t\tif job.State != proto.STATE_COMPLETE {\n\t\t\tisReady = false\n\t\t}\n\t}\n\treturn isReady\n}", "func isValidCreateState(s pb.Invocation_State) bool {\n\tswitch s {\n\tdefault:\n\t\treturn false\n\tcase pb.Invocation_STATE_UNSPECIFIED:\n\tcase pb.Invocation_ACTIVE:\n\tcase pb.Invocation_FINALIZING:\n\t}\n\treturn true\n}", "func (s *InitialisationStep) checkRuntimeStatus(operation internal.UpgradeKymaOperation, instance *internal.Instance, log logrus.FieldLogger) (internal.UpgradeKymaOperation, time.Duration, error) {\n\tif time.Since(operation.UpdatedAt) > CheckStatusTimeout {\n\t\tlog.Infof(\"operation has reached the time limit: updated operation time: %s\", operation.UpdatedAt)\n\t\treturn s.operationManager.OperationFailed(operation, fmt.Sprintf(\"operation has reached the time limit: %s\", CheckStatusTimeout))\n\t}\n\n\tstatus, err := s.provisionerClient.RuntimeOperationStatus(instance.GlobalAccountID, operation.ProvisionerOperationID)\n\tif err != nil {\n\t\treturn operation, s.timeSchedule.StatusCheck, nil\n\t}\n\tlog.Infof(\"call to provisioner returned %s status\", status.State.String())\n\n\tvar msg string\n\tif status.Message != nil {\n\t\tmsg = *status.Message\n\t}\n\n\t// do required steps on init\n\toperation, delay, err := s.performRuntimeTasks(UpgradeInitSteps, operation, instance, log)\n\tif delay != 0 || err != nil {\n\t\treturn operation, delay, err\n\t}\n\n\t// wait for operation completion\n\tswitch status.State {\n\tcase gqlschema.OperationStateInProgress, gqlschema.OperationStatePending:\n\t\treturn operation, s.timeSchedule.StatusCheck, nil\n\tcase gqlschema.OperationStateSucceeded, gqlschema.OperationStateFailed:\n\t\t// Set post-upgrade description which also reset UpdatedAt for operation retries to work properly\n\t\tif operation.Description != postUpgradeDescription {\n\t\t\toperation.Description = postUpgradeDescription\n\t\t\toperation, delay = s.operationManager.UpdateOperation(operation)\n\t\t\tif delay != 0 {\n\t\t\t\treturn operation, delay, nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// do required steps on finish\n\toperation, delay, err = s.performRuntimeTasks(UpgradeFinishSteps, operation, instance, log)\n\tif delay != 0 || err != nil {\n\t\treturn operation, delay, err\n\t}\n\n\t// handle operation completion\n\tswitch status.State {\n\tcase gqlschema.OperationStateSucceeded:\n\t\treturn s.operationManager.OperationSucceeded(operation, msg)\n\tcase gqlschema.OperationStateFailed:\n\t\treturn s.operationManager.OperationFailed(operation, fmt.Sprintf(\"provisioner client returns failed status: %s\", msg))\n\t}\n\n\treturn s.operationManager.OperationFailed(operation, fmt.Sprintf(\"unsupported provisioner client status: %s\", status.State.String()))\n}", "func ttrBuildImageAsserting(ctx context.Context, t *testing.T, client apiclient.APIClient, image string) func() {\n\tsource := fakecontext.New(t, \"\")\n\tdefer source.Close()\n\n\terr := copy.DirCopy(\"../../integration/testdata/delta/\", source.Dir, copy.Content, false)\n\tassert.Assert(t, err)\n\n\tresp, err := client.ImageBuild(ctx, source.AsTarReader(t),\n\t\ttypes.ImageBuildOptions{\n\t\t\tTags: []string{ttrImageName(image)},\n\t\t\tDockerfile: image + \".Dockerfile\",\n\t\t},\n\t)\n\tassert.Assert(t, err)\n\n\tif resp.Body != nil {\n\t\tbody, err := readAllAndClose(resp.Body)\n\t\tassert.Assert(t, err)\n\t\tassert.Assert(t, strings.Contains(body, \"Successfully built\"))\n\t\tassert.Assert(t, strings.Contains(body, \"Successfully tagged\"))\n\t}\n\n\treturn func() {\n\t\tttrRemoveImageAsserting(ctx, t, client, image)\n\t}\n}", "func (s *service) Build(ctx *shared.Context) (err error) {\n\tif !s.IsOptimized() {\n\t\treturn nil\n\t}\n\tif err = s.buildBatched(ctx); err == nil {\n\t\terr = s.buildIndividual(ctx)\n\t}\n\treturn err\n}", "func CfnStreamingImage_IsConstruct(x interface{}) *bool {\n\t_init_.Initialize()\n\n\tvar returns *bool\n\n\t_jsii_.StaticInvoke(\n\t\t\"monocdk.aws_nimblestudio.CfnStreamingImage\",\n\t\t\"isConstruct\",\n\t\t[]interface{}{x},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "func (r *RecipeInfo) initStep(step int) (bool, error) {\n\t// Check if the recipe is done\n\tif step == r.TotalSteps || r.ID.ValueOrZero() == -1 {\n\t\treturn true, r.clear()\n\t}\n\n\t// Check if we are given a valid step in our recipe\n\tif step < 0 || step > r.TotalSteps {\n\t\tlog.Errorf(\"invalid step (%d) when there are only (%d) steps\", step, r.TotalSteps)\n\t\treturn false, errors.New(\"invalid step\")\n\t}\n\n\t// Clear past step jobs\n\tvar err error\n\t_, err = CurrentRecipe.clearJobs()\n\tCurrentRecipe.JobIDs = make([]int64, 0)\n\tif err != nil {\n\t\tlog.Error(err.Error())\n\t}\n\n\t// Setup triggers/jobs\n\tjobs := make([]*JobPayload, 0)\n\n\t// Construct each JobPayload from each TriggerGroup\n\tfor _, triggerGroup := range r.recipe.Steps[step].TriggerGroups {\n\t\tvar job JobPayload\n\n\t\tif triggerGroup.ActionParams.Valid {\n\t\t\tjob.ActionParams = triggerGroup.ActionParams\n\t\t}\n\n\t\tif triggerGroup.ActionKey.Valid {\n\t\t\tjob.ActionKey = triggerGroup.ActionKey\n\t\t}\n\n\t\tif triggerGroup.Service.Valid {\n\t\t\tjob.Service = triggerGroup.Service.String\n\t\t}\n\n\t\t// Loop through all the triggers in the trigger group\n\t\tfor _, trigger := range triggerGroup.Triggers {\n\t\t\tl, err := strconv.Atoi(trigger.TriggerParams.String)\n\t\t\tif err != nil {\n\t\t\t\tlog.Error(err.Error())\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tjob.TriggerParams = append(job.TriggerParams, l)\n\t\t\tjob.TriggerKeys = append(job.TriggerKeys, trigger.TriggerType.Key.String)\n\t\t}\n\t\tjobs = append(jobs, &job)\n\t}\n\n\t// Send the jobs to the trigger-queue\n\tfor _, j := range jobs {\n\t\tvar id int64\n\t\tvar err error\n\t\tid, err = j.SendJob()\n\t\tif err != nil {\n\t\t\tlog.Error(\"error sending job %+v\", j)\n\t\t\tlog.Error(err.Error())\n\t\t} else {\n\t\t\tr.JobIDs = append(r.JobIDs, id)\n\t\t}\n\t}\n\n\t// Update self\n\tif step > 0 {\n\t\tr.PrevStep = r.recipe.Steps[step-1]\n\t} else {\n\t\tr.PrevStep = nil\n\t}\n\n\tr.CurrentStep = r.recipe.Steps[step]\n\n\tif step+1 < r.TotalSteps {\n\t\tr.NextStep = r.recipe.Steps[step+1]\n\t} else {\n\t\tr.NextStep = nil\n\t}\n\treturn false, nil\n}", "func (a *Amoeba) buildImage(buildContext io.Reader) error {\n\topts := types.ImageBuildOptions{\n\t\tTags: []string{a.bid + \":latest\"},\n\t\tRemove: true,\n\t\tForceRemove: true,\n\t\tLabels: map[string]string{amoebaBuild: a.bid},\n\t}\n\n\tres, err := a.cli.ImageBuild(a.ctx, buildContext, opts)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer res.Body.Close()\n\n\t_, err = ioutil.ReadAll(res.Body) // Blocks until built\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (b *Builder) Build(ctx context.Context, opt backend.BuildConfig) (*builder.Result, error) {\n\tif len(opt.Options.Outputs) > 1 {\n\t\treturn nil, errors.Errorf(\"multiple outputs not supported\")\n\t}\n\n\trc := opt.Source\n\tif buildID := opt.Options.BuildID; buildID != \"\" {\n\t\tb.mu.Lock()\n\n\t\tupload := false\n\t\tif strings.HasPrefix(buildID, \"upload-request:\") {\n\t\t\tupload = true\n\t\t\tbuildID = strings.TrimPrefix(buildID, \"upload-request:\")\n\t\t}\n\n\t\tif _, ok := b.jobs[buildID]; !ok {\n\t\t\tb.jobs[buildID] = newBuildJob()\n\t\t}\n\t\tj := b.jobs[buildID]\n\t\tvar cancel func()\n\t\tctx, cancel = context.WithCancel(ctx)\n\t\tj.cancel = cancel\n\t\tb.mu.Unlock()\n\n\t\tif upload {\n\t\t\tctx2, cancel := context.WithTimeout(ctx, 5*time.Second)\n\t\t\tdefer cancel()\n\t\t\terr := j.SetUpload(ctx2, rc)\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif remoteContext := opt.Options.RemoteContext; remoteContext == \"upload-request\" {\n\t\t\tctx2, cancel := context.WithTimeout(ctx, 5*time.Second)\n\t\t\tdefer cancel()\n\t\t\tvar err error\n\t\t\trc, err = j.WaitUpload(ctx2)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\topt.Options.RemoteContext = \"\"\n\t\t}\n\n\t\tdefer func() {\n\t\t\tb.mu.Lock()\n\t\t\tdelete(b.jobs, buildID)\n\t\t\tb.mu.Unlock()\n\t\t}()\n\t}\n\n\tvar out builder.Result\n\n\tid := identity.NewID()\n\n\tfrontendAttrs := map[string]string{}\n\n\tif opt.Options.Target != \"\" {\n\t\tfrontendAttrs[\"target\"] = opt.Options.Target\n\t}\n\n\tif opt.Options.Dockerfile != \"\" && opt.Options.Dockerfile != \".\" {\n\t\tfrontendAttrs[\"filename\"] = opt.Options.Dockerfile\n\t}\n\n\tif opt.Options.RemoteContext != \"\" {\n\t\tif opt.Options.RemoteContext != \"client-session\" {\n\t\t\tfrontendAttrs[\"context\"] = opt.Options.RemoteContext\n\t\t}\n\t} else {\n\t\turl, cancel := b.reqBodyHandler.newRequest(rc)\n\t\tdefer cancel()\n\t\tfrontendAttrs[\"context\"] = url\n\t}\n\n\tcacheFrom := append([]string{}, opt.Options.CacheFrom...)\n\n\tfrontendAttrs[\"cache-from\"] = strings.Join(cacheFrom, \",\")\n\n\tfor k, v := range opt.Options.BuildArgs {\n\t\tif v == nil {\n\t\t\tcontinue\n\t\t}\n\t\tfrontendAttrs[\"build-arg:\"+k] = *v\n\t}\n\n\tfor k, v := range opt.Options.Labels {\n\t\tfrontendAttrs[\"label:\"+k] = v\n\t}\n\n\tif opt.Options.NoCache {\n\t\tfrontendAttrs[\"no-cache\"] = \"\"\n\t}\n\n\tif opt.Options.PullParent {\n\t\tfrontendAttrs[\"image-resolve-mode\"] = \"pull\"\n\t} else {\n\t\tfrontendAttrs[\"image-resolve-mode\"] = \"default\"\n\t}\n\n\tif opt.Options.Platform != \"\" {\n\t\t// same as in newBuilder in builder/dockerfile.builder.go\n\t\t// TODO: remove once opt.Options.Platform is of type specs.Platform\n\t\t_, err := platforms.Parse(opt.Options.Platform)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfrontendAttrs[\"platform\"] = opt.Options.Platform\n\t}\n\n\tswitch opt.Options.NetworkMode {\n\tcase \"host\", \"none\":\n\t\tfrontendAttrs[\"force-network-mode\"] = opt.Options.NetworkMode\n\tcase \"\", \"default\":\n\tdefault:\n\t\treturn nil, errors.Errorf(\"network mode %q not supported by buildkit\", opt.Options.NetworkMode)\n\t}\n\n\textraHosts, err := toBuildkitExtraHosts(opt.Options.ExtraHosts, b.dnsconfig.HostGatewayIP)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfrontendAttrs[\"add-hosts\"] = extraHosts\n\n\tif opt.Options.ShmSize > 0 {\n\t\tfrontendAttrs[\"shm-size\"] = strconv.FormatInt(opt.Options.ShmSize, 10)\n\t}\n\n\tulimits, err := toBuildkitUlimits(opt.Options.Ulimits)\n\tif err != nil {\n\t\treturn nil, err\n\t} else if len(ulimits) > 0 {\n\t\tfrontendAttrs[\"ulimit\"] = ulimits\n\t}\n\n\texporterName := \"\"\n\texporterAttrs := map[string]string{}\n\tif len(opt.Options.Outputs) == 0 {\n\t\texporterName = exporter.Moby\n\t} else {\n\t\t// cacheonly is a special type for triggering skipping all exporters\n\t\tif opt.Options.Outputs[0].Type != \"cacheonly\" {\n\t\t\texporterName = opt.Options.Outputs[0].Type\n\t\t\texporterAttrs = opt.Options.Outputs[0].Attrs\n\t\t}\n\t}\n\n\tif (exporterName == client.ExporterImage || exporterName == exporter.Moby) && len(opt.Options.Tags) > 0 {\n\t\tnameAttr, err := overrides.SanitizeRepoAndTags(opt.Options.Tags)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif exporterAttrs == nil {\n\t\t\texporterAttrs = make(map[string]string)\n\t\t}\n\t\texporterAttrs[\"name\"] = strings.Join(nameAttr, \",\")\n\t}\n\n\tcache := controlapi.CacheOptions{}\n\tif inlineCache := opt.Options.BuildArgs[\"BUILDKIT_INLINE_CACHE\"]; inlineCache != nil {\n\t\tif b, err := strconv.ParseBool(*inlineCache); err == nil && b {\n\t\t\tcache.Exports = append(cache.Exports, &controlapi.CacheOptionsEntry{\n\t\t\t\tType: \"inline\",\n\t\t\t})\n\t\t}\n\t}\n\n\treq := &controlapi.SolveRequest{\n\t\tRef: id,\n\t\tExporter: exporterName,\n\t\tExporterAttrs: exporterAttrs,\n\t\tFrontend: \"dockerfile.v0\",\n\t\tFrontendAttrs: frontendAttrs,\n\t\tSession: opt.Options.SessionID,\n\t\tCache: cache,\n\t}\n\n\tif opt.Options.NetworkMode == \"host\" {\n\t\treq.Entitlements = append(req.Entitlements, entitlements.EntitlementNetworkHost)\n\t}\n\n\taux := streamformatter.AuxFormatter{Writer: opt.ProgressWriter.Output}\n\n\teg, ctx := errgroup.WithContext(ctx)\n\n\teg.Go(func() error {\n\t\tresp, err := b.controller.Solve(ctx, req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif exporterName != exporter.Moby && exporterName != client.ExporterImage {\n\t\t\treturn nil\n\t\t}\n\t\tid, ok := resp.ExporterResponse[\"containerimage.digest\"]\n\t\tif !ok {\n\t\t\treturn errors.Errorf(\"missing image id\")\n\t\t}\n\t\tout.ImageID = id\n\t\treturn aux.Emit(\"moby.image.id\", types.BuildResult{ID: id})\n\t})\n\n\tch := make(chan *controlapi.StatusResponse)\n\n\teg.Go(func() error {\n\t\tdefer close(ch)\n\t\t// streamProxy.ctx is not set to ctx because when request is cancelled,\n\t\t// only the build request has to be cancelled, not the status request.\n\t\tstream := &statusProxy{streamProxy: streamProxy{ctx: context.TODO()}, ch: ch}\n\t\treturn b.controller.Status(&controlapi.StatusRequest{Ref: id}, stream)\n\t})\n\n\teg.Go(func() error {\n\t\tfor sr := range ch {\n\t\t\tdt, err := sr.Marshal()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := aux.Emit(\"moby.buildkit.trace\", dt); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\n\tif err := eg.Wait(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &out, nil\n}", "func StateConnectorCall(blockTime *big.Int, checkRet []byte, availableLedger uint64) bool {\n\tif len(checkRet) != 96 {\n\t\treturn false\n\t}\n\tinstructions := ParseInstructions(checkRet, availableLedger)\n\tif instructions.InitialCommit {\n\t\tgo func() {\n\t\t\tacceptedPath, rejectedPath := GetVerificationPaths(checkRet[8:])\n\t\t\t_, errACCEPTED := os.Stat(acceptedPath)\n\t\t\tif errACCEPTED != nil {\n\t\t\t\tif ReadChainWithRetries(blockTime, instructions) {\n\t\t\t\t\tverificationHashStore, err := os.Create(acceptedPath)\n\t\t\t\t\tverificationHashStore.Close()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t// Permissions problem\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tverificationHashStore, err := os.Create(rejectedPath)\n\t\t\t\t\tverificationHashStore.Close()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t// Permissions problem\n\t\t\t\t\t\tpanic(err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}()\n\t\treturn true\n\t} else {\n\t\tacceptedPath, rejectedPath := GetVerificationPaths(checkRet[8:])\n\t\t_, errACCEPTED := os.Stat(acceptedPath)\n\t\t_, errREJECTED := os.Stat(rejectedPath)\n\t\tif errACCEPTED != nil && errREJECTED != nil {\n\t\t\tfor i := 0; i < 2*apiRetries; i++ {\n\t\t\t\t_, errACCEPTED = os.Stat(acceptedPath)\n\t\t\t\t_, errREJECTED = os.Stat(rejectedPath)\n\t\t\t\tif errACCEPTED == nil || errREJECTED == nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\ttime.Sleep(apiRetryDelay)\n\t\t\t}\n\t\t}\n\t\treturn errACCEPTED == nil\n\t}\n}", "func BuildImage(ctx context.Context, ow *rpc.OutputWriter, cli *client.Client, opts *docker.BuildImageOpts) Fixer {\n\treturn func() (string, error) {\n\t\tcreated, err := docker.EnsureImage(ctx, ow, cli, opts)\n\t\tif err != nil {\n\t\t\treturn \"failed to create custom image.\", err\n\t\t}\n\t\tif created {\n\t\t\treturn \"custom image already existed.\", nil\n\t\t}\n\t\treturn \"custom image created successfully.\", nil\n\t}\n}", "func (t *task) validateState(newRuntime *pbtask.RuntimeInfo) bool {\n\tcurrentRuntime := t.runtime\n\n\tif newRuntime == nil {\n\t\t// no runtime is invalid\n\t\treturn false\n\t}\n\n\t// if current goal state is deleted, it cannot be overwritten\n\t// till the desired configuration version also changes\n\tif currentRuntime.GetGoalState() == pbtask.TaskState_DELETED &&\n\t\tnewRuntime.GetGoalState() != currentRuntime.GetGoalState() {\n\t\tif currentRuntime.GetDesiredConfigVersion() == newRuntime.GetDesiredConfigVersion() {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tif newRuntime.GetMesosTaskId() != nil {\n\t\tif currentRuntime.GetMesosTaskId().GetValue() !=\n\t\t\tnewRuntime.GetMesosTaskId().GetValue() {\n\t\t\t// Validate post migration, new runid is greater than previous one\n\t\t\tif !validateMesosTaskID(newRuntime.GetMesosTaskId().GetValue(),\n\t\t\t\tcurrentRuntime.GetMesosTaskId().GetValue()) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\t// mesos task id has changed\n\t\t\tif newRuntime.GetState() == pbtask.TaskState_INITIALIZED {\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn false\n\t\t}\n\t}\n\n\t// desired mesos task id should not have runID decrease at\n\t// any time\n\tif newRuntime.GetDesiredMesosTaskId() != nil &&\n\t\t!validateMesosTaskID(newRuntime.GetDesiredMesosTaskId().GetValue(),\n\t\t\tcurrentRuntime.GetDesiredMesosTaskId().GetValue()) {\n\t\treturn false\n\t}\n\n\t// if state update is not requested, then return true\n\tif newRuntime.GetState() == currentRuntime.GetState() {\n\t\treturn true\n\t}\n\n\t//TBD replace if's with more structured checks\n\n\tif util.IsPelotonStateTerminal(currentRuntime.GetState()) {\n\t\t// cannot overwrite terminal state without changing the mesos task id\n\t\treturn false\n\t}\n\n\tif IsMesosOwnedState(newRuntime.GetState()) {\n\t\t// update from mesos eventstream is ok from mesos states, resource manager states\n\t\t// and from INITIALIZED and LAUNCHED states.\n\t\tif IsMesosOwnedState(currentRuntime.GetState()) || IsResMgrOwnedState(currentRuntime.GetState()) {\n\t\t\treturn true\n\t\t}\n\n\t\tif currentRuntime.GetState() == pbtask.TaskState_INITIALIZED || currentRuntime.GetState() == pbtask.TaskState_LAUNCHED {\n\t\t\treturn true\n\t\t}\n\n\t\t// Update from KILLING state to only terminal states is allowed\n\t\tif util.IsPelotonStateTerminal(newRuntime.GetState()) && currentRuntime.GetState() == pbtask.TaskState_KILLING {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tif IsResMgrOwnedState(newRuntime.GetState()) {\n\t\t// update from resource manager evenstream is ok from resource manager states or INITIALIZED state\n\t\tif IsResMgrOwnedState(currentRuntime.GetState()) {\n\t\t\treturn true\n\t\t}\n\n\t\tif currentRuntime.GetState() == pbtask.TaskState_INITIALIZED {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tif newRuntime.GetState() == pbtask.TaskState_LAUNCHED {\n\t\t// update to LAUNCHED state from resource manager states and INITIALIZED state is ok\n\t\tif IsResMgrOwnedState(currentRuntime.GetState()) {\n\t\t\treturn true\n\t\t}\n\t\tif currentRuntime.GetState() == pbtask.TaskState_INITIALIZED {\n\t\t\treturn true\n\t\t}\n\t}\n\n\tif newRuntime.GetState() == pbtask.TaskState_KILLING {\n\t\t// update to KILLING state from any non-terminal state is ok\n\t\treturn true\n\t}\n\n\t// any other state transition is invalid\n\treturn false\n}", "func execute(fn GraphiteReturner, job *Job, cache *lru.Cache) error {\n\tkey := fmt.Sprintf(\"%d-%d\", job.MonitorId, job.LastPointTs.Unix())\n\n\tpreConsider := time.Now()\n\n\tif time.Now().Sub(job.GeneratedAt) > time.Minute*time.Duration(10) {\n\t\texecutorNumTooOld.Inc(1)\n\t\treturn nil\n\t}\n\n\tif found, _ := cache.ContainsOrAdd(key, true); found {\n\t\t//log.Debug(\"T %s already done\", key)\n\t\texecutorNumAlreadyDone.Inc(1)\n\t\texecutorConsiderJobAlreadyDone.Value(time.Since(preConsider))\n\t\treturn nil\n\t}\n\n\t//log.Debug(\"T %s doing\", key)\n\texecutorNumOriginalTodo.Inc(1)\n\texecutorConsiderJobOriginalTodo.Value(time.Since(preConsider))\n\tgr, err := fn(job.OrgId)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"fatal: job %q: %q\", job, err)\n\t}\n\tif gr, ok := gr.(*graphite.GraphiteContext); ok {\n\t\tgr.AssertMinSeries = job.AssertMinSeries\n\t\tgr.AssertStart = job.AssertStart\n\t\tgr.AssertStep = job.AssertStep\n\t\tgr.AssertSteps = job.AssertSteps\n\t}\n\n\tpreExec := time.Now()\n\texecutorJobExecDelay.Value(preExec.Sub(job.LastPointTs))\n\tevaluator, err := NewGraphiteCheckEvaluator(gr, job.Definition)\n\tif err != nil {\n\t\t// expressions should be validated before they are stored in the db!\n\t\treturn fmt.Errorf(\"fatal: job %q: invalid check definition %q: %q\", job, job.Definition, err)\n\t}\n\n\tres, err := evaluator.Eval(job.LastPointTs)\n\tdurationExec := time.Since(preExec)\n\tlog.Debug(\"job results - job:%v err:%v res:%v\", job, err, res)\n\n\t// the bosun api abstracts parsing, execution and graphite querying for us via 1 call.\n\t// we want to have some individual times\n\tif gr, ok := gr.(*graphite.GraphiteContext); ok {\n\t\texecutorJobQueryGraphite.Value(gr.Dur)\n\t\texecutorJobParseAndEval.Value(durationExec - gr.Dur)\n\t\tif gr.MissingVals > 0 {\n\t\t\texecutorGraphiteMissingVals.Value(int64(gr.MissingVals))\n\t\t}\n\t\tif gr.EmptyResp != 0 {\n\t\t\texecutorGraphiteEmptyResponse.Inc(int64(gr.EmptyResp))\n\t\t}\n\t\tif gr.IncompleteResp != 0 {\n\t\t\texecutorGraphiteIncompleteResponse.Inc(int64(gr.IncompleteResp))\n\t\t}\n\t\tif gr.BadStart != 0 {\n\t\t\texecutorGraphiteBadStart.Inc(int64(gr.BadStart))\n\t\t}\n\t\tif gr.BadStep != 0 {\n\t\t\texecutorGraphiteBadStep.Inc(int64(gr.BadStep))\n\t\t}\n\t\tif gr.BadSteps != 0 {\n\t\t\texecutorGraphiteBadSteps.Inc(int64(gr.BadSteps))\n\t\t}\n\t}\n\n\tif err != nil {\n\t\texecutorAlertOutcomesErr.Inc(1)\n\t\treturn fmt.Errorf(\"Eval failed for job %q : %s\", job, err.Error())\n\t}\n\n\tupdateMonitorStateCmd := m.UpdateMonitorStateCommand{\n\t\tId: job.MonitorId,\n\t\tState: res,\n\t\tUpdated: job.LastPointTs, // this protects against jobs running out of order.\n\t\tChecked: preExec,\n\t}\n\tif err := bus.Dispatch(&updateMonitorStateCmd); err != nil {\n\t\t//check if we failed due to deadlock.\n\t\tif err.Error() == \"Error 1213: Deadlock found when trying to get lock; try restarting transaction\" {\n\t\t\terr = bus.Dispatch(&updateMonitorStateCmd)\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"non-fatal: failed to update monitor state: %q\", err)\n\t}\n\tif gr, ok := gr.(*graphite.GraphiteContext); ok {\n\t\trequests := \"\"\n\t\tfor _, trace := range gr.Traces {\n\t\t\tr := trace.Request\n\t\t\t// mangle trace.Response to keep the dumped out graphite\n\t\t\t// responses from crashing logstash\n\t\t\tresp := bytes.Replace(trace.Response, []byte(\"\\n\"), []byte(\"\\n> \"), -1)\n\t\t\trequests += fmt.Sprintf(\"\\ntargets: %s\\nfrom:%s\\nto:%s\\nresponse:%s\\n\", r.Targets, r.Start, r.End, resp)\n\t\t}\n\t\tlog.Debug(\"Job %s state_change=%t request traces: %s\", job, updateMonitorStateCmd.Affected > 0, requests)\n\t}\n\tif updateMonitorStateCmd.Affected > 0 && res != m.EvalResultUnknown {\n\t\t//emit a state change event.\n\t\tif job.Notifications.Enabled {\n\t\t\temails := strings.Split(job.Notifications.Addresses, \",\")\n\t\t\tif len(emails) < 1 {\n\t\t\t\tlog.Debug(\"no email addresses provided. OrgId: %d monitorId: %d\", job.OrgId, job.MonitorId)\n\t\t\t} else {\n\t\t\t\tfor _, email := range emails {\n\t\t\t\t\tlog.Info(\"sending email. addr=%s, orgId=%d, monitorId=%d, endpointSlug=%s, state=%s\", email, job.OrgId, job.MonitorId, job.EndpointSlug, res.String())\n\t\t\t\t}\n\t\t\t\tsendCmd := m.SendEmailCommand{\n\t\t\t\t\tTo: emails,\n\t\t\t\t\tTemplate: \"alerting_notification.html\",\n\t\t\t\t\tData: map[string]interface{}{\n\t\t\t\t\t\t\"EndpointId\": job.EndpointId,\n\t\t\t\t\t\t\"EndpointName\": job.EndpointName,\n\t\t\t\t\t\t\"EndpointSlug\": job.EndpointSlug,\n\t\t\t\t\t\t\"Settings\": job.Settings,\n\t\t\t\t\t\t\"CheckType\": job.MonitorTypeName,\n\t\t\t\t\t\t\"State\": res.String(),\n\t\t\t\t\t\t\"TimeLastData\": job.LastPointTs, // timestamp of the most recent data used\n\t\t\t\t\t\t\"TimeExec\": preExec, // when we executed the alerting rule and made the determination\n\t\t\t\t\t},\n\t\t\t\t}\n\n\t\t\t\tif err := bus.Dispatch(&sendCmd); err != nil {\n\t\t\t\t\tlog.Error(0, \"failed to send email to %s. OrgId: %d monitorId: %d due to: %s\", emails, job.OrgId, job.MonitorId, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t//store the result in graphite.\n\tjob.StoreResult(res)\n\n\tswitch res {\n\tcase m.EvalResultOK:\n\t\texecutorAlertOutcomesOk.Inc(1)\n\tcase m.EvalResultWarn:\n\t\texecutorAlertOutcomesWarn.Inc(1)\n\tcase m.EvalResultCrit:\n\t\texecutorAlertOutcomesCrit.Inc(1)\n\tcase m.EvalResultUnknown:\n\t\texecutorAlertOutcomesUnkn.Inc(1)\n\t}\n\n\treturn nil\n}", "func TakePipelineBuildJob(db gorp.SqlExecutor, store cache.Store, pbJobID int64, model string, workerName string, infos []sdk.SpawnInfo) (*sdk.PipelineBuildJob, error) {\n\tpbJob, err := GetPipelineBuildJobForUpdate(db, store, pbJobID)\n\tif err != nil {\n\t\treturn nil, sdk.WrapError(err, \"TakePipelineBuildJob> Cannot load pipeline build job\")\n\t}\n\tif pbJob.Status != sdk.StatusWaiting.String() {\n\t\tk := keyBookJob(pbJobID)\n\t\th := sdk.Hatchery{}\n\t\tif store.Get(k, &h) {\n\t\t\treturn nil, sdk.WrapError(sdk.ErrAlreadyTaken, \"TakePipelineBuildJob> job %d is not waiting status and was booked by hatchery %d. Current status:%s\", pbJobID, h.ID, pbJob.Status)\n\t\t}\n\t\treturn nil, sdk.WrapError(sdk.ErrAlreadyTaken, \"TakePipelineBuildJob> job %d is not waiting status. Current status:%s\", pbJobID, pbJob.Status)\n\t}\n\n\tpbJob.Model = model\n\tpbJob.Job.WorkerName = workerName\n\tpbJob.Start = time.Now()\n\tpbJob.Status = sdk.StatusBuilding.String()\n\n\tif err := prepareSpawnInfos(pbJob, infos); err != nil {\n\t\treturn nil, sdk.WrapError(err, \"TakePipelineBuildJob> Cannot prepare spawn infos\")\n\t}\n\n\tif err := UpdatePipelineBuildJob(db, pbJob); err != nil {\n\t\treturn nil, sdk.WrapError(err, \"TakePipelineBuildJob>Cannot update model on pipeline build job\")\n\t}\n\treturn pbJob, nil\n}", "func createThumbnail(\n\tctx context.Context,\n\tsrc types.Path,\n\timg image.Image,\n\tconfig types.ThumbnailSize,\n\tmediaMetadata *types.MediaMetadata,\n\tactiveThumbnailGeneration *types.ActiveThumbnailGeneration,\n\tmaxThumbnailGenerators int,\n\tdb storage.Database,\n\tlogger *log.Entry,\n) (busy bool, errorReturn error) {\n\tlogger = logger.WithFields(log.Fields{\n\t\t\"Width\": config.Width,\n\t\t\"Height\": config.Height,\n\t\t\"ResizeMethod\": config.ResizeMethod,\n\t})\n\n\t// Check if request is larger than original\n\tif config.Width >= img.Bounds().Dx() && config.Height >= img.Bounds().Dy() {\n\t\treturn false, nil\n\t}\n\n\tdst := GetThumbnailPath(src, config)\n\n\t// Note: getActiveThumbnailGeneration uses mutexes and conditions from activeThumbnailGeneration\n\tisActive, busy, err := getActiveThumbnailGeneration(dst, config, activeThumbnailGeneration, maxThumbnailGenerators, logger)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif busy {\n\t\treturn true, nil\n\t}\n\n\tif isActive {\n\t\t// Note: This is an active request that MUST broadcastGeneration to wake up waiting goroutines!\n\t\t// Note: broadcastGeneration uses mutexes and conditions from activeThumbnailGeneration\n\t\tdefer func() {\n\t\t\t// Note: errorReturn is the named return variable so we wrap this in a closure to re-evaluate the arguments at defer-time\n\t\t\t// if err := recover(); err != nil {\n\t\t\t// \tbroadcastGeneration(dst, activeThumbnailGeneration, config, err.(error), logger)\n\t\t\t// \tpanic(err)\n\t\t\t// }\n\t\t\tbroadcastGeneration(dst, activeThumbnailGeneration, config, errorReturn, logger)\n\t\t}()\n\t}\n\n\texists, err := isThumbnailExists(ctx, dst, config, mediaMetadata, db, logger)\n\tif err != nil || exists {\n\t\treturn false, err\n\t}\n\n\tstart := time.Now()\n\twidth, height, err := adjustSize(dst, img, config.Width, config.Height, config.ResizeMethod == types.Crop, logger)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tlogger.WithFields(log.Fields{\n\t\t\"ActualWidth\": width,\n\t\t\"ActualHeight\": height,\n\t\t\"processTime\": time.Since(start),\n\t}).Info(\"Generated thumbnail\")\n\n\tstat, err := os.Stat(string(dst))\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tthumbnailMetadata := &types.ThumbnailMetadata{\n\t\tMediaMetadata: &types.MediaMetadata{\n\t\t\tMediaID: mediaMetadata.MediaID,\n\t\t\tOrigin: mediaMetadata.Origin,\n\t\t\t// Note: the code currently always creates a JPEG thumbnail\n\t\t\tContentType: types.ContentType(\"image/jpeg\"),\n\t\t\tFileSizeBytes: types.FileSizeBytes(stat.Size()),\n\t\t},\n\t\tThumbnailSize: types.ThumbnailSize{\n\t\t\tWidth: config.Width,\n\t\t\tHeight: config.Height,\n\t\t\tResizeMethod: config.ResizeMethod,\n\t\t},\n\t}\n\n\terr = db.StoreThumbnail(ctx, thumbnailMetadata)\n\tif err != nil {\n\t\tlogger.WithError(err).WithFields(log.Fields{\n\t\t\t\"ActualWidth\": width,\n\t\t\t\"ActualHeight\": height,\n\t\t}).Error(\"Failed to store thumbnail metadata in database.\")\n\t\treturn false, err\n\t}\n\n\treturn false, nil\n}", "func StartAndCheckJobBatchSuccess(testName string) {\n\tnspMetrics.AddStartAndCheckJobBatchSuccess()\n\tmetrics.AddTestOne(testName, nspMetrics.Success)\n\tmetrics.AddTestZero(testName, nspMetrics.Errors)\n\tlogger.Infof(\"Test %s: SUCCESS\", testName)\n}", "func DockerBuild(w http.ResponseWriter, req *http.Request) (int, string) {\n\t// TODO: check content type\n\n\tbody, err := ioutil.ReadAll(req.Body)\n\tdefer req.Body.Close()\n\tif err != nil {\n\t\treturn 400, \"400 bad request\"\n\t}\n\n\tspec, err := job.NewSpec(body)\n\tif err != nil {\n\t\treturn 400, \"400 bad request\"\n\t}\n\n\treturn processJobHelper(spec, w, req)\n}", "func (restorer *APTRestorer) buildState(message *nsq.Message) (*models.RestoreState, error) {\n\trestoreState := models.NewRestoreState(message)\n\trestorer.Context.MessageLog.Info(\"Asking Pharos for WorkItem %s\", string(message.Body))\n\tworkItem, err := GetWorkItem(message, restorer.Context)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trestoreState.WorkItem = workItem\n\trestorer.Context.MessageLog.Info(\"Got WorkItem %d\", workItem.Id)\n\n\t// Get the saved state of this item, if there is one.\n\tif workItem.WorkItemStateId != nil {\n\t\trestorer.Context.MessageLog.Info(\"Asking Pharos for WorkItemState %d\", *workItem.WorkItemStateId)\n\t\tresp := restorer.Context.PharosClient.WorkItemStateGet(*workItem.WorkItemStateId)\n\t\tif resp.Error != nil {\n\t\t\trestorer.Context.MessageLog.Warning(\"Could not retrieve WorkItemState with id %d: %v\",\n\t\t\t\t*workItem.WorkItemStateId, resp.Error)\n\t\t} else {\n\t\t\tworkItemState := resp.WorkItemState()\n\t\t\tsavedState := &models.RestoreState{}\n\t\t\terr = json.Unmarshal([]byte(workItemState.State), savedState)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Could not unmarshal WorkItemState.State: %v\", err)\n\t\t\t}\n\t\t\trestoreState.PackageSummary = savedState.PackageSummary\n\t\t\trestoreState.ValidateSummary = savedState.ValidateSummary\n\t\t\trestoreState.CopySummary = savedState.CopySummary\n\t\t\trestoreState.RecordSummary = savedState.RecordSummary\n\t\t\trestoreState.LocalBagDir = savedState.LocalBagDir\n\t\t\trestoreState.LocalTarFile = savedState.LocalTarFile\n\t\t\trestoreState.RestoredToUrl = savedState.RestoredToUrl\n\t\t\trestoreState.CopiedToRestorationAt = savedState.CopiedToRestorationAt\n\t\t\trestorer.Context.MessageLog.Info(\"Got WorkItemState %d\", *workItem.WorkItemStateId)\n\t\t}\n\t}\n\n\t// Get the intellectual object. This should not have changed\n\t// during the processing of this request, because Pharos does\n\t// not permit delete operations while a restore is pending.\n\trestorer.Context.MessageLog.Info(\"Asking Pharos for IntellectualObject %s\",\n\t\trestoreState.WorkItem.ObjectIdentifier)\n\tresponse := restorer.Context.PharosClient.IntellectualObjectGet(\n\t\trestoreState.WorkItem.ObjectIdentifier, true, false)\n\tif response.Error != nil {\n\t\treturn nil, fmt.Errorf(\"Error retrieving IntellectualObject %s from Pharos: %v\", restoreState.WorkItem.ObjectIdentifier, response.Error)\n\t}\n\trestoreState.IntellectualObject = response.IntellectualObject()\n\trestorer.Context.MessageLog.Info(\"Got IntellectualObject %s\",\n\t\trestoreState.WorkItem.ObjectIdentifier)\n\n\t// LocalBagDir will not be set if we were unable to retrieve\n\t// WorkItemState above.\n\tif restoreState.LocalBagDir == \"\" {\n\t\trestoreState.LocalBagDir = filepath.Join(\n\t\t\trestorer.Context.Config.RestoreDirectory,\n\t\t\trestoreState.IntellectualObject.Identifier)\n\t}\n\trestorer.Context.MessageLog.Info(\"Set local bag dir to %s\", restoreState.LocalBagDir)\n\treturn restoreState, nil\n}", "func (fsm *DeployFSMContext) checkServiceReady() (bool, error) {\n\truntime := fsm.Runtime\n\t// do not check if nil for compatibility\n\tif fsm.Deployment.Extra.ServicePhaseStartAt != nil {\n\t\tstartCheckPoint := fsm.Deployment.Extra.ServicePhaseStartAt.Add(30 * time.Second)\n\t\tif time.Now().Before(startCheckPoint) {\n\t\t\tfsm.pushLog(fmt.Sprintf(\"checking too early, delay to: %s\", startCheckPoint.String()))\n\t\t\t// too early to check\n\t\t\treturn false, nil\n\t\t}\n\t}\n\tisReplicasZero := false\n\tfor _, s := range fsm.Spec.Services {\n\t\tif s.Deployments.Replicas == 0 {\n\t\t\tisReplicasZero = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif isReplicasZero {\n\t\tfsm.pushLog(\"checking status by inspect\")\n\t\t// we do double check to prevent `fake Healthy`\n\t\t// runtime.ScheduleName must have\n\t\tsg, err := fsm.getServiceGroup()\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\treturn sg.Status == \"Ready\" || sg.Status == \"Healthy\", nil\n\t}\n\n\t// 获取addon状态\n\tserviceGroup, err := fsm.getServiceGroup()\n\tif err != nil {\n\t\tfsm.pushLog(fmt.Sprintf(\"获取service状态失败,%s\", err.Error()))\n\t\treturn false, nil\n\t}\n\tfsm.pushLog(fmt.Sprintf(\"checking status: %s, servicegroup: %v\", serviceGroup.Status, runtime.ScheduleName))\n\t// 如果状态是failed,说明服务或者job运行失败\n\tif serviceGroup.Status == apistructs.StatusFailed {\n\t\treturn false, errors.New(serviceGroup.LastMessage)\n\t}\n\t// 如果状态是ready或者healthy,说明服务已经发起来了\n\truntimeStatus := apistructs.RuntimeStatusUnHealthy\n\tif serviceGroup.Status == apistructs.StatusReady || serviceGroup.Status == apistructs.StatusHealthy {\n\t\truntimeStatus = apistructs.RuntimeStatusHealthy\n\t}\n\truntimeItem := fsm.Runtime\n\tif runtimeItem.Status != runtimeStatus {\n\t\truntimeItem.Status = runtimeStatus\n\t\tif err := fsm.db.UpdateRuntime(runtime); err != nil {\n\t\t\tlogrus.Errorf(\"failed to update runtime status changed, runtime: %v, err: %v\", runtime.ID, err.Error())\n\t\t\treturn false, nil\n\t\t}\n\t}\n\tif runtimeStatus == apistructs.RuntimeStatusHealthy {\n\t\treturn true, nil\n\t}\n\treturn false, nil\n}", "func (e *dockerExec) create(ctx context.Context) (execState, error) {\n\tif _, err := e.client.ContainerInspect(ctx, e.containerName()); err == nil {\n\t\treturn execCreated, nil\n\t} else if !docker.IsErrNotFound(err) {\n\t\treturn execInit, errors.E(\"ContainerInspect\", e.containerName(), kind(err), err)\n\t}\n\tif err := e.Executor.ensureImage(ctx, e.Config.Image); err != nil {\n\t\te.Log.Errorf(\"error ensuring image %s: %v\", e.Config.Image, err)\n\t\treturn execInit, errors.E(\"ensureimage\", e.Config.Image, err)\n\t}\n\t// Map the products to input arguments and volume bindings for\n\t// the container. Currently we map the whole repository (named by\n\t// the digest) and then include the cut in the arguments passed to\n\t// the job.\n\targs := make([]interface{}, len(e.Config.Args))\n\tfor i, iv := range e.Config.Args {\n\t\tif iv.Out {\n\t\t\twhich := strconv.Itoa(iv.Index)\n\t\t\targs[i] = path.Join(\"/return\", which)\n\t\t} else {\n\t\t\tflat := iv.Fileset.Flatten()\n\t\t\targv := make([]string, len(flat))\n\t\t\tfor j, jv := range flat {\n\t\t\t\targPath := fmt.Sprintf(\"arg/%d/%d\", i, j)\n\t\t\t\tbinds := map[string]digest.Digest{}\n\t\t\t\tfor path, file := range jv.Map {\n\t\t\t\t\tbinds[path] = file.ID\n\t\t\t\t}\n\t\t\t\tif err := e.repo.Materialize(e.path(argPath), binds); err != nil {\n\t\t\t\t\treturn execInit, err\n\t\t\t\t}\n\t\t\t\targv[j] = \"/\" + argPath\n\t\t\t}\n\t\t\targs[i] = strings.Join(argv, \" \")\n\t\t}\n\t}\n\t// Set up temporary directory.\n\tos.MkdirAll(e.path(\"tmp\"), 0777)\n\tos.MkdirAll(e.path(\"return\"), 0777)\n\thostConfig := &container.HostConfig{\n\t\tBinds: []string{\n\t\t\te.hostPath(\"arg\") + \":/arg\",\n\t\t\te.hostPath(\"tmp\") + \":/tmp\",\n\t\t\te.hostPath(\"return\") + \":/return\",\n\t\t},\n\t\tNetworkMode: container.NetworkMode(\"host\"),\n\t\t// Try to ensure that jobs we control get killed before the reflowlet,\n\t\t// so that we don't lose adjacent tasks unnecessarily and so that\n\t\t// errors are more sensible to the user.\n\t\tOomScoreAdj: 1000,\n\t}\n\tif e.Config.NeedDockerAccess {\n\t\thostConfig.Binds = append(hostConfig.Binds, \"/var/run/docker.sock:/var/run/docker.sock\")\n\t}\n\n\t// Restrict docker memory usage if specified by the user.\n\t// If the docker container memory limit (the cgroup limit) is exceeded\n\t// before the OOM Killer kills the process, the following message\n\t// is recorded in /dev/kmsg:\n\t// Memory cgroup out of memory: Kill process <pid>\n\tif mem := e.Config.Resources[\"mem\"]; mem > 0 && e.Executor.HardMemLimit {\n\t\thostConfig.Resources.Memory = int64(mem)\n\t\thostConfig.Resources.MemorySwap = int64(mem) + int64(hardLimitSwapMem)\n\t}\n\n\tenv := []string{\n\t\t\"tmp=/tmp\",\n\t\t\"TMPDIR=/tmp\",\n\t\t\"HOME=/tmp\",\n\t}\n\tif outputs := e.Config.OutputIsDir; outputs != nil {\n\t\tfor i, isdir := range outputs {\n\t\t\tif isdir {\n\t\t\t\tos.MkdirAll(e.path(\"return\", strconv.Itoa(i)), 0777)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tenv = append(env, \"out=/return/default\")\n\t}\n\t// TODO(marius): this is a hack for Earl to use the AWS tool.\n\tif e.Config.NeedAWSCreds {\n\t\tcreds, err := e.Executor.AWSCreds.Get()\n\t\tif err != nil {\n\t\t\t// We mark this as temporary, because most of the time it is.\n\t\t\t// TODO(marius): can we get better error classification from\n\t\t\t// the AWS SDK?\n\t\t\treturn execInit, errors.E(\"run\", e.id, errors.Temporary, err)\n\t\t}\n\t\t// TODO(marius): region?\n\t\tenv = append(env, \"AWS_ACCESS_KEY_ID=\"+creds.AccessKeyID)\n\t\tenv = append(env, \"AWS_SECRET_ACCESS_KEY=\"+creds.SecretAccessKey)\n\t\tenv = append(env, \"AWS_SESSION_TOKEN=\"+creds.SessionToken)\n\t}\n\tconfig := &container.Config{\n\t\tImage: e.Config.Image,\n\t\t// We use a login shell here as many Docker images are configured\n\t\t// with /root/.profile, etc.\n\t\tEntrypoint: []string{\"/bin/bash\", \"-e\", \"-l\", \"-o\", \"pipefail\", \"-c\", fmt.Sprintf(e.Config.Cmd, args...)},\n\t\tCmd: []string{},\n\t\tEnv: env,\n\t\tLabels: map[string]string{\"reflow-id\": e.id.Hex()},\n\t\tUser: dockerUser,\n\t}\n\tnetworkingConfig := &network.NetworkingConfig{}\n\tif _, err := e.client.ContainerCreate(ctx, config, hostConfig, networkingConfig, e.containerName()); err != nil {\n\t\treturn execInit, errors.E(\n\t\t\t\"ContainerCreate\",\n\t\t\tkind(err),\n\t\t\te.containerName(),\n\t\t\tfmt.Sprint(config), fmt.Sprint(hostConfig), fmt.Sprint(networkingConfig),\n\t\t\terr,\n\t\t)\n\t}\n\treturn execCreated, nil\n}", "func TestStartJob(t *testing.T) {\n\tc := &kc{}\n\tbr := BuildRequest{\n\t\tOrg: \"owner\",\n\t\tRepo: \"kube\",\n\t\tBaseRef: \"master\",\n\t\tBaseSHA: \"abc\",\n\t\tPulls: []Pull{\n\t\t\t{\n\t\t\t\tNumber: 5,\n\t\t\t\tAuthor: \"a\",\n\t\t\t\tSHA: \"123\",\n\t\t\t},\n\t\t},\n\t}\n\tif _, err := startJob(c, \"job-name\", \"Context\", br); err != nil {\n\t\tt.Fatalf(\"Didn't expect error starting job: %v\", err)\n\t}\n\tlabels := c.job.Metadata.Labels\n\tif labels[\"jenkins-job-name\"] != \"job-name\" {\n\t\tt.Errorf(\"Jenkins job name label incorrect: %s\", labels[\"jenkins-job-name\"])\n\t}\n\tif labels[\"owner\"] != \"owner\" {\n\t\tt.Errorf(\"Owner label incorrect: %s\", labels[\"owner\"])\n\t}\n\tif labels[\"repo\"] != \"kube\" {\n\t\tt.Errorf(\"Repo label incorrect: %s\", labels[\"kube\"])\n\t}\n\tif labels[\"pr\"] != \"5\" {\n\t\tt.Errorf(\"PR label incorrect: %s\", labels[\"pr\"])\n\t}\n}", "func (b *Build) IsPushImageSuccess() bool {\n\tif b.event.Version.Operation == api.DeployOperation {\n\t\treturn true\n\t}\n\treturn (b.status & pushImageSuccess) != 0\n}", "func isRetryableTerminationState(s *v1.ContainerStateTerminated) bool {\n\t// TODO(jlewi): Need to match logic in\n\t// https://cs.corp.google.com/piper///depot/google3/cloud/ml/beta/job/training_job_state_util.cc?l=88\n\tif s.Reason == \"OOMKilled\" {\n\t\t// If the user's process causes an OOM and Docker kills the container,\n\t\t// the termination reason of ContainerState will be specified to\n\t\t// 'OOMKilled'. In this case, we can't assume this to be a retryable error.\n\t\t//\n\t\t// This check should happen before checking the termination log, since\n\t\t// if the container terminated with an OOM, the termination log may not\n\t\t// be written.\n\t\treturn false\n\t}\n\n\tif s.Message == \"\" {\n\t\t// launcher.sh should produce a termination log message. So if Kubernetes\n\t\t// doesn't report a termmination message then we can infer that\n\t\t// launcher.sh didn't exit cleanly. For example, the container might\n\t\t// have failed to start. We consider this a retryable error regardless\n\t\t// of the actual exit code.\n\t\treturn true\n\t}\n\n\t// TODO(jlewi): Should we use the exit code reported in the termination\n\t// log message and not the ExitCode reported by the container.\n\n\tif s.ExitCode >= 0 && s.ExitCode <= 127 {\n\t\t// For the exit_code in [0, 127]:\n\t\t// 0 means success,\n\t\t// 1 - 127 corresponds to permanent user errors.\n\t\t// We don't want to retry for both cases.\n\t\t// More info about exit status can be found in:\n\t\t// https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html\n\t\treturn false\n\t}\n\n\t// For the remaining cases that exit_code from workers that doesn't\n\t// fall into [0, 127]. They can be:\n\t// 137 corresponds to SIGKILL,\n\t// 143 corresponds to SIGTERM,\n\t// other values that have undefined behavior.\n\t// We treat them as internal errors for now and all the internal errors\n\t// will be retired.\n\treturn true\n}", "func updateTaskState(task *api.Task) api.TaskStatus {\n\t//The task is the minimum status of all its essential containers unless the\n\t//status is terminal in which case it's that status\n\tlog.Debug(\"Updating task\", \"task\", task)\n\n\t// minContainerStatus is the minimum status of all essential containers\n\tminContainerStatus := api.ContainerDead + 1\n\t// minContainerStatus is the minimum status of all containers to be used in\n\t// the edge case of no essential containers\n\tabsoluteMinContainerStatus := minContainerStatus\n\tfor _, cont := range task.Containers {\n\t\tlog.Debug(\"On container\", \"cont\", cont)\n\t\tif cont.KnownStatus < absoluteMinContainerStatus {\n\t\t\tabsoluteMinContainerStatus = cont.KnownStatus\n\t\t}\n\t\tif !cont.Essential {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Terminal states\n\t\tif cont.KnownStatus == api.ContainerStopped {\n\t\t\tif task.KnownStatus < api.TaskStopped {\n\t\t\t\ttask.KnownStatus = api.TaskStopped\n\t\t\t\treturn task.KnownStatus\n\t\t\t}\n\t\t} else if cont.KnownStatus == api.ContainerDead {\n\t\t\tif task.KnownStatus < api.TaskDead {\n\t\t\t\ttask.KnownStatus = api.TaskDead\n\t\t\t\treturn task.KnownStatus\n\t\t\t}\n\t\t}\n\t\t// Non-terminal\n\t\tif cont.KnownStatus < minContainerStatus {\n\t\t\tminContainerStatus = cont.KnownStatus\n\t\t}\n\t}\n\n\tif minContainerStatus == api.ContainerDead+1 {\n\t\tlog.Warn(\"Task with no essential containers; all properly formed tasks should have at least one essential container\", \"task\", task)\n\n\t\t// If there's no essential containers, let's just assume the container\n\t\t// with the earliest status is essential and proceed.\n\t\tminContainerStatus = absoluteMinContainerStatus\n\t}\n\n\tlog.Info(\"MinContainerStatus is \" + minContainerStatus.String())\n\n\tif minContainerStatus == api.ContainerCreated {\n\t\tif task.KnownStatus < api.TaskCreated {\n\t\t\ttask.KnownStatus = api.TaskCreated\n\t\t\treturn task.KnownStatus\n\t\t}\n\t} else if minContainerStatus == api.ContainerRunning {\n\t\tif task.KnownStatus < api.TaskRunning {\n\t\t\ttask.KnownStatus = api.TaskRunning\n\t\t\treturn task.KnownStatus\n\t\t}\n\t} else if minContainerStatus == api.ContainerStopped {\n\t\tif task.KnownStatus < api.TaskStopped {\n\t\t\ttask.KnownStatus = api.TaskStopped\n\t\t\treturn task.KnownStatus\n\t\t}\n\t} else if minContainerStatus == api.ContainerDead {\n\t\tif task.KnownStatus < api.TaskDead {\n\t\t\ttask.KnownStatus = api.TaskDead\n\t\t\treturn task.KnownStatus\n\t\t}\n\t}\n\treturn api.TaskStatusNone\n}", "func WorkflowKeyAvailability(key string) ([]string, []string) {\n\tswitch key {\n\tcase \"jobs.<job_id>.outputs.<output_id>\":\n\t\treturn []string{\"env\", \"github\", \"inputs\", \"job\", \"matrix\", \"needs\", \"runner\", \"secrets\", \"steps\", \"strategy\", \"vars\"}, []string{}\n\tcase \"jobs.<job_id>.steps.continue-on-error\", \"jobs.<job_id>.steps.env\", \"jobs.<job_id>.steps.name\", \"jobs.<job_id>.steps.run\", \"jobs.<job_id>.steps.timeout-minutes\", \"jobs.<job_id>.steps.with\", \"jobs.<job_id>.steps.working-directory\":\n\t\treturn []string{\"env\", \"github\", \"inputs\", \"job\", \"matrix\", \"needs\", \"runner\", \"secrets\", \"steps\", \"strategy\", \"vars\"}, []string{\"hashfiles\"}\n\tcase \"jobs.<job_id>.container.env.<env_id>\", \"jobs.<job_id>.services.<service_id>.env.<env_id>\":\n\t\treturn []string{\"env\", \"github\", \"inputs\", \"job\", \"matrix\", \"needs\", \"runner\", \"secrets\", \"strategy\", \"vars\"}, []string{}\n\tcase \"jobs.<job_id>.environment.url\":\n\t\treturn []string{\"env\", \"github\", \"inputs\", \"job\", \"matrix\", \"needs\", \"runner\", \"steps\", \"strategy\", \"vars\"}, []string{}\n\tcase \"jobs.<job_id>.steps.if\":\n\t\treturn []string{\"env\", \"github\", \"inputs\", \"job\", \"matrix\", \"needs\", \"runner\", \"steps\", \"strategy\", \"vars\"}, []string{\"always\", \"cancelled\", \"failure\", \"hashfiles\", \"success\"}\n\tcase \"jobs.<job_id>.container.credentials\", \"jobs.<job_id>.services.<service_id>.credentials\":\n\t\treturn []string{\"env\", \"github\", \"inputs\", \"matrix\", \"needs\", \"secrets\", \"strategy\", \"vars\"}, []string{}\n\tcase \"jobs.<job_id>.defaults.run\":\n\t\treturn []string{\"env\", \"github\", \"inputs\", \"matrix\", \"needs\", \"strategy\", \"vars\"}, []string{}\n\tcase \"on.workflow_call.outputs.<output_id>.value\":\n\t\treturn []string{\"github\", \"inputs\", \"jobs\", \"vars\"}, []string{}\n\tcase \"jobs.<job_id>.env\", \"jobs.<job_id>.secrets.<secrets_id>\":\n\t\treturn []string{\"github\", \"inputs\", \"matrix\", \"needs\", \"secrets\", \"strategy\", \"vars\"}, []string{}\n\tcase \"jobs.<job_id>.concurrency\", \"jobs.<job_id>.container\", \"jobs.<job_id>.container.image\", \"jobs.<job_id>.continue-on-error\", \"jobs.<job_id>.environment\", \"jobs.<job_id>.name\", \"jobs.<job_id>.runs-on\", \"jobs.<job_id>.services\", \"jobs.<job_id>.timeout-minutes\", \"jobs.<job_id>.with.<with_id>\":\n\t\treturn []string{\"github\", \"inputs\", \"matrix\", \"needs\", \"strategy\", \"vars\"}, []string{}\n\tcase \"jobs.<job_id>.strategy\":\n\t\treturn []string{\"github\", \"inputs\", \"needs\", \"vars\"}, []string{}\n\tcase \"jobs.<job_id>.if\":\n\t\treturn []string{\"github\", \"inputs\", \"needs\", \"vars\"}, []string{\"always\", \"cancelled\", \"failure\", \"success\"}\n\tcase \"env\":\n\t\treturn []string{\"github\", \"inputs\", \"secrets\", \"vars\"}, []string{}\n\tcase \"concurrency\", \"on.workflow_call.inputs.<inputs_id>.default\", \"run-name\":\n\t\treturn []string{\"github\", \"inputs\", \"vars\"}, []string{}\n\tdefault:\n\t\treturn nil, nil\n\t}\n}", "func (b *Build) IsRunning() bool {\n\treturn (b.Status == StatusStarted || b.Status == StatusEnqueue)\n}", "func (manager *Manager) Start(projectUpdateID string) {\n\tswitch manager.state {\n\tcase notRunningState:\n\t\t// Start elasticsearch update job async and return the job ID\n\t\tesJobIDs, err := manager.startProjectTagUpdater()\n\t\tif err != nil {\n\t\t\tlogrus.Errorf(\"Failed to start Elasticsearch Project rule update job projectUpdateID: %q\",\n\t\t\t\tprojectUpdateID)\n\t\t\tmanager.sendFailedEvent(fmt.Sprintf(\n\t\t\t\t\"Failed to start Elasticsearch Project rule update job projectUpdateID: %q\", projectUpdateID),\n\t\t\t\tprojectUpdateID)\n\t\t\treturn\n\t\t}\n\t\tmanager.esJobIDs = esJobIDs\n\n\t\tmanager.projectUpdateID = projectUpdateID\n\t\tmanager.state = runningState\n\t\tgo manager.waitingForJobToComplete()\n\tcase runningState:\n\t\tif manager.projectUpdateID == projectUpdateID {\n\t\t\t// Do nothing. The job has ready started\n\t\t} else {\n\t\t\tmanager.sendFailedEvent(fmt.Sprintf(\n\t\t\t\t\"Can not start another project update %q is running\", manager.projectUpdateID),\n\t\t\t\tprojectUpdateID)\n\t\t}\n\tdefault:\n\t\t// error state not found\n\t\tmanager.sendFailedEvent(fmt.Sprintf(\n\t\t\t\"Internal error state %q eventID %q\", manager.state, manager.projectUpdateID),\n\t\t\tprojectUpdateID)\n\t}\n}", "func launchStatusCheck(conf *Config) error {\n\t// verify we can connect to message bus\n\tconn, err := Connect(conf)\n\tdefer conn.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\tlog.Info().Msg(\"OK ... AMQP Connection\")\n\n\t// verify we get a message channel\n\tch, err := GetAMQPChannel(conn)\n\tdefer ch.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\tlog.Info().Msg(\"OK ... AMQP Channel\")\n\n\t// verify the pre-configured exchange exists\n\tif err := CheckExchangeExists(ch, conf.Publisher.Exchange); err != nil {\n\t\treturn err\n\t}\n\tlog.Info().\n\t\tStr(\"exchange\", conf.Publisher.Exchange.Name).\n\t\tMsg(\"OK ... AMQP Exchange\")\n\n\treturn nil\n}", "func checkInstallStatus(cs kube.Cluster) error {\n\tscopes.Framework.Infof(\"checking IstioOperator CR status\")\n\tgvr := schema.GroupVersionResource{\n\t\tGroup: \"install.istio.io\",\n\t\tVersion: \"v1alpha1\",\n\t\tResource: \"istiooperators\",\n\t}\n\n\tvar unhealthyCN []string\n\tretryFunc := func() error {\n\t\tus, err := cs.GetUnstructured(gvr, IstioNamespace, \"test-istiocontrolplane\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get istioOperator resource: %v\", err)\n\t\t}\n\t\tusIOPStatus := us.UnstructuredContent()[\"status\"]\n\t\tif usIOPStatus == nil {\n\t\t\tif _, err := cs.CoreV1().Services(OperatorNamespace).Get(context.TODO(), \"istio-operator\",\n\t\t\t\tkubeApiMeta.GetOptions{}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"istio operator svc is not ready: %v\", err)\n\t\t\t}\n\t\t\tif _, err := cs.CheckPodsAreReady(kube2.NewPodFetch(cs.Accessor, OperatorNamespace)); err != nil {\n\t\t\t\treturn fmt.Errorf(\"istio operator pod is not ready: %v\", err)\n\t\t\t}\n\n\t\t\treturn fmt.Errorf(\"status not found from the istioOperator resource\")\n\t\t}\n\t\tusIOPStatus = usIOPStatus.(map[string]interface{})\n\t\tiopStatusString, err := json.Marshal(usIOPStatus)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to marshal istioOperator status: %v\", err)\n\t\t}\n\t\tstatus := &api.InstallStatus{}\n\t\tjspb := jsonpb.Unmarshaler{AllowUnknownFields: true}\n\t\tif err := jspb.Unmarshal(bytes.NewReader(iopStatusString), status); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to unmarshal istioOperator status: %v\", err)\n\t\t}\n\t\terrs := util.Errors{}\n\t\tunhealthyCN = []string{}\n\t\tif status.Status != api.InstallStatus_HEALTHY {\n\t\t\terrs = util.AppendErr(errs, fmt.Errorf(\"got IstioOperator status: %v\", status.Status))\n\t\t}\n\n\t\tfor cn, cnstatus := range status.ComponentStatus {\n\t\t\tif cnstatus.Status != api.InstallStatus_HEALTHY {\n\t\t\t\tunhealthyCN = append(unhealthyCN, cn)\n\t\t\t\terrs = util.AppendErr(errs, fmt.Errorf(\"got component: %s status: %v\", cn, cnstatus.Status))\n\t\t\t}\n\t\t}\n\t\treturn errs.ToError()\n\t}\n\terr := retry.UntilSuccess(retryFunc, retry.Timeout(retryTimeOut), retry.Delay(retryDelay))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"istioOperator status is not healthy: %v\", err)\n\t}\n\treturn nil\n}", "func UpdatePipelineBuildJobStatus(db gorp.SqlExecutor, pbJob *sdk.PipelineBuildJob, status sdk.Status) error {\n\tvar query string\n\tquery = `SELECT status FROM pipeline_build_job WHERE id = $1 FOR UPDATE`\n\tvar currentStatus string\n\tif err := db.QueryRow(query, pbJob.ID).Scan(&currentStatus); err != nil {\n\t\treturn sdk.WrapError(err, \"UpdatePipelineBuildJobStatus> Cannot lock pipeline build job %d\", pbJob.ID)\n\t}\n\n\tswitch status {\n\tcase sdk.StatusBuilding:\n\t\tif currentStatus != sdk.StatusWaiting.String() {\n\t\t\treturn fmt.Errorf(\"UpdatePipelineBuildJobStatus> Cannot update status of PipelineBuildJob %d to %s, expected current status %s, got %s\",\n\t\t\t\tpbJob.ID, status, sdk.StatusWaiting, currentStatus)\n\t\t}\n\t\tpbJob.Start = time.Now()\n\t\tpbJob.Status = status.String()\n\n\tcase sdk.StatusFail, sdk.StatusSuccess, sdk.StatusDisabled, sdk.StatusSkipped, sdk.StatusStopped:\n\t\tif currentStatus != string(sdk.StatusWaiting) && currentStatus != string(sdk.StatusBuilding) && status != sdk.StatusDisabled && status != sdk.StatusSkipped {\n\t\t\tlog.Debug(\"UpdatePipelineBuildJobStatus> Status is %s, cannot update %d to %s\", currentStatus, pbJob.ID, status)\n\t\t\t// too late, Nate\n\t\t\treturn nil\n\t\t}\n\t\tpbJob.Done = time.Now()\n\t\tpbJob.Status = status.String()\n\tdefault:\n\t\treturn fmt.Errorf(\"UpdatePipelineBuildJobStatus> Cannot update PipelineBuildJob %d to status %v\", pbJob.ID, status.String())\n\t}\n\n\tif err := UpdatePipelineBuildJob(db, pbJob); err != nil {\n\t\treturn sdk.WrapError(err, \"UpdatePipelineBuildJobStatus> Cannot update pipeline build job %d\", pbJob.ID)\n\t}\n\n\tpb, errLoad := LoadPipelineBuildByID(db, pbJob.PipelineBuildID)\n\tif errLoad != nil {\n\t\treturn sdk.WrapError(errLoad, \"UpdatePipelineBuildJobStatus> Cannot load pipeline build %d: %s\", pbJob.PipelineBuildID, errLoad)\n\t}\n\n\tevent.PublishActionBuild(pb, pbJob)\n\treturn nil\n}", "func TestDaemon_JobStatusWithNoCache(t *testing.T) {\n\td, start, clean, _, _, restart := mockDaemon(t)\n\tstart()\n\tdefer clean()\n\tw := newWait(t)\n\n\tctx := context.Background()\n\t// Perform update\n\tid := updatePolicy(ctx, t, d)\n\n\t// Make sure the job finishes first\n\tw.ForJobSucceeded(d, id)\n\n\t// Clear the cache like we've just restarted\n\trestart(func() {\n\t\td.JobStatusCache = &job.StatusCache{Size: 100}\n\t})\n\n\t// Now check if we can get the job status from the commit\n\tw.ForJobSucceeded(d, id)\n}", "func (p Pipeline) BuildImages(force bool) error {\n\tif Verbose {\n\t\tpipelineLogger.Printf(\"Build Images:\")\n\t}\n\tcount, elapsedTime, totalElapsedTime, err := p.runCommand(runConfig{\n\t\tselection: func(step Step) bool {\n\t\t\treturn step.IsBuildable()\n\t\t},\n\t\trun: func(runner Runner, step Step) func() error {\n\t\t\treturn runner.ImageBuilder(step, force)\n\t\t},\n\t})\n\tif Verbose {\n\t\tpipelineLogger.Printf(\"Build %d images in %s\", count, elapsedTime)\n\t\tpipelineLogger.Printf(\"Total time spent building images: %s\", totalElapsedTime)\n\t}\n\treturn err\n}", "func Application(cfg config.Config, suiteName string) error {\n\tlogger = log.WithFields(log.Fields{\"Suite\": suiteName})\n\n\t// Trigger build via web hook\n\terr := httpUtils.TriggerWebhookPush(cfg, defaults.App2BranchToBuildFrom, defaults.App2CommitID, defaults.App2SSHRepository, defaults.App2SharedSecret, logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\tlogger.Infof(\"First job was triggered\")\n\n\t// Get job\n\tjobSummary, err := test.WaitForCheckFuncWithValueOrTimeout(cfg, func(cfg config.Config) (*models.JobSummary, error) {\n\t\treturn job.GetLastPipelineJobWithStatus(cfg, defaults.App2Name, \"Running\", logger)\n\t}, logger)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tjobName := jobSummary.Name\n\tlogger.Infof(\"First job name: %s\", jobName)\n\n\t// Another build should cause second job to queue up\n\t// Trigger another build via web hook\n\ttime.Sleep(1 * time.Second)\n\terr = httpUtils.TriggerWebhookPush(cfg, defaults.App2BranchToBuildFrom, defaults.App2CommitID, defaults.App2SSHRepository, defaults.App2SharedSecret, logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\tlogger.Infof(\"Second job was triggered\")\n\n\terr = test.WaitForCheckFuncOrTimeout(cfg, func(cfg config.Config) error {\n\t\t_, err := job.GetLastPipelineJobWithStatus(cfg, defaults.App2Name, \"Queued\", logger)\n\t\treturn err\n\t}, logger)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlogger.Info(\"Second job was queued\")\n\tjobStatus, err := test.WaitForCheckFuncWithValueOrTimeout(cfg, func(cfg config.Config) (string, error) {\n\t\treturn job.IsDone(cfg, defaults.App2Name, jobName, logger)\n\t}, logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif jobStatus != \"Succeeded\" {\n\t\treturn fmt.Errorf(\"expected job status was Success, but got %s\", jobStatus)\n\t}\n\tlogger.Info(\"First job was completed\")\n\tsteps := job.GetSteps(cfg, defaults.App2Name, jobName)\n\n\texpectedSteps := []expectedStep{\n\t\t{name: \"clone-config\", components: []string{}},\n\t\t{name: \"prepare-pipelines\", components: []string{}},\n\t\t{name: \"radix-pipeline\", components: []string{}},\n\t\t{name: \"clone\", components: []string{}},\n\t\t{name: \"build-app\", components: []string{\"app\"}},\n\t\t{name: \"build-redis\", components: []string{\"redis\"}},\n\t}\n\n\tif len(steps) != len(expectedSteps) {\n\t\treturn errors.New(\"number of pipeline steps was not as expected\")\n\t}\n\n\tfor index, step := range steps {\n\t\tif !strings.EqualFold(step.Name, expectedSteps[index].name) {\n\t\t\treturn fmt.Errorf(\"expeced step %s, but got %s\", expectedSteps[index].name, step.Name)\n\t\t}\n\n\t\tif !array.EqualElements(step.Components, expectedSteps[index].components) {\n\t\t\treturn fmt.Errorf(\"expeced components %s, but got %s\", expectedSteps[index].components, step.Components)\n\t\t}\n\t}\n\n\tstepLog := job.GetLogForStep(cfg, defaults.App2Name, jobName, \"build-app\", logger)\n\t// Validate if Dockerfile build output contains SHA256 hash of build secrets:\n\t// https://github.com/equinor/radix-canarycicd-test-2/blob/master/Dockerfile#L9\n\tif !strings.Contains(stepLog, Secret1ValueSha256) || !strings.Contains(stepLog, Secret2ValueSha256) {\n\t\treturn errors.New(\"build secrets are not contained in build log\")\n\t}\n\n\tjobSummary, err = test.WaitForCheckFuncWithValueOrTimeout(cfg, func(cfg config.Config) (*models.JobSummary, error) {\n\t\treturn job.GetLastPipelineJobWithStatus(cfg, defaults.App2Name, \"Running\", logger)\n\t}, logger)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Stop job and verify that it has been stopped\n\tjobName = jobSummary.Name\n\tlogger.Infof(\"Second job name: %s\", jobName)\n\terr = job.Stop(cfg, defaults.App2Name, jobName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = test.WaitForCheckFuncOrTimeout(cfg, func(cfg config.Config) error {\n\t\t_, err := job.GetLastPipelineJobWithStatus(cfg, defaults.App2Name, \"Stopped\", logger)\n\t\treturn err\n\t}, logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlogger.Info(\"Second job was stopped\")\n\treturn nil\n}", "func buildImage(id, baseDir, stageDir string, buildEnv map[string]string) (CmdResult, error) {\n\tlog.Printf(\"Building image for %s\", id)\n\n\tdir := filepath.Join(baseDir, stageDir)\n\tvar b strings.Builder\n\tfor k, v := range buildEnv {\n\t\tfmt.Fprintf(&b, \"--build-arg %s=%s \", k, fmt.Sprintf(`\"%s\"`, v))\n\t}\n\tenv := b.String()\n\n\tcmdStr := fmt.Sprintf(\"docker build %s-t %s .\", env, id)\n\t// sh -c is a workaround that allow us to have double quotes around environment variable values.\n\t// Those are needed when the environment variables have whitespaces, for instance a NAME, like in\n\t// TREPB.\n\tcmd := exec.Command(\"bash\", \"-c\", cmdStr)\n\tcmd.Dir = dir\n\tvar outb, errb bytes.Buffer\n\tcmd.Stdout = &outb\n\tcmd.Stderr = &errb\n\n\tlog.Printf(\"$ %s\", cmdStr)\n\terr := cmd.Run()\n\tswitch err.(type) {\n\tcase *exec.Error:\n\t\tcmdResultError := CmdResult{\n\t\t\tExitStatus: statusCode(err),\n\t\t\tCmd: cmdStr,\n\t\t}\n\t\treturn cmdResultError, fmt.Errorf(\"command was not executed correctly: %s\", err)\n\t}\n\n\tcmdResult := CmdResult{\n\t\tStdout: outb.String(),\n\t\tStderr: errb.String(),\n\t\tCmd: cmdStr,\n\t\tCmdDir: dir,\n\t\tExitStatus: statusCode(err),\n\t\tEnv: os.Environ(),\n\t}\n\n\treturn cmdResult, err\n}", "func (this *Task) image(zkc zk.ZK) (string, string, string, error) {\n\tif this.ImagePath == \"\" {\n\n\t\tdefaultReleaseWatchPath, _, err := RegistryKeyValue(KReleaseWatch, map[string]interface{}{\n\t\t\t\"Domain\": this.domain,\n\t\t\t\"Service\": this.service,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", \"\", err\n\t\t}\n\n\t\treleaseNode, err := zkc.Get(defaultReleaseWatchPath)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", \"\", err\n\t\t}\n\n\t\tthis.ImagePath = releaseNode.GetValueString()\n\t\tglog.Infoln(\"ImagePath defaults to\", this.ImagePath, \"for job\", *this)\n\t}\n\n\tglog.Infoln(\"Container image from image path\", this.ImagePath)\n\tdocker_info, err := zkc.Get(this.ImagePath)\n\tif err != nil {\n\t\treturn \"\", \"\", \"\", err\n\t}\n\timage := docker_info.GetValueString()\n\tversion := image[strings.LastIndex(image, \":\")+1:]\n\treturn fmt.Sprintf(\"/%s/%s/%s\", this.domain, this.service, version), version, image, nil\n}", "func TestJobSuccess(t *testing.T) {\n\tif !isTravis() {\n\t\tt.Skip(\"skipping integration test; it will only run on travis\")\n\t\treturn\n\t}\n\n\tjobDone := make(chan struct{}, 1)\n\n\tst, err := NewStore(testDBURL)\n\tif err != nil {\n\t\tt.Fatalf(\"NewStore returned %v\", err)\n\t}\n\tdefer dropDatabase(t, testDBURL)\n\n\tm := jobqueue.New(jobqueue.SetStore(st))\n\n\tf := func(args ...interface{}) error {\n\t\tif len(args) != 1 {\n\t\t\treturn fmt.Errorf(\"expected len(args) == 1, have %d\", len(args))\n\t\t}\n\t\ts, ok := args[0].(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"expected type of 1st arg == string, have %T\", args[0])\n\t\t}\n\t\tif have, want := s, \"Hello\"; have != want {\n\t\t\treturn fmt.Errorf(\"expected 1st arg = %q, have %q\", want, have)\n\t\t}\n\t\tjobDone <- struct{}{}\n\t\treturn nil\n\t}\n\terr = m.Register(\"topic\", f)\n\tif err != nil {\n\t\tt.Fatalf(\"Register failed with %v\", err)\n\t}\n\terr = m.Start()\n\tif err != nil {\n\t\tt.Fatalf(\"Start failed with %v\", err)\n\t}\n\tjob := &jobqueue.Job{Topic: \"topic\", Args: []interface{}{\"Hello\"}}\n\terr = m.Add(job)\n\tif err != nil {\n\t\tt.Fatalf(\"Add failed with %v\", err)\n\t}\n\tif job.ID == \"\" {\n\t\tt.Fatalf(\"Job ID = %q\", job.ID)\n\t}\n\ttimeout := 2 * time.Second\n\tselect {\n\tcase <-jobDone:\n\tcase <-time.After(timeout):\n\t\tt.Fatal(\"Processor func timed out\")\n\t}\n}", "func IsTraining(projectID string, location string) (bool, error) {\n\tctx := context.Background()\n\tclient, err := automl.NewClient(ctx)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"NewClient: %v\", err)\n\t}\n\tdefer client.Close()\n\n\treq := &lropb.ListOperationsRequest{\n\t\tName: fmt.Sprintf(\"projects/%s/locations/%s\", projectID, location),\n\t}\n\n\tit := client.LROClient.ListOperations(ctx, req)\n\n\tfor {\n\t\top, err := it.Next()\n\t\tif err == iterator.Done {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"ListOperations.Next: %v\", err)\n\t\t}\n\n\t\tif op.GetDone() {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Since the OP is still running check if its an ImportJob or model training.\n\t\topMeta := &automlpb.OperationMetadata{}\n\n\t\terr = op.GetMetadata().UnmarshalTo(opMeta)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Could not unmarshal metadata for: %v; error: %v\", op.GetName(), err)\n\t\t}\n\n\t\t// Creating a dataset is not actually a long running operation; when we create a dataset we are just\n\t\t// defining the name essentionally.\n\t\tif opMeta.GetCreateDatasetDetails() != nil {\n\t\t\tdetails := opMeta.GetCreateDatasetDetails()\n\n\t\t\tif details != nil {\n\t\t\t\tlog.Infof(\"Found running op dataset pp: %v\\n%v\",op.Name, toString(details))\n\t\t\t}\n\t\t\treturn true, nil\n\t\t}\n\n\t\t// ImportData is a long running operation can take hours\n\t\t// TODO(jlewi): How do we associate a running ImportData with its dataset? Neither Metadata, nor details appears\n\t\t// to contain the dataset id.\n\t\tif opMeta.GetImportDataDetails() != nil {\n\t\t\tlog.Infof(\"ImportData Op: %v; metadata:\\n%v\", op.Name, toString(opMeta))\n\t\t\tdetails := opMeta.GetImportDataDetails()\n\n\t\t\tif details != nil {\n\t\t\t\tlog.Infof(\"ImportDataDetails Op: %v; Details:\\n%v\",op.Name, toString(details))\n\t\t\t}\n\n\t\t\treturn true, nil\n\t\t}\n\n\t\tif opMeta.GetCreateModelDetails() != nil {\n\t\t\tdetails := opMeta.GetCreateModelDetails()\n\n\t\t\tif details != nil {\n\t\t\t\tlog.Infof(\"Create Model Op: %v; Details:\\n%v\",op.Name, toString(details))\n\t\t\t}\n\n\t\t\treturn true, nil\n\t\t}\n\t}\n\n\treturn false, nil\n}", "func check(err error) {\n\tif err == nil {\n\t\treturn\n\t}\n\n\tbuildMU.Lock()\n\tdefer buildMU.Unlock()\n\tbuild.Status = pb.Status_INFRA_FAILURE\n\tbuild.SummaryMarkdown = fmt.Sprintf(\"run_annotations failure: `%s`\", err)\n\tclient.WriteBuild(build)\n\tfmt.Fprintln(os.Stderr, err)\n\tos.Exit(1)\n}", "func (m *MinikubeRunner) EnsureRunning(opts ...string) {\n\ts, _, err := m.Status()\n\tif err != nil {\n\t\tm.T.Errorf(\"error getting status for ensure running: %v\", err)\n\t}\n\tif s != state.Running.String() {\n\t\tstdout, stderr, err := m.start(opts...)\n\t\tif err != nil {\n\t\t\tm.T.Errorf(\"error starting while running EnsureRunning : %v , stdout %s stderr %s\", err, stdout, stderr)\n\t\t}\n\t}\n\tm.CheckStatus(state.Running.String())\n}", "func (c *Client) Build(ctx context.Context, opts BuildOptions) error {\n\timageRef, err := c.parseTagReference(opts.Image)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"invalid image name '%s'\", opts.Image)\n\t}\n\n\tappPath, err := c.processAppPath(opts.AppPath)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"invalid app path '%s'\", opts.AppPath)\n\t}\n\n\tproxyConfig := c.processProxyConfig(opts.ProxyConfig)\n\n\tbuilderRef, err := c.processBuilderName(opts.Builder)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"invalid builder '%s'\", opts.Builder)\n\t}\n\n\trawBuilderImage, err := c.imageFetcher.Fetch(ctx, builderRef.Name(), image.FetchOptions{Daemon: true, PullPolicy: opts.PullPolicy})\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to fetch builder image '%s'\", builderRef.Name())\n\t}\n\n\tbldr, err := c.getBuilder(rawBuilderImage)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"invalid builder %s\", style.Symbol(opts.Builder))\n\t}\n\n\trunImageName := c.resolveRunImage(opts.RunImage, imageRef.Context().RegistryStr(), builderRef.Context().RegistryStr(), bldr.Stack(), opts.AdditionalMirrors, opts.Publish)\n\trunImage, err := c.validateRunImage(ctx, runImageName, opts.PullPolicy, opts.Publish, bldr.StackID)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"invalid run-image '%s'\", runImageName)\n\t}\n\n\tvar runMixins []string\n\tif _, err := dist.GetLabel(runImage, stack.MixinsLabel, &runMixins); err != nil {\n\t\treturn err\n\t}\n\n\tfetchedBPs, order, err := c.processBuildpacks(ctx, bldr.Image(), bldr.Buildpacks(), bldr.Order(), bldr.StackID, opts)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := c.validateMixins(fetchedBPs, bldr, runImageName, runMixins); err != nil {\n\t\treturn errors.Wrap(err, \"validating stack mixins\")\n\t}\n\n\tbuildEnvs := map[string]string{}\n\tfor _, envVar := range opts.ProjectDescriptor.Build.Env {\n\t\tbuildEnvs[envVar.Name] = envVar.Value\n\t}\n\n\tfor k, v := range opts.Env {\n\t\tbuildEnvs[k] = v\n\t}\n\n\tephemeralBuilder, err := c.createEphemeralBuilder(rawBuilderImage, buildEnvs, order, fetchedBPs)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer c.docker.ImageRemove(context.Background(), ephemeralBuilder.Name(), types.ImageRemoveOptions{Force: true})\n\n\tvar builderPlatformAPIs builder.APISet\n\tbuilderPlatformAPIs = append(builderPlatformAPIs, ephemeralBuilder.LifecycleDescriptor().APIs.Platform.Deprecated...)\n\tbuilderPlatformAPIs = append(builderPlatformAPIs, ephemeralBuilder.LifecycleDescriptor().APIs.Platform.Supported...)\n\n\tif !supportsPlatformAPI(builderPlatformAPIs) {\n\t\tc.logger.Debugf(\"pack %s supports Platform API(s): %s\", c.version, strings.Join(build.SupportedPlatformAPIVersions.AsStrings(), \", \"))\n\t\tc.logger.Debugf(\"Builder %s supports Platform API(s): %s\", style.Symbol(opts.Builder), strings.Join(builderPlatformAPIs.AsStrings(), \", \"))\n\t\treturn errors.Errorf(\"Builder %s is incompatible with this version of pack\", style.Symbol(opts.Builder))\n\t}\n\n\timgOS, err := rawBuilderImage.OS()\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"getting builder OS\")\n\t}\n\n\tprocessedVolumes, warnings, err := processVolumes(imgOS, opts.ContainerConfig.Volumes)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, warning := range warnings {\n\t\tc.logger.Warn(warning)\n\t}\n\n\tfileFilter, err := getFileFilter(opts.ProjectDescriptor)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trunImageName, err = pname.TranslateRegistry(runImageName, c.registryMirrors, c.logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tprojectMetadata := platform.ProjectMetadata{}\n\tif c.experimental {\n\t\tversion := opts.ProjectDescriptor.Project.Version\n\t\tsourceURL := opts.ProjectDescriptor.Project.SourceURL\n\t\tif version != \"\" || sourceURL != \"\" {\n\t\t\tprojectMetadata.Source = &platform.ProjectSource{\n\t\t\t\tType: \"project\",\n\t\t\t\tVersion: map[string]interface{}{\"declared\": version},\n\t\t\t\tMetadata: map[string]interface{}{\"url\": sourceURL},\n\t\t\t}\n\t\t}\n\t}\n\n\t// Default mode: if the TrustBuilder option is not set, trust the suggested builders.\n\tif opts.TrustBuilder == nil {\n\t\topts.TrustBuilder = IsSuggestedBuilderFunc\n\t}\n\n\tlifecycleOpts := build.LifecycleOptions{\n\t\tAppPath: appPath,\n\t\tImage: imageRef,\n\t\tBuilder: ephemeralBuilder,\n\t\tLifecycleImage: ephemeralBuilder.Name(),\n\t\tRunImage: runImageName,\n\t\tProjectMetadata: projectMetadata,\n\t\tClearCache: opts.ClearCache,\n\t\tPublish: opts.Publish,\n\t\tTrustBuilder: opts.TrustBuilder(opts.Builder),\n\t\tUseCreator: false,\n\t\tDockerHost: opts.DockerHost,\n\t\tCacheImage: opts.CacheImage,\n\t\tHTTPProxy: proxyConfig.HTTPProxy,\n\t\tHTTPSProxy: proxyConfig.HTTPSProxy,\n\t\tNoProxy: proxyConfig.NoProxy,\n\t\tNetwork: opts.ContainerConfig.Network,\n\t\tAdditionalTags: opts.AdditionalTags,\n\t\tVolumes: processedVolumes,\n\t\tDefaultProcessType: opts.DefaultProcessType,\n\t\tFileFilter: fileFilter,\n\t\tWorkspace: opts.Workspace,\n\t\tGID: opts.GroupID,\n\t\tPreviousImage: opts.PreviousImage,\n\t\tInteractive: opts.Interactive,\n\t\tTermui: termui.NewTermui(imageRef.Name(), ephemeralBuilder, runImageName),\n\t\tSBOMDestinationDir: opts.SBOMDestinationDir,\n\t}\n\n\tlifecycleVersion := ephemeralBuilder.LifecycleDescriptor().Info.Version\n\t// Technically the creator is supported as of platform API version 0.3 (lifecycle version 0.7.0+) but earlier versions\n\t// have bugs that make using the creator problematic.\n\tlifecycleSupportsCreator := !lifecycleVersion.LessThan(semver.MustParse(minLifecycleVersionSupportingCreator))\n\n\tif lifecycleSupportsCreator && opts.TrustBuilder(opts.Builder) {\n\t\tlifecycleOpts.UseCreator = true\n\t\t// no need to fetch a lifecycle image, it won't be used\n\t\tif err := c.lifecycleExecutor.Execute(ctx, lifecycleOpts); err != nil {\n\t\t\treturn errors.Wrap(err, \"executing lifecycle\")\n\t\t}\n\n\t\treturn c.logImageNameAndSha(ctx, opts.Publish, imageRef)\n\t}\n\n\tif !opts.TrustBuilder(opts.Builder) {\n\t\tif lifecycleImageSupported(imgOS, lifecycleVersion) {\n\t\t\tlifecycleImageName := opts.LifecycleImage\n\t\t\tif lifecycleImageName == \"\" {\n\t\t\t\tlifecycleImageName = fmt.Sprintf(\"%s:%s\", internalConfig.DefaultLifecycleImageRepo, lifecycleVersion.String())\n\t\t\t}\n\n\t\t\timgArch, err := rawBuilderImage.Architecture()\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"getting builder architecture\")\n\t\t\t}\n\n\t\t\tlifecycleImage, err := c.imageFetcher.Fetch(\n\t\t\t\tctx,\n\t\t\t\tlifecycleImageName,\n\t\t\t\timage.FetchOptions{Daemon: true, PullPolicy: opts.PullPolicy, Platform: fmt.Sprintf(\"%s/%s\", imgOS, imgArch)},\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, \"fetching lifecycle image\")\n\t\t\t}\n\n\t\t\tlifecycleOpts.LifecycleImage = lifecycleImage.Name()\n\t\t} else {\n\t\t\treturn errors.Errorf(\"Lifecycle %s does not have an associated lifecycle image. Builder must be trusted.\", lifecycleVersion.String())\n\t\t}\n\t}\n\n\tif err := c.lifecycleExecutor.Execute(ctx, lifecycleOpts); err != nil {\n\t\treturn errors.Wrap(err, \"executing lifecycle. This may be the result of using an untrusted builder\")\n\t}\n\n\treturn c.logImageNameAndSha(ctx, opts.Publish, imageRef)\n}", "func getJobStatus(row chunk.Row) (JobStatus, string, error) {\n\t// ending status has the highest priority\n\tendTimeIsNull := row.IsNull(2)\n\tif !endTimeIsNull {\n\t\tresultMsgIsNull := row.IsNull(3)\n\t\tif !resultMsgIsNull {\n\t\t\tresultMessage := row.GetString(3)\n\t\t\treturn JobFinished, resultMessage, nil\n\t\t}\n\t\terrorMessage := row.GetString(4)\n\t\treturn JobFailed, errorMessage, nil\n\t}\n\n\tisAlive := row.GetInt64(1) == 1\n\tstartTimeIsNull := row.IsNull(5)\n\texpectedStatus := row.GetEnum(0).String()\n\n\tswitch expectedStatus {\n\tcase \"canceled\":\n\t\treturn JobCanceled, \"\", nil\n\tcase \"paused\":\n\t\tif startTimeIsNull || isAlive {\n\t\t\treturn JobPaused, \"\", nil\n\t\t}\n\t\treturn JobFailed, \"job expected paused but the node is timeout\", nil\n\tcase \"running\":\n\t\tif startTimeIsNull {\n\t\t\treturn JobPending, \"\", nil\n\t\t}\n\t\tif isAlive {\n\t\t\treturn JobRunning, \"\", nil\n\t\t}\n\t\treturn JobFailed, \"job expected running but the node is timeout\", nil\n\tdefault:\n\t\treturn JobFailed, fmt.Sprintf(\"unexpected job status %s\", expectedStatus), nil\n\t}\n}", "func CfnWorkflow_IsConstruct(x interface{}) *bool {\n\t_init_.Initialize()\n\n\tvar returns *bool\n\n\t_jsii_.StaticInvoke(\n\t\t\"aws-cdk-lib.aws_glue.CfnWorkflow\",\n\t\t\"isConstruct\",\n\t\t[]interface{}{x},\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "func runBuilding(args []string) int {\n\tsuccess := false\n\tw, wf, r, rf, err := prepare(args, buildingOpt.Overwrite)\n\tif wf != nil {\n\t\tdefer wf(&success, buildingOpt.Backup)\n\t}\n\tif rf != nil {\n\t\tdefer rf()\n\t}\n\tif err != nil {\n\t\treturn handleError(err)\n\t}\n\n\terr = csvutil.Building(r, w, buildingOpt.BuildingOption)\n\tif err != nil {\n\t\treturn handleError(err)\n\t}\n\n\tsuccess = true\n\treturn 0\n}", "func (spec *SourceSpec) IsContainerBuild() bool {\n\treturn spec.ContainerImage.Image != \"\"\n}", "func (runner Runner) RequiresBuild() bool {\n\treturn true\n}", "func IsFinished(job *batchv1.Job) bool {\n\tfor _, condition := range job.Status.Conditions {\n\t\tswitch condition.Type {\n\t\tcase batchv1.JobComplete:\n\t\t\treturn true\n\t\tcase batchv1.JobFailed:\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (twrkr *twerk) status() Status {\n\tlive := twrkr.liveWorkersNum.Get()\n\tworking := twrkr.currentlyWorkingNum.Get()\n\tinQueue := len(twrkr.jobListener)\n\n\treturn Status{\n\t\tlive: live,\n\t\tworking: working,\n\t\tjobsInQueue: inQueue,\n\t}\n}", "func running() bool {\n\treturn runCalled.Load() != 0\n}", "func (s *StateStrategy) StartScript(){\n util.Info(\"*****************Begin Start up Script ********************* \")\n if s.bapplySuccess == false {\n s.RollBackStart()\n return\n }\n\n ipCnt, err_code := strconv.Atoi(s.ipCnt)\n slotCnt, err_code1 := strconv.Atoi(s.slotCnt)\n if nil != err_code || nil != err_code1 {\n util.Error(fmt.Sprintf(\"Start Params Wrong, ipCnt %s, slotCnt %s\", s.ipCnt,s.slotCnt))\n }\n\n // compute np\n np := ipCnt*slotCnt\n shellPath := fmt.Sprintf(\"./test.sh %d %s %s %s %s %s %s %v %v %v\",np,s.algType,s.epochs,s.batchsize,s.learningrate,s.trainPath,s.savePath,s.taskId,env.REPORT_ADDR,env.REPORT_TOKEN)\n util.Infof(\"shellpath = %v\",shellPath)\n cmd := exec.Command(\"/bin/bash\",\"-c\",shellPath) //Cmd init\n util.Infof(\"Start Exec Cmd Arg: %v , Process PID: %v \",cmd.Args,s.pid)\n\n // get local env\n cmd.Env = s.GetCmdEnv()\n\n // Run starts the specified command and waits for it to complete\n var out bytes.Buffer\n var stderr bytes.Buffer\n cmd.Stdout = &out\n cmd.Stderr = &stderr\n err := cmd.Run()\n if nil != err {\n util.Error(fmt.Sprintf(\"Cmd Go Wrong, err : %v\",stderr.String()))\n util.Error(fmt.Sprint(err) + \": \" + stderr.String())\n s.RollBackStart()\n return\n }\n\n s.pid = cmd.Process.Pid\n util.Infof(\"Cmd Arg: %v , Process PID: %v \",cmd.Args,s.pid)\n\n if out.String() == \"\" {\n util.Info(\"*****************Start up Script Success********************* \")\n }else{\n util.Error(\"*****************Start up Script Unknow Wrong : \" + out.String())\n s.RollBackStart()\n return\n }\n\n s.UpdateState()\n}", "func (j *JobJob) Valid() bool {\n\treturn j.TargetJob != nil\n}", "func bootstrapAppImageBuild(c *cli.Context) error {\n\n\t// check if the number of arguments are stictly 1, if not\n\t// return\n\tif c.NArg() != 1 {\n\t\tlog.Fatal(\"Please specify the path to the AppDir which you would like to aid.\")\n\n\t}\n\tfileToAppDir := c.Args().Get(0)\n\n\t// does the file exist? if not early-exit\n\tif ! helpers.CheckIfFileOrFolderExists(fileToAppDir) {\n\t\tlog.Fatal(\"The specified directory does not exist\")\n\t}\n\n\t// Add the location of the executable to the $PATH\n\thelpers.AddHereToPath()\n\n\n\t// Check for needed files on $PATH\n\ttools := []string{\"file\", \"mksquashfs\", \"desktop-file-validate\", \"uploadtool\", \"patchelf\", \"desktop-file-validate\", \"patchelf\"} // \"sh\", \"strings\", \"grep\" no longer needed?; \"curl\" is needed for uploading only, \"glib-compile-schemas\" is needed in some cases only\n\t// curl is needed by uploadtool; TODO: Replace uploadtool with native Go code\n\t// \"sh\", \"strings\", \"grep\" are needed by appdirtool to parse qt_prfxpath; TODO: Replace with native Go code\n\tfor _, t := range tools {\n\t\t_, err := exec.LookPath(t)\n\t\tif err != nil {\n\t\t\tlog.Println(\"Required helper tool\", t, \"missing\")\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\t// Check whether we have a sufficient version of mksquashfs for -offset\n\tif helpers.CheckIfSquashfsVersionSufficient(\"mksquashfs\") == false {\n\t\tos.Exit(1)\n\t}\n\n\t// Check if is directory, then assume we want to convert an AppDir into an AppImage\n\tfileToAppDir, _ = filepath.EvalSymlinks(fileToAppDir)\n\tif info, err := os.Stat(fileToAppDir); err == nil && info.IsDir() {\n\t\tGenerateAppImage(fileToAppDir)\n\t} else {\n\t\t// TODO: If it is a file, then check if it is an AppImage and if yes, extract it\n\t\tlog.Fatal(\"Supplied argument is not a directory \\n\" +\n\t\t\t\"To extract an AppImage, run it with --appimage-extract \\n\")\n\n\t}\n\treturn nil\n}", "func checkArtStates(ctx context.Context, invID invocations.ID, arts []*artifactCreationRequest) (reqs []*artifactCreationRequest, realm string, err error) {\n\tvar invState pb.Invocation_State\n\n\teg, ctx := errgroup.WithContext(ctx)\n\teg.Go(func() error {\n\t\treturn invocations.ReadColumns(ctx, invID, map[string]any{\n\t\t\t\"State\": &invState, \"Realm\": &realm,\n\t\t})\n\t})\n\n\teg.Go(func() (err error) {\n\t\treqs, err = findNewArtifacts(ctx, invID, arts)\n\t\treturn\n\t})\n\n\tswitch err := eg.Wait(); {\n\tcase err != nil:\n\t\treturn nil, \"\", err\n\tcase invState != pb.Invocation_ACTIVE:\n\t\treturn nil, \"\", appstatus.Errorf(codes.FailedPrecondition, \"%s is not active\", invID.Name())\n\t}\n\treturn reqs, realm, nil\n}", "func (self *Manager) checkProgramState(program *Program, checkLock *sync.WaitGroup) {\n\tvar isStopping = self.stopping\n\tdefer checkLock.Done()\n\n\tif isStopping {\n\t\treturn\n\t}\n\n\tswitch program.GetState() {\n\tcase ProgramStopped:\n\t\t// first-time start for autostart programs\n\t\tif program.AutoStart && !program.HasEverBeenStarted() {\n\t\t\tlog.Debugf(\"[%s] Starting program for the first time\", program.Name)\n\t\t\tprogram.ShouldAutoRestart() // do this here to \"seed\" the scheduler with the first schedule time\n\t\t\tprogram.Start()\n\t\t}\n\n\tcase ProgramExited:\n\t\t// automatic restart of cleanly-exited programs\n\t\tif program.ShouldAutoRestart() {\n\t\t\tlog.Debugf(\"[%s] Automatically restarting cleanly-exited program\", program.Name)\n\t\t\tprogram.Start()\n\t\t}\n\n\tcase ProgramBackoff:\n\t\tif program.ShouldAutoRestart() {\n\t\t\tlog.Debugf(\"[%s] Automatically restarting program after backoff (retry %d/%d)\",\n\t\t\t\tprogram.Name,\n\t\t\t\tprogram.processRetryCount,\n\t\t\t\tprogram.StartRetries)\n\t\t\tprogram.Start()\n\t\t} else {\n\t\t\tlog.Debugf(\"[%s] Marking program fatal after %d/%d retries\",\n\t\t\t\tprogram.Name,\n\t\t\t\tprogram.processRetryCount,\n\t\t\t\tprogram.StartRetries)\n\t\t\tprogram.StopFatal()\n\t\t}\n\t}\n}", "func ProcessStateSuccess(p *os.ProcessState,) bool", "func NewBuildState(config *Configuration) *BuildState {\n\tgraph := NewGraph()\n\tstate := &BuildState{\n\t\tGraph: graph,\n\t\tpendingParses: make(chan ParseTask, 10000),\n\t\tpendingActions: make(chan Task, 1000),\n\t\thashers: map[string]*fs.PathHasher{\n\t\t\t// For compatibility reasons the sha1 hasher has no suffix.\n\t\t\t\"sha1\": fs.NewPathHasher(RepoRoot, config.Build.Xattrs, sha1.New, \"sha1\"),\n\t\t\t\"sha256\": fs.NewPathHasher(RepoRoot, config.Build.Xattrs, sha256.New, \"sha256\"),\n\t\t\t\"crc32\": fs.NewPathHasher(RepoRoot, config.Build.Xattrs, newCRC32, \"crc32\"),\n\t\t\t\"crc64\": fs.NewPathHasher(RepoRoot, config.Build.Xattrs, newCRC64, \"crc64\"),\n\t\t\t\"blake3\": fs.NewPathHasher(RepoRoot, config.Build.Xattrs, newBlake3, \"blake3\"),\n\t\t\t\"xxhash\": fs.NewPathHasher(RepoRoot, config.Build.Xattrs, newXXHash, \"xxhash\"),\n\t\t},\n\t\tProcessExecutor: executorFromConfig(config),\n\t\tStartTime: startTime,\n\t\tConfig: config,\n\t\tRepoConfig: config,\n\t\tVerifyHashes: true,\n\t\tNeedBuild: true,\n\t\tXattrsSupported: config.Build.Xattrs,\n\t\tCoverage: TestCoverage{Files: map[string][]LineCoverage{}},\n\t\tTargetArch: config.Build.Arch,\n\t\tArch: cli.HostArch(),\n\t\tstats: &lockedStats{},\n\t\tprogress: &stateProgress{\n\t\t\tnumActive: 1, // One for the initial target adding on the main thread.\n\t\t\tnumPending: 1,\n\t\t\tpendingTargets: cmap.New[BuildLabel, chan struct{}](cmap.DefaultShardCount, hashBuildLabel),\n\t\t\tpendingPackages: cmap.New[packageKey, chan struct{}](cmap.DefaultShardCount, hashPackageKey),\n\t\t\tpackageWaits: cmap.New[packageKey, chan struct{}](cmap.DefaultShardCount, hashPackageKey),\n\t\t\tinternalResults: make(chan *BuildResult, 1000),\n\t\t\tcycleDetector: cycleDetector{graph: graph},\n\t\t},\n\t\tinitOnce: new(sync.Once),\n\t\tpreloadDownloadOnce: new(sync.Once),\n\t}\n\n\tstate.PathHasher = state.Hasher(config.Build.HashFunction)\n\tstate.progress.allStates = []*BuildState{state}\n\tstate.Hashes.Config = config.Hash()\n\tfor _, exp := range config.Parse.ExperimentalDir {\n\t\tstate.experimentalLabels = append(state.experimentalLabels, BuildLabel{PackageName: exp, Name: \"...\"})\n\t}\n\tgo state.forwardResults()\n\treturn state\n}", "func (i *invocation) isActive() bool {\n\treturn i.queuedOperations.Len() > 0 || i.executingWorkersCount > 0\n}", "func (p *PodmanTestIntegration) BuildImage(dockerfile, imageName string, layers string) {\n\t// TODO\n}", "func (o *initJobOpts) askDockerfile() (isDfSelected bool, err error) {\n\tif o.dockerfilePath != \"\" || o.image != \"\" {\n\t\treturn true, nil\n\t}\n\tif err = o.dockerEngine.CheckDockerEngineRunning(); err != nil {\n\t\tvar errDaemon *dockerengine.ErrDockerDaemonNotResponsive\n\t\tswitch {\n\t\tcase errors.Is(err, dockerengine.ErrDockerCommandNotFound):\n\t\t\tlog.Info(\"Docker command is not found; Copilot won't build from a Dockerfile.\\n\")\n\t\t\treturn false, nil\n\t\tcase errors.As(err, &errDaemon):\n\t\t\tlog.Info(\"Docker daemon is not responsive; Copilot won't build from a Dockerfile.\\n\")\n\t\t\treturn false, nil\n\t\tdefault:\n\t\t\treturn false, fmt.Errorf(\"check if docker engine is running: %w\", err)\n\t\t}\n\t}\n\tdf, err := o.dockerfileSel.Dockerfile(\n\t\tfmt.Sprintf(fmtWkldInitDockerfilePrompt, color.HighlightUserInput(o.name)),\n\t\tfmt.Sprintf(fmtWkldInitDockerfilePathPrompt, color.HighlightUserInput(o.name)),\n\t\twkldInitDockerfileHelpPrompt,\n\t\twkldInitDockerfilePathHelpPrompt,\n\t\tfunc(v interface{}) error {\n\t\t\treturn validatePath(afero.NewOsFs(), v)\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"select Dockerfile: %w\", err)\n\t}\n\tif df == selector.DockerfilePromptUseImage {\n\t\treturn false, nil\n\t}\n\to.dockerfilePath = df\n\treturn true, nil\n}", "func (bldr *stackBuilder) Succeeded() bool {\n\treturn !bldr.failed\n}" ]
[ "0.5804885", "0.576292", "0.57217044", "0.56923383", "0.5667544", "0.5643866", "0.56260103", "0.5621047", "0.55758095", "0.5512292", "0.5495707", "0.54381084", "0.5428398", "0.5407359", "0.5348316", "0.5330184", "0.53044367", "0.5302426", "0.5284066", "0.52470475", "0.5225209", "0.52098966", "0.5205371", "0.5205035", "0.51705945", "0.51440954", "0.5134171", "0.51336575", "0.51315695", "0.51306", "0.5098524", "0.5092978", "0.5076843", "0.5076279", "0.5051923", "0.5050195", "0.50448465", "0.50355947", "0.50315595", "0.50297403", "0.501612", "0.5007842", "0.500766", "0.4972332", "0.4946587", "0.49447295", "0.49426648", "0.4939377", "0.4917301", "0.4913231", "0.4909241", "0.49083453", "0.4902477", "0.49011776", "0.48989165", "0.4896408", "0.48963448", "0.4875938", "0.4872168", "0.48610657", "0.48565295", "0.48561996", "0.48480493", "0.48472258", "0.4844314", "0.4830866", "0.48306665", "0.4829727", "0.4828304", "0.48213112", "0.48204434", "0.48176962", "0.48096645", "0.48075503", "0.4806411", "0.4806084", "0.48038182", "0.4800449", "0.47984862", "0.47898617", "0.47893274", "0.4788031", "0.47878042", "0.47785848", "0.47695833", "0.4762726", "0.47617772", "0.4761582", "0.47534326", "0.47475305", "0.47439232", "0.47410676", "0.4737177", "0.47353894", "0.47339278", "0.47322416", "0.47296995", "0.47290686", "0.47279134", "0.4727279" ]
0.7990586
0
Save changes the configuration of the hostonly network.
func (n *hostOnlyNetwork) Save(vbox VBoxManager) error { if err := n.SaveIPv4(vbox); err != nil { return err } if n.DHCP { vbox.vbm("hostonlyif", "ipconfig", n.Name, "--dhcp") // not implemented as of VirtualBox 4.3 } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (ctx *BoltDbContext) SaveHost(host Host) error {\n\treturn ctx.db.Update(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket([]byte(hostsBucketName))\n\t\terr := b.Put([]byte(host.Address), host.GobEncode())\n\t\treturn err\n\t})\n}", "func (hc *Hailconfig) Save() error {\n\terr := hc.f.Reset()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to reset\")\n\t}\n\treturn toml.NewEncoder(hc.f).Encode(&hc.config)\n}", "func (smCfg *smConfiguration) Save(clientCfg *smclient.ClientConfig) error {\n\tsmCfg.viperEnv.Set(\"url\", clientCfg.URL)\n\tsmCfg.viperEnv.Set(\"user\", clientCfg.User)\n\tsmCfg.viperEnv.Set(\"ssl_disabled\", clientCfg.SSLDisabled)\n\n\tsmCfg.viperEnv.Set(\"access_token\", clientCfg.AccessToken)\n\tsmCfg.viperEnv.Set(\"refresh_token\", clientCfg.RefreshToken)\n\tsmCfg.viperEnv.Set(\"expiry\", clientCfg.ExpiresIn.Format(time.RFC1123Z))\n\n\tsmCfg.viperEnv.Set(\"client_id\", clientCfg.ClientID)\n\tsmCfg.viperEnv.Set(\"client_secret\", clientCfg.ClientSecret)\n\tsmCfg.viperEnv.Set(\"issuer_url\", clientCfg.IssuerURL)\n\tsmCfg.viperEnv.Set(\"token_url\", clientCfg.TokenEndpoint)\n\tsmCfg.viperEnv.Set(\"auth_url\", clientCfg.AuthorizationEndpoint)\n\n\treturn smCfg.viperEnv.WriteConfig()\n}", "func (n *NetworkBuilder) Save(writer io.Writer) error {\n\terr := json.NewEncoder(writer).Encode(n.Network)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn err\n}", "func (c *Config) save() {\n\tconst file = \"access.json\"\n\n\tc.logger.Printf(\"Save file %s\\n\", file)\n\n\tcfg := conf{\n\t\tIP: c.GetString(\"ip\"),\n\t\tPort: c.GetString(\"port\"),\n\t\tToken: c.GetString(\"token\"),\n\t\tWait: c.GetBool(\"wait\"),\n\t}\n\n\tb, err := json.Marshal(cfg)\n\tif err != nil {\n\t\tc.logger.Error(err)\n\t}\n\n\tif err = ioutil.WriteFile(file, b, 0644); err != nil {\n\t\tc.logger.Error(err)\n\t}\n}", "func (n *hostOnlyNetwork) SaveIPv4(vbox VBoxManager) error {\n\tif n.IPv4.IP != nil && n.IPv4.Mask != nil {\n\t\tif err := vbox.vbm(\"hostonlyif\", \"ipconfig\", n.Name, \"--ip\", n.IPv4.IP.String(), \"--netmask\", net.IP(n.IPv4.Mask).String()); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (a *Network) Save(path string) {\n\tioutil.WriteFile(path, []byte(a.outputFormat()), 0666)\n}", "func hostsetconfigcmd(totalstorage, maxfilesize, mintolerance, maxduration, price, burn string) {\n\terr := callAPI(fmt.Sprintf(\"/host/setconfig?totalstorage=%s&maxfilesize=%s&mintolerance=%s\"+\n\t\t\"&maxduration=%s&price=%s&burn=%s\", totalstorage, maxfilesize, mintolerance, maxduration, price, burn))\n\tif err != nil {\n\t\tfmt.Println(\"Could not update host settings:\", err)\n\t\treturn\n\t}\n\tfmt.Println(\"Host settings updated. You have been announced as a host on the network.\")\n}", "func (d donut) SaveConfig() error {\n\tnodeDiskMap := make(map[string][]string)\n\tfor hostname, node := range d.nodes {\n\t\tdisks, err := node.ListDisks()\n\t\tif err != nil {\n\t\t\treturn iodine.New(err, nil)\n\t\t}\n\t\tfor order, disk := range disks {\n\t\t\tdonutConfigPath := filepath.Join(d.name, donutConfig)\n\t\t\tdonutConfigWriter, err := disk.CreateFile(donutConfigPath)\n\t\t\tdefer donutConfigWriter.Close()\n\t\t\tif err != nil {\n\t\t\t\treturn iodine.New(err, nil)\n\t\t\t}\n\t\t\tnodeDiskMap[hostname][order] = disk.GetPath()\n\t\t\tjenc := json.NewEncoder(donutConfigWriter)\n\t\t\tif err := jenc.Encode(nodeDiskMap); err != nil {\n\t\t\t\treturn iodine.New(err, nil)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func Save() {\n\tc := Config{viper.GetString(\"email\"), viper.GetString(\"platform\"), viper.GetDuration(\"timeout\")}\n\tdata, err := json.MarshalIndent(c, \"\", \" \")\n\tif err != nil {\n\t\treturn\n\t}\n\n\t_ = ioutil.WriteFile(viper.GetString(\"file_config\"), data, 0600)\n}", "func (viperConfig *Configurator) Save(sbConfig *config.SBConfiguration) error {\n\tviperConfig.viper.Set(\"url\", sbConfig.URL)\n\tviperConfig.viper.Set(\"authorization\", sbConfig.Authorization)\n\tviperConfig.viper.Set(\"room\", sbConfig.Room)\n\n\tif err := viperConfig.viper.WriteConfig(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (cfg *Config) Save(fpath string) error {\n\t// create a copy\n\tconfig2 := cfg\n\t// clear, setup setting\n\tconfig2.Password = \"\"\n\tconfig2.Iterations = ConfigHashIterations\n\n\t// save to file\n\tbyteDat2, err := json.MarshalIndent(config2, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(fpath, byteDat2, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (s *store) RegisterHost(host Host) error {\n\tconfig := host.Config()\n\tdir, err := host.Dir()\n\tif err != nil {\n\t\treturn err\n\t}\n\tbytes, err := json.Marshal(config)\n\tif err != nil {\n\t\treturn err\n\t}\n\tjsonPath := filepath.Join(dir, HostConfigJSONFile)\n\treturn ioutil.WriteFile(jsonPath, bytes, 0644)\n}", "func saveRemoteConfig(conf *types.NetConf,\n\targs *skel.CmdArgs,\n\tipResult *current.Result,\n\tconnData connectionData) error {\n\n\tvar err error\n\n\t// Populate the configData with input data, which will be written to container.\n\tconfigData, err := populateUserspaceConfigData(conf, args, ipResult)\n\tif err != nil {\n\t\tlogging.Errorf(\"ERROR: saveRemoteConfig: Failure to retrieve pod - %v\", err)\n\t\treturn err\n\t}\n\n\t// Wrtie configData to the annotations, which will be read by container.\n\tconnData.pod, err = annotations.WritePodAnnotation(connData.kubeClient, connData.pod, configData)\n\tif err != nil {\n\t\tlogging.Errorf(\"ERROR: saveRemoteConfig: Failure to write annotations - %v\", err)\n\t\treturn err\n\t}\n\n\treturn err\n}", "func Save() error {\n\treturn defaultConfig.Save()\n}", "func (smCfg *smConfiguration) Save(settings *Settings) error {\n\tsmCfg.viperEnv.Set(\"url\", settings.URL)\n\tsmCfg.viperEnv.Set(\"user\", settings.User)\n\tsmCfg.viperEnv.Set(\"ssl_disabled\", settings.SSLDisabled)\n\tsmCfg.viperEnv.Set(\"token_basic_auth\", settings.TokenBasicAuth)\n\n\tsmCfg.viperEnv.Set(\"access_token\", settings.AccessToken)\n\tsmCfg.viperEnv.Set(\"refresh_token\", settings.RefreshToken)\n\tsmCfg.viperEnv.Set(\"expiry\", settings.ExpiresIn.Format(time.RFC1123Z))\n\n\tsmCfg.viperEnv.Set(\"client_id\", settings.ClientID)\n\tsmCfg.viperEnv.Set(\"client_secret\", settings.ClientSecret)\n\tsmCfg.viperEnv.Set(\"issuer_url\", settings.IssuerURL)\n\tsmCfg.viperEnv.Set(\"token_url\", settings.TokenEndpoint)\n\tsmCfg.viperEnv.Set(\"auth_url\", settings.AuthorizationEndpoint)\n\tsmCfg.viperEnv.Set(\"auth_flow\", string(settings.AuthFlow))\n\n\tcfgFile := smCfg.viperEnv.ConfigFileUsed()\n\tif err := smCfg.viperEnv.WriteConfig(); err != nil {\n\t\treturn fmt.Errorf(\"could not save config file %s: %s\", cfgFile, err)\n\t}\n\tconst ownerAccessOnly = 0600\n\tif err := os.Chmod(cfgFile, ownerAccessOnly); err != nil {\n\t\treturn fmt.Errorf(\"could not set access rights of config file %s: %s\", cfgFile, err)\n\t}\n\treturn nil\n}", "func GhostConfigSave(config *GhostConfig) error {\n\tbucket, err := db.GetBucket(ghostBucketName)\n\tif err != nil {\n\t\treturn err\n\t}\n\trawConfig, err := json.Marshal(config)\n\tif err != nil {\n\t\treturn err\n\t}\n\tstorageLog.Infof(\"Saved config for '%s'\", config.Name)\n\treturn bucket.Set(fmt.Sprintf(\"%s.%s\", ghostConfigNamespace, config.Name), rawConfig)\n}", "func (f *HostFilter) SaveAuto(path string) {\n\tf.mu.Lock()\n\tdefer f.mu.Unlock()\n\n\tfile, err := os.Create(path)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer file.Close()\n\n\tw := bufio.NewWriter(file)\n\n\thosts := make(map[string]HostEntry)\n\tfor host, entry := range f.hosts {\n\t\tif entry.Type.IsAuto() {\n\t\t\thosts[host] = entry\n\t\t}\n\t}\n\n\tyaml.NewEncoder(w).Encode(hosts)\n\n\tw.Flush()\n\tfile.Close()\n}", "func (a *AppConf) Save(c LocalConf) (err error) {\n\terr = a.cc.Save(&c)\n\treturn\n}", "func (o Iperf3SpecServerConfigurationOutput) HostNetwork() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v Iperf3SpecServerConfiguration) *bool { return v.HostNetwork }).(pulumi.BoolPtrOutput)\n}", "func SaveToEgressCache(egressConfigFromPilot map[string][]*config.EgressRule) {\n\t{\n\t\tvar egressconfig []control.EgressConfig\n\t\tfor _, v := range egressConfigFromPilot {\n\t\t\tfor _, v1 := range v {\n\t\t\t\tvar Ports []*control.EgressPort\n\t\t\t\tfor _, v2 := range v1.Ports {\n\t\t\t\t\tp := control.EgressPort{\n\t\t\t\t\t\tPort: (*v2).Port,\n\t\t\t\t\t\tProtocol: (*v2).Protocol,\n\t\t\t\t\t}\n\t\t\t\t\tPorts = append(Ports, &p)\n\t\t\t\t}\n\t\t\t\tc := control.EgressConfig{\n\t\t\t\t\tHosts: v1.Hosts,\n\t\t\t\t\tPorts: Ports,\n\t\t\t\t}\n\n\t\t\t\tegressconfig = append(egressconfig, c)\n\t\t\t}\n\t\t}\n\t\tEgressConfigCache.Set(\"\", egressconfig, 0)\n\t}\n}", "func (c Config) Save() error {\n\td, err := yaml.Marshal(&c)\n\tif err != nil {\n\t\treturn err\n\t}\n\tos.Remove(\"handshake.yaml\")\n\treturn ioutil.WriteFile(\"handshake.yaml\", d, 0644)\n}", "func (c *Config) Save() error {\r\n\tlog.Debug().Msg(\"[Config] Saving configuration...\")\r\n\tc.Validate()\r\n\r\n\treturn c.SaveFile(EnvManagerConfigFile)\r\n}", "func (o Iperf3SpecClientConfigurationOutput) HostNetwork() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v Iperf3SpecClientConfiguration) *bool { return v.HostNetwork }).(pulumi.BoolPtrOutput)\n}", "func (b *BlockCreator) save() error {\n\treturn persist.SaveJSON(settingsMetadata, b.persist, filepath.Join(b.persistDir, settingsFile))\n}", "func (k *Kluster) Save() error {\n\t// we load the nil defaults so that future versions\n\t// don't have to deal with the backwards compatibility with omitted values\n\tif k.Config != nil {\n\t\tk.Config.LoadNilDefault()\n\t}\n\n\tdir := k.Dir()\n\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"base directory %s does not exists\", dir)\n\t\t// Or?:\n\t\t// os.MkdirAll(dir, 0755)\n\t}\n\n\tformat := k.format()\n\tvar data []byte\n\tvar err error\n\n\t// Get platform configurations\n\n\t// Update configuration\n\t// pConfig := make(map[string]interface{}, len(k.Platforms))\n\tname := k.Platform()\n\tif p, ok := k.provisioner[name]; ok {\n\t\tplatform := p\n\t\tk.Platforms[name] = platform.Config()\n\t\t// c := platform.Config()\n\t\t// // TODO: Workaround to not save the vSphere credentials, cannot have metadata to '-' because the Configurator takes the credentials from there.\n\t\t// if name == \"vsphere\" {\n\t\t// \tcVsphere := c.(*vsphere.Config)\n\t\t// \tcVsphere.VspherePassword = \"\"\n\t\t// \tcVsphere.VsphereUsername = \"\"\n\t\t// \tcVsphere.VsphereServer = \"\"\n\t\t// \tk.Platforms[name] = cVsphere\n\t\t// } else {\n\t\t// \tk.Platforms[name] = c\n\t\t// }\n\n\t\terr := k.LoadState()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tk.UpdateState(name)\n\n\t\tk.ui.Log.Debugf(\"update state for %s: %v\", name, k.State[name])\n\t}\n\n\t// k.Platforms = pConfig\n\n\t// Do not use String() because:\n\t// (1) returns string and []byte is needed, and\n\t// (2) pretty print (pp=true) is needed with JSON format\n\tswitch format {\n\tcase \"yaml\":\n\t\tdata, err = k.YAML()\n\tcase \"json\":\n\t\tdata, err = k.JSON(true)\n\tcase \"toml\":\n\t\tdata, err = k.TOML()\n\tdefault:\n\t\terr = fmt.Errorf(\"can't stringify the Kluster, unknown format %q\", format)\n\t}\n\n\tlock, err := lockFile(k.path)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer lock.Unlock()\n\n\tk.ui.Log.Debugf(\"updating cluster configuration file %s\", k.path)\n\treturn ioutil.WriteFile(k.path, data, 0644)\n}", "func saveHostMetadata(metadata Metadata) error {\n\tdataBytes, err := json.Marshal(metadata)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[Telemetry] marshal data failed with err %+v\", err)\n\t}\n\n\tif err = ioutil.WriteFile(metadataFile, dataBytes, 0644); err != nil {\n\t\ttelemetryLogger.Printf(\"[Telemetry] Writing metadata to file failed: %v\", err)\n\t}\n\n\treturn err\n}", "func (in *Database) SaveNetwork(netw *types.Network) error {\n\tif netw.ID == \"\" {\n\t\tid := stringid.GenerateRandomID()\n\t\tnetw.ID = id\n\t\tnetw.ShortID = stringid.TruncateID(id)\n\t\tnetw.Created = time.Now()\n\t}\n\treturn in.save(\"network\", netw)\n}", "func saveHostMetadata(metadata Metadata) error {\n\tdataBytes, err := json.Marshal(metadata)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"[Telemetry] marshal data failed with err %+v\", err)\n\t}\n\n\tif err = ioutil.WriteFile(metadataFile, dataBytes, 0644); err != nil {\n\t\tlog.Logf(\"[Telemetry] Writing metadata to file failed: %v\", err)\n\t}\n\n\treturn err\n}", "func (c Configuration) Save() {\n\tbuf := new(bytes.Buffer)\n\tif err := toml.NewEncoder(buf).Encode(c); err != nil {\n\t\tlog.Fatalln(\"Failed to encode config\", err)\n\t}\n\tf, err := os.Create(configFile)\n\tif err != nil {\n\t\tlog.Fatalln(\"Failed to create file\", err)\n\t\treturn\n\t}\n\n\tw := bufio.NewWriter(f)\n\tbuf.WriteTo(w)\n\tw.Flush()\n}", "func saveDummyConfig() {\n\tif file, err := os.Create(\"dummyconfig.json\"); err == nil {\n\t\tencoder := json.NewEncoder(file)\n\t\tvar config Config\n\t\tconfig.Cluster = make([]ClusterConfig, 0)\n\t\tvar def, cluster ClusterConfig\n\t\tdef.Name = \"default\"\n\t\tdef.Address = \"http://localhost:8888/\"\n\t\tdef.ProtocolVersion = \"v1\"\n\t\tcluster.Name = \"cluster1\"\n\t\tcluster.Address = \"http://localhost:8282/\"\n\t\tcluster.ProtocolVersion = \"v1\"\n\t\tconfig.Cluster = append(config.Cluster, def)\n\t\tconfig.Cluster = append(config.Cluster, cluster)\n\t\tencoder.Encode(config)\n\t\tfile.Close()\n\t}\n}", "func (c *Config) Save(name, key, value string) (err error) {\n\treturn c.SaveGlobal(name, key, value)\n}", "func (defaultStorage) Save() error {\n\tpanic(noConfigStorage)\n}", "func save() {\n\tnaksuIniPath := getIniFilePath()\n\n\terr := cfg.SaveTo(naksuIniPath)\n\tif err != nil {\n\t\tlog.Error(\"%s save failed: %v\", naksuIniPath, err)\n\t}\n}", "func setEdisonInterfaces(i config.Interfaces, ip string) error {\n\n\tif dialogs.YesNoDialog(\"Would you like to assign static IP wlan address for your board?\") {\n\n\t\t// assign static ip\n\t\tfmt.Println(\"[+] ********NOTE: ADJUST THESE VALUES ACCORDING TO YOUR LOCAL NETWORK CONFIGURATION********\")\n\n\t\tfor {\n\t\t\tfmt.Printf(\"[+] Current values are:\\n \\t[+] Address:%s\\n\\t[+] Gateway:%s\\n\\t[+] Netmask:%s\\n\\t[+] DNS:%s\\n\",\n\t\t\t\ti.Address, i.Gateway, i.Netmask, i.DNS)\n\n\t\t\tif dialogs.YesNoDialog(\"Change values?\") {\n\t\t\t\tconfig.AskInterfaceParams(&i)\n\t\t\t}\n\n\t\t\tfmt.Println(\"[+] NOTE: You might need to enter your Edison board password\")\n\n\t\t\targs1 := []string{\n\t\t\t\t\"root@\" + ip,\n\t\t\t\t\"-t\",\n\t\t\t\tfmt.Sprintf(\"sed -i.bak -e '53 s/.*/ifconfig $IFNAME %s netmask %s/g' /etc/wpa_supplicant/wpa_cli-actions.sh\",\n\t\t\t\t\ti.Address, i.Netmask),\n\t\t\t}\n\n\t\t\targs2 := []string{\n\t\t\t\t\"root@\" + ip,\n\t\t\t\t\"-t\",\n\t\t\t\tfmt.Sprintf(\"sed -i -e '54i route add default gw %s' /etc/wpa_supplicant/wpa_cli-actions.sh\",\n\t\t\t\t\ti.Gateway),\n\t\t\t}\n\n\t\t\targs3 := []string{\n\t\t\t\t\"root@\" + ip,\n\t\t\t\t\"-t\",\n\t\t\t\tfmt.Sprintf(\"echo nameserver %s > /etc/resolv.conf\", i.DNS),\n\t\t\t}\n\t\t\tifaceDown := []string{\n\t\t\t\t\"root@\" + ip,\n\t\t\t\t\"-t\",\n\t\t\t\tfmt.Sprint(\"ifconfig wlan0 down\"),\n\t\t\t}\n\n\t\t\tifaceUp := []string{\n\t\t\t\t\"-o\",\n\t\t\t\t\"StrictHostKeyChecking=no\",\n\t\t\t\t\"root@\" + ip,\n\t\t\t\t\"-t\",\n\t\t\t\tfmt.Sprint(\"ifconfig wlan0 up\"),\n\t\t\t}\n\t\t\tfmt.Println(\"[+] Updating network configuration\")\n\t\t\tif err := help.ExecStandardStd(\"ssh\", args1...); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfmt.Println(\"[+] Updating gateway settings\")\n\t\t\tif err := help.ExecStandardStd(\"ssh\", args2...); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfmt.Println(\"[+] Adding custom nameserver\")\n\t\t\tif err := help.ExecStandardStd(\"ssh\", args3...); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfmt.Println(\"[+] Reloading interface settings\")\n\t\t\tif err := help.ExecStandardStd(\"ssh\", ifaceDown...); err != nil {\n\t\t\t\tfmt.Println(\"[-] Error shutting down wlan0 interface: \", err.Error())\n\t\t\t\treturn err\n\t\t\t}\n\t\t\ttime.Sleep(1 * time.Second)\n\t\t\tif err := help.ExecStandardStd(\"ssh\", ifaceUp...); err != nil {\n\t\t\t\tfmt.Println(\"[-] Error starting wlan0 interface: \", err.Error())\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\treturn nil\n\n}", "func Save(pushURL string, tart config.Tart) {\n\tif config.All().Tarts == nil {\n\t\tconfig.All().Tarts = map[string]config.Tart{}\n\t}\n\tconfig.All().Tarts[pushURL] = tart\n\tconfig.Flush()\n}", "func (w *Hostworker) SaveToFile() bool {\n\tos.Mkdir(\"/etc/lantern/hosts\", 0777)\n\tfile, err := os.Create(\"/etc/lantern/hosts/host_\" + w.Host + \".txt\")\n\tif err != nil {\n\t\tw.crawler.cfg.LogError(err)\n\t\treturn false\n\t}\n\tdefer func() {\n\t\tfile.Close()\n\t}()\n\n\twriter := bufio.NewWriter(file)\n\tw.SaveToWriter(writer)\n\twriter.Flush()\n\treturn true\n}", "func (m *Machine) Save(n string) error {\n\tf, err := os.Create(n)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to create vm config file\")\n\t}\n\tdefer f.Close()\n\n\tif err := json.NewEncoder(f).Encode(m); err != nil {\n\t\treturn errors.Wrap(err, \"failed to serialize machine object\")\n\t}\n\n\treturn nil\n}", "func (c *Config) Save(filename string) (err error) {\n\tlog.Println(\"[DEBUG] Save\", filename)\n\n\tbody, err := json.MarshalIndent(c, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = c.writeFile(filename, body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (s *ServiceState) save() {\n\tlog.Lvl3(\"Saving service\")\n\tb, err := network.Marshal(s.Storage)\n\tif err != nil {\n\t\tlog.Error(\"Couldn't marshal service:\", err)\n\t} else {\n\t\terr = ioutil.WriteFile(s.path+\"/prifi.bin\", b, 0660)\n\t\tif err != nil {\n\t\t\tlog.Error(\"Couldn't save file:\", err)\n\t\t}\n\t}\n}", "func (device *BlockDevice) Save() config.DeviceState {\n\tds := device.GenericDevice.Save()\n\tds.Type = string(device.DeviceType())\n\n\tds.BlockDrive = device.BlockDrive\n\n\treturn ds\n}", "func (c *Config) Save() (err error) {\n\tc.init()\n\tlog.Infof(\"save config to %v\", c.Filename)\n\tdir := filepath.Dir(c.Filename)\n\tif _, e := os.Stat(dir); os.IsNotExist(e) {\n\t\terr = os.MkdirAll(dir, os.ModePerm)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"save config to %v fail with %v\", c.Filename, err)\n\t\t\treturn\n\t\t}\n\t}\n\terr = marshal(c.Filename, c)\n\tif err == nil {\n\t\tlog.Infof(\"save config to %v success\", c.Filename)\n\t} else {\n\t\tlog.Errorf(\"save config to %v fail with %v\", c.Filename, err)\n\t}\n\treturn\n}", "func (o QperfSpecServerConfigurationOutput) HostNetwork() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v QperfSpecServerConfiguration) *bool { return v.HostNetwork }).(pulumi.BoolPtrOutput)\n}", "func Persist() error {\n\tJSON, err := json.MarshalIndent(instance, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = os.WriteFile(filepath.Join(GetConfigFolder(), configName), JSON, 0755)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (o QperfSpecClientConfigurationOutput) HostNetwork() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v QperfSpecClientConfiguration) *bool { return v.HostNetwork }).(pulumi.BoolPtrOutput)\n}", "func (cfg *Configuration) Save() error {\n\tcfg.locker.Lock()\n\tdefer cfg.locker.Unlock()\n\tif cfg.FilePath == \"\" {\n\t\treturn errors.New(\"Configuration.FilePath was not set\")\n\t}\n\treturn gonfig.Write(cfg, true)\n}", "func (c *Passward) Save() error {\n\n\tif !util.DirectoryExists(c.Path) {\n\t\tif err := os.MkdirAll(c.Path, 0700); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfile, err := os.Create(c.configPath())\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\tif err := toml.NewEncoder(file).Encode(c); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (self *JsonConfig) Save() (err error) {\n\tb, err := json.Marshal(self.Configurable.All())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := ioutil.WriteFile(self.Path, b, 0600); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func Write(tx Transport, host string, data, info []string, options ...TransportOption) error {\n\t// the Kind should configure the transport parameters before\n\n\terr := tx.Connect(host, options...)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: %s\", host, err)\n\t}\n\n\tdefer tx.Close()\n\n\tfor i1, d1 := range data {\n\t\terr := tx.Write(&d1, &info[i1])\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not write config %s: %s\", d1, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (o Iperf3SpecServerConfigurationPtrOutput) HostNetwork() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *Iperf3SpecServerConfiguration) *bool {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.HostNetwork\n\t}).(pulumi.BoolPtrOutput)\n}", "func (m *AospDeviceOwnerDeviceConfiguration) SetWifiBlockEditConfigurations(value *bool)() {\n err := m.GetBackingStore().Set(\"wifiBlockEditConfigurations\", value)\n if err != nil {\n panic(err)\n }\n}", "func (cfg OpenVpnCfg) Save() error {\n\tcfgPath := getCfgPath(cfg.Name)\n\tkeyPath := getKeyPath(cfg.Name)\n\n\tcfgFile, err := os.OpenFile(cfgPath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tcfgFile.Close()\n\t\tif err != nil {\n\t\t\tos.Remove(cfgPath)\n\t\t}\n\t}()\n\tkeyFile, err := os.OpenFile(keyPath, os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tkeyFile.Close()\n\t\tif err != nil {\n\t\t\tos.Remove(keyPath)\n\t\t}\n\t}()\n\targ := templateArg{\n\t\tOpenVpnCfg: cfg,\n\t\tLibexecdir: staticconfig.Libexecdir,\n\t}\n\tif err = openVpnCfgTpl.Execute(cfgFile, arg); err != nil {\n\t\treturn err\n\t}\n\t_, err = keyFile.Write([]byte(cfg.Key))\n\treturn err\n}", "func (c *Configuration) Save(filename string) error {\n\tb, err := json.MarshalIndent(c, \"\", \"\\t\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tf, err := os.Create(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\t_, err = f.Write([]byte(configHeader))\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = f.Write(b)\n\treturn err\n}", "func (c *Direct) SetHostinfo(hi *tailcfg.Hostinfo) bool {\n\tif hi == nil {\n\t\tpanic(\"nil Hostinfo\")\n\t}\n\tc.mu.Lock()\n\tdefer c.mu.Unlock()\n\n\tif hi.Equal(c.hostinfo) {\n\t\treturn false\n\t}\n\tc.hostinfo = hi.Clone()\n\tj, _ := json.Marshal(c.hostinfo)\n\tc.logf(\"HostInfo: %s\", j)\n\treturn true\n}", "func SaveConfig(path string) error {\n\t// TODO: Implement\n\n\treturn nil\n}", "func (ws *WalletStore) Save() {\n\tvar buffer bytes.Buffer\n\tgob.Register(elliptic.P256())\n\tencoder := gob.NewEncoder(&buffer)\n\terr := encoder.Encode(ws.Wallets)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfile := ws.Config.GetWalletStoreFile(ws.NodeID)\n\terr = ioutil.WriteFile(file, buffer.Bytes(), 0644)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func (b *BlockCreator) saveSync() error {\n\treturn persist.SaveJSON(settingsMetadata, b.persist, filepath.Join(b.persistDir, settingsFile))\n}", "func SaveConfig(conf ClientConfig) error {\n configFilePath, err := getConfigFilePath()\n if err != nil {\n return err\n }\n\n d, err := yaml.Marshal(&conf)\n if err != nil {\n return err\n }\n writeErr := os.WriteFile(configFilePath, d, 0666)\n if writeErr != nil {\n return writeErr\n }\n\n return nil\n}", "func (o Iperf3SpecClientConfigurationPtrOutput) HostNetwork() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *Iperf3SpecClientConfiguration) *bool {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.HostNetwork\n\t}).(pulumi.BoolPtrOutput)\n}", "func (c Config) Save(writer io.Writer) error {\n\tlog.Printf(\"Saving config\")\n\tcontent, err := json.MarshalIndent(c, \"\", \" \")\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\t_, err = writer.Write(content)\n\treturn errors.WithStack(err)\n}", "func (api *configurationsnapshotAPI) Save(obj *cluster.ConfigurationSnapshotRequest) (*cluster.ConfigurationSnapshot, error) {\n\tif api.ct.resolver != nil {\n\t\tapicl, err := api.ct.apiClient()\n\t\tif err != nil {\n\t\t\tapi.ct.logger.Errorf(\"Error creating API server clent. Err: %v\", err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn apicl.ClusterV1().ConfigurationSnapshot().Save(context.Background(), obj)\n\t}\n\tif api.localSaveHandler != nil {\n\t\treturn api.localSaveHandler(obj)\n\t}\n\treturn nil, fmt.Errorf(\"Action not implemented for local operation\")\n}", "func (c *Config) Save(path string) error {\n\tconfigBytes, err := yaml.Marshal(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(path, configBytes, 0600)\n}", "func (c *Config) Save(filename string) {\n\tconfigFile, err := os.Create(filename)\n\tif err != nil {\n\t\tlogrus.Error(\"creating config file\", err.Error())\n\t}\n\n\tlogrus.Info(\"Save config: \", c)\n\tvar out bytes.Buffer\n\tb, err := json.MarshalIndent(c, \"\", \"\\t\")\n\tif err != nil {\n\t\tlogrus.Error(\"error marshal json\", err)\n\t}\n\tjson.Indent(&out, b, \"\", \"\\t\")\n\tout.WriteTo(configFile)\n}", "func (c *FwGeneral) Set(e Config) error {\n var err error\n _, fn := c.versioning()\n c.con.LogAction(\"(set) general settings\")\n\n path := c.xpath()\n path = path[:len(path) - 1]\n\n _, err = c.con.Set(path, fn(e), nil, nil)\n return err\n}", "func (o *PersistConfig) Persist(storage endpoint.ConfigStorage) error {\n\treturn nil\n}", "func (c *Config) Save(filename string) error {\n\tvar b bytes.Buffer\n\tenc := json.NewEncoder(&b)\n\tenc.SetIndent(\"\", \"\\t\")\n\tif err := enc.Encode(c); err != nil {\n\t\treturn fmt.Errorf(\"error encoding configuration: %w\", err)\n\t}\n\tif err := os.WriteFile(filename, b.Bytes(), 0600); err != nil {\n\t\treturn fmt.Errorf(\"error writing %q: %w\", filename, err)\n\t}\n\treturn nil\n}", "func (hdb *HostDB) insertBlockchainHost(host modules.HostDBEntry) {\n\t// Remove garbage hosts and local hosts (but allow local hosts in testing).\n\tif err := host.NetAddress.IsValid(); err != nil {\n\t\thdb.staticLog.Debugf(\"WARN: host '%v' has an invalid NetAddress: %v\", host.NetAddress, err)\n\t\treturn\n\t}\n\t// Ignore all local hosts announced through the blockchain.\n\tif build.Release == \"standard\" && host.NetAddress.IsLocal() {\n\t\treturn\n\t}\n\n\t// Make sure the host gets into the host tree so it does not get dropped if\n\t// shutdown occurs before a scan can be performed.\n\toldEntry, exists := hdb.staticHostTree.Select(host.PublicKey)\n\tif exists {\n\t\t// Replace the netaddress with the most recently announced netaddress.\n\t\t// Also replace the FirstSeen value with the current block height if\n\t\t// the first seen value has been set to zero (no hosts actually have a\n\t\t// first seen height of zero, but due to rescans hosts can end up with\n\t\t// a zero-value FirstSeen field.\n\t\toldEntry.NetAddress = host.NetAddress\n\t\tif oldEntry.FirstSeen == 0 {\n\t\t\toldEntry.FirstSeen = hdb.blockHeight\n\t\t}\n\t\t// Resolve the host's used subnets and update the timestamp if they\n\t\t// changed. We only update the timestamp if resolving the ipNets was\n\t\t// successful.\n\t\tipNets, err := hdb.staticLookupIPNets(oldEntry.NetAddress)\n\t\tif err == nil && !equalIPNets(ipNets, oldEntry.IPNets) {\n\t\t\toldEntry.IPNets = ipNets\n\t\t\toldEntry.LastIPNetChange = time.Now()\n\t\t}\n\t\t// Modify hosttree\n\t\terr = hdb.modify(oldEntry)\n\t\tif err != nil {\n\t\t\thdb.staticLog.Println(\"ERROR: unable to modify host entry of host tree after a blockchain scan:\", err)\n\t\t}\n\t} else {\n\t\thost.FirstSeen = hdb.blockHeight\n\t\t// Insert into hosttree\n\t\terr := hdb.insert(host)\n\t\tif err != nil {\n\t\t\thdb.staticLog.Println(\"ERROR: unable to insert host entry into host tree after a blockchain scan:\", err)\n\t\t}\n\t}\n\n\t// Add the host to the scan queue.\n\thdb.queueScan(host)\n}", "func (c *Config) Save() error {\n\tdir, err := getConfigDir()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfile, err := json.MarshalIndent(c, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tp := path.Join(dir, configFile)\n\treturn ioutil.WriteFile(p, file, 0644)\n}", "func (cfg *Config) SaveConfig() error {\n\t// Find home directory.\n\thome, err := homedir.Dir()\n\tif err != nil {\n\t\tlog.Printf(\"Error when fetching home directory\\n%v\", err)\n\t\treturn err\n\t}\n\n\tviper.SetConfigName(\".alfred\")\n\tviper.AddConfigPath(home)\n\tviper.Set(\"output_format\", cfg.OutputFormat)\n\tviper.Set(\"slack_token\", cfg.SlackToken)\n\tviper.Set(\"todoist_token\", cfg.TodoistToken)\n\treturn viper.WriteConfig()\n}", "func saveStore(s dhtStore) {\n\tif s.path == \"\" {\n\t\treturn\n\t}\n\ttmp, err := ioutil.TempFile(s.path, \"marconi\")\n\tif err != nil {\n\t\tlog.Println(\"saveStore tempfile:\", err)\n\t\treturn\n\t}\n\terr = json.NewEncoder(tmp).Encode(s)\n\t// The file has to be closed already otherwise it can't be renamed on\n\t// Windows.\n\ttmp.Close()\n\tif err != nil {\n\t\tlog.Println(\"saveStore json encoding:\", err)\n\t\treturn\n\t}\n\n\t// Write worked, so replace the existing file. That's atomic in Linux, but\n\t// not on Windows.\n\tp := fmt.Sprintf(\"%v-%v\", s.path+\"/dht\", s.Port)\n\tif err := os.Rename(tmp.Name(), p); err != nil {\n\t\t// if os.IsExist(err) {\n\t\t// Not working for Windows:\n\t\t// http://code.google.com/p/go/issues/detail?id=3828\n\n\t\t// It's not possible to atomically rename files on Windows, so I\n\t\t// have to delete it and try again. If the program crashes between\n\t\t// the unlink and the rename operation, it loses the configuration,\n\t\t// unfortunately.\n\t\tif err := os.Remove(p); err != nil {\n\t\t\tlog.Println(\"saveStore failed to remove the existing config:\", err)\n\t\t\treturn\n\t\t}\n\t\tif err := os.Rename(tmp.Name(), p); err != nil {\n\t\t\tlog.Println(\"saveStore failed to rename file after deleting the original config:\", err)\n\t\t\treturn\n\t\t}\n\t\t// } else {\n\t\t// \tlog.Println(\"saveStore failed when replacing existing config:\", err)\n\t\t// }\n\t} else {\n\t\t// log.Println(\"Saved DHT routing table to the filesystem.\")\n\t}\n}", "func (cr *ConnectionRegistry) Save(c *Connection) error {\n\tif cr.list[c.ID] != nil {\n\t\treturn errors.New(\"id already in use\")\n\t}\n\tcr.list[c.ID] = c\n\tlog.Println(\"registering:\", c.ID, \" # of connections: \", len(cr.list))\n\treturn nil\n}", "func (c *Config) Save(cfgPath string) error {\n\tcfgFile, err := yaml.Marshal(c)\n\tif err == nil {\n\t\terr = ioutil.WriteFile(cfgPath, cfgFile, 0600)\n\t}\n\treturn err\n}", "func (epc *EquipmentPortCreate) Save(ctx context.Context) (*EquipmentPort, error) {\n\tif epc.create_time == nil {\n\t\tv := equipmentport.DefaultCreateTime()\n\t\tepc.create_time = &v\n\t}\n\tif epc.update_time == nil {\n\t\tv := equipmentport.DefaultUpdateTime()\n\t\tepc.update_time = &v\n\t}\n\tif len(epc.definition) > 1 {\n\t\treturn nil, errors.New(\"ent: multiple assignments on a unique edge \\\"definition\\\"\")\n\t}\n\tif epc.definition == nil {\n\t\treturn nil, errors.New(\"ent: missing required edge \\\"definition\\\"\")\n\t}\n\tif len(epc.parent) > 1 {\n\t\treturn nil, errors.New(\"ent: multiple assignments on a unique edge \\\"parent\\\"\")\n\t}\n\tif len(epc.link) > 1 {\n\t\treturn nil, errors.New(\"ent: multiple assignments on a unique edge \\\"link\\\"\")\n\t}\n\treturn epc.sqlSave(ctx)\n}", "func (connection *Connection) Save(path string) error {\n\tjson, err := json.Marshal(connection)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(path, json, 0644)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (cfg *Config) Save(filename string) error {\n\tfilename_ := C.CString(filename)\n\tdefer freeString(filename_)\n\tok := bool(C.al_save_config_file(filename_, (*C.ALLEGRO_CONFIG)(cfg)))\n\tif !ok {\n\t\treturn fmt.Errorf(\"failed to save config file to '%s'\", filename)\n\t}\n\treturn nil\n}", "func (wAPI WalletAPI) Save() error {\n\t_, _, err := wAPI.sendRequest(\n\t\t\"PUT\",\n\t\twAPI.Host+\":\"+wAPI.Port+\"/save\",\n\t\t\"\",\n\t)\n\n\treturn err\n}", "func (c *Config) Save(file *os.File) error {\n\tif file == nil && c.file != nil {\n\t\tfile = c.file\n\t}\n\n\tif err := file.Truncate(0); err != nil {\n\t\treturn err\n\t}\n\tif _, err := file.Seek(0, 0); err != nil {\n\t\treturn err\n\t}\n\tif err := yaml.NewEncoder(file).Encode(c); err != nil {\n\t\treturn err\n\t}\n\n\treturn file.Sync()\n}", "func (config *Config) Save(file string) error {\n\tbts, err := json.Marshal(*config)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar out bytes.Buffer\n\tjson.Indent(&out, bts, \"\", \"\\t\")\n\n\treturn ioutil.WriteFile(file, out.Bytes(), 0600)\n}", "func (c *Config) Save() error {\n\tpath := filepath.Dir(c.filePath)\n\terr := os.MkdirAll(path, directoryPermissions)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\traw, err := json.MarshalIndent(c, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = ioutil.WriteFile(c.filePath, raw, filePermissions)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func Save(c Config) error {\n\tb, err := toml.Marshal(c)\n\tif err != nil {\n\t\treturn errors.Wrap(errReadConfigFile, err)\n\t}\n\tfile := dfltFile\n\tif c.File != \"\" {\n\t\tfile = c.File\n\t}\n\tif err := os.WriteFile(file, b, 0644); err != nil {\n\t\treturn errors.Wrap(errWritingConfigFile, err)\n\t}\n\n\treturn nil\n}", "func (s *slaveContext) SaveConfiguration() error {\n // master pubkey\n if mpubkey, err := s.GetMasterPublicKey(); err != nil {\n return errors.WithStack(err)\n } else {\n s.config.SaveMasterPublicKey(mpubkey)\n }\n // save slave node name to hostname\n if err := s.config.SaveHostname(); err != nil {\n return errors.WithStack(err)\n }\n // update hosts\n if err := s.config.UpdateHostsFile(); err != nil {\n return errors.WithStack(err)\n }\n/*\n // slave network interface\n TODO : (2017-05-15) we'll re-evaluate this option later. For not, this is none critical\n if err = s.config.SaveFixedNetworkInterface(); err != nil {\n return errors.WithStack(err)\n }\n*/\n // update linux hostname with systemd\n if err := exec.Command(\"/usr/bin/hostnamectl\", \"set-hostname\", s.config.SlaveSection.SlaveNodeName).Run(); err != nil {\n return errors.WithStack(err)\n }\n // save slave config into yaml\n return s.config.SaveSlaveConfig()\n}", "func SaveRemote(remote *cfg.Remote) error {\n\tremotes, err := GetRemotes()\n\tif err != nil {\n\t\treturn err\n\t}\n\tremotes.SetRemote(*remote)\n\treturn Write(InertiaRemotesPath(), remotes)\n}", "func (o *NSPortInfo) Save() *bambou.Error {\n\n\treturn bambou.CurrentSession().SaveEntity(o)\n}", "func saveClusterIP(current, overlay *unstructured.Unstructured) error {\n\t// Save the value of spec.clusterIP set by the cluster\n\tif clusterIP, found, err := unstructured.NestedString(current.Object, \"spec\",\n\t\t\"clusterIP\"); err != nil {\n\t\treturn err\n\t} else if found {\n\t\tif err := unstructured.SetNestedField(overlay.Object, clusterIP, \"spec\",\n\t\t\t\"clusterIP\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (c *MetaConfig) Save() error {\n\tdata, err := json.Marshal(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ioutil.WriteFile(MetaConfigPath, data, 0644)\n}", "func SaveHvacConfig(db Database, cfg dhvac.HvacSetup) error {\n\tcriteria := make(map[string]interface{})\n\tcriteria[\"Mac\"] = cfg.Mac\n\treturn SaveOnUpdateObject(db, cfg, pconst.DbConfig, pconst.TbHvacs, criteria)\n}", "func (c *ConfigManager) Save() error {\n\tlogger.V(1).Info(\"saving ConfigMap\")\n\n\tvar tmpOptions pomeriumconfig.Options\n\n\ttmpOptions, err := c.GetCurrentConfig()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not render current config: %w\", err)\n\t}\n\n\t// Make sure we can load the target configmap\n\tconfigObj := &corev1.ConfigMap{}\n\tif err := c.client.Get(context.Background(), types.NamespacedName{Name: c.configMap, Namespace: c.namespace}, configObj); err != nil {\n\t\terr = fmt.Errorf(\"output configmap not found: %w\", err)\n\t\treturn err\n\t}\n\n\tconfigBytes, err := yaml.Marshal(tmpOptions)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not serialize config: %w\", err)\n\t}\n\n\tconfigObj.Data = map[string]string{configKey: string(configBytes)}\n\n\t// TODO set deadline?\n\t// TODO use context from save?\n\terr = c.client.Update(context.Background(), configObj)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to update configmap: %w\", err)\n\t}\n\n\tlogger.Info(\"successfully saved ConfigMap\")\n\tc.pendingSave = false\n\treturn nil\n}", "func (service *HTTPRestService) setNetworkInfo(networkName string, networkInfo *networkInfo) {\n\tservice.lock.Lock()\n\tdefer service.lock.Unlock()\n\tservice.state.Networks[networkName] = networkInfo\n\n\treturn\n}", "func (s *Server) SaveConfig() (err error) {\n\t// TODO: Switch to an atomic implementation like renameio. Consider what\n\t// happens if Config.Save() panics: we'll have truncated the file\n\t// on disk and the hub will be unable to recover. For now, since we normally\n\t// only save the configuration during initialize and any configuration\n\t// errors could be fixed by reinitializing, the risk seems small.\n\tfile, err := utils.System.Create(upgrade.GetConfigFile())\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif cerr := file.Close(); cerr != nil {\n\t\t\tcerr = xerrors.Errorf(\"closing hub configuration: %w\", cerr)\n\t\t\terr = multierror.Append(err, cerr).ErrorOrNil()\n\t\t}\n\t}()\n\n\terr = s.Config.Save(file)\n\tif err != nil {\n\t\treturn xerrors.Errorf(\"saving hub configuration: %w\", err)\n\t}\n\n\treturn nil\n}", "func (c *ConfigurationFile) Save() error {\n\tcontent, err := json.Marshal(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ioutil.WriteFile(c.location.get(), content, 0600)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func SetHost(v string) {\n\traw.Host = v\n}", "func (set *HostSet) AddHost(c renter.Contract) {\n\tlh := new(lockedHost)\n\t// lazy connection function\n\tvar lastSeen time.Time\n\tlh.reconnect = func() error {\n\t\tif lh.s != nil && !lh.s.IsClosed() {\n\t\t\t// if it hasn't been long since the last reconnect, assume the\n\t\t\t// connection is still open\n\t\t\tif time.Since(lastSeen) < 2*time.Minute {\n\t\t\t\tlastSeen = time.Now()\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\t// otherwise, the connection *might* still be open; test by sending\n\t\t\t// a \"ping\" RPC\n\t\t\t//\n\t\t\t// NOTE: this is somewhat inefficient; it means we might incur an\n\t\t\t// extra roundtrip when we don't need to. Better would be for the\n\t\t\t// caller to handle the reconnection logic after calling whatever\n\t\t\t// RPC it wants to call; that way, we only do extra work if the host\n\t\t\t// has actually disconnected. But that feels too burdensome.\n\t\t\tif _, err := lh.s.Settings(); err == nil {\n\t\t\t\tlastSeen = time.Now()\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\t// connection timed out, or some other error occurred; close our\n\t\t\t// end (just in case) and fallthrough to the reconnection logic\n\t\t\tlh.s.Close()\n\t\t}\n\t\thostIP, err := set.hkr.ResolveHostKey(c.HostKey)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not resolve host key: %w\", err)\n\t\t}\n\t\t// create and lock the session manually so that we can use our custom\n\t\t// lock timeout\n\t\tlh.s, err = proto.NewUnlockedSession(hostIP, c.HostKey, set.currentHeight)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := lh.s.Lock(c.ID, c.RenterKey, set.lockTimeout); err != nil {\n\t\t\tlh.s.Close()\n\t\t\treturn err\n\t\t} else if _, err := lh.s.Settings(); err != nil {\n\t\t\tlh.s.Close()\n\t\t\treturn err\n\t\t}\n\t\tset.onConnect(lh.s)\n\t\tlastSeen = time.Now()\n\t\treturn nil\n\t}\n\tset.sessions[c.HostKey] = lh\n}", "func Host(host string) func(*Config) error {\n\treturn func(c *Config) error {\n\t\tc.Host = host\n\t\treturn nil\n\t}\n}", "func (f *freeClientPool) saveToDb() {\n\tnow := f.clock.Now()\n\tstorage := freeClientPoolStorage{\n\t\tLogOffset: uint64(f.logOffset(now)),\n\t\tList: make([]*freeClientPoolEntry, len(f.addressMap)),\n\t}\n\ti := 0\n\tfor _, e := range f.addressMap {\n\t\tif e.connected {\n\t\t\tf.calcLogUsage(e, now)\n\t\t}\n\t\tstorage.List[i] = e\n\t\ti++\n\t}\n\tenc, err := rlp.EncodeToBytes(storage)\n\tif err != nil {\n\t\tlog.Error(\"Failed to encode client list\", \"err\", err)\n\t} else {\n\t\tf.db.Put([]byte(\"freeClientPool\"), enc)\n\t}\n}", "func (c *ChainPing) SavePing() bool {\n\tc.mux.Lock()\n\tdefer c.mux.Unlock()\n\tlog.Printf(\"writing Ping chain of length %d\", len(c.Chain))\n\tbytes := parser.ParseToJSONPing(c.Chain)\n\te := saveToHDD(c.Path, bytes)\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\treturn true\n}", "func (ps *PlatformService) SaveConfig(newCfg *model.Config, sendConfigChangeClusterMessage bool) (*model.Config, *model.Config, *model.AppError) {\n\toldCfg, newCfg, err := ps.configStore.Set(newCfg)\n\tif errors.Is(err, config.ErrReadOnlyConfiguration) {\n\t\treturn nil, nil, model.NewAppError(\"saveConfig\", \"ent.cluster.save_config.error\", nil, \"\", http.StatusForbidden).Wrap(err)\n\t} else if err != nil {\n\t\treturn nil, nil, model.NewAppError(\"saveConfig\", \"app.save_config.app_error\", nil, \"\", http.StatusInternalServerError).Wrap(err)\n\t}\n\n\tif ps.startMetrics && *ps.Config().MetricsSettings.Enable {\n\t\tps.RestartMetrics()\n\t} else {\n\t\tps.ShutdownMetrics()\n\t}\n\n\tif ps.clusterIFace != nil {\n\t\terr := ps.clusterIFace.ConfigChanged(ps.configStore.RemoveEnvironmentOverrides(oldCfg),\n\t\t\tps.configStore.RemoveEnvironmentOverrides(newCfg), sendConfigChangeClusterMessage)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t}\n\n\treturn oldCfg, newCfg, nil\n}", "func (vm *vmQemu) fillNetworkDevice(name string, m deviceConfig.Device) (deviceConfig.Device, error) {\n\tnewDevice := m.Clone()\n\tupdateKey := func(key string, value string) error {\n\t\ttx, err := vm.state.Cluster.Begin()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\terr = db.ContainerConfigInsert(tx, vm.id, map[string]string{key: value})\n\t\tif err != nil {\n\t\t\ttx.Rollback()\n\t\t\treturn err\n\t\t}\n\n\t\terr = db.TxCommit(tx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn nil\n\t}\n\n\t// Fill in the MAC address\n\tif !shared.StringInSlice(m[\"nictype\"], []string{\"physical\", \"ipvlan\", \"sriov\"}) && m[\"hwaddr\"] == \"\" {\n\t\tconfigKey := fmt.Sprintf(\"volatile.%s.hwaddr\", name)\n\t\tvolatileHwaddr := vm.localConfig[configKey]\n\t\tif volatileHwaddr == \"\" {\n\t\t\t// Generate a new MAC address\n\t\t\tvolatileHwaddr, err := deviceNextInterfaceHWAddr()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\t// Update the database\n\t\t\terr = query.Retry(func() error {\n\t\t\t\terr := updateKey(configKey, volatileHwaddr)\n\t\t\t\tif err != nil {\n\t\t\t\t\t// Check if something else filled it in behind our back\n\t\t\t\t\tvalue, err1 := vm.state.Cluster.ContainerConfigGet(vm.id, configKey)\n\t\t\t\t\tif err1 != nil || value == \"\" {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\tvm.localConfig[configKey] = value\n\t\t\t\t\tvm.expandedConfig[configKey] = value\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\tvm.localConfig[configKey] = volatileHwaddr\n\t\t\t\tvm.expandedConfig[configKey] = volatileHwaddr\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t\tnewDevice[\"hwaddr\"] = volatileHwaddr\n\t}\n\n\treturn newDevice, nil\n}", "func SaveCloudsConfig(data []byte) error {\n\thomedir, err := homedir.Dir()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcfgPath := filepath.Join(homedir, DevSpaceCloudConfigPath)\n\terr = os.MkdirAll(filepath.Dir(cfgPath), 0755)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ioutil.WriteFile(cfgPath, data, 0600)\n}", "func (s *Syncthing) SaveConfig(dev *model.Dev) error {\n\tmarshalled, err := yaml.Marshal(s)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsyncthingInfoFile := getInfoFile(dev.Namespace, dev.Name)\n\tif err := os.WriteFile(syncthingInfoFile, marshalled, 0600); err != nil {\n\t\treturn fmt.Errorf(\"failed to write syncthing info file: %w\", err)\n\t}\n\n\treturn nil\n}", "func Save(app *cli.Context) error {\n\tif err := cmds.InitLogging(); err != nil {\n\t\treturn err\n\t}\n\treturn save(app, &cmds.ServerConfig)\n}" ]
[ "0.57114166", "0.5705443", "0.55867183", "0.55641735", "0.5545801", "0.5540158", "0.55362916", "0.5509479", "0.5506129", "0.5503006", "0.5464419", "0.5461447", "0.5456357", "0.54298675", "0.5423216", "0.5402514", "0.5287204", "0.5237437", "0.5235597", "0.52300316", "0.522529", "0.52008885", "0.51970625", "0.5190391", "0.51560247", "0.51429504", "0.51167125", "0.510831", "0.5104182", "0.50794", "0.506037", "0.5048555", "0.503774", "0.50306135", "0.50082564", "0.50077134", "0.50053287", "0.5000288", "0.49943665", "0.49883357", "0.49755937", "0.49525356", "0.49459347", "0.49404284", "0.49333116", "0.4918979", "0.49127597", "0.49054378", "0.4899529", "0.48971173", "0.48877898", "0.4886714", "0.4886425", "0.48856658", "0.48692548", "0.48646855", "0.48599562", "0.4852498", "0.4848781", "0.482615", "0.48205963", "0.48134598", "0.48101157", "0.4806775", "0.48050693", "0.480375", "0.4800942", "0.48000008", "0.47892252", "0.47799033", "0.4775741", "0.47687295", "0.47679403", "0.47660974", "0.4751455", "0.47444054", "0.4742978", "0.4726026", "0.4723586", "0.47196552", "0.47161388", "0.47155112", "0.4704033", "0.4694132", "0.46923465", "0.46918106", "0.468867", "0.46873245", "0.4682927", "0.46772492", "0.4675236", "0.46662387", "0.46656907", "0.46656182", "0.4654023", "0.46494576", "0.46424916", "0.46402735", "0.46376544", "0.46361384" ]
0.76610893
0
SaveIPv4 changes the ipv4 configuration of the hostonly network.
func (n *hostOnlyNetwork) SaveIPv4(vbox VBoxManager) error { if n.IPv4.IP != nil && n.IPv4.Mask != nil { if err := vbox.vbm("hostonlyif", "ipconfig", n.Name, "--ip", n.IPv4.IP.String(), "--netmask", net.IP(n.IPv4.Mask).String()); err != nil { return err } } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *FSEIDFields) SetIPv4Flag() {\n\tf.Flags |= 0x02\n}", "func (internet Internet) IPv4(v reflect.Value) (interface{}, error) {\n\treturn internet.ipv4(), nil\n}", "func IPv4(a, b, c, d uint8) IP {\n\treturn IP{\n\t\tlo: 0xffff00000000 | uint64(a)<<24 | uint64(b)<<16 | uint64(c)<<8 | uint64(d),\n\t\tz: z4,\n\t}\n}", "func (n *hostOnlyNetwork) Save(vbox VBoxManager) error {\n\tif err := n.SaveIPv4(vbox); err != nil {\n\t\treturn err\n\t}\n\n\tif n.DHCP {\n\t\tvbox.vbm(\"hostonlyif\", \"ipconfig\", n.Name, \"--dhcp\") // not implemented as of VirtualBox 4.3\n\t}\n\n\treturn nil\n}", "func IPv4(opts ...options.OptionFunc) string {\n\treturn singleFakeData(IPV4Tag, func() interface{} {\n\t\topt := options.BuildOptions(opts)\n\t\ti := Internet{fakerOption: *opt}\n\t\treturn i.ipv4()\n\t}, opts...).(string)\n}", "func (i Internet) Ipv4() string {\n\tips := make([]string, 0, 4)\n\n\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(1, 255)))\n\tfor j := 0; j < 3; j++ {\n\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(0, 255)))\n\t}\n\n\treturn strings.Join(ips, \".\")\n}", "func IPv4() (string, error) {\n\tconn, err := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tif err != nil {\n\t\treturn \"\", errors.New(\"Failed to determine your IP\")\n\t}\n\tlocalAddr := conn.LocalAddr().(*net.UDPAddr)\n\tmyIP := localAddr.IP.String()\n\tconn.Close()\n\treturn myIP, nil\n}", "func IPv4(name string) (string, error) {\n\ti, err := net.InterfaceByName(name)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\taddrs, err := i.Addrs()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor _, a := range addrs {\n\t\tif ipn, ok := a.(*net.IPNet); ok {\n\t\t\tif ipn.IP.To4() != nil {\n\t\t\t\treturn ipn.IP.String(), nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn \"\", fmt.Errorf(\"no IPv4 found for interface: %q\", name)\n}", "func Ipv4(v string) predicate.Agent {\n\treturn predicate.Agent(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldIpv4), v))\n\t})\n}", "func NewIPv4(value string) (IPv4, error) {\n\tvar IP = IPv4{value: value}\n\n\tif !IP.validate() {\n\t\treturn IPv4{}, ErrInvalidIPv4\n\t}\n\n\treturn IP, nil\n}", "func IpV4Address() string {\n\tblocks := []string{}\n\tfor i := 0; i < 4; i++ {\n\t\tnumber := seedAndReturnRandom(255)\n\t\tblocks = append(blocks, strconv.Itoa(number))\n\t}\n\n\treturn strings.Join(blocks, \".\")\n}", "func ipv4only(addr IPAddr) bool {\n\treturn supportsIPv4 && addr.IP.To4() != nil\n}", "func stringIPv4(n uint32) string {\n\tip := make(net.IP, 4)\n\tbinary.BigEndian.PutUint32(ip, n)\n\treturn ip.String()\n}", "func (internet *Internet) IPv4Address() string {\n\tvar parts []string\n\tfor i := 0; i < 4; i++ {\n\t\tparts = append(parts, fmt.Sprintf(\"%d\", internet.faker.random.Intn(253)+2))\n\t}\n\treturn strings.Join(parts, \".\")\n}", "func (p *PeerToPeer) handlePacketIPv4(contents []byte, proto int) {\n\tLog(Trace, \"Handling IPv4 Packet\")\n\tf := new(ethernet.Frame)\n\tif err := f.UnmarshalBinary(contents); err != nil {\n\t\tLog(Error, \"Failed to unmarshal IPv4 packet\")\n\t}\n\n\tif f.EtherType != ethernet.EtherTypeIPv4 {\n\t\treturn\n\t}\n\tmsg := CreateNencP2PMessage(p.Crypter, contents, uint16(proto), 1, 1, 1)\n\tp.SendTo(f.Destination, msg)\n}", "func (i *InstanceServiceHandler) CreateIPv4(ctx context.Context, instanceID string, reboot *bool) (*IPv4, error) {\n\turi := fmt.Sprintf(\"%s/%s/ipv4\", instancePath, instanceID)\n\n\tbody := RequestBody{\"reboot\": reboot}\n\n\treq, err := i.client.NewRequest(ctx, http.MethodPost, uri, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tip := new(ipv4Base)\n\tif err = i.client.DoWithContext(ctx, req, ip); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ip.IPv4, nil\n}", "func uint32ToIPv4(intIP uint32) net.IP {\n\tip := make(net.IP, 4)\n\tbinary.BigEndian.PutUint32(ip, intIP)\n\treturn ip\n}", "func IPv4(str string) bool {\n\tip := net.ParseIP(str)\n\treturn ip != nil && strings.Contains(str, \".\")\n}", "func (ipSet *IPSet) IsIPv4() bool {\n\treturn govalidator.IsIPv4(ipSet.IPv4)\n}", "func TestGetSetIP4(t *testing.T) {\n\tip := IP{192, 168, 0, 3}\n\tvar r Record\n\tr.Set(&ip)\n\n\tvar ip2 IP\n\trequire.NoError(t, r.Load(&ip2))\n\tassert.Equal(t, ip, ip2)\n}", "func isIPv4(fl FieldLevel) bool {\n\tip := net.ParseIP(fl.Field().String())\n\n\treturn ip != nil && ip.To4() != nil\n}", "func (impl *IPv4Pool) AllocateIPv4Address(id string, key string) (string, base.ModelInterface, *base.ErrorResponse) {\n\tvar (\n\t\tc = impl.TemplateImpl.GetConnection()\n\t\trecord = new(entity.IPv4Pool)\n\t)\n\n\ttx := c.Begin()\n\tif err := tx.Error; err != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"id\": id,\n\t\t\t\"key\": key,\n\t\t\t\"error\": err,\n\t\t}).Warn(\"Allocate IPv4 failed, start transaction failed.\")\n\t\treturn \"\", nil, base.NewErrorResponseTransactionError()\n\t}\n\texist, err := impl.GetInternal(tx, id, record)\n\tif !exist {\n\t\ttx.Rollback()\n\t\treturn \"\", nil, base.NewErrorResponseNotExist()\n\t}\n\tif err != nil {\n\t\ttx.Rollback()\n\t\treturn \"\", nil, base.NewErrorResponseTransactionError()\n\t}\n\n\tfoundKey := false\n\t// If try to find the address with the same key.\n\tif key != \"\" {\n\t\tfor i := range record.Ranges {\n\t\t\tfor j := range record.Ranges[i].Addresses {\n\t\t\t\tif record.Ranges[i].Addresses[j].Key == key {\n\t\t\t\t\tfoundKey = true\n\t\t\t\t\tif record.Ranges[i].Addresses[j].Allocated == true {\n\t\t\t\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\t\t\t\"id\": record.ID,\n\t\t\t\t\t\t\t\"key\": key,\n\t\t\t\t\t\t\t\"address\": record.Ranges[i].Addresses[j].Address,\n\t\t\t\t\t\t}).Info(\"Allocate IPv4, found address with key but already allocated.\")\n\t\t\t\t\t} else {\n\t\t\t\t\t\trecord.Ranges[i].Addresses[j].Allocated = true\n\t\t\t\t\t\tif record.Ranges[i].Free > 0 {\n\t\t\t\t\t\t\trecord.Ranges[i].Free--\n\t\t\t\t\t\t}\n\t\t\t\t\t\trecord.Ranges[i].Allocatable--\n\t\t\t\t\t\tif commited, err := impl.SaveAndCommit(tx, record); commited && err == nil {\n\t\t\t\t\t\t\treturn record.Ranges[i].Addresses[j].Address, record.ToModel(), nil\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn \"\", nil, base.NewErrorResponseTransactionError()\n\t\t\t\t\t}\n\t\t\t\t\t// found the address with the key, but in already allocated.\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif foundKey {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// if the key == nil, we don't have to find the address with the key.\n\tfor i := range record.Ranges {\n\t\tif record.Ranges[i].Free > 0 {\n\t\t\tfor j := range record.Ranges[i].Addresses {\n\t\t\t\tif record.Ranges[i].Addresses[j].Key != \"\" || record.Ranges[i].Addresses[j].Allocated == true {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\trecord.Ranges[i].Addresses[j].Allocated = true\n\t\t\t\trecord.Ranges[i].Addresses[j].Key = key\n\t\t\t\tif record.Ranges[i].Free > 0 {\n\t\t\t\t\trecord.Ranges[i].Free--\n\t\t\t\t}\n\t\t\t\trecord.Ranges[i].Allocatable--\n\t\t\t\tcommited, err := impl.SaveAndCommit(tx, record)\n\t\t\t\tif commited && err == nil {\n\t\t\t\t\treturn record.Ranges[i].Addresses[j].Address, record.ToModel(), nil\n\t\t\t\t}\n\t\t\t\treturn \"\", nil, base.NewErrorResponseTransactionError()\n\t\t\t}\n\t\t}\n\t}\n\t// So no free address, try to use the allocatable address.\n\tfor i := range record.Ranges {\n\t\tif record.Ranges[i].Allocatable > 0 {\n\t\t\tfor j := range record.Ranges[i].Addresses {\n\t\t\t\tif record.Ranges[i].Addresses[j].Allocated == true {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\trecord.Ranges[i].Addresses[j].Allocated = true\n\t\t\t\trecord.Ranges[i].Addresses[j].Key = key\n\t\t\t\tif record.Ranges[i].Free > 0 {\n\t\t\t\t\trecord.Ranges[i].Free--\n\t\t\t\t}\n\t\t\t\trecord.Ranges[i].Allocatable--\n\t\t\t\tcommited, err := impl.SaveAndCommit(tx, record)\n\t\t\t\tif commited && err == nil {\n\t\t\t\t\treturn record.Ranges[i].Addresses[j].Address, record.ToModel(), nil\n\t\t\t\t}\n\t\t\t\treturn \"\", nil, base.NewErrorResponseTransactionError()\n\t\t\t}\n\t\t}\n\t}\n\t// So no address can allocate.\n\ttx.Rollback()\n\tlog.WithFields(log.Fields{\n\t\t\"id\": id,\n\t\t\"key\": key,\n\t}).Info(\"Allocate IPv4 failed, no allocatable address.\")\n\n\treturn \"\", nil, errorResp.NewErrorResponseIPv4PoolEmpty()\n}", "func (impl *IPv4Pool) FreeIPv4Address(id string, address string) (base.ModelInterface, *base.ErrorResponse) {\n\tvar (\n\t\tc = impl.TemplateImpl.GetConnection()\n\t\trecord = new(entity.IPv4Pool)\n\t)\n\n\ttx := c.Begin()\n\tif err := tx.Error; err != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"id\": id,\n\t\t\t\"address\": address,\n\t\t\t\"error\": err,\n\t\t}).Warn(\"Free IPv4 failed, start transaction failed.\")\n\t\treturn nil, base.NewErrorResponseTransactionError()\n\t}\n\texist, err := impl.GetInternal(tx, id, record)\n\tif !exist {\n\t\ttx.Rollback()\n\t\treturn nil, base.NewErrorResponseNotExist()\n\t}\n\tif err != nil {\n\t\ttx.Rollback()\n\t\treturn nil, base.NewErrorResponseTransactionError()\n\t}\n\tfor i := range record.Ranges {\n\t\tif !base.IPStringBetween(record.Ranges[i].Start, record.Ranges[i].End, address) {\n\t\t\tcontinue\n\t\t}\n\t\tfor j := range record.Ranges[i].Addresses {\n\t\t\tif record.Ranges[i].Addresses[j].Address == address {\n\t\t\t\tif !record.Ranges[i].Addresses[j].Allocated {\n\t\t\t\t\ttx.Rollback()\n\t\t\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\t\t\"id\": id,\n\t\t\t\t\t\t\"address\": address,\n\t\t\t\t\t}).Warn(\"Free IPv4 failed, the address didn't allocate, transaction rollback.\")\n\t\t\t\t\treturn nil, errorResp.NewErrorResponseIPv4NotAllocatedError()\n\t\t\t\t}\n\t\t\t\trecord.Ranges[i].Addresses[j].Allocated = false\n\t\t\t\trecord.Ranges[i].Allocatable++\n\t\t\t\tif record.Ranges[i].Addresses[j].Key == \"\" {\n\t\t\t\t\trecord.Ranges[i].Free++\n\t\t\t\t}\n\t\t\t\tcommited, err := impl.SaveAndCommit(tx, record)\n\t\t\t\tif commited && err == nil {\n\t\t\t\t\treturn record.ToModel(), nil\n\t\t\t\t}\n\t\t\t\treturn nil, base.NewErrorResponseTransactionError()\n\t\t\t}\n\t\t}\n\t\tbreak\n\t}\n\t// Can't find the address in pool.\n\ttx.Rollback()\n\treturn nil, errorResp.NewErrorResponseIPv4AddressNotExistError()\n}", "func uint32ToIPV4(addr uint32) net.IP {\n\tip := make([]byte, net.IPv4len)\n\tbinary.BigEndian.PutUint32(ip, addr)\n\treturn ip\n}", "func (o *StorageHitachiPortAllOf) SetIpv4Address(v string) {\n\to.Ipv4Address = &v\n}", "func PublicIpv4EqualFold(v string) predicate.Agent {\n\treturn predicate.Agent(func(s *sql.Selector) {\n\t\ts.Where(sql.EqualFold(s.C(FieldPublicIpv4), v))\n\t})\n}", "func PublicIpv4(v string) predicate.Agent {\n\treturn predicate.Agent(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldPublicIpv4), v))\n\t})\n}", "func (f *FakeInstance) DeleteIPv4(_ context.Context, _, _ string) error {\n\tpanic(\"implement me\")\n}", "func (ip IP) As4() [4]byte {\n\tif ip.z == z4 || ip.Is4in6() {\n\t\tvar ret [4]byte\n\t\tbinary.BigEndian.PutUint32(ret[:], uint32(ip.lo))\n\t\treturn ret\n\t}\n\tif ip.z == z0 {\n\t\tpanic(\"As4 called on IP zero value\")\n\t}\n\tpanic(\"As4 called on IPv6 address\")\n}", "func (instanceKey *InstanceKey) IsIPv4() bool {\n\treturn ipv4Regexp.MatchString(instanceKey.Hostname)\n}", "func (u *IPv4) DeepCopy() *IPv4 {\n\tif u == nil {\n\t\treturn nil\n\t}\n\tout := new(IPv4)\n\tu.DeepCopyInto(out)\n\treturn out\n}", "func IPv4ClassfulNetwork(address net.IP) *net.IPNet {\n\tif address.To4() != nil {\n\t\tvar newIP net.IP\n\t\tvar newMask net.IPMask\n\t\tswitch {\n\t\tcase uint8(address[0]) < 128:\n\t\t\tnewIP = net.IPv4(uint8(address[0]), 0, 0, 0)\n\t\t\tnewMask = net.IPv4Mask(255, 0, 0, 0)\n\t\tcase uint8(address[0]) < 192:\n\t\t\tnewIP = net.IPv4(uint8(address[0]), uint8(address[1]), 0, 0)\n\t\t\tnewMask = net.IPv4Mask(255, 255, 0, 0)\n\t\tcase uint8(address[0]) < 224:\n\t\t\tnewIP = net.IPv4(uint8(address[0]), uint8(address[1]), uint8(address[2]), 0)\n\t\t\tnewMask = net.IPv4Mask(255, 255, 255, 0)\n\t\tdefault:\n\t\t\treturn nil\n\t\t}\n\t\treturn &net.IPNet{IP: newIP, Mask: newMask}\n\t}\n\treturn nil\n}", "func IsIPv4(value string) bool {\n\tip := net.ParseIP(value)\n\tif ip == nil {\n\t\treturn false\n\t}\n\treturn ip.To4() != nil\n}", "func IsValidIP4(ipAddress string) bool {\n\tipAddress = strings.Trim(ipAddress, \" \")\n\tif !regexp.MustCompile(`^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`).\n\t\tMatchString(ipAddress) {\n\t\treturn false\n\t}\n\treturn true\n}", "func ResolveIPv4(host string) (net.IP, error) {\n\tif node := DefaultHosts.Search(host); node != nil {\n\t\tif ip := node.Data.(net.IP).To4(); ip != nil {\n\t\t\treturn ip, nil\n\t\t}\n\t}\n\n\tip := net.ParseIP(host)\n\tif ip != nil {\n\t\tif !strings.Contains(host, \":\") {\n\t\t\treturn ip, nil\n\t\t}\n\t\treturn nil, errIPVersion\n\t}\n\n\tif DefaultResolver != nil {\n\t\treturn DefaultResolver.ResolveIPv4(host)\n\t}\n\n\tipAddrs, err := net.LookupIP(host)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, ip := range ipAddrs {\n\t\tif ip4 := ip.To4(); ip4 != nil {\n\t\t\treturn ip4, nil\n\t\t}\n\t}\n\n\treturn nil, errIPNotFound\n}", "func (c *Client) PublicIPv4() (net.IP, error) {\n\tresp, err := c.get(\"/public-ipv4\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn net.ParseIP(resp), nil\n}", "func (f *FloatingIP) IPv4Net() (*net.IPNet, error) {\n\tvar ip net.IP\n\tif ip = net.ParseIP(f.IP); ip == nil {\n\t\treturn nil, fmt.Errorf(\"error parsing IPv4Address '%s'\", f.IP)\n\t}\n\treturn &net.IPNet{\n\t\tIP: ip,\n\t\tMask: net.CIDRMask(32, 32),\n\t}, nil\n}", "func IsIPv4(dots string) bool {\n\tip := net.ParseIP(dots)\n\tif ip == nil {\n\t\treturn false\n\t}\n\treturn ip.To4() != nil\n}", "func WithIPv4Mask(mask net.IPMask) Option {\n\treturn func(o *Options) {\n\t\to.IPv4Mask = mask\n\t}\n}", "func ToVppIP4Address(addr net.IP) ip_types.IP4Address {\n\tip := [4]uint8{}\n\tcopy(ip[:], addr.To4())\n\treturn ip\n}", "func (n *NetworkAssociation) IPv4Net() (*net.IPNet, error) {\n\tvar ip net.IP\n\tif ip = net.ParseIP(n.ServerIP); ip == nil {\n\t\treturn nil, fmt.Errorf(\"error parsing ServerIP '%s'\", ip)\n\t}\n\treturn &net.IPNet{\n\t\tIP: ip,\n\t\tMask: net.CIDRMask(24, 32),\n\t}, nil\n}", "func GetIPv4Addr(ifAdds map[string]string, ipAdds *map[string]string) {\n\ttempAdds := *ipAdds\n\tfor k, v := range ifAdds {\n\t\tif runtime.GOOS == \"linux\" {\n\t\t\tif (strings.HasPrefix(k, \"local\") || strings.HasPrefix(k, \"en\") || strings.HasPrefix(k, \"eth\")) && strings.HasSuffix(k, \"_0\") {\n\t\t\t\ttempAdds[\"eth_ipv4\"] = v\n\t\t\t} else if strings.HasPrefix(k, \"wireless\") && strings.HasSuffix(k, \"_0\") {\n\t\t\t\ttempAdds[\"wireless_ipv4\"] = v\n\t\t\t}\n\t\t} else {\n\t\t\tif (strings.HasPrefix(k, \"local\") || strings.HasPrefix(k, \"en\") || strings.HasPrefix(k, \"eth\")) && strings.HasSuffix(k, \"_1\") {\n\t\t\t\ttempAdds[\"eth_ipv4\"] = v\n\t\t\t} else if strings.HasPrefix(k, \"wireless\") && strings.HasSuffix(k, \"_1\") {\n\t\t\t\ttempAdds[\"wireless_ipv4\"] = v\n\t\t\t}\n\t\t}\n\n\t}\n}", "func (i Internet) LocalIpv4() string {\n\tips := make([]string, 0, 4)\n\tips = append(ips, i.Faker.RandomStringElement([]string{\"10\", \"172\", \"192\"}))\n\n\tif ips[0] == \"10\" {\n\t\tfor j := 0; j < 3; j++ {\n\t\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(0, 255)))\n\t\t}\n\t}\n\n\tif ips[0] == \"172\" {\n\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(16, 31)))\n\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(0, 255)))\n\t\t}\n\t}\n\n\tif ips[0] == \"192\" {\n\t\tips = append(ips, \"168\")\n\n\t\tfor j := 0; j < 2; j++ {\n\t\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(0, 255)))\n\t\t}\n\t}\n\n\treturn strings.Join(ips, \".\")\n}", "func (s *Server) IPv4Net() (*net.IPNet, error) {\n\tvar ip net.IP\n\tif ip = net.ParseIP(s.IPv4Address); ip == nil {\n\t\treturn nil, fmt.Errorf(\"error parsing IPv4Address '%s'\", s.IPv4Address)\n\t}\n\treturn &net.IPNet{\n\t\tIP: ip,\n\t\tMask: net.CIDRMask(32, 32),\n\t}, nil\n}", "func (o *LocalDatabaseProvider) SetIpPoolV4(v string) {\n\to.IpPoolV4 = &v\n}", "func (f *FakeInstance) CreateIPv4(_ context.Context, _ string, _ *bool) (*govultr.IPv4, *http.Response, error) {\n\tpanic(\"implement me\")\n}", "func Ipv4EqualFold(v string) predicate.Agent {\n\treturn predicate.Agent(func(s *sql.Selector) {\n\t\ts.Where(sql.EqualFold(s.C(FieldIpv4), v))\n\t})\n}", "func (in *Ipv4) DeepCopy() *Ipv4 {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Ipv4)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "func (o NodeBalancerOutput) Ipv4() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *NodeBalancer) pulumi.StringOutput { return v.Ipv4 }).(pulumi.StringOutput)\n}", "func PublicIpv4EQ(v string) predicate.Agent {\n\treturn predicate.Agent(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldPublicIpv4), v))\n\t})\n}", "func DetectHostIPv4() (string, error) {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\", errors.WithStack(err)\n\t}\n\tfor _, a := range addrs {\n\t\tif ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn ipnet.IP.String(), nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"cannot detect host IPv4 address\")\n}", "func (o *IppoolPoolMember) SetIpV4Address(v string) {\n\to.IpV4Address = &v\n}", "func isIP4AddrResolvable(fl FieldLevel) bool {\n\tif !isIPv4(fl) {\n\t\treturn false\n\t}\n\n\t_, err := net.ResolveIPAddr(\"ip4\", fl.Field().String())\n\n\treturn err == nil\n}", "func (c *Client) GetIPv4() string {\n\treturn c.ip.String()\n}", "func (o *StorageHitachiPortAllOf) GetIpv4Address() string {\n\tif o == nil || o.Ipv4Address == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Ipv4Address\n}", "func (f *FSEIDFields) HasIPv4() bool {\n\treturn has2ndBit(f.Flags)\n}", "func indexAsIPv4(i uint32, baseSlashEight int) string {\n\tip := make(net.IP, 4)\n\tbinary.BigEndian.PutUint32(ip, uint32(i)+uint32(baseSlashEight*16777216))\n\treturn ip.String()\n}", "func (af AddressFamily) IsIPv4() bool {\n\treturn af == AddressFamilyIPv4\n}", "func (i *InstanceServiceHandler) DefaultReverseIPv4(ctx context.Context, instanceID, ip string) error {\n\turi := fmt.Sprintf(\"%s/%s/ipv4/reverse/default\", instancePath, instanceID)\n\treqBody := RequestBody{\"ip\": ip}\n\n\treq, err := i.client.NewRequest(ctx, http.MethodPost, uri, reqBody)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn i.client.DoWithContext(ctx, req, nil)\n}", "func IsIPv4(ip *net.IP) bool {\n\treturn ip.To4() != nil\n}", "func (a *Lisp_address) lisp_is_ipv4() bool {\n\treturn((len(a.address) == 4))\n}", "func ParsePublicIPV4(ip string) (*l5dNetPb.IPAddress, error) {\n\tnetIP := net.ParseIP(ip)\n\tif netIP != nil {\n\t\toBigInt := IPToInt(netIP.To4())\n\t\tnetIPAddress := &l5dNetPb.IPAddress{\n\t\t\tIp: &l5dNetPb.IPAddress_Ipv4{\n\t\t\t\tIpv4: uint32(oBigInt.Uint64()),\n\t\t\t},\n\t\t}\n\t\treturn netIPAddress, nil\n\t}\n\treturn nil, fmt.Errorf(\"Invalid IP address: %s\", ip)\n}", "func IntToIPv4(intip *big.Int) net.IP {\n\tipByte := make([]byte, net.IPv4len)\n\tuint32IP := intip.Uint64()\n\tbinary.BigEndian.PutUint32(ipByte, uint32(uint32IP))\n\treturn net.IP(ipByte)\n}", "func NewIPv4Address(address uint32, length uint) IPv4Address {\n\treturn IPv4Address{\n\t\tAddress: address,\n\t\tLength: length,\n\t}\n}", "func EnsureIPv4(ipOrHost string) (string, error) {\n\tip := net.ParseIP(ipOrHost)\n\tif ip != nil {\n\t\tif ip.To4() == nil {\n\t\t\treturn \"\", fmt.Errorf(\"%s is IPv6 address\", ipOrHost)\n\t\t}\n\t\treturn ipOrHost, nil\n\t}\n\taddrs, err := net.LookupHost(ipOrHost)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tips := make([]string, 0)\n\tfor _, addr := range addrs {\n\t\tif ip := net.ParseIP(addr); ip != nil {\n\t\t\tif ip.To4() == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tips = append(ips, addr)\n\t\t}\n\t}\n\tif len(ips) == 0 {\n\t\treturn \"\", errors.New(\"no IPv4 address found\")\n\t}\n\trand.Seed(time.Now().UnixNano())\n\treturn ips[rand.Intn(len(ips))], nil\n}", "func network4(addr uint32, prefix uint) uint32 {\n\treturn addr & netmask(prefix)\n}", "func getLocalIPV4() string {\n\taddrList, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\tlogrus.Panicf(\"net.InterfaceAddrs error : %v\", err)\n\t}\n\n\tfor _, addr := range addrList {\n\t\tif ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() {\n\t\t\tif ip.IP.To4() == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn ip.IP.String()\n\t\t}\n\t}\n\treturn \"127.0.0.1\"\n}", "func IsIPv4(ip string) bool {\n\treturn net.ParseIP(ip).To4() != nil\n}", "func (f *FakeInstance) DefaultReverseIPv4(_ context.Context, _, _ string) error {\n\tpanic(\"implement me\")\n}", "func IsIPv4(s string) bool {\n\tif s == \"\" {\n\t\treturn false\n\t}\n\n\tip := net.ParseIP(s)\n\treturn ip != nil && ip.To4() != nil\n}", "func (s IPV4) String() string {\n\treturn fmt.Sprintf(\"%v.%v.%v.%v\", s[0], s[1], s[2], s[3])\n}", "func IsIPv4(s string) bool {\n\tif s == \"\" {\n\t\treturn false\n\t}\n\n\tip := net.ParseIP(s)\n\treturn ip != nil && strings.Contains(s, \".\") // && ip.To4() != nil\n}", "func (m *InterfaceProtocolConfigIPV4) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateDhcp(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateMethod(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateStatic(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *NetworkElementSummaryAllOf) SetIpv4Address(v string) {\n\to.Ipv4Address = &v\n}", "func PublicIpv4ContainsFold(v string) predicate.Agent {\n\treturn predicate.Agent(func(s *sql.Selector) {\n\t\ts.Where(sql.ContainsFold(s.C(FieldPublicIpv4), v))\n\t})\n}", "func (ds *DataStore) AssignPodIPv4Address(k8sPod *k8sapi.K8SPodInfo) (string, int, error) {\n\tds.lock.Lock()\n\tdefer ds.lock.Unlock()\n\n\tklog.V(2).Infof(\"AssignIPv4Address: IP address pool stats: total: %d, assigned %d\", ds.total, ds.assigned)\n\tpodKey := PodKey{\n\t\tname: k8sPod.Name,\n\t\tnamespace: k8sPod.Namespace,\n\t\tcontainer: k8sPod.Container,\n\t}\n\tipAddr, ok := ds.podsIP[podKey]\n\tif ok {\n\t\tif ipAddr.IP == k8sPod.IP && k8sPod.IP != \"\" {\n\t\t\t// The caller invoke multiple times to assign(PodName/NameSpace --> same IPAddress). It is not a error, but not very efficient.\n\t\t\tklog.V(1).Infof(\"AssignPodIPv4Address: duplicate pod assign for IP %s, name %s, namespace %s, container %s\",\n\t\t\t\tk8sPod.IP, k8sPod.Name, k8sPod.Namespace, k8sPod.Container)\n\t\t\treturn ipAddr.IP, ipAddr.DeviceNumber, nil\n\t\t}\n\t\t// TODO Handle this bug assert? May need to add a counter here, if counter is too high, need to mark node as unhealthy...\n\t\t// This is a bug that the caller invokes multiple times to assign(PodName/NameSpace -> a different IP address).\n\t\tklog.Errorf(\"AssignPodIPv4Address: current IP %s is changed to IP %s for pod(name %s, namespace %s, container %s)\",\n\t\t\tipAddr.IP, k8sPod.IP, k8sPod.Name, k8sPod.Namespace, k8sPod.Container)\n\t\treturn \"\", 0, errors.New(\"AssignPodIPv4Address: invalid pod with multiple IP addresses\")\n\t}\n\treturn ds.assignPodIPv4AddressUnsafe(k8sPod)\n}", "func (ipSet *IPSet) HasIPv4() bool {\n\treturn ipSet.IPv4 != \"\"\n}", "func IsIP4(val interface{}) bool {\n\treturn isMatch(ip4, val)\n}", "func (o *IPPrefixesSynthetics) SetPrefixesIpv4(v []string) {\n\to.PrefixesIpv4 = v\n}", "func (ip IPv4) Equals(value Value) bool {\n\to, ok := value.(IPv4)\n\treturn ok && ip.value == o.value\n}", "func NewV4(pubkey *ecdsa.PublicKey, ip net.IP, tcp, udp int) *Node {\n\tvar r qnr.Record\n\tif len(ip) > 0 {\n\t\tr.Set(qnr.IP(ip))\n\t}\n\tif udp != 0 {\n\t\tr.Set(qnr.UDP(udp))\n\t}\n\tif tcp != 0 {\n\t\tr.Set(qnr.TCP(tcp))\n\t}\n\tsignV4Compat(&r, pubkey)\n\tn, err := New(v4CompatID{}, &r)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn n\n}", "func (p *IPv4) Swap() {\n\tp.src, p.dst = p.dst, p.src\n}", "func AllLocalIP4() ([]net.IP, error) {\n\tdevices, err := net.Interfaces()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tret := []net.IP{}\n\tfor _, dev := range devices {\n\t\tif dev.Flags&net.FlagUp != 0 {\n\t\t\taddrs, err := dev.Addrs()\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor i := range addrs {\n\t\t\t\tif ip, ok := addrs[i].(*net.IPNet); ok {\n\t\t\t\t\tif ip.IP.To4() != nil {\n\t\t\t\t\t\tret = append(ret, ip.IP)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn ret, nil\n}", "func IPv4Address(ctx context.Context, client *docker.Client, containerID string) (net.IP, error) {\n\tc, err := client.InspectContainerWithContext(containerID, ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"find container %s address: %w\", containerID, err)\n\t}\n\treturn ipv4Address(c)\n}", "func FilterIPV4(ips []net.IP) []string {\n\tvar ret = make([]string, 0)\n\tfor _, ip := range ips {\n\t\tif ip.To4() != nil {\n\t\t\tret = append(ret, ip.String())\n\t\t}\n\t}\n\treturn ret\n}", "func GetIPv4(c *fluent.GRIBIClient, wantACK fluent.ProgrammingResult, t testing.TB, _ ...TestOpt) {\n\tops := []func(){\n\t\tfunc() {\n\t\t\tc.Modify().AddEntry(t,\n\t\t\t\tfluent.NextHopEntry().\n\t\t\t\t\tWithNetworkInstance(server.DefaultNetworkInstanceName).\n\t\t\t\t\tWithIndex(1).\n\t\t\t\t\tWithIPAddress(\"1.1.1.1\"))\n\t\t},\n\t\tfunc() {\n\t\t\tc.Modify().AddEntry(t,\n\t\t\t\tfluent.NextHopGroupEntry().\n\t\t\t\t\tWithNetworkInstance(server.DefaultNetworkInstanceName).\n\t\t\t\t\tWithID(1).\n\t\t\t\t\tAddNextHop(1, 1))\n\t\t},\n\t\tfunc() {\n\t\t\tc.Modify().AddEntry(t,\n\t\t\t\tfluent.IPv4Entry().\n\t\t\t\t\tWithNetworkInstance(server.DefaultNetworkInstanceName).\n\t\t\t\t\tWithNextHopGroup(1).\n\t\t\t\t\tWithPrefix(\"42.42.42.42/32\"))\n\t\t},\n\t}\n\n\tres := doModifyOps(c, t, ops, wantACK, false)\n\n\tchk.HasResult(t, res,\n\t\tfluent.OperationResult().\n\t\t\tWithNextHopOperation(1).\n\t\t\tWithOperationType(constants.Add).\n\t\t\tWithProgrammingResult(wantACK).\n\t\t\tAsResult(),\n\t\tchk.IgnoreOperationID(),\n\t)\n\n\tchk.HasResult(t, res,\n\t\tfluent.OperationResult().\n\t\t\tWithNextHopGroupOperation(1).\n\t\t\tWithOperationType(constants.Add).\n\t\t\tWithProgrammingResult(wantACK).\n\t\t\tAsResult(),\n\t\tchk.IgnoreOperationID(),\n\t)\n\n\tchk.HasResult(t, res,\n\t\tfluent.OperationResult().\n\t\t\tWithIPv4Operation(\"42.42.42.42/32\").\n\t\t\tWithOperationType(constants.Add).\n\t\t\tWithProgrammingResult(wantACK).\n\t\t\tAsResult(),\n\t\tchk.IgnoreOperationID(),\n\t)\n\n\tctx := context.Background()\n\tc.Start(ctx, t)\n\tdefer c.Stop(t)\n\tgr, err := c.Get().\n\t\tWithNetworkInstance(server.DefaultNetworkInstanceName).\n\t\tWithAFT(fluent.IPv4).\n\t\tSend()\n\n\tif err != nil {\n\t\tt.Fatalf(\"got unexpected error from get, got: %v\", err)\n\t}\n\n\tchk.GetResponseHasEntries(t, gr,\n\t\tfluent.IPv4Entry().\n\t\t\tWithNetworkInstance(server.DefaultNetworkInstanceName).\n\t\t\tWithNextHopGroup(1).\n\t\t\tWithPrefix(\"42.42.42.42/32\"),\n\t)\n}", "func extractIPv4(ptr string) string {\n\ts := strings.Replace(ptr, \".in-addr.arpa\", \"\", 1)\n\twords := strings.Split(s, \".\")\n\tfor i, j := 0, len(words)-1; i < j; i, j = i+1, j-1 {\n\t\twords[i], words[j] = words[j], words[i]\n\t}\n\treturn strings.Join(words, \".\")\n}", "func (l4netlb *L4NetLB) ensureIPv4Resources(result *L4NetLBSyncResult, nodeNames []string, bsLink string) {\n\tfr, ipAddrType, err := l4netlb.ensureIPv4ForwardingRule(bsLink)\n\tif err != nil {\n\t\t// User can misconfigure the forwarding rule if Network Tier will not match service level Network Tier.\n\t\tresult.GCEResourceInError = annotations.ForwardingRuleResource\n\t\tresult.Error = fmt.Errorf(\"failed to ensure forwarding rule - %w\", err)\n\t\tresult.MetricsLegacyState.IsUserError = utils.IsUserError(err)\n\t\treturn\n\t}\n\tif fr.IPProtocol == string(corev1.ProtocolTCP) {\n\t\tresult.Annotations[annotations.TCPForwardingRuleKey] = fr.Name\n\t} else {\n\t\tresult.Annotations[annotations.UDPForwardingRuleKey] = fr.Name\n\t}\n\tresult.MetricsLegacyState.IsManagedIP = ipAddrType == IPAddrManaged\n\tresult.MetricsLegacyState.IsPremiumTier = fr.NetworkTier == cloud.NetworkTierPremium.ToGCEValue()\n\n\tl4netlb.ensureIPv4NodesFirewall(nodeNames, fr.IPAddress, result)\n\tif result.Error != nil {\n\t\tklog.Errorf(\"ensureIPv4Resources: Failed to ensure nodes firewall for L4 NetLB Service %s/%s, error: %v\", l4netlb.Service.Namespace, l4netlb.Service.Name, err)\n\t\treturn\n\t}\n\n\tresult.Status = utils.AddIPToLBStatus(result.Status, fr.IPAddress)\n}", "func parseIPv4(ip string) net.IP {\n\tif parsedIP := net.ParseIP(strings.TrimSpace(ip)); parsedIP != nil {\n\t\tif ipv4 := parsedIP.To4(); ipv4 != nil {\n\t\t\treturn ipv4\n\t\t}\n\t}\n\n\treturn nil\n}", "func (m *RIBMessage) IPv4Flow() (*IPv4FlowAnnounceTextMessage, error) {\n\treturn nil, nil\n}", "func (m *IPV4) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateLan(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateWan(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func IsIpv4(s string) bool {\n\tips := strings.Split(s, ipSep)\n\tif len(ips) != ipV4Len {\n\t\treturn false\n\t}\n\tfor _, v := range ips {\n\t\tnum, e := strconv.Atoi(v)\n\t\tif e != nil || num > ipv4Max || num < ipv4Min {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func (ds *DataStore) DelIPv4AddressFromStore(nicID string, ipv4 string) error {\n\tds.lock.Lock()\n\tdefer ds.lock.Unlock()\n\tklog.V(2).Infof(\"Deleting NIC(%s)'s IPv4 address %s from datastore\", nicID, ipv4)\n\tklog.V(2).Infof(\"IP Address Pool stats: total: %d, assigned: %d\", ds.total, ds.assigned)\n\n\tcurNIC, ok := ds.nicIPPools[nicID]\n\tif !ok {\n\t\treturn errors.New(UnknownNICError)\n\t}\n\n\tipAddr, ok := curNIC.IPv4Addresses[ipv4]\n\tif !ok {\n\t\treturn errors.New(UnknownIPError)\n\t}\n\n\tif ipAddr.Assigned {\n\t\treturn errors.New(IPInUseError)\n\t}\n\n\tds.total--\n\t// Prometheus gauge\n\ttotalIPs.Set(float64(ds.total))\n\n\tdelete(curNIC.IPv4Addresses, ipv4)\n\n\tklog.V(1).Infof(\"Deleted NIC(%s)'s IP %s from datastore\", nicID, ipv4)\n\treturn nil\n}", "func (ds *DataStore) AddIPv4AddressFromStore(nicID string, ipv4 string) error {\n\tds.lock.Lock()\n\tdefer ds.lock.Unlock()\n\n\tklog.V(2).Infof(\"Adding NIC(%s)'s IPv4 address %s to datastore\", nicID, ipv4)\n\tklog.V(2).Infof(\"IP Address Pool stats: total: %d, assigned: %d\", ds.total, ds.assigned)\n\n\tcurNIC, ok := ds.nicIPPools[nicID]\n\tif !ok {\n\t\treturn errors.New(\"add NIC's IP to datastore: unknown NIC\")\n\t}\n\n\t_, ok = curNIC.IPv4Addresses[ipv4]\n\tif ok {\n\t\treturn errors.New(DuplicateIPError)\n\t}\n\n\tds.total++\n\t// Prometheus gauge\n\ttotalIPs.Set(float64(ds.total))\n\n\tcurNIC.IPv4Addresses[ipv4] = &AddressInfo{Address: ipv4, Assigned: false}\n\tklog.V(1).Infof(\"Added NIC(%s)'s IP %s to datastore\", nicID, ipv4)\n\treturn nil\n}", "func (ip IPv4) String() string {\n\treturn fmt.Sprintf(\"%d.%d.%d.%d\", ip[0], ip[1], ip[2], ip[3])\n}", "func IncrementIPv4(ip net.IP, inc int) net.IP {\n\tip = ip.To4()\n\tv := binary.BigEndian.Uint32(ip)\n\tif v >= uint32(0) {\n\t\tv = v + uint32(inc)\n\t} else {\n\t\tv = v - uint32(-inc)\n\t}\n\tip = make(net.IP, 4)\n\tbinary.BigEndian.PutUint32(ip, v)\n\treturn ip\n}", "func (crc *CasbinRuleCreate) SetV4(s string) *CasbinRuleCreate {\n\tcrc.mutation.SetV4(s)\n\treturn crc\n}", "func (p *IPPacket) DstV4() net.IP {\n\treturn net.IPv4((*p)[16], (*p)[17], (*p)[18], (*p)[19])\n}", "func (ep *epInfoCache) IPv4Address() netip.Addr {\n\treturn ep.ipv4\n}", "func IntToIpv4(intv int64) (ip string, err error) {\n\tif intv < ipv4MinInt || intv > ipv4MaxInt {\n\t\terr = BadIpv4Error\n\t\treturn\n\t}\n\n\tip = strings.Join([]string{\n\t\tstrconv.Itoa(int(intv & ip1x >> ipv4Shift[0])),\n\t\tstrconv.Itoa(int(intv & ip2x >> ipv4Shift[1])),\n\t\tstrconv.Itoa(int(intv & ip3x >> ipv4Shift[2])),\n\t\tstrconv.Itoa(int(intv & ip4x >> ipv4Shift[3]))},\n\t\tipSep)\n\n\treturn\n}" ]
[ "0.6443081", "0.6388994", "0.63776445", "0.6346549", "0.6192383", "0.61467063", "0.6119341", "0.59505796", "0.58408594", "0.5829703", "0.5822138", "0.5800136", "0.574169", "0.5729033", "0.57041806", "0.5692545", "0.5672946", "0.56706774", "0.5669973", "0.5656812", "0.56447315", "0.56057584", "0.5597116", "0.5588403", "0.55849063", "0.556407", "0.55628103", "0.5550961", "0.551651", "0.55156076", "0.5490048", "0.5484926", "0.5465212", "0.5451935", "0.54303", "0.5404971", "0.5391032", "0.53788126", "0.5376378", "0.5369238", "0.53685534", "0.535852", "0.53558964", "0.53378344", "0.53253394", "0.5323153", "0.5321143", "0.5314374", "0.5310506", "0.5297026", "0.5289147", "0.52889216", "0.5284165", "0.5241419", "0.52404153", "0.52169997", "0.5216206", "0.521614", "0.5215295", "0.5210172", "0.5209929", "0.52054214", "0.5192797", "0.51924574", "0.5190526", "0.5189518", "0.51833075", "0.5174843", "0.51738375", "0.51737523", "0.5157874", "0.51505876", "0.51471895", "0.5141837", "0.51411355", "0.512112", "0.5110004", "0.5101439", "0.5095463", "0.50915", "0.5091398", "0.5082896", "0.5080923", "0.50804216", "0.50737786", "0.50705194", "0.5070183", "0.5068823", "0.5058205", "0.5054369", "0.5047928", "0.5046807", "0.50303435", "0.5029502", "0.5018306", "0.5017512", "0.50008744", "0.50002414", "0.49979165", "0.49900252" ]
0.8872807
0
createHostonlyAdapter creates a new hostonly network.
func createHostonlyAdapter(vbox VBoxManager) (*hostOnlyNetwork, error) { out, err := vbox.vbmOut("hostonlyif", "create") if err != nil { return nil, err } res := reHostOnlyAdapterCreated.FindStringSubmatch(string(out)) if res == nil { return nil, errors.New("Failed to create host-only adapter") } return &hostOnlyNetwork{Name: res[1]}, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func createHostWithIp(nodeId int, ip string, port int) (core.Host, error) {\n\t// Producing private key using nodeId\n\tr := mrand.New(mrand.NewSource(int64(nodeId)))\n\n\tprvKey, _ := ecdsa.GenerateKey(btcec.S256(), r)\n\tsk := (*crypto.Secp256k1PrivateKey)(prvKey)\n\n\t// Starting a peer with default configs\n\topts := []libp2p.Option{\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/0.0.0.0/tcp/%s\", strconv.Itoa(port))),\n\t\tlibp2p.Identity(sk),\n\t\tlibp2p.DefaultTransports,\n\t\tlibp2p.DefaultMuxers,\n\t\tlibp2p.DefaultSecurity,\n\t}\n\n\th, err := libp2p.New(context.Background(), opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn h, nil\n}", "func listHostOnlyAdapters(vbox VBoxManager) (map[string]*hostOnlyNetwork, error) {\n\tout, err := vbox.vbmOut(\"list\", \"hostonlyifs\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbyName := map[string]*hostOnlyNetwork{}\n\tbyIP := map[string]*hostOnlyNetwork{}\n\tn := &hostOnlyNetwork{}\n\n\terr = parseKeyValues(out, reColonLine, func(key, val string) error {\n\t\tswitch key {\n\t\tcase \"Name\":\n\t\t\tn.Name = val\n\t\tcase \"GUID\":\n\t\t\tn.GUID = val\n\t\tcase \"DHCP\":\n\t\t\tn.DHCP = (val != \"Disabled\")\n\t\tcase \"IPAddress\":\n\t\t\tn.IPv4.IP = net.ParseIP(val)\n\t\tcase \"NetworkMask\":\n\t\t\tn.IPv4.Mask = parseIPv4Mask(val)\n\t\tcase \"HardwareAddress\":\n\t\t\tmac, err := net.ParseMAC(val)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tn.HwAddr = mac\n\t\tcase \"MediumType\":\n\t\t\tn.Medium = val\n\t\tcase \"Status\":\n\t\t\tn.Status = val\n\t\tcase \"VBoxNetworkName\":\n\t\t\tn.NetworkName = val\n\n\t\t\tif _, present := byName[n.NetworkName]; present {\n\t\t\t\treturn fmt.Errorf(\"VirtualBox is configured with multiple host-only adapters with the same name %q. Please remove one.\", n.NetworkName)\n\t\t\t}\n\t\t\tbyName[n.NetworkName] = n\n\n\t\t\tif len(n.IPv4.IP) != 0 {\n\t\t\t\tif _, present := byIP[n.IPv4.IP.String()]; present {\n\t\t\t\t\treturn fmt.Errorf(\"VirtualBox is configured with multiple host-only adapters with the same IP %q. Please remove one.\", n.IPv4.IP)\n\t\t\t\t}\n\t\t\t\tbyIP[n.IPv4.IP.String()] = n\n\t\t\t}\n\n\t\t\tn = &hostOnlyNetwork{}\n\t\t}\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn byName, nil\n}", "func createHost(port int) (core.Host, error) {\n\t// Producing private key\n\tprvKey, _ := ecdsa.GenerateKey(btcec.S256(), rand.Reader)\n\tsk := (*crypto.Secp256k1PrivateKey)(prvKey)\n\n\t// Starting a peer with default configs\n\topts := []libp2p.Option{\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/0.0.0.0/tcp/%d\", port)),\n\t\tlibp2p.Identity(sk),\n\t\tlibp2p.DefaultTransports,\n\t\tlibp2p.DefaultMuxers,\n\t\tlibp2p.DefaultSecurity,\n\t}\n\n\th, err := libp2p.New(context.Background(), opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn h, nil\n}", "func NewHost(host string) Host {\n\treturn Host(host)\n}", "func (s stack) CreateHost(ctx context.Context, request abstract.HostRequest, extra interface{}) (_ *abstract.HostFull, _ *userdata.Content, ferr fail.Error) {\n\tdefer fail.OnPanic(&ferr)\n\n\treturn nil, nil, fail.NotImplementedError(\"useless method\")\n}", "func (d *Device) CreateHost(ctx context.Context, hostname string) (*Host, error) {\n\tspath := \"/host\"\n\tparam := struct {\n\t\tNAME string `json:\"NAME\"`\n\t\tTYPE string `json:\"TYPE\"`\n\t\tOPERATIONSYSTEM string `json:\"OPERATIONSYSTEM\"`\n\t\tDESCRIPTION string `json:\"DESCRIPTION\"`\n\t}{\n\t\tNAME: encodeHostName(hostname),\n\t\tTYPE: strconv.Itoa(TypeHost),\n\t\tOPERATIONSYSTEM: \"0\",\n\t\tDESCRIPTION: hostname,\n\t}\n\tjb, err := json.Marshal(param)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(ErrCreatePostValue+\": %w\", err)\n\t}\n\treq, err := d.newRequest(ctx, \"POST\", spath, bytes.NewBuffer(jb))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(ErrCreateRequest+\": %w\", err)\n\t}\n\n\thost := &Host{}\n\tif err = d.requestWithRetry(req, host, DefaultHTTPRetryCount); err != nil {\n\t\treturn nil, fmt.Errorf(ErrRequestWithRetry+\": %w\", err)\n\t}\n\n\treturn host, nil\n}", "func NewHost(ip net.IP, hostname string, aliases ...string) Host {\n\treturn Host{\n\t\tIP: ip,\n\t\tHostname: hostname,\n\t\tAliases: aliases,\n\t}\n}", "func addHostOnlyDHCPServer(ifname string, d dhcpServer, vbox VBoxManager) error {\n\tname := dhcpPrefix + ifname\n\n\tdhcps, err := listDHCPServers(vbox)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// On some platforms (OSX), creating a host-only adapter adds a default dhcpserver,\n\t// while on others (Windows?) it does not.\n\tcommand := \"add\"\n\tif dhcp, ok := dhcps[name]; ok {\n\t\tcommand = \"modify\"\n\t\tif (dhcp.IPv4.IP.Equal(d.IPv4.IP)) && (dhcp.IPv4.Mask.String() == d.IPv4.Mask.String()) && (dhcp.LowerIP.Equal(d.LowerIP)) && (dhcp.UpperIP.Equal(d.UpperIP)) && dhcp.Enabled {\n\t\t\t// dhcp is up to date\n\t\t\treturn nil\n\t\t}\n\t}\n\n\targs := []string{\"dhcpserver\", command,\n\t\t\"--netname\", name,\n\t\t\"--ip\", d.IPv4.IP.String(),\n\t\t\"--netmask\", net.IP(d.IPv4.Mask).String(),\n\t\t\"--lowerip\", d.LowerIP.String(),\n\t\t\"--upperip\", d.UpperIP.String(),\n\t}\n\tif d.Enabled {\n\t\targs = append(args, \"--enable\")\n\t} else {\n\t\targs = append(args, \"--disable\")\n\t}\n\n\treturn vbox.vbm(args...)\n}", "func NewHost(addr Address, peerCount, channelLimit uint64, incomingBandwidth, outgoingBandwidth uint32) (Host, error) {\n\tvar cAddr *C.struct__ENetAddress\n\tif addr != nil {\n\t\tcAddr = &(addr.(*enetAddress)).cAddr\n\t}\n\n\thost := C.enet_host_create(\n\t\tcAddr,\n\t\t(C.size_t)(peerCount),\n\t\t(C.size_t)(channelLimit),\n\t\t(C.enet_uint32)(incomingBandwidth),\n\t\t(C.enet_uint32)(outgoingBandwidth),\n\t)\n\n\tif host == nil {\n\t\treturn nil, errors.New(\"unable to create host\")\n\t}\n\n\treturn &enetHost{\n\t\tcHost: host,\n\t}, nil\n}", "func NewBindHostForbidden() *BindHostForbidden {\n\treturn &BindHostForbidden{}\n}", "func NewPerHost(defaultDialer, bypass Dialer) *PerHost {\n\treturn &PerHost{\n\t\tdef: defaultDialer,\n\t\tbypass: bypass,\n\t}\n}", "func getHostOnlyNetworkInterface(mc *driver.MachineConfig) (string, error) {\n\t// Check if the interface/dhcp exists.\n\tnets, err := HostonlyNets()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdhcps, err := DHCPs()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor _, n := range nets {\n\t\tif dhcp, ok := dhcps[n.NetworkName]; ok {\n\t\t\tif dhcp.IPv4.IP.Equal(mc.DHCPIP) &&\n\t\t\t\tdhcp.IPv4.Mask.String() == mc.NetMask.String() &&\n\t\t\t\tdhcp.LowerIP.Equal(mc.LowerIP) &&\n\t\t\t\tdhcp.UpperIP.Equal(mc.UpperIP) &&\n\t\t\t\tdhcp.Enabled == mc.DHCPEnabled {\n\t\t\t\treturn n.Name, nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// No existing host-only interface found. Create a new one.\n\thostonlyNet, err := CreateHostonlyNet()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\thostonlyNet.IPv4.IP = mc.HostIP\n\thostonlyNet.IPv4.Mask = mc.NetMask\n\tif err := hostonlyNet.Config(); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Create and add a DHCP server to the host-only network\n\tdhcp := driver.DHCP{}\n\tdhcp.IPv4.IP = mc.DHCPIP\n\tdhcp.IPv4.Mask = mc.NetMask\n\tdhcp.LowerIP = mc.LowerIP\n\tdhcp.UpperIP = mc.UpperIP\n\tdhcp.Enabled = true\n\tif err := AddHostonlyDHCP(hostonlyNet.Name, dhcp); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn hostonlyNet.Name, nil\n}", "func NewTransportConfigHostonly() *TransportConfig {\n\treturn &TransportConfig{\n\t\tComponentNumber: 1,\n\t}\n}", "func NewHost(address string) (*Host, error) {\n\taddr, err := NewAddress(address)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Failed to create Host\")\n\t}\n\treturn &Host{Address: addr}, nil\n}", "func NewAdapter(g *gce.Cloud) NetworkEndpointGroupCloud {\n\treturn &cloudProviderAdapter{\n\t\tc: g,\n\t\tnetworkURL: g.NetworkURL(),\n\t\tsubnetworkURL: g.SubnetworkURL(),\n\t}\n}", "func (tester *ServiceTester) CreateHost(t *testing.T, name string, subnet *abstract.Subnet, public bool) (*abstract.HostFull, *userdata.Content, fail.Error) {\n\tctx := context.Background()\n\ttpls, xerr := tester.Service.ListTemplatesBySizing(ctx, abstract.HostSizingRequirements{\n\t\tMinCores: 1,\n\t\tMinRAMSize: 1,\n\t\tMinDiskSize: 10,\n\t}, false)\n\tassert.Nil(t, xerr)\n\timg, xerr := tester.Service.SearchImage(ctx, \"Ubuntu 20.04\")\n\tassert.Nil(t, xerr)\n\thostRequest := abstract.HostRequest{\n\t\tResourceName: name,\n\t\tSubnets: []*abstract.Subnet{subnet},\n\t\tDefaultRouteIP: \"\",\n\t\tPublicIP: public,\n\t\tTemplateID: tpls[0].ID,\n\t\tImageID: img.ID,\n\t\tKeyPair: nil,\n\t\tPassword: \"\",\n\t\tDiskSize: 0,\n\t}\n\treturn tester.Service.CreateHost(context.Background(), hostRequest, nil)\n}", "func createHnsNetwork(backend string, networkAdapter string) (string, error) {\n\tvar network hcsshim.HNSNetwork\n\tif backend == \"vxlan\" {\n\t\t// Ignoring the return because both true and false without an error represent that the firewall rule was created or already exists\n\t\tif _, err := wapi.FirewallRuleAdd(\"OverlayTraffic4789UDP\", \"Overlay network traffic UDP\", \"\", \"4789\", wapi.NET_FW_IP_PROTOCOL_UDP, wapi.NET_FW_PROFILE2_ALL); err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"error creating firewall rules: %v\", err)\n\t\t}\n\t\tlogrus.Infof(\"Creating VXLAN network using the vxlanAdapter: %s\", networkAdapter)\n\t\tnetwork = hcsshim.HNSNetwork{\n\t\t\tType: \"Overlay\",\n\t\t\tName: CalicoHnsNetworkName,\n\t\t\tNetworkAdapterName: networkAdapter,\n\t\t\tSubnets: []hcsshim.Subnet{\n\t\t\t\t{\n\t\t\t\t\tAddressPrefix: \"192.168.255.0/30\",\n\t\t\t\t\tGatewayAddress: \"192.168.255.1\",\n\t\t\t\t\tPolicies: []json.RawMessage{\n\t\t\t\t\t\t[]byte(\"{ \\\"Type\\\": \\\"VSID\\\", \\\"VSID\\\": 9999 }\"),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t} else {\n\t\tnetwork = hcsshim.HNSNetwork{\n\t\t\tType: \"L2Bridge\",\n\t\t\tName: CalicoHnsNetworkName,\n\t\t\tNetworkAdapterName: networkAdapter,\n\t\t\tSubnets: []hcsshim.Subnet{\n\t\t\t\t{\n\t\t\t\t\tAddressPrefix: \"192.168.255.0/30\",\n\t\t\t\t\tGatewayAddress: \"192.168.255.1\",\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\t}\n\n\tif _, err := network.Create(); err != nil {\n\t\treturn \"\", fmt.Errorf(\"error creating the %s network: %v\", CalicoHnsNetworkName, err)\n\t}\n\n\t// Check if network exists. If it does not after 5 minutes, fail\n\tfor start := time.Now(); time.Since(start) < 5*time.Minute; {\n\t\tnetwork, err := hcsshim.GetHNSNetworkByName(CalicoHnsNetworkName)\n\t\tif err == nil {\n\t\t\treturn network.ManagementIP, nil\n\t\t}\n\t}\n\n\treturn \"\", fmt.Errorf(\"failed to create %s network\", CalicoHnsNetworkName)\n}", "func (client *Client) CreateHost(request model.HostRequest) (*model.Host, error) {\n\treturn client.osclt.CreateHost(request)\n}", "func createHost() (context.Context, host.Host, error) {\n\tctx, _ /* cancel */ := context.WithCancel(context.Background())\n\t// defer cancel()\n\n\tprvKey, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, rand.Reader)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tport, err := freeport.GetFreePort()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\thost, err := libp2p.New(\n\t\tctx,\n\t\tlibp2p.Identity(prvKey),\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/0.0.0.0/tcp/%v\", port)),\n\t)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn ctx, host, nil\n}", "func (client *Client) CreateHost(request model.HostRequest) (*model.Host, error) {\n\treturn client.feclt.CreateHost(request)\n}", "func NewAdapter() (adapter *Adapter, err error) {\n\tp := configProvider()\n\tadapter = &Adapter{\n\t\tec2: ec2.New(p),\n\t\tec2metadata: ec2metadata.New(p),\n\t\tautoscaling: autoscaling.New(p),\n\t\tacm: acm.New(p),\n\t\tiam: iam.New(p),\n\t\tcloudformation: cloudformation.New(p),\n\t\thealthCheckPath: DefaultHealthCheckPath,\n\t\thealthCheckPort: DefaultHealthCheckPort,\n\t\thealthCheckInterval: DefaultHealthCheckInterval,\n\t\tcreationTimeout: DefaultCreationTimeout,\n\t\tstackTTL: DefaultStackTTL,\n\t}\n\n\tadapter.manifest, err = buildManifest(adapter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn\n}", "func newTestingHost(testdir string, cs modules.ConsensusSet, tp modules.TransactionPool) (modules.Host, error) {\n\tg, err := gateway.New(\"localhost:0\", false, filepath.Join(testdir, modules.GatewayDir), false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tw, err := newTestingWallet(testdir, cs, tp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\th, err := host.New(cs, g, tp, w, \"localhost:0\", filepath.Join(testdir, modules.HostDir))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// configure host to accept contracts\n\tsettings := h.InternalSettings()\n\tsettings.AcceptingContracts = true\n\terr = h.SetInternalSettings(settings)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// add storage to host\n\tstorageFolder := filepath.Join(testdir, \"storage\")\n\terr = os.MkdirAll(storageFolder, 0700)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = h.AddStorageFolder(storageFolder, modules.SectorSize*64)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn h, nil\n}", "func NewVppAdapter(addr string, useShm bool) adapter.VppAPI {\n\tif useShm {\n\t\tfmt.Fprint(os.Stderr, noShmWarning)\n\t\tpanic(\"No implementation for shared memory in pure Go client!\")\n\t}\n\t// addr is used as socket path\n\treturn socketclient.NewVppClient(addr)\n}", "func NewAdapter(b *AdapterBuilder) (a *Adapter) {\n\t// allocate default adapter\n\ta = &Adapter{\n\t\tbeforeErr: doNothing,\n\t\tafterErr: doNothing,\n\t\tinternalHandler: defaultInternalServerErrorHandler,\n\t\twrapInternal: b.WrapInternal,\n\t}\n\n\t// check for nil arguments\n\tif b.AfterError != nil {\n\t\ta.afterErr = b.AfterError\n\t}\n\tif b.BeforeError != nil {\n\t\ta.beforeErr = b.BeforeError\n\t}\n\tif b.InternalHandler != nil {\n\t\ta.internalHandler = b.InternalHandler\n\t}\n\n\t// return adapter that is safe to use and will\n\t// not panic because of nil function pointers\n\treturn\n}", "func NewAdapter(driverName string, masterDSNs []string, slaveDSNs []string, dbSpecified ...bool) *Adapter {\n\ta := &Adapter{}\n\ta.driverName = driverName\n\ta.masterDSNs = masterDSNs\n\ta.slaveDSNs = slaveDSNs\n\n\tif len(dbSpecified) == 0 {\n\t\ta.dbSpecified = false\n\t} else if len(dbSpecified) == 1 {\n\t\ta.dbSpecified = dbSpecified[0]\n\t} else {\n\t\tpanic(errors.New(\"invalid parameter: dbSpecified\"))\n\t}\n\n\t// Open the DB, create it if not existed.\n\ta.open()\n\n\t// Call the destructor when the object is released.\n\truntime.SetFinalizer(a, finalizer)\n\n\treturn a\n}", "func NewHostAddress(host string, port uint16) *HostAddress {\n\treturn &HostAddress{host: host, port: port}\n}", "func NewBindHostMethodNotAllowed() *BindHostMethodNotAllowed {\n\treturn &BindHostMethodNotAllowed{}\n}", "func NewHost(config v2.Host, clusterInfo types.ClusterInfo) types.Host {\n\taddr, _ := net.ResolveTCPAddr(\"tcp\", config.Address)\n\n\treturn &host{\n\t\thostInfo: newHostInfo(addr, config, clusterInfo),\n\t\tweight: config.Weight,\n\t}\n}", "func (client *Client) CreateHost(name, iqn string) (*Response, *ResponseStatus, error) {\n\treturn client.FormattedRequest(\"/create/host/id/\\\"%s\\\"/\\\"%s\\\"\", iqn, name)\n}", "func NewDisableHostForbidden() *DisableHostForbidden {\n\treturn &DisableHostForbidden{}\n}", "func (b *BridgeNetworkDriver) Create(name string, subnet string) (*Network, error) {\n\t// 取到网段字符串中的网关ip地址和网络的ip段\n\tip, IPRange, _ := net.ParseCIDR(subnet)\n\tIPRange.IP = ip\n\n\tn := &Network{\n\t\tName: name,\n\t\tIPRange: IPRange,\n\t\tDriver: b.Name(),\n\t}\n\n\terr := b.initBridge(n)\n\treturn n, err\n}", "func (p *Proxy) NewHost(c *exec.Cmd) (*Host, error) {\n\th := &Host{\n\t\tcmd: c,\n\t\tproxy: p,\n\t}\n\tvar err error\n\th.httpTransfer, h.httpsTransfer, err = h.setupCmd(c)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn h, nil\n}", "func (s *PolicySets) NewHostRule(isInbound bool) *hns.ACLPolicy {\n\tdirection := hns.Out\n\tif isInbound {\n\t\tdirection = hns.In\n\t}\n\n\treturn &hns.ACLPolicy{\n\t\tType: hns.ACL,\n\t\tRuleType: hns.Host,\n\t\tAction: hns.Allow,\n\t\tDirection: direction,\n\t\tPriority: 100,\n\t\tProtocol: 256, // Any\n\t}\n}", "func NewHost(ctx *pulumi.Context,\n\tname string, args *HostArgs, opts ...pulumi.ResourceOption) (*Host, error) {\n\tif args == nil || args.Hostname == nil {\n\t\treturn nil, errors.New(\"missing required argument 'Hostname'\")\n\t}\n\tif args == nil || args.Password == nil {\n\t\treturn nil, errors.New(\"missing required argument 'Password'\")\n\t}\n\tif args == nil || args.Username == nil {\n\t\treturn nil, errors.New(\"missing required argument 'Username'\")\n\t}\n\tif args == nil {\n\t\targs = &HostArgs{}\n\t}\n\tvar resource Host\n\terr := ctx.RegisterResource(\"vsphere:index/host:Host\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (d *Driver) createNetwork() error {\n\tconn, err := getConnection()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"getting libvirt connection\")\n\t}\n\tdefer conn.Close()\n\n\t// network: default\n\t// It is assumed that the libvirt/kvm installation has already created this network\n\n\t// network: private\n\n\t// Only create the private network if it does not already exist\n\tif _, err := conn.LookupNetworkByName(d.PrivateNetwork); err != nil {\n\t\t// create the XML for the private network from our networkTmpl\n\t\ttmpl := template.Must(template.New(\"network\").Parse(networkTmpl))\n\t\tvar networkXML bytes.Buffer\n\t\tif err := tmpl.Execute(&networkXML, d); err != nil {\n\t\t\treturn errors.Wrap(err, \"executing network template\")\n\t\t}\n\n\t\t// define the network using our template\n\t\tnetwork, err := conn.NetworkDefineXML(networkXML.String())\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"defining network from xml: %s\", networkXML.String())\n\t\t}\n\n\t\t// and finally create it\n\t\tif err := network.Create(); err != nil {\n\t\t\treturn errors.Wrapf(err, \"creating network %s\", d.PrivateNetwork)\n\t\t}\n\t}\n\n\treturn nil\n}", "func New(tb testing.TB, settings hostdb.HostSettings, wm host.Wallet, tpool host.TransactionPool) *Host {\n\ttb.Helper()\n\tl, err := net.Listen(\"tcp\", \":0\")\n\tif err != nil {\n\t\ttb.Fatal(err)\n\t}\n\ttb.Cleanup(func() { l.Close() })\n\tsettings.NetAddress = modules.NetAddress(l.Addr().String())\n\tsettings.UnlockHash, err = wm.Address()\n\tif err != nil {\n\t\ttb.Fatal(err)\n\t}\n\tkey := ed25519.NewKeyFromSeed(frand.Bytes(ed25519.SeedSize))\n\th := &Host{\n\t\tPublicKey: hostdb.HostKeyFromPublicKey(ed25519hash.ExtractPublicKey(key)),\n\t\tSettings: settings,\n\t\tl: l,\n\t}\n\tcs := newEphemeralContractStore(key)\n\tss := newEphemeralSectorStore()\n\tsh := host.NewSessionHandler(key, (*constantHostSettings)(&h.Settings), cs, ss, wm, tpool, nopMetricsRecorder{})\n\tgo listen(sh, l)\n\th.cw = host.NewChainWatcher(tpool, wm, cs, ss)\n\treturn h\n}", "func NewHostFilter(host string) *HostFilter {\n\tctx, cancel := context.WithCancel(context.Background())\n\tf := &HostFilter{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\n\t\thost: host,\n\n\t\toutputCh: make(chan map[string][]*targetgroup.Group),\n\t}\n\treturn f\n}", "func NewAdapter() Adapter {\n\treturn createAdapter()\n}", "func NewAdapter() Adapter {\n\treturn createAdapter()\n}", "func NewAdapter() Adapter {\n\treturn createAdapter()\n}", "func NewAdapter() Adapter {\n\treturn createAdapter()\n}", "func NewAdapter() Adapter {\n\treturn createAdapter()\n}", "func makeOrgVdcNetworkWithDhcp(vcd *TestVCD, check *C, edgeGateway *EdgeGateway) *types.OrgVDCNetwork {\n\tvar networkConfig = types.OrgVDCNetwork{\n\t\tXmlns: types.XMLNamespaceVCloud,\n\t\tName: TestCreateOrgVdcNetworkDhcp,\n\t\tDescription: TestCreateOrgVdcNetworkDhcp,\n\t\tConfiguration: &types.NetworkConfiguration{\n\t\t\tFenceMode: types.FenceModeNAT,\n\t\t\tIPScopes: &types.IPScopes{\n\t\t\t\tIPScope: []*types.IPScope{&types.IPScope{\n\t\t\t\t\tIsInherited: false,\n\t\t\t\t\tGateway: \"32.32.32.1\",\n\t\t\t\t\tNetmask: \"255.255.255.0\",\n\t\t\t\t\tIPRanges: &types.IPRanges{\n\t\t\t\t\t\tIPRange: []*types.IPRange{\n\t\t\t\t\t\t\t&types.IPRange{\n\t\t\t\t\t\t\t\tStartAddress: \"32.32.32.10\",\n\t\t\t\t\t\t\t\tEndAddress: \"32.32.32.20\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tBackwardCompatibilityMode: true,\n\t\t},\n\t\tEdgeGateway: &types.Reference{\n\t\t\tHREF: edgeGateway.EdgeGateway.HREF,\n\t\t\tID: edgeGateway.EdgeGateway.ID,\n\t\t\tName: edgeGateway.EdgeGateway.Name,\n\t\t\tType: edgeGateway.EdgeGateway.Type,\n\t\t},\n\t\tIsShared: false,\n\t}\n\n\t// Create network\n\terr := vcd.vdc.CreateOrgVDCNetworkWait(&networkConfig)\n\tif err != nil {\n\t\tfmt.Printf(\"error creating Network <%s>: %s\\n\", TestCreateOrgVdcNetworkDhcp, err)\n\t}\n\tcheck.Assert(err, IsNil)\n\tAddToCleanupList(TestCreateOrgVdcNetworkDhcp, \"network\", vcd.org.Org.Name+\"|\"+vcd.vdc.Vdc.Name, \"TestCreateOrgVdcNetworkDhcp\")\n\tnetwork, err := vcd.vdc.GetOrgVdcNetworkByName(TestCreateOrgVdcNetworkDhcp, true)\n\tcheck.Assert(err, IsNil)\n\n\t// Add DHCP pool\n\tdhcpPoolConfig := make([]interface{}, 1)\n\tdhcpPool := make(map[string]interface{})\n\tdhcpPool[\"start_address\"] = \"32.32.32.21\"\n\tdhcpPool[\"end_address\"] = \"32.32.32.250\"\n\tdhcpPool[\"default_lease_time\"] = 3600\n\tdhcpPool[\"max_lease_time\"] = 7200\n\tdhcpPoolConfig[0] = dhcpPool\n\ttask, err := edgeGateway.AddDhcpPool(network.OrgVDCNetwork, dhcpPoolConfig)\n\tcheck.Assert(err, IsNil)\n\terr = task.WaitTaskCompletion()\n\tcheck.Assert(err, IsNil)\n\n\treturn network.OrgVDCNetwork\n}", "func makeBasicHost(listenPort int, secio bool, randseed int64) (host.Host, error) {\r\n\r\n\tvar r io.Reader\r\n\tif randseed == 0 {\r\n\t\tr = rand.Reader\r\n\t} else {\r\n\t\tr = mrand.New(mrand.NewSource(randseed))\r\n\t}\r\n\r\n\tpriv, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, r)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\t// To create a 'swarm' (BasicHost), we need an <ipfs-protocol ID> like 'QmNt...xc'\r\n\t// We generate a key pair on every run and uses and ID extracted from the public key.\r\n\t// We also need a <multiaddress> indicating how to reach this peer.\r\n\topts := []libp2p.Option{\r\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/127.0.0.1/tcp/%d\", listenPort)),\r\n\t\tlibp2p.Identity(priv),\r\n\t}\r\n\r\n\tif !secio {\r\n\t\topts = append(opts, libp2p.NoSecurity)\r\n\t}\r\n\r\n\tbasicHost, err := libp2p.New(context.Background(), opts...)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\thostAddr, _ := ma.NewMultiaddr(fmt.Sprintf(\"/ipfs/%s\", basicHost.ID().Pretty()))\r\n\r\n\tvar addr ma.Multiaddr\r\n\tfor _, a := range basicHost.Addrs() {\r\n\t\tif strings.Contains(a.String(), \"p2p-circuit\") {\r\n\t\t\tcontinue\r\n\t\t}\r\n\t\taddr = a\r\n\t\tbreak\r\n\t}\r\n\r\n\t// concat addr + hostAddr\r\n\tfullAddr := addr.Encapsulate(hostAddr)\r\n\tlog.Printf(\"I am %s\\n\", fullAddr)\r\n\tif secio {\r\n\t\tlog.Printf(\"Now run \\\"./echo -l %d -d %s -secio\\\" on a different terminal\\n\", listenPort+1, fullAddr)\r\n\t} else {\r\n\t\tlog.Printf(\"Now run \\\"./echo -l %d -d %s \\\" on a different terminal\\n\", listenPort+1, fullAddr)\r\n\t}\r\n\r\n\treturn basicHost, nil\r\n}", "func NewAdapter(db *sql.DB, tableName string) (*Adapter, error) {\n\treturn NewAdapterWithDBSchema(db, \"public\", tableName)\n}", "func (nc *Builder) buildHost(ctx context.Context, makeDHT func(host host.Host) (routing.Routing, error)) (host.Host, error) {\n\t// Node must build a host acting as a libp2p relay. Additionally it\n\t// runs the autoNAT service which allows other nodes to check for their\n\t// own dialability by having this node attempt to dial them.\n\tmakeDHTRightType := func(h host.Host) (routing.PeerRouting, error) {\n\t\treturn makeDHT(h)\n\t}\n\n\tif nc.IsRelay {\n\t\tcfg := nc.Repo.Config()\n\t\tpublicAddr, err := ma.NewMultiaddr(cfg.Swarm.PublicRelayAddress)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tpublicAddrFactory := func(lc *libp2p.Config) error {\n\t\t\tlc.AddrsFactory = func(addrs []ma.Multiaddr) []ma.Multiaddr {\n\t\t\t\tif cfg.Swarm.PublicRelayAddress == \"\" {\n\t\t\t\t\treturn addrs\n\t\t\t\t}\n\t\t\t\treturn append(addrs, publicAddr)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t\trelayHost, err := libp2p.New(\n\t\t\tctx,\n\t\t\tlibp2p.EnableRelay(circuit.OptHop),\n\t\t\tlibp2p.EnableAutoRelay(),\n\t\t\tlibp2p.Routing(makeDHTRightType),\n\t\t\tpublicAddrFactory,\n\t\t\tlibp2p.ChainOptions(nc.Libp2pOpts...),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\t// Set up autoNATService as a streamhandler on the host.\n\t\t_, err = autonatsvc.NewAutoNATService(ctx, relayHost)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn relayHost, nil\n\t}\n\treturn libp2p.New(\n\t\tctx,\n\t\tlibp2p.EnableAutoRelay(),\n\t\tlibp2p.Routing(makeDHTRightType),\n\t\tlibp2p.ChainOptions(nc.Libp2pOpts...),\n\t)\n}", "func FL_mk_host( ipv4 string, ipv6 string, mac string, swname string, port int ) ( flhost FL_host_json ) {\n\n\tflhost = FL_host_json { }\t\t\t// new struct\n\tflhost.Mac = make( []string, 1 )\n\tflhost.Ipv4 = make( []string, 1 )\n\tflhost.Ipv6 = make( []string, 1 )\n\tflhost.Mac[0] = mac\n\tflhost.Ipv4[0] = ipv4\n\tflhost.Ipv6[0] = ipv6\n\n\tflhost.AttachmentPoint = make( []FL_attachment_json, 1 )\n\tflhost.AttachmentPoint[0].SwitchDPID = swname\n\tflhost.AttachmentPoint[0].Port = port\n\n\treturn\n}", "func NewHost(conf Config, middlewares ...Middleware) (host *Host) {\n\thost = &Host{\n\t\thandlers: map[string]*endpoint{},\n\t\tconf: conf,\n\n\t\tbasepath: \"\",\n\t\tmstack: middlewares,\n\t}\n\tif !conf.DisableAutoReport {\n\t\tos.Stdout.WriteString(\"Registration Info:\\r\\n\")\n\t}\n\thost.initCheck()\n\treturn\n}", "func NewHostDevCni(typeOfVlan string, logger logr.Logger) *HostDevCni {\n\treturn &HostDevCni{VlanType: typeOfVlan,\n\t\tLog: logger}\n}", "func (b *Bridge) CreateHostTap(tap string, lan int) (string, error) {\n\tbridgeLock.Lock()\n\tdefer bridgeLock.Unlock()\n\n\treturn b.createHostTap(tap, lan)\n}", "func MakeBasicHost(listenPort int, protocolID string, randseed int64) (host.Host, error) {\n\n\t// If the seed is zero, use real cryptographic randomness. Otherwise, use a\n\t// deterministic randomness source to make generated keys stay the same\n\t// across multiple runs\n\tvar r io.Reader\n\tif randseed == 0 {\n\t\tr = rand.Reader\n\t} else {\n\t\tr = mrand.New(mrand.NewSource(randseed))\n\t}\n\n\t// Generate a key pair for this host. We will use it at least\n\t// to obtain a valid host ID.\n\tpriv, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\topts := []libp2p.Option{\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/127.0.0.1/tcp/%d\", listenPort)),\n\t\tlibp2p.Identity(priv),\n\t\tlibp2p.DisableRelay(),\n\t}\n\n\tif protocolID == plaintext.ID {\n\t\topts = append(opts, libp2p.NoSecurity)\n\t} else if protocolID == noise.ID {\n\t\ttpt, err := noise.New(priv)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\topts = append(opts, libp2p.Security(protocolID, tpt))\n\t} else if protocolID == secio.ID {\n\t\ttpt, err := secio.New(priv)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\topts = append(opts, libp2p.Security(protocolID, tpt))\n\t} else {\n\t\treturn nil, fmt.Errorf(\"security protocolID '%s' is not supported\", protocolID)\n\t}\n\n\tbasicHost, err := libp2p.New(context.Background(), opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Build host multiaddress\n\thostAddr, _ := ma.NewMultiaddr(fmt.Sprintf(\"/ipfs/%s\", basicHost.ID().Pretty()))\n\n\t// Now we can build a full multiaddress to reach this host\n\t// by encapsulating both addresses:\n\taddr := basicHost.Addrs()[0]\n\tfullAddr := addr.Encapsulate(hostAddr)\n\tlog.Printf(\"I am %s\\n\", fullAddr)\n\tlog.Printf(\"Now run \\\"./echo -l %d -d %s -security %s\\\" on a different terminal\\n\", listenPort+1, fullAddr, protocolID)\n\n\treturn basicHost, nil\n}", "func NewBindHostNotImplemented() *BindHostNotImplemented {\n\treturn &BindHostNotImplemented{}\n}", "func NewAdapter(config *aws.Config, ds string) *Adapter {\n\ta := &Adapter{}\n\ta.Config = config\n\ta.DataSourceName = ds\n\ta.Service = dynamodb.New(session.New(config), a.Config)\n\ta.DB = dynamo.New(session.New(), a.Config)\n\treturn a\n}", "func createHostWebSocket(port int) (core.Host, error) {\n\n\t// Starting a peer with QUIC transport\n\topts := []libp2p.Option{\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/0.0.0.0/udp/%d/quic\", port)),\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/0.0.0.0/tcp/%d/ws\", port)),\n\t\tlibp2p.Transport(ws.New),\n\t\tlibp2p.DefaultMuxers,\n\t\tlibp2p.DefaultSecurity,\n\t}\n\n\th, err := libp2p.New(context.Background(), opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn h, nil\n}", "func NewFromIpfsHost(host host.Host, r routing.ContentRouting, opts ...NetOpt) BitSwapNetwork {\n\ts := processSettings(opts...)\n\n\tbitswapNetwork := impl{\n\t\thost: host,\n\t\trouting: r,\n\n\t\tprotocolBitswapNoVers: s.ProtocolPrefix + ProtocolBitswapNoVers,\n\t\tprotocolBitswapOneZero: s.ProtocolPrefix + ProtocolBitswapOneZero,\n\t\tprotocolBitswapOneOne: s.ProtocolPrefix + ProtocolBitswapOneOne,\n\t\tprotocolBitswap: s.ProtocolPrefix + ProtocolBitswap,\n\n\t\tsupportedProtocols: s.SupportedProtocols,\n\t}\n\n\treturn &bitswapNetwork\n}", "func NewMockhost(ctrl *gomock.Controller) *Mockhost {\n\tmock := &Mockhost{ctrl: ctrl}\n\tmock.recorder = &MockhostMockRecorder{mock}\n\treturn mock\n}", "func NewHostN(address string, nodeID core.RecordRef) (*Host, error) {\n\th, err := NewHost(address)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\th.NodeID = nodeID\n\treturn h, nil\n}", "func (s *HostListener) Create(ctx context.Context, in *protocol.HostDefinition) (_ *protocol.Host, err error) {\n\tdefer fail.OnExitConvertToGRPCStatus(&err)\n\tdefer fail.OnExitWrapError(&err, \"cannot create host\")\n\tdefer fail.OnPanic(&err)\n\n\tif s == nil {\n\t\treturn nil, fail.InvalidInstanceError()\n\t}\n\tif in == nil {\n\t\treturn nil, fail.InvalidParameterCannotBeNilError(\"in\")\n\t}\n\tif ctx == nil {\n\t\treturn nil, fail.InvalidParameterCannotBeNilError(\"ctx\")\n\t}\n\n\tif ok, err := govalidator.ValidateStruct(in); err != nil || !ok {\n\t\tlogrus.Warnf(\"Structure validation failure: %v\", in) // FIXME: Generate json tags in protobuf\n\t}\n\n\tname := in.GetName()\n\tjob, xerr := PrepareJob(ctx, in.GetTenantId(), fmt.Sprintf(\"/host/%s/create\", name))\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\tdefer job.Close()\n\n\ttracer := debug.NewTracer(job.Task(), tracing.ShouldTrace(\"listeners.home\"), \"('%s')\", name).WithStopwatch().Entering()\n\tdefer tracer.Exiting()\n\tdefer fail.OnExitLogError(&err, tracer.TraceMessage())\n\n\tvar sizing *abstract.HostSizingRequirements\n\tif in.SizingAsString != \"\" {\n\t\tsizing, _, err = converters.HostSizingRequirementsFromStringToAbstract(in.SizingAsString)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else if in.Sizing != nil {\n\t\tsizing = converters.HostSizingRequirementsFromProtocolToAbstract(in.Sizing)\n\t}\n\tif sizing == nil {\n\t\tsizing = &abstract.HostSizingRequirements{MinGPU: -1}\n\t}\n\n\t// Determine if the Subnet(s) to use exist\n\t// Because of legacy, the subnet can be fully identified by network+subnet, or can be identified by network+network,\n\t// because previous release of SafeScale created network AND subnet with the same name\n\tvar (\n\t\tnetworkRef string\n\t\tsubnetInstance resources.Subnet\n\t\tsubnets []*abstract.Subnet\n\t)\n\tif !in.GetSingle() {\n\t\tnetworkRef = in.GetNetwork()\n\t}\n\tif len(in.GetSubnets()) > 0 {\n\t\tfor _, v := range in.GetSubnets() {\n\t\t\tsubnetInstance, xerr = subnetfactory.Load(job.Service(), networkRef, v)\n\t\t\tif xerr != nil {\n\t\t\t\treturn nil, xerr\n\t\t\t}\n\n\t\t\tdefer func(instance resources.Subnet) { // nolint\n\t\t\t\tinstance.Released()\n\t\t\t}(subnetInstance)\n\n\t\t\txerr = subnetInstance.Review(func(clonable data.Clonable, _ *serialize.JSONProperties) fail.Error {\n\t\t\t\tas, ok := clonable.(*abstract.Subnet)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fail.InconsistentError(\"'*abstract.Subnet' expected, '%s' provided\", reflect.TypeOf(clonable).String())\n\t\t\t\t}\n\n\t\t\t\tsubnets = append(subnets, as)\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tif xerr != nil {\n\t\t\t\treturn nil, xerr\n\t\t\t}\n\t\t}\n\t}\n\tif len(subnets) == 0 && networkRef != \"\" {\n\t\tsubnetInstance, xerr = subnetfactory.Load(job.Service(), networkRef, networkRef)\n\t\tif xerr != nil {\n\t\t\treturn nil, xerr\n\t\t}\n\n\t\tdefer subnetInstance.Released()\n\n\t\txerr = subnetInstance.Review(func(clonable data.Clonable, _ *serialize.JSONProperties) fail.Error {\n\t\t\tas, ok := clonable.(*abstract.Subnet)\n\t\t\tif !ok {\n\t\t\t\treturn fail.InconsistentError(\"'*abstract.Subnet' expected, '%s' provided\", reflect.TypeOf(clonable).String())\n\t\t\t}\n\n\t\t\tsubnets = append(subnets, as)\n\t\t\treturn nil\n\t\t})\n\t\tif xerr != nil {\n\t\t\treturn nil, xerr\n\t\t}\n\t}\n\tif len(subnets) == 0 && !in.GetSingle() {\n\t\treturn nil, fail.InvalidRequestError(\"insufficient use of --network and/or --subnet or missing --single\")\n\t}\n\n\tdomain := in.Domain\n\tdomain = strings.Trim(domain, \".\")\n\tif domain != \"\" {\n\t\tdomain = \".\" + domain\n\t}\n\n\thostReq := abstract.HostRequest{\n\t\tResourceName: name,\n\t\tHostName: name + domain,\n\t\tSingle: in.GetSingle(),\n\t\tKeepOnFailure: in.GetKeepOnFailure(),\n\t\tSubnets: subnets,\n\t\tImageRef: in.GetImageId(),\n\t}\n\n\thostInstance, xerr := hostfactory.New(job.Service())\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\n\t_, xerr = hostInstance.Create(job.Context(), hostReq, *sizing)\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\n\tdefer hostInstance.Released()\n\n\t// logrus.Infof(\"Host '%s' created\", name)\n\treturn hostInstance.ToProtocol()\n}", "func NewHost(uri string) Host {\n\t// no need to decompose uri using net/url package\n\treturn Host{uri: uri, client: http.Client{}}\n}", "func makeBasicHost(listenPort int, secio bool, randseed int64) (host.Host, error) {\n\n\t// If the seed is zero, use real cryptographic randomness. Otherwise, use a\n\t// deterministic randomness source to make generated keys stay the same\n\t// across multiple runs\n\tvar r io.Reader\n\tif randseed == 0 {\n\t\tr = rand.Reader\n\t} else {\n\t\tr = mrand.New(mrand.NewSource(randseed))\n\t}\n\n\t// Generate a key pair for this host. We will use it\n\t// to obtain a valid host ID.\n\tpriv, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\topts := []libp2p.Option{\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/127.0.0.1/tcp/%d\", listenPort)),\n\t\tlibp2p.Identity(priv),\n\t}\n\n\t// if !secio {\n\t// \topts = append(opts, libp2p.NoEncryption())\n\t// }\n\n\tbasicHost, err := libp2p.New(context.Background(), opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Build host multiaddress\n\thostAddr, _ := ma.NewMultiaddr(fmt.Sprintf(\"/ipfs/%s\", basicHost.ID().Pretty()))\n\n\t// Now we can build a full multiaddress to reach this host\n\t// by encapsulating both addresses:\n\taddr := basicHost.Addrs()[0]\n\tfullAddr := addr.Encapsulate(hostAddr)\n\tlog.Printf(\"I am %s\\n\", fullAddr)\n\tif secio {\n\t\tlog.Printf(\"Now run \\\"go run main.go -l %d -d %s -secio\\\" on a different terminal\\n\", listenPort+1, fullAddr)\n\t} else {\n\t\tlog.Printf(\"Now run \\\"go run main.go -l %d -d %s\\\" on a different terminal\\n\", listenPort+1, fullAddr)\n\t}\n\n\treturn basicHost, nil\n}", "func resourceHostCreate(d *schema.ResourceData, m interface{}) error {\n\tapi := m.(*zabbix.API)\n\n\titem, err := buildHostObject(d, m)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\titems := []zabbix.Host{*item}\n\n\terr = api.HostsCreate(items)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Trace(\"created host: %+v\", items[0])\n\n\td.SetId(items[0].HostID)\n\n\treturn resourceHostRead(d, m)\n}", "func createBaremetalHost() *metal3api.BareMetalHost {\n\n\tbmh := &metal3api.BareMetalHost{}\n\tbmh.ObjectMeta = metav1.ObjectMeta{Name: hostName, Namespace: hostNamespace}\n\tc := fakeclient.NewFakeClient(bmh)\n\n\treconciler := &BareMetalHostReconciler{\n\t\tClient: c,\n\t\tProvisionerFactory: nil,\n\t\tLog: ctrl.Log.WithName(\"bmh_reconciler\").WithName(\"BareMetalHost\"),\n\t}\n\n\treconciler.Create(context.TODO(), bmh)\n\n\treturn bmh\n}", "func NewBindHostUnauthorized() *BindHostUnauthorized {\n\treturn &BindHostUnauthorized{}\n}", "func (h *HostService) CreateHost(data map[string]interface{}, params map[string]string) (*Host, error) {\n\tmandatoryFields = []string{\"name\", \"inventory\"}\n\tvalidate, status := ValidateParams(data, mandatoryFields)\n\n\tif !status {\n\t\terr := fmt.Errorf(\"Mandatory input arguments are absent: %s\", validate)\n\t\treturn nil, err\n\t}\n\n\tresult := new(Host)\n\tpayload, err := json.Marshal(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add check if Host exists and return proper error\n\n\tresp, err := h.client.Requester.PostJSON(hostsAPIEndpoint, bytes.NewReader(payload), result, params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := CheckResponse(resp); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn result, nil\n}", "func (h Hostingv4) CreatePrivateIP(vlan hosting.Vlan, ip string) (hosting.IPAddress, error) {\n\tvar fn = \"CreatePrivateIP\"\n\tif vlan.RegionID == \"\" || vlan.ID == \"\" {\n\t\treturn hosting.IPAddress{}, &HostingError{fn, \"Vlan\", \"ID/RegionID\", ErrNotProvided}\n\t}\n\tregionid, err := strconv.Atoi(vlan.RegionID)\n\tif err != nil {\n\t\treturn hosting.IPAddress{}, &HostingError{fn, \"Vlan\", \"RegionID\", ErrParse}\n\t}\n\tvlanid, err := strconv.Atoi(vlan.ID)\n\tif err != nil {\n\t\treturn hosting.IPAddress{}, &HostingError{fn, \"Vlan\", \"ID\", ErrParse}\n\t}\n\n\tvar ipv4 iPAddressv4\n\tvar response = Operation{}\n\terr = h.Send(\"hosting.iface.create\", []interface{}{\n\t\tmap[string]interface{}{\n\t\t\t\"datacenter_id\": regionid,\n\t\t\t\"bandwidth\": hosting.DefaultBandwidth,\n\t\t\t\"ip\": ip,\n\t\t\t\"vlan\": vlanid,\n\t\t}}, &response)\n\tif err != nil {\n\t\treturn hosting.IPAddress{}, err\n\t}\n\tif err = h.waitForOp(response); err != nil {\n\t\treturn hosting.IPAddress{}, err\n\t}\n\n\tif err = h.Send(\"hosting.ip.info\", []interface{}{response.IPID}, &ipv4); err != nil {\n\t\treturn hosting.IPAddress{}, err\n\t}\n\n\treturn toIPAddress(ipv4), nil\n}", "func NewAdapter(fs http.FileSystem, path string) *Adapter {\n\treturn &Adapter{fs, path}\n}", "func NewHwAdapter(hw *hw.HwRoot) HwAdapter {\n\treturn HwAdapter{hw.GetServicePort(), mykafka.NewWriter(mykafka.HwClient, mykafka.TunerTopic)}\n}", "func NewAdapter(text string) *Adapter {\n\treturn &Adapter{text: text}\n}", "func (account *SCloudaccount) createNetwork(ctx context.Context, wireId, networkType string, net CANetConf) error {\n\tnetwork := &SNetwork{}\n\tnetwork.Name = net.Name\n\tif hint, err := NetworkManager.NewIfnameHint(net.Name); err != nil {\n\t\tlog.Errorf(\"can't NewIfnameHint form hint %s\", net.Name)\n\t} else {\n\t\tnetwork.IfnameHint = hint\n\t}\n\tnetwork.GuestIpStart = net.IpStart\n\tnetwork.GuestIpEnd = net.IpEnd\n\tnetwork.GuestIpMask = net.IpMask\n\tnetwork.GuestGateway = net.Gateway\n\tnetwork.VlanId = int(net.VlanID)\n\tnetwork.WireId = wireId\n\tnetwork.ServerType = networkType\n\tnetwork.IsPublic = true\n\tnetwork.Status = api.NETWORK_STATUS_AVAILABLE\n\tnetwork.PublicScope = string(rbacscope.ScopeDomain)\n\tnetwork.ProjectId = account.ProjectId\n\tnetwork.DomainId = account.DomainId\n\tnetwork.Description = net.Description\n\n\tnetwork.SetModelManager(NetworkManager, network)\n\t// TODO: Prevent IP conflict\n\tlog.Infof(\"create network %s succussfully\", network.Id)\n\terr := NetworkManager.TableSpec().Insert(ctx, network)\n\treturn err\n}", "func createSingleHostNetworking(ctx context.Context, svc iaas.Service, singleHostRequest abstract.HostRequest) (_ resources.Subnet, _ func() fail.Error, ferr fail.Error) {\n\t// Build network name\n\tcfg, xerr := svc.GetConfigurationOptions(ctx)\n\tif xerr != nil {\n\t\treturn nil, nil, xerr\n\t}\n\n\tbucketName := cfg.GetString(\"MetadataBucketName\")\n\tif bucketName == \"\" {\n\t\treturn nil, nil, fail.InconsistentError(\"missing service configuration option 'MetadataBucketName'\")\n\t}\n\n\t// Trim and TrimPrefix don't do the same thing\n\tnetworkName := fmt.Sprintf(\"sfnet-%s\", strings.TrimPrefix(bucketName, objectstorage.BucketNamePrefix+\"-\"))\n\n\t// Create network if needed\n\tnetworkInstance, xerr := LoadNetwork(ctx, svc, networkName)\n\tif xerr != nil {\n\t\tswitch xerr.(type) {\n\t\tcase *fail.ErrNotFound:\n\t\t\tnetworkInstance, xerr = NewNetwork(svc)\n\t\t\tif xerr != nil {\n\t\t\t\treturn nil, nil, xerr\n\t\t\t}\n\n\t\t\trequest := abstract.NetworkRequest{\n\t\t\t\tName: networkName,\n\t\t\t\tCIDR: abstract.SingleHostNetworkCIDR,\n\t\t\t\tKeepOnFailure: true,\n\t\t\t}\n\t\t\txerr = networkInstance.Create(ctx, &request, nil)\n\t\t\tif xerr != nil {\n\t\t\t\t// handle a particular case of *fail.ErrDuplicate...\n\t\t\t\tswitch cerr := xerr.(type) {\n\t\t\t\tcase *fail.ErrDuplicate:\n\t\t\t\t\tvalue, found := cerr.Annotation(\"managed\")\n\t\t\t\t\tif found && value != nil {\n\t\t\t\t\t\tmanaged, ok := value.(bool)\n\t\t\t\t\t\tif ok && !managed {\n\t\t\t\t\t\t\treturn nil, nil, xerr\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t}\n\t\t\t\t// ... otherwise, try to get Network that is created by another goroutine\n\t\t\t\tswitch xerr.(type) {\n\t\t\t\tcase *fail.ErrDuplicate, *fail.ErrNotAvailable:\n\t\t\t\t\t// If these errors occurred, another goroutine is running to create the same Network, so wait for it\n\t\t\t\t\tnetworkInstance, xerr = LoadNetwork(ctx, svc, networkName)\n\t\t\t\t\tif xerr != nil {\n\t\t\t\t\t\treturn nil, nil, xerr\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, nil, xerr\n\t\t\t\t}\n\t\t\t}\n\t\tdefault:\n\t\t\treturn nil, nil, xerr\n\t\t}\n\t}\n\n\tnid, err := networkInstance.GetID()\n\tif err != nil {\n\t\treturn nil, nil, fail.ConvertError(err)\n\t}\n\n\t// Check if Subnet exists\n\tvar (\n\t\tsubnetRequest abstract.SubnetRequest\n\t\tcidrIndex uint\n\t)\n\tsubnetInstance, xerr := LoadSubnet(ctx, svc, nid, singleHostRequest.ResourceName)\n\tif xerr != nil {\n\t\tswitch xerr.(type) {\n\t\tcase *fail.ErrNotFound:\n\t\t\tsubnetInstance, xerr = NewSubnet(svc)\n\t\t\tif xerr != nil {\n\t\t\t\treturn nil, nil, xerr\n\t\t\t}\n\n\t\t\tvar (\n\t\t\t\tsubnetCIDR string\n\t\t\t)\n\n\t\t\tsubnetCIDR, cidrIndex, xerr = ReserveCIDRForSingleHost(ctx, networkInstance)\n\t\t\txerr = debug.InjectPlannedFail(xerr)\n\t\t\tif xerr != nil {\n\t\t\t\treturn nil, nil, xerr\n\t\t\t}\n\n\t\t\tvar dnsServers []string\n\t\t\topts, xerr := svc.GetConfigurationOptions(ctx)\n\t\t\txerr = debug.InjectPlannedFail(xerr)\n\t\t\tif xerr != nil {\n\t\t\t\tswitch xerr.(type) {\n\t\t\t\tcase *fail.ErrNotFound:\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, nil, xerr\n\t\t\t\t}\n\t\t\t} else if servers := strings.TrimSpace(opts.GetString(\"DNSServers\")); servers != \"\" {\n\t\t\t\tdnsServers = strings.Split(servers, \",\")\n\t\t\t}\n\n\t\t\tsubnetRequest.Name = singleHostRequest.ResourceName\n\t\t\tsubnetRequest.NetworkID, err = networkInstance.GetID()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, nil, fail.ConvertError(err)\n\t\t\t}\n\t\t\tsubnetRequest.IPVersion = ipversion.IPv4\n\t\t\tsubnetRequest.CIDR = subnetCIDR\n\t\t\tsubnetRequest.DNSServers = dnsServers\n\t\t\tsubnetRequest.HA = false\n\n\t\t\txerr = subnetInstance.CreateSubnetWithoutGateway(ctx, subnetRequest)\n\t\t\txerr = debug.InjectPlannedFail(xerr)\n\t\t\tif xerr != nil {\n\t\t\t\treturn nil, nil, xerr\n\t\t\t}\n\n\t\t\tdefer func() {\n\t\t\t\tferr = debug.InjectPlannedFail(ferr)\n\t\t\t\tif ferr != nil && !singleHostRequest.KeepOnFailure {\n\t\t\t\t\tderr := subnetInstance.Delete(cleanupContextFrom(ctx))\n\t\t\t\t\tif derr != nil {\n\t\t\t\t\t\t_ = ferr.AddConsequence(\n\t\t\t\t\t\t\tfail.Wrap(\n\t\t\t\t\t\t\t\tderr, \"cleaning up on failure, failed to delete Subnet '%s'\",\n\t\t\t\t\t\t\t\tsingleHostRequest.ResourceName,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\t// Sets the CIDR index in instance metadata\n\t\t\txerr = subnetInstance.Alter(ctx, func(clonable data.Clonable, _ *serialize.JSONProperties) fail.Error {\n\t\t\t\tas, ok := clonable.(*abstract.Subnet)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fail.InconsistentError(\n\t\t\t\t\t\t\"'*abstract.Subnet' expected, '%s' provided\", reflect.TypeOf(clonable).String(),\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\tas.SingleHostCIDRIndex = cidrIndex\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tif xerr != nil {\n\t\t\t\treturn nil, nil, xerr\n\t\t\t}\n\t\tdefault:\n\t\t\treturn nil, nil, xerr\n\t\t}\n\t} else {\n\t\treturn nil, nil, fail.DuplicateError(\"there is already a Subnet named '%s'\", singleHostRequest.ResourceName)\n\t}\n\n\tundoFunc := func() fail.Error {\n\t\tvar errs []error\n\t\tif !singleHostRequest.KeepOnFailure {\n\t\t\tderr := subnetInstance.Delete(cleanupContextFrom(ctx))\n\t\t\tif derr != nil {\n\t\t\t\terrs = append(\n\t\t\t\t\terrs, fail.Wrap(\n\t\t\t\t\t\tderr, \"cleaning up on failure, failed to delete Subnet '%s'\", singleHostRequest.ResourceName,\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t}\n\t\t\tderr = FreeCIDRForSingleHost(cleanupContextFrom(ctx), networkInstance, cidrIndex)\n\t\t\tif derr != nil {\n\t\t\t\terrs = append(\n\t\t\t\t\terrs, fail.Wrap(\n\t\t\t\t\t\tderr, \"cleaning up on failure, failed to free CIDR slot in Network '%s'\",\n\t\t\t\t\t\tnetworkInstance.GetName(),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif len(errs) > 0 {\n\t\t\treturn fail.NewErrorList(errs)\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn subnetInstance, undoFunc, nil\n}", "func NewGetAdapterHostEthInterfacesDefault(code int) *GetAdapterHostEthInterfacesDefault {\n\treturn &GetAdapterHostEthInterfacesDefault{\n\t\t_statusCode: code,\n\t}\n}", "func (FinagleFmt) Create(host string, port int) ZKRecord {\n\treturn &FinagleRecord{\n\t\tServiceEndpoint: endpoint{host, port},\n\t\tAdditionalEndpoints: make(map[string]endpoint),\n\t\tShard: 0,\n\t\tStatus: statusAlive,\n\t}\n}", "func HostOnly(addr string) string {\n\thost, _, err := net.SplitHostPort(addr)\n\tif err != nil {\n\t\treturn addr\n\t} else {\n\t\treturn host\n\t}\n}", "func NewHostNetworkMock(t minimock.Tester) *HostNetworkMock {\n\tm := &HostNetworkMock{t: t}\n\n\tif controller, ok := t.(minimock.MockController); ok {\n\t\tcontroller.RegisterMocker(m)\n\t}\n\n\tm.BuildResponseMock = mHostNetworkMockBuildResponse{mock: m}\n\tm.GetNodeIDMock = mHostNetworkMockGetNodeID{mock: m}\n\tm.NewRequestBuilderMock = mHostNetworkMockNewRequestBuilder{mock: m}\n\tm.PublicAddressMock = mHostNetworkMockPublicAddress{mock: m}\n\tm.RegisterRequestHandlerMock = mHostNetworkMockRegisterRequestHandler{mock: m}\n\tm.SendRequestMock = mHostNetworkMockSendRequest{mock: m}\n\tm.StartMock = mHostNetworkMockStart{mock: m}\n\tm.StopMock = mHostNetworkMockStop{mock: m}\n\n\treturn m\n}", "func NewAdapter(cfg Config) (AdapterInterface, error) {\n\n\terr := validateCfg(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ta := &Adapter{\n\t\tcfg: cfg,\n\t}\n\n\terr = a.initLogFile()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn a, nil\n}", "func makeRandomHost() (host.Host, *kaddht.IpfsDHT) {\n\tctx := context.Background()\n\tport := 10000 + rand.Intn(10000)\n\n\thost, err := libp2p.New(ctx,\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/0.0.0.0/tcp/%d\", port)),\n\t\tlibp2p.EnableRelay(circuit.OptHop, circuit.OptDiscovery))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Bootstrap the DHT. In the default configuration, this spawns a Background\n\t// thread that will refresh the peer table every five minutes.\n\tdht, err := kaddht.New(ctx, host)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\terr = dht.Bootstrap(ctx)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn host, dht\n}", "func NewDisableHostUnauthorized() *DisableHostUnauthorized {\n\treturn &DisableHostUnauthorized{}\n}", "func makeBasicHostZLH(listenPort int, secio bool, randseed int64) (host.Host, error) {\n\t// If the seed is zero, use real cryptographic randomness. Otherwise, use a\n\t// deterministic randomness source to make generated keys stay the same\n\t// across multiple runs\n\tvar r io.Reader\n\tif randseed == 0 {\n\t\tr = rand.Reader\n\t} else {\n\t\tr = mrand.New(mrand.NewSource(randseed))\n\t}\n\n\t// Generate a key pair for this host. We will use it\n\t// to obtain a valid host ID.\n\tpriv, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\topts := []libp2p.Option{\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/127.0.0.1/tcp/%d\", listenPort)),\n\t\tlibp2p.Identity(priv),\n\t}\n\n\tbasicHost, err := libp2p.New(context.Background(), opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Build host multiaddress\n\thostAddr, _ := multiaddr.NewMultiaddr(fmt.Sprintf(\"/ipfs/%s\", basicHost.ID().Pretty()))\n\n\t// Now we can build a full miltiaddress to reach this host by encapsulation both addresses:\n\taddr := basicHost.Addrs()[0]\n\tfullAddr := addr.Encapsulate(hostAddr)\n\tlog.Printf(\"I am %s\\n\", fullAddr)\n\tif secio {\n\t\tlog.Printf(\"Now run \\\"go run main.go -l %d -d %s -secio\\\" on a different terminal\\n\", listenPort+1, fullAddr)\n\t} else {\n\t\tlog.Printf(\"Now run \\\"go run main.go -l %d -d %s \\\" on a different terminal\\n\", listenPort+1, fullAddr)\n\t}\n\treturn basicHost, nil\n}", "func (d *Driver) createNetworks() error {\n\tif err := d.createNetwork(\"default\", defaultNetworkTmpl); err != nil {\n\t\treturn errors.Wrap(err, \"creating default network\")\n\t}\n\tif err := d.createNetwork(d.NetworkName, privateNetworkTmpl); err != nil {\n\t\treturn errors.Wrap(err, \"creating private network\")\n\t}\n\n\treturn nil\n}", "func (d *Driver) CreateNetwork(r *sdk.CreateNetworkRequest) error {\n\tvar netCidr *net.IPNet\n\tvar netGw string\n\tvar err error\n\tlog.Debugf(\"Network Create Called: [ %+v ]\", r)\n\tfor _, v4 := range r.IPv4Data {\n\t\tnetGw = v4.Gateway\n\t\t_, netCidr, err = net.ParseCIDR(v4.Pool)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Parse and validate the config. It should not be conflict with existing networks' config\n\tconfig, err := parseNetworkOptions(r.NetworkID, r.Options)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Generate a name for what will be the sandbox side pipe interface\n\tcontainerIfName, err := d.getContainerIfName(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\tlog.Debugf(\"containerIfName:%v\", containerIfName)\n\tconfig.ContainerIfName = containerIfName\n\n\tn := &network{\n\t\tid: r.NetworkID,\n\t\tconfig: config,\n\t\tendpoints: endpointTable{},\n\t\tcidr: netCidr,\n\t\tgateway: netGw,\n\t}\n\n\tbName, err := getBridgeName(r)\n\tconfig.BridgeName = bName\n\tlog.Debugf(\"bridgeName:%v\", bName)\n\n\t// Initialize handle when needed\n\td.Lock()\n\tif d.nlh == nil {\n\t\td.nlh = NlHandle()\n\t}\n\td.Unlock()\n\n\t// Create or retrieve the bridge L3 interface\n\tbridgeIface, err := newInterface(d.nlh, bName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tn.bridge = bridgeIface\n\tsetupDevice(bridgeIface)\n\tsetupDeviceUp(config, bridgeIface)\n\n\td.addNetwork(n)\n\treturn nil\n}", "func NewHostNode(ctx context.Context, config Config, blockchain chain.Blockchain) (HostNode, error) {\n\tps := pstoremem.NewPeerstore()\n\tdb, err := NewDatabase(config.Path)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = db.Initialize()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpriv, err := db.GetPrivKey()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// get saved hostnode\n\tsavedAddresses, err := db.GetSavedPeers()\n\tif err != nil {\n\t\tconfig.Log.Errorf(\"error retrieving saved hostnode: %s\", err)\n\t}\n\n\tnetAddr, err := net.ResolveTCPAddr(\"tcp\", \"0.0.0.0:\"+config.Port)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlisten, err := mnet.FromNetAddr(netAddr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tlistenAddress := []multiaddr.Multiaddr{listen}\n\n\t//append saved addresses\n\tlistenAddress = append(listenAddress, savedAddresses...)\n\n\th, err := libp2p.New(\n\t\tctx,\n\t\tlibp2p.ListenAddrs(listenAddress...),\n\t\tlibp2p.Identity(priv),\n\t\tlibp2p.EnableRelay(),\n\t\tlibp2p.Peerstore(ps),\n\t)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\taddrs, err := peer.AddrInfoToP2pAddrs(&peer.AddrInfo{\n\t\tID: h.ID(),\n\t\tAddrs: listenAddress,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, a := range addrs {\n\t\tconfig.Log.Infof(\"binding to address: %s\", a)\n\t}\n\n\t// setup gossip sub protocol\n\tg, err := pubsub.NewGossipSub(ctx, h)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnode := &hostNode{\n\t\tprivateKey: config.PrivateKey,\n\t\thost: h,\n\t\tgossipSub: g,\n\t\tctx: ctx,\n\t\ttimeoutInterval: timeoutInterval,\n\t\theartbeatInterval: heartbeatInterval,\n\t\tlog: config.Log,\n\t\ttopics: map[string]*pubsub.Topic{},\n\t\tdb: db,\n\t}\n\n\tdiscovery, err := NewDiscoveryProtocol(ctx, node, config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnode.discoveryProtocol = discovery\n\n\tsyncProtocol, err := NewSyncProtocol(ctx, node, config, blockchain)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnode.syncProtocol = syncProtocol\n\n\treturn node, nil\n}", "func NewHostNS(address string, nodeID core.RecordRef, shortID core.ShortNodeID) (*Host, error) {\n\th, err := NewHostN(address, nodeID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\th.ShortID = shortID\n\treturn h, nil\n}", "func New(address string, port int) *Host {\n\thost := Host{\n\t\taddress: address,\n\t\tport: port,\n\t}\n\treturn &host\n}", "func (d *Driver) CreateNetwork(r *pluginNet.CreateNetworkRequest) error {\n\tdefer osl.InitOSContext()()\n\n\tid := r.NetworkID\n\topts := r.Options\n\tipV4Data := r.IPv4Data\n\tipV6Data := r.IPv6Data\n\tlogrus.Infof(\"CreateNetwork macvlan with networkID=%s,opts=%s\", id, opts)\n\n\tif id == \"\" {\n\t\treturn fmt.Errorf(\"invalid network id\")\n\t}\n\n\t// reject a null v4 network\n\tif len(ipV4Data) == 0 || ipV4Data[0].Pool == \"0.0.0.0/0\" {\n\t\treturn fmt.Errorf(\"ipv4 pool is empty\")\n\t}\n\n\t// parse and validate the config and bind to networkConfiguration\n\tconfig, err := parseNetworkOptions(id, opts)\n\tif err != nil {\n\t\tstr := fmt.Sprintf(\"CreateNetwork opts is invalid %s\", opts)\n\t\tlogrus.Errorf(str)\n\t\treturn fmt.Errorf(str)\n\t}\n\n\tconfig.ID = id\n\terr = config.processIPAM(id, ipV4Data, ipV6Data)\n\tif err != nil {\n\t\tstr := fmt.Sprintf(\"CreateNetwork ipV4Data is invalid %s\", ipV4Data)\n\t\tlogrus.Errorf(str)\n\t\treturn fmt.Errorf(str)\n\t}\n\t// verify the macvlan mode from -o macvlan_mode option\n\tswitch config.MacvlanMode {\n\tcase \"\", modeBridge:\n\t\t// default to macvlan bridge mode if -o macvlan_mode is empty\n\t\tconfig.MacvlanMode = modeBridge\n\tcase modePrivate:\n\t\tconfig.MacvlanMode = modePrivate\n\tcase modePassthru:\n\t\tconfig.MacvlanMode = modePassthru\n\tcase modeVepa:\n\t\tconfig.MacvlanMode = modeVepa\n\tdefault:\n\t\tstr := fmt.Sprintf(\"requested macvlan mode '%s' is not valid, 'bridge' mode is the macvlan driver default\", config.MacvlanMode)\n\t\tlogrus.Errorf(str)\n\t\treturn fmt.Errorf(str)\n\t}\n\t// loopback is not a valid parent link\n\tif config.Parent == \"lo\" {\n\t\tstr := fmt.Sprintf(\"loopback interface is not a valid %s parent link\", macvlanType)\n\t\tlogrus.Errorf(str)\n\t\treturn fmt.Errorf(str)\n\t}\n\t// if parent interface not specified, create a dummy type link to use named dummy+net_id\n\tif config.Parent == \"\" {\n\t\tconfig.Parent = getDummyName(stringid.TruncateID(config.ID))\n\t\t// empty parent and --internal are handled the same. Set here to update k/v\n\t\tconfig.Internal = true\n\t}\n\n\terr = d.createNetwork(config)\n\tif err != nil {\n\t\tstr := fmt.Sprintf(\"CreateNetwork is failed %v\", err)\n\t\tlogrus.Errorf(str)\n\t\treturn fmt.Errorf(str)\n\t}\n\n\treturn nil\n}", "func NewHostDiscovery() HostDiscovery {\n\treturn &hostDiscovery{}\n}", "func createVhostUserEndpoint(netInfo NetworkInfo, socket string) (*VhostUserEndpoint, error) {\n\n\tvhostUserEndpoint := &VhostUserEndpoint{\n\t\tSocketPath: socket,\n\t\tHardAddr: netInfo.Iface.HardwareAddr.String(),\n\t\tIfaceName: netInfo.Iface.Name,\n\t\tEndpointType: VhostUserEndpointType,\n\t}\n\treturn vhostUserEndpoint, nil\n}", "func NewDinnerHostPtr(tableCount, maxParallel, maxDinner int) *DinnerHost {\n\thost := new(DinnerHost)\n\thost.Init(tableCount, maxParallel, maxDinner)\n\treturn host\n}", "func networkCreateExample() string {\n\treturn `$ pouch network create -n pouchnet -d bridge --gateway 192.168.1.1 --subnet 192.168.1.0/24\npouchnet: e1d541722d68dc5d133cca9e7bd8fd9338603e1763096c8e853522b60d11f7b9`\n}", "func NewAdapter() Adapter {\n\tbuilder := NewBuilder()\n\treturn createAdapter(builder)\n}", "func newAdapter(config *AdapterConfig) (adapters.ListChecker, error) {\n\tvar u *url.URL\n\tvar err error\n\tif u, err = url.Parse(config.ProviderURL); err != nil {\n\t\t// bogus URL format\n\t\treturn nil, err\n\t}\n\n\ta := adapter{\n\t\tbackend: u,\n\t\tclosing: make(chan bool),\n\t\trefreshInterval: config.RefreshInterval,\n\t\tttl: config.TimeToLive,\n\t}\n\n\t// install an empty list\n\ta.setList([]*net.IPNet{})\n\n\t// load up the list synchronously so we're ready to accept traffic immediately\n\ta.refreshList()\n\n\t// crank up the async list refresher\n\tgo a.listRefresher()\n\n\treturn &a, nil\n}", "func makeBasicHost(listenPort int, secio bool, randseed int64) { //(host.Host, error) {\n\n\t// If the seed is zero, use real cryptographic randomness. Otherwise, use a\n\t// deterministic randomness source to make generated keys stay the same\n\t// across multiple runs\n\tvar r io.Reader\n\tif randseed == 0 {\n\t\tr = rand.Reader\n\t} else {\n\t\tr = mrand.New(mrand.NewSource(randseed))\n\t}\n\tif *verbose { log.Printf(\"r = \", r) }\n\n\t// Generate a key pair for this host. We will use it\n\t// to obtain a valid host ID.\n\tpriv, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, r)\n\tif err != nil {\n\t\t//return nil, err\n\t\tlog.Fatal(err)\n\t}\n\tif *verbose { log.Printf(\"priv = \", priv) }\n\n\topts := []libp2p.Option{\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/\"+GetMyIP()+\"/tcp/%d\", listenPort)),\n\t\tlibp2p.Identity(priv),\n\t}\n\tif *verbose { log.Printf(\"opts = \", opts) }\n\n\tbasicHost, err := libp2p.New(context.Background(), opts...)\n\tif err != nil {\n\t\t//return nil, err\n\t\tlog.Fatal(err)\n\t}\n\tif *verbose {\n\t\tlog.Printf(\"basicHost = \", basicHost)\n\t\tlog.Printf(\"basicHost.ID() = \", basicHost.ID())\n\t\tlog.Printf(\"basicHost.ID().Pretty() = \", basicHost.ID().Pretty())\n\t}\n\n\t// Build host multiaddress\n\thostAddr, _ := ma.NewMultiaddr(fmt.Sprintf(\"/ipfs/%s\", basicHost.ID().Pretty()))\n\tif *verbose { log.Printf(\"hostAddr = \", hostAddr) }\n\n\t// Now we can build a full multiaddress to reach this host\n\t// by encapsulating both addresses:\n\taddr := basicHost.Addrs()[0]\n\tif *verbose { log.Printf(\"addr = \", addr) }\n\tfullAddr := addr.Encapsulate(hostAddr)\n\tlog.Printf(\"My fullAddr = %s\\n\", fullAddr)\n\tif secio {\n\t\tlog.Printf(\"Now run \\\"go run defs.go p2p.go mux.go blockchain.go main.go -l %d -d %s -secio\\\" on a different terminal\\n\", listenPort+1, fullAddr)\n\t} else {\n\t\tlog.Printf(\"Now run \\\"go run defs.go p2p.go mux.go blockchain.go main.go -l %d -d %s\\\" on a different terminal\\n\", listenPort+1, fullAddr)\n\t}\n\n\t//return basicHost, nil\n\tha = basicHost // ha defined in defs.go\n\tif *verbose { log.Printf(\"basicHost = \", ha) }\n}", "func createHostQUIC(port int) (core.Host, error) {\n\t// Producing private key\n\tpriv, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, rand.Reader)\n\n\tquicTransport, err := quic.NewTransport(priv, nil, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Starting a peer with QUIC transport\n\topts := []libp2p.Option{\n\t\tlibp2p.ListenAddrStrings(fmt.Sprintf(\"/ip4/0.0.0.0/udp/%d/quic\", port)),\n\t\tlibp2p.Transport(quicTransport),\n\t\tlibp2p.Identity(priv),\n\t\tlibp2p.DefaultMuxers,\n\t\tlibp2p.DefaultSecurity,\n\t}\n\n\th, err := libp2p.New(context.Background(), opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn h, nil\n}", "func CreateDefaultExtNetwork(networkType string) error {\n\treturn fmt.Errorf(\"CreateDefaultExtNetwork shouldn't be called for linux platform\")\n}", "func setupHost(ctx context.Context) (host.Host, *dht.IpfsDHT) {\n\t// Set up the host identity options\n\tprvkey, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, rand.Reader)\n\tidentity := libp2p.Identity(prvkey)\n\t// Handle any potential error\n\tif err != nil {\n\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Fatalln(\"Failed to Generate P2P Identity Configuration!\")\n\t}\n\n\t// Trace log\n\tlogrus.Traceln(\"Generated P2P Identity Configuration.\")\n\n\t// Set up TCP, QUIC transport and options\n\ttlstransport, err := tls.New(prvkey)\n\tsecurity := libp2p.Security(tls.ID, tlstransport)\n\ttcpTransport := libp2p.Transport(tcp.NewTCPTransport)\n\tquicTransport := libp2p.Transport(libp2pquic.NewTransport)\n\t// Handle any potential error\n\tif err != nil {\n\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Fatalln(\"Failed to Generate P2P Security and Transport Configurations!\")\n\t}\n\n\t// Trace log\n\tlogrus.Traceln(\"Generated P2P Security and Transport Configurations.\")\n\n\t// Set up host listener address options\n\ttcpMuladdr4, err := multiaddr.NewMultiaddr(\"/ip4/0.0.0.0/tcp/0\")\n\ttcpMuladdr6, err1 := multiaddr.NewMultiaddr(\"/ip6/::/tcp/0\")\n\tquicMuladdr4, err2 := multiaddr.NewMultiaddr(\"/ip4/0.0.0.0/udp/0/quic\")\n\tquicMuladdr6, err3 := multiaddr.NewMultiaddr(\"/ip6/::/udp/0/quic\")\n\tlisten := libp2p.ListenAddrs(quicMuladdr6, quicMuladdr4, tcpMuladdr6, tcpMuladdr4)\n\t// Handle any potential error\n\tcheckErr(err)\n\tcheckErr(err1)\n\tcheckErr(err2)\n\tcheckErr(err3)\n\n\t// Trace log\n\tlogrus.Traceln(\"Generated P2P Address Listener Configuration.\")\n\n\t// Set up the stream multiplexer and connection manager options\n\tmuxer := libp2p.Muxer(\"/yamux/1.0.0\", yamux.DefaultTransport)\n\tconn := libp2p.ConnectionManager(connmgr.NewConnManager(100, 400, time.Minute))\n\n\t// Trace log\n\tlogrus.Traceln(\"Generated P2P Stream Multiplexer, Connection Manager Configurations.\")\n\n\t// Setup NAT traversal and relay options\n\tnat := libp2p.NATPortMap()\n\trelay := libp2p.EnableAutoRelay()\n\n\t// Trace log\n\tlogrus.Traceln(\"Generated P2P NAT Traversal and Relay Configurations.\")\n\n\t// Declare a KadDHT\n\tvar kaddht *dht.IpfsDHT\n\t// Setup a routing configuration with the KadDHT\n\trouting := libp2p.Routing(func(h host.Host) (routing.PeerRouting, error) {\n\t\tkaddht = setupKadDHT(ctx, h)\n\t\treturn kaddht, err\n\t})\n\n\t// Trace log\n\tlogrus.Traceln(\"Generated P2P Routing Configurations.\")\n\n\topts := libp2p.ChainOptions(identity, listen, security, tcpTransport, quicTransport, muxer, conn, nat, routing, relay)\n\n\t// Construct a new libP2P host with the created options\n\tlibhost, err := libp2p.New(ctx, opts)\n\t// Handle any potential error\n\tif err != nil {\n\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Fatalln(\"Failed to Create the P2P Host!\")\n\t}\n\n\t// Return the created host and the kademlia DHT\n\treturn libhost, kaddht\n}", "func ConfigHostNew() *ConfigHost {\n\th := ConfigHost{\n\t\tTLS: regclient.TLSEnabled,\n\t}\n\treturn &h\n}", "func RequireHostHeader(allowed []string, h *render.Renderer, stripPort bool) mux.MiddlewareFunc {\n\twant := make(map[string]struct{}, len(allowed))\n\tfor _, v := range allowed {\n\t\twant[strings.ToLower(v)] = struct{}{}\n\t}\n\n\treturn func(next http.Handler) http.Handler {\n\t\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\thost := strings.ToLower(r.Host)\n\n\t\t\tif stripPort {\n\t\t\t\tif i := strings.Index(host, \":\"); i > 0 {\n\t\t\t\t\thost = host[0:i]\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif _, ok := want[host]; !ok {\n\t\t\t\tcontroller.Unauthorized(w, r, h)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tnext.ServeHTTP(w, r)\n\t\t})\n\t}\n}", "func (c *Client) MakeHost(pk ci.PrivKey, opts *HostOpts) error {\n\thost, err := makeHost(pk, opts, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\tc.Host = host\n\treturn nil\n}", "func (client WorkloadNetworksClient) CreateDhcpResponder(resp *http.Response) (result WorkloadNetworkDhcp, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func AddHost(name, addr string) (*Host, error) {\n\t// Create a network namespace\n\th, err := NewHost(name)\n\tif err != nil {\n\t\tlog.Fatal(\"failed to NewHost: \", err)\n\t}\n\t// setup a veth pair\n\t_, err = h.setupVeth(\"eth2\", 1500)\n\tif err != nil {\n\t\tlog.Fatal(\"failed to open netns: \", err)\n\t}\n\t// setup a IP for host\n\th.setIfaceIP(addr)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to setIfaceIP for %s: %v\", h.Name, err)\n\t\treturn nil, err\n\t}\n\treturn h, nil\n}", "func (data *DNSData) AddNetworkAdapter(name string, networkAdapter compute.VirtualMachineNetworkAdapter) {\n\tif networkAdapter.PrivateIPv4Address != nil {\n\t\tdata.Add(name,\n\t\t\tnet.ParseIP(*networkAdapter.PrivateIPv4Address),\n\t\t)\n\t}\n\tif networkAdapter.PrivateIPv6Address != nil {\n\t\tdata.Add(name,\n\t\t\tnet.ParseIP(*networkAdapter.PrivateIPv6Address),\n\t\t)\n\t}\n}" ]
[ "0.5605203", "0.5528005", "0.5470935", "0.54345465", "0.5420929", "0.53596747", "0.53540576", "0.5293824", "0.52900076", "0.52677083", "0.52036476", "0.52007806", "0.5181415", "0.5149478", "0.5139053", "0.511084", "0.5104876", "0.5074306", "0.50325537", "0.5014431", "0.49915975", "0.49881247", "0.4966575", "0.49329117", "0.49076483", "0.49035245", "0.48922315", "0.48681793", "0.48655298", "0.4823171", "0.48156744", "0.48128363", "0.48018137", "0.47923383", "0.47837648", "0.47458747", "0.4735962", "0.46994296", "0.46994296", "0.46994296", "0.46994296", "0.46994296", "0.4696455", "0.46826854", "0.46820843", "0.46702752", "0.4662444", "0.4655375", "0.464832", "0.46443158", "0.4642055", "0.46334925", "0.46124744", "0.45790285", "0.45711532", "0.45686564", "0.45634842", "0.455431", "0.45513067", "0.45407212", "0.45236543", "0.4523336", "0.4520994", "0.4507867", "0.45068806", "0.4505637", "0.45052296", "0.4494038", "0.44896004", "0.44885153", "0.44827223", "0.44744426", "0.44680947", "0.446155", "0.4459507", "0.4436449", "0.44334635", "0.44325364", "0.44236764", "0.44221917", "0.44172123", "0.44113755", "0.4392641", "0.43924427", "0.43910626", "0.43902966", "0.43844253", "0.43835723", "0.43822372", "0.43778163", "0.43753082", "0.43658537", "0.43643335", "0.43636107", "0.43635625", "0.43574765", "0.43531704", "0.43468437", "0.43453753", "0.43415263" ]
0.84993964
0
listHostOnlyAdapters gets all hostonly adapters in a map keyed by NetworkName.
func listHostOnlyAdapters(vbox VBoxManager) (map[string]*hostOnlyNetwork, error) { out, err := vbox.vbmOut("list", "hostonlyifs") if err != nil { return nil, err } byName := map[string]*hostOnlyNetwork{} byIP := map[string]*hostOnlyNetwork{} n := &hostOnlyNetwork{} err = parseKeyValues(out, reColonLine, func(key, val string) error { switch key { case "Name": n.Name = val case "GUID": n.GUID = val case "DHCP": n.DHCP = (val != "Disabled") case "IPAddress": n.IPv4.IP = net.ParseIP(val) case "NetworkMask": n.IPv4.Mask = parseIPv4Mask(val) case "HardwareAddress": mac, err := net.ParseMAC(val) if err != nil { return err } n.HwAddr = mac case "MediumType": n.Medium = val case "Status": n.Status = val case "VBoxNetworkName": n.NetworkName = val if _, present := byName[n.NetworkName]; present { return fmt.Errorf("VirtualBox is configured with multiple host-only adapters with the same name %q. Please remove one.", n.NetworkName) } byName[n.NetworkName] = n if len(n.IPv4.IP) != 0 { if _, present := byIP[n.IPv4.IP.String()]; present { return fmt.Errorf("VirtualBox is configured with multiple host-only adapters with the same IP %q. Please remove one.", n.IPv4.IP) } byIP[n.IPv4.IP.String()] = n } n = &hostOnlyNetwork{} } return nil }) if err != nil { return nil, err } return byName, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func listDHCPServers(vbox VBoxManager) (map[string]*dhcpServer, error) {\n\tout, err := vbox.vbmOut(\"list\", \"dhcpservers\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tm := map[string]*dhcpServer{}\n\tdhcp := &dhcpServer{}\n\n\terr = parseKeyValues(out, reColonLine, func(key, val string) error {\n\t\tswitch key {\n\t\tcase \"NetworkName\":\n\t\t\tdhcp = &dhcpServer{}\n\t\t\tm[val] = dhcp\n\t\t\tdhcp.NetworkName = val\n\t\tcase \"IP\":\n\t\t\tdhcp.IPv4.IP = net.ParseIP(val)\n\t\tcase \"upperIPAddress\":\n\t\t\tdhcp.UpperIP = net.ParseIP(val)\n\t\tcase \"lowerIPAddress\":\n\t\t\tdhcp.LowerIP = net.ParseIP(val)\n\t\tcase \"NetworkMask\":\n\t\t\tdhcp.IPv4.Mask = parseIPv4Mask(val)\n\t\tcase \"Enabled\":\n\t\t\tdhcp.Enabled = (val == \"Yes\")\n\t\t}\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn m, nil\n}", "func AddressesForHost(host string) []string {\n\tss := collection.NewStringSet()\n\tif host == \"\" { // All address on machine\n\t\tif iFaces, err := net.Interfaces(); err == nil {\n\t\t\tfor _, iFace := range iFaces {\n\t\t\t\tconst interesting = net.FlagUp | net.FlagBroadcast\n\t\t\t\tif iFace.Flags&interesting == interesting {\n\t\t\t\t\tvar addrs []net.Addr\n\t\t\t\t\tif addrs, err = iFace.Addrs(); err == nil {\n\t\t\t\t\t\tfor _, addr := range addrs {\n\t\t\t\t\t\t\tvar ip net.IP\n\t\t\t\t\t\t\tswitch v := addr.(type) {\n\t\t\t\t\t\t\tcase *net.IPNet:\n\t\t\t\t\t\t\t\tip = v.IP\n\t\t\t\t\t\t\tcase *net.IPAddr:\n\t\t\t\t\t\t\t\tip = v.IP\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ip.IsGlobalUnicast() {\n\t\t\t\t\t\t\t\tss.Add(ip.String())\n\t\t\t\t\t\t\t\tvar names []string\n\t\t\t\t\t\t\t\tif names, err = net.LookupAddr(ip.String()); err == nil {\n\t\t\t\t\t\t\t\t\tfor _, name := range names {\n\t\t\t\t\t\t\t\t\t\tif strings.HasSuffix(name, \".\") {\n\t\t\t\t\t\t\t\t\t\t\tname = name[:len(name)-1]\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tss.Add(name)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tss.Add(host)\n\t\tif net.ParseIP(host) == nil {\n\t\t\tif ips, err := net.LookupIP(host); err == nil && len(ips) > 0 {\n\t\t\t\tfor _, ip := range ips {\n\t\t\t\t\tss.Add(ip.String())\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor _, one := range []string{\"::\", \"::1\", \"127.0.0.1\"} {\n\t\tif ss.Contains(one) {\n\t\t\tdelete(ss, one)\n\t\t\tss.Add(\"localhost\")\n\t\t}\n\t}\n\taddrs := ss.Values()\n\tsort.Slice(addrs, func(i, j int) bool {\n\t\tisName1 := net.ParseIP(addrs[i]) == nil\n\t\tisName2 := net.ParseIP(addrs[j]) == nil\n\t\tif isName1 == isName2 {\n\t\t\treturn txt.NaturalLess(addrs[i], addrs[j], true)\n\t\t}\n\t\treturn isName1\n\t})\n\treturn addrs\n}", "func createHostonlyAdapter(vbox VBoxManager) (*hostOnlyNetwork, error) {\n\tout, err := vbox.vbmOut(\"hostonlyif\", \"create\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tres := reHostOnlyAdapterCreated.FindStringSubmatch(string(out))\n\tif res == nil {\n\t\treturn nil, errors.New(\"Failed to create host-only adapter\")\n\t}\n\n\treturn &hostOnlyNetwork{Name: res[1]}, nil\n}", "func (c *Eth) ShowList() ([]string, error) {\n c.con.LogQuery(\"(show) list of ethernet interfaces\")\n path := c.xpath(nil)\n return c.con.EntryListUsing(c.con.Show, path[:len(path) - 1])\n}", "func NonTailscaleInterfaces() (map[winipcfg.LUID]*winipcfg.IPAdapterAddresses, error) {\n\tifs, err := winipcfg.GetAdaptersAddresses(windows.AF_UNSPEC, winipcfg.GAAFlagIncludeAllInterfaces)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tret := map[winipcfg.LUID]*winipcfg.IPAdapterAddresses{}\n\tfor _, iface := range ifs {\n\t\tif iface.Description() == tsconst.WintunInterfaceDesc {\n\t\t\tcontinue\n\t\t}\n\t\tret[iface.LUID] = iface\n\t}\n\n\treturn ret, nil\n}", "func (client *Client) ShowHostMaps(host string) ([]Volume, *ResponseStatus, error) {\n\tif len(host) > 0 {\n\t\thost = fmt.Sprintf(\"\\\"%s\\\"\", host)\n\t}\n\tres, status, err := client.FormattedRequest(\"/show/host-maps/%s\", host)\n\tif err != nil {\n\t\treturn nil, status, err\n\t}\n\n\tmappings := make([]Volume, 0)\n\tfor _, rootObj := range res.Objects {\n\t\tif rootObj.Name != \"host-view\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, object := range rootObj.Objects {\n\t\t\tif object.Name == \"volume-view\" {\n\t\t\t\tvol := Volume{}\n\t\t\t\tvol.fillFromObject(&object)\n\t\t\t\tmappings = append(mappings, vol)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn mappings, status, err\n}", "func (d *RestrictedDialer) AllowedHosts() []string {\n\tranges := []string{}\n\tfor _, ipRange := range d.allowedHosts {\n\t\tranges = append(ranges, ipRange.String())\n\t}\n\treturn ranges\n}", "func (m *MicroService) blackListHost(host string, blacklist bool) {\r\n\tfor idx, inst := range m.Instances {\r\n\t\tif inst.Host == host {\r\n\t\t\tm.blackList(idx, blacklist)\r\n\t\t}\r\n\t}\r\n}", "func (h *ConfigHandler) GetHostList(ctx *fasthttp.RequestCtx) {\n\tuser, ok := common.GlobalSession.GetUser(ctx.ID())\n\tif !ok {\n\t\th.WriteJSON(ctx, nil, common.NewNotLoginError())\n\t\treturn\n\t}\n\n\tconf, err := h.Service.GetVPNConfig(context.Background(), &user)\n\tif err != nil {\n\t\th.WriteJSON(ctx, nil, err)\n\t\treturn\n\t}\n\tdata := vpnConfigResponseEncode(conf)\n\th.WriteJSON(ctx, map[string]interface{}{\n\t\t\"list\": data.Hosts,\n\t}, nil)\n\treturn\n}", "func getHostOnlyNetworkInterface(mc *driver.MachineConfig) (string, error) {\n\t// Check if the interface/dhcp exists.\n\tnets, err := HostonlyNets()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdhcps, err := DHCPs()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor _, n := range nets {\n\t\tif dhcp, ok := dhcps[n.NetworkName]; ok {\n\t\t\tif dhcp.IPv4.IP.Equal(mc.DHCPIP) &&\n\t\t\t\tdhcp.IPv4.Mask.String() == mc.NetMask.String() &&\n\t\t\t\tdhcp.LowerIP.Equal(mc.LowerIP) &&\n\t\t\t\tdhcp.UpperIP.Equal(mc.UpperIP) &&\n\t\t\t\tdhcp.Enabled == mc.DHCPEnabled {\n\t\t\t\treturn n.Name, nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// No existing host-only interface found. Create a new one.\n\thostonlyNet, err := CreateHostonlyNet()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\thostonlyNet.IPv4.IP = mc.HostIP\n\thostonlyNet.IPv4.Mask = mc.NetMask\n\tif err := hostonlyNet.Config(); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Create and add a DHCP server to the host-only network\n\tdhcp := driver.DHCP{}\n\tdhcp.IPv4.IP = mc.DHCPIP\n\tdhcp.IPv4.Mask = mc.NetMask\n\tdhcp.LowerIP = mc.LowerIP\n\tdhcp.UpperIP = mc.UpperIP\n\tdhcp.Enabled = true\n\tif err := AddHostonlyDHCP(hostonlyNet.Name, dhcp); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn hostonlyNet.Name, nil\n}", "func WhiteListHostFilter(hosts ...string) HostFilter {\n\thostInfos, err := addrsToHosts(hosts, 9042)\n\tif err != nil {\n\t\t// dont want to panic here, but rather not break the API\n\t\tpanic(fmt.Errorf(\"unable to lookup host info from address: %v\", err))\n\t}\n\n\tm := make(map[string]bool, len(hostInfos))\n\tfor _, host := range hostInfos {\n\t\tm[host.ConnectAddress().String()] = true\n\t}\n\n\treturn HostFilterFunc(func(host *HostInfo) bool {\n\t\treturn m[host.ConnectAddress().String()]\n\t})\n}", "func (b *BlubberBlockDirectory) ListHosts(\n\tvoid blubberstore.Empty, hosts *blubberstore.BlockHolderList) error {\n\tvar host string\n\tb.blockMapMtx.RLock()\n\tdefer b.blockMapMtx.RUnlock()\n\n\tfor host, _ = range b.blockHostMap {\n\t\thosts.HostPort = append(hosts.HostPort, host)\n\t}\n\n\treturn nil\n}", "func NewGetAdapterHostEthInterfacesDefault(code int) *GetAdapterHostEthInterfacesDefault {\n\treturn &GetAdapterHostEthInterfacesDefault{\n\t\t_statusCode: code,\n\t}\n}", "func addHostOnlyDHCPServer(ifname string, d dhcpServer, vbox VBoxManager) error {\n\tname := dhcpPrefix + ifname\n\n\tdhcps, err := listDHCPServers(vbox)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// On some platforms (OSX), creating a host-only adapter adds a default dhcpserver,\n\t// while on others (Windows?) it does not.\n\tcommand := \"add\"\n\tif dhcp, ok := dhcps[name]; ok {\n\t\tcommand = \"modify\"\n\t\tif (dhcp.IPv4.IP.Equal(d.IPv4.IP)) && (dhcp.IPv4.Mask.String() == d.IPv4.Mask.String()) && (dhcp.LowerIP.Equal(d.LowerIP)) && (dhcp.UpperIP.Equal(d.UpperIP)) && dhcp.Enabled {\n\t\t\t// dhcp is up to date\n\t\t\treturn nil\n\t\t}\n\t}\n\n\targs := []string{\"dhcpserver\", command,\n\t\t\"--netname\", name,\n\t\t\"--ip\", d.IPv4.IP.String(),\n\t\t\"--netmask\", net.IP(d.IPv4.Mask).String(),\n\t\t\"--lowerip\", d.LowerIP.String(),\n\t\t\"--upperip\", d.UpperIP.String(),\n\t}\n\tif d.Enabled {\n\t\targs = append(args, \"--enable\")\n\t} else {\n\t\targs = append(args, \"--disable\")\n\t}\n\n\treturn vbox.vbm(args...)\n}", "func (r *reader) GetBlockedHostnames() (hostnames []string, err error) {\n\ts, err := r.envParams.GetEnv(\"BLOCK_HOSTNAMES\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(s) == 0 {\n\t\treturn nil, nil\n\t}\n\thostnames = strings.Split(s, \",\")\n\tfor _, hostname := range hostnames {\n\t\tif !r.verifier.MatchHostname(hostname) {\n\t\t\treturn nil, fmt.Errorf(\"hostname %q does not seem valid\", hostname)\n\t\t}\n\t}\n\treturn hostnames, nil\n}", "func (r *reader) GetUnblockedHostnames() (hostnames []string, err error) {\n\ts, err := r.envParams.GetEnv(\"UNBLOCK\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(s) == 0 {\n\t\treturn nil, nil\n\t}\n\thostnames = strings.Split(s, \",\")\n\tfor _, hostname := range hostnames {\n\t\tif !r.verifier.MatchHostname(hostname) {\n\t\t\treturn nil, fmt.Errorf(\"hostname %q does not seem valid\", hostname)\n\t\t}\n\t}\n\treturn hostnames, nil\n}", "func (p *PorterHelper) List() (map[string]string, error) {\n\tentries := p.Cache.List()\n\n\tres := make(map[string]string)\n\n\tfor _, entry := range entries {\n\t\tres[entry.ProxyEndpoint] = entry.AuthorizationToken\n\t}\n\n\treturn res, nil\n}", "func ips(h *hostsfile.Hostsfile, ipnet *net.IPNet) map[string]bool {\n\tips := make(map[string]bool)\n\t// Make sure we never touch localhost (may be missing in hosts-file).\n\tif ipnet.Contains(net.IP{127, 0, 0, 1}) {\n\t\tips[\"127.0.0.1\"] = true\n\t}\n\tfor _, r := range h.Records() {\n\t\tif ipnet.Contains(r.IpAddress.IP) {\n\t\t\tips[r.IpAddress.String()] = true\n\t\t}\n\t}\n\treturn ips\n}", "func HostIP() []string {\n\tvar out []string\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\tlogs.WithFields(logs.Fields{\n\t\t\t\"Error\": err,\n\t\t}).Error(\"Unable to resolve net.InterfaceAddrs\")\n\t}\n\tfor _, addr := range addrs {\n\t\t// check the address type and if it is not a loopback the display it\n\t\tif ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() != nil {\n\t\t\t\tout = append(out, ipnet.IP.String())\n\t\t\t}\n\t\t\tif ipnet.IP.To16() != nil {\n\t\t\t\tout = append(out, ipnet.IP.String())\n\t\t\t}\n\t\t}\n\t}\n\treturn List2Set(out)\n}", "func (api *PublicStorageHostManagerAPI) FilteredHosts() (allFiltered []storage.HostInfo) {\n\treturn api.shm.filteredTree.All()\n}", "func (p *ProxySQL) HostsLike(opts ...HostOpts) ([]*Host, error) {\n\tmut.RLock()\n\tdefer mut.RUnlock()\n\thostq, err := buildAndParseHostQuery(opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// run query built from these opts\n\trows, err := query(p, buildSelectQuery(hostq))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\tentries := make([]*Host, 0)\n\tfor rows.Next() {\n\t\tvar (\n\t\t\thostgroup_id int\n\t\t\thostname string\n\t\t\tport int\n\t\t\tstatus string\n\t\t\tweight int\n\t\t\tcompression int\n\t\t\tmax_connections int\n\t\t\tmax_replication_lag int\n\t\t\tuse_ssl int\n\t\t\tmax_latency_ms int\n\t\t\tcomment string\n\t\t)\n\t\terr := scanRows(rows, &hostgroup_id, &hostname, &port, &status, &weight, &compression, &max_connections, &max_replication_lag, &use_ssl, &max_latency_ms, &comment)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\thost := &Host{hostgroup_id, hostname, port, status, weight, compression, max_connections, max_replication_lag, use_ssl, max_latency_ms, comment}\n\t\tentries = append(entries, host)\n\t}\n\tif rowsErr(rows) != nil && rowsErr(rows) != sql.ErrNoRows {\n\t\treturn nil, rowsErr(rows)\n\t}\n\treturn entries, nil\n}", "func (a *Alias) HostedZones() []string {\n\tvar hostedZones []string\n\tfor _, alias := range a.AdvancedAliases {\n\t\tif alias.HostedZone != nil {\n\t\t\thostedZones = append(hostedZones, *alias.HostedZone)\n\t\t}\n\t}\n\treturn hostedZones\n}", "func (d *portworx) GetPoolDrives(n *node.Node) (map[string][]string, error) {\n\tsystemOpts := node.SystemctlOpts{\n\t\tConnectionOpts: node.ConnectionOpts{\n\t\t\tTimeout: startDriverTimeout,\n\t\t\tTimeBeforeRetry: defaultRetryInterval,\n\t\t},\n\t\tAction: \"start\",\n\t}\n\tpoolDrives := make(map[string][]string, 0)\n\tlog.Infof(\"Getting available block drives on node [%s]\", n.Name)\n\tblockDrives, err := d.nodeDriver.GetBlockDrives(*n, systemOpts)\n\n\tif err != nil {\n\t\treturn poolDrives, err\n\t}\n\tfor _, v := range blockDrives {\n\t\tlabelsMap := v.Labels\n\t\tif pm, ok := labelsMap[\"pxpool\"]; ok {\n\t\t\tpoolDrives[pm] = append(poolDrives[pm], v.Path)\n\t\t}\n\t}\n\treturn poolDrives, nil\n}", "func gatherHostportMappings(podPortMapping *PodPortMapping, isIPv6 bool) []*PortMapping {\n\tmappings := []*PortMapping{}\n\tfor _, pm := range podPortMapping.PortMappings {\n\t\tif pm.HostPort <= 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif pm.HostIP != \"\" && utilnet.IsIPv6String(pm.HostIP) != isIPv6 {\n\t\t\tcontinue\n\t\t}\n\t\tmappings = append(mappings, pm)\n\t}\n\treturn mappings\n}", "func (o *AggregatedDomain) HostInterfaces(info *bambou.FetchingInfo) (HostInterfacesList, *bambou.Error) {\n\n\tvar list HostInterfacesList\n\terr := bambou.CurrentSession().FetchChildren(o, HostInterfaceIdentity, &list, info)\n\treturn list, err\n}", "func (api *hostAPI) List(ctx context.Context, opts *api.ListWatchOptions) ([]*Host, error) {\n\tvar objlist []*Host\n\tobjs, err := api.ct.List(\"Host\", ctx, opts)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, obj := range objs {\n\t\tswitch tp := obj.(type) {\n\t\tcase *Host:\n\t\t\teobj := obj.(*Host)\n\t\t\tobjlist = append(objlist, eobj)\n\t\tdefault:\n\t\t\tlog.Fatalf(\"Got invalid object type %v while looking for Host\", tp)\n\t\t}\n\t}\n\n\treturn objlist, nil\n}", "func AdvertiseHost(listen string) string {\n\tif listen == \"0.0.0.0\" {\n\t\taddrs, err := net.InterfaceAddrs()\n\t\tif err != nil || len(addrs) == 0 {\n\t\t\treturn \"localhost\"\n\t\t}\n\n\t\tfor _, addr := range addrs {\n\t\t\tif ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() && ip.IP.To4() != nil {\n\t\t\t\treturn ip.IP.To4().String()\n\t\t\t}\n\t\t}\n\t\treturn \"localhost\"\n\t}\n\n\treturn listen\n}", "func (p partition) Hosts() []string {\n\tvar res []string\n\tfor _, a := range p {\n\t\tres = append(res, a.node.Address())\n\t}\n\treturn res\n}", "func (ls *LocalStorage) filterAllowedNodes(clients map[string]provisioner.API, deploymentName, role string) ([]provisioner.API, error) {\n\t// Find all PVs for given deployment & role\n\tlist, err := ls.deps.KubeCli.CoreV1().PersistentVolumes().List(metav1.ListOptions{\n\t\tLabelSelector: fmt.Sprintf(\"%s=%s,%s=%s\", k8sutil.LabelKeyArangoDeployment, deploymentName, k8sutil.LabelKeyRole, role),\n\t})\n\tif err != nil {\n\t\treturn nil, maskAny(err)\n\t}\n\texcludedNodes := make(map[string]struct{})\n\tfor _, pv := range list.Items {\n\t\tnodeName := pv.GetAnnotations()[nodeNameAnnotation]\n\t\texcludedNodes[nodeName] = struct{}{}\n\t}\n\tresult := make([]provisioner.API, 0, len(clients))\n\tfor nodeName, c := range clients {\n\t\tif _, found := excludedNodes[nodeName]; !found {\n\t\t\tresult = append(result, c)\n\t\t}\n\t}\n\treturn result, nil\n}", "func boundIPs(c *caddy.Controller) (ips []net.IP) {\n\tconf := dnsserver.GetConfig(c)\n\thosts := conf.ListenHosts\n\tif hosts == nil || hosts[0] == \"\" {\n\t\thosts = nil\n\t\taddrs, err := net.InterfaceAddrs()\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\tfor _, addr := range addrs {\n\t\t\thosts = append(hosts, addr.String())\n\t\t}\n\t}\n\tfor _, host := range hosts {\n\t\tip, _, _ := net.ParseCIDR(host)\n\t\tip4 := ip.To4()\n\t\tif ip4 != nil && !ip4.IsLoopback() {\n\t\t\tips = append(ips, ip4)\n\t\t\tcontinue\n\t\t}\n\t\tip6 := ip.To16()\n\t\tif ip6 != nil && !ip6.IsLoopback() {\n\t\t\tips = append(ips, ip6)\n\t\t}\n\t}\n\treturn ips\n}", "func NewBindHostForbidden() *BindHostForbidden {\n\treturn &BindHostForbidden{}\n}", "func ListWifiNetworks() []string {\n\ts := spinner.New(spinner.CharSets[11], 100*time.Millisecond)\n\ts.Prefix = \"Searching networks: \"\n\ts.Start()\n\n\tlistWifiCmd := exec.Command(\"bash\", \"-c\", \"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport scan\")\n\twifiList, err := listWifiCmd.Output()\n\tHandleError(err)\n\ts.Stop()\n\n\tif len(wifiList) == 0 {\n\t\tfmt.Println(\"There are no available networks\")\n\t\tif isWifiOff() {\n\t\t\tfmt.Println(\"It looks like the wifi is off. You can turn it on running `wificli on`\")\n\t\t}\n\t\tos.Exit(1)\n\t}\n\n\tvar list []string\n\twifiListArray := strings.Split(string(wifiList), \"\\n\")[1:]\n\tfor _, network := range wifiListArray {\n\t\tnetworkFields := strings.Fields(network)\n\t\tif len(networkFields) > 0 {\n\t\t\tlist = append(list, networkFields[0])\n\t\t}\n\t}\n\n\treturn list\n}", "func GetHostAliases(ctx context.Context) ([]string, error) {\n\tname, err := GetHostname(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't extract a host alias from the kubelet: %w\", err)\n\t}\n\tif err := validate.ValidHostname(name); err != nil {\n\t\treturn nil, fmt.Errorf(\"host alias from kubelet is not valid: %w\", err)\n\t}\n\treturn []string{name}, nil\n}", "func (mc *MockContiv) GetHostIPs() []net.IP {\n\treturn mc.hostIPs\n}", "func (p *pgSerDe) ListDbClientIps() ([]string, error) {\n\tconst sql = \"SELECT DISTINCT(client_addr) FROM pg_stat_activity\"\n\trows, err := p.dbConn.Query(sql)\n\tif err != nil {\n\t\tlog.Printf(\"ListDbClientIps(): error querying database: %v\", err)\n\t\treturn nil, err\n\t}\n\tdefer rows.Close()\n\n\tresult := make([]string, 0)\n\tfor rows.Next() {\n\t\tvar addr *string\n\t\tif err := rows.Scan(&addr); err != nil {\n\t\t\tlog.Printf(\"ListDbClientIps(): error scanning row: %v\", err)\n\t\t\treturn nil, err\n\t\t}\n\t\tif addr != nil {\n\t\t\tresult = append(result, *addr)\n\t\t}\n\t}\n\treturn result, nil\n}", "func (p *PCache) List(kind string) map[string]interface{} {\n\tp.RLock()\n\tkindMap := p.kinds[kind]\n\tp.RUnlock()\n\titems := map[string]interface{}{}\n\n\tif kindMap != nil {\n\t\tkindMap.Lock()\n\t\tfor key, entry := range kindMap.entries {\n\t\t\titems[key] = entry\n\t\t}\n\t\tkindMap.Unlock()\n\t}\n\n\treturn items\n}", "func (d *Daemon) syncHostIPs() error {\n\tif option.Config.DryMode {\n\t\treturn nil\n\t}\n\n\ttype ipIDLabel struct {\n\t\tidentity.IPIdentityPair\n\t\tlabels.Labels\n\t}\n\tspecialIdentities := make([]ipIDLabel, 0, 2)\n\n\tif option.Config.EnableIPv4 {\n\t\taddrs, err := d.datapath.LocalNodeAddressing().IPv4().LocalAddresses()\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Warning(\"Unable to list local IPv4 addresses\")\n\t\t}\n\n\t\tfor _, ip := range addrs {\n\t\t\tif option.Config.IsExcludedLocalAddress(ip) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif len(ip) > 0 {\n\t\t\t\tspecialIdentities = append(specialIdentities, ipIDLabel{\n\t\t\t\t\tidentity.IPIdentityPair{\n\t\t\t\t\t\tIP: ip,\n\t\t\t\t\t\tID: identity.ReservedIdentityHost,\n\t\t\t\t\t},\n\t\t\t\t\tlabels.LabelHost,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tipv4Ident := identity.ReservedIdentityWorldIPv4\n\t\tipv4Label := labels.LabelWorldIPv4\n\t\tif !option.Config.EnableIPv6 {\n\t\t\tipv4Ident = identity.ReservedIdentityWorld\n\t\t\tipv4Label = labels.LabelWorld\n\t\t}\n\t\tspecialIdentities = append(specialIdentities, ipIDLabel{\n\t\t\tidentity.IPIdentityPair{\n\t\t\t\tIP: net.IPv4zero,\n\t\t\t\tMask: net.CIDRMask(0, net.IPv4len*8),\n\t\t\t\tID: ipv4Ident,\n\t\t\t},\n\t\t\tipv4Label,\n\t\t})\n\t}\n\n\tif option.Config.EnableIPv6 {\n\t\taddrs, err := d.datapath.LocalNodeAddressing().IPv6().LocalAddresses()\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Warning(\"Unable to list local IPv6 addresses\")\n\t\t}\n\n\t\taddrs = append(addrs, node.GetIPv6Router())\n\t\tfor _, ip := range addrs {\n\t\t\tif option.Config.IsExcludedLocalAddress(ip) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif len(ip) > 0 {\n\t\t\t\tspecialIdentities = append(specialIdentities, ipIDLabel{\n\t\t\t\t\tidentity.IPIdentityPair{\n\t\t\t\t\t\tIP: ip,\n\t\t\t\t\t\tID: identity.ReservedIdentityHost,\n\t\t\t\t\t},\n\t\t\t\t\tlabels.LabelHost,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tipv6Ident := identity.ReservedIdentityWorldIPv6\n\t\tipv6Label := labels.LabelWorldIPv6\n\t\tif !option.Config.EnableIPv4 {\n\t\t\tipv6Ident = identity.ReservedIdentityWorld\n\t\t\tipv6Label = labels.LabelWorld\n\t\t}\n\t\tspecialIdentities = append(specialIdentities, ipIDLabel{\n\t\t\tidentity.IPIdentityPair{\n\t\t\t\tIP: net.IPv6zero,\n\t\t\t\tMask: net.CIDRMask(0, net.IPv6len*8),\n\t\t\t\tID: ipv6Ident,\n\t\t\t},\n\t\t\tipv6Label,\n\t\t})\n\t}\n\n\texistingEndpoints, err := lxcmap.DumpToMap()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdaemonResourceID := ipcachetypes.NewResourceID(ipcachetypes.ResourceKindDaemon, \"\", \"\")\n\tfor _, ipIDLblsPair := range specialIdentities {\n\t\tisHost := ipIDLblsPair.ID == identity.ReservedIdentityHost\n\t\tif isHost {\n\t\t\tadded, err := lxcmap.SyncHostEntry(ipIDLblsPair.IP)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"Unable to add host entry to endpoint map: %s\", err)\n\t\t\t}\n\t\t\tif added {\n\t\t\t\tlog.WithField(logfields.IPAddr, ipIDLblsPair.IP).Debugf(\"Added local ip to endpoint map\")\n\t\t\t}\n\t\t}\n\n\t\tdelete(existingEndpoints, ipIDLblsPair.IP.String())\n\n\t\tlbls := ipIDLblsPair.Labels\n\t\tif ipIDLblsPair.ID.IsWorld() {\n\t\t\tp := netip.PrefixFrom(ippkg.MustAddrFromIP(ipIDLblsPair.IP), 0)\n\t\t\td.ipcache.OverrideIdentity(p, lbls, source.Local, daemonResourceID)\n\t\t} else {\n\t\t\td.ipcache.UpsertLabels(ippkg.IPToNetPrefix(ipIDLblsPair.IP),\n\t\t\t\tlbls,\n\t\t\t\tsource.Local, daemonResourceID,\n\t\t\t)\n\t\t}\n\t}\n\n\t// existingEndpoints is a map from endpoint IP to endpoint info. Referring\n\t// to the key as host IP here because we only care about the host endpoint.\n\tfor hostIP, info := range existingEndpoints {\n\t\tif ip := net.ParseIP(hostIP); info.IsHost() && ip != nil {\n\t\t\tif err := lxcmap.DeleteEntry(ip); err != nil {\n\t\t\t\tlog.WithError(err).WithFields(logrus.Fields{\n\t\t\t\t\tlogfields.IPAddr: hostIP,\n\t\t\t\t}).Warn(\"Unable to delete obsolete host IP from BPF map\")\n\t\t\t} else {\n\t\t\t\tlog.Debugf(\"Removed outdated host IP %s from endpoint map\", hostIP)\n\t\t\t}\n\n\t\t\td.ipcache.RemoveLabels(ippkg.IPToNetPrefix(ip), labels.LabelHost, daemonResourceID)\n\t\t}\n\t}\n\n\tif option.Config.EnableVTEP {\n\t\terr := setupVTEPMapping()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = setupRouteToVtepCidr()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (c *Eth) GetList() ([]string, error) {\n c.con.LogQuery(\"(get) list of ethernet interfaces\")\n path := c.xpath(nil)\n return c.con.EntryListUsing(c.con.Get, path[:len(path) - 1])\n}", "func (r Virtual_DedicatedHost) GetGuests() (resp []datatypes.Virtual_Guest, err error) {\n\terr = r.Session.DoRequest(\"SoftLayer_Virtual_DedicatedHost\", \"getGuests\", nil, &r.Options, &resp)\n\treturn\n}", "func (h *Hub) AllHosts() map[string]client.HostConfig {\n\th.Lock()\n\tdefer h.Unlock()\n\tr := map[string]client.HostConfig{}\n\tfor _, host := range h.hosts {\n\t\tc := host.GetConfig()\n\t\tr[c.HostID] = c\n\t}\n\treturn r\n}", "func (s *ServerT) Hosts() ([]string, error) {\n\tvar hosts = []string{s.Config.HTTPHost}\n\n\tif s.Config.HTTPHost != \"localhost\" {\n\t\thosts = append(hosts, \"localhost\")\n\t}\n\n\taddresses, _ := net.InterfaceAddrs()\n\tfor _, address := range addresses {\n\t\tif ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\thost := ipnet.IP.To4()\n\t\t\tif host != nil {\n\t\t\t\thosts = append(hosts, host.String())\n\t\t\t}\n\t\t}\n\t}\n\n\treturn hosts, nil\n}", "func ListDeviceNames(withDescription bool, withIP bool) ([]string, error) {\n\tdevices, err := pcap.FindAllDevs()\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\n\tret := []string{}\n\tfor _, dev := range devices {\n\t\tr := dev.Name\n\n\t\tif withDescription {\n\t\t\tdesc := \"No description available\"\n\t\t\tif len(dev.Description) > 0 {\n\t\t\t\tdesc = dev.Description\n\t\t\t}\n\t\t\tr += fmt.Sprintf(\" (%s)\", desc)\n\t\t}\n\n\t\tif withIP {\n\t\t\tips := \"Not assigned ip address\"\n\t\t\tif len(dev.Addresses) > 0 {\n\t\t\t\tips = \"\"\n\n\t\t\t\tfor i, address := range []pcap.InterfaceAddress(dev.Addresses) {\n\t\t\t\t\t// Add a space between the IP address.\n\t\t\t\t\tif i > 0 {\n\t\t\t\t\t\tips += \" \"\n\t\t\t\t\t}\n\n\t\t\t\t\tips += fmt.Sprintf(\"%s\", address.IP.String())\n\t\t\t\t}\n\t\t\t}\n\t\t\tr += fmt.Sprintf(\" (%s)\", ips)\n\n\t\t}\n\t\tret = append(ret, r)\n\t}\n\treturn ret, nil\n}", "func (r *reader) GetDNSUnblockedHostnames() (hostnames []string, err error) {\n\ts, err := r.envParams.GetEnv(\"UNBLOCK\")\n\tif err != nil {\n\t\treturn nil, err\n\t} else if len(s) == 0 {\n\t\treturn nil, nil\n\t}\n\thostnames = strings.Split(s, \",\")\n\tfor _, hostname := range hostnames {\n\t\tif !r.verifier.MatchHostname(hostname) {\n\t\t\treturn nil, fmt.Errorf(\"hostname %q does not seem valid\", hostname)\n\t\t}\n\t}\n\treturn hostnames, nil\n}", "func ListDockerHosts(w http.ResponseWriter, r *http.Request) {\n\t// let's get all host uri from map.\n\tvar hosts []string\n\tfor host, _ := range clientMap {\n\t\thosts = append(hosts, host)\n\t}\n\t// map with list of hosts\n\tresponse := make(map[string][]string)\n\tresponse[\"hosts\"] = hosts\n\t// convert map to json\n\tjsonString, err := json.Marshal(response)\n\tif err != nil {\n\t\tfmt.Fprintln(w,\"{ \\\"error\\\" : \\\"Internal server error\\\" }\")\n\t}\n\tfmt.Fprintln(w,string(jsonString))\n}", "func (o *LdapProvider) GetHostnames() []string {\n\tif o == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\n\treturn o.Hostnames\n}", "func ActiveAddresses() map[string]net.Interface {\n\tresult := make(map[string]net.Interface)\n\tif iFaces, err := net.Interfaces(); err == nil {\n\t\tfor _, iFace := range iFaces {\n\t\t\tconst interesting = net.FlagUp | net.FlagBroadcast\n\t\t\tif iFace.Flags&interesting == interesting {\n\t\t\t\tif name := Address(iFace); name != \"\" {\n\t\t\t\t\tresult[name] = iFace\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn result\n}", "func (s *k8sStore) ListIngresses() []*networkingv1.Ingress {\n\t// filter ingress rules\n\tvar ingresses []*networkingv1.Ingress\n\tfor _, item := range s.listers.Ingress.List() {\n\t\ting := item.(*networkingv1.Ingress)\n\n\t\tingresses = append(ingresses, ing)\n\t}\n\n\treturn ingresses\n}", "func validateAdapters(adapterMap map[string]Adapter, errs []error) []error {\n\tfor adapterName, adapter := range adapterMap {\n\t\tif !adapter.Disabled {\n\t\t\t// Verify that every adapter has a valid endpoint associated with it\n\t\t\terrs = validateAdapterEndpoint(adapter.Endpoint, adapterName, errs)\n\n\t\t\t// Verify that valid user_sync URLs are specified in the config\n\t\t\terrs = validateAdapterUserSyncURL(adapter.UserSyncURL, adapterName, errs)\n\t\t}\n\t}\n\treturn errs\n}", "func HostOnly(addr string) string {\n\thost, _, err := net.SplitHostPort(addr)\n\tif err != nil {\n\t\treturn addr\n\t} else {\n\t\treturn host\n\t}\n}", "func (c *Client) ListAddresses() (map[int][]*AddrEntry, error) {\n\tvar msg netlink.Message\n\tmsg.Header.Type = unix.RTM_GETADDR\n\tmsg.Header.Flags = netlink.Dump | netlink.Request\n\n\tvar ifimsg iproute2.IfInfoMsg\n\tae := netlink.NewAttributeEncoder()\n\tae.Uint32(unix.IFLA_EXT_MASK, uint32(iproute2.RTEXT_FILTER_BRVLAN))\n\tmsg.Data, _ = ifimsg.MarshalBinary()\n\tdata, err := ae.Encode()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmsg.Data = append(msg.Data, data...)\n\n\tmsgs, err := c.conn.Execute(msg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tentries := make(map[int][]*AddrEntry)\n\tfor _, msg := range msgs {\n\t\tif msg.Header.Type != unix.RTM_NEWADDR {\n\t\t\tcontinue\n\t\t}\n\n\t\te, ok, err := parseAddrMsg(&msg)\n\t\tif err != nil {\n\t\t\treturn entries, err\n\t\t}\n\t\tif ok {\n\t\t\tentries[e.Ifindex] = append(entries[e.Ifindex], e)\n\t\t}\n\t}\n\treturn entries, nil\n}", "func (r Virtual_Guest) GetAllowedHost() (resp datatypes.Network_Storage_Allowed_Host, err error) {\n\terr = r.Session.DoRequest(\"SoftLayer_Virtual_Guest\", \"getAllowedHost\", nil, &r.Options, &resp)\n\treturn\n}", "func filteredConfig(list *configstore.ItemList, dropAlias ...string) (map[string]*string, error) {\n\tcfg := make(map[string]*string)\n\tfor _, i := range list.Items {\n\t\tif !utils.ListContainsString(dropAlias, i.Key()) {\n\t\t\t// assume only one value per alias\n\t\t\tif _, ok := cfg[i.Key()]; !ok {\n\t\t\t\tv, err := i.Value()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tif len(v) > 0 {\n\t\t\t\t\tcfg[i.Key()] = &v\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn cfg, nil\n}", "func RegisteredListenNetworks() []string {\n\tnetworks := []string{}\n\tfor network := range listenFuncs {\n\t\tnetworks = append(networks, network)\n\t}\n\treturn networks\n}", "func iterateAdapters(task func(adapters.Adapter, ...string), adapterList ...string) {\n\tonce.Do(func() {\n\t\tcheckLocalTimezone()\n\t\tcheckDatabase()\n\t})\n\n\tif len(adapterList) == 0 {\n\t\tfor _, a := range adapters.Adapters {\n\t\t\twg.Add(1)\n\t\t\tgo task(a)\n\t\t}\n\t} else {\n\t\tfor _, adapterCode := range adapterList {\n\t\t\toperatorCodes := make([]string, 0, len(adapterCode))\n\t\t\tsep := strings.Index(adapterCode, \".\")\n\t\t\tif sep > 0 {\n\t\t\t\tfor index := sep + 1; index < len(adapterCode); index++ {\n\t\t\t\t\toperatorCodes = append(operatorCodes, adapterCode[index:index+1])\n\t\t\t\t}\n\t\t\t\tadapterCode = adapterCode[:sep]\n\t\t\t}\n\n\t\t\ta := adapters.MustGetAdapterByCode(string(adapterCode))\n\t\t\twg.Add(1)\n\t\t\tgo task(a, operatorCodes...)\n\t\t}\n\t}\n\n\twg.Wait()\n}", "func NewIpNetwork_getRemoteHostByName_Params_List(s *capnp.Segment, sz int32) (IpNetwork_getRemoteHostByName_Params_List, error) {\n\tl, err := capnp.NewCompositeList(s, capnp.ObjectSize{DataSize: 0, PointerCount: 1}, sz)\n\treturn IpNetwork_getRemoteHostByName_Params_List{l}, err\n}", "func (v *Virter) getDHCPHosts(network libvirt.Network) ([]libvirtxml.NetworkDHCPHost, error) {\n\thosts := []libvirtxml.NetworkDHCPHost{}\n\n\tnetworkDescription, err := getNetworkDescription(v.libvirt, network)\n\tif err != nil {\n\t\treturn hosts, err\n\t}\n\tif len(networkDescription.IPs) < 1 {\n\t\treturn hosts, fmt.Errorf(\"no IPs in network\")\n\t}\n\n\tipDescription := networkDescription.IPs[0]\n\n\tdhcpDescription := ipDescription.DHCP\n\tif dhcpDescription == nil {\n\t\treturn hosts, fmt.Errorf(\"no DHCP in network\")\n\t}\n\n\tfor _, host := range dhcpDescription.Hosts {\n\t\thosts = append(hosts, host)\n\t}\n\n\treturn hosts, nil\n}", "func (authManager *AuthManager) GetDatastoreIgnoreMapForBlockVolumes(ctx context.Context) map[string]*cnsvsphere.DatastoreInfo {\n\tdatastoreIgnoreMapForBlockVolumes := make(map[string]*cnsvsphere.DatastoreInfo)\n\tauthManager.rwMutex.RLock()\n\tdefer authManager.rwMutex.RUnlock()\n\tfor dsURL, dsInfo := range authManager.datastoreIgnoreMapForBlockVolumes {\n\t\tdatastoreIgnoreMapForBlockVolumes[dsURL] = dsInfo\n\t}\n\treturn datastoreIgnoreMapForBlockVolumes\n}", "func (s *Module) DiskList() ([]pkg.VDisk, error) {\n\tpools, err := s.diskPools()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar disks []pkg.VDisk\n\tfor _, pool := range pools {\n\n\t\titems, err := os.ReadDir(pool)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to list virtual disks\")\n\t\t}\n\n\t\tfor _, item := range items {\n\t\t\tif item.IsDir() {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tinfo, err := item.Info()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"failed to get file info for '%s'\", item.Name())\n\t\t\t}\n\n\t\t\tdisks = append(disks, pkg.VDisk{\n\t\t\t\tPath: filepath.Join(pool, item.Name()),\n\t\t\t\tSize: info.Size(),\n\t\t\t})\n\t\t}\n\n\t\treturn disks, nil\n\t}\n\n\treturn disks, nil\n}", "func CyberghostServers() []models.CyberghostServer {\n\treturn []models.CyberghostServer{\n\t\t{Region: \"Albania\", Group: \"Premium TCP Europe\", Hostname: \"97-1-al.cg-dialup.net\", IPs: []net.IP{{31, 171, 155, 3}, {31, 171, 155, 4}, {31, 171, 155, 7}, {31, 171, 155, 8}, {31, 171, 155, 9}, {31, 171, 155, 10}, {31, 171, 155, 11}, {31, 171, 155, 12}, {31, 171, 155, 13}, {31, 171, 155, 14}}},\n\t\t{Region: \"Albania\", Group: \"Premium UDP Europe\", Hostname: \"87-1-al.cg-dialup.net\", IPs: []net.IP{{31, 171, 155, 4}, {31, 171, 155, 5}, {31, 171, 155, 6}, {31, 171, 155, 7}, {31, 171, 155, 8}, {31, 171, 155, 9}, {31, 171, 155, 10}, {31, 171, 155, 11}, {31, 171, 155, 13}, {31, 171, 155, 14}}},\n\t\t{Region: \"Algeria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-dz.cg-dialup.net\", IPs: []net.IP{{176, 125, 228, 132}, {176, 125, 228, 134}, {176, 125, 228, 135}, {176, 125, 228, 136}, {176, 125, 228, 137}, {176, 125, 228, 138}, {176, 125, 228, 139}, {176, 125, 228, 140}, {176, 125, 228, 141}, {176, 125, 228, 142}}},\n\t\t{Region: \"Algeria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-dz.cg-dialup.net\", IPs: []net.IP{{176, 125, 228, 131}, {176, 125, 228, 133}, {176, 125, 228, 134}, {176, 125, 228, 136}, {176, 125, 228, 137}, {176, 125, 228, 139}, {176, 125, 228, 140}, {176, 125, 228, 141}, {176, 125, 228, 142}, {176, 125, 228, 143}}},\n\t\t{Region: \"Andorra\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ad.cg-dialup.net\", IPs: []net.IP{{188, 241, 82, 137}, {188, 241, 82, 138}, {188, 241, 82, 140}, {188, 241, 82, 142}, {188, 241, 82, 147}, {188, 241, 82, 155}, {188, 241, 82, 159}, {188, 241, 82, 160}, {188, 241, 82, 161}, {188, 241, 82, 166}}},\n\t\t{Region: \"Andorra\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ad.cg-dialup.net\", IPs: []net.IP{{188, 241, 82, 133}, {188, 241, 82, 134}, {188, 241, 82, 136}, {188, 241, 82, 137}, {188, 241, 82, 146}, {188, 241, 82, 153}, {188, 241, 82, 155}, {188, 241, 82, 160}, {188, 241, 82, 164}, {188, 241, 82, 168}}},\n\t\t{Region: \"Argentina\", Group: \"Premium TCP USA\", Hostname: \"93-1-ar.cg-dialup.net\", IPs: []net.IP{{146, 70, 39, 4}, {146, 70, 39, 9}, {146, 70, 39, 15}, {146, 70, 39, 19}, {146, 70, 39, 135}, {146, 70, 39, 136}, {146, 70, 39, 139}, {146, 70, 39, 142}, {146, 70, 39, 143}, {146, 70, 39, 145}}},\n\t\t{Region: \"Argentina\", Group: \"Premium UDP USA\", Hostname: \"94-1-ar.cg-dialup.net\", IPs: []net.IP{{146, 70, 39, 3}, {146, 70, 39, 5}, {146, 70, 39, 6}, {146, 70, 39, 8}, {146, 70, 39, 11}, {146, 70, 39, 12}, {146, 70, 39, 131}, {146, 70, 39, 134}, {146, 70, 39, 142}, {146, 70, 39, 143}}},\n\t\t{Region: \"Armenia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-am.cg-dialup.net\", IPs: []net.IP{{185, 253, 160, 131}, {185, 253, 160, 134}, {185, 253, 160, 136}, {185, 253, 160, 137}, {185, 253, 160, 138}, {185, 253, 160, 139}, {185, 253, 160, 140}, {185, 253, 160, 141}, {185, 253, 160, 142}, {185, 253, 160, 143}}},\n\t\t{Region: \"Armenia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-am.cg-dialup.net\", IPs: []net.IP{{185, 253, 160, 131}, {185, 253, 160, 132}, {185, 253, 160, 133}, {185, 253, 160, 134}, {185, 253, 160, 135}, {185, 253, 160, 136}, {185, 253, 160, 137}, {185, 253, 160, 141}, {185, 253, 160, 142}, {185, 253, 160, 144}}},\n\t\t{Region: \"Australia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-au.cg-dialup.net\", IPs: []net.IP{{154, 16, 81, 22}, {181, 214, 215, 7}, {181, 214, 215, 15}, {181, 214, 215, 18}, {191, 101, 210, 15}, {191, 101, 210, 50}, {191, 101, 210, 60}, {202, 60, 80, 78}, {202, 60, 80, 82}, {202, 60, 80, 102}}},\n\t\t{Region: \"Australia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-au.cg-dialup.net\", IPs: []net.IP{{181, 214, 215, 4}, {181, 214, 215, 16}, {191, 101, 210, 18}, {191, 101, 210, 21}, {191, 101, 210, 36}, {191, 101, 210, 58}, {191, 101, 210, 60}, {202, 60, 80, 74}, {202, 60, 80, 106}, {202, 60, 80, 124}}},\n\t\t{Region: \"Austria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-at.cg-dialup.net\", IPs: []net.IP{{37, 19, 223, 9}, {37, 19, 223, 16}, {37, 19, 223, 113}, {37, 19, 223, 205}, {37, 19, 223, 211}, {37, 19, 223, 218}, {37, 19, 223, 223}, {37, 19, 223, 245}, {37, 120, 155, 104}, {89, 187, 168, 174}}},\n\t\t{Region: \"Austria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-at.cg-dialup.net\", IPs: []net.IP{{37, 19, 223, 202}, {37, 19, 223, 205}, {37, 19, 223, 229}, {37, 19, 223, 239}, {37, 19, 223, 241}, {37, 19, 223, 243}, {37, 120, 155, 103}, {89, 187, 168, 160}, {89, 187, 168, 174}, {89, 187, 168, 181}}},\n\t\t{Region: \"Bahamas\", Group: \"Premium TCP USA\", Hostname: \"93-1-bs.cg-dialup.net\", IPs: []net.IP{{95, 181, 238, 131}, {95, 181, 238, 136}, {95, 181, 238, 142}, {95, 181, 238, 144}, {95, 181, 238, 146}, {95, 181, 238, 147}, {95, 181, 238, 148}, {95, 181, 238, 152}, {95, 181, 238, 153}, {95, 181, 238, 155}}},\n\t\t{Region: \"Bahamas\", Group: \"Premium UDP USA\", Hostname: \"94-1-bs.cg-dialup.net\", IPs: []net.IP{{95, 181, 238, 131}, {95, 181, 238, 138}, {95, 181, 238, 140}, {95, 181, 238, 141}, {95, 181, 238, 146}, {95, 181, 238, 147}, {95, 181, 238, 148}, {95, 181, 238, 151}, {95, 181, 238, 153}, {95, 181, 238, 155}}},\n\t\t{Region: \"Bangladesh\", Group: \"Premium TCP Asia\", Hostname: \"96-1-bd.cg-dialup.net\", IPs: []net.IP{{84, 252, 93, 132}, {84, 252, 93, 133}, {84, 252, 93, 135}, {84, 252, 93, 138}, {84, 252, 93, 139}, {84, 252, 93, 141}, {84, 252, 93, 142}, {84, 252, 93, 143}, {84, 252, 93, 144}, {84, 252, 93, 145}}},\n\t\t{Region: \"Bangladesh\", Group: \"Premium UDP Asia\", Hostname: \"95-1-bd.cg-dialup.net\", IPs: []net.IP{{84, 252, 93, 131}, {84, 252, 93, 133}, {84, 252, 93, 134}, {84, 252, 93, 135}, {84, 252, 93, 136}, {84, 252, 93, 139}, {84, 252, 93, 140}, {84, 252, 93, 141}, {84, 252, 93, 143}, {84, 252, 93, 145}}},\n\t\t{Region: \"Belarus\", Group: \"Premium TCP Europe\", Hostname: \"97-1-by.cg-dialup.net\", IPs: []net.IP{{45, 132, 194, 5}, {45, 132, 194, 6}, {45, 132, 194, 23}, {45, 132, 194, 24}, {45, 132, 194, 25}, {45, 132, 194, 27}, {45, 132, 194, 30}, {45, 132, 194, 35}, {45, 132, 194, 44}, {45, 132, 194, 49}}},\n\t\t{Region: \"Belarus\", Group: \"Premium UDP Europe\", Hostname: \"87-1-by.cg-dialup.net\", IPs: []net.IP{{45, 132, 194, 6}, {45, 132, 194, 8}, {45, 132, 194, 9}, {45, 132, 194, 11}, {45, 132, 194, 15}, {45, 132, 194, 19}, {45, 132, 194, 20}, {45, 132, 194, 23}, {45, 132, 194, 24}, {45, 132, 194, 26}}},\n\t\t{Region: \"Belgium\", Group: \"Premium TCP Europe\", Hostname: \"97-1-be.cg-dialup.net\", IPs: []net.IP{{37, 120, 143, 165}, {37, 120, 143, 166}, {185, 210, 217, 10}, {185, 210, 217, 248}, {193, 9, 114, 211}, {193, 9, 114, 220}, {194, 110, 115, 195}, {194, 110, 115, 199}, {194, 110, 115, 205}, {194, 110, 115, 238}}},\n\t\t{Region: \"Belgium\", Group: \"Premium UDP Europe\", Hostname: \"87-1-be.cg-dialup.net\", IPs: []net.IP{{37, 120, 143, 163}, {37, 120, 143, 167}, {185, 210, 217, 9}, {185, 210, 217, 13}, {185, 210, 217, 55}, {185, 210, 217, 251}, {185, 232, 21, 120}, {194, 110, 115, 214}, {194, 110, 115, 218}, {194, 110, 115, 236}}},\n\t\t{Region: \"Bosnia and Herzegovina\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ba.cg-dialup.net\", IPs: []net.IP{{185, 99, 3, 57}, {185, 99, 3, 58}, {185, 99, 3, 72}, {185, 99, 3, 73}, {185, 99, 3, 74}, {185, 99, 3, 130}, {185, 99, 3, 131}, {185, 99, 3, 134}, {185, 99, 3, 135}, {185, 99, 3, 136}}},\n\t\t{Region: \"Bosnia and Herzegovina\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ba.cg-dialup.net\", IPs: []net.IP{{185, 99, 3, 57}, {185, 99, 3, 58}, {185, 99, 3, 72}, {185, 99, 3, 73}, {185, 99, 3, 74}, {185, 99, 3, 130}, {185, 99, 3, 131}, {185, 99, 3, 134}, {185, 99, 3, 135}, {185, 99, 3, 136}}},\n\t\t{Region: \"Brazil\", Group: \"Premium TCP USA\", Hostname: \"93-1-br.cg-dialup.net\", IPs: []net.IP{{188, 241, 177, 5}, {188, 241, 177, 11}, {188, 241, 177, 38}, {188, 241, 177, 45}, {188, 241, 177, 132}, {188, 241, 177, 135}, {188, 241, 177, 136}, {188, 241, 177, 152}, {188, 241, 177, 153}, {188, 241, 177, 156}}},\n\t\t{Region: \"Brazil\", Group: \"Premium UDP USA\", Hostname: \"94-1-br.cg-dialup.net\", IPs: []net.IP{{188, 241, 177, 8}, {188, 241, 177, 37}, {188, 241, 177, 40}, {188, 241, 177, 42}, {188, 241, 177, 45}, {188, 241, 177, 135}, {188, 241, 177, 139}, {188, 241, 177, 149}, {188, 241, 177, 152}, {188, 241, 177, 154}}},\n\t\t{Region: \"Bulgaria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-bg.cg-dialup.net\", IPs: []net.IP{{37, 120, 152, 99}, {37, 120, 152, 101}, {37, 120, 152, 103}, {37, 120, 152, 104}, {37, 120, 152, 105}, {37, 120, 152, 106}, {37, 120, 152, 107}, {37, 120, 152, 108}, {37, 120, 152, 109}, {37, 120, 152, 110}}},\n\t\t{Region: \"Bulgaria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-bg.cg-dialup.net\", IPs: []net.IP{{37, 120, 152, 99}, {37, 120, 152, 100}, {37, 120, 152, 101}, {37, 120, 152, 102}, {37, 120, 152, 103}, {37, 120, 152, 105}, {37, 120, 152, 106}, {37, 120, 152, 107}, {37, 120, 152, 108}, {37, 120, 152, 109}}},\n\t\t{Region: \"Cambodia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-kh.cg-dialup.net\", IPs: []net.IP{{188, 215, 235, 35}, {188, 215, 235, 36}, {188, 215, 235, 38}, {188, 215, 235, 39}, {188, 215, 235, 45}, {188, 215, 235, 49}, {188, 215, 235, 51}, {188, 215, 235, 53}, {188, 215, 235, 54}, {188, 215, 235, 57}}},\n\t\t{Region: \"Cambodia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-kh.cg-dialup.net\", IPs: []net.IP{{188, 215, 235, 36}, {188, 215, 235, 40}, {188, 215, 235, 42}, {188, 215, 235, 44}, {188, 215, 235, 46}, {188, 215, 235, 47}, {188, 215, 235, 48}, {188, 215, 235, 50}, {188, 215, 235, 55}, {188, 215, 235, 57}}},\n\t\t{Region: \"Canada\", Group: \"Premium TCP USA\", Hostname: \"93-1-ca.cg-dialup.net\", IPs: []net.IP{{66, 115, 142, 136}, {66, 115, 142, 139}, {66, 115, 142, 156}, {66, 115, 142, 162}, {66, 115, 142, 172}, {104, 200, 151, 99}, {104, 200, 151, 111}, {104, 200, 151, 153}, {104, 200, 151, 164}, {172, 98, 89, 137}}},\n\t\t{Region: \"Canada\", Group: \"Premium UDP USA\", Hostname: \"94-1-ca.cg-dialup.net\", IPs: []net.IP{{66, 115, 142, 135}, {66, 115, 142, 154}, {66, 115, 142, 165}, {104, 200, 151, 32}, {104, 200, 151, 57}, {104, 200, 151, 85}, {104, 200, 151, 86}, {104, 200, 151, 147}, {172, 98, 89, 144}, {172, 98, 89, 173}}},\n\t\t{Region: \"Chile\", Group: \"Premium TCP USA\", Hostname: \"93-1-cl.cg-dialup.net\", IPs: []net.IP{{146, 70, 11, 3}, {146, 70, 11, 6}, {146, 70, 11, 7}, {146, 70, 11, 8}, {146, 70, 11, 9}, {146, 70, 11, 10}, {146, 70, 11, 11}, {146, 70, 11, 12}, {146, 70, 11, 13}, {146, 70, 11, 14}}},\n\t\t{Region: \"Chile\", Group: \"Premium UDP USA\", Hostname: \"94-1-cl.cg-dialup.net\", IPs: []net.IP{{146, 70, 11, 3}, {146, 70, 11, 4}, {146, 70, 11, 6}, {146, 70, 11, 7}, {146, 70, 11, 8}, {146, 70, 11, 9}, {146, 70, 11, 10}, {146, 70, 11, 11}, {146, 70, 11, 13}, {146, 70, 11, 14}}},\n\t\t{Region: \"China\", Group: \"Premium TCP Asia\", Hostname: \"96-1-cn.cg-dialup.net\", IPs: []net.IP{{188, 241, 80, 131}, {188, 241, 80, 132}, {188, 241, 80, 133}, {188, 241, 80, 134}, {188, 241, 80, 135}, {188, 241, 80, 137}, {188, 241, 80, 139}, {188, 241, 80, 140}, {188, 241, 80, 141}, {188, 241, 80, 142}}},\n\t\t{Region: \"China\", Group: \"Premium UDP Asia\", Hostname: \"95-1-cn.cg-dialup.net\", IPs: []net.IP{{188, 241, 80, 131}, {188, 241, 80, 132}, {188, 241, 80, 133}, {188, 241, 80, 134}, {188, 241, 80, 135}, {188, 241, 80, 136}, {188, 241, 80, 137}, {188, 241, 80, 138}, {188, 241, 80, 139}, {188, 241, 80, 142}}},\n\t\t{Region: \"Colombia\", Group: \"Premium TCP USA\", Hostname: \"93-1-co.cg-dialup.net\", IPs: []net.IP{{146, 70, 9, 3}, {146, 70, 9, 4}, {146, 70, 9, 5}, {146, 70, 9, 7}, {146, 70, 9, 9}, {146, 70, 9, 10}, {146, 70, 9, 11}, {146, 70, 9, 12}, {146, 70, 9, 13}, {146, 70, 9, 14}}},\n\t\t{Region: \"Colombia\", Group: \"Premium UDP USA\", Hostname: \"94-1-co.cg-dialup.net\", IPs: []net.IP{{146, 70, 9, 3}, {146, 70, 9, 4}, {146, 70, 9, 5}, {146, 70, 9, 6}, {146, 70, 9, 7}, {146, 70, 9, 8}, {146, 70, 9, 9}, {146, 70, 9, 10}, {146, 70, 9, 11}, {146, 70, 9, 12}}},\n\t\t{Region: \"Costa Rica\", Group: \"Premium TCP USA\", Hostname: \"93-1-cr.cg-dialup.net\", IPs: []net.IP{{146, 70, 10, 3}, {146, 70, 10, 4}, {146, 70, 10, 5}, {146, 70, 10, 6}, {146, 70, 10, 7}, {146, 70, 10, 8}, {146, 70, 10, 10}, {146, 70, 10, 11}, {146, 70, 10, 12}, {146, 70, 10, 13}}},\n\t\t{Region: \"Costa Rica\", Group: \"Premium UDP USA\", Hostname: \"94-1-cr.cg-dialup.net\", IPs: []net.IP{{146, 70, 10, 3}, {146, 70, 10, 4}, {146, 70, 10, 5}, {146, 70, 10, 6}, {146, 70, 10, 7}, {146, 70, 10, 8}, {146, 70, 10, 9}, {146, 70, 10, 11}, {146, 70, 10, 12}, {146, 70, 10, 14}}},\n\t\t{Region: \"Croatia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-hr.cg-dialup.net\", IPs: []net.IP{{146, 70, 8, 5}, {146, 70, 8, 8}, {146, 70, 8, 9}, {146, 70, 8, 10}, {146, 70, 8, 11}, {146, 70, 8, 12}, {146, 70, 8, 13}, {146, 70, 8, 14}, {146, 70, 8, 15}, {146, 70, 8, 16}}},\n\t\t{Region: \"Croatia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-hr.cg-dialup.net\", IPs: []net.IP{{146, 70, 8, 3}, {146, 70, 8, 4}, {146, 70, 8, 5}, {146, 70, 8, 6}, {146, 70, 8, 7}, {146, 70, 8, 9}, {146, 70, 8, 11}, {146, 70, 8, 13}, {146, 70, 8, 14}, {146, 70, 8, 16}}},\n\t\t{Region: \"Cyprus\", Group: \"Premium TCP Europe\", Hostname: \"97-1-cy.cg-dialup.net\", IPs: []net.IP{{185, 253, 162, 131}, {185, 253, 162, 133}, {185, 253, 162, 135}, {185, 253, 162, 136}, {185, 253, 162, 137}, {185, 253, 162, 139}, {185, 253, 162, 140}, {185, 253, 162, 142}, {185, 253, 162, 143}, {185, 253, 162, 144}}},\n\t\t{Region: \"Cyprus\", Group: \"Premium UDP Europe\", Hostname: \"87-1-cy.cg-dialup.net\", IPs: []net.IP{{185, 253, 162, 131}, {185, 253, 162, 132}, {185, 253, 162, 134}, {185, 253, 162, 135}, {185, 253, 162, 137}, {185, 253, 162, 138}, {185, 253, 162, 140}, {185, 253, 162, 142}, {185, 253, 162, 143}, {185, 253, 162, 144}}},\n\t\t{Region: \"Czech Republic\", Group: \"Premium TCP Europe\", Hostname: \"97-1-cz.cg-dialup.net\", IPs: []net.IP{{138, 199, 56, 235}, {138, 199, 56, 236}, {138, 199, 56, 237}, {138, 199, 56, 245}, {138, 199, 56, 246}, {138, 199, 56, 249}, {195, 181, 161, 12}, {195, 181, 161, 16}, {195, 181, 161, 20}, {195, 181, 161, 23}}},\n\t\t{Region: \"Czech Republic\", Group: \"Premium UDP Europe\", Hostname: \"87-1-cz.cg-dialup.net\", IPs: []net.IP{{138, 199, 56, 227}, {138, 199, 56, 229}, {138, 199, 56, 231}, {138, 199, 56, 235}, {138, 199, 56, 241}, {138, 199, 56, 247}, {195, 181, 161, 10}, {195, 181, 161, 16}, {195, 181, 161, 18}, {195, 181, 161, 22}}},\n\t\t{Region: \"Denmark\", Group: \"Premium TCP Europe\", Hostname: \"97-1-dk.cg-dialup.net\", IPs: []net.IP{{37, 120, 145, 83}, {37, 120, 145, 88}, {37, 120, 145, 93}, {37, 120, 194, 36}, {37, 120, 194, 56}, {37, 120, 194, 57}, {95, 174, 65, 163}, {95, 174, 65, 174}, {185, 206, 224, 238}, {185, 206, 224, 243}}},\n\t\t{Region: \"Denmark\", Group: \"Premium UDP Europe\", Hostname: \"87-1-dk.cg-dialup.net\", IPs: []net.IP{{37, 120, 194, 39}, {95, 174, 65, 167}, {95, 174, 65, 170}, {185, 206, 224, 227}, {185, 206, 224, 230}, {185, 206, 224, 236}, {185, 206, 224, 238}, {185, 206, 224, 245}, {185, 206, 224, 250}, {185, 206, 224, 254}}},\n\t\t{Region: \"Egypt\", Group: \"Premium TCP Europe\", Hostname: \"97-1-eg.cg-dialup.net\", IPs: []net.IP{{188, 214, 122, 40}, {188, 214, 122, 42}, {188, 214, 122, 43}, {188, 214, 122, 45}, {188, 214, 122, 48}, {188, 214, 122, 50}, {188, 214, 122, 52}, {188, 214, 122, 60}, {188, 214, 122, 70}, {188, 214, 122, 73}}},\n\t\t{Region: \"Egypt\", Group: \"Premium UDP Europe\", Hostname: \"87-1-eg.cg-dialup.net\", IPs: []net.IP{{188, 214, 122, 37}, {188, 214, 122, 38}, {188, 214, 122, 44}, {188, 214, 122, 54}, {188, 214, 122, 57}, {188, 214, 122, 59}, {188, 214, 122, 60}, {188, 214, 122, 61}, {188, 214, 122, 67}, {188, 214, 122, 69}}},\n\t\t{Region: \"Estonia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ee.cg-dialup.net\", IPs: []net.IP{{95, 153, 32, 83}, {95, 153, 32, 84}, {95, 153, 32, 86}, {95, 153, 32, 88}, {95, 153, 32, 89}, {95, 153, 32, 90}, {95, 153, 32, 91}, {95, 153, 32, 92}, {95, 153, 32, 93}, {95, 153, 32, 94}}},\n\t\t{Region: \"Estonia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ee.cg-dialup.net\", IPs: []net.IP{{95, 153, 32, 83}, {95, 153, 32, 84}, {95, 153, 32, 85}, {95, 153, 32, 87}, {95, 153, 32, 88}, {95, 153, 32, 89}, {95, 153, 32, 90}, {95, 153, 32, 91}, {95, 153, 32, 92}, {95, 153, 32, 94}}},\n\t\t{Region: \"Finland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-fi.cg-dialup.net\", IPs: []net.IP{{188, 126, 89, 99}, {188, 126, 89, 102}, {188, 126, 89, 105}, {188, 126, 89, 107}, {188, 126, 89, 108}, {188, 126, 89, 110}, {188, 126, 89, 112}, {188, 126, 89, 115}, {188, 126, 89, 116}, {188, 126, 89, 119}}},\n\t\t{Region: \"Finland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-fi.cg-dialup.net\", IPs: []net.IP{{188, 126, 89, 101}, {188, 126, 89, 104}, {188, 126, 89, 109}, {188, 126, 89, 110}, {188, 126, 89, 111}, {188, 126, 89, 113}, {188, 126, 89, 114}, {188, 126, 89, 115}, {188, 126, 89, 122}, {188, 126, 89, 124}}},\n\t\t{Region: \"France\", Group: \"Premium TCP Europe\", Hostname: \"97-1-fr.cg-dialup.net\", IPs: []net.IP{{84, 17, 43, 167}, {84, 17, 60, 147}, {84, 17, 60, 155}, {151, 106, 8, 108}, {191, 101, 31, 202}, {191, 101, 31, 254}, {191, 101, 217, 45}, {191, 101, 217, 159}, {191, 101, 217, 211}, {191, 101, 217, 240}}},\n\t\t{Region: \"France\", Group: \"Premium UDP Europe\", Hostname: \"87-1-fr.cg-dialup.net\", IPs: []net.IP{{84, 17, 60, 59}, {84, 17, 60, 121}, {191, 101, 31, 81}, {191, 101, 31, 84}, {191, 101, 31, 126}, {191, 101, 31, 127}, {191, 101, 217, 140}, {191, 101, 217, 201}, {191, 101, 217, 206}, {191, 101, 217, 211}}},\n\t\t{Region: \"Georgia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ge.cg-dialup.net\", IPs: []net.IP{{95, 181, 236, 131}, {95, 181, 236, 132}, {95, 181, 236, 133}, {95, 181, 236, 134}, {95, 181, 236, 135}, {95, 181, 236, 136}, {95, 181, 236, 138}, {95, 181, 236, 139}, {95, 181, 236, 142}, {95, 181, 236, 144}}},\n\t\t{Region: \"Georgia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ge.cg-dialup.net\", IPs: []net.IP{{95, 181, 236, 132}, {95, 181, 236, 133}, {95, 181, 236, 134}, {95, 181, 236, 136}, {95, 181, 236, 137}, {95, 181, 236, 139}, {95, 181, 236, 141}, {95, 181, 236, 142}, {95, 181, 236, 143}, {95, 181, 236, 144}}},\n\t\t{Region: \"Germany\", Group: \"Premium TCP Europe\", Hostname: \"97-1-de.cg-dialup.net\", IPs: []net.IP{{84, 17, 48, 39}, {84, 17, 48, 234}, {84, 17, 49, 106}, {84, 17, 49, 112}, {84, 17, 49, 218}, {154, 28, 188, 35}, {154, 28, 188, 66}, {154, 28, 188, 133}, {154, 28, 188, 144}, {154, 28, 188, 145}}},\n\t\t{Region: \"Germany\", Group: \"Premium UDP Europe\", Hostname: \"87-1-de.cg-dialup.net\", IPs: []net.IP{{84, 17, 48, 41}, {84, 17, 48, 224}, {84, 17, 49, 95}, {84, 17, 49, 236}, {84, 17, 49, 241}, {138, 199, 36, 151}, {154, 13, 1, 177}, {154, 28, 188, 73}, {154, 28, 188, 76}, {154, 28, 188, 93}}},\n\t\t{Region: \"Greece\", Group: \"Premium TCP Europe\", Hostname: \"97-1-gr.cg-dialup.net\", IPs: []net.IP{{185, 51, 134, 163}, {185, 51, 134, 165}, {185, 51, 134, 171}, {185, 51, 134, 172}, {185, 51, 134, 245}, {185, 51, 134, 246}, {185, 51, 134, 247}, {185, 51, 134, 249}, {185, 51, 134, 251}, {185, 51, 134, 254}}},\n\t\t{Region: \"Greece\", Group: \"Premium UDP Europe\", Hostname: \"87-1-gr.cg-dialup.net\", IPs: []net.IP{{185, 51, 134, 163}, {185, 51, 134, 166}, {185, 51, 134, 173}, {185, 51, 134, 174}, {185, 51, 134, 244}, {185, 51, 134, 246}, {185, 51, 134, 247}, {185, 51, 134, 251}, {185, 51, 134, 252}, {185, 51, 134, 253}}},\n\t\t{Region: \"Greenland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-gl.cg-dialup.net\", IPs: []net.IP{{91, 90, 120, 3}, {91, 90, 120, 4}, {91, 90, 120, 5}, {91, 90, 120, 7}, {91, 90, 120, 8}, {91, 90, 120, 10}, {91, 90, 120, 12}, {91, 90, 120, 13}, {91, 90, 120, 14}, {91, 90, 120, 17}}},\n\t\t{Region: \"Greenland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-gl.cg-dialup.net\", IPs: []net.IP{{91, 90, 120, 3}, {91, 90, 120, 4}, {91, 90, 120, 5}, {91, 90, 120, 7}, {91, 90, 120, 9}, {91, 90, 120, 10}, {91, 90, 120, 12}, {91, 90, 120, 14}, {91, 90, 120, 15}, {91, 90, 120, 16}}},\n\t\t{Region: \"Hong Kong\", Group: \"Premium TCP Asia\", Hostname: \"96-1-hk.cg-dialup.net\", IPs: []net.IP{{84, 17, 56, 144}, {84, 17, 56, 148}, {84, 17, 56, 153}, {84, 17, 56, 162}, {84, 17, 56, 163}, {84, 17, 56, 169}, {84, 17, 56, 170}, {84, 17, 56, 179}, {84, 17, 56, 180}, {84, 17, 56, 181}}},\n\t\t{Region: \"Hong Kong\", Group: \"Premium UDP Asia\", Hostname: \"95-1-hk.cg-dialup.net\", IPs: []net.IP{{84, 17, 56, 143}, {84, 17, 56, 147}, {84, 17, 56, 150}, {84, 17, 56, 152}, {84, 17, 56, 161}, {84, 17, 56, 164}, {84, 17, 56, 168}, {84, 17, 56, 179}, {84, 17, 56, 180}, {84, 17, 56, 183}}},\n\t\t{Region: \"Hungary\", Group: \"Premium TCP Europe\", Hostname: \"97-1-hu.cg-dialup.net\", IPs: []net.IP{{86, 106, 74, 247}, {86, 106, 74, 251}, {86, 106, 74, 253}, {185, 189, 114, 117}, {185, 189, 114, 118}, {185, 189, 114, 119}, {185, 189, 114, 121}, {185, 189, 114, 123}, {185, 189, 114, 125}, {185, 189, 114, 126}}},\n\t\t{Region: \"Hungary\", Group: \"Premium UDP Europe\", Hostname: \"87-1-hu.cg-dialup.net\", IPs: []net.IP{{86, 106, 74, 245}, {86, 106, 74, 247}, {86, 106, 74, 248}, {86, 106, 74, 249}, {86, 106, 74, 250}, {86, 106, 74, 252}, {86, 106, 74, 253}, {185, 189, 114, 120}, {185, 189, 114, 121}, {185, 189, 114, 122}}},\n\t\t{Region: \"Iceland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-is.cg-dialup.net\", IPs: []net.IP{{45, 133, 193, 3}, {45, 133, 193, 4}, {45, 133, 193, 6}, {45, 133, 193, 7}, {45, 133, 193, 8}, {45, 133, 193, 10}, {45, 133, 193, 11}, {45, 133, 193, 12}, {45, 133, 193, 13}, {45, 133, 193, 14}}},\n\t\t{Region: \"Iceland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-is.cg-dialup.net\", IPs: []net.IP{{45, 133, 193, 3}, {45, 133, 193, 5}, {45, 133, 193, 6}, {45, 133, 193, 7}, {45, 133, 193, 8}, {45, 133, 193, 9}, {45, 133, 193, 10}, {45, 133, 193, 11}, {45, 133, 193, 13}, {45, 133, 193, 14}}},\n\t\t{Region: \"India\", Group: \"Premium TCP Europe\", Hostname: \"97-1-in.cg-dialup.net\", IPs: []net.IP{{103, 13, 112, 68}, {103, 13, 112, 70}, {103, 13, 112, 72}, {103, 13, 112, 74}, {103, 13, 112, 75}, {103, 13, 113, 74}, {103, 13, 113, 79}, {103, 13, 113, 82}, {103, 13, 113, 83}, {103, 13, 113, 84}}},\n\t\t{Region: \"India\", Group: \"Premium UDP Europe\", Hostname: \"87-1-in.cg-dialup.net\", IPs: []net.IP{{103, 13, 112, 67}, {103, 13, 112, 70}, {103, 13, 112, 71}, {103, 13, 112, 77}, {103, 13, 112, 80}, {103, 13, 113, 72}, {103, 13, 113, 74}, {103, 13, 113, 75}, {103, 13, 113, 77}, {103, 13, 113, 85}}},\n\t\t{Region: \"Indonesia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-id.cg-dialup.net\", IPs: []net.IP{{146, 70, 14, 3}, {146, 70, 14, 4}, {146, 70, 14, 5}, {146, 70, 14, 6}, {146, 70, 14, 7}, {146, 70, 14, 10}, {146, 70, 14, 12}, {146, 70, 14, 13}, {146, 70, 14, 15}, {146, 70, 14, 16}}},\n\t\t{Region: \"Indonesia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-id.cg-dialup.net\", IPs: []net.IP{{146, 70, 14, 3}, {146, 70, 14, 5}, {146, 70, 14, 8}, {146, 70, 14, 9}, {146, 70, 14, 10}, {146, 70, 14, 12}, {146, 70, 14, 13}, {146, 70, 14, 14}, {146, 70, 14, 15}, {146, 70, 14, 16}}},\n\t\t{Region: \"Iran\", Group: \"Premium TCP Asia\", Hostname: \"96-1-ir.cg-dialup.net\", IPs: []net.IP{{62, 133, 46, 3}, {62, 133, 46, 4}, {62, 133, 46, 5}, {62, 133, 46, 6}, {62, 133, 46, 7}, {62, 133, 46, 8}, {62, 133, 46, 9}, {62, 133, 46, 10}, {62, 133, 46, 14}, {62, 133, 46, 15}}},\n\t\t{Region: \"Iran\", Group: \"Premium UDP Asia\", Hostname: \"95-1-ir.cg-dialup.net\", IPs: []net.IP{{62, 133, 46, 3}, {62, 133, 46, 4}, {62, 133, 46, 7}, {62, 133, 46, 8}, {62, 133, 46, 11}, {62, 133, 46, 12}, {62, 133, 46, 13}, {62, 133, 46, 14}, {62, 133, 46, 15}, {62, 133, 46, 16}}},\n\t\t{Region: \"Ireland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ie.cg-dialup.net\", IPs: []net.IP{{37, 120, 235, 154}, {37, 120, 235, 166}, {37, 120, 235, 174}, {77, 81, 139, 35}, {84, 247, 48, 6}, {84, 247, 48, 19}, {84, 247, 48, 22}, {84, 247, 48, 23}, {84, 247, 48, 25}, {84, 247, 48, 26}}},\n\t\t{Region: \"Ireland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ie.cg-dialup.net\", IPs: []net.IP{{37, 120, 235, 147}, {37, 120, 235, 148}, {37, 120, 235, 153}, {37, 120, 235, 158}, {37, 120, 235, 169}, {37, 120, 235, 174}, {84, 247, 48, 8}, {84, 247, 48, 11}, {84, 247, 48, 20}, {84, 247, 48, 23}}},\n\t\t{Region: \"Isle of Man\", Group: \"Premium TCP Europe\", Hostname: \"97-1-im.cg-dialup.net\", IPs: []net.IP{{91, 90, 124, 147}, {91, 90, 124, 149}, {91, 90, 124, 150}, {91, 90, 124, 151}, {91, 90, 124, 152}, {91, 90, 124, 153}, {91, 90, 124, 154}, {91, 90, 124, 156}, {91, 90, 124, 157}, {91, 90, 124, 158}}},\n\t\t{Region: \"Isle of Man\", Group: \"Premium UDP Europe\", Hostname: \"87-1-im.cg-dialup.net\", IPs: []net.IP{{91, 90, 124, 147}, {91, 90, 124, 149}, {91, 90, 124, 150}, {91, 90, 124, 151}, {91, 90, 124, 152}, {91, 90, 124, 153}, {91, 90, 124, 154}, {91, 90, 124, 155}, {91, 90, 124, 156}, {91, 90, 124, 157}}},\n\t\t{Region: \"Israel\", Group: \"Premium TCP Europe\", Hostname: \"97-1-il.cg-dialup.net\", IPs: []net.IP{{160, 116, 0, 174}, {185, 77, 248, 103}, {185, 77, 248, 111}, {185, 77, 248, 113}, {185, 77, 248, 114}, {185, 77, 248, 124}, {185, 77, 248, 125}, {185, 77, 248, 127}, {185, 77, 248, 128}, {185, 77, 248, 129}}},\n\t\t{Region: \"Israel\", Group: \"Premium UDP Europe\", Hostname: \"87-1-il.cg-dialup.net\", IPs: []net.IP{{160, 116, 0, 163}, {160, 116, 0, 165}, {160, 116, 0, 172}, {185, 77, 248, 103}, {185, 77, 248, 106}, {185, 77, 248, 114}, {185, 77, 248, 117}, {185, 77, 248, 118}, {185, 77, 248, 126}, {185, 77, 248, 129}}},\n\t\t{Region: \"Italy\", Group: \"Premium TCP Europe\", Hostname: \"97-1-it.cg-dialup.net\", IPs: []net.IP{{84, 17, 58, 21}, {84, 17, 58, 100}, {84, 17, 58, 106}, {84, 17, 58, 111}, {84, 17, 58, 117}, {87, 101, 94, 122}, {212, 102, 55, 100}, {212, 102, 55, 106}, {212, 102, 55, 110}, {212, 102, 55, 122}}},\n\t\t{Region: \"Italy\", Group: \"Premium UDP Europe\", Hostname: \"87-1-it.cg-dialup.net\", IPs: []net.IP{{84, 17, 58, 19}, {84, 17, 58, 95}, {84, 17, 58, 105}, {84, 17, 58, 119}, {84, 17, 58, 120}, {87, 101, 94, 116}, {185, 217, 71, 137}, {185, 217, 71, 138}, {185, 217, 71, 153}, {212, 102, 55, 108}}},\n\t\t{Region: \"Japan\", Group: \"Premium TCP Asia\", Hostname: \"96-1-jp.cg-dialup.net\", IPs: []net.IP{{156, 146, 35, 6}, {156, 146, 35, 10}, {156, 146, 35, 15}, {156, 146, 35, 22}, {156, 146, 35, 37}, {156, 146, 35, 39}, {156, 146, 35, 40}, {156, 146, 35, 41}, {156, 146, 35, 44}, {156, 146, 35, 50}}},\n\t\t{Region: \"Japan\", Group: \"Premium UDP Asia\", Hostname: \"95-1-jp.cg-dialup.net\", IPs: []net.IP{{156, 146, 35, 4}, {156, 146, 35, 14}, {156, 146, 35, 15}, {156, 146, 35, 18}, {156, 146, 35, 25}, {156, 146, 35, 34}, {156, 146, 35, 36}, {156, 146, 35, 46}, {156, 146, 35, 49}, {156, 146, 35, 50}}},\n\t\t{Region: \"Kazakhstan\", Group: \"Premium TCP Europe\", Hostname: \"97-1-kz.cg-dialup.net\", IPs: []net.IP{{62, 133, 47, 131}, {62, 133, 47, 132}, {62, 133, 47, 134}, {62, 133, 47, 136}, {62, 133, 47, 138}, {62, 133, 47, 139}, {62, 133, 47, 140}, {62, 133, 47, 142}, {62, 133, 47, 143}, {62, 133, 47, 144}}},\n\t\t{Region: \"Kazakhstan\", Group: \"Premium UDP Europe\", Hostname: \"87-1-kz.cg-dialup.net\", IPs: []net.IP{{62, 133, 47, 131}, {62, 133, 47, 132}, {62, 133, 47, 133}, {62, 133, 47, 134}, {62, 133, 47, 135}, {62, 133, 47, 138}, {62, 133, 47, 139}, {62, 133, 47, 140}, {62, 133, 47, 142}, {62, 133, 47, 143}}},\n\t\t{Region: \"Kenya\", Group: \"Premium TCP Asia\", Hostname: \"96-1-ke.cg-dialup.net\", IPs: []net.IP{{62, 12, 118, 195}, {62, 12, 118, 196}, {62, 12, 118, 197}, {62, 12, 118, 198}, {62, 12, 118, 199}, {62, 12, 118, 200}, {62, 12, 118, 201}, {62, 12, 118, 202}, {62, 12, 118, 203}, {62, 12, 118, 204}}},\n\t\t{Region: \"Kenya\", Group: \"Premium UDP Asia\", Hostname: \"95-1-ke.cg-dialup.net\", IPs: []net.IP{{62, 12, 118, 195}, {62, 12, 118, 196}, {62, 12, 118, 197}, {62, 12, 118, 198}, {62, 12, 118, 199}, {62, 12, 118, 200}, {62, 12, 118, 201}, {62, 12, 118, 202}, {62, 12, 118, 203}, {62, 12, 118, 204}}},\n\t\t{Region: \"Korea\", Group: \"Premium TCP Asia\", Hostname: \"96-1-kr.cg-dialup.net\", IPs: []net.IP{{79, 110, 55, 131}, {79, 110, 55, 134}, {79, 110, 55, 141}, {79, 110, 55, 147}, {79, 110, 55, 148}, {79, 110, 55, 151}, {79, 110, 55, 152}, {79, 110, 55, 153}, {79, 110, 55, 155}, {79, 110, 55, 157}}},\n\t\t{Region: \"Korea\", Group: \"Premium UDP Asia\", Hostname: \"95-1-kr.cg-dialup.net\", IPs: []net.IP{{79, 110, 55, 131}, {79, 110, 55, 133}, {79, 110, 55, 134}, {79, 110, 55, 136}, {79, 110, 55, 138}, {79, 110, 55, 140}, {79, 110, 55, 149}, {79, 110, 55, 151}, {79, 110, 55, 152}, {79, 110, 55, 157}}},\n\t\t{Region: \"Latvia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-lv.cg-dialup.net\", IPs: []net.IP{{109, 248, 148, 244}, {109, 248, 148, 245}, {109, 248, 148, 246}, {109, 248, 148, 247}, {109, 248, 148, 249}, {109, 248, 148, 250}, {109, 248, 148, 253}, {109, 248, 149, 22}, {109, 248, 149, 24}, {109, 248, 149, 25}}},\n\t\t{Region: \"Latvia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lv.cg-dialup.net\", IPs: []net.IP{{109, 248, 148, 248}, {109, 248, 148, 250}, {109, 248, 148, 254}, {109, 248, 149, 19}, {109, 248, 149, 20}, {109, 248, 149, 22}, {109, 248, 149, 24}, {109, 248, 149, 26}, {109, 248, 149, 28}, {109, 248, 149, 30}}},\n\t\t{Region: \"Liechtenstein\", Group: \"Premium UDP Europe\", Hostname: \"87-1-li.cg-dialup.net\", IPs: []net.IP{{91, 90, 122, 131}, {91, 90, 122, 134}, {91, 90, 122, 137}, {91, 90, 122, 138}, {91, 90, 122, 139}, {91, 90, 122, 140}, {91, 90, 122, 141}, {91, 90, 122, 142}, {91, 90, 122, 144}, {91, 90, 122, 145}}},\n\t\t{Region: \"Lithuania\", Group: \"Premium TCP Europe\", Hostname: \"97-1-lt.cg-dialup.net\", IPs: []net.IP{{85, 206, 162, 212}, {85, 206, 162, 215}, {85, 206, 162, 219}, {85, 206, 162, 222}, {85, 206, 165, 17}, {85, 206, 165, 23}, {85, 206, 165, 25}, {85, 206, 165, 26}, {85, 206, 165, 30}, {85, 206, 165, 31}}},\n\t\t{Region: \"Lithuania\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lt.cg-dialup.net\", IPs: []net.IP{{85, 206, 162, 209}, {85, 206, 162, 210}, {85, 206, 162, 211}, {85, 206, 162, 213}, {85, 206, 162, 214}, {85, 206, 162, 217}, {85, 206, 162, 218}, {85, 206, 162, 220}, {85, 206, 165, 26}, {85, 206, 165, 30}}},\n\t\t{Region: \"Luxembourg\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lu.cg-dialup.net\", IPs: []net.IP{{5, 253, 204, 7}, {5, 253, 204, 10}, {5, 253, 204, 12}, {5, 253, 204, 23}, {5, 253, 204, 26}, {5, 253, 204, 30}, {5, 253, 204, 37}, {5, 253, 204, 39}, {5, 253, 204, 44}, {5, 253, 204, 45}}},\n\t\t{Region: \"Macao\", Group: \"Premium TCP Asia\", Hostname: \"96-1-mo.cg-dialup.net\", IPs: []net.IP{{84, 252, 92, 131}, {84, 252, 92, 133}, {84, 252, 92, 135}, {84, 252, 92, 137}, {84, 252, 92, 138}, {84, 252, 92, 139}, {84, 252, 92, 141}, {84, 252, 92, 142}, {84, 252, 92, 144}, {84, 252, 92, 145}}},\n\t\t{Region: \"Macao\", Group: \"Premium UDP Asia\", Hostname: \"95-1-mo.cg-dialup.net\", IPs: []net.IP{{84, 252, 92, 132}, {84, 252, 92, 134}, {84, 252, 92, 135}, {84, 252, 92, 136}, {84, 252, 92, 137}, {84, 252, 92, 139}, {84, 252, 92, 141}, {84, 252, 92, 143}, {84, 252, 92, 144}, {84, 252, 92, 145}}},\n\t\t{Region: \"Macedonia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-mk.cg-dialup.net\", IPs: []net.IP{{185, 225, 28, 3}, {185, 225, 28, 4}, {185, 225, 28, 5}, {185, 225, 28, 6}, {185, 225, 28, 7}, {185, 225, 28, 8}, {185, 225, 28, 9}, {185, 225, 28, 10}, {185, 225, 28, 11}, {185, 225, 28, 12}}},\n\t\t{Region: \"Macedonia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-mk.cg-dialup.net\", IPs: []net.IP{{185, 225, 28, 3}, {185, 225, 28, 4}, {185, 225, 28, 5}, {185, 225, 28, 6}, {185, 225, 28, 7}, {185, 225, 28, 8}, {185, 225, 28, 9}, {185, 225, 28, 10}, {185, 225, 28, 11}, {185, 225, 28, 12}}},\n\t\t{Region: \"Malaysia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-my.cg-dialup.net\", IPs: []net.IP{{146, 70, 15, 4}, {146, 70, 15, 6}, {146, 70, 15, 8}, {146, 70, 15, 9}, {146, 70, 15, 10}, {146, 70, 15, 11}, {146, 70, 15, 12}, {146, 70, 15, 13}, {146, 70, 15, 15}, {146, 70, 15, 16}}},\n\t\t{Region: \"Malaysia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-my.cg-dialup.net\", IPs: []net.IP{{146, 70, 15, 3}, {146, 70, 15, 4}, {146, 70, 15, 5}, {146, 70, 15, 6}, {146, 70, 15, 7}, {146, 70, 15, 8}, {146, 70, 15, 10}, {146, 70, 15, 12}, {146, 70, 15, 15}, {146, 70, 15, 16}}},\n\t\t{Region: \"Malta\", Group: \"Premium TCP Europe\", Hostname: \"97-1-mt.cg-dialup.net\", IPs: []net.IP{{176, 125, 230, 133}, {176, 125, 230, 135}, {176, 125, 230, 136}, {176, 125, 230, 137}, {176, 125, 230, 138}, {176, 125, 230, 140}, {176, 125, 230, 142}, {176, 125, 230, 143}, {176, 125, 230, 144}, {176, 125, 230, 145}}},\n\t\t{Region: \"Malta\", Group: \"Premium UDP Europe\", Hostname: \"87-1-mt.cg-dialup.net\", IPs: []net.IP{{176, 125, 230, 131}, {176, 125, 230, 133}, {176, 125, 230, 134}, {176, 125, 230, 136}, {176, 125, 230, 137}, {176, 125, 230, 138}, {176, 125, 230, 139}, {176, 125, 230, 140}, {176, 125, 230, 144}, {176, 125, 230, 145}}},\n\t\t{Region: \"Mexico\", Group: \"Premium TCP USA\", Hostname: \"93-1-mx.cg-dialup.net\", IPs: []net.IP{{77, 81, 142, 132}, {77, 81, 142, 134}, {77, 81, 142, 136}, {77, 81, 142, 139}, {77, 81, 142, 142}, {77, 81, 142, 154}, {77, 81, 142, 155}, {77, 81, 142, 157}, {77, 81, 142, 158}, {77, 81, 142, 159}}},\n\t\t{Region: \"Mexico\", Group: \"Premium UDP USA\", Hostname: \"94-1-mx.cg-dialup.net\", IPs: []net.IP{{77, 81, 142, 130}, {77, 81, 142, 131}, {77, 81, 142, 132}, {77, 81, 142, 139}, {77, 81, 142, 141}, {77, 81, 142, 142}, {77, 81, 142, 146}, {77, 81, 142, 147}, {77, 81, 142, 154}, {77, 81, 142, 159}}},\n\t\t{Region: \"Moldova\", Group: \"Premium TCP Europe\", Hostname: \"97-1-md.cg-dialup.net\", IPs: []net.IP{{178, 175, 130, 243}, {178, 175, 130, 244}, {178, 175, 130, 245}, {178, 175, 130, 246}, {178, 175, 130, 251}, {178, 175, 130, 254}, {178, 175, 142, 131}, {178, 175, 142, 132}, {178, 175, 142, 133}, {178, 175, 142, 134}}},\n\t\t{Region: \"Moldova\", Group: \"Premium UDP Europe\", Hostname: \"87-1-md.cg-dialup.net\", IPs: []net.IP{{178, 175, 130, 243}, {178, 175, 130, 244}, {178, 175, 130, 246}, {178, 175, 130, 250}, {178, 175, 130, 251}, {178, 175, 130, 253}, {178, 175, 130, 254}, {178, 175, 142, 132}, {178, 175, 142, 133}, {178, 175, 142, 134}}},\n\t\t{Region: \"Monaco\", Group: \"Premium TCP Europe\", Hostname: \"97-1-mc.cg-dialup.net\", IPs: []net.IP{{95, 181, 233, 131}, {95, 181, 233, 132}, {95, 181, 233, 133}, {95, 181, 233, 137}, {95, 181, 233, 138}, {95, 181, 233, 139}, {95, 181, 233, 140}, {95, 181, 233, 141}, {95, 181, 233, 143}, {95, 181, 233, 144}}},\n\t\t{Region: \"Monaco\", Group: \"Premium UDP Europe\", Hostname: \"87-1-mc.cg-dialup.net\", IPs: []net.IP{{95, 181, 233, 132}, {95, 181, 233, 135}, {95, 181, 233, 136}, {95, 181, 233, 137}, {95, 181, 233, 138}, {95, 181, 233, 139}, {95, 181, 233, 141}, {95, 181, 233, 142}, {95, 181, 233, 143}, {95, 181, 233, 144}}},\n\t\t{Region: \"Mongolia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-mn.cg-dialup.net\", IPs: []net.IP{{185, 253, 163, 132}, {185, 253, 163, 133}, {185, 253, 163, 135}, {185, 253, 163, 136}, {185, 253, 163, 139}, {185, 253, 163, 140}, {185, 253, 163, 141}, {185, 253, 163, 142}, {185, 253, 163, 143}, {185, 253, 163, 144}}},\n\t\t{Region: \"Mongolia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-mn.cg-dialup.net\", IPs: []net.IP{{185, 253, 163, 131}, {185, 253, 163, 133}, {185, 253, 163, 134}, {185, 253, 163, 137}, {185, 253, 163, 138}, {185, 253, 163, 139}, {185, 253, 163, 140}, {185, 253, 163, 141}, {185, 253, 163, 142}, {185, 253, 163, 144}}},\n\t\t{Region: \"Montenegro\", Group: \"Premium TCP Europe\", Hostname: \"97-1-me.cg-dialup.net\", IPs: []net.IP{{176, 125, 229, 131}, {176, 125, 229, 135}, {176, 125, 229, 137}, {176, 125, 229, 138}, {176, 125, 229, 140}, {176, 125, 229, 141}, {176, 125, 229, 142}, {176, 125, 229, 143}, {176, 125, 229, 144}, {176, 125, 229, 145}}},\n\t\t{Region: \"Montenegro\", Group: \"Premium UDP Europe\", Hostname: \"87-1-me.cg-dialup.net\", IPs: []net.IP{{176, 125, 229, 131}, {176, 125, 229, 134}, {176, 125, 229, 136}, {176, 125, 229, 137}, {176, 125, 229, 138}, {176, 125, 229, 139}, {176, 125, 229, 140}, {176, 125, 229, 141}, {176, 125, 229, 143}, {176, 125, 229, 144}}},\n\t\t{Region: \"Morocco\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ma.cg-dialup.net\", IPs: []net.IP{{95, 181, 232, 132}, {95, 181, 232, 133}, {95, 181, 232, 134}, {95, 181, 232, 136}, {95, 181, 232, 137}, {95, 181, 232, 138}, {95, 181, 232, 139}, {95, 181, 232, 140}, {95, 181, 232, 141}, {95, 181, 232, 144}}},\n\t\t{Region: \"Morocco\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ma.cg-dialup.net\", IPs: []net.IP{{95, 181, 232, 131}, {95, 181, 232, 132}, {95, 181, 232, 133}, {95, 181, 232, 135}, {95, 181, 232, 137}, {95, 181, 232, 139}, {95, 181, 232, 140}, {95, 181, 232, 141}, {95, 181, 232, 142}, {95, 181, 232, 143}}},\n\t\t{Region: \"Netherlands\", Group: \"Premium TCP Europe\", Hostname: \"97-1-nl.cg-dialup.net\", IPs: []net.IP{{84, 17, 47, 98}, {181, 214, 206, 22}, {181, 214, 206, 27}, {181, 214, 206, 36}, {195, 78, 54, 10}, {195, 78, 54, 20}, {195, 78, 54, 43}, {195, 78, 54, 50}, {195, 78, 54, 119}, {195, 181, 172, 78}}},\n\t\t{Region: \"Netherlands\", Group: \"Premium UDP Europe\", Hostname: \"87-1-nl.cg-dialup.net\", IPs: []net.IP{{84, 17, 47, 110}, {181, 214, 206, 29}, {181, 214, 206, 42}, {195, 78, 54, 8}, {195, 78, 54, 19}, {195, 78, 54, 47}, {195, 78, 54, 110}, {195, 78, 54, 141}, {195, 78, 54, 143}, {195, 78, 54, 157}}},\n\t\t{Region: \"New Zealand\", Group: \"Premium TCP Asia\", Hostname: \"96-1-nz.cg-dialup.net\", IPs: []net.IP{{43, 250, 207, 98}, {43, 250, 207, 99}, {43, 250, 207, 100}, {43, 250, 207, 101}, {43, 250, 207, 102}, {43, 250, 207, 103}, {43, 250, 207, 105}, {43, 250, 207, 106}, {43, 250, 207, 108}, {43, 250, 207, 109}}},\n\t\t{Region: \"New Zealand\", Group: \"Premium UDP Asia\", Hostname: \"95-1-nz.cg-dialup.net\", IPs: []net.IP{{43, 250, 207, 98}, {43, 250, 207, 99}, {43, 250, 207, 102}, {43, 250, 207, 104}, {43, 250, 207, 105}, {43, 250, 207, 106}, {43, 250, 207, 107}, {43, 250, 207, 108}, {43, 250, 207, 109}, {43, 250, 207, 110}}},\n\t\t{Region: \"Nigeria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ng.cg-dialup.net\", IPs: []net.IP{{102, 165, 25, 68}, {102, 165, 25, 69}, {102, 165, 25, 70}, {102, 165, 25, 71}, {102, 165, 25, 72}, {102, 165, 25, 73}, {102, 165, 25, 75}, {102, 165, 25, 76}, {102, 165, 25, 77}, {102, 165, 25, 78}}},\n\t\t{Region: \"Nigeria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ng.cg-dialup.net\", IPs: []net.IP{{102, 165, 25, 68}, {102, 165, 25, 69}, {102, 165, 25, 70}, {102, 165, 25, 71}, {102, 165, 25, 72}, {102, 165, 25, 74}, {102, 165, 25, 75}, {102, 165, 25, 76}, {102, 165, 25, 77}, {102, 165, 25, 78}}},\n\t\t{Region: \"Norway\", Group: \"Premium TCP Europe\", Hostname: \"97-1-no.cg-dialup.net\", IPs: []net.IP{{45, 12, 223, 137}, {45, 12, 223, 140}, {185, 206, 225, 29}, {185, 206, 225, 231}, {185, 253, 97, 234}, {185, 253, 97, 236}, {185, 253, 97, 238}, {185, 253, 97, 244}, {185, 253, 97, 250}, {185, 253, 97, 254}}},\n\t\t{Region: \"Norway\", Group: \"Premium UDP Europe\", Hostname: \"87-1-no.cg-dialup.net\", IPs: []net.IP{{45, 12, 223, 133}, {45, 12, 223, 134}, {45, 12, 223, 142}, {185, 206, 225, 227}, {185, 206, 225, 228}, {185, 206, 225, 231}, {185, 206, 225, 235}, {185, 253, 97, 237}, {185, 253, 97, 246}, {185, 253, 97, 254}}},\n\t\t{Region: \"Pakistan\", Group: \"Premium TCP Asia\", Hostname: \"96-1-pk.cg-dialup.net\", IPs: []net.IP{{146, 70, 12, 3}, {146, 70, 12, 4}, {146, 70, 12, 6}, {146, 70, 12, 8}, {146, 70, 12, 9}, {146, 70, 12, 10}, {146, 70, 12, 11}, {146, 70, 12, 12}, {146, 70, 12, 13}, {146, 70, 12, 14}}},\n\t\t{Region: \"Pakistan\", Group: \"Premium UDP Asia\", Hostname: \"95-1-pk.cg-dialup.net\", IPs: []net.IP{{146, 70, 12, 4}, {146, 70, 12, 5}, {146, 70, 12, 6}, {146, 70, 12, 7}, {146, 70, 12, 8}, {146, 70, 12, 10}, {146, 70, 12, 11}, {146, 70, 12, 12}, {146, 70, 12, 13}, {146, 70, 12, 14}}},\n\t\t{Region: \"Panama\", Group: \"Premium TCP Europe\", Hostname: \"97-1-pa.cg-dialup.net\", IPs: []net.IP{{91, 90, 126, 131}, {91, 90, 126, 132}, {91, 90, 126, 133}, {91, 90, 126, 134}, {91, 90, 126, 136}, {91, 90, 126, 138}, {91, 90, 126, 139}, {91, 90, 126, 141}, {91, 90, 126, 142}, {91, 90, 126, 145}}},\n\t\t{Region: \"Panama\", Group: \"Premium UDP Europe\", Hostname: \"87-1-pa.cg-dialup.net\", IPs: []net.IP{{91, 90, 126, 131}, {91, 90, 126, 133}, {91, 90, 126, 134}, {91, 90, 126, 135}, {91, 90, 126, 136}, {91, 90, 126, 138}, {91, 90, 126, 140}, {91, 90, 126, 141}, {91, 90, 126, 142}, {91, 90, 126, 145}}},\n\t\t{Region: \"Philippines\", Group: \"Premium TCP Asia\", Hostname: \"96-1-ph.cg-dialup.net\", IPs: []net.IP{{188, 214, 125, 37}, {188, 214, 125, 38}, {188, 214, 125, 40}, {188, 214, 125, 43}, {188, 214, 125, 44}, {188, 214, 125, 45}, {188, 214, 125, 52}, {188, 214, 125, 55}, {188, 214, 125, 61}, {188, 214, 125, 62}}},\n\t\t{Region: \"Philippines\", Group: \"Premium UDP Asia\", Hostname: \"95-1-ph.cg-dialup.net\", IPs: []net.IP{{188, 214, 125, 37}, {188, 214, 125, 40}, {188, 214, 125, 46}, {188, 214, 125, 49}, {188, 214, 125, 52}, {188, 214, 125, 54}, {188, 214, 125, 57}, {188, 214, 125, 58}, {188, 214, 125, 61}, {188, 214, 125, 62}}},\n\t\t{Region: \"Poland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-pl.cg-dialup.net\", IPs: []net.IP{{138, 199, 59, 132}, {138, 199, 59, 136}, {138, 199, 59, 137}, {138, 199, 59, 143}, {138, 199, 59, 144}, {138, 199, 59, 152}, {138, 199, 59, 153}, {138, 199, 59, 166}, {138, 199, 59, 174}, {138, 199, 59, 175}}},\n\t\t{Region: \"Poland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-pl.cg-dialup.net\", IPs: []net.IP{{138, 199, 59, 130}, {138, 199, 59, 136}, {138, 199, 59, 148}, {138, 199, 59, 149}, {138, 199, 59, 153}, {138, 199, 59, 156}, {138, 199, 59, 157}, {138, 199, 59, 164}, {138, 199, 59, 171}, {138, 199, 59, 173}}},\n\t\t{Region: \"Portugal\", Group: \"Premium TCP Europe\", Hostname: \"97-1-pt.cg-dialup.net\", IPs: []net.IP{{89, 26, 243, 112}, {89, 26, 243, 115}, {89, 26, 243, 195}, {89, 26, 243, 216}, {89, 26, 243, 218}, {89, 26, 243, 220}, {89, 26, 243, 222}, {89, 26, 243, 223}, {89, 26, 243, 225}, {89, 26, 243, 228}}},\n\t\t{Region: \"Portugal\", Group: \"Premium UDP Europe\", Hostname: \"87-1-pt.cg-dialup.net\", IPs: []net.IP{{89, 26, 243, 99}, {89, 26, 243, 113}, {89, 26, 243, 115}, {89, 26, 243, 195}, {89, 26, 243, 199}, {89, 26, 243, 216}, {89, 26, 243, 219}, {89, 26, 243, 225}, {89, 26, 243, 226}, {89, 26, 243, 227}}},\n\t\t{Region: \"Qatar\", Group: \"Premium TCP Europe\", Hostname: \"97-1-qa.cg-dialup.net\", IPs: []net.IP{{95, 181, 234, 133}, {95, 181, 234, 135}, {95, 181, 234, 136}, {95, 181, 234, 137}, {95, 181, 234, 138}, {95, 181, 234, 139}, {95, 181, 234, 140}, {95, 181, 234, 141}, {95, 181, 234, 142}, {95, 181, 234, 143}}},\n\t\t{Region: \"Qatar\", Group: \"Premium UDP Europe\", Hostname: \"87-1-qa.cg-dialup.net\", IPs: []net.IP{{95, 181, 234, 131}, {95, 181, 234, 132}, {95, 181, 234, 133}, {95, 181, 234, 134}, {95, 181, 234, 135}, {95, 181, 234, 137}, {95, 181, 234, 138}, {95, 181, 234, 139}, {95, 181, 234, 142}, {95, 181, 234, 143}}},\n\t\t{Region: \"Russian Federation\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ru.cg-dialup.net\", IPs: []net.IP{{5, 8, 16, 72}, {5, 8, 16, 74}, {5, 8, 16, 84}, {5, 8, 16, 85}, {5, 8, 16, 123}, {5, 8, 16, 124}, {5, 8, 16, 132}, {146, 70, 52, 35}, {146, 70, 52, 44}, {146, 70, 52, 54}}},\n\t\t{Region: \"Russian Federation\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ru.cg-dialup.net\", IPs: []net.IP{{5, 8, 16, 75}, {5, 8, 16, 87}, {5, 8, 16, 99}, {5, 8, 16, 110}, {5, 8, 16, 138}, {146, 70, 52, 29}, {146, 70, 52, 52}, {146, 70, 52, 58}, {146, 70, 52, 59}, {146, 70, 52, 67}}},\n\t\t{Region: \"Saudi Arabia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-sa.cg-dialup.net\", IPs: []net.IP{{95, 181, 235, 131}, {95, 181, 235, 133}, {95, 181, 235, 134}, {95, 181, 235, 135}, {95, 181, 235, 137}, {95, 181, 235, 138}, {95, 181, 235, 139}, {95, 181, 235, 140}, {95, 181, 235, 141}, {95, 181, 235, 142}}},\n\t\t{Region: \"Saudi Arabia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-sa.cg-dialup.net\", IPs: []net.IP{{95, 181, 235, 131}, {95, 181, 235, 132}, {95, 181, 235, 134}, {95, 181, 235, 135}, {95, 181, 235, 136}, {95, 181, 235, 137}, {95, 181, 235, 138}, {95, 181, 235, 139}, {95, 181, 235, 141}, {95, 181, 235, 144}}},\n\t\t{Region: \"Serbia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-rs.cg-dialup.net\", IPs: []net.IP{{37, 120, 193, 179}, {37, 120, 193, 186}, {37, 120, 193, 188}, {37, 120, 193, 190}, {141, 98, 103, 36}, {141, 98, 103, 38}, {141, 98, 103, 39}, {141, 98, 103, 43}, {141, 98, 103, 44}, {141, 98, 103, 46}}},\n\t\t{Region: \"Serbia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-rs.cg-dialup.net\", IPs: []net.IP{{37, 120, 193, 180}, {37, 120, 193, 186}, {37, 120, 193, 187}, {37, 120, 193, 188}, {37, 120, 193, 189}, {37, 120, 193, 190}, {141, 98, 103, 35}, {141, 98, 103, 36}, {141, 98, 103, 39}, {141, 98, 103, 41}}},\n\t\t{Region: \"Singapore\", Group: \"Premium TCP Asia\", Hostname: \"96-1-sg.cg-dialup.net\", IPs: []net.IP{{84, 17, 39, 162}, {84, 17, 39, 165}, {84, 17, 39, 168}, {84, 17, 39, 171}, {84, 17, 39, 175}, {84, 17, 39, 177}, {84, 17, 39, 178}, {84, 17, 39, 181}, {84, 17, 39, 183}, {84, 17, 39, 185}}},\n\t\t{Region: \"Singapore\", Group: \"Premium UDP Asia\", Hostname: \"95-1-sg.cg-dialup.net\", IPs: []net.IP{{84, 17, 39, 162}, {84, 17, 39, 165}, {84, 17, 39, 166}, {84, 17, 39, 167}, {84, 17, 39, 171}, {84, 17, 39, 174}, {84, 17, 39, 175}, {84, 17, 39, 178}, {84, 17, 39, 180}, {84, 17, 39, 185}}},\n\t\t{Region: \"Slovakia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-sk.cg-dialup.net\", IPs: []net.IP{{185, 245, 85, 227}, {185, 245, 85, 228}, {185, 245, 85, 229}, {185, 245, 85, 230}, {185, 245, 85, 231}, {185, 245, 85, 232}, {185, 245, 85, 233}, {185, 245, 85, 234}, {185, 245, 85, 235}, {185, 245, 85, 236}}},\n\t\t{Region: \"Slovakia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-sk.cg-dialup.net\", IPs: []net.IP{{185, 245, 85, 227}, {185, 245, 85, 228}, {185, 245, 85, 229}, {185, 245, 85, 230}, {185, 245, 85, 231}, {185, 245, 85, 232}, {185, 245, 85, 233}, {185, 245, 85, 234}, {185, 245, 85, 235}, {185, 245, 85, 236}}},\n\t\t{Region: \"Slovenia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-si.cg-dialup.net\", IPs: []net.IP{{195, 80, 150, 211}, {195, 80, 150, 212}, {195, 80, 150, 214}, {195, 80, 150, 215}, {195, 80, 150, 216}, {195, 80, 150, 217}, {195, 80, 150, 218}, {195, 80, 150, 219}, {195, 80, 150, 221}, {195, 80, 150, 222}}},\n\t\t{Region: \"Slovenia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-si.cg-dialup.net\", IPs: []net.IP{{195, 80, 150, 211}, {195, 80, 150, 212}, {195, 80, 150, 214}, {195, 80, 150, 215}, {195, 80, 150, 216}, {195, 80, 150, 217}, {195, 80, 150, 219}, {195, 80, 150, 220}, {195, 80, 150, 221}, {195, 80, 150, 222}}},\n\t\t{Region: \"South Africa\", Group: \"Premium TCP Asia\", Hostname: \"96-1-za.cg-dialup.net\", IPs: []net.IP{{154, 127, 50, 212}, {154, 127, 50, 215}, {154, 127, 50, 217}, {154, 127, 50, 219}, {154, 127, 50, 220}, {154, 127, 50, 222}, {154, 127, 60, 196}, {154, 127, 60, 198}, {154, 127, 60, 199}, {154, 127, 60, 200}}},\n\t\t{Region: \"South Africa\", Group: \"Premium TCP Europe\", Hostname: \"97-1-za.cg-dialup.net\", IPs: []net.IP{{197, 85, 7, 26}, {197, 85, 7, 27}, {197, 85, 7, 28}, {197, 85, 7, 29}, {197, 85, 7, 30}, {197, 85, 7, 31}, {197, 85, 7, 131}, {197, 85, 7, 132}, {197, 85, 7, 133}, {197, 85, 7, 134}}},\n\t\t{Region: \"South Africa\", Group: \"Premium UDP Asia\", Hostname: \"95-1-za.cg-dialup.net\", IPs: []net.IP{{154, 127, 50, 210}, {154, 127, 50, 214}, {154, 127, 50, 218}, {154, 127, 50, 219}, {154, 127, 50, 220}, {154, 127, 50, 221}, {154, 127, 50, 222}, {154, 127, 60, 195}, {154, 127, 60, 199}, {154, 127, 60, 206}}},\n\t\t{Region: \"South Africa\", Group: \"Premium UDP Europe\", Hostname: \"87-1-za.cg-dialup.net\", IPs: []net.IP{{197, 85, 7, 26}, {197, 85, 7, 27}, {197, 85, 7, 28}, {197, 85, 7, 29}, {197, 85, 7, 30}, {197, 85, 7, 31}, {197, 85, 7, 131}, {197, 85, 7, 132}, {197, 85, 7, 133}, {197, 85, 7, 134}}},\n\t\t{Region: \"Spain\", Group: \"Premium TCP Europe\", Hostname: \"97-1-es.cg-dialup.net\", IPs: []net.IP{{37, 120, 142, 41}, {37, 120, 142, 52}, {37, 120, 142, 55}, {37, 120, 142, 61}, {37, 120, 142, 173}, {84, 17, 62, 131}, {84, 17, 62, 142}, {84, 17, 62, 144}, {185, 93, 3, 108}, {185, 93, 3, 114}}},\n\t\t{Region: \"Sri Lanka\", Group: \"Premium TCP Europe\", Hostname: \"97-1-lk.cg-dialup.net\", IPs: []net.IP{{95, 181, 239, 131}, {95, 181, 239, 132}, {95, 181, 239, 133}, {95, 181, 239, 134}, {95, 181, 239, 135}, {95, 181, 239, 136}, {95, 181, 239, 137}, {95, 181, 239, 138}, {95, 181, 239, 140}, {95, 181, 239, 144}}},\n\t\t{Region: \"Sri Lanka\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lk.cg-dialup.net\", IPs: []net.IP{{95, 181, 239, 131}, {95, 181, 239, 132}, {95, 181, 239, 133}, {95, 181, 239, 134}, {95, 181, 239, 135}, {95, 181, 239, 136}, {95, 181, 239, 140}, {95, 181, 239, 141}, {95, 181, 239, 142}, {95, 181, 239, 144}}},\n\t\t{Region: \"Sweden\", Group: \"Premium TCP Europe\", Hostname: \"97-1-se.cg-dialup.net\", IPs: []net.IP{{188, 126, 73, 207}, {188, 126, 73, 209}, {188, 126, 73, 214}, {188, 126, 73, 219}, {188, 126, 79, 6}, {188, 126, 79, 11}, {188, 126, 79, 19}, {188, 126, 79, 25}, {195, 246, 120, 148}, {195, 246, 120, 161}}},\n\t\t{Region: \"Sweden\", Group: \"Premium UDP Europe\", Hostname: \"87-1-se.cg-dialup.net\", IPs: []net.IP{{188, 126, 73, 201}, {188, 126, 73, 211}, {188, 126, 73, 213}, {188, 126, 73, 218}, {188, 126, 79, 6}, {188, 126, 79, 8}, {188, 126, 79, 19}, {195, 246, 120, 142}, {195, 246, 120, 144}, {195, 246, 120, 168}}},\n\t\t{Region: \"Switzerland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ch.cg-dialup.net\", IPs: []net.IP{{84, 17, 52, 4}, {84, 17, 52, 20}, {84, 17, 52, 44}, {84, 17, 52, 65}, {84, 17, 52, 72}, {84, 17, 52, 80}, {84, 17, 52, 83}, {84, 17, 52, 85}, {185, 32, 222, 112}, {185, 189, 150, 73}}},\n\t\t{Region: \"Switzerland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ch.cg-dialup.net\", IPs: []net.IP{{84, 17, 52, 5}, {84, 17, 52, 14}, {84, 17, 52, 24}, {84, 17, 52, 64}, {84, 17, 52, 73}, {84, 17, 52, 85}, {185, 32, 222, 114}, {185, 189, 150, 52}, {185, 189, 150, 57}, {195, 225, 118, 43}}},\n\t\t{Region: \"Taiwan\", Group: \"Premium TCP Asia\", Hostname: \"96-1-tw.cg-dialup.net\", IPs: []net.IP{{45, 133, 181, 100}, {45, 133, 181, 102}, {45, 133, 181, 103}, {45, 133, 181, 106}, {45, 133, 181, 109}, {45, 133, 181, 113}, {45, 133, 181, 115}, {45, 133, 181, 116}, {45, 133, 181, 123}, {45, 133, 181, 125}}},\n\t\t{Region: \"Taiwan\", Group: \"Premium UDP Asia\", Hostname: \"95-1-tw.cg-dialup.net\", IPs: []net.IP{{45, 133, 181, 99}, {45, 133, 181, 102}, {45, 133, 181, 107}, {45, 133, 181, 108}, {45, 133, 181, 109}, {45, 133, 181, 114}, {45, 133, 181, 116}, {45, 133, 181, 117}, {45, 133, 181, 123}, {45, 133, 181, 124}}},\n\t\t{Region: \"Thailand\", Group: \"Premium TCP Asia\", Hostname: \"96-1-th.cg-dialup.net\", IPs: []net.IP{{146, 70, 13, 3}, {146, 70, 13, 4}, {146, 70, 13, 6}, {146, 70, 13, 7}, {146, 70, 13, 8}, {146, 70, 13, 9}, {146, 70, 13, 11}, {146, 70, 13, 13}, {146, 70, 13, 15}, {146, 70, 13, 16}}},\n\t\t{Region: \"Thailand\", Group: \"Premium UDP Asia\", Hostname: \"95-1-th.cg-dialup.net\", IPs: []net.IP{{146, 70, 13, 3}, {146, 70, 13, 4}, {146, 70, 13, 8}, {146, 70, 13, 9}, {146, 70, 13, 10}, {146, 70, 13, 11}, {146, 70, 13, 12}, {146, 70, 13, 13}, {146, 70, 13, 15}, {146, 70, 13, 16}}},\n\t\t{Region: \"Turkey\", Group: \"Premium TCP Europe\", Hostname: \"97-1-tr.cg-dialup.net\", IPs: []net.IP{{188, 213, 34, 9}, {188, 213, 34, 11}, {188, 213, 34, 15}, {188, 213, 34, 16}, {188, 213, 34, 23}, {188, 213, 34, 25}, {188, 213, 34, 28}, {188, 213, 34, 41}, {188, 213, 34, 108}, {188, 213, 34, 110}}},\n\t\t{Region: \"Turkey\", Group: \"Premium UDP Europe\", Hostname: \"87-1-tr.cg-dialup.net\", IPs: []net.IP{{188, 213, 34, 8}, {188, 213, 34, 11}, {188, 213, 34, 14}, {188, 213, 34, 28}, {188, 213, 34, 35}, {188, 213, 34, 42}, {188, 213, 34, 43}, {188, 213, 34, 100}, {188, 213, 34, 103}, {188, 213, 34, 107}}},\n\t\t{Region: \"Ukraine\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ua.cg-dialup.net\", IPs: []net.IP{{31, 28, 161, 18}, {31, 28, 161, 20}, {31, 28, 161, 27}, {31, 28, 163, 34}, {31, 28, 163, 37}, {31, 28, 163, 44}, {62, 149, 7, 167}, {62, 149, 7, 172}, {62, 149, 29, 45}, {62, 149, 29, 57}}},\n\t\t{Region: \"Ukraine\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ua.cg-dialup.net\", IPs: []net.IP{{31, 28, 161, 27}, {31, 28, 163, 38}, {31, 28, 163, 42}, {31, 28, 163, 54}, {31, 28, 163, 61}, {62, 149, 7, 162}, {62, 149, 7, 163}, {62, 149, 29, 35}, {62, 149, 29, 38}, {62, 149, 29, 41}}},\n\t\t{Region: \"United Arab Emirates\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ae.cg-dialup.net\", IPs: []net.IP{{217, 138, 193, 179}, {217, 138, 193, 180}, {217, 138, 193, 181}, {217, 138, 193, 182}, {217, 138, 193, 183}, {217, 138, 193, 184}, {217, 138, 193, 185}, {217, 138, 193, 186}, {217, 138, 193, 188}, {217, 138, 193, 190}}},\n\t\t{Region: \"United Arab Emirates\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ae.cg-dialup.net\", IPs: []net.IP{{217, 138, 193, 179}, {217, 138, 193, 180}, {217, 138, 193, 181}, {217, 138, 193, 182}, {217, 138, 193, 183}, {217, 138, 193, 186}, {217, 138, 193, 187}, {217, 138, 193, 188}, {217, 138, 193, 189}, {217, 138, 193, 190}}},\n\t\t{Region: \"United Kingdom\", Group: \"Premium TCP Europe\", Hostname: \"97-1-gb.cg-dialup.net\", IPs: []net.IP{{45, 133, 173, 49}, {45, 133, 173, 56}, {45, 133, 173, 82}, {45, 133, 173, 86}, {95, 154, 200, 153}, {95, 154, 200, 156}, {181, 215, 176, 103}, {181, 215, 176, 246}, {181, 215, 176, 251}, {194, 110, 13, 141}}},\n\t\t{Region: \"United Kingdom\", Group: \"Premium UDP Europe\", Hostname: \"87-1-gb.cg-dialup.net\", IPs: []net.IP{{45, 133, 172, 100}, {45, 133, 172, 126}, {45, 133, 173, 84}, {95, 154, 200, 174}, {181, 215, 176, 110}, {181, 215, 176, 151}, {181, 215, 176, 158}, {191, 101, 209, 142}, {194, 110, 13, 107}, {194, 110, 13, 128}}},\n\t\t{Region: \"United States\", Group: \"Premium TCP USA\", Hostname: \"93-1-us.cg-dialup.net\", IPs: []net.IP{{102, 129, 145, 15}, {102, 129, 152, 195}, {102, 129, 152, 248}, {154, 21, 208, 159}, {185, 242, 5, 117}, {185, 242, 5, 123}, {185, 242, 5, 229}, {191, 96, 227, 173}, {191, 96, 227, 196}, {199, 115, 119, 248}}},\n\t\t{Region: \"United States\", Group: \"Premium UDP USA\", Hostname: \"94-1-us.cg-dialup.net\", IPs: []net.IP{{23, 82, 14, 113}, {23, 105, 177, 122}, {45, 89, 173, 222}, {84, 17, 35, 4}, {89, 187, 171, 132}, {156, 146, 37, 45}, {156, 146, 59, 86}, {184, 170, 240, 231}, {191, 96, 150, 248}, {199, 115, 119, 248}}},\n\t\t{Region: \"Venezuela\", Group: \"Premium TCP USA\", Hostname: \"93-1-ve.cg-dialup.net\", IPs: []net.IP{{95, 181, 237, 132}, {95, 181, 237, 133}, {95, 181, 237, 134}, {95, 181, 237, 135}, {95, 181, 237, 136}, {95, 181, 237, 138}, {95, 181, 237, 139}, {95, 181, 237, 140}, {95, 181, 237, 141}, {95, 181, 237, 143}}},\n\t\t{Region: \"Venezuela\", Group: \"Premium UDP USA\", Hostname: \"94-1-ve.cg-dialup.net\", IPs: []net.IP{{95, 181, 237, 131}, {95, 181, 237, 132}, {95, 181, 237, 134}, {95, 181, 237, 135}, {95, 181, 237, 136}, {95, 181, 237, 140}, {95, 181, 237, 141}, {95, 181, 237, 142}, {95, 181, 237, 143}, {95, 181, 237, 144}}},\n\t\t{Region: \"Vietnam\", Group: \"Premium TCP Asia\", Hostname: \"96-1-vn.cg-dialup.net\", IPs: []net.IP{{188, 214, 152, 99}, {188, 214, 152, 101}, {188, 214, 152, 103}, {188, 214, 152, 104}, {188, 214, 152, 105}, {188, 214, 152, 106}, {188, 214, 152, 107}, {188, 214, 152, 108}, {188, 214, 152, 109}, {188, 214, 152, 110}}},\n\t\t{Region: \"Vietnam\", Group: \"Premium UDP Asia\", Hostname: \"95-1-vn.cg-dialup.net\", IPs: []net.IP{{188, 214, 152, 99}, {188, 214, 152, 100}, {188, 214, 152, 101}, {188, 214, 152, 102}, {188, 214, 152, 103}, {188, 214, 152, 104}, {188, 214, 152, 105}, {188, 214, 152, 106}, {188, 214, 152, 107}, {188, 214, 152, 109}}},\n\t}\n}", "func filterIPs(addrs []net.Addr) string {\n\tvar ipAddr string\n\tfor _, addr := range addrs {\n\t\tif v, ok := addr.(*net.IPNet); ok {\n\t\t\tif ip := v.IP.To4(); ip != nil {\n\t\t\t\tipAddr = v.IP.String()\n\t\t\t\tif !strings.HasPrefix(ipAddr, `169.254.`) {\n\t\t\t\t\treturn ipAddr\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn ipAddr\n}", "func (c *cache) List() []string {\n\tnames := make([]string, len(c.items))\n\n\ti := 0\n\tfor key := range c.items {\n\t\tnames[i] = key\n\t\ti ++\n\t}\n\n\treturn names\n}", "func getHostMapping() []verifyMapping {\n\treturn []verifyMapping{\n\t\t{\"volumes\", sourceBinds, expectedBinds},\n\t\t{\"logging\", sourceLogConfig, expectedLogconfig},\n\t\t{\"network_mode\", \"host\", container.NetworkMode(\"host\")},\n\t\t{\"ports\", sourcePortBindings, expectedPortBindings},\n\t\t{\"restart\", \"on-failure:5\", container.RestartPolicy{Name: \"on-failure\", MaximumRetryCount: 5}},\n\t\t{\"cap_add\", []interface{}{\"ALL\"}, strslice.StrSlice{\"ALL\"}},\n\t\t{\"cap_drop\", []interface{}{\"NET_ADMIN\"}, strslice.StrSlice{\"NET_ADMIN\"}},\n\t\t{\"dns\", []interface{}{\"8.8.8.8\"}, []string{\"8.8.8.8\"}},\n\t\t{\"dns_search\", []interface{}{\"example.com\"}, []string{\"example.com\"}},\n\t\t{\"extra_hosts\", []interface{}{\"somehost:162.242.195.82\", \"otherhost:50.31.209.229\"}, []string{\"somehost:162.242.195.82\", \"otherhost:50.31.209.229\"}},\n\t\t{\"ipc\", \"host\", container.IpcMode(\"host\")},\n\t\t{\"pid\", \"host\", container.PidMode(\"host\")},\n\t\t{\"external_links\", []interface{}{\"db\", \"test:external\"}, []string{\"db\", \"test:external\"}},\n\t\t{\"privileged\", true, true},\n\t\t{\"read_only\", true, true},\n\t\t{\"security_opt\", []interface{}{\"label:user:USER\", \"label:role:ROLE\"}, []string{\"label:user:USER\", \"label:role:ROLE\"}},\n\t\t{\"tmpfs\", []interface{}{\"/tmp:rw,size=787448k,mode=1777\"}, map[string]string{\"/tmp\": \"rw,size=787448k,mode=1777\"}},\n\t\t{\"userns_mode\", \"host\", container.UsernsMode(\"host\")},\n\t\t{\"shm_size\", \"64M\", int64(64000000)},\n\t\t{\"sysctls\", []interface{}{\"net.core.somaxconn=1024\", \"net.ipv4.tcp_syncookies=0\"}, map[string]string{\"net.core.somaxconn\": \"1024\", \"net.ipv4.tcp_syncookies\": \"0\"}},\n\t\t{\"init\", true, func(x bool) *bool { return &x }(true)}, //bodge for inline *bool\n\t\t// Resources\n\t\t{\"cgroup_parent\", \"m-executor-abcd\", \"m-executor-abcd\"},\n\t\t{\"devices\", []interface{}{\"/dev/ttyUSB0:/dev/ttyUSB0\"}, expectedDevices},\n\t\t{\"ulimits\", sourceUlimits, expectedUlimits},\n\t}\n}", "func filterBindAddrs(addrs []PtBindAddr, methodNames []string) []PtBindAddr {\n\tvar result []PtBindAddr\n\n\tfor _, ba := range addrs {\n\t\tfor _, methodName := range methodNames {\n\t\t\tif ba.MethodName == methodName {\n\t\t\t\tresult = append(result, ba)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result\n}", "func (storage *SrvStorage) GetVhostBindings(vhost string) []*binding.Binding {\n\tvar bindings []*binding.Binding\n\tstorage.db.Iterate(\n\t\tfunc(key []byte, value []byte) {\n\t\t\tif !bytes.HasPrefix(key, []byte(bindingPrefix)) || getVhostFromKey(string(key)) != vhost {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tbind := &binding.Binding{}\n\t\t\tbind.Unmarshal(value, storage.protoVersion)\n\t\t\tbindings = append(bindings, bind)\n\t\t},\n\t)\n\n\treturn bindings\n}", "func (k Keeper) GetBlackListedAddrs() map[string]bool {\n\treturn k.blacklistedAddrs\n}", "func (client WorkloadNetworksClient) ListDhcpSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, azure.DoRetryWithRegistration(client.Client))\n}", "func (t *Tracker) HostTimes() map[string]time.Time {\n\tm := make(map[string]time.Time)\n\tt.Query(func(t *Tracker) {\n\t\tfor k, v := range t.hostTimes {\n\t\t\tm[k] = v\n\t\t}\n\t})\n\n\treturn m\n}", "func GroupHostList(group string) ([]string, error) {\n\t//default result not found\n\tresult := []string{}\n\t//get all host groups\n\thost_groups, err := HostGroups()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, host_group := range host_groups {\n\t\tif host_group.GroupName == group {\n\t\t\tresult = host_group.Members\n\t\t}\n\t}\n\treturn result, nil\n}", "func (v *version) GatewayHosts() GatewayHostInformer {\n\treturn &gatewayHostInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}\n}", "func addressRecordsByHostName(records map[addressRecordID]addressRecord) map[hostName][]addressRecord {\n\tbyName := make(map[hostName][]addressRecord)\n\tfor _, record := range records {\n\t\tbyName[record.name] = append(byName[record.name], record)\n\t}\n\n\treturn byName\n}", "func (b *BlubberBlockDirectory) GetFreeHosts(req blubberstore.FreeHostsRequest,\n\thosts *blubberstore.BlockHolderList) error {\n\tvar allhosts []string\n\tvar onehost string\n\tvar i int\n\tvar min int = -1\n\n\tif b.doozerConn == nil {\n\t\tvar host string\n\t\tfor host, _ = range b.blockHostMap {\n\t\t\tallhosts = append(allhosts, host)\n\t\t}\n\t} else {\n\t\tvar names []string\n\t\tvar name string\n\t\tvar rev int64\n\t\tvar err error\n\n\t\trev, err = b.doozerConn.Rev()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// TODO(caoimhe): reading until the end may return MANY records.\n\t\tnames, err = b.doozerConn.Getdir(b.blockServicePrefix, rev, 0, -1)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, name = range names {\n\t\t\tvar data []byte\n\t\t\tdata, _, err = b.doozerConn.Get(b.blockServicePrefix+\"/\"+name, &rev)\n\t\t\tif err == nil {\n\t\t\t\tallhosts = append(allhosts, string(data))\n\t\t\t} else {\n\t\t\t\tlog.Print(\"Unable to retrieve version \", rev, \" of \",\n\t\t\t\t\tb.blockServicePrefix, \"/\", name, \": \", err)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor i = 0; int32(i) < req.GetNumHosts(); i++ {\n\t\tvar ok bool\n\t\tif i >= len(allhosts) {\n\t\t\tbreak\n\t\t}\n\n\t\thosts.HostPort = append(hosts.HostPort, allhosts[i])\n\t\t_, ok = b.blockHostMap[allhosts[i]]\n\t\tif !ok {\n\t\t\tmin = 0\n\t\t} else if min < 1 || len(b.blockHostMap[allhosts[i]]) < min {\n\t\t\tmin = len(b.blockHostMap[allhosts[i]])\n\t\t}\n\t}\n\n\tfor i, onehost = range allhosts {\n\t\tvar ok bool\n\n\t\tif int32(i) < req.GetNumHosts() {\n\t\t\tcontinue\n\t\t}\n\n\t\t_, ok = b.blockHostMap[onehost]\n\t\tif !ok {\n\t\t\thosts.HostPort = append(hosts.HostPort[1:], onehost)\n\t\t\tmin = 0\n\t\t} else if len(b.blockHostMap[onehost]) <= min {\n\t\t\thosts.HostPort = append(hosts.HostPort[1:], onehost)\n\t\t\tmin = len(b.blockHostMap[onehost])\n\t\t}\n\t}\n\n\treturn nil\n}", "func (i *InternalData) GetAdapterName() {\n\n\tl, err := net.Interfaces()\n\tcheckErr(err)\n\n\tfor _, f := range l {\n\n\t\tbyNameInterface, err := net.InterfaceByName(f.Name)\n\t\tcheckErr(err)\n\n\t\taddr, err := byNameInterface.Addrs()\n\t\tcheckErr(err)\n\n\t\tfor _, v := range addr {\n\n\t\t\tif v.String()[:strings.Index(v.String(), \"/\")] == i.IntIP {\n\t\t\t\ti.AdapterName = f.Name\n\t\t\t}\n\t\t}\n\t}\n}", "func NewGetAdapterHostEthInterfacesMoidDefault(code int) *GetAdapterHostEthInterfacesMoidDefault {\n\treturn &GetAdapterHostEthInterfacesMoidDefault{\n\t\t_statusCode: code,\n\t}\n}", "func privateNetworkInterfaces(all []net.Interface, fallback []string, logger log.Logger) []string {\n\tvar privInts []string\n\tfor _, i := range all {\n\t\taddrs, err := getInterfaceAddrs(&i)\n\t\tif err != nil {\n\t\t\tlevel.Warn(logger).Log(\"msg\", \"error getting addresses from network interface\", \"interface\", i.Name, \"err\", err)\n\t\t}\n\t\tfor _, a := range addrs {\n\t\t\ts := a.String()\n\t\t\tip, _, err := net.ParseCIDR(s)\n\t\t\tif err != nil {\n\t\t\t\tlevel.Warn(logger).Log(\"msg\", \"error parsing network interface IP address\", \"interface\", i.Name, \"addr\", s, \"err\", err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif ip.IsPrivate() {\n\t\t\t\tprivInts = append(privInts, i.Name)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tif len(privInts) == 0 {\n\t\treturn fallback\n\t}\n\treturn privInts\n}", "func (p preferScheduleOnHost) filter(pools *csp.CSPList) (*csp.CSPList, error) {\n\tplist, err := p.scheduleOnHost.filter(pools)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(plist.GetPoolUIDs()) == 0 {\n\t\treturn pools, nil\n\t}\n\treturn plist, nil\n}", "func onlyPublic(addrs []ma.Multiaddr) []ma.Multiaddr {\n\troutable := []ma.Multiaddr{}\n\tfor _, addr := range addrs {\n\t\tif manet.IsPublicAddr(addr) {\n\t\t\troutable = append(routable, addr)\n\t\t}\n\t}\n\treturn routable\n}", "func (client *DedicatedHostsClient) ListByHostGroup(resourceGroupName string, hostGroupName string, options *DedicatedHostsListByHostGroupOptions) *DedicatedHostsListByHostGroupPager {\n\treturn &DedicatedHostsListByHostGroupPager{\n\t\tclient: client,\n\t\trequester: func(ctx context.Context) (*policy.Request, error) {\n\t\t\treturn client.listByHostGroupCreateRequest(ctx, resourceGroupName, hostGroupName, options)\n\t\t},\n\t\tadvancer: func(ctx context.Context, resp DedicatedHostsListByHostGroupResponse) (*policy.Request, error) {\n\t\t\treturn runtime.NewRequest(ctx, http.MethodGet, *resp.DedicatedHostListResult.NextLink)\n\t\t},\n\t}\n}", "func (f FakeContainerImpl) GetDefaultHostIPs() ([]string, error) {\n\tpanic(\"implement me\")\n}", "func (p scheduleOnHost) filter(pools *csp.CSPList) (*csp.CSPList, error) {\n\tif p.hostName == \"\" {\n\t\treturn pools, nil\n\t}\n\tfilteredPools := pools.Filter(csp.HasAnnotation(string(scheduleOnHostAnnotation), p.hostName))\n\treturn filteredPools, nil\n}", "func parseHosts() {\n\t// Convert the hosts entries into IP and IPNet\n\tfor _, h := range cfg.Hosts {\n\t\t// Does it look like a CIDR?\n\t\t_, ipv4Net, err := net.ParseCIDR(h)\n\t\tif err == nil {\n\t\t\tallowedNetworks = append(allowedNetworks, ipv4Net)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Does it look like an IP?\n\t\tip := net.ParseIP(h)\n\t\tif ip != nil {\n\t\t\tallowedHosts = append(allowedHosts, ip)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Does it look like a hostname?\n\t\tips, err := net.LookupIP(h)\n\t\tif err == nil {\n\t\t\tallowedHosts = append(allowedHosts, ips...)\n\t\t}\n\t}\n}", "func ReadHostList(cfg *common.Config) ([]string, error) {\n\tconfig := struct {\n\t\tHosts []string `config:\"hosts\" validate:\"required\"`\n\t\tWorker int `config:\"worker\" validate:\"min=1\"`\n\t}{\n\t\tWorker: 1,\n\t}\n\n\terr := cfg.Unpack(&config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlst := config.Hosts\n\tif len(lst) == 0 || config.Worker <= 1 {\n\t\treturn lst, nil\n\t}\n\n\t// duplicate entries config.Workers times\n\thosts := make([]string, 0, len(lst)*config.Worker)\n\tfor _, entry := range lst {\n\t\tfor i := 0; i < config.Worker; i++ {\n\t\t\thosts = append(hosts, entry)\n\t\t}\n\t}\n\n\treturn hosts, nil\n}", "func (dir *Dir) Hostnames() ([]string, error) {\n\tif dir.Config.Changed(\"host-wrapper\") {\n\t\tvariables := map[string]string{\n\t\t\t\"HOST\": dir.Config.Get(\"host\"),\n\t\t\t\"ENVIRONMENT\": dir.Config.Get(\"environment\"),\n\t\t\t\"DIRNAME\": dir.BaseName(),\n\t\t\t\"DIRPATH\": dir.Path,\n\t\t\t\"SCHEMA\": dir.Config.Get(\"schema\"),\n\t\t}\n\t\tshellOut, err := util.NewInterpolatedShellOut(dir.Config.Get(\"host-wrapper\"), variables)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn shellOut.RunCaptureSplit()\n\t}\n\treturn dir.Config.GetSlice(\"host\", ',', true), nil\n}", "func getConfigsForHost(hostname host.Name, configs []model.Config) []model.Config {\n\tsvcConfigs := make([]model.Config, 0)\n\tfor index := range configs {\n\t\tvirtualService := configs[index].Spec.(*v1alpha3.VirtualService)\n\t\tfor _, vsHost := range virtualService.Hosts {\n\t\t\tif host.Name(vsHost).Matches(hostname) {\n\t\t\t\tsvcConfigs = append(svcConfigs, configs[index])\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn svcConfigs\n}", "func GetAllGateway() []domain.Gateway {\n\titems := make([]domain.Gateway, 0)\n\n\tcols := domain.Gateways.Iter()\n\tfor kv := range cols {\n\t\tgateway := kv.Value.(*domain.Gateway)\n\t\titems = append(items, *gateway)\n\t}\n\n\treturn items\n}", "func getServerBindaddrs(bindaddrList *string, options *string, transports *string) ([]pt_extras.Bindaddr, error) {\n\tvar result []pt_extras.Bindaddr\n\tvar serverBindaddr string\n\tvar serverTransports string\n\n\t// Get the list of all requested bindaddrs.\n\tif *bindaddrList != \"\" {\n\t\tserverBindaddr = *bindaddrList\n\t}\n\n\tfor _, spec := range strings.Split(serverBindaddr, \",\") {\n\t\tvar bindaddr pt_extras.Bindaddr\n\n\t\tparts := strings.SplitN(spec, \"-\", 2)\n\t\tif len(parts) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"-bindaddr: %q: doesn't contain \\\"-\\\"\", spec)\n\t\t}\n\t\tbindaddr.MethodName = parts[0]\n\t\taddr, err := pt_extras.ResolveAddr(parts[1])\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"-bindaddr: %q: %s\", spec, err.Error())\n\t\t}\n\t\tbindaddr.Addr = addr\n\t\tbindaddr.Options = *options\n\t\tresult = append(result, bindaddr)\n\t}\n\n\tif transports == nil {\n\t\treturn nil, errors.New(\"must specify -transport or -transports in server mode\")\n\t} else {\n\t\tserverTransports = *transports\n\t}\n\tresult = pt_extras.FilterBindaddrs(result, strings.Split(serverTransports, \",\"))\n\tif len(result) == 0 {\n\t\tgolog.Errorf(\"no valid bindaddrs\")\n\t}\n\treturn result, nil\n}", "func (client *DedicatedHostsClient) ListByHostGroup(resourceGroupName string, hostGroupName string, options *DedicatedHostsListByHostGroupOptions) DedicatedHostListResultPager {\n\treturn &dedicatedHostListResultPager{\n\t\tpipeline: client.con.Pipeline(),\n\t\trequester: func(ctx context.Context) (*azcore.Request, error) {\n\t\t\treturn client.listByHostGroupCreateRequest(ctx, resourceGroupName, hostGroupName, options)\n\t\t},\n\t\tresponder: client.listByHostGroupHandleResponse,\n\t\terrorer: client.listByHostGroupHandleError,\n\t\tadvancer: func(ctx context.Context, resp DedicatedHostListResultResponse) (*azcore.Request, error) {\n\t\t\treturn azcore.NewRequest(ctx, http.MethodGet, *resp.DedicatedHostListResult.NextLink)\n\t\t},\n\t\tstatusCodes: []int{http.StatusOK},\n\t}\n}", "func (client *Client) ListHosts() ([]*model.Host, error) {\n\treturn client.osclt.ListHosts()\n}", "func (client *Client) ListHosts() ([]*model.Host, error) {\n\treturn client.feclt.ListHosts()\n}", "func FilterStrictDomains(domains []string, publicSuffixes map[string]bool) []string {\n\tvar output []string\n\tfor _, domain := range domains {\n\t\tfirst := strings.Index(domain, \".\")\n\t\tcleanedDomain := domain[:first]\n\t\tif _, ok := publicSuffixes[cleanedDomain]; !ok {\n\t\t\toutput = append(output, domain)\n\t\t}\n\t}\n\treturn output\n}", "func NewDisableHostForbidden() *DisableHostForbidden {\n\treturn &DisableHostForbidden{}\n}", "func doGetAllIpKeys(d *db.DB, dbSpec *db.TableSpec) ([]db.Key, error) {\n\n var keys []db.Key\n\n intfTable, err := d.GetTable(dbSpec)\n if err != nil {\n return keys, err\n }\n\n keys, err = intfTable.GetKeys()\n log.Infof(\"Found %d INTF table keys\", len(keys))\n return keys, err\n}", "func (c *CachedSites) List() string {\n\tsites := \"\"\n\tfor site := range c.cache {\n\t\tsites += site.Host + \"\\n\"\n\t}\n\treturn sites\n}", "func getBrokerUrls() (map[int]config.HostPort, error) {\n\tres := make(map[int]config.HostPort)\n\tbrokers, err := zookeeper.Brokers()\n\tif err != nil {\n\t\treturn res, err\n\t}\n\tfor _, id := range brokers {\n\t\tbroker, err := zookeeper.Broker(id)\n\t\tif err != nil {\n\t\t\treturn res, err\n\t\t}\n\t\tres[id] = config.HostPort{Host: broker.Host, Port: broker.Port}\n\t}\n\treturn res, nil\n}", "func (pr *ProxyRegistry) ListConnectedProxies() map[string]*models.Proxy {\n\tpr.mu.Lock()\n\tdefer pr.mu.Unlock()\n\n\tproxies := make(map[string]*models.Proxy, len(pr.connectedProxies))\n\tfor _, p := range pr.connectedProxies {\n\t\t// A proxy could connect twice quickly and not register the disconnect, so we return the proxy with the higher connection ID.\n\t\tif prior := proxies[p.UUID.String()]; prior == nil || prior.GetConnectionID() < p.GetConnectionID() {\n\t\t\tproxies[p.UUID.String()] = p\n\t\t}\n\t}\n\treturn proxies\n}", "func (p *MemoryProposer) ListAccepters() (addrs []string, err error) {\n\tp.mtx.Lock()\n\tdefer p.mtx.Unlock()\n\n\taddrs = make([]string, 0, len(p.accepters))\n\tfor addr := range p.accepters {\n\t\taddrs = append(addrs, addr)\n\t}\n\n\tsort.Strings(addrs)\n\treturn addrs, nil\n}", "func (dir *Dir) Hostnames() ([]string, error) {\n\tif dir.Config.Changed(\"host-wrapper\") {\n\t\tvariables := map[string]string{\n\t\t\t\"HOST\": dir.Config.GetAllowEnvVar(\"host\"),\n\t\t\t\"ENVIRONMENT\": dir.Config.Get(\"environment\"),\n\t\t\t\"DIRNAME\": dir.BaseName(),\n\t\t\t\"DIRPATH\": dir.Path,\n\t\t\t\"SCHEMA\": dir.Config.GetAllowEnvVar(\"schema\"),\n\t\t}\n\t\tshellOut, err := shellout.New(dir.Config.Get(\"host-wrapper\")).WithVariables(variables)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn shellOut.RunCaptureSplit()\n\t}\n\treturn dir.Config.GetSliceAllowEnvVar(\"host\", ',', true), nil\n}", "func AllDeviceDrivers() map[string]bool {\n\tret := make(map[string]bool)\n\tfor k, v := range allDeviceDrivers {\n\t\tret[k] = v\n\t}\n\treturn ret\n}", "func (s *SQLStorage) GetWhiteList(ctx context.Context) ([]*IPNet, error) {\n\treturn s.getSubnetList(ctx, \"SELECT ip, mask FROM whitelist\")\n}", "func (m *Manager) List() map[string]Modem {\n\tdevList := make(map[string]Modem)\n\tfor k, v := range m.devices {\n\t\tif v.ready == 1 {\n\t\t\tdevList[k] = v\n\t\t}\n\t}\n\treturn devList\n}", "func SetAllowedHosts(allowed []string) {\n\tDefaultDialer.SetAllowedHosts(allowed)\n}" ]
[ "0.4922467", "0.49170256", "0.48662174", "0.46048605", "0.45793784", "0.4545906", "0.4537662", "0.45205545", "0.45185655", "0.44573838", "0.44563538", "0.4444831", "0.44146225", "0.4406497", "0.43984336", "0.43956515", "0.43870476", "0.4317521", "0.42667553", "0.4260609", "0.42515606", "0.4248183", "0.42229694", "0.4182807", "0.41670847", "0.41662374", "0.41613647", "0.41502324", "0.41390446", "0.41300252", "0.41218328", "0.41194957", "0.4085199", "0.40843797", "0.40837824", "0.40698856", "0.40653926", "0.40623856", "0.4059313", "0.40451148", "0.4041583", "0.40285683", "0.4024153", "0.40218836", "0.40194538", "0.40189895", "0.40127406", "0.40117258", "0.40057692", "0.39976585", "0.39969555", "0.39822626", "0.39792445", "0.39789227", "0.3964914", "0.395633", "0.39546037", "0.3953619", "0.39536142", "0.3952923", "0.39528817", "0.39513925", "0.39495382", "0.3948868", "0.39481497", "0.39446932", "0.3944175", "0.3943653", "0.39428255", "0.39368647", "0.39219832", "0.39183503", "0.3914064", "0.3908435", "0.3906975", "0.39060232", "0.39050052", "0.39018774", "0.38928354", "0.38883248", "0.3887354", "0.388587", "0.38603163", "0.38581607", "0.38506192", "0.3844624", "0.38389942", "0.38335449", "0.38289446", "0.38284928", "0.3827315", "0.38265342", "0.38194177", "0.38188052", "0.38162273", "0.38156033", "0.3814484", "0.38130245", "0.38119915", "0.38114277" ]
0.7816921
0
removeOrphanDHCPServers removed the DHCP servers linked to no hostonly adapter
func removeOrphanDHCPServers(vbox VBoxManager) error { dhcps, err := listDHCPServers(vbox) if err != nil { return err } if len(dhcps) == 0 { return nil } nets, err := listHostOnlyAdapters(vbox) if err != nil { return err } for name := range dhcps { if strings.HasPrefix(name, dhcpPrefix) { if _, present := nets[name]; !present { if err := vbox.vbm("dhcpserver", "remove", "--netname", name); err != nil { log.Warnf("Unable to remove orphan dhcp server %q: %s", name, err) } } } } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func DHCPsDelete() error {\n\tdhcps, err := DHCPsGet()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, d := range dhcps {\n\t\tif isUnmanaged(UnmanagedID(d.Ifname), LINKTYPE) {\n\t\t\tlogger.Log.Info(fmt.Sprintf(\"Skipping Unmanaged Link %v DHCP configuration\", d.Ifname))\n\t\t\tcontinue\n\t\t}\n\t\terr = DHCPDelete(d.Ifname)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func listDHCPServers(vbox VBoxManager) (map[string]*dhcpServer, error) {\n\tout, err := vbox.vbmOut(\"list\", \"dhcpservers\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tm := map[string]*dhcpServer{}\n\tdhcp := &dhcpServer{}\n\n\terr = parseKeyValues(out, reColonLine, func(key, val string) error {\n\t\tswitch key {\n\t\tcase \"NetworkName\":\n\t\t\tdhcp = &dhcpServer{}\n\t\t\tm[val] = dhcp\n\t\t\tdhcp.NetworkName = val\n\t\tcase \"IP\":\n\t\t\tdhcp.IPv4.IP = net.ParseIP(val)\n\t\tcase \"upperIPAddress\":\n\t\t\tdhcp.UpperIP = net.ParseIP(val)\n\t\tcase \"lowerIPAddress\":\n\t\t\tdhcp.LowerIP = net.ParseIP(val)\n\t\tcase \"NetworkMask\":\n\t\t\tdhcp.IPv4.Mask = parseIPv4Mask(val)\n\t\tcase \"Enabled\":\n\t\t\tdhcp.Enabled = (val == \"Yes\")\n\t\t}\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn m, nil\n}", "func addHostOnlyDHCPServer(ifname string, d dhcpServer, vbox VBoxManager) error {\n\tname := dhcpPrefix + ifname\n\n\tdhcps, err := listDHCPServers(vbox)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// On some platforms (OSX), creating a host-only adapter adds a default dhcpserver,\n\t// while on others (Windows?) it does not.\n\tcommand := \"add\"\n\tif dhcp, ok := dhcps[name]; ok {\n\t\tcommand = \"modify\"\n\t\tif (dhcp.IPv4.IP.Equal(d.IPv4.IP)) && (dhcp.IPv4.Mask.String() == d.IPv4.Mask.String()) && (dhcp.LowerIP.Equal(d.LowerIP)) && (dhcp.UpperIP.Equal(d.UpperIP)) && dhcp.Enabled {\n\t\t\t// dhcp is up to date\n\t\t\treturn nil\n\t\t}\n\t}\n\n\targs := []string{\"dhcpserver\", command,\n\t\t\"--netname\", name,\n\t\t\"--ip\", d.IPv4.IP.String(),\n\t\t\"--netmask\", net.IP(d.IPv4.Mask).String(),\n\t\t\"--lowerip\", d.LowerIP.String(),\n\t\t\"--upperip\", d.UpperIP.String(),\n\t}\n\tif d.Enabled {\n\t\targs = append(args, \"--enable\")\n\t} else {\n\t\targs = append(args, \"--disable\")\n\t}\n\n\treturn vbox.vbm(args...)\n}", "func removeServerInConfig(server string) {\n\tfor k, v := range selfConf.Servers {\n\t\tif v == server {\n\t\t\tselfConf.Servers = selfConf.Servers[:k+copy(selfConf.Servers[k:], selfConf.Servers[k+1:])]\n\t\t}\n\t}\n}", "func (p *Pool) RemoveHostAndPlugins(host string) {\n\tp.mutex.Lock()\n\tdefer p.mutex.Unlock()\n\tfor plHostName, pls := range p.hosts {\n\t\tif plHostName == host {\n\t\t\t// stop all plugins\n\t\t\tfor _, pl := range pls.plugins {\n\t\t\t\tpl.stop()\n\t\t\t}\n\t\t\tdelete(p.hosts, host)\n\t\t}\n\t}\n}", "func (adminOrg *AdminOrg) removeAllOrgVDCs() error {\n\tfor _, vdcs := range adminOrg.AdminOrg.Vdcs.Vdcs {\n\n\t\tadminVdcUrl := adminOrg.client.VCDHREF\n\t\tsplitVdcId := strings.Split(vdcs.HREF, \"/api/vdc/\")\n\t\tif len(splitVdcId) == 1 {\n\t\t\tadminVdcUrl.Path += \"/admin/vdc/\" + strings.Split(vdcs.HREF, \"/api/admin/vdc/\")[1] + \"/action/disable\"\n\t\t} else {\n\t\t\tadminVdcUrl.Path += \"/admin/vdc/\" + splitVdcId[1] + \"/action/disable\"\n\t\t}\n\n\t\treq := adminOrg.client.NewRequest(map[string]string{}, http.MethodPost, adminVdcUrl, nil)\n\t\t_, err := checkResp(adminOrg.client.Http.Do(req))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error disabling vdc: %s\", err)\n\t\t}\n\t\t// Get admin vdc HREF for normal deletion\n\t\tadminVdcUrl.Path = strings.Split(adminVdcUrl.Path, \"/action/disable\")[0]\n\t\treq = adminOrg.client.NewRequest(map[string]string{\n\t\t\t\"recursive\": \"true\",\n\t\t\t\"force\": \"true\",\n\t\t}, http.MethodDelete, adminVdcUrl, nil)\n\t\tresp, err := checkResp(adminOrg.client.Http.Do(req))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error deleting vdc: %s\", err)\n\t\t}\n\t\ttask := NewTask(adminOrg.client)\n\t\tif err = decodeBody(types.BodyTypeXML, resp, task.Task); err != nil {\n\t\t\treturn fmt.Errorf(\"error decoding task response: %s\", err)\n\t\t}\n\t\tif task.Task.Status == \"error\" {\n\t\t\treturn fmt.Errorf(\"vdc not properly destroyed\")\n\t\t}\n\t\terr = task.WaitTaskCompletion()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"couldn't finish removing vdc %s\", err)\n\t\t}\n\n\t}\n\n\treturn nil\n}", "func deleteNodeVIPs(svcIPs []string, protocol v1.Protocol, sourcePort int32) error {\n\tklog.V(5).Infof(\"Searching to remove Gateway VIPs - %s, %d\", protocol, sourcePort)\n\tgatewayRouters, _, err := gateway.GetOvnGateways()\n\tif err != nil {\n\t\tklog.Errorf(\"Error while searching for gateways: %v\", err)\n\t\treturn err\n\t}\n\n\tfor _, gatewayRouter := range gatewayRouters {\n\t\tvar loadBalancers []string\n\t\tgatewayLB, err := gateway.GetGatewayLoadBalancer(gatewayRouter, protocol)\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"Gateway router %s does not have load balancer (%v)\", gatewayRouter, err)\n\t\t\tcontinue\n\t\t}\n\t\tips := svcIPs\n\t\tif len(ips) == 0 {\n\t\t\tips, err = gateway.GetGatewayPhysicalIPs(gatewayRouter)\n\t\t\tif err != nil {\n\t\t\t\tklog.Errorf(\"Gateway router %s does not have physical ip (%v)\", gatewayRouter, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tloadBalancers = append(loadBalancers, gatewayLB)\n\t\tif config.Gateway.Mode == config.GatewayModeShared {\n\t\t\tworkerNode := util.GetWorkerFromGatewayRouter(gatewayRouter)\n\t\t\tworkerLB, err := loadbalancer.GetWorkerLoadBalancer(workerNode, protocol)\n\t\t\tif err != nil {\n\t\t\t\tklog.Errorf(\"Worker switch %s does not have load balancer (%v)\", workerNode, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tloadBalancers = append(loadBalancers, workerLB)\n\t\t}\n\t\tfor _, loadBalancer := range loadBalancers {\n\t\t\tfor _, ip := range ips {\n\t\t\t\t// With the physical_ip:sourcePort as the VIP, delete an entry in 'load_balancer'.\n\t\t\t\tvip := util.JoinHostPortInt32(ip, sourcePort)\n\t\t\t\tklog.V(5).Infof(\"Removing gateway VIP: %s from load balancer: %s\", vip, loadBalancer)\n\t\t\t\tif err := loadbalancer.DeleteLoadBalancerVIP(loadBalancer, vip); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func DHCPsConfigure(dhcp []Dhcp) error {\n\tfor _, d := range dhcp {\n\t\tif isUnmanaged(UnmanagedID(d.Ifname), LINKTYPE) {\n\t\t\tlogger.Log.Info(fmt.Sprintf(\"Skipping Unmanaged Link %v DHCP configuration\", d.Ifname))\n\t\t\tcontinue\n\t\t}\n\t\terr := DHCPDelete(d.Ifname)\n\t\tif err != nil {\n\t\t\tif _, ok := err.(*NotFoundError); ok != true {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tif err := DHCPCreate(d); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (h *ValidationHandler) removeServers(swagger *openapi3.Swagger) (*openapi3.Swagger, error) {\n\t// collect API pathPrefix path prefixes\n\tprefixes := make(map[string]struct{}, 0) // a \"set\"\n\tfor _, s := range swagger.Servers {\n\t\tu, err := url.Parse(s.URL)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tprefixes[u.Path] = struct{}{}\n\t}\n\tif len(prefixes) != 1 {\n\t\treturn nil, fmt.Errorf(\"requires a single API pathPrefix path prefix: %v\", prefixes)\n\t}\n\tvar prefix string\n\tfor k := range prefixes {\n\t\tprefix = k\n\t}\n\n\t// update the paths to start with the API pathPrefix path prefixes\n\tpaths := make(openapi3.Paths, 0)\n\tfor key, path := range swagger.Paths {\n\t\tpaths[prefix+key] = path\n\t}\n\tswagger.Paths = paths\n\n\t// now remove the servers\n\tswagger.Servers = nil\n\n\treturn swagger, nil\n}", "func (self *basicPodManager) DeleteOrphanedMirrorPods() {\n\tpodByFullName, mirrorPodByFullName := self.getFullNameMaps()\n\n\tfor podFullName := range mirrorPodByFullName {\n\t\tif _, ok := podByFullName[podFullName]; !ok {\n\t\t\tself.mirrorClient.DeleteMirrorPod(podFullName)\n\t\t}\n\t}\n}", "func vSphereRemoveHost(ctx context.Context, obj *object.HostSystem) error {\n\tdisconnectTask, err := obj.Disconnect(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := disconnectTask.Wait(ctx); err != nil {\n\t\treturn err\n\t}\n\n\tdestroyTask, err := obj.Destroy(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn destroyTask.Wait(ctx)\n}", "func WithDHCPNameServers(dns []string) Option {\n\treturn func(d *dnsmasq) {\n\t\td.dns = dns\n\t}\n}", "func CyberghostServers() []models.CyberghostServer {\n\treturn []models.CyberghostServer{\n\t\t{Region: \"Albania\", Group: \"Premium TCP Europe\", Hostname: \"97-1-al.cg-dialup.net\", IPs: []net.IP{{31, 171, 155, 3}, {31, 171, 155, 4}, {31, 171, 155, 7}, {31, 171, 155, 8}, {31, 171, 155, 9}, {31, 171, 155, 10}, {31, 171, 155, 11}, {31, 171, 155, 12}, {31, 171, 155, 13}, {31, 171, 155, 14}}},\n\t\t{Region: \"Albania\", Group: \"Premium UDP Europe\", Hostname: \"87-1-al.cg-dialup.net\", IPs: []net.IP{{31, 171, 155, 4}, {31, 171, 155, 5}, {31, 171, 155, 6}, {31, 171, 155, 7}, {31, 171, 155, 8}, {31, 171, 155, 9}, {31, 171, 155, 10}, {31, 171, 155, 11}, {31, 171, 155, 13}, {31, 171, 155, 14}}},\n\t\t{Region: \"Algeria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-dz.cg-dialup.net\", IPs: []net.IP{{176, 125, 228, 132}, {176, 125, 228, 134}, {176, 125, 228, 135}, {176, 125, 228, 136}, {176, 125, 228, 137}, {176, 125, 228, 138}, {176, 125, 228, 139}, {176, 125, 228, 140}, {176, 125, 228, 141}, {176, 125, 228, 142}}},\n\t\t{Region: \"Algeria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-dz.cg-dialup.net\", IPs: []net.IP{{176, 125, 228, 131}, {176, 125, 228, 133}, {176, 125, 228, 134}, {176, 125, 228, 136}, {176, 125, 228, 137}, {176, 125, 228, 139}, {176, 125, 228, 140}, {176, 125, 228, 141}, {176, 125, 228, 142}, {176, 125, 228, 143}}},\n\t\t{Region: \"Andorra\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ad.cg-dialup.net\", IPs: []net.IP{{188, 241, 82, 137}, {188, 241, 82, 138}, {188, 241, 82, 140}, {188, 241, 82, 142}, {188, 241, 82, 147}, {188, 241, 82, 155}, {188, 241, 82, 159}, {188, 241, 82, 160}, {188, 241, 82, 161}, {188, 241, 82, 166}}},\n\t\t{Region: \"Andorra\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ad.cg-dialup.net\", IPs: []net.IP{{188, 241, 82, 133}, {188, 241, 82, 134}, {188, 241, 82, 136}, {188, 241, 82, 137}, {188, 241, 82, 146}, {188, 241, 82, 153}, {188, 241, 82, 155}, {188, 241, 82, 160}, {188, 241, 82, 164}, {188, 241, 82, 168}}},\n\t\t{Region: \"Argentina\", Group: \"Premium TCP USA\", Hostname: \"93-1-ar.cg-dialup.net\", IPs: []net.IP{{146, 70, 39, 4}, {146, 70, 39, 9}, {146, 70, 39, 15}, {146, 70, 39, 19}, {146, 70, 39, 135}, {146, 70, 39, 136}, {146, 70, 39, 139}, {146, 70, 39, 142}, {146, 70, 39, 143}, {146, 70, 39, 145}}},\n\t\t{Region: \"Argentina\", Group: \"Premium UDP USA\", Hostname: \"94-1-ar.cg-dialup.net\", IPs: []net.IP{{146, 70, 39, 3}, {146, 70, 39, 5}, {146, 70, 39, 6}, {146, 70, 39, 8}, {146, 70, 39, 11}, {146, 70, 39, 12}, {146, 70, 39, 131}, {146, 70, 39, 134}, {146, 70, 39, 142}, {146, 70, 39, 143}}},\n\t\t{Region: \"Armenia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-am.cg-dialup.net\", IPs: []net.IP{{185, 253, 160, 131}, {185, 253, 160, 134}, {185, 253, 160, 136}, {185, 253, 160, 137}, {185, 253, 160, 138}, {185, 253, 160, 139}, {185, 253, 160, 140}, {185, 253, 160, 141}, {185, 253, 160, 142}, {185, 253, 160, 143}}},\n\t\t{Region: \"Armenia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-am.cg-dialup.net\", IPs: []net.IP{{185, 253, 160, 131}, {185, 253, 160, 132}, {185, 253, 160, 133}, {185, 253, 160, 134}, {185, 253, 160, 135}, {185, 253, 160, 136}, {185, 253, 160, 137}, {185, 253, 160, 141}, {185, 253, 160, 142}, {185, 253, 160, 144}}},\n\t\t{Region: \"Australia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-au.cg-dialup.net\", IPs: []net.IP{{154, 16, 81, 22}, {181, 214, 215, 7}, {181, 214, 215, 15}, {181, 214, 215, 18}, {191, 101, 210, 15}, {191, 101, 210, 50}, {191, 101, 210, 60}, {202, 60, 80, 78}, {202, 60, 80, 82}, {202, 60, 80, 102}}},\n\t\t{Region: \"Australia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-au.cg-dialup.net\", IPs: []net.IP{{181, 214, 215, 4}, {181, 214, 215, 16}, {191, 101, 210, 18}, {191, 101, 210, 21}, {191, 101, 210, 36}, {191, 101, 210, 58}, {191, 101, 210, 60}, {202, 60, 80, 74}, {202, 60, 80, 106}, {202, 60, 80, 124}}},\n\t\t{Region: \"Austria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-at.cg-dialup.net\", IPs: []net.IP{{37, 19, 223, 9}, {37, 19, 223, 16}, {37, 19, 223, 113}, {37, 19, 223, 205}, {37, 19, 223, 211}, {37, 19, 223, 218}, {37, 19, 223, 223}, {37, 19, 223, 245}, {37, 120, 155, 104}, {89, 187, 168, 174}}},\n\t\t{Region: \"Austria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-at.cg-dialup.net\", IPs: []net.IP{{37, 19, 223, 202}, {37, 19, 223, 205}, {37, 19, 223, 229}, {37, 19, 223, 239}, {37, 19, 223, 241}, {37, 19, 223, 243}, {37, 120, 155, 103}, {89, 187, 168, 160}, {89, 187, 168, 174}, {89, 187, 168, 181}}},\n\t\t{Region: \"Bahamas\", Group: \"Premium TCP USA\", Hostname: \"93-1-bs.cg-dialup.net\", IPs: []net.IP{{95, 181, 238, 131}, {95, 181, 238, 136}, {95, 181, 238, 142}, {95, 181, 238, 144}, {95, 181, 238, 146}, {95, 181, 238, 147}, {95, 181, 238, 148}, {95, 181, 238, 152}, {95, 181, 238, 153}, {95, 181, 238, 155}}},\n\t\t{Region: \"Bahamas\", Group: \"Premium UDP USA\", Hostname: \"94-1-bs.cg-dialup.net\", IPs: []net.IP{{95, 181, 238, 131}, {95, 181, 238, 138}, {95, 181, 238, 140}, {95, 181, 238, 141}, {95, 181, 238, 146}, {95, 181, 238, 147}, {95, 181, 238, 148}, {95, 181, 238, 151}, {95, 181, 238, 153}, {95, 181, 238, 155}}},\n\t\t{Region: \"Bangladesh\", Group: \"Premium TCP Asia\", Hostname: \"96-1-bd.cg-dialup.net\", IPs: []net.IP{{84, 252, 93, 132}, {84, 252, 93, 133}, {84, 252, 93, 135}, {84, 252, 93, 138}, {84, 252, 93, 139}, {84, 252, 93, 141}, {84, 252, 93, 142}, {84, 252, 93, 143}, {84, 252, 93, 144}, {84, 252, 93, 145}}},\n\t\t{Region: \"Bangladesh\", Group: \"Premium UDP Asia\", Hostname: \"95-1-bd.cg-dialup.net\", IPs: []net.IP{{84, 252, 93, 131}, {84, 252, 93, 133}, {84, 252, 93, 134}, {84, 252, 93, 135}, {84, 252, 93, 136}, {84, 252, 93, 139}, {84, 252, 93, 140}, {84, 252, 93, 141}, {84, 252, 93, 143}, {84, 252, 93, 145}}},\n\t\t{Region: \"Belarus\", Group: \"Premium TCP Europe\", Hostname: \"97-1-by.cg-dialup.net\", IPs: []net.IP{{45, 132, 194, 5}, {45, 132, 194, 6}, {45, 132, 194, 23}, {45, 132, 194, 24}, {45, 132, 194, 25}, {45, 132, 194, 27}, {45, 132, 194, 30}, {45, 132, 194, 35}, {45, 132, 194, 44}, {45, 132, 194, 49}}},\n\t\t{Region: \"Belarus\", Group: \"Premium UDP Europe\", Hostname: \"87-1-by.cg-dialup.net\", IPs: []net.IP{{45, 132, 194, 6}, {45, 132, 194, 8}, {45, 132, 194, 9}, {45, 132, 194, 11}, {45, 132, 194, 15}, {45, 132, 194, 19}, {45, 132, 194, 20}, {45, 132, 194, 23}, {45, 132, 194, 24}, {45, 132, 194, 26}}},\n\t\t{Region: \"Belgium\", Group: \"Premium TCP Europe\", Hostname: \"97-1-be.cg-dialup.net\", IPs: []net.IP{{37, 120, 143, 165}, {37, 120, 143, 166}, {185, 210, 217, 10}, {185, 210, 217, 248}, {193, 9, 114, 211}, {193, 9, 114, 220}, {194, 110, 115, 195}, {194, 110, 115, 199}, {194, 110, 115, 205}, {194, 110, 115, 238}}},\n\t\t{Region: \"Belgium\", Group: \"Premium UDP Europe\", Hostname: \"87-1-be.cg-dialup.net\", IPs: []net.IP{{37, 120, 143, 163}, {37, 120, 143, 167}, {185, 210, 217, 9}, {185, 210, 217, 13}, {185, 210, 217, 55}, {185, 210, 217, 251}, {185, 232, 21, 120}, {194, 110, 115, 214}, {194, 110, 115, 218}, {194, 110, 115, 236}}},\n\t\t{Region: \"Bosnia and Herzegovina\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ba.cg-dialup.net\", IPs: []net.IP{{185, 99, 3, 57}, {185, 99, 3, 58}, {185, 99, 3, 72}, {185, 99, 3, 73}, {185, 99, 3, 74}, {185, 99, 3, 130}, {185, 99, 3, 131}, {185, 99, 3, 134}, {185, 99, 3, 135}, {185, 99, 3, 136}}},\n\t\t{Region: \"Bosnia and Herzegovina\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ba.cg-dialup.net\", IPs: []net.IP{{185, 99, 3, 57}, {185, 99, 3, 58}, {185, 99, 3, 72}, {185, 99, 3, 73}, {185, 99, 3, 74}, {185, 99, 3, 130}, {185, 99, 3, 131}, {185, 99, 3, 134}, {185, 99, 3, 135}, {185, 99, 3, 136}}},\n\t\t{Region: \"Brazil\", Group: \"Premium TCP USA\", Hostname: \"93-1-br.cg-dialup.net\", IPs: []net.IP{{188, 241, 177, 5}, {188, 241, 177, 11}, {188, 241, 177, 38}, {188, 241, 177, 45}, {188, 241, 177, 132}, {188, 241, 177, 135}, {188, 241, 177, 136}, {188, 241, 177, 152}, {188, 241, 177, 153}, {188, 241, 177, 156}}},\n\t\t{Region: \"Brazil\", Group: \"Premium UDP USA\", Hostname: \"94-1-br.cg-dialup.net\", IPs: []net.IP{{188, 241, 177, 8}, {188, 241, 177, 37}, {188, 241, 177, 40}, {188, 241, 177, 42}, {188, 241, 177, 45}, {188, 241, 177, 135}, {188, 241, 177, 139}, {188, 241, 177, 149}, {188, 241, 177, 152}, {188, 241, 177, 154}}},\n\t\t{Region: \"Bulgaria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-bg.cg-dialup.net\", IPs: []net.IP{{37, 120, 152, 99}, {37, 120, 152, 101}, {37, 120, 152, 103}, {37, 120, 152, 104}, {37, 120, 152, 105}, {37, 120, 152, 106}, {37, 120, 152, 107}, {37, 120, 152, 108}, {37, 120, 152, 109}, {37, 120, 152, 110}}},\n\t\t{Region: \"Bulgaria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-bg.cg-dialup.net\", IPs: []net.IP{{37, 120, 152, 99}, {37, 120, 152, 100}, {37, 120, 152, 101}, {37, 120, 152, 102}, {37, 120, 152, 103}, {37, 120, 152, 105}, {37, 120, 152, 106}, {37, 120, 152, 107}, {37, 120, 152, 108}, {37, 120, 152, 109}}},\n\t\t{Region: \"Cambodia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-kh.cg-dialup.net\", IPs: []net.IP{{188, 215, 235, 35}, {188, 215, 235, 36}, {188, 215, 235, 38}, {188, 215, 235, 39}, {188, 215, 235, 45}, {188, 215, 235, 49}, {188, 215, 235, 51}, {188, 215, 235, 53}, {188, 215, 235, 54}, {188, 215, 235, 57}}},\n\t\t{Region: \"Cambodia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-kh.cg-dialup.net\", IPs: []net.IP{{188, 215, 235, 36}, {188, 215, 235, 40}, {188, 215, 235, 42}, {188, 215, 235, 44}, {188, 215, 235, 46}, {188, 215, 235, 47}, {188, 215, 235, 48}, {188, 215, 235, 50}, {188, 215, 235, 55}, {188, 215, 235, 57}}},\n\t\t{Region: \"Canada\", Group: \"Premium TCP USA\", Hostname: \"93-1-ca.cg-dialup.net\", IPs: []net.IP{{66, 115, 142, 136}, {66, 115, 142, 139}, {66, 115, 142, 156}, {66, 115, 142, 162}, {66, 115, 142, 172}, {104, 200, 151, 99}, {104, 200, 151, 111}, {104, 200, 151, 153}, {104, 200, 151, 164}, {172, 98, 89, 137}}},\n\t\t{Region: \"Canada\", Group: \"Premium UDP USA\", Hostname: \"94-1-ca.cg-dialup.net\", IPs: []net.IP{{66, 115, 142, 135}, {66, 115, 142, 154}, {66, 115, 142, 165}, {104, 200, 151, 32}, {104, 200, 151, 57}, {104, 200, 151, 85}, {104, 200, 151, 86}, {104, 200, 151, 147}, {172, 98, 89, 144}, {172, 98, 89, 173}}},\n\t\t{Region: \"Chile\", Group: \"Premium TCP USA\", Hostname: \"93-1-cl.cg-dialup.net\", IPs: []net.IP{{146, 70, 11, 3}, {146, 70, 11, 6}, {146, 70, 11, 7}, {146, 70, 11, 8}, {146, 70, 11, 9}, {146, 70, 11, 10}, {146, 70, 11, 11}, {146, 70, 11, 12}, {146, 70, 11, 13}, {146, 70, 11, 14}}},\n\t\t{Region: \"Chile\", Group: \"Premium UDP USA\", Hostname: \"94-1-cl.cg-dialup.net\", IPs: []net.IP{{146, 70, 11, 3}, {146, 70, 11, 4}, {146, 70, 11, 6}, {146, 70, 11, 7}, {146, 70, 11, 8}, {146, 70, 11, 9}, {146, 70, 11, 10}, {146, 70, 11, 11}, {146, 70, 11, 13}, {146, 70, 11, 14}}},\n\t\t{Region: \"China\", Group: \"Premium TCP Asia\", Hostname: \"96-1-cn.cg-dialup.net\", IPs: []net.IP{{188, 241, 80, 131}, {188, 241, 80, 132}, {188, 241, 80, 133}, {188, 241, 80, 134}, {188, 241, 80, 135}, {188, 241, 80, 137}, {188, 241, 80, 139}, {188, 241, 80, 140}, {188, 241, 80, 141}, {188, 241, 80, 142}}},\n\t\t{Region: \"China\", Group: \"Premium UDP Asia\", Hostname: \"95-1-cn.cg-dialup.net\", IPs: []net.IP{{188, 241, 80, 131}, {188, 241, 80, 132}, {188, 241, 80, 133}, {188, 241, 80, 134}, {188, 241, 80, 135}, {188, 241, 80, 136}, {188, 241, 80, 137}, {188, 241, 80, 138}, {188, 241, 80, 139}, {188, 241, 80, 142}}},\n\t\t{Region: \"Colombia\", Group: \"Premium TCP USA\", Hostname: \"93-1-co.cg-dialup.net\", IPs: []net.IP{{146, 70, 9, 3}, {146, 70, 9, 4}, {146, 70, 9, 5}, {146, 70, 9, 7}, {146, 70, 9, 9}, {146, 70, 9, 10}, {146, 70, 9, 11}, {146, 70, 9, 12}, {146, 70, 9, 13}, {146, 70, 9, 14}}},\n\t\t{Region: \"Colombia\", Group: \"Premium UDP USA\", Hostname: \"94-1-co.cg-dialup.net\", IPs: []net.IP{{146, 70, 9, 3}, {146, 70, 9, 4}, {146, 70, 9, 5}, {146, 70, 9, 6}, {146, 70, 9, 7}, {146, 70, 9, 8}, {146, 70, 9, 9}, {146, 70, 9, 10}, {146, 70, 9, 11}, {146, 70, 9, 12}}},\n\t\t{Region: \"Costa Rica\", Group: \"Premium TCP USA\", Hostname: \"93-1-cr.cg-dialup.net\", IPs: []net.IP{{146, 70, 10, 3}, {146, 70, 10, 4}, {146, 70, 10, 5}, {146, 70, 10, 6}, {146, 70, 10, 7}, {146, 70, 10, 8}, {146, 70, 10, 10}, {146, 70, 10, 11}, {146, 70, 10, 12}, {146, 70, 10, 13}}},\n\t\t{Region: \"Costa Rica\", Group: \"Premium UDP USA\", Hostname: \"94-1-cr.cg-dialup.net\", IPs: []net.IP{{146, 70, 10, 3}, {146, 70, 10, 4}, {146, 70, 10, 5}, {146, 70, 10, 6}, {146, 70, 10, 7}, {146, 70, 10, 8}, {146, 70, 10, 9}, {146, 70, 10, 11}, {146, 70, 10, 12}, {146, 70, 10, 14}}},\n\t\t{Region: \"Croatia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-hr.cg-dialup.net\", IPs: []net.IP{{146, 70, 8, 5}, {146, 70, 8, 8}, {146, 70, 8, 9}, {146, 70, 8, 10}, {146, 70, 8, 11}, {146, 70, 8, 12}, {146, 70, 8, 13}, {146, 70, 8, 14}, {146, 70, 8, 15}, {146, 70, 8, 16}}},\n\t\t{Region: \"Croatia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-hr.cg-dialup.net\", IPs: []net.IP{{146, 70, 8, 3}, {146, 70, 8, 4}, {146, 70, 8, 5}, {146, 70, 8, 6}, {146, 70, 8, 7}, {146, 70, 8, 9}, {146, 70, 8, 11}, {146, 70, 8, 13}, {146, 70, 8, 14}, {146, 70, 8, 16}}},\n\t\t{Region: \"Cyprus\", Group: \"Premium TCP Europe\", Hostname: \"97-1-cy.cg-dialup.net\", IPs: []net.IP{{185, 253, 162, 131}, {185, 253, 162, 133}, {185, 253, 162, 135}, {185, 253, 162, 136}, {185, 253, 162, 137}, {185, 253, 162, 139}, {185, 253, 162, 140}, {185, 253, 162, 142}, {185, 253, 162, 143}, {185, 253, 162, 144}}},\n\t\t{Region: \"Cyprus\", Group: \"Premium UDP Europe\", Hostname: \"87-1-cy.cg-dialup.net\", IPs: []net.IP{{185, 253, 162, 131}, {185, 253, 162, 132}, {185, 253, 162, 134}, {185, 253, 162, 135}, {185, 253, 162, 137}, {185, 253, 162, 138}, {185, 253, 162, 140}, {185, 253, 162, 142}, {185, 253, 162, 143}, {185, 253, 162, 144}}},\n\t\t{Region: \"Czech Republic\", Group: \"Premium TCP Europe\", Hostname: \"97-1-cz.cg-dialup.net\", IPs: []net.IP{{138, 199, 56, 235}, {138, 199, 56, 236}, {138, 199, 56, 237}, {138, 199, 56, 245}, {138, 199, 56, 246}, {138, 199, 56, 249}, {195, 181, 161, 12}, {195, 181, 161, 16}, {195, 181, 161, 20}, {195, 181, 161, 23}}},\n\t\t{Region: \"Czech Republic\", Group: \"Premium UDP Europe\", Hostname: \"87-1-cz.cg-dialup.net\", IPs: []net.IP{{138, 199, 56, 227}, {138, 199, 56, 229}, {138, 199, 56, 231}, {138, 199, 56, 235}, {138, 199, 56, 241}, {138, 199, 56, 247}, {195, 181, 161, 10}, {195, 181, 161, 16}, {195, 181, 161, 18}, {195, 181, 161, 22}}},\n\t\t{Region: \"Denmark\", Group: \"Premium TCP Europe\", Hostname: \"97-1-dk.cg-dialup.net\", IPs: []net.IP{{37, 120, 145, 83}, {37, 120, 145, 88}, {37, 120, 145, 93}, {37, 120, 194, 36}, {37, 120, 194, 56}, {37, 120, 194, 57}, {95, 174, 65, 163}, {95, 174, 65, 174}, {185, 206, 224, 238}, {185, 206, 224, 243}}},\n\t\t{Region: \"Denmark\", Group: \"Premium UDP Europe\", Hostname: \"87-1-dk.cg-dialup.net\", IPs: []net.IP{{37, 120, 194, 39}, {95, 174, 65, 167}, {95, 174, 65, 170}, {185, 206, 224, 227}, {185, 206, 224, 230}, {185, 206, 224, 236}, {185, 206, 224, 238}, {185, 206, 224, 245}, {185, 206, 224, 250}, {185, 206, 224, 254}}},\n\t\t{Region: \"Egypt\", Group: \"Premium TCP Europe\", Hostname: \"97-1-eg.cg-dialup.net\", IPs: []net.IP{{188, 214, 122, 40}, {188, 214, 122, 42}, {188, 214, 122, 43}, {188, 214, 122, 45}, {188, 214, 122, 48}, {188, 214, 122, 50}, {188, 214, 122, 52}, {188, 214, 122, 60}, {188, 214, 122, 70}, {188, 214, 122, 73}}},\n\t\t{Region: \"Egypt\", Group: \"Premium UDP Europe\", Hostname: \"87-1-eg.cg-dialup.net\", IPs: []net.IP{{188, 214, 122, 37}, {188, 214, 122, 38}, {188, 214, 122, 44}, {188, 214, 122, 54}, {188, 214, 122, 57}, {188, 214, 122, 59}, {188, 214, 122, 60}, {188, 214, 122, 61}, {188, 214, 122, 67}, {188, 214, 122, 69}}},\n\t\t{Region: \"Estonia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ee.cg-dialup.net\", IPs: []net.IP{{95, 153, 32, 83}, {95, 153, 32, 84}, {95, 153, 32, 86}, {95, 153, 32, 88}, {95, 153, 32, 89}, {95, 153, 32, 90}, {95, 153, 32, 91}, {95, 153, 32, 92}, {95, 153, 32, 93}, {95, 153, 32, 94}}},\n\t\t{Region: \"Estonia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ee.cg-dialup.net\", IPs: []net.IP{{95, 153, 32, 83}, {95, 153, 32, 84}, {95, 153, 32, 85}, {95, 153, 32, 87}, {95, 153, 32, 88}, {95, 153, 32, 89}, {95, 153, 32, 90}, {95, 153, 32, 91}, {95, 153, 32, 92}, {95, 153, 32, 94}}},\n\t\t{Region: \"Finland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-fi.cg-dialup.net\", IPs: []net.IP{{188, 126, 89, 99}, {188, 126, 89, 102}, {188, 126, 89, 105}, {188, 126, 89, 107}, {188, 126, 89, 108}, {188, 126, 89, 110}, {188, 126, 89, 112}, {188, 126, 89, 115}, {188, 126, 89, 116}, {188, 126, 89, 119}}},\n\t\t{Region: \"Finland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-fi.cg-dialup.net\", IPs: []net.IP{{188, 126, 89, 101}, {188, 126, 89, 104}, {188, 126, 89, 109}, {188, 126, 89, 110}, {188, 126, 89, 111}, {188, 126, 89, 113}, {188, 126, 89, 114}, {188, 126, 89, 115}, {188, 126, 89, 122}, {188, 126, 89, 124}}},\n\t\t{Region: \"France\", Group: \"Premium TCP Europe\", Hostname: \"97-1-fr.cg-dialup.net\", IPs: []net.IP{{84, 17, 43, 167}, {84, 17, 60, 147}, {84, 17, 60, 155}, {151, 106, 8, 108}, {191, 101, 31, 202}, {191, 101, 31, 254}, {191, 101, 217, 45}, {191, 101, 217, 159}, {191, 101, 217, 211}, {191, 101, 217, 240}}},\n\t\t{Region: \"France\", Group: \"Premium UDP Europe\", Hostname: \"87-1-fr.cg-dialup.net\", IPs: []net.IP{{84, 17, 60, 59}, {84, 17, 60, 121}, {191, 101, 31, 81}, {191, 101, 31, 84}, {191, 101, 31, 126}, {191, 101, 31, 127}, {191, 101, 217, 140}, {191, 101, 217, 201}, {191, 101, 217, 206}, {191, 101, 217, 211}}},\n\t\t{Region: \"Georgia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ge.cg-dialup.net\", IPs: []net.IP{{95, 181, 236, 131}, {95, 181, 236, 132}, {95, 181, 236, 133}, {95, 181, 236, 134}, {95, 181, 236, 135}, {95, 181, 236, 136}, {95, 181, 236, 138}, {95, 181, 236, 139}, {95, 181, 236, 142}, {95, 181, 236, 144}}},\n\t\t{Region: \"Georgia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ge.cg-dialup.net\", IPs: []net.IP{{95, 181, 236, 132}, {95, 181, 236, 133}, {95, 181, 236, 134}, {95, 181, 236, 136}, {95, 181, 236, 137}, {95, 181, 236, 139}, {95, 181, 236, 141}, {95, 181, 236, 142}, {95, 181, 236, 143}, {95, 181, 236, 144}}},\n\t\t{Region: \"Germany\", Group: \"Premium TCP Europe\", Hostname: \"97-1-de.cg-dialup.net\", IPs: []net.IP{{84, 17, 48, 39}, {84, 17, 48, 234}, {84, 17, 49, 106}, {84, 17, 49, 112}, {84, 17, 49, 218}, {154, 28, 188, 35}, {154, 28, 188, 66}, {154, 28, 188, 133}, {154, 28, 188, 144}, {154, 28, 188, 145}}},\n\t\t{Region: \"Germany\", Group: \"Premium UDP Europe\", Hostname: \"87-1-de.cg-dialup.net\", IPs: []net.IP{{84, 17, 48, 41}, {84, 17, 48, 224}, {84, 17, 49, 95}, {84, 17, 49, 236}, {84, 17, 49, 241}, {138, 199, 36, 151}, {154, 13, 1, 177}, {154, 28, 188, 73}, {154, 28, 188, 76}, {154, 28, 188, 93}}},\n\t\t{Region: \"Greece\", Group: \"Premium TCP Europe\", Hostname: \"97-1-gr.cg-dialup.net\", IPs: []net.IP{{185, 51, 134, 163}, {185, 51, 134, 165}, {185, 51, 134, 171}, {185, 51, 134, 172}, {185, 51, 134, 245}, {185, 51, 134, 246}, {185, 51, 134, 247}, {185, 51, 134, 249}, {185, 51, 134, 251}, {185, 51, 134, 254}}},\n\t\t{Region: \"Greece\", Group: \"Premium UDP Europe\", Hostname: \"87-1-gr.cg-dialup.net\", IPs: []net.IP{{185, 51, 134, 163}, {185, 51, 134, 166}, {185, 51, 134, 173}, {185, 51, 134, 174}, {185, 51, 134, 244}, {185, 51, 134, 246}, {185, 51, 134, 247}, {185, 51, 134, 251}, {185, 51, 134, 252}, {185, 51, 134, 253}}},\n\t\t{Region: \"Greenland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-gl.cg-dialup.net\", IPs: []net.IP{{91, 90, 120, 3}, {91, 90, 120, 4}, {91, 90, 120, 5}, {91, 90, 120, 7}, {91, 90, 120, 8}, {91, 90, 120, 10}, {91, 90, 120, 12}, {91, 90, 120, 13}, {91, 90, 120, 14}, {91, 90, 120, 17}}},\n\t\t{Region: \"Greenland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-gl.cg-dialup.net\", IPs: []net.IP{{91, 90, 120, 3}, {91, 90, 120, 4}, {91, 90, 120, 5}, {91, 90, 120, 7}, {91, 90, 120, 9}, {91, 90, 120, 10}, {91, 90, 120, 12}, {91, 90, 120, 14}, {91, 90, 120, 15}, {91, 90, 120, 16}}},\n\t\t{Region: \"Hong Kong\", Group: \"Premium TCP Asia\", Hostname: \"96-1-hk.cg-dialup.net\", IPs: []net.IP{{84, 17, 56, 144}, {84, 17, 56, 148}, {84, 17, 56, 153}, {84, 17, 56, 162}, {84, 17, 56, 163}, {84, 17, 56, 169}, {84, 17, 56, 170}, {84, 17, 56, 179}, {84, 17, 56, 180}, {84, 17, 56, 181}}},\n\t\t{Region: \"Hong Kong\", Group: \"Premium UDP Asia\", Hostname: \"95-1-hk.cg-dialup.net\", IPs: []net.IP{{84, 17, 56, 143}, {84, 17, 56, 147}, {84, 17, 56, 150}, {84, 17, 56, 152}, {84, 17, 56, 161}, {84, 17, 56, 164}, {84, 17, 56, 168}, {84, 17, 56, 179}, {84, 17, 56, 180}, {84, 17, 56, 183}}},\n\t\t{Region: \"Hungary\", Group: \"Premium TCP Europe\", Hostname: \"97-1-hu.cg-dialup.net\", IPs: []net.IP{{86, 106, 74, 247}, {86, 106, 74, 251}, {86, 106, 74, 253}, {185, 189, 114, 117}, {185, 189, 114, 118}, {185, 189, 114, 119}, {185, 189, 114, 121}, {185, 189, 114, 123}, {185, 189, 114, 125}, {185, 189, 114, 126}}},\n\t\t{Region: \"Hungary\", Group: \"Premium UDP Europe\", Hostname: \"87-1-hu.cg-dialup.net\", IPs: []net.IP{{86, 106, 74, 245}, {86, 106, 74, 247}, {86, 106, 74, 248}, {86, 106, 74, 249}, {86, 106, 74, 250}, {86, 106, 74, 252}, {86, 106, 74, 253}, {185, 189, 114, 120}, {185, 189, 114, 121}, {185, 189, 114, 122}}},\n\t\t{Region: \"Iceland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-is.cg-dialup.net\", IPs: []net.IP{{45, 133, 193, 3}, {45, 133, 193, 4}, {45, 133, 193, 6}, {45, 133, 193, 7}, {45, 133, 193, 8}, {45, 133, 193, 10}, {45, 133, 193, 11}, {45, 133, 193, 12}, {45, 133, 193, 13}, {45, 133, 193, 14}}},\n\t\t{Region: \"Iceland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-is.cg-dialup.net\", IPs: []net.IP{{45, 133, 193, 3}, {45, 133, 193, 5}, {45, 133, 193, 6}, {45, 133, 193, 7}, {45, 133, 193, 8}, {45, 133, 193, 9}, {45, 133, 193, 10}, {45, 133, 193, 11}, {45, 133, 193, 13}, {45, 133, 193, 14}}},\n\t\t{Region: \"India\", Group: \"Premium TCP Europe\", Hostname: \"97-1-in.cg-dialup.net\", IPs: []net.IP{{103, 13, 112, 68}, {103, 13, 112, 70}, {103, 13, 112, 72}, {103, 13, 112, 74}, {103, 13, 112, 75}, {103, 13, 113, 74}, {103, 13, 113, 79}, {103, 13, 113, 82}, {103, 13, 113, 83}, {103, 13, 113, 84}}},\n\t\t{Region: \"India\", Group: \"Premium UDP Europe\", Hostname: \"87-1-in.cg-dialup.net\", IPs: []net.IP{{103, 13, 112, 67}, {103, 13, 112, 70}, {103, 13, 112, 71}, {103, 13, 112, 77}, {103, 13, 112, 80}, {103, 13, 113, 72}, {103, 13, 113, 74}, {103, 13, 113, 75}, {103, 13, 113, 77}, {103, 13, 113, 85}}},\n\t\t{Region: \"Indonesia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-id.cg-dialup.net\", IPs: []net.IP{{146, 70, 14, 3}, {146, 70, 14, 4}, {146, 70, 14, 5}, {146, 70, 14, 6}, {146, 70, 14, 7}, {146, 70, 14, 10}, {146, 70, 14, 12}, {146, 70, 14, 13}, {146, 70, 14, 15}, {146, 70, 14, 16}}},\n\t\t{Region: \"Indonesia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-id.cg-dialup.net\", IPs: []net.IP{{146, 70, 14, 3}, {146, 70, 14, 5}, {146, 70, 14, 8}, {146, 70, 14, 9}, {146, 70, 14, 10}, {146, 70, 14, 12}, {146, 70, 14, 13}, {146, 70, 14, 14}, {146, 70, 14, 15}, {146, 70, 14, 16}}},\n\t\t{Region: \"Iran\", Group: \"Premium TCP Asia\", Hostname: \"96-1-ir.cg-dialup.net\", IPs: []net.IP{{62, 133, 46, 3}, {62, 133, 46, 4}, {62, 133, 46, 5}, {62, 133, 46, 6}, {62, 133, 46, 7}, {62, 133, 46, 8}, {62, 133, 46, 9}, {62, 133, 46, 10}, {62, 133, 46, 14}, {62, 133, 46, 15}}},\n\t\t{Region: \"Iran\", Group: \"Premium UDP Asia\", Hostname: \"95-1-ir.cg-dialup.net\", IPs: []net.IP{{62, 133, 46, 3}, {62, 133, 46, 4}, {62, 133, 46, 7}, {62, 133, 46, 8}, {62, 133, 46, 11}, {62, 133, 46, 12}, {62, 133, 46, 13}, {62, 133, 46, 14}, {62, 133, 46, 15}, {62, 133, 46, 16}}},\n\t\t{Region: \"Ireland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ie.cg-dialup.net\", IPs: []net.IP{{37, 120, 235, 154}, {37, 120, 235, 166}, {37, 120, 235, 174}, {77, 81, 139, 35}, {84, 247, 48, 6}, {84, 247, 48, 19}, {84, 247, 48, 22}, {84, 247, 48, 23}, {84, 247, 48, 25}, {84, 247, 48, 26}}},\n\t\t{Region: \"Ireland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ie.cg-dialup.net\", IPs: []net.IP{{37, 120, 235, 147}, {37, 120, 235, 148}, {37, 120, 235, 153}, {37, 120, 235, 158}, {37, 120, 235, 169}, {37, 120, 235, 174}, {84, 247, 48, 8}, {84, 247, 48, 11}, {84, 247, 48, 20}, {84, 247, 48, 23}}},\n\t\t{Region: \"Isle of Man\", Group: \"Premium TCP Europe\", Hostname: \"97-1-im.cg-dialup.net\", IPs: []net.IP{{91, 90, 124, 147}, {91, 90, 124, 149}, {91, 90, 124, 150}, {91, 90, 124, 151}, {91, 90, 124, 152}, {91, 90, 124, 153}, {91, 90, 124, 154}, {91, 90, 124, 156}, {91, 90, 124, 157}, {91, 90, 124, 158}}},\n\t\t{Region: \"Isle of Man\", Group: \"Premium UDP Europe\", Hostname: \"87-1-im.cg-dialup.net\", IPs: []net.IP{{91, 90, 124, 147}, {91, 90, 124, 149}, {91, 90, 124, 150}, {91, 90, 124, 151}, {91, 90, 124, 152}, {91, 90, 124, 153}, {91, 90, 124, 154}, {91, 90, 124, 155}, {91, 90, 124, 156}, {91, 90, 124, 157}}},\n\t\t{Region: \"Israel\", Group: \"Premium TCP Europe\", Hostname: \"97-1-il.cg-dialup.net\", IPs: []net.IP{{160, 116, 0, 174}, {185, 77, 248, 103}, {185, 77, 248, 111}, {185, 77, 248, 113}, {185, 77, 248, 114}, {185, 77, 248, 124}, {185, 77, 248, 125}, {185, 77, 248, 127}, {185, 77, 248, 128}, {185, 77, 248, 129}}},\n\t\t{Region: \"Israel\", Group: \"Premium UDP Europe\", Hostname: \"87-1-il.cg-dialup.net\", IPs: []net.IP{{160, 116, 0, 163}, {160, 116, 0, 165}, {160, 116, 0, 172}, {185, 77, 248, 103}, {185, 77, 248, 106}, {185, 77, 248, 114}, {185, 77, 248, 117}, {185, 77, 248, 118}, {185, 77, 248, 126}, {185, 77, 248, 129}}},\n\t\t{Region: \"Italy\", Group: \"Premium TCP Europe\", Hostname: \"97-1-it.cg-dialup.net\", IPs: []net.IP{{84, 17, 58, 21}, {84, 17, 58, 100}, {84, 17, 58, 106}, {84, 17, 58, 111}, {84, 17, 58, 117}, {87, 101, 94, 122}, {212, 102, 55, 100}, {212, 102, 55, 106}, {212, 102, 55, 110}, {212, 102, 55, 122}}},\n\t\t{Region: \"Italy\", Group: \"Premium UDP Europe\", Hostname: \"87-1-it.cg-dialup.net\", IPs: []net.IP{{84, 17, 58, 19}, {84, 17, 58, 95}, {84, 17, 58, 105}, {84, 17, 58, 119}, {84, 17, 58, 120}, {87, 101, 94, 116}, {185, 217, 71, 137}, {185, 217, 71, 138}, {185, 217, 71, 153}, {212, 102, 55, 108}}},\n\t\t{Region: \"Japan\", Group: \"Premium TCP Asia\", Hostname: \"96-1-jp.cg-dialup.net\", IPs: []net.IP{{156, 146, 35, 6}, {156, 146, 35, 10}, {156, 146, 35, 15}, {156, 146, 35, 22}, {156, 146, 35, 37}, {156, 146, 35, 39}, {156, 146, 35, 40}, {156, 146, 35, 41}, {156, 146, 35, 44}, {156, 146, 35, 50}}},\n\t\t{Region: \"Japan\", Group: \"Premium UDP Asia\", Hostname: \"95-1-jp.cg-dialup.net\", IPs: []net.IP{{156, 146, 35, 4}, {156, 146, 35, 14}, {156, 146, 35, 15}, {156, 146, 35, 18}, {156, 146, 35, 25}, {156, 146, 35, 34}, {156, 146, 35, 36}, {156, 146, 35, 46}, {156, 146, 35, 49}, {156, 146, 35, 50}}},\n\t\t{Region: \"Kazakhstan\", Group: \"Premium TCP Europe\", Hostname: \"97-1-kz.cg-dialup.net\", IPs: []net.IP{{62, 133, 47, 131}, {62, 133, 47, 132}, {62, 133, 47, 134}, {62, 133, 47, 136}, {62, 133, 47, 138}, {62, 133, 47, 139}, {62, 133, 47, 140}, {62, 133, 47, 142}, {62, 133, 47, 143}, {62, 133, 47, 144}}},\n\t\t{Region: \"Kazakhstan\", Group: \"Premium UDP Europe\", Hostname: \"87-1-kz.cg-dialup.net\", IPs: []net.IP{{62, 133, 47, 131}, {62, 133, 47, 132}, {62, 133, 47, 133}, {62, 133, 47, 134}, {62, 133, 47, 135}, {62, 133, 47, 138}, {62, 133, 47, 139}, {62, 133, 47, 140}, {62, 133, 47, 142}, {62, 133, 47, 143}}},\n\t\t{Region: \"Kenya\", Group: \"Premium TCP Asia\", Hostname: \"96-1-ke.cg-dialup.net\", IPs: []net.IP{{62, 12, 118, 195}, {62, 12, 118, 196}, {62, 12, 118, 197}, {62, 12, 118, 198}, {62, 12, 118, 199}, {62, 12, 118, 200}, {62, 12, 118, 201}, {62, 12, 118, 202}, {62, 12, 118, 203}, {62, 12, 118, 204}}},\n\t\t{Region: \"Kenya\", Group: \"Premium UDP Asia\", Hostname: \"95-1-ke.cg-dialup.net\", IPs: []net.IP{{62, 12, 118, 195}, {62, 12, 118, 196}, {62, 12, 118, 197}, {62, 12, 118, 198}, {62, 12, 118, 199}, {62, 12, 118, 200}, {62, 12, 118, 201}, {62, 12, 118, 202}, {62, 12, 118, 203}, {62, 12, 118, 204}}},\n\t\t{Region: \"Korea\", Group: \"Premium TCP Asia\", Hostname: \"96-1-kr.cg-dialup.net\", IPs: []net.IP{{79, 110, 55, 131}, {79, 110, 55, 134}, {79, 110, 55, 141}, {79, 110, 55, 147}, {79, 110, 55, 148}, {79, 110, 55, 151}, {79, 110, 55, 152}, {79, 110, 55, 153}, {79, 110, 55, 155}, {79, 110, 55, 157}}},\n\t\t{Region: \"Korea\", Group: \"Premium UDP Asia\", Hostname: \"95-1-kr.cg-dialup.net\", IPs: []net.IP{{79, 110, 55, 131}, {79, 110, 55, 133}, {79, 110, 55, 134}, {79, 110, 55, 136}, {79, 110, 55, 138}, {79, 110, 55, 140}, {79, 110, 55, 149}, {79, 110, 55, 151}, {79, 110, 55, 152}, {79, 110, 55, 157}}},\n\t\t{Region: \"Latvia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-lv.cg-dialup.net\", IPs: []net.IP{{109, 248, 148, 244}, {109, 248, 148, 245}, {109, 248, 148, 246}, {109, 248, 148, 247}, {109, 248, 148, 249}, {109, 248, 148, 250}, {109, 248, 148, 253}, {109, 248, 149, 22}, {109, 248, 149, 24}, {109, 248, 149, 25}}},\n\t\t{Region: \"Latvia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lv.cg-dialup.net\", IPs: []net.IP{{109, 248, 148, 248}, {109, 248, 148, 250}, {109, 248, 148, 254}, {109, 248, 149, 19}, {109, 248, 149, 20}, {109, 248, 149, 22}, {109, 248, 149, 24}, {109, 248, 149, 26}, {109, 248, 149, 28}, {109, 248, 149, 30}}},\n\t\t{Region: \"Liechtenstein\", Group: \"Premium UDP Europe\", Hostname: \"87-1-li.cg-dialup.net\", IPs: []net.IP{{91, 90, 122, 131}, {91, 90, 122, 134}, {91, 90, 122, 137}, {91, 90, 122, 138}, {91, 90, 122, 139}, {91, 90, 122, 140}, {91, 90, 122, 141}, {91, 90, 122, 142}, {91, 90, 122, 144}, {91, 90, 122, 145}}},\n\t\t{Region: \"Lithuania\", Group: \"Premium TCP Europe\", Hostname: \"97-1-lt.cg-dialup.net\", IPs: []net.IP{{85, 206, 162, 212}, {85, 206, 162, 215}, {85, 206, 162, 219}, {85, 206, 162, 222}, {85, 206, 165, 17}, {85, 206, 165, 23}, {85, 206, 165, 25}, {85, 206, 165, 26}, {85, 206, 165, 30}, {85, 206, 165, 31}}},\n\t\t{Region: \"Lithuania\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lt.cg-dialup.net\", IPs: []net.IP{{85, 206, 162, 209}, {85, 206, 162, 210}, {85, 206, 162, 211}, {85, 206, 162, 213}, {85, 206, 162, 214}, {85, 206, 162, 217}, {85, 206, 162, 218}, {85, 206, 162, 220}, {85, 206, 165, 26}, {85, 206, 165, 30}}},\n\t\t{Region: \"Luxembourg\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lu.cg-dialup.net\", IPs: []net.IP{{5, 253, 204, 7}, {5, 253, 204, 10}, {5, 253, 204, 12}, {5, 253, 204, 23}, {5, 253, 204, 26}, {5, 253, 204, 30}, {5, 253, 204, 37}, {5, 253, 204, 39}, {5, 253, 204, 44}, {5, 253, 204, 45}}},\n\t\t{Region: \"Macao\", Group: \"Premium TCP Asia\", Hostname: \"96-1-mo.cg-dialup.net\", IPs: []net.IP{{84, 252, 92, 131}, {84, 252, 92, 133}, {84, 252, 92, 135}, {84, 252, 92, 137}, {84, 252, 92, 138}, {84, 252, 92, 139}, {84, 252, 92, 141}, {84, 252, 92, 142}, {84, 252, 92, 144}, {84, 252, 92, 145}}},\n\t\t{Region: \"Macao\", Group: \"Premium UDP Asia\", Hostname: \"95-1-mo.cg-dialup.net\", IPs: []net.IP{{84, 252, 92, 132}, {84, 252, 92, 134}, {84, 252, 92, 135}, {84, 252, 92, 136}, {84, 252, 92, 137}, {84, 252, 92, 139}, {84, 252, 92, 141}, {84, 252, 92, 143}, {84, 252, 92, 144}, {84, 252, 92, 145}}},\n\t\t{Region: \"Macedonia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-mk.cg-dialup.net\", IPs: []net.IP{{185, 225, 28, 3}, {185, 225, 28, 4}, {185, 225, 28, 5}, {185, 225, 28, 6}, {185, 225, 28, 7}, {185, 225, 28, 8}, {185, 225, 28, 9}, {185, 225, 28, 10}, {185, 225, 28, 11}, {185, 225, 28, 12}}},\n\t\t{Region: \"Macedonia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-mk.cg-dialup.net\", IPs: []net.IP{{185, 225, 28, 3}, {185, 225, 28, 4}, {185, 225, 28, 5}, {185, 225, 28, 6}, {185, 225, 28, 7}, {185, 225, 28, 8}, {185, 225, 28, 9}, {185, 225, 28, 10}, {185, 225, 28, 11}, {185, 225, 28, 12}}},\n\t\t{Region: \"Malaysia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-my.cg-dialup.net\", IPs: []net.IP{{146, 70, 15, 4}, {146, 70, 15, 6}, {146, 70, 15, 8}, {146, 70, 15, 9}, {146, 70, 15, 10}, {146, 70, 15, 11}, {146, 70, 15, 12}, {146, 70, 15, 13}, {146, 70, 15, 15}, {146, 70, 15, 16}}},\n\t\t{Region: \"Malaysia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-my.cg-dialup.net\", IPs: []net.IP{{146, 70, 15, 3}, {146, 70, 15, 4}, {146, 70, 15, 5}, {146, 70, 15, 6}, {146, 70, 15, 7}, {146, 70, 15, 8}, {146, 70, 15, 10}, {146, 70, 15, 12}, {146, 70, 15, 15}, {146, 70, 15, 16}}},\n\t\t{Region: \"Malta\", Group: \"Premium TCP Europe\", Hostname: \"97-1-mt.cg-dialup.net\", IPs: []net.IP{{176, 125, 230, 133}, {176, 125, 230, 135}, {176, 125, 230, 136}, {176, 125, 230, 137}, {176, 125, 230, 138}, {176, 125, 230, 140}, {176, 125, 230, 142}, {176, 125, 230, 143}, {176, 125, 230, 144}, {176, 125, 230, 145}}},\n\t\t{Region: \"Malta\", Group: \"Premium UDP Europe\", Hostname: \"87-1-mt.cg-dialup.net\", IPs: []net.IP{{176, 125, 230, 131}, {176, 125, 230, 133}, {176, 125, 230, 134}, {176, 125, 230, 136}, {176, 125, 230, 137}, {176, 125, 230, 138}, {176, 125, 230, 139}, {176, 125, 230, 140}, {176, 125, 230, 144}, {176, 125, 230, 145}}},\n\t\t{Region: \"Mexico\", Group: \"Premium TCP USA\", Hostname: \"93-1-mx.cg-dialup.net\", IPs: []net.IP{{77, 81, 142, 132}, {77, 81, 142, 134}, {77, 81, 142, 136}, {77, 81, 142, 139}, {77, 81, 142, 142}, {77, 81, 142, 154}, {77, 81, 142, 155}, {77, 81, 142, 157}, {77, 81, 142, 158}, {77, 81, 142, 159}}},\n\t\t{Region: \"Mexico\", Group: \"Premium UDP USA\", Hostname: \"94-1-mx.cg-dialup.net\", IPs: []net.IP{{77, 81, 142, 130}, {77, 81, 142, 131}, {77, 81, 142, 132}, {77, 81, 142, 139}, {77, 81, 142, 141}, {77, 81, 142, 142}, {77, 81, 142, 146}, {77, 81, 142, 147}, {77, 81, 142, 154}, {77, 81, 142, 159}}},\n\t\t{Region: \"Moldova\", Group: \"Premium TCP Europe\", Hostname: \"97-1-md.cg-dialup.net\", IPs: []net.IP{{178, 175, 130, 243}, {178, 175, 130, 244}, {178, 175, 130, 245}, {178, 175, 130, 246}, {178, 175, 130, 251}, {178, 175, 130, 254}, {178, 175, 142, 131}, {178, 175, 142, 132}, {178, 175, 142, 133}, {178, 175, 142, 134}}},\n\t\t{Region: \"Moldova\", Group: \"Premium UDP Europe\", Hostname: \"87-1-md.cg-dialup.net\", IPs: []net.IP{{178, 175, 130, 243}, {178, 175, 130, 244}, {178, 175, 130, 246}, {178, 175, 130, 250}, {178, 175, 130, 251}, {178, 175, 130, 253}, {178, 175, 130, 254}, {178, 175, 142, 132}, {178, 175, 142, 133}, {178, 175, 142, 134}}},\n\t\t{Region: \"Monaco\", Group: \"Premium TCP Europe\", Hostname: \"97-1-mc.cg-dialup.net\", IPs: []net.IP{{95, 181, 233, 131}, {95, 181, 233, 132}, {95, 181, 233, 133}, {95, 181, 233, 137}, {95, 181, 233, 138}, {95, 181, 233, 139}, {95, 181, 233, 140}, {95, 181, 233, 141}, {95, 181, 233, 143}, {95, 181, 233, 144}}},\n\t\t{Region: \"Monaco\", Group: \"Premium UDP Europe\", Hostname: \"87-1-mc.cg-dialup.net\", IPs: []net.IP{{95, 181, 233, 132}, {95, 181, 233, 135}, {95, 181, 233, 136}, {95, 181, 233, 137}, {95, 181, 233, 138}, {95, 181, 233, 139}, {95, 181, 233, 141}, {95, 181, 233, 142}, {95, 181, 233, 143}, {95, 181, 233, 144}}},\n\t\t{Region: \"Mongolia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-mn.cg-dialup.net\", IPs: []net.IP{{185, 253, 163, 132}, {185, 253, 163, 133}, {185, 253, 163, 135}, {185, 253, 163, 136}, {185, 253, 163, 139}, {185, 253, 163, 140}, {185, 253, 163, 141}, {185, 253, 163, 142}, {185, 253, 163, 143}, {185, 253, 163, 144}}},\n\t\t{Region: \"Mongolia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-mn.cg-dialup.net\", IPs: []net.IP{{185, 253, 163, 131}, {185, 253, 163, 133}, {185, 253, 163, 134}, {185, 253, 163, 137}, {185, 253, 163, 138}, {185, 253, 163, 139}, {185, 253, 163, 140}, {185, 253, 163, 141}, {185, 253, 163, 142}, {185, 253, 163, 144}}},\n\t\t{Region: \"Montenegro\", Group: \"Premium TCP Europe\", Hostname: \"97-1-me.cg-dialup.net\", IPs: []net.IP{{176, 125, 229, 131}, {176, 125, 229, 135}, {176, 125, 229, 137}, {176, 125, 229, 138}, {176, 125, 229, 140}, {176, 125, 229, 141}, {176, 125, 229, 142}, {176, 125, 229, 143}, {176, 125, 229, 144}, {176, 125, 229, 145}}},\n\t\t{Region: \"Montenegro\", Group: \"Premium UDP Europe\", Hostname: \"87-1-me.cg-dialup.net\", IPs: []net.IP{{176, 125, 229, 131}, {176, 125, 229, 134}, {176, 125, 229, 136}, {176, 125, 229, 137}, {176, 125, 229, 138}, {176, 125, 229, 139}, {176, 125, 229, 140}, {176, 125, 229, 141}, {176, 125, 229, 143}, {176, 125, 229, 144}}},\n\t\t{Region: \"Morocco\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ma.cg-dialup.net\", IPs: []net.IP{{95, 181, 232, 132}, {95, 181, 232, 133}, {95, 181, 232, 134}, {95, 181, 232, 136}, {95, 181, 232, 137}, {95, 181, 232, 138}, {95, 181, 232, 139}, {95, 181, 232, 140}, {95, 181, 232, 141}, {95, 181, 232, 144}}},\n\t\t{Region: \"Morocco\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ma.cg-dialup.net\", IPs: []net.IP{{95, 181, 232, 131}, {95, 181, 232, 132}, {95, 181, 232, 133}, {95, 181, 232, 135}, {95, 181, 232, 137}, {95, 181, 232, 139}, {95, 181, 232, 140}, {95, 181, 232, 141}, {95, 181, 232, 142}, {95, 181, 232, 143}}},\n\t\t{Region: \"Netherlands\", Group: \"Premium TCP Europe\", Hostname: \"97-1-nl.cg-dialup.net\", IPs: []net.IP{{84, 17, 47, 98}, {181, 214, 206, 22}, {181, 214, 206, 27}, {181, 214, 206, 36}, {195, 78, 54, 10}, {195, 78, 54, 20}, {195, 78, 54, 43}, {195, 78, 54, 50}, {195, 78, 54, 119}, {195, 181, 172, 78}}},\n\t\t{Region: \"Netherlands\", Group: \"Premium UDP Europe\", Hostname: \"87-1-nl.cg-dialup.net\", IPs: []net.IP{{84, 17, 47, 110}, {181, 214, 206, 29}, {181, 214, 206, 42}, {195, 78, 54, 8}, {195, 78, 54, 19}, {195, 78, 54, 47}, {195, 78, 54, 110}, {195, 78, 54, 141}, {195, 78, 54, 143}, {195, 78, 54, 157}}},\n\t\t{Region: \"New Zealand\", Group: \"Premium TCP Asia\", Hostname: \"96-1-nz.cg-dialup.net\", IPs: []net.IP{{43, 250, 207, 98}, {43, 250, 207, 99}, {43, 250, 207, 100}, {43, 250, 207, 101}, {43, 250, 207, 102}, {43, 250, 207, 103}, {43, 250, 207, 105}, {43, 250, 207, 106}, {43, 250, 207, 108}, {43, 250, 207, 109}}},\n\t\t{Region: \"New Zealand\", Group: \"Premium UDP Asia\", Hostname: \"95-1-nz.cg-dialup.net\", IPs: []net.IP{{43, 250, 207, 98}, {43, 250, 207, 99}, {43, 250, 207, 102}, {43, 250, 207, 104}, {43, 250, 207, 105}, {43, 250, 207, 106}, {43, 250, 207, 107}, {43, 250, 207, 108}, {43, 250, 207, 109}, {43, 250, 207, 110}}},\n\t\t{Region: \"Nigeria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ng.cg-dialup.net\", IPs: []net.IP{{102, 165, 25, 68}, {102, 165, 25, 69}, {102, 165, 25, 70}, {102, 165, 25, 71}, {102, 165, 25, 72}, {102, 165, 25, 73}, {102, 165, 25, 75}, {102, 165, 25, 76}, {102, 165, 25, 77}, {102, 165, 25, 78}}},\n\t\t{Region: \"Nigeria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ng.cg-dialup.net\", IPs: []net.IP{{102, 165, 25, 68}, {102, 165, 25, 69}, {102, 165, 25, 70}, {102, 165, 25, 71}, {102, 165, 25, 72}, {102, 165, 25, 74}, {102, 165, 25, 75}, {102, 165, 25, 76}, {102, 165, 25, 77}, {102, 165, 25, 78}}},\n\t\t{Region: \"Norway\", Group: \"Premium TCP Europe\", Hostname: \"97-1-no.cg-dialup.net\", IPs: []net.IP{{45, 12, 223, 137}, {45, 12, 223, 140}, {185, 206, 225, 29}, {185, 206, 225, 231}, {185, 253, 97, 234}, {185, 253, 97, 236}, {185, 253, 97, 238}, {185, 253, 97, 244}, {185, 253, 97, 250}, {185, 253, 97, 254}}},\n\t\t{Region: \"Norway\", Group: \"Premium UDP Europe\", Hostname: \"87-1-no.cg-dialup.net\", IPs: []net.IP{{45, 12, 223, 133}, {45, 12, 223, 134}, {45, 12, 223, 142}, {185, 206, 225, 227}, {185, 206, 225, 228}, {185, 206, 225, 231}, {185, 206, 225, 235}, {185, 253, 97, 237}, {185, 253, 97, 246}, {185, 253, 97, 254}}},\n\t\t{Region: \"Pakistan\", Group: \"Premium TCP Asia\", Hostname: \"96-1-pk.cg-dialup.net\", IPs: []net.IP{{146, 70, 12, 3}, {146, 70, 12, 4}, {146, 70, 12, 6}, {146, 70, 12, 8}, {146, 70, 12, 9}, {146, 70, 12, 10}, {146, 70, 12, 11}, {146, 70, 12, 12}, {146, 70, 12, 13}, {146, 70, 12, 14}}},\n\t\t{Region: \"Pakistan\", Group: \"Premium UDP Asia\", Hostname: \"95-1-pk.cg-dialup.net\", IPs: []net.IP{{146, 70, 12, 4}, {146, 70, 12, 5}, {146, 70, 12, 6}, {146, 70, 12, 7}, {146, 70, 12, 8}, {146, 70, 12, 10}, {146, 70, 12, 11}, {146, 70, 12, 12}, {146, 70, 12, 13}, {146, 70, 12, 14}}},\n\t\t{Region: \"Panama\", Group: \"Premium TCP Europe\", Hostname: \"97-1-pa.cg-dialup.net\", IPs: []net.IP{{91, 90, 126, 131}, {91, 90, 126, 132}, {91, 90, 126, 133}, {91, 90, 126, 134}, {91, 90, 126, 136}, {91, 90, 126, 138}, {91, 90, 126, 139}, {91, 90, 126, 141}, {91, 90, 126, 142}, {91, 90, 126, 145}}},\n\t\t{Region: \"Panama\", Group: \"Premium UDP Europe\", Hostname: \"87-1-pa.cg-dialup.net\", IPs: []net.IP{{91, 90, 126, 131}, {91, 90, 126, 133}, {91, 90, 126, 134}, {91, 90, 126, 135}, {91, 90, 126, 136}, {91, 90, 126, 138}, {91, 90, 126, 140}, {91, 90, 126, 141}, {91, 90, 126, 142}, {91, 90, 126, 145}}},\n\t\t{Region: \"Philippines\", Group: \"Premium TCP Asia\", Hostname: \"96-1-ph.cg-dialup.net\", IPs: []net.IP{{188, 214, 125, 37}, {188, 214, 125, 38}, {188, 214, 125, 40}, {188, 214, 125, 43}, {188, 214, 125, 44}, {188, 214, 125, 45}, {188, 214, 125, 52}, {188, 214, 125, 55}, {188, 214, 125, 61}, {188, 214, 125, 62}}},\n\t\t{Region: \"Philippines\", Group: \"Premium UDP Asia\", Hostname: \"95-1-ph.cg-dialup.net\", IPs: []net.IP{{188, 214, 125, 37}, {188, 214, 125, 40}, {188, 214, 125, 46}, {188, 214, 125, 49}, {188, 214, 125, 52}, {188, 214, 125, 54}, {188, 214, 125, 57}, {188, 214, 125, 58}, {188, 214, 125, 61}, {188, 214, 125, 62}}},\n\t\t{Region: \"Poland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-pl.cg-dialup.net\", IPs: []net.IP{{138, 199, 59, 132}, {138, 199, 59, 136}, {138, 199, 59, 137}, {138, 199, 59, 143}, {138, 199, 59, 144}, {138, 199, 59, 152}, {138, 199, 59, 153}, {138, 199, 59, 166}, {138, 199, 59, 174}, {138, 199, 59, 175}}},\n\t\t{Region: \"Poland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-pl.cg-dialup.net\", IPs: []net.IP{{138, 199, 59, 130}, {138, 199, 59, 136}, {138, 199, 59, 148}, {138, 199, 59, 149}, {138, 199, 59, 153}, {138, 199, 59, 156}, {138, 199, 59, 157}, {138, 199, 59, 164}, {138, 199, 59, 171}, {138, 199, 59, 173}}},\n\t\t{Region: \"Portugal\", Group: \"Premium TCP Europe\", Hostname: \"97-1-pt.cg-dialup.net\", IPs: []net.IP{{89, 26, 243, 112}, {89, 26, 243, 115}, {89, 26, 243, 195}, {89, 26, 243, 216}, {89, 26, 243, 218}, {89, 26, 243, 220}, {89, 26, 243, 222}, {89, 26, 243, 223}, {89, 26, 243, 225}, {89, 26, 243, 228}}},\n\t\t{Region: \"Portugal\", Group: \"Premium UDP Europe\", Hostname: \"87-1-pt.cg-dialup.net\", IPs: []net.IP{{89, 26, 243, 99}, {89, 26, 243, 113}, {89, 26, 243, 115}, {89, 26, 243, 195}, {89, 26, 243, 199}, {89, 26, 243, 216}, {89, 26, 243, 219}, {89, 26, 243, 225}, {89, 26, 243, 226}, {89, 26, 243, 227}}},\n\t\t{Region: \"Qatar\", Group: \"Premium TCP Europe\", Hostname: \"97-1-qa.cg-dialup.net\", IPs: []net.IP{{95, 181, 234, 133}, {95, 181, 234, 135}, {95, 181, 234, 136}, {95, 181, 234, 137}, {95, 181, 234, 138}, {95, 181, 234, 139}, {95, 181, 234, 140}, {95, 181, 234, 141}, {95, 181, 234, 142}, {95, 181, 234, 143}}},\n\t\t{Region: \"Qatar\", Group: \"Premium UDP Europe\", Hostname: \"87-1-qa.cg-dialup.net\", IPs: []net.IP{{95, 181, 234, 131}, {95, 181, 234, 132}, {95, 181, 234, 133}, {95, 181, 234, 134}, {95, 181, 234, 135}, {95, 181, 234, 137}, {95, 181, 234, 138}, {95, 181, 234, 139}, {95, 181, 234, 142}, {95, 181, 234, 143}}},\n\t\t{Region: \"Russian Federation\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ru.cg-dialup.net\", IPs: []net.IP{{5, 8, 16, 72}, {5, 8, 16, 74}, {5, 8, 16, 84}, {5, 8, 16, 85}, {5, 8, 16, 123}, {5, 8, 16, 124}, {5, 8, 16, 132}, {146, 70, 52, 35}, {146, 70, 52, 44}, {146, 70, 52, 54}}},\n\t\t{Region: \"Russian Federation\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ru.cg-dialup.net\", IPs: []net.IP{{5, 8, 16, 75}, {5, 8, 16, 87}, {5, 8, 16, 99}, {5, 8, 16, 110}, {5, 8, 16, 138}, {146, 70, 52, 29}, {146, 70, 52, 52}, {146, 70, 52, 58}, {146, 70, 52, 59}, {146, 70, 52, 67}}},\n\t\t{Region: \"Saudi Arabia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-sa.cg-dialup.net\", IPs: []net.IP{{95, 181, 235, 131}, {95, 181, 235, 133}, {95, 181, 235, 134}, {95, 181, 235, 135}, {95, 181, 235, 137}, {95, 181, 235, 138}, {95, 181, 235, 139}, {95, 181, 235, 140}, {95, 181, 235, 141}, {95, 181, 235, 142}}},\n\t\t{Region: \"Saudi Arabia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-sa.cg-dialup.net\", IPs: []net.IP{{95, 181, 235, 131}, {95, 181, 235, 132}, {95, 181, 235, 134}, {95, 181, 235, 135}, {95, 181, 235, 136}, {95, 181, 235, 137}, {95, 181, 235, 138}, {95, 181, 235, 139}, {95, 181, 235, 141}, {95, 181, 235, 144}}},\n\t\t{Region: \"Serbia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-rs.cg-dialup.net\", IPs: []net.IP{{37, 120, 193, 179}, {37, 120, 193, 186}, {37, 120, 193, 188}, {37, 120, 193, 190}, {141, 98, 103, 36}, {141, 98, 103, 38}, {141, 98, 103, 39}, {141, 98, 103, 43}, {141, 98, 103, 44}, {141, 98, 103, 46}}},\n\t\t{Region: \"Serbia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-rs.cg-dialup.net\", IPs: []net.IP{{37, 120, 193, 180}, {37, 120, 193, 186}, {37, 120, 193, 187}, {37, 120, 193, 188}, {37, 120, 193, 189}, {37, 120, 193, 190}, {141, 98, 103, 35}, {141, 98, 103, 36}, {141, 98, 103, 39}, {141, 98, 103, 41}}},\n\t\t{Region: \"Singapore\", Group: \"Premium TCP Asia\", Hostname: \"96-1-sg.cg-dialup.net\", IPs: []net.IP{{84, 17, 39, 162}, {84, 17, 39, 165}, {84, 17, 39, 168}, {84, 17, 39, 171}, {84, 17, 39, 175}, {84, 17, 39, 177}, {84, 17, 39, 178}, {84, 17, 39, 181}, {84, 17, 39, 183}, {84, 17, 39, 185}}},\n\t\t{Region: \"Singapore\", Group: \"Premium UDP Asia\", Hostname: \"95-1-sg.cg-dialup.net\", IPs: []net.IP{{84, 17, 39, 162}, {84, 17, 39, 165}, {84, 17, 39, 166}, {84, 17, 39, 167}, {84, 17, 39, 171}, {84, 17, 39, 174}, {84, 17, 39, 175}, {84, 17, 39, 178}, {84, 17, 39, 180}, {84, 17, 39, 185}}},\n\t\t{Region: \"Slovakia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-sk.cg-dialup.net\", IPs: []net.IP{{185, 245, 85, 227}, {185, 245, 85, 228}, {185, 245, 85, 229}, {185, 245, 85, 230}, {185, 245, 85, 231}, {185, 245, 85, 232}, {185, 245, 85, 233}, {185, 245, 85, 234}, {185, 245, 85, 235}, {185, 245, 85, 236}}},\n\t\t{Region: \"Slovakia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-sk.cg-dialup.net\", IPs: []net.IP{{185, 245, 85, 227}, {185, 245, 85, 228}, {185, 245, 85, 229}, {185, 245, 85, 230}, {185, 245, 85, 231}, {185, 245, 85, 232}, {185, 245, 85, 233}, {185, 245, 85, 234}, {185, 245, 85, 235}, {185, 245, 85, 236}}},\n\t\t{Region: \"Slovenia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-si.cg-dialup.net\", IPs: []net.IP{{195, 80, 150, 211}, {195, 80, 150, 212}, {195, 80, 150, 214}, {195, 80, 150, 215}, {195, 80, 150, 216}, {195, 80, 150, 217}, {195, 80, 150, 218}, {195, 80, 150, 219}, {195, 80, 150, 221}, {195, 80, 150, 222}}},\n\t\t{Region: \"Slovenia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-si.cg-dialup.net\", IPs: []net.IP{{195, 80, 150, 211}, {195, 80, 150, 212}, {195, 80, 150, 214}, {195, 80, 150, 215}, {195, 80, 150, 216}, {195, 80, 150, 217}, {195, 80, 150, 219}, {195, 80, 150, 220}, {195, 80, 150, 221}, {195, 80, 150, 222}}},\n\t\t{Region: \"South Africa\", Group: \"Premium TCP Asia\", Hostname: \"96-1-za.cg-dialup.net\", IPs: []net.IP{{154, 127, 50, 212}, {154, 127, 50, 215}, {154, 127, 50, 217}, {154, 127, 50, 219}, {154, 127, 50, 220}, {154, 127, 50, 222}, {154, 127, 60, 196}, {154, 127, 60, 198}, {154, 127, 60, 199}, {154, 127, 60, 200}}},\n\t\t{Region: \"South Africa\", Group: \"Premium TCP Europe\", Hostname: \"97-1-za.cg-dialup.net\", IPs: []net.IP{{197, 85, 7, 26}, {197, 85, 7, 27}, {197, 85, 7, 28}, {197, 85, 7, 29}, {197, 85, 7, 30}, {197, 85, 7, 31}, {197, 85, 7, 131}, {197, 85, 7, 132}, {197, 85, 7, 133}, {197, 85, 7, 134}}},\n\t\t{Region: \"South Africa\", Group: \"Premium UDP Asia\", Hostname: \"95-1-za.cg-dialup.net\", IPs: []net.IP{{154, 127, 50, 210}, {154, 127, 50, 214}, {154, 127, 50, 218}, {154, 127, 50, 219}, {154, 127, 50, 220}, {154, 127, 50, 221}, {154, 127, 50, 222}, {154, 127, 60, 195}, {154, 127, 60, 199}, {154, 127, 60, 206}}},\n\t\t{Region: \"South Africa\", Group: \"Premium UDP Europe\", Hostname: \"87-1-za.cg-dialup.net\", IPs: []net.IP{{197, 85, 7, 26}, {197, 85, 7, 27}, {197, 85, 7, 28}, {197, 85, 7, 29}, {197, 85, 7, 30}, {197, 85, 7, 31}, {197, 85, 7, 131}, {197, 85, 7, 132}, {197, 85, 7, 133}, {197, 85, 7, 134}}},\n\t\t{Region: \"Spain\", Group: \"Premium TCP Europe\", Hostname: \"97-1-es.cg-dialup.net\", IPs: []net.IP{{37, 120, 142, 41}, {37, 120, 142, 52}, {37, 120, 142, 55}, {37, 120, 142, 61}, {37, 120, 142, 173}, {84, 17, 62, 131}, {84, 17, 62, 142}, {84, 17, 62, 144}, {185, 93, 3, 108}, {185, 93, 3, 114}}},\n\t\t{Region: \"Sri Lanka\", Group: \"Premium TCP Europe\", Hostname: \"97-1-lk.cg-dialup.net\", IPs: []net.IP{{95, 181, 239, 131}, {95, 181, 239, 132}, {95, 181, 239, 133}, {95, 181, 239, 134}, {95, 181, 239, 135}, {95, 181, 239, 136}, {95, 181, 239, 137}, {95, 181, 239, 138}, {95, 181, 239, 140}, {95, 181, 239, 144}}},\n\t\t{Region: \"Sri Lanka\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lk.cg-dialup.net\", IPs: []net.IP{{95, 181, 239, 131}, {95, 181, 239, 132}, {95, 181, 239, 133}, {95, 181, 239, 134}, {95, 181, 239, 135}, {95, 181, 239, 136}, {95, 181, 239, 140}, {95, 181, 239, 141}, {95, 181, 239, 142}, {95, 181, 239, 144}}},\n\t\t{Region: \"Sweden\", Group: \"Premium TCP Europe\", Hostname: \"97-1-se.cg-dialup.net\", IPs: []net.IP{{188, 126, 73, 207}, {188, 126, 73, 209}, {188, 126, 73, 214}, {188, 126, 73, 219}, {188, 126, 79, 6}, {188, 126, 79, 11}, {188, 126, 79, 19}, {188, 126, 79, 25}, {195, 246, 120, 148}, {195, 246, 120, 161}}},\n\t\t{Region: \"Sweden\", Group: \"Premium UDP Europe\", Hostname: \"87-1-se.cg-dialup.net\", IPs: []net.IP{{188, 126, 73, 201}, {188, 126, 73, 211}, {188, 126, 73, 213}, {188, 126, 73, 218}, {188, 126, 79, 6}, {188, 126, 79, 8}, {188, 126, 79, 19}, {195, 246, 120, 142}, {195, 246, 120, 144}, {195, 246, 120, 168}}},\n\t\t{Region: \"Switzerland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ch.cg-dialup.net\", IPs: []net.IP{{84, 17, 52, 4}, {84, 17, 52, 20}, {84, 17, 52, 44}, {84, 17, 52, 65}, {84, 17, 52, 72}, {84, 17, 52, 80}, {84, 17, 52, 83}, {84, 17, 52, 85}, {185, 32, 222, 112}, {185, 189, 150, 73}}},\n\t\t{Region: \"Switzerland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ch.cg-dialup.net\", IPs: []net.IP{{84, 17, 52, 5}, {84, 17, 52, 14}, {84, 17, 52, 24}, {84, 17, 52, 64}, {84, 17, 52, 73}, {84, 17, 52, 85}, {185, 32, 222, 114}, {185, 189, 150, 52}, {185, 189, 150, 57}, {195, 225, 118, 43}}},\n\t\t{Region: \"Taiwan\", Group: \"Premium TCP Asia\", Hostname: \"96-1-tw.cg-dialup.net\", IPs: []net.IP{{45, 133, 181, 100}, {45, 133, 181, 102}, {45, 133, 181, 103}, {45, 133, 181, 106}, {45, 133, 181, 109}, {45, 133, 181, 113}, {45, 133, 181, 115}, {45, 133, 181, 116}, {45, 133, 181, 123}, {45, 133, 181, 125}}},\n\t\t{Region: \"Taiwan\", Group: \"Premium UDP Asia\", Hostname: \"95-1-tw.cg-dialup.net\", IPs: []net.IP{{45, 133, 181, 99}, {45, 133, 181, 102}, {45, 133, 181, 107}, {45, 133, 181, 108}, {45, 133, 181, 109}, {45, 133, 181, 114}, {45, 133, 181, 116}, {45, 133, 181, 117}, {45, 133, 181, 123}, {45, 133, 181, 124}}},\n\t\t{Region: \"Thailand\", Group: \"Premium TCP Asia\", Hostname: \"96-1-th.cg-dialup.net\", IPs: []net.IP{{146, 70, 13, 3}, {146, 70, 13, 4}, {146, 70, 13, 6}, {146, 70, 13, 7}, {146, 70, 13, 8}, {146, 70, 13, 9}, {146, 70, 13, 11}, {146, 70, 13, 13}, {146, 70, 13, 15}, {146, 70, 13, 16}}},\n\t\t{Region: \"Thailand\", Group: \"Premium UDP Asia\", Hostname: \"95-1-th.cg-dialup.net\", IPs: []net.IP{{146, 70, 13, 3}, {146, 70, 13, 4}, {146, 70, 13, 8}, {146, 70, 13, 9}, {146, 70, 13, 10}, {146, 70, 13, 11}, {146, 70, 13, 12}, {146, 70, 13, 13}, {146, 70, 13, 15}, {146, 70, 13, 16}}},\n\t\t{Region: \"Turkey\", Group: \"Premium TCP Europe\", Hostname: \"97-1-tr.cg-dialup.net\", IPs: []net.IP{{188, 213, 34, 9}, {188, 213, 34, 11}, {188, 213, 34, 15}, {188, 213, 34, 16}, {188, 213, 34, 23}, {188, 213, 34, 25}, {188, 213, 34, 28}, {188, 213, 34, 41}, {188, 213, 34, 108}, {188, 213, 34, 110}}},\n\t\t{Region: \"Turkey\", Group: \"Premium UDP Europe\", Hostname: \"87-1-tr.cg-dialup.net\", IPs: []net.IP{{188, 213, 34, 8}, {188, 213, 34, 11}, {188, 213, 34, 14}, {188, 213, 34, 28}, {188, 213, 34, 35}, {188, 213, 34, 42}, {188, 213, 34, 43}, {188, 213, 34, 100}, {188, 213, 34, 103}, {188, 213, 34, 107}}},\n\t\t{Region: \"Ukraine\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ua.cg-dialup.net\", IPs: []net.IP{{31, 28, 161, 18}, {31, 28, 161, 20}, {31, 28, 161, 27}, {31, 28, 163, 34}, {31, 28, 163, 37}, {31, 28, 163, 44}, {62, 149, 7, 167}, {62, 149, 7, 172}, {62, 149, 29, 45}, {62, 149, 29, 57}}},\n\t\t{Region: \"Ukraine\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ua.cg-dialup.net\", IPs: []net.IP{{31, 28, 161, 27}, {31, 28, 163, 38}, {31, 28, 163, 42}, {31, 28, 163, 54}, {31, 28, 163, 61}, {62, 149, 7, 162}, {62, 149, 7, 163}, {62, 149, 29, 35}, {62, 149, 29, 38}, {62, 149, 29, 41}}},\n\t\t{Region: \"United Arab Emirates\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ae.cg-dialup.net\", IPs: []net.IP{{217, 138, 193, 179}, {217, 138, 193, 180}, {217, 138, 193, 181}, {217, 138, 193, 182}, {217, 138, 193, 183}, {217, 138, 193, 184}, {217, 138, 193, 185}, {217, 138, 193, 186}, {217, 138, 193, 188}, {217, 138, 193, 190}}},\n\t\t{Region: \"United Arab Emirates\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ae.cg-dialup.net\", IPs: []net.IP{{217, 138, 193, 179}, {217, 138, 193, 180}, {217, 138, 193, 181}, {217, 138, 193, 182}, {217, 138, 193, 183}, {217, 138, 193, 186}, {217, 138, 193, 187}, {217, 138, 193, 188}, {217, 138, 193, 189}, {217, 138, 193, 190}}},\n\t\t{Region: \"United Kingdom\", Group: \"Premium TCP Europe\", Hostname: \"97-1-gb.cg-dialup.net\", IPs: []net.IP{{45, 133, 173, 49}, {45, 133, 173, 56}, {45, 133, 173, 82}, {45, 133, 173, 86}, {95, 154, 200, 153}, {95, 154, 200, 156}, {181, 215, 176, 103}, {181, 215, 176, 246}, {181, 215, 176, 251}, {194, 110, 13, 141}}},\n\t\t{Region: \"United Kingdom\", Group: \"Premium UDP Europe\", Hostname: \"87-1-gb.cg-dialup.net\", IPs: []net.IP{{45, 133, 172, 100}, {45, 133, 172, 126}, {45, 133, 173, 84}, {95, 154, 200, 174}, {181, 215, 176, 110}, {181, 215, 176, 151}, {181, 215, 176, 158}, {191, 101, 209, 142}, {194, 110, 13, 107}, {194, 110, 13, 128}}},\n\t\t{Region: \"United States\", Group: \"Premium TCP USA\", Hostname: \"93-1-us.cg-dialup.net\", IPs: []net.IP{{102, 129, 145, 15}, {102, 129, 152, 195}, {102, 129, 152, 248}, {154, 21, 208, 159}, {185, 242, 5, 117}, {185, 242, 5, 123}, {185, 242, 5, 229}, {191, 96, 227, 173}, {191, 96, 227, 196}, {199, 115, 119, 248}}},\n\t\t{Region: \"United States\", Group: \"Premium UDP USA\", Hostname: \"94-1-us.cg-dialup.net\", IPs: []net.IP{{23, 82, 14, 113}, {23, 105, 177, 122}, {45, 89, 173, 222}, {84, 17, 35, 4}, {89, 187, 171, 132}, {156, 146, 37, 45}, {156, 146, 59, 86}, {184, 170, 240, 231}, {191, 96, 150, 248}, {199, 115, 119, 248}}},\n\t\t{Region: \"Venezuela\", Group: \"Premium TCP USA\", Hostname: \"93-1-ve.cg-dialup.net\", IPs: []net.IP{{95, 181, 237, 132}, {95, 181, 237, 133}, {95, 181, 237, 134}, {95, 181, 237, 135}, {95, 181, 237, 136}, {95, 181, 237, 138}, {95, 181, 237, 139}, {95, 181, 237, 140}, {95, 181, 237, 141}, {95, 181, 237, 143}}},\n\t\t{Region: \"Venezuela\", Group: \"Premium UDP USA\", Hostname: \"94-1-ve.cg-dialup.net\", IPs: []net.IP{{95, 181, 237, 131}, {95, 181, 237, 132}, {95, 181, 237, 134}, {95, 181, 237, 135}, {95, 181, 237, 136}, {95, 181, 237, 140}, {95, 181, 237, 141}, {95, 181, 237, 142}, {95, 181, 237, 143}, {95, 181, 237, 144}}},\n\t\t{Region: \"Vietnam\", Group: \"Premium TCP Asia\", Hostname: \"96-1-vn.cg-dialup.net\", IPs: []net.IP{{188, 214, 152, 99}, {188, 214, 152, 101}, {188, 214, 152, 103}, {188, 214, 152, 104}, {188, 214, 152, 105}, {188, 214, 152, 106}, {188, 214, 152, 107}, {188, 214, 152, 108}, {188, 214, 152, 109}, {188, 214, 152, 110}}},\n\t\t{Region: \"Vietnam\", Group: \"Premium UDP Asia\", Hostname: \"95-1-vn.cg-dialup.net\", IPs: []net.IP{{188, 214, 152, 99}, {188, 214, 152, 100}, {188, 214, 152, 101}, {188, 214, 152, 102}, {188, 214, 152, 103}, {188, 214, 152, 104}, {188, 214, 152, 105}, {188, 214, 152, 106}, {188, 214, 152, 107}, {188, 214, 152, 109}}},\n\t}\n}", "func (lv *Libvirt) RemoveTransientDHCPHost(newHost *libvirtxml.NetworkDHCPHost, app *App) error {\n\tlv.dhcpLeases.mutex.Lock()\n\tdefer lv.dhcpLeases.mutex.Unlock()\n\n\tdelete(lv.dhcpLeases.leases, newHost)\n\treturn lv.rebuildDHCPStaticLeases(app)\n}", "func delExternalClientBlackholeFromNodes(nodes []v1.Node, routingTable, externalV4, externalV6 string, useV4 bool) {\n\tfor _, node := range nodes {\n\t\tif useV4 {\n\t\t\tout, err := runCommand(containerRuntime, \"exec\", node.Name, \"ip\", \"route\", \"del\", \"blackhole\", externalV4, \"table\", routingTable)\n\t\t\tframework.ExpectNoError(err, fmt.Sprintf(\"failed to delete blackhole route to %s on node %s table %s, out: %s\", externalV4, node.Name, routingTable, out))\n\t\t\tcontinue\n\t\t}\n\t\tout, err := runCommand(containerRuntime, \"exec\", node.Name, \"ip\", \"route\", \"del\", \"blackhole\", externalV6, \"table\", routingTable)\n\t\tframework.ExpectNoError(err, fmt.Sprintf(\"failed to delete blackhole route to %s on node %s table %s, out: %s\", externalV6, node.Name, routingTable, out))\n\t}\n}", "func (p *ProxySQL) RemoveHostsLike(opts ...HostOpts) error {\n\tmut.Lock()\n\tdefer mut.Unlock()\n\thostq, err := buildAndParseHostQuery(opts...)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// build a query with these options\n\t_, err = exec(p, buildDeleteQuery(hostq))\n\treturn err\n}", "func cleanUpNodes(provisioner provision.Provisioner) {\n\n\tfor _, machine := range provisioner.GetMachinesAll() {\n\t\tnodeName := machine.Name\n\t\texistNode := false\n\t\tfor _, node := range provisioner.Cluster.Nodes {\n\t\t\tif node.Name == nodeName {\n\t\t\t\tnode.Credential = \"\"\n\t\t\t\tnode.PublicIP = \"\"\n\t\t\t\tnode.PrivateIP = \"\"\n\t\t\t\texistNode = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif existNode {\n\t\t\tif err := provisioner.DrainAndDeleteNode(nodeName); err != nil {\n\t\t\t\tlogger.Warnf(\"[%s.%s] %s\", provisioner.Cluster.Namespace, provisioner.Cluster.Name, err.Error())\n\t\t\t}\n\t\t}\n\t}\n\tif err := provisioner.Cluster.PutStore(); err != nil {\n\t\tlogger.Warnf(\"[%s.%s] Failed to update a cluster-entity. (cause='%v')\", provisioner.Cluster.Namespace, provisioner.Cluster.Name, err)\n\t}\n\tlogger.Infof(\"[%s.%s] Garbage data has been cleaned.\", provisioner.Cluster.Namespace, provisioner.Cluster.Name)\n}", "func DHCPDelete(ifname LinkID) error {\n\tif isUnmanaged(UnmanagedID(ifname), LINKTYPE) {\n\t\treturn NewUnmanagedLinkDHCPCannotBeModifiedError(ifname)\n\t}\n\tout, err := exec.Command(prefixInstallPAth+\"dhcp_stop.sh\", string(ifname)).Output()\n\tif err != nil {\n\t\treturn NewCannotStopDHCPError(ifname, err)\n\t}\n\tif string(out) == \"Service not running\" {\n\t\treturn NewDHCPRunningNotFoundError(ifname)\n\t}\n\treturn nil\n}", "func filterResolvDNS(resolvConf []byte, ipv6Enabled bool, netnsEnabled bool) []byte {\n\t// If we're using the host netns, we have nothing to do besides hash the file.\n\tif !netnsEnabled {\n\t\treturn resolvConf\n\t}\n\tcleanedResolvConf := localhostNSRegexp.ReplaceAll(resolvConf, []byte{})\n\t// if IPv6 is not enabled, also clean out any IPv6 address nameserver\n\tif !ipv6Enabled {\n\t\tcleanedResolvConf = nsIPv6Regexp.ReplaceAll(cleanedResolvConf, []byte{})\n\t}\n\t// if the resulting resolvConf has no more nameservers defined, add appropriate\n\t// default DNS servers for IPv4 and (optionally) IPv6\n\tif len(getNameservers(cleanedResolvConf)) == 0 {\n\t\tlogrus.Infof(\"No non-localhost DNS nameservers are left in resolv.conf. Using default external servers: %v\", defaultIPv4Dns)\n\t\tdns := defaultIPv4Dns\n\t\tif ipv6Enabled {\n\t\t\tlogrus.Infof(\"IPv6 enabled; Adding default IPv6 external servers: %v\", defaultIPv6Dns)\n\t\t\tdns = append(dns, defaultIPv6Dns...)\n\t\t}\n\t\tcleanedResolvConf = append(cleanedResolvConf, []byte(\"\\n\"+strings.Join(dns, \"\\n\"))...)\n\t}\n\treturn cleanedResolvConf\n}", "func WhitelistRemove(conn io.ReadWriteCloser, pks ...cipher.PubKey) error {\n\treturn rpc.NewClient(conn).Call(rpcMethod(\"WhitelistRemove\"), &pks, &empty)\n}", "func (p *linodeProvider) removeAbandoned(s *linodeServer) {\n\tconst warn = \"WARNING: Cannot clean up %s: %v\"\n\n\tnow := time.Now()\n\n\tconfigs, err := p.configs(s)\n\tif err != nil {\n\t\tprintf(warn, s, err)\n\t}\n\tfor _, config := range configs {\n\t\tt, err := ParseLabelTime(config.Label)\n\t\tif err == nil && now.Sub(t) > p.backend.HaltTimeout.Duration {\n\t\t\terr := p.removeConfig(s, \"abandoned\", config.ConfigID)\n\t\t\tif err != nil {\n\t\t\t\tprintf(warn, s, err)\n\t\t\t}\n\t\t}\n\t}\n\n\tdisks, err := p.disks(s)\n\tif err != nil {\n\t\tprintf(warn, s, err)\n\t}\n\tvar diskIds []int\n\tfor _, disk := range disks {\n\t\tt, err := ParseLabelTime(disk.Label)\n\t\tif err == nil && now.Sub(t) > p.backend.HaltTimeout.Duration && disk.DiskID != s.d.Root && disk.DiskID != s.d.Swap {\n\t\t\tdiskIds = append(diskIds, disk.DiskID)\n\t\t}\n\t}\n\tif len(diskIds) > 0 {\n\t\terr := p.removeDisks(s, \"abandoned\", 0, diskIds...)\n\t\tif err != nil {\n\t\t\tprintf(warn, s, err)\n\t\t}\n\t}\n}", "func (p* Proxy) StopProxyForServer(s *Server) (error) {\n\n f := logrus.Fields{\n \"proxy\": p.Name, \"server\": s.Name, \"user\": s.User,\n }\n\n rcon, err := p.GetRcon()\n if err != nil { \n log.Error(f,\"Server not removed.\", err)\n return err \n }\n\n serverFQDN, err := p.ProxiedServerFQDN(s)\n if err != nil { \n serverFQDN = p.attachedServerFQDN(s)\n log.Error(f, \"Failed to get proxy name from DNS. Will try to remove server forced host anyway.\", err)\n }\n f[\"serverFQDN\"] = serverFQDN\n\n command := fmt.Sprintf(\"bconf remForcedHost(%d, \\\"%s\\\")\", 0, serverFQDN)\n reply, err := rcon.Send(command)\n f[\"command\"] = command\n f[\"reply\"] = reply\n if err == nil {\n log.Info(f, \"Remote remove-forced-host completed.\")\n } else {\n log.Error(f, \"Failed on remote remove-forced-host: will try to remote remove-server.\", err)\n }\n\n return err\n}", "func cleanupDGP(nodes *kapi.NodeList) error {\n\t// remove dnat_snat entries as well as LRPs\n\tfor _, node := range nodes.Items {\n\t\tdelPbrAndNatRules(node.Name, []string{types.InterNodePolicyPriority, types.MGMTPortPolicyPriority})\n\t}\n\t// remove SBDB MAC bindings for DGP\n\tfor _, ip := range []string{types.V4NodeLocalNATSubnetNextHop, types.V6NodeLocalNATSubnetNextHop} {\n\t\tuuid, stderr, err := util.RunOVNSbctl(\"--columns=_uuid\", \"--no-headings\", \"find\", \"mac_binding\",\n\t\t\tfmt.Sprintf(`ip=\"%s\"`, ip))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to get DGP MAC binding, err: %v, stderr: %s\", err, stderr)\n\t\t}\n\t\tif len(uuid) > 0 {\n\t\t\t_, stderr, err = util.RunOVNSbctl(\"destroy\", \"mac_binding\", uuid)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"unable to remove mac_binding for DGP, err: %v, stderr: %s\", err, stderr)\n\t\t\t}\n\t\t}\n\t}\n\t// remove node local switch\n\t_, stderr, err := util.RunOVNNbctl(\"--if-exists\", \"ls-del\", types.NodeLocalSwitch)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to remove node local switch, err: %v, stderr: %s\", err, stderr)\n\t}\n\tdgpName := types.RouterToSwitchPrefix + types.NodeLocalSwitch\n\n\t// remove lrp on ovn_cluster_router. Will also remove gateway chassis.\n\t_, stderr, err = util.RunOVNNbctl(\"--if-exists\", \"lrp-del\", dgpName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to delete DGP LRP, error: %v, stderr: %s\", err, stderr)\n\t}\n\treturn nil\n}", "func listHostOnlyAdapters(vbox VBoxManager) (map[string]*hostOnlyNetwork, error) {\n\tout, err := vbox.vbmOut(\"list\", \"hostonlyifs\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbyName := map[string]*hostOnlyNetwork{}\n\tbyIP := map[string]*hostOnlyNetwork{}\n\tn := &hostOnlyNetwork{}\n\n\terr = parseKeyValues(out, reColonLine, func(key, val string) error {\n\t\tswitch key {\n\t\tcase \"Name\":\n\t\t\tn.Name = val\n\t\tcase \"GUID\":\n\t\t\tn.GUID = val\n\t\tcase \"DHCP\":\n\t\t\tn.DHCP = (val != \"Disabled\")\n\t\tcase \"IPAddress\":\n\t\t\tn.IPv4.IP = net.ParseIP(val)\n\t\tcase \"NetworkMask\":\n\t\t\tn.IPv4.Mask = parseIPv4Mask(val)\n\t\tcase \"HardwareAddress\":\n\t\t\tmac, err := net.ParseMAC(val)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tn.HwAddr = mac\n\t\tcase \"MediumType\":\n\t\t\tn.Medium = val\n\t\tcase \"Status\":\n\t\t\tn.Status = val\n\t\tcase \"VBoxNetworkName\":\n\t\t\tn.NetworkName = val\n\n\t\t\tif _, present := byName[n.NetworkName]; present {\n\t\t\t\treturn fmt.Errorf(\"VirtualBox is configured with multiple host-only adapters with the same name %q. Please remove one.\", n.NetworkName)\n\t\t\t}\n\t\t\tbyName[n.NetworkName] = n\n\n\t\t\tif len(n.IPv4.IP) != 0 {\n\t\t\t\tif _, present := byIP[n.IPv4.IP.String()]; present {\n\t\t\t\t\treturn fmt.Errorf(\"VirtualBox is configured with multiple host-only adapters with the same IP %q. Please remove one.\", n.IPv4.IP)\n\t\t\t\t}\n\t\t\t\tbyIP[n.IPv4.IP.String()] = n\n\t\t\t}\n\n\t\t\tn = &hostOnlyNetwork{}\n\t\t}\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn byName, nil\n}", "func gatewayCleanup(nodeName string) error {\n\tgatewayRouter := types.GWRouterPrefix + nodeName\n\n\t// Get the gateway router port's IP address (connected to join switch)\n\tvar nextHops []net.IP\n\n\tgwIPAddrs, err := util.GetLRPAddrs(types.GWRouterToJoinSwitchPrefix + gatewayRouter)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, gwIPAddr := range gwIPAddrs {\n\t\tnextHops = append(nextHops, gwIPAddr.IP)\n\t}\n\tstaticRouteCleanup(nextHops)\n\n\t// Remove the patch port that connects join switch to gateway router\n\t_, stderr, err := util.RunOVNNbctl(\"--if-exist\", \"lsp-del\", types.JoinSwitchToGWRouterPrefix+gatewayRouter)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete logical switch port %s%s: \"+\n\t\t\t\"stderr: %q, error: %v\", types.JoinSwitchToGWRouterPrefix, gatewayRouter, stderr, err)\n\t}\n\n\t// Remove router to lb associations from the LBCache before removing the router\n\tlbCache, err := ovnlb.GetLBCache()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get load_balancer cache for router %s: %v\", gatewayRouter, err)\n\t}\n\tlbCache.RemoveRouter(gatewayRouter)\n\n\t// Remove the gateway router associated with nodeName\n\t_, stderr, err = util.RunOVNNbctl(\"--if-exist\", \"lr-del\",\n\t\tgatewayRouter)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete gateway router %s, stderr: %q, \"+\n\t\t\t\"error: %v\", gatewayRouter, stderr, err)\n\t}\n\n\t// Remove external switch\n\texternalSwitch := types.ExternalSwitchPrefix + nodeName\n\t_, stderr, err = util.RunOVNNbctl(\"--if-exist\", \"ls-del\",\n\t\texternalSwitch)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete external switch %s, stderr: %q, \"+\n\t\t\t\"error: %v\", externalSwitch, stderr, err)\n\t}\n\n\texGWexternalSwitch := types.ExternalSwitchPrefix + types.ExternalSwitchPrefix + nodeName\n\t_, stderr, err = util.RunOVNNbctl(\"--if-exist\", \"ls-del\",\n\t\texGWexternalSwitch)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete external switch %s, stderr: %q, \"+\n\t\t\t\"error: %v\", exGWexternalSwitch, stderr, err)\n\t}\n\n\t// We don't know the gateway mode as this is running in the master, try to delete the additional local\n\t// gateway for the shared gateway mode. it will be no op if this is done for other gateway modes.\n\tdelPbrAndNatRules(nodeName, nil)\n\treturn nil\n}", "func (dns *EdgeDNS) cleanResolvForHost() {\n\tbs, err := ioutil.ReadFile(hostResolv)\n\tif err != nil {\n\t\tklog.Warningf(\"read file %s err: %v\", hostResolv, err)\n\t}\n\n\tresolv := strings.Split(string(bs), \"\\n\")\n\tif resolv == nil {\n\t\treturn\n\t}\n\tnameserver := \"\"\n\tfor _, item := range resolv {\n\t\tif strings.Contains(item, dns.ListenIP.String()) || item == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tnameserver = nameserver + item + \"\\n\"\n\t}\n\tif err := ioutil.WriteFile(hostResolv, []byte(nameserver), 0600); err != nil {\n\t\tklog.Errorf(\"failed to write nameserver to file %s, err: %v\", hostResolv, err)\n\t}\n}", "func (v *Virter) getDHCPHosts(network libvirt.Network) ([]libvirtxml.NetworkDHCPHost, error) {\n\thosts := []libvirtxml.NetworkDHCPHost{}\n\n\tnetworkDescription, err := getNetworkDescription(v.libvirt, network)\n\tif err != nil {\n\t\treturn hosts, err\n\t}\n\tif len(networkDescription.IPs) < 1 {\n\t\treturn hosts, fmt.Errorf(\"no IPs in network\")\n\t}\n\n\tipDescription := networkDescription.IPs[0]\n\n\tdhcpDescription := ipDescription.DHCP\n\tif dhcpDescription == nil {\n\t\treturn hosts, fmt.Errorf(\"no DHCP in network\")\n\t}\n\n\tfor _, host := range dhcpDescription.Hosts {\n\t\thosts = append(hosts, host)\n\t}\n\n\treturn hosts, nil\n}", "func (d *DistributedBackupDescriptor) RemoveEmpty() *DistributedBackupDescriptor {\n\tfor node, desc := range d.Nodes {\n\t\tif len(desc.Classes) == 0 {\n\t\t\tdelete(d.Nodes, node)\n\t\t}\n\t}\n\treturn d\n}", "func deleteAllNetworks() error {\n\tnetworks, err := hcsshim.HNSListNetworkRequest(\"GET\", \"\", \"\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, network := range networks {\n\t\tif network.Name != \"nat\" {\n\t\t\t_, err = network.Delete()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func serversRemove(w http.ResponseWriter, r *http.Request) {\n\tsetHeader(w, r)\n\treadCookies(r)\n\tserver := r.URL.Query().Get(\"removeServer\")\n\tremoveServerInCookie(server, w, r)\n\tremoveServerInConfig(server)\n\thttp.Redirect(w, r, \"/public\", 301)\n}", "func (a *Client) DeleteNodesMacaddressDhcpWhitelist(params *DeleteNodesMacaddressDhcpWhitelistParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteNodesMacaddressDhcpWhitelistNoContent, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewDeleteNodesMacaddressDhcpWhitelistParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"DeleteNodesMacaddressDhcpWhitelist\",\n\t\tMethod: \"DELETE\",\n\t\tPathPattern: \"/nodes/{macaddress}/dhcp/whitelist\",\n\t\tProducesMediaTypes: []string{\"application/json\", \"application/x-gzip\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\", \"https\"},\n\t\tParams: params,\n\t\tReader: &DeleteNodesMacaddressDhcpWhitelistReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*DeleteNodesMacaddressDhcpWhitelistNoContent), nil\n}", "func (p *ProxySQL) RemoveHost(host *Host) error {\n\tmut.Lock()\n\tdefer mut.Unlock()\n\t// build a query with these options\n\t_, err := exec(p, fmt.Sprintf(\"delete from mysql_servers where %s\", host.where()))\n\treturn err\n}", "func (d *DHCPv4) NTPServers() []net.IP {\n\treturn GetIPs(OptionNTPServers, d.Options)\n}", "func (c *FortiSDKClient) DeleteNetworkingInterfaceDHCP(mkey string) (err error) {\n\tlogPrefix := \"DeleteNetworkingInterfaceDHCP - \"\n\tHTTPMethod := \"DELETE\"\n\tpath := \"/api/v2/cmdb/system.dhcp/server\"\n\tpath += \"/\" + EscapeURLString(mkey)\n\n\treq := c.NewRequest(HTTPMethod, path, nil, nil)\n\terr = req.Send()\n\tif err != nil || req.HTTPResponse == nil {\n\t\terr = fmt.Errorf(\"cannot send request %s\", err)\n\t\treturn\n\t}\n\n\tbody, err := ioutil.ReadAll(req.HTTPResponse.Body)\n\tif err != nil || body == nil {\n\t\terr = fmt.Errorf(\"cannot get response body %s\", err)\n\t\treturn\n\t}\n\n\tvar result map[string]interface{}\n\tjson.Unmarshal([]byte(string(body)), &result)\n\n\treq.HTTPResponse.Body.Close()\n\n\tlog.Printf(logPrefix+\"Path called %s\", path)\n\tlog.Printf(logPrefix+\"FortiOS response: %s\", string(body))\n\n\tif result != nil {\n\t\tif result[\"status\"] == nil {\n\t\t\terr = fmt.Errorf(\"cannot get status from the response\")\n\t\t\treturn\n\t\t}\n\n\t\tif result[\"status\"] != \"success\" {\n\t\t\tif result[\"error\"] != nil {\n\t\t\t\terr = fmt.Errorf(\"status is %s and error no is %.0f\", result[\"status\"], result[\"error\"])\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"status is %s and error no is not found\", result[\"status\"])\n\t\t\t}\n\n\t\t\tif result[\"http_status\"] != nil {\n\t\t\t\terr = fmt.Errorf(\"%s, details: %s\", err, util.HttpStatus2Str(int(result[\"http_status\"].(float64))))\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"%s, and http_status no is not found\", err)\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"cannot get the right response\")\n\t\treturn\n\t}\n\n\treturn\n}", "func (c *VMReplicaSet) orphan(cm *controller.VirtualMachineControllerRefManager, rs *virtv1.VirtualMachineReplicaSet, vms []*virtv1.VirtualMachine) error {\n\n\tvar wg sync.WaitGroup\n\terrChan := make(chan error, len(vms))\n\twg.Add(len(vms))\n\n\tfor _, vm := range vms {\n\t\tgo func(vm *virtv1.VirtualMachine) {\n\t\t\tdefer wg.Done()\n\t\t\terr := cm.ReleaseVirtualMachine(vm)\n\t\t\tif err != nil {\n\t\t\t\terrChan <- err\n\t\t\t}\n\t\t}(vm)\n\t}\n\twg.Wait()\n\tselect {\n\tcase err := <-errChan:\n\t\treturn err\n\tdefault:\n\t}\n\treturn nil\n}", "func (m *ServerManager) DeleteUnhealthServerAtPeriodic(ctx context.Context, duration time.Duration) {\n\tticker := time.NewTicker(duration)\n\tfor {\n\t\tselect {\n\t\tcase <-ticker.C:\n\t\t\tvar deadServerIDs []int\n\t\t\tm.servers.Range(func(_, value interface{}) bool {\n\t\t\t\tserver, ok := value.(*Server)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tif time.Now().Sub(server.updated) > duration {\n\t\t\t\t\tdeadServerIDs = append(deadServerIDs, server.ServerID)\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t})\n\t\t\tfor _, id := range deadServerIDs {\n\t\t\t\tm.Delete(id)\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\t}\n\t}\n}", "func ToNameserversStripTD(nss []string) ([]*Nameserver, error) {\n\tnservers := []*Nameserver{}\n\tfor _, ns := range nss {\n\t\tif !strings.HasSuffix(ns, \".\") {\n\t\t\treturn nil, fmt.Errorf(\"provider code already removed nameserver trailing dot (%v)\", ns)\n\t\t\t// If you see this error, maybe the provider should call ToNameservers instead.\n\t\t}\n\t\tnservers = append(nservers, &Nameserver{Name: ns[0 : len(ns)-1]})\n\t}\n\treturn nservers, nil\n}", "func removeRBDLocks(instance *ec2.Instance) {\n\taddress, found := hosts[instance.InstanceId]\n\tif !found {\n\t\tglog.Errorf(\"The instance: %s was not found in the hosts map\", instance.InstanceId)\n\t\treturn\n\t}\n\tglog.Infof(\"Instance: %s, address: %s, state: %s, checking for locks\", instance.InstanceId, address, instance.State.Name)\n\n\tvar deleted = false\n\n\tfor i := 0; i < 3; i++ {\n\t\terr := rbdClient.UnlockClient(address)\n\t\tif err != nil {\n\t\t\tglog.Errorf(\"Failed to unlock the images, attempting again if possible\")\n\t\t\t<-time.After(time.Duration(5) * time.Second)\n\t\t}\n\t\tdeleted = true\n\t}\n\n\tif !deleted {\n\t\tglog.Errorf(\"Failed to unlock any images that could have been held by client: %s\", address)\n\t}\n\n\t// step: delete from the hosts map\n\tdelete(hosts, instance.InstanceId)\n}", "func (w *worker) excludeHostFromClickHouseCluster(host *chop.ChiHost) {\n\t// Specify in options to exclude host from ClickHouse config file\n\toptions := chopmodel.NewClickHouseConfigFilesGeneratorOptions().\n\t\tSetRemoteServersGeneratorOptions(\n\t\t\tchopmodel.NewRemoteServersGeneratorOptions().\n\t\t\t\tExcludeHost(host).\n\t\t\t\tExcludeReconcileAttributes(\n\t\t\t\t\tchop.NewChiHostReconcileAttributes().SetAdd(),\n\t\t\t\t),\n\t\t)\n\n\t// Remove host from cluster config and wait for ClickHouse to pick-up the change\n\tif w.waitExcludeHost(host) {\n\t\t_ = w.reconcileCHIConfigMapCommon(host.GetCHI(), options, true)\n\t\t_ = w.waitHostNotInCluster(host)\n\t}\n}", "func (st *State) dropServer(id string) {\n\tst.mu.Lock()\n\tdefer st.mu.Unlock()\n\tfor i, s := range st.servers {\n\t\tif s.ID == id {\n\t\t\tcopy(st.servers[i:], st.servers[i+1:])\n\t\t\tst.servers[len(st.servers)-1] = nil\n\t\t\tst.servers = st.servers[:len(st.servers)-1]\n\t\t\treturn\n\t\t}\n\t}\n}", "func removeWorkers(addrs []dist.Address) error {\n\tdirLock.Lock()\n\tdefer dirLock.Unlock()\n\n\t// cs 101 here we come\n\tres := make([]*dist.Address, 0)\n\tfor i := range directory {\n\t\trm := false\n\t\tfor k := range addrs {\n\t\t\tif directory[i].Equal(addrs[k]) {\n\t\t\t\trm = true\n\t\t\t}\n\t\t}\n\t\tif !rm {\n\t\t\tif directory[i].Valid() {\n\t\t\t\tres = append(res, directory[i])\n\t\t\t}\n\t\t}\n\t}\n\tdirectory = res\n\treturn nil\n}", "func (s *Swarm) filterKnownUndialables(p peer.ID, addrs []ma.Multiaddr) []ma.Multiaddr {\n\tlisAddrs, _ := s.InterfaceListenAddresses()\n\tvar ourAddrs []ma.Multiaddr\n\tfor _, addr := range lisAddrs {\n\t\tprotos := addr.Protocols()\n\t\t// we're only sure about filtering out /ip4 and /ip6 addresses, so far\n\t\tif protos[0].Code == ma.P_IP4 || protos[0].Code == ma.P_IP6 {\n\t\t\tourAddrs = append(ourAddrs, addr)\n\t\t}\n\t}\n\n\treturn maybeRemoveWebTransportAddrs(ma.FilterAddrs(addrs,\n\t\tfunc(addr ma.Multiaddr) bool { return !ma.Contains(ourAddrs, addr) },\n\t\ts.canDial,\n\t\t// TODO: Consider allowing link-local addresses\n\t\tfunc(addr ma.Multiaddr) bool { return !manet.IsIP6LinkLocal(addr) },\n\t\tfunc(addr ma.Multiaddr) bool {\n\t\t\treturn s.gater == nil || s.gater.InterceptAddrDial(p, addr)\n\t\t},\n\t))\n}", "func (n PowerVSNetwork) cleanup(options *CleanupOptions) error {\n\tresourceLogger := logrus.WithFields(logrus.Fields{\"resource\": options.Resource.Name})\n\tresourceLogger.Info(\"Cleaning up the networks\")\n\tpclient, err := NewPowerVSClient(options)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"couldn't create powervs client\")\n\t}\n\n\tnetworks, err := pclient.GetNetworks()\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to get the networks in %q\", pclient.resource.Name)\n\t}\n\n\tfor _, net := range networks.Networks {\n\t\tports, err := pclient.GetPorts(*net.NetworkID)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to get ports of network %q\", *net.Name)\n\t\t}\n\t\tfor _, port := range ports.Ports {\n\t\t\terr = pclient.DeletePort(*net.NetworkID, *port.PortID)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"failed to delete port of network %q\", *net.Name)\n\t\t\t}\n\t\t}\n\t\terr = pclient.DeleteNetwork(*net.NetworkID)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to delete network %q\", *net.Name)\n\t\t}\n\t}\n\tresourceLogger.Info(\"Successfully deleted the networks\")\n\treturn nil\n}", "func (orgVdcNet *OpenApiOrgVdcNetwork) DeletNetworkDhcp() error {\n\tendpoint := types.OpenApiPathVersion1_0_0 + types.OpenApiEndpointOrgVdcNetworksDhcp\n\tapiVersion, err := orgVdcNet.client.getOpenApiHighestElevatedVersion(endpoint)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif orgVdcNet.OpenApiOrgVdcNetwork.ID == \"\" {\n\t\treturn fmt.Errorf(\"cannot delete Org VDC network DHCP configuration without ID\")\n\t}\n\n\turlRef, err := orgVdcNet.client.OpenApiBuildEndpoint(fmt.Sprintf(endpoint, orgVdcNet.OpenApiOrgVdcNetwork.ID))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = orgVdcNet.client.OpenApiDeleteItem(apiVersion, urlRef, nil, nil)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error deleting Org VDC network DHCP configuration: %s\", err)\n\t}\n\n\treturn nil\n}", "func (self *basicPodManager) DeleteOrphanedMirrorPods(mirrorPods *mirrorPods) {\n\tpodFullNames := mirrorPods.GetOrphanedMirrorPodNames()\n\tfor _, podFullName := range podFullNames {\n\t\tself.mirrorManager.DeleteMirrorPod(podFullName)\n\t}\n}", "func (f *Framework) CleanUp(ns string) error {\n\treturn f.AgonesClient.StableV1alpha1().GameServers(ns).\n\t\tDeleteCollection(&v1.DeleteOptions{}, v1.ListOptions{})\n}", "func (md *MassDns) Clean() error {\n\t// remove only temp resolvers file\n\tif md.tempResolversPath != \"\" {\n\t\tos.Remove(md.tempResolversPath)\n\t\tmd.tempResolversPath = \"\"\n\t}\n\treturn nil\n}", "func (o ArgoCDSpecInitialSSHKnownHostsOutput) Excludedefaulthosts() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v ArgoCDSpecInitialSSHKnownHosts) *bool { return v.Excludedefaulthosts }).(pulumi.BoolPtrOutput)\n}", "func (i *DHCPInterface) SetDNSServers(dns []string) {\n\tfor _, server := range dns {\n\t\ti.dnsServers = append(i.dnsServers, []byte(net.ParseIP(server).To4())...)\n\t}\n}", "func IPIsDoHOnlyServer(ip netip.Addr) bool {\n\treturn nextDNSv6RangeA.Contains(ip) || nextDNSv6RangeB.Contains(ip) ||\n\t\tnextDNSv4RangeA.Contains(ip) || nextDNSv4RangeB.Contains(ip)\n}", "func (pr *PortRegistry) DeregisterServerPorts(ports []int32) {\n\tfor i := 0; i < len(ports); i++ {\n\t\tpr.HostPorts[ports[i]] = false\n\t}\n}", "func multiJoinSwitchGatewayCleanup(nodeName string, upgradeOnly bool) error {\n\tgatewayRouter := types.GWRouterPrefix + nodeName\n\n\t// Get the gateway router port's IP address (connected to join switch)\n\tvar nextHops []net.IP\n\n\tgwIPAddrs, err := util.GetLRPAddrs(types.GWRouterToJoinSwitchPrefix + gatewayRouter)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, gwIPAddr := range gwIPAddrs {\n\t\t// Delete logical router policy whose nexthop is the old rtoj- gateway port address\n\t\tstdout, stderr, err := util.RunOVNNbctl(\"--data=bare\", \"--no-heading\", \"--columns=_uuid\",\n\t\t\t\"find\", \"logical_router_policy\", fmt.Sprintf(\"nexthop=%s\", gwIPAddr.IP))\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"Unable to find LR policy of nexthop: %s for node %s, stderr: %s, err: %v\",\n\t\t\t\tgwIPAddr.IP, nodeName, stderr, err)\n\t\t\tcontinue\n\t\t}\n\t\tif stdout != \"\" {\n\t\t\tpolicyIDs := strings.Fields(stdout)\n\t\t\tfor _, policyID := range policyIDs {\n\t\t\t\t_, stderr, err = util.RunOVNNbctl(\"remove\", \"logical_router\", types.OVNClusterRouter, \"policies\", policyID)\n\t\t\t\tif err != nil {\n\t\t\t\t\tklog.Errorf(\"Unable to remove LR policy: %s, stderr: %s, err: %v\", policyID, stderr, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tnextHops = append(nextHops, gwIPAddr.IP)\n\t}\n\tstaticRouteCleanup(nextHops)\n\n\t// Remove the join switch that connects ovn_cluster_router to gateway router\n\t_, stderr, err := util.RunOVNNbctl(\"--if-exist\", \"ls-del\", \"join_\"+nodeName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete the join logical switch %s, \"+\n\t\t\t\"stderr: %q, error: %v\", \"join_\"+nodeName, stderr, err)\n\t}\n\n\t// Remove the logical router port on the distributed router that connects to the join switch\n\t_, stderr, err = util.RunOVNNbctl(\"--if-exist\", \"lrp-del\", \"dtoj-\"+nodeName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete the patch port dtoj-%s on distributed router \"+\n\t\t\t\"stderr: %q, error: %v\", nodeName, stderr, err)\n\t}\n\n\t// Remove the logical router port on the gateway router that connects to the join switch\n\t_, stderr, err = util.RunOVNNbctl(\"--if-exist\", \"lrp-del\", types.GWRouterToJoinSwitchPrefix+gatewayRouter)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete the port %s%s on gateway router \"+\n\t\t\t\"stderr: %q, error: %v\", types.GWRouterToJoinSwitchPrefix, gatewayRouter, stderr, err)\n\t}\n\n\tif upgradeOnly {\n\t\treturn nil\n\t}\n\n\t// Remove router to lb associations from the LBCache before removing the router\n\tlbCache, err := ovnlb.GetLBCache()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get load_balancer cache for router %s: %v\", gatewayRouter, err)\n\t}\n\tlbCache.RemoveRouter(gatewayRouter)\n\n\t// Remove the gateway router associated with nodeName\n\t_, stderr, err = util.RunOVNNbctl(\"--if-exist\", \"lr-del\",\n\t\tgatewayRouter)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete gateway router %s, stderr: %q, \"+\n\t\t\t\"error: %v\", gatewayRouter, stderr, err)\n\t}\n\n\t// Remove external switch\n\texternalSwitch := types.ExternalSwitchPrefix + nodeName\n\t_, stderr, err = util.RunOVNNbctl(\"--if-exist\", \"ls-del\",\n\t\texternalSwitch)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to delete external switch %s, stderr: %q, \"+\n\t\t\t\"error: %v\", externalSwitch, stderr, err)\n\t}\n\n\t// We don't know the gateway mode as this is running in the master, try to delete the additional local\n\t// gateway for the shared gateway mode. it will be no op if this is done for other gateway modes.\n\tdelPbrAndNatRules(nodeName, nil)\n\treturn nil\n}", "func (d *Daemon) syncHostIPs() error {\n\tif option.Config.DryMode {\n\t\treturn nil\n\t}\n\n\ttype ipIDLabel struct {\n\t\tidentity.IPIdentityPair\n\t\tlabels.Labels\n\t}\n\tspecialIdentities := make([]ipIDLabel, 0, 2)\n\n\tif option.Config.EnableIPv4 {\n\t\taddrs, err := d.datapath.LocalNodeAddressing().IPv4().LocalAddresses()\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Warning(\"Unable to list local IPv4 addresses\")\n\t\t}\n\n\t\tfor _, ip := range addrs {\n\t\t\tif option.Config.IsExcludedLocalAddress(ip) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif len(ip) > 0 {\n\t\t\t\tspecialIdentities = append(specialIdentities, ipIDLabel{\n\t\t\t\t\tidentity.IPIdentityPair{\n\t\t\t\t\t\tIP: ip,\n\t\t\t\t\t\tID: identity.ReservedIdentityHost,\n\t\t\t\t\t},\n\t\t\t\t\tlabels.LabelHost,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tipv4Ident := identity.ReservedIdentityWorldIPv4\n\t\tipv4Label := labels.LabelWorldIPv4\n\t\tif !option.Config.EnableIPv6 {\n\t\t\tipv4Ident = identity.ReservedIdentityWorld\n\t\t\tipv4Label = labels.LabelWorld\n\t\t}\n\t\tspecialIdentities = append(specialIdentities, ipIDLabel{\n\t\t\tidentity.IPIdentityPair{\n\t\t\t\tIP: net.IPv4zero,\n\t\t\t\tMask: net.CIDRMask(0, net.IPv4len*8),\n\t\t\t\tID: ipv4Ident,\n\t\t\t},\n\t\t\tipv4Label,\n\t\t})\n\t}\n\n\tif option.Config.EnableIPv6 {\n\t\taddrs, err := d.datapath.LocalNodeAddressing().IPv6().LocalAddresses()\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Warning(\"Unable to list local IPv6 addresses\")\n\t\t}\n\n\t\taddrs = append(addrs, node.GetIPv6Router())\n\t\tfor _, ip := range addrs {\n\t\t\tif option.Config.IsExcludedLocalAddress(ip) {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif len(ip) > 0 {\n\t\t\t\tspecialIdentities = append(specialIdentities, ipIDLabel{\n\t\t\t\t\tidentity.IPIdentityPair{\n\t\t\t\t\t\tIP: ip,\n\t\t\t\t\t\tID: identity.ReservedIdentityHost,\n\t\t\t\t\t},\n\t\t\t\t\tlabels.LabelHost,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tipv6Ident := identity.ReservedIdentityWorldIPv6\n\t\tipv6Label := labels.LabelWorldIPv6\n\t\tif !option.Config.EnableIPv4 {\n\t\t\tipv6Ident = identity.ReservedIdentityWorld\n\t\t\tipv6Label = labels.LabelWorld\n\t\t}\n\t\tspecialIdentities = append(specialIdentities, ipIDLabel{\n\t\t\tidentity.IPIdentityPair{\n\t\t\t\tIP: net.IPv6zero,\n\t\t\t\tMask: net.CIDRMask(0, net.IPv6len*8),\n\t\t\t\tID: ipv6Ident,\n\t\t\t},\n\t\t\tipv6Label,\n\t\t})\n\t}\n\n\texistingEndpoints, err := lxcmap.DumpToMap()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdaemonResourceID := ipcachetypes.NewResourceID(ipcachetypes.ResourceKindDaemon, \"\", \"\")\n\tfor _, ipIDLblsPair := range specialIdentities {\n\t\tisHost := ipIDLblsPair.ID == identity.ReservedIdentityHost\n\t\tif isHost {\n\t\t\tadded, err := lxcmap.SyncHostEntry(ipIDLblsPair.IP)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"Unable to add host entry to endpoint map: %s\", err)\n\t\t\t}\n\t\t\tif added {\n\t\t\t\tlog.WithField(logfields.IPAddr, ipIDLblsPair.IP).Debugf(\"Added local ip to endpoint map\")\n\t\t\t}\n\t\t}\n\n\t\tdelete(existingEndpoints, ipIDLblsPair.IP.String())\n\n\t\tlbls := ipIDLblsPair.Labels\n\t\tif ipIDLblsPair.ID.IsWorld() {\n\t\t\tp := netip.PrefixFrom(ippkg.MustAddrFromIP(ipIDLblsPair.IP), 0)\n\t\t\td.ipcache.OverrideIdentity(p, lbls, source.Local, daemonResourceID)\n\t\t} else {\n\t\t\td.ipcache.UpsertLabels(ippkg.IPToNetPrefix(ipIDLblsPair.IP),\n\t\t\t\tlbls,\n\t\t\t\tsource.Local, daemonResourceID,\n\t\t\t)\n\t\t}\n\t}\n\n\t// existingEndpoints is a map from endpoint IP to endpoint info. Referring\n\t// to the key as host IP here because we only care about the host endpoint.\n\tfor hostIP, info := range existingEndpoints {\n\t\tif ip := net.ParseIP(hostIP); info.IsHost() && ip != nil {\n\t\t\tif err := lxcmap.DeleteEntry(ip); err != nil {\n\t\t\t\tlog.WithError(err).WithFields(logrus.Fields{\n\t\t\t\t\tlogfields.IPAddr: hostIP,\n\t\t\t\t}).Warn(\"Unable to delete obsolete host IP from BPF map\")\n\t\t\t} else {\n\t\t\t\tlog.Debugf(\"Removed outdated host IP %s from endpoint map\", hostIP)\n\t\t\t}\n\n\t\t\td.ipcache.RemoveLabels(ippkg.IPToNetPrefix(ip), labels.LabelHost, daemonResourceID)\n\t\t}\n\t}\n\n\tif option.Config.EnableVTEP {\n\t\terr := setupVTEPMapping()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = setupRouteToVtepCidr()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (VPCNetwork) cleanup(options *CleanupOptions) error {\n\tresourceLogger := logrus.WithFields(logrus.Fields{\"resource\": options.Resource.Name})\n\tresourceLogger.Info(\"Cleaning up the networks\")\n\tclient, err := NewVPCClient(options)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"couldn't create VPC client\")\n\t}\n\n\tsubnetList, _, err := client.ListSubnets(&vpcv1.ListSubnetsOptions{\n\t\tResourceGroupID: &client.ResourceGroupID,\n\t})\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to list the subnets\")\n\t}\n\n\tfor _, subnet := range subnetList.Subnets {\n\t\tpg, _, err := client.GetSubnetPublicGateway(&vpcv1.GetSubnetPublicGatewayOptions{\n\t\t\tID: subnet.ID,\n\t\t})\n\t\tif pg != nil && err == nil {\n\t\t\t_, err := client.UnsetSubnetPublicGateway(&vpcv1.UnsetSubnetPublicGatewayOptions{\n\t\t\t\tID: subnet.ID,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"failed to unset the gateway for %q\", *subnet.Name)\n\t\t\t}\n\n\t\t\t_, err = client.DeletePublicGateway(&vpcv1.DeletePublicGatewayOptions{\n\t\t\t\tID: pg.ID,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"failed to delete the gateway %q\", *pg.Name)\n\t\t\t}\n\t\t\tresourceLogger.WithFields(logrus.Fields{\"name\": pg.Name}).Info(\"Successfully deleted the gateway\")\n\t\t}\n\t\t_, err = client.DeleteSubnet(&vpcv1.DeleteSubnetOptions{ID: subnet.ID})\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to delete the subnet %q\", *subnet.Name)\n\t\t}\n\t}\n\n\t// Delete the unbound floating IPs that were previously used by a VSI\n\tfips, _, err := client.ListFloatingIps(&vpcv1.ListFloatingIpsOptions{\n\t\tResourceGroupID: &client.ResourceGroupID,\n\t})\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to list the floating IPs\")\n\t}\n\tfor _, fip := range fips.FloatingIps {\n\t\t_, err = client.DeleteFloatingIP(&vpcv1.DeleteFloatingIPOptions{\n\t\t\tID: fip.ID,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to delete the floating IP %q\", *fip.Name)\n\t\t}\n\t\tresourceLogger.WithFields(logrus.Fields{\"name\": fip.Name}).Info(\"Successfully deleted the floating IP\")\n\t}\n\n\tresourceLogger.Info(\"Successfully deleted the subnets\")\n\treturn nil\n}", "func (client WorkloadNetworksClient) DeleteDhcpResponder(resp *http.Response) (result autorest.Response, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),\n\t\tautorest.ByClosing())\n\tresult.Response = resp\n\treturn\n}", "func (m *MicroService) blackListHost(host string, blacklist bool) {\r\n\tfor idx, inst := range m.Instances {\r\n\t\tif inst.Host == host {\r\n\t\t\tm.blackList(idx, blacklist)\r\n\t\t}\r\n\t}\r\n}", "func RemoveHvacConfig(db Database, mac string) error {\n\tcriteria := make(map[string]interface{})\n\tcriteria[\"Mac\"] = mac\n\treturn db.DeleteRecord(pconst.DbConfig, pconst.TbHvacs, criteria)\n}", "func Clean(c Config) {\n\n\tSetup(&c)\n\tContainers, _ := model.DockerContainerList()\n\n\tfor _, Container := range Containers {\n\t\ttarget := false\n\t\tif l := Container.Labels[\"pygmy.enable\"]; l == \"true\" || l == \"1\" {\n\t\t\ttarget = true\n\t\t}\n\t\tif l := Container.Labels[\"pygmy\"]; l == \"pygmy\" {\n\t\t\ttarget = true\n\t\t}\n\n\t\tif target {\n\t\t\terr := model.DockerKill(Container.ID)\n\t\t\tif err == nil {\n\t\t\t\tfmt.Printf(\"Successfully killed %v.\\n\", Container.Names[0])\n\t\t\t}\n\n\t\t\terr = model.DockerRemove(Container.ID)\n\t\t\tif err == nil {\n\t\t\t\tfmt.Printf(\"Successfully removed %v.\\n\", Container.Names[0])\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, network := range c.Networks {\n\t\tmodel.DockerNetworkRemove(&network)\n\t\tif s, _ := model.DockerNetworkStatus(&network); s {\n\t\t\tfmt.Printf(\"Successfully removed network %v\\n\", network.Name)\n\t\t} else {\n\t\t\tfmt.Printf(\"Network %v was not removed\\n\", network.Name)\n\t\t}\n\t}\n\n\tfor _, resolver := range c.Resolvers {\n\t\tresolver.Clean()\n\t}\n}", "func cleanupAddressSet(addrs []ma.Multiaddr) []ma.Multiaddr {\n\tvar public, private []ma.Multiaddr\n\n\tfor _, a := range addrs {\n\t\tif isRelayAddr(a) {\n\t\t\tcontinue\n\t\t}\n\n\t\tif manet.IsPublicAddr(a) || isDNSAddr(a) {\n\t\t\tpublic = append(public, a)\n\t\t\tcontinue\n\t\t}\n\n\t\t// discard unroutable addrs\n\t\tif manet.IsPrivateAddr(a) {\n\t\t\tprivate = append(private, a)\n\t\t}\n\t}\n\n\tif !hasAddrsplosion(public) {\n\t\treturn public\n\t}\n\n\treturn sanitizeAddrsplodedSet(public, private)\n}", "func (lv *Libvirt) rebuildDHCPStaticLeases(app *App) error {\n\t_, err := lv.GetConnection()\n\tif err != nil {\n\t\treturn err\n\t}\n\tpreviousHosts := lv.NetworkXML.IPs[0].DHCP.Hosts\n\tvar hostsToDelete []libvirtxml.NetworkDHCPHost\n\tvar hostsToAdd []libvirtxml.NetworkDHCPHost // mostly for old VMs (previous \"format\") where no static IP was set\n\n\t// search for leases to delete\n\tfor _, host := range previousHosts {\n\t\tif !strings.HasPrefix(host.Name, app.Config.VMPrefix) {\n\t\t\tcontinue\n\t\t}\n\t\tnameID := strings.TrimPrefix(host.Name, app.Config.VMPrefix)\n\t\tvm, _ := app.VMDB.GetByNameID(nameID)\n\t\tif vm == nil {\n\t\t\tif lv.dhcpLeases.findByHost(host.Name) == nil {\n\t\t\t\thostsToDelete = append(hostsToDelete, host)\n\t\t\t}\n\t\t}\n\t}\n\n\t// search for leases to add (from VM database)\n\tvmNames := app.VMDB.GetNames()\n\tfor _, name := range vmNames {\n\t\tfound := false\n\t\tfor _, host := range previousHosts {\n\t\t\tif host.Name == name.LibvirtDomainName(app) {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tvm, err := app.VMDB.GetByName(name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\thost := libvirtxml.NetworkDHCPHost{\n\t\t\t\tName: name.LibvirtDomainName(app),\n\t\t\t\tMAC: vm.AssignedMAC,\n\t\t\t\tIP: vm.AssignedIPv4,\n\t\t\t}\n\t\t\thostsToAdd = append(hostsToAdd, host)\n\t\t}\n\t}\n\n\t// search for leases to add (from transient database)\n\tfor lease := range lv.dhcpLeases.leases {\n\t\tfound := false\n\t\tfor _, host := range previousHosts {\n\t\t\tif host.Name == lease.Name {\n\t\t\t\tfound = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\thostsToAdd = append(hostsToAdd, *lease)\n\t\t}\n\t}\n\n\tfor _, host := range hostsToDelete {\n\t\tapp.Log.Tracef(\"remove DHCP lease for '%s/%s/%s'\", host.Name, host.MAC, host.IP)\n\t\txml, err := host.Marshal()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = lv.Network.Update(\n\t\t\tlibvirt.NETWORK_UPDATE_COMMAND_DELETE,\n\t\t\tlibvirt.NETWORK_SECTION_IP_DHCP_HOST,\n\t\t\t-1,\n\t\t\txml,\n\t\t\tlibvirt.NETWORK_UPDATE_AFFECT_LIVE|libvirt.NETWORK_UPDATE_AFFECT_CONFIG,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfor _, host := range hostsToAdd {\n\t\tapp.Log.Tracef(\"add DHCP lease for '%s/%s/%s'\", host.Name, host.MAC, host.IP)\n\t\txml, err := host.Marshal()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = lv.Network.Update(\n\t\t\tlibvirt.NETWORK_UPDATE_COMMAND_ADD_LAST,\n\t\t\tlibvirt.NETWORK_SECTION_IP_DHCP_HOST,\n\t\t\t-1,\n\t\t\txml,\n\t\t\tlibvirt.NETWORK_UPDATE_AFFECT_LIVE|libvirt.NETWORK_UPDATE_AFFECT_CONFIG,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// update lv.NetworkXML\n\txmldoc, err := lv.Network.GetXMLDesc(0)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed GetXMLDesc: %s\", err)\n\t}\n\n\tnetcfg := &libvirtxml.Network{}\n\terr = netcfg.Unmarshal(xmldoc)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed Unmarshal: %s\", err)\n\t}\n\n\tlv.NetworkXML = netcfg\n\n\treturn nil\n}", "func (p *ProxySQL) RemoveHosts(hosts ...*Host) error {\n\tfor _, host := range hosts {\n\t\terr := p.RemoveHost(host)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (ps *PeerStore) RemoveRandom() {\n\tps.lock.Lock()\n\tdefer ps.lock.Unlock()\n\tfor _, p := range ps.peers {\n\t\tdelete(ps.peers, p.ListenAddr)\n\t\tbreak\n\t}\n}", "func (r *HashRing) copyServersNoLock() []string {\n\tservers := make([]string, 0, len(r.serverSet))\n\tfor server := range r.serverSet {\n\t\tservers = append(servers, server)\n\t}\n\treturn servers\n}", "func DeallocateIP(reservelist []IPReservation, containerID string) ([]IPReservation, net.IP, error) {\n\n}", "func (o ArgoCDSpecInitialSSHKnownHostsPtrOutput) Excludedefaulthosts() pulumi.BoolPtrOutput {\n\treturn o.ApplyT(func(v *ArgoCDSpecInitialSSHKnownHosts) *bool {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Excludedefaulthosts\n\t}).(pulumi.BoolPtrOutput)\n}", "func WithDHCPServer(subnet *net.IPNet) Option {\n\treturn func(d *dnsmasq) {\n\t\td.subnet = subnet\n\t}\n}", "func (dump *Dump) purge(existed Int32Map, stats *ParseStatistics) {\n\tfor id, cont := range dump.ContentIndex {\n\t\tif _, ok := existed[id]; !ok {\n\t\t\tfor _, ip4 := range cont.IPv4 {\n\t\t\t\tdump.RemoveFromIPv4Index(ip4.IPv4, cont.ID)\n\t\t\t}\n\n\t\t\tfor _, ip6 := range cont.IPv6 {\n\t\t\t\tip6 := string(ip6.IPv6)\n\t\t\t\tdump.RemoveFromIPv6Index(ip6, cont.ID)\n\t\t\t}\n\n\t\t\tfor _, subnet6 := range cont.SubnetIPv6 {\n\t\t\t\tdump.RemoveFromSubnetIPv6Index(subnet6.SubnetIPv6, cont.ID)\n\t\t\t}\n\n\t\t\tfor _, subnet4 := range cont.SubnetIPv4 {\n\t\t\t\tdump.RemoveFromSubnetIPv4Index(subnet4.SubnetIPv4, cont.ID)\n\t\t\t}\n\n\t\t\tfor _, u := range cont.URL {\n\t\t\t\tdump.RemoveFromURLIndex(NormalizeURL(u.URL), cont.ID)\n\t\t\t}\n\n\t\t\tfor _, domain := range cont.Domain {\n\t\t\t\tdump.RemoveFromDomainIndex(NormalizeDomain(domain.Domain), cont.ID)\n\t\t\t}\n\n\t\t\tdump.RemoveFromDecisionIndex(cont.Decision, cont.ID)\n\t\t\tdump.RemoveFromDecisionOrgIndex(cont.DecisionOrg, cont.ID)\n\t\t\tdump.RemoveFromDecisionWithoutNoIndex(cont.ID)\n\t\t\tdump.RemoveFromEntryTypeIndex(entryTypeKey(cont.EntryType, cont.DecisionOrg), cont.ID)\n\n\t\t\tdelete(dump.ContentIndex, id)\n\n\t\t\tstats.RemoveCount++\n\t\t}\n\t}\n}", "func cleanNS(l []*net.NS) []string {\n\tvar r []string\n\tfor _, i := range l {\n\t\tr = append(r, i.Host)\n\t}\n\tsort.Strings(r)\n\treturn (r)\n\n}", "func RemoveDnats(dnats []*Dnat) int {\n\n\ttree := vyos.NewParserFromShowConfiguration().Tree\n\n\tfor _, dnat := range dnats {\n\t\tdeleteDnat(tree, dnat)\n\t}\n\n\ttree.Apply(false)\n\n\treturn merrors.ErrSuccess\n}", "func resourceBoilerplateServerDelete(d *schema.ResourceData, m interface{}) error {\n\tclient := m.(*Client).Client\n\n\tid, err := strconv.Atoi(d.Id())\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclient.DeleteServer(context.Background(), id)\n\n\tlog.Printf(\"[INFO] Deleting Server\")\n\n\treturn nil\n}", "func stripPendingDeletes(pm *kafkazk.PartitionMap, zk kafkazk.Handler) []string {\n\t// Get pending deletions.\n\tpd, err := zk.GetPendingDeletion()\n\tif err != nil {\n\t\tfmt.Println(\"Error fetching topics pending deletion\")\n\t}\n\n\tif len(pd) == 0 {\n\t\treturn []string{}\n\t}\n\n\t// This is used as a set of topic names\n\t// pending deleting.\n\tpending := map[string]struct{}{}\n\n\tfor _, t := range pd {\n\t\tpending[t] = struct{}{}\n\t}\n\n\t// Traverse the partition map and drop\n\t// any pending topics.\n\n\tnewPL := kafkazk.PartitionList{}\n\tpendingExcluded := map[string]struct{}{}\n\tfor _, p := range pm.Partitions {\n\t\tif _, exists := pending[p.Topic]; !exists {\n\t\t\tnewPL = append(newPL, p)\n\t\t} else {\n\t\t\tpendingExcluded[p.Topic] = struct{}{}\n\t\t}\n\t}\n\n\tpm.Partitions = newPL\n\n\tpendingExcludedNames := []string{}\n\tfor t := range pendingExcluded {\n\t\tpendingExcludedNames = append(pendingExcludedNames, t)\n\t}\n\n\treturn pendingExcludedNames\n}", "func (plugin *cniNetworkPlugin) cleanupBridges(containerID string) error {\n\t// Get the amount of combinations between an IP mask, and an iptables chain, with the specified container ID\n\tresult, err := getIPChains(containerID)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar teardownErrs []error\n\tfor _, net := range plugin.cniConfig.Networks {\n\t\tvar hasBridge bool\n\t\tfor _, plugin := range net.Config.Plugins {\n\t\t\tif plugin.Network.Type == \"bridge\" {\n\t\t\t\thasBridge = true\n\t\t\t}\n\t\t}\n\n\t\tif hasBridge {\n\t\t\tlog.Debugf(\"Teardown IPMasq for container %q on CNI network %q which contains a bridge\", containerID, net.Config.Name)\n\t\t\tcomment := utils.FormatComment(net.Config.Name, containerID)\n\t\t\tfor _, t := range result {\n\t\t\t\tif err = ip.TeardownIPMasq(t.ip, t.chain, comment); err != nil {\n\t\t\t\t\tteardownErrs = append(teardownErrs, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(teardownErrs) == 1 {\n\t\treturn teardownErrs[0]\n\t}\n\tif len(teardownErrs) > 0 {\n\t\treturn fmt.Errorf(\"Errors occured cleaning up bridges: %v\", teardownErrs)\n\t}\n\n\treturn nil\n}", "func (client *LANHostConfigManagement1) DeleteDNSServer(NewDNSServers string) (err error) {\n\treturn client.DeleteDNSServerCtx(context.Background(),\n\t\tNewDNSServers,\n\t)\n}", "func (e *Engine) shutdownVservers() {\n\tfor _, v := range e.vservers {\n\t\tv.stop()\n\t}\n\tfor name, v := range e.vservers {\n\t\t<-v.stopped\n\t\tdelete(e.vservers, name)\n\t}\n\te.vserverLock.Lock()\n\te.vserverSnapshots = make(map[string]*seesaw.Vserver)\n\te.vserverLock.Unlock()\n}", "func RemoveServiceVhosts(conn client.Connection, svc *service.Service) error {\n\tglog.V(2).Infof(\"RemoveServiceVhosts for ID:%s Name:%s\", svc.ID, svc.Name)\n\n\t// generate map of current vhosts\n\tif svcvhosts, err := conn.Children(zkServiceVhosts); err == client.ErrNoNode {\n\t} else if err != nil {\n\t\tglog.Errorf(\"UpdateServiceVhosts unable to retrieve vhost children at path %s %s\", zkServiceVhosts, err)\n\t\treturn err\n\t} else {\n\t\tglog.V(2).Infof(\"RemoveServiceVhosts for svc.ID:%s from children:%+v\", svc.ID, svcvhosts)\n\t\tfor _, svcvhost := range svcvhosts {\n\t\t\tvhkey := VHostKey(svcvhost)\n\t\t\tif vhkey.ServiceID() == svc.ID {\n\t\t\t\tif err := removeServiceVhost(conn, string(vhkey)); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func CleanTunIP(tunName string, subnetIP global.Address, subnetMask uint8, client bool) error {\n\tip, subnet, err := ParseCIDR(subnetIP, subnetMask)\n\tif nil != err {\n\t\treturn err\n\t}\n\n\tip = ip.To4()\n\tif ip[3]%2 == 0 {\n\t\treturn errors.New(\"Invalid ip address.\")\n\t}\n\n\tpeer := net.IP(make([]byte, 4))\n\tcopy([]byte(peer), []byte(ip))\n\tpeer[3]++\n\n\tsargs := fmt.Sprintf(\"route del %s via %s dev %s\", subnet, peer, tunName)\n\targs := strings.Split(sargs, \" \")\n\tcmd := exec.Command(\"ip\", args...)\n\tif err := cmd.Run(); nil != err {\n\t\tlog.Errorf(\"ip %v err:%v\", sargs, err)\n\t} else {\n\t\tlog.Infof(\"ip %s\", sargs)\n\t}\n\n\tsargs = fmt.Sprintf(\"link set %s down\", tunName)\n\targs = strings.Split(sargs, \" \")\n\tcmd = exec.Command(\"ip\", args...)\n\tif err := cmd.Run(); nil != err {\n\t\tlog.Errorf(\"ip %v err:%v\", sargs, err)\n\t} else {\n\t\tlog.Infof(\"ip %s\", sargs)\n\t}\n\n\tsargs = fmt.Sprintf(\"%s %s %s down\", tunName, ip, peer)\n\targs = strings.Split(sargs, \" \")\n\tcmd = exec.Command(\"ifconfig\", args...)\n\tif err := cmd.Run(); nil != err {\n\t\treturn errors.New(fmt.Sprintf(\"ifconfig %v err:%v\", sargs, err))\n\t} else {\n\t\tlog.Infof(\"ifconfig %s\", sargs)\n\t}\n\n\tif client { // for client\n\t\tif err := UnRedirectGateway(); nil != err {\n\t\t\tlog.Errorf(\"%v\", err)\n\t\t}\n\t} else { // for server\n\t\tsargs = \"net.ipv4.ip_forward=0\"\n\t\targs = strings.Split(sargs, \" \")\n\t\tcmd = exec.Command(\"sysctl\", args...)\n\t\tif err := cmd.Run(); nil != err {\n\t\t\tlog.Errorf(\"sysctl %v err:%v\", sargs, err)\n\t\t}\n\n\t\tsargs = \"-t nat -D POSTROUTING -j MASQUERADE\"\n\t\targs = strings.Split(sargs, \" \")\n\t\tcmd = exec.Command(\"iptables\", args...)\n\t\tif err := cmd.Run(); nil != err {\n\t\t\tlog.Errorf(\"iptables %v err:%v\", sargs, err)\n\t\t}\n\t}\n\treturn nil\n}", "func createServersOfDomain(domainA DomainAPI, domain *model.Domain) {\n\n\tfor _, servers := range domainA.Endpoints {\n\t\taddress := servers.IPAddress\n\t\towner, country := domainA.WhoisServerAttributes(address)\n\t\tsslGrade := servers.Grade\n\t\ttemServer := model.Server{address, sslGrade, country, owner}\n\t\tdomain.Servers = append(domain.Servers, temServer)\n\t}\n}", "func getHostOnlyNetworkInterface(mc *driver.MachineConfig) (string, error) {\n\t// Check if the interface/dhcp exists.\n\tnets, err := HostonlyNets()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdhcps, err := DHCPs()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor _, n := range nets {\n\t\tif dhcp, ok := dhcps[n.NetworkName]; ok {\n\t\t\tif dhcp.IPv4.IP.Equal(mc.DHCPIP) &&\n\t\t\t\tdhcp.IPv4.Mask.String() == mc.NetMask.String() &&\n\t\t\t\tdhcp.LowerIP.Equal(mc.LowerIP) &&\n\t\t\t\tdhcp.UpperIP.Equal(mc.UpperIP) &&\n\t\t\t\tdhcp.Enabled == mc.DHCPEnabled {\n\t\t\t\treturn n.Name, nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// No existing host-only interface found. Create a new one.\n\thostonlyNet, err := CreateHostonlyNet()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\thostonlyNet.IPv4.IP = mc.HostIP\n\thostonlyNet.IPv4.Mask = mc.NetMask\n\tif err := hostonlyNet.Config(); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Create and add a DHCP server to the host-only network\n\tdhcp := driver.DHCP{}\n\tdhcp.IPv4.IP = mc.DHCPIP\n\tdhcp.IPv4.Mask = mc.NetMask\n\tdhcp.LowerIP = mc.LowerIP\n\tdhcp.UpperIP = mc.UpperIP\n\tdhcp.Enabled = true\n\tif err := AddHostonlyDHCP(hostonlyNet.Name, dhcp); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn hostonlyNet.Name, nil\n}", "func purgeOldStateOfGluster() error {\n\n\tpeers, err := client.PeerStatus()\n\tif err != nil {\n\t\trwolog.Error(\"Error while checking gluster Pool list\", err.Error())\n\t\treturn err\n\t}\n\n\tvar otherPeers []string\n\tvar connectedPeers []string\n\n\t// Debug Prints\n\trwolog.Debug(\"purgeOldStateOfGluster: Peers List \", peers)\n\tfor _, peer := range peers {\n\t\tif peer.Name != \"localhost\" {\n\t\t\totherPeers = append(otherPeers, peer.Name)\n\n\t\t\tif peer.Status == \"CONNECTED\" {\n\t\t\t\tconnectedPeers = append(connectedPeers, peer.Name)\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(connectedPeers) == 0 {\n\t\t// All peers are disconnected.\n\t\t// Remove individual bricks and delete the volume\n\t\t// Iterate and do peer detach\n\n\t\tvols, err := client.ListVolumes()\n\t\tif err != nil {\n\t\t\trwolog.Error(\"Error while List gluster volumes\", err.Error())\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, vol := range vols {\n\n\t\t\t//Set the quorum ratio before cleanup.\n\t\t\terr = helpers.SetQuorumRatio(client, \"cleanup\")\n\t\t\tif err != nil {\n\t\t\t\trwolog.Error(\"Error while setting server quorum ratio \", err)\n\t\t\t}\n\n\t\t\tstopVolumeRetry(vol.Name)\n\n\t\t\t// Iterate over bricks and remove bricks but one\n\t\t\treplica := len(vol.Bricks) - 1\n\t\t\tfor _, brick := range vol.Bricks {\n\t\t\t\t// since peers are disconnected, we delete bricks individually\n\t\t\t\tourIP, err := helpers.GetIPAddr()\n\t\t\t\tif err != nil {\n\t\t\t\t\trwolog.Error(\"Failed to get network up:\", err)\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tif !strings.Contains(brick, ourIP) {\n\t\t\t\t\tif replica > 0 {\n\t\t\t\t\t\trwolog.Debug(\"Remove Brick \", brick, \" with replica \", replica)\n\n\t\t\t\t\t\terr = rmBricksFromVol(vol.Name, brick, replica)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\trwolog.Error(\"Error Removing Brick \", err)\n\t\t\t\t\t\t\t// Do not return error, As we have tried to remove the bricks five times.\n\t\t\t\t\t\t\t// Might be IP address has been changed and handler is trying to remove\n\t\t\t\t\t\t\t// its own brick with previous IP address.\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfmt.Printf(\"Brick deleted: %s\\n\", brick)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tb, _ := client.GetBricks(vol.Name)\n\t\t\t\treplica = len(b) - 1\n\t\t\t}\n\t\t}\n\n\t\tfor _, p := range otherPeers {\n\t\t\terr = client.PeerDetach(p)\n\t\t\tif err != nil {\n\t\t\t\trwolog.Error(err)\n\t\t\t}\n\t\t\trwolog.Debug(\"Detach peer \", p, \" error \", err)\n\t\t}\n\n\t\t// Uptil here, peers can be detached or not detached\n\t\tpeers, err := client.GetPeers()\n\t\tif err != nil {\n\t\t\trwolog.Error(err)\n\t\t}\n\n\t\t// Peer detach was not successful\n\t\tif len(peers) > 1 {\n\t\t\treturn fmt.Errorf(\"Not able to detach all peers\")\n\t\t}\n\n\t} else {\n\t\trwolog.Debug(\"purgeOldStateOfGluster: Some peers are connected. Not removing bricks.\")\n\t}\n\n\treturn nil\n}", "func (s *Schemer) hostGetDropTables(host *chop.ChiHost) ([]string, []string, error) {\n\t// There isn't a separate query for deleting views. To delete a view, use DROP TABLE\n\t// See https://clickhouse.yandex/docs/en/query_language/create/\n\tsql := heredoc.Doc(`\n\t\tSELECT\n\t\t\tdistinct name, \n\t\t\tconcat('DROP TABLE IF EXISTS \"', database, '\".\"', name, '\"') AS drop_db_query\n\t\tFROM system.tables\n\t\tWHERE engine like 'Replicated%'`,\n\t)\n\n\tnames, sqlStatements, _ := s.getObjectListFromClickHouse([]string{CreatePodFQDN(host)}, sql)\n\treturn names, sqlStatements, nil\n}", "func (o *PluginDnsClient) OnRemove(ctx *core.PluginCtx) {\n\tctx.UnregisterEvents(&o.PluginBase, dnsEvents)\n\tif o.IsNameServer() {\n\t\ttransportCtx := transport.GetTransportCtx(o.Client)\n\t\tif transportCtx != nil {\n\t\t\ttransportCtx.UnListen(\"udp\", \":53\", o)\n\t\t}\n\t} else {\n\t\tif o.cache != nil {\n\t\t\t_ = utils.NewDnsCacheRemover(o.cache, ctx.Tctx.GetTimerCtx())\n\t\t\to.cache = nil // GC can remove the client while the cache is removed.\n\t\t}\n\t}\n}", "func (p *F5Plugin) deletePoolIfEmpty(poolname string) error {\n\tpoolExists, err := p.F5Client.PoolExists(poolname)\n\tif err != nil {\n\t\tglog.V(4).Infof(\"F5Client.PoolExists failed: %v\", err)\n\t\treturn err\n\t}\n\n\tif poolExists {\n\t\tmembers, err := p.F5Client.GetPoolMembers(poolname)\n\t\tif err != nil {\n\t\t\tglog.V(4).Infof(\"F5Client.GetPoolMembers failed: %v\", err)\n\t\t\treturn err\n\t\t}\n\n\t\t// We only delete the pool if the pool is empty, which it may not be\n\t\t// if a service has been added and has not (yet) been deleted.\n\t\tif len(members) == 0 {\n\t\t\terr = p.F5Client.DeletePool(poolname)\n\t\t\tif err != nil {\n\t\t\t\tglog.V(4).Infof(\"Error deleting pool %s: %v\", poolname, err)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func filterOutBlockedDsInDirectDs() {\n\tfor k, _ := range blockedDs.domainSet {\n\t\tif directDs.domainSet[k] {\n\t\t\tdelete(directDs.domainSet, k)\n\t\t\tdirectDomainChanged = true\n\t\t}\n\t}\n\tfor k, _ := range alwaysBlockedDs {\n\t\tif alwaysDirectDs[k] {\n\t\t\terrl.Printf(\"%s in both always blocked and direct domain lists, taken as blocked.\\n\", k)\n\t\t\tdelete(alwaysDirectDs, k)\n\t\t}\n\t}\n}", "func (d *deprecatedTemplate) prune() {\n\tfor key, blocker := range d.Blockers {\n\t\tfor name, job := range blocker.Jobs {\n\t\t\tif !job.current {\n\t\t\t\tdelete(d.Blockers[key].Jobs, name)\n\t\t\t}\n\t\t}\n\t\tif len(blocker.Jobs) == 0 {\n\t\t\tdelete(d.Blockers, key)\n\t\t}\n\t}\n\tif len(d.Blockers) == 0 {\n\t\td.Blockers = nil\n\t}\n\n\tfor name, job := range d.UnknownBlocker.Jobs {\n\t\tif !job.current {\n\t\t\tdelete(d.UnknownBlocker.Jobs, name)\n\t\t}\n\t}\n}", "func DeleteVirtualNetworkSubnet() {}", "func DeleteVirtualNetworkSubnet() {}", "func (h *TunnelHandler) Clean() {\n\th.mu.Lock()\n\tremoved := make([]string, 0, len(h.tunnels))\n\tfor id, tunnel := range h.tunnels {\n\t\tselect {\n\t\tcase <-tunnel.chDone:\n\t\t\tremoved = append(removed, id)\n\t\tdefault:\n\t\t}\n\t}\n\th.mu.Unlock()\n\n\tfor _, id := range removed {\n\t\th.remove(id)\n\t}\n}", "func (r Dns_Domain_Registration) RemoveNameserversFromDomain(nameservers []string) (resp bool, err error) {\n\tparams := []interface{}{\n\t\tnameservers,\n\t}\n\terr = r.Session.DoRequest(\"SoftLayer_Dns_Domain_Registration\", \"removeNameserversFromDomain\", params, &r.Options, &resp)\n\treturn\n}", "func (o *ClusterUninstaller) destroyFloatingIPs() error {\n\tfound, err := o.listFloatingIPs()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\titems := o.insertPendingItems(floatingIPTypeName, found.list())\n\n\tfor _, item := range items {\n\t\tif _, ok := found[item.key]; !ok {\n\t\t\t// This item has finished deletion.\n\t\t\to.deletePendingItems(item.typeName, []cloudResource{item})\n\t\t\to.Logger.Infof(\"Deleted floating IP %q\", item.name)\n\t\t\tcontinue\n\t\t}\n\t\terr = o.deleteFloatingIP(item)\n\t\tif err != nil {\n\t\t\to.errorTracker.suppressWarning(item.key, err, o.Logger)\n\t\t}\n\t}\n\n\tif items = o.getPendingItems(floatingIPTypeName); len(items) > 0 {\n\t\treturn errors.Errorf(\"%d items pending\", len(items))\n\t}\n\treturn nil\n}", "func (p *Plugin) Cleanup(kubeclient kubernetes.Interface) {\n\tp.cleanedUp = true\n\tgracePeriod := int64(1)\n\tdeletionPolicy := metav1.DeletePropagationBackground\n\n\tlistOptions := p.listOptions()\n\tdeleteOptions := metav1.DeleteOptions{\n\t\tGracePeriodSeconds: &gracePeriod,\n\t\tPropagationPolicy: &deletionPolicy,\n\t}\n\n\t// Delete the DaemonSet created by this plugin\n\terr := kubeclient.ExtensionsV1beta1().DaemonSets(p.Namespace).DeleteCollection(\n\t\t&deleteOptions,\n\t\tlistOptions,\n\t)\n\tif err != nil {\n\t\terrlog.LogError(errors.Wrapf(err, \"could not delete DaemonSet %v for daemonset plugin %v\", p.daemonSetName(), p.GetName()))\n\t}\n\n\t// Delete the ConfigMap created by this plugin\n\terr = kubeclient.CoreV1().ConfigMaps(p.Namespace).DeleteCollection(\n\t\t&deleteOptions,\n\t\tlistOptions,\n\t)\n\tif err != nil {\n\t\terrlog.LogError(errors.Wrapf(err, \"could not delete ConfigMap %v for daemonset plugin %v\", p.configMapName(), p.GetName()))\n\t}\n}", "func (p *ProxySQL) Clear() error {\n\tmut.Lock()\n\tdefer mut.Unlock()\n\t_, err := exec(p, \"delete from mysql_servers\")\n\treturn err\n}", "func (d *deprecatedTemplate) prune() {\n\tfor key, blocker := range d.Blockers {\n\t\tfor name, job := range blocker.Jobs {\n\t\t\tif !job.current {\n\t\t\t\tdelete(d.Blockers[key].Jobs, name)\n\t\t\t}\n\t\t}\n\t\tif len(blocker.Jobs) == 0 {\n\t\t\tdelete(d.Blockers, key)\n\t\t}\n\t}\n\tif len(d.Blockers) == 0 {\n\t\td.Blockers = nil\n\t}\n\n\tif d.UnknownBlocker == nil {\n\t\treturn\n\t}\n\tfor name, job := range d.UnknownBlocker.Jobs {\n\t\tif !job.current {\n\t\t\tdelete(d.UnknownBlocker.Jobs, name)\n\t\t}\n\t}\n}", "func (h *InterfaceVppHandler) DumpDhcpClients() (map[uint32]*vppcalls.Dhcp, error) {\n\tdhcpData := make(map[uint32]*vppcalls.Dhcp)\n\treqCtx := h.callsChannel.SendMultiRequest(&dhcp.DHCPClientDump{})\n\n\tfor {\n\t\tdhcpDetails := &dhcp.DHCPClientDetails{}\n\t\tlast, err := reqCtx.ReceiveReply(dhcpDetails)\n\t\tif last {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclient := dhcpDetails.Client\n\t\tlease := dhcpDetails.Lease\n\n\t\tvar hostMac net.HardwareAddr = lease.HostMac\n\t\tvar hostAddr, routerAddr string\n\t\tif uintToBool(lease.IsIPv6) {\n\t\t\thostAddr = fmt.Sprintf(\"%s/%d\", net.IP(lease.HostAddress).To16().String(), uint32(lease.MaskWidth))\n\t\t\trouterAddr = fmt.Sprintf(\"%s/%d\", net.IP(lease.RouterAddress).To16().String(), uint32(lease.MaskWidth))\n\t\t} else {\n\t\t\thostAddr = fmt.Sprintf(\"%s/%d\", net.IP(lease.HostAddress[:4]).To4().String(), uint32(lease.MaskWidth))\n\t\t\trouterAddr = fmt.Sprintf(\"%s/%d\", net.IP(lease.RouterAddress[:4]).To4().String(), uint32(lease.MaskWidth))\n\t\t}\n\n\t\t// DHCP client data\n\t\tdhcpClient := &vppcalls.Client{\n\t\t\tSwIfIndex: client.SwIfIndex,\n\t\t\tHostname: string(bytes.SplitN(client.Hostname, []byte{0x00}, 2)[0]),\n\t\t\tID: string(bytes.SplitN(client.ID, []byte{0x00}, 2)[0]),\n\t\t\tWantDhcpEvent: uintToBool(client.WantDHCPEvent),\n\t\t\tSetBroadcastFlag: uintToBool(client.SetBroadcastFlag),\n\t\t\tPID: client.PID,\n\t\t}\n\n\t\t// DHCP lease data\n\t\tdhcpLease := &vppcalls.Lease{\n\t\t\tSwIfIndex: lease.SwIfIndex,\n\t\t\tState: lease.State,\n\t\t\tHostname: string(bytes.SplitN(lease.Hostname, []byte{0x00}, 2)[0]),\n\t\t\tIsIPv6: uintToBool(lease.IsIPv6),\n\t\t\tHostAddress: hostAddr,\n\t\t\tRouterAddress: routerAddr,\n\t\t\tHostMac: hostMac.String(),\n\t\t}\n\n\t\t// DHCP metadata\n\t\tdhcpData[client.SwIfIndex] = &vppcalls.Dhcp{\n\t\t\tClient: dhcpClient,\n\t\t\tLease: dhcpLease,\n\t\t}\n\t}\n\n\treturn dhcpData, nil\n}", "func filterOutDs(ds domainSet) {\n\tfor k, _ := range ds {\n\t\tif blockedDs.domainSet[k] {\n\t\t\tdelete(blockedDs.domainSet, k)\n\t\t\tblockedDomainChanged = true\n\t\t}\n\t\tif directDs.domainSet[k] {\n\t\t\tdelete(directDs.domainSet, k)\n\t\t\tdirectDomainChanged = true\n\t\t}\n\t}\n}", "func (j *Janitor) removeOrphanedData(ctx context.Context) {\n\toffset := 0\n\tfor {\n\t\tdumpIDs, err := j.lsifStore.DumpIDs(ctx, orphanBatchSize, offset)\n\t\tif err != nil {\n\t\t\tj.error(\"Failed to list dump identifiers\", \"error\", err)\n\t\t\treturn\n\t\t}\n\n\t\tstates, err := j.store.GetStates(ctx, dumpIDs)\n\t\tif err != nil {\n\t\t\tj.error(\"Failed to get states for dumps\", \"error\", err)\n\t\t\treturn\n\t\t}\n\n\t\tcount := 0\n\t\tfor _, dumpID := range dumpIDs {\n\t\t\tif _, ok := states[dumpID]; !ok {\n\t\t\t\tif err := j.lsifStore.Clear(ctx, dumpID); err != nil {\n\t\t\t\t\tj.error(\"Failed to remove data for dump\", \"dump_id\", dumpID, \"error\", err)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tcount++\n\t\t\t}\n\t\t}\n\n\t\tif count > 0 {\n\t\t\tlog15.Debug(\"Removed orphaned data rows from skunkworks orphan harvester\", \"count\", count)\n\t\t\tj.metrics.DataRowsRemoved.Add(float64(count))\n\t\t}\n\n\t\tif len(dumpIDs) < orphanBatchSize {\n\t\t\tbreak\n\t\t}\n\n\t\toffset += orphanBatchSize\n\t}\n}", "func deleteMulticastAllowPolicy(ovnNBClient goovn.Client, ns string, nsInfo *namespaceInfo) error {\n\tportGroupHash := hashedPortGroup(ns)\n\n\terr := deleteMulticastACLs(ns, portGroupHash, nsInfo)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_ = nsInfo.updateNamespacePortGroup(ovnNBClient, ns)\n\treturn nil\n}", "func (c *RpcClusterClient) clear(addrs []string) {\n\tc.Lock()\n\tvar rm []*poolWeightClient\n\tfor _, cli := range c.clients {\n\t\tvar has_cli bool\n\t\tfor _, addr := range addrs {\n\t\t\tif cli.endpoint == addr {\n\t\t\t\thas_cli = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif !has_cli {\n\t\t\trm = append(rm, cli)\n\t\t} else if cli.errcnt > 0 {\n\t\t\t/*\n\t\t\t\tif cli.weight >= errWeight*uint64(cli.errcnt) {\n\t\t\t\t\tcli.weight -= errWeight * uint64(cli.errcnt)\n\t\t\t\t\tcli.errcnt = 0\n\t\t\t\t\tif c.Len() >= minHeapSize {\n\t\t\t\t\t\t// cli will and only up, so it's ok here.\n\t\t\t\t\t\theap.Fix(c, cli.index)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t*/\n\t\t}\n\t}\n\n\tfor _, cli := range rm {\n\t\t// p will up, down, or not move, so append it to rm list.\n\t\tc.Debugf(\"remove cli: %s\", cli.endpoint)\n\n\t\theap.Remove(c, cli.index)\n\t\tcli.pool.Close()\n\t}\n\tc.Unlock()\n}", "func RouteIngrDeletePoolsByHostnameForEvh(routeIgrObj RouteIngressModel, namespace, objname, key string, fullsync bool, sharedQueue *utils.WorkerQueue) {\n\tok, hostMap := routeIgrObj.GetSvcLister().IngressMappings(namespace).GetRouteIngToHost(objname)\n\tif !ok {\n\t\tutils.AviLog.Warnf(\"key: %s, msg: nothing to delete for route: %s\", key, objname)\n\t\treturn\n\t}\n\n\tvar infraSettingName string\n\tif aviInfraSetting := routeIgrObj.GetAviInfraSetting(); aviInfraSetting != nil {\n\t\tinfraSettingName = aviInfraSetting.Name\n\t}\n\n\tutils.AviLog.Debugf(\"key: %s, msg: hosts to delete are :%s\", key, utils.Stringify(hostMap))\n\tfor host, hostData := range hostMap {\n\t\tshardVsName, _ := DeriveShardVSForEvh(host, key, routeIgrObj)\n\t\tdeleteVS := false\n\t\tif hostData.SecurePolicy == lib.PolicyPass {\n\t\t\tshardVsName.Name, _ = DerivePassthroughVS(host, key, routeIgrObj)\n\t\t}\n\n\t\tmodelName := lib.GetModelName(lib.GetTenant(), shardVsName.Name)\n\t\tfound, aviModel := objects.SharedAviGraphLister().Get(modelName)\n\t\tif !found || aviModel == nil {\n\t\t\tutils.AviLog.Warnf(\"key: %s, msg: model not found during delete: %s\", key, modelName)\n\t\t\tcontinue\n\t\t}\n\n\t\t// Delete the pool corresponding to this host\n\t\tif hostData.SecurePolicy == lib.PolicyEdgeTerm {\n\t\t\tdeleteVS = aviModel.(*AviObjectGraph).DeletePoolForHostnameForEvh(shardVsName.Name, host, routeIgrObj, hostData.PathSvc, key, infraSettingName, true, true, true, true)\n\t\t} else if hostData.SecurePolicy == lib.PolicyPass {\n\t\t\taviModel.(*AviObjectGraph).DeleteObjectsForPassthroughHost(shardVsName.Name, host, routeIgrObj, hostData.PathSvc, infraSettingName, key, true, true, true)\n\t\t}\n\t\tif hostData.InsecurePolicy == lib.PolicyAllow {\n\t\t\tdeleteVS = aviModel.(*AviObjectGraph).DeletePoolForHostnameForEvh(shardVsName.Name, host, routeIgrObj, hostData.PathSvc, key, infraSettingName, true, true, true, false)\n\t\t}\n\t\tif !deleteVS {\n\t\t\tok := saveAviModel(modelName, aviModel.(*AviObjectGraph), key)\n\t\t\tif ok && len(aviModel.(*AviObjectGraph).GetOrderedNodes()) != 0 && !fullsync {\n\t\t\t\tPublishKeyToRestLayer(modelName, key, sharedQueue)\n\t\t\t}\n\t\t} else {\n\t\t\tutils.AviLog.Debugf(\"Setting up model name :[%v] to nil\", modelName)\n\t\t\tobjects.SharedAviGraphLister().Save(modelName, nil)\n\t\t\tPublishKeyToRestLayer(modelName, key, sharedQueue)\n\t\t}\n\t}\n\t// Now remove the secret relationship\n\trouteIgrObj.GetSvcLister().IngressMappings(namespace).RemoveIngressSecretMappings(objname)\n\tutils.AviLog.Infof(\"key: %s, removed ingress mapping for: %s\", key, objname)\n\n\t// Remove the hosts mapping for this ingress\n\trouteIgrObj.GetSvcLister().IngressMappings(namespace).DeleteIngToHostMapping(objname)\n\n\t// remove hostpath mappings\n\tupdateHostPathCache(namespace, objname, hostMap, nil)\n}", "func (this *ExDomain) removesIvDomain(ivdom *IvDomain,\n\tmodifyingOtherDomain bool) {\n\tif modifyingOtherDomain {\n\t\tdels := make([]int, 0)\n\t\tfor _, part := range ivdom.GetParts() {\n\t\t\tfor v := part.From; v <= part.To; v++ {\n\t\t\t\tif this.Contains(v) {\n\t\t\t\t\tthis.Remove(v)\n\t\t\t\t} else {\n\t\t\t\t\tdels = append(dels, v)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif len(dels) != 0 {\n\t\t\tivdom.Removes(CreateIvDomainFromIntArr(dels))\n\t\t}\n\t} else {\n\t\tfor _, part := range ivdom.GetParts() {\n\t\t\tfor v := part.From; v <= part.To; v++ {\n\t\t\t\tthis.Remove(v)\n\t\t\t}\n\t\t}\n\t}\n}", "func (q *gcpQuery) deleteNameServers(gcpClient gcpclient.Client, managedZone string, domain string, values sets.String) error {\n\treturn gcpClient.DeleteResourceRecordSet(managedZone, q.resourceRecordSet(domain, values))\n}" ]
[ "0.6231171", "0.5975118", "0.592964", "0.5638924", "0.5413972", "0.51644886", "0.5150004", "0.5145574", "0.51422113", "0.50841993", "0.5060565", "0.5032385", "0.50233114", "0.50209886", "0.5001533", "0.49985364", "0.49904168", "0.4957759", "0.49550113", "0.49398196", "0.4936964", "0.4928295", "0.4917889", "0.49097753", "0.48729655", "0.48728853", "0.48693764", "0.48662356", "0.48557687", "0.48502415", "0.4847909", "0.48439294", "0.48409843", "0.48360962", "0.48341566", "0.48242816", "0.48150998", "0.47838515", "0.4769143", "0.47471902", "0.47471353", "0.47437918", "0.47182995", "0.47095296", "0.4708826", "0.47072875", "0.47021317", "0.4690318", "0.4687757", "0.4686866", "0.4677887", "0.46776098", "0.46712223", "0.4669997", "0.46680278", "0.46640438", "0.46635774", "0.46625152", "0.46383265", "0.46348673", "0.46341085", "0.46265993", "0.46232274", "0.46141085", "0.4612332", "0.4609329", "0.46080285", "0.45973563", "0.4592265", "0.45915735", "0.45893255", "0.45880947", "0.4587978", "0.4585361", "0.4583789", "0.45820442", "0.45818594", "0.4565169", "0.45635784", "0.45606855", "0.45525324", "0.45451918", "0.45421633", "0.4539433", "0.45343068", "0.45343068", "0.45299402", "0.452823", "0.45217946", "0.45208725", "0.45201626", "0.45157576", "0.45140916", "0.45120937", "0.45108867", "0.45057127", "0.45013985", "0.4490932", "0.44887152", "0.44798288" ]
0.80990946
0
addHostOnlyDHCPServer adds a DHCP server to a hostonly network.
func addHostOnlyDHCPServer(ifname string, d dhcpServer, vbox VBoxManager) error { name := dhcpPrefix + ifname dhcps, err := listDHCPServers(vbox) if err != nil { return err } // On some platforms (OSX), creating a host-only adapter adds a default dhcpserver, // while on others (Windows?) it does not. command := "add" if dhcp, ok := dhcps[name]; ok { command = "modify" if (dhcp.IPv4.IP.Equal(d.IPv4.IP)) && (dhcp.IPv4.Mask.String() == d.IPv4.Mask.String()) && (dhcp.LowerIP.Equal(d.LowerIP)) && (dhcp.UpperIP.Equal(d.UpperIP)) && dhcp.Enabled { // dhcp is up to date return nil } } args := []string{"dhcpserver", command, "--netname", name, "--ip", d.IPv4.IP.String(), "--netmask", net.IP(d.IPv4.Mask).String(), "--lowerip", d.LowerIP.String(), "--upperip", d.UpperIP.String(), } if d.Enabled { args = append(args, "--enable") } else { args = append(args, "--disable") } return vbox.vbm(args...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func WithDHCPServer(subnet *net.IPNet) Option {\n\treturn func(d *dnsmasq) {\n\t\td.subnet = subnet\n\t}\n}", "func (p *PerHost) AddHost(host string) {\n\tif strings.HasSuffix(host, \".\") {\n\t\thost = host[:len(host)-1]\n\t}\n\tp.bypassHosts = append(p.bypassHosts, host)\n}", "func (lv *Libvirt) AddTransientDHCPHost(newHost *libvirtxml.NetworkDHCPHost, app *App) error {\n\tlv.dhcpLeases.mutex.Lock()\n\tdefer lv.dhcpLeases.mutex.Unlock()\n\n\tlv.dhcpLeases.leases[newHost] = true\n\treturn lv.rebuildDHCPStaticLeases(app)\n}", "func getHostOnlyNetworkInterface(mc *driver.MachineConfig) (string, error) {\n\t// Check if the interface/dhcp exists.\n\tnets, err := HostonlyNets()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdhcps, err := DHCPs()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor _, n := range nets {\n\t\tif dhcp, ok := dhcps[n.NetworkName]; ok {\n\t\t\tif dhcp.IPv4.IP.Equal(mc.DHCPIP) &&\n\t\t\t\tdhcp.IPv4.Mask.String() == mc.NetMask.String() &&\n\t\t\t\tdhcp.LowerIP.Equal(mc.LowerIP) &&\n\t\t\t\tdhcp.UpperIP.Equal(mc.UpperIP) &&\n\t\t\t\tdhcp.Enabled == mc.DHCPEnabled {\n\t\t\t\treturn n.Name, nil\n\t\t\t}\n\t\t}\n\t}\n\n\t// No existing host-only interface found. Create a new one.\n\thostonlyNet, err := CreateHostonlyNet()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\thostonlyNet.IPv4.IP = mc.HostIP\n\thostonlyNet.IPv4.Mask = mc.NetMask\n\tif err := hostonlyNet.Config(); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Create and add a DHCP server to the host-only network\n\tdhcp := driver.DHCP{}\n\tdhcp.IPv4.IP = mc.DHCPIP\n\tdhcp.IPv4.Mask = mc.NetMask\n\tdhcp.LowerIP = mc.LowerIP\n\tdhcp.UpperIP = mc.UpperIP\n\tdhcp.Enabled = true\n\tif err := AddHostonlyDHCP(hostonlyNet.Name, dhcp); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn hostonlyNet.Name, nil\n}", "func (v *Virter) addDHCPEntry(mac string, id uint) (net.IP, error) {\n\tnetwork, err := v.libvirt.NetworkLookupByName(v.networkName)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not get network: %w\", err)\n\t}\n\n\tipNet, err := v.getIPNet(network)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnetworkBaseIP := ipNet.IP.Mask(ipNet.Mask)\n\tip := addToIP(networkBaseIP, id)\n\n\tif !ipNet.Contains(ip) {\n\t\treturn nil, fmt.Errorf(\"computed IP %v is not in network\", ip)\n\t}\n\n\tlog.Printf(\"Add DHCP entry from %v to %v\", mac, ip)\n\terr = v.libvirt.NetworkUpdate(\n\t\tnetwork,\n\t\t// the following 2 arguments are swapped; see\n\t\t// https://github.com/digitalocean/go-libvirt/issues/87\n\t\tuint32(libvirt.NetworkSectionIPDhcpHost),\n\t\tuint32(libvirt.NetworkUpdateCommandAddLast),\n\t\t-1,\n\t\tfmt.Sprintf(\"<host mac='%s' ip='%v'/>\", mac, ip),\n\t\tlibvirt.NetworkUpdateAffectLive|libvirt.NetworkUpdateAffectConfig)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not add DHCP entry: %w\", err)\n\t}\n\n\treturn ip, nil\n}", "func addBlockedHost(host string) bool {\n\tdm := host2Domain(host)\n\tif isHostAlwaysDirect(host) || hostIsIP(host) || dm == \"localhost\" {\n\t\treturn false\n\t}\n\tif chouDs[dm] {\n\t\t// Record blocked time for chou domain, this marks a chou domain as\n\t\t// temporarily blocked\n\t\tnow := time.Now()\n\t\tchou.Lock()\n\t\tchou.time[dm] = now\n\t\tchou.Unlock()\n\t\tdebug.Printf(\"chou domain %s blocked at %v\\n\", dm, now)\n\t} else if !blockedDs.has(dm) {\n\t\tblockedDs.add(dm)\n\t\tblockedDomainChanged = true\n\t\tdebug.Printf(\"%s added to blocked list\\n\", dm)\n\t\t// Delete this domain from direct domain set\n\t\tdelDirectDomain(dm)\n\t}\n\treturn true\n}", "func (servers *Servers) AddServer(macAddressStr string) error {\n\tvar macAddress net.HardwareAddr\n\tmacAddress, err := net.ParseMAC(macAddressStr)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = servers.GetServer(macAddress.String())\n\tserver := Server{\n\t\tMacAddress: macAddress, IPAddress: \"change me\", Installed: false, Kernel: \"linux\", SecondMacAddress: \"find me\"}\n\tif err == nil {\n\t\tlog.Warnln(\"The server already exist in the list. Overwrite it.\")\n\t} else {\n\t\tswitch err.(type) {\n\t\tcase *EmptyServerListError:\n\t\t\tlog.Infoln(err)\n\t\t\tbreak\n\t\tcase *UnreconizeServerError:\n\t\t\tbreak\n\t\tcase *NilServerListError:\n\n\t\t\t// A map should not be nil\n\t\t\t// Refence : https://blog.golang.org/go-maps-in-action\n\t\t\treturn err\n\n\t\tdefault:\n\t\t\treturn err\n\t\t}\n\t}\n\n\t(*servers)[macAddress.String()] = &server\n\n\treturn nil\n}", "func WithDHCPNameServers(dns []string) Option {\n\treturn func(d *dnsmasq) {\n\t\td.dns = dns\n\t}\n}", "func (data *DNSData) AddServer(server compute.Server) {\n\tdata.AddNetworkAdapter(server.Name, server.Network.PrimaryAdapter)\n\n\tfor _, additionalNetworkAdapter := range server.Network.AdditionalNetworkAdapters {\n\t\tdata.AddNetworkAdapter(server.Name, additionalNetworkAdapter)\n\t}\n}", "func (h *HostHandler) AddHost(host string) *http.ServeMux {\n\tmux := http.NewServeMux()\n\th.eligibleHosts[host] = mux\n\treturn mux\n}", "func AddHCNHostEndpoint(ctx context.Context, i *Endpoint, netns, networkID string, decorates ...HCNEndpointDecorator) error {\n\tif netns == \"\" || networkID == \"\" ||\n\t\t!i.isValid() {\n\t\treturn errors.Errorf(\"invalid HostComputeEndpoint configuration\")\n\t}\n\n\tvar attach = func(ep *hcn.HostComputeEndpoint, isNewlyCreatedEndpoint bool) error {\n\t\t// attach gateway endpoint to host\n\t\tvar condErr error\n\t\tvar err = wait.PollImmediateUntil(100*time.Millisecond, func() (bool, error) {\n\t\t\tcondErr = ep.NamespaceAttach(netns)\n\t\t\tif condErr == nil ||\n\t\t\t\thcn.CheckErrorWithCode(condErr, 0x803B0014) { // if already attached\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t\treturn false, nil\n\t\t}, ctx.Done())\n\t\tif err != nil {\n\t\t\tif condErr == nil {\n\t\t\t\tcondErr = err\n\t\t\t}\n\t\t\treturn errors.Wrapf(condErr, \"failed to attach gateway HostComputeEndpoint %s\", ep.Name)\n\t\t}\n\t\treturn nil\n\t}\n\n\treturn addHCNEndpoint(ctx, i, netns, networkID, attach, decorates...)\n}", "func (s *Switch) Add_host( host *string, vmid *string, port int ) {\n\tif s == nil {\n\t\treturn\n\t}\n\n\ts.hosts[*host] = true\n\ts.hport[*host] = port\n\ts.hvmid[*host] = vmid\n}", "func (s *Server) ServeDHCP(p dhcp4.Packet, msgType dhcp4.MessageType, options dhcp4.Options) dhcp4.Packet {\n\ts.printLeases()\n\n\tswitch msgType {\n\tcase dhcp4.Discover: // Broadcast Packet From Client - Can I have an IP?\n\t\treturn s.handleDiscover(p, options)\n\n\tcase dhcp4.Request: // Broadcast From Client - I'll take that IP (Also start for renewals)\n\t\t// start/renew a lease -- update lease time\n\t\t// some clients (OSX) just go right ahead and do Request first from previously known IP, if they get NAK, they restart full cycle with Discover then Request\n\t\treturn s.handleDHCP4Request(p, options)\n\n\tcase dhcp4.Decline: // Broadcast From Client - Sorry I can't use that IP\n\t\treturn s.handleDecline(p, options)\n\n\tcase dhcp4.Release: // From Client, I don't need that IP anymore\n\t\treturn s.handleRelease(p, options)\n\n\tcase dhcp4.Inform: // From Client, I have this IP and there's nothing you can do about it\n\t\treturn s.handleInform(p, options)\n\n\t// from server -- ignore those but enumerate just in case\n\tcase dhcp4.Offer: // Broadcast From Server - Here's an IP\n\t\tlog.Printf(\"DHCP: received message from %s: Offer\", p.CHAddr())\n\n\tcase dhcp4.ACK: // From Server, Yes you can have that IP\n\t\tlog.Printf(\"DHCP: received message from %s: ACK\", p.CHAddr())\n\n\tcase dhcp4.NAK: // From Server, No you cannot have that IP\n\t\tlog.Printf(\"DHCP: received message from %s: NAK\", p.CHAddr())\n\n\tdefault:\n\t\tlog.Printf(\"DHCP: unknown packet %v from %s\", msgType, p.CHAddr())\n\t\treturn nil\n\t}\n\treturn nil\n}", "func createHostonlyAdapter(vbox VBoxManager) (*hostOnlyNetwork, error) {\n\tout, err := vbox.vbmOut(\"hostonlyif\", \"create\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tres := reHostOnlyAdapterCreated.FindStringSubmatch(string(out))\n\tif res == nil {\n\t\treturn nil, errors.New(\"Failed to create host-only adapter\")\n\t}\n\n\treturn &hostOnlyNetwork{Name: res[1]}, nil\n}", "func AddHost(name, addr string) (*Host, error) {\n\t// Create a network namespace\n\th, err := NewHost(name)\n\tif err != nil {\n\t\tlog.Fatal(\"failed to NewHost: \", err)\n\t}\n\t// setup a veth pair\n\t_, err = h.setupVeth(\"eth2\", 1500)\n\tif err != nil {\n\t\tlog.Fatal(\"failed to open netns: \", err)\n\t}\n\t// setup a IP for host\n\th.setIfaceIP(addr)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to setIfaceIP for %s: %v\", h.Name, err)\n\t\treturn nil, err\n\t}\n\treturn h, nil\n}", "func WithDHCPWPAD(wpad string) Option {\n\treturn func(d *dnsmasq) {\n\t\td.wpad = wpad\n\t}\n}", "func (o *VirtualizationVmwareVirtualMachineAllOf) SetDhcpEnabled(v bool) {\n\to.DhcpEnabled = &v\n}", "func parseDhcp(packet gopacket.Packet) {\n\t// DHCP v4\n\tdhcpLayer := packet.Layer(layers.LayerTypeDHCPv4)\n\tif dhcpLayer != nil {\n\t\tdhcp, _ := dhcpLayer.(*layers.DHCPv4)\n\t\tlinkSrc, _ := getMacs(packet)\n\n\t\t// add device\n\t\tdev := devices.Add(linkSrc)\n\t\tif dhcp.Operation == layers.DHCPOpRequest {\n\t\t\tdebug(\"DHCP Request\")\n\t\t\treturn\n\t\t}\n\t\tif dhcp.Operation == layers.DHCPOpReply {\n\t\t\tdebug(\"DHCP Reply\")\n\t\t\t// mark this device as dhcp server\n\t\t\tdev.DHCP.Enable()\n\t\t\tdev.DHCP.SetTimestamp(packet.Metadata().Timestamp)\n\t\t}\n\t}\n\n\t// DHCP v6\n\tdhcpv6Layer := packet.Layer(layers.LayerTypeDHCPv6)\n\tif dhcpv6Layer != nil {\n\t\tdhcp, _ := dhcpv6Layer.(*layers.DHCPv6)\n\t\tlinkSrc, _ := getMacs(packet)\n\t\tnetSrc, _ := getIps(packet)\n\t\tdev := devices.Add(linkSrc)\n\t\tdev.UCasts.Add(netSrc)\n\t\ttimestamp := packet.Metadata().Timestamp\n\n\t\t// parse message type to determine if server or client\n\t\tswitch dhcp.MsgType {\n\t\tcase layers.DHCPv6MsgTypeSolicit:\n\t\t\tdebug(\"DHCPv6 Solicit\")\n\t\tcase layers.DHCPv6MsgTypeAdvertise:\n\t\t\tdebug(\"DHCPv6 Advertise\")\n\t\tcase layers.DHCPv6MsgTypeRequest:\n\t\t\tdebug(\"DHCPv6 Request\")\n\t\t\t// server\n\t\t\tdev.DHCP.Enable()\n\t\t\tdev.DHCP.SetTimestamp(timestamp)\n\t\tcase layers.DHCPv6MsgTypeConfirm:\n\t\t\tdebug(\"DHCPv6 Confirm\")\n\t\tcase layers.DHCPv6MsgTypeRenew:\n\t\t\tdebug(\"DHCPv6 Renew\")\n\t\tcase layers.DHCPv6MsgTypeRebind:\n\t\t\tdebug(\"DHCPv6 Rebind\")\n\t\tcase layers.DHCPv6MsgTypeReply:\n\t\t\tdebug(\"DHCPv6 Reply\")\n\t\t\t// server\n\t\t\tdev.DHCP.Enable()\n\t\t\tdev.DHCP.SetTimestamp(timestamp)\n\t\tcase layers.DHCPv6MsgTypeRelease:\n\t\t\tdebug(\"DHCPv6 Release\")\n\t\tcase layers.DHCPv6MsgTypeDecline:\n\t\t\tdebug(\"DHCPv6 Decline\")\n\t\tcase layers.DHCPv6MsgTypeReconfigure:\n\t\t\tdebug(\"DHCPv6 Reconfigure\")\n\t\t\t// server\n\t\t\tdev.DHCP.Enable()\n\t\t\tdev.DHCP.SetTimestamp(timestamp)\n\t\tcase layers.DHCPv6MsgTypeInformationRequest:\n\t\t\tdebug(\"DHCPv6 Information Request\")\n\t\tcase layers.DHCPv6MsgTypeRelayForward:\n\t\t\tdebug(\"DHCPv6 Relay Forward\")\n\t\tcase layers.DHCPv6MsgTypeRelayReply:\n\t\t\tdebug(\"DHCPv6 Relay Reply\")\n\t\t\t// server\n\t\t\tdev.DHCP.Enable()\n\t\t\tdev.DHCP.SetTimestamp(timestamp)\n\t\t}\n\t}\n}", "func (p *ProxySQL) AddHost(opts ...HostOpts) error {\n\tmut.Lock()\n\tdefer mut.Unlock()\n\thostq, err := buildAndParseHostQueryWithHostname(opts...)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// build a query with these options\n\t_, err = exec(p, buildInsertQuery(hostq))\n\treturn err\n}", "func (i *DHCPInterface) ServeDHCP(p dhcp.Packet, msgType dhcp.MessageType, options dhcp.Options) dhcp.Packet {\n\tvar respMsg dhcp.MessageType\n\n\tswitch msgType {\n\tcase dhcp.Discover:\n\t\trespMsg = dhcp.Offer\n\tcase dhcp.Request:\n\t\trespMsg = dhcp.ACK\n\t}\n\n\tif respMsg != 0 {\n\t\trequestingMAC := p.CHAddr().String()\n\n\t\tif requestingMAC == i.MACFilter {\n\t\t\topts := dhcp.Options{\n\t\t\t\tdhcp.OptionSubnetMask: []byte(i.VMIPNet.Mask),\n\t\t\t\tdhcp.OptionRouter: []byte(*i.GatewayIP),\n\t\t\t\tdhcp.OptionDomainNameServer: i.dnsServers,\n\t\t\t\tdhcp.OptionHostName: []byte(i.Hostname),\n\t\t\t}\n\n\t\t\tif netRoutes := formClasslessRoutes(&i.Routes); netRoutes != nil {\n\t\t\t\topts[dhcp.OptionClasslessRouteFormat] = netRoutes\n\t\t\t}\n\n\t\t\tif i.ntpServers != nil {\n\t\t\t\topts[dhcp.OptionNetworkTimeProtocolServers] = i.ntpServers\n\t\t\t}\n\n\t\t\toptSlice := opts.SelectOrderOrAll(options[dhcp.OptionParameterRequestList])\n\n\t\t\treturn dhcp.ReplyPacket(p, respMsg, *i.GatewayIP, i.VMIPNet.IP, leaseDuration, optSlice)\n\t\t}\n\t}\n\n\treturn nil\n}", "func HasDHCP(net libvirtxml.Network) bool {\n\tif net.Forward != nil {\n\t\tif net.Forward.Mode == \"nat\" || net.Forward.Mode == \"route\" || net.Forward.Mode == \"\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (f *HostFilter) AddHost(host string, port int, ptype ProxyType) {\n\tf.mu.Lock()\n\tdefer f.mu.Unlock()\n\the, ok := f.hosts[host]\n\tf.hosts[host] = HostEntry{\n\t\tType: ptype,\n\t\tPort: port,\n\t}\n\tif !ok {\n\t\ttslog.Green(\"+ Add Rule [%s] %s\", ptype, host)\n\t} else {\n\t\tif he.Type != ptype {\n\t\t\ttslog.Green(\"* Change Rule [%s -> %s] %s\", he.Type, ptype, host)\n\t\t}\n\t}\n}", "func HostOnly(addr string) string {\n\thost, _, err := net.SplitHostPort(addr)\n\tif err != nil {\n\t\treturn addr\n\t} else {\n\t\treturn host\n\t}\n}", "func (px *PXE) StartDHCP(iface string, ip net.IP) {\n\n\tvar netmask net.IP\n\tif px.selfNet.IsUnspecified() {\n\t\tnetmask = net.ParseIP(\"255.255.255.0\").To4()\n\t} else {\n\t\tnetmask = px.selfNet.To4()\n\t}\n\n\t// FIXME: hardcoded value\n\tpx.leaseTime = time.Minute * 5\n\tleaseTime := make([]byte, 4)\n\tbinary.BigEndian.PutUint32(leaseTime, uint32(px.leaseTime.Seconds()))\n\n\tpx.options = layers.DHCPOptions{\n\t\tlayers.DHCPOption{Type: layers.DHCPOptLeaseTime, Length: 4, Data: leaseTime},\n\t\tlayers.DHCPOption{Type: layers.DHCPOptSubnetMask, Length: 4, Data: netmask.To4()},\n\t\tlayers.DHCPOption{Type: layers.DHCPOptRouter, Length: 4, Data: px.selfIP.To4()},\n\t}\n\n\tvar e error\n\n\t// Find our interface\n\tpx.iface, e = net.InterfaceByName(iface)\n\tif e != nil {\n\t\tpx.api.Logf(types.LLCRITICAL, \"%v: %s\", e, iface)\n\t\treturn\n\t}\n\n\t// We need the raw handle to send unicast packet replies\n\t// This is only used for sending initial DHCP offers\n\t// Note: 0x0800 is EtherType for ipv4. See: https://en.wikipedia.org/wiki/EtherType\n\tpx.rawHandle, e = raw.ListenPacket(px.iface, 0x0800, nil)\n\tif e != nil {\n\t\tpx.api.Logf(types.LLCRITICAL, \"%v: %s\", e, iface)\n\t\treturn\n\t}\n\tdefer px.rawHandle.Close()\n\n\t// We use this packetconn to read from\n\tnc, e := net.ListenPacket(\"udp4\", \":67\")\n\tif e != nil {\n\t\tpx.api.Logf(types.LLCRITICAL, \"%v\", e)\n\t\treturn\n\t}\n\tc := ipv4.NewPacketConn(nc)\n\tdefer c.Close()\n\tpx.api.Logf(types.LLINFO, \"started DHCP listener on: %s\", iface)\n\n\t// main read loop\n\tfor {\n\t\tbuffer := make([]byte, DHCPPacketBuffer)\n\t\tvar req layers.DHCPv4\n\t\tparser := gopacket.NewDecodingLayerParser(layers.LayerTypeDHCPv4, &req)\n\t\tdecoded := []gopacket.LayerType{}\n\n\t\tn, _, addr, e := c.ReadFrom(buffer)\n\t\tif e != nil {\n\t\t\tpx.api.Logf(types.LLCRITICAL, \"%v\", e)\n\t\t\tbreak\n\t\t}\n\t\tpx.api.Logf(types.LLDDEBUG, \"got a dhcp packet from: %s\", addr.String())\n\t\tif n < 240 {\n\t\t\tpx.api.Logf(types.LLDDEBUG, \"packet is too short: %d < 240\", n)\n\t\t\tcontinue\n\t\t}\n\n\t\tif e = parser.DecodeLayers(buffer[:n], &decoded); e != nil {\n\t\t\tpx.api.Logf(types.LLERROR, \"error decoding packet: %v\", e)\n\t\t\tcontinue\n\t\t}\n\t\tif len(decoded) < 1 || decoded[0] != layers.LayerTypeDHCPv4 {\n\t\t\tpx.api.Logf(types.LLERROR, \"decoded non-DHCP packet\")\n\t\t\tcontinue\n\t\t}\n\t\t// at this point we have a parsed DHCPv4 packet\n\n\t\tif req.Operation != layers.DHCPOpRequest {\n\t\t\t// odd...\n\t\t\tcontinue\n\t\t}\n\t\tif req.HardwareLen > 16 {\n\t\t\tpx.api.Logf(types.LLDDEBUG, \"packet HardwareLen too long: %d > 16\", req.HardwareLen)\n\t\t\tcontinue\n\t\t}\n\n\t\tgo px.handleDHCPRequest(req)\n\t}\n\tpx.api.Log(types.LLNOTICE, \"DHCP stopped.\")\n}", "func (p *RangePlugin) ServeDHCP(ctx context.Context, req, res *dhcpv4.DHCPv4) error {\n\tdb := lease.GetDatabase(ctx)\n\tcli := lease.Client{HwAddr: req.ClientHWAddr}\n\n\tif dhcpserver.Discover(req) {\n\t\tip := p.findUnboundAddr(ctx, req.ClientHWAddr, req.RequestedIPAddress(), db)\n\t\tif ip != nil {\n\t\t\tp.L.Debugf(\"found unbound address for %s: %s\", req.ClientHWAddr, ip)\n\t\t\tres.YourIPAddr = ip\n\t\t\treturn nil\n\t\t}\n\t\tp.L.Debugf(\"failed to find address for %s\", req.ClientHWAddr)\n\t\t// we failed to find an IP address for that client\n\t\t// so fallthrough and call the next middleware\n\t} else\n\n\t// for DHCPREQUEST we try to actually lease the IP address\n\t// and send a DHCPACK if we succeeded. In any error case\n\t// we will NOT send a NAK as a middleware below us\n\t// may succeed in leasing the address\n\t// TODO(ppacher): we could check if the RequestedIPAddress() is inside\n\t// the IP ranges and then decide to ACK or NAK\n\tif dhcpserver.Request(req) {\n\t\tstate := \"binding\"\n\t\tip := req.RequestedIPAddress()\n\t\tif ip == nil || ip.IsUnspecified() {\n\t\t\tip = req.ClientIPAddr\n\t\t\tstate = \"renewing\"\n\t\t}\n\n\t\tif ip != nil && !ip.IsUnspecified() {\n\t\t\tp.L.Debugf(\"%s (%s) requests %s\", req.ClientHWAddr, state, ip)\n\n\t\t\t// use the leaseTime already set to the response packet\n\t\t\t// else we fallback to time.Hour\n\t\t\t// TODO(ppacher): we should make the default lease time configurable\n\t\t\t// for the ranges plguin\n\t\t\tleaseTime := res.IPAddressLeaseTime(time.Hour)\n\n\t\t\tleaseTime, err := db.Lease(ctx, ip, cli, leaseTime, state == \"renewing\")\n\t\t\tif err == nil {\n\t\t\t\tp.L.Infof(\"%s (%s): lease %s for %s\", req.ClientHWAddr, state, ip, leaseTime)\n\t\t\t\tif leaseTime == time.Hour {\n\t\t\t\t\t// if we use the default, make sure to set it\n\t\t\t\t\tres.UpdateOption(dhcpv4.OptIPAddressLeaseTime(leaseTime))\n\t\t\t\t}\n\n\t\t\t\t// make sure we ACK the DHCPREQUEST\n\t\t\t\tres.YourIPAddr = ip\n\n\t\t\t\tif res.SubnetMask() == nil || res.SubnetMask().String() == \"0.0.0.0\" {\n\t\t\t\t\tres.UpdateOption(dhcpv4.OptSubnetMask(p.Network.Mask))\n\t\t\t\t}\n\n\t\t\t\tres.UpdateOption(dhcpv4.OptMessageType(dhcpv4.MessageTypeAck))\n\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tp.L.Errorf(\"%s: failed to lease requested ip %s: %s\", req.ClientHWAddr, ip, err.Error())\n\t\t}\n\t} else\n\n\t// If it's a DHCPRELEASE message and part of our range we'll release it\n\tif dhcpserver.Release(req) && p.Ranges.Contains(req.ClientIPAddr) {\n\t\tif err := db.Release(ctx, req.ClientIPAddr); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// No response should be sent for DHCPRELEASE messages\n\t\treturn dhcpserver.ErrNoResponse\n\t}\n\n\treturn p.Next.ServeDHCP(ctx, req, res)\n}", "func (m *NetManager) serverAdd(key string, con cm.Connection) error {\n\n\tm.keyMarker[key] = key_marker_server\n\treturn m.serverConsManager.Add(key, con)\n}", "func (h *Hosts) AddHost(host ...Host) {\n\th.mux.Lock()\n\tdefer h.mux.Unlock()\n\n\th.hosts = append(h.hosts, host...)\n}", "func SetServerHost(s string) func(*Server) error {\n\treturn func(c *Server) error {\n\t\tc.host = s\n\t\treturn nil\n\t}\n}", "func (client *Client) AddHpHost(request *AddHpHostRequest) (response *AddHpHostResponse, err error) {\n\tresponse = CreateAddHpHostResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func listDHCPServers(vbox VBoxManager) (map[string]*dhcpServer, error) {\n\tout, err := vbox.vbmOut(\"list\", \"dhcpservers\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tm := map[string]*dhcpServer{}\n\tdhcp := &dhcpServer{}\n\n\terr = parseKeyValues(out, reColonLine, func(key, val string) error {\n\t\tswitch key {\n\t\tcase \"NetworkName\":\n\t\t\tdhcp = &dhcpServer{}\n\t\t\tm[val] = dhcp\n\t\t\tdhcp.NetworkName = val\n\t\tcase \"IP\":\n\t\t\tdhcp.IPv4.IP = net.ParseIP(val)\n\t\tcase \"upperIPAddress\":\n\t\t\tdhcp.UpperIP = net.ParseIP(val)\n\t\tcase \"lowerIPAddress\":\n\t\t\tdhcp.LowerIP = net.ParseIP(val)\n\t\tcase \"NetworkMask\":\n\t\t\tdhcp.IPv4.Mask = parseIPv4Mask(val)\n\t\tcase \"Enabled\":\n\t\t\tdhcp.Enabled = (val == \"Yes\")\n\t\t}\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn m, nil\n}", "func (client *Client) AddHDMInstance(request *AddHDMInstanceRequest) (response *AddHDMInstanceResponse, err error) {\n\tresponse = CreateAddHDMInstanceResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func (o *VirtualizationVmwareVirtualMachineAllOf) HasDhcpEnabled() bool {\n\tif o != nil && o.DhcpEnabled != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (h *hostfile) AddHost(ip, hostname string) error {\n\th.hosts.Reload()\n\th.hosts.AddHost(ip, hostname)\n\terr := h.hosts.Save()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func addDoH(ipStr, base string) {\n\tip := netip.MustParseAddr(ipStr)\n\tdohOfIP[ip] = base\n\tdohIPsOfBase[base] = append(dohIPsOfBase[base], ip)\n}", "func (p *PerHost) AddZone(zone string) {\n\tif strings.HasSuffix(zone, \".\") {\n\t\tzone = zone[:len(zone)-1]\n\t}\n\tif !strings.HasPrefix(zone, \".\") {\n\t\tzone = \".\" + zone\n\t}\n\tp.bypassZones = append(p.bypassZones, zone)\n}", "func NewHostHandler() *HostHandler {\n\th := &HostHandler{\n\t\teligibleHosts: make(map[string]*http.ServeMux),\n\t}\n\n\treturn h\n}", "func (c *Config) AddServer(name string, host string, port int) (string, *Server) {\n\tserver := &Server{\n\t\tName: name,\n\t\tHost: host,\n\t\tPort: port,\n\t}\n\tserverAmount := len(*c.Servers) + 1\n\tlog.Printf(\"Add server, server amount: %d\", serverAmount)\n\tkey := fmt.Sprintf(\"%s%d\", \"server\", serverAmount)\n\t(*c.Servers)[key] = server\n\treturn key, server\n}", "func addDomainsWithHost(domains map[string]*lazyloadv1alpha1.Destinations, sf *lazyloadv1alpha1.ServiceFence, nsSvcCache *NsSvcCache,\n\trules []*domainAliasRule,\n) {\n\tcheckStatus := func(now int64, strategy *lazyloadv1alpha1.RecyclingStrategy) lazyloadv1alpha1.Destinations_Status {\n\t\tswitch {\n\t\tcase strategy.Stable != nil:\n\t\t\t// ...\n\t\tcase strategy.Deadline != nil:\n\t\t\tif now > strategy.Deadline.Expire.Seconds {\n\t\t\t\treturn lazyloadv1alpha1.Destinations_EXPIRE\n\t\t\t}\n\t\tcase strategy.Auto != nil:\n\t\t\tif strategy.RecentlyCalled != nil {\n\t\t\t\tif now-strategy.RecentlyCalled.Seconds > strategy.Auto.Duration.Seconds {\n\t\t\t\t\treturn lazyloadv1alpha1.Destinations_EXPIRE\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn lazyloadv1alpha1.Destinations_ACTIVE\n\t}\n\n\tfor h, strategy := range sf.Spec.Host {\n\t\tif strings.HasSuffix(h, \"/*\") {\n\t\t\t// handle namespace level host, like 'default/*'\n\t\t\thandleNsHost(h, domains, nsSvcCache, rules)\n\t\t} else {\n\t\t\t// handle service level host, like 'a.default.svc.cluster.local' or 'www.netease.com'\n\t\t\thandleSvcHost(h, strategy, checkStatus, domains, sf, rules)\n\t\t}\n\t}\n}", "func (r *Resource) AddHost(id int, hostname, ip string) error {\n\th := Host{\n\t\tID: id,\n\t\tName: hostname,\n\t\tIP: ip,\n\t\tvolume: make(map[int]volume),\n\t}\n\n\tr.Lock()\n\tdefer r.Unlock()\n\n\tif err := checkHosts(r, h); err != nil {\n\t\treturn err\n\t}\n\tr.host[hostname] = h\n\n\treturn nil\n}", "func (sl *ServerList) Add(server string) error {\n\tvar serverAddress net.Addr\n\tif strings.Contains(server, \"/\") {\n\t\taddr, err := net.ResolveUnixAddr(\"unix\", server)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tserverAddress = newAddrValue(addr)\n\t} else {\n\t\ttcpaddr, err := net.ResolveTCPAddr(\"tcp\", server)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tserverAddress = newAddrValue(tcpaddr)\n\t}\n\n\tsl.mu.Lock()\n\tdefer sl.mu.Unlock()\n\tsl.servers = append(sl.servers, serverAddress)\n\tsl.consistentHash.Add(serverAddress)\n\treturn nil\n}", "func AddServer(serverName string, roles []string) error {\n\tsshKey, err := sshkey.ReadSSHPublicKeyFromConf()\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !sshKey.IsProvisioned() {\n\t\treturn fmt.Errorf(\n\t\t\t\"Could not add SSH key to server '%s'. The SSH key '%s' is not available in hcloud. Use the provision command first\", serverName, sshKey.Name)\n\t}\n\tserverConf := Config{\n\t\tName: serverName,\n\t\tSSHPublicKeyID: sshKey.ID,\n\t\tServerType: viper.GetString(confHCloudDefaultServerTypeKey),\n\t\tImageName: viper.GetString(confHCloudDefaultImageNameKey),\n\t\tLocationName: viper.GetString(confHCloudLocationNameKey),\n\t\tRoles: roles}\n\tserverConf.UpdateConfig()\n\treturn nil\n}", "func (c *ConfigurationFile) AddServer(name string, server Server) {\n\tc.Servers[name] = server\n}", "func (c *FortiSDKClient) CreateNetworkingInterfaceDHCP(params *JSONNetworkingInterfaceDHCP) (output *JSONNetworkingInterfaceDHCPResult, err error) {\n\tlogPrefix := \"CreateNetworkingInterfaceDHCP - \"\n\tHTTPMethod := \"POST\"\n\tpath := \"/api/v2/cmdb/system.dhcp/server\"\n\n\t// Check if there is already a server attached to interface\n\t// Create will fail with error but still creat new config if interface already associated with a config., so we don't post the request if interface already has a config\n\tdata, err := c.ReadNetworkingInterfaceDHCPServers()\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\tservers := *data\n\n\tfor _, server := range servers {\n\t\tif server.Interface == params.Interface {\n\t\t\terr = fmt.Errorf(\"DHCP Server already attached to interface!\")\n\t\t\treturn\n\t\t}\n\t}\n\t// End Check\n\n\toutput = &JSONNetworkingInterfaceDHCPResult{}\n\tlocJSON, err := json.Marshal(params)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn\n\t}\n\n\tlog.Printf(logPrefix+\"%s: %s\", HTTPMethod, string(locJSON))\n\n\tbytes := bytes.NewBuffer(locJSON)\n\treq := c.NewRequest(HTTPMethod, path, nil, bytes)\n\terr = req.Send()\n\tif err != nil || req.HTTPResponse == nil {\n\t\terr = fmt.Errorf(\"cannot send request %s\", err)\n\t\treturn\n\t}\n\n\tbody, err := ioutil.ReadAll(req.HTTPResponse.Body)\n\tif err != nil || body == nil {\n\n\t\terr = fmt.Errorf(\"cannot get response body %s\", err)\n\t\treturn\n\t}\n\n\tlog.Printf(logPrefix+\"PATH: %s\", path)\n\tlog.Printf(logPrefix+\"FortiOS Response: %s\", string(body))\n\n\tvar result map[string]interface{}\n\tjson.Unmarshal([]byte(string(body)), &result)\n\n\treq.HTTPResponse.Body.Close()\n\n\tif result != nil {\n\t\tif result[\"vdom\"] != nil {\n\t\t\toutput.Vdom = result[\"vdom\"].(string)\n\t\t}\n\t\tif result[\"mkey\"] != nil {\n\t\t\t// Note that Fortios is inconsistent in how mkey is reported\n\t\t\tif fmt.Sprintf(\"%T\", result[\"mkey\"]) == \"float64\" {\n\t\t\t\toutput.Mkey = fmt.Sprintf(\"%.0f\", result[\"mkey\"].(float64))\n\t\t\t} else {\n\t\t\t\toutput.Mkey = result[\"mkey\"].(string)\n\t\t\t}\n\t\t}\n\t\tif result[\"status\"] != nil {\n\t\t\tif result[\"status\"] != \"success\" {\n\t\t\t\tif result[\"error\"] != nil {\n\t\t\t\t\terrorCode := fmt.Sprintf(\"%.0f\", result[\"error\"])\n\t\t\t\t\tswitch errorCode {\n\t\t\t\t\tcase \"-3\":\n\t\t\t\t\t\terr = fmt.Errorf(\"Invalid Interface, no such interface\")\n\t\t\t\t\tcase \"-526\":\n\t\t\t\t\t\terr = fmt.Errorf(\"DHCP Server already attached to interface\")\n\t\t\t\t\t\t// Even if create fail a server config is created. Check func added to avoid getting here\n\t\t\t\t\tdefault:\n\t\t\t\t\t\terr = fmt.Errorf(\"status is %s and error no is %.0f\", result[\"status\"], result[\"error\"])\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\terr = fmt.Errorf(\"status is %s and error no is not found\", result[\"status\"])\n\t\t\t\t}\n\n\t\t\t\tif result[\"http_status\"] != nil {\n\t\t\t\t\terr = fmt.Errorf(\"%s, details: %s\", err, util.HttpStatus2Str(int(result[\"http_status\"].(float64))))\n\t\t\t\t} else {\n\t\t\t\t\terr = fmt.Errorf(\"%s, and http_status no is not found\", err)\n\t\t\t\t}\n\n\t\t\t\treturn\n\t\t\t}\n\t\t\toutput.Status = result[\"status\"].(string)\n\t\t} else {\n\t\t\terr = fmt.Errorf(\"cannot get status from the response\")\n\t\t\treturn\n\t\t}\n\t\tif result[\"http_status\"] != nil {\n\t\t\toutput.HTTPStatus = fmt.Sprintf(\"%.0f\", result[\"http_status\"].(float64))\n\t\t}\n\t} else {\n\t\terr = fmt.Errorf(\"cannot get the right response\")\n\t\treturn\n\t}\n\n\treturn\n}", "func AdvertiseHost(listen string) string {\n\tif listen == \"0.0.0.0\" {\n\t\taddrs, err := net.InterfaceAddrs()\n\t\tif err != nil || len(addrs) == 0 {\n\t\t\treturn \"localhost\"\n\t\t}\n\n\t\tfor _, addr := range addrs {\n\t\t\tif ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() && ip.IP.To4() != nil {\n\t\t\t\treturn ip.IP.To4().String()\n\t\t\t}\n\t\t}\n\t\treturn \"localhost\"\n\t}\n\n\treturn listen\n}", "func (m *mDNS) AddHandler(f func(net.Interface, net.Addr, Packet)) {\n\tm.pHandlers = append(m.pHandlers, f)\n}", "func (c *connection) addHost(conn *net.TCPConn) {\n\tmsg := read(conn)\n\tvar buf bytes.Buffer\n\tid := int(msg[1])\n\tport := int(msg[2])*256 + int(msg[3])\n\tif id == 0 {\n\t\tid = len(c.peers)\n\t\tbuf.Write([]byte{byte(id), byte(c.myId)})\n\t\tfor i := range c.peers {\n\t\t\tif i != c.myId {\n\t\t\t\tbuf.WriteByte(byte(i))\n\t\t\t\tbuf.Write(addrToBytes(c.peers[i].ip, c.peers[i].port))\n\t\t\t}\n\t\t}\n\t\twrite(conn, buf.Bytes())\n\n\t}\n\tc.addPeer(id, conn, port)\n\tgo c.receive(c.peers[id])\n}", "func (c *FortiSDKClient) DeleteNetworkingInterfaceDHCP(mkey string) (err error) {\n\tlogPrefix := \"DeleteNetworkingInterfaceDHCP - \"\n\tHTTPMethod := \"DELETE\"\n\tpath := \"/api/v2/cmdb/system.dhcp/server\"\n\tpath += \"/\" + EscapeURLString(mkey)\n\n\treq := c.NewRequest(HTTPMethod, path, nil, nil)\n\terr = req.Send()\n\tif err != nil || req.HTTPResponse == nil {\n\t\terr = fmt.Errorf(\"cannot send request %s\", err)\n\t\treturn\n\t}\n\n\tbody, err := ioutil.ReadAll(req.HTTPResponse.Body)\n\tif err != nil || body == nil {\n\t\terr = fmt.Errorf(\"cannot get response body %s\", err)\n\t\treturn\n\t}\n\n\tvar result map[string]interface{}\n\tjson.Unmarshal([]byte(string(body)), &result)\n\n\treq.HTTPResponse.Body.Close()\n\n\tlog.Printf(logPrefix+\"Path called %s\", path)\n\tlog.Printf(logPrefix+\"FortiOS response: %s\", string(body))\n\n\tif result != nil {\n\t\tif result[\"status\"] == nil {\n\t\t\terr = fmt.Errorf(\"cannot get status from the response\")\n\t\t\treturn\n\t\t}\n\n\t\tif result[\"status\"] != \"success\" {\n\t\t\tif result[\"error\"] != nil {\n\t\t\t\terr = fmt.Errorf(\"status is %s and error no is %.0f\", result[\"status\"], result[\"error\"])\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"status is %s and error no is not found\", result[\"status\"])\n\t\t\t}\n\n\t\t\tif result[\"http_status\"] != nil {\n\t\t\t\terr = fmt.Errorf(\"%s, details: %s\", err, util.HttpStatus2Str(int(result[\"http_status\"].(float64))))\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"%s, and http_status no is not found\", err)\n\t\t\t}\n\n\t\t\treturn\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"cannot get the right response\")\n\t\treturn\n\t}\n\n\treturn\n}", "func WithHwAddr(hwaddr []byte) Modifier {\n\treturn func(d *DHCPv4) *DHCPv4 {\n\t\td.SetClientHwAddr(hwaddr)\n\t\treturn d\n\t}\n}", "func (c *RawClient) sendDHCP(target net.HardwareAddr, dhcp []byte, dstIP net.IP, srcIP net.IP) error {\n\n\tproto := 17\n\n\tudpsrc := uint(67)\n\tudpdst := uint(68)\n\n\tudp := udphdr{\n\t\tsrc: uint16(udpsrc),\n\t\tdst: uint16(udpdst),\n\t}\n\n\tudplen := 8 + len(dhcp)\n\n\tip := iphdr{\n\t\tvhl: 0x45,\n\t\ttos: 0,\n\t\tid: 0x0000, // the kernel overwrites id if it is zero\n\t\toff: 0,\n\t\tttl: 128,\n\t\tproto: uint8(proto),\n\t}\n\tcopy(ip.src[:], srcIP.To4())\n\tcopy(ip.dst[:], dstIP.To4())\n\n\tudp.ulen = uint16(udplen)\n\tudp.checksum(&ip, dhcp)\n\n\ttotalLen := 20 + udplen\n\n\tip.iplen = uint16(totalLen)\n\tip.checksum()\n\n\tbuf := bytes.NewBuffer([]byte{})\n\terr := binary.Write(buf, binary.BigEndian, &udp)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tudpHeader := buf.Bytes()\n\tdataWithHeader := append(udpHeader, dhcp...)\n\n\tbuff := bytes.NewBuffer([]byte{})\n\terr = binary.Write(buff, binary.BigEndian, &ip)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tipHeader := buff.Bytes()\n\tpacket := append(ipHeader, dataWithHeader...)\n\n\t// Create Ethernet frame\n\tf := &ethernet.Frame{\n\t\tDestination: target,\n\t\tSource: c.ifi.HardwareAddr,\n\t\tEtherType: ethernet.EtherTypeIPv4,\n\t\tPayload: packet,\n\t}\n\tfb, err := f.MarshalBinary()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Send packet to target\n\t_, err = c.p.WriteTo(fb, &raw.Addr{\n\t\tHardwareAddr: target,\n\t})\n\treturn err\n}", "func (b *DummyPool) AddServer(s *Server) {\n\tb.server = s\n}", "func (vcd *TestVCD) Test_VMGetDhcpAddress(check *C) {\n\tif vcd.config.VCD.EdgeGateway == \"\" {\n\t\tcheck.Skip(\"Skipping test because no edge gateway given\")\n\t}\n\n\t// Construct new VM for test\n\tvapp, err := deployVappForTest(vcd, \"GetDhcpAddress\")\n\tcheck.Assert(err, IsNil)\n\tvmType, _ := vcd.findFirstVm(*vapp)\n\tvm := &VM{\n\t\tVM: &vmType,\n\t\tclient: vapp.client,\n\t}\n\n\tedgeGateway, err := vcd.vdc.GetEdgeGatewayByName(vcd.config.VCD.EdgeGateway, false)\n\tif err != nil {\n\t\tcheck.Skip(fmt.Sprintf(\"Edge Gateway %s not found\", vcd.config.VCD.EdgeGateway))\n\t}\n\n\t// Setup Org network with a single IP in DHCP pool\n\tnetwork := makeOrgVdcNetworkWithDhcp(vcd, check, edgeGateway)\n\n\t// Attach Org network to vApp\n\t_, err = vapp.AddOrgNetwork(&VappNetworkSettings{}, network, false)\n\tcheck.Assert(err, IsNil)\n\n\t// Get network config and update it to use DHCP\n\tnetCfg, err := vm.GetNetworkConnectionSection()\n\tcheck.Assert(err, IsNil)\n\tcheck.Assert(netCfg, NotNil)\n\n\tnetCfg.NetworkConnection[0].Network = network.Name\n\tnetCfg.NetworkConnection[0].IPAddressAllocationMode = types.IPAllocationModeDHCP\n\tnetCfg.NetworkConnection[0].IsConnected = true\n\n\tsecondNic := &types.NetworkConnection{\n\t\tNetwork: network.Name,\n\t\tIPAddressAllocationMode: types.IPAllocationModeDHCP,\n\t\tNetworkConnectionIndex: 1,\n\t\tIsConnected: true,\n\t}\n\tnetCfg.NetworkConnection = append(netCfg.NetworkConnection, secondNic)\n\n\t// Update network configuration to use DHCP\n\terr = vm.UpdateNetworkConnectionSection(netCfg)\n\tcheck.Assert(err, IsNil)\n\n\tif testVerbose {\n\t\tfmt.Printf(\"# Time out waiting for DHCP IPs on powered off VMs: \")\n\t}\n\t// Pretend we are waiting for DHCP addresses when VM is powered off - it must timeout\n\tips, hasTimedOut, err := vm.WaitForDhcpIpByNicIndexes([]int{0, 1}, 10, true)\n\tcheck.Assert(err, IsNil)\n\tcheck.Assert(hasTimedOut, Equals, true)\n\tcheck.Assert(ips, HasLen, 2)\n\tcheck.Assert(ips[0], Equals, \"\")\n\tcheck.Assert(ips[1], Equals, \"\")\n\n\tif testVerbose {\n\t\tfmt.Println(\"OK\")\n\t}\n\n\t// err = vm.PowerOnAndForceCustomization()\n\ttask, err := vapp.PowerOn()\n\tcheck.Assert(err, IsNil)\n\terr = task.WaitTaskCompletion()\n\tcheck.Assert(err, IsNil)\n\n\tif testVerbose {\n\t\tfmt.Printf(\"# Get IPs for NICs 0 and 1: \")\n\t}\n\t// Wait and check DHCP lease acquired\n\tips, hasTimedOut, err = vm.WaitForDhcpIpByNicIndexes([]int{0, 1}, 300, true)\n\tcheck.Assert(err, IsNil)\n\tcheck.Assert(hasTimedOut, Equals, false)\n\tcheck.Assert(ips, HasLen, 2)\n\tcheck.Assert(ips[0], Matches, `^32.32.32.\\d{1,3}$`)\n\tcheck.Assert(ips[1], Matches, `^32.32.32.\\d{1,3}$`)\n\n\tif testVerbose {\n\t\tfmt.Printf(\"OK:(NICs 0 and 1): %s, %s\\n\", ips[0], ips[1])\n\t}\n\n\t// DHCP lease was received so VMs MAC address should have an active lease\n\tif testVerbose {\n\t\tfmt.Printf(\"# Get active lease for NICs with MAC 0: \")\n\t}\n\tlease, err := edgeGateway.GetNsxvActiveDhcpLeaseByMac(netCfg.NetworkConnection[0].MACAddress)\n\tcheck.Assert(err, IsNil)\n\tcheck.Assert(lease, NotNil)\n\t// This check fails for a known bug in vCD\n\t//check.Assert(lease.IpAddress, Matches, `^32.32.32.\\d{1,3}$`)\n\tif testVerbose {\n\t\tfmt.Printf(\"Ok. (Got active lease for MAC 0: %s)\\n\", lease.IpAddress)\n\t}\n\n\tif testVerbose {\n\t\tfmt.Printf(\"# Check number of leases on Edge Gateway: \")\n\t}\n\tallLeases, err := edgeGateway.GetAllNsxvDhcpLeases()\n\tcheck.Assert(err, IsNil)\n\tcheck.Assert(allLeases, NotNil)\n\tcheck.Assert(len(allLeases) > 0, Equals, true)\n\tif testVerbose {\n\t\tfmt.Printf(\"OK: (%d leases found)\\n\", len(allLeases))\n\t}\n\n\t// Check for a single NIC\n\tif testVerbose {\n\t\tfmt.Printf(\"# Get IP for single NIC 0: \")\n\t}\n\tips, hasTimedOut, err = vm.WaitForDhcpIpByNicIndexes([]int{0}, 300, true)\n\tcheck.Assert(err, IsNil)\n\tcheck.Assert(hasTimedOut, Equals, false)\n\tcheck.Assert(ips, HasLen, 1)\n\n\t// This check fails for a known bug in vCD\n\t// TODO: re-enable when the bug is fixed\n\t//check.Assert(ips[0], Matches, `^32.32.32.\\d{1,3}$`)\n\tif testVerbose {\n\t\tfmt.Printf(\"OK: Got IP for NICs 0: %s\\n\", ips[0])\n\t}\n\n\t// Check if IPs are reported by only using VMware tools\n\tif testVerbose {\n\t\tfmt.Printf(\"# Get IPs for NICs 0 and 1 (only using guest tools): \")\n\t}\n\tips, hasTimedOut, err = vm.WaitForDhcpIpByNicIndexes([]int{0, 1}, 300, false)\n\tcheck.Assert(err, IsNil)\n\tcheck.Assert(hasTimedOut, Equals, false)\n\tcheck.Assert(ips, HasLen, 2)\n\t// This check fails for a known bug in vCD\n\t//check.Assert(ips[0], Matches, `^32.32.32.\\d{1,3}$`)\n\t//check.Assert(ips[1], Matches, `^32.32.32.\\d{1,3}$`)\n\tif testVerbose {\n\t\tfmt.Printf(\"OK: IPs for NICs 0 and 1 (via guest tools): %s, %s\\n\", ips[0], ips[1])\n\t}\n\n\t// Cleanup vApp\n\terr = deleteVapp(vcd, vapp.VApp.Name)\n\tcheck.Assert(err, IsNil)\n}", "func (m *mDNS) AddHandler(f func(net.Addr, Packet)) {\n\tm.pHandlers = append(m.pHandlers, f)\n}", "func (sp *ServerPool) AddServer(server *Server) {\n\tlog.Printf(\"Added server %s to pool\", server.Name)\n\tsp.servers = append(sp.servers, server)\n}", "func (c *Client) SetServerHost(host string, port int) {\n\tc.serverAddr = net.JoinHostPort(host, strconv.Itoa(port))\n}", "func createFakeDHCP() error{\n\n\n dhcpData := []byte(`lease 192.168.50.63 {\n starts 4 2019/08/08 22:32:49;\n ends 4 2019/08/08 23:52:49;\n cltt 4 2019/08/08 22:32:49;\n binding state active;\n next binding state free;\n rewind binding state free;\n hardware ethernet 08:00:27:00:ab:2c;\n client-hostname \"fake-test-bmh\"\";\n}`)\n err := ioutil.WriteFile(\"/var/lib/dhcp/dhcpd.leases\", dhcpData, 0777)\n\n if (err != nil) {\n return err\n }\n\n return nil\n}", "func (ln *linuxNetworking) AddVirtualServer(ipvsSvc *ipvs.Service) error {\n\tln.Lock()\n\tdefer ln.Unlock()\n\n\treturn ln.ipvsHandle.NewService(ipvsSvc)\n}", "func (d *dataset) addServer(server Server) {\n\tif server.WritePriority > 0 {\n\t\td.write = &server\n\t}\n\tif server.ReadPriority > 0 {\n\t\td.read.addServer(&server)\n\t\tif _, ok := d.allReadServers[server.ReadPriority]; !ok {\n\t\t\td.allReadServers[server.ReadPriority] = []*Server{}\n\t\t}\n\t\td.allReadServers[server.ReadPriority] = append(d.allReadServers[server.ReadPriority], &server)\n\t}\n}", "func NewAddDNSServerNoContent() *AddDNSServerNoContent {\n\treturn &AddDNSServerNoContent{}\n}", "func WithHost(p string) Option {\n\treturn func(o *options) {\n\t\to.host = p\n\t}\n}", "func AddHostAndDatabase(ctx context.Context, pmfs ...DBOption) error {\n\tpm := getParam(pmfs...)\n\n\tconf := new(config)\n\tif _, err := os.Stat(pm.ConfFilePath); err == nil {\n\t\tconf, err = getConfig(ctx, pm.ConfFilePath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif conf.Hosts == nil {\n\t\tconf.Hosts = []*host{}\n\t}\n\n\tif conf.Databases == nil {\n\t\tconf.Databases = []*database{}\n\t}\n\n\t// add Host Info\n\tvar ho *host\n\tfor _, h := range conf.Hosts {\n\t\tif h.User == pm.User &&\n\t\t\th.Password == pm.Password &&\n\t\t\th.Address == pm.Address &&\n\t\t\th.Port == pm.Port &&\n\t\t\th.Protocol == pm.Protocol {\n\t\t\tho = h\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ho == nil {\n\t\tho = &host{\n\t\t\tKey: len(conf.Hosts) + 1,\n\t\t\tUser: pm.User,\n\t\t\tPassword: pm.Password,\n\t\t\tAddress: pm.Address,\n\t\t\tPort: pm.Port,\n\t\t\tProtocol: pm.Protocol,\n\t\t}\n\n\t\tconf.Hosts = append(conf.Hosts, ho)\n\t}\n\n\thostKey := ho.Key\n\n\tvar db *database\n\n\t// add Database Info\n\tfor _, d := range conf.Databases {\n\t\tif d.HostKey == hostKey && d.Name == pm.Database {\n\t\t\tdb = d\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif db == nil {\n\t\tdb = &database{\n\t\t\tHostKey: hostKey,\n\t\t\tName: pm.Database,\n\t\t}\n\n\t\tconf.Databases = append(conf.Databases, db)\n\t}\n\n\treturn setConfig(ctx, conf, pm.ConfFilePath)\n}", "func (sf *ClientOption) AddRemoteServer(server string) error {\n\tif len(server) > 0 && server[0] == ':' {\n\t\tserver = \"127.0.0.1\" + server\n\t}\n\tif !strings.Contains(server, \"://\") {\n\t\tserver = \"tcp://\" + server\n\t\t//server = \"mms://\" + server\n\t}\n\tremoteURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsf.server = remoteURL\n\treturn nil\n}", "func AddServer(dir, serverID string) error {\n\tscript := fmt.Sprintf(`cd %v && ./easyrsa build-server-full %v nopass`, dir, serverID)\n\treturn execScript(script)\n}", "func (client *LANHostConfigManagement1) SetDHCPServerConfigurable(NewDHCPServerConfigurable bool) (err error) {\n\treturn client.SetDHCPServerConfigurableCtx(context.Background(),\n\t\tNewDHCPServerConfigurable,\n\t)\n}", "func (px *PXE) handleDHCPRequest(p layers.DHCPv4) {\n\n\t// Construct a hash of options so we can use it more easily\n\topts := make(map[layers.DHCPOpt]layers.DHCPOption)\n\tfor _, o := range p.Options {\n\t\topts[o.Type] = o\n\t}\n\n\tt, ok := opts[layers.DHCPOptMessageType]\n\tif !ok {\n\t\tpx.api.Log(types.LLDEBUG, \"got DHCP packet with no message type\")\n\t\treturn\n\t}\n\n\tn := px.NodeGet(queryByMAC, p.ClientHWAddr.String())\n\t// fmt.Printf(\"%v, %v, %p, %v\\n\", count, n.ID().String(), &n, p.ClientHWAddr.String())\n\tif n == nil {\n\t\tpx.api.Logf(types.LLDEBUG, \"ignoring DHCP packet from unknown %s\", p.ClientHWAddr.String())\n\t\treturn\n\t}\n\n\tv, e := n.GetValue(px.cfg.IpUrl)\n\tif e != nil {\n\t\tpx.api.Logf(types.LLDEBUG, \"ignoring DHCP packet from node with no IP in state: %s\", p.ClientHWAddr.String())\n\t\treturn\n\t}\n\tip := v.Interface().(ipv4t.IP).IP\n\n\tswitch layers.DHCPMsgType(t.Data[0]) {\n\tcase layers.DHCPMsgTypeDiscover:\n\t\tpx.api.Logf(types.LLDEBUG, \"sending DHCP offer of %s to %s\", ip.String(), p.ClientHWAddr.String())\n\n\t\tr := px.newDHCPPacket(\n\t\t\tp,\n\t\t\tlayers.DHCPMsgTypeOffer,\n\t\t\tpx.selfIP.To4(),\n\t\t\tip,\n\t\t\tpx.leaseTime,\n\t\t\tlayers.DHCPOptions{},\n\t\t)\n\n\t\tpx.transmitDHCPPacket(n, ip, p.ClientHWAddr, r)\n\t\treturn\n\tcase layers.DHCPMsgTypeRequest:\n\t\treq, ok := opts[layers.DHCPOptRequestIP]\n\t\tif !ok {\n\t\t\tpx.api.Log(types.LLDEBUG, \"got a DHCP request, but no request IP\")\n\t\t\treturn\n\t\t}\n\t\tif req.Length != 4 {\n\t\t\tpx.api.Logf(types.LLDEBUG, \"got a DHCP request with invalid length request IP, len = %d\", req.Length)\n\t\t\treturn\n\t\t}\n\t\treqIP := net.IP(req.Data)\n\t\tif reqIP.Equal(ip) {\n\t\t\tr := px.newDHCPPacket(\n\t\t\t\tp,\n\t\t\t\tlayers.DHCPMsgTypeAck,\n\t\t\t\tpx.selfIP.To4(),\n\t\t\t\tip,\n\t\t\t\tpx.leaseTime,\n\t\t\t\tlayers.DHCPOptions{},\n\t\t\t)\n\t\t\tpx.transmitDHCPPacket(n, ip, p.ClientHWAddr, r)\n\t\t\tpx.api.Logf(types.LLDEBUG, \"acknowledging DHCP request by %s for %s\", p.ClientHWAddr.String(), reqIP.String())\n\t\t\t// discover that we've progressed\n\t\t\turl1 := util.NodeURLJoin(n.ID().String(), PXEStateURL)\n\t\t\tev1 := core.NewEvent(\n\t\t\t\ttypes.Event_DISCOVERY,\n\t\t\t\turl1,\n\t\t\t\t&core.DiscoveryEvent{\n\t\t\t\t\tURL: url1,\n\t\t\t\t\tValueID: \"INIT\",\n\t\t\t\t},\n\t\t\t)\n\t\t\turl2 := util.NodeURLJoin(n.ID().String(), \"/RunState\")\n\t\t\tev2 := core.NewEvent(\n\t\t\t\ttypes.Event_DISCOVERY,\n\t\t\t\turl2,\n\t\t\t\t&core.DiscoveryEvent{\n\t\t\t\t\tURL: url2,\n\t\t\t\t\tValueID: \"NODE_INIT\",\n\t\t\t\t},\n\t\t\t)\n\t\t\tpx.dchan <- ev1\n\t\t\tpx.dchan <- ev2\n\t\t} else {\n\t\t\tpx.api.Logf(types.LLDEBUG, \"NAKing DHCP request by %s for %s\", p.ClientHWAddr.String(), reqIP.String())\n\t\t\tr := px.newDHCPPacket(\n\t\t\t\tp,\n\t\t\t\tlayers.DHCPMsgTypeNak,\n\t\t\t\tpx.selfIP.To4(),\n\t\t\t\tip,\n\t\t\t\tpx.leaseTime,\n\t\t\t\tlayers.DHCPOptions{},\n\t\t\t)\n\t\t\tpx.transmitDHCPPacket(n, ip, p.ClientHWAddr, r)\n\t\t}\n\t// We don't expect any of the following, so we don't handle them\n\tcase layers.DHCPMsgTypeDecline:\n\t\tfallthrough\n\tcase layers.DHCPMsgTypeInform:\n\t\tfallthrough\n\tcase layers.DHCPMsgTypeRelease:\n\t\tfallthrough\n\tcase layers.DHCPMsgTypeUnspecified:\n\t\tfallthrough\n\tdefault: // Pi's only send Discovers\n\t\tpx.api.Log(types.LLDEBUG, \"Unhandled DHCP packet.\")\n\t}\n\treturn\n}", "func (r Virtual_Guest) GetDedicatedHost() (resp datatypes.Virtual_DedicatedHost, err error) {\n\terr = r.Session.DoRequest(\"SoftLayer_Virtual_Guest\", \"getDedicatedHost\", nil, &r.Options, &resp)\n\treturn\n}", "func (p *PerHost) AddIP(ip net.IP) {\n\tp.bypassIPs = append(p.bypassIPs, ip)\n}", "func WithHost(host string) Option {\n\treturn func(c *gate.Configuration) {\n\t\tc.Host = host\n\t}\n}", "func handleDHCPFindActiveServer(w http.ResponseWriter, r *http.Request) {\n\tlog.Tracef(\"%s %v\", r.Method, r.URL)\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\terrorText := fmt.Sprintf(\"failed to read request body: %s\", err)\n\t\tlog.Error(errorText)\n\t\thttp.Error(w, errorText, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tinterfaceName := strings.TrimSpace(string(body))\n\tif interfaceName == \"\" {\n\t\terrorText := fmt.Sprintf(\"empty interface name specified\")\n\t\tlog.Error(errorText)\n\t\thttp.Error(w, errorText, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tfound, err := dhcpd.CheckIfOtherDHCPServersPresent(interfaceName)\n\n\tothSrv := map[string]interface{}{}\n\tfoundVal := \"no\"\n\tif found {\n\t\tfoundVal = \"yes\"\n\t} else if err != nil {\n\t\tfoundVal = \"error\"\n\t\tothSrv[\"error\"] = err.Error()\n\t}\n\tothSrv[\"found\"] = foundVal\n\n\tstaticIP := map[string]interface{}{}\n\tisStaticIP, err := hasStaticIP(interfaceName)\n\tstaticIPStatus := \"yes\"\n\tif err != nil {\n\t\tstaticIPStatus = \"error\"\n\t\tstaticIP[\"error\"] = err.Error()\n\t} else if !isStaticIP {\n\t\tstaticIPStatus = \"no\"\n\t\tstaticIP[\"ip\"] = getFullIP(interfaceName)\n\t}\n\tstaticIP[\"static\"] = staticIPStatus\n\n\tresult := map[string]interface{}{}\n\tresult[\"other_server\"] = othSrv\n\tresult[\"static_ip\"] = staticIP\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\terr = json.NewEncoder(w).Encode(result)\n\tif err != nil {\n\t\thttpError(w, http.StatusInternalServerError, \"Failed to marshal DHCP found json: %s\", err)\n\t\treturn\n\t}\n}", "func sendUnicastDHCP(dhcp []byte, dstIP net.IP, srcIP net.IP, srcPort int, dstPort int) error {\n\n\ts, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, syscall.IPPROTO_RAW)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tspew.Dump(dstIP)\n\tspew.Dump(srcIP)\n\tproto := 17\n\n\tudpsrc := srcPort\n\n\tudpdst := dstPort\n\n\tudp := udphdr{\n\t\tsrc: uint16(udpsrc),\n\t\tdst: uint16(udpdst),\n\t}\n\n\tudplen := 8 + len(dhcp)\n\n\tip := iphdr{\n\t\tvhl: 0x45,\n\t\ttos: 0,\n\t\tid: 0x0000, // the kernel overwrites id if it is zero\n\t\toff: 0,\n\t\tttl: 128,\n\t\tproto: uint8(proto),\n\t}\n\tcopy(ip.src[:], srcIP.To4())\n\tcopy(ip.dst[:], dstIP.To4())\n\n\tudp.ulen = uint16(udplen)\n\tudp.checksum(&ip, dhcp)\n\n\ttotalLen := 20 + udplen\n\n\tip.iplen = uint16(totalLen)\n\tip.checksum()\n\n\tbuf := bytes.NewBuffer([]byte{})\n\terr = binary.Write(buf, binary.BigEndian, &udp)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tudpHeader := buf.Bytes()\n\tdataWithHeader := append(udpHeader, dhcp...)\n\n\tbuff := bytes.NewBuffer([]byte{})\n\terr = binary.Write(buff, binary.BigEndian, &ip)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tipHeader := buff.Bytes()\n\tpacket := append(ipHeader, dataWithHeader...)\n\n\taddr := syscall.SockaddrInet4{}\n\tcopy(addr.Addr[:], dstIP.To4())\n\taddr.Port = int(udpdst)\n\n\terr = syscall.Sendto(s, packet, 0, &addr)\n\t// Send packet to target\n\terr = syscall.Close(s)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"error closing the socket: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\treturn err\n}", "func (d *DelegationCache) Add(domain string, server Server) bool {\n\td.mu.Lock()\n\tdefer d.mu.Unlock()\n\tdomain = strings.ToLower(domain)\n\tfor _, s2 := range d.c[domain] {\n\t\tif domainEqual(s2.Name, server.Name) {\n\t\t\treturn false\n\t\t}\n\t}\n\tif d.c == nil {\n\t\td.c = map[string][]Server{}\n\t}\n\td.c[domain] = append(d.c[domain], server)\n\treturn true\n}", "func (d *DHCPv4) SetUnicast() {\n\td.Flags &= ^uint16(0x8000)\n}", "func (p *SpecificDeriver) DeriveHostToHost(dstHost string, key Key) (Key, error) {\n\thost, err := packtoHostAddr(dstHost)\n\tif err != nil {\n\t\treturn Key{}, serrors.WrapStr(\"deriving input H2H\", err)\n\t}\n\tlen := inputDeriveHostToHost(p.buf[:], host)\n\toutKey, err := deriveKey(p.buf[:], len, key)\n\treturn outKey, err\n}", "func DHCPCreate(dhcp Dhcp) error {\n\tif isUnmanaged(UnmanagedID(dhcp.Ifname), LINKTYPE) {\n\t\treturn NewUnmanagedLinkDHCPCannotBeModifiedError(dhcp.Ifname)\n\t}\n\t_, err := DHCPGet(dhcp.Ifname)\n\tif err != nil {\n\t\t/* The only acceptable error is that you didn't find it. For any other error, abort */\n\t\tif _, ok := err.(*NotFoundError); !ok {\n\t\t\treturn err\n\t\t}\n\t}\n\n\terr = DHCPStaticAddressesManage(dhcp.Ifname)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tout, err := exec.Command(prefixInstallPAth+\"dhcp_start.sh\", string(dhcp.Ifname)).Output()\n\tif err != nil {\n\t\treturn NewCannotStartDHCPError(dhcp.Ifname, err)\n\t}\n\n\tif string(out) == \"Service running already\" {\n\t\treturn NewDHCPAlreadyRunningConflictError(dhcp.Ifname)\n\t}\n\treturn nil\n}", "func (o *DhcpRangeDataData) HasServerAddr() bool {\n\tif o != nil && o.ServerAddr != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (p *Proxy) AddServerAccess(s *Server) (err error) {\n\n // We only want to connect internally to the VPN.\n // These should not be exposed.\n // serverAddress := s.PublicServerAddress()\n serverAddress := s.ServerAddress()\n\n f:= logrus.Fields{\n \"proxy\": p.Name, \"server\": s.Name, \"user\": s.User, \"serverAddress\": serverAddress,\n }\n log.Info(f, \"Adding server access to proxy.\")\n\n if s.ServerPort == 0 {\n return fmt.Errorf(\"Failed to add server: invalid server port = (%d)\", s.ServerPort)\n }\n\n rcon, err := p.GetRcon()\n if err != nil { return err }\n\n motd := fmt.Sprintf(\"%s hosted by %s in the %s neighborhood.\", s.Name, s.User, s.Name)\n command := fmt.Sprintf(\"bconf addServer(\\\"%s\\\", \\\"%s\\\", \\\"%s\\\", false)\",\n s.Name, motd, serverAddress)\n\n reply, err := rcon.Send(command)\n f[\"command\"] = command\n f[\"reply\"] = reply\n if err != nil { \n log.Error(f, \"Remore addServer failed.\", err)\n return err \n }\n // fmt.Printf(\"Received reply: %s\\n\", reply)\n log.Info(f, \"Remote addServer reply.\")\n\n return err\n}", "func isServerAddHeaderDirective(directive string) bool {\n\tif isEqualString(directive, AddHeaderDirective) {\n\t\treturn true\n\t}\n\treturn false\n}", "func DBHost(address string) DBOption {\n\treturn func(pm *param) *param {\n\t\tpm.Address = address\n\t\treturn pm\n\t}\n}", "func (i *DHCPInterface) StartBlockingServer() error {\n\tpacketConn, err := conn.NewUDP4BoundListener(i.Bridge, \":67\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn dhcp.Serve(packetConn, i)\n}", "func (h *Host) SetAdress(a string) {\n}", "func (client WorkloadNetworksClient) CreateDhcpResponder(resp *http.Response) (result WorkloadNetworkDhcp, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func IPIsDoHOnlyServer(ip netip.Addr) bool {\n\treturn nextDNSv6RangeA.Contains(ip) || nextDNSv6RangeB.Contains(ip) ||\n\t\tnextDNSv4RangeA.Contains(ip) || nextDNSv4RangeB.Contains(ip)\n}", "func (client WorkloadNetworksClient) CreateDhcp(ctx context.Context, resourceGroupName string, privateCloudName string, dhcpID string, workloadNetworkDhcp WorkloadNetworkDhcp) (result WorkloadNetworksCreateDhcpFuture, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/WorkloadNetworksClient.CreateDhcp\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.Response() != nil {\n\t\t\t\tsc = result.Response().StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tif err := validation.Validate([]validation.Validation{\n\t\t{TargetValue: client.SubscriptionID,\n\t\t\tConstraints: []validation.Constraint{{Target: \"client.SubscriptionID\", Name: validation.MinLength, Rule: 1, Chain: nil}}},\n\t\t{TargetValue: resourceGroupName,\n\t\t\tConstraints: []validation.Constraint{{Target: \"resourceGroupName\", Name: validation.MaxLength, Rule: 90, Chain: nil},\n\t\t\t\t{Target: \"resourceGroupName\", Name: validation.MinLength, Rule: 1, Chain: nil},\n\t\t\t\t{Target: \"resourceGroupName\", Name: validation.Pattern, Rule: `^[-\\w\\._\\(\\)]+$`, Chain: nil}}}}); err != nil {\n\t\treturn result, validation.NewError(\"avs.WorkloadNetworksClient\", \"CreateDhcp\", err.Error())\n\t}\n\n\treq, err := client.CreateDhcpPreparer(ctx, resourceGroupName, privateCloudName, dhcpID, workloadNetworkDhcp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"avs.WorkloadNetworksClient\", \"CreateDhcp\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresult, err = client.CreateDhcpSender(req)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"avs.WorkloadNetworksClient\", \"CreateDhcp\", nil, \"Failure sending request\")\n\t\treturn\n\t}\n\n\treturn\n}", "func NewPutDevicesEroutersIDDhcpServersServernameForbidden() *PutDevicesEroutersIDDhcpServersServernameForbidden {\n\treturn &PutDevicesEroutersIDDhcpServersServernameForbidden{}\n}", "func AddServer(data map[string]string)(err error) {\n uuid := data[\"uuid\"]\n err = ndb.GetTokenByUuid(uuid); if err!=nil{logs.Error(\"Error loading node token: %s\",err); return err}\n ipuuid,portuuid,err := ndb.ObtainPortIp(uuid)\n if err != nil {\n logs.Error(\"AddServer ERROR Obtaining Port and IP for Add a new server into STAP: \"+err.Error())\n return err\n }\n err = nodeclient.AddServer(ipuuid,portuuid, data)\n if err != nil {\n logs.Error(\"node/AddServer ERROR http data request: \"+err.Error())\n return err\n }\n return nil\n}", "func (a *Client) PostNodesMacaddressDhcpWhitelist(params *PostNodesMacaddressDhcpWhitelistParams, authInfo runtime.ClientAuthInfoWriter) (*PostNodesMacaddressDhcpWhitelistCreated, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewPostNodesMacaddressDhcpWhitelistParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"PostNodesMacaddressDhcpWhitelist\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/nodes/{macaddress}/dhcp/whitelist\",\n\t\tProducesMediaTypes: []string{\"application/json\", \"application/x-gzip\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\", \"https\"},\n\t\tParams: params,\n\t\tReader: &PostNodesMacaddressDhcpWhitelistReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*PostNodesMacaddressDhcpWhitelistCreated), nil\n}", "func (a *Client) PostNodesMacaddressDhcpWhitelist(params *PostNodesMacaddressDhcpWhitelistParams, authInfo runtime.ClientAuthInfoWriter) (*PostNodesMacaddressDhcpWhitelistCreated, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewPostNodesMacaddressDhcpWhitelistParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"PostNodesMacaddressDhcpWhitelist\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/nodes/{macaddress}/dhcp/whitelist\",\n\t\tProducesMediaTypes: []string{\"application/json\", \"application/x-gzip\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\", \"https\"},\n\t\tParams: params,\n\t\tReader: &PostNodesMacaddressDhcpWhitelistReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*PostNodesMacaddressDhcpWhitelistCreated), nil\n}", "func (gs *GRPCClient) AddServer(sv *Server) {\n\tvar host, port, portKey string\n\tvar ok bool\n\n\thost, portKey = gs.getServerHost(sv)\n\tif host == \"\" {\n\t\tlogger.Log.Errorf(\"[grpc client] server %s has no grpcHost specified in metadata\", sv.ID)\n\t\treturn\n\t}\n\n\tif port, ok = sv.Metadata[portKey]; !ok {\n\t\tlogger.Log.Errorf(\"[grpc client] server %s has no %s specified in metadata\", sv.ID, portKey)\n\t\treturn\n\t}\n\n\taddress := fmt.Sprintf(\"%s:%s\", host, port)\n\tclient := &grpcClient{address: address}\n\tif !gs.lazy {\n\t\tif err := client.connect(); err != nil {\n\t\t\tlogger.Log.Errorf(\"[grpc client] unable to connect to server %s at %s: %v\", sv.ID, address, err)\n\t\t}\n\t}\n\tgs.clientMap.Store(sv.ID, client)\n\tlogger.Log.Debugf(\"[grpc client] added server %s at %s\", sv.ID, address)\n}", "func (d *Device) AddService(svc *ble.Service) error {\n\treturn d.Server.AddService(svc)\n}", "func (_obj *Apichannels) AddServant(imp _impApichannels, obj string) {\n\ttars.AddServant(_obj, imp, obj)\n}", "func listHostOnlyAdapters(vbox VBoxManager) (map[string]*hostOnlyNetwork, error) {\n\tout, err := vbox.vbmOut(\"list\", \"hostonlyifs\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbyName := map[string]*hostOnlyNetwork{}\n\tbyIP := map[string]*hostOnlyNetwork{}\n\tn := &hostOnlyNetwork{}\n\n\terr = parseKeyValues(out, reColonLine, func(key, val string) error {\n\t\tswitch key {\n\t\tcase \"Name\":\n\t\t\tn.Name = val\n\t\tcase \"GUID\":\n\t\t\tn.GUID = val\n\t\tcase \"DHCP\":\n\t\t\tn.DHCP = (val != \"Disabled\")\n\t\tcase \"IPAddress\":\n\t\t\tn.IPv4.IP = net.ParseIP(val)\n\t\tcase \"NetworkMask\":\n\t\t\tn.IPv4.Mask = parseIPv4Mask(val)\n\t\tcase \"HardwareAddress\":\n\t\t\tmac, err := net.ParseMAC(val)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tn.HwAddr = mac\n\t\tcase \"MediumType\":\n\t\t\tn.Medium = val\n\t\tcase \"Status\":\n\t\t\tn.Status = val\n\t\tcase \"VBoxNetworkName\":\n\t\t\tn.NetworkName = val\n\n\t\t\tif _, present := byName[n.NetworkName]; present {\n\t\t\t\treturn fmt.Errorf(\"VirtualBox is configured with multiple host-only adapters with the same name %q. Please remove one.\", n.NetworkName)\n\t\t\t}\n\t\t\tbyName[n.NetworkName] = n\n\n\t\t\tif len(n.IPv4.IP) != 0 {\n\t\t\t\tif _, present := byIP[n.IPv4.IP.String()]; present {\n\t\t\t\t\treturn fmt.Errorf(\"VirtualBox is configured with multiple host-only adapters with the same IP %q. Please remove one.\", n.IPv4.IP)\n\t\t\t\t}\n\t\t\t\tbyIP[n.IPv4.IP.String()] = n\n\t\t\t}\n\n\t\t\tn = &hostOnlyNetwork{}\n\t\t}\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn byName, nil\n}", "func WithDHCPClasslessStaticRoutes(routes []Route) Option {\n\treturn func(d *dnsmasq) {\n\t\td.classlessStaticRoutes = routes\n\t}\n}", "func (impl *ldapAuthImpl) SetLDAPServerHost(ldapServerHost string) {\n\timpl.Lock()\n\tdefer impl.Unlock()\n\n\tif ldapServerHost != impl.ldapServerHost {\n\t\timpl.ldapServerHost = ldapServerHost\n\t}\n}", "func WithDNSServer(dns string) ClientOption {\n\treturn optionFunc(func(c *Client) {\n\t\tc.WithDNSServer(dns)\n\t})\n}", "func setupKadDHT(ctx context.Context, nodehost host.Host) *dht.IpfsDHT {\n\t// Create DHT server mode option\n\tdhtmode := dht.Mode(dht.ModeServer)\n\t// Rertieve the list of boostrap peer addresses\n\tbootstrappeers := dht.GetDefaultBootstrapPeerAddrInfos()\n\t// Create the DHT bootstrap peers option\n\tdhtpeers := dht.BootstrapPeers(bootstrappeers...)\n\n\t// Trace log\n\tlogrus.Traceln(\"Generated DHT Configuration.\")\n\n\t// Start a Kademlia DHT on the host in server mode\n\tkaddht, err := dht.New(ctx, nodehost, dhtmode, dhtpeers)\n\t// Handle any potential error\n\tif err != nil {\n\t\tlogrus.WithFields(logrus.Fields{\n\t\t\t\"error\": err.Error(),\n\t\t}).Fatalln(\"Failed to Create the Kademlia DHT!\")\n\t}\n\n\t// Return the KadDHT\n\treturn kaddht\n}", "func (n *GoDHCPd) Serve(ctx context.Context, addr net.IP, iface string) error {\n\tconn, err := dhcp4.NewConn(fmt.Sprintf(\"%s:67\", addr))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create nwe connection: %w\", err)\n\t}\n\tdefer conn.Close()\n\n\tfor {\n\t\treq, riface, err := conn.RecvDHCP()\n\t\tif err != nil {\n\t\t\tn.logger.Error(\"failed to receive dhcp request\", zap.Error(err))\n\t\t\tcontinue\n\t\t}\n\t\tif riface.Name != iface {\n\t\t\tcontinue\n\t\t}\n\t\tn.logger.Info(\"received request\", zap.String(\"req\", fmt.Sprintf(\"%+v\", req)))\n\n\t\tsubnet, err := n.ds.GetManagementSubnet(ctx)\n\t\tif err != nil {\n\t\t\tn.logger.Error(\"failed to get subnet\", zap.Error(err))\n\t\t\tcontinue\n\t\t}\n\t\tvar lease *dhcpd.Lease\n\t\tlease, err = n.ds.GetLeaseFromManagementSubnet(ctx, types.HardwareAddr(req.HardwareAddr))\n\t\tif err != nil && errors.Is(err, sql.ErrNoRows) {\n\t\t\tlease, err = n.ds.CreateLeaseFromManagementSubnet(ctx, types.HardwareAddr(req.HardwareAddr))\n\t\t}\n\t\tif err != nil {\n\t\t\tn.logger.Error(\"failed to get lease\", zap.Error(err))\n\t\t\tcontinue\n\t\t}\n\t\tresp, err := makeResponse(addr, *req, *subnet, *lease)\n\t\tif err != nil {\n\t\t\tn.logger.Error(\"failed to make response\", zap.Error(err))\n\t\t\tcontinue\n\t\t}\n\t\terr = conn.SendDHCP(resp, riface)\n\t\tif err != nil {\n\t\t\tn.logger.Error(\"failed to send dhcp response\", zap.Error(err))\n\t\t\tcontinue\n\t\t}\n\t\tn.logger.Info(\"send DCHP response\", zap.String(\"resp\", fmt.Sprintf(\"%+v\", resp)))\n\t}\n}", "func (host *DinnerHost) Add(newPhilosopher Philosopher) bool {\n\tnewName := newPhilosopher.Name()\n\tfmt.Println(newName + \" WANTS TO JOIN THE TABLE.\")\n\tif len(host.phiData) >= host.tableCount {\n\t\tfmt.Println(newName + \" CANNOT JOIN: THE TABLE IS FULL.\")\n\t\tfmt.Println()\n\t\treturn false\n\t}\n\tif host.phiData[newName] != nil {\n\t\tfmt.Println(newName + \" CANNOT JOIN: ALREADY ON THE HOST'S LIST.\")\n\t\tfmt.Println()\n\t\treturn false\n\t}\n\thost.phiData[newName] = newPhilosopherDataPtr(newPhilosopher.RespChannel())\n\thost.phiData[newName].TakeSeat(host.freeSeats[0])\n\thost.freeSeats = host.freeSeats[1:]\n\tfmt.Println(newName + \" JOINED THE TABLE.\")\n\tfmt.Println()\n\treturn true\n}", "func (p *RoundRobinPool) addServer(server *Instance.ServerRoute) {\n\tp.servers = append(p.servers, server)\n}", "func WithHost(host string) InstanceOpt {\n\treturn func(i *Instance) error {\n\t\ti.host = host\n\t\treturn nil\n\t}\n}", "func WithRelay(ip net.IP) Modifier {\n\treturn func(d *DHCPv4) *DHCPv4 {\n\t\td.SetUnicast()\n\t\td.SetGatewayIPAddr(ip)\n\t\td.SetHopCount(1)\n\t\treturn d\n\t}\n}", "func (p *Proxy) StartProxyForServer(s *Server) (err error) {\n\n f:= logrus.Fields{\n \"proxy\": p.Name, \"server\": s.Name, \"user\": s.User,\n }\n log.Info(f, \"Adding proxy as a network-proxy for server.\")\n\n serverFQDN, err := p.ProxiedServerFQDN(s)\n if err != nil {\n log.Error(f, \"Failed to obtain server address from DNS. Proxy not started for Server\", err)\n return err\n }\n f[\"serverFQDN\"] = serverFQDN\n\n rcon, err := p.GetRcon()\n if err != nil { \n log.Error(f, \"Failed to get an RCON connection. Proxy not started for Server\", err)\n return err \n }\n\n // serverFQDN := fmt.Sprintf(\"%s.%s\", s.DNSName(), proxyFQDN)\n command := fmt.Sprintf(\"bconf addForcedHost(%d, \\\"%s\\\", \\\"%s\\\")\", 0, serverFQDN, s.Name)\n reply, err := rcon.Send(command)\n f[\"command\"] = command\n f[\"reply\"] = reply\n log.Info(f, \"Remote addForcedHost reply.\")\n\n return err\n}" ]
[ "0.63686794", "0.57897925", "0.57406795", "0.56142825", "0.55573124", "0.5441052", "0.5403369", "0.5396786", "0.534772", "0.524854", "0.5180699", "0.5176822", "0.5176461", "0.5159396", "0.5083173", "0.50322163", "0.49743834", "0.49698305", "0.496737", "0.49510124", "0.49067736", "0.48714405", "0.48523742", "0.48360628", "0.48351282", "0.4821606", "0.47922447", "0.47706908", "0.4767083", "0.4760986", "0.47439435", "0.47333866", "0.47288126", "0.47206798", "0.47150165", "0.46803376", "0.46512908", "0.46505734", "0.46504596", "0.46489352", "0.4637664", "0.4617628", "0.46120188", "0.46094453", "0.46076196", "0.460009", "0.45959625", "0.45946854", "0.45893478", "0.4587159", "0.45741847", "0.45704418", "0.45579877", "0.45421147", "0.45354497", "0.4529297", "0.45285884", "0.45146662", "0.4506589", "0.4498673", "0.44984016", "0.44910008", "0.44900438", "0.44798318", "0.44733733", "0.44687897", "0.44658753", "0.44569877", "0.44557405", "0.4444806", "0.44185925", "0.43920606", "0.43619987", "0.43607026", "0.435303", "0.43376684", "0.43335643", "0.43307328", "0.43301997", "0.43230027", "0.43207383", "0.43186373", "0.42981058", "0.42927444", "0.42906183", "0.42906183", "0.42771927", "0.42698038", "0.42695972", "0.42589486", "0.425653", "0.425592", "0.42554125", "0.42550424", "0.42489424", "0.4228788", "0.42212117", "0.42197332", "0.42105326", "0.42066267" ]
0.8681207
0
listDHCPServers lists all DHCP server settings in a map keyed by DHCP.NetworkName.
func listDHCPServers(vbox VBoxManager) (map[string]*dhcpServer, error) { out, err := vbox.vbmOut("list", "dhcpservers") if err != nil { return nil, err } m := map[string]*dhcpServer{} dhcp := &dhcpServer{} err = parseKeyValues(out, reColonLine, func(key, val string) error { switch key { case "NetworkName": dhcp = &dhcpServer{} m[val] = dhcp dhcp.NetworkName = val case "IP": dhcp.IPv4.IP = net.ParseIP(val) case "upperIPAddress": dhcp.UpperIP = net.ParseIP(val) case "lowerIPAddress": dhcp.LowerIP = net.ParseIP(val) case "NetworkMask": dhcp.IPv4.Mask = parseIPv4Mask(val) case "Enabled": dhcp.Enabled = (val == "Yes") } return nil }) if err != nil { return nil, err } return m, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *VirtualizationVmwareVirtualMachineAllOf) GetDnsServerList() []string {\n\tif o == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn o.DnsServerList\n}", "func WithDHCPNameServers(dns []string) Option {\n\treturn func(d *dnsmasq) {\n\t\td.dns = dns\n\t}\n}", "func (client WorkloadNetworksClient) ListDhcpResponder(resp *http.Response) (result WorkloadNetworkDhcpList, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func removeOrphanDHCPServers(vbox VBoxManager) error {\n\tdhcps, err := listDHCPServers(vbox)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(dhcps) == 0 {\n\t\treturn nil\n\t}\n\n\tnets, err := listHostOnlyAdapters(vbox)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor name := range dhcps {\n\t\tif strings.HasPrefix(name, dhcpPrefix) {\n\t\t\tif _, present := nets[name]; !present {\n\t\t\t\tif err := vbox.vbm(\"dhcpserver\", \"remove\", \"--netname\", name); err != nil {\n\t\t\t\t\tlog.Warnf(\"Unable to remove orphan dhcp server %q: %s\", name, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func runListServers(_ *cobra.Command, _ []string) {\n\tcfg, err := config.LoadFromFile()\n\tif err != nil {\n\t\texitWithError(err)\n\t}\n\n\tregions, err := checkRegions(*region)\n\tif err != nil {\n\t\texitWithError(err)\n\t}\n\n\tnameFilter := core.NewFilter(core.TagName, *name, core.Contains, *ignoreCase)\n\tenvFilter := core.NewFilter(core.TagEnv, *env, core.Equals, *ignoreCase)\n\tservers, err := core.GetAllServers(cfg.AWSCredentials, regions, nameFilter, envFilter)\n\tif err != nil {\n\t\texitWithError(err)\n\t}\n\n\tw := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)\n\tfmt.Fprintln(w, \"NAME\\tENVIRONMENT\\tPRIVATE IP\\tPUBLIC IP\")\n\tfor _, server := range servers {\n\t\tfmt.Fprintf(w, \"%s\\t%s\\t%s\\t%s\\n\", server.Name, server.Env, server.PrivateIP, server.PublicIP)\n\t}\n\tw.Flush()\n}", "func (o *VirtualizationVmwareVirtualMachineAllOf) SetDnsServerList(v []string) {\n\to.DnsServerList = v\n}", "func (s *FastDNSv2Service) ListZones(ctx context.Context, opt *ZoneListOptions) (*ZoneList, *Response, error) {\n\tu := fmt.Sprintf(\"config-dns/v2/zones\")\n\tu, err := addOptions(u, opt)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treq, err := s.client.NewRequest(\"GET\", u, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvar zones *ZoneList\n\tresp, err := s.client.Do(ctx, req, &zones)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn zones, resp, nil\n}", "func (h *InterfaceVppHandler) DumpDhcpClients() (map[uint32]*vppcalls.Dhcp, error) {\n\tdhcpData := make(map[uint32]*vppcalls.Dhcp)\n\treqCtx := h.callsChannel.SendMultiRequest(&dhcp.DHCPClientDump{})\n\n\tfor {\n\t\tdhcpDetails := &dhcp.DHCPClientDetails{}\n\t\tlast, err := reqCtx.ReceiveReply(dhcpDetails)\n\t\tif last {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tclient := dhcpDetails.Client\n\t\tlease := dhcpDetails.Lease\n\n\t\tvar hostMac net.HardwareAddr = lease.HostMac\n\t\tvar hostAddr, routerAddr string\n\t\tif uintToBool(lease.IsIPv6) {\n\t\t\thostAddr = fmt.Sprintf(\"%s/%d\", net.IP(lease.HostAddress).To16().String(), uint32(lease.MaskWidth))\n\t\t\trouterAddr = fmt.Sprintf(\"%s/%d\", net.IP(lease.RouterAddress).To16().String(), uint32(lease.MaskWidth))\n\t\t} else {\n\t\t\thostAddr = fmt.Sprintf(\"%s/%d\", net.IP(lease.HostAddress[:4]).To4().String(), uint32(lease.MaskWidth))\n\t\t\trouterAddr = fmt.Sprintf(\"%s/%d\", net.IP(lease.RouterAddress[:4]).To4().String(), uint32(lease.MaskWidth))\n\t\t}\n\n\t\t// DHCP client data\n\t\tdhcpClient := &vppcalls.Client{\n\t\t\tSwIfIndex: client.SwIfIndex,\n\t\t\tHostname: string(bytes.SplitN(client.Hostname, []byte{0x00}, 2)[0]),\n\t\t\tID: string(bytes.SplitN(client.ID, []byte{0x00}, 2)[0]),\n\t\t\tWantDhcpEvent: uintToBool(client.WantDHCPEvent),\n\t\t\tSetBroadcastFlag: uintToBool(client.SetBroadcastFlag),\n\t\t\tPID: client.PID,\n\t\t}\n\n\t\t// DHCP lease data\n\t\tdhcpLease := &vppcalls.Lease{\n\t\t\tSwIfIndex: lease.SwIfIndex,\n\t\t\tState: lease.State,\n\t\t\tHostname: string(bytes.SplitN(lease.Hostname, []byte{0x00}, 2)[0]),\n\t\t\tIsIPv6: uintToBool(lease.IsIPv6),\n\t\t\tHostAddress: hostAddr,\n\t\t\tRouterAddress: routerAddr,\n\t\t\tHostMac: hostMac.String(),\n\t\t}\n\n\t\t// DHCP metadata\n\t\tdhcpData[client.SwIfIndex] = &vppcalls.Dhcp{\n\t\t\tClient: dhcpClient,\n\t\t\tLease: dhcpLease,\n\t\t}\n\t}\n\n\treturn dhcpData, nil\n}", "func (client WorkloadNetworksClient) ListDhcpSender(req *http.Request) (*http.Response, error) {\n\treturn client.Send(req, azure.DoRetryWithRegistration(client.Client))\n}", "func (c *OperatorDNS) List() (srvRecords map[string][]SrvRecord, err error) {\n\treturn nil, ErrNotImplemented\n}", "func (api Solarwinds) ListServers(siteid int) ([]Server, error) {\n\tbody := struct {\n\t\tItems []Server `xml:\"items>server\"`\n\t}{}\n\n\terr := api.get(url.Values{\n\t\t\"service\": []string{\"list_servers\"},\n\t\t\"siteid\": []string{strconv.Itoa(siteid)},\n\t}, &body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn body.Items, nil\n}", "func (s *API) ListDNSZoneNameservers(req *ListDNSZoneNameserversRequest, opts ...scw.RequestOption) (*ListDNSZoneNameserversResponse, error) {\n\tvar err error\n\n\tquery := url.Values{}\n\tparameter.AddToQuery(query, \"organization_id\", req.OrganizationID)\n\n\tif fmt.Sprint(req.DNSZone) == \"\" {\n\t\treturn nil, errors.New(\"field DNSZone cannot be empty in request\")\n\t}\n\n\tscwReq := &scw.ScalewayRequest{\n\t\tMethod: \"GET\",\n\t\tPath: \"/domain/v2alpha2/dns-zones/\" + fmt.Sprint(req.DNSZone) + \"/nameservers\",\n\t\tQuery: query,\n\t\tHeaders: http.Header{},\n\t}\n\n\tvar resp ListDNSZoneNameserversResponse\n\n\terr = s.client.Do(scwReq, &resp, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "func (d *DHCPv4) NTPServers() []net.IP {\n\treturn GetIPs(OptionNTPServers, d.Options)\n}", "func (s *API) ListDNSZoneNameservers(req *ListDNSZoneNameserversRequest, opts ...scw.RequestOption) (*ListDNSZoneNameserversResponse, error) {\n\tvar err error\n\n\tquery := url.Values{}\n\tparameter.AddToQuery(query, \"project_id\", req.ProjectID)\n\n\tif fmt.Sprint(req.DNSZone) == \"\" {\n\t\treturn nil, errors.New(\"field DNSZone cannot be empty in request\")\n\t}\n\n\tscwReq := &scw.ScalewayRequest{\n\t\tMethod: \"GET\",\n\t\tPath: \"/domain/v2beta1/dns-zones/\" + fmt.Sprint(req.DNSZone) + \"/nameservers\",\n\t\tQuery: query,\n\t\tHeaders: http.Header{},\n\t}\n\n\tvar resp ListDNSZoneNameserversResponse\n\n\terr = s.client.Do(scwReq, &resp, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "func (o LookupVirtualNetworkResultOutput) DnsServers() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v LookupVirtualNetworkResult) []string { return v.DnsServers }).(pulumi.StringArrayOutput)\n}", "func (api *powerdnsProvider) ListZones() ([]string, error) {\n\tvar result []string\n\tmyZones, err := api.client.Zones().ListZones(context.Background(), api.ServerName)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\tfor _, zone := range myZones {\n\t\tresult = append(result, zone.Name)\n\t}\n\treturn result, nil\n}", "func (m *VpnConfiguration) GetServers()([]VpnServerable) {\n val, err := m.GetBackingStore().Get(\"servers\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]VpnServerable)\n }\n return nil\n}", "func (r *ReconcileRethinkDBCluster) listServers(cr *rethinkdbv1alpha1.RethinkDBCluster) ([]corev1.Pod, error) {\n\tfound := &corev1.PodList{}\n\tlabelSelector := labels.SelectorFromSet(labelsForCluster(cr))\n\tlistOps := &client.ListOptions{Namespace: cr.Namespace, LabelSelector: labelSelector}\n\terr := r.client.List(context.TODO(), listOps, found)\n\tif err != nil {\n\t\tlog.Error(err, \"failed to list server pods\")\n\t\treturn nil, err\n\t}\n\treturn found.Items, nil\n}", "func (o AccountActiveDirectoryOutput) DnsServers() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v AccountActiveDirectory) []string { return v.DnsServers }).(pulumi.StringArrayOutput)\n}", "func (ml *Memberlist) List() (map[string]*IpAddress, error) {\n\n\t// Send request to service\n\tres, err := http.Post(ml.ServiceUrl+\"/list\",\n\t\t\"application/x-www-form-urlencoded\", nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to list memberlist (%v): %v\\n\", ml, err)\n\t}\n\n\t// Read response body in JSON\n\tbody, err := ioutil.ReadAll(res.Body)\n\tres.Body.Close()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read response of memberlist list (%v): %v\\n\", ml, err)\n\t}\n\n\t// Unmarshall all ip addresses as map\n\tvar memberlist map[string]*IpAddress\n\tjson.Unmarshal(body, &memberlist)\n\n\treturn memberlist, nil\n}", "func (client DnsClient) listZones(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) {\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/zones\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListZonesResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (ncr *NamespacedConfigMapReflector) List() ([]interface{}, error) {\n\treturn virtualkubelet.List[virtualkubelet.Lister[*corev1.ConfigMap], *corev1.ConfigMap](\n\t\tncr.localConfigMaps,\n\t\tncr.remoteConfigMaps,\n\t)\n}", "func addHostOnlyDHCPServer(ifname string, d dhcpServer, vbox VBoxManager) error {\n\tname := dhcpPrefix + ifname\n\n\tdhcps, err := listDHCPServers(vbox)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// On some platforms (OSX), creating a host-only adapter adds a default dhcpserver,\n\t// while on others (Windows?) it does not.\n\tcommand := \"add\"\n\tif dhcp, ok := dhcps[name]; ok {\n\t\tcommand = \"modify\"\n\t\tif (dhcp.IPv4.IP.Equal(d.IPv4.IP)) && (dhcp.IPv4.Mask.String() == d.IPv4.Mask.String()) && (dhcp.LowerIP.Equal(d.LowerIP)) && (dhcp.UpperIP.Equal(d.UpperIP)) && dhcp.Enabled {\n\t\t\t// dhcp is up to date\n\t\t\treturn nil\n\t\t}\n\t}\n\n\targs := []string{\"dhcpserver\", command,\n\t\t\"--netname\", name,\n\t\t\"--ip\", d.IPv4.IP.String(),\n\t\t\"--netmask\", net.IP(d.IPv4.Mask).String(),\n\t\t\"--lowerip\", d.LowerIP.String(),\n\t\t\"--upperip\", d.UpperIP.String(),\n\t}\n\tif d.Enabled {\n\t\targs = append(args, \"--enable\")\n\t} else {\n\t\targs = append(args, \"--disable\")\n\t}\n\n\treturn vbox.vbm(args...)\n}", "func (o AccountActiveDirectoryPtrOutput) DnsServers() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *AccountActiveDirectory) []string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.DnsServers\n\t}).(pulumi.StringArrayOutput)\n}", "func (c *Client) ListServers() (*ServerList) {\n\tv := &ServerList{}\n\tURL, err := url.Parse(c.BaseURL)\n\tif err != nil {\n\t\tpanic(\"boom! Busted :F\")\n\t}\n\tURL.Path += \"listservers.php\"\n\tparameters := url.Values{}\n\tparameters.Add(\"key\", c.Token)\n\tparameters.Add(\"login\", c.Login)\n\tURL.RawQuery = parameters.Encode()\n\n\trequest, err := http.NewRequest(\"GET\", URL.String(), nil)\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\tc.Do(request, &v)\n\treturn v\n}", "func (server Server) List() map[string]clientproxy.ClientProxy {\n\tparams := make([]interface{}, 0)\n\trequest := utils.Request{Op: \"List\", Params: params}\n\tinvocation := utils.Invocation{Host: server.IP, Port: server.Port, Request: request}\n\treqtor := requestor.Requestor{}\n\t// getting the result\n\treply := reqtor.Invoke(invocation).([]interface{})\n\tresult := reply[0].(map[string]clientproxy.ClientProxy)\n\treturn result\n}", "func (o LookupServerResultOutput) DnsServers() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v LookupServerResult) []string { return v.DnsServers }).(pulumi.StringArrayOutput)\n}", "func (db *MongoDB) ListSSHServers() ([]SSHServer, error) {\n\tcur, err := db.instance.Collection(serverCollection).Find(context.Background(), bson.D{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer db.safeClose(cur)\n\tvar servers []SSHServer\n\tfor cur.Next(context.Background()) {\n\t\tvar result SSHServer\n\t\tif err := cur.Decode(&result); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tservers = append(servers, result)\n\t}\n\tSSHServers = servers // update cache\n\treturn servers, nil\n}", "func DHCPsGet() ([]Dhcp, error) {\n\tvar dhcps []Dhcp\n\tlinks, err := LinksGet()\n\tif err != nil {\n\t\treturn dhcps, err\n\t}\n\tfor _, l := range links {\n\t\td, err := DHCPGet(l.Ifname)\n\t\tif err != nil {\n\t\t\tif _, ok := err.(*NotFoundError); ok == true {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn dhcps, err\n\t\t}\n\n\t\tdhcps = append(dhcps, d)\n\n\t}\n\treturn dhcps, nil\n}", "func listHostOnlyAdapters(vbox VBoxManager) (map[string]*hostOnlyNetwork, error) {\n\tout, err := vbox.vbmOut(\"list\", \"hostonlyifs\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbyName := map[string]*hostOnlyNetwork{}\n\tbyIP := map[string]*hostOnlyNetwork{}\n\tn := &hostOnlyNetwork{}\n\n\terr = parseKeyValues(out, reColonLine, func(key, val string) error {\n\t\tswitch key {\n\t\tcase \"Name\":\n\t\t\tn.Name = val\n\t\tcase \"GUID\":\n\t\t\tn.GUID = val\n\t\tcase \"DHCP\":\n\t\t\tn.DHCP = (val != \"Disabled\")\n\t\tcase \"IPAddress\":\n\t\t\tn.IPv4.IP = net.ParseIP(val)\n\t\tcase \"NetworkMask\":\n\t\t\tn.IPv4.Mask = parseIPv4Mask(val)\n\t\tcase \"HardwareAddress\":\n\t\t\tmac, err := net.ParseMAC(val)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tn.HwAddr = mac\n\t\tcase \"MediumType\":\n\t\t\tn.Medium = val\n\t\tcase \"Status\":\n\t\t\tn.Status = val\n\t\tcase \"VBoxNetworkName\":\n\t\t\tn.NetworkName = val\n\n\t\t\tif _, present := byName[n.NetworkName]; present {\n\t\t\t\treturn fmt.Errorf(\"VirtualBox is configured with multiple host-only adapters with the same name %q. Please remove one.\", n.NetworkName)\n\t\t\t}\n\t\t\tbyName[n.NetworkName] = n\n\n\t\t\tif len(n.IPv4.IP) != 0 {\n\t\t\t\tif _, present := byIP[n.IPv4.IP.String()]; present {\n\t\t\t\t\treturn fmt.Errorf(\"VirtualBox is configured with multiple host-only adapters with the same IP %q. Please remove one.\", n.IPv4.IP)\n\t\t\t\t}\n\t\t\t\tbyIP[n.IPv4.IP.String()] = n\n\t\t\t}\n\n\t\t\tn = &hostOnlyNetwork{}\n\t\t}\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn byName, nil\n}", "func (g *LiveDNS) ListDomains() (domains []Domain, err error) {\n\t_, err = g.client.Get(\"domains\", nil, &domains)\n\treturn\n}", "func (z *Zone) GetNameServerList() ([]*NameServerRecord) {\n\tmutableMutex.Lock()\n\tdefer mutableMutex.Unlock()\n\tif z.NameServerList == nil {\n\t\tz.NameServerList = make([]*NameServerRecord, 0)\n\t}\n\tnewNameServerList := make([]*NameServerRecord, len(z.NameServerList))\n\tcopy(newNameServerList, z.NameServerList)\n\treturn newNameServerList\n}", "func (h *ConfigHandler) GetHostList(ctx *fasthttp.RequestCtx) {\n\tuser, ok := common.GlobalSession.GetUser(ctx.ID())\n\tif !ok {\n\t\th.WriteJSON(ctx, nil, common.NewNotLoginError())\n\t\treturn\n\t}\n\n\tconf, err := h.Service.GetVPNConfig(context.Background(), &user)\n\tif err != nil {\n\t\th.WriteJSON(ctx, nil, err)\n\t\treturn\n\t}\n\tdata := vpnConfigResponseEncode(conf)\n\th.WriteJSON(ctx, map[string]interface{}{\n\t\t\"list\": data.Hosts,\n\t}, nil)\n\treturn\n}", "func (v *Virter) getDHCPHosts(network libvirt.Network) ([]libvirtxml.NetworkDHCPHost, error) {\n\thosts := []libvirtxml.NetworkDHCPHost{}\n\n\tnetworkDescription, err := getNetworkDescription(v.libvirt, network)\n\tif err != nil {\n\t\treturn hosts, err\n\t}\n\tif len(networkDescription.IPs) < 1 {\n\t\treturn hosts, fmt.Errorf(\"no IPs in network\")\n\t}\n\n\tipDescription := networkDescription.IPs[0]\n\n\tdhcpDescription := ipDescription.DHCP\n\tif dhcpDescription == nil {\n\t\treturn hosts, fmt.Errorf(\"no DHCP in network\")\n\t}\n\n\tfor _, host := range dhcpDescription.Hosts {\n\t\thosts = append(hosts, host)\n\t}\n\n\treturn hosts, nil\n}", "func (conf *Configuration) VirtualMachineList() ([]*VirtualMachine, error) {\n\tctx := context.NewContext(conf.Timeout)\n\tdefer ctx.Cancel()\n\n\treturn conf.VirtualMachineListWithContext(ctx)\n}", "func (s *API) ListDNSZones(req *ListDNSZonesRequest, opts ...scw.RequestOption) (*ListDNSZonesResponse, error) {\n\tvar err error\n\n\tdefaultPageSize, exist := s.client.GetDefaultPageSize()\n\tif (req.PageSize == nil || *req.PageSize == 0) && exist {\n\t\treq.PageSize = &defaultPageSize\n\t}\n\n\tquery := url.Values{}\n\tparameter.AddToQuery(query, \"page\", req.Page)\n\tparameter.AddToQuery(query, \"page_size\", req.PageSize)\n\tparameter.AddToQuery(query, \"order_by\", req.OrderBy)\n\tparameter.AddToQuery(query, \"domain\", req.Domain)\n\tparameter.AddToQuery(query, \"dns_zone\", req.DNSZone)\n\tparameter.AddToQuery(query, \"organization_id\", req.OrganizationID)\n\n\tscwReq := &scw.ScalewayRequest{\n\t\tMethod: \"GET\",\n\t\tPath: \"/domain/v2alpha2/dns-zones\",\n\t\tQuery: query,\n\t\tHeaders: http.Header{},\n\t}\n\n\tvar resp ListDNSZonesResponse\n\n\terr = s.client.Do(scwReq, &resp, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "func (i *DHCPInterface) SetDNSServers(dns []string) {\n\tfor _, server := range dns {\n\t\ti.dnsServers = append(i.dnsServers, []byte(net.ParseIP(server).To4())...)\n\t}\n}", "func (client WorkloadNetworksClient) ListDhcp(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkDhcpListPage, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/WorkloadNetworksClient.ListDhcp\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.wndl.Response.Response != nil {\n\t\t\t\tsc = result.wndl.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tif err := validation.Validate([]validation.Validation{\n\t\t{TargetValue: client.SubscriptionID,\n\t\t\tConstraints: []validation.Constraint{{Target: \"client.SubscriptionID\", Name: validation.MinLength, Rule: 1, Chain: nil}}},\n\t\t{TargetValue: resourceGroupName,\n\t\t\tConstraints: []validation.Constraint{{Target: \"resourceGroupName\", Name: validation.MaxLength, Rule: 90, Chain: nil},\n\t\t\t\t{Target: \"resourceGroupName\", Name: validation.MinLength, Rule: 1, Chain: nil},\n\t\t\t\t{Target: \"resourceGroupName\", Name: validation.Pattern, Rule: `^[-\\w\\._\\(\\)]+$`, Chain: nil}}}}); err != nil {\n\t\treturn result, validation.NewError(\"avs.WorkloadNetworksClient\", \"ListDhcp\", err.Error())\n\t}\n\n\tresult.fn = client.listDhcpNextResults\n\treq, err := client.ListDhcpPreparer(ctx, resourceGroupName, privateCloudName)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"avs.WorkloadNetworksClient\", \"ListDhcp\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.ListDhcpSender(req)\n\tif err != nil {\n\t\tresult.wndl.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"avs.WorkloadNetworksClient\", \"ListDhcp\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult.wndl, err = client.ListDhcpResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"avs.WorkloadNetworksClient\", \"ListDhcp\", resp, \"Failure responding to request\")\n\t\treturn\n\t}\n\tif result.wndl.hasNextLink() && result.wndl.IsEmpty() {\n\t\terr = result.NextWithContext(ctx)\n\t\treturn\n\t}\n\n\treturn\n}", "func DHCPsDelete() error {\n\tdhcps, err := DHCPsGet()\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, d := range dhcps {\n\t\tif isUnmanaged(UnmanagedID(d.Ifname), LINKTYPE) {\n\t\t\tlogger.Log.Info(fmt.Sprintf(\"Skipping Unmanaged Link %v DHCP configuration\", d.Ifname))\n\t\t\tcontinue\n\t\t}\n\t\terr = DHCPDelete(d.Ifname)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (z *zones) List() ([]dnsprovider.Zone, error) {\n\tsnapshot := z.dnsView.Snapshot()\n\n\tvar zones []dnsprovider.Zone\n\tzoneInfos := snapshot.ListZones()\n\tfor i := range zoneInfos {\n\t\tzones = append(zones, &zone{dnsView: z.dnsView, zoneInfo: zoneInfos[i]})\n\t}\n\treturn zones, nil\n}", "func (s *postgresqlServerLister) List(selector labels.Selector) (ret []*v1alpha1.PostgresqlServer, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1alpha1.PostgresqlServer))\n\t})\n\treturn ret, err\n}", "func (s *API) ListDNSZones(req *ListDNSZonesRequest, opts ...scw.RequestOption) (*ListDNSZonesResponse, error) {\n\tvar err error\n\n\tdefaultPageSize, exist := s.client.GetDefaultPageSize()\n\tif (req.PageSize == nil || *req.PageSize == 0) && exist {\n\t\treq.PageSize = &defaultPageSize\n\t}\n\n\tquery := url.Values{}\n\tparameter.AddToQuery(query, \"organization_id\", req.OrganizationID)\n\tparameter.AddToQuery(query, \"project_id\", req.ProjectID)\n\tparameter.AddToQuery(query, \"order_by\", req.OrderBy)\n\tparameter.AddToQuery(query, \"page\", req.Page)\n\tparameter.AddToQuery(query, \"page_size\", req.PageSize)\n\tparameter.AddToQuery(query, \"domain\", req.Domain)\n\tparameter.AddToQuery(query, \"dns_zone\", req.DNSZone)\n\n\tscwReq := &scw.ScalewayRequest{\n\t\tMethod: \"GET\",\n\t\tPath: \"/domain/v2beta1/dns-zones\",\n\t\tQuery: query,\n\t\tHeaders: http.Header{},\n\t}\n\n\tvar resp ListDNSZonesResponse\n\n\terr = s.client.Do(scwReq, &resp, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}", "func (o *VirtualizationVmwareVirtualMachineAllOf) SetDnsSuffixList(v []string) {\n\to.DnsSuffixList = v\n}", "func (w *wireguardServerConfig) List() ([]api.WireguardServerConfig, error) {\n\tvar wgscList []api.WireguardServerConfig\n\treturn wgscList, w.store.Search(w.prefix, regexp.MustCompile(\".*\"), func(k, v []byte) error {\n\t\tvar obj api.WireguardServerConfig\n\t\tif err := json.Unmarshal(v, &obj); err != nil {\n\t\t\treturn err\n\t\t}\n\t\twgscList = append(wgscList, obj)\n\t\treturn nil\n\t})\n}", "func ListZones(r *route53.Route53) {\n\tresp, err := r.ListHostedZones(&route53.ListHostedZonesRequest{})\n\tif err != nil {\n\t\tlog.Fatalln(err)\n\t}\n\tfmt.Println(*resp)\n}", "func (p *listDiscoveryPlugin) ListDomains(provider *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) ([]core.KeystoneDomain, error) {\n\tclient, err := openstack.NewIdentityV3(provider, eo)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t//gophercloud does not support domain listing yet - do it manually\n\turl := client.ServiceURL(\"domains\")\n\tvar result gophercloud.Result\n\t_, err = client.Get(url, &result.Body, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar data struct {\n\t\tDomains []core.KeystoneDomain `json:\"domains\"`\n\t}\n\terr = result.ExtractInto(&data)\n\treturn data.Domains, err\n}", "func (o *VirtualizationVmwareVirtualMachineAllOf) GetDnsSuffixList() []string {\n\tif o == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn o.DnsSuffixList\n}", "func (p *Proxy) ServerNames() ([]string, error) {\n ns := []string{\"Error-Getting-Server-Names\"}\n rcon, err := p.GetRcon()\n if err != nil { return ns, err }\n\n command := fmt.Sprintf(\"bconf getServers().getKeys()\")\n reply, err := rcon.Send(command)\n if err != nil { return ns, err }\n\n reply = strings.Trim(reply, \"[] \\n\")\n names := strings.Split(reply, \",\")\n for i, n := range names {\n names[i] = strings.Trim(n, \" \")\n }\n return names, nil\n}", "func (o *NetworkDns) GetNameServers() []string {\n\tif o == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn o.NameServers\n}", "func (api *powerdnsProvider) GetNameservers(string) ([]*models.Nameserver, error) {\n\tvar r []string\n\tfor _, j := range api.nameservers {\n\t\tr = append(r, j.Name)\n\t}\n\treturn models.ToNameservers(r)\n}", "func (client *Client) ListNamespacedConfigMaps(request *ListNamespacedConfigMapsRequest) (response *ListNamespacedConfigMapsResponse, err error) {\n\tresponse = CreateListNamespacedConfigMapsResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func (r Dns_Domain_Registration) GetDomainNameservers() (resp []datatypes.Container_Dns_Domain_Registration_Nameserver, err error) {\n\terr = r.Session.DoRequest(\"SoftLayer_Dns_Domain_Registration\", \"getDomainNameservers\", nil, &r.Options, &resp)\n\treturn\n}", "func (c *ThreeScaleClient) ListProxyConfig(svcId string, env string) (ProxyConfigList, error) {\n\tvar pc ProxyConfigList\n\n\tendpoint := fmt.Sprintf(proxyConfigList, svcId, env)\n\treq, err := c.buildGetReq(endpoint)\n\tif err != nil {\n\t\treturn pc, httpReqError\n\t}\n\treq.Header.Set(\"Accept\", \"application/json\")\n\n\tvalues := url.Values{}\n\treq.URL.RawQuery = values.Encode()\n\n\tresp, err := c.httpClient.Do(req)\n\tif err != nil {\n\t\treturn pc, err\n\t}\n\n\tdefer resp.Body.Close()\n\n\terr = handleJsonResp(resp, http.StatusOK, &pc)\n\treturn pc, err\n}", "func (ovs OvsdbClient) ListDbs() ([]string, error) {\n\tvar dbs []string\n\terr := ovs.rpcClient.Call(\"list_dbs\", nil, &dbs)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"ListDbs failure - %v\", err)\n\t}\n\treturn dbs, err\n}", "func (w *Watcher) GetDomainList() ([]string) {\n\tmutableMutex.Lock()\n\tdefer mutableMutex.Unlock()\n\tif w.ZoneMap == nil {\n\t\tw.ZoneMap = make(map[string]*Zone)\n\t}\n\tdomainList := make([]string, 0, len(w.ZoneMap))\n\tfor d := range w.ZoneMap {\n\t\tdomainList = append(domainList, d)\n\t}\n\treturn domainList\n}", "func DHCPsConfigure(dhcp []Dhcp) error {\n\tfor _, d := range dhcp {\n\t\tif isUnmanaged(UnmanagedID(d.Ifname), LINKTYPE) {\n\t\t\tlogger.Log.Info(fmt.Sprintf(\"Skipping Unmanaged Link %v DHCP configuration\", d.Ifname))\n\t\t\tcontinue\n\t\t}\n\t\terr := DHCPDelete(d.Ifname)\n\t\tif err != nil {\n\t\t\tif _, ok := err.(*NotFoundError); ok != true {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tif err := DHCPCreate(d); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func CyberghostServers() []models.CyberghostServer {\n\treturn []models.CyberghostServer{\n\t\t{Region: \"Albania\", Group: \"Premium TCP Europe\", Hostname: \"97-1-al.cg-dialup.net\", IPs: []net.IP{{31, 171, 155, 3}, {31, 171, 155, 4}, {31, 171, 155, 7}, {31, 171, 155, 8}, {31, 171, 155, 9}, {31, 171, 155, 10}, {31, 171, 155, 11}, {31, 171, 155, 12}, {31, 171, 155, 13}, {31, 171, 155, 14}}},\n\t\t{Region: \"Albania\", Group: \"Premium UDP Europe\", Hostname: \"87-1-al.cg-dialup.net\", IPs: []net.IP{{31, 171, 155, 4}, {31, 171, 155, 5}, {31, 171, 155, 6}, {31, 171, 155, 7}, {31, 171, 155, 8}, {31, 171, 155, 9}, {31, 171, 155, 10}, {31, 171, 155, 11}, {31, 171, 155, 13}, {31, 171, 155, 14}}},\n\t\t{Region: \"Algeria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-dz.cg-dialup.net\", IPs: []net.IP{{176, 125, 228, 132}, {176, 125, 228, 134}, {176, 125, 228, 135}, {176, 125, 228, 136}, {176, 125, 228, 137}, {176, 125, 228, 138}, {176, 125, 228, 139}, {176, 125, 228, 140}, {176, 125, 228, 141}, {176, 125, 228, 142}}},\n\t\t{Region: \"Algeria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-dz.cg-dialup.net\", IPs: []net.IP{{176, 125, 228, 131}, {176, 125, 228, 133}, {176, 125, 228, 134}, {176, 125, 228, 136}, {176, 125, 228, 137}, {176, 125, 228, 139}, {176, 125, 228, 140}, {176, 125, 228, 141}, {176, 125, 228, 142}, {176, 125, 228, 143}}},\n\t\t{Region: \"Andorra\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ad.cg-dialup.net\", IPs: []net.IP{{188, 241, 82, 137}, {188, 241, 82, 138}, {188, 241, 82, 140}, {188, 241, 82, 142}, {188, 241, 82, 147}, {188, 241, 82, 155}, {188, 241, 82, 159}, {188, 241, 82, 160}, {188, 241, 82, 161}, {188, 241, 82, 166}}},\n\t\t{Region: \"Andorra\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ad.cg-dialup.net\", IPs: []net.IP{{188, 241, 82, 133}, {188, 241, 82, 134}, {188, 241, 82, 136}, {188, 241, 82, 137}, {188, 241, 82, 146}, {188, 241, 82, 153}, {188, 241, 82, 155}, {188, 241, 82, 160}, {188, 241, 82, 164}, {188, 241, 82, 168}}},\n\t\t{Region: \"Argentina\", Group: \"Premium TCP USA\", Hostname: \"93-1-ar.cg-dialup.net\", IPs: []net.IP{{146, 70, 39, 4}, {146, 70, 39, 9}, {146, 70, 39, 15}, {146, 70, 39, 19}, {146, 70, 39, 135}, {146, 70, 39, 136}, {146, 70, 39, 139}, {146, 70, 39, 142}, {146, 70, 39, 143}, {146, 70, 39, 145}}},\n\t\t{Region: \"Argentina\", Group: \"Premium UDP USA\", Hostname: \"94-1-ar.cg-dialup.net\", IPs: []net.IP{{146, 70, 39, 3}, {146, 70, 39, 5}, {146, 70, 39, 6}, {146, 70, 39, 8}, {146, 70, 39, 11}, {146, 70, 39, 12}, {146, 70, 39, 131}, {146, 70, 39, 134}, {146, 70, 39, 142}, {146, 70, 39, 143}}},\n\t\t{Region: \"Armenia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-am.cg-dialup.net\", IPs: []net.IP{{185, 253, 160, 131}, {185, 253, 160, 134}, {185, 253, 160, 136}, {185, 253, 160, 137}, {185, 253, 160, 138}, {185, 253, 160, 139}, {185, 253, 160, 140}, {185, 253, 160, 141}, {185, 253, 160, 142}, {185, 253, 160, 143}}},\n\t\t{Region: \"Armenia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-am.cg-dialup.net\", IPs: []net.IP{{185, 253, 160, 131}, {185, 253, 160, 132}, {185, 253, 160, 133}, {185, 253, 160, 134}, {185, 253, 160, 135}, {185, 253, 160, 136}, {185, 253, 160, 137}, {185, 253, 160, 141}, {185, 253, 160, 142}, {185, 253, 160, 144}}},\n\t\t{Region: \"Australia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-au.cg-dialup.net\", IPs: []net.IP{{154, 16, 81, 22}, {181, 214, 215, 7}, {181, 214, 215, 15}, {181, 214, 215, 18}, {191, 101, 210, 15}, {191, 101, 210, 50}, {191, 101, 210, 60}, {202, 60, 80, 78}, {202, 60, 80, 82}, {202, 60, 80, 102}}},\n\t\t{Region: \"Australia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-au.cg-dialup.net\", IPs: []net.IP{{181, 214, 215, 4}, {181, 214, 215, 16}, {191, 101, 210, 18}, {191, 101, 210, 21}, {191, 101, 210, 36}, {191, 101, 210, 58}, {191, 101, 210, 60}, {202, 60, 80, 74}, {202, 60, 80, 106}, {202, 60, 80, 124}}},\n\t\t{Region: \"Austria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-at.cg-dialup.net\", IPs: []net.IP{{37, 19, 223, 9}, {37, 19, 223, 16}, {37, 19, 223, 113}, {37, 19, 223, 205}, {37, 19, 223, 211}, {37, 19, 223, 218}, {37, 19, 223, 223}, {37, 19, 223, 245}, {37, 120, 155, 104}, {89, 187, 168, 174}}},\n\t\t{Region: \"Austria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-at.cg-dialup.net\", IPs: []net.IP{{37, 19, 223, 202}, {37, 19, 223, 205}, {37, 19, 223, 229}, {37, 19, 223, 239}, {37, 19, 223, 241}, {37, 19, 223, 243}, {37, 120, 155, 103}, {89, 187, 168, 160}, {89, 187, 168, 174}, {89, 187, 168, 181}}},\n\t\t{Region: \"Bahamas\", Group: \"Premium TCP USA\", Hostname: \"93-1-bs.cg-dialup.net\", IPs: []net.IP{{95, 181, 238, 131}, {95, 181, 238, 136}, {95, 181, 238, 142}, {95, 181, 238, 144}, {95, 181, 238, 146}, {95, 181, 238, 147}, {95, 181, 238, 148}, {95, 181, 238, 152}, {95, 181, 238, 153}, {95, 181, 238, 155}}},\n\t\t{Region: \"Bahamas\", Group: \"Premium UDP USA\", Hostname: \"94-1-bs.cg-dialup.net\", IPs: []net.IP{{95, 181, 238, 131}, {95, 181, 238, 138}, {95, 181, 238, 140}, {95, 181, 238, 141}, {95, 181, 238, 146}, {95, 181, 238, 147}, {95, 181, 238, 148}, {95, 181, 238, 151}, {95, 181, 238, 153}, {95, 181, 238, 155}}},\n\t\t{Region: \"Bangladesh\", Group: \"Premium TCP Asia\", Hostname: \"96-1-bd.cg-dialup.net\", IPs: []net.IP{{84, 252, 93, 132}, {84, 252, 93, 133}, {84, 252, 93, 135}, {84, 252, 93, 138}, {84, 252, 93, 139}, {84, 252, 93, 141}, {84, 252, 93, 142}, {84, 252, 93, 143}, {84, 252, 93, 144}, {84, 252, 93, 145}}},\n\t\t{Region: \"Bangladesh\", Group: \"Premium UDP Asia\", Hostname: \"95-1-bd.cg-dialup.net\", IPs: []net.IP{{84, 252, 93, 131}, {84, 252, 93, 133}, {84, 252, 93, 134}, {84, 252, 93, 135}, {84, 252, 93, 136}, {84, 252, 93, 139}, {84, 252, 93, 140}, {84, 252, 93, 141}, {84, 252, 93, 143}, {84, 252, 93, 145}}},\n\t\t{Region: \"Belarus\", Group: \"Premium TCP Europe\", Hostname: \"97-1-by.cg-dialup.net\", IPs: []net.IP{{45, 132, 194, 5}, {45, 132, 194, 6}, {45, 132, 194, 23}, {45, 132, 194, 24}, {45, 132, 194, 25}, {45, 132, 194, 27}, {45, 132, 194, 30}, {45, 132, 194, 35}, {45, 132, 194, 44}, {45, 132, 194, 49}}},\n\t\t{Region: \"Belarus\", Group: \"Premium UDP Europe\", Hostname: \"87-1-by.cg-dialup.net\", IPs: []net.IP{{45, 132, 194, 6}, {45, 132, 194, 8}, {45, 132, 194, 9}, {45, 132, 194, 11}, {45, 132, 194, 15}, {45, 132, 194, 19}, {45, 132, 194, 20}, {45, 132, 194, 23}, {45, 132, 194, 24}, {45, 132, 194, 26}}},\n\t\t{Region: \"Belgium\", Group: \"Premium TCP Europe\", Hostname: \"97-1-be.cg-dialup.net\", IPs: []net.IP{{37, 120, 143, 165}, {37, 120, 143, 166}, {185, 210, 217, 10}, {185, 210, 217, 248}, {193, 9, 114, 211}, {193, 9, 114, 220}, {194, 110, 115, 195}, {194, 110, 115, 199}, {194, 110, 115, 205}, {194, 110, 115, 238}}},\n\t\t{Region: \"Belgium\", Group: \"Premium UDP Europe\", Hostname: \"87-1-be.cg-dialup.net\", IPs: []net.IP{{37, 120, 143, 163}, {37, 120, 143, 167}, {185, 210, 217, 9}, {185, 210, 217, 13}, {185, 210, 217, 55}, {185, 210, 217, 251}, {185, 232, 21, 120}, {194, 110, 115, 214}, {194, 110, 115, 218}, {194, 110, 115, 236}}},\n\t\t{Region: \"Bosnia and Herzegovina\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ba.cg-dialup.net\", IPs: []net.IP{{185, 99, 3, 57}, {185, 99, 3, 58}, {185, 99, 3, 72}, {185, 99, 3, 73}, {185, 99, 3, 74}, {185, 99, 3, 130}, {185, 99, 3, 131}, {185, 99, 3, 134}, {185, 99, 3, 135}, {185, 99, 3, 136}}},\n\t\t{Region: \"Bosnia and Herzegovina\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ba.cg-dialup.net\", IPs: []net.IP{{185, 99, 3, 57}, {185, 99, 3, 58}, {185, 99, 3, 72}, {185, 99, 3, 73}, {185, 99, 3, 74}, {185, 99, 3, 130}, {185, 99, 3, 131}, {185, 99, 3, 134}, {185, 99, 3, 135}, {185, 99, 3, 136}}},\n\t\t{Region: \"Brazil\", Group: \"Premium TCP USA\", Hostname: \"93-1-br.cg-dialup.net\", IPs: []net.IP{{188, 241, 177, 5}, {188, 241, 177, 11}, {188, 241, 177, 38}, {188, 241, 177, 45}, {188, 241, 177, 132}, {188, 241, 177, 135}, {188, 241, 177, 136}, {188, 241, 177, 152}, {188, 241, 177, 153}, {188, 241, 177, 156}}},\n\t\t{Region: \"Brazil\", Group: \"Premium UDP USA\", Hostname: \"94-1-br.cg-dialup.net\", IPs: []net.IP{{188, 241, 177, 8}, {188, 241, 177, 37}, {188, 241, 177, 40}, {188, 241, 177, 42}, {188, 241, 177, 45}, {188, 241, 177, 135}, {188, 241, 177, 139}, {188, 241, 177, 149}, {188, 241, 177, 152}, {188, 241, 177, 154}}},\n\t\t{Region: \"Bulgaria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-bg.cg-dialup.net\", IPs: []net.IP{{37, 120, 152, 99}, {37, 120, 152, 101}, {37, 120, 152, 103}, {37, 120, 152, 104}, {37, 120, 152, 105}, {37, 120, 152, 106}, {37, 120, 152, 107}, {37, 120, 152, 108}, {37, 120, 152, 109}, {37, 120, 152, 110}}},\n\t\t{Region: \"Bulgaria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-bg.cg-dialup.net\", IPs: []net.IP{{37, 120, 152, 99}, {37, 120, 152, 100}, {37, 120, 152, 101}, {37, 120, 152, 102}, {37, 120, 152, 103}, {37, 120, 152, 105}, {37, 120, 152, 106}, {37, 120, 152, 107}, {37, 120, 152, 108}, {37, 120, 152, 109}}},\n\t\t{Region: \"Cambodia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-kh.cg-dialup.net\", IPs: []net.IP{{188, 215, 235, 35}, {188, 215, 235, 36}, {188, 215, 235, 38}, {188, 215, 235, 39}, {188, 215, 235, 45}, {188, 215, 235, 49}, {188, 215, 235, 51}, {188, 215, 235, 53}, {188, 215, 235, 54}, {188, 215, 235, 57}}},\n\t\t{Region: \"Cambodia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-kh.cg-dialup.net\", IPs: []net.IP{{188, 215, 235, 36}, {188, 215, 235, 40}, {188, 215, 235, 42}, {188, 215, 235, 44}, {188, 215, 235, 46}, {188, 215, 235, 47}, {188, 215, 235, 48}, {188, 215, 235, 50}, {188, 215, 235, 55}, {188, 215, 235, 57}}},\n\t\t{Region: \"Canada\", Group: \"Premium TCP USA\", Hostname: \"93-1-ca.cg-dialup.net\", IPs: []net.IP{{66, 115, 142, 136}, {66, 115, 142, 139}, {66, 115, 142, 156}, {66, 115, 142, 162}, {66, 115, 142, 172}, {104, 200, 151, 99}, {104, 200, 151, 111}, {104, 200, 151, 153}, {104, 200, 151, 164}, {172, 98, 89, 137}}},\n\t\t{Region: \"Canada\", Group: \"Premium UDP USA\", Hostname: \"94-1-ca.cg-dialup.net\", IPs: []net.IP{{66, 115, 142, 135}, {66, 115, 142, 154}, {66, 115, 142, 165}, {104, 200, 151, 32}, {104, 200, 151, 57}, {104, 200, 151, 85}, {104, 200, 151, 86}, {104, 200, 151, 147}, {172, 98, 89, 144}, {172, 98, 89, 173}}},\n\t\t{Region: \"Chile\", Group: \"Premium TCP USA\", Hostname: \"93-1-cl.cg-dialup.net\", IPs: []net.IP{{146, 70, 11, 3}, {146, 70, 11, 6}, {146, 70, 11, 7}, {146, 70, 11, 8}, {146, 70, 11, 9}, {146, 70, 11, 10}, {146, 70, 11, 11}, {146, 70, 11, 12}, {146, 70, 11, 13}, {146, 70, 11, 14}}},\n\t\t{Region: \"Chile\", Group: \"Premium UDP USA\", Hostname: \"94-1-cl.cg-dialup.net\", IPs: []net.IP{{146, 70, 11, 3}, {146, 70, 11, 4}, {146, 70, 11, 6}, {146, 70, 11, 7}, {146, 70, 11, 8}, {146, 70, 11, 9}, {146, 70, 11, 10}, {146, 70, 11, 11}, {146, 70, 11, 13}, {146, 70, 11, 14}}},\n\t\t{Region: \"China\", Group: \"Premium TCP Asia\", Hostname: \"96-1-cn.cg-dialup.net\", IPs: []net.IP{{188, 241, 80, 131}, {188, 241, 80, 132}, {188, 241, 80, 133}, {188, 241, 80, 134}, {188, 241, 80, 135}, {188, 241, 80, 137}, {188, 241, 80, 139}, {188, 241, 80, 140}, {188, 241, 80, 141}, {188, 241, 80, 142}}},\n\t\t{Region: \"China\", Group: \"Premium UDP Asia\", Hostname: \"95-1-cn.cg-dialup.net\", IPs: []net.IP{{188, 241, 80, 131}, {188, 241, 80, 132}, {188, 241, 80, 133}, {188, 241, 80, 134}, {188, 241, 80, 135}, {188, 241, 80, 136}, {188, 241, 80, 137}, {188, 241, 80, 138}, {188, 241, 80, 139}, {188, 241, 80, 142}}},\n\t\t{Region: \"Colombia\", Group: \"Premium TCP USA\", Hostname: \"93-1-co.cg-dialup.net\", IPs: []net.IP{{146, 70, 9, 3}, {146, 70, 9, 4}, {146, 70, 9, 5}, {146, 70, 9, 7}, {146, 70, 9, 9}, {146, 70, 9, 10}, {146, 70, 9, 11}, {146, 70, 9, 12}, {146, 70, 9, 13}, {146, 70, 9, 14}}},\n\t\t{Region: \"Colombia\", Group: \"Premium UDP USA\", Hostname: \"94-1-co.cg-dialup.net\", IPs: []net.IP{{146, 70, 9, 3}, {146, 70, 9, 4}, {146, 70, 9, 5}, {146, 70, 9, 6}, {146, 70, 9, 7}, {146, 70, 9, 8}, {146, 70, 9, 9}, {146, 70, 9, 10}, {146, 70, 9, 11}, {146, 70, 9, 12}}},\n\t\t{Region: \"Costa Rica\", Group: \"Premium TCP USA\", Hostname: \"93-1-cr.cg-dialup.net\", IPs: []net.IP{{146, 70, 10, 3}, {146, 70, 10, 4}, {146, 70, 10, 5}, {146, 70, 10, 6}, {146, 70, 10, 7}, {146, 70, 10, 8}, {146, 70, 10, 10}, {146, 70, 10, 11}, {146, 70, 10, 12}, {146, 70, 10, 13}}},\n\t\t{Region: \"Costa Rica\", Group: \"Premium UDP USA\", Hostname: \"94-1-cr.cg-dialup.net\", IPs: []net.IP{{146, 70, 10, 3}, {146, 70, 10, 4}, {146, 70, 10, 5}, {146, 70, 10, 6}, {146, 70, 10, 7}, {146, 70, 10, 8}, {146, 70, 10, 9}, {146, 70, 10, 11}, {146, 70, 10, 12}, {146, 70, 10, 14}}},\n\t\t{Region: \"Croatia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-hr.cg-dialup.net\", IPs: []net.IP{{146, 70, 8, 5}, {146, 70, 8, 8}, {146, 70, 8, 9}, {146, 70, 8, 10}, {146, 70, 8, 11}, {146, 70, 8, 12}, {146, 70, 8, 13}, {146, 70, 8, 14}, {146, 70, 8, 15}, {146, 70, 8, 16}}},\n\t\t{Region: \"Croatia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-hr.cg-dialup.net\", IPs: []net.IP{{146, 70, 8, 3}, {146, 70, 8, 4}, {146, 70, 8, 5}, {146, 70, 8, 6}, {146, 70, 8, 7}, {146, 70, 8, 9}, {146, 70, 8, 11}, {146, 70, 8, 13}, {146, 70, 8, 14}, {146, 70, 8, 16}}},\n\t\t{Region: \"Cyprus\", Group: \"Premium TCP Europe\", Hostname: \"97-1-cy.cg-dialup.net\", IPs: []net.IP{{185, 253, 162, 131}, {185, 253, 162, 133}, {185, 253, 162, 135}, {185, 253, 162, 136}, {185, 253, 162, 137}, {185, 253, 162, 139}, {185, 253, 162, 140}, {185, 253, 162, 142}, {185, 253, 162, 143}, {185, 253, 162, 144}}},\n\t\t{Region: \"Cyprus\", Group: \"Premium UDP Europe\", Hostname: \"87-1-cy.cg-dialup.net\", IPs: []net.IP{{185, 253, 162, 131}, {185, 253, 162, 132}, {185, 253, 162, 134}, {185, 253, 162, 135}, {185, 253, 162, 137}, {185, 253, 162, 138}, {185, 253, 162, 140}, {185, 253, 162, 142}, {185, 253, 162, 143}, {185, 253, 162, 144}}},\n\t\t{Region: \"Czech Republic\", Group: \"Premium TCP Europe\", Hostname: \"97-1-cz.cg-dialup.net\", IPs: []net.IP{{138, 199, 56, 235}, {138, 199, 56, 236}, {138, 199, 56, 237}, {138, 199, 56, 245}, {138, 199, 56, 246}, {138, 199, 56, 249}, {195, 181, 161, 12}, {195, 181, 161, 16}, {195, 181, 161, 20}, {195, 181, 161, 23}}},\n\t\t{Region: \"Czech Republic\", Group: \"Premium UDP Europe\", Hostname: \"87-1-cz.cg-dialup.net\", IPs: []net.IP{{138, 199, 56, 227}, {138, 199, 56, 229}, {138, 199, 56, 231}, {138, 199, 56, 235}, {138, 199, 56, 241}, {138, 199, 56, 247}, {195, 181, 161, 10}, {195, 181, 161, 16}, {195, 181, 161, 18}, {195, 181, 161, 22}}},\n\t\t{Region: \"Denmark\", Group: \"Premium TCP Europe\", Hostname: \"97-1-dk.cg-dialup.net\", IPs: []net.IP{{37, 120, 145, 83}, {37, 120, 145, 88}, {37, 120, 145, 93}, {37, 120, 194, 36}, {37, 120, 194, 56}, {37, 120, 194, 57}, {95, 174, 65, 163}, {95, 174, 65, 174}, {185, 206, 224, 238}, {185, 206, 224, 243}}},\n\t\t{Region: \"Denmark\", Group: \"Premium UDP Europe\", Hostname: \"87-1-dk.cg-dialup.net\", IPs: []net.IP{{37, 120, 194, 39}, {95, 174, 65, 167}, {95, 174, 65, 170}, {185, 206, 224, 227}, {185, 206, 224, 230}, {185, 206, 224, 236}, {185, 206, 224, 238}, {185, 206, 224, 245}, {185, 206, 224, 250}, {185, 206, 224, 254}}},\n\t\t{Region: \"Egypt\", Group: \"Premium TCP Europe\", Hostname: \"97-1-eg.cg-dialup.net\", IPs: []net.IP{{188, 214, 122, 40}, {188, 214, 122, 42}, {188, 214, 122, 43}, {188, 214, 122, 45}, {188, 214, 122, 48}, {188, 214, 122, 50}, {188, 214, 122, 52}, {188, 214, 122, 60}, {188, 214, 122, 70}, {188, 214, 122, 73}}},\n\t\t{Region: \"Egypt\", Group: \"Premium UDP Europe\", Hostname: \"87-1-eg.cg-dialup.net\", IPs: []net.IP{{188, 214, 122, 37}, {188, 214, 122, 38}, {188, 214, 122, 44}, {188, 214, 122, 54}, {188, 214, 122, 57}, {188, 214, 122, 59}, {188, 214, 122, 60}, {188, 214, 122, 61}, {188, 214, 122, 67}, {188, 214, 122, 69}}},\n\t\t{Region: \"Estonia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ee.cg-dialup.net\", IPs: []net.IP{{95, 153, 32, 83}, {95, 153, 32, 84}, {95, 153, 32, 86}, {95, 153, 32, 88}, {95, 153, 32, 89}, {95, 153, 32, 90}, {95, 153, 32, 91}, {95, 153, 32, 92}, {95, 153, 32, 93}, {95, 153, 32, 94}}},\n\t\t{Region: \"Estonia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ee.cg-dialup.net\", IPs: []net.IP{{95, 153, 32, 83}, {95, 153, 32, 84}, {95, 153, 32, 85}, {95, 153, 32, 87}, {95, 153, 32, 88}, {95, 153, 32, 89}, {95, 153, 32, 90}, {95, 153, 32, 91}, {95, 153, 32, 92}, {95, 153, 32, 94}}},\n\t\t{Region: \"Finland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-fi.cg-dialup.net\", IPs: []net.IP{{188, 126, 89, 99}, {188, 126, 89, 102}, {188, 126, 89, 105}, {188, 126, 89, 107}, {188, 126, 89, 108}, {188, 126, 89, 110}, {188, 126, 89, 112}, {188, 126, 89, 115}, {188, 126, 89, 116}, {188, 126, 89, 119}}},\n\t\t{Region: \"Finland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-fi.cg-dialup.net\", IPs: []net.IP{{188, 126, 89, 101}, {188, 126, 89, 104}, {188, 126, 89, 109}, {188, 126, 89, 110}, {188, 126, 89, 111}, {188, 126, 89, 113}, {188, 126, 89, 114}, {188, 126, 89, 115}, {188, 126, 89, 122}, {188, 126, 89, 124}}},\n\t\t{Region: \"France\", Group: \"Premium TCP Europe\", Hostname: \"97-1-fr.cg-dialup.net\", IPs: []net.IP{{84, 17, 43, 167}, {84, 17, 60, 147}, {84, 17, 60, 155}, {151, 106, 8, 108}, {191, 101, 31, 202}, {191, 101, 31, 254}, {191, 101, 217, 45}, {191, 101, 217, 159}, {191, 101, 217, 211}, {191, 101, 217, 240}}},\n\t\t{Region: \"France\", Group: \"Premium UDP Europe\", Hostname: \"87-1-fr.cg-dialup.net\", IPs: []net.IP{{84, 17, 60, 59}, {84, 17, 60, 121}, {191, 101, 31, 81}, {191, 101, 31, 84}, {191, 101, 31, 126}, {191, 101, 31, 127}, {191, 101, 217, 140}, {191, 101, 217, 201}, {191, 101, 217, 206}, {191, 101, 217, 211}}},\n\t\t{Region: \"Georgia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ge.cg-dialup.net\", IPs: []net.IP{{95, 181, 236, 131}, {95, 181, 236, 132}, {95, 181, 236, 133}, {95, 181, 236, 134}, {95, 181, 236, 135}, {95, 181, 236, 136}, {95, 181, 236, 138}, {95, 181, 236, 139}, {95, 181, 236, 142}, {95, 181, 236, 144}}},\n\t\t{Region: \"Georgia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ge.cg-dialup.net\", IPs: []net.IP{{95, 181, 236, 132}, {95, 181, 236, 133}, {95, 181, 236, 134}, {95, 181, 236, 136}, {95, 181, 236, 137}, {95, 181, 236, 139}, {95, 181, 236, 141}, {95, 181, 236, 142}, {95, 181, 236, 143}, {95, 181, 236, 144}}},\n\t\t{Region: \"Germany\", Group: \"Premium TCP Europe\", Hostname: \"97-1-de.cg-dialup.net\", IPs: []net.IP{{84, 17, 48, 39}, {84, 17, 48, 234}, {84, 17, 49, 106}, {84, 17, 49, 112}, {84, 17, 49, 218}, {154, 28, 188, 35}, {154, 28, 188, 66}, {154, 28, 188, 133}, {154, 28, 188, 144}, {154, 28, 188, 145}}},\n\t\t{Region: \"Germany\", Group: \"Premium UDP Europe\", Hostname: \"87-1-de.cg-dialup.net\", IPs: []net.IP{{84, 17, 48, 41}, {84, 17, 48, 224}, {84, 17, 49, 95}, {84, 17, 49, 236}, {84, 17, 49, 241}, {138, 199, 36, 151}, {154, 13, 1, 177}, {154, 28, 188, 73}, {154, 28, 188, 76}, {154, 28, 188, 93}}},\n\t\t{Region: \"Greece\", Group: \"Premium TCP Europe\", Hostname: \"97-1-gr.cg-dialup.net\", IPs: []net.IP{{185, 51, 134, 163}, {185, 51, 134, 165}, {185, 51, 134, 171}, {185, 51, 134, 172}, {185, 51, 134, 245}, {185, 51, 134, 246}, {185, 51, 134, 247}, {185, 51, 134, 249}, {185, 51, 134, 251}, {185, 51, 134, 254}}},\n\t\t{Region: \"Greece\", Group: \"Premium UDP Europe\", Hostname: \"87-1-gr.cg-dialup.net\", IPs: []net.IP{{185, 51, 134, 163}, {185, 51, 134, 166}, {185, 51, 134, 173}, {185, 51, 134, 174}, {185, 51, 134, 244}, {185, 51, 134, 246}, {185, 51, 134, 247}, {185, 51, 134, 251}, {185, 51, 134, 252}, {185, 51, 134, 253}}},\n\t\t{Region: \"Greenland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-gl.cg-dialup.net\", IPs: []net.IP{{91, 90, 120, 3}, {91, 90, 120, 4}, {91, 90, 120, 5}, {91, 90, 120, 7}, {91, 90, 120, 8}, {91, 90, 120, 10}, {91, 90, 120, 12}, {91, 90, 120, 13}, {91, 90, 120, 14}, {91, 90, 120, 17}}},\n\t\t{Region: \"Greenland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-gl.cg-dialup.net\", IPs: []net.IP{{91, 90, 120, 3}, {91, 90, 120, 4}, {91, 90, 120, 5}, {91, 90, 120, 7}, {91, 90, 120, 9}, {91, 90, 120, 10}, {91, 90, 120, 12}, {91, 90, 120, 14}, {91, 90, 120, 15}, {91, 90, 120, 16}}},\n\t\t{Region: \"Hong Kong\", Group: \"Premium TCP Asia\", Hostname: \"96-1-hk.cg-dialup.net\", IPs: []net.IP{{84, 17, 56, 144}, {84, 17, 56, 148}, {84, 17, 56, 153}, {84, 17, 56, 162}, {84, 17, 56, 163}, {84, 17, 56, 169}, {84, 17, 56, 170}, {84, 17, 56, 179}, {84, 17, 56, 180}, {84, 17, 56, 181}}},\n\t\t{Region: \"Hong Kong\", Group: \"Premium UDP Asia\", Hostname: \"95-1-hk.cg-dialup.net\", IPs: []net.IP{{84, 17, 56, 143}, {84, 17, 56, 147}, {84, 17, 56, 150}, {84, 17, 56, 152}, {84, 17, 56, 161}, {84, 17, 56, 164}, {84, 17, 56, 168}, {84, 17, 56, 179}, {84, 17, 56, 180}, {84, 17, 56, 183}}},\n\t\t{Region: \"Hungary\", Group: \"Premium TCP Europe\", Hostname: \"97-1-hu.cg-dialup.net\", IPs: []net.IP{{86, 106, 74, 247}, {86, 106, 74, 251}, {86, 106, 74, 253}, {185, 189, 114, 117}, {185, 189, 114, 118}, {185, 189, 114, 119}, {185, 189, 114, 121}, {185, 189, 114, 123}, {185, 189, 114, 125}, {185, 189, 114, 126}}},\n\t\t{Region: \"Hungary\", Group: \"Premium UDP Europe\", Hostname: \"87-1-hu.cg-dialup.net\", IPs: []net.IP{{86, 106, 74, 245}, {86, 106, 74, 247}, {86, 106, 74, 248}, {86, 106, 74, 249}, {86, 106, 74, 250}, {86, 106, 74, 252}, {86, 106, 74, 253}, {185, 189, 114, 120}, {185, 189, 114, 121}, {185, 189, 114, 122}}},\n\t\t{Region: \"Iceland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-is.cg-dialup.net\", IPs: []net.IP{{45, 133, 193, 3}, {45, 133, 193, 4}, {45, 133, 193, 6}, {45, 133, 193, 7}, {45, 133, 193, 8}, {45, 133, 193, 10}, {45, 133, 193, 11}, {45, 133, 193, 12}, {45, 133, 193, 13}, {45, 133, 193, 14}}},\n\t\t{Region: \"Iceland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-is.cg-dialup.net\", IPs: []net.IP{{45, 133, 193, 3}, {45, 133, 193, 5}, {45, 133, 193, 6}, {45, 133, 193, 7}, {45, 133, 193, 8}, {45, 133, 193, 9}, {45, 133, 193, 10}, {45, 133, 193, 11}, {45, 133, 193, 13}, {45, 133, 193, 14}}},\n\t\t{Region: \"India\", Group: \"Premium TCP Europe\", Hostname: \"97-1-in.cg-dialup.net\", IPs: []net.IP{{103, 13, 112, 68}, {103, 13, 112, 70}, {103, 13, 112, 72}, {103, 13, 112, 74}, {103, 13, 112, 75}, {103, 13, 113, 74}, {103, 13, 113, 79}, {103, 13, 113, 82}, {103, 13, 113, 83}, {103, 13, 113, 84}}},\n\t\t{Region: \"India\", Group: \"Premium UDP Europe\", Hostname: \"87-1-in.cg-dialup.net\", IPs: []net.IP{{103, 13, 112, 67}, {103, 13, 112, 70}, {103, 13, 112, 71}, {103, 13, 112, 77}, {103, 13, 112, 80}, {103, 13, 113, 72}, {103, 13, 113, 74}, {103, 13, 113, 75}, {103, 13, 113, 77}, {103, 13, 113, 85}}},\n\t\t{Region: \"Indonesia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-id.cg-dialup.net\", IPs: []net.IP{{146, 70, 14, 3}, {146, 70, 14, 4}, {146, 70, 14, 5}, {146, 70, 14, 6}, {146, 70, 14, 7}, {146, 70, 14, 10}, {146, 70, 14, 12}, {146, 70, 14, 13}, {146, 70, 14, 15}, {146, 70, 14, 16}}},\n\t\t{Region: \"Indonesia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-id.cg-dialup.net\", IPs: []net.IP{{146, 70, 14, 3}, {146, 70, 14, 5}, {146, 70, 14, 8}, {146, 70, 14, 9}, {146, 70, 14, 10}, {146, 70, 14, 12}, {146, 70, 14, 13}, {146, 70, 14, 14}, {146, 70, 14, 15}, {146, 70, 14, 16}}},\n\t\t{Region: \"Iran\", Group: \"Premium TCP Asia\", Hostname: \"96-1-ir.cg-dialup.net\", IPs: []net.IP{{62, 133, 46, 3}, {62, 133, 46, 4}, {62, 133, 46, 5}, {62, 133, 46, 6}, {62, 133, 46, 7}, {62, 133, 46, 8}, {62, 133, 46, 9}, {62, 133, 46, 10}, {62, 133, 46, 14}, {62, 133, 46, 15}}},\n\t\t{Region: \"Iran\", Group: \"Premium UDP Asia\", Hostname: \"95-1-ir.cg-dialup.net\", IPs: []net.IP{{62, 133, 46, 3}, {62, 133, 46, 4}, {62, 133, 46, 7}, {62, 133, 46, 8}, {62, 133, 46, 11}, {62, 133, 46, 12}, {62, 133, 46, 13}, {62, 133, 46, 14}, {62, 133, 46, 15}, {62, 133, 46, 16}}},\n\t\t{Region: \"Ireland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ie.cg-dialup.net\", IPs: []net.IP{{37, 120, 235, 154}, {37, 120, 235, 166}, {37, 120, 235, 174}, {77, 81, 139, 35}, {84, 247, 48, 6}, {84, 247, 48, 19}, {84, 247, 48, 22}, {84, 247, 48, 23}, {84, 247, 48, 25}, {84, 247, 48, 26}}},\n\t\t{Region: \"Ireland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ie.cg-dialup.net\", IPs: []net.IP{{37, 120, 235, 147}, {37, 120, 235, 148}, {37, 120, 235, 153}, {37, 120, 235, 158}, {37, 120, 235, 169}, {37, 120, 235, 174}, {84, 247, 48, 8}, {84, 247, 48, 11}, {84, 247, 48, 20}, {84, 247, 48, 23}}},\n\t\t{Region: \"Isle of Man\", Group: \"Premium TCP Europe\", Hostname: \"97-1-im.cg-dialup.net\", IPs: []net.IP{{91, 90, 124, 147}, {91, 90, 124, 149}, {91, 90, 124, 150}, {91, 90, 124, 151}, {91, 90, 124, 152}, {91, 90, 124, 153}, {91, 90, 124, 154}, {91, 90, 124, 156}, {91, 90, 124, 157}, {91, 90, 124, 158}}},\n\t\t{Region: \"Isle of Man\", Group: \"Premium UDP Europe\", Hostname: \"87-1-im.cg-dialup.net\", IPs: []net.IP{{91, 90, 124, 147}, {91, 90, 124, 149}, {91, 90, 124, 150}, {91, 90, 124, 151}, {91, 90, 124, 152}, {91, 90, 124, 153}, {91, 90, 124, 154}, {91, 90, 124, 155}, {91, 90, 124, 156}, {91, 90, 124, 157}}},\n\t\t{Region: \"Israel\", Group: \"Premium TCP Europe\", Hostname: \"97-1-il.cg-dialup.net\", IPs: []net.IP{{160, 116, 0, 174}, {185, 77, 248, 103}, {185, 77, 248, 111}, {185, 77, 248, 113}, {185, 77, 248, 114}, {185, 77, 248, 124}, {185, 77, 248, 125}, {185, 77, 248, 127}, {185, 77, 248, 128}, {185, 77, 248, 129}}},\n\t\t{Region: \"Israel\", Group: \"Premium UDP Europe\", Hostname: \"87-1-il.cg-dialup.net\", IPs: []net.IP{{160, 116, 0, 163}, {160, 116, 0, 165}, {160, 116, 0, 172}, {185, 77, 248, 103}, {185, 77, 248, 106}, {185, 77, 248, 114}, {185, 77, 248, 117}, {185, 77, 248, 118}, {185, 77, 248, 126}, {185, 77, 248, 129}}},\n\t\t{Region: \"Italy\", Group: \"Premium TCP Europe\", Hostname: \"97-1-it.cg-dialup.net\", IPs: []net.IP{{84, 17, 58, 21}, {84, 17, 58, 100}, {84, 17, 58, 106}, {84, 17, 58, 111}, {84, 17, 58, 117}, {87, 101, 94, 122}, {212, 102, 55, 100}, {212, 102, 55, 106}, {212, 102, 55, 110}, {212, 102, 55, 122}}},\n\t\t{Region: \"Italy\", Group: \"Premium UDP Europe\", Hostname: \"87-1-it.cg-dialup.net\", IPs: []net.IP{{84, 17, 58, 19}, {84, 17, 58, 95}, {84, 17, 58, 105}, {84, 17, 58, 119}, {84, 17, 58, 120}, {87, 101, 94, 116}, {185, 217, 71, 137}, {185, 217, 71, 138}, {185, 217, 71, 153}, {212, 102, 55, 108}}},\n\t\t{Region: \"Japan\", Group: \"Premium TCP Asia\", Hostname: \"96-1-jp.cg-dialup.net\", IPs: []net.IP{{156, 146, 35, 6}, {156, 146, 35, 10}, {156, 146, 35, 15}, {156, 146, 35, 22}, {156, 146, 35, 37}, {156, 146, 35, 39}, {156, 146, 35, 40}, {156, 146, 35, 41}, {156, 146, 35, 44}, {156, 146, 35, 50}}},\n\t\t{Region: \"Japan\", Group: \"Premium UDP Asia\", Hostname: \"95-1-jp.cg-dialup.net\", IPs: []net.IP{{156, 146, 35, 4}, {156, 146, 35, 14}, {156, 146, 35, 15}, {156, 146, 35, 18}, {156, 146, 35, 25}, {156, 146, 35, 34}, {156, 146, 35, 36}, {156, 146, 35, 46}, {156, 146, 35, 49}, {156, 146, 35, 50}}},\n\t\t{Region: \"Kazakhstan\", Group: \"Premium TCP Europe\", Hostname: \"97-1-kz.cg-dialup.net\", IPs: []net.IP{{62, 133, 47, 131}, {62, 133, 47, 132}, {62, 133, 47, 134}, {62, 133, 47, 136}, {62, 133, 47, 138}, {62, 133, 47, 139}, {62, 133, 47, 140}, {62, 133, 47, 142}, {62, 133, 47, 143}, {62, 133, 47, 144}}},\n\t\t{Region: \"Kazakhstan\", Group: \"Premium UDP Europe\", Hostname: \"87-1-kz.cg-dialup.net\", IPs: []net.IP{{62, 133, 47, 131}, {62, 133, 47, 132}, {62, 133, 47, 133}, {62, 133, 47, 134}, {62, 133, 47, 135}, {62, 133, 47, 138}, {62, 133, 47, 139}, {62, 133, 47, 140}, {62, 133, 47, 142}, {62, 133, 47, 143}}},\n\t\t{Region: \"Kenya\", Group: \"Premium TCP Asia\", Hostname: \"96-1-ke.cg-dialup.net\", IPs: []net.IP{{62, 12, 118, 195}, {62, 12, 118, 196}, {62, 12, 118, 197}, {62, 12, 118, 198}, {62, 12, 118, 199}, {62, 12, 118, 200}, {62, 12, 118, 201}, {62, 12, 118, 202}, {62, 12, 118, 203}, {62, 12, 118, 204}}},\n\t\t{Region: \"Kenya\", Group: \"Premium UDP Asia\", Hostname: \"95-1-ke.cg-dialup.net\", IPs: []net.IP{{62, 12, 118, 195}, {62, 12, 118, 196}, {62, 12, 118, 197}, {62, 12, 118, 198}, {62, 12, 118, 199}, {62, 12, 118, 200}, {62, 12, 118, 201}, {62, 12, 118, 202}, {62, 12, 118, 203}, {62, 12, 118, 204}}},\n\t\t{Region: \"Korea\", Group: \"Premium TCP Asia\", Hostname: \"96-1-kr.cg-dialup.net\", IPs: []net.IP{{79, 110, 55, 131}, {79, 110, 55, 134}, {79, 110, 55, 141}, {79, 110, 55, 147}, {79, 110, 55, 148}, {79, 110, 55, 151}, {79, 110, 55, 152}, {79, 110, 55, 153}, {79, 110, 55, 155}, {79, 110, 55, 157}}},\n\t\t{Region: \"Korea\", Group: \"Premium UDP Asia\", Hostname: \"95-1-kr.cg-dialup.net\", IPs: []net.IP{{79, 110, 55, 131}, {79, 110, 55, 133}, {79, 110, 55, 134}, {79, 110, 55, 136}, {79, 110, 55, 138}, {79, 110, 55, 140}, {79, 110, 55, 149}, {79, 110, 55, 151}, {79, 110, 55, 152}, {79, 110, 55, 157}}},\n\t\t{Region: \"Latvia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-lv.cg-dialup.net\", IPs: []net.IP{{109, 248, 148, 244}, {109, 248, 148, 245}, {109, 248, 148, 246}, {109, 248, 148, 247}, {109, 248, 148, 249}, {109, 248, 148, 250}, {109, 248, 148, 253}, {109, 248, 149, 22}, {109, 248, 149, 24}, {109, 248, 149, 25}}},\n\t\t{Region: \"Latvia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lv.cg-dialup.net\", IPs: []net.IP{{109, 248, 148, 248}, {109, 248, 148, 250}, {109, 248, 148, 254}, {109, 248, 149, 19}, {109, 248, 149, 20}, {109, 248, 149, 22}, {109, 248, 149, 24}, {109, 248, 149, 26}, {109, 248, 149, 28}, {109, 248, 149, 30}}},\n\t\t{Region: \"Liechtenstein\", Group: \"Premium UDP Europe\", Hostname: \"87-1-li.cg-dialup.net\", IPs: []net.IP{{91, 90, 122, 131}, {91, 90, 122, 134}, {91, 90, 122, 137}, {91, 90, 122, 138}, {91, 90, 122, 139}, {91, 90, 122, 140}, {91, 90, 122, 141}, {91, 90, 122, 142}, {91, 90, 122, 144}, {91, 90, 122, 145}}},\n\t\t{Region: \"Lithuania\", Group: \"Premium TCP Europe\", Hostname: \"97-1-lt.cg-dialup.net\", IPs: []net.IP{{85, 206, 162, 212}, {85, 206, 162, 215}, {85, 206, 162, 219}, {85, 206, 162, 222}, {85, 206, 165, 17}, {85, 206, 165, 23}, {85, 206, 165, 25}, {85, 206, 165, 26}, {85, 206, 165, 30}, {85, 206, 165, 31}}},\n\t\t{Region: \"Lithuania\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lt.cg-dialup.net\", IPs: []net.IP{{85, 206, 162, 209}, {85, 206, 162, 210}, {85, 206, 162, 211}, {85, 206, 162, 213}, {85, 206, 162, 214}, {85, 206, 162, 217}, {85, 206, 162, 218}, {85, 206, 162, 220}, {85, 206, 165, 26}, {85, 206, 165, 30}}},\n\t\t{Region: \"Luxembourg\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lu.cg-dialup.net\", IPs: []net.IP{{5, 253, 204, 7}, {5, 253, 204, 10}, {5, 253, 204, 12}, {5, 253, 204, 23}, {5, 253, 204, 26}, {5, 253, 204, 30}, {5, 253, 204, 37}, {5, 253, 204, 39}, {5, 253, 204, 44}, {5, 253, 204, 45}}},\n\t\t{Region: \"Macao\", Group: \"Premium TCP Asia\", Hostname: \"96-1-mo.cg-dialup.net\", IPs: []net.IP{{84, 252, 92, 131}, {84, 252, 92, 133}, {84, 252, 92, 135}, {84, 252, 92, 137}, {84, 252, 92, 138}, {84, 252, 92, 139}, {84, 252, 92, 141}, {84, 252, 92, 142}, {84, 252, 92, 144}, {84, 252, 92, 145}}},\n\t\t{Region: \"Macao\", Group: \"Premium UDP Asia\", Hostname: \"95-1-mo.cg-dialup.net\", IPs: []net.IP{{84, 252, 92, 132}, {84, 252, 92, 134}, {84, 252, 92, 135}, {84, 252, 92, 136}, {84, 252, 92, 137}, {84, 252, 92, 139}, {84, 252, 92, 141}, {84, 252, 92, 143}, {84, 252, 92, 144}, {84, 252, 92, 145}}},\n\t\t{Region: \"Macedonia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-mk.cg-dialup.net\", IPs: []net.IP{{185, 225, 28, 3}, {185, 225, 28, 4}, {185, 225, 28, 5}, {185, 225, 28, 6}, {185, 225, 28, 7}, {185, 225, 28, 8}, {185, 225, 28, 9}, {185, 225, 28, 10}, {185, 225, 28, 11}, {185, 225, 28, 12}}},\n\t\t{Region: \"Macedonia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-mk.cg-dialup.net\", IPs: []net.IP{{185, 225, 28, 3}, {185, 225, 28, 4}, {185, 225, 28, 5}, {185, 225, 28, 6}, {185, 225, 28, 7}, {185, 225, 28, 8}, {185, 225, 28, 9}, {185, 225, 28, 10}, {185, 225, 28, 11}, {185, 225, 28, 12}}},\n\t\t{Region: \"Malaysia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-my.cg-dialup.net\", IPs: []net.IP{{146, 70, 15, 4}, {146, 70, 15, 6}, {146, 70, 15, 8}, {146, 70, 15, 9}, {146, 70, 15, 10}, {146, 70, 15, 11}, {146, 70, 15, 12}, {146, 70, 15, 13}, {146, 70, 15, 15}, {146, 70, 15, 16}}},\n\t\t{Region: \"Malaysia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-my.cg-dialup.net\", IPs: []net.IP{{146, 70, 15, 3}, {146, 70, 15, 4}, {146, 70, 15, 5}, {146, 70, 15, 6}, {146, 70, 15, 7}, {146, 70, 15, 8}, {146, 70, 15, 10}, {146, 70, 15, 12}, {146, 70, 15, 15}, {146, 70, 15, 16}}},\n\t\t{Region: \"Malta\", Group: \"Premium TCP Europe\", Hostname: \"97-1-mt.cg-dialup.net\", IPs: []net.IP{{176, 125, 230, 133}, {176, 125, 230, 135}, {176, 125, 230, 136}, {176, 125, 230, 137}, {176, 125, 230, 138}, {176, 125, 230, 140}, {176, 125, 230, 142}, {176, 125, 230, 143}, {176, 125, 230, 144}, {176, 125, 230, 145}}},\n\t\t{Region: \"Malta\", Group: \"Premium UDP Europe\", Hostname: \"87-1-mt.cg-dialup.net\", IPs: []net.IP{{176, 125, 230, 131}, {176, 125, 230, 133}, {176, 125, 230, 134}, {176, 125, 230, 136}, {176, 125, 230, 137}, {176, 125, 230, 138}, {176, 125, 230, 139}, {176, 125, 230, 140}, {176, 125, 230, 144}, {176, 125, 230, 145}}},\n\t\t{Region: \"Mexico\", Group: \"Premium TCP USA\", Hostname: \"93-1-mx.cg-dialup.net\", IPs: []net.IP{{77, 81, 142, 132}, {77, 81, 142, 134}, {77, 81, 142, 136}, {77, 81, 142, 139}, {77, 81, 142, 142}, {77, 81, 142, 154}, {77, 81, 142, 155}, {77, 81, 142, 157}, {77, 81, 142, 158}, {77, 81, 142, 159}}},\n\t\t{Region: \"Mexico\", Group: \"Premium UDP USA\", Hostname: \"94-1-mx.cg-dialup.net\", IPs: []net.IP{{77, 81, 142, 130}, {77, 81, 142, 131}, {77, 81, 142, 132}, {77, 81, 142, 139}, {77, 81, 142, 141}, {77, 81, 142, 142}, {77, 81, 142, 146}, {77, 81, 142, 147}, {77, 81, 142, 154}, {77, 81, 142, 159}}},\n\t\t{Region: \"Moldova\", Group: \"Premium TCP Europe\", Hostname: \"97-1-md.cg-dialup.net\", IPs: []net.IP{{178, 175, 130, 243}, {178, 175, 130, 244}, {178, 175, 130, 245}, {178, 175, 130, 246}, {178, 175, 130, 251}, {178, 175, 130, 254}, {178, 175, 142, 131}, {178, 175, 142, 132}, {178, 175, 142, 133}, {178, 175, 142, 134}}},\n\t\t{Region: \"Moldova\", Group: \"Premium UDP Europe\", Hostname: \"87-1-md.cg-dialup.net\", IPs: []net.IP{{178, 175, 130, 243}, {178, 175, 130, 244}, {178, 175, 130, 246}, {178, 175, 130, 250}, {178, 175, 130, 251}, {178, 175, 130, 253}, {178, 175, 130, 254}, {178, 175, 142, 132}, {178, 175, 142, 133}, {178, 175, 142, 134}}},\n\t\t{Region: \"Monaco\", Group: \"Premium TCP Europe\", Hostname: \"97-1-mc.cg-dialup.net\", IPs: []net.IP{{95, 181, 233, 131}, {95, 181, 233, 132}, {95, 181, 233, 133}, {95, 181, 233, 137}, {95, 181, 233, 138}, {95, 181, 233, 139}, {95, 181, 233, 140}, {95, 181, 233, 141}, {95, 181, 233, 143}, {95, 181, 233, 144}}},\n\t\t{Region: \"Monaco\", Group: \"Premium UDP Europe\", Hostname: \"87-1-mc.cg-dialup.net\", IPs: []net.IP{{95, 181, 233, 132}, {95, 181, 233, 135}, {95, 181, 233, 136}, {95, 181, 233, 137}, {95, 181, 233, 138}, {95, 181, 233, 139}, {95, 181, 233, 141}, {95, 181, 233, 142}, {95, 181, 233, 143}, {95, 181, 233, 144}}},\n\t\t{Region: \"Mongolia\", Group: \"Premium TCP Asia\", Hostname: \"96-1-mn.cg-dialup.net\", IPs: []net.IP{{185, 253, 163, 132}, {185, 253, 163, 133}, {185, 253, 163, 135}, {185, 253, 163, 136}, {185, 253, 163, 139}, {185, 253, 163, 140}, {185, 253, 163, 141}, {185, 253, 163, 142}, {185, 253, 163, 143}, {185, 253, 163, 144}}},\n\t\t{Region: \"Mongolia\", Group: \"Premium UDP Asia\", Hostname: \"95-1-mn.cg-dialup.net\", IPs: []net.IP{{185, 253, 163, 131}, {185, 253, 163, 133}, {185, 253, 163, 134}, {185, 253, 163, 137}, {185, 253, 163, 138}, {185, 253, 163, 139}, {185, 253, 163, 140}, {185, 253, 163, 141}, {185, 253, 163, 142}, {185, 253, 163, 144}}},\n\t\t{Region: \"Montenegro\", Group: \"Premium TCP Europe\", Hostname: \"97-1-me.cg-dialup.net\", IPs: []net.IP{{176, 125, 229, 131}, {176, 125, 229, 135}, {176, 125, 229, 137}, {176, 125, 229, 138}, {176, 125, 229, 140}, {176, 125, 229, 141}, {176, 125, 229, 142}, {176, 125, 229, 143}, {176, 125, 229, 144}, {176, 125, 229, 145}}},\n\t\t{Region: \"Montenegro\", Group: \"Premium UDP Europe\", Hostname: \"87-1-me.cg-dialup.net\", IPs: []net.IP{{176, 125, 229, 131}, {176, 125, 229, 134}, {176, 125, 229, 136}, {176, 125, 229, 137}, {176, 125, 229, 138}, {176, 125, 229, 139}, {176, 125, 229, 140}, {176, 125, 229, 141}, {176, 125, 229, 143}, {176, 125, 229, 144}}},\n\t\t{Region: \"Morocco\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ma.cg-dialup.net\", IPs: []net.IP{{95, 181, 232, 132}, {95, 181, 232, 133}, {95, 181, 232, 134}, {95, 181, 232, 136}, {95, 181, 232, 137}, {95, 181, 232, 138}, {95, 181, 232, 139}, {95, 181, 232, 140}, {95, 181, 232, 141}, {95, 181, 232, 144}}},\n\t\t{Region: \"Morocco\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ma.cg-dialup.net\", IPs: []net.IP{{95, 181, 232, 131}, {95, 181, 232, 132}, {95, 181, 232, 133}, {95, 181, 232, 135}, {95, 181, 232, 137}, {95, 181, 232, 139}, {95, 181, 232, 140}, {95, 181, 232, 141}, {95, 181, 232, 142}, {95, 181, 232, 143}}},\n\t\t{Region: \"Netherlands\", Group: \"Premium TCP Europe\", Hostname: \"97-1-nl.cg-dialup.net\", IPs: []net.IP{{84, 17, 47, 98}, {181, 214, 206, 22}, {181, 214, 206, 27}, {181, 214, 206, 36}, {195, 78, 54, 10}, {195, 78, 54, 20}, {195, 78, 54, 43}, {195, 78, 54, 50}, {195, 78, 54, 119}, {195, 181, 172, 78}}},\n\t\t{Region: \"Netherlands\", Group: \"Premium UDP Europe\", Hostname: \"87-1-nl.cg-dialup.net\", IPs: []net.IP{{84, 17, 47, 110}, {181, 214, 206, 29}, {181, 214, 206, 42}, {195, 78, 54, 8}, {195, 78, 54, 19}, {195, 78, 54, 47}, {195, 78, 54, 110}, {195, 78, 54, 141}, {195, 78, 54, 143}, {195, 78, 54, 157}}},\n\t\t{Region: \"New Zealand\", Group: \"Premium TCP Asia\", Hostname: \"96-1-nz.cg-dialup.net\", IPs: []net.IP{{43, 250, 207, 98}, {43, 250, 207, 99}, {43, 250, 207, 100}, {43, 250, 207, 101}, {43, 250, 207, 102}, {43, 250, 207, 103}, {43, 250, 207, 105}, {43, 250, 207, 106}, {43, 250, 207, 108}, {43, 250, 207, 109}}},\n\t\t{Region: \"New Zealand\", Group: \"Premium UDP Asia\", Hostname: \"95-1-nz.cg-dialup.net\", IPs: []net.IP{{43, 250, 207, 98}, {43, 250, 207, 99}, {43, 250, 207, 102}, {43, 250, 207, 104}, {43, 250, 207, 105}, {43, 250, 207, 106}, {43, 250, 207, 107}, {43, 250, 207, 108}, {43, 250, 207, 109}, {43, 250, 207, 110}}},\n\t\t{Region: \"Nigeria\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ng.cg-dialup.net\", IPs: []net.IP{{102, 165, 25, 68}, {102, 165, 25, 69}, {102, 165, 25, 70}, {102, 165, 25, 71}, {102, 165, 25, 72}, {102, 165, 25, 73}, {102, 165, 25, 75}, {102, 165, 25, 76}, {102, 165, 25, 77}, {102, 165, 25, 78}}},\n\t\t{Region: \"Nigeria\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ng.cg-dialup.net\", IPs: []net.IP{{102, 165, 25, 68}, {102, 165, 25, 69}, {102, 165, 25, 70}, {102, 165, 25, 71}, {102, 165, 25, 72}, {102, 165, 25, 74}, {102, 165, 25, 75}, {102, 165, 25, 76}, {102, 165, 25, 77}, {102, 165, 25, 78}}},\n\t\t{Region: \"Norway\", Group: \"Premium TCP Europe\", Hostname: \"97-1-no.cg-dialup.net\", IPs: []net.IP{{45, 12, 223, 137}, {45, 12, 223, 140}, {185, 206, 225, 29}, {185, 206, 225, 231}, {185, 253, 97, 234}, {185, 253, 97, 236}, {185, 253, 97, 238}, {185, 253, 97, 244}, {185, 253, 97, 250}, {185, 253, 97, 254}}},\n\t\t{Region: \"Norway\", Group: \"Premium UDP Europe\", Hostname: \"87-1-no.cg-dialup.net\", IPs: []net.IP{{45, 12, 223, 133}, {45, 12, 223, 134}, {45, 12, 223, 142}, {185, 206, 225, 227}, {185, 206, 225, 228}, {185, 206, 225, 231}, {185, 206, 225, 235}, {185, 253, 97, 237}, {185, 253, 97, 246}, {185, 253, 97, 254}}},\n\t\t{Region: \"Pakistan\", Group: \"Premium TCP Asia\", Hostname: \"96-1-pk.cg-dialup.net\", IPs: []net.IP{{146, 70, 12, 3}, {146, 70, 12, 4}, {146, 70, 12, 6}, {146, 70, 12, 8}, {146, 70, 12, 9}, {146, 70, 12, 10}, {146, 70, 12, 11}, {146, 70, 12, 12}, {146, 70, 12, 13}, {146, 70, 12, 14}}},\n\t\t{Region: \"Pakistan\", Group: \"Premium UDP Asia\", Hostname: \"95-1-pk.cg-dialup.net\", IPs: []net.IP{{146, 70, 12, 4}, {146, 70, 12, 5}, {146, 70, 12, 6}, {146, 70, 12, 7}, {146, 70, 12, 8}, {146, 70, 12, 10}, {146, 70, 12, 11}, {146, 70, 12, 12}, {146, 70, 12, 13}, {146, 70, 12, 14}}},\n\t\t{Region: \"Panama\", Group: \"Premium TCP Europe\", Hostname: \"97-1-pa.cg-dialup.net\", IPs: []net.IP{{91, 90, 126, 131}, {91, 90, 126, 132}, {91, 90, 126, 133}, {91, 90, 126, 134}, {91, 90, 126, 136}, {91, 90, 126, 138}, {91, 90, 126, 139}, {91, 90, 126, 141}, {91, 90, 126, 142}, {91, 90, 126, 145}}},\n\t\t{Region: \"Panama\", Group: \"Premium UDP Europe\", Hostname: \"87-1-pa.cg-dialup.net\", IPs: []net.IP{{91, 90, 126, 131}, {91, 90, 126, 133}, {91, 90, 126, 134}, {91, 90, 126, 135}, {91, 90, 126, 136}, {91, 90, 126, 138}, {91, 90, 126, 140}, {91, 90, 126, 141}, {91, 90, 126, 142}, {91, 90, 126, 145}}},\n\t\t{Region: \"Philippines\", Group: \"Premium TCP Asia\", Hostname: \"96-1-ph.cg-dialup.net\", IPs: []net.IP{{188, 214, 125, 37}, {188, 214, 125, 38}, {188, 214, 125, 40}, {188, 214, 125, 43}, {188, 214, 125, 44}, {188, 214, 125, 45}, {188, 214, 125, 52}, {188, 214, 125, 55}, {188, 214, 125, 61}, {188, 214, 125, 62}}},\n\t\t{Region: \"Philippines\", Group: \"Premium UDP Asia\", Hostname: \"95-1-ph.cg-dialup.net\", IPs: []net.IP{{188, 214, 125, 37}, {188, 214, 125, 40}, {188, 214, 125, 46}, {188, 214, 125, 49}, {188, 214, 125, 52}, {188, 214, 125, 54}, {188, 214, 125, 57}, {188, 214, 125, 58}, {188, 214, 125, 61}, {188, 214, 125, 62}}},\n\t\t{Region: \"Poland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-pl.cg-dialup.net\", IPs: []net.IP{{138, 199, 59, 132}, {138, 199, 59, 136}, {138, 199, 59, 137}, {138, 199, 59, 143}, {138, 199, 59, 144}, {138, 199, 59, 152}, {138, 199, 59, 153}, {138, 199, 59, 166}, {138, 199, 59, 174}, {138, 199, 59, 175}}},\n\t\t{Region: \"Poland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-pl.cg-dialup.net\", IPs: []net.IP{{138, 199, 59, 130}, {138, 199, 59, 136}, {138, 199, 59, 148}, {138, 199, 59, 149}, {138, 199, 59, 153}, {138, 199, 59, 156}, {138, 199, 59, 157}, {138, 199, 59, 164}, {138, 199, 59, 171}, {138, 199, 59, 173}}},\n\t\t{Region: \"Portugal\", Group: \"Premium TCP Europe\", Hostname: \"97-1-pt.cg-dialup.net\", IPs: []net.IP{{89, 26, 243, 112}, {89, 26, 243, 115}, {89, 26, 243, 195}, {89, 26, 243, 216}, {89, 26, 243, 218}, {89, 26, 243, 220}, {89, 26, 243, 222}, {89, 26, 243, 223}, {89, 26, 243, 225}, {89, 26, 243, 228}}},\n\t\t{Region: \"Portugal\", Group: \"Premium UDP Europe\", Hostname: \"87-1-pt.cg-dialup.net\", IPs: []net.IP{{89, 26, 243, 99}, {89, 26, 243, 113}, {89, 26, 243, 115}, {89, 26, 243, 195}, {89, 26, 243, 199}, {89, 26, 243, 216}, {89, 26, 243, 219}, {89, 26, 243, 225}, {89, 26, 243, 226}, {89, 26, 243, 227}}},\n\t\t{Region: \"Qatar\", Group: \"Premium TCP Europe\", Hostname: \"97-1-qa.cg-dialup.net\", IPs: []net.IP{{95, 181, 234, 133}, {95, 181, 234, 135}, {95, 181, 234, 136}, {95, 181, 234, 137}, {95, 181, 234, 138}, {95, 181, 234, 139}, {95, 181, 234, 140}, {95, 181, 234, 141}, {95, 181, 234, 142}, {95, 181, 234, 143}}},\n\t\t{Region: \"Qatar\", Group: \"Premium UDP Europe\", Hostname: \"87-1-qa.cg-dialup.net\", IPs: []net.IP{{95, 181, 234, 131}, {95, 181, 234, 132}, {95, 181, 234, 133}, {95, 181, 234, 134}, {95, 181, 234, 135}, {95, 181, 234, 137}, {95, 181, 234, 138}, {95, 181, 234, 139}, {95, 181, 234, 142}, {95, 181, 234, 143}}},\n\t\t{Region: \"Russian Federation\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ru.cg-dialup.net\", IPs: []net.IP{{5, 8, 16, 72}, {5, 8, 16, 74}, {5, 8, 16, 84}, {5, 8, 16, 85}, {5, 8, 16, 123}, {5, 8, 16, 124}, {5, 8, 16, 132}, {146, 70, 52, 35}, {146, 70, 52, 44}, {146, 70, 52, 54}}},\n\t\t{Region: \"Russian Federation\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ru.cg-dialup.net\", IPs: []net.IP{{5, 8, 16, 75}, {5, 8, 16, 87}, {5, 8, 16, 99}, {5, 8, 16, 110}, {5, 8, 16, 138}, {146, 70, 52, 29}, {146, 70, 52, 52}, {146, 70, 52, 58}, {146, 70, 52, 59}, {146, 70, 52, 67}}},\n\t\t{Region: \"Saudi Arabia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-sa.cg-dialup.net\", IPs: []net.IP{{95, 181, 235, 131}, {95, 181, 235, 133}, {95, 181, 235, 134}, {95, 181, 235, 135}, {95, 181, 235, 137}, {95, 181, 235, 138}, {95, 181, 235, 139}, {95, 181, 235, 140}, {95, 181, 235, 141}, {95, 181, 235, 142}}},\n\t\t{Region: \"Saudi Arabia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-sa.cg-dialup.net\", IPs: []net.IP{{95, 181, 235, 131}, {95, 181, 235, 132}, {95, 181, 235, 134}, {95, 181, 235, 135}, {95, 181, 235, 136}, {95, 181, 235, 137}, {95, 181, 235, 138}, {95, 181, 235, 139}, {95, 181, 235, 141}, {95, 181, 235, 144}}},\n\t\t{Region: \"Serbia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-rs.cg-dialup.net\", IPs: []net.IP{{37, 120, 193, 179}, {37, 120, 193, 186}, {37, 120, 193, 188}, {37, 120, 193, 190}, {141, 98, 103, 36}, {141, 98, 103, 38}, {141, 98, 103, 39}, {141, 98, 103, 43}, {141, 98, 103, 44}, {141, 98, 103, 46}}},\n\t\t{Region: \"Serbia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-rs.cg-dialup.net\", IPs: []net.IP{{37, 120, 193, 180}, {37, 120, 193, 186}, {37, 120, 193, 187}, {37, 120, 193, 188}, {37, 120, 193, 189}, {37, 120, 193, 190}, {141, 98, 103, 35}, {141, 98, 103, 36}, {141, 98, 103, 39}, {141, 98, 103, 41}}},\n\t\t{Region: \"Singapore\", Group: \"Premium TCP Asia\", Hostname: \"96-1-sg.cg-dialup.net\", IPs: []net.IP{{84, 17, 39, 162}, {84, 17, 39, 165}, {84, 17, 39, 168}, {84, 17, 39, 171}, {84, 17, 39, 175}, {84, 17, 39, 177}, {84, 17, 39, 178}, {84, 17, 39, 181}, {84, 17, 39, 183}, {84, 17, 39, 185}}},\n\t\t{Region: \"Singapore\", Group: \"Premium UDP Asia\", Hostname: \"95-1-sg.cg-dialup.net\", IPs: []net.IP{{84, 17, 39, 162}, {84, 17, 39, 165}, {84, 17, 39, 166}, {84, 17, 39, 167}, {84, 17, 39, 171}, {84, 17, 39, 174}, {84, 17, 39, 175}, {84, 17, 39, 178}, {84, 17, 39, 180}, {84, 17, 39, 185}}},\n\t\t{Region: \"Slovakia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-sk.cg-dialup.net\", IPs: []net.IP{{185, 245, 85, 227}, {185, 245, 85, 228}, {185, 245, 85, 229}, {185, 245, 85, 230}, {185, 245, 85, 231}, {185, 245, 85, 232}, {185, 245, 85, 233}, {185, 245, 85, 234}, {185, 245, 85, 235}, {185, 245, 85, 236}}},\n\t\t{Region: \"Slovakia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-sk.cg-dialup.net\", IPs: []net.IP{{185, 245, 85, 227}, {185, 245, 85, 228}, {185, 245, 85, 229}, {185, 245, 85, 230}, {185, 245, 85, 231}, {185, 245, 85, 232}, {185, 245, 85, 233}, {185, 245, 85, 234}, {185, 245, 85, 235}, {185, 245, 85, 236}}},\n\t\t{Region: \"Slovenia\", Group: \"Premium TCP Europe\", Hostname: \"97-1-si.cg-dialup.net\", IPs: []net.IP{{195, 80, 150, 211}, {195, 80, 150, 212}, {195, 80, 150, 214}, {195, 80, 150, 215}, {195, 80, 150, 216}, {195, 80, 150, 217}, {195, 80, 150, 218}, {195, 80, 150, 219}, {195, 80, 150, 221}, {195, 80, 150, 222}}},\n\t\t{Region: \"Slovenia\", Group: \"Premium UDP Europe\", Hostname: \"87-1-si.cg-dialup.net\", IPs: []net.IP{{195, 80, 150, 211}, {195, 80, 150, 212}, {195, 80, 150, 214}, {195, 80, 150, 215}, {195, 80, 150, 216}, {195, 80, 150, 217}, {195, 80, 150, 219}, {195, 80, 150, 220}, {195, 80, 150, 221}, {195, 80, 150, 222}}},\n\t\t{Region: \"South Africa\", Group: \"Premium TCP Asia\", Hostname: \"96-1-za.cg-dialup.net\", IPs: []net.IP{{154, 127, 50, 212}, {154, 127, 50, 215}, {154, 127, 50, 217}, {154, 127, 50, 219}, {154, 127, 50, 220}, {154, 127, 50, 222}, {154, 127, 60, 196}, {154, 127, 60, 198}, {154, 127, 60, 199}, {154, 127, 60, 200}}},\n\t\t{Region: \"South Africa\", Group: \"Premium TCP Europe\", Hostname: \"97-1-za.cg-dialup.net\", IPs: []net.IP{{197, 85, 7, 26}, {197, 85, 7, 27}, {197, 85, 7, 28}, {197, 85, 7, 29}, {197, 85, 7, 30}, {197, 85, 7, 31}, {197, 85, 7, 131}, {197, 85, 7, 132}, {197, 85, 7, 133}, {197, 85, 7, 134}}},\n\t\t{Region: \"South Africa\", Group: \"Premium UDP Asia\", Hostname: \"95-1-za.cg-dialup.net\", IPs: []net.IP{{154, 127, 50, 210}, {154, 127, 50, 214}, {154, 127, 50, 218}, {154, 127, 50, 219}, {154, 127, 50, 220}, {154, 127, 50, 221}, {154, 127, 50, 222}, {154, 127, 60, 195}, {154, 127, 60, 199}, {154, 127, 60, 206}}},\n\t\t{Region: \"South Africa\", Group: \"Premium UDP Europe\", Hostname: \"87-1-za.cg-dialup.net\", IPs: []net.IP{{197, 85, 7, 26}, {197, 85, 7, 27}, {197, 85, 7, 28}, {197, 85, 7, 29}, {197, 85, 7, 30}, {197, 85, 7, 31}, {197, 85, 7, 131}, {197, 85, 7, 132}, {197, 85, 7, 133}, {197, 85, 7, 134}}},\n\t\t{Region: \"Spain\", Group: \"Premium TCP Europe\", Hostname: \"97-1-es.cg-dialup.net\", IPs: []net.IP{{37, 120, 142, 41}, {37, 120, 142, 52}, {37, 120, 142, 55}, {37, 120, 142, 61}, {37, 120, 142, 173}, {84, 17, 62, 131}, {84, 17, 62, 142}, {84, 17, 62, 144}, {185, 93, 3, 108}, {185, 93, 3, 114}}},\n\t\t{Region: \"Sri Lanka\", Group: \"Premium TCP Europe\", Hostname: \"97-1-lk.cg-dialup.net\", IPs: []net.IP{{95, 181, 239, 131}, {95, 181, 239, 132}, {95, 181, 239, 133}, {95, 181, 239, 134}, {95, 181, 239, 135}, {95, 181, 239, 136}, {95, 181, 239, 137}, {95, 181, 239, 138}, {95, 181, 239, 140}, {95, 181, 239, 144}}},\n\t\t{Region: \"Sri Lanka\", Group: \"Premium UDP Europe\", Hostname: \"87-1-lk.cg-dialup.net\", IPs: []net.IP{{95, 181, 239, 131}, {95, 181, 239, 132}, {95, 181, 239, 133}, {95, 181, 239, 134}, {95, 181, 239, 135}, {95, 181, 239, 136}, {95, 181, 239, 140}, {95, 181, 239, 141}, {95, 181, 239, 142}, {95, 181, 239, 144}}},\n\t\t{Region: \"Sweden\", Group: \"Premium TCP Europe\", Hostname: \"97-1-se.cg-dialup.net\", IPs: []net.IP{{188, 126, 73, 207}, {188, 126, 73, 209}, {188, 126, 73, 214}, {188, 126, 73, 219}, {188, 126, 79, 6}, {188, 126, 79, 11}, {188, 126, 79, 19}, {188, 126, 79, 25}, {195, 246, 120, 148}, {195, 246, 120, 161}}},\n\t\t{Region: \"Sweden\", Group: \"Premium UDP Europe\", Hostname: \"87-1-se.cg-dialup.net\", IPs: []net.IP{{188, 126, 73, 201}, {188, 126, 73, 211}, {188, 126, 73, 213}, {188, 126, 73, 218}, {188, 126, 79, 6}, {188, 126, 79, 8}, {188, 126, 79, 19}, {195, 246, 120, 142}, {195, 246, 120, 144}, {195, 246, 120, 168}}},\n\t\t{Region: \"Switzerland\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ch.cg-dialup.net\", IPs: []net.IP{{84, 17, 52, 4}, {84, 17, 52, 20}, {84, 17, 52, 44}, {84, 17, 52, 65}, {84, 17, 52, 72}, {84, 17, 52, 80}, {84, 17, 52, 83}, {84, 17, 52, 85}, {185, 32, 222, 112}, {185, 189, 150, 73}}},\n\t\t{Region: \"Switzerland\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ch.cg-dialup.net\", IPs: []net.IP{{84, 17, 52, 5}, {84, 17, 52, 14}, {84, 17, 52, 24}, {84, 17, 52, 64}, {84, 17, 52, 73}, {84, 17, 52, 85}, {185, 32, 222, 114}, {185, 189, 150, 52}, {185, 189, 150, 57}, {195, 225, 118, 43}}},\n\t\t{Region: \"Taiwan\", Group: \"Premium TCP Asia\", Hostname: \"96-1-tw.cg-dialup.net\", IPs: []net.IP{{45, 133, 181, 100}, {45, 133, 181, 102}, {45, 133, 181, 103}, {45, 133, 181, 106}, {45, 133, 181, 109}, {45, 133, 181, 113}, {45, 133, 181, 115}, {45, 133, 181, 116}, {45, 133, 181, 123}, {45, 133, 181, 125}}},\n\t\t{Region: \"Taiwan\", Group: \"Premium UDP Asia\", Hostname: \"95-1-tw.cg-dialup.net\", IPs: []net.IP{{45, 133, 181, 99}, {45, 133, 181, 102}, {45, 133, 181, 107}, {45, 133, 181, 108}, {45, 133, 181, 109}, {45, 133, 181, 114}, {45, 133, 181, 116}, {45, 133, 181, 117}, {45, 133, 181, 123}, {45, 133, 181, 124}}},\n\t\t{Region: \"Thailand\", Group: \"Premium TCP Asia\", Hostname: \"96-1-th.cg-dialup.net\", IPs: []net.IP{{146, 70, 13, 3}, {146, 70, 13, 4}, {146, 70, 13, 6}, {146, 70, 13, 7}, {146, 70, 13, 8}, {146, 70, 13, 9}, {146, 70, 13, 11}, {146, 70, 13, 13}, {146, 70, 13, 15}, {146, 70, 13, 16}}},\n\t\t{Region: \"Thailand\", Group: \"Premium UDP Asia\", Hostname: \"95-1-th.cg-dialup.net\", IPs: []net.IP{{146, 70, 13, 3}, {146, 70, 13, 4}, {146, 70, 13, 8}, {146, 70, 13, 9}, {146, 70, 13, 10}, {146, 70, 13, 11}, {146, 70, 13, 12}, {146, 70, 13, 13}, {146, 70, 13, 15}, {146, 70, 13, 16}}},\n\t\t{Region: \"Turkey\", Group: \"Premium TCP Europe\", Hostname: \"97-1-tr.cg-dialup.net\", IPs: []net.IP{{188, 213, 34, 9}, {188, 213, 34, 11}, {188, 213, 34, 15}, {188, 213, 34, 16}, {188, 213, 34, 23}, {188, 213, 34, 25}, {188, 213, 34, 28}, {188, 213, 34, 41}, {188, 213, 34, 108}, {188, 213, 34, 110}}},\n\t\t{Region: \"Turkey\", Group: \"Premium UDP Europe\", Hostname: \"87-1-tr.cg-dialup.net\", IPs: []net.IP{{188, 213, 34, 8}, {188, 213, 34, 11}, {188, 213, 34, 14}, {188, 213, 34, 28}, {188, 213, 34, 35}, {188, 213, 34, 42}, {188, 213, 34, 43}, {188, 213, 34, 100}, {188, 213, 34, 103}, {188, 213, 34, 107}}},\n\t\t{Region: \"Ukraine\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ua.cg-dialup.net\", IPs: []net.IP{{31, 28, 161, 18}, {31, 28, 161, 20}, {31, 28, 161, 27}, {31, 28, 163, 34}, {31, 28, 163, 37}, {31, 28, 163, 44}, {62, 149, 7, 167}, {62, 149, 7, 172}, {62, 149, 29, 45}, {62, 149, 29, 57}}},\n\t\t{Region: \"Ukraine\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ua.cg-dialup.net\", IPs: []net.IP{{31, 28, 161, 27}, {31, 28, 163, 38}, {31, 28, 163, 42}, {31, 28, 163, 54}, {31, 28, 163, 61}, {62, 149, 7, 162}, {62, 149, 7, 163}, {62, 149, 29, 35}, {62, 149, 29, 38}, {62, 149, 29, 41}}},\n\t\t{Region: \"United Arab Emirates\", Group: \"Premium TCP Europe\", Hostname: \"97-1-ae.cg-dialup.net\", IPs: []net.IP{{217, 138, 193, 179}, {217, 138, 193, 180}, {217, 138, 193, 181}, {217, 138, 193, 182}, {217, 138, 193, 183}, {217, 138, 193, 184}, {217, 138, 193, 185}, {217, 138, 193, 186}, {217, 138, 193, 188}, {217, 138, 193, 190}}},\n\t\t{Region: \"United Arab Emirates\", Group: \"Premium UDP Europe\", Hostname: \"87-1-ae.cg-dialup.net\", IPs: []net.IP{{217, 138, 193, 179}, {217, 138, 193, 180}, {217, 138, 193, 181}, {217, 138, 193, 182}, {217, 138, 193, 183}, {217, 138, 193, 186}, {217, 138, 193, 187}, {217, 138, 193, 188}, {217, 138, 193, 189}, {217, 138, 193, 190}}},\n\t\t{Region: \"United Kingdom\", Group: \"Premium TCP Europe\", Hostname: \"97-1-gb.cg-dialup.net\", IPs: []net.IP{{45, 133, 173, 49}, {45, 133, 173, 56}, {45, 133, 173, 82}, {45, 133, 173, 86}, {95, 154, 200, 153}, {95, 154, 200, 156}, {181, 215, 176, 103}, {181, 215, 176, 246}, {181, 215, 176, 251}, {194, 110, 13, 141}}},\n\t\t{Region: \"United Kingdom\", Group: \"Premium UDP Europe\", Hostname: \"87-1-gb.cg-dialup.net\", IPs: []net.IP{{45, 133, 172, 100}, {45, 133, 172, 126}, {45, 133, 173, 84}, {95, 154, 200, 174}, {181, 215, 176, 110}, {181, 215, 176, 151}, {181, 215, 176, 158}, {191, 101, 209, 142}, {194, 110, 13, 107}, {194, 110, 13, 128}}},\n\t\t{Region: \"United States\", Group: \"Premium TCP USA\", Hostname: \"93-1-us.cg-dialup.net\", IPs: []net.IP{{102, 129, 145, 15}, {102, 129, 152, 195}, {102, 129, 152, 248}, {154, 21, 208, 159}, {185, 242, 5, 117}, {185, 242, 5, 123}, {185, 242, 5, 229}, {191, 96, 227, 173}, {191, 96, 227, 196}, {199, 115, 119, 248}}},\n\t\t{Region: \"United States\", Group: \"Premium UDP USA\", Hostname: \"94-1-us.cg-dialup.net\", IPs: []net.IP{{23, 82, 14, 113}, {23, 105, 177, 122}, {45, 89, 173, 222}, {84, 17, 35, 4}, {89, 187, 171, 132}, {156, 146, 37, 45}, {156, 146, 59, 86}, {184, 170, 240, 231}, {191, 96, 150, 248}, {199, 115, 119, 248}}},\n\t\t{Region: \"Venezuela\", Group: \"Premium TCP USA\", Hostname: \"93-1-ve.cg-dialup.net\", IPs: []net.IP{{95, 181, 237, 132}, {95, 181, 237, 133}, {95, 181, 237, 134}, {95, 181, 237, 135}, {95, 181, 237, 136}, {95, 181, 237, 138}, {95, 181, 237, 139}, {95, 181, 237, 140}, {95, 181, 237, 141}, {95, 181, 237, 143}}},\n\t\t{Region: \"Venezuela\", Group: \"Premium UDP USA\", Hostname: \"94-1-ve.cg-dialup.net\", IPs: []net.IP{{95, 181, 237, 131}, {95, 181, 237, 132}, {95, 181, 237, 134}, {95, 181, 237, 135}, {95, 181, 237, 136}, {95, 181, 237, 140}, {95, 181, 237, 141}, {95, 181, 237, 142}, {95, 181, 237, 143}, {95, 181, 237, 144}}},\n\t\t{Region: \"Vietnam\", Group: \"Premium TCP Asia\", Hostname: \"96-1-vn.cg-dialup.net\", IPs: []net.IP{{188, 214, 152, 99}, {188, 214, 152, 101}, {188, 214, 152, 103}, {188, 214, 152, 104}, {188, 214, 152, 105}, {188, 214, 152, 106}, {188, 214, 152, 107}, {188, 214, 152, 108}, {188, 214, 152, 109}, {188, 214, 152, 110}}},\n\t\t{Region: \"Vietnam\", Group: \"Premium UDP Asia\", Hostname: \"95-1-vn.cg-dialup.net\", IPs: []net.IP{{188, 214, 152, 99}, {188, 214, 152, 100}, {188, 214, 152, 101}, {188, 214, 152, 102}, {188, 214, 152, 103}, {188, 214, 152, 104}, {188, 214, 152, 105}, {188, 214, 152, 106}, {188, 214, 152, 107}, {188, 214, 152, 109}}},\n\t}\n}", "func getNameServerAddressListFromCmd(nameSrvAdders *string) *singlylinkedlist.List {\n\tif nameSrvAdders != nil {\n\t\tif *nameSrvAdders == \"\" {\n\t\t\treturn nil\n\t\t}\n\t\tnameSrvAdderArr := strings.Split(*nameSrvAdders, \";\")\n\t\tif len(nameSrvAdderArr) == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tnameServerAddressList := singlylinkedlist.New()\n\t\tfor _, nameServerAddress := range nameSrvAdderArr {\n\t\t\tnameServerAddressList.Add(nameServerAddress)\n\t\t}\n\t\treturn nameServerAddressList\n\t}\n\treturn nil\n}", "func (m *VpnConfiguration) SetServers(value []VpnServerable)() {\n err := m.GetBackingStore().Set(\"servers\", value)\n if err != nil {\n panic(err)\n }\n}", "func (g *Gandi) ListDomains() (domains []Domain, err error) {\n\t_, err = g.askGandi(mGET, \"domains\", nil, &domains)\n\treturn\n}", "func (c *Client) DNSNameservers(ctx context.Context) ([]string, error) {\n\tconst uriFmt = \"/api/v2/domain/%v/dns/nameservers\"\n\n\treq, err := c.buildRequest(ctx, http.MethodGet, fmt.Sprintf(uriFmt, c.domain), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar resp DomainDNSNameservers\n\tif err = c.performRequest(req, &resp); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn resp.DNS, nil\n}", "func ListDockerHosts(w http.ResponseWriter, r *http.Request) {\n\t// let's get all host uri from map.\n\tvar hosts []string\n\tfor host, _ := range clientMap {\n\t\thosts = append(hosts, host)\n\t}\n\t// map with list of hosts\n\tresponse := make(map[string][]string)\n\tresponse[\"hosts\"] = hosts\n\t// convert map to json\n\tjsonString, err := json.Marshal(response)\n\tif err != nil {\n\t\tfmt.Fprintln(w,\"{ \\\"error\\\" : \\\"Internal server error\\\" }\")\n\t}\n\tfmt.Fprintln(w,string(jsonString))\n}", "func getDNSConf() []string {\n\tservers := []string{}\n\t_, err := os.Stat(\"/etc/resolv.conf\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tj, _ := dns.ClientConfigFromFile(\"/etc/resolv.conf\")\n\n\tservers = append(servers, fmt.Sprintf(\"%s:53\", j.Servers[0]))\n\tif len(servers) < 2 {\n\t\tservers = append(servers, fmt.Sprintf(\"%s:53\", j.Servers[0]))\n\t} else {\n\t\tservers = append(servers, fmt.Sprintf(\"%s:53\", j.Servers[1]))\n\t}\n\n\treturn servers\n\n}", "func (c *Client) VirtualServerList() []A10VServer {\n\treturn a10VirtualServerList(c.debugf, c.host, c.sessionID)\n}", "func (c *FakeGBPServers) List(opts v1.ListOptions) (result *aciawv1.GBPServerList, err error) {\n\tobj, err := c.Fake.\n\t\tInvokes(testing.NewListAction(gbpserversResource, gbpserversKind, c.ns, opts), &aciawv1.GBPServerList{})\n\n\tif obj == nil {\n\t\treturn nil, err\n\t}\n\n\tlabel, _, _ := testing.ExtractFromListOptions(opts)\n\tif label == nil {\n\t\tlabel = labels.Everything()\n\t}\n\tlist := &aciawv1.GBPServerList{ListMeta: obj.(*aciawv1.GBPServerList).ListMeta}\n\tfor _, item := range obj.(*aciawv1.GBPServerList).Items {\n\t\tif label.Matches(labels.Set(item.Labels)) {\n\t\t\tlist.Items = append(list.Items, item)\n\t\t}\n\t}\n\treturn list, err\n}", "func (p *PorterHelper) List() (map[string]string, error) {\n\tentries := p.Cache.List()\n\n\tres := make(map[string]string)\n\n\tfor _, entry := range entries {\n\t\tres[entry.ProxyEndpoint] = entry.AuthorizationToken\n\t}\n\n\treturn res, nil\n}", "func (d *DhcpOptions) UnmarshalJSON(data []byte) error {\n\tvar rawMsg map[string]json.RawMessage\n\tif err := json.Unmarshal(data, &rawMsg); err != nil {\n\t\treturn fmt.Errorf(\"unmarshalling type %T: %v\", d, err)\n\t}\n\tfor key, val := range rawMsg {\n\t\tvar err error\n\t\tswitch key {\n\t\tcase \"dnsServers\":\n\t\t\terr = unpopulate(val, \"DNSServers\", &d.DNSServers)\n\t\t\tdelete(rawMsg, key)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unmarshalling type %T: %v\", d, err)\n\t\t}\n\t}\n\treturn nil\n}", "func (o *NodeUpdate) GetDnsServers() []string {\n\tif o == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\n\treturn o.DnsServers\n}", "func listDatacenters(c context.Context, names stringset.Set) ([]*crimson.Datacenter, error) {\n\tdb := database.Get(c)\n\trows, err := db.QueryContext(c, `\n\t\tSELECT name, description, state\n\t\tFROM datacenters\n\t`)\n\tif err != nil {\n\t\treturn nil, errors.Annotate(err, \"failed to fetch datacenters\").Err()\n\t}\n\tdefer rows.Close()\n\n\tvar datacenters []*crimson.Datacenter\n\tfor rows.Next() {\n\t\tdc := &crimson.Datacenter{}\n\t\tif err = rows.Scan(&dc.Name, &dc.Description, &dc.State); err != nil {\n\t\t\treturn nil, errors.Annotate(err, \"failed to fetch datacenter\").Err()\n\t\t}\n\t\tif matches(dc.Name, names) {\n\t\t\tdatacenters = append(datacenters, dc)\n\t\t}\n\t}\n\treturn datacenters, nil\n}", "func (d *DHCPv4) DNS() []net.IP {\n\treturn GetIPs(OptionDomainNameServer, d.Options)\n}", "func (i *InstanceServiceHandler) ListIPv4(ctx context.Context, instanceID string, options *ListOptions) ([]IPv4, *Meta, error) {\n\turi := fmt.Sprintf(\"%s/%s/ipv4\", instancePath, instanceID)\n\treq, err := i.client.NewRequest(ctx, http.MethodGet, uri, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tnewValues, err := query.Values(options)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treq.URL.RawQuery = newValues.Encode()\n\tips := new(ipBase)\n\tif err = i.client.DoWithContext(ctx, req, ips); err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn ips.IPv4s, ips.Meta, nil\n}", "func (c *Client) ListFlavorZones(args *ListFlavorZonesArgs) (*ListZonesResult, error) {\n\tjsonBytes, jsonErr := json.Marshal(args)\n\tif jsonErr != nil {\n\t\treturn nil, jsonErr\n\t}\n\tbody, err := bce.NewBodyFromBytes(jsonBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ListFlavorZones(c, body)\n}", "func (c *Client) DBList() []string {\n\tres, _ := r.DBList().Run(c.session)\n\tdbs := []string{}\n\tres.All(&dbs)\n\treturn dbs\n}", "func (c *Client) ListZoneFlavors(args *ListZoneFlavorsArgs) (*ListFlavorInfosResult, error) {\n\tjsonBytes, jsonErr := json.Marshal(args)\n\tif jsonErr != nil {\n\t\treturn nil, jsonErr\n\t}\n\tbody, err := bce.NewBodyFromBytes(jsonBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn ListZoneFlavors(c, body)\n}", "func (s *dnsManagedZoneLister) List(selector labels.Selector) (ret []*v1alpha1.DnsManagedZone, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1alpha1.DnsManagedZone))\n\t})\n\treturn ret, err\n}", "func DSList(dss ...kapisext.DaemonSet) kapisext.DaemonSetList {\n\treturn kapisext.DaemonSetList{\n\t\tItems: dss,\n\t}\n}", "func (api *hostAPI) ApisrvList(ctx context.Context, opts *api.ListWatchOptions) ([]*cluster.Host, error) {\n\tif api.ct.resolver != nil {\n\t\tapicl, err := api.ct.apiClient()\n\t\tif err != nil {\n\t\t\tapi.ct.logger.Errorf(\"Error creating API server clent. Err: %v\", err)\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn apicl.ClusterV1().Host().List(context.Background(), opts)\n\t}\n\n\t// List from local cache\n\tctkitObjs, err := api.List(ctx, opts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar ret []*cluster.Host\n\tfor _, obj := range ctkitObjs {\n\t\tret = append(ret, &obj.Host)\n\t}\n\treturn ret, nil\n}", "func (o *ZoneZone) GetNameservers() []string {\n\tif o == nil || o.Nameservers == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn *o.Nameservers\n}", "func (g *Domain) GetNameServers(domain string) (nameservers []string, err error) {\n\t_, err = g.client.Get(\"domains/\"+domain+\"/nameservers\", nil, &nameservers)\n\treturn\n}", "func (a Agent) VirtualServerList() ([]VirtualServer, error) {\n\tlist, err := a.VirtualServerIDList()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvServers := make([]VirtualServer, len(list))\n\tfor i := range list {\n\t\tvServer, err := a.VirtualServer(list[i])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tvServers[i] = *vServer\n\t}\n\treturn vServers, nil\n}", "func (c *daemonSetsClass) getList(ns string, listOptions meta.ListOptions) (*kext.DaemonSetList, error) {\n\treturn c.rk.clientset.Extensions().DaemonSets(ns).List(listOptions)\n}", "func (h *HTTPApi) listDatasourceInstance(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tdatasourceInstances := make([]string, 0, len(h.storageNode.Datasources))\n\tfor k := range h.storageNode.Datasources {\n\t\tdatasourceInstances = append(datasourceInstances, k)\n\t}\n\n\t// Now we need to return the results\n\tif bytes, err := json.Marshal(datasourceInstances); err != nil {\n\t\t// TODO: log this better?\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t} else {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write(bytes)\n\t}\n}", "func (i *DHCPInterface) SetNTPServers(ntp []string) {\n\tfor _, server := range ntp {\n\t\ti.ntpServers = append(i.ntpServers, []byte(net.ParseIP(server).To4())...)\n\t}\n}", "func (client DnsClient) ListZones(ctx context.Context, request ListZonesRequest) (response ListZonesResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listZones, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListZonesResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListZonesResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListZonesResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListZonesResponse\")\n\t}\n\treturn\n}", "func (client WorkloadNetworksClient) ListDhcpPreparer(ctx context.Context, resourceGroupName string, privateCloudName string) (*http.Request, error) {\n\tpathParameters := map[string]interface{}{\n\t\t\"privateCloudName\": autorest.Encode(\"path\", privateCloudName),\n\t\t\"resourceGroupName\": autorest.Encode(\"path\", resourceGroupName),\n\t\t\"subscriptionId\": autorest.Encode(\"path\", client.SubscriptionID),\n\t}\n\n\tconst APIVersion = \"2020-07-17-preview\"\n\tqueryParameters := map[string]interface{}{\n\t\t\"api-version\": APIVersion,\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsGet(),\n\t\tautorest.WithBaseURL(client.BaseURI),\n\t\tautorest.WithPathParameters(\"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AVS/privateClouds/{privateCloudName}/workloadNetworks/default/dhcpConfigurations\", pathParameters),\n\t\tautorest.WithQueryParameters(queryParameters))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func (client DatabasesClient) ListByServerResponder(resp *http.Response) (result DatabaseListResult, err error) {\n\terr = autorest.Respond(\n\t\tresp,\n\t\tclient.ByInspecting(),\n\t\tazure.WithErrorUnlessStatusCode(http.StatusOK),\n\t\tautorest.ByUnmarshallingJSON(&result),\n\t\tautorest.ByClosing())\n\tresult.Response = autorest.Response{Response: resp}\n\treturn\n}", "func (o GroupDnsConfigPtrOutput) Nameservers() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *GroupDnsConfig) []string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Nameservers\n\t}).(pulumi.StringArrayOutput)\n}", "func getDNSNameservers(resolvConfPath string) ([]string, error) {\n\tif resolvConfPath == \"\" {\n\t\tresolvConfPath = defaultResolvConfPath\n\t}\n\n\tfile, err := os.Open(resolvConfPath)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"Could not open '%s'.\", resolvConfPath)\n\t}\n\tdefer mustClose(file)\n\n\tscanner := bufio.NewScanner(file)\n\n\tvar servers []string\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tmatch := resolvConfNameserverPattern.FindStringSubmatch(line)\n\t\tif len(match) == 2 {\n\t\t\tservers = append(servers, match[1])\n\t\t}\n\t}\n\n\tif err = scanner.Err(); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"Could not read '%s'.\", resolvConfPath)\n\t}\n\n\tif len(servers) == 0 {\n\t\treturn nil, errors.Errorf(\"No nameservers found in '%s'.\", resolvConfPath)\n\t}\n\n\treturn servers, nil\n}", "func List(_ machine.ListOptions) ([]*machine.ListResponse, error) {\n\treturn GetVMInfos()\n}", "func AdminListDynamicConfig(c *cli.Context) {\n\tadminClient := cFactory.ServerAdminClient(c)\n\n\tctx, cancel := newContext(c)\n\tdefer cancel()\n\n\treq := &types.ListDynamicConfigRequest{\n\t\tConfigName: dynamicconfig.UnknownKey.String(),\n\t}\n\n\tval, err := adminClient.ListDynamicConfig(ctx, req)\n\tif err != nil {\n\t\tErrorAndExit(\"Failed to list dynamic config value(s)\", err)\n\t}\n\n\tif val == nil || val.Entries == nil || len(val.Entries) == 0 {\n\t\tfmt.Printf(\"No dynamic config values stored to list.\\n\")\n\t} else {\n\t\tcliEntries := make([]*cliEntry, 0, len(val.Entries))\n\t\tfor _, dcEntry := range val.Entries {\n\t\t\tcliEntry, err := convertToInputEntry(dcEntry)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Printf(\"Cannot parse list response.\\n\")\n\t\t\t}\n\t\t\tcliEntries = append(cliEntries, cliEntry)\n\t\t}\n\t\tprettyPrintJSONObject(cliEntries)\n\t}\n}", "func (client *Client) ShowHostMaps(host string) ([]Volume, *ResponseStatus, error) {\n\tif len(host) > 0 {\n\t\thost = fmt.Sprintf(\"\\\"%s\\\"\", host)\n\t}\n\tres, status, err := client.FormattedRequest(\"/show/host-maps/%s\", host)\n\tif err != nil {\n\t\treturn nil, status, err\n\t}\n\n\tmappings := make([]Volume, 0)\n\tfor _, rootObj := range res.Objects {\n\t\tif rootObj.Name != \"host-view\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tfor _, object := range rootObj.Objects {\n\t\t\tif object.Name == \"volume-view\" {\n\t\t\t\tvol := Volume{}\n\t\t\t\tvol.fillFromObject(&object)\n\t\t\t\tmappings = append(mappings, vol)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn mappings, status, err\n}", "func (s *GetServersInput) SetVmServerAddressList(v []*VmServerAddress) *GetServersInput {\n\ts.VmServerAddressList = v\n\treturn s\n}", "func (k *kvSender) updateServerListCache(vbmap *protobuf.VbmapResponse) {\n\n\t//clear the cache\n\tk.serverListCache = k.serverListCache[:0]\n\n\t//update the cache\n\tfor _, kv := range vbmap.GetKvaddrs() {\n\t\tk.serverListCache = append(k.serverListCache, kv)\n\t}\n\n}", "func (i *InstanceServiceHandler) ListPrivateNetworks(ctx context.Context, instanceID string, options *ListOptions) ([]PrivateNetwork, *Meta, error) {\n\turi := fmt.Sprintf(\"%s/%s/private-networks\", instancePath, instanceID)\n\treq, err := i.client.NewRequest(ctx, http.MethodGet, uri, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tnewValues, err := query.Values(options)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treq.URL.RawQuery = newValues.Encode()\n\n\tnetworks := new(privateNetworksBase)\n\tif err = i.client.DoWithContext(ctx, req, networks); err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\treturn networks.PrivateNetworks, networks.Meta, nil\n}", "func (s *DataStore) ListReplicas() (map[string]*longhorn.Replica, error) {\n\treturn s.listReplicas(labels.Everything())\n}", "func (i *DHCPInterface) ServeDHCP(p dhcp.Packet, msgType dhcp.MessageType, options dhcp.Options) dhcp.Packet {\n\tvar respMsg dhcp.MessageType\n\n\tswitch msgType {\n\tcase dhcp.Discover:\n\t\trespMsg = dhcp.Offer\n\tcase dhcp.Request:\n\t\trespMsg = dhcp.ACK\n\t}\n\n\tif respMsg != 0 {\n\t\trequestingMAC := p.CHAddr().String()\n\n\t\tif requestingMAC == i.MACFilter {\n\t\t\topts := dhcp.Options{\n\t\t\t\tdhcp.OptionSubnetMask: []byte(i.VMIPNet.Mask),\n\t\t\t\tdhcp.OptionRouter: []byte(*i.GatewayIP),\n\t\t\t\tdhcp.OptionDomainNameServer: i.dnsServers,\n\t\t\t\tdhcp.OptionHostName: []byte(i.Hostname),\n\t\t\t}\n\n\t\t\tif netRoutes := formClasslessRoutes(&i.Routes); netRoutes != nil {\n\t\t\t\topts[dhcp.OptionClasslessRouteFormat] = netRoutes\n\t\t\t}\n\n\t\t\tif i.ntpServers != nil {\n\t\t\t\topts[dhcp.OptionNetworkTimeProtocolServers] = i.ntpServers\n\t\t\t}\n\n\t\t\toptSlice := opts.SelectOrderOrAll(options[dhcp.OptionParameterRequestList])\n\n\t\t\treturn dhcp.ReplyPacket(p, respMsg, *i.GatewayIP, i.VMIPNet.IP, leaseDuration, optSlice)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (vc *VirtualCenter) ListDatacenters(ctx context.Context) (\n\t[]*Datacenter, error) {\n\tlog := logger.GetLogger(ctx)\n\tif err := vc.Connect(ctx); err != nil {\n\t\tlog.Errorf(\"failed to connect to vCenter. err: %v\", err)\n\t\treturn nil, err\n\t}\n\tfinder := find.NewFinder(vc.Client.Client, false)\n\tdcList, err := finder.DatacenterList(ctx, \"*\")\n\tif err != nil {\n\t\tlog.Errorf(\"failed to list datacenters with err: %v\", err)\n\t\treturn nil, err\n\t}\n\n\tvar dcs []*Datacenter\n\tfor _, dcObj := range dcList {\n\t\tdc := &Datacenter{Datacenter: dcObj, VirtualCenterHost: vc.Config.Host}\n\t\tdcs = append(dcs, dc)\n\t}\n\treturn dcs, nil\n}", "func Start(config *config.Config) (*Servers, error) {\n\thandlers4, handlers6, err := plugins.LoadPlugins(config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsrv := Servers{\n\t\terrors: make(chan error),\n\t}\n\n\t// listen\n\tif config.Server6 != nil {\n\t\tlog.Println(\"Starting DHCPv6 server\")\n\t\tfor _, addr := range config.Server6.Addresses {\n\t\t\tvar l6 *listener6\n\t\t\tl6, err = listen6(&addr)\n\t\t\tif err != nil {\n\t\t\t\tgoto cleanup\n\t\t\t}\n\t\t\tl6.handlers = handlers6\n\t\t\tsrv.listeners = append(srv.listeners, l6)\n\t\t\tgo func() {\n\t\t\t\tsrv.errors <- l6.Serve()\n\t\t\t}()\n\t\t}\n\t}\n\n\tif config.Server4 != nil {\n\t\tlog.Println(\"Starting DHCPv4 server\")\n\t\tfor _, addr := range config.Server4.Addresses {\n\t\t\tvar l4 *listener4\n\t\t\tl4, err = listen4(&addr)\n\t\t\tif err != nil {\n\t\t\t\tgoto cleanup\n\t\t\t}\n\t\t\tl4.handlers = handlers4\n\t\t\tsrv.listeners = append(srv.listeners, l4)\n\t\t\tgo func() {\n\t\t\t\tsrv.errors <- l4.Serve()\n\t\t\t}()\n\t\t}\n\t}\n\n\treturn &srv, nil\n\ncleanup:\n\tsrv.Close()\n\treturn nil, err\n}", "func ListTimezonesHandler(w http.ResponseWriter, r *http.Request) {\n\ttimezones, err := database.GetAllTimezones()\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tresults, _ := json.Marshal(timezones)\n\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(results)\n}", "func listVMs(c context.Context, q database.QueryerContext, req *crimson.ListVMsRequest) ([]*crimson.VM, error) {\n\tipv4s, err := parseIPv4s(req.Ipv4S)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tstmt := squirrel.Select(\n\t\t\"hv.name\",\n\t\t\"hv.vlan_id\",\n\t\t\"hp.name\",\n\t\t\"hp.vlan_id\",\n\t\t\"o.name\",\n\t\t\"v.description\",\n\t\t\"v.deployment_ticket\",\n\t\t\"i.ipv4\",\n\t\t\"v.state\",\n\t)\n\tstmt = stmt.From(\"vms v, hostnames hv, physical_hosts p, hostnames hp, oses o, ips i\").\n\t\tWhere(\"v.hostname_id = hv.id\").\n\t\tWhere(\"v.physical_host_id = p.id\").\n\t\tWhere(\"p.hostname_id = hp.id\").\n\t\tWhere(\"v.os_id = o.id\").\n\t\tWhere(\"i.hostname_id = hv.id\")\n\tstmt = selectInString(stmt, \"hv.name\", req.Names)\n\tstmt = selectInInt64(stmt, \"hv.vlan_id\", req.Vlans)\n\tstmt = selectInInt64(stmt, \"i.ipv4\", ipv4s)\n\tstmt = selectInString(stmt, \"hp.name\", req.Hosts)\n\tstmt = selectInInt64(stmt, \"hp.vlan_id\", req.HostVlans)\n\tstmt = selectInString(stmt, \"o.name\", req.Oses)\n\tstmt = selectInState(stmt, \"v.state\", req.States)\n\tquery, args, err := stmt.ToSql()\n\tif err != nil {\n\t\treturn nil, errors.Annotate(err, \"failed to generate statement\").Err()\n\t}\n\n\trows, err := q.QueryContext(c, query, args...)\n\tif err != nil {\n\t\treturn nil, errors.Annotate(err, \"failed to fetch VMs\").Err()\n\t}\n\tdefer rows.Close()\n\tvar vms []*crimson.VM\n\tfor rows.Next() {\n\t\tv := &crimson.VM{}\n\t\tvar ipv4 common.IPv4\n\t\tif err = rows.Scan(\n\t\t\t&v.Name,\n\t\t\t&v.Vlan,\n\t\t\t&v.Host,\n\t\t\t&v.HostVlan,\n\t\t\t&v.Os,\n\t\t\t&v.Description,\n\t\t\t&v.DeploymentTicket,\n\t\t\t&ipv4,\n\t\t\t&v.State,\n\t\t); err != nil {\n\t\t\treturn nil, errors.Annotate(err, \"failed to fetch VM\").Err()\n\t\t}\n\t\tv.Ipv4 = ipv4.String()\n\t\tvms = append(vms, v)\n\t}\n\treturn vms, nil\n}" ]
[ "0.5871556", "0.57992846", "0.5637868", "0.5621159", "0.561796", "0.55982745", "0.5547308", "0.5486327", "0.5452146", "0.5445553", "0.5430095", "0.5428605", "0.5427161", "0.53797334", "0.5372634", "0.53152144", "0.5299417", "0.52930343", "0.5261868", "0.5255848", "0.52518666", "0.5201575", "0.5200406", "0.51966465", "0.51674825", "0.5159501", "0.51589966", "0.5156744", "0.5146874", "0.51299787", "0.5116046", "0.5096171", "0.5064668", "0.50444514", "0.5004254", "0.499411", "0.49530444", "0.4942069", "0.49324647", "0.49231845", "0.49230257", "0.49160486", "0.49139962", "0.48982298", "0.48870382", "0.48858282", "0.48809054", "0.48762622", "0.48684943", "0.4860596", "0.48594922", "0.48374856", "0.48371267", "0.4835746", "0.4830727", "0.48197433", "0.48010135", "0.47998422", "0.47952172", "0.47918957", "0.4780157", "0.47619763", "0.47508544", "0.47504663", "0.47467673", "0.4742025", "0.4739674", "0.47313166", "0.47272465", "0.47165543", "0.4712249", "0.47037864", "0.47033155", "0.4702828", "0.46982178", "0.46952233", "0.469375", "0.4685327", "0.46825144", "0.46762642", "0.4672919", "0.46721554", "0.46717206", "0.466471", "0.4664619", "0.46601772", "0.4660026", "0.46597272", "0.46484014", "0.46411267", "0.46404326", "0.4640408", "0.46389467", "0.46321505", "0.46215233", "0.46207544", "0.4620066", "0.46153277", "0.46140847", "0.46130762" ]
0.8791519
0
parseIPv4Mask parses IPv4 netmask written in IP form (e.g. 255.255.255.0). This function should really belong to the net package.
func parseIPv4Mask(s string) net.IPMask { mask := net.ParseIP(s) if mask == nil { return nil } return net.IPv4Mask(mask[12], mask[13], mask[14], mask[15]) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func parseMask4(s string) (mask Prefix, i int) {\n\ti = len(s)\n\tif i == 0 {\n\t\treturn 0, 0\n\t}\n\tif !isD(s[0]) {\n\t\treturn 0, 0\n\t}\n\tmask = Prefix(s[0] - '0')\n\tif i == 1 || !isD(s[1]) {\n\t\treturn mask, 1\n\t}\n\tmask = mask*10 + Prefix(s[1]-'0')\n\tif mask > 32 {\n\t\treturn 0, 0\n\t}\n\tif i == 2 || !isD(s[2]) {\n\t\treturn mask, 2\n\t}\n\treturn 0, 0\n}", "func ParseIPv4(ip string) ([]net.IP, error) {\n\tparts := strings.Split(ip, \"/\")\n\tif len(parts) > 2 {\n\t\treturn nil, fmt.Errorf(\"parse/ParseIPv4: Invalid IP Address %s\", ip)\n\t}\n\n\tips, err := parseIPv4(parts[0])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar cidr int64\n\n\tif len(parts) != 2 {\n\t\tcidr = 32\n\t} else {\n\n\t\tcidr, err = strconv.ParseInt(parts[1], 0, 8)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif cidr > 32 {\n\t\t\treturn nil, fmt.Errorf(\"parse/ParseIPv4: Invalid IP Address %s: Invalid CIDR notation\", ip)\n\t\t}\n\t}\n\n\treturn parseIPv4CIDR(ips, net.CIDRMask(int(cidr), 32))\n}", "func ParseIPv4AndCIDR(data string) []*net.IPNet {\n\tfmt.Println(\"data: \", data)\n\tvar reIPv4 = regexp.MustCompile(`(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])+)(\\/(3[0-2]|[1-2][0-9]|[0-9]))?`)\n\t//var reIPv4 = regexp.MustCompile(`(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/(3[0-2]|[1-2][0-9]|[0-9]))`)\n\tscanner := bufio.NewScanner(strings.NewReader(data))\n\n\taddrs := make([]*net.IPNet, 0)\n\tfor scanner.Scan() {\n\t\tx := reIPv4.FindString(scanner.Text())\n\t\tfmt.Println(\"in ParseIPv4AndCIDR, x: \", x)\n\t\tif !strings.Contains(x, \"/\") {\n\t\t\tif !strings.Contains(x, \":\") {\n\t\t\t\tx = x + \"/32\"\n\t\t\t} else {\n\t\t\t\tx = x + \"/128\"\n\t\t\t}\n\t\t}\n\t\tif addr, cidr, e := net.ParseCIDR(x); e == nil {\n\t\t\t//if !ipv4.IsRFC4193(addr) && !ipv4.IsLoopback(addr) && !ipv4.IsBogonIP(addr) {\n\t\t\tif !IsLoopback(addr) && !IsBogonIP(addr) {\n\t\t\t\taddrs = append(addrs, cidr)\n\t\t\t}\n\t\t}\n\t}\n\treturn addrs\n}", "func WithIPv4Mask(mask net.IPMask) Option {\n\treturn func(o *Options) {\n\t\to.IPv4Mask = mask\n\t}\n}", "func ParseIPv4(data []byte) (Packet, error) {\n\tif len(data) < 20 {\n\t\treturn nil, ErrorTruncated\n\t}\n\tihl := int(data[0] & 0x0f)\n\theaderLen := ihl * 4\n\tlength := int(bo.Uint16(data[2:]))\n\n\tif headerLen < 20 || headerLen > length {\n\t\treturn nil, ErrorInvalid\n\t}\n\tif length > len(data) {\n\t\treturn nil, ErrorTruncated\n\t}\n\tif Checksum(data[0:headerLen]) != 0 {\n\t\treturn nil, ErrorChecksum\n\t}\n\n\treturn &IPv4{\n\t\tversion: int(data[0] >> 4),\n\t\ttos: int(data[1]),\n\t\tid: bo.Uint16(data[4:]),\n\t\tflags: int8(data[6] >> 5),\n\t\toffset: bo.Uint16(data[6:]) & 0x1fff,\n\t\tttl: data[8],\n\t\tprotocol: Protocol(data[9]),\n\t\tsrc: net.IP(data[12:16]),\n\t\tdst: net.IP(data[16:20]),\n\t\tdata: data[headerLen:length],\n\t}, nil\n}", "func (i Internet) Ipv4() string {\n\tips := make([]string, 0, 4)\n\n\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(1, 255)))\n\tfor j := 0; j < 3; j++ {\n\t\tips = append(ips, strconv.Itoa(i.Faker.IntBetween(0, 255)))\n\t}\n\n\treturn strings.Join(ips, \".\")\n}", "func parseIPv4(ip string) net.IP {\n\tif parsedIP := net.ParseIP(strings.TrimSpace(ip)); parsedIP != nil {\n\t\tif ipv4 := parsedIP.To4(); ipv4 != nil {\n\t\t\treturn ipv4\n\t\t}\n\t}\n\n\treturn nil\n}", "func IsValidIP4(ipAddress string) bool {\n\tipAddress = strings.Trim(ipAddress, \" \")\n\tif !regexp.MustCompile(`^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$`).\n\t\tMatchString(ipAddress) {\n\t\treturn false\n\t}\n\treturn true\n}", "func ParseProxyIPV4(ip string) (*pb.IPAddress, error) {\n\tnetIP := net.ParseIP(ip)\n\tif netIP == nil {\n\t\treturn nil, fmt.Errorf(\"Invalid IP address: %s\", ip)\n\t}\n\n\toBigInt := IPToInt(netIP.To4())\n\treturn &pb.IPAddress{\n\t\tIp: &pb.IPAddress_Ipv4{\n\t\t\tIpv4: uint32(oBigInt.Uint64()),\n\t\t},\n\t}, nil\n}", "func parseIPv4(s string) (ip ipOctets, cc int) {\n\tip = make(ipOctets, net.IPv4len)\n\n\tfor i := 0; i < net.IPv4len; i++ {\n\t\tip[i] = make([]ipOctet, 0)\n\t}\n\n\tvar bb [2]uint16 // octet bounds: 0 - lo, 1 - hi\n\n\ti := 0 // octet idx\n\tk := 0 // bound idx: 0 - lo, 1 - hi\n\nloop:\n\tfor i < net.IPv4len {\n\t\t// Decimal number.\n\t\tn, c, ok := dtoi(s)\n\t\tif !ok || n > 0xFF {\n\t\t\treturn nil, cc\n\t\t}\n\n\t\t// Save bound.\n\t\tbb[k] = uint16(n)\n\n\t\t// Stop at max of string.\n\t\ts = s[c:]\n\t\tcc += c\n\t\tif len(s) == 0 {\n\t\t\tip.push(i, bb[0], bb[1])\n\t\t\ti++\n\t\t\tbreak\n\t\t}\n\n\t\t// Otherwise must be followed by dot, colon or dp.\n\t\tswitch s[0] {\n\t\tcase '.':\n\t\t\tfallthrough\n\t\tcase ',':\n\t\t\tip.push(i, bb[0], bb[1])\n\t\t\tbb[1] = 0\n\t\t\tk = 0\n\t\tcase '-':\n\t\t\tif k == 1 {\n\t\t\t\t// To many dashes in one octet.\n\t\t\t\treturn nil, cc\n\t\t\t}\n\t\t\tk++\n\t\tdefault:\n\t\t\tip.push(i, bb[0], bb[1])\n\t\t\ti++\n\t\t\tbreak loop\n\t\t}\n\n\t\tif s[0] == '.' {\n\t\t\ti++\n\t\t}\n\n\t\ts = s[1:]\n\t\tcc++\n\t}\n\n\tif i < net.IPv4len {\n\t\t// Missing ip2octets.\n\t\treturn nil, cc\n\t}\n\n\treturn ip, cc\n}", "func parseIPv4(s string) (ip IP, ok bool) {\n\tvar ip4 [4]byte\n\n\tfor i := 0; i < 4; i++ {\n\t\tvar (\n\t\t\tj int\n\t\t\tacc uint16\n\t\t)\n\t\t// Parse one byte of digits. Bail if we overflow, stop at\n\t\t// first non-digit.\n\t\t//\n\t\t// As of Go 1.15, don't try to factor this digit reading into\n\t\t// a helper function. Its complexity is slightly too high for\n\t\t// inlining, which ends up costing +50% in parse time.\n\t\tfor j = 0; j < len(s); j++ {\n\t\t\tif s[j] < '0' || s[j] > '9' {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tacc = (acc * 10) + uint16(s[j]-'0')\n\t\t\tif acc > 255 {\n\t\t\t\treturn IP{}, false\n\t\t\t}\n\t\t}\n\t\t// There must be at least 1 digit per quad.\n\t\tif j == 0 {\n\t\t\treturn IP{}, false\n\t\t}\n\n\t\tip4[i] = uint8(acc)\n\n\t\t// Non-final byte must be followed by a dot\n\t\tif i < 3 {\n\t\t\tif len(s) == j || s[j] != '.' {\n\t\t\t\treturn IP{}, false\n\t\t\t}\n\t\t\tj++\n\t\t}\n\n\t\t// Advance to the next set of digits.\n\t\ts = s[j:]\n\t}\n\tif len(s) != 0 {\n\t\treturn IP{}, false\n\t}\n\n\treturn IPv4(ip4[0], ip4[1], ip4[2], ip4[3]), true\n}", "func ParsePublicIPV4(ip string) (*l5dNetPb.IPAddress, error) {\n\tnetIP := net.ParseIP(ip)\n\tif netIP != nil {\n\t\toBigInt := IPToInt(netIP.To4())\n\t\tnetIPAddress := &l5dNetPb.IPAddress{\n\t\t\tIp: &l5dNetPb.IPAddress_Ipv4{\n\t\t\t\tIpv4: uint32(oBigInt.Uint64()),\n\t\t\t},\n\t\t}\n\t\treturn netIPAddress, nil\n\t}\n\treturn nil, fmt.Errorf(\"Invalid IP address: %s\", ip)\n}", "func unpackSockaddr4(data []byte) (net.IP, int) {\n\tif len(data) != 16 {\n\t\tpanic(\"unexpected struct length\")\n\t}\n\tvar port uint16\n\tbinary.Read(bytes.NewReader(data[2:4]), binary.BigEndian, &port)\n\treturn data[4:8], int(port)\n}", "func ParseFromIPAddr(ipNet *net.IPNet) (*IPv4Address, *IPv6Address, error) {\n\tif ipNet == nil {\n\t\treturn nil, nil, fmt.Errorf(\"Nil address: %v\", ipNet)\n\t}\n\n\tif v4Addr := ipNet.IP.To4(); v4Addr != nil {\n\t\tcidr, _ := ipNet.Mask.Size()\n\t\tret := NewIPv4AddressFromBytes(v4Addr, uint(cidr))\n\t\treturn &ret, nil, nil\n\t}\n\tif v6Addr := ipNet.IP.To16(); v6Addr != nil {\n\t\tcidr, _ := ipNet.Mask.Size()\n\t\tret := NewIPv6Address(v6Addr, uint(cidr))\n\t\treturn nil, &ret, nil\n\t}\n\n\treturn nil, nil, fmt.Errorf(\"couldn't parse either v4 or v6 address: %v\", ipNet)\n}", "func extractIPv4(ptr string) string {\n\ts := strings.Replace(ptr, \".in-addr.arpa\", \"\", 1)\n\twords := strings.Split(s, \".\")\n\tfor i, j := 0, len(words)-1; i < j; i, j = i+1, j-1 {\n\t\twords[i], words[j] = words[j], words[i]\n\t}\n\treturn strings.Join(words, \".\")\n}", "func ParseIPFromString(address string) (*IPv4Address, *IPv6Address, error) {\n\tvar err error\n\n\t// see if there's a CIDR\n\tparts := strings.Split(address, \"/\")\n\tcidr := -1 // default needs to be -1 to handle /0\n\tif len(parts) == 2 {\n\t\tc, err := strconv.ParseUint(parts[1], 10, 8)\n\t\tif err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"couldn't parse CIDR to int: %s\", err)\n\t\t}\n\t\tif c > 128 {\n\t\t\treturn nil, nil, fmt.Errorf(\"Invalid CIDR: %d\", c)\n\t\t}\n\t\tcidr = int(c)\n\t}\n\n\t// try parsing as IPv4 - force CIDR at the end\n\tv4AddrStr := address\n\tif cidr == -1 {\n\t\t// no CIDR specified - tack on /32\n\t\tv4AddrStr = fmt.Sprintf(\"%s/32\", address)\n\t}\n\t_, ipNet, err := net.ParseCIDR(v4AddrStr)\n\tif err == nil {\n\t\tcidr, mask := ipNet.Mask.Size()\n\t\tif v4Addr := ipNet.IP.To4(); v4Addr != nil && mask == 32 { // nil error here\n\t\t\tret := NewIPv4AddressFromBytes(v4Addr, uint(cidr))\n\t\t\treturn &ret, nil, nil\n\t\t}\n\t}\n\n\t// try parsing as IPv6\n\tv6AddrStr := address\n\tif cidr == -1 {\n\t\t// no CIDR specified - tack on /128\n\t\tv6AddrStr = fmt.Sprintf(\"%s/128\", address)\n\t}\n\t_, ipNet, err = net.ParseCIDR(v6AddrStr)\n\tif err == nil {\n\t\tcidr, mask := ipNet.Mask.Size()\n\t\tif v6Addr := ipNet.IP.To16(); v6Addr != nil && mask == 128 {\n\t\t\tret := NewIPv6Address(v6Addr, uint(cidr))\n\t\t\treturn nil, &ret, nil\n\t\t}\n\t}\n\n\treturn nil, nil, fmt.Errorf(\"couldn't parse either v4 or v6 address\")\n}", "func (f *FloatingIP) IPv4Net() (*net.IPNet, error) {\n\tvar ip net.IP\n\tif ip = net.ParseIP(f.IP); ip == nil {\n\t\treturn nil, fmt.Errorf(\"error parsing IPv4Address '%s'\", f.IP)\n\t}\n\treturn &net.IPNet{\n\t\tIP: ip,\n\t\tMask: net.CIDRMask(32, 32),\n\t}, nil\n}", "func CheckIPv4Addr(addr string) error {\n\tif IsEmptyString(&addr) {\n\t\treturn errors.New(\"addr is empty\")\n\t}\n\n\tstrArray := strings.Split(addr, \":\")\n\n\tif len(strArray) != 2 {\n\t\treturn errors.New(\"Invalid addr:\" + addr)\n\t}\n\n\tif IsEmptyString(&strArray[0]) {\n\t\treturn errors.New(\"Invalid addr:\" + addr)\n\t}\n\n\tif IsEmptyString(&strArray[1]) {\n\t\treturn errors.New(\"Invalid addr:\" + addr)\n\t}\n\n\tvar error error\n\n\tipv4 := strArray[0]\n\terror = CheckIPv4(ipv4)\n\tif error != nil {\n\t\treturn error\n\t}\n\n\tvar port int64\n\tport, error = strconv.ParseInt(strArray[1], 10, 64)\n\tif error != nil {\n\t\treturn error\n\t}\n\n\terror = CheckPort(port)\n\tif error != nil {\n\t\treturn error\n\t}\n\n\treturn nil\n}", "func Ipv4(v string) predicate.Agent {\n\treturn predicate.Agent(func(s *sql.Selector) {\n\t\ts.Where(sql.EQ(s.C(FieldIpv4), v))\n\t})\n}", "func IPv4(a, b, c, d uint8) IP {\n\treturn IP{\n\t\tlo: 0xffff00000000 | uint64(a)<<24 | uint64(b)<<16 | uint64(c)<<8 | uint64(d),\n\t\tz: z4,\n\t}\n}", "func decodeMask(mask string) (uint32, error) {\n\timask, err := strconv.Atoi(mask)\n\tvar outmask uint32\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"Error decoding netmask\")\n\t}\n\tif imask > 32 || imask < 0 {\n\t\treturn 0, errors.New(\"Mask out of bounds\")\n\t}\n\tfor i := 0; i < imask; i++ {\n\t\toutmask += 1 << i\n\t}\n\treturn outmask, nil\n}", "func decodeIPv4ToNetIP(ip uint32) net.IP {\n\toBigInt := big.NewInt(0)\n\toBigInt = oBigInt.SetUint64(uint64(ip))\n\treturn IntToIPv4(oBigInt)\n}", "func IsIPv4(dots string) bool {\n\tip := net.ParseIP(dots)\n\tif ip == nil {\n\t\treturn false\n\t}\n\treturn ip.To4() != nil\n}", "func IsIPv4(value string) bool {\n\tip := net.ParseIP(value)\n\tif ip == nil {\n\t\treturn false\n\t}\n\treturn ip.To4() != nil\n}", "func IsIpv4(s string) bool {\n\tips := strings.Split(s, ipSep)\n\tif len(ips) != ipV4Len {\n\t\treturn false\n\t}\n\tfor _, v := range ips {\n\t\tnum, e := strconv.Atoi(v)\n\t\tif e != nil || num > ipv4Max || num < ipv4Min {\n\t\t\treturn false\n\t\t}\n\t}\n\n\treturn true\n}", "func network4(addr uint32, prefix uint) uint32 {\n\treturn addr & netmask(prefix)\n}", "func FilterIPV4(ips []net.IP) []string {\n\tvar ret = make([]string, 0)\n\tfor _, ip := range ips {\n\t\tif ip.To4() != nil {\n\t\t\tret = append(ret, ip.String())\n\t\t}\n\t}\n\treturn ret\n}", "func IPv4(str string) bool {\n\tip := net.ParseIP(str)\n\treturn ip != nil && strings.Contains(str, \".\")\n}", "func (m *IPV4) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateLan(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateWan(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func IPv4(name string) (string, error) {\n\ti, err := net.InterfaceByName(name)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\taddrs, err := i.Addrs()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tfor _, a := range addrs {\n\t\tif ipn, ok := a.(*net.IPNet); ok {\n\t\t\tif ipn.IP.To4() != nil {\n\t\t\t\treturn ipn.IP.String(), nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn \"\", fmt.Errorf(\"no IPv4 found for interface: %q\", name)\n}", "func IsIPv4(s string) bool {\n\tif s == \"\" {\n\t\treturn false\n\t}\n\n\tip := net.ParseIP(s)\n\treturn ip != nil && strings.Contains(s, \".\") // && ip.To4() != nil\n}", "func splitRange4(addr uint32, prefix uint, lo, hi uint32, cidrs *[]*net.IPNet) error {\n\tif prefix > 32 {\n\t\treturn fmt.Errorf(\"Invalid mask size: %d\", prefix)\n\t}\n\n\tbc := broadcast4(addr, prefix)\n\tif (lo < addr) || (hi > bc) {\n\t\treturn fmt.Errorf(\"%d, %d out of range for network %d/%d, broadcast %d\", lo, hi, addr, prefix, bc)\n\t}\n\n\tif (lo == addr) && (hi == bc) {\n\t\tcidr := net.IPNet{IP: uint32ToIPV4(addr), Mask: net.CIDRMask(int(prefix), 8*net.IPv4len)}\n\t\t*cidrs = append(*cidrs, &cidr)\n\t\treturn nil\n\t}\n\n\tprefix++\n\tlowerHalf := addr\n\tupperHalf := setBit(addr, prefix, 1)\n\tif hi < upperHalf {\n\t\treturn splitRange4(lowerHalf, prefix, lo, hi, cidrs)\n\t} else if lo >= upperHalf {\n\t\treturn splitRange4(upperHalf, prefix, lo, hi, cidrs)\n\t} else {\n\t\terr := splitRange4(lowerHalf, prefix, lo, broadcast4(lowerHalf, prefix), cidrs)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn splitRange4(upperHalf, prefix, upperHalf, hi, cidrs)\n\t}\n}", "func isIPv4(fl FieldLevel) bool {\n\tip := net.ParseIP(fl.Field().String())\n\n\treturn ip != nil && ip.To4() != nil\n}", "func isCIDRv4(fl FieldLevel) bool {\n\tip, _, err := net.ParseCIDR(fl.Field().String())\n\n\treturn err == nil && ip.To4() != nil\n}", "func (s *Server) IPv4Net() (*net.IPNet, error) {\n\tvar ip net.IP\n\tif ip = net.ParseIP(s.IPv4Address); ip == nil {\n\t\treturn nil, fmt.Errorf(\"error parsing IPv4Address '%s'\", s.IPv4Address)\n\t}\n\treturn &net.IPNet{\n\t\tIP: ip,\n\t\tMask: net.CIDRMask(32, 32),\n\t}, nil\n}", "func IPv4NetStartEnd(ip net.IP, mask int) (start, end uint32) {\n\tswitch {\n\tcase mask < 0:\n\t\treturn minIPv4, maxIPv4\n\tcase mask > 32:\n\t\treturn maxIPv4, maxIPv4\n\t}\n\n\ti := IPv4ToUInt(ip)\n\tsm := uint32(maxIPv4 << uint32(32-mask))\n\tem := ^sm\n\n\tstart = i & sm\n\tend = i | em\n\treturn start, end\n}", "func (n *hostOnlyNetwork) SaveIPv4(vbox VBoxManager) error {\n\tif n.IPv4.IP != nil && n.IPv4.Mask != nil {\n\t\tif err := vbox.vbm(\"hostonlyif\", \"ipconfig\", n.Name, \"--ip\", n.IPv4.IP.String(), \"--netmask\", net.IP(n.IPv4.Mask).String()); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func IsIPv4(ipAddress string) bool {\n\tip := net.ParseIP(ipAddress)\n\treturn ip != nil && strings.Count(ipAddress, \":\") < 2\n}", "func (me TxsdAddressSimpleContentExtensionCategory) IsIpv4NetMask() bool {\n\treturn me.String() == \"ipv4-net-mask\"\n}", "func IsIPv4(s string) bool {\n\tif s == \"\" {\n\t\treturn false\n\t}\n\n\tip := net.ParseIP(s)\n\treturn ip != nil && ip.To4() != nil\n}", "func Ipv4ToInt(ip string) (intv int64, err error) {\n\tips := strings.Split(ip, ipSep)\n\tif len(ips) != ipV4Len {\n\t\terr = BadIpv4Error\n\t\treturn\n\t}\n\n\tfor i, v := range ips {\n\t\tnum, e := strconv.Atoi(v)\n\t\tif e != nil || num < ipv4Min || num > ipv4Max {\n\t\t\terr = BadIpv4Error\n\t\t\treturn\n\t\t}\n\t\tintv += int64(num) << ipv4Shift[i]\n\t}\n\treturn\n}", "func IPv4ClassfulNetwork(address net.IP) *net.IPNet {\n\tif address.To4() != nil {\n\t\tvar newIP net.IP\n\t\tvar newMask net.IPMask\n\t\tswitch {\n\t\tcase uint8(address[0]) < 128:\n\t\t\tnewIP = net.IPv4(uint8(address[0]), 0, 0, 0)\n\t\t\tnewMask = net.IPv4Mask(255, 0, 0, 0)\n\t\tcase uint8(address[0]) < 192:\n\t\t\tnewIP = net.IPv4(uint8(address[0]), uint8(address[1]), 0, 0)\n\t\t\tnewMask = net.IPv4Mask(255, 255, 0, 0)\n\t\tcase uint8(address[0]) < 224:\n\t\t\tnewIP = net.IPv4(uint8(address[0]), uint8(address[1]), uint8(address[2]), 0)\n\t\t\tnewMask = net.IPv4Mask(255, 255, 255, 0)\n\t\tdefault:\n\t\t\treturn nil\n\t\t}\n\t\treturn &net.IPNet{IP: newIP, Mask: newMask}\n\t}\n\treturn nil\n}", "func extractIPv4(reverseName string) (string, error) {\n\t// reverse the segments and then combine them\n\tsegments := ReverseArray(strings.Split(reverseName, \".\"))\n\n\tip := net.ParseIP(strings.Join(segments, \".\")).To4()\n\tif ip == nil {\n\t\treturn \"\", fmt.Errorf(\"failed to parse IPv4 reverse name: %q\", reverseName)\n\t}\n\treturn ip.String(), nil\n}", "func IPv4() (string, error) {\n\tconn, err := net.Dial(\"udp\", \"8.8.8.8:80\")\n\tif err != nil {\n\t\treturn \"\", errors.New(\"Failed to determine your IP\")\n\t}\n\tlocalAddr := conn.LocalAddr().(*net.UDPAddr)\n\tmyIP := localAddr.IP.String()\n\tconn.Close()\n\treturn myIP, nil\n}", "func NewIPv4(value string) (IPv4, error) {\n\tvar IP = IPv4{value: value}\n\n\tif !IP.validate() {\n\t\treturn IPv4{}, ErrInvalidIPv4\n\t}\n\n\treturn IP, nil\n}", "func (internet Internet) IPv4(v reflect.Value) (interface{}, error) {\n\treturn internet.ipv4(), nil\n}", "func ParseIP(s string) (IP, error) {\n\t// IPv4 fast path.\n\tif ip, ok := parseIPv4(s); ok {\n\t\treturn ip, nil\n\t}\n\n\tvar ipa net.IPAddr\n\tipa.IP = net.ParseIP(s)\n\tif ipa.IP == nil {\n\t\tswitch percent := strings.Index(s, \"%\"); percent {\n\t\tcase -1:\n\t\t\t// handle bad input with no % at all, so the net.ParseIP was not due to a zoned IPv6 fail\n\t\t\treturn IP{}, fmt.Errorf(\"netaddr.ParseIP(%q): unable to parse IP\", s)\n\t\tcase 0:\n\t\t\t// handle bad input with % at the start\n\t\t\treturn IP{}, fmt.Errorf(\"netaddr.ParseIP(%q): missing IPv6 address\", s)\n\t\tcase len(s) - 1:\n\t\t\t// handle bad input with % at the end\n\t\t\treturn IP{}, fmt.Errorf(\"netaddr.ParseIP(%q): missing zone\", s)\n\t\tdefault:\n\t\t\t// net.ParseIP can't deal with zoned scopes, let's split and try to parse the IP again\n\t\t\ts, ipa.Zone = s[:percent], s[percent+1:]\n\t\t\tipa.IP = net.ParseIP(s)\n\t\t\tif ipa.IP == nil {\n\t\t\t\treturn IP{}, fmt.Errorf(\"netaddr.ParseIP(%q): unable to parse IP\", s)\n\t\t\t}\n\t\t}\n\t}\n\n\tif !strings.Contains(s, \":\") {\n\t\tif ip4 := ipa.IP.To4(); ip4 != nil {\n\t\t\tif ipa.Zone != \"\" {\n\t\t\t\treturn IP{}, fmt.Errorf(\"netaddr.ParseIP(%q): invalid zone with IPv4 address\", s)\n\t\t\t}\n\t\t\treturn IPv4(ip4[0], ip4[1], ip4[2], ip4[3]), nil\n\t\t}\n\t}\n\treturn ipv6Slice(ipa.IP.To16()).WithZone(ipa.Zone), nil\n}", "func (n *NetworkAssociation) IPv4Net() (*net.IPNet, error) {\n\tvar ip net.IP\n\tif ip = net.ParseIP(n.ServerIP); ip == nil {\n\t\treturn nil, fmt.Errorf(\"error parsing ServerIP '%s'\", ip)\n\t}\n\treturn &net.IPNet{\n\t\tIP: ip,\n\t\tMask: net.CIDRMask(24, 32),\n\t}, nil\n}", "func (o NodeBalancerOutput) Ipv4() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *NodeBalancer) pulumi.StringOutput { return v.Ipv4 }).(pulumi.StringOutput)\n}", "func (internet *Internet) IPv4Address() string {\n\tvar parts []string\n\tfor i := 0; i < 4; i++ {\n\t\tparts = append(parts, fmt.Sprintf(\"%d\", internet.faker.random.Intn(253)+2))\n\t}\n\treturn strings.Join(parts, \".\")\n}", "func (o *NetworkElementSummaryAllOf) GetOutOfBandIpv4Mask() string {\n\tif o == nil || o.OutOfBandIpv4Mask == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.OutOfBandIpv4Mask\n}", "func IsIPv4(ip string) bool {\n\treturn net.ParseIP(ip).To4() != nil\n}", "func mask4(n uint8) uint32 {\n\treturn ^uint32(0) << (32 - n)\n}", "func inAddrV4(ip netip.Addr) (uint32, error) {\n\tif !ip.Is4() {\n\t\treturn 0, fmt.Errorf(\"%s is not IPv4\", ip)\n\t}\n\tv4 := ip.As4()\n\treturn endian.Uint32(v4[:]), nil\n}", "func IsIPv4(ipv4 string) bool {\n\tis, _ := regexp.Match(`^(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2}).(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2}).(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2}).(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2})$`, []byte(ipv4))\n\treturn is\n}", "func (m *InterfaceProtocolConfigIPV4) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateDhcp(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateMethod(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateStatic(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func IpV4Address() string {\n\tblocks := []string{}\n\tfor i := 0; i < 4; i++ {\n\t\tnumber := seedAndReturnRandom(255)\n\t\tblocks = append(blocks, strconv.Itoa(number))\n\t}\n\n\treturn strings.Join(blocks, \".\")\n}", "func decodeAddress(address string) (uint32, error) {\n\tsplit := strings.Split(address, \".\")\n\tif len(split) != 4 {\n\t\treturn 0, errors.New(\"Error decoding IPv4 address: wrong amount of octets\")\n\t}\n\tvar IPaddress uint32\n\tfor i, octetstr := range split {\n\t\tsegment, err := strconv.Atoi(octetstr)\n\t\tif err != nil {\n\t\t\treturn 0, errors.Wrap(err, \"Error decoding IPv4 address\")\n\t\t}\n\t\tif segment > math.MaxUint8 {\n\t\t\treturn 0, errors.New(\"Error decoding IPv4 address: value overflow\")\n\t\t}\n\t\t// Shift octets by determined amount of bits.\n\t\tswitch i {\n\t\tcase 0:\n\t\t\tsegment = segment << 24\n\t\tcase 1:\n\t\t\tsegment = segment << 16\n\t\tcase 2:\n\t\t\tsegment = segment << 8\n\t\t}\n\t\tIPaddress += uint32(segment)\n\t}\n\treturn IPaddress, nil\n}", "func IsIPv4(s string) bool {\n\tvar p [IPv4len]byte\n\tfor i := 0; i < IPv4len; i++ {\n\t\tif len(s) == 0 {\n\t\t\t// Missing octets.\n\t\t\treturn false\n\t\t}\n\t\tif i > 0 {\n\t\t\tif s[0] != '.' {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ts = s[1:]\n\t\t}\n\t\tn, c, ok := dtoi(s)\n\t\tif !ok || n > 0xFF {\n\t\t\treturn false\n\t\t}\n\t\ts = s[c:]\n\t\tp[i] = byte(n)\n\t}\n\tif len(s) != 0 {\n\t\treturn false\n\t}\n\treturn true\n}", "func extractUnicastIPv4Addrs(addrs []net.Addr) []string {\n\tvar ips []string\n\n\tfor _, a := range addrs {\n\t\tvar ip net.IP\n\n\t\tswitch a := a.(type) {\n\t\tcase *net.IPNet:\n\t\t\tip = a.IP\n\t\tcase *net.IPAddr:\n\t\t\tip = a.IP\n\t\t}\n\n\t\tif ip == nil || len(ip.To4()) == 0 {\n\t\t\t// Windows dataplane doesn't support IPv6 yet.\n\t\t\tcontinue\n\t\t}\n\t\tif ip.IsLoopback() {\n\t\t\t// Skip 127.0.0.1.\n\t\t\tcontinue\n\t\t}\n\t\tips = append(ips, ip.String()+\"/32\")\n\t}\n\n\treturn ips\n}", "func ResolveIPv4(host string) (net.IP, error) {\n\tif node := DefaultHosts.Search(host); node != nil {\n\t\tif ip := node.Data.(net.IP).To4(); ip != nil {\n\t\t\treturn ip, nil\n\t\t}\n\t}\n\n\tip := net.ParseIP(host)\n\tif ip != nil {\n\t\tif !strings.Contains(host, \":\") {\n\t\t\treturn ip, nil\n\t\t}\n\t\treturn nil, errIPVersion\n\t}\n\n\tif DefaultResolver != nil {\n\t\treturn DefaultResolver.ResolveIPv4(host)\n\t}\n\n\tipAddrs, err := net.LookupIP(host)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, ip := range ipAddrs {\n\t\tif ip4 := ip.To4(); ip4 != nil {\n\t\t\treturn ip4, nil\n\t\t}\n\t}\n\n\treturn nil, errIPNotFound\n}", "func isIP4AddrResolvable(fl FieldLevel) bool {\n\tif !isIPv4(fl) {\n\t\treturn false\n\t}\n\n\t_, err := net.ResolveIPAddr(\"ip4\", fl.Field().String())\n\n\treturn err == nil\n}", "func newBlock4(ip net.IP, mask net.IPMask) *cidrBlock4 {\n\tvar block cidrBlock4\n\n\tblock.first = ipv4ToUInt32(ip)\n\tprefix, _ := mask.Size()\n\tblock.last = broadcast4(block.first, uint(prefix))\n\n\treturn &block\n}", "func IntToIpv4(intv int64) (ip string, err error) {\n\tif intv < ipv4MinInt || intv > ipv4MaxInt {\n\t\terr = BadIpv4Error\n\t\treturn\n\t}\n\n\tip = strings.Join([]string{\n\t\tstrconv.Itoa(int(intv & ip1x >> ipv4Shift[0])),\n\t\tstrconv.Itoa(int(intv & ip2x >> ipv4Shift[1])),\n\t\tstrconv.Itoa(int(intv & ip3x >> ipv4Shift[2])),\n\t\tstrconv.Itoa(int(intv & ip4x >> ipv4Shift[3]))},\n\t\tipSep)\n\n\treturn\n}", "func isIPv4(s string) bool {\n\tip := netutils.ParseIPSloppy(s)\n\treturn ip != nil && strings.Contains(s, \".\")\n}", "func (o *NetworkElementSummaryAllOf) SetOutOfBandIpv4Mask(v string) {\n\to.OutOfBandIpv4Mask = &v\n}", "func ResolveToIPv4Address(address string) (string, error) {\n\tif ip := net.ParseIP(address); ip != nil {\n\t\t// Address is either an IPv6 or IPv4 address\n\t\tipv4 := ip.To4()\n\t\tif ipv4 == nil {\n\t\t\treturn \"\", errors.Errorf(\"not an IPv4 network address: %s\", ip.String())\n\t\t}\n\t\treturn ipv4.String(), nil\n\t}\n\n\t// DNS address in this case\n\tips, err := net.LookupIP(address)\n\tif err != nil {\n\t\treturn \"\", errors.Wrapf(err, \"lookup of address %s failed\", address)\n\t}\n\t// Get first IPv4 address returned\n\tfor _, returnedIP := range ips {\n\t\tif returnedIP.To4() != nil {\n\t\t\treturn returnedIP.String(), nil\n\t\t}\n\t}\n\treturn \"\", errors.Errorf(\"%s does not resolve to an IPv4 address\", address)\n}", "func IPv4Address(ctx context.Context, client *docker.Client, containerID string) (net.IP, error) {\n\tc, err := client.InspectContainerWithContext(containerID, ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"find container %s address: %w\", containerID, err)\n\t}\n\treturn ipv4Address(c)\n}", "func isIPv4(s []byte) bool {\n\tfor _, v := range s[4:] {\n\t\tif v != 0 {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func IsIPv4Net(ipnet *net.IPNet) bool {\n\treturn ipnet.IP.To4() != nil\n}", "func (o *NetworkElementSummaryAllOf) GetOutOfBandIpv4MaskOk() (*string, bool) {\n\tif o == nil || o.OutOfBandIpv4Mask == nil {\n\t\treturn nil, false\n\t}\n\treturn o.OutOfBandIpv4Mask, true\n}", "func uint32ToIPv4(intIP uint32) net.IP {\n\tip := make(net.IP, 4)\n\tbinary.BigEndian.PutUint32(ip, intIP)\n\treturn ip\n}", "func parsedIp(ip []byte) []byte {\n\tvar ip4 []byte\n\tip_arr := bytes.Split(ip, dot)\n\tif len(ip_arr) != 4 {\n\t\treturn nil\n\t}\n\tfor _, p := range ip_arr {\n\t\ttmp := bytes2byte(p)\n\t\tif tmp == 32 {\n\t\t\treturn nil\n\t\t}\n\t\tip4 = append(ip4, tmp)\n\t}\n\treturn ip4\n}", "func ScanOnIPv4WithCIDR(iface, cidrIP string) ([]Device, error) {\n\tipParts := strings.Split(cidrIP, \"/\")\n\tif len(ipParts) != 2 {\n\t\treturn nil, errors.New(\"Invalid CIDR IP - \" + cidrIP)\n\t}\n\tip := ipParts[0]\n\tmask := ipParts[1]\n\n\t// nmap args\n\targTarget := ip[:strings.LastIndex(ip, \".\")] + \".0/\" + mask\n\n\t// TODO: check if it's running with su privileges\n\tcmd := exec.Command(\"nmap\", \"-oN\", \"-\", \"-sP\", argTarget, \"-T\", \"insane\", \"--exclude\", ip)\n\n\t//cmd.Stdin = strings.NewReader(\"\")\n\tvar out bytes.Buffer\n\tcmd.Stdout = &out\n\n\terr := cmd.Run()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlines := strings.Split(out.String(), \"\\n\")\n\tl := len(lines)\n\n\tif l < 5 {\n\t\treturn nil, errors.New(\"nmap invalid response\")\n\t}\n\n\tvar devices []Device\n\tfor i := 1; i < l-2; i += 3 {\n\t\tdevices = append(devices, Device{\n\t\t\tIP: lines[i][21:],\n\t\t\tMAC: lines[i+2][13:30],\n\t\t\tManufacturer: lines[i+2][32 : len(lines[i+2])-1],\n\t\t})\n\t}\n\n\treturn devices, nil\n}", "func (out *ipv4Subnet) UnmarshalJSON(b []byte) error {\n\tvar s string\n\tif err := json.Unmarshal(b, &s); err != nil {\n\t\treturn err\n\t}\n\n\tif ip, ipnet, err := net.ParseCIDR(s); err == nil {\n\t\tif out.Addr, err = convertIPv4(ip.To4()); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif out.Mask, err = convertIPv4(ipnet.Mask); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}\n\n\tif ip := net.ParseIP(s); ip != nil {\n\t\tvar err error\n\t\tif out.Addr, err = convertIPv4(ip.To4()); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tout.Mask = 0xffffffff\n\t\treturn nil\n\t}\n\treturn errors.New(\"Failed to parse address \" + s)\n}", "func (f *FSEIDFields) SetIPv4Flag() {\n\tf.Flags |= 0x02\n}", "func packSockaddr4(addr net.IP, port int) []byte {\n\tip4 := addr.To4()\n\tif ip4 == nil {\n\t\tpanic(\"must take an IPv4 address\")\n\t}\n\tvar buf bytes.Buffer\n\tbuf.WriteByte(16)\n\tbuf.WriteByte(unix.AF_INET)\n\tbinary.Write(&buf, binary.BigEndian, uint16(port))\n\tbuf.Write(ip4)\n\tbuf.Write(make([]byte, 8))\n\treturn buf.Bytes()\n}", "func (ipSet *IPSet) IsIPv4() bool {\n\treturn govalidator.IsIPv4(ipSet.IPv4)\n}", "func broadcast4(addr uint32, prefix uint) uint32 {\n\treturn addr | ^netmask(prefix)\n}", "func stringIPv4(n uint32) string {\n\tip := make(net.IP, 4)\n\tbinary.BigEndian.PutUint32(ip, n)\n\treturn ip.String()\n}", "func uint32ToIPV4(addr uint32) net.IP {\n\tip := make([]byte, net.IPv4len)\n\tbinary.BigEndian.PutUint32(ip, addr)\n\treturn ip\n}", "func (m *IPAddresses100IPV4Address) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAddress(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateAddressOrigin(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateSubnetMask(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (p *PeerToPeer) handlePacketIPv4(contents []byte, proto int) {\n\tLog(Trace, \"Handling IPv4 Packet\")\n\tf := new(ethernet.Frame)\n\tif err := f.UnmarshalBinary(contents); err != nil {\n\t\tLog(Error, \"Failed to unmarshal IPv4 packet\")\n\t}\n\n\tif f.EtherType != ethernet.EtherTypeIPv4 {\n\t\treturn\n\t}\n\tmsg := CreateNencP2PMessage(p.Crypter, contents, uint16(proto), 1, 1, 1)\n\tp.SendTo(f.Destination, msg)\n}", "func decodeMask(mask string) (uint64, error) {\n\tmask = strings.ToLower(mask)\n\n\tif strings.HasPrefix(mask, \"0x\") {\n\t\tif len(mask) < 3 {\n\t\t\treturn 0, fmt.Errorf(\"invalid mask: %s\", mask)\n\t\t}\n\n\t\tb, err := hex.DecodeString(mask[2:])\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"invalid mask: %w\", err)\n\t\t}\n\n\t\tvar u uint64\n\t\tfor _, v := range b {\n\t\t\tu = u<<8 | uint64(v)\n\t\t}\n\n\t\treturn u, nil\n\t}\n\n\treturn strconv.ParseUint(mask, 10, 64)\n}", "func GetNetAndMask(input string) (string, int, error) {\n\t_, cidr, err := net.ParseCIDR(input)\n\tif err != nil {\n\t\treturn \"\", 0, err\n\t}\n\tnet := cidr.IP.String()\n\tmask, _ := cidr.Mask.Size()\n\treturn net, mask, nil\n}", "func Ipv4Contains(v string) predicate.Agent {\n\treturn predicate.Agent(func(s *sql.Selector) {\n\t\ts.Where(sql.Contains(s.C(FieldIpv4), v))\n\t})\n}", "func Ipv4In(vs ...string) predicate.Agent {\n\tv := make([]interface{}, len(vs))\n\tfor i := range v {\n\t\tv[i] = vs[i]\n\t}\n\treturn predicate.Agent(func(s *sql.Selector) {\n\t\t// if not arguments were provided, append the FALSE constants,\n\t\t// since we can't apply \"IN ()\". This will make this predicate falsy.\n\t\tif len(v) == 0 {\n\t\t\ts.Where(sql.False())\n\t\t\treturn\n\t\t}\n\t\ts.Where(sql.In(s.C(FieldIpv4), v...))\n\t})\n}", "func ipv4only(addr IPAddr) bool {\n\treturn supportsIPv4 && addr.IP.To4() != nil\n}", "func (m *RIBMessage) IPv4Unicast() (*IPv4UnicastAnnounceTextMessage, error) {\n\tif m.Family() != \"ipv4 unicast\" {\n\t\treturn nil, fmt.Errorf(\"wrong entry family: %s\", m.Family())\n\t}\n\tnm := &IPv4UnicastAnnounceTextMessage{}\n\tres, err := parseIPv4UnicastLine(m.Details)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnm.NLRI = res[\"nlri\"]\n\tnm.NextHop = res[\"next_hop\"]\n\tnm.Attributes = res[\"attributes\"]\n\treturn nm, nil\n}", "func add_cidr_mask(addr string) string {\n\tif strings.Contains(addr, \"/\") {\n\t\treturn addr\n\t}\n\n\tif strings.Contains(addr, \":\") {\n\t\treturn addr + \"/128\"\n\t} else {\n\t\treturn addr + \"/32\"\n\t}\n}", "func isUDP4AddrResolvable(fl FieldLevel) bool {\n\tif !isIP4Addr(fl) {\n\t\treturn false\n\t}\n\n\t_, err := net.ResolveUDPAddr(\"udp4\", fl.Field().String())\n\n\treturn err == nil\n}", "func ipv4ToUInt32(ip net.IP) uint32 {\n\treturn binary.BigEndian.Uint32(ip)\n}", "func DetectHostIPv4() (string, error) {\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn \"\", errors.WithStack(err)\n\t}\n\tfor _, a := range addrs {\n\t\tif ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {\n\t\t\tif ipnet.IP.To4() == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn ipnet.IP.String(), nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"cannot detect host IPv4 address\")\n}", "func IsIPv4(ip *net.IP) bool {\n\treturn ip.To4() != nil\n}", "func IsCIDRv4(s string) bool {\n\tif s == \"\" {\n\t\treturn false\n\t}\n\tip, _, err := net.ParseCIDR(s)\n\treturn err == nil && ip.To4() != nil\n}", "func IsCIDRv4(s string) bool {\n\tif s == \"\" {\n\t\treturn false\n\t}\n\tip, _, err := net.ParseCIDR(s)\n\treturn err == nil && ip.To4() != nil\n}", "func IsIPv4(ip net.IP) bool {\n\treturn (len(ip) == net.IPv4len) || (len(ip) == net.IPv6len &&\n\t\tip[0] == 0x00 &&\n\t\tip[1] == 0x00 &&\n\t\tip[2] == 0x00 &&\n\t\tip[3] == 0x00 &&\n\t\tip[4] == 0x00 &&\n\t\tip[5] == 0x00 &&\n\t\tip[6] == 0x00 &&\n\t\tip[7] == 0x00 &&\n\t\tip[8] == 0x00 &&\n\t\tip[9] == 0x00 &&\n\t\tip[10] == 0xff &&\n\t\tip[11] == 0xff)\n}", "func localIPv4s() ([]string, error) {\n\tvar ips []string\n\taddrs, err := net.InterfaceAddrs()\n\tif err != nil {\n\t\treturn ips, err\n\t}\n\n\tfor _, a := range addrs {\n\t\tif ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() && ipnet.IP.To4() != nil {\n\t\t\tips = append(ips, ipnet.IP.String())\n\t\t}\n\t}\n\n\treturn ips, nil\n}", "func isIPv4(ip net.IP) bool {\n\treturn ip.To4() != nil && strings.Count(ip.String(), \":\") < 2\n}", "func IsIP4(val interface{}) bool {\n\treturn isMatch(ip4, val)\n}" ]
[ "0.6910413", "0.65817773", "0.64788103", "0.64404845", "0.61875916", "0.61496323", "0.6074284", "0.60079217", "0.59941304", "0.59614414", "0.58839774", "0.58533674", "0.582732", "0.5775293", "0.57644033", "0.57606894", "0.5736692", "0.573576", "0.570588", "0.5696371", "0.56833994", "0.5683031", "0.5661739", "0.56537896", "0.564742", "0.5631333", "0.5623487", "0.5592208", "0.5565591", "0.5532977", "0.5532031", "0.5510396", "0.55049044", "0.55017656", "0.5488127", "0.5470335", "0.54689074", "0.5462034", "0.5431872", "0.54143304", "0.5386428", "0.5378486", "0.5353306", "0.535178", "0.53505886", "0.53452814", "0.5290702", "0.5286229", "0.5286054", "0.5280478", "0.5274077", "0.5265233", "0.5240618", "0.5230248", "0.5219644", "0.521165", "0.52110946", "0.5209704", "0.5205639", "0.51969534", "0.5193639", "0.5179071", "0.51727194", "0.5170799", "0.51628405", "0.51565486", "0.5150351", "0.5139961", "0.51299226", "0.51045585", "0.50871766", "0.50706404", "0.5070487", "0.5064613", "0.5063839", "0.5051146", "0.50358635", "0.50352484", "0.50330913", "0.50295043", "0.50266266", "0.5013194", "0.49972895", "0.49823952", "0.49815032", "0.49718073", "0.4970712", "0.49498683", "0.49457875", "0.4938413", "0.49351496", "0.49335426", "0.49216595", "0.49178654", "0.49156058", "0.49156058", "0.49060822", "0.4904693", "0.4895479", "0.48838085" ]
0.86540896
0
NewBlock creates new block
func NewBlock(transactions []*Transaction, prevBlockHash []byte, height int) *Block { block := &Block{time.Now().Unix(), transactions, prevBlockHash, []byte{}, 0, height} block.POW() return block }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func generateNewBlock(oldBlock Block, dataPayload string) (Block, error) {\n\n\tvar newBlock Block\n\ttimeNow := time.Now()\n\n\tnewBlock.Index = oldBlock.Index + 1\n\tnewBlock.Timestamp = timeNow.String()\n\n\tnewEvent, err := dataPayloadtoServiceEvent(dataPayload)\n\n\tif err != nil {\n\t\tlog.Println(\"ERROR: Unable to convert data payload into ServiceEvent for new block generation.\")\n\t}\n\n\tnewBlock.Event = newEvent\n\tnewBlock.PrevHash = oldBlock.Hash\n\tnewBlock.Hash = calculateHash(newBlock)\n\n\treturn newBlock, nil\n}", "func CreateNewBlock(txs []*model.Transaction, prevHash string, reward float64, height int64, pk []byte, l *model.Ledger, difficulty int, ctl chan commands.Command) (*model.Block, commands.Command, []*model.Transaction, error) {\n\torigL := GetLedgerDeepCopy(l)\n\n\terrTxs, err := HandleTransactions(txs, l)\n\tif err != nil {\n\t\treturn nil, commands.NewDefaultCommand(), errTxs, err\n\t}\n\n\t// All transactions are valid if reached here, calculate transaction fee on the original ledger.\n\tfee, err := CalcTxFee(txs, origL)\n\tif err != nil {\n\t\tlog.Fatalln(\"there should never be a case where handle transaction success but fail calcFee\")\n\t}\n\n\tblock := model.Block{\n\t\tPrevHash: prevHash,\n\t\tTxs: txs,\n\t\tCoinbase: CreateCoinbaseTx(reward+fee, pk, height),\n\t}\n\n\tc, err := Mine(&block, difficulty, ctl)\n\treturn &block, c, []*model.Transaction{}, err\n}", "func (bc *BlockChain) CreateNewBlock(bPrev *Block) *Block {\n\tbPrev.hash = bPrev.createHash()\n\tb2 := &Block{Index: bPrev.Index + 1, Timestamp: time.Now(), prevHash: bPrev.hash}\n\tbc.AddBlock(bPrev)\n\treturn b2\n}", "func newBlock(prevHash [32]byte, prevHashWithoutTx [32]byte, commitmentProof [crypto.COMM_PROOF_LENGTH]byte, height uint32) *protocol.Block {\n\tblock := new(protocol.Block)\n\tblock.PrevHash = prevHash\n\tblock.PrevHashWithoutTx = prevHashWithoutTx\n\tblock.CommitmentProof = commitmentProof\n\tblock.Height = height\n\tblock.StateCopy = make(map[[32]byte]*protocol.Account)\n\tblock.Aggregated = false\n\n\treturn block\n}", "func NewBlock(index int, data interface{}, date time.Time) *Block {\n\treturn &Block{\n\t\tIndex: index,\n\t\tDate: date,\n\t\tData: data,\n\t}\n}", "func newBlock(lastBlock Block, seed int, npeer string, transactions []SignedTransaction) Block {\n\tvar newBlock Block\n\n\tnewBlock.Seed = seed\n\tnewBlock.Index = lastBlock.Index + 1\n\tnewBlock.LastHash = lastBlock.Hash\n\tnewBlock.Peer = npeer\n\tnewBlock.SpecialAccounts = lastBlock.SpecialAccounts\n\tnewBlock.Transactions = transactions\n\tnewBlock.Hash = blockHash(newBlock)\n\treturn newBlock\n}", "func NewBlock(oldBlock Block, data string) Block {\n\t// fmt.Println(\"******TODO: IMPLEMENT NewBlock!******\")\n\tblock := Block{Data: data, Timestamp: time.Now().Unix(), PrevHash: oldBlock.Hash, Hash: []byte{}}\n\tblock.Hash = block.calculateHash()\n\t// fmt.Println(\"data: \" + block.Data)\n\t// fmt.Printf(\"timestamp: %d\", block.Timestamp)\n\t// fmt.Println()\n\t// fmt.Printf(\"preHash: %x\", block.PrevHash)\n\t// fmt.Println()\n\t// fmt.Printf(\"currentHash: %x\", block.Hash)\n\t// fmt.Println()\n\t// fmt.Println(\"******TODO: END NewBlock!******\")\n\t// fmt.Println()\n\t// fmt.Println()\n\t// fmt.Println()\n\treturn block\n}", "func (cm *chainManager) MintNewBlock(timestamp time.Time) (*block.Block, error) {\n\treturn cm.bc.MintNewBlock(timestamp)\n}", "func NewBlock() (*Block, error) {\n\tn, err := findLast()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\th, err := ftoh(n)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfmt.Println(\"Hash: \" + h)\n\n\treturn &Block{Number: n + 1, PreviousHash: h}, nil\n}", "func NewBlock(t *testing.T, bc blockchainer.Blockchainer, offset uint32, primary uint32, txs ...*transaction.Transaction) *block.Block {\n\twitness := transaction.Witness{VerificationScript: MultisigVerificationScript()}\n\theight := bc.BlockHeight()\n\th := bc.GetHeaderHash(int(height))\n\thdr, err := bc.GetHeader(h)\n\trequire.NoError(t, err)\n\tb := &block.Block{\n\t\tHeader: block.Header{\n\t\t\tPrevHash: hdr.Hash(),\n\t\t\tTimestamp: (uint64(time.Now().UTC().Unix()) + uint64(hdr.Index)) * 1000,\n\t\t\tIndex: hdr.Index + offset,\n\t\t\tPrimaryIndex: byte(primary),\n\t\t\tNextConsensus: witness.ScriptHash(),\n\t\t\tScript: witness,\n\t\t},\n\t\tTransactions: txs,\n\t}\n\tb.RebuildMerkleRoot()\n\n\tb.Script.InvocationScript = Sign(b)\n\treturn b\n}", "func NewBlock(b *block.Block, chain blockchainer.Blockchainer) Block {\n\tres := Block{\n\t\tBlock: *b,\n\t\tBlockMetadata: BlockMetadata{\n\t\t\tSize: io.GetVarSize(b),\n\t\t\tConfirmations: chain.BlockHeight() - b.Index + 1,\n\t\t},\n\t}\n\n\thash := chain.GetHeaderHash(int(b.Index) + 1)\n\tif !hash.Equals(util.Uint256{}) {\n\t\tres.NextBlockHash = &hash\n\t}\n\n\treturn res\n}", "func newBlock(t nbt.Tag) BlockState {\r\n\tblock := BlockState{}\r\n\tblock.Name = t.Compound()[\"Name\"].String()\r\n\tblock.parseProperties(t)\r\n\treturn block\r\n}", "func (bc *Blockchain) chainNewBlock(nonce int, previousHash [32]byte) *Block {\n\tb := NewBlock(nonce, previousHash, bc.transactionPool)\n\tbc.chain = append(bc.chain, b)\n\tbc.transactionPool = []*Transaction{}\n\treturn b\n}", "func NewBlock(data *SPOTuple, prevBlockHash string) (*Block, error) {\n\n\tblock := &Block{\n\t\tBlockId: nuid.Next(),\n\t\tData: data,\n\t\tPrevBlockHash: prevBlockHash,\n\t\tHash: \"\",\n\t\tSig: \"\",\n\t\tAuthor: cs.PublicID(),\n\t\tSender: cs.PublicID(),\n\t}\n\n\t// assign new hash\n\tblock.setHash()\n\n\t// now sign the completed block\n\terr := block.sign()\n\tif err != nil {\n\t\tlog.Println(\"unable to sign block: \", err)\n\t\treturn nil, err\n\t}\n\n\treturn block, nil\n}", "func ProduceBlock(prevBlockHash string, prevBlock *Block) *Block {\n // This function creates a new block.\n //\n // The implementation is fairly straightforward matter of creating a Block instance and filling in the fields.\n //\n // This function's API is slightly weird, it requires the caller to compute `prevBlockHash = HashBlock(prevBlock)`.\n // Why we don't simplify the API by computing `prevBlockHash` ourselves, reducing the number of arguments\n // from two to one? Two reasons:\n //\n // - Immediately, it makes the placement of the `HashBlock()` debugging output less confusing.\n // - Eventually, we will have more data with the same data flow as `prevBlockHash`, so writing code to route this data\n // now will be useful later.\n\n newBlock := new(Block)\n\n if prevBlock == nil {\n newBlock.PrevHash = prevBlockHash\n newBlock.Height = 1\n } else {\n newBlock.PrevHash = prevBlockHash\n newBlock.Height = prevBlock.Height + 1\n }\n\n return newBlock\n}", "func (I *Blockchain) NewBlock(proof uint64, previousHash string) {\n\t// In order to be able to create the first block\n\tif previousHash == \"\" {\n\t\tpreviousHash = \"1\"\n\t}\n\t// Create the block\n\tb := block{\n\t\tindex: I.currentIndex,\n\t\ttimestamp: time.Now().UnixNano(),\n\t\tproof: proof,\n\t\tpreviousHash: previousHash,\n\t\ttransactions: I.currentTransactions,\n\t}\n\t// Append the new block\n\tI.blocks = append(I.blocks, b)\n\t// Reset the transactions\n\tI.currentTransactions = make([]transaction, 0)\n\t// Update the index\n\tI.currentIndex += 1\n\t// Modify the last block variable\n\tI.lastBlock = b\n}", "func (blockchain *Blockchain) MineNewBlock(originalTxs []*Transaction) *Block {\n\t// Reward of mining a block\n\tcoinBaseTransaction := NewRewardTransacion()\n\ttxs := []*Transaction{coinBaseTransaction}\n\ttxs = append(txs, originalTxs...)\n\t// Verify transactions\n\tfor _, tx := range txs {\n\t\tif !tx.IsCoinBaseTransaction() {\n\t\t\tif blockchain.VerifityTransaction(tx, txs) == false {\n\t\t\t\tlog.Panic(\"Verify transaction failed...\")\n\t\t\t}\n\t\t}\n\t}\n\n\tDBName := fmt.Sprintf(DBName, os.Getenv(\"NODE_ID\"))\n\tdb, err := bolt.Open(DBName, 0600, nil)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tdefer db.Close()\n\t// Get the latest block\n\tvar block Block\n\terr = db.View(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket([]byte(BlockBucketName))\n\t\tif b != nil {\n\t\t\thash := b.Get([]byte(\"l\"))\n\t\t\tblockBytes := b.Get(hash)\n\t\t\tgobDecode(blockBytes, &block)\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\t// Mine a new block\n\tnewBlock := NewBlock(txs, block.Height+1, block.BlockHash)\n\n\treturn newBlock\n}", "func (b *Block) NewBlock(height int32, parentHash string, value p1.MerklePatriciaTrie) {\n\n var header Header\n mptAsBytes := getBytes(value)\n\n header.Height = height\n header.Timestamp = int64(time.Now().Unix())\n header.ParentHash = parentHash\n header.Size = int32(len(mptAsBytes))\n header.Nonce = \"\"\n hashString := string(header.Height) + string(header.Timestamp) + header.ParentHash + value.Root + string(header.Size)\n sum := sha3.Sum256([]byte(hashString))\n header.Hash = hex.EncodeToString(sum[:])\n\n b.Header = header\n b.Mpt = value\n}", "func generateBlock(oldBlock Block, BPM int, address string) (Block, error) {\n\n\tvar newBlock Block\n\n\tt := time.Now()\n\n\tnewBlock.Index = oldBlock.Index + 1\n\tnewBlock.Timestamp = t.String()\n\tnewBlock.BPM = BPM\n\tnewBlock.PrevHash = oldBlock.Hash\n\tnewBlock.Validator = address\n\n\tnewBlock.Hash = calculateBlockHash(newBlock)\n\tnewBlock.Data = makeSignature(newBlock.Hash)\n\n\treturn newBlock, nil\n}", "func NewBlock(index idx.Block, time Timestamp, events hash.Events, prevHash hash.Event) *Block {\n\treturn &Block{\n\t\tIndex: index,\n\t\tTime: time,\n\t\tEvents: events,\n\t\tPrevHash: prevHash,\n\t\tSkippedTxs: make([]uint, 0),\n\t}\n}", "func (honest *Honest) createBlock(iterationCount int, stakeMap map[int]int) (*Block,error) {\n\n\t// Has block already been appended from advertisements by other client?\n\tif(honest.bc.getBlock(iterationCount) != nil){\n\t\treturn nil, blockExistsError\n\t}\n\n\tpulledGradient := make([]float64, honest.ncol)\n\tpulledGradient = honest.bc.getLatestGradient()\n\tupdatedGradient := make([]float64, honest.ncol)\n\tdeltaM := mat.NewDense(1, honest.ncol, make([]float64, honest.ncol))\n\tpulledGradientM := mat.NewDense(1, honest.ncol, pulledGradient)\n\t// avgFactor := 1.0/float64(len(honest.blockUpdates))\n\n\t// Update Aggregation\n\tfor _, update := range honest.blockUpdates {\n\t\ttheirStake := stakeMap[update.SourceID] \n\t\tif update.Accepted {\n\t\t\tdeltaM = mat.NewDense(1, honest.ncol, update.Delta)\n\t\t\tpulledGradientM.Add(pulledGradientM, deltaM)\t\n\t\t\tstakeMap[update.SourceID] = theirStake + STAKE_UNIT\n\t\t} else {\n\t\t\toutLog.Printf(\"Skipping an update\")\n\t\t\tstakeMap[update.SourceID] = theirStake - STAKE_UNIT\n\t\t}\n\t}\n\n\t// pulledGradientM.Scale(avgFactor, pulledGradientM)\n\n\tmat.Row(updatedGradient, 0, pulledGradientM)\n\n\tupdatesGathered := make([]Update, len(honest.blockUpdates))\n\tcopy(updatesGathered, honest.blockUpdates)\n\n\tbData := BlockData{iterationCount, updatedGradient, updatesGathered}\n\thonest.bc.AddBlock(bData, stakeMap) \n\n\tnewBlock := honest.bc.Blocks[len(honest.bc.Blocks)-1]\n\n\treturn newBlock,nil\n\n\n}", "func NewBlock(header *Header, txs []*Transaction, receipts []*Receipt, signs []*PbftSign) *Block {\n\tb := &Block{header: CopyHeader(header)}\n\n\t// TODO: panic if len(txs) != len(receipts)\n\tif len(txs) == 0 {\n\t\tb.header.TxHash = EmptyRootHash\n\t} else {\n\t\tb.header.TxHash = DeriveSha(Transactions(txs))\n\t\tb.transactions = make(Transactions, len(txs))\n\t\tcopy(b.transactions, txs)\n\t}\n\n\tif len(receipts) == 0 {\n\t\tb.header.ReceiptHash = EmptyRootHash\n\t} else {\n\t\tb.header.ReceiptHash = DeriveSha(Receipts(receipts))\n\t\tb.header.Bloom = CreateBloom(receipts)\n\t}\n\n\tif len(receipts) == 0 {\n\t\tb.header.ReceiptHash = EmptyRootHash\n\t} else {\n\t\tb.header.ReceiptHash = DeriveSha(Receipts(receipts))\n\t\tb.header.Bloom = CreateBloom(receipts)\n\t}\n\n\tif len(signs) != 0 {\n\t\tb.signs = make(PbftSigns, len(signs))\n\t\tcopy(b.signs, signs)\n\t}\n\n\treturn b\n}", "func NewBlock(width float64, height float64) *Block {\n\tb := &Block{}\n\tb.contents = &contentstream.ContentStreamOperations{}\n\tb.resources = model.NewPdfPageResources()\n\tb.width = width\n\tb.height = height\n\treturn b\n}", "func NewBlock(data *models.Block, opts ...options.Option[Block]) (newBlock *Block) {\n\treturn options.Apply(&Block{\n\t\tstrongChildren: make([]*Block, 0),\n\t\tweakChildren: make([]*Block, 0),\n\t\tlikedInsteadChildren: make([]*Block, 0),\n\t\tModelsBlock: data,\n\t}, opts)\n}", "func (bc *Blockchain) createBlock() {\n\tnonce := bc.proofOfWork()\n\tpreviousHash := bc.lastBlock().Hash()\n\tbc.chainNewBlock(nonce, previousHash)\n}", "func NewBlock(seqNum uint64, previousHash []byte) *cb.Block {\n\tblock := &cb.Block{}\n\tblock.Header = &cb.BlockHeader{}\n\tblock.Header.Number = seqNum\n\tblock.Header.PreviousHash = previousHash\n\tblock.Header.DataHash = []byte{}\n\tblock.Data = &cb.BlockData{}\n\n\tvar metadataContents [][]byte\n\tfor i := 0; i < len(cb.BlockMetadataIndex_name); i++ {\n\t\tmetadataContents = append(metadataContents, []byte{})\n\t}\n\tblock.Metadata = &cb.BlockMetadata{Metadata: metadataContents}\n\n\treturn block\n}", "func New(storage Storage) *Block {\n\tb := Block{\n\t\tstorage: storage,\n\t}\n\tb.Transactions = make([]transaction.Transaction, 0, 0)\n\treturn &b\n}", "func (s *service) MineNewBlock(lastBlock *Block, data []Transaction) (*Block, error) {\n\t// validations\n\tif lastBlock == nil {\n\t\treturn nil, ErrMissingLastBlock\n\t}\n\n\tdifficulty := lastBlock.Difficulty\n\tvar nonce uint32\n\tvar timestamp int64\n\tvar hash string\n\tfor {\n\t\tnonce++\n\t\ttimestamp = time.Now().UnixNano()\n\t\tdifficulty = adjustBlockDifficulty(*lastBlock, timestamp, s.MineRate)\n\t\thash = hashing.SHA256Hash(timestamp, *lastBlock.Hash, data, nonce, difficulty)\n\t\tif hexStringToBinary(hash)[:difficulty] == strings.Repeat(\"0\", int(difficulty)) {\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn yieldBlock(timestamp, lastBlock.Hash, &hash, data, nonce, difficulty), nil\n}", "func (b *Block) CreateGenesisBlock() {\n\n header := Header{0, int64(time.Now().Unix()), \"GenesisBlock\", \"\", 0, \"\"}\n b.Mpt = p1.GetMPTrie()\n b.Header = header\n}", "func generateBlock(oldBlock Block, Key int) Block {\n\n\tvar newBlock Block\n\n\tt := time.Now()\n\n\tnewBlock.Index = oldBlock.Index + 1\n\tnewBlock.Timestamp = t.String()\n\tnewBlock.Key = Key\n\tnewBlock.PrevHash = oldBlock.Hash\n\tnewBlock.Hash = calculateHash(newBlock)\n\n\tf, err := os.OpenFile(\"blocks.txt\",\n\t\tos.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)\n\tif err != nil {\n\t\tlog.Println(err)\n\t}\n\tb, err := json.Marshal(newBlock)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tdefer f.Close()\n\tif _, err := f.WriteString(string(b)); err != nil {\n\t\tlog.Println(err)\n\t}\n\n\treturn newBlock\n}", "func NewBlock(data Data, previousBlock Block, noonce string) Block {\n\tnewBlock := Block{\n\t\ttimestamp: time.Now(),\n\t\tdata: data,\n\t\tpreviousHash: previousBlock.GetHash(),\n\t\tnoonce: noonce,\n\t}\n\tnewBlock.hash()\n\n\treturn newBlock\n}", "func generateBlock(oldBlock Block, BPM int, address string) (Block, error) {\n\n\tvar newBlock Block\n\n\tt := time.Now()\n\n\tnewBlock.Index = oldBlock.Index + 1\n\tnewBlock.Timestamp = t.String()\n\tnewBlock.BPM = BPM\n\tnewBlock.PrevHash = oldBlock.Hash\n\tnewBlock.Hash = calculateBlockHash(newBlock)\n\tnewBlock.Validator = address\n\n\treturn newBlock, nil\n}", "func NewBlock(block Block, data string) Block {\r\n\tt := time.Now().Unix()\r\n\tBlockID := block.BlockID\r\n\tBlockID++\r\n\thashed := sha256.Sum256([]byte(data))\r\n\tsignature, err := rsa.SignPKCS1v15(rand.Reader, nodeinfo.PrivateKey, crypto.SHA256, hashed[:])\r\n\tif err != nil {\r\n\t\tlog.Fatalln(err)\r\n\t}\r\n\tnonce, hash := computeHashWithProofOfWork(IntToStr(BlockID)+IntToStr(t)+data+string(signature)+nodeinfo.NodeID+block.Hash, nodeinfo.Difficulty)\r\n\treturn Block{BlockID, t, data, signature, nodeinfo.NodeID, block.Hash, hash, nonce}\r\n}", "func NewBlock(_data string, _prevHash []byte) *Block {\n\t_block := &Block{\n\t\tTimestamp: time.Now().Unix(),\n\t\tData: []byte(_data),\n\t\tPrevHash: _prevHash,\n\t\tHash: []byte{},\n\t}\n\n\tpow := NewProofOfWork(_block)\n\tnonce, hash := pow.Run()\n\n\t_block.Nonce = nonce\n\t_block.Hash = hash[:]\n\n\treturn _block\n}", "func (a *insight) NewBlock(id interface{}) *block {\n\tb := new(block)\n\tb.insight = a\n\tswitch v := id.(type) {\n\tcase int:\n\t\tb.Height = int(v)\n\t\tb.hash()\n\t\tb.pages()\n\t\tb.info()\n\t\treturn b\n\tcase string:\n\t\tb.Hash = string(v)\n\t\tb.pages()\n\t\tb.info()\n\t\treturn b\n\tcase nil:\n\t\treturn b.latestBlock()\n\t}\n\treturn nil\n}", "func (oc *Operachain) MakeBlock(name string) {\n\tvar newHeight int\n\tvar tip []byte\n\terr := oc.Db.View(func(tx *bolt.Tx) error {\n\t\tb := tx.Bucket([]byte(blocksBucket))\n\t\ttip = b.Get([]byte(\"l\"))\n\t\ttipData := b.Get(tip)\n\t\ttipBlock := DeserializeBlock(tipData)\n\t\tnewHeight = tipBlock.Height + 1\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tnewBlock := NewBlock(oc.MyName, tip, oc.KnownTips[name], newHeight)\n\n\toc.AddBlock(newBlock)\n\n\toc.MyGraph.Tip = oc.BuildGraph(newBlock.Hash, oc.MyGraph.ChkVertex, oc.MyGraph)\n\tfmt.Println(\"create new block\")\n\t//oc.UpdateChk = true\n}", "func NewBlock(tlvType uint32, value []byte) *Block {\n\tvar block Block\n\tblock.tlvType = tlvType\n\tblock.value = value\n\t// copy(block.value, value)\n\treturn &block\n}", "func (self *BlockChain) NewBlock(proof int, previous_hash string) {\n\n\t// check if previous hash matches self.hash(self.chain[-1])\n\tt := time.Now()\n\n\tblock := Block{\n\t\tIndex: len(self.Chain) + 1,\n\t\tTimestamp: t.UnixNano(),\n\t\tTransactions: self.CurrentTransactions,\n\t\tProof: proof,\n\t\tPreviousHash: previous_hash}\n\n\t// Reset the current list of transactions\n\tself.CurrentTransactions = nil\n\tself.Chain = append(self.Chain, block)\n}", "func NewBlock(statements []sql.Node) *Block {\n\treturn &Block{statements: statements}\n}", "func NewBlock(tx *Transaction) *Block {\n\t\n\treturn nil\n}", "func NewBlock(data string, prevBlockHash []byte) *Block {\n\tblock := &Block{time.Now().Unix(), []byte(data), prevBlockHash, []byte{}, 0}\n\tpow := NewProofOfWork(block)\n\n\tnonce, hash := pow.Run()\n\n\tblock.Hash = hash[:]\n\tblock.Nonce = nonce\n\n\treturn block\n}", "func NewBlock() *Block {\n\treturn &Block{}\n}", "func NewBlock(sigKey ed25519.PrivateKey, previousBlock BlockID, txs []*Transaction) (*Block, error) {\n\trand_bytes := make([]byte, 8)\n\t_, err := rand.Read(rand_bytes)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to get Random data\")\n\t}\n\ttemp := binary.LittleEndian.Uint64(rand_bytes)\n\tb := &Block{\n\t\tHeader: &BlockHeader{\n\t\t\tVersion: 0,\n\t\t\tPreviousBlock: previousBlock,\n\t\t\tTimestamp: 0, // XXX: Populate this correctly.\n\t\t\tRandom: temp,\n\t\t},\n\t\tTransactions: &Transactions{Transactions: txs},\n\t}\n\n\tb.Header.MerkleRoot, err = b.MerkleRoot()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to compute merkle root\")\n\t}\n\n\tbid := b.BlockID()\n\tb.Header.Signature = ed25519.Sign(sigKey, bid[:])\n\n\treturn b, nil\n}", "func newBlockBuffer(blockSize int64) *blockBuffer {\n\treturn &blockBuffer{\n\t\tblockSize: blockSize,\n\t\tsgl: glMem2.NewSGL(blockSize, blockSize),\n\t\tvalid: false,\n\t}\n}", "func NewBlock(prev Block, currentTime uint64, uxHash cipher.SHA256, txns Transactions, calc FeeCalculator) (*Block, error) {\n\tif len(txns) == 0 {\n\t\treturn nil, fmt.Errorf(\"Refusing to create block with no transactions\")\n\t}\n\n\tfee, err := txns.Fees(calc)\n\tif err != nil {\n\t\t// This should have been caught earlier\n\t\treturn nil, fmt.Errorf(\"Invalid transaction fees: %v\", err)\n\t}\n\n\tbody := BlockBody{txns}\n\thead := NewBlockHeader(prev.Head, uxHash, currentTime, fee, body)\n\treturn &Block{\n\t\tHead: head,\n\t\tBody: body,\n\t}, nil\n}", "func generateBlock(previousBlock Block, BPM int, address string) (Block, error) {\n\n\tnewBlock := Block{\n\t\tIndex: previousBlock.Index + 1,\n\t\tTimestamp: time.Now().String(),\n\t\tBPM: BPM,\n\t\tPrevHash: previousBlock.Hash,\n\t}\n\tnewBlock.Hash = calculateBlockHash(newBlock)\n\tnewBlock.Validator = address\n\n\treturn newBlock, nil\n}", "func (c *Crawler) newBlock(block *wire.MsgBlock, hash *chainhash.Hash) {\t\n\tc.height += 1\n\tc.blockQueue.PushBack(*hash)\n\n\tif c.blockQueue.Len() > BlockQueueSize {\n\t\tc.blockQueue.PopFront()\n\t}\n}", "func CreateBlock(data string, prevHash []byte) *Block {\n\tblock := &Block{[]byte{}, []byte(data), prevHash, 0}\n\tpow := NewProof(block)\n\tnonce, hash := pow.Run()\n\n\tblock.Hash = hash[:]\n\tblock.Nonce = nonce\n\n\treturn block\n}", "func NewBlock(data string, prevBlockHash []byte) *Block {\n\tblock := &Block{\n\t\tTimestamp: time.Now().Unix(),\n\t\tData: []byte(data),\n\t\tPrevBlockHash: prevBlockHash,\n\t\tHash: []byte{},\n\t}\n\tpow := NewProofOfWork(block)\n\tnonce, hash := pow.Run()\n\n\tblock.Hash = hash[:]\n\tblock.Nonce = nonce\n\n\treturn block\n}", "func NewBlock(prev Block, currentTime uint64, uxHash cipher.SHA256, txns Transactions, calc FeeCalculator) (*Block, error) {\n\tif len(txns) == 0 {\n\t\treturn nil, fmt.Errorf(\"Refusing to create block with no transactions\")\n\t}\n\n\tfee, err := txns.Fees(calc)\n\tif err != nil {\n\t\t// This should have been caught earlier\n\t\treturn nil, fmt.Errorf(\"Invalid transaction fees: %v\", err)\n\t}\n\n\tbody := BlockBody{txns}\n\treturn &Block{\n\t\tHead: NewBlockHeader(prev.Head, uxHash, currentTime, fee, body),\n\t\tBody: body,\n\t}, nil\n}", "func NewBlock(data string, prevBlockHash []byte) *Block {\n\tblock := &Block{\n\t\tTimestamp: time.Now().UTC().Unix(),\n\t\tPrevBlockHash: prevBlockHash,\n\t\tHash: []byte{},\n\t\tData: []byte(data),\n\t}\n\n\tpow := NewProofOfWork(block)\n\tnonce, hash := pow.Run()\n\n\tblock.Hash = hash[:]\n\tblock.Nonce = nonce\n\n\treturn block\n}", "func CreateBlock(txs []*Transaction, prevHash []byte) *Block {\n\tblock := &Block{[]byte{}, txs, prevHash, 0}\n\tpow := NewProof(block)\n\tnonce, hash := pow.Run()\n\n\tblock.Hash = hash[:]\n\tblock.Nonce = nonce\n\treturn block\n}", "func (wc *WalletClient) NewBlock(b Block) error {\n\t_, err := wc.POST(\"/new-block\", b.Json())\n\treturn err\n}", "func CreateBlock(transactions []*Transaction, prevHash []byte) *Block {\n\tblock := &Block{time.Now().Unix(), transactions, prevHash, []byte{}, 0}\n\tpow := CreatePoW(block)\n\tnonce, hash := pow.Mine()\n\n\tblock.Hash = hash[:]\n\tblock.Nonce = nonce\n\n\treturn block\n}", "func newblock(prog *obj.Prog) *BasicBlock {\n\tif prog == nil {\n\t\tFatal(\"newblock: prog cannot be nil\")\n\t}\n\tresult := new(BasicBlock)\n\tresult.rpo = -1\n\tresult.mark = UNVISITED\n\tresult.first = prog\n\tresult.last = prog\n\tresult.pred = make([]*BasicBlock, 0, 2)\n\tresult.succ = make([]*BasicBlock, 0, 2)\n\treturn result\n}", "func NewBlock(previousBlock Block, data string) (Block, error) {\n\tvar newBlock Block\n\n\tnewBlock.Index = previousBlock.Index + 1\n\tnewBlock.Timestamp = time.Now().String()\n\tnewBlock.Data = data\n\tnewBlock.PrevHash = previousBlock.Hash\n\tnewBlock.Difficulty = GetDifficulty()\n\n\tif !isCandidateBlockValid(newBlock, previousBlock) {\n\t\treturn newBlock, errors.New(\"Candidate block is not valid\")\n\t}\n\n\tmineBlock(&newBlock)\n\n\treturn newBlock, nil\n}", "func CreateBlock(txs []*Transaction, prevHash []byte) *Block {\n\tblock := &Block{Hash: []byte{}, Transactions: txs, PrevHash: prevHash, Nonce: 0}\n\tpow := NewProof(block)\n\tnonce, hash := pow.Run()\n\tblock.Hash = hash\n\tblock.Nonce = nonce\n\treturn block\n}", "func New(ctx context.Context, now NowFunc) *Blockchain {\n\tvar b = Blockchain{\n\t\tnow: now,\n\t}\n\n\tgenesisBlock := Block{\n\t\t0,\n\t\tb.now().String(),\n\t\t0,\n\t\t\"\",\n\t\t\"\",\n\t}\n\n\tb.Blocks = append(b.Blocks, genesisBlock)\n\n\treturn &b\n}", "func Block(b models.Block) *genModels.BlocksRow {\n\tts := b.Timestamp.Unix()\n\n\tgenBlock := genModels.BlocksRow{\n\t\tLevel: b.Level.Ptr(),\n\t\tProto: b.Proto.Ptr(),\n\t\tBlockTime: b.BlockTime,\n\t\tPredecessor: b.Predecessor.Ptr(),\n\t\tTimestamp: &ts,\n\t\tValidationPass: b.ValidationPass.Ptr(),\n\t\tFitness: b.Fitness.Ptr(),\n\t\tContext: b.Context,\n\t\tSignature: b.Signature,\n\t\tProtocol: b.Protocol.Ptr(),\n\t\tPriority: b.Priority.Ptr(),\n\t\tChainID: b.ChainID,\n\t\tHash: b.Hash.Ptr(),\n\t\tReward: &b.Reward,\n\t\tDeposit: b.Deposit,\n\t\tOperationsHash: b.OperationsHash,\n\t\tPeriodKind: b.PeriodKind,\n\t\tCurrentExpectedQuorum: b.CurrentExpectedQuorum,\n\t\tActiveProposal: b.ActiveProposal,\n\t\tBaker: b.Baker,\n\t\tBakerName: b.BakerName,\n\t\tNonceHash: b.NonceHash,\n\t\tConsumedGas: b.ConsumedGas,\n\t\tMetaLevel: b.MetaLevel,\n\t\tMetaLevelPosition: b.MetaLevelPosition,\n\t\tMetaCycle: b.MetaCycle,\n\t\tMetaCyclePosition: b.MetaCyclePosition,\n\t\tMetaVotingPeriod: b.MetaVotingPeriod,\n\t\tMetaVotingPeriodPosition: b.MetaVotingPeriodPosition,\n\t\tExpectedCommitment: b.ExpectedCommitment,\n\t}\n\n\tif b.BlockAggregation != nil {\n\t\tgenBlock.Volume = b.BlockAggregation.Volume\n\t\tgenBlock.Fees = b.BlockAggregation.Fees\n\t\tgenBlock.Endorsements = b.BlockAggregation.Endorsements\n\t\tgenBlock.Proposals = b.BlockAggregation.Proposals\n\t\tgenBlock.SeedNonceRevelations = b.BlockAggregation.SeedNonceRevelations\n\t\tgenBlock.Delegations = b.BlockAggregation.Delegations\n\t\tgenBlock.Transactions = b.BlockAggregation.Transactions\n\t\tgenBlock.ActivateAccounts = b.BlockAggregation.ActivateAccounts\n\t\tgenBlock.Ballots = b.BlockAggregation.Ballots\n\t\tgenBlock.Originations = b.BlockAggregation.Originations\n\t\tgenBlock.Reveals = b.BlockAggregation.Reveals\n\t\tgenBlock.DoubleBakingEvidence = b.BlockAggregation.DoubleBakingEvidences\n\t\tgenBlock.DoubleEndorsementEvidence = b.BlockAggregation.DoubleEndorsementEvidences\n\t\tgenBlock.NumberOfOperations = b.BlockAggregation.NumberOfOperations\n\t}\n\n\treturn &genBlock\n}", "func NewBlock(typeName string, labels []string) *Block {\n\tblock := newBlock()\n\tblock.init(typeName, labels)\n\treturn block\n}", "func NewBlock(typeName string, labels []string) *Block {\n\tblock := newBlock()\n\tblock.init(typeName, labels)\n\treturn block\n}", "func NewBlock(index uint64, ordered Events) *Block {\n\tevents := make(hash.EventsSlice, len(ordered))\n\tfor i, e := range ordered {\n\t\tevents[i] = e.Hash()\n\t}\n\n\treturn &Block{\n\t\tIndex: index,\n\t\tEvents: events,\n\t}\n}", "func newChunkBlock(chunks []*chunk, reporter errorLocationReporter) *chunk {\n\tr := newChunk(CHUNK_BLOCK, reporter)\n\tr.m[\"chunks\"] = chunks\n\treturn r\n}", "func CreateBlock(txs []*Transaction, PrevHash []byte, height int) *Block {\n\tblock := &Block{time.Now().Unix(), []byte{}, txs, PrevHash, 0, height}\n\tpow := NewProof(block)\n\tnonce, hash := pow.Run()\n\tblock.Nonce = nonce\n\tblock.Hash = hash[:]\n\treturn block\n}", "func NewBlock(data string, transactions []*Tx, prevBlockHash []byte) *Block {\n\tblock := &Block{\n\t\tIdentifier: internal.GenerateID(),\n\t\tData: []byte(data),\n\t\tTransactions: transactions,\n\t\tPrevBlockHash: prevBlockHash,\n\t\tTimestamp: time.Now().Unix(),\n\t}\n\n\tpow := NewPow(block)\n\tnonce, hash := pow.Run()\n\n\tblock.Hash = hash[:]\n\tblock.Nonce = nonce\n\treturn block\n}", "func newBlockCipher(key string) (cipher.Block, error) {\n\n\thash := md5.New()\n\tfmt.Fprint(hash, key)\n\tcipherKey := hash.Sum(nil)\n\treturn aes.NewCipher(cipherKey)\n}", "func (b *Blockchain) InsertNewBlock(ctx context.Context, value int) (*Block, error) {\n\tvar err error\n\n\tlastBlock := b.Blocks[len(b.Blocks)-1]\n\n\t// Generate new block\n\tnewBlock, err := b.generateBlock(lastBlock, value)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Validate new block\n\terr = validateBlock(*newBlock, lastBlock)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Add new block to Blockchain\n\tnewBlockchain := append(b.Blocks, *newBlock)\n\tb.replaceChain(newBlockchain)\n\n\treturn newBlock, nil\n}", "func makeGenesisBlock() Block {\n\ttext := \"Welcome to this Go-Blockchain!\"\n\tblock := Block{}\n\n\t//Find suitable hash\n\tblock.HashPoW, block.textNoncePoW = \"0\", \"0\"\n\n\t//Define Header elements\n\tblock.Index = 0\n\tblock.Timestamp = time.Now()\n\tblock.PrevHashHeader = \"0\"\n\n\t//make hash of Header elements\n\tblock.blockHash = makeBlockHash(block)\n\n\t//Define Data\n\tblock.payload = text\n\treturn block\n}", "func (*blockR) NewStruct() *blockR {\n\treturn &blockR{}\n}", "func (c *Context) CreateBlock() block.Block {\n\tif c.block == nil {\n\t\tif c.block = c.MakeHeader(); c.block == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\ttxx := make([]block.Transaction, len(c.TransactionHashes))\n\n\t\tfor i, h := range c.TransactionHashes {\n\t\t\ttxx[i] = c.Transactions[h]\n\t\t}\n\n\t\tc.block.SetTransactions(txx)\n\t}\n\n\treturn c.block\n}", "func generateRandomBlock() types.Block {\n\tblock := types.Block{\n\t\tTimestamp: types.Timestamp(rand.Uint64()),\n\t}\n\treturn block\n}", "func (w *Writer) newBlockWriter(typ byte) *blockWriter {\n\tblock := w.block\n\n\tvar blockStart uint32\n\tif w.next == 0 {\n\t\thb := w.headerBytes()\n\t\tblockStart = uint32(copy(block, hb))\n\t}\n\n\tbw := newBlockWriter(typ, block, blockStart)\n\tbw.restartInterval = w.opts.RestartInterval\n\treturn bw\n}", "func (t *Blockchain) New() *Blockchain {\n\tt = new(Blockchain)\n\tt.NewBlock(100, \"1\")\n\treturn t\n}", "func (s *BlockchainService) generateBlock(oldBlock *Block, payload int) Block {\n\tvar newBlock Block\n\n\tt := time.Now()\n\n\tnewBlock.Index = oldBlock.Index + 1\n\tnewBlock.Timestamp = t.String()\n\tnewBlock.Payload = payload\n\tnewBlock.PrevHash = oldBlock.Hash\n\tnewBlock.Hash = calculateHash(&newBlock)\n\n\treturn newBlock\n}", "func NewBlock(hash string) *pfs.Block {\n\treturn &pfs.Block{\n\t\tHash: hash,\n\t}\n}", "func NewBlock(transactionPool *mempool, previousBlock *Block) *Block {\n\n\tcurrentBlock := Block{}\n\tcurrentBlock.PreviousBlock = previousBlock\n\n\t// First, select which transactions the block will contain\n\tselectedTransactions := selectTransactions(transactionPool)\n\tcurrentBlock.Transactions = selectedTransactions\n\n\t// Second, calculate the hash of the selected transactions\n\thashedTransaction := string(processTransactions(selectedTransactions))\n\thashedBlockData := hashedTransaction + currentBlock.Hash\n\tcurrentBlock.Hash = hashedBlockData\n\treturn &currentBlock\n}", "func newBlockStorage(c *Config, b *Block) *blockStorage {\n\treturn &blockStorage{\n\t\tc: c,\n\t\tblock: b,\n\t\tsigs: make(map[int][]byte),\n\t\tpub: share.NewPubPoly(G2, G2.Point().Base(), c.Public),\n\t}\n}", "func createTestBlock() (blk *DBlock, err error) {\n\tcmd := exec.Command(\"rm\", \"-rf\", \"/tmp/test-dblock\")\n\tif err := cmd.Run(); err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = os.MkdirAll(\"/tmp/test-dblock\", 0777)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tblk, err = New(Options{\n\t\tBlockPath: \"/tmp/test-dblock\",\n\t\tPayloadSize: 4,\n\t\tPayloadCount: 100,\n\t\tSegmentSize: 100000,\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif blk == nil {\n\t\terr = errors.New(\"block should not be nil\")\n\t\treturn nil, err\n\t}\n\n\treturn blk, nil\n}", "func New() *Blockstream {\n\treturn &Blockstream{}\n}", "func mineNewBlock (block *Block) {\n proofPrefix := strings.Repeat(\"0\", difficulty)\n for calculateHash(*block)[:difficulty] != proofPrefix {\n block.Nonce ++\n }\n\n block.Hash = calculateHash(*block)\n}", "func GenerateBlock(oldBlock model.Block, data string, address string) (model.Block, error) {\n\n\tvar newBlock model.Block\n\n\tt := time.Now()\n\n\tnewBlock.Index = oldBlock.Index + 1\n\tnewBlock.Timestamp = t.String()\n\tnewBlock.Data = data\n\tnewBlock.PrevHash = oldBlock.Hash\n\tnewBlock.Hash = crypto.CalculateBlockHash(newBlock)\n\tnewBlock.Validator = address\n\n\treturn newBlock, nil\n}", "func (b Engine) block(difficulty uint8) *core.Block {\n\t//random data\n\tpriv, _ := crypt.GenKeys()\n\tj, _ := job.NewJob(\"func test(){return 1+1}\", \"test\", false, priv)\n\tnodes := []*merkletree.MerkleNode{}\n\tfor i := 0; i < 16; i++ {\n\t\tnode, err := merkletree.NewNode(*j, nil, nil)\n\t\tif err != nil {\n\t\t\tb.logger.Fatal(err)\n\t\t}\n\t\tnodes = append(nodes, node)\n\t}\n\ttree, err := merkletree.NewMerkleTree(nodes)\n\tif err != nil {\n\t\tb.logger.Fatal(err)\n\t}\n\tblock, err := core.NewBlock(*tree, \"47656e65736973\", uint64(rand.Int()), difficulty, \"62656e63686d61726b2d656e67696e65\")\n\tif err != nil {\n\t\tb.logger.Fatal(err)\n\t}\n\treturn block\n}", "func generateGenesisBlock() Block {\n\n\tvar genesisBlock Block\n\tvar genesisRecord ServiceEvent\n\tvar genesisRecordEventDescription EventDescription\n\tvar genesisRecordEventDescriptionType EventType\n\tvar genesisRecordVehicle Vehicle\n\tvar genesisRecordGarage Garage\n\n\t// Seed values for Garage, Vehicle, EventType and EventDescription\n\tgenesisRecordGarage.GarageId = 0\n\tgenesisRecordGarage.Location = \"genesis location\"\n\tgenesisRecordGarage.Name = \"genesis inc.\"\n\tgenesisRecordGarage.Owner = \"genesis and co.\"\n\tgenesisRecordGarage.Type = \"main dealer\"\n\n\tgenesisRecordVehicle.V5c = \"63ne515\"\n\tgenesisRecordVehicle.VehicleColour = append(genesisRecordVehicle.VehicleColour, \"starting colour\")\n\tgenesisRecordVehicle.VehicleMake = \"genesis make\"\n\tgenesisRecordVehicle.VehicleModel = \"genesis model\"\n\tgenesisRecordVehicle.VehicleRegistration = append(genesisRecordVehicle.VehicleRegistration, \"GEN 351 S\")\n\n\tgenesisRecordEventDescriptionType.EventId = 0\n\tgenesisRecordEventDescriptionType.EventDescription = \"genesis event\"\n\n\tgenesisRecordEventDescription.EventItem = append(genesisRecordEventDescription.EventItem, genesisRecordEventDescriptionType)\n\tgenesisRecordEventDescription.VehicleMilage = 10000000\n\n\t// Pull all the objects into ServiceEvent\n\tgenesisRecord.EventAuthorisor = \"Created by serviceChain as the Genesis Block\"\n\tgenesisRecord.EventDetails = genesisRecordEventDescription\n\tgenesisRecord.Identifier = 1\n\tgenesisRecord.PerformedBy = genesisRecordGarage\n\tgenesisRecord.PerformedOnVehicle = genesisRecordVehicle\n\n\t// Set the values for the Block\n\tgenesisBlock.Index = 1\n\tgenesisBlock.Hash = \"0\"\n\tgenesisBlock.PrevHash = \"0\"\n\tgenesisBlock.Timestamp = time.Now().String()\n\tgenesisBlock.Event = genesisRecord\n\n\tblockString, err := json.MarshalIndent(genesisBlock, \"\", \"\\t\")\n\tif err != nil {\n\t\tlog.Println(\"INFO: serviceChain.createGenesisBlock(): Problem creating the JSON output of the genesis block. Continuing...\")\n\t}\n\n\tlog.Println(\"INFO: serviceChain.generateGenesisBlock(): Created block with contents: \" + string(blockString))\n\n\treturn genesisBlock\n}", "func NewBlock(transactions []*Transaction, preBlockHash []byte) *Block {\n\tb := &Block{time.Now().Unix(), transactions, preBlockHash, []byte{}, 252, 0}\n\n\tpow := NewProofOfWork(b)\n\tnonce, hash := pow.Run()\n\n\tb.Nonce = nonce\n\tb.Hash = hash[:]\n\n\treturn b\n}", "func NewBlock(\n\tblockStart xtime.UnixNano,\n\tmd namespace.Metadata,\n\tblockOpts BlockOptions,\n\tnamespaceRuntimeOptsMgr namespace.RuntimeOptionsManager,\n\topts Options,\n) (Block, error) {\n\tblockSize := md.Options().IndexOptions().BlockSize()\n\tiopts := opts.InstrumentOptions()\n\tscope := iopts.MetricsScope().SubScope(\"index\").SubScope(\"block\")\n\tiopts = iopts.SetMetricsScope(scope)\n\n\tcpus := int(math.Max(1, math.Ceil(0.25*float64(runtime.GOMAXPROCS(0)))))\n\tcachedSearchesWorkers := xsync.NewWorkerPool(cpus)\n\tcachedSearchesWorkers.Init()\n\n\tsegs := newMutableSegments(\n\t\tmd,\n\t\tblockStart,\n\t\topts,\n\t\tblockOpts,\n\t\tcachedSearchesWorkers,\n\t\tnamespaceRuntimeOptsMgr,\n\t\tiopts,\n\t)\n\n\tcoldSegs := newMutableSegments(\n\t\tmd,\n\t\tblockStart,\n\t\topts,\n\t\tblockOpts,\n\t\tcachedSearchesWorkers,\n\t\tnamespaceRuntimeOptsMgr,\n\t\tiopts,\n\t)\n\n\t// NB(bodu): The length of coldMutableSegments is always at least 1.\n\tcoldMutableSegments := []*mutableSegments{coldSegs}\n\tb := &block{\n\t\tstate: blockStateOpen,\n\t\tblockStart: blockStart,\n\t\tblockEnd: blockStart.Add(blockSize),\n\t\tblockSize: blockSize,\n\t\tblockOpts: blockOpts,\n\t\tcachedSearchesWorkers: cachedSearchesWorkers,\n\t\tmutableSegments: segs,\n\t\tcoldMutableSegments: coldMutableSegments,\n\t\tshardRangesSegmentsByVolumeType: make(shardRangesSegmentsByVolumeType),\n\t\topts: opts,\n\t\tiopts: iopts,\n\t\tnsMD: md,\n\t\tnamespaceRuntimeOptsMgr: namespaceRuntimeOptsMgr,\n\t\tmetrics: newBlockMetrics(scope),\n\t\tlogger: iopts.Logger(),\n\t\tfetchDocsLimit: opts.QueryLimits().FetchDocsLimit(),\n\t\taggDocsLimit: opts.QueryLimits().AggregateDocsLimit(),\n\t}\n\tb.newFieldsAndTermsIteratorFn = newFieldsAndTermsIterator\n\tb.newExecutorWithRLockFn = b.executorWithRLock\n\tb.addAggregateResultsFn = b.addAggregateResults\n\n\treturn b, nil\n}", "func (build *blockBuilder) Create() chained.BlockBuilder {\n\tbuild.id = nil\n\tbuild.met = nil\n\tbuild.blk = nil\n\tbuild.prevID = nil\n\tbuild.crOn = nil\n\treturn build\n}", "func (b *Builder) Block() *Builder {\n\treturn new(Builder)\n}", "func NewBlock(version uint32,\n\tprevBlock []byte,\n\tmerkleRoot []byte,\n\ttimestamp uint32,\n\tbits []byte,\n\tnonce []byte,\n\ttotal uint32,\n\thashes [][]byte,\n\tflags []byte) *Block {\n\tresult := &Block{\n\t\tVersion: version,\n\t\tTimestamp: timestamp,\n\t\tTotal: total,\n\t\tHashes: hashes,\n\t\tFlags: flags,\n\t}\n\tcopy(result.PrevBlock[:32], prevBlock)\n\tcopy(result.MerkleRoot[:32], merkleRoot)\n\tcopy(result.Bits[:4], bits)\n\tcopy(result.Nonce[:4], nonce)\n\treturn result\n}", "func NewBlock(filename string, blockNum int) *Block {\n\treturn &Block{FileName: filename, BlockNum: blockNum}\n}", "func NewBlockHeader(prev BlockHeader, uxHash cipher.SHA256, currentTime, fee uint64, body BlockBody) BlockHeader {\n\tif currentTime <= prev.Time {\n\t\tlog.Panic(\"Time can only move forward\")\n\t}\n\tbodyHash := body.Hash()\n\tprevHash := prev.Hash()\n\treturn BlockHeader{\n\t\tBodyHash: bodyHash,\n\t\tVersion: prev.Version,\n\t\tPrevHash: prevHash,\n\t\tTime: currentTime,\n\t\tBkSeq: prev.BkSeq + 1,\n\t\tFee: fee,\n\t\tUxHash: uxHash,\n\t}\n}", "func NewBlock(chain uint64, producer Address) *StBlock {\n\tvar hashPowerLimit uint64\n\tvar blockInterval uint64\n\tvar pStat BaseInfo\n\tout := new(StBlock)\n\tgetDataFormDB(chain, dbStat{}, []byte{StatBaseInfo}, &pStat)\n\tgetDataFormDB(chain, dbStat{}, []byte{StatHashPower}, &hashPowerLimit)\n\tgetDataFormDB(chain, dbStat{}, []byte{StatBlockInterval}, &blockInterval)\n\n\tif pStat.ID == 0 {\n\t\tlog.Println(\"fail to get the last block. chain:\", chain)\n\t\treturn nil\n\t}\n\n\thashPowerLimit = hashPowerLimit / 1000\n\tif hashPowerLimit < minHPLimit {\n\t\thashPowerLimit = minHPLimit\n\t}\n\n\tout.HashpowerLimit = hashPowerLimit\n\n\tif pStat.ID == 1 && chain > 1 {\n\t\tpStat.Time = pStat.Time + blockSyncMax + blockSyncMin + TimeSecond\n\t} else {\n\t\tpStat.Time += blockInterval\n\t}\n\n\tout.Previous = pStat.Key\n\tout.Producer = producer\n\tout.Time = pStat.Time\n\n\tout.Chain = chain\n\tout.Index = pStat.ID + 1\n\n\tif pStat.Chain > 1 {\n\t\tvar key Hash\n\t\tvar tmp BlockInfo\n\t\tgetDataFormLog(chain/2, logBlockInfo{}, runtime.Encode(pStat.ParentID+1), &key)\n\t\tgetDataFormLog(chain/2, logBlockInfo{}, key[:], &tmp)\n\t\tif out.Index != 2 && !key.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\tvar key2 Hash\n\t\t\tgetDataFormLog(chain/2, logBlockInfo{}, runtime.Encode(pStat.ParentID+2), &key2)\n\t\t\tgetDataFormLog(chain/2, logBlockInfo{}, key2[:], &tmp)\n\t\t\tif !key2.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\t\tout.Parent = key2\n\t\t\t} else {\n\t\t\t\tout.Parent = key\n\t\t\t}\n\t\t\t// assert(out.Time-tmp.Time <= blockSyncMax)\n\t\t} else {\n\t\t\tgetDataFormLog(chain/2, logBlockInfo{}, runtime.Encode(pStat.ParentID), &key)\n\t\t\tout.Parent = key\n\t\t}\n\t}\n\tif pStat.LeftChildID > 0 {\n\t\tvar key Hash\n\t\tvar tmp BlockInfo\n\t\tgetDataFormLog(2*chain, logBlockInfo{}, runtime.Encode(pStat.LeftChildID+1), &key)\n\t\tgetDataFormLog(2*chain, logBlockInfo{}, key[:], &tmp)\n\t\tif !key.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\tvar key2 Hash\n\t\t\tgetDataFormLog(2*chain, logBlockInfo{}, runtime.Encode(pStat.LeftChildID+2), &key2)\n\t\t\tgetDataFormLog(2*chain, logBlockInfo{}, key2[:], &tmp)\n\t\t\tif !key2.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\t\tout.LeftChild = key2\n\t\t\t} else {\n\t\t\t\tout.LeftChild = key\n\t\t\t}\n\t\t\t// assert(out.Time-tmp.Time <= blockSyncMax)\n\t\t} else if pStat.LeftChildID == 1 {\n\t\t\tgetDataFormLog(chain, logBlockInfo{}, runtime.Encode(pStat.LeftChildID), &key)\n\t\t\tout.LeftChild = key\n\t\t} else {\n\t\t\tgetDataFormLog(2*chain, logBlockInfo{}, runtime.Encode(pStat.LeftChildID), &key)\n\t\t\tout.LeftChild = key\n\t\t}\n\t}\n\tif pStat.RightChildID > 0 {\n\t\tvar key Hash\n\t\tvar tmp BlockInfo\n\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, runtime.Encode(pStat.RightChildID+1), &key)\n\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, key[:], &tmp)\n\t\tif !key.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\tvar key2 Hash\n\t\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, runtime.Encode(pStat.RightChildID+2), &key2)\n\t\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, key2[:], &tmp)\n\t\t\tif !key2.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\t\tout.RightChild = key2\n\t\t\t} else {\n\t\t\t\tout.RightChild = key\n\t\t\t}\n\t\t\t// assert(out.Time-tmp.Time <= blockSyncMax)\n\t\t} else if pStat.RightChildID == 1 {\n\t\t\tgetDataFormLog(chain, logBlockInfo{}, runtime.Encode(pStat.RightChildID), &key)\n\t\t\tout.RightChild = key\n\t\t} else {\n\t\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, runtime.Encode(pStat.RightChildID), &key)\n\t\t\tout.RightChild = key\n\t\t}\n\t}\n\n\treturn out\n}", "func (app *BurrowMint) BeginBlock(hash []byte, header *abci.Header) {\n\n}", "func GetNewBlock(blocks [][][]int)([][]int,[]int){\n\tLocationOfBlock := []int{0,3}\n\tNumberBlock := rand.Intn(7)\n block := blocks[NumberBlock]\n\tnum := rand.Intn(7)+1\n\tfor row := 0; row<len(block);row++{\n\t\tfor colum :=0; colum<len(block[row]); colum++{\n\t\t\tif block[row][colum] != 0{\n\t\t\t\tblock[row][colum] = num\n\t\t\t}\n\t\t}\n }\n\treturn block, LocationOfBlock\n}", "func (bc *Blockchain) AddBlock() {\n newBlock := new(Block)\n newBlock.Proof, newBlock.Timestamp = bc.ProofOfWork()\n //newBlock.Timestamp = time.Now().Unix()\n newBlock.Index = len(bc.Chain)\n newBlock.PreviousHash = bc.HashBlock(bc.Chain[len(bc.Chain) - 1])\n newBlock.Difficulty = bc.AdjustDifficulty()\n\n bc.BlockMutex.Lock()\n bc.Chain = append(bc.Chain, *newBlock)\n bc.BlockMutex.Unlock()\n}", "func NewBlock(filename string, blknum uint64) *Block {\n\treturn &Block{\n\t\tfilename: filename,\n\t\tblknum: blknum,\n\t}\n}", "func NewBlockHeader(prev BlockHeader, uxHash cipher.SHA256, currentTime, fee uint64, body BlockBody) BlockHeader {\n\tif currentTime <= prev.Time {\n\t\tlogger.Panic(\"Time can only move forward\")\n\t}\n\tprevHash := prev.Hash()\n\treturn BlockHeader{\n\t\tBodyHash: body.Hash(),\n\t\tVersion: prev.Version,\n\t\tPrevHash: prevHash,\n\t\tTime: currentTime,\n\t\tBkSeq: prev.BkSeq + 1,\n\t\tFee: fee,\n\t\tUxHash: uxHash,\n\t}\n}", "func (build *signedBlockBuilder) Create() validated.SignedBlockBuilder {\n\tbuild.id = nil\n\tbuild.met = nil\n\tbuild.blk = nil\n\tbuild.sig = nil\n\tbuild.crOn = nil\n\treturn build\n}", "func (g *testGenerator) createPremineBlock(blockName string, additionalAmount dcrutil.Amount) *wire.MsgBlock {\n\tcoinbaseTx := wire.NewMsgTx()\n\tcoinbaseTx.AddTxIn(&wire.TxIn{\n\t\tPreviousOutPoint: *wire.NewOutPoint(&chainhash.Hash{},\n\t\t\twire.MaxPrevOutIndex, wire.TxTreeRegular),\n\t\tSequence: wire.MaxTxInSequenceNum,\n\t\tValueIn: 0, // Updated below.\n\t\tBlockHeight: wire.NullBlockHeight,\n\t\tBlockIndex: wire.NullBlockIndex,\n\t\tSignatureScript: coinbaseSigScript,\n\t})\n\n\t// Add each required output and tally the total payouts for the coinbase\n\t// in order to set the input value appropriately.\n\tvar totalSubsidy dcrutil.Amount\n\tfor _, payout := range g.params.BlockOneLedger {\n\t\tpayoutAddr, err := dcrutil.DecodeAddress(payout.Address, g.params)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tpkScript, err := txscript.PayToAddrScript(payoutAddr)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tcoinbaseTx.AddTxOut(&wire.TxOut{\n\t\t\tValue: payout.Amount + int64(additionalAmount),\n\t\t\tVersion: 0,\n\t\t\tPkScript: pkScript,\n\t\t})\n\n\t\ttotalSubsidy += dcrutil.Amount(payout.Amount)\n\t}\n\tcoinbaseTx.TxIn[0].ValueIn = int64(totalSubsidy)\n\n\t// Generate the block with the specially created regular transactions.\n\treturn g.nextBlock(blockName, nil, nil, func(b *wire.MsgBlock) {\n\t\tb.Transactions = []*wire.MsgTx{coinbaseTx}\n\t})\n}", "func createBlockAlloca(f *ir.Function, elemType types.Type, name string) *ir.InstAlloca {\n\t// Create a new allocation in the root of the function\n\talloca := f.Blocks[0].NewAlloca(elemType)\n\t// Set the name of the allocation (the variable name)\n\t// alloca.SetName(name)\n\treturn alloca\n}", "func TestBlock(t *testing.T) {\n\tl := &Leading{\n\t\tMagic: 0x7425,\n\t\tLenBlock: 0,\n\t}\n\n\tfmt.Println(l)\n\n\th := &chunk.Header{}\n\tfmt.Println(hex.Dump(h.Marshal()))\n\n\tcaller := &chunk.Quater{\n\t\tMain: \"1LVfRcj31E9mGujxUD3nTJjsUPtcczqJnX\",\n\t\tSub: \"send\",\n\t}\n\tcallee := &chunk.Quater{\n\t\tMain: \"1LVfRcj31E9mGujxUD3nTJjsUPtcczqJnX\",\n\t\tSub: \"recv\",\n\t}\n\n\tr := chunk.NewRouting(caller, callee)\n\tfmt.Println(hex.Dump(r.Marshal()))\n\n\tc := &chunk.Content{\n\t\tSha: chunk.GetHash('0'),\n\t\tMime: 0xff,\n\t\tCipher: []byte{},\n\t\tBody: []byte(\"Hello bitmsg\"),\n\t}\n\t//fmt.Println(c)\n\tc.Marshal()\n\tb := NewBlock(*h, *r)\n\tb.AddContent(*c)\n\tfmt.Println(hex.Dump(b.Header.ShaMerkle[:]))\n\tfmt.Println(hex.Dump(b.Marshal()))\n}" ]
[ "0.75757486", "0.75706005", "0.72429085", "0.7192294", "0.70964277", "0.7095982", "0.70929307", "0.70588", "0.70484954", "0.7039668", "0.6990194", "0.6981644", "0.69665647", "0.69518673", "0.68588614", "0.6853967", "0.6762825", "0.67510724", "0.6685897", "0.66617703", "0.66590303", "0.6657446", "0.66540134", "0.66441935", "0.66440636", "0.664093", "0.6634573", "0.6629453", "0.6588098", "0.6584097", "0.6584096", "0.65737045", "0.6565733", "0.65602136", "0.6541639", "0.6539558", "0.6532813", "0.6532802", "0.6529724", "0.65229833", "0.6513837", "0.6496594", "0.6493196", "0.6488342", "0.6485481", "0.64843416", "0.64690334", "0.64497215", "0.64484847", "0.6444864", "0.6438861", "0.64358336", "0.6426922", "0.64164585", "0.6407304", "0.6405042", "0.6379444", "0.6374182", "0.63642323", "0.6362294", "0.6362294", "0.6356847", "0.6356811", "0.63506436", "0.6343055", "0.6333253", "0.6291253", "0.62892646", "0.6270652", "0.62679315", "0.6253749", "0.62518567", "0.6241847", "0.6233454", "0.6221187", "0.62094617", "0.6197002", "0.61883986", "0.61855584", "0.618314", "0.6182207", "0.6169278", "0.6162436", "0.6148304", "0.61379606", "0.61354554", "0.6112555", "0.61081964", "0.60975164", "0.6095799", "0.6091061", "0.607796", "0.6064735", "0.605816", "0.60535544", "0.60497653", "0.6044937", "0.6020481", "0.5998331", "0.59902066" ]
0.6270857
68
HashTransactions makes hash of all transaction ids
func (block *Block) HashTransactions() []byte { var hashes [][]byte for _, transaction := range block.Transactions { hashes = append(hashes, transaction.Serialize()) } if len(hashes) == 0 { return []byte{} } mtree := NewMerkleTree(hashes) return mtree.Root.Data }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (block *Block) HashTransactions() []byte {\n\tvar txHashes [][]byte\n\tvar txHash [32]byte\n\n\tfor _, tx := range block.Transactions {\n\t\ttxHashes = append(txHashes, tx.ID)\n\t}\n\n\ttxHash = sha256.Sum256(bytes.Join(txHashes, []byte{}))\n\n\treturn txHash[:]\n}", "func (b *Block) HashTransactions() []byte {\n\tvar txHashes [][]byte\n\tvar txHash [32]byte\n\n\tfor _, tx := range b.Transactions {\n\t\ttxHashes = append(txHashes, tx.ID)\n\t}\n\n\ttxHash = sha256.Sum256(bytes.Join(txHashes, []byte{}))\n\n\treturn txHash[:]\n}", "func (block *Block) HashTransactions() []byte{\n\tvar txHashes [][]byte\n\tvar txHash [32]byte\n\tfor _,tx := range block.Transactions{\n\t\ttxHashes = append(txHashes,tx.Hash())\n\t}\n\ttxHash = sha256.Sum256(bytes.Join(txHashes,[]byte{}))\n\treturn txHash[:]\n}", "func (block *Block) HashTransactions() []byte {\n\tvar transactions [][]byte\n\n\tfor _, tx := range block.Transactions {\n\t\ttransactions = append(transactions, tx.serialize())\n\t}\n\n\tmTree := CreateTree(transactions)\n\n\treturn mTree.Root.Data\n}", "func (b *Block) HashTransactions() []byte {\n\tvar (\n\t\thashes [][]byte\n\t\thash [32]byte\n\t)\n\n\tfor _, tx := range b.Transactions {\n\t\thashes = append(hashes, tx.Hash())\n\t}\n\thash = sha256.Sum256(bytes.Join(hashes, []byte{}))\n\treturn hash[:]\n}", "func (b *Block) HashTransactions() []byte {\n\tvar txHashes [][]byte\n\n\tfor _, tx := range b.Transactions {\n\t\ttxHashes = append(txHashes, tx.Serialize())\n\t}\n\n\ttree := NewMerkleTree(txHashes)\n\n\treturn tree.RootNode.Data\n}", "func (tx Transaction) HashTx() [32]byte {\n\n\ttxCopy := tx\n\ttxCopy.Hash = [32]byte{}\n\n\thash := sha256.Sum256(txCopy.Serialize())\n\n\treturn hash\n}", "func (tx *Transaction) Hash() []byte {\n\tvar hash [32]byte\n\n\ttxCopy := *tx\n\ttxCopy.ID = []byte{}\n\n\thash = sha256.Sum256(txCopy.Serialize())\n\n\treturn hash[:]\n}", "func (tx *Transaction) Hash() []byte {\n\tvar hash [32]byte\n\n\ttxCopy := *tx\n\ttxCopy.ID = []byte{}\n\n\thash = sha256.Sum256(txCopy.Serialize())\n\n\treturn hash[:]\n}", "func (tx *Transaction) Hash() []byte {\n\tvar hash [32]byte\n\n\ttxCopy := *tx\n\ttxCopy.ID = []byte{}\n\n\thash = sha256.Sum256(txCopy.Serialize())\n\n\treturn hash[:]\n}", "func (tx *Tx) Hash() []byte {\n\tvar hash [32]byte\n\n\ttxCopy := *tx\n\ttxCopy.ID = []byte{}\n\n\thash = sha256.Sum256(txCopy.Serialize())\n\n\treturn hash[:]\n}", "func TransactionsToHashes(elems []*types.Transaction) []common.Hash {\n\tout := make([]common.Hash, len(elems))\n\tfor i, el := range elems {\n\t\tout[i] = el.Hash()\n\t}\n\treturn out\n}", "func (tx *Tx) generateHash() [32]byte {\n\ttxInSlices := make([][]byte, 0)\n\tfor _, txIn := range tx.Inputs {\n\t\ttxInSlices = append(txInSlices, txIn.forBlkHash())\n\t}\n\ttxInSlice := helpers.ConcatByteArray(txInSlices)\n\n\ttxOutSlices := make([][]byte, 0)\n\tfor _, txOut := range tx.Outputs {\n\t\ttxOutSlices = append(txOutSlices, txOut.forBlkHash())\n\t}\n\ttxOutSlice := helpers.ConcatByteArray(txOutSlices)\n\n\ttxSlices := [][]byte{\n\t\thelpers.UInt32ToBytes(tx.Version), // 4 bytes\n\t\thelpers.UInt32ToBytes(tx.LockTime), // 4 bytes\n\t\ttxInSlice,\n\t\ttxOutSlice,\n\t}\n\n\tmsg := helpers.ConcatByteArray(txSlices)\n\treturn DHASH(msg)\n}", "func processTransactions(selectedTransactions []Transaction) []byte {\n\tharsher := sha512.New()\n\tfor _, v := range selectedTransactions {\n\t\ttransformedTransaction := resolveTransaction(v)\n\t\tharsher.Write(transformedTransaction)\n\t}\n\treturn harsher.Sum([]byte{})\n}", "func (t *Transaction) Hash() string {\n\treturn utils.EncodeToBase64(t.id)\n}", "func (tx *Transaction) Hash() ([]byte, error) {\n\tvar hash [32]byte\n\n\tserializedTx, err := common.Serialize(&tx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\thash = sha256.Sum256(serializedTx)\n\n\treturn hash[:], nil\n}", "func TestDeriveSha_Transactions(t *testing.T) {\n\tlength := 10\n\ttxs := make(Transactions, 0, length)\n\tfor i := 0; i != length; i++ {\n\t\ttxs = append(txs, simpleNewTransactionByNonce(uint64(i)))\n\t}\n\tres := DeriveSha(txs)\n\texpected := common.FromHex(\"28dd2d133be3d1611630d16f28a96c5473b82d92bdbbd8e8b9339e3a4e852931\")\n\tif !bytes.Equal(expected, res.Bytes()) {\n\t\tt.Errorf(\"DeriveSha for Transactions got an unexpected root hash.\\nGot %x\\nWant %x\", res, expected)\n\t}\n}", "func calculateHash(index int, previousHash string, timestamp int64, data transaction.Transaction) string {\n\tvar foo = strconv.Itoa(index) + string(previousHash) + strconv.Itoa(int(timestamp)) + hex.EncodeToString(data.Id)\n\tinput :=strings.NewReader(foo)\n\tvar newHash = sha256.New()\n\tif _, err := io.Copy(newHash, input); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn hex.EncodeToString(newHash.Sum(nil))\n}", "func (self *ResTransaction)GetHash()string{\n hb := new(utils.HashBuilder)\n hb.Add(self.Creator)\n hb.Add(self.Timestamp.Format(\"2006-01-02 15:04:05\"))\n hb.Add(self.JobBlock)\n hb.Add(self.JobTrans)\n hb.Add(self.Output)\n for i:=0;i<len(self.Inputs);i++{\n hb.Add(self.Inputs[i])\n }\n hb.Add(self.HashSol)\n hb.Add(self.Evaluation)\n hb.Add(self.IsMin)\n return fmt.Sprintf(\"%x\",hb.GetHash())\n}", "func (mp *TxPool) TxHashes() []*chainhash.Hash {\n\tmp.mtx.RLock()\n\thashes := make([]*chainhash.Hash, len(mp.pool))\n\ti := 0\n\tfor hash := range mp.pool {\n\t\thashCopy := hash\n\t\thashes[i] = &hashCopy\n\t\ti++\n\t}\n\tmp.mtx.RUnlock()\n\n\treturn hashes\n}", "func (txn *Transaction) GenerateHash() utils.Hash {\n\t// Create a copy of the transaction\n\ttxncopy := *txn\n\t// Remove the ID of the transaction copy\n\ttxncopy.ID = utils.Hash{}\n\n\t// Serialize the transaction into a gob and hash it\n\thash := utils.Hash256(txncopy.Serialize())\n\t// Return the hash slice\n\treturn hash[:]\n}", "func (obj *transaction) Hash() hash.Hash {\n\tif obj.IsGraphbase() {\n\t\treturn obj.Graphbase().Hash()\n\t}\n\n\tif obj.IsDatabase() {\n\t\treturn obj.Database().Hash()\n\t}\n\n\tif obj.IsTable() {\n\t\treturn obj.Table().Hash()\n\t}\n\n\treturn obj.Set().Hash()\n}", "func TestTxHashAndID(t *testing.T) {\n\ttxID1Str := \"edca872f27279674c7a52192b32fd68b8b8be714bfea52d98b2c3c86c30e85c6\"\n\twantTxID1, err := daghash.NewTxIDFromStr(txID1Str)\n\tif err != nil {\n\t\tt.Errorf(\"NewTxIDFromStr: %v\", err)\n\t\treturn\n\t}\n\n\t// A coinbase transaction\n\ttxIn := &TxIn{\n\t\tPreviousOutpoint: Outpoint{\n\t\t\tTxID: daghash.TxID{},\n\t\t\tIndex: math.MaxUint32,\n\t\t},\n\t\tSignatureScript: []byte{0x04, 0x31, 0xdc, 0x00, 0x1b, 0x01, 0x62},\n\t\tSequence: math.MaxUint64,\n\t}\n\ttxOut := &TxOut{\n\t\tValue: 5000000000,\n\t\tScriptPubKey: []byte{\n\t\t\t0x41, // OP_DATA_65\n\t\t\t0x04, 0xd6, 0x4b, 0xdf, 0xd0, 0x9e, 0xb1, 0xc5,\n\t\t\t0xfe, 0x29, 0x5a, 0xbd, 0xeb, 0x1d, 0xca, 0x42,\n\t\t\t0x81, 0xbe, 0x98, 0x8e, 0x2d, 0xa0, 0xb6, 0xc1,\n\t\t\t0xc6, 0xa5, 0x9d, 0xc2, 0x26, 0xc2, 0x86, 0x24,\n\t\t\t0xe1, 0x81, 0x75, 0xe8, 0x51, 0xc9, 0x6b, 0x97,\n\t\t\t0x3d, 0x81, 0xb0, 0x1c, 0xc3, 0x1f, 0x04, 0x78,\n\t\t\t0x34, 0xbc, 0x06, 0xd6, 0xd6, 0xed, 0xf6, 0x20,\n\t\t\t0xd1, 0x84, 0x24, 0x1a, 0x6a, 0xed, 0x8b, 0x63,\n\t\t\t0xa6, // 65-byte signature\n\t\t\t0xac, // OP_CHECKSIG\n\t\t},\n\t}\n\ttx1 := NewSubnetworkMsgTx(1, []*TxIn{txIn}, []*TxOut{txOut}, subnetworkid.SubnetworkIDCoinbase, 0, nil)\n\n\t// Ensure the hash produced is expected.\n\ttx1Hash := tx1.TxHash()\n\tif !tx1Hash.IsEqual((*daghash.Hash)(wantTxID1)) {\n\t\tt.Errorf(\"TxHash: wrong hash - got %v, want %v\",\n\t\t\tspew.Sprint(tx1Hash), spew.Sprint(wantTxID1))\n\t}\n\n\t// Ensure the TxID for coinbase transaction is the same as TxHash.\n\ttx1ID := tx1.TxID()\n\tif !tx1ID.IsEqual(wantTxID1) {\n\t\tt.Errorf(\"TxID: wrong ID - got %v, want %v\",\n\t\t\tspew.Sprint(tx1ID), spew.Sprint(wantTxID1))\n\t}\n\n\thash2Str := \"b11924b7eeffea821522222576c53dc5b8ddd97602f81e5e124d2626646d74ca\"\n\twantHash2, err := daghash.NewHashFromStr(hash2Str)\n\tif err != nil {\n\t\tt.Errorf(\"NewTxIDFromStr: %v\", err)\n\t\treturn\n\t}\n\n\tid2Str := \"750499ae9e6d44961ef8bad8af27a44dd4bcbea166b71baf181e8d3997e1ff72\"\n\twantID2, err := daghash.NewTxIDFromStr(id2Str)\n\tif err != nil {\n\t\tt.Errorf(\"NewTxIDFromStr: %v\", err)\n\t\treturn\n\t}\n\tpayload := []byte{1, 2, 3}\n\ttxIns := []*TxIn{{\n\t\tPreviousOutpoint: Outpoint{\n\t\t\tIndex: 0,\n\t\t\tTxID: daghash.TxID{1, 2, 3},\n\t\t},\n\t\tSignatureScript: []byte{\n\t\t\t0x49, 0x30, 0x46, 0x02, 0x21, 0x00, 0xDA, 0x0D, 0xC6, 0xAE, 0xCE, 0xFE, 0x1E, 0x06, 0xEF, 0xDF,\n\t\t\t0x05, 0x77, 0x37, 0x57, 0xDE, 0xB1, 0x68, 0x82, 0x09, 0x30, 0xE3, 0xB0, 0xD0, 0x3F, 0x46, 0xF5,\n\t\t\t0xFC, 0xF1, 0x50, 0xBF, 0x99, 0x0C, 0x02, 0x21, 0x00, 0xD2, 0x5B, 0x5C, 0x87, 0x04, 0x00, 0x76,\n\t\t\t0xE4, 0xF2, 0x53, 0xF8, 0x26, 0x2E, 0x76, 0x3E, 0x2D, 0xD5, 0x1E, 0x7F, 0xF0, 0xBE, 0x15, 0x77,\n\t\t\t0x27, 0xC4, 0xBC, 0x42, 0x80, 0x7F, 0x17, 0xBD, 0x39, 0x01, 0x41, 0x04, 0xE6, 0xC2, 0x6E, 0xF6,\n\t\t\t0x7D, 0xC6, 0x10, 0xD2, 0xCD, 0x19, 0x24, 0x84, 0x78, 0x9A, 0x6C, 0xF9, 0xAE, 0xA9, 0x93, 0x0B,\n\t\t\t0x94, 0x4B, 0x7E, 0x2D, 0xB5, 0x34, 0x2B, 0x9D, 0x9E, 0x5B, 0x9F, 0xF7, 0x9A, 0xFF, 0x9A, 0x2E,\n\t\t\t0xE1, 0x97, 0x8D, 0xD7, 0xFD, 0x01, 0xDF, 0xC5, 0x22, 0xEE, 0x02, 0x28, 0x3D, 0x3B, 0x06, 0xA9,\n\t\t\t0xD0, 0x3A, 0xCF, 0x80, 0x96, 0x96, 0x8D, 0x7D, 0xBB, 0x0F, 0x91, 0x78,\n\t\t},\n\t\tSequence: math.MaxUint64,\n\t}}\n\ttxOuts := []*TxOut{\n\t\t{\n\t\t\tValue: 244623243,\n\t\t\tScriptPubKey: []byte{\n\t\t\t\t0x76, 0xA9, 0x14, 0xBA, 0xDE, 0xEC, 0xFD, 0xEF, 0x05, 0x07, 0x24, 0x7F, 0xC8, 0xF7, 0x42, 0x41,\n\t\t\t\t0xD7, 0x3B, 0xC0, 0x39, 0x97, 0x2D, 0x7B, 0x88, 0xAC,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tValue: 44602432,\n\t\t\tScriptPubKey: []byte{\n\t\t\t\t0x76, 0xA9, 0x14, 0xC1, 0x09, 0x32, 0x48, 0x3F, 0xEC, 0x93, 0xED, 0x51, 0xF5, 0xFE, 0x95, 0xE7,\n\t\t\t\t0x25, 0x59, 0xF2, 0xCC, 0x70, 0x43, 0xF9, 0x88, 0xAC,\n\t\t\t},\n\t\t},\n\t}\n\ttx2 := NewSubnetworkMsgTx(1, txIns, txOuts, &subnetworkid.SubnetworkID{1, 2, 3}, 0, payload)\n\n\t// Ensure the hash produced is expected.\n\ttx2Hash := tx2.TxHash()\n\tif !tx2Hash.IsEqual(wantHash2) {\n\t\tt.Errorf(\"TxHash: wrong hash - got %v, want %v\",\n\t\t\tspew.Sprint(tx2Hash), spew.Sprint(wantHash2))\n\t}\n\n\t// Ensure the TxID for coinbase transaction is the same as TxHash.\n\ttx2ID := tx2.TxID()\n\tif !tx2ID.IsEqual(wantID2) {\n\t\tt.Errorf(\"TxID: wrong ID - got %v, want %v\",\n\t\t\tspew.Sprint(tx2ID), spew.Sprint(wantID2))\n\t}\n\n\tif tx2ID.IsEqual((*daghash.TxID)(tx2Hash)) {\n\t\tt.Errorf(\"tx2ID and tx2Hash shouldn't be the same for non-coinbase transaction with signature and/or payload\")\n\t}\n\n\ttx2.TxIn[0].SignatureScript = []byte{}\n\tnewTx2Hash := tx2.TxHash()\n\tif !tx2ID.IsEqual((*daghash.TxID)(newTx2Hash)) {\n\t\tt.Errorf(\"tx2ID and newTx2Hash should be the same for transaction with an empty signature\")\n\t}\n}", "func (t Transaction) SigHash(i int) crypto.Hash {\n\tcf := t.Signatures[i].CoveredFields\n\tvar signedData []byte\n\tif cf.WholeTransaction {\n\t\tsignedData = encoding.MarshalAll(\n\t\t\tt.SiacoinInputs,\n\t\t\tt.SiacoinOutputs,\n\t\t\tt.FileContracts,\n\t\t\tt.FileContractTerminations,\n\t\t\tt.StorageProofs,\n\t\t\tt.SiafundInputs,\n\t\t\tt.SiafundOutputs,\n\t\t\tt.MinerFees,\n\t\t\tt.ArbitraryData,\n\t\t\tt.Signatures[i].ParentID,\n\t\t\tt.Signatures[i].PublicKeyIndex,\n\t\t\tt.Signatures[i].Timelock,\n\t\t)\n\t} else {\n\t\tfor _, input := range cf.SiacoinInputs {\n\t\t\tsignedData = append(signedData, encoding.Marshal(t.SiacoinInputs[input])...)\n\t\t}\n\t\tfor _, output := range cf.SiacoinOutputs {\n\t\t\tsignedData = append(signedData, encoding.Marshal(t.SiacoinOutputs[output])...)\n\t\t}\n\t\tfor _, contract := range cf.FileContracts {\n\t\t\tsignedData = append(signedData, encoding.Marshal(t.FileContracts[contract])...)\n\t\t}\n\t\tfor _, termination := range cf.FileContractTerminations {\n\t\t\tsignedData = append(signedData, encoding.Marshal(t.FileContractTerminations[termination])...)\n\t\t}\n\t\tfor _, storageProof := range cf.StorageProofs {\n\t\t\tsignedData = append(signedData, encoding.Marshal(t.StorageProofs[storageProof])...)\n\t\t}\n\t\tfor _, siafundInput := range cf.SiafundInputs {\n\t\t\tsignedData = append(signedData, encoding.Marshal(t.SiafundInputs[siafundInput])...)\n\t\t}\n\t\tfor _, siafundOutput := range cf.SiafundOutputs {\n\t\t\tsignedData = append(signedData, encoding.Marshal(t.SiafundOutputs[siafundOutput])...)\n\t\t}\n\t\tfor _, minerFee := range cf.MinerFees {\n\t\t\tsignedData = append(signedData, encoding.Marshal(t.MinerFees[minerFee])...)\n\t\t}\n\t\tfor _, arbData := range cf.ArbitraryData {\n\t\t\tsignedData = append(signedData, encoding.Marshal(t.ArbitraryData[arbData])...)\n\t\t}\n\t}\n\n\tfor _, sig := range cf.Signatures {\n\t\tsignedData = append(signedData, encoding.Marshal(t.Signatures[sig])...)\n\t}\n\n\treturn crypto.HashBytes(signedData)\n}", "func calculateHash (block Block) string{\n h := sha256.New()\n unique := block.Data + block.PrevHash + block.TimeStamp + strconv.Itoa(block.Nonce)\n h.Write([]byte(unique))\n \n return hex.EncodeToString(h.Sum(nil))\n}", "func hash(elements ...[32]byte) [32]byte {\n\tvar hash []byte\n\tfor i := range elements {\n\t\thash = append(hash, elements[i][:]...)\n\t}\n\treturn sha256.Sum256(hash)\n}", "func (cs *ConsensusSet) consensusSetHash() crypto.Hash {\n\t// Check is too slow to be done on a full node.\n\tif build.Release == \"standard\" {\n\t\treturn crypto.Hash{}\n\t}\n\n\t// Items of interest:\n\t// 1.\tgenesis block\n\t// 3.\tcurrent height\n\t// 4.\tcurrent target\n\t// 5.\tcurrent depth\n\t// 6.\tcurrent path + diffs\n\t// (7)\tearliest allowed timestamp of next block\n\t// 8.\tunspent siacoin outputs, sorted by id.\n\t// 9.\topen file contracts, sorted by id.\n\t// 10.\tunspent siafund outputs, sorted by id.\n\t// 11.\tdelayed siacoin outputs, sorted by height, then sorted by id.\n\t// 12.\tsiafund pool\n\n\t// Create a slice of hashes representing all items of interest.\n\ttree := crypto.NewTree()\n\ttree.PushObject(cs.blockRoot.Block)\n\ttree.PushObject(cs.height())\n\ttree.PushObject(cs.currentProcessedBlock().ChildTarget)\n\ttree.PushObject(cs.currentProcessedBlock().Depth)\n\t// tree.PushObject(cs.earliestChildTimestamp(cs.currentProcessedBlock()))\n\n\t// Add all the blocks in the current path TODO: along with their diffs.\n\tfor i := 0; i < int(cs.db.pathHeight()); i++ {\n\t\ttree.PushObject(cs.db.getPath(types.BlockHeight(i)))\n\t}\n\n\t// Add all of the siacoin outputs, sorted by id.\n\tvar openSiacoinOutputs crypto.HashSlice\n\tcs.db.forEachSiacoinOutputs(func(scoid types.SiacoinOutputID, sco types.SiacoinOutput) {\n\t\topenSiacoinOutputs = append(openSiacoinOutputs, crypto.Hash(scoid))\n\t})\n\tsort.Sort(openSiacoinOutputs)\n\tfor _, id := range openSiacoinOutputs {\n\t\tsco := cs.db.getSiacoinOutputs(types.SiacoinOutputID(id))\n\t\ttree.PushObject(id)\n\t\ttree.PushObject(sco)\n\t}\n\n\t// Add all of the file contracts, sorted by id.\n\tvar openFileContracts crypto.HashSlice\n\tcs.db.forEachFileContracts(func(fcid types.FileContractID, fc types.FileContract) {\n\t\topenFileContracts = append(openFileContracts, crypto.Hash(fcid))\n\t})\n\tsort.Sort(openFileContracts)\n\tfor _, id := range openFileContracts {\n\t\t// Sanity Check - file contract should exist.\n\t\tfc := cs.db.getFileContracts(types.FileContractID(id))\n\t\ttree.PushObject(id)\n\t\ttree.PushObject(fc)\n\t}\n\n\t// Add all of the siafund outputs, sorted by id.\n\tvar openSiafundOutputs crypto.HashSlice\n\tcs.db.forEachSiafundOutputs(func(sfoid types.SiafundOutputID, sfo types.SiafundOutput) {\n\t\topenSiafundOutputs = append(openSiafundOutputs, crypto.Hash(sfoid))\n\t})\n\tsort.Sort(openSiafundOutputs)\n\tfor _, id := range openSiafundOutputs {\n\t\tsco := cs.db.getSiafundOutputs(types.SiafundOutputID(id))\n\t\ttree.PushObject(id)\n\t\ttree.PushObject(sco)\n\t}\n\n\t// Get the set of delayed siacoin outputs, sorted by maturity height then\n\t// sorted by id and add them.\n\tfor i := cs.height() + 1; i <= cs.height()+types.MaturityDelay; i++ {\n\t\tvar delayedSiacoinOutputs crypto.HashSlice\n\t\tif cs.db.inDelayedSiacoinOutputs(i) {\n\t\t\tcs.db.forEachDelayedSiacoinOutputsHeight(i, func(id types.SiacoinOutputID, output types.SiacoinOutput) {\n\t\t\t\tdelayedSiacoinOutputs = append(delayedSiacoinOutputs, crypto.Hash(id))\n\t\t\t})\n\t\t}\n\t\tsort.Sort(delayedSiacoinOutputs)\n\t\tfor _, delayedSiacoinOutputID := range delayedSiacoinOutputs {\n\t\t\tdelayedSiacoinOutput := cs.db.getDelayedSiacoinOutputs(i, types.SiacoinOutputID(delayedSiacoinOutputID))\n\t\t\ttree.PushObject(delayedSiacoinOutput)\n\t\t\ttree.PushObject(delayedSiacoinOutputID)\n\t\t}\n\t}\n\n\t// Add the siafund pool\n\tvar siafundPool types.Currency\n\terr := cs.db.Update(func(tx *bolt.Tx) error {\n\t\tsiafundPool = getSiafundPool(tx)\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttree.PushObject(siafundPool)\n\n\treturn tree.Root()\n}", "func (b *BlockPublish) Hash() (out [32]byte) {\n\th := sha256.New()\n\th.Write(b.PrevHash[:])\n\tth := b.Transaction.Hash()\n\th.Write(th[:])\n\tcopy(out[:], h.Sum(nil))\n\treturn\n}", "func (t *TxPublish) Hash() (out [32]byte) {\n\th := sha256.New()\n\tbinary.Write(h, binary.LittleEndian,\n\t\tuint32(len(t.Name)))\n\th.Write([]byte(t.Name))\n\th.Write(t.MetafileHash)\n\tcopy(out[:], h.Sum(nil))\n\treturn\n}", "func (msg *Block) TxHashes() ([]chainhash.Hash, error) {\n\thashList := make([]chainhash.Hash, 0, len(msg.Transactions))\n\tfor _, tx := range msg.Transactions {\n\t\thashList = append(hashList, tx.TxHash())\n\t}\n\treturn hashList, nil\n}", "func Hashbin(tox string) []byte {\n h:= sha256.New()\n h.Write([]byte(tox))\n bs := h.Sum([]byte{})\n return bs \n}", "func (tx *Transaction) Hash() common.Uint256 {\n\tif tx.hash == nil {\n\t\tw := new(bytes.Buffer)\n\t\tbinary.Write(w, binary.LittleEndian, tx.Version)\n\t\tbinary.Write(w, binary.LittleEndian, byte(tx.TxType))\n\t\tbinary.Write(w, binary.LittleEndian, tx.Nonce)\n\t\tbinary.Write(w, binary.LittleEndian, tx.GasPrice)\n\t\tbinary.Write(w, binary.LittleEndian, tx.GasLimit)\n\t\tif err := tx.Payer.Serialize(w); err != nil {\n\t\t\treturn common.UINT256_EMPTY\n\t\t}\n\t\tif err := tx.Payload.Serialize(w); err != nil {\n\t\t\treturn common.UINT256_EMPTY\n\t\t}\n\t\tvar attrvu = &serialize.VarUint{\n\t\t\tUintType: serialize.GetUintTypeByValue(uint64(len(tx.Attributes))),\n\t\t\tValue: uint64(len(tx.Attributes)),\n\t\t}\n\t\tif err := attrvu.Serialize(w); err != nil {\n\t\t\treturn common.UINT256_EMPTY\n\t\t}\n\t\tfor _, attr := range tx.Attributes {\n\t\t\tif err := attr.Serialize(w); err != nil {\n\t\t\t\treturn common.UINT256_EMPTY\n\t\t\t}\n\t\t}\n\n\t\ttemp := sha256.Sum256(w.Bytes())\n\t\tf := common.Uint256(sha256.Sum256(temp[:]))\n\t\ttx.hash = &f\n\t}\n\treturn *tx.hash\n}", "func findTransactionHashes(c echo.Context) error {\n\tvar request Request\n\n\tif err := c.Bind(&request); err != nil {\n\t\tlog.Info(err.Error())\n\t\treturn c.JSON(http.StatusBadRequest, Response{Error: err.Error()})\n\t}\n\tlog.Debug(\"Received:\", request.Addresses)\n\tresult := make([][]trinary.Trytes, len(request.Addresses))\n\n\tfor i, address := range request.Addresses {\n\t\ttxs, err := tangle.ReadTransactionHashesForAddressFromDatabase(address)\n\t\tif err != nil {\n\t\t\treturn c.JSON(http.StatusInternalServerError, Response{Error: err.Error()})\n\t\t}\n\t\tresult[i] = append(result[i], txs...)\n\t}\n\n\treturn c.JSON(http.StatusOK, Response{Transactions: result})\n}", "func nodeHash(no *NodeSaves) []byte {\n\n\th := md5.New()\n\n\tfor _, n := range no.Save {\n\t\th.Write([]byte(n.Hash[:]))\n\t}\n\n\treturn h.Sum(nil)\n}", "func calculateHash(block Block) string {\n\n\t// Time and vehicle identifier (v5c) are the key block items to generate the hash\n\trecord := string(string(block.Index) + block.Timestamp + block.Event.PerformedOnVehicle.V5c + block.PrevHash)\n\th := sha256.New()\n\th.Write([]byte(record))\n\thashed := h.Sum(nil)\n\treturn hex.EncodeToString(hashed)\n}", "func calculateHash(block Block) string {\n\trecord := strconv.Itoa(block.Index) + block.Timestamp + strconv.Itoa(block.Key) + block.PrevHash\n\th := sha256.New()\n\th.Write([]byte(record))\n\thashed := h.Sum(nil)\n\treturn hex.EncodeToString(hashed)\n}", "func (t Transaction) SignatureHash(extraObjects ...interface{}) (crypto.Hash, error) {\n\tcontroller, exists := _RegisteredTransactionVersions[t.Version]\n\tif !exists {\n\t\treturn crypto.Hash{}, ErrUnknownTransactionType\n\t}\n\tif hasher, ok := controller.(TransactionSignatureHasher); ok {\n\t\t// if extension implements TransactionSignatureHasher,\n\t\t// use it here to sign the input with it\n\t\treturn hasher.SignatureHash(t, extraObjects...)\n\t}\n\n\th := crypto.NewHash()\n\tenc := siabin.NewEncoder(h)\n\n\tenc.Encode(t.Version)\n\tif len(extraObjects) > 0 {\n\t\tenc.EncodeAll(extraObjects...)\n\t}\n\tenc.Encode(len(t.CoinInputs))\n\tfor _, ci := range t.CoinInputs {\n\t\tenc.Encode(ci.ParentID)\n\t}\n\tenc.Encode(t.CoinOutputs)\n\tenc.Encode(len(t.BlockStakeInputs))\n\tfor _, bsi := range t.BlockStakeInputs {\n\t\tenc.Encode(bsi.ParentID)\n\t}\n\tenc.EncodeAll(\n\t\tt.BlockStakeOutputs,\n\t\tt.MinerFees,\n\t\tt.ArbitraryData,\n\t)\n\n\tvar hash crypto.Hash\n\th.Sum(hash[:0])\n\treturn hash, nil\n}", "func (id *Public) hash() []byte {\n\treturn hashHelper(id.SigningKey.SerializeUncompressed(),\n\t\tid.EncryptionKey.SerializeUncompressed())\n}", "func (msg *MsgTx) TransactionHash() common.Hash {\n\treturn msg.TxHash()\n}", "func (t *Transaction) Hash() []byte {\n\tbuf := make([]byte, 8)\n\tbinary.LittleEndian.PutUint64(buf, t.Nonce)\n\treturn buf\n}", "func (trans *Transaction) HashSHA256() [32]byte {\n\tmessage, err := json.Marshal(trans)\n\tif err != nil {\n\t\tlog.Fatalf(\"Fail to marshal transaction with error: %s\", err)\n\t}\n\treturn sha256.Sum256([]byte(message))\n}", "func hash(values ...[]byte) ([]byte, error) {\n\th := swarm.NewHasher()\n\tfor _, v := range values {\n\t\t_, err := h.Write(v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn h.Sum(nil), nil\n}", "func (t *Transaction) TxHash() chainhash.Hash {\n\t// Encode the transaction and calculate double sha256 on the result.\n\t// Ignore the error returns since the only way the encode could fail\n\t// is being out of memory or due to nil pointers, both of which would\n\t// cause a run-time panic.\n\tb, _ := t.MarshalBinary()\n\treturn chainhash.DoubleHashH(b)\n}", "func (t *TxPublish) Hash() (out [32]byte) {\n\th := sha256.New()\n\tbinary.Write(h, binary.LittleEndian,\n\t\tuint32(len(t.File.Name)))\n\th.Write([]byte(t.File.Name))\n\th.Write(t.File.MetafileHash)\n\tcopy(out[:], h.Sum(nil))\n\treturn\n}", "func Hash(t *Token) (hash []byte) {\n var sum []byte\n\n // Compute the SHA1 sum of the Token\n {\n shasum := sha1.Sum([]byte(salt+string(*t)))\n copy(sum[:], shasum[:20])\n }\n\n // Encode the sum to hexadecimal\n hex.Encode(sum, sum)\n\n return\n}", "func (s *State) stateHash() hash.Hash {\n\t// Items of interest:\n\t// 1. CurrentBlockID\n\t// 2. Current Height\n\t// 3. Current Target\n\t// 4. Current Depth\n\t// 5. Earliest Allowed Timestamp of Next Block\n\t// 6. Genesis Block\n\t// 7. CurrentPath, ordered by height.\n\t// 8. UnspentOutputs, sorted by id.\n\t// 9. OpenContracts, sorted by id.\n\n\t// Create a slice of hashes representing all items of interest.\n\tleaves := []hash.Hash{\n\t\thash.Hash(s.currentBlockID),\n\t\thash.HashObject(s.height()),\n\t\thash.HashObject(s.currentBlockNode().Target),\n\t\thash.HashObject(s.currentBlockNode().Depth),\n\t\thash.HashObject(s.currentBlockNode().earliestChildTimestamp()),\n\t\thash.Hash(s.blockRoot.Block.ID()),\n\t}\n\n\t// Add all the blocks in the current path.\n\tfor i := 0; i < len(s.currentPath); i++ {\n\t\tleaves = append(leaves, hash.Hash(s.currentPath[BlockHeight(i)]))\n\t}\n\n\t// Sort the unspent outputs by the string value of their ID.\n\tsortedUtxos := s.sortedUtxoSet()\n\n\t// Add the unspent outputs in sorted order.\n\tfor _, output := range sortedUtxos {\n\t\tleaves = append(leaves, hash.HashObject(output))\n\t}\n\n\t// Sort the open contracts by the string value of their ID.\n\tvar openContractStrings []string\n\tfor contractID := range s.openContracts {\n\t\topenContractStrings = append(openContractStrings, string(contractID[:]))\n\t}\n\tsort.Strings(openContractStrings)\n\n\t// Add the open contracts in sorted order.\n\tfor _, stringContractID := range openContractStrings {\n\t\tvar contractID ContractID\n\t\tcopy(contractID[:], stringContractID)\n\t\tleaves = append(leaves, hash.HashObject(s.openContracts[contractID]))\n\t}\n\n\treturn hash.MerkleRoot(leaves)\n}", "func (blk *Block) TxHashList() []types.Hash {\n\t// make the container\n\ttxs := make([]types.Hash, len(blk.Txs))\n\n\t// loop hashes and extract them\n\tfor i, hash := range blk.Txs {\n\t\ttxs[i] = *hash\n\t}\n\n\treturn txs\n}", "func blockHash(block Block) [32]byte {\n\tblockmarshal, _ := json.Marshal(block)\n\tsha := sha256.Sum256(blockmarshal)\n\treturn sha\n}", "func toCoinID(txHash *chainhash.Hash, vout uint32) []byte {\n\thashLen := len(txHash)\n\tb := make([]byte, hashLen+4)\n\tcopy(b[:hashLen], txHash[:])\n\tbinary.BigEndian.PutUint32(b[hashLen:], vout)\n\treturn b\n}", "func (msg *MsgTx) TxHash() common.Hash {\n\t// Encode the transaction and calculate double sha256 on the result.\n\t// Ignore the error returns since the only way the encode could fail\n\t// is being out of memory or due to nil pointers, both of which would\n\t// cause a run-time panic.\n\tbuf := bytes.NewBuffer(make([]byte, 0, msg.SerializeSize()))\n\t_ = msg.Serialize(buf)\n\treturn common.DoubleHashH(buf.Bytes())\n}", "func (obj *transaction) Hash() hash.Hash {\n\treturn obj.hash\n}", "func (obj *transaction) Hash() hash.Hash {\n\treturn obj.hash\n}", "func serializeTicketHashes(ths TicketHashes) []byte {\n\tb := make([]byte, len(ths)*chainhash.HashSize)\n\toffset := 0\n\tfor _, th := range ths {\n\t\tcopy(b[offset:offset+chainhash.HashSize], th[:])\n\t\toffset += chainhash.HashSize\n\t}\n\n\treturn b\n}", "func HashCommit(values []*big.Int, issig bool) *big.Int {\n\t// The first element is the number of elements\n\tvar tmp []interface{}\n\toffset := 0\n\tif issig {\n\t\ttmp = make([]interface{}, len(values)+2)\n\t\ttmp[0] = true\n\t\toffset++\n\t} else {\n\t\ttmp = make([]interface{}, len(values)+1)\n\t}\n\ttmp[offset] = gobig.NewInt(int64(len(values)))\n\toffset++\n\tfor i, v := range values {\n\t\ttmp[i+offset] = v.Go()\n\t}\n\tr, err := asn1.Marshal(tmp)\n\tif err != nil {\n\t\tpanic(err) // Marshal should never error, so panic if it does\n\t}\n\n\tsha := sha256.Sum256(r)\n\treturn new(big.Int).SetBytes(sha[:])\n}", "func (b BlockChain) Hash() {\n\n}", "func hashBytes(input ...interface{}) []byte {\n\tvar combine []string\n\tfor _, v := range input {\n\t\tif x, ok := v.([]byte); ok {\n\t\t\tv = string(x)\n\t\t}\n\t\tcombine = append(combine, fmt.Sprintf(\"%v\", v))\n\t}\n\tsum := sha256.Sum256([]byte(strings.Join(combine[0:], NONE)))\n\tvar output []byte\n\toutput = append(output[0:], sum[0:]...)\n\treturn output\n}", "func Hashit(tox string) string {\n h:= sha256.New()\n h.Write([]byte(tox))\n bs := h.Sum([]byte{})\n str := base64.StdEncoding.EncodeToString(bs)\n return str\n}", "func (t *Transaction) createHash() error {\n\tshaHash := sha256.New()\n\tbw := io.NewBinWriterFromIO(shaHash)\n\tt.encodeHashableFields(bw)\n\tif bw.Err != nil {\n\t\treturn bw.Err\n\t}\n\n\tshaHash.Sum(t.hash[:0])\n\tt.hashed = true\n\treturn nil\n}", "func hexHash(input string) string {\n return idToString(hash([]byte(input)))\n}", "func toCoinID(txHash *chainhash.Hash, vout uint32) []byte {\n\tcoinID := make([]byte, chainhash.HashSize+4)\n\tcopy(coinID[:chainhash.HashSize], txHash[:])\n\tbinary.BigEndian.PutUint32(coinID[chainhash.HashSize:], vout)\n\treturn coinID\n}", "func toCoinID(txHash *chainhash.Hash, vout uint32) []byte {\n\tcoinID := make([]byte, chainhash.HashSize+4)\n\tcopy(coinID[:chainhash.HashSize], txHash[:])\n\tbinary.BigEndian.PutUint32(coinID[chainhash.HashSize:], vout)\n\treturn coinID\n}", "func toCoinID(txHash *chainhash.Hash, vout uint32) []byte {\n\tcoinID := make([]byte, chainhash.HashSize+4)\n\tcopy(coinID[:chainhash.HashSize], txHash[:])\n\tbinary.BigEndian.PutUint32(coinID[chainhash.HashSize:], vout)\n\treturn coinID\n}", "func calculateHash(block Block) []byte {\n\tbVersion := util.Uinttobyte(block.Version)\n\tbNonce := util.Uinttobyte(block.Nonce)\n\tbDifficulty := util.Uinttobyte(block.Difficulty)\n\n\trecord := []byte{}\n\trecord = append(record, bVersion[:]...)\n\trecord = append(record, block.PrevHash[:]...)\n\trecord = append(record, bNonce[:]...)\n\trecord = append(record, []byte(block.Timestamp)[:]...)\n\trecord = append(record, bDifficulty[:]...)\n\n\th := sha256.New()\n\th.Write([]byte(record))\n\thashed := h.Sum(nil)\n\t//fmt.Println(hex.EncodeToString(hashed))\n\treturn hashed\n}", "func (data *Data) ListTxHash() ([]chainhash.Hash, error) {\n\tdb, err := data.openDb()\n\tdefer data.closeDb(db)\n\tif err != nil {\n\t\tlog.Printf(\"data.openDb Error : %+v\", err)\n\t\treturn nil, err\n\t}\n\trows, err := db.Query(\"SELECT hash FROM tx\")\n\tif err != nil {\n\t\tlog.Printf(\"db.Query Error : %+v\", err)\n\t\treturn nil, err\n\t}\n\tvar list []chainhash.Hash\n\tfor rows.Next() {\n\t\tvar hash chainhash.Hash\n\t\trows.Scan(&hash)\n\t\tlist = append(list, hash)\n\t}\n\treturn list, nil\n}", "func (op *output) txHash() *chainhash.Hash {\n\treturn &op.pt.txHash\n}", "func (op *output) txHash() *chainhash.Hash {\n\treturn &op.pt.txHash\n}", "func Hash(data []byte) {\n\tfor i := 0; i < 50; i++ {\n\t\tsha256.Sum256(data)\n\t}\n}", "func (bc *Blockchain) Hash() {\n\n}", "func TransactionHashOf(sender hash.Peer, nonce uint64) hash.Transaction {\n\tbuf := append(sender.Bytes(), common.IntToBytes(nonce)...)\n\treturn hash.Transaction(hash.Of(buf))\n}", "func transactionKey(txid []byte) []byte {\n\tkey := make([]byte, len(keyTransactions)+len(txid))\n\tcopy(key, keyTransactions[:])\n\tcopy(key[len(keyTransactions):], txid)\n\treturn key\n}", "func hashhex(a ...[]byte) string {\n\th := hashbyte(a...)\n\ts := fmt.Sprintf(\"%x\", h)\n\treturn s\n}", "func (spec Spec) DeepHash() string {\n\thash := sha512.New512_224()\n\tspec.DefaultService.hash(hash)\n\tfor _, rule := range spec.Rules {\n\t\trule.hash(hash)\n\t}\n\tsvcs := make([]string, len(spec.AllServices))\n\ti := 0\n\tfor k := range spec.AllServices {\n\t\tsvcs[i] = k\n\t\ti++\n\t}\n\tsort.Strings(svcs)\n\tfor _, svc := range svcs {\n\t\thash.Write([]byte(svc))\n\t\tspec.AllServices[svc].hash(hash)\n\t}\n\tspec.ShardCluster.hash(hash)\n\thash.Write([]byte(spec.VCL))\n\tfor _, auth := range spec.Auths {\n\t\tauth.hash(hash)\n\t}\n\tfor _, acl := range spec.ACLs {\n\t\tacl.hash(hash)\n\t}\n\tfor _, rw := range spec.Rewrites {\n\t\trw.hash(hash)\n\t}\n\tfor _, reqDisp := range spec.Dispositions {\n\t\treqDisp.hash(hash)\n\t}\n\th := new(big.Int)\n\th.SetBytes(hash.Sum(nil))\n\treturn h.Text(62)\n}", "func Hash(input []byte) string {\n\treturn fmt.Sprintf(\"%x\", sha256.Sum256(input))\n}", "func calculateAttributesHash(attributes []string) (attrHash string) {\n\n\tkeys := make([]string, len(attributes))\n\n\tfor _, k := range attributes {\n\t\tkeys = append(keys, k)\n\t}\n\n\tsort.Strings(keys)\n\n\tvalues := make([]byte, len(keys))\n\n\tfor _, k := range keys {\n\t\tvb := []byte(k)\n\t\tfor _, bval := range vb {\n\t\t\tvalues = append(values, bval)\n\t\t}\n\t}\n\tattributesHash := primitives.Hash(values)\n\treturn hex.EncodeToString(attributesHash)\n\n}", "func hashBytes(hashType HashType, bytes []byte) []byte {\n var idHash []byte\n switch hashType {\n case SHA3:\n hash := sha3.Sum224(bytes)\n return hash[:]\n case Shake128:\n sha3.ShakeSum256(idHash, bytes)\n return idHash\n default: // Undefined\n return bytes\n }\n}", "func IDHashBytes(b []byte) []byte {\n\th := sha3.Sum224(b)\n\treturn h[:]\n}", "func (_DevUtils *DevUtilsSession) GetTransactionHash(transaction LibZeroExTransactionZeroExTransaction, chainId *big.Int, exchange common.Address) ([32]byte, error) {\n\treturn _DevUtils.Contract.GetTransactionHash(&_DevUtils.CallOpts, transaction, chainId, exchange)\n}", "func Hash(strings ...string) uint32 {\n\tdigester := fnv.New32()\n\tfor _, s := range strings {\n\t\t_, _ = io.WriteString(digester, s)\n\t}\n\treturn digester.Sum32()\n}", "func (tx *Tx) SequenceHash() []byte {\r\n\tbuf := make([]byte, 0)\r\n\r\n\tfor _, in := range tx.Inputs {\r\n\t\toi := make([]byte, 4)\r\n\t\tbinary.LittleEndian.PutUint32(oi, in.SequenceNumber)\r\n\t\tbuf = append(buf, oi...)\r\n\t}\r\n\r\n\treturn crypto.Sha256d(buf)\r\n}", "func (s SampleList) Hash(i int) []byte {\n\tres := md5.Sum(s[i])\n\treturn res[:]\n}", "func hash(data []byte) [32]byte {\n\tvar hash [32]byte\n\n\th := sha256.New()\n\t// The hash interface never returns an error, for that reason\n\t// we are not handling the error below. For reference, it is\n\t// stated here https://golang.org/pkg/hash/#Hash\n\t// #nosec G104\n\th.Write(data)\n\th.Sum(hash[:0])\n\n\treturn hash\n}", "func (t *largeFlatTable) Hash() hash.Hash { return t.hash }", "func (w WithdrawEvent) TxHash() common.Hash {\n\treturn w.txHash\n}", "func Hash(mem []byte) uint64 {\n\tvar hash uint64 = 5381\n\tfor _, b := range mem {\n\t\thash = (hash << 5) + hash + uint64(b)\n\t}\n\treturn hash\n}", "func seededHash(hashFunc hash.Hash, element []byte, seed uint32) []byte{\n hashFunc.Reset()\n binary.Write(hashFunc, defaultEndianness, seed)\n hashFunc.Write(element)\n hashCode := hashFunc.Sum()\n return hashCode\n}", "func (_DevUtils *DevUtilsCallerSession) GetTransactionHash(transaction LibZeroExTransactionZeroExTransaction, chainId *big.Int, exchange common.Address) ([32]byte, error) {\n\treturn _DevUtils.Contract.GetTransactionHash(&_DevUtils.CallOpts, transaction, chainId, exchange)\n}", "func hexEncodeSHA256Hash(body []byte) (string, error) {\n\thash := sha256.New()\n\tif body == nil {\n\t\tbody = []byte(\"\")\n\t}\n\t_, err := hash.Write(body)\n\treturn hex.EncodeToString(hash.Sum(nil)), err\n}", "func (c *CoordinatorHelper) Hash(\n\tctx context.Context,\n\tnetworkIdentifier *types.NetworkIdentifier,\n\tnetworkTransaction string,\n) (*types.TransactionIdentifier, error) {\n\tres, fetchErr := c.offlineFetcher.ConstructionHash(\n\t\tctx,\n\t\tnetworkIdentifier,\n\t\tnetworkTransaction,\n\t)\n\n\tif fetchErr != nil {\n\t\treturn nil, fetchErr.Err\n\t}\n\n\treturn res, nil\n}", "func (bb BlockBody) Hash() cipher.SHA256 {\n\thashes := make([]cipher.SHA256, len(bb.Transactions))\n\tfor i := range bb.Transactions {\n\t\thashes[i] = bb.Transactions[i].Hash()\n\t}\n\t// Merkle hash of transactions\n\treturn cipher.Merkle(hashes)\n}", "func (bb BlockBody) Hash() cipher.SHA256 {\n\thashes := make([]cipher.SHA256, len(bb.Transactions))\n\tfor i := range bb.Transactions {\n\t\thashes[i] = bb.Transactions[i].Hash()\n\t}\n\t// Merkle hash of transactions\n\treturn cipher.Merkle(hashes)\n}", "func hash(x []byte) uint32 {\n\treturn crc32.ChecksumIEEE(x)\n}", "func (c *Coinbase) CalculateHash() ([]byte, error) {\n\tif len(c.TxID) != 0 {\n\t\treturn c.TxID, nil\n\t}\n\n\ttxid, err := hashBytes(c.Encode)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tc.TxID = txid\n\n\treturn c.TxID, nil\n}", "func (t *Tx) sign() {\n\tfor _, txIn := range t.TxIns {\n\t\t// sign transaction id, which is a hash of the transaction\n\t\ttxIn.Signature = wallet.Sign(t.Id, wallet.Wallet())\n\t}\n}", "func (t *Transaction) Hash() util.Uint256 {\n\tif !t.hashed {\n\t\tif t.createHash() != nil {\n\t\t\tpanic(\"failed to compute hash!\")\n\t\t}\n\t}\n\treturn t.hash\n}", "func (s *State) Hash() []byte {\n\treturn s.deliverTx.Hash()\n}", "func (block *Block) calculateHash() {\n\tblock.hash = hash([]byte(string(block.id) +\n\t\tstring(block.previousBlockHash) +\n\t\tstring(block.Content)))\n}", "func (self *ResTransaction)GetHashCached()string{\n return self.Hash\n}", "func (t *smallFlatTable) Hash() hash.Hash { return t.hash }", "func (t *Tangle) Hashes() []hash.Hash {\n\treturn t.store.Hashes()\n}", "func (cb *cachedBatch) hash(namespace string, key []byte) hash.CacheHash {\n\tstream := hash.Hash160b([]byte(namespace))\n\tstream = append(stream, key...)\n\treturn byteutil.BytesToCacheHash(hash.Hash160b(stream))\n}" ]
[ "0.75380266", "0.74975175", "0.7465126", "0.74426436", "0.73201126", "0.7020707", "0.6872097", "0.67827904", "0.67827904", "0.67827904", "0.6652028", "0.6523222", "0.6502628", "0.6484236", "0.63336706", "0.6326585", "0.63102835", "0.6273257", "0.6252849", "0.62448186", "0.6161875", "0.6159073", "0.6152616", "0.61391455", "0.60948586", "0.60857993", "0.60761", "0.6074528", "0.60743713", "0.6053388", "0.60474735", "0.6037763", "0.6022506", "0.6015675", "0.5990419", "0.59578687", "0.5957352", "0.5944834", "0.5937835", "0.5925509", "0.5924581", "0.5904779", "0.5904232", "0.58952427", "0.58949286", "0.58921605", "0.5888053", "0.5878537", "0.5858684", "0.5853821", "0.5853298", "0.5853298", "0.5821327", "0.5811724", "0.5789788", "0.57820976", "0.57639456", "0.575993", "0.5748824", "0.5748652", "0.5748652", "0.5748652", "0.57407504", "0.570824", "0.5703218", "0.5703218", "0.56987077", "0.5683796", "0.5675226", "0.5669831", "0.5657613", "0.56309897", "0.561479", "0.56102", "0.5599338", "0.55968624", "0.5591374", "0.5581877", "0.5579163", "0.5558792", "0.55575955", "0.5554413", "0.5544798", "0.5540708", "0.5532782", "0.552763", "0.5527231", "0.5527169", "0.55198216", "0.55198216", "0.55062115", "0.5501083", "0.5499024", "0.5493173", "0.5491744", "0.5489429", "0.5455052", "0.5454488", "0.545097", "0.54502815" ]
0.6858078
7
Serialize serializes block using encoder
func (block *Block) Serialize() []byte { var result bytes.Buffer encoder := gob.NewEncoder(&result) err := encoder.Encode(block) if err != nil { panic(err) } return result.Bytes() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b *block) Serialize() []byte {\n\tvar res bytes.Buffer\n\tencoder := gob.NewEncoder(&res) // address\n\terr := encoder.Encode(b) // here b is the source\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\treturn res.Bytes()\n}", "func (b *MicroBlock) Serialize(w io.Writer) error {\n return writeBlockHeader(w, 0, b)\n}", "func (block *Block) Serialize() []byte {\n\tvar buff bytes.Buffer\n\n\tencoder := gob.NewEncoder(&buff)\n\n\terr := encoder.Encode(block)\n\n\tHandle(err)\n\n\treturn buff.Bytes()\n}", "func (pb *PutBlock) Serialize() []byte {\n\treturn byteutil.Must(proto.Marshal(pb.Proto()))\n}", "func (b *Block) Serialize() []byte {\n\tvar res bytes.Buffer\n\tencoder := gob.NewEncoder(&res)\n\n\terr := encoder.Encode(b)\n\n\tHandle(err)\n\n\treturn res.Bytes()\n}", "func (b *Block) Serialize() []byte {\n\tvar res bytes.Buffer\n\tencoder := gob.NewEncoder(&res)\n\n\terr := encoder.Encode(b)\n\n\tHandle(err)\n\n\treturn res.Bytes()\n}", "func (msg *Block) Serialize(w io.Writer) (e error) {\n\t// At the current time, there is no difference between the wire encoding at\n\t// protocol version 0 and the stable long-term storage format. As a result, make\n\t// use of BtcEncode. Passing WitnessEncoding as the encoding type here indicates\n\t// that each of the transactions should be serialized using the witness\n\t// serialization structure defined in BIP0141.\n\treturn msg.BtcEncode(w, 0, BaseEncoding)\n}", "func (b *Block) Serialize() []byte {\n\tvar result bytes.Buffer\n\tencoder := gob.NewEncoder(&result)\n\tencoder.Encode(b)\n\treturn result.Bytes()\n}", "func (b *Block) Serialize() []byte {\n\tvar result bytes.Buffer\n\tencoder := gob.NewEncoder(&result)\n\n\tencoder.Encode(b)\n\n\treturn result.Bytes()\n}", "func (b *Block) Serialize() []byte {\n\n\tout, err := proto.Marshal(b)\n\tif err != nil {\n\t\tlog.Println(\"block-serialize: protobuf encoding error: \", err)\n\t}\n\treturn out\n\n}", "func (b *Block) Serialize() []byte {\n\tvar res bytes.Buffer\n\tencoder := gob.NewEncoder(&res)\n\terr := encoder.Encode(b)\n\n\tif err != nil {\n\t\tlog.Println(\"cannot serialize \" + err.Error())\n\t\treturn nil\n\t}\n\n\treturn res.Bytes()\n}", "func (b *Block) Serialize() ([]byte, error) {\n\treturn proto.Marshal(b.ConvertToBlockPb())\n}", "func (bm *BlockMeta) Serialize() ([]byte, error) {\n\tpb, err := bm.Proto()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn proto.Marshal(pb)\n}", "func (b *Block) EncodeToJson() (string, error) {\n\n toJson := BlockJson{\n b.Header.Height,\n b.Header.Timestamp,\n b.Header.Hash,\n b.Header.ParentHash,\n b.Header.Size,\n b.Header.Nonce,\n b.Mpt.Inputs,\n }\n\n jsonFormatted, err := json.Marshal(toJson)\n if err != nil {\n fmt.Println(\"Error in EncodeToJson\")\n return string(jsonFormatted), err\n }\n return string(jsonFormatted), nil\n}", "func (b *Block1) Serialize() []byte {\n\tvar result bytes.Buffer\n\tencoder := gob.NewEncoder(&result)\n\n\terr := encoder.Encode(b)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\treturn result.Bytes()\n}", "func (b *Block) Encode() error {\n\tif len(b.subelements) == 0 {\n\t\t// Take no action, but is not an error\n\t\treturn nil\n\t}\n\n\tb.value = []byte{}\n\tfor _, elem := range b.subelements {\n\t\telemWire, err := elem.Wire()\n\t\tif err != nil {\n\t\t\tb.value = []byte{}\n\t\t\treturn err\n\t\t}\n\t\tb.value = append(b.value, elemWire...)\n\t}\n\n\tb.subelements = []*Block{}\n\treturn nil\n}", "func (block *Block) SerializeBlock() []byte {\n\tvar result bytes.Buffer\n\n\tencoder := gob.NewEncoder(&result)\n\n\t_ = encoder.Encode(block)\n\n\treturn result.Bytes()\n}", "func (r *BlockSeqFunc) Serialize() ([]byte, error) {\n\ts, ok := r.Block.(serializer.Serializer)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"type is not a Serializer: %T\", r.Block)\n\t}\n\treturn serializer.SerializeWithType(s)\n}", "func (b *Block) Serialize() []byte {\n\tresult := make([]byte, 80)\n\tposition := 0\n\tcopy(result[position:position+4], util.Int32ToLittleEndian(b.Version))\n\tposition += 4\n\tcopy(result[position:position+32], b.PrevBlock[:])\n\tutil.ReverseByteArray(result[position : position+32])\n\tposition += 32\n\tcopy(result[position:position+32], b.MerkleRoot[:])\n\tutil.ReverseByteArray(result[position : position+32])\n\tposition += 32\n\tcopy(result[position:position+4], util.Int32ToLittleEndian(b.Timestamp))\n\tposition += 4\n\tcopy(result[position:position+4], b.Bits[:])\n\tposition += 4\n\tcopy(result[position:position+4], b.Nonce[:])\n\treturn result\n}", "func (h *BlockHeader) Serialize(w io.Writer) error {\n\t// At the current time, there is no difference between the wire encoding\n\t// at protocol version 0 and the stable long-term storage format. As\n\t// a result, make use of writeBlockHeader.\n\treturn nil\n}", "func (u *UndoBlock) Serialize(w io.Writer) error {\n\terr := binary.Write(w, binary.BigEndian, u.numAdds)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.BigEndian, uint64(len(u.positions)))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.BigEndian, u.positions)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = binary.Write(w, binary.BigEndian, uint64(len(u.hashes)))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, hash := range u.hashes {\n\t\tn, err := w.Write(hash[:])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif n != 32 {\n\t\t\terr := fmt.Errorf(\"UndoBlock Serialize supposed to write 32 bytes but wrote %d bytes\", n)\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (block *Block) SerializeBlock() []byte {\n\tvar result bytes.Buffer\n\n\tencoder := gob.NewEncoder(&result)\n\terr := encoder.Encode(block)\n\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\treturn result.Bytes()\n}", "func (v Block) EncodeJSON(b []byte) []byte {\n\tb = append(b, '{', '\"', 'b', 'l', 'o', 'c', 'k', '_', 'i', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', '\"', ':')\n\tb = v.BlockIdentifier.EncodeJSON(b)\n\tb = append(b, \",\"...)\n\tif len(v.Metadata) > 0 {\n\t\tb = append(b, `\"metadata\":`...)\n\t\tb = append(b, v.Metadata...)\n\t\tb = append(b, \",\"...)\n\t}\n\tb = append(b, '\"', 'p', 'a', 'r', 'e', 'n', 't', '_', 'b', 'l', 'o', 'c', 'k', '_', 'i', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', '\"', ':')\n\tb = v.ParentBlockIdentifier.EncodeJSON(b)\n\tb = append(b, `,\"timestamp\":`...)\n\tb = json.AppendInt(b, int64(v.Timestamp))\n\tb = append(b, ',', '\"', 't', 'r', 'a', 'n', 's', 'a', 'c', 't', 'i', 'o', 'n', 's', '\"', ':', '[')\n\tfor i, elem := range v.Transactions {\n\t\tif i != 0 {\n\t\t\tb = append(b, \",\"...)\n\t\t}\n\t\tb = elem.EncodeJSON(b)\n\t}\n\treturn append(b, \"]}\"...)\n}", "func (b *Block) SerializeBlock() []byte {\n\tvar result bytes.Buffer\n\tencoder := gob.NewEncoder(&result)\n\n\tencoder.Encode(b)\n\n\treturn result.Bytes()\n}", "func (bh *BlockHeader) Serialize(w io.Writer) error {\n\t// At the current time, there is no difference between the protos encoding\n\t// at protocol version 0 and the stable long-term storage format. As\n\t// a result, make use of writeBlockHeader.\n\terr := bh.SerializeNode(w)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = serialization.WriteNBytes(w, bh.SigData[:])\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (h *BlockHeader) Serialize(w io.Writer) error {\n\t// At the current time, there is no difference between the wire encoding\n\t// at protocol version 0 and the stable long-term storage format. As\n\t// a result, make use of writeBlockHeader.\n\treturn writeBlockHeader(w, 0, h)\n}", "func (h *BlockHeader) Serialize(w io.Writer) error {\n\t// At the current time, there is no difference between the wire encoding\n\t// at protocol version 0 and the stable long-term storage format. As\n\t// a result, make use of writeBlockHeader.\n\treturn writeBlockHeader(w, 0, h)\n}", "func (b Block) Encode(w io.Writer) error {\n\tcorrectLength := b.CorrectLength()\n\tif (correctLength < 32 && b.Type == 3) || correctLength < 16 {\n\t\t// Error should never happen\n\t\treturn errors.New(\"Block length is too small\")\n\t}\n\theaderLength := 16\n\tbuf := make([]byte, correctLength)\n\tbinary.LittleEndian.PutUint32(buf[0:4], correctLength)\n\tbinary.LittleEndian.PutUint32(buf[4:8], b.SubjectID)\n\tbinary.LittleEndian.PutUint32(buf[8:12], b.CurrentID)\n\tbinary.LittleEndian.PutUint16(buf[12:14], b.Type)\n\tbinary.LittleEndian.PutUint16(buf[14:16], b.Pad1)\n\tif b.Type == 3 {\n\t\theaderLength = 32\n\t\tbinary.LittleEndian.PutUint16(buf[16:18], b.Reserved)\n\t\tbinary.LittleEndian.PutUint16(buf[18:20], b.Opcode)\n\t\tbinary.LittleEndian.PutUint16(buf[20:22], b.Pad2)\n\t\tbinary.LittleEndian.PutUint16(buf[22:24], b.ServerID)\n\t\ttime := uint32(b.Time.Unix())\n\t\tbinary.LittleEndian.PutUint32(buf[24:28], time)\n\t\tbinary.LittleEndian.PutUint32(buf[28:32], b.Pad3)\n\t}\n\n\tvar blockData []byte\n\tvar err error\n\tswitch v := b.Data.(type) {\n\tcase *GenericBlockData:\n\t\tblockData, err = v.MarshalBytes()\n\tdefault:\n\t\tblockData, err = MarshalBlockBytes(v)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tcopy(buf[headerLength:correctLength], blockData)\n\n\t_, err = w.Write(buf)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (txn *Transaction) Serialize() utils.Gob {\n\t// Encode the blockheader as a gob and return it\n\treturn utils.GobEncode(txn)\n}", "func (b *blockV1) Serialize(paddedBlockSize uint32) ([]byte, error) {\n\tblockSize := uint32(len(b.GetData()))\n\ttotalSize := blockHeaderLen + blockSize\n\tarrayBytes := totalSize\n\n\t// Padding turned on\n\tif paddedBlockSize > 0 {\n\t\tarrayBytes = paddedBlockSize\n\n\t\t// Each block can be at most \"paddedBlockSize\"\n\t\tif totalSize > paddedBlockSize {\n\t\t\treturn nil, NewBlockPaddingError(\n\t\t\t\t\"Block too large to pad to a fixed size\",\n\t\t\t\tpaddedBlockSize, totalSize, paddedBlockSize-8)\n\t\t}\n\t}\n\n\tserial := make([]byte, arrayBytes)\n\tbinary.BigEndian.PutUint32(serial[0:], b.GetID())\n\tbinary.BigEndian.PutUint32(serial[blockNumLen:], blockSize)\n\tcopy(serial[blockHeaderLen:], b.GetData())\n\n\t// Padding turned on\n\tif paddedBlockSize > 0 {\n\t\tif _, err := rand.Read(serial[totalSize:]); err != nil {\n\t\t\treturn nil, errors.New(err)\n\t\t}\n\t}\n\n\treturn serial, nil\n}", "func (self *Block) Bytes() []byte {\n\treturn encoder.Serialize(*self)\n}", "func MarshalBlock(block Block) []byte {\n\tmBlock, err := json.Marshal(block)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n\tmBlock = append([]byte(\"POW\"), mBlock...)\n\treturn mBlock\n}", "func EncodeToJSON(block *Block) string {\n\n\tblockForJson := BlockJson{\n\t\tHeight: block.Header.Height,\n\t\tTimestamp: block.Header.Timestamp,\n\t\tHash: block.Header.Hash,\n\t\tParentHash: block.Header.ParentHash,\n\t\tSize: block.Header.Size,\n\t\tNonce: block.Header.Nonce,\n\t\tMPT: block.Value.GetAllKeyValuePairs(),\n\t}\n\n\tjsonByteArray, err := json.Marshal(blockForJson)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\t//jsonString = string(jsonByteArray)\n\treturn string(jsonByteArray) //empty jsonString if not encoded else some value\n}", "func (p *printer) EncodeBlock(block *fabriccmn.Block) (string, error) {\n\treturn p.Encoder.EncodeBlockIon(block)\n}", "func (b *Block) MarshalBinary() ([]byte, error) {\n\treturn json.Marshal(b)\n}", "func (b *Block) CompressBlock() string {\n return \"height=\" + int32ToString(b.Header.Height) + \", timestamp=\" + int64ToString(b.Header.Timestamp) + \", hash=\" + b.Header.Hash + \", parentHash=\" + b.Header.ParentHash + \", size=\" + int32ToString(b.Header.Size)\n}", "func (b Block) MarshalJSON() ([]byte, error) {\n\toutput, err := json.Marshal(b.BlockMetadata)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbaseBytes, err := json.Marshal(b.Block)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// We have to keep both \"fields\" at the same level in json in order to\n\t// match C# API, so there's no way to marshall Block correctly with\n\t// standard json.Marshaller tool.\n\tif output[len(output)-1] != '}' || baseBytes[0] != '{' {\n\t\treturn nil, errors.New(\"can't merge internal jsons\")\n\t}\n\toutput[len(output)-1] = ','\n\toutput = append(output, baseBytes[1:]...)\n\treturn output, nil\n}", "func EncodeBestBlock(bb BestBlock) ([]byte, error) {\n\treturn json.Marshal(bb)\n}", "func (msg *Block) SerializeNoWitness(w io.Writer) (e error) {\n\treturn msg.BtcEncode(w, 0, BaseEncoding)\n}", "func (b *Block) ToJSON() []byte {\n\tdata, err := json.Marshal(b)\n\tif err != nil {\n\t\tlog.Printf(\"[!] Failed to encode block data to JSON : %s\\n\", err.Error())\n\t\treturn nil\n\t}\n\n\treturn data\n}", "func (v PartialBlockIdentifier) EncodeJSON(b []byte) []byte {\n\tb = append(b, \"{\"...)\n\tif v.Hash.Set {\n\t\tb = append(b, `\"hash\":`...)\n\t\tb = json.AppendString(b, v.Hash.Value)\n\t\tb = append(b, \",\"...)\n\t}\n\tif v.Index.Set {\n\t\tb = append(b, `\"index\":`...)\n\t\tb = json.AppendInt(b, v.Index.Value)\n\t\tb = append(b, \",\"...)\n\t}\n\tb[len(b)-1] = '}'\n\treturn b\n}", "func (out *TransactionOutput) Serialize(bw *io.BinaryWriter) {\n\tbw.WriteLE(out.AssetId)\n\tbw.WriteLE(out.Value)\n\tbw.WriteLE(out.ScriptHash)\n}", "func Serialize(name string, comment string, b []byte, w io.Writer) error {\n\topcodes := make([]Opcode, len(b))\n\tfor i := range b {\n\t\topcodes[i] = Opcode(b[i])\n\t}\n\toutput := ChasmBinary{\n\t\tName: name,\n\t\tComment: comment,\n\t\tData: opcodes,\n\t}\n\tenc := json.NewEncoder(w)\n\tenc.SetIndent(\"\", \" \")\n\treturn enc.Encode(output)\n}", "func (bh *BlockHeader) SerializeNode(w io.Writer) error {\n\tif err := serialization.WriteUint32(w, uint32(bh.Version)); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteNBytes(w, bh.PrevBlock[:]); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteNBytes(w, bh.MerkleRoot[:]); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteUint64(w, uint64(bh.Timestamp)); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteNBytes(w, bh.StateRoot[:]); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteUint64(w, bh.GasLimit); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteUint64(w, bh.GasUsed); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteUint32(w, bh.Round); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteUint16(w, bh.SlotIndex); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteUint16(w, bh.Weight); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteNBytes(w, bh.PoaHash[:]); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteUint32(w, uint32(bh.Height)); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.WriteNBytes(w, bh.CoinBase[:]); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (v BlockIdentifier) EncodeJSON(b []byte) []byte {\n\tb = append(b, `{\"hash\":`...)\n\tb = json.AppendString(b, v.Hash)\n\tb = append(b, `,\"index\":`...)\n\tb = json.AppendInt(b, v.Index)\n\treturn append(b, \"}\"...)\n}", "func (v BlockEvent) EncodeJSON(b []byte) []byte {\n\tb = append(b, '{', '\"', 'b', 'l', 'o', 'c', 'k', '_', 'i', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', '\"', ':')\n\tb = v.BlockIdentifier.EncodeJSON(b)\n\tb = append(b, `,\"sequence\":`...)\n\tb = json.AppendInt(b, v.Sequence)\n\tb = append(b, `,\"type\":`...)\n\tb = json.AppendString(b, string(v.Type))\n\treturn append(b, \"}\"...)\n}", "func (b *Block) String() string {\r\n\treturn hex.EncodeToString(b.Bytes())\r\n}", "func writeBlock(w io.Writer, pver uint32, b *MicroBlock) error {\n\tsec := uint32(bh.Timestamp.Unix())\n\treturn writeElements(w, b.Version, &b.PrevBlock, &b.MerkleRoot,\n\t\tsec, b.Bits)\n}", "func Serialize(o interface{}) ([]byte, error) {\n\tautil.TODO(\"CBOR-serialization\")\n\treturn nil, nil\n}", "func (s *StoredChannel) serialize() ([]byte, error) {\n\tbuffer := &bytes.Buffer{}\n\tencoder := gob.NewEncoder(buffer)\n\terr := encoder.Encode(s)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn buffer.Bytes(), nil\n}", "func (b *blockEnc) encodeRaw(a []byte) {\n\tvar bh blockHeader\n\tbh.setLast(b.last)\n\tbh.setSize(uint32(len(a)))\n\tbh.setType(blockTypeRaw)\n\tb.output = bh.appendTo(b.output[:0])\n\tb.output = append(b.output, a...)\n\tif debugEncoder {\n\t\tprintln(\"Adding RAW block, length\", len(a), \"last:\", b.last)\n\t}\n}", "func TestGraphQLBlockSerialization(t *testing.T) {\n\tstack := createNode(t, true, false)\n\tdefer stack.Close()\n\t// start node\n\tif err := stack.Start(); err != nil {\n\t\tt.Fatalf(\"could not start node: %v\", err)\n\t}\n\n\tfor i, tt := range []struct {\n\t\tbody string\n\t\twant string\n\t\tcode int\n\t}{\n\t\t{ // Should return latest block\n\t\t\tbody: `{\"query\": \"{block{number}}\",\"variables\": null}`,\n\t\t\twant: `{\"data\":{\"block\":{\"number\":10}}}`,\n\t\t\tcode: 200,\n\t\t},\n\t\t{ // Should return info about latest block\n\t\t\tbody: `{\"query\": \"{block{number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"data\":{\"block\":{\"number\":10,\"gasUsed\":0,\"gasLimit\":11500000}}}`,\n\t\t\tcode: 200,\n\t\t},\n\t\t{\n\t\t\tbody: `{\"query\": \"{block(number:0){number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"data\":{\"block\":{\"number\":0,\"gasUsed\":0,\"gasLimit\":11500000}}}`,\n\t\t\tcode: 200,\n\t\t},\n\t\t{\n\t\t\tbody: `{\"query\": \"{block(number:-1){number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"data\":{\"block\":null}}`,\n\t\t\tcode: 200,\n\t\t},\n\t\t{\n\t\t\tbody: `{\"query\": \"{block(number:-500){number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"data\":{\"block\":null}}`,\n\t\t\tcode: 200,\n\t\t},\n\t\t{\n\t\t\tbody: `{\"query\": \"{block(number:\\\"0\\\"){number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"data\":{\"block\":{\"number\":0,\"gasUsed\":0,\"gasLimit\":11500000}}}`,\n\t\t\tcode: 200,\n\t\t},\n\t\t{\n\t\t\tbody: `{\"query\": \"{block(number:\\\"-33\\\"){number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"data\":{\"block\":null}}`,\n\t\t\tcode: 200,\n\t\t},\n\t\t{\n\t\t\tbody: `{\"query\": \"{block(number:\\\"1337\\\"){number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"data\":{\"block\":null}}`,\n\t\t\tcode: 200,\n\t\t},\n\t\t{\n\t\t\tbody: `{\"query\": \"{block(number:\\\"0xbad\\\"){number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"errors\":[{\"message\":\"strconv.ParseInt: parsing \\\"0xbad\\\": invalid syntax\"}],\"data\":{}}`,\n\t\t\tcode: 400,\n\t\t},\n\t\t{ // hex strings are currently not supported. If that's added to the spec, this test will need to change\n\t\t\tbody: `{\"query\": \"{block(number:\\\"0x0\\\"){number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"errors\":[{\"message\":\"strconv.ParseInt: parsing \\\"0x0\\\": invalid syntax\"}],\"data\":{}}`,\n\t\t\tcode: 400,\n\t\t},\n\t\t{\n\t\t\tbody: `{\"query\": \"{block(number:\\\"a\\\"){number,gasUsed,gasLimit}}\",\"variables\": null}`,\n\t\t\twant: `{\"errors\":[{\"message\":\"strconv.ParseInt: parsing \\\"a\\\": invalid syntax\"}],\"data\":{}}`,\n\t\t\tcode: 400,\n\t\t},\n\t\t{\n\t\t\tbody: `{\"query\": \"{bleh{number}}\",\"variables\": null}\"`,\n\t\t\twant: `{\"errors\":[{\"message\":\"Cannot query field \\\"bleh\\\" on type \\\"Query\\\".\",\"locations\":[{\"line\":1,\"column\":2}]}]}`,\n\t\t\tcode: 400,\n\t\t},\n\t\t// should return `estimateGas` as decimal\n\t\t{\n\t\t\tbody: `{\"query\": \"{block{ estimateGas(data:{}) }}\"}`,\n\t\t\twant: `{\"data\":{\"block\":{\"estimateGas\":53000}}}`,\n\t\t\tcode: 200,\n\t\t},\n\t\t// should return `status` as decimal\n\t\t{\n\t\t\tbody: `{\"query\": \"{block {number call (data : {from : \\\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\\\", to: \\\"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\\\", data :\\\"0x12a7b914\\\"}){data status}}}\"}`,\n\t\t\twant: `{\"data\":{\"block\":{\"number\":10,\"call\":{\"data\":\"0x\",\"status\":1}}}}`,\n\t\t\tcode: 200,\n\t\t},\n\t} {\n\t\tresp, err := http.Post(fmt.Sprintf(\"%s/graphql\", stack.HTTPEndpoint()), \"application/json\", strings.NewReader(tt.body))\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"could not post: %v\", err)\n\t\t}\n\t\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"could not read from response body: %v\", err)\n\t\t}\n\t\tif have := string(bodyBytes); have != tt.want {\n\t\t\tt.Errorf(\"testcase %d %s,\\nhave:\\n%v\\nwant:\\n%v\", i, tt.body, have, tt.want)\n\t\t}\n\t\tif tt.code != resp.StatusCode {\n\t\t\tt.Errorf(\"testcase %d %s,\\nwrong statuscode, have: %v, want: %v\", i, tt.body, resp.StatusCode, tt.code)\n\t\t}\n\t}\n}", "func writeBlock(file *os.File, index int64, data *dataBlock) {\n\tfile.Seek(index, 0)\n\t//Empezamos el proceso de guardar en binario la data en memoria del struct\n\tvar binaryDisc bytes.Buffer\n\tbinary.Write(&binaryDisc, binary.BigEndian, data)\n\twriteNextBytes(file, binaryDisc.Bytes())\n}", "func sendBlock(block *Block, ws *WrappedStream) error {\n\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tfmt.Println(\"recovered error in send block\", r)\n\t\t}\n\t}()\n\n\terr := ws.enc.Encode(block)\n\tif err != nil {\n\t\tlog.Printf(\"block encoding error:\\n\\n%v\\n\\n\", block)\n\t\treturn err\n\t}\n\t// Because output is buffered with bufio, we need to flush!\n\tws.w.Flush()\n\treturn err\n}", "func (in *Store) Serialize() ([]byte, error) {\n\treturn proto.Marshal(in.ToProto())\n}", "func serializeBlockUndoData(utds []UndoTicketData) []byte {\n\tb := make([]byte, len(utds)*undoTicketDataSize)\n\toffset := 0\n\tfor _, utd := range utds {\n\t\tcopy(b[offset:offset+chainhash.HashSize], utd.TicketHash[:])\n\t\toffset += chainhash.HashSize\n\t\tdbnamespace.ByteOrder.PutUint32(b[offset:offset+4], utd.TicketHeight)\n\t\toffset += 4\n\t\tb[offset] = undoBitFlagsToByte(utd.Missed, utd.Revoked, utd.Spent,\n\t\t\tutd.Expired)\n\t\toffset++\n\t}\n\n\treturn b\n}", "func (o *A_2) Serialize(\r\n\tbyteOrder binary.ByteOrder,\r\n\tstream io.Writer,\r\n) error {\r\n\t//TODO: implement\r\n\t/*\r\n\t\tif err := o.cursor.Serialize(byteOrder, stream); err != nil {\r\n\t\t\treturn err\r\n\t\t}\r\n\t\t\tif err := o.limit.Serialize(byteOrder, stream); err != nil {\r\n\t\t\t\treturn err\r\n\t\t\t}\r\n\t*/\r\n\treturn fmt.Errorf(\"not yet implemented\")\r\n}", "func (b BlockNumber) Encode(encoder util.Encoder) error {\n\treturn encoder.EncodeUintCompact(uint64(b))\n}", "func (b *Block) Write() error {\n\tdata := []byte(b.String())\n\tfname := \"blocks/\" + strconv.Itoa(b.Number) + \".block\"\n\n\tif err := ioutil.WriteFile(fname, data, 0600); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (m *Synchronization) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n if m.GetJobs() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetJobs()))\n for i, v := range m.GetJobs() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"jobs\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetSecrets() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetSecrets()))\n for i, v := range m.GetSecrets() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"secrets\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetTemplates() != nil {\n cast := make([]i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, len(m.GetTemplates()))\n for i, v := range m.GetTemplates() {\n if v != nil {\n cast[i] = v.(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable)\n }\n }\n err = writer.WriteCollectionOfObjectValues(\"templates\", cast)\n if err != nil {\n return err\n }\n }\n return nil\n}", "func encodeBlock(dst, src []byte) (d int) {\n\tif len(src) < minNonLiteralBlockSize {\n\t\treturn 0\n\t}\n\treturn encodeBlockGo(dst, src)\n}", "func (bo *BlockObject) toJSON(t *thread) string {\n\treturn bo.toString()\n}", "func Serialize(input interface{}) (msg []byte, err error) {\n\tbuffer, err := json.Marshal(input)\n\treturn buffer, err\n\n\t// TODO: Do we really need wire here?\n\t/*\n\t\tvar count int\n\n\t\tbuffer := new(bytes.Buffer)\n\n\t\twire.WriteBinary(input, buffer, &count, &err)\n\n\t\treturn buffer.Bytes(), err\n\t*/\n}", "func (b Block) MarshalSia(w io.Writer) error {\n\tif build.DEBUG {\n\t\t// Sanity check: compare against the old encoding\n\t\tbuf := new(bytes.Buffer)\n\t\tencoding.NewEncoder(buf).EncodeAll(\n\t\t\tb.ParentID,\n\t\t\tb.Nonce,\n\t\t\tb.Timestamp,\n\t\t\tb.MinerPayouts,\n\t\t\tb.Transactions,\n\t\t)\n\t\tw = sanityCheckWriter{w, buf}\n\t}\n\n\te := encoding.NewEncoder(w)\n\te.Write(b.ParentID[:])\n\te.Write(b.Nonce[:])\n\te.WriteUint64(uint64(b.Timestamp))\n\te.WriteInt(len(b.MinerPayouts))\n\tfor i := range b.MinerPayouts {\n\t\tb.MinerPayouts[i].MarshalSia(e)\n\t}\n\te.WriteInt(len(b.Transactions))\n\tfor i := range b.Transactions {\n\t\tif err := b.Transactions[i].MarshalSia(e); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn e.Err()\n}", "func (b *Blocks) ToJSON() []byte {\n\tdata, err := json.Marshal(b)\n\tif err != nil {\n\t\tlog.Printf(\"[!] Failed to encode block data to JSON : %s\\n\", err.Error())\n\t\treturn nil\n\t}\n\n\treturn data\n}", "func (m *ExternalConnection) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.Entity.Serialize(writer)\n if err != nil {\n return err\n }\n {\n err = writer.WriteObjectValue(\"configuration\", m.GetConfiguration())\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"description\", m.GetDescription())\n if err != nil {\n return err\n }\n }\n if m.GetGroups() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetGroups())\n err = writer.WriteCollectionOfObjectValues(\"groups\", cast)\n if err != nil {\n return err\n }\n }\n if m.GetItems() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetItems())\n err = writer.WriteCollectionOfObjectValues(\"items\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteStringValue(\"name\", m.GetName())\n if err != nil {\n return err\n }\n }\n if m.GetOperations() != nil {\n cast := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.CollectionCast[i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable](m.GetOperations())\n err = writer.WriteCollectionOfObjectValues(\"operations\", cast)\n if err != nil {\n return err\n }\n }\n {\n err = writer.WriteObjectValue(\"schema\", m.GetSchema())\n if err != nil {\n return err\n }\n }\n return nil\n}", "func (msg *Block) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) (e error) {\n\tif e = writeBlockHeader(w, pver, &msg.Header); E.Chk(e) {\n\t\treturn\n\t}\n\tif e = WriteVarInt(w, pver, uint64(len(msg.Transactions))); E.Chk(e) {\n\t\treturn\n\t}\n\tfor _, tx := range msg.Transactions {\n\t\tif e = tx.BtcEncode(w, pver, enc); E.Chk(e) {\n\t\t\treturn\n\t\t}\n\t}\n\treturn\n}", "func (s *State) Serialize() []byte {\n\treturn s.serializer.Serialize(s.structure())\n}", "func (v BlockRequest) EncodeJSON(b []byte, network []byte) []byte {\n\tb = append(b, network...)\n\tb = append(b, '\"', 'b', 'l', 'o', 'c', 'k', '_', 'i', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r', '\"', ':')\n\tb = v.BlockIdentifier.EncodeJSON(b)\n\treturn append(b, \"}\"...)\n}", "func (pt MDTurbo) Serialize() ([PartitionBlkLen]uint8, error) {\n\treturn Serialize(pt)\n}", "func ExportBlock(conn *dbus.Conn, path dbus.ObjectPath, v Blocker) error {\n\treturn conn.ExportSubtreeMethodTable(map[string]interface{}{\n\t\t\"AddConfigurationItem\": v.AddConfigurationItem,\n\t\t\"RemoveConfigurationItem\": v.RemoveConfigurationItem,\n\t\t\"UpdateConfigurationItem\": v.UpdateConfigurationItem,\n\t\t\"GetSecretConfiguration\": v.GetSecretConfiguration,\n\t\t\"Format\": v.Format,\n\t\t\"OpenForBackup\": v.OpenForBackup,\n\t\t\"OpenForRestore\": v.OpenForRestore,\n\t\t\"OpenForBenchmark\": v.OpenForBenchmark,\n\t\t\"OpenDevice\": v.OpenDevice,\n\t\t\"Rescan\": v.Rescan,\n\t}, path, InterfaceBlock)\n}", "func (broadcast *Broadcast) encodeForEncryption(w io.Writer) error {\n\terr := broadcast.bm.encodeBroadcast(w)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsigLength := uint64(len(broadcast.sig))\n\tif err = bmutil.WriteVarInt(w, sigLength); err != nil {\n\t\treturn err\n\t}\n\tif _, err = w.Write(broadcast.sig); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (b *blockEnc) encode(org []byte, raw, rawAllLits bool) error {\n\tif len(b.sequences) == 0 {\n\t\treturn b.encodeLits(b.literals, rawAllLits)\n\t}\n\t// We want some difference to at least account for the headers.\n\tsaved := b.size - len(b.literals) - (b.size >> 5)\n\tif saved < 16 {\n\t\tif org == nil {\n\t\t\treturn errIncompressible\n\t\t}\n\t\tb.popOffsets()\n\t\treturn b.encodeLits(org, rawAllLits)\n\t}\n\n\tvar bh blockHeader\n\tvar lh literalsHeader\n\tbh.setLast(b.last)\n\tbh.setType(blockTypeCompressed)\n\t// Store offset of the block header. Needed when we know the size.\n\tbhOffset := len(b.output)\n\tb.output = bh.appendTo(b.output)\n\n\tvar (\n\t\tout []byte\n\t\treUsed, single bool\n\t\terr error\n\t)\n\tif b.dictLitEnc != nil {\n\t\tb.litEnc.TransferCTable(b.dictLitEnc)\n\t\tb.litEnc.Reuse = huff0.ReusePolicyAllow\n\t\tb.dictLitEnc = nil\n\t}\n\tif len(b.literals) >= 1024 && !raw {\n\t\t// Use 4 Streams.\n\t\tout, reUsed, err = huff0.Compress4X(b.literals, b.litEnc)\n\t} else if len(b.literals) > 32 && !raw {\n\t\t// Use 1 stream\n\t\tsingle = true\n\t\tout, reUsed, err = huff0.Compress1X(b.literals, b.litEnc)\n\t} else {\n\t\terr = huff0.ErrIncompressible\n\t}\n\n\tswitch err {\n\tcase huff0.ErrIncompressible:\n\t\tlh.setType(literalsBlockRaw)\n\t\tlh.setSize(len(b.literals))\n\t\tb.output = lh.appendTo(b.output)\n\t\tb.output = append(b.output, b.literals...)\n\t\tif debugEncoder {\n\t\t\tprintln(\"Adding literals RAW, length\", len(b.literals))\n\t\t}\n\tcase huff0.ErrUseRLE:\n\t\tlh.setType(literalsBlockRLE)\n\t\tlh.setSize(len(b.literals))\n\t\tb.output = lh.appendTo(b.output)\n\t\tb.output = append(b.output, b.literals[0])\n\t\tif debugEncoder {\n\t\t\tprintln(\"Adding literals RLE\")\n\t\t}\n\tcase nil:\n\t\t// Compressed litLen...\n\t\tif reUsed {\n\t\t\tif debugEncoder {\n\t\t\t\tprintln(\"reused tree\")\n\t\t\t}\n\t\t\tlh.setType(literalsBlockTreeless)\n\t\t} else {\n\t\t\tif debugEncoder {\n\t\t\t\tprintln(\"new tree, size:\", len(b.litEnc.OutTable))\n\t\t\t}\n\t\t\tlh.setType(literalsBlockCompressed)\n\t\t\tif debugEncoder {\n\t\t\t\t_, _, err := huff0.ReadTable(out, nil)\n\t\t\t\tif err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlh.setSizes(len(out), len(b.literals), single)\n\t\tif debugEncoder {\n\t\t\tprintf(\"Compressed %d literals to %d bytes\", len(b.literals), len(out))\n\t\t\tprintln(\"Adding literal header:\", lh)\n\t\t}\n\t\tb.output = lh.appendTo(b.output)\n\t\tb.output = append(b.output, out...)\n\t\tb.litEnc.Reuse = huff0.ReusePolicyAllow\n\t\tif debugEncoder {\n\t\t\tprintln(\"Adding literals compressed\")\n\t\t}\n\tdefault:\n\t\tif debugEncoder {\n\t\t\tprintln(\"Adding literals ERROR:\", err)\n\t\t}\n\t\treturn err\n\t}\n\t// Sequence compression\n\n\t// Write the number of sequences\n\tswitch {\n\tcase len(b.sequences) < 128:\n\t\tb.output = append(b.output, uint8(len(b.sequences)))\n\tcase len(b.sequences) < 0x7f00: // TODO: this could be wrong\n\t\tn := len(b.sequences)\n\t\tb.output = append(b.output, 128+uint8(n>>8), uint8(n))\n\tdefault:\n\t\tn := len(b.sequences) - 0x7f00\n\t\tb.output = append(b.output, 255, uint8(n), uint8(n>>8))\n\t}\n\tif debugEncoder {\n\t\tprintln(\"Encoding\", len(b.sequences), \"sequences\")\n\t}\n\tb.genCodes()\n\tllEnc := b.coders.llEnc\n\tofEnc := b.coders.ofEnc\n\tmlEnc := b.coders.mlEnc\n\terr = llEnc.normalizeCount(len(b.sequences))\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = ofEnc.normalizeCount(len(b.sequences))\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = mlEnc.normalizeCount(len(b.sequences))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Choose the best compression mode for each type.\n\t// Will evaluate the new vs predefined and previous.\n\tchooseComp := func(cur, prev, preDef *fseEncoder) (*fseEncoder, seqCompMode) {\n\t\t// See if predefined/previous is better\n\t\thist := cur.count[:cur.symbolLen]\n\t\tnSize := cur.approxSize(hist) + cur.maxHeaderSize()\n\t\tpredefSize := preDef.approxSize(hist)\n\t\tprevSize := prev.approxSize(hist)\n\n\t\t// Add a small penalty for new encoders.\n\t\t// Don't bother with extremely small (<2 byte gains).\n\t\tnSize = nSize + (nSize+2*8*16)>>4\n\t\tswitch {\n\t\tcase predefSize <= prevSize && predefSize <= nSize || forcePreDef:\n\t\t\tif debugEncoder {\n\t\t\t\tprintln(\"Using predefined\", predefSize>>3, \"<=\", nSize>>3)\n\t\t\t}\n\t\t\treturn preDef, compModePredefined\n\t\tcase prevSize <= nSize:\n\t\t\tif debugEncoder {\n\t\t\t\tprintln(\"Using previous\", prevSize>>3, \"<=\", nSize>>3)\n\t\t\t}\n\t\t\treturn prev, compModeRepeat\n\t\tdefault:\n\t\t\tif debugEncoder {\n\t\t\t\tprintln(\"Using new, predef\", predefSize>>3, \". previous:\", prevSize>>3, \">\", nSize>>3, \"header max:\", cur.maxHeaderSize()>>3, \"bytes\")\n\t\t\t\tprintln(\"tl:\", cur.actualTableLog, \"symbolLen:\", cur.symbolLen, \"norm:\", cur.norm[:cur.symbolLen], \"hist\", cur.count[:cur.symbolLen])\n\t\t\t}\n\t\t\treturn cur, compModeFSE\n\t\t}\n\t}\n\n\t// Write compression mode\n\tvar mode uint8\n\tif llEnc.useRLE {\n\t\tmode |= uint8(compModeRLE) << 6\n\t\tllEnc.setRLE(b.sequences[0].llCode)\n\t\tif debugEncoder {\n\t\t\tprintln(\"llEnc.useRLE\")\n\t\t}\n\t} else {\n\t\tvar m seqCompMode\n\t\tllEnc, m = chooseComp(llEnc, b.coders.llPrev, &fsePredefEnc[tableLiteralLengths])\n\t\tmode |= uint8(m) << 6\n\t}\n\tif ofEnc.useRLE {\n\t\tmode |= uint8(compModeRLE) << 4\n\t\tofEnc.setRLE(b.sequences[0].ofCode)\n\t\tif debugEncoder {\n\t\t\tprintln(\"ofEnc.useRLE\")\n\t\t}\n\t} else {\n\t\tvar m seqCompMode\n\t\tofEnc, m = chooseComp(ofEnc, b.coders.ofPrev, &fsePredefEnc[tableOffsets])\n\t\tmode |= uint8(m) << 4\n\t}\n\n\tif mlEnc.useRLE {\n\t\tmode |= uint8(compModeRLE) << 2\n\t\tmlEnc.setRLE(b.sequences[0].mlCode)\n\t\tif debugEncoder {\n\t\t\tprintln(\"mlEnc.useRLE, code: \", b.sequences[0].mlCode, \"value\", b.sequences[0].matchLen)\n\t\t}\n\t} else {\n\t\tvar m seqCompMode\n\t\tmlEnc, m = chooseComp(mlEnc, b.coders.mlPrev, &fsePredefEnc[tableMatchLengths])\n\t\tmode |= uint8(m) << 2\n\t}\n\tb.output = append(b.output, mode)\n\tif debugEncoder {\n\t\tprintf(\"Compression modes: 0b%b\", mode)\n\t}\n\tb.output, err = llEnc.writeCount(b.output)\n\tif err != nil {\n\t\treturn err\n\t}\n\tstart := len(b.output)\n\tb.output, err = ofEnc.writeCount(b.output)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif false {\n\t\tprintln(\"block:\", b.output[start:], \"tablelog\", ofEnc.actualTableLog, \"maxcount:\", ofEnc.maxCount)\n\t\tfmt.Printf(\"selected TableLog: %d, Symbol length: %d\\n\", ofEnc.actualTableLog, ofEnc.symbolLen)\n\t\tfor i, v := range ofEnc.norm[:ofEnc.symbolLen] {\n\t\t\tfmt.Printf(\"%3d: %5d -> %4d \\n\", i, ofEnc.count[i], v)\n\t\t}\n\t}\n\tb.output, err = mlEnc.writeCount(b.output)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Maybe in block?\n\twr := &b.wr\n\twr.reset(b.output)\n\n\tvar ll, of, ml cState\n\n\t// Current sequence\n\tseq := len(b.sequences) - 1\n\ts := b.sequences[seq]\n\tllEnc.setBits(llBitsTable[:])\n\tmlEnc.setBits(mlBitsTable[:])\n\tofEnc.setBits(nil)\n\n\tllTT, ofTT, mlTT := llEnc.ct.symbolTT[:256], ofEnc.ct.symbolTT[:256], mlEnc.ct.symbolTT[:256]\n\n\t// We have 3 bounds checks here (and in the loop).\n\t// Since we are iterating backwards it is kinda hard to avoid.\n\tllB, ofB, mlB := llTT[s.llCode], ofTT[s.ofCode], mlTT[s.mlCode]\n\tll.init(wr, &llEnc.ct, llB)\n\tof.init(wr, &ofEnc.ct, ofB)\n\twr.flush32()\n\tml.init(wr, &mlEnc.ct, mlB)\n\n\t// Each of these lookups also generates a bounds check.\n\twr.addBits32NC(s.litLen, llB.outBits)\n\twr.addBits32NC(s.matchLen, mlB.outBits)\n\twr.flush32()\n\twr.addBits32NC(s.offset, ofB.outBits)\n\tif debugSequences {\n\t\tprintln(\"Encoded seq\", seq, s, \"codes:\", s.llCode, s.mlCode, s.ofCode, \"states:\", ll.state, ml.state, of.state, \"bits:\", llB, mlB, ofB)\n\t}\n\tseq--\n\t// Store sequences in reverse...\n\tfor seq >= 0 {\n\t\ts = b.sequences[seq]\n\n\t\tofB := ofTT[s.ofCode]\n\t\twr.flush32() // tablelog max is below 8 for each, so it will fill max 24 bits.\n\t\t//of.encode(ofB)\n\t\tnbBitsOut := (uint32(of.state) + ofB.deltaNbBits) >> 16\n\t\tdstState := int32(of.state>>(nbBitsOut&15)) + int32(ofB.deltaFindState)\n\t\twr.addBits16NC(of.state, uint8(nbBitsOut))\n\t\tof.state = of.stateTable[dstState]\n\n\t\t// Accumulate extra bits.\n\t\toutBits := ofB.outBits & 31\n\t\textraBits := uint64(s.offset & bitMask32[outBits])\n\t\textraBitsN := outBits\n\n\t\tmlB := mlTT[s.mlCode]\n\t\t//ml.encode(mlB)\n\t\tnbBitsOut = (uint32(ml.state) + mlB.deltaNbBits) >> 16\n\t\tdstState = int32(ml.state>>(nbBitsOut&15)) + int32(mlB.deltaFindState)\n\t\twr.addBits16NC(ml.state, uint8(nbBitsOut))\n\t\tml.state = ml.stateTable[dstState]\n\n\t\toutBits = mlB.outBits & 31\n\t\textraBits = extraBits<<outBits | uint64(s.matchLen&bitMask32[outBits])\n\t\textraBitsN += outBits\n\n\t\tllB := llTT[s.llCode]\n\t\t//ll.encode(llB)\n\t\tnbBitsOut = (uint32(ll.state) + llB.deltaNbBits) >> 16\n\t\tdstState = int32(ll.state>>(nbBitsOut&15)) + int32(llB.deltaFindState)\n\t\twr.addBits16NC(ll.state, uint8(nbBitsOut))\n\t\tll.state = ll.stateTable[dstState]\n\n\t\toutBits = llB.outBits & 31\n\t\textraBits = extraBits<<outBits | uint64(s.litLen&bitMask32[outBits])\n\t\textraBitsN += outBits\n\n\t\twr.flush32()\n\t\twr.addBits64NC(extraBits, extraBitsN)\n\n\t\tif debugSequences {\n\t\t\tprintln(\"Encoded seq\", seq, s)\n\t\t}\n\n\t\tseq--\n\t}\n\tml.flush(mlEnc.actualTableLog)\n\tof.flush(ofEnc.actualTableLog)\n\tll.flush(llEnc.actualTableLog)\n\terr = wr.close()\n\tif err != nil {\n\t\treturn err\n\t}\n\tb.output = wr.out\n\n\tif len(b.output)-3-bhOffset >= b.size {\n\t\t// Maybe even add a bigger margin.\n\t\tb.litEnc.Reuse = huff0.ReusePolicyNone\n\t\treturn errIncompressible\n\t}\n\n\t// Size is output minus block header.\n\tbh.setSize(uint32(len(b.output)-bhOffset) - 3)\n\tif debugEncoder {\n\t\tprintln(\"Rewriting block header\", bh)\n\t}\n\t_ = bh.appendTo(b.output[bhOffset:bhOffset])\n\tb.coders.setPrev(llEnc, mlEnc, ofEnc)\n\treturn nil\n}", "func (b *Block) Wire() ([]byte, error) {\n\tif len(b.wire) == 0 {\n\t\t// There is still unnecessary copying, but better than the original one.\n\t\tl := uint64(0)\n\t\tif len(b.subelements) > 0 {\n\t\t\tfor _, elem := range b.subelements {\n\t\t\t\telemWire, err := elem.Wire()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn []byte{}, err\n\t\t\t\t}\n\t\t\t\tl += uint64(len(elemWire))\n\t\t\t}\n\t\t} else {\n\t\t\tl = uint64(len(b.value))\n\t\t}\n\n\t\t// Encode type, length, and value into wire\n\t\twireSz := varSize(uint64(b.tlvType)) + l + varSize(l)\n\t\tb.wire = make([]byte, 0, wireSz)\n\t\tencodedType := EncodeVarNum(uint64(b.tlvType))\n\t\tb.wire = append(b.wire, encodedType...)\n\t\tencodedLength := EncodeVarNum(l)\n\t\tb.wire = append(b.wire, encodedLength...)\n\n\t\tif len(b.subelements) > 0 {\n\t\t\t// Wire encode subelements\n\t\t\tfor _, elem := range b.subelements {\n\t\t\t\tb.wire = append(b.wire, elem.wire...)\n\t\t\t}\n\t\t} else {\n\t\t\tb.wire = append(b.wire, b.value...)\n\t\t}\n\t}\n\n\treturn b.wire, nil\n}", "func (m *EmbeddedSIMActivationCode) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n {\n err := writer.WriteStringValue(\"integratedCircuitCardIdentifier\", m.GetIntegratedCircuitCardIdentifier())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"matchingIdentifier\", m.GetMatchingIdentifier())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"@odata.type\", m.GetOdataType())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteStringValue(\"smdpPlusServerAddress\", m.GetSmdpPlusServerAddress())\n if err != nil {\n return err\n }\n }\n {\n err := writer.WriteAdditionalData(m.GetAdditionalData())\n if err != nil {\n return err\n }\n }\n return nil\n}", "func encodeBlockBetter(dst, src []byte) (d int) {\n\treturn encodeBlockBetterGo(dst, src)\n}", "func (self *Encoder) Encode(v interface{}) ([]byte, error) {\n if self.indent != \"\" || self.prefix != \"\" { \n return EncodeIndented(v, self.prefix, self.indent, self.Opts)\n }\n return Encode(v, self.Opts)\n}", "func (f Frame) Encode(w io.Writer, timestamp time.Time, compress bool) error {\n\tf.CorrectTimestamps(timestamp)\n\tf.Length = f.correctLength()\n\tf.Count = uint16(len(f.Blocks))\n\tf.Reserved1 = 1\n\n\tvar compressedBlockData []byte\n\tif compress {\n\t\tvar err error\n\t\tcompressedBlockData, err = f.compressBlocks()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tf.Compression = 1\n\t\tf.Length = uint32(40 + len(compressedBlockData))\n\t} else {\n\t\tf.Compression = 0\n\t}\n\n\tbuf := make([]byte, 40)\n\tcopy(buf[0:16], f.Preamble[:])\n\ttime := uint64(f.Time.UnixNano() / 1000000)\n\tbinary.LittleEndian.PutUint64(buf[16:24], time)\n\tbinary.LittleEndian.PutUint32(buf[24:28], f.Length)\n\tbinary.LittleEndian.PutUint16(buf[28:30], f.ConnectionType)\n\tbinary.LittleEndian.PutUint16(buf[30:32], f.Count)\n\tbuf[32] = f.Reserved1\n\tbuf[33] = f.Compression\n\tbinary.LittleEndian.PutUint16(buf[34:36], f.Reserved2)\n\tbinary.LittleEndian.PutUint32(buf[36:40], f.DecompressedLength)\n\n\t_, err := w.Write(buf)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif compress {\n\t\t_, err := w.Write(compressedBlockData)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tfor _, b := range f.Blocks {\n\t\t\terr := b.Encode(w)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\treturn nil\n}", "func TestBlockHeaderSerialize(t *testing.T) {\n\tnonce := uint64(123123) // 0x01e0f3\n\n\t// baseBlockHdr is used in the various tests as a baseline BlockHeader.\n\tbits := uint32(0x1d00ffff)\n\tbaseBlockHdr := &BlockHeader{\n\t\tVersion: 1,\n\t\tParentHashes: []*daghash.Hash{mainnetGenesisHash, simnetGenesisHash},\n\t\tHashMerkleRoot: mainnetGenesisMerkleRoot,\n\t\tAcceptedIDMerkleRoot: exampleAcceptedIDMerkleRoot,\n\t\tUTXOCommitment: exampleUTXOCommitment,\n\t\tTimestamp: mstime.UnixMilliseconds(0x17315ed0f99),\n\t\tBits: bits,\n\t\tNonce: nonce,\n\t}\n\n\t// baseBlockHdrEncoded is the domainmessage encoded bytes of baseBlockHdr.\n\tbaseBlockHdrEncoded := []byte{\n\t\t0x01, 0x00, 0x00, 0x00, // Version 1\n\t\t0x02, // NumParentBlocks\n\t\t0xdc, 0x5f, 0x5b, 0x5b, 0x1d, 0xc2, 0xa7, 0x25, // mainnetGenesisHash\n\t\t0x49, 0xd5, 0x1d, 0x4d, 0xee, 0xd7, 0xa4, 0x8b,\n\t\t0xaf, 0xd3, 0x14, 0x4b, 0x56, 0x78, 0x98, 0xb1,\n\t\t0x8c, 0xfd, 0x9f, 0x69, 0xdd, 0xcf, 0xbb, 0x63,\n\t\t0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, // simnetGenesisHash\n\t\t0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,\n\t\t0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,\n\t\t0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,\n\t\t0x4a, 0x5e, 0x1e, 0x4b, 0xaa, 0xb8, 0x9f, 0x3a, // HashMerkleRoot\n\t\t0x32, 0x51, 0x8a, 0x88, 0xc3, 0x1b, 0xc8, 0x7f,\n\t\t0x61, 0x8f, 0x76, 0x67, 0x3e, 0x2c, 0xc7, 0x7a,\n\t\t0xb2, 0x12, 0x7b, 0x7a, 0xfd, 0xed, 0xa3, 0x3b,\n\t\t0x09, 0x3B, 0xC7, 0xE3, 0x67, 0x11, 0x7B, 0x3C, // AcceptedIDMerkleRoot\n\t\t0x30, 0xC1, 0xF8, 0xFD, 0xD0, 0xD9, 0x72, 0x87,\n\t\t0x7F, 0x16, 0xC5, 0x96, 0x2E, 0x8B, 0xD9, 0x63,\n\t\t0x65, 0x9C, 0x79, 0x3C, 0xE3, 0x70, 0xD9, 0x5F,\n\t\t0x10, 0x3B, 0xC7, 0xE3, 0x67, 0x11, 0x7B, 0x3C, // UTXOCommitment\n\t\t0x30, 0xC1, 0xF8, 0xFD, 0xD0, 0xD9, 0x72, 0x87,\n\t\t0x7F, 0x16, 0xC5, 0x96, 0x2E, 0x8B, 0xD9, 0x63,\n\t\t0x65, 0x9C, 0x79, 0x3C, 0xE3, 0x70, 0xD9, 0x5F,\n\t\t0x99, 0x0f, 0xed, 0x15, 0x73, 0x01, 0x00, 0x00, // Timestamp\n\t\t0xff, 0xff, 0x00, 0x1d, // Bits\n\t\t0xf3, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // Fake Nonce. TODO: (Ori) Replace to a real nonce\n\t}\n\n\ttests := []struct {\n\t\tin *BlockHeader // Data to encode\n\t\tout *BlockHeader // Expected decoded data\n\t\tbuf []byte // Serialized data\n\t}{\n\t\t{\n\t\t\tbaseBlockHdr,\n\t\t\tbaseBlockHdr,\n\t\t\tbaseBlockHdrEncoded,\n\t\t},\n\t}\n\n\tt.Logf(\"Running %d tests\", len(tests))\n\tfor i, test := range tests {\n\t\t// Serialize the block header.\n\t\tvar buf bytes.Buffer\n\t\terr := test.in.Serialize(&buf)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Serialize #%d error %v\", i, err)\n\t\t\tcontinue\n\t\t}\n\t\tif !bytes.Equal(buf.Bytes(), test.buf) {\n\t\t\tt.Errorf(\"Serialize #%d\\n got: %s want: %s\", i,\n\t\t\t\tspew.Sdump(buf.Bytes()), spew.Sdump(test.buf))\n\t\t\tcontinue\n\t\t}\n\n\t\t// Deserialize the block header.\n\t\tvar bh BlockHeader\n\t\trbuf := bytes.NewReader(test.buf)\n\t\terr = bh.Deserialize(rbuf)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Deserialize #%d error %v\", i, err)\n\t\t\tcontinue\n\t\t}\n\t\tif !reflect.DeepEqual(&bh, test.out) {\n\t\t\tt.Errorf(\"Deserialize #%d\\n got: %s want: %s\", i,\n\t\t\t\tspew.Sdump(&bh), spew.Sdump(test.out))\n\t\t\tcontinue\n\t\t}\n\t}\n}", "func (this *Codec) serialize(root *TreeNode) string {\n\tthis.s(root)\n\treturn \"[\" + strings.Join(this.data, \",\") + \"]\"\n}", "func (*nopSerializer) Marshal(Message) ([]byte, error) { return nil, nil }", "func (blockChain *BlockChain) MarshalJSON() ([]byte, error) {\n\tblocks := make([]Block, 0)\n\tfor _, v := range blockChain.Chain {\n\t\tblocks = append(blocks, v...)\n\t}\n\treturn json.Marshal(blocks)\n}", "func (b *Buffer) Serialize() error {\n\tif !b.Settings[\"savecursor\"].(bool) && !b.Settings[\"saveundo\"].(bool) {\n\t\treturn nil\n\t}\n\tif b.Path == \"\" {\n\t\treturn nil\n\t}\n\n\tname := filepath.Join(config.ConfigDir, \"buffers\", util.EscapePath(b.AbsPath))\n\n\treturn overwriteFile(name, encoding.Nop, func(file io.Writer) error {\n\t\terr := gob.NewEncoder(file).Encode(SerializedBuffer{\n\t\t\tb.EventHandler,\n\t\t\tb.GetActiveCursor().Loc,\n\t\t\tb.ModTime,\n\t\t})\n\t\treturn err\n\t}, false)\n}", "func EncodeBlock(data []byte) ([]byte, error) {\n\tout := []byte{}\n\tbuf := bytes.NewBuffer(data)\n\tinputBlock := make([]byte, maxBytesPerLine)\n\tfor {\n\t\tn, err := buf.Read(inputBlock)\n\t\tif n == 0 && err != nil {\n\t\t\tif err != io.EOF {\n\t\t\t\treturn out, err\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t\tout = append(out, byte(n+32)) // length\n\t\tout = append(out, encoding.EncodeToString(inputBlock[:n])...)\n\t\tout = append(out, '\\n')\n\t}\n\treturn out, nil\n}", "func (this *Codec) serialize(root *TreeNode) string {\n\treturn dfsSerial(root, \"\")\n}", "func (r *SbProxy) Serialize() rotator.Object {\n\tr.RLock()\n\tdefer r.RUnlock()\n\treturn r.serialize()\n}", "func writeBlockHeader(w io.Writer, bh *BlockHeader) error {\n\treturn bh.Serialize(w)\n}", "func (b *Blockchain) ExportToJSON(path string) error {\n\tf, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\tbuf := bytes.NewBuffer([]byte{})\n\t_, err = buf.WriteString(\"[\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tm := jsonpb.Marshaler{}\n\titer := &BlockchainIterator{}\n\terr = iter.InitIter(b)\n\tif err != nil {\n\t\treturn err\n\t}\n\tv, err := iter.Value()\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = m.Marshal(buf, v)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor iter.Prev() {\n\t\t_, err = buf.WriteString(\",\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tv, err := iter.Value()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = m.Marshal(buf, v)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\t_, err = buf.WriteString(\"]\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = f.Write(buf.Bytes())\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (s *BlockStore) Write(b *block.Block) error {\n\terr := os.MkdirAll(s.RootDir, 0666)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfilename := s.filename(b.Hash)\n\tf, err := os.Create(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tdata, err := json.Marshal(b)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_, err = f.Write(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (n ByteArray) Serialize() *bytes.Buffer {\n\tbuffer := bytes.NewBuffer([]byte{})\n\twriteByteArray([]byte(n), buffer)\n\treturn buffer\n}", "func (m *ImpactedMailboxAsset) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter)(error) {\n err := m.ImpactedAsset.Serialize(writer)\n if err != nil {\n return err\n }\n if m.GetIdentifier() != nil {\n cast := (*m.GetIdentifier()).String()\n err = writer.WriteStringValue(\"identifier\", &cast)\n if err != nil {\n return err\n }\n }\n return nil\n}", "func saveBlockRaw(w kv.Putter, id polo.Bytes32, raw block.Raw) error {\n\treturn w.Put(append(blockPrefix, id[:]...), raw)\n}", "func Encode(node ipld.Node, w io.Writer) error {\n\t// 1KiB can be allocated on the stack, and covers most small nodes\n\t// without having to grow the buffer and cause allocations.\n\tenc := make([]byte, 0, 1024)\n\n\tenc, err := AppendEncode(enc, node)\n\tif err != nil {\n\t\treturn err\n\t}\n\t_, err = w.Write(enc)\n\treturn err\n}", "func (b *Block) ToWire() *wire.Block {\n\tif b == nil {\n\t\treturn nil\n\t}\n\treturn &wire.Block{\n\t\tIndex: b.Index,\n\t\tEvents: b.Events.ToWire(),\n\t}\n}", "func (m *TokenPool) Encode() []byte {\n\tblob, _ := json.Marshal(m)\n\treturn blob\n}", "func (bc *Blockchain) WriteChain() {\n\tjsonChain, err := json.Marshal(bc.Chain)\n\tif err != nil{\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\terr = ioutil.WriteFile(JSONCHAIN, jsonChain, 0644)\n\tif err != nil{\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n}", "func (s *SystemMetrics) Encode(block interface{}) string {\n\tswitch node := block.(type) {\n\tcase DiskStats:\n\t\treturn fmt.Sprintf(\"%d|%d\", node.DiskIO, node.Cached)\n\tcase MemoryStats:\n\t\treturn fmt.Sprintf(\"%d|%d|%d|%f|%d\",\n\t\t\tnode.Total, node.Available, node.Used, node.UsedPercent, node.Free,\n\t\t)\n\tcase NetworkStats:\n\t\treturn fmt.Sprintf(\"%d|%d|%d|%d|%d|%d\",\n\t\t\tnode.PtcpIncoming, node.PtcpOutgoing, node.StcpIncoming, node.StcpOutgoing, node.PudpIncoming, node.PudpOutgoing,\n\t\t)\n\tcase string:\n\t\treturn node\n\t}\n\n\tdata, ok := block.(string)\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"Invalid block type: %v (block)\", block))\n\t}\n\n\treturn data\n}", "func (d *LockStakeData) Encode() ([]byte, error) {\n\treturn rlp.EncodeToBytes(d)\n}", "func (u *UndoBlock) SerializeSize() int {\n\t// Size of u.numAdds + len(u.positions) + each position takes up 8 bytes\n\tsize := 4 + 8 + (len(u.positions) * 8)\n\n\t// Size of len(u.hashes) + each hash takes up 32 bytes\n\tsize += 8 + (len(u.hashes) * 32)\n\n\treturn size\n}", "func (p *PublicKey) Serialize() []byte {\n\treturn p.pk().SerializeCompressed()\n}" ]
[ "0.7462726", "0.72769517", "0.72016114", "0.71894073", "0.7182576", "0.7182576", "0.7104357", "0.70748967", "0.70703816", "0.7004063", "0.69893056", "0.6981453", "0.68361217", "0.6798621", "0.6779572", "0.66548055", "0.66274667", "0.65355444", "0.65316427", "0.65251213", "0.64794123", "0.64787924", "0.64785874", "0.6422555", "0.6396715", "0.6392448", "0.6392448", "0.6391725", "0.63779336", "0.63131946", "0.60908735", "0.60719615", "0.60615474", "0.59460133", "0.5913215", "0.57922214", "0.57598186", "0.5756908", "0.5727976", "0.5701919", "0.5677448", "0.56740373", "0.56673235", "0.5612416", "0.5611967", "0.5584415", "0.5579136", "0.556682", "0.551433", "0.55133307", "0.5512466", "0.54785347", "0.5467697", "0.5443938", "0.5415627", "0.54142445", "0.54063106", "0.54009503", "0.5395676", "0.53870314", "0.53737915", "0.5367634", "0.53571105", "0.53390545", "0.53175", "0.53105503", "0.53066725", "0.5300764", "0.530027", "0.5297564", "0.5296052", "0.52932334", "0.5280954", "0.5273007", "0.5269678", "0.5267957", "0.526596", "0.52614105", "0.52600974", "0.52597344", "0.5256854", "0.52511567", "0.5247529", "0.52453446", "0.5237678", "0.5237357", "0.52311105", "0.5227924", "0.52131915", "0.52115655", "0.5208222", "0.5195136", "0.51946265", "0.5190831", "0.5189998", "0.5181761", "0.51786536", "0.5162683", "0.51539224", "0.51537895" ]
0.7117319
6
Deserialize deserializes bytes to block
func Deserialize(data []byte) *Block { var block Block decoder := gob.NewDecoder(bytes.NewReader(data)) err := decoder.Decode(&block) if err != nil { panic(err) } return &block }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Deserialize(buffer []byte) *block {\n\tvar b block\n\tdecoder := gob.NewDecoder(bytes.NewReader(buffer)) // convert []byte to io.Reader\n\terr := decoder.Decode(&b) // here b is the dest\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\treturn &b\n}", "func Deserialize(data []byte) *Block {\n\tvar block Block\n\tdecoder := gob.NewDecoder(bytes.NewReader(data))\n\n\terr := decoder.Decode(&block)\n\n\tHandle(err)\n\n\treturn &block\n\n}", "func Deserialize(data []byte) *Block {\n\tvar block Block\n\n\tdecoder := gob.NewDecoder(bytes.NewReader(data))\n\n\terr := decoder.Decode(&block)\n\n\tHandle(err)\n\n\treturn &block\n}", "func Deserialize(data []byte) *Block {\n\tvar block Block\n\n\tdecoder := gob.NewDecoder(bytes.NewReader(data))\n\n\terr := decoder.Decode(&block)\n\n\tHandle(err)\n\n\treturn &block\n}", "func (bm *BlockMeta) Deserialize(buf []byte) error {\n\tepochMetapb := &blockmetapb.BlockMeta{}\n\tif err := proto.Unmarshal(buf, epochMetapb); err != nil {\n\t\treturn errors.Wrap(err, \"failed to unmarshal blocklist\")\n\t}\n\treturn bm.LoadProto(epochMetapb)\n}", "func (b *MicroBlock) Deserialize(r io.Reader) error {\n return readBlock(r, 0, b)\n}", "func (msg *Block) Deserialize(r io.Reader) (e error) {\n\t// At the current time, there is no difference between the wire encoding at\n\t// protocol version 0 and the stable long-term storage format. As a result, make\n\t// use of BtcDecode. Passing an encoding type of WitnessEncoding to BtcEncode\n\t// for the MessageEncoding parameter indicates that the transactions within the\n\t// block are expected to be serialized according to the new serialization\n\t// structure defined in BIP0141.\n\treturn msg.BtcDecode(r, 0, BaseEncoding)\n}", "func (h *BlockHeader) Deserialize(r io.Reader) error { //TODO parse blockheader data\n\t// At the current time, there is no difference between the wire encoding\n\t// at protocol version 0 and the stable long-term storage format. As\n\t// a result, make use of readBlockHeader.\n\treturn nil\n}", "func DeserializeBlock(encodedBlock []byte) *Block {\n\tvar block Block\n\n\tdecoder := gob.NewDecoder(bytes.NewReader(encodedBlock))\n\terr := decoder.Decode(&block)\n\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\treturn &block\n}", "func DeserializeBlock(d []byte) *Block {\n\tvar block Block\n\n\tdecoder := gob.NewDecoder(bytes.NewReader(d))\n\terr := decoder.Decode(&block)\n\n\treturn &block\n}", "func DeserializeBlock(d []byte) *Block {\n\n\tblock := &Block{}\n\n\terr := proto.Unmarshal(d, block)\n\tif err != nil {\n\t\tlog.Println(\"block-deserialize: protobuf decoding error: \", err)\n\t}\n\n\treturn block\n\n}", "func DeserializeBlock(d []byte) *Block {\n\tvar block Block\n\tdecoder := gob.NewDecoder(bytes.NewReader(d))\n\tdecoder.Decode(&block)\n\treturn &block\n}", "func DeserializeBlock(d []byte) *Block {\n\tvar block Block\n\n\tdecoder := gob.NewDecoder(bytes.NewReader(d))\n\terr := decoder.Decode(&block)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\treturn &block\n}", "func DeserializeBlock(d []byte) *Block1 {\n\tvar block Block1 \n\n\tdecoder := gob.NewDecoder(bytes.NewReader(d))\n\terr := decoder.Decode(&block)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\treturn &block\n}", "func DeserializeBlock(d []byte) *Block {\n\tvar block Block\n\n\tdecoder := gob.NewDecoder(bytes.NewReader(d))\n\tdecoder.Decode(&block)\n\n\treturn &block\n}", "func (h *BlockHeader) Deserialize(r io.Reader) error {\n\t// At the current time, there is no difference between the wire encoding\n\t// at protocol version 0 and the stable long-term storage format. As\n\t// a result, make use of readBlockHeader.\n\treturn readBlockHeader(r, 0, h)\n}", "func (h *BlockHeader) Deserialize(r io.Reader) error {\n\t// At the current time, there is no difference between the wire encoding\n\t// at protocol version 0 and the stable long-term storage format. As\n\t// a result, make use of readBlockHeader.\n\treturn readBlockHeader(r, 0, h)\n}", "func DeserializeBlock(serializedBlock []byte) *Block {\n\tvar block Block\n\n\tdecoder := gob.NewDecoder(bytes.NewReader(serializedBlock))\n\tdecoder.Decode(&block)\n\n\treturn &block\n}", "func (txn *Transaction) Deserialize(gobdata utils.Gob) {\n\t// Decode the gob data into the blockheader\n\tutils.GobDecode(gobdata, txn)\n}", "func (bh *BlockHeader) Deserialize(r io.Reader) error {\n\t// At the current time, there is no difference between the protos encoding\n\t// at protocol version 0 and the stable long-term storage format. As\n\t// a result, make use of readBlockHeader.\n\tif err := serialization.ReadUint32(r, (*uint32)(unsafe.Pointer(&bh.Version))); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.ReadNBytes(r, bh.PrevBlock[:], common.HashLength); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.ReadNBytes(r, bh.MerkleRoot[:], common.HashLength); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.ReadUint64(r, (*uint64)(unsafe.Pointer(&bh.Timestamp))); err != nil {\n\t\treturn err\n\t}\n\n\tif err := serialization.ReadNBytes(r, bh.StateRoot[:], common.HashLength); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.ReadUint64(r, &bh.GasLimit); err != nil {\n\t\treturn err\n\t}\n\tif err := serialization.ReadUint64(r, &bh.GasUsed); err != nil {\n\t\treturn err\n\t}\n\n\tif err := serialization.ReadUint32(r, &bh.Round); err != nil {\n\t\treturn err\n\t}\n\n\tif err := serialization.ReadUint16(r, &bh.SlotIndex); err != nil {\n\t\treturn err\n\t}\n\n\tif err := serialization.ReadUint16(r, &bh.Weight); err != nil {\n\t\treturn err\n\t}\n\n\tif err := serialization.ReadNBytes(r, bh.PoaHash[:], common.HashLength); err != nil {\n\t\treturn err\n\t}\n\n\tif err := serialization.ReadUint32(r, (*uint32)(unsafe.Pointer(&bh.Height))); err != nil {\n\t\treturn err\n\t}\n\n\tif err := serialization.ReadNBytes(r, bh.CoinBase[:], common.AddressLength); err != nil {\n\t\treturn err\n\t}\n\n\terr := serialization.ReadNBytes(r, bh.SigData[:], HashSignLen)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (u *UndoBlock) Deserialize(r io.Reader) error {\n\terr := binary.Read(r, binary.BigEndian, &u.numAdds)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar posCount uint64\n\terr = binary.Read(r, binary.BigEndian, &posCount)\n\tif err != nil {\n\t\treturn err\n\t}\n\tu.positions = make([]uint64, posCount)\n\n\terr = binary.Read(r, binary.BigEndian, u.positions)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar hashCount uint64\n\terr = binary.Read(r, binary.BigEndian, &hashCount)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tu.hashes = make([]Hash, hashCount)\n\n\tfor i := uint64(0); i < hashCount; i++ {\n\t\tn, err := r.Read(u.hashes[i][:])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif n != 32 {\n\t\t\terr := fmt.Errorf(\"UndoBlock Deserialize supposed to read 32 bytes but read %d bytes\", n)\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (eb *EBlock) UnmarshalBinary(data []byte) error {\n\tif len(data) < EBlockMinTotalLen {\n\t\treturn fmt.Errorf(\"insufficient length\")\n\t}\n\tif len(data) > EBlockMaxTotalLen {\n\t\treturn fmt.Errorf(\"invalid length\")\n\t}\n\tif eb.ChainID == nil {\n\t\teb.ChainID = new(Bytes32)\n\t}\n\teb.ChainID = eb.ChainID\n\ti := copy(eb.ChainID[:], data[:len(eb.ChainID)])\n\teb.BodyMR = new(Bytes32)\n\ti += copy(eb.BodyMR[:], data[i:i+len(eb.BodyMR)])\n\teb.PrevKeyMR = new(Bytes32)\n\ti += copy(eb.PrevKeyMR[:], data[i:i+len(eb.PrevKeyMR)])\n\teb.PrevFullHash = new(Bytes32)\n\ti += copy(eb.PrevFullHash[:], data[i:i+len(eb.PrevFullHash)])\n\teb.Sequence = binary.BigEndian.Uint32(data[i : i+4])\n\ti += 4\n\teb.Height = binary.BigEndian.Uint32(data[i : i+4])\n\ti += 4\n\teb.ObjectCount = binary.BigEndian.Uint32(data[i : i+4])\n\ti += 4\n\tif len(data[i:]) != int(eb.ObjectCount*32) {\n\t\treturn fmt.Errorf(\"invalid length\")\n\t}\n\n\t// Parse all objects into Bytes32\n\tobjects := make([]Bytes32, eb.ObjectCount)\n\tmaxMinute := Bytes32{31: 10}\n\tvar numMins int\n\tfor oi := range objects {\n\t\tobj := &objects[len(objects)-1-oi] // Reverse object order\n\t\ti += copy(obj[:], data[i:i+len(obj)])\n\t\tif bytes.Compare(obj[:], maxMinute[:]) <= 0 {\n\t\t\tnumMins++\n\t\t}\n\t}\n\tif bytes.Compare(objects[0][:], maxMinute[:]) > 0 {\n\t\treturn fmt.Errorf(\"invalid minute marker\")\n\t}\n\n\t// Populate Entries from objects.\n\teb.Entries = make([]Entry, int(eb.ObjectCount)-numMins)\n\tei := len(eb.Entries) - 1\n\tvar ts time.Time\n\tfor _, obj := range objects {\n\t\tif bytes.Compare(obj[:], maxMinute[:]) <= 0 {\n\t\t\tts = eb.Timestamp.\n\t\t\t\tAdd(time.Duration(obj[31]) * time.Minute)\n\t\t\tcontinue\n\t\t}\n\t\te := &eb.Entries[ei]\n\t\te.Timestamp = ts\n\t\te.ChainID = eb.ChainID\n\t\te.Height = eb.Height\n\t\tobj := obj\n\t\te.Hash = &obj\n\t\tei--\n\t}\n\treturn nil\n}", "func (b *Block) FromBytes(bits []byte) error {\n\tvar rb RawBlock\n\terr := proto.Unmarshal(bits, &rb)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttxs := make([]*Tx, len(rb.Transactions))\n\tvar eg errgroup.Group\n\tfor i := range rb.Transactions {\n\t\ti := i\n\t\teg.Go(func() error {\n\t\t\ttx, err := NewTx(rb.Transactions[i].Program, rb.Transactions[i].Version, rb.Transactions[i].Runlimit)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif !tx.Finalized {\n\t\t\t\treturn txvm.ErrUnfinalized\n\t\t\t}\n\t\t\ttxs[i] = tx\n\t\t\treturn nil\n\t\t})\n\t}\n\terr = eg.Wait()\n\tif err != nil {\n\t\treturn err\n\t}\n\tb.UnsignedBlock = &UnsignedBlock{\n\t\tBlockHeader: rb.Header,\n\t\tTransactions: txs,\n\t}\n\tfor _, arg := range rb.Arguments {\n\t\tswitch arg.Type {\n\t\tcase DataType_BYTES:\n\t\t\tb.Arguments = append(b.Arguments, arg.Bytes)\n\t\tcase DataType_INT:\n\t\t\tb.Arguments = append(b.Arguments, arg.Int)\n\t\tcase DataType_TUPLE:\n\t\t\tb.Arguments = append(b.Arguments, arg.Tuple)\n\t\t}\n\t}\n\treturn nil\n}", "func (pd *pymtData) Deserialize(b []byte) error {\n\terr := json.Unmarshal(b, pd)\n\tif err != nil {\n\t\treturn errors.Wrap(err, ErrInvalidFormatBlob)\n\t}\n\n\treturn nil\n}", "func DeserializeBlock(d []byte) *Block {\n\tvar block Block\n\n\terr := utils.Deserialize(nil, d, &block)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn &block\n}", "func (bc BlockChain) deserializeBlock(o []byte) *Block {\r\n\tif !json.Valid(o) {\r\n\t\tpanic(\"Input is not a valid json object for block\")\r\n\t}\r\n\r\n\tvar jsonBlock Block\r\n\tvar b Block\r\n\t/**\r\n\tdec := json.NewDecoder(strings.NewReader(string(\to)))\r\n\tif err := dec.Decode(&jsonBlock); err == io.EOF {\r\n\t} else if err != nil {\r\n\t\tlog.Fatal(err)\r\n\t}\r\n\t**/\r\n\terr := json.Unmarshal(o, &jsonBlock)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\t//fmt.Println(\"new block is \" + jsonBlock.Serialize())\r\n\r\n\tbalances := make(map[string]int)\r\n\tchainLength := jsonBlock.ChainLength\r\n\ttimestamp := jsonBlock.Timestamp\r\n\r\n\tif jsonBlock.IsGenesisBlock() {\r\n\t\t//fmt.Println(\"setting balances\")\r\n\t\t//fmt.Println(jsonBlock.Balances)\r\n\t\tfor client, amount := range jsonBlock.Balances {\r\n\t\t\tbalances[client] = amount\r\n\t\t}\r\n\t\tb.Balances = balances\r\n\t} else {\r\n\t\tprevBlockHash := jsonBlock.PrevBlockHash\r\n\t\tproof := jsonBlock.Proof\r\n\t\trewardAddr := jsonBlock.RewardAddr\r\n\t\ttransactions := make(map[string]*Transaction)\r\n\t\tif jsonBlock.Transactions != nil {\r\n\t\t\tfor id, tx := range jsonBlock.Transactions {\r\n\t\t\t\ttransactions[id] = tx\r\n\t\t\t}\r\n\t\t}\r\n\t\t//GOTTA FIX THIS WHEN YOU IMPLEMENT CONSTANTS\r\n\t\tb = *bc.MakeBlock(rewardAddr, nil, nil, nil)\r\n\t\tb.ChainLength = chainLength\r\n\t\tb.Timestamp = timestamp\r\n\t\tb.PrevBlockHash = prevBlockHash\r\n\t\tb.Proof = proof\r\n\t\tb.Transactions = transactions\r\n\t}\r\n\treturn &b\r\n}", "func BlockFromBytes(data []byte) (Block, error) {\n\tvar b Block\n\treturn b, encoder.DeserializeRaw(data, &b)\n}", "func deserializeBlockUndoData(b []byte) ([]UndoTicketData, error) {\n\tif b != nil && len(b) == 0 {\n\t\treturn make([]UndoTicketData, 0), nil\n\t}\n\n\tif len(b) < undoTicketDataSize {\n\t\treturn nil, ticketDBError(ErrUndoDataShortRead, \"short read when \"+\n\t\t\t\"deserializing block undo data\")\n\t}\n\n\tif len(b)%undoTicketDataSize != 0 {\n\t\treturn nil, ticketDBError(ErrUndoDataCorrupt, \"corrupt data found \"+\n\t\t\t\"when deserializing block undo data\")\n\t}\n\n\tentries := len(b) / undoTicketDataSize\n\tutds := make([]UndoTicketData, entries)\n\n\toffset := 0\n\tfor i := 0; i < entries; i++ {\n\t\thash, err := chainhash.NewHash(\n\t\t\tb[offset : offset+chainhash.HashSize])\n\t\tif err != nil {\n\t\t\treturn nil, ticketDBError(ErrUndoDataCorrupt, \"corrupt hash found \"+\n\t\t\t\t\"when deserializing block undo data\")\n\t\t}\n\t\toffset += chainhash.HashSize\n\n\t\theight := dbnamespace.ByteOrder.Uint32(b[offset : offset+4])\n\t\toffset += 4\n\n\t\tmissed, revoked, spent, expired := undoBitFlagsFromByte(b[offset])\n\t\toffset++\n\n\t\tutds[i] = UndoTicketData{\n\t\t\tTicketHash: *hash,\n\t\t\tTicketHeight: height,\n\t\t\tMissed: missed,\n\t\t\tRevoked: revoked,\n\t\t\tSpent: spent,\n\t\t\tExpired: expired,\n\t\t}\n\t}\n\n\treturn utds, nil\n}", "func (f *OpenStreamReply) Deserialize(buffer []byte, err *error) []byte {\n\tif *err != nil {\n\t\treturn nil\n\t}\n\tif len(buffer) != 4 {\n\t\t*err = errDeserialize\n\t\treturn nil\n\t}\n\treturn buffer\n}", "func receiveBlock(ws *WrappedStream) (*Block, error) {\n\tvar block Block\n\terr := ws.dec.Decode(&block)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"unable to read block from stream\")\n\t}\n\treturn &block, nil\n}", "func DeserializeBytes(d []byte) (Bytes, error) {\n\treturn d, nil\n}", "func Deserialize(b []byte, out interface{}) error {\n\tautil.TODO(\"CBOR-deseriaization\")\n\treturn nil\n}", "func (block *Block) Parse(reader *bytes.Reader) *Block {\n\tbuffer4 := make([]byte, 4)\n\tbuffer32 := make([]byte, 32)\n\treader.Read(buffer4)\n\tblock.Version = util.LittleEndianToInt32(buffer4)\n\treader.Read(buffer32)\n\tcopy(block.PrevBlock[:32], util.ReverseByteArray(buffer32))\n\treader.Read(buffer32)\n\tcopy(block.MerkleRoot[:32], util.ReverseByteArray(buffer32))\n\treader.Read(buffer4)\n\tblock.Timestamp = util.LittleEndianToInt32(buffer4)\n\treader.Read(buffer4)\n\tcopy(block.Bits[:4], buffer4)\n\treader.Read(buffer4)\n\tcopy(block.Nonce[:4], buffer4)\n\treader.Read(buffer4)\n\tblock.Total = util.LittleEndianToInt32(buffer4)\n\tnumHashes := util.ReadVarInt(reader)\n\thashes := make([][]byte, numHashes)\n\tfor i := range hashes {\n\t\treader.Read(buffer32)\n\t\thashes[i] = make([]byte, 32)\n\t\tcopy(hashes[i], util.ReverseByteArray(buffer32))\n\t}\n\tblock.Hashes = hashes\n\tflagLength := util.ReadVarInt(reader)\n\tblock.Flags = make([]byte, flagLength)\n\treader.Read(block.Flags)\n\treturn block\n}", "func DecodeBlock(data []byte) *StBlock {\n\tout := new(StBlock)\n\tout.sign = data[1 : data[0]+1]\n\tbData := data[data[0]+1:]\n\tn := runtime.Decode(bData, &out.Block)\n\tstream := bData[n:]\n\tif len(stream)%HashLen != 0 {\n\t\treturn nil\n\t}\n\tif out.Index < 1 {\n\t\treturn nil\n\t}\n\n\trst := wallet.Recover(out.Producer[:], out.sign, bData)\n\tif !rst {\n\t\tlog.Printf(\"fail to recover block,producer:%x\\n\", out.Producer)\n\t\treturn nil\n\t}\n\th := runtime.GetHash(data)\n\truntime.Decode(h, &out.Key)\n\n\treturn out\n}", "func DeserializeBlockV1(paddedBlockSize uint32, dataBytes []byte) (Block, error) {\n\tblock := &blockV1{}\n\treturn block.deserialize(paddedBlockSize, dataBytes)\n}", "func (st *StatMicMsgBody) ReadBlock(_is *codec.Reader, tag byte, require bool) error {\r\n\tvar err error\r\n\tvar have bool\r\n\tst.resetDefault()\r\n\r\n\terr, have = _is.SkipTo(codec.STRUCT_BEGIN, tag, require)\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\tif !have {\r\n\t\tif require {\r\n\t\t\treturn fmt.Errorf(\"require StatMicMsgBody, but not exist. tag %d\", tag)\r\n\t\t}\r\n\t\treturn nil\r\n\r\n\t}\r\n\r\n\tst.ReadFrom(_is)\r\n\r\n\terr = _is.SkipToStructEnd()\r\n\tif err != nil {\r\n\t\treturn err\r\n\t}\r\n\t_ = have\r\n\treturn nil\r\n}", "func (f *OpenStreamRequest) Deserialize(buffer []byte, err *error) []byte {\n\tif *err != nil {\n\t\treturn nil\n\t}\n\tbuffer = f.Stream.Deserialize(buffer, err)\n\treturn buffer\n}", "func (u *Uint256) Deserialize(r io.Reader) error {\n\treturn binary.Read(r, binary.LittleEndian, u)\n}", "func Parse(s *bytes.Reader) *Block {\n\tblock := new(Block)\n\tbuffer4 := make([]byte, 4)\n\tbuffer32 := make([]byte, 32)\n\ts.Read(buffer4)\n\tblock.Version = util.LittleEndianToInt32(buffer4)\n\ts.Read(buffer32)\n\tcopy(block.PrevBlock[:], util.ReverseByteArray(buffer32))\n\ts.Read(buffer32)\n\tcopy(block.MerkleRoot[:], util.ReverseByteArray(buffer32))\n\ts.Read(buffer4)\n\tblock.Timestamp = util.LittleEndianToInt32(buffer4)\n\ts.Read(buffer4)\n\tcopy(block.Bits[:], buffer4)\n\ts.Read(buffer4)\n\tcopy(block.Nonce[:], buffer4)\n\treturn block\n}", "func (f *CloseNotice) Deserialize(buffer []byte, err *error) []byte {\n\tif *err != nil {\n\t\treturn nil\n\t}\n\tif len(buffer) != 0 {\n\t\t*err = errDeserialize\n\t\treturn nil\n\t}\n\treturn buffer\n}", "func deserializeBlockRow(blockRow []byte) (*protos.BlockHeader, *ainterface.Round, blockStatus, error) {\n\tbuffer := bytes.NewReader(blockRow)\n\n\tvar header protos.BlockHeader\n\terr := header.Deserialize(buffer)\n\tif err != nil {\n\t\treturn nil, nil, statusNone, err\n\t}\n\n\tstatusByte, err := buffer.ReadByte()\n\tif err != nil {\n\t\treturn nil, nil, statusNone, err\n\t}\n\n\tif blockStatus(statusByte)&statusFirstInRound == statusFirstInRound {\n\t\tvar round ainterface.Round\n\t\terr = round.Deserialize(buffer)\n\t\tif err != nil {\n\t\t\treturn nil, nil, statusNone, err\n\t\t}\n\t\tround.Round = header.Round\n\n\t\treturn &header, &round, blockStatus(statusByte), nil\n\t}\n\treturn &header, nil, blockStatus(statusByte), nil\n}", "func DecodeFromJSON(jsonString string) Block {\n\n\t// block := Block{}\n\tblockJson := BlockJson{}\n\n\terr := json.Unmarshal([]byte(jsonString), &blockJson)\n\tif err != nil {\n\t\tfmt.Println(\"DecodeFromJSON in block.go : block Err : \", err)\n\t\treturn Block{}\n\t}\n\treturn DecodeToBlock(\n\t\tblockJson.Height,\n\t\tblockJson.Timestamp,\n\t\tblockJson.Hash,\n\t\tblockJson.ParentHash,\n\t\tblockJson.Size,\n\t\tblockJson.Nonce,\n\t\tblockJson.MPT)\n}", "func DecodeFromJson(jsonString string) (Block, error) {\n\n var header Header\n newBlock := Block{}\n blockJson, err := jsonToBlockJson(jsonString)\n if err != nil {\n return newBlock, err\n }\n\n mpt := NewTrie(blockJson.MPT)\n header.Height = blockJson.Height\n header.Timestamp = blockJson.Timestamp\n header.Hash = blockJson.Hash\n header.ParentHash = blockJson.ParentHash\n header.Size = blockJson.Size\n header.Nonce = blockJson.Nonce\n\n newBlock.Header = header\n newBlock.Mpt = mpt\n return newBlock, nil\n}", "func Unmarshal([]byte) (WireMessage, error) { return nil, nil }", "func (b *block) InitFromBlockData(bd *blockData, sbu *stringsBlockUnmarshaler, vd *valuesDecoder) error {\n\tb.reset()\n\n\tif bd.rowsCount > maxRowsPerBlock {\n\t\treturn fmt.Errorf(\"too many entries found in the block: %d; mustn't exceed %d\", bd.rowsCount, maxRowsPerBlock)\n\t}\n\trowsCount := int(bd.rowsCount)\n\n\t// unmarshal timestamps\n\ttd := &bd.timestampsData\n\tvar err error\n\tb.timestamps, err = encoding.UnmarshalTimestamps(b.timestamps[:0], td.data, td.marshalType, td.minTimestamp, rowsCount)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot unmarshal timestamps: %w\", err)\n\t}\n\n\t// unmarshal columns\n\tcds := bd.columnsData\n\tcs := b.resizeColumns(len(cds))\n\tfor i := range cds {\n\t\tcd := &cds[i]\n\t\tc := &cs[i]\n\t\tc.name = cd.name\n\t\tc.values, err = sbu.unmarshal(c.values[:0], cd.valuesData, uint64(rowsCount))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot unmarshal column %d: %w\", i, err)\n\t\t}\n\t\tif err = vd.decodeInplace(c.values, cd.valueType, &cd.valuesDict); err != nil {\n\t\t\treturn fmt.Errorf(\"cannot decode column values: %w\", err)\n\t\t}\n\t}\n\n\t// unmarshal constColumns\n\tb.constColumns = append(b.constColumns[:0], bd.constColumns...)\n\n\treturn nil\n}", "func (t *LastAccessTime) Deserialize(b []byte) error {\n\ti, n := binary.Varint(b)\n\tif n <= 0 {\n\t\treturn fmt.Errorf(\"unmarshal last access time: %s\", b)\n\t}\n\tt.Time = time.Unix(int64(i), 0)\n\treturn nil\n}", "func (f *ReadRequest) Deserialize(buffer []byte, err *error) []byte {\n\tif *err != nil {\n\t\treturn nil\n\t}\n\tif len(buffer) != 1+8+8 {\n\t\t*err = errDeserialize\n\t\treturn nil\n\t}\n\tf.Seek = SeekFlags(buffer[0])\n\tf.Offset = int64(binary.LittleEndian.Uint64(buffer[1:]))\n\tf.Count = int64(binary.LittleEndian.Uint64(buffer[9:]))\n\treturn buffer\n}", "func DeserializeBlockSeqFunc(d []byte) (*BlockSeqFunc, error) {\n\tobj, err := serializer.DeserializeWithType(d)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tblock, ok := obj.(Block)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"expected Block but got %T\", obj)\n\t}\n\treturn &BlockSeqFunc{Block: block}, nil\n}", "func DeserializerFromBytes(value []byte, result interface{}) error {\n\tif json.Valid(value) {\n\t\treturn json.Unmarshal(value, result)\n\t}\n\treturn errors.New(\"invalid json byte array\")\n}", "func readBlockHeader(r io.Reader, bh *BlockHeader) error {\n\treturn bh.Deserialize(r)\n}", "func (blk IntegerBlock) Parse(bytes []byte, rd io.Reader) (BlockParseResult, error) {\n\tvar result = BlockParseResult{}\n\n\tif string(bytes[0]) != \":\" {\n\t\treturn result, errors.New(\"invalid format: \" + string(bytes[0]))\n\t}\n\n\tline, bytes, err := readLine(bytes, rd)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\ti, err := strconv.Atoi(string(line[1:]))\n\tif err != nil {\n\t\treturn result, err\n\t}\n\n\tresult.Value = IntegerBlock{Content: i}\n\tresult.remainBytes = bytes\n\n\treturn result, nil\n}", "func deserialize(src *[]byte, obj interface{}) error {\n\tglog.Infof(\"Deserialization\")\n\n\t// make a copy of the bytes as this comes from bolt and the object will be used outside\n\t// of the transaction\n\tb := make([]byte, len(*src))\n\tcopy(b, *src)\n\n\tbuf := bytes.NewBuffer(b)\n\tdec := gob.NewDecoder(buf)\n\n\terr := dec.Decode(obj)\n\tif err != nil {\n\t\tglog.Infof(\"Failed to deserialize object: %s\", err)\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (vb *VarBytes) Deserialize(r io.Reader) error {\n\tvar varlen VarUint\n\tif err := varlen.Deserialize(r); err != nil {\n\t\treturn err\n\t}\n\tvb.Len = uint64(varlen.Value)\n\tvb.Bytes = make([]byte, vb.Len)\n\treturn binary.Read(r, binary.LittleEndian, vb.Bytes)\n}", "func Deserialize(packet [UDP_BUF_LEN]byte, n int) TCP_Segment {\n\ttemp := packet[0:n]\n\tb := bytes.NewBuffer(temp)\n\t//log.Println(\"Buffer:\", b.Bytes())\n\tvar segmentReceived TCP_Segment\n\tbinary.Read(b, binary.BigEndian, &segmentReceived)\n\t//log.Println(\"Segment Rec: \", segmentReceived)\n\treturn segmentReceived\n}", "func ParseOne(bytes []byte) (IBlock, error) {\n\tif bytes == nil || len(bytes) == 0 {\n\t\treturn nil, errors.New(\"bytes can not be nil or empty\")\n\t}\n\n\tparser, err := GetBlockParser(rune(bytes[0]))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresult, err := parser.Parse(bytes, nil)\n\n\tif err != nil {\n\t\treturn result.Value, err\n\t}\n\n\treturn result.Value, nil\n}", "func readBlock(r io.Reader, pver uint32, b *MicroBlock) error {\n return readElements(r, &b.Version, &b.PrevBlock, &b.MerkleRoot,\n\t(*uint32Time)(&bh.Timestamp), &bh.Bits)\n}", "func (b *BlockStruct) FromJSON(byteblock []byte) (BlockStructObj BlockStruct) {\n\tjson.Unmarshal(byteblock, b)\n\tmapstructure.Decode(b, &BlockStructObj)\n\treturn BlockStructObj\n}", "func deserialize(src []byte, dst interface{}) error {\n\tdec := gob.NewDecoder(bytes.NewBuffer(src))\n\tif err := dec.Decode(dst); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func BlockFromProto(bp *tmproto.Block) (*Block, error) {\n\tif bp == nil {\n\t\treturn nil, errors.New(\"nil block\")\n\t}\n\n\tb := new(Block)\n\th, err := HeaderFromProto(&bp.Header)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb.Header = h\n\tdata, err := DataFromProto(&bp.Data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb.Data = data\n\tif err := b.Evidence.FromProto(&bp.Evidence); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif bp.LastCommit != nil {\n\t\tlc, err := CommitFromProto(bp.LastCommit)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tb.LastCommit = lc\n\t}\n\n\treturn b, b.ValidateBasic()\n}", "func Deserialize(registerValue interface{}, data []byte, targetPointer interface{}) error {\n\tif registerValue != nil {\n\t\tgob.Register(registerValue)\n\t}\n\tdecoder := gob.NewDecoder(bytes.NewReader(data))\n\terr := decoder.Decode(targetPointer)\n\n\treturn err\n}", "func (f *PushNotice) Deserialize(buffer []byte, err *error) []byte {\n\tif *err != nil {\n\t\treturn nil\n\t}\n\tif len(buffer) < 1 {\n\t\t*err = errDeserialize\n\t\treturn nil\n\t}\n\tf.Flags = DataFlags(buffer[0])\n\tf.Data = buffer[1:]\n\treturn buffer\n}", "func BlockFromProto(bp *tmproto.Block) (*Block, error) {\n\tif bp == nil {\n\t\treturn nil, errors.New(\"nil block\")\n\t}\n\n\tb := new(Block)\n\th, err := HeaderFromProto(&bp.Header)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb.Header = h\n\tdata, err := DataFromProto(&bp.Data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tb.Data = data\n\tif err := b.Evidence.FromProto(&bp.Evidence); err != nil {\n\t\treturn nil, err\n\t}\n\n\tcoreChainLock, err := CoreChainLockFromProto(bp.CoreChainLock)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tb.CoreChainLock = coreChainLock\n\n\tif bp.LastCommit != nil {\n\t\tlc, err := CommitFromProto(bp.LastCommit)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tb.LastCommit = lc\n\t}\n\n\treturn b, b.ValidateBasic()\n}", "func NewBlockFromBytes(b []byte) (*Block, error) {\r\n\tif len(b) == 0 {\r\n\t\treturn nil, errors.New(\"block cannot be empty\")\r\n\t}\r\n\r\n\tvar offset int\r\n\tbh, err := NewBlockHeaderFromBytes(b[:80])\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\toffset += 80\r\n\r\n\ttxCount, size := bt.DecodeVarInt(b[offset:])\r\n\toffset += size\r\n\r\n\tvar txs []*bt.Tx\r\n\tfor i := 0; i < int(txCount); i++ {\r\n\t\ttx, size, err := bt.NewTxFromStream(b[offset:])\r\n\t\tif err != nil {\r\n\t\t\treturn nil, err\r\n\t\t}\r\n\t\ttxs = append(txs, tx)\r\n\t\toffset += size\r\n\t}\r\n\r\n\treturn &Block{\r\n\t\tBlockHeader: bh,\r\n\t\tTxs: txs,\r\n\t}, nil\r\n}", "func Deserialize(b []byte) (Message, error) {\n\tvar msg Message\n\tbuf := bytes.NewBuffer(b)\n\tdecoder := json.NewDecoder(buf)\n\terr := decoder.Decode(&msg)\n\treturn msg, err\n}", "func (bp *bitmapPart) FromBlock(block disk.Block) error {\n\tbp.data = block\n\treturn nil\n}", "func FromBytes(rawBytes []byte, p Packet) error {\n\t// interface smuggling\n\tif pp, ok := p.(encoding.BinaryUnmarshaler); ok {\n\t\treturn pp.UnmarshalBinary(rawBytes)\n\t}\n\treader := bytes.NewReader(rawBytes)\n\treturn binary.Read(reader, binary.BigEndian, p)\n}", "func Deserialize(data []byte, value interface{}) error {\n\treturn rlp.DecodeBytes(data, value)\n}", "func readBlock(reader io.ReadSeeker) (*Block, int64, error) {\n\t// Protect function with lock since it modifies reader state\n\tm.Lock()\n\tdefer m.Unlock()\n\n\toffset, err := reader.Seek(0, 1)\n\n\tif err != nil {\n\t\treturn nil, offset, err\n\t}\n\n\theaderData := make([]byte, HEADER_SIZE)\n\tn, err := reader.Read(headerData)\n\n\tif err != nil {\n\t\treturn nil, offset, err\n\t}\n\n\tif n != HEADER_SIZE {\n\t\treturn nil, offset, NotEnoughDataErr\n\t}\n\n\tblockSize := binary.LittleEndian.Uint32(headerData)\n\tblockBuffer := make([]byte, blockSize)\n\tn, err = reader.Read(blockBuffer)\n\n\tif err != nil {\n\t\treturn nil, offset, err\n\t}\n\n\tif uint32(n) != blockSize {\n\t\treturn nil, offset, NotEnoughDataErr\n\t}\n\n\tif err != nil {\n\t\treturn nil, offset, err\n\t}\n\n\tvar block = &Block{}\n\n\terr = json.Unmarshal(blockBuffer, block)\n\n\tif err != nil {\n\t\treturn nil, offset, err\n\t}\n\n\t// Set reader to begin of next block or EOF\n\t_, err = reader.Seek(DIGEST_SIZE, 1)\n\n\tif err != nil {\n\t\treturn nil, offset, err\n\t}\n\n\treturn block, offset, nil\n}", "func BytesToBlock(b []byte) Block {\n\treturn Block(bigendian.BytesToUint64(b))\n}", "func (e *EthRedeemScript) Deserialize(b []byte) error {\n\tbuf := bytes.NewBuffer(b)\n\td := gob.NewDecoder(buf)\n\terr := d.Decode(e)\n\treturn err\n}", "func (c *ChunkRef) DecodeBytes(by []byte) error {\n\treturn msgpack.Unmarshal(by, c)\n}", "func deserializeByteSequenceModel(model SerializedSequenceModel) *SequenceModel {\n\tsequence, err := hex.DecodeString(model.Sequence)\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\treturn &SequenceModel{Index: model.Index, Offset: model.Offset, Sequence: sequence, Length: model.Length}\n}", "func (bn *BlockNumber) UnmarshalJSON(data []byte) error {\ninput := strings.TrimSpace(string(data))\nif len(input) >= 2 && input[0] == '\"' && input[len(input)-1] == '\"' {\ninput = input[1 : len(input)-1]\n}\n\nswitch input {\ncase \"earliest\":\n*bn = EarliestBlockNumber\nreturn nil\ncase \"latest\":\n*bn = LatestBlockNumber\nreturn nil\ncase \"pending\":\n*bn = PendingBlockNumber\nreturn nil\n}\n\nblckNum, err := hexutil.DecodeUint64(input)\nif err != nil {\nreturn err\n}\nif blckNum > math.MaxInt64 {\nreturn fmt.Errorf(\"Blocknumber too high\")\n}\n\n*bn = BlockNumber(blckNum)\nreturn nil\n}", "func ReadBytes(obj any, b []byte) error {\n\terr := toml.Unmarshal(b, obj)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *uint8Type) Deserialize(sv []byte) (interface{}, error) {\n\treturn c.DeserializeT(sv)\n}", "func (q *Quote) Deserialize(b []byte) error {\n\tbuf := bytes.NewBuffer(b)\n\tdec := gob.NewDecoder(buf)\n\terr := dec.Decode(q)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"Deserialize: decoding failed for %s\", b)\n\t}\n\treturn nil\n}", "func DeserializeThrift(ctx context.Context, b []byte, s athrift.TStruct) error {\n\treader := bytes.NewReader(b)\n\ttransport := athrift.NewStreamTransportR(reader)\n\treturn s.Read(ctx, athrift.NewTBinaryProtocolTransport(transport))\n}", "func Deserialize(holder interface{}, data []byte) error {\n\tds := createDeserializer(data)\n\n\tt := reflect.ValueOf(holder)\n\tif t.Kind() != reflect.Ptr {\n\t\treturn fmt.Errorf(\"holder must set pointer value. but got: %t\", holder)\n\t}\n\n\tt = t.Elem()\n\tif t.Kind() == reflect.Ptr {\n\t\tt = t.Elem()\n\t}\n\n\t// byte to Struct\n\tif t.Kind() == reflect.Struct && !isDateTime(t) && !isDateTimeOffset(t) {\n\t\treturn ds.deserializeStruct(t)\n\t}\n\n\t// byte to primitive\n\t_, err := ds.deserialize(t, 0)\n\treturn err\n}", "func (b *BlockNumber) UnmarshalJSON(bz []byte) error {\n\tvar tmp string\n\tif err := json.Unmarshal(bz, &tmp); err != nil {\n\t\treturn err\n\t}\n\n\ts := strings.TrimPrefix(tmp, \"0x\")\n\n\tp, err := strconv.ParseUint(s, 16, 32)\n\t*b = BlockNumber(p)\n\treturn err\n}", "func (d *Data) transcodeBlock(b blockData) (out []byte, err error) {\n\tformatIn, checksum := dvid.DecodeSerializationFormat(dvid.SerializationFormat(b.data[0]))\n\n\tvar start int\n\tif checksum == dvid.CRC32 {\n\t\tstart = 5\n\t} else {\n\t\tstart = 1\n\t}\n\n\tvar outsize uint32\n\n\tswitch formatIn {\n\tcase dvid.LZ4:\n\t\toutsize = binary.LittleEndian.Uint32(b.data[start : start+4])\n\t\tout = b.data[start+4:]\n\t\tif len(out) != int(outsize) {\n\t\t\terr = fmt.Errorf(\"block %s was corrupted lz4: supposed size %d but had %d bytes\", b.bcoord, outsize, len(out))\n\t\t\treturn\n\t\t}\n\tcase dvid.Uncompressed, dvid.Gzip:\n\t\toutsize = uint32(len(b.data[start:]))\n\t\tout = b.data[start:]\n\tdefault:\n\t\terr = fmt.Errorf(\"labelmap data was stored in unknown compressed format: %s\", formatIn)\n\t\treturn\n\t}\n\n\tvar formatOut dvid.CompressionFormat\n\tswitch b.compression {\n\tcase \"\", \"lz4\":\n\t\tformatOut = dvid.LZ4\n\tcase \"blocks\":\n\t\tformatOut = formatIn\n\tcase \"gzip\":\n\t\tformatOut = dvid.Gzip\n\tcase \"uncompressed\":\n\t\tformatOut = dvid.Uncompressed\n\tdefault:\n\t\terr = fmt.Errorf(\"unknown compression %q requested for blocks\", b.compression)\n\t\treturn\n\t}\n\n\tvar doMapping bool\n\tvar mapping *VCache\n\tif !b.supervoxels {\n\t\tif mapping, err = getMapping(d, b.v); err != nil {\n\t\t\treturn\n\t\t}\n\t\tif mapping != nil && mapping.mapUsed {\n\t\t\tdoMapping = true\n\t\t}\n\t}\n\n\t// Need to do uncompression/recompression if we are changing compression or mapping\n\tvar uncompressed, recompressed []byte\n\tif formatIn != formatOut || b.compression == \"gzip\" || doMapping {\n\t\tswitch formatIn {\n\t\tcase dvid.LZ4:\n\t\t\tuncompressed = make([]byte, outsize)\n\t\t\tif err = lz4.Uncompress(out, uncompressed); err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\tcase dvid.Uncompressed:\n\t\t\tuncompressed = out\n\t\tcase dvid.Gzip:\n\t\t\tgzipIn := bytes.NewBuffer(out)\n\t\t\tvar zr *gzip.Reader\n\t\t\tzr, err = gzip.NewReader(gzipIn)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tuncompressed, err = ioutil.ReadAll(zr)\n\t\t\tif err != nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tzr.Close()\n\t\t}\n\n\t\tvar block labels.Block\n\t\tif err = block.UnmarshalBinary(uncompressed); err != nil {\n\t\t\terr = fmt.Errorf(\"unable to deserialize label block %s: %v\", b.bcoord, err)\n\t\t\treturn\n\t\t}\n\n\t\tif !b.supervoxels {\n\t\t\tmodifyBlockMapping(b.v, &block, mapping)\n\t\t}\n\n\t\tif b.compression == \"blocks\" { // send native DVID block compression with gzip\n\t\t\tout, err = block.CompressGZIP()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t} else { // we are sending raw block data\n\t\t\tuint64array, size := block.MakeLabelVolume()\n\t\t\texpectedSize := d.BlockSize().(dvid.Point3d)\n\t\t\tif !size.Equals(expectedSize) {\n\t\t\t\terr = fmt.Errorf(\"deserialized label block size %s does not equal data %q block size %s\", size, d.DataName(), expectedSize)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tswitch formatOut {\n\t\t\tcase dvid.LZ4:\n\t\t\t\trecompressed = make([]byte, lz4.CompressBound(uint64array))\n\t\t\t\tvar size int\n\t\t\t\tif size, err = lz4.Compress(uint64array, recompressed); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\toutsize = uint32(size)\n\t\t\t\tout = recompressed[:outsize]\n\t\t\tcase dvid.Uncompressed:\n\t\t\t\tout = uint64array\n\t\t\tcase dvid.Gzip:\n\t\t\t\tvar gzipOut bytes.Buffer\n\t\t\t\tzw := gzip.NewWriter(&gzipOut)\n\t\t\t\tif _, err = zw.Write(uint64array); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t\tzw.Flush()\n\t\t\t\tzw.Close()\n\t\t\t\tout = gzipOut.Bytes()\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func BlockDecode(packed []byte, number uint64, decodeTxs bool) (*blockResult, error) {\n\n\tbr := blockrecord.Get()\n\n\theader, digest, data, err := br.ExtractHeader(packed, number, false)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\n\tif !decodeTxs {\n\t\tresult := &blockResult{\n\t\t\tDigest: &digest,\n\t\t\tHeader: header,\n\t\t\tTransactions: nil,\n\t\t\tPacked: packed,\n\t\t}\n\n\t\treturn result, nil\n\t}\n\n\ttxs := make([]transactionItem, header.TransactionCount)\nloop:\n\tfor i := 1; true; i += 1 {\n\t\ttransaction, n, err := transactionrecord.Packed(data).Unpack(mode.IsTesting())\n\t\tif nil != err {\n\t\t\treturn nil, err\n\t\t}\n\t\tname, _ := transactionrecord.RecordName(transaction)\n\t\ttxs[i-1] = transactionItem{\n\t\t\tIndex: i,\n\t\t\tTxId: merkle.NewDigest(data[:n]),\n\t\t\tType: name,\n\t\t\tData: transaction,\n\t\t}\n\t\tdata = data[n:]\n\t\tif 0 == len(data) {\n\t\t\tbreak loop\n\t\t}\n\t}\n\n\tresult := &blockResult{\n\t\tDigest: &digest,\n\t\tHeader: header,\n\t\tTransactions: txs,\n\t\tPacked: packed,\n\t}\n\n\treturn result, nil\n}", "func (f *CreateBundleReply) Deserialize(buffer []byte, err *error) []byte {\n\tif *err != nil {\n\t\treturn nil\n\t}\n\tif len(buffer) != 4 {\n\t\t*err = errDeserialize\n\t\treturn nil\n\t}\n\treturn buffer\n}", "func newDataFileReaderBytes(buf []byte, datumReader DatumReader) (reader *DataFileReader, err error) {\n\tif len(buf) < len(magic) || !bytes.Equal(magic, buf[0:4]) {\n\t\treturn nil, NotAvroFile\n\t}\n\n\tdec := NewBinaryDecoder(buf)\n\tblockDecoder := NewBinaryDecoder(nil)\n\treader = &DataFileReader{\n\t\tdata: buf,\n\t\tdec: dec,\n\t\tblockDecoder: blockDecoder,\n\t\tdatum: datumReader,\n\t}\n\n\tif reader.header, err = readObjFileHeader(dec); err != nil {\n\t\treturn nil, err\n\t}\n\n\tschema, err := ParseSchema(string(reader.header.Meta[schemaKey]))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treader.datum.SetSchema(schema)\n\treader.block = &DataBlock{}\n\n\tif reader.hasNextBlock() {\n\t\tif err := reader.NextBlock(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn reader, nil\n}", "func (msg *Block) DeserializeTxLoc(r *bytes.Buffer) (txLocs []TxLoc, e error) {\n\tfullLen := r.Len()\n\t// At the current time, there is no difference between the wire encoding at protocol version 0 and the stable\n\t// long-term storage format. As a result, make use of existing wire protocol functions.\n\tif e = readBlockHeader(r, 0, &msg.Header); E.Chk(e) {\n\t\treturn\n\t}\n\tvar txCount uint64\n\tif txCount, e = ReadVarInt(r, 0); E.Chk(e) {\n\t\treturn\n\t}\n\t// Prevent more transactions than could possibly fit into a block. It would be possible to cause memory exhaustion\n\t// and panics without a sane upper bound on this count.\n\tif txCount > maxTxPerBlock {\n\t\tstr := fmt.Sprintf(\n\t\t\t\"too many transactions to fit into a block [count %d, max %d]\", txCount, maxTxPerBlock,\n\t\t)\n\t\treturn nil, messageError(\"Block.DeserializeTxLoc\", str)\n\t}\n\t// Deserialize each transaction while keeping track of its location within the byte stream.\n\tmsg.Transactions = make([]*MsgTx, 0, txCount)\n\ttxLocs = make([]TxLoc, txCount)\n\tfor i := uint64(0); i < txCount; i++ {\n\t\ttxLocs[i].TxStart = fullLen - r.Len()\n\t\ttx := MsgTx{}\n\t\tif e = tx.Deserialize(r); E.Chk(e) {\n\t\t\treturn\n\t\t}\n\t\tmsg.Transactions = append(msg.Transactions, &tx)\n\t\ttxLocs[i].TxLen = (fullLen - r.Len()) - txLocs[i].TxStart\n\t}\n\treturn\n}", "func (msg *MsgTx) Deserialize(r io.Reader) error {\n\t// At the current time, there is no difference between the protos encoding\n\t// at protocol version 0 and the stable long-term storage format. As\n\t// a result, make use of VVSDecode.\n\treturn msg.VVSDecode(r, 0, BaseEncoding)\n}", "func DeserializeBlockStoresPb(buf []byte) (*iotextypes.BlockStores, error) {\n\tpbStores := &iotextypes.BlockStores{}\n\tif err := proto.Unmarshal(buf, pbStores); err != nil {\n\t\treturn nil, err\n\t}\n\treturn pbStores, nil\n}", "func (prkg *KeyIterator) Deserialize(data []byte) error {\n\treturn gob.NewDecoder(bytes.NewBuffer(data)).Decode(prkg)\n}", "func (broadcast *Broadcast) decodeFromDecrypted(r io.Reader) error {\n\tbroadcast.bm = &Bitmessage{}\n\terr := broadcast.bm.decodeBroadcast(r)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar sigLength uint64\n\tif sigLength, err = bmutil.ReadVarInt(r); err != nil {\n\t\treturn err\n\t}\n\tif sigLength > obj.SignatureMaxLength {\n\t\tstr := fmt.Sprintf(\"signature length exceeds max length - \"+\n\t\t\t\"indicates %d, but max length is %d\",\n\t\t\tsigLength, obj.SignatureMaxLength)\n\t\treturn wire.NewMessageError(\"DecodeFromDecrypted\", str)\n\t}\n\tbroadcast.sig = make([]byte, sigLength)\n\t_, err = io.ReadFull(r, broadcast.sig)\n\treturn err\n}", "func parseBlocks(r *bufio.Reader, s *SOR) error {\n\tvar mb Block\n\tmb.ID = \"Map\"\n\n\t// no map is 'Map' on v1 so skip past it\n\tif s.Version == SORv2 {\n\t\t_, _ = readNBytes(r, 4)\n\t}\n\n\tbinary.Read(r, binary.LittleEndian, &mb.Version)\n\tbinary.Read(r, binary.LittleEndian, &mb.Bytes)\n\n\tvar blocks int16\n\tbinary.Read(r, binary.LittleEndian, &blocks)\n\n\ts.Blocks = append(s.Blocks, mb)\n\n\t// parse remaining blocks\n\tfor i := 1; i < int(blocks); i++ {\n\t\tvar m Block\n\t\tblock_name, _ := r.ReadBytes('\\x00')\n\t\tm.ID = string(bytes.Trim(block_name, \"\\x00\"))\n\t\tbinary.Read(r, binary.LittleEndian, &m.Version)\n\t\tbinary.Read(r, binary.LittleEndian, &m.Bytes)\n\t\ts.Blocks = append(s.Blocks, m)\n\t}\n\n\treturn nil\n}", "func FromBytes(byteData []byte) (Data, error) {\n\tvar data Data\n\tif err := yaml.Unmarshal(byteData, &data); err != nil {\n\t\treturn data, fmt.Errorf(\"could not unmarshal config data: %w\", err)\n\t}\n\treturn data, nil\n}", "func deserializeSendStruct(ret []byte) *sendStruct {\n\tss := new(sendStruct)\n\tss.SendType = ret[0]\n\tss.length = binary.LittleEndian.Uint64(ret[1:9])\n\tcopy(ss.Receiver[0:rsautil.KeySize], ret[9:9+rsautil.KeySize])\n\n\tss.data = make([]byte, ss.length)\n\tcopy(ss.data[0:ss.length], ret[9+rsautil.KeySize:9+rsautil.KeySize+ss.length])\n\n\treturn ss\n}", "func UnmarshalBlockDatabase(data []byte) (BlockDatabase, error) {\n\tdb, err := hs.DeserializeDatabase(data)\n\tif err != nil {\n\t\treturn nil, err //nolint: wrapcheck\n\t}\n\n\treturn newBlockDatabase(db), nil\n}", "func (b *Block) Parse() error {\n\tstartPos := uint64(0)\n\tb.subelements = []*Block{}\n\tfor startPos < uint64(len(b.value)) {\n\t\tblock, blockLen, err := DecodeBlock(b.value[startPos:])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tb.subelements = append(b.subelements, block)\n\t\tstartPos += blockLen\n\t}\n\treturn nil\n}", "func (msg *Block) DeserializeNoWitness(r io.Reader) (e error) {\n\treturn msg.BtcDecode(r, 0, BaseEncoding)\n}", "func (flush *FuseFlushIn) ParseBinary(bcontent []byte) error {\n\n\tlength := len(bcontent)\n\n\tif length < 24 {\n\t\treturn ErrDataLen\n\t}\n\n\tcommon.ParseBinary(bcontent, flush)\n\n\treturn nil\n}", "func Deserialize(input []byte) (HMSketch, error) {\n\tvar inbytes bytes.Buffer\n\tvar h HMSketch\n\tinbytes.Write(input)\n\tdec := gob.NewDecoder(&inbytes)\n\terr := dec.Decode(&h)\n\treturn h, err\n}", "func (c *cursor) decodeBlock(position uint32) {\n\tlength := c.blockLength(position)\n\tblock := c.f.mmap[position+blockHeaderSize : position+blockHeaderSize+length]\n\tc.vals = c.vals[:0]\n\t_ = DecodeBlock(block, &c.vals)\n\n\t// only adavance the position if we're asceending.\n\t// Descending queries use the blockPositions\n\tif c.ascending {\n\t\tc.pos = position + blockHeaderSize + length\n\t}\n}", "func (f *CommitNotice) Deserialize(buffer []byte, err *error) []byte {\n\tif *err != nil {\n\t\treturn nil\n\t}\n\tif len(buffer) != 4+8 {\n\t\t*err = errDeserialize\n\t\treturn nil\n\t}\n\tf.Error = ErrorCode(binary.LittleEndian.Uint32(buffer))\n\tf.Time = int64(binary.LittleEndian.Uint64(buffer[4:]))\n\treturn buffer\n}", "func (b *OldBlock) DecodeRLP(s *rlp.Stream) error {\n\tvar eb extoldblock\n\t_, size, _ := s.Kind()\n\tif err := s.Decode(&eb); err != nil {\n\t\treturn err\n\t}\n\tb.header, b.uncles, b.currencies = eb.Header, eb.Uncles, eb.Currencies\n\n\tb.size.Store(common.StorageSize(rlp.ListSize(size)))\n\treturn nil\n}", "func (s *State) ParseBlock(b []byte) (snowman.Block, error) {\n\t// See if we've cached this block's ID by its byte repr.\n\tblkIDIntf, blkIDCached := s.bytesToIDCache.Get(string(b))\n\tif blkIDCached {\n\t\tblkID := blkIDIntf.(ids.ID)\n\t\t// See if we have this block cached\n\t\tif cachedBlk, ok := s.getCachedBlock(blkID); ok {\n\t\t\treturn cachedBlk, nil\n\t\t}\n\t}\n\n\t// We don't have this block cached by its byte repr.\n\t// Parse the block from bytes\n\tblk, err := s.unmarshalBlock(b)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tblkID := blk.ID()\n\ts.bytesToIDCache.Put(string(b), blkID)\n\n\t// Only check the caches if we didn't do so above\n\tif !blkIDCached {\n\t\t// Check for an existing block, so we can return a unique block\n\t\t// if processing or simply allow this block to be immediately\n\t\t// garbage collected if it is already cached.\n\t\tif cachedBlk, ok := s.getCachedBlock(blkID); ok {\n\t\t\treturn cachedBlk, nil\n\t\t}\n\t}\n\n\ts.missingBlocks.Evict(blkID)\n\n\t// Since this block is not in consensus, addBlockOutsideConsensus\n\t// is called to add [blk] to the correct cache.\n\treturn s.addBlockOutsideConsensus(blk)\n}" ]
[ "0.7719862", "0.73738414", "0.73401064", "0.73401064", "0.72333825", "0.71995974", "0.70526373", "0.7010707", "0.6952458", "0.6866853", "0.6866474", "0.6858835", "0.68524516", "0.68484986", "0.6825386", "0.6787646", "0.6787646", "0.67310977", "0.6635826", "0.6546314", "0.64646703", "0.6399814", "0.63041455", "0.62807", "0.62350684", "0.61157024", "0.60341406", "0.5949704", "0.59205323", "0.58878577", "0.58153373", "0.579744", "0.57816887", "0.5749558", "0.57459545", "0.57364374", "0.5700764", "0.56993777", "0.56820315", "0.5673335", "0.566121", "0.5599891", "0.5594302", "0.55781615", "0.55691123", "0.55558497", "0.5538985", "0.553845", "0.55351686", "0.54868966", "0.54855496", "0.54766923", "0.5475304", "0.5475167", "0.54742146", "0.54670995", "0.5464776", "0.5463324", "0.546147", "0.5460682", "0.54543215", "0.54227424", "0.54201114", "0.54175866", "0.5414068", "0.5413225", "0.5404429", "0.5402001", "0.53920966", "0.5385237", "0.5369039", "0.536502", "0.53616387", "0.5349339", "0.5340706", "0.5337625", "0.53201175", "0.53171784", "0.5315571", "0.5309188", "0.5308202", "0.5303943", "0.52987796", "0.52968603", "0.52905643", "0.52888995", "0.5283926", "0.52750486", "0.52726823", "0.5267697", "0.5254119", "0.5252836", "0.5252552", "0.5242523", "0.5242018", "0.52308106", "0.52074665", "0.520571", "0.5205122", "0.52019405" ]
0.72823566
4
Log prints block info
func (block *Block) Log() { template := "BLOCK >>>> \nHeight: %d \nPrevious hash: %x \nData: %x " + "\nTimestamp: %d [%s] \nNonce: %d \nTransactions:\n" fmt.Printf(template, block.Height, block.PrevBlockHash, block.Hash, block.Timestamp, time.Unix(block.Timestamp, 0), block.Nonce) for _, t := range block.Transactions { t.Log() } fmt.Printf("\n") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (bc *Blockchain) PrintBlockInfo(index int) {\n block := bc.Chain[index]\n fmt.Println(\"Index of the block is \" + strconv.Itoa(block.Index))\n fmt.Println(\"Timestamp of the block is \" + time.Unix(block.Timestamp, 0).Format(time.UnixDate))\n fmt.Println(\"Proof of the block is \" + strconv.Itoa(block.Proof))\n fmt.Println(\"Hash of the previous block is \" + block.PreviousHash)\n fmt.Println(\"Hash of the current block is \" + bc.HashBlock(block))\n fmt.Println(\"Difficulty of the block is \" + block.Difficulty)\n fmt.Println(\"\\n\\n\")\n}", "func PrintBlockInfo(block *Block) {\n\tfmt.Printf(\"previous hash : %x\\n\", block.PreBlockHash)\n\t// fmt.Printf(\"block data : %s\\n\", block.Data)\n\tfmt.Printf(\"block nonce :%d\\n\", block.Nonce)\n\tfmt.Printf(\"block hash : %x\\n\", block.Hash)\n\tfmt.Printf(\"validate : %s\\n\\n\", strconv.FormatBool(NewProofOfWork(block).Validate()))\n}", "func LogBlock(block *util.Block) error {\n\tmtx.Lock()\n\tdefer mtx.Unlock()\n\n\treceivedLogBlocks++\n\treceivedLogTx += int64(len(block.MsgBlock().Transactions))\n\n\tnow := mstime.Now()\n\tduration := now.Sub(lastBlockLogTime)\n\tif duration < time.Second*10 {\n\t\treturn nil\n\t}\n\n\t// Truncate the duration to 10s of milliseconds.\n\ttDuration := duration.Round(10 * time.Millisecond)\n\n\t// Log information about new block blue score.\n\tblockStr := \"blocks\"\n\tif receivedLogBlocks == 1 {\n\t\tblockStr = \"block\"\n\t}\n\ttxStr := \"transactions\"\n\tif receivedLogTx == 1 {\n\t\ttxStr = \"transaction\"\n\t}\n\n\tblueScore, err := block.BlueScore()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Infof(\"Processed %d %s in the last %s (%d %s, blue score %d, %s)\",\n\t\treceivedLogBlocks, blockStr, tDuration, receivedLogTx,\n\t\ttxStr, blueScore, block.MsgBlock().Header.Timestamp)\n\n\treceivedLogBlocks = 0\n\treceivedLogTx = 0\n\tlastBlockLogTime = now\n\treturn nil\n}", "func printBlock(blockHash string) {\n\tmutex.Lock()\n\tblock := blockChain[blockHash]\n\tmutex.Unlock()\n\tindent := \"\"\n\tfor i := 0; i < block.Depth; i++ {\n\t\tindent += \" \"\n\t}\n\tfmt.Printf(\"%sBlockTransactionID: %v\\n\", indent, block.HashBlock.TxID)\n\tfmt.Printf(\"%sBlock.Hash :%x\\n\", indent, block.Hash)\n\tfmt.Printf(\"%sBlock.Depth :%v\\n\", indent, block.Depth)\n\tfmt.Printf(\"%sBlock.ChildrenHashes :%x\\n\", indent, block.ChildrenHashes)\n\tfmt.Printf(\"%sBlock.PutSet :%v\\n\", indent, block.PutSet)\n\thashBlock := block.HashBlock\n\tfmt.Printf(\"%sBlock.HashBlock.ParentHash :%x\\n\", indent, hashBlock.ParentHash)\n\tfmt.Printf(\"%sBlock.HashBlock.NodeID :%v\\n\\n\", indent, hashBlock.NodeID)\n\tfor _, childHash := range block.ChildrenHashes {\n\t\tprintBlock(childHash)\n\t}\n}", "func logFilterBlocksResp(block wtxmgr.BlockMeta,\n\tresp *chain.FilterBlocksResponse) {\n\n\tif log.Level() < pktlog.LevelDebug {\n\t\t// Nothing here runs unless debug level logging\n\t\treturn\n\t}\n\n\t// Log the number of external addresses found in this block.\n\tvar nFoundExternal int\n\tfor _, indexes := range resp.FoundExternalAddrs {\n\t\tnFoundExternal += len(indexes)\n\t}\n\tif nFoundExternal > 0 {\n\t\tlog.Debugf(\"Recovered %d external addrs at height=%d hash=%v\",\n\t\t\tnFoundExternal, block.Height, block.Hash)\n\t}\n\n\t// Log the number of internal addresses found in this block.\n\tvar nFoundInternal int\n\tfor _, indexes := range resp.FoundInternalAddrs {\n\t\tnFoundInternal += len(indexes)\n\t}\n\tif nFoundInternal > 0 {\n\t\tlog.Debugf(\"Recovered %d internal addrs at height=%d hash=%v\",\n\t\t\tnFoundInternal, block.Height, block.Hash)\n\t}\n\n\t// Log the number of outpoints found in this block.\n\tnFoundOutPoints := len(resp.FoundOutPoints)\n\tif nFoundOutPoints > 0 {\n\t\tlog.Debugf(\"Found %d spends from watched outpoints at \"+\n\t\t\t\"height=%d hash=%v\",\n\t\t\tnFoundOutPoints, block.Height, block.Hash)\n\t}\n}", "func (b *BlockLogger) LogBlockHeight(block *wire.MsgBlock, syncHeight int64) {\n\tb.Lock()\n\tdefer b.Unlock()\n\n\theader := &block.Header\n\tb.receivedLogBlocks++\n\tb.receivedLogTx += int64(len(block.Transactions))\n\tb.receivedLogVotes += int64(header.Voters)\n\tb.receivedLogRevocations += int64(header.Revocations)\n\tb.receivedLogTickets += int64(header.FreshStake)\n\tnow := time.Now()\n\tduration := now.Sub(b.lastBlockLogTime)\n\tif int64(header.Height) < syncHeight && duration < time.Second*10 {\n\t\treturn\n\t}\n\n\t// Truncate the duration to 10s of milliseconds.\n\tdurationMillis := int64(duration / time.Millisecond)\n\ttDuration := 10 * time.Millisecond * time.Duration(durationMillis/10)\n\n\t// Log information about new block height.\n\tblockStr := \"blocks\"\n\tif b.receivedLogBlocks == 1 {\n\t\tblockStr = \"block\"\n\t}\n\ttxStr := \"transactions\"\n\tif b.receivedLogTx == 1 {\n\t\ttxStr = \"transaction\"\n\t}\n\tticketStr := \"tickets\"\n\tif b.receivedLogTickets == 1 {\n\t\tticketStr = \"ticket\"\n\t}\n\trevocationStr := \"revocations\"\n\tif b.receivedLogRevocations == 1 {\n\t\trevocationStr = \"revocation\"\n\t}\n\tvoteStr := \"votes\"\n\tif b.receivedLogVotes == 1 {\n\t\tvoteStr = \"vote\"\n\t}\n\tb.subsystemLogger.Infof(\"%s %d %s in the last %s (%d %s, %d %s, %d %s, \"+\n\t\t\"%d %s, height %d, %s)\", b.progressAction, b.receivedLogBlocks,\n\t\tblockStr, tDuration, b.receivedLogTx, txStr, b.receivedLogTickets,\n\t\tticketStr, b.receivedLogVotes, voteStr, b.receivedLogRevocations,\n\t\trevocationStr, header.Height, header.Timestamp)\n\n\tb.receivedLogBlocks = 0\n\tb.receivedLogTx = 0\n\tb.receivedLogVotes = 0\n\tb.receivedLogTickets = 0\n\tb.receivedLogRevocations = 0\n\tb.lastBlockLogTime = now\n}", "func (bi *blockImporter) logProgress() {\n\tbi.receivedLogBlocks++\n\n\tnow := time.Now()\n\tduration := now.Sub(bi.lastLogTime)\n\tif duration < time.Second*time.Duration(cfg.Progress) {\n\t\treturn\n\t}\n\n\t// Truncate the duration to 10s of milliseconds.\n\tdurationMillis := int64(duration / time.Millisecond)\n\ttDuration := 10 * time.Millisecond * time.Duration(durationMillis/10)\n\n\t// Log information about new block height.\n\tblockStr := \"blocks\"\n\tif bi.receivedLogBlocks == 1 {\n\t\tblockStr = \"block\"\n\t}\n\ttxStr := \"transactions\"\n\tif bi.receivedLogTx == 1 {\n\t\ttxStr = \"transaction\"\n\t}\n\tlog.Infof(\"Processed %d %s in the last %s (%d %s, height %d, %s)\",\n\t\tbi.receivedLogBlocks, blockStr, tDuration, bi.receivedLogTx,\n\t\ttxStr, bi.lastHeight, bi.lastBlockTime)\n\n\tbi.receivedLogBlocks = 0\n\tbi.receivedLogTx = 0\n\tbi.lastLogTime = now\n}", "func (v *NavPrinter) VisitBlockTut(x *model.BlockTut) {\n}", "func (b *Blockchain) Print() {\n\tspew.Dump(b.Blocks)\n}", "func (s *sequencer) dump() {\n\tif logrus.GetLevel() != logrus.TraceLevel {\n\t\treturn\n\t}\n\n\ts.lock.RLock()\n\tdefer s.lock.RUnlock()\n\n\tfor height := range s.blockPool {\n\t\tblk, err := s.get(height)\n\t\tif err == nil {\n\t\t\tlog.WithField(\"hash\", hex.EncodeToString(blk.Header.Hash)).\n\t\t\t\tWithField(\"height\", blk.Header.Height).\n\t\t\t\tTrace(\"sequencer item\")\n\t\t}\n\t}\n}", "func block(c echo.Context) error {\n\tpprof.Handler(\"block\").ServeHTTP(c.Response().Writer, c.Request())\n\treturn nil\n}", "func livenessprintblock(lv *Liveness, bb *BasicBlock) {\n\tfmt.Printf(\"basic block %d\\n\", bb.rpo)\n\n\tfmt.Printf(\"\\tpred:\")\n\tfor _, pred := range bb.pred {\n\t\tfmt.Printf(\" %d\", pred.rpo)\n\t}\n\tfmt.Printf(\"\\n\")\n\n\tfmt.Printf(\"\\tsucc:\")\n\tfor _, succ := range bb.succ {\n\t\tfmt.Printf(\" %d\", succ.rpo)\n\t}\n\tfmt.Printf(\"\\n\")\n\n\tprintvars(\"\\tuevar\", bb.uevar, []*Node(lv.vars))\n\tprintvars(\"\\tvarkill\", bb.varkill, []*Node(lv.vars))\n\tprintvars(\"\\tlivein\", bb.livein, []*Node(lv.vars))\n\tprintvars(\"\\tliveout\", bb.liveout, []*Node(lv.vars))\n\tprintvars(\"\\tavarinit\", bb.avarinit, []*Node(lv.vars))\n\tprintvars(\"\\tavarinitany\", bb.avarinitany, []*Node(lv.vars))\n\tprintvars(\"\\tavarinitall\", bb.avarinitall, []*Node(lv.vars))\n\n\tfmt.Printf(\"\\tprog:\\n\")\n\tfor prog := bb.first; ; prog = prog.Link {\n\t\tfmt.Printf(\"\\t\\t%v\", prog)\n\t\tif prog.As == obj.APCDATA && prog.From.Offset == obj.PCDATA_StackMapIndex {\n\t\t\tpos := int32(prog.To.Offset)\n\t\t\tlive := lv.livepointers[pos]\n\t\t\tfmt.Printf(\" \")\n\t\t\tbvprint(live)\n\t\t}\n\n\t\tfmt.Printf(\"\\n\")\n\t\tif prog == bb.last {\n\t\t\tbreak\n\t\t}\n\t}\n}", "func printBlockList(blobClient *storage.BlobStorageClient, containerName, blockBlobName string) error {\n\tfmt.Println(\"Get block list...\")\n\tlist, err := blobClient.GetBlockList(containerName, blockBlobName, storage.BlockListTypeAll)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfmt.Printf(\"Block blob '%v' block list\\n\", blockBlobName)\n\tfmt.Println(\"\\tCommitted Blocks' IDs\")\n\tfor _, b := range list.CommittedBlocks {\n\t\tfmt.Printf(\"\\t\\t%v\\n\", b.Name)\n\t}\n\tfmt.Println(\"\\tUncommited Blocks' IDs\")\n\tfor _, b := range list.UncommittedBlocks {\n\t\tfmt.Printf(\"\\t\\t%v\\n\", b.Name)\n\t}\n\treturn nil\n}", "func (a *API) PrintBlock(number uint64) (string, error) {\n\tblock, err := a.backend.BlockByNumber(rpctypes.BlockNumber(number))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn spew.Sdump(block), nil\n}", "func printblock(bb *BasicBlock) {\n\tfmt.Printf(\"basic block %d\\n\", bb.rpo)\n\tfmt.Printf(\"\\tpred:\")\n\tfor _, pred := range bb.pred {\n\t\tfmt.Printf(\" %d\", pred.rpo)\n\t}\n\tfmt.Printf(\"\\n\")\n\tfmt.Printf(\"\\tsucc:\")\n\tfor _, succ := range bb.succ {\n\t\tfmt.Printf(\" %d\", succ.rpo)\n\t}\n\tfmt.Printf(\"\\n\")\n\tfmt.Printf(\"\\tprog:\\n\")\n\tfor prog := bb.first; ; prog = prog.Link {\n\t\tfmt.Printf(\"\\t\\t%v\\n\", prog)\n\t\tif prog == bb.last {\n\t\t\tbreak\n\t\t}\n\t}\n}", "func\tprint_block(ant Ant, matrix [][]uint8, x int, y int) {\n\tif ant.X == x && ant.Y == y {\n\t\tgoterm.Printf(\"%s\", goterm.Color(\"*\", goterm.RED))\n\t} else if matrix[y][x] == 0 {\n\t\tgoterm.Printf(\"%s\", goterm.Color(\".\", goterm.WHITE))\n\t} else {\n\t\tgoterm.Printf(\"%s\", goterm.Color(\".\", goterm.BLACK))\n\t}\n}", "func (st *LogInfo) ReadBlock(readBuf *codec.Reader, tag byte, require bool) error {\n\tvar (\n\t\terr error\n\t\thave bool\n\t)\n\tst.ResetDefault()\n\n\thave, err = readBuf.SkipTo(codec.StructBegin, tag, require)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !have {\n\t\tif require {\n\t\t\treturn fmt.Errorf(\"require LogInfo, but not exist. tag %d\", tag)\n\t\t}\n\t\treturn nil\n\t}\n\n\terr = st.ReadFrom(readBuf)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = readBuf.SkipToStructEnd()\n\tif err != nil {\n\t\treturn err\n\t}\n\t_ = have\n\treturn nil\n}", "func printBlockChain() {\n\tmutex.Lock()\n\tgenesisBlock := blockChain[genesisHash]\n\tmutex.Unlock()\n\tfmt.Printf(\"GenesisBlockHash: %x\\n\", genesisBlock.Hash)\n\tfmt.Printf(\"GenesisBlockChildren: %x\\n\\n\", genesisBlock.ChildrenHashes)\n\tfor _, childHash := range genesisBlock.ChildrenHashes {\n\t\tprintBlock(childHash)\n\t}\n}", "func (t *Tortoise) OnBlock(header types.BlockHeader) {\n\tstart := time.Now()\n\tt.mu.Lock()\n\tdefer t.mu.Unlock()\n\twaitBlockDuration.Observe(float64(time.Since(start).Nanoseconds()))\n\tt.trtl.onBlock(header, true, false)\n\tif t.tracer != nil {\n\t\tt.tracer.On(&BlockTrace{Header: header})\n\t}\n}", "func (cs *Service) ProduceBlock() *Block {\n\tconsole.Infof(\"chain.Service.ProduceBlock() >> log.Len = %d\", len(cs.LogPool))\n\n\tlogLen := len(cs.LogPool)\n\tb := NewBlock(cs.C.blockNumber)\n\tfor i := 0; i < logLen; i++ {\n\t\tb.AddLog(<-cs.LogPool)\n\t}\n\treturn b\n}", "func (B block) String() string {\n\treturn fmt.Sprintf(\"{\\n\\tindex:%v,\\n\\ttimestamp:%v,\\n\\tproof:%v,\\n\\tpreviousHash:%v,\\n\\ttransactions:\\n\\t\\t%v\\n}\", B.index, B.timestamp, B.proof, B.previousHash, B.transactions)\n}", "func blockDetails(block *btcutil.Block, txIndex int) *btcjson.BlockDetails {\n\tif block == nil {\n\t\treturn nil\n\t}\n\treturn &btcjson.BlockDetails{\n\t\tHeight: block.Height(),\n\t\tHash: block.Hash().String(),\n\t\tIndex: txIndex,\n\t\tTime: block.MsgBlock().Header.Timestamp.Unix(),\n\t}\n}", "func (h HTTPHandler) HandleBlockInfo(w http.ResponseWriter, r *http.Request) {\n\terr := processJWT(r, false, h.secret)\n\tif err != nil {\n\t\thttp.Error(w, \"{\\\"message\\\": \\\"\"+err.Error()+\"\\\"}\", 401)\n\t\treturn\n\t}\n\n\tvars := mux.Vars(r)\n\tblockId, err := hex.DecodeString(vars[\"blockId\"])\n\n\tif err != nil {\n\t\thttp.Error(w, \"{\\\"message\\\": \\\"invalid block ID\\\"}\", 400)\n\t\treturn\n\t}\n\n\tblockchainPeer, err := getBlockchainById(h.bf, vars[\"blockchainId\"])\n\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), 400)\n\t\treturn\n\t}\n\n\tif blockchainPeer == nil {\n\t\thttp.Error(w, \"{\\\"message\\\": \\\"blockchain doesn't exist\\\"}\", 404)\n\t\treturn\n\t}\n\n\tvar block *blockchain.Block\n\n\terr = blockchainPeer.Db.View(func(dbtx *bolt.Tx) error {\n\t\tb := dbtx.Bucket([]byte(blockchain.BlocksBucket))\n\n\t\tif b == nil {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"route\": \"HandleBlockInfo\",\n\t\t\t\t\"address\": r.Header.Get(\"address\"),\n\t\t\t}).Warn(\"bucket doesn't exist\")\n\t\t\treturn errors.New(\"block doesn't exist\")\n\t\t}\n\n\t\tencodedBlock := b.Get(blockId)\n\n\t\tif encodedBlock == nil {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"route\": \"HandleBlockInfo\",\n\t\t\t\t\"address\": r.Header.Get(\"address\"),\n\t\t\t}).Error(\"block doesn't exist\")\n\t\t\treturn errors.New(\"block doesn't exist\")\n\t\t}\n\t\tblock = blockchain.DeserializeBlock(encodedBlock)\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\thttp.Error(w, \"{\\\"message\\\": \\\"block doesn't exist\\\"}\", 404)\n\t\treturn\n\t}\n\n\tblockInfoResponse := BlockInfo{BlockchainId: vars[\"blockchainId\"], BlockId: fmt.Sprintf(\"%x\", block.Hash), PrevBlockId: fmt.Sprintf(\"%x\", block.PrevBlockHash), BlockHeight: block.Height, TotalTransactions: block.TotalTransactions}\n\n\tmustEncode(w, blockInfoResponse)\n}", "func (cli *CLI) printBlocks() {\n\tbc := blockchain.InitBlockChain(\"\")\n\tdefer bc.DB.Close()\n\titer := bc.NewIterator()\n\n\t// iterate over blocks\n\tfor {\n\t\tblock := iter.Next()\n\n\t\tfmt.Printf(\"\\nPrevious Hash: %x\\n\", block.PrevHash)\n\t\tfmt.Printf(\"Hash: %x\\n\", block.Hash)\n\n\t\tpow := blockchain.NewProof(block)\n\t\tfmt.Printf(\"PoW: %s\\n\", strconv.FormatBool(pow.Validate()))\n\n\t\tfor _, tx := range block.Transactions {\n\t\t\tfmt.Println(tx)\n\t\t}\n\n\t\t// break once PrevHash is empty (Genesis block has been reached)\n\t\tif len(block.PrevHash) == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (b Block) ToString() string {\n\treturn fmt.Sprintf(\"Index: %d, TimeStamp: %s, BPM: %d, Hash: %x, PrevHash: %x\", b.Index, b.Timestamp, b.BPM, b.hash, b.prevHash)\n}", "func (app *BurrowMint) BeginBlock(hash []byte, header *abci.Header) {\n\n}", "func (d SmartCardData) PrintLog() {\r\n\tlog.Printf(\"Request: Class:%d, Instruction:%d, Param1:%d, Param2:%d, data:%s\", d.Cls, d.Ins, d.P1, d.P2, d.Data)\r\n}", "func (log *PbftLog) AddBlock(block *types.Block) {\n\tlog.blocks.Add(block)\n}", "func (_AnchorChain *AnchorChainSession) ViewBlock(i *big.Int) (string, error) {\n\treturn _AnchorChain.Contract.ViewBlock(&_AnchorChain.CallOpts, i)\n}", "func (_AnchorChain *AnchorChainCallerSession) ViewBlock(i *big.Int) (string, error) {\n\treturn _AnchorChain.Contract.ViewBlock(&_AnchorChain.CallOpts, i)\n}", "func TestBlock(t *testing.T) {\n\tdefer check(t)\n\tcontent := \"hello world!\"\n\treq := &showcasepb.BlockRequest{\n\t\tResponseDelay: &durationpb.Duration{Nanos: 1000},\n\t\tResponse: &showcasepb.BlockRequest_Success{\n\t\t\tSuccess: &showcasepb.BlockResponse{Content: content},\n\t\t},\n\t}\n\tresp, err := echo.Block(context.Background(), req)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif resp.GetContent() != content {\n\t\tt.Errorf(\"Block() = %q, want %q\", resp.GetContent(), content)\n\t}\n}", "func FmtBlock(data []byte) string {\n\tvar builder strings.Builder\n\tfor i := 0; i < NumBytesPerBlock; i++ {\n\t\tbuilder.WriteString(fmt.Sprintf(\"%s\", hex.EncodeToString(data[i:i+1])))\n\t\tif i != NumBytesPerBlock-1 {\n\t\t\tbuilder.WriteString(\" \")\n\t\t}\n\t}\n\treturn builder.String()\n}", "func getBlock(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {\n\n\thash, err := chainhash.NewHashFromStr(ps.ByName(\"hash\"))\n\tif err != nil {\n\t\tlog.Printf(\"could not convert string to hash: %s\\n\", err)\n\t}\n\n\tblock, err := dao.GetBlock(hash)\n\tif err != nil {\n\t\tfmt.Fprintf(w, \"Not found\")\n\t\treturn\n\t}\n\t//block.Confirmations = getBlockConfirmations(block)\n\t//block.Confirmations = getBlockConfirmations(*block) // needs dynamic calculation\n\n\t//apiblock, err := insight.ConvertToInsightBlock(block)\n\n\tjson.NewEncoder(w).Encode(&block)\n}", "func (l *Ledger) FormatBlock(txList []*pb.Transaction,\n\tproposer []byte, ecdsaPk *ecdsa.PrivateKey, /*矿工的公钥私钥*/\n\ttimestamp int64, curTerm int64, curBlockNum int64,\n\tpreHash []byte, utxoTotal *big.Int) (*pb.InternalBlock, error) {\n\treturn l.formatBlock(txList, proposer, ecdsaPk, timestamp, curTerm, curBlockNum, preHash, 0, utxoTotal, true, nil, nil, 0)\n}", "func (b *Block) String() string {\n\treturn fmt.Sprintf(\"[file %s, block %d]\", b.FileName, b.BlockNum)\n}", "func (_AnchorChain *AnchorChainCaller) ViewBlock(opts *bind.CallOpts, i *big.Int) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _AnchorChain.contract.Call(opts, out, \"viewBlock\", i)\n\treturn *ret0, err\n}", "func Info(data []byte) {\n\tlog.Print(\"INFO: \", string(data))\n}", "func ToLog(b *Block) {\n\tfor {\n\t\tselect {\n\t\tcase msg := <-b.InChan:\n\t\t\tout, err := json.Marshal(msg.Msg)\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(\"could not marshal json\")\n\t\t\t}\n\t\t\tlog.Println(string(out))\n\t\tcase <-b.QuitChan:\n\t\t\tquit(b)\n\t\t\treturn\n\t\t}\n\t}\n}", "func testBlockVerbose(blockHash, prevHash *chainhash.Hash, confirmations, height int64) *btcjson.GetBlockVerboseResult {\n\treturn &btcjson.GetBlockVerboseResult{\n\t\tHash: blockHash.String(),\n\t\tConfirmations: confirmations,\n\t\tHeight: height,\n\t\tPreviousHash: prevHash.String(),\n\t}\n}", "func (b *Block) String() string {\n\treturn fmt.Sprintf(\n\t\t\"[file %q, block %d]\",\n\t\tb.Filename(),\n\t\tb.Number(),\n\t)\n}", "func main() {\n\n\t// Connection to leveldb\n\t db, _ := leveldb.OpenFile(\"/home/name/.ethereum/geth/chaindata\", nil) // change the path to your local chaindata path\n file1, _ := os.OpenFile(os.Args[3], os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)\n \n defer file1.Close()\n \n writer1 := csv.NewWriter(file1)\n \n defer writer1.Flush()\n \n from_block_num, _ := strconv.Atoi(os.Args[1])\n end_block_num, _ := strconv.Atoi(os.Args[2])\n \n for i:= from_block_num; i< end_block_num; i++ {\n //block number\n blockNumber := make([]byte, 8)\n binary.BigEndian.PutUint64(blockNumber, uint64(i))\n //block hash\n hashKey := append(headerPrefix, blockNumber...)\n hashKey = append(hashKey, numSuffix...)\n\n blockHash, _ := db.Get(hashKey, nil)\n\n //headerkey\n headerkey := append(headerPrefix, blockNumber...)\n headerkey = append(headerkey, blockHash...)\n //get block header, then I could get the block time and blocknum\n blockHeaderData, _ := db.Get(headerkey, nil)\n header := new(types.Header)\n rlp.Decode(bytes.NewReader(blockHeaderData), header)\n blocktime := header.Time\n blocknum := header.Number\n \n blockReceiptKey := append(blockReceiptsPrefix, blockNumber...)\n blockReceiptKey = append(blockReceiptKey, blockHash...)\n blockReceiptData, _ :=db.Get(blockReceiptKey, nil)\n\n storageReceipts := []*types.ReceiptForStorage{}\n rlp.DecodeBytes(blockReceiptData, &storageReceipts)\n for _, receipt := range storageReceipts {\n Logs := (*types.Receipt)(receipt).Logs\n tx_hash := (*types.Receipt)(receipt).TxHash.Hex()\n if len(Logs) > 0 {\n for _, Log := range Logs{\n if len(Log.Topics) > 0 {\n if Log.Topics[0].Hex() == logTransferSighash.Hex() {\n from := \"\"\n to := \"\"\n amount := new(big.Int)\n if len(Log.Topics) > 2 {\n from = strings.ToLower(common.HexToAddress(Log.Topics[1].Hex()).String())\n to = strings.ToLower(common.HexToAddress(Log.Topics[2].Hex()).String())\n amount.SetBytes(Log.Data)\n } else{\n length := len(Log.Data)/3\n from = strings.ToLower(common.BytesToHash(Log.Data[0:length]).Hex())\n if len(from) < 40 {\n continue\n }\n from = \"0x\"+from[len(from)-40:]\n to = strings.ToLower(common.BytesToHash(Log.Data[length:2*length]).Hex())\n to = \"0x\"+to[len(to)-40:]\n amount.SetBytes(Log.Data[2*length:])\n }\n if from != \"\" && to != \"\" {\n token_addr := strings.ToLower(Log.Address.String())\n var transferEvent []string\n transferEvent = []string{token_addr, from, to, amount.String(), strings.ToLower(tx_hash), blocktime.String(), blocknum.String()}\n \n writer1.Write(transferEvent)\n }\n }\n }\n writer1.Flush()\n }\n }\n }\n }\n}", "func EthloggerPrint(content string) {\n\tlog.Printf(\"[Eth handler] %s\\n\", content)\n}", "func (b *Block) CompressBlock() string {\n return \"height=\" + int32ToString(b.Header.Height) + \", timestamp=\" + int64ToString(b.Header.Timestamp) + \", hash=\" + b.Header.Hash + \", parentHash=\" + b.Header.ParentHash + \", size=\" + int32ToString(b.Header.Size)\n}", "func (m *Manager) statPrint() {\n\tfor {\n\t\tfmt.Printf(\"Customers Today: %03d, In Store: %03d, Shopping: %02d,\"+\n\t\t\t\" At Checkout: %02d, Checkouts Open: %d\\r\",\n\t\t\ttotalNumberOfCustomersToday, totalNumberOfCustomersInStore, numberOfCurrentCustomersShopping,\n\t\t\tnumberOfCurrentCustomersAtCheckout, numberOfCheckoutsOpen)\n\t\ttime.Sleep(time.Millisecond * 40)\n\n\t\tif !m.supermarket.openStatus && totalNumberOfCustomersInStore == 0 {\n\t\t\tfmt.Printf(\"\\n\")\n\t\t\tbreak\n\t\t}\n\t}\n\n\tm.wg.Done()\n}", "func (b *BlockChain) Print() {\n\n\titer := b.GetIterator()\n\n\tfor {\n\t\tb := iter.Next()\n\t\tif b == nil || len(b.PrevBlockHash) == 0 {\n\t\t\tbreak\n\t\t}\n\t\tb.Print()\n\t}\n}", "func (ts *Tipset) Block(miner Miner, winCount int64, msgs ...*ApplicableMessage) {\n\tblock := Block{\n\t\tMinerAddr: miner.MinerActorAddr.ID,\n\t\tWinCount: winCount,\n\t}\n\tfor _, am := range msgs {\n\t\tblock.Messages = append(block.Messages, MustSerialize(am.Message))\n\n\t\t// if we see this message for the first time, add it to the `msgIdx` map and to the `orderMsgs` slice.\n\t\tif _, ok := ts.tss.msgIdx[am.Message.Cid()]; !ok {\n\t\t\tts.tss.msgIdx[am.Message.Cid()] = am\n\t\t\tts.tss.orderedMsgs = append(ts.tss.orderedMsgs, am)\n\t\t}\n\t}\n\n\tts.Blocks = append(ts.Blocks, block)\n}", "func PrintBlockyLogo() {\n\tfmt.Println(`\n::: ::: .::::::::... :::::::::::: \n ::: ::: .:::' ':::: ::: ::: \n ::: ::: ::: ::: .::::.. ..::::::.. ::: .:: ::: :::\n ::: ::: :::.: ::: .::' ':: ::: ....... ::: :::\n ::: .:: ::: ::: ::: ::: ::: ::: ::::::: ::: :::\n ::. ' ::: ::: ::: '::. .:: ::: ':::. ::: ::: ::: \n ::: ::: ::: ::: '::::::::' ::: ':::::::::::' :::::::::::: \n\n:::::::::::::\n:: ::\n:: :: ..::::::.. ::\n:::::::::: ..... :::::::: .::' ':: ::.:::::.\n:: .: :. :: ::: :: ::\n:: ::::::::: :: '::. .:: :: ::\n:: :..... ::. '::::::::' :: ::\n\n ::: ::: ::: \n ::: : ::. ::: :: \n ::: :: :: ::: :: :: \n ::: ::: ::: ::: ..... ..... :::::::: ::.:::::. ..... :: .::\n ::: :: ::: ::: .: :. .: :. :: :: :: .: :. ::.\n ::: : ::: : ::::::::: :: :: :: :: :: ::::::::: ::\n ::: ::: :..... ::....::.. ::. :: :: :..... ::\n\t`)\n}", "func (s *BaseBundListener) EnterBlock(ctx *BlockContext) {}", "func (s *BaseConcertoListener) EnterBlock(ctx *BlockContext) {}", "func Print() {\n\tfmt.Printf(\"Fabric peer server version %s\\n\", metadata.Version)\n}", "func logNode(n *html.Node) {\n switch n.Type {\n case html.ElementNode:\n str := nodeLogger.indent + str(n)\n nodeLogger.Logger.Println(str)\n nodeLogger.indent += \" \"\n default:\n nodeLogger.Logger.Printf(`%sSkipping \"%s\"`, nodeLogger.indent, str(n))\n }\n}", "func infoLog(msg ...interface{}) {\n\tlogLocker.Lock()\n\tdefer logLocker.Unlock()\n\tif *confVerbose {\n\t\tcolor.Cyan(fmt.Sprint(time.Now().Format(\"02_01_06-15.04.05\"), \"[INFOR] ->\", msg))\n\t}\n}", "func TestBlock(t *testing.T) {\n\tl := &Leading{\n\t\tMagic: 0x7425,\n\t\tLenBlock: 0,\n\t}\n\n\tfmt.Println(l)\n\n\th := &chunk.Header{}\n\tfmt.Println(hex.Dump(h.Marshal()))\n\n\tcaller := &chunk.Quater{\n\t\tMain: \"1LVfRcj31E9mGujxUD3nTJjsUPtcczqJnX\",\n\t\tSub: \"send\",\n\t}\n\tcallee := &chunk.Quater{\n\t\tMain: \"1LVfRcj31E9mGujxUD3nTJjsUPtcczqJnX\",\n\t\tSub: \"recv\",\n\t}\n\n\tr := chunk.NewRouting(caller, callee)\n\tfmt.Println(hex.Dump(r.Marshal()))\n\n\tc := &chunk.Content{\n\t\tSha: chunk.GetHash('0'),\n\t\tMime: 0xff,\n\t\tCipher: []byte{},\n\t\tBody: []byte(\"Hello bitmsg\"),\n\t}\n\t//fmt.Println(c)\n\tc.Marshal()\n\tb := NewBlock(*h, *r)\n\tb.AddContent(*c)\n\tfmt.Println(hex.Dump(b.Header.ShaMerkle[:]))\n\tfmt.Println(hex.Dump(b.Marshal()))\n}", "func (s *BasePlSqlParserListener) EnterBlock(ctx *BlockContext) {}", "func (d *DummyLogger) Info(format string) {}", "func FormatBlock(\n\theader tmtypes.Header, size int, gasLimit int64,\n\tgasUsed *big.Int, transactions interface{}, bloom ethtypes.Bloom,\n) map[string]interface{} {\n\tif len(header.DataHash) == 0 {\n\t\theader.DataHash = tmbytes.HexBytes(common.Hash{}.Bytes())\n\t}\n\n\treturn map[string]interface{}{\n\t\t\"number\": hexutil.Uint64(header.Height),\n\t\t\"hash\": hexutil.Bytes(header.Hash()),\n\t\t\"parentHash\": hexutil.Bytes(header.LastBlockID.Hash),\n\t\t\"nonce\": hexutil.Uint64(0), // PoW specific\n\t\t\"sha3Uncles\": common.Hash{}, // No uncles in Tendermint\n\t\t\"logsBloom\": bloom,\n\t\t\"transactionsRoot\": hexutil.Bytes(header.DataHash),\n\t\t\"stateRoot\": hexutil.Bytes(header.AppHash),\n\t\t\"miner\": common.Address{},\n\t\t\"mixHash\": common.Hash{},\n\t\t\"difficulty\": 0,\n\t\t\"totalDifficulty\": 0,\n\t\t\"extraData\": hexutil.Uint64(0),\n\t\t\"size\": hexutil.Uint64(size),\n\t\t\"gasLimit\": hexutil.Uint64(gasLimit), // Static gas limit\n\t\t\"gasUsed\": (*hexutil.Big)(gasUsed),\n\t\t\"timestamp\": hexutil.Uint64(header.Time.Unix()),\n\t\t\"transactions\": transactions.([]common.Hash),\n\t\t\"uncles\": []string{},\n\t\t\"receiptsRoot\": common.Hash{},\n\t}\n}", "func (masterfile *MasterFile) Print(spacing int) {\n\tlog.Debug(\"%*sMagic : %s\", spacing, \"\", masterfile.Magic)\n\tlog.Debug(\"%*sMD5 : %s\", spacing, \"\", masterfile.Md5)\n\tlog.Debug(\"%*sGeneration : %d\", spacing, \"\", masterfile.Generation)\n}", "func BlockDisplay(w io.Writer) metrics.Processors {\n\treturn BlockDisplayWith(w, \"Message:\", nil)\n}", "func BlockDisplay(w io.Writer) metrics.Processors {\n\treturn BlockDisplayWith(w, \"Message:\", nil)\n}", "func (h blockHeader) String() string {\n\treturn fmt.Sprintf(\"Type: %d, Size: %d, Last:%t\", (h>>1)&3, h>>3, h&1 == 1)\n}", "func (ring *ringBuffer) dump(out io.Writer) {\n\tring.mutex.Lock()\n\t/* print out the top-level fields */\n\tfmt.Fprintln(out, \"datagram_size = \", ring.datagramSize)\n\tfmt.Fprintln(out, \"base_data = \", ring.baseData)\n\tfmt.Fprintln(out, \"count_data = \", ring.countData)\n\tfmt.Fprintln(out, \"count_reserved = \", ring.countReserved)\n\tfmt.Fprintln(out, \"data_ready = \", ring.dataReady)\n\tfmt.Fprintln(out, \"space_ready = \", ring.spaceReady)\n\n\t/* print out the block list */\n\tfmt.Fprint(out, \"block list = [\")\n\tfor index := ring.baseData; index < ring.baseData+ring.countData; index++ {\n\t\toffset := ((index % MAX_BLOCKS_QUEUED) * ring.datagramSize)\n\t\td := binary.BigEndian.Uint32(ring.datagrams[offset:])\n\t\tfmt.Fprint(out, d)\n\t}\n\tfmt.Fprintln(out, \"]\")\n\tring.mutex.Unlock()\n}", "func printcfg(cfg []*BasicBlock) {\n\tfor _, bb := range cfg {\n\t\tprintblock(bb)\n\t}\n}", "func (s *SkipList) print() {\n\tx := s.Header\n\t// fmt.Println(s.level, s.max)\n\tcount := 0\n\tfmt.Println(\"Height:\", s.level+1)\n\tfor x.Forward[0] != nil {\n\t\tfmt.Println(count, len(x.Forward), x.Forward[0].Key, x.Forward[0].Value)\n\t\tx = x.Forward[0]\n\t\tcount++\n\t}\n}", "func NewBlock(chain uint64, producer Address) *StBlock {\n\tvar hashPowerLimit uint64\n\tvar blockInterval uint64\n\tvar pStat BaseInfo\n\tout := new(StBlock)\n\tgetDataFormDB(chain, dbStat{}, []byte{StatBaseInfo}, &pStat)\n\tgetDataFormDB(chain, dbStat{}, []byte{StatHashPower}, &hashPowerLimit)\n\tgetDataFormDB(chain, dbStat{}, []byte{StatBlockInterval}, &blockInterval)\n\n\tif pStat.ID == 0 {\n\t\tlog.Println(\"fail to get the last block. chain:\", chain)\n\t\treturn nil\n\t}\n\n\thashPowerLimit = hashPowerLimit / 1000\n\tif hashPowerLimit < minHPLimit {\n\t\thashPowerLimit = minHPLimit\n\t}\n\n\tout.HashpowerLimit = hashPowerLimit\n\n\tif pStat.ID == 1 && chain > 1 {\n\t\tpStat.Time = pStat.Time + blockSyncMax + blockSyncMin + TimeSecond\n\t} else {\n\t\tpStat.Time += blockInterval\n\t}\n\n\tout.Previous = pStat.Key\n\tout.Producer = producer\n\tout.Time = pStat.Time\n\n\tout.Chain = chain\n\tout.Index = pStat.ID + 1\n\n\tif pStat.Chain > 1 {\n\t\tvar key Hash\n\t\tvar tmp BlockInfo\n\t\tgetDataFormLog(chain/2, logBlockInfo{}, runtime.Encode(pStat.ParentID+1), &key)\n\t\tgetDataFormLog(chain/2, logBlockInfo{}, key[:], &tmp)\n\t\tif out.Index != 2 && !key.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\tvar key2 Hash\n\t\t\tgetDataFormLog(chain/2, logBlockInfo{}, runtime.Encode(pStat.ParentID+2), &key2)\n\t\t\tgetDataFormLog(chain/2, logBlockInfo{}, key2[:], &tmp)\n\t\t\tif !key2.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\t\tout.Parent = key2\n\t\t\t} else {\n\t\t\t\tout.Parent = key\n\t\t\t}\n\t\t\t// assert(out.Time-tmp.Time <= blockSyncMax)\n\t\t} else {\n\t\t\tgetDataFormLog(chain/2, logBlockInfo{}, runtime.Encode(pStat.ParentID), &key)\n\t\t\tout.Parent = key\n\t\t}\n\t}\n\tif pStat.LeftChildID > 0 {\n\t\tvar key Hash\n\t\tvar tmp BlockInfo\n\t\tgetDataFormLog(2*chain, logBlockInfo{}, runtime.Encode(pStat.LeftChildID+1), &key)\n\t\tgetDataFormLog(2*chain, logBlockInfo{}, key[:], &tmp)\n\t\tif !key.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\tvar key2 Hash\n\t\t\tgetDataFormLog(2*chain, logBlockInfo{}, runtime.Encode(pStat.LeftChildID+2), &key2)\n\t\t\tgetDataFormLog(2*chain, logBlockInfo{}, key2[:], &tmp)\n\t\t\tif !key2.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\t\tout.LeftChild = key2\n\t\t\t} else {\n\t\t\t\tout.LeftChild = key\n\t\t\t}\n\t\t\t// assert(out.Time-tmp.Time <= blockSyncMax)\n\t\t} else if pStat.LeftChildID == 1 {\n\t\t\tgetDataFormLog(chain, logBlockInfo{}, runtime.Encode(pStat.LeftChildID), &key)\n\t\t\tout.LeftChild = key\n\t\t} else {\n\t\t\tgetDataFormLog(2*chain, logBlockInfo{}, runtime.Encode(pStat.LeftChildID), &key)\n\t\t\tout.LeftChild = key\n\t\t}\n\t}\n\tif pStat.RightChildID > 0 {\n\t\tvar key Hash\n\t\tvar tmp BlockInfo\n\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, runtime.Encode(pStat.RightChildID+1), &key)\n\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, key[:], &tmp)\n\t\tif !key.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\tvar key2 Hash\n\t\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, runtime.Encode(pStat.RightChildID+2), &key2)\n\t\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, key2[:], &tmp)\n\t\t\tif !key2.Empty() && out.Time > tmp.Time && out.Time-tmp.Time > blockSyncMin {\n\t\t\t\tout.RightChild = key2\n\t\t\t} else {\n\t\t\t\tout.RightChild = key\n\t\t\t}\n\t\t\t// assert(out.Time-tmp.Time <= blockSyncMax)\n\t\t} else if pStat.RightChildID == 1 {\n\t\t\tgetDataFormLog(chain, logBlockInfo{}, runtime.Encode(pStat.RightChildID), &key)\n\t\t\tout.RightChild = key\n\t\t} else {\n\t\t\tgetDataFormLog(2*chain+1, logBlockInfo{}, runtime.Encode(pStat.RightChildID), &key)\n\t\t\tout.RightChild = key\n\t\t}\n\t}\n\n\treturn out\n}", "func (self *bipbuf_t) Print() {\n\tfmt.Printf(\"data:[%s %s],len:%d,size:%d,a_start:%d,a_end:%d,b_end:%d,b_inuse:%v,Used:%d,Unused:%d\\n\",\n\t\tstring(self.data[0:0]),string(self.data[0:0]),len(self.data), self.size, self.a_start, self.a_end, self.b_end, self.b_inuse,\n\t\tself.Used(), self.Unused())\n}", "func printCLC(net, transport gopacket.Flow, clc clc.Message) {\n\tclcFmt := \"%s%s:%s -> %s:%s: %s\\n\"\n\tt := \"\"\n\n\tif *showTimestamps {\n\t\tt = time.Now().Format(\"15:04:05.000000 \")\n\t}\n\tif *showReserved {\n\t\tfmt.Fprintf(stdout, clcFmt, t, net.Src(), transport.Src(),\n\t\t\tnet.Dst(), transport.Dst(), clc.Reserved())\n\t} else {\n\t\tfmt.Fprintf(stdout, clcFmt, t, net.Src(), transport.Src(),\n\t\t\tnet.Dst(), transport.Dst(), clc)\n\t}\n\tif *showDumps {\n\t\tfmt.Fprintf(stdout, \"%s\", clc.Dump())\n\t}\n}", "func (bo *BlockObject) toString() string {\n\treturn fmt.Sprintf(\"<Block: %s>\", bo.instructionSet.filename)\n}", "func LogRawInfo(app string) {\n\tlog.Infof(\"Welcome to %s.\", app)\n\tlog.Infof(\"Release Version: %s\", Version)\n\tlog.Infof(\"Git Commit Hash: %s\", GitHash)\n\tlog.Infof(\"Git Branch: %s\", GitBranch)\n\tlog.Infof(\"UTC Build Time: %s\", BuildTS)\n}", "func (s *BasevhdlListener) EnterBlock_header(ctx *Block_headerContext) {}", "func Info(msg string) {\n log.Info(msg)\n}", "func (s *AdapterSuite) reportLogChunks(clientLog *client.Log) {\n\tfor chunk, ok := clientLog.GetChunk(); ok; chunk, ok = clientLog.GetChunk() {\n\t\tlog.Print(string(chunk))\n\t}\n}", "func (s *session) log(info ...interface{}) {\n\tpreamble := fmt.Sprintf(\"IMAP (%s) \", s.id)\n\tmessage := []interface{}{preamble}\n\tmessage = append(message, info...)\n\tlog.Print(message...)\n}", "func (s *Logger) Print(level log.Level, depth int, kvpair ...interface{}) {\n\tif len(kvpair) == 0 {\n\t\treturn\n\t}\n\tif len(kvpair)%2 != 0 {\n\t\tkvpair = append(kvpair[:len(kvpair)-2], append([]interface{}{\"\"}, kvpair[len(kvpair)-2:]...)...)\n\t}\n\tbuf := s.pool.Get().(*bytes.Buffer)\n\tswitch level {\n\tcase log.LevelDebug:\n\t\tbuf.WriteString(fmt.Sprintf(\"%-6s \", fmt.Sprintf(\"%s \", log.LevelDebug)))\n\tcase log.LevelInfo:\n\t\tbuf.WriteString(fmt.Sprintf(\"%-6s \", fmt.Sprintf(\"%s \", log.LevelInfo)))\n\tcase log.LevelWarn:\n\t\tbuf.WriteString(fmt.Sprintf(\"%-6s \", fmt.Sprintf(\"%s \", log.LevelWarn)))\n\tcase log.LevelError:\n\t\tbuf.WriteString(fmt.Sprintf(\"%-6s \", fmt.Sprintf(\"%s \", log.LevelError)))\n\t}\n\tif _, file, line, ok := runtime.Caller(baseSkip + depth); ok {\n\t\tbuf.WriteString(fmt.Sprintf(\"[source=%s:%d] \", s.stackTrace(file), line))\n\t}\n\tvar (\n\t\tstack stackTracer\n\t)\n\tfor i := 0; i < len(kvpair)-2; i += 2 {\n\t\tif kvpair[i] == \"error\" {\n\t\t\tv, ok := kvpair[i+1].(stackTracer)\n\t\t\tif ok {\n\t\t\t\tstack = v\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tfmt.Fprint(buf, fmt.Sprintf(\"[%s=%s] \", kvpair[i], kvpair[i+1]))\n\t}\n\tfmt.Fprint(buf, fmt.Sprintf(\"%s\", kvpair[len(kvpair)-1]))\n\tif stack != nil {\n\t\tfmt.Fprint(buf, fmt.Sprintf(\"\\nstack trace:%+v\\n\", stack.StackTrace()))\n\t}\n\ts.log.Println(buf.String())\n\tbuf.Reset()\n\ts.pool.Put(buf)\n}", "func (t *Tortoise) OnValidBlock(header types.BlockHeader) {\n\tstart := time.Now()\n\tt.mu.Lock()\n\tdefer t.mu.Unlock()\n\twaitBlockDuration.Observe(float64(time.Since(start).Nanoseconds()))\n\tt.trtl.onBlock(header, true, true)\n\tif t.tracer != nil {\n\t\tt.tracer.On(&BlockTrace{Header: header, Valid: true})\n\t}\n}", "func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}", "func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}", "func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}", "func (app AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}", "func (l Log) ShowLog () {\n fmt.Printf(\"\\n\\n----------------------------------------------------------------------------\\n\")\n fmt.Printf(\" ACTIVITY LOG \\n\")\n for i := range l.Action {\n fmt.Printf(\"%s\\n\", l.Action[i])\n }\n fmt.Printf(\"____________________________________________________________________________\\n\")\n}", "func printPacket(packet rpc.LogMessage, prefix string, isCompressed bool, compressor compressor.Compressor) {\n\tif isCompressed {\n\t\tbuffer, err := compressor.Decompress(packet.Buffer)\n\t\tif err != nil {\n\t\t\tlog.Panic(\"Packet decompress failed\")\n\t\t}\n\t\tpacket.Buffer = buffer\n\t}\n\twp := uint64(0)\n\tfor i, info := range packet.Info {\n\t\tfilename := packet.Files.MapTable[packet.Files.Indexes[i]]\n\t\tlog.Printf(\"[%s:%s] %s (size: %d)\\n\", prefix, filename, string(packet.Buffer[wp:wp+info.Length]), len(packet.Buffer))\n\t\twp += info.Length\n\t}\n}", "func FmtAuthBlock(auth *AuthBlock) string {\n\treturn fmt.Sprintf(\"KeyA=%s KeyB=%s BlocksAccess=(%s)\\n\", FmtKey(auth.KeyA), FmtKey(auth.KeyB), FmtBlocksAccess(auth.Permissions))\n}", "func (b *Block) String() string {\n\tvar t string\n\tfor _, transaction := range b.Transactions {\n\t\tt += fmt.Sprintf(\"%s\\n\", transaction.String())\n\t}\n\treturn t + b.PreviousHash\n}", "func Log(logType, content interface{}) {\n\t_time := getTime()\n\tfmt.Printf(\"\\n%v [%v] %v\", _time, logType, content)\n}", "func (s *BaseCymbolListener) EnterBlock(ctx *BlockContext) {}", "func (layout Layout) blockOffset(level int, index int64) int64 {\n\treturn layout.levelOffset[level] + index*layout.blockSize\n}", "func (p *HTTPPool) Log(format string,v ...interface{}) {\n\tlog.Printf(\"[Server %s]%s\",p.self,fmt.Sprintf(format,v...))\n}", "func I(format string, args ...interface{}) { infodeps(sentry.CaptureMessage, 3, format, args...) }", "func (s StatsEntry) BlockIO() string {\n\tif s.err != nil {\n\t\treturn fmt.Sprintf(\"--\")\n\t}\n\treturn fmt.Sprintf(\"%s / %s\", units.HumanSizeWithPrecision(s.blockRead, 3), units.HumanSizeWithPrecision(s.blockWrite, 3))\n}", "func (ui *UI) Block(s string, options ...lipgloss.WhitespaceOption) string {\n\treturn lipgloss.PlaceHorizontal(80, lipgloss.Center, s, options...)\n}", "func BlockFailed(blockNumber uint64){\r\n\r\n}", "func (s *BasevhdlListener) EnterBlock_statement(ctx *Block_statementContext) {}", "func (pp *PacketParser) Log(lc LogComposer, _ time.Duration) {\n\tlc.Finish(\"\\tmax in channel: %d/%d, sentences split: %d\",\n\t\tpp.maxInChan, cap(pp.async), pp.sentencesSplit)\n\tpp.sentencesSplit = 0\n\tpp.maxInChan = 0\n}", "func (hf *historyFile) Section(name, info string) {\n\thf.l.SetFlags(0)\n\thf.l.Println(\"*** \" + name + \" - \" + info)\n\thf.l.SetFlags(logFlags)\n}", "func (rt *recvTxOut) Block() *BlockDetails {\n\treturn rt.block\n}", "func (*BlockParams) Descriptor() ([]byte, []int) {\n\treturn file_tm_replay_proto_rawDescGZIP(), []int{11}\n}", "func (l *Ledger) FormatFakeBlock(txList []*pb.Transaction,\n\tproposer []byte, ecdsaPk *ecdsa.PrivateKey, /*矿工的公钥私钥*/\n\ttimestamp int64, curTerm int64, curBlockNum int64,\n\tpreHash []byte, utxoTotal *big.Int, blockHeight int64) (*pb.InternalBlock, error) {\n\treturn l.formatBlock(txList, proposer, ecdsaPk, timestamp, curTerm, curBlockNum, preHash, 0, utxoTotal, false, nil, nil, blockHeight)\n}", "func BlockDisplayWith(w io.Writer, header string, filterFn func(metrics.Entry) bool) metrics.Processors {\n\treturn NewEmitter(w, func(en metrics.Entry) []byte {\n\t\tif filterFn != nil && !filterFn(en) {\n\t\t\treturn nil\n\t\t}\n\n\t\tvar bu bytes.Buffer\n\t\tif header != \"\" {\n\t\t\tfmt.Fprintf(&bu, \"%s %+s\\n\", green.Sprint(header), printAtLevel(en.Level, en.Message))\n\t\t} else {\n\t\t\tfmt.Fprintf(&bu, \"%+s\\n\", printAtLevel(en.Level, en.Message))\n\t\t}\n\n\t\tif en.ID != \"\" {\n\t\t\tfmt.Fprintf(&bu, \"ID: %+s\\n\", printAtLevel(en.Level, en.ID))\n\t\t}\n\n\t\tif en.Function != \"\" {\n\t\t\tfmt.Fprintf(&bu, \"%s: %+s\\n\", green.Sprint(\"Function\"), en.Function)\n\t\t\tfmt.Fprintf(&bu, \"%s: %+s:%d\\n\", green.Sprint(\"File\"), en.File, en.Line)\n\t\t}\n\n\t\tfor key, val := range en.Field {\n\t\t\tvalue := printItem(val)\n\t\t\tkeyLength := len(key) + 2\n\t\t\tvalLength := len(value) + 2\n\n\t\t\tkeyLines := printBlockLine(keyLength)\n\t\t\tvalLines := printBlockLine(valLength)\n\t\t\tspaceLines := printSpaceLine(1)\n\n\t\t\tfmt.Fprintf(&bu, \"+%s+%s+\\n\", keyLines, valLines)\n\t\t\tfmt.Fprintf(&bu, \"|%s%s%s|%s%s%s|\\n\", spaceLines, green.Sprint(key), spaceLines, spaceLines, value, spaceLines)\n\t\t\tfmt.Fprintf(&bu, \"+%s+%s+\", keyLines, valLines)\n\t\t\tfmt.Fprintf(&bu, \"\\n\")\n\t\t}\n\n\t\tbu.WriteString(\"\\n\")\n\t\treturn bu.Bytes()\n\t})\n}", "func (self Block) ToString() string {\n\treturn fmt.Sprintf(\"%x %s %s\", self.PrevHash, self.Name, self.Nonce)\n}", "func (node *Begin) Format(buf *TrackedBuffer) {\n\tbuf.WriteString(\"begin\")\n}", "func (s *BaseGraffleParserListener) EnterBlock_end(ctx *Block_endContext) {}" ]
[ "0.7314222", "0.6935649", "0.678305", "0.6357967", "0.6300318", "0.61575276", "0.6108993", "0.6061079", "0.6044", "0.59945685", "0.5978331", "0.5937402", "0.5936929", "0.59180486", "0.59160495", "0.5888289", "0.58667827", "0.57686156", "0.57345873", "0.56689864", "0.5664615", "0.560964", "0.55154014", "0.5505212", "0.5504691", "0.550314", "0.54943126", "0.54199374", "0.5404096", "0.540123", "0.5379855", "0.5377218", "0.53617054", "0.5342316", "0.5306226", "0.52825207", "0.52775115", "0.52454317", "0.52444404", "0.52400976", "0.52347326", "0.5234353", "0.52257", "0.5214799", "0.5213785", "0.52108175", "0.5206199", "0.5205124", "0.5194762", "0.5192349", "0.5189149", "0.51807296", "0.51657915", "0.51596147", "0.51481014", "0.5139847", "0.51262766", "0.512557", "0.512557", "0.5114829", "0.5110224", "0.5104691", "0.5093309", "0.5087627", "0.50865483", "0.50852585", "0.5084653", "0.5083644", "0.50824577", "0.508101", "0.5077728", "0.5077137", "0.50726473", "0.50719595", "0.50712967", "0.50712967", "0.50712967", "0.50706095", "0.506285", "0.50572014", "0.50558114", "0.5042068", "0.5039787", "0.50392485", "0.5037448", "0.50355005", "0.50166833", "0.5016567", "0.50088733", "0.49998078", "0.4997141", "0.49939126", "0.49849945", "0.4982537", "0.49824876", "0.49746656", "0.49699816", "0.49642885", "0.49629852", "0.49571663" ]
0.6910912
2
NewFlagSet returns a new FlagSet for usage in Config objects.
func NewFlagSet(name string) *FlagSet { return &FlagSet{ FlagSet: pflag.NewFlagSet(name, pflag.ContinueOnError), Name: name, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewFlagSet(flags ...string) FlagSet {\n\tfs := make(FlagSet, len(flags))\n\tfor _, v := range flags {\n\t\tfs[v] = true\n\t}\n\treturn fs\n}", "func NewFlagSet(name string, args []string, flags []Flag) (*FlagSet, error) {\n\tset := flag.NewFlagSet(name, flag.ContinueOnError)\n\tflagSet := &FlagSet{set}\n\n\tfor _, flag := range flags {\n\t\tflag.Apply(set)\n\t}\n\n\terr := set.Parse(args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn flagSet, nil\n}", "func NewFlagSet(name string, errorHandling ErrorHandling) *FlagSet {\n\tf := &FlagSet{\n\t\tname: name,\n\t\terrorHandling: errorHandling,\n\t\targsLenAtDash: -1,\n\t\tinterspersed: true,\n\t\tSortFlags: true,\n\t}\n\treturn f\n}", "func NewFlagSet() *pflag.FlagSet {\n\tflags := &pflag.FlagSet{}\n\n\tflags.AddFlagSet(NewRootFlagSet())\n\tflags.AddFlagSet(NewServerFlagSet())\n\tflags.AddFlagSet(NewDBFlagSet())\n\n\treturn flags\n}", "func (c *Command) NewFlagSet(command cli.Command) *flag.FlagSet {\n\tf := flag.NewFlagSet(\"\", flag.ContinueOnError)\n\tf.Usage = func() { c.UI.Error(command.Help()) }\n\n\tif c.hasClientHTTP() {\n\t\tc.httpFlagsClient(f)\n\t}\n\n\tif c.hasServerHTTP() {\n\t\tc.httpFlagsServer(f)\n\t}\n\n\terrR, errW := io.Pipe()\n\terrScanner := bufio.NewScanner(errR)\n\tgo func() {\n\t\tfor errScanner.Scan() {\n\t\t\tc.UI.Error(errScanner.Text())\n\t\t}\n\t}()\n\tf.SetOutput(errW)\n\n\tc.flagSet = f\n\tc.hidden = flag.NewFlagSet(\"\", flag.ContinueOnError)\n\n\treturn f\n}", "func NewSetFlag(base ParserProvider) ParserProvider {\n\treturn &setFlagProvider{\n\t\tbase: base,\n\t}\n}", "func NewSet(root *cobra.Command) {\n\troot.AddCommand(setCmd)\n\n\t// Here you will define your flags and configuration settings.\n\n\t// Cobra supports Persistent Flags which will work for this command\n\t// and all subcommands, e.g.:\n\t// listCmd.PersistentFlags().String(\"foo\", \"\", \"A help for foo\")\n\n\t// Cobra supports local flags which will only run when this command\n\t// is called directly, e.g.:\n\t// listCmd.Flags().BoolP(\"toggle\", \"t\", false, \"Help message for toggle\")\n}", "func New(args []string, flags ...string) (Flag, []string) {\n\tflag := Flag(make(map[string]bool))\n\tfor _, s := range flags {\n\t\tflag[s] = false\n\t}\n\n\tfor i := 0; i < len(args); {\n\t\tif _, found := flag[args[i]]; found {\n\t\t\tflag[args[i]] = true\n\t\t\tif i < len(args)-1 {\n\t\t\t\tcopy(args[i:], args[i+1:])\n\t\t\t}\n\t\t\targs = args[:len(args)-1]\n\t\t} else if args[i][0] == '-' {\n\t\t\tset := make([]string, 0, len(flags))\n\t\t\tfor _, c := range args[i][1:] {\n\t\t\t\ts := string([]rune{'-', c})\n\t\t\t\tif _, found := flag[s]; found {\n\t\t\t\t\tset = append(set, s)\n\t\t\t\t} else {\n\t\t\t\t\tset = set[:0]\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t\tif len(set) > 0 {\n\t\t\t\tfor _, s := range set {\n\t\t\t\t\tflag[s] = true\n\t\t\t\t}\n\t\t\t\tif i < len(args)-1 {\n\t\t\t\t\tcopy(args[i:], args[i+1:])\n\t\t\t\t}\n\t\t\t\targs = args[:len(args)-1]\n\t\t\t} else {\n\t\t\t\ti++\n\t\t\t}\n\t\t} else {\n\t\t\ti++\n\t\t}\n\t}\n\treturn flag, args\n}", "func DefineFlagSet(fs *flag.FlagSet, config interface{}) {\n\tif fs == nil {\n\t\tpanic(errInvalidFlagSet)\n\t}\n\tst := reflect.ValueOf(config)\n\tif st.Kind() != reflect.Ptr {\n\t\tpanic(errPointerWanted)\n\t}\n\tst = reflect.Indirect(st)\n\tif !st.IsValid() || st.Type().Kind() != reflect.Struct {\n\t\tpanic(errInvalidArgument)\n\t}\n\tflagValueType := reflect.TypeOf((*flag.Value)(nil)).Elem()\n\tfor i := 0; i < st.NumField(); i++ {\n\t\ttyp := st.Type().Field(i)\n\t\tvar name, usage string\n\t\ttag := typ.Tag.Get(\"flag\")\n\t\tif tag == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tval := st.Field(i)\n\t\tif !val.CanAddr() {\n\t\t\tpanic(errInvalidField)\n\t\t}\n\t\tflagData := strings.SplitN(tag, \",\", 2)\n\t\tswitch len(flagData) {\n\t\tcase 1:\n\t\t\tname = flagData[0]\n\t\tcase 2:\n\t\t\tname, usage = flagData[0], flagData[1]\n\t\t}\n\t\taddr := val.Addr()\n\t\tif addr.Type().Implements(flagValueType) {\n\t\t\tfs.Var(addr.Interface().(flag.Value), name, usage)\n\t\t\tcontinue\n\t\t}\n\t\tswitch d := val.Interface().(type) {\n\t\tcase int:\n\t\t\tfs.IntVar(addr.Interface().(*int), name, d, usage)\n\t\tcase int64:\n\t\t\tfs.Int64Var(addr.Interface().(*int64), name, d, usage)\n\t\tcase uint:\n\t\t\tfs.UintVar(addr.Interface().(*uint), name, d, usage)\n\t\tcase uint64:\n\t\t\tfs.Uint64Var(addr.Interface().(*uint64), name, d, usage)\n\t\tcase float64:\n\t\t\tfs.Float64Var(addr.Interface().(*float64), name, d, usage)\n\t\tcase bool:\n\t\t\tfs.BoolVar(addr.Interface().(*bool), name, d, usage)\n\t\tcase string:\n\t\t\tfs.StringVar(addr.Interface().(*string), name, d, usage)\n\t\tcase time.Duration:\n\t\t\tfs.DurationVar(addr.Interface().(*time.Duration), name, d, usage)\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"autoflags: field with flag tag value %q is of unsupported type\", name))\n\t\t}\n\t}\n}", "func newFlags(args []string) (flgs flags, err error) {\n\t// create new FlagSet using the program name being executed (args[0])\n\t// as the name of the FlagSet\n\tfs := flag.NewFlagSet(args[0], flag.ContinueOnError)\n\n\tvar (\n\t\tloglvl = fs.String(\"log-level\", \"info\", \"sets log level (debug, warn, error, fatal, panic, disabled), (also via LOG_LEVEL)\")\n\t\tport = fs.Int(\"port\", 8080, \"listen port for server (also via PORT)\")\n\t\tdbhost = fs.String(\"db-host\", \"\", \"postgresql database host (also via DB_HOST)\")\n\t\tdbport = fs.Int(\"db-port\", 5432, \"postgresql database port (also via DB_PORT)\")\n\t\tdbname = fs.String(\"db-name\", \"\", \"postgresql database name (also via DB_NAME)\")\n\t\tdbuser = fs.String(\"db-user\", \"\", \"postgresql database user (also via DB_USER)\")\n\t\tdbpassword = fs.String(\"db-password\", \"\", \"postgresql database password (also via DB_PASSWORD)\")\n\t)\n\n\t// Parse the command line flags from above\n\terr = ff.Parse(fs, args[1:], ff.WithEnvVarNoPrefix())\n\tif err != nil {\n\t\treturn flgs, err\n\t}\n\n\treturn flags{\n\t\tloglvl: *loglvl,\n\t\tport: *port,\n\t\tdbhost: *dbhost,\n\t\tdbport: *dbport,\n\t\tdbname: *dbname,\n\t\tdbuser: *dbuser,\n\t\tdbpassword: *dbpassword,\n\t}, nil\n}", "func Newset(flag, ex, tr int) *set_st {\n\ts := new(set_st)\n\ts.m = make(mapProto)\n\ts.set = make(setProto, 0)\n\ts.pset = unsafe.Pointer(&s.set)\n\n\ts.expireTime = ex\n\ts.triggerInterval = tr\n\ts.flag = flag\n\n\tgo s.refresh()\n\n\treturn s\n}", "func NewSet() *Set {\n\treturn &Set{\n\t\tcache: make(map[I]bool),\n\t}\n}", "func initFlagSet() {\n\tutils.DriverFlagSet.StringVar(\n\t\t&config.Driver,\n\t\t\"driver\",\n\t\t\"local\",\n\t\t\"driver to use (local or docker)\",\n\t)\n\n\tutils.DefaultFlagSet.StringVar(\n\t\t&config.Host,\n\t\t\"host\",\n\t\t\"https://dashboard.getporter.dev\",\n\t\t\"host URL of Porter instance\",\n\t)\n\n\tutils.DefaultFlagSet.UintVar(\n\t\t&config.Project,\n\t\t\"project\",\n\t\t0,\n\t\t\"project ID of Porter project\",\n\t)\n\n\tutils.DefaultFlagSet.UintVar(\n\t\t&config.Cluster,\n\t\t\"cluster\",\n\t\t0,\n\t\t\"cluster ID of Porter cluster\",\n\t)\n\n\tutils.DefaultFlagSet.StringVar(\n\t\t&config.Token,\n\t\t\"token\",\n\t\t\"\",\n\t\t\"token for Porter authentication\",\n\t)\n\n\tutils.RegistryFlagSet.UintVar(\n\t\t&config.Registry,\n\t\t\"registry\",\n\t\t0,\n\t\t\"registry ID of connected Porter registry\",\n\t)\n\n\tutils.HelmRepoFlagSet.UintVar(\n\t\t&config.HelmRepo,\n\t\t\"helmrepo\",\n\t\t0,\n\t\t\"helm repo ID of connected Porter Helm repository\",\n\t)\n}", "func Define(config interface{}) { DefineFlagSet(flag.CommandLine, config) }", "func NewSet() *Set {\n\treturn &Set{\n\t\tset: make(map[string]bool),\n\t}\n}", "func New() Set {\n\treturn make(map[string]bool)\n}", "func BaseFlagSet(name string) *flag.FlagSet {\n\tflagSet := flag.NewFlagSet(name, flag.ExitOnError)\n\n\tflagSet.String(\"config\", \"\", \"path to .toml config file\")\n\n\t// Installation flags.\n\tflagSet.Bool(\"install\", false, \"install the logserver service\")\n\tflagSet.String(\"install-with-custom-pipe\", \"\", `when installing service: pipe flux-capacitor output to specified additional shell command; e.g. 'sudo -E -u $USER bash -c \"~${USER}/go/bin/some-binary -application 1-1-my-app -process $(hostname)' would result in an upstart definition with 'flux-capacitor -flags | sudo -E -u $USER bash -c \"~${USER}/go/bin/logger -application 1-1-my-app -process $(hostname)'. (optional)`)\n\tflagSet.String(\"user\", \"\", \"specify the name of user the service will be run as (required when installing system service)\")\n\tflagSet.Bool(\"uninstall\", false, \"uninstall the logserver service\")\n\n\tflagSet.Usage = func() {\n\t\tfmt.Fprintf(os.Stderr, \"Usage of %v:\\n\", name)\n\t\tflagSet.SetOutput(os.Stderr)\n\t\tflagSet.PrintDefaults()\n\t}\n\n\treturn flagSet\n}", "func NewDBFlagSet() *pflag.FlagSet {\n\tflags := &pflag.FlagSet{}\n\n\t// db subsection flags\n\tflags.StringP(\"db.dbname\", \"\", \"\", \"The database name to connect to\")\n\tflags.StringP(\"db.host\", \"\", \"\", \"The database hostname, e.g localhost\")\n\tflags.IntP(\"db.port\", \"\", 0, \"The database port\")\n\tflags.StringP(\"db.user\", \"\", \"\", \"The database username\")\n\tflags.StringP(\"db.pass\", \"\", \"\", \"The database password\")\n\tflags.StringP(\"db.sslmode\", \"\", \"\", \"The database sslmode\")\n\tflags.BoolP(\"db.enforce-migrations\", \"\", true, \"Throw error on app start if database is not using latest migration\")\n\n\treturn flags\n}", "func (o SetOptions) New(elements ...interface{}) (set Set) {\n\tif o.Unsafe {\n\t\tnewSet := o.newThreadUnsafeSet()\n\t\tset = &newSet\n\t} else {\n\t\tnewSet := o.newThreadSafeSet()\n\t\tset = &newSet\n\t}\n\tset.Add(elements...)\n\treturn\n}", "func newFlags(args []string) (flgs flags, err error) {\n\t// create new FlagSet using the program name being executed (args[0])\n\t// as the name of the FlagSet\n\tfs := flag.NewFlagSet(args[0], flag.ContinueOnError)\n\n\tvar (\n\t\tlogLvlMin = fs.String(\"log-level-min\", \"trace\", fmt.Sprintf(\"sets minimum log level (trace, debug, info, warn, error, fatal, panic, disabled), (also via %s)\", logLevelMinEnv))\n\t\tloglvl = fs.String(\"log-level\", \"info\", fmt.Sprintf(\"sets log level (trace, debug, info, warn, error, fatal, panic, disabled), (also via %s)\", loglevelEnv))\n\t\tlogErrorStack = fs.Bool(\"log-error-stack\", true, fmt.Sprintf(\"if true, log full error stacktrace, else just log error, (also via %s)\", logErrorStackEnv))\n\t\tport = fs.Int(\"port\", 8080, fmt.Sprintf(\"listen port for server (also via %s)\", portEnv))\n\t\tdbhost = fs.String(\"db-host\", \"\", fmt.Sprintf(\"postgresql database host (also via %s)\", dbHostEnv))\n\t\tdbport = fs.Int(\"db-port\", 5432, fmt.Sprintf(\"postgresql database port (also via %s)\", dbPortEnv))\n\t\tdbname = fs.String(\"db-name\", \"\", fmt.Sprintf(\"postgresql database name (also via %s)\", dbNameEnv))\n\t\tdbuser = fs.String(\"db-user\", \"\", fmt.Sprintf(\"postgresql database user (also via %s)\", dbUserEnv))\n\t\tdbpassword = fs.String(\"db-password\", \"\", fmt.Sprintf(\"postgresql database password (also via %s)\", dbPasswordEnv))\n\t)\n\n\t// Parse the command line flags from above\n\terr = ff.Parse(fs, args[1:], ff.WithEnvVarNoPrefix())\n\tif err != nil {\n\t\treturn flgs, err\n\t}\n\n\treturn flags{\n\t\tloglvl: *loglvl,\n\t\tlogLvlMin: *logLvlMin,\n\t\tlogErrorStack: *logErrorStack,\n\t\tport: *port,\n\t\tdbhost: *dbhost,\n\t\tdbport: *dbport,\n\t\tdbname: *dbname,\n\t\tdbuser: *dbuser,\n\t\tdbpassword: *dbpassword,\n\t}, nil\n}", "func NewSet(compare func(interface{}, interface{}) int) Set {\n\treturn Set{NewTree(compare)}\n}", "func flagSet(name string, cfg *CmdConfig) *flag.FlagSet {\n\tflags := flag.NewFlagSet(name, flag.ExitOnError)\n\tflags.StringVar(\n\t\t&cfg.ConfigPath,\n\t\t\"config-path\",\n\t\tsetFromEnvStr(\"CONFIG_PATH\", \"/repo\"),\n\t\t\"Configuration root directory. Should include the '.porter' or 'environment' directory. \"+\n\t\t\t\"Kubernetes object yaml files may be in the directory or in a subdirectory named 'k8s'.\",\n\t)\n\tflags.StringVar(&cfg.ConfigType, \"config-type\", setFromEnvStr(\"CONFIG_TYPE\", \"porter\"), \"Configuration type, \"+\n\t\t\"simple or porter.\")\n\tflags.StringVar(&cfg.Environment, \"environment\", setFromEnvStr(\"ENVIRONMENT\", \"\"), \"Environment of deployment.\")\n\tflags.IntVar(&cfg.MaxConfigMaps, \"max-cm\", setFromEnvInt(\"MAX_CM\", 5), \"Maximum number of configmaps and secret \"+\n\t\t\"objects to keep per app.\")\n\tflags.StringVar(&cfg.Namespace, \"namespace\", setFromEnvStr(\"NAMESPACE\", \"default\"), \"Kubernetes namespace.\")\n\tflags.StringVar(&cfg.Regions, \"regions\", setFromEnvStr(\"REGIONS\", \"\"), \"Regions\"+\n\t\t\"of deployment. (Multiple Space delimited regions allowed)\")\n\tflags.StringVar(&cfg.SHA, \"sha\", setFromEnvStr(\"sha\", \"\"), \"Deployment sha.\")\n\tflags.StringVar(&cfg.VaultAddress, \"vault-addr\", setFromEnvStr(\"VAULT_ADDR\", \"https://vault.loc.adobe.net\"),\n\t\t\"Vault server.\")\n\tflags.StringVar(&cfg.VaultBasePath, \"vault-path\", setFromEnvStr(\"VAULT_PATH\", \"/\"), \"Path in Vault.\")\n\tflags.StringVar(&cfg.VaultToken, \"vault-token\", setFromEnvStr(\"VAULT_TOKEN\", \"\"), \"Vault token.\")\n\tflags.StringVar(&cfg.SecretPathWhiteList, \"secret-path-whitelist\", setFromEnvStr(\"SECRET_PATH_WHITELIST\", \"\"), \"\"+\n\t\t\"Multiple Space delimited secret path whitelist allowed\")\n\tflags.BoolVar(&cfg.Verbose, \"v\", setFromEnvBool(\"VERBOSE\"), \"Verbose log output.\")\n\tflags.IntVar(&cfg.Wait, \"wait\", setFromEnvInt(\"WAIT\", 180), \"Extra time to wait for deployment to complete in \"+\n\t\t\"seconds.\")\n\tflags.StringVar(&cfg.LogMode, \"log-mode\", setFromEnvStr(\"LOG_MODE\", \"inline\"), \"Pod log streaming mode. \"+\n\t\t\"One of 'inline' (print to porter2k8s log), 'file' (write to filesystem, see log-dir option), \"+\n\t\t\"'none' (disable log streaming)\")\n\tflags.StringVar(&cfg.LogDir, \"log-dir\", setFromEnvStr(\"LOG_DIR\", \"logs\"),\n\t\t\"Directory to write pod logs into. (must already exist)\")\n\n\treturn flags\n}", "func NewSet() *Set {\n\treturn &Set{elements: make(map[interface{}]bool), mu: sync.Mutex{}}\n}", "func (cmd *Command) FlagSet(out io.Writer) *flag.FlagSet {\n\tname := cmd.Name()\n\tfs := flag.NewFlagSet(name, flag.ContinueOnError)\n\tfs.SetOutput(out)\n\tfs.Usage = func() {\n\t\tfmt.Fprintln(fs.Output(), cmd.Usage)\n\t}\n\t// populate FlagSet variables with command options\n\tfor _, opt := range cmd.Flags {\n\t\tfor _, name := range strings.Split(opt.Names, \",\") {\n\t\t\tfs.Var(opt.Value, name, \"\")\n\t\t}\n\t}\n\treturn fs\n}", "func NewFlags(devel bool) *Flags {\n\treturn &Flags{\n\t\tdevel: devel,\n\t}\n}", "func FlagSet() *pflag.FlagSet {\n\tfs := pflag.NewFlagSet(\"cli-test-flags\", pflag.ContinueOnError)\n\tfs.BoolP(printReportFlagName, \"p\", false, \"print report\")\n\tfs.BoolP(deferDelete, \"d\", false, \"defer resource deletion\")\n\treturn fs\n}", "func NewFeatureSet(features ...string) FeatureSet {\n\tset := make(FeatureSet, len(features))\n\tfor _, feature := range features {\n\t\tset[feature] = struct{}{}\n\t}\n\treturn set\n}", "func NewRootFlagSet() *pflag.FlagSet {\n\tflags := &pflag.FlagSet{}\n\n\t// root level flags\n\tflags.BoolP(\"version\", \"\", false, \"Display the build version hash\")\n\tflags.StringP(\"env\", \"e\", \"prod\", \"The config files environment to load\")\n\n\treturn flags\n}", "func NewSet(members ...uint) Set {\n\ts := Set{}\n\tfor _, member := range members {\n\t\ts[member] = true\n\t}\n\treturn s\n}", "func NewGlobSet(globs []Glob) (GlobSet, error) {\n\tset := make(globSetImpl, len(globs))\n\tfor i, glob := range globs {\n\t\tset[i] = glob\n\t}\n\treturn set, nil\n}", "func NewSet() Set {\n\tm := make(map[string]struct{})\n\treturn Set{m}\n}", "func NewSet(ss ...string) Set {\n\tsset := map[string]bool{}\n\tfor _, s := range ss {\n\t\tsset[s] = true\n\t}\n\n\treturn sset\n}", "func newOptionSet(rpcType string, opts ...Option) *optionSet {\n\tset := &optionSet{\n\t\tEntryName: rkgrpcinter.RpcEntryNameValue,\n\t\tEntryType: rkgrpcinter.RpcEntryTypeValue,\n\t\tregisterer: prometheus.DefaultRegisterer,\n\t}\n\n\tfor i := range opts {\n\t\topts[i](set)\n\t}\n\n\tnamespace := strings.ReplaceAll(rkentry.GlobalAppCtx.GetAppInfoEntry().AppName, \"-\", \"_\")\n\tsubSystem := strings.ReplaceAll(set.EntryName, \"-\", \"_\")\n\tset.MetricsSet = rkprom.NewMetricsSet(\n\t\tnamespace,\n\t\tsubSystem,\n\t\tset.registerer)\n\n\tkey := rkgrpcinter.ToOptionsKey(set.EntryName, rpcType)\n\tif _, ok := optionsMap[key]; !ok {\n\t\toptionsMap[key] = set\n\t}\n\n\tinitMetrics(set)\n\n\treturn set\n}", "func (s *Set) New() Set {\n\treturn Set{make(map[interface{}]bool), 0}\n}", "func newConfigParser(conf *litConfig, options flags.Options) *flags.Parser {\n\tparser := flags.NewParser(conf, options)\n\treturn parser\n}", "func New() *Flag {\n\treturn &Flag{false}\n}", "func FlagSetCreateGauge() *flag.FlagSet {\n\tfs := flag.NewFlagSet(\"\", flag.ContinueOnError)\n\n\tdur, _ := time.ParseDuration(\"24h\")\n\tfs.Duration(FlagDuration, dur, \"The duration token to be locked, default 1d(24h). Other examples are 7d(168h), 14d(336h). Maximum unit is hour.\")\n\tfs.String(FlagStartTime, \"\", \"Timestamp to begin distribution\")\n\tfs.Uint64(FlagEpochs, 0, \"Total epochs to distribute tokens\")\n\tfs.Bool(FlagPerpetual, false, \"Perpetual distribution\")\n\treturn fs\n}", "func (c *clusterJoinCmd) FlagSet() *flagset.FlagSet {\n\treturn c.flagset\n}", "func newConfigParser(conf *config, options flags.Options) *flags.Parser {\n\tparser := flags.NewParser(conf, options)\n\treturn parser\n}", "func (f *FlagSet) AddFlagSet(newSet *FlagSet) {\n\tif newSet == nil {\n\t\treturn\n\t}\n\tnewSet.VisitAll(func(flag *Flag) {\n\t\tif f.Lookup(flag.Name) == nil {\n\t\t\tf.AddFlag(flag)\n\t\t}\n\t})\n}", "func (p *createParams) getFlagSet() *pflag.FlagSet {\n\tfs := new(pflag.FlagSet)\n\tfs.StringVarP(&createParam.serverType, \"type\", \"t\", \"\", \"server type (upcloud | vultr)\")\n\tfs.StringVar(&createParam.pubKeyPath, \"pubkey\", file.GetHomeDir()+\"/.ssh/id_rsa.pub\", \"ssh public key\")\n\tfs.StringVar(&createParam.privKeyPath, \"privkey\", file.GetHomeDir()+\"/.ssh/id_rsa\", \"ssh private key\")\n\n\tfs.StringVarP(&createParam.serverName, \"name\", \"n\", \"\", \"server name\")\n\tfs.IntVarP(&createParam.ipCount, \"ipcount\", \"c\", 1, \"server ipv4 address count\")\n\tfs.StringArrayVarP(&createParam.tags, \"tags\", \"t\", []string{}, \"server tags\")\n\treturn fs\n}", "func NewSet() *Set {\n\tcomparator := func(left, right interface{}) bool {\n\t\treturn left.(Ordered).LessThan(right.(Ordered))\n\t}\n\treturn NewCustomSet(comparator)\n}", "func NewFileSet() *FileSet {\n\treturn &FileSet{files: map[string]bool{}}\n}", "func New(nameWithDesc ...string) *Parser {\n\tp := &Parser{\n\t\tout: os.Stdout,\n\t\tcfg: newDefaultFlagConfig(),\n\t}\n\t// fs.ExitFunc = os.Exit\n\n\tfName := \"gflag\"\n\tif num := len(nameWithDesc); num > 0 {\n\t\tfName = nameWithDesc[0]\n\t\tif num > 1 {\n\t\t\tp.Desc = nameWithDesc[1]\n\t\t}\n\t}\n\n\tp.InitFlagSet(fName)\n\treturn p\n}", "func NewSet(els ...string) (s Set) {\n\treturn s.Add(els...)\n}", "func (this *Command) NewFlag(name, alias, usage string, multiple bool) *Command {\n\treturn this.AddOption(NewFlag(name, alias, usage, multiple))\n}", "func NewSet() Set {\n\treturn make(Set)\n}", "func NewSet(elements ...interface{}) Set {\n\toptions := &SetOptions{Cache: true}\n\tset := options.newThreadSafeSet()\n\tset.Add(elements...)\n\treturn &set\n}", "func NewServerFlagSet() *pflag.FlagSet {\n\tflags := &pflag.FlagSet{}\n\n\t// server subsection flags\n\tflags.BoolP(\"server.live-reload\", \"\", false, \"Enable or disable LiveReload\")\n\tflags.BoolP(\"server.prod-logger\", \"\", true, \"Use the production logger, JSON and log level warn\")\n\tflags.StringP(\"server.bind\", \"\", \"\", `HTTP bind address, eg: \":80\"`)\n\tflags.StringP(\"server.tls-bind\", \"\", \"\", `HTTPS bind address, eg: \":443\"`)\n\tflags.StringP(\"server.tls-cert-file\", \"\", \"\", \"TLS certificate file path\")\n\tflags.StringP(\"server.tls-key-file\", \"\", \"\", \"TLS key file path\")\n\tflags.StringP(\"server.public-path\", \"\", \"public\", \"The path to the public folder containing assets\")\n\tflags.DurationP(\"server.read-timeout\", \"\", time.Second*10, \"Maximum duration before timing out read of the request\")\n\tflags.DurationP(\"server.write-timeout\", \"\", time.Second*15, \"Maximum duration before timing out write of the response\")\n\tflags.DurationP(\"server.idle-timeout\", \"\", time.Second*120, \"Maximum duration before timing out idle keep-alive connection\")\n\t// manifest.json is created as a part of the gulp production \"build\" task,\n\t// it maps fingerprinted asset names to regular asset names, for example:\n\t// {\"js/main.css\": \"js/e2a3ff9-main.css\"}.\n\t// This should only be set to true if doing asset fingerprinting.\n\tflags.BoolP(\"server.assets-manifest\", \"\", true, \"Use manifest.json for mapping asset names to fingerprinted assets\")\n\t// This should be used in development mode to prevent browser caching of assets\n\tflags.BoolP(\"server.assets-no-cache\", \"\", false, \"Disable browsers caching asset files by setting response headers\")\n\t// This should be used in development mode to avoid having to reload the\n\t// server on every template file modification.\n\tflags.BoolP(\"server.render-recompile\", \"\", false, \"Enable recompilation of the template on each render\")\n\t// Defined in app/sessions.go -- Usually cookie storer for dev and disk storer for prod.\n\tflags.BoolP(\"server.sessions-dev-storer\", \"\", false, \"Use the development mode sessions storer (defined in app/sessions.go)\")\n\n\treturn flags\n}", "func FileSetNew() *FileSet {\n\tfs := &FileSet{\n\t\ttop: 0,\n\t}\n\tc := make(chan string, bufferSize)\n\tfs.fileChannels = append(fs.fileChannels, c)\n\treturn fs\n}", "func newCfg() *cfg {\n\tcfg := &cfg{}\n\n\tflag.IntVar(&cfg.pool, \"pool\", 32,\n\t\t\"count of the workers in pool (default: 32)\")\n\n\tflag.BoolVar(&cfg.greedy, \"greedy\", true,\n\t\t\"enable greedy mode (default: true)\")\n\n\tflag.DurationVar(&cfg.dur, \"duration\", time.Minute,\n\t\t\"pool's heartbeat duration\")\n\n\tflag.Parse()\n\n\treturn cfg\n}", "func New(items ...string) *Set {\n\tset := &Set{make(map[string]bool, len(items))}\n\tset.AppendSlice(items)\n\treturn set\n}", "func makeNewFilterSet(excludes []MetricFilter) (*dpfilters.FilterSet, error) {\n\tvar excludeSet []dpfilters.DatapointFilter\n\tfor _, f := range excludes {\n\t\tif f.Negated {\n\t\t\treturn nil, errors.New(\"new filters can't be negated\")\n\t\t}\n\t\tdimSet, err := f.Normalize()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tdpf, err := dpfilters.NewOverridable(f.MetricNames, dimSet)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\texcludeSet = append(excludeSet, dpf)\n\t}\n\treturn &dpfilters.FilterSet{\n\t\tExcludeFilters: excludeSet,\n\t}, nil\n}", "func New() *GameSet {\n\treturn &GameSet{\n\t\tmutex: &sync.Mutex{},\n\t\tdata: make(map[int64]bool),\n\t}\n}", "func New(opts *Options) *Set {\n\ts := &Set{\n\t\tsymid: make(map[string]id),\n\t\tnodes: make(map[node]nid),\n\t\tfacts: make(map[nid]map[fact]struct{}),\n\t\tedges: make(map[nid]map[edge]struct{}),\n\t\topts: opts,\n\t}\n\ts.enter(\"\") // pre-assign \"\" as ID 0\n\ts.canon = true\n\treturn s\n}", "func (p *Parser) FSet() *flag.FlagSet { return p.fSet }", "func NewSet(db string, algo hash.Hash) (*Set, error) {\n\tpd := filepath.Join(db, \"pack\")\n\n\tpaths, err := filepath.Glob(filepath.Join(escapeGlobPattern(pd), \"*.pack\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpacks := make([]*Packfile, 0, len(paths))\n\n\tfor _, path := range paths {\n\t\tsubmatch := nameRe.FindStringSubmatch(filepath.Base(path))\n\t\tif len(submatch) != 2 {\n\t\t\tcontinue\n\t\t}\n\n\t\tname := submatch[1]\n\n\t\tidxf, err := os.Open(filepath.Join(pd, fmt.Sprintf(\"%s.idx\", name)))\n\t\tif err != nil {\n\t\t\t// We have a pack (since it matched the regex), but the\n\t\t\t// index is missing or unusable. Skip this pack and\n\t\t\t// continue on with the next one, as Git does.\n\t\t\tif idxf != nil {\n\t\t\t\t// In the unlikely event that we did open a\n\t\t\t\t// file, close it, but discard any error in\n\t\t\t\t// doing so.\n\t\t\t\tidxf.Close()\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\tpackf, err := os.Open(filepath.Join(pd, fmt.Sprintf(\"%s.pack\", name)))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tpack, err := DecodePackfile(packf, algo)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tidx, err := DecodeIndex(idxf, algo)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tpack.idx = idx\n\n\t\tpacks = append(packs, pack)\n\t}\n\treturn NewSetPacks(packs...), nil\n}", "func New(dataType string) *HashSet {\n\treturn &HashSet{\n\t\tset: make(map[interface{}]interface{}),\n\t\tt: dataType,\n\t\tsize: 0,\n\t}\n}", "func New(base mb.BaseMetricSet) (mb.MetricSet, error) {\n\n\tconfig := struct{}{}\n\n\tif err := base.Module().UnpackConfig(&config); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &MetricSet{\n\t\tBaseMetricSet: base,\n\t}, nil\n}", "func newConfigParser(conf *dlcConfig, options flags.Options) *flags.Parser {\n\tparser := flags.NewParser(conf, options)\n\treturn parser\n}", "func NewFlags() *Flags {\n\t// We keep the forwarded args, and \"modify\" os.Args so it contains only maybe-valid-flags.\n\tos.Args = config.ParsedForwardedArgs.Parse()\n\t// TODO(dio): Revert os.Args.\n\treturn new(Flags)\n}", "func NewFlags() *Flags {\n\tflags := &Flags{}\n\tfl := flag.NewFlagSet(os.Args[0], flag.ExitOnError)\n\n\tfl.IntVar(&flags.ResyncIntervalSeconds, \"resync-interval\", resyncIntervalSecondsDef, \"resync seconds of the controller\")\n\tfl.StringVar(&flags.KubeConfig, \"kubeconfig\", kubehomeDef, \"kubernetes configuration path, only used when development mode enabled\")\n\tfl.BoolVar(&flags.DryRun, \"dry-run\", dryRunDef, \"run in dry-run mode\")\n\tfl.BoolVar(&flags.Development, \"development\", developmentDef, \"development flag will allow to run outside a kubernetes cluster\")\n\tfl.BoolVar(&flags.Debug, \"debug\", debugDef, \"enable debug mode\")\n\n\tfl.Parse(os.Args[1:])\n\n\treturn flags\n}", "func NewCmdSet(f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {\n\tset := &cobra.Command{\n\t\tUse: \"set COMMAND\",\n\t\tShort: \"Commands that help set specific features on objects\",\n\t\tLong: setLong,\n\t\tRun: kcmdutil.DefaultSubCommandRun(streams.ErrOut),\n\t}\n\n\tgroups := ktemplates.CommandGroups{\n\t\t{\n\t\t\tMessage: \"Manage workloads:\",\n\t\t\tCommands: []*cobra.Command{\n\t\t\t\tNewCmdDeploymentHook(f, streams),\n\t\t\t\tNewCmdEnv(f, streams),\n\t\t\t\tNewCmdImage(f, streams),\n\t\t\t\t// TODO: this seems reasonable to upstream\n\t\t\t\tNewCmdProbe(f, streams),\n\t\t\t\tNewCmdResources(f, streams),\n\t\t\t\tNewCmdSelector(f, streams),\n\t\t\t\tNewCmdServiceAccount(f, streams),\n\t\t\t\tNewCmdVolume(f, streams),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tMessage: \"Manage secrets and config:\",\n\t\t\tCommands: []*cobra.Command{\n\t\t\t\tNewCmdData(f, streams),\n\t\t\t\tNewCmdBuildSecret(f, streams),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tMessage: \"Manage application flows:\",\n\t\t\tCommands: []*cobra.Command{\n\t\t\t\tNewCmdBuildHook(f, streams),\n\t\t\t\tNewCmdImageLookup(f, streams),\n\t\t\t\tNewCmdTriggers(f, streams),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tMessage: \"Manage load balancing:\",\n\t\t\tCommands: []*cobra.Command{\n\t\t\t\tNewCmdRouteBackends(f, streams),\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tMessage: \"Manage authorization policy:\",\n\t\t\tCommands: []*cobra.Command{\n\t\t\t\tNewCmdSubject(f, streams),\n\t\t\t},\n\t\t},\n\t}\n\tgroups.Add(set)\n\treturn set\n}", "func newPeerSet() *peerSet {\n\treturn &peerSet{\n\t\tpeers: make(map[string]*peer),\n\t}\n}", "func NewSet() *Set {\n\treturn &Set{\n\t\tproxies: make(map[Proxy]bool),\n\t}\n}", "func NewSet() *Set {\n\treturn &Set{set: make(map[cid.Cid]struct{}), lk: sync.Mutex{}}\n}", "func NewSet()(*Set) {\n m := &Set{\n Entity: *iadcd81124412c61e647227ecfc4449d8bba17de0380ddda76f641a29edf2b242.NewEntity(),\n }\n return m\n}", "func New(base mb.BaseMetricSet) (mb.MetricSet, error) {\n\tvar config Config\n\n\tif err := base.Module().UnpackConfig(&config); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &MetricSet{\n\t\tBaseMetricSet: base,\n\t\tcfg: config,\n\t}, nil\n}", "func (f *Factory) SetFlags() {\n}", "func NewSet() *cobra.Command {\n\tvar opts setContextOptions\n\n\treturn &cobra.Command{\n\t\tUse: \"set-context\",\n\t\tShort: \"Updates the active hub configuration context\",\n\t\tExample: heredoc.WithCLIName(`\n\t\t\t# Selects which Hub/Gateway server to use of via a prompt\n\t\t\t<cli> config set-context\n\t\t\t\n\t\t\t# Sets the specified Hub/Gateway server\n\t\t\t<cli> config set-context localhost:8080\n\t\t`, cli.Name),\n\t\tArgs: cobra.MaximumNArgs(1),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) > 0 {\n\t\t\t\topts.serverAddress = args[0]\n\t\t\t}\n\t\t\treturn setRun(opts)\n\t\t},\n\t}\n}", "func AsFlagSet(f Field) FlagSet {\n\tlist, ok := f.([]Field)\n\tif !ok {\n\t\treturn nil\n\t}\n\tv := make(FlagSet, len(list))\n\tfor _, f := range list {\n\t\tif s := AsAtom(f); s != \"\" {\n\t\t\tv[s] = true\n\t\t} else {\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn v\n}", "func newClusterToolSet(federationClient federationclientset.Interface) clusterToolSetInterface {\n\treturn nil\n}", "func NewViewSet() *ViewSetCfg {\n\tv := GlobalTrinity.vCfg.clone()\n\treturn v\n}", "func New(vals ...interface{}) Set {\n\ts := &setImpl{\n\t\tset: make(map[interface{}]struct{}, 0),\n\t}\n\tfor _, i := range vals {\n\t\ts.Insert(i)\n\t}\n\treturn s\n}", "func New(elements ...string) *StringSet {\n\tset := &StringSet{make(map[string]bool)}\n\tset.Add(elements...)\n\treturn set\n}", "func (fs *FS) newInvalSet() *invalSet { return &invalSet{server: fs.server} }", "func NewSet() *Set {\n\treturn newSet()\n}", "func (module *Module) NewFlags() interface{} {\n\treturn new(Flags)\n}", "func (cfg Config) GetPFlagSet(prefix string) *pflag.FlagSet {\n\tcmdFlags := pflag.NewFlagSet(\"Config\", pflag.ExitOnError)\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"kube-config\"), *new(string), \"Path to kubernetes client config file.\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"master\"), *new(string), \"\")\n\tcmdFlags.Int(fmt.Sprintf(\"%v%v\", prefix, \"workers\"), 2, \"Number of threads to process workflows\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"workflow-reeval-duration\"), \"30s\", \"Frequency of re-evaluating workflows\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"downstream-eval-duration\"), \"60s\", \"Frequency of re-evaluating downstream tasks\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"limit-namespace\"), \"all\", \"Namespaces to watch for this propeller\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"prof-port\"), \"10254\", \"Profiler port\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"metadata-prefix\"), *new(string), \"MetadataPrefix should be used if all the metadata for Flyte executions should be stored under a specific prefix in CloudStorage. If not specified, the data will be stored in the base container directly.\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"queue.type\"), \"simple\", \"Type of composite queue to use for the WorkQueue\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"queue.queue.type\"), \"default\", \"Type of RateLimiter to use for the WorkQueue\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"queue.queue.base-delay\"), \"10s\", \"base backoff delay for failure\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"queue.queue.max-delay\"), \"10s\", \"Max backoff delay for failure\")\n\tcmdFlags.Int64(fmt.Sprintf(\"%v%v\", prefix, \"queue.queue.rate\"), int64(10), \"Bucket Refill rate per second\")\n\tcmdFlags.Int(fmt.Sprintf(\"%v%v\", prefix, \"queue.queue.capacity\"), 100, \"Bucket capacity as number of items\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"queue.sub-queue.type\"), \"default\", \"Type of RateLimiter to use for the WorkQueue\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"queue.sub-queue.base-delay\"), \"10s\", \"base backoff delay for failure\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"queue.sub-queue.max-delay\"), \"10s\", \"Max backoff delay for failure\")\n\tcmdFlags.Int64(fmt.Sprintf(\"%v%v\", prefix, \"queue.sub-queue.rate\"), int64(10), \"Bucket Refill rate per second\")\n\tcmdFlags.Int(fmt.Sprintf(\"%v%v\", prefix, \"queue.sub-queue.capacity\"), 100, \"Bucket capacity as number of items\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"queue.batching-interval\"), \"1s\", \"Duration for which downstream updates are buffered\")\n\tcmdFlags.Int(fmt.Sprintf(\"%v%v\", prefix, \"queue.batch-size\"), -1, \"Number of downstream triggered top-level objects to re-enqueue every duration. -1 indicates all available.\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"metrics-prefix\"), \"flyte:\", \"An optional prefix for all published metrics.\")\n\tcmdFlags.Bool(fmt.Sprintf(\"%v%v\", prefix, \"enable-admin-launcher\"), false, \" Enable remote Workflow launcher to Admin\")\n\tcmdFlags.Int(fmt.Sprintf(\"%v%v\", prefix, \"max-workflow-retries\"), 50, \"Maximum number of retries per workflow\")\n\tcmdFlags.Int(fmt.Sprintf(\"%v%v\", prefix, \"max-ttl-hours\"), 23, \"Maximum number of hours a completed workflow should be retained. Number between 1-23 hours\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"gc-interval\"), \"30m\", \"Run periodic GC every 30 minutes\")\n\tcmdFlags.Bool(fmt.Sprintf(\"%v%v\", prefix, \"leader-election.enabled\"), *new(bool), \"Enables/Disables leader election.\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"leader-election.lock-config-map.Namespace\"), *new(string), \"\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"leader-election.lock-config-map.Name\"), *new(string), \"\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"leader-election.lease-duration\"), \"15s\", \"Duration that non-leader candidates will wait to force acquire leadership. This is measured against time of last observed ack.\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"leader-election.renew-deadline\"), \"10s\", \"Duration that the acting master will retry refreshing leadership before giving up.\")\n\tcmdFlags.String(fmt.Sprintf(\"%v%v\", prefix, \"leader-election.retry-period\"), \"2s\", \"Duration the LeaderElector clients should wait between tries of actions.\")\n\tcmdFlags.Bool(fmt.Sprintf(\"%v%v\", prefix, \"publish-k8s-events\"), *new(bool), \"Enable events publishing to K8s events API.\")\n\tcmdFlags.Int64(fmt.Sprintf(\"%v%v\", prefix, \"max-output-size-bytes\"), *new(int64), \"Maximum size of outputs per task\")\n\treturn cmdFlags\n}", "func newBitset(bits uint) bitset {\n\textra := uint(0)\n\tif bits%64 != 0 {\n\t\textra = 1\n\t}\n\tchunks := bits/64 + extra\n\treturn bitset(make([]uint64, chunks))\n}", "func NewHashSet() *HashSet {\n\tmmap := maps.NewHashMap()\n\treturn &HashSet{mmap}\n}", "func NewFlagger(cmd *cobra.Command, cfg *viper.Viper) *Flagger {\n\treturn &Flagger{cmd: cmd, cfg: cfg}\n}", "func newWrappedSet(encapsulated Set, immutable bool) DependentSet {\n res := new(setWrapper)\n res.SetDerived = EmbeddedDependentSet(res)\n res.encapsulated = encapsulated\n res.immutable = immutable\n return res\n}", "func NewSet(name string, client *Client) Set {\n\treturn Set{name: name, c: client}\n}", "func NewBitset(maxSize uint) *Bitset {\n\treturn &Bitset{\n\t\tbitset.New(maxSize),\n\t}\n}", "func NewSet(labels ...Instance) Set {\n\ts := make(map[Instance]struct{})\n\tfor _, l := range labels {\n\t\ts[l] = struct{}{}\n\t}\n\n\treturn s\n}", "func InitFlags() *FactoryOptions {\n\ttesting.Init()\n\t_, err := types.NewAttachedGinkgoFlagSet(flag.CommandLine, types.GinkgoFlags{}, nil, types.GinkgoFlagSections{}, types.GinkgoFlagSection{})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\ttestOptions := &FactoryOptions{}\n\ttestOptions.BindFlags(flag.CommandLine)\n\tflag.Parse()\n\n\treturn testOptions\n}", "func makeSet() *customSet {\n\treturn &customSet{\n\t\tcontainer: make(map[string]struct{}),\n\t}\n}", "func (b *AdapterBase) initFlagSet() {\n\tif b.FlagSet == nil {\n\t\t// default to the normal commandline flags\n\t\tb.FlagSet = pflag.CommandLine\n\t}\n}", "func (m *Meta) FlagSet(n string, fs FlagSetFlags) *flag.FlagSet {\n\tf := flag.NewFlagSet(n, flag.ContinueOnError)\n\n\t// Create an io.Writer that writes to our UI properly for errors.\n\t// This is kind of a hack, but it does the job. Basically: create\n\t// a pipe, use a scanner to break it into lines, and output each line\n\t// to the UI. Do this forever.\n\terrR, errW := io.Pipe()\n\terrScanner := bufio.NewScanner(errR)\n\tgo func() {\n\t\tfor errScanner.Scan() {\n\t\t\tm.UI.Error(errScanner.Text())\n\t\t}\n\t}()\n\tf.SetOutput(errW)\n\n\treturn f\n}", "func NewSet() *Set {\n\treturn &Set{}\n}", "func NewFileSet() *FileSet {\n\treturn &FileSet{}\n}", "func (m *ApiMeta) GlobalFlagSet(cmd string) *flag.FlagSet {\n\tf := flag.NewFlagSet(cmd, flag.ContinueOnError)\n\n\tf.StringVar(&m.gateEndpoint, \"gate-endpoint\", \"http://localhost:8084\",\n\t\t\"Gate (API server) endpoint\")\n\n\tf.Usage = func() {}\n\n\treturn f\n}", "func NewSet() *Set {\n\treturn &Set{maxID: -1, used: make(set.Int64s), free: make(set.Int64s)}\n}", "func (f *PluginAPIClientMeta) FlagSet() *flag.FlagSet {\n\tfs := flag.NewFlagSet(\"vault plugin settings\", flag.ContinueOnError)\n\n\tfs.StringVar(&f.flagCACert, \"ca-cert\", \"\", \"\")\n\tfs.StringVar(&f.flagCAPath, \"ca-path\", \"\", \"\")\n\tfs.StringVar(&f.flagClientCert, \"client-cert\", \"\", \"\")\n\tfs.StringVar(&f.flagClientKey, \"client-key\", \"\", \"\")\n\tfs.BoolVar(&f.flagInsecure, \"tls-skip-verify\", false, \"\")\n\n\treturn fs\n}", "func New(initial ...string) Set {\n\ts := make(Set)\n\n\tfor _, v := range initial {\n\t\ts.Insert(v)\n\t}\n\n\treturn s\n}", "func NewSet(opts ...SetOption) Set {\n\tresult := Set{}\n\tfor _, opt := range opts {\n\t\topt(&result)\n\t}\n\tcenter := result.calculateCenter()\n\tradius := result.calculateRadius(center)\n\tresult.bs = NewSphere(center, radius)\n\treturn result\n}", "func NewSetQuery() filters.Spec { return &modQuery{behavior: set} }", "func Set(opts ...Option) utilset {\n\tvar done bool\n\tonce.Do(func() {\n\t\tdopts := defaultOptions()\n\t\tfor _, opt := range opts {\n\t\t\topt.Apply(&dopts)\n\t\t}\n\t\ttodo, closer := run.StartHealthyMonitoring(dopts.todo, destroy)\n\t\t// one.TODO(todo)\n\t\tunique = &uniqueSet{\n\t\t\ttodo: todo,\n\t\t\ttkset: auth.NewTokenset(todo),\n\t\t\tmdb: dialDB(todo, dopts.mdb),\n\t\t\tfat: sys.NewFat(),\n\t\t\tnatsconn: dialNats(dopts.natsUrl),\n\t\t\tCloser: closer,\n\t\t}\n\t\tdone = true\n\t})\n\tif !done && len(opts) > 0 {\n\t\tpanic(ErrInvalidInitialize)\n\t}\n\treturn unique\n}", "func NewSet() *Set {\n\treturn &Set{\n\t\trules: make(map[string]*Rule),\n\t\trouter: route.New(),\n\t}\n}" ]
[ "0.70940214", "0.68933076", "0.680488", "0.66169435", "0.6524972", "0.6482576", "0.62197244", "0.5822131", "0.5776519", "0.57721347", "0.5768234", "0.5692028", "0.56861347", "0.56835216", "0.56695974", "0.566484", "0.5659758", "0.56593263", "0.5658331", "0.5636956", "0.56219906", "0.5575091", "0.55691", "0.5524738", "0.5511395", "0.5492164", "0.54329604", "0.5431656", "0.54273844", "0.5422061", "0.53643614", "0.53504384", "0.5348721", "0.5346304", "0.53439283", "0.533706", "0.5320091", "0.52752554", "0.5265357", "0.5257592", "0.52487594", "0.5236504", "0.52292126", "0.5211429", "0.5208757", "0.519238", "0.5187169", "0.5170122", "0.51594126", "0.5158068", "0.5147758", "0.5144173", "0.51329243", "0.5123958", "0.5120601", "0.50989324", "0.50976187", "0.5096839", "0.50888664", "0.50732166", "0.5058571", "0.50581783", "0.5054463", "0.5046794", "0.50379163", "0.50326294", "0.50229865", "0.5020721", "0.5011028", "0.500591", "0.4996193", "0.49879938", "0.49861482", "0.49755073", "0.49676445", "0.4963337", "0.4961686", "0.49135128", "0.49035347", "0.48896143", "0.4886538", "0.4880939", "0.48793584", "0.4874461", "0.4871161", "0.48645166", "0.48634675", "0.4856891", "0.48563427", "0.48395753", "0.48390445", "0.48389894", "0.48382515", "0.48336908", "0.4830125", "0.4829779", "0.48234788", "0.48227915", "0.4816539", "0.48028854" ]
0.66196287
3
NewPreRunner takes a name and a standalone pre runner compatible function and turns them into a Group compatible PreRunner, ready for registration.
func NewPreRunner(name string, fn func() error) PreRunner { return preRunner{name: name, fn: fn} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func preRun(c *cobra.Command, args []string) error {\n\tif len(args) < 1 {\n\t\treturn errors.New(\"Missing name argument\")\n\t}\n\n\tname = args[0]\n\treturn nil\n}", "func newRunnerGroup(scope RunnerGroupScope, name string) RunnerGroup {\n\tif name == \"\" {\n\t\treturn RunnerGroup{\n\t\t\tScope: scope,\n\t\t\tKind: Default,\n\t\t\tName: \"\",\n\t\t}\n\t}\n\n\treturn RunnerGroup{\n\t\tScope: scope,\n\t\tKind: Custom,\n\t\tName: name,\n\t}\n}", "func New(t *testing.T, name string, arg ...string) *Runner {\n\treturn &Runner{t, name, arg}\n}", "func NewRunner(parent string) *Runner {\n\tr := &Runner{}\n\tc := &cobra.Command{\n\t\tUse: \"fix LOCAL_PKG_DIR\",\n\t\tArgs: cobra.ExactArgs(1),\n\t\tShort: docs.FixShort,\n\t\tLong: docs.FixShort + \"\\n\" + docs.FixLong,\n\t\tExample: docs.FixExamples,\n\t\tPreRunE: r.preRunE,\n\t\tRunE: r.runE,\n\t\tSuggestFor: []string{\"upgrade\", \"migrate\"},\n\t}\n\tcmdutil.FixDocs(\"kpt\", parent, c)\n\tc.Flags().BoolVar(&r.Fix.DryRun, \"dry-run\", false,\n\t\t`Dry run emits the actions`)\n\tr.Command = c\n\treturn r\n}", "func NewRunner(getter Getter) *Runner {\n\treturn &Runner{getter: getter}\n}", "func NewRunner(wfClientset wfclientset.Interface) *Runner {\n\treturn &Runner{wfClientset: wfClientset}\n}", "func NewRunner(ctx *pulumi.Context,\n\tname string, args *RunnerArgs, opts ...pulumi.ResourceOption) (*Runner, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.RegistrationToken == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'RegistrationToken'\")\n\t}\n\tif args.RegistrationToken != nil {\n\t\targs.RegistrationToken = pulumi.ToSecret(args.RegistrationToken).(pulumi.StringInput)\n\t}\n\tsecrets := pulumi.AdditionalSecretOutputs([]string{\n\t\t\"authenticationToken\",\n\t\t\"registrationToken\",\n\t})\n\topts = append(opts, secrets)\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Runner\n\terr := ctx.RegisterResource(\"gitlab:index/runner:Runner\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (k *PluginRunner) preRun(cmd *cobra.Command, args []string) error {\n\tlr := fLdr.RestrictionRootOnly\n\tfSys := filesys.MakeFsOnDisk()\n\tldr, err := fLdr.NewLoader(lr, filepath.Clean(k.root), fSys)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tv := validator.NewKustValidator()\n\n\tuf := kunstruct.NewKunstructuredFactoryImpl()\n\tvar pm resmap.Merginator // TODO The actual implementation is internal now...\n\trf := resmap.NewFactory(resource.NewFactory(uf), pm)\n\n\tk.h = resmap.NewPluginHelpers(ldr, v, rf)\n\n\tif c, ok := k.plugin.(resmap.Configurable); ok {\n\t\tconfig, err := k.config(cmd, args)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := c.Config(k.h, config); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (s *Supervisor) AddRunner(name string, callback Callback, policyOptions ...PolicyOption) {\n\tkey := fmt.Sprintf(\"%s-%s\", \"runner\", name)\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\n\tif _, exists := s.processes[key]; exists {\n\t\ts.logger(Error, loggerData{\"name\": name}, \"runner already exists\")\n\t\treturn\n\t}\n\n\tr := &runner{\n\t\tCallback: callback,\n\t\tname: name,\n\t\trestartPolicy: s.policy.Restart,\n\t\tlogger: s.logger,\n\t}\n\n\tp := Policy{\n\t\tRestart: s.policy.Restart,\n\t}\n\tp.Reconfigure(policyOptions...)\n\n\tr.restartPolicy = p.Restart\n\n\ts.processes[key] = r\n}", "func newPreReqValidator(opts ...option) *preReqValidator {\n\tcfg := defaultPreReqCfg()\n\tfor _, opt := range opts {\n\t\topt(cfg)\n\t}\n\treturn &preReqValidator{\n\t\tctxName: cfg.ctxName,\n\t\tns: cfg.ns,\n\t\tk8sClientProvider: cfg.k8sClientProvider,\n\t\toktetoClientProvider: cfg.oktetoClientProvider,\n\t\tgetContextStore: cfg.getContextStore,\n\t\tgetCtxResource: cfg.getCtxResource,\n\t}\n}", "func NewRunner(be func() Backend, host string, userf, passf string) *Runner {\n\treturn &Runner{\n\t\tbe: be,\n\t\thost: host,\n\t\tuserf: userf,\n\t\tpassf: passf,\n\t\tsessions: make(chan error),\n\t\tpwdOver: make(chan struct{}),\n\t\tbroken: makeBroken(),\n\t\tlogins: gen.NewLogins(),\n\t\tagents: gen.NewAgents(),\n\t\tpool: newPool(),\n\t}\n}", "func (rnr *Runner) Preparer(l logger.Logger) (preparer.Preparer, error) {\n\n\t// NOTE: We have a good generic preparer so we'll provide that here\n\n\tl.Debug(\"** Preparer **\")\n\n\t// Return the existing preparer if we already have one\n\tif rnr.Prepare != nil {\n\t\tl.Debug(\"Returning existing preparer\")\n\t\treturn rnr.Prepare, nil\n\t}\n\n\tl.Debug(\"Creating new preparer\")\n\n\tp, err := prepare.NewPrepare(l)\n\tif err != nil {\n\t\tl.Warn(\"Failed new prepare >%v<\", err)\n\t\treturn nil, err\n\t}\n\n\tdb, err := rnr.Store.GetDb()\n\tif err != nil {\n\t\tl.Warn(\"Failed getting database handle >%v<\", err)\n\t\treturn nil, err\n\t}\n\n\terr = p.Init(db)\n\tif err != nil {\n\t\tl.Warn(\"Failed preparer init >%v<\", err)\n\t\treturn nil, err\n\t}\n\n\trnr.Prepare = p\n\n\treturn p, nil\n}", "func NewFakeAppPrecondition(name string, numApps int, innerPre func(name string, opts ...chrome.Option) testing.Precondition, skiaRenderer bool) *preImpl {\n\tname = fmt.Sprintf(\"%s_%d\", name, numApps)\n\ttmpDir, err := ioutil.TempDir(\"\", name)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\topts := make([]chrome.Option, 0, numApps)\n\tfor i := 0; i < numApps; i++ {\n\t\topts = append(opts, chrome.UnpackedExtension(filepath.Join(tmpDir, fmt.Sprintf(\"fake_%d\", i))))\n\t}\n\tif skiaRenderer {\n\t\tname = name + \"_skia_renderer\"\n\t\topts = append(opts, chrome.EnableFeatures(\"UseSkiaRenderer\"))\n\t}\n\tcrPre := innerPre(name, opts...)\n\treturn &preImpl{crPre: crPre, numApps: numApps, extDirBase: tmpDir, prepared: false}\n}", "func NewRunner(pubClientFactory func() publisher.Client, mod *Wrapper) Runner {\n\treturn &runner{\n\t\tdone: make(chan struct{}),\n\t\tmod: mod,\n\t\tclient: pubClientFactory(),\n\t}\n}", "func NewRunner(client ucare.Client, customStorage string) *Runner {\n\treturn &Runner{\n\t\tFile: file.NewService(client),\n\t\tGroup: group.NewService(client),\n\t\tUpload: upload.NewService(client),\n\t\tConversion: conversion.NewService(client),\n\t\tWebhook: webhook.NewService(client),\n\t\tProject: project.NewService(client),\n\t\tArtifacts: Artifacts{\n\t\t\tCustomStorage: customStorage,\n\t\t},\n\t}\n}", "func New(runner, tracker, hosted string) *Runner {\n\tn := &Runner{\n\t\ttcl: client.New(tracker, http.DefaultClient, client.JsonCodec),\n\t\tbase: hosted,\n\t\trunner: runner,\n\t\trpc: gorpc.NewServer(),\n\t\trq: rpc.NewRunnerQueue(),\n\t\tresp: make(chan rpc.Output),\n\t}\n\n\t//register the run service in the rpc\n\tif err := n.rpc.RegisterService(n.rq, \"\"); err != nil {\n\t\tpanic(err)\n\t}\n\n\t//register the pinger\n\tif err := n.rpc.RegisterService(pinger.Pinger{}, \"\"); err != nil {\n\t\tpanic(err)\n\t}\n\n\t//register ourselves in the rpc\n\tif err := n.rpc.RegisterService(n, \"\"); err != nil {\n\t\tpanic(err)\n\t}\n\n\t//register the codec\n\tn.rpc.RegisterCodec(json.NewCodec(), \"application/json\")\n\n\t//start processing\n\tgo n.run()\n\n\treturn n\n}", "func NewPrecompileCaller(address common.Address, caller bind.ContractCaller) (*PrecompileCaller, error) {\n\tcontract, err := bindPrecompile(address, caller, nil, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &PrecompileCaller{contract: contract}, nil\n}", "func NewRunner(methods MethodMap) *Runner {\n\treturn &Runner{methods}\n}", "func NewRunner(env []string) *Runner {\n\treturn &Runner{\n\t\tenv: env,\n\t}\n}", "func NewRunner(c client.Client) *ClientPipelineRunner {\n\treturn &ClientPipelineRunner{client: c, objectMeta: objectMetaCreator}\n}", "func newProcessRunner(pipeID string, p phono.Processor) (*processRunner, error) {\n\tfn, err := p.Process(pipeID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr := processRunner{\n\t\tfn: fn,\n\t\tProcessor: p,\n\t\thooks: bindHooks(p),\n\t}\n\treturn &r, nil\n}", "func Register(name string, fn func(ctx Context, payload map[string]interface{}) (Runner, error)) {\n\tonce.Do(func() {\n\t\trunners = factory{\n\t\t\trunners: make(map[string]func(ctx Context, payload map[string]interface{}) (Runner, error)),\n\t\t}\n\t})\n\n\trunners.Lock()\n\tdefer runners.Unlock()\n\n\trunners.runners[name] = fn\n}", "func (pfs *Supervisor) NewRunner(t *testing.T, m Matrix) *Runner {\n\tif Flags.PrintMatrix {\n\t\tmatrix := m.scenarios()\n\t\tfor _, m := range matrix {\n\t\t\tfmt.Printf(\"%s/%s\\n\", t.Name(), m)\n\t\t}\n\t\tt.Skip(\"Just printing test matrix (-ls-matrix flag set)\")\n\t}\n\tt.Helper()\n\tt.Parallel()\n\tpf := &Runner{\n\t\tt: t,\n\t\tmatrix: m,\n\t\ttestNames: map[string]struct{}{},\n\t\ttestNamesPassed: map[string]struct{}{},\n\t\ttestNamesSkipped: map[string]struct{}{},\n\t\ttestNamesFailed: map[string]struct{}{},\n\t\tparent: pfs,\n\t}\n\tpfs.mu.Lock()\n\tdefer pfs.mu.Unlock()\n\tpfs.fixtures[t.Name()] = pf\n\treturn pf\n}", "func NewRunner(cli *DockerClient, problemDir, fileName, ft string, timeLimit time.Duration) (*Runner, error) {\n\tdef := languageDefs[ft]\n\n\ttestCtr := &Container{\n\t\tDocker: cli,\n\t\tImage: def.Image,\n\t\tCmd: []string{\"sleep\", \"1000000000000\"},\n\t\tWorkingDir: \"/mnt\",\n\t\tOut: os.Stdout,\n\t\tReadOnly: true,\n\t}\n\n\tif err := testCtr.BindDir(problemDir, \"/mnt\", true); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := testCtr.Run(); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Runner{\n\t\tproblemDir: problemDir,\n\t\tfileName: fileName,\n\t\tcontainer: testCtr,\n\t\ttimeLimit: timeLimit,\n\t\tft: ft,\n\t}, nil\n}", "func PreHook(f func()) {\n\thookLock.Lock()\n\tdefer hookLock.Unlock()\n\n\tprehooks = append(prehooks, f)\n}", "func NewRunner(manager *PM, command *core.Command, factory process.ProcessFactory, hooks ...RunnerHook) Runner {\n\tstatsInterval := command.StatsInterval\n\n\tif statsInterval < 30 {\n\t\tstatsInterval = 30\n\t}\n\n\trunner := &runnerImpl{\n\t\tmanager: manager,\n\t\tcommand: command,\n\t\tfactory: factory,\n\t\tkill: make(chan int),\n\t\thooks: hooks,\n\n\t\tstatsd: stats.NewStatsd(\n\t\t\tcommand.ID,\n\t\t\ttime.Duration(statsInterval)*time.Second,\n\t\t\tmanager.statsFlushCallback),\n\t}\n\n\trunner.wg.Add(1)\n\treturn runner\n}", "func NameFunc(name string, fn func(ctx context.Context) error) NamedRunner {\n\treturn Name(name, RunnerFunc(fn))\n}", "func NewPreparersBuilder(filePath string, params map[string]string) *PreparersBuilder {\n\treturn &PreparersBuilder{preparers: &Preparers{functions: &[]Preparer{}}, filePath: filePath, params: params}\n}", "func newPumpRunner(pipeID string, p phono.Pump) (*pumpRunner, error) {\n\tfn, err := p.Pump(pipeID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tr := pumpRunner{\n\t\tfn: fn,\n\t\tPump: p,\n\t\thooks: bindHooks(p),\n\t}\n\treturn &r, nil\n}", "func NewRunner(dir string, logger *Logger, options Options) Runner {\n\tif !options.FirecrackerOptions.Enabled {\n\t\treturn &dockerRunner{dir: dir, logger: logger, options: options}\n\t}\n\n\treturn &firecrackerRunner{name: options.ExecutorName, dir: dir, logger: logger, options: options}\n}", "func NewPrecompileFilterer(address common.Address, filterer bind.ContractFilterer) (*PrecompileFilterer, error) {\n\tcontract, err := bindPrecompile(address, nil, nil, filterer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &PrecompileFilterer{contract: contract}, nil\n}", "func New() *LegPreAllocGrp {\n\tvar m LegPreAllocGrp\n\treturn &m\n}", "func (b *OGame) BeginNamed(name string) Prioritizable {\n\treturn b.WithPriority(taskRunner.Normal).BeginNamed(name)\n}", "func (tf *TestFixture) PreTest(ctx context.Context, s *testing.FixtTestState) {\n}", "func NewRunner(reader io.Reader, comp Component) (Runner, error) {\n\tr := &runner{\n\t\tcomp: comp,\n\t}\n\trecvComp, ok := comp.(ReceiveComponent)\n\tif ok {\n\t\tr.recvComp = recvComp\n\t}\n\tsendComp, ok := comp.(SendComponent)\n\tif ok {\n\t\tr.sendComp = sendComp\n\t}\n\terr := r.load(reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn r, nil\n}", "func (tr *TaskRunner) prestart() error {\n\t// Determine if the allocation is terminal and we should avoid running\n\t// prestart hooks.\n\tif tr.shouldShutdown() {\n\t\ttr.logger.Trace(\"skipping prestart hooks since allocation is terminal\")\n\t\treturn nil\n\t}\n\n\tif tr.logger.IsTrace() {\n\t\tstart := time.Now()\n\t\ttr.logger.Trace(\"running prestart hooks\", \"start\", start)\n\t\tdefer func() {\n\t\t\tend := time.Now()\n\t\t\ttr.logger.Trace(\"finished prestart hooks\", \"end\", end, \"duration\", end.Sub(start))\n\t\t}()\n\t}\n\n\t// use a join context to allow any blocking pre-start hooks\n\t// to be canceled by either killCtx or shutdownCtx\n\tjoinedCtx, joinedCancel := joincontext.Join(tr.killCtx, tr.shutdownCtx)\n\tdefer joinedCancel()\n\n\tfor _, hook := range tr.runnerHooks {\n\t\tpre, ok := hook.(interfaces.TaskPrestartHook)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tname := pre.Name()\n\n\t\t// Build the request\n\t\treq := interfaces.TaskPrestartRequest{\n\t\t\tTask: tr.Task(),\n\t\t\tTaskDir: tr.taskDir,\n\t\t\tTaskEnv: tr.envBuilder.Build(),\n\t\t\tTaskResources: tr.taskResources,\n\t\t}\n\n\t\torigHookState := tr.hookState(name)\n\t\tif origHookState != nil {\n\t\t\tif origHookState.PrestartDone {\n\t\t\t\ttr.logger.Trace(\"skipping done prestart hook\", \"name\", pre.Name())\n\n\t\t\t\t// Always set env vars from hooks\n\t\t\t\tif name == HookNameDevices {\n\t\t\t\t\ttr.envBuilder.SetDeviceHookEnv(name, origHookState.Env)\n\t\t\t\t} else {\n\t\t\t\t\ttr.envBuilder.SetHookEnv(name, origHookState.Env)\n\t\t\t\t}\n\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Give the hook it's old data\n\t\t\treq.PreviousState = origHookState.Data\n\t\t}\n\n\t\treq.VaultToken = tr.getVaultToken()\n\t\treq.NomadToken = tr.getNomadToken()\n\n\t\t// Time the prestart hook\n\t\tvar start time.Time\n\t\tif tr.logger.IsTrace() {\n\t\t\tstart = time.Now()\n\t\t\ttr.logger.Trace(\"running prestart hook\", \"name\", name, \"start\", start)\n\t\t}\n\n\t\t// Run the prestart hook\n\t\tvar resp interfaces.TaskPrestartResponse\n\t\tif err := pre.Prestart(joinedCtx, &req, &resp); err != nil {\n\t\t\ttr.emitHookError(err, name)\n\t\t\treturn structs.WrapRecoverable(fmt.Sprintf(\"prestart hook %q failed: %v\", name, err), err)\n\t\t}\n\n\t\t// Store the hook state\n\t\t{\n\t\t\thookState := &state.HookState{\n\t\t\t\tData: resp.State,\n\t\t\t\tPrestartDone: resp.Done,\n\t\t\t\tEnv: resp.Env,\n\t\t\t}\n\n\t\t\t// Store and persist local state if the hook state has changed\n\t\t\tif !hookState.Equal(origHookState) {\n\t\t\t\ttr.stateLock.Lock()\n\t\t\t\ttr.localState.Hooks[name] = hookState\n\t\t\t\ttr.stateLock.Unlock()\n\n\t\t\t\tif err := tr.persistLocalState(); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Store the environment variables returned by the hook\n\t\tif name == HookNameDevices {\n\t\t\ttr.envBuilder.SetDeviceHookEnv(name, resp.Env)\n\t\t} else {\n\t\t\ttr.envBuilder.SetHookEnv(name, resp.Env)\n\t\t}\n\n\t\t// Store the resources\n\t\tif len(resp.Devices) != 0 {\n\t\t\ttr.hookResources.setDevices(resp.Devices)\n\t\t}\n\t\tif len(resp.Mounts) != 0 {\n\t\t\ttr.hookResources.setMounts(resp.Mounts)\n\t\t}\n\n\t\tif tr.logger.IsTrace() {\n\t\t\tend := time.Now()\n\t\t\ttr.logger.Trace(\"finished prestart hook\", \"name\", name, \"end\", end, \"duration\", end.Sub(start))\n\t\t}\n\t}\n\n\treturn nil\n}", "func WithPreRunE(preRunE func(cmd *cobra.Command, args []string) error) RunnerOption {\n\treturn func(k *PluginRunner) {\n\t\tk.cmd.PreRunE = func(cmd *cobra.Command, args []string) error {\n\t\t\tif err := preRunE(cmd, args); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// Explicitly call through to the default implementation to invoke Configurable.Config\n\t\t\treturn k.preRun(cmd, args)\n\t\t}\n\t}\n}", "func (tc *TestCase) SetPreTestFunc(curFunc func(data interface{}, context *TestContext)) {\n\tif tc.PreTestFunc == nil {\n\t\ttc.PreTestFunc = curFunc\n\t}\n}", "func (client ModelClient) AddPrebuiltPreparer(ctx context.Context, appID uuid.UUID, versionID string, prebuiltExtractorNames []string) (*http.Request, error) {\n\turlParameters := map[string]interface{}{\n\t\t\"Endpoint\": client.Endpoint,\n\t}\n\n\tpathParameters := map[string]interface{}{\n\t\t\"appId\": autorest.Encode(\"path\", appID),\n\t\t\"versionId\": autorest.Encode(\"path\", versionID),\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsContentType(\"application/json; charset=utf-8\"),\n\t\tautorest.AsPost(),\n\t\tautorest.WithCustomBaseURL(\"{Endpoint}/luis/api/v2.0\", urlParameters),\n\t\tautorest.WithPathParameters(\"/apps/{appId}/versions/{versionId}/prebuilts\", pathParameters),\n\t\tautorest.WithJSON(prebuiltExtractorNames))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func PrebuiltFactory() android.Module {\n\tmodule := &Prebuilt{}\n\tmodule.AddProperties(&module.properties)\n\tandroid.InitSingleSourcePrebuiltModule(module, &module.properties, \"Source\")\n\tandroid.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)\n\treturn module\n}", "func NewPrecompile(address common.Address, backend bind.ContractBackend) (*Precompile, error) {\n\tcontract, err := bindPrecompile(address, backend, backend, backend)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Precompile{PrecompileCaller: PrecompileCaller{contract: contract}, PrecompileTransactor: PrecompileTransactor{contract: contract}, PrecompileFilterer: PrecompileFilterer{contract: contract}}, nil\n}", "func (client AppsClient) AddCustomPrebuiltDomainPreparer(ctx context.Context, prebuiltDomainCreateObject PrebuiltDomainCreateObject) (*http.Request, error) {\n\turlParameters := map[string]interface{}{\n\t\t\"AzureRegion\": client.AzureRegion,\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsContentType(\"application/json; charset=utf-8\"),\n\t\tautorest.AsPost(),\n\t\tautorest.WithCustomBaseURL(\"https://{AzureRegion}.api.cognitive.microsoft.com/luis/api/v2.0\", urlParameters),\n\t\tautorest.WithPath(\"/apps/customprebuiltdomains\"),\n\t\tautorest.WithJSON(prebuiltDomainCreateObject))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func NewPregeneratorFromFountain(f *Fountain, pregenInterval int64) *PreGenerator {\n\tpg := &PreGenerator{\n\t\tstartdate: f.startdate,\n\t\tduration: f.duration,\n\t\tpregenInterval: pregenInterval,\n\t\tratchet: f.serviceDesc.ratchet.Copy(),\n\t\tlastCounter: 1,\n\t}\n\treturn pg\n}", "func NewCustom(executor executor.Executor) executor.Launcher {\n\treturn New(executor, fmt.Sprintf(\"stress-ng-custom %s\", StressngCustomArguments.Value()), StressngCustomArguments.Value())\n}", "func NewRunner() *Runner {\n\tr := &Runner{}\n\tr.generator = romanumeral.NewRomanNumeralGenerator()\n\n\treturn r\n}", "func New(stages ...StageRunner) *Pipeline {\n\treturn &Pipeline{\n\t\tstages: stages,\n\t}\n}", "func New(config *Config) functions.Runner {\n\treturn &impl{*config}\n}", "func newRestoreRunner(restore *backupv1alpha1.Restore, common service.CommonObjects, observer *observe.Observer) *restoreRunner {\n\treturn &restoreRunner{\n\t\trestore: restore,\n\t\tCommonObjects: common,\n\t\tconfig: newConfig(),\n\t\tobserver: observer,\n\t}\n}", "func NewRunner(config *Config, client Client, server Server) *Runner {\n\treturn &Runner{\n\t\tconfig: config,\n\t\tclient: client,\n\t\tserver: server,\n\t}\n}", "func Name(name string, runner Runner) NamedRunner {\n\treturn &namedRunner{\n\t\tRunner: runner,\n\t\tname: name,\n\t}\n}", "func NewRunner() Runner {\n\treturn execRunner{}\n}", "func New() (*Runner, error) {\n\tpool, err := dockertest.NewPool(\"\")\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to start pool\")\n\t}\n\n\treturn NewWithPool(pool), nil\n}", "func (f Factory) WithPreprocessTxHook(preprocessFn client.PreprocessTxFn) Factory {\n\tf.preprocessTxHook = preprocessFn\n\treturn f\n}", "func NewSingleRunner(\n\texec execer.Execer,\n\tfilerMap runner.RunTypeMap,\n\toutput runner.OutputCreator,\n\tstat stats.StatsReceiver,\n\tdirMonitor *stats.DirsMonitor,\n\trID runner.RunnerID,\n\tpreprocessors []func() error,\n\tpostprocessors []func() error,\n\tuploader LogUploader,\n) runner.Service {\n\treturn NewQueueRunner(exec, filerMap, output, 0, stat, dirMonitor, rID, preprocessors, postprocessors, uploader)\n}", "func newProfile(ctx context.Context, cfg config.KubeSchedulerProfile, r frameworkruntime.Registry, recorderFact RecorderFactory,\n\topts ...frameworkruntime.Option) (framework.Framework, error) {\n\trecorder := recorderFact(cfg.SchedulerName)\n\topts = append(opts, frameworkruntime.WithEventRecorder(recorder))\n\treturn frameworkruntime.NewFramework(ctx, r, &cfg, opts...)\n}", "func NewRunner(executor Executor, rep reporter.Reporter) *Runner {\n\treturn &Runner{\n\t\texecutor: executor,\n\t\treporter: rep,\n\t}\n}", "func (pu *PatientrecordUpdate) SetPrenameID(id int) *PatientrecordUpdate {\n\tpu.mutation.SetPrenameID(id)\n\treturn pu\n}", "func (puo *PatientrecordUpdateOne) SetPrenameID(id int) *PatientrecordUpdateOne {\n\tpuo.mutation.SetPrenameID(id)\n\treturn puo\n}", "func NewNamePreclaimTx(accountID, name string, ttlnoncer TTLNoncer) (tx *NamePreclaimTx, nameSalt *big.Int, err error) {\n\tttl, _, accountNonce, err := ttlnoncer(accountID, config.Client.TTL)\n\tif err != nil {\n\t\treturn\n\t}\n\t// calculate the commitment and get the preclaim salt since the salt is 32\n\t// bytes long, you must use a big.Int to convert it into an integer\n\tcm, nameSalt, err := generateCommitmentID(name)\n\tif err != nil {\n\t\treturn\n\t}\n\n\ttx = &NamePreclaimTx{accountID, cm, config.Client.Fee, ttl, accountNonce}\n\tCalculateFee(tx)\n\treturn\n}", "func (puo *PatientrecordUpdateOne) SetPrename(p *Prename) *PatientrecordUpdateOne {\n\treturn puo.SetPrenameID(p.ID)\n}", "func V23RunnerFunc(ctxfn func() *context.T, run func(*context.T, *cmdline.Env, []string) error) cmdline.Runner {\n\treturn RunnerFunc(runner{false, ctxfn, run}.Run)\n}", "func GetPre(config *viper.Viper, spec *models.Spec) (PreOperation, map[string]interface{}) {\n\tif spec.PreRun == nil {\n\t\treturn &DummyPre{}, map[string]interface{}{}\n\t}\n\n\tswitch spec.PreRun.Function {\n\tcase PreRunFunctionRedis:\n\t\treturn redis.GetPre(config), spec.PreRun.Args\n\t}\n\treturn &DummyPre{}, map[string]interface{}{}\n}", "func NewRunner(config *config.Config, once bool) (*Runner, error) {\n\t// var repos repository.Repo\n\tlogger := log.WithField(\"caller\", \"runner\")\n\n\t// Create repos from configuration\n\trepos, err := repository.LoadRepos(config)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Cannot load repositories from configuration: %s\", err)\n\t}\n\tvar reposI = make([]repository.Repo, len(repos))\n\tfor index, repo := range repos {\n\t\treposI[index] = repo\n\t}\n\t// Create watcher to watch for repo changes\n\twatcher := watch.New(reposI, config.HookSvr, once)\n\n\t// Create the handler\n\thandler, err := kv.New(config.Consul)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trunner := &Runner{\n\t\tlogger: logger,\n\t\tErrCh: make(chan error),\n\t\tRcvDoneCh: make(chan struct{}, 1),\n\t\tSndDoneCh: make(chan struct{}, 1),\n\t\tonce: once,\n\t\tkvHandler: handler,\n\t\twatcher: watcher,\n\t}\n\n\treturn runner, nil\n}", "func (pu *PatientrecordUpdate) SetPrename(p *Prename) *PatientrecordUpdate {\n\treturn pu.SetPrenameID(p.ID)\n}", "func NewRunner(view ui.ViewInterface, proxy proxy.ProxyInterface, project *config.Project) *Runner {\n\treturn &Runner{\n\t\tproxy: proxy,\n\t\tprojectName: project.Name,\n\t\tapplications: project.Applications,\n\t\tcmds: make(map[string]*exec.Cmd, 0),\n\t\tview: view,\n\t}\n}", "func CreatePreFeaturizedMultiBandImageClusteringPipeline(name string, description string, variables []*model.Variable, params *ClusterParams) (*FullySpecifiedPipeline, error) {\n\tvar steps []Step\n\tif params.UseKMeans {\n\t\tif params.PoolFeatures {\n\t\t\tsteps = []Step{\n\t\t\t\tNewDatasetToDataframeStep(map[string]DataRef{\"inputs\": &PipelineDataRef{0}}, []string{\"produce\"}),\n\t\t\t\tNewDistilColumnParserStep(map[string]DataRef{\"inputs\": &StepDataRef{0, \"produce\"}}, []string{\"produce\"}, []string{model.TA2RealType}),\n\t\t\t\tNewExtractColumnsByStructuralTypeStep(map[string]DataRef{\"inputs\": &StepDataRef{1, \"produce\"}}, []string{\"produce\"},\n\t\t\t\t\t[]string{\n\t\t\t\t\t\t\"float\", // python type\n\t\t\t\t\t\t\"numpy.float32\", // numpy types\n\t\t\t\t\t\t\"numpy.float64\",\n\t\t\t\t\t}),\n\t\t\t\tNewKMeansClusteringStep(map[string]DataRef{\"inputs\": &StepDataRef{2, \"produce\"}}, []string{\"produce\"}, params.ClusterCount),\n\t\t\t\tNewConstructPredictionStep(map[string]DataRef{\"inputs\": &StepDataRef{3, \"produce\"}}, []string{\"produce\"}, &StepDataRef{1, \"produce\"}),\n\t\t\t}\n\t\t} else {\n\t\t\tsteps = []Step{\n\t\t\t\tNewDatasetToDataframeStep(map[string]DataRef{\"inputs\": &PipelineDataRef{0}}, []string{\"produce\"}),\n\t\t\t\tNewDistilColumnParserStep(map[string]DataRef{\"inputs\": &StepDataRef{0, \"produce\"}}, []string{\"produce\"}, []string{model.TA2RealType}),\n\t\t\t\tNewPrefeaturisedPoolingStep(map[string]DataRef{\"inputs\": &StepDataRef{1, \"produce\"}}, []string{\"produce\"}),\n\t\t\t\tNewExtractColumnsByStructuralTypeStep(map[string]DataRef{\"inputs\": &StepDataRef{2, \"produce\"}}, []string{\"produce\"},\n\t\t\t\t\t[]string{\n\t\t\t\t\t\t\"float\", // python type\n\t\t\t\t\t\t\"numpy.float32\", // numpy types\n\t\t\t\t\t\t\"numpy.float64\",\n\t\t\t\t\t}),\n\t\t\t\tNewKMeansClusteringStep(map[string]DataRef{\"inputs\": &StepDataRef{3, \"produce\"}}, []string{\"produce\"}, params.ClusterCount),\n\t\t\t\tNewConstructPredictionStep(map[string]DataRef{\"inputs\": &StepDataRef{4, \"produce\"}}, []string{\"produce\"}, &StepDataRef{1, \"produce\"}),\n\t\t\t}\n\t\t}\n\t} else {\n\t\tsteps = []Step{\n\t\t\tNewDatasetToDataframeStep(map[string]DataRef{\"inputs\": &PipelineDataRef{0}}, []string{\"produce\"}),\n\t\t\tNewDistilColumnParserStep(map[string]DataRef{\"inputs\": &StepDataRef{0, \"produce\"}}, []string{\"produce\"}, []string{model.TA2RealType}),\n\t\t\tNewExtractColumnsByStructuralTypeStep(map[string]DataRef{\"inputs\": &StepDataRef{1, \"produce\"}}, []string{\"produce\"},\n\t\t\t\t[]string{\n\t\t\t\t\t\"float\", // python type\n\t\t\t\t\t\"numpy.float32\", // numpy types\n\t\t\t\t\t\"numpy.float64\",\n\t\t\t\t}),\n\t\t\tNewHDBScanStep(map[string]DataRef{\"inputs\": &StepDataRef{2, \"produce\"}}, []string{\"produce\"}),\n\t\t\tNewExtractColumnsStep(map[string]DataRef{\"inputs\": &StepDataRef{3, \"produce\"}}, []string{\"produce\"}, []int{-1}),\n\t\t\t// Needs to be added since the input dataset doesn't have a target, and hdbscan doesn't set the target itself. Without this being\n\t\t\t// set the subsequent ConstructPredictions step doesn't work.\n\t\t\tNewAddSemanticTypeStep(map[string]DataRef{\"inputs\": &StepDataRef{4, \"produce\"}}, []string{\"produce\"}, &ColumnUpdate{\n\t\t\t\tIndices: []int{0},\n\t\t\t\tSemanticTypes: []string{\"https://metadata.datadrivendiscovery.org/types/PredictedTarget\"},\n\t\t\t}),\n\t\t\tNewConstructPredictionStep(map[string]DataRef{\"inputs\": &StepDataRef{5, \"produce\"}}, []string{\"produce\"}, &StepDataRef{1, \"produce\"}),\n\t\t}\n\t}\n\n\tinputs := []string{\"inputs\"}\n\toutputs := []DataRef{&StepDataRef{len(steps) - 1, \"produce\"}}\n\n\tpipeline, err := NewPipelineBuilder(name, description, inputs, outputs, steps).Compile()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpipelineJSON, err := MarshalSteps(pipeline)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfullySpecified := &FullySpecifiedPipeline{\n\t\tPipeline: pipeline,\n\t\tEquivalentValues: []interface{}{pipelineJSON},\n\t}\n\treturn fullySpecified, nil\n}", "func (p *PrecheckHandler) Precheck(c echo.Context, clusterID uint, driverID uint, modules []model.ModuleType, moduleConfig string) error {\n\tavailableModules := make(map[string]string)\n\n\tcluster, err := p.clusterStore.GetByID(clusterID)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif cluster == nil {\n\t\treturn fmt.Errorf(\"not able to find cluster with id %d\", clusterID)\n\t}\n\n\tcfs, err := p.configFileStore.GetAll()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif driverID > 0 {\n\t\tdriver, err := p.driverStore.GetByID(driverID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif driver == nil {\n\t\t\treturn fmt.Errorf(\"not able to find driver with id %d\", driverID)\n\t\t}\n\n\t\tdriverPrechecks := p.precheckGetter.GetDriverPrechecks(driver.StorageArrayType.Name, cluster.ConfigFileData, cluster.ClusterDetails.Nodes, modules, c.Logger())\n\t\tfor _, precheck := range driverPrechecks {\n\t\t\tc.Logger().Printf(\"Running precheck: %T for driver of type %s\", precheck, driver.StorageArrayType.Name)\n\t\t\terr := precheck.Validate()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tavailableModules[\"csidriver\"] = driver.StorageArrayType.Name\n\t}\n\n\tfor _, m := range modules {\n\t\tavailableModules[m.Name] = m.Name\n\t}\n\n\t// Run pre-checks for standalone modules (ex: observability)\n\tfor _, module := range modules {\n\t\tmodulePrechecks := p.precheckGetter.GetModuleTypePrechecks(module.Name, moduleConfig, cluster.ConfigFileData, cfs, availableModules)\n\t\tfor _, precheck := range modulePrechecks {\n\t\t\tc.Logger().Printf(\"Running precheck: %T for %s module\", precheck, module.Name)\n\t\t\terr := precheck.Validate()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (r *registryExecutor) PreCheck(context.Context) error {\n\treturn nil\n}", "func PersistentPreRunEFn(ctx *Context) func(*cobra.Command, []string) error {\n\treturn func(cmd *cobra.Command, args []string) error {\n\t\trootViper := viper.New()\n\t\trootViper.BindPFlags(cmd.Flags())\n\t\trootViper.BindPFlags(cmd.PersistentFlags())\n\n\t\tif cmd.Name() == version.Cmd.Name() {\n\t\t\treturn nil\n\t\t}\n\n\t\tconfig, err := interceptConfigs(ctx, rootViper)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tlogger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))\n\t\tlogger, err = tmflags.ParseLogLevel(config.LogLevel, logger, tmcfg.DefaultLogLevel())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif rootViper.GetBool(tmcli.TraceFlag) {\n\t\t\tlogger = log.NewTracingLogger(logger)\n\t\t}\n\n\t\tlogger = logger.With(\"module\", \"main\")\n\t\tctx.Config = config\n\t\tctx.Logger = logger\n\n\t\treturn nil\n\t}\n}", "func newFromName(clusterClient kubernetes.Interface, client k8s.Interface, wfr, namespace string) (Operator, error) {\n\tw, err := client.CycloneV1alpha1().WorkflowRuns(namespace).Get(context.TODO(), wfr, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &operator{\n\t\tclusterClient: clusterClient,\n\t\tclient: client,\n\t\trecorder: common.GetEventRecorder(client, common.EventSourceWfrController),\n\t\twfr: w,\n\t}, nil\n}", "func NewEventRunner(events []cases.EventDescriptor, raftEngine *RaftEngine) *EventRunner {\n\ter := &EventRunner{events: make([]Event, 0, len(events)), raftEngine: raftEngine}\n\tfor _, e := range events {\n\t\tevent := parserEvent(e)\n\t\tif event != nil {\n\t\t\ter.events = append(er.events, event)\n\t\t}\n\t}\n\treturn er\n}", "func NewRunner(\n\tcheckInterval time.Duration,\n\temissionInterval time.Duration,\n\ttimeoutInterval time.Duration,\n\tlogger lager.Logger,\n\tchecker Checker,\n\texecutorClient executor.Client,\n\tmetronClient loggingclient.IngressClient,\n\tclock clock.Clock,\n) *Runner {\n\treturn &Runner{\n\t\tcheckInterval: checkInterval,\n\t\temissionInterval: emissionInterval,\n\t\ttimeoutInterval: timeoutInterval,\n\t\tlogger: logger.Session(\"garden-healthcheck\"),\n\t\tchecker: checker,\n\t\texecutorClient: executorClient,\n\t\tmetronClient: metronClient,\n\t\tclock: clock,\n\t\thealthy: false,\n\t\tfailures: 0,\n\t}\n}", "func (o *RunSuiteOptions) SuiteWithProviderPreSuite() error {\n\tif err := o.SuiteWithInitializedProviderPreSuite(); err != nil {\n\t\treturn err\n\t}\n\to.GinkgoRunSuiteOptions.MatchFn = o.config.MatchFn()\n\treturn nil\n}", "func newBaseRunner(collector *resourceStatusCollector) *baseRunner {\n\treturn &baseRunner{\n\t\tcollector: collector,\n\t}\n}", "func NewNameLT(v string) predicate.User {\n\treturn predicate.User(func(s *sql.Selector) {\n\t\ts.Where(sql.LT(s.C(FieldNewName), v))\n\t})\n}", "func (client ModelClient) AddCustomPrebuiltDomainPreparer(ctx context.Context, appID uuid.UUID, versionID string, prebuiltDomainObject PrebuiltDomainCreateBaseObject) (*http.Request, error) {\n\turlParameters := map[string]interface{}{\n\t\t\"Endpoint\": client.Endpoint,\n\t}\n\n\tpathParameters := map[string]interface{}{\n\t\t\"appId\": autorest.Encode(\"path\", appID),\n\t\t\"versionId\": autorest.Encode(\"path\", versionID),\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsContentType(\"application/json; charset=utf-8\"),\n\t\tautorest.AsPost(),\n\t\tautorest.WithCustomBaseURL(\"{Endpoint}/luis/api/v2.0\", urlParameters),\n\t\tautorest.WithPathParameters(\"/apps/{appId}/versions/{versionId}/customprebuiltdomains\", pathParameters),\n\t\tautorest.WithJSON(prebuiltDomainObject))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func NewFakeRunner(t *testing.T) *FakeRunner {\n\treturn &FakeRunner{\n\t\tservices: map[string]serviceState{},\n\t\tcmds: []string{},\n\t\tt: t,\n\t\tcontainers: map[string]string{},\n\t\timages: map[string]string{},\n\t}\n}", "func New(opts ...func(*Runner) error) (*Runner, error) {\n\tr := &Runner{usedNew: true}\n\tfor _, opt := range opts {\n\t\tif err := opt(r); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\t// Set the default fallbacks, if necessary.\n\tif r.Env == nil {\n\t\tEnv(nil)(r)\n\t}\n\tif r.Dir == \"\" {\n\t\tif err := Dir(\"\")(r); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tif r.Exec == nil {\n\t\tModule(nil)(r)\n\t}\n\tif r.Open == nil {\n\t\tModule(nil)(r)\n\t}\n\tif r.Stdout == nil || r.Stderr == nil {\n\t\tStdIO(r.Stdin, r.Stdout, r.Stderr)(r)\n\t}\n\treturn r, nil\n}", "func NewPipeline(ctx *pulumi.Context,\n\tname string, args *PipelineArgs, opts ...pulumi.ResourceOption) (*Pipeline, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.BootstrapConfiguration == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'BootstrapConfiguration'\")\n\t}\n\tif args.PipelineType == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'PipelineType'\")\n\t}\n\tif args.ResourceGroupName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ResourceGroupName'\")\n\t}\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:devops/v20200713preview:Pipeline\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:devops:Pipeline\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:devops:Pipeline\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:devops/v20190701preview:Pipeline\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:devops/v20190701preview:Pipeline\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource Pipeline\n\terr := ctx.RegisterResource(\"azure-native:devops/v20200713preview:Pipeline\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (l *jsiiProxy_LambdaDeploymentGroup) AddPreHook(preHook awslambda.IFunction) {\n\t_jsii_.InvokeVoid(\n\t\tl,\n\t\t\"addPreHook\",\n\t\t[]interface{}{preHook},\n\t)\n}", "func (w *DefaultPreWorkflowHooksCommandRunner) RunPreHooks(\n\tbaseRepo models.Repo,\n\theadRepo models.Repo,\n\tpull models.PullRequest,\n\tuser models.User,\n) {\n\tif opStarted := w.Drainer.StartOp(); !opStarted {\n\t\tif commentErr := w.VCSClient.CreateComment(baseRepo, pull.Num, ShutdownComment, \"pre_workflow_hooks\"); commentErr != nil {\n\t\t\tw.Logger.Log(logging.Error, \"unable to comment that Atlantis is shutting down: %s\", commentErr)\n\t\t}\n\t\treturn\n\t}\n\tdefer w.Drainer.OpDone()\n\n\tlog := w.buildLogger(baseRepo.FullName, pull.Num)\n\tdefer w.logPanics(baseRepo, pull.Num, log)\n\n\tlog.Info(\"running pre hooks\")\n\n\tunlockFn, err := w.WorkingDirLocker.TryLock(baseRepo.FullName, pull.Num, DefaultWorkspace)\n\tif err != nil {\n\t\tlog.Warn(\"workspace is locked\")\n\t\treturn\n\t}\n\tlog.Debug(\"got workspace lock\")\n\tdefer unlockFn()\n\n\trepoDir, _, err := w.WorkingDir.Clone(log, headRepo, pull, DefaultWorkspace)\n\tif err != nil {\n\t\tlog.Err(\"unable to run pre workflow hooks: %s\", err)\n\t\treturn\n\t}\n\n\tpreWorkflowHooks := make([]*valid.PreWorkflowHook, 0)\n\tfor _, repo := range w.GlobalCfg.Repos {\n\t\tif repo.IDMatches(baseRepo.ID()) && len(repo.PreWorkflowHooks) > 0 {\n\t\t\tpreWorkflowHooks = append(preWorkflowHooks, repo.PreWorkflowHooks...)\n\t\t}\n\t}\n\n\tctx := models.PreWorkflowHookCommandContext{\n\t\tBaseRepo: baseRepo,\n\t\tHeadRepo: headRepo,\n\t\tLog: log,\n\t\tPull: pull,\n\t\tUser: user,\n\t\tVerbose: false,\n\t}\n\n\terr = w.runHooks(ctx, preWorkflowHooks, repoDir)\n\n\tif err != nil {\n\t\tlog.Err(\"pre workflow hook run error results: %s\", err)\n\t}\n}", "func NewRunner(sources []string, count int, languagesYml string, autoPull bool, log *logrus.Logger) (*Runner, error) {\n\tvar langs *Languages\n\n\tif languagesYml == \"\" {\n\t\tlanguagesYml = DefaultLanguagesYml\n\t}\n\n\tif _, err := os.Stat(languagesYml); err != nil && autoPull {\n\t\tlog.WithFields(logrus.Fields{\n\t\t\t\"url\": DefaultLanguagesYmlURL,\n\t\t\t\"dest\": languagesYml,\n\t\t}).Info(\"downloading\")\n\n\t\terr = PullLanguagesYml(DefaultLanguagesYmlURL, languagesYml)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif _, err := os.Stat(languagesYml); err == nil {\n\t\tlog.WithFields(logrus.Fields{\n\t\t\t\"languages\": languagesYml,\n\t\t}).Info(\"loading\")\n\n\t\tlangs, err = LoadLanguages(languagesYml)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn &Runner{\n\t\tSources: sources,\n\t\tCount: count,\n\t\tFrobs: DefaultFrobs,\n\t\tLanguages: langs,\n\n\t\tlog: log,\n\t}, nil\n}", "func TestPreprocess(t *testing.T) {\n\tdefaultRes := resource.JobResource{\n\t\tWorkerCPU: \"1000m\",\n\t\tWorkerMemory: \"1Gi\",\n\t\tPSCPU: \"1000m\",\n\t\tPSMemory: \"1Gi\",\n\t\tMasterCPU: \"1000m\",\n\t\tMasterMemory: \"1Gi\",\n\t}\n\n\ti := New(defaultRes)\n\ttype TestCase struct {\n\t\tCode string\n\t\tExpected *types.Parameter\n\t}\n\ttestCases := []TestCase{\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1\n%worker=1\nsome code here.\n`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tWorkerCount: 1,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1\nsome code here.\n`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%cleanPolicy=running`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tCleanPolicy: types.CleanPodPolicyRunning,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%cleanPolicy=all`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tCleanPolicy: types.CleanPodPolicyAll,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%cleanPolicy=none`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tCleanPolicy: types.CleanPodPolicyNone,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\t// Invalid clean policy will use default value none.\n\t\t\tCode: `%framework=tensorflow\n%cleanPolicy=test`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tCleanPolicy: types.CleanPodPolicyNone,\n\t\t\t\tResource: defaultRes,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1;%cpu=100m;%memory=100Mi`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tResource: resource.JobResource{\n\t\t\t\t\tPSCPU: \"100m\",\n\t\t\t\t\tPSMemory: \"100Mi\",\n\t\t\t\t\tWorkerCPU: defaultRes.WorkerCPU,\n\t\t\t\t\tWorkerMemory: defaultRes.WorkerMemory,\n\t\t\t\t\tMasterCPU: defaultRes.MasterCPU,\n\t\t\t\t\tMasterMemory: defaultRes.MasterMemory,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=tensorflow\n%ps=1;%cpu=100m;%memory=100Mi\n%worker=2;%cpu=10m;%memory=10Mi`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypeTensorFlow,\n\t\t\t\tPSCount: 1,\n\t\t\t\tWorkerCount: 2,\n\t\t\t\tResource: resource.JobResource{\n\t\t\t\t\tPSCPU: \"100m\",\n\t\t\t\t\tPSMemory: \"100Mi\",\n\t\t\t\t\tWorkerCPU: \"10m\",\n\t\t\t\t\tWorkerMemory: \"10Mi\",\n\t\t\t\t\tMasterCPU: defaultRes.MasterCPU,\n\t\t\t\t\tMasterMemory: defaultRes.MasterMemory,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tCode: `%framework=pytorch\n%master=1;%cpu=100m;%memory=100Mi\n%worker=2;%cpu=10m;%memory=10Mi`,\n\t\t\tExpected: &types.Parameter{\n\t\t\t\tFramework: types.FrameworkTypePyTorch,\n\t\t\t\tMasterCount: 1,\n\t\t\t\tWorkerCount: 2,\n\t\t\t\tResource: resource.JobResource{\n\t\t\t\t\tPSCPU: defaultRes.PSCPU,\n\t\t\t\t\tPSMemory: defaultRes.PSMemory,\n\t\t\t\t\tWorkerCPU: \"10m\",\n\t\t\t\t\tWorkerMemory: \"10Mi\",\n\t\t\t\t\tMasterCPU: \"100m\",\n\t\t\t\t\tMasterMemory: \"100Mi\",\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, tc := range testCases {\n\t\tactual, err := i.Preprocess(tc.Code)\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Expected nil got error: %v\", err)\n\t\t}\n\t\tif !reflect.DeepEqual(actual, tc.Expected) {\n\t\t\tt.Errorf(\"Expected %v, got %v\", tc.Expected, actual)\n\t\t}\n\t}\n}", "func startRunner(manifest *manifest) (*testRunner, error) {\n\ttype runner struct {\n\t\tName string\n\t\tCommand struct {\n\t\t\tWindows string\n\t\t\tLinux string\n\t\t\tDarwin string\n\t\t}\n\t}\n\n\tvar r runner\n\tcontents := readFileContents(fmt.Sprintf(\"runner/%s.json\", manifest.Language))\n\terr := json.Unmarshal([]byte(contents), &r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tcommand := \"\"\n\tswitch runtime.GOOS {\n\tcase \"windows\":\n\t\tcommand = r.Command.Windows\n\t\tbreak\n\tcase \"darwin\":\n\t\tcommand = r.Command.Darwin\n\t\tbreak\n\tdefault:\n\t\tcommand = r.Command.Linux\n\t\tbreak\n\t}\n\n\tcmd := exec.Command(command)\n\tcmd.Stdout = os.Stdout\n\tcmd.Stderr = os.Stderr\n\terr = cmd.Start()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Wait for the process to exit so we will get a detailed error message\n\tgo func() {\n\t\terr := cmd.Wait()\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Runner exited with error: %s\\n\", err.Error())\n\t\t}\n\t}()\n\n\treturn &testRunner{cmd: cmd}, nil\n}", "func TestPruner(t *testing.T) {\n\tte := framework.SetupAvailableImageRegistry(t, nil)\n\tdefer framework.TeardownImageRegistry(te)\n\n\tdefer func() {\n\t\tif t.Failed() {\n\t\t\tframework.DumpImagePrunerResource(t, te.Client())\n\t\t}\n\t}()\n\n\t// TODO: Move these checks to a conformance test run on all providers\n\tframework.EnsureInternalRegistryHostnameIsSet(te)\n\tframework.EnsureOperatorIsNotHotLooping(te)\n\tframework.EnsureServiceCAConfigMap(te)\n\tframework.EnsureNodeCADaemonSetIsAvailable(te)\n\n\t// Check that the pruner custom resource was created\n\tcr, err := te.Client().ImagePruners().Get(\n\t\tcontext.Background(), defaults.ImageRegistryImagePrunerResourceName, metav1.GetOptions{},\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif !cr.Spec.IgnoreInvalidImageReferences {\n\t\tt.Errorf(\"the default pruner config should have spec.ignoreInvalidImageReferences set to true, but it doesn't\")\n\t}\n\n\t// Check that the cronjob was created\n\tcronjob, err := te.Client().BatchV1beta1Interface.CronJobs(defaults.ImageRegistryOperatorNamespace).Get(\n\t\tcontext.Background(), \"image-pruner\", metav1.GetOptions{},\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\t// Check that the Available condition is set for the pruner\n\tframework.PrunerConditionExistsWithStatusAndReason(te, \"Available\", operatorapi.ConditionTrue, \"AsExpected\")\n\n\t// Check that the Scheduled condition is set for the cronjob\n\tframework.PrunerConditionExistsWithStatusAndReason(te, \"Scheduled\", operatorapi.ConditionTrue, \"Scheduled\")\n\n\t// Check that the Failed condition is set correctly for the last job run\n\tframework.PrunerConditionExistsWithStatusAndReason(te, \"Failed\", operatorapi.ConditionFalse, \"Complete\")\n\n\tif !containsString(cronjob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Args, \"--ignore-invalid-refs=true\") {\n\t\tdefer framework.DumpYAML(t, \"cronjob\", cronjob)\n\t\tt.Fatalf(\"flag --ignore-invalid-refs=true is not found\")\n\t}\n\n\t// Check that making changes to the pruner custom resource trickle down to the cronjob\n\t// and that the conditions get updated correctly\n\ttruePtr := true\n\tcr.Spec.Suspend = &truePtr\n\tcr.Spec.Schedule = \"10 10 * * *\"\n\tcr.Spec.IgnoreInvalidImageReferences = false\n\t_, err = te.Client().ImagePruners().Update(\n\t\tcontext.Background(), cr, metav1.UpdateOptions{},\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer func() {\n\t\t// Reset the CR\n\t\tcr, err := te.Client().ImagePruners().Get(\n\t\t\tcontext.Background(), defaults.ImageRegistryImagePrunerResourceName, metav1.GetOptions{},\n\t\t)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\n\t\tfalsePtr := false\n\t\tcr.Spec.Suspend = &falsePtr\n\t\tcr.Spec.Schedule = \"\"\n\t\t_, err = te.Client().ImagePruners().Update(\n\t\t\tcontext.Background(), cr, metav1.UpdateOptions{},\n\t\t)\n\t\tif err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}()\n\n\t// Check that the Scheduled condition is set for the cronjob\n\tframework.PrunerConditionExistsWithStatusAndReason(te, \"Scheduled\", operatorapi.ConditionFalse, \"Suspended\")\n\n\tcronjob, err = te.Client().BatchV1beta1Interface.CronJobs(defaults.ImageRegistryOperatorNamespace).Get(\n\t\tcontext.Background(), \"image-pruner\", metav1.GetOptions{},\n\t)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif *cronjob.Spec.Suspend != true {\n\t\tt.Errorf(\"The cronjob Spec.Suspend field should have been true, but was %v instead\", *cronjob.Spec.Suspend)\n\t}\n\n\tif cronjob.Spec.Schedule != \"10 10 * * *\" {\n\t\tt.Errorf(\"The cronjob Spec.Schedule field should have been '10 10 * * *' but was %v instead\", cronjob.Spec.Schedule)\n\t}\n\n\tif !containsString(cronjob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Args, \"--ignore-invalid-refs=false\") {\n\t\tt.Fatalf(\"The cronjob container arguments should contain --ignore-invalid-refs=false, but arguments are %v\", cronjob.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Args)\n\t}\n}", "func NewRunnerAPI() runnerAPI {\n\treturn runnerAPI{}\n}", "func ExecutePre(ctx context.Context, c string) {\n\texecute(ctx, c, preJobMap)\n}", "func (name *GroupNameFlag) Preprocess(c *app.Context) (err error) {\n\tif name.Value == \"\" {\n\t\treturn\n\t}\n\tgroupName := lib.ParseGroupName(name.Value, c.Config().GetGroup())\n\tname.GroupName = groupName\n\treturn\n}", "func New() *Runner {\n\treturn &Runner{\n\t\tmanager: endly.New(),\n\t\tEvents: NewEventTags(),\n\t\tRenderer: NewRenderer(os.Stdout, 120),\n\t\tgroup: &MessageGroup{},\n\t\txUnitSummary: xunit.NewTestsuite(),\n\t\tStyle: NewStyle(),\n\t}\n}", "func NewStage(name string, e func(*Context) error) Stage {\n\treturn &baseStage{name: name, execFunc: e}\n}", "func GetRunFnRunner(name string) *RunFnRunner {\n\tr := &RunFnRunner{}\n\tc := &cobra.Command{\n\t\tUse: \"run DIR\",\n\t\tAliases: []string{\"run-fns\"},\n\t\tShort: commands.RunFnsShort,\n\t\tLong: commands.RunFnsLong,\n\t\tExample: commands.RunFnsExamples,\n\t\tRunE: r.runE,\n\t\tArgs: cobra.ExactArgs(1),\n\t}\n\tfixDocs(name, c)\n\tc.Flags().BoolVar(&r.IncludeSubpackages, \"include-subpackages\", true,\n\t\t\"also print resources from subpackages.\")\n\tr.Command = c\n\tr.Command.Flags().BoolVar(\n\t\t&r.DryRun, \"dry-run\", false, \"print results to stdout\")\n\tr.Command.Flags().StringSliceVar(\n\t\t&r.FnPaths, \"fn-path\", []string{},\n\t\t\"directories containing functions without configuration\")\n\tr.Command.AddCommand(XArgsCommand())\n\tr.Command.AddCommand(WrapCommand())\n\treturn r\n}", "func newRunner(output string, err error) *MockRunner {\n\tm := &MockRunner{}\n\tm.On(\"Run\", mock.Anything).Return([]byte(output), err)\n\treturn m\n}", "func (*clusterPackagesExecutor) PreCheck(ctx context.Context) error {\n\treturn nil\n}", "func (s *BasePlSqlParserListener) EnterNew_partition_name(ctx *New_partition_nameContext) {}", "func (m *Measure) preBarrier(t time.Time) {\n\tm.preRunners = append(m.preRunners, Runner{PreTime: t})\n\tfmt.Printf(\"Now there is %v runners qualifying\\n\", len(m.preRunners))\n\tfmt.Printf(\"Now there is %v runners running\\n\", len(m.runners))\n\n}", "func (r *Runner) Name() string { return RunnerName }", "func (this *Tidy) NewPreTags(val string) (bool, error) {\n\tv := (*C.tmbchar)(C.CString(val))\n\tdefer C.free(unsafe.Pointer(v))\n\treturn this.optSetString(C.TidyPreTags, v)\n}", "func (client ModelClient) AddCustomPrebuiltIntentPreparer(ctx context.Context, appID uuid.UUID, versionID string, prebuiltDomainModelCreateObject PrebuiltDomainModelCreateObject) (*http.Request, error) {\n\turlParameters := map[string]interface{}{\n\t\t\"Endpoint\": client.Endpoint,\n\t}\n\n\tpathParameters := map[string]interface{}{\n\t\t\"appId\": autorest.Encode(\"path\", appID),\n\t\t\"versionId\": autorest.Encode(\"path\", versionID),\n\t}\n\n\tpreparer := autorest.CreatePreparer(\n\t\tautorest.AsContentType(\"application/json; charset=utf-8\"),\n\t\tautorest.AsPost(),\n\t\tautorest.WithCustomBaseURL(\"{Endpoint}/luis/api/v2.0\", urlParameters),\n\t\tautorest.WithPathParameters(\"/apps/{appId}/versions/{versionId}/customprebuiltintents\", pathParameters),\n\t\tautorest.WithJSON(prebuiltDomainModelCreateObject))\n\treturn preparer.Prepare((&http.Request{}).WithContext(ctx))\n}", "func NewNameLT(v string) predicate.User {\n\treturn predicate.User(sql.FieldLT(FieldNewName, v))\n}", "func (r *PodsIncomingReflector) PreAdd(obj interface{}) (interface{}, watch.EventType) {\n\tforeignPod := obj.(*corev1.Pod)\n\n\thomePod := r.sharedPreRoutine(foreignPod)\n\tif homePod == nil {\n\t\treturn nil, watch.Added\n\t}\n\n\treturn homePod, watch.Added\n}" ]
[ "0.574454", "0.5559259", "0.5491292", "0.54819775", "0.54751414", "0.54033977", "0.53813756", "0.5324207", "0.5233656", "0.5183823", "0.51202166", "0.511692", "0.50739557", "0.5055979", "0.50478184", "0.50427", "0.49869433", "0.49579746", "0.49525964", "0.4946813", "0.49373913", "0.49336827", "0.49235207", "0.48999068", "0.48933965", "0.48901942", "0.48623538", "0.48579386", "0.4843702", "0.48044685", "0.47489446", "0.4748392", "0.47396335", "0.47339883", "0.4727486", "0.47206095", "0.47160387", "0.47072002", "0.47016266", "0.4652885", "0.4635366", "0.46322677", "0.4632154", "0.4628737", "0.46272334", "0.46250686", "0.4622277", "0.46195516", "0.4614659", "0.45811537", "0.45796323", "0.45774665", "0.4570769", "0.4569171", "0.4566725", "0.45497006", "0.4542608", "0.4535446", "0.4523536", "0.45225245", "0.4517741", "0.45177177", "0.4516559", "0.45138404", "0.44844016", "0.44811296", "0.44795853", "0.44748157", "0.4470957", "0.44660124", "0.44580963", "0.44507033", "0.444974", "0.44480857", "0.44377986", "0.44274485", "0.44140425", "0.44096494", "0.44069102", "0.44012696", "0.43975478", "0.4393636", "0.4388487", "0.43817866", "0.43783182", "0.4372668", "0.43718755", "0.436917", "0.43678924", "0.43523157", "0.43365195", "0.4332182", "0.43317422", "0.4317757", "0.43156034", "0.4311935", "0.43105158", "0.43035093", "0.42990905", "0.42901635" ]
0.82757413
0
NewGroup return a Group with input name.
func NewGroup(name string) Group { return Group{ name: name, readyCh: make(chan struct{}), } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewGroup(owner, name string) Group {\n\tnow := time.Now()\n\treturn Group{\n\t\tOwner: owner,\n\t\tName: name,\n\t\tDescription: name,\n\t\tAccess: \"private\",\n\t\tBirthtime: now,\n\t\tMTime: now,\n\t}\n}", "func NewGroup(name string, members ...string) *Group {\n\treturn &Group{\n\t\tName: name,\n\t\tpassword: \"\",\n\t\tGID: -1,\n\t\tUserList: members,\n\t}\n}", "func NewGroup() *Group {\n\treturn &Group{}\n}", "func NewGroup() *Group {\n\treturn &Group{}\n}", "func NewGroup(name string, maxSize int) *Group {\n\treturn &Group{\n\t\tName: name,\n\t\tMembers: []Person{},\n\t\tMaxSize: maxSize,\n\t}\n}", "func NewGroup(name string, o Owner) *Group {\n\tng := new(Group)\n\tng.Own = o\n\tng.Name = name\n\n\tvar nid OwnerID\n\tnid.Type = 'g'\n\tnid.UserDefined = name2userdefined(name)\n\t// nid.Stamp = newstamp()\n\n\tng.ID = nid\n\n\treturn ng\n}", "func NewGroup(field string) Group {\n\treturn Group{\n\t\tField: field,\n\t}\n}", "func New(dir string) *Group {\n\tg := &Group{\n\t\tdir: dir,\n\t}\n\tg.Clear()\n\treturn g\n}", "func NewGroup(system SystemUtils) *Group {\n\treturn &Group{\n\t\tsystem: system,\n\t}\n}", "func NewGroup()(*Group) {\n m := &Group{\n DirectoryObject: *NewDirectoryObject(),\n }\n odataTypeValue := \"#microsoft.graph.group\";\n m.SetOdataType(&odataTypeValue);\n return m\n}", "func New(gid string) *Group {\n return &Group{\n Client: client.New().Init(),\n GroupID: gid,\n }\n}", "func newRunnerGroup(scope RunnerGroupScope, name string) RunnerGroup {\n\tif name == \"\" {\n\t\treturn RunnerGroup{\n\t\t\tScope: scope,\n\t\t\tKind: Default,\n\t\t\tName: \"\",\n\t\t}\n\t}\n\n\treturn RunnerGroup{\n\t\tScope: scope,\n\t\tKind: Custom,\n\t\tName: name,\n\t}\n}", "func (visual *Visual) NewGroup(parts []string, effect string) (*Group, error) {\n\tgroup, err := newGroup(parts, effect)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvisual.mux.Lock()\n\tvisual.groups = append(visual.groups, group)\n\tvisual.mux.Unlock()\n\n\treturn group, nil\n}", "func NewGroup(ctx context.Context) *Group {\n\tctx, cancel := context.WithCancel(ctx)\n\n\tg := &Group{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\t\tdone: make(chan struct{}),\n\t}\n\n\tgo g.wait()\n\n\treturn g\n}", "func (s *GroupsService) Create(\n\tctx context.Context,\n\tgroupName string,\n) error {\n\traw, err := json.Marshal(struct {\n\t\tGroupName string `json:\"group_name\"`\n\t}{\n\t\tgroupName,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq, err := http.NewRequest(\n\t\thttp.MethodPost,\n\t\ts.client.url+\"2.0/groups/create\",\n\t\tbytes.NewBuffer(raw),\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq = req.WithContext(ctx)\n\tres, err := s.client.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif res.StatusCode >= 300 || res.StatusCode <= 199 {\n\t\treturn fmt.Errorf(\n\t\t\t\"Failed to returns 2XX response: %d\", res.StatusCode)\n\t}\n\n\treturn nil\n}", "func NewGroup(name string, cacheBytes int64, getter Getter) *Group {\n\tif getter == nil {\n\t\tpanic(\"Nil Getter\")\n\t}\n\n\tmu.Lock()\n\tdefer mu.Unlock()\n\n\tg := &Group{\n\t\tname: name,\n\t\tmainCache: &SafeCache{maxBytes: cacheBytes},\n\t\tgetter: getter,\n\t}\n\tgroups[name] = g\n\treturn g\n}", "func newGroup(groupId string, broadcastChannelCap int64) *group {\n\n\tg := &group{\n\t\tId: groupId,\n\t\tclients: make(map[string]*socketClient),\n\t\tbroadcastChannel: make(chan interface{}, broadcastChannelCap),\n\t\tshutdownChannel: make(chan interface{}),\n\t\tdownChannel: make(chan interface{}, broadcastChannelCap),\n\t}\n\n\tAppLogger.Infof(\"[newGroup] group: %s created\", groupId)\n\treturn g\n}", "func NewGroup(gvr client.GVR) ResourceViewer {\n\tg := Group{ResourceViewer: NewBrowser(gvr)}\n\tg.AddBindKeysFn(g.bindKeys)\n\tg.SetContextFn(g.subjectCtx)\n\n\treturn &g\n}", "func New(s []string) Group {\n\treturn Group{str: s}\n}", "func NewGroup(lv Level, w io.Writer) Group {\n\treturn NewGroupWithHandle(lv, w, nil, nil)\n}", "func NewGroup(ctx context.Context, options ...GroupOption) *Group {\n\tctx, cancel := context.WithCancel(ctx)\n\tg := &Group{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\t\tpool: dummyPool{},\n\t\trecover: false,\n\t}\n\tfor _, opt := range options {\n\t\topt(g)\n\t}\n\treturn g\n}", "func NewGroup(m *algebra.Matrix) *Group {\n\tmat := m\n\tif m == nil || len(m.Get()) != 4 || len(m.Get()[0]) != 4 {\n\t\tmat = algebra.IdentityMatrix(4)\n\t}\n\temptyShapes := make([]Shape, 0, 0)\n\treturn &Group{transform: mat, parent: nil, shapes: emptyShapes, bounds: [2]*algebra.Vector{}}\n}", "func NewGrouping(arg string) *Grouping {\n\tsplit := strings.Split(arg, \",\")\n\tvar grouping *Grouping\n\tif len(split) > 0 {\n\t\tgrouping = &Grouping{\n\t\t\tName: split[0],\n\t\t}\n\t}\n\tif len(split) >= 2 {\n\t\tindex, _ := strconv.ParseInt(split[1], 0, 64)\n\t\tgrouping.Index = int(index)\n\t}\n\tif len(split) >= 3 {\n\t\tduration, _ := time.ParseDuration(split[2])\n\t\tgrouping.Max = duration\n\t}\n\treturn grouping\n}", "func (conn Connection) CreateGroup(name string) (resp *http.Response, err error) {\n\tresp, err = conn.Post(fmt.Sprintf(\"/groups/%s\", name), nil, nil)\n\treturn resp, err\n}", "func (s *GroupsService) Create(r *GroupRequest) (*Group, *Response, error) {\n\treq, err := s.client.NewRequest(\"POST\", \"groups\", r)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tgroup := &Group{}\n\tresp, err := s.client.Do(req, group)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn group, resp, nil\n}", "func WindowGroupNew() (*WindowGroup, error) {\n\tc := C.gtk_window_group_new()\n\tif c == nil {\n\t\treturn nil, nilPtrErr\n\t}\n\treturn wrapWindowGroup(glib.Take(unsafe.Pointer(c))), nil\n}", "func (r *RouteGroup) NewGroup(path string) *RouteGroup {\n\treturn NewRouteGroup(r.r, r.subPath(path))\n}", "func newGroup() *Group {\n\tg := new(Group)\n\tg.handlers = make([]HandlerFunc, 0)\n\treturn g\n}", "func NewGroup() UserGroup {\n\tgroup := make(UserGroup, 0)\n\treturn group\n}", "func NewGroup(client *Client) *GroupService {\n\treturn &GroupService{\n\t\tclient: client,\n\t}\n}", "func (r *ProjectsGroupsService) Create(name string, group *Group) *ProjectsGroupsCreateCall {\n\tc := &ProjectsGroupsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.name = name\n\tc.group = group\n\treturn c\n}", "func New(directory string) (*Group, []error) {\n\tthis := new(Group)\n\n\tthis.t = template.New(\"\")\n\tthis.t.Parse(\"\")\n\n\terrs := this.loadFolder(directory)\n\n\treturn this, errs\n}", "func NewGroup(bootles []Bottle, water uint32) Group {\n\treturn Group{\n\t\tWater: water,\n\t\tBottles: bootles,\n\t}\n}", "func (og *OrdererGroup) NewGroup(name string) (ValueProposer, error) {\n\treturn NewOrganizationGroup(name, og.mspConfig), nil\n}", "func NewGroup(client *gosip.SPClient, endpoint string, config *RequestConfig) *Group {\n\treturn &Group{\n\t\tclient: client,\n\t\tendpoint: endpoint,\n\t\tconfig: config,\n\t\tmodifiers: NewODataMods(),\n\t}\n}", "func CreateGroup(g *Group) (err error) {\n\tif err = IsUsableGroupname(g.Name); err != nil {\n\t\treturn err\n\t}\n\n\tisExist, err := IsGroupExist(0, g.Name)\n\tif err != nil {\n\t\treturn err\n\t} else if isExist {\n\t\treturn ErrGroupAlreadyExist{g.Name}\n\t\t//return nil\n\t}\n\n\tsess := x.NewSession()\n\tdefer sessionRelease(sess)\n\tif err = sess.Begin(); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err = sess.Insert(g); err != nil {\n\t\treturn err\n\t}\n\n\treturn sess.Commit()\n}", "func CreateDefaultGroup(db *gorp.DbMap, groupName string) error {\n\tquery := `SELECT id FROM \"group\" where name = $1`\n\tvar id int64\n\tif err := db.QueryRow(query, groupName).Scan(&id); err == sql.ErrNoRows {\n\t\tlog.Debug(\"CreateDefaultGroup> create %s group in DB\", groupName)\n\t\tquery = `INSERT INTO \"group\" (name) VALUES ($1)`\n\t\tif _, err := db.Exec(query, groupName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (c *EtcdGroupService) GroupCreate(ctx context.Context, groupName string) error {\n\treturn c.createGroup(ctx, groupName, 0)\n}", "func NewGroupBy(name string, ex goexpr.Expr) GroupBy {\n\treturn GroupBy{\n\t\tExpr: ex,\n\t\tName: name,\n\t}\n}", "func (gr *GroupResource) Create(owner string, name string) (g *GroupDetails, err error) {\n\townerOrCurrentUser(gr, &owner)\n\n\tpath := fmt.Sprintf(\"/groups/%s/\", owner)\n\tvalues := url.Values{}\n\tvalues.Set(\"name\", name)\n\terr = gr.client.do(\"POST\", path, nil, values, &g)\n\n\treturn\n}", "func (db *MySQLDB) CreateGroup(ctx context.Context, groupName, groupDomain, description string) (*Group, error) {\n\tfLog := mysqlLog.WithField(\"func\", \"CreateGroup\").WithField(\"RequestID\", ctx.Value(constants.RequestID))\n\tr := &Group{\n\t\tRecID: helper.MakeRandomString(10, true, true, true, false),\n\t\tGroupName: groupName,\n\t\tGroupDomain: groupDomain,\n\t\tDescription: description,\n\t}\n\tq := \"INSERT INTO HANSIP_GROUP(REC_ID, GROUP_NAME, GROUP_DOMAIN, DESCRIPTION) VALUES (?,?,?,?)\"\n\t_, err := db.instance.ExecContext(ctx, q, r.RecID, groupName, groupDomain, description)\n\tif err != nil {\n\t\tfLog.Errorf(\"db.instance.ExecContext got %s. SQL = %s\", err.Error(), q)\n\t\treturn nil, &ErrDBExecuteError{\n\t\t\tWrapped: err,\n\t\t\tMessage: \"Error CreateGroup\",\n\t\t\tSQL: q,\n\t\t}\n\t}\n\treturn r, nil\n}", "func (db *Database) AddGroup(name string) (int, error) {\n\trow := db.db.QueryRow(`\n\t\tINSERT INTO melodious.groups (name)\tVALUES ($1) RETURNING id;\n\t`, name)\n\tvar id int\n\terr := row.Scan(&id)\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\treturn id, nil\n}", "func NewGroup(list []*Identity, threshold int, genesis int64, period, catchupPeriod time.Duration,\n\tsch *crypto.Scheme, beaconID string) *Group {\n\treturn &Group{\n\t\tNodes: copyAndSort(list),\n\t\tThreshold: threshold,\n\t\tGenesisTime: genesis,\n\t\tPeriod: period,\n\t\tCatchupPeriod: catchupPeriod,\n\t\tScheme: sch,\n\t\tID: beaconID,\n\t}\n}", "func New(app, account, region, stack, cluster string) InstanceGroup {\n\treturn group{\n\t\tapp: app,\n\t\taccount: account,\n\t\tregion: region,\n\t\tstack: stack,\n\t\tcluster: cluster,\n\t}\n}", "func (app *App) GroupCreate(ctx context.Context, groupName string) error {\n\treturn app.groups.GroupCreate(ctx, groupName)\n}", "func (_IFactorySpace *IFactorySpaceTransactor) CreateGroup(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _IFactorySpace.contract.Transact(opts, \"createGroup\")\n}", "func GroupName() string {\n\treturn groupName\n}", "func (s *AutograderService) CreateGroup(ctx context.Context, in *pb.Group) (*pb.Group, error) {\n\tusr, err := s.getCurrentUser(ctx)\n\tif err != nil {\n\t\ts.logger.Errorf(\"CreateGroup failed: authentication error: %w\", err)\n\t\treturn nil, ErrInvalidUserInfo\n\t}\n\tif !s.isEnrolled(usr.GetID(), in.GetCourseID()) {\n\t\ts.logger.Errorf(\"CreateGroup failed: user %s not enrolled in course %d\", usr.GetLogin(), in.GetCourseID())\n\t\treturn nil, status.Errorf(codes.PermissionDenied, \"user not enrolled in given course\")\n\t}\n\tif !(in.Contains(usr) || s.isTeacher(usr.GetID(), in.GetCourseID())) {\n\t\ts.logger.Error(\"CreateGroup failed: user is not group member or teacher\")\n\t\treturn nil, status.Errorf(codes.PermissionDenied, \"only group member or teacher can create group\")\n\t}\n\tgroup, err := s.createGroup(in)\n\tif err != nil {\n\t\ts.logger.Errorf(\"CreateGroup failed: %w\", err)\n\t\treturn nil, status.Error(codes.InvalidArgument, \"failed to create group\")\n\t}\n\treturn group, nil\n}", "func NewGroup(ctx context.Context) *errGroup {\n\tnewCtx, cancel := context.WithCancel(ctx)\n\treturn &errGroup{\n\t\tctx: newCtx,\n\t\tcancel: cancel,\n\t}\n}", "func (c *Client) CreateGroup() (string, error) {\n\tvar groupId string\n\tif !c.authenticated {\n\t\treturn groupId, errors.New(\"Not authenticated. Call Authenticate first\")\n\t}\n\n\tmsg := common.NewMessage(c.userId, \"server\",\n\t\t\"control\", \"remove_contact\", time.Time{},\n\t\tcommon.TEXT, \"\")\n\n\tencoded, err := msg.Json()\n\tif err != nil {\n\t\tlog.Println(\"Failed to encode create group message\", err)\n\t\treturn groupId, err\n\t}\n\n\terr = c.transport.SendText(string(encoded))\n\tif err != nil {\n\t\tlog.Println(\"Failed to send create group message\", err)\n\t\treturn groupId, err\n\t}\n\n\tresp := <-c.Out\n\tif resp.Status() == common.STATUS_ERROR {\n\t\terrMsg := resp.Error()\n\t\tlog.Println(\"Create group response error\", errMsg)\n\t\treturn groupId, errors.New(errMsg)\n\t}\n\n\tgroupId = resp.GetJsonData(\"group_id\").(string)\n\treturn groupId, nil\n}", "func GroupName(name string) OptFunc {\n\treturn func(p *ByName) error {\n\t\tname = strings.TrimSpace(name)\n\t\terr := GroupNameCheck(name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tp.groupName = name\n\t\treturn nil\n\t}\n}", "func NewCalendarGroup()(*CalendarGroup) {\n m := &CalendarGroup{\n Entity: *NewEntity(),\n }\n return m\n}", "func (g *Group) CreateGroup(name string) (*Group, error) {\n\treturn createGroup(g.id, name, C.H5P_DEFAULT, C.H5P_DEFAULT, C.H5P_DEFAULT)\n}", "func newProviderGroup(k key) *providerGroup {\n\tifaceKey := key{\n\t\tres: reflect.SliceOf(k.res),\n\t\ttyp: ptGroup,\n\t}\n\n\treturn &providerGroup{\n\t\tresult: ifaceKey,\n\t\tpl: parameterList{},\n\t}\n}", "func (db *DB) Group(name string) (tx *DB) {\n\ttx = db.getInstance()\n\n\tfields := strings.FieldsFunc(name, utils.IsValidDBNameChar)\n\ttx.Statement.AddClause(clause.GroupBy{\n\t\tColumns: []clause.Column{{Name: name, Raw: len(fields) != 1}},\n\t})\n\treturn\n}", "func (r *marathonClient) Group(name string) (*Group, error) {\n\tgroup := new(Group)\n\tif err := r.apiGet(fmt.Sprintf(\"%s/%s\", marathonAPIGroups, trimRootPath(name)), nil, group); err != nil {\n\t\treturn nil, err\n\t}\n\treturn group, nil\n}", "func NewGroup(dataframe *DataFrame, columns ...string) *Groups {\n\t// ret := &Groups{Columns: []string{}, Grouper: columns, Group: make(map[types.C][]indices.Index), Df: dataframe}\n\tret := &Groups{Keys: []Keys{}, Columns: []string{}, Grouper: columns, Group: make(map[types.C][]indices.Index), Df: dataframe}\n\n\treturn ret\n}", "func New(ctx context.Context, concurrency int) (*Group, context.Context) {\n\tif concurrency < 1 {\n\t\tconcurrency = 1\n\t}\n\n\tparent, ctx := errgroup.WithContext(ctx)\n\treturn &Group{\n\t\tlimiter: make(chan struct{}, concurrency),\n\t\tparent: parent,\n\t\tctx: ctx,\n\t}, ctx\n}", "func (_BaseGroupFactory *BaseGroupFactoryTransactor) CreateGroup(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BaseGroupFactory.contract.Transact(opts, \"createGroup\")\n}", "func (p ByName) GroupName() string { return p.groupName }", "func (mg *Groups) Create(group *Group) error {\n\n\tif mg.group != nil && len(group.ID) > 0 {\n\n\t\tpath := fmt.Sprintf(\"%s%s\", marathon.APIGroups, utilities.DelInitialSlash(group.ID))\n\n\t\tif _, err := mg.client.Session.BodyAsJSON(group).Post(path, mg.deploy, mg.fail); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmg.group = group\n\t\treturn nil\n\t}\n\treturn errors.New(\"group cannot be null nor empty\")\n}", "func NewGroup(thresholds ...*Threshold) *Group {\n\treturn &Group{Thresholds: thresholds}\n}", "func (a *API) CreateGroup(name, language string, agentPriorities map[string]GroupPriority) (int32, error) {\n\tvar resp createGroupResponse\n\terr := a.Call(\"create_group\", &createGroupRequest{\n\t\tName: name,\n\t\tLanguageCode: language,\n\t\tAgentPriorities: agentPriorities,\n\t}, &resp)\n\n\treturn resp.ID, err\n}", "func (g *GroupsService) CreateGroup(group Group) (*Group, *Response, error) {\n\tif err := g.client.validate.Struct(group); err != nil {\n\t\treturn nil, nil, err\n\t}\n\treq, err := g.client.newRequest(IDM, \"POST\", \"authorize/identity/Group\", &group, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\treq.Header.Set(\"api-version\", groupAPIVersion)\n\n\tvar createdGroup Group\n\n\tresp, err := g.client.do(req, &createdGroup)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\treturn &createdGroup, resp, err\n\n}", "func (u Util) CreateGroup(g types.Group) error {\n\targs := []string{\"--root\", u.DestDir}\n\n\tif g.Gid != nil {\n\t\targs = append(args, \"--gid\",\n\t\t\tstrconv.FormatUint(uint64(*g.Gid), 10))\n\t}\n\n\tif g.PasswordHash != \"\" {\n\t\targs = append(args, \"--password\", g.PasswordHash)\n\t} else {\n\t\targs = append(args, \"--password\", \"*\")\n\t}\n\n\tif g.System {\n\t\targs = append(args, \"--system\")\n\t}\n\n\targs = append(args, g.Name)\n\n\treturn u.LogCmd(exec.Command(\"groupadd\", args...),\n\t\t\"adding group %q\", g.Name)\n}", "func (s *Server) makeGroup(cmd string, phone string) (Group, error) {\n\n\tstartIndex := strings.Index(cmd, \"<\")\n\tendIndex := strings.Index(cmd, \">\") + 1\n\n\tscannerEngine := &scanner.GScanner{\n\t\tInput: cmd[startIndex:endIndex],\n\t\tTokens: []string{\"<\", \">\", \":\"},\n\t\tIncludeTokensInOutput: false,\n\t}\n\n\toutput := scannerEngine.Scan()\n\n\tif len(output) == 3 {\n\t\tcommand := output[0]\n\t\tgrpName := strings.TrimSpace(output[1])\n\t\talias := strings.TrimSpace(output[2])\n\n\t\tif command != GroupMakeCommand[1:len(GroupMakeCommand)] {\n\t\t\treturn Group{}, errors.New(\"Bad command for making group. Please use the syntax: \" + GroupMakeCommand)\n\t\t}\n\t\tif len(alias) > GroupAliasMaxLen {\n\t\t\treturn Group{}, errors.New(\"Error. Your group alias cannot be more than \" + strconv.Itoa(GroupAliasMaxLen) + \" characters\")\n\t\t}\n\t\tif strings.Contains(alias, \" \") || strings.Contains(alias, \"\\n\") || strings.Contains(alias, \"\\t\") {\n\t\t\treturn Group{}, errors.New(\"Error: Your group alias must have no white spaces. \")\n\t\t}\n\n\t\tgrp := &Group{\n\t\t\tID: utils.GenUlid(),\n\t\t\tName: grpName,\n\t\t\tAlias: alias,\n\t\t\tAdminPhone: phone,\n\t\t\tMembers: make([]string, 0),\n\t\t}\n\n\t\t//Ensure that none of the user's groups has either of the alias or name given here\n\t\tif s.userHasGroupByName(phone, grp.Name) {\n\t\t\treturn Group{}, errors.New(\"Error: The Group, \" + grp.Name + \" is already amongst your groups!\")\n\t\t}\n\n\t\treturn *grp, nil\n\t}\n\n\terr := errors.New(\"The syntax of your command i.e `\" + cmd + \"` is wrong!\\n Please use `<grpmk:grpName>` to create a new group\")\n\n\treturn Group{}, err\n}", "func CreateGroup(params types.ContextParams, clientSet apimachinery.ClientSetInterface, groupItems []metadata.Group) []Group {\n\tresults := make([]Group, 0)\n\tfor _, grp := range groupItems {\n\n\t\tresults = append(results, &group{\n\t\t\tgrp: grp,\n\t\t\tparams: params,\n\t\t\tclientSet: clientSet,\n\t\t})\n\t}\n\n\treturn results\n}", "func Group(name string) (result *lib.FileGroup, err error) {\n\tresult = mainAssetDirectory.GetGroup(name)\n\tif result == nil {\n\t\tresult, err = mainAssetDirectory.NewFileGroup(name)\n\t}\n\treturn\n}", "func (c *Client) CreateGroup(ctx context.Context, group Group) (Group, error) {\n\tresult := Group{}\n\tbody, err := json.Marshal(group)\n\tif err != nil {\n\t\treturn Group{}, err\n\t}\n\terr = c.sendRequest(\n\t\tctx,\n\t\t\"POST\",\n\t\tfmt.Sprintf(\"%s%s\", c.getRootURL(), groupSlug),\n\t\tbytes.NewReader(body),\n\t\t&result)\n\tif err != nil {\n\t\treturn Group{}, err\n\t}\n\n\treturn result, nil\n}", "func createEmptyTestGroup(t *testing.T, session *session.Session, name string) error {\n\tsvc := iam.New(session)\n\n\tgroupInput := &iam.CreateGroupInput{\n\t\tGroupName: awsgo.String(name),\n\t}\n\n\t_, err := svc.CreateGroup(groupInput)\n\trequire.NoError(t, err)\n\treturn nil\n}", "func createGroup() (group resources.Group, err error) {\n\tgroupsClient := resources.NewGroupsClient(config.SubscriptionID)\n\tgroupsClient.Authorizer = autorest.NewBearerAuthorizer(token)\n\n\treturn groupsClient.CreateOrUpdate(\n\t\tctx,\n\t\tresourceGroupName,\n\t\tresources.Group{\n\t\t\tLocation: to.StringPtr(resourceGroupLocation)})\n}", "func (*CreateInstanceGroup) name() string {\n\treturn \"createInstanceGroup\"\n}", "func (_BaseContentSpace *BaseContentSpaceTransactor) CreateGroup(opts *bind.TransactOpts) (*types.Transaction, error) {\n\treturn _BaseContentSpace.contract.Transact(opts, \"createGroup\")\n}", "func (g *Group) NewSubgroup() *Group {\n\tid := g.db.nextGroupID()\n\tsub := &Group{ID: id, db: g.db}\n\tg.groups = append(g.groups, sub)\n\tg.db.groups[id] = sub\n\treturn sub\n}", "func CreateGroup(c *store.Context, group *Group) error {\n\n\terr := group.BeforeCreate()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar existingGroups []*Group\n\terr = c.Store.FindAll(c, bson.M{\"name\": group.Name}, &existingGroups)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(existingGroups) > 0 {\n\t\treturn helpers.NewError(http.StatusConflict, \"group_already_exists\", \"Group already exists\", err)\n\t}\n\n\terr = c.Store.Create(c, \"groups\", group)\n\tif err != nil {\n\t\treturn helpers.NewError(http.StatusInternalServerError, \"group_creation_failed\", \"Failed to insert the group in the database\", err)\n\t}\n\n\treturn nil\n}", "func (d *Dao) GroupByName(name string) (res *model.CardGroup, err error) {\n\tres = new(model.CardGroup)\n\tq := d.DB.Table(\"card_group\").Where(\"name=?\", name).First(res)\n\tif q.Error != nil {\n\t\tif q.RecordNotFound() {\n\t\t\terr = nil\n\t\t\tres = nil\n\t\t\treturn\n\t\t}\n\t\terr = errors.Wrapf(err, \"card_group by name\")\n\t}\n\treturn\n}", "func New(controllerManager *generic.ControllerManager, informers informers.Interface,\n\tclient clientset.Interface) Interface {\n\treturn &group{\n\t\tcontrollerManager: controllerManager,\n\t\tinformers: informers,\n\t\tclient: client,\n\t}\n}", "func (sqlStore *SQLStore) CreateGroup(group *model.Group) error {\n\tgroup.ID = model.NewID()\n\tgroup.CreateAt = GetMillis()\n\n\t_, err := sqlStore.execBuilder(sqlStore.db, sq.\n\t\tInsert(`\"Group\"`).\n\t\tSetMap(map[string]interface{}{\n\t\t\t\"ID\": group.ID,\n\t\t\t\"Name\": group.Name,\n\t\t\t\"Description\": group.Description,\n\t\t\t\"Version\": group.Version,\n\t\t\t\"CreateAt\": group.CreateAt,\n\t\t\t\"DeleteAt\": 0,\n\t\t}),\n\t)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to create group\")\n\t}\n\n\treturn nil\n}", "func NewLogGroup(ctx *pulumi.Context,\n\tname string, args *LogGroupArgs, opts ...pulumi.ResourceOpt) (*LogGroup, error) {\n\tinputs := make(map[string]interface{})\n\tif args == nil {\n\t\tinputs[\"kmsKeyId\"] = nil\n\t\tinputs[\"name\"] = nil\n\t\tinputs[\"namePrefix\"] = nil\n\t\tinputs[\"retentionInDays\"] = nil\n\t\tinputs[\"tags\"] = nil\n\t} else {\n\t\tinputs[\"kmsKeyId\"] = args.KmsKeyId\n\t\tinputs[\"name\"] = args.Name\n\t\tinputs[\"namePrefix\"] = args.NamePrefix\n\t\tinputs[\"retentionInDays\"] = args.RetentionInDays\n\t\tinputs[\"tags\"] = args.Tags\n\t}\n\tinputs[\"arn\"] = nil\n\ts, err := ctx.RegisterResource(\"aws:cloudwatch/logGroup:LogGroup\", name, true, inputs, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &LogGroup{s: s}, nil\n}", "func (r *Group) Name(name string) *Group {\n\tr.ID = validateID(name)\n\treturn r\n}", "func New(ctx context.Context) *Group {\n\t// Monitor goroutine context and cancelation.\n\tmctx, cancel := context.WithCancel(ctx)\n\n\tg := &Group{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\n\t\taddC: make(chan struct{}),\n\t\tlenC: make(chan int),\n\t}\n\n\tg.wg.Add(1)\n\tgo func() {\n\t\tdefer g.wg.Done()\n\t\tg.monitor(mctx)\n\t}()\n\n\treturn g\n}", "func (p *ServerGatedServiceClient) CreateGroup(project_id int32, key string, group_id int64, group_name string) (r int64, err error) {\n\tif err = p.sendCreateGroup(project_id, key, group_id, group_name); err != nil {\n\t\treturn\n\t}\n\treturn p.recvCreateGroup()\n}", "func (m *TeamItemRequestBuilder) Group()(*i8a1cdbeac728d5d9d3409d0d7085c53384ad37435e0292d966ed94bbc4155a05.GroupRequestBuilder) {\n return i8a1cdbeac728d5d9d3409d0d7085c53384ad37435e0292d966ed94bbc4155a05.NewGroupRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "func (l *GroupLookup) newKeyGroup(entries []groupKeyListElement) *groupKeyList {\n\tid := l.nextID\n\tl.nextID++\n\treturn &groupKeyList{\n\t\tid: id,\n\t\telements: entries,\n\t}\n}", "func (a *Client) CreateGroup(params *CreateGroupParams) (*CreateGroupOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewCreateGroupParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"create_group\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/groups\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &CreateGroupReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*CreateGroupOK), nil\n\n}", "func NewPatchGroup(ctx *pulumi.Context,\n\tname string, args *PatchGroupArgs, opts ...pulumi.ResourceOption) (*PatchGroup, error) {\n\tif args == nil || args.BaselineId == nil {\n\t\treturn nil, errors.New(\"missing required argument 'BaselineId'\")\n\t}\n\tif args == nil || args.PatchGroup == nil {\n\t\treturn nil, errors.New(\"missing required argument 'PatchGroup'\")\n\t}\n\tif args == nil {\n\t\targs = &PatchGroupArgs{}\n\t}\n\tvar resource PatchGroup\n\terr := ctx.RegisterResource(\"aws:ssm/patchGroup:PatchGroup\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (t *OpenconfigSystem_System_Aaa_ServerGroups) NewServerGroup(Name string) (*OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup, error){\n\n\t// Initialise the list within the receiver struct if it has not already been\n\t// created.\n\tif t.ServerGroup == nil {\n\t\tt.ServerGroup = make(map[string]*OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup)\n\t}\n\n\tkey := Name\n\n\t// Ensure that this key has not already been used in the\n\t// list. Keyed YANG lists do not allow duplicate keys to\n\t// be created.\n\tif _, ok := t.ServerGroup[key]; ok {\n\t\treturn nil, fmt.Errorf(\"duplicate key %v for list ServerGroup\", key)\n\t}\n\n\tt.ServerGroup[key] = &OpenconfigSystem_System_Aaa_ServerGroups_ServerGroup{\n\t\tName: &Name,\n\t}\n\n\treturn t.ServerGroup[key], nil\n}", "func NewResourceGroup(key string) ResourceGroup {\n\tscope := Scope{\n\t\tKey: key,\n\t\tScopeObjects: []ScopeObject{\n\t\t\t{\n\t\t\t\tKey: \"*\",\n\t\t\t},\n\t\t},\n\t}\n\tresourceGroup := ResourceGroup{\n\t\tID: \"\",\n\t\tName: key,\n\t\tMeta: map[string]string{\n\t\t\t\"editable\": \"false\",\n\t\t},\n\t\tScope: scope,\n\t}\n\treturn resourceGroup\n}", "func newRouteGroup(prefix string, router *Router, handlers []Handler) *RouteGroup {\n\treturn &RouteGroup{\n\t\tprefix: prefix,\n\t\trouter: router,\n\t\thandlers: handlers,\n\t}\n}", "func NewProviderGroup(name string, providers ...Provider) Provider {\n\tgroup := providerGroup{\n\t\tname: name,\n\t}\n\tfor _, provider := range providers {\n\t\tgroup.providers = append([]Provider{provider}, group.providers...)\n\t}\n\treturn group\n}", "func FindGroupByName(name string) Group {\n\tgroup := Group{}\n\tdb.Where(\"name = ?\", name).Take(&group)\n\treturn group\n}", "func Group(queryName, group string) *QueryGVR {\n\treturn &QueryGVR{\n\t\tname: queryName,\n\t\tgroup: group,\n\t}\n}", "func AddGroup(name string, members ...string) (gid int, err error) {\n\ts := NewGShadow(name, members...)\n\tif err = s.Add(nil); err != nil {\n\t\treturn\n\t}\n\n\treturn NewGroup(name, members...).Add()\n}", "func NewGroupLookup() *GroupLookup {\n\treturn &GroupLookup{\n\t\tlastIndex: -1,\n\t\tnextID: 1,\n\t}\n}", "func NewProtectGroup()(*ProtectGroup) {\n m := &ProtectGroup{\n LabelActionBase: *NewLabelActionBase(),\n }\n odataTypeValue := \"#microsoft.graph.protectGroup\"\n m.SetOdataType(&odataTypeValue)\n return m\n}", "func createGroup(logGroupName string) error {\n\n\tlog.Println(\"Creating a LogGroup\", logGroupName)\n\tparams := &cloudwatchlogs.CreateLogGroupInput{\n\t\tLogGroupName: aws.String(logGroupName),\n\t}\n\t_, err := cloudWatchSvc.CreateLogGroup(params)\n\tif err != nil {\n\t\tif aerr, ok := err.(awserr.Error); ok {\n\t\t\tswitch aerr.Code() {\n\t\t\tcase cloudwatchlogs.ErrCodeResourceAlreadyExistsException:\n\t\t\t\tlog.Printf(\"LogGroup already exists %s\", logGroupName)\n\t\t\t\treturn nil\n\t\t\tdefault:\n\t\t\t\treturn aerr\n\t\t\t}\n\t\t}\n\t\treturn err\n\t}\n\treturn nil\n}", "func NewGroups(filename string, bad BadLineHandler) (*HTGroup, error) {\n\thtGroup := HTGroup{\n\t\tfilePath: filename,\n\t}\n\treturn &htGroup, htGroup.ReloadGroups(bad)\n}", "func NewProtectionGroup(ctx *pulumi.Context,\n\tname string, args *ProtectionGroupArgs, opts ...pulumi.ResourceOption) (*ProtectionGroup, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.Aggregation == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Aggregation'\")\n\t}\n\tif args.Pattern == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Pattern'\")\n\t}\n\tif args.ProtectionGroupId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ProtectionGroupId'\")\n\t}\n\tvar resource ProtectionGroup\n\terr := ctx.RegisterResource(\"aws:shield/protectionGroup:ProtectionGroup\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewSystemGroup(name string, members ...string) *Group {\n\treturn &Group{\n\t\tName: name,\n\t\tpassword: \"\",\n\t\tGID: -1,\n\t\tUserList: members,\n\n\t\taddSystemGroup: true,\n\t}\n}", "func (c *Client) CreateGroup(ctx context.Context, group *Group) (*Group, *http.Response, error) {\n\t// POST /Groups\n\tresp, err := c.CreateGroupResp(ctx, group)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\tdefer resp.Body.Close()\n\tg := &Group{}\n\treturn g, resp, c.parseResponse(resp, g)\n}" ]
[ "0.7774005", "0.7614487", "0.7580504", "0.7580504", "0.75550216", "0.7460315", "0.7294258", "0.72896034", "0.7261106", "0.7210766", "0.7202386", "0.71659905", "0.7141491", "0.70930296", "0.6947957", "0.6907739", "0.6901332", "0.6881721", "0.6866693", "0.68410695", "0.68170804", "0.6800524", "0.6765825", "0.6739809", "0.6738948", "0.67354685", "0.67326653", "0.6717328", "0.6688455", "0.6649262", "0.6630139", "0.6616099", "0.6615016", "0.65964264", "0.653488", "0.6528466", "0.6514312", "0.64874464", "0.64863515", "0.6480565", "0.645159", "0.6447302", "0.64383286", "0.6387504", "0.637926", "0.6352435", "0.6340105", "0.6326478", "0.62932307", "0.62811565", "0.62703454", "0.62643045", "0.626236", "0.6210813", "0.6210758", "0.62034833", "0.6199856", "0.6189308", "0.61845195", "0.61826825", "0.61740863", "0.61732364", "0.6172921", "0.61663276", "0.61552155", "0.6138159", "0.6134338", "0.6126589", "0.6118299", "0.61174595", "0.611167", "0.6110214", "0.6098611", "0.6086651", "0.6086043", "0.608314", "0.60651374", "0.6061095", "0.6058347", "0.6048096", "0.60476846", "0.6045707", "0.6045137", "0.6040846", "0.6027784", "0.6026179", "0.5999546", "0.59958506", "0.5991744", "0.59864897", "0.59864706", "0.59681565", "0.59650624", "0.59577864", "0.59518945", "0.5941032", "0.5926748", "0.59123766", "0.5909949", "0.59042823" ]
0.79604924
0
Name shows the name of the group.
func (g Group) Name() string { return g.name }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (g *Group) Name() string {\n\treturn g.name\n}", "func (g *Group) Name() string {\n\treturn g.name\n}", "func (o ServerGroupOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ServerGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (o InstanceGroupOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *InstanceGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (o PlacementGroupOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *PlacementGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (r *LogGroup) Name() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"name\"])\n}", "func (o ReportGroupOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ReportGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (o GetGroupResultOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GetGroupResult) string { return v.Name }).(pulumi.StringOutput)\n}", "func (o ThingGroupOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ThingGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (o ResourceGroupOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ResourceGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func GroupName() string {\n\treturn groupName\n}", "func (r *Group) Name(name string) *Group {\n\tr.ID = validateID(name)\n\treturn r\n}", "func (o GroupContainerOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GroupContainer) string { return v.Name }).(pulumi.StringOutput)\n}", "func (o TargetGroupOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v TargetGroup) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (o ElastigroupSignalOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ElastigroupSignal) string { return v.Name }).(pulumi.StringOutput)\n}", "func (o DataSetGeoSpatialColumnGroupOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v DataSetGeoSpatialColumnGroup) string { return v.Name }).(pulumi.StringOutput)\n}", "func (s *SoundGroup) Name() (string, error) {\n\tnlen := C.int(len(s.name) + 1)\n\tvar cname *C.char = C.CString(`\\0`)\n\tdefer C.free(unsafe.Pointer(cname))\n\tres := C.FMOD_SoundGroup_GetName(s.cptr, cname, nlen)\n\tif C.GoString(cname) != s.name {\n\t\treturn s.name, errors.New(\"Wrong names\")\n\t}\n\treturn C.GoString(cname), errs[res]\n}", "func (o BudgetResourceGroupOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *BudgetResourceGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (g *SettingGroup) Name() string {\n\treturn g.NameValue\n}", "func (p ByName) GroupName() string { return p.groupName }", "func (pg *PropertyGroup) Name() string {\n\treturn pg.name\n}", "func (o GroupInitContainerOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GroupInitContainer) string { return v.Name }).(pulumi.StringOutput)\n}", "func (o DomainGroupOutput) GroupName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *DomainGroup) pulumi.StringOutput { return v.GroupName }).(pulumi.StringOutput)\n}", "func (o GroupPolicyOutput) GroupName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *GroupPolicy) pulumi.StringOutput { return v.GroupName }).(pulumi.StringOutput)\n}", "func (o RegionNetworkEndpointGroupOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *RegionNetworkEndpointGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (gb *GroupBy) DisplayName() string {\n\tif gb.Name == \"\" && gb.Key != \"\" {\n\t\treturn gb.Key\n\t}\n\n\treturn gb.Name\n}", "func (o TargetGroupPtrOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *TargetGroup) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Name\n\t}).(pulumi.StringPtrOutput)\n}", "func (o PowerBIOutputDataSourceResponseOutput) GroupName() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v PowerBIOutputDataSourceResponse) *string { return v.GroupName }).(pulumi.StringPtrOutput)\n}", "func (g *Group) String() string {\n\treturn fmt.Sprintf(\"%s:%d\", g.name, len(g.files))\n}", "func (o ParameterGroupParameterOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ParameterGroupParameter) string { return v.Name }).(pulumi.StringOutput)\n}", "func (group *Meetinggroup) String() string {\n\treturn group.Name\n}", "func (*CreateInstanceGroup) name() string {\n\treturn \"createInstanceGroup\"\n}", "func (p StorageProvider) GroupName() string {\n\treturn servicecatalog.GroupName\n}", "func (o OptionGroupOptionOptionSettingOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v OptionGroupOptionOptionSetting) string { return v.Name }).(pulumi.StringOutput)\n}", "func (g *GitLab) Name() string {\n\treturn \"gitlab\"\n}", "func (o PowerBIOutputDataSourceOutput) GroupName() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v PowerBIOutputDataSource) *string { return v.GroupName }).(pulumi.StringPtrOutput)\n}", "func (o LookupRegionNetworkEndpointGroupResultOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupRegionNetworkEndpointGroupResult) string { return v.Name }).(pulumi.StringOutput)\n}", "func (o LookupTransitionRouteGroupResultOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v LookupTransitionRouteGroupResult) string { return v.Name }).(pulumi.StringOutput)\n}", "func (k *Kind) Name() string {\n\treturn \"team\"\n}", "func (o GroupContainerVolumeOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GroupContainerVolume) string { return v.Name }).(pulumi.StringOutput)\n}", "func (o DataSetGeoSpatialColumnGroupPtrOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *DataSetGeoSpatialColumnGroup) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.Name\n\t}).(pulumi.StringPtrOutput)\n}", "func (group *ContainerGroup_Spec_ARM) GetName() string {\n\treturn group.Name\n}", "func (o InstanceGroupNamedPortOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *InstanceGroupNamedPort) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (c *RestoreItemActionGRPCClient) Name() string {\n\treturn \"\"\n}", "func (r *Roster) Name() string { return ModuleName }", "func (gr *Group) String() string {\n\tvar builder strings.Builder\n\tbuilder.WriteString(\"Group(\")\n\tbuilder.WriteString(fmt.Sprintf(\"id=%v\", gr.ID))\n\tbuilder.WriteString(\", name=\")\n\tbuilder.WriteString(gr.Name)\n\tbuilder.WriteString(\", nickname=\")\n\tbuilder.WriteString(gr.Nickname)\n\tbuilder.WriteString(\", count=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", gr.Count))\n\tbuilder.WriteString(\", code=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", gr.Code))\n\tbuilder.WriteString(\", index=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", gr.Index))\n\tbuilder.WriteString(\", min=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", gr.Min))\n\tbuilder.WriteString(\", max=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", gr.Max))\n\tbuilder.WriteString(\", range=\")\n\tbuilder.WriteString(fmt.Sprintf(\"%v\", gr.Range))\n\tbuilder.WriteString(\", note=\")\n\tbuilder.WriteString(gr.Note)\n\tbuilder.WriteString(\", log=\")\n\tbuilder.WriteString(gr.Log)\n\tbuilder.WriteString(\", username=\")\n\tbuilder.WriteString(gr.Username)\n\tbuilder.WriteByte(')')\n\treturn builder.String()\n}", "func (o GroupInitContainerVolumeOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v GroupInitContainerVolume) string { return v.Name }).(pulumi.StringOutput)\n}", "func (o DeviceGroupDeviceOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v DeviceGroupDevice) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (o ClusterParameterGroupParameterOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ClusterParameterGroupParameter) string { return v.Name }).(pulumi.StringOutput)\n}", "func (name GroupNameFlag) String() string {\n\treturn name.GroupName.String()\n}", "func (v *StackPanel) Name() string {\n\treturn \"stackpanel\"\n}", "func (d Distribution) Name() string {\n\treturn strings.Replace(d.ID, \"-\", \"::\", -1)\n}", "func (x Group) String() string {\n\tif str, ok := _GroupMap[x]; ok {\n\t\treturn str\n\t}\n\treturn fmt.Sprintf(\"Group(%d)\", x)\n}", "func GroupName(name string) OptFunc {\n\treturn func(p *ByName) error {\n\t\tname = strings.TrimSpace(name)\n\t\terr := GroupNameCheck(name)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tp.groupName = name\n\t\treturn nil\n\t}\n}", "func (o AclOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Acl) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (c *client) GetName(ctx context.Context, groupID string) (string, error) {\n\tcli := c.getGroupClient()\n\n\tresp, err := cli.Detail(ctx, &pb.GroupRequest{Groupid: groupID})\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn \"\", err\n\t}\n\n\tif resp.ResultCode == pb.ResponseCode_NON_EXIST {\n\t\treturn \"\", ErrGroupNonExist\n\t}\n\n\treturn resp.Groups[0].GetName(), nil\n}", "func (impl *ServerServerGroup) ResourceName() string {\n\treturn \"server-servergroup\"\n}", "func (o PermissionSetOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *PermissionSet) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (o ProjectOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Project) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (o RegexPatternSetOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *RegexPatternSet) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (o StudioOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *Studio) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (o InstanceGroupManagerVersionOutput) Name() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v InstanceGroupManagerVersion) *string { return v.Name }).(pulumi.StringPtrOutput)\n}", "func (*DeleteInstanceGroup) name() string {\n\treturn \"deleteInstanceGroup\"\n}", "func (p provider) Name() string {\n\treturn p.name\n}", "func (s SetOfSpaces) Name() string {\r\n\treturn s.name\r\n}", "func (o NetworkPacketCaptureOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *NetworkPacketCapture) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (p *Provider) Name() string {\n\treturn p.name\n}", "func (e *EndComponent) Name() string {\n\treturn \"name\"\n}", "func (kmc KernelModuleCheck) Name() string {\n\tif kmc.Label != \"\" {\n\t\treturn kmc.Label\n\t}\n\treturn fmt.Sprintf(\"KernelModule-%s\", strings.Replace(kmc.Module, \"/\", \"-\", -1))\n}", "func SetGroupName(name string) {\n\tgroupName = name\n}", "func (o VolumeGroupSapHanaVolumeOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v VolumeGroupSapHanaVolume) string { return v.Name }).(pulumi.StringOutput)\n}", "func (a *MembersAPI) Name() string {\n\treturn a.name\n}", "func (*ListInstanceGroups) name() string {\n\treturn \"listInstanceGroups\"\n}", "func (o InstanceGroupManagerVersionResponseOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v InstanceGroupManagerVersionResponse) string { return v.Name }).(pulumi.StringOutput)\n}", "func (n NamedComponents) Name() string {\n\treturn n.uniqueComponent\n}", "func (t *Team) Name() string {\n\treturn t.name\n}", "func (d *Demo) Name() string {\n\treturn d.info.Name()\n}", "func (o ConnectedRegistryNotificationOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v ConnectedRegistryNotification) string { return v.Name }).(pulumi.StringOutput)\n}", "func (m *Group) GetDisplayName()(*string) {\n return m.displayName\n}", "func (p Project) Name() string {\n\treturn p.name\n}", "func (o RuleMfaOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *RuleMfa) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (c *Dg) Show(name string) (Entry, error) {\n c.con.LogQuery(\"(show) device group %q\", name)\n return c.details(c.con.Show, name)\n}", "func (o ConnectedRegistryOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *ConnectedRegistry) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (o PlaybackKeyPairOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *PlaybackKeyPair) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)\n}", "func (c *Config) Name(n int) string {\n\treturn fmt.Sprintf(\"%03d.%s\", n, c.Type)\n}", "func (*UpdateInstanceGroup) name() string {\n\treturn \"updateInstanceGroup\"\n}", "func (s *SharingKey) Name() string {\n\treturn string(s.name)\n}", "func (s Group) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (s Group) String() string {\n\treturn awsutil.Prettify(s)\n}", "func (g Gossiper) Name() string {\n\treturn g.name\n}", "func (id NetworkGroupId) String() string {\n\tcomponents := []string{\n\t\tfmt.Sprintf(\"Subscription: %q\", id.SubscriptionId),\n\t\tfmt.Sprintf(\"Resource Group Name: %q\", id.ResourceGroupName),\n\t\tfmt.Sprintf(\"Network Manager Name: %q\", id.NetworkManagerName),\n\t\tfmt.Sprintf(\"Network Group Name: %q\", id.NetworkGroupName),\n\t}\n\treturn fmt.Sprintf(\"Network Group (%s)\", strings.Join(components, \"\\n\"))\n}", "func (cmd *CLI) Name() string {\n\tvar name string\n\tif cmd.parent != nil {\n\t\tname = strings.Join([]string{cmd.parent.Name(), cmd.name}, \" \")\n\t} else {\n\t\tname = cmd.name\n\t}\n\treturn name\n}", "func (o FleetMetricAggregationTypeOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v FleetMetricAggregationType) string { return v.Name }).(pulumi.StringOutput)\n}", "func (o OptionGroupOptionOutput) OptionName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v OptionGroupOption) string { return v.OptionName }).(pulumi.StringOutput)\n}", "func (project *Project) Name() string {\n\treturn project.PName\n}", "func (sh SubdirectoryHeader) Name() string {\n\treturn string(sh.SubdirectoryName[0 : sh.TypeAndNameLength&0xf])\n}", "func (o BackendServiceFabricClusterServerX509NameOutput) Name() pulumi.StringOutput {\n\treturn o.ApplyT(func(v BackendServiceFabricClusterServerX509Name) string { return v.Name }).(pulumi.StringOutput)\n}", "func (l Level) Name() string {\n\treturn LevelName(l)\n}", "func (g *Gpg) Name() string {\n\treturn gpgLabel\n}", "func (c Provider) Name() string {\n\treturn \"GitHub\"\n}" ]
[ "0.80168146", "0.80168146", "0.75941217", "0.75454223", "0.74364364", "0.7433477", "0.7422203", "0.73819286", "0.7380036", "0.73613214", "0.7249155", "0.72418725", "0.7185711", "0.7158183", "0.7133307", "0.7036169", "0.7024919", "0.7012739", "0.6959442", "0.6914941", "0.6895415", "0.6876077", "0.68412757", "0.67925954", "0.6775768", "0.6750172", "0.6749456", "0.6671215", "0.66570324", "0.6621952", "0.65969074", "0.658828", "0.6568318", "0.65642446", "0.6560756", "0.6558466", "0.65045017", "0.64961404", "0.64923275", "0.6481466", "0.64578986", "0.6445377", "0.6437958", "0.6426955", "0.6398833", "0.63934124", "0.6341869", "0.63200825", "0.63004357", "0.6295351", "0.62376887", "0.6235386", "0.6234454", "0.6233862", "0.61742026", "0.6165737", "0.61524147", "0.61241984", "0.6102945", "0.61028045", "0.60956293", "0.60755634", "0.60608065", "0.60454684", "0.603075", "0.6019226", "0.6017223", "0.60166097", "0.60143864", "0.60124177", "0.6005599", "0.6004766", "0.6004024", "0.5999445", "0.5986665", "0.59825", "0.5982008", "0.5976316", "0.59726316", "0.59715724", "0.59647894", "0.5962496", "0.59616077", "0.5959673", "0.59561616", "0.59519047", "0.59518003", "0.59487617", "0.59487617", "0.5946798", "0.59402955", "0.59397256", "0.5934666", "0.59329677", "0.59271914", "0.5925615", "0.5925365", "0.59250283", "0.5922746", "0.592048" ]
0.8108221
0
Register will inspect the provided objects implementing the Unit interface to see if it needs to register the objects for any of the Group bootstrap phases. If a Unit doesn't satisfy any of the bootstrap phases it is ignored by Group. The returned array of booleans is of the same size as the amount of provided Units, signaling for each provided Unit if it successfully registered with Group for at least one of the bootstrap phases or if it was ignored.
func (g *Group) Register(units ...Unit) []bool { g.log = logger.GetLogger(g.name) hasRegistered := make([]bool, len(units)) for idx := range units { if !g.configured { // if RunConfig has been called we can no longer register Config // phases of Units if c, ok := units[idx].(Config); ok { g.c = append(g.c, c) hasRegistered[idx] = true } } if p, ok := units[idx].(PreRunner); ok { g.p = append(g.p, p) hasRegistered[idx] = true } if s, ok := units[idx].(Service); ok { g.s = append(g.s, s) hasRegistered[idx] = true } } return hasRegistered }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *MemoryArrayAllOf) HasUnits() bool {\n\tif o != nil && o.Units != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func Register(pcs ...components.Pluggable) int {\n\tregisteredComponents := 0\n\tfor _, pc := range pcs {\n\t\tregister, ok := registries[pc.Type]\n\t\tif !ok {\n\t\t\tlog.Warnf(\"%s is not registered as a pluggable component\", pc.Type)\n\t\t\tcontinue\n\t\t}\n\t\tregister(pc)\n\t\tregisteredComponents++\n\t\tlog.Infof(\"%s.%s %s pluggable component was successfully registered\", pc.Type, pc.Name, pc.Version)\n\t}\n\treturn registeredComponents\n}", "func Register(toReg ...Component) {\n\tfor i := range toReg {\n\t\tComponents = append(Components, toReg[i])\n\t}\n\tsort.Sort(ByCommand(Components))\n}", "func (container *Container) Register(factories ...interface{}) error {\n\tfor _, factory := range factories {\n\t\terr := container.RegisterOne(factory)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func Register(m ...initializer.Simple) {\n\tall = append(all, m...)\n}", "func (o *StorageHitachiParityGroupAllOf) HasRegisteredDevice() bool {\n\tif o != nil && o.RegisteredDevice != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (r *Resolver) Units() (*[]*Unit, error) {\n\tvar result []*Unit\n\tfor _, theirUnit := range units.All() {\n\t\tourUnit, err := NewUnit(theirUnit.Name)\n\t\tif err != nil {\n\t\t\treturn &result, err\n\t\t}\n\t\tresult = append(result, &ourUnit)\n\t}\n\treturn &result, nil\n}", "func (b *Builder) Register(br *sous.BuildResult) error {\n\tfor _, prod := range br.Products {\n\t\tif prod.Advisories.Contains(sous.IsBuilder) {\n\t\t\tmessages.ReportLogFieldsMessage(\"not pushing builder image\", logging.DebugLevel, b.log, prod)\n\t\t\tcontinue\n\t\t}\n\t\terr := b.pushToRegistry(prod)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\terr = b.recordName(prod)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (o *EquipmentBaseSensor) HasUnits() bool {\n\tif o != nil && o.Units != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (app *App) Register(devices ...*message.Device) {\n\t// we are registering devices, we should also register for\n\t// discovery messages, but they are handled in the app.\n\t// we add a NoopHandler to the map to make the subscription work\n\t// we only do this if no handler is allready registered\n\tif _, ok := app.handler[queue.Inventory]; !ok {\n\t\tapp.SetHandler(queue.Inventory, app.inventoryHandler)\n\t}\n\n\tapp.deviceLock.Lock()\n\tdefer app.deviceLock.Unlock()\n\tfor _, device := range devices {\n\t\tfound := false\n\t\tfor _, d := range app.devices {\n\t\t\tif *device.ID == *d.device.ID {\n\t\t\t\td.lastSeen = time.Now()\n\t\t\t\tfound = true\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\tapp.devices = append(app.devices, &appDevice{device: device, lastSeen: time.Now()})\n\t\t}\n\t}\n}", "func (r *Registry) RegisterGroups(groups ...*Group) error {\n\tfor _, group := range groups {\n\t\t_, ok := r.groupMap[group.ID]\n\t\tif ok {\n\t\t\treturn fmt.Errorf(\"duplicate group ID %q\", group.ID)\n\t\t}\n\n\t\terr := r.RegisterOutlets(group.Outlets...)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tr.groupMap[group.ID] = group\n\t\tr.groups = append(r.groups, group)\n\n\t\tlog.WithField(\"groupID\", group.ID).Info(\"registered outlet group\")\n\t}\n\n\treturn nil\n}", "func (r *Registry) Register(ds ...*Object) {\n\tr.Lock()\n\tdefer r.Unlock()\n\tr.initDataStores()\n\n\tfor _, obj := range ds {\n\t\tname := obj.Name\n\t\tr.dataStores[name] = obj\n\t\tr.dataStores[name].Enabled = true\n\t}\n}", "func RegisterAll(emitPerNodeGroupMetrics bool) {\n\tlegacyregistry.MustRegister(clusterSafeToAutoscale)\n\tlegacyregistry.MustRegister(nodesCount)\n\tlegacyregistry.MustRegister(nodeGroupsCount)\n\tlegacyregistry.MustRegister(unschedulablePodsCount)\n\tlegacyregistry.MustRegister(maxNodesCount)\n\tlegacyregistry.MustRegister(cpuCurrentCores)\n\tlegacyregistry.MustRegister(cpuLimitsCores)\n\tlegacyregistry.MustRegister(memoryCurrentBytes)\n\tlegacyregistry.MustRegister(memoryLimitsBytes)\n\tlegacyregistry.MustRegister(lastActivity)\n\tlegacyregistry.MustRegister(functionDuration)\n\tlegacyregistry.MustRegister(functionDurationSummary)\n\tlegacyregistry.MustRegister(errorsCount)\n\tlegacyregistry.MustRegister(scaleUpCount)\n\tlegacyregistry.MustRegister(gpuScaleUpCount)\n\tlegacyregistry.MustRegister(failedScaleUpCount)\n\tlegacyregistry.MustRegister(failedGPUScaleUpCount)\n\tlegacyregistry.MustRegister(scaleDownCount)\n\tlegacyregistry.MustRegister(gpuScaleDownCount)\n\tlegacyregistry.MustRegister(evictionsCount)\n\tlegacyregistry.MustRegister(unneededNodesCount)\n\tlegacyregistry.MustRegister(unremovableNodesCount)\n\tlegacyregistry.MustRegister(scaleDownInCooldown)\n\tlegacyregistry.MustRegister(oldUnregisteredNodesRemovedCount)\n\tlegacyregistry.MustRegister(overflowingControllersCount)\n\tlegacyregistry.MustRegister(skippedScaleEventsCount)\n\tlegacyregistry.MustRegister(napEnabled)\n\tlegacyregistry.MustRegister(nodeGroupCreationCount)\n\tlegacyregistry.MustRegister(nodeGroupDeletionCount)\n\tlegacyregistry.MustRegister(pendingNodeDeletions)\n\n\tif emitPerNodeGroupMetrics {\n\t\tlegacyregistry.MustRegister(nodesGroupMinNodes)\n\t\tlegacyregistry.MustRegister(nodesGroupMaxNodes)\n\t}\n}", "func (o *Group) Register() int {\n\to.wait_lock.Lock()\n\tdefer o.wait_lock.Unlock()\n\to.wg().Add(1)\n\to.wait_index++\n\to.wait_register[o.wait_index] = true\n\treturn o.wait_index\n}", "func (o *MemoryArrayAllOf) GetUnitsOk() ([]MemoryUnitRelationship, bool) {\n\tif o == nil || o.Units == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Units, true\n}", "func (i Transform) Registered() bool {\n\tfor _, v := range _Transform_values {\n\t\tif i == v {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (o *MemoryArrayAllOf) HasRegisteredDevice() bool {\n\tif o != nil && o.RegisteredDevice != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (o *MemoryArrayAllOf) SetUnits(v []MemoryUnitRelationship) {\n\to.Units = v\n}", "func (s *ExternalAgentStartedState) Register(events []Event) error {\n\tfor _, e := range events {\n\t\tif err := s.agent.subscribeUnsafe(e); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\ts.agent.setStateUnsafe(s.agent.RegisteredState)\n\ts.initFlow.ExternalAgentRegistered()\n\treturn nil\n}", "func (me *Container) Register(r Registries) *Container {\n\tfor _, v := range r {\n\t\tme.bag[v.Key] = v.Value\n\t}\n\n\treturn me\n}", "func (m MapRegistry) Register(rs []transport.Registrant) {\n\tfor _, r := range rs {\n\t\tif r.Service == \"\" {\n\t\t\tr.Service = m.defaultService\n\t\t}\n\n\t\tif r.Procedure == \"\" {\n\t\t\tpanic(\"Expected procedure name not to be empty string in registration\")\n\t\t}\n\n\t\tsp := transport.ServiceProcedure{\n\t\t\tService: r.Service,\n\t\t\tProcedure: r.Procedure,\n\t\t}\n\t\tm.entries[sp] = r.HandlerSpec\n\t}\n}", "func isRegistered(sample string, stringArray []string) bool {\n\tfor _, value := range stringArray {\n\t\tif ok := strings.Compare(sample, value); ok == 0 {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}", "func (tm *TestManager) Register(obj interface{}) {\n\ttm.ModuleMap[Common.GetTypeName(obj)] = reflect.TypeOf(obj)\n}", "func IsRegistered(name string) bool {\n\t_, ok := registry[name]\n\treturn ok\n}", "func (m *manager) IsRegistered(name string) bool {\n\treturn m.registry.Get(name) != nil\n}", "func (m *DeviceGroup) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAwsTestResult(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateAzureTestResult(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateCustomProperties(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateGcpTestResult(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateName(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateSubGroups(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (container *Container) RegisterCompose(registrars ...Registrar) error {\n\tfor _, registrar := range registrars {\n\t\terr := registrar(container)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func TestMultipleRegisterCalls(t *testing.T) {\n\tRegister(\"multiple-register-driver-1\")\n\trequire.PanicsWithError(t, \"Register called twice for driver multiple-register-driver-1\", func() {\n\t\tRegister(\"multiple-register-driver-1\")\n\t})\n\n\t// Should be no error.\n\tRegister(\"multiple-register-driver-2\")\n}", "func (router *Router) Register(modules ...IModule) {\n\tfor _, m := range modules {\n\t\trouter.modules[m.GetMID()] = m\n\t}\n}", "func (m *Metrics) MustRegister(metrics ...prometheus.Collector) {\n\tm.reg.MustRegister(metrics...)\n}", "func validateDevices(agentDevices, containerDevices []device.Device) bool {\n\tfor _, d := range containerDevices {\n\t\tif !slices.Contains(agentDevices, d) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func Register() {\n\tregisterConstMetrics()\n\t{{[- if .API.Enabled ]}}\n\tregisterGRPCMetrics()\n\t{{[- end ]}}\n\t{{[- if .Storage.Enabled ]}}\n\tregisterDatabaseMetrics()\n\t{{[- end ]}}\n\tregisterBusinessMetrics()\n}", "func IsRegistered(name string) bool {\n\treturn i.IsRegistered(name)\n}", "func (p *DevicePool) Register(d *Device, id string) bool {\n\tp.devicesMtx.Lock()\n\tdefer p.devicesMtx.Unlock()\n\t_, ok := p.devices[id]\n\tif ok {\n\t\treturn false\n\t}\n\tp.devices[id] = d\n\treturn true\n}", "func Register() []Option {\n\treturn []Option{\n\t\t/* Dependencies */\n\t\tDependencies(\n\t\t\tapp.Providers(),\n\t\t),\n\t\t\n\t\t/* Modules */\n\t\tModules(\n\t\t\tsrvhttp.HealthCheckModule{}, // health check module (http demo)\n\t\t\tdocs.Module{}, // docs module\n\t\t),\n\n\t\t/* Module Constructors */\n\t\tConstructors(\n\t\t\tapp.New,\n\t\t\tconfig.New, // config module\n\t\t\tcore.NewServeModule, // server module\n\t\t),\n\t}\n}", "func IsRegistered(name string) bool {\n\t_, ok := driverMap[name]\n\treturn ok\n}", "func (o *VirtualizationIweClusterAllOf) HasRegisteredDevice() bool {\n\tif o != nil && o.RegisteredDevice != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (gf *GOFactory) Register(typeID string, creator ICreator) bool {\n\tgologger.SLogger.Println(\"registering\", typeID)\n\n\t// check if already registered\n\t_, ok := gf.GoCreator[typeID]\n\tif ok {\n\t\tgologger.SLogger.Println(\"Already Registered Object \", typeID)\n\n\t\treturn false\n\t}\n\n\tgf.GoCreator[typeID] = creator\n\n\tgologger.SLogger.Println(\"Added To Factory Obj Of Type\", typeID)\n\n\treturn true\n}", "func Register(j Job) {\n\tif j == nil {\n\t\tpanic(\"Can't register nil job\")\n\t}\n\tregistry = append(registry, j)\n}", "func Register(params ...interface{}) {\n\t// appendParams will append the object that annotated with at.AutoConfiguration\n\tcomponentContainer, _ = appendParams(componentContainer, params...)\n\treturn\n}", "func (oc *OrganizationCreate) AddUnits(o ...*OrgUnit) *OrganizationCreate {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn oc.AddUnitIDs(ids...)\n}", "func checkUnits(units []ignv2_2types.Unit) bool {\n\tfor _, u := range units {\n\t\tfor j := range u.Dropins {\n\t\t\tpath := filepath.Join(pathSystemd, u.Name+\".d\", u.Dropins[j].Name)\n\t\t\tif status := checkFileContentsAndMode(path, []byte(u.Dropins[j].Contents), defaultFilePermissions); !status {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\n\t\tif u.Contents == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tpath := filepath.Join(pathSystemd, u.Name)\n\t\tif u.Mask {\n\t\t\tlink, err := filepath.EvalSymlinks(path)\n\t\t\tif err != nil {\n\t\t\t\tglog.Errorf(\"state validation: error while evaluation symlink for path: %q, err: %v\", path, err)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tif strings.Compare(pathDevNull, link) != 0 {\n\t\t\t\tglog.Errorf(\"state validation: invalid unit masked setting. path: %q; expected: %v; received: %v\", path, pathDevNull, link)\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tif status := checkFileContentsAndMode(path, []byte(u.Contents), defaultFilePermissions); !status {\n\t\t\treturn false\n\t\t}\n\n\t}\n\treturn true\n}", "func (m *ComputeRackUnit) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\t// validation for a type composition with ComputePhysical\n\tif err := m.ComputePhysical.Validate(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateAdapters(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateBiosBootmode(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateBiosunits(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateBmc(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateBoard(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateBootDeviceBootmode(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateFanmodules(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateGenericInventoryHolders(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateLocatorLed(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validatePciDevices(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validatePsus(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateRackEnclosureSlot(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateRegisteredDevice(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateSasExpanders(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateStorageEnclosures(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateTopSystem(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (l unitList) Started() bool {\n\tfor _, unit := range l {\n\t\tif unit.State != string(provision.StatusStarted) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (h *StorageArrayHandler) Register(api *echo.Group) {\n\tjwtMiddleware := middleware.JWT(utils.JWTSecret)\n\n\tstorageArrays := api.Group(\"/storage-arrays\", jwtMiddleware)\n\tstorageArrays.POST(\"\", h.CreateStorageArray)\n\tstorageArrays.GET(\"\", h.ListStorageArrays)\n\tstorageArrays.GET(\"/:id\", h.GetStorageArray)\n\tstorageArrays.DELETE(\"/:id\", h.DeleteStorageArray)\n\tstorageArrays.PATCH(\"/:id\", h.UpdateStorageArray)\n}", "func (o *RackUnitPersonality) HasRegisteredDevice() bool {\n\tif o != nil && o.RegisteredDevice != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (me *GlobalContainer) Register(r Registries) *GlobalContainer {\n\tfor _, v := range r {\n\t\tglobalContainerInstance.Container.bag[v.Key] = v.Value\n\t}\n\n\treturn me\n}", "func Registered() (names []string) {\n\tmux.Lock()\n\tdefer mux.Unlock()\n\n\tfor key := range pool {\n\t\tnames = append(names, key)\n\t}\n\treturn names\n}", "func (o *DataExportQuery) HasUnits() bool {\n\tif o != nil && o.Units != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (self gcmSink) Register(metrics []sink_api.MetricDescriptor) error {\n\tfor _, metric := range metrics {\n\t\tif err := self.core.Register(metric.Name, metric.Description, metric.Type.String(), metric.ValueType.String(), metric.Labels); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif rateMetric, exists := gcmRateMetrics[metric.Name]; exists {\n\t\t\tif err := self.core.Register(rateMetric.name, rateMetric.description, sink_api.MetricGauge.String(), sink_api.ValueDouble.String(), metric.Labels); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (reg *registrar) Register(example interface{}) error {\n\treg.lock.Lock()\n\tdefer reg.lock.Unlock()\n\treturn reg.Registry.Register(example)\n}", "func lazyCreateUnits(cCmd *cobra.Command, args []string) error {\n\terrchan := make(chan error)\n\tblockAttempts, _ := cCmd.Flags().GetInt(\"block-attempts\")\n\tvar wg sync.WaitGroup\n\tfor _, arg := range args {\n\t\targ = maybeAppendDefaultUnitType(arg)\n\t\tname := unitNameMangle(arg)\n\n\t\tret, err := checkUnitCreation(cCmd, arg)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t} else if ret != 0 {\n\t\t\tcontinue\n\t\t}\n\n\t\t// Assume that the name references a local unit file on\n\t\t// disk or if it is an instance unit and if so get its\n\t\t// corresponding unit\n\t\tuf, err := getUnitFile(cCmd, arg)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t_, err = createUnit(name, uf)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\twg.Add(1)\n\t\tgo checkUnitState(name, job.JobStateInactive, blockAttempts, os.Stdout, &wg, errchan)\n\t}\n\n\tgo func() {\n\t\twg.Wait()\n\t\tclose(errchan)\n\t}()\n\n\thaserr := false\n\tfor msg := range errchan {\n\t\tstderr(\"Error waiting on unit creation: %v\", msg)\n\t\thaserr = true\n\t}\n\n\tif haserr {\n\t\treturn fmt.Errorf(\"One or more errors creating units\")\n\t}\n\n\treturn nil\n}", "func (o *NiatelemetryNexusDashboardsAllOf) HasRegisteredDevice() bool {\n\tif o != nil && o.RegisteredDevice != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func RegisterElements(\n\tname string,\n\ttoInternal func(interface{}, string) (TAI64NARUXTime, error),\n\tfromInternal func(TAI64NARUXTime, string) (string, error),\n\toffset func(TAI64NARUXTime, interface{}) (TAI64NARUXTime, error),\n\tdefaultFormat string,\n) {\n\tregisteredCalendars[canonCalendarName(name)] = calendarRegistration{\n\t\tToInternal: toInternal,\n\t\tFromInternal: fromInternal,\n\t\tOffset: offset,\n\t\tDefaultFormat: defaultFormat,\n\t}\n}", "func Register(mut Mutation) {\n\tgob.Register(mut)\n\tt := reflect.TypeOf(mut)\n\tregistry[t.String()] = t\n}", "func (o *StorageHitachiPortAllOf) HasRegisteredDevice() bool {\n\tif o != nil && o.RegisteredDevice != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (p *jsiiProxy_ProfilingGroup) Validate() *[]*string {\n\tvar returns *[]*string\n\n\t_jsii_.Invoke(\n\t\tp,\n\t\t\"validate\",\n\t\tnil, // no parameters\n\t\t&returns,\n\t)\n\n\treturn returns\n}", "func UnitNames() [7]string {\n\treturn unitNames\n}", "func Register(i interface{}) {\n\tregister(i)\n}", "func deployUnits(hosts Hosts, appName, appVersion, unitFile string) bool {\n\t// get the next instance number to use for deployment\n\t// this function will also handling initializing the instance number\n\t// if one does not exist\n\n\tfmt.Println(\"getting instance number for non global unit\")\n\tnextInstNum := getNextInstance(hosts.etcd, appName)\n\n\t// init what we are going to return\n\tvar status bool\n\n\t// deploy new unit.\n\tsendTries := 5\n\tfor sendTries != 0 {\n\t\tsendUnitResponse := sendUnitFile(hosts.fleet, appName+\"-\"+appVersion, fmt.Sprintf(\"%d\", nextInstNum), unitFile)\n\t\tif sendUnitResponse.StatusCode != 201 {\n\t\t\t// special catch for 204 errors.\n\t\t\tif sendUnitResponse.StatusCode == 204 {\n\t\t\t\tcolor.Red(\"Received 204 - Duplicate unit file submitted to fleet. This usually a sign multiple unit files for this version. Contact DevOPs\")\n\t\t\t} else {\n\t\t\t\tcolor.Red(\"Error communicating with fleet trying again\")\n\t\t\t}\n\t\t\tsendTries--\n\t\t\tif sendTries == 0 {\n\t\t\t\tcolor.Red(\"Deployment Failed\")\n\t\t\t}\n\t\t\ttime.Sleep(1 * time.Second)\n\t\t} else {\n\t\t\t// we succeeded now break out of this loop\n\t\t\tsendTries = 0\n\t\t}\n\t}\n\n\t// now wait for the container to be up\n\t// only for the main unit types. Not watching for presence yet\n\tsuccess := instanceUp(hosts, appName, appVersion, fmt.Sprintf(\"%d\", nextInstNum), 600)\n\tif success == true {\n\t\tstatus = true\n\t\tcolor.Green(\"Deployment Successful\")\n\t} else {\n\t\tstatus = false\n\t}\n\n\t// default to false but we should never really hit this\n\treturn status\n\n}", "func (m MultiProducer) MultiRegister(r Registerer) {\n\tfor k, p := range m.producers {\n\t\tr.Register(k, p)\n\t}\n}", "func (h *Healthz) Register() *Check {\n\th.mu.Lock()\n\tdefer h.mu.Unlock()\n\n\tcheck := new(Check)\n\th.checks = append(h.checks, check)\n\n\treturn check\n}", "func (m *manager) Register(name string, item interface{}, tags map[string]string) error {\n\tif err := dtos.ValidateMetricName(name, \"metric\"); err != nil {\n\t\treturn err\n\t}\n\n\tif len(tags) > 0 {\n\t\tif err := m.setMetricTags(name, tags); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif err := m.registry.Register(name, item); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (p *Plugin) Register() error {\n\tpr := PluginRegistry()\n\tpr.mut.Lock()\n\tdefer pr.mut.Unlock()\n\n\tfor _, plugin := range pr.plugins {\n\t\tif plugin.Name == p.Name {\n\t\t\tlog.Printf(\"Ignoring multiple calls to Register() for plugin '%s'\", p.Name)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tpr.plugins = append(pr.plugins, p)\n\n\treturn nil\n}", "func (o *StoragePhysicalDiskAllOf) HasRegisteredDevice() bool {\n\tif o != nil && o.RegisteredDevice != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func RegisterTypes(registry interface {\n\t RegisterType(name string, obj any)\n}) {\n\n}", "func (o *EquipmentIdentityAllOf) HasRegisteredDevice() bool {\n\tif o != nil && o.RegisteredDevice != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func SupportedUnits() map[UnitType][]string {\n\tunitLock.RLock()\n\tdefer unitLock.RUnlock()\n\tsupported := make(map[UnitType][]string, len(supportedUnits))\n\tfor unit, aliases := range supportedUnits {\n\t\tsupported[unit] = aliases\n\t}\n\treturn supported\n}", "func setTargetStateOfUnits(units []string, state job.JobState) ([]*schema.Unit, error) {\n\ttriggered := make([]*schema.Unit, 0)\n\tfor _, name := range units {\n\t\tu, err := cAPI.Unit(name)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error retrieving unit %s from registry: %v\", name, err)\n\t\t} else if u == nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to find unit %s\", name)\n\t\t} else if job.JobState(u.DesiredState) == state {\n\t\t\tlog.Debugf(\"Unit(%s) already %s, skipping.\", u.Name, u.DesiredState)\n\t\t\tcontinue\n\t\t}\n\n\t\tlog.Debugf(\"Setting Unit(%s) target state to %s\", u.Name, state)\n\t\tif err := cAPI.SetUnitTargetState(u.Name, string(state)); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttriggered = append(triggered, u)\n\t}\n\n\treturn triggered, nil\n}", "func New(tag string) (Unit, error) {\n\tfor u, pair := range unitTags {\n\t\tif pair.Matched(tag) {\n\t\t\treturn u, nil\n\t\t}\n\t}\n\treturn Unimplemented, fmt.Errorf(\"Unimplemented unit tag: %v\", tag)\n}", "func (mr *MockISubKeyBucketMockRecorder) Register(receiver interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockISubKeyBucket)(nil).Register), receiver)\n}", "func (o *MemoryArrayAllOf) GetUnits() []MemoryUnitRelationship {\n\tif o == nil {\n\t\tvar ret []MemoryUnitRelationship\n\t\treturn ret\n\t}\n\treturn o.Units\n}", "func Register() error {\n\tnoopCompress := noop.New()\n\n\tfor name, c := range map[string]compress.Compression{\n\t\t\"\": noopCompress, // to ensure backwards compatibility\n\t\tnoop.AlgorithmName: noopCompress,\n\t\tgzip.AlgorithmName: gzip.New(),\n\t} {\n\t\tif err := compress.RegisterAlgorithm(name, c); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn nil\n}", "func (ouo *OrganizationUpdateOne) AddUnits(o ...*OrgUnit) *OrganizationUpdateOne {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn ouo.AddUnitIDs(ids...)\n}", "func (mr *MockUsersRepoInterfaceMockRecorder) Register(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockUsersRepoInterface)(nil).Register), arg0)\n}", "func (bc *Blockchain) Validate() bool {\n\tfor i := 0; i < len(*bc); i++ {\n\t\tif i == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif !(*bc)[i].Validate((*bc)[i-1]) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func Register(fn interface{}) error {\n\t// Validate that its a function\n\tfnType := reflect.TypeOf(fn)\n\tif err := validateFnFormat(fnType); err != nil {\n\t\treturn err\n\t}\n\t// Check if already registered\n\tfnName := getFunctionName(fn)\n\t_, ok := fnLookup.getFn(fnName)\n\tif ok {\n\t\treturn nil\n\t}\n\tfor i := 0; i < fnType.NumIn(); i++ {\n\t\targType := fnType.In(i)\n\t\t// Interfaces cannot be registered, their implementations should be\n\t\t// https://golang.org/pkg/encoding/gob/#Register\n\t\tif argType.Kind() != reflect.Interface {\n\t\t\targ := reflect.Zero(argType).Interface()\n\t\t\tif err := GlobalBackend().Encoder().Register(arg); err != nil {\n\t\t\t\treturn errors.Wrap(err, \"unable to register the message for encoding\")\n\t\t\t}\n\t\t}\n\t}\n\tfnLookup.addFn(fnName, fn)\n\treturn nil\n}", "func Register(ch chan ExecutionEvent, topics ...Topic) {\n\tfor _, t := range topics {\n\t\tsubscriberRegistry[t] = append(subscriberRegistry[t], ch)\n\t}\n}", "func push(q *availableUnits, units ...*workUnit) {\n\tfor _, unit := range units {\n\t\tq.Add(unit)\n\t}\n}", "func (d *DeviceGroup) Validate() error {\n\tvar mErr multierror.Error\n\n\tif d.Vendor == \"\" {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"device vendor must be specified\"))\n\t}\n\tif d.Type == \"\" {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"device type must be specified\"))\n\t}\n\tif d.Name == \"\" {\n\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"device name must be specified\"))\n\t}\n\n\tfor i, dev := range d.Devices {\n\t\tif dev == nil {\n\t\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"device %d is nil\", i))\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := dev.Validate(); err != nil {\n\t\t\t_ = multierror.Append(&mErr, multierror.Prefix(err, fmt.Sprintf(\"device %d: \", i)))\n\t\t}\n\t}\n\n\tfor k, v := range d.Attributes {\n\t\tif err := v.Validate(); err != nil {\n\t\t\t_ = multierror.Append(&mErr, fmt.Errorf(\"device attribute %q invalid: %v\", k, err))\n\t\t}\n\t}\n\n\treturn mErr.ErrorOrNil()\n\n}", "func (o *VirtualizationVmwareVirtualMachineAllOf) HasPortGroups() bool {\n\tif o != nil && o.PortGroups != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (r *registerManager) IsAllNodeRegistered(ts time.Time) bool {\n r.Lock()\n defer r.Unlock()\n\n var (\n isAllDone = true\n mLen = len(r.monitorList)\n )\n // if node is not being registered\n if !r.isRegisteringNode {\n return false\n }\n for i := 0; i < mLen; i++ {\n if !r.monitorList[i].isRegistered {\n isAllDone = false\n break\n }\n }\n return isAllDone\n}", "func (r *Registrator) Register(port int, reg quantum.Registry) error {\n\tfor _, t := range reg.Types() {\n\t\tr.Jobs[t] = \"0.0.0.0:\" + strconv.Itoa(port)\n\t}\n\n\treturn nil\n}", "func Register() map[string]string {\n\treturn map[string]string{\n\t\t\"name\": \"Beubo Example Plugin\",\n\t\t// identifier should be a unique identifier used to differentiate this plugin from other plugins\n\t\t\"identifier\": \"beubo_example_plugin\",\n\t}\n}", "func (ou *OrganizationUpdate) AddUnits(o ...*OrgUnit) *OrganizationUpdate {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn ou.AddUnitIDs(ids...)\n}", "func (me *masterExtension) Units() ([]k8scloudconfig.UnitAsset, error) {\n\tunitsMeta := []k8scloudconfig.UnitMetadata{\n\t\t{\n\t\t\tAssetContent: ignition.AzureCNINatRules,\n\t\t\tName: \"azure-cni-nat-rules.service\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.CertificateDecrypterUnit,\n\t\t\tName: \"certificate-decrypter.service\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.EtcdMountUnit,\n\t\t\tName: \"var-lib-etcd.mount\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.DockerMountUnit,\n\t\t\tName: \"var-lib-docker.mount\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.KubeletMountUnit,\n\t\t\tName: \"var-lib-kubelet.mount\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.VNICConfigurationUnit,\n\t\t\tName: \"vnic-configuration.service\",\n\t\t\tEnabled: true,\n\t\t},\n\t}\n\n\tdata := me.templateData(me.certFiles)\n\n\t// To use the certificate decrypter unit for the etcd data encryption config file.\n\tdata.certificateDecrypterUnitParams.CertsPaths = append(data.certificateDecrypterUnitParams.CertsPaths, encryptionConfigFilePath)\n\n\tvar newUnits []k8scloudconfig.UnitAsset\n\n\tfor _, fm := range unitsMeta {\n\t\tc, err := k8scloudconfig.RenderAssetContent(fm.AssetContent, data)\n\t\tif err != nil {\n\t\t\treturn nil, microerror.Mask(err)\n\t\t}\n\n\t\tunitAsset := k8scloudconfig.UnitAsset{\n\t\t\tMetadata: fm,\n\t\t\tContent: c,\n\t\t}\n\n\t\tnewUnits = append(newUnits, unitAsset)\n\t}\n\n\treturn newUnits, nil\n}", "func Register(s *health.State, options ...Option) error {\n\tro := newRegisterOptions(options...)\n\tr := metric.NewRegistry()\n\tif err := addMetrics(r, ro, s); err != nil {\n\t\treturn err\n\t}\n\tmetricproducer.GlobalManager().AddProducer(r)\n\treturn nil\n}", "func (o *EmbeddedUnitModel) HasUnitGroupId() bool {\n\tif o != nil && o.UnitGroupId != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (usl UnitStatusList) Group() (UnitStatusList, error) {\n\tmatchers := map[string]struct{}{}\n\tnewList := []fleet.UnitStatus{}\n\n\thashesEqual, err := allHashesEqual(usl)\n\tif err != nil {\n\t\treturn nil, maskAny(err)\n\t}\n\n\tfor _, us := range usl {\n\t\t// Group unit status\n\t\tgrouped, suffix, err := groupUnitStatus(usl, us)\n\t\tif err != nil {\n\t\t\treturn nil, maskAny(err)\n\t\t}\n\n\t\t// Prevent doubled aggregation.\n\t\tif _, ok := matchers[suffix]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tmatchers[suffix] = struct{}{}\n\n\t\tstatesEqual := allStatesEqual(grouped)\n\n\t\t// Aggregate.\n\t\tif hashesEqual && statesEqual {\n\t\t\tnewStatus := grouped[0]\n\t\t\tnewStatus.Name = \"*\"\n\t\t\tnewList = append(newList, newStatus)\n\t\t} else {\n\t\t\tnewList = append(newList, grouped...)\n\t\t}\n\t}\n\n\treturn newList, nil\n}", "func (_m *IService) RegisterMix(info models.MixRegistrationInfo) {\n\t_m.Called(info)\n}", "func Register(functions ...func()) *Manager {\n\treturn defaultManager.Register(functions...)\n}", "func MustRegister(decoder Decoder, mediaTypes ...string) {\n\tif err := Register(decoder, mediaTypes...); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (r *Registration) Check() (errlist []error) {\n\tif !r.NameIsOk() {\n\t\terrlist = append(errlist, nameError)\n\t}\n\tif !r.AddressIsOk() {\n\t\terrlist = append(errlist, addressError)\n\t}\n\tif !r.EmailIsOk() {\n\t\terrlist = append(errlist, emailError)\n\t}\n\treturn errlist\n}", "func MustRegisterMetrics(registrables ...metrics.Registerable) {\n\tfor _, r := range registrables {\n\t\terr := legacyregistry.Register(r)\n\t\tif err != nil {\n\t\t\tklog.Errorf(\"Failed to register metric %s: %v\", r.FQName(), err)\n\t\t}\n\t}\n}", "func (mr *MockHubMockRecorder) Register(c interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockHub)(nil).Register), c)\n}", "func Register(plugins *admission.Plugins) {\n\tplugins.Register(PluginName, NewFactory)\n}", "func Register(cmds ...*cli.Command) error {\n\treturn cmd.Register(cmds...)\n}", "func (s *mustRunAs) Validate(fldPath *field.Path, _ *api.Pod, groups []int64) field.ErrorList {\n\tallErrs := field.ErrorList{}\n\n\tif len(groups) == 0 && len(s.ranges) > 0 {\n\t\tallErrs = append(allErrs, field.Invalid(fldPath.Child(s.field), groups, \"unable to validate empty groups against required ranges\"))\n\t}\n\n\tfor _, group := range groups {\n\t\tif !s.isGroupValid(group) {\n\t\t\tdetail := fmt.Sprintf(\"%d is not an allowed group\", group)\n\t\t\tallErrs = append(allErrs, field.Invalid(fldPath.Child(s.field), groups, detail))\n\t\t}\n\t}\n\n\treturn allErrs\n}", "func (backend *Backend) DevicesRegistered() map[string]device.Interface {\n\treturn backend.devices\n}", "func (o *DataExportQuery) HasUnit() bool {\n\tif o != nil && o.Unit != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}" ]
[ "0.5419398", "0.5418993", "0.531174", "0.5119865", "0.50986594", "0.49601153", "0.4939661", "0.4924268", "0.49226665", "0.48969033", "0.48539323", "0.47764537", "0.4633344", "0.46204185", "0.45852447", "0.45746577", "0.45736307", "0.45174125", "0.44895804", "0.44889534", "0.44798318", "0.44712976", "0.44646692", "0.44265658", "0.44189548", "0.4414824", "0.44139528", "0.4383407", "0.4381984", "0.4373068", "0.43660828", "0.4362405", "0.4362103", "0.43437326", "0.43433616", "0.43266928", "0.4315063", "0.4311639", "0.43113142", "0.42997432", "0.42972127", "0.4291208", "0.4283654", "0.42783833", "0.42590705", "0.42544344", "0.42519882", "0.42436448", "0.42177314", "0.42158648", "0.42140162", "0.42057735", "0.42020893", "0.4197392", "0.41915435", "0.41889566", "0.4187937", "0.41855633", "0.41847798", "0.41822326", "0.41810393", "0.41801816", "0.41784483", "0.41761586", "0.4170961", "0.41653702", "0.41573548", "0.415344", "0.41444054", "0.4142637", "0.41370174", "0.4129867", "0.41273823", "0.4116813", "0.41097203", "0.41064116", "0.4103202", "0.4100136", "0.4096936", "0.40968347", "0.40955207", "0.40921968", "0.40910852", "0.4088122", "0.40801927", "0.40779468", "0.40726605", "0.40716234", "0.40708363", "0.4070183", "0.4065028", "0.40582117", "0.40500468", "0.40455124", "0.4039415", "0.4036452", "0.40339336", "0.40335172", "0.40300587", "0.40249932" ]
0.7825831
0
RegisterFlags returns FlagSet contains Flags in all modules.
func (g *Group) RegisterFlags() *FlagSet { // run configuration stage g.f = NewFlagSet(g.name) g.f.SortFlags = false // keep order of flag registration g.f.Usage = func() { fmt.Printf("Flags:\n") g.f.PrintDefaults() } gFS := NewFlagSet("Common Service options") gFS.SortFlags = false gFS.StringVarP(&g.name, "name", "n", g.name, `name of this service`) gFS.BoolVar(&g.showRunGroup, "show-rungroup-units", false, "show rungroup units") g.f.AddFlagSet(gFS.FlagSet) // register flags from attached Config objects fs := make([]*FlagSet, len(g.c)) for idx := range g.c { // a Namer might have been deregistered if g.c[idx] == nil { continue } g.log.Debug().Str("name", g.c[idx].Name()).Uint32("registered", uint32(idx+1)).Uint32("total", uint32(len(g.c))).Msg("register flags") fs[idx] = g.c[idx].FlagSet() if fs[idx] == nil { // no FlagSet returned g.log.Debug().Str("name", g.c[idx].Name()).Msg("config object did not return a flagset") continue } fs[idx].VisitAll(func(f *pflag.Flag) { if g.f.Lookup(f.Name) != nil { // log duplicate flag g.log.Warn().Str("name", f.Name).Uint32("registered", uint32(idx+1)).Msg("ignoring duplicate flag") return } g.f.AddFlag(f) }) } return g.f }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func RegisterFlags() {\n\tregisterFlags()\n}", "func (*bzlLibraryLang) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {}", "func (a *BootstrapCommand) RegisterFlags(r codegen.FlagRegistry) {\n\tfor _, c := range BootstrapCommands {\n\t\tif c != a {\n\t\t\tc.RegisterFlags(r)\n\t\t}\n\t}\n}", "func (app *App) RegFlags() {\n\tif app.Flags.values == nil {\n\t\tapp.Flags.values = make(map[string]Flag)\n\t}\n\tapp.flagsRegistered = true\n\tfor _, v := range app.flagsQueue {\n\t\tapp.Flags.values[v.Name] = Flag{\n\t\t\tName: v.Name,\n\t\t\tDescription: v.Description,\n\t\t\tDefault: v.Default,\n\t\t\tValue: flag.String(v.Name, v.Default, v.Description),\n\t\t}\n\t}\n}", "func registerFlags(c *Configuration) {\n\tfor _, k := range configurationMap {\n\t\tif k.Flag != \"\" {\n\t\t\tflagRegister(k, c)\n\t\t}\n\t}\n}", "func GetRegisterFlags() []cli.Flag {\n\treturn []cli.Flag{\n\t\tcli.IntFlag{\n\t\t\tName: FlagWeight,\n\t\t\tUsage: \"initial weight of this backend\",\n\t\t\tValue: 1,\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: FlagDC,\n\t\t\tUsage: \"datacenter short name as defined in VaaS\",\n\t\t\tEnvVar: EnvDC,\n\t\t},\n\t}\n}", "func (d *Data) RegisterFlags(fs *flag.FlagSet) {\n\tfs.BoolVar(&d.Verbose, \"verbose\", false, \"\")\n\tfs.IntVar(&d.Server.Port, \"server.port\", 80, \"\")\n\tfs.DurationVar(&d.Server.Timeout, \"server.timeout\", 60*time.Second, \"\")\n\n\tfs.StringVar(&d.TLS.Cert, \"tls.cert\", \"DEFAULTCERT\", \"\")\n\tfs.StringVar(&d.TLS.Key, \"tls.key\", \"DEFAULTKEY\", \"\")\n}", "func (cfg *Config) RegisterFlags(f *flag.FlagSet) {\n\tcfg.RegisterFlagsWithPrefix(\"\", f)\n}", "func (cmd *ListProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (cmd *ListCurrentProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (cfg *Config) RegisterFlags(f *flag.FlagSet) {\n\tcfg.RegisterFlagsWithPrefix(f, \"\")\n}", "func RegisterFlags() {\n\tflag.StringVar(&globalCfg.Endpoint, \"nrinsights-endpoint\", DefaultConfig.Endpoint, \"New Relic Insights API endpoint\")\n\tflag.StringVar(&globalCfg.Token, \"nrinsights-token\", DefaultConfig.Token, \"New Relic Insights API access token\")\n\tflag.IntVar(&globalCfg.MaxBatchSize, \"nrinsights-batch-size\", DefaultConfig.MaxBatchSize, \"Maximum size of message batches to Insights endpoint\")\n\tflag.DurationVar(&globalCfg.MaxBatchDelay, \"nrinsights-batch-delay\", DefaultConfig.MaxBatchDelay, \"Maximum delay between batches to Insights endpoint\")\n}", "func (cmd *ListStationProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar stationID int\n\tcc.Flags().IntVar(&cmd.StationID, \"stationId\", stationID, ``)\n}", "func (cmd *FindAllLocationsCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar game string\n\tcc.Flags().StringVar(&cmd.Game, \"game\", game, ``)\n}", "func (cmd *AddStationProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar projectID int\n\tcc.Flags().IntVar(&cmd.ProjectID, \"projectId\", projectID, ``)\n\tvar stationID int\n\tcc.Flags().IntVar(&cmd.StationID, \"stationId\", stationID, ``)\n}", "func (cfg *Config) RegisterFlags(fs *flag.FlagSet) {\n\tfs.BoolVar(&cfg.verbose, \"verbose\", false, \"Enable verbose logging.\")\n\tfs.BoolVar(&cfg.jsonLogs, \"json\", false, \"Encode logs as JSON, instead of pretty/human readable output.\")\n}", "func RegisterFlags(flags *flag.FlagSet, s interface{}, opts ...Option) error {\n\tv := reflect.ValueOf(s)\n\tif v.Kind() != reflect.Struct {\n\t\treturn fmt.Errorf(\"unable to register flags for %q: not a struct type\", v.Type())\n\t}\n\to := getOpts(opts...)\n\treturn registerStructFields(flags, v, o)\n}", "func (cmd *GetAllAccountsCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (cmd *TechListHyTechCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (cmd *ListFirmwareCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar module string\n\tcc.Flags().StringVar(&cmd.Module, \"module\", module, ``)\n\tvar page int\n\tcc.Flags().IntVar(&cmd.Page, \"page\", page, ``)\n\tvar pageSize int\n\tcc.Flags().IntVar(&cmd.PageSize, \"pageSize\", pageSize, ``)\n\tvar profile string\n\tcc.Flags().StringVar(&cmd.Profile, \"profile\", profile, ``)\n}", "func (c *Command) RegisterFlags(r codegen.FlagRegistry) {\n\tr.Flags().StringVar(&TargetPackage, \"pkg\", \"app\", \"Name of generated Go package containing controllers supporting code (contexts, media types, user types etc.)\")\n\tr.Flags().BoolVar(&NoGenTest, \"notest\", false, \"Prevent generation of test helpers\")\n}", "func RegisterFlags(fs *pflag.FlagSet) {\n\tfs.StringSlice(\"config-path\", configPaths.Default(), \"Paths to search for config files in.\")\n\tfs.String(\"config-type\", configType.Default(), \"Config file type (omit to infer config type from file extension).\")\n\tfs.String(\"config-name\", configName.Default(), \"Name of the config file (without extension) to search for.\")\n\tfs.String(\"config-file\", configFile.Default(), \"Full path of the config file (with extension) to use. If set, --config-path, --config-type, and --config-name are ignored.\")\n\tfs.Duration(\"config-persistence-min-interval\", configPersistenceMinInterval.Default(), \"minimum interval between persisting dynamic config changes back to disk (if no change has occurred, nothing is done).\")\n\n\tvar h = configFileNotFoundHandling.Default()\n\tfs.Var(&h, \"config-file-not-found-handling\", fmt.Sprintf(\"Behavior when a config file is not found. (Options: %s)\", strings.Join(handlingNames, \", \")))\n\n\tBindFlags(fs, configPaths, configType, configName, configFile, configFileNotFoundHandling, configPersistenceMinInterval)\n}", "func (c *Config) RegisterFlags(f *flag.FlagSet) {\n\tc.TLS.RegisterFlags(f)\n\tc.SASL.RegisterFlags(f)\n}", "func (b *AdapterBase) Flags() *pflag.FlagSet {\n\tb.initFlagSet()\n\tb.InstallFlags()\n\n\treturn b.FlagSet\n}", "func (cmd *ProjectRolesUserCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (c *DashboardLsCmd) RegisterFlags(fs *flag.FlagSet) {\n\tfs.StringVar(&c.Conf.UID, \"uid\", \"\", \"dashboard UID\")\n}", "func (cfg *Config) RegisterFlags(f *flag.FlagSet) {\n\tf.BoolVar(&cfg.ExitAfterFlush, \"flusher.exit-after-flush\", true, \"Stop Cortex after flush has finished. If false, Cortex process will keep running, doing nothing.\")\n}", "func (cfg *Config) RegisterFlags(f *flag.FlagSet) {\n\tcfg.Ring.RegisterFlags(\"index-gateway.\", \"collectors/\", f)\n\tf.StringVar((*string)(&cfg.Mode), \"index-gateway.mode\", SimpleMode.String(), \"Defines in which mode the index gateway server will operate (default to 'simple'). It supports two modes:\\n- 'simple': an index gateway server instance is responsible for handling, storing and returning requests for all indices for all tenants.\\n- 'ring': an index gateway server instance is responsible for a subset of tenants instead of all tenants.\")\n}", "func (cmd *GetUsersCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (l *Loader) RegisterFlags(fs *flag.FlagSet) {\n\tfs.StringVar(&l.ConfigPath, \"qscheduler-config\", \"\", \"Path to qscheduler config file\")\n}", "func (cmd *RemoveStationProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar projectID int\n\tcc.Flags().IntVar(&cmd.ProjectID, \"projectId\", projectID, ``)\n\tvar stationID int\n\tcc.Flags().IntVar(&cmd.StationID, \"stationId\", stationID, ``)\n}", "func RegisterFlagSets(cmd *cobra.Command, flagsets ...*pflag.FlagSet) {\n\tcommandFlagSets[cmd] = append(commandFlagSets[cmd], flagsets...)\n}", "func (msf *ModuleSetFlag) RegisterFlag(set *pflag.FlagSet, helpCommand string) {\n\tdescription := \"define the enabled modules (available modules: \" +\n\t\tmsf.availableModules.String() + \")\"\n\tif helpCommand != \"\" {\n\t\tdescription += \" use '\" + helpCommand + \"' for more information\"\n\t}\n\tif msf.shortFlag != \"\" {\n\t\tset.VarP(msf, msf.longFlag, msf.shortFlag, description)\n\t\treturn\n\t}\n\tset.Var(msf, msf.longFlag, description)\n}", "func (cmd *ListByProjectUserCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar projectID string\n\tcc.Flags().StringVar(&cmd.ProjectID, \"projectId\", projectID, ``)\n}", "func (cmd *TransmissionTokenUserCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (cmd *CompanyListHyCompanyCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func init() {\n\tregisterFlags(&Td)\n}", "func (cmd *UserListHyUserCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (c *Config) RegisterFlags(fs *flag.FlagSet) {\n\t_ = fs.String(\"config\", \"\", \"config path (YAML format)\")\n\tfs.StringVar(&c.LogHandler, \"o\", \"\", \"[\"+logging.GetLogOutputs()+\"]\")\n\tfs.StringVar(&c.LogLevel, \"v\", \"error\", \"[\"+logging.GetLogLevels()+\"]\")\n\n\tif err := ff.Parse(fs, os.Args[1:],\n\t\tff.WithIgnoreUndefined(true),\n\t\tff.WithConfigFileFlag(\"config\"),\n\t\tff.WithConfigFileParser(ffyaml.Parser),\n\t\tff.WithEnvVarNoPrefix(),\n\t); err != nil {\n\t\tlog.WithError(err).Fatal(\"Unable to parse flags\")\n\t}\n}", "func (cmd *HealthHealthCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (cmd *GetAllTransactionsCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar currencyURI string\n\tcc.Flags().StringVar(&cmd.CurrencyURI, \"currency_uri\", currencyURI, `currency's uri`)\n\tvar creatorPubkey string\n\tcc.Flags().StringVar(&cmd.CreatorPubkey, \"creator_pubkey\", creatorPubkey, `Public key of creator's account`)\n\tvar isCommitted string\n\tcc.Flags().StringVar(&cmd.IsCommitted, \"is_committed\", isCommitted, `If this value is true, you can only get transactions committed to ametsuchi`)\n\tvar target string\n\tcc.Flags().StringVar(&cmd.Target, \"target\", target, `Public key of URL-encoded target's account`)\n}", "func registerFlags(td *OsmTestData) {\n\tflag.BoolVar(&td.CleanupTest, \"cleanupTest\", true, \"Cleanup test resources when done\")\n\tflag.BoolVar(&td.WaitForCleanup, \"waitForCleanup\", true, \"Wait for effective deletion of resources\")\n\tflag.BoolVar(&td.IgnoreRestarts, \"ignoreRestarts\", false, \"When true, will not make tests fail if restarts of control plane processes are observed\")\n\n\tflag.StringVar(&td.TestDirBase, \"testDirBase\", testFolderBase, \"Test directory base. Test directory name will be created inside.\")\n\n\tflag.StringVar((*string)(&td.InstType), \"installType\", string(SelfInstall), \"Type of install/deployment for OSM\")\n\tflag.StringVar((*string)(&td.CollectLogs), \"collectLogs\", string(CollectLogsIfErrorOnly), \"Defines if/when to collect logs.\")\n\n\tflag.StringVar(&td.ClusterName, \"kindClusterName\", \"osm-e2e\", \"Name of the Kind cluster to be created\")\n\n\tflag.BoolVar(&td.CleanupKindCluster, \"cleanupKindCluster\", true, \"Cleanup kind cluster upon exit\")\n\tflag.BoolVar(&td.CleanupKindClusterBetweenTests, \"cleanupKindClusterBetweenTests\", false, \"Cleanup kind cluster between tests\")\n\tflag.StringVar(&td.ClusterVersion, \"kindClusterVersion\", \"\", \"Kind cluster version, ex. v.1.20.2\")\n\n\tflag.StringVar(&td.CtrRegistryServer, \"ctrRegistry\", os.Getenv(\"CTR_REGISTRY\"), \"Container registry\")\n\tflag.StringVar(&td.CtrRegistryUser, \"ctrRegistryUser\", os.Getenv(\"CTR_REGISTRY_USER\"), \"Container registry\")\n\tflag.StringVar(&td.CtrRegistryPassword, \"ctrRegistrySecret\", os.Getenv(\"CTR_REGISTRY_PASSWORD\"), \"Container registry secret\")\n\n\tflag.StringVar(&td.OsmImageTag, \"osmImageTag\", utils.GetEnv(\"CTR_TAG\", defaultImageTag), \"OSM image tag\")\n\tflag.StringVar(&td.OsmNamespace, \"OsmNamespace\", utils.GetEnv(\"K8S_NAMESPACE\", defaultOsmNamespace), \"OSM Namespace\")\n\tflag.StringVar(&td.OsmMeshConfigName, \"OsmMeshConfig\", defaultMeshConfigName, \"OSM MeshConfig name\")\n\n\tflag.BoolVar(&td.EnableNsMetricTag, \"EnableMetricsTag\", true, \"Enable tagging Namespaces for metrics collection\")\n\tflag.BoolVar(&td.DeployOnOpenShift, \"deployOnOpenShift\", false, \"Configure tests to run on OpenShift\")\n\tflag.BoolVar(&td.DeployOnWindowsWorkers, \"deployOnWindowsWorkers\", false, \"Configure tests to run on Windows workers\")\n\tflag.BoolVar(&td.RetryAppPodCreation, \"retryAppPodCreation\", true, \"Retry app pod creation on error\")\n\tflag.BoolVar(&td.EnableSPIFFE, \"enableSPIFFE\", false, \"Globally Enables SPIFFE IDs when running tests\")\n}", "func (cmd *GetLocationsCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar id int\n\tcc.Flags().IntVar(&cmd.ID, \"id\", id, ``)\n\tvar lat string\n\tcc.Flags().StringVar(&cmd.Lat, \"lat\", lat, ``)\n\tvar long string\n\tcc.Flags().StringVar(&cmd.Long, \"long\", long, ``)\n}", "func (cmd *GetCompanyGroupHyCompanyCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar companyID int\n\tcc.Flags().IntVar(&cmd.CompanyID, \"companyID\", companyID, `Company ID`)\n\tvar hqFlg string\n\tcc.Flags().StringVar(&cmd.HqFlg, \"hq_flg\", hqFlg, ``)\n}", "func (cmd *ListAccountCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func RegisterGRPCFlags() {\n\tGRPCPort = flag.Int(\"grpc_port\", 0, \"Port to listen on for gRPC calls\")\n}", "func (cfg *RingCfg) RegisterFlags(prefix, storePrefix string, f *flag.FlagSet) {\n\tcfg.RegisterFlagsWithPrefix(prefix, storePrefix, f)\n\tf.IntVar(&cfg.ReplicationFactor, \"replication-factor\", 3, \"How many index gateway instances are assigned to each tenant.\")\n}", "func (c *Config) RegisterFlags(f *flag.FlagSet) {\n\tf.StringVar(&c.WALDir, \"prometheus.wal-directory\", \"\", \"base directory to store the WAL in\")\n\tf.DurationVar(&c.InstanceRestartBackoff, \"prometheus.instance-restart-backoff\", DefaultConfig.InstanceRestartBackoff, \"how long to wait before restarting a failed Prometheus instance\")\n\n\tc.ServiceConfig.RegisterFlagsWithPrefix(\"prometheus.service.\", f)\n\tc.ServiceClientConfig.RegisterFlags(f)\n}", "func (t *T) AddFlags(fs *flag.FlagSet) {\n\tt.RequirementLevels.AddFlags(fs)\n\tt.FeatureStates.AddFlags(fs)\n}", "func (cmd *GetTechHyTechCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar techID int\n\tcc.Flags().IntVar(&cmd.TechID, \"techID\", techID, `Tech ID`)\n}", "func (cmd *ListUserCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func RegisterFlags(f *flag.FlagSet) {\n\tf.StringVar(&CPUProfileFlag, \"cpuprofile\", \"\", \"a filename to write a CPU profile.\")\n\tf.StringVar(&HeapProfileFlag, \"heapprofile\", \"\", \"a filename to write a heap profile.\")\n\tf.StringVar(&ThreadProfileFlag, \"threadprofile\", \"\", \"a filename to write the stack traces that caused new OS threads to be created.\")\n\tf.StringVar(&BlockProfileFlag, \"blockprofile\", \"\", \"a filename to write the stack traces that caused blocking on synchronization primitives.\")\n}", "func (cmd *GetProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar projectID int\n\tcc.Flags().IntVar(&cmd.ProjectID, \"projectId\", projectID, ``)\n}", "func AddAndParseFlags(fs *flag.FlagSet) error { return nil }", "func (cmd *ListBookCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (c *Config) RegisterFlags(flags *pflag.FlagSet) {\n\tflags.BoolVar(&c.EnableMiddleware, \"cors-enable-middleware\", c.EnableMiddleware, \"Specify whether or not CORS middleware is enabled to enforce policies on cross origin requests\")\n\tflags.StringVar(&c.AllowedOrigins, \"cors-allowed-origins\", c.AllowedOrigins, \"Specify which origin(s) allow responses to be populated with headers to allow cross origin requests (e.g. \\\"*\\\") or \\\"https://example.com\\\")\")\n\tflags.StringVar(&c.AllowedMethods, \"cors-allowed-methods\", c.AllowedMethods, \"Specify which method(s) allow responses to be populated with headers to allow cross origin requests (e.g. \\\"POST, GET, OPTIONS, PUT, DELETE\\\")\")\n\tflags.StringVar(&c.AllowedHeaders, \"cors-allowed-headers\", c.AllowedHeaders, \"Specify which header(s) are allowed for cross origin requests (e.g. \\\"*\\\" or \\\"Accept, Content-Type, Content-Length\\\")\")\n}", "func (cmd *GetCurrentUserCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (sdr *SDR) RegisterFlags() {\n\tflag.StringVar(&sdr.Flags.ServerAddr, \"server\", \"127.0.0.1:1234\", \"address or hostname of rtl_tcp instance\")\n\tflag.Var(&sdr.Flags.CenterFreq, \"centerfreq\", \"center frequency to receive on\")\n\tflag.Lookup(\"centerfreq\").DefValue = \"100M\"\n\tflag.Var(&sdr.Flags.SampleRate, \"samplerate\", \"sample rate\")\n\tflag.Lookup(\"samplerate\").DefValue = \"2.4M\"\n\tflag.BoolVar(&sdr.Flags.TunerGainMode, \"tunergainmode\", false, \"enable/disable tuner gain\")\n\tflag.Float64Var(&sdr.Flags.TunerGain, \"tunergain\", 0.0, \"set tuner gain in dB\")\n\tflag.IntVar(&sdr.Flags.FreqCorrection, \"freqcorrection\", 0, \"frequency correction in ppm\")\n\tflag.BoolVar(&sdr.Flags.TestMode, \"testmode\", false, \"enable/disable test mode\")\n\tflag.BoolVar(&sdr.Flags.AgcMode, \"agcmode\", false, \"enable/disable rtl agc\")\n\tflag.BoolVar(&sdr.Flags.DirectSampling, \"directsampling\", false, \"enable/disable direct sampling\")\n\tflag.BoolVar(&sdr.Flags.OffsetTuning, \"offsettuning\", false, \"enable/disable offset tuning\")\n\tflag.UintVar(&sdr.Flags.RtlXtalFreq, \"rtlxtalfreq\", 0, \"set rtl xtal frequency\")\n\tflag.UintVar(&sdr.Flags.TunerXtalFreq, \"tunerxtalfreq\", 0, \"set tuner xtal frequency\")\n\tflag.UintVar(&sdr.Flags.GainByIndex, \"gainbyindex\", 0, \"set gain by index\")\n}", "func (p *Pack) AddFlags(flags registry.Flags) {\n\tp.flags |= flags\n}", "func (cmd *ListHeroCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (cmd *GetFieldNoteCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar stationID int\n\tcc.Flags().IntVar(&cmd.StationID, \"stationId\", stationID, ``)\n}", "func (cfg *Config) RegisterFlags(f *flag.FlagSet) {\n\tcfg.AWSStorageConfig.RegisterFlags(f)\n\tcfg.AzureStorageConfig.RegisterFlags(f)\n\tcfg.GCPStorageConfig.RegisterFlags(f)\n\tcfg.GCSConfig.RegisterFlags(f)\n\tcfg.CassandraStorageConfig.RegisterFlags(f)\n\tcfg.BoltDBConfig.RegisterFlags(f)\n\tcfg.FSConfig.RegisterFlags(f)\n\tcfg.DeleteStoreConfig.RegisterFlags(f)\n\tcfg.Swift.RegisterFlags(f)\n\tcfg.GrpcConfig.RegisterFlags(f)\n\n\tf.StringVar(&cfg.Engine, \"store.engine\", \"chunks\", \"The storage engine to use: chunks (deprecated) or blocks.\")\n\tcfg.IndexQueriesCacheConfig.RegisterFlagsWithPrefix(\"store.index-cache-read.\", \"Cache config for index entry reading. \", f)\n\tf.DurationVar(&cfg.IndexCacheValidity, \"store.index-cache-validity\", 5*time.Minute, \"Cache validity for active index entries. Should be no higher than -ingester.max-chunk-idle.\")\n}", "func (cmd *InviteUserProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request body encoded in JSON\")\n\tcc.Flags().StringVar(&cmd.ContentType, \"content\", \"\", \"Request content type override, e.g. 'application/x-www-form-urlencoded'\")\n\tvar projectID int\n\tcc.Flags().IntVar(&cmd.ProjectID, \"projectId\", projectID, ``)\n}", "func getFlagsGroup() []cli.Flag {\n\treturn []cli.Flag{\n\t\t&cli.StringFlag{\n\t\t\tName: \"use\",\n\t\t\tAliases: []string{\"u\"},\n\t\t\tUsage: \"set default engine [gin|http]\",\n\t\t\tValue: \"gin\",\n\t\t},\n\t\t&cli.StringFlag{\n\t\t\tName: \"path\",\n\t\t\tAliases: []string{\"p\", \"static\"},\n\t\t\tUsage: \"set default static file path\",\n\t\t\tValue: \".\",\n\t\t},\n\t\t&cli.StringFlag{\n\t\t\tName: \"index\",\n\t\t\tAliases: []string{\"i\", \"index_file\"},\n\t\t\tUsage: \"set default index file\",\n\t\t\tValue: \"index.html\",\n\t\t},\n\t\t&cli.IntFlag{\n\t\t\tName: \"port\",\n\t\t\tAliases: []string{\"po\"},\n\t\t\tUsage: \"set default listen port\",\n\t\t\tValue: 5000,\n\t\t},\n\t\t&cli.StringFlag{\n\t\t\tName: \"log\",\n\t\t\tAliases: []string{\"l\", \"logfile\"},\n\t\t\tUsage: \"set default logfile\",\n\t\t\tValue: \"\",\n\t\t},\n\t\t&cli.BoolFlag{\n\t\t\tName: \"withtime\",\n\t\t\tAliases: []string{\"enable\", \"time\"},\n\t\t\tUsage: \"log with current time\",\n\t\t\tValue: false,\n\t\t},\n\t\t&cli.BoolFlag{\n\t\t\tName: \"test\",\n\t\t\tAliases: []string{\"t\", \"testit\"},\n\t\t\tUsage: \"run in a test mode\",\n\t\t\tValue: false,\n\t\t},\n\t\t&cli.BoolFlag{\n\t\t\tName: \"try\",\n\t\t\tAliases: []string{\"tryfile\"},\n\t\t\tUsage: \"run in a try file mode\",\n\t\t\tValue: false,\n\t\t},\n\t\t&cli.BoolFlag{\n\t\t\tName: \"daemon\",\n\t\t\tAliases: []string{\"d\"},\n\t\t\tUsage: \"run in a daemon mode\",\n\t\t\tValue: false,\n\t\t},\n\t}\n}", "func SetFlags(f *asn1.BitString, j []int) {\n\tfor _, i := range j {\n\t\tSetFlag(f, i)\n\t}\n}", "func RegisterEngineFlags(flagset *flag.FlagSet) *EngineSettings {\n\ts := new(EngineSettings)\n\tflagset.BoolVar(&s.UseTranspositionTable, \"use_transposition_table\", true, \"Use the transposition table during search.\")\n\tflagset.BoolVar(&s.UsePonder, \"use_ponder\", true, `Ponder on the opponent's turn.\nPonder implies we will search until we're asked explicitly to stop unless a terminal score is guaranteed.\nWe don't print the best move after a ponder. We don't clear the transposition table when we're done.`)\n\tflag.Int64Var(&s.Seed, \"seed\", 0, \"Seed for random state in the engine. Defaults to a time-based seed.\")\n\tflag.UintVar(&s.Concurrency, \"concurrency\", 1, \"Use this number of goroutines for concurrent MCTS.\")\n\tflag.StringVar(&s.MoveList, \"movelist\", \"\",\n\t\t`Execute \"newgame\" followed by the given movelist.\nThis should be the path to a move list file. Each line should be prefixed by move number and color (e.g. 5s Rd4e).\nSetup moves must be included. The last line may include a move number and color to indice the side to move.\nThe file may be newline terminated.`)\n\tflag.Var(&s.Options, \"O\", `Repeated flag used to set AEI options (e.g. -O foo=1 -O bar=\"xxx\"`)\n\tflag.BoolVar(&s.UseDatasetWriter, \"use_dataset_writer\", false, \"Enables the Dataset writer for outputting training data\")\n\tflag.IntVar(&s.DatasetEpoch, \"dataset_epoch\", 0, \"Epoch number to use when writing Dataset files\")\n\tflag.IntVar(&s.PlayBatchGames, \"playbatch_games\", 5000, \"Number of games to play for `playbatch'\")\n\tflag.BoolVar(&s.UseSampledMove, \"use_suboptimal_move\", false, \"Sample to best move instead of selecting the best\")\n\tflag.BoolVar(&s.UseSavedModel, \"use_saved_model\", false, \"Use a saved model configured by model_graph_path*\")\n\tflag.StringVar(&s.SavedModelPath, \"saved_model_path\", \"\", \"Path to GraphDef binary protocol buffer\")\n\treturn s\n}", "func (cfg *Config) RegisterFlags(f *flag.FlagSet) {\n\tcfg.AWSStorageConfig.RegisterFlags(f)\n\tcfg.AzureStorageConfig.RegisterFlags(f)\n\tcfg.BOSStorageConfig.RegisterFlags(f)\n\tcfg.GCPStorageConfig.RegisterFlags(f)\n\tcfg.GCSConfig.RegisterFlags(f)\n\tcfg.CassandraStorageConfig.RegisterFlags(f)\n\tcfg.BoltDBConfig.RegisterFlags(f)\n\tcfg.FSConfig.RegisterFlags(f)\n\tcfg.Swift.RegisterFlags(f)\n\tcfg.GrpcConfig.RegisterFlags(f)\n\tcfg.Hedging.RegisterFlagsWithPrefix(\"store.\", f)\n\n\tcfg.IndexQueriesCacheConfig.RegisterFlagsWithPrefix(\"store.index-cache-read.\", \"Cache config for index entry reading.\", f)\n\tf.DurationVar(&cfg.IndexCacheValidity, \"store.index-cache-validity\", 5*time.Minute, \"Cache validity for active index entries. Should be no higher than -ingester.max-chunk-idle.\")\n\tf.BoolVar(&cfg.DisableBroadIndexQueries, \"store.disable-broad-index-queries\", false, \"Disable broad index queries which results in reduced cache usage and faster query performance at the expense of somewhat higher QPS on the index store.\")\n\tf.IntVar(&cfg.MaxParallelGetChunk, \"store.max-parallel-get-chunk\", 150, \"Maximum number of parallel chunk reads.\")\n\tcfg.BoltDBShipperConfig.RegisterFlags(f)\n\tf.IntVar(&cfg.MaxChunkBatchSize, \"store.max-chunk-batch-size\", 50, \"The maximum number of chunks to fetch per batch.\")\n\tcfg.TSDBShipperConfig.RegisterFlagsWithPrefix(\"tsdb.\", f)\n}", "func (cmd *GetJSONDataCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar deviceID string\n\tcc.Flags().StringVar(&cmd.DeviceID, \"deviceId\", deviceID, ``)\n\tvar end int\n\tcc.Flags().IntVar(&cmd.End, \"end\", end, ``)\n\tvar internal string\n\tcc.Flags().StringVar(&cmd.Internal, \"internal\", internal, ``)\n\tvar page int\n\tcc.Flags().IntVar(&cmd.Page, \"page\", page, ``)\n\tvar pageSize int\n\tcc.Flags().IntVar(&cmd.PageSize, \"pageSize\", pageSize, ``)\n\tvar start int\n\tcc.Flags().IntVar(&cmd.Start, \"start\", start, ``)\n}", "func (h *HyperCommand) Flags() *pflag.FlagSet {\n\treturn h.root.Flags()\n}", "func (cmd *GetAllSignatoriesCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar target string\n\tcc.Flags().StringVar(&cmd.Target, \"target\", target, `Public key of URL-encoded target's account`)\n\tvar creatorPubkey string\n\tcc.Flags().StringVar(&cmd.CreatorPubkey, \"creator_pubkey\", creatorPubkey, `Public key of URL-encoded creator's account`)\n\tvar isCommitted string\n\tcc.Flags().StringVar(&cmd.IsCommitted, \"is_committed\", isCommitted, `If this value is true, you can only get transactions committed to ametsuchi`)\n}", "func (cmd *Command) registerPrivateFlags() {\n\tfor _, f := range cmd.Flags {\n\t\tprivateFlags[f] = true\n\t}\n}", "func (cmd *GetAllCurrencyCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar currencyURI string\n\tcc.Flags().StringVar(&cmd.CurrencyURI, \"currency_uri\", currencyURI, `currency's uri`)\n\tvar creatorPubkey string\n\tcc.Flags().StringVar(&cmd.CreatorPubkey, \"creator_pubkey\", creatorPubkey, `Public key of creator's account`)\n\tvar isCommitted string\n\tcc.Flags().StringVar(&cmd.IsCommitted, \"is_committed\", isCommitted, `If this value is true, you can only get transactions committed to ametsuchi`)\n\tvar target string\n\tcc.Flags().StringVar(&cmd.Target, \"target\", target, `Public key of URL-encoded target's account`)\n}", "func (p *Pack) Flags() registry.Flags {\n\treturn p.flags\n}", "func (module *Module) NewFlags() interface{} {\n\treturn new(Flags)\n}", "func NewFlagSet(flags ...string) FlagSet {\n\tfs := make(FlagSet, len(flags))\n\tfor _, v := range flags {\n\t\tfs[v] = true\n\t}\n\treturn fs\n}", "func (c *Command) RegisterFlags(r codegen.FlagRegistry) {\n\tr.Flags().StringVar(&Version, \"cli-version\", \"1.0\", \"Generated client version\")\n}", "func (cmd *GetAccountsCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar target string\n\tcc.Flags().StringVar(&cmd.Target, \"target\", target, `Public key of URL-encoded target's account`)\n\tvar creatorPubkey string\n\tcc.Flags().StringVar(&cmd.CreatorPubkey, \"creator_pubkey\", creatorPubkey, `Public key of URL-encoded creator's account`)\n\tvar isCommitted string\n\tcc.Flags().StringVar(&cmd.IsCommitted, \"is_committed\", isCommitted, `If this value is true, you can only get transactions committed to ametsuchi`)\n}", "func (cmd *ValidateUserCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar token string\n\tcc.Flags().StringVar(&cmd.Token, \"token\", token, ``)\n}", "func (cfg *PeriodicTableConfig) RegisterFlags(f *flag.FlagSet) {\n\tf.BoolVar(&cfg.UsePeriodicTables, \"dynamodb.use-periodic-tables\", true, \"Should we user periodic tables.\")\n\tf.StringVar(&cfg.TablePrefix, \"dynamodb.periodic-table.prefix\", \"cortex_\", \"DynamoDB table prefix for the periodic tables.\")\n\tf.DurationVar(&cfg.TablePeriod, \"dynamodb.periodic-table.period\", 7*24*time.Hour, \"DynamoDB periodic tables period.\")\n\tf.Var(&cfg.PeriodicTableStartAt, \"dynamodb.periodic-table.start\", \"DynamoDB periodic tables start time.\")\n}", "func (cmd *UpdateProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request body encoded in JSON\")\n\tcc.Flags().StringVar(&cmd.ContentType, \"content\", \"\", \"Request content type override, e.g. 'application/x-www-form-urlencoded'\")\n\tvar projectID int\n\tcc.Flags().IntVar(&cmd.ProjectID, \"projectId\", projectID, ``)\n}", "func (cmd *DownloadFirmwareCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar firmwareID int\n\tcc.Flags().IntVar(&cmd.FirmwareID, \"firmwareId\", firmwareID, ``)\n}", "func (o *ModuleOptions) Register(f *flag.FlagSet) {\n\tif o.MaxConcurrentRPCs == 0 {\n\t\to.MaxConcurrentRPCs = defaultMaxConcurrentRPCs\n\t}\n\tf.Int64Var(\n\t\t&o.MaxConcurrentRPCs,\n\t\t\"limiter-max-concurrent-rpcs\",\n\t\to.MaxConcurrentRPCs,\n\t\tfmt.Sprintf(\"Limit on a number of incoming concurrent RPCs (default is %d)\", o.MaxConcurrentRPCs),\n\t)\n\tf.BoolVar(\n\t\t&o.AdvisoryMode,\n\t\t\"limiter-advisory-mode\",\n\t\to.AdvisoryMode,\n\t\t\"If set, don't enforce -limiter-max-concurrent-rpcs, but still report violations\",\n\t)\n}", "func (cmd *AddProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request body encoded in JSON\")\n\tcc.Flags().StringVar(&cmd.ContentType, \"content\", \"\", \"Request content type override, e.g. 'application/x-www-form-urlencoded'\")\n}", "func (cmd *LogoutUserCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n}", "func (cmd *ResolvedRecordsCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar recordID int\n\tcc.Flags().IntVar(&cmd.RecordID, \"recordId\", recordID, ``)\n}", "func (cmd *FilteredRecordsCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar recordID int\n\tcc.Flags().IntVar(&cmd.RecordID, \"recordId\", recordID, ``)\n}", "func (cmd *ListRoomCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar limit int\n\tcc.Flags().IntVar(&cmd.Limit, \"limit\", limit, ``)\n\tvar offset int\n\tcc.Flags().IntVar(&cmd.Offset, \"offset\", offset, ``)\n}", "func (cfg *Config) RegisterFlags(f *flag.FlagSet) {\n\tf.StringVar(&cfg.Addresses, \"cassandra.addresses\", \"\", \"Comma-separated hostnames or IPs of Cassandra instances.\")\n\tf.IntVar(&cfg.Port, \"cassandra.port\", 9042, \"Port that Cassandra is running on\")\n\tf.StringVar(&cfg.Keyspace, \"cassandra.keyspace\", \"\", \"Keyspace to use in Cassandra.\")\n\tf.StringVar(&cfg.Consistency, \"cassandra.consistency\", \"QUORUM\", \"Consistency level for Cassandra.\")\n\tf.IntVar(&cfg.ReplicationFactor, \"cassandra.replication-factor\", 1, \"Replication factor to use in Cassandra.\")\n\tf.BoolVar(&cfg.DisableInitialHostLookup, \"cassandra.disable-initial-host-lookup\", false, \"Instruct the cassandra driver to not attempt to get host info from the system.peers table.\")\n\tf.BoolVar(&cfg.SSL, \"cassandra.ssl\", false, \"Use SSL when connecting to cassandra instances.\")\n\tf.BoolVar(&cfg.HostVerification, \"cassandra.host-verification\", true, \"Require SSL certificate validation.\")\n\tf.StringVar(&cfg.CAPath, \"cassandra.ca-path\", \"\", \"Path to certificate file to verify the peer.\")\n\tf.BoolVar(&cfg.Auth, \"cassandra.auth\", false, \"Enable password authentication when connecting to cassandra.\")\n\tf.StringVar(&cfg.Username, \"cassandra.username\", \"\", \"Username to use when connecting to cassandra.\")\n\tf.StringVar(&cfg.Password, \"cassandra.password\", \"\", \"Password to use when connecting to cassandra.\")\n\tf.DurationVar(&cfg.Timeout, \"cassandra.timeout\", 600*time.Millisecond, \"Timeout when connecting to cassandra.\")\n\tf.DurationVar(&cfg.ConnectTimeout, \"cassandra.connect-timeout\", 600*time.Millisecond, \"Initial connection timeout, used during initial dial to server.\")\n}", "func (_m *Factory) BindFlags(flags *pflag.FlagSet) {\n\t_m.Called(flags)\n}", "func (_m *Factory) BindFlags(flags *pflag.FlagSet) {\n\t_m.Called(flags)\n}", "func RegisterListenFlags() {\n\tflag.IntVar(&port, \"port\", ServerPort, \"Port to bind server component to\")\n\tflag.BoolVar(&restrictToPeers, \"restrict-to-peers\", false, \"Only allow connections from peers\")\n}", "func (cmd *AddAccountsCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request body encoded in JSON\")\n\tcc.Flags().StringVar(&cmd.ContentType, \"content\", \"\", \"Request content type override, e.g. 'application/x-www-form-urlencoded'\")\n}", "func (cmd *GetUserWorkHistoryHyUserWorkHistoryCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar userID int\n\tcc.Flags().IntVar(&cmd.UserID, \"userID\", userID, `User ID`)\n}", "func (cmd *SaveImageProjectCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar projectID int\n\tcc.Flags().IntVar(&cmd.ProjectID, \"projectId\", projectID, ``)\n}", "func (cmd *SaveMediaFieldNoteCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar stationID int\n\tcc.Flags().IntVar(&cmd.StationID, \"stationId\", stationID, ``)\n}", "func (cmd *TokenAuthCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request JSON body\")\n}", "func RegisterFlags(flags DBConfigFlag) DBConfigFlag {\n\tif flags == EmptyConfig {\n\t\tpanic(\"No DB config is provided.\")\n\t}\n\tregisteredFlags := EmptyConfig\n\tif AppConfig&flags != 0 {\n\t\tregisterConnFlags(&dbConfigs.App.ConnParams, AppConfigName, DefaultDBConfigs.App.ConnParams)\n\t\tregisteredFlags |= AppConfig\n\t}\n\tif DbaConfig&flags != 0 {\n\t\tregisterConnFlags(&dbConfigs.Dba, DbaConfigName, DefaultDBConfigs.Dba)\n\t\tregisteredFlags |= DbaConfig\n\t}\n\tif FilteredConfig&flags != 0 {\n\t\tregisterConnFlags(&dbConfigs.Filtered, FilteredConfigName, DefaultDBConfigs.Filtered)\n\t\tregisteredFlags |= FilteredConfig\n\t}\n\tif ReplConfig&flags != 0 {\n\t\tregisterConnFlags(&dbConfigs.Repl, ReplConfigName, DefaultDBConfigs.Repl)\n\t\tregisteredFlags |= ReplConfig\n\t}\n\tflag.StringVar(&dbConfigs.App.Keyspace, \"db-config-app-keyspace\", DefaultDBConfigs.App.Keyspace, \"db app connection keyspace\")\n\tflag.StringVar(&dbConfigs.App.Shard, \"db-config-app-shard\", DefaultDBConfigs.App.Shard, \"db app connection shard\")\n\treturn registeredFlags\n}", "func (cmd *GetMediaFieldNoteCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tvar mediaID int\n\tcc.Flags().IntVar(&cmd.MediaID, \"mediaId\", mediaID, ``)\n\tvar stationID int\n\tcc.Flags().IntVar(&cmd.StationID, \"stationId\", stationID, ``)\n}", "func (cmd *PlayLocationsCommand) RegisterFlags(cc *cobra.Command, c *client.Client) {\n\tcc.Flags().StringVar(&cmd.Payload, \"payload\", \"\", \"Request body encoded in JSON\")\n\tcc.Flags().StringVar(&cmd.ContentType, \"content\", \"\", \"Request content type override, e.g. 'application/x-www-form-urlencoded'\")\n\tvar id int\n\tcc.Flags().IntVar(&cmd.ID, \"id\", id, ``)\n\tvar lat string\n\tcc.Flags().StringVar(&cmd.Lat, \"lat\", lat, ``)\n\tvar long string\n\tcc.Flags().StringVar(&cmd.Long, \"long\", long, ``)\n}", "func (s *Signer) Flags() *pflag.FlagSet {\n\tif s.flags == nil {\n\t\ts.flags = pflag.NewFlagSet(s.Name, pflag.ExitOnError)\n\t}\n\treturn s.flags\n}" ]
[ "0.7010139", "0.6359649", "0.62703633", "0.62660193", "0.60479647", "0.60416174", "0.6022744", "0.60207623", "0.6005792", "0.5976918", "0.59758586", "0.59306777", "0.58929294", "0.5855352", "0.5824367", "0.58160895", "0.57945955", "0.5786991", "0.57704777", "0.5751199", "0.5724833", "0.5711548", "0.5642677", "0.5627069", "0.5624878", "0.56047773", "0.560307", "0.5595908", "0.55959016", "0.5595032", "0.55809826", "0.55685633", "0.5548085", "0.55435383", "0.5540995", "0.5522261", "0.5517821", "0.5515282", "0.5494468", "0.54823977", "0.54731315", "0.5470171", "0.546339", "0.5457246", "0.5447604", "0.5442096", "0.5436053", "0.54218113", "0.53950334", "0.5393857", "0.53879964", "0.5370621", "0.53635395", "0.535762", "0.53419083", "0.53408784", "0.53320634", "0.53046596", "0.5301702", "0.5291622", "0.5284108", "0.5279333", "0.5278669", "0.5278099", "0.52708393", "0.5264682", "0.5263158", "0.52447546", "0.52436477", "0.5237645", "0.521683", "0.52119327", "0.5210894", "0.52042776", "0.5194115", "0.5191996", "0.5188772", "0.5175485", "0.5171846", "0.5160368", "0.5151956", "0.51493657", "0.51461107", "0.514562", "0.5138239", "0.5125221", "0.5120603", "0.51033413", "0.5090784", "0.5090784", "0.5088757", "0.50831914", "0.50810826", "0.50752074", "0.50681275", "0.5060808", "0.50595874", "0.50511646", "0.50485426", "0.5045152" ]
0.675552
1
RunConfig runs the Config phase of all registered Config aware Units. Only use this function if needing to add additional wiring between config and (pre)run phases and a separate PreRunner phase is not an option. In most cases it is best to use the Run method directly as it will run the Config phase prior to executing the PreRunner and Service phases. If an error is returned the application must shut down as it is considered fatal.
func (g *Group) RunConfig() (interrupted bool, err error) { g.log = logger.GetLogger(g.name) g.configured = true if g.name == "" { // use the binary name if custom name has not been provided g.name = path.Base(os.Args[0]) } defer func() { if err != nil { g.log.Error().Err(err).Msg("unexpected exit") } }() // Load config from env and file if err = config.Load(g.f.Name, g.f.FlagSet); err != nil { return false, errors.Wrapf(err, "%s fails to load config", g.f.Name) } // bail early on help or version requests switch { case g.showRunGroup: fmt.Println(g.ListUnits()) return true, nil } // Validate Config inputs for idx := range g.c { // a Config might have been deregistered during Run if g.c[idx] == nil { g.log.Debug().Uint32("ran", uint32(idx+1)).Msg("skipping validate") continue } g.log.Debug().Str("name", g.c[idx].Name()).Uint32("ran", uint32(idx+1)).Uint32("total", uint32(len(g.c))).Msg("validate config") if vErr := g.c[idx].Validate(); vErr != nil { err = multierr.Append(err, vErr) } } // exit on at least one Validate error if err != nil { return false, err } // log binary name and version g.log.Info().Msg("started") return false, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ConfigRun(ctx *cli.Context) error {\n\topt, err := InitOption(ctx)\n\tif err != nil {\n\t\treturn xerrors.Errorf(\"option error: %w\", err)\n\t}\n\n\t// Disable OS and language analyzers\n\topt.DisabledAnalyzers = append(analyzer.TypeOSes, analyzer.TypeLanguages...)\n\n\t// Scan only config files\n\topt.VulnType = nil\n\topt.SecurityChecks = []string{types.SecurityCheckConfig}\n\n\t// Run filesystem command internally\n\treturn run(ctx.Context, opt, filesystemArtifact)\n}", "func RunForConfig(ctx context.Context, cfg Config, init func(*InitData) error) error {\n\tlogger, err := newLogger(cfg)\n\tif err != nil {\n\t\treturn err\n\t}\n\tctx, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\tlogger.Info(\"Starting server\",\n\t\tzap.String(\"network\", cfg.GetNetwork()),\n\t\tzap.String(\"address\", cfg.GetAddress()),\n\t)\n\tlistener, err := net.Listen(cfg.GetNetwork(), cfg.GetAddress())\n\tif err != nil {\n\t\treturn err\n\t}\n\ts := grpc.NewServer(grpc.UnaryInterceptor(newSecretChecker(cfg).Intercept))\n\tif err = init(&InitData{\n\t\tLogger: logger,\n\t\tServer: s,\n\t\tListener: listener,\n\t}); err != nil {\n\t\treturn err\n\t}\n\tgo func() {\n\t\t<-ctx.Done()\n\t\ts.GracefulStop()\n\t}()\n\terr = s.Serve(listener)\n\tlogger.Info(\"Server stopped\")\n\treturn err\n}", "func Run(ctx context.Context, cfg *config.Config) error {\n\tMetrics = newMetrics()\n\tdefer runCleanupHooks()\n\n\t// apply defaults before validation\n\tcfg.ApplyDefaults()\n\n\terr := cfg.Validate()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to validate config: %w\\n%+v\", err, cfg)\n\t}\n\n\tfuncMap := template.FuncMap{}\n\terr = bindPlugins(ctx, cfg, funcMap)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// if a custom Stdin is set in the config, inject it into the context now\n\tctx = data.ContextWithStdin(ctx, cfg.Stdin)\n\n\topts := optionsFromConfig(cfg)\n\topts.Funcs = funcMap\n\ttr := NewRenderer(opts)\n\n\tstart := time.Now()\n\n\tnamer := chooseNamer(cfg, tr)\n\ttmpl, err := gatherTemplates(ctx, cfg, namer)\n\tMetrics.GatherDuration = time.Since(start)\n\tif err != nil {\n\t\tMetrics.Errors++\n\t\treturn fmt.Errorf(\"failed to gather templates for rendering: %w\", err)\n\t}\n\tMetrics.TemplatesGathered = len(tmpl)\n\n\terr = tr.RenderTemplates(ctx, tmpl)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c *ConfigController) Run(threadiness int, stopCh <-chan struct{}) error {\n\tdefer func() {\n\t\tc.queue.ShutDown()\n\t}()\n\n\tglog.V(3).Infoln(\"Creating CDI config\")\n\tif _, err := CreateCDIConfig(c.client, c.cdiClientSet, c.configName); err != nil {\n\t\truntime.HandleError(err)\n\t\treturn errors.Wrap(err, \"Error creating CDI config\")\n\t}\n\n\tglog.V(3).Infoln(\"Starting config controller Run loop\")\n\tif threadiness < 1 {\n\t\treturn errors.Errorf(\"expected >0 threads, got %d\", threadiness)\n\t}\n\n\tif ok := cache.WaitForCacheSync(stopCh, c.ingressesSynced, c.routesSynced); !ok {\n\t\treturn errors.New(\"failed to wait for caches to sync\")\n\t}\n\n\tglog.V(3).Infoln(\"ConfigController cache has synced\")\n\n\tfor i := 0; i < threadiness; i++ {\n\t\tgo wait.Until(c.runWorker, time.Second, stopCh)\n\t}\n\n\tglog.Info(\"Started workers\")\n\t<-stopCh\n\tglog.Info(\"Shutting down workers\")\n\treturn nil\n}", "func (o *UninstallConfigOptions) Run() error {\n\n\terr := UninstallConfig()\n\tif err != nil {\n\t\treturn errors.Wrapf(err,\"Uninstall Config command failed.\")\n\t}\n\treturn nil\n}", "func (act *ActionConfig) Run() error {\n\t// prepre for configuration\n\t// recovery from log\n\treturn act.next()\n}", "func Run(cliCtx *cli.Context) error {\n\tc, err := config.New(cliCtx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn run(c)\n}", "func Run(a *config.Args) error {\n\tfor {\n\t\t// copy the baseline config\n\t\tcfg := *a\n\n\t\t// load the config file\n\t\tif err := fetchConfig(&cfg); err != nil {\n\t\t\tif cfg.StartupOptions.ConfigRepo != \"\" {\n\t\t\t\tlog.Errorf(\"Unable to load configuration file, waiting for 1 minute and then will try again: %v\", err)\n\t\t\t\ttime.Sleep(time.Minute)\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"unable to load configuration file: %v\", err)\n\t\t\t}\n\t\t}\n\n\t\tif err := serve(&cfg); err != nil {\n\t\t\tif cfg.StartupOptions.ConfigRepo != \"\" {\n\t\t\t\tlog.Errorf(\"Unable to initialize server likely due to bad config, waiting for 1 minute and then will try again: %v\", err)\n\t\t\t\ttime.Sleep(time.Minute)\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"unable to initialize server: %v\", err)\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Infof(\"Configuration change detected, attempting to reload configuration\")\n\t\t}\n\t}\n}", "func Run(root string) error {\n\tv1, err := readConfig()\n\tmust(err)\n\n\tvar context = runconf{\n\t\tFilterOut: v1.GetStringSlice(\"filterOut\"),\n\t\tLookFor: v1.GetStringSlice(\"lookFor\"),\n\t\trootPath: root,\n\t}\n\n\titerate(context)\n\treturn nil\n}", "func (fr *Runner) RunConfigs(cfgs ...Config) (stdout, stderr string, err error) {\n\targs := fr.argsFromConfigs(append([]Config{fr.Global}, cfgs...)...)\n\n\treturn fr.Run(args...)\n}", "func (c ConfigUnmarshalTests) Run(t *testing.T) {\n\ttestConfMaps, err := confmaptest.LoadConf(c.TestsFile)\n\trequire.NoError(t, err)\n\n\tfor _, tc := range c.Tests {\n\t\tt.Run(tc.Name, func(t *testing.T) {\n\t\t\ttestConfMap, err := testConfMaps.Sub(tc.Name)\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.NotZero(t, len(testConfMap.AllKeys()), fmt.Sprintf(\"config not found: '%s'\", tc.Name))\n\n\t\t\tcfg := newAnyOpConfig(c.DefaultConfig)\n\t\t\terr = config.UnmarshalReceiver(testConfMap, cfg)\n\n\t\t\tif tc.ExpectErr {\n\t\t\t\trequire.Error(t, err)\n\t\t\t} else {\n\t\t\t\trequire.NoError(t, err)\n\t\t\t\trequire.Equal(t, tc.Expect, cfg.Operator.Builder)\n\t\t\t}\n\t\t})\n\t}\n}", "func (manager *Manager) Run(configManagerID string, configManagerSpec string) error {\n\n\t// We dont want any reloads happening until we are fully running\n\tmanager.configReloadMutex.Lock()\n\n\tif len(configManagerID) > 0 {\n\t\tmanager.InitializeConfigurationManager(configManagerID, configManagerSpec)\n\t}\n\n\tconfiguration := config.Config{}\n\tmanager.InitializeConnectionManagers(configuration)\n\n\tlog.Println(\"Initialization of plugins done.\")\n\n\tlog.Println(\"Initializing the proxy...\")\n\tresolver := NewResolver(manager.ProviderFactories, manager, nil)\n\n\tmanager.Proxy = secretless.Proxy{\n\t\tConfig: configuration,\n\t\tEventNotifier: manager,\n\t\tResolver: resolver,\n\t\tRunHandlerFunc: manager._RunHandler,\n\t\tRunListenerFunc: manager._RunListener,\n\t}\n\n\tmanager.configReloadMutex.Unlock()\n\n\tmanager.Proxy.Run()\n\n\treturn nil\n}", "func RunConfigs() {\n\tloggingSetup()\n}", "func Run(configPath, devURL, addr string) error {\n\tcfg := new(Config)\n\tf, err := os.Open(configPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open config file: %s\", err)\n\t}\n\n\tif err := json.NewDecoder(f).Decode(cfg); err != nil {\n\t\treturn fmt.Errorf(\"failed to decode config file: %s\", err)\n\t}\n\n\tsrv, err := setupServer(cfg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to initialise server: %s\", err)\n\t}\n\n\tif err := setupAssets(devURL, srv); err != nil {\n\t\treturn err\n\t}\n\n\tlog.Println(\"Serving on\", addr)\n\n\tif err := http.ListenAndServe(addr, srv); err != nil {\n\t\treturn fmt.Errorf(\"failed to start server: %s\", err)\n\t}\n\n\treturn nil\n}", "func Run() {\n\tl := logrus.WithField(\"component\", \"main\")\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer l.Info(\"Done.\")\n\n\t// handle termination signals\n\tsignals := make(chan os.Signal, 1)\n\tsignal.Notify(signals, unix.SIGTERM, unix.SIGINT)\n\tgo func() {\n\t\ts := <-signals\n\t\tsignal.Stop(signals)\n\t\tl.Warnf(\"Got %s, shutting down...\", unix.SignalName(s.(unix.Signal)))\n\t\tcancel()\n\t}()\n\n\tfor {\n\t\tcfg, configFilepath, err := config.Get(l)\n\t\tif err != nil {\n\t\t\tl.Fatalf(\"Failed to load configuration: %s.\", err)\n\t\t}\n\t\tconfig.ConfigureLogger(cfg)\n\t\tl.Debugf(\"Loaded configuration: %+v\", cfg)\n\n\t\trun(ctx, cfg, configFilepath)\n\n\t\tif ctx.Err() != nil {\n\t\t\treturn\n\t\t}\n\t}\n}", "func (cli *ApplyConfigStepImplementation) Run(pipelineInfo *model.PipelineInfo) error {\n\t// Get radix application from config map\n\tnamespace := utils.GetAppNamespace(cli.GetAppName())\n\tconfigMap, err := cli.GetKubeutil().GetConfigMap(namespace, pipelineInfo.RadixConfigMapName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconfigFileContent, ok := configMap.Data[pipelineDefaults.PipelineConfigMapContent]\n\tif !ok {\n\t\treturn fmt.Errorf(\"failed load RadixApplication from ConfigMap\")\n\t}\n\tra, err := CreateRadixApplication(cli.GetRadixclient(), configFileContent)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Apply RA to cluster\n\tapplicationConfig, err := application.NewApplicationConfig(cli.GetKubeclient(), cli.GetKubeutil(),\n\t\tcli.GetRadixclient(), cli.GetRegistration(), ra)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = applicationConfig.ApplyConfigToApplicationNamespace()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Set back to pipeline\n\tpipelineInfo.SetApplicationConfig(applicationConfig)\n\n\tpipelineInfo.PrepareBuildContext, err = getPrepareBuildContextContent(configMap)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif pipelineInfo.PipelineArguments.PipelineType == string(v1.BuildDeploy) {\n\t\tgitCommitHash, gitTags := cli.getHashAndTags(namespace, pipelineInfo)\n\t\terr = validate.GitTagsContainIllegalChars(gitTags)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpipelineInfo.SetGitAttributes(gitCommitHash, gitTags)\n\t\tpipelineInfo.StopPipeline, pipelineInfo.StopPipelineMessage = getPipelineShouldBeStopped(pipelineInfo.PrepareBuildContext)\n\t}\n\n\treturn nil\n}", "func (cmd *GenerateConfigCommand) Run(_ context.Context) error {\n\tconf := server.NewConfig()\n\tret, err := toml.Marshal(*conf)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"unmarshaling default config\")\n\t}\n\tfmt.Fprintf(cmd.Stdout, \"%s\\n\", ret)\n\treturn nil\n}", "func (cli *CLI) Run(args []string) int {\n\n\tc, err := cli.setup(args)\n\tif err != nil {\n\t\tlogging.Error(\"unable to parse configuration: %v\", err)\n\t\treturn ExitCodeParseConfigError\n\t}\n\n\t// Set the logging level for the logger.\n\tlogging.SetLevel(c.LogLevel)\n\n\t// Initialize telemetry if this was configured by the user.\n\tif c.Telemetry.StatsdAddress != \"\" {\n\t\tsink, statsErr := metrics.NewStatsdSink(c.Telemetry.StatsdAddress)\n\t\tif statsErr != nil {\n\t\t\tlogging.Error(\"unable to setup telemetry correctly: %v\", statsErr)\n\t\t\treturn ExitCodeTelemtryError\n\t\t}\n\t\tmetrics.NewGlobal(metrics.DefaultConfig(\"replicator\"), sink)\n\t}\n\n\t// Create the initial runner with the merged configuration parameters.\n\trunner, err := NewRunner(c)\n\tif err != nil {\n\t\treturn ExitCodeRunnerError\n\t}\n\n\tlogging.Debug(\"running version %v\", version.Get())\n\tgo runner.Start()\n\n\tsignalCh := make(chan os.Signal, 1)\n\tsignal.Notify(signalCh,\n\t\tsyscall.SIGHUP,\n\t\tsyscall.SIGINT,\n\t\tsyscall.SIGTERM,\n\t\tsyscall.SIGQUIT,\n\t)\n\n\tfor {\n\t\tselect {\n\t\tcase s := <-signalCh:\n\t\t\tswitch s {\n\t\t\tcase syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT:\n\t\t\t\trunner.Stop()\n\t\t\t\treturn ExitCodeInterrupt\n\n\t\t\tcase syscall.SIGHUP:\n\t\t\t\trunner.Stop()\n\n\t\t\t\t// Reload the configuration in order to make proper use of SIGHUP.\n\t\t\t\tc, err := cli.setup(args)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn ExitCodeParseConfigError\n\t\t\t\t}\n\n\t\t\t\t// Setup a new runner with the new configuration.\n\t\t\t\trunner, err = NewRunner(c)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn ExitCodeRunnerError\n\t\t\t\t}\n\n\t\t\t\tgo runner.Start()\n\t\t\t}\n\t\t}\n\t}\n}", "func Run(ctx *cli.Context) error {\n\tc, err := NewConfig(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn run(ctx.Context, c)\n}", "func (cmd *PrintConfigCommand) Run(args ...string) error {\n\t// Parse command flags.\n\tfs := flag.NewFlagSet(\"\", flag.ContinueOnError)\n\tconfigPath := fs.String(\"config\", \"\", \"\")\n\tfs.Usage = func() {\n\t\tif _, err := fmt.Fprintln(os.Stderr, printConfigUsage); err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\t}\n\tif err := fs.Parse(args); err != nil {\n\t\treturn err\n\t}\n\n\t// Parse config from path.\n\topt := Options{ConfigPath: *configPath}\n\tconfig, err := cmd.parseConfig(opt.GetConfigPath())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"parse config: %s\", err)\n\t}\n\n\t// Validate the configuration.\n\tif err = config.Validate(); err != nil {\n\t\treturn fmt.Errorf(\"%s. To generate a valid configuration file run `emailworker config > emailworker.generated.toml`\", err)\n\t}\n\n\tif err = toml.NewEncoder(cmd.Stdout).Encode(config); err != nil {\n\t\treturn fmt.Errorf(\"error encoding toml: %s\", err)\n\t}\n\t_, err = fmt.Fprint(cmd.Stdout, \"\\n\")\n\treturn err\n}", "func (conf *Config) Run() error {\n\t// no error-checking if nothing to check errors on\n\tif conf == nil {\n\t\treturn nil\n\t}\n\tif conf.ThreadCount < 0 {\n\t\treturn fmt.Errorf(\"invalid thread count %d [must be a positive number]\", conf.ThreadCount)\n\t}\n\t// if not given other instructions, just describe the specs\n\tif !conf.Generate && !conf.Delete && conf.Verify == \"\" {\n\t\tconf.Describe = true\n\t\tconf.onlyDescribe = true\n\t}\n\tif conf.Verify != \"\" {\n\t\terr := conf.verifyType.UnmarshalText([]byte(conf.Verify))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unknown verify type '%s'\", conf.Verify)\n\t\t}\n\t} else {\n\t\t// If we're deleting, and not generating, we can skip\n\t\t// verification. Otherwise, default to erroring out if\n\t\t// there's a mismatch.\n\t\tif conf.Delete && !conf.Generate {\n\t\t\tconf.verifyType = verifyTypeNone\n\t\t} else {\n\t\t\tconf.verifyType = verifyTypeError\n\t\t}\n\t}\n\tconf.NewSpecsFiles(conf.flagset.Args())\n\tif len(conf.specFiles) < 1 {\n\t\treturn errors.New(\"must specify one or more spec files\")\n\t}\n\tif conf.ColumnScale < 0 || conf.ColumnScale > (1<<31) {\n\t\treturn fmt.Errorf(\"column scale [%d] should be between 1 and 2^31\", conf.ColumnScale)\n\t}\n\tif conf.RowScale < 0 || conf.RowScale > (1<<16) {\n\t\treturn fmt.Errorf(\"row scale [%d] should be between 1 and 2^16\", conf.RowScale)\n\t}\n\treturn nil\n}", "func initRunConfig() (*runConfig, error) {\n\t// Find the server binary for each phase\n\tpCmd := flagServerCmd\n\tif flagParseServerCmd != \"\" {\n\t\tpCmd = flagParseServerCmd\n\t}\n\tif pCmd == \"\" {\n\t\treturn nil, fmt.Errorf(\"no parse server defined\")\n\t}\n\n\tcCmd := flagServerCmd\n\tif flagCheckServerCmd != \"\" {\n\t\tcCmd = flagCheckServerCmd\n\t}\n\tif cCmd == \"\" {\n\t\treturn nil, fmt.Errorf(\"no check server defined\")\n\t}\n\n\teCmd := flagServerCmd\n\tif flagEvalServerCmd != \"\" {\n\t\teCmd = flagEvalServerCmd\n\t}\n\tif eCmd == \"\" {\n\t\treturn nil, fmt.Errorf(\"no eval server defined\")\n\t}\n\n\t// Only launch each required binary once\n\tservers := make(map[string]celrpc.ConfClient)\n\tservers[pCmd] = nil\n\tservers[cCmd] = nil\n\tservers[eCmd] = nil\n\tfor cmd := range servers {\n\t\tvar cli celrpc.ConfClient\n\t\tvar err error\n\t\tif flagPipe {\n\t\t\tcli, err = celrpc.NewPipeClient(cmd, flagPipeBase64)\n\t\t} else {\n\t\t\tcli, err = celrpc.NewGrpcClient(cmd)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tservers[cmd] = cli\n\t}\n\n\tvar rc runConfig\n\trc.parseClient = servers[pCmd]\n\trc.checkClient = servers[cCmd]\n\trc.evalClient = servers[eCmd]\n\trc.checkedOnly = flagCheckedOnly\n\trc.skipCheck = flagSkipCheck\n\treturn &rc, nil\n}", "func runConfig(cfg Config, root string) []error {\n\tfiles, err := gatherFiles(root, cfg)\n\tif err != nil {\n\t\treturn []error{fmt.Errorf(\"Failed to gather files: %w\", err)}\n\t}\n\n\tfmt.Printf(\"Scanning %d files...\\n\", len(files))\n\n\tvar wg sync.WaitGroup\n\terrs := make([]error, len(files))\n\tfor i, file := range files {\n\t\ti, file := i, file\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\terrs[i] = examine(root, file, cfg)\n\t\t}()\n\t}\n\twg.Wait()\n\n\treturn removeNilErrs(errs)\n}", "func (o *GetVaultConfigOptions) Run() error {\n\tvar vaultClient vault.Client\n\tvar err error\n\n\tif o.Name != \"\" || o.Namespace != \"\" {\n\t\tvaultClient, err = o.vaultClient(o.Name, o.Namespace)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tvaultClient, err = o.systemVaultClient()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\turl, token, err := vaultClient.Config()\n\t// Echo the client config out to the command line to be piped into bash\n\tif o.terminal == \"\" {\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\to.terminal = \"cmd\"\n\t\t} else {\n\t\t\to.terminal = \"sh\"\n\t\t}\n\t}\n\tif o.terminal == \"cmd\" {\n\t\t_, _ = fmt.Fprintf(o.Out, \"set VAULT_ADDR=%s\\nset VAULT_TOKEN=%s\\n\", url.String(), token)\n\t} else {\n\t\t_, _ = fmt.Fprintf(o.Out, \"export VAULT_ADDR=%s\\nexport VAULT_TOKEN=%s\\n\", url.String(), token)\n\t}\n\n\treturn err\n}", "func Run(appCtx app.Context) error {\n\tif err := loadConfig(&appCtx); err != nil {\n\t\treturn err\n\t}\n\tapi, err := makeAPI(appCtx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn api.Run()\n}", "func (p *Pipeline) Run(args []string) int {\n\tif err := p.LoadConfig(); err != nil {\n\t\treturn 1\n\t}\n\treturn 0\n}", "func (i *MonitorInstance) InitConfig(\n\tctx context.Context,\n\te ctxt.Executor,\n\tclusterName,\n\tclusterVersion,\n\tdeployUser string,\n\tpaths meta.DirPaths,\n) error {\n\tgOpts := *i.topo.BaseTopo().GlobalOptions\n\tif err := i.BaseInstance.InitConfig(ctx, e, gOpts, deployUser, paths); err != nil {\n\t\treturn err\n\t}\n\n\tenableTLS := gOpts.TLSEnabled\n\t// transfer run script\n\tspec := i.InstanceSpec.(*PrometheusSpec)\n\n\tcfg := &scripts.PrometheusScript{\n\t\tPort: spec.Port,\n\t\tWebExternalURL: fmt.Sprintf(\"http://%s\", utils.JoinHostPort(spec.Host, spec.Port)),\n\t\tRetention: getRetention(spec.Retention),\n\t\tEnableNG: spec.NgPort > 0,\n\n\t\tDeployDir: paths.Deploy,\n\t\tLogDir: paths.Log,\n\t\tDataDir: paths.Data[0],\n\n\t\tNumaNode: spec.NumaNode,\n\t}\n\n\tfp := filepath.Join(paths.Cache, fmt.Sprintf(\"run_prometheus_%s_%d.sh\", i.GetHost(), i.GetPort()))\n\tif err := cfg.ConfigToFile(fp); err != nil {\n\t\treturn err\n\t}\n\n\tdst := filepath.Join(paths.Deploy, \"scripts\", \"run_prometheus.sh\")\n\tif err := e.Transfer(ctx, fp, dst, false, 0, false); err != nil {\n\t\treturn err\n\t}\n\n\tif _, _, err := e.Execute(ctx, \"chmod +x \"+dst, false); err != nil {\n\t\treturn err\n\t}\n\n\ttopoHasField := func(field string) (reflect.Value, bool) {\n\t\treturn findSliceField(i.topo, field)\n\t}\n\tmonitoredOptions := i.topo.GetMonitoredOptions()\n\n\t// transfer config\n\tcfig := config.NewPrometheusConfig(clusterName, clusterVersion, enableTLS)\n\tif monitoredOptions != nil {\n\t\tcfig.AddBlackbox(i.GetHost(), uint64(monitoredOptions.BlackboxExporterPort))\n\t}\n\tcfig.ScrapeInterval = spec.ScrapeInterval\n\tcfig.ScrapeTimeout = spec.ScrapeTimeout\n\tuniqueHosts := set.NewStringSet()\n\n\tif servers, found := topoHasField(\"PDServers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tpd := servers.Index(i).Interface().(*PDSpec)\n\t\t\tuniqueHosts.Insert(pd.Host)\n\t\t\tcfig.AddPD(pd.Host, uint64(pd.ClientPort))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"TiKVServers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tkv := servers.Index(i).Interface().(*TiKVSpec)\n\t\t\tuniqueHosts.Insert(kv.Host)\n\t\t\tcfig.AddTiKV(kv.Host, uint64(kv.StatusPort))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"TiDBServers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tdb := servers.Index(i).Interface().(*TiDBSpec)\n\t\t\tuniqueHosts.Insert(db.Host)\n\t\t\tcfig.AddTiDB(db.Host, uint64(db.StatusPort))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"TiFlashServers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tflash := servers.Index(i).Interface().(*TiFlashSpec)\n\t\t\tuniqueHosts.Insert(flash.Host)\n\t\t\tcfig.AddTiFlashLearner(flash.Host, uint64(flash.FlashProxyStatusPort))\n\t\t\tcfig.AddTiFlash(flash.Host, uint64(flash.StatusPort))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"PumpServers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tpump := servers.Index(i).Interface().(*PumpSpec)\n\t\t\tuniqueHosts.Insert(pump.Host)\n\t\t\tcfig.AddPump(pump.Host, uint64(pump.Port))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"Drainers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tdrainer := servers.Index(i).Interface().(*DrainerSpec)\n\t\t\tuniqueHosts.Insert(drainer.Host)\n\t\t\tcfig.AddDrainer(drainer.Host, uint64(drainer.Port))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"CDCServers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tcdc := servers.Index(i).Interface().(*CDCSpec)\n\t\t\tuniqueHosts.Insert(cdc.Host)\n\t\t\tcfig.AddCDC(cdc.Host, uint64(cdc.Port))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"TiKVCDCServers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\ttikvCdc := servers.Index(i).Interface().(*TiKVCDCSpec)\n\t\t\tuniqueHosts.Insert(tikvCdc.Host)\n\t\t\tcfig.AddTiKVCDC(tikvCdc.Host, uint64(tikvCdc.Port))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"Monitors\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tmonitoring := servers.Index(i).Interface().(*PrometheusSpec)\n\t\t\tuniqueHosts.Insert(monitoring.Host)\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"Grafanas\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tgrafana := servers.Index(i).Interface().(*GrafanaSpec)\n\t\t\tuniqueHosts.Insert(grafana.Host)\n\t\t\tcfig.AddGrafana(grafana.Host, uint64(grafana.Port))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"Alertmanagers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\talertmanager := servers.Index(i).Interface().(*AlertmanagerSpec)\n\t\t\tuniqueHosts.Insert(alertmanager.Host)\n\t\t\tcfig.AddAlertmanager(alertmanager.Host, uint64(alertmanager.WebPort))\n\t\t}\n\t}\n\tif servers, found := topoHasField(\"Masters\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tmaster := reflect.Indirect(servers.Index(i))\n\t\t\thost, port := master.FieldByName(\"Host\").String(), master.FieldByName(\"Port\").Int()\n\t\t\tuniqueHosts.Insert(host)\n\t\t\tcfig.AddDMMaster(host, uint64(port))\n\t\t}\n\t}\n\n\tif servers, found := topoHasField(\"Workers\"); found {\n\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\tworker := reflect.Indirect(servers.Index(i))\n\t\t\thost, port := worker.FieldByName(\"Host\").String(), worker.FieldByName(\"Port\").Int()\n\t\t\tuniqueHosts.Insert(host)\n\t\t\tcfig.AddDMWorker(host, uint64(port))\n\t\t}\n\t}\n\n\tif monitoredOptions != nil {\n\t\tfor host := range uniqueHosts {\n\t\t\tcfig.AddNodeExpoertor(host, uint64(monitoredOptions.NodeExporterPort))\n\t\t\tcfig.AddBlackboxExporter(host, uint64(monitoredOptions.BlackboxExporterPort))\n\t\t\tcfig.AddMonitoredServer(host)\n\t\t}\n\t}\n\n\tremoteCfg, err := encodeRemoteCfg2Yaml(spec.RemoteConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\tcfig.SetRemoteConfig(string(remoteCfg))\n\n\t// doesn't work\n\tif _, err := i.setTLSConfig(ctx, false, nil, paths); err != nil {\n\t\treturn err\n\t}\n\n\tfor _, alertmanager := range spec.ExternalAlertmanagers {\n\t\tcfig.AddAlertmanager(alertmanager.Host, uint64(alertmanager.WebPort))\n\t}\n\tcfig.AddPushgateway(spec.PushgatewayAddrs)\n\n\tif spec.RuleDir != \"\" {\n\t\tfilter := func(name string) bool { return strings.HasSuffix(name, \".rules.yml\") }\n\t\terr := i.IteratorLocalConfigDir(ctx, spec.RuleDir, filter, func(name string) error {\n\t\t\tcfig.AddLocalRule(name)\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\treturn errors.Annotate(err, \"add local rule\")\n\t\t}\n\t}\n\n\tif err := i.installRules(ctx, e, paths.Deploy, clusterName, clusterVersion); err != nil {\n\t\treturn errors.Annotate(err, \"install rules\")\n\t}\n\n\tif err := i.initRules(ctx, e, spec, paths, clusterName); err != nil {\n\t\treturn err\n\t}\n\n\tif spec.NgPort > 0 {\n\t\tpds := []string{}\n\t\tif servers, found := topoHasField(\"PDServers\"); found {\n\t\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\t\tpd := servers.Index(i).Interface().(*PDSpec)\n\t\t\t\tpds = append(pds, fmt.Sprintf(\"\\\"%s\\\"\", utils.JoinHostPort(pd.Host, pd.ClientPort)))\n\t\t\t}\n\t\t}\n\t\tngcfg := &config.NgMonitoringConfig{\n\t\t\tClusterName: clusterName,\n\t\t\tAddress: utils.JoinHostPort(i.GetListenHost(), spec.NgPort),\n\t\t\tAdvertiseAddress: utils.JoinHostPort(i.GetHost(), spec.NgPort),\n\t\t\tPDAddrs: strings.Join(pds, \",\"),\n\t\t\tTLSEnabled: enableTLS,\n\n\t\t\tDeployDir: paths.Deploy,\n\t\t\tDataDir: paths.Data[0],\n\t\t\tLogDir: paths.Log,\n\t\t}\n\n\t\tif servers, found := topoHasField(\"Monitors\"); found {\n\t\t\tfor i := 0; i < servers.Len(); i++ {\n\t\t\t\tmonitoring := servers.Index(i).Interface().(*PrometheusSpec)\n\t\t\t\tcfig.AddNGMonitoring(monitoring.Host, uint64(monitoring.NgPort))\n\t\t\t}\n\t\t}\n\t\tfp = filepath.Join(paths.Cache, fmt.Sprintf(\"ngmonitoring_%s_%d.toml\", i.GetHost(), i.GetPort()))\n\t\tif err := ngcfg.ConfigToFile(fp); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdst = filepath.Join(paths.Deploy, \"conf\", \"ngmonitoring.toml\")\n\t\tif err := e.Transfer(ctx, fp, dst, false, 0, false); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tfp = filepath.Join(paths.Cache, fmt.Sprintf(\"prometheus_%s_%d.yml\", i.GetHost(), i.GetPort()))\n\tif err := cfig.ConfigToFile(fp); err != nil {\n\t\treturn err\n\t}\n\tif spec.AdditionalScrapeConf != nil {\n\t\terr = mergeAdditionalScrapeConf(fp, spec.AdditionalScrapeConf)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tdst = filepath.Join(paths.Deploy, \"conf\", \"prometheus.yml\")\n\tif err := e.Transfer(ctx, fp, dst, false, 0, false); err != nil {\n\t\treturn err\n\t}\n\n\treturn checkConfig(ctx, e, i.ComponentName(), i.ComponentSource(), clusterVersion, i.OS(), i.Arch(), i.ComponentName()+\".yml\", paths, nil)\n}", "func (c *Cfg) Run(args ...string) {\n\tif args == nil {\n\t\targs = os.Args[1:]\n\t}\n\tc, cmd, args, err := c.Parse(args)\n\tif err == nil {\n\t\tif err = cmd.Main(args); err == nil {\n\t\t\tExit(0)\n\t\t\treturn\n\t\t}\n\t}\n\tif err == ErrHelp {\n\t\tw := newWriter(c)\n\t\tdefer w.done(os.Stderr, 0)\n\t\tw.help()\n\t} else {\n\t\tswitch e := err.(type) {\n\t\tcase UsageError:\n\t\t\tw := newWriter(c)\n\t\t\tdefer w.done(os.Stderr, 2)\n\t\t\tw.error(string(e))\n\t\tcase ExitCode:\n\t\t\tExit(int(e))\n\t\tdefault:\n\t\t\tverb := \"%v\"\n\t\t\tif Debug {\n\t\t\t\tverb = \"%+v\"\n\t\t\t}\n\t\t\tfmt.Fprintf(os.Stderr, \"Error: \"+verb+\"\\n\", err)\n\t\t\tExit(1)\n\t\t}\n\t}\n}", "func (o *Options) Run(ctx context.Context) error {\n\tlog.Info(\"getting rest config\")\n\trestConfig, err := config.GetConfig()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Info(\"setting up manager\")\n\tmgr, err := manager.New(restConfig, manager.Options{\n\t\tScheme: kubernetes.SeedScheme,\n\t\tLeaderElection: false,\n\t\tMetricsBindAddress: \"0\", // disable for now, as we don't scrape the component\n\t\tHost: o.BindAddress,\n\t\tPort: o.Port,\n\t\tCertDir: o.ServerCertDir,\n\t\tGracefulShutdownTimeout: &gracefulShutdownTimeout,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Info(\"setting up webhook server\")\n\tserver := mgr.GetWebhookServer()\n\tserver.Register(extensioncrds.WebhookPath, &webhook.Admission{Handler: extensioncrds.New(runtimelog.Log.WithName(extensioncrds.HandlerName))})\n\tserver.Register(podschedulername.WebhookPath, &webhook.Admission{Handler: admission.HandlerFunc(podschedulername.DefaultShootControlPlanePodsSchedulerName)})\n\tserver.Register(extensionresources.WebhookPath, &webhook.Admission{Handler: extensionresources.New(runtimelog.Log.WithName(extensionresources.HandlerName), o.AllowInvalidExtensionResources)})\n\n\tlog.Info(\"starting manager\")\n\tif err := mgr.Start(ctx); err != nil {\n\t\tlog.Error(err, \"error running manager\")\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func Run(conf *config.Config) {\n\n\tvar eventHandler = ParseEventHandler(conf)\n\tcontroller.Start(conf, eventHandler)\n}", "func Run(yml load.Config) {\n\t// samplesToMerge := map[string][]interface{}{}\n\tvar samplesToMerge load.SamplesToMerge\n\tsamplesToMerge.Data = map[string][]interface{}{}\n\tload.Logrus.WithFields(logrus.Fields{\n\t\t\"name\": yml.Name,\n\t\t\"apis\": len(yml.APIs),\n\t}).Debug(\"config: processing apis\")\n\n\t// load secrets\n\t_ = loadSecrets(&yml)\n\n\t// intentionally handled synchronously\n\tfor i := range yml.APIs {\n\t\tif err := runVariableProcessor(&yml); err != nil {\n\t\t\tload.Logrus.WithError(err).Error(\"config: variable processor error\")\n\t\t}\n\t\tdataSets := FetchData(i, &yml, &samplesToMerge)\n\t\tprocessor.RunDataHandler(dataSets, &samplesToMerge, i, &yml, i)\n\t}\n\n\tload.Logrus.WithFields(logrus.Fields{\n\t\t\"name\": yml.Name,\n\t\t\"apis\": len(yml.APIs),\n\t}).Debug(\"config: finished variable processing apis\")\n\n\t// processor.ProcessSamplesToMerge(&samplesToMerge, &yml)\n\t// hren MergeAndJoin processing - replacing processor.ProcessSamplesToMerge\n\tprocessor.ProcessSamplesMergeJoin(&samplesToMerge, &yml)\n}", "func Run(config Configuration) {\n\tif err := validateConfig(&config); err != nil {\n\t\tpanic(err)\n\t}\n\n\tlog.SetOutput(os.Stdout)\n\tif config.LogFile != \"\" {\n\t\tlogFile, err := os.OpenFile(config.LogFile, os.O_CREATE|os.O_WRONLY, 0666)\n\t\tif err == nil {\n\t\t\tlog.SetOutput(logFile)\n\t\t} else {\n\t\t\tlog.Warnf(\"failed to open log file %s, using default stderr\", config.LogFile)\n\t\t}\n\t}\n\n\tif config.DevelopmentConfiguration != nil {\n\t\tif config.DevelopmentConfiguration.Enabled {\n\t\t\tlog.Debug(\"initializing development configuration\")\n\t\t\tif err := config.DevelopmentConfiguration.Init(config.Context.ParentEventID, config.Context.EventID); err != nil {\n\t\t\t\tlog.Errorf(\"%+v\", err) // non fatal error\n\t\t\t}\n\t\t}\n\t}\n\n\tmetaProvider := getMetaProvider(&config)\n\tblobProvider := getBlobProvider(&config, metaProvider)\n\teventProvider := getEventProvider(&config)\n\n\tdataPlane := &dataplane.DataPlane{\n\t\tBlobStorageProvider: blobProvider,\n\t\tDocumentStorageProvider: metaProvider,\n\t\tEventPublisher: eventProvider,\n\t}\n\n\t// TODO Refactor out below into doRun(dataPlane *dataplane.Dataplane, config Configuration)\n\n\tvalidEventTypes := strings.Split(config.ValidEventTypes, \",\")\n\n\tbaseDir := config.BaseDir\n\tif baseDir == \"\" || baseDir == \"./\" || baseDir == \".\\\\\" {\n\t\tbaseDir = getDefaultBaseDir()\n\t\tlog.Debugf(\"using default base directory %s\", baseDir)\n\t}\n\n\taction := strings.ToLower(config.Action)\n\tif config.Action == constants.Prepare {\n\t\tpreparer := preparer.NewPreparer(baseDir, config.DevelopmentConfiguration)\n\t\tdefer preparer.Close()\n\t\tif err := preparer.Prepare(config.Context, dataPlane); err != nil {\n\t\t\tpanic(fmt.Sprintf(\"error during prepration %+v\", err))\n\t\t}\n\t} else if config.Action == constants.Commit {\n\t\tcommitter := committer.NewCommitter(baseDir, config.DevelopmentConfiguration)\n\t\tdefer committer.Close()\n\t\tif err := committer.Commit(config.Context, dataPlane, validEventTypes); err != nil {\n\t\t\tpanic(fmt.Sprintf(\"error during commit %+v\", err))\n\t\t}\n\t} else {\n\t\tpanic(fmt.Sprintf(\"unsupported action type %+v\", action))\n\t}\n}", "func Run(args []string) {\n\t// Parse the arguments\n\tvar cmdCfg CmdConfig\n\tif err := parse(args, &cmdCfg); err != nil {\n\t\tlog.Errorf(\"%s\", err)\n\t\tfmt.Fprintf(os.Stderr, \"USAGE \\n\\n\\t%s\\n\\n\", os.Args[0])\n\t\tfmt.Fprint(os.Stderr, \"GLOBAL OPTIONS:\\n\\n\")\n\t\tusage(os.Stderr, &cmdCfg)\n\n\t\tos.Exit(1)\n\t}\n\n\t// set up global context for signal interuption\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\tvar stop = make(chan os.Signal)\n\tsignal.Notify(stop, syscall.SIGTERM, syscall.SIGINT)\n\tgo func() {\n\t\tsig := <-stop\n\t\tfmt.Printf(\"caught sig: %+v\\n\", sig)\n\t\tcancel()\n\t\tfmt.Println(\"Waiting up to 2 seconds to finish.\")\n\t\ttime.Sleep(2 * time.Second)\n\t\tos.Exit(0)\n\t}()\n\n\t// Global Configuration\n\t// Read deployment and service files into Kubernetes structs\n\tkubeServiceConfig, kubeServiceConfigErr := getServiceConfig(&cmdCfg)\n\tif kubeServiceConfigErr != nil {\n\t\tlog.Errorf(\"%s\", kubeServiceConfigErr)\n\t\tos.Exit(2)\n\t}\n\n\t// Regional configuration.\n\t// Gather environment variables and secret references.\n\t// Retrieve secrets from vault.\n\t// Create configmap and secret object.\n\tvar regionEnvs []*RegionEnv\n\tfor regionEnv := range createEnv(kubeServiceConfig, fetchSecrets(getConfig(ctx, &cmdCfg))) {\n\t\tlog.Debugf(\"Retrieved Configuration %+v\", regionEnv)\n\t\tif len(regionEnv.Errors) > 0 {\n\t\t\tlog.Errorf(\"%s\", regionEnv.Errors)\n\t\t\tos.Exit(2)\n\t\t}\n\t\tregionEnvs = append(regionEnvs, regionEnv)\n\t}\n\n\t// Run and monitor updates in this order.\n\tupdateFns := []UpdateFn{\n\t\tupdateConfigMapRegion,\n\t\tupdateServiceRegion,\n\t\tupdateServiceAccountRegion,\n\t\tupdateIngressRegion,\n\t\tupdateIngressRouteRegion,\n\t\tupdateGatewayRegion,\n\t\tupdateVirtualServiceRegion,\n\t\tupdateServiceInstanceRegion,\n\t\tupdateServiceBindingRegion,\n\t\tupdateNamedSecretsRegion,\n\t\tupdateDeploymentRegion,\n\t\tupdateJobRegion,\n\t\tupdateHPAutoscalerRegion,\n\t\tupdatePodDisruptionBudgetRegion,\n\t}\n\tfor _, updateFn := range updateFns {\n\t\terr := runUpdate(regionEnvs, updateFn)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"%s\", err)\n\t\t\tos.Exit(2)\n\t\t}\n\t}\n}", "func Run(settings *Settings) error {\n\tlog.Infof(\"using k8s version: %s\", settings.KubernetesVersion.String())\n\n\t// parse config\n\tlog.Infof(\"reading config from path: %s\", settings.PathConfig)\n\tconfigBytes, err := os.ReadFile(settings.PathConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\tconfig := &config{}\n\tif err := yaml.UnmarshalStrict(configBytes, &config); err != nil {\n\t\treturn errors.Wrapf(err, \"cannot parse config\")\n\t}\n\n\tfor _, j := range config.JobGroups {\n\t\tif err := processjobGroup(settings, &j); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {\n\tdefer utilruntime.HandleCrash()\n\tdefer c.workqueue.ShutDown()\n\t// Start the informer factories to begin populating the informer caches\n\tklog.Info(\"Starting Configurator controller\")\n\n\t// Wait for the caches to be synced before starting workers\n\tklog.Info(\"Waiting for informer caches to sync\")\n\tif ok := cache.WaitForCacheSync(stopCh, c.configmapsSynced, c.customConfigMapSynced); !ok {\n\t\treturn fmt.Errorf(\"failed to wait for caches to sync\")\n\t}\n\n\tklog.Info(\"Waiting for informer caches to sync\")\n\tif ok := cache.WaitForCacheSync(stopCh, c.secretSynced, c.customSecretSynced); !ok {\n\t\treturn fmt.Errorf(\"failed to wait for caches to sync\")\n\t}\n\n\tklog.Info(\"Starting workers\")\n\t// Launch two workers to process configurator resources\n\tfor i := 0; i < threadiness; i++ {\n\t\tgo wait.Until(c.runWorker, time.Second, stopCh)\n\t}\n\n\tklog.Info(\"Started workers\")\n\t<-stopCh\n\tklog.Info(\"Shutting down workers\")\n\n\treturn nil\n}", "func Run() int {\n\tpflag.Parse()\n\tpopulateAvailableKubeconfigs()\n\n\tif len(availableKubeconfigs) == 0 {\n\t\tprintKubeConfigHelpOutput()\n\t\treturn 2\n\t}\n\n\t// DEBUG\n\tfmt.Println(availableKubeconfigs)\n\treturn 0\n}", "func (p *processor) Run(_ context.Context, cfg *ucfg.Config) (err error) {\n\treturn p.Reload(cfg)\n}", "func (o *Options) Run() error {\n\terr := o.Validate()\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to validate options\")\n\t}\n\n\tconfig, err := o.LoadSourceConfig()\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to load source config\")\n\t}\n\n\tfor i := range config.Spec.Groups {\n\t\tgroup := &config.Spec.Groups[i]\n\t\tfor j := range group.Repositories {\n\t\t\trepo := &group.Repositories[j]\n\n\t\t\tif o.Filter != \"\" && !strings.Contains(repo.Name, o.Filter) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\terr := o.UpgradeRepository(config, group, repo)\n\t\t\tif err != nil {\n\t\t\t\tlog.Logger().Errorf(\"failed to upgrade repository %s due to: %s\", repo.Name, err.Error())\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (ce *MqttConfigExecutor) StartConfig(config *gateways.ConfigContext) {\n\tce.GatewayConfig.Log.Info().Str(\"config-key\", config.Data.Src).Msg(\"operating on configuration...\")\n\tm, err := parseConfig(config.Data.Config)\n\tif err != nil {\n\t\tconfig.ErrChan <- err\n\t}\n\tce.GatewayConfig.Log.Info().Str(\"config-key\", config.Data.Src).Interface(\"config-value\", *m).Msg(\"mqtt configuration\")\n\n\tgo ce.listenEvents(m, config)\n\n\tfor {\n\t\tselect {\n\t\tcase <-config.StartChan:\n\t\t\tconfig.Active = true\n\t\t\tce.GatewayConfig.Log.Info().Str(\"config-key\", config.Data.Src).Msg(\"configuration is running\")\n\n\t\tcase data := <-config.DataChan:\n\t\t\tce.GatewayConfig.DispatchEvent(&gateways.GatewayEvent{\n\t\t\t\tSrc: config.Data.Src,\n\t\t\t\tPayload: data,\n\t\t\t})\n\n\t\tcase <-config.StopChan:\n\t\t\tce.GatewayConfig.Log.Info().Str(\"config-name\", config.Data.Src).Msg(\"stopping configuration\")\n\t\t\tconfig.DoneChan <- struct{}{}\n\t\t\tce.GatewayConfig.Log.Info().Str(\"config-name\", config.Data.Src).Msg(\"configuration stopped\")\n\t\t\treturn\n\t\t}\n\t}\n}", "func (p *Plan) RunWithConfig(address string, conf *consulapi.Config) error {\n\t// Setup the client\n\tp.address = address\n\tif conf == nil {\n\t\tconf = consulapi.DefaultConfig()\n\t}\n\tconf.Address = address\n\tconf.Datacenter = p.Datacenter\n\tconf.Token = p.Token\n\tclient, err := consulapi.NewClient(conf)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to connect to agent: %v\", err)\n\t}\n\n\t// Create the logger\n\toutput := p.LogOutput\n\tif output == nil {\n\t\toutput = os.Stderr\n\t}\n\tlogger := log.New(output, \"\", log.LstdFlags)\n\n\treturn p.RunWithClientAndLogger(client, logger)\n}", "func (c *TargetConfigController) Run(workers int, stopCh <-chan struct{}) {\n\tdefer utilruntime.HandleCrash()\n\tdefer c.queue.ShutDown()\n\n\tglog.Infof(\"Starting TargetConfigController\")\n\tdefer glog.Infof(\"Shutting down TargetConfigController\")\n\n\t// doesn't matter what workers say, only start one.\n\tgo wait.Until(c.runWorker, time.Second, stopCh)\n\n\t<-stopCh\n}", "func (cmd *InitCmd) Run(f factory.Factory) error {\n\t// Check if config already exists\n\tcmd.log = f.GetLog()\n\tconfigLoader, err := f.NewConfigLoader(\"\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tconfigExists := configLoader.Exists()\n\tif configExists && !cmd.Reconfigure {\n\t\toptionNo := \"No\"\n\t\tcmd.log.WriteString(cmd.log.GetLevel(), \"\\n\")\n\t\tcmd.log.Warnf(\"%s already exists in this project\", ansi.Color(\"devspace.yaml\", \"white+b\"))\n\t\tresponse, err := cmd.log.Question(&survey.QuestionOptions{\n\t\t\tQuestion: \"Do you want to delete devspace.yaml and recreate it from scratch?\",\n\t\t\tOptions: []string{optionNo, \"Yes\"},\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif response == optionNo {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// Delete config & overwrite config\n\tos.RemoveAll(\".devspace\")\n\n\t// Delete configs path\n\tos.Remove(constants.DefaultConfigsPath)\n\n\t// Delete config & overwrite config\n\tos.Remove(constants.DefaultConfigPath)\n\n\t// Delete config & overwrite config\n\tos.Remove(constants.DefaultVarsPath)\n\n\t// Execute plugin hook\n\terr = hook.ExecuteHooks(nil, nil, \"init\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Print DevSpace logo\n\tlog.PrintLogo()\n\n\t// Determine if we're initializing from scratch, or using docker-compose.yaml\n\tdockerComposePath, generateFromDockerCompose, err := cmd.shouldGenerateFromDockerCompose()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif generateFromDockerCompose {\n\t\terr = cmd.initDockerCompose(f, dockerComposePath)\n\t} else {\n\t\terr = cmd.initDevspace(f, configLoader)\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcmd.log.WriteString(logrus.InfoLevel, \"\\n\")\n\tcmd.log.Done(\"Project successfully initialized\")\n\tcmd.log.Info(\"Configuration saved in devspace.yaml - you can make adjustments as needed\")\n\tcmd.log.Infof(\"\\r \\nYou can now run:\\n1. %s - to pick which Kubernetes namespace to work in\\n2. %s - to start developing your project in Kubernetes\\n\\nRun `%s` or `%s` to see a list of available commands and flags\\n\", ansi.Color(\"devspace use namespace\", \"blue+b\"), ansi.Color(\"devspace dev\", \"blue+b\"), ansi.Color(\"devspace -h\", \"blue+b\"), ansi.Color(\"devspace [command] -h\", \"blue+b\"))\n\n\treturn nil\n}", "func (e *Engine) Run(ctx context.Context) error {\n\tdefer e.dataStores.Close()\n\n\tfor _, cfg := range e.opts.AppConfigs {\n\t\tif err := e.initApp(ctx, cfg); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tclose(e.ready)\n\n\treturn e.run(ctx)\n}", "func (gtc *GTClient) RunWithCfg() error {\n\n\treturn nil\n}", "func (kr *KRun) LoadConfig(ctx context.Context) error {\n\terr := kr.K8SClient(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Load additional settings from env.\n\tkr.initFromEnv()\n\n\t// It is possible to have only one of the 2 mesh connector services installed\n\tif kr.XDSAddr == \"\" || kr.ProjectNumber == \"\" ||\n\t\t(kr.MeshConnectorAddr == \"\" && kr.MeshConnectorInternalAddr == \"\") {\n\t\terr := kr.loadMeshEnv(ctx)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn err\n}", "func (container *Container) Run(configPath string, projectName string, volumes map[string]types.Volume, hostsEntries []types.HostsEntry) error {\n\t// set up logging for this run\n\tcolors := util.RandomColor()\n\tourColor := color.New(colors...).SprintfFunc()\n\tlogger := log.New(os.Stdout, fmt.Sprintf(\"[%s] \", ourColor(container.Name)), log.LstdFlags)\n\tlogger.Printf(\"Running\")\n\n\t// set a result to start with\n\tvar result error\n\tresult = nil\n\n\t// check to see if we are not already running a container with this project and name\n\t// get our name\n\tname, err := rkt.GetAppName(projectName, container.Name)\n\t// get a list of running pods\n\trunningPods, err := rkt.GetRunningPods(projectName)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// a pod of our name is already running, we dont continue\n\tfor runningName, _ := range runningPods.Pods {\n\t\tif runningName == name {\n\t\t\tlogger.Printf(\"Using already running container %s for %s.\", runningName, container.Name)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\t// get our command line\n\tcommandLine, err := container.getCommandLine(projectName, runningPods, logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// prefix volumes\n\tfor _, volume := range volumes {\n\t\tcommandLine = append(volume.GenerateCommandLine(), commandLine...)\n\t}\n\n\t// prefix hostsEntries\n\tfor _, entry := range hostsEntries {\n\t\tcommandLine = append(entry.GenerateCommandLine(), commandLine...)\n\t}\n\n\t// prefix our port maps\n\tfor _, entry := range container.Ports {\n\t\t// we do this as close to execution as possible to avoid conflicts\n\t\terr = entry.SetHostPort()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcommandLine = append(entry.GenerateCommandLine(), commandLine...)\n\t}\n\n\t// prefix TODO: we want to allow settings for these\n\tcommandLine = append(strings.Split(fmt.Sprintf(\"rkt run --local-config=%s --dns=host\", configPath), \" \"), commandLine...)\n\n\tlogger.Println(commandLine)\n\t// set up our command run\n\tcommand := exec.Command(commandLine[0], commandLine[1:]...)\n\n\t// setup our state condition results\n\tstatus := make(chan error)\n\t// setup our stop channel to let state conditions know they don't need to continue, we buffer as many values as we have handlers\n\tnumHandlers := container.StateConditions.Count()\n\tstop := make(chan bool, numHandlers)\n\n\t// handle timeouts if set\n\tif container.StateConditions.Timeout != nil {\n\t\tgo container.StateConditions.Timeout.Handle(status, stop, logger)\n\t}\n\n\t// handle log monitors if set (must happen before command is started)\n\tif len(container.StateConditions.FileMonitors) > 0 {\n\t\tfor _, monitor := range container.StateConditions.FileMonitors {\n\t\t\tgo func(monitor state.FileMonitorCondition, status chan error, stop chan bool, logger *log.Logger) {\n\t\t\t\tmonitor.Handle(status, stop, logger)\n\t\t\t}(monitor, status, stop, logger)\n\t\t}\n\t}\n\n\t// we want to both monitor and print outputs so we do things a bit different for this Handler. This has to go prior to\n\t// command.Start()\n\terr = container.handleOutputs(command, status, stop, logger)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// start the command\n\terr = command.Start()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// handle exit conditions if set (must happen after the command is started)\n\tif container.StateConditions.Exit != nil {\n\t\tgo container.StateConditions.Exit.Handle(command, status, stop, logger)\n\t} else {\n\t\t// if we don't have an exit handler, we build a default one to fail on any exit\n\t\texitHandler := state.ExitCondition{\n\t\t\tCodes: []int{-1},\n\t\t\tStatus: \"success\",\n\t\t}\n\t\tgo exitHandler.Handle(command, status, stop, logger)\n\t}\n\n\t// we wait for one of our conditions to return if we have any\n\tif container.StateConditions.Count() != 0 {\n\t\tresult = <-status\n\t\t// once one condition returns, we cancel the rest\n\t\tclose(stop)\n\t\tclose(status)\n\t\t//for i := 0; i < numHandlers; i++ {\n\t\t//\tstop <- true\n\t\t//}\n\t}\n\n\treturn result\n}", "func Run(updateHandler func(updated *Config)) error {\n\tfor {\n\t\tnext := m.Next()\n\t\tnextCfg := next.(*Config)\n\t\terr := updateGlobals(nextCfg)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tupdateHandler(nextCfg)\n\t}\n}", "func Run(ctx context.Context, c *config.Config) error {\n\tdeprecatedLogger, err := util.MakeLogger(c.LogLevel, c.LogFormat)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to make logger: %w\", err)\n\t}\n\tvar logger logr.Logger = logrusr.NewLogger(deprecatedLogger)\n\n\tctrl.SetLogger(logger)\n\tsetupLog := ctrl.Log.WithName(\"setup\")\n\tsetupLog.Info(\"starting controller manager\", \"release\", Release, \"repo\", Repo, \"commit\", Commit)\n\n\tkubeconfig, err := c.GetKubeconfig()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get kubeconfig from file %q: %w\", c.KubeconfigPath, err)\n\t}\n\n\t// set \"kubernetes.io/ingress.class\" to be used by controllers (defaults to \"kong\")\n\tsetupLog.Info(`the ingress class name has been set`, \"value\", c.IngressClassName)\n\n\tscheme := runtime.NewScheme()\n\tutilruntime.Must(clientgoscheme.AddToScheme(scheme))\n\tutilruntime.Must(konghqcomv1.AddToScheme(scheme))\n\tutilruntime.Must(configurationv1alpha1.AddToScheme(scheme))\n\tutilruntime.Must(configurationv1beta1.AddToScheme(scheme))\n\n\tcontrollerOpts := ctrl.Options{\n\t\tScheme: scheme,\n\t\tMetricsBindAddress: c.MetricsAddr,\n\t\tPort: 9443,\n\t\tHealthProbeBindAddress: c.ProbeAddr,\n\t\tLeaderElection: c.EnableLeaderElection,\n\t\tLeaderElectionID: c.LeaderElectionID,\n\t}\n\n\t// determine how to configure namespace watchers\n\tif strings.Contains(c.WatchNamespace, \",\") {\n\t\tsetupLog.Info(\"manager set up with multiple namespaces\", \"namespaces\", c.WatchNamespace)\n\t\t// this mode does not set the Namespace option, so the manager will default to watching all namespaces\n\t\t// MultiNamespacedCacheBuilder imposes a filter on top of that watch to retrieve scoped resources\n\t\t// from the watched namespaces only.\n\t\tcontrollerOpts.NewCache = cache.MultiNamespacedCacheBuilder(strings.Split(c.WatchNamespace, \",\"))\n\t} else {\n\t\tcontrollerOpts.Namespace = c.WatchNamespace\n\t}\n\n\t// build the controller manager\n\tmgr, err := ctrl.NewManager(kubeconfig, controllerOpts)\n\tif err != nil {\n\t\tsetupLog.Error(err, \"unable to start manager\")\n\t\treturn err\n\t}\n\n\tkongClient, err := c.GetKongClient(ctx)\n\tif err != nil {\n\t\tsetupLog.Error(err, \"cannot create a Kong Admin API client\")\n\t\treturn err\n\t}\n\n\t// configure the kong client\n\tkongConfig := sendconfig.Kong{\n\t\tURL: c.KongAdminURL,\n\t\tFilterTags: c.FilterTags,\n\t\tConcurrency: c.Concurrency,\n\t\tClient: kongClient,\n\t\tPluginSchemaStore: util.NewPluginSchemaStore(kongClient),\n\t}\n\n\t// determine the proxy synchronization strategy\n\tsyncTickDuration, err := time.ParseDuration(fmt.Sprintf(\"%gs\", c.ProxySyncSeconds))\n\tif err != nil {\n\t\tsetupLog.Error(err, \"%s is not a valid number of seconds to stagger the proxy server synchronization\")\n\t\treturn err\n\t}\n\n\t// start the proxy cache server\n\tprx, err := proxy.NewCacheBasedProxyWithStagger(ctx,\n\t\t// NOTE: logr-based loggers use the \"logger\" field instead of \"subsystem\". When replacing logrus with logr, replace\n\t\t// WithField(\"subsystem\", ...) with WithName(...).\n\t\tdeprecatedLogger.WithField(\"subsystem\", \"proxy-cache-resolver\"),\n\t\tmgr.GetClient(),\n\t\tkongConfig,\n\t\tc.IngressClassName,\n\t\tc.EnableReverseSync,\n\t\tsyncTickDuration,\n\t\tsendconfig.UpdateKongAdminSimple,\n\t)\n\tif err != nil {\n\t\tsetupLog.Error(err, \"unable to start proxy cache server\")\n\t\treturn err\n\t}\n\n\tcontrollers := []ControllerDef{\n\t\t// ---------------------------------------------------------------------------\n\t\t// Core API Controllers\n\t\t// ---------------------------------------------------------------------------\n\n\t\t{\n\t\t\tIsEnabled: &c.ServiceEnabled,\n\t\t\tController: &configuration.CoreV1ServiceReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"Service\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tIsEnabled: &c.ServiceEnabled,\n\t\t\tController: &configuration.CoreV1EndpointsReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"Endpoints\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tIsEnabled: &c.IngressNetV1Enabled,\n\t\t\tController: &configuration.NetV1IngressReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"Ingress\").WithName(\"netv1\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t\tIngressClassName: c.IngressClassName,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tIsEnabled: &c.IngressNetV1beta1Enabled,\n\t\t\tController: &configuration.NetV1Beta1IngressReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"Ingress\").WithName(\"netv1beta1\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t\tIngressClassName: c.IngressClassName,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tIsEnabled: &c.IngressExtV1beta1Enabled,\n\t\t\tController: &configuration.ExtV1Beta1IngressReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"Ingress\").WithName(\"extv1beta1\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t\tIngressClassName: c.IngressClassName,\n\t\t\t},\n\t\t},\n\n\t\t// ---------------------------------------------------------------------------\n\t\t// Kong API Controllers\n\t\t// ---------------------------------------------------------------------------\n\n\t\t{\n\t\t\tIsEnabled: &c.UDPIngressEnabled,\n\t\t\tController: &kongctrl.KongV1Alpha1UDPIngressReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"UDPIngress\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t\tIngressClassName: c.IngressClassName,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tIsEnabled: &c.TCPIngressEnabled,\n\t\t\tController: &kongctrl.KongV1Beta1TCPIngressReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"TCPIngress\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t\tIngressClassName: c.IngressClassName,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tIsEnabled: &c.KongIngressEnabled,\n\t\t\tController: &kongctrl.KongV1KongIngressReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"KongIngress\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tIsEnabled: &c.KongClusterPluginEnabled,\n\t\t\tController: &kongctrl.KongV1KongClusterPluginReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"KongClusterPlugin\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t\tIngressClassName: c.IngressClassName,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tIsEnabled: &c.KongPluginEnabled,\n\t\t\tController: &kongctrl.KongV1KongPluginReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"KongPlugin\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tIsEnabled: &c.KongConsumerEnabled,\n\t\t\tController: &kongctrl.KongV1KongConsumerReconciler{\n\t\t\t\tClient: mgr.GetClient(),\n\t\t\t\tLog: ctrl.Log.WithName(\"controllers\").WithName(\"KongConsumer\"),\n\t\t\t\tScheme: mgr.GetScheme(),\n\t\t\t\tProxy: prx,\n\t\t\t\tIngressClassName: c.IngressClassName,\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, c := range controllers {\n\t\tif err := c.MaybeSetupWithManager(mgr); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to create controller %q: %w\", c.Name(), err)\n\t\t}\n\t}\n\n\t// BUG: kubebuilder (at the time of writing - 3.0.0-rc.1) does not allow this tag anywhere else than main.go\n\t// See https://github.com/kubernetes-sigs/kubebuilder/issues/932\n\t//+kubebuilder:scaffold:builder\n\n\tif err := mgr.AddHealthzCheck(\"health\", healthz.Ping); err != nil {\n\t\treturn fmt.Errorf(\"unable to setup healthz: %w\", err)\n\t}\n\tif err := mgr.AddReadyzCheck(\"check\", healthz.Ping); err != nil {\n\t\treturn fmt.Errorf(\"unable to setup readyz: %w\", err)\n\t}\n\n\tif c.AnonymousReports {\n\t\tsetupLog.Info(\"running anonymous reports\")\n\t\tif err := mgrutils.RunReport(ctx, kubeconfig, kongConfig, Release); err != nil {\n\t\t\tsetupLog.Error(err, \"anonymous reporting failed\")\n\t\t}\n\t} else {\n\t\tsetupLog.Info(\"anonymous reports disabled, skipping\")\n\t}\n\n\tsetupLog.Info(\"starting manager\")\n\treturn mgr.Start(ctx)\n}", "func Run(config Config, sigCh <-chan bool) error {\n\tif err := config.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\twatcher, err := newFSWatcher(pluginapi.KubeletSocket)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer watcher.Close()\n\n\tfor {\n\t\tif restart, err := runOnce(config, watcher, sigCh); err != nil {\n\t\t\treturn err\n\t\t} else if !restart {\n\t\t\treturn nil\n\t\t}\n\t}\n}", "func (e *EndComponent) Run(ctx context.Context, config *ucfg.Config) error {\n\treturn nil\n}", "func (kr *KRun) LoadConfig() *KRun {\n\n\tif kr.KSA == \"\" {\n\t\t// Same environment used for VMs\n\t\tkr.KSA = os.Getenv(\"WORKLOAD_SERVICE_ACCOUNT\")\n\t}\n\tif kr.KSA == \"\" {\n\t\tkr.KSA = \"default\"\n\t}\n\n\tif kr.Namespace == \"\" {\n\t\t// Same environment used for VMs\n\t\tkr.Namespace = os.Getenv(\"WORKLOAD_NAMESPACE\")\n\t}\n\tif kr.Name == \"\" {\n\t\tkr.Name = os.Getenv(\"WORKLOAD_NAME\")\n\t}\n\tif kr.Gateway == \"\" {\n\t\tkr.Gateway = os.Getenv(\"GATEWAY_NAME\")\n\t}\n\n\tks := os.Getenv(\"K_SERVICE\")\n\tif kr.Namespace == \"\" {\n\t\tverNsName := strings.SplitN(ks, \"--\", 2)\n\t\tif len(verNsName) > 1 {\n\t\t\tks = verNsName[1]\n\t\t\tkr.Labels[\"ver\"] = verNsName[0]\n\t\t}\n\t\tparts := strings.Split(ks, \"-\")\n\t\tkr.Namespace = parts[0]\n\t\tif len(parts) > 1 {\n\t\t\tkr.Name = parts[1]\n\t\t}\n\t}\n\n\tif kr.Namespace == \"\" {\n\t\tkr.Namespace = \"default\"\n\t}\n\tif kr.Name == \"\" {\n\t\tkr.Name = kr.Namespace\n\t}\n\n\tkr.Aud2File = map[string]string{}\n\tprefix := \".\"\n\tif os.Getuid() == 0 {\n\t\tprefix = \"\"\n\t}\n\tif kr.BaseDir == \"\" {\n\t\tkr.BaseDir = os.Getenv(\"MESH_BASE_DIR\")\n\t}\n\tif kr.BaseDir != \"\" {\n\t\tprefix = kr.BaseDir\n\t}\n\tfor _, kv := range os.Environ() {\n\t\tkvl := strings.SplitN(kv, \"=\", 2)\n\t\tif strings.HasPrefix(kvl[0], \"K8S_SECRET_\") {\n\t\t\tkr.Secrets2Dirs[kvl[0][11:]] = prefix + kvl[1]\n\t\t}\n\t\tif strings.HasPrefix(kvl[0], \"K8S_CM_\") {\n\t\t\tkr.CM2Dirs[kvl[0][7:]] = prefix + kvl[1]\n\t\t}\n\t\tif strings.HasPrefix(kvl[0], \"K8S_TOKEN_\") {\n\t\t\tkr.Aud2File[kvl[0][10:]] = prefix + kvl[1]\n\t\t}\n\t\tif strings.HasPrefix(kvl[0], \"LABEL_\") {\n\t\t\tkr.Labels[kvl[0][6:]] = prefix + kvl[1]\n\t\t}\n\t}\n\n\tif kr.TrustDomain == \"\" {\n\t\tkr.TrustDomain = os.Getenv(\"TRUST_DOMAIN\")\n\t}\n\tif kr.TrustDomain == \"\" {\n\t\tkr.TrustDomain = kr.ProjectId + \".svc.id.goog\"\n\t}\n\tkr.Aud2File[kr.TrustDomain] = prefix + \"/var/run/secrets/tokens/istio-token\"\n\tif !kr.InCluster {\n\t\tkr.Aud2File[\"api\"] = prefix + \"/var/run/secrets/kubernetes.io/serviceaccount/token\"\n\t}\n\tif kr.KSA == \"\" {\n\t\tkr.KSA = \"default\"\n\t}\n\n\tif kr.XDSAddr == \"\" {\n\t\tkr.XDSAddr = os.Getenv(\"XDS_ADDR\")\n\t}\n\t// Advanced options\n\n\t// example dns:debug\n\tkr.AgentDebug = cfg(\"XDS_AGENT_DEBUG\", \"\")\n\n\treturn kr\n}", "func ConfigAndRunApp(config *config.Configuration) {\n\tapi := new(Api)\n\tapi.Initialize(config)\n\tapi.Run(config.Address)\n}", "func (d *AlertsRouter) Run(ctx context.Context) error {\n\tfor {\n\t\tselect {\n\t\tcase <-time.After(d.adminConfigPollInterval):\n\t\t\tif err := d.SyncAndApplyConfigFromDatabase(); err != nil {\n\t\t\t\td.logger.Error(\"Unable to sync admin configuration\", \"error\", err)\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\t// Stop sending alerts to all external Alertmanager(s).\n\t\t\td.adminConfigMtx.Lock()\n\t\t\tfor orgID, s := range d.externalAlertmanagers {\n\t\t\t\tdelete(d.externalAlertmanagers, orgID) // delete before we stop to make sure we don't accept any more alerts.\n\t\t\t\ts.Stop()\n\t\t\t}\n\t\t\td.adminConfigMtx.Unlock()\n\n\t\t\treturn nil\n\t\t}\n\t}\n}", "func (ac *Config) RunConfiguration(filename string, mux *http.ServeMux, withHandlerFunctions bool) error {\n\t// Retrieve a Lua state\n\tL := ac.luapool.Get()\n\n\t// Basic system functions, like log()\n\tac.LoadBasicSystemFunctions(L)\n\n\t// If there is a database backend\n\tif ac.perm != nil {\n\n\t\t// Retrieve the userstate\n\t\tuserstate := ac.perm.UserState()\n\n\t\t// Server configuration functions\n\t\tac.LoadServerConfigFunctions(L, filename)\n\n\t\tcreator := userstate.Creator()\n\n\t\t// Simpleredis data structures (could be used for storing server stats)\n\t\tdatastruct.LoadList(L, creator)\n\t\tdatastruct.LoadSet(L, creator)\n\t\tdatastruct.LoadHash(L, creator)\n\t\tdatastruct.LoadKeyValue(L, creator)\n\n\t\t// For saving and loading Lua functions\n\t\tcodelib.Load(L, creator)\n\n\t\t// For executing PostgreSQL queries\n\t\tpquery.Load(L)\n\n\t\t// For executing MSSQL queries\n\t\tmssql.Load(L)\n\t}\n\n\t// For handling JSON data\n\tjnode.LoadJSONFunctions(L)\n\tac.LoadJFile(L, filepath.Dir(filename))\n\tjnode.Load(L)\n\n\t// Extras\n\tpure.Load(L)\n\n\t// Plugins\n\tac.LoadPluginFunctions(L, nil)\n\n\t// Cache\n\tac.LoadCacheFunctions(L)\n\n\t// Pages and Tags\n\tonthefly.Load(L)\n\n\t// HTTP Client\n\thttpclient.Load(L, ac.serverHeaderName)\n\n\tif withHandlerFunctions {\n\t\t// Lua HTTP handlers\n\t\tac.LoadLuaHandlerFunctions(L, filename, mux, false, nil, ac.defaultTheme)\n\t}\n\n\t// Run the script\n\tif err := L.DoFile(filename); err != nil {\n\t\t// Close the Lua state\n\t\tL.Close()\n\n\t\t// Logging and/or HTTP response is handled elsewhere\n\t\treturn err\n\t}\n\n\t// Only put the Lua state back if there were no errors\n\tac.luapool.Put(L)\n\n\treturn nil\n}", "func (b *Builder) InitConfig(ctx *interpolate.Context) (warnings []string, errors []error) {\n\tvar (\n\t\twarns []string\n\t\terrs []error\n\t)\n\n\twarns, errs = b.config.RemoteFileConfig.Prepare(ctx)\n\twarnings = append(warnings, warns...)\n\terrors = append(errors, errs...)\n\n\twarns, errs = b.config.ImageConfig.Prepare(ctx)\n\twarnings = append(warnings, warns...)\n\terrors = append(errors, errs...)\n\n\twarns, errs = b.config.QemuConfig.Prepare(ctx)\n\twarnings = append(warnings, warns...)\n\terrors = append(errors, errs...)\n\n\treturn warnings, errors\n}", "func Run(c *config.Config, stopCh <-chan struct{}) error {\n\tklog.Info(version.Get().Pretty())\n\tklog.Infof(\"Controller Running with additionalTolerations %v\", c.Cfg.AdditionalTolerations)\n\n\t// start a controller on instances of lb\n\tcontroller := lbcontroller.NewLoadBalancerController(c.Cfg)\n\tcontroller.Run(5, stopCh)\n\n\treturn nil\n}", "func (c *updateConfigCmd) Run(k *kong.Context, logger logging.Logger) error {\n\tlogger = logger.WithValues(\"Name\", c.Name)\n\tkubeConfig, err := ctrl.GetConfig()\n\tif err != nil {\n\t\tlogger.Debug(errKubeConfig, \"error\", err)\n\t\treturn errors.Wrap(err, errKubeConfig)\n\t}\n\tlogger.Debug(\"Found kubeconfig\")\n\tkube, err := typedclient.NewForConfig(kubeConfig)\n\tif err != nil {\n\t\tlogger.Debug(errKubeClient, \"error\", err)\n\t\treturn errors.Wrap(err, errKubeClient)\n\t}\n\tlogger.Debug(\"Created kubernetes client\")\n\tprevConf, err := kube.Configurations().Get(context.Background(), c.Name, metav1.GetOptions{})\n\tif err != nil {\n\t\terr = warnIfNotFound(err)\n\t\tlogger.Debug(\"Failed to update configuration\", \"error\", err)\n\t\treturn errors.Wrap(err, \"cannot update configuration\")\n\t}\n\tlogger.Debug(\"Found previous configuration object\")\n\tpkg := prevConf.Spec.Package\n\tpkgReference, err := name.ParseReference(pkg, name.WithDefaultRegistry(\"\"))\n\tif err != nil {\n\t\terr = warnIfNotFound(err)\n\t\tlogger.Debug(\"Failed to update configuration\", \"error\", err)\n\t\treturn errors.Wrap(err, \"cannot update configuration\")\n\t}\n\tnewPkg := \"\"\n\tif strings.HasPrefix(c.Tag, \"sha256\") {\n\t\tnewPkg = pkgReference.Context().Digest(c.Tag).Name()\n\t} else {\n\t\tnewPkg = pkgReference.Context().Tag(c.Tag).Name()\n\t}\n\tprevConf.Spec.Package = newPkg\n\treq, err := json.Marshal(prevConf)\n\tif err != nil {\n\t\terr = warnIfNotFound(err)\n\t\tlogger.Debug(\"Failed to update configuration\", \"error\", err)\n\t\treturn errors.Wrap(err, \"cannot update configuration\")\n\t}\n\tres, err := kube.Configurations().Patch(context.Background(), c.Name, types.MergePatchType, req, metav1.PatchOptions{})\n\tif err != nil {\n\t\terr = warnIfNotFound(err)\n\t\tlogger.Debug(\"Failed to update configuration\", \"error\", err)\n\t\treturn errors.Wrap(err, \"cannot update configuration\")\n\t}\n\t_, err = fmt.Fprintf(k.Stdout, \"%s/%s updated\\n\", strings.ToLower(v1.ConfigurationGroupKind), res.GetName())\n\treturn err\n}", "func (cmd *SyncCmd) Run(f factory.Factory) error {\n\tif cmd.Ctx == nil {\n\t\tvar cancelFn context.CancelFunc\n\t\tcmd.Ctx, cancelFn = context.WithCancel(context.Background())\n\t\tdefer cancelFn()\n\t}\n\n\t// Switch working directory\n\tif cmd.ConfigPath != \"\" {\n\t\t_, err := os.Stat(cmd.ConfigPath)\n\t\tif err != nil {\n\t\t\treturn errors.Errorf(\"--config is specified, but config %s cannot be loaded: %v\", cmd.GlobalFlags.ConfigPath, err)\n\t\t}\n\t}\n\n\t// Load generated config if possible\n\tvar err error\n\tvar localCache localcache.Cache\n\tlogger := f.GetLog()\n\tconfigOptions := cmd.ToConfigOptions()\n\tconfigLoader, err := f.NewConfigLoader(cmd.ConfigPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif configLoader.Exists() {\n\t\tif cmd.GlobalFlags.ConfigPath != \"\" {\n\t\t\tconfigExists, err := configLoader.SetDevSpaceRoot(logger)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t} else if !configExists {\n\t\t\t\treturn errors.New(message.ConfigNotFound)\n\t\t\t}\n\n\t\t\tlocalCache, err = configLoader.LoadLocalCache()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.Warnf(\"If you want to use the sync paths from `devspace.yaml`, use the `--config=devspace.yaml` flag for this command.\")\n\t\t}\n\t}\n\n\t// Get config with adjusted cluster config\n\tclient, err := f.NewKubeClientFromContext(cmd.KubeContext, cmd.Namespace)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"new kube client\")\n\t}\n\n\t// If the current kube context or namespace is different from old,\n\t// show warnings and reset kube client if necessary\n\tclient, err = kubectl.CheckKubeContext(client, localCache, cmd.NoWarn, cmd.SwitchContext, false, logger)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar configInterface config.Config\n\tif configLoader.Exists() && cmd.GlobalFlags.ConfigPath != \"\" {\n\t\tconfigInterface, err = configLoader.LoadWithCache(context.Background(), localCache, client, configOptions, logger)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// create the devspace context\n\tctx := devspacecontext.NewContext(cmd.Ctx, nil, logger).\n\t\tWithConfig(configInterface).\n\t\tWithKubeClient(client)\n\n\t// Execute plugin hook\n\terr = hook.ExecuteHooks(ctx, nil, \"sync\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// get image selector if specified\n\timageSelector, err := getImageSelector(ctx, configLoader, configOptions, cmd.ImageSelector)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Build params\n\toptions := targetselector.NewOptionsFromFlags(cmd.Container, cmd.LabelSelector, imageSelector, cmd.Namespace, cmd.Pod).\n\t\tWithPick(cmd.Pick).\n\t\tWithWait(cmd.Wait)\n\n\tif cmd.DownloadOnly && cmd.UploadOnly {\n\t\treturn errors.New(\"--upload-only cannot be used together with --download-only\")\n\t}\n\n\t// Create the sync config to apply\n\tsyncConfig := nameConfig{\n\t\tdevPod: &latest.DevPod{},\n\t\tsyncConfig: &latest.SyncConfig{},\n\t}\n\tif cmd.GlobalFlags.ConfigPath != \"\" && configInterface != nil {\n\t\tdevSection := configInterface.Config().Dev\n\t\tsyncConfigs := []nameConfig{}\n\t\tfor _, v := range devSection {\n\t\t\tloader.EachDevContainer(v, func(devContainer *latest.DevContainer) bool {\n\t\t\t\tfor _, s := range devContainer.Sync {\n\t\t\t\t\tn, err := fromSyncConfig(v, devContainer.Container, s)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn true\n\t\t\t\t\t}\n\t\t\t\t\tsyncConfigs = append(syncConfigs, n)\n\t\t\t\t}\n\t\t\t\treturn true\n\t\t\t})\n\t\t}\n\t\tif len(syncConfigs) == 0 {\n\t\t\treturn fmt.Errorf(\"no sync config found in %s\", cmd.GlobalFlags.ConfigPath)\n\t\t}\n\n\t\t// Check which sync config should be used\n\t\tif len(syncConfigs) > 1 {\n\t\t\t// Select syncConfig to use\n\t\t\tsyncConfigNames := []string{}\n\t\t\tfor _, sc := range syncConfigs {\n\t\t\t\tsyncConfigNames = append(syncConfigNames, sc.name)\n\t\t\t}\n\n\t\t\tanswer, err := logger.Question(&survey.QuestionOptions{\n\t\t\t\tQuestion: \"Multiple sync configurations found. Which one do you want to use?\",\n\t\t\t\tDefaultValue: syncConfigNames[0],\n\t\t\t\tOptions: syncConfigNames,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tfor idx, n := range syncConfigNames {\n\t\t\t\tif answer == n {\n\t\t\t\t\tsyncConfig = syncConfigs[idx]\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tsyncConfig = syncConfigs[0]\n\t\t}\n\t}\n\n\t// apply the flags to the empty sync config or loaded sync config from the devspace.yaml\n\tvar configImageSelector []string\n\tif syncConfig.devPod.ImageSelector != \"\" {\n\t\timageSelector, err := runtimevar.NewRuntimeResolver(ctx.WorkingDir(), true).FillRuntimeVariablesAsImageSelector(ctx.Context(), syncConfig.devPod.ImageSelector, ctx.Config(), ctx.Dependencies())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tconfigImageSelector = []string{imageSelector.Image}\n\t}\n\toptions = options.ApplyConfigParameter(syncConfig.containerName, syncConfig.devPod.LabelSelector, configImageSelector, syncConfig.devPod.Namespace, \"\")\n\toptions, err = cmd.applyFlagsToSyncConfig(syncConfig.syncConfig, options)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"apply flags to sync config\")\n\t}\n\n\t// Start sync\n\toptions = options.WithSkipInitContainers(true)\n\treturn sync.StartSyncFromCmd(ctx, targetselector.NewTargetSelector(options), syncConfig.devPod.Name, syncConfig.syncConfig, cmd.NoWatch)\n}", "func Run(m *testing.M, opts ...RunOption) {\n\t// Run tests in a separate function such that we can use deferred statements and still\n\t// (indirectly) call `os.Exit()` in case the test setup failed.\n\tif err := func() error {\n\t\tvar cfg runConfig\n\t\tfor _, opt := range opts {\n\t\t\topt(&cfg)\n\t\t}\n\n\t\tdefer mustHaveNoChildProcess()\n\t\tif !cfg.disableGoroutineChecks {\n\t\t\tdefer mustHaveNoGoroutines()\n\t\t}\n\n\t\tcleanup, err := configure()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"test configuration: %w\", err)\n\t\t}\n\t\tdefer cleanup()\n\n\t\tif cfg.setup != nil {\n\t\t\tif err := cfg.setup(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error calling setup function: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\tm.Run()\n\n\t\treturn nil\n\t}(); err != nil {\n\t\tfmt.Printf(\"%s\", err)\n\t\tos.Exit(1)\n\t}\n}", "func (c *addDutRun) Run(a subcommands.Application, args []string, env subcommands.Env) int {\n\tif err := c.innerRun(a, args, env); err != nil {\n\t\tPrintError(a.GetErr(), err)\n\t\treturn 1\n\t}\n\treturn 0\n}", "func (g *Group) Run() (err error) {\n\t// run config registration and flag parsing stages\n\tif interrupted, errRun := g.RunConfig(); interrupted || errRun != nil {\n\t\treturn errRun\n\t}\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tg.log.Fatal().Err(err).Stack().Msg(\"unexpected exit\")\n\t\t}\n\t}()\n\n\t// execute pre run stage and exit on error\n\tfor idx := range g.p {\n\t\t// a PreRunner might have been deregistered during Run\n\t\tif g.p[idx] == nil {\n\t\t\tcontinue\n\t\t}\n\t\tg.log.Debug().Uint32(\"ran\", uint32(idx+1)).Uint32(\"total\", uint32(len(g.p))).Str(\"name\", g.p[idx].Name()).Msg(\"pre-run\")\n\t\tif err := g.p[idx].PreRun(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tswg := &sync.WaitGroup{}\n\tswg.Add(len(g.s))\n\tgo func() {\n\t\tswg.Wait()\n\t\tclose(g.readyCh)\n\t}()\n\t// feed our registered services to our internal run.Group\n\tfor idx := range g.s {\n\t\t// a Service might have been deregistered during Run\n\t\ts := g.s[idx]\n\t\tif s == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tg.log.Debug().Uint32(\"total\", uint32(len(g.s))).Uint32(\"ran\", uint32(idx+1)).Str(\"name\", s.Name()).Msg(\"serve\")\n\t\tg.r.Add(func() error {\n\t\t\tnotify := s.Serve()\n\t\t\tswg.Done()\n\t\t\t<-notify\n\t\t\treturn nil\n\t\t}, func(_ error) {\n\t\t\tg.log.Debug().Uint32(\"total\", uint32(len(g.s))).Uint32(\"ran\", uint32(idx+1)).Str(\"name\", s.Name()).Msg(\"stop\")\n\t\t\ts.GracefulStop()\n\t\t})\n\t}\n\n\t// start registered services and block\n\treturn g.r.Run()\n}", "func (m *Manager) ApplyConfig(cfg *config.Config) error {\n\t// Update only if a config change is detected. If TLS configuration is\n\t// set, we have to restart the manager to make sure that new TLS\n\t// certificates are picked up.\n\tvar blankTLSConfig config_util.TLSConfig\n\tif reflect.DeepEqual(m.config, cfg.TracingConfig) && m.config.TLSConfig == blankTLSConfig {\n\t\treturn nil\n\t}\n\n\tif m.shutdownFunc != nil {\n\t\tif err := m.shutdownFunc(); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to shut down the tracer provider: %w\", err)\n\t\t}\n\t}\n\n\t// If no endpoint is set, assume tracing should be disabled.\n\tif cfg.TracingConfig.Endpoint == \"\" {\n\t\tm.config = cfg.TracingConfig\n\t\tm.shutdownFunc = nil\n\t\totel.SetTracerProvider(trace.NewNoopTracerProvider())\n\t\tlevel.Info(m.logger).Log(\"msg\", \"Tracing provider uninstalled.\")\n\t\treturn nil\n\t}\n\n\ttp, shutdownFunc, err := buildTracerProvider(context.Background(), cfg.TracingConfig)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to install a new tracer provider: %w\", err)\n\t}\n\n\tm.shutdownFunc = shutdownFunc\n\tm.config = cfg.TracingConfig\n\totel.SetTracerProvider(tp)\n\n\tlevel.Info(m.logger).Log(\"msg\", \"Successfully installed a new tracer provider.\")\n\treturn nil\n}", "func (o *ConfigCleanOption) Run(cmd *cobra.Command, args []string) (err error) {\n\tif config := getConfig(); config == nil {\n\t\tcmd.Println(\"cannot found config file\")\n\t}\n\to.Logger = cmd\n\n\titemCount := len(config.JenkinsServers)\n\tcheckResult := make(chan CheckResult, itemCount)\n\n\tfor _, jenkins := range config.JenkinsServers {\n\t\tgo func(target cfg.JenkinsServer) {\n\t\t\tcheckResult <- o.Check(target)\n\t\t}(jenkins)\n\t}\n\n\tcheckResultList := make([]CheckResult, itemCount)\n\tfor i := range config.JenkinsServers {\n\t\tcheckResultList[i] = <-checkResult\n\t}\n\n\t// do the clean work\n\terr = o.CleanByCondition(checkResultList)\n\tcmd.Println()\n\treturn\n}", "func RunRun(r *cmd.RootCMD, c *cmd.CMD) {\n\tgFlags := r.Flags.(*GlobalFlags)\n\targs := c.Args.(*RunArgs)\n\tflags := c.Flags.(*RunFlags)\n\t// Enable Debug Output\n\tif gFlags.Debug {\n\t\tlog.SetLevel(level.Debug)\n\t}\n\tlog.Debugln(\"Started usysconf\")\n\tdefer log.Debugln(\"Exiting usysconf\")\n\t// Root user check\n\tif os.Geteuid() != 0 {\n\t\tlog.Fatalln(\"You must have root privileges to run triggers\")\n\t}\n\t// Set Chroot as needed\n\tif util.IsChroot() {\n\t\tgFlags.Chroot = true\n\t}\n\t// Set Live as needed\n\tif util.IsLive() {\n\t\tgFlags.Live = true\n\t}\n\t// Load Triggers\n\ttm, err := config.LoadAll()\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to load triggers, reason: %s\\n\", err)\n\t}\n\t// If the names flag is not present, retrieve the names of the\n\t// configurations in the system and usr directories.\n\tn := args.Triggers\n\tif len(n) == 0 {\n\t\tfor k := range tm {\n\t\t\tn = append(n, k)\n\t\t}\n\t}\n\t// Establish scope of operations\n\ts := triggers.Scope{\n\t\tChroot: gFlags.Chroot,\n\t\tDebug: gFlags.Debug,\n\t\tDryRun: flags.DryRun,\n\t\tForced: flags.Force,\n\t\tLive: gFlags.Live,\n\t}\n\t// Run triggers\n\ttm.Run(s, n)\n}", "func (srv *Server) Run() error {\n\tvar err error\n\n\t// Initiate a new logger\n\tsrv.log = logrus.New()\n\tif srv.cfg.GetBool(\"debug\") {\n\t\tsrv.log.Level = logrus.DebugLevel\n\t\tsrv.log.Debug(\"Enabling Debug Logging\")\n\t}\n\tif srv.cfg.GetBool(\"trace\") {\n\t\tsrv.log.Level = logrus.TraceLevel\n\t\tsrv.log.Debug(\"Enabling Trace Logging\")\n\t}\n\tif srv.cfg.GetBool(\"disable_logging\") {\n\t\tsrv.log.Level = logrus.FatalLevel\n\t}\n\n\t// Setup Scheduler\n\tsrv.scheduler = tasks.New()\n\tdefer srv.scheduler.Stop()\n\n\t// Config Reload\n\tif srv.cfg.GetInt(\"config_watch_interval\") > 0 {\n\t\t_, err := srv.scheduler.Add(&tasks.Task{\n\t\t\tInterval: time.Duration(srv.cfg.GetInt(\"config_watch_interval\")) * time.Second,\n\t\t\tTaskFunc: func() error {\n\t\t\t\t// Reload config using Viper's Watch capabilities\n\t\t\t\terr := srv.cfg.WatchRemoteConfig()\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\t// Support hot enable/disable of debug logging\n\t\t\t\tif srv.cfg.GetBool(\"debug\") {\n\t\t\t\t\tsrv.log.Level = logrus.DebugLevel\n\t\t\t\t}\n\n\t\t\t\t// Support hot enable/disable of trace logging\n\t\t\t\tif srv.cfg.GetBool(\"trace\") {\n\t\t\t\t\tsrv.log.Level = logrus.TraceLevel\n\t\t\t\t}\n\n\t\t\t\t// Support hot enable/disable of all logging\n\t\t\t\tif srv.cfg.GetBool(\"disable_logging\") {\n\t\t\t\t\tsrv.log.Level = logrus.FatalLevel\n\t\t\t\t}\n\n\t\t\t\tsrv.log.Tracef(\"Config reloaded from Consul\")\n\t\t\t\treturn nil\n\t\t\t},\n\t\t})\n\t\tif err != nil {\n\t\t\tsrv.log.Errorf(\"Error scheduling Config watcher - %s\", err)\n\t\t}\n\t}\n\n\t// Setup the DB Connection\n\tsrv.kv, err = redis.Dial(redis.Config{\n\t\tServer: srv.cfg.GetString(\"kv_server\"),\n\t\tPassword: srv.cfg.GetString(\"kv_password\"),\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not establish database connection - %s\", err)\n\t}\n\tdefer srv.kv.Close()\n\n\t// Initialize the DB\n\terr = srv.kv.Setup()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not setup database - %s\", err)\n\t}\n\n\t// Setup the HTTP Server\n\tsrv.httpRouter = httprouter.New()\n\tsrv.httpServer = &http.Server{\n\t\tAddr: srv.cfg.GetString(\"listen_addr\"),\n\t\tHandler: srv.httpRouter,\n\t}\n\n\t// Setup TLS Configuration\n\tif srv.cfg.GetBool(\"enable_tls\") {\n\t\tsrv.httpServer.TLSConfig = &tls.Config{\n\t\t\tMinVersion: tls.VersionTLS12,\n\t\t\tCipherSuites: []uint16{\n\t\t\t\ttls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,\n\t\t\t\ttls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,\n\t\t\t},\n\t\t}\n\t}\n\n\t// Kick off Graceful Shutdown Go Routine\n\tgo func() {\n\t\t// Make the Trap\n\t\ttrap := make(chan os.Signal, 1)\n\t\tsignal.Notify(trap, syscall.SIGTERM)\n\n\t\t// Wait for a signal then action\n\t\ts := <-trap\n\t\tsrv.log.Infof(\"Received shutdown signal %s\", s)\n\n\t\t// Shutdown the HTTP Server\n\t\terr := srv.httpServer.Shutdown(context.Background())\n\t\tif err != nil {\n\t\t\tsrv.log.Errorf(\"Received errors when shutting down HTTP sessions %s\", err)\n\t\t}\n\n\t\t// Close DB Sessions\n\t\tsrv.kv.Close()\n\n\t\t// Shutdown the app via runCtx\n\t\tsrv.runCancel()\n\t}()\n\n\t// Register Health Check Handler used for Liveness checks\n\tsrv.httpRouter.GET(\"/health\", srv.middleware(srv.Health))\n\n\t// Register Health Check Handler used for Readiness checks\n\tsrv.httpRouter.GET(\"/ready\", srv.middleware(srv.Ready))\n\n\t// Register Hello World Handler\n\tsrv.httpRouter.GET(\"/hello\", srv.middleware(srv.Hello))\n\tsrv.httpRouter.POST(\"/hello\", srv.middleware(srv.SetHello))\n\tsrv.httpRouter.PUT(\"/hello\", srv.middleware(srv.SetHello))\n\n\t// Start HTTP Listener\n\tsrv.log.Infof(\"Starting Listener on %s\", srv.cfg.GetString(\"listen_addr\"))\n\tif srv.cfg.GetBool(\"enable_tls\") {\n\t\terr := srv.httpServer.ListenAndServeTLS(srv.cfg.GetString(\"cert_file\"), srv.cfg.GetString(\"key_file\"))\n\t\tif err != nil {\n\t\t\tif err == http.ErrServerClosed {\n\t\t\t\t// Wait until all outstanding requests are done\n\t\t\t\t<-srv.runCtx.Done()\n\t\t\t\treturn ErrShutdown\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\terr = srv.httpServer.ListenAndServe()\n\tif err != nil {\n\t\tif err == http.ErrServerClosed {\n\t\t\t// Wait until all outstanding requests are done\n\t\t\t<-srv.runCtx.Done()\n\t\t\treturn ErrShutdown\n\t\t}\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func Run(ctx context.Context, client *guardian.Client, config Config) (err error) {\n\tif config.Icon == nil {\n\t\tconfig.Icon = leaseui.DefaultIcon()\n\t}\n\n\trunner, err := New(client, config)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn runner.Run(ctx)\n\n\t/*\n\t\tg, ctx := errgroup.WithContext(ctx)\n\n\t\trun := func() error {\n\t\t\trunner, err := New(client, config)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn runner.Run(ctx)\n\t\t}\n\n\t\tg.Go(run)\n\t\tg.Go(run)\n\n\t\treturn g.Wait()\n\t*/\n}", "func (c *LdapChecker) Run(config v1.CanarySpec) []*pkg.CheckResult {\n\tvar results []*pkg.CheckResult\n\tfor _, conf := range config.LDAP {\n\t\tresults = append(results, c.Check(conf))\n\t}\n\treturn results\n}", "func (c *Controller) Run(stopCh <-chan struct{}) error {\n\t// Normally, we let informers start after all controllers. However, in this case we need namespaces to start and sync\n\t// first, so we have DiscoveryNamespacesFilter ready to go. This avoids processing objects that would be filtered during startup.\n\tc.namespaces.Start(stopCh)\n\t// Wait for namespace informer synced, which implies discovery filter is synced as well\n\tif !kube.WaitForCacheSync(\"namespace\", stopCh, c.namespaces.HasSynced) {\n\t\treturn fmt.Errorf(\"failed to sync namespaces\")\n\t}\n\t// run handlers for the config cluster; do not store this *Cluster in the ClusterStore or give it a SyncTimeout\n\t// this is done outside the goroutine, we should block other Run/startFuncs until this is registered\n\tconfigCluster := &Cluster{Client: c.configClusterClient, ID: c.configClusterID}\n\tc.handleAdd(configCluster, stopCh)\n\tgo func() {\n\t\tt0 := time.Now()\n\t\tlog.Info(\"Starting multicluster remote secrets controller\")\n\t\t// we need to start here when local cluster secret watcher enabled\n\t\tif features.LocalClusterSecretWatcher && features.ExternalIstiod {\n\t\t\tc.secrets.Start(stopCh)\n\t\t}\n\t\tif !kube.WaitForCacheSync(\"multicluster remote secrets\", stopCh, c.secrets.HasSynced) {\n\t\t\treturn\n\t\t}\n\t\tlog.Infof(\"multicluster remote secrets controller cache synced in %v\", time.Since(t0))\n\t\tc.queue.Run(stopCh)\n\t}()\n\treturn nil\n}", "func (c *volumeEngine) Run() (op []byte, err error) {\n\tm, err := cast.ConfigToMap(c.prepareFinalConfig())\n\tif err != nil {\n\t\treturn\n\t}\n\t// set customized config\n\tc.engine.SetConfig(m)\n\t// delegate to generic cas template engine\n\treturn c.engine.Run()\n}", "func Run(t *testing.T, configOpt core.ConfigProvider, sdkOpts ...fabsdk.Option) {\n\tsetupAndRun(t, true, configOpt, e2eTest, sdkOpts...)\n}", "func Run(c *Config, logger *zap.Logger) error {\n\tif c.Duration > 0 {\n\t\tc.Traces = 0\n\t} else if c.Traces <= 0 {\n\t\treturn fmt.Errorf(\"either `traces` or `duration` must be greater than 0\")\n\t}\n\n\twg := sync.WaitGroup{}\n\tvar running uint32 = 1\n\tfor i := 0; i < c.Workers; i++ {\n\t\twg.Add(1)\n\t\tw := worker{\n\t\t\tid: i,\n\t\t\ttraces: c.Traces,\n\t\t\tmarshal: c.Marshal,\n\t\t\tdebug: c.Debug,\n\t\t\tfirehose: c.Firehose,\n\t\t\tpause: c.Pause,\n\t\t\tduration: c.Duration,\n\t\t\trunning: &running,\n\t\t\twg: &wg,\n\t\t\tlogger: logger.With(zap.Int(\"worker\", i)),\n\t\t}\n\n\t\tgo w.simulateTraces()\n\t}\n\tif c.Duration > 0 {\n\t\ttime.Sleep(c.Duration)\n\t\tatomic.StoreUint32(&running, 0)\n\t}\n\twg.Wait()\n\treturn nil\n}", "func (i *interactor) Config(args ...string) error {\n\ti.logger.WithField(\"args\", args).Info(\"Configuring.\")\n\tif out, err := i.executor.Run(append([]string{\"config\"}, args...)...); err != nil {\n\t\treturn fmt.Errorf(\"error configuring %v: %w %v\", args, err, string(out))\n\t}\n\treturn nil\n}", "func ConfigAndRunApp(config *config.Config) {\r\n\tapp := new(App)\r\n\tapp.Initialize(config)\r\n\tapp.Run(config.ServerHost)\r\n}", "func Run(rc types.ResourceConfig) int {\n\t// Read files.\n\tf, err := readFiles()\n\tif err != nil {\n\t\tfmt.Printf(\"Failed reading files: %v\\n\", err)\n\n\t\treturn ExitError\n\t}\n\n\tc, err := prepare(f, rc)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed preparing object: %v\\n\", err)\n\n\t\treturn ExitError\n\t}\n\n\t// Calculate and print diff.\n\tfmt.Printf(\"Calculating diff...\\n\\n\")\n\n\td := cmp.Diff(c.Containers().ToExported().PreviousState, c.Containers().DesiredState())\n\n\tif d == \"\" {\n\t\tfmt.Println(\"No changes required\")\n\n\t\treturn ExitOK\n\t}\n\n\tfmt.Printf(\"Following changes required:\\n\\n%s\\n\\n\", d)\n\n\treturn deploy(c)\n}", "func (c *RunCommand) Run() error {\n\tconf, err := c.loadConfig()\n\tif err != nil {\n\t\tlog.Fatalf(\"error reading config: %s\", err)\n\t}\n\n\tmonitor := monitoring.NewMonitor(log.StandardLogger())\n\n\tsourceManager := connection.NewManager()\n\ttargetManager := connection.NewManager()\n\n\tlogBroker := broker.NewBroker(c.Workers, monitor)\n\n\tif c.Web || c.Ui {\n\t\tc.startHttp(monitor)\n\t}\n\n\tfor name, source := range conf.Sources {\n\t\tswitch source.Provider {\n\t\tcase \"dummy\":\n\t\t\tsourceManager.AddConnection(name, &dummy.Source{})\n\t\tcase \"nomad\":\n\t\t\tsourceManager.AddConnection(name, &nomad.Source{\n\t\t\t\tConfig: source.Config,\n\t\t\t\tConsulAddr: c.Consul,\n\t\t\t})\n\t\t}\n\t}\n\n\tfor name, target := range conf.Targets {\n\t\tswitch target.Provider {\n\t\tcase \"blackhole\":\n\t\t\ttargetManager.AddConnection(name, &blackhole.Target{})\n\t\tcase \"stdout\":\n\t\t\ttargetManager.AddConnection(name, &stdout.Target{})\n\t\tcase \"logzio\":\n\t\t\ttargetManager.AddConnection(name, &logzio.Target{\n\t\t\t\tConfig: target.Config,\n\t\t\t})\n\t\t}\n\t}\n\n\terr = c.startProcesses(conf, sourceManager, targetManager, logBroker)\n\tif err != nil {\n\t\tlog.Fatalf(\"error starting processes: %s\", err)\n\t}\n\n\treturn nil\n}", "func Run(rpcCfg RPCConfig) error {\n\tconfig := DefaultConfig()\n\n\t// Parse command line flags.\n\tparser := flags.NewParser(&config, flags.Default)\n\tparser.SubcommandsOptional = true\n\n\t_, err := parser.Parse()\n\tif e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp {\n\t\treturn nil\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Parse ini file.\n\tloopDir := lncfg.CleanAndExpandPath(config.LoopDir)\n\tconfigFile := lncfg.CleanAndExpandPath(config.ConfigFile)\n\n\t// If our loop directory is set and the config file parameter is not\n\t// set, we assume that they want to point to a config file in their\n\t// loop dir. However, if the config file has a non-default value, then\n\t// we leave the config parameter as its custom value.\n\tif loopDir != loopDirBase && configFile == defaultConfigFile {\n\t\tconfigFile = filepath.Join(\n\t\t\tloopDir, defaultConfigFilename,\n\t\t)\n\t}\n\n\tif err := flags.IniParse(configFile, &config); err != nil {\n\t\t// If it's a parsing related error, then we'll return\n\t\t// immediately, otherwise we can proceed as possibly the config\n\t\t// file doesn't exist which is OK.\n\t\tif _, ok := err.(*flags.IniError); ok {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Parse command line flags again to restore flags overwritten by ini\n\t// parse.\n\t_, err = parser.Parse()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Show the version and exit if the version flag was specified.\n\tappName := filepath.Base(os.Args[0])\n\tappName = strings.TrimSuffix(appName, filepath.Ext(appName))\n\tif config.ShowVersion {\n\t\tfmt.Println(appName, \"version\", loop.Version())\n\t\tos.Exit(0)\n\t}\n\n\t// Special show command to list supported subsystems and exit.\n\tif config.DebugLevel == \"show\" {\n\t\tfmt.Printf(\"Supported subsystems: %v\\n\",\n\t\t\tlogWriter.SupportedSubsystems())\n\t\tos.Exit(0)\n\t}\n\n\t// Validate our config before we proceed.\n\tif err := Validate(&config); err != nil {\n\t\treturn err\n\t}\n\n\t// Initialize logging at the default logging level.\n\terr = logWriter.InitLogRotator(\n\t\tfilepath.Join(config.LogDir, defaultLogFilename),\n\t\tconfig.MaxLogFileSize, config.MaxLogFiles,\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = build.ParseAndSetDebugLevels(config.DebugLevel, logWriter)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Print the version before executing either primary directive.\n\tlog.Infof(\"Version: %v\", loop.Version())\n\n\tlisCfg := newListenerCfg(&config, rpcCfg)\n\n\t// Execute command.\n\tif parser.Active == nil {\n\t\tsignal.Intercept()\n\n\t\tdaemon := New(&config, lisCfg)\n\t\tif err := daemon.Start(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tselect {\n\t\tcase <-signal.ShutdownChannel():\n\t\t\tlog.Infof(\"Received SIGINT (Ctrl+C).\")\n\t\t\tdaemon.Stop()\n\n\t\t\t// The above stop will return immediately. But we'll be\n\t\t\t// notified on the error channel once the process is\n\t\t\t// complete.\n\t\t\treturn <-daemon.ErrChan\n\n\t\tcase err := <-daemon.ErrChan:\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif parser.Active.Name == \"view\" {\n\t\treturn view(&config, lisCfg)\n\t}\n\n\treturn fmt.Errorf(\"unimplemented command %v\", parser.Active.Name)\n}", "func InitConfig(configName string) func() {\n\treturn func() {\n\t\tConfig.ConfigFile = viper.GetString(ConfigFile) // enable ability to specify config file via flag\n\t\tConfig.ConfigDir = viper.GetString(ConfigDir)\n\t\tviper.SetEnvPrefix(\"cilium\")\n\n\t\t// INFO: 启动时候用的 --config-dir=/tmp/cilium/config-map, 每一个文件名 filename 是 key,文件内容是 value\n\t\tif Config.ConfigDir != \"\" {\n\t\t\tif _, err := os.Stat(Config.ConfigDir); os.IsNotExist(err) {\n\t\t\t\tlog.Fatalf(\"Non-existent configuration directory %s\", Config.ConfigDir)\n\t\t\t}\n\n\t\t\tif m, err := ReadDirConfig(Config.ConfigDir); err != nil {\n\t\t\t\tlog.Fatalf(\"Unable to read configuration directory %s: %s\", Config.ConfigDir, err)\n\t\t\t} else {\n\t\t\t\terr := MergeConfig(m)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Fatalf(\"Unable to merge configuration: %s\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif Config.ConfigFile != \"\" {\n\t\t\tviper.SetConfigFile(Config.ConfigFile)\n\t\t} else {\n\t\t\tviper.SetConfigName(configName) // name of config file (without extension)\n\t\t\tviper.AddConfigPath(\"$HOME\") // adding home directory as first search path\n\t\t}\n\n\t\t// If a config file is found, read it in.\n\t\tif err := viper.ReadInConfig(); err == nil {\n\t\t\tlog.WithField(logfields.Path, viper.ConfigFileUsed()).\n\t\t\t\tInfo(\"Using config from file\")\n\t\t} else if Config.ConfigFile != \"\" {\n\t\t\tlog.WithField(logfields.Path, Config.ConfigFile).\n\t\t\t\tFatal(\"Error reading config file\")\n\t\t} else {\n\t\t\tlog.WithField(logfields.Reason, err).Info(\"Skipped reading configuration file\")\n\t\t}\n\t}\n}", "func Run(ctx app.Context) {\n\t// //////////////////////////////////////////////////////////////////////\n\t// Config and command line\n\t// //////////////////////////////////////////////////////////////////////\n\n\t// Options are set in this order: config -> env var -> cmd line option.\n\t// So first we must apply config files, then do cmd line parsing which\n\t// will apply env vars and cmd line options.\n\n\t// Parse cmd line to get --config files\n\tcmdLine := config.ParseCommandLine(config.Options{})\n\n\t// --config files override defaults if given\n\tconfigFiles := config.DEFAULT_CONFIG_FILES\n\tif cmdLine.Config != \"\" {\n\t\tconfigFiles = cmdLine.Config\n\t}\n\n\t// Parse default options from config files\n\tdef := config.ParseConfigFiles(configFiles, cmdLine.Debug)\n\n\t// Parse env vars and cmd line options, override default config\n\tcmdLine = config.ParseCommandLine(def)\n\n\t// Final options and commands\n\tvar o config.Options = cmdLine.Options\n\tvar c config.Command = cmdLine.Command\n\tif o.Debug {\n\t\tapp.Debug(\"command: %#v\\n\", c)\n\t\tapp.Debug(\"options: %#v\\n\", o)\n\t}\n\n\tif ctx.Hooks.AfterParseOptions != nil {\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"calling hook AfterParseOptions\")\n\t\t}\n\t\tctx.Hooks.AfterParseOptions(&o)\n\n\t\t// Dump options again to see if hook changed them\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"options: %#v\\n\", o)\n\t\t}\n\t}\n\tctx.Options = o\n\tctx.Command = c\n\n\t// //////////////////////////////////////////////////////////////////////\n\t// Help and version\n\t// //////////////////////////////////////////////////////////////////////\n\n\t// Help uses a Request Manager client to fetch the list of all requests.\n\t// If addr is set, then this works; else, ignore and always print help.\n\trmc, _ := makeRMC(&ctx)\n\n\t// spinc with no args (Args[0] = \"spinc\" itself). Print short request help\n\t// because Ryan is very busy.\n\tif len(os.Args) == 1 {\n\t\tconfig.Help(false, rmc)\n\t\tos.Exit(0)\n\t}\n\n\t// spinc --help or spinc help (full help)\n\tif o.Help || (c.Cmd == \"help\" && len(c.Args) == 0) {\n\t\tconfig.Help(true, rmc)\n\t\tos.Exit(0)\n\t}\n\n\t// spinc help <command>\n\tif c.Cmd == \"help\" && len(c.Args) > 0 {\n\t\t// Need rm client for this\n\t\tif rmc == nil {\n\t\t\tvar err error\n\t\t\trmc, err = makeRMC(&ctx)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintln(os.Stderr, err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t}\n\t\treqName := c.Args[0]\n\t\tif err := config.RequestHelp(reqName, rmc); err != nil {\n\t\t\tswitch err {\n\t\t\tcase config.ErrUnknownRequest:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Unknown request: %s. Run spinc (no arguments) to list all requests.\\n\", reqName)\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"API error: %s. Use --ping to test the API connection.\\n\", err)\n\t\t\t}\n\t\t\tos.Exit(1)\n\t\t}\n\t\tos.Exit(0)\n\t}\n\n\t// spinc --version or spinc version\n\tif o.Version || c.Cmd == \"version\" {\n\t\tfmt.Println(\"spinc v0.0.0\")\n\t\tos.Exit(0)\n\t}\n\n\t// //////////////////////////////////////////////////////////////////////\n\t// Request Manager Client\n\t// //////////////////////////////////////////////////////////////////////\n\tif rmc == nil {\n\t\tvar err error\n\t\trmc, err = makeRMC(&ctx)\n\t\tif err != nil {\n\t\t\tfmt.Fprintln(os.Stderr, err)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\t// //////////////////////////////////////////////////////////////////////\n\t// Ping\n\t// //////////////////////////////////////////////////////////////////////\n\tif o.Ping {\n\t\tif _, err := rmc.RequestList(); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Ping failed: %s\\n\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tfmt.Printf(\"%s OK\\n\", o.Addr)\n\t\tos.Exit(0)\n\t}\n\n\t// //////////////////////////////////////////////////////////////////////\n\t// Commands\n\t// //////////////////////////////////////////////////////////////////////\n\tcmdFactory := &cmd.DefaultFactory{}\n\n\tvar err error\n\tvar run app.Command\n\tif ctx.Factories.Command != nil {\n\t\trun, err = ctx.Factories.Command.Make(c.Cmd, ctx)\n\t\tif err != nil {\n\t\t\tswitch err {\n\t\t\tcase cmd.ErrNotExist:\n\t\t\t\tif o.Debug {\n\t\t\t\t\tapp.Debug(\"user cmd factory cannot make a %s cmd, trying default factory\", c.Cmd)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"User command factory error: %s\\n\", err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t}\n\t}\n\tif run == nil {\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"using default factory to make a %s cmd\", c.Cmd)\n\t\t}\n\t\trun, err = cmdFactory.Make(c.Cmd, ctx)\n\t\tif err != nil {\n\t\t\tswitch err {\n\t\t\tcase cmd.ErrNotExist:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Unknown command: %s. Run 'spinc help' to list commands.\\n\", c.Cmd)\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Command factory error: %s\\n\", err)\n\t\t\t}\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\tif err := run.Prepare(); err != nil {\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"%s Prepare error: %s\", c.Cmd, err)\n\t\t}\n\t\tswitch err {\n\t\tcase config.ErrUnknownRequest:\n\t\t\treqName := c.Args[0]\n\t\t\tfmt.Fprintf(os.Stderr, \"Unknown request: %s. Run spinc (no arguments) to list all requests.\\n\", reqName)\n\t\tdefault:\n\t\t\tfmt.Fprintln(os.Stderr, err)\n\t\t}\n\t\tos.Exit(1)\n\t}\n\n\tif err := run.Run(); err != nil {\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"%s Run error: %s\", c.Cmd, err)\n\t\t}\n\t\tfmt.Fprintln(os.Stderr, err)\n\t\tos.Exit(1)\n\t}\n}", "func (a *Agent) Run(shutdown chan struct{}) error {\n\tvar wg sync.WaitGroup\n\n\tlog.Printf(\"INFO Agent Config: Interval:%s, Hostname:%#v, Flush Interval:%s \\n\",\n\t\ta.Config.Agent.Interval, a.Config.Agent.Hostname, a.Config.Agent.FlushInterval)\n\n\t// configure all sources\n\tfor _, source := range a.Config.Sources {\n\t\tsource.SetDefaultTags(a.Config.Tags)\n\t}\n\n\t// Start all ServiceSources\n\tfor _, source := range a.Config.Sources {\n\t\tswitch p := source.Source.(type) {\n\t\tcase optic.ServiceSource:\n\t\t\tacc := NewAccumulator(source, source.EventsCh())\n\t\t\tif err := p.Start(acc); err != nil {\n\t\t\t\tlog.Printf(\"ERROR Service for source %s failed to start, exiting\\n%s\\n\",\n\t\t\t\t\tsource.Name(), err.Error())\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdefer p.Stop()\n\t\t}\n\t}\n\n\twg.Add(len(a.Config.Sources))\n\tfor _, source := range a.Config.Sources {\n\t\tinterval := a.Config.Agent.Interval\n\t\t// overwrite global interval if this plugin has it's own\n\t\tif source.Config.Interval != 0 {\n\t\t\tinterval = source.Config.Interval\n\t\t}\n\t\tgo func(source *models.RunningSource, interval time.Duration) {\n\t\t\tdefer wg.Done()\n\t\t\ta.gatherer(shutdown, source, interval)\n\t\t}(source, interval)\n\t}\n\n\twg.Wait()\n\ta.Close()\n\treturn nil\n}", "func (m *Manager) ApplyConfig(cfg map[string]sd_config.ServiceDiscoveryConfig) error {\n\tm.mtx.Lock()\n\tdefer m.mtx.Unlock()\n\n\tm.cancelDiscoverers()\n\tfor name, scfg := range cfg {\n\t\tfor provName, prov := range m.providersFromConfig(scfg) {\n\t\t\tm.startProvider(m.ctx, poolKey{setName: name, provider: provName}, prov)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Run(name string, initFunc Init, opts ...BinaryOpts) {\n\tvar config Config\n\tfor _, o := range opts {\n\t\to(&config)\n\t}\n\n\tctx := context.Background()\n\tctx = log.WithLogger(ctx, log.G(ctx).WithField(\"runtime\", name))\n\n\tif err := run(ctx, nil, initFunc, name, config); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"%s: %s\", name, err)\n\t\tos.Exit(1)\n\t}\n}", "func (s *Sinker) Run() {\n\tvar err error\n\tvar newCfg *config.Config\n\tdefer func() {\n\t\ts.stopped <- struct{}{}\n\t}()\n\tif cmdOps.PushGatewayAddrs != \"\" {\n\t\taddrs := strings.Split(cmdOps.PushGatewayAddrs, \",\")\n\t\ts.pusher = statistics.NewPusher(addrs, cmdOps.PushInterval, httpAddr)\n\t\tif err = s.pusher.Init(); err != nil {\n\t\t\treturn\n\t\t}\n\t\tgo s.pusher.Run()\n\t}\n\tif s.rcm == nil {\n\t\tif _, err = os.Stat(cmdOps.LocalCfgFile); err == nil {\n\t\t\tif newCfg, err = config.ParseLocalCfgFile(cmdOps.LocalCfgFile); err != nil {\n\t\t\t\tutil.Logger.Fatal(\"config.ParseLocalCfgFile failed\", zap.Error(err))\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tutil.Logger.Fatal(\"expect --local-cfg-file or --nacos-dataid\")\n\t\t\treturn\n\t\t}\n\t\tif err = newCfg.Normallize(); err != nil {\n\t\t\tutil.Logger.Fatal(\"newCfg.Normallize failed\", zap.Error(err))\n\t\t\treturn\n\t\t}\n\t\tif err = s.applyConfig(newCfg); err != nil {\n\t\t\tutil.Logger.Fatal(\"s.applyConfig failed\", zap.Error(err))\n\t\t\treturn\n\t\t}\n\t\t<-s.ctx.Done()\n\t} else {\n\t\tif cmdOps.NacosServiceName != \"\" {\n\t\t\tgo s.rcm.Run()\n\t\t}\n\t\t// Golang <-time.After() is not garbage collected before expiry.\n\t\tticker := time.NewTicker(10 * time.Second)\n\t\tdefer ticker.Stop()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-s.ctx.Done():\n\t\t\t\tutil.Logger.Info(\"Sinker.Run quit due to context has been canceled\")\n\t\t\t\treturn\n\t\t\tcase <-ticker.C:\n\t\t\t\tif newCfg, err = s.rcm.GetConfig(); err != nil {\n\t\t\t\t\tutil.Logger.Error(\"s.rcm.GetConfig failed\", zap.Error(err))\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif err = newCfg.Normallize(); err != nil {\n\t\t\t\t\tutil.Logger.Error(\"newCfg.Normallize failed\", zap.Error(err))\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif err = s.applyConfig(newCfg); err != nil {\n\t\t\t\t\tutil.Logger.Error(\"s.applyConfig failed\", zap.Error(err))\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func Run(ctx context.Context, conf Config) error {\n\tsrv := New(ctx, conf)\n\treturn srv.Run()\n}", "func TestConfig(t *testing.T) {\n\t// Register gomega fail handler\n\tRegisterFailHandler(Fail)\n\n\t// Have go's testing package run package specs\n\tRunSpecs(t, \"go-utils suite\")\n}", "func (c *ConverterController) Run(ctx context.Context, group *errgroup.Group, cfg *conf.BaseOperatorConf) {\n\n\tif cfg.EnabledPrometheusConverter.ServiceScrape {\n\t\tgroup.Go(func() error {\n\t\t\treturn c.runInformerWithDiscovery(ctx, v1.SchemeGroupVersion.String(), v1.ServiceMonitorsKind, c.serviceInf.Run)\n\t\t})\n\n\t}\n\tif cfg.EnabledPrometheusConverter.PodMonitor {\n\t\tgroup.Go(func() error {\n\t\t\treturn c.runInformerWithDiscovery(ctx, v1.SchemeGroupVersion.String(), v1.PodMonitorsKind, c.podInf.Run)\n\t\t})\n\n\t}\n\tif cfg.EnabledPrometheusConverter.PrometheusRule {\n\t\tgroup.Go(func() error {\n\t\t\treturn c.runInformerWithDiscovery(ctx, v1.SchemeGroupVersion.String(), v1.PrometheusRuleKind, c.ruleInf.Run)\n\t\t})\n\n\t}\n}", "func Run(cfg RunnerConfig) {\n\tif cfg.LogOutput == nil {\n\t\tcfg.LogOutput = os.Stdout\n\t}\n\tlog.NewLogger(cfg.LogLevel, cfg.LogOutput)\n\tserver.Run()\n}", "func NewForConfig(ctx context.Context, runCtx *runcontext.RunContext) (*SkaffoldRunner, error) {\n\tevent.InitializeState(runCtx)\n\tevent.LogMetaEvent()\n\teventV2.InitializeState(runCtx)\n\teventV2.LogMetaEvent()\n\t_, endTrace := instrumentation.StartTrace(context.Background(), \"NewForConfig\")\n\tdefer endTrace()\n\n\ttagger, err := tag.NewTaggerMux(runCtx)\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"creating tagger: %w\", err)\n\t}\n\n\tstore := build.NewArtifactStore()\n\tg := graph.ToArtifactGraph(runCtx.Artifacts())\n\tsourceDependencies := graph.NewSourceDependenciesCache(runCtx, store, g)\n\n\tisLocalImage := func(imageName string) (bool, error) {\n\t\treturn isImageLocal(runCtx, imageName)\n\t}\n\n\t// Always add skaffold-specific labels, except during `skaffold render`\n\tlabeller := label.NewLabeller(runCtx.AddSkaffoldLabels(), runCtx.CustomLabels(), runCtx.GetRunID())\n\ttester, err := getTester(ctx, runCtx, isLocalImage)\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"creating tester: %w\", err)\n\t}\n\n\tvar deployer deploy.Deployer\n\n\thydrationDir, err := util.GetHydrationDir(runCtx.Opts, runCtx.WorkingDir, true, isKptRendererOrDeployerUsed(runCtx.Pipelines))\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting render output path: %w\", err)\n\t}\n\n\trenderer, err := GetRenderer(ctx, runCtx, hydrationDir, labeller.Labels(), runCtx.UsingLegacyHelmDeploy())\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"creating renderer: %w\", err)\n\t}\n\n\tdeployer, err = GetDeployer(ctx, runCtx, labeller, hydrationDir, runCtx.UsingLegacyHelmDeploy())\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"creating deployer: %w\", err)\n\t}\n\trOpts := platform.ResolverOpts{\n\t\tKubeContext: runCtx.KubeContext,\n\t\tCliPlatformsSelection: runCtx.Opts.Platforms,\n\t\tCheckClusterNodePlatforms: runCtx.CheckClusterNodePlatforms(),\n\t\tDisableMultiPlatformBuild: runCtx.DisableMultiPlatformBuild(),\n\t}\n\n\tplatforms, err := platform.NewResolver(ctx, runCtx.Pipelines.All(), rOpts)\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"getting target platforms: %w\", err)\n\t}\n\n\tvar verifier verify.Verifier\n\tverifier, err = GetVerifier(ctx, runCtx, labeller)\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"creating verifier: %w\", err)\n\t}\n\n\tvar acsRunner ActionsRunner\n\tacsRunner, err = GetActionsRunner(ctx, runCtx, labeller, runCtx.VerifyDockerNetwork(), runCtx.Opts.VerifyEnvFile)\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"creating actiosn runner: %w\", err)\n\t}\n\n\tdepLister := func(ctx context.Context, artifact *latest.Artifact) ([]string, error) {\n\t\tctx, endTrace := instrumentation.StartTrace(ctx, \"NewForConfig_depLister\")\n\t\tdefer endTrace()\n\n\t\tbuildDependencies, err := sourceDependencies.SingleArtifactDependencies(ctx, artifact)\n\t\tif err != nil {\n\t\t\tendTrace(instrumentation.TraceEndError(err))\n\t\t\treturn nil, err\n\t\t}\n\n\t\ttestDependencies, err := tester.TestDependencies(ctx, artifact)\n\t\tif err != nil {\n\t\t\tendTrace(instrumentation.TraceEndError(err))\n\t\t\treturn nil, err\n\t\t}\n\t\treturn append(buildDependencies, testDependencies...), nil\n\t}\n\n\tartifactCache, err := cache.NewCache(ctx, runCtx, isLocalImage, depLister, g, store)\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"initializing cache: %w\", err)\n\t}\n\t// The Builder must be instantiated AFTER the Deployer, because the Deploy target influences\n\t// the Cluster object on the RunContext, which in turn influences whether or not we will push images.\n\tvar builder build.Builder\n\tbuilder, err = build.NewBuilderMux(runCtx, store, artifactCache, func(p latest.Pipeline) (build.PipelineBuilder, error) {\n\t\treturn GetBuilder(ctx, runCtx, store, sourceDependencies, p)\n\t})\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"creating builder: %w\", err)\n\t}\n\n\tbuilder, tester, renderer, deployer = WithTimings(builder, tester, renderer, deployer, runCtx.CacheArtifacts())\n\tif runCtx.Notification() {\n\t\tdeployer = WithNotification(deployer)\n\t}\n\n\tmonitor := filemon.NewMonitor()\n\tintents, intentChan := setupIntents(runCtx)\n\trtrigger, err := trigger.NewTrigger(runCtx, intents.IsAnyAutoEnabled)\n\tif err != nil {\n\t\tendTrace(instrumentation.TraceEndError(err))\n\t\treturn nil, fmt.Errorf(\"creating watch trigger: %w\", err)\n\t}\n\n\trbuilder := NewBuilder(builder, tagger, platforms, artifactCache, runCtx)\n\treturn &SkaffoldRunner{\n\t\tBuilder: *rbuilder,\n\t\tPruner: Pruner{Builder: builder},\n\t\trenderer: renderer,\n\t\ttester: tester,\n\t\tdeployer: deployer,\n\t\tplatforms: platforms,\n\t\tmonitor: monitor,\n\t\tlistener: NewSkaffoldListener(monitor, rtrigger, sourceDependencies, intentChan),\n\t\tartifactStore: store,\n\t\tsourceDependencies: sourceDependencies,\n\t\tlabeller: labeller,\n\t\tcache: artifactCache,\n\t\trunCtx: runCtx,\n\t\tintents: intents,\n\t\tisLocalImage: isLocalImage,\n\t\tverifier: verifier,\n\t\tactionsRunner: acsRunner,\n\t}, nil\n}", "func (o *Orchestrator) Run() {\n\tv := newValidator(o.Plugin)\n\tm := newMetrics(o.healthzPath, o.healthzPort, o.metricsPath, o.metricsPort)\n\n\tv.mustValidatePrerequisites()\n\n\to.mustServeKMSRequests()\n\n\t// Giving some time for kmsPlugin to start Serving.\n\t// TODO: Must be a better way than to sleep.\n\ttime.Sleep(3 * time.Millisecond)\n\n\tv.mustPingRPC()\n\tmustGatherMetrics()\n\n\tm.mustServeHealthzAndMetrics()\n\n\t// Giving some time for HealthZ and Metrics to start Serving.\n\t// TODO: Must be a better way than to sleep.\n\ttime.Sleep(3 * time.Millisecond)\n\tmustEmitOKHealthz()\n\tmustEmitMetrics()\n}", "func initConfig() {\n\t// Find home directory.\n\thome, err := os.UserHomeDir()\n\tzenDir := home + \"/.zen\"\n\n\tcobra.CheckErr(err)\n\n\t// load the config data\n\tcfg = config.InitConfig(zenDir)\n\n\t// set default exec and runner\n\tcfg.AppCfg.Executor = &plugins.DefaultExecutor{}\n\tcfg.AppCfg.Runner = &plugins.DefaultRunner{}\n\n\t// load plugin from path based on config default\n\tfor _, plugin := range cfg.Plugins.Runners {\n\t\tif plugin.Name == cfg.AppCfg.RunnerID {\n\t\t\tplugins.LoadPlugin(plugin.Path)\n\t\t\tcfg.AppCfg.Runner = plugins.ZenPluginRegistry.Runner\n\t\t}\n\t}\n\n\tfor _, plugin := range cfg.Plugins.Executors {\n\t\tif plugin.Name == cfg.AppCfg.ExecutorID {\n\t\t\tplugins.LoadPlugin(plugin.Path)\n\t\t\tcfg.AppCfg.Executor = plugins.ZenPluginRegistry.Executor\n\t\t}\n\t}\n\n}", "func (m *Mix) Exec_Config(payload *mixTy.MixConfigAction, tx *types.Transaction, index int) (*types.Receipt, error) {\n\ta := newAction(m, tx)\n\treceipt, err := a.Config(payload)\n\tif err != nil {\n\t\tmlog.Error(\"mix config failed\", \"error\", err, \"hash\", hex.EncodeToString(tx.Hash()))\n\t\treturn nil, err\n\t}\n\treturn receipt, nil\n}", "func (c *Command) Run(args []string) int {\n\tname, opts, peers, err := c.readConfig()\n\tif err != nil {\n\t\tc.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\tc.instance, err = huton.NewInstance(name, opts...)\n\tif err != nil {\n\t\tc.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\t_, err = c.instance.Join(peers)\n\tif err != nil {\n\t\tc.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\treturn c.handleSignals()\n}", "func Run(l net.Listener, myconfig *config.Config, routes *[]router.Route, enableCORS bool) error {\n\tvar handler http.Handler\n\n\tif myconfig == nil {\n\t\treturn errors.New(\"Configuration is not set\")\n\t}\n\terr := dbhelper.Connect(myconfig.Database)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmyrouter := router.New(routes, true, true, myconfig.Server)\n\tif enableCORS {\n\t\thandler = router.GetCORS(myrouter, myconfig.Cors)\n\t} else {\n\t\thandler = myrouter\n\t}\n\tif l != nil {\n\t\treturn router.RunWithListener(handler, l)\n\t}\n\treturn router.Run(handler, myconfig.Server.Port)\n}", "func (r *CmdReporter) Run() error {\n\tstdout, stderr, retcode, err := r.runCommand()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"system failed to run command. %+v\", err)\n\t}\n\n\tif err := r.saveToConfigMap(stdout, stderr, retcode); err != nil {\n\t\treturn fmt.Errorf(\"failed to save command output to ConfigMap. %+v\", err)\n\t}\n\n\treturn nil\n}", "func (o *CreateConfigGwOptions) Run() error {\n\tif o.ListenAddress == \"\" {\n\t\tlog.Infof(\"%s not specified; using default (%s)\\n\", optionListenAddress, defaultListenAddress)\n\t\to.ListenAddress = defaultListenAddress\n\t\t// return util.MissingOption(optionListenAddress)\n\t}\n\n\tgwConfigDir, err := util.ZitiAppConfigDir(c.ZITI_FABRIC_GW)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"err\")\n\t}\n\n\treturn fmt.Errorf(\"UNIMPLEMENTED: '%s'\", gwConfigDir)\n}", "func LoadConfig(logger *zap.Logger, cfg interface{}) {\n\terr := envconfig.Process(\"\", cfg)\n\tif err != nil {\n\t\tenvconfig.Usage(\"\", cfg)\n\t\tlogger.Fatal(\"app: could not process config\", zap.Error(err))\n\t}\n}", "func (config *ReleaseCommandConfig) Run() error {\n\n\tgit, err := gitpkg.GetGit()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = release(git)\n\n\treturn err\n}", "func (c *ConverterController) Run(ctx context.Context, group *errgroup.Group, cfg *config.BaseOperatorConf) {\n\n\tif cfg.EnabledPrometheusConverter.ServiceScrape {\n\t\tgroup.Go(func() error {\n\t\t\treturn c.runInformerWithDiscovery(ctx, v1.SchemeGroupVersion.String(), v1.ServiceMonitorsKind, c.serviceInf.Run)\n\t\t})\n\n\t}\n\tif cfg.EnabledPrometheusConverter.PodMonitor {\n\t\tgroup.Go(func() error {\n\t\t\treturn c.runInformerWithDiscovery(ctx, v1.SchemeGroupVersion.String(), v1.PodMonitorsKind, c.podInf.Run)\n\t\t})\n\n\t}\n\tif cfg.EnabledPrometheusConverter.PrometheusRule {\n\t\tgroup.Go(func() error {\n\t\t\treturn c.runInformerWithDiscovery(ctx, v1.SchemeGroupVersion.String(), v1.PrometheusRuleKind, c.ruleInf.Run)\n\t\t})\n\n\t}\n\tif cfg.EnabledPrometheusConverter.Probe {\n\t\tgroup.Go(func() error {\n\t\t\treturn c.runInformerWithDiscovery(ctx, v1.SchemeGroupVersion.String(), v1.ProbeKindKey, c.probeInf.Run)\n\t\t})\n\n\t}\n\n}", "func (i *TiFlashInstance) InitConfig(\n\te executor.Executor,\n\tclusterName,\n\tclusterVersion,\n\tdeployUser string,\n\tpaths meta.DirPaths,\n) error {\n\ttopo := i.topo.(*Specification)\n\tif err := i.BaseInstance.InitConfig(e, topo.GlobalOptions, deployUser, paths); err != nil {\n\t\treturn err\n\t}\n\n\tspec := i.InstanceSpec.(TiFlashSpec)\n\n\ttidbStatusAddrs := []string{}\n\tfor _, tidb := range topo.TiDBServers {\n\t\ttidbStatusAddrs = append(tidbStatusAddrs, fmt.Sprintf(\"%s:%d\", tidb.Host, uint64(tidb.StatusPort)))\n\t}\n\ttidbStatusStr := strings.Join(tidbStatusAddrs, \",\")\n\n\tpdStr := strings.Join(i.getEndpoints(), \",\")\n\n\tcfg := scripts.NewTiFlashScript(\n\t\ti.GetHost(),\n\t\tpaths.Deploy,\n\t\tstrings.Join(paths.Data, \",\"),\n\t\tpaths.Log,\n\t\ttidbStatusStr,\n\t\tpdStr,\n\t).WithTCPPort(spec.TCPPort).\n\t\tWithHTTPPort(spec.HTTPPort).\n\t\tWithFlashServicePort(spec.FlashServicePort).\n\t\tWithFlashProxyPort(spec.FlashProxyPort).\n\t\tWithFlashProxyStatusPort(spec.FlashProxyStatusPort).\n\t\tWithStatusPort(spec.StatusPort).\n\t\tWithTmpDir(spec.TmpDir).\n\t\tWithNumaNode(spec.NumaNode).\n\t\tAppendEndpoints(topo.Endpoints(deployUser)...)\n\n\tfp := filepath.Join(paths.Cache, fmt.Sprintf(\"run_tiflash_%s_%d.sh\", i.GetHost(), i.GetPort()))\n\tif err := cfg.ConfigToFile(fp); err != nil {\n\t\treturn err\n\t}\n\tdst := filepath.Join(paths.Deploy, \"scripts\", \"run_tiflash.sh\")\n\n\tif err := e.Transfer(fp, dst, false); err != nil {\n\t\treturn err\n\t}\n\n\tif _, _, err := e.Execute(\"chmod +x \"+dst, false); err != nil {\n\t\treturn err\n\t}\n\n\tconf, err := i.InitTiFlashLearnerConfig(cfg, clusterVersion, topo.ServerConfigs.TiFlashLearner)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// merge config files for imported instance\n\tif i.IsImported() {\n\t\tconfigPath := ClusterPath(\n\t\t\tclusterName,\n\t\t\tAnsibleImportedConfigPath,\n\t\t\tfmt.Sprintf(\n\t\t\t\t\"%s-learner-%s-%d.toml\",\n\t\t\t\ti.ComponentName(),\n\t\t\t\ti.GetHost(),\n\t\t\t\ti.GetPort(),\n\t\t\t),\n\t\t)\n\t\timportConfig, err := ioutil.ReadFile(configPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tconf, err = mergeImported(importConfig, conf)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\terr = i.mergeTiFlashLearnerServerConfig(e, conf, spec.LearnerConfig, paths)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconf, err = i.InitTiFlashConfig(cfg, topo.ServerConfigs.TiFlash)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// merge config files for imported instance\n\tif i.IsImported() {\n\t\tconfigPath := ClusterPath(\n\t\t\tclusterName,\n\t\t\tAnsibleImportedConfigPath,\n\t\t\tfmt.Sprintf(\n\t\t\t\t\"%s-%s-%d.toml\",\n\t\t\t\ti.ComponentName(),\n\t\t\t\ti.GetHost(),\n\t\t\t\ti.GetPort(),\n\t\t\t),\n\t\t)\n\t\timportConfig, err := ioutil.ReadFile(configPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tconf, err = mergeImported(importConfig, conf)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn i.MergeServerConfig(e, conf, spec.Config, paths)\n}", "func (c *ConfigMapController) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {\n\t// When this function completes, mark the go function as done\n\tdefer wg.Done()\n\n\t// Increment wait group as we're about to execute a go function\n\twg.Add(1)\n\n\t// Execute go function\n\tgo c.configmapInformer.Run(stopCh)\n\n\t// Wait till we receive a stop signal\n\t<-stopCh\n}", "func (a *Agent) Run(ctx context.Context) error {\n\ta.Context = ctx\n\tlog.Printf(\"I! [agent] Config: Interval:%s, Quiet:%#v, Hostname:%#v, \"+\n\t\t\"Flush Interval:%s\",\n\t\ta.Config.Agent.Interval.Duration, a.Config.Agent.Quiet,\n\t\ta.Config.Agent.Hostname, a.Config.Agent.FlushInterval.Duration)\n\n\tlog.Printf(\"D! [agent] Initializing plugins\")\n\terr := a.initPlugins()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstartTime := time.Now()\n\tlog.Printf(\"D! [agent] Connecting outputs\")\n\tnext, ou, err := a.startOutputs(ctx, a.Config.Outputs)\n\tif err != nil {\n\t\treturn err\n\t}\n\ta.ou = ou\n\tvar apu []*processorUnit\n\tvar au *aggregatorUnit\n\tif len(a.Config.Aggregators) != 0 {\n\t\taggC := next\n\t\tif len(a.Config.AggProcessors) != 0 {\n\t\t\taggC, apu, err = a.startProcessors(next, a.Config.AggProcessors)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tnext, au, err = a.startAggregators(aggC, next, a.Config.Aggregators)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tvar pu []*processorUnit\n\tif len(a.Config.Processors) != 0 {\n\t\tnext, pu, err = a.startProcessors(next, a.Config.Processors)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tiu, err := a.startInputs(next, a.Config.Inputs)\n\ta.iu = iu\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar wg sync.WaitGroup\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\terr := a.runOutputs(ou)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"E! [agent] Error running outputs: %v\", err)\n\t\t}\n\t}()\n\n\tif au != nil {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\terr := a.runProcessors(apu)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"E! [agent] Error running processors: %v\", err)\n\t\t\t}\n\t\t}()\n\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\terr := a.runAggregators(startTime, au)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"E! [agent] Error running aggregators: %v\", err)\n\t\t\t}\n\t\t}()\n\t}\n\n\tif pu != nil {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\terr := a.runProcessors(pu)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"E! [agent] Error running processors: %v\", err)\n\t\t\t}\n\t\t}()\n\t}\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\terr := a.runInputs(ctx, startTime, iu)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"E! [agent] Error running inputs: %v\", err)\n\t\t}\n\t}()\n\n\twg.Wait()\n\n\tlog.Printf(\"D! [agent] Stopped Successfully\")\n\treturn err\n}" ]
[ "0.71010476", "0.64792436", "0.6213528", "0.62125707", "0.61918336", "0.60716456", "0.60399765", "0.60297084", "0.6020371", "0.60044134", "0.5958", "0.59382945", "0.58830523", "0.58809024", "0.5818161", "0.5803526", "0.5797414", "0.5793293", "0.5785053", "0.57504505", "0.57250494", "0.5718365", "0.56934637", "0.565791", "0.56416804", "0.5633542", "0.562904", "0.55968034", "0.5543123", "0.5521258", "0.55004114", "0.54941297", "0.549013", "0.5475373", "0.5469869", "0.5462719", "0.5460456", "0.5451451", "0.54485065", "0.54406667", "0.54190236", "0.5412966", "0.5381508", "0.537677", "0.53745943", "0.53740484", "0.53724056", "0.536694", "0.53590995", "0.5338566", "0.5337688", "0.5333704", "0.5331051", "0.53300285", "0.5313361", "0.528527", "0.52848804", "0.5284479", "0.52759975", "0.5263643", "0.52625793", "0.52532923", "0.52518755", "0.525099", "0.52450097", "0.5234943", "0.52329934", "0.52064174", "0.52040166", "0.51831824", "0.5177105", "0.517596", "0.51635396", "0.51616114", "0.5158125", "0.5156675", "0.5137417", "0.5134622", "0.51327753", "0.51198226", "0.510165", "0.5101057", "0.5099833", "0.50974804", "0.50931954", "0.5087555", "0.5077139", "0.50768566", "0.506884", "0.5065827", "0.50561374", "0.50555766", "0.50474393", "0.5043617", "0.50354654", "0.50327575", "0.5028912", "0.5020575", "0.50166035", "0.50151515" ]
0.7411264
0
Run will execute all phases of all registered Units and block until an error occurs. If RunConfig has been called prior to Run, the Group's Config phase will be skipped and Run continues with the PreRunner and Service phases. The following phases are executed in the following sequence: Config phase (serially, in order of Unit registration) FlagSet() Get & register all FlagSets from Config Units. Flag Parsing Using the provided args (os.Args if empty) Validate() Validate Config Units. Exit on first error. PreRunner phase (serially, in order of Unit registration) PreRun() Execute PreRunner Units. Exit on first error. Service phase (concurrently) Serve() Execute all Service Units in separate Go routines. Wait Block until one of the Serve() methods returns GracefulStop() Call interrupt handlers of all Service Units. Run will return with the originating error on: first Config.Validate() returning an error first PreRunner.PreRun() returning an error first Service.Serve() returning (error or nil)
func (g *Group) Run() (err error) { // run config registration and flag parsing stages if interrupted, errRun := g.RunConfig(); interrupted || errRun != nil { return errRun } defer func() { if err != nil { g.log.Fatal().Err(err).Stack().Msg("unexpected exit") } }() // execute pre run stage and exit on error for idx := range g.p { // a PreRunner might have been deregistered during Run if g.p[idx] == nil { continue } g.log.Debug().Uint32("ran", uint32(idx+1)).Uint32("total", uint32(len(g.p))).Str("name", g.p[idx].Name()).Msg("pre-run") if err := g.p[idx].PreRun(); err != nil { return err } } swg := &sync.WaitGroup{} swg.Add(len(g.s)) go func() { swg.Wait() close(g.readyCh) }() // feed our registered services to our internal run.Group for idx := range g.s { // a Service might have been deregistered during Run s := g.s[idx] if s == nil { continue } g.log.Debug().Uint32("total", uint32(len(g.s))).Uint32("ran", uint32(idx+1)).Str("name", s.Name()).Msg("serve") g.r.Add(func() error { notify := s.Serve() swg.Done() <-notify return nil }, func(_ error) { g.log.Debug().Uint32("total", uint32(len(g.s))).Uint32("ran", uint32(idx+1)).Str("name", s.Name()).Msg("stop") s.GracefulStop() }) } // start registered services and block return g.r.Run() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Cfg) Run(args ...string) {\n\tif args == nil {\n\t\targs = os.Args[1:]\n\t}\n\tc, cmd, args, err := c.Parse(args)\n\tif err == nil {\n\t\tif err = cmd.Main(args); err == nil {\n\t\t\tExit(0)\n\t\t\treturn\n\t\t}\n\t}\n\tif err == ErrHelp {\n\t\tw := newWriter(c)\n\t\tdefer w.done(os.Stderr, 0)\n\t\tw.help()\n\t} else {\n\t\tswitch e := err.(type) {\n\t\tcase UsageError:\n\t\t\tw := newWriter(c)\n\t\t\tdefer w.done(os.Stderr, 2)\n\t\t\tw.error(string(e))\n\t\tcase ExitCode:\n\t\t\tExit(int(e))\n\t\tdefault:\n\t\t\tverb := \"%v\"\n\t\t\tif Debug {\n\t\t\t\tverb = \"%+v\"\n\t\t\t}\n\t\t\tfmt.Fprintf(os.Stderr, \"Error: \"+verb+\"\\n\", err)\n\t\t\tExit(1)\n\t\t}\n\t}\n}", "func (cli *CLI) Run(args []string) int {\n\n\tc, err := cli.setup(args)\n\tif err != nil {\n\t\tlogging.Error(\"unable to parse configuration: %v\", err)\n\t\treturn ExitCodeParseConfigError\n\t}\n\n\t// Set the logging level for the logger.\n\tlogging.SetLevel(c.LogLevel)\n\n\t// Initialize telemetry if this was configured by the user.\n\tif c.Telemetry.StatsdAddress != \"\" {\n\t\tsink, statsErr := metrics.NewStatsdSink(c.Telemetry.StatsdAddress)\n\t\tif statsErr != nil {\n\t\t\tlogging.Error(\"unable to setup telemetry correctly: %v\", statsErr)\n\t\t\treturn ExitCodeTelemtryError\n\t\t}\n\t\tmetrics.NewGlobal(metrics.DefaultConfig(\"replicator\"), sink)\n\t}\n\n\t// Create the initial runner with the merged configuration parameters.\n\trunner, err := NewRunner(c)\n\tif err != nil {\n\t\treturn ExitCodeRunnerError\n\t}\n\n\tlogging.Debug(\"running version %v\", version.Get())\n\tgo runner.Start()\n\n\tsignalCh := make(chan os.Signal, 1)\n\tsignal.Notify(signalCh,\n\t\tsyscall.SIGHUP,\n\t\tsyscall.SIGINT,\n\t\tsyscall.SIGTERM,\n\t\tsyscall.SIGQUIT,\n\t)\n\n\tfor {\n\t\tselect {\n\t\tcase s := <-signalCh:\n\t\t\tswitch s {\n\t\t\tcase syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT:\n\t\t\t\trunner.Stop()\n\t\t\t\treturn ExitCodeInterrupt\n\n\t\t\tcase syscall.SIGHUP:\n\t\t\t\trunner.Stop()\n\n\t\t\t\t// Reload the configuration in order to make proper use of SIGHUP.\n\t\t\t\tc, err := cli.setup(args)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn ExitCodeParseConfigError\n\t\t\t\t}\n\n\t\t\t\t// Setup a new runner with the new configuration.\n\t\t\t\trunner, err = NewRunner(c)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn ExitCodeRunnerError\n\t\t\t\t}\n\n\t\t\t\tgo runner.Start()\n\t\t\t}\n\t\t}\n\t}\n}", "func (s *ServiceManager) Run() error {\n\tif err := CheckAllRegisteredServices(); err != nil {\n\t\treturn err\n\t}\n\t// Run all service\n\tglog.Infof(\"There are %d service in iothub\", len(s.services))\n\tfor _, service := range s.services {\n\t\tglog.Infof(\"Starting service:'%s'...\", service.Name())\n\t\tgo service.Start()\n\t}\n\t// Wait all service to terminate in main context\n\tfor name, ch := range s.chs {\n\t\t<-ch\n\t\tglog.Info(\"Servide(%s) is terminated\", name)\n\t}\n\treturn nil\n}", "func Run(m *testing.M, opts ...RunOption) {\n\t// Run tests in a separate function such that we can use deferred statements and still\n\t// (indirectly) call `os.Exit()` in case the test setup failed.\n\tif err := func() error {\n\t\tvar cfg runConfig\n\t\tfor _, opt := range opts {\n\t\t\topt(&cfg)\n\t\t}\n\n\t\tdefer mustHaveNoChildProcess()\n\t\tif !cfg.disableGoroutineChecks {\n\t\t\tdefer mustHaveNoGoroutines()\n\t\t}\n\n\t\tcleanup, err := configure()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"test configuration: %w\", err)\n\t\t}\n\t\tdefer cleanup()\n\n\t\tif cfg.setup != nil {\n\t\t\tif err := cfg.setup(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"error calling setup function: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\tm.Run()\n\n\t\treturn nil\n\t}(); err != nil {\n\t\tfmt.Printf(\"%s\", err)\n\t\tos.Exit(1)\n\t}\n}", "func (o *Orchestrator) Run() {\n\tv := newValidator(o.Plugin)\n\tm := newMetrics(o.healthzPath, o.healthzPort, o.metricsPath, o.metricsPort)\n\n\tv.mustValidatePrerequisites()\n\n\to.mustServeKMSRequests()\n\n\t// Giving some time for kmsPlugin to start Serving.\n\t// TODO: Must be a better way than to sleep.\n\ttime.Sleep(3 * time.Millisecond)\n\n\tv.mustPingRPC()\n\tmustGatherMetrics()\n\n\tm.mustServeHealthzAndMetrics()\n\n\t// Giving some time for HealthZ and Metrics to start Serving.\n\t// TODO: Must be a better way than to sleep.\n\ttime.Sleep(3 * time.Millisecond)\n\tmustEmitOKHealthz()\n\tmustEmitMetrics()\n}", "func (m *Manager) Run(ctx context.Context) error {\n\t// start log broadcaster\n\t_ = utils.Pool.Submit(func() { m.logBroadcaster.run(ctx) })\n\n\t// initWorkloadStatus container\n\tif err := m.initWorkloadStatus(ctx); err != nil {\n\t\treturn err\n\t}\n\n\t// start status watcher\n\t_ = utils.Pool.Submit(func() { m.monitor(ctx) })\n\n\t// start health check\n\t_ = utils.Pool.Submit(func() { m.healthCheck(ctx) })\n\n\t// wait for signal\n\t<-ctx.Done()\n\tlog.WithFunc(\"Run\").Info(ctx, \"exiting\")\n\treturn nil\n}", "func Run(args []string) {\n\t// Parse the arguments\n\tvar cmdCfg CmdConfig\n\tif err := parse(args, &cmdCfg); err != nil {\n\t\tlog.Errorf(\"%s\", err)\n\t\tfmt.Fprintf(os.Stderr, \"USAGE \\n\\n\\t%s\\n\\n\", os.Args[0])\n\t\tfmt.Fprint(os.Stderr, \"GLOBAL OPTIONS:\\n\\n\")\n\t\tusage(os.Stderr, &cmdCfg)\n\n\t\tos.Exit(1)\n\t}\n\n\t// set up global context for signal interuption\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\tvar stop = make(chan os.Signal)\n\tsignal.Notify(stop, syscall.SIGTERM, syscall.SIGINT)\n\tgo func() {\n\t\tsig := <-stop\n\t\tfmt.Printf(\"caught sig: %+v\\n\", sig)\n\t\tcancel()\n\t\tfmt.Println(\"Waiting up to 2 seconds to finish.\")\n\t\ttime.Sleep(2 * time.Second)\n\t\tos.Exit(0)\n\t}()\n\n\t// Global Configuration\n\t// Read deployment and service files into Kubernetes structs\n\tkubeServiceConfig, kubeServiceConfigErr := getServiceConfig(&cmdCfg)\n\tif kubeServiceConfigErr != nil {\n\t\tlog.Errorf(\"%s\", kubeServiceConfigErr)\n\t\tos.Exit(2)\n\t}\n\n\t// Regional configuration.\n\t// Gather environment variables and secret references.\n\t// Retrieve secrets from vault.\n\t// Create configmap and secret object.\n\tvar regionEnvs []*RegionEnv\n\tfor regionEnv := range createEnv(kubeServiceConfig, fetchSecrets(getConfig(ctx, &cmdCfg))) {\n\t\tlog.Debugf(\"Retrieved Configuration %+v\", regionEnv)\n\t\tif len(regionEnv.Errors) > 0 {\n\t\t\tlog.Errorf(\"%s\", regionEnv.Errors)\n\t\t\tos.Exit(2)\n\t\t}\n\t\tregionEnvs = append(regionEnvs, regionEnv)\n\t}\n\n\t// Run and monitor updates in this order.\n\tupdateFns := []UpdateFn{\n\t\tupdateConfigMapRegion,\n\t\tupdateServiceRegion,\n\t\tupdateServiceAccountRegion,\n\t\tupdateIngressRegion,\n\t\tupdateIngressRouteRegion,\n\t\tupdateGatewayRegion,\n\t\tupdateVirtualServiceRegion,\n\t\tupdateServiceInstanceRegion,\n\t\tupdateServiceBindingRegion,\n\t\tupdateNamedSecretsRegion,\n\t\tupdateDeploymentRegion,\n\t\tupdateJobRegion,\n\t\tupdateHPAutoscalerRegion,\n\t\tupdatePodDisruptionBudgetRegion,\n\t}\n\tfor _, updateFn := range updateFns {\n\t\terr := runUpdate(regionEnvs, updateFn)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"%s\", err)\n\t\t\tos.Exit(2)\n\t\t}\n\t}\n}", "func Run() {\n\tl := logrus.WithField(\"component\", \"main\")\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer l.Info(\"Done.\")\n\n\t// handle termination signals\n\tsignals := make(chan os.Signal, 1)\n\tsignal.Notify(signals, unix.SIGTERM, unix.SIGINT)\n\tgo func() {\n\t\ts := <-signals\n\t\tsignal.Stop(signals)\n\t\tl.Warnf(\"Got %s, shutting down...\", unix.SignalName(s.(unix.Signal)))\n\t\tcancel()\n\t}()\n\n\tfor {\n\t\tcfg, configFilepath, err := config.Get(l)\n\t\tif err != nil {\n\t\t\tl.Fatalf(\"Failed to load configuration: %s.\", err)\n\t\t}\n\t\tconfig.ConfigureLogger(cfg)\n\t\tl.Debugf(\"Loaded configuration: %+v\", cfg)\n\n\t\trun(ctx, cfg, configFilepath)\n\n\t\tif ctx.Err() != nil {\n\t\t\treturn\n\t\t}\n\t}\n}", "func (o *Options) Run(ctx context.Context) error {\n\tlog.Info(\"getting rest config\")\n\trestConfig, err := config.GetConfig()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Info(\"setting up manager\")\n\tmgr, err := manager.New(restConfig, manager.Options{\n\t\tScheme: kubernetes.SeedScheme,\n\t\tLeaderElection: false,\n\t\tMetricsBindAddress: \"0\", // disable for now, as we don't scrape the component\n\t\tHost: o.BindAddress,\n\t\tPort: o.Port,\n\t\tCertDir: o.ServerCertDir,\n\t\tGracefulShutdownTimeout: &gracefulShutdownTimeout,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Info(\"setting up webhook server\")\n\tserver := mgr.GetWebhookServer()\n\tserver.Register(extensioncrds.WebhookPath, &webhook.Admission{Handler: extensioncrds.New(runtimelog.Log.WithName(extensioncrds.HandlerName))})\n\tserver.Register(podschedulername.WebhookPath, &webhook.Admission{Handler: admission.HandlerFunc(podschedulername.DefaultShootControlPlanePodsSchedulerName)})\n\tserver.Register(extensionresources.WebhookPath, &webhook.Admission{Handler: extensionresources.New(runtimelog.Log.WithName(extensionresources.HandlerName), o.AllowInvalidExtensionResources)})\n\n\tlog.Info(\"starting manager\")\n\tif err := mgr.Start(ctx); err != nil {\n\t\tlog.Error(err, \"error running manager\")\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (s *VMTServer) Run(_ []string) error {\n\tif err := s.checkFlag(); err != nil {\n\t\tglog.Errorf(\"check flag failed:%v. abort.\", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\tglog.V(3).Infof(\"spec path is: %v\", s.K8sTAPSpec)\n\tk8sTAPSpec, err := kubeturbo.ParseK8sTAPServiceSpec(s.K8sTAPSpec)\n\tif err != nil {\n\t\tglog.Errorf(\"Failed to generate correct TAP config: %v\", err.Error())\n\t\tos.Exit(1)\n\t}\n\n\tkubeConfig := s.createKubeConfigOrDie()\n\tkubeClient := s.createKubeClientOrDie(kubeConfig)\n\tkubeletClient := s.createKubeletClientOrDie(kubeConfig)\n\tprobeConfig := s.createProbeConfigOrDie(kubeConfig, kubeletClient)\n\tbroker := turbostore.NewPodBroker()\n\n\tvmtConfig := kubeturbo.NewVMTConfig2()\n\tvmtConfig.WithTapSpec(k8sTAPSpec).\n\t\tWithKubeClient(kubeClient).\n\t\tWithKubeletClient(kubeletClient).\n\t\tWithProbeConfig(probeConfig).\n\t\tWithBroker(broker).\n\t\tWithK8sVersion(s.K8sVersion).\n\t\tWithNoneScheduler(s.NoneSchedulerName).\n\t\tWithRecorder(createRecorder(kubeClient))\n\tglog.V(3).Infof(\"Finished creating turbo configuration: %+v\", vmtConfig)\n\n\tvmtService := kubeturbo.NewKubeturboService(vmtConfig)\n\trun := func(_ <-chan struct{}) {\n\t\tvmtService.Run()\n\t\tselect {}\n\t}\n\n\tgo s.startHttp()\n\n\t//if !s.LeaderElection.LeaderElect {\n\tglog.V(2).Infof(\"No leader election\")\n\trun(nil)\n\n\tglog.Fatal(\"this statement is unreachable\")\n\tpanic(\"unreachable\")\n}", "func (a *App) Run(ctx context.Context) error {\n\n\t// 1. instantiate all components\n\n\tfor _, runnable := range a.runnables {\n\t\ta.logger(\"building: %s\", runnable)\n\n\t\t_, err := a.getValue(runnable)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"building %s: %w\", runnable, err)\n\t\t}\n\t}\n\n\t// 2. start all runnable\n\tctx, cancelCtx := context.WithCancel(ctx)\n\tdefer cancelCtx()\n\n\tvar wg sync.WaitGroup\n\n\tfor _, runnable := range a.runnables {\n\t\ta.logger(\"starting: %s\", runnable)\n\t\terr := a.start(ctx, runnable, &wg)\n\t\tif err != nil {\n\t\t\ta.logger(\"runnable failed to start: %s\", runnable)\n\t\t\tcancelCtx()\n\t\t\tbreak\n\t\t}\n\t}\n\n\t<-ctx.Done()\n\ta.logger(\"context cancelled, starting shutdown\")\n\n\t// 3. TODO: cancel component in reverse order\n\n\twg.Wait()\n\n\treturn nil\n}", "func (c *cli) Run(args []string) int {\n\t// Parse CLI args and flags\n\tflags, err := c.parseArgs(args)\n\n\tif err != nil {\n\t\tfmt.Fprintf(c.stderr, \"%v\\n\", err)\n\t\treturn 1\n\t}\n\n\t// Exit immediately if user asked for a help or an app version\n\tif flags.isHelp || flags.isVersion {\n\t\treturn 0\n\t}\n\n\t// Setup logrus\n\tc.configureLogger(flags.isVerbose)\n\n\t// Load config\n\tconfigChan, err := c.prepareConfigChan(flags.configPath)\n\n\tif err != nil {\n\t\tfmt.Fprintf(c.stderr, \"failed to load config: %v\\n\", err)\n\t\treturn 1\n\t}\n\n\t// Run the server (this is blocking call)\n\terr = c.runServer(configChan)\n\n\tif err != nil {\n\t\tfmt.Fprintf(c.stderr, \"server error: %v\\n\", err)\n\t\treturn 1\n\t}\n\n\treturn 0\n}", "func (p *Pipeline) Run(args []string) int {\n\tif err := p.LoadConfig(); err != nil {\n\t\treturn 1\n\t}\n\treturn 0\n}", "func (conf *Config) Run() error {\n\t// no error-checking if nothing to check errors on\n\tif conf == nil {\n\t\treturn nil\n\t}\n\tif conf.ThreadCount < 0 {\n\t\treturn fmt.Errorf(\"invalid thread count %d [must be a positive number]\", conf.ThreadCount)\n\t}\n\t// if not given other instructions, just describe the specs\n\tif !conf.Generate && !conf.Delete && conf.Verify == \"\" {\n\t\tconf.Describe = true\n\t\tconf.onlyDescribe = true\n\t}\n\tif conf.Verify != \"\" {\n\t\terr := conf.verifyType.UnmarshalText([]byte(conf.Verify))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unknown verify type '%s'\", conf.Verify)\n\t\t}\n\t} else {\n\t\t// If we're deleting, and not generating, we can skip\n\t\t// verification. Otherwise, default to erroring out if\n\t\t// there's a mismatch.\n\t\tif conf.Delete && !conf.Generate {\n\t\t\tconf.verifyType = verifyTypeNone\n\t\t} else {\n\t\t\tconf.verifyType = verifyTypeError\n\t\t}\n\t}\n\tconf.NewSpecsFiles(conf.flagset.Args())\n\tif len(conf.specFiles) < 1 {\n\t\treturn errors.New(\"must specify one or more spec files\")\n\t}\n\tif conf.ColumnScale < 0 || conf.ColumnScale > (1<<31) {\n\t\treturn fmt.Errorf(\"column scale [%d] should be between 1 and 2^31\", conf.ColumnScale)\n\t}\n\tif conf.RowScale < 0 || conf.RowScale > (1<<16) {\n\t\treturn fmt.Errorf(\"row scale [%d] should be between 1 and 2^16\", conf.RowScale)\n\t}\n\treturn nil\n}", "func (g *Group) RunConfig() (interrupted bool, err error) {\n\tg.log = logger.GetLogger(g.name)\n\tg.configured = true\n\n\tif g.name == \"\" {\n\t\t// use the binary name if custom name has not been provided\n\t\tg.name = path.Base(os.Args[0])\n\t}\n\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tg.log.Error().Err(err).Msg(\"unexpected exit\")\n\t\t}\n\t}()\n\n\t// Load config from env and file\n\tif err = config.Load(g.f.Name, g.f.FlagSet); err != nil {\n\t\treturn false, errors.Wrapf(err, \"%s fails to load config\", g.f.Name)\n\t}\n\n\t// bail early on help or version requests\n\tswitch {\n\tcase g.showRunGroup:\n\t\tfmt.Println(g.ListUnits())\n\t\treturn true, nil\n\t}\n\n\t// Validate Config inputs\n\tfor idx := range g.c {\n\t\t// a Config might have been deregistered during Run\n\t\tif g.c[idx] == nil {\n\t\t\tg.log.Debug().Uint32(\"ran\", uint32(idx+1)).Msg(\"skipping validate\")\n\t\t\tcontinue\n\t\t}\n\t\tg.log.Debug().Str(\"name\", g.c[idx].Name()).Uint32(\"ran\", uint32(idx+1)).Uint32(\"total\", uint32(len(g.c))).Msg(\"validate config\")\n\t\tif vErr := g.c[idx].Validate(); vErr != nil {\n\t\t\terr = multierr.Append(err, vErr)\n\t\t}\n\t}\n\n\t// exit on at least one Validate error\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\t// log binary name and version\n\tg.log.Info().Msg(\"started\")\n\n\treturn false, nil\n}", "func (bs *BusinessServer) Run() {\n\t// initialize config.\n\tbs.initConfig()\n\n\t// initialize logger.\n\tbs.initLogger()\n\tdefer bs.Stop()\n\n\t// initialize server modules.\n\tbs.initMods()\n\n\t// register businessserver service.\n\tgo func() {\n\t\tif err := bs.service.Register(bs.etcdCfg); err != nil {\n\t\t\tlogger.Fatal(\"register service for discovery, %+v\", err)\n\t\t}\n\t}()\n\tlogger.Info(\"register service for discovery success.\")\n\n\t// run service.\n\ts := grpc.NewServer(grpc.MaxRecvMsgSize(math.MaxInt32))\n\tpb.RegisterBusinessServer(s, bs)\n\tlogger.Info(\"Business Server running now.\")\n\n\tif err := s.Serve(bs.lis); err != nil {\n\t\tlogger.Fatal(\"start businessserver gRPC service. %+v\", err)\n\t}\n}", "func (c *SystemCommand) Run(args []string) int {\n\tvar debug bool\n\tf := flag.NewFlagSet(\"system\", flag.ContinueOnError)\n\tf.Usage = func() { c.UI.Output(c.Help()) }\n\tf.BoolVar(&debug, \"debug\", false, \"Debug mode enabled\")\n\tif err := f.Parse(args); err != nil {\n\t\treturn 1\n\t}\n\tsetupLogging(debug)\n\treturn c.doSystemInformations()\n}", "func Run(root string) error {\n\tv1, err := readConfig()\n\tmust(err)\n\n\tvar context = runconf{\n\t\tFilterOut: v1.GetStringSlice(\"filterOut\"),\n\t\tLookFor: v1.GetStringSlice(\"lookFor\"),\n\t\trootPath: root,\n\t}\n\n\titerate(context)\n\treturn nil\n}", "func Run(settings *Settings) error {\n\tlog.Infof(\"using k8s version: %s\", settings.KubernetesVersion.String())\n\n\t// parse config\n\tlog.Infof(\"reading config from path: %s\", settings.PathConfig)\n\tconfigBytes, err := os.ReadFile(settings.PathConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\tconfig := &config{}\n\tif err := yaml.UnmarshalStrict(configBytes, &config); err != nil {\n\t\treturn errors.Wrapf(err, \"cannot parse config\")\n\t}\n\n\tfor _, j := range config.JobGroups {\n\t\tif err := processjobGroup(settings, &j); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (s *Server) Run(ctx context.Context) error {\n\t// Attach the context to the errgroup so that goroutines are canceled when\n\t// one of them returns an error.\n\teg, ctx := errgroup.WithContext(ctx)\n\ts.eg = eg\n\tdefer close(s.ready)\n\n\tmm := NewAdvertiserMetrics(s.reg)\n\n\t// Serve on each specified interface.\n\tfor _, ifi := range s.cfg.Interfaces {\n\t\t// Prepend the interface name to all logs for this server.\n\t\tlogf := func(format string, v ...interface{}) {\n\t\t\ts.ll.Println(ifi.Name + \": \" + fmt.Sprintf(format, v...))\n\t\t}\n\n\t\tif !ifi.SendAdvertisements {\n\t\t\tlogf(\"send advertisements is false, skipping initialization\")\n\t\t\tcontinue\n\t\t}\n\n\t\tlogf(\"initializing with %d plugins\", len(ifi.Plugins))\n\n\t\tfor i, p := range ifi.Plugins {\n\t\t\tlogf(\"plugin %02d: %q: %s\", i, p.Name(), p)\n\t\t}\n\n\t\t// TODO: find a way to reasonably test this.\n\n\t\t// Begin advertising on this interface until the context is canceled.\n\t\tad, err := NewAdvertiser(ifi, s.ll, mm)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to create NDP advertiser: %v\", err)\n\t\t}\n\n\t\ts.eg.Go(func() error {\n\t\t\tif err := ad.Advertise(ctx); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to advertise NDP: %v\", err)\n\t\t\t}\n\n\t\t\treturn nil\n\t\t})\n\t}\n\n\t// Configure the HTTP debug server, if applicable.\n\tif err := s.runDebug(ctx); err != nil {\n\t\treturn fmt.Errorf(\"failed to start debug HTTP server: %v\", err)\n\t}\n\n\t// Indicate readiness to any waiting callers, and then wait for all\n\t// goroutines to be canceled and stopped successfully.\n\ts.ready <- struct{}{}\n\tif err := s.eg.Wait(); err != nil {\n\t\treturn fmt.Errorf(\"failed to serve: %v\", err)\n\t}\n\n\treturn nil\n}", "func Run() int {\n\tpflag.Parse()\n\tpopulateAvailableKubeconfigs()\n\n\tif len(availableKubeconfigs) == 0 {\n\t\tprintKubeConfigHelpOutput()\n\t\treturn 2\n\t}\n\n\t// DEBUG\n\tfmt.Println(availableKubeconfigs)\n\treturn 0\n}", "func Run(ctx context.Context, cfg *config.Config) error {\n\tMetrics = newMetrics()\n\tdefer runCleanupHooks()\n\n\t// apply defaults before validation\n\tcfg.ApplyDefaults()\n\n\terr := cfg.Validate()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to validate config: %w\\n%+v\", err, cfg)\n\t}\n\n\tfuncMap := template.FuncMap{}\n\terr = bindPlugins(ctx, cfg, funcMap)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// if a custom Stdin is set in the config, inject it into the context now\n\tctx = data.ContextWithStdin(ctx, cfg.Stdin)\n\n\topts := optionsFromConfig(cfg)\n\topts.Funcs = funcMap\n\ttr := NewRenderer(opts)\n\n\tstart := time.Now()\n\n\tnamer := chooseNamer(cfg, tr)\n\ttmpl, err := gatherTemplates(ctx, cfg, namer)\n\tMetrics.GatherDuration = time.Since(start)\n\tif err != nil {\n\t\tMetrics.Errors++\n\t\treturn fmt.Errorf(\"failed to gather templates for rendering: %w\", err)\n\t}\n\tMetrics.TemplatesGathered = len(tmpl)\n\n\terr = tr.RenderTemplates(ctx, tmpl)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c *RunCommand) Run(args []string) int {\n\tvar (\n\t\tlangFlag string\n\t\tvalidaterFlag string\n\t\tverboseFlag bool\n\t\troundFlag int\n\t)\n\n\tflags := c.Meta.NewFlagSet(\"run\", c.Help())\n\tflags.StringVar(&langFlag, \"l\", \"\", \"Specify Language\")\n\tflags.StringVar(&langFlag, \"language\", \"\", \"Specify Language\")\n\tflags.StringVar(&validaterFlag, \"V\", \"\", \"Specify Validater\")\n\tflags.StringVar(&validaterFlag, \"validater\", \"\", \"Specify Validater\")\n\tflags.BoolVar(&verboseFlag, \"vb\", false, \"increase amount of output\")\n\tflags.BoolVar(&verboseFlag, \"verbose\", false, \"increase amount of output\")\n\tflags.IntVar(&roundFlag, \"p\", 0, \"Rounded to the decimal point p digits\")\n\tflags.IntVar(&roundFlag, \"place\", 0, \"Rounded to the decimal point place digits\")\n\n\tif err := flags.Parse(args); err != nil {\n\t\tmsg := fmt.Sprintf(\"Invalid option: %s\", strings.Join(args, \" \"))\n\t\tc.UI.Error(msg)\n\t\treturn ExitCodeFailed\n\t}\n\targs = flags.Args()\n\n\tif len(args) < 2 {\n\t\tmsg := fmt.Sprintf(\"Invalid arguments: %s\", strings.Join(args, \" \"))\n\t\tc.UI.Error(msg)\n\t\treturn ExitCodeFailed\n\t}\n\n\tif _, err := os.Stat(args[0]); err != nil {\n\t\tc.UI.Error(\"does not exist (No such directory)\")\n\t\treturn ExitCodeFailed\n\t}\n\n\tif langFlag == \"\" {\n\t\tlangFlag = strings.Replace(path.Ext(args[1]), \".\", \"\", -1)\n\t}\n\tlang, ok := Lang[langFlag]\n\tif !ok {\n\t\tmsg := fmt.Sprintf(\"Invalid language: %s\", langFlag)\n\t\tc.UI.Error(msg)\n\t\treturn ExitCodeFailed\n\t}\n\n\tif roundFlag < 0 || roundFlag > 15 {\n\t\tmsg := fmt.Sprintf(\"Invalid round: %d\", roundFlag)\n\t\tc.UI.Error(msg)\n\t\treturn ExitCodeFailed\n\t}\n\n\tif validaterFlag == \"float\" {\n\t\tValidaters[\"float\"] = &FloatValidater{Place: roundFlag}\n\t}\n\n\tif validaterFlag == \"\" {\n\t\tvalidaterFlag = \"diff\"\n\t}\n\tv, ok := Validaters[validaterFlag]\n\tif !ok {\n\t\tmsg := fmt.Sprintf(\"Invalid validater: %s\", validaterFlag)\n\t\tc.UI.Error(msg)\n\t\treturn ExitCodeFailed\n\t}\n\n\tinfoBuf, err := ioutil.ReadFile(args[0] + \"/\" + \"info.json\")\n\tif err != nil {\n\t\tc.UI.Error(fmt.Sprintf(\"failed to read info file: %v\", err))\n\t\treturn ExitCodeFailed\n\t}\n\n\tinfo := Info{}\n\tif err := json.Unmarshal(infoBuf, &info); err != nil {\n\t\tc.UI.Error(err.Error())\n\t\treturn ExitCodeFailed\n\t}\n\n\tvar w, e io.Writer\n\tif verboseFlag {\n\t\tw, e = os.Stdout, os.Stderr\n\t}\n\n\tcode, result, clearFunc, err := NewCode(args[1], lang, &info, w, e)\n\tif err != nil {\n\t\tc.UI.Output(err.Error())\n\t\treturn ExitCodeFailed\n\t}\n\tc.UI.Output(result.String())\n\tdefer clearFunc()\n\n\tvar rCode *Code\n\tif info.JudgeType > 0 {\n\t\trCode, clearFunc, err = NewReactiveCode(&info, args[0], w, e)\n\t\tif err != nil {\n\t\t\tc.UI.Error(err.Error())\n\t\t\treturn ExitCodeFailed\n\t\t}\n\t\tdefer clearFunc()\n\t}\n\n\tinputFiles, err := filepath.Glob(strings.Join([]string{args[0], \"test_in\", \"*\"}, \"/\"))\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"input testcase error: %v\", err)\n\t\tc.UI.Error(msg)\n\t\treturn ExitCodeFailed\n\t}\n\n\toutputFiles, err := filepath.Glob(strings.Join([]string{args[0], \"test_out\", \"*\"}, \"/\"))\n\tif err != nil {\n\t\tmsg := fmt.Sprintf(\"output testcase error: %v\", err)\n\t\tc.UI.Error(msg)\n\t\treturn ExitCodeFailed\n\t}\n\n\tfor i := 0; i < len(inputFiles); i++ {\n\t\terr := func() error {\n\t\t\tinput, err := os.Open(inputFiles[i])\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"input test file error: %v\", err)\n\t\t\t}\n\t\t\tdefer input.Close()\n\n\t\t\toutput, err := ioutil.ReadFile(outputFiles[i])\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"output test file error: %v\", err)\n\t\t\t}\n\n\t\t\tvar result string\n\t\t\tif info.JudgeType > 0 {\n\t\t\t\tresult, err = rCode.Reactive(code, inputFiles[i], outputFiles[i], input, w, e)\n\t\t\t} else {\n\t\t\t\tvar buf bytes.Buffer\n\t\t\t\tresult, err = code.Run(v, output, input, &buf, e)\n\t\t\t}\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t_, testFile := path.Split(inputFiles[i])\n\t\t\tc.UI.Output(fmt.Sprintf(\"%s\\t%s\", result, testFile))\n\t\t\treturn nil\n\t\t}()\n\t\tif err != nil {\n\t\t\tc.UI.Error(err.Error())\n\t\t\treturn ExitCodeFailed\n\t\t}\n\t}\n\treturn ExitCodeOK\n}", "func Run(ctx context.Context) error {\n\tctx, cancel := context.WithCancel(ctx)\n\tlogger := log.WithContext(nil)\n\n\ttester := server.Prepare(&server.Options{\n\t\tName: \"tester\",\n\t\tInsecureAddr: viper.GetString(options.FlagServerInsecureBindAddress.GetLong()),\n\t\tSecureAddr: viper.GetString(options.FlagServerSecureBindAddress.GetLong()),\n\t\tInsecurePort: viper.GetInt(options.FlagServerInsecurePort.GetLong()),\n\t\tSecurePort: viper.GetInt(options.FlagServerSecurePort.GetLong()),\n\t\tTLSKey: viper.GetString(options.FlagServerTLSKeyFile.GetLong()),\n\t\tTLSCert: viper.GetString(options.FlagServerTLSCertFile.GetLong()),\n\t\tTLSCa: viper.GetString(options.FlagServerTLSCaFile.GetLong()),\n\t\tHandler: chain.New().Add(\n\t\t\tmiddleware.Correlation,\n\t\t\tmiddleware.Metrics,\n\t\t).Link(middleware.Dump),\n\t\tLogger: logger.Sugar(),\n\t})\n\n\tmetrics := server.Prepare(&server.Options{\n\t\tName: \"prometheus\",\n\t\tInsecureAddr: viper.GetString(options.FlagPrometheusInsecureBindAddress.GetLong()),\n\t\tInsecurePort: viper.GetInt(options.FlagPrometheusInsecurePort.GetLong()),\n\t\tHandler: promhttp.Handler(),\n\t\tLogger: logger.Sugar(),\n\t})\n\n\tvar g run.Group\n\n\tg.Add(func() error {\n\t\t<-ctx.Done()\n\t\treturn nil\n\t}, func(error) {\n\t\tcancel()\n\t})\n\n\tg.Add(func() error {\n\t\treturn logError(metrics.Run())\n\t}, func(error) {\n\t\tlogError(metrics.Close())\n\t})\n\n\tg.Add(func() error {\n\t\treturn logError(tester.Run())\n\t}, func(error) {\n\t\tlogError(tester.Close())\n\t})\n\n\treturn g.Run()\n}", "func (s *Service) Run(c context.Context, f func(context.Context) error) {\n\tc = gologger.StdConfig.Use(c)\n\n\t// If a service name isn't specified, default to the base of the current\n\t// executable.\n\tif s.Name == \"\" {\n\t\ts.Name = filepath.Base(os.Args[0])\n\t}\n\n\trc := 0\n\tif err := s.runImpl(c, f); err != nil {\n\t\tlog.WithError(err).Errorf(c, \"Application exiting with error.\")\n\t\trc = 1\n\t}\n\tos.Exit(rc)\n}", "func (c *EBSCommand) Run(args []string) int {\n\n\t// Decorate this CLI's UI\n\tc.Ui = &cli.PrefixedUi{\n\t\tOutputPrefix: \" \",\n\t\tInfoPrefix: \"INFO: \",\n\t\tErrorPrefix: \"ERROR: \",\n\t\tUi: c.Ui,\n\t}\n\n\t// Set the args which may have the mtest config\n\tc.args = args\n\n\t// Dependency Injection\n\tif !c.IsInitialized() {\n\t\terr := c.SetAll()\n\t\tif err != nil {\n\t\t\tc.Ui.Error(err.Error())\n\t\t\treturn 1\n\t\t}\n\t}\n\n\tif c.wtrVarsMake == nil {\n\t\tc.Ui.Error(fmt.Sprintf(\"Writer-variants-maker instance is nil.\"))\n\t\treturn 1\n\t}\n\n\t// Defer flush the gatedWriter which is linked to this\n\t// CLI's io.writer during Dependency Injection\n\tgatedLogger := c.wtrVarsMake.GatedWriter()\n\tif gatedLogger == nil {\n\t\treturn 1\n\t}\n\tdefer gatedLogger.Flush()\n\n\tif c.mtestMake == nil {\n\t\tc.Ui.Error(fmt.Sprintf(\"Mtest-maker instance is nil.\"))\n\t\treturn 1\n\t}\n\n\t// ebs cli is meant to run Maya Server\n\t// Get a Mtest instance that is associated with Maya Server\n\tmt, err := c.mtestMake.Make()\n\tif err != nil {\n\t\tc.Ui.Error(err.Error())\n\t\treturn 1\n\t}\n\n\t// Output the header that the server has started\n\tc.Ui.Output(\"Mtest ebs run started! Log data will start streaming:\\n\")\n\n\t// Start EBS use cases\n\trpts, err := mt.Start()\n\tdefer mt.Stop()\n\n\tif err != nil {\n\t\tc.Ui.Error(err.Error())\n\t\t// Exit code is set to 0 as this has nothing to do\n\t\t// with running of CLI. CLI execution was fine.\n\t\treturn 0\n\t}\n\n\tc.Ui.Info(fmt.Sprintf(\"%+s\", rpts))\n\n\treturn 0\n}", "func Run(rpcCfg RPCConfig) error {\n\tconfig := DefaultConfig()\n\n\t// Parse command line flags.\n\tparser := flags.NewParser(&config, flags.Default)\n\tparser.SubcommandsOptional = true\n\n\t_, err := parser.Parse()\n\tif e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp {\n\t\treturn nil\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Parse ini file.\n\tloopDir := lncfg.CleanAndExpandPath(config.LoopDir)\n\tconfigFile := lncfg.CleanAndExpandPath(config.ConfigFile)\n\n\t// If our loop directory is set and the config file parameter is not\n\t// set, we assume that they want to point to a config file in their\n\t// loop dir. However, if the config file has a non-default value, then\n\t// we leave the config parameter as its custom value.\n\tif loopDir != loopDirBase && configFile == defaultConfigFile {\n\t\tconfigFile = filepath.Join(\n\t\t\tloopDir, defaultConfigFilename,\n\t\t)\n\t}\n\n\tif err := flags.IniParse(configFile, &config); err != nil {\n\t\t// If it's a parsing related error, then we'll return\n\t\t// immediately, otherwise we can proceed as possibly the config\n\t\t// file doesn't exist which is OK.\n\t\tif _, ok := err.(*flags.IniError); ok {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Parse command line flags again to restore flags overwritten by ini\n\t// parse.\n\t_, err = parser.Parse()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Show the version and exit if the version flag was specified.\n\tappName := filepath.Base(os.Args[0])\n\tappName = strings.TrimSuffix(appName, filepath.Ext(appName))\n\tif config.ShowVersion {\n\t\tfmt.Println(appName, \"version\", loop.Version())\n\t\tos.Exit(0)\n\t}\n\n\t// Special show command to list supported subsystems and exit.\n\tif config.DebugLevel == \"show\" {\n\t\tfmt.Printf(\"Supported subsystems: %v\\n\",\n\t\t\tlogWriter.SupportedSubsystems())\n\t\tos.Exit(0)\n\t}\n\n\t// Validate our config before we proceed.\n\tif err := Validate(&config); err != nil {\n\t\treturn err\n\t}\n\n\t// Initialize logging at the default logging level.\n\terr = logWriter.InitLogRotator(\n\t\tfilepath.Join(config.LogDir, defaultLogFilename),\n\t\tconfig.MaxLogFileSize, config.MaxLogFiles,\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = build.ParseAndSetDebugLevels(config.DebugLevel, logWriter)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Print the version before executing either primary directive.\n\tlog.Infof(\"Version: %v\", loop.Version())\n\n\tlisCfg := newListenerCfg(&config, rpcCfg)\n\n\t// Execute command.\n\tif parser.Active == nil {\n\t\tsignal.Intercept()\n\n\t\tdaemon := New(&config, lisCfg)\n\t\tif err := daemon.Start(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tselect {\n\t\tcase <-signal.ShutdownChannel():\n\t\t\tlog.Infof(\"Received SIGINT (Ctrl+C).\")\n\t\t\tdaemon.Stop()\n\n\t\t\t// The above stop will return immediately. But we'll be\n\t\t\t// notified on the error channel once the process is\n\t\t\t// complete.\n\t\t\treturn <-daemon.ErrChan\n\n\t\tcase err := <-daemon.ErrChan:\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif parser.Active.Name == \"view\" {\n\t\treturn view(&config, lisCfg)\n\t}\n\n\treturn fmt.Errorf(\"unimplemented command %v\", parser.Active.Name)\n}", "func Run() derrors.Error {\n\t// Channel to signal errors from starting the servers\n\terrChan := make(chan error, 1)\n\n\t// Start listening on API port\n\tgrpcListener, err := net.Listen(\"tcp\", \":12345\")\n\tif err != nil {\n\t\treturn derrors.NewUnavailableError(\"failed to listen\", err)\n\t}\n\n\tgrpcServer, derr := ec_stub.Start(grpcListener, errChan)\n\tif derr != nil {\n\t\treturn derr\n\t}\n\tdefer grpcServer.GracefulStop()\n\n\t// Wait for termination signal\n\tsigterm := make(chan os.Signal, 1)\n\tsignal.Notify(sigterm, syscall.SIGTERM)\n\tsignal.Notify(sigterm, syscall.SIGINT)\n\n\tselect {\n\tcase sig := <-sigterm:\n\t\tlog.Info().Str(\"signal\", sig.String()).Msg(\"Gracefully shutting down\")\n\tcase err := <-errChan:\n\t\t// We've already logged the error\n\t\treturn derrors.NewInternalError(\"failed starting server\", err)\n\t}\n\n\treturn nil\n}", "func (a *Agent) Run(ctx context.Context) error {\n\ta.Context = ctx\n\tlog.Printf(\"I! [agent] Config: Interval:%s, Quiet:%#v, Hostname:%#v, \"+\n\t\t\"Flush Interval:%s\",\n\t\ta.Config.Agent.Interval.Duration, a.Config.Agent.Quiet,\n\t\ta.Config.Agent.Hostname, a.Config.Agent.FlushInterval.Duration)\n\n\tlog.Printf(\"D! [agent] Initializing plugins\")\n\terr := a.initPlugins()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstartTime := time.Now()\n\tlog.Printf(\"D! [agent] Connecting outputs\")\n\tnext, ou, err := a.startOutputs(ctx, a.Config.Outputs)\n\tif err != nil {\n\t\treturn err\n\t}\n\ta.ou = ou\n\tvar apu []*processorUnit\n\tvar au *aggregatorUnit\n\tif len(a.Config.Aggregators) != 0 {\n\t\taggC := next\n\t\tif len(a.Config.AggProcessors) != 0 {\n\t\t\taggC, apu, err = a.startProcessors(next, a.Config.AggProcessors)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tnext, au, err = a.startAggregators(aggC, next, a.Config.Aggregators)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tvar pu []*processorUnit\n\tif len(a.Config.Processors) != 0 {\n\t\tnext, pu, err = a.startProcessors(next, a.Config.Processors)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tiu, err := a.startInputs(next, a.Config.Inputs)\n\ta.iu = iu\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar wg sync.WaitGroup\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\terr := a.runOutputs(ou)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"E! [agent] Error running outputs: %v\", err)\n\t\t}\n\t}()\n\n\tif au != nil {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\terr := a.runProcessors(apu)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"E! [agent] Error running processors: %v\", err)\n\t\t\t}\n\t\t}()\n\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\terr := a.runAggregators(startTime, au)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"E! [agent] Error running aggregators: %v\", err)\n\t\t\t}\n\t\t}()\n\t}\n\n\tif pu != nil {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\terr := a.runProcessors(pu)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"E! [agent] Error running processors: %v\", err)\n\t\t\t}\n\t\t}()\n\t}\n\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\terr := a.runInputs(ctx, startTime, iu)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"E! [agent] Error running inputs: %v\", err)\n\t\t}\n\t}()\n\n\twg.Wait()\n\n\tlog.Printf(\"D! [agent] Stopped Successfully\")\n\treturn err\n}", "func Run(c *cli.Context, o *options) error {\n\terr := verifyFlags(o)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to verify flags: %v\", err)\n\t}\n\n\terr = initialize()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to initialize: %v\", err)\n\t}\n\tdefer shutdown()\n\n\terr = installToolkit(o)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to install toolkit: %v\", err)\n\t}\n\n\terr = setupRuntime(o)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to setup runtime: %v\", err)\n\t}\n\n\tif !o.noDaemon {\n\t\terr = waitForSignal()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to wait for signal: %v\", err)\n\t\t}\n\n\t\terr = cleanupRuntime(o)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to cleanup runtime: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (c *Command) Run(args []string) {\n\tservice := servd.New()\n\tc.loadAndValidateConfig()\n\n\tswitch args[0] {\n\tcase inquiry:\n\t\tservice.Inquiry()\n\tcase payment:\n\t\tservice.Payment()\n\tcase checkStatus:\n\t\tservice.CheckStatus()\n\tdefault:\n\t\tlog.Println(\"please specify the available command (inquiry, payment, checkstatus)\")\n\t}\n}", "func (c *CLI) Run(args []string) int {\n\tparam := &param{}\n\terr := c.parseArgs(args[1:], param)\n\tif err != nil {\n\t\tfmt.Fprintf(c.ErrStream, \"args parse error: %v\", err)\n\t\treturn ExitCodeParseError\n\t}\n\n\tserver, err := NewServer(param.file)\n\tif err != nil {\n\t\tfmt.Fprintf(c.ErrStream, \"invalid args. failed to initialize server: %v\", err)\n\t\treturn ExitCodeInvalidArgsError\n\t}\n\n\tif err := server.PrepareServer(); err != nil {\n\t\tfmt.Fprintf(c.ErrStream, \"failed to setup server: %v\", err)\n\t\treturn ExitCodeSetupServerError\n\t}\n\n\tif err := server.Run(param.port); err != nil {\n\t\tfmt.Fprintf(c.ErrStream, \"failed from server: %v\", err)\n\t\treturn ExitCodeError\n\t}\n\treturn ExitCodeOK\n}", "func (s *Service) Run(host, port string) error {\n\t// let's gooooo\n\ts.l.Infow(\"spinning up core service\",\n\t\t\"core.host\", host,\n\t\t\"core.port\", port)\n\tlistener, err := net.Listen(\"tcp\", host+\":\"+port)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif err = s.grpc.Serve(listener); err != nil {\n\t\ts.l.Errorf(\"error encountered - service stopped\",\n\t\t\t\"error\", err)\n\t\treturn err\n\t}\n\n\t// report shutdown\n\ts.l.Info(\"service shut down\")\n\treturn nil\n}", "func (o *Options) Run() error {\n\terr := o.Validate()\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to validate options\")\n\t}\n\n\tconfig, err := o.LoadSourceConfig()\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to load source config\")\n\t}\n\n\tfor i := range config.Spec.Groups {\n\t\tgroup := &config.Spec.Groups[i]\n\t\tfor j := range group.Repositories {\n\t\t\trepo := &group.Repositories[j]\n\n\t\t\tif o.Filter != \"\" && !strings.Contains(repo.Name, o.Filter) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\terr := o.UpgradeRepository(config, group, repo)\n\t\t\tif err != nil {\n\t\t\t\tlog.Logger().Errorf(\"failed to upgrade repository %s due to: %s\", repo.Name, err.Error())\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (m *Manager) Run(ctx context.Context) error {\n\ts := <-m.status\n\tswitch s {\n\tcase StatusShutdown:\n\t\tm.status <- s\n\t\treturn ErrShutdown\n\tcase StatusUnknown:\n\t\t// ok\n\tdefault:\n\t\tm.status <- s\n\t\treturn ErrAlreadyStarted\n\t}\n\n\tstartCtx, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\tm.startupCancel = cancel\n\tstartupFunc := m.startupFunc\n\tm.status <- StatusStarting\n\n\tif startupFunc != nil {\n\t\tm.startupErr = startupFunc(startCtx)\n\t}\n\tcancel()\n\n\ts = <-m.status\n\n\tswitch s {\n\tcase StatusShutdown:\n\t\tm.status <- s\n\t\t// no error on shutdown while starting\n\t\treturn nil\n\tcase StatusStarting:\n\t\tif m.startupErr != nil {\n\t\t\tm.status <- s\n\t\t\tclose(m.startupDone)\n\t\t\treturn m.startupErr\n\t\t}\n\t\t// ok\n\tdefault:\n\t\tm.status <- s\n\t\tpanic(\"unexpected lifecycle state\")\n\t}\n\n\tctx, m.runCancel = context.WithCancel(ctx)\n\tclose(m.startupDone)\n\tm.status <- StatusReady\n\n\terr := m.runFunc(ctx)\n\tclose(m.runDone)\n\t<-m.shutdownDone\n\treturn err\n}", "func (phase *EtcdSetupPhase) Run() error {\n\tvar etcdNodes []clustermanager.Node\n\tcluster := phase.clusterManager.Cluster()\n\n\tif cluster.IsolatedEtcd {\n\t\tetcdNodes = phase.provider.GetEtcdNodes()\n\t} else {\n\t\tetcdNodes = phase.provider.GetMasterNodes()\n\t}\n\n\terr := phase.clusterManager.InstallEtcdNodes(etcdNodes, phase.options.KeepData)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (r *Runner) Run(ctx context.Context) error {\n\treturn errors.New(\"not implemented\")\n}", "func (c *Command) Run(s *runtime.Scheme, log logging.Logger) error {\n\tcfg, err := ctrl.GetConfig()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Cannot get config\")\n\t}\n\tlog.Debug(\"Starting\", \"sync-period\", c.Sync.String())\n\n\tmgr, err := ctrl.NewManager(cfg, ctrl.Options{\n\t\tScheme: s,\n\t\tLeaderElection: c.LeaderElection,\n\t\tLeaderElectionID: \"crossplane-leader-election-core\",\n\t\tSyncPeriod: &c.Sync,\n\t})\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"Cannot create manager\")\n\t}\n\n\tif err := apiextensions.Setup(mgr, log); err != nil {\n\t\treturn errors.Wrap(err, \"Cannot setup API extension controllers\")\n\t}\n\n\tpkgCache := xpkg.NewImageCache(c.CacheDir, afero.NewOsFs())\n\n\tif err := pkg.Setup(mgr, log, pkgCache, c.Namespace); err != nil {\n\t\treturn errors.Wrap(err, \"Cannot add packages controllers to manager\")\n\t}\n\n\treturn errors.Wrap(mgr.Start(ctrl.SetupSignalHandler()), \"Cannot start controller manager\")\n}", "func (c *Command) Run(args []string) int {\n\tname, opts, peers, err := c.readConfig()\n\tif err != nil {\n\t\tc.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\tc.instance, err = huton.NewInstance(name, opts...)\n\tif err != nil {\n\t\tc.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\t_, err = c.instance.Join(peers)\n\tif err != nil {\n\t\tc.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\treturn c.handleSignals()\n}", "func (c *ContainerExecutor) Run(opts ifc.RunOptions) error {\n\tlog.Print(\"starting generic container\")\n\n\tif c.Options.ClusterName != \"\" {\n\t\tcleanup, err := c.SetKubeConfig()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer cleanup()\n\t}\n\n\tinput, err := bundleReader(c.ExecutorBundle)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// TODO this logic is redundant in executor package, move it to pkg/container\n\tvar output io.Writer\n\tif c.ResultsDir == \"\" {\n\t\t// set output only if the output if resulting directory is not defined\n\t\toutput = os.Stdout\n\t}\n\tif err = c.setConfig(); err != nil {\n\t\treturn err\n\t}\n\n\t// TODO check the executor type when dryrun is set\n\tif opts.DryRun {\n\t\tlog.Print(\"DryRun execution finished\")\n\t\treturn nil\n\t}\n\n\terr = c.ClientFunc(c.ResultsDir, input, output, c.Container, c.MountBasePath).Run()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlog.Print(\"execution of the generic container finished\")\n\treturn nil\n}", "func (s *Service) Run() error {\n\tgo func() {\n\t\tif s.config.CertConfig != nil {\n\t\t\tif err := s.Server.ListenAndServeTLS(s.config.CertConfig.CertificateFile, s.config.CertConfig.KeyFile); err != http.ErrServerClosed {\n\t\t\t\tlogrus.Fatalf(\"Failed to start query service: %s\\n\", err)\n\t\t\t}\n\t\t} else {\n\t\t\tif err := s.Server.ListenAndServe(); err != http.ErrServerClosed {\n\t\t\t\tlogrus.Fatalf(\"Failed to start query service: %s\\n\", err)\n\t\t\t}\n\t\t}\n\t}()\n\n\tlog.SetLogLevel(s.config.LogLevel)\n\t//We want a graceful exit\n\tif err := s.waitForShutdown(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (a *Agent) Run() {\n\tagent.RegisterAPIValidator(a.validateAPI)\n\tagent.OnConfigChange(a.onConfigChange)\n\n\tgo a.discoveryLoop()\n\tgo a.publishLoop()\n\n\tselect {\n\tcase <-a.stopAgent:\n\t\tlog.Info(\"Received request to kill agent\")\n\t\ta.stopDiscovery <- true\n\t\ta.stopPublish <- true\n\t\treturn\n\t}\n}", "func (d *Daemon) Run() (err error) {\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n\tgc := gc.NewGC()\n\tgc.StartGC(ctx)\n\n\tif rerr := d.registerSubReaper(gc); rerr != nil {\n\t\treturn rerr\n\t}\n\n\tlogrus.Debugf(\"Daemon start with option %#v\", d.opts)\n\n\tstack.Setup(d.opts.RunRoot)\n\n\td.NewBackend()\n\n\tif err = d.NewGrpcServer(); err != nil {\n\t\treturn err\n\t}\n\td.backend.Register(d.grpc.server)\n\t// after the daemon is done setting up we can notify systemd api\n\tsystemd.NotifySystemReady()\n\n\terrCh := make(chan error)\n\tif err = d.grpc.Run(ctx, errCh, cancel); err != nil {\n\t\tlogrus.Error(\"Running GRPC server failed: \", err)\n\t}\n\n\tselect {\n\tcase serverErr, ok := <-errCh:\n\t\tif !ok {\n\t\t\tlogrus.Errorf(\"Channel errCh closed, check grpc server err\")\n\t\t}\n\t\terr = serverErr\n\t\tcancel()\n\t// channel closed is what we expected since it's daemon normal behavior\n\tcase <-ctx.Done():\n\t\tlogrus.Infof(\"Context finished with: %v\", ctx.Err())\n\t}\n\n\tsystemd.NotifySystemStopping()\n\td.grpc.server.GracefulStop()\n\td.backend.wg.Wait()\n\treturn err\n}", "func (c *Controller) Run(ctx context.Context) error {\n\t// Start the informer factories to begin populating the informer caches\n\tc.log.Infof(\"starting step control loop, node name: %s\", c.nodeName)\n\n\t// 初始化runner\n\tc.log.Info(\"init controller engine\")\n\tif err := engine.Init(c.wc, c.informer.Recorder()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := c.sync(ctx); err != nil {\n\t\treturn err\n\t}\n\n\tc.waitDown(ctx)\n\treturn nil\n}", "func (e *Signer) Run(ctx context.Context) {\n\t// Shut down queues\n\tdefer utilruntime.HandleCrash()\n\tdefer e.syncQueue.ShutDown()\n\n\tif !cache.WaitForNamedCacheSync(\"bootstrap_signer\", ctx.Done(), e.configMapSynced, e.secretSynced) {\n\t\treturn\n\t}\n\n\tlogger := klog.FromContext(ctx)\n\tlogger.V(5).Info(\"Starting workers\")\n\tgo wait.UntilWithContext(ctx, e.serviceConfigMapQueue, 0)\n\t<-ctx.Done()\n\tlogger.V(1).Info(\"Shutting down\")\n}", "func (pm *PipelineManager) Run(threadiness int, stopCh <-chan struct{}) error {\n\t// Start the informer factories to begin populating the informer caches\n\tlog.Info(\"[PipelineManager.Run] Starting...\")\n\n\t// Wait for the caches to be synced before starting workers\n\tlog.Info(\"[PipelineManager.Run] Waiting for informer caches to sync\")\n\n\tif ok := cache.WaitForCacheSync(stopCh, pm.deploymentSynced, pm.podSynced); !ok {\n\t\treturn fmt.Errorf(\"[PipelineManager.Run] failed to wait for caches to sync\")\n\t}\n\n\tlog.Info(\"[PipelineManager.Run] Starting workers\")\n\tgo func() {\n\t\t<-stopCh\n\t\tlog.Info(\"[PipelineManager] shutdown work queue\")\n\t\tpm.workqueue.ShutDown()\n\t}()\n\n\t// Launch two workers to process Pipeline resources\n\tfor i := 0; i < threadiness; i++ {\n\t\tgo wait.Until(pm.runWorker, time.Second, stopCh)\n\t}\n\n\tlog.Info(\"[PipelineManager.Run] Started workers\")\n\treturn nil\n}", "func (e *Engine) Run() error {\n\n\tgo e.service.Run()\n\n\te.consensus.Run()\n\n\treturn nil\n}", "func Run(s options.Options, stopCh <-chan struct{}) error {\n\terr := NonBlockingRun(s, stopCh)\n\tif err != nil {\n\t\treturn err\n\t}\n\t<-stopCh\n\treturn nil\n}", "func Run(ctx context.Context) {\n\tif flags.Version {\n\t\tfmt.Print(info.VersionString())\n\t\treturn\n\t}\n\n\tcfg, err := config.Load(flags.ConfigPath)\n\tif err != nil {\n\t\tif err == config.ErrMissingAPIKey {\n\t\t\tfmt.Println(config.ErrMissingAPIKey)\n\n\t\t\t// a sleep is necessary to ensure that supervisor registers this process as \"STARTED\"\n\t\t\t// If the exit is \"too quick\", we enter a BACKOFF->FATAL loop even though this is an expected exit\n\t\t\t// http://supervisord.org/subprocess.html#process-states\n\t\t\ttime.Sleep(5 * time.Second)\n\n\t\t\t// Don't use os.Exit() method here, even with os.Exit(0) the Service Control Manager\n\t\t\t// on Windows will consider the process failed and log an error in the Event Viewer and\n\t\t\t// attempt to restart the process.\n\t\t\treturn\n\t\t}\n\t\tosutil.Exitf(\"%v\", err)\n\t}\n\terr = info.InitInfo(cfg) // for expvar & -info option\n\tif err != nil {\n\t\tosutil.Exitf(\"%v\", err)\n\t}\n\n\tif flags.Info {\n\t\tif err := info.Info(os.Stdout, cfg); err != nil {\n\t\t\tosutil.Exitf(\"Failed to print info: %s\", err)\n\t\t}\n\t\treturn\n\t}\n\n\tif err := coreconfig.SetupLogger(\n\t\tcoreconfig.LoggerName(\"TRACE\"),\n\t\tcfg.LogLevel,\n\t\tcfg.LogFilePath,\n\t\tcoreconfig.GetSyslogURI(),\n\t\tcoreconfig.Datadog.GetBool(\"syslog_rfc\"),\n\t\tcoreconfig.Datadog.GetBool(\"log_to_console\"),\n\t\tcoreconfig.Datadog.GetBool(\"log_format_json\"),\n\t); err != nil {\n\t\tosutil.Exitf(\"Cannot create logger: %v\", err)\n\t}\n\tdefer log.Flush()\n\n\tif !cfg.Enabled {\n\t\tlog.Info(messageAgentDisabled)\n\n\t\t// a sleep is necessary to ensure that supervisor registers this process as \"STARTED\"\n\t\t// If the exit is \"too quick\", we enter a BACKOFF->FATAL loop even though this is an expected exit\n\t\t// http://supervisord.org/subprocess.html#process-states\n\t\ttime.Sleep(5 * time.Second)\n\t\treturn\n\t}\n\n\tdefer watchdog.LogOnPanic()\n\n\tif flags.CPUProfile != \"\" {\n\t\tf, err := os.Create(flags.CPUProfile)\n\t\tif err != nil {\n\t\t\tlog.Error(err)\n\t\t}\n\t\tpprof.StartCPUProfile(f)\n\t\tlog.Info(\"CPU profiling started...\")\n\t\tdefer pprof.StopCPUProfile()\n\t}\n\n\tif flags.PIDFilePath != \"\" {\n\t\terr := pidfile.WritePID(flags.PIDFilePath)\n\t\tif err != nil {\n\t\t\tlog.Criticalf(\"Error writing PID file, exiting: %v\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\tlog.Infof(\"PID '%d' written to PID file '%s'\", os.Getpid(), flags.PIDFilePath)\n\t\tdefer os.Remove(flags.PIDFilePath)\n\t}\n\n\terr = metrics.Configure(cfg, []string{\"version:\" + info.Version})\n\tif err != nil {\n\t\tosutil.Exitf(\"cannot configure dogstatsd: %v\", err)\n\t}\n\tdefer metrics.Flush()\n\tdefer timing.Stop()\n\n\tmetrics.Count(\"datadog.trace_agent.started\", 1, nil, 1)\n\n\trand.Seed(time.Now().UTC().UnixNano())\n\n\ttagger.Init()\n\tdefer tagger.Stop()\n\n\tagnt := NewAgent(ctx, cfg)\n\tlog.Infof(\"Trace agent running on host %s\", cfg.Hostname)\n\tagnt.Run()\n\n\t// collect memory profile\n\tif flags.MemProfile != \"\" {\n\t\tf, err := os.Create(flags.MemProfile)\n\t\tif err != nil {\n\t\t\tlog.Error(\"Could not create memory profile: \", err)\n\t\t}\n\n\t\t// get up-to-date statistics\n\t\truntime.GC()\n\t\t// Not using WriteHeapProfile but instead calling WriteTo to\n\t\t// make sure we pass debug=1 and resolve pointers to names.\n\t\tif err := pprof.Lookup(\"heap\").WriteTo(f, 1); err != nil {\n\t\t\tlog.Error(\"Could not write memory profile: \", err)\n\t\t}\n\t\tf.Close()\n\t}\n}", "func (Tests) Run(ctx context.Context) error {\n\targ := BuildDockerComposeArgs(ProjectName, ProjectType, \"test\", DockerComposeTestFile)\n\targ = append(arg, \"run\")\n\targ = append(arg,\n\t\t\"--rm\",\n\t\t\"--use-aliases\",\n\t)\n\targ = append(arg, \"app\", \"go\", \"test\", \"-mod=vendor\", \"-v\", \"-cover\")\n\tif err := Exec(ComposeBin, append(arg, \"./service\")...); err != nil {\n\t\treturn err\n\t}\n\tif err := Exec(ComposeBin, append(arg, \"./...\")...); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (p *Plugin) Run(kubeclient kubernetes.Interface) error {\n\tvar err error\n\tconfigMap, err := p.buildConfigMap()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdaemonSet, err := p.buildDaemonSet()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Submit them to the API server, capturing the results\n\tif _, err = kubeclient.CoreV1().ConfigMaps(p.Namespace).Create(configMap); err != nil {\n\t\treturn errors.Wrapf(err, \"could not create ConfigMap for daemonset plugin %v\", p.GetName())\n\t}\n\tif _, err = kubeclient.ExtensionsV1beta1().DaemonSets(p.Namespace).Create(daemonSet); err != nil {\n\t\treturn errors.Wrapf(err, \"could not create DaemonSet for daemonset plugin %v\", p.GetName())\n\t}\n\n\treturn nil\n}", "func (rc *Controller) Run(ctx context.Context) error {\n\topts := []func(context.Context) error{\n\t\trc.setGlobalVariables,\n\t\trc.restoreSchema,\n\t\trc.preCheckRequirements,\n\t\trc.initCheckpoint,\n\t\trc.importTables,\n\t\trc.fullCompact,\n\t\trc.cleanCheckpoints,\n\t}\n\n\ttask := log.FromContext(ctx).Begin(zap.InfoLevel, \"the whole procedure\")\n\n\tvar err error\n\tfinished := false\noutside:\n\tfor i, process := range opts {\n\t\terr = process(ctx)\n\t\tif i == len(opts)-1 {\n\t\t\tfinished = true\n\t\t}\n\t\tlogger := task.With(zap.Int(\"step\", i), log.ShortError(err))\n\n\t\tswitch {\n\t\tcase err == nil:\n\t\tcase log.IsContextCanceledError(err):\n\t\t\tlogger.Info(\"task canceled\")\n\t\t\tbreak outside\n\t\tdefault:\n\t\t\tlogger.Error(\"run failed\")\n\t\t\tbreak outside // ps : not continue\n\t\t}\n\t}\n\n\t// if process is cancelled, should make sure checkpoints are written to db.\n\tif !finished {\n\t\trc.waitCheckpointFinish()\n\t}\n\n\ttask.End(zap.ErrorLevel, err)\n\trc.errorMgr.LogErrorDetails()\n\trc.errorSummaries.emitLog()\n\n\treturn errors.Trace(err)\n}", "func (s Server) Run(ctx context.Context) error {\n\tctx, cancel := context.WithCancel(ctx)\n\terrWg := errgroup.Group{}\n\n\terrWg.Go(func() error {\n\t\tlis, err := net.Listen(\"tcp\", s.grpcAddr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn s.grpcServer.Serve(lis)\n\t})\n\n\terrWg.Go(func() error {\n\t\tl, err := net.Listen(\"tcp\", s.httpAddr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\treturn s.httpServer.Serve(l)\n\t})\n\n\terrWg.Go(func() error {\n\t\tswaggerAddr := s.httpAddr + swaggerUIPrefix\n\t\tlog.Info().Msgf(\"App started. HTTP: %s, Swagger UI: %s, gRPC: %s\", s.httpAddr, swaggerAddr, s.grpcAddr)\n\t\treturn nil\n\t})\n\n\terrWg.Go(func() error {\n\t\tshutdownCh := make(chan os.Signal, 1)\n\t\tsignal.Notify(shutdownCh, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)\n\t\tsig := <-shutdownCh\n\n\t\ts.stop(ctx)\n\t\tcancel()\n\n\t\tlog.Fatal().Msgf(\"exit reason: %s\", sig)\n\n\t\treturn nil\n\t})\n\n\treturn errWg.Wait()\n}", "func (s *Service) Run(r Runner) {\n\ts.init()\n\tenv := s.envFunc()\n\tpfs := &FlagSet{FlagSet: s.fs, es: s.es}\n\tr.SetFlags(pfs)\n\n\ts.asPlugin = env[\"DRONE\"] == \"true\"\n\ts.debug = env[\"PLUGIN_PLUGIN_DEBUG\"] != \"\"\n\t{\n\t\tlogFlags := 0\n\t\tif s.debug {\n\t\t\tlogFlags = log.Ltime | log.Lshortfile\n\t\t}\n\t\tif s.log.logger == nil {\n\t\t\tlog.SetFlags(logFlags)\n\t\t} else {\n\t\t\ts.log.logger.SetFlags(logFlags)\n\t\t}\n\t}\n\tif s.debug {\n\t\ts.log.Debugln(\"drone plugins debug mode is active!\")\n\t}\n\tif s.debug {\n\t\tfor k, v := range env {\n\t\t\tif strings.HasPrefix(k, \"PLUGIN_\") || strings.HasPrefix(k, \"DRONE_\") {\n\t\t\t\ts.log.Debugf(\"[env] %s=%s\", k, v)\n\t\t\t}\n\t\t}\n\t\ts.es.VisitAll(func(e fenv.EnvFlag) {\n\t\t\ts.log.Debugf(\"[assign] flag '%s' for env vars: %s\",\n\t\t\t\te.Flag.Name, strings.Join(e.Names, \", \"))\n\t\t})\n\t}\n\n\tif pfs.envFilesActive {\n\t\ts.readEnvfiles(env, pfs.envFiles)\n\t}\n\n\tif s.asPlugin {\n\t\ts.fs.Usage = s.usageFuncYml\n\t\ts.fs.Init(s.args()[0], flag.ContinueOnError)\n\t}\n\n\tif err := s.es.ParseEnv(env); err != nil {\n\t\ts.execErr = err\n\t\ts.fs.Usage()\n\t\tif !s.continueOnError {\n\t\t\tos.Exit(1)\n\t\t}\n\t\treturn\n\n\t}\n\n\tif err := s.fs.Parse(s.args()[1:]); err != nil {\n\t\ts.execErr = err\n\t\ts.log.Println(err)\n\t\tif !s.continueOnError {\n\t\t\tos.Exit(1)\n\t\t}\n\t\treturn\n\n\t}\n\tif s.debug {\n\t\ts.es.VisitAll(func(e fenv.EnvFlag) {\n\t\t\tif !e.IsSelfSet && e.IsSet {\n\t\t\t\ts.log.Debugf(\"[flag] '%s' set: %v\", e.Flag.Name, e.Flag.Value)\n\t\t\t}\n\t\t})\n\t\ts.es.VisitAll(func(e fenv.EnvFlag) {\n\t\t\tif e.IsSelfSet {\n\t\t\t\ts.log.Debugf(\"[envflag] '%s' set by env var '%s': %v\", e.Flag.Name, e.Name, e.Flag.Value)\n\t\t\t}\n\t\t})\n\t\ts.usageFuncYml()\n\t}\n\tctx := context.Background()\n\ts.log.Debugln(\"------ executing plugin func -----\")\n\terr := r.Exec(ctx, s.log)\n\ts.log.Debugln(\"------ plugin func done -----\")\n\ts.execErr = err\n\tvar hasErrors bool\n\tif err != nil {\n\t\ts.log.Debugln(\"ErrUsageError returned\")\n\t\tif s.debug {\n\t\t\t_ = s.log.Output(2, fmt.Sprintf(\"plugin runner error: %v\", err))\n\t\t}\n\t\tif err == ErrUsageError {\n\t\t\thasErrors = true\n\t\t}\n\t} else {\n\t\ts.es.VisitAll(func(e fenv.EnvFlag) {\n\t\t\tif e.Err != nil {\n\t\t\t\thasErrors = true\n\t\t\t}\n\t\t})\n\t}\n\tif hasErrors {\n\t\ts.fs.Usage()\n\t\tif !s.continueOnError {\n\t\t\tos.Exit(1)\n\t\t}\n\t\treturn\n\t}\n}", "func (s *VMTServer) Run() {\n\tif err := s.checkFlag(); err != nil {\n\t\tglog.Fatalf(\"Check flag failed: %v. Abort.\", err.Error())\n\t}\n\n\tkubeConfig := s.createKubeConfigOrDie()\n\tglog.V(3).Infof(\"kubeConfig: %+v\", kubeConfig)\n\n\tkubeClient := s.createKubeClientOrDie(kubeConfig)\n\n\t// Create controller runtime client that support custom resources\n\truntimeClient, err := runtimeclient.New(kubeConfig, runtimeclient.Options{Scheme: customScheme})\n\tif err != nil {\n\t\tglog.Fatalf(\"Failed to create controller runtime client: %v.\", err)\n\t}\n\n\t// Openshift client for deploymentconfig resize forced rollouts\n\tosClient, err := osclient.NewForConfig(kubeConfig)\n\tif err != nil {\n\t\tglog.Fatalf(\"Failed to generate openshift client for kubernetes target: %v\", err)\n\t}\n\n\t// TODO: Replace dynamicClient with runtimeClient\n\tdynamicClient, err := dynamic.NewForConfig(kubeConfig)\n\tif err != nil {\n\t\tglog.Fatalf(\"Failed to generate dynamic client for kubernetes target: %v\", err)\n\t}\n\n\tutil.K8sAPIDeploymentGV, err = discoverk8sAPIResourceGV(kubeClient, util.DeploymentResName)\n\tif err != nil {\n\t\tglog.Warningf(\"Failure in discovering k8s deployment API group/version: %v\", err.Error())\n\t}\n\tglog.V(2).Infof(\"Using group version %v for k8s deployments\", util.K8sAPIDeploymentGV)\n\n\tutil.K8sAPIReplicasetGV, err = discoverk8sAPIResourceGV(kubeClient, util.ReplicaSetResName)\n\tif err != nil {\n\t\tglog.Warningf(\"Failure in discovering k8s replicaset API group/version: %v\", err.Error())\n\t}\n\tglog.V(2).Infof(\"Using group version %v for k8s replicasets\", util.K8sAPIReplicasetGV)\n\n\tglog.V(3).Infof(\"Turbonomic config path is: %v\", s.K8sTAPSpec)\n\n\tk8sTAPSpec, err := kubeturbo.ParseK8sTAPServiceSpec(s.K8sTAPSpec, kubeConfig.Host)\n\tif err != nil {\n\t\tglog.Fatalf(\"Failed to generate correct TAP config: %v\", err.Error())\n\t}\n\n\tif k8sTAPSpec.FeatureGates != nil {\n\t\terr = utilfeature.DefaultMutableFeatureGate.SetFromMap(k8sTAPSpec.FeatureGates)\n\t\tif err != nil {\n\t\t\tglog.Fatalf(\"Invalid Feature Gates: %v\", err)\n\t\t}\n\t}\n\n\tif utilfeature.DefaultFeatureGate.Enabled(features.GoMemLimit) {\n\t\tglog.V(2).Info(\"Memory Optimisations are enabled.\")\n\t\t// AUTOMEMLIMIT_DEBUG environment variable enables debug logging of AUTOMEMLIMIT\n\t\t// GoMemLimit will be set during the start of each discovery, see K8sDiscoveryClient.Discover,\n\t\t// as memory limit may change overtime\n\t\t_ = os.Setenv(\"AUTOMEMLIMIT_DEBUG\", \"true\")\n\t\tif s.ItemsPerListQuery != 0 {\n\t\t\t// Perform sanity check on user specified value of itemsPerListQuery\n\t\t\tif s.ItemsPerListQuery < processor.DefaultItemsPerGiMemory {\n\t\t\t\tvar errMsg string\n\t\t\t\tif s.ItemsPerListQuery < 0 {\n\t\t\t\t\terrMsg = \"negative\"\n\t\t\t\t} else {\n\t\t\t\t\terrMsg = \"set too low\"\n\t\t\t\t}\n\t\t\t\tglog.Warningf(\"Argument --items-per-list-query is %s (%v). Setting it to the default value of %d.\",\n\t\t\t\t\terrMsg, s.ItemsPerListQuery, processor.DefaultItemsPerGiMemory)\n\t\t\t\ts.ItemsPerListQuery = processor.DefaultItemsPerGiMemory\n\t\t\t} else {\n\t\t\t\tglog.V(2).Infof(\"Set items per list API call to the user specified value: %v.\", s.ItemsPerListQuery)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tglog.V(2).Info(\"Memory Optimisations are not enabled.\")\n\t}\n\n\t// Collect target and probe info such as master host, server version, probe container image, etc\n\tk8sTAPSpec.CollectK8sTargetAndProbeInfo(kubeConfig, kubeClient)\n\n\texcludeLabelsMap, err := nodeUtil.LabelMapFromNodeSelectorString(s.CpufreqJobExcludeNodeLabels)\n\tif err != nil {\n\t\tglog.Fatalf(\"Invalid cpu frequency exclude node label selectors: %v. The selectors \"+\n\t\t\t\"should be a comma saperated list of key=value node label pairs\", err)\n\t}\n\n\ts.ensureBusyboxImageBackwardCompatibility()\n\tkubeletClient := s.CreateKubeletClientOrDie(kubeConfig, kubeClient, s.CpuFrequencyGetterImage,\n\t\ts.CpuFrequencyGetterPullSecret, excludeLabelsMap, s.UseNodeProxyEndpoint)\n\tcaClient, err := clusterclient.NewForConfig(kubeConfig)\n\tif err != nil {\n\t\tglog.Errorf(\"Failed to generate correct TAP config: %v\", err.Error())\n\t\tcaClient = nil\n\t}\n\n\t// Interface to discover turbonomic ORM mappings (legacy and v2) for resize actions\n\tormClientManager := resourcemapping.NewORMClientManager(dynamicClient, kubeConfig)\n\n\t// Configuration for creating the Kubeturbo TAP service\n\tvmtConfig := kubeturbo.NewVMTConfig2()\n\tvmtConfig.WithTapSpec(k8sTAPSpec).\n\t\tWithKubeClient(kubeClient).\n\t\tWithKubeConfig(kubeConfig).\n\t\tWithDynamicClient(dynamicClient).\n\t\tWithControllerRuntimeClient(runtimeClient).\n\t\tWithORMClientManager(ormClientManager).\n\t\tWithKubeletClient(kubeletClient).\n\t\tWithClusterAPIClient(caClient).\n\t\tWithOpenshiftClient(osClient).\n\t\tWithVMPriority(s.VMPriority).\n\t\tWithVMIsBase(s.VMIsBase).\n\t\tUsingUUIDStitch(s.UseUUID).\n\t\tWithDiscoveryInterval(s.DiscoveryIntervalSec).\n\t\tWithValidationTimeout(s.ValidationTimeout).\n\t\tWithValidationWorkers(s.ValidationWorkers).\n\t\tWithDiscoveryWorkers(s.DiscoveryWorkers).\n\t\tWithDiscoveryTimeout(s.DiscoveryTimeoutSec).\n\t\tWithDiscoverySamples(s.DiscoverySamples).\n\t\tWithDiscoverySampleIntervalSec(s.DiscoverySampleIntervalSec).\n\t\tWithSccSupport(s.sccSupport).\n\t\tWithCAPINamespace(s.ClusterAPINamespace).\n\t\tWithContainerUtilizationDataAggStrategy(s.containerUtilizationDataAggStrategy).\n\t\tWithContainerUsageDataAggStrategy(s.containerUsageDataAggStrategy).\n\t\tWithVolumePodMoveConfig(s.FailVolumePodMoves).\n\t\tWithQuotaUpdateConfig(s.UpdateQuotaToAllowMoves).\n\t\tWithReadinessRetryThreshold(s.readinessRetryThreshold).\n\t\tWithClusterKeyInjected(s.ClusterKeyInjected).\n\t\tWithItemsPerListQuery(s.ItemsPerListQuery)\n\n\tif utilfeature.DefaultFeatureGate.Enabled(features.GitopsApps) {\n\t\tvmtConfig.WithGitConfig(s.gitConfig)\n\t} else {\n\t\tif s.gitConfig.GitEmail != \"\" ||\n\t\t\ts.gitConfig.GitSecretName != \"\" ||\n\t\t\ts.gitConfig.GitSecretNamespace != \"\" ||\n\t\t\ts.gitConfig.GitUsername != \"\" {\n\t\t\tglog.V(2).Infof(\"Feature: %v is not enabled, arg values set for git-email: %s, git-username: %s \"+\n\t\t\t\t\"git-secret-name: %s, git-secret-namespace: %s will be ignored.\", features.GitopsApps,\n\t\t\t\ts.gitConfig.GitEmail, s.gitConfig.GitUsername, s.gitConfig.GitSecretName, s.gitConfig.GitSecretNamespace)\n\t\t}\n\t}\n\tglog.V(3).Infof(\"Finished creating turbo configuration: %+v\", vmtConfig)\n\n\t// The KubeTurbo TAP service\n\tk8sTAPService, err := kubeturbo.NewKubernetesTAPService(vmtConfig)\n\tif err != nil {\n\t\tglog.Fatalf(\"Unexpected error while creating Kubernetes TAP service: %s\", err)\n\t}\n\n\t// Its a must to include the namespace env var in the kubeturbo pod spec.\n\tns := util.GetKubeturboNamespace()\n\t// Update scc resources in parallel.\n\tgo ManageSCCs(ns, dynamicClient, kubeClient)\n\n\t// The client for healthz, debug, and prometheus\n\tgo s.startHttp()\n\n\tcleanupWG := &sync.WaitGroup{}\n\tcleanupSCCFn := func() {\n\t\tns := util.GetKubeturboNamespace()\n\t\tCleanUpSCCMgmtResources(ns, dynamicClient, kubeClient)\n\t}\n\tdisconnectFn := func() {\n\t\t// Disconnect from Turbo server when Kubeturbo is shutdown\n\t\t// Close the mediation container including the endpoints. It avoids the\n\t\t// invalid endpoints remaining in the server side. See OM-28801.\n\t\tk8sTAPService.DisconnectFromTurbo()\n\t}\n\tvar cleanupFuns []cleanUp\n\tif s.CleanupSccRelatedResources {\n\t\tcleanupFuns = append(cleanupFuns, cleanupSCCFn)\n\t}\n\tcleanupFuns = append(cleanupFuns, disconnectFn)\n\thandleExit(cleanupWG, cleanupFuns...)\n\n\tgCChan := make(chan bool)\n\tdefer close(gCChan)\n\tworker.NewGarbageCollector(kubeClient, dynamicClient, gCChan, s.GCIntervalMin*60, time.Minute*30).StartCleanup()\n\n\tglog.V(1).Infof(\"********** Start running Kubeturbo Service **********\")\n\tk8sTAPService.ConnectToTurbo()\n\tglog.V(1).Info(\"Kubeturbo service is stopped.\")\n\n\tcleanupWG.Wait()\n\tglog.V(1).Info(\"Cleanup completed. Exiting gracefully.\")\n}", "func (s *Server) Run(ctx context.Context) error {\n\th := HealthHandler{\n\t\tservices: map[string]Healthier{\n\t\t\t\"ec2\": s.collectors.EC2,\n\t\t\t\"asg\": s.collectors.ASG,\n\t\t\t\"spot\": s.collectors.Spot,\n\t\t\t\"nodes\": s.collectors.Node,\n\t\t\t\"pods\": s.collectors.Pod,\n\n\t\t\t\"mainloop\": s.mainloop,\n\t\t},\n\t}\n\n\trouter := httprouter.New()\n\trouter.GET(\"/\", s.handleStatus)\n\trouter.GET(\"/-/ready\", webutil.HandleHealth)\n\trouter.Handler(\"GET\", \"/-/healthy\", h)\n\trouter.Handler(\"GET\", \"/metrics\", promhttp.Handler())\n\n\treturn webutil.ListenAndServerWithContext(\n\t\tctx, \":8080\", router)\n}", "func (s *Server) Run(ctx context.Context, wg *sync.WaitGroup) {\n\tif err := s.Config.Validate(); err != nil {\n\t\tlog.Panicf(\"invalid server config: %s\\n\", err)\n\t}\n\n\thandler := &http.Server{\n\t\tHandler: s.Router,\n\t\tAddr: \":\" + strconv.Itoa(s.Config.Port),\n\t}\n\n\tstartServer(ctx, handler, wg)\n}", "func (c *Controller) Run(stopCh <-chan struct{}) error {\n\t// Normally, we let informers start after all controllers. However, in this case we need namespaces to start and sync\n\t// first, so we have DiscoveryNamespacesFilter ready to go. This avoids processing objects that would be filtered during startup.\n\tc.namespaces.Start(stopCh)\n\t// Wait for namespace informer synced, which implies discovery filter is synced as well\n\tif !kube.WaitForCacheSync(\"namespace\", stopCh, c.namespaces.HasSynced) {\n\t\treturn fmt.Errorf(\"failed to sync namespaces\")\n\t}\n\t// run handlers for the config cluster; do not store this *Cluster in the ClusterStore or give it a SyncTimeout\n\t// this is done outside the goroutine, we should block other Run/startFuncs until this is registered\n\tconfigCluster := &Cluster{Client: c.configClusterClient, ID: c.configClusterID}\n\tc.handleAdd(configCluster, stopCh)\n\tgo func() {\n\t\tt0 := time.Now()\n\t\tlog.Info(\"Starting multicluster remote secrets controller\")\n\t\t// we need to start here when local cluster secret watcher enabled\n\t\tif features.LocalClusterSecretWatcher && features.ExternalIstiod {\n\t\t\tc.secrets.Start(stopCh)\n\t\t}\n\t\tif !kube.WaitForCacheSync(\"multicluster remote secrets\", stopCh, c.secrets.HasSynced) {\n\t\t\treturn\n\t\t}\n\t\tlog.Infof(\"multicluster remote secrets controller cache synced in %v\", time.Since(t0))\n\t\tc.queue.Run(stopCh)\n\t}()\n\treturn nil\n}", "func (cli *CLI) Run(args []string) int {\n\tf := flag.NewFlagSet(Name, flag.ContinueOnError)\n\tf.SetOutput(cli.outStream)\n\n\tf.Usage = func() {\n\t\tfmt.Fprintf(cli.outStream, usageText)\n\t\tf.PrintDefaults()\n\t\tfmt.Fprint(cli.outStream, exampleText)\n\t}\n\n\tvar opt Options\n\n\tf.StringVar(&opt.Config, []string{\"c\", \"-config\"}, \"\", \"the path to the configuration file\")\n\tf.StringVar(&opt.Endpoint, []string{\"e\", \"-endpoint\"}, \"\", \"specify github api endpoint\")\n\tf.StringVar(&opt.Token, []string{\"t\", \"-token\"}, \"\", \"github personal token for using API\")\n\tf.StringVar(&opt.Belongs, []string{\"b\", \"-belongs\"}, \"\", \"organization/team on github\")\n\tf.BoolVar(&opt.Syslog, []string{\"s\", \"-syslog\"}, false, \"use syslog for log output\")\n\tf.BoolVar(&opt.Version, []string{\"v\", \"-version\"}, false, \"print the version and exit\")\n\n\tif err := f.Parse(args[1:]); err != nil {\n\t\treturn ExitCodeError\n\t}\n\tparsedArgs := f.Args()\n\n\tif opt.Version {\n\t\tfmt.Fprintf(cli.outStream, \"%s version %s\\n\", Name, Version)\n\t\treturn ExitCodeOK\n\t}\n\n\tif len(parsedArgs) == 0 {\n\t\tf.Usage()\n\t\treturn ExitCodeOK\n\t}\n\n\tif parsedArgs[0] != \"keys\" && parsedArgs[0] != \"pam\" {\n\t\tfmt.Fprintf(cli.errStream, \"invalid argument: %s\\n\", parsedArgs[0])\n\t\treturn ExitCodeError\n\t}\n\n\tc := NewConfig(&opt)\n\toct := NewOctopass(c, cli, nil)\n\tif err := oct.Run(parsedArgs); err != nil {\n\t\tfmt.Fprintf(cli.errStream, \"%s\\n\", err)\n\t\treturn ExitCodeError\n\t}\n\n\treturn ExitCodeOK\n}", "func (s *SystemService) Run() error {\n\tlogger.Log(\"running service\")\n\n\tname := s.Command.Name\n\tdebugOn := s.Command.Debug\n\n\tvar err error\n\tif debugOn {\n\t\telog = debug.New(name)\n\t} else {\n\t\telog, err = eventlog.Open(name)\n\t\tif err != nil {\n\t\t\tlogger.Log(\"error opening logs: \", err)\n\t\t\treturn err\n\t\t}\n\t}\n\tdefer elog.Close()\n\n\tlogger.Log(\"starting service: \", name)\n\telog.Info(1, fmt.Sprintf(\"starting %s service\", name))\n\n\trun := svc.Run\n\tif debugOn {\n\t\trun = debug.Run\n\t}\n\n\terr = run(name, &windowsService{})\n\tif err != nil {\n\t\tlogger.Log(\"error running service: \", err)\n\t\telog.Error(1, fmt.Sprintf(\"%s service failed: %v\", name, err))\n\t\treturn err\n\t}\n\n\tlogger.Log(\"service stopped: \", name)\n\telog.Info(1, fmt.Sprintf(\"%s service stopped\", name))\n\n\t// if err := svc.Run(s.Command.Name, &windowsService{}); err != nil {\n\t// \treturn err\n\t// }\n\n\treturn nil\n}", "func (o *Options) Run() error {\n\tclusterConfig, err := loadClusterConfig()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to load cluster config: %v\", err)\n\t}\n\n\tclient, err := kubernetes.NewForConfig(clusterConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tprowJobClient, err := kube.NewClientInCluster(o.ProwJobNamespace)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcontroller := artifact_uploader.NewController(client.CoreV1(), prowJobClient, o.Options)\n\n\tstop := make(chan struct{})\n\tdefer close(stop)\n\tgo controller.Run(o.NumWorkers, stop)\n\n\t// Wait forever\n\tselect {}\n}", "func (b *Builder) Run() error {\n\tdefer b.Cleanup()\n\tlogrus.Debug(b.Options)\n\n\tfor _, s := range b.steps {\n\t\terr := s()\n\t\tif err != nil {\n\t\t\treturn errors.WithStack(err)\n\t\t}\n\t\tos.Chdir(b.Root)\n\t}\n\treturn nil\n}", "func Run(ctx app.Context) {\n\t// //////////////////////////////////////////////////////////////////////\n\t// Config and command line\n\t// //////////////////////////////////////////////////////////////////////\n\n\t// Options are set in this order: config -> env var -> cmd line option.\n\t// So first we must apply config files, then do cmd line parsing which\n\t// will apply env vars and cmd line options.\n\n\t// Parse cmd line to get --config files\n\tcmdLine := config.ParseCommandLine(config.Options{})\n\n\t// --config files override defaults if given\n\tconfigFiles := config.DEFAULT_CONFIG_FILES\n\tif cmdLine.Config != \"\" {\n\t\tconfigFiles = cmdLine.Config\n\t}\n\n\t// Parse default options from config files\n\tdef := config.ParseConfigFiles(configFiles, cmdLine.Debug)\n\n\t// Parse env vars and cmd line options, override default config\n\tcmdLine = config.ParseCommandLine(def)\n\n\t// Final options and commands\n\tvar o config.Options = cmdLine.Options\n\tvar c config.Command = cmdLine.Command\n\tif o.Debug {\n\t\tapp.Debug(\"command: %#v\\n\", c)\n\t\tapp.Debug(\"options: %#v\\n\", o)\n\t}\n\n\tif ctx.Hooks.AfterParseOptions != nil {\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"calling hook AfterParseOptions\")\n\t\t}\n\t\tctx.Hooks.AfterParseOptions(&o)\n\n\t\t// Dump options again to see if hook changed them\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"options: %#v\\n\", o)\n\t\t}\n\t}\n\tctx.Options = o\n\tctx.Command = c\n\n\t// //////////////////////////////////////////////////////////////////////\n\t// Help and version\n\t// //////////////////////////////////////////////////////////////////////\n\n\t// Help uses a Request Manager client to fetch the list of all requests.\n\t// If addr is set, then this works; else, ignore and always print help.\n\trmc, _ := makeRMC(&ctx)\n\n\t// spinc with no args (Args[0] = \"spinc\" itself). Print short request help\n\t// because Ryan is very busy.\n\tif len(os.Args) == 1 {\n\t\tconfig.Help(false, rmc)\n\t\tos.Exit(0)\n\t}\n\n\t// spinc --help or spinc help (full help)\n\tif o.Help || (c.Cmd == \"help\" && len(c.Args) == 0) {\n\t\tconfig.Help(true, rmc)\n\t\tos.Exit(0)\n\t}\n\n\t// spinc help <command>\n\tif c.Cmd == \"help\" && len(c.Args) > 0 {\n\t\t// Need rm client for this\n\t\tif rmc == nil {\n\t\t\tvar err error\n\t\t\trmc, err = makeRMC(&ctx)\n\t\t\tif err != nil {\n\t\t\t\tfmt.Fprintln(os.Stderr, err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t}\n\t\treqName := c.Args[0]\n\t\tif err := config.RequestHelp(reqName, rmc); err != nil {\n\t\t\tswitch err {\n\t\t\tcase config.ErrUnknownRequest:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Unknown request: %s. Run spinc (no arguments) to list all requests.\\n\", reqName)\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"API error: %s. Use --ping to test the API connection.\\n\", err)\n\t\t\t}\n\t\t\tos.Exit(1)\n\t\t}\n\t\tos.Exit(0)\n\t}\n\n\t// spinc --version or spinc version\n\tif o.Version || c.Cmd == \"version\" {\n\t\tfmt.Println(\"spinc v0.0.0\")\n\t\tos.Exit(0)\n\t}\n\n\t// //////////////////////////////////////////////////////////////////////\n\t// Request Manager Client\n\t// //////////////////////////////////////////////////////////////////////\n\tif rmc == nil {\n\t\tvar err error\n\t\trmc, err = makeRMC(&ctx)\n\t\tif err != nil {\n\t\t\tfmt.Fprintln(os.Stderr, err)\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\t// //////////////////////////////////////////////////////////////////////\n\t// Ping\n\t// //////////////////////////////////////////////////////////////////////\n\tif o.Ping {\n\t\tif _, err := rmc.RequestList(); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Ping failed: %s\\n\", err)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tfmt.Printf(\"%s OK\\n\", o.Addr)\n\t\tos.Exit(0)\n\t}\n\n\t// //////////////////////////////////////////////////////////////////////\n\t// Commands\n\t// //////////////////////////////////////////////////////////////////////\n\tcmdFactory := &cmd.DefaultFactory{}\n\n\tvar err error\n\tvar run app.Command\n\tif ctx.Factories.Command != nil {\n\t\trun, err = ctx.Factories.Command.Make(c.Cmd, ctx)\n\t\tif err != nil {\n\t\t\tswitch err {\n\t\t\tcase cmd.ErrNotExist:\n\t\t\t\tif o.Debug {\n\t\t\t\t\tapp.Debug(\"user cmd factory cannot make a %s cmd, trying default factory\", c.Cmd)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"User command factory error: %s\\n\", err)\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t}\n\t}\n\tif run == nil {\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"using default factory to make a %s cmd\", c.Cmd)\n\t\t}\n\t\trun, err = cmdFactory.Make(c.Cmd, ctx)\n\t\tif err != nil {\n\t\t\tswitch err {\n\t\t\tcase cmd.ErrNotExist:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Unknown command: %s. Run 'spinc help' to list commands.\\n\", c.Cmd)\n\t\t\tdefault:\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Command factory error: %s\\n\", err)\n\t\t\t}\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\tif err := run.Prepare(); err != nil {\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"%s Prepare error: %s\", c.Cmd, err)\n\t\t}\n\t\tswitch err {\n\t\tcase config.ErrUnknownRequest:\n\t\t\treqName := c.Args[0]\n\t\t\tfmt.Fprintf(os.Stderr, \"Unknown request: %s. Run spinc (no arguments) to list all requests.\\n\", reqName)\n\t\tdefault:\n\t\t\tfmt.Fprintln(os.Stderr, err)\n\t\t}\n\t\tos.Exit(1)\n\t}\n\n\tif err := run.Run(); err != nil {\n\t\tif o.Debug {\n\t\t\tapp.Debug(\"%s Run error: %s\", c.Cmd, err)\n\t\t}\n\t\tfmt.Fprintln(os.Stderr, err)\n\t\tos.Exit(1)\n\t}\n}", "func (s *Server) Run(\n\t// Common\n\tctx context.Context,\n\tlog logger.Logger,\n\ttracer *trace.TracerProvider,\n) (*Server, error) {\n\t// API port\n\tviper.SetDefault(\"API_PORT\", 7070) // nolint:gomnd\n\t// Request Timeout (seconds)\n\tviper.SetDefault(\"API_TIMEOUT\", \"60s\")\n\n\tconfig := http_server.Config{\n\t\tPort: viper.GetInt(\"API_PORT\"),\n\t\tTimeout: viper.GetDuration(\"API_TIMEOUT\"),\n\t}\n\n\tg := errgroup.Group{}\n\n\tg.Go(func() error {\n\t\treturn s.run(\n\t\t\tctx,\n\t\t\tconfig,\n\t\t\tlog,\n\t\t\ttracer,\n\t\t)\n\t})\n\n\treturn s, nil\n}", "func (d Driver) Run(name, confTarget, hostVolume string, args []string) error {\n\td.containerID = fmt.Sprintf(\"maestro-%s\", name)\n\td.confTarget = confTarget\n\td.hostVolume = hostVolume\n\td.cmd = args\n\tneedToPull, checkErr := d.needToPull(context.Background())\n\tif checkErr != nil {\n\t\treturn checkErr\n\t}\n\tif needToPull {\n\t\tpullErr := d.pull(context.Background())\n\t\tif pullErr != nil {\n\t\t\treturn pullErr\n\t\t}\n\t}\n\tneedToRemoveOld, removalID, checkRemoveErr := d.needToRemove(context.Background())\n\tif checkRemoveErr != nil {\n\t\treturn checkRemoveErr\n\t}\n\tif needToRemoveOld {\n\t\tremoveErr := d.remove(context.Background(), removalID)\n\t\tif removeErr != nil {\n\t\t\treturn removeErr\n\t\t}\n\t}\n\tcreateErr := d.create(context.Background())\n\tif createErr != nil {\n\t\treturn createErr\n\t}\n\treturn d.start(context.Background())\n}", "func Run(cfg *config.Config, opts *Options) error {\n\t// TODO https://github.com/kube-compose/kube-compose/issues/2 accept context as a parameter\n\tu := &upRunner{\n\t\tcfg: cfg,\n\t\topts: opts,\n\t}\n\tu.hostAliases.once = &sync.Once{}\n\tu.localImagesCache.once = &sync.Once{}\n\treturn u.run()\n}", "func (o *ConfigCleanOption) Run(cmd *cobra.Command, args []string) (err error) {\n\tif config := getConfig(); config == nil {\n\t\tcmd.Println(\"cannot found config file\")\n\t}\n\to.Logger = cmd\n\n\titemCount := len(config.JenkinsServers)\n\tcheckResult := make(chan CheckResult, itemCount)\n\n\tfor _, jenkins := range config.JenkinsServers {\n\t\tgo func(target cfg.JenkinsServer) {\n\t\t\tcheckResult <- o.Check(target)\n\t\t}(jenkins)\n\t}\n\n\tcheckResultList := make([]CheckResult, itemCount)\n\tfor i := range config.JenkinsServers {\n\t\tcheckResultList[i] = <-checkResult\n\t}\n\n\t// do the clean work\n\terr = o.CleanByCondition(checkResultList)\n\tcmd.Println()\n\treturn\n}", "func (r Reflector) Run(ctx context.Context) error {\n\n\n\tctx, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\n\n\t// Grab all goroutines error into err\n\tvar err error\n\terrLock := sync.Mutex{}\n\twg := &sync.WaitGroup{}\n\n\t// Goroutine fetch events from API server and schedule them\n\twg.Add(1)\n\tgo func() {\n\t\tdefer wg.Done()\n\t\tif gErr := r.runFetcher(ctx); gErr != nil {\n\t\t\terrLock.Lock()\n\t\t\terr = multierr.Append(err, gErr)\n\t\t\terrLock.Unlock()\n\t\t\tr.log.Errorw(\"Error during fetching events. Send signal to stop\", zap.Error(err))\n\t\t\tcancel()\n\t\t} else {\n\t\t\tr.log.Info(\"Event fetcher was stopped\")\n\t\t}\n\t}()\n\n\n\t// Handler. Can re-schedule event if temporary error happens\n\tfor i := 0; i < r.workersCount; i++ {\n\t\twg.Add(1)\n\t\tlog := r.log.With(\"WorkerID\", i)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tr.runProcessor(log)\n\t\t\tlog.Info(\"Worker was stopped\")\n\t\t}()\n\t}\n\tr.log.Infof(\"Start %d workers\", r.workersCount)\n\n\tgo func() {\n\t\t<-ctx.Done()\n\t\tr.log.Debug(\"Get cancel signal. Shutdown queue\")\n\t\tr.queue.ShutDown()\n\t}()\n\n\twg.Wait()\n\n\treturn err\n}", "func (eng *Engine) Run(opts Options) error {\n\tctx := ContextForOptions(opts)\n\n\t// Run the deploy and return if everything works.\n\tfinalErr := eng.runDeploy(ctx)\n\tif finalErr == nil {\n\t\treturn nil\n\t}\n\n\tfmt.Println(strings.Repeat(\"*\", 80))\n\tfmt.Println(\"An error was encountered while deploying the application\")\n\tfmt.Printf(\"The error message was: %v\\n\", finalErr)\n\tfmt.Println(strings.Repeat(\"*\", 80))\n\n\tif err := eng.runRollback(ctx); err != nil {\n\t\treturn nil\n\t}\n\n\treturn finalErr\n}", "func (c *ConfigController) Run(threadiness int, stopCh <-chan struct{}) error {\n\tdefer func() {\n\t\tc.queue.ShutDown()\n\t}()\n\n\tglog.V(3).Infoln(\"Creating CDI config\")\n\tif _, err := CreateCDIConfig(c.client, c.cdiClientSet, c.configName); err != nil {\n\t\truntime.HandleError(err)\n\t\treturn errors.Wrap(err, \"Error creating CDI config\")\n\t}\n\n\tglog.V(3).Infoln(\"Starting config controller Run loop\")\n\tif threadiness < 1 {\n\t\treturn errors.Errorf(\"expected >0 threads, got %d\", threadiness)\n\t}\n\n\tif ok := cache.WaitForCacheSync(stopCh, c.ingressesSynced, c.routesSynced); !ok {\n\t\treturn errors.New(\"failed to wait for caches to sync\")\n\t}\n\n\tglog.V(3).Infoln(\"ConfigController cache has synced\")\n\n\tfor i := 0; i < threadiness; i++ {\n\t\tgo wait.Until(c.runWorker, time.Second, stopCh)\n\t}\n\n\tglog.Info(\"Started workers\")\n\t<-stopCh\n\tglog.Info(\"Shutting down workers\")\n\treturn nil\n}", "func (o *CreateTerraformOptions) Run() error {\n\n\tif len(o.Flags.Cluster) > 1 {\n\t\terr := o.validateClusterDetails()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(o.Flags.Cluster) == 0 {\n\t\terr := o.ClusterDetailsWizard()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tlog.Infof(\"Creating clusters %v\", o.Clusters)\n\n\terr := o.createOrganisationGitRepo()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (a *Agent) Run() error {\n\t/*\n\t* Start the agent service\n\t*\n\t* Tasks:\n\t* - Initialize Redis connection\n\t* - Start the http debug server and metrics endpoint\n\t* - Start the executor responsible for ensuring node state\n\t */\n\tvar errChan = make(chan error, 1)\n\n\tgo func(errChan chan error) {\n\t\tlog.Infof(\"Starting http server on %s\", a.httpServer.GetListenAddr())\n\t\terrChan <- a.httpServer.Run()\n\t}(errChan)\n\n\tgo func(errChan chan error) {\n\t\tlog.Info(\"Starting executor\")\n\t\terrChan <- a.executor.Run()\n\t}(errChan)\n\n\treturn <-errChan\n}", "func (cli *CLI) Run(args []string) int {\n\t// Define option flag parse\n\tflags := flag.NewFlagSet(Name, flag.ContinueOnError)\n\tflags.SetOutput(cli.errStream)\n\n\tflags.BoolVar(&cli.nonum, \"nonum\", false, \"hide line numbers\")\n\tflags.StringVar(&cli.delim, \"delim\", \":\", \"a delimiter that separates elements of an argument\")\n\n\tflVersion := flags.Bool(\"version\", false, \"Print version information and quit.\")\n\n\t// Parse commandline flag\n\tif err := flags.Parse(args[1:]); err != nil {\n\t\treturn ExitCodeError\n\t}\n\n\t// Show version\n\tif *flVersion {\n\t\tfmt.Fprintf(cli.errStream, \"%s version %s\\n\", Name, Version)\n\t\treturn ExitCodeOK\n\t}\n\n\tif e := cli.split(flags.Args()); e != nil {\n\t\tfmt.Fprintf(cli.errStream, \"Error splitting %s: %s\\n\", flag.Args(), e)\n\t\treturn ExitCodeError\n\t}\n\n\treturn ExitCodeOK\n}", "func (rnr *Runner) Run(args map[string]interface{}) (err error) {\n\n\trnr.Log.Debug(\"** Run **\")\n\n\t// signal channel\n\tsigChan := make(chan os.Signal, 1)\n\tsignal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)\n\n\t// run HTTP server\n\tgo func() {\n\t\trnr.Log.Debug(\"** Running HTTP server process **\")\n\t\terr = rnr.RunHTTPFunc(args)\n\t\tif err != nil {\n\t\t\trnr.Log.Error(\"Failed run server >%v<\", err)\n\t\t\tsigChan <- syscall.SIGTERM\n\t\t}\n\t\trnr.Log.Debug(\"** HTTP server process ended **\")\n\t}()\n\n\t// run daemon server\n\tgo func() {\n\t\trnr.Log.Debug(\"** Running daemon process **\")\n\t\terr = rnr.RunDaemonFunc(args)\n\t\tif err != nil {\n\t\t\trnr.Log.Error(\"Failed run daemon >%v<\", err)\n\t\t\tsigChan <- syscall.SIGTERM\n\t\t}\n\t\trnr.Log.Debug(\"** Daemon process ended **\")\n\t}()\n\n\t// wait\n\tsig := <-sigChan\n\n\tvar m runtime.MemStats\n\truntime.ReadMemStats(&m)\n\n\tbToMb := func(b uint64) uint64 {\n\t\treturn b / 1024 / 1024\n\t}\n\n\terr = fmt.Errorf(\"Received SIG >%v< Mem Alloc >%d MiB< TotalAlloc >%d MiB< Sys >%d MiB< NumGC >%d<\",\n\t\tsig,\n\t\tbToMb(m.Alloc),\n\t\tbToMb(m.TotalAlloc),\n\t\tbToMb(m.Sys),\n\t\tm.NumGC,\n\t)\n\n\trnr.Log.Warn(\">%v<\", err)\n\n\treturn err\n}", "func (d *driver) Run(ctx context.Context) (ok bool) {\n\tprepareBaseConfig()\n\tprepareCertBundle()\n\tgo d.ensureAllRegistriesAreRunning()\n\n\tinnerCtx, cancel := context.WithCancel(ctx)\n\tprocessExitChan := make(chan processExitMessage)\n\tpc := processContext{\n\t\tContext: innerCtx,\n\t\tProcessExitChan: processExitChan,\n\t}\n\n\t//Overview of how this main loop works:\n\t//\n\t//1. Each call to pc.startRegistry() spawns a keppel-registry process.\n\t// pc.startRegistry() will launch some goroutines that manage the child\n\t// process during its lifetime. Those goroutines are tracked by\n\t// pc.WaitGroup.\n\t//\n\t//2. When the original ctx expires, the aforementioned goroutines will\n\t// cleanly shutdown all keppel-registry processes. When they're done\n\t// shutting down, the main loop (which is waiting on pc.WaitGroup) unblocks\n\t// and returns true.\n\t//\n\t//3. Abnormal termination of a single keppel-registry process is not a fatal\n\t// error. Its observing goroutine will send a processExitMessage that the\n\t// main loop uses to update its bookkeeping accordingly. The next request\n\t// for that Keppel account will launch a new keppel-registry process.\n\t//\n\tok = true\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\t//silence govet (cancel() is a no-op since ctx and therefore innerCtx has\n\t\t\t//already expired, but govet cannot understand that and suspects a context leak)\n\t\t\tcancel()\n\t\t\t//wait on child processes\n\t\t\tpc.WaitGroup.Wait()\n\t\t\treturn ok\n\n\t\tcase msg := <-processExitChan:\n\t\t\tdelete(d.listenPorts, msg.AccountName)\n\n\t\tcase req := <-d.getPortRequestChan:\n\t\t\tport, exists := d.listenPorts[req.Account.Name]\n\t\t\tif !exists {\n\t\t\t\td.nextListenPort++\n\t\t\t\tport = d.nextListenPort\n\t\t\t\terr := pc.startRegistry(req.Account, port)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlogg.Error(\"[account=%s] failed to start keppel-registry: %s\", req.Account.Name, err.Error())\n\t\t\t\t\t//failure to start new keppel-registries is considered a fatal error\n\t\t\t\t\tok = false\n\t\t\t\t\tcancel()\n\t\t\t\t}\n\t\t\t}\n\t\t\td.listenPorts[req.Account.Name] = port\n\t\t\tif req.Result != nil { //is nil when called from ensureAllRegistriesAreRunning()\n\t\t\t\treq.Result <- port\n\t\t\t}\n\t\t}\n\t}\n}", "func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {\n\tdefer runtime.HandleCrash()\n\tdefer c.workqueue.ShutDown()\n\n\t// Start the informer factories to begin populating the informer caches\n\tglog.Info(\"Starting virtualservices control loop\")\n\n\t// Wait for the caches to be synced before starting workers\n\tglog.Info(\"Waiting for informer caches to sync\")\n\tif ok := cache.WaitForCacheSync(stopCh, c.virtualservicesSynced); !ok {\n\t\treturn fmt.Errorf(\"failed to wait for caches to sync\")\n\t}\n\n\tglog.Info(\"Starting workers\")\n\t// Launch workers to process virtualservices resources\n\tfor i := 0; i < threadiness; i++ {\n\t\tgo wait.Until(c.runWorker, time.Second, stopCh)\n\t}\n\n\tglog.Info(\"Started workers\")\n\t<-stopCh\n\tglog.Info(\"Shutting down workers\")\n\n\treturn nil\n}", "func (s *ServiceManager) Run(routine func(ctx context.Context) error) (err error) {\n\ts.Start(routine)\n\treturn s.Wait()\n}", "func (manager *Manager) Run(configManagerID string, configManagerSpec string) error {\n\n\t// We dont want any reloads happening until we are fully running\n\tmanager.configReloadMutex.Lock()\n\n\tif len(configManagerID) > 0 {\n\t\tmanager.InitializeConfigurationManager(configManagerID, configManagerSpec)\n\t}\n\n\tconfiguration := config.Config{}\n\tmanager.InitializeConnectionManagers(configuration)\n\n\tlog.Println(\"Initialization of plugins done.\")\n\n\tlog.Println(\"Initializing the proxy...\")\n\tresolver := NewResolver(manager.ProviderFactories, manager, nil)\n\n\tmanager.Proxy = secretless.Proxy{\n\t\tConfig: configuration,\n\t\tEventNotifier: manager,\n\t\tResolver: resolver,\n\t\tRunHandlerFunc: manager._RunHandler,\n\t\tRunListenerFunc: manager._RunListener,\n\t}\n\n\tmanager.configReloadMutex.Unlock()\n\n\tmanager.Proxy.Run()\n\n\treturn nil\n}", "func (m *Manager) Run(ctx context.Context, run func() error) (err error) {\n\t// Acquire mutex lock\n\tm.mux.Lock()\n\t// Defer the release of mutex lock\n\tdefer m.mux.Unlock()\n\t// Call internal run func\n\treturn m.run(ctx, run)\n}", "func Run(ctx *cli.Context) error {\n\t// new service\n\tsrv := service.New(\n\t\tservice.Name(\"events\"),\n\t)\n\n\t// register the handlers\n\tpb.RegisterStreamHandler(srv.Server(), new(handler.Stream))\n\tpb.RegisterStoreHandler(srv.Server(), new(handler.Store))\n\n\t// run the service\n\tif err := srv.Run(); err != nil {\n\t\tlogger.Fatal(err)\n\t}\n\n\treturn nil\n}", "func Run(version, buildTime string) int {\n\tdefer glog.Flush() // always flush\n\n\trmain := initDaemon(version, buildTime)\n\terr := daemon.rg.run(rmain)\n\n\tif err == nil {\n\t\tglog.Infoln(\"Terminated OK\")\n\t\treturn 0\n\t}\n\tif e, ok := err.(*cos.ErrSignal); ok {\n\t\tglog.Infof(\"Terminated OK via %v\", e)\n\t\treturn e.ExitCode()\n\t}\n\tif errors.Is(err, cmn.ErrStartupTimeout) {\n\t\t// NOTE: stats and keepalive runners wait for the ClusterStarted() - i.e., for the primary\n\t\t// to reach the corresponding stage. There must be an external \"restarter\" (e.g. K8s)\n\t\t// to restart the daemon if the primary gets killed or panics prior (to reaching that state)\n\t\tglog.Errorln(\"Timed-out while starting up\")\n\t}\n\tglog.Errorf(\"Terminated with err: %v\", err)\n\treturn 1\n}", "func (r chiRouter) Run(cfg config.ServiceConfig) {\n\tr.cfg.Engine.Use(r.cfg.Middlewares...)\n\tif cfg.Debug {\n\t\tr.registerDebugEndpoints()\n\t}\n\n\tr.cfg.Engine.Get(\"/__health\", mux.HealthHandler)\n\n\tserver.InitHTTPDefaultTransport(cfg)\n\n\tr.registerKrakendEndpoints(cfg.Endpoints)\n\n\tr.cfg.Engine.NotFound(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(server.CompleteResponseHeaderName, server.HeaderIncompleteResponseValue)\n\t\thttp.NotFound(w, r)\n\t})\n\n\tif err := r.RunServer(r.ctx, cfg, r.cfg.Engine); err != nil {\n\t\tr.cfg.Logger.Error(logPrefix, err.Error())\n\t}\n\n\tr.cfg.Logger.Info(logPrefix, \"Router execution ended\")\n}", "func (s *Server) Run() error {\n\t// configure service routes\n\ts.configureRoutes()\n\n\tlog.Infof(\"Serving '%s - %s' on address %s\", s.Title, s.Version, s.server.Addr)\n\t// server is set to healthy when started.\n\ts.healthy = true\n\tif s.config.InsecureHTTP {\n\t\treturn s.server.ListenAndServe()\n\t}\n\treturn s.server.ListenAndServeTLS(s.config.TLSCertFile, s.config.TLSKeyFile)\n}", "func (e *EndComponent) Run(ctx context.Context, config *ucfg.Config) error {\n\treturn nil\n}", "func Run(s *options.MCMServer) error {\n\t// To help debugging, immediately log version\n\tklog.V(4).Infof(\"Version: %+v\", version.Get())\n\tif err := s.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\tvar err error\n\n\t//kubeconfig for the cluster for which machine-controller-manager will create machines.\n\ttargetkubeconfig, err := clientcmd.BuildConfigFromFlags(\"\", s.TargetKubeconfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcontrolkubeconfig := targetkubeconfig\n\n\tif s.ControlKubeconfig != \"\" {\n\t\tif s.ControlKubeconfig == \"inClusterConfig\" {\n\t\t\t//use inClusterConfig when controller is running inside clus\n\t\t\tcontrolkubeconfig, err = clientcmd.BuildConfigFromFlags(\"\", \"\")\n\t\t} else {\n\t\t\t//kubeconfig for the seedcluster where MachineCRDs are supposed to be registered.\n\t\t\tcontrolkubeconfig, err = clientcmd.BuildConfigFromFlags(\"\", s.ControlKubeconfig)\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// PROTOBUF WONT WORK\n\t// kubeconfig.ContentConfig.ContentType = s.ContentType\n\t// Override kubeconfig qps/burst settings from flags\n\ttargetkubeconfig.QPS = s.KubeAPIQPS\n\tcontrolkubeconfig.QPS = s.KubeAPIQPS\n\ttargetkubeconfig.Burst = int(s.KubeAPIBurst)\n\tcontrolkubeconfig.Burst = int(s.KubeAPIBurst)\n\ttargetkubeconfig.Timeout = targetkubeconfigTimeout\n\tcontrolkubeconfig.Timeout = controlkubeconfigTimeout\n\n\tkubeClientControl, err := kubernetes.NewForConfig(\n\t\trest.AddUserAgent(controlkubeconfig, \"machine-controller-manager\"),\n\t)\n\tif err != nil {\n\t\tklog.Fatalf(\"Invalid API configuration for kubeconfig-control: %v\", err)\n\t}\n\n\tleaderElectionClient := kubernetes.NewForConfigOrDie(rest.AddUserAgent(controlkubeconfig, \"machine-leader-election\"))\n\tklog.V(4).Info(\"Starting http server and mux\")\n\tgo startHTTP(s)\n\n\trecorder := createRecorder(kubeClientControl)\n\n\trun := func(ctx context.Context) {\n\t\tvar stop <-chan struct{}\n\t\t// Control plane client used to interact with machine APIs\n\t\tcontrolMachineClientBuilder := machinecontroller.SimpleClientBuilder{\n\t\t\tClientConfig: controlkubeconfig,\n\t\t}\n\t\t// Control plane client used to interact with core kubernetes objects\n\t\tcontrolCoreClientBuilder := corecontroller.SimpleControllerClientBuilder{\n\t\t\tClientConfig: controlkubeconfig,\n\t\t}\n\t\t// Target plane client used to interact with core kubernetes objects\n\t\ttargetCoreClientBuilder := corecontroller.SimpleControllerClientBuilder{\n\t\t\tClientConfig: targetkubeconfig,\n\t\t}\n\n\t\terr := StartControllers(\n\t\t\ts,\n\t\t\tcontrolkubeconfig,\n\t\t\ttargetkubeconfig,\n\t\t\tcontrolMachineClientBuilder,\n\t\t\tcontrolCoreClientBuilder,\n\t\t\ttargetCoreClientBuilder,\n\t\t\trecorder,\n\t\t\tstop,\n\t\t)\n\n\t\tklog.Fatalf(\"error running controllers: %v\", err)\n\t\tpanic(\"unreachable\")\n\n\t}\n\n\tif !s.LeaderElection.LeaderElect {\n\t\trun(nil)\n\t\tpanic(\"unreachable\")\n\t}\n\n\tid, err := os.Hostname()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\trl, err := resourcelock.New(\n\t\ts.LeaderElection.ResourceLock,\n\t\ts.Namespace,\n\t\t\"machine-controller-manager\",\n\t\tleaderElectionClient.CoreV1(),\n\t\tleaderElectionClient.CoordinationV1(),\n\t\tresourcelock.ResourceLockConfig{\n\t\t\tIdentity: id,\n\t\t\tEventRecorder: recorder,\n\t\t},\n\t)\n\tif err != nil {\n\t\tklog.Fatalf(\"error creating lock: %v\", err)\n\t}\n\n\tctx := context.TODO()\n\tleaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{\n\t\tLock: rl,\n\t\tLeaseDuration: s.LeaderElection.LeaseDuration.Duration,\n\t\tRenewDeadline: s.LeaderElection.RenewDeadline.Duration,\n\t\tRetryPeriod: s.LeaderElection.RetryPeriod.Duration,\n\t\tCallbacks: leaderelection.LeaderCallbacks{\n\t\t\tOnStartedLeading: run,\n\t\t\tOnStoppedLeading: func() {\n\t\t\t\tklog.Fatalf(\"leaderelection lost\")\n\t\t\t},\n\t\t},\n\t})\n\tpanic(\"unreachable\")\n}", "func (s *StatusSyncer) Run(stopCh <-chan struct{}) {\n\ts.queue.Run(stopCh)\n\tcontrollers.ShutdownAll(s.services, s.nodes, s.pods, s.ingressClasses, s.ingresses)\n}", "func (cmd *UpCmd) Run(cobraCmd *cobra.Command, args []string) {\n\tif configutil.ConfigPath != cmd.flags.config {\n\t\tconfigutil.ConfigPath = cmd.flags.config\n\n\t\t// Don't use overwrite config if we use a different config\n\t\tconfigutil.OverwriteConfigPath = \"\"\n\t}\n\n\tlog.StartFileLogging()\n\tvar err error\n\n\tconfigExists, _ := configutil.ConfigExists()\n\tif !configExists {\n\t\tinitCmd := &InitCmd{\n\t\t\tflags: InitCmdFlagsDefault,\n\t\t}\n\n\t\tinitCmd.Run(nil, []string{})\n\n\t\t// Ensure that config is initialized correctly\n\t\tconfigutil.SetDefaultsOnce()\n\t}\n\n\t// Create kubectl client\n\tcmd.kubectl, err = kubectl.NewClientWithContextSwitch(cmd.flags.switchContext)\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create new kubectl client: %v\", err)\n\t}\n\n\t// Create namespace if necessary\n\terr = kubectl.EnsureDefaultNamespace(cmd.kubectl, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create namespace: %v\", err)\n\t}\n\n\t// Create cluster role binding if necessary\n\terr = kubectl.EnsureGoogleCloudClusterRoleBinding(cmd.kubectl, log.GetInstance())\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to create ClusterRoleBinding: %v\", err)\n\t}\n\n\t// Init image registries\n\tif cmd.flags.initRegistries {\n\t\terr = registry.InitRegistries(cmd.kubectl, log.GetInstance())\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n\n\t// Build and deploy images\n\tcmd.buildAndDeploy()\n\n\tif cmd.flags.exitAfterDeploy == false {\n\t\t// Start services\n\t\tcmd.startServices(args)\n\t}\n}", "func (c *CLI) Run(args []string) int {\n\tvar (\n\t\tdebug bool\n\t\tversion bool\n\t)\n\tflags := flag.NewFlagSet(args[0], flag.ContinueOnError)\n\tflags.Usage = func() {\n\t\tfmt.Fprint(c.errStream, helpText)\n\t}\n\tflags.BoolVar(&debug, \"debug\", false, \"\")\n\tflags.BoolVar(&debug, \"d\", false, \"\")\n\tflags.BoolVar(&version, \"version\", false, \"\")\n\tflags.BoolVar(&version, \"v\", false, \"\")\n\n\t// Parse flag\n\tif err := flags.Parse(args[1:]); err != nil {\n\t\treturn ExitCodeParseFlagsError\n\t}\n\n\tif debug {\n\t\tos.Setenv(EnvDebug, \"1\")\n\t\tDebugf(\"Run as DEBUG mode\")\n\t}\n\n\tif version {\n\t\tfmt.Fprintf(c.outStream, fmt.Sprintf(\"%s\\n\", Version))\n\t\treturn ExitCodeOK\n\t}\n\n\tparsedArgs := flags.Args()\n\tif len(parsedArgs) == 0 {\n\t\tPrintErrorf(\"Invalid argument: you must set keyword.\")\n\t\treturn ExitCodeBadArgs\n\t}\n\n\tkeywords := parsedArgs\n\tDebugf(\"keyword: %s\", keywords)\n\n\tsearcher, err := NewClient(keywords)\n\tif err != nil {\n\t\treturn ExitCodeError\n\t}\n\n\tstatus := searcher.search()\n\tif status != ExitCodeOK {\n\t\treturn ExitCodeError\n\t}\n\n\tsearcher.output(c.outStream)\n\n\treturn ExitCodeOK\n}", "func Run(ctx *cli.Context) error {\n\tc, err := NewConfig(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn run(ctx.Context, c)\n}", "func (c *Controller) Run(threadiness int, stopCh <-chan struct{}) error {\n\tdefer utilruntime.HandleCrash()\n\tdefer c.workqueue.ShutDown()\n\t// Start the informer factories to begin populating the informer caches\n\tklog.Info(\"Starting Configurator controller\")\n\n\t// Wait for the caches to be synced before starting workers\n\tklog.Info(\"Waiting for informer caches to sync\")\n\tif ok := cache.WaitForCacheSync(stopCh, c.configmapsSynced, c.customConfigMapSynced); !ok {\n\t\treturn fmt.Errorf(\"failed to wait for caches to sync\")\n\t}\n\n\tklog.Info(\"Waiting for informer caches to sync\")\n\tif ok := cache.WaitForCacheSync(stopCh, c.secretSynced, c.customSecretSynced); !ok {\n\t\treturn fmt.Errorf(\"failed to wait for caches to sync\")\n\t}\n\n\tklog.Info(\"Starting workers\")\n\t// Launch two workers to process configurator resources\n\tfor i := 0; i < threadiness; i++ {\n\t\tgo wait.Until(c.runWorker, time.Second, stopCh)\n\t}\n\n\tklog.Info(\"Started workers\")\n\t<-stopCh\n\tklog.Info(\"Shutting down workers\")\n\n\treturn nil\n}", "func (a *Agent) Run(shutdown chan struct{}) error {\n\tvar wg sync.WaitGroup\n\n\tlog.Printf(\"INFO Agent Config: Interval:%s, Hostname:%#v, Flush Interval:%s \\n\",\n\t\ta.Config.Agent.Interval, a.Config.Agent.Hostname, a.Config.Agent.FlushInterval)\n\n\t// configure all sources\n\tfor _, source := range a.Config.Sources {\n\t\tsource.SetDefaultTags(a.Config.Tags)\n\t}\n\n\t// Start all ServiceSources\n\tfor _, source := range a.Config.Sources {\n\t\tswitch p := source.Source.(type) {\n\t\tcase optic.ServiceSource:\n\t\t\tacc := NewAccumulator(source, source.EventsCh())\n\t\t\tif err := p.Start(acc); err != nil {\n\t\t\t\tlog.Printf(\"ERROR Service for source %s failed to start, exiting\\n%s\\n\",\n\t\t\t\t\tsource.Name(), err.Error())\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tdefer p.Stop()\n\t\t}\n\t}\n\n\twg.Add(len(a.Config.Sources))\n\tfor _, source := range a.Config.Sources {\n\t\tinterval := a.Config.Agent.Interval\n\t\t// overwrite global interval if this plugin has it's own\n\t\tif source.Config.Interval != 0 {\n\t\t\tinterval = source.Config.Interval\n\t\t}\n\t\tgo func(source *models.RunningSource, interval time.Duration) {\n\t\t\tdefer wg.Done()\n\t\t\ta.gatherer(shutdown, source, interval)\n\t\t}(source, interval)\n\t}\n\n\twg.Wait()\n\ta.Close()\n\treturn nil\n}", "func Run() (err error) {\n\n\terr = sm.Run()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = as.Run()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Start Swagger API Manager (provider)\n\terr = apiMgr.Start(true, false)\n\tif err != nil {\n\t\tlog.Error(\"Failed to start Swagger API Manager with error: \", err.Error())\n\t\treturn err\n\t}\n\tlog.Info(\"Swagger API Manager started\")\n\n\t// Add module Swagger APIs\n\terr = apiMgr.AddApis()\n\tif err != nil {\n\t\tlog.Error(\"Failed to add Swagger APIs with error: \", err.Error())\n\t\treturn err\n\t}\n\tlog.Info(\"Swagger APIs successfully added\")\n\n\t// Register Message Queue handler\n\thandler := mq.MsgHandler{Handler: msgHandler, UserData: nil}\n\thandlerId, err = mqLocal.RegisterHandler(handler)\n\tif err != nil {\n\t\tlog.Error(\"Failed to register local Msg Queue listener: \", err.Error())\n\t\treturn err\n\t}\n\tlog.Info(\"Registered local Msg Queue listener\")\n\n\t// Initalize metric store\n\tupdateStoreName()\n\n\treturn nil\n}", "func Run() error {\n\tcloseLogger, err := setupLogger()\n\tif err != nil {\n\t\treturn fail.Wrap(err)\n\t}\n\tdefer closeLogger()\n\n\ts := grapiserver.New(\n\t\tgrapiserver.WithGrpcServerUnaryInterceptors(\n\t\t\tgrpc_ctxtags.UnaryServerInterceptor(grpc_ctxtags.WithFieldExtractor(grpc_ctxtags.CodeGenRequestFieldExtractor)),\n\t\t\tgrpc_zap.UnaryServerInterceptor(zap.L()),\n\t\t\tgrpc_zap.PayloadUnaryServerInterceptor(\n\t\t\t\tzap.L(),\n\t\t\t\tfunc(ctx context.Context, fullMethodName string, servingObject interface{}) bool { return true },\n\t\t\t),\n\t\t),\n\t\tgrapiserver.WithGatewayServerMiddlewares(\n\t\t\tgithubEventDispatcher,\n\t\t),\n\t\tgrapiserver.WithServers(\n\t\t\tgithub.NewInstallationEventServiceServer(),\n\t\t),\n\t)\n\treturn s.Serve()\n}", "func Run(ctx context.Context, client *guardian.Client, config Config) (err error) {\n\tif config.Icon == nil {\n\t\tconfig.Icon = leaseui.DefaultIcon()\n\t}\n\n\trunner, err := New(client, config)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn runner.Run(ctx)\n\n\t/*\n\t\tg, ctx := errgroup.WithContext(ctx)\n\n\t\trun := func() error {\n\t\t\trunner, err := New(client, config)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn runner.Run(ctx)\n\t\t}\n\n\t\tg.Go(run)\n\t\tg.Go(run)\n\n\t\treturn g.Wait()\n\t*/\n}", "func (params *serverParams) Run(context.Context) error {\n\tif params.err != nil && len(params.err) > 0 {\n\t\treturn utilerrors.NewAggregate(params.err)\n\t}\n\n\tvar g errgroup.Group\n\tif params.secureServer != nil {\n\t\tparams.options.Logger.Info(fmt.Sprintf(\"starting %s %s server on %s:%d\", params.options.Name, \"HTTPS\", params.options.SecureAddr, params.options.SecurePort))\n\t\tg.Go(func() error {\n\t\t\treturn params.secureServer.ListenAndServeTLS(params.options.TLSCert, params.options.TLSKey)\n\t\t})\n\t}\n\tif params.insecureServer != nil {\n\t\tparams.options.Logger.Info(fmt.Sprintf(\"starting %s %s server on %s:%d\", params.options.Name, \"HTTP\", params.options.InsecureAddr, params.options.InsecurePort))\n\t\tg.Go(func() error {\n\t\t\treturn params.insecureServer.ListenAndServe()\n\t\t})\n\t}\n\terr := g.Wait()\n\tif err != nil && err != http.ErrServerClosed {\n\t\tparams.options.Logger.Error(err.Error())\n\t\treturn err\n\t}\n\treturn nil\n}", "func Run(t *testing.T, configOpt core.ConfigProvider, sdkOpts ...fabsdk.Option) {\n\tsetupAndRun(t, true, configOpt, e2eTest, sdkOpts...)\n}", "func (cli *CLI) Run() {\n\tcli.validateArgs()\n\n\t//possible commands\n\twallet := cmds.ConfigureCreateWalletCmd()\n\tcreate, createData := cmds.ConfigureCreateChainCmd()\n\tgetBalance, getBalanceData := cmds.ConfigureBalanceCmd()\n\tsend, from, to, amount := cmds.ConfigureSendCmd()\n\tprintChain := cmds.ConfigurePrintCmd()\n\n\tif len(os.Args) >= 1 {\n\t\tswitch os.Args[1] {\n\t\tcase cmds.CreateWalletCmdId:\n\t\t\t_ = wallet.Parse(os.Args[2:])\n\t\tcase cmds.PrintCmdId:\n\t\t\t_ = printChain.Parse(os.Args[2:])\n\t\tcase cmds.CreateChainCmdId:\n\t\t\t_ = create.Parse(os.Args[2:])\n\t\tcase cmds.BalanceCmdId:\n\t\t\t_ = getBalance.Parse(os.Args[2:])\n\t\tcase cmds.SendCmdId:\n\t\t\t_ = send.Parse(os.Args[2:])\n\t\tdefault:\n\t\t\tcli.printUsage()\n\t\t\tos.Exit(1)\n\t\t}\n\t} else {\n\t\tcli.printUsage()\n\t\tos.Exit(1)\n\t\treturn\n\t}\n\n\tif wallet.Parsed() {\n\t\tcli.createWallet()\n\t}\n\n\tif printChain.Parsed() {\n\t\tcli.printChain()\n\t}\n\n\tif create.Parsed() {\n\t\terr := cli.createBlockchain(*createData)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n\n\tif getBalance.Parsed() {\n\t\tif *getBalanceData == \"\" {\n\t\t\tgetBalance.Usage()\n\t\t\tos.Exit(1)\n\t\t}\n\t\terr := cli.getBalance(*getBalanceData)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n\n\tif send.Parsed() {\n\t\tif *from == \"\" || *to == \"\" || *amount <= 0 {\n\t\t\tsend.Usage()\n\t\t\tos.Exit(1)\n\t\t}\n\t\terr := cli.send(*from, *to, *amount)\n\t\tif err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n}", "func (m *Manager) Run() {\n\tgo func() {\n\t\tif err := m.Start(context.Background()); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n}", "func (l *Listen) Run(args []string) int {\n\tconfig.ListenContext = true\n\n\tvar listener, address, cpuprofile string\n\tcmdFlags := flag.NewFlagSet(\"listen\", flag.ContinueOnError)\n\tcmdFlags.Usage = func() { l.UI.Error(l.Help()) }\n\tcmdFlags.StringVar(&listener, \"ln\", \"\", \"\")\n\tcmdFlags.StringVar(&address, \"address\", \"\", \"\")\n\tcmdFlags.StringVar(&cpuprofile, \"cpuprofile\", \"\", \"write cpu profile to file\")\n\tif err := cmdFlags.Parse(args); err != nil {\n\t\treturn 1\n\t}\n\n\targErr := false\n\n\t//Check listener\n\tif listener == \"\" {\n\t\tl.UI.Error(\"Listener name must be specified\")\n\t\targErr = true\n\t}\n\n\t//Check address\n\tif address == \"\" {\n\t\tl.UI.Error(\"Address must be specified\")\n\t\targErr = true\n\t}\n\n\tif argErr {\n\t\tl.UI.Error(\"\")\n\t\tl.UI.Error(l.Help())\n\t\treturn 1\n\t}\n\n\tif cpuprofile != \"\" {\n\t\tf, err := os.Create(cpuprofile)\n\t\tif err != nil {\n\t\t\tl.UI.Error(err.Error())\n\t\t\treturn 1\n\t\t}\n\t\tpprof.StartCPUProfile(f)\n\t\tdefer pprof.StopCPUProfile()\n\t}\n\n\t//Read and record the listener config so it is available to the plugin chain\n\tserviceConfig, err := config.ReadServiceConfig(listener, l.KVStore)\n\tif err != nil {\n\t\tl.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\n\tconfig.RecordActiveConfig(serviceConfig)\n\n\t//Build the service for the named listener\n\ts, err := service.BuildServiceForListener(listener, address, l.KVStore)\n\tif err != nil {\n\t\tl.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\tl.UI.Info(fmt.Sprintf(\"***Service:\\n%s\", s))\n\n\t//Build health check context for the named listerner\n\thcc, err := service.BuildHealthContextForListener(listener, l.KVStore)\n\tif err != nil {\n\t\tl.UI.Error(err.Error())\n\t\treturn 1\n\t}\n\tservice.RecordActiveHealthCheckContext(hcc)\n\n\texitChannel := make(chan int)\n\tsignalChannel := make(chan os.Signal, 1)\n\tsignal.Notify(signalChannel, os.Interrupt)\n\n\tgo func() {\n\t\tfor _ = range signalChannel {\n\t\t\texitChannel <- 0\n\t\t}\n\t}()\n\n\tgo func(service service.Service) {\n\t\tservice.Run()\n\t\t//Run can return if it can't open ports, etc.\n\t\texitChannel <- 1\n\t}(s)\n\n\texitStatus := <-exitChannel\n\tfmt.Printf(\"exiting with status %d\\n\", exitStatus)\n\treturn exitStatus\n}", "func (r *PluginRunner) Run(ctx context.Context, wrapper RunnerUtil, pluginSets map[int]plugin.PluginSet, hs plugin.HandshakeConfig, env []string, logger log.Logger) (*plugin.Client, error) {\n\treturn r.RunConfig(ctx,\n\t\tRunner(wrapper),\n\t\tPluginSets(pluginSets),\n\t\tHandshakeConfig(hs),\n\t\tEnv(env...),\n\t\tLogger(logger),\n\t\tMetadataMode(false),\n\t)\n}" ]
[ "0.67258763", "0.66956735", "0.66749555", "0.6631407", "0.6609172", "0.6555715", "0.6465029", "0.64125794", "0.64101774", "0.64062446", "0.6338222", "0.6321938", "0.63210386", "0.63161224", "0.63157916", "0.6259968", "0.6221255", "0.62152505", "0.61776745", "0.6164499", "0.6158526", "0.613736", "0.61324894", "0.6129859", "0.6089335", "0.6083563", "0.6068427", "0.6067681", "0.6059456", "0.6056985", "0.60530424", "0.60360086", "0.6034598", "0.60243535", "0.59989196", "0.5989384", "0.5978657", "0.5974376", "0.59678537", "0.5965441", "0.5963916", "0.59591943", "0.5958269", "0.59535104", "0.5950086", "0.59409815", "0.59345514", "0.5930353", "0.5924641", "0.5916793", "0.5916686", "0.5916297", "0.5915137", "0.5912678", "0.59110445", "0.59064937", "0.59004736", "0.59001756", "0.5897039", "0.58952594", "0.5892439", "0.5892432", "0.5889571", "0.5889014", "0.5877117", "0.58659005", "0.58652586", "0.58592814", "0.5858116", "0.5853723", "0.5852558", "0.5849522", "0.58477896", "0.5837138", "0.5832099", "0.58220106", "0.58199656", "0.58144397", "0.58138096", "0.58094066", "0.57903475", "0.5788151", "0.5784656", "0.57812744", "0.5779176", "0.5770404", "0.57679963", "0.5767468", "0.5762508", "0.5755075", "0.57534945", "0.5743537", "0.57423544", "0.57297003", "0.5727", "0.572478", "0.57244706", "0.5722258", "0.5720605", "0.5720596" ]
0.7633714
0
ListUnits returns a list of all Group phases and the Units registered to each of them.
func (g Group) ListUnits() string { var ( s string t = "cli" ) if len(g.c) > 0 { s += "\n- config: " for _, u := range g.c { if u != nil { s += u.Name() + " " } } } if len(g.p) > 0 { s += "\n- prerun: " for _, u := range g.p { if u != nil { s += u.Name() + " " } } } if len(g.s) > 0 { s += "\n- serve : " for _, u := range g.s { if u != nil { t = "svc" s += u.Name() + " " } } } return fmt.Sprintf("Group: %s [%s]%s", g.name, t, s) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ListUnits(w http.ResponseWriter) error {\n\tconn, err := sd.NewSystemdConnection()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to get systemd bus connection: %s\", err)\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\n\tunits, err := conn.ListUnits()\n\tif err != nil {\n\t\tlog.Errorf(\"Failed ListUnits: %v\", err)\n\t\treturn err\n\t}\n\n\treturn share.JSONResponse(units, w)\n}", "func cmdUnitList(c *cli.Context) error {\n\tif err := adm.VerifyNoArgument(c); err != nil {\n\t\treturn err\n\t}\n\n\treturn adm.Perform(`get`, `/unit/`, `list`, nil, c)\n}", "func (r *Resolver) Units() (*[]*Unit, error) {\n\tvar result []*Unit\n\tfor _, theirUnit := range units.All() {\n\t\tourUnit, err := NewUnit(theirUnit.Name)\n\t\tif err != nil {\n\t\t\treturn &result, err\n\t\t}\n\t\tresult = append(result, &ourUnit)\n\t}\n\treturn &result, nil\n}", "func listInstalledUnits(ns string, suffix string) ([]string, error) {\n\targs := []string{\n\t\t\"list-units\",\n\t\t\"--no-legend\",\n\t\t\"--no-pager\",\n\t\tfmt.Sprintf(\"%s_*.%s\", ns, suffix),\n\t}\n\tout, err := exec.Command(\"systemctl\", args...).Output()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn parseListUnits(string(out), ns, suffix)\n}", "func (st *Tools) GetUnitNames() (units []string, err error) {\n\tfiles, err := ioutil.ReadDir(\"/etc/systemd/system/dcos.target.wants\")\n\tif err != nil {\n\t\treturn units, err\n\t}\n\tfor _, f := range files {\n\t\tunits = append(units, f.Name())\n\t}\n\tlogrus.Debugf(\"List of units: %s\", units)\n\treturn units, nil\n}", "func getUnits(app *App, names []string) unitList {\n\tvar units []Unit\n\tif len(names) > 0 {\n\t\tfor _, unitName := range names {\n\t\t\tfor _, appUnit := range app.Units {\n\t\t\t\tif appUnit.Name == unitName {\n\t\t\t\t\tunits = append(units, appUnit)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn unitList(units)\n}", "func UnitNames() [7]string {\n\treturn unitNames\n}", "func NewList(slice []Unit) List {\n\treturn unitlist{slice}\n}", "func (usl UnitStatusList) Group() (UnitStatusList, error) {\n\tmatchers := map[string]struct{}{}\n\tnewList := []fleet.UnitStatus{}\n\n\thashesEqual, err := allHashesEqual(usl)\n\tif err != nil {\n\t\treturn nil, maskAny(err)\n\t}\n\n\tfor _, us := range usl {\n\t\t// Group unit status\n\t\tgrouped, suffix, err := groupUnitStatus(usl, us)\n\t\tif err != nil {\n\t\t\treturn nil, maskAny(err)\n\t\t}\n\n\t\t// Prevent doubled aggregation.\n\t\tif _, ok := matchers[suffix]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tmatchers[suffix] = struct{}{}\n\n\t\tstatesEqual := allStatesEqual(grouped)\n\n\t\t// Aggregate.\n\t\tif hashesEqual && statesEqual {\n\t\t\tnewStatus := grouped[0]\n\t\t\tnewStatus.Name = \"*\"\n\t\t\tnewList = append(newList, newStatus)\n\t\t} else {\n\t\t\tnewList = append(newList, grouped...)\n\t\t}\n\t}\n\n\treturn newList, nil\n}", "func (m *MeasurementFamilyListUnits) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateUnitCode(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *MemoryArrayAllOf) GetUnits() []MemoryUnitRelationship {\n\tif o == nil {\n\t\tvar ret []MemoryUnitRelationship\n\t\treturn ret\n\t}\n\treturn o.Units\n}", "func (s *ServiceOp) List(ctx context.Context, input *ListGroupsInput) (*ListGroupsOutput, error) {\n\tr := client.NewRequest(http.MethodGet, \"/azure/compute/group\")\n\tresp, err := client.RequireOK(s.Client.Do(ctx, r))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tgs, err := groupsFromHttpResponse(resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &ListGroupsOutput{Groups: gs}, nil\n}", "func (c *tiKVGroups) List(opts v1.ListOptions) (result *v1alpha1.TiKVGroupList, err error) {\n\tvar timeout time.Duration\n\tif opts.TimeoutSeconds != nil {\n\t\ttimeout = time.Duration(*opts.TimeoutSeconds) * time.Second\n\t}\n\tresult = &v1alpha1.TiKVGroupList{}\n\terr = c.client.Get().\n\t\tNamespace(c.ns).\n\t\tResource(\"tikvgroups\").\n\t\tVersionedParams(&opts, scheme.ParameterCodec).\n\t\tTimeout(timeout).\n\t\tDo().\n\t\tInto(result)\n\treturn\n}", "func (s *ServiceOp) List(ctx context.Context, input *ListGroupsInput) (*ListGroupsOutput, error) {\n\tr := client.NewRequest(http.MethodGet, \"/compute/azure/group\")\n\tresp, err := client.RequireOK(s.Client.Do(ctx, r))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tgs, err := groupsFromHttpResponse(resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &ListGroupsOutput{Groups: gs}, nil\n}", "func (c *awsWafregionalRuleGroups) List(opts meta_v1.ListOptions) (result *v1.AwsWafregionalRuleGroupList, err error) {\n\tresult = &v1.AwsWafregionalRuleGroupList{}\n\terr = c.client.Get().\n\t\tNamespace(c.ns).\n\t\tResource(\"awswafregionalrulegroups\").\n\t\tVersionedParams(&opts, scheme.ParameterCodec).\n\t\tDo().\n\t\tInto(result)\n\treturn\n}", "func (c *tiDBGroups) List(opts v1.ListOptions) (result *v1alpha1.TiDBGroupList, err error) {\n\tvar timeout time.Duration\n\tif opts.TimeoutSeconds != nil {\n\t\ttimeout = time.Duration(*opts.TimeoutSeconds) * time.Second\n\t}\n\tresult = &v1alpha1.TiDBGroupList{}\n\terr = c.client.Get().\n\t\tNamespace(c.ns).\n\t\tResource(\"tidbgroups\").\n\t\tVersionedParams(&opts, scheme.ParameterCodec).\n\t\tTimeout(timeout).\n\t\tDo().\n\t\tInto(result)\n\treturn\n}", "func (s *GroupsService) List(opt ...CallOption) ([]*Group, *Response, error) {\n\tgroups, resp, err := listGroup(s.client, \"groups\", opt...)\n\n\treturn groups, resp, err\n}", "func (o *MemoryArrayAllOf) SetUnits(v []MemoryUnitRelationship) {\n\to.Units = v\n}", "func (o *DataExportQuery) SetUnits(v int32) {\n\to.Units = &v\n}", "func (me *masterExtension) Units() ([]k8scloudconfig.UnitAsset, error) {\n\tunitsMeta := []k8scloudconfig.UnitMetadata{\n\t\t{\n\t\t\tAssetContent: ignition.AzureCNINatRules,\n\t\t\tName: \"azure-cni-nat-rules.service\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.CertificateDecrypterUnit,\n\t\t\tName: \"certificate-decrypter.service\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.EtcdMountUnit,\n\t\t\tName: \"var-lib-etcd.mount\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.DockerMountUnit,\n\t\t\tName: \"var-lib-docker.mount\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.KubeletMountUnit,\n\t\t\tName: \"var-lib-kubelet.mount\",\n\t\t\tEnabled: true,\n\t\t},\n\t\t{\n\t\t\tAssetContent: ignition.VNICConfigurationUnit,\n\t\t\tName: \"vnic-configuration.service\",\n\t\t\tEnabled: true,\n\t\t},\n\t}\n\n\tdata := me.templateData(me.certFiles)\n\n\t// To use the certificate decrypter unit for the etcd data encryption config file.\n\tdata.certificateDecrypterUnitParams.CertsPaths = append(data.certificateDecrypterUnitParams.CertsPaths, encryptionConfigFilePath)\n\n\tvar newUnits []k8scloudconfig.UnitAsset\n\n\tfor _, fm := range unitsMeta {\n\t\tc, err := k8scloudconfig.RenderAssetContent(fm.AssetContent, data)\n\t\tif err != nil {\n\t\t\treturn nil, microerror.Mask(err)\n\t\t}\n\n\t\tunitAsset := k8scloudconfig.UnitAsset{\n\t\t\tMetadata: fm,\n\t\t\tContent: c,\n\t\t}\n\n\t\tnewUnits = append(newUnits, unitAsset)\n\t}\n\n\treturn newUnits, nil\n}", "func (o *EquipmentBaseSensor) GetUnits() string {\n\tif o == nil || o.Units == nil {\n\t\tvar ret string\n\t\treturn ret\n\t}\n\treturn *o.Units\n}", "func (o *EquipmentBaseSensor) SetUnits(v string) {\n\to.Units = &v\n}", "func (s *GroupsService) List(ctx context.Context, opts *PagingOptions) (*GroupList, error) {\n\tquery := addPaging(url.Values{}, opts)\n\treq, err := s.Client.NewRequest(ctx, http.MethodGet, newURI(groupsURI), WithQuery(query))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"list groups failed: , %w\", err)\n\t}\n\tres, resp, err := s.Client.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"list groups failed: , %w\", err)\n\t}\n\n\tif resp != nil && resp.StatusCode == http.StatusNotFound {\n\t\treturn nil, ErrNotFound\n\t}\n\n\tg := &GroupList{\n\t\tGroups: []*Group{},\n\t}\n\tif err := json.Unmarshal(res, g); err != nil {\n\t\treturn nil, fmt.Errorf(\"list groups failed, unable to unmarshal repository list json: , %w\", err)\n\t}\n\n\tfor _, r := range g.GetGroups() {\n\t\tr.Session.set(resp)\n\t}\n\n\treturn g, nil\n}", "func (m *MeasurementFamilyListUnitsUnitCode) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateConvertFromStandard(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateLabels(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func Unit_Values() []string {\n\treturn []string{\n\t\tUnitSeconds,\n\t\tUnitCount,\n\t\tUnitPercent,\n\t}\n}", "func (d *drawer) DrawUnitList(units []swgohhelp.Unit) ([]byte, error) {\n\t// 5 per row, 100px per unit, 10px padding\n\tpadding := 30\n\tportraitSize := 100\n\tunitSize := portraitSize + padding*2\n\twidth := unitSize * 5\n\theight := unitSize * int(math.Ceil((float64(len(units)) / 5.0)))\n\n\tcanvas := gg.NewContext(width, height)\n\tcanvas.SetHexColor(\"#0D1D25\")\n\tcanvas.Clear()\n\n\t// Use an asset bundle to save some disk I/O\n\tbundle := &assetBundle{\n\t\tui: make(map[string]image.Image),\n\t}\n\n\t// draw each unit portrait\n\tx, y := padding, padding\n\tfor unitCount, u := range units {\n\t\t// Draw portrait\n\t\tportrait, err := loadAsset(fmt.Sprintf(\"characters/%s_portrait.png\", u.Name))\n\t\tif err != nil {\n\t\t\tlogger.Errorf(\"Error loading character image portrait %v: %v\", u.Name, err)\n\t\t\tcontinue\n\t\t}\n\t\tcroppedPortrait := cropCircle(portrait)\n\t\tcanvas.DrawImage(croppedPortrait, x, y)\n\n\t\t// Draw gear\n\t\tgear, _ := bundle.loadUIAsset(fmt.Sprintf(\"ui/gear-icon-g%d_100x100.png\", u.Gear))\n\t\tif gear != nil {\n\t\t\tcanvas.DrawImage(gear, x, y)\n\t\t}\n\n\t\t// Draw stars\n\t\tstarYellow, _ := bundle.loadUIAsset(\"ui/ap-5r-char-portrait_star-yellow.png\")\n\t\tstarGray, _ := bundle.loadUIAsset(\"ui/ap-5r-char-portrait_star-gray.png\")\n\t\tif starYellow != nil {\n\t\t\tcx, cy := x+(unitSize/4)+10, y+(unitSize/4)\n\t\t\trotate := []float64{0, -66, -43, -21, 0, 21, 43, 66}\n\t\t\tfor i := 1; i <= 7; i++ {\n\t\t\t\tcanvas.Push()\n\t\t\t\tcanvas.Stroke()\n\t\t\t\tcanvas.Translate(0.5, 0)\n\t\t\t\tcanvas.RotateAbout(gg.Radians(rotate[i]), f(cx), f(cy))\n\t\t\t\tif u.Rarity >= i {\n\t\t\t\t\tcanvas.DrawImageAnchored(starYellow, cx, cy-26, 0.5, 0.5)\n\t\t\t\t} else {\n\t\t\t\t\tcanvas.DrawImageAnchored(starGray, cx, cy-26, 0.5, 0.5)\n\t\t\t\t}\n\t\t\t\tcanvas.Pop()\n\t\t\t}\n\t\t}\n\n\t\t// Check offset\n\t\tx += unitSize\n\t\tif (unitCount+1)%5 == 0 {\n\t\t\ty += unitSize\n\t\t\tx = padding\n\t\t}\n\t}\n\n\tvar b bytes.Buffer\n\tif err := canvas.EncodePNG(&b); err != nil {\n\t\treturn nil, err\n\t}\n\treturn b.Bytes(), nil\n}", "func (sm *SpaceManager) List(ctx context.Context) ([]string, error) {\n\tlock := sm.Lock.Get(allSpacesLockName)\n\tif !lock.RLock(sm.LockTimeout) {\n\t\treturn nil, ErrorLocking.Format(\"space manager\", allSpacesLockName)\n\t}\n\tdefer lock.RUnlock()\n\treturn list(ctx, sm.Backend, sm.Prefix, validateName, sortNames)\n}", "func (s *GroupsService) ListGroups(opt *ListGroupsOptions, options ...RequestOptionFunc) ([]*Group, *Response, error) {\n\treq, err := s.client.NewRequest(http.MethodGet, \"groups\", opt, options)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvar gs []*Group\n\tresp, err := s.client.Do(req, &gs)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn gs, resp, nil\n}", "func List(c messagebird.Client, options *messagebird.PaginationRequest) (*Groups, error) {\n\tgroupList := &Groups{}\n\tif err := c.Request(groupList, http.MethodGet, path+\"?\"+options.QueryParams(), nil); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn groupList, nil\n}", "func (o *DataExportQuery) GetUnits() int32 {\n\tif o == nil || o.Units == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.Units\n}", "func (o ElastigroupMultipleMetricsMetricOutput) Unit() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v ElastigroupMultipleMetricsMetric) *string { return v.Unit }).(pulumi.StringPtrOutput)\n}", "func ListVolumeGroupNames() ([]string, error) {\n\tresult := new(vgsOutput)\n\tif err := run(\"vgs\", result); err != nil {\n\t\treturn nil, err\n\t}\n\tvar names []string\n\tfor _, report := range result.Report {\n\t\tfor _, vg := range report.Vg {\n\t\t\tnames = append(names, vg.Name)\n\t\t}\n\t}\n\treturn names, nil\n}", "func (m *manager) List() ([]string, error) {\n\tvar igs []*compute.InstanceGroup\n\n\tzones, err := m.ListZones(utils.AllNodesPredicate)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, zone := range zones {\n\t\tigsForZone, err := m.cloud.ListInstanceGroups(zone)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tfor _, ig := range igsForZone {\n\t\t\tigs = append(igs, ig)\n\t\t}\n\t}\n\n\tvar names []string\n\tfor _, ig := range igs {\n\t\tif m.namer.NameBelongsToCluster(ig.Name) {\n\t\t\tnames = append(names, ig.Name)\n\t\t}\n\t}\n\n\treturn names, nil\n}", "func (s *EmptyStore) GroupList() (groups []*storagepb.Group, err error) {\n\treturn groups, nil\n}", "func (m *VirtualMachinesClientMock) List(ctx context.Context, resourceGroupName string) (result []compute.VirtualMachine, rerr *retry.Error) {\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\n\tif _, ok := m.FakeStore[resourceGroupName]; ok {\n\t\tfor _, v := range m.FakeStore[resourceGroupName] {\n\t\t\tresult = append(result, v)\n\t\t}\n\t}\n\n\treturn result, nil\n}", "func (s *statsFloat64) List() []float64 {\n\treturn []float64{\n\t\ts.size,\n\t\ts.used,\n\t\ts.free,\n\t\ts.usedCapacityPercent,\n\t}\n}", "func (s *statsFloat64) List() []float64 {\n\treturn []float64{\n\t\ts.size,\n\t\ts.used,\n\t\ts.free,\n\t\ts.usedCapacityPercent,\n\t}\n}", "func ListVolumeGroupNames() ([]string, error) {\n\tresult := new(vgsOutput)\n\tif err := run(\"vgs\", result); err != nil {\n\t\tlog.Errorf(\"ListVolumeGroupNames error: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\tvar names []string\n\tfor _, report := range result.Report {\n\t\tfor _, vg := range report.Vg {\n\t\t\tnames = append(names, vg.Name)\n\t\t}\n\t}\n\treturn names, nil\n}", "func (oc *OrganizationCreate) AddUnits(o ...*OrgUnit) *OrganizationCreate {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn oc.AddUnitIDs(ids...)\n}", "func (ou *OrganizationUpdate) RemoveUnits(o ...*OrgUnit) *OrganizationUpdate {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn ou.RemoveUnitIDs(ids...)\n}", "func (client *VirtualMachineScaleSetsClientMock) List(ctx context.Context, resourceGroupName string) (result []compute.VirtualMachineScaleSet, rerr *retry.Error) {\n\tclient.mutex.Lock()\n\tdefer client.mutex.Unlock()\n\n\tresult = []compute.VirtualMachineScaleSet{}\n\tif _, ok := client.FakeStore[resourceGroupName]; ok {\n\t\tfor _, v := range client.FakeStore[resourceGroupName] {\n\t\t\tresult = append(result, v)\n\t\t}\n\t}\n\n\treturn result, nil\n}", "func ListTests() {\n\tfmt.Printf(\"Available test suites:\\n\\tauto\\n\")\n\tfor _, suite := range AllSuites {\n\t\tfmt.Printf(\"\\t%s\\n\", suite)\n\t}\n}", "func (o FleetOutput) MetricGroups() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *Fleet) pulumi.StringArrayOutput { return v.MetricGroups }).(pulumi.StringArrayOutput)\n}", "func (c *GroupController) List(ctx *app.ListGroupContext) error {\n\t// GroupController_List: start_implement\n\n\tdataStore := &dal.DataStore{}\n\tdataStore.GetSession()\n\t// Close the session\n\tdefer dataStore.Close()\n\tdc := dal.NewDalGroup(dataStore)\n\n\tgroups, err := dc.FetchAll()\n\n\tif err != nil {\n\t\tctx.ResponseData.Service.LogError(\"InternalServerError\", \"req_id\", middleware.ContextRequestID(ctx), \"ctrl\", \"Group\", \"action\", \"List\", ctx.RequestData.Request.Method, ctx.RequestData.Request.URL, \"databaseError\", err.Error())\n\t\treturn ctx.InternalServerError()\n\t}\n\n\tres := make(app.GwentapiGroupCollection, len(*groups))\n\n\tlastModified := time.Time{}\n\tfor i, group := range *groups {\n\t\tg, _ := factory.CreateGroup(&group)\n\n\t\tif lastModified.Before(group.Last_Modified) {\n\t\t\tlastModified = group.Last_Modified\n\t\t}\n\n\t\tres[i] = g\n\t}\n\n\t// GroupController_List: end_implement\n\thelpers.LastModified(ctx.ResponseData, lastModified)\n\tif ctx.IfModifiedSince != nil {\n\t\tif !helpers.IsModified(*ctx.IfModifiedSince, lastModified) {\n\t\t\treturn ctx.NotModified()\n\t\t}\n\t}\n\treturn ctx.OK(res)\n}", "func (g *Group) Register(units ...Unit) []bool {\n\tg.log = logger.GetLogger(g.name)\n\thasRegistered := make([]bool, len(units))\n\tfor idx := range units {\n\t\tif !g.configured {\n\t\t\t// if RunConfig has been called we can no longer register Config\n\t\t\t// phases of Units\n\t\t\tif c, ok := units[idx].(Config); ok {\n\t\t\t\tg.c = append(g.c, c)\n\t\t\t\thasRegistered[idx] = true\n\t\t\t}\n\t\t}\n\t\tif p, ok := units[idx].(PreRunner); ok {\n\t\t\tg.p = append(g.p, p)\n\t\t\thasRegistered[idx] = true\n\t\t}\n\t\tif s, ok := units[idx].(Service); ok {\n\t\t\tg.s = append(g.s, s)\n\t\t\thasRegistered[idx] = true\n\t\t}\n\t}\n\treturn hasRegistered\n}", "func (ouo *OrganizationUpdateOne) RemoveUnits(o ...*OrgUnit) *OrganizationUpdateOne {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn ouo.RemoveUnitIDs(ids...)\n}", "func (c *MockNetworkSecurityGroupsClient) List(ctx context.Context, resourceGroupName string) ([]network.SecurityGroup, error) {\n\tvar l []network.SecurityGroup\n\tfor _, nsg := range c.NSGs {\n\t\tl = append(l, nsg)\n\t}\n\treturn l, nil\n}", "func (c *MockVMScaleSetsClient) List(ctx context.Context, resourceGroupName string) ([]compute.VirtualMachineScaleSet, error) {\n\tvar l []compute.VirtualMachineScaleSet\n\tfor _, vmss := range c.VMSSes {\n\t\tl = append(l, vmss)\n\t}\n\treturn l, nil\n}", "func groupUnitStatus(usl []fleet.UnitStatus, groupMember fleet.UnitStatus) ([]fleet.UnitStatus, string, error) {\n\tID, err := common.SliceID(groupMember.Name)\n\tif err != nil {\n\t\treturn nil, \"\", maskAny(invalidUnitStatusError)\n\t}\n\n\tnewList := []fleet.UnitStatus{}\n\tfor _, us := range usl {\n\t\texp := common.ExtExp.ReplaceAllString(us.Name, \"\")\n\t\tif !strings.HasSuffix(exp, ID) {\n\t\t\tcontinue\n\t\t}\n\n\t\tnewList = append(newList, us)\n\t}\n\n\treturn newList, ID, nil\n}", "func (r *PlacementGroupsService) List(profileId int64) *PlacementGroupsListCall {\n\tc := &PlacementGroupsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.profileId = profileId\n\treturn c\n}", "func (r *ProjectsGroupsService) List(name string) *ProjectsGroupsListCall {\n\tc := &ProjectsGroupsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}\n\tc.name = name\n\treturn c\n}", "func SupportedUnits() map[UnitType][]string {\n\tunitLock.RLock()\n\tdefer unitLock.RUnlock()\n\tsupported := make(map[UnitType][]string, len(supportedUnits))\n\tfor unit, aliases := range supportedUnits {\n\t\tsupported[unit] = aliases\n\t}\n\treturn supported\n}", "func List() []string {\n\tnames := make([]string, 0, len(stores))\n\tfor name := range stores {\n\t\tnames = append(names, name)\n\t}\n\treturn names\n}", "func (m *VirtualMachineScaleSetVMsClientMock) List(ctx context.Context, resourceGroupName string, virtualMachineScaleSetName string, expand string) (result []compute.VirtualMachineScaleSetVM, rerr *retry.Error) {\n\tm.mutex.Lock()\n\tdefer m.mutex.Unlock()\n\n\tif _, ok := m.FakeStore[resourceGroupName]; ok {\n\t\tfor _, v := range m.FakeStore[resourceGroupName] {\n\t\t\tresult = append(result, v)\n\t\t}\n\t}\n\treturn result, nil\n}", "func (c CouchbaseFleet) DestroyUnits(allUnits bool) error {\n\n\tttlSeconds := uint64(300)\n\t_, err := c.etcdClient.Set(KEY_REMOVE_REBALANCE_DISABLED, \"true\", ttlSeconds)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// call ManipulateUnits with a function that will stop them\n\tunitDestroyer := func(unit *schema.Unit) error {\n\n\t\t// stop the unit by updating desiredState to inactive\n\t\t// and posting to fleet api\n\t\tendpointUrl := fmt.Sprintf(\"%v/units/%v\", FLEET_API_ENDPOINT, unit.Name)\n\t\treturn DELETE(endpointUrl)\n\n\t}\n\n\treturn c.ManipulateUnits(unitDestroyer, allUnits)\n\n}", "func (c *Client) ListGroups() ([]string, error) {\n\tvar groups []string\n\tif !c.authenticated {\n\t\treturn groups, errors.New(\"Not authenticated. Call Authenticate first\")\n\t}\n\n\tmsg := common.NewMessage(c.userId, \"server\",\n\t\t\"control\", \"remove_to_group\", time.Time{},\n\t\tcommon.TEXT, \"\")\n\n\tencoded, err := msg.Json()\n\tif err != nil {\n\t\tlog.Println(\"Failed to encode list groups message\", err)\n\t\treturn groups, err\n\t}\n\n\terr = c.transport.SendText(string(encoded))\n\tif err != nil {\n\t\tlog.Println(\"Failed to send list groups message\", err)\n\t\treturn groups, err\n\t}\n\n\tresp := <-c.Out\n\tif resp.Status() == common.STATUS_ERROR {\n\t\terrMsg := resp.Error()\n\t\tlog.Println(\"Delete group response error\", errMsg)\n\t\treturn groups, errors.New(errMsg)\n\t}\n\n\tgroups, _ = resp.GetJsonData(\"groups\").([]string)\n\treturn groups, nil\n}", "func (s *Set) ListMetricNames() []string {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\tmetricNames := make([]string, 0, len(s.m))\n\tfor _, nm := range s.m {\n\t\tif nm.isAux {\n\t\t\tcontinue\n\t\t}\n\t\tmetricNames = append(metricNames, nm.name)\n\t}\n\tsort.Strings(metricNames)\n\treturn metricNames\n}", "func (s *LiftingStorage) GetUniqueUnits() ([]string, error) {\n\tcategorys := make([]string, 0)\n\terr := s.db.Select(&categorys, uniqueUnits)\n\tif err != nil {\n\t\treturn categorys, err\n\t}\n\treturn categorys, nil\n}", "func (st *API) UserGroupList(ctx context.Context) ([]UserGroup, error) {\n\terr := checkPermission(ctx, \"bot\", \"usergroups:read\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tst.mx.Lock()\n\tdefer st.mx.Unlock()\n\n\tids := make([]string, 0, len(st.usergroups))\n\tfor id := range st.usergroups {\n\t\tids = append(ids, id)\n\t}\n\tsort.Strings(ids)\n\n\tresult := make([]UserGroup, 0, len(ids))\n\tfor _, id := range ids {\n\t\tch := st.usergroups[id]\n\t\tresult = append(result, ch.UserGroup)\n\t}\n\n\treturn result, nil\n}", "func (ou *OrganizationUpdate) AddUnits(o ...*OrgUnit) *OrganizationUpdate {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn ou.AddUnitIDs(ids...)\n}", "func (s *Space) List(ctx context.Context) ([]string, error) {\n\tlock := s.SpaceManager.Lock.Get(s.Name())\n\tif !lock.RLock(s.SpaceManager.LockTimeout) {\n\t\treturn nil, ErrorLocking.Format(\"space\", s.Name())\n\t}\n\tdefer lock.RUnlock()\n\treturn list(ctx, s.SpaceManager.Backend, s.Prefix, validateName, sortNames)\n}", "func (Unit) Values() []Unit {\n\treturn []Unit{\n\t\t\"Seconds\",\n\t\t\"Microseconds\",\n\t\t\"Milliseconds\",\n\t\t\"Bytes\",\n\t\t\"Kilobytes\",\n\t\t\"Megabytes\",\n\t\t\"Gigabytes\",\n\t\t\"Terabytes\",\n\t\t\"Bits\",\n\t\t\"Kilobits\",\n\t\t\"Megabits\",\n\t\t\"Gigabits\",\n\t\t\"Terabits\",\n\t\t\"Percent\",\n\t\t\"Count\",\n\t\t\"Bytes/Second\",\n\t\t\"Kilobytes/Second\",\n\t\t\"Megabytes/Second\",\n\t\t\"Gigabytes/Second\",\n\t\t\"Terabytes/Second\",\n\t\t\"Bits/Second\",\n\t\t\"Kilobits/Second\",\n\t\t\"Megabits/Second\",\n\t\t\"Gigabits/Second\",\n\t\t\"Terabits/Second\",\n\t\t\"Count/Second\",\n\t\t\"None\",\n\t}\n}", "func (c *Dg) GetList() ([]string, error) {\n c.con.LogQuery(\"(get) list of device groups\")\n path := c.xpath(nil)\n return c.con.EntryListUsing(c.con.Get, path[:len(path) - 1])\n}", "func (s *JobService) List(ctx context.Context, clientTimeOffset int, collectAllChildJobs bool) (*Groups, *http.Response, error) {\n\trequest := Request{\n\t\tAction: JobAction,\n\t\tMethod: \"getGroupInfo\",\n\t\tData: []interface{}{[]interface{}{nil}, clientTimeOffset, collectAllChildJobs},\n\t\tType: \"rpc\",\n\t\tTid: 1,\n\t}\n\n\treq, err := s.client.NewRequest(&request)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tvar groups Groups\n\tr := Response{Data: &groups}\n\tresp, err := s.client.Do(ctx, req, &r)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\treturn &groups, resp, nil\n}", "func (c *MockResourceGroupsClient) List(ctx context.Context, filter string) ([]resources.Group, error) {\n\tif filter != \"\" {\n\t\treturn nil, fmt.Errorf(\"unsupported non-empty filter: %s\", filter)\n\t}\n\tvar l []resources.Group\n\tfor _, rg := range c.RGs {\n\t\tl = append(l, rg)\n\t}\n\treturn l, nil\n}", "func List() (list []string) {\n\n\tfor i := range box {\n\t\tlist = append(list, i)\n\t}\n\n\treturn list\n}", "func (cnst planckUnits) Unit() *unit.Unit {\n\treturn unit.New(float64(cnst), unit.Dimensions{\n\t\tunit.MassDim: 1,\n\t\tunit.LengthDim: 2,\n\t\tunit.TimeDim: -1,\n\t})\n}", "func (covList CoverageList) ListDirectories() []string {\n\tdirSet := map[string]bool{}\n\tfor _, cov := range covList.Group {\n\t\tdirSet[path.Dir(cov.Name)] = true\n\t}\n\tvar result []string\n\tfor key := range dirSet {\n\t\tresult = append(result, key)\n\t}\n\treturn result\n}", "func (o *GetForecastByCityIDParams) SetUnits(units *string) {\n\to.Units = units\n}", "func (m *Directory) GetAdministrativeUnits()([]AdministrativeUnitable) {\n val, err := m.GetBackingStore().Get(\"administrativeUnits\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.([]AdministrativeUnitable)\n }\n return nil\n}", "func List(numbers []uint64, prefix string) string {\n\tvar s []string\n\tfor _, n := range numbers {\n\t\ts = append(s, fmt.Sprintf(\"%s%d\", prefix, n))\n\t}\n\treturn strings.Join(s, \", \")\n}", "func (service Service) GetList(pagination entity.Pagination) (ug []entity.UserGroup, count int, err error) {\n\tusers, count, err := service.repository.GetList(pagination)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tug, err = service.mapUsersToUserGroups(users)\n\treturn\n}", "func ListOrganizations() error {\n\tclient, err := NewPacketClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\torgs, _, err := client.Organizations.List()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\te := MarshallAndPrint(orgs)\n\treturn e\n}", "func (this *ClientCLI) StatusAll() ([]UnitStatus, error) {\n\tcmd := execPkg.Command(FLEETCTL, ENDPOINT_OPTION, this.etcdPeer, \"list-units\", \"--full=true\", \"-l=true\", \"--fields=unit,load,active,sub,machine\")\n\tstdout, err := exec(cmd)\n\tif err != nil {\n\t\treturn []UnitStatus{}, err\n\t}\n\n\treturn parseFleetStatusOutput(stdout)\n}", "func (o *MemoryArrayAllOf) GetUnitsOk() ([]MemoryUnitRelationship, bool) {\n\tif o == nil || o.Units == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Units, true\n}", "func (ouo *OrganizationUpdateOne) AddUnits(o ...*OrgUnit) *OrganizationUpdateOne {\n\tids := make([]int, len(o))\n\tfor i := range o {\n\t\tids[i] = o[i].ID\n\t}\n\treturn ouo.AddUnitIDs(ids...)\n}", "func (db *MySQLDB) ListGroups(ctx context.Context, tenant *Tenant, request *helper.PageRequest) ([]*Group, *helper.Page, error) {\n\tfLog := mysqlLog.WithField(\"func\", \"ListGroups\").WithField(\"RequestID\", ctx.Value(constants.RequestID))\n\tq := \"SELECT COUNT(*) AS CNT FROM HANSIP_GROUP\"\n\tret := make([]*Group, 0)\n\trow := db.instance.QueryRowContext(ctx, q)\n\tcount := 0\n\terr := row.Scan(&count)\n\tif err != nil {\n\t\tif err == sql.ErrNoRows {\n\t\t\treturn ret, helper.NewPage(request, uint(count)), nil\n\t\t}\n\t\tfLog.Errorf(\"row.Scan got %s\", err.Error())\n\t\treturn nil, nil, &ErrDBScanError{\n\t\t\tWrapped: err,\n\t\t\tMessage: \"Error ListGroups\",\n\t\t\tSQL: q,\n\t\t}\n\t}\n\tpage := helper.NewPage(request, uint(count))\n\tq = fmt.Sprintf(\"SELECT REC_ID, GROUP_NAME, GROUP_DOMAIN, DESCRIPTION FROM HANSIP_GROUP WHERE GROUP_DOMAIN=? ORDER BY GROUP_NAME %s LIMIT %d, %d\", request.Sort, page.OffsetStart, page.OffsetEnd-page.OffsetStart)\n\trows, err := db.instance.QueryContext(ctx, q, tenant.Domain)\n\tif err != nil {\n\t\tfLog.Errorf(\"db.instance.QueryContext got %s. SQL = %s\", err.Error(), q)\n\t\treturn nil, nil, &ErrDBQueryError{\n\t\t\tWrapped: err,\n\t\t\tMessage: \"Error ListGroups\",\n\t\t\tSQL: q,\n\t\t}\n\t}\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tr := &Group{}\n\t\terr := rows.Scan(&r.RecID, &r.GroupName, &r.GroupDomain, &r.Description)\n\t\tif err != nil {\n\t\t\tfLog.Warnf(\"row.Scan got %s\", err.Error())\n\t\t\treturn nil, nil, &ErrDBScanError{\n\t\t\t\tWrapped: err,\n\t\t\t\tMessage: \"Error ListGroups\",\n\t\t\t\tSQL: q,\n\t\t\t}\n\t\t} else {\n\t\t\tret = append(ret, r)\n\t\t}\n\t}\n\treturn ret, page, nil\n}", "func (c *cave) orderUnits() []*caveUnit {\n\tvar units []*caveUnit\n\tfor _, unit := range c.units {\n\t\tunits = append(units, unit)\n\t}\n\tsort.Slice(units, func(i, j int) bool {\n\t\treturn units[i].loc.readingLess(units[j].loc)\n\t})\n\treturn units\n}", "func (client Client) ListByResourceGroup(resourceGroupName string) (result ListResult, err error) {\n\treq, err := client.ListByResourceGroupPreparer(resourceGroupName)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"redis.Client\", \"ListByResourceGroup\", nil, \"Failure preparing request\")\n\t}\n\n\tresp, err := client.ListByResourceGroupSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"redis.Client\", \"ListByResourceGroup\", resp, \"Failure sending request\")\n\t}\n\n\tresult, err = client.ListByResourceGroupResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"redis.Client\", \"ListByResourceGroup\", resp, \"Failure responding to request\")\n\t}\n\n\treturn\n}", "func (o *EquipmentBaseSensor) GetUnitsOk() (*string, bool) {\n\tif o == nil || o.Units == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Units, true\n}", "func (fs *FluidsizeService) List() (fl []Fluidsize, err error) {\n\t// GET: /fluidsizes\n\tvar req *http.Request\n\treq, err = fs.c.NewRequest(\"GET\", \"/fluidsizes\", nil)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tresp := struct {\n\t\tStatus string\n\t\tData []Fluidsize\n\t\tMessage string\n\t}{}\n\terr = fs.c.Do(req, &resp)\n\treturn resp.Data, err\n}", "func (r *Runsc) List(context context.Context) ([]*runc.Container, error) {\n\tdata, stderr, err := cmdOutput(r.command(context, \"list\", \"--format=json\"), false)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%w: %s\", err, stderr)\n\t}\n\tvar out []*runc.Container\n\tif err := json.Unmarshal(data, &out); err != nil {\n\t\treturn nil, err\n\t}\n\treturn out, nil\n}", "func (s *Store) List() []string {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\n\tls := make([]string, 0, len(s.ls))\n\tfor p := range s.ls {\n\t\tls = append(ls, p)\n\t}\n\n\treturn ls\n}", "func (s *Store) List() []string {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\n\tls := make([]string, 0, len(s.ls))\n\tfor p := range s.ls {\n\t\tls = append(ls, p)\n\t}\n\n\treturn ls\n}", "func (m *prom) ListMetric() []string {\n\tvar res = make([]string, 0)\n\tres = append(res, m.ginMet.List()...)\n\tres = append(res, m.othMet.List()...)\n\treturn res\n}", "func (domain *Domain) ListComponents() ([]string, error) {\n\t// collect names\n\tcomponents := []string{}\n\n\tdomain.ComponentsX.RLock()\n\tfor component := range domain.Components {\n\t\tcomponents = append(components, component)\n\t}\n\tdomain.ComponentsX.RUnlock()\n\n\t// success\n\treturn components, nil\n}", "func (client WorkloadNetworksClient) ListVMGroups(ctx context.Context, resourceGroupName string, privateCloudName string) (result WorkloadNetworkVMGroupsListPage, err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/WorkloadNetworksClient.ListVMGroups\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif result.wnvgl.Response.Response != nil {\n\t\t\t\tsc = result.wnvgl.Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tif err := validation.Validate([]validation.Validation{\n\t\t{TargetValue: client.SubscriptionID,\n\t\t\tConstraints: []validation.Constraint{{Target: \"client.SubscriptionID\", Name: validation.MinLength, Rule: 1, Chain: nil}}},\n\t\t{TargetValue: resourceGroupName,\n\t\t\tConstraints: []validation.Constraint{{Target: \"resourceGroupName\", Name: validation.MaxLength, Rule: 90, Chain: nil},\n\t\t\t\t{Target: \"resourceGroupName\", Name: validation.MinLength, Rule: 1, Chain: nil},\n\t\t\t\t{Target: \"resourceGroupName\", Name: validation.Pattern, Rule: `^[-\\w\\._\\(\\)]+$`, Chain: nil}}}}); err != nil {\n\t\treturn result, validation.NewError(\"avs.WorkloadNetworksClient\", \"ListVMGroups\", err.Error())\n\t}\n\n\tresult.fn = client.listVMGroupsNextResults\n\treq, err := client.ListVMGroupsPreparer(ctx, resourceGroupName, privateCloudName)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"avs.WorkloadNetworksClient\", \"ListVMGroups\", nil, \"Failure preparing request\")\n\t\treturn\n\t}\n\n\tresp, err := client.ListVMGroupsSender(req)\n\tif err != nil {\n\t\tresult.wnvgl.Response = autorest.Response{Response: resp}\n\t\terr = autorest.NewErrorWithError(err, \"avs.WorkloadNetworksClient\", \"ListVMGroups\", resp, \"Failure sending request\")\n\t\treturn\n\t}\n\n\tresult.wnvgl, err = client.ListVMGroupsResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"avs.WorkloadNetworksClient\", \"ListVMGroups\", resp, \"Failure responding to request\")\n\t\treturn\n\t}\n\tif result.wnvgl.hasNextLink() && result.wnvgl.IsEmpty() {\n\t\terr = result.NextWithContext(ctx)\n\t\treturn\n\t}\n\n\treturn\n}", "func (s stage) createUnits(config types.Config) error {\n\tfor _, unit := range config.Systemd.Units {\n\t\tif err := s.writeSystemdUnit(unit); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif unit.Enable {\n\t\t\tif err := s.Logger.LogOp(\n\t\t\t\tfunc() error { return s.EnableUnit(unit) },\n\t\t\t\t\"enabling unit %q\", unit.Name,\n\t\t\t); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tif unit.Mask {\n\t\t\tif err := s.Logger.LogOp(\n\t\t\t\tfunc() error { return s.MaskUnit(unit) },\n\t\t\t\t\"masking unit %q\", unit.Name,\n\t\t\t); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tfor _, unit := range config.Networkd.Units {\n\t\tif err := s.writeNetworkdUnit(unit); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (d *DivMaster) List() []string {\n\tlist := make([]string, 0)\n\tfor _, v := range d.divName {\n\t\tlist = append(list, v)\n\t}\n\treturn list\n}", "func (c *routeGroups) List(opts metav1.ListOptions) (result *v1.RouteGroupList, err error) {\n\tvar timeout time.Duration\n\tif opts.TimeoutSeconds != nil {\n\t\ttimeout = time.Duration(*opts.TimeoutSeconds) * time.Second\n\t}\n\tresult = &v1.RouteGroupList{}\n\terr = c.client.Get().\n\t\tNamespace(c.ns).\n\t\tResource(\"routegroups\").\n\t\tVersionedParams(&opts, scheme.ParameterCodec).\n\t\tTimeout(timeout).\n\t\tDo().\n\t\tInto(result)\n\treturn\n}", "func (c *Dg) ShowList() ([]string, error) {\n c.con.LogQuery(\"(show) list of device groups\")\n path := c.xpath(nil)\n return c.con.EntryListUsing(c.con.Show, path[:len(path) - 1])\n}", "func AllNames() []string {\n\tret := make([]string, 0, len(unitByName))\n\tfor n := range unitByName {\n\t\tif n == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tret = append(ret, n)\n\t}\n\tsort.Strings(ret)\n\treturn ret\n}", "func (TtlDurationUnit) Values() []TtlDurationUnit {\n\treturn []TtlDurationUnit{\n\t\t\"Seconds\",\n\t\t\"Minutes\",\n\t\t\"Hours\",\n\t\t\"Days\",\n\t\t\"Weeks\",\n\t}\n}", "func (TtlDurationUnit) Values() []TtlDurationUnit {\n\treturn []TtlDurationUnit{\n\t\t\"Seconds\",\n\t\t\"Minutes\",\n\t\t\"Hours\",\n\t\t\"Days\",\n\t\t\"Weeks\",\n\t}\n}", "func (c *MockNatGatewaysClient) List(ctx context.Context, resourceGroupName string) ([]network.NatGateway, error) {\n\tvar l []network.NatGateway\n\tfor _, ngw := range c.NGWs {\n\t\tl = append(l, ngw)\n\t}\n\treturn l, nil\n}", "func ListVolumeGroupUUIDs() ([]string, error) {\n\tresult := new(vgsOutput)\n\tif err := run(\"vgs\", result, \"--options=vg_uuid\"); err != nil {\n\t\treturn nil, err\n\t}\n\tvar uuids []string\n\tfor _, report := range result.Report {\n\t\tfor _, vg := range report.Vg {\n\t\t\tuuids = append(uuids, vg.UUID)\n\t\t}\n\t}\n\treturn uuids, nil\n}", "func (c *MockVMScaleSetVMsClient) List(ctx context.Context, resourceGroupName, vmssName string) ([]compute.VirtualMachineScaleSetVM, error) {\n\t// Ignore resourceGroupName and vmssName for simplicity.\n\tvar l []compute.VirtualMachineScaleSetVM\n\tfor _, vm := range c.VMs {\n\t\tl = append(l, vm)\n\t}\n\treturn l, nil\n}", "func ListVolumeGroupUUIDs() ([]string, error) {\n\tresult := new(vgsOutput)\n\tif err := run(\"vgs\", result, \"--options=vg_uuid\"); err != nil {\n\t\tlog.Errorf(\"ListVolumeGroupUUIDs error: %s\", err.Error())\n\t\treturn nil, err\n\t}\n\tvar uuids []string\n\tfor _, report := range result.Report {\n\t\tfor _, vg := range report.Vg {\n\t\t\tuuids = append(uuids, vg.UUID)\n\t\t}\n\t}\n\treturn uuids, nil\n}", "func (client *Client) ListExperimentGroups(request *ListExperimentGroupsRequest) (response *ListExperimentGroupsResponse, err error) {\n\tresponse = CreateListExperimentGroupsResponse()\n\terr = client.DoAction(request, response)\n\treturn\n}", "func (StorageUnit) Values() []StorageUnit {\n\treturn []StorageUnit{\n\t\t\"TB\",\n\t}\n}" ]
[ "0.72441345", "0.7032067", "0.6085787", "0.6073443", "0.595272", "0.5778228", "0.5681488", "0.5550705", "0.5550341", "0.5543723", "0.553827", "0.55062217", "0.5478257", "0.5455158", "0.54498625", "0.5443609", "0.53967434", "0.5386662", "0.53394026", "0.5324254", "0.5321294", "0.527811", "0.5277048", "0.5252291", "0.52466196", "0.5199905", "0.51424944", "0.508134", "0.5059078", "0.5036113", "0.5032049", "0.5028996", "0.5014391", "0.50075984", "0.5007328", "0.50015706", "0.50015706", "0.4991006", "0.4988078", "0.498503", "0.4965824", "0.49512297", "0.49083504", "0.48942584", "0.48922098", "0.48868403", "0.48840407", "0.4881102", "0.48802513", "0.48748133", "0.48726508", "0.4839712", "0.48395473", "0.48331937", "0.48318353", "0.4819877", "0.48106697", "0.48103693", "0.4807688", "0.48023576", "0.47992688", "0.4795687", "0.47920135", "0.47896862", "0.47841662", "0.47812605", "0.47760338", "0.47734886", "0.4753167", "0.47413778", "0.47094864", "0.47051668", "0.47003868", "0.46971378", "0.46876964", "0.46852", "0.4683783", "0.46785513", "0.46757683", "0.4671572", "0.46697178", "0.46654886", "0.46622628", "0.46622628", "0.46613362", "0.46593252", "0.46571955", "0.46512353", "0.46508574", "0.4649988", "0.46460274", "0.46397316", "0.46388304", "0.46388304", "0.4632877", "0.46287218", "0.46269107", "0.46236902", "0.46219853", "0.46184736" ]
0.75670975
0
WaitTillReady blocks the goroutine till all modules are ready.
func (g *Group) WaitTillReady() { <-g.readyCh }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (envManager *TestEnvManager) WaitUntilReady() (bool, error) {\n\tlog.Println(\"Start checking components' status\")\n\tretry := u.Retrier{\n\t\tBaseDelay: 1 * time.Second,\n\t\tMaxDelay: 10 * time.Second,\n\t\tRetries: 8,\n\t}\n\n\tready := false\n\tretryFn := func(_ context.Context, i int) error {\n\t\tfor _, comp := range envManager.testEnv.GetComponents() {\n\t\t\tif alive, err := comp.IsAlive(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"unable to comfirm compoment %s is alive %v\", comp.GetName(), err)\n\t\t\t} else if !alive {\n\t\t\t\treturn fmt.Errorf(\"component %s is not alive\", comp.GetName())\n\t\t\t}\n\t\t}\n\n\t\tready = true\n\t\tlog.Println(\"All components are ready\")\n\t\treturn nil\n\t}\n\n\t_, err := retry.Retry(context.Background(), retryFn)\n\treturn ready, err\n}", "func (c *BFTChain) WaitReady() error {\n\treturn nil\n}", "func WaitReady(ctx *util.Context) error {\n\tif !ctx.Cluster.MachineController.Deploy {\n\t\treturn nil\n\t}\n\n\tctx.Logger.Infoln(\"Waiting for machine-controller to come up…\")\n\n\t// Wait a bit to let scheduler to react\n\ttime.Sleep(10 * time.Second)\n\n\tif err := WaitForWebhook(ctx.DynamicClient); err != nil {\n\t\treturn errors.Wrap(err, \"machine-controller-webhook did not come up\")\n\t}\n\n\tif err := WaitForMachineController(ctx.DynamicClient); err != nil {\n\t\treturn errors.Wrap(err, \"machine-controller did not come up\")\n\t}\n\treturn nil\n}", "func (t *Indie) waitModules() {\n for _, m := range t.modules {\n\tim := reflect.ValueOf(m).FieldByName(\"Module\").Interface()\n\tt.moduleWgs[im.(Module).Name].Wait()\n }\n}", "func (t *Indie) Wait() {\n t.waitModules()\n}", "func WaitReady(s *state.State) error {\n\tif !s.Cluster.MachineController.Deploy {\n\t\treturn nil\n\t}\n\n\ts.Logger.Infoln(\"Waiting for machine-controller to come up...\")\n\n\tif err := cleanupStaleResources(s.Context, s.DynamicClient); err != nil {\n\t\treturn err\n\t}\n\n\tif err := waitForWebhook(s.Context, s.DynamicClient); err != nil {\n\t\treturn err\n\t}\n\n\tif err := waitForMachineController(s.Context, s.DynamicClient); err != nil {\n\t\treturn err\n\t}\n\n\treturn waitForCRDs(s)\n}", "func WaitReady() {\n\tif deviceReady {\n\t\treturn\n\t}\n\tch := make(chan struct{}, 0)\n\tf := func() {\n\t\tdeviceReady = true\n\t\tclose(ch)\n\t}\n\tOnDeviceReady(f)\n\t<-ch\n\tUnDeviceReady(f)\n}", "func (b *Botanist) WaitUntilRequiredExtensionsReady(ctx context.Context) error {\n\treturn retry.UntilTimeout(ctx, 5*time.Second, time.Minute, func(ctx context.Context) (done bool, err error) {\n\t\tif err := b.RequiredExtensionsReady(ctx); err != nil {\n\t\t\tb.Logger.Infof(\"Waiting until all the required extension controllers are ready (%+v)\", err)\n\t\t\treturn retry.MinorError(err)\n\t\t}\n\t\treturn retry.Ok()\n\t})\n}", "func (a *Agent) WaitReady() {\n\ta.statusLock.RLock()\n\tdefer a.statusLock.RUnlock()\n\n\tfor {\n\t\tif a.status == 1 {\n\t\t\treturn\n\t\t}\n\t\ta.statusCond.Wait()\n\t}\n}", "func WaitForReady() {\n\tucc.WaitForReady()\n}", "func WaitForReady() {\n\tdefaultClient.WaitForReady()\n}", "func (p *Pebble) WaitReady(t *testing.T) {\n\tif p.pebbleCMD.Process == nil {\n\t\tt.Fatal(\"Pebble not started\")\n\t}\n\turl := p.DirectoryURL()\n\tRetry(t, 10, 10*time.Millisecond, func() error {\n\t\tctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)\n\t\tdefer cancel()\n\n\t\tt.Log(\"Checking pebble readiness\")\n\t\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tresp, err := p.httpClient.Do(req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tresp.Body.Close()\n\t\treturn nil\n\t})\n}", "func (c *Client) WaitUntilReady() {\n\tc.waitUntilReady()\n}", "func Wait() {\n\tdefaultManager.Wait()\n}", "func StartAndWaitForReady(ctx context.Context, t *testing.T, manager datatransfer.Manager) {\n\tready := make(chan error, 1)\n\tmanager.OnReady(func(err error) {\n\t\tready <- err\n\t})\n\trequire.NoError(t, manager.Start(ctx))\n\tselect {\n\tcase <-ctx.Done():\n\t\tt.Fatal(\"did not finish starting up module\")\n\tcase err := <-ready:\n\t\trequire.NoError(t, err)\n\t}\n}", "func (b *Bucket) WaitUntilReady(timeout time.Duration, opts *WaitUntilReadyOptions) error {\n\tif opts == nil {\n\t\topts = &WaitUntilReadyOptions{}\n\t}\n\n\tcli := b.sb.getCachedClient()\n\tif cli == nil {\n\t\treturn errors.New(\"bucket is not connected\")\n\t}\n\n\terr := cli.getBootstrapError()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tprovider, err := cli.getWaitUntilReadyProvider()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdesiredState := opts.DesiredState\n\tif desiredState == 0 {\n\t\tdesiredState = ClusterStateOnline\n\t}\n\n\terr = provider.WaitUntilReady(\n\t\ttime.Now().Add(timeout),\n\t\tgocbcore.WaitUntilReadyOptions{\n\t\t\tDesiredState: gocbcore.ClusterState(desiredState),\n\t\t},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (b Build) Wait() {\n\t<-make(chan struct{})\n}", "func (p *Init) Wait() {\n\t<-p.waitBlock\n}", "func (b *buildandrun) Wait() {\n\t<-b.done\n}", "func (t Task) ready() {\n\tif t.depWg != nil {\n\t\tt.SetMessage(\"wait dependency tasks\")\n\t\tt.depWg.Wait()\n\t}\n}", "func (m *Module) Wait(ctx context.Context) error {\n\tselect {\n\tcase <-m.done:\n\t\tif m.err != nil {\n\t\t\treturn m.err\n\t\t}\n\t\treturn nil\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\t}\n}", "func (mod *Module)WaitTillStartupDone(){\n\tfor mod.hasRunStartup == false{//wait for startup to stop running\n\t\ttime.Sleep(time.Millisecond*10)\n\t}\n}", "func (test *Test) WaitForNodesReady(expectedNodes int, timeout time.Duration) {\n\terr := test.waitForNodesReady(expectedNodes, true, timeout)\n\ttest.err(err)\n}", "func Wait() {\n\twg.Wait()\n}", "func (vm *VirtualMachine) WaitUntilReady(client SkytapClient) (*VirtualMachine, error) {\n\treturn vm.WaitUntilInState(client, []string{RunStateStop, RunStateStart, RunStatePause}, false)\n}", "func TestWaitUntilAllNodesReady(t *testing.T) {\n\tt.Parallel()\n\n\toptions := NewKubectlOptions(\"\", \"\", \"default\")\n\n\tWaitUntilAllNodesReady(t, options, 12, 5*time.Second)\n\n\tnodes := GetNodes(t, options)\n\tnodeNames := map[string]bool{}\n\tfor _, node := range nodes {\n\t\tnodeNames[node.Name] = true\n\t}\n\n\treadyNodes := GetReadyNodes(t, options)\n\treadyNodeNames := map[string]bool{}\n\tfor _, node := range readyNodes {\n\t\treadyNodeNames[node.Name] = true\n\t}\n\n\tassert.Equal(t, nodeNames, readyNodeNames)\n}", "func waitForProvidersReady(ctx context.Context, opts InstallOptions, installQueue []repository.Components, proxy Proxy) error {\n\t// If we dont have to wait for providers to be installed\n\t// return early.\n\tif !opts.WaitProviders {\n\t\treturn nil\n\t}\n\n\tlog := logf.Log\n\tlog.Info(\"Waiting for providers to be available...\")\n\n\treturn waitManagerDeploymentsReady(ctx, opts, installQueue, proxy)\n}", "func (m *DomainMonitor) WaitReady() (err error) {\n\treturn m.sink.WaitReady()\n}", "func (s *SeleniumServer) Wait() {\n\terr := s.cmd.Wait()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func Wait() {\n\twaitGroup.Wait()\n}", "func (server *Server) Wait(){\n\tfor{\n\t\tif server.threads > 0 {\n\t\t\tserver.Logger.Info(server.threads, \"active channels at the moment. Waiting for busy goroutine.\")\n\t\t\t<-server.ThreadSync\n\t\t} else {\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (ini *Init) wait() {\n\tvar counter time.Duration\n\tfor !ini.init.Done() {\n\t\tcounter += 10\n\t\tif counter > 600000000 {\n\t\t\tpanic(\"BUG: timed out in lazy init\")\n\t\t}\n\t\ttime.Sleep(counter * time.Microsecond)\n\t}\n}", "func (b *EventBus) Wait() {\n\tb.wg.Wait()\n\n\tif err := b.amqpChannel.Close(); err != nil {\n\t\tlog.Printf(\"eventhorizon: failed to close RabbitMQ queue: %s\", err)\n\t}\n\n\tif err := b.amqpConn.Close(); err != nil {\n\t\tlog.Printf(\"eventhorizon: failed to close RabbitMQ connection: %s\", err)\n\t}\n}", "func WaitForNodesReady(t *testing.T, nomadClient *api.Client, nodes int) {\n\tnodesAPI := nomadClient.Nodes()\n\n\ttestutil.WaitForResultRetries(retries, func() (bool, error) {\n\t\tdefer time.Sleep(time.Millisecond * 100)\n\t\tnodesList, _, err := nodesAPI.List(nil)\n\t\tif err != nil {\n\t\t\treturn false, fmt.Errorf(\"error listing nodes: %v\", err)\n\t\t}\n\n\t\teligibleNodes := 0\n\t\tfor _, node := range nodesList {\n\t\t\tif node.Status == \"ready\" {\n\t\t\t\teligibleNodes++\n\t\t\t}\n\t\t}\n\n\t\treturn eligibleNodes >= nodes, fmt.Errorf(\"only %d nodes ready (wanted at least %d)\", eligibleNodes, nodes)\n\t}, func(err error) {\n\t\trequire.NoError(t, err, \"failed to get enough ready nodes\")\n\t})\n}", "func (elm *etcdLeaseManager) Wait() {\n\telm.wg.Wait()\n}", "func (cli *CLI) SystemWaitReady() {\n\tintervalSec := time.Duration(3)\n\tutil.Panic(wait.PollImmediateInfinite(intervalSec*time.Second, func() (bool, error) {\n\t\tsys := &nbv1.NooBaa{}\n\t\terr := cli.Client.Get(cli.Ctx, client.ObjectKey{Namespace: cli.Namespace, Name: cli.SystemName}, sys)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\tif sys.Status.Phase == nbv1.SystemPhaseReady {\n\t\t\tcli.Log.Printf(\"✅ System Phase is \\\"%s\\\".\\n\", sys.Status.Phase)\n\t\t\treturn true, nil\n\t\t}\n\t\tif sys.Status.Phase == nbv1.SystemPhaseRejected {\n\t\t\treturn false, fmt.Errorf(\"❌ System Phase is \\\"%s\\\". describe noobaa for more information\", sys.Status.Phase)\n\t\t}\n\t\tcli.Log.Printf(\"⏳ System Phase is \\\"%s\\\". Waiting for it to be ready ...\\n\", sys.Status.Phase)\n\t\treturn false, nil\n\t}))\n}", "func (d *InMemoryTaskDB) Wait() {\n\td.modClientsWg.Wait()\n}", "func WaitOnReady(pvCount int, sleep, timeout time.Duration) bool {\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\tch := make(chan bool)\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-ctx.Done():\n\t\t\t\treturn\n\t\t\tdefault:\n\t\t\t\tch <- AreAllReady(pvCount)\n\t\t\t\ttime.Sleep(sleep)\n\t\t\t}\n\t\t}\n\t}()\n\tfor {\n\t\tselect {\n\t\tcase ready := <-ch:\n\t\t\tif ready {\n\t\t\t\treturn ready\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\tDescribePVs()\n\t\t\treturn false\n\t\t}\n\t}\n}", "func (c *apiConsumers) Wait() {\n\tc.wait()\n}", "func (display smallEpd) waitUntilIdle() (err error) {\n\tlog.Debug(\"EPD42 WaitUntilIdle\")\n\tfor {\n\t\tbusy, err := display.driver.DigitalRead(display.BUSY)\n\t\tif !busy {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Error checking bust %s\\n\", err.Error())\n\t\t}\n\t\tfmt.Printf(\".\")\n\t\ttime.Sleep(200 * time.Millisecond)\n\t}\n\tlog.Debug(\"EPD42 WaitUntilIdle End\")\n\treturn\n}", "func (chanSync *channelRelaySync) WaitOnSetup() {\n\tdefer chanSync.shared.setupComplete.Wait()\n}", "func Wait() {\n\tselect {}\n}", "func (b *Botanist) WaitUntilEtcdsReady(ctx context.Context) error {\n\treturn etcd.WaitUntilEtcdsReady(\n\t\tctx,\n\t\tb.K8sSeedClient.DirectClient(),\n\t\tb.Logger,\n\t\tb.Shoot.SeedNamespace,\n\t\t2,\n\t\t5*time.Second,\n\t\t3*time.Minute,\n\t\t5*time.Minute,\n\t)\n}", "func (p Poller) WaitReady() error {\n\tinterval := time.Tick(p.Interval)\n\ttimer := time.NewTimer(p.Timeout)\n\n\tfor {\n\t\tlog.WithFields(log.Fields{}).Info(\"polling\")\n\n\t\tready, err := p.CheckReady()\n\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"ready\": ready,\n\t\t\t\"err\": err,\n\t\t}).Debug(\"poll_result\")\n\n\t\tif p.FailFast && err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif ready {\n\t\t\treturn nil\n\t\t}\n\n\t\tselect {\n\t\tcase <-interval:\n\t\t\tcontinue\n\t\tcase <-timer.C:\n\t\t\tlog.WithFields(log.Fields{}).Info(\"timeout_reached\")\n\t\t\treturn fmt.Errorf(\"timeout reached: %s\", p.Timeout)\n\t\t}\n\t}\n}", "func wait() {\n\twaitImpl()\n}", "func (m *HeavySyncMock) Wait(timeout time.Duration) {\n\tm.MinimockWait(timeout)\n}", "func (c *myClient) waitForEnvironmentsReady(p, t int, envList ...string) (err error) {\n\n\tlogger.Infof(\"Waiting up to %v seconds for the environments to be ready\", t)\n\ttimeOut := 0\n\tfor timeOut < t {\n\t\tlogger.Info(\"Waiting for the environments\")\n\t\ttime.Sleep(time.Duration(p) * time.Second)\n\t\ttimeOut = timeOut + p\n\t\tif err = c.checkForBusyEnvironments(envList); err == nil {\n\t\t\tbreak\n\t\t}\n\t}\n\tif timeOut >= t {\n\t\terr = fmt.Errorf(\"waitForEnvironmentsReady timed out\")\n\t}\n\treturn err\n}", "func (wg *WaitGroupBar) Wait() {\n\twg.wg.Wait()\n}", "func (m *ActiveNodeMock) Wait(timeout time.Duration) {\n\tm.MinimockWait(timeout)\n}", "func waitReady(project, name, region string) error {\n\twait := time.Minute * 4\n\tdeadline := time.Now().Add(wait)\n\tfor time.Now().Before(deadline) {\n\t\tsvc, err := getService(project, name, region)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to query Service for readiness: %w\", err)\n\t\t}\n\n\t\tfor _, cond := range svc.Status.Conditions {\n\t\t\tif cond.Type == \"Ready\" {\n\t\t\t\tif cond.Status == \"True\" {\n\t\t\t\t\treturn nil\n\t\t\t\t} else if cond.Status == \"False\" {\n\t\t\t\t\treturn fmt.Errorf(\"reason=%s message=%s\", cond.Reason, cond.Message)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(time.Second * 2)\n\t}\n\treturn fmt.Errorf(\"the service did not become ready in %s, check Cloud Console for logs to see why it failed\", wait)\n}", "func ReadyWait(ctx context.Context, driverName string, databaseURLs []string, logger func(...interface{})) error {\n\tlogger(driverName, \"checking connection\")\n\tadapter, err := AdapterFor(driverName)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tcount := len(databaseURLs)\n\tcurr := -1\n\tfor {\n\t\tcurr = (curr + 1) % count\n\t\tdb, err := sql.Open(driverName, databaseURLs[curr])\n\t\tif err == nil {\n\t\t\tlogger(driverName, \"server up\")\n\t\t\tvar num int\n\t\t\tif err = db.QueryRow(adapter.PingQuery).Scan(&num); err == nil {\n\t\t\t\tlogger(driverName, \"connected\")\n\t\t\t\treturn db.Close()\n\t\t\t}\n\t\t\tdb.Close()\n\t\t}\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tcase <-time.After(time.Second):\n\t\t\tlogger(driverName, \"retrying...\", err)\n\t\t}\n\t}\n}", "func Wait() {\n\tfor sched0.tasks.length() != 0 {\n\t\truntime.Gosched()\n\t}\n}", "func (aio *AsyncIO) waitAll() {\n\taio.trigger <- struct{}{}\n\t<-aio.trigger\n}", "func waitForConductor(ctx context.Context, client *gophercloud.ServiceClient) {\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn\n\t\tdefault:\n\t\t\tlog.Printf(\"[DEBUG] Waiting for conductor API to become available...\")\n\t\t\tdriverCount := 0\n\n\t\t\tdrivers.ListDrivers(client, drivers.ListDriversOpts{\n\t\t\t\tDetail: false,\n\t\t\t}).EachPage(func(page pagination.Page) (bool, error) {\n\t\t\t\tactual, err := drivers.ExtractDrivers(page)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn false, err\n\t\t\t\t}\n\t\t\t\tdriverCount += len(actual)\n\t\t\t\treturn true, nil\n\t\t\t})\n\t\t\t// If we have any drivers, conductor is up.\n\t\t\tif driverCount > 0 {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\ttime.Sleep(5 * time.Second)\n\t\t}\n\t}\n}", "func (manager *Manager) Wait() {\n\tlogger.FromCtx(manager.ctx, logger.Flow).WithField(\"flow\", manager.Name).Info(\"Awaiting till all processes are completed\")\n\tmanager.wg.Wait()\n}", "func Wait() {\n\t<-wait\n}", "func (a *Agent) Wait() error {\n\ta.init()\n\treturn <-a.waitCh\n}", "func WaitReady(namespaceStore *nbv1.NamespaceStore) bool {\n\tlog := util.Logger()\n\tklient := util.KubeClient()\n\n\tinterval := time.Duration(3)\n\n\terr := wait.PollUntilContextCancel(ctx, interval*time.Second, true, func(ctx context.Context) (bool, error) {\n\t\terr := klient.Get(util.Context(), util.ObjectKey(namespaceStore), namespaceStore)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"⏳ Failed to get NamespaceStore: %s\", err)\n\t\t\treturn false, nil\n\t\t}\n\t\tCheckPhase(namespaceStore)\n\t\tif namespaceStore.Status.Phase == nbv1.NamespaceStorePhaseRejected {\n\t\t\treturn false, fmt.Errorf(\"NamespaceStorePhaseRejected\")\n\t\t}\n\t\tif namespaceStore.Status.Phase != nbv1.NamespaceStorePhaseReady {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn true, nil\n\t})\n\treturn (err == nil)\n}", "func (wg *WaitGroup) Wait() {\n\twg.waitGroup.Wait()\n}", "func (node *Node) Wait() error {\n\treturn node.httpAPIServer.Wait()\n}", "func (twrkr *twerk) Wait() {\n\tif twrkr.stop {\n\t\treturn\n\t}\n\tticker := time.NewTicker(100 * time.Microsecond)\n\tdefer ticker.Stop()\n\n\tfor range ticker.C {\n\t\tif len(twrkr.jobListener) == 0 && twrkr.liveWorkersNum.Get() == 0 && twrkr.currentlyWorkingNum.Get() == 0 {\n\t\t\treturn\n\t\t}\n\t}\n}", "func (client *Client) WaitForAllTestResourcesReady() error {\n\tif err := client.WaitForChannelsReady(); err != nil {\n\t\treturn err\n\t}\n\tif err := client.WaitForSubscriptionsReady(); err != nil {\n\t\treturn err\n\t}\n\tif err := client.WaitForBrokersReady(); err != nil {\n\t\treturn err\n\t}\n\tif err := client.WaitForTriggersReady(); err != nil {\n\t\treturn err\n\t}\n\tif err := client.WaitForCronJobSourcesReady(); err != nil {\n\t\treturn err\n\t}\n\tif err := client.WaitForContainerSourcesReady(); err != nil {\n\t\treturn err\n\t}\n\tif err := pkgTest.WaitForAllPodsRunning(client.Kube, client.Namespace); err != nil {\n\t\treturn err\n\t}\n\t// FIXME(Fredy-Z): This hacky sleep is added to try mitigating the test flakiness.\n\t// Will delete it after we find the root cause and fix.\n\ttime.Sleep(10 * time.Second)\n\treturn nil\n}", "func (m *UnsyncListMock) Wait(timeout time.Duration) {\n\tm.MinimockWait(timeout)\n}", "func (s *Server) Wait() {\n\ts.wg.Wait()\n}", "func (s *Server) Wait() {\n\ts.wg.Wait()\n}", "func WaitFabricReady(ctx context.Context, log logging.Logger, params WaitFabricReadyParams) error {\n\tif common.InterfaceIsNil(params.StateProvider) {\n\t\treturn errors.New(\"nil NetDevStateProvider\")\n\t}\n\n\tif len(params.FabricIfaces) == 0 {\n\t\treturn errors.New(\"no fabric interfaces requested\")\n\t}\n\n\tparams.FabricIfaces = common.DedupeStringSlice(params.FabricIfaces)\n\n\tch := make(chan error)\n\tgo loopFabricReady(log, params, ch)\n\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tcase err := <-ch:\n\t\treturn err\n\t}\n}", "func (s YieldingWaitStrategy) Wait() {\n\truntime.Gosched()\n}", "func (lc *Closer) Wait() {\n\tlc.waiting.Wait()\n}", "func (m *StateSwitcherMock) Wait(timeout time.Duration) {\n\tm.MinimockWait(timeout)\n}", "func (t *Ticker) Wait() {\n\tt.wg.Wait()\n}", "func (h *KubernetesHelper) WaitUntilDeployReady(deploys map[string]DeploySpec) {\n\tctx := context.Background()\n\tfor deploy, spec := range deploys {\n\t\tif err := h.CheckPods(ctx, spec.Namespace, deploy, 1); err != nil {\n\t\t\tvar out string\n\t\t\t//nolint:errorlint\n\t\t\tif rce, ok := err.(*RestartCountError); ok {\n\t\t\t\tout = fmt.Sprintf(\"Error running test: failed to wait for deploy/%s to become 'ready', too many restarts (%v)\\n\", deploy, rce)\n\t\t\t} else {\n\t\t\t\tout = fmt.Sprintf(\"Error running test: failed to wait for deploy/%s to become 'ready', timed out waiting for condition\\n\", deploy)\n\t\t\t}\n\t\t\tos.Stderr.Write([]byte(out))\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n}", "func (s *Store) WaitForInit() {\n\ts.initComplete.Wait()\n}", "func Wait() {\n\tfor {\n\t\ttime.Sleep(time.Millisecond)\n\t\tif messages == nil || len(messages) == 0 {\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (s *RaftDatabase) AwaitReady() error {\n\tfor {\n\t\tdatabase, err := s.atomixClient.CloudV1beta1().Databases(s.namespace).Get(s.name, metav1.GetOptions{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t} else if database.Status.ReadyClusters == database.Spec.Clusters {\n\t\t\treturn nil\n\t\t} else {\n\t\t\ttime.Sleep(100 * time.Millisecond)\n\t\t}\n\t}\n}", "func (n *Netlify) WaitUntilDeployReady(ctx context.Context, d *models.Deploy) (*models.Deploy, error) {\n\treturn n.waitForState(ctx, d, \"prepared\", \"ready\")\n}", "func (w *WaitGroup) Wait() {\n\tfor w.counter > 0 {\n\t\tw.waiters++\n\t\tw.wait.Wait()\n\t\tw.waiters--\n\t}\n}", "func (b *Bot) WaitUntilCompletion() {\n\tb.server.Wait()\n}", "func (s *Stopper) Wait() {\n\ts.wg.Wait()\n}", "func (bus *EventBus) WaitAsync() {\n\tbus.wg.Wait()\n}", "func (bus *EventBus) WaitAsync() {\n\tbus.wg.Wait()\n}", "func (w *Worker) Wait() {\n\tw.helper.wg.Wait()\n}", "func (d *InMemoryJobDB) Wait() {\n\td.modClientsWg.Wait()\n}", "func (r SortedRunner) Wait() error {\n\treturn nil\n}", "func (m *HostNetworkMock) Wait(timeout time.Duration) {\n\tm.MinimockWait(timeout)\n}", "func (c *Config) Wait() {\n\tc.wg.Wait()\n}", "func (p *Probe) wait() {\n\tp.waitGroup.Wait()\n}", "func (s *Server) Wait() {\n\tfor {\n\t\tselect {\n\t\tcase <-s.channelQuit:\n\t\t\treturn\n\t\t}\n\t}\n}", "func (m *OutboundMock) Wait(timeout time.Duration) {\n\tm.MinimockWait(timeout)\n}", "func (ep *ExpectProcess) Wait() {\n\tep.wg.Wait()\n}", "func (wg *WaitGroup) Wait() {\n\twg.Wg.Wait()\n}", "func (t *Terminal) Wait() {\n\tfor <-t.stopChan {\n\t\treturn\n\t}\n}", "func (w *Worker) Wait() {\n\tw.ow.Do(func() {\n\t\tw.l.Info(\"astikit: worker is now waiting...\")\n\t\tw.wg.Wait()\n\t})\n}", "func (ms *Server) Wait() {\n\tms.loops.Wait()\n}", "func (w *WaitGroup) Wait() {\n\tw.wg.Wait()\n}", "func (e *Executor) Wait() {\n\tfor {\n\t\tnjob, ndone := e.Count()\n\t\tif ndone == njob {\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(100 * time.Millisecond)\n\t}\n}", "func (m *ConsensusNetworkMock) Wait(timeout time.Duration) {\n\tm.MinimockWait(timeout)\n}", "func (r *volumeReactor) waitForIdle() {\n\tr.ctrl.runningOperations.WaitForCompletion()\n\t// Check every 10ms if the controller does something and stop if it's\n\t// idle.\n\toldChanges := -1\n\tfor {\n\t\ttime.Sleep(10 * time.Millisecond)\n\t\tchanges := r.getChangeCount()\n\t\tif changes == oldChanges {\n\t\t\t// No changes for last 10ms -> controller must be idle.\n\t\t\tbreak\n\t\t}\n\t\toldChanges = changes\n\t}\n}", "func waitServerReady(t *testing.T, addr string) {\n\tfor i := 0; i < 50; i++ {\n\t\t_, err := http.DefaultClient.Get(addr)\n\t\t// assume server ready when no err anymore\n\t\tif err == nil {\n\t\t\treturn\n\t\t}\n\t\ttime.Sleep(100 * time.Millisecond)\n\t\tcontinue\n\t}\n}", "func waitManagerDeploymentsReady(ctx context.Context, opts InstallOptions, installQueue []repository.Components, proxy Proxy) error {\n\tfor _, components := range installQueue {\n\t\tfor _, obj := range components.Objs() {\n\t\t\tif util.IsDeploymentWithManager(obj) {\n\t\t\t\tif err := waitDeploymentReady(ctx, obj, opts.WaitProviderTimeout, proxy); err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"deployment %q is not ready after %s\", obj.GetName(), opts.WaitProviderTimeout)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func (c *C) Wait() {\n\tc.wg.Wait()\n}" ]
[ "0.71673805", "0.7037186", "0.6973799", "0.69529676", "0.6943009", "0.67180645", "0.6540523", "0.65389913", "0.6448208", "0.64068717", "0.63826364", "0.6358909", "0.63548183", "0.6340962", "0.6263704", "0.6206062", "0.61352175", "0.6132525", "0.61261886", "0.60737973", "0.60353774", "0.602201", "0.6014714", "0.597966", "0.59758645", "0.5947379", "0.594252", "0.5940867", "0.59302485", "0.5904095", "0.58651865", "0.5850224", "0.5848503", "0.58345234", "0.58126265", "0.57703835", "0.5757945", "0.5757431", "0.5755224", "0.57546735", "0.5748997", "0.57326674", "0.57301605", "0.5715935", "0.5712563", "0.5712087", "0.56998104", "0.5682395", "0.5675259", "0.5668885", "0.5666431", "0.5663693", "0.5653898", "0.5651902", "0.563558", "0.5630438", "0.5620813", "0.56075233", "0.5600549", "0.5593047", "0.5587408", "0.55795765", "0.5549454", "0.5546708", "0.5546708", "0.5545567", "0.55342", "0.55299205", "0.5527766", "0.55245334", "0.5520209", "0.55125743", "0.5510038", "0.5503663", "0.5487959", "0.54847515", "0.54801285", "0.54755825", "0.54716367", "0.54716367", "0.54703575", "0.54669285", "0.5461576", "0.5456165", "0.5452607", "0.5451909", "0.544927", "0.54490066", "0.54489547", "0.54391843", "0.5436193", "0.54347813", "0.5424801", "0.5420951", "0.54201925", "0.5408455", "0.5402397", "0.5401856", "0.5399817", "0.53976357" ]
0.7307017
0
Validate adds an error if the Field is a path that does not exist.
func (v *StringIsPath) Validate(e *validator.Errors) { if Exists(v.Field) { return } e.Add(v.Name, StringIsPathError(v)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (b *Builder) Validate() error {\n\tif b.path == \"\" {\n\t\treturn errors.New(\"failed to validate: missing host path\")\n\t}\n\n\tb = b.WithCheckf(isValidPath(), \"invalid path %v\", b.path)\n\n\tfailedValidations := []string{}\n\tfor check, msg := range b.checks {\n\t\tif !(*check)(b.path) {\n\t\t\tfailedValidations = append(failedValidations, msg)\n\t\t}\n\t}\n\n\tif len(failedValidations) > 0 {\n\t\treturn errors.Errorf(\"host path validation failed: %v\", failedValidations)\n\t}\n\treturn nil\n}", "func (r *RouteSpecFields) Validate(ctx context.Context) (errs *apis.FieldError) {\n\n\tif r.Domain == \"\" {\n\t\terrs = errs.Also(apis.ErrMissingField(\"domain\"))\n\t}\n\n\tif r.Hostname == \"www\" {\n\t\terrs = errs.Also(apis.ErrInvalidValue(\"hostname\", r.Hostname))\n\t}\n\n\tif _, err := BuildPathRegexp(r.Path); err != nil {\n\t\terrs = errs.Also(apis.ErrInvalidValue(\"path\", r.Path))\n\t}\n\n\treturn errs\n}", "func (e PathCFValidationError) Field() string { return e.field }", "func validatePathNoBacksteps(targetPath string, fldPath *field.Path) field.ErrorList {\n\tallErrs := field.ErrorList{}\n\tparts := strings.Split(filepath.ToSlash(targetPath), \"/\")\n\tfor _, item := range parts {\n\t\tif item == \"..\" {\n\t\t\tallErrs = append(allErrs, field.Invalid(fldPath, targetPath, \"must not contain '..'\"))\n\t\t\tbreak // even for `../../..`, one error is sufficient to make the point\n\t\t}\n\t}\n\treturn allErrs\n}", "func (f Unstructured) HasPath(fieldPath ...string) bool {\n\tif f.IsUndefined() || len(fieldPath) == 0 {\n\t\treturn true\n\t}\n\tif !f.HasByName(fieldPath[0]) {\n\t\treturn false\n\t}\n\treturn f.Field(fieldPath[0]) != nil\n}", "func validatePathParameter(field *surface_v1.Field) {\n\tif field.Kind != surface_v1.FieldKind_SCALAR {\n\t\tlog.Println(\"The path parameter with the Name \" + field.Name + \" is invalid. \" +\n\t\t\t\"The path template may refer to one or more fields in the gRPC request message, as\" +\n\t\t\t\" long as each field is a non-repeated field with a primitive (non-message) type. \" +\n\t\t\t\"See: https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L62 for more information.\")\n\t}\n}", "func (e HttpConnectionManager_PathNormalizationOptionsValidationError) Field() string { return e.field }", "func ValidateAbsPath(fl validator.FieldLevel) bool {\n\treturn strings.HasPrefix(fl.Field().String(), \"/\")\n}", "func (f *InfoField) Validate() error {\n\tif err := f.BWCls.Validate(); err != nil {\n\t\treturn err\n\t}\n\tif err := f.RLC.Validate(); err != nil {\n\t\treturn err\n\t}\n\tif err := f.Idx.Validate(); err != nil {\n\t\treturn err\n\t}\n\tif err := f.PathType.Validate(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func validatePath(p string) (path string, err error) {\n\tpath = p\n\tif !strings.HasPrefix(path, \"/\") {\n\t\tpath = fmt.Sprintf(\"/%s\", path)\n\t}\n\n\tpath = strings.TrimSuffix(path, \"/\")\n\n\treturn\n}", "func validOriginPath(fl validator.FieldLevel) bool {\n\tval := fl.Field().String()\n\t// Not required\n\tif val == \"\" {\n\t\treturn true\n\t}\n\treturn OriginPathRexExp.MatchString(val)\n}", "func (pt PathType) Validate() error {\n\tif pt == UnknownPath || pt > CorePath {\n\t\treturn serrors.New(\"Invalid path type\", \"PathType\", pt)\n\t}\n\treturn nil\n}", "func (t *test) pathValidate(p *gpb.Path, prefix bool) error {\n\terrs := &testerror.List{}\n\n\tif t.gpc.CheckElem && p != nil && len(p.Element) > 0 {\n\t\terrs.AddErr(fmt.Errorf(\"element field is used in gNMI Path %v\", proto.CompactTextString(p)))\n\t}\n\n\tif !prefix || (t.gpc.CheckTarget == \"\" && t.gpc.CheckOrigin == \"\") {\n\t\treturn errs\n\t}\n\n\tif p == nil {\n\t\terrs.AddErr(fmt.Errorf(\"prefix gNMI Path must be non-nil, origin and/or target are missing\"))\n\t\treturn errs\n\t}\n\n\tswitch {\n\tcase t.gpc.CheckTarget == \"\": // Validation on target field isn't requested.\n\tcase t.gpc.CheckTarget == \"*\":\n\t\tif p.Target == \"\" {\n\t\t\terrs.AddErr(fmt.Errorf(\"target isn't set in prefix gNMI Path %v\", proto.CompactTextString(p)))\n\t\t}\n\tcase t.gpc.CheckTarget != p.Target:\n\t\terrs.AddErr(fmt.Errorf(\"target in gNMI Path %v is %q, expect %q\", proto.CompactTextString(p), p.Target, t.gpc.CheckTarget))\n\t}\n\n\tswitch {\n\tcase t.gpc.CheckOrigin == \"\": // Validation on origin field isn't requested.\n\tcase t.gpc.CheckOrigin == \"*\":\n\t\tif p.Origin == \"\" {\n\t\t\terrs.AddErr(fmt.Errorf(\"origin isn't set in prefix gNMI Path %v\", proto.CompactTextString(p)))\n\t\t}\n\tcase t.gpc.CheckOrigin != p.Origin:\n\t\terrs.AddErr(fmt.Errorf(\"origin in gNMI Path %v is %q, expect %q\", proto.CompactTextString(p), p.Origin, t.gpc.CheckOrigin))\n\t}\n\n\treturn errs\n}", "func ContainsField(path string, allowedPaths []string) bool {\n\tfor _, allowedPath := range allowedPaths {\n\t\tif path == allowedPath {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func (form *FormData) mandatoryPath(filename string, target *string) *FormData {\n\tform.path(filename, target)\n\n\tif *target != \"\" {\n\t\treturn form\n\t}\n\n\tform.append(\n\t\tfmt.Errorf(\"form file '%s' is required\", filename),\n\t)\n\n\treturn form\n}", "func (v *PathValidator) Validate(r *http.Request) error {\n\tpath := r.URL.Path\n\tif !strings.HasPrefix(v.Path, \"/\") {\n\t\tpath = strings.TrimPrefix(r.URL.Path, \"/\")\n\t}\n\treturn deepCompare(\"PathValidator\", v.Path, path)\n}", "func (e Matcher_MatcherTreeValidationError) Field() string { return e.field }", "func (e CreateLinkRequestValidationError) Field() string { return e.field }", "func (e ScopedRoutesValidationError) Field() string { return e.field }", "func ValidatePath(path string) error {\n\tif path == \"\" {\n\t\treturn fmt.Errorf(\"path cannot be empty\")\n\t}\n\tif string(path[0]) != \"/\" {\n\t\treturn fmt.Errorf(\"path must start with / character\")\n\t}\n\tif len(path) == 1 { // done checking - it's the root\n\t\treturn nil\n\t}\n\n\tif string(path[len(path)-1]) == \"/\" {\n\t\treturn fmt.Errorf(\"path must not end with / character\")\n\t}\n\n\tvar reason string\n\tlastr := '/'\n\tchars := []rune(path)\n\tfor i := 1; i < len(chars); i++ {\n\t\tr := chars[i]\n\t\tif r == 0 {\n\t\t\treason = fmt.Sprintf(\"null character not allowed @%d\", i)\n\t\t\tbreak\n\t\t} else if r == '/' && lastr == '/' {\n\t\t\treason = fmt.Sprintf(\"empty node name specified @%d\", i)\n\t\t\tbreak\n\t\t} else if r == '.' && lastr == '.' {\n\t\t\tif chars[i-2] == '/' && (i+1 == len(chars) || chars[i+1] == '/') {\n\t\t\t\treason = fmt.Sprintf(\"relative paths not allowed @%d\", i)\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else if r == '.' {\n\t\t\tif chars[i-1] == '/' && (i+1 == len(chars) || chars[i+1] == '/') {\n\t\t\t\treason = fmt.Sprintf(\"relative paths not allowed @%d\", i)\n\t\t\t\tbreak\n\t\t\t}\n\t\t} else if r > '\\u0000' && r <= '\\u001f' || r >= '\\u007f' && r <= '\\u009F' || r >= 0xd800 && r <= 0xf8ff || r >= 0xfff0 && r <= 0xffff {\n\t\t\treason = fmt.Sprintf(\"invalid character @%d\", i)\n\t\t\tbreak\n\t\t}\n\n\t\tlastr = r\n\t}\n\tif reason != \"\" {\n\t\treturn fmt.Errorf(\"Invalid path string \\\"\" + path + \"\\\" caused by \" + reason)\n\t}\n\treturn nil\n}", "func (r Rules) CheckPath(name string) error {\n\tif len(name) == 0 {\n\t\treturn &Error{isPath: true, path: name, err: errEmpty}\n\t}\n\tif name[0] == '/' {\n\t\treturn &Error{isPath: true, path: name, err: errAbsolute}\n\t}\n\trest := name\n\tfor len(rest) != 0 {\n\t\tvar part string\n\t\tswitch i := strings.IndexByte(rest, '/'); {\n\t\tcase i == 0:\n\t\t\treturn &Error{isPath: true, path: name, err: errDoubleSlash}\n\t\tcase i == -1:\n\t\t\tpart = rest\n\t\t\trest = \"\"\n\t\tdefault:\n\t\t\tpart = rest[:i]\n\t\t\trest = rest[i+1:]\n\t\t\tif len(rest) == 0 {\n\t\t\t\treturn &Error{isPath: true, path: name, err: errTrailingSlash}\n\t\t\t}\n\t\t}\n\t\tif err := r.CheckPathSegment(part); err != nil {\n\t\t\te := err.(*Error)\n\t\t\te.isPath = true\n\t\t\te.path = name\n\t\t\treturn e\n\t\t}\n\t}\n\treturn nil\n}", "func (e JsonToMetadata_RuleValidationError) Field() string { return e.field }", "func (m *PathCF) Validate() error {\n\tif m == nil {\n\t\treturn nil\n\t}\n\n\tif utf8.RuneCountInString(m.GetGlob()) < 1 {\n\t\treturn PathCFValidationError{\n\t\t\tfield: \"Glob\",\n\t\t\treason: \"value length must be at least 1 runes\",\n\t\t}\n\t}\n\n\treturn nil\n}", "func IsValidImportPath(v Value) (err error) {\n\tswitch v := v.(type) {\n\tcase Var:\n\t\tif !v.Equal(DefaultRootDocument.Value) && !v.Equal(RequestRootDocument.Value) {\n\t\t\treturn fmt.Errorf(\"invalid path %v: path must begin with request or data\", v)\n\t\t}\n\tcase Ref:\n\t\tif err := IsValidImportPath(v[0].Value); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid path %v: path must begin with request or data\", v)\n\t\t}\n\t\tfor _, e := range v[1:] {\n\t\t\tif _, ok := e.Value.(String); !ok {\n\t\t\t\treturn fmt.Errorf(\"invalid path %v: path elements must be %vs\", v, StringTypeName)\n\t\t\t}\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid path %v: path must be %v or %v\", v, RefTypeName, VarTypeName)\n\t}\n\treturn nil\n}", "func (e NodeValidationError) Field() string { return e.field }", "func (e ReferenceValidationError) Field() string { return e.field }", "func (e ScopedRoutes_ScopeKeyBuilderValidationError) Field() string { return e.field }", "func (e CreateDocV1RequestValidationError) Field() string { return e.field }", "func (v *Volume) Validate() error {\n\tif v.Path == \"\" {\n\t\treturn maskAny(errgo.WithCausef(nil, ValidationError, \"path is empty\"))\n\t}\n\tif err := v.Type.Validate(); err != nil {\n\t\treturn maskAny(err)\n\t}\n\treturn nil\n}", "func IsOptionalFieldPathNotFound(err error, s *PatchPolicy) bool {\n\tswitch {\n\tcase s == nil:\n\t\tfallthrough\n\tcase s.FromFieldPath == nil:\n\t\tfallthrough\n\tcase *s.FromFieldPath == FromFieldPathPolicyOptional:\n\t\treturn fieldpath.IsNotFound(err)\n\tdefault:\n\t\treturn false\n\t}\n}", "func (e ScopedRoutes_ScopeKeyBuilder_FragmentBuilderValidationError) Field() string { return e.field }", "func (e CreateLinkResponseValidationError) Field() string { return e.field }", "func (e PerRouteConfigValidationError) Field() string { return e.field }", "func ValidatePath(w http.ResponseWriter, r *http.Request) (string, error) {\n\tm := ValidPath.FindStringSubmatch(r.URL.Path)\n\tif m == nil {\n\t\thttp.NotFound(w, r)\n\t\treturn \"\", errors.New(\"Invalid ID. IDs must only contain alpha characters.\")\n\t}\n\treturn m[2], nil\n}", "func (e ScopedRoutes_ScopeKeyBuilder_FragmentBuilder_HeaderValueExtractor_KvElementValidationError) Field() string {\n\treturn e.field\n}", "func (e EmptyValidationError) Field() string { return e.field }", "func (e NotAllReachableValidationError) Field() string { return e.field }", "func (d *Destination) Validate(ctx context.Context) *apis.FieldError {\n\tif d == nil {\n\t\treturn nil\n\t}\n\treturn ValidateDestination(ctx, *d).ViaField(apis.CurrentField)\n}", "func (u *UserInfo) Validate(path *field.Path) (errs field.ErrorList) {\n\terrs = append(errs, u.ValidateSubjects(path.Child(\"subjects\"))...)\n\terrs = append(errs, u.ValidateRoles(path.Child(\"roles\"))...)\n\treturn errs\n}", "func validateField(f *Field, hash map[string]string) {\n\tlength := 0\n\n\tif f.Value != \"\" {\n\t\tlength = len(f.Value)\n\t}\n\n\tswitch {\n\tcase length < f.Length.Min || length > f.Length.Max:\n\t\thash[f.Name] = fmt.Sprintf(LENGTH_ERROR, f.DisplayName, f.Length.Min, f.Length.Max)\n\tcase f.Regex != nil:\n\t\tmatches, _ := regexp.MatchString(f.Regex.Pattern, f.Value)\n\n\t\tif !matches {\n\t\t\thash[f.Name] = fmt.Sprintf(f.Regex.Error, f.DisplayName)\n\t\t}\n\t}\n}", "func (e DataPointValidationError) Field() string { return e.field }", "func (e PassiveHealthCheckUnhealthyValidationError) Field() string { return e.field }", "func (e TwoOneofsValidationError) Field() string { return e.field }", "func (e MatcherValidationError) Field() string { return e.field }", "func (e CreateDocV1ResponseValidationError) Field() string { return e.field }", "func (e MovableObjectValidationError) Field() string { return e.field }", "func (e HealthCheck_GrpcHealthCheckValidationError) Field() string { return e.field }", "func (e CreateNamespaceWithQuotaReqValidationError) Field() string { return e.field }", "func (e HTTPRequestValidationError) Field() string { return e.field }", "func (e DocValidationError) Field() string { return e.field }", "func (e DeleteLinkRequestValidationError) Field() string { return e.field }", "func (m *NotFoundError) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateCode(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (e PassiveHealthCheckValidationError) Field() string { return e.field }", "func (e ScopedRoutes_ScopeKeyBuilder_FragmentBuilder_HeaderValueExtractorValidationError) Field() string {\n\treturn e.field\n}", "func (e LinkEntityValidationError) Field() string { return e.field }", "func (e EutracgiValidationError) Field() string { return e.field }", "func (e NoOneofsValidationError) Field() string { return e.field }", "func (e ConfigurationFileValidationError) Field() string { return e.field }", "func IsOptionalFieldPathNotFound(err error, p *v1.PatchPolicy) bool {\n\tswitch {\n\tcase p == nil:\n\t\tfallthrough\n\tcase p.FromFieldPath == nil:\n\t\tfallthrough\n\tcase *p.FromFieldPath == v1.FromFieldPathPolicyOptional:\n\t\treturn fieldpath.IsNotFound(err)\n\tdefault:\n\t\treturn false\n\t}\n}", "func (e HealthCheck_HttpHealthCheckValidationError) Field() string { return e.field }", "func (o BuildStrategySpecBuildStepsEnvValueFromFieldRefPtrOutput) FieldPath() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *BuildStrategySpecBuildStepsEnvValueFromFieldRef) *string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.FieldPath\n\t}).(pulumi.StringPtrOutput)\n}", "func (e FindLinksRequestValidationError) Field() string { return e.field }", "func (e CreateRequestValidationError) Field() string { return e.field }", "func (e CreateRequestValidationError) Field() string { return e.field }", "func (e NrtValidationError) Field() string { return e.field }", "func (e SimpleRequestValidationError) Field() string { return e.field }", "func (v *validator) validateStruct(value reflect.Value, path string) {\n\tprefix := \".\"\n\tif path == \"\" {\n\t\tprefix = \"\"\n\t}\n\n\tfor i := 0; i < value.Type().NumField(); i++ {\n\t\tf := value.Type().Field(i)\n\t\tif strings.ToLower(f.Name[0:1]) == f.Name[0:1] {\n\t\t\tcontinue\n\t\t}\n\t\tfvalue := value.FieldByName(f.Name)\n\n\t\tnotset := false\n\t\tif f.Tag.Get(\"required\") != \"\" {\n\t\t\tswitch fvalue.Kind() {\n\t\t\tcase reflect.Ptr, reflect.Slice, reflect.Map:\n\t\t\t\tif fvalue.IsNil() {\n\t\t\t\t\tnotset = true\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tif !fvalue.IsValid() {\n\t\t\t\t\tnotset = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif notset {\n\t\t\tmsg := \"missing required parameter: \" + path + prefix + f.Name\n\t\t\tv.errors = append(v.errors, msg)\n\t\t} else {\n\t\t\tv.validateAny(fvalue, path+prefix+f.Name)\n\t\t}\n\t}\n}", "func (e HealthCheck_CustomHealthCheckValidationError) Field() string { return e.field }", "func (e EarfcnValidationError) Field() string { return e.field }", "func (e RemoveDocV1RequestValidationError) Field() string { return e.field }", "func (e TwoValidOneofsValidationError) Field() string { return e.field }", "func (e CreateMovableObjectRequestValidationError) Field() string { return e.field }", "func (o BuildStrategySpecBuildStepsEnvValueFromFieldRefOutput) FieldPath() pulumi.StringOutput {\n\treturn o.ApplyT(func(v BuildStrategySpecBuildStepsEnvValueFromFieldRef) string { return v.FieldPath }).(pulumi.StringOutput)\n}", "func (e PassiveHealthCheckHealthyValidationError) Field() string { return e.field }", "func (e CreateTodoRequestValidationError) Field() string { return e.field }", "func (e RequirementRuleValidationError) Field() string { return e.field }", "func (e DeleteLinkResponseValidationError) Field() string { return e.field }", "func (s *Segment) Validate() error {\n\tif s.Name == nil {\n\t\treturn errors.New(`segment \"name\" can not be nil`)\n\t}\n\n\tif s.ID == nil {\n\t\treturn errors.New(`segment \"id\" can not be nil`)\n\t}\n\n\tif s.StartTime == nil {\n\t\treturn errors.New(`segment \"start_time\" can not be nil`)\n\t}\n\n\t// it's ok for embedded subsegments to not have trace_id\n\t// but the root segment and independent subsegments must all\n\t// have trace_id.\n\tif s.TraceID == nil {\n\t\treturn errors.New(`segment \"trace_id\" can not be nil`)\n\t}\n\n\treturn nil\n}", "func (e ResolveRequestValidationError) Field() string { return e.field }", "func (v *StringsArePathsNotInTheSameDir) Validate(e *validator.Errors) {\n\tabsFieldPath, _ := filepath.Abs(v.Field)\n\tabsComparedFieldPath, _ := filepath.Abs(v.ComparedField)\n\n\tif (filepath.Dir(absFieldPath) != filepath.Dir(absComparedFieldPath)) &&\n\t\tfilepath.IsAbs(absFieldPath) &&\n\t\tfilepath.IsAbs(absComparedFieldPath) {\n\t\treturn\n\t}\n\n\te.Add(v.Name, StringsArePathsNotInTheSameDirError(v))\n}", "func (e CreateTodoResponseValidationError) Field() string { return e.field }", "func (e ExerciseValidationError) Field() string { return e.field }", "func (m MountPointOpts) validate() error {\n\tpath := aws.StringValue(m.ContainerPath)\n\tif path == \"\" {\n\t\treturn &errFieldMustBeSpecified{\n\t\t\tmissingField: \"path\",\n\t\t}\n\t}\n\tif err := validateVolumePath(path); err != nil {\n\t\treturn fmt.Errorf(`validate \"path\": %w`, err)\n\t}\n\treturn nil\n}", "func (e RequestValidationError) Field() string { return e.field }", "func (o IopingSpecVolumeVolumeSourceDownwardAPIItemsFieldRefOutput) FieldPath() pulumi.StringOutput {\n\treturn o.ApplyT(func(v IopingSpecVolumeVolumeSourceDownwardAPIItemsFieldRef) string { return v.FieldPath }).(pulumi.StringOutput)\n}", "func (o VirtualDatabaseSpecDatasourcesPropertiesValueFromFieldRefOutput) FieldPath() pulumi.StringOutput {\n\treturn o.ApplyT(func(v VirtualDatabaseSpecDatasourcesPropertiesValueFromFieldRef) string { return v.FieldPath }).(pulumi.StringOutput)\n}", "func (e NrcgiValidationError) Field() string { return e.field }", "func (e CreateNamespaceReqValidationError) Field() string { return e.field }", "func (m *Http404Error) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateResource(formats); err != nil {\n\t\t// prop\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m *ContainerDelete) Field(fieldpath []string) (string, bool) {\n\tif len(fieldpath) == 0 {\n\t\treturn \"\", false\n\t}\n\n\tswitch fieldpath[0] {\n\tcase \"id\":\n\t\treturn string(m.ID), len(m.ID) > 0\n\t}\n\treturn \"\", false\n}", "func (e DescribeDocV1RequestValidationError) Field() string { return e.field }", "func (e WordValidationError) Field() string { return e.field }", "func (ctx ValidationContext) Validate(s *Schema, spath string, v interface{}, vpath string) error {\n\tif vpath == \"\" {\n\t\treturn ctx.validateInplace(s, spath)\n\t}\n\treturn ctx.validate(s, spath, v, vpath)\n}", "func (e CreateDisscusRespValidationError) Field() string { return e.field }", "func (e Matcher_OnMatchValidationError) Field() string { return e.field }", "func (o *CreateUserRequest) HasPath() bool {\n\tif o != nil && o.Path != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (m *FingerPath) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateBlur(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateBoardColor(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateClear(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateDash(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateFingerPoints(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validatePathColor(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateStrokeWidth(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (e CreateNamespaceWithQuotaRespValidationError) Field() string { return e.field }", "func (e HealthCheckValidationError) Field() string { return e.field }", "func (e HealthCheckValidationError) Field() string { return e.field }" ]
[ "0.61732626", "0.616282", "0.61580884", "0.61464876", "0.6046862", "0.597934", "0.5973007", "0.59136385", "0.5814603", "0.57751167", "0.5684489", "0.5603558", "0.5591774", "0.55728245", "0.550294", "0.54576457", "0.54488456", "0.54190725", "0.54136354", "0.54079545", "0.54070395", "0.5399927", "0.5395902", "0.53743607", "0.5364955", "0.5351689", "0.5350055", "0.5349733", "0.5322969", "0.53197736", "0.5317656", "0.5314924", "0.52998877", "0.52906966", "0.5290181", "0.5287044", "0.5272096", "0.52686787", "0.5266935", "0.5254405", "0.52455443", "0.5238205", "0.52341616", "0.5230282", "0.52271396", "0.52232033", "0.5222968", "0.52228266", "0.52212083", "0.5212881", "0.5211167", "0.5207364", "0.5197694", "0.5195868", "0.51956296", "0.51896375", "0.51876944", "0.5185873", "0.5184634", "0.5182842", "0.51819056", "0.5176624", "0.51745623", "0.51745623", "0.5173301", "0.5172385", "0.51715523", "0.51706773", "0.516426", "0.5162969", "0.5161569", "0.51576036", "0.5148612", "0.51443076", "0.514357", "0.5142439", "0.5137266", "0.512989", "0.51239127", "0.5123499", "0.5120861", "0.5119858", "0.5119142", "0.5118724", "0.5109218", "0.51090425", "0.5108988", "0.5107013", "0.51060873", "0.5104771", "0.5101419", "0.5100077", "0.5099411", "0.50957507", "0.50923383", "0.5092066", "0.5091765", "0.50902474", "0.5089561", "0.5089561" ]
0.69477284
0
SetField sets validator field.
func (v *StringIsPath) SetField(s string) { v.Field = s }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (self *Bgmchain) SetValidator(validator bgmcommon.Address) {\n\tself.lock.Lock()\n\tself.validator = validator\n\tself.lock.Unlock()\n}", "func (bc *BlockChain) SetValidator(validator Validator) {\n\tbc.procmu.Lock()\n\tdefer bc.procmu.Unlock()\n\tbc.validator = validator\n}", "func (p *PCache) SetValidator(kind string, validator ValidatorFn) {\n\tp.Log.Infof(\"validator set for kind %s\", kind)\n\tp.Lock()\n\tp.kindOptsMap[kind].Validator = validator\n\tp.Unlock()\n\treturn\n}", "func (b *baseValue) Set(s string) error {\n\tif err := b.validationFunc(s); err != nil {\n\t\treturn err\n\t}\n\tb.value = s\n\treturn nil\n}", "func (f *Field) Set(val interface{}) error {\n\t// we can't set unexported fields, so be sure this field is exported\n\tif !f.IsExported() {\n\t\treturn errNotExported\n\t}\n\n\t// do we get here? not sure...\n\tif !f.value.CanSet() {\n\t\treturn errNotSettable\n\t}\n\n\tgiven := reflect.ValueOf(val)\n\n\tif f.value.Kind() != given.Kind() {\n\t\treturn fmt.Errorf(\"wrong kind. got: %s want: %s\", given.Kind(), f.value.Kind())\n\t}\n\n\tf.value.Set(given)\n\treturn nil\n}", "func (o *Compliance) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (x *fastReflection_MsgWithdrawValidatorCommission) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission.validator_address\":\n\t\tx.ValidatorAddress = value.Interface().(string)\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission does not contain field %s\", fd.FullName()))\n\t}\n}", "func (x *fastReflection_ValidatorSlashEventRecord) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.validator_address\":\n\t\tx.ValidatorAddress = value.Interface().(string)\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.height\":\n\t\tx.Height = value.Uint()\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.period\":\n\t\tx.Period = value.Uint()\n\tcase \"cosmos.distribution.v1beta1.ValidatorSlashEventRecord.validator_slash_event\":\n\t\tx.ValidatorSlashEvent = value.Message().Interface().(*ValidatorSlashEvent)\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.ValidatorSlashEventRecord\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.ValidatorSlashEventRecord does not contain field %s\", fd.FullName()))\n\t}\n}", "func Set(target, source interface{}) error {\n\tconverter := &Converter{\n\t\tTagName: \"field\",\n\t}\n\n\treturn converter.Convert(source, target)\n}", "func (f *Field) Set(l *Location, val string, seps *Delimeters) error {\n\tloc := l.Comp\n\tif loc < 0 {\n\t\tloc = 0\n\t}\n\tif x := loc - len(f.Components) + 1; x > 0 {\n\t\tf.Components = append(f.Components, make([]Component, x)...)\n\t}\n\terr := f.Components[loc].Set(l, val, seps)\n\tif err != nil {\n\t\treturn err\n\t}\n\tf.Value = f.encode(seps)\n\treturn nil\n}", "func (s *StructField) Set(v interface{}) error {\n\tif s.field.PkgPath != \"\" {\n\t\treturn errors.New(\"Field is not exported\")\n\t}\n\n\tif !s.CanSet() {\n\t\treturn errors.New(\"Field cannot be set\")\n\t}\n\n\tgiven := reflect.ValueOf(v)\n\n\tif s.value.Kind() != given.Kind() {\n\t\treturn errors.New(\"Field and value kind don't match\")\n\t}\n\n\ts.value.Set(given)\n\treturn nil\n}", "func (field *Field) Set(value interface{}) (err error) {\n\tif !field.Field.IsValid() {\n\t\treturn errors.New(\"field value not valid\")\n\t}\n\n\tif !field.Field.CanAddr() {\n\t\treturn ErrUnaddressable\n\t}\n\n\treflectValue, ok := value.(reflect.Value)\n\tif !ok {\n\t\treflectValue = reflect.ValueOf(value)\n\t}\n\n\tfieldValue := field.Field\n\tif reflectValue.IsValid() {\n\t\tif reflectValue.Type().ConvertibleTo(fieldValue.Type()) {\n\t\t\tfieldValue.Set(reflectValue.Convert(fieldValue.Type()))\n\t\t} else {\n\t\t\tif fieldValue.Kind() == reflect.Ptr {\n\t\t\t\tif fieldValue.IsNil() {\n\t\t\t\t\tfieldValue.Set(reflect.New(field.Struct.Type.Elem()))\n\t\t\t\t}\n\t\t\t\tfieldValue = fieldValue.Elem()\n\t\t\t}\n\n\t\t\tif reflectValue.Type().ConvertibleTo(fieldValue.Type()) {\n\t\t\t\tfieldValue.Set(reflectValue.Convert(fieldValue.Type()))\n\t\t\t} else {\n\t\t\t\terr = fmt.Errorf(\"could not convert argument of field %s from %s to %s\", field.Name, reflectValue.Type(), fieldValue.Type())\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfield.Field.Set(reflect.Zero(field.Field.Type()))\n\t}\n\n\treturn err\n}", "func (r *Wrapper) Set(name string, val any) error {\n\tfv := r.rv.FieldByName(name)\n\tif !fv.IsValid() {\n\t\treturn errors.New(\"field not found\")\n\t}\n\n\tif !fv.CanSet() {\n\t\treturn errors.New(\"field can not set value\")\n\t}\n\n\tfv.Set(reflect.ValueOf(val))\n\treturn nil\n}", "func (r *Router) SetValidator(v *Validator) {\n\tr.validator = v\n}", "func (f FormField) SetValidators(validators *ValidatorsList) FormField {\n\tf.Validators = validators\n\treturn f\n}", "func (field *Field) SetValue(parser *ArgParse, args ...string) (size int, err error) {\n\tsize = 1\n\t// the basic setter\n\tif size, err = field.setValue(field.Value, args...); err != nil {\n\t\treturn\n\t}\n\n\tif fn := GetCallback(parser.Value, field.Callback); fn != nil {\n\t\tlog.Debug(\"try execute %v\", field.Callback)\n\t\t// trigger the callback, exit when callback return true\n\t\tif fn(parser) && ExitWhenCallback {\n\t\t\tlog.Info(\"execute callback %v, and exit 0\", field.Callback)\n\t\t\tos.Exit(0)\n\t\t}\n\t}\n\n\tfield.BeenSet = true\n\tif field.Value.Kind() == reflect.Ptr && field.Value.Elem().Kind() == reflect.Slice {\n\t\t// can set repeat\n\t\tfield.BeenSet = false\n\t}\n\tlog.Info(\"set %v as %v (%d)\", field.Name, field.Value, size)\n\treturn\n}", "func (field *Field) Set(value interface{}) (err error) {\n if !field.Field.IsValid() {\n return errors.New(\"field value not valid\")\n }\n\n if !field.Field.CanAddr() {\n return ErrUnaddressable\n }\n\n reflectValue, ok := value.(reflect.Value)\n if !ok {\n reflectValue = reflect.ValueOf(value)\n }\n\n fieldValue := field.Field\n if reflectValue.IsValid() {\n if reflectValue.Type().ConvertibleTo(fieldValue.Type()) {\n fieldValue.Set(reflectValue.Convert(fieldValue.Type()))\n } else {\n if fieldValue.Kind() == reflect.Ptr {\n if fieldValue.IsNil() {\n fieldValue.Set(reflect.New(field.Struct.Type.Elem()))\n }\n fieldValue = fieldValue.Elem()\n }\n\n if reflectValue.Type().ConvertibleTo(fieldValue.Type()) {\n fieldValue.Set(reflectValue.Convert(fieldValue.Type()))\n } else if scanner, ok := fieldValue.Addr().Interface().(sql.Scanner); ok {\n v := reflectValue.Interface()\n if valuer, ok := v.(driver.Valuer); ok {\n if v, err = valuer.Value(); err == nil {\n err = scanner.Scan(v)\n }\n } else {\n err = scanner.Scan(v)\n }\n } else {\n err = fmt.Errorf(\"could not convert argument of field %s from %s to %s\", field.Name, reflectValue.Type(), fieldValue.Type())\n }\n }\n } else {\n field.Field.Set(reflect.Zero(field.Field.Type()))\n }\n\n field.IsBlank = isBlank(field.Field)\n return err\n}", "func (me *TClipFillRuleType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (m *AuthorizeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase authorize.FieldProvider:\n\t\tv, ok := value.(authorize.Provider)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetProvider(v)\n\t\treturn nil\n\tcase authorize.FieldServiceID:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetServiceID(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Authorize field %s\", name)\n}", "func (m *ModelStructRecord) SetField(name string, value reflect.Value) {\n\tif name == \"\" {\n\t\treturn\n\t}\n\tfieldValue := m.FieldValues[name]\n\t//if value.Kind() == reflect.Ptr {\n\t//\tpanic(\"RecordFieldSetError: value cannot be a ptr\")\n\t//}\n\tif fieldValue.IsValid() == false {\n\t\tm.VirtualFieldValues[name] = reflect.New(m.model.GetFieldWithName(name).StructField().Type).Elem()\n\t\tfieldValue = m.VirtualFieldValues[name]\n\t}\n\t//fieldValue = LoopIndirectAndNew(fieldValue)\n\tsafeSet(fieldValue, value)\n}", "func (cv *Choice) Set(value string) error {\n\tif indexof.String(cv.AllowedValues, value) == indexof.NotFound {\n\t\treturn fmt.Errorf(\n\t\t\t\"invalid flag value: %s, must be one of %s\",\n\t\t\tvalue,\n\t\t\tstrings.Join(cv.AllowedValues, \", \"),\n\t\t)\n\t}\n\n\tcv.Choice = &value\n\treturn nil\n}", "func (o *Wfmagent) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (mapper GovMapper) saveValidatorSet(ctx context.Context, proposalID uint64) {\n\tvalidators := ecomapper.GetValidatorMapper(ctx).GetActiveValidatorSet(false)\n\tif validators != nil {\n\t\tmapper.Set(KeyVotingPeriodValidators(proposalID), validators)\n\t}\n}", "func (me *TxsdFiscalYear) Set(s string) { (*xsdt.Integer)(me).Set(s) }", "func (m *SalaryMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase salary.FieldSALARY:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetSALARY(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Salary field %s\", name)\n}", "func (o *Wfmbushorttermforecastimportcompletetopicbuforecastmodification) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *PatientrightsMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase patientrights.FieldPermissionDate:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPermissionDate(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Patientrights field %s\", name)\n}", "func (o *Oauthclientrequest) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Createshareresponse) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *AbilitypatientrightsMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase abilitypatientrights.FieldOperative:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetOperative(v)\n\t\treturn nil\n\tcase abilitypatientrights.FieldMedicalSupplies:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetMedicalSupplies(v)\n\t\treturn nil\n\tcase abilitypatientrights.FieldExamine:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetExamine(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Abilitypatientrights field %s\", name)\n}", "func (o *Voicemailmessagestopicvoicemailmessage) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (f *Fieldx) Set(v interface{}) error {\n\tif !f.IsExport() {\n\t\treturn ErrNotExported\n\t}\n\n\tif !f.value.CanSet() {\n\t\treturn errNotSettable\n\t}\n\n\tvv := reflect.ValueOf(v)\n\tif f.Kind() != vv.Kind() {\n\t\treturn fmt.Errorf(\"xstruct: value kind not match, want: %s but got %s\", f.Kind(), vv.Kind())\n\t}\n\n\tf.value.Set(vv)\n\n\treturn nil\n}", "func (o *Outcomequantilecondition) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (b *Bitfield) Set(field Bitfield, value bool) {\n\tif value {\n\t\t*b |= field\n\t} else {\n\t\t*b &= Bitfield(^uint8(field))\n\t}\n}", "func (m *PetruleMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase petrule.FieldPetrule:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPetrule(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Petrule field %s\", name)\n}", "func (m *mParcelMockAllowedSenderObjectAndRole) Set(f func() (r *insolar.Reference, r1 insolar.DynamicRole)) *ParcelMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.AllowedSenderObjectAndRoleFunc = f\n\treturn m.mock\n}", "func (o *Dialercampaignconfigchangecampaign) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *PatientrightstypeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase patientrightstype.FieldPermission:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPermission(v)\n\t\treturn nil\n\tcase patientrightstype.FieldPermissionArea:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPermissionArea(v)\n\t\treturn nil\n\tcase patientrightstype.FieldResponsible:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetResponsible(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Patientrightstype field %s\", name)\n}", "func (d *DateValue) Set(s string) error {\n\tv, err := time.Parse(\"2006-01-02\", s)\n\t*d = DateValue(v)\n\treturn err\n}", "func (fic *FrameInputConverter) Set(fieldIdx, rowIdx int, val interface{}) error {\n\tif fic.fieldConverters[fieldIdx].Converter == nil {\n\t\tfic.Frame.Set(fieldIdx, rowIdx, val)\n\t\treturn nil\n\t}\n\tconvertedVal, err := fic.fieldConverters[fieldIdx].Converter(val)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfic.Frame.Set(fieldIdx, rowIdx, convertedVal)\n\treturn nil\n}", "func (f *ExtensionField) Set(t protoreflect.ExtensionType, v protoreflect.Value) {\n\tf.typ = t\n\tf.value = v\n\tf.lazy = nil\n}", "func (field *Field) SetField() {\n\tdefer func() {\n\t\tif err := recover(); err != nil {\n\t\t}\n\t}()\n\n\tfield.SetDefault()\n\tfield.SetName()\n\tfield.SetIgnore()\n\tfield.SetDoc()\n\t//\tfield.SetShort()\n\tfield.SetOmit()\n\tfield.SetRequired()\n\tfield.SetKeyName()\n\tfield.SetFlagName()\n\tfield.SetValueFromEnv()\n\tfield.SetType()\n\t// Must run last if referencing any info from field settings\n\tif field.UseFlags {\n\t\tfield.AddFlag()\n\t}\n}", "func (field *Field) Set(x, y int, b bool) {\n\tfield.states[y][x] = b\n}", "func (m *RentalstatusMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase rentalstatus.FieldRentalstatus:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRentalstatus(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Rentalstatus field %s\", name)\n}", "func (n *Node) SetField(field string, val interface{}) bool {\n\tfv := kit.FlatFieldValueByName(n.This, field)\n\tif !fv.IsValid() {\n\t\tlog.Printf(\"ki.SetField, could not find field %v on node %v\\n\", field, n.PathUnique())\n\t\treturn false\n\t}\n\tupdt := n.UpdateStart()\n\tok := kit.SetRobust(kit.PtrValue(fv).Interface(), val)\n\tif ok {\n\t\tbitflag.Set(n.Flags(), int(FieldUpdated))\n\t}\n\tn.UpdateEnd(updt)\n\treturn ok\n}", "func (m *mOutboundMockCanAccept) Set(f func(p Inbound) (r bool)) *OutboundMock {\n\tm.mainExpectation = nil\n\tm.expectationSeries = nil\n\n\tm.mock.CanAcceptFunc = f\n\treturn m.mock\n}", "func (d Document) SetField(field string, value interface{}) error {\n\tif d.m != nil {\n\t\td.m[field] = value\n\t\treturn nil\n\t}\n\tpanic(\"unimplemented\")\n}", "func (mmIsRelayForbidden *mPacketParserMockIsRelayForbidden) Set(f func() (b1 bool)) *PacketParserMock {\n\tif mmIsRelayForbidden.defaultExpectation != nil {\n\t\tmmIsRelayForbidden.mock.t.Fatalf(\"Default expectation is already set for the PacketParser.IsRelayForbidden method\")\n\t}\n\n\tif len(mmIsRelayForbidden.expectations) > 0 {\n\t\tmmIsRelayForbidden.mock.t.Fatalf(\"Some expectations are already set for the PacketParser.IsRelayForbidden method\")\n\t}\n\n\tmmIsRelayForbidden.mock.funcIsRelayForbidden = f\n\treturn mmIsRelayForbidden.mock\n}", "func (f *Field) SetValue(newValue interface{}) {\n\tf.Call(\"setValue\", newValue)\n}", "func (m *StatusdMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase statusd.FieldStatusdname:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetStatusdname(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Statusd field %s\", name)\n}", "func (f Field) Set(x, y int, b bool) {\n\tf.s[y][x] = b\n}", "func (o *Digitalcondition) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (cs *ConsensusState) SetPrivValidator(priv ttypes.PrivValidator) {\n\tcs.mtx.Lock()\n\tdefer cs.mtx.Unlock()\n\tcs.privValidator = priv\n}", "func (m *InviteeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase invitee.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase invitee.FieldIsChild:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsChild(v)\n\t\treturn nil\n\tcase invitee.FieldHasPlusOne:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetHasPlusOne(v)\n\t\treturn nil\n\tcase invitee.FieldIsBridesmaid:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsBridesmaid(v)\n\t\treturn nil\n\tcase invitee.FieldIsGroomsman:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsGroomsman(v)\n\t\treturn nil\n\tcase invitee.FieldPlusOneName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPlusOneName(v)\n\t\treturn nil\n\tcase invitee.FieldPhone:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPhone(v)\n\t\treturn nil\n\tcase invitee.FieldEmail:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmail(v)\n\t\treturn nil\n\tcase invitee.FieldAddressLine1:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressLine1(v)\n\t\treturn nil\n\tcase invitee.FieldAddressLine2:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressLine2(v)\n\t\treturn nil\n\tcase invitee.FieldAddressCity:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressCity(v)\n\t\treturn nil\n\tcase invitee.FieldAddressState:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressState(v)\n\t\treturn nil\n\tcase invitee.FieldAddressPostalCode:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressPostalCode(v)\n\t\treturn nil\n\tcase invitee.FieldAddressCountry:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAddressCountry(v)\n\t\treturn nil\n\tcase invitee.FieldRsvpResponse:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRsvpResponse(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Invitee field %s\", name)\n}", "func (m *EventRSVPMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\t}\n\treturn fmt.Errorf(\"unknown EventRSVP field %s\", name)\n}", "func (u ConstraintUpdater) SetValue(value string) ConstraintUpdater {\n\tu.fields[string(ConstraintDBSchema.Value)] = value\n\treturn u\n}", "func (f *transformingValue) Set(s string) error {\n\treturn f.Value.Set(f.fn(s))\n}", "func (o *Wfmintradaydataupdatetopicintradayhistoricalqueuedata) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (o *Workitemwrapup) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *ManagerMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase manager.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase manager.FieldEmail:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEmail(v)\n\t\treturn nil\n\tcase manager.FieldPassword:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPassword(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Manager field %s\", name)\n}", "func (m *RepairingMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase repairing.FieldRepairpart:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRepairpart(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Repairing field %s\", name)\n}", "func (m *SalaryMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase salary.FieldSalary:\n\t\tv, ok := value.(float64)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetSalary(v)\n\t\treturn nil\n\tcase salary.FieldBonus:\n\t\tv, ok := value.(float64)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetBonus(v)\n\t\treturn nil\n\tcase salary.FieldSalaryDatetime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetSalaryDatetime(v)\n\t\treturn nil\n\tcase salary.FieldAccountNumber:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAccountNumber(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Salary field %s\", name)\n}", "func SetValidate(v *validator.Validate) {\n\tvalidate = v\n}", "func (m *ClassifierMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase classifier.FieldEQUIPMENTCLASSIFIER:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetEQUIPMENTCLASSIFIER(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Classifier field %s\", name)\n}", "func (m *RobberMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\t}\n\treturn fmt.Errorf(\"unknown Robber field %s\", name)\n}", "func (m *MedicalrecordstaffMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\t}\n\treturn fmt.Errorf(\"unknown Medicalrecordstaff field %s\", name)\n}", "func (m *PermissionMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase permission.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Permission field %s\", name)\n}", "func (f *Fields) Set(s []*Field)", "func (m *GroupMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\t}\n\treturn fmt.Errorf(\"unknown Group field %s\", name)\n}", "func (m *SeverityMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase severity.FieldSeverityName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetSeverityName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Severity field %s\", name)\n}", "func (m *EquipmentrentalMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase equipmentrental.FieldRENTALAMOUNT:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRENTALAMOUNT(v)\n\t\treturn nil\n\tcase equipmentrental.FieldRENTALDATE:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRENTALDATE(v)\n\t\treturn nil\n\tcase equipmentrental.FieldRETURNDATE:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRETURNDATE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Equipmentrental field %s\", name)\n}", "func (me *TFilterValueType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (o *Contentmanagementworkspacedocumentstopicdocumentdatav2) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (me *TAttlistInvestigatorValidYN) Set(s string) { (*xsdt.Token)(me).Set(s) }", "func (m *SettlementMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase settlement.FieldX:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetX(v)\n\t\treturn nil\n\tcase settlement.FieldY:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetY(v)\n\t\treturn nil\n\tcase settlement.FieldIsCity:\n\t\tv, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetIsCity(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Settlement field %s\", name)\n}", "func (cm *ConsensusManager) SetPrivValidator(priv *PrivValidator) {\n\tcm.mtx.Lock()\n\tdefer cm.mtx.Unlock()\n\tcm.privValidator = priv\n}", "func (o *Webchatmemberinfo) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *GroupMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase group.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Group field %s\", name)\n}", "func (m *CleaningroomMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase cleaningroom.FieldNote:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNote(v)\n\t\treturn nil\n\tcase cleaningroom.FieldDateandstarttime:\n\t\tv, ok := value.(time.Time)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDateandstarttime(v)\n\t\treturn nil\n\tcase cleaningroom.FieldPhonenumber:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetPhonenumber(v)\n\t\treturn nil\n\tcase cleaningroom.FieldNumofem:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNumofem(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Cleaningroom field %s\", name)\n}", "func (me *TStrokeMiterLimitValueType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (m *NurseMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase nurse.FieldNurseName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNurseName(v)\n\t\treturn nil\n\tcase nurse.FieldNurseEmail:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNurseEmail(v)\n\t\treturn nil\n\tcase nurse.FieldNursePassword:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNursePassword(v)\n\t\treturn nil\n\tcase nurse.FieldNurseTel:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetNurseTel(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Nurse field %s\", name)\n}", "func (opts *ListOpts) Set(value string) error {\n if opts.validator != nil {\n v, err := opts.validator(value)\n if err != nil {\n return err\n }\n value = v\n }\n (*opts.values) = append((*opts.values), value)\n return nil\n}", "func (m *AgeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase age.FieldAGE:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetAGE(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Age field %s\", name)\n}", "func (s *settableBool) Set(v string) error {\n\tb, err := strconv.ParseBool(v)\n\tif err != nil {\n\t\treturn err\n\t}\n\ts.val = b\n\ts.isSet = true\n\treturn nil\n}", "func (m *TradeConditionMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase tradecondition.FieldCondition:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCondition(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown TradeCondition field %s\", name)\n}", "func (f BooleanField) Set(val interface{}) FieldAssignment {\n\treturn FieldAssignment{\n\t\tField: f,\n\t\tValue: val,\n\t}\n}", "func (o *Posttextresponse) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *CompanyMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase company.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Company field %s\", name)\n}", "func (m *InsuranceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase insurance.FieldCompany:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCompany(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Insurance field %s\", name)\n}", "func (x *fastReflection_ValidatorAccumulatedCommissionRecord) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {\n\tswitch fd.FullName() {\n\tcase \"cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord.validator_address\":\n\t\tx.ValidatorAddress = value.Interface().(string)\n\tcase \"cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord.accumulated\":\n\t\tx.Accumulated = value.Message().Interface().(*ValidatorAccumulatedCommission)\n\tdefault:\n\t\tif fd.IsExtension() {\n\t\t\tpanic(fmt.Errorf(\"proto3 declared messages do not support extensions: cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord\"))\n\t\t}\n\t\tpanic(fmt.Errorf(\"message cosmos.distribution.v1beta1.ValidatorAccumulatedCommissionRecord does not contain field %s\", fd.FullName()))\n\t}\n}", "func (m *CleanernameMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase cleanername.FieldCleanername:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetCleanername(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Cleanername field %s\", name)\n}", "func (m *RestaurantMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\t}\n\treturn fmt.Errorf(\"unknown Restaurant field %s\", name)\n}", "func (m *CompetenceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase competence.FieldName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetName(v)\n\t\treturn nil\n\tcase competence.FieldLevel:\n\t\tv, ok := value.(int)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetLevel(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Competence field %s\", name)\n}", "func (k Keeper) SetStakedValidator(ctx sdk.Ctx, validator types.Validator) {\n\tstore := ctx.KVStore(k.storeKey)\n\t_ = store.Set(types.KeyForValidatorInStakingSet(validator), validator.Address)\n\t// save in the network id stores for quick session generations\n\t//k.SetStakedValidatorByChains(ctx, validator)\n}", "func (m *ToolMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase tool.FieldToolName:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetToolName(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Tool field %s\", name)\n}", "func (m *LengthtimeMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase lengthtime.FieldLengthtime:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetLengthtime(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Lengthtime field %s\", name)\n}", "func (m *FederatedTokenValidationPolicy) SetValidatingDomains(value ValidatingDomainsable)() {\n err := m.GetBackingStore().Set(\"validatingDomains\", value)\n if err != nil {\n panic(err)\n }\n}", "func (self *Encoder) SetValidateString(f bool) {\n if f {\n self.Opts |= ValidateString\n } else {\n self.Opts &= ^ValidateString\n }\n}", "func (o *Integrationtype) SetField(field string, fieldValue interface{}) {\n\t// Get Value object for field\n\ttarget := reflect.ValueOf(o)\n\ttargetField := reflect.Indirect(target).FieldByName(field)\n\n\t// Set value\n\tif fieldValue != nil {\n\t\ttargetField.Set(reflect.ValueOf(fieldValue))\n\t} else {\n\t\t// Must create a new Value (creates **type) then get its element (*type), which will be nil pointer of the appropriate type\n\t\tx := reflect.Indirect(reflect.New(targetField.Type()))\n\t\ttargetField.Set(x)\n\t}\n\n\t// Add field to set field names list\n\tif o.SetFieldNames == nil {\n\t\to.SetFieldNames = make(map[string]bool)\n\t}\n\to.SetFieldNames[field] = true\n}", "func (m *DropMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase drop.FieldObjectID:\n\t\tv, ok := value.(uint32)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetObjectID(v)\n\t\treturn nil\n\tcase drop.FieldRate:\n\t\tv, ok := value.(float32)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetRate(v)\n\t\treturn nil\n\tcase drop.FieldSeriesID:\n\t\tv, ok := value.(uint32)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetSeriesID(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Drop field %s\", name)\n}", "func (m *DistanceMutation) SetField(name string, value ent.Value) error {\n\tswitch name {\n\tcase distance.FieldDistance:\n\t\tv, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unexpected type %T for field %s\", value, name)\n\t\t}\n\t\tm.SetDistance(v)\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"unknown Distance field %s\", name)\n}" ]
[ "0.6745325", "0.6549376", "0.6272245", "0.59254694", "0.58315104", "0.5823037", "0.5804896", "0.5743061", "0.57349515", "0.5696178", "0.5676906", "0.5657407", "0.5617112", "0.56097883", "0.55886614", "0.5579758", "0.556051", "0.5544205", "0.55363196", "0.55320895", "0.5531661", "0.5503294", "0.54964703", "0.5481366", "0.5470726", "0.5468656", "0.54667705", "0.54533046", "0.54039025", "0.5373498", "0.5371503", "0.53702563", "0.5369595", "0.5367038", "0.53646433", "0.5352885", "0.5349625", "0.5331486", "0.53150827", "0.5314873", "0.5311023", "0.5301655", "0.5300186", "0.5298813", "0.5296832", "0.5284103", "0.5279344", "0.5278256", "0.5277336", "0.5276993", "0.52738744", "0.52735376", "0.527052", "0.52595806", "0.52570474", "0.525235", "0.5249509", "0.524856", "0.52460426", "0.5244137", "0.5240519", "0.52314836", "0.52308303", "0.52269363", "0.52256465", "0.5223959", "0.5218564", "0.52173245", "0.521496", "0.5214065", "0.5202877", "0.52000624", "0.51990765", "0.51980615", "0.51943845", "0.51897705", "0.518825", "0.5188158", "0.51829606", "0.5182618", "0.51784456", "0.51776636", "0.51763153", "0.5174029", "0.51736844", "0.5166731", "0.51656693", "0.51642805", "0.5163971", "0.5162755", "0.51610994", "0.51600343", "0.51560056", "0.51543015", "0.5152344", "0.51486117", "0.5144337", "0.51433325", "0.51410913", "0.51378435", "0.51367307" ]
0.0
-1
SetNameIndex sets index of slice element on Name.
func (v *StringIsPath) SetNameIndex(i int) { v.Name = fmt.Sprintf("%s[%d]", RxSetNameIndex.ReplaceAllString(v.Name, ""), i) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *StringHasSuffixAny) SetNameIndex(i int) {\n\tv.Name = fmt.Sprintf(\"%s[%d]\", RxSetNameIndex.ReplaceAllString(v.Name, \"\"), i)\n}", "func (v *StringIsUserGroupOrWhitelisted) SetNameIndex(i int) {\n\tv.Name = fmt.Sprintf(\"%s[%d]\", RxSetNameIndex.ReplaceAllString(v.Name, \"\"), i)\n}", "func (v *StringsArePathsNotInTheSameDir) SetNameIndex(i int) {\n\tv.Name = fmt.Sprintf(\"%s[%d]\", RxSetNameIndex.ReplaceAllString(v.Name, \"\"), i)\n}", "func (e *Element) SetIndex(value int) {\n\tif e.Scene != nil {\n\t\te.Scene.Resize.Notify()\n\t}\n\n\tif e.Parent != nil {\n\t\te.Parent.projectIndex(&value)\n\t\te.Parent.children.ReIndex(e.index, value)\n\t\te.Parent.updateIndexes(e.index, value) // this will set the index\n\t}\n}", "func (e *Engine) setIndex(index int64) {\n\te.Index = index\n\te.Name = naming.Name(index)\n}", "func (n Nodes) SetIndex(i int, node *Node)", "func (o *FakeObject) SetIndex(i int, value interface{}) {\n\treflect.ValueOf(o.Value).Index(i).Set(reflect.ValueOf(value))\n}", "func (v Value) SetIndex(i int, x interface{}) {\n\tpanic(message)\n}", "func (g *gnmiPath) SetIndex(i int, v any) error {\n\tif i > g.Len() {\n\t\treturn fmt.Errorf(\"invalid index, out of range, got: %d, length: %d\", i, g.Len())\n\t}\n\n\tswitch v := v.(type) {\n\tcase string:\n\t\tif !g.isStringSlicePath() {\n\t\t\treturn fmt.Errorf(\"cannot set index %d of %v to %v, wrong type %T, expected string\", i, v, g, v)\n\t\t}\n\t\tg.stringSlicePath[i] = v\n\t\treturn nil\n\tcase *gnmipb.PathElem:\n\t\tif !g.isPathElemPath() {\n\t\t\treturn fmt.Errorf(\"cannot set index %d of %v to %v, wrong type %T, expected gnmipb.PathElem\", i, v, g, v)\n\t\t}\n\t\tg.pathElemPath[i] = v\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"cannot set index %d of %v to %v, wrong type %T\", i, v, g, v)\n}", "func (duo *DatumUpdateOne) SetIndex(i int) *DatumUpdateOne {\n\tduo.mutation.ResetIndex()\n\tduo.mutation.SetIndex(i)\n\treturn duo\n}", "func (o *Object) SetIdx(idx uint32, val interface{}) error {\n\treturn set(o, \"\", idx, val)\n}", "func (du *DatumUpdate) SetIndex(i int) *DatumUpdate {\n\tdu.mutation.ResetIndex()\n\tdu.mutation.SetIndex(i)\n\treturn du\n}", "func (gen *AddressGenerator) SetIndex(i uint) *AddressGenerator {\n\tgen.state = addressState(i)\n\treturn gen\n}", "func (c *Chip8) SetIndex() {\n\tc.index = c.inst & 0x0FFF\n}", "func (this *Value) SetIndex(index int, val interface{}) {\n\tif this.parsedType == ARRAY && index >= 0 {\n\t\tswitch parsedValue := this.parsedValue.(type) {\n\t\tcase []*Value:\n\t\t\tif index < len(parsedValue) {\n\t\t\t\t// if we've already parsed the object, store it there\n\t\t\t\tswitch val := val.(type) {\n\t\t\t\tcase *Value:\n\t\t\t\t\tparsedValue[index] = val\n\t\t\t\tdefault:\n\t\t\t\t\tparsedValue[index] = NewValue(val)\n\t\t\t\t}\n\t\t\t}\n\t\tcase nil:\n\t\t\t// if not store it in alias\n\t\t\tif this.alias == nil {\n\t\t\t\tthis.alias = make(map[string]*Value)\n\t\t\t}\n\t\t\tswitch val := val.(type) {\n\t\t\tcase *Value:\n\t\t\t\tthis.alias[strconv.Itoa(index)] = val\n\t\t\tdefault:\n\t\t\t\tthis.alias[strconv.Itoa(index)] = NewValue(val)\n\t\t\t}\n\n\t\t}\n\t}\n}", "func (cli *SetWrapper) SetName(name string) error {\n\treturn cli.set.SetValue(fieldSetName, name)\n}", "func (e *Engine) setName(name string) error {\n\tindex, err := naming.ExtractIndex(name, \"-\", 1)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"couldn't get index from device name: %v\", err)\n\t\treturn err\n\t}\n\te.Name = name\n\te.Index = index\n\treturn nil\n}", "func (t *Table) Index(idxName string) *Table {\n\tt.columns[len(t.columns)-1].IdxName = idxName\n\tt.columns[len(t.columns)-1].IsIndex = true\n\treturn t\n}", "func (c *Collection) SetBleveIndex(name string, documentMapping *mapping.DocumentMapping) (err error) {\n\t// Use only the tow first bytes as index prefix.\n\t// The prefix is used to confine indexes with a prefixes.\n\tprefix := c.buildIndexPrefix()\n\tindexHash := blake2b.Sum256([]byte(name))\n\tprefix = append(prefix, indexHash[:2]...)\n\n\t// ok, start building a new index\n\tindex := newIndex(name)\n\tindex.name = name\n\tindex.collection = c\n\tindex.prefix = prefix\n\terr = index.buildSignature(documentMapping)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Check there is no conflict name or hash\n\tfor _, i := range c.bleveIndexes {\n\t\tif i.name == name {\n\t\t\tif !bytes.Equal(i.signature[:], index.signature[:]) {\n\t\t\t\treturn ErrIndexAllreadyExistsWithDifferentMapping\n\t\t\t}\n\t\t\treturn ErrNameAllreadyExists\n\t\t}\n\t\tif reflect.DeepEqual(i.prefix, prefix) {\n\t\t\treturn ErrHashCollision\n\t\t}\n\t}\n\n\t// Bleve needs to save some parts on the drive.\n\t// The path is based on a part of the collection hash and the index prefix.\n\tcolHash := blake2b.Sum256([]byte(c.name))\n\tindex.path = fmt.Sprintf(\"%x%s%x\", colHash[:2], string(os.PathSeparator), indexHash[:2])\n\n\t// Build the index and set the given document index as default\n\tbleveMapping := bleve.NewIndexMapping()\n\tbleveMapping.StoreDynamic = false\n\tbleveMapping.IndexDynamic = true\n\tbleveMapping.DocValuesDynamic = false\n\n\tfor _, fieldMapping := range documentMapping.Fields {\n\t\tfieldMapping.Store = false\n\t\tfieldMapping.Index = true\n\t}\n\tbleveMapping.DefaultMapping = documentMapping\n\n\t// Build the configuration to use the local bleve storage and initialize the index\n\tconfig := blevestore.NewConfigMap(c.db.ctx, index.path, c.db.privateKey, prefix, c.db.badger, c.db.writeChan)\n\tindex.bleveIndex, err = bleve.NewUsing(c.db.path+string(os.PathSeparator)+index.path, bleveMapping, upsidedown.Name, blevestore.Name, config)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// Save the on drive bleve element into the index struct itself\n\tindex.bleveIndexAsBytes, err = index.indexZipper()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Add the new index to the list of index of this collection\n\tc.bleveIndexes = append(c.bleveIndexes, index)\n\n\t// Index all existing values\n\terr = c.db.badger.View(func(txn *badger.Txn) error {\n\t\titer := txn.NewIterator(badger.DefaultIteratorOptions)\n\t\tdefer iter.Close()\n\n\t\tcolPrefix := c.buildDBKey(\"\")\n\t\tfor iter.Seek(colPrefix); iter.ValidForPrefix(colPrefix); iter.Next() {\n\t\t\titem := iter.Item()\n\n\t\t\tvar err error\n\t\t\tvar itemAsEncryptedBytes []byte\n\t\t\titemAsEncryptedBytes, err = item.ValueCopy(itemAsEncryptedBytes)\n\t\t\tif err != nil {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tvar clearBytes []byte\n\t\t\tclearBytes, err = cipher.Decrypt(c.db.privateKey, item.Key(), itemAsEncryptedBytes)\n\n\t\t\tid := string(item.Key()[len(colPrefix):])\n\n\t\t\tcontent := c.fromValueBytesGetContentToIndex(clearBytes)\n\t\t\terr = index.bleveIndex.Index(id, content)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Save the new settup\n\treturn c.db.saveConfig()\n}", "func (self *SinglePad) SetIndexA(member int) {\n self.Object.Set(\"index\", member)\n}", "func (bA *CompactBitArray) SetIndex(i int, v bool) bool {\n\tif bA == nil {\n\t\treturn false\n\t}\n\n\tif i < 0 || i >= bA.Count() {\n\t\treturn false\n\t}\n\n\tif v {\n\t\tbA.Elems[i>>3] |= (1 << uint8(7-(i%8)))\n\t} else {\n\t\tbA.Elems[i>>3] &= ^(1 << uint8(7-(i%8)))\n\t}\n\n\treturn true\n}", "func (i *Index) IndexWithName(name string, opt ...Option) *Index {\n\to := &options{parent: i, name: name}\n\to.fill(opt)\n\treturn i.subIndexForKey(o)\n}", "func (self *FileBaseDataStore) SetIndex(\n\tconfig_obj *api_proto.Config,\n\tindex_urn string,\n\tentity string,\n\tkeywords []string) error {\n\n\tfor _, keyword := range keywords {\n\t\tsubject := path.Join(index_urn, strings.ToLower(keyword), entity)\n\t\terr := writeContentToFile(config_obj, subject, []byte{})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (self *Graphics) SetChildIndex(child *DisplayObject, index int) {\n self.Object.Call(\"setChildIndex\", child, index)\n}", "func (m *RecurrencePattern) SetIndex(value *WeekIndex)() {\n m.index = value\n}", "func (r *Resultset) NameIndex(name string) (int, error) {\n\tcolumn, ok := r.FieldNames[name]\n\tif ok {\n\t\treturn column, nil\n\t}\n\treturn 0, fmt.Errorf(\"invalid field name %s\", name)\n}", "func (s UserSet) SetName(value string) {\n\ts.RecordCollection.Set(models.NewFieldName(\"Name\", \"name\"), value)\n}", "func (a *App) SetIndex(controllerName string) *route {\n\troute := a.newRoute(controllerName, nil)\n\troute.segment = \"\"\n\troute.buildPatterns(\"\")\n\treturn route\n}", "func (m *metricEventDimensions) SetIndex(val *int32) {\n\tm.indexField = val\n}", "func UseIndex(designDocument, name string) Parameter {\n\treturn func(pa Parameterizable) {\n\t\tif name == \"\" {\n\t\t\tpa.SetParameter(\"use_index\", designDocument)\n\t\t} else {\n\t\t\tpa.SetParameter(\"use_index\", []string{designDocument, name})\n\t\t}\n\t}\n}", "func (pw *PixelWand) SetIndex(index *IndexPacket) {\n\tC.PixelSetIndex(pw.pw, C.IndexPacket(*index))\n\truntime.KeepAlive(pw)\n}", "func (t *Dense) SetMaskAtIndex(v bool, i int) error {\n\tif !t.IsMasked() {\n\t\treturn nil\n\t}\n\tt.mask[i] = v\n\treturn nil\n}", "func (m *CalendarGroup) SetName(value *string)() {\n err := m.GetBackingStore().Set(\"name\", value)\n if err != nil {\n panic(err)\n }\n}", "func (cc *CrontabConfig) SetGroupName(state State, i, fieldi int, a *CrontabConstraint, s string) error {\n\tk := cc.NameToNumber(fieldi, s) + cc.Fields[fieldi].min\n\tif k < cc.Fields[fieldi].min || k > cc.Fields[fieldi].max {\n\t\treturn &ErrorBadIndex{FieldName: cc.Fields[fieldi].name, Value: k}\n\t}\n\tif state == StateInName {\n\t\t*a = [3]int{k, k, 1}\n\t} else if state == StateInEndRangeName {\n\t\t(*a)[1] = k\n\t} else {\n\t\treturn &ErrorParse{Index: i, State: state}\n\t}\n\treturn nil\n}", "func (z *Zzz) IdxName() int { //nolint:dupl false positive\n\treturn 3\n}", "func (m *WorkbookRangeBorder) SetSideIndex(value *string)() {\n err := m.GetBackingStore().Set(\"sideIndex\", value)\n if err != nil {\n panic(err)\n }\n}", "func SliceIndexByName(sl *[]Ki, name string, startIdx int) (int, bool) {\n\treturn SliceIndexByFunc(sl, startIdx, func(ch Ki) bool { return ch.Name() == name })\n}", "func (o *IssueRemoveLabelParams) SetIndex(index int64) {\n\to.Index = index\n}", "func (m *LabelActionBase) SetName(value *string)() {\n err := m.GetBackingStore().Set(\"name\", value)\n if err != nil {\n panic(err)\n }\n}", "func (sl *Slice) IndexByName(name string, startIdx int) (int, bool) {\n\treturn sl.IndexByFunc(startIdx, func(ch Ki) bool { return ch.Name() == name })\n}", "func (b CreateIndexBuilder) Name(name string) CreateIndexBuilder {\n\treturn builder.Set(b, \"Name\", name).(CreateIndexBuilder)\n}", "func (v *Vec3i) SetByName(name string, value int32) {\n\tswitch name {\n\tcase \"x\", \"X\":\n\t\tv.X = value\n\tcase \"y\", \"Y\":\n\t\tv.Y = value\n\tcase \"z\", \"Z\":\n\t\tv.Z = value\n\tdefault:\n\t\tpanic(\"Invalid Vec3i component name: \" + name)\n\t}\n}", "func (ms Float64Slice) SetAt(i int, val float64) {\n\t(*ms.getOrig())[i] = val\n}", "func (r *PopRow) SetName(name string) { r.Data.Name = name }", "func (idx *IndexMap) Rename(indname string) *IndexMap {\n\tidx.IndexName = indname\n\treturn idx\n}", "func (s *MyTestStruct) SetName(n string) *MyTestStruct {\n\tif s.mutable {\n\t\ts.field_Name = n\n\t\treturn s\n\t}\n\n\tres := *s\n\tres.field_Name = n\n\treturn &res\n}", "func (q *Queue) SetIndexed(repoName string, opts IndexOptions, state indexState) {\n\tq.mu.Lock()\n\titem := q.get(repoName)\n\titem.setIndexState(state)\n\tif state != indexStateFail {\n\t\titem.indexed = reflect.DeepEqual(opts, item.opts)\n\t}\n\tif item.heapIdx >= 0 {\n\t\t// We only update the position in the queue, never add it.\n\t\theap.Fix(&q.pq, item.heapIdx)\n\t}\n\tq.mu.Unlock()\n}", "func (m Mapping) IndexName() string {\n\treturn fmt.Sprintf(\"idx_%s\", m.Alias)\n}", "func (m *etcdMinion) SetName(name string) error {\n\tnameKey := filepath.Join(m.rootDir, \"name\")\n\topts := &etcdclient.SetOptions{\n\t\tPrevExist: etcdclient.PrevIgnore,\n\t}\n\n\t_, err := m.kapi.Set(context.Background(), nameKey, name, opts)\n\tif err != nil {\n\t\tlog.Printf(\"Failed to set name of minion: %s\\n\", err)\n\t}\n\n\treturn err\n}", "func (m *WorkbookNamedItem) SetName(value *string)() {\n err := m.GetBackingStore().Set(\"name\", value)\n if err != nil {\n panic(err)\n }\n}", "func (self *TileSprite) SetChildIndex(child *DisplayObject, index int) {\n self.Object.Call(\"setChildIndex\", child, index)\n}", "func (iob *IndexOptionsBuilder) Name(name string) *IndexOptionsBuilder {\n\tiob.document = append(iob.document, bson.E{\"name\", name})\n\treturn iob\n}", "func (ll *LevelLedger) SetClassIndex(ref *record.Reference, idx *index.ClassLifeline) error {\n\tk := prefixkey(scopeIDLifeline, ref.Key())\n\tencoded, err := index.EncodeClassLifeline(idx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ll.ldb.Put(k, encoded, nil)\n}", "func (nc *NodeCreate) SetName(s string) *NodeCreate {\n\tnc.mutation.SetName(s)\n\treturn nc\n}", "func (_Contract *ContractTransactor) SetName(opts *bind.TransactOpts, node [32]byte, name string) (*types.Transaction, error) {\n\treturn _Contract.contract.Transact(opts, \"setName\", node, name)\n}", "func (m *WorkbookPivotTable) SetName(value *string)() {\n m.name = value\n}", "func (c *Mock) SetName(v string) interfaces.Client {\n\treturn c.FakeSetName(v)\n}", "func (blood *bloodGeneral) SetByIndex(index int, value float64) {\n\te := reflect.ValueOf(blood).Elem()\n\tfield := e.Field(index)\n\tif field.IsValid() && field.CanSet() && field.Kind() == reflect.Float64 {\n\t\tfield.SetFloat(value)\n\t} else {\n\t\tlog.Panicf(\"Cannot find element with index %d in BloodGeneral struct\", index)\n\t}\n\n\treturn\n}", "func (rc *Cache) PutIndex(key, name string) error {\n\tvar err error\n\tif _, err = rc.do(\"HSET\", key, name, \"1\"); err != nil {\n\t\treturn err\n\t}\n\treturn err\n}", "func (e *ObservableEditableBuffer) SetName(name string) {\n\tif e.Name() == name {\n\t\treturn\n\t}\n\n\t// SetName always forces an update of the tag.\n\t// TODO(rjk): This reset of filtertagobservers might now be unnecessary.\n\te.filtertagobservers = false\n\tbefore := e.getTagStatus()\n\tdefer e.notifyTagObservers(before)\n\n\tif e.seq > 0 {\n\t\t// TODO(rjk): Pass in the name, make the function name better reflect its purpose.\n\t\te.f.UnsetName(e.Name(), e.seq)\n\t}\n\te.setfilename(name)\n}", "func (v *V) SetAt(i int, f float64) Vector {\n\tif i < 0 || i >= v.Dim() {\n\t\tpanic(ErrIndex)\n\t}\n\tv.Data[i] = f\n\treturn v\n}", "func (i *Index) Name() string { return i.name }", "func (stquo *SurveyTemplateQuestionUpdateOne) SetIndex(i int) *SurveyTemplateQuestionUpdateOne {\n\tstquo.index = &i\n\tstquo.addindex = nil\n\treturn stquo\n}", "func (kcuo *K8sContainerUpdateOne) SetName(s string) *K8sContainerUpdateOne {\n\tkcuo.mutation.SetName(s)\n\treturn kcuo\n}", "func (entry *Entry) SetName(name ndn.Name) error {\n\tnameV, _ := name.MarshalBinary()\n\tnameL := len(nameV)\n\tif nameL > MaxNameLength {\n\t\treturn fmt.Errorf(\"FIB entry name cannot exceed %d octets\", MaxNameLength)\n\t}\n\n\tc := (*CEntry)(entry)\n\tc.NameL = uint16(copy(c.NameV[:], nameV))\n\tc.NComps = uint8(len(name))\n\treturn nil\n}", "func (suo *SettingUpdateOne) SetName(s string) *SettingUpdateOne {\n\tsuo.mutation.SetName(s)\n\treturn suo\n}", "func (e *Element) ReIndex(old, new int) {\n\tdiv := e.children.Slice()[old]\n\tdiv.Value.SetIndex(new)\n}", "func (d *V8interceptor) SetByindex(index int32, object, value *V8value, exception *string) int32 {\n\texception_ := C.cef_string_userfree_alloc()\n\tsetCEFStr(*exception, exception_)\n\tdefer func() {\n\t\t*exception = cefstrToString(exception_)\n\t\tC.cef_string_userfree_free(exception_)\n\t}()\n\treturn int32(C.gocef_v8interceptor_set_byindex(d.toNative(), C.int(index), object.toNative(), value.toNative(), (*C.cef_string_t)(exception_), d.set_byindex))\n}", "func (t *Type) SetNname(n *Node)", "func newIndex(name string) (index *ind) {\n\tindex = new(ind)\n\tindex.name = name\n\tindex.Storage = map[string][]string{}\n\tindex.Domains = map[string]bool{}\n\treturn\n}", "func (m *DeviceManagementApplicabilityRuleOsEdition) SetName(value *string)() {\n err := m.GetBackingStore().Set(\"name\", value)\n if err != nil {\n panic(err)\n }\n}", "func (_m *MockMutableSeriesIterators) SetAt(idx int, iter SeriesIterator) {\n\t_m.ctrl.Call(_m, \"SetAt\", idx, iter)\n}", "func (i *IndexDB) SetIndex(ctx context.Context, pn insolar.PulseNumber, bucket record.Index) error {\n\ti.lock.Lock()\n\tdefer i.lock.Unlock()\n\n\terr := i.setBucket(pn, bucket.ObjID, &bucket)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tstats.Record(ctx, statIndexesAddedCount.M(1))\n\n\tinslogger.FromContext(ctx).Debugf(\"[SetIndex] bucket for obj - %v was set successfully. Pulse: %d\", bucket.ObjID.DebugString(), pn)\n\n\treturn nil\n}", "func (db *DB) SetClassIndex(id *record.ID, idx *index.ClassLifeline) error {\n\treturn db.Update(func(tx *TransactionManager) error {\n\t\treturn tx.SetClassIndex(id, idx)\n\t})\n}", "func SetIterationNames(names []string) CustomizeIterationFunc {\n\treturn func(fxt *TestFixture, idx int) error {\n\t\tif len(fxt.Iterations) != len(names) {\n\t\t\treturn errs.Errorf(\"number of names (%d) must match number of iterations to create (%d)\", len(names), len(fxt.Iterations))\n\t\t}\n\t\tfxt.Iterations[idx].Name = names[idx]\n\t\treturn nil\n\t}\n}", "func poolSetIndex(a interface{}, i int) {\n\ta.(*freeClientPoolEntry).index = i\n}", "func (kcu *K8sContainerUpdate) SetName(s string) *K8sContainerUpdate {\n\tkcu.mutation.SetName(s)\n\treturn kcu\n}", "func (m *SDKScriptCollectorAttribute) SetName(val string) {\n\n}", "func (r *Search) Index(index string) *Search {\n\tr.paramSet |= indexMask\n\tr.index = index\n\n\treturn r\n}", "func (t *SignerHistory) IndexName() IndexName {\n\treturn signerHistoryIndexName\n}", "func (nu *NodeUpdate) SetName(s string) *NodeUpdate {\n\tnu.mutation.SetName(s)\n\treturn nu\n}", "func (mc *MockContiv) SetPodAppNsIndex(pod podmodel.ID, nsIndex uint32) {\n\tmc.podAppNs[pod] = nsIndex\n}", "func (nuo *NodeUpdateOne) SetName(s string) *NodeUpdateOne {\n\tnuo.mutation.SetName(s)\n\treturn nuo\n}", "func (ll *LevelLedger) SetObjectIndex(ref *record.Reference, idx *index.ObjectLifeline) error {\n\tk := prefixkey(scopeIDLifeline, ref.Key())\n\tencoded, err := index.EncodeObjectLifeline(idx)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn ll.ldb.Put(k, encoded, nil)\n}", "func (r *ProductRow) SetName(name string) { r.Data.Name = name }", "func (xdc *XxxDemoCreate) SetName(s string) *XxxDemoCreate {\n\txdc.mutation.SetName(s)\n\treturn xdc\n}", "func (wouo *WorkOrderUpdateOne) SetIndex(i int) *WorkOrderUpdateOne {\n\twouo.index = &i\n\twouo.addindex = nil\n\treturn wouo\n}", "func (xs *Sheet) SetName(name string) {\n\txs.xb.lib.NewProc(\"xlSheetSetNameW\").\n\t\tCall(xs.self, S(name))\n}", "func (k *Kitten) SetName(name string) {\n k.Name = name\n}", "func (_ResolverContract *ResolverContractTransactor) SetName(opts *bind.TransactOpts, node [32]byte, name string) (*types.Transaction, error) {\n\treturn _ResolverContract.contract.Transact(opts, \"setName\", node, name)\n}", "func NameToIndex(name string, names []string) int {\n\tvar index = -1\n\tfor i := 0; i < len(names); i++ {\n\t\tif name == names[i] {\n\t\t\tindex = i\n\t\t}\n\t}\n\treturn index\n}", "func (stqu *SurveyTemplateQuestionUpdate) SetIndex(i int) *SurveyTemplateQuestionUpdate {\n\tstqu.index = &i\n\tstqu.addindex = nil\n\treturn stqu\n}", "func (ms Span) SetName(v string) {\n\tms.orig.Name = v\n}", "func (muo *ModelUpdateOne) SetName(s string) *ModelUpdateOne {\n\tmuo.mutation.SetName(s)\n\treturn muo\n}", "func (db *DB) SetObjectIndex(\n\tctx context.Context,\n\tid *core.RecordID,\n\tidx *index.ObjectLifeline,\n) error {\n\treturn db.Update(ctx, func(tx *TransactionManager) error {\n\t\treturn tx.SetObjectIndex(ctx, id, idx)\n\t})\n}", "func (ig *InstanceGroup) IndexedServiceName(index int, azIndex int, azName string) string {\n\tsn := boshnames.TruncatedServiceName(ig.Name, 53)\n\tif azIndex > -1 {\n\t\treturn fmt.Sprintf(\"%s-%s-%d-%d\", sn, azName, azIndex, index)\n\t}\n\treturn fmt.Sprintf(\"%s-%d\", sn, index)\n}", "func (s *ReadOnlyStorer) SetIndex(*index.Index) error {\n\treturn ErrReadOnlyStorer.New()\n\n}", "func (obj *Device) SetIndices(indexData *IndexBuffer) Error {\n\tret, _, _ := syscall.Syscall(\n\t\tobj.vtbl.SetIndices,\n\t\t2,\n\t\tuintptr(unsafe.Pointer(obj)),\n\t\tuintptr(unsafe.Pointer(indexData)),\n\t\t0,\n\t)\n\treturn toErr(ret)\n}", "func (o SecondaryIndexOutput) IndexName() pulumi.StringOutput {\n\treturn o.ApplyT(func(v *SecondaryIndex) pulumi.StringOutput { return v.IndexName }).(pulumi.StringOutput)\n}", "func (m *ParentLabelDetails) SetName(value *string)() {\n err := m.GetBackingStore().Set(\"name\", value)\n if err != nil {\n panic(err)\n }\n}" ]
[ "0.748726", "0.7431408", "0.6964414", "0.6346891", "0.6253622", "0.6180723", "0.6141942", "0.60409635", "0.59939164", "0.5878266", "0.5856989", "0.5851746", "0.57178617", "0.5685566", "0.5639303", "0.56303644", "0.55680585", "0.5561141", "0.5557104", "0.5499101", "0.548195", "0.54818314", "0.54684585", "0.5453392", "0.54036677", "0.5371271", "0.53363836", "0.5287455", "0.528704", "0.5279632", "0.52241546", "0.5202348", "0.5188694", "0.51864153", "0.5186413", "0.5183055", "0.5150658", "0.5144818", "0.5126203", "0.5086723", "0.5066663", "0.5065852", "0.5047603", "0.50461113", "0.50301135", "0.5028728", "0.50225097", "0.5021532", "0.50200856", "0.50130963", "0.50078917", "0.50032824", "0.5000461", "0.49974406", "0.49920255", "0.49871707", "0.49830332", "0.49818647", "0.49763897", "0.49634835", "0.49619636", "0.4957827", "0.4951766", "0.49446127", "0.49444243", "0.4942674", "0.49399543", "0.49346548", "0.49300075", "0.49178302", "0.49081287", "0.49054363", "0.48957288", "0.489193", "0.48878166", "0.4878403", "0.48759207", "0.48694032", "0.48623422", "0.4861499", "0.4858354", "0.4825373", "0.48231307", "0.48217747", "0.48197708", "0.48173186", "0.47999308", "0.47986695", "0.4794664", "0.47946015", "0.47905636", "0.47803637", "0.4779535", "0.47767293", "0.4775903", "0.47687873", "0.47676122", "0.47615093", "0.4759826", "0.47563237" ]
0.77226394
0
Exists returns true if path exists
func Exists(path string) bool { if _, err := os.Stat(path); !os.IsNotExist(err) { return true } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func PathExists(path string) bool {\n _, err := os.Stat(path)\n if err == nil {\n return true\n }\n return false\n}", "func PathExists(p string) bool {\n\tif st, err := os.Stat(p); err == nil && st != nil {\n\t\treturn true\n\t}\n\treturn false\n}", "func pathExists(path string) (exists bool) {\n\texists = true\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\texists = false\n\t}\n\treturn\n}", "func PathExists(path string) bool {\n\tif path == \"\" {\n\t\treturn false\n\t}\n\n\tif _, err := os.Stat(path); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func pathExists(p string) bool {\n\tif _, err := os.Lstat(p); err != nil && os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err != nil {\n\t\tif os.IsExist(err) {\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\treturn true\n}", "func pathExists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn false\n}", "func pathExists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn false\n}", "func exists(path string) bool {\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func PathExists(path string) bool {\n\t// note: the err is either IsNotExist or something else\n\t// if it's something else, you have bigger issues...\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\treturn false\n}", "func PathExists(path string) bool {\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func PathExists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn err == nil\n}", "func Exists(path string) bool {\n _, err := os.Stat(path)\n if err == nil { return true }\n if os.IsNotExist(err) { return false }\n return false\n}", "func PathExists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn false\n}", "func PathExists(path string) bool {\n\t_, err := os.Lstat(path)\n\tif err != nil && os.IsNotExist(err) {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func PathExists(path string) (bool, error) {\r\n\tif _, err := os.Stat(path); err != nil {\r\n\t\tif os.IsNotExist(err) {\r\n\t\t\treturn false, nil\r\n\t\t}\r\n\t\treturn true, err\r\n\t}\r\n\treturn true, nil\r\n}", "func exists(path string) (bool, error) {\n\tif path == \"\" {\n\t\treturn false, nil\n\t}\n\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif !os.IsNotExist(err) {\n\t\treturn false, err\n\t}\n\n\treturn false, nil\n}", "func PathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, nil\n}", "func Exists(path string) bool {\n\tif _, err := os.Stat(path); err == nil {\n\t\treturn true\n\t}\n\treturn false\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func pathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func pathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn false\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn false\n}", "func pathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func pathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func pathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func (f FileManager) Exists(path string) bool {\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func Exists(path string) error {\n\t_, err := os.Stat(realPath(path))\n\n\tif err == nil {\n\t\treturn nil\n\t}\n\n\tif os.IsNotExist(err) {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func exists(path string) (bool) {\n\t_, err := os.Stat(path)\n\tif err == nil { return true }\n\tif os.IsNotExist(err) {return false}\n\treturn true\n}", "func exists(path string) (bool) {\n\t_, err := os.Stat(path)\n\tif err == nil { return true }\n\tif os.IsNotExist(err) {return false}\n\treturn true\n}", "func exists(path string) (bool) {\n\t_, err := os.Stat(path)\n\tif err == nil { return true }\n\tif os.IsNotExist(err) {return false}\n\treturn true\n}", "func exists(path string) bool {\n\tif _, err := os.Stat(path); err != nil {\n\t\treturn os.IsExist(err)\n\t}\n\treturn true\n}", "func (p *Path) Exists() bool {\n\t_, err := os.Stat(p.Path)\n\treturn err == nil || os.IsExist(err)\n}", "func PathExists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\tpanic(err)\n}", "func Exists(path string) bool {\n\tif _, err := os.Stat(path); err == nil {\n\t\treturn true\n\t}\n\t// else, doesn't exist\n\treturn false\n}", "func Exists(path string) bool {\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn !os.IsNotExist(err)\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn !os.IsNotExist(err)\n}", "func (fs *FileSystem) PathExists(path string) bool {\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func exists(filePath string) (exists bool) {\n _,err := os.Stat(filePath)\n if err != nil {\n exists = false\n } else {\n exists = true\n }\n return\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn err == nil || os.IsExist(err)\n}", "func Exists(path string) bool {\n\t_, err := os.Stat(path) //os.Stat获取文件信息\n\tif err != nil && os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\tpanic(err)\n}", "func PathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func pathExists(path string) bool {\n\t_, err := os.Stat(path)\n\n\tif err != nil {\n\t\treturn false\n\t}\n\n\treturn os.IsNotExist(err)\n}", "func exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil { return true, nil }\n\tif os.IsNotExist(err) { return false, nil }\n\treturn true, err\n}", "func Exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func exists(filePath string) bool {\n\t_, err := os.Stat(filePath)\n\treturn err == nil\n}", "func (helpers *Helpers) Exists(pathToCheck string) bool {\n\t_, err := os.Stat(pathToCheck)\n\tif err != nil && os.IsNotExist(err) {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (mzk *MockZK) Exists(path string) (bool, *zk.Stat, error) {\n\tmzk.Args = append(mzk.Args, []interface{}{\n\t\t\"exists\",\n\t\tpath,\n\t})\n\treturn mzk.ExistsFn(path)\n}", "func (f *fileSystem) Exists(prefix, path string) bool {\n\tpth := strings.TrimPrefix(path, prefix)\n\tif pth == \"/\" {\n\t\treturn false\n\t}\n\t_, ok := f.Files[pth]\n\treturn ok\n}", "func Exists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true // ignoring error\n}", "func isPathExists(path string) bool {\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func PathExist(path string) bool {\n\t_, err := os.Lstat(path)\n\treturn err == nil\n}", "func PathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil { return true, nil }\n\tif os.IsNotExist(err) { return false, nil }\n\treturn false, err\n}", "func Exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn err == nil\n}", "func (fs *FS) Exists(fpath string) bool {\n\t_, err := os.Stat(fpath)\n\tif err != nil {\n\t\treturn false\n\t}\n\treturn true\n}", "func Exists(fPath string) bool {\n\t_, err := os.Stat(fPath)\n\treturn !os.IsNotExist(err) // err would be not-exists\n}", "func (l *localFileSystem) Exists(prefix string, filepath string) bool {\n\tif p := strings.TrimPrefix(filepath, prefix); len(p) <= len(filepath) {\n\t\tp = path.Join(l.root, p)\n\t\t/*if !l.physfs {\n\t\t\treturn existsFile(l, p)\n\t\t} else {*/\n\t\tfmt.Println(\"Exists: \" + p)\n\t\treturn physfs.Exists(p)\n\t\t//}\n\t}\n\treturn false\n}", "func (f *file) pathIsExists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn false\n}", "func PathExists(path string) bool {\n\treturn fsutil.PathExists(path)\n}", "func PathExists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t} else if os.IsNotExist(err) {\n\t\treturn false, nil\n\t} else if IsCorruptedMnt(err) {\n\t\treturn true, err\n\t}\n\treturn false, err\n}", "func (mounter *csiProxyMounterV1Beta) ExistsPath(path string) (bool, error) {\n\tklog.V(4).Infof(\"Exists path: %s\", path)\n\tisExistsResponse, err := mounter.FsClient.PathExists(context.Background(),\n\t\t&fs.PathExistsRequest{\n\t\t\tPath: normalizeWindowsPath(path),\n\t\t})\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn isExistsResponse.Exists, err\n}", "func DoesExist(pth string) bool {\n\tif _, err := os.Stat(pth); os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func Exists(path string) (bool, error) {\n\tif _, err := os.Stat(path); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func Exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn !os.IsNotExist(err)\n}", "func Exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn !os.IsNotExist(err)\n}", "func Exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn !os.IsNotExist(err)\n}", "func Exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn !os.IsNotExist(err)\n}", "func Exists(path string) bool {\n\t_, err := os.Stat(path)\n\treturn !os.IsNotExist(err)\n}", "func PathExist(path string) bool {\n\t_, err := os.Stat(path)\n\treturn err == nil || os.IsExist(err)\n}", "func (z *ZkPlus) Exists(path string) (bool, *zk.Stat, error) {\n\tz.forPath(path).Log(logkey.ZkMethod, \"Exists\")\n\treturn z.blockOnConn().Exists(z.realPath(path))\n}", "func Exists(fname string) bool {\n if _, err := os.Stat(fname); os.IsNotExist(err) {\n return false\n }\n return true\n}", "func Exists(fs Fs, path string) (bool, error) {\n\t_, err := fs.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func IsPathExists(name string) bool {\n\tif _, err := os.Stat(name); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func exists(f string) (bool, error) {\n\t_, err := os.Stat(f)\n\tif err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn false, nil\n\t\t}\n\t\treturn false, fmt.Errorf(\"cannot get stats for path `%s`: %v\", f, err)\n\t}\n\treturn true, nil\n}", "func PathExist(path string) bool {\n\t_, err := os.Stat(path)\n\tif err != nil && os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn true\n}", "func Exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn false, err\n}", "func Exists(path string) (bool, error) {\n\tif path == \"\" {\n\t\treturn false, nil\n\t}\n\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\n\tif !os.IsNotExist(err) {\n\t\treturn false, errors.Wrap(err, \"cannot determine if path exists, error ambiguous\")\n\t}\n\n\treturn false, nil\n}", "func Exists(filePath string) (bool, error) {\n\tfilePath = strings.Replace(filePath, \"~\", HomeDir(), 1)\n\n\tif _, err := os.Stat(filePath); err == nil {\n\t\treturn true, nil\n\t} else if os.IsNotExist(err) {\n\t\treturn false, nil\n\t} else {\n\t\treturn false, err\n\t}\n}", "func PathExist(path string) bool {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false\n\t}\n\treturn false\n}", "func Exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\n\treturn false, err\n}", "func fileExists(path string) bool {\n _, err := os.Stat(path)\n return err == nil\n}", "func Exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func Exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func Exists(path string) (bool, error) {\n\t_, err := os.Stat(path)\n\tif err == nil {\n\t\treturn true, nil\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\treturn true, err\n}", "func IsExists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err != nil {\n\t\treturn os.IsExist(err)\n\t}\n\treturn true\n}", "func IsExists(path string) bool {\n\t_, err := os.Stat(path)\n\tif err != nil {\n\t\treturn os.IsExist(err)\n\t}\n\treturn true\n}", "func exists(path string) (bool, bool, error) {\n\tinfo, err := os.Stat(path)\n\tif err != nil {\n\t\treturn false, false, err\n\t}\n\tif os.IsNotExist(err) {\n\t\treturn false, false, nil\n\t}\n\tif info.IsDir() {\n\t\treturn true, true, nil\n\t}\n\treturn true, false, err\n}" ]
[ "0.82518166", "0.814709", "0.8141594", "0.807197", "0.80642235", "0.8063287", "0.8056969", "0.8056969", "0.8033987", "0.80294985", "0.8026755", "0.8016769", "0.8013383", "0.79878515", "0.7980666", "0.79802924", "0.7979126", "0.79775023", "0.7969888", "0.7967049", "0.7967049", "0.7962913", "0.7962913", "0.7961256", "0.7961256", "0.79597163", "0.79597163", "0.79597163", "0.7946349", "0.79314506", "0.7913833", "0.7913833", "0.7913833", "0.7910846", "0.79105574", "0.79057425", "0.79056", "0.7895476", "0.78941876", "0.78941876", "0.7890606", "0.7887511", "0.7887511", "0.7887511", "0.7887511", "0.7887511", "0.7882232", "0.7865037", "0.7865037", "0.7865037", "0.7865037", "0.7859953", "0.78486663", "0.78470415", "0.78466123", "0.7837986", "0.7837461", "0.782642", "0.7825124", "0.7819192", "0.7813398", "0.7801279", "0.7791042", "0.7784882", "0.7782831", "0.7781998", "0.7771827", "0.77657074", "0.7746101", "0.77405673", "0.77281487", "0.77228785", "0.77196264", "0.7696581", "0.7686393", "0.7662787", "0.7659267", "0.7659267", "0.7659267", "0.7659267", "0.7659267", "0.7648493", "0.7643461", "0.7641043", "0.7639791", "0.7623966", "0.76158446", "0.76079255", "0.7606732", "0.75992984", "0.7592666", "0.75905645", "0.7586324", "0.7584849", "0.75847673", "0.75847673", "0.75847673", "0.75752926", "0.75752926", "0.7550024" ]
0.7855411
52
a function to initialise the command line arguments
func init() { kmerSize = indexCmd.Flags().IntP("kmerSize", "k", 31, "size of k-mer") sketchSize = indexCmd.Flags().IntP("sketchSize", "s", 21, "size of MinHash sketch") windowSize = indexCmd.Flags().IntP("windowSize", "w", 100, "size of window to sketch graph traversals with") numPart = indexCmd.Flags().IntP("numPart", "x", 8, "number of partitions in the LSH Ensemble") maxK = indexCmd.Flags().IntP("maxK", "y", 4, "maxK in the LSH Ensemble") maxSketchSpan = indexCmd.Flags().Int("maxSketchSpan", 30, "max number of identical neighbouring sketches permitted in any graph traversal") msaDir = indexCmd.Flags().StringP("msaDir", "m", "", "directory containing the clustered references (MSA files) - required") indexCmd.MarkFlagRequired("msaDir") RootCmd.AddCommand(indexCmd) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func argsInit() {\n\tArgs = make([]string, 0, 0)\n\tArgs = append(Args, os.Args...)\n\tExecFile = options.GetExecFileByPid(os.Getpid())\n\t// default opt Parser\n\t// do not include ExecFile\n\topts = options.NewOptParser(Args[1:])\n\tArgLine = options.ArgsToSpLine(Args)\n\tArgFullLine = options.CleanArgLine(os.Args[0] + \" \" + opts.String())\n\t//\n}", "func initArgs(){\n\t//master -config ./master.json\n\tflag.StringVar(&confFile, \"config\", \"./master.json\", \"specify master.json as config file\")\n\tflag.Parse()\n}", "func argInit() args {\n\n\tvar a args\n\tflag.Float64Var(&a.x1, \"x1\", -2.0, \"left position of real axis\")\n\tflag.Float64Var(&a.x2, \"x2\", 1.0, \"right position of real axis\")\n\tflag.Float64Var(&a.y1, \"y1\", -1.5, \"down position of imaginary axis\")\n\tflag.Float64Var(&a.y2, \"y2\", 1.5, \"up position of imaginary axis\")\n\tflag.Float64Var(&a.threshold, \"th\", 4.0, \"squared threshold of the function\")\n\tflag.IntVar(&a.w, \"w\", 1000, \"width in pixels of the image\")\n\tflag.IntVar(&a.h, \"h\", 1000, \"height in pixels of the image\")\n\tflag.IntVar(&a.nIter, \"ni\", 100, \"maximum number of iterations for pixel\")\n\tflag.IntVar(&a.nRoutines, \"nr\", 4, \"number of go routines to be used\")\n\tflag.StringVar(&a.path, \"p\", \"./\", \"path to the generated png image\")\n\n\tflag.Parse()\n\treturn a\n}", "func getArguments() {\n\t// define pointers to the arguments which will be filled up when flag.Parse() is called\n\tlangFlag := flag.String(\"l\", string(auto), \"Which language to use. Args are: lua | wren | moon | auto\")\n\tdirFlag := flag.String(\"d\", \".\", \"The directory containing the main file and the subfiles\")\n\toutFlag := flag.String(\"o\", \"out\", \"The output file (sans extension)\")\n\twatchFlag := flag.Bool(\"w\", false, \"Whether to enable Watch mode, which automatically recompiles if a file has changed in the directory\")\n\tdefinesFlag := flag.String(\"D\", \"\", \"Used to pass in defines before compiling. Format is -D \\\"var1=value;var2=value;var3=value\\\"\")\n\n\t// begin parsing the flags\n\tflag.Parse()\n\n\t// these setup functions have to be performed in this particular order\n\t// because they depend on certain fields of Args to be set when they are called\n\t_setDir(*dirFlag)\n\t_setLanguage(*langFlag)\n\t_setOutputFile(*outFlag)\n\t_setDefines(*definesFlag)\n\n\tArgs.watchMode = *watchFlag\n\n\t// this gives all the non-flag command line args\n\tArgs.positional = flag.Args()\n}", "func parseArgs() {\n\tflag.StringVar(&cmdline.Config, \"config\", cmdline.Config, \"Path to configutation file\")\n\tflag.StringVar(&cmdline.Host, \"host\", cmdline.Host, \"Host IP or name to bind to\")\n\tflag.IntVar(&cmdline.Port, \"port\", cmdline.Port, \"Port to bind to\")\n\tflag.StringVar(&cmdline.Maildirs, \"maildirs\", cmdline.Maildirs, \"Path to the top level of the user Maildirs\")\n\tflag.StringVar(&cmdline.Logfile, \"log\", cmdline.Logfile, \"Path to logfile\")\n\tflag.BoolVar(&cmdline.Debug, \"debug\", cmdline.Debug, \"Log debugging information\")\n\n\tflag.Parse()\n}", "func init() {\n\tflag.StringVar(&KubectlPath, \"kubectl-path\", \"\", \"Path to the kubectl binary\")\n\tflag.StringVar(&ClusterctlPath, \"clusterctl-path\", \"\", \"Path to the clusterctl binary\")\n\tflag.StringVar(&DumpPath, \"dump-path\", \"\", \"Path to the kubevirt artifacts dump cmd binary\")\n\tflag.StringVar(&WorkingDir, \"working-dir\", \"\", \"Path used for e2e test files\")\n}", "func InitArgs(args ...string) func(*LinuxFactory) error {\n\treturn func(l *LinuxFactory) error {\n\t\tname := args[0]\n\t\tif filepath.Base(name) == name {\n\t\t\tif lp, err := exec.LookPath(name); err == nil {\n\t\t\t\tname = lp\n\t\t\t}\n\t\t} else {\n\t\t\tabs, err := filepath.Abs(name)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tname = abs\n\t\t}\n\t\tl.InitPath = \"/proc/self/exe\"\n\t\tl.InitArgs = append([]string{name}, args[1:]...)\n\t\treturn nil\n\t}\n}", "func InitArgs(cliArgs cli.Args) (*Args, error) {\n\targs := Args{Pattern: cliArgs.Get(0)}\n\tpath, err := filepath.Abs(cliArgs.Get(1))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, path)\n\t}\n\targs.Path = path\n\treturn &args, nil\n}", "func init() {\n\t// We pass the user variable we declared at the package level (above).\n\t// The \"&\" character means we are passing the variable \"by reference\" (as opposed to \"by value\"),\n\t// meaning: we don't want to pass a copy of the user variable. We want to pass the original variable.\n\tflag.StringVarP(&city, \"weather\", \"w\", \"\", \"get weather by [city,country code] (ex: paris,fr)\")\n\tflag.StringVarP(&user, \"user\", \"u\", \"\", \"Search Github Users\")\n\tflag.StringVarP(&repo, \"repo\", \"r\", \"\", \"Search Github repos by User\\n Usage: cli -u [user name] -r 'y'\\n\")\n\tflag.StringVarP(&movie, \"movie\", \"m\", \"\", \"Search Movies\")\n\t// flag.StringVarP(&genre, \"genre\", \"g\", \"\", \"Search Movie by genre\\n Usage: cli -g {not yet implemented}\\n\")\n\tflag.StringVarP(&news, \"news\", \"n\", \"\", \"Search News by country code (ex: fr, us)\")\n\tflag.StringVarP(&category, \"category\", \"c\", \"\", \"Search News by category\\n Usage: cli -n [ISO 3166-1 alpha-2 country code] -c {one of:}\\n [business entertainment general health science sports technology]\")\n\tflag.StringVarP(&reddit, \"reddit\", \"R\", \"\", \"Search Reddit posts by keyword\")\n\tflag.StringVarP(&com, \"com\", \"C\", \"\", \"Search Reddit comments by postId\\n Usage: cli -R [reddit keyword] -C [postId]\\n\")\n\tflag.StringVarP(&proj, \"project\", \"p\", \"\", \"Create a Node.js micro-service by a name\\n Usage: cli -p [project name]\\n to use in terminal emulator under win env\\n\")\n\tflag.StringVarP(&publi, \"publi\", \"P\", \"\", \"Find scientific publications by search-word\\n Usage: cli -P [search term]\\n\")\n\tflag.StringVarP(&osTool, \"env\", \"e\", \"\", \"Display the env as key/val\")\n\tflag.StringVarP(&docker, \"docker\", \"d\", \"\", \"Docker tool\\n Usage: cli -d [list/l]\\n\")\n\tflag.StringVarP(&x, \"x\", \"x\", \"\", \"Width in chars of displayed ascii images\")\n\tflag.StringVarP(&netw, \"net\", \"N\", \"\", \"List local Network available adresses\")\n\tflag.StringVarP(&ip, \"ip\", \"i\", \"\", \"Remote Network details\")\n\tflag.StringVarP(&img, \"ascii\", \"a\", \"\", \"Display ascii art from local images\")\n\n\tdir, _ := syscall.Getwd()\n\tfmt.Println(\"dossier courant:\", dir)\n\t// project()\n\t// fmt.Println(createProject(\"SANDBOX\"))\n}", "func parseProgramArgs() {\n\tLocalFolderPath = flag.String(\"l\", \".\", \"Path to local directory to open, default is '.'\")\n\tdpRestURL = flag.String(\"r\", \"\", \"DataPower REST URL\")\n\tdpSomaURL = flag.String(\"s\", \"\", \"DataPower SOMA URL\")\n\tdpUsername = flag.String(\"u\", \"\", \"DataPower user username\")\n\tpassword := flag.String(\"p\", \"\", \"DataPower user password\")\n\tdpDomain = flag.String(\"d\", \"\", \"DataPower domain name\")\n\tproxy = flag.String(\"x\", \"\", \"URL of proxy server for DataPower connection\")\n\tdpConfigName = flag.String(\"c\", \"\", \"Name of DataPower connection configuration to save with given configuration params\")\n\tDebugLogFile = flag.Bool(\"debug\", false, \"Write debug dpcmder.log file in current dir\")\n\tTraceLogFile = flag.Bool(\"trace\", false, \"Write trace dpcmder.log file in current dir\")\n\thelpUsage = flag.Bool(\"h\", false, \"Show dpcmder usage with examples\")\n\thelpFull = flag.Bool(\"help\", false, \"Show dpcmder in-program help on console\")\n\tversion = flag.Bool(\"v\", false, \"Show dpcmder version\")\n\n\tflag.Parse()\n\tsetDpPasswordPlain(*password)\n}", "func Args() []string { return CommandLine.args }", "func init() {\n\tconst (\n\t\tdefaultRsFilePath = \"./data/rslist1.txt\"\n\t\trsusage = \"File containing list of rsnumbers\"\n\t\tdefaultvcfPathPref = \"\"\n\t\tvusage = \"default path prefix for vcf files\"\n\t\tdefaultThreshold = 0.9\n\t\tthrusage = \"Prob threshold\"\n\t\tdefaultAssayTypes = \"affy,illumina,broad,metabo,exome\"\n\t\tatusage = \"Assay types\"\n\t)\n\tflag.StringVar(&rsFilePath, \"rsfile\", defaultRsFilePath, rsusage)\n\tflag.StringVar(&rsFilePath, \"r\", defaultRsFilePath, rsusage+\" (shorthand)\")\n\tflag.StringVar(&vcfPathPref, \"vcfprfx\", defaultvcfPathPref, vusage)\n\tflag.StringVar(&vcfPathPref, \"v\", defaultvcfPathPref, vusage+\" (shorthand)\")\n\tflag.Float64Var(&threshold, \"threshold\", defaultThreshold, thrusage)\n\tflag.Float64Var(&threshold, \"t\", defaultThreshold, thrusage+\" (shorthand)\")\n\tflag.StringVar(&assayTypes, \"assaytypes\", defaultAssayTypes, atusage)\n\tflag.StringVar(&assayTypes, \"a\", defaultAssayTypes, atusage+\" (shorthand)\")\n\tflag.Parse()\n}", "func init() {\n\tflag.StringVar(&port, \"port\", \"8080\", \"port to run the utility on\")\n\tflag.BoolVar(&https, \"https\", false, \"run a HTTPS server\")\n\tflag.StringVar(&cert, \"cert\", \"localhost.crt\", \"certificate file\")\n\tflag.StringVar(&key, \"key\", \"localhost.key\", \"private key file\")\n}", "func init() {\n\tenv = flag.String(\"env\", \"development\", \"current environment\")\n\tport = flag.Int(\"port\", 3000, \"port number\")\n}", "func init() {\n\tprepareOptionsFromCommandline(&configFromInit)\n\tparseConfigFromEnvironment(&configFromInit)\n}", "func init() {\n\n\tflag.StringVar(&host, \"h\", \"\", \"SQL Server hostname or IP\")\n\tflag.StringVar(&user, \"u\", \"\", \"User ID\")\n\tflag.StringVar(&pass, \"p\", \"\", \"Password\")\n\tflag.StringVar(&sqlf, \"s\", \"\", \"SQL Query filename\")\n\tflag.StringVar(&outf, \"o\", \"\", \"Output filename\")\n\n\tif len(os.Args) < 5 {\n\t\tflag.Usage()\n\t\tos.Exit(1)\n\t}\n\n\tflag.Parse()\n\n}", "func init() {\n\tflag.StringVar(&apikey, \"apikey\", os.Getenv(\"VT_API_KEY\"), \"Set environment variable VT_API_KEY to your VT API Key or specify on prompt\")\n\tflag.StringVar(&apiurl, \"apiurl\", \"https://www.virustotal.com/vtapi/v2/\", \"URL of the VirusTotal API to be used.\")\n\tflag.StringVar(&domain, \"domain\", \"\", \"a domain to ask information about from VT.\")\n}", "func readargs() config {\n\tvar db string\n\tvar verarg bool\n\tvar nw uint\n\tflag.StringVar(&db, \"database\", \"\", \"database to use for determining forks; if unspecified, no fork detection is performed\")\n\tflag.UintVar(&nw, \"nworkers\", 4, \"number of concurrent workers\")\n\tflag.BoolVar(&verarg, \"version\", false, \"show version information\")\n\tflag.Usage = printusage\n\n\tflag.Parse()\n\n\tif verarg {\n\t\tprintversion()\n\t}\n\n\tif flag.NArg() > 1 {\n\t\tflag.Usage()\n\t}\n\n\trepostore := flag.Arg(0)\n\treturn config{Repostore: repostore, Database: db, NWorkers: uint(nw)}\n}", "func parseArgs() {\n\tflag.StringVar(&masterPhrase, \"master\", \"\", \"The master phrase to use for password generation. Do NOT forget to escape any special characters contained in the master phrase (e.g. $, space etc).\")\n\tflag.StringVar(&masterPhraseFile, \"master-file\", \"\", \"The path to a file, containing the master phrase.\")\n\n\tflag.StringVar(&domain, \"domain\", \"\", \"The domain for which this password is intended\")\n\tflag.StringVar(&additionalInfo, \"additional-info\", \"\", \"Free text to add (e.g. index/timestamp/username if the previous password was compromized)\")\n\tflag.IntVar(&passLength, \"password-length\", 12, \"Define the length of the password.\")\n\tflag.BoolVar(&addSpecialChars, \"special-characters\", true, \"Whether to add a known set of special characters to the password\")\n\tflag.BoolVar(&addInfoToLog, \"log-info\", false, \"Whether to log the parameters that were used for generation to a file. Note that the password itself will NOT be stored!\")\n\n\tflag.Parse()\n}", "func init() {\n\tconst (\n\t\tmemMaxStr = \"--mem.max=\"\n\t\tmemMinStr = \"--mem.min=\"\n\t)\n\tfor _, item := range os.Args {\n\t\tif strings.HasPrefix(item, memMaxStr) {\n\t\t\tn := ParseByteNumber(item[len(memMaxStr):])\n\t\t\tif n <= 0 {\n\t\t\t\tpanic(\"cmd flags error:\" + item)\n\t\t\t}\n\t\t\tmaxMem = n\n\t\t} else if strings.HasPrefix(item, memMinStr) {\n\t\t\tn := ParseByteNumber(item[len(memMinStr):])\n\t\t\tif n <= 0 {\n\t\t\t\tpanic(\"cmd flags error:\" + item)\n\t\t\t}\n\t\t\tminMem = n\n\t\t}\n\t}\n\tif maxMem == 0 {\n\t\tmaxMem = 32 * 1024 * 1024 * 1024\n\t}\n\tif minMem == 0 {\n\t\tminMem = 512 * 1024 * 1024\n\t}\n\tgo checkMemory()\n}", "func init() {\n\tflag.StringVar(&cfg.tzlib, \"tzlib\", \"./tzlib.json\", \"Use database file <tzlib>\")\n\tflag.StringVar(&cfg.from, \"from\", \"\", \"Import HTML from <from> and write database to <zlib>\")\n\tflag.StringVar(&cfg.webroot, \"webroot\", \"\", \"Serve the <webroot> directory at '/'\")\n\tflag.StringVar(&cfg.endpoint, \"endpoint\", \"/dann\", \"Serve the API at <endpoint>\")\n\tflag.StringVar(&cfg.bind, \"bind\", \"localhost:1620\", \"Listen on <bind> for connections. \")\n\n\tflag.Parse()\n}", "func (t *Terraform) initArgs(p types.ProviderType, cfg map[string]interface{}, clusterDir string) []string {\n\targs := make([]string, 0)\n\n\tvarsFile := filepath.Join(clusterDir, tfVarsFile)\n\n\targs = append(args, fmt.Sprintf(\"-var-file=%s\", varsFile), clusterDir)\n\n\treturn args\n}", "func init() {\n\ttrimSwitch = alignCmd.Flags().Bool(\"trim\", false, \"enable quality based trimming of reads (post seeding)\")\n\tminQual = alignCmd.Flags().IntP(\"minQual\", \"q\", 20, \"minimum base quality (used in quality based trimming)\")\n\tminRL = alignCmd.Flags().IntP(\"minRL\", \"l\", 100, \"minimum read length (evaluated post trimming)\")\n\tclip = alignCmd.Flags().IntP(\"clip\", \"c\", 5, \"maximum number of clipped bases allowed during local alignment\")\n\tindexDir = alignCmd.Flags().StringP(\"indexDir\", \"i\", \"\", \"directory containing the index files - required\")\n\tfastq = alignCmd.Flags().StringSliceP(\"fastq\", \"f\", []string{}, \"FASTQ file(s) to align\")\n\tgraphDir = alignCmd.PersistentFlags().StringP(\"graphDir\", \"o\", defaultGraphDir, \"directory to save variation graphs to\")\n\talignCmd.MarkFlagRequired(\"indexDir\")\n\tRootCmd.AddCommand(alignCmd)\n}", "func init() {\n\tappCmd.AddCommand(appInstallCmd)\n\tappInstallCmd.Flags().StringVarP(&appInstallVersion, \"version\", \"v\", \"\", \"Specify the version of the contribution (optional)\")\n\tappInstallCmd.Flags().StringVarP(&appInstallName, \"name\", \"n\", \"\", \"The name of the contribution (required)\")\n\tappInstallCmd.Flags().BoolVarP(&appInstallPalette, \"palette\", \"p\", false, \"Install palette file\")\n\tappInstallCmd.MarkFlagRequired(\"name\")\n}", "func init() {\n\tusage = fmt.Sprintf(\"Usage: %s config.toml\", os.Args[0])\n}", "func setCommandLineAndArgs(process *specs.Process, createProcessParms *hcsshim.ProcessConfig) {\n\tif process.CommandLine != \"\" {\n\t\tcreateProcessParms.CommandLine = process.CommandLine\n\t} else {\n\t\tcreateProcessParms.CommandLine = system.EscapeArgs(process.Args)\n\t}\n}", "func init() {\n\thostPtr := flag.String(\"host\", \"localhost\", \"ip of host\")\n\tportPtr := flag.String(\"port\", \"12345\", \"port on which to run server\")\n\tflag.Parse()\n\thost = *hostPtr\n\tport = *portPtr\n}", "func init() {\n RootCmd.AddCommand(DeployCmd)\n DeployCmd.Flags().StringP(\"file\", \"f\", \"\", \"file used to specify the job to deploy (required)\")\n DeployCmd.Flags().StringP(\"port\", \"p\", \"\", \"connect to a specific port (default: 3939)\")\n DeployCmd.MarkFlagRequired(\"file\")\n}", "func (c *cli) parseArgs(args []string) (*cliArgs, error) {\n\tparsedArgs := &cliArgs{}\n\n\tapp := kingpin.New(appName, \"\")\n\n\t// Do not call os.Exit\n\tapp.Terminate(nil)\n\n\t// Write output to stderr\n\tapp.Writer(c.stderr)\n\n\t// Add --version flag with to display build info\n\tapp.Version(fmt.Sprintf(\"%s version %s (%s) built on %s\", appName, version, commitHash, buildDate))\n\n\t// Add --config flag to specify path to the config\n\tapp.Flag(\"config\", \"Set the configuration file path\").\n\t\tShort('c').\n\t\tPlaceHolder(\"PATH\").\n\t\tDefault(filepath.Join(filepath.Dir(os.Args[0]), \"gevulot.toml\")).\n\t\tStringVar(&parsedArgs.configPath)\n\n\t// Add --verbose flag to enable debug output\n\tapp.Flag(\"verbose\", \"Enable debug output\").\n\t\tShort('v').\n\t\tBoolVar(&parsedArgs.isVerbose)\n\n\t// Expose --help and --version flags to our struct\n\tapp.HelpFlag.BoolVar(&parsedArgs.isHelp)\n\tapp.VersionFlag.BoolVar(&parsedArgs.isHelp)\n\n\t_, err := app.Parse(args)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn parsedArgs, nil\n}", "func CommandArgs(allArgs map[string]reflect.Value) {\n\tallArgs[\"config\"] = reflect.ValueOf(&ConfigFile)\n\tallArgs[\"cfg\"] = reflect.ValueOf(&ConfigFile)\n\tallArgs[\"help\"] = reflect.ValueOf(&Help)\n\tallArgs[\"h\"] = reflect.ValueOf(&Help)\n}", "func init() {\n\trootCmd.AddCommand(renameCmd)\n\trenameCmd.Flags().StringVarP(&mapFile, \"map\", \"m\", \"\", \"Tab separated file mapping old names to new names. 1 operation per line\")\n\trenameCmd.Flags().StringVarP(&regexRenamer, \"regex\", \"r\", \"\", \"Regex to match part of the sequence name\")\n\trenameCmd.Flags().StringVarP(&replaceGroup, \"replace\", \"p\", \"\", \"Replace matched element with this\")\n}", "func init() {\n\thome, err := homedir.Dir() // Fetch the current user home dir.\n\tutils.PanicErr(err) // Panic in case user dir not available\n\tdefaultOutputDir := filepath.Join(home, utils.DEFAULT_OUTPUT_PATH)\n\tgenCmd.Flags().String(utils.FLAG_INPUT, utils.DEFAULT_PDF_PATH, utils.FLAG_INPUT_DESC)\n\tgenCmd.Flags().String(utils.FLAG_OUTPUT, defaultOutputDir, utils.FLAG_OUTPUT_DESC)\n\tgenCmd.Flags().String(utils.FLAG_VOICE, utils.FEMALE_VOICE, utils.FLAG_VOICE_DESC)\n\tRootCmd.AddCommand(genCmd)\n}", "func main() {\n\n\tvar argValues string //defining an argValues\n\tif len(os.Args) > 1 { //checking the argument values for ex: go run hello.go hello bhuppal kumar\n\t\targValues = strings.Join(os.Args[1:], \" \")\n\t}\n\tfmt.Println(argValues)\n}", "func process_arguments() {\n\tfmt.Println(\"Processing arguments\")\n\tflag.Parse()\n}", "func init() {\n\tflag.BoolVar(&opts.verbose, \"verbose\", false, \"provide verbose output\")\n\tflag.BoolVar(&opts.debug, \"debug\", false, \"provide internal debugging output\")\n\tflag.StringVar(&opts.url, \"url\", \"http://localhost\", \"server URL\")\n\tflag.IntVar(&opts.port, \"port\", 3000, \"server port\")\n}", "func parseArgs(args []string) (*arguments, error) {\n\tif len(args) == 0 {\n\t\treturn nil, errors.Errorf(\"required input \\\" --src <Src_File> \\\" not found !\")\n\t}\n\n\tapp := kingpin.New(\"mircat\", \"Utility for processing Mir state event logs.\")\n\tsrc := app.Flag(\"src\", \"The input file to read (defaults to stdin).\").Default(os.Stdin.Name()).File()\n\t_, err := app.Parse(args)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &arguments{\n\t\tsrcFile: *src,\n\t}, nil\n}", "func initConfig() {\n\toptions.db = *flag.String(\"db\", \"test/test.db\", \"SQLite database file\")\n\toptions.host = *flag.String(\"bind\", \"localhost\", \"HTTP server host\")\n\toptions.port = *flag.Uint(\"listen\", 8000, \"HTTP server listen port\")\n\tflag.Parse()\n}", "func init() {\r\n// get the arguments to run the server\r\n\tflag.StringVar(&Host,\"httpserver\",DEFAULT_HOST,\"name of HTTP server\")\r\n\tflag.IntVar(&Port,\"port\",DEFAULT_PORT,\"port number\")\r\n\tflag.StringVar(&UrlPath,\"urlpath\",DEFAULT_URLPATH,\"relative url path\")\r\n\tflag.StringVar(&SecretKey,\"key\",DEFAULT_KEY,\"secret key to terminate program via TCP/UDP port\")\r\n\tflag.BoolVar(&isVerbose,\"verbose\",false,\"enable verbose logging output\")\r\n\tflag.Parse()\r\n\tlogger.Print(\"Starting servers on Port:\"+strconv.Itoa(Port)+\" HTTP-server:\"+Host+\" urlpath:\"+UrlPath+\" Key:\"+SecretKey)\r\n\tinitConf()\r\n}", "func parseCmdLine() []string{\n\t// Anything that wasn't command, argument, or option will be returned\n\t// as a filename.\n\t// Upon return:\n\t// if a command like init was encountered,\n\tvar filenames []string\n\tvar parsingArgument bool\n\tfor pos, nextArg := range os.Args {\n\t\t//fmt.Printf(\"\\n\\nTop of loop. os.Args[%v]: %v. parsingArgument: %v\\n\", pos, nextArg,parsingArgument)\n\t\tswitch nextArg {\n\t\tcase \"init\":\n\t\t\t// initCmd.Parsed() is now true\n\t\t\tinitCmd.Parse(os.Args[pos+1:])\n\t\t\tif *initSiteName != \"\" {\n\t\t\t\t// *initSitename now points to the string value.\n\t\t\t\t// It's empty if -sitename wasn't -sitename specified\n\t\t\t\tparsingArgument = true\n\t\t\t}\n\t\tcase \"build\":\n\t\t\tbuildCmd.Parse(os.Args[pos+1:])\n\t\t\tif *buildOutputDir != \"\" {\n\t\t\t\tparsingArgument = true\n\t\t\t}\n\t\t\tif *buildBaseURL != \"\" {\n\t\t\t\tparsingArgument = true\n\t\t\t}\n\t\tdefault:\n\t\t\t// If not in the middle of parsing a command-like subargument,\n\t\t\t// like the -sitename=test in this command line:\n\t\t\t// foo init -sitename=test\n\t\t\t// Where foo is the name of the program, and -sitename is\n\t\t\t// an optional subcommand to init,\n\t\t\t//\n\t\t\t// os.Args[0] falls through so exclude it, since it's\n\t\t\t// the name of the invoking program.\n\t\t\tif !parsingArgument && pos > 0{\n\t\t\t\tfilenames = append(filenames, nextArg)\n\t\t\t} else {\n\t\t\t\tparsingArgument = false\n\t\t\t}\n\n\t\t}\n\t}\n\treturn filenames\n}", "func init() {\n\trootCmd.AddCommand(newAdrCmd)\n\tnewAdrCmd.Flags().StringVarP(&projectName, \"project-name\", \"n\", \"\", \"name of adr project\")\n\tnewAdrCmd.Flags().StringVarP(&title, \"adr-title\", \"t\", \"\", \"title of new adr\")\n\tnewAdrCmd.MarkFlagRequired(\"project-name\")\n\tnewAdrCmd.MarkFlagRequired(\"adr-title\")\n}", "func init() {\n\tflag.DurationVar(&config.fetchTimeout, \"timeout\", 2*time.Second, \"timeout between downloading papers\")\n\tflag.StringVar(&config.conferencesFile, \"config\", \"conferences.json\", \"JSON file listing conferences\")\n\tflag.StringVar(&config.outputDirectory, \"output-dir\", \"papers\", \"output directory for storing papers\")\n\tflag.Parse()\n\n\t// create output directory\n\tif _, err := os.Stat(config.outputDirectory); os.IsNotExist(err) {\n\t\tif err := os.MkdirAll(config.outputDirectory, os.ModePerm); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t}\n}", "func init() {\n\tconfigFile = flag.String(FILE, EMPTY_STRING, A_STRING)\n}", "func init() {\n\tflag.StringVar(&configfile, \"configfile\", \"/data/config/go/best-practices/config.yml\", \"config file full path\")\n\tflag.StringVar(&loggerfile, \"loggerfile\", \"\", \"seelog config file\")\n\tflag.BoolVar(&help, \"h\", false, \"show help\")\n\tflag.IntVar(&port, \"port\", 0, \"service port to listen\")\n\tflag.Parse()\n\n\tif help {\n\t\tflag.Usage()\n\t}\n\t// init logger firstly!!!\n\tmylogger.Init(loggerfile)\n\n\tappConfig.GetConfig(configfile)\n\n\tlogger.Infof(\"Init with config:%+v\", appConfig)\n}", "func ParseArgs() {\n\t// Set function to be called if parsing fails.\n\tflag.Usage = usage\n\n\t// Parse CLI arguments.\n\tflag.Parse()\n\n\t// Print usage text and exit if:\n\t// - browser is neither \"chrome\" or \"firefox\",\n\t// - env is neither \"dev\", \"uat\" or \"preprod\",\n\t// - headless is neither \"false\" or \"true\",\n\t// - displayAddress is not valid IP address,\n\t// - port is not a number between 1024-65535\n\tisHeadless, err := strconv.ParseBool(*headless)\n\tif !(validBrowserArg() && validEnvArg() && err == nil && validDisplayArg() && (*port >= 1024 && *port <= 65535)) {\n\t\tusage()\n\t\tos.Exit(2)\n\t}\n\n\t// Set conf global variable.\n\tconf = Conf{\n\t\tBrowser: Browser(*browser),\n\t\tEnv: Env(*env),\n\t\tHeadless: isHeadless,\n\t\tDisplayAddress: *displayAddress,\n\t\tPort: *port,\n\t\tWidth: *width,\n\t\tHeight: *height,\n\t}\n\n\t// Set caps global variable.\n\tSetCaps(conf)\n}", "func init() {\n\t// NOTE: this will utilize CONSUL_HTTP_ADDR if it is set.\n\tclient, err := consul.NewClient(consul.DefaultConfig())\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to connect to Consul => {%s}\", err)\n\t}\n\tkv = client.KV()\n\n\tflag.StringVar(&srcKey, \"srcKey\", \"\", \"key to move values from\")\n\tflag.StringVar(&destKey, \"destKey\", \"\", \"key to move values to\")\n\tflag.StringVar(&srcJSON, \"srcJSON\", \"\", \"file to import values from\")\n\tflag.StringVar(&destJSON, \"destJSON\", \"\", \"file to export values to\")\n\tflag.BoolVar(&rename, \"rename\", false, \"place as a rename instead of a insertion\")\n\tflag.Parse()\n}", "func parseArgs() {\n\tfirstArgWithDash := 1\n\tfor i := 1; i < len(os.Args); i++ {\n\t\tfirstArgWithDash = i\n\n\t\tif len(os.Args[i]) > 0 && os.Args[i][0] == '-' {\n\t\t\tbreak\n\t\t} else {\n\t\t\tfilePaths = append(filePaths, os.Args[i])\n\t\t}\n\t}\n\n\tflag.CommandLine.Parse(os.Args[firstArgWithDash:])\n}", "func (args *Arguments) define() {\n\n\tflag.BoolVar(\n\t\t&args.Version,\n\t\t\"Version\",\n\t\tfalse,\n\t\t\"Prints the version number of this utility and exits.\",\n\t)\n\n\tflag.BoolVar(\n\t\t&args.Licence,\n\t\t\"Licence\",\n\t\tfalse,\n\t\t\"Prints the copyright licence this software is released under.\",\n\t)\n\n\tflag.BoolVar(\n\t\t&args.AllProblems,\n\t\t\"AllProblems\",\n\t\tfalse,\n\t\t\"Answer all problems for which there is code.\",\n\t)\n\n\tflag.UintVar(\n\t\t&args.Problem,\n\t\t\"Problem\",\n\t\t0,\n\t\t\"Numeric Id of problem as per Projecteuler.net\",\n\t)\n\n\tflag.BoolVar(\n\t\t&args.Concurrent,\n\t\t\"Concurrent\",\n\t\tfalse,\n\t\t\"Solves problems concurrently (may be faster)\",\n\t)\n\n\tflag.Usage = usageMessage\n\n\tflag.Parse()\n}", "func ParseArgs() {\n\tflag.Var(&color, \"color\", \"Background and border color\")\n\tflag.Var(&paddingTop, \"padding-top\", \"Value of top padding\")\n\tflag.Var(&paddingBottom, \"padding-bottom\", \"Value of bottom padding\")\n\tflag.Var(&borderWidth, \"border-width\", \"Border width of focused window\")\n\tflag.Var(&nameLimit, \"name-limit\", \"Maximum length of workspace name\")\n\tflag.Var(&commands, \"exec\", \"Commands to execute at startup\")\n\tflag.StringVar(&terminal, \"term\", \"xterm\", \"A command to launch terminal emulator\")\n\tflag.StringVar(&launcher, \"launcher\", \"rofi -show run\", \"A command to show application launcher\")\n\tflag.StringVar(&locker, \"lock\", \"slock\", \"A command to lock screen\")\n\tflag.BoolVar(\n\t\t&debug, \"debug\", false,\n\t\t\"Outputs debug information to Stderr\",\n\t)\n\tflag.Parse()\n}", "func initFlags() {\n\tflag.Var(&logLevel, \"log\", \"set the `level` of logging.\")\n\tflag.TextVar(&logEnv, \"log-env\", log.DefaultEnv, \"set logging `env`.\")\n\tflag.TextVar(&formatType, \"format\", signalio.WriterTypeText, \"set the output format. Choices are text, json or csv.\")\n\toutfile.DefineFlags(flag.CommandLine, \"out\", \"force\", \"append\", \"OUTFILE\")\n\tflag.Usage = func() {\n\t\tcmdName := path.Base(os.Args[0])\n\t\tw := flag.CommandLine.Output()\n\t\tfmt.Fprintf(w, \"Usage:\\n %s [FLAGS]... {FILE|REPO...}\\n\\n\", cmdName)\n\t\tfmt.Fprintf(w, \"Collects signals for a list of project repository urls.\\n\\n\")\n\t\tfmt.Fprintf(w, \"FILE must be either a file or - to read from stdin. If FILE does not\\n\")\n\t\tfmt.Fprintf(w, \"exist it will be treated as a REPO.\\n\")\n\t\tfmt.Fprintf(w, \"Each REPO must be a project repository url.\\n\")\n\t\tfmt.Fprintf(w, \"\\nFlags:\\n\")\n\t\tflag.PrintDefaults()\n\t}\n\tflag.Parse()\n\n\t// Handle the version flag immediately. It's similar to -help.\n\tif *versionFlag {\n\t\tprintVersion()\n\t\tos.Exit(0)\n\t}\n}", "func init() {\n\tRootCmd.AddCommand(DeployCmd)\n\tDeployCmd.Flags().StringP(\"file\", \"f\", \"\", \"file used to specify the job to deploy (required)\")\n\tDeployCmd.Flags().StringP(\"port\", \"p\", \"\", \"connect to a specific port (default: 3939)\")\n\tDeployCmd.MarkFlagRequired(\"file\")\n}", "func parseArguments() (port int, userAgent string, cacheCapacity int, cacheExpiration time.Duration, apiOnly bool) {\n\tflag.BoolVar(&apiOnly, \"api-only\", false, \"Expose only the API end points\")\n\tflag.IntVar(&port, \"port\", 8080, \"Bind webserver to given port.\")\n\tflag.StringVar(&userAgent, \"user-agent\",\n\t\t\"Mozilla/5.0 (compatible; UrlExpander/1.0)\",\n\t\t\" User agent string used when translating shortened url.\")\n\tflag.IntVar(&cacheCapacity, \"cache-capacity\",\n\t\t100000,\n\t\t\"Expanded urls are cached for repeated queries. Using this option cache capacity can be set.\")\n\n\tvar cacheExpirationMinutes int\n\tflag.IntVar(&cacheExpirationMinutes, \"cache-expiration\",\n\t\t60,\n\t\t\"Set cache expiration time in minutes.\")\n\n\thelp := flag.Bool(\"help\", false, \"Print usage.\")\n\tflag.Parse()\n\n\tcacheExpiration = time.Duration(cacheExpirationMinutes) * time.Minute\n\n\t// print usage\n\tif *help {\n\t\tfmt.Fprintf(os.Stderr, \"Usage of %s:\\n\", os.Args[0])\n\t\tflag.PrintDefaults()\n\t\tsyscall.Exit(0)\n\t}\n\n\treturn\n}", "func setupCLI() string {\n\n\tvar input string\n\n\tInputPtr := flag.String(\"i\", \"\", \"location of raw binary data cipher text file\")\n\n\tif len(os.Args) < 2 {\n\n\t\tmissingParametersError()\n\t\tflag.PrintDefaults()\n\t\tos.Exit(1)\n\n\t}\n\n\tflag.Parse()\n\n\tinput = *InputPtr\n\n\tif input == \"\" {\n\t\tmissingParametersError()\n\t\tflag.PrintDefaults()\n\t\tos.Exit(1)\n\t}\n\n\treturn input\n\n}", "func init() {\n\tflag.StringVar(&inputFile, \"i\", \"\", \"The input file to unsort\")\n\tflag.StringVar(&outputFile, \"o\", \"\", \"The output file into which the unsorted content of inputfile will be placed. This file *will* be overwritten.\")\n}", "func init() {\n\tRootCmd.AddCommand(AdminCmd)\n\tAdminCmd.AddCommand(UnsubscribeCmd, HealthCheckDb, HealthCheckStore, HealthCheckStats, SetVasCmd, SetConfig, DeleteConfig)\n\tSetVasCmd.Flags().String(FlagUserID, \"\", \"\")\n\tSetVasCmd.Flags().Bool(FlagEnabled, false, \"\")\n\tSetConfig.Flags().String(FlagKey, \"\", \"\")\n\tSetConfig.Flags().String(FlagValue, \"\", \"\")\n\tDeleteConfig.Flags().String(FlagKey, \"\", \"\")\n}", "func FromArgs(args []string) (Config, error) {\n\tm := make(map[string]interface{})\n\n\tfor _, f := range args {\n\t\tif f == \"--\" {\n\t\t\tcontinue\n\t\t}\n\t\tassign := strings.SplitN(strings.TrimLeft(f, \"-\"), \"=\", 2)\n\t\tif len(assign) != 2 {\n\t\t\treturn nil, errors.Errorf(\"expected assignment, got: %s\", f)\n\t\t}\n\t\tm[assign[0]] = assign[1]\n\t}\n\n\treturn flatMap(m), nil\n}", "func Args() []string\t{ return os.Args[flags.first_arg:len(os.Args)] }", "func init() {\n\tflag.StringVar(&configFile, \"config\", \"config.toml\", \"config file name\")\n\n\tflag.Parse()\n}", "func newArguments(arguments []string) *Arguments {\n\treturn &Arguments{\n\t\targs: arguments,\n\t\tcount: len(arguments),\n\t\tindex: 0,\n\t\trawMode: false,\n\t}\n}", "func init() {\n\t\n\ta := len(os.Args)\n\n\tif a > 1 {\n\t\tN, _ = strconv.Atoi(os.Args[1]) \t\t// Number of goroutines\n\t\tif a > 2 {\n\t\t\tR, _ = strconv.Atoi(os.Args[2])\t\t// Number of rounds\n\t\t\tif a > 3 {\n\t\t\t\tF, _ = strconv.Atoi(os.Args[3]) // Number of flows \n\t\t\t}\n\t\t}\n\t}\n\n\tif N < 1 { // 0 deadlocks.\n\t\tN = 1000\n\t}\n\n\tif R < 1 {\n\t\tR = 1\n\t}\n\n\tif F > N {\n\t\tF = N\n\t}\n}", "func init() {\n\tapp.Parse(os.Args[1:])\n\tif *logging {\n\t\tf, err := os.Create(*logFile)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tlog.SetFlags(0)\n\t\tlog.SetOutput(f)\n\t} else {\n\t\tdis := ioutil.Discard\n\t\tlog.SetOutput(dis)\n\t}\n\tfmt.Println(\"Game starting\\nPoolsize :\\t\", *poolSize)\n\tfmt.Println(\"Generations :\\t\", *generations)\n\tfmt.Println(\"neuronsPL :\\t\", *neuronsPerLayer)\n}", "func init() {\n\tfor _, arg := range os.Args {\n\t\tif flag := strings.TrimLeft(arg, \"-\"); flag == TracingEnabledFlag {\n\t\t\tEnabled = true\n\t\t}\n\t}\n}", "func init() {\n\trootCmd.AddCommand(pmmpostCmd)\n\tpmmpostCmd.Flags().BoolP(\"vi\", \"m\", false, \"Set vi editing mode\")\n\tpmmpostCmd.Flags().StringP(\"outdir\", \"d\", \".\", \"Output directory\")\n\tpmmpostCmd.Flags().StringP(\"format\", \"f\", \"png\", \"Output format\")\n\tpmmpostCmd.Flags().BoolP(\"debug\", \"x\", false, \"Debug mode\")\n}", "func init() {\n\t// We register a flag to get it shown in the default usage.\n\t//\n\t// We don't actually use the parsed flag value, though, since that would require us to call\n\t// flag.Parse() here. If we call flag.Parse(), then higher-level libraries can't easily add\n\t// their own flags, since testing's t.Run() will not re-run flag.Parse() if the flags have\n\t// already been parsed.\n\t//\n\t// Instead, we simply look for our flag text in os.Args.\n\n\tflag.Bool(\"help-docket\", false, \"get help on docket\")\n\n\tfor _, arg := range os.Args {\n\t\tif arg == \"-help-docket\" || arg == \"--help-docket\" {\n\t\t\twriteHelp(os.Stderr)\n\n\t\t\tconst helpExitCode = 2 // This matches what 'go test -h' returns.\n\t\t\tos.Exit(helpExitCode)\n\t\t}\n\t}\n}", "func (o PgbenchSpecOutput) InitArgs() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v PgbenchSpec) *string { return v.InitArgs }).(pulumi.StringPtrOutput)\n}", "func getargs() (args []string) {\n\targs = []string{}\n\n\targs = append(args, \"--orientation\", \"Landscape\")\n\targs = append(args, \"--user-style-sheet\", \"style.css\")\n\targs = append(args, \"--page-width\", \"9in\")\n\targs = append(args, \"--page-height\", \"12in\")\n\targs = append(args, \"--zoom\", \"1.7\")\n\n\tproxy := os.Getenv(\"https_proxy\")\n\tif proxy != \"\" {\n\t\targs = append(args, \"--proxy\", proxy)\n\t}\n\n\treturn args\n}", "func init() {\n\tconst (\n\t\tdefaultGridSize = 2\n\t\tusage = \"Grid Size of the lattice\"\n\t)\n\tflag.Uint64Var(&gridSize, \"gridSize\", defaultGridSize, usage)\n\tflag.Uint64Var(&gridSize, \"g\", defaultGridSize, usage+\" (shorthand)\")\n}", "func main() {\n\tapp := cli.NewApp()\n\tapp.Name = \"go-init\"\n\tapp.Usage = \"Initialize a go project\"\n\tapp.Version = \"1.1.0\"\n\n\t// global flags\n\t//Log Level and Config Path\n\tapp.Flags = []cli.Flag{\n\t\tcli.StringFlag{\n\t\t\tName: \"configPath, c\",\n\t\t\tEnvVar: \"CONFIGPATH\",\n\t\t\tUsage: \"config path\",\n\t\t\tValue: \"./\",\n\t\t},\n\t\tcli.StringFlag{\n\t\t\tName: \"configName, n\",\n\t\t\tEnvVar: \"CONFIGNAME\",\n\t\t\tUsage: \"name of the config\",\n\t\t\tValue: \"config\",\n\t\t},\n\t\tcli.BoolFlag{\n\t\t\tName: \"force, f\",\n\t\t\tEnvVar: \"FORCE\",\n\t\t\tUsage: \"force the creatino of the folder\",\n\t\t},\n\t}\n\tapp.Action = func(c *cli.Context) {\n\t\tif len(c.Args()) == 0 {\n\t\t\treturn\n\t\t}\n\t\tif len(c.Args()) == 1 {\n\t\t\tappName = c.Args()[0]\n\t\t\tdirectory = \"./\"\n\n\t\t} else {\n\t\t\tdirectory = c.Args()[0]\n\t\t\tappName = c.Args()[1]\n\t\t}\n\t\tGenerate(c)\n\t}\n\tapp.Before = func(ctx *cli.Context) error {\n\t\tconfigPath = ctx.String(\"configPath\")\n\t\tconfigName = ctx.String(\"ConfigName\")\n\t\tforce = ctx.Bool(\"force\")\n\t\treturn nil\n\t}\n\tapp.Run(os.Args)\n\n}", "func init() {\n\tPromu.AddCommand(buildCmd)\n\n\tbuildCmd.Flags().String(\"prefix\", \"\", \"Specific dir to store binaries (default is .)\")\n\n\tviper.BindPFlag(\"build.prefix\", buildCmd.Flags().Lookup(\"prefix\"))\n}", "func setupFlags() commandOptions {\n\t// Usage text\n\tflag.Usage = asshUsage\n\n\t// Flags\n\tsshKey := flag.String(\"i\", \"${HOME}/.ssh/id-rsa.pem\", \"your ssh key\")\n\tuser := flag.String(\"u\", \"ec2-user\", \"ssh user name\")\n\n\tflag.Parse()\n\n\t// Required arguments\n\tif len(flag.Args()) < 1 {\n\t\tfmt.Println(\"Auto Scaling Group name is required\")\n\t\tos.Exit(1)\n\t}\n\n\t// Return a nice struct with all flags and arguments\n\treturn commandOptions{\n\t\tASGName: flag.Arg(0),\n\t\tSSHKey: *sshKey,\n\t\tUser: *user,\n\t}\n}", "func setMainFlags() {\n\tflagBasedir = flag.String(\"basedir\", \"\", \"set the basedir, the $(pwd) is default\")\n\tflagConffile = flag.String(\"conf\", \"erzha.ini\", \"$basedir/conf/erzha.ini is the default.\")\n}", "func init() {\n\trootCmd.AddCommand(reportCmd)\n\treportCmd.PersistentFlags().Int8Var(&before, \"before\", 12, \"Specified before uptime in hour report will be generate\")\n\terr := viper.BindPFlag(\"before\", reportCmd.PersistentFlags().Lookup(\"before\"))\n\tif err != nil {\n\t\tlog.Error().Msgf(\"Error binding before value: %v\", err.Error())\n\t}\n\tviper.SetDefault(\"before\", 12)\n\treportCmd.PersistentFlags().StringVar(&credfile, \"credfile\", \"~/.aws/credentials\", \"Specify aws credential file\")\n\terr = viper.BindPFlag(\"credfile\", reportCmd.PersistentFlags().Lookup(\"credfile\"))\n\tif err != nil {\n\t\tlog.Error().Msgf(\"Error binding credfile value: %v\", err.Error())\n\t}\n\tviper.SetDefault(\"credfile\", \"/.aws/credentials\")\n}", "func init() {\n\tcobra.OnInitialize(initConfig)\n\trootCmd.PersistentFlags().BoolVar(&loglevel, \"debug\", false, \"Set log level to Debug\") //nolint\n\trootCmd.PersistentFlags().StringVar(&jaegerurl, \"jaegerurl\", \"\", \"Set jaegger collector endpoint\")\n\trootCmd.PersistentFlags().BoolVar(&version, \"version\", false, \"version\")\n\n\trootCmd.Flags().BoolP(\"toggle\", \"t\", false, \"Help message for toggle\")\n\terr := viper.BindPFlag(\"jaegerurl\", rootCmd.PersistentFlags().Lookup(\"jaegerurl\"))\n\tif err != nil {\n\t\tlog.Error().Msgf(\"Error binding jaegerurl value: %v\", err.Error())\n\t}\n\tviper.SetDefault(\"jaegerurl\", \"\")\n\n}", "func init() {\n\tflag.StringVar(&logFileName, \"logfile\", \"\", \"log file\")\n}", "func parse_command_line() {\n\tflag.StringVar(&inputFile, \"file\", \"\", \"Use file as input source\")\n\tflag.Parse()\n}", "func init() {\n\tflag.StringVar(&port, \"port\", \"\", \"port to serve from\")\n\tflag.StringVar(&dir, \"directory\", \"\", \"directory with static files\")\n\tflag.Parse()\n\tif port == \"\" {\n\t\tlog.Fatal(\"must pass port to serve from\")\n\t}\n\tif dir == \"\" {\n\t\tlog.Fatal(\"must pass directory with static files\")\n\t}\n}", "func init() {\n\toptions.only = make(SelectedCollectors)\n\toptions.exclude = make(SelectedCollectors)\n\n\tflag.Var(&options.only, \"only\", \"Run only the listed collectors (comma-separated list of collector names)\")\n\tflag.Var(&options.exclude, \"exclude\", \"Run all the collectors except those listed (comma-separated list of collector names)\")\n\tflag.StringVar(&options.logLevel, \"log-level\", \"info\", \"Log level (one of 'warn', 'info', 'debug')\")\n}", "func makeCmdLine(args []string) string {\n\tvar s string\n\tfor _, v := range args {\n\t\tif s != \"\" {\n\t\t\ts += \" \"\n\t\t}\n\t\ts += windows.EscapeArg(v)\n\t}\n\treturn s\n}", "func initCommand(args ...string) []string {\n\tcmd := []string{\"singularity\"}\n\tcmd = append(cmd, args...)\n\treturn cmd\n}", "func init() {\n\tflag.Parse()\n}", "func init() {\n\tflag.Parse()\n}", "func ParseArguments() {\n\t/** Initializing system */\n\tconfigParams := InitSystem()\n\n\t/** Parse arguments */\n\tglobalFlags()\n\tkubectl(configParams)\n\tdockerBuild(configParams)\n\thelm(configParams)\n\n\t/** Default behavior */\n\tAlert(\"ERR\", \"This command doesn't exists!\", false)\n\tos.Exit(1)\n}", "func main() {\n\targs := os.Args[1:]\n\t// if len(args) == 5 {\n\t// \tfmt.Println(\"There are 5 arguments\")\n\t// } else if len(args) == 2 {\n\t// \tfmt.Printf(\"There are %d arguments: %s\\n\", len(args), args)\n\t// } else {\n\t// \tfmt.Println(strings.TrimSpace(usage))\n\t// }\n\tif len(args) >= 2 {\n\t\tfmt.Printf(\"There are %d arguments: %s\\n\", len(args), strings.Join(args, \" \"))\n\t} else {\n\t\tfmt.Println(usage)\n\t}\n}", "func ParseAndSetup(cl *cmdline.CmdLine) []string {\n\tlogFile := rotation.DefaultPath()\n\tvar maxSize int64 = rotation.DefaultMaxSize\n\tmaxBackups := rotation.DefaultMaxBackups\n\tlogToConsole := false\n\tcl.NewStringOption(&logFile).SetSingle('l').SetName(\"log-file\").SetUsage(\"The file to write logs to\")\n\tcl.NewInt64Option(&maxSize).SetName(\"log-file-size\").SetUsage(\"The maximum number of bytes to write to a log file before rotating it\")\n\tcl.NewIntOption(&maxBackups).SetName(\"log-file-backups\").SetUsage(\"The maximum number of old logs files to retain\")\n\tcl.NewBoolOption(&logToConsole).SetSingle('C').SetName(\"log-to-console\").SetUsage(\"Copy the log output to the console\")\n\tremainingArgs := cl.Parse(os.Args[1:])\n\tif rotator, err := rotation.New(rotation.Path(logFile), rotation.MaxSize(maxSize), rotation.MaxBackups(maxBackups)); err == nil {\n\t\tif logToConsole {\n\t\t\tjot.SetWriter(&xio.TeeWriter{Writers: []io.Writer{rotator, os.Stdout}})\n\t\t} else {\n\t\t\tjot.SetWriter(rotator)\n\t\t}\n\t} else {\n\t\tjot.Error(err)\n\t}\n\treturn remainingArgs\n}", "func init() {\n\t// Read command line flags\n\tusers := flag.Int(\"users\", 1, \"Concurrent user count, 동접 유저\")\n\tduration := flag.Int(\"duration\", 30, \"Test duration in seconds\")\n\tinterval := flag.String(\"interval\", \"1s\", `Interval for file creation(\"ns\", \"us\" (or \"µs\"), \"ms\", \"s\", \"m\", \"h\")`)\n\tsize := flag.Int64(\"size\", 1024, \"Size of file to create in bytes\")\n\tpath := flag.String(\"path\", \"\", \"[Required] Path where to create files\")\n\tflag.StringVar(&cpuprofile, \"cpuprofile\", \"\", \"write cpu profile to file\")\n\n\tflag.Parse()\n\n\tparsedInterval, err := time.ParseDuration(*interval)\n\tif err != nil || *path == \"\" {\n\t\tflag.Usage()\n\t\tos.Exit(1)\n\t}\n\n\t// Pass the flag values into viper.\n\tviper.Set(\"users\", *users)\n\tviper.Set(\"duration\", *duration)\n\tviper.Set(\"interval\", parsedInterval)\n\tviper.Set(\"size\", *size)\n\tviper.Set(\"path\", *path)\n\n\tformatter := &log.TextFormatter{\n\t\tTimestampFormat: \"2006-01-02T15:04:05.000\",\n\t\tFullTimestamp: true,\n\t}\n\tlog.SetFormatter(formatter)\n\tlog.SetLevel(log.DebugLevel)\n}", "func Init() {\n\targs, errs := options.Parse(optMap)\n\n\tif len(errs) != 0 {\n\t\tfmtc.Println(\"Arguments parsing errors:\")\n\n\t\tfor _, err := range errs {\n\t\t\tfmtc.Printf(\" %s\\n\", err.Error())\n\t\t}\n\n\t\tos.Exit(1)\n\t}\n\n\tif options.Has(OPT_COMPLETION) {\n\t\tgenCompletion()\n\t}\n\n\tif options.GetB(OPT_NO_COLOR) {\n\t\tfmtc.DisableColors = true\n\t}\n\n\tif options.GetB(OPT_VER) {\n\t\tshowAbout()\n\t\treturn\n\t}\n\n\tif options.GetB(OPT_HELP) || len(args) == 0 {\n\t\tshowUsage()\n\t\treturn\n\t}\n\n\tswitch len(args) {\n\tcase 1:\n\t\tprocess(args[0], \"\")\n\tcase 2:\n\t\tprocess(args[0], args[1])\n\tdefault:\n\t\tshowUsage()\n\t}\n}", "func init() {\n\tport = flag.Int(\"port\", 3000, \"an int\")\n}", "func main() {\n\t// os.Args provides access to raw command-line arguments. Note that the first value in this\n\t// slice is the path to the program, and os.Args[1:] holds the arguments to the program.\n\targsWithProg := os.Args\n\targsWithoutProg := os.Args[1:]\n\n\t// You can get individual args with normal indexing.\n\targ := os.Args[3]\n\n\tfmt.Println(argsWithProg)\n\tfmt.Println(argsWithoutProg)\n\tfmt.Println(arg)\n}", "func init() {\n\tflag.StringVar(&apiKey, \"apikey\", \"\", \"Mandatory. API key to access server platform\")\n\tflag.StringVar(&zoneID, \"zone\", \"\", \"Mandatory. Zone uuid\")\n\tflag.StringVar(&recordName, \"record\", \"\", \"Mandatory. Record to update\")\n\tflag.DurationVar(&refresh, \"refresh\", 5*time.Minute, \"Delay between checks for public IP address updates\")\n\tflag.StringVar(&resolver, \"resolver\", \"resolver1.opendns.com\", \"The resolver to check use for `myip` record\")\n\tflag.StringVar(&hostname, \"myip\", \"myip.opendns.com\", \"The hostname of the record to use to check for current IP\")\n}", "func init(){\n h = flag.Bool(\"h\", false, \"help\")\n l = flag.String(\"l\", \"\", \"music\")\n flag.Parse()\n //是否是帮助\n if *h {\n func(){\n help :=\n`\nGPlayer is based on mplayer.\nUsage: gplayer [-FLAG [VALUE]] [MUSIC [MUSIC]]\nFlag:\n-h Show help\n-l FILE Play a music list file\n`\n fmt.Print(help)\n os.Exit(0)\n }()\n }\n //是否是播放列表\n if *l != \"\"{\n dir := filepath.Dir(*l)\n lst, _ := os.OpenFile(*l, os.O_RDONLY, 0444)\n defer lst.Close()\n bnr := bufio.NewReader(lst)\n for{\n line, err := bnr.ReadString('\\n')\n if err==io.EOF {\n break\n }\n musics = append(musics, dir+\"/\"+line[0:len(line)-1])\n }\n return\n }\n //是否是连续的歌曲名参数\n musics = append(musics, flag.Args()...)\n}", "func (a *Analytics) Init() {\n\tflag.IntVar(&a.lowerBound, \"l\", 100, \"lower size of input\")\n\tflag.IntVar(&a.upperBound, \"u\", 10000, \"upper size of input\")\n\tflag.IntVar(&a.step, \"s\", 100, \"step of increasing input size\")\n\tflag.IntVar(&a.repetitions, \"r\", 1000, \"number of repetitions for given input size\")\n\n\tflag.Parse()\n}", "func init() {\n\tflag.StringVar(&domainID, \"d\", \"\", \"specify domain id\")\n}", "func ProcessArgs(cfg *Config) (u []string) {\n\tflag.Usage = func() {\n\t\tfmt.Println(\"Usage:\\nkdevpije user1,user2,alias3... [default|week|sprint]\")\n\t\tflag.PrintDefaults()\n\t}\n\tvar debugFlag = flag.Bool(\"debug\", false, \"Print logs to stderr\")\n\tvar reloadData = flag.Bool(\"reloadData\", false, \"Download list of employees again\")\n\tflag.Parse() // Scan the arguments list\n\n\tif !*debugFlag {\n\t\tlog.SetOutput(ioutil.Discard)\n\t}\n\tlog.Println(\"Processing arguments\")\n\tcfg.ReloadData = *reloadData\n\temps := flag.Arg(0)\n\tif emps == \"\" {\n\t\tflag.PrintDefaults()\n\t\treturn\n\t}\n\tu = strings.Split(emps, \",\")\n\tu = employees.ExpandFiveTimes(u, cfg.Aliases)\n\n\ttimeframe := flag.Arg(1)\n\tif timeframe == \"\" {\n\t\ttimeframe = \"default\"\n\t}\n\ttf, ok := cfg.Intervals[timeframe]\n\tif !ok {\n\t\ttf = 1\n\t}\n\tcfg.TimeFrame = tf\n\tcfg.PDConfig.TimeFrame = cfg.TimeFrame\n\tlog.Println(\"Processed config:\", cfg)\n\treturn\n}", "func (flag *Flags) ParseArgs(args []string) {\n\t*flag = Flags{FlagSet: pflag.NewFlagSet(Binary, pflag.ExitOnError)}\n\tflag.Usage = func() {\n\t\tfmt.Printf(\"Usage: %s [--config=filepath] [--version] [--debug]\", Binary)\n\t\tflag.PrintDefaults()\n\t}\n\tflag.StringVarP(&flag.ConfigFile, \"config\", \"c\", \"/usr/local/etc/\"+Binary+\".conf\", \"Config File\")\n\tflag.BoolVarP(&flag.VersionReq, \"version\", \"v\", false, \"Print the version and exit\")\n\t_ = flag.Parse(args) // flag.ExitOnError means this will never return != nil\n}", "func Init() *cli.App {\n\tapp := cli.NewApp()\n\tapp.Name = \"maklo\"\n\tapp.Usage = \"maklo [command]\"\n\tapp.Author = \"sofyan48\"\n\tapp.Email = \"meongbego@gmail.com\"\n\tapp.Version = \"0.0.1\"\n\tapp.Flags = []cli.Flag{\n\t\tcli.StringFlag{\n\t\t\tName: \"environtment, e\",\n\t\t\tUsage: \"Load Environtment from path\",\n\t\t\tDestination: &Args.Environment,\n\t\t},\n\t}\n\n\treturn app\n}", "func (c *PruneCommand) Init(args []string) error {\n\treturn c.fs.Parse(args)\n}", "func init() {\n\tnewCommand(\"ping\", 0, false, false, ping).setHelp(\"\\\"Pong!\\\"\").add()\n\tnewCommand(\"pong\", 0, false, false, ping).setHelp(\"\\\"Ping!\\\"\").add()\n\tnewCommand(\"help\", 0, false, false, msgHelp).add()\n\tnewCommand(\"git\", 0, false, false, gitHubLink).setHelp(\n\t\t\"Displays the github link where I'm being developed.\",\n\t).add()\n\t/*newCommand(\"request\", 0, false, false, featureRequest).setHelp(\n\t\"Requests a feature.\").add()*/\n\tnewCommand(\"report\", 0, false, false, bugReport).setHelp(\n\t\t\"Report a bug.\").add()\n\tnewCommand(\"woot\", 0, false, false, celebration).setHelp(\n\t\t\"Starts a celebration!\").add()\n}", "func InitFlags(flagset *flag.FlagSet) {\n\tif flagset == nil {\n\t\tflagset = flag.CommandLine\n\t}\n\n\tcommandLine.VisitAll(func(f *flag.Flag) {\n\t\tflagset.Var(f.Value, f.Name, f.Usage)\n\t})\n}", "func ArgParse(confPath, tmplPath, emailTmplPath, staticTmplPath *string) (*commandLineArgs, error) {\n\tvar args commandLineArgs\n\targs.isProdFlag = flag.Bool(\"production\", false, \"use this flag to run the production executable\")\n\targs.basePath = flag.String(\"base\", \"\", \"base path (that contains client and server files) of the web application\")\n\tflag.Parse()\n\tif *args.isProdFlag {\n\t\t*confPath = filepath.Join(*args.basePath, *confPath)\n\t\t*tmplPath = filepath.Join(*args.basePath, *tmplPath)\n\t\t*emailTmplPath = filepath.Join(*args.basePath, *emailTmplPath)\n\t\t*staticTmplPath = filepath.Join(*args.basePath, *staticTmplPath)\n\t} else {\n\t\tbasePath, err := filepath.Abs(filepath.Dir(os.Args[0]))\n\t\tif err != nil {\n\t\t\treturn &args, err\n\t\t}\n\t\tvar (\n\t\t\tintermediateTmplPath string\n\t\t\tintermediateEmailTmplPath string\n\t\t\tintermediateStaticTmplPath string\n\t\t\tintermediateConfPath string\n\t\t)\n\t\tfor {\n\t\t\tintermediateTmplPath = filepath.Join(basePath, *tmplPath)\n\t\t\tintermediateEmailTmplPath = filepath.Join(basePath, *emailTmplPath)\n\t\t\tintermediateStaticTmplPath = filepath.Join(basePath, *staticTmplPath)\n\t\t\tintermediateConfPath = filepath.Join(basePath, *confPath)\n\t\t\tif _, err = os.Stat(intermediateConfPath); err == nil {\n\t\t\t\t*tmplPath, *emailTmplPath, *staticTmplPath, *confPath = intermediateTmplPath, intermediateEmailTmplPath, intermediateStaticTmplPath, intermediateConfPath\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tbasePath = filepath.Dir(basePath)\n\t\t}\n\t}\n\treturn &args, nil\n}", "func init() {\n\t// Add command names to cfssl usage\n\tflag.IntVar(&log.Level, \"loglevel\", log.LevelInfo, \"Log level\")\n\tflag.Usage = func() {\n\t\tfmt.Fprintf(os.Stderr, usage)\n\t\tfor name := range cmds {\n\t\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", name)\n\t\t}\n\t}\n\t// Register commands.\n\tcmds = map[string]*Command{\n\t\t\"bundle\": CLIBundler,\n\t\t\"sign\": CLISigner,\n\t\t\"serve\": CLIServer,\n\t\t\"version\": CLIVersioner,\n\t\t\"genkey\": CLIGenKey,\n\t\t\"gencert\": CLIGenCert,\n\t\t\"selfsign\": CLISelfSign,\n\t}\n\t// Register all command flags.\n\tregisterFlags()\n}", "func init() {\n\tflagset.Usage = func() {\n\t\tfmt.Println(\"Usage: stellaratomicswap [flags] cmd [cmd args]\")\n\t\tfmt.Println()\n\t\tfmt.Println(\"Commands:\")\n\t\tfmt.Println(\" initiate [-asset code:issuer] <initiator seed> <participant address> <amount>\")\n\t\tfmt.Println(\" participate [-asset code:issuer] <participant seed> <initiator address> <amount> <secret hash>\")\n\t\tfmt.Println(\" redeem <receiver seed> <holdingAccountAdress> <secret>\")\n\t\tfmt.Println(\" refund <refund transaction>\")\n\t\tfmt.Println(\" extractsecret <holdingAccountAdress> <secret hash>\")\n\t\tfmt.Println(\" auditcontract <holdingAccountAdress> < refund transaction>\")\n\t\tfmt.Println()\n\t\tfmt.Println(\"Flags:\")\n\t\tflagset.PrintDefaults()\n\t}\n}" ]
[ "0.7419382", "0.74053735", "0.6910425", "0.67321837", "0.67054397", "0.6680921", "0.66162205", "0.6614232", "0.6585571", "0.6536786", "0.6528025", "0.648461", "0.6451435", "0.6429187", "0.63542014", "0.63480437", "0.6340536", "0.63089436", "0.6298183", "0.62748134", "0.6271853", "0.625551", "0.6251872", "0.6222327", "0.6216845", "0.6202818", "0.61877376", "0.6172327", "0.617174", "0.6155977", "0.6151131", "0.614856", "0.61375064", "0.6133238", "0.6113888", "0.610903", "0.6089372", "0.60746765", "0.6066927", "0.60585064", "0.605273", "0.60348934", "0.6029035", "0.6026187", "0.601759", "0.60158664", "0.6001943", "0.59950507", "0.5994626", "0.59943825", "0.5982988", "0.59663355", "0.5965824", "0.59561336", "0.59272426", "0.591933", "0.5914577", "0.59112585", "0.5908375", "0.5901729", "0.59008247", "0.5891538", "0.58894706", "0.5876761", "0.5871218", "0.58690375", "0.586901", "0.58661807", "0.58644074", "0.58576226", "0.58541083", "0.5852763", "0.58493423", "0.583776", "0.580981", "0.58069205", "0.5803986", "0.5792931", "0.5790653", "0.5790653", "0.5789868", "0.5777198", "0.57733583", "0.5766724", "0.57640094", "0.5759448", "0.57570934", "0.5740107", "0.5730487", "0.5725471", "0.57193196", "0.5718464", "0.5696743", "0.5696135", "0.5688464", "0.56870055", "0.567659", "0.566703", "0.56591094", "0.5651327" ]
0.61650586
29
runIndex is the main function for the index subcommand
func runIndex() { // check index flag is set (global flag but don't require it for all sub commands) if *indexDir == "" { fmt.Println("please specify a directory for the index files (--indexDir)") os.Exit(1) } // set up profiling if *profiling == true { defer profile.Start(profile.MemProfile, profile.ProfilePath("./")).Stop() //defer profile.Start(profile.ProfilePath("./")).Stop() } // start logging if *logFile != "" { logFH := misc.StartLogging(*logFile) defer logFH.Close() log.SetOutput(logFH) } else { log.SetOutput(os.Stdout) } // start the index sub command start := time.Now() log.Printf("i am groot (version %s)", version.GetVersion()) log.Printf("starting the index subcommand") // check the supplied files and then log some stuff log.Printf("checking parameters...") misc.ErrorCheck(indexParamCheck()) log.Printf("\tprocessors: %d", *proc) log.Printf("\tk-mer size: %d", *kmerSize) log.Printf("\tsketch size: %d", *sketchSize) log.Printf("\tgraph window size: %d", *windowSize) log.Printf("\tnum. partitions: %d", *numPart) log.Printf("\tmax. K: %d", *maxK) log.Printf("\tmax. sketch span: %d", *maxSketchSpan) // record the runtime information for the index sub command info := &pipeline.Info{ Version: version.GetVersion(), KmerSize: *kmerSize, SketchSize: *sketchSize, WindowSize: *windowSize, NumPart: *numPart, MaxK: *maxK, MaxSketchSpan: *maxSketchSpan, IndexDir: *indexDir, } // create the pipeline log.Printf("initialising indexing pipeline...") indexingPipeline := pipeline.NewPipeline() // initialise processes log.Printf("\tinitialising the processes") msaConverter := pipeline.NewMSAconverter(info) graphSketcher := pipeline.NewGraphSketcher(info) sketchIndexer := pipeline.NewSketchIndexer(info) // connect the pipeline processes log.Printf("\tconnecting data streams") msaConverter.Connect(msaList) graphSketcher.Connect(msaConverter) sketchIndexer.Connect(graphSketcher) // submit each process to the pipeline and run it indexingPipeline.AddProcesses(msaConverter, graphSketcher, sketchIndexer) log.Printf("\tnumber of processes added to the indexing pipeline: %d\n", indexingPipeline.GetNumProcesses()) log.Print("creating graphs, sketching traversals and indexing...") indexingPipeline.Run() log.Printf("writing index files in \"%v\"...", *indexDir) misc.ErrorCheck(info.SaveDB(*indexDir + "/groot.lshe")) misc.ErrorCheck(info.Dump(*indexDir + "/groot.gg")) log.Printf("finished in %s", time.Since(start)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func index(w http.ResponseWriter, req *http.Request, ctx httputil.Context) (e *httputil.Error) {\n\tif req.URL.Path != \"/\" {\n\t\tnotFound(w, req)\n\t\treturn\n\t}\n\tm := newManager(ctx)\n\n\tres, err := m.Index()\n\tif err != nil {\n\t\te = httputil.Errorf(err, \"couldn't query for test results\")\n\t\treturn\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"text/html\")\n\tif err := T(\"index/index.html\").Execute(w, res); err != nil {\n\t\te = httputil.Errorf(err, \"error executing index template\")\n\t}\n\treturn\n}", "func index(w http.ResponseWriter, r *http.Request){\n\terr := templ.ExecuteTemplate(w, \"index\", nil)\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t}\n}", "func index(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\n\terr := tpl.ExecuteTemplate(w, \"index.html\", nil)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\tlog.Fatalln(err)\n\t}\n\tfmt.Println(\"HERE INDEX\")\n}", "func Run() {\n\terr := Index(\n\t\tviper.GetString(\"collection\"),\n\t\tviper.GetString(\"key\"),\n\t\tviper.GetString(\"indexType\"),\n\t)\n\tif err != nil {\n\t\tlog.Println(\"ERROR applying index\", err)\n\t\treturn\n\t}\n}", "func index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"index de uma função\")\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\tmessage := \"Welcome to Recipe Book!\"\n\tindexT.Execute(w, message)\n}", "func ExecuteIndex(user models.User, w http.ResponseWriter, r *http.Request) error {\n\taccess := 0\n\n\t// check if user is empty\n\tif user.ID != \"\" {\n\t\taccess = user.GetAccess()\n\t} else {\n\t\t// todo: normal auth page\n\t\tw.Header().Set(\"Content-Type\", \"\")\n\t\thttp.Redirect(w, r, \"/login\", http.StatusFound)\n\t\treturn nil\n\t}\n\n\t// getting all required data\n\tvoiceTime := \"\"\n\tvtd, err := user.GetVoiceTime()\n\tif err == nil {\n\t\tvoiceTime = utils.FormatDuration(vtd)\n\t}\n\txbox := \"\"\n\txboxes, _ := user.GetXboxes()\n\tif len(xboxes) > 0 {\n\t\txbox = xboxes[0].Xbox\n\t}\n\tjoinedAtTime, err := user.GetGuildJoinDate()\n\tjoinedAt := \"\"\n\tif err == nil {\n\t\tdif := int(time.Now().Sub(joinedAtTime).Milliseconds()) / 1000 / 3600 / 24\n\t\tdays := utils.FormatUnit(dif, utils.Days)\n\t\tjoinedAt = fmt.Sprintf(\"%s (%s)\", utils.FormatDateTime(joinedAtTime), days)\n\t}\n\twarns, err := user.GetWarnings()\n\tif err != nil {\n\t\twarns = []models.Warning{}\n\t}\n\n\t// Preparing content and rendering\n\tcontent := IndexContent{\n\t\tUsername: user.Username,\n\t\tAvatar: user.AvatarURL,\n\t\tJoinedAt: joinedAt,\n\t\tXbox: xbox,\n\t\tVoiceTime: voiceTime,\n\t\tWarnsCount: len(warns),\n\t\tWarnings: PrepareWarnings(warns),\n\t}\n\n\ttmpl, err := template.ParseFiles(\"templates/layout.gohtml\", \"templates/index.gohtml\", \"templates/navbar.gohtml\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = tmpl.ExecuteTemplate(w, \"layout\", Layout{\n\t\tTitle: \"Главная страница\",\n\t\tPage: \"index\",\n\t\tAccess: access,\n\t\tContent: content,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func ShowIndex() {\n\tfmt.Printf(\"%v\\n\", indexText)\n}", "func (c *RunCommand) Index() int {\n\treturn c.cmd.index\n}", "func Index(w http.ResponseWriter, data *IndexData) {\n\trender(tpIndex, w, data)\n}", "func Index(w http.ResponseWriter, data *IndexData) {\n\trender(tpIndex, w, data)\n}", "func (si ServeIndex) Index(w http.ResponseWriter, r *http.Request) {\n\tpara := params.NewParams()\n\tdata, _, err := Updates(r, para)\n\tif err != nil {\n\t\tif _, ok := err.(params.RenamedConstError); ok {\n\t\t\thttp.Redirect(w, r, err.Error(), http.StatusFound)\n\t\t\treturn\n\t\t}\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tdata[\"Distrib\"] = si.StaticData.Distrib\n\tdata[\"Exporting\"] = exportingCopy() // from ./ws.go\n\tdata[\"OstentUpgrade\"] = OstentUpgrade.Get()\n\tdata[\"OstentVersion\"] = si.StaticData.OstentVersion\n\tdata[\"TAGGEDbin\"] = si.StaticData.TAGGEDbin\n\n\tsi.IndexTemplate.Apply(w, struct{ Data IndexData }{Data: data})\n}", "func (i *IndexCommand) Run(ctx context.Context, subcommandArgs []string) error {\n\toutputPath := i.flags.String(\"o\", \"Index.md\", \"Output path contained to the $JOURNAL_PATH.\")\n\tif !i.flags.Parsed() {\n\t\tif err := i.flags.Parse(subcommandArgs); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif *outputPath == \".\" {\n\t\t*outputPath = \"Index.md\"\n\t}\n\tindex, err := tagMap(i.options.JournalPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tkeys := sortedTagKeys(index)\n\tvar newIndex string\n\tfor _, tag := range keys {\n\t\tnewIndex += fmt.Sprintf(\"\\n* *%s* \", tag)\n\t\tmappedEntries := make([]string, len(index[tag]))\n\t\tmapper := func(entry string) string {\n\t\t\treturn fmt.Sprintf(\"[%s](%s)\", entry, entry)\n\t\t}\n\t\tfor i, entry := range index[tag] {\n\t\t\tmappedEntries[i] = mapper(entry)\n\t\t}\n\t\tnewIndex += strings.Join(mappedEntries, \", \")\n\t}\n\tindexPath := fmt.Sprintf(\"%s/%s\", i.options.JournalPath, path.Base(*outputPath))\n\treturn ioutil.WriteFile(indexPath, []byte(newIndex), 0644)\n}", "func index(res http.ResponseWriter, req *http.Request) {\n\ttpl, err := template.ParseFiles(\"index.html\")\n\tif err != nil { // if file does not exist, give user a error\n\t\tlog.Fatalln(err) // stops program if file does not exist\n\t}\n\ttpl.Execute(res, nil) // execute the html file\n}", "func UseIndex() *ishell.Cmd {\n\n\treturn &ishell.Cmd{\n\t\tName: \"use\",\n\t\tHelp: \"Select index to use for subsequent document operations\",\n\t\tFunc: func(c *ishell.Context) {\n\t\t\tif context == nil {\n\t\t\t\terrorMsg(c, errNotConnected)\n\t\t\t} else {\n\t\t\t\tdefer restorePrompt(c)\n\t\t\t\tif len(c.Args) < 1 {\n\t\t\t\t\tif context.ActiveIndex != \"\" {\n\t\t\t\t\t\tcprintlist(c, \"Using index \", cy(context.ActiveIndex))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcprintln(c, \"No index is in use\")\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif c.Args[0] == \"--\" {\n\t\t\t\t\tif context.ActiveIndex != \"\" {\n\t\t\t\t\t\tcprintlist(c, \"Index \", cy(context.ActiveIndex), \" is no longer in use\")\n\t\t\t\t\t\tcontext.ActiveIndex = \"\"\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcprintln(c, \"No index is in use\")\n\t\t\t\t\t}\n\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\ts, err := context.ResolveAndValidateIndex(c.Args[0])\n\t\t\t\tif err != nil {\n\t\t\t\t\terrorMsg(c, err.Error())\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tcontext.ActiveIndex = s\n\t\t\t\tif s != c.Args[0] {\n\t\t\t\t\tcprintlist(c, \"For alias \", cyb(c.Args[0]), \" selected index \", cy(s))\n\t\t\t\t} else {\n\t\t\t\t\tcprintlist(c, \"Selected index \", cy(s))\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t}\n\n}", "func Index(w http.ResponseWriter, data interface{}) {\n\trender(tpIndex, w, data)\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\ta := \"hello from index router\"\n\tfmt.Fprintln(w, a)\n}", "func showIndex(res http.ResponseWriter, req *http.Request, params httprouter.Params) {\n\tServeTemplateWithParams(res, req, \"index.html\", nil)\n}", "func indexHandler(c *fiber.Ctx) error {\n\treturn common.HandleTemplate(c, \"index\",\n\t\t\"me\", nil, 200)\n}", "func (i indexer) Index(ctx context.Context, req IndexQuery) (\n\tresp *IndexResult, err error) {\n\n\tlog.Info(\"index [%v] root [%v] len_dirs=%v len_files=%v\",\n\t\treq.Key, req.Root, len(req.Dirs), len(req.Files))\n\tstart := time.Now()\n\t// Setup the response\n\tresp = NewIndexResult()\n\tif err = req.Normalize(); err != nil {\n\t\tlog.Info(\"index [%v] error: %v\", req.Key, err)\n\t\tresp.Error = errs.NewStructError(err)\n\t\treturn\n\t}\n\n\t// create index shards\n\tvar nshards int\n\tif nshards = i.cfg.NumShards; nshards == 0 {\n\t\tnshards = 1\n\t}\n\tnshards = utils.MinInt(nshards, maxShards)\n\ti.shards = make([]index.IndexWriter, nshards)\n\ti.root = getRoot(i.cfg, &req)\n\n\tfor n := range i.shards {\n\t\tname := path.Join(i.root, shardName(req.Key, n))\n\t\tixw, err := getIndexWriter(ctx, name)\n\t\tif err != nil {\n\t\t\tresp.Error = errs.NewStructError(err)\n\t\t\treturn resp, nil\n\t\t}\n\t\ti.shards[n] = ixw\n\t}\n\n\tfs := getFileSystem(ctx, i.root)\n\trepo := newRepoFromQuery(&req, i.root)\n\trepo.SetMeta(i.cfg.RepoMeta, req.Meta)\n\tresp.Repo = repo\n\n\t// Add query Files and scan Dirs for files to index\n\tnames, err := i.scanner(fs, &req)\n\tch := make(chan int, nshards)\n\tchnames := make(chan string, 100)\n\tgo func() {\n\t\tfor _, name := range names {\n\t\t\tchnames <- name\n\t\t}\n\t\tclose(chnames)\n\t}()\n\treqch := make(chan par.RequestFunc, nshards)\n\tfor _, shard := range i.shards {\n\t\treqch <- indexShard(&i, &req, shard, fs, chnames, ch)\n\t}\n\tclose(reqch)\n\terr = par.Requests(reqch).WithConcurrency(nshards).DoWithContext(ctx)\n\tclose(ch)\n\n\t// Await results, each indicating the number of files scanned\n\tfor num := range ch {\n\t\trepo.NumFiles += num\n\t}\n\n\trepo.NumShards = len(i.shards)\n\t// Flush our index shard files\n\tfor _, shard := range i.shards {\n\t\tshard.Flush()\n\t\trepo.SizeIndex += ByteSize(shard.IndexBytes())\n\t\trepo.SizeData += ByteSize(shard.DataBytes())\n\t\tlog.Debug(\"index flush %v (data) %v (index)\",\n\t\t\trepo.SizeData, repo.SizeIndex)\n\t}\n\trepo.ElapsedIndexing = time.Since(start)\n\trepo.TimeUpdated = time.Now().UTC()\n\n\tvar msg string\n\tif err != nil {\n\t\trepo.State = ERROR\n\t\tresp.SetError(err)\n\t\tmsg = \"error: \" + resp.Error.Error()\n\t} else {\n\t\trepo.State = OK\n\t\tmsg = \"ok \" + fmt.Sprintf(\n\t\t\t\"(%v files, %v data, %v index)\",\n\t\t\trepo.NumFiles, repo.SizeData, repo.SizeIndex)\n\t}\n\tlog.Info(\"index [%v] %v [%v]\", req.Key, msg, repo.ElapsedIndexing)\n\treturn\n}", "func (b *Blueprint) indexCommand(typ string, columns []string, index string, algorithm string) *Blueprint {\n\t// if no name was specified for this index, we will create one using a bsaic\n\t// convention of the table name, followed by the columns, followd by an\n\t// index type, such as primary or index, which makes the index unique.\n\tif index == \"\" {\n\t\tindex = b.createIndexName(typ, columns)\n\t}\n\n\treturn b.addCommand(typ, &CommandOptions{\n\t\tIndex: index,\n\t\tColumns: columns,\n\t\tAlgorithm: algorithm,\n\t})\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\t// validate the passed-in arguments\n\tvars, err := wdp.ValidateApiArgs(r)\n\tif err != nil {\n\t\tlog.Print(\"error validating API arguments: \", err)\n\t}\n\n\t// parse the template at index.html\n\t// NOTE: SWITCH WHICH OF THESE STATEMENTS IS COMMENTED OUT TO RUN ON CLOUD VPS VS LOCALLY\n\t// t, err := template.ParseFiles(\"templates/index.html\") // LOCAL\n\tt, err := template.ParseFiles(\"/etc/diff-privacy-beam/index.html\") // CLOUD VPS\n\tif err != nil {\n\t\tlog.Print(\"error parsing template index_go.html: \", err)\n\t}\n\n\t// execute the template to serve it back to the client\n\terr = t.Execute(w, vars)\n\tif err != nil {\n\t\tlog.Print(\"error executing template index_go.html: \", err)\n\t}\n}", "func CheckoutIndexCmd(c *git.Client, args []string) error {\n\tflags := flag.NewFlagSet(\"checkout-index\", flag.ExitOnError)\n\tflags.SetOutput(flag.CommandLine.Output())\n\tflags.Usage = func() {\n\t\tflag.Usage()\n\t\tfmt.Fprintf(flag.CommandLine.Output(), \"\\n\\nOptions:\\n\")\n\t\tflags.PrintDefaults()\n\t\t// Some git tests test for a 129 exit code if the commandline\n\t\t// parsing fails for checkout-index.\n\t\tos.Exit(129)\n\t}\n\toptions := git.CheckoutIndexOptions{}\n\n\tflags.BoolVar(&options.UpdateStat, \"index\", false, \"Update stat information for checkout out entries in the index\")\n\tflags.BoolVar(&options.UpdateStat, \"u\", false, \"Alias for --index\")\n\n\tflags.BoolVar(&options.Quiet, \"quiet\", false, \"Be quiet if files exist or are not in index\")\n\tflags.BoolVar(&options.Quiet, \"q\", false, \"Alias for --quiet\")\n\n\tflags.BoolVar(&options.Force, \"force\", false, \"Force overwrite of existing files\")\n\tflags.BoolVar(&options.Force, \"f\", false, \"Alias for --force\")\n\n\tflags.BoolVar(&options.All, \"all\", false, \"Checkout all files in the index.\")\n\tflags.BoolVar(&options.All, \"a\", false, \"Alias for --all\")\n\n\tflags.BoolVar(&options.NoCreate, \"no-create\", false, \"Don't checkout new files, only refresh existing ones\")\n\tflags.BoolVar(&options.NoCreate, \"n\", false, \"Alias for --no-create\")\n\n\tflags.StringVar(&options.Prefix, \"prefix\", \"\", \"When creating files, prepend string\")\n\tflags.StringVar(&options.Stage, \"stage\", \"\", \"Copy files from named stage (unimplemented)\")\n\n\tflags.BoolVar(&options.Temp, \"temp\", false, \"Instead of copying files to a working directory, write them to a temp dir\")\n\n\tstdin := flags.Bool(\"stdin\", false, \"Instead of taking paths from command line, read from stdin\")\n\tflags.BoolVar(&options.NullTerminate, \"z\", false, \"Use nil instead of newline to terminate paths read from stdin\")\n\n\tflags.Parse(args)\n\tfiles := flags.Args()\n\tif *stdin {\n\t\toptions.Stdin = os.Stdin\n\t}\n\n\t// Convert from string to git.File\n\tgfiles := make([]git.File, len(files))\n\tfor i, f := range files {\n\t\tgfiles[i] = git.File(f)\n\t}\n\n\treturn git.CheckoutIndex(c, options, gfiles)\n\n}", "func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tdata := &Index{\n\t\tTitle: \"Image gallery\",\n\t\tBody: \"Welcome to the image gallery.\",\n\t}\n\tfor name, img := range images {\n\t\tdata.Links = append(data.Links, Link{\n\t\t\tURL: \"/image/\" + name,\n\t\t\tTitle: img.Title,\n\t\t})\n\t}\n\tif err := indexTemplate.Execute(w, data); err != nil {\n\t\tlog.Println(err)\n\t}\n}", "func serveIndex(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\terr := serveAssets(w, r, \"index.html\")\n\tcheckError(err)\n}", "func (c App) Index() revel.Result {\n\treturn c.Render()\n}", "func (c App) Index() revel.Result {\n\treturn c.Render()\n}", "func indexHandler(res http.ResponseWriter, req *http.Request) {\n\n\t// Execute the template and respond with the index page.\n\ttemplates.ExecuteTemplate(res, \"index\", nil)\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hello from our index page\")\n}", "func index(w http.ResponseWriter, req *http.Request) {\n\thttp.ServeFile(w, req, \"./templates/index.html\")\n}", "func index(w http.ResponseWriter, r *http.Request) {\n\tdata := page{Title: \"School Database\", Header: \"Welcome, please select an option\"}\n\ttemplateInit(w, \"index.html\", data)\n\n}", "func (t tApp) Index(w http.ResponseWriter, r *http.Request) {\n\tvar h http.Handler\n\tc := App.New(w, r, \"App\", \"Index\")\n\tdefer func() {\n\t\tif h != nil {\n\t\t\th.ServeHTTP(w, r)\n\t\t}\n\t}()\n\tdefer App.After(c, w, r)\n\tif res := App.Before(c, w, r); res != nil {\n\t\th = res\n\t\treturn\n\t}\n\tif res := c.Index(); res != nil {\n\t\th = res\n\t\treturn\n\t}\n}", "func indexHandler(w http.ResponseWriter, r *http.Request) {\r\n t, _ := template.New(\"webpage\").Parse(indexPage) // parse embeded index page\r\n t.Execute(w, pd) // serve the index page (html template)\r\n}", "func ReadIndex(output http.ResponseWriter, reader *http.Request) {\n\tfmt.Fprintln(output, \"ImageManagerAPI v1.0\")\n\tLog(\"info\", \"Endpoint Hit: ReadIndex\")\n}", "func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tdata, err := newPageData(1)\n\tif err != nil {\n\t\thttp.NotFound(w, r)\n\t}\n\terr = t.ExecuteTemplate(w, \"index\", data)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func (s *service) indexCore(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\treq := &indexRequest{\n\t\tindex: s.index,\n\t\tlog: s.logger,\n\t\tr: r,\n\t\tstore: s.store,\n\t}\n\treq.init()\n\treq.read()\n\treq.readCore()\n\tif req.req.IncludeExecutable {\n\t\treq.readExecutable()\n\t} else {\n\t\treq.computeExecutableSize()\n\t}\n\treq.indexCore()\n\treq.close()\n\n\tif req.err != nil {\n\t\ts.logger.Error(\"indexing\", \"uid\", req.uid, \"err\", req.err)\n\t\twriteError(w, http.StatusInternalServerError, req.err)\n\t\treturn\n\t}\n\n\ts.received.With(prometheus.Labels{\n\t\t\"hostname\": req.coredump.Hostname,\n\t\t\"executable\": req.coredump.Executable,\n\t}).Inc()\n\n\ts.receivedSizes.With(prometheus.Labels{\n\t\t\"hostname\": req.coredump.Hostname,\n\t\t\"executable\": req.coredump.Executable,\n\t}).Observe(datasize.ByteSize(req.coredump.Size).MBytes())\n\n\ts.analysisQueue <- req.coredump\n\n\twrite(w, http.StatusOK, map[string]interface{}{\"acknowledged\": true})\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\t// Fill out the page data for index\n\tpd := PageData{\n\t\tTitle: \"Index Page\",\n\t\tBody: \"This is the body of the index page.\",\n\t}\n\n\t// Render a template with our page data\n\ttmpl, err := render(pd)\n\n\t// if we get an error, write it out and exit\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\n\t// All went well, so write out the template\n\tw.Write([]byte(tmpl))\n\n\t//fmt.Fprintf(w, \"Hello world from %q\", html.EscapeString(r.URL.Path))\n}", "func (api *API) GetIndex(w http.ResponseWriter, r *http.Request) {\n\n\tinfo := Info{Port: api.Session.Config.API.Port, Versions: Version}\n\td := Metadata{Info: info}\n\n\tres := CodeToResult[CodeOK]\n\tres.Data = d\n\tres.Message = \"Documentation available at https://github.com/netm4ul/netm4ul\"\n\tw.WriteHeader(res.HTTPCode)\n\tjson.NewEncoder(w).Encode(res)\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != http.MethodGet {\n\t\thttp.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\tfmt.Fprintf(w, \"I am running...\\n\")\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\n\tfmt.Fprintln(w, \"Steve and Kyle Podcast: #api\")\n\tfmt.Fprintln(w, \"Number of episodes in database:\", EpCount())\n\tfmt.Fprintln(w, \"Created by Derek Slenk\")\n\tfmt.Println(\"Endpoint Hit: Index\")\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\n\t// Render the \"Index.gtpl\"\n\tgoTmpl.ExecuteTemplate(w, \"Index\", nil)\n\n\t//name := r.FormValue(\"name\")\n\n\t// Logging the Action\n\tlog.Println(\"Render: Index.gtpl\")\n\n}", "func TestIndex(t *testing.T) {\n\tstubTank := &tank.StubTank{Moves: nil}\n\n\ts := server.NewServer(stubTank)\n\n\treq, err := http.NewRequest(http.MethodGet, \"/\", http.NoBody)\n\tif err != nil {\n\t\tt.Fatalf(\"Error creating request for index: %v\", err)\n\t}\n\n\tw := httptest.NewRecorder()\n\ts.ServeHTTP(w, req)\n\n\tif w.Code != http.StatusOK {\n\t\tt.Fatalf(\"Wrong status - expected %d, got %d\", http.StatusOK, w.Code)\n\t}\n\n\tbody, err := ioutil.ReadAll(w.Body)\n\tif err != nil {\n\t\tt.Fatalf(\"Error reading index body: %v\", err)\n\t}\n\n\tif !strings.Contains(string(body), \"html\") {\n\t\tt.Fatalf(\"Expected HTML from the index.\")\n\t}\n}", "func (h *Handlers) Index(w http.ResponseWriter, r *http.Request, _ map[string]string) {\n\tfile := path.Join(\"index.html\")\n\n\tdata := struct{ Host string }{Host: h.Host}\n\n\ttemp, _ := template.ParseFiles(file)\n\ttemp.Execute(w, &data)\n}", "func (t tApp) Index(w http.ResponseWriter, r *http.Request) {\n\tvar h http.Handler\n\tc := App.newC(w, r, \"App\", \"Index\")\n\tdefer func() {\n\t\t// If one of the actions (Before, After or Index) returned\n\t\t// a handler, apply it.\n\t\tif h != nil {\n\t\t\th.ServeHTTP(w, r)\n\t\t}\n\t}()\n\tdefer App.after(c, w, r) // Call this at the very end, but before applying result.\n\tif res := App.before(c, w, r); res != nil {\n\t\th = res\n\t\treturn\n\t}\n\tif res := c.Index(); res != nil {\n\t\th = res\n\t\treturn\n\t}\n}", "func handleIndex(w http.ResponseWriter, r *http.Request) {\n\n\tif r.URL.Path != \"/\" {\n\t\thttp.NotFound(w, r)\n\t\treturn\n\t}\n\n\tc := appengine.NewContext(r)\n\tlog.Infof(c, \"Serving main page.\")\n\n\ttmpl, _ := template.ParseFiles(\"web/tmpl/index.tmpl\")\n\n\ttmpl.Execute(w, time.Since(initTime))\n}", "func showIndex(c *gin.Context) {\n\trender(\n\t\tc,\n\t\tgin.H{\n\t\t\t\"title\": \"Home Page\",\n\t\t\t\"payload\": films,\n\t\t},\n\t\ttemplates.Index,\n\t)\n}", "func indexHandler(w http.ResponseWriter, req *http.Request) {\n\tlayout, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_LAYOUT)\n\tif err != nil {\n\t\thttp.Error(w, ERROR_TEMPLATE_NOT_FOUND, http.StatusNotFound)\n\t\treturn\n\t}\n\tindex, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_INDEX)\n\t//artical, err := template.ParseFile(PATH_PUBLIC + TEMPLATE_ARTICAL)\n\tif err != nil {\n\t\thttp.Error(w, ERROR_TEMPLATE_NOT_FOUND, http.StatusNotFound)\n\t\treturn\n\t}\n\tmapOutput := map[string]interface{}{\"Title\": \"炫酷的网站技术\" + TITLE, \"Keyword\": KEYWORD, \"Description\": DESCRIPTION, \"Base\": BASE_URL, \"Url\": BASE_URL, \"Carousel\": getAddition(PREFIX_INDEX), \"Script\": getAddition(PREFIX_SCRIPT), \"Items\": leveldb.GetRandomContents(20, &Filter{})}\n\tcontent := []byte(index.RenderInLayout(layout, mapOutput))\n\tw.Write(content)\n\tgo cacheFile(\"index\", content)\n}", "func (app *Application) Index(w http.ResponseWriter, r *http.Request) {\n\tdata := struct {\n\t\tTime int64\n\t}{\n\t\tTime: time.Now().Unix(),\n\t}\n\n\tt, err := template.ParseFiles(\"views/index.tpl\")\n\n\tif err != nil {\n\t\tlog.Println(\"Template.Parse:\", err)\n\t\thttp.Error(w, \"Internal Server Error 0x0178\", http.StatusInternalServerError)\n\t}\n\n\tif err := t.Execute(w, data); err != nil {\n\t\tlog.Println(\"Template.Execute:\", err)\n\t\thttp.Error(w, \"Internal Server Error 0x0183\", http.StatusInternalServerError)\n\t}\n}", "func AdminIndex(c *cli.Context) {\n\tesClient := getESClient(c)\n\tindexName := getRequiredOption(c, FlagIndex)\n\tinputFileName := getRequiredOption(c, FlagInputFile)\n\tbatchSize := c.Int(FlagBatchSize)\n\n\tmessages, err := parseIndexerMessage(inputFileName)\n\tif err != nil {\n\t\tErrorAndExit(\"Unable to parse indexer message\", err)\n\t}\n\n\tbulkRequest := esClient.Bulk()\n\tbulkConductFn := func() {\n\t\t_, err := bulkRequest.Do(context.Background())\n\t\tif err != nil {\n\t\t\tErrorAndExit(\"Bulk failed\", err)\n\t\t}\n\t\tif bulkRequest.NumberOfActions() != 0 {\n\t\t\tErrorAndExit(fmt.Sprintf(\"Bulk request not done, %d\", bulkRequest.NumberOfActions()), err)\n\t\t}\n\t}\n\tfor i, message := range messages {\n\t\tdocID := message.GetWorkflowID() + esDocIDDelimiter + message.GetRunID()\n\t\tvar req elastic.BulkableRequest\n\t\tswitch message.GetMessageType() {\n\t\tcase indexer.MessageTypeIndex:\n\t\t\tdoc := generateESDoc(message)\n\t\t\treq = elastic.NewBulkIndexRequest().\n\t\t\t\tIndex(indexName).\n\t\t\t\tType(esDocType).\n\t\t\t\tId(docID).\n\t\t\t\tVersionType(versionTypeExternal).\n\t\t\t\tVersion(message.GetVersion()).\n\t\t\t\tDoc(doc)\n\t\tcase indexer.MessageTypeDelete:\n\t\t\treq = elastic.NewBulkDeleteRequest().\n\t\t\t\tIndex(indexName).\n\t\t\t\tType(esDocType).\n\t\t\t\tId(docID).\n\t\t\t\tVersionType(versionTypeExternal).\n\t\t\t\tVersion(message.GetVersion())\n\t\tdefault:\n\t\t\tErrorAndExit(\"Unknown message type\", nil)\n\t\t}\n\t\tbulkRequest.Add(req)\n\n\t\tif i%batchSize == batchSize-1 {\n\t\t\tbulkConductFn()\n\t\t}\n\t}\n\tif bulkRequest.NumberOfActions() != 0 {\n\t\tbulkConductFn()\n\t}\n}", "func Indexer() *cobra.Command {\n\tvar Indexer = &cobra.Command{\n\t\tUse: \"indexer\",\n\t\tShort: \"consumes metrics from the bus and makes them searchable\",\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\t// get kafka source\n\t\t\ts, err := kafka.NewSource(&kafka.SourceConfig{\n\t\t\t\tAddrs: strings.Split(viper.GetString(flagKafkaAddrs), \",\"),\n\t\t\t\tClientID: viper.GetString(flagKafkaClientID),\n\t\t\t\tGroupID: viper.GetString(flagKafkaGroupID),\n\t\t\t\tTopics: []string{viper.GetString(flagKafkaTopic)},\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// custom client used so we can more effeciently reuse connections.\n\t\t\tcustomClient := &http.Client{\n\t\t\t\tTransport: &http.Transport{\n\t\t\t\t\tDial: func(network, addr string) (net.Conn, error) {\n\t\t\t\t\t\treturn net.Dial(network, addr)\n\t\t\t\t\t},\n\t\t\t\t\tMaxIdleConnsPerHost: viper.GetInt(\"max-idle-conn\"),\n\t\t\t\t},\n\t\t\t}\n\n\t\t\t// allow sniff to be set because in some networking environments sniffing doesn't work. Should be allowed in prod\n\t\t\tclient, err := elastic.NewClient(\n\t\t\t\telastic.SetURL(viper.GetString(\"es\")),\n\t\t\t\telastic.SetSniff(viper.GetBool(\"es-sniff\")),\n\t\t\t\telastic.SetHttpClient(customClient),\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\t// set up caching es sample indexer\n\t\t\tesIndexer := elasticsearch.NewSampleIndexer(&elasticsearch.SampleIndexerConfig{\n\t\t\t\tClient: client,\n\t\t\t\tIndex: viper.GetString(\"es-index\"),\n\t\t\t})\n\t\t\tsampleIndexer := indexer.NewCachingIndexer(&indexer.CachingIndexerConfig{\n\t\t\t\tIndexer: esIndexer,\n\t\t\t\tMaxDuration: viper.GetDuration(\"es-writecache-duration\"),\n\t\t\t})\n\n\t\t\t// create indexer and run\n\t\t\ti := indexer.NewIndexer(&indexer.Config{\n\t\t\t\tSampleIndexer: sampleIndexer,\n\t\t\t\tSource: s,\n\t\t\t\tNumIndexGoroutines: viper.GetInt(\"indexer-goroutines\"),\n\t\t\t})\n\n\t\t\tprometheus.MustRegister(i)\n\t\t\tprometheus.MustRegister(esIndexer)\n\t\t\tprometheus.MustRegister(sampleIndexer)\n\n\t\t\tgo func() {\n\t\t\t\thttp.Handle(\"/metrics\", prometheus.Handler())\n\t\t\t\thttp.ListenAndServe(\":8080\", nil)\n\t\t\t}()\n\n\t\t\treturn i.Run()\n\t\t},\n\t}\n\n\tIndexer.Flags().String(flagKafkaAddrs, \"\", \"one.example.com:9092,two.example.com:9092\")\n\tIndexer.Flags().String(flagKafkaClientID, \"vulcan-indexer\", \"set the kafka client id\")\n\tIndexer.Flags().String(flagKafkaTopic, \"vulcan\", \"topic to read in kafka\")\n\tIndexer.Flags().String(flagKafkaGroupID, \"vulcan-indexer\", \"workers with the same groupID will join the same Kafka ConsumerGroup\")\n\tIndexer.Flags().String(\"es\", \"http://elasticsearch:9200\", \"elasticsearch connection url\")\n\tIndexer.Flags().Bool(\"es-sniff\", true, \"whether or not to sniff additional hosts in the cluster\")\n\tIndexer.Flags().String(\"es-index\", \"vulcan\", \"the elasticsearch index to write documents into\")\n\tIndexer.Flags().Duration(\"es-writecache-duration\", time.Minute*10, \"the duration to cache having written a value to es and to skip further writes of the same metric\")\n\tIndexer.Flags().Uint(\"indexer-goroutines\", 30, \"worker goroutines for writing indexes\")\n\tIndexer.Flags().Uint(\"max-idle-conn\", 30, \"max idle connections for fetching from data storage\")\n\n\treturn Indexer\n}", "func (i *indexer) Index() (*Stats, error) {\n\tpkgs, err := i.packages()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn i.index(pkgs)\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"Welcome to this example API\\n\")\n}", "func indexHandler(res http.ResponseWriter, req *http.Request) {\n\tfmt.Println(\"website index\")\n\t//grab all partials\n\tpartials, err := loadPartials()\n\tif err != nil {\n\t\thttp.Error(res, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\t//get template function based on index and execute to load page\n\tt, _ := template.ParseFiles(\"../index.html\")\n\tt.Execute(res, partials)\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\t//shows 404 not found\n\tif r.URL.Path != \"/\" {\n\t\tNotFound(w, r)\n\t} else {\n\t\ttemplate, err := template.ParseFiles(\"../htmls/index.html\")\n\t\tif err != nil {\n\t\t\tlogger.ErrLogger(err)\n\t\t} else {\n\t\t\ttemplate.Execute(w, nil)\n\t\t}\n\t}\n}", "func (h *Root) Index(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\tif claims, err := auth.ClaimsFromContext(ctx); err == nil && claims.HasAuth() {\n\t\treturn h.indexDashboard(ctx, w, r, params)\n\t}\n\n\treturn h.indexDefault(ctx, w, r, params)\n}", "func Index(logger *log.Logger, basepath string, done <-chan struct{}, templ *template.Template) http.Handler {\n\ttracker, err := dir.Watch(basepath)\n\tif err != nil {\n\t\tlogger.Printf(\"failed to watch directory [%s] - %v\", basepath, err)\n\t\treturn ResponseCode(500, \"failed to initialize IndexHandler - %v\", err)\n\t}\n\tgo func() {\n\t\t<-done\n\t\ttracker.Close()\n\t}()\n\n\treturn indexHandler{basePath: basepath, templ: templ, l: logger, dir: tracker, done: done}\n}", "func (d *Diagnosis) indexHandler(w http.ResponseWriter, r *http.Request) {\n\tvar profiles []profile\n\tfor _, p := range pprof.Profiles() {\n\t\tprofiles = append(profiles, profile{\n\t\t\tName: p.Name(),\n\t\t\tHref: p.Name() + \"?debug=1\",\n\t\t\tDesc: profileDescriptions[p.Name()],\n\t\t\tCount: p.Count(),\n\t\t})\n\t}\n\n\t// Adding other profiles exposed from within this package\n\tfor _, p := range []string{\"cmdline\", \"profile\", \"trace\"} {\n\t\tprofiles = append(profiles, profile{\n\t\t\tName: p,\n\t\t\tHref: p,\n\t\t\tDesc: profileDescriptions[p],\n\t\t})\n\t}\n\n\tsort.Slice(profiles, func(i, j int) bool {\n\t\treturn profiles[i].Name < profiles[j].Name\n\t})\n\n\tif err := indexTmpl.Execute(w, map[string]interface{}{\n\t\t\"AppName\": d.appName,\n\t\t\"PathPrefix\": d.pathPrefix,\n\t\t\"Profiles\": profiles,\n\t}); err != nil {\n\t\td.log.Error(err)\n\t}\n}", "func (h *MovieHandler) index(w http.ResponseWriter, r *http.Request) {\n\t// Call GetMovies to retrieve all movies from the database.\n\tif movies, err := h.MovieService.GetMovies(); err != nil {\n\t\t// Render an error response and set status code.\n\t\thttp.Error(w, \"Internal Server Error\", http.StatusInternalServerError)\n\t\tlog.Println(\"Error:\", err)\n\t} else {\n\t\t// Render a HTML response and set status code.\n\t\trender.HTML(w, http.StatusOK, \"movie/index.html\", movies)\n\t}\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\tenv.Output.WriteChDebug(\"(ApiEngine::Index)\")\n\thttp.Redirect(w, r, \"/api/node\", http.StatusFound)\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"s-senpai, please don't hurt me ;_;\\n\")\n}", "func handleIndex(w http.ResponseWriter, r *http.Request) {\n\tmsg := fmt.Sprintf(\"You've called url %s\", r.URL.String())\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\tw.WriteHeader(http.StatusOK) // 200\n\tw.Write([]byte(msg))\n}", "func main() {\n\t// Create a client\n\tclient, err := elastic.NewClient(elastic.SetURL(ES_URL), elastic.SetSniff(false))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdeleteIndex, err := client.DeleteIndex(INDEX).Do()\n\tif err != nil {\n\t\t// Handle error\n\t\tpanic(err)\n\t}\n\tif !deleteIndex.Acknowledged {\n\t\t// Not acknowledged\n\t}\n\n}", "func (s *HTTPServer) Index(resp http.ResponseWriter, req *http.Request) {\n\t// Check if this is a non-index path\n\tif req.URL.Path != \"/\" {\n\t\tresp.WriteHeader(http.StatusNotFound)\n\t\treturn\n\t}\n\n\t// Give them something helpful if there's no UI so they at least know\n\t// what this server is.\n\tif !s.IsUIEnabled() {\n\t\tfmt.Fprint(resp, \"Consul Agent\")\n\t\treturn\n\t}\n\n\t// Redirect to the UI endpoint\n\thttp.Redirect(resp, req, \"/ui/\", http.StatusMovedPermanently) // 301\n}", "func (s *server) handleIndex(FSS fs.FS) http.HandlerFunc {\n\ttype AppConfig struct {\n\t\tAvatarService string\n\t\tToastTimeout int\n\t\tAllowGuests bool\n\t\tAllowRegistration bool\n\t\tDefaultLocale string\n\t\tAuthMethod string\n\t\tAppVersion string\n\t\tCookieName string\n\t\tPathPrefix string\n\t\tAPIEnabled bool\n\t\tCleanupGuestsDaysOld int\n\t\tCleanupStoryboardsDaysOld int\n\t\tShowActiveCountries bool\n\t}\n\ttype UIConfig struct {\n\t\tAnalyticsEnabled bool\n\t\tAnalyticsID string\n\t\tAppConfig AppConfig\n\t\tActiveAlerts []interface{}\n\t}\n\n\ttmpl := s.getIndexTemplate(FSS)\n\n\tappConfig := AppConfig{\n\t\tAvatarService: viper.GetString(\"config.avatar_service\"),\n\t\tToastTimeout: viper.GetInt(\"config.toast_timeout\"),\n\t\tAllowGuests: viper.GetBool(\"config.allow_guests\"),\n\t\tAllowRegistration: viper.GetBool(\"config.allow_registration\") && viper.GetString(\"auth.method\") == \"normal\",\n\t\tDefaultLocale: viper.GetString(\"config.default_locale\"),\n\t\tAuthMethod: viper.GetString(\"auth.method\"),\n\t\tAPIEnabled: viper.GetBool(\"config.allow_external_api\"),\n\t\tAppVersion: s.config.Version,\n\t\tCookieName: s.config.FrontendCookieName,\n\t\tPathPrefix: s.config.PathPrefix,\n\t\tCleanupGuestsDaysOld: viper.GetInt(\"config.cleanup_guests_days_old\"),\n\t\tCleanupStoryboardsDaysOld: viper.GetInt(\"config.cleanup_storyboards_days_old\"),\n\t\tShowActiveCountries: viper.GetBool(\"config.show_active_countries\"),\n\t}\n\n\tActiveAlerts = s.database.GetActiveAlerts()\n\n\tdata := UIConfig{\n\t\tAnalyticsEnabled: s.config.AnalyticsEnabled,\n\t\tAnalyticsID: s.config.AnalyticsID,\n\t\tAppConfig: appConfig,\n\t}\n\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tdata.ActiveAlerts = ActiveAlerts // get latest alerts from memory\n\n\t\tif embedUseOS {\n\t\t\ttmpl = s.getIndexTemplate(FSS)\n\t\t}\n\n\t\ttmpl.Execute(w, data)\n\t}\n}", "func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"Whoa, Nice!\")\n}", "func index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tasset, err := Asset(\"static/templates/index.html\")\n\tif err != nil {\n\t\tlog.Panic(\"Unable to read file from bindata: \", err)\n\t}\n\tfmt.Fprint(w, string(asset))\n}", "func index(c echo.Context) error {\n\tpprof.Index(c.Response().Writer, c.Request())\n\treturn nil\n}", "func GetIndex(c *gin.Context) {\n\tc.String(http.StatusOK, \"Hello world !!\")\n}", "func index(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {\n\tvar returnResponse = map[string]interface{}{\"message\": \"Welcome to the TonicPow API!\"}\n\tapirouter.ReturnResponse(w, req, http.StatusOK, returnResponse)\n}", "func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"indexHandler is called\")\n\n\tw.WriteHeader(http.StatusOK)\n}", "func indexHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"indexHandler is called\")\n\n\tw.WriteHeader(http.StatusOK)\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\tw.WriteHeader(http.StatusOK)\n\tw.Write([]byte(\"Hello World!\"))\n}", "func (v1 *V1Client) Index() error {\n\tresp := v1.POST(nil, \"/api/v1/index\")\n\treturn resp.Error\n}", "func indexhandler(w http.ResponseWriter, r *http.Request) {\n\tt, _ := template.ParseFiles(os.Getenv(\"GOPATH\")+\"/lib/flickrquizz/index.html\")\n\tt.ExecuteTemplate(w, \"Seed\", rand.Int())\n}", "func ShowIndex(ctx context.Context, db QueryExecutor, schemaName string, table string) ([]*IndexInfo, error) {\n\t/*\n\t\tshow index example result:\n\t\tmysql> show index from test;\n\t\t+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+\n\t\t| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |\n\t\t+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+\n\t\t| test | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | |\n\t\t| test | 0 | aid | 1 | aid | A | 0 | NULL | NULL | YES | BTREE | | |\n\t\t+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+\n\t*/\n\tindices := make([]*IndexInfo, 0, 3)\n\tquery := fmt.Sprintf(\"SHOW INDEX FROM %s\", TableName(schemaName, table))\n\trows, err := db.QueryContext(ctx, query)\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\tdefer rows.Close()\n\n\tfor rows.Next() {\n\t\tfields, err1 := ScanRow(rows)\n\t\tif err1 != nil {\n\t\t\treturn nil, errors.Trace(err1)\n\t\t}\n\t\tseqInIndex, err1 := strconv.Atoi(string(fields[\"Seq_in_index\"].Data))\n\t\tif err1 != nil {\n\t\t\treturn nil, errors.Trace(err1)\n\t\t}\n\t\tcardinality, err1 := strconv.Atoi(string(fields[\"Cardinality\"].Data))\n\t\tif err1 != nil {\n\t\t\treturn nil, errors.Trace(err1)\n\t\t}\n\t\tindex := &IndexInfo{\n\t\t\tTable: string(fields[\"Table\"].Data),\n\t\t\tNoneUnique: string(fields[\"Non_unique\"].Data) == \"1\",\n\t\t\tKeyName: string(fields[\"Key_name\"].Data),\n\t\t\tColumnName: string(fields[\"Column_name\"].Data),\n\t\t\tSeqInIndex: seqInIndex,\n\t\t\tCardinality: cardinality,\n\t\t}\n\t\tindices = append(indices, index)\n\t}\n\n\treturn indices, nil\n}", "func serveIndex(w http.ResponseWriter, r *http.Request, bs buildSpec, br *buildResult) {\n\txreq := request{bs, \"\", pageIndex}\n\txlink := xreq.link()\n\n\ttype versionLink struct {\n\t\tVersion string\n\t\tURLPath string\n\t\tSuccess bool\n\t\tActive bool\n\t}\n\ttype response struct {\n\t\tErr error\n\t\tLatestVersion string\n\t\tVersionLinks []versionLink\n\t}\n\n\t// Do a lookup to the goproxy in the background, to list the module versions.\n\tc := make(chan response, 1)\n\tgo func() {\n\t\tt0 := time.Now()\n\t\tdefer func() {\n\t\t\tmetricGoproxyListDuration.Observe(time.Since(t0).Seconds())\n\t\t}()\n\n\t\tmodPath, err := module.EscapePath(bs.Mod)\n\t\tif err != nil {\n\t\t\tc <- response{fmt.Errorf(\"bad module path: %v\", err), \"\", nil}\n\t\t\treturn\n\t\t}\n\t\tu := fmt.Sprintf(\"%s%s/@v/list\", config.GoProxy, modPath)\n\t\tmreq, err := http.NewRequestWithContext(r.Context(), \"GET\", u, nil)\n\t\tif err != nil {\n\t\t\tc <- response{fmt.Errorf(\"%w: preparing new http request: %v\", errServer, err), \"\", nil}\n\t\t\treturn\n\t\t}\n\t\tmreq.Header.Set(\"User-Agent\", userAgent)\n\t\tresp, err := http.DefaultClient.Do(mreq)\n\t\tif err != nil {\n\t\t\tc <- response{fmt.Errorf(\"%w: http request: %v\", errServer, err), \"\", nil}\n\t\t\treturn\n\t\t}\n\t\tdefer resp.Body.Close()\n\t\tif resp.StatusCode != 200 {\n\t\t\tmetricGoproxyListErrors.WithLabelValues(fmt.Sprintf(\"%d\", resp.StatusCode)).Inc()\n\t\t\tc <- response{fmt.Errorf(\"%w: http response from goproxy: %v\", errRemote, resp.Status), \"\", nil}\n\t\t\treturn\n\t\t}\n\t\tbuf, err := io.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tc <- response{fmt.Errorf(\"%w: reading versions from goproxy: %v\", errRemote, err), \"\", nil}\n\t\t\treturn\n\t\t}\n\t\tl := []versionLink{}\n\t\tfor _, s := range strings.Split(string(buf), \"\\n\") {\n\t\t\tif s != \"\" {\n\t\t\t\tvbs := bs\n\t\t\t\tvbs.Version = s\n\t\t\t\tsuccess := fileExists(filepath.Join(vbs.storeDir(), \"recordnumber\"))\n\t\t\t\tp := request{vbs, \"\", pageIndex}.link()\n\t\t\t\tlink := versionLink{s, p, success, p == xlink}\n\t\t\t\tl = append(l, link)\n\t\t\t}\n\t\t}\n\t\tsort.Slice(l, func(i, j int) bool {\n\t\t\treturn semver.Compare(l[i].Version, l[j].Version) > 0\n\t\t})\n\t\tvar latestVersion string\n\t\tif len(l) > 0 {\n\t\t\tlatestVersion = l[0].Version\n\t\t}\n\t\tc <- response{nil, latestVersion, l}\n\t}()\n\n\t// Non-emptiness means we'll serve the error page instead of doing a SSE request for events.\n\tvar output string\n\tif br == nil {\n\t\tif buf, err := readGzipFile(filepath.Join(bs.storeDir(), \"log.gz\")); err != nil {\n\t\t\tif !os.IsNotExist(err) {\n\t\t\t\tfailf(w, \"%w: reading log.gz: %v\", errServer, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// For not-exist, we'll continue below to build.\n\t\t} else {\n\t\t\toutput = string(buf)\n\t\t}\n\t}\n\n\t// Construct links to other goversions, targets.\n\ttype goversionLink struct {\n\t\tGoversion string\n\t\tURLPath string\n\t\tSuccess bool\n\t\tSupported bool\n\t\tActive bool\n\t}\n\tgoversionLinks := []goversionLink{}\n\tnewestAllowed, supported, remaining := installedSDK()\n\tfor _, goversion := range supported {\n\t\tgvbs := bs\n\t\tgvbs.Goversion = goversion\n\t\tsuccess := fileExists(filepath.Join(gvbs.storeDir(), \"recordnumber\"))\n\t\tp := request{gvbs, \"\", pageIndex}.link()\n\t\tgoversionLinks = append(goversionLinks, goversionLink{goversion, p, success, true, p == xlink})\n\t}\n\tfor _, goversion := range remaining {\n\t\tgvbs := bs\n\t\tgvbs.Goversion = goversion\n\t\tsuccess := fileExists(filepath.Join(gvbs.storeDir(), \"recordnumber\"))\n\t\tp := request{gvbs, \"\", pageIndex}.link()\n\t\tgoversionLinks = append(goversionLinks, goversionLink{goversion, p, success, false, p == xlink})\n\t}\n\n\ttype targetLink struct {\n\t\tGoos string\n\t\tGoarch string\n\t\tURLPath string\n\t\tSuccess bool\n\t\tActive bool\n\t}\n\ttargetLinks := []targetLink{}\n\tfor _, target := range targets.get() {\n\t\ttbs := bs\n\t\ttbs.Goos = target.Goos\n\t\ttbs.Goarch = target.Goarch\n\t\tsuccess := fileExists(filepath.Join(tbs.storeDir(), \"recordnumber\"))\n\t\tp := request{tbs, \"\", pageIndex}.link()\n\t\ttargetLinks = append(targetLinks, targetLink{target.Goos, target.Goarch, p, success, p == xlink})\n\t}\n\n\ttype variantLink struct {\n\t\tVariant string // \"default\" or \"stripped\"\n\t\tTitle string // Displayed on hover in UI.\n\t\tURLPath string\n\t\tSuccess bool\n\t\tActive bool\n\t}\n\tvar variantLinks []variantLink\n\taddVariant := func(v, title string, stripped bool) {\n\t\tvbs := bs\n\t\tvbs.Stripped = stripped\n\t\tsuccess := fileExists(filepath.Join(vbs.storeDir(), \"recordnumber\"))\n\t\tp := request{vbs, \"\", pageIndex}.link()\n\t\tvariantLinks = append(variantLinks, variantLink{v, title, p, success, p == xlink})\n\t}\n\taddVariant(\"default\", \"\", false)\n\taddVariant(\"stripped\", \"Symbol table and debug information stripped, reducing binary size.\", true)\n\n\tpkgGoDevURL := \"https://pkg.go.dev/\" + path.Join(bs.Mod+\"@\"+bs.Version, bs.Dir[1:]) + \"?tab=doc\"\n\n\tresp := <-c\n\n\tvar filesizeGz string\n\tif br == nil {\n\t\tbr = &buildResult{buildSpec: bs}\n\t} else {\n\t\tif info, err := os.Stat(filepath.Join(bs.storeDir(), \"binary.gz\")); err == nil {\n\t\t\tfilesizeGz = fmt.Sprintf(\"%.1f MB\", float64(info.Size())/(1024*1024))\n\t\t}\n\t}\n\n\tprependDir := xreq.Dir\n\tif prependDir == \"/\" {\n\t\tprependDir = \"\"\n\t}\n\n\tvar newerText, newerURL string\n\tif xreq.Goversion != newestAllowed && newestAllowed != \"\" && xreq.Version != resp.LatestVersion && resp.LatestVersion != \"\" {\n\t\tnewerText = \"A newer version of both this module and the Go toolchain is available\"\n\t} else if xreq.Version != resp.LatestVersion && resp.LatestVersion != \"\" {\n\t\tnewerText = \"A newer version of this module is available\"\n\t} else if xreq.Goversion != newestAllowed && newestAllowed != \"\" {\n\t\tnewerText = \"A newer Go toolchain version is available\"\n\t}\n\tif newerText != \"\" {\n\t\tnbs := bs\n\t\tnbs.Version = resp.LatestVersion\n\t\tnbs.Goversion = newestAllowed\n\t\tnewerURL = request{nbs, \"\", pageIndex}.link()\n\t}\n\n\tfavicon := \"/favicon.ico\"\n\tif output != \"\" {\n\t\tfavicon = \"/favicon-error.png\"\n\t} else if br.Sum == \"\" {\n\t\tfavicon = \"/favicon-building.png\"\n\t}\n\targs := map[string]interface{}{\n\t\t\"Favicon\": favicon,\n\t\t\"Success\": br.Sum != \"\",\n\t\t\"Sum\": br.Sum,\n\t\t\"Req\": xreq, // eg \"/\" or \"/cmd/x\"\n\t\t\"DirAppend\": xreq.appendDir(), // eg \"\" or \"cmd/x/\"\n\t\t\"DirPrepend\": prependDir, // eg \"\" or /cmd/x\"\n\t\t\"GoversionLinks\": goversionLinks,\n\t\t\"TargetLinks\": targetLinks,\n\t\t\"VariantLinks\": variantLinks,\n\t\t\"Mod\": resp,\n\t\t\"GoProxy\": config.GoProxy,\n\t\t\"DownloadFilename\": xreq.downloadFilename(),\n\t\t\"PkgGoDevURL\": pkgGoDevURL,\n\t\t\"GobuildVersion\": gobuildVersion,\n\t\t\"GobuildPlatform\": gobuildPlatform,\n\t\t\"VerifierKey\": config.VerifierKey,\n\t\t\"GobuildsOrgVerifierKey\": gobuildsOrgVerifierKey,\n\t\t\"NewerText\": newerText,\n\t\t\"NewerURL\": newerURL,\n\n\t\t// Whether we will do SSE request for updates.\n\t\t\"InProgress\": br.Sum == \"\" && output == \"\",\n\n\t\t// Non-empty on failure.\n\t\t\"Output\": output,\n\n\t\t// Below only meaningful when \"success\".\n\t\t\"Filesize\": fmt.Sprintf(\"%.1f MB\", float64(br.Filesize)/(1024*1024)),\n\t\t\"FilesizeGz\": filesizeGz,\n\t}\n\n\tif br.Sum == \"\" {\n\t\tw.Header().Set(\"Cache-Control\", \"no-store\")\n\t}\n\n\tif err := buildTemplate.Execute(w, args); err != nil {\n\t\tfailf(w, \"%w: executing template: %v\", errServer, err)\n\t}\n}", "func (app *App) RenderIndex(w http.ResponseWriter, r *http.Request) {\n\ttmplList := []string{\"./web/views/base.html\",\n\t\t\"./web/views/index.html\"}\n\tres, err := app.TplParser.ParseTemplate(tmplList, nil)\n\tif err != nil {\n\t\tapp.Log.Info(err)\n\t}\n\tio.WriteString(w, res)\n}", "func TestIndex(t *testing.T) {\n\tdefer os.RemoveAll(\"testidx\")\n\n\tindex, err := New(\"testidx\", mapping)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer index.Close()\n\n\t// index all the people\n\tfor _, person := range people {\n\t\terr = index.Index(person.Identifier, person)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t}\n\n\ttermQuery := NewTermQuery(\"marti\").SetField(\"name\")\n\tsearchRequest := NewSearchRequest(termQuery)\n\tsearchResult, err := index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for term query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"a\" {\n\t\t\tt.Errorf(\"expected top hit id 'a', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"noone\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(0) {\n\t\tt.Errorf(\"expected 0 total hits\")\n\t}\n\n\tmatchPhraseQuery := NewMatchPhraseQuery(\"long name\")\n\tsearchRequest = NewSearchRequest(matchPhraseQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for phrase query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"b\" {\n\t\t\tt.Errorf(\"expected top hit id 'b', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"walking\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(0) {\n\t\tt.Errorf(\"expected 0 total hits\")\n\t}\n\n\tmatchQuery := NewMatchQuery(\"walking\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(matchQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for match query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"c\" {\n\t\t\tt.Errorf(\"expected top hit id 'c', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\tprefixQuery := NewPrefixQuery(\"bobble\").SetField(\"name\")\n\tsearchRequest = NewSearchRequest(prefixQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for prefix query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"d\" {\n\t\t\tt.Errorf(\"expected top hit id 'd', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\tsyntaxQuery := NewSyntaxQuery(\"+name:phone\")\n\tsearchRequest = NewSearchRequest(syntaxQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for syntax query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"d\" {\n\t\t\tt.Errorf(\"expected top hit id 'd', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\tmaxAge := 30.0\n\tnumericRangeQuery := NewNumericRangeQuery(nil, &maxAge).SetField(\"age\")\n\tsearchRequest = NewSearchRequest(numericRangeQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(2) {\n\t\tt.Errorf(\"expected 2 total hits for numeric range query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"b\" {\n\t\t\tt.Errorf(\"expected top hit id 'b', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t\tif searchResult.Hits[1].ID != \"a\" {\n\t\t\tt.Errorf(\"expected next hit id 'a', got '%s'\", searchResult.Hits[1].ID)\n\t\t}\n\t}\n\n\tstartDate = \"2010-01-01\"\n\tdateRangeQuery := NewDateRangeQuery(&startDate, nil).SetField(\"birthday\")\n\tsearchRequest = NewSearchRequest(dateRangeQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(2) {\n\t\tt.Errorf(\"expected 2 total hits for numeric range query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"d\" {\n\t\t\tt.Errorf(\"expected top hit id 'd', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t\tif searchResult.Hits[1].ID != \"c\" {\n\t\t\tt.Errorf(\"expected next hit id 'c', got '%s'\", searchResult.Hits[1].ID)\n\t\t}\n\t}\n\n\t// test that 0 time doesn't get indexed\n\tendDate = \"2010-01-01\"\n\tdateRangeQuery = NewDateRangeQuery(nil, &endDate).SetField(\"birthday\")\n\tsearchRequest = NewSearchRequest(dateRangeQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(1) {\n\t\tt.Errorf(\"expected 1 total hit for numeric range query, got %d\", searchResult.Total)\n\t} else {\n\t\tif searchResult.Hits[0].ID != \"b\" {\n\t\t\tt.Errorf(\"expected top hit id 'b', got '%s'\", searchResult.Hits[0].ID)\n\t\t}\n\t}\n\n\t// test behavior of arrays\n\t// make sure we can successfully find by all elements in array\n\ttermQuery = NewTermQuery(\"gopher\").SetField(\"tags\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\tif searchResult.Total != uint64(1) {\n\t\t\tt.Errorf(\"expected 1 total hit for term query, got %d\", searchResult.Total)\n\t\t} else {\n\t\t\tif searchResult.Hits[0].ID != \"a\" {\n\t\t\t\tt.Errorf(\"expected top hit id 'a', got '%s'\", searchResult.Hits[0].ID)\n\t\t\t}\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"belieber\").SetField(\"tags\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\tif searchResult.Total != uint64(1) {\n\t\t\tt.Errorf(\"expected 1 total hit for term query, got %d\", searchResult.Total)\n\t\t} else {\n\t\t\tif searchResult.Hits[0].ID != \"a\" {\n\t\t\t\tt.Errorf(\"expected top hit id 'a', got '%s'\", searchResult.Hits[0].ID)\n\t\t\t}\n\t\t}\n\t}\n\n\ttermQuery = NewTermQuery(\"notintagsarray\").SetField(\"tags\")\n\tsearchRequest = NewSearchRequest(termQuery)\n\tsearchResult, err = index.Search(searchRequest)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif searchResult.Total != uint64(0) {\n\t\tt.Errorf(\"expected 0 total hits\")\n\t}\n\n\t// lookup document a\n\t// expect to find 2 values for field \"tags\"\n\ttagsCount := 0\n\tdoc, err := index.Document(\"a\")\n\tif err != nil {\n\t\tt.Error(err)\n\t} else {\n\t\tfor _, f := range doc.Fields {\n\t\t\tif f.Name() == \"tags\" {\n\t\t\t\ttagsCount++\n\t\t\t}\n\t\t}\n\t}\n\tif tagsCount != 2 {\n\t\tt.Errorf(\"expected to find 2 values for tags\")\n\t}\n}", "func (c App) Index() revel.Result {\n\tusername, _ := c.Session.Get(\"user\")\n\tfulluser, _ := c.Session.Get(\"fulluser\")\n\treturn c.Render(username, fulluser)\n}", "func (_Casper *CasperCaller) Index(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _Casper.contract.Call(opts, out, \"index\")\n\treturn *ret0, err\n}", "func TestBuildIndex(t *testing.T) {\n\tbuildIndexFromSite(testHugoPath, testIndexPath)\n\tindex := openIndex(t, testIndexPath)\n\tdefer index.Close()\n\tqueryIndex(t, index)\n}", "func IndexHandeler(w http.ResponseWriter, r *http.Request) {\n\trespond.OK(w, map[string]interface{}{\n\t\t\"name\": \"hotstar-schedular\",\n\t\t\"version\": 1,\n\t})\n}", "func (cmd *Command) Run(args ...string) error {\n\tfs := flag.NewFlagSet(\"buildtsi\", flag.ExitOnError)\n\tdataDir := fs.String(\"datadir\", \"\", \"data directory\")\n\twalDir := fs.String(\"waldir\", \"\", \"WAL directory\")\n\tfs.IntVar(&cmd.concurrency, \"concurrency\", runtime.GOMAXPROCS(0), \"Number of workers to dedicate to shard index building. Defaults to GOMAXPROCS\")\n\tfs.StringVar(&cmd.databaseFilter, \"database\", \"\", \"optional: database name\")\n\tfs.StringVar(&cmd.retentionFilter, \"retention\", \"\", \"optional: retention policy\")\n\tfs.StringVar(&cmd.shardFilter, \"shard\", \"\", \"optional: shard id\")\n\tfs.Int64Var(&cmd.maxLogFileSize, \"max-log-file-size\", tsdb.DefaultMaxIndexLogFileSize, \"optional: maximum log file size\")\n\tfs.Uint64Var(&cmd.maxCacheSize, \"max-cache-size\", tsdb.DefaultCacheMaxMemorySize, \"optional: maximum cache size\")\n\tfs.IntVar(&cmd.batchSize, \"batch-size\", defaultBatchSize, \"optional: set the size of the batches we write to the index. Setting this can have adverse affects on performance and heap requirements\")\n\tfs.BoolVar(&cmd.Verbose, \"v\", false, \"verbose\")\n\tfs.SetOutput(cmd.Stdout)\n\tif err := fs.Parse(args); err != nil {\n\t\treturn err\n\t} else if fs.NArg() > 0 || *dataDir == \"\" || *walDir == \"\" {\n\t\tfs.Usage()\n\t\treturn nil\n\t}\n\tcmd.Logger = logger.New(cmd.Stderr)\n\n\treturn cmd.run(*dataDir, *walDir)\n}", "func (c *Monitor) ProfIndex(command string) revel.Result {\n var profs []string\n\n if command != \"\" {\n buf := bytes.NewBuffer([]byte{})\n\n toolbox.ProcessInput(command, buf)\n\n prof := buf.String()\n profs = strings.Split(prof, \"\\n\")\n }\n\n return c.Render(command, profs)\n}", "func indexHandler(w http.ResponseWriter, r *http.Request, s *Server) {\n\tif r.Method == \"GET\" {\n\t\t//create the source upload page with available languages and metrics\n\t\tpage := &Page{Config: s.Config, Extensions: s.Analyzer.Extensions(), Metrics: s.Analyzer.Metrics, Languages: s.Analyzer.Languages}\n\n\t\t//display the source upload page\n\t\ts.Template.ExecuteTemplate(w, \"index.html\", page)\n\t}\n}", "func index() string {\n\tvar buffer bytes.Buffer\n\tvar id = 0\n\tvar class = 0\n\tbuffer.WriteString(indexTemplate)\n\tlock.Lock()\n\tfor folderName, folder := range folders {\n\t\tbuffer.WriteString(fmt.Sprintf(\"<h2>%s</h2>\", folderName))\n\t\tfor _, source := range folder {\n\t\t\tif !anyNonRead(source) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tsort.Sort(source)\n\t\t\tbuffer.WriteString(fmt.Sprintf(\"<h3>%s</h3>\", source.Title))\n\t\t\tbuffer.WriteString(fmt.Sprintf(`<button onClick=\"hideAll('source_%d'); return false\">Mark all as read</button>`, class))\n\t\t\tbuffer.WriteString(\"<ul>\")\n\n\t\t\tfor _, entry := range source.Entries {\n\t\t\t\tif entry.Read {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tbuffer.WriteString(fmt.Sprintf(`<li id=\"entry_%d\">`, id))\n\t\t\t\tbuffer.WriteString(fmt.Sprintf(`<button class=\"source_%d\" onClick=\"hide('entry_%d', '%s'); return false\">Mark Read</button> `, class, id, entry.Url))\n\t\t\t\tbuffer.WriteString(fmt.Sprintf(`<a href=\"%s\">%s</a>`, entry.Url, entry.Title))\n\t\t\t\tbuffer.WriteString(\"</li>\")\n\t\t\t\tid += 1\n\t\t\t}\n\t\t\tbuffer.WriteString(\"</ul>\")\n\t\t\tclass += 1\n\t\t}\n\t}\n\tlock.Unlock()\n\tbuffer.WriteString(\"</body></html>\")\n\treturn buffer.String()\n}", "func Index(c *gin.Context) {\n\n\tw := c.Writer\n\tr := c.Request\n\tw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n\tp, lastMod, err := tools.ReadFileIfModified(time.Time{})\n\tif err != nil {\n\t\tp = []byte(err.Error())\n\t\tlastMod = time.Unix(0, 0)\n\t}\n\tvar v = struct {\n\t\tHost string\n\t\tData string\n\t\tLastMod string\n\t}{\n\t\tr.Host,\n\t\tstring(p),\n\t\tstrconv.FormatInt(lastMod.UnixNano(), 16),\n\t}\n\tindexTempl.Execute(w, &v)\n}", "func (s *BaseCymbolListener) ExitIndex(ctx *IndexContext) {}", "func (c *FromCommand) Index() int {\n\treturn c.cmd.index\n}", "func (ms *MusicServer) Index(response http.ResponseWriter, request *http.Request) {\n\t// Always check addressMask. If no define, mask is 0.0.0.0 and nothing is accepted (except localhost)\n\tif !ms.checkRequester(request) {\n\t\treturn\n\t}\n\tif ms.musicFolder != \"\" {\n\t\ttextIndexer := music.IndexArtists(ms.folder)\n\t\tms.indexManager.UpdateIndexer(textIndexer)\n\t}\n}", "func (h *Root) indexDefault(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\treturn h.Renderer.Render(ctx, w, r, tmplLayoutSite, \"site-index.gohtml\", web.MIMETextHTMLCharsetUTF8, http.StatusOK, nil)\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hola, este es el inicio\")\n}", "func BuildIndex(dir string){\n\tconfig := Config()\n\tbuilder := makeIndexBuilder(config)\n\tbuilder.Build(\"/\")\n\tsort.Strings(documents)\n\tsave(documents, config)\n}", "func Index(c echo.Context) error {\n\treturn c.Render(http.StatusOK, \"index\", echo.Map{})\n}", "func index(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprint(w, \"Welcome!\\n\")\n}", "func (api *MediaApi) index(c *routing.Context) error {\n\t// --- fetch search data\n\tsearchFields := []string{\"title\", \"type\", \"path\", \"created\", \"modified\"}\n\tsearchData := utils.GetSearchConditions(c, searchFields)\n\t// ---\n\n\t// --- fetch sort data\n\tsortFields := []string{\"title\", \"type\", \"path\", \"created\", \"modified\"}\n\tsortData := utils.GetSortFields(c, sortFields)\n\t// ---\n\n\ttotal, _ := api.dao.Count(searchData)\n\n\tlimit, page := utils.GetPaginationSettings(c, total)\n\n\tutils.SetPaginationHeaders(c, limit, total, page)\n\n\titems := []models.Media{}\n\n\tif total > 0 {\n\t\titems, _ = api.dao.GetList(limit, limit*(page-1), searchData, sortData)\n\n\t\titems = daos.ToAbsMediaPaths(items)\n\t}\n\n\treturn c.Write(items)\n}", "func (h *HTTPApi) listIndex(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tcollections := h.storageNode.Datasources[ps.ByName(\"datasource\")].GetMeta().Databases[ps.ByName(\"dbname\")].ShardInstances[ps.ByName(\"shardinstance\")].Collections[ps.ByName(\"collectionname\")]\n\n\t// Now we need to return the results\n\tif bytes, err := json.Marshal(collections.Indexes); err != nil {\n\t\t// TODO: log this better?\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t} else {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write(bytes)\n\t}\n}", "func httpServeIndex(w http.ResponseWriter, r *http.Request) {\n\tbox := rice.MustFindBox(\"public\")\n\thtml := box.MustString(\"index.html\")\n\tcss := box.MustString(\"dist/styles.css\")\n\tt := template.New(\"index\")\n\tt, _ = t.Parse(html)\n\tt.Execute(w, &HTMLContent{CSS: template.CSS(css)})\n}", "func (prc *PipelineRunsController) Index(c *gin.Context, size, page, offset int) {\n\tjobSpec := job.Job{}\n\terr := jobSpec.SetID(c.Param(\"ID\"))\n\tif err != nil {\n\t\tjsonAPIError(c, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\n\tpipelineRuns, count, err := prc.App.GetJobORM().PipelineRunsByJobID(jobSpec.ID, offset, size)\n\tif err != nil {\n\t\tjsonAPIError(c, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tpaginatedResponse(c, \"offChainReportingPipelineRun\", size, page, pipelineRuns, count, err)\n}", "func GetIndex(w http.ResponseWriter, req *http.Request, app *App) {\n\tscheme := \"http\"\n\tif req.TLS != nil {\n\t\tscheme = \"https\"\n\t}\n\tbase := []string{scheme, \"://\", req.Host, app.Config.General.Prefix}\n\trender(w, \"index\", map[string]interface{}{\"base\": strings.Join(base, \"\"), \"hideNav\": true}, app)\n}" ]
[ "0.72352827", "0.7231066", "0.6974629", "0.6947217", "0.6895008", "0.68026304", "0.66526365", "0.65366894", "0.65255636", "0.6510996", "0.6510996", "0.64903265", "0.6484665", "0.648378", "0.64530957", "0.64055777", "0.6405252", "0.6393524", "0.63744456", "0.63676375", "0.6320205", "0.63021904", "0.62569594", "0.6253341", "0.6244095", "0.62348586", "0.62348586", "0.62327546", "0.62201214", "0.6211135", "0.61948234", "0.6189748", "0.6171233", "0.6165229", "0.61625713", "0.616139", "0.61490697", "0.6129594", "0.61176336", "0.6107657", "0.60832256", "0.6074175", "0.6068898", "0.60542756", "0.60502326", "0.6048729", "0.6035932", "0.60322875", "0.60163194", "0.599126", "0.59909475", "0.59896123", "0.5961652", "0.59614617", "0.595707", "0.5956077", "0.5941416", "0.59408545", "0.5939566", "0.59368587", "0.59363294", "0.59136575", "0.5908333", "0.5907802", "0.59019977", "0.5901875", "0.5879725", "0.58652276", "0.58628803", "0.58622664", "0.58622664", "0.58589417", "0.58528316", "0.585175", "0.58508724", "0.5848384", "0.58472973", "0.5842007", "0.5835645", "0.5830665", "0.5827591", "0.5826751", "0.5822455", "0.5818282", "0.58047616", "0.5804595", "0.57889897", "0.57863265", "0.5783793", "0.5779801", "0.5777006", "0.5776255", "0.5774326", "0.5773833", "0.5766765", "0.5761253", "0.57577443", "0.5747304", "0.5745089", "0.5742563" ]
0.7970374
0
indexParamCheck is a function to check user supplied parameters
func indexParamCheck() error { // check the supplied directory is accessible etc. log.Printf("\tdirectory containing MSA files: %v", *msaDir) misc.ErrorCheck(misc.CheckDir(*msaDir)) // check there are some files with the msa extension msas, err := filepath.Glob(*msaDir + "/cluster*.msa") if err != nil { return fmt.Errorf("no MSA files in the supplied directory (must be named cluster-DD.msa)") } for _, msa := range msas { // check accessibility misc.ErrorCheck(misc.CheckFile(msa)) // add to the pile msaList = append(msaList, msa) } if len(msas) == 0 { return fmt.Errorf("no MSA files found that passed the file checks (make sure filenames follow 'cluster-DD.msa' convention)") } log.Printf("\tnumber of MSA files: %d", len(msas)) // TODO: check the supplied arguments to make sure they don't conflict with each other eg: if *kmerSize > *windowSize { return fmt.Errorf("supplied k-mer size greater than read length") } // setup the indexDir if _, err := os.Stat(*indexDir); os.IsNotExist(err) { if err := os.MkdirAll(*indexDir, 0700); err != nil { return fmt.Errorf("can't create specified output directory") } } // set number of processors to use if *proc <= 0 || *proc > runtime.NumCPU() { *proc = runtime.NumCPU() } runtime.GOMAXPROCS(*proc) return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (af *filtBase) checkIntParam(p, low, high int, name string) (int, error) {\n\tif low <= p && p <= high {\n\t\treturn p, nil\n\t} else {\n\t\terr := fmt.Errorf(\"parameter %v is not in range <%v, %v>\", name, low, high)\n\t\treturn 0, err\n\t}\n}", "func CheckArgs(argsLength, argIndex int) error {\n\tif argsLength == (argIndex + 1) {\n\t\treturn errors.New(\"Not specified key value.\")\n\t}\n\treturn nil\n}", "func checkSetParameter(param interface{}) bool {\n\tswitch param.(type) {\n\tcase string:\n\t\tif param.(string) == \"\" {\n\t\t\treturn false\n\t\t}\n\tcase int:\n\t\tif param.(int) == 0 {\n\t\t\treturn false\n\t\t}\n\tcase uint:\n\t\tif param.(uint) == 0 {\n\t\t\treturn false\n\t\t}\n\tcase float64:\n\t\tif param.(float64) == 0 {\n\t\t\treturn false\n\t\t}\n\tcase []Namespace:\n\t\tif param.([]Namespace) == nil {\n\t\t\treturn false\n\t\t}\n\tdefault:\n\t\treturn false\n\t}\n\treturn true\n}", "func (d *Driver) checkIdx(i int) error {\n\tif i <= 0 || i > d.Drivers {\n\t\treturn fmt.Errorf(\"max72xx: bad index, %d\", i)\n\t}\n\treturn nil\n}", "func (o *GetFetchParams) validateIndex(formats strfmt.Registry) error {\n\n\tif err := validate.MinimumInt(\"index\", \"query\", int64(*o.Index), 1, false); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func checkParameter(parms [3]string, r *http.Request) (map[string]string, error){\n\tresult := make(map[string]string)\n\tfmt.Printf(\"==> \")\n for i := 0; i < len(parms); i++ {\n value, ok := r.URL.Query()[parms[i]]\n if !ok || len(value) < 1 {\n\n\t\t\treturn result, errors.New(fmt.Sprintf(\"==> Error %s not filled\", parms[i]))\n }\n fmt.Printf(\"%s=%s \", parms[i], value[0])\n result[parms[i]] = value[0]\n }\n\tfmt.Printf(\"\\n\")\n return result, nil\n\n}", "func checkIndexInfo(indexName string, indexPartSpecifications []*ast.IndexPartSpecification) error {\n\tif strings.EqualFold(indexName, mysql.PrimaryKeyName) {\n\t\treturn dbterror.ErrWrongNameForIndex.GenWithStackByArgs(indexName)\n\t}\n\tif len(indexPartSpecifications) > mysql.MaxKeyParts {\n\t\treturn infoschema.ErrTooManyKeyParts.GenWithStackByArgs(mysql.MaxKeyParts)\n\t}\n\tfor _, idxSpec := range indexPartSpecifications {\n\t\t// -1 => unspecified/full, > 0 OK, 0 => error\n\t\tif idxSpec.Expr == nil && idxSpec.Length == 0 {\n\t\t\treturn ErrKeyPart0.GenWithStackByArgs(idxSpec.Column.Name.O)\n\t\t}\n\t}\n\treturn checkDuplicateColumnName(indexPartSpecifications)\n}", "func alignParamCheck() error {\n\t// check the supplied FASTQ file(s)\n\tif len(*fastq) == 0 {\n\t\tstat, err := os.Stdin.Stat()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error with STDIN\")\n\t\t}\n\t\tif (stat.Mode() & os.ModeNamedPipe) == 0 {\n\t\t\treturn fmt.Errorf(\"no STDIN found\")\n\t\t}\n\t\tlog.Printf(\"\\tinput file: using STDIN\")\n\t} else {\n\t\tfor _, fastqFile := range *fastq {\n\t\t\tif _, err := os.Stat(fastqFile); err != nil {\n\t\t\t\tif os.IsNotExist(err) {\n\t\t\t\t\treturn fmt.Errorf(\"FASTQ file does not exist: %v\", fastqFile)\n\t\t\t\t} else {\n\t\t\t\t\treturn fmt.Errorf(\"can't access FASTQ file (check permissions): %v\", fastqFile)\n\t\t\t\t}\n\t\t\t}\n\t\t\tsplitFilename := strings.Split(fastqFile, \".\")\n\t\t\tif splitFilename[len(splitFilename)-1] == \"gz\" {\n\t\t\t\tif splitFilename[len(splitFilename)-2] == \"fastq\" || splitFilename[len(splitFilename)-2] == \"fq\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif splitFilename[len(splitFilename)-1] == \"fastq\" || splitFilename[len(splitFilename)-1] == \"fq\" {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"does not look like a FASTQ file: %v\", fastqFile)\n\t\t}\n\t}\n\t// check the index directory and files\n\tif *indexDir == \"\" {\n\t\tmisc.ErrorCheck(errors.New(\"need to specify the directory where the index files are\"))\n\t}\n\tif _, err := os.Stat(*indexDir); err != nil {\n\t\tif os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"index directory does not exist: %v\", *indexDir)\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"can't access an index directory (check permissions): %v\", indexDir)\n\t\t}\n\t}\n\tindexFiles := [3]string{\"/index.graph\", \"/index.info\", \"/index.sigs\"}\n\tfor _, indexFile := range indexFiles {\n\t\tif _, err := os.Stat(*indexDir + indexFile); err != nil {\n\t\t\tif os.IsNotExist(err) {\n\t\t\t\treturn fmt.Errorf(\"index file does not exist: %v\", indexFile)\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"can't access an index file (check permissions): %v\", indexFile)\n\t\t\t}\n\t\t}\n\t}\n\tinfo := new(misc.IndexInfo)\n\tmisc.ErrorCheck(info.Load(*indexDir + \"/index.info\"))\n\tif info.Version != version.VERSION {\n\t\treturn fmt.Errorf(\"the groot index was created with a different version of groot (you are currently using version %v)\", version.VERSION)\n\t}\n\t// setup the graphDir\n\tif _, err := os.Stat(*graphDir); os.IsNotExist(err) {\n\t\tif err := os.MkdirAll(*graphDir, 0700); err != nil {\n\t\t\treturn fmt.Errorf(\"can't create specified output directory\")\n\t\t}\n\t}\n\t// set number of processors to use\n\tif *proc <= 0 || *proc > runtime.NumCPU() {\n\t\t*proc = runtime.NumCPU()\n\t}\n\truntime.GOMAXPROCS(*proc)\n\treturn nil\n}", "func (af *filtBase) checkFloatParam(p, low, high float64, name string) (float64, error) {\n\tif low <= p && p <= high {\n\t\treturn p, nil\n\t} else {\n\t\terr := fmt.Errorf(\"parameter %v is not in range <%v, %v>\", name, low, high)\n\t\treturn 0, err\n\t}\n}", "func ensureIndex(t *testing.T, i int, expectValue int) {\n\n\tif v := i; v != expectValue {\n\t\tt.Errorf(\"Index = %d, want %d\", v, expectValue)\n\t}\n\n}", "func Test_CheckParam(t *testing.T) {\n\n\t//Validate mode\n\n\tat := []string{\"Alphanumeric\", \"Alpha\"}\n\tbt := []string{\"Alphanumeric\", \"Alpha\"}\n\tct := []string{\"Alphanumeric\", \"Alpha\"}\n\tdt := []string{\"Numeric\"}\n\ttarget := map[string][]string{\n\t\t\"a\": at,\n\t\t\"b\": bt,\n\t\t\"c\": ct,\n\t\t\"d\": dt,\n\t}\n\n\t//Test set 1\n\tstandardOutput := make(map[string]string)\n\n\tstandardOutput[\"c\"] = \"[Check catal#yst123 with Alphanumeric failed][Check catal#yst123 with Alpha failed]\"\n\tstandardOutput[\"d\"] = \"[Check 81927l39824 with Numeric failed]\"\n\n\ta := []string{\"apple\", \"applause\"}\n\tb := []string{\"banana\", \"balista\"}\n\tc := []string{\"catherine\", \"catal#yst123\"}\n\td := []string{\"432\", \"301\", \"81927l39824\"}\n\n\tx := map[string][]string{\n\t\t\"a\": a,\n\t\t\"b\": b,\n\t\t\"c\": c,\n\t\t\"d\": d,\n\t}\n\n\tkeys := []string{\"a\", \"b\", \"c\", \"d\"}\n\n\t//Simulate input []interface with getQueryValue().\n\t//This is the param we get when parsing the GET\n\n\tinput := getQueryValue(x, keys)\n\n\t//fmt.Println(\"input: \", x)\n\t//fmt.Println(\"filter: \", target)\n\t_, detail := CheckParam(*input, target)\n\n\tfmt.Println(\"Result: \", detail)\n\n\tassert.Equal(t, detail, standardOutput, \"The two words should be the same.\")\n\n\t//Test set 2\n\n\tstandardOutput = make(map[string]string)\n\n\tstandardOutput[\"d\"] = \"[Check monopolosomeplace.com with Email failed]\"\n\n\ta = []string{\"op.gg\", \"www.yahoo.com.tw\"}\n\tb = []string{\"banana\", \"balista\"}\n\tc = []string{\"catherine\", \"catalyst\"}\n\td = []string{\"tig4605246@gmail.com\", \"monopolosomeplace.com\"}\n\n\tx = map[string][]string{\n\t\t\"a\": a,\n\t\t\"b\": b,\n\t\t\"c\": c,\n\t\t\"d\": d,\n\t}\n\n\tkeys = []string{\"a\", \"b\", \"c\", \"d\"}\n\n\t//Simulate input []interface with getQueryValue().\n\t//This is the param we get when parsing the GET\n\n\tinput = getQueryValue(x, keys)\n\n\tdt2 := []string{\"Email\"}\n\tat2 := []string{\"DNS\"}\n\ttarget[\"a\"] = at2\n\ttarget[\"d\"] = dt2\n\t//fmt.Println(\"input: \", x)\n\t//fmt.Println(\"filter: \", target)\n\t_, detail = CheckParam(*input, target)\n\t//fmt.Println(\"Result: \",detail,\"\\nexpected: \",standardOutput)\n\tassert.Equal(t, detail, standardOutput, \"The two words should be the same.\")\n\n}", "func (a *Parser) verify() error {\n\tfor n, p := range a.params {\n\t\tif n == p.name {\n\t\t\tvalue := reflValue(p.target)\n\t\t\tswitch value.Kind() {\n\t\t\tcase reflect.Slice:\n\t\t\t\tfor i := p.count; i < reflLen(p.target); i++ {\n\t\t\t\t\tif p.scan != nil {\n\t\t\t\t\t\t// scan remaining initial values to ensure they are okay\n\t\t\t\t\t\te := p.scan(fmt.Sprint(reflElement(i, value)), reflCopy(reflElementAddr(i, value)))\n\t\t\t\t\t\tif e != nil {\n\t\t\t\t\t\t\treturn decorate(fmt.Errorf(\"invalid default value at offset %d: %v\", i, e), n)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase reflect.Array:\n\t\t\t\tif p.count != p.limit {\n\t\t\t\t\treturn decorate(fmt.Errorf(\"%d value%s specified but exactly %d expected\", p.count, plural(p.count), p.limit), n)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\t// single-valued parameter\n\t\t\t\tif p.count < 1 {\n\t\t\t\t\tif p.limit != 0 {\n\t\t\t\t\t\treturn decorate(fmt.Errorf(\"mandatory parameter not set\"), n)\n\t\t\t\t\t}\n\t\t\t\t\t// scan initial value (into a copy) to ensure it's okay\n\t\t\t\t\tif p.scan != nil {\n\t\t\t\t\t\te := p.scan(fmt.Sprint(value), reflCopy(p.target))\n\t\t\t\t\t\tif e != nil {\n\t\t\t\t\t\t\treturn decorate(fmt.Errorf(\"invalid default value: %v\", e), n)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func IsValidParameterPresent(vars map[string]string, sp []string) error {\n\n\tfor i := range sp {\n\t\tv := vars[sp[i]]\n\t\tif v == \"\" {\n\t\t\terrMessage := fmt.Sprintf(\"Missing %v in GET request\", sp[i])\n\t\t\treturn fmt.Errorf(errMessage)\n\t\t}\n\n\t}\n\treturn nil\n\n}", "func (lc *imgListCfg) checkParams(cmd *cobra.Command, args []string) error {\n\tvar err error\n\n\t//check and get persistent flag\n\tvar pf *PersistentFlags\n\tpf, err = CheckPersistentFlags()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//check Flags using common parameter checker\n\tvar params utils.Params\n\tparams, err = utils.CheckFlags(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tlc.params = params\n\tlc.pf = pf\n\n\treturn err\n}", "func validateParams(params map[string][]string) error {\n\tfor param, values := range params {\n\t\tswitch param {\n\t\tcase timeRangeQS:\n\t\t\tvalue := values[len(values)-1]\n\t\t\tif !validTimeRange(value) {\n\t\t\t\treturn errors.New(\"invalid time_range query string param\")\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func checkHVLookupArgs(name string, argsList *list.List) (idx int, lookupValue, tableArray, matchMode, errArg formulaArg) {\n\tunit := map[string]string{\n\t\t\"HLOOKUP\": \"row\",\n\t\t\"VLOOKUP\": \"col\",\n\t}[name]\n\tif argsList.Len() < 3 {\n\t\terrArg = newErrorFormulaArg(formulaErrorVALUE, fmt.Sprintf(\"%s requires at least 3 arguments\", name))\n\t\treturn\n\t}\n\tif argsList.Len() > 4 {\n\t\terrArg = newErrorFormulaArg(formulaErrorVALUE, fmt.Sprintf(\"%s requires at most 4 arguments\", name))\n\t\treturn\n\t}\n\tlookupValue = argsList.Front().Value.(formulaArg)\n\ttableArray = argsList.Front().Next().Value.(formulaArg)\n\tif tableArray.Type != ArgMatrix {\n\t\terrArg = newErrorFormulaArg(formulaErrorVALUE, fmt.Sprintf(\"%s requires second argument of table array\", name))\n\t\treturn\n\t}\n\targ := argsList.Front().Next().Next().Value.(formulaArg)\n\tif arg.Type != ArgNumber || arg.Boolean {\n\t\terrArg = newErrorFormulaArg(formulaErrorVALUE, fmt.Sprintf(\"%s requires numeric %s argument\", name, unit))\n\t\treturn\n\t}\n\tidx, matchMode = int(arg.Number)-1, newNumberFormulaArg(matchModeMaxLess)\n\tif argsList.Len() == 4 {\n\t\trangeLookup := argsList.Back().Value.(formulaArg).ToBool()\n\t\tif rangeLookup.Type == ArgError {\n\t\t\terrArg = rangeLookup\n\t\t\treturn\n\t\t}\n\t\tif rangeLookup.Number == 0 {\n\t\t\tmatchMode = newNumberFormulaArg(matchModeWildcard)\n\t\t}\n\t}\n\treturn\n}", "func checkPossibleOptions(param interface{}, paramOptions []interface{}) bool {\n\tfor _, opt := range paramOptions {\n\t\tif opt == param {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func ValidateParam(param Param) error {\n if len(param.value) < 4096 {\n return ErrInvalidArgumentLength\n }\n // TODO: Format validation should be based on data type\n // Yes, it should be based on type switch\n //for _, paramRune := range param.value {\n // if !unicode.IsLetter(paramRune) {\n // return errors.New(ErrInvalidParamFormat)\n // }\n //}\n return nil\n}", "func typeCheckParameter(obj interface{}, expected string, name string) error {\n\t// Make sure there is an object.\n\tif obj == nil {\n\t\treturn nil\n\t}\n\n\t// Check the type is as expected.\n\tif reflect.TypeOf(obj).String() != expected {\n\t\treturn fmt.Errorf(\"Expected %s to be of type %s but received %s.\", name, expected, reflect.TypeOf(obj).String())\n\t}\n\treturn nil\n}", "func typeCheckParameter(obj interface{}, expected string, name string) error {\n\t// Make sure there is an object.\n\tif obj == nil {\n\t\treturn nil\n\t}\n\n\t// Check the type is as expected.\n\tif reflect.TypeOf(obj).String() != expected {\n\t\treturn fmt.Errorf(\"Expected %s to be of type %s but received %s.\", name, expected, reflect.TypeOf(obj).String())\n\t}\n\treturn nil\n}", "func typeCheckParameter(obj interface{}, expected string, name string) error {\n\t// Make sure there is an object.\n\tif obj == nil {\n\t\treturn nil\n\t}\n\n\t// Check the type is as expected.\n\tif reflect.TypeOf(obj).String() != expected {\n\t\treturn fmt.Errorf(\"Expected %s to be of type %s but received %s.\", name, expected, reflect.TypeOf(obj).String())\n\t}\n\treturn nil\n}", "func typeCheckParameter(obj interface{}, expected string, name string) error {\n\t// Make sure there is an object.\n\tif obj == nil {\n\t\treturn nil\n\t}\n\n\t// Check the type is as expected.\n\tif reflect.TypeOf(obj).String() != expected {\n\t\treturn fmt.Errorf(\"Expected %s to be of type %s but received %s.\", name, expected, reflect.TypeOf(obj).String())\n\t}\n\treturn nil\n}", "func typeCheckParameter(obj interface{}, expected string, name string) error {\n\t// Make sure there is an object.\n\tif obj == nil {\n\t\treturn nil\n\t}\n\n\t// Check the type is as expected.\n\tif reflect.TypeOf(obj).String() != expected {\n\t\treturn fmt.Errorf(\"expected %s to be of type %s but received %s\", name, expected, reflect.TypeOf(obj).String())\n\t}\n\treturn nil\n}", "func isValidParam(data Data) (result bool, err error) {\n\t// check length of param From\n\tif len(data.From) > 3 || len(data.From) < 3 {\n\t\tresult = false\n\t\terr = ErrInvalidParamFrom\n\t\treturn\n\t}\n\n\t// check length of param To\n\tif len(data.To) > 3 || len(data.To) < 3 {\n\t\tresult = false\n\t\terr = ErrInvalidParamTo\n\t\treturn\n\t}\n\n\tresult = true\n\treturn\n}", "func (s *BaseEvent) ExistsParam( name string ) (bool) {\n _,ok:=s.execParams[name]\n return ok\n}", "func (pList ParamList) Check(ctx Context) {\n\tfor _, param := range pList {\n\t\tparam.Check(ctx)\n\t}\n}", "func validateParams(method model.Method, params map[string]interface{}) (bool, error) {\n\tvar notSpecified []model.Parameter\n\tfor _, param := range method.Parameters {\n\t\tvalue := params[param.Name]\n\t\tif param.Required {\n\t\t\tif value != \"\" && value != nil{\n\t\t\t\tactualType := getTypeName(value)\n\t\t\t\tif actualType != param.Type {\n\t\t\t\t\tmsg := fmt.Sprintf(\"Wrong argument '%s' for method '%s'. Expected type '%s', but found '%s'\", param.Name, method.Name, param.Type, actualType)\n\t\t\t\t\tlog.Printf(\"[ERROR] \" + msg)\n\t\t\t\t\treturn false, errors.New(msg)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnotSpecified = append(notSpecified, param)\n\t\t\t}\n\t\t} else {\n\t\t\tif value != \"\" && value != nil {\n\t\t\t\t// optional parameters check\n\t\t\t\tactualType := getTypeName(value)\n\t\t\t\tif actualType != param.Type {\n\t\t\t\t\tmsg := fmt.Sprintf(\"Wrong argument '%s' for method '%s'. Expected type '%s', but found '%s'\", param.Name, method.Name, param.Type, actualType)\n\t\t\t\t\tlog.Printf(\"[ERROR] \" + msg)\n\t\t\t\t\treturn false, errors.New(msg)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(notSpecified) != 0 {\n\t\tvar paramStr string = \"\"\n\t\tfor _, param := range notSpecified {\n\t\t\tparamStr += fmt.Sprintf(\"'%s', \", param.Name)\n\t\t}\n\t\tmsg := fmt.Sprintf(\"Required parameters are not provided for '%s' method. Please specify: %s\", method.Name, paramStr[:len(paramStr) - 2])\n\t\tlog.Printf(\"[ERROR] \" + msg)\n\t\treturn false, errors.New(msg)\n\t}\n\treturn true, nil\n}", "func (m *MongoStore) validateParams(args ...interface{}) bool {\n\tfor _, v := range args {\n\t\tval, ok := v.(string)\n\t\tif ok {\n\t\t\tif val == \"\" {\n\t\t\t\treturn false\n\t\t\t}\n\t\t} else {\n\t\t\tif v == nil {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\n\treturn true\n}", "func CheckParameters(r *rest.Request, needed_fields []string) (bool, map[string]string) {\n\tvar result map[string]string\n\tresult = make(map[string]string)\n\tfor _, field := range needed_fields {\n\t\tvalues, _ := r.URL.Query()[field]\n\t\tif len(values) < 1 {\n\t\t\treturn false, result\n\t\t}\n\t\tresult[field] = values[0]\n\t}\n\treturn true, result\n}", "func (buf *ListBuffer) legalIndex(idx BufferIndex) (inRange, initialized bool) {\n\tinRange = idx >= 0 && idx < BufferIndex(len(buf.Buffer))\n\tif inRange {\n\t\tinitialized = buf.Buffer[idx].Item.Type != Uninitialized\n\t} else {\n\t\tinitialized = true\n\t}\n\treturn inRange, initialized\n}", "func TestAllowedParams(t *testing.T) {\n\tif len(AllowedParams()) == 0 {\n\t\tt.Fatalf(\"pages: no allowed params\")\n\t}\n}", "func ParamExists(id int64, tx *sql.Tx) (bool, error) {\n\tcount := 0\n\tif err := tx.QueryRow(`SELECT count(*) from parameter where id = $1`, id).Scan(&count); err != nil {\n\t\treturn false, errors.New(\"querying param existence from id: \" + err.Error())\n\t}\n\treturn count > 0, nil\n}", "func CheckAnsibleParameter(opt string, val string, expected []string) error {\n\tif !SInList(strings.ToLower(val), expected) {\n\t\treturn fmt.Errorf(\"Unknown value for '%s': %s. Expected: %s\", opt, val, strings.Join(expected, \", \"))\n\t}\n\treturn nil\n}", "func (r *Client) validateTemplateParams(t *Template, params []*Parameter) error {\n\tmissing := map[string]interface{}{}\n\t// copy all wanted params into missing\n\tfor k, v := range t.Parameters {\n\t\tmissing[k] = v\n\t}\n\t// remove items from missing list as found\n\tfor wantedKey := range t.Parameters {\n\t\tfor _, param := range params {\n\t\t\tif param.ParameterKey == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// phew found it\n\t\t\tif *param.ParameterKey == wantedKey {\n\t\t\t\tdelete(missing, wantedKey)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\t// if any left, then we have an issue\n\tif len(missing) > 0 {\n\t\tkeys := []string{}\n\t\tfor k := range missing {\n\t\t\tkeys = append(keys, k)\n\t\t}\n\t\tkeysCSV := strings.Join(keys, \",\")\n\t\treturn fmt.Errorf(\"missing required input parameters: [%s]\", keysCSV)\n\t}\n\treturn nil\n}", "func checkParameters(src []string, dest string, algorithm string) (is bool) {\n\tis = true\n\t// check src\n\tif len(src) == 0 {\n\t\tis = false\n\t\tfmt.Println(\"Source file list can't be empty.\")\n\t\treturn is\n\t}\n\tfor i := 0; i < len(src); i++ {\n\t\tis, _ = PathExist(src[i])\n\t\tif !is {\n\t\t\tfmt.Printf(\"Source file %v path not exist.\\n\", i+1)\n\t\t\treturn is\n\t\t}\n\t}\n\t// check algorithm\n\tswitch algorithm {\n\tcase \"AES\", \"aes\":\n\tcase \"DES\", \"des\":\n\tcase \"3DES\", \"3des\":\n\tcase \"RSA\", \"rsa\":\n\tcase \"BASE64\", \"base64\":\n\tdefault:\n\t\tis = false\n\t\tfmt.Printf(\"Algorithm %v not support.\\n\", algorithm)\n\t}\n\treturn is\n}", "func check_args(parsed_query []string, num_expected int) bool {\n\treturn (len(parsed_query) >= num_expected)\n}", "func (pr *prepareResult) check(qd *queryDescr) error {\n\tcall := qd.kind == qkCall\n\tif call != pr.fc.IsProcedureCall() {\n\t\treturn fmt.Errorf(\"function code mismatch: query descriptor %s - function code %s\", qd.kind, pr.fc)\n\t}\n\n\tif !call {\n\t\t// only input parameters allowed\n\t\tfor _, f := range pr.parameterFields {\n\t\t\tif f.Out() {\n\t\t\t\treturn fmt.Errorf(\"invalid parameter %s\", f)\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}", "func checkIfRequiredStringSliceParameterIsSupplied(propName, optionName, in string, parsedBody interface{}, varValue []string) error {\n\tif in == \"body\" {\n\t\tcontains := doesBodyContainParameter(parsedBody, propName)\n\t\tif !contains && len(varValue) == 0 {\n\t\t\treturn fmt.Errorf(\"required parameter '%s' in body (or command line option '%s') is not specified\", propName, optionName)\n\t\t}\n\t\treturn nil\n\t}\n\n\tif len(varValue) == 0 {\n\t\treturn fmt.Errorf(\"required parameter '%s' is not specified\", optionName)\n\t}\n\treturn nil\n}", "func (ctx *Context) ParamByIndex(index int) string {\n\treturn ctx.PathParams.ByIndex(index)\n}", "func paramError(field string, v interface{}) error {\n\treturn fmt.Errorf(\"Invalid %s option: <%v>\", field, v)\n}", "func RequireParam(rt runtime.Runtime, predicate bool, msg string, args ...interface{}) {\n\tRequirePredicate(rt, predicate, exitcode.ErrIllegalArgument, msg, args...)\n}", "func EqualsVindexParam(a, b VindexParam) bool {\n\treturn a.Val == b.Val &&\n\t\tEqualsColIdent(a.Key, b.Key)\n}", "func requiredParam(w http.ResponseWriter, req *http.Request, key string) (string, bool) {\n\tvalue, exists := getParams(req, key)\n\n\tif !exists {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Write([]byte(\"400 - Bad Request!\"))\n\t\treturn \"\", false\n\t}\n\n\treturn value, true\n}", "func doAnyParametersExist(args ...string) bool {\n\tif args == nil {\n\t\treturn false\n\t}\n\tfor _, arg := range args {\n\t\tif arg != \"\" {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}", "func validateParams() {\n\tif domain == \"\" {\n\t\tprintAndExit(\"-domain is required!\", true)\n\t}\n\n\tif passLength < 1 {\n\t\tprintAndExit(\"-password-length must be a positive number!\", true)\n\t}\n\n\tif passLength < 8 {\n\t\tfmt.Println(\"WARN: -password-length is too short. We will grant your wish, but this might be a security risk. Consider using longer password.\", false)\n\t}\n}", "func indexValueOf(args []string, flag string) (int, int, error) {\n for i := 0; i < len(args); i ++ {\n s := args[i]\n\n if len(s) == 0 || s[0] != '-' || len(s) == 1 {\n continue\n }\n\n num_minuses := 1\n if s[1] == '-' {\n num_minuses++\n if len(s) == 2 { // \"--\" terminates the flags\n i ++\n break\n }\n }\n\n name := s[num_minuses:]\n if len(name) == 0 || name[0] == '-' || name[0] == '=' {\n continue\n }\n\n // it's a flag. does it have an argument?\n has_value := false\n var j int\n for j = 1; j < len(name); j ++ { // equals cannot be first\n if name[j] == '=' {\n has_value = true\n name = name[0:j]\n break\n }\n }\n\n if name == flag {\n if !has_value {\n if i + 1 < len(args) {\n // value is the current arg\n has_value = true\n return i + 1, 0, nil\n }\n\n return -1, -1, fmt.Errorf(\"flag needs an argument: -%s\", name)\n }\n\n return i, num_minuses + j + 1, nil\n }\n }\n\n return -1, -1, fmt.Errorf(\"not found\")\n}", "func isParameter(key string) (isParam bool) {\n\tif len([]rune(key)) <= 1 {\n\t\treturn // avoid empty variables, i.e. /somepath/:/someotherpath\n\t}\n\n\tif key[1] != ':' {\n\t\treturn\n\t}\n\n\tisParam = true\n\n\treturn\n}", "func (list *ArrayList) boundCheck(index int) bool {\n\treturn index >= 0 && index < list.size\n}", "func checkNumberOfArgs(name string, nargs, nresults, min, max int) error {\n\tif min == max {\n\t\tif nargs != max {\n\t\t\treturn ExceptionNewf(TypeError, \"%s() takes exactly %d arguments (%d given)\", name, max, nargs)\n\t\t}\n\t} else {\n\t\tif nargs > max {\n\t\t\treturn ExceptionNewf(TypeError, \"%s() takes at most %d arguments (%d given)\", name, max, nargs)\n\t\t}\n\t\tif nargs < min {\n\t\t\treturn ExceptionNewf(TypeError, \"%s() takes at least %d arguments (%d given)\", name, min, nargs)\n\t\t}\n\t}\n\n\tif nargs > nresults {\n\t\treturn ExceptionNewf(TypeError, \"Internal error: not enough arguments supplied to Unpack*/Parse*\")\n\t}\n\treturn nil\n}", "func valsCheck(t *testing.T, testID string, vals expVals) {\n\tt.Helper()\n\n\tvar nameLogged bool\n\tif paramInt1 != vals.pi1Val {\n\t\tnameLogged = logName(t, nameLogged, testID)\n\t\tt.Errorf(\"\\t: unexpected values: paramInt1 = %d, should be %d\\n\",\n\t\t\tparamInt1, vals.pi1Val)\n\t}\n\n\tif paramInt2 != vals.pi2Val {\n\t\tnameLogged = logName(t, nameLogged, testID)\n\t\tt.Errorf(\"\\t: unexpected values: paramInt2 = %d, should be %d\\n\",\n\t\t\tparamInt2, vals.pi2Val)\n\t}\n\n\tif paramBool1 != vals.pb1Val {\n\t\tnameLogged = logName(t, nameLogged, testID)\n\t\tt.Errorf(\"\\t: unexpected values: paramBool1 = %v, should be %v\\n\",\n\t\t\tparamBool1, vals.pb1Val)\n\t}\n\n\tif paramBool2 != vals.pb2Val {\n\t\tlogName(t, nameLogged, testID)\n\t\tt.Errorf(\"\\t: unexpected values: paramBool2 = %v, should be %v\\n\",\n\t\t\tparamBool2, vals.pb2Val)\n\t}\n}", "func (checker *Checker) checkEventParameters(\n\tparameterList *ast.ParameterList,\n\tparameters []Parameter,\n) {\n\n\tparameterTypeValidationResults := map[*Member]bool{}\n\n\tfor i, parameter := range parameterList.Parameters {\n\t\tparameterType := parameters[i].TypeAnnotation.Type\n\n\t\tif !parameterType.IsInvalidType() &&\n\t\t\t!IsValidEventParameterType(parameterType, parameterTypeValidationResults) {\n\n\t\t\tchecker.report(\n\t\t\t\t&InvalidEventParameterTypeError{\n\t\t\t\t\tType: parameterType,\n\t\t\t\t\tRange: ast.NewRange(\n\t\t\t\t\t\tchecker.memoryGauge,\n\t\t\t\t\t\tparameter.StartPos,\n\t\t\t\t\t\tparameter.TypeAnnotation.EndPosition(checker.memoryGauge),\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t}\n}", "func goodParamFuncName(name string) bool {\n\tif name == \"\" {\n\t\treturn false\n\t}\n\t// valid names are only letters and _\n\tfor _, r := range name {\n\t\tswitch {\n\t\tcase r == '_':\n\t\tcase !unicode.IsLetter(r):\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (o *GetFetchParams) bindIndex(rawData []string, hasKey bool, formats strfmt.Registry) error {\n\tvar raw string\n\tif len(rawData) > 0 {\n\t\traw = rawData[len(rawData)-1]\n\t}\n\n\t// Required: false\n\t// AllowEmptyValue: false\n\tif raw == \"\" { // empty values pass all other validations\n\t\treturn nil\n\t}\n\n\tvalue, err := swag.ConvertInt64(raw)\n\tif err != nil {\n\t\treturn errors.InvalidType(\"index\", \"query\", \"int64\", raw)\n\t}\n\to.Index = &value\n\n\tif err := o.validateIndex(formats); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func check_index(indexname string, index int) bool {\n\tvar name string\n\n\tif indexname == \"index\" {\n\t\tname = fmt.Sprintf(\"./output/%s-%d.html\", indexname, index)\n\t} else {\n\t\tname = fmt.Sprintf(\"./output/categories/%s-%d.html\", indexname, index)\n\t}\n\tif exists(name) {\n\t\treturn true\n\t} else {\n\t\treturn false\n\t}\n\n}", "func (p ParamScope) findByParamName(name string) (ret int, okay bool) {\n\tfor index, src := range []string{\"action.Source\", \"action.Target\", \"action.Context\"} {\n\t\tif strings.EqualFold(name, src) {\n\t\t\tret, okay = index, true\n\t\t\tbreak\n\t\t}\n\t}\n\treturn\n}", "func (p *Params) Check() error {\n\t// Validate Memory\n\tif p.Memory < minMemoryValue {\n\t\treturn ErrInvalidParams\n\t}\n\n\t// Validate Iterations\n\tif p.Iterations < 1 {\n\t\treturn ErrInvalidParams\n\t}\n\n\t// Validate Parallelism\n\tif p.Parallelism < 1 {\n\t\treturn ErrInvalidParams\n\t}\n\n\t// Validate salt length\n\tif p.SaltLength < minSaltLength {\n\t\treturn ErrInvalidParams\n\t}\n\n\t// Validate key length\n\tif p.KeyLength < minKeyLength {\n\t\treturn ErrInvalidParams\n\t}\n\n\treturn nil\n}", "func validateArgs(linkIndex int, fn reflect.Type, args []Argument) error {\n\tif !fn.IsVariadic() && (fn.NumIn() != len(args)) {\n\t\treturn argumentMismatchError(linkIndex, len(args), fn.NumIn())\n\t}\n\n\treturn nil\n}", "func CheckParams(params Setting, passwordType string) bool {\n\n\tminLen := params.MinLength\n\tminSpecials := params.MinSpecialCharacters\n\tminDigits := params.MinDigits\n\tminLowers := params.MinLowercase\n\tminUppers := params.MinUppercase\n\n\tif minLen < AbsoluteMinLen ||\n\t\tminDigits < config[passwordType].MinDigits ||\n\t\tminLowers < config[passwordType].MinLowercase ||\n\t\tminUppers < config[passwordType].MinUppercase ||\n\t\tminSpecials < config[passwordType].MinSpecialCharacters {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func checkLookupArgs(argsList *list.List) (arrayForm bool, lookupValue, lookupVector, errArg formulaArg) {\n\tif argsList.Len() < 2 {\n\t\terrArg = newErrorFormulaArg(formulaErrorVALUE, \"LOOKUP requires at least 2 arguments\")\n\t\treturn\n\t}\n\tif argsList.Len() > 3 {\n\t\terrArg = newErrorFormulaArg(formulaErrorVALUE, \"LOOKUP requires at most 3 arguments\")\n\t\treturn\n\t}\n\tlookupValue = newStringFormulaArg(argsList.Front().Value.(formulaArg).Value())\n\tlookupVector = argsList.Front().Next().Value.(formulaArg)\n\tif lookupVector.Type != ArgMatrix && lookupVector.Type != ArgList {\n\t\terrArg = newErrorFormulaArg(formulaErrorVALUE, \"LOOKUP requires second argument of table array\")\n\t\treturn\n\t}\n\tarrayForm = lookupVector.Type == ArgMatrix\n\tif arrayForm && len(lookupVector.Matrix) == 0 {\n\t\terrArg = newErrorFormulaArg(formulaErrorVALUE, \"LOOKUP requires not empty range as second argument\")\n\t}\n\treturn\n}", "func checkOutOfBounds(index, sliceLength int) bool {\n\treturn index < 0 || index >= sliceLength\n}", "func checkIndex(resp *httptest.ResponseRecorder) error {\n\theader := resp.Header().Get(\"X-Maya-Index\")\n\tif header == \"\" || header == \"0\" {\n\t\treturn fmt.Errorf(\"Bad: %v\", header)\n\t}\n\treturn nil\n}", "func GetParam(args []string, key string) (string, error) {\n\tvar catched = false\n\tfor _, item := range args {\n\t\tif catched {\n\t\t\treturn item, nil\n\t\t}\n\t\tif item == key {\n\t\t\tcatched = true\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"%s value not found\", key)\n}", "func TestParameters(t *testing.T) {\n\tdb := NewFtsDB()\n\tdefer db.Close()\n\n\tif err := db.SetParameter(\"test1\", \"value1\"); err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif value := db.GetParameter(\"test2\"); value != nil {\n\t\tt.Fatalf(`value should be nil, it's \"%s\"`, value)\n\t}\n\n\tif value := db.GetParameter(\"test1\"); value == nil || *value != \"value1\" {\n\t\tt.Fatalf(`value should be \"test1\", it's \"%s\"`, value)\n\t}\n\n}", "func isParamChar(c byte) bool {\n\tif (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c <= 57) || c == 95 {\n\t\treturn true\n\t}\n\treturn false\n}", "func isValidKeyPair(param []string) bool {\n\treturn len(param) == 2\n}", "func asSupportedParameter(param string) (string, bool) {\n\tlower := strings.ToLower(param)\n\treturn lower, lowerCaseParameters[lower]\n}", "func (args *CliArgs) checkArgs() {\n\t// print all filed of the object\n\tif !(args.startPage > 0 && args.endPage > 0 && args.endPage-args.startPage >= 0) {\n\t\tfmt.Fprintf(os.Stderr, \"start page and end page should be positive and endpage should be bigger than startpage\")\n\t\tos.Exit(1)\n\t}\n\n\tif args.isFtype {\n\t\tif args.lineNumPerPage != specialNum {\n\t\t\tfmt.Fprintln(os.Stderr, \"Fatal: setting -f and -l simultaneously is not allowed\")\n\t\t\tos.Exit(1)\n\t\t}\n\t} else {\n\t\tif args.lineNumPerPage == specialNum {\n\t\t\targs.lineNumPerPage = defaultLineNum\n\t\t} else if args.lineNumPerPage < 0 {\n\t\t\tfmt.Fprintln(os.Stderr, \"Fatal: the linenum should be positive\")\n\t\t\tos.Exit(1)\n\t\t}\n\t}\n\n\t// set default number of linenumber\n\tif pflag.NArg() != 0 {\n\t\targs.inFilename = pflag.Args()[0]\n\t}\n\n\tfmt.Printf(\"%+v\", args)\n}", "func (task *Task) checkPartIndex() (newPartition *PartInfo, totalunits int, isSingle bool, err error) {\n\tlock, err := task.RLockNamed(\"checkPartIndex\")\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer task.RUnlockNamed(lock)\n\n\tinputIO := task.Inputs[0]\n\tnewPartition = &PartInfo{\n\t\tInput: inputIO.FileName,\n\t\tMaxPartSizeMB: task.MaxWorkSize,\n\t}\n\n\tif len(task.Inputs) > 1 {\n\t\tfound := false\n\t\tif (task.Partition != nil) && (task.Partition.Input != \"\") {\n\t\t\t// task submitted with partition input specified, use that\n\t\t\tfor _, io := range task.Inputs {\n\t\t\t\tif io.FileName == task.Partition.Input {\n\t\t\t\t\tfound = true\n\t\t\t\t\tinputIO = io\n\t\t\t\t\tnewPartition.Input = io.FileName\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif !found {\n\t\t\t// bad state - set as not multi-workunit\n\t\t\tlogger.Error(\"warning: lacking partition info while multiple inputs are specified, taskid=\" + task.Id)\n\t\t\tisSingle = true\n\t\t\treturn\n\t\t}\n\t}\n\n\t// if submitted with partition index use that, otherwise default\n\tif (task.Partition != nil) && (task.Partition.Index != \"\") {\n\t\tnewPartition.Index = task.Partition.Index\n\t} else {\n\t\tnewPartition.Index = conf.DEFAULT_INDEX\n\t}\n\n\tidxInfo, err := inputIO.IndexFile(newPartition.Index)\n\tif err != nil {\n\t\t// bad state - set as not multi-workunit\n\t\tlogger.Error(\"warning: failed to create / retrieve index=%s, taskid=%s, error=%s\", newPartition.Index, task.Id, err.Error())\n\t\tisSingle = true\n\t\terr = nil\n\t\treturn\n\t}\n\n\ttotalunits = int(idxInfo.TotalUnits)\n\treturn\n}", "func checkAndPrint(a []string, index int) {\n\t//defer function named handleOutIfBounds as well at the start of the function checkAndPrint.\n\t//This function contains the call to recover function\n\tdefer handleOutOfBound()\n\n\tif index > len(a)-1 {\n\t\t//if the index passed is greater than the length of the array then the program panics.\n\t\tpanic(\"Out of Bound aaccess for slice\")\n\t}\n\tfmt.Println(a[index])\n}", "func (m *MongoSearchSuite) TestInvalidSearchParameterPanics(c *C) {\n\tq := Query{\"Condition\", \"abatement=2012\"}\n\tc.Assert(func() { m.MongoSearcher.CreateQuery(q) }, Panics, createInvalidSearchError(\"SEARCH_NONE\", \"Error: no processable search found for Condition search parameters \\\"abatement\\\"\"))\n}", "func validateLogIndex(v string) error {\n\ti, err := strconv.Atoi(v)\n\tif err != nil {\n\t\treturn err\n\t}\n\tl := struct {\n\t\tIndex int `validate:\"gte=0\"`\n\t}{i}\n\n\treturn useValidator(logIndexFlag, l)\n}", "func ValidateAndRegisterParams(mapName string, params []provider.QueryParameter) error {\n\tif len(params) == 0 {\n\t\treturn nil\n\t}\n\n\tusedNames := make(map[string]struct{})\n\tusedTokens := make(map[string]struct{})\n\n\tfor _, param := range params {\n\t\tif _, ok := provider.ParamTypeDecoders[param.Type]; !ok {\n\t\t\treturn ErrParamUnknownType{\n\t\t\t\tMapName: string(mapName),\n\t\t\t\tParameter: param,\n\t\t\t}\n\t\t}\n\n\t\tif len(param.DefaultSQL) > 0 && len(param.DefaultValue) > 0 {\n\t\t\treturn ErrParamTwoDefaults{\n\t\t\t\tMapName: string(mapName),\n\t\t\t\tParameter: param,\n\t\t\t}\n\t\t}\n\n\t\tif len(param.DefaultValue) > 0 {\n\t\t\tdecoderFn := provider.ParamTypeDecoders[param.Type]\n\t\t\tif _, err := decoderFn(param.DefaultValue); err != nil {\n\t\t\t\treturn ErrParamInvalidDefault{\n\t\t\t\t\tMapName: string(mapName),\n\t\t\t\t\tParameter: param,\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif _, ok := ReservedTokens[param.Token]; ok {\n\t\t\treturn ErrParamTokenReserved{\n\t\t\t\tMapName: string(mapName),\n\t\t\t\tParameter: param,\n\t\t\t}\n\t\t}\n\n\t\tif !provider.ParameterTokenRegexp.MatchString(param.Token) {\n\t\t\treturn ErrParamBadTokenName{\n\t\t\t\tMapName: string(mapName),\n\t\t\t\tParameter: param,\n\t\t\t}\n\t\t}\n\n\t\tif _, ok := usedNames[param.Name]; ok {\n\t\t\treturn ErrParamDuplicateName{\n\t\t\t\tMapName: string(mapName),\n\t\t\t\tParameter: param,\n\t\t\t}\n\t\t}\n\n\t\tif _, ok := usedTokens[param.Token]; ok {\n\t\t\treturn ErrParamDuplicateToken{\n\t\t\t\tMapName: string(mapName),\n\t\t\t\tParameter: param,\n\t\t\t}\n\t\t}\n\n\t\tusedNames[param.Name] = struct{}{}\n\t\tusedTokens[param.Token] = struct{}{}\n\t}\n\n\t// Mark all used tokens as reserved\n\tfor token := range usedTokens {\n\t\tReservedTokens[token] = struct{}{}\n\t}\n\n\treturn nil\n}", "func (m *MockValidatorLogic) Index(height int64, valUpdates []types2.ValidatorUpdate) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Index\", height, valUpdates)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func checkArgValue(v string, found bool, def cmdkit.Argument) error {\n\tif def.Variadic && def.SupportsStdin {\n\t\treturn nil\n\t}\n\n\tif !found && def.Required {\n\t\treturn fmt.Errorf(\"argument %q is required\", def.Name)\n\t}\n\n\treturn nil\n}", "func (_Ethdkg *EthdkgCaller) CheckIndices(opts *bind.CallOpts, honestIndices []*big.Int, dishonestIndices []*big.Int, n *big.Int) (bool, error) {\n\tvar (\n\t\tret0 = new(bool)\n\t)\n\tout := ret0\n\terr := _Ethdkg.contract.Call(opts, out, \"checkIndices\", honestIndices, dishonestIndices, n)\n\treturn *ret0, err\n}", "func TestPaginateParams(t *testing.T) {\n\ttype TestCase struct {\n\t\treq SearchRequest\n\t\terr error\n\t}\n\n\tcases := []TestCase{\n\t\t{\n\t\t\treq: SearchRequest{Limit: -5, Offset: 3},\n\t\t\terr: fmt.Errorf(\"limit must be > 0\"),\n\t\t},\n\t\t{\n\t\t\treq: SearchRequest{Offset: -3, Limit: 2},\n\t\t\terr: fmt.Errorf(\"offset must be > 0\"),\n\t\t},\n\t}\n\n\tts := NewTestServer(allowedAccessToken)\n\tdefer ts.Close()\n\n\tfor caseNum, item := range cases {\n\t\t_, err := ts.Client.FindUsers(item.req)\n\t\tif err.Error() != item.err.Error() {\n\t\t\tt.Errorf(\"[%d] invalid error, expected %, got %v\", caseNum, item.err, err)\n\t\t}\n\t}\n}", "func mssqlCheckParameter(dsn string, option string) bool {\n\traw, err := neturl.QueryUnescape(dsn)\n\tif err != nil {\n\t\traw = dsn\n\t}\n\treturn strings.Contains(strings.ToLower(raw), option)\n}", "func paramTest (w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tfmt.Fprint(w, vars[\"param\"])\n}", "func EqualsSliceOfVindexParam(a, b []VindexParam) bool {\n\tif len(a) != len(b) {\n\t\treturn false\n\t}\n\tfor i := 0; i < len(a); i++ {\n\t\tif !EqualsVindexParam(a[i], b[i]) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func checkInput(args []string) bool {\n\tif len(args) != 9 {\n\t\tfmt.Println(\"Error\") // Input length is out of range\n\t\treturn false\n\t}\n\n\tfor i := 0; i < len(args); i++ {\n\t\tif len(args[i]) != 9 {\n\t\t\tfmt.Println(\"Error\") // Input length is out of range\n\t\t\treturn false\n\t\t}\n\t}\n\tfor i := 0; i < len(args); i++ {\n\t\tfor _, value := range args[i] {\n\t\t\t//check if it equals char / or 0 and aslo\n\t\t\t//check if it less than . or greater than 9\n\t\t\t// if value == 47 || value == 48 {\n\t\t\t// \tfmt.Println(\"Error\") // Input is not correct\n\t\t\t// \treturn false\n\t\t\t// } else\n\t\t\tif value < 49 && value > 57 {\n\t\t\t\tfmt.Println(\"Error\") // Input is not correct\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t}\n\treturn true\n}", "func driverArgsConnLocked(ci driver.Conn, ds *driverStmt, args []any) ([]driver.NamedValue, error) {\n\tnvargs := make([]driver.NamedValue, len(args))\n\n\t// -1 means the driver doesn't know how to count the number of\n\t// placeholders, so we won't sanity check input here and instead let the\n\t// driver deal with errors.\n\twant := -1\n\n\tvar si driver.Stmt\n\tvar cc ccChecker\n\tif ds != nil {\n\t\tsi = ds.si\n\t\twant = ds.si.NumInput()\n\t\tcc.want = want\n\t}\n\n\t// Check all types of interfaces from the start.\n\t// Drivers may opt to use the NamedValueChecker for special\n\t// argument types, then return driver.ErrSkip to pass it along\n\t// to the column converter.\n\tnvc, ok := si.(driver.NamedValueChecker)\n\tif !ok {\n\t\tnvc, ok = ci.(driver.NamedValueChecker)\n\t}\n\tcci, ok := si.(driver.ColumnConverter)\n\tif ok {\n\t\tcc.cci = cci\n\t}\n\n\t// Loop through all the arguments, checking each one.\n\t// If no error is returned simply increment the index\n\t// and continue. However if driver.ErrRemoveArgument\n\t// is returned the argument is not included in the query\n\t// argument list.\n\tvar err error\n\tvar n int\n\tfor _, arg := range args {\n\t\tnv := &nvargs[n]\n\t\tif np, ok := arg.(NamedArg); ok {\n\t\t\tif err = validateNamedValueName(np.Name); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\targ = np.Value\n\t\t\tnv.Name = np.Name\n\t\t}\n\t\tnv.Ordinal = n + 1\n\t\tnv.Value = arg\n\n\t\t// Checking sequence has four routes:\n\t\t// A: 1. Default\n\t\t// B: 1. NamedValueChecker 2. Column Converter 3. Default\n\t\t// C: 1. NamedValueChecker 3. Default\n\t\t// D: 1. Column Converter 2. Default\n\t\t//\n\t\t// The only time a Column Converter is called is first\n\t\t// or after NamedValueConverter. If first it is handled before\n\t\t// the nextCheck label. Thus for repeats tries only when the\n\t\t// NamedValueConverter is selected should the Column Converter\n\t\t// be used in the retry.\n\t\tchecker := defaultCheckNamedValue\n\t\tnextCC := false\n\t\tswitch {\n\t\tcase nvc != nil:\n\t\t\tnextCC = cci != nil\n\t\t\tchecker = nvc.CheckNamedValue\n\t\tcase cci != nil:\n\t\t\tchecker = cc.CheckNamedValue\n\t\t}\n\n\tnextCheck:\n\t\terr = checker(nv)\n\t\tswitch err {\n\t\tcase nil:\n\t\t\tn++\n\t\t\tcontinue\n\t\tcase driver.ErrRemoveArgument:\n\t\t\tnvargs = nvargs[:len(nvargs)-1]\n\t\t\tcontinue\n\t\tcase driver.ErrSkip:\n\t\t\tif nextCC {\n\t\t\t\tnextCC = false\n\t\t\t\tchecker = cc.CheckNamedValue\n\t\t\t} else {\n\t\t\t\tchecker = defaultCheckNamedValue\n\t\t\t}\n\t\t\tgoto nextCheck\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"sql: converting argument %s type: %v\", describeNamedValue(nv), err)\n\t\t}\n\t}\n\n\t// Check the length of arguments after conversion to allow for omitted\n\t// arguments.\n\tif want != -1 && len(nvargs) != want {\n\t\treturn nil, fmt.Errorf(\"sql: expected %d arguments, got %d\", want, len(nvargs))\n\t}\n\n\treturn nvargs, nil\n\n}", "func simpleParamValidator(In []reflect.Type, Out []reflect.Type) func(cache *functionCache) error {\n\treturn func(cache *functionCache) error {\n\t\tvar isValid = func() bool {\n\t\t\tif In != nil {\n\t\t\t\tif len(In) != len(cache.TypesIn) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tfor i, paramIn := range In {\n\t\t\t\t\tif paramIn != genericTp && paramIn != cache.TypesIn[i] {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif Out != nil {\n\t\t\t\tif len(Out) != len(cache.TypesOut) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tfor i, paramOut := range Out {\n\t\t\t\t\tif paramOut != genericTp && paramOut != cache.TypesOut[i] {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\n\t\tif !isValid() {\n\t\t\treturn fmt.Errorf(\"%s: parameter [%s] has a invalid function signature. Expected: '%s', actual: '%s'\", cache.MethodName, cache.ParamName, formatFnSignature(In, Out), formatFnSignature(cache.TypesIn, cache.TypesOut))\n\t\t}\n\t\treturn nil\n\t}\n}", "func simpleParamValidator(In []reflect.Type, Out []reflect.Type) func(cache *functionCache) error {\n\treturn func(cache *functionCache) error {\n\t\tvar isValid = func() bool {\n\t\t\tif In != nil {\n\t\t\t\tif len(In) != len(cache.TypesIn) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tfor i, paramIn := range In {\n\t\t\t\t\tif paramIn != genericTp && paramIn != cache.TypesIn[i] {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif Out != nil {\n\t\t\t\tif len(Out) != len(cache.TypesOut) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t\tfor i, paramOut := range Out {\n\t\t\t\t\tif paramOut != genericTp && paramOut != cache.TypesOut[i] {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true\n\t\t}\n\n\t\tif !isValid() {\n\t\t\treturn fmt.Errorf(\"%s: parameter [%s] has a invalid function signature. Expected: '%s', actual: '%s'\", cache.MethodName, cache.ParamName, formatFnSignature(In, Out), formatFnSignature(cache.TypesIn, cache.TypesOut))\n\t\t}\n\t\treturn nil\n\t}\n}", "func ParamsExist(ids []int64, tx *sql.Tx) ([]int64, error) {\n\tvar nonExistingIDs []int64\n\tif err := tx.QueryRow(`SELECT ARRAY_AGG(id) FROM UNNEST($1::INT[]) AS id WHERE id NOT IN (SELECT id FROM parameter)`, pq.Array(ids)).Scan(pq.Array(&nonExistingIDs)); err != nil {\n\t\treturn nil, fmt.Errorf(\"querying parameters existence from id: %w\", err)\n\t}\n\tif len(nonExistingIDs) >= 1 {\n\t\treturn nonExistingIDs, nil\n\t}\n\treturn nil, nil\n}", "func getParam(memory []int, ip int, rb int, mode ParamMode) int {\n\tswitch mode {\n\tcase POSITION:\n\t\treturn memory[memory[ip]]\n\tcase IMMEDIATE:\n\t\treturn memory[ip]\n\tcase RELATIVE:\n\t\treturn memory[rb+memory[ip]]\n\tdefault:\n\t\tpanic(fmt.Errorf(\"Unknown parameter mode: %d\", mode))\n\t}\n\treturn 0\n}", "func (inv *ActionLocationIndexInvocation) IsParameterSelected(param string) bool {\n\tif inv.Input._selectedParameters == nil {\n\t\treturn true\n\t}\n\n\t_, exists := inv.Input._selectedParameters[param]\n\treturn exists\n}", "func (inv *ActionLocationIndexInvocation) IsParameterNil(param string) bool {\n\tif inv.Input._nilParameters == nil {\n\t\treturn false\n\t}\n\n\t_, exists := inv.Input._nilParameters[param]\n\treturn exists\n}", "func (s *SelectSampleSearch) ValidateParameters() {\n\ts.common.ValidateParameters()\n\tif len(s.mutInfoFile) == 0 {\n\t\tlog.Panic(\"Mutual information file missing\")\n\t}\n\ts.mutInfo = scr.ReadMutInf(s.mutInfoFile)\n}", "func parseAndCheckParameters(params ...Parameter) (*parameters, error) {\n\tparameters := parameters{\n\t\tlogLevel: zerolog.GlobalLevel(),\n\t}\n\tfor _, p := range params {\n\t\tif params != nil {\n\t\t\tp.apply(&parameters)\n\t\t}\n\t}\n\n\tif parameters.monitor == nil {\n\t\t// Use no-op monitor.\n\t\tparameters.monitor = &noopMonitor{}\n\t}\n\tif parameters.signer == nil {\n\t\treturn nil, errors.New(\"no signer specified\")\n\t}\n\tif parameters.lister == nil {\n\t\treturn nil, errors.New(\"no lister specified\")\n\t}\n\tif parameters.process == nil {\n\t\treturn nil, errors.New(\"no process specified\")\n\t}\n\tif parameters.walletManager == nil {\n\t\treturn nil, errors.New(\"no wallet manager specified\")\n\t}\n\tif parameters.accountManager == nil {\n\t\treturn nil, errors.New(\"no account manager specified\")\n\t}\n\tif parameters.peers == nil {\n\t\treturn nil, errors.New(\"no peers specified\")\n\t}\n\tif parameters.name == \"\" {\n\t\treturn nil, errors.New(\"no name specified\")\n\t}\n\tif parameters.id == 0 {\n\t\treturn nil, errors.New(\"no ID specified\")\n\t}\n\tif parameters.listenAddress == \"\" {\n\t\treturn nil, errors.New(\"no listen address specified\")\n\t}\n\tif len(parameters.serverCert) == 0 {\n\t\treturn nil, errors.New(\"no server certificate specified\")\n\t}\n\tif len(parameters.serverKey) == 0 {\n\t\treturn nil, errors.New(\"no server key specified\")\n\t}\n\n\treturn &parameters, nil\n}", "func ValidateParams(paramSpec []GeneratorParam, params map[string]interface{}) error {\n\tallErrs := []error{}\n\tfor ix := range paramSpec {\n\t\tif paramSpec[ix].Required {\n\t\t\tvalue, found := params[paramSpec[ix].Name]\n\t\t\tif !found || IsZero(value) {\n\t\t\t\tallErrs = append(allErrs, fmt.Errorf(\"Parameter: %s is required\", paramSpec[ix].Name))\n\t\t\t}\n\t\t}\n\t}\n\treturn utilerrors.NewAggregate(allErrs)\n}", "func (inv *ActionIpAddressIndexInvocation) IsParameterSelected(param string) bool {\n\tif inv.Input._selectedParameters == nil {\n\t\treturn true\n\t}\n\n\t_, exists := inv.Input._selectedParameters[param]\n\treturn exists\n}", "func GetParam(name string, r *http.Request, index ...int) string {\n\tif params := r.Context().Value(ParamsKey); params != nil {\n\t\tparams := params.(Params)\n\t\tif name != \"*\" {\n\t\t\tname = \":\" + name\n\t\t}\n\t\tif param := params[name]; param != nil {\n\t\t\tswitch param := param.(type) {\n\t\t\tcase []string:\n\t\t\t\tif len(index) > 0 {\n\t\t\t\t\tif index[0] < len(param) {\n\t\t\t\t\t\treturn param[index[0]]\n\t\t\t\t\t}\n\t\t\t\t\treturn \"\"\n\t\t\t\t}\n\t\t\t\treturn param[0]\n\t\t\tdefault:\n\t\t\t\treturn param.(string)\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}", "func HasParam(values url.Values, param string) bool {\n\t_, ok := values[param]\n\treturn ok\n}", "func paramName(params *types.Tuple, pos int) string {\n\tname := params.At(pos).Name()\n\tif name == \"\" || name == \"_\" || paramRE.MatchString(name) {\n\t\tname = fmt.Sprintf(\"p%d\", pos)\n\t}\n\treturn name\n}", "func TestIntIndex(t *testing.T) {\n\tt.Parallel()\n\tvar tests = []struct {\n\t\thaystack []int\n\t\tneedle int\n\t\texpected int\n\t}{\n\t\t{[]int{1, 2}, 1, 0},\n\t\t{[]int{1, 2}, 2, 1},\n\t\t{[]int{1, 2}, 0, -1},\n\t}\n\tfor _, test := range tests {\n\t\tactual := primitives.Index(&test.haystack, test.needle)\n\t\tassert.Equal(t, test.expected, actual, \"expected value '%v' | actual : '%v'\", test.expected, actual)\n\t}\n}", "func (fn *formulaFuncs) index(array formulaArg, rowIdx, colIdx int) formulaArg {\n\tvar cells []formulaArg\n\tif array.Type == ArgMatrix {\n\t\tcellMatrix := array.Matrix\n\t\tif rowIdx < -1 || rowIdx >= len(cellMatrix) {\n\t\t\treturn newErrorFormulaArg(formulaErrorREF, \"INDEX row_num out of range\")\n\t\t}\n\t\tif rowIdx == -1 {\n\t\t\tif colIdx >= len(cellMatrix[0]) {\n\t\t\t\treturn newErrorFormulaArg(formulaErrorREF, \"INDEX col_num out of range\")\n\t\t\t}\n\t\t\tvar column [][]formulaArg\n\t\t\tfor _, cells = range cellMatrix {\n\t\t\t\tcolumn = append(column, []formulaArg{cells[colIdx]})\n\t\t\t}\n\t\t\treturn newMatrixFormulaArg(column)\n\t\t}\n\t\tcells = cellMatrix[rowIdx]\n\t}\n\tif colIdx < -1 || colIdx >= len(cells) {\n\t\treturn newErrorFormulaArg(formulaErrorREF, \"INDEX col_num out of range\")\n\t}\n\treturn newListFormulaArg(cells)\n}", "func ValidateParameter(nPar string, validParams map[string]bool, fieldPath *field.Path) field.ErrorList {\n\tif !validParams[nPar] {\n\t\tmsg := fmt.Sprintf(\"'%v' contains an invalid NGINX parameter. Accepted parameters are: %v\", nPar, mapToPrettyString(validParams))\n\t\treturn field.ErrorList{field.Invalid(fieldPath, nPar, msg)}\n\t}\n\treturn nil\n}", "func isTypeParam(_ *ast.Field, _ []*ast.FuncDecl, _ []*ast.FuncLit) bool {\n\treturn false\n}", "func isNamedParam(str string) bool {\n\treturn namedParamRegx.MatchString(str)\n}", "func (s *BasevhdlListener) EnterIndex_specification(ctx *Index_specificationContext) {}" ]
[ "0.64062905", "0.6219524", "0.5964376", "0.5929825", "0.5826433", "0.58000696", "0.57833385", "0.5755149", "0.57122403", "0.5704308", "0.5693902", "0.56724966", "0.5590904", "0.5540803", "0.5513222", "0.5499996", "0.5456984", "0.5451518", "0.5449487", "0.5449487", "0.5449487", "0.5449487", "0.544946", "0.54137367", "0.53690857", "0.5367469", "0.53650016", "0.5360691", "0.5353875", "0.5349612", "0.53243595", "0.5258082", "0.52466524", "0.5235129", "0.5229761", "0.5189993", "0.5179721", "0.51783466", "0.51764655", "0.5172123", "0.5163074", "0.51306367", "0.51256305", "0.512053", "0.51137", "0.5113032", "0.5108365", "0.5097492", "0.5093209", "0.50840247", "0.5075943", "0.505301", "0.5049147", "0.50473154", "0.5028611", "0.5023016", "0.5018956", "0.5014152", "0.50051606", "0.49948582", "0.49920693", "0.4967897", "0.49495262", "0.49397284", "0.49365807", "0.4925751", "0.4922006", "0.49191046", "0.490523", "0.4903904", "0.48923746", "0.48741794", "0.48684186", "0.48654214", "0.48631307", "0.48571765", "0.48569757", "0.4853758", "0.4849548", "0.48451072", "0.48435166", "0.48354343", "0.48354343", "0.48329324", "0.4830123", "0.48167643", "0.48163742", "0.48089468", "0.4806822", "0.48062575", "0.48057094", "0.48000255", "0.4795781", "0.4794627", "0.47945175", "0.4792993", "0.47912446", "0.47898975", "0.47875583", "0.47713915" ]
0.6897079
0
NewApplication initializes and returns Application.
func NewApplication() *Application { tview.Styles = tview.Theme{ PrimitiveBackgroundColor: tcell.ColorDefault, ContrastBackgroundColor: tcell.ColorBlue, PrimaryTextColor: tcell.ColorDefault, SecondaryTextColor: tcell.ColorDefault, } table := NewTable() table.SetInputCapture(func(t todo.Todo, event *tcell.EventKey) *tcell.EventKey { switch event.Rune() { case 'd': todo.GetStore().ToggleDone(t.ID) return nil default: return event } }) description := NewDescription() flex := tview.NewFlex(). SetDirection(tview.FlexRow). AddItem(table, 0, 1, true) table.SetSelectedFunc(func(todo todo.Todo) { if description.IsShown { description.IsShown = false flex.RemoveItem(description) } else { description.IsShown = true description.SetText(todo.Description) flex.AddItem(description, 0, 1, false) } }) table.SetSelectionChangedFunc(func(todo todo.Todo) { if description.IsShown { description.SetText(todo.Description) } }) pages := tview.NewPages(). AddPage("list", flex, true, true) form := NewForm(func() { pages.SwitchToPage("list") }) pages.AddPage("form", form, true, false) app := tview.NewApplication(). SetRoot(pages, true) // https://github.com/rivo/tview/issues/270 app.SetBeforeDrawFunc(func(s tcell.Screen) bool { s.Clear() return false }) app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { switch event.Rune() { case 'c': pages.SwitchToPage("form") return nil default: return event } }) return &Application{ Application: app, table: table, subscriber: make(chan []todo.Todo), } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewApplication() Application {\n\treturn app\n}", "func New() *Application {\n\tapp := &Application{}\n\treturn app\n}", "func NewApplication() application.Application {\n\treturn &app{}\n}", "func NewApplication() *Application {\n\treturn &Application{}\n}", "func New(name string) *Application {\n\tif name == \"\" {\n\t\tpanic(\"can't construct an app without a name\")\n\t}\n\n\treturn &Application{Name: name}\n}", "func New() *Application {\n\tapp := &Application{\n\t\tmiddlewares: []Handler{logging, respond},\n\t\tconfigs: map[string]string{},\n\t}\n\treturn app\n}", "func New() *Application {\n\tbrizo := new(Application)\n\tbrizo.serverListener = http.ListenAndServe\n\tbrizo.serverHandler = routes.BuildRouter()\n\tbrizo.healthChecks = []ChecksHealth{\n\t\tdatabase.Health,\n\t}\n\tbrizo.migrator = migrations.Run\n\n\treturn brizo\n}", "func New(cfg *conf.Config) *Application {\n\tapp := new(Application)\n\n\t// init db\n\tapp.DB = model.Init()\n\n\t// init redis\n\tapp.RedisClient = redis2.Init()\n\n\t// init router\n\tapp.Router = gin.Default()\n\n\t// init log\n\tconf.InitLog()\n\n\tif viper.GetString(\"app.run_mode\") == ModeDebug {\n\t\tapp.Debug = true\n\t}\n\n\treturn app\n}", "func New(\n\tfactories config.Factories,\n\tappInfo ApplicationStartInfo,\n) (*Application, error) {\n\n\tif err := configcheck.ValidateConfigFromFactories(factories); err != nil {\n\t\treturn nil, err\n\t}\n\n\tapp := &Application{\n\t\tinfo: appInfo,\n\t\tv: viper.New(),\n\t\treadyChan: make(chan struct{}),\n\t\tfactories: factories,\n\t}\n\n\trootCmd := &cobra.Command{\n\t\tUse: appInfo.ExeName,\n\t\tLong: appInfo.LongName,\n\t\tRun: func(cmd *cobra.Command, args []string) {\n\t\t\tapp.init()\n\t\t\tapp.execute()\n\t\t},\n\t}\n\n\t// TODO: coalesce this code and expose this information to other components.\n\tflagSet := new(flag.FlagSet)\n\taddFlagsFns := []func(*flag.FlagSet){\n\t\ttelemetryFlags,\n\t\tbuilder.Flags,\n\t\tloggerFlags,\n\t}\n\tfor _, addFlags := range addFlagsFns {\n\t\taddFlags(flagSet)\n\t}\n\trootCmd.Flags().AddGoFlagSet(flagSet)\n\n\tapp.rootCmd = rootCmd\n\n\treturn app, nil\n}", "func New() *App {\n\treturn NewApp(newDefaultApp())\n}", "func New() App {\n\treturn App{}\n}", "func New() *App {\n\treturn &App{}\n}", "func NewApp() App {\n\treturn App{}\n}", "func NewApp() App {\n\treturn App{}\n}", "func NewApp() App {\n\treturn new(app)\n}", "func NewApplication(configPath *string) (*Application, error) {\n\n\tconfig, err := config.Load(configPath)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Load pulseaudio DBus module if needed. This module is mandatory, but it\n\t// can also be configured in system files. See package doc.\n\tisLoaded, err := pulseaudio.ModuleIsLoaded()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !isLoaded {\n\t\terr = pulseaudio.LoadModule()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Connect to the pulseaudio dbus service.\n\tclient, err := pulseaudio.New()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// defer pulse.Close()\n\n\taudio, err := audio.NewAudio(config, client)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tapplication := Application{client, isLoaded, audio, config}\n\n\tapplication.iniTrayIcon()\n\n\treturn &application, nil\n}", "func New(cfg config.Configuration) *App {\n\tapp := &App{\n\t\tcommonApp.New(cfg),\n\t}\n\n\treturn app\n}", "func NewApplication() *Application {\n\treturn &Application{\n\t\tevents: make(chan tcell.Event, queueSize),\n\t\tupdates: make(chan func(), queueSize),\n\t\tscreenReplacement: make(chan tcell.Screen, 1),\n\t}\n}", "func NewApplication() {\n\tlog.Info(\"Setting up a new application\")\n\tapp := &application{\n\t\trouter: mux.NewRouter().StrictSlash(true),\n\t\tdb: datastore.NewDBConnection(),\n\t}\n\tapp.routes()\n\tapp.start()\n}", "func NewApplication(ctx *pulumi.Context,\n\tname string, args *ApplicationArgs, opts ...pulumi.ResourceOption) (*Application, error) {\n\tif args == nil {\n\t\targs = &ApplicationArgs{}\n\t}\n\n\treplaceOnChanges := pulumi.ReplaceOnChanges([]string{\n\t\t\"location\",\n\t\t\"project\",\n\t})\n\topts = append(opts, replaceOnChanges)\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Application\n\terr := ctx.RegisterResource(\"google-native:appengine/v1beta:Application\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func New(config config.Config) *App {\n\treturn &App{\n\t\tconfig: config,\n\t\tlog: config.Log(),\n\t}\n}", "func NewApp() *App {\n\treturn &App{}\n}", "func NewApp() *App {\n\treturn &App{}\n}", "func NewApp() *App {\n\treturn &App{}\n}", "func New(config *Config) *App {\n\treturn &App{Config: config}\n}", "func NewApp() *App {\n\tapp := App{}\n\treturn &app\n}", "func NewApp() *App {\n\treturn &App{\n\t\tConfig: &Config{},\n\t}\n}", "func NewApplication(\n\tpeersRepository peers.Repository,\n\tpeersService peers.Service,\n) Application {\n\tpeerBuilder := peer.NewBuilder()\n\tpeersBuilder := peers.NewBuilder()\n\treturn createApplication(\n\t\tpeerBuilder,\n\t\tpeersBuilder,\n\t\tpeersRepository,\n\t\tpeersService,\n\t)\n}", "func NewApplication(\n\tname,\n\tappID,\n\tkey,\n\tsecret string,\n\tonlySSL,\n\tenabled,\n\tuserEvents,\n\twebHooks bool,\n\twebHookURL string,\n) *Application {\n\n\ta := &Application{\n\t\tName: name,\n\t\tAppID: appID,\n\t\tKey: key,\n\t\tSecret: secret,\n\t\tOnlySSL: onlySSL,\n\t\tEnabled: enabled,\n\t\tUserEvents: userEvents,\n\t\tWebHooks: webHooks,\n\t\tURLWebHook: webHookURL,\n\t}\n\n\ta.connections = make(map[string]*connection.Connection)\n\ta.channels = make(map[string]*channel.Channel)\n\ta.Stats = expvar.NewMap(fmt.Sprintf(\"%s (%s)\", a.Name, a.AppID))\n\n\treturn a\n}", "func NewApplication(aOptrions Options) (*Application, error) {\n\tservices := []startable{}\n\n\ttools := processing.NewTools(aOptrions.UploadLocation, aOptrions.PreviewSize)\n\n\tsrv := newServer(aOptrions.Listen, aOptrions.Port, tools)\n\n\tif srv == nil {\n\t\treturn nil, fmt.Errorf(\"Can't create server\")\n\t}\n\n\tservices = append(services, srv)\n\n\treturn &Application{\n\t\tservices: services,\n\t}, nil\n}", "func New(c Config) *App {\n\treturn &App{\n\t\tName: c.Name,\n\t}\n}", "func NewApplication(\n\tconfig Config,\n\ttemplate TemplateEngine,\n) Application {\n\tkbyte := 1024\n\tapp := fiber.New(fiber.Config{\n\t\tPrefork: config.Server.Prefork,\n\t\tStrictRouting: config.Server.Strict,\n\t\tCaseSensitive: config.Server.Case,\n\t\tETag: config.Server.Etag,\n\t\tBodyLimit: config.Server.BodyLimit * kbyte * kbyte,\n\t\tConcurrency: config.Server.Concurrency * kbyte,\n\t\tReadTimeout: config.Server.Timeout.Read * time.Second,\n\t\tWriteTimeout: config.Server.Timeout.Write * time.Second,\n\t\tIdleTimeout: config.Server.Timeout.Idel * time.Second,\n\t\tReadBufferSize: config.Server.Buffer.Read * kbyte,\n\t\tWriteBufferSize: config.Server.Buffer.Write * kbyte,\n\t\tViews: template.Engine,\n\t})\n\treturn Application{\n\t\tApp: app,\n\t\tConfig: config,\n\t}\n}", "func New() (App, error) {\n\tcfg := config.New()\n\n\tdb, err := database.New(cfg)\n\tif err != nil {\n\t\treturn App{}, err\n\t}\n\n\tm, err := metrics.New(metrics.Config{\n\t\tEnvironment: cfg.Environment,\n\t\tHostname: cfg.Hostname,\n\t\tNamespace: \"pharos-api-server\",\n\t\tStatsdHost: cfg.StatsdHost,\n\t\tStatsdPort: cfg.StatsdPort,\n\t})\n\tif err != nil {\n\t\treturn App{}, errors.Wrap(err, \"application\")\n\t}\n\n\ts, err := sentry.New(cfg.SentryDSN)\n\tif err != nil {\n\t\treturn App{}, errors.Wrap(err, \"application\")\n\t}\n\n\tv := token.NewVerifier()\n\n\treturn App{cfg, db, m, s, v}, nil\n}", "func New(appName, version string) *App {\n\treturn createApp(appName, version)\n}", "func NewApplication(s IdentitiesStore) *App {\n\tapp := &App{store : s, Server: fiber.New()}\n\n\tSetupRoutes(app)\n\n\treturn app\n}", "func NewApp() *App {\n\treturn &App{\n\t\tName: filepath.Base(os.Args[0]),\n\t\tUsage: \"A new cli application\",\n\t\tVersion: \"0.0.0\",\n\t\tShowHelp: showHelp,\n\t\tShowVersion: showVersion,\n\t}\n}", "func NewApplication() *Application {\n\tapp := &Application{\n\t\tDB: &ecomdb.DBConnector{},\n\t\tHooks: make(map[string][]Hook),\n\t\tURIHandler: &urihandler.URIHandler{},\n\t}\n\tapp.URIHandler.Init()\n\tapp.DB.Init()\n\treturn app\n}", "func NewApp(name string) (*App, error) {\n\treturn newApp(\"app.\" + name)\n}", "func NewApplication(ctx context.Context, flags *cliFlags) (*application, func(), error) {\n\twire.Build(\n\t\twire.FieldsOf(new(*cliFlags), \"Log\", \"Census\", \"MySQL\", \"Event\", \"Orc8r\"),\n\t\tlog.Provider,\n\t\tnewApplication,\n\t\tnewTenancy,\n\t\tnewHealthChecks,\n\t\tnewMySQLTenancy,\n\t\tnewAuthURL,\n\t\tmysql.Open,\n\t\tevent.Set,\n\t\tgraphhttp.NewServer,\n\t\twire.Struct(new(graphhttp.Config), \"*\"),\n\t\tgraphgrpc.NewServer,\n\t\twire.Struct(new(graphgrpc.Config), \"*\"),\n\t)\n\treturn nil, nil, nil\n}", "func New(config *viper.Viper) (*Application, error) {\n\tcookieStoreSecret := config.Get(\"cookie_secret\").(string)\n\n\tapp := &Application{}\n\tapp.config = config\n\tapp.sessionStore = sessions.NewCookieStore([]byte(cookieStoreSecret))\n\n\treturn app, nil\n}", "func NewApp() *App {\n\tv := new(App)\n\tv.opened = false\n\tv.simType = \"runreset\"\n\tv.status = \"Stopped\"\n\tv.mode = \"Main\"\n\tv.incSize = 10.0\n\tv.decSize = 10.0\n\tv.keyMaps = make([]IKeyMap, 10)\n\tv.keyMaps[0] = NewKeyMap0(v)\n\tv.keyMaps[1] = NewKeyMap1(v)\n\n\treturn v\n}", "func NewApp(f interface{}, args Arguments, info *debug.Info) App {\n\treturn App{f, args, info}\n}", "func NewApp() *App {\n\treturn &App{ver: \"v0\"}\n}", "func New(Store store.Store, options Options) *Application {\n\n\treturn &Application{\n\t\tConfig: &Config{\n\t\t\tStore: Store,\n\t\t\tOMDB: omdb.New(),\n\t\t\tOptions: options,\n\t\t\tDownloader: &imdbPosterDownloader{},\n\t\t},\n\t}\n}", "func NewApp(reader reader.Reader) (*App, error) {\n\tapp := &App{}\n\terr := app.configure(reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn app, nil\n}", "func NewApplication(pgsql postgres.Client, redis core.Application) core.Application {\n\treturn &application{\n\t\tpg: pgsql,\n\t\tmainPg: pgsql.MainDatastore(),\n\t\tredis: redis,\n\t}\n}", "func NewApplication(ctx *pulumi.Context,\n\tname string, args *ApplicationArgs, opts ...pulumi.ResourceOption) (*Application, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.ApplicationName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ApplicationName'\")\n\t}\n\tif args.ClusterId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ClusterId'\")\n\t}\n\tif args.PackageType == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'PackageType'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Application\n\terr := ctx.RegisterResource(\"alicloud:edas/application:Application\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewApp() *App_ {\n\treturn NewApp_WithOverrides(nil)\n}", "func NewApplication(ctx *pulumi.Context,\n\tname string, args *ApplicationArgs, opts ...pulumi.ResourceOption) (*Application, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.ResourceGroupName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ResourceGroupName'\")\n\t}\n\taliases := pulumi.Aliases([]pulumi.Alias{\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabricmesh/v20180701preview:Application\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabricmesh:Application\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabricmesh:Application\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-native:servicefabricmesh/v20180901preview:Application\"),\n\t\t},\n\t\t{\n\t\t\tType: pulumi.String(\"azure-nextgen:servicefabricmesh/v20180901preview:Application\"),\n\t\t},\n\t})\n\topts = append(opts, aliases)\n\tvar resource Application\n\terr := ctx.RegisterResource(\"azure-native:servicefabricmesh/v20180701preview:Application\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func New(repo Repo, cfg Config) *App {\n\ta := &App{\n\t\tcfg: cfg,\n\t\trepo: repo,\n\t}\n\treturn a\n}", "func NewApplication(ctx *pulumi.Context,\n\tname string, args *ApplicationArgs, opts ...pulumi.ResourceOption) (*Application, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.RuntimeEnvironment == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'RuntimeEnvironment'\")\n\t}\n\tif args.ServiceExecutionRole == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'ServiceExecutionRole'\")\n\t}\n\tvar resource Application\n\terr := ctx.RegisterResource(\"aws:kinesisanalyticsv2/application:Application\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewApplication(config *ApplicationConfig) (*Application, error) {\n\n\tif config.ObjectName == \"\" {\n\t\treturn nil, errors.New(\"objectName is required\")\n\t}\n\tif config.ObjectPath == \"\" {\n\t\treturn nil, errors.New(\"objectPath is required\")\n\t}\n\n\tif config.conn == nil {\n\t\tconn, err := dbus.SystemBus()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tconfig.conn = conn\n\t}\n\n\tom, err := NewObjectManager(config.conn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// props, err := NewProperties(config.conn)\n\t// if err != nil {\n\t// \treturn nil, err\n\t// }\n\n\ts := &Application{\n\t\tconfig: config,\n\t\tobjectManager: om,\n\t\tservices: make(map[dbus.ObjectPath]*GattService1),\n\t}\n\n\treturn s, nil\n}", "func NewApplication(id int32, name string, order int32, type_ string, group ApplicationGroup, workspace ApplicationWorkspace) *Application {\n\tthis := Application{}\n\tthis.Id = id\n\tthis.Name = name\n\tthis.Order = order\n\tthis.Type = type_\n\tthis.Group = group\n\tthis.Workspace = workspace\n\treturn &this\n}", "func NewApplication(app *kingpin.Application) ApplicationArguments {\n\treturn ApplicationArguments{\n\t\tApplication: app,\n\t\tlongs: map[string]bool{\n\t\t\t\"help-man\": true,\n\t\t\t\"help-long\": true,\n\t\t\t\"completion-bash\": true,\n\t\t\t\"completion-script-bash\": true,\n\t\t\t\"completion-script-zsh\": true,\n\t\t},\n\t\tshorts: map[rune]bool{},\n\t}\n}", "func NewApp(host string, port int, log logger.Logger, config *viper.Viper) (*App, error) {\n\ta := &App{\n\t\thost: host,\n\t\tport: port,\n\t\tlog: log,\n\t\tconfig: config,\n\t}\n\terr := a.configure()\n\treturn a, err\n}", "func New(descr string) App {\n\treturn &app{descr: descr}\n}", "func NewApp() *App {\n\tpages := ui.NewPageHandler()\n\n\tapp := tview.NewApplication().\n\t\tSetInputCapture(pages.InputCapture()).\n\t\tSetRoot(pages, true)\n\n\treturn &App{\n\t\tPageHandler: pages,\n\t\tapp: app,\n\t}\n}", "func NewApp(cfg *Config) *App {\n\treturn &App{\n\t\tl: log.With().Str(\"m\", \"app\").Logger(),\n\t\tcfg: cfg,\n\t\tgui: gui.NewGui(&cfg.Gui),\n\t}\n}", "func New() *App {\n\tapp := &App{}\n\tapp.readConfig()\n\tapp.container = newContainer(app.Config)\n\n\tapp.initTracer()\n\t// HTTP Server\n\tport, err := strconv.Atoi(app.Config.Get(\"HTTP_PORT\"))\n\tif err != nil || port <= 0 {\n\t\tport = defaultHTTPPort\n\t}\n\n\tapp.httpServer = &httpServer{\n\t\trouter: gofrHTTP.NewRouter(),\n\t\tport: port,\n\t}\n\n\treturn app\n}", "func NewApp(name string) *App {\n\treturn &App{Name: name, Labels: make(map[string]string)}\n}", "func NewApp(config *config.Config) (*App, error) {\n\tapp := &App{Config: config}\n\tapp.Log = logger.NewLogger(config)\n\tapp.Gui = gui.NewGui()\n\treturn app, nil\n\n}", "func NewApp(ctx *pulumi.Context,\n\tname string, args *AppArgs, opts ...pulumi.ResourceOption) (*App, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.AppType == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'AppType'\")\n\t}\n\tif args.DomainId == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'DomainId'\")\n\t}\n\tif args.UserProfileName == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'UserProfileName'\")\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource App\n\terr := ctx.RegisterResource(\"aws-native:sagemaker:App\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewApp(apiKey string, workspaceID int) App {\n\treturn App{APIKey: apiKey, WorkspaceID: workspaceID}\n}", "func NewApp() *App {\n\treturn &App{\n\t\tRequests: make([]Path, 0),\n\t\tHandlers: make(HandlerMap),\n\t\tPrefix: \"/\",\n\t\tMiddlewares: make([]Handler, 0),\n\t\trouteIndex: -1,\n\t\tRouters: make(RouterMap),\n\t}\n}", "func New(options ...Option) Application {\n\topts := &Options{}\n\tfor _, opt := range options {\n\t\topt(opts)\n\t}\n\n\tif opts.StartupTimeout == 0 {\n\t\topts.StartupTimeout = 1000\n\t}\n\tif opts.ShutdownTimeout == 0 {\n\t\topts.ShutdownTimeout = 5000\n\t}\n\n\tif opts.AutoMaxProcs == nil || *opts.AutoMaxProcs {\n\t\tprocsutil.EnableAutoMaxProcs()\n\t}\n\n\tconfig.AppendServiceTag(opts.Tags...)\n\n\tapp := &application{\n\t\tquit: make(chan os.Signal),\n\t\tstartupTimeout: opts.StartupTimeout,\n\t\tshutdownTimeout: opts.ShutdownTimeout,\n\t\tboxes: append(opts.Boxes, &boxMetric{}),\n\t}\n\n\tsignal.Notify(app.quit, syscall.SIGINT, syscall.SIGTERM)\n\n\treturn app\n}", "func NewApp(clientService ClientService, lobby Lobby) *App {\n\treturn &App{clientService, lobby}\n}", "func NewApplication(logger *logger.Logger) *Application {\n\t// Load skeefree-specific config:\n\tcfg := &skconfig.Config{}\n\tif err := config.Load(cfg); err != nil {\n\t\tpanic(fmt.Sprintf(\"error loading skeefree configuration: %s\", err))\n\t}\n\tbackend, err := db.NewBackend(cfg)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error creating backend: %s\", err))\n\t}\n\tghAPI, err := ghapi.NewGitHubAPI(cfg)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error creating github client: %s\", err))\n\t}\n\tsitesAPI, err := gh.NewSitesAPI(cfg)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error creating sites api client: %s\", err))\n\t}\n\tmysqlDiscoveryAPI, err := gh.NewMySQLDiscoveryAPI(cfg)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error creating mysql discovery api client: %s\", err))\n\t}\n\tscheduler := NewScheduler(cfg, logger, backend, sitesAPI, mysqlDiscoveryAPI)\n\tdirectApplier := NewDirectApplier(cfg, logger, backend, mysqlDiscoveryAPI)\n\treturn &Application{\n\t\tLogger: logger,\n\t\tcfg: cfg,\n\t\tbackend: backend,\n\t\tghAPI: ghAPI,\n\t\tsitesAPI: sitesAPI,\n\t\tmysqlDiscoveryAPI: mysqlDiscoveryAPI,\n\t\tscheduler: scheduler,\n\t\tdirectApplier: directApplier,\n\t}\n}", "func NewApp() *App {\n\treturn NewAppWithConfig(AppConfig{})\n}", "func New() (*App, error) {\n\tcfg := Config{}\n\ta := &App{\n\t\tcfg: &cfg,\n\t}\n\terr := env.Parse(&cfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse ENV: %v\", err)\n\t}\n\treturn a, nil\n}", "func New() *App {\n\te := echo.New()\n\tbindMiddlewares(e)\n\tbindRoutes(e)\n\n\treturn &App{\n\t\tEcho: e,\n\t}\n}", "func NewApp(ctx context.Context, config Config) (*App, error) {\n\tcctx, cancel := context.WithCancel(ctx)\n\tg, gctx := errgroup.WithContext(cctx)\n\n\tapp := &App{\n\t\tConfig: config,\n\n\t\tcancel: cancel,\n\t\tctx: gctx,\n\t\tgroup: g,\n\n\t\terrors: make(chan Error),\n\t\treplies: make(chan osc.Message),\n\t}\n\tif err := app.initialize(); err != nil {\n\t\treturn nil, errors.Wrap(err, \"could not initialize app\")\n\t}\n\treturn app, nil\n}", "func NewApplication(ldr loader.Loader, fSys fs.FileSystem) (*Application, error) {\n\tcontent, err := ldr.Load(constants.KustomizationFileName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar m types.Kustomization\n\terr = unmarshal(content, &m)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Application{kustomization: &m, ldr: ldr, fSys: fSys}, nil\n}", "func CreateApplication() *Alpha {\n app := &Alpha{}\n app.Request = &Request{}\n app.Response = &Response{}\n app.init()\n return app\n}", "func NewApp(listenAddr string, ghClient *githubclient.Client, cache cache.Cache, objTTL time.Duration) App {\n\treturn App{\n\t\tlistenAddr: listenAddr,\n\t\tghClient: ghClient,\n\t\tcache: cache,\n\t\tcacheObjTTL: objTTL,\n\t}\n}", "func New(opts Options) *App {\n\topts = optionsWithDefaults(opts)\n\n\ta := &App{\n\t\tOptions: opts,\n\t\tMiddleware: newMiddlewareStack(),\n\t\tErrorHandlers: ErrorHandlers{\n\t\t\t404: defaultErrorHandler,\n\t\t\t500: defaultErrorHandler,\n\t\t},\n\t\trouter: mux.NewRouter(),\n\t\tmoot: &sync.Mutex{},\n\t\troutes: RouteList{},\n\t\tchildren: []*App{},\n\t}\n\ta.router.NotFoundHandler = http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {\n\t\tc := a.newContext(RouteInfo{}, res, req)\n\t\terr := errors.Errorf(\"path not found: %s\", req.URL.Path)\n\t\ta.ErrorHandlers.Get(404)(404, err, c)\n\t})\n\n\treturn a\n}", "func New(argConfig *Config) (*App, error) {\n\t// initiate the app and give it initial values\n\tapp := &App{}\n\tif len(argConfig.Directories) <= 0 {\n\t\td, _ := os.Getwd()\n\t\targConfig.Directories = []string{d}\n\t}\n\tpresetConfig, err := loadConfiguration()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tapp.Config = overrideConfig(presetConfig, argConfig)\n\n\treturn app, nil\n}", "func NewApp(kubeConfig, kubeContext string) (*App, error) {\n\t// Initialize a service catalog client\n\t_, cl, err := getKubeClient(kubeConfig, kubeContext)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tapp := &App{\n\t\tSDK: &servicecatalog.SDK{\n\t\t\tServiceCatalogClient: cl,\n\t\t},\n\t}\n\n\treturn app, nil\n}", "func NewCmdNewApplication(f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {\n\to := NewAppOptions(streams)\n\n\tcmd := &cobra.Command{\n\t\tUse: \"new-app (IMAGE | IMAGESTREAM | TEMPLATE | PATH | URL ...)\",\n\t\tShort: \"Create a new application\",\n\t\tLong: newAppLong,\n\t\tExample: newAppExample,\n\t\tSuggestFor: []string{\"app\", \"application\"},\n\t\tRun: func(c *cobra.Command, args []string) {\n\t\t\tkcmdutil.CheckErr(o.Complete(f, c, args))\n\t\t\tkcmdutil.CheckErr(o.RunNewApp())\n\t\t},\n\t}\n\n\to.PrintFlags.AddFlags(cmd)\n\n\tcmd.Flags().BoolVar(&o.Config.AsTestDeployment, \"as-test\", o.Config.AsTestDeployment, \"If true create this application as a test deployment, which validates that the deployment succeeds and then scales down.\")\n\tcmd.Flags().BoolVar(&o.Config.DeploymentConfig, \"as-deployment-config\", o.Config.DeploymentConfig, \"If true create this application as a deployment config, which allows for hooks and custom strategies.\")\n\tcmd.Flags().StringSliceVar(&o.Config.SourceRepositories, \"code\", o.Config.SourceRepositories, \"Source code to use to build this application.\")\n\tcmd.Flags().StringVar(&o.Config.ContextDir, \"context-dir\", o.Config.ContextDir, \"Context directory to be used for the build.\")\n\tcmd.Flags().StringSliceVarP(&o.Config.ImageStreams, \"image-stream\", \"i\", o.Config.ImageStreams, \"Name of an existing image stream to use to deploy an app.\")\n\tcmd.Flags().StringSliceVar(&o.Config.DockerImages, \"image\", o.Config.DockerImages, \"Name of a container image to include in the app. Note: not specifying a registry or repository means defaults in place for client image pulls are employed.\")\n\tcmd.Flags().StringSliceVar(&o.Config.DockerImages, \"docker-image\", o.Config.DockerImages, \"\")\n\tcmd.Flags().MarkDeprecated(\"docker-image\", \"Deprecated flag use --image\")\n\tcmd.Flags().StringSliceVar(&o.Config.Templates, \"template\", o.Config.Templates, \"Name of a stored template to use in the app.\")\n\tcmd.Flags().StringSliceVarP(&o.Config.TemplateFiles, \"file\", \"f\", o.Config.TemplateFiles, \"Path to a template file to use for the app.\")\n\tcmd.MarkFlagFilename(\"file\", \"yaml\", \"yml\", \"json\")\n\tcmd.Flags().StringArrayVarP(&o.Config.TemplateParameters, \"param\", \"p\", o.Config.TemplateParameters, \"Specify a key-value pair (e.g., -p FOO=BAR) to set/override a parameter value in the template.\")\n\tcmd.Flags().StringArrayVar(&o.Config.TemplateParameterFiles, \"param-file\", o.Config.TemplateParameterFiles, \"File containing parameter values to set/override in the template.\")\n\tcmd.MarkFlagFilename(\"param-file\")\n\tcmd.Flags().StringSliceVar(&o.Config.Groups, \"group\", o.Config.Groups, \"Indicate components that should be grouped together as <comp1>+<comp2>.\")\n\tcmd.Flags().StringArrayVarP(&o.Config.Environment, \"env\", \"e\", o.Config.Environment, \"Specify a key-value pair for an environment variable to set into each container.\")\n\tcmd.Flags().StringArrayVar(&o.Config.EnvironmentFiles, \"env-file\", o.Config.EnvironmentFiles, \"File containing key-value pairs of environment variables to set into each container.\")\n\tcmd.MarkFlagFilename(\"env-file\")\n\tcmd.Flags().StringArrayVar(&o.Config.BuildEnvironment, \"build-env\", o.Config.BuildEnvironment, \"Specify a key-value pair for an environment variable to set into each build image.\")\n\tcmd.Flags().StringArrayVar(&o.Config.BuildEnvironmentFiles, \"build-env-file\", o.Config.BuildEnvironmentFiles, \"File containing key-value pairs of environment variables to set into each build image.\")\n\tcmd.MarkFlagFilename(\"build-env-file\")\n\tcmd.Flags().StringVar(&o.Config.Name, \"name\", o.Config.Name, \"Set name to use for generated application artifacts\")\n\tcmd.Flags().Var(&o.Config.Strategy, \"strategy\", \"Specify the build strategy to use if you don't want to detect (docker|pipeline|source). NOTICE: the pipeline strategy is deprecated; consider using Jenkinsfiles directly on Jenkins or OpenShift Pipelines.\")\n\tcmd.Flags().StringP(\"labels\", \"l\", \"\", \"Label to set in all resources for this application.\")\n\tcmd.Flags().BoolVar(&o.Config.IgnoreUnknownParameters, \"ignore-unknown-parameters\", o.Config.IgnoreUnknownParameters, \"If true, will not stop processing if a provided parameter does not exist in the template.\")\n\tcmd.Flags().BoolVar(&o.Config.InsecureRegistry, \"insecure-registry\", o.Config.InsecureRegistry, \"If true, indicates that the referenced container images are on insecure registries and should bypass certificate checking\")\n\tcmd.Flags().BoolVarP(&o.Config.AsList, \"list\", \"L\", o.Config.AsList, \"List all local templates and image streams that can be used to create.\")\n\tcmd.Flags().BoolVarP(&o.Config.AsSearch, \"search\", \"S\", o.Config.AsSearch, \"Search all templates, image streams, and container images that match the arguments provided. Note: the container images search is run on the OpenShift cluster via the ImageStreamImport API.\")\n\tcmd.Flags().BoolVar(&o.Config.AllowMissingImages, \"allow-missing-images\", o.Config.AllowMissingImages, \"If true, indicates that referenced container images that cannot be found locally or in a registry should still be used.\")\n\tcmd.Flags().BoolVar(&o.Config.AllowMissingImageStreamTags, \"allow-missing-imagestream-tags\", o.Config.AllowMissingImageStreamTags, \"If true, indicates that image stream tags that don't exist should still be used.\")\n\tcmd.Flags().BoolVar(&o.Config.AllowSecretUse, \"grant-install-rights\", o.Config.AllowSecretUse, \"If true, a component that requires access to your account may use your token to install software into your project. Only grant images you trust the right to run with your token.\")\n\tcmd.Flags().StringVar(&o.Config.SourceSecret, \"source-secret\", o.Config.SourceSecret, \"The name of an existing secret that should be used for cloning a private git repository.\")\n\tcmd.Flags().BoolVar(&o.Config.SkipGeneration, \"no-install\", o.Config.SkipGeneration, \"Do not attempt to run images that describe themselves as being installable\")\n\tcmd.Flags().BoolVar(&o.Config.BinaryBuild, \"binary\", o.Config.BinaryBuild, \"Instead of expecting a source URL, set the build to expect binary contents. Will disable triggers.\")\n\tcmd.Flags().StringVar(&o.Config.ImportMode, \"import-mode\", o.Config.ImportMode, \"Imports the full manifest list of a tag when set to 'PreserveOriginal'. Defaults to 'Legacy'.\")\n\n\to.Action.BindForOutput(cmd.Flags(), \"output\", \"template\")\n\tcmd.Flags().String(\"output-version\", \"\", \"The preferred API versions of the output objects\")\n\n\treturn cmd\n}", "func NewApp(name string) (*App, error) {\n\tvar (\n\t\tconfig Config\n\t\tflagset = flag.NewFlagSet(name, flagErrorHandling)\n\t)\n\tif err := flagset.Parse(os.Args[1:]); err != nil {\n\t\tif err == flag.ErrHelp {\n\t\t\treturn &App{pass: true}, nil\n\t\t}\n\t\treturn nil, errors.Wrap(err, \"parsing flags\")\n\t}\n\treturn NewAppFrom(name, config)\n}", "func New(db fsdb.DB, indexer *index.StudyIndexer) *App {\n\treturn &App{\n\t\tFsDB: db,\n\t\tIndexer: indexer,\n\t}\n}", "func NewApp(g Generator) *App {\n\treturn &App{gene: g}\n}", "func NewApp() App {\n\tapp := App{}\n\tapp.craterRequestHandler = newCraterHandler()\n\tapp.htmlTemplates = &craterTemplate{}\n\tapp.middleware = make([]handlerFunc, 0)\n\tapp.craterRouter = new(router)\n\tapp.settings = DefaultSettings()\n\n\treturn app\n}", "func (t *UseCase_UseCase_UseCase) NewApplication(Application string) (*UseCase_UseCase_UseCase_Application, error){\n\n\t// Initialise the list within the receiver struct if it has not already been\n\t// created.\n\tif t.Application == nil {\n\t\tt.Application = make(map[string]*UseCase_UseCase_UseCase_Application)\n\t}\n\n\tkey := Application\n\n\t// Ensure that this key has not already been used in the\n\t// list. Keyed YANG lists do not allow duplicate keys to\n\t// be created.\n\tif _, ok := t.Application[key]; ok {\n\t\treturn nil, fmt.Errorf(\"duplicate key %v for list Application\", key)\n\t}\n\n\tt.Application[key] = &UseCase_UseCase_UseCase_Application{\n\t\tApplication: &Application,\n\t}\n\n\treturn t.Application[key], nil\n}", "func NewApplication(app sdk.Application, keys []EncryptedKey) (a Application, err error) {\n\ta.Version = ApplicationVersion1\n\ta.Name = app.Name\n\ta.Description = app.Description\n\n\tif app.VCSServer != \"\" {\n\t\ta.VCSServer = app.VCSServer\n\t\ta.RepositoryName = app.RepositoryFullname\n\t}\n\n\ta.Variables = make(map[string]VariableValue, len(app.Variables))\n\tfor _, v := range app.Variables {\n\t\tat := v.Type\n\t\tif at == \"string\" {\n\t\t\tat = \"\"\n\t\t}\n\t\ta.Variables[v.Name] = VariableValue{\n\t\t\tType: at,\n\t\t\tValue: v.Value,\n\t\t}\n\t}\n\n\ta.Keys = make(map[string]KeyValue, len(keys))\n\tfor _, e := range keys {\n\t\ta.Keys[e.Name] = KeyValue{\n\t\t\tType: e.Type,\n\t\t\tValue: e.Content,\n\t\t}\n\t}\n\n\ta.VCSPGPKey = app.RepositoryStrategy.PGPKey\n\ta.VCSConnectionType = app.RepositoryStrategy.ConnectionType\n\tif app.RepositoryStrategy.ConnectionType == \"ssh\" {\n\t\ta.VCSSSHKey = app.RepositoryStrategy.SSHKey\n\t\ta.VCSUser = \"\"\n\t\ta.VCSPassword = \"\"\n\t} else {\n\t\ta.VCSSSHKey = \"\"\n\t\ta.VCSUser = app.RepositoryStrategy.User\n\t\ta.VCSPassword = app.RepositoryStrategy.Password\n\t}\n\n\tif app.RepositoryStrategy.ConnectionType != \"https\" {\n\t\ta.VCSConnectionType = app.RepositoryStrategy.ConnectionType\n\t}\n\ta.VCSPGPKey = app.RepositoryStrategy.PGPKey\n\n\ta.DeploymentStrategies = make(map[string]map[string]VariableValue, len(app.DeploymentStrategies))\n\tfor name, config := range app.DeploymentStrategies {\n\t\tvars := make(map[string]VariableValue, len(config))\n\t\tfor k, v := range config {\n\t\t\tvars[k] = VariableValue{\n\t\t\t\tType: v.Type,\n\t\t\t\tValue: v.Value,\n\t\t\t}\n\t\t}\n\t\ta.DeploymentStrategies[name] = vars\n\t}\n\n\treturn a, nil\n}", "func NewApplication(dbPath string) *Application {\n\tapp := &Application{}\n\n\tfile, err := os.OpenFile(\"error.log\", os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644)\n\tkill(err)\n\tapp.Log = log.New(file, \"\", log.LstdFlags)\n\tapp.logfile = file\n\n\tdb, err := sqlx.Open(\"sqlite3\", dbPath)\n\tif err != nil {\n\t\tapp.Log.Println(err)\n\t\tos.Exit(1)\n\t}\n\tapp.DB = db\n\n\tapp.setupRoutes()\n\n\treturn app\n}", "func NewApp(config gettConfig.AppConfig, handler http.Handler, logger *logrus.Logger, pingers []healthcheck.Pinger) App {\n\tapp := App{\n\t\tconfig: config,\n\t\thandler: handler,\n\t\tlogger: logger,\n\t\tpingers: pingers,\n\t}\n\n\tgettOps.InitOps()\n\n\tlog.SetFlags(0)\n\tlog.Print(skeletonBanner)\n\tlog.SetFlags(log.LstdFlags)\n\n\treturn app\n}", "func (t *Application_Application) NewApplication(Id string) (*Application_Application_Application, error){\n\n\t// Initialise the list within the receiver struct if it has not already been\n\t// created.\n\tif t.Application == nil {\n\t\tt.Application = make(map[string]*Application_Application_Application)\n\t}\n\n\tkey := Id\n\n\t// Ensure that this key has not already been used in the\n\t// list. Keyed YANG lists do not allow duplicate keys to\n\t// be created.\n\tif _, ok := t.Application[key]; ok {\n\t\treturn nil, fmt.Errorf(\"duplicate key %v for list Application\", key)\n\t}\n\n\tt.Application[key] = &Application_Application_Application{\n\t\tId: &Id,\n\t}\n\n\treturn t.Application[key], nil\n}", "func NewApp(shutdown chan os.Signal, mw ...Middleware) *App {\n\tapp := &App{\n\t\tRouter: mux.NewRouter(),\n\t\tshutdown: shutdown,\n\t\tmw: mw,\n\t}\n\n\treturn app\n}", "func NewApp() *App {\n\tlogger := Log.With(zap.String(\"type\", \"app\")).Sugar()\n\tetcd := embed.NewServer(Config, Log)\n\tws := ws.NewServer(Config, Log)\n\tapp := &App{\n\t\tcfg: Config,\n\t\tlogger: logger,\n\t\tetcd: etcd,\n\t\tws: ws,\n\t\trepo: repository.NewRepo(),\n\t\tstopch: make(chan struct{}),\n\t}\n\tapp.scheduler = NewScheduler(Log, app)\n\treturn app\n}", "func New(config *Config, modules *Modules) *App {\n\teosws.DisabledWsMessage = config.DisabledWsMessage\n\treturn &App{\n\t\tShutter: shutter.New(),\n\t\tConfig: config,\n\t\tModules: modules,\n\t}\n\n}", "func New(opt *Options) *Application {\n\tr := mux.NewRouter()\n\treturn &Application{\n\t\tr: r,\n\t\tserv: &http.Server{\n\t\t\tAddr: \":8120\",\n\t\t\tReadTimeout: time.Duration(opt.Serv.ReadTimeout),\n\t\t\tIdleTimeout: time.Duration(opt.Serv.IdleTimeout),\n\t\t\tWriteTimeout: time.Duration(opt.Serv.WriteTimeout),\n\t\t\tHandler: r,\n\t\t},\n\t\thashSum: opt.HashSum,\n\t\tsvc: opt.Svc,\n\t\tpr: opt.Pr,\n\t\tlogger: opt.Logger,\n\t}\n}", "func NewApp() *App {\n\treturn &App{\n\t\tserver: &http.Server{\n\t\t\tHandler: http.NewServeMux(),\n\t\t},\n\t}\n}", "func newApp(name string) (app *App, err error) {\n\tapp = &App{\n\t\tName: name,\n\t\tID: uuid.NewV5(namespace, \"org.homealone.\"+name).String(),\n\t\thandler: make(map[queue.Topic]message.Handler),\n\t\tdebug: *debug,\n\t\tfilterMessages: true,\n\t}\n\tapp.Log = log.NewLogger().With(log.Fields{\"app\": name, \"id\": app.ID})\n\treturn app, errors.Wrap(err, \"newApp failed\")\n}", "func App() *Application {\n\treturn &app\n}", "func NewApp(\n\thost string, port int,\n\tconfig *viper.Viper,\n\tlogger *logrus.Logger,\n\tstorageAdapter storage.Adapter,\n\tcollector *logger.LogCollector,\n\tunsecure bool) (*App, error) {\n\ta := &App{\n\t\tConfig: config,\n\t\tAddress: fmt.Sprintf(\"%s:%d\", host, port),\n\t\tLogger: logger,\n\t\tstorageAdapter: storageAdapter,\n\t\tEmailDomain: config.GetStringSlice(\"oauth.acceptedDomains\"),\n\t\tUnsecure: unsecure,\n\t\tCollector: collector,\n\t}\n\terr := a.configureApp()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn a, nil\n}", "func NewApp(logger *logrus.Logger, shutdown chan os.Signal, mw ...Middleware) *App {\n\treturn &App{\n\t\tlogger: logger,\n\t\tshutdown: shutdown,\n\t\trouter: router.New(),\n\t\tmiddlewares: mw,\n\t}\n}", "func NewApp(dbname, dburl, slackSetLocationToken, slackWhereIsToken, slackReqToken string) *App {\n\ta := App{}\n\n\ta.Router = gin.Default()\n\n\ta.SlackSetLocationToken = slackSetLocationToken\n\n\ta.SlackWhereIsToken = slackWhereIsToken\n\n\ta.SlackRequestToken = slackReqToken\n\n\ta.initialiseRoutes()\n\n\tdialled := false\n\tcount := 1\n\n\tfor dialled == false {\n\t\tfmt.Printf(\"Connecting to database, attempt %v\\n\", count)\n\t\ts, err := mgo.Dial(dburl)\n\n\t\tif err != nil {\n\t\t\tfmt.Println(\"Error: \" + err.Error())\n\t\t\tfmt.Println(\"Retrying...\")\n\t\t} else {\n\t\t\tfmt.Println(\"Connected!\")\n\t\t\tdialled = true\n\t\t\ta.DB = s.DB(dbname)\n\t\t}\n\n\t\ttime.Sleep(2 * time.Second)\n\n\t\tif count > 5 {\n\t\t\tfmt.Printf(\"Tried to connect %v times. Exiting program\\n\", count)\n\t\t\tos.Exit(1)\n\t\t}\n\t\tcount++\n\t}\n\n\treturn &a\n}", "func New(db *db.DB, gameService game.Service, userService user.Service) *App {\n\treturn &App{\n\t\tdb: db,\n\t\tgameService: gameService,\n\t\tuserService: userService,\n\t}\n}", "func NewApp() *App {\n\treturn (*App)(web.NewHttpSever())\n}", "func NewApp() *App {\n\tapp := &App{\n\t\tTodoList: &TodoList{},\n\t\tPrinter: NewScreenPrinter(true),\n\t\tTodoStore: NewFileStore(),\n\t}\n\treturn app\n}", "func New(c *deis.Client, appID string) (api.App, error) {\n\tbody := []byte{}\n\n\tif appID != \"\" {\n\t\treq := api.AppCreateRequest{ID: appID}\n\t\tb, err := json.Marshal(req)\n\n\t\tif err != nil {\n\t\t\treturn api.App{}, err\n\t\t}\n\t\tbody = b\n\t}\n\n\tres, reqErr := c.Request(\"POST\", \"/v2/apps/\", body)\n\tif reqErr != nil && !deis.IsErrAPIMismatch(reqErr) {\n\t\treturn api.App{}, reqErr\n\t}\n\tdefer res.Body.Close()\n\n\tapp := api.App{}\n\tif err := json.NewDecoder(res.Body).Decode(&app); err != nil {\n\t\treturn api.App{}, err\n\t}\n\n\treturn app, reqErr\n}" ]
[ "0.8507224", "0.8236647", "0.8201647", "0.8193408", "0.7851466", "0.77492255", "0.7746956", "0.7736586", "0.76904875", "0.76795036", "0.76363564", "0.75912136", "0.7583377", "0.7583377", "0.7543192", "0.7496061", "0.74459046", "0.74452597", "0.7433334", "0.741236", "0.7368086", "0.7355004", "0.7355004", "0.7355004", "0.7350911", "0.73459184", "0.7343371", "0.7329996", "0.7325362", "0.7299379", "0.7219413", "0.71790314", "0.71754575", "0.7154805", "0.7113156", "0.7101411", "0.70980567", "0.70970297", "0.7095112", "0.7085377", "0.70692885", "0.7060511", "0.7043304", "0.7036809", "0.70295817", "0.7027033", "0.7026207", "0.7016456", "0.7003146", "0.6963773", "0.6962445", "0.69608647", "0.690549", "0.6881647", "0.6877121", "0.685325", "0.68484896", "0.6842147", "0.6836493", "0.6836079", "0.6831666", "0.6825709", "0.68243796", "0.6793641", "0.6790166", "0.67839724", "0.6779164", "0.6765357", "0.67644006", "0.67570794", "0.67466736", "0.6746496", "0.6714062", "0.66948795", "0.6689046", "0.6678881", "0.66716385", "0.6671299", "0.6663282", "0.66588384", "0.6658343", "0.66549665", "0.66505677", "0.66489494", "0.66488105", "0.6646596", "0.6646209", "0.66453207", "0.6636701", "0.66179097", "0.66010094", "0.6586056", "0.65849966", "0.65726227", "0.6571301", "0.656838", "0.6564514", "0.6563152", "0.65605944", "0.6558643", "0.6548703" ]
0.0
-1
Run starts TUI application.
func (app *Application) Run() error { go func() { for { todos := <-app.subscriber app.Update(todos) } }() return app.Application.Run() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (tui *TUI) Run() error {\n\treturn tui.app.SetRoot(tui.window, true).Run()\n}", "func (app *App) Run() error {\n\tgo func() {\n\t\t<-app.Quit\n\t\tapp.app.Stop()\n\t}()\n\n\tui.SetConsoleTitle(\"RazTracer\")\n\n\treturn app.app.SetFocus(app).Run()\n}", "func runTUI() error {\n\n\t// Set function to manage all views and keybindings\n\tclientGui.SetManagerFunc(layout)\n\n\t// Bind keys with functions\n\t_ = clientGui.SetKeybinding(\"\", gocui.KeyCtrlC, gocui.ModNone, quit)\n\t_ = clientGui.SetKeybinding(\"input\", gocui.KeyEnter, gocui.ModNone, send)\n\n\t// Start main event loop of the TUI\n\treturn clientGui.MainLoop()\n}", "func (t *tui) Run(done, ready chan bool) {\n\tt.ready = ready\n\n\tlog.Tracef(\"creating UI\")\n\tvar err error\n\tt.g, err = gotui.NewGui(gotui.Output256)\n\tif err != nil {\n\t\tlog.Criticalf(\"unable to create ui: %v\", err)\n\t\tos.Exit(2)\n\t}\n\tdefer t.g.Close()\n\n\tt.g.Cursor = true\n\tt.g.Mouse = t.client.Config.Client.UI.Mouse\n\n\tt.g.SetManagerFunc(t.layout)\n\tt.g.SetResizeFunc(t.onResize)\n\n\tlog.Tracef(\"adding keybindings\")\n\tif err := t.keybindings(t.g); err != nil {\n\t\tlog.Criticalf(\"ui couldn't create keybindings: %v\", err)\n\t\tos.Exit(2)\n\t}\n\n\tlog.Tracef(\"listening for signals\")\n\tt.listener = make(chan signal.Signal)\n\tgo t.listen()\n\tt.client.Env.AddListener(\"ui\", t.listener)\n\n\tlog.Tracef(\"running UI...\")\n\tif err := t.g.MainLoop(); err != nil && err != gotui.ErrQuit {\n\t\tt.errs.Close()\n\t\tlog.Criticalf(\"ui unexpectedly quit: %s: %s\", err, errgo.Details(err))\n\t\tfmt.Printf(\"Oh no! Something went very wrong :( Here's all we know: %s: %s\\n\", err, errgo.Details(err))\n\t\tfmt.Println(\"Your connections will all close gracefully and any logs properly closed out.\")\n\t}\n\tt.client.CloseAll()\n\tdone <- true\n}", "func (a *App) Run() error {\n\tdirs := generateDirectories(a.Config.Directories, a.Config.Depth)\n\tif a.Config.QuickMode {\n\t\treturn a.execQuickMode(dirs)\n\t}\n\t// create a gui.Gui struct and run the gui\n\tgui, err := gui.New(a.Config.Mode, dirs)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn gui.Run()\n}", "func Run() {\n\tlog.Printf(\"[%s] starting ui\", tag)\n\n\t// stream list\n\tstreamList := cview.NewList()\n\tstreamList.\n\t\tClear().\n\t\tSetHighlightFullLine(true).\n\t\tShowSecondaryText(false).\n\t\tSetBorder(true).\n\t\tSetBorderColor(tcell.ColorBlue).\n\t\tSetTitle(\" 📻 streams \").\n\t\tSetTitleAlign(cview.AlignLeft)\n\n\tfor _, stationID := range streams.StreamStationIDs {\n\t\tstreamList.AddItem(streams.Streams[stationID].Stream, \"\", 0, nil)\n\t}\n\n\t// now playing\n\tnowplaying := cview.NewTextView()\n\tnowplaying.\n\t\tSetText(\"...\").\n\t\tSetTextAlign(cview.AlignCenter).\n\t\tSetTitle(\" 🎵 now playing \").\n\t\tSetTitleAlign(cview.AlignLeft).\n\t\tSetBorderColor(tcell.ColorOrange).\n\t\tSetBorder(true)\n\n\tstreamList.SetSelectedFunc(func(idx int, maintext string, secondarytext string, shortcut rune) {\n\t\tlog.Printf(\"[%s] selected stream changed\", tag)\n\n\t\tstationID := streams.StreamStationIDs[idx]\n\t\turl := \"http:\" + streams.Streams[stationID].URLHigh\n\t\tnowplaying.SetText(streams.Streams[stationID].Stream)\n\n\t\tlog.Printf(\"[%s] playing %s from url %s\", tag, streams.Streams[stationID].Stream, url)\n\t\tplayer.Stop()\n\t\tplayer.Play(url)\n\t})\n\n\t// main layout\n\tflex := cview.NewFlex().\n\t\tSetDirection(cview.FlexRow).\n\t\tAddItem(streamList, 0, 1, true).\n\t\tAddItem(nowplaying, 3, 1, false)\n\n\tapp.SetInputCapture(handleKeyEvent)\n\tif err := app.SetRoot(flex, true).Run(); err != nil {\n\t\tlog.Fatalf(\"[%s] ui initialization failed: %d\", tag, err)\n\t}\n}", "func (v *Viewer) Run(ctx context.Context) {\n\tv.ui.Run()\n}", "func (tui *TUI) Start() error {\n\treturn tui.App.SetRoot(tui.Grid, true).EnableMouse(true).Run()\n}", "func (m *Maker) Run(t *testing.T, userCalls ...func(*testing.T, gtk.Widgetter)) {\n\tvar w gtk.Widgetter // stores the widget to provide for all calls.\n\tcalls := make([]interface{}, len(userCalls)+1)\n\tcalls[0] = func() gtk.Widgetter {\n\t\tw = m.newW()\n\t\treturn w\n\t}\n\tfor i, call := range userCalls {\n\t\tcalls[i+1] = func() { call(t, w) }\n\t}\n\tm.app.ID = fmt.Sprintf(\"%s%d\", m.baseID, m.counter)\n\tm.counter++\n\tm.app.Run(calls...)\n}", "func (app *App) Run() (err error) {\n\treturn app.Renderer.Run()\n}", "func Run(app App) error {\n\t// -------------------------------------------------------------------- //\n\t// Create\n\t// -------------------------------------------------------------------- //\n\tsettings := defaultSettings\n\terr := app.OnCreate(&settings)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tpanic(err)\n\t}\n\n\t// -------------------------------------------------------------------- //\n\t// Init\n\t// -------------------------------------------------------------------- //\n\tjsTge := js.Global().Get(\"tge\")\n\tif settings.Fullscreen {\n\t\tjsTge.Call(\"setFullscreen\", settings.Fullscreen)\n\t} else {\n\t\tjsTge.Call(\"resize\", settings.Width, settings.Height)\n\t}\n\n\tcanvas := jsTge.Call(\"init\")\n\n\t// Instanciate Runtime\n\tbrowserRuntime := _runtimeInstance.(*browserRuntime)\n\tbrowserRuntime.app = app\n\tbrowserRuntime.canvas = &canvas\n\tbrowserRuntime.jsTge = &jsTge\n\tbrowserRuntime.settings = settings\n\tbrowserRuntime.isPaused = true\n\tbrowserRuntime.isStopped = true\n\tbrowserRuntime.done = make(chan bool)\n\n\t// Init plugins\n\tinitPlugins()\n\n\t// Start App\n\terr = app.OnStart(browserRuntime)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tpanic(err)\n\t}\n\tbrowserRuntime.isStopped = false\n\n\t// Resume App\n\tapp.OnResume()\n\tbrowserRuntime.isPaused = false\n\n\t// Resize App\n\tpublish(ResizeEvent{int32(browserRuntime.canvas.Get(\"clientWidth\").Int()),\n\t\tint32(browserRuntime.canvas.Get(\"clientHeight\").Int())})\n\n\t// -------------------------------------------------------------------- //\n\t// Ticker Loop\n\t// -------------------------------------------------------------------- //\n\tsyncChan := make(chan interface{})\n\telapsedTpsTime := time.Duration(0)\n\tgo func() {\n\t\tfor !browserRuntime.isStopped {\n\t\t\tif !browserRuntime.isPaused {\n\t\t\t\tnow := time.Now()\n\t\t\t\tapp.OnTick(elapsedTpsTime, syncChan)\n\t\t\t\telapsedTpsTime = time.Since(now)\n\t\t\t}\n\t\t}\n\t}()\n\n\t// -------------------------------------------------------------------- //\n\t// Callbacks\n\t// -------------------------------------------------------------------- //\n\n\t// Resize\n\tresizeEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\tif !browserRuntime.isStopped {\n\t\t\tw := int32(browserRuntime.canvas.Get(\"clientWidth\").Int())\n\t\t\th := int32(browserRuntime.canvas.Get(\"clientHeight\").Int())\n\t\t\tjsTge.Call(\"resize\", w, h)\n\t\t\tpublish(ResizeEvent{\n\t\t\t\tWidth: w,\n\t\t\t\tHeight: h,\n\t\t\t})\n\t\t}\n\t\treturn false\n\t})\n\tdefer resizeEvtCb.Release()\n\tjs.Global().Call(\"addEventListener\", \"resize\", resizeEvtCb)\n\n\t// Focus\n\tblurEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\tgo func() {\n\t\t\t\tbrowserRuntime.isPaused = true\n\t\t\t\tbrowserRuntime.app.OnPause()\n\t\t\t}()\n\t\t}\n\t\treturn false\n\t})\n\tdefer blurEvtCb.Release()\n\tbrowserRuntime.canvas.Call(\"addEventListener\", \"blur\", blurEvtCb)\n\n\tfocuseEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\tif !browserRuntime.isStopped && browserRuntime.isPaused {\n\t\t\t//Called in go routine in case of asset loading in resume (blocking)\n\t\t\tgo func() {\n\t\t\t\tbrowserRuntime.app.OnResume()\n\t\t\t\tbrowserRuntime.isPaused = false\n\t\t\t}()\n\t\t}\n\t\treturn false\n\t})\n\tdefer focuseEvtCb.Release()\n\tbrowserRuntime.canvas.Call(\"addEventListener\", \"focus\", focuseEvtCb)\n\n\t// Destroy\n\tbeforeunloadEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\tif !browserRuntime.isStopped {\n\t\t\tbrowserRuntime.Stop()\n\t\t}\n\t\treturn false\n\t})\n\tdefer beforeunloadEvtCb.Release()\n\tjs.Global().Call(\"addEventListener\", \"beforeunload\", beforeunloadEvtCb)\n\n\t// MouseButtonEvent\n\tif (settings.EventMask & MouseButtonEventEnabled) != 0 {\n\t\tmouseDownEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\t\tevent := args[0]\n\t\t\t\tbutton := ButtonNone\n\t\t\t\tswitch event.Get(\"button\").Int() {\n\t\t\t\tcase 0:\n\t\t\t\t\tbutton = ButtonLeft\n\t\t\t\tcase 1:\n\t\t\t\t\tbutton = ButtonMiddle\n\t\t\t\tcase 2:\n\t\t\t\t\tbutton = ButtonRight\n\t\t\t\t}\n\t\t\t\tpublish(MouseEvent{\n\t\t\t\t\tX: int32(event.Get(\"offsetX\").Int()),\n\t\t\t\t\tY: int32(event.Get(\"offsetY\").Int()),\n\t\t\t\t\tButton: button,\n\t\t\t\t\tType: TypeDown,\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\t\tdefer mouseDownEvtCb.Release()\n\t\tbrowserRuntime.canvas.Call(\"addEventListener\", \"mousedown\", mouseDownEvtCb)\n\n\t\ttouchDownEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\t\tevent := args[0]\n\t\t\t\tevent.Call(\"preventDefault\")\n\t\t\t\ttouchList := event.Get(\"touches\")\n\t\t\t\ttouchListLen := touchList.Get(\"length\").Int()\n\t\t\t\tfor i := 0; i < touchListLen; i++ {\n\t\t\t\t\tbutton := ButtonNone\n\t\t\t\t\tswitch i {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbutton = TouchFirst\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tbutton = TouchSecond\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tbutton = TouchThird\n\t\t\t\t\t}\n\t\t\t\t\ttouch := touchList.Index(i)\n\t\t\t\t\tpublish(MouseEvent{\n\t\t\t\t\t\tX: int32(touch.Get(\"clientX\").Int()),\n\t\t\t\t\t\tY: int32(touch.Get(\"clientY\").Int()),\n\t\t\t\t\t\tButton: button,\n\t\t\t\t\t\tType: TypeDown,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\t\tdefer touchDownEvtCb.Release()\n\t\tbrowserRuntime.canvas.Call(\"addEventListener\", \"touchstart\", touchDownEvtCb)\n\n\t\tmouseUpEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\t\tevent := args[0]\n\t\t\t\tbutton := ButtonNone\n\t\t\t\tswitch event.Get(\"button\").Int() {\n\t\t\t\tcase 0:\n\t\t\t\t\tbutton = ButtonLeft\n\t\t\t\tcase 1:\n\t\t\t\t\tbutton = ButtonMiddle\n\t\t\t\tcase 2:\n\t\t\t\t\tbutton = ButtonRight\n\t\t\t\t}\n\t\t\t\tpublish(MouseEvent{\n\t\t\t\t\tX: int32(event.Get(\"offsetX\").Int()),\n\t\t\t\t\tY: int32(event.Get(\"offsetY\").Int()),\n\t\t\t\t\tButton: button,\n\t\t\t\t\tType: TypeUp,\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\t\tdefer mouseUpEvtCb.Release()\n\t\tbrowserRuntime.canvas.Call(\"addEventListener\", \"mouseup\", mouseUpEvtCb)\n\n\t\ttouchUpEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\t\tevent := args[0]\n\t\t\t\tevent.Call(\"preventDefault\")\n\t\t\t\ttouchList := event.Get(\"changedTouches\")\n\t\t\t\ttouchListLen := touchList.Get(\"length\").Int()\n\t\t\t\tfor i := 0; i < touchListLen; i++ {\n\t\t\t\t\tbutton := ButtonNone\n\t\t\t\t\tswitch i {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbutton = TouchFirst\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tbutton = TouchSecond\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tbutton = TouchThird\n\t\t\t\t\t}\n\t\t\t\t\ttouch := touchList.Index(i)\n\t\t\t\t\tpublish(MouseEvent{\n\t\t\t\t\t\tX: int32(touch.Get(\"clientX\").Int()),\n\t\t\t\t\t\tY: int32(touch.Get(\"clientY\").Int()),\n\t\t\t\t\t\tButton: button,\n\t\t\t\t\t\tType: TypeUp,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\t\tdefer touchUpEvtCb.Release()\n\t\tbrowserRuntime.canvas.Call(\"addEventListener\", \"touchend\", touchUpEvtCb)\n\t}\n\n\t// MouseMotionEventEnabled\n\tif (settings.EventMask & MouseMotionEventEnabled) != 0 {\n\t\tmouseMoveEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\t\tevent := args[0]\n\t\t\t\tpublish(MouseEvent{\n\t\t\t\t\tX: int32(event.Get(\"clientX\").Int()),\n\t\t\t\t\tY: int32(event.Get(\"clientY\").Int()),\n\t\t\t\t\tButton: ButtonNone,\n\t\t\t\t\tType: TypeMove,\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\t\tdefer mouseMoveEvtCb.Release()\n\t\tbrowserRuntime.canvas.Call(\"addEventListener\", \"mousemove\", mouseMoveEvtCb)\n\n\t\ttouchMoveEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\t\tevent := args[0]\n\t\t\t\tevent.Call(\"preventDefault\")\n\t\t\t\ttouchList := event.Get(\"touches\")\n\t\t\t\ttouchListLen := touchList.Get(\"length\").Int()\n\t\t\t\tfor i := 0; i < touchListLen; i++ {\n\t\t\t\t\tbutton := ButtonNone\n\t\t\t\t\tswitch i {\n\t\t\t\t\tcase 0:\n\t\t\t\t\t\tbutton = TouchFirst\n\t\t\t\t\tcase 1:\n\t\t\t\t\t\tbutton = TouchSecond\n\t\t\t\t\tcase 2:\n\t\t\t\t\t\tbutton = TouchThird\n\t\t\t\t\t}\n\t\t\t\t\ttouch := touchList.Index(i)\n\t\t\t\t\tpublish(MouseEvent{\n\t\t\t\t\t\tX: int32(touch.Get(\"clientX\").Int()),\n\t\t\t\t\t\tY: int32(touch.Get(\"clientY\").Int()),\n\t\t\t\t\t\tButton: button,\n\t\t\t\t\t\tType: TypeMove,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\t\tdefer touchMoveEvtCb.Release()\n\t\tbrowserRuntime.canvas.Call(\"addEventListener\", \"touchmove\", touchMoveEvtCb)\n\t}\n\n\t// ScrollEvent\n\tif (settings.EventMask & ScrollEventEnabled) != 0 {\n\t\twheelEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\t\tevent := args[0]\n\t\t\t\tevent.Call(\"preventDefault\")\n\t\t\t\tx := float64(event.Get(\"deltaX\").Int())\n\t\t\t\ty := float64(event.Get(\"deltaY\").Int())\n\t\t\t\tif x != 0 {\n\t\t\t\t\tx = x / math.Abs(x)\n\t\t\t\t}\n\t\t\t\tif y != 0 {\n\t\t\t\t\ty = y / math.Abs(y)\n\t\t\t\t}\n\t\t\t\tpublish(ScrollEvent{\n\t\t\t\t\tX: int32(x),\n\t\t\t\t\tY: -int32(y),\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\t\tdefer wheelEvtCb.Release()\n\t\tbrowserRuntime.canvas.Call(\"addEventListener\", \"wheel\", wheelEvtCb)\n\t}\n\n\t// KeyEvent\n\tif (settings.EventMask & KeyEventEnabled) != 0 {\n\t\tkeyDownEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\t\tevent := args[0]\n\t\t\t\tevent.Call(\"preventDefault\")\n\t\t\t\tkeyCode := event.Get(\"key\").String()\n\t\t\t\tpublish(KeyEvent{\n\t\t\t\t\tKey: keyMap[keyCode],\n\t\t\t\t\tValue: keyCode,\n\t\t\t\t\tType: TypeDown,\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\t\tdefer keyDownEvtCb.Release()\n\t\tbrowserRuntime.canvas.Call(\"addEventListener\", \"keydown\", keyDownEvtCb)\n\n\t\tkeyUpEvtCb := js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\t\tif !browserRuntime.isStopped && !browserRuntime.isPaused {\n\t\t\t\tevent := args[0]\n\t\t\t\tevent.Call(\"preventDefault\")\n\t\t\t\tkeyCode := event.Get(\"key\").String()\n\t\t\t\tpublish(KeyEvent{\n\t\t\t\t\tKey: keyMap[keyCode],\n\t\t\t\t\tValue: keyCode,\n\t\t\t\t\tType: TypeUp,\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\t\tdefer keyUpEvtCb.Release()\n\t\tbrowserRuntime.canvas.Call(\"addEventListener\", \"keyup\", keyUpEvtCb)\n\t}\n\n\t// -------------------------------------------------------------------- //\n\t// Render Loop\n\t// -------------------------------------------------------------------- //\n\tvar renderFrame js.Func\n\telapsedFpsTime := time.Duration(0)\n\trenderFrame = js.FuncOf(func(this js.Value, args []js.Value) interface{} {\n\t\tif !browserRuntime.isPaused {\n\t\t\tnow := time.Now()\n\t\t\tapp.OnRender(elapsedFpsTime, syncChan)\n\t\t\telapsedFpsTime = time.Since(now)\n\t\t}\n\t\tif !browserRuntime.isStopped {\n\t\t\tjs.Global().Call(\"requestAnimationFrame\", renderFrame)\n\t\t} else {\n\t\t\tbrowserRuntime.done <- true\n\t\t}\n\t\treturn false\n\t})\n\tjs.Global().Call(\"requestAnimationFrame\", renderFrame)\n\n\t<-browserRuntime.done\n\n\trenderFrame.Release()\n\tjsTge.Call(\"stop\")\n\n\tnoExit := make(chan int)\n\t<-noExit\n\n\treturn nil\n}", "func (app *App) Run() error {\n\treturn nil\n}", "func Run(version string, args []string) {\n\terr := NewApp(version, time.Now()).Run(args)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tos.Exit(1)\n\t}\n}", "func runApp(config Config) {\n\tvar theme string\n\tswitch config.Theme {\n\tcase \"System\":\n\t\ttheme = \"\"\n\tcase \"Light\":\n\t\ttheme = \"Default\"\n\tdefault:\n\t\ttheme = config.Theme\n\t}\n\tif theme != \"\" {\n\t\tquickcontrols2.QQuickStyle_SetStyle(theme)\n\t}\n\n\tapp := qml.NewQQmlApplicationEngine(nil)\n\tapp.RootContext().SetContextProperty(\"uiBridge\", uiBridge)\n\tapp.RootContext().SetContextProperty(\"accountBridge\", accountBridge)\n\tapp.RootContext().SetContextProperty(\"profileBridge\", profileBridge)\n\tapp.RootContext().SetContextProperty(\"settings\", configBridge)\n\n\tapp.Load(core.NewQUrl3(\"qrc:/qml/telephant.qml\", 0))\n\tgui.QGuiApplication_Exec()\n}", "func (a *App) Run() error {\n\t// Run state updater\n\tctx, cancel := context.WithCancel(context.Background())\n\tgo a.updater.Run(ctx)\n\ta.cancelStateUpdate = cancel\n\n\t// run gui\n\treturn a.gui.Run()\n}", "func (ui *ReplApp) Run() {\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel() // stops engine\n\n\t// start chat engine\n\tui.engine.Start(ctx)\n\t// start repl console\n\tui.console.Run(ctx)\n\n\tui.loop() // blocks until \"quit\"\n}", "func (ui *GUI) Run() {\n\tlog.Infof(\"GUI served on port %v.\", ui.cfg.GUIPort)\n\n\tgo func() {\n\t\tif err := ui.server.ListenAndServeTLS(ui.cfg.TLSCertFile,\n\t\t\tui.cfg.TLSKeyFile); err != nil &&\n\t\t\terr != http.ErrServerClosed {\n\t\t\tlog.Error(err)\n\t\t}\n\t}()\n}", "func (ui *jobCreatorUI) ShowAndRun() {\n\tif ui.window == nil {\n\t\tfmt.Errorf(\"Window of jobCreatorUI is nil!\")\n\t} else {\n\t\tui.window.ShowAll()\n\t}\n\tgtk.Main()\n}", "func Run() {\n\t// Seed RNG\n\trand.Seed(time.Now().UnixNano())\n\n\t// Set up the game window\n\tebiten.SetWindowSize(640, 480)\n\tebiten.SetWindowTitle(\"Soup The Moon\")\n\n\tif util.IsRasPi() {\n\t\t// Set fullscreen\n\t\tebiten.SetFullscreen(true)\n\n\t\t// Hide cursor\n\t\tebiten.SetCursorMode(ebiten.CursorModeHidden)\n\n\t\t// Setup RPIO button input\n\t\tinput.InitPluto()\n\t\tinput.InitSaturn()\n\t\tinput.InitJupiter()\n\t\tinput.InitMars()\n\t\tinput.InitEarth()\n\t\tinput.InitMercury()\n\t\tinput.InitUp()\n\t\tinput.InitDown()\n\t\tinput.InitEnter()\n\t\tinput.InitBack()\n\t}\n\n\t// Run game\n\tif err := ebiten.RunGame(newGame(640, 480)); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func run() {\n\tglobal.gVariables.Load(wConfigFile)\n\n\t// Initialize window\n\tcfg := pixelgl.WindowConfig{\n\t\tTitle: wWindowTitle,\n\t\tBounds: pixel.R(0, 0, global.gVariables.WindowWidth, global.gVariables.WindowHeight),\n\t\tVSync: true,\n\t}\n\tgWin, err := pixelgl.NewWindow(cfg)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tgWin.SetCursorVisible(false)\n\tglobal.gWin = gWin\n\n\tsetup()\n\n\tgameLoop()\n}", "func main() {\n\tgo func() {\n\t\tw := app.NewWindow(\n\t\t\tapp.Title(\"Gopher-Garden\"),\n\t\t\tapp.Size(unit.Dp(ui.WidthPx+500), unit.Dp(ui.HeightPx)))\n\t\tu := ui.NewUi(w)\n\t\tif err := u.Loop(); err != nil {\n\t\t\tlog.Fatal(err)\n\t\t}\n\t\tos.Exit(0)\n\t}()\n\tapp.Main()\n}", "func runApp(config Config) {\n\tvar theme string\n\tswitch config.Theme {\n\tcase \"System\":\n\t\ttheme = \"\"\n\tcase \"Light\":\n\t\ttheme = \"Default\"\n\tdefault:\n\t\ttheme = config.Theme\n\t}\n\tif theme != \"\" {\n\t\tquickcontrols2.QQuickStyle_SetStyle(theme)\n\t}\n\n\tapp := qml.NewQQmlApplicationEngine(nil)\n\tapp.RootContext().SetContextProperty(\"accountBridge\", accountBridge)\n\tapp.RootContext().SetContextProperty(\"settings\", configBridge)\n\n\tapp.Load(core.NewQUrl3(\"qrc:/qml/catchat.qml\", 0))\n\tgui.QGuiApplication_Exec()\n}", "func main() {\n\ttheApp = app.NewApp()\n\tdefer theApp.Close()\n\n\ttheApp.Open()\n\n\ttheApp.SetFont(\"Roboto-Bold.ttf\", 24)\n\ttheApp.Configure()\n\n\ttheApp.Run()\n}", "func InitTui(instanceRunning bool) bool {\n\tinitialModel.instanceAlreadyRunning = instanceRunning\n\tinitialModel.updateMenuItemsHomePage()\n\tp := tea.NewProgram(initialModel)\n\tif err := p.Start(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn execBot\n}", "func (app *App) Run() {\n\tif err := app.Start(Timeout(DefaultTimeout)); err != nil {\n\t\tapp.logger.Fatalf(\"ERROR\\t\\tFailed to start: %v\", err)\n\t}\n\n\tapp.logger.PrintSignal(<-app.Done())\n\n\tif err := app.Stop(Timeout(DefaultTimeout)); err != nil {\n\t\tapp.logger.Fatalf(\"ERROR\\t\\tFailed to stop cleanly: %v\", err)\n\t}\n}", "func (app *Application) Run() error {\n\n\terr := app.expose()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (a *Application) Run() error {\n\t<-a.quit\n\treturn nil\n}", "func (p Helium) Run() error {\n\treturn p.di.Invoke(func(ctx context.Context, app App) error {\n\t\treturn app.Run(ctx)\n\t})\n}", "func (r *Runner) Run(application *config.Application) {\n\n\tif debugMode {\n\n\t\tif err := r.checkApplicationExecutableEnvironment(application); err != nil {\n\t\t\tr.view.Writef(\"❌ %s\\n\", err.Error())\n\t\t\treturn\n\t\t}\n\n\t\tr.view.Writef(\"⚙️ Running local app '%s' (%s)...\\n\", application.Name, application.Path)\n\n\t\tapplicationPath := application.GetPath()\n\n\t\tstdoutStream := NewLogstreamer(StdOut, application.Name, r.view)\n\t\tstderrStream := NewLogstreamer(StdErr, application.Name, r.view)\n\n\t\tcmd := exec.Command(application.Executable, application.Args...)\n\t\tcmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: false}\n\t\tcmd.Dir = applicationPath\n\t\tcmd.Stdout = stdoutStream\n\t\tcmd.Stderr = stderrStream\n\t\tcmd.Stdin = os.Stdin\n\n\t\tcmd.Env = os.Environ()\n\n\t\t// Add environment variables\n\t\tfor key, value := range application.Env {\n\t\t\tcmd.Env = append(cmd.Env, fmt.Sprintf(\"%s=%s\", key, value))\n\t\t}\n\n\t\tr.cmds[application.Name] = cmd\n\n\t\tif err := cmd.Run(); err != nil {\n\t\t\tr.view.Writef(\"❌ Cannot run the following application: %s: %v\\n\", applicationPath, err)\n\t\t\treturn\n\t\t}\n\t\tcmd.Stdin = os.Stdin\n\t}else {\n\n\t\tcmd := exec.Command(application.Executable, application.Args...)\n\n\t\tcmd.Dir = application.GetPath()\n\n\t\tvar errStdout, errStderr error\n\t\tstdoutIn, _ := cmd.StdoutPipe()\n\t\tstderrIn, _ := cmd.StderrPipe()\n\t\tstdout := NewinteractiveWriter(os.Stdout)\n\t\tstderr := NewinteractiveWriter(os.Stderr)\n\t\t//cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}\n\t\tcmd.Stdin = os.Stdin\n\t\terr := cmd.Start()\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Unable to run command: %s\", err)\n\t\t}\n\n\t\tvar wg sync.WaitGroup\n\t\twg.Add(1)\n\n\t\tgo func() {\n\t\t\t_, errStdout = io.Copy(stdout, stdoutIn)\n\t\t\twg.Done()\n\t\t}()\n\n\t\t_, errStderr = io.Copy(stderr, stderrIn)\n\t\twg.Wait()\n\n\t\terr = cmd.Wait()\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"Unable to run command\")\n\t\t}\n\t\tif errStdout != nil || errStderr != nil {\n\t\t\tlog.Fatalf(\"internal failure with std pipe\")\n\t\t}\n\t}\n\t\n}", "func Run(c *cli.Context, o *options) error {\n\terr := verifyFlags(o)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to verify flags: %v\", err)\n\t}\n\n\terr = initialize()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to initialize: %v\", err)\n\t}\n\tdefer shutdown()\n\n\terr = installToolkit(o)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to install toolkit: %v\", err)\n\t}\n\n\terr = setupRuntime(o)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to setup runtime: %v\", err)\n\t}\n\n\tif !o.noDaemon {\n\t\terr = waitForSignal()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to wait for signal: %v\", err)\n\t\t}\n\n\t\terr = cleanupRuntime(o)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to cleanup runtime: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func (m *AppManager) Run() {\n\tlog.Info(\"Starting HO App Manager\")\n\tm.SB.Run()\n}", "func main() {\n\t// 设置运行时默认操作界面,并开始运行\n\t// 运行软件前,可设置 -a_ui 参数为\"web\"、\"gui\"或\"cmd\",指定本次运行的操作界面\n\t// 其中\"gui\"仅支持Windows系统\n\texec.DefaultRun(\"cmd\")\n}", "func (h Helium) Run() error {\n\treturn h.di.Invoke(func(ctx context.Context, app App) error {\n\t\treturn app.Run(ctx)\n\t})\n}", "func (g *Getter) Run(args []string) {\n\tif len(args) != 1 {\n\t\tfmt.Fprintln(os.Stderr, \"Missing \\\"package\\\" argument to define the application to get\")\n\t\tos.Exit(1)\n\t}\n\n\terr := get(args[0], g.icon)\n\tif err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"%s\\n\", err.Error())\n\t\tos.Exit(1)\n\t}\n}", "func Run() {\n\n\tgo func() {\n\t\terrors := setupTemplates(\"server/templates\")\n\t\tif errors != nil {\n\t\t\tfmt.Println(errors)\n\t\t}\n\t}()\n\n\tfmt.Println(\"Starting server...\")\n\thttp.HandleFunc(\"/\", index)\n\thttp.HandleFunc(\"/view\", view)\n\thttp.Handle(\"/static/\", http.StripPrefix(\"/static/\", http.FileServer(http.Dir(\"server/static/\"))))\n\thttp.ListenAndServe(\":8080\", nil)\n}", "func Run() {\n\tappConfig := &OpenZwaveAppConfig{}\n\t// Load the appConfig from <AppID>.yaml from the default config folder (~/.config/iotdomain)\n\tpub, _ := publisher.NewAppPublisher(AppID, \"\", appConfig, \"\", true)\n\tNewOpenZwaveApp(appConfig, pub)\n\n\tpub.Start()\n\tpub.WaitForSignal()\n\tpub.Stop()\n}", "func (f *Floki) Run() {\n\tlogger := f.logger\n\n\tif Env == Prod {\n\t\truntime.GOMAXPROCS(runtime.NumCPU())\n\t}\n\n\ttplDir := f.GetParameter(\"views dir\").(string)\n\tf.SetParameter(\"templates\", compileTemplates(tplDir, logger))\n\n\tport := os.Getenv(\"PORT\")\n\tif port == \"\" {\n\t\tport = \"3000\"\n\t}\n\n\thost := os.Getenv(\"HOST\")\n\t_ = host\n\n\taddr := host + \":\" + port\n\tlogger.Printf(\"listening on %s (%s)\\n\", addr, Env)\n\n\tif err := http.ListenAndServe(addr, f); err != nil {\n\t\tpanic(err)\n\t}\n}", "func RunMinUI(n *node.Node) {\n\ts := minui.New(Config, n)\n\ts.Run()\n}", "func (w *web) Run() {\n\tw.ready()\n\n\taddr := fmt.Sprintf(\"%s:%s\", w.Host, w.Port)\n\tLogger.Info(\"Starting web server at: %s\", addr)\n\tw.instance.Run(standard.New(addr))\n}", "func (s *Starter) Run() error {\n\t// Step-1: rake config\n\t// Step-2: clone|use-local template\n\t// Step-3: ask-flow\n\t// Step-4: generate project\n\n\treturn nil\n}", "func run() {\n\tw, h := 800, 550\n\n\tvar err error\n\twin, err := wde.NewWindow(w, h)\n\tif err != nil {\n\t\tlog.Printf(\"Create window error: %v\", err)\n\t\treturn\n\t}\n\n\twin.SetTitle(title)\n\twin.LockSize(true)\n\twin.Show()\n\n\teng = engine.NewEngine(win, w, h)\n\tgo eng.Run()\n\n\tfor event := range win.EventChan() {\n\t\tif quit := handleEvent(event); quit {\n\t\t\tbreak\n\t\t}\n\t}\n\teng.Stop()\n\n\twde.Stop()\n}", "func Run(ctx context.Context) {\n\ttoken := os.Getenv(\"TELEGRAM_TOKEN\")\n\tbot := tbot.New(token)\n\tc := bot.Client()\n\tHandle(ctx, c, bot)\n\t_ = bot.Start()\n}", "func (a *App) Run(ctx context.Context) error {\n\tif a.pass {\n\t\treturn nil\n\t}\n\t// TODO\n\treturn nil\n}", "func Run(app func(w *Window)) {\n\tw := &Window{\n\t\tRedraw: make(chan window.Event, 128),\n\t\tapp: app,\n\t\trender: make(chan struct{}),\n\t}\n\twindow.Run(w.gfxLoop, Props)\n}", "func (c *WebConsoleManager) Run() error {\n\tif checkVersion() {\n\t\treturn nil\n\t}\n\n\tlogger.Info(\"starting bcs-webconsole.\")\n\n\teg, ctx := errgroup.WithContext(c.ctx)\n\n\tpodCleanUpMgr := podmanager.NewCleanUpManager(ctx)\n\teg.Go(func() error {\n\t\treturn podCleanUpMgr.Run()\n\t})\n\n\tif c.multiCredConf != nil {\n\t\tc.microService.Init(micro.AfterStop(func() error {\n\t\t\tc.multiCredConf.Stop()\n\t\t\treturn nil\n\t\t}))\n\n\t\teg.Go(func() error {\n\t\t\treturn c.multiCredConf.Watch()\n\t\t})\n\t}\n\n\teg.Go(func() error {\n\t\tif err := c.microService.Run(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n\n\tif err := eg.Wait(); err != nil {\n\t\tdefer logger.CloseLogs()\n\t\treturn err\n\t}\n\treturn nil\n}", "func main() {\n\tdomTarget := dom.GetWindow().Document().GetElementByID(\"app\")\n\n\tr.Render(container.Container(), domTarget)\n}", "func (app *Application) Run() {\n\tapp.Setup()\n\n\tapp.App.Listen(fmt.Sprintf(\"%s:%d\", app.Config.App.Host, app.Config.App.Port))\n}", "func RunApp() {\n\tapp := createApp()\n\tapp.Run()\n}", "func Run(conf *config.Config) {\n\n\tvar eventHandler = ParseEventHandler(conf)\n\tcontroller.Start(conf, eventHandler)\n}", "func (s *Service) Run() {\n\tgrip.CatchAlert(s.App().Run())\n}", "func (a *App) Run() {\n\trand.Seed(time.Now().UTC().UnixNano())\n\n\tinitFlag()\n\n\tcmd := cobra.Command{\n\t\tUse: FormatBaseName(a.basename),\n\t\tLong: a.description,\n\t\tSilenceUsage: true,\n\t\tSilenceErrors: true,\n\t}\n\tcmd.SetUsageTemplate(usageTemplate)\n\tcmd.Flags().SortFlags = false\n\tif len(a.commands) > 0 {\n\t\tfor _, command := range a.commands {\n\t\t\tcmd.AddCommand(command.cobraCommand())\n\t\t}\n\t\tcmd.SetHelpCommand(helpCommand(a.name))\n\t}\n\tif a.runFunc != nil {\n\t\tcmd.Run = a.runCommand\n\t}\n\n\tcmd.Flags().AddGoFlagSet(flag.CommandLine)\n\tif a.options != nil {\n\t\tif _, ok := a.options.(ConfigurableOptions); ok {\n\t\t\taddConfigFlag(a.basename, cmd.Flags())\n\t\t}\n\t\ta.options.AddFlags(cmd.Flags())\n\t}\n\n\tif !a.noVersion {\n\t\tversion.AddFlags(cmd.Flags())\n\t}\n\taddHelpFlag(a.name, cmd.Flags())\n\n\tif err := cmd.Execute(); err != nil {\n\t\tfmt.Printf(\"%v %v\\n\", color.RedString(\"Error:\"), err)\n\t\tos.Exit(1)\n\t}\n}", "func Run() {\n\tcmd := registry.Root()\n\tif err := cmd.Execute(); err != nil {\n\t\tkouch.Exit(err)\n\t}\n}", "func Run(\n\tlog Logger,\n\tcr CommandRunner,\n\tmanifestPath string,\n\targs []string,\n\topts ...RunOption,\n) {\n\tcfg := runConfig{\n\t\truntimeOS: runtime.GOOS,\n\t\terrorWriter: os.Stderr,\n\t\ttmuxSocket: defaultTmuxSocket(),\n\t}\n\n\tfor _, o := range opts {\n\t\to(&cfg)\n\t}\n\n\ttm := tmux.New(cfg.tmuxSocket,\n\t\ttmux.WithCommandRunner(cr),\n\t)\n\n\tif fileNotExists(manifestPath) {\n\t\terr := ioutil.WriteFile(manifestPath, []byte(manifestTemplate), 0664)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed to create jkl manifest: %s\", err)\n\t\t}\n\n\t\tlog.Printf(\"example manifest created at %s\", manifestPath)\n\t}\n\n\tm, err := manifest.Load(manifestPath)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to read jkl manifest: %s\", err)\n\t}\n\n\tapp := cli.App(\"jkl\", \"developer project management life improver\")\n\tproject := app.StringArg(\"PROJECT\", \"\", \"name or alias of project to goto\")\n\tapp.Spec = \"[PROJECT]\"\n\n\tapp.Action = func() {\n\t\tif *project == \"\" {\n\t\t\tapp.PrintHelp()\n\t\t\tcli.Exit(1)\n\t\t}\n\n\t\tif !tm.Valid() {\n\t\t\tlog.Fatalf(\"jkl goto must be ran in tmux\")\n\t\t}\n\n\t\tp, err := m.FindProject(*project)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"%s\", err)\n\t\t}\n\n\t\terr = tm.ChangeDirectory(p.Path)\n\t\tif err != nil {\n\t\t\tlog.Fatalf(\"failed to open project '%s': %s\", p.Name, err)\n\t\t}\n\t}\n\n\tcommands := []command{\n\t\t{\n\t\t\tname: \"browser b\",\n\t\t\tdescription: \"open the projects page in the browser\",\n\t\t\tcmd: BrowserCommand(log, cr, m, cfg.runtimeOS),\n\t\t},\n\t\t{\n\t\t\tname: \"clone c\",\n\t\t\tdescription: \"clone the project to the projects path\",\n\t\t\tcmd: CloneCommand(cr, m),\n\t\t},\n\t\t{\n\t\t\tname: \"edit e\",\n\t\t\tdescription: \"open the jkl manifest for editing\",\n\t\t\tcmd: EditCommand(log, tm, m),\n\t\t},\n\t\t{\n\t\t\tname: \"goto cd\",\n\t\t\tdescription: \"change the current directory of the current tmux pane to the project directory\",\n\t\t\tcmd: GoToCommand(log, tm, m),\n\t\t},\n\t\t{\n\t\t\tname: \"open o\",\n\t\t\tdescription: \"open one or more projects\",\n\t\t\tcmd: OpenCommand(log, tm, m),\n\t\t},\n\t\t{\n\t\t\tname: \"projects p\",\n\t\t\tdescription: \"list known projects\",\n\t\t\tcmd: ProjectsCommand(log, cfg.errorWriter, m),\n\t\t},\n\t}\n\n\tfor _, cmd := range commands {\n\t\tapp.Command(cmd.name, cmd.description, cmd.cmd)\n\t}\n\n\tapp.Run(args)\n}", "func (s *Scheduler) Run(app twelvefactor.App, processes ...twelvefactor.Process) error {\n\treturn s.stackBuilder.Build(app, processes...)\n}", "func Run() {\n\troot.Execute()\n}", "func (c *AppsInitCmd) Run() (err error) {\n\tvar stdout bytes.Buffer\n\tvar stderr bytes.Buffer\n\tswitch c.StackName {\n\tcase \"nodejs-basic\":\n\t\terr := c.InitializeNodeBasicApp(stdout, stderr)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"[ERROR]: init completed with error %x\", err)\n\t\t}\n\tdefault:\n\t\tlog.Printf(\"[ERROR]: Stack name %s does not have an initialization defined\\n\", c.StackName)\n\t}\n\treturn err\n}", "func main() {\n\tcreateGUI()\n}", "func (app *App) Run() {\n\tMust(app.Engine.Start(\":\" + app.Conf.UString(\"port\")))\n}", "func (ta *TestApp) run() {\n\tlog.Info(\">>> child >>> test application started\")\n\tif *maxUptime != 0 {\n\t\tlog.Infof(\">>> child >>> max uptime set to %d second(s)\", *maxUptime)\n\t}\n\n\tticker := time.NewTicker(1 * time.Second)\n\tvar uptime uint\n\n\tfunc() {\n\t\tfor range ticker.C {\n\t\t\tuptime++\n\t\t\tif uptime == *maxUptime {\n\t\t\t\tlog.Info(\">>> child >>> time's up, bye\")\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\tlog.Info(\">>> child >>> test application ended\")\n\treturn\n}", "func Run() {\n\tApp.Init()\n\n\tif Config.String(\"address\") != \"\" {\n\t\tLog.Info(fmt.Sprintf(\"listening on %s\", Config.String(\"address\")))\n\t\tLog.Error(http.ListenAndServe(Config.String(\"address\"), App.Router))\n\t} else {\n\t\tLog.Info(fmt.Sprintf(\"listening on port :%d\", Config.Int(\"port\")))\n\t\tLog.Error(http.ListenAndServe(fmt.Sprintf(\":%d\", Config.Int(\"port\")), App.Router))\n\t}\n}", "func (c *AppsInitCmd) Run() (err error) {\n\tvar stdout bytes.Buffer\n\tvar stderr bytes.Buffer\n\tswitch c.StackName {\n\tcase \"nodejs-basic\":\n\t\terr := c.InitializeNodeBasicApp(stdout, stderr)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"[ERROR]: init completed with error %x\", err)\n\t\t}\n\tdefault:\n\t\tlog.Error().Msg(fmt.Sprintf(\": Stack name %s does not have an initialization defined\\n\", c.StackName))\n\t}\n\treturn err\n}", "func (app *App) Run(addr string) {}", "func (a *App) Run() {\n\tif a.cmd != nil {\n\t\ta.cmd.Run(a.container)\n\t}\n\n\twg := sync.WaitGroup{}\n\n\t// Start HTTP Server\n\tif a.httpServer != nil {\n\t\twg.Add(1)\n\n\t\tgo func(s *httpServer) {\n\t\t\tdefer wg.Done()\n\t\t\ts.Run(a.container)\n\t\t}(a.httpServer)\n\t}\n\n\twg.Wait()\n}", "func Run(appStart func() error) {\n\tlchr.run(appStart)\n}", "func (c *Client) run() error {\n\tsignal.Notify(c.sigkil, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)\n\tc.setReloadSignals()\n\n\tif c.newCon {\n\t\t_, _ = c.Config.Write(c.Flags.ConfigFile)\n\t\t_ = ui.OpenFile(c.Flags.ConfigFile)\n\t\t_, _ = ui.Warning(Title, \"A new configuration file was created @ \"+\n\t\t\tc.Flags.ConfigFile+\" - it should open in a text editor. \"+\n\t\t\t\"Please edit the file and reload this application using the tray menu.\")\n\t}\n\n\tif c.Config.AutoUpdate != \"\" {\n\t\tgo c.AutoWatchUpdate()\n\t}\n\n\tswitch ui.HasGUI() {\n\tcase true:\n\t\tc.startTray() // This starts the web server.\n\t\treturn nil // startTray() calls os.Exit()\n\tdefault:\n\t\tc.StartWebServer()\n\t\treturn c.Exit()\n\t}\n}", "func Run(osArgs []string) error {\n\terrRun := app.Run(osArgs)\n\tif errRun != nil {\n\t\treturn errRun\n\t}\n\treturn nil\n}", "func Run(args []string) (err error) {\n\tcli.VersionFlag = &cli.BoolFlag{\n\t\tName: \"version\",\n\t\tAliases: []string{\"v\"},\n\t\tUsage: \"Shows current cli version\",\n\t}\n\n\tapp.EnableBashCompletion = true\n\terr = app.Run(args)\n\treturn\n}", "func main() {\n\tapp.StartApp()\n}", "func Run(args []string, w io.Writer) error {\n\n\tapp := clir.NewCli(\"WinIcon\", \"A utility for manipulating windows .ico files\", VERSION)\n\n\t// Custom Banner\n\tapp.SetBannerFunction(func(cli *clir.Cli) string {\n\t\treturn fmt.Sprintf(\"%s %s (c) 2020-Present Lea Anthony\", cli.Name(), cli.Version())\n\t})\n\n\t// Add commands\n\tinfo(app)\n\tgenerate(app)\n\textract(app)\n\n\t// Run!\n\treturn app.Run()\n}", "func run() {\n\tlog.Info(\"Maison is starting...\")\n\n\tbus.Init()\n\n\t// TODO: init stores\n\n\tinitPlugins()\n\n\tlog.Info(\"Maison is started\")\n}", "func (m *Manager) Run() {\n\tgo func() {\n\t\tif err := m.Start(context.Background()); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n}", "func (g *UICommand) Run() error {\n\tlog.WithField(\"g\", g).Trace(\n\t\t\"Running cli command\",\n\t)\n\n\tuiServer := meshservice.NewUIServer(\n\t\tg.meshConfig.Agent.GRPCSocket,\n\t\tg.meshConfig.UI.HTTPBindAddr,\n\t\tg.meshConfig.UI.HTTPBindPort)\n\tuiServer.Serve()\n\n\treturn nil\n}", "func (sto *SetOptions) Run() (err error) {\n\terr = component.SetCurrent(sto.componentName, sto.Context.Application, sto.Context.Project)\n\tif err != nil {\n\t\treturn err\n\t}\n\tlog.Infof(\"Switched to component: %v\", sto.componentName)\n\treturn\n}", "func Main() {\n\n\tclient = tweet.MyTwitterClient{}\n\n\tif err := client.Connect(); err != nil {\n\t\tlog.Fatalf(\"failed to connect to Twitter: %v\", err.Error())\n\t}\n\n\tif err := ui.Init(); err != nil {\n\t\tlog.Fatalf(\"failed to initialize termui: %v\", err)\n\t}\n\tdefer ui.Close()\n\n\ttermWidth, termHeight = ui.TerminalDimensions()\n\n\tp := widgets.NewParagraph()\n\tp.Title = \"Loading...\"\n\tp.Text = \"Fetching Tweets...\"\n\tp.SetRect(5, 5, termWidth, termHeight)\n\n\tui.Render(p)\n\n\trefreshTweets()\n\tshowTweets()\n\n\tfor e := range ui.PollEvents() {\n\t\t//fmt.Print(e.ID)\n\t\tswitch e.ID {\n\t\tcase \"q\", \"<C-c>\":\n\t\t\tui.Close()\n\t\t\tos.Exit(0)\n\t\tcase \"j\", \"<Down>\", \"<MouseWheelDown>\":\n\t\t\tscrollDown()\n\t\tcase \"k\", \"<Up>\", \"<MouseWheelUp>\":\n\t\t\tscrollUp()\n\t\tcase \"r\", \"R\":\n\t\t\trefreshTweets()\n\t\tcase \"<Resize>\":\n\t\t\tshowTweets()\n\t\t}\n\t}\n}", "func main() {\n\tc := getConfig()\n\n\t// Ask version\n\tif c.askVersion {\n\t\tfmt.Println(versionFull())\n\t\tos.Exit(0)\n\t}\n\n\t// Ask Help\n\tif c.askHelp {\n\t\tfmt.Println(versionFull())\n\t\tfmt.Println(HELP)\n\t\tos.Exit(0)\n\t}\n\n\t// Only used to check errors\n\tgetClientSet()\n\n\tg, err := gocui.NewGui(gocui.OutputNormal)\n\tif err != nil {\n\t\tlog.Panicln(err)\n\t}\n\tdefer g.Close()\n\n\tg.Highlight = true\n\tg.SelFgColor = gocui.ColorGreen\n\n\tg.SetManagerFunc(uiLayout)\n\n\tif err := uiKey(g); err != nil {\n\t\tlog.Panicln(err)\n\t}\n\n\tif err := g.MainLoop(); err != nil && err != gocui.ErrQuit {\n\t\tlog.Panicln(err)\n\t}\n}", "func (app *Application) Run() {\n\terr := app.Server.ListenAndServe()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n}", "func Run() error {\n\tcfg := config.Load()\n\n\tapp := &cli.App{\n\t\tName: \"prometheus-hcloud-sd\",\n\t\tVersion: version.String,\n\t\tUsage: \"Prometheus HetznerCloud SD\",\n\t\tAuthors: []*cli.Author{\n\t\t\t{\n\t\t\t\tName: \"Thomas Boerger\",\n\t\t\t\tEmail: \"thomas@webhippie.de\",\n\t\t\t},\n\t\t},\n\t\tFlags: RootFlags(cfg),\n\t\tCommands: []*cli.Command{\n\t\t\tHealth(cfg),\n\t\t\tServer(cfg),\n\t\t},\n\t}\n\n\tcli.HelpFlag = &cli.BoolFlag{\n\t\tName: \"help\",\n\t\tAliases: []string{\"h\"},\n\t\tUsage: \"Show the help, so what you see now\",\n\t}\n\n\tcli.VersionFlag = &cli.BoolFlag{\n\t\tName: \"version\",\n\t\tAliases: []string{\"v\"},\n\t\tUsage: \"Print the current version of that tool\",\n\t}\n\n\treturn app.Run(os.Args)\n}", "func (g *App) Run(args []string) error {\n\tif g.root == nil {\n\t\tpanic(\"need Bind or use NewWith\")\n\t}\n\n\t_, _, err := g.exec(args, true)\n\treturn err\n}", "func (v *App) Run() {\n\t// log.Println(\"Starting App polling\")\n\tv.running = true\n\tsdl.SetEventFilterFunc(v.filterEvent, nil)\n\n\t// sdl.SetHint(sdl.HINT_RENDER_SCALE_QUALITY, \"linear\")\n\tv.renderer.SetDrawColor(64, 64, 64, 255)\n\tv.renderer.Clear()\n\n\t// v.pointsGraph.SetSeries(v.pointsGraph.Accessor())\n\tv.spikeGraph.SetSeries(nil)\n\n\tfor v.running {\n\t\tsdl.PumpEvents()\n\n\t\tv.renderer.Clear()\n\n\t\t// v.pointsGraph.MarkDirty(true)\n\t\tv.spikeGraph.MarkDirty(true)\n\n\t\tif samples.PoiSamples != nil {\n\t\t\tdraw := v.spikeGraph.Check()\n\t\t\tif draw {\n\t\t\t\tv.spikeGraph.DrawAt(0, 100)\n\t\t\t}\n\t\t}\n\n\t\tv.expoGraph.DrawAt(0, 300)\n\n\t\tv.txtSimStatus.Draw()\n\t\tv.txtActiveProperty.Draw()\n\n\t\tv.window.UpdateSurface()\n\n\t\t// sdl.Delay(17)\n\t\ttime.Sleep(time.Millisecond * 100)\n\t}\n\n\tv.shutdown()\n}", "func run() error {\n\tif err := ShowInfo(Hello); err != nil {\n\t\treturn err\n\t}\n\n\tif err := ShowInfo(func(\n\t\tw io.Writer,\n\t\tname string,\n\t) error {\n\t\treturn nil\n\t}); err != nil {\n\t\treturn err\n\t}\n\n\tif err := ShowInfo(new(P).Hello); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func Run(level int8) error {\n\terr := sdl.Init(sdl.INIT_EVERYTHING)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not initialize SDL: %w\", err)\n\t}\n\tdefer sdl.Quit()\n\n\tif err := ttf.Init(); err != nil {\n\t\treturn fmt.Errorf(\"could not initialize TTF: %w\", err)\n\t}\n\tdefer ttf.Quit()\n\n\tw, r, err := sdl.CreateWindowAndRenderer(1280, 720, sdl.WINDOW_SHOWN)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not create window: %w\", err)\n\t}\n\tdefer w.Destroy()\n\n\ts, err := scene.NewScene(r, level)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not create scene: %w\", err)\n\t}\n\tdefer s.Destroy()\n\n\tevents := make(chan sdl.Event)\n\terrc := s.Run(events, r)\n\n\truntime.LockOSThread()\n\tfor {\n\t\tselect {\n\t\tcase events <- sdl.WaitEvent():\n\t\tcase err := <-errc:\n\t\t\treturn err\n\t\t}\n\t}\n}", "func (c *AppsCreateCmd) Run(logWriters *LogWriters) (err error) {\t\n\ts := NewSpinner(fmt.Sprintf(\"Creating new app %s\", c.Hostname),logWriters)\n\ts.Start()\n\n\tapi.Timeout = 120 * time.Second // this specific request can take a long time\n\tr, err := api.ApplicationCreate(c.AccountID, c.Hostname, c.Origin, c.StackName)\n\ts.Stop()\n\tfmt.Println()\n\tif err != nil {\n\t\tif err == api.ErrStatusForbidden {\n\t\t\tstacks, herr := api.Stacks()\n\t\t\tif herr != nil {\n\t\t\t\treturn fmt.Errorf(\"unable to query stacks: %w\", herr)\n\t\t\t}\n\t\t\tfor _, s := range stacks {\n\t\t\t\tif s.Name == c.StackName {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"bad request: unable to find stack %s\", c.StackName)\n\t\t}\n\t\treturn err\n\t}\n\n\tlog.Info().Msg(fmt.Sprintf(\"\\nSuccess: created app '%s' with id '%d'\\n\", r.ApplicationName, r.ID))\n\n\treturn err\n}", "func Run() {\n\tbrowser.OpenURL(getURL())\n}", "func Main() error {\n\tapp, err := New(context.Background())\n\tif err != nil {\n\t\treturn skerr.Wrap(err)\n\t}\n\n\treturn app.Run()\n}", "func (sw *Swgen) Run() error {\n\tif err := os.MkdirAll(sw.Target, os.ModePerm); err != nil {\n\t\treturn err\n\t}\n\n\ttree, err := sw.Scan(sw.Source)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmetadata := &Metadata{}\n\tcontent := template.HTML(\"\")\n\treturn sw.renderAll(tree, metadata, content)\n}", "func main() {\n\ta := App{}\n\ta.Initialize()\n\ta.Run(\":8000\")\n}", "func main() {\n\ttemplateAPP := templates.NewAPP()\n\ttemplateAPP.SetFlags()\n\tflag.Parse()\n\tgo templateAPP.Run()\n\tapp.StartDealWithCmdSets(templateAPP)\n}", "func main() {\n\tapp := app.New()\n\tapp.SetIcon(resourceIconPng)\n\n\tc := newCalculator()\n\tc.loadUI(app)\n\tapp.Run()\n}", "func main() {\n\terr := app.Execute()\n\tif err != nil {\n\t\tlog.WithError(err).Error(\"Error while Execute lookatch\")\n\t}\n}", "func Run(onStart func() error, onExit func(err error)) {\n\tif started {\n\t\tpanic(\"re-enter func Run()\")\n\t}\n\tstarted = true\n\tgOnStart = onStart\n\tgOnExit = onExit\n\tcode := C.winl_event_loop()\n\twinl_on_exit(code)\n}", "func Run(ctx *cli.Context) {\n\tif ctx.Bool(\"debug\") {\n\t\tlog.SetLevel(log.DebugLevel)\n\t}\n\tlog.SetLevel(log.DebugLevel)\n\n\td, err := bridge.NewDriver(version, ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\th := network.NewHandler(d)\n\th.ServeUnix(pluginName, 0)\n}", "func (app *App) Run(address string) {\n\tif app.Server() != nil {\n\t\tapp.Server().Addr = address\n\t}\n\n\tquit := make(chan os.Signal)\n\tsignal.Notify(quit, os.Interrupt)\n\n\tgo func() {\n\t\t<-quit\n\t\tif err := app.Stop(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tdefer close(quit)\n\t}()\n\n\tif err := app.Start(); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (c *AppsCreateCmd) Run() (err error) {\n\ts := NewSpinner(fmt.Sprintf(\"Creating new app %s\", c.Hostname))\n\ts.Start()\n\n\tapi.Timeout = 120 * time.Second // this specific request can take a long time\n\tr, err := api.ApplicationCreate(c.AccountID, c.Hostname, c.Origin, c.StackName)\n\ts.Stop()\n\tif err != nil {\n\t\tif err == api.ErrStatusForbidden {\n\t\t\tstacks, herr := api.Stacks()\n\t\t\tif herr != nil {\n\t\t\t\treturn fmt.Errorf(\"unable to query stacks: %w\", herr)\n\t\t\t}\n\t\t\tfor _, s := range stacks {\n\t\t\t\tif s.Name == c.StackName {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"bad request: unable to find stack %s\", c.StackName)\n\t\t}\n\t\treturn err\n\t}\n\n\tfmt.Printf(\"\\nSuccess: created app '%s' with id '%d'\\n\", r.ApplicationName, r.ID)\n\n\treturn err\n}", "func (s *Service) Run() error {\n\t// Create an MQTT client for mqtt service\n\t/*\n\t\tPort: 1883\n\t\tCleanSession: True\n\t\tOrder: True\n\t\tKeepAlive: 30 (seconds)\n\t\tConnectTimeout: 30 (seconds)\n\t\tMaxReconnectInterval 10 (minutes)\n\t\tAutoReconnect: True\n\t*/\n\topts := paho.NewClientOptions()\n\topts.AddBroker(envy.Get(\"USR_BROKER_URL\", \"tcp://127.0.0.1:1883\"))\n\topts.SetUsername(envy.Get(\"USR_BROKER_USER\", \"ella\"))\n\topts.SetClientID(fmt.Sprintf(\"FANIoT-mqs-link-%d\", rand.Intn(1024)))\n\topts.SetOnConnectHandler(func(client paho.Client) {\n\t\tif t := s.cli.Subscribe(\"$share/i1820-link/things/+/state\", 0, s.handler); t.Wait() && t.Error() != nil {\n\t\t\ts.app.Logger.Fatalf(\"MQTT subscribe error: %s\", t.Error())\n\t\t}\n\t})\n\ts.cli = paho.NewClient(opts)\n\n\t// Connect to the MQTT Broker.\n\tif t := s.cli.Connect(); t.Wait() && t.Error() != nil {\n\t\treturn t.Error()\n\t}\n\ts.app.Run()\n\n\treturn nil\n}", "func (m *Manager) Run() {\n\tlog.Info(\"Starting Manager\")\n\tif err := m.Start(); err != nil {\n\t\tlog.Fatal(\"Unable to run Manager\", err)\n\t}\n}", "func main() {\n\n\teventBus := utils.NewEventBus()\n\teventSource := models.NewEventSource(eventBus)\n\teventSource.Start()\n\tdefer eventSource.Stop()\n\n\tpiSource := models.NewProcessInfoSource(eventBus)\n\tpiSource.AddProcess(models.ProcessInfo{ID: \"P1\", Name: \"P1\", CPU: 10})\n\tpiSource.AddProcess(models.ProcessInfo{ID: \"P2\", Name: \"P2\", CPU: 10})\n\tpiSource.AddProcess(models.ProcessInfo{ID: \"P3\", Name: \"P3\", CPU: 30})\n\tpiSource.Start()\n\tdefer piSource.Stop()\n\n\ttaskRepo := models.NewTaskInfoRepo()\n\n\tmiSource := models.NewMachineInfoSource(eventBus)\n\tmiSource.InitWithFakeData()\n\tmiSource.Start()\n\tdefer miSource.Stop()\n\n\ttcx := ws.TestClientX{}\n\ttcx.Open(\"ws://localhost:8000/echo\")\n\tdefer tcx.Close()\n\n\tapp.Route(\"/\", &ui.UpdateButton{})\n\tapp.Route(\"/clusters\", views.NewClustersView(eventBus))\n\tapp.Route(\"/machines\", views.NewMachinesView(eventBus))\n\tapp.Route(\"/events\", views.NewEventsView(eventBus))\n\tapp.Route(\"/charts\", views.NewProcessesView(eventBus))\n\tapp.RouteWithRegexp(\"^/task.*\", ui.NewTaskDetail(taskRepo))\n\n\tapp.Run() // Launches the PWA.\n\n\tfmt.Println(\"DONE\")\n}", "func Run() string {\n\tmain()\n\treturn \"\"\n}", "func main() {\n\tapplication.Application()\n}", "func (app *UIApp) Start() bool {\n\t//Setup the canvasss\n\t//n.SetCanvasSize(400, 300)\n\n\t//Prepare the image\nimage, err := n.LoadImage(\"resources/tile.png\") // The image URL\n\tif err != nil {\n\t\tlog.Fatalln(\"Failed to spawn image\", err)\n\t\treturn false\n\t}\n\n\t//Setup the texture\n\tapp.texture = image.CreateTexture()\n\ttileSize := float32(app.texture.Width()) / 1.0\n\tapp.sprite = n.NewSliceSprite(app.texture, Rectangle{tileSize * 0, 0, tileSize, float32(app.texture.Height())}, Vector2{10, 10})\n\tapp.batch = n.NewUIRenderer()\n\n\tcursor, _ := n.LoadImage(\"resources/cursors.svg\")\n\tcursorTexture := cursor.CreateTexture()\n\tapp.cursor = n.NewSprite(cursorTexture, Rectangle{0, 0, float32(cursorTexture.Width()) / 8.0, float32(cursorTexture.Height()) / 8.0})\n\n\treturn true\n}", "func (a *App) Run(ctx context.Context) error {\n\n\t// 1. instantiate all components\n\n\tfor _, runnable := range a.runnables {\n\t\ta.logger(\"building: %s\", runnable)\n\n\t\t_, err := a.getValue(runnable)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"building %s: %w\", runnable, err)\n\t\t}\n\t}\n\n\t// 2. start all runnable\n\tctx, cancelCtx := context.WithCancel(ctx)\n\tdefer cancelCtx()\n\n\tvar wg sync.WaitGroup\n\n\tfor _, runnable := range a.runnables {\n\t\ta.logger(\"starting: %s\", runnable)\n\t\terr := a.start(ctx, runnable, &wg)\n\t\tif err != nil {\n\t\t\ta.logger(\"runnable failed to start: %s\", runnable)\n\t\t\tcancelCtx()\n\t\t\tbreak\n\t\t}\n\t}\n\n\t<-ctx.Done()\n\ta.logger(\"context cancelled, starting shutdown\")\n\n\t// 3. TODO: cancel component in reverse order\n\n\twg.Wait()\n\n\treturn nil\n}", "func (s *SystemTap) Run() error {\n\treturn s.P.Run()\n}" ]
[ "0.8116523", "0.72560894", "0.7200513", "0.70855904", "0.69775754", "0.692683", "0.687408", "0.686363", "0.6770994", "0.6596238", "0.658861", "0.657219", "0.6472527", "0.6390534", "0.63787776", "0.6367142", "0.63598305", "0.63289285", "0.6238836", "0.6215028", "0.6201569", "0.617359", "0.6167164", "0.6147951", "0.6141452", "0.6133418", "0.610654", "0.6096527", "0.6072421", "0.6063616", "0.60621", "0.602902", "0.60138535", "0.5998334", "0.59950024", "0.59887594", "0.59874725", "0.59794587", "0.59772396", "0.59757286", "0.5971887", "0.59628624", "0.5956802", "0.5946566", "0.59446937", "0.59290314", "0.59274846", "0.59210914", "0.5917197", "0.5903472", "0.589001", "0.58836037", "0.5878857", "0.58692175", "0.5868251", "0.586823", "0.58557135", "0.5855471", "0.5842074", "0.5841935", "0.5835238", "0.5809756", "0.5798422", "0.57844514", "0.57819504", "0.57787853", "0.5776545", "0.57737774", "0.5770529", "0.5757255", "0.57552403", "0.57525796", "0.5746538", "0.5740027", "0.5738014", "0.57355905", "0.57315224", "0.57307315", "0.572842", "0.572779", "0.57270545", "0.57242304", "0.57204294", "0.5719506", "0.57041055", "0.5696046", "0.5694238", "0.5684264", "0.5680408", "0.5669911", "0.5661901", "0.56593984", "0.5653447", "0.5643859", "0.56438303", "0.56391144", "0.5636539", "0.56362504", "0.5628253", "0.5623357", "0.5620659" ]
0.0
-1
Subscribe subscribes to the update of todos.
func (app *Application) Subscribe(store *todo.Store) { store.Register(app.subscriber) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (n *notifier) Subscribe(ch chan<- []Update) {\n\tn.mu.Lock()\n\tdefer n.mu.Unlock()\n\tn.subs = append(n.subs, ch)\n}", "func (u *Updater) Subscribe(s *Server) {\n\tu.mux.Lock()\n\tu.listeners = append(u.listeners, s)\n\tu.mux.Unlock()\n}", "func (d *Demo) Subscribe(recv backend.Receiver) {\n\td.Lock()\n\tdefer d.Unlock()\n\n\td.subscriber = recv\n\n\t// Release the lock before running an update.\n\tgo d.updateAll()\n}", "func Run() {\n\tmodels.Subscribe(handleUpdate)\n}", "func (l *ObserverList) Subscribe(obs Observer) {\n\tl.Lock()\n\tl.Observers = append(l.Observers, obs)\n\tl.Unlock()\n}", "func (c *Coordinator) Subscribe(ss ...func(*Config) error) {\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\n\tc.subscribers = append(c.subscribers, ss...)\n}", "func (h *Handler) apiSubscribe(w http.ResponseWriter, r *http.Request) {\n\t// Extract request parameters\n\tevent := route.Param(r.Context(), \"event\")\n\n\t// Upgrade connection to websocket\n\tws, err := upgrader.Upgrade(w, r, nil)\n\tif err != nil {\n\t\tlog.Print(\"Could not upgrade:\", err)\n\t\treturn\n\t}\n\tdefer ws.Close()\n\n\tws.SetPongHandler(func(string) error { ws.SetReadDeadline(time.Now().Add(pongWait)); return nil })\n\n\tdone := make(chan struct{})\n\n\tgo h.ping(ws, done)\n\n\terr = h.client.SubscribeUntil(event,\n\t\tfunc(eventName string, eventBytes []byte) bool {\n\t\t\tmsg := struct {\n\t\t\t\tName string `json:\"name\"`\n\t\t\t\tData string `json:\"data\"`\n\t\t\t}{Name: eventName, Data: string(eventBytes)}\n\t\t\tmsgTxt, err := json.Marshal(msg)\n\t\t\tif err != nil {\n\t\t\t\th.logger.Error(\"json:\", err)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\terr = ws.WriteMessage(websocket.TextMessage, msgTxt)\n\t\t\tif err != nil {\n\t\t\t\th.logger.Error(\"Write error:\", err)\n\t\t\t\tdone <- struct{}{}\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t<-done\n}", "func (_m *LogPollerWrapper) SubscribeToUpdates(name string, subscriber types.RouteUpdateSubscriber) {\n\t_m.Called(name, subscriber)\n}", "func (d *RMQ) Subscribe(model interface{}) interface{} { return nil }", "func (h *Handler) Subscribe(c *session.Client, topics *[]string) {\n\th.logger.Info(fmt.Sprintf(\"Subscribe() - username: %s, clientID: %s, topics: %s\", c.Username, c.ID, strings.Join(*topics, \",\")))\n}", "func (s *Store) NotifySubscribers(ctx context.Context, summary ChangeSummary) {\n\ts.subscribers.NotifyAll(ctx, s, summary)\n}", "func (s ec2sessions) SubscribeForDeletions() {\n\tsub, err := sc.Subscribe(\"deployer.status\", s.terminationHandler)\n\tif err != nil {\n\t\tfmt.Println(\"Failed to Subscribe to nats topic\", err.Error())\n\t}\n\t_ = sub\n}", "func (tr *Transport) SubscribeTwinUpdates(ctx context.Context, mux transport.TwinStateDispatcher) error {\n\treturn ErrNotImplemented\n}", "func (h *handler) Subscribe(c *session.Client, topics *[]string) {\n\tif c == nil {\n\t\th.logger.Error(LogErrFailedSubscribe + (ErrClientNotInitialized).Error())\n\t\treturn\n\t}\n\th.logger.Info(fmt.Sprintf(LogInfoSubscribed, c.ID, strings.Join(*topics, \",\")))\n}", "func (s *Store) Subscribe(id string, up chan uint64) {\n\ts.subs = append(s.subs, subscription{id: id, ch: up})\n}", "func (b *EventStreamBroker) UpdateSubscriptionsHandler(w http.ResponseWriter, r *http.Request) {\n\n\tif r.Method != \"POST\" {\n\t\thttp.Error(w, \"Only POST method allowed\", http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\th := w.Header()\n\th.Set(\"Cache-Control\", \"no-cache\")\n\th.Set(\"Connection\", \"keep-alive\")\n\th.Set(\"Access-Control-Allow-Origin\", \"*\")\n\n\t// Incoming request data\n\tvar reqData updateSubscriptionsData\n\n\t// Decode JSON body\n\tdec := json.NewDecoder(r.Body)\n\tif err := dec.Decode(&reqData); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// If the ID isn't provided, that means it is a new client\n\t// So generate an ID and create a new client.\n\tif reqData.SessID == \"\" {\n\t\thttp.Error(w, \"Session ID is required 'session_id'\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tb.mu.RLock()\n\tclient, ok := b.clients[reqData.SessID]\n\tb.mu.RUnlock()\n\tif !ok {\n\t\thttp.Error(w, \"Invalid session ID\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tctx := r.Context()\n\n\tvar wg sync.WaitGroup\n\n\tfor _, topic := range reqData.Add {\n\t\twg.Add(1)\n\t\tgo func(t string) {\n\t\t\tif err := b.subscriptionBroker.SubscribeClient(client, t); err != nil {\n\t\t\t\tlog.Println(\"Error:\", err)\n\n\t\t\t\td, _ := json.Marshal(map[string]interface{}{\n\t\t\t\t\t\"error\": map[string]string{\n\t\t\t\t\t\t\"code\": \"subscription-failure\",\n\t\t\t\t\t\t\"message\": fmt.Sprintf(\"Cannot subscribe to topic %v\", t),\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t\tclient.writeChannel <- d\n\t\t\t}\n\t\t\twg.Done()\n\t\t}(topic)\n\t}\n\n\tfor _, topic := range reqData.Remove {\n\t\twg.Add(1)\n\t\tgo func(t string) {\n\t\t\tb.subscriptionBroker.UnsubscribeClient(ctx, client, t)\n\t\t\twg.Done()\n\t\t}(topic)\n\t}\n\n\twg.Wait()\n\n\tclient.mu.RLock()\n\tlog.Printf(\"Client '%v' subscriptions updated, total topics subscribed: %v \\n\", client.sessID, len(client.topics))\n\tclient.mu.RUnlock()\n\n\t// Return the ID of the client.\n\tenc := json.NewEncoder(w)\n\tif err := enc.Encode(map[string]string{\"session_id\": reqData.SessID}); err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n}", "func SubscribeToEvents() {\n\tnotesService := notes.NewNotesService(os.Getenv(\"MICRO_API_TOKEN\"))\n\trsp, err := notesService.Events(&notes.EventsRequest{\n\t\tId: \"63c0cdf8-2121-11ec-a881-0242e36f037a\",\n\t})\n\tfmt.Println(rsp, err)\n}", "func Subscribe(callback func(models.Update), absolute []time.Time, relative []time.Duration) int64 {\n\tif callback == nil {\n\t\treturn -1\n\t}\n\n\tif absolute == nil {\n\t\tabsolute = make([]time.Time, 0)\n\t}\n\tif relative == nil {\n\t\trelative = make([]time.Duration, 0)\n\t}\n\n\tid := rand.Int63()\n\n\t// round timestamps\n\tfor i, t := range absolute {\n\t\tabsolute[i] = models.Round(t)\n\t}\n\n\t// remove outdated relative timestamps\n\tfor i, d := range relative {\n\t\tif d <= -1*outdatedAfter {\n\t\t\trelative = append(relative[:i], relative[i+1:]...)\n\t\t}\n\t}\n\n\ts := subscriber{\n\t\tcallback: callback,\n\t\ttimestamps: absolute,\n\t\trelativeTimestamps: relative,\n\t}\n\n\tsm.Lock()\n\tsubscribers[id] = &s\n\tsm.Unlock()\n\n\tgo func() {\n\t\tcm.RLock()\n\t\tfor _, u := range cache {\n\t\t\tnotify(u, &s)\n\t\t}\n\t\tcm.RUnlock()\n\t}()\n\n\treturn id\n}", "func Subscribe(conn net.Conn, command []string, pubsub *PubSub) {\n\n\tfmt.Println(\"SUBSCRIBE TO:\", command[1:])\n\n\tch := make(chan string)\n\n\tdefer func() {\n\t\tconn.Close()\n\t\tpubsub.Unsubscribe <- UnsubscribeEvent{command[1], ch}\n\t}()\n\n\tpubsub.Subscribe <- SubscribeEvent{command[1], ch}\n\n\tfor msg := range ch {\n\t\t//fmt.Fprintf(conn, \"%s\\n\", msg)\n\t\t_, err := conn.Write([]byte(msg + \"\\n\"))\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}\n}", "func (hubPtr *Hub) Subscribe(sink chan<- accounts.WalletEvent) event.Subscription {\n\t// We need the mutex to reliably start/stop the update loop\n\thubPtr.stateLock.Lock()\n\tdefer hubPtr.stateLock.Unlock()\n\n\t// Subscribe the Called and track the subscriber count\n\tsub := hubPtr.updateScope.Track(hubPtr.updateFeed.Subscribe(sink))\n\n\t// Subscribers require an active notification loop, start it\n\tif !hubPtr.updating {\n\t\thubPtr.updating = true\n\t\tgo hubPtr.updater()\n\t}\n\treturn sub\n}", "func (h *Hookbot) ServeSubscribe(conn *websocket.Conn, r *http.Request) {\n\ttopic := Topic(r)\n\n\tlistener := h.Add(topic)\n\tdefer h.Del(listener)\n\n\tclosed := make(chan struct{})\n\n\tgo func() {\n\t\tdefer close(closed)\n\t\tfor {\n\t\t\tif _, _, err := conn.NextReader(); err != nil {\n\t\t\t\tconn.Close()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\tvar message Message\n\n\tfor {\n\t\tselect {\n\t\tcase message = <-listener.c:\n\t\tcase <-closed:\n\t\t\treturn\n\t\t}\n\n\t\tconn.SetWriteDeadline(time.Now().Add(90 * time.Second))\n\t\t_, isRecursive := recursive(topic)\n\t\tmsgBytes := []byte{}\n\t\tif isRecursive {\n\t\t\tmsgBytes = append(msgBytes, message.Topic...)\n\t\t\tmsgBytes = append(msgBytes, '\\x00')\n\t\t\tmsgBytes = append(msgBytes, message.Body...)\n\t\t} else {\n\t\t\tmsgBytes = message.Body\n\t\t}\n\t\terr := conn.WriteMessage(websocket.BinaryMessage, msgBytes)\n\t\tswitch {\n\t\tcase err == io.EOF || IsConnectionClose(err):\n\t\t\treturn\n\t\tcase err != nil:\n\t\t\tlog.Printf(\"Error in conn.WriteMessage: %v\", err)\n\t\t\treturn\n\t\t}\n\t}\n}", "func (h *Handler) AuthSubscribe(c *session.Client, topics *[]string) error {\n\th.logger.Info(fmt.Sprintf(\"AuthSubscribe() - clientID: %s, topics: %s\", c.ID, strings.Join(*topics, \",\")))\n\tfor i := range *topics {\n\t\th.DLMap.Store(\"/obj_dl/1/test/\"+(*topics)[i], (*topics)[i])\n\t\t(*topics)[i] = \"/obj_dl/1/test/\"+(*topics)[i]\n\t\th.logger.Debug(\"sub to \" + (*topics)[i])\n\t}\n\treturn nil\n}", "func (client *Client) SubscribeToLogsAPI(ctx context.Context, logEvents []string) ([]byte, error) {\n\tURL := client.baseURL + logsURL\n\n\treqBody, err := json.Marshal(map[string]interface{}{\n\t\t\"destination\": map[string]interface{}{\"protocol\": \"HTTP\", \"URI\": fmt.Sprintf(\"http://sandbox:%v\", receiverPort)},\n\t\t\"types\": logEvents,\n\t\t\"buffering\": map[string]interface{}{\"timeoutMs\": timeoutMs, \"maxBytes\": maxBytes, \"maxItems\": maxItems},\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\theaders := map[string]string{\n\t\textensionIdentiferHeader: client.extensionID,\n\t}\n\tvar response []byte\n\tif ctx != nil {\n\t\tresponse, err = client.MakeRequestWithContext(ctx, headers, bytes.NewBuffer(reqBody), \"PUT\", URL)\n\t} else {\n\t\tresponse, err = client.MakeRequest(headers, bytes.NewBuffer(reqBody), \"PUT\", URL)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn response, nil\n}", "func (m *Mux) Subscribe(ds *discordgo.Session, dm *discordgo.Message, ctx *Context) {\n\tresp := \"\\n\"\n\n\tid, _ := strconv.Atoi(ctx.Fields[len(ctx.Fields) -1])\n\tif id >= 0 && id < len(Config.Feeds) {\n\t\tvar sub Subscription\n\n\t\t// Check if already subscribed\n\t\tfor _, v := range Config.Subs {\n\t\t\tif v.ChanID == dm.ChannelID && v.SubID == id {\n\t\t\t\tresp += \"Denied subscription. Already subscribed in this channel.\"\n\t\t\t\tgoto NOSUB\n\t\t\t}\n\t\t}\n\t\t\n\t\tsub.ChanID = dm.ChannelID\n\t\tsub.SubID = id\n\t\n\t\t// Might not be thread-safe\n\t\tConfig.Subs = append(Config.Subs, sub)\n\t\tresp += \"Subscribed.\"\n\t\tNOSUB:\n\t} else {\n\t\tresp += \"Denied subscription. Invalid stream id, see: list command\"\n\t}\n\t\n\tresp += \"\\n\"\n\tds.ChannelMessageSend(dm.ChannelID, resp)\n\n\treturn\n}", "func (opcuaExport *OpcuaExport) Subscribe() {\n\tglog.Infof(\"-- Initializing message bus context\")\n\tdefer opcuaExport.configMgr.Destroy()\n\n\tnumOfSubscriber, _ := opcuaExport.configMgr.GetNumSubscribers()\n\tfor i := 0; i < numOfSubscriber; i++ {\n\t\tsubctx, err := opcuaExport.configMgr.GetSubscriberByIndex(i)\n\t\tif err != nil {\n\t\t\tglog.Errorf(\"Failed to get subscriber context : %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\tsubTopics, err := subctx.GetTopics()\n\t\tif err != nil {\n\t\t\tglog.Errorf(\"Failed to fetch topics : %v\", err)\n\t\t\treturn\n\t\t}\n\n\t\tconfig, err := subctx.GetMsgbusConfig()\n\t\tif err != nil {\n\t\t\tglog.Errorf(\"Failed to fetch msgbus config : %v\", err)\n\t\t\treturn\n\t\t}\n\t\tgo worker(opcuaExport, config, subTopics[0])\n\t\tsubctx.Destroy()\n\t}\n\t\n}", "func (dtp *Datetimepicker) Subscribe(subscription chan time.Time) {\n\tdtp.dtp.Call(\"on\", \"dp.change\", func(e *js.Object) {\n\t\tnewDate := e.Get(\"date\")\n\t\tif !newDate.Bool() {\n\t\t\tsubscription <- time.Time{}\n\t\t\treturn\n\t\t}\n\t\tsubscription <- newDate.Call(\"toDate\").Interface().(time.Time)\n\t})\n}", "func (c *Crawler) notifySubscribers(update BlockUpdate) {\n\tfor subscriber, _ := range c.subscribers {\n\t\tsubscriber <- update\n\t}\n}", "func (s *Server) Subscribe(rw http.ResponseWriter, req *http.Request) {\n\tlog.Printf(\"subscribe [%s]\", req.RemoteAddr)\n\tflusher, ok := rw.(http.Flusher)\n\n\tif !ok {\n\t\thttp.Error(rw, \"Streaming unsupported!\", http.StatusInternalServerError)\n\t\treturn\n\t}\n\t// Set the headers related to event streaming.\n\trw.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\trw.Header().Set(\"Content-Type\", \"text/event-stream\")\n\trw.Header().Set(\"Cache-Control\", \"no-cache\")\n\trw.Header().Set(\"Connection\", \"keep-alive\")\n\n\t// create communication channel and register\n\tc := make(chan []byte)\n\ts.register <- c\n\n\t// listen to the closing of the http connection via the CloseNotifier\n\tnotify := rw.(http.CloseNotifier).CloseNotify()\n\tgo func() {\n\t\t<-notify\n\t\tlog.Printf(\"unsubscribe [%s]\", req.RemoteAddr)\n\t\ts.unregister <- c\n\t}()\n\n\tfor msg := range c {\n\t\t_, err := fmt.Fprintf(rw, \"%s\\n\", msg)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"[%s] %v\", req.RemoteAddr, err)\n\t\t\ts.unregister <- c\n\t\t\tbreak\n\t\t}\n\t\tflusher.Flush()\n\t}\n}", "func (s *SubscriptionHandler) Update(creatures []*entity.Creature) {\n\tfor _, fn := range s.entitiesChangedSubscriptions {\n\t\tfn(creatures)\n\t}\n}", "func (sn *ViewUpdateNotification) Notify(sub ViewUpdateSubscriber) {\n\tsn.do(func() {\n\t\tsn.register[sub] = len(sn.subs)\n\t\tsn.subs = append(sn.subs, sub)\n\t})\n}", "func Subscribe() {\n\tpath, err := config.TempFile(\"subscription.yaml\")\n\tassert.FailOnError(err)\n\tlog.Printf(\"output: %s\\n\", cmd.MustSucceed(\"oc\", \"apply\", \"-f\", path).Stdout())\n}", "func (p RPCServer) Subscribe(ctx context.Context, in *pb.SubscriptionRequest) (*pb.Subscription, error) {\n\tsubID := *p.currentSubID\n\t*p.currentSubID++\n\n\tlogrus.WithField(\"topic\", in.Topic).WithField(\"subID\", subID).Debug(\"subscribed to new messages\")\n\n\tp.subChannels[subID] = make(chan []byte)\n\tp.cancelChannels[subID] = make(chan bool)\n\n\ts, err := p.service.RegisterHandler(in.Topic, func(b []byte) error {\n\t\tselect {\n\t\tcase p.subChannels[subID] <- b:\n\t\tdefault:\n\t\t}\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tp.subscriptions[subID] = s\n\n\treturn &pb.Subscription{ID: subID}, nil\n}", "func (channel Channel) subscribe(observers ...Observer) {\n\tchannel.checkChannelMap()\n\tfor _, observer := range observers {\n\t\tchannel.observers[observer.id] = observer\n\t\tfmt.Printf(\"New observer %s subscribed in channel %s \\n\", observer.id, channel.id)\n\t}\n}", "func (ps PubSub) Subscribe(\n\tctx context.Context, ids *ttnpb.ApplicationIdentifiers, handler func(context.Context, *ttnpb.ApplicationUp) error,\n) error {\n\tuid := unique.ID(ctx, ids)\n\tsub := ps.Redis.Subscribe(ctx, ps.uidUplinkKey(uid))\n\tdefer sub.Close()\n\n\t// sub.Receive(.*) will not respect the asynchronous context\n\t// cancelation, only a context deadline, if present.\n\t// As such, we use the buffered channel instead and do the\n\t// asynchronous select here. This allows us to close the\n\t// subscription on context cancellation.\n\tch := sub.Channel()\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\n\t\tcase msg, ok := <-ch:\n\t\t\tif !ok {\n\t\t\t\treturn errChannelClosed.New()\n\t\t\t}\n\n\t\t\tup := &ttnpb.ApplicationUp{}\n\t\t\tif err := ttnredis.UnmarshalProto(msg.Payload, up); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tif err := handler(ctx, up); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n}", "func (v *Config) Subscribe(h ReloadHandler) {\n\t// ignore exists.\n\tfor _, v := range v.reloadHandlers {\n\t\tif v == h {\n\t\t\treturn\n\t\t}\n\t}\n\n\tv.reloadHandlers = append(v.reloadHandlers, h)\n}", "func (c *observerSubComponent) Subscribe(cb func(Notification)) {\n\tc.callbackLock.Lock()\n\tdefer c.callbackLock.Unlock()\n\tc.callback = cb\n\tc.once.Do(func() {\n\t\tclose(c.subscribed)\n\t})\n}", "func (v *View) Subscribe() error {\n\treq := &subscribeToViewReq{\n\t\tv: v,\n\t\terr: make(chan error),\n\t}\n\tdefaultWorker.c <- req\n\treturn <-req.err\n}", "func (t *Topic) Subscribe(cb *func(interface{})) {\n\tt.subs = append(t.subs, cb)\n}", "func (cg *CandlesGroup) subscribe() {\n\tfor _, symb := range cg.symbols {\n\t\tmessage := candlesSubsMessage{\n\t\t\tEvent: eventSubscribe,\n\t\t\tChannel: \"candles\",\n\t\t\tKey: \"trade:1m:t\" + strings.ToUpper(symb.OriginalName),\n\t\t}\n\n\t\tif err := cg.wsClient.Write(message); err != nil {\n\t\t\tlog.Printf(\"[BITFINEX] Error subsciring to %v candles\", symb.Name)\n\t\t\tcg.restart()\n\t\t\treturn\n\t\t}\n\t}\n\tlog.Println(\"[BITFINEX] Subscription ok\")\n}", "func (l *Logger) Subscribe(c chan DataUnit) {\n\tl.consumers = append(l.consumers, c)\n}", "func (tr *ModuleTransport) SubscribeTwinUpdates(ctx context.Context, mux transport.TwinStateDispatcher) error {\n\treturn tr.sub(tr.subTwinUpdates(ctx, mux))\n}", "func subscribe(t *testing.T, con *websocket.Conn, eventid string) {\n\terr := con.WriteJSON(rpctypes.RPCRequest{\n\t\tJSONRPC: \"2.0\",\n\t\tID: \"\",\n\t\tMethod: \"subscribe\",\n\t\tParams: []interface{}{eventid},\n\t})\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n}", "func (message UserStatusMessage) Subscribe(session *Session, payload interface{}) error {\n\treturn session.sendPut(\"/messaging/subscriptions/status/user-statuses\", payload, nil)\n}", "func (w *Watcher) Subscribe(sink chan<- []*zeroex.OrderEvent) event.Subscription {\n\treturn w.orderScope.Track(w.orderFeed.Subscribe(sink))\n}", "func NotifySubscribers(e SyncEvent, m SyncMessage) error {\n\tif manager == nil {\n\t\treturn ErrManagerNotInitialized\n\t}\n\n\t// Get the repo from the version.\n\trepo, err := manager.repoFromVersion(m.Version)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Use the repo notification system to notify internal subscribers.\n\treturn repo.notifySubscribers(e, m)\n}", "func (ps *PubsubApi) LogsSubscribe(ctx context.Context, crit filters.FilterCriteria) (*rpc.Subscription, error) {\n\tif ps.s.context().eventBus == nil {\n\t\t// @Note: Should not happen!\n\t\tlog.Error(\"rpc: eventbus nil, not support Subscribetion!!!\")\n\t\treturn nil, rpc.ErrNotificationsUnsupported\n\t}\n\n\tnotifier, supported := rpc.NotifierFromContext(ctx)\n\tif !supported {\n\t\treturn nil, rpc.ErrNotificationsUnsupported\n\t}\n\n\tsubscription := notifier.CreateSubscription()\n\n\tsuberName := fmt.Sprintf(\"rpc-log-suber-%s\", subscription.ID)\n\tebCtx := context.Background()\n\tlogsCh := make(chan interface{}, 128)\n\tif err := ps.context().eventBus.Subscribe(ebCtx, suberName, types.EventQueryLog, logsCh); err != nil {\n\t\tlog.Warn(\"rpc: Subscribe fail\", \"err\", err)\n\t\treturn nil, err\n\t}\n\n\tgo func() {\n\t\tdefer ps.context().eventBus.Unsubscribe(ebCtx, suberName, types.EventQueryLog)\n\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase ev := <-logsCh:\n\t\t\t\tlogs := ev.(types.EventDataLog).Logs\n\t\t\t\tlogs = filterLogs(logs, crit.FromBlock.ToInt(), crit.ToBlock.ToInt(), crit.Addresses, crit.Topics)\n\t\t\t\tfor _, l := range logs {\n\t\t\t\t\tnotifier.Notify(subscription.ID, l)\n\t\t\t\t\tlog.Info(\"rpc: notify success\", \"suber\", suberName, \"log\", l)\n\t\t\t\t}\n\t\t\tcase <-notifier.Closed():\n\t\t\t\tlog.Info(\"rpc LogSubscribe: unsubscribe\", \"suber\", suberName)\n\t\t\t\treturn\n\t\t\tcase err := <-subscription.Err():\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Error(\"rpc subscription: error\", \"suber\", suberName, \"err\", err)\n\t\t\t\t} else {\n\t\t\t\t\tlog.Info(\"rpc subscription: exit\", \"suber\", suberName)\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}()\n\n\tlog.Info(\"rpc LogsSubscribe: ok\", \"name\", suberName, \"crit\", crit.String())\n\treturn subscription, nil\n}", "func (s *service) Subscribe(stationID int, listener Listener) {\n\ts.fetcher.Subscribe(stationID, listener)\n}", "func (l *logPollerWrapper) SubscribeToUpdates(subscriberName string, subscriber evmRelayTypes.RouteUpdateSubscriber) {\n\tif l.pluginConfig.ContractVersion == 0 {\n\t\t// in V0, immediately set contract address to Oracle contract and never update again\n\t\tif err := subscriber.UpdateRoutes(l.routerContract.Address(), l.routerContract.Address()); err != nil {\n\t\t\tl.lggr.Errorw(\"LogPollerWrapper: Failed to update routes\", \"subscriberName\", subscriberName, \"error\", err)\n\t\t}\n\t} else if l.pluginConfig.ContractVersion == 1 {\n\t\tl.mu.Lock()\n\t\tdefer l.mu.Unlock()\n\t\tl.subscribers[subscriberName] = subscriber\n\t}\n}", "func (node *Node) Subscribe(ctx context.Context, project string) error {\n\tif !node.IsOnline() {\n\t\treturn ErrOffline\n\t}\n\tsub, err := node.sh.PubSubSubscribe(project)\n\tif err != nil {\n\t\treturn err\n\t}\n\tnode.subscription = sub\n\tnode.project = project\n\treturn nil\n}", "func (s *State) updateSubscribers(revertedNodes []*blockNode, appliedNodes []*blockNode) {\n\t// Add the changes to the change set.\n\ts.revertUpdates = append(s.revertUpdates, revertedNodes)\n\ts.applyUpdates = append(s.applyUpdates, appliedNodes)\n\n\t// Notify each update channel that a new update is ready.\n\tfor _, subscriber := range s.subscriptions {\n\t\t// If the channel is already full, don't block.\n\t\tselect {\n\t\tcase subscriber <- struct{}{}:\n\t\tdefault:\n\t\t}\n\t}\n}", "func (n *notifier) Unsubscribe(ch chan<- []Update) {\n\tn.mu.Lock()\n\tdefer n.mu.Unlock()\n\tsubs := make([]chan<- []Update, 0, len(n.subs))\n\tfor _, s := range n.subs {\n\t\tif s != ch {\n\t\t\tsubs = append(subs, s)\n\t\t}\n\t}\n\tn.subs = subs\n}", "func (b *Topics) Subscribe(s *Subscriber, topics ...string) {\n\tb.topic_lock.Lock()\n\tdefer b.topic_lock.Unlock()\n\tfor _, topic := range topics {\n\t\tif nil == b.sub_topics[topic] {\n\t\t\tfmt.Println(\"!!! topic does not exist !!!\")\n\t\t}\n\t\ts.AddTopic(topic)\n\t\tb.sub_topics[topic][s.id] = s\n\t}\n}", "func (s *Server) ringSubscribersNotify() {\n\tfor change := range s.subsChangeChan {\n\t\ts.ringSubs.RLock()\n\t\tring := &pb.Ring{\n\t\t\tRing: *change.rb,\n\t\t\tVersion: change.v,\n\t\t}\n\t\tfor id, ch := range s.ringSubs.subs {\n\t\t\tgo func(id string, ch chan *pb.Ring, ring *pb.Ring) {\n\t\t\t\tch <- ring\n\t\t\t}(id, ch, ring)\n\t\t}\n\t\ts.ringSubs.RUnlock()\n\t}\n}", "func subscribed(src *v1alpha1.AWSSNSSource) {\n\tsrc.Status.MarkSubscribed(tSubARN.String())\n}", "func (app *Application) Run() error {\n\tgo func() {\n\t\tfor {\n\t\t\ttodos := <-app.subscriber\n\t\t\tapp.Update(todos)\n\t\t}\n\t}()\n\n\treturn app.Application.Run()\n}", "func Subscribe(subscription *pubsub.Subscription) {\n\tctx := context.Background()\n\tbufCh := make(chan TaxiData, bufferCount)\n\tgo batchWriter(bufCh)\n\n\terr := subscription.Receive(ctx, func(ctx context.Context, msg *pubsub.Message) {\n\t\tvar data TaxiData\n\t\tvar err error\n\t\tif err = json.Unmarshal(msg.Data, &data); err != nil {\n\t\t\tlog.Printf(\"could not decode message data: %#v\", msg)\n\t\t\tmsg.Nack()\n\t\t\treturn\n\t\t}\n\n\t\tbufCh <- data\n\t\tmsg.Ack()\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}", "func (s *Subscriber) Subscribe(ctx context.Context, topic string, h Handler) error {\n\tfor _, w := range s.opts.wrappers {\n\t\th = w(h)\n\t}\n\n\treturn s.subscribe(ctx, topic, h)\n}", "func (fs *FilterStorage) NotifySubscribers(env *Envelope) {\n\tvar msg *ReceivedMessage\n\n\tfs.mutex.RLock()\n\tdefer fs.mutex.RUnlock()\n\n\tcandidates := fs.getSubscribersByTopic(env.Topic)\n\tfor _, sub := range candidates {\n\t\tif sub.Pow <= 0 || env.pow >= sub.Pow {\n\t\t\tmsg = env.GetMessageFromEnvelope(sub)\n\t\t\tif msg == nil {\n\t\t\t\tfmt.Println(\"\\nWhisper: failed to open message\")\n\t\t\t} else {\n\t\t\t\tfmt.Println(\"\\nWhisper: unwrapped and decrypted payload, new message for client is available\")\n\t\t\t\tsub.Mutex.Lock()\n\t\t\t\tif _, exist := sub.Messages[msg.EnvelopeHash]; !exist {\n\t\t\t\t\tsub.Messages[msg.EnvelopeHash] = msg\n\t\t\t\t}\n\t\t\t\tsub.Mutex.Unlock()\n\t\t\t}\n\t\t}\n\t}\n}", "func (c Conference) Subscribe(id uuid.UUID, topic string, out chan Notification) {\n\ttree, ok := c.Room[topic]\n\tif !ok {\n\t\ttree = &bst.BinarySearchTree{}\n\t\tc.Room[topic] = tree\n\t}\n\tc.mutex.Lock()\n\tdefer c.mutex.Unlock()\n\ttree.Add(NewSubscriber(id, out))\n}", "func (p PlatziCourse) Subscribe(name string){\n\tfmt.Printf(\"La persona %s se ha registrado al curso %s\", name, p.Name)\n}", "func (o *Okcoin) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error {\n\treturn o.handleSubscriptions(\"subscribe\", channelsToSubscribe)\n}", "func (l *ServiceList) NotifyUpdate(oldSvc, newSvc *slim_corev1.Service) {\n\tl.RLock()\n\tdefer l.RUnlock()\n\tfor _, s := range l.subs {\n\t\ts.OnUpdate(oldSvc, newSvc)\n\t}\n}", "func (c *subContext) subscribe(ctx context.Context, indCh chan<- indication.Indication) error {\n\t// Add the subscription to the subscription service\n\terr := c.subClient.Add(ctx, c.sub)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Watch the subscription task service to determine assignment of the subscription to E2 terminations\n\twatchCh := make(chan subtaskapi.Event)\n\twatchCtx, cancel := context.WithCancel(context.Background())\n\tc.cancel = cancel\n\terr = c.taskClient.Watch(watchCtx, watchCh, subscriptiontask.WithSubscriptionID(c.sub.ID))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// The subscription is considered activated, and task events are processed in a separate goroutine.\n\tgo c.processTaskEvents(watchCtx, watchCh, indCh)\n\treturn nil\n}", "func (hc *Conn) Subscribe(topic string) {\n\thc.parent.subscribe <- subscription{topic, hc}\n}", "func (s *Server) Subscribe(ping *pb.Ping, stream pb.Echo_SubscribeServer) (err error) {\n\tctx := stream.Context()\n\ts.changeSubscriberCount(1)\n\tdefer s.changeSubscriberCount(-1)\n\tticker := time.NewTicker(1 * time.Second)\n\tdefer ticker.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase timestamp := <-ticker.C:\n\t\t\terr = stream.Send(&pb.Pong{\n\t\t\t\tMessage: ping.Message,\n\t\t\t\tTimestamp: timestamp.Unix(),\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\t}\n\t}\n}", "func (s *Subscriber) Subscribe(ctx context.Context) error {\n\tclient, err := pubsub.NewClient(ctx, s.config.ProjectID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"pubsub.NewClient: %v\", err)\n\t}\n\n\tsub := client.Subscription(s.config.SubscriptionID)\n\tsub.ReceiveSettings.MaxOutstandingMessages = s.config.ConcurrencyLevel\n\treturn sub.Receive(ctx, func(ctx context.Context, msg *pubsub.Message) {\n\t\ts.Stats.AddTotal(1)\n\t\tif err := s.ShipToHoneycomb(ctx, msg); err != nil {\n\t\t\t// If we got an unexpected error, record stat, print, and nack.\n\t\t\tif err != ErrEventSkippedDueToSampling {\n\t\t\t\ts.Stats.AddError(1)\n\t\t\t\tfmt.Fprintln(os.Stderr, err)\n\t\t\t\tmsg.Nack()\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\ts.Stats.AddSampled(1) // record that we kept this message.\n\t\t}\n\t\tmsg.Ack()\n\t})\n}", "func (c *WSClient) Subscribe(ctx context.Context, query string) error {\n\tparams := map[string]interface{}{\"query\": query}\n\treturn c.Call(ctx, \"subscribe\", params)\n}", "func (backend *RedisBackend) Subscribe(queuename string) {\n\terr := backend.pubsub.Subscribe(fmt.Sprintf(\"%s_%s\", TITLE, queuename))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}", "func Notify(id int) {\n\tresp := \".\\n\"\n\tresp += \"**\" + Config.Feeds[id].Feed.Title + \": **\" + \"\\n\"\n\tresp += Config.Feeds[id].Feed.Items[0].Date.String() + \"\\n\\n\"\n\t// If a 9front feed, extract the user ☺\n\tif strings.Contains(Config.Feeds[id].Feed.Items[0].Link, \"http://code.9front.org/hg/\") {\n\t\tlines := strings.Split(Config.Feeds[id].Feed.Items[0].Summary, \"\\n\")\n\t\tfor i, v := range lines {\n\t\t\tif strings.Contains(v, \"<th style=\\\"text-align:left;vertical-align:top;\\\">user</th>\") {\n\t\t\t\tline := html.UnescapeString((lines[i+1])[6:len(lines[i+1])-5])\n\t\t\t\tresp += line + \"\\n\\n\"\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\tresp += \"`\" + Config.Feeds[id].Feed.Items[0].Title + \"`\" + \"\\n\"\n\tresp += \"\\n\" + Config.Feeds[id].Feed.Items[0].Link + \"\\n\"\n\tConfig.Feeds[id].Feed.Items[0].Read = true\n\tresp += \"\\n\"\n\t\n\t// Loop through subbed chans and post notification message\n\tfmt.Println(\"Looping through subs to notify...\")\n\tfor _, v := range Config.Subs {\n\t\tif v.SubID == id {\n\t\t\tSession.ChannelMessageSend(v.ChanID, resp)\n\t\t}\n\t\ttime.Sleep(10 * time.Millisecond)\n\t}\n\n\tfmt.Println(\"No new notifys for \", Config.Feeds[id].Feed.UpdateURL)\n\t\n\t/* Enable for logging if subs break\n\tfmt.Println(Config.Feeds[id].Feed.Items[0])\n\tfmt.Println(Config.Feeds[id].Feed.Items[len(Config.Feeds[id].Feed.Items)-1])\n\t*/\n}", "func (p PlatziCareer) Subscribe(name string){\n\tfmt.Printf(\"La persona %s se ha registrado a la carrera %s\", name, p.Name)\n}", "func (l *ServiceList) NotifyAdd(svc *slim_corev1.Service) {\n\tl.RLock()\n\tdefer l.RUnlock()\n\tfor _, s := range l.subs {\n\t\ts.OnAdd(svc)\n\t}\n}", "func (m *TaskManager) Subscribe(\n\tctx context.Context,\n\ttaskID string,\n\tcallback func(*TaskCallbackData) error,\n) error {\n\tif taskID == \"\" {\n\t\treturn errors.New(\"Task ID is not valid\")\n\t}\n\tfor {\n\t\ti, ok := m.taskInfos.Load(taskID)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"Task %s is not found\", taskID)\n\t\t}\n\t\ttInfo := i.(*taskInfo)\n\t\tif tInfo.future == nil {\n\t\t\treturn fmt.Errorf(\"Invalid task %s for subscription\", taskID)\n\t\t}\n\t\tselect {\n\t\tcase <-m.ctx.Done():\n\t\t\treturn errors.New(\"Task manager is cancelled\")\n\t\tcase <-ctx.Done():\n\t\t\tm.updateTime(taskID)\n\t\t\treturn errors.New(\"Subscriber is cancelled\")\n\t\tcase <-tInfo.future.Done():\n\t\t\t// Task is completed.\n\t\t\tsize := 0\n\t\t\tm.updateTime(taskID)\n\t\t\ttaskStatus := tInfo.asyncTask.CurrentTaskStatus()\n\t\t\tcallbackData := &TaskCallbackData{State: tInfo.future.State()}\n\t\t\tcallbackData.Info, size = taskStatus.Info.StringWithLen()\n\t\t\tif size > 0 {\n\t\t\t\t// Send the info messages first before any error.\n\t\t\t\terr := callback(callbackData)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\ttaskStatus.Info.Consume(size)\n\t\t\t}\n\n\t\t\tsize = 0\n\t\t\tif taskStatus.ExitStatus.Code == 0 {\n\t\t\t\tif tInfo.rpcResponseConverter != nil {\n\t\t\t\t\tresult, err := tInfo.future.Get()\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tresponse, err := tInfo.rpcResponseConverter(result)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t\tcallbackData := &TaskCallbackData{State: tInfo.future.State()}\n\t\t\t\t\tcallbackData.RPCResponse = response\n\t\t\t\t\terr = callback(callbackData)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Send the error messages.\n\t\t\t\tcallbackData.ExitCode = taskStatus.ExitStatus.Code\n\t\t\t\tcallbackData.Error, size = taskStatus.ExitStatus.Error.StringWithLen()\n\t\t\t\terr := callback(callbackData)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif size > 0 {\n\t\t\t\t\ttaskStatus.ExitStatus.Error.Consume(size)\n\t\t\t\t}\n\t\t\t}\n\t\t\tutil.FileLogger().Infof(ctx, \"Task %s is completed.\", taskID)\n\t\t\treturn io.EOF\n\t\tdefault:\n\t\t\t// Task is still running.\n\t\t\tm.updateTime(taskID)\n\t\t\ttaskStatus := tInfo.asyncTask.CurrentTaskStatus()\n\t\t\tdata, size := taskStatus.Info.StringWithLen()\n\t\t\tif size > 0 {\n\t\t\t\tcallbackData := &TaskCallbackData{Info: data, State: tInfo.future.State()}\n\t\t\t\terr := callback(callbackData)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\ttaskStatus.Info.Consume(size)\n\t\t\t}\n\t\t\ttime.Sleep(TaskProgressWaitTime)\n\t\t}\n\t}\n}", "func (p *ConfigDistributor) Subscribe(ch chan<- *Config, checks ...ConfigChangedCheckFn) error {\n\t// Check that distributor is still active\n\tif p.closed.HasFired() {\n\t\treturn ErrConfigDistributorClosed\n\t}\n\n\tp.mu.Lock()\n\tdefer p.mu.Unlock()\n\n\t// Send current config immediately even before we registered a new subscription\n\tif p.lastConfig != nil && p.shouldSendUpdatedConfig(checks, nil, p.lastConfig) {\n\t\tch <- p.lastConfig\n\t}\n\n\t// Register subscription\n\tif p.subscriptions == nil {\n\t\tp.subscriptions = make(map[chan<- *Config][]ConfigChangedCheckFn)\n\t}\n\n\tp.subscriptions[ch] = checks\n\n\t// Start monitoring goroutine\n\tif p.started.Fire() {\n\t\tgo p.monitorConfig()\n\t}\n\n\treturn nil\n}", "func (s *OHLCVService) Subscribe(conn *ws.Client, p *types.SubscriptionPayload) {\n\tsocket := ws.GetOHLCVSocket()\n\n\tohlcv, err := s.GetOHLCV(\n\t\t[]types.PairAddresses{types.PairAddresses{BaseToken: p.BaseToken, QuoteToken: p.QuoteToken}},\n\t\tp.Duration,\n\t\tp.Units,\n\t\tp.From,\n\t\tp.To,\n\t)\n\n\tif err != nil {\n\t\tlogger.Error(err)\n\t\tsocket.SendErrorMessage(conn, err.Error())\n\t\treturn\n\t}\n\n\tid := utils.GetOHLCVChannelID(p.BaseToken, p.QuoteToken, p.Units, p.Duration)\n\terr = socket.Subscribe(id, conn)\n\tif err != nil {\n\t\tlogger.Error(err)\n\t\tsocket.SendErrorMessage(conn, err.Error())\n\t\treturn\n\t}\n\n\tws.RegisterConnectionUnsubscribeHandler(conn, socket.UnsubscribeChannelHandler(id))\n\tsocket.SendInitMessage(conn, ohlcv)\n}", "func (s *Cluster) NotifySubscribe(conn security.ID, ssid subscription.Ssid) {\n\tevent := SubscriptionEvent{\n\t\tPeer: s.name,\n\t\tConn: conn,\n\t\tSsid: ssid,\n\t}\n\n\t// Add to our global state\n\ts.state.Add(event.Encode())\n\t// Create a delta for broadcasting just this operation\n\top := newSubscriptionState()\n\top.Add(event.Encode())\n\ts.gossip.GossipBroadcast(op)\n}", "func (s *Server) Subscribe(ctx context.Context, callback SubscriptionCallback, lastEventID EventID, topics ...string) error {\n\tif len(topics) == 0 {\n\t\ttopics = defaultTopicSlice\n\t}\n\n\treturn s.Provider().Subscribe(ctx, Subscription{\n\t\tCallback: callback,\n\t\tLastEventID: lastEventID,\n\t\tTopics: topics,\n\t})\n}", "func (s *service) Subscribe(ctx context.Context, req *pb.Souscription, res *pb.Response) error {\n\tlog.Println(\"The request is : %v \\n\", req)\n\n\tresp, err := s.repo.Subscribe(req)\n\tif err != nil {\n\t\ttheerror := fmt.Sprintf(\"%v --from souscription_service\", err)\n\t\tres.Done = false\n\t\tres.Errors = []*pb.Error{{\n\t\t\tCode: 400,\n\t\t\tDescription: \"souscription echouée.Veuillez contacter l'administrateur système\",\n\t\t}}\n\t\treturn errors.New(theerror)\n\t}\n\n\tres.Done = true\n\tres.Description = \"Souscription prise en compte.Un retour vous sera fait d'ici 24h\"\n\tres.Souscription = resp\n\n\t//envoi de sms pour confirmation au client\n\n\tbody := &jsonData{\n\t\tUsername: \"WEBLOGY\",\n\t\tPassword: \"WEBLOGY\",\n\t\tTelephone: req.Telephone,\n\t\tExpeditor: \"Nsia Vie CI\",\n\t\tTypeEnvoi: \"Confirmation de souscription\",\n\t\tSms: fmt.Sprintf(\"Cher(e) %s, votre souscription a été enregistrée avec succès! Vous pouvez effectuer vos cotisations. Info : 22419800\", req.Nom),\n\t}\n\turl := \"http://10.11.100.48:8084/sendSMS\"\n\tpayloadBuf := new(bytes.Buffer)\n\tjson.NewEncoder(payloadBuf).Encode(body)\n\trequest, _ := http.NewRequest(\"POST\", url, payloadBuf)\n\trequest.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresponse, er := client.Do(request)\n\n\tif er != nil {\n\t\tfmt.Printf(\"The HTTP request failed with error %s\\n\", err)\n\t} else {\n\t\tdata, _ := ioutil.ReadAll(response.Body)\n\t\tfmt.Println(string(data))\n\t}\n\n\treturn nil\n}", "func (repo *feedRepository) Subscribe(f *feed.Feed, channelname string) error {\n\t_, err := repo.db.Exec(`\n\t\tINSERT INTO feed_subscriptions (feed_id,channel_username)\n\t\tVALUES ($1, $2)\n\t\tON CONFLICT DO NOTHING\n\t\t`, f.ID, channelname)\n\tconst foreignKeyViolationErrorCode = pq.ErrorCode(\"23503\")\n\tif err != nil {\n\t\tif pgErr, isPGErr := err.(pq.Error); !isPGErr {\n\t\t\tif pgErr.Code != foreignKeyViolationErrorCode {\n\t\t\t\treturn feed.ErrChannelNotFound\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"insertion of user failed because of: %s\", err.Error())\n\t\t}\n\t}\n\treturn nil\n}", "func (h *Hub) doSubscribe(s *subscription) {\n\th.Lock()\n\tdefer h.Unlock()\n\n\t// check if there already is a subscriber, if not then create the subscription\n\tnewSubscriber, alreadyAvailable := h.subscribers[s.Topic]\n\tif !alreadyAvailable {\n\t\tnewSubscriber = &subscriber{\n\t\t\tTopic: s.Topic,\n\t\t\tconnections: make(map[*connection]bool),\n\t\t}\n\t\terr := h.subconn.Subscribe(s.Topic)\n\t\tif err != nil {\n\t\t\th.log.Println(\"Unable to subscribe user to hub subconn\")\n\t\t}\n\t}\n\n\t// add the connection to the subscriber\n\tnewSubscriber.connections[s.connection] = true\n\t// attach subscription to the hub's connections (currently nil) that was made\n\t// in doRegister\n\th.connections[s.connection] = newSubscriber\n\t// add subscriber to the hub\n\th.subscribers[newSubscriber.Topic] = newSubscriber\n\th.log.Println(\"[DEBUG] subscribed to topic:\", s.Topic)\n}", "func Subscribe(s Subscriber) error {\r\n\treturn DefaultServer.Subscribe(s)\r\n}", "func SubscribeChanges() <-chan bool {\n\treturn DefaultInstance.SubscribeChanges()\n}", "func (h *handler) AuthSubscribe(c *session.Client, topics *[]string) error {\n\tif c == nil {\n\t\treturn ErrClientNotInitialized\n\t}\n\tif topics == nil || *topics == nil {\n\t\treturn ErrMissingTopicSub\n\t}\n\n\tfor _, v := range *topics {\n\t\tif err := h.authAccess(c.Username, v); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\treturn nil\n}", "func Sub(c mqtt.Client, topic string) {\n\tvar choke = make(chan [2]string)\n\n\tvar f mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {\n\t\tchoke <- [2]string{msg.Topic(), string(msg.Payload())}\n\t}\n\tfor {\n\t\tif token := c.Subscribe(topic, 0, f); token.Wait() && token.Error() != nil {\n\t\t\tmqtt.ERROR.Println(token.Error())\n\t\t\tos.Exit(1)\n\t\t}\n\t\tfor {\n\t\t\tincoming := <-choke\n\t\t\tmqtt.ERROR.Printf(\"Received:TOPIC: %s\\n\", incoming[0])\n\t\t\twriteFile(incoming[1])\n\t\t}\n\t}\n\n}", "func (res ItemsResource) Update(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"Todo item update by id\"))\n}", "func (m *manager) Subscribe(nh datapath.NodeHandler) {\n\tm.nodeHandlersMu.Lock()\n\tm.nodeHandlers[nh] = struct{}{}\n\tm.nodeHandlersMu.Unlock()\n\t// Add all nodes already received by the manager.\n\tm.mutex.RLock()\n\tfor _, v := range m.nodes {\n\t\tv.mutex.Lock()\n\t\tif err := nh.NodeAdd(v.node); err != nil {\n\t\t\tlog.WithFields(logrus.Fields{\n\t\t\t\t\"handler\": nh.Name(),\n\t\t\t\t\"node\": v.node.Name,\n\t\t\t}).WithError(err).Error(\"Failed applying node handler following initial subscribe. Cilium may have degraded functionality. See error message for more details.\")\n\t\t}\n\t\tv.mutex.Unlock()\n\t}\n\tm.mutex.RUnlock()\n}", "func (p *Peer) updateSyncSubscriptions(subBins, quitBins []int) {\n\tif p.streamer.getPeer(p.ID()) == nil {\n\t\tlog.Debug(\"update syncing subscriptions\", \"peer not found\", p.ID())\n\t\treturn\n\t}\n\tlog.Debug(\"update syncing subscriptions\", \"peer\", p.ID(), \"subscribe\", subBins, \"quit\", quitBins)\n\tfor _, po := range subBins {\n\t\tp.subscribeSync(po)\n\t}\n\tfor _, po := range quitBins {\n\t\tp.quitSync(po)\n\t}\n}", "func (self *Subscription) Subscribe() {\n\tself.db.subscriptionsMutex.Lock()\n\tdefer self.db.subscriptionsMutex.Unlock()\n\ttypeSubs, found := self.db.subscriptions[self.typ.Name()]\n\tif !found {\n\t\ttypeSubs = make(map[string]*Subscription)\n\t\tself.db.subscriptions[self.typ.Name()] = typeSubs\n\t}\n\ttypeSubs[self.name] = self\n\treturn\n}", "func (t *Topic) Subscribe(ctx context.Context) <-chan interface{} {\n\tch := make(chan interface{})\n\tt.subs[ch] = ctx\n\treturn ch\n}", "func (r *ring) Subscribe(\n\tservice string,\n\tnotifyChannel chan<- *ChangedEvent,\n) error {\n\tr.subscribers.Lock()\n\tdefer r.subscribers.Unlock()\n\n\t_, ok := r.subscribers.keys[service]\n\tif ok {\n\t\treturn fmt.Errorf(\"service %q already subscribed\", service)\n\t}\n\n\tr.subscribers.keys[service] = notifyChannel\n\treturn nil\n}", "func (_Crowdsale *CrowdsaleFilterer) WatchBonusOffListUpdated(opts *bind.WatchOpts, sink chan<- *CrowdsaleBonusOffListUpdated) (event.Subscription, error) {\n\n\tlogs, sub, err := _Crowdsale.contract.WatchLogs(opts, \"BonusOffListUpdated\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn event.NewSubscription(func(quit <-chan struct{}) error {\n\t\tdefer sub.Unsubscribe()\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase log := <-logs:\n\t\t\t\t// New log arrived, parse the event and forward to the user\n\t\t\t\tevent := new(CrowdsaleBonusOffListUpdated)\n\t\t\t\tif err := _Crowdsale.contract.UnpackLog(event, \"BonusOffListUpdated\", log); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tevent.Raw = log\n\n\t\t\t\tselect {\n\t\t\t\tcase sink <- event:\n\t\t\t\tcase err := <-sub.Err():\n\t\t\t\t\treturn err\n\t\t\t\tcase <-quit:\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\tcase err := <-sub.Err():\n\t\t\t\treturn err\n\t\t\tcase <-quit:\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}), nil\n}", "func (l *LiveQuery) Subscribe(onSnapshot SnapshotFunction, onError ErrorFunction) UnsubscribeFunction {\n\tconn := l.config.Transport.GetConn()\n\tvar stream proto.SpaceCloud_RealTimeClient\n\tgo func() {\n\t\tfor {\n\t\t\tstate := conn.GetState()\n\t\t\tif state.String() == \"READY\" {\n\t\t\t\tvar err error\n\t\t\t\tstream, err = l.config.Transport.GetStub().RealTime(context.TODO())\n\t\t\t\tif err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfindJSON, err := json.Marshal(l.find)\n\t\t\t\tif err != nil {\n\t\t\t\t\tlog.Println(\"Could not marshal the where clause\")\n\t\t\t\t}\n\t\t\t\tsubscribeRequest := &proto.RealTimeRequest{Token: l.config.Token, DbType: l.db, Project: l.config.Project, Group: l.col, Type: utils.TypeRealtimeSubscribe, Id: l.id, Where: findJSON, Options: l.getOptions()}\n\t\t\t\tif err := stream.Send(subscribeRequest); err != nil {\n\t\t\t\t\tlog.Println(\"Failed to send the subscribe request\")\n\t\t\t\t}\n\t\t\t\tfor {\n\t\t\t\t\tin, err := stream.Recv()\n\t\t\t\t\tif err == io.EOF {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tlog.Println(\"Failed to receive a request:\", err)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\n\t\t\t\t\tif in.Id == l.id {\n\t\t\t\t\t\tif in.Ack {\n\t\t\t\t\t\t\tl.snapshotCallback(in.FeedData, onSnapshot)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tonError(errors.New(in.Error))\n\t\t\t\t\t\t\tl.unsubscribe(stream)()\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// log.Println(\"Not connected. Attempting to Reconnect...\")\n\t\t\t\tconn.WaitForStateChange(context.TODO(), state)\n\t\t\t}\n\t\t}\n\t}()\n\treturn l.unsubscribe(stream)\n}", "func (s *Subscriber) Subscribe(out chan *commons.WebResource) {\n\n\terr := s.sub.Receive(s.context, func(ctx context.Context, msg *pubsub.Message) {\n\t\titem := &commons.WebResource{}\n\t\tif err := json.Unmarshal(msg.Data, &item); err != nil {\n\t\t\tlogger.Printf(\"Error while decoding PubSub message: %#v\", msg)\n\t\t\tmsg.Nack()\n\t\t} else {\n\t\t\t//logger.Printf(\"Event -> %s\", item.String())\n\t\t\tout <- item\n\t\t\tmsg.Ack()\n\t\t}\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n}", "func EventSubscribeH(w http.ResponseWriter, r *http.Request) {\n\n\tlog.V(logLevel).Debugf(\"%s:subscribe:> subscribe on subscribe\", logPrefix)\n\n\tif r.Method != \"GET\" {\n\t\thttp.Error(w, \"Method not allowed\", http.StatusMethodNotAllowed)\n\t\treturn\n\t}\n\n\tlog.V(logLevel).Debugf(\"%s:subscribe:> watch all events\", logPrefix)\n\n\tvar (\n\t\tsm = distribution.NewServiceModel(r.Context(), envs.Get().GetStorage())\n\t\tnm = distribution.NewNamespaceModel(r.Context(), envs.Get().GetStorage())\n\t\tcm = distribution.NewClusterModel(r.Context(), envs.Get().GetStorage())\n\t\tdone = make(chan bool, 1)\n\t)\n\n\tconn, err := upgrader.Upgrade(w, r, nil)\n\tif err != nil {\n\t\tlog.V(logLevel).Debugf(\"%s:subscribe:> set websocket upgrade err: %s\", logPrefix, err.Error())\n\t\treturn\n\t}\n\n\tticker := time.NewTicker(time.Second)\n\tdefer ticker.Stop()\n\n\tvar serviceEvents = make(chan types.ServiceEvent)\n\tvar namespaceEvents = make(chan types.NamespaceEvent)\n\tvar clusterEvents = make(chan types.ClusterEvent)\n\n\tnotify := w.(http.CloseNotifier).CloseNotify()\n\n\tgo func() {\n\t\t<-notify\n\t\tlog.V(logLevel).Debugf(\"%s:subscribe:> HTTP connection just closed.\", logPrefix)\n\t\tdone <- true\n\t}()\n\n\tgo func() {\n\t\tfor {\n\t\t\tselect {\n\t\t\tcase <-done:\n\t\t\t\tclose(serviceEvents)\n\t\t\t\tclose(namespaceEvents)\n\t\t\t\tclose(clusterEvents)\n\t\t\t\treturn\n\t\t\tcase e := <-clusterEvents:\n\n\t\t\t\tvar data interface{}\n\t\t\t\tif e.Data == nil {\n\t\t\t\t\tdata = nil\n\t\t\t\t} else {\n\t\t\t\t\tdata = v1.View().Cluster().New(e.Data)\n\t\t\t\t}\n\n\t\t\t\tevent := Event{\n\t\t\t\t\tEntity: \"cluster\",\n\t\t\t\t\tAction: e.Action,\n\t\t\t\t\tName: e.Name,\n\t\t\t\t\tData: data,\n\t\t\t\t}\n\n\t\t\t\tif err = conn.WriteJSON(event); err != nil {\n\t\t\t\t\tlog.Errorf(\"%s:subscribe:> write cluster event to socket error.\", logPrefix)\n\t\t\t\t}\n\t\t\tcase e := <-serviceEvents:\n\n\t\t\t\tvar data interface{}\n\t\t\t\tif e.Data == nil {\n\t\t\t\t\tdata = nil\n\t\t\t\t} else {\n\t\t\t\t\tdata = v1.View().Service().New(e.Data)\n\t\t\t\t}\n\n\t\t\t\tevent := Event{\n\t\t\t\t\tEntity: \"service\",\n\t\t\t\t\tAction: e.Action,\n\t\t\t\t\tName: e.Name,\n\t\t\t\t\tData: data,\n\t\t\t\t}\n\n\t\t\t\tif err = conn.WriteJSON(event); err != nil {\n\t\t\t\t\tlog.Errorf(\"%s:subscribe:> write service event to socket error.\", logPrefix)\n\t\t\t\t}\n\t\t\tcase e := <-namespaceEvents:\n\n\t\t\t\tvar data interface{}\n\t\t\t\tif e.Data == nil {\n\t\t\t\t\tdata = nil\n\t\t\t\t} else {\n\t\t\t\t\tdata = v1.View().Namespace().New(e.Data)\n\t\t\t\t}\n\n\t\t\t\tevent := Event{\n\t\t\t\t\tEntity: \"namespace\",\n\t\t\t\t\tAction: e.Action,\n\t\t\t\t\tName: e.Name,\n\t\t\t\t\tData: data,\n\t\t\t\t}\n\n\t\t\t\tif err = conn.WriteJSON(event); err != nil {\n\t\t\t\t\tlog.Errorf(\"%s:subscribe:> write namespace event to socket error.\", logPrefix)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\tgo cm.Watch(clusterEvents)\n\tgo sm.Watch(serviceEvents, nil)\n\tgo nm.Watch(namespaceEvents)\n\n\tgo func() {\n\t\tfor range ticker.C {\n\t\t\tif err := conn.WriteMessage(websocket.TextMessage, []byte{}); err != nil {\n\t\t\t\tlog.Errorf(\"%s:subscribe:> writing to the client websocket err: %s\", logPrefix, err.Error())\n\t\t\t\tdone <- true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}()\n\n\t<-done\n}", "func (s *Subscription) Subscribe(channels ...string) {\n\tif len(channels) < 1 {\n\t\treturn\n\t}\n\n\ts.broker.dataChan <- &envData{false, &envSubscription{true, s, channels}, nil}\n}", "func (b *Broker) Subscribe(s *Subscriber, topics ...string) {\n\tb.tlock.Lock()\n\tdefer b.tlock.Unlock()\n\tfor _, topic := range topics {\n\t\tif nil == b.topics[topic] {\n\t\t\tb.topics[topic] = Subscribers{}\n\t\t}\n\t\ts.topics[topic] = true\n\t\tb.topics[topic][s.id] = s\n\t}\n}", "func (b *UpdateBroadcaster) Subscribe() <-chan validators.Validator {\n\tb.listenersMutex.Lock()\n\tdefer b.listenersMutex.Unlock()\n\n\tsubscribeChan := make(chan validators.Validator)\n\tb.listeners = append(b.listeners, subscribeChan)\n\t// Insert the current validator in the channel if there is one.\n\tif b.current != nil {\n\t\tgo func() {\n\t\t\tsubscribeChan <- b.current\n\t\t}()\n\t}\n\treturn subscribeChan\n}", "func (cb *Cinnabot) Subscribe(msg *message) {\n\tif len(msg.Args) == 0 || !cb.CheckArgCmdPair(\"/subscribe\", msg.Args) {\n\n\t\tvar rowList [][]tgbotapi.KeyboardButton\n\t\tfor i := 0; i < len(cb.allTags); i += 2 {\n\t\t\tif !cb.db.CheckSubscribed(msg.From.ID, cb.allTags[i]) {\n\t\t\t\trowList = append(rowList, tgbotapi.NewKeyboardButtonRow(tgbotapi.NewKeyboardButton(cb.allTags[i])))\n\t\t\t}\n\t\t}\n\t\tif len(rowList) == 0 {\n\t\t\tcb.SendTextMessage(int(msg.Chat.ID), \"🤖: You are subscribed to everything :)\")\n\t\t\treturn\n\t\t}\n\n\t\toptions := tgbotapi.NewReplyKeyboard(rowList...)\n\t\treplyMsg := tgbotapi.NewMessage(msg.Chat.ID, \"🤖: What would you like to subscribe to?\\n\\n\")\n\t\treplyMsg.ReplyMarkup = options\n\t\tcb.SendMessage(replyMsg)\n\n\t\treturn\n\t}\n\n\ttag := msg.Args[0]\n\tlog.Print(\"Tag: \" + tag)\n\n\t//Check if tag exists.\n\tif !cb.db.CheckTagExists(msg.From.ID, tag) {\n\t\tcb.SendTextMessage(int(msg.Chat.ID), \"🤖: Invalid tag\")\n\t\treturn\n\t}\n\n\t//Check if user is already subscribed to\n\tif cb.db.CheckSubscribed(msg.From.ID, tag) {\n\t\tcb.SendTextMessage(int(msg.Chat.ID), \"🤖: You are already subscribed to \"+tag)\n\t\treturn\n\t}\n\n\t//Check if there are other errors\n\tif err := cb.db.UpdateTag(msg.From.ID, tag, \"true\"); err != nil { //Need to try what happens someone updates user_id field.\n\t\tcb.SendTextMessage(int(msg.Chat.ID), \"🤖: Oh no there is an error\")\n\t\tlog.Fatal(err.Error())\n\t\treturn\n\t}\n\tif tag == \"everything\" {\n\t\tfor i := 0; i < len(cb.allTags); i += 2 {\n\t\t\tcb.db.UpdateTag(msg.From.ID, cb.allTags[i], \"true\")\n\t\t}\n\t}\n\n\tcb.SendTextMessage(int(msg.Chat.ID), \"🤖: You are now subscribed to \"+tag)\n\treturn\n}", "func (iw *IPWatcher) Subscribe(clusterIP string, port Port, listener EndpointUpdateListener) error {\n\tiw.log.Infof(\"Establishing watch on service cluster ip [%s:%d]\", clusterIP, port)\n\tss := iw.getOrNewServiceSubscriptions(clusterIP)\n\treturn ss.subscribe(port, listener)\n}", "func (r *Routes) Subscribe(c *gin.Context) {\n\tc.Header(\"Content-Type\", \"text/event-stream\")\n\n\tticker := time.NewTicker(15 * time.Second)\n\tfor {\n\t\tselect {\n\t\tcase <-c.Request.Context().Done():\n\t\t\t// release resources\n\t\t\tbreak\n\t\tcase data := <-GetSubscriptionService().Receive():\n\t\t\tsse.Encode(c.Writer, sse.Event{\n\t\t\t\tEvent: \"message\",\n\t\t\t\tData: data,\n\t\t\t})\n\n\t\t\tc.Writer.Flush()\n\t\tcase <-ticker.C:\n\t\t\tsse.Encode(c.Writer, sse.Event{\n\t\t\t\tEvent: \"heartbeat\",\n\t\t\t\tData: \"Alive\",\n\t\t\t})\n\n\t\t\tc.Writer.Flush()\n\t\t}\n\t}\n}", "func (p *BoxPeer) Subscribe(notifiee *Notifiee) {\n\tp.notifier.Subscribe(notifiee)\n}" ]
[ "0.66930926", "0.6341041", "0.61283416", "0.6050386", "0.5937323", "0.57322043", "0.56926197", "0.5690928", "0.56162053", "0.5593847", "0.55849826", "0.557723", "0.55625504", "0.5504636", "0.55015826", "0.54984856", "0.5491044", "0.54770607", "0.5442515", "0.5441608", "0.5441227", "0.5406734", "0.5405146", "0.5394806", "0.538325", "0.5332843", "0.53189313", "0.5303002", "0.5296305", "0.5295305", "0.52900845", "0.5277199", "0.5261892", "0.52518255", "0.5250367", "0.523497", "0.52288765", "0.5226862", "0.52223337", "0.5204042", "0.519325", "0.51911527", "0.5188666", "0.51860803", "0.5161299", "0.5153154", "0.51524484", "0.5140774", "0.51297325", "0.51290685", "0.51266825", "0.5125809", "0.5124041", "0.5123178", "0.5119159", "0.5102817", "0.50947255", "0.50938207", "0.5089486", "0.50821996", "0.50745726", "0.5067048", "0.5045348", "0.50415343", "0.50415033", "0.503282", "0.5032629", "0.5032183", "0.502916", "0.5024823", "0.5024301", "0.50201476", "0.5010167", "0.50051504", "0.49983478", "0.49934444", "0.4992986", "0.4992255", "0.49904856", "0.49870634", "0.49869645", "0.49839854", "0.49837056", "0.4983456", "0.49715772", "0.4952534", "0.4952434", "0.4949521", "0.49421442", "0.4941877", "0.4941835", "0.4934684", "0.49341416", "0.49309942", "0.49306276", "0.49300617", "0.49246463", "0.4920537", "0.4907916", "0.49049824" ]
0.66747826
1
Update updates views along with given todos.
func (app *Application) Update(todos []todo.Todo) { app.table.Update(todos) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func UpdateTodo(writer http.ResponseWriter, request *http.Request) {\n\tparams := mux.Vars(request)\n\tid, err := strconv.Atoi(params[\"id\"])\n\n\tif err != nil {\n\t\tresponseWithJson(writer, http.StatusBadRequest, map[string]string{\"message\": \"Invalid todo id\"})\n\t\treturn\n\t}\n\n\tvar updateTodo tdo.Todo\n\tif err := json.NewDecoder(request.Body).Decode(&updateTodo); err != nil {\n\t\tresponseWithJson(writer, http.StatusBadRequest, map[string]string{\"message\": \"Invalid body\"})\n\t\treturn\n\t}\n\tupdateTodo.ID = id\n\n\tfor i, todo := range data.Todos {\n\t\tif todo.ID == id {\n\t\t\tdata.Todos[i] = updateTodo\n\t\t\tresponseWithJson(writer, http.StatusOK, updateTodo)\n\t\t\treturn\n\t\t}\n\t}\n\n\tresponseWithJson(writer, http.StatusNotFound, map[string]string{\"message\": \"Todo not found\"})\n}", "func UpdateTodosOK(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.TodosController, id int, body string, isFinished bool) (http.ResponseWriter, *app.Todo) {\n\t// Setup service\n\tvar (\n\t\tlogBuf bytes.Buffer\n\t\tresp interface{}\n\n\t\trespSetter goatest.ResponseSetterFunc = func(r interface{}) { resp = r }\n\t)\n\tif service == nil {\n\t\tservice = goatest.Service(&logBuf, respSetter)\n\t} else {\n\t\tlogger := log.New(&logBuf, \"\", log.Ltime)\n\t\tservice.WithLogger(goa.NewLogger(logger))\n\t\tnewEncoder := func(io.Writer) goa.Encoder { return respSetter }\n\t\tservice.Encoder = goa.NewHTTPEncoder() // Make sure the code ends up using this decoder\n\t\tservice.Encoder.Register(newEncoder, \"*/*\")\n\t}\n\n\t// Setup request context\n\trw := httptest.NewRecorder()\n\tquery := url.Values{}\n\t{\n\t\tsliceVal := []string{body}\n\t\tquery[\"body\"] = sliceVal\n\t}\n\t{\n\t\tsliceVal := []string{fmt.Sprintf(\"%v\", isFinished)}\n\t\tquery[\"is_finished\"] = sliceVal\n\t}\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/todos/%v\", id),\n\t\tRawQuery: query.Encode(),\n\t}\n\treq, err := http.NewRequest(\"PUT\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tprms[\"id\"] = []string{fmt.Sprintf(\"%v\", id)}\n\t{\n\t\tsliceVal := []string{body}\n\t\tprms[\"body\"] = sliceVal\n\t}\n\t{\n\t\tsliceVal := []string{fmt.Sprintf(\"%v\", isFinished)}\n\t\tprms[\"is_finished\"] = sliceVal\n\t}\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"TodosTest\"), rw, req, prms)\n\tupdateCtx, _err := app.NewUpdateTodosContext(goaCtx, req, service)\n\tif _err != nil {\n\t\tpanic(\"invalid test data \" + _err.Error()) // bug\n\t}\n\n\t// Perform action\n\t_err = ctrl.Update(updateCtx)\n\n\t// Validate response\n\tif _err != nil {\n\t\tt.Fatalf(\"controller returned %+v, logs:\\n%s\", _err, logBuf.String())\n\t}\n\tif rw.Code != 200 {\n\t\tt.Errorf(\"invalid response status code: got %+v, expected 200\", rw.Code)\n\t}\n\tvar mt *app.Todo\n\tif resp != nil {\n\t\tvar ok bool\n\t\tmt, ok = resp.(*app.Todo)\n\t\tif !ok {\n\t\t\tt.Fatalf(\"invalid response media: got variable of type %T, value %+v, expected instance of app.Todo\", resp, resp)\n\t\t}\n\t\t_err = mt.Validate()\n\t\tif _err != nil {\n\t\t\tt.Errorf(\"invalid response media type: %s\", _err)\n\t\t}\n\t}\n\n\t// Return results\n\treturn rw, mt\n}", "func UpdateTodosNotFound(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.TodosController, id int, body string, isFinished bool) http.ResponseWriter {\n\t// Setup service\n\tvar (\n\t\tlogBuf bytes.Buffer\n\t\tresp interface{}\n\n\t\trespSetter goatest.ResponseSetterFunc = func(r interface{}) { resp = r }\n\t)\n\tif service == nil {\n\t\tservice = goatest.Service(&logBuf, respSetter)\n\t} else {\n\t\tlogger := log.New(&logBuf, \"\", log.Ltime)\n\t\tservice.WithLogger(goa.NewLogger(logger))\n\t\tnewEncoder := func(io.Writer) goa.Encoder { return respSetter }\n\t\tservice.Encoder = goa.NewHTTPEncoder() // Make sure the code ends up using this decoder\n\t\tservice.Encoder.Register(newEncoder, \"*/*\")\n\t}\n\n\t// Setup request context\n\trw := httptest.NewRecorder()\n\tquery := url.Values{}\n\t{\n\t\tsliceVal := []string{body}\n\t\tquery[\"body\"] = sliceVal\n\t}\n\t{\n\t\tsliceVal := []string{fmt.Sprintf(\"%v\", isFinished)}\n\t\tquery[\"is_finished\"] = sliceVal\n\t}\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/todos/%v\", id),\n\t\tRawQuery: query.Encode(),\n\t}\n\treq, err := http.NewRequest(\"PUT\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tprms[\"id\"] = []string{fmt.Sprintf(\"%v\", id)}\n\t{\n\t\tsliceVal := []string{body}\n\t\tprms[\"body\"] = sliceVal\n\t}\n\t{\n\t\tsliceVal := []string{fmt.Sprintf(\"%v\", isFinished)}\n\t\tprms[\"is_finished\"] = sliceVal\n\t}\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"TodosTest\"), rw, req, prms)\n\tupdateCtx, _err := app.NewUpdateTodosContext(goaCtx, req, service)\n\tif _err != nil {\n\t\tpanic(\"invalid test data \" + _err.Error()) // bug\n\t}\n\n\t// Perform action\n\t_err = ctrl.Update(updateCtx)\n\n\t// Validate response\n\tif _err != nil {\n\t\tt.Fatalf(\"controller returned %+v, logs:\\n%s\", _err, logBuf.String())\n\t}\n\tif rw.Code != 404 {\n\t\tt.Errorf(\"invalid response status code: got %+v, expected 404\", rw.Code)\n\t}\n\n\t// Return results\n\treturn rw\n}", "func UpdateTodoHandler(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {\n\tvars := mux.Vars(r)\n\tlog.Print(\"update\")\n\n\ttasks := strings.Split(vars[\"todo\"], \",\")\n\n\tw.WriteHeader(http.StatusOK)\n\n\tusername := context.Get(r, \"username\")\n\n\tlog.Print(username)\n\tlog.Print(tasks)\n\n\tstatus, err := models.SaveTodos(username.(string), tasks)\n\tjsonErr, _ := json.Marshal(err)\n\tjsonStatus, _ := json.Marshal(status)\n\tif err != nil {\n\t\tw.Write(jsonErr)\n\t}\n\tw.Write(jsonStatus)\n}", "func UpdateTodo(w http.ResponseWriter, r *http.Request) {\n\tparams := mux.Vars(r)\n\tid, _ := strconv.Atoi(params[\"id\"])\n\tvar todo model.Todo\n\t_ = json.NewDecoder(r.Body).Decode(&todo)\n\ttodo = model.UpdateTodo(id, todo)\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(todo)\n}", "func updateViews(db *sql.DB) {\n\ttxn, err := db.Begin()\n\tif err != nil {\n\t\tlog.Printf(\"ERROR: failed to start pq txn for materialized view updates => %s\", err.Error())\n\t\treturn\n\t}\n\n\tfor _, view := range materializedViews {\n\t\tif _, err = txn.Exec(fmt.Sprintf(\"REFRESH MATERIALIZED VIEW %s\", view)); err != nil {\n\t\t\tlog.Printf(\"ERROR: Failed to update materialized view, %s => %s\", view, err.Error())\n\t\t}\n\t}\n\n\terr = txn.Commit()\n\tif err != nil {\n\t\tlog.Printf(\"ERROR: Failed to commit transaction => {%s}\", err)\n\t}\n}", "func UpdateTodosBadRequest(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.TodosController, id int, body string, isFinished bool) (http.ResponseWriter, error) {\n\t// Setup service\n\tvar (\n\t\tlogBuf bytes.Buffer\n\t\tresp interface{}\n\n\t\trespSetter goatest.ResponseSetterFunc = func(r interface{}) { resp = r }\n\t)\n\tif service == nil {\n\t\tservice = goatest.Service(&logBuf, respSetter)\n\t} else {\n\t\tlogger := log.New(&logBuf, \"\", log.Ltime)\n\t\tservice.WithLogger(goa.NewLogger(logger))\n\t\tnewEncoder := func(io.Writer) goa.Encoder { return respSetter }\n\t\tservice.Encoder = goa.NewHTTPEncoder() // Make sure the code ends up using this decoder\n\t\tservice.Encoder.Register(newEncoder, \"*/*\")\n\t}\n\n\t// Setup request context\n\trw := httptest.NewRecorder()\n\tquery := url.Values{}\n\t{\n\t\tsliceVal := []string{body}\n\t\tquery[\"body\"] = sliceVal\n\t}\n\t{\n\t\tsliceVal := []string{fmt.Sprintf(\"%v\", isFinished)}\n\t\tquery[\"is_finished\"] = sliceVal\n\t}\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/todos/%v\", id),\n\t\tRawQuery: query.Encode(),\n\t}\n\treq, err := http.NewRequest(\"PUT\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tprms[\"id\"] = []string{fmt.Sprintf(\"%v\", id)}\n\t{\n\t\tsliceVal := []string{body}\n\t\tprms[\"body\"] = sliceVal\n\t}\n\t{\n\t\tsliceVal := []string{fmt.Sprintf(\"%v\", isFinished)}\n\t\tprms[\"is_finished\"] = sliceVal\n\t}\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"TodosTest\"), rw, req, prms)\n\tupdateCtx, _err := app.NewUpdateTodosContext(goaCtx, req, service)\n\tif _err != nil {\n\t\tpanic(\"invalid test data \" + _err.Error()) // bug\n\t}\n\n\t// Perform action\n\t_err = ctrl.Update(updateCtx)\n\n\t// Validate response\n\tif _err != nil {\n\t\tt.Fatalf(\"controller returned %+v, logs:\\n%s\", _err, logBuf.String())\n\t}\n\tif rw.Code != 400 {\n\t\tt.Errorf(\"invalid response status code: got %+v, expected 400\", rw.Code)\n\t}\n\tvar mt error\n\tif resp != nil {\n\t\tvar ok bool\n\t\tmt, ok = resp.(error)\n\t\tif !ok {\n\t\t\tt.Fatalf(\"invalid response media: got variable of type %T, value %+v, expected instance of error\", resp, resp)\n\t\t}\n\t}\n\n\t// Return results\n\treturn rw, mt\n}", "func UpdateTodo(c *gin.Context) {\n\tfmt.Printf(\"Update Todo\")\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"status\": \"putted\",\n\t\t\"message\": \"can update todo\",\n\t\t\"nick\": \"nick\",\n\t})\n}", "func (e Endpoints) Update(ctx context.Context, todo io.Todo) (t io.Todo, error error) {\n\trequest := UpdateRequest{Todo: todo}\n\tresponse, err := e.UpdateEndpoint(ctx, request)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn response.(UpdateResponse).T, response.(UpdateResponse).Error\n}", "func UpdateTodo(c *fiber.Ctx) error {\n\n\tdb := database.GetConnection()\n\n\tvar updateTodo models.Todo\n\tif err := c.BodyParser(&updateTodo); err != nil {\n\t\treturn c.Status(503).JSON(fiber.Map{\n\t\t\t\"success\": false,\n\t\t\t\"message\": \"No se puede procesar\",\n\t\t})\n\t}\n\n\tvar todo models.Todo\n\tid := c.Params(\"id\")\n\n\tif err := db.First(&todo, id).Error; err != nil {\n\t\treturn c.Status(404).JSON(fiber.Map{\n\t\t\t\"success\": false,\n\t\t\t\"message\": \"Not found id\",\n\t\t})\n\t}\n\n\tdb.Model(&todo).Updates(models.Todo{Description: updateTodo.Description})\n\treturn c.JSON(todo)\n\n}", "func Update(c *gin.Context) {\n\tvar todo todo\n\tid := c.Param(\"Id\")\n\n\tdb := Database()\n\tdb.First(&todo, id)\n\n\tif todo.ID == 0 {\n\t\tc.JSON(http.StatusNotFound, gin.H{\n\t\t\t\"status\": http.StatusNotFound,\n\t\t\t\"message\": \"Todo Not Found\",\n\t\t})\n\t}\n\n\tif strings.TrimSpace(c.PostForm(\"title\")) != \"\" {\n\t\tdb.Model(&todo).Update(\"title\", c.PostForm(\"title\"))\n\t}\n\n\tif c.GetBool(\"done\") {\n\t\tdb.Model(&todo).Update(\"done\", c.GetBool(\"done\"))\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"status\": http.StatusOK,\n\t\t\"message\": \"Todo Updated\",\n\t})\n}", "func Update(w http.ResponseWriter, r *http.Request, params httprouter.Params) {\n\tdbUser := \"postgres\"\n\tdbHost := \"localhost\"\n\tdbPassword := \"b4n4n4s\"\n\tdbName := \"postgres\"\n\n\tdbinfo := fmt.Sprintf(\"host=%s user=%s password=%s dbname=%s sslmode=disable\", dbHost, dbUser, dbPassword, dbName)\n\tdb, err := sql.Open(\"postgres\", dbinfo)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t}\n//////////////DB BOILER ABOVE, might refactor into a dbservice, decouple processing from DBAdmin etc\n//////////////Input validation boiler below,\n\n\tvar todo CreateTodo // right model, could address naming for better clarity.\n\tjson.NewDecoder(r.Body).Decode(&todo)\n\n\tif todo.Status == \"\" || todo.Title == \"\" {\n\t\thttp.Error(w, \"Todo request is missing status and/or title\", http.StatusBadRequest)\n\t} else {\n\n\t\tinvalidStatus := true\n\t\tfor _, status := range allowedStatuses {\n\t\t\tif todo.Status == status {\n\t\t\t\tinvalidStatus = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t//double negatives are tricky :-)\n\t\tif invalidStatus {\n\t\t\thttp.Error(w, \"The provided status is not supported\", http.StatusBadRequest)\n\t\t} else {\n\t\t\tvar resultingTodo Todo\n\t\t\tupdateStmt := fmt.Sprintf(`UPDATE todo SET title = '%s', status = '%s' WHERE id = %s RETURNING id, title, status;`, todo.Title, todo.Status, params.ByName(\"todoID\"))\n\n\t\t\t// Update todo and return the new DB entry\n\t\t\tif err := db.QueryRow(updateStmt).Scan(&resultingTodo.ID, &resultingTodo.Title, &resultingTodo.Status); err != nil {\n\t\t\t\tfmt.Printf(\"Failed to save to db: %s\", err.Error())\n\t\t\t\thttp.Error(w, \"failed in Update handler, likely found no todo to update? check log.\", 500)\n\t\t\t} else {\n\t\t\t\tfmt.Printf(\"Todo Updated -- id: %s\\n\", params.ByName(\"todoID\"))\n\n\t\t\t\tjsonResp, _ := json.Marshal(resultingTodo)\n\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\t\tw.WriteHeader(200)\n\t\t\t\tfmt.Fprintf(w, string(jsonResp))\n\t\t\t}\n\t\t}\n\t}\n}", "func UpdateTodo(w http.ResponseWriter, r *http.Request, params httprouter.Params) {\n\tdefer r.Body.Close()\n\tclaims := r.Context().Value(shared.KeyClaims).(jwt.MapClaims)\n\tID := params.ByName(\"id\")\n\tif ID == \"\" || !bson.IsObjectIdHex(ID) {\n\t\tshared.SendError(w, models.Response{Status: http.StatusBadRequest, Message: \"invalid todo id\"})\n\t\treturn\n\t}\n\tvar todo models.Todo\n\tif err := json.NewDecoder(r.Body).Decode(&todo); err != nil {\n\t\tshared.SendError(w, models.Response{Status: http.StatusBadRequest, Message: err.Error()})\n\t\treturn\n\t}\n\ttodo.ID = bson.ObjectIdHex(ID)\n\ttodo.CreatedBy = claims[\"id\"].(string)\n\tdbTodo, err := controllers.UpdateTodo(todo)\n\tif err != nil {\n\t\tshared.SendError(w, models.Response{Status: http.StatusInternalServerError, Message: err.Error()})\n\t\treturn\n\t}\n\tshared.SendJSON(w, http.StatusOK, dbTodo)\n}", "func (h *todoHTTPHandler) UpdateTodo(c echo.Context) error {\n id, _ := strconv.Atoi(c.Param(\"id\"))\n todo, err := sanitizer.Todo(c)\n\tif err != nil && err != state.ErrDataNotFound {\n response := helper.TodoResponse()\n\t\tresponse.ErrorMessage = err.Error()\n\t\tresponse.Code = http.StatusInternalServerError\n\t\treturn c.JSON(http.StatusInternalServerError, response)\n }\n response, err := h.TodoUseCase.UpdateTodo(todo, id)\n\tif err != nil && err != state.ErrDataNotFound {\n\t\tresponse.ErrorMessage = err.Error()\n\t\tresponse.Code = http.StatusInternalServerError\n\t\treturn c.JSON(http.StatusInternalServerError, response)\n }\n\tresponse.Code = http.StatusOK\n return c.JSON(http.StatusOK, response)\n}", "func TasksUpdate(c buffalo.Context) error {\n\ttask := &models.Task{}\n\n\ttx := c.Value(\"tx\").(*pop.Connection)\n\terr := tx.Eager().Find(task, c.Param(\"task_id\"))\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tc.Flash().Add(\"warning\", \"Cannot find that task.\")\n\t\treturn c.Redirect(307, \"/\")\n\t}\n\n\t// Bind entity to the HTML form.\n\tif err := c.Bind(task); err != nil {\n\t\treturn err\n\t}\n\n\ttask.UpdatedAt = time.Now()\n\n\t// Validate the data from the html form.\n\tverrs, err := tx.ValidateAndUpdate(task)\n\tif err != nil {\n\t\treturn errors.WithStack(err)\n\t}\n\n\tif verrs.HasAny() {\n\t\tc.Set(\"task\", task)\n\t\t// Make the errors available inside the html template\n\t\tc.Set(\"errors\", verrs)\n\t\treturn c.Render(422, r.HTML(\"tasks/edit.html\"))\n\t}\n\n\tc.Flash().Add(\"success\", \"Task updated.\")\n\treturn c.Redirect(303, \"/users/%s/contracts/%d\", task.Contract.UserID, task.Contract.ID)\n}", "func (a *App) updateViews() {\n\t// if a.state.Settings[\"TLDSubstitutions\"] {\n\t// \ta.writeView(viewSettings, \"[X] TLD substitutions\")\n\t// } else {\n\t// \ta.writeView(viewSettings, \"[ ] TLD substitutions\")\n\t// }\n}", "func UpdateTodo(c echo.Context) error {\n\tdb := connection.Conn()\n\tdefer db.Close()\n\tt := models.Todo{}\n\tid := c.Param(\"id\")\n\tdb.First(&t, id)\n\n\tif t.ID <= 0 {\n\t\tmsg := \"user with id \" + id + \" does not exist\"\n\t\treturn echo.NewHTTPError(http.StatusNotFound, msg)\n\t}\n\n\terr := c.Bind(&t)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdb.Save(&t)\n\treturn c.JSON(http.StatusOK, &t)\n}", "func update(ctx context.Context, tx *sqlx.Tx, todo *Todo) error {\n\t_, err := tx.NamedExecContext(ctx, updateTodo, todo)\n\treturn err\n}", "func (root Root) UpdateTodoMutation(\n\tctx context.Context,\n\tinput schema.UpdateTodoInputStruct,\n) (schema.UpdateTodoPayloadInterface, error) {\n\tauth := Auth(ctx)\n\tif auth.Check() == false {\n\t\treturn nil, errors.New(\"Not loged in\")\n\t}\n\n\tviewer := auth.Viewer()\n\n\tdb := Session(ctx).DB\n\tid := relay.FromGlobalID(*input.TodoID)\n\tif id == nil {\n\t\treturn nil, nil\n\t}\n\n\trows, err := db.Select(\"1\").\n\t\tFrom(todosTable).\n\t\tWhere(\"user_id = ?\", viewer.ID).\n\t\tWhere(\"id = ?\", id.ID).Load(&null{})\n\n\tif rows == 0 {\n\t\treturn nil, errors.New(\"Could not find todo\")\n\t}\n\n\tupdate := db.Update(todosTable)\n\tif input.Title != nil {\n\t\tupdate.Set(\"title\", *input.Title)\n\t}\n\tif input.Description != nil {\n\t\tupdate.Set(\"description\", *input.Description)\n\t}\n\tif input.Status != nil {\n\t\tupdate.Set(\"status\", *input.Status)\n\t}\n\n\t_, err = update.Where(\"id = ?\", id.ID).Exec()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn nil, errors.New(\"Could not update todo\")\n\t}\n\n\tvar todo Todo\n\tdb.Select(\"*\").From(todosTable).\n\t\tWhere(\"id = ?\", id.ID).Load(&todo)\n\n\treturn UpdateTodoPayload{Todo: todo}, nil\n}", "func updateTask(w http.ResponseWriter, r *http.Request){\n\t//definimos variable de vars que devuelve las variables de ruta\n\tvars := mux.Vars(r)\n\t//convertimos la variable del id a ints\n\ttaskID, err := strconv.Atoi(vars[\"id\"])\n\n\t//Creamos una variable donde almacenaremos la nueva tarea \n\tvar updatedTask task\n\n\n\tif err != nil {\n\t\tfmt.Fprintf(w, \"Invalid ID\")\n\t}\n\n\t//Creamos una funcion que lee todo el body del request\n\treqBody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tfmt.Fprintf(w,\"Please enter Valid Data\")\n\t}\n\n\t//Desarma el Json y lo hace una struct\n\tjson.Unmarshal(reqBody, &updatedTask)\n\n\t\n\t//Se busca entre todas las tasks una task con el ID solicitado\n\tfor i, task := range tasks {\n\t\tif task.ID == taskID {\n\t\t\t//Se elimina la task a la lista, guardando todas las que estan hasta su indice, y la que le sigue en adelante.\n\t\t\ttasks = append(tasks[:i], tasks[i + 1:]...)\n\n\t\t\t//El id se mantiene\n\t\t\tupdatedTask.ID = taskID\n\t\t\t//Se agrega nueva task\n\t\t\ttasks = append(tasks, updatedTask)\n\n\t\t\t//Aviso de que la task se cambio con exito\n\t\t\tfmt.Fprintf(w, \"The task with ID %v has been succesfully updated\", taskID)\n\t\t}\n\t}\n}", "func (url *URL)UpdateViews(views uint)error{\n\turl.Views = views\n\terr := GetDB().Save(&url).Error\n\treturn err\n}", "func (h *todoHTTPHandler) UpdateStatusTodo(c echo.Context) error {\n id, _ := strconv.Atoi(c.Param(\"id\"))\n todo, err := sanitizer.Todo(c)\n\tif err != nil && err != state.ErrDataNotFound {\n response := helper.TodoResponse()\n\t\tresponse.ErrorMessage = err.Error()\n\t\tresponse.Code = http.StatusInternalServerError\n\t\treturn c.JSON(http.StatusInternalServerError, response)\n }\n response, err := h.TodoUseCase.UpdateTodo(todo, id)\n\tif err != nil && err != state.ErrDataNotFound {\n\t\tresponse.ErrorMessage = err.Error()\n\t\tresponse.Code = http.StatusInternalServerError\n\t\treturn c.JSON(http.StatusInternalServerError, response)\n }\n\tresponse.Code = http.StatusOK\n return c.JSON(http.StatusOK, response)\n}", "func (res ItemsResource) Update(w http.ResponseWriter, r *http.Request) {\n\tw.Write([]byte(\"Todo item update by id\"))\n}", "func (h Handler) Update(w http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\tdata := postData{}\n\terr := json.NewDecoder(r.Body).Decode(&data)\n\tif err != nil {\n\t\th.log.Println(err)\n\t\tres := response.Resp{\n\t\t\tStatus: \"error\",\n\t\t\tData: \"There was an problem, please try again\",\n\t\t}\n\t\tresponse.Writer(w, res)\n\t\treturn\n\t}\n\tif data.Name == \"\" || data.Desc == \"\" {\n\t\tres := response.Resp{\n\t\t\tStatus: \"error\",\n\t\t\tData: \"Empty post values\",\n\t\t}\n\t\tresponse.Writer(w, res)\n\t\treturn\n\t}\n\tid, err := strconv.ParseUint(p.ByName(\"id\"), 10, 64)\n\tif err != nil {\n\t\th.log.Println(err)\n\t\tres := response.Resp{\n\t\t\tStatus: \"error\",\n\t\t\tData: \"There was an problem, please try again\",\n\t\t}\n\t\tresponse.Writer(w, res)\n\t\treturn\n\t}\n\ttodo, err := h.m.Update(id, model.Todo{Name: data.Name, Description: data.Desc})\n\tif err != nil {\n\t\th.log.Println(err)\n\t\tres := response.Resp{\n\t\t\tStatus: \"error\",\n\t\t\tData: \"There was an problem, please try again\",\n\t\t}\n\t\tresponse.Writer(w, res)\n\t\treturn\n\t}\n\tres := response.Resp{\n\t\tStatus: \"succes\",\n\t\tData: todo,\n\t}\n\tresponse.Writer(w, res)\n}", "func UpdateTodo(idx string, t *Todo) (*Todo, error) {\n\tvar err error\n\tclient := mongo.ClientManager()\n\n\t// create ObjectID from string\n\tid, err := primitive.ObjectIDFromHex(idx)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n\tdefer cancel()\n\n\t// set filters and updates\n\tfilter := bson.M{\"_id\": id}\n\tupdate := bson.M{\"$set\": t}\n\n\tfmt.Println(\"new update todo:\", t)\n\n\tres, err := client.Database(\"document\").Collection(\"todo\").UpdateOne(ctx, filter, update)\n\tfmt.Println(\"Updated a Todo: \", res)\n\treturn t, err\n}", "func (a *TodoAdapter) Update(ctx context.Context, t todo.Todo) error {\n\tspan, _ := opentracing.StartSpanFromContext(ctx, \"TodoAdapter-Update\")\n\tdefer span.Finish()\n\n\toid, err := primitive.ObjectIDFromHex(string(t.ID))\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//Filter\n\tfilter := bson.M{\"_id\": bson.M{\"$eq\": oid}}\n\n\t//Update fields\n\tdocument := bson.M{\"$set\": bson.M{\n\t\t\"title\": t.Title,\n\t\t\"description\": t.Description,\n\t\t\"priority_level\": t.Priority,\n\t\t\"completed\": t.Completed,\n\t\t\"updated_at\": t.UpdatedAt,\n\t}}\n\n\t//Update Item\n\tresult, err := a.collection.UpdateOne(ctx, filter, document)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif result.MatchedCount > 0 {\n\t\treturn nil\n\t}\n\n\treturn ErrNoItemsUpdated\n}", "func (view *DetailsView) Update() error {\n\treturn nil\n}", "func (controller *todoController) UpdateATodo(c *gin.Context) {\n\tvar responses Responses.ResponseApi\n\n\tvar todo Models.Todo\n\te := c.BindJSON(&todo)\n\tif e != nil {\n\t\tfmt.Println(e)\n\t}\n\n\tid := c.Params.ByName(\"id\")\n\tresult, err := controller.service.UpdateATodo(todo, id)\n\tif err != nil {\n\t\tresponses = Formatters.Format(err, Constants.ERROR_RC500, Constants.ERROR_RM500)\n\t\tc.JSON(http.StatusOK, responses)\n\t\treturn\n\t}\n\n\tresponses = Formatters.Format(result, Constants.SUCCESS_RC200, Constants.SUCCESS_RM200)\n\tc.JSON(http.StatusOK, responses)\n}", "func (s *ToDoServer) Update(ctx context.Context, req *v1.UpdateRequest) (*v1.UpdateResponse, error) {\n\tif err := s.checkAPI(req.Api); err != nil {\n\t\treturn nil, err\n\t}\n\n\tc, err := s.connect(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer c.Close()\n\n\treminder, err := ptypes.Timestamp(req.ToDo.Reminder)\n\n\tif err != nil {\n\t\treturn nil, status.Error(codes.InvalidArgument, \"reminder field is invalid\")\n\t}\n\n\tres, err := c.ExecContext(ctx, \"UPDATE ToDo SET `Title`=?, `Description`=?, `Reminder`=? WHERE `ID`=?\",\n\t\treq.ToDo.Title, req.ToDo.Description, reminder, req.ToDo.Id)\n\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Unknown, \"failed to update ToDo->\"+err.Error())\n\t}\n\n\trows, err := res.RowsAffected()\n\tif err != nil {\n\t\treturn nil, status.Error(codes.Unknown, \"fail to retrieve updated rows\")\n\t}\n\n\tif rows == 0 {\n\t\treturn nil, status.Error(codes.NotFound, \"Todo not found\")\n\t}\n\n\treturn &v1.UpdateResponse{\n\t\tApi: apiVersion,\n\t\tUpdated: rows,\n\t}, nil\n}", "func (store TodoStore) Update(_ sqlx.Ext, update gtimer.Todo) (gtimer.Todo, error) {\n\ttodo, err := store.Get(update.ID)\n\tif err != nil {\n\t\treturn gtimer.Todo{}, err\n\t}\n\tif update.Status != \"completed\" && update.Status != \"active\" {\n\t\treturn gtimer.Todo{}, fmt.Errorf(\"invalid status: %s\", update.Status)\n\t}\n\ttodo.Title = update.Title\n\ttodo.Status = update.Status\n\ttodo.Updated = time.Now()\n\tstore[todo.ID] = todo\n\treturn todo, nil\n}", "func update(vs *ViewServer, primary string, backup string){\n\tvs.currentView.Viewnum += 1\n\tvs.currentView.Primary = primary\n\tvs.currentView.Backup = backup\n\tvs.idleServer = \"\"\n\tvs.primaryACK = false\n\tvs.backupACK = false\n}", "func IndexView(ctx *fiber.Ctx) error {\n\t// load records\n\tquery := bson.D{{}}\n\tcursor, queryError := Instance.Database.Collection(\"Todos\").Find(ctx.Context(), query)\n\tif queryError != nil {\n\t\treturn utilities.Response(utilities.ResponseParams{\n\t\t\tCtx: ctx,\n\t\t\tInfo: configuration.ResponseMessages.InternalServerError,\n\t\t\tStatus: fiber.StatusInternalServerError,\n\t\t})\n\t}\n\n\tvar todos []Todo = make([]Todo, 0)\n\n\t// iterate the cursor and decode each item into a Todo\n\tif err := cursor.All(ctx.Context(), &todos); err != nil {\n\t\treturn utilities.Response(utilities.ResponseParams{\n\t\t\tCtx: ctx,\n\t\t\tInfo: configuration.ResponseMessages.InternalServerError,\n\t\t\tStatus: fiber.StatusInternalServerError,\n\t\t})\n\t}\n\n\t// caclulate the latency\n\tinitial := ctx.Context().Time()\n\tlatency := utilities.MakeTimestamp() - (initial.UnixNano() / 1e6)\n\n\t// send response: render the page\n\treturn ctx.Render(\n\t\t\"index\",\n\t\tfiber.Map{\n\t\t\t\"Latency\": latency,\n\t\t\t\"Todos\": todos,\n\t\t},\n\t\t\"layouts/main\",\n\t)\n}", "func TiposPagoUpdate(w http.ResponseWriter, r *http.Request) {\n\tdb := database.DbConn()\n\ttip := model.TtipoPago{}\n\tif r.Method == \"POST\" {\n\t\ti, _ := strconv.Atoi(r.FormValue(\"Id\"))\n\t\ttip.Id = int64(i)\n\t\ttip.Nombre = r.FormValue(\"Nombre\")\n\n\t\tinsForm, err := db.Prepare(\"UPDATE tiposPago SET nombre=? WHERE id=?\")\n\t\tif err != nil {\n\t\t\tutil.ErrorApi(err.Error(), w, \"Error actualizando Base de Datos\")\n\t\t}\n\n\t\tinsForm.Exec(tip.Nombre, tip.Id)\n\t\tlog.Printf(\"UPDATE: id: %d | nombre: %s\\n\", tip.Id, tip.Nombre)\n\t}\n\tdefer db.Close()\n\tvar vrecord model.TipoPagoRecord\n\tvrecord.Result = \"OK\"\n\tvrecord.Record = tip\n\ta, _ := json.Marshal(vrecord)\n\tw.Write(a)\n\n\thttp.Redirect(w, r, \"/\", 301)\n}", "func UpdateNoteView(noteID string) error {\n\t// construct update parameters\n\tupdateParams := &dynamodb.UpdateItemInput{\n\t\tExpressionAttributeValues: map[string]*dynamodb.AttributeValue{\n\t\t\t\":v\": {\n\t\t\t\tN: aws.String(\"1\"),\n\t\t\t},\n\t\t},\n\t\t// Views is a reserved keyword, so it has it be substituted\n\t\tExpressionAttributeNames: map[string]*string{\n\t\t\t\"#views\": aws.String(\"Views\"),\n\t\t},\n\t\tKey: map[string]*dynamodb.AttributeValue{\n\t\t\t\"NoteID\": {\n\t\t\t\tS: aws.String(noteID),\n\t\t\t},\n\t\t},\n\t\tReturnValues: aws.String(\"UPDATED_NEW\"),\n\t\tTableName: aws.String(DDBTable),\n\t\tUpdateExpression: aws.String(\"ADD #views :v\"),\n\t}\n\n\t// update the database\n\t_, err := ddb.UpdateItem(updateParams)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (t *Todo) Update(id int, todo string) bool {\n\tt.todos[id] = todo\n\n\treturn true\n}", "func (t *Task) EditToDo(todo EditToDo, reply *ToDo) error {\n\tvar edited ToDo\n\t// 'i' is the index in the array and 'v' the value\n\tfor i, v := range todoSlice {\n\t\tif v.Title == todo.Title {\n\t\t\ttodoSlice[i] = ToDo{todo.NewTitle, todo.NewStatus}\n\t\t\tedited = ToDo{todo.NewTitle, todo.NewStatus}\n\t\t}\n\t}\n\t// edited will be the edited ToDo or a zeroed ToDo\n\t*reply = edited\n\treturn nil\n}", "func (o *Orchestrator) UpdateTasks(tasks []Task) {\n\to.mu.Lock()\n\tdefer o.mu.Unlock()\n\n\to.expectedTasks = tasks\n}", "func (v *App) toggleBtnClicked(event dom.Event) {\n\tisChecked := event.Target().(*dom.HTMLInputElement).Checked\n\tfor _, todo := range v.Children {\n\t\ttodo.setComplete(isChecked)\n\t}\n\n\tif v.CurrentFilter == FilterActive {\n\t\tswitch isChecked {\n\t\tcase true:\n\t\t\t// If we are only showing active todos and we just completed all of them,\n\t\t\t// hide all the views\n\t\t\tfor _, todoView := range v.Children {\n\t\t\t\tif err := view.Hide(todoView); err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\t\t\t}\n\t\tcase false:\n\t\t\t// If we are only showing active todos and we just uncompleted all of them,\n\t\t\t// show all the views\n\t\t\tfor _, todoView := range v.Children {\n\t\t\t\tif err := view.Show(todoView); err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if v.CurrentFilter == FilterCompleted {\n\t\tswitch isChecked {\n\t\tcase true:\n\t\t\t// If we are only showing completed todos and we just completed all of them,\n\t\t\t// show all the views\n\t\t\tfor _, todoView := range v.Children {\n\t\t\t\tif err := view.Show(todoView); err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\t\t\t}\n\t\tcase false:\n\t\t\t// If we are only showing completed todos and we just uncompleted all of them,\n\t\t\t// hide all the views\n\t\t\tfor _, todoView := range v.Children {\n\t\t\t\tif err := view.Hide(todoView); err != nil {\n\t\t\t\t\tpanic(err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Update the footer text\n\tif err := view.Update(v.Footer); err != nil {\n\t\tpanic(err)\n\t}\n}", "func TestUpdateTodoByID(t *testing.T) {\n\t_client := setupDatabase(t)\n\t_handler := setupTodoHandler(_client)\n\tdefer _client.Close()\n\n\tapp := fiber.New()\n\n\tapp.Put(\"/todos/:id\", _handler.UpdateTodoByID)\n\n\tbody := []byte(`{\"content\":\"Updated content\"}`)\n\tr := httptest.NewRequest(\"PUT\", \"/todos/\"+sampleID.String(), bytes.NewReader(body))\n\tr.Header.Set(\"Content-Type\", \"application/json\")\n\n\tresp, err := app.Test(r)\n\tif err != nil {\n\t\tassert.Fail(t, err.Error())\n\t}\n\n\tassert.Equal(t, fiber.StatusOK, resp.StatusCode)\n\n\tvar data entity.Todo\n\tif err := json.NewDecoder(resp.Body).Decode(&data); err != nil {\n\t\tassert.Fail(t, err.Error())\n\t}\n\tassert.Equal(t, \"Updated content\", data.Content)\n\n\tfmt.Println(\"Updated content:\", data.Content)\n\tfmt.Println(\"Status Code:\", resp.StatusCode)\n}", "func update(w http.ResponseWriter, r *http.Request) {\r\n\tif r.Method != \"PUT\" {\r\n\t\thttp.Error(w, \"404 not found.\", http.StatusNotFound)\r\n\t\treturn\r\n\t}\r\n\tid, _ := strconv.ParseInt(r.URL.Query().Get(\"id\"), 10, 64)\r\n\tcontents := &content{\r\n\t\tID: id,\r\n\t\tvalue: r.PostFormValue(\"value\"),\r\n\t\tcompleted: r.PostFormValue(\"completed\"),\r\n\t}\r\n\t//fmt.Println(user)\r\n\tquery := \"UPDATE public.item SET completed=$3,value=$2 WHERE id = $1;\"\r\n\t_, err = db.Exec(query, contents.ID, contents.value,contents.completed)\r\n\tif err != nil {\r\n\t\tpanic(err)\r\n\t}\r\n\tjson.NewEncoder(w).Encode(contents)\r\n}", "func EditTodo(todo *Todo, todoList *TodoList, filter *Filter) error {\n\tif filter.HasDue {\n\t\ttodo.Due = filter.Due\n\t}\n\n\tif filter.HasCompleted {\n\t\tif filter.Completed {\n\t\t\ttodoList.Complete(todo.ID)\n\t\t} else {\n\t\t\ttodo.Uncomplete()\n\t\t}\n\t}\n\n\tif filter.HasArchived {\n\t\ttodo.Archived = filter.Archived\n\t}\n\n\tif filter.HasIsPriority {\n\t\ttodo.IsPriority = filter.IsPriority\n\t}\n\n\tif filter.HasStatus {\n\t\ttodo.Status = filter.LastStatus()\n\t}\n\n\tif filter.Subject != \"\" {\n\t\ttodo.Subject = filter.Subject\n\t}\n\n\tif len(filter.Projects) > 0 {\n\t\ttodo.Projects = filter.Projects\n\t}\n\n\tif len(filter.Contexts) > 0 {\n\t\ttodo.Contexts = filter.Contexts\n\t}\n\n\tif filter.HasRecur {\n\t\ttodo.Recur = filter.Recur\n\t\ttodo.RecurUntil = filter.RecurUntil\n\t}\n\n\treturn nil\n}", "func updateTasks(c context.Context) {\n\tnow := clock.Now(c)\n\tq := datastore.NewQuery(\"TaskCount\").Order(\"computed\")\n\tif err := datastore.Run(c, q, func(tc *TaskCount) {\n\t\tif now.Sub(tc.Computed) > 5*time.Minute {\n\t\t\tlogging.Debugf(c, \"deleting outdated count %q\", tc.Queue)\n\t\t\tif err := datastore.Delete(c, tc); err != nil {\n\t\t\t\tlogging.Errorf(c, \"%s\", err)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\ttasksExecuting.Set(c, int64(tc.Executing), tc.Queue)\n\t\ttasksPending.Set(c, int64(tc.Total-tc.Executing), tc.Queue)\n\t\ttasksTotal.Set(c, int64(tc.Total), tc.Queue)\n\t}); err != nil {\n\t\terrors.Log(c, errors.Annotate(err, \"failed to fetch counts\").Err())\n\t}\n}", "func TodoIndex(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json;charset=UTF-8\")\n\tw.WriteHeader(http.StatusOK)\n\tif err := json.NewEncoder(w).Encode(todos); err != nil {\n\t\tpanic(err)\n\t}\n}", "func Update(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\tif !c.FormValid(\"name\") {\n\t\tEdit(w, r)\n\t\treturn\n\t}\n\n\t_, err := summary.Update(c.DB, r.FormValue(\"name\"), c.Param(\"id\"))\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\tEdit(w, r)\n\t\treturn\n\t}\n\n\tc.FlashSuccess(\"Item updated.\")\n\tc.Redirect(uri)\n}", "func TodoIndex(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n\tw.WriteHeader(http.StatusOK)\n\tif err := json.NewEncoder(w).Encode(todos); err != nil {\n\t\tpanic(err)\n\t}\n}", "func update(db *sql.DB, todoID int, todo CreateTodo) (*Todo, error) {\n\tupdateStmt := fmt.Sprintf(`UPDATE todo SET title = ?, status = ? WHERE id = ?`)\n\n\t// Insert and get back newly created todo ID\n\tif _, err := db.Exec(updateStmt, todo.Title, todo.Status, todoID); err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed to save to db: %s\", err.Error())\n\t}\n\treturn get(db, todoID)\n}", "func (nc *NotificationController) UpdateNotificationViewed(ni usecase.NotificationInteractor) func(*gin.Context) {\n\treturn func(c *gin.Context) {\n\t\tuserID := c.PostForm(\"userID\")\n\t\tfeedID := c.PostForm(\"feedID\")\n\t\tisViewed, _ := strconv.ParseBool(c.PostForm(\"isViewed\"))\n\n\t\tactivity, err := ni.UpdateNotificationViewed(userID, feedID, isViewed)\n\n\t\tif err != nil {\n\t\t\tlog.Print(err)\n\t\t\tc.JSON(http.StatusNoContent, gin.H{\n\t\t\t\t\"error:\": \"Unable to update notification archive\",\n\t\t\t\t\"internalMessage\": err.Error(),\n\t\t\t})\n\t\t}\n\n\t\tc.JSON(http.StatusOK, gin.H{\n\t\t\t\"status:\": \"ok\",\n\t\t\t\"activity\": activity,\n\t\t})\n\t}\n}", "func (d *TodolistDB) View(id uint) (*model.Todolist, error) {\n\tvar t model.Todolist\n\tif err := d.cl.\n\t\tPreload(\"Tasks\").\n\t\tFind(&t, id).Error; err == gorm.ErrRecordNotFound {\n\t\treturn nil, model.ErrTodolistNotFound\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\treturn &t, nil\n}", "func (a *App) update(c *echo.Context) error {\n\tid := c.Param(\"id\")\n\ttask := &model.Task{}\n\tif a.GetDB().First(task, id) != nil {\n\t\terr := errors.New(\"Task is not found.\")\n\t\tc.JSON(http.StatusNotFound, ErrorMsg{Msg: err.Error()})\n\t\treturn err\n\t}\n\tstatus, err := task.Update(a.GetDB(), c)\n\tif err == nil {\n\t\tc.JSON(status, task)\n\t} else {\n\t\tc.JSON(status, ErrorMsg{Msg: err.Error()})\n\t}\n\treturn err\n}", "func TodoShow(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\ttodoID, err := strconv.Atoi(vars[\"todoId\"])\n\tif err != nil {\n\t\tw.WriteHeader(422) // unprocessable entity\n\t\tif err := json.NewEncoder(w).Encode(err); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t} else {\n\t\tt := RepoFindTodo(todoID)\n\t\tw.Header().Set(\"Content-Type\", \"application/json;charset=UTF-8\")\n\t\tw.WriteHeader(http.StatusFound)\n\t\tif err := json.NewEncoder(w).Encode(t); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}\n}", "func GetUserTodos(w http.ResponseWriter, r *http.Request, params httprouter.Params) {\n\tskipLiteral := r.URL.Query().Get(\"skip\")\n\tlimitLiteral := r.URL.Query().Get(\"limit\")\n\tif skipLiteral == \"\" {\n\t\tskipLiteral = \"0\"\n\t}\n\tif limitLiteral == \"\" {\n\t\tlimitLiteral = \"10\"\n\t}\n\tskip, err := strconv.Atoi(skipLiteral)\n\tif err != nil {\n\t\tshared.SendError(w, models.Response{Status: http.StatusBadRequest, Message: err.Error()})\n\t\treturn\n\t}\n\tlimit, err := strconv.Atoi(skipLiteral)\n\tif err != nil {\n\t\tshared.SendError(w, models.Response{Status: http.StatusBadRequest, Message: err.Error()})\n\t\treturn\n\t}\n\tclaims := r.Context().Value(shared.KeyClaims).(jwt.MapClaims)\n\tID := claims[\"id\"].(string)\n\n\ttodos, err := controllers.GetUserTodos(ID, params.ByName(\"id\"), skip, limit)\n\tif err != nil {\n\t\tshared.SendError(w, models.Response{Status: http.StatusInternalServerError, Message: err.Error()})\n\t\treturn\n\t}\n\tshared.SendJSON(w, http.StatusOK, todos)\n}", "func TasksEdit(c buffalo.Context) error {\n\ttx := c.Value(\"tx\").(*pop.Connection)\n\n\ttask := &models.Task{}\n\terr := tx.Eager().Find(task, c.Param(\"task_id\"))\n\tif err != nil {\n\t\tc.Flash().Add(\"warning\", \"Cannot find that task.\")\n\t\treturn c.Redirect(307, \"/\")\n\t}\n\tc.Set(\"task\", task)\n\treturn c.Render(http.StatusOK, r.HTML(\"tasks/edit.html\"))\n}", "func ShowTodosOK(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.TodosController, id int) (http.ResponseWriter, *app.Todo) {\n\t// Setup service\n\tvar (\n\t\tlogBuf bytes.Buffer\n\t\tresp interface{}\n\n\t\trespSetter goatest.ResponseSetterFunc = func(r interface{}) { resp = r }\n\t)\n\tif service == nil {\n\t\tservice = goatest.Service(&logBuf, respSetter)\n\t} else {\n\t\tlogger := log.New(&logBuf, \"\", log.Ltime)\n\t\tservice.WithLogger(goa.NewLogger(logger))\n\t\tnewEncoder := func(io.Writer) goa.Encoder { return respSetter }\n\t\tservice.Encoder = goa.NewHTTPEncoder() // Make sure the code ends up using this decoder\n\t\tservice.Encoder.Register(newEncoder, \"*/*\")\n\t}\n\n\t// Setup request context\n\trw := httptest.NewRecorder()\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/todos/%v\", id),\n\t}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tprms[\"id\"] = []string{fmt.Sprintf(\"%v\", id)}\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"TodosTest\"), rw, req, prms)\n\tshowCtx, _err := app.NewShowTodosContext(goaCtx, req, service)\n\tif _err != nil {\n\t\tpanic(\"invalid test data \" + _err.Error()) // bug\n\t}\n\n\t// Perform action\n\t_err = ctrl.Show(showCtx)\n\n\t// Validate response\n\tif _err != nil {\n\t\tt.Fatalf(\"controller returned %+v, logs:\\n%s\", _err, logBuf.String())\n\t}\n\tif rw.Code != 200 {\n\t\tt.Errorf(\"invalid response status code: got %+v, expected 200\", rw.Code)\n\t}\n\tvar mt *app.Todo\n\tif resp != nil {\n\t\tvar ok bool\n\t\tmt, ok = resp.(*app.Todo)\n\t\tif !ok {\n\t\t\tt.Fatalf(\"invalid response media: got variable of type %T, value %+v, expected instance of app.Todo\", resp, resp)\n\t\t}\n\t\t_err = mt.Validate()\n\t\tif _err != nil {\n\t\t\tt.Errorf(\"invalid response media type: %s\", _err)\n\t\t}\n\t}\n\n\t// Return results\n\treturn rw, mt\n}", "func runOperationTodosUpdateOne(cmd *cobra.Command, args []string) error {\n\tappCli, err := makeClient(cmd, args)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// retrieve flag values from cmd and fill params\n\tparams := todos.NewUpdateOneParams()\n\tif err, _ := retrieveOperationTodosUpdateOneBodyFlag(params, \"\", cmd); err != nil {\n\t\treturn err\n\t}\n\tif err, _ := retrieveOperationTodosUpdateOneIDFlag(params, \"\", cmd); err != nil {\n\t\treturn err\n\t}\n\t// make request and then print result\n\tif err := printOperationTodosUpdateOneResult(appCli.Todos.UpdateOne(params, nil)); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func UpdateTask(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tfmt.Fprint(w, \"UpdateTask\\n\")\n}", "func (fv *FileView) UpdateFavs() {\n\tsv := fv.FavsView()\n\tsv.UpdateFromSlice()\n}", "func (s *PSQLService) UpdateTodo(todo *Todo) error {\n\t_, err := s.DB.Exec(updateTodo, todo.ID, todo.Title, todo.Body)\n\treturn err\n}", "func UpdateExamples(t *testing.T, db *mongo.Database) {\n\tcoll := db.Collection(\"inventory_update\")\n\n\terr := coll.Drop(context.Background())\n\trequire.NoError(t, err)\n\n\t{\n\t\t// Start Example 51\n\n\t\tdocs := []interface{}{\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"canvas\"},\n\t\t\t\t{\"qty\", 100},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 28},\n\t\t\t\t\t{\"w\", 35.5},\n\t\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"A\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"journal\"},\n\t\t\t\t{\"qty\", 25},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 14},\n\t\t\t\t\t{\"w\", 21},\n\t\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"A\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"mat\"},\n\t\t\t\t{\"qty\", 85},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 27.9},\n\t\t\t\t\t{\"w\", 35.5},\n\t\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"A\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"mousepad\"},\n\t\t\t\t{\"qty\", 25},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 19},\n\t\t\t\t\t{\"w\", 22.85},\n\t\t\t\t\t{\"uom\", \"in\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"P\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"notebook\"},\n\t\t\t\t{\"qty\", 50},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 8.5},\n\t\t\t\t\t{\"w\", 11},\n\t\t\t\t\t{\"uom\", \"in\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"P\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"paper\"},\n\t\t\t\t{\"qty\", 100},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 8.5},\n\t\t\t\t\t{\"w\", 11},\n\t\t\t\t\t{\"uom\", \"in\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"D\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"planner\"},\n\t\t\t\t{\"qty\", 75},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 22.85},\n\t\t\t\t\t{\"w\", 30},\n\t\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"D\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"postcard\"},\n\t\t\t\t{\"qty\", 45},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 10},\n\t\t\t\t\t{\"w\", 15.25},\n\t\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"A\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"sketchbook\"},\n\t\t\t\t{\"qty\", 80},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 14},\n\t\t\t\t\t{\"w\", 21},\n\t\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"A\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"sketch pad\"},\n\t\t\t\t{\"qty\", 95},\n\t\t\t\t{\"size\", bson.D{\n\t\t\t\t\t{\"h\", 22.85},\n\t\t\t\t\t{\"w\", 30.5},\n\t\t\t\t\t{\"uom\", \"cm\"},\n\t\t\t\t}},\n\t\t\t\t{\"status\", \"A\"},\n\t\t\t},\n\t\t}\n\n\t\tresult, err := coll.InsertMany(context.Background(), docs)\n\n\t\t// End Example 51\n\n\t\trequire.NoError(t, err)\n\t\trequire.Len(t, result.InsertedIDs, 10)\n\t}\n\n\t{\n\t\t// Start Example 52\n\n\t\tresult, err := coll.UpdateOne(\n\t\t\tcontext.Background(),\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"paper\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"$set\", bson.D{\n\t\t\t\t\t{\"size.uom\", \"cm\"},\n\t\t\t\t\t{\"status\", \"P\"},\n\t\t\t\t}},\n\t\t\t\t{\"$currentDate\", bson.D{\n\t\t\t\t\t{\"lastModified\", true},\n\t\t\t\t}},\n\t\t\t},\n\t\t)\n\n\t\t// End Example 52\n\n\t\trequire.NoError(t, err)\n\t\trequire.Equal(t, int64(1), result.MatchedCount)\n\t\trequire.Equal(t, int64(1), result.ModifiedCount)\n\n\t\tcursor, err := coll.Find(\n\t\t\tcontext.Background(),\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"paper\"},\n\t\t\t})\n\n\t\trequire.NoError(t, err)\n\n\t\tfor cursor.Next(context.Background()) {\n\t\t\tdoc := cursor.Current\n\n\t\t\tuom, err := doc.LookupErr(\"size\", \"uom\")\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, uom.StringValue(), \"cm\")\n\n\t\t\tstatus, err := doc.LookupErr(\"status\")\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, status.StringValue(), \"P\")\n\n\t\t\trequire.True(t, containsKey(doc, \"lastModified\"))\n\t\t}\n\n\t\trequire.NoError(t, cursor.Err())\n\t}\n\n\t{\n\t\t// Start Example 53\n\n\t\tresult, err := coll.UpdateMany(\n\t\t\tcontext.Background(),\n\t\t\tbson.D{\n\t\t\t\t{\"qty\", bson.D{\n\t\t\t\t\t{\"$lt\", 50},\n\t\t\t\t}},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"$set\", bson.D{\n\t\t\t\t\t{\"size.uom\", \"cm\"},\n\t\t\t\t\t{\"status\", \"P\"},\n\t\t\t\t}},\n\t\t\t\t{\"$currentDate\", bson.D{\n\t\t\t\t\t{\"lastModified\", true},\n\t\t\t\t}},\n\t\t\t},\n\t\t)\n\n\t\t// End Example 53\n\n\t\trequire.NoError(t, err)\n\t\trequire.Equal(t, int64(3), result.MatchedCount)\n\t\trequire.Equal(t, int64(3), result.ModifiedCount)\n\n\t\tcursor, err := coll.Find(\n\t\t\tcontext.Background(),\n\t\t\tbson.D{\n\t\t\t\t{\"qty\", bson.D{\n\t\t\t\t\t{\"$lt\", 50},\n\t\t\t\t}},\n\t\t\t})\n\n\t\trequire.NoError(t, err)\n\n\t\tfor cursor.Next(context.Background()) {\n\t\t\tdoc := cursor.Current\n\n\t\t\tuom, err := doc.LookupErr(\"size\", \"uom\")\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, uom.StringValue(), \"cm\")\n\n\t\t\tstatus, err := doc.LookupErr(\"status\")\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, status.StringValue(), \"P\")\n\n\t\t\trequire.True(t, containsKey(doc, \"lastModified\"))\n\t\t}\n\n\t\trequire.NoError(t, cursor.Err())\n\t}\n\n\t{\n\t\t// Start Example 54\n\n\t\tresult, err := coll.ReplaceOne(\n\t\t\tcontext.Background(),\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"paper\"},\n\t\t\t},\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"paper\"},\n\t\t\t\t{\"instock\", bson.A{\n\t\t\t\t\tbson.D{\n\t\t\t\t\t\t{\"warehouse\", \"A\"},\n\t\t\t\t\t\t{\"qty\", 60},\n\t\t\t\t\t},\n\t\t\t\t\tbson.D{\n\t\t\t\t\t\t{\"warehouse\", \"B\"},\n\t\t\t\t\t\t{\"qty\", 40},\n\t\t\t\t\t},\n\t\t\t\t}},\n\t\t\t},\n\t\t)\n\n\t\t// End Example 54\n\n\t\trequire.NoError(t, err)\n\t\trequire.Equal(t, int64(1), result.MatchedCount)\n\t\trequire.Equal(t, int64(1), result.ModifiedCount)\n\n\t\tcursor, err := coll.Find(\n\t\t\tcontext.Background(),\n\t\t\tbson.D{\n\t\t\t\t{\"item\", \"paper\"},\n\t\t\t})\n\n\t\trequire.NoError(t, err)\n\n\t\tfor cursor.Next(context.Background()) {\n\t\t\trequire.True(t, containsKey(cursor.Current, \"_id\"))\n\t\t\trequire.True(t, containsKey(cursor.Current, \"item\"))\n\t\t\trequire.True(t, containsKey(cursor.Current, \"instock\"))\n\n\t\t\tinstock, err := cursor.Current.LookupErr(\"instock\")\n\t\t\trequire.NoError(t, err)\n\t\t\tvals, err := instock.Array().Values()\n\t\t\trequire.NoError(t, err)\n\t\t\trequire.Equal(t, len(vals), 2)\n\n\t\t}\n\n\t\trequire.NoError(t, cursor.Err())\n\t}\n\n}", "func (a *App) SetTodoStatus(input string) {\n\ta.load()\n\tids := a.getIDs(input)\n\tif len(ids) == 0 {\n\t\treturn\n\t}\n\n\tsplitted := strings.Split(input, \" \")\n\n\ta.TodoList.SetStatus(splitted[len(splitted)-1], ids...)\n\ta.save()\n\tfmt.Println(\"Todo status updated.\")\n}", "func FAQEditViewRender(w http.ResponseWriter, r *http.Request) {\n\tsID := r.FormValue(\"id\")\n\tif sID == \"\" {\n\t\tlog.Error(\"Form value not have id\")\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tid, err := strconv.Atoi(sID)\n\tif err != nil {\n\t\tlog.Error(\"Error convert Id from string to int \" + err.Error())\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tfaq, err := db.GetFAQByID(id)\n\tif err == NotFound {\n\t\tlog.Error(\"Get FAQ error \" + err.Error())\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t\treturn\n\t} else if err != nil {\n\t\thttp.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t//log.Error(faq)\n\n\tfaqs := []db.FAQ{faq}\n\n\tvar result = make(map[string]interface{})\n\n\tresult[\"faq\"] = faqs\n\n\ttplHelper.Render(w, \"edit\", result)\n}", "func (_m *DatabaseReaderWriter) UpdateTodo(ctx context.Context, todo entity.Todo) error {\n\tret := _m.Called(ctx, todo)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(context.Context, entity.Todo) error); ok {\n\t\tr0 = rf(ctx, todo)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func TodoRoutes(app fiber.Router) {\n\tr := app.Group(\"/todo\").Use(middleware.Auth)\n\n\tr.Post(\"/create\", controller.Create)\n\tr.Get(\"/list\", controller.GetAll)\n\tr.Get(\"/:todoID\", controller.Get)\n\tr.Patch(\"/:todoID\", controller.Update)\n\tr.Patch(\"/:todoID/check\", controller.Check)\n\tr.Delete(\"/:todoID\", controller.Delete)\n}", "func (uuo *UserUpdateOne) SetViews(i int) *UserUpdateOne {\n\tuuo.mutation.ResetViews()\n\tuuo.mutation.SetViews(i)\n\treturn uuo\n}", "func HandleUpdateShow(w http.ResponseWriter, r *http.Request) error {\n\n\t// Fetch the params\n\tparams, err := mux.Params(r)\n\tif err != nil {\n\t\treturn server.InternalError(err)\n\t}\n\n\t// Find the post\n\tpost, err := posts.Find(params.GetInt(posts.KeyName))\n\tif err != nil {\n\t\treturn server.NotFoundError(err)\n\t}\n\n\t// Authorise update post\n\tuser := session.CurrentUser(w, r)\n\terr = can.Update(post, user)\n\tif err != nil {\n\t\treturn server.NotAuthorizedError(err)\n\t}\n\n\t// Fetch the users\n\tauthors, err := users.FindAll(users.Where(\"role=?\", users.Admin))\n\tif err != nil {\n\t\treturn server.InternalError(err)\n\t}\n\n\t// Render the template\n\tview := view.NewRenderer(w, r)\n\tview.AddKey(\"currentUser\", user)\n\tview.AddKey(\"post\", post)\n\tview.AddKey(\"authors\", authors)\n\treturn view.Render()\n}", "func (n *Note) Edit(note string, done bool) error {\n\n n.Note = note\n n.Done = done\n n.Updated_at = time.Now()\n rows, err := n.DB.Query(\"UPDATE \"+TABLE+\" SET note = ?, done = ?, updated_at = ? WHERE id = ?\", n.Note, n.Done, n.Updated_at, n.ID)\n defer rows.Close()\n\n return err\n}", "func (tdc ToDoController) ListAllToDos(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tuser := context.Get(r, \"user\").(model.User)\n\n\tvar todos []model.ToDo\n\tvar err error\n\n\tif user.IsAdmin() {\n\t\ttodos, err = model.ListAllToDos(0)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tutils.WriteJSON(w, \"Unable to show all created ToDos\", 400)\n\t\t}\n\t} else {\n\t\ttodos, err = model.ListAllToDos(user.ID)\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tutils.WriteJSON(w, \"Unable to show all created ToDos\", 400)\n\t\t}\n\t}\n\n\tutils.WriteJSON(w, todos, 200)\n}", "func todoHandler(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase \"GET\":\n\n\t\ttodoList := GetAll()\n\n\t\tresult, err := json.Marshal(todoList)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.Write(result)\n\n\t\tbreak\n\tcase \"POST\":\n\n\t\tdecoder := json.NewDecoder(r.Body)\n\t\tvar todo Todo\n\n\t\terr := decoder.Decode(&todo)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tAddTodo(todo)\n\t\tw.WriteHeader(http.StatusOK)\n\t\tbreak\n\tcase \"DELETE\":\n\t\tvar id int\n\n\t\tdecoder := json.NewDecoder(r.Body)\n\n\t\tif err := decoder.Decode(&id); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tDeleteTodo(id)\n\n\t\tbreak\n\t}\n\n}", "func (a *App) EditTodo(todoID int, input string) {\n\ta.load()\n\ttodo := a.TodoList.FindByID(todoID)\n\tif todo == nil {\n\t\tfmt.Println(\"No todo with that id.\")\n\t\treturn\n\t}\n\n\tparser := &InputParser{}\n\tfilter, err := parser.Parse(input)\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\n\tif err = EditTodo(todo, a.TodoList, filter); err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\n\ta.save()\n\tfmt.Println(\"Todo updated.\")\n}", "func (fv *FileView) UpdateFiles() {\n\tupdt := fv.UpdateStart()\n\tdefer fv.UpdateEnd(updt)\n\tvar win oswin.Window\n\tif fv.Viewport != nil && fv.Viewport.Win != nil && fv.Viewport.Win.OSWin != nil {\n\t\twin = fv.Viewport.Win.OSWin\n\t} else {\n\t\twin = oswin.TheApp.WindowInFocus()\n\t}\n\n\tfv.UpdatePath()\n\tpf := fv.PathField()\n\tif len(gi.SavedPaths) == 0 {\n\t\tgi.OpenPaths()\n\t}\n\tgi.SavedPaths.AddPath(fv.DirPath, gi.Prefs.SavedPathsMax)\n\tgi.SavePaths()\n\tsp := []string(gi.SavedPaths)\n\tsp = append(sp, fileViewResetPaths)\n\tpf.ItemsFromStringList(sp, true, 0)\n\tpf.SetText(fv.DirPath)\n\tsf := fv.SelField()\n\tsf.SetText(fv.SelFile)\n\toswin.TheApp.Cursor(win).Push(cursor.Wait)\n\tdefer oswin.TheApp.Cursor(win).Pop()\n\n\tfv.Files = make([]*FileInfo, 0, 1000)\n\tfilepath.Walk(fv.DirPath, func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\temsg := fmt.Sprintf(\"Path %q: Error: %v\", fv.DirPath, err)\n\t\t\t// if fv.Viewport != nil {\n\t\t\t// \tgi.PromptDialog(fv.Viewport, \"FileView UpdateFiles\", emsg, true, false, nil, nil)\n\t\t\t// } else {\n\t\t\tlog.Printf(\"gi.FileView error: %v\\n\", emsg)\n\t\t\t// }\n\t\t\treturn nil // ignore\n\t\t}\n\t\tif path == fv.DirPath { // proceed..\n\t\t\treturn nil\n\t\t}\n\t\tfi, ferr := NewFileInfo(path)\n\t\tkeep := ferr == nil\n\t\tif fv.FilterFunc != nil {\n\t\t\tkeep = fv.FilterFunc(fv, fi)\n\t\t}\n\t\tif keep {\n\t\t\tfv.Files = append(fv.Files, fi)\n\t\t}\n\t\tif info.IsDir() {\n\t\t\treturn filepath.SkipDir\n\t\t}\n\t\treturn nil\n\t})\n\n\tsv := fv.FilesView()\n\tsv.SelField = \"Name\"\n\tsv.SelVal = fv.SelFile\n\tsv.UpdateFromSlice()\n\tfv.SelectedIdx = sv.SelectedIdx\n\tif sv.SelectedIdx >= 0 {\n\t\tsv.ScrollToRow(sv.SelectedIdx)\n\t}\n}", "func (t *ThreadController) Update(c *gin.Context) {\n\n\tif err := model.ValidateParams(c, \"tid\"); err != nil {\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, gin.H{\n\t\t\t\"errors\": err,\n\t\t})\n\t\treturn\n\t}\n\n\tif err := model.ValidatePostFromParams(c, \"title\", \"body\"); err != nil {\n\t\tc.AbortWithStatusJSON(http.StatusBadRequest, gin.H{\n\t\t\t\"errors\": err,\n\t\t})\n\t\treturn\n\t}\n\n\tts.Update(c)\n\n\tc.Redirect(http.StatusFound, \"/t\")\n}", "func (t *TaskStore) update(up reqUpdate) ([]*Task, error) {\n\tuerr := UpdateError{}\n\ttransaction := make([]updateDiff, len(up.Deletes)+len(up.Changes))\n\tif len(transaction) == 0 {\n\t\tuerr.Bugs = append(uerr.Bugs, fmt.Errorf(\"empty update requested\"))\n\t\treturn nil, uerr\n\t}\n\n\t// Check that the requested operation is allowed.\n\t// This means:\n\t// - All referenced task IDs must exist: dependencies, deletions, and updates.\n\t// - Updates and deletions must be modifying an unowned task, or a task owned by the requester.\n\t// - Additions are always OK.\n\t// - All of the above must be true *simultaneously* for any operation to be done.\n\n\t// Check that the dependencies are all around.\n\tif missing := t.missingDependencies(up.Depends); len(missing) > 0 {\n\t\tuerr.Depends = missing\n\t}\n\n\tnow := Now()\n\n\t// Check that the deletions exist and are either owned by this client or expired, as well.\n\t// Also create transactions for these deletions.\n\tfor i, id := range up.Deletes {\n\t\ttask := t.getTask(id)\n\t\tif task == nil {\n\t\t\tuerr.Deletes = append(uerr.Deletes, id)\n\t\t\tcontinue\n\t\t}\n\t\tif !canModify(now, up.OwnerID, task) {\n\t\t\tuerr.Owned = append(uerr.Owned, task.ID)\n\t\t\tcontinue\n\t\t}\n\t\t// Make a deletion transaction.\n\t\ttransaction[i] = updateDiff{id, nil}\n\t}\n\n\tfor chgi, task := range up.Changes {\n\t\ti := chgi + len(up.Deletes)\n\n\t\t// Additions always OK.\n\t\tif task.ID <= 0 {\n\t\t\tif task.Group == \"\" {\n\t\t\t\tuerr.Bugs = append(uerr.Bugs, fmt.Errorf(\"update bug: adding task with empty task group not allowed: %v\", task))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !uerr.HasErrors() {\n\t\t\t\ttransaction[i] = updateDiff{0, task.Copy()}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\t// Everything else has to exist first.\n\t\tot := t.getTask(task.ID)\n\t\tif ot == nil {\n\t\t\tuerr.Changes = append(uerr.Changes, task.ID)\n\t\t\tcontinue\n\t\t}\n\t\tif !canModify(now, up.OwnerID, ot) {\n\t\t\tuerr.Owned = append(uerr.Owned, ot.ID)\n\t\t\tcontinue\n\t\t}\n\t\t// Specifying a different (or any) group is meaningless in an update,\n\t\t// as this cannot be changed, so we just make sure that the update has\n\t\t// the same group as the existing task before creating the update entry.\n\t\ttask.Group = ot.Group\n\t\ttransaction[i] = updateDiff{task.ID, task.Copy()}\n\t}\n\n\tif uerr.HasErrors() {\n\t\treturn nil, uerr\n\t}\n\n\t// Create new tasks for all non-deleted tasks, since we only get here without errors.\n\t// Also assign IDs and times as needed. Note that deletes are always in\n\t// front, so we start that far along in the transaction slice.\n\tnewTasks := make([]*Task, len(up.Changes))\n\tfor i, diff := range transaction[len(up.Deletes):] {\n\t\tnt := diff.NewTask\n\t\tnewTasks[i] = nt\n\t\tif nt == nil {\n\t\t\tcontinue\n\t\t}\n\t\t// Assign IDs to all new tasks, and assign \"now\" to any that have no availability set.\n\t\t// Negative available time means \"add the absolute value of this to now\".\n\t\tnt.ID = t.nextID()\n\t\tif nt.AT <= 0 {\n\t\t\tnt.AT = now - nt.AT\n\t\t}\n\t}\n\n\tif err := t.applyTransaction(transaction); err != nil {\n\t\tuerr.Bugs = append(uerr.Bugs, err)\n\t\treturn nil, uerr\n\t}\n\n\treturn newTasks, nil\n}", "func UpdateHandler(db storage.DB) atreugo.View {\n\treturn func(ctx *atreugo.RequestCtx) error {\n\t\tqueries := queriesParam(ctx)\n\t\tworlds := storage.AcquireWorlds()[:queries]\n\n\t\tfor i := 0; i < queries; i++ {\n\t\t\tw := &worlds[i]\n\t\t\tdb.GetOneRandomWorld(w)\n\t\t\tw.RandomNumber = int32(storage.RandomWorldNum())\n\t\t}\n\n\t\tdb.UpdateWorlds(worlds)\n\t\terr := ctx.JSONResponse(worlds)\n\n\t\tstorage.ReleaseWorlds(worlds)\n\n\t\treturn err\n\t}\n}", "func metricViewPut(c *gin.Context) {\n\tvar f models.MetricView\n\tginx.BindJSON(c, &f)\n\n\tview, err := models.MetricViewGet(\"id = ?\", f.Id)\n\tginx.Dangerous(err)\n\n\tif view == nil {\n\t\tginx.NewRender(c).Message(\"no such item(id: %d)\", f.Id)\n\t\treturn\n\t}\n\n\tme := c.MustGet(\"user\").(*models.User)\n\tif !me.IsAdmin() {\n\t\tf.Cate = 1\n\n\t\t// 如果是普通用户,只能修改自己的\n\t\tif view.CreateBy != me.Id {\n\t\t\tginx.NewRender(c, http.StatusForbidden).Message(\"forbidden\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tginx.NewRender(c).Message(view.Update(f.Name, f.Configs, f.Cate, me.Id))\n}", "func (r *RepoImp) UpdateTodo(id int, todo models.Todo) error {\n\treturn r.db.Model(todo).Where(models.Todo{ID: id}).Update(&todo).Error\n}", "func updateTask(msg BackendPayload) {\n\tincomingTaskID := msg.ID // attempt to retreive the id of the task in the case its an update POST\n\t// TodoList[incomingTaskID] = Task{incomingTaskID, msg.TaskName} // update task with id provided\n\tTodoList.Store(incomingTaskID, Task{incomingTaskID, msg.TaskName})\n\treturn\n}", "func (handler WebserviceHandler) UpdateFaq(res http.ResponseWriter, req *http.Request) {\n\thandler.Logger.Info(\"Received \" + req.Method + \" request at path: \" + req.URL.Path)\n\n\t// Setting headers for CORS\n\tres.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n\tres.Header().Set(\"Access-Control-Allow-Headers\", \"Authorization\")\n\tif req.Method == http.MethodOptions {\n\t\treturn\n\t}\n\n\tvar err error\n\tvar updatedFaq Faq\n\n\t// Parsing the request body\n\terr = json.NewDecoder(req.Body).Decode(&updatedFaq)\n\tif err != nil {\n\t\tres.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Checking request, verifying if ID is in query params\n\thandler.Logger.Debug(\"Starting to check the ID\")\n\tvar id string\n\tok := checkID(handler, res, req)\n\tif !ok {\n\t\treturn\n\t}\n\tids, ok := req.URL.Query()[\"id\"]\n\tid = ids[0]\n\thandler.Logger.Debug(\"Request correct, ID inserted as query params\")\n\n\thandler.Logger.Info(\"ID: \" + id)\n\n\t// Transforming data for presentation\n\thandler.Logger.Debug(\"Starting to transform data for presentation\")\n\tusecasesFaq := webserviceFaqToUsecaseFaq(updatedFaq)\n\thandler.Logger.Debug(\"Data transformed for presentation\")\n\n\t// Updating faq\n\thandler.Logger.Debug(\"Starting to update faq\")\n\terr = handler.KnowledgeBaseInteractor.Update(id, usecasesFaq)\n\tif err != nil {\n\t\tres.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\thandler.Logger.Debug(\"Faq updated\")\n\n\t// Preparing response\n\tres.WriteHeader(200)\n\thandler.Logger.Info(\"Returning response\")\n\treturn\n}", "func (c *todoController) GetAll(ctx *fiber.Ctx) error {\n\tres := []TodoResponse{}\n\tuser := utils.GetUser(ctx)\n\n\ttodos, err := c.useCase.FindByUser(user)\n\n\tfor _, todo := range todos {\n\t\ttodoRes := TodoResponse{\n\t\t\tID: todo.ID,\n\t\t\tTask: todo.Task,\n\t\t\tCompleted: todo.Completed,\n\t\t}\n\n\t\tres = append(res, todoRes)\n\t}\n\n\tif err != nil {\n\t\treturn fiber.NewError(fiber.StatusConflict, err.Error())\n\t}\n\n\treturn ctx.JSON(&TodosResponse{\n\t\tTodos: &res,\n\t})\n}", "func (ctrl *TaskController) UpdateTask(w http.ResponseWriter, r *http.Request) {\n\ttask := &model.Task{}\n\terr := GetJSONContent(task, r)\n\tif err != nil {\n\t\tlogrus.Error(err)\n\t\tSendJSONError(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tlogrus.Println(\"update task : \", task.Id)\n\n\ttask.ModificationDate = time.Now()\n\n\ttaskExist, err := ctrl.taskDao.Exist(task.Id)\n\tif err != nil {\n\t\tlogrus.Error(err)\n\t\tSendJSONError(w, err.Error(), http.StatusNotFound)\n\t\treturn\n\t} else if taskExist == false {\n\t\tSendJSONError(w, \"task not found\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\ttask, err = ctrl.taskDao.Upsert(task)\n\tif err != nil {\n\t\tlogrus.Error(err)\n\t\tSendJSONError(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tlogrus.Println(\"task : \", task)\n\tSendJSONOk(w, task)\n}", "func (o TaskSlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) {\n\tln := int64(len(o))\n\tif ln == 0 {\n\t\treturn 0, nil\n\t}\n\n\tif len(cols) == 0 {\n\t\treturn 0, errors.New(\"models: update all requires at least one column argument\")\n\t}\n\n\tcolNames := make([]string, len(cols))\n\targs := make([]interface{}, len(cols))\n\n\ti := 0\n\tfor name, value := range cols {\n\t\tcolNames[i] = name\n\t\targs[i] = value\n\t\ti++\n\t}\n\n\t// Append all of the primary key values for each column\n\tfor _, obj := range o {\n\t\tpkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), taskPrimaryKeyMapping)\n\t\targs = append(args, pkeyArgs...)\n\t}\n\n\tsql := fmt.Sprintf(\"UPDATE \\\"tasks\\\" SET %s WHERE %s\",\n\t\tstrmangle.SetParamNames(\"\\\"\", \"\\\"\", 1, colNames),\n\t\tstrmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), len(colNames)+1, taskPrimaryKeyColumns, len(o)))\n\n\tif boil.IsDebug(ctx) {\n\t\twriter := boil.DebugWriterFrom(ctx)\n\t\tfmt.Fprintln(writer, sql)\n\t\tfmt.Fprintln(writer, args...)\n\t}\n\tresult, err := exec.ExecContext(ctx, sql, args...)\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"models: unable to update all in task slice\")\n\t}\n\n\trowsAff, err := result.RowsAffected()\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"models: unable to retrieve rows affected all in update all task\")\n\t}\n\treturn rowsAff, nil\n}", "func (t *TodoRepository) UpdateTodo(todo *entity.Todo) (*mongo.UpdateResult, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\tdefer cancel()\n\n\tcollection := t.db.Database(\"taski\").Collection(\"todos\")\n\n\tfilter := bson.M{\"_id\": todo.Id}\n\tupdate := bson.M{\n\t\t\"$set\": bson.M{\n\t\t\t\"title\": todo.Title,\n\t\t\t\"isDone\": todo.IsDone,\n\t\t\t\"status\": todo.Status,\n\t\t\t\"schedule\": todo.Schedule,\n\t\t}}\n\n\tresult, err := collection.UpdateOne(ctx, filter, update)\n\tavoidPanic(err)\n\n\tupdateNewUpdatedAtInProject(t, todo, ctx)\n\n\treturn result, nil\n}", "func (rc *RockClient) UpdateView(ctx context.Context, workspace, view, query string,\n\toptions ...option.ViewOption) (openapi.View, error) {\n\tvar err error\n\tvar httpResp *http.Response\n\tvar resp *openapi.UpdateViewResponse\n\n\tq := rc.ViewsApi.UpdateView(ctx, workspace, view)\n\treq := openapi.NewUpdateViewRequest(query)\n\n\topts := option.ViewOptions{}\n\tfor _, o := range options {\n\t\to(&opts)\n\t}\n\n\tif opts.Description != nil {\n\t\treq.Description = opts.Description\n\t}\n\n\terr = rc.Retry(ctx, func() error {\n\t\tresp, httpResp, err = q.Body(*req).Execute()\n\n\t\treturn NewErrorWithStatusCode(err, httpResp)\n\t})\n\n\tif err != nil {\n\t\treturn openapi.View{}, err\n\t}\n\n\tlog := zerolog.Ctx(ctx)\n\tlog.Trace().Str(\"status\", httpResp.Status).Msg(\"view updated\")\n\n\treturn resp.GetData(), nil\n}", "func list(w http.ResponseWriter, r *http.Request) {\r\n\t // If method is post create a new list as well as create new items if needed\r\n\t if(r.Method==\"POST\"){\r\n\t\tid, _ := strconv.ParseInt(r.PostFormValue(\"id\"), 10, 64)\r\n\t\titemsid, _ :=strconv.ParseInt(r.PostFormValue(\"items.id\"), 10, 64)\r\n\t\t// items given\r\n\t\titemsof :=content{\r\n\t\t\tID : itemsid,\r\n\t\t\tvalue: r.PostFormValue(\"items.value\"),\r\n\t\t\tcompleted: r.PostFormValue(\"items.completed\"),\r\n\t\t}\r\n\r\n\t\t//list given\r\n\t\ttodo := &toDoList{\r\n\t\t\tID: id,\r\n\t\t\tname: r.PostFormValue(\"name\"),\r\n\t\t\titems: itemsof,\r\n\t\t}\r\n\r\n\t\t// Insert the list into the LIST table\r\n\t\tquery := \"INSERT INTO public.list(id, name) VALUES($1,$2)\"\r\n\t\terr := db.QueryRow(query, todo.ID, todo.name)\r\n\t\tif err!=nil{\r\n\t\t\tpanic(err)\r\n\t\t}\r\n\r\n\t\t// Insert the items into the ITEM table\r\n\t\tquery = \"INSERT INTO public.item(listId,id, value,complete) VALUES($1,$2,$3,$4)\"\r\n\t\terr = db.QueryRow(query,id,itemsof.ID, itemsof.value,itemsof.completed)\r\n\t\tif err!=nil{\r\n\t\t\tpanic(err)\r\n\t\t}\r\n\t\tjson.NewEncoder(w).Encode(todo)\r\n\t\treturn \r\n\t }\r\n\r\n\t // If method is delete then delete list with given list id\r\n\t if(r.Method==\"DELETE\"){\r\n\t\t\t // If you are going to delete list in List table first delete all the items corresponding to that list\r\n\t\t\t\r\n\t\t\tid, _ := strconv.ParseInt(r.URL.Query().Get(\"id\"), 10, 64)\r\n\t\t\t query := \"DELETE from public.item where listid=$1\"\r\n\t\t\t_, err = db.Exec(query,id)\r\n\t\t\tif err != nil {\r\n\t\t\tpanic(err)\r\n\t\t\t}\r\n\r\n\t\t\t\r\n\t\t\tquery = \"DELETE from public.list where id=$1\"\r\n\t\t\t_, err = db.Exec(query,id)\r\n\t\t\tif err != nil {\r\n\t\t\t\tpanic(err)\r\n\t\t\t}\r\n\t\t\treturn\r\n\r\n\t }\r\n\r\n\t // if the method is patch update the name of the list with given list id\r\n\t if(r.Method==\"PATCH\"){\r\n\t\t\tid, _ := strconv.ParseInt(r.URL.Query().Get(\"id\"), 10, 64)\r\n\t\t\tname:= r.PostFormValue(\"name\")\r\n\t\t\tquery := \"UPDATE public.list set name=$2 where id=$1\"\r\n\t\t\t_, err = db.Exec(query,name,id)\r\n\t\t\tif err != nil {\r\n\t\t\t\tpanic(err)\r\n\t\t\t}\r\n\t\t\treturn\r\n\t }\r\n\t http.Error(w, \"404 not found.\", http.StatusNotFound)\r\n\t return\r\n}", "func (db *Database) Update(id int, params *UpdateParams) (*Todo, error) {\n\t// Create variables to hold the query fields\n\t// being updated and their new values.\n\tvar queryFields string\n\tvar queryValues []interface{}\n\n\t// Handle created field.\n\tif params.Created != nil {\n\t\tif queryFields == \"\" {\n\t\t\tqueryFields = \"created=?\"\n\t\t} else {\n\t\t\tqueryFields += \", created=?\"\n\t\t}\n\n\t\tqueryValues = append(queryValues, *params.Created)\n\t}\n\n\t// Handle detail field.\n\tif params.Detail != nil {\n\t\tif queryFields == \"\" {\n\t\t\tqueryFields = \"detail=?\"\n\t\t} else {\n\t\t\tqueryFields += \", detail=?\"\n\t\t}\n\n\t\tqueryValues = append(queryValues, *params.Detail)\n\t}\n\n\t// Handle completed field.\n\tif params.Completed != nil {\n\t\tif queryFields == \"\" {\n\t\t\tqueryFields = \"completed=?\"\n\t\t} else {\n\t\t\tqueryFields += \", completed=?\"\n\t\t}\n\n\t\t// Handle turning boolean into tinyint.\n\t\tif *params.Completed {\n\t\t\tqueryValues = append(queryValues, 1)\n\t\t} else {\n\t\t\tqueryValues = append(queryValues, 0)\n\t\t}\n\t}\n\n\t// Check if the query is empty.\n\tif queryFields == \"\" {\n\t\treturn db.GetByID(id)\n\t}\n\n\t// Build the full query.\n\tquery := fmt.Sprintf(stmtUpdate, queryFields)\n\tqueryValues = append(queryValues, id)\n\n\t// Execute the query.\n\t_, err := db.db.Exec(query, queryValues...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Since the GetByID method is straight forward,\n\t// we can use this method to retrieve the updated\n\t// todo. Anything more complicated should use the\n\t// original statement constants.\n\treturn db.GetByID(id)\n}", "func (u *usecase) Update() error {\n\t// Time execution\n\tstart := time.Now()\n\n\t// Creating context with timeout duration process\n\tctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)\n\tdefer cancel()\n\n\t// Get all archieve from scrapper repository\n\tarchieves, err := u.scrapperRepo.GetAllArchieve()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Create array (slice) of archieve object\n\tvar newArchieves []*model.Archieve\n\n\t// Check if archieve is exist in DB\n\tfor _, archieve := range archieves {\n\t\t// Get archieve from DB by archieve code\n\t\t_, err := u.mysqlRepo.GetArchieveByCode(ctx, archieve.Code)\n\n\t\t// if archieve not exist then add to newArchieve array (slice)\n\t\tif err == model.ErrDataNotFound {\n\t\t\t// Add archieve\n\t\t\tnewArchieves = append(newArchieves, archieve)\n\t\t\tlog.Printf(\"New archieve: %v\", archieve.Code)\n\t\t} else if err != nil && err != model.ErrDataNotFound {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Counter new journal from archieves\n\tvar totalNewJournal int\n\n\t// Get new archieves journals\n\tfor _, newArchieve := range newArchieves {\n\t\t// Get all journal from scrapper repository based on archieve\n\t\tjournals, err := u.scrapperRepo.GetAllJournalByArchieveObject(newArchieve)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Append Journals into archieve object\n\t\tnewArchieve.Journals = journals\n\t\ttotalNewJournal += len(newArchieve.Journals)\n\t}\n\n\t// Check if there's new archieve then saved new archieve into DB\n\tif len(newArchieves) > 0 {\n\t\t// Insert new archieves into DB\n\t\tif err := u.mysqlRepo.BatchArchieves(ctx, newArchieves); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tlog.Printf(\"Added %v archieve and %v journal (%v)m\", len(newArchieves), totalNewJournal, time.Since(start).Minutes())\n\n\t// if there's no update then do nothing or finish pull data from archieve scrapper\n\treturn nil\n}", "func Edit(w http.ResponseWriter, r *http.Request) {\n\tc := flight.Context(w, r)\n\n\titem, _, err := summary.ByID(c.DB, c.Param(\"id\"))\n\tif err != nil {\n\t\tc.FlashErrorGeneric(err)\n\t\tc.Redirect(uri)\n\t\treturn\n\t}\n\n\tv := c.View.New(\"summary/edit\")\n\tc.Repopulate(v.Vars, \"name\")\n\tv.Vars[\"item\"] = item\n\tv.Render(w, r)\n}", "func UpdateAll(ui UI, data *UIData) {\n\tvar wg sync.WaitGroup\n\tfor _, service := range data.Services {\n\t\twg.Add(1)\n\t\tgo service.Update(&wg)\n\t}\n\twg.Wait()\n\n\tdata.LastTimestamp = time.Now()\n\n\tui.Update(*data)\n}", "func (a *AppController) UpdateWorlds() {\n\ta.handleResult(models.UpdateRandomWorlds(a.getCount()))\n}", "func Edit(writer http.ResponseWriter, request *http.Request, p httprouter.Params) {\n\n\tvar TP m.Thread\n\n\t//find the thread by id and assign it to TP\n\terr := m.Threads.Find(\"_id\", p.ByName(\"id\"), &TP)\n\tif err != nil {\n\t\tLogger.Println(\"Not able to Find the thread by ID!!\")\n\t\thttp.Redirect(writer, request, \"/home\", 302)\n\t\treturn\n\t}\n\n\tvar UP m.User\n\n\t//get the User and assign to User UP struct\n\terr = m.Users.Find(\"_id\", TP.User, &UP)\n\tif err != nil {\n\t\tLogger.Println(\"Not able to Find the user by ID!!\")\n\t\thttp.Redirect(writer, request, \"/\", 302)\n\t\treturn\n\t}\n\n\t// get the list of mongo collections\n\tcoll, err := m.ShowCollectionNames(m.DB)\n\tif err != nil {\n\t\tLogger.Println(\"Not able to Get the list of Collection!!\")\n\t\thttp.Redirect(writer, request, \"/\", 302)\n\t\treturn\n\t}\n\n\tdashlist := m.FindDetails{\n\t\tCollectionNames: coll,\n\t\tContentDetails: &TP,\n\t\tUser: &UP,\n\t}\n\n\tvar LIP m.LogInUser\n\n\terr = m.GetLogInUser(\"User\", &LIP, request)\n\tif err != nil {\n\t\tdashlist.LogInUser = nil\n\t\tLogger.Printf(\"Failed to get the login details %v\\n\", err)\n\t} else {\n\t\tdashlist.LogInUser = &LIP\n\t}\n\n\tgenerateHTML(writer, &dashlist, \"Layout\", \"ThreadLeftSideBar\", \"ThreadTopSideBar\", \"ThreadModal\", \"ThreadEdit\")\n}", "func (resolver *ResolverTODO) Update(params graphql.ResolveParams) (interface{}, error) {\n\ttodo, err := resolver.Db.Update(params.Args)\n\n\tif err != nil {\n\t\treturn nil, err\n\t} else if todo.ID == \"\" {\n\t\treturn nil, errors.New(\"todo not found\")\n\t}\n\n\treturn todo, nil\n}", "func ListTodosOK(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.TodosController) (http.ResponseWriter, app.TodoCollection) {\n\t// Setup service\n\tvar (\n\t\tlogBuf bytes.Buffer\n\t\tresp interface{}\n\n\t\trespSetter goatest.ResponseSetterFunc = func(r interface{}) { resp = r }\n\t)\n\tif service == nil {\n\t\tservice = goatest.Service(&logBuf, respSetter)\n\t} else {\n\t\tlogger := log.New(&logBuf, \"\", log.Ltime)\n\t\tservice.WithLogger(goa.NewLogger(logger))\n\t\tnewEncoder := func(io.Writer) goa.Encoder { return respSetter }\n\t\tservice.Encoder = goa.NewHTTPEncoder() // Make sure the code ends up using this decoder\n\t\tservice.Encoder.Register(newEncoder, \"*/*\")\n\t}\n\n\t// Setup request context\n\trw := httptest.NewRecorder()\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/todos/\"),\n\t}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"TodosTest\"), rw, req, prms)\n\tlistCtx, _err := app.NewListTodosContext(goaCtx, req, service)\n\tif _err != nil {\n\t\tpanic(\"invalid test data \" + _err.Error()) // bug\n\t}\n\n\t// Perform action\n\t_err = ctrl.List(listCtx)\n\n\t// Validate response\n\tif _err != nil {\n\t\tt.Fatalf(\"controller returned %+v, logs:\\n%s\", _err, logBuf.String())\n\t}\n\tif rw.Code != 200 {\n\t\tt.Errorf(\"invalid response status code: got %+v, expected 200\", rw.Code)\n\t}\n\tvar mt app.TodoCollection\n\tif resp != nil {\n\t\tvar ok bool\n\t\tmt, ok = resp.(app.TodoCollection)\n\t\tif !ok {\n\t\t\tt.Fatalf(\"invalid response media: got variable of type %T, value %+v, expected instance of app.TodoCollection\", resp, resp)\n\t\t}\n\t\t_err = mt.Validate()\n\t\tif _err != nil {\n\t\t\tt.Errorf(\"invalid response media type: %s\", _err)\n\t\t}\n\t}\n\n\t// Return results\n\treturn rw, mt\n}", "func UpdateTask(w http.ResponseWriter, r *http.Request, repo *tasks.TaskRepository) {\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tdecoder := json.NewDecoder(r.Body)\n\tparams := mux.Vars(r)\n\ttaskID, err := strconv.Atoi(params[\"id\"])\n\tvar updateParams map[string]string\n\terr = decoder.Decode(&updateParams)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\ttask, err := repo.UpdateTask(taskID, updateParams)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tjson.NewEncoder(w).Encode(apiIndexTask(task))\n}", "func (_m *TodoUsecase) UpdateTodoByID(_a0 context.Context, _a1 domain.TodoUpdatePayload) error {\n\tret := _m.Called(_a0, _a1)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(context.Context, domain.TodoUpdatePayload) error); ok {\n\t\tr0 = rf(_a0, _a1)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func updateAnArticle(w http.ResponseWriter, r *http.Request){\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tvar updatedArticle article\n\t_ = json.NewDecoder(r.Body).Decode(&updatedArticle)\n\tparams := mux.Vars(r)\n\tfor index, article := range articles {\n\t\tif article.ID == params[\"id\"] { \n\t\t\tupdatedArticle.ID = params[\"id\"] \n\t\t\tarticle.Title = updatedArticle.Title\n\t\t\tarticle.Content = updatedArticle.Content\n\t\t\tarticles = append(articles[:index], updatedArticle) //{\"ID\":\"4\",\"Title\":\"Go is Clean and Readable\",\"Content\":\"It is clean in design, easy to read and outputs very fast.\"}\n\t\t\tjson.NewEncoder(w).Encode(updatedArticle)\n\t\t\tw.WriteHeader(http.StatusAccepted)\n\t\t\tw.Write([]byte(`{\"success\": \"article updated\"}`))\n\t\t}\n\t}\n}", "func Index(w http.ResponseWriter, r *http.Request) {\n\tw.Header().Set(\"Content-Type\", \"application/json; charset=UTF-8\")\n//\tw.WriteHeader(http.StatusOK)\n\n\tfmt.Fprint(w, `{\"todos\":\"/todos/\"}\\n`)\n}", "func templateHTML(releases []models.HelmRelease, w io.Writer) error {\n\n\tsum := internalSummery{\n\t\tOutdatedReleases: make(map[string][]uiHelmRelease),\n\t\tDeprecatedReleases: make(map[string][]uiHelmRelease),\n\t\tGoodReleases: make(map[string][]uiHelmRelease),\n\t}\n\n\tfor _, c := range releases {\n\t\tuiC := uiHelmRelease{\n\t\t\tName: c.Name,\n\t\t\tNamespace: c.Namespace,\n\t\t\tDeprecated: c.Deprecated,\n\t\t\tInstalledVersion: c.InstalledVersion,\n\t\t\tLatestVersion: c.LatestVersion,\n\t\t\tOutdated: c.InstalledVersion != c.LatestVersion,\n\t\t}\n\n\t\tif uiC.Deprecated {\n\t\t\tsum.DeprecatedReleases[uiC.Namespace] = append(sum.DeprecatedReleases[uiC.Namespace], uiC)\n\t\t} else if uiC.Outdated {\n\t\t\tsum.OutdatedReleases[uiC.Namespace] = append(sum.OutdatedReleases[uiC.Namespace], uiC)\n\t\t} else {\n\t\t\tsum.GoodReleases[uiC.Namespace] = append(sum.GoodReleases[uiC.Namespace], uiC)\n\t\t}\n\t}\n\n\tfor i, v := range sum.DeprecatedReleases {\n\t\tsort.Sort(ByName(v))\n\t\tsum.DeprecatedReleases[i] = v\n\t}\n\n\tfor i, v := range sum.OutdatedReleases {\n\t\tsort.Sort(ByName(v))\n\t\tsum.OutdatedReleases[i] = v\n\t}\n\n\tfor i, v := range sum.GoodReleases {\n\t\tsort.Sort(ByName(v))\n\t\tsum.GoodReleases[i] = v\n\t}\n\n\tt := template.Must(template.New(\"index.html\").Funcs(getFunctions()).ParseFS(views, \"views/*\"))\n\terr := t.Execute(w, sum)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func ShowTodosNotFound(t goatest.TInterface, ctx context.Context, service *goa.Service, ctrl app.TodosController, id int) http.ResponseWriter {\n\t// Setup service\n\tvar (\n\t\tlogBuf bytes.Buffer\n\t\tresp interface{}\n\n\t\trespSetter goatest.ResponseSetterFunc = func(r interface{}) { resp = r }\n\t)\n\tif service == nil {\n\t\tservice = goatest.Service(&logBuf, respSetter)\n\t} else {\n\t\tlogger := log.New(&logBuf, \"\", log.Ltime)\n\t\tservice.WithLogger(goa.NewLogger(logger))\n\t\tnewEncoder := func(io.Writer) goa.Encoder { return respSetter }\n\t\tservice.Encoder = goa.NewHTTPEncoder() // Make sure the code ends up using this decoder\n\t\tservice.Encoder.Register(newEncoder, \"*/*\")\n\t}\n\n\t// Setup request context\n\trw := httptest.NewRecorder()\n\tu := &url.URL{\n\t\tPath: fmt.Sprintf(\"/todos/%v\", id),\n\t}\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\tpanic(\"invalid test \" + err.Error()) // bug\n\t}\n\tprms := url.Values{}\n\tprms[\"id\"] = []string{fmt.Sprintf(\"%v\", id)}\n\tif ctx == nil {\n\t\tctx = context.Background()\n\t}\n\tgoaCtx := goa.NewContext(goa.WithAction(ctx, \"TodosTest\"), rw, req, prms)\n\tshowCtx, _err := app.NewShowTodosContext(goaCtx, req, service)\n\tif _err != nil {\n\t\tpanic(\"invalid test data \" + _err.Error()) // bug\n\t}\n\n\t// Perform action\n\t_err = ctrl.Show(showCtx)\n\n\t// Validate response\n\tif _err != nil {\n\t\tt.Fatalf(\"controller returned %+v, logs:\\n%s\", _err, logBuf.String())\n\t}\n\tif rw.Code != 404 {\n\t\tt.Errorf(\"invalid response status code: got %+v, expected 404\", rw.Code)\n\t}\n\n\t// Return results\n\treturn rw\n}", "func (t *TaskService) Edit(w http.ResponseWriter, r *http.Request) {\n\tvar (\n\t\temptyUUID gocql.UUID\n\t\ttaskIDStr = mux.Vars(r)[\"taskID\"]\n\t\tpartnerID = mux.Vars(r)[partnerIDKey]\n\t\tctx = r.Context()\n\t\tcurrentUser = t.userService.GetUser(r, t.httpClient)\n\t\tmodifiedAt = time.Now().Truncate(time.Millisecond).UTC()\n\t)\n\n\ttaskID, err := gocql.ParseUUID(taskIDStr)\n\tif err != nil || taskID == emptyUUID {\n\t\tlogger.Log.ErrfCtx(r.Context(), errorcode.ErrorTaskIDHasBadFormat, \"TaskService.Edit: task ID(UUID=%s) has bad format or empty. err=%v\", taskIDStr, err)\n\t\tcommon.SendBadRequest(w, r, errorcode.ErrorTaskIDHasBadFormat)\n\t\treturn\n\t}\n\n\tinputTask, err := t.extractPostTaskPayload(r, w)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tinputTask.PartnerID = partnerID\n\tinternalTasks, err := t.taskPersistence.GetByIDs(ctx, nil, inputTask.PartnerID, false, taskID)\n\tif err != nil && err != gocql.ErrNotFound {\n\t\tlogger.Log.ErrfCtx(r.Context(), errorcode.ErrorCantGetTaskByTaskID, \"TaskService.Edit: can not get internal tasks by Task ID %v. err=%v\", taskID, err)\n\t\tcommon.SendInternalServerError(w, r, errorcode.ErrorCantGetTaskByTaskID)\n\t\treturn\n\t}\n\n\tif len(internalTasks) == 0 {\n\t\tlogger.Log.ErrfCtx(r.Context(), errorcode.ErrorCantGetTaskByTaskID, \"TaskService.Edit: can not get internal tasks by Task ID %v. err=%v\", taskID, err)\n\t\tcommon.SendNotFound(w, r, errorcode.ErrorCantGetTaskByTaskID)\n\t\treturn\n\t}\n\n\ttask := internalTasks[0]\n\ttask.Schedule = inputTask.Schedule\n\ttask.Schedule.StartRunTime = task.Schedule.StartRunTime.Truncate(time.Minute)\n\ttask.Schedule.EndRunTime = task.Schedule.EndRunTime.Truncate(time.Minute)\n\ttask.ModifiedBy = currentUser.UID()\n\ttask.ModifiedAt = modifiedAt\n\ttask.DefinitionID = inputTask.DefinitionID\n\ttask.OriginID = inputTask.OriginID\n\ttask.PartnerID = partnerID\n\n\ttask.TargetsByType = inputTask.TargetsByType\n\tif task.TargetsByType == nil {\n\t\ttask.TargetsByType = make(models.TargetsByType)\n\t}\n\n\tif inputTask.Targets.Type != 0 {\n\t\ttask.TargetsByType[inputTask.Targets.Type] = inputTask.Targets.IDs\n\t}\n\n\tfor targetType, targets := range task.TargetsByType {\n\t\ttask.Targets.Type = targetType\n\t\ttask.Targets.IDs = targets\n\t}\n\n\tif len(inputTask.Parameters) > 0 {\n\t\ttask.Parameters = inputTask.Parameters\n\t}\n\n\tfor i := range internalTasks {\n\t\tinternalTasks[i].OriginalNextRunTime = time.Time{}\n\t\tif internalTasks[i].State != statuses.TaskStateDisabled {\n\t\t\tinternalTasks[i].State = statuses.TaskStateInactive\n\t\t}\n\t\tinternalTasks[i].ModifiedBy = currentUser.UID()\n\t}\n\n\tt.processEditReq(ctx, internalTasks, r, w, currentUser, task)\n}", "func (o VoteSlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) {\n\tln := int64(len(o))\n\tif ln == 0 {\n\t\treturn 0, nil\n\t}\n\n\tif len(cols) == 0 {\n\t\treturn 0, errors.New(\"models: update all requires at least one column argument\")\n\t}\n\n\tcolNames := make([]string, len(cols))\n\targs := make([]interface{}, len(cols))\n\n\ti := 0\n\tfor name, value := range cols {\n\t\tcolNames[i] = name\n\t\targs[i] = value\n\t\ti++\n\t}\n\n\t// Append all of the primary key values for each column\n\tfor _, obj := range o {\n\t\tpkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), votePrimaryKeyMapping)\n\t\targs = append(args, pkeyArgs...)\n\t}\n\n\tsql := fmt.Sprintf(\"UPDATE \\\"vote\\\" SET %s WHERE %s\",\n\t\tstrmangle.SetParamNames(\"\\\"\", \"\\\"\", 1, colNames),\n\t\tstrmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), len(colNames)+1, votePrimaryKeyColumns, len(o)))\n\n\tif boil.IsDebug(ctx) {\n\t\twriter := boil.DebugWriterFrom(ctx)\n\t\tfmt.Fprintln(writer, sql)\n\t\tfmt.Fprintln(writer, args...)\n\t}\n\tresult, err := exec.ExecContext(ctx, sql, args...)\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"models: unable to update all in vote slice\")\n\t}\n\n\trowsAff, err := result.RowsAffected()\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"models: unable to retrieve rows affected all in update all vote\")\n\t}\n\treturn rowsAff, nil\n}", "func taskDefUpdateHandler(w http.ResponseWriter, r *http.Request, isReplace bool) {\r\n\r\n\t// decode json run \"public\" metadata\r\n\tvar tpd db.TaskDefPub\r\n\tif !jsonRequestDecode(w, r, true, &tpd) {\r\n\t\treturn // error at json decode, response done with http error\r\n\t}\r\n\r\n\t// if task name is empty then automatically generate name\r\n\tif tpd.Name == \"\" {\r\n\t\tts, _ := theCatalog.getNewTimeStamp()\r\n\t\ttpd.Name = \"task_\" + ts\r\n\t}\r\n\r\n\t// update task definition in model catalog\r\n\tok, dn, tn, err := theCatalog.UpdateTaskDef(isReplace, &tpd)\r\n\tif err != nil {\r\n\t\tomppLog.Log(err.Error())\r\n\t\thttp.Error(w, \"Modeling task merge failed \"+dn+\": \"+tn, http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\tif ok {\r\n\t\tw.Header().Set(\"Content-Location\", \"/api/model/\"+dn+\"/task/\"+tn)\r\n\t\tjsonResponse(w, r,\r\n\t\t\tstruct {\r\n\t\t\t\tName string // task name\r\n\t\t\t}{\r\n\t\t\t\tName: tn,\r\n\t\t\t},\r\n\t\t)\r\n\t}\r\n}", "func (q taskQuery) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) {\n\tqueries.SetUpdate(q.Query, cols)\n\n\tresult, err := q.Query.ExecContext(ctx, exec)\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"models: unable to update all for tasks\")\n\t}\n\n\trowsAff, err := result.RowsAffected()\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"models: unable to retrieve rows affected for tasks\")\n\t}\n\n\treturn rowsAff, nil\n}" ]
[ "0.61347115", "0.60770625", "0.6028172", "0.5963277", "0.59206903", "0.5800302", "0.5769452", "0.57317597", "0.5701334", "0.5638788", "0.5621505", "0.5592594", "0.55199575", "0.5502505", "0.550189", "0.54874307", "0.54446393", "0.5402243", "0.5352037", "0.52726525", "0.5271713", "0.52642226", "0.52520216", "0.52047944", "0.5145475", "0.51327956", "0.504338", "0.5033786", "0.49886233", "0.49669018", "0.4952276", "0.4948357", "0.49276954", "0.49028802", "0.48611125", "0.48599505", "0.48097238", "0.47771165", "0.47655758", "0.47554737", "0.47440714", "0.47406146", "0.47357765", "0.47152498", "0.47131377", "0.47110206", "0.47064373", "0.468947", "0.4672454", "0.46400154", "0.4639596", "0.4618658", "0.46180847", "0.46125618", "0.46036103", "0.45755914", "0.45644102", "0.45603442", "0.4551829", "0.4549802", "0.45429704", "0.4538938", "0.45343134", "0.4533787", "0.45258114", "0.45176944", "0.44991565", "0.4493169", "0.4493113", "0.44862065", "0.44841275", "0.44522196", "0.44348437", "0.44341323", "0.44301215", "0.44225827", "0.4421787", "0.44157323", "0.44023243", "0.43853647", "0.43629453", "0.43538886", "0.4349662", "0.4349101", "0.43478563", "0.43299773", "0.4325197", "0.4324986", "0.43223372", "0.4316154", "0.4314278", "0.43126446", "0.43111166", "0.4301055", "0.4285933", "0.42844936", "0.4279901", "0.42794293", "0.427548", "0.4274425" ]
0.56051385
11
/ Returns an elliptic.CurveWrapper around this group. The elliptic.CurveParams returned by the .Params() method the Curve should not be used for doing ScalarMult, etc.!
func (m *ModulusGroup) AsCurve() elliptic.Curve { return &asCurve{m} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s Keygen) Curve() elliptic.Curve {\n\treturn s.group\n}", "func getCurve() elliptic.Curve {\n return elliptic.P256()\n}", "func CurveParamsParams(curve *elliptic.CurveParams,) *elliptic.CurveParams", "func NewCurve(xyz XYZer) Curve {\n\tc := Curve{}\n\tc.points.minXYZ.X, c.points.minXYZ.Y, c.points.minXYZ.Z = xyz.XYZ(0)\n\tc.points.maxXYZ.X, c.points.maxXYZ.Y, c.points.maxXYZ.Z = xyz.XYZ(0)\n\tc.points.XYZs = CopyXYZs(xyz)\n\tfor i := range c.points.XYZs {\n\t\tx, y, z := c.points.XYZ(i)\n\t\tupdateBounds(&c.points, x, y, z)\n\t}\n\treturn c\n}", "func EllipticCurve() elliptic.Curve {\n\treturn p256Strategy()\n}", "func getECDSACurve(scheme SignatureScheme) elliptic.Curve {\n\tswitch scheme {\n\tcase ECDSAWithP256AndSHA256:\n\t\treturn elliptic.P256()\n\tcase ECDSAWithP384AndSHA384:\n\t\treturn elliptic.P384()\n\tcase ECDSAWithP521AndSHA512:\n\t\treturn elliptic.P521()\n\tdefault:\n\t\treturn nil\n\t}\n}", "func (c *curve) init(self kyber.Group, p *Param, fullGroup bool,\n\tnull, base point) *curve {\n\tc.self = self\n\tc.Param = *p\n\tc.full = fullGroup\n\tc.null = null\n\n\t// Edwards curve parameters as ModInts for convenience\n\tc.a.Init(&p.A, &p.P)\n\tc.d.Init(&p.D, &p.P)\n\n\t// Cofactor\n\tc.cofact.Init64(int64(p.R), &c.P)\n\n\t// Determine the modulus for scalars on this curve.\n\t// Note that we do NOT initialize c.order with Init(),\n\t// as that would normalize to the modulus, resulting in zero.\n\t// Just to be sure it's never used, we leave c.order.M set to nil.\n\t// We want it to be in a ModInt so we can pass it to P.Mul(),\n\t// but the scalar's modulus isn't needed for point multiplication.\n\tif fullGroup {\n\t\t// Scalar modulus is prime-order times the ccofactor\n\t\tc.order.V.SetInt64(int64(p.R)).Mul(&c.order.V, &p.Q)\n\t} else {\n\t\tc.order.V.Set(&p.Q) // Prime-order subgroup\n\t}\n\n\t// Useful ModInt constants for this curve\n\tc.zero.Init64(0, &c.P)\n\tc.one.Init64(1, &c.P)\n\n\t// Identity element is (0,1)\n\tnull.initXY(zero, one, self)\n\n\t// Base point B\n\tvar bx, by *big.Int\n\tif !fullGroup {\n\t\tbx, by = &p.PBX, &p.PBY\n\t} else {\n\t\tbx, by = &p.FBX, &p.FBY\n\t\tbase.initXY(&p.FBX, &p.FBY, self)\n\t}\n\tif by.Sign() == 0 {\n\t\t// No standard base point was defined, so pick one.\n\t\t// Find the lowest-numbered y-coordinate that works.\n\t\t//println(\"Picking base point:\")\n\t\tvar x, y mod.Int\n\t\tfor y.Init64(2, &c.P); ; y.Add(&y, &c.one) {\n\t\t\tif !c.solveForX(&x, &y) {\n\t\t\t\tcontinue // try another y\n\t\t\t}\n\t\t\tif c.coordSign(&x) != 0 {\n\t\t\t\tx.Neg(&x) // try positive x first\n\t\t\t}\n\t\t\tbase.initXY(&x.V, &y.V, self)\n\t\t\tif c.validPoint(base) {\n\t\t\t\tbreak // got one\n\t\t\t}\n\t\t\tx.Neg(&x) // try -bx\n\t\t\tif c.validPoint(base) {\n\t\t\t\tbreak // got one\n\t\t\t}\n\t\t}\n\t\t//println(\"BX: \"+x.V.String())\n\t\t//println(\"BY: \"+y.V.String())\n\t\tbx, by = &x.V, &y.V\n\t}\n\tbase.initXY(bx, by, self)\n\n\t// Uniform representation encoding methods,\n\t// only useful when using the full group.\n\t// (Points taken from the subgroup would be trivially recognizable.)\n\tif fullGroup {\n\t\tif p.Elligator1s.Sign() != 0 {\n\t\t\tc.hide = new(el1param).init(c, &p.Elligator1s)\n\t\t} else if p.Elligator2u.Sign() != 0 {\n\t\t\tc.hide = new(el2param).init(c, &p.Elligator2u)\n\t\t}\n\t}\n\n\t// Sanity checks\n\tif !c.validPoint(null) {\n\t\tpanic(\"invalid identity point \" + null.String())\n\t}\n\tif !c.validPoint(base) {\n\t\tpanic(\"invalid base point \" + base.String())\n\t}\n\n\treturn c\n}", "func GetCurve(s string) elliptic.Curve {\n\ts3 := s[len(s)-3:]\n\tif s3 == \"256\" {\n\t\treturn elliptic.P256()\n\t} else if s3 == \"384\" {\n\t\treturn elliptic.P384()\n\t} else if s3 == \"521\" {\n\t\treturn elliptic.P521()\n\t}\n\treturn elliptic.P224()\n}", "func newPrivateKeyOnCurve(c elliptic.Curve) (*PrivateKey, error) {\n\tpk, err := ecdsa.GenerateKey(c, rand.Reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &PrivateKey{*pk}, nil\n}", "func Generic(c elliptic.Curve) KeyExchange {\n\tif c == nil {\n\t\tpanic(\"ecdh: curve is nil\")\n\t}\n\treturn genericCurve{curve: c}\n}", "func curveByName(name string) elliptic.Curve {\n\tswitch name {\n\tcase \"P-224\":\n\t\treturn elliptic.P224()\n\tcase \"P-256\":\n\t\treturn elliptic.P256()\n\tcase \"P-384\":\n\t\treturn elliptic.P384()\n\tcase \"P-521\":\n\t\treturn elliptic.P521()\n\tcase \"P-256K\", \"SECP256K1\", \"secp256k1\":\n\t\treturn secp256k1.S256()\n\tdefault:\n\t\treturn nil\n\t}\n}", "func CurveParamsScalarMult(curve *elliptic.CurveParams, Bx, By *big.Int, k []byte) (*big.Int, *big.Int)", "func CurveParamsScalarBaseMult(curve *elliptic.CurveParams, k []byte) (*big.Int, *big.Int)", "func CurveByName(curveName string) ec.Curve {\n\tswitch curveName {\n\tcase \"P-224\":\n\t\treturn ec.P224()\n\tcase \"P-256\":\n\t\treturn ec.P256()\n\tcase \"P-384\":\n\t\treturn ec.P384()\n\tcase \"P-521\":\n\t\treturn ec.P521()\n\tdefault:\n\t\treturn nil\n\t}\n}", "func getCurve(curve string) (elliptic.Curve, string, error) {\n\tswitch curve {\n\tcase \"secp224r1\": // secp224r1: NIST/SECG curve over a 224 bit prime field\n\t\treturn elliptic.P224(), \"secp224r1\", nil\n\tcase \"prime256v1\": // prime256v1: X9.62/SECG curve over a 256 bit prime field\n\t\treturn elliptic.P256(), \"prime256v1\", nil\n\tcase \"secp384r1\": // secp384r1: NIST/SECG curve over a 384 bit prime field\n\t\treturn elliptic.P384(), \"secp384r1\", nil\n\tcase \"secp521r1\": // secp521r1: NIST/SECG curve over a 521 bit prime field\n\t\treturn elliptic.P521(), \"secp521r1\", nil\n\tdefault:\n\t\treturn nil, \"\", fmt.Errorf(\"%s\", helpers.RFgB(\"incorrect curve size passed\"))\n\t}\n}", "func (this *NurbsCurve) clone() *NurbsCurve {\n\treturn &NurbsCurve{\n\t\tdegree: this.degree,\n\t\tcontrolPoints: append([]HomoPoint(nil), this.controlPoints...),\n\t\tknots: this.knots.Clone(),\n\t}\n}", "func CurveParamsAdd(curve *elliptic.CurveParams, x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)", "func CurveParamsDouble(curve *elliptic.CurveParams, x1, y1 *big.Int) (*big.Int, *big.Int)", "func NewECDSA(c config.Reader, name string, curve string) (KeyAPI, error) {\n\t// Validate the type of curve passed\n\tec, ty, err := getCurve(curve)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Generate the private key with our own io.Reader\n\tpri, err := ecdsa.GenerateKey(ec, crypto.Reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Extract the public key\n\tpub := &pri.PublicKey\n\n\t// PEM #1 - encoding\n\tpemKey, pemPub, perr := enc.Encode(pri, pub)\n\tif perr != nil {\n\t\treturn nil, perr\n\t}\n\n\t// Create the key struct object\n\tkey := &key{\n\t\tGID: api.GenerateUUID(),\n\t\tName: name,\n\t\tSlug: helpers.NewHaikunator().Haikunate(),\n\t\tKeyType: fmt.Sprintf(\"ecdsa.PrivateKey <==> %s\", ty),\n\t\tStatus: api.StatusActive,\n\t\tPublicKeyB64: base64.StdEncoding.EncodeToString([]byte(pemPub)),\n\t\tPrivateKeyB64: base64.StdEncoding.EncodeToString([]byte(pemKey)),\n\t\tFingerprintMD5: enc.FingerprintMD5(pub),\n\t\tFingerprintSHA: enc.FingerprintSHA256(pub),\n\t\tCreatedAt: time.Now(),\n\t}\n\n\t// Write the entire key object to FS\n\tif err := key.writeToFS(c, pri, pub); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn key, nil\n}", "func (c EasyCert) newPrivateKey() (crypto.PrivateKey, error) {\n\tif c.ec != \"\" {\n\t\tvar curve elliptic.Curve\n\t\tswitch c.ec {\n\t\tcase \"224\":\n\t\t\tcurve = elliptic.P224()\n\t\tcase \"384\":\n\t\t\tcurve = elliptic.P384()\n\t\tcase \"521\":\n\t\t\tcurve = elliptic.P521()\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unknown elliptic curve: %q\", c.ec)\n\t\t}\n\t\treturn ecdsa.GenerateKey(curve, rand.Reader)\n\t}\n\treturn rsa.GenerateKey(rand.Reader, c.rsaBits)\n}", "func (d MapDescriptor) Get(e C.EllCurve) MapToCurve {\n\tswitch d.ID {\n\tcase BF:\n\t\treturn NewBF(e)\n\tcase SSWU:\n\t\tz := e.Field().Elt(d.Z)\n\t\treturn NewSSWU(e, z, d.Iso)\n\tcase SVDW:\n\t\treturn NewSVDW(e)\n\tcase ELL2:\n\t\treturn NewElligator2(e)\n\tdefault:\n\t\tpanic(\"Mapping not supported\")\n\t}\n}", "func parseECPrivateKey(namedCurveOID *asn1.ObjectIdentifier, der []byte) (key *ecdsa.PrivateKey, err error) {\n\tvar privKey ecPrivateKey\n\tif _, err := asn1.Unmarshal(der, &privKey); err != nil {\n\t\treturn nil, errors.New(\"x509: failed to parse EC private key: \" + err.Error())\n\t}\n\tif privKey.Version != ecPrivKeyVersion {\n\t\treturn nil, fmt.Errorf(\"x509: unknown EC private key version %d\", privKey.Version)\n\t}\n\n\tvar curve elliptic.Curve\n\tif namedCurveOID != nil {\n\t\tcurve = namedCurveFromOID(*namedCurveOID)\n\t} else {\n\t\tcurve = namedCurveFromOID(privKey.NamedCurveOID)\n\t}\n\tif curve == nil {\n\t\treturn nil, errors.New(\"x509: unknown elliptic curve\")\n\t}\n\n\tk := new(big.Int).SetBytes(privKey.PrivateKey)\n\tcurveOrder := curve.Params().N\n\tif k.Cmp(curveOrder) >= 0 {\n\t\treturn nil, errors.New(\"x509: invalid elliptic curve private key value\")\n\t}\n\tpriv := new(ecdsa.PrivateKey)\n\tpriv.Curve = curve\n\tpriv.D = k\n\n\tprivateKey := make([]byte, (curveOrder.BitLen()+7)/8)\n\n\t// Some private keys have leading zero padding. This is invalid\n\t// according to [SEC1], but this code will ignore it.\n\tfor len(privKey.PrivateKey) > len(privateKey) {\n\t\tif privKey.PrivateKey[0] != 0 {\n\t\t\treturn nil, errors.New(\"x509: invalid private key length\")\n\t\t}\n\t\tprivKey.PrivateKey = privKey.PrivateKey[1:]\n\t}\n\n\t// Some private keys remove all leading zeros, this is also invalid\n\t// according to [SEC1] but since OpenSSL used to do this, we ignore\n\t// this too.\n\tcopy(privateKey[len(privateKey)-len(privKey.PrivateKey):], privKey.PrivateKey)\n\tpriv.X, priv.Y = curve.ScalarBaseMult(privateKey)\n\n\treturn priv, nil\n}", "func PeelCurve() model2d.Curve {\n\treturn model2d.JoinedCurve{\n\t\tmodel2d.BezierCurve{\n\t\t\tmodel2d.XY(-1.0, 0.0),\n\t\t\tmodel2d.XY(-0.6, 0.6),\n\t\t\tmodel2d.XY(0.0, 0.0),\n\t\t},\n\t\tmodel2d.BezierCurve{\n\t\t\tmodel2d.XY(0.0, 0.0),\n\t\t\tmodel2d.XY(0.6, -0.6),\n\t\t\tmodel2d.XY(1.0, 0.0),\n\t\t},\n\t}\n}", "func (phi *isogeny4) GenerateCurve(p *ProjectivePoint) CurveCoefficientsEquiv {\n\tvar coefEq CurveCoefficientsEquiv\n\tvar xp4, zp4 = &p.X, &p.Z\n\tvar K1, K2, K3 = &phi.K1, &phi.K2, &phi.K3\n\n\top := phi.Field\n\top.Sub(K2, xp4, zp4)\n\top.Add(K3, xp4, zp4)\n\top.Square(K1, zp4)\n\top.Add(K1, K1, K1)\n\top.Square(&coefEq.C, K1)\n\top.Add(K1, K1, K1)\n\top.Square(&coefEq.A, xp4)\n\top.Add(&coefEq.A, &coefEq.A, &coefEq.A)\n\top.Square(&coefEq.A, &coefEq.A)\n\treturn coefEq\n}", "func genericParamsForCurve(c Curve) *CurveParams {\n\td := *(c.Params())\n\treturn &d\n}", "func newProtoECDSAPrivateKey(publicKey *ecdsapb.EcdsaPublicKey, keyValue []byte) *ecdsapb.EcdsaPrivateKey {\n\treturn &ecdsapb.EcdsaPrivateKey{\n\t\tVersion: 0,\n\t\tPublicKey: publicKey,\n\t\tKeyValue: keyValue,\n\t}\n}", "func toECDSA(curveName string, d []byte, strict bool) (*ecdsa.PrivateKey, error) {\n\tpriv := new(ecdsa.PrivateKey)\n\n\tpriv.PublicKey.Curve = CurveType(curveName)\n\tif strict && 8*len(d) != priv.Params().BitSize {\n\t\treturn nil, fmt.Errorf(\"invalid length, need %d bits\", priv.Params().BitSize)\n\t}\n\tpriv.D = new(big.Int).SetBytes(d)\n\n\t// The priv.D must < N,secp256k1N\n\tif priv.D.Cmp(priv.PublicKey.Curve.Params().N) >= 0 {\n\t\treturn nil, fmt.Errorf(\"invalid private key, >=N\")\n\t}\n\t// The priv.D must not be zero or negative.\n\tif priv.D.Sign() <= 0 {\n\t\treturn nil, fmt.Errorf(\"invalid private key, zero or negative\")\n\t}\n\n\tpriv.PublicKey.X, priv.PublicKey.Y = priv.PublicKey.Curve.ScalarBaseMult(d)\n\tif priv.PublicKey.X == nil {\n\t\treturn nil, errors.New(\"invalid private key\")\n\t}\n\treturn priv, nil\n}", "func (x *ed25519_t) New(public PublicKey, private PrivateKey) (Credentials, error) {\n\n\tvar credentials Ed25519Credentials\n\tvar err error\n\n\terr = credentials.SetPublicKey(public)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = credentials.SetPrivateKey(private)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &credentials, nil\n\n}", "func NewGRPCClient(conn *grpc.ClientConn, logger log.Logger) mathservice2.Service {\n\tvar divideEndpoint endpoint.Endpoint\n\t{\n\t\tdivideEndpoint = grpctransport.NewClient(\n\t\t\tconn,\n\t\t\t\"pb.Math\",\n\t\t\t\"Divide\",\n\t\t\tencodeGRPCMathOpRequest,\n\t\t\tdecodeGRPCMathOpResponse,\n\t\t\tpb.MathOpReply{},\n\t\t).Endpoint()\n\t}\n\tvar maxEndpoint endpoint.Endpoint\n\t{\n\t\tmaxEndpoint = grpctransport.NewClient(\n\t\t\tconn,\n\t\t\t\"pb.Math\",\n\t\t\t\"Max\",\n\t\t\tencodeGRPCMathOpRequest,\n\t\t\tdecodeGRPCMathOpResponse,\n\t\t\tpb.MathOpReply{},\n\t\t).Endpoint()\n\t}\n\tvar minEndpoint endpoint.Endpoint\n\t{\n\t\tminEndpoint = grpctransport.NewClient(\n\t\t\tconn,\n\t\t\t\"pb.Math\",\n\t\t\t\"Min\",\n\t\t\tencodeGRPCMathOpRequest,\n\t\t\tdecodeGRPCMathOpResponse,\n\t\t\tpb.MathOpReply{},\n\t\t).Endpoint()\n\t}\n\tvar multiplyEndpoint endpoint.Endpoint\n\t{\n\t\tmultiplyEndpoint = grpctransport.NewClient(\n\t\t\tconn,\n\t\t\t\"pb.Math\",\n\t\t\t\"Multiply\",\n\t\t\tencodeGRPCMathOpRequest,\n\t\t\tdecodeGRPCMathOpResponse,\n\t\t\tpb.MathOpReply{},\n\t\t).Endpoint()\n\t}\n\tvar powEndpoint endpoint.Endpoint\n\t{\n\t\tpowEndpoint = grpctransport.NewClient(\n\t\t\tconn,\n\t\t\t\"pb.Math\",\n\t\t\t\"Pow\",\n\t\t\tencodeGRPCMathOpRequest,\n\t\t\tdecodeGRPCMathOpResponse,\n\t\t\tpb.MathOpReply{},\n\t\t).Endpoint()\n\t}\n\tvar subtractEndpoint endpoint.Endpoint\n\t{\n\t\tsubtractEndpoint = grpctransport.NewClient(\n\t\t\tconn,\n\t\t\t\"pb.Math\",\n\t\t\t\"Subtract\",\n\t\t\tencodeGRPCMathOpRequest,\n\t\t\tdecodeGRPCMathOpResponse,\n\t\t\tpb.MathOpReply{},\n\t\t).Endpoint()\n\t}\n\tvar sumEndpoint endpoint.Endpoint\n\t{\n\t\tsumEndpoint = grpctransport.NewClient(\n\t\t\tconn,\n\t\t\t\"pb.Math\",\n\t\t\t\"Sum\",\n\t\t\tencodeGRPCMathOpRequest,\n\t\t\tdecodeGRPCMathOpResponse,\n\t\t\tpb.MathOpReply{},\n\t\t).Endpoint()\n\t}\n\n\t// Returning the endpoint.Set as a service.Service relies on the\n\t// endpoint.Set implementing the Service methods. That's just a simple bit\n\t// of glue code.\n\treturn mathendpoint2.Set{\n\t\tDivideEndpoint: divideEndpoint,\n\t\tMaxEndpoint: maxEndpoint,\n\t\tMinEndpoint: minEndpoint,\n\t\tMultiplyEndpoint: multiplyEndpoint,\n\t\tPowEndpoint: powEndpoint,\n\t\tSubtractEndpoint: subtractEndpoint,\n\t\tSumEndpoint: sumEndpoint,\n\t}\n}", "func NewEcdsaParty(prv *PrvKey) (*EcdsaParty, error) {\n\tpub := prv.PubKey()\n\tcurve := pub.Curve\n\tN := curve.Params().N\n\n\t// Paillier key pair.\n\tencpub, encprv, err := paillier.GenerateKeyPair(bitlen)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Homomorphic Encryption of party pk.\n\tencpk, err := encpub.Encrypt(prv.D)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &EcdsaParty{\n\t\tN: N,\n\t\tprv: prv,\n\t\tpub: pub,\n\t\tcurve: curve,\n\t\tencpub: encpub,\n\t\tencprv: encprv,\n\t\tencpk: encpk,\n\t}, nil\n}", "func New(compressed bool) *PrivateKey {\n\tbuf := make([]byte, 32)\n\tz := new(big.Int)\n\n\tfor z.Cmp(big.NewInt(1)) == -1 || z.Cmp(curve.Params().N) == 1 {\n\t\t_, err := rand.Read(buf)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\t\tz.SetBytes(buf)\n\t}\n\n\tKxInt, KyInt := curve.ScalarBaseMult(z.Bytes())\n\tpubKey := &PublicKey{\n\t\tx: KxInt,\n\t\ty: KyInt,\n\t\tcompressed: compressed,\n\t}\n\n\treturn &PrivateKey{\n\t\tk: z,\n\t\tpubkey: pubKey,\n\t}\n}", "func NewPrivateKey(curve elliptic.Curve) (*PrivateKey, error) {\n\tkey, err := ecdsa.GenerateKey(curve, rand.Reader)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn (*PrivateKey)(key), nil\n}", "func S224() *Curve {\n\tinitonce.Do(initAll)\n\treturn secp224k1\n}", "func NewKey() (*Key, *big.Int, error) {\n\t// Use the DSA crypto code to generate a key pair. For testing\n\t// purposes, we'll use (2048,224) instead of (2048,160) as used by the\n\t// current Helios implementation\n\tparams := new(dsa.Parameters)\n\tif err := dsa.GenerateParameters(params, rand.Reader, dsa.L2048N224); err != nil {\n\t\t// glog.Error(\"Couldn't generate DSA parameters for the ElGamal group\")\n\t\treturn nil, nil, err\n\t}\n\n\treturn NewKeyFromParams(params.G, params.P, params.Q)\n}", "func newKeyPair() (ecdsa.PrivateKey, []byte) {\n\t// ECC generate private key\n\tcurve := elliptic.P256()\n\tprivate, err := ecdsa.GenerateKey(curve, rand.Reader)\n\tlog.Println(\"--------\", private)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\t// private key generate public key\n\tpubKey := append(private.PublicKey.X.Bytes(), private.PublicKey.Y.Bytes()...)\n\treturn *private, pubKey\n}", "func newEcdsaKeyPair(config CreateKeyPairConfig) (KeyPair, error) {\n\tvar curve elliptic.Curve\n\n\tswitch config.Bits {\n\tcase 0:\n\t\tconfig.Bits = 521\n\t\tfallthrough\n\tcase 521:\n\t\tcurve = elliptic.P521()\n\tcase 384:\n\t\tcurve = elliptic.P384()\n\tcase 256:\n\t\tcurve = elliptic.P256()\n\tcase 224:\n\t\t// Not supported by \"golang.org/x/crypto/ssh\".\n\t\treturn KeyPair{}, fmt.Errorf(\"golang.org/x/crypto/ssh does not support %d bits\", config.Bits)\n\tdefault:\n\t\treturn KeyPair{}, fmt.Errorf(\"crypto/elliptic does not support %d bits\", config.Bits)\n\t}\n\n\tprivateKey, err := ecdsa.GenerateKey(curve, rand.Reader)\n\tif err != nil {\n\t\treturn KeyPair{}, err\n\t}\n\n\tsshPublicKey, err := gossh.NewPublicKey(&privateKey.PublicKey)\n\tif err != nil {\n\t\treturn KeyPair{}, err\n\t}\n\n\tprivateRaw, err := x509.MarshalECPrivateKey(privateKey)\n\tif err != nil {\n\t\treturn KeyPair{}, err\n\t}\n\n\tprivatePem, err := rawPemBlock(&pem.Block{\n\t\tType: \"EC PRIVATE KEY\",\n\t\tHeaders: nil,\n\t\tBytes: privateRaw,\n\t})\n\tif err != nil {\n\t\treturn KeyPair{}, err\n\t}\n\n\treturn KeyPair{\n\t\tPrivateKeyPemBlock: privatePem,\n\t\tPublicKeyAuthorizedKeysLine: authorizedKeysLine(sshPublicKey, config.Comment),\n\t\tComment: config.Comment,\n\t}, nil\n}", "func GetECPrivateKey(raw []byte) (*ecdsa.PrivateKey, error) {\n\tdecoded, _ := pem.Decode(raw)\n\tif decoded == nil {\n\t\treturn nil, errors.New(\"Failed to decode the PEM-encoded ECDSA key\")\n\t}\n\tECPrivKey, err := x509.ParseECPrivateKey(decoded.Bytes)\n\tif err == nil {\n\t\treturn ECPrivKey, nil\n\t}\n\tkey, err2 := x509.ParsePKCS8PrivateKey(decoded.Bytes)\n\tif err2 == nil {\n\t\tswitch key.(type) {\n\t\tcase *ecdsa.PrivateKey:\n\t\t\treturn key.(*ecdsa.PrivateKey), nil\n\t\tcase *rsa.PrivateKey:\n\t\t\treturn nil, errors.New(\"Expecting EC private key but found RSA private key\")\n\t\tdefault:\n\t\t\treturn nil, errors.New(\"Invalid private key type in PKCS#8 wrapping\")\n\t\t}\n\t}\n\treturn nil, errors.Wrap(err, \"Failed parsing EC private key\")\n}", "func mkKey(ecdsaCurve string, rsaBits int) (interface{}, error) {\n\tvar priv interface{}\n\tvar err error\n\tswitch ecdsaCurve {\n\tcase \"\":\n\t\tpriv, err = rsa.GenerateKey(rand.Reader, rsaBits)\n\tcase \"P224\":\n\t\tpriv, err = ecdsa.GenerateKey(elliptic.P224(), rand.Reader)\n\tcase \"P256\":\n\t\tpriv, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader)\n\tcase \"P384\":\n\t\tpriv, err = ecdsa.GenerateKey(elliptic.P384(), rand.Reader)\n\tcase \"P521\":\n\t\tpriv, err = ecdsa.GenerateKey(elliptic.P521(), rand.Reader)\n\tdefault:\n\t\tfmt.Fprintf(os.Stderr, \"Unrecognized elliptic curve: %q\", ecdsaCurve)\n\t\tos.Exit(1)\n\t}\n\treturn priv, err\n}", "func (priv *PrivateKey) derive() (pub *PublicKey) {\n\t/* See Certicom's SEC1 3.2.1, pg.23 */\n\n\t/* Derive public key from Q = d*G */\n\tQ := secp256k1.ScalarBaseMult(priv.D)\n\n\t/* Check that Q is on the curve */\n\tif !secp256k1.IsOnCurve(Q) {\n\t\tpanic(\"Catastrophic math logic failure in public key derivation.\")\n\t}\n\n\tpriv.X = Q.X\n\tpriv.Y = Q.Y\n\n\treturn &priv.PublicKey\n}", "func ECCPub(parms *TPMSECCParms, pub *TPMSECCPoint) (*ECDHPub, error) {\n\tcurve, err := parms.CurveID.Curve()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &ECDHPub{\n\t\tCurve: curve,\n\t\tX: big.NewInt(0).SetBytes(pub.X.Buffer),\n\t\tY: big.NewInt(0).SetBytes(pub.Y.Buffer),\n\t}, nil\n}", "func (ec *ECPoint) ScalarMult(base *ECPoint, k *big.Int) *ECPoint {\n\tec.X, ec.Y = base.Curve.ScalarMult(base.X, base.Y, k.Bytes())\n\tec.Curve = base.Curve\n\tec.checkNil()\n\n\treturn ec\n}", "func newPrivateKey() (crypto.Signer, error) {\n\treturn ecdsa.GenerateKey(ellipticCurve, crand.Reader)\n}", "func generateKeyPair(algo string, ecCurve string) (privateKey interface{}, publicKey interface{}, err error) {\n\n // Make them case-insensitive\n switch strings.ToUpper(algo) {\n // If RSA, generate a pair of RSA keys\n case \"RSA\":\n // rsa.GenerateKey(): https://golang.org/pkg/crypto/rsa/#GenerateKey\n // Return value is of type *rsa.PrivateKey\n privateKey, err = rsa.GenerateKey(rand.Reader, 2048) // by default create a 2048 bit key\n\n // If ECDSA, use a provided curve\n case \"ECDSA\":\n // First check if ecCurve is provided\n if ecCurve == \"\" {\n return nil, nil, errors.New(\"ECDSA needs a curve\")\n }\n // Then generate the key based on the curve\n // Curves: https://golang.org/pkg/crypto/elliptic/#Curve\n // ecdsa.GenerateKey(): https://golang.org/pkg/crypto/ecdsa/#GenerateKey\n // Return value is of type *ecdsa.PrivateKey\n switch strings.ToUpper(ecCurve) {\n case \"P224\":\n privateKey, err = ecdsa.GenerateKey(elliptic.P224(), rand.Reader)\n case \"P256\":\n privateKey, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader)\n case \"P384\":\n \tprivateKey, err = ecdsa.GenerateKey(elliptic.P384(), rand.Reader)\n case \"P521\":\n \tprivateKey, err = ecdsa.GenerateKey(elliptic.P521(), rand.Reader)\n\n // If the curve is invalid\n default:\n return nil, nil, errors.New(\"Unrecognized curve, valid values are P224, P256, P384 and P521\")\n }\n\n // If neither RSA nor ECDSA return an error\n default:\n return nil, nil, errors.New(\"Unrecognized algorithm, valid options are RSA and ECDSA\")\n }\n\n // If we get here, then input parameters have been valid\n // Check if key generation has been successful by checking err\n if err != nil {\n return nil, nil, err\n }\n\n // Exporting the public key (needed later)\n switch tempPrivKey:= privateKey.(type) {\n case *rsa.PrivateKey:\n publicKey = &tempPrivKey.PublicKey\n case *ecdsa.PrivateKey:\n publicKey = &tempPrivKey.PublicKey\n }\n\n return privateKey, publicKey, err // or just return\n}", "func (ec *ecdsa) NewKey(l int, w io.Writer) error {\n\tq, d, err := secp256k1.NewPair()\n\tif err != nil {\n\t\treturn err\n\t}\n\tk := new(sec1.PrivateKey)\n\terr = k.SetCurve(&secp256k1.OID)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = k.SetPoint(q.GetX(), q.GetY())\n\tif err != nil {\n\t\treturn err\n\t}\n\tk.SetGenerator(d)\n\tec.Private = k\n\n\treturn k.Write(w)\n}", "func (p *G2Jac) Add(curve *Curve, a *G2Jac) *G2Jac {\n\t// p is infinity, return a\n\tif p.Z.IsZero() {\n\t\tp.Set(a)\n\t\treturn p\n\t}\n\n\t// a is infinity, return p\n\tif a.Z.IsZero() {\n\t\treturn p\n\t}\n\n\t// get some Element from our pool\n\tvar Z1Z1, Z2Z2, U1, U2, S1, S2, H, I, J, r, V e2\n\n\t// Z1Z1 = a.Z ^ 2\n\tZ1Z1.Square(&a.Z)\n\n\t// Z2Z2 = p.Z ^ 2\n\tZ2Z2.Square(&p.Z)\n\n\t// U1 = a.X * Z2Z2\n\tU1.Mul(&a.X, &Z2Z2)\n\n\t// U2 = p.X * Z1Z1\n\tU2.Mul(&p.X, &Z1Z1)\n\n\t// S1 = a.Y * p.Z * Z2Z2\n\tS1.Mul(&a.Y, &p.Z).\n\t\tMulAssign(&Z2Z2)\n\n\t// S2 = p.Y * a.Z * Z1Z1\n\tS2.Mul(&p.Y, &a.Z).\n\t\tMulAssign(&Z1Z1)\n\n\t// if p == a, we double instead\n\tif U1.Equal(&U2) && S1.Equal(&S2) {\n\t\treturn p.Double()\n\t}\n\n\t// H = U2 - U1\n\tH.Sub(&U2, &U1)\n\n\t// I = (2*H)^2\n\tI.Double(&H).\n\t\tSquare(&I)\n\n\t// J = H*I\n\tJ.Mul(&H, &I)\n\n\t// r = 2*(S2-S1)\n\tr.Sub(&S2, &S1).Double(&r)\n\n\t// V = U1*I\n\tV.Mul(&U1, &I)\n\n\t// res.X = r^2-J-2*V\n\tp.X.Square(&r).\n\t\tSubAssign(&J).\n\t\tSubAssign(&V).\n\t\tSubAssign(&V)\n\n\t// res.Y = r*(V-X3)-2*S1*J\n\tp.Y.Sub(&V, &p.X).\n\t\tMulAssign(&r)\n\tS1.MulAssign(&J).Double(&S1)\n\tp.Y.SubAssign(&S1)\n\n\t// res.Z = ((a.Z+p.Z)^2-Z1Z1-Z2Z2)*H\n\tp.Z.AddAssign(&a.Z)\n\tp.Z.Square(&p.Z).\n\t\tSubAssign(&Z1Z1).\n\t\tSubAssign(&Z2Z2).\n\t\tMulAssign(&H)\n\n\treturn p\n}", "func (ec *EC) BaseMul(x *big.Int) *Point {\n\treturn ec.Mul(x, ec.G)\n}", "func (p *PointProj) Add(p1, p2 *PointProj) *PointProj {\n\n\tvar res PointProj\n\n\tecurve := GetEdwardsCurve()\n\n\tvar A, B, C, D, E, F, G, H, I fr.Element\n\tA.Mul(&p1.Z, &p2.Z)\n\tB.Square(&A)\n\tC.Mul(&p1.X, &p2.X)\n\tD.Mul(&p1.Y, &p2.Y)\n\tE.Mul(&ecurve.D, &C).Mul(&E, &D)\n\tF.Sub(&B, &E)\n\tG.Add(&B, &E)\n\tH.Add(&p1.X, &p1.Y)\n\tI.Add(&p2.X, &p2.Y)\n\tres.X.Mul(&H, &I).\n\t\tSub(&res.X, &C).\n\t\tSub(&res.X, &D).\n\t\tMul(&res.X, &A).\n\t\tMul(&res.X, &F)\n\tmulByA(&C)\n\tC.Neg(&C)\n\tres.Y.Add(&D, &C).\n\t\tMul(&res.Y, &A).\n\t\tMul(&res.Y, &G)\n\tres.Z.Mul(&F, &G)\n\n\tp.Set(&res)\n\treturn p\n}", "func newKeyPair() (ecdsa.PrivateKey, []byte) {\n\tcurve := elliptic.P256()\n\n\tpriKey, err := ecdsa.GenerateKey(curve, rand.Reader)\n\tif err != nil {\n\t\tlog.Panicln(err)\n\t}\n\tpubKey := append(priKey.PublicKey.X.Bytes(), priKey.PublicKey.Y.Bytes()...)\n\n\treturn *priKey, pubKey\n}", "func ToEcdsa(key []byte) *ecdsa.PrivateKey {\n\tecdsaKey := new(ecdsa.PrivateKey)\n\tecdsaKey.PublicKey.Curve = elliptic.P256()\n\tecdsaKey.D = new(big.Int).SetBytes(key)\n\tecdsaKey.PublicKey.X, ecdsaKey.PublicKey.Y = ecdsaKey.PublicKey.Curve.ScalarBaseMult(key)\n\treturn ecdsaKey\n}", "func (csp *impl) getECKey(ski []byte) (pubKey *ecdsa.PublicKey, isPriv bool, err error) {\n\n\tsession := csp.pkcs11Ctx.GetSession()\n\tdefer func() { csp.handleSessionReturn(err, session) }()\n\tisPriv = true\n\t_, err = csp.pkcs11Ctx.FindKeyPairFromSKI(session, ski, privateKeyFlag)\n\tif err != nil {\n\t\tisPriv = false\n\t\tlogger.Debugf(\"Private key not found [%s] for SKI [%s], looking for Public key\", err, hex.EncodeToString(ski))\n\t}\n\n\tpublicKey, err := csp.pkcs11Ctx.FindKeyPairFromSKI(session, ski, publicKeyFlag)\n\tif err != nil {\n\t\treturn nil, false, fmt.Errorf(\"Public key not found [%s] for SKI [%s]\", err, hex.EncodeToString(ski))\n\t}\n\n\tecpt, marshaledOid, err := ecPoint(csp.pkcs11Ctx, session, *publicKey)\n\tif err != nil {\n\t\treturn nil, false, fmt.Errorf(\"Public key not found [%s] for SKI [%s]\", err, hex.EncodeToString(ski))\n\t}\n\n\tcurveOid := new(asn1.ObjectIdentifier)\n\t_, err = asn1.Unmarshal(marshaledOid, curveOid)\n\tif err != nil {\n\t\treturn nil, false, fmt.Errorf(\"Failed Unmarshaling Curve OID [%s]\\n%s\", err.Error(), hex.EncodeToString(marshaledOid))\n\t}\n\n\tcurve := namedCurveFromOID(*curveOid)\n\tif curve == nil {\n\t\treturn nil, false, fmt.Errorf(\"Cound not recognize Curve from OID\")\n\t}\n\tx, y := elliptic.Unmarshal(curve, ecpt)\n\tif x == nil {\n\t\treturn nil, false, fmt.Errorf(\"Failed Unmarshaling Public Key\")\n\t}\n\n\tpubKey = &ecdsa.PublicKey{Curve: curve, X: x, Y: y}\n\treturn pubKey, isPriv, nil\n}", "func (phi *isogeny3) GenerateCurve(p *ProjectivePoint) CurveCoefficientsEquiv {\n\tvar t0, t1, t2, t3, t4 Fp2Element\n\tvar coefEq CurveCoefficientsEquiv\n\tvar K1, K2 = &phi.K1, &phi.K2\n\n\top := phi.Field\n\top.Sub(K1, &p.X, &p.Z) // K1 = XP3 - ZP3\n\top.Square(&t0, K1) // t0 = K1^2\n\top.Add(K2, &p.X, &p.Z) // K2 = XP3 + ZP3\n\top.Square(&t1, K2) // t1 = K2^2\n\top.Add(&t2, &t0, &t1) // t2 = t0 + t1\n\top.Add(&t3, K1, K2) // t3 = K1 + K2\n\top.Square(&t3, &t3) // t3 = t3^2\n\top.Sub(&t3, &t3, &t2) // t3 = t3 - t2\n\top.Add(&t2, &t1, &t3) // t2 = t1 + t3\n\top.Add(&t3, &t3, &t0) // t3 = t3 + t0\n\top.Add(&t4, &t3, &t0) // t4 = t3 + t0\n\top.Add(&t4, &t4, &t4) // t4 = t4 + t4\n\top.Add(&t4, &t1, &t4) // t4 = t1 + t4\n\top.Mul(&coefEq.C, &t2, &t4) // A24m = t2 * t4\n\top.Add(&t4, &t1, &t2) // t4 = t1 + t2\n\top.Add(&t4, &t4, &t4) // t4 = t4 + t4\n\top.Add(&t4, &t0, &t4) // t4 = t0 + t4\n\top.Mul(&t4, &t3, &t4) // t4 = t3 * t4\n\top.Sub(&t0, &t4, &coefEq.C) // t0 = t4 - A24m\n\top.Add(&coefEq.A, &coefEq.C, &t0) // A24p = A24m + t0\n\treturn coefEq\n}", "func New(ctx context.Context, concurrency int) (*Group, context.Context) {\n\tif concurrency < 1 {\n\t\tconcurrency = 1\n\t}\n\n\tparent, ctx := errgroup.WithContext(ctx)\n\treturn &Group{\n\t\tlimiter: make(chan struct{}, concurrency),\n\t\tparent: parent,\n\t\tctx: ctx,\n\t}, ctx\n}", "func NewCurveECDSA() ECDSA {\n\treturn &curveP256{}\n}", "func Add(a, b *ecdsa.PublicKey) *ecdsa.PublicKey {\n\tkey := new(ecdsa.PublicKey)\n\tkey.Curve = Secp256k1()\n\tkey.X, key.Y = Secp256k1().Add(a.X, a.Y, b.X, b.Y)\n\treturn key\n}", "func (r1cs *R1CS) GetCurveID() gurvy.ID {\n\treturn gurvy.BN256\n}", "func (cg *Group) Add(ec *ExpresionChain) {\n\tcg.chains = append(cg.chains, ec)\n}", "func (curve *Curve) ScalarMult(Bx, By *big.Int, k []byte) (*big.Int, *big.Int) {\n\t// We have a slight problem in that the identity of the group (the\n\t// point at infinity) cannot be represented in (x, y) form on a finite\n\t// machine. Thus the standard add/double algorithm has to be tweaked\n\t// slightly: our initial state is not the identity, but x, and we\n\t// ignore the first true bit in |k|. If we don't find any true bits in\n\t// |k|, then we return nil, nil, because we cannot return the identity\n\t// element.\n\n\tBz := new(big.Int).SetInt64(1)\n\tx := Bx\n\ty := By\n\tz := Bz\n\n\tseenFirstTrue := false\n\tfor _, byte := range k {\n\t\tfor bitNum := 0; bitNum < 8; bitNum++ {\n\t\t\tif seenFirstTrue {\n\t\t\t\tx, y, z = curve.doubleJacobian(x, y, z)\n\t\t\t}\n\t\t\tif byte&0x80 == 0x80 {\n\t\t\t\tif !seenFirstTrue {\n\t\t\t\t\tseenFirstTrue = true\n\t\t\t\t} else {\n\t\t\t\t\tx, y, z = curve.addJacobian(Bx, By, Bz, x, y, z)\n\t\t\t\t}\n\t\t\t}\n\t\t\tbyte <<= 1\n\t\t}\n\t}\n\n\tif !seenFirstTrue {\n\t\treturn nil, nil\n\t}\n\n\treturn curve.affineFromJacobian(x, y, z)\n}", "func PeelCentralCurve() func(x float64) model3d.Coord3D {\n\tplaneCurve := PeelCurve()\n\tzCurve := PeelHeight()\n\treturn func(x float64) model3d.Coord3D {\n\t\treturn model3d.XYZ(x, model2d.CurveEvalX(planeCurve, x), model2d.CurveEvalX(zCurve, x))\n\t}\n}", "func GenerateGroup(r io.Reader) (*PrivateKey, error) {\n\tpriv := new(PrivateKey)\n\tpriv.Group = new(Group)\n\tvar err error\n\n\tif _, priv.g1, err = bn256.RandomG1(r); err != nil {\n\t\treturn nil, err\n\t}\n\tif _, priv.g2, err = bn256.RandomG2(r); err != nil {\n\t\treturn nil, err\n\t}\n\tif _, priv.h, err = bn256.RandomG1(r); err != nil {\n\t\treturn nil, err\n\t}\n\tif priv.xi1, err = randomZp(r); err != nil {\n\t\treturn nil, err\n\t}\n\tif priv.xi2, err = randomZp(r); err != nil {\n\t\treturn nil, err\n\t}\n\n\tz0 := new(big.Int).ModInverse(priv.xi1, bn256.Order)\n\tpriv.u = new(bn256.G1).ScalarMult(priv.h, z0)\n\n\tz0.ModInverse(priv.xi2, bn256.Order)\n\tpriv.v = new(bn256.G1).ScalarMult(priv.h, z0)\n\n\tpriv.gamma, err = randomZp(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpriv.w = new(bn256.G2).ScalarMult(priv.g2, priv.gamma)\n\tpriv.precompute()\n\n\treturn priv, nil\n}", "func (c *CurveOperations) CalcCurveParamsEquiv4(cparams *ProjectiveCurveParameters) CurveCoefficientsEquiv {\n\tvar coefEq CurveCoefficientsEquiv\n\tvar op = c.Params.Op\n\n\top.Add(&coefEq.C, &cparams.C, &cparams.C)\n\t// A24p = A+2C\n\top.Add(&coefEq.A, &cparams.A, &coefEq.C)\n\t// C24 = 4*C\n\top.Add(&coefEq.C, &coefEq.C, &coefEq.C)\n\treturn coefEq\n}", "func NewGroupClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *GroupClient {\n\tcp := arm.ClientOptions{}\n\tif options != nil {\n\t\tcp = *options\n\t}\n\tif len(cp.Host) == 0 {\n\t\tcp.Host = arm.AzurePublicCloud\n\t}\n\treturn &GroupClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)}\n}", "func ScalarBaseMult(k *big.Int) *ecdsa.PublicKey {\n\tkey := new(ecdsa.PublicKey)\n\tkey.Curve = Secp256k1()\n\tkey.X, key.Y = Secp256k1().ScalarBaseMult(k.Bytes())\n\treturn key\n}", "func PrivatecaAlphaCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveToProto(o *alpha.CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) *alphapb.PrivatecaAlphaCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve {\n\tif o == nil {\n\t\treturn nil\n\t}\n\tp := &alphapb.PrivatecaAlphaCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{}\n\tp.SetSignatureAlgorithm(PrivatecaAlphaCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnumToProto(o.SignatureAlgorithm))\n\treturn p\n}", "func GenECCKey(curve int, password string, kmPubFile, kmPrivFile, bpmPubFile, bpmPrivFile *os.File) error {\n\tvar ellCurve elliptic.Curve\n\tswitch curve {\n\tcase 224:\n\t\tellCurve = elliptic.P224()\n\tcase 256:\n\t\tellCurve = elliptic.P256()\n\tdefault:\n\t\treturn fmt.Errorf(\"Selected ECC algorithm not supported\")\n\t}\n\tkey, err := ecdsa.GenerateKey(ellCurve, rand.Reader)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := writePrivKeyToFile(key, kmPrivFile, password); err != nil {\n\t\treturn err\n\t}\n\n\tif err := writePubKeyToFile(key.Public(), kmPubFile); err != nil {\n\t\treturn err\n\t}\n\n\tkey, err = ecdsa.GenerateKey(ellCurve, rand.Reader)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err := writePrivKeyToFile(key, bpmPrivFile, password); err != nil {\n\t\treturn err\n\t}\n\n\tif err := writePubKeyToFile(key.Public(), bpmPubFile); err != nil {\n\t\treturn err\n\n\t}\n\treturn nil\n}", "func GenerateKey(c elliptic.Curve, rand io.Reader) (*PrivateKey, error)", "func New() (*KeyPair, error) {\n\tp, v, err := p2pCrypto.GenerateKeyPairWithReader(p2pCrypto.Ed25519, 256, rand.Reader)\n\tif err == nil {\n\t\treturn &KeyPair{privKey: p, pubKey: v}, nil\n\t}\n\treturn nil, err\n}", "func PointMul(group Group, n Bignum, P Point, m Bignum, ctx Ctx) Point {\n\tresult := NewPoint(group)\n\tC.EC_POINT_mul(group, result, n, P, m, ctx)\n\treturn result\n}", "func (self *Graphics) DrawEllipse(x int, y int, width int, height int) *Graphics{\n return &Graphics{self.Object.Call(\"drawEllipse\", x, y, width, height)}\n}", "func NewECPoint(x, y *big.Int, curve elliptic.Curve) *ECPoint {\n\tec := ECPoint{}\n\tec.Curve = curve\n\tec.X = new(big.Int).Set(x)\n\tec.Y = new(big.Int).Set(y)\n\n\treturn &ec\n}", "func (c curve) ScalarBaseMult(k []byte) (*big.Int, *big.Int) {\n\treturn c.ScalarMult(c.Params().Gx, c.Params().Gy, k)\n}", "func (ec *EllipticCurve) Set(value string) error {\n\tswitch strings.ToUpper(value) {\n\tcase strEccP521, \"P-521\":\n\t\t*ec = EllipticCurveP521\n\tcase strEccP384, \"P-384\":\n\t\t*ec = EllipticCurveP384\n\tcase strEccP256, \"P-256\":\n\t\t*ec = EllipticCurveP256\n\tcase strEccED25519:\n\t\t*ec = EllipticCurveED25519\n\tdefault:\n\t\t*ec = EllipticCurveDefault\n\t}\n\n\treturn nil\n}", "func ExponentiateKey(s beam.Scope, col beam.PCollection, secret string, publicKey *pb.ElGamalPublicKey) beam.PCollection {\n\ts = s.Scope(\"ExponentiateKey\")\n\treturn beam.ParDo(s, &exponentiateKeyFn{Secret: secret, ElGamalPublicKey: publicKey}, col)\n}", "func ProtoToPrivatecaAlphaCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(p *alphapb.PrivatecaAlphaCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) *alpha.CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve {\n\tif p == nil {\n\t\treturn nil\n\t}\n\tobj := &alpha.CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{\n\t\tSignatureAlgorithm: ProtoToPrivatecaAlphaCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum(p.GetSignatureAlgorithm()),\n\t}\n\treturn obj\n}", "func ScalarMultH(scalar *Key) (result *Key) {\n\th := new(ExtendedGroupElement)\n\th.FromBytes(&H)\n\tresultPoint := new(ProjectiveGroupElement)\n\tGeScalarMult(resultPoint, scalar, h)\n\tresult = new(Key)\n\tresultPoint.ToBytes(result)\n\treturn\n}", "func New(w io.Writer, width, height float64) *Renderer {\n\tfmt.Fprintf(w, \"%%!PS-Adobe-3.0 EPSF-3.0\\n%%%%BoundingBox: 0 0 %v %v\\n\", dec(width), dec(height))\n\tfmt.Fprintf(w, psEllipseDef)\n\t// TODO: (EPS) generate and add preview\n\n\treturn &Renderer{\n\t\tw: w,\n\t\twidth: width,\n\t\theight: height,\n\t\tcolor: canvas.Black,\n\t}\n}", "func ScalarMult(k *big.Int, B *ecdsa.PublicKey) *ecdsa.PublicKey {\n\tkey := new(ecdsa.PublicKey)\n\tkey.Curve = Secp256k1()\n\tkey.X, key.Y = Secp256k1().ScalarMult(B.X, B.Y, k.Bytes())\n\treturn key\n}", "func (p *Provider) Public() *Provider {\n\tif p.key == nil {\n\t\treturn p\n\t}\n\treturn &Provider{chain: p.chain, key: nil}\n}", "func NewKeyPair() (ecdsa.PrivateKey, []byte) {\n\tellipticCurve := EllipticCurve()\n\n\tprivateKey, err := ecdsa.GenerateKey(ellipticCurve, rand.Reader)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tX := privateKey.PublicKey.X.Bytes()\n\tY := privateKey.PublicKey.Y.Bytes()\n\t//fmt.Println(len(X), X)\n\t//fmt.Println(len(Y), Y)\n\tpublicKey := append(\n\t\tX, // 32 bytes (P256)\n\t\tY..., // 32 bytes (P256)\n\t) // 64 bytes => 64 * 8 bits = 512 bits (perchè usiamo P256 o secp256k)\n\treturn *privateKey, publicKey\n}", "func NewPoint(group Group) Point {\n\treturn C.EC_POINT_new(group)\n}", "func New(cfg hotstuff.Config) (hotstuff.Signer, hotstuff.Verifier) {\n\tec := &ecdsaCrypto{cfg}\n\treturn ec, ec\n}", "func NewSubGroup(rootOfUnity curve.Element, maxOrderRoot uint, m int) *SubGroup {\n\tsubGroup := &SubGroup{}\n\tx := nextPowerOfTwo(uint(m))\n\n\t// maxOderRoot is the largest power-of-two order for any element in the field\n\t// set subGroup.GeneratorSqRt = rootOfUnity^(2^(maxOrderRoot-log(x)-1))\n\t// to this end, compute expo = 2^(maxOrderRoot-log(x)-1)\n\tlogx := uint(bits.TrailingZeros(x))\n\tif logx > maxOrderRoot-1 {\n\t\tpanic(\"m is too big: the required root of unity does not exist\")\n\t}\n\texpo := uint64(1 << (maxOrderRoot - logx - 1))\n\tsubGroup.GeneratorSqRt.Exp(rootOfUnity, expo)\n\n\t// Generator = GeneratorSqRt^2 has order x\n\tsubGroup.Generator.Mul(&subGroup.GeneratorSqRt, &subGroup.GeneratorSqRt) // order x\n\tsubGroup.Cardinality = int(x)\n\tsubGroup.GeneratorSqRtInv.Inverse(&subGroup.GeneratorSqRt)\n\tsubGroup.GeneratorInv.Inverse(&subGroup.Generator)\n\tsubGroup.CardinalityInv.SetUint64(uint64(x)).Inverse(&subGroup.CardinalityInv)\n\n\treturn subGroup\n}", "func New(opt ...option) *Group {\n\tr := &Group{wait_register: map[int]bool{}}\n\tfor _, o := range opt {\n\t\to(r)\n\t}\n\tif r.CancelFunc == nil {\n\t\tWith_cancel_nowait(nil)(r)\n\t}\n\tif r.parent == nil {\n\t\tr.local_wg = &sync.WaitGroup{}\n\t}\n\tif r.sig != nil {\n\t\tr.wg().Add(1)\n\t\tgo func() {\n\t\t\tdefer r.wg().Done()\n\t\t\tch := make(chan os.Signal, 1)\n\t\t\tdefer close(ch)\n\t\t\tsignal.Notify(ch, r.sig...)\n\t\t\tdefer signal.Stop(ch)\n\t\t\tselect {\n\t\t\tcase <-r.Done():\n\t\t\tcase <-ch:\n\t\t\t\tr.Interrupted = true\n\t\t\t\tfmt.Fprintf(os.Stderr, \"%v\", r.line_end)\n\t\t\t}\n\t\t\tr.Cancel()\n\t\t}()\n\t}\n\treturn r\n}", "func (*FactorySECP256K1R) NewPrivateKey() (PrivateKey, error) {\n\tk, err := secp256k1.GeneratePrivateKey()\n\treturn &PrivateKeySECP256K1R{sk: k}, err\n}", "func generateKey(curve elliptic.Curve) (private []byte, public []byte, err error) {\n\tvar x, y *big.Int\n\tprivate, x, y, err = elliptic.GenerateKey(curve, rand.Reader)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tpublic = elliptic.Marshal(curve, x, y)\n\treturn\n}", "func (x *Ed25519Credentials) PrivateKey() PrivateKey {\n\n\treturn PrivateKey{\n\t\tAlgorithm: AlgorithmEd25519,\n\t\tPrivate: base64.URLEncoding.EncodeToString(x.Private[:]),\n\t}\n\n}", "func New(privKey *ecdsa.PrivateKey, alg, kid string) *Signer {\n\treturn &Signer{privateKey: privKey, kid: kid, alg: alg}\n}", "func toECDSA(d []byte, strict bool) (*ecdsa.PrivateKey, error) {\n\tpriv := new(ecdsa.PrivateKey)\n\tpriv.PublicKey.Curve = S256()\n\tif strict && 8*len(d) != priv.Params().BitSize {\n\t\treturn nil, fmt.Errorf(\"invalid length, need %d bits\", priv.Params().BitSize)\n\t}\n\tpriv.D = new(big.Int).SetBytes(d)\n\n\t// The priv.D must < N\n\tif priv.D.Cmp(secp256k1N) >= 0 {\n\t\treturn nil, fmt.Errorf(\"invalid private key, >=N\")\n\t}\n\t// The priv.D must not be zero or negative.\n\tif priv.D.Sign() <= 0 {\n\t\treturn nil, fmt.Errorf(\"invalid private key, zero or negative\")\n\t}\n\n\tpriv.PublicKey.X, priv.PublicKey.Y = priv.PublicKey.Curve.ScalarBaseMult(d)\n\tif priv.PublicKey.X == nil {\n\t\treturn nil, errors.New(\"invalid private key\")\n\t}\n\treturn priv, nil\n}", "func (in *EndpointGroupParameters) DeepCopy() *EndpointGroupParameters {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(EndpointGroupParameters)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "func getECDSAPublicKey(rawPubKey []byte) (*ecdsa.PublicKey, error) {\n\ttag := rawPubKey[0]\n\tuncompressed := rawPubKey[2]\n\tif tag != 0x04 || uncompressed != 0x04 {\n\t\treturn nil, errors.New(\"Invalid public key.\")\n\t}\n\tlength := int(rawPubKey[1]) - 1\n\tif len(rawPubKey) != (3 + length) {\n\t\treturn nil, errors.New(\"Invalid public key.\")\n\t}\n\tx := new(big.Int).SetBytes(rawPubKey[3 : 3+(length/2)])\n\ty := new(big.Int).SetBytes(rawPubKey[3+(length/2):])\n\tecdsaPubKey := ecdsa.PublicKey{Curve: elliptic.P256(), X: x, Y: y}\n\treturn &ecdsaPubKey, nil\n}", "func (x *ed25519_t) NewSigner(key PrivateKey) (Credentials, error) {\n\n\tvar credentials Ed25519Credentials\n\tvar err error\n\n\terr = credentials.SetPrivateKey(key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &credentials, nil\n\n}", "func TestScalarMult(t *testing.T) {\n\tsecp256k1 := newECDSASecp256k1().curve\n\tp256 := newECDSAP256().curve\n\tgenericMultTests := []struct {\n\t\tcurve elliptic.Curve\n\t\tPx string\n\t\tPy string\n\t\tk string\n\t\tQx string\n\t\tQy string\n\t}{\n\t\t{\n\t\t\tsecp256k1,\n\t\t\t\"858a2ea2498449acf531128892f8ee5eb6d10cfb2f7ebfa851def0e0d8428742\",\n\t\t\t\"015c59492d794a4f6a3ab3046eecfc85e223d1ce8571aa99b98af6838018286e\",\n\t\t\t\"6e37a39c31a05181bf77919ace790efd0bdbcaf42b5a52871fc112fceb918c95\",\n\t\t\t\"fea24b9a6acdd97521f850e782ef4a24f3ef672b5cd51f824499d708bb0c744d\",\n\t\t\t\"5f0b6db1a2c851cb2959fab5ed36ad377e8b53f1f43b7923f1be21b316df1ea1\",\n\t\t},\n\t\t{\n\t\t\tp256,\n\t\t\t\"fa1a85f1ae436e9aa05baabe60eb83b2d7ff52e5766504fda4e18d2d25887481\",\n\t\t\t\"f7cc347e1ac53f6720ffc511bfb23c2f04c764620be0baf8c44313e92d5404de\",\n\t\t\t\"6e37a39c31a05181bf77919ace790efd0bdbcaf42b5a52871fc112fceb918c95\",\n\t\t\t\"28a27fc352f315d5cc562cb0d97e5882b6393fd6571f7d394cc583e65b5c7ffe\",\n\t\t\t\"4086d17a2d0d9dc365388c91ba2176de7acc5c152c1a8d04e14edc6edaebd772\",\n\t\t},\n\t}\n\n\tbaseMultTests := []struct {\n\t\tcurve elliptic.Curve\n\t\tk string\n\t\tQx string\n\t\tQy string\n\t}{\n\t\t{\n\t\t\tsecp256k1,\n\t\t\t\"6e37a39c31a05181bf77919ace790efd0bdbcaf42b5a52871fc112fceb918c95\",\n\t\t\t\"36f292f6c287b6e72ca8128465647c7f88730f84ab27a1e934dbd2da753930fa\",\n\t\t\t\"39a09ddcf3d28fb30cc683de3fc725e095ec865c3d41aef6065044cb12b1ff61\",\n\t\t},\n\t\t{\n\t\t\tp256,\n\t\t\t\"6e37a39c31a05181bf77919ace790efd0bdbcaf42b5a52871fc112fceb918c95\",\n\t\t\t\"78a80dfe190a6068be8ddf05644c32d2540402ffc682442f6a9eeb96125d8681\",\n\t\t\t\"3789f92cf4afabf719aaba79ecec54b27e33a188f83158f6dd15ecb231b49808\",\n\t\t},\n\t}\n\n\tfor _, test := range genericMultTests {\n\t\tPx, _ := new(big.Int).SetString(test.Px, 16)\n\t\tPy, _ := new(big.Int).SetString(test.Py, 16)\n\t\tk, _ := new(big.Int).SetString(test.k, 16)\n\t\tQx, _ := new(big.Int).SetString(test.Qx, 16)\n\t\tQy, _ := new(big.Int).SetString(test.Qy, 16)\n\t\tRx, Ry := test.curve.ScalarMult(Px, Py, k.Bytes())\n\t\tassert.Equal(t, Rx.Cmp(Qx), 0)\n\t\tassert.Equal(t, Ry.Cmp(Qy), 0)\n\t}\n\tfor _, test := range baseMultTests {\n\t\tk, _ := new(big.Int).SetString(test.k, 16)\n\t\tQx, _ := new(big.Int).SetString(test.Qx, 16)\n\t\tQy, _ := new(big.Int).SetString(test.Qy, 16)\n\t\t// base mult\n\t\tRx, Ry := test.curve.ScalarBaseMult(k.Bytes())\n\t\tassert.Equal(t, Rx.Cmp(Qx), 0)\n\t\tassert.Equal(t, Ry.Cmp(Qy), 0)\n\t\t// generic mult with base point\n\t\tPx := new(big.Int).Set(test.curve.Params().Gx)\n\t\tPy := new(big.Int).Set(test.curve.Params().Gy)\n\t\tRx, Ry = test.curve.ScalarMult(Px, Py, k.Bytes())\n\t\tassert.Equal(t, Rx.Cmp(Qx), 0)\n\t\tassert.Equal(t, Ry.Cmp(Qy), 0)\n\t}\n}", "func simpleEC(this js.Value, inputs []js.Value) interface{} {\n\tvar suite = suites.MustFind(\"Ed25519\")\n\tvar args map[string]interface{}\n\tjson.Unmarshal([]byte(inputs[0].String()), &args)\n\tscalar := suite.Scalar()\n\tscalarB, _ := base64.StdEncoding.DecodeString(args[\"scalar\"].(string))\n\tscalar.UnmarshalBinary(scalarB)\n\tvar resultB []byte\n\tfor i := 0; i < 1; i++ {\n\t\tresultB, _ = suite.Point().Mul(scalar, nil).MarshalBinary()\n\t}\n\targs[\"result\"] = base64.StdEncoding.EncodeToString(resultB)\n\t//args[\"resultTest\"] = result.String()\n\targs[\"Accepted\"] = \"true\"\n\treturn args\n}", "func (lib *PKCS11Lib) exportECDSAPublicKey(session pkcs11.SessionHandle, pubHandle pkcs11.ObjectHandle) (crypto.PublicKey, error) {\n\tvar err error\n\tvar attributes []*pkcs11.Attribute\n\tvar pub ecdsa.PublicKey\n\ttemplate := []*pkcs11.Attribute{\n\t\tpkcs11.NewAttribute(pkcs11.CKA_ECDSA_PARAMS, nil),\n\t\tpkcs11.NewAttribute(pkcs11.CKA_EC_POINT, nil),\n\t}\n\tif attributes, err = lib.Ctx.GetAttributeValue(session, pubHandle, template); err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\tif pub.Curve, err = unmarshalEcParams(attributes[0].Value); err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\tif pub.X, pub.Y, err = unmarshalEcPoint(attributes[1].Value, pub.Curve); err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\treturn &pub, nil\n}", "func Encrypt(pub *ecdsa.PublicKey, in []byte) (out []byte, err error) {\n\tephemeral, err := ecdsa.GenerateKey(Curve(), rand.Reader)\n\tif err != nil {\n\t\treturn\n\t}\n\tx, _ := pub.Curve.ScalarMult(pub.X, pub.Y, ephemeral.D.Bytes())\n\tif x == nil {\n\t\treturn nil, errors.New(\"Failed to generate encryption key\")\n\t}\n\tshared := sha256.Sum256(x.Bytes())\n\tiv, err := symcrypt.MakeRandom(16)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tpaddedIn := padding.AddPadding(in)\n\tct, err := symcrypt.EncryptCBC(paddedIn, iv, shared[:16])\n\tif err != nil {\n\t\treturn\n\t}\n\n\tephPub := elliptic.Marshal(pub.Curve, ephemeral.PublicKey.X, ephemeral.PublicKey.Y)\n\tout = make([]byte, 1+len(ephPub)+16)\n\tout[0] = byte(len(ephPub))\n\tcopy(out[1:], ephPub)\n\tcopy(out[1+len(ephPub):], iv)\n\tout = append(out, ct...)\n\n\th := hmac.New(sha1.New, shared[16:])\n\th.Write(iv)\n\th.Write(ct)\n\tout = h.Sum(out)\n\treturn\n}", "func (g *G1) Double() {\n\t// Reference:\n\t// \"Complete addition formulas for prime order elliptic curves\" by\n\t// Costello-Renes-Batina. [Alg.9] (eprint.iacr.org/2015/1060).\n\tvar R G1\n\tX, Y, Z := &g.x, &g.y, &g.z\n\tX3, Y3, Z3 := &R.x, &R.y, &R.z\n\tvar f0, f1, f2 ff.Fp\n\tt0, t1, t2 := &f0, &f1, &f2\n\t_3B := &g1Params._3b\n\tt0.Sqr(Y) // 1. t0 = Y * Y\n\tZ3.Add(t0, t0) // 2. Z3 = t0 + t0\n\tZ3.Add(Z3, Z3) // 3. Z3 = Z3 + Z3\n\tZ3.Add(Z3, Z3) // 4. Z3 = Z3 + Z3\n\tt1.Mul(Y, Z) // 5. t1 = Y * Z\n\tt2.Sqr(Z) // 6. t2 = Z * Z\n\tt2.Mul(_3B, t2) // 7. t2 = b3 * t2\n\tX3.Mul(t2, Z3) // 8. X3 = t2 * Z3\n\tY3.Add(t0, t2) // 9. Y3 = t0 + t2\n\tZ3.Mul(t1, Z3) // 10. Z3 = t1 * Z3\n\tt1.Add(t2, t2) // 11. t1 = t2 + t2\n\tt2.Add(t1, t2) // 12. t2 = t1 + t2\n\tt0.Sub(t0, t2) // 13. t0 = t0 - t2\n\tY3.Mul(t0, Y3) // 14. Y3 = t0 * Y3\n\tY3.Add(X3, Y3) // 15. Y3 = X3 + Y3\n\tt1.Mul(X, Y) // 16. t1 = X * Y\n\tX3.Mul(t0, t1) // 17. X3 = t0 * t1\n\tX3.Add(X3, X3) // 18. X3 = X3 + X3\n\t*g = R\n}", "func (pk *ECPublicKey) toECDSA() *ecdsa.PublicKey {\n\tecdsaPub := new(ecdsa.PublicKey)\n\tecdsaPub.Curve = pk.Curve\n\tecdsaPub.X = pk.X\n\tecdsaPub.Y = pk.Y\n\n\treturn ecdsaPub\n}", "func New() *backend_bn256.R1CS {\n\t// create root constraint system\n\tcircuit := frontend.New()\n\n\t// declare secret and public inputs\n\tpreImage := circuit.SECRET_INPUT(\"pi\")\n\thash := circuit.PUBLIC_INPUT(\"h\")\n\n\t// hash function\n\tmimc, _ := mimc.NewMiMCGadget(\"seed\", gurvy.BN256)\n\n\t// specify constraints\n\t// mimc(preImage) == hash\n\tcircuit.MUSTBE_EQ(hash, mimc.Hash(&circuit, preImage))\n\n\tr1cs := backend_bn256.New(&circuit)\n\n\treturn &r1cs\n}", "func (c *Curve) NewPoint(x, y float64) (CurvePoint, error) {\n\n\tvar point CurvePoint\n\n\tif !c.IsPointOnCurve(x, y) {\n\t\terr := fmt.Errorf(\"Point (%f, %f) is not on y^2 = x^3 + %fx + %f\", x, y, c.a, c.b)\n\t\treturn point, err\n\t}\n\n\tpoint.x = x\n\tpoint.y = y\n\tpoint.order = -1\n\tpoint.curve = c\n\n\treturn point, nil\n}", "func (c *container) Ellipse(cx, cy, rx, ry float64) *Ellipse {\n\te := &Ellipse{Cx: cx, Cy: cy, Rx: rx, Ry: ry}\n\tc.contents = append(c.contents, e)\n\n\treturn e\n}", "func New(ctx context.Context) *Group {\n\t// Monitor goroutine context and cancelation.\n\tmctx, cancel := context.WithCancel(ctx)\n\n\tg := &Group{\n\t\tctx: ctx,\n\t\tcancel: cancel,\n\n\t\taddC: make(chan struct{}),\n\t\tlenC: make(chan int),\n\t}\n\n\tg.wg.Add(1)\n\tgo func() {\n\t\tdefer g.wg.Done()\n\t\tg.monitor(mctx)\n\t}()\n\n\treturn g\n}" ]
[ "0.6798301", "0.6065067", "0.5757176", "0.56906825", "0.56289303", "0.54817134", "0.5463004", "0.5415355", "0.539792", "0.53937465", "0.5361424", "0.5323893", "0.5249899", "0.51688224", "0.50669473", "0.5043877", "0.50011253", "0.49452612", "0.49054405", "0.48807684", "0.47987887", "0.47651106", "0.47571173", "0.4744629", "0.47287554", "0.4727858", "0.47117567", "0.46565667", "0.46432996", "0.4636588", "0.46358663", "0.45650247", "0.4564723", "0.4525633", "0.45005924", "0.4498344", "0.4489864", "0.4486951", "0.44715083", "0.4471491", "0.44631237", "0.4427965", "0.44210693", "0.4408045", "0.44052696", "0.43887824", "0.43758488", "0.43751046", "0.4370899", "0.4367349", "0.43654534", "0.4355001", "0.43387482", "0.43333298", "0.43047076", "0.43009183", "0.42848307", "0.42815778", "0.42814973", "0.42769006", "0.42539665", "0.42528844", "0.42352763", "0.4225302", "0.42237338", "0.42098147", "0.41796428", "0.41752842", "0.41752765", "0.41746128", "0.4167619", "0.41669697", "0.415623", "0.41492134", "0.41416645", "0.41411176", "0.41401213", "0.41328403", "0.41178867", "0.4115851", "0.4112761", "0.41110083", "0.41101888", "0.40954947", "0.4090991", "0.40839395", "0.40745997", "0.40582994", "0.40553132", "0.4055145", "0.40545356", "0.4050158", "0.40408683", "0.40389386", "0.40383673", "0.4037078", "0.40365073", "0.40314084", "0.4026407", "0.40232432" ]
0.7203198
0
root mustn't be null return maximum sum, maximum sum from root
func helper(root *TreeNode) (int, int) { maxFromRoot, max, maxThroughRoot := root.Val, root.Val, root.Val if root.Left != nil { leftMax, leftMaxFromRoot := helper(root.Left) if leftMaxFromRoot+root.Val > maxFromRoot { maxFromRoot = leftMaxFromRoot + root.Val } if leftMaxFromRoot > 0 { maxThroughRoot += leftMaxFromRoot } if leftMax > max { max = leftMax } } if root.Right != nil { rightMax, rightMaxFromRoot := helper(root.Right) if rightMaxFromRoot+root.Val > maxFromRoot { maxFromRoot = rightMaxFromRoot + root.Val } if rightMaxFromRoot > 0 { maxThroughRoot += rightMaxFromRoot } if rightMax > max { max = rightMax } } if maxThroughRoot > max { max = maxThroughRoot } return max, maxFromRoot }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func maxPathSum(root *TreeNode) int {\n\treturn max(mps(root))\n}", "func (tree *Tree) MaxSum() int {\n\tleftSum := tree.sumLeft(tree.root.left)\n\trightSum := tree.sumRight(tree.root.right)\n\tfmt.Printf(\"L/R and max: %d %d %d\\n\", leftSum, rightSum, max(leftSum, rightSum) + tree.root.data)\n\treturn max(leftSum, rightSum) + tree.root.data\n}", "func maxPathSum(root *TreeNode) int {\n\t_, max := _maxPathSum(root)\n\treturn max\n}", "func (tree *Tree23) max(t TreeNodeIndex) float64 {\n\tif tree.IsLeaf(t) {\n\t\treturn tree.treeNodes[t].elem.ExtractValue()\n\t}\n\tc := tree.treeNodes[t].cCount - 1\n\treturn tree.treeNodes[t].children[c].maxChild\n}", "func findMax(sum map[int64]int64) int64 {\n\tdx := int64(0)\n\n\tfor _, v := range sum {\n\t\tdx = int64(math.Max(float64(dx), float64(v)))\n\t}\n\treturn dx\n}", "func GetMax(root *Node) *Node {\n\tif root == nil || root.right == nil {\n\t\treturn root\n\t}\n\treturn GetMax(root.right)\n}", "func (bst *BinarySearch) Max() (int, error) {\n\tbst.lock.RLock()\n\tdefer bst.lock.RUnlock()\n\n\tn := bst.root\n\tif n == nil {\n\t\treturn 0, fmt.Errorf(\"max: no nodes exist in tree\")\n\t}\n\tfor {\n\t\tif n.right == nil {\n\t\t\treturn n.value, nil\n\t\t}\n\t\tn = n.right\n\t}\n}", "func MaxPathSum(tree *BinaryTree) int {\n\tconst MinInt = -int(^uint(0)>>1) - 1\n\tresult := MinInt\n\tmaxPathSum(tree, &result)\n\treturn result\n}", "func maxPathSum140II(root *TreeNode) int {\n\tmax := new(int)\n\t*max = math.MinInt64\n\thelper140II(root, max)\n\treturn *max\n}", "func rob(root *TreeNode) int {\n\tif root == nil {\n\t\treturn 0\n\t}\n\tval1 := root.Val\n\tif root.Left != nil {\n\t\tval1 += rob(root.Left.Left) + rob(root.Left.Right)\n\t}\n\tif root.Right != nil {\n\t\tval1 += rob(root.Right.Left) + rob(root.Right.Right)\n\t}\n\tval2 := rob(root.Left) + rob(root.Right)\n\treturn Max(val1, val2)\n}", "func maxSubsetSum(arr []int32) int32 {\n\t// Check if the array contains any element\n\t// The sum of 0 subset is 0\n\tif len(arr) == 0 {\n\t\treturn int32(0)\n\t}\n\n\t// Check if the array contains only 1 element\n\t// If yes, return the first element\n\tarr[0] = int32(math.Max(float64(0), float64(arr[0])))\n\tif len(arr) == 1 {\n\t\treturn arr[0]\n\t}\n\n\t// At index 1, the max value could be at index 0 or\n\t// at index 1 itself\n\tarr[1] = int32(math.Max(float64(arr[0]), float64(arr[1])))\n\n\t// Loop for the length of the array but start at index 2\n\tfor index := 2; index < len(arr); index++ {\n\n\t\t// At index 2, calculate which is greater\n\t\t// Previous value at current index - 1 or current value plus previous value at current index - 2\n\t\t// That way, at each iteration we keep track of current max value that are stored at current index - 1\n\t\tarr[index] = int32(math.Max(float64(arr[index-1]), float64(arr[index-2]+arr[index])))\n\t}\n\n\t// After the sum, we keep the max value at last index\n\t// Return it\n\treturn arr[len(arr)-1]\n}", "func findBottomLeftValue(root *TreeNode) int {\n\tqueue := []*TreeNode{root}\n\tvar sum int\n\tfor len(queue) > 0 {\n\t\tcurs := queue\n\t\tif len(queue) > 0 {\n\t\t\tsum = queue[0].Val\n\t\t}\n\t\tqueue = make([]*TreeNode, 0)\n\t\tfor _, cur := range curs {\n\t\t\tif cur.Left != nil {\n\t\t\t\tqueue = append(queue, cur.Left)\n\t\t\t}\n\t\t\tif cur.Right != nil {\n\t\t\t\tqueue = append(queue, cur.Right)\n\t\t\t}\n\t\t}\n\t}\n\treturn sum\n}", "func maxPathSum140I(root *TreeNode) int {\n\tmax := new(int)\n\t*max = math.MinInt64\n\thelper140I(root, 0, max)\n\treturn *max\n}", "func getBestSum(max int, cnt int, m []int) int {\n\tif len(m) < cnt {\n\t\treturn -1\n\t}\n\tvar cntCombs = countCombinations(len(m), cnt)\n\tvar sums []int\n\tfor i := 0; i < cntCombs; i++ {\n\t\tsums = append(sums, getSumsOfComb(i, cnt, m))\n\t}\n\tsort.Ints(sums)\n\n\tif sums[0] > max {\n\t\treturn -1\n\t}\n\n\tfor i := 0; i < len(sums); i++ {\n\t\tif sums[i] > max && i > 0 {\n\t\t\treturn sums[i-1]\n\t\t}\n\t\tif sums[i] > max && i == 0 {\n\t\t\treturn sums[i]\n\t\t}\n\t}\n\n\treturn sums[len(sums)-1]\n}", "func (tree *RedBlack[K, V]) Max() (v alg.Pair[K, V], ok bool) {\n\tif max := tree.root.max(); max != nil {\n\t\treturn alg.Two(max.key, max.value), true\n\t}\n\treturn\n}", "func (st *RedBlackBST) max(x *RedBlackBSTNode) *RedBlackBSTNode {\n\tif x.right == nil {\n\t\treturn x\n\t}\n\treturn st.max(x.right)\n}", "func (t *RbTree[K, V]) Last() *Node[K, V] {\n\tif t.root == nil {\n\t\treturn nil\n\t}\n\treturn maximum(t.root)\n}", "func Solution(root *Tree) int {\n\tif root == nil {\n\t\treturn -1\n\t}\n\treturn max(Solution(root.L), Solution(root.R)) + 1\n}", "func (n *Node) findMax (parent *Node) (*Node, *Node) {\n \tif n.Right == nil {\n \t\treturn n, parent\n \t}\n\treturn n.Right.findMax(n)\n}", "func Solution(A []int) int {\n\t// write your code in Go 1.4\n\tcurrentSum := A[0]\n\tmax := A[0]\n\n\tfor i := 1; i < len(A); i++ {\n\t\tif currentSum < 0 {\n\t\t\tcurrentSum = A[i]\n\t\t} else {\n\t\t\tcurrentSum += A[i]\n\t\t}\n\t\tif max < currentSum {\n\t\t\tmax = currentSum\n\t\t}\n\t}\n\treturn max\n\n}", "func (s *Stat) GetMax() float64 {\n\tif s.n <= 0 {\n\t\treturn 0.0\n\t}\n\treturn s.max\n}", "func (t *BinarySearchTree) FindMax() int {\n\tnode := t.root\n\tfor {\n\t\tif node.right != nil {\n\t\t\tnode = node.right\n\t\t} else {\n\t\t\treturn node.data\n\t\t}\n\t}\n}", "func findBestValue(arr []int, target int) int {\n\tmaxv := 0\n\tsum := 0\n\tfor _, v := range arr {\n\t\tsum += v\n\t\tif v>maxv {\n\t\t\tmaxv = v\n\t\t}\n\t}\n\tif target>=sum {\n\t\treturn maxv // can't be more larger\n\t}\n\tmindiff := sum-target // base line diff\n\tminvalue := maxv // base line value\n l, r := 0, maxv\n for l<=r {\n \tmid := (l+r)/2\n\n \t// get current sum\n \tsum = 0\n \tfor _, v := range arr {\n \t\tif v>mid {\n \t\t\tsum += mid\n \t\t} else {\n \t\t\tsum += v\n \t\t}\n \t}\n\n \tif sum > target {\n \t\tr = mid-1\n \t\tif sum-target < mindiff {\n \t\t\tmindiff = sum-target\n \t\t\tminvalue = mid\n \t\t} else if sum-target == mindiff && mid<minvalue { // tie\n \t\t\tminvalue = mid\n \t\t}\n \t} else if sum < target {\n \t\tl = mid+1\n \t\tif target-sum < mindiff {\n \t\t\tmindiff = target-sum\n \t\t\tminvalue = mid\n \t\t} else if target-sum == mindiff && mid<minvalue { // tie\n \t\t\tminvalue = mid\n \t\t}\n \t} else {\n \t\tminvalue = mid // find the value that make sum==target\n \t\tbreak\n \t}\n }\n return minvalue\n}", "func (treeNode *TreeNode) FindMax() int {\n\tif treeNode.right == nil {\n\t\treturn treeNode.value\n\t}\n\n\treturn treeNode.right.FindMax()\n}", "func maxSum(input []int) int {\n\tif len(input) == 0 {\n\t\treturn 0\n\t}\n\n\tincl := input[0]\n\texcl := 0\n\n\tfor _, val := range input[1:] {\n\t\ttemp := incl\n\t\tincl = max(excl+val, incl)\n\t\texcl = temp\n\t}\n\n\treturn incl\n}", "func FindMax(tree *TreeNode) *TreeNode {\n\tif tree.Right != nil {\n\t\treturn FindMax(tree.Right)\n\t} else {\n\t\treturn tree\n\t}\n}", "func (x *Node) findMaximum(sentinelT *Node) *Node {\n\n\tif x.right != sentinelT {\n\n\t\tx = x.right.findMaximum(sentinelT)\n\t}\n\treturn x\n\n}", "func maxSubArraySum(data []int) int {\n\tsum := 0\n\tmax := 0\n\tfor _, v := range data {\n\t\tsum = sum + v\n\t\tif sum < 0 {\n\t\t\tsum = 0\n\t\t}\n\t\tif max < sum {\n\t\t\tmax = sum\n\t\t}\n\t}\n\treturn max\n}", "func (g *graph) find_max_value(chk *checklist) int {\n\tcurrent := 0\n\tidx := -1\n\tfor i,c := range chk.nodes_count {\n\t\tif c > current {\n\t\t\tidx = i\n\t\t\tcurrent = c\n\t\t}\n\t}\n\tif idx >= 0 { chk.nodes_count[idx] = -1 }\n\treturn idx\n}", "func (t *RedBlackTree) Max() *Node {\n\treturn t.root.Max()\n}", "func findSecondMinimumValue(root *TreeNode) int {\n\tif root == nil || root.Left == nil || root.Right == nil {\n\t\treturn -1\n\t}\n\n\t// 1\n\t// / \\\n\t// 1 3\n\t// / \\ / \\\n\t// 1 1 3 4\n\t// / \\ / \\ / \\ / \\\n\t// 3 1 1 1 3 8 4 8\n\t// / \\ / \\ / \\\n\t// 3 3 1 6 2 1\n\t// 在遇到上述 case 时, 下面的 if 就会导致结果错误\n\t//if root.Val == root.Left.Val && root.Val == root.Right.Val {\n\t//\treturn -1\n\t//}\n\n\tlsv, rsv := root.Left.Val, root.Right.Val\n\t// 根值和左子树根值相等,第二小的值有可能在左子树里\n\t// 所以需要找出左子树的第二小值,和右子树的根值作比较\n\tif root.Val == root.Left.Val {\n\t\tlsv = findSecondMinimumValue(root.Left)\n\t}\n\t// 根值和右子树根值相等\n\tif root.Val == root.Right.Val {\n\t\trsv = findSecondMinimumValue(root.Right)\n\t}\n\tif lsv != -1 && rsv != -1 {\n\t\tif lsv < rsv {\n\t\t\treturn lsv\n\t\t}\n\t\treturn rsv\n\t}\n\t// 如果代码能到这一行,说明 lsv 和 rsv 两者有一个为-1或者两者都为-1\n\tif lsv != -1 {\n\t\treturn lsv\n\t}\n\treturn rsv\n}", "func findMax(vals []float64) float64 {\n\tmax := float64(vals[0])\n\tfor v := range vals {\n\t\tif vals[v] > max {\n\t\t\tmax = vals[v]\n\t\t}\n\t}\n\treturn float64(max)\n}", "func maxSubsetSum(arr []int32) int32 {\n\tk := make([]int32, len(arr))\n\n\tfor i := range arr {\n\t\tif i == 0 {\n\t\t\tk[i] = arr[i]\n\t\t} else if i == 1 {\n\t\t\tk[i] = max(arr[i], arr[i-1])\n\t\t} else {\n\t\t\tk[i] = max(k[i-2]+arr[i], k[i-1])\n\t\t}\n\t}\n\n\tif k[len(arr)-1] <= 0 {\n\t\treturn 0\n\t}\n\n\treturn k[len(arr)-1]\n}", "func (t *BinarySearch[T]) Max() (T, bool) {\n\tret := maximum[T](t.Root, t._NIL)\n\tif ret == t._NIL {\n\t\tvar dft T\n\t\treturn dft, false\n\t}\n\treturn ret.Key(), true\n}", "func (m Matrix) MaxPathSum() Int {\n\tfor row := len(m) - 2; row >= 0; row-- {\n\t\tfor col := 0; col < len(m[row])-1; col++ {\n\t\t\tif m[row+1][col] > m[row+1][col+1] {\n\t\t\t\tm[row][col] += m[row+1][col]\n\t\t\t} else {\n\t\t\t\tm[row][col] += m[row+1][col+1]\n\t\t\t}\n\t\t}\n\t}\n\n\treturn m[0][0]\n}", "func MaxSumSubmatrix(matrix [][]int, k int) int {\n type point struct {\n i, j int\n }\n // re map right bottom point to left top point for all sub matrix\n re := make(map[point]map[point]int)\n var maxSum int\n var hasSum bool\n for i := range matrix {\n for j := range matrix[i] {\n re[point{i,j}] = map[point]int{point{i,j}: matrix[i][j]}\n if (!hasSum || matrix[i][j] > maxSum) && matrix[i][j] <= k {\n maxSum = matrix[i][j]\n hasSum = true\n }\n if hasSum && maxSum == k {\n return maxSum\n }\n\n if i > 0 {\n s := 0\n for jLeftTop := j; jLeftTop >= 0; jLeftTop-- {\n s += matrix[i][jLeftTop]\n m, exist := re[point{i-1, j}]\n if !exist {\n break\n }\n for p := range m {\n if p.j != jLeftTop {\n continue\n }\n re[point{i, j}][p] = m[p] + s\n if (!hasSum || re[point{i, j}][p] > maxSum) && re[point{i, j}][p] <= k {\n maxSum = re[point{i, j}][p]\n hasSum = true\n }\n if hasSum && maxSum == k {\n return maxSum\n }\n }\n }\n }\n\n if j > 0 {\n s := 0\n for iLeftTop := i; iLeftTop >= 0; iLeftTop-- {\n s += matrix[iLeftTop][j]\n m, exist := re[point{i, j-1}]\n if !exist {\n continue\n }\n for p := range m {\n if p.i != iLeftTop {\n continue\n }\n re[point{i, j}][p] = m[p] + s\n if (!hasSum || re[point{i, j}][p] > maxSum) && re[point{i, j}][p] <= k {\n maxSum = re[point{i, j}][p]\n hasSum = true\n }\n if hasSum && maxSum == k {\n return maxSum\n }\n }\n }\n }\n }\n }\n\n return maxSum\n}", "func max(n *node) Item {\n\tif n == nil {\n\t\treturn nil\n\t}\n\tfor len(n.children) > 0 {\n\t\tn = n.children[len(children)-1]\n\t}\n\tif len(n.items) == 0 {\n\t\treturn nil\n\t}\n\treturn n.items[len(n.items)-1]\n}", "func FindMaximumTotal(data [][]int) int {\n\tfor i := 0; i < len(data); i++ {\n\t\tLoadPreviousRow(data, i)\n\t}\n\tmax := 0\n\tfor _, v := range data[len(data)-1] {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\treturn max\n}", "func root(arg float64) (float64, error) {\n\tif arg < 0 {\n\t\t// If argument is negative, then return an arbitrary integer\n\t\t// And an error value. Basic error construction:\n\t\treturn -1, errors.New(\"number can not be negative\")\n\t}\n\n\t// A nil value indicates no error happened\n\treturn math.Sqrt(arg), nil\n}", "func (v *VEBTree) Maximum() int {\n\treturn v.max\n}", "func maxSumCircularArray(input []int) int {\n\tif len(input) == 0 {\n\t\treturn 0\n\t}\n\n\tif len(input) == 1 {\n\t\treturn input[0]\n\t}\n\n\t// maxsum excluding 1st element from left to right\n\tmaxSum1 := maxSum(input[1:])\n\n\t// maxsum excluding nth element from right to left\n\tmaxSum2 := maxSum(input[:len(input)-1])\n\n\treturn max(maxSum1, maxSum2)\n}", "func getMaximumGold(grid [][]int) int {\n m := len(grid)\n n := len(grid[0])\n var ans int\n for i := 0; i<m;i++ {\n for j := 0;j < n; j++ {\n ans = max(ans, dfsGold(grid, m, n, i, j, 0))\n }\n }\n return ans\n}", "func (b *BSTNode) FindMaxRecur() (int, error) {\n\tif *b == (BSTNode{}) {\n\t\treturn 0, errors.New(\"The Binary Search Tree is empty\")\n\t}\n\n\tif b.Right == nil {\n\t\tfmt.Println(\"FOUND\")\n\t\treturn b.Data, nil\n\t}\n\n\treturn b.Right.FindMaxRecur()\n}", "func distributeCoins(root *TreeNode) int {\n\tres := 0\n\tif root.Left != nil {\n\t\tres += distributeCoins(root.Left)\n\t\troot.Val += root.Left.Val - 1\n\t\tres += int(math.Abs(float64(root.Left.Val - 1)))\n\t}\n\tif root.Right != nil {\n\t\tres += distributeCoins(root.Right)\n\t\troot.Val += root.Right.Val - 1\n\t\tres += int(math.Abs(float64(root.Right.Val - 1)))\n\t}\n\treturn res\n}", "func root(candies int) int {\n\tdelta := float64(1 + 8*candies)\n\treturn int((math.Sqrt(delta) - 1) / 2)\n}", "func FetchMax(t *treeNode) int {\n\tif t.Right == nil {\n\t\treturn t.Value\n\t}\n\treturn FetchMax(t.Right)\n}", "func max(v *Histo) (max float64) {\n\tmax = -1\n\tfor _, row := range v {\n\t\tfor _, v := range row {\n\t\t\tif v > max {\n\t\t\t\tmax = v\n\t\t\t}\n\t\t}\n\t}\n\treturn max\n}", "func (f *fragment) max(filter *Row, bitDepth uint) (max int64, count uint64, err error) {\n\tconsider := f.row(bsiExistsBit)\n\tif filter != nil {\n\t\tconsider = consider.Intersect(filter)\n\t}\n\n\t// If there are no columns to consider, return early.\n\tif !consider.Any() {\n\t\treturn 0, 0, nil\n\t}\n\n\t// Find lowest negative number w/o sign and negate, if no positives are available.\n\tpos := consider.Difference(f.row(bsiSignBit))\n\tif !pos.Any() {\n\t\tmax, count = f.minUnsigned(consider, bitDepth)\n\t\treturn -max, count, nil\n\t}\n\n\t// Otherwise find highest positive number.\n\tmax, count = f.maxUnsigned(pos, bitDepth)\n\treturn max, count, nil\n}", "func (n *Node) Max() int {\n\tif n.Right == nil {\n\t\treturn n.Key\n\t}\n\n\treturn n.Right.Max()\n}", "func (t *Tree) Max() *Elem {\n\tif t.Root == nil {\n\t\treturn nil\n\t}\n\treturn t.Root.max().Elem\n}", "func rmax(data ArrType) float64 {\r\n\tvar i, idxCari, idxMax int\r\n\ti = 0\r\n\tidxCari = 1\r\n\tidxMax = 0\r\n\tfor i < N-1 { // N-1 karena idxCari = i + 1 sehingga data terakhir masih diperhitungkan\r\n\t\tif data[idxCari].f3 > data[idxMax].f3 {\r\n\t\t\tidxMax = idxCari\r\n\t\t}\r\n\t\tidxCari++\r\n\t\ti++\r\n\t}\r\n\treturn data[idxMax].f3\r\n}", "func (v Vec) Max() float64 {\n\treturn v[1:].Reduce(func(a, e float64) float64 { return math.Max(a, e) }, v[0])\n}", "func MAXSD(mx, x operand.Op) { ctx.MAXSD(mx, x) }", "func maxSubArray(nums []int) int {\n if len(nums) == 0 {\n return 0\n }\n result := nums[0]\n preSum := nums[0]\n for i:=1; i<len(nums); i++ {\n if preSum < 0 {\n preSum = nums[i]\n } else {\n preSum += nums[i]\n }\n result = max(result, preSum)\n }\n return result\n}", "func maxDepth(root *data.TreeNode) int {\n\tif root == nil {\n\t\treturn 0\n\t}\n\tif root.Left == nil && root.Right == nil {\n\t\treturn 1\n\t}\n\treturn int(math.Max(float64(maxDepth(root.Left))+1, float64(maxDepth(root.Right))+1))\n}", "func (ind *Indicator) Max(val VarSet) float64 {\n\tv, ok := val[ind.varid]\n\tif !ok || v == ind.setting {\n\t\treturn 0.0\n\t}\n\treturn math.Inf(-1)\n}", "func (n *Node) Max() (node *Node) {\n\tif node = n; node == nil {\n\t\treturn\n\t}\n\n\tfor node.right != nil {\n\t\tnode = node.right\n\t}\n\n\treturn\n}", "func (t *Tree) sum(n *Node) (int, int) {\n\ttotal := 0\n\tnodeCount := 0\n\t// create a starting stack\n\tvar stack []*Node\n\tfor n != nil {\n\t\t// push\n\t\tstack = append(stack, n)\n\t\tn = n.Left\n\t}\n\tfor len(stack) > 0 {\n\t\t// pop a value out\n\t\t// https://github.com/golang/go/wiki/SliceTricks\n\t\tn, stack = stack[len(stack)-1], stack[:len(stack)-1]\n\t\ttotal += n.Data\n\t\tnodeCount++\n\t\tif n.Right != nil {\n\t\t\tn = n.Right\n\t\t\tfor n != nil {\n\t\t\t\tstack = append(stack, n)\n\t\t\t\tn = n.Left\n\t\t\t}\n\t\t}\n\t}\n\treturn total, nodeCount\n}", "func getMaximumGold(grid [][]int) int {\n\tdirections := [][]int{{0, 1}, {0, -1}, {1, 0}, {-1, 0}}\n\n\tif len(grid) == 0 {\n\t\treturn 0\n\t}\n\n\tm, n := len(grid), len(grid[0])\n\tresult := 0\n\n\tfor i := 0; i < m; i++ {\n\t\tfor j := 0; j < n; j++ {\n\t\t\tresult = Max(result, findMaxGold(grid, i, j, directions))\n\t\t}\n\t}\n\treturn result\n}", "func Max(vals []float64) float64 {\n\tif len(vals) == 0 {\n\t\treturn 0.0\n\t}\n\n\tmax := math.Inf(-1)\n\n\tfor i := 0; i < len(vals); i++ {\n\t\tif vals[i] > max {\n\t\t\tmax = vals[i]\n\t\t}\n\t}\n\n\treturn max\n}", "func sum(m int) int {\n\tn := int(maxNumber / m)\n\tsum := (2*m + m*(n-1)) * n / 2\n\n\treturn sum\n}", "func sumOfLeftLeaves(root *TreeNode) int {\n\tif root == nil {\n\t\treturn 0\n\t}\n\n\tif root.Left != nil && root.Left.Left == nil && root.Left.Right == nil {\n\t\treturn root.Left.Val + sumOfLeftLeaves(root.Right)\n\t}\n\n\treturn sumOfLeftLeaves(root.Left) + sumOfLeftLeaves(root.Right)\n}", "func (orderTree *OrderTree) MaxPrice() *big.Int {\n\tif orderTree.Depth() > 0 {\n\t\tif bytes, found := orderTree.PriceTree.GetMax(); found {\n\t\t\titem := orderTree.getOrderListItem(bytes)\n\t\t\tif item != nil {\n\t\t\t\treturn CloneBigInt(item.Price)\n\t\t\t}\n\t\t}\n\t}\n\treturn Zero()\n}", "func getHeight(root *TreeNode) int {\n\tif root == nil {\n\t\treturn 0\n\t}\n\thl := getHeight(root.Left)\n\tif hl == -1 {\n\t\treturn -1\n\t}\n\trl := getHeight(root.Right)\n\tif rl == -1 {\n\t\treturn -1\n\t}\n\n\tdiff := hl - rl\n\tif diff > 1 || diff < -1 {\n\t\treturn -1\n\t}\n\tif hl > rl {\n\t\treturn hl + 1\n\t}\n\treturn rl + 1\n}", "func (tree *BinarySearchTree) MaxNode() *int {\n\ttree.lock.RLock()\n\tdefer tree.lock.RUnlock()\n\tvar treeNode *TreeNode\n\ttreeNode = tree.rootNode\n\tif treeNode == nil {\n\t\t//nil instead of 0\n\t\treturn (*int)(nil)\n\t}\n\tfor {\n\t\tif treeNode.rightNode == nil {\n\t\t\treturn &treeNode.value\n\t\t}\n\t\ttreeNode = treeNode.rightNode\n\t}\n}", "func Max(values []float64) float64 {\n\tif len(values) == 0 {\n\t\treturn math.NaN()\n\t}\n\treturnValue := math.Inf(-1)\n\tfor _, d := range values {\n\t\treturnValue = math.Max(returnValue, d)\n\t}\n\treturn returnValue\n}", "func (root *TreeNode) getBalance() int64 {\n\tif root == nil {\n\t\treturn 0\n\t}\n\treturn root.left.getHeight() - root.right.getHeight()\n}", "func distributeCoins(root *TreeNode) int {\n\tres := 0\n\tvar dfs func(root *TreeNode) int\n\tabs := func(a int) int {\n\t\tif a < 0 {\n\t\t\treturn -a\n\t\t}\n\t\treturn a\n\t}\n\tdfs = func(root *TreeNode) int {\n\t\tif root == nil {\n\t\t\treturn 0\n\t\t}\n\t\tleft := dfs(root.Left)\n\t\tright := dfs(root.Right)\n\t\tres += abs(left) + abs(right)\n\t\treturn left + right + root.Val - 1\n\t}\n\tdfs(root)\n\treturn res\n}", "func (o *Brent) Root(xa, xb float64) (res float64) {\n\n\t// basic variables and function evaluation\n\ta := xa // the last but one approximation\n\tb := xb // the last and the best approximation to the root\n\tc := a // the last but one or even earlier approximation than a that\n\tfa := o.ffcn(a)\n\tfb := o.ffcn(b)\n\to.NumFeval = 2\n\to.NumJeval = 0\n\tfc := fa\n\n\t// check input\n\tif fa*fb >= -MACHEPS {\n\t\tchk.Panic(\"root must be bracketed: xa=%g, xb=%g, fa=%g, fb=%b => fa * fb >= 0\", xa, xb, fa, fb)\n\t}\n\n\t// message\n\tif o.Verbose {\n\t\tio.Pf(\"%4s%23s%23s%23s\\n\", \"it\", \"x\", \"f(x)\", \"err\")\n\t\tio.Pf(\"%50s%23.1e\\n\", \"\", o.Tol)\n\t}\n\n\t// solve\n\tvar prevStep float64 // distance from the last but one to the last approximation\n\tvar tolAct float64 // actual tolerance\n\tvar p, q float64 // interpol. step is calculated in the form p/q (divisions are delayed)\n\tvar newStep float64 // step at this iteration\n\tvar t1, cb, t2 float64 // auxiliary variables\n\tfor o.NumIter = 0; o.NumIter < o.MaxIt; o.NumIter++ {\n\n\t\t// distance\n\t\tprevStep = b - a\n\n\t\t// swap data for b to be the best approximation\n\t\tif math.Abs(fc) < math.Abs(fb) {\n\t\t\ta = b\n\t\t\tb = c\n\t\t\tc = a\n\t\t\tfa = fb\n\t\t\tfb = fc\n\t\t\tfc = fa\n\t\t}\n\t\ttolAct = 2.0*MACHEPS*math.Abs(b) + o.Tol/2.0\n\t\tnewStep = (c - b) / 2.0\n\n\t\t// converged?\n\t\tif o.Verbose {\n\t\t\tio.Pf(\"%4d%23.15e%23.15e%23.15e\\n\", o.NumIter, b, fb, math.Abs(newStep))\n\t\t}\n\t\tif math.Abs(newStep) <= tolAct || fb == 0.0 {\n\t\t\treturn b\n\t\t}\n\n\t\t// decide if the interpolation can be tried\n\t\tif math.Abs(prevStep) >= tolAct && math.Abs(fa) > math.Abs(fb) {\n\t\t\t// if prev_step was large enough and was in true direction, interpolation may be tried\n\t\t\tcb = c - b\n\n\t\t\t// with two distinct points, linear interpolation must be applied\n\t\t\tif a == c {\n\t\t\t\tt1 = fb / fa\n\t\t\t\tp = cb * t1\n\t\t\t\tq = 1.0 - t1\n\n\t\t\t\t// otherwise, quadric inverse interpolation is applied\n\t\t\t} else {\n\t\t\t\tq = fa / fc\n\t\t\t\tt1 = fb / fc\n\t\t\t\tt2 = fb / fa\n\t\t\t\tp = t2 * (cb*q*(q-t1) - (b-a)*(t1-1.0))\n\t\t\t\tq = (q - 1.0) * (t1 - 1.0) * (t2 - 1.0)\n\t\t\t}\n\n\t\t\t// p was calculated with the opposite sign;\n\t\t\t// make p positive and assign possible minus to q\n\t\t\tif p > 0.0 {\n\t\t\t\tq = -q\n\t\t\t} else {\n\t\t\t\tp = -p\n\t\t\t}\n\n\t\t\t// if b+p/q falls in [b,c] and isn't too large, it is accepted\n\t\t\t// if p/q is too large then the bissection procedure can reduce [b,c] range to more extent\n\t\t\tif p < (0.75*cb*q-math.Abs(tolAct*q)/2.0) && p < math.Abs(prevStep*q/2.0) {\n\t\t\t\tnewStep = p / q\n\t\t\t}\n\t\t}\n\n\t\t// adjust the step to be not less than tolerance\n\t\tif math.Abs(newStep) < tolAct {\n\t\t\tif newStep > 0.0 {\n\t\t\t\tnewStep = tolAct\n\t\t\t} else {\n\t\t\t\tnewStep = -tolAct\n\t\t\t}\n\t\t}\n\n\t\t// save the previous approximation\n\t\ta = b\n\t\tfa = fb\n\n\t\t// do step to a new approximation\n\t\tb += newStep\n\t\tfb = o.ffcn(b)\n\t\to.NumFeval++\n\n\t\t// adjust c for it to have a sign opposite to that of b\n\t\tif (fb > 0.0 && fc > 0.0) || (fb < 0.0 && fc < 0.0) {\n\t\t\tc = a\n\t\t\tfc = fa\n\t\t}\n\t}\n\n\t// did not converge\n\tchk.Panic(\"fail to converge after %d iterations\", o.NumIter)\n\treturn\n}", "func Max(xs []float64) float64 {\n\tif len(xs) == 0 {\n\t\treturn 0\n\t}\n\t\n\tmax := xs[0]\n\tfor _, v := range xs {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\treturn max\n}", "func root(n uint) uint {\n\tw := nodeWidth(n)\n\treturn uint((1 << log2(w)) - 1)\n}", "func Maximum(values ...float64) float64 {\n\t// initialized with negative infinity, all finite numbers are bigger than it\n\tcurMax := math.Inf(-1)\n\tfor _, v := range values {\n\t\tif v > curMax {\n\t\t\tcurMax = v\n\t\t}\n\t}\n\treturn curMax\n}", "func Max(numbers []float64) float64 {\n\tif len(numbers) == 0 {\n\t\treturn 0\n\t}\n\tmax := numbers[0]\n\tfor _, value := range numbers {\n\t\tif value > max {\n\t\t\tmax = value\n\t\t}\n\t}\n\treturn max\n}", "func minimumTotal(triangle [][]int) int {\n\trunningSum := make([]int, 1)\n\trunningSum[0] = triangle[0][0]\n\ttriangleHeight := len(triangle)\n\tfor i := 1; i < triangleHeight; i++ {\n\t\trow := triangle[i]\n\t\tnumInRow := len(row)\n\t\tnumInRunningSum := len(runningSum)\n\t\tnewRunningSum := make([]int, 0)\n\t\tfor j := 0; j < numInRow; j++ {\n\t\t\tval := triangle[i][j]\n\t\t\tif j == 0 {\n\t\t\t\tnewRunningSum = append(newRunningSum, runningSum[0]+val)\n\t\t\t} else {\n\t\t\t\tm1 := runningSum[j-1] + val\n\t\t\t\tif j < numInRunningSum {\n\t\t\t\t\tm2 := runningSum[j] + val\n\t\t\t\t\tif m1 < m2 {\n\t\t\t\t\t\tnewRunningSum = append(newRunningSum, m1)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnewRunningSum = append(newRunningSum, m2)\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// we to append\n\t\t\t\t\tnewRunningSum = append(newRunningSum, m1)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\trunningSum = newRunningSum\n\t}\n\tresult := runningSum[0]\n\tfor k := 1; k < len(runningSum); k++ {\n\t\tif runningSum[k] < result {\n\t\t\tresult = runningSum[k]\n\t\t}\n\t}\n\treturn result\n}", "func (tree *Tree) sumRight(node *TreeNode) int {\n\tif node == nil {\n\t\treturn 0\n\t}\n\n\tleftSum, rightSum := 0, 0\n\tfor node != nil {\n\t\tif node.left != nil {\n\t\t\tleftSum = max(leftSum, tree.sumLeft(node.left) + node.data)\n\t\t}\n\t\trightSum += node.data\n\t\tnode = node.right\n\t}\n\n\treturn max(rightSum, leftSum)\n}", "func (bst *StringBinarySearchTree) Max() *string {\n\tbst.lock.RLock()\n\tdefer bst.lock.RUnlock()\n\tn := bst.root\n\tif n == nil {\n\t\treturn nil\n\t}\n\tfor {\n\t\tif n.right == nil {\n\t\t\treturn &n.value\n\t\t}\n\t\tn = n.right\n\t}\n}", "func maxSubArray(nums []int) int {\n\tstMax := -1\n\tvar max int\n\t// var endMax int\n\tfor st := 0; st < len(nums); st++ {\n\t\tsum := 0\n\t\tfor end := st; end < len(nums); end++ {\n\t\t\tsum += nums[end]\n\t\t\tif (stMax < 0) || (sum > max) {\n\t\t\t\tmax = sum\n\t\t\t\tstMax = st\n\t\t\t\t// end_max = end\n\t\t\t}\n\t\t}\n\t}\n\treturn max\n}", "func squareRootsAndSum(w *lagrange) *big.Int {\n\tsum := new(big.Int)\n\tfor _, root := range w {\n\t\tsum.Add(sum, new(big.Int).Mul(root, root))\n\t}\n\n\treturn sum\n}", "func Max(key []byte, nodes []*memberlist.Node) (max *memberlist.Node) {\n\tmaxValue := big.NewInt(0)\n\n\tCompute(key, nodes, func(node *memberlist.Node, bi *big.Int) {\n\t\tif bi.Cmp(maxValue) == 1 {\n\t\t\tmaxValue = bi\n\t\t\tmax = node\n\t\t}\n\t})\n\n\treturn max\n}", "func findMaxAverage(arr []int, k int) float64 {\n\tfirstPart := arr[:k] //0~k-1, k numbers\n\tsum := 0\n\tmax := 0\n\trestPart := arr[k:] //k~end\n\tfor _, v := range firstPart {\n\t\tsum += v\n\t}\n\tmax = sum\n\tfor i, v := range restPart {\n\t\tsum = sum + v - arr[i]\n\t\tif max < sum {\n\t\t\tmax = sum\n\t\t}\n\n\t}\n\treturn float64(max) / float64(k)\n\n}", "func MaxHailstoneValue(n int) int {\n var max int = n\n for n > 1 {\n var temp int = h(n)\n if temp > max {\n max = temp\n }\n n = temp\n }\n return max\n}", "func maxDepth(root *TreeNode) int {\n\tif root == nil {\n\t\treturn 0\n\t}\n\n\treturn max(maxDepth(root.Left), maxDepth(root.Right)) + 1\n}", "func Total() uint64 {\n\treturn 1<<uint64(max) - 1\n}", "func sumOfLeftLeaves(root *TreeNode) int {\n\tif root == nil {\n\t\treturn 0\n\t}\n\tif isLeaf(root.Left) {\n\t\treturn root.Left.Val + sumOfLeftLeaves(root.Right)\n\t}\n\treturn sumOfLeftLeaves(root.Left) + sumOfLeftLeaves(root.Right)\n}", "func MaximumSubarraySum(numbers []int) int {\n\tmax := 0\n\tfor i := 0; i < len(numbers); i++ {\n\t\tsum := 0\n\t\tfor y := i; y < len(numbers); y++ {\n\t\t\tsum = sum + numbers[y]\n\t\t\tif sum > max {\n\t\t\t\tmax = sum\n\t\t\t}\n\t\t}\n\t}\n\treturn max\n}", "func (st *RedBlackBST) Max() Key {\n\tif st.IsEmpty() {\n\t\tpanic(\"call Max on empty RedBlackbst\")\n\t}\n\treturn st.max(st.root).key\n}", "func (node *Node) findMaxNode(parent *Node) (*Node, *Node) {\n\tif node == nil {\n\t\treturn nil, parent\n\t}\n\tif node.Right == nil {\n\t\treturn node, parent\n\t}\n\treturn node.Right.findMaxNode(node)\n}", "func getMaxLen(nums []int) int {\n\tmaxlen := 0\n\ts := -1\n\tfn, ln, negs := -1, -1, 0\n\tfor i:=0; i<=len(nums); i++ {\n\t\t// add zero at end to trigger final compute\n\t\tv := 0\n\t\tif i<len(nums) {\n\t\t\tv = nums[i]\n\t\t}\n\n\t\t// find an interval\n\t\tif v==0 { \n\t\t\tif i-s > 1 { // non-empty interval\n\t\t\t\tif negs%2==0 { // even negs, whole interval is ok\n\t\t\t\t\tmaxlen = max(maxlen, i-s-1)\n\t\t\t\t} else {\n\t\t\t\t\tmaxlen = max(maxlen, max(ln-s-1, i-fn-1))\n\t\t\t\t}\n\t\t\t}\n\t\t\tfn, ln, s = i, i, i\n\t\t\tnegs = 0\n\t\t}\n\n\t\t// find a value\n\t\tif v < 0 {\n\t\t\tnegs++\n\t\t\tif fn==s {\n\t\t\t\tfn = i\n\t\t\t}\n\t\t\tln = i\n\t\t}\n\t\t// if v > 0, do nothing\n\t}\n return maxlen\n}", "func est_square_root(tls *libc.TLS, x int32) int32 { /* speedtest1.c:617:12: */\n\tvar y0 int32 = (x / 2)\n\tvar y1 int32\n\tvar n int32\n\tfor n = 0; (y0 > 0) && (n < 10); n++ {\n\t\ty1 = ((y0 + (x / y0)) / 2)\n\t\tif y1 == y0 {\n\t\t\tbreak\n\t\t}\n\t\ty0 = y1\n\t}\n\treturn y0\n}", "func (dim Dimensions) Max() float64 {\n\tmax := 0.0\n\n\tif d := dim[1][0] - dim[0][0]; d > max {\n\t\tmax = d\n\t}\n\n\tif d := dim[1][1] - dim[0][1]; d > max {\n\t\tmax = d\n\t}\n\n\tif d := dim[1][2] - dim[0][2]; d > max {\n\t\tmax = d\n\t}\n\n\treturn math.Abs(max)\n}", "func Max(inp data) (max float64, err error) {\n\n\tif inp.Len() == 0 {\n\t\treturn math.NaN(), errors.New(\"Empty Set\")\n\t}\n\n\tmax = inp.Get(0)\n\n\tfor i := 1; i < inp.Len(); i++ {\n\t\tif inp.Get(i) > max {\n\t\t\tmax = inp.Get(i)\n\t\t}\n\t}\n\n\treturn max, nil\n}", "func FindMaxSumOfSubArray(arr []int) (int, bool) {\n\tif arr == nil || len(arr) < 1 {\n\t\treturn 0, false\n\t}\n\n\tmaxSum, curSum := ^int(^uint(0)>>1), 0\n\tfor _, e := range arr {\n\t\tif curSum <= 0 {\n\t\t\tcurSum = e\n\t\t} else {\n\t\t\tcurSum += e\n\t\t}\n\t\tif maxSum < curSum {\n\t\t\tmaxSum = curSum\n\t\t}\n\t}\n\treturn maxSum, true\n}", "func GetMaximumLoot (capacity int, values []int, weights []int) float64 {\n\tvar units []float64\n\tfor i := 0; i < len(values); i++ {\n\t\tunits = append(units, float64(values[i])/float64(weights[i]))\n\t}\n\n\tvar temp float64\n\tvar tempWeights int\n\tfor k := 0; k < len(units) - 2; k++ {\n\t\tfor i := 0; i < len(units) - 1; i++ {\n\t\t\tif units[i] > units[i + 1] {\n\t\t\t\ttemp = units[i]\n\t\t\t\ttempWeights = weights[i]\n\n\t\t\t\tunits[i] = units[i + 1]\n\t\t\t\tweights[i] = weights[i + 1]\n\n\t\t\t\tunits[i + 1] = temp\n\t\t\t\tweights[i + 1] = tempWeights\n\t\t\t}\n\t\t}\n\t}\n\n\tvar result float64\n\tresult = 0.0000\n\n\tfor m := len(units) - 1; m >= 0; m-- {\n\t\tif weights[m] <= capacity {\n\t\t\tresult += units[m] * float64(weights[m])\n\t\t\tcapacity -= weights[m]\n\t\t\tif capacity == 0 {\n\t\t\t\tbreak\n\t\t\t} else {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tresult += units[m] * float64(capacity)\n\t\tcapacity = 0\n\t\tbreak\n\t}\n\n\treturn RoundUp(result, 4)\n}", "func main() {\n\tnine := &Node{item: 9, left: &Node{item: 3}}\n\tseven := &Node{item: 7}\n\teight := &Node{item: 8, right: nine}\n\n\tt := &Node{item: 10, left: seven, right: eight}\n\tfmt.Println(findMaxDepth1(t, 0))\n\tfmt.Println(findMaxDepth2(t))\n\tfmt.Println(findMaxDepth3(t))\n\n\tfmt.Println(\"height of binary tree=\", height(t))\n}", "func (v *parameter) Maximum() float64 {\n\tif !v.HasMaximum() {\n\t\treturn 0\n\t}\n\treturn *v.maximum\n}", "func (na *NArray) Max() float32 {\n\tif na == nil || len(na.Data) == 0 {\n\t\tpanic(\"unable to take max of nil or zero-sizes array\")\n\t}\n\treturn maxSliceElement(na.Data)\n}", "func (g *Gaussian) Max(val VarSet) float64 {\n\tv, ok := val[g.varid]\n\tif ok {\n\t\t//fmt.Printf(\"Preparing Gaussian with parameters z = (x-mu)/sigma = (%.3f - %.3f) / %.3f\\n\",\n\t\t//float64(v), g.mean, g.sd)\n\t\tz := math.Log(float64(C.gsl_ran_ugaussian_pdf(C.double((float64(v) - g.mean) / g.sd))))\n\t\t//fmt.Printf(\"Max: Gaussian[%d] = %.5f\\n\", g.varid, z)\n\t\treturn z\n\t}\n\treturn math.Log(GaussMax)\n}", "func (s VectOp) Max() float64 {\n\tmax := math.Inf(-1)\n\tfor _, val := range s {\n\t\tmax = math.Max(max, val)\n\t}\n\treturn max\n}", "func sumOfLeftLeavesDFS(root *TreeNode) int {\n\tsum := 0\n\tvar dfs func(r *TreeNode)\n\tdfs = func(r *TreeNode) {\n\t\tif r == nil {\n\t\t\treturn\n\t\t}\n\t\tif r.Left != nil && r.Left.Left == nil && r.Left.Right == nil {\n\t\t\tsum += r.Left.Val\n\t\t}\n\t\tdfs(r.Left)\n\t\tdfs(r.Right)\n\t}\n\tdfs(root)\n\treturn sum\n}", "func Solution(A []int) int {\n\n\tN := len(A)\n\n\tsum := make([]int, N)\n\tsum[0] = A[0]\n\tfor i := 1; i < N; i++ {\n\t\tsum[i] = sum[i-1] + A[i]\n\t}\n\n\tif sum[N-1] >= 0 {\n\t\treturn N\n\t}\n\n\t// Now lets look for repitions in sum, basically the next position where a sum repeats\n\t// is indicative of non zero (especially for negative values)\n\tlower := make(map[int]int)\n\tupper := make(map[int]int)\n\tfor i := 0; i < N; i++ {\n\t\ts := sum[i]\n\t\t_, ok := lower[s]\n\t\tif !ok {\n\t\t\tlower[s] = i\n\t\t\tupper[s] = -1 // dummy\n\t\t} else {\n\t\t\tupper[s] = i\n\t\t}\n\t}\n\n\t// fmt.Printf(\"lower: %v\\n\", lower)\n\t// fmt.Printf(\"upper: %v\\n\", upper)\n\n\tvar sum_arr []int\n\tfor s, _ := range lower {\n\t\tsum_arr = append(sum_arr, s)\n\t}\n\n\tsort.Ints(sum_arr)\n\n\tmax_gap := 0\n\tfirst_lower := N\n\tfor i := 0; i < len(sum_arr); i++ {\n\t\ts := sum_arr[i]\n\t\tl := lower[s]\n\t\tif l < first_lower {\n\t\t\tfirst_lower = l\n\t\t\t//fmt.Printf(\"first_lower: %v\\n\", first_lower)\n\t\t}\n\n\t\tu := upper[s]\n\t\t// fmt.Printf(\"u: %v\\n\", u)\n\t\tgap := u - first_lower\n\t\tif s >= 0 {\n\t\t\t// or 0 or more the values are inclusive by 1\n\t\t\tgap++\n\t\t}\n\t\tif gap > max_gap {\n\t\t\tmax_gap = gap\n\t\t}\n\t}\n\n\treturn max_gap\n}" ]
[ "0.6921572", "0.6881113", "0.65898454", "0.64856327", "0.6413233", "0.64065135", "0.62849116", "0.6170783", "0.6122969", "0.6112235", "0.6084347", "0.5971642", "0.59470457", "0.59462214", "0.59316504", "0.59189284", "0.5914049", "0.5894993", "0.5746111", "0.5735989", "0.5656961", "0.5651436", "0.5634269", "0.56335044", "0.5630174", "0.5605202", "0.55918044", "0.558084", "0.5523912", "0.5515186", "0.5508591", "0.549638", "0.5495473", "0.54865336", "0.54542464", "0.5449655", "0.5439872", "0.5419544", "0.5418258", "0.5400284", "0.539003", "0.53817606", "0.537868", "0.5369831", "0.53661054", "0.5359871", "0.53560054", "0.5355212", "0.5353757", "0.5345945", "0.53390443", "0.5338424", "0.53368044", "0.5320995", "0.5319881", "0.53059775", "0.52888393", "0.52746", "0.5242747", "0.5242224", "0.52376825", "0.5237326", "0.5235971", "0.5234259", "0.5231168", "0.52262616", "0.5217494", "0.5216524", "0.5206934", "0.52057695", "0.51787627", "0.5176326", "0.51700366", "0.5168208", "0.5160077", "0.515602", "0.5153937", "0.5151695", "0.5146606", "0.5144156", "0.5142014", "0.51360315", "0.5133268", "0.51319766", "0.51277953", "0.51262283", "0.5089412", "0.50864977", "0.5079329", "0.5078758", "0.5077103", "0.50706506", "0.50630456", "0.50547665", "0.505081", "0.50389117", "0.50276697", "0.502468", "0.502412", "0.5017713" ]
0.64266676
4
MaxItemID retrieves the current largest item id is at You can walk backward from here to discover all items.
func MaxItemID() int { var maxItemID int err := getJSON(MaxItemIDURL, &maxItemID) if err != nil { log.Panicln(err.Error()) } return maxItemID }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getMaxID() uint8 {\n\tmaxID++\n\treturn maxID\n}", "func getMaxID() int {\n\n\tif len(cdb.classMap) != 0 {\n\t\tkeys := make([]int, 0, len(cdb.classMap))\n\t\tfor k := range cdb.classMap {\n\t\t\tkeys = append(keys, k)\n\t\t}\n\t\tsort.Ints(keys)\n\t\treturn keys[len(keys)-1]\n\t}\n\n\treturn -1\n\n}", "func (m *MessageReplies) GetMaxID() (value int, ok bool) {\n\tif m == nil {\n\t\treturn\n\t}\n\tif !m.Flags.Has(2) {\n\t\treturn value, false\n\t}\n\treturn m.MaxID, true\n}", "func (p *Policy) getMaxBlockSize(ic *interop.Context, _ []stackitem.Item) stackitem.Item {\n\treturn stackitem.NewBigInteger(big.NewInt(int64(p.GetMaxBlockSizeInternal(ic.DAO))))\n}", "func (_SmartTgStats *SmartTgStatsCaller) MaxRequestID(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _SmartTgStats.contract.Call(opts, out, \"maxRequestID\")\n\treturn *ret0, err\n}", "func (m *MessageReplies) SetMaxID(value int) {\n\tm.Flags.Set(2)\n\tm.MaxID = value\n}", "func (v *parameter) MaxItems() int {\n\tif !v.HasMaxItems() {\n\t\treturn 0\n\t}\n\treturn *v.maxItems\n}", "func MaxItems(totalItems int) int {\n\tvar maxItems int\n\n\tif totalItems%2 == 0 {\n\t\tmaxItems = totalItems / 2\n\t} else {\n\t\tmaxItems = totalItems/2 + 1\n\t}\n\treturn maxItems\n}", "func (l *Limiter) MaxItems() int {\n\treturn l.maxItems\n}", "func (o *ListScansParams) SetMaxItems(maxItems *int64) {\n\to.MaxItems = maxItems\n}", "func max(n *node) Item {\n\tif n == nil {\n\t\treturn nil\n\t}\n\tfor len(n.children) > 0 {\n\t\tn = n.children[len(children)-1]\n\t}\n\tif len(n.items) == 0 {\n\t\treturn nil\n\t}\n\treturn n.items[len(n.items)-1]\n}", "func (b *MessagesGetLongPollHistoryBuilder) MaxMsgID(v int) *MessagesGetLongPollHistoryBuilder {\n\tb.Params[\"max_msg_id\"] = v\n\treturn b\n}", "func MaxKey() Val { return Val{t: bsontype.MaxKey} }", "func (list *List) HighestID() (ID, bool) {\n\tif list.highest == -1 {\n\t\treturn ID(0), false\n\t}\n\n\treturn ID(list.highest), true\n}", "func (_SmartTgStats *SmartTgStatsSession) MaxRequestID() (*big.Int, error) {\n\treturn _SmartTgStats.Contract.MaxRequestID(&_SmartTgStats.CallOpts)\n}", "func (t *BTree) maxItems() int {\n\tdegree := 2\n\treturn degree*2 - 1\n}", "func (_SmartTgStats *SmartTgStatsCallerSession) MaxRequestID() (*big.Int, error) {\n\treturn _SmartTgStats.Contract.MaxRequestID(&_SmartTgStats.CallOpts)\n}", "func (s *DescribeFileSystemsInput) SetMaxItems(v int64) *DescribeFileSystemsInput {\n\ts.MaxItems = &v\n\treturn s\n}", "func (m *Max) GetId() int {\n\tif m.count > 0 {\n\t\treturn m.maxIdx\n\t} else {\n\t\treturn -1\n\t}\n}", "func (px *Paxos) Max() int {\n\tkeys := px.sortedSeqs()\n\tif len(keys) == 0 {\n\t\treturn -1\n\t} else {\n\t\tsort.Ints(keys)\n\t}\n\treturn keys[len(keys)-1]\n}", "func (s *DescribeMountTargetsInput) SetMaxItems(v int64) *DescribeMountTargetsInput {\n\ts.MaxItems = &v\n\treturn s\n}", "func (s *DescribeTagsInput) SetMaxItems(v int64) *DescribeTagsInput {\n\ts.MaxItems = &v\n\treturn s\n}", "func (s *GetSampledRequestsInput) SetMaxItems(v int64) *GetSampledRequestsInput {\n\ts.MaxItems = &v\n\treturn s\n}", "func (o *GetComplianceByResourceTypesParams) SetMaxItems(maxItems *int64) {\n\to.MaxItems = maxItems\n}", "func (it *Item) ID() int64 { return it.id }", "func GetMaxBlockSize() int64 {\r\n\treturn converter.StrToInt64(SysString(MaxBlockSize))\r\n}", "func MaxI(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}", "func (t *MedLabPharmaChaincode) GetMaxIDValue(stub shim.ChaincodeStubInterface) ([]byte, error) {\n\tvar jsonResp string\n\tvar err error\n\tConMaxAsbytes, err := stub.GetState(UNIQUE_ID_COUNTER)\n\tif err != nil {\n\t\tjsonResp = \"{\\\"Error\\\":\\\"Failed to get state for ContainerMaxNumber \\\"}\"\n\t\treturn nil, errors.New(jsonResp)\n\t}\n\treturn ConMaxAsbytes, nil\n}", "func (h *binaryHeap) GetMax() int {\n\tmax := h.items[0]\n\th.items[0], h.items[h.size-1] = h.items[h.size-1], 0\n\th.size--\n\th.siftdown(0)\n\treturn max\n}", "func (px *Paxos) Max() int {\n\t// Your code here.\n\treturn px.curMax\n}", "func MaxI64(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}", "func MaxI64(x, y int64) int64 {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}", "func (this *AllOne) GetMaxKey() string {\n\tif this.Head.Next != this.Tail {\n\t\tnmap := this.Head.Next.NodeMap\n\t\tret := \"\"\n\t\tfor k, _ := range nmap {\n\t\t\tret = k\n\t\t\tbreak\n\t\t}\n\t\treturn ret\n\t}\n\n\treturn \"\"\n}", "func assignAuctionId() (key int) {\n\tvar highestKey int\n\tfor _, auction := range auctions {\n\t\tif auction.Id > highestKey {\n\t\t\thighestKey = auction.Id\n\t\t}\n\t}\n\treturn highestKey + 1\n}", "func (this *AllOne) GetMaxKey() string {\n\tif this.head == nil {\n\t\treturn \"\"\n\t}\n\tfor k := range this.head.set {\n\t\treturn k\n\t}\n\treturn \"ERROR\"\n}", "func (tb *TimeBucket) Max() int64 { return tb.max }", "func assignBidId() (key int) {\n\tvar highestKey int\n\tfor _, bid := range bids {\n\t\tif bid.Id > highestKey {\n\t\t\thighestKey = bid.Id\n\t\t}\n\t}\n\treturn highestKey + 1\n}", "func (this *AllOne) GetMaxKey() string {\n\tif this.tail.pre != this.head {\n\t\tfor k := range this.tail.pre.keys {\n\t\t\treturn k\n\t\t}\n\t}\n\treturn \"\"\n}", "func (n *Node) Max() int {\n\tif n.Right == nil {\n\t\treturn n.Key\n\t}\n\n\treturn n.Right.Max()\n}", "func (q *SimpleQueue) getCurrentMaxExtID(source string) (extID int64, ok bool) {\n\tq.mxExt.DoGlobal(func() {\n\t\tif q.lastExtID != nil {\n\t\t\textID, ok = q.lastExtID[source]\n\t\t}\n\t})\n\n\treturn extID, ok\n}", "func (px *Paxos) Max() int {\n\t// Your code here.\n\treturn px.max_seq\n}", "func (px *Paxos) Max() int {\n\t// Your code here.\n\treturn px.max\n}", "func (m *ItemsMutator) MaxItems(v int) *ItemsMutator {\n\tm.proxy.maxItems = &v\n\treturn m\n}", "func (list Int64Set) Max() (result int64) {\n\treturn list.MaxBy(func(a int64, b int64) bool {\n\t\treturn a < b\n\t})\n}", "func (u *UserStories) GetMaxReadID() (value int, ok bool) {\n\tif u == nil {\n\t\treturn\n\t}\n\tif !u.Flags.Has(0) {\n\t\treturn value, false\n\t}\n\treturn u.MaxReadID, true\n}", "func (orderTree *OrderTree) MaxPrice() *big.Int {\n\tif orderTree.Depth() > 0 {\n\t\tif bytes, found := orderTree.PriceTree.GetMax(); found {\n\t\t\titem := orderTree.getOrderListItem(bytes)\n\t\t\tif item != nil {\n\t\t\t\treturn CloneBigInt(item.Price)\n\t\t\t}\n\t\t}\n\t}\n\treturn Zero()\n}", "func (px *Paxos) Max() int {\n\t// Your code here.\n\tmax := -1\n\thead := px.prepareStatus.Head\n\tfor head.Next != nil {\n\t\tstate := head.Next\n\t\tif max < state.Seq {\n\t\t\tmax = state.Seq\n\t\t}\n\t\thead = head.Next\n\t}\n\treturn max\n}", "func itemIDToWeaponID(itemID int) int {\n\tfor wid, w := range defs.Weapons {\n\t\tif itemID == w.ItemID {\n\t\t\treturn wid\n\t\t}\n\t}\n\n\treturn -1\n}", "func Imax(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}", "func Imax(a, b int) int {\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}", "func Max(key []byte, nodes []*memberlist.Node) (max *memberlist.Node) {\n\tmaxValue := big.NewInt(0)\n\n\tCompute(key, nodes, func(node *memberlist.Node, bi *big.Int) {\n\t\tif bi.Cmp(maxValue) == 1 {\n\t\t\tmaxValue = bi\n\t\t\tmax = node\n\t\t}\n\t})\n\n\treturn max\n}", "func (s *OverflowShelf) PopMax(temp string) (maxOrderID uuid.UUID, found bool, err error) {\n\tvar orders map[uuid.UUID]float32\n\torders, err = s.getOrders(temp)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif len(orders) == 0 {\n\t\t// no orders for temp, return not found.\n\t\treturn\n\t}\n\n\tmaxDecayRate := float32(-1)\n\n\t// O(n) scan is quick for small sets. When size gets bigger,\n\t// use priority queues instead of slices to Store the orders.\n\tfor orderID, decayRate := range orders {\n\t\tif decayRate > maxDecayRate {\n\t\t\tmaxDecayRate = decayRate\n\t\t\tmaxOrderID = orderID\n\t\t\tfound = true\n\t\t}\n\t}\n\n\tdelete(orders, maxOrderID)\n\treturn\n}", "func (this *ExDomain) GetMax() int {\n\tif this.IsEmpty() {\n\t\tlogger.If(\"Domain %s\", *this)\n\t\tdebug.PrintStack()\n\t\tpanic(\"GetMax on empty domain\")\n\t}\n\treturn this.Max\n}", "func (m *MailTips) GetMaxMessageSize()(*int32) {\n val, err := m.GetBackingStore().Get(\"maxMessageSize\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*int32)\n }\n return nil\n}", "func (px *Paxos) Max() int {\n\t//DPrintf(\"Max()\\n\")\n\treturn px.nseq\n}", "func (h *MaxHeap) Max() int {\n\tif h.IsEmpty() {\n\t\treturn -1\n\t}\n\treturn h.data[1]\n}", "func (u *UserStories) SetMaxReadID(value int) {\n\tu.Flags.Set(0)\n\tu.MaxReadID = value\n}", "func (d *Dropping) MaxSize() int {\n\treturn d.maxSize\n}", "func (px *Paxos) Max() int {\n\t// Your code here.\n\t// probably just return the max seq number from local state?\n\n\tpx.mu.Lock()\n\tdefer px.mu.Unlock()\n\treturn px.maxSeq\n}", "func (mw *MaxWriter) Max() int {\n\treturn mw.max\n}", "func GetMaxIndexKey(shardID uint64, key []byte) []byte {\n\tkey = getKeySlice(key, idKeyLength)\n\treturn getIDKey(maxIndexSuffix, shardID, key)\n}", "func (px *Paxos) Max() int {\n\t// Your code here.\n\treturn px.maxSeq\n}", "func (m *MessageReplies) GetReadMaxID() (value int, ok bool) {\n\tif m == nil {\n\t\treturn\n\t}\n\tif !m.Flags.Has(3) {\n\t\treturn value, false\n\t}\n\treturn m.ReadMaxID, true\n}", "func max(d dataSet) int {\n\treturn d[len(d)-1]\n}", "func (r *SlidingWindow) Max() int {return r.base + len(r.values) - 1}", "func maximize() int64 {\n\tmax := 0\n\tmaxItem := int64(0)\n\t// var cache Cache\n\n\t// The larger the cache, the faster it is. Even without a\n\t// cache, it's only around a second on a modern machine, so\n\t// not that big of a deal.\n\t// cache.init(10000)\n\n\tfor x := int64(1); x < 1000000; x++ {\n\t\tcount := collatz2(x)\n\t\t// count := cache.chainLen(x)\n\t\tif count > max {\n\t\t\tmax = count\n\t\t\tmaxItem = x\n\t\t}\n\t}\n\tfmt.Printf(\"%d, %d\\n\", maxItem, max)\n\treturn maxItem\n}", "func (me XsdGoPkgHasElems_MaxHeight) MaxHeightDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (j *DSRocketchat) ItemID(item interface{}) string {\n\tid, _ := Dig(item, []string{\"_id\"}, true, false)\n\treturn id.(string)\n}", "func Max(field string) *AggrItem {\n\treturn NewAggrItem(field, AggrMax, field)\n}", "func (t *Indexed) Max(i, j int) int {\n\treturn -1\n}", "func GetMaxDroplets(client *godo.Client, ctx context.Context) int {\n\tacc, _, _ := client.Account.Get(ctx)\n\treturn acc.DropletLimit\n}", "func (me XsdGoPkgHasElem_MaxHeight) MaxHeightDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func max(x int) int {\n\treturn 40 + x\n}", "func ItemID(name string) (string, error) {\n\t// the id of gold is the special string\n\tif name == ItemIDGold {\n\t\treturn name, nil\n\t}\n\n\t// if we have an entry for that item, use it\n\tif item, ok := itemIDs[strings.ToLower(name)]; ok {\n\t\treturn item, nil\n\t}\n\n\t// there was no entry for that name\n\treturn \"\", errors.New(\"I don't recognize this item: \" + name)\n}", "func (i *Item) ID() ID {\n\treturn i.id\n}", "func (it *Item) FeedID() int64 { return it.feedID }", "func (p *Policy) getMaxTransactionsPerBlock(ic *interop.Context, _ []stackitem.Item) stackitem.Item {\n\treturn stackitem.NewBigInteger(big.NewInt(int64(p.GetMaxTransactionsPerBlockInternal(ic.DAO))))\n}", "func (p *Policy) GetMaxBlockSizeInternal(dao dao.DAO) uint32 {\n\tp.lock.RLock()\n\tdefer p.lock.RUnlock()\n\tif p.isValid {\n\t\treturn p.maxBlockSize\n\t}\n\treturn p.getUint32WithKey(dao, maxBlockSizeKey)\n}", "func (prices *pricesVal) MaxPrice() int {\n\treturn prices.maxPrice\n}", "func MaxI(n ...int) int {\n\tmax := math.MinInt64\n\tfor _, v := range n {\n\t\tif v > max {\n\t\t\tmax = v\n\t\t}\n\t}\n\treturn max\n}", "func Max(Len int, Less func(i, j int) bool) int {\n\tmx := 0\n\tfor i := 1; i < Len; i++ {\n\t\tif Less(mx, i) {\n\t\t\tmx = i\n\t\t}\n\t}\n\treturn mx\n}", "func GetMaxBlockFuel() int64 {\r\n\treturn converter.StrToInt64(SysString(MaxBlockFuel))\r\n}", "func (b *JSONSchemaPropApplyConfiguration) WithMaxItems(value int64) *JSONSchemaPropApplyConfiguration {\n\tb.MaxItems = &value\n\treturn b\n}", "func opI64Max(expr *CXExpression, fp int) {\n\tinpV0 := ReadI64(fp, expr.Inputs[0])\n\tinpV1 := ReadI64(fp, expr.Inputs[1])\n\tif inpV1 > inpV0 {\n\t\tinpV0 = inpV1\n\t}\n\tWriteI64(GetOffset_i64(fp, expr.Outputs[0]), inpV0)\n}", "func (this *AllOne) GetMaxKey() string {\n if len(this.m) == 0{\n return \"\"\n }\n return this.g[this.max][1].k\n}", "func (px *Paxos) Max() int {\n\tpx.RLock()\n\tdefer px.RUnlock()\n\treturn px.maxSeq\n}", "func (self *Limits) Maximum() uint32 {\n\treturn uint32(self.inner().max)\n}", "func (v *VEBTree) Maximum() int {\n\treturn v.max\n}", "func (k Keeper) GetMaxAmount(ctx sdk.Context) sdk.Int {\n\tparams := k.GetParams(ctx)\n\treturn params.MaxAmount\n}", "func MaxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t} else {\n\t\treturn y\n\t}\n}", "func (c *Counter) Max() int64 { return c.max }", "func (px *Paxos) Max() int {\n\treturn px.maxSeq\n}", "func (sm *StackMax) Max() (int, error) {\n\tif sm.Empty() {\n\t\treturn -1, ErrstackEmpty\n\t}\n\treturn sm.maxer[sm.length-1], nil\n}", "func (p *Policy) setMaxBlockSize(ic *interop.Context, args []stackitem.Item) stackitem.Item {\n\tvalue := uint32(toBigInt(args[0]).Int64())\n\tif value > payload.MaxSize {\n\t\tpanic(fmt.Errorf(\"MaxBlockSize cannot be more than the maximum payload size = %d\", payload.MaxSize))\n\t}\n\tok, err := p.checkValidators(ic)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif !ok {\n\t\treturn stackitem.NewBool(false)\n\t}\n\tp.lock.Lock()\n\tdefer p.lock.Unlock()\n\terr = p.setUint32WithKey(ic.DAO, maxBlockSizeKey, value)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tp.isValid = false\n\treturn stackitem.NewBool(true)\n}", "func MaxInt(a, b int64) int64 {\n\n\tif a > b {\n\t\treturn a\n\t}\n\treturn b\n}", "func MaxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\treturn y\n}", "func maxI(a int, b int) (res int) {\n\tif a < b {\n\t\tres = b\n\t} else {\n\t\tres = a\n\t}\n\n\treturn\n}", "func (idx *Tree) MaxKey(searchPrefix []byte) (v uint64, ok bool) {\n\traw, _ := idx.partialSearch(searchPrefix)\n\tif raw == 0 {\n\t\treturn 0, false\n\t}\n\tif isLeaf(raw) {\n\t\treturn getLeafValue(raw), true\n\t}\n\t// now find the max\nsearchLoop:\n\tfor {\n\t\t_, node, count, prefixLen := explodeNode(raw)\n\t\tblock := int(node >> blockSlotsShift)\n\t\toffset := int(node & blockSlotsOffsetMask)\n\t\tdata := idx.blocks[block].data[offset:]\n\t\tvar prefixSlots int\n\t\tif prefixLen > 0 {\n\t\t\tif prefixLen == 255 {\n\t\t\t\tprefixLen = int(data[0])\n\t\t\t\tprefixSlots = (prefixLen + 15) >> 3\n\t\t\t} else {\n\t\t\t\tprefixSlots = (prefixLen + 7) >> 3\n\t\t\t}\n\t\t\tdata = data[prefixSlots:]\n\t\t}\n\t\tif count >= fullAllocFrom {\n\t\t\t// find max, iterate from top\n\t\t\tfor k := 255; k >= 0; k-- {\n\t\t\t\ta := atomic.LoadUint64(&data[k])\n\t\t\t\tif a != 0 {\n\t\t\t\t\tif isLeaf(a) {\n\t\t\t\t\t\treturn getLeafValue(a), true\n\t\t\t\t\t}\n\t\t\t\t\traw = a\n\t\t\t\t\tcontinue searchLoop\n\t\t\t\t}\n\t\t\t}\n\t\t\t// BUG: this might happen if all children in the node has been deleted, since we currently don't shrink node-256. we should go back in the tree!\n\t\t\treturn 0, false\n\t\t}\n\t\t// load the last child (since they are ordered)\n\t\ta := atomic.LoadUint64(&data[count-1])\n\t\tif isLeaf(a) {\n\t\t\treturn getLeafValue(a), true\n\t\t}\n\t\traw = a\n\t}\n}", "func MaxInt(x, y int) int {\n\tif x > y {\n\t\treturn x\n\t}\n\n\treturn y\n}", "func getMax() int {\n\n\t// These are arbitrary numbers\n\tdef := 100\n\tmin := 1\n\n\treader := r.NewReader(os.Stdin)\n\n\tfor {\n\t\tf.Printf(\"Please give a max value (>= %v) and press ENTER\\n\", min)\n\t\tf.Printf(\"Enter for default (Default = %v)\\n\", def)\n\n\t\ttext, _ := reader.ReadString('\\n')\n\t\ttext = ss.Replace(text, \"\\n\", \"\", -1)\n\n\t\tif text == \"\" {\n\t\t\treturn def\n\t\t}\n\n\t\tiTxt, err := scvt.Atoi(text)\n\t\tif iTxt < min {\n\t\t\tf.Printf(\"%v < %v, try again\\n\", iTxt, min)\n\t\t} else if err == nil {\n\t\t\treturn iTxt\n\t\t}\n\n\t\tf.Println(\"Please give a valid integer or no value for default\")\n\n\t}\n}" ]
[ "0.6239351", "0.62393034", "0.6184761", "0.6177771", "0.61411256", "0.5951838", "0.59276485", "0.5924461", "0.5894317", "0.5864182", "0.58507824", "0.5841664", "0.5819029", "0.57879007", "0.5785859", "0.5710718", "0.5693274", "0.5676167", "0.56462955", "0.56358624", "0.55982965", "0.5593892", "0.5591572", "0.5573422", "0.5564279", "0.5536613", "0.55114186", "0.5504773", "0.5473257", "0.54713935", "0.5458459", "0.5458459", "0.54558134", "0.54393303", "0.5425836", "0.5418179", "0.54168564", "0.54056025", "0.5395047", "0.5381739", "0.53810465", "0.53650147", "0.53597313", "0.53420585", "0.5339871", "0.53321105", "0.530738", "0.53048915", "0.52987784", "0.52987784", "0.5298236", "0.528819", "0.52871436", "0.52801645", "0.52755356", "0.52723783", "0.52706367", "0.52702034", "0.5264941", "0.52644604", "0.5258735", "0.525543", "0.5248233", "0.5248201", "0.524389", "0.52431494", "0.52378887", "0.5235779", "0.5230477", "0.5230243", "0.52297133", "0.5217335", "0.5214984", "0.5210735", "0.519585", "0.5191371", "0.517413", "0.51733595", "0.517309", "0.5171061", "0.5158012", "0.5149305", "0.5145765", "0.5144301", "0.51434046", "0.5141361", "0.5141007", "0.5133633", "0.51256275", "0.51209056", "0.51178896", "0.511402", "0.5112235", "0.51056516", "0.51036346", "0.50854677", "0.5082091", "0.50800127", "0.5077536", "0.5074298" ]
0.86796016
0
Deprecated: Use Message.ProtoReflect.Descriptor instead.
func (*Message) Descriptor() ([]byte, []int) { return file_helloworld_helloworld_proto_rawDescGZIP(), []int{0} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ProtoFromMessageDescriptor(d protoreflect.MessageDescriptor) *descriptorpb.DescriptorProto {\n\ttype canProto interface {\n\t\tMessageDescriptorProto() *descriptorpb.DescriptorProto\n\t}\n\tif res, ok := d.(canProto); ok {\n\t\treturn res.MessageDescriptorProto()\n\t}\n\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\tif md, ok := res.AsProto().(*descriptorpb.DescriptorProto); ok {\n\t\t\treturn md\n\t\t}\n\t}\n\treturn protodesc.ToDescriptorProto(d)\n}", "func ProtoFromDescriptor(d protoreflect.Descriptor) proto.Message {\n\tswitch d := d.(type) {\n\tcase protoreflect.FileDescriptor:\n\t\treturn ProtoFromFileDescriptor(d)\n\tcase protoreflect.MessageDescriptor:\n\t\treturn ProtoFromMessageDescriptor(d)\n\tcase protoreflect.FieldDescriptor:\n\t\treturn ProtoFromFieldDescriptor(d)\n\tcase protoreflect.OneofDescriptor:\n\t\treturn ProtoFromOneofDescriptor(d)\n\tcase protoreflect.EnumDescriptor:\n\t\treturn ProtoFromEnumDescriptor(d)\n\tcase protoreflect.EnumValueDescriptor:\n\t\treturn ProtoFromEnumValueDescriptor(d)\n\tcase protoreflect.ServiceDescriptor:\n\t\treturn ProtoFromServiceDescriptor(d)\n\tcase protoreflect.MethodDescriptor:\n\t\treturn ProtoFromMethodDescriptor(d)\n\tdefault:\n\t\t// WTF??\n\t\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\t\treturn res.AsProto()\n\t\t}\n\t\treturn nil\n\t}\n}", "func ToDescriptorProto(message protoreflect.MessageDescriptor) *descriptorpb.DescriptorProto {\n\tp := &descriptorpb.DescriptorProto{\n\t\tName: proto.String(string(message.Name())),\n\t\tOptions: proto.Clone(message.Options()).(*descriptorpb.MessageOptions),\n\t}\n\tfor i, fields := 0, message.Fields(); i < fields.Len(); i++ {\n\t\tp.Field = append(p.Field, ToFieldDescriptorProto(fields.Get(i)))\n\t}\n\tfor i, exts := 0, message.Extensions(); i < exts.Len(); i++ {\n\t\tp.Extension = append(p.Extension, ToFieldDescriptorProto(exts.Get(i)))\n\t}\n\tfor i, messages := 0, message.Messages(); i < messages.Len(); i++ {\n\t\tp.NestedType = append(p.NestedType, ToDescriptorProto(messages.Get(i)))\n\t}\n\tfor i, enums := 0, message.Enums(); i < enums.Len(); i++ {\n\t\tp.EnumType = append(p.EnumType, ToEnumDescriptorProto(enums.Get(i)))\n\t}\n\tfor i, xranges := 0, message.ExtensionRanges(); i < xranges.Len(); i++ {\n\t\txrange := xranges.Get(i)\n\t\tp.ExtensionRange = append(p.ExtensionRange, &descriptorpb.DescriptorProto_ExtensionRange{\n\t\t\tStart: proto.Int32(int32(xrange[0])),\n\t\t\tEnd: proto.Int32(int32(xrange[1])),\n\t\t\tOptions: proto.Clone(message.ExtensionRangeOptions(i)).(*descriptorpb.ExtensionRangeOptions),\n\t\t})\n\t}\n\tfor i, oneofs := 0, message.Oneofs(); i < oneofs.Len(); i++ {\n\t\tp.OneofDecl = append(p.OneofDecl, ToOneofDescriptorProto(oneofs.Get(i)))\n\t}\n\tfor i, ranges := 0, message.ReservedRanges(); i < ranges.Len(); i++ {\n\t\trrange := ranges.Get(i)\n\t\tp.ReservedRange = append(p.ReservedRange, &descriptorpb.DescriptorProto_ReservedRange{\n\t\t\tStart: proto.Int32(int32(rrange[0])),\n\t\t\tEnd: proto.Int32(int32(rrange[1])),\n\t\t})\n\t}\n\tfor i, names := 0, message.ReservedNames(); i < names.Len(); i++ {\n\t\tp.ReservedName = append(p.ReservedName, string(names.Get(i)))\n\t}\n\treturn p\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_google_ai_generativelanguage_v1beta2_discuss_service_proto_rawDescGZIP(), []int{2}\n}", "func (x *fastReflection_MsgUpdateParams) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_MsgUpdateParams\n}", "func (*Message6024) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{26}\n}", "func ProtoFromMethodDescriptor(d protoreflect.MethodDescriptor) *descriptorpb.MethodDescriptorProto {\n\ttype canProto interface {\n\t\tMethodDescriptorProto() *descriptorpb.MethodDescriptorProto\n\t}\n\tif res, ok := d.(canProto); ok {\n\t\treturn res.MethodDescriptorProto()\n\t}\n\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\tif md, ok := res.AsProto().(*descriptorpb.MethodDescriptorProto); ok {\n\t\t\treturn md\n\t\t}\n\t}\n\treturn protodesc.ToMethodDescriptorProto(d)\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{7}\n}", "func (*Embed) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{2}\n}", "func (SVC_Messages) EnumDescriptor() ([]byte, []int) {\n\treturn file_netmessages_proto_rawDescGZIP(), []int{4}\n}", "func (*Message12796) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{1}\n}", "func (SVC_Messages) EnumDescriptor() ([]byte, []int) {\n\treturn file_csgo_netmessages_proto_rawDescGZIP(), []int{4}\n}", "func ProtoFromFieldDescriptor(d protoreflect.FieldDescriptor) *descriptorpb.FieldDescriptorProto {\n\ttype canProto interface {\n\t\tFieldDescriptorProto() *descriptorpb.FieldDescriptorProto\n\t}\n\tif res, ok := d.(canProto); ok {\n\t\treturn res.FieldDescriptorProto()\n\t}\n\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\tif fd, ok := res.AsProto().(*descriptorpb.FieldDescriptorProto); ok {\n\t\t\treturn fd\n\t\t}\n\t}\n\treturn protodesc.ToFieldDescriptorProto(d)\n}", "func (*Message12818) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{5}\n}", "func (*Message7928) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{18}\n}", "func (*Message7920) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{20}\n}", "func (*Message7511) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{16}\n}", "func (*AddPeerRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{8}\n}", "func (*GetMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{11}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_toit_model_pubsub_message_proto_rawDescGZIP(), []int{2}\n}", "func (*DownlinkMessage) Descriptor() ([]byte, []int) {\n\treturn file_ttn_lorawan_v3_messages_proto_rawDescGZIP(), []int{1}\n}", "func (*Message7921) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{19}\n}", "func (*Message5903) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{34}\n}", "func (*Message3920) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{17}\n}", "func (*GenerateMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_ai_generativelanguage_v1beta2_discuss_service_proto_rawDescGZIP(), []int{0}\n}", "func (*DeleteMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{13}\n}", "func (*Message6127) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{24}\n}", "func (*Message12817) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{22}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_pkg_proto_l3_proto_rawDescGZIP(), []int{0}\n}", "func ProtoFromFileDescriptor(d protoreflect.FileDescriptor) *descriptorpb.FileDescriptorProto {\n\tif imp, ok := d.(protoreflect.FileImport); ok {\n\t\td = imp.FileDescriptor\n\t}\n\ttype canProto interface {\n\t\tFileDescriptorProto() *descriptorpb.FileDescriptorProto\n\t}\n\tif res, ok := d.(canProto); ok {\n\t\treturn res.FileDescriptorProto()\n\t}\n\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\tif fd, ok := res.AsProto().(*descriptorpb.FileDescriptorProto); ok {\n\t\t\treturn fd\n\t\t}\n\t}\n\treturn protodesc.ToFileDescriptorProto(d)\n}", "func (*Embed_EmbedField) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{2, 1}\n}", "func (*AnalysisMessageWeakSchema) Descriptor() ([]byte, []int) {\n\treturn file_analysis_v1alpha1_message_proto_rawDescGZIP(), []int{1}\n}", "func (x *fastReflection_Metadata) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_Metadata\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_chat_proto_rawDescGZIP(), []int{2}\n}", "func (CLC_Messages) EnumDescriptor() ([]byte, []int) {\n\treturn file_csgo_netmessages_proto_rawDescGZIP(), []int{1}\n}", "func (*Message5867) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{29}\n}", "func (CLC_Messages) EnumDescriptor() ([]byte, []int) {\n\treturn file_netmessages_proto_rawDescGZIP(), []int{1}\n}", "func (*Message6578) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{7}\n}", "func (*Message6108) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{31}\n}", "func (*MessageWithId) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{8}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_toit_api_data_proto_rawDescGZIP(), []int{1}\n}", "func (*FormatMessage) Descriptor() ([]byte, []int) {\n\treturn file_google_devtools_clouddebugger_v2_data_proto_rawDescGZIP(), []int{0}\n}", "func (*Message7919) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{21}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_messages_proto_rawDescGZIP(), []int{2}\n}", "func (*MyProto) Descriptor() ([]byte, []int) {\n\treturn file_my_proto_proto_rawDescGZIP(), []int{0}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_proto_message_message_proto_rawDescGZIP(), []int{0}\n}", "func (*Message5908) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{13}\n}", "func (x *fastReflection_ServiceCommandDescriptor) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_ServiceCommandDescriptor\n}", "func (*EnumMessage) Descriptor() ([]byte, []int) {\n\treturn file_enum_enum_example_proto_rawDescGZIP(), []int{0}\n}", "func (x *fastReflection_EventReceive) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_EventReceive\n}", "func (*Proto3Message) Descriptor() ([]byte, []int) {\n\treturn file_runtime_internal_examplepb_proto3_proto_rawDescGZIP(), []int{0}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_Forum_proto_rawDescGZIP(), []int{2}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_chat_proto_rawDescGZIP(), []int{0}\n}", "func (x *fastReflection_Params) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_Params\n}", "func (*Primitive) Descriptor() ([]byte, []int) {\n\treturn file_messages_proto_rawDescGZIP(), []int{15}\n}", "func (*Message5907) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{32}\n}", "func (*GetChannelMessagesRequest) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{9}\n}", "func (*Message12821) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{2}\n}", "func (*TraceProto) Descriptor() ([]byte, []int) {\n\treturn file_internal_tracing_extended_extended_trace_proto_rawDescGZIP(), []int{0}\n}", "func (*MsgWithRequiredBytes) Descriptor() ([]byte, []int) {\n\treturn file_jsonpb_proto_test2_proto_rawDescGZIP(), []int{11}\n}", "func (*Messages) Descriptor() ([]byte, []int) {\n\treturn file_proto_model_v1_archive_proto_rawDescGZIP(), []int{1}\n}", "func (x *fastReflection_FlagOptions) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_FlagOptions\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_proto_service_proto_rawDescGZIP(), []int{1}\n}", "func (*Message7865) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{15}\n}", "func (x *fastReflection_Evidence) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_Evidence\n}", "func (*Message12774) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{0}\n}", "func (*Msg) Descriptor() ([]byte, []int) {\n\treturn file_chatMsg_msg_proto_rawDescGZIP(), []int{1}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_uni_proto_rawDescGZIP(), []int{9}\n}", "func LegacyLoadMessageDesc(t reflect.Type) protoreflect.MessageDescriptor {\n\treturn legacyLoadMessageDesc(t, \"\")\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_messages_proto_rawDescGZIP(), []int{0}\n}", "func (*NetProtoTalker) Descriptor() ([]byte, []int) {\n\treturn file_pkg_smgrpc_smgrpc_proto_rawDescGZIP(), []int{1}\n}", "func (*Message6107) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{11}\n}", "func (*Message6126) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{8}\n}", "func (NET_Messages) EnumDescriptor() ([]byte, []int) {\n\treturn file_netmessages_proto_rawDescGZIP(), []int{0}\n}", "func (x *fastReflection_MsgUpdateParamsResponse) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_MsgUpdateParamsResponse\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_api_protobuf_spec_example_example_proto_rawDescGZIP(), []int{0}\n}", "func (*Message12820) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{3}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_api_proto_rawDescGZIP(), []int{4}\n}", "func (*Message12819) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{4}\n}", "func (NET_Messages) EnumDescriptor() ([]byte, []int) {\n\treturn file_csgo_netmessages_proto_rawDescGZIP(), []int{0}\n}", "func (*MessageInfo) Descriptor() ([]byte, []int) {\n\treturn file_TSPArchiveMessages_proto_rawDescGZIP(), []int{1}\n}", "func (*BroadcastMsg) Descriptor() ([]byte, []int) {\n\treturn file_proto_rpc_rpc_proto_rawDescGZIP(), []int{1}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_proto_threads_proto_rawDescGZIP(), []int{1}\n}", "func (*MsgWithIndirectRequired) Descriptor() ([]byte, []int) {\n\treturn file_jsonpb_proto_test2_proto_rawDescGZIP(), []int{10}\n}", "func (*CMsgClientToGCPlayerStatsRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{143}\n}", "func (*Messages) Descriptor() ([]byte, []int) {\n\treturn file_Forum_proto_rawDescGZIP(), []int{3}\n}", "func (*Message6052) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{25}\n}", "func (*Listen) Descriptor() ([]byte, []int) {\n\treturn file_pkg_smgrpc_smgrpc_proto_rawDescGZIP(), []int{4}\n}", "func (*ListMessagesRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_threads_proto_rawDescGZIP(), []int{14}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_protos_addressbook_proto_rawDescGZIP(), []int{0}\n}", "func (*Message10319) Descriptor() ([]byte, []int) {\n\treturn file_datasets_google_message4_benchmark_message4_2_proto_rawDescGZIP(), []int{6}\n}", "func (*CMsgInspectElement) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{145}\n}", "func (*PatchCollectorsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{161}\n}", "func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.FieldDescriptorProto {\n\tp := &descriptorpb.FieldDescriptorProto{\n\t\tName: proto.String(string(field.Name())),\n\t\tNumber: proto.Int32(int32(field.Number())),\n\t\tLabel: descriptorpb.FieldDescriptorProto_Label(field.Cardinality()).Enum(),\n\t\tOptions: proto.Clone(field.Options()).(*descriptorpb.FieldOptions),\n\t}\n\tif field.IsExtension() {\n\t\tp.Extendee = fullNameOf(field.ContainingMessage())\n\t}\n\tif field.Kind().IsValid() {\n\t\tp.Type = descriptorpb.FieldDescriptorProto_Type(field.Kind()).Enum()\n\t}\n\tif field.Enum() != nil {\n\t\tp.TypeName = fullNameOf(field.Enum())\n\t}\n\tif field.Message() != nil {\n\t\tp.TypeName = fullNameOf(field.Message())\n\t}\n\tif field.HasJSONName() {\n\t\t// A bug in older versions of protoc would always populate the\n\t\t// \"json_name\" option for extensions when it is meaningless.\n\t\t// When it did so, it would always use the camel-cased field name.\n\t\tif field.IsExtension() {\n\t\t\tp.JsonName = proto.String(strs.JSONCamelCase(string(field.Name())))\n\t\t} else {\n\t\t\tp.JsonName = proto.String(field.JSONName())\n\t\t}\n\t}\n\tif field.Syntax() == protoreflect.Proto3 && field.HasOptionalKeyword() {\n\t\tp.Proto3Optional = proto.Bool(true)\n\t}\n\tif field.HasDefault() {\n\t\tdef, err := defval.Marshal(field.Default(), field.DefaultEnumValue(), field.Kind(), defval.Descriptor)\n\t\tif err != nil && field.DefaultEnumValue() != nil {\n\t\t\tdef = string(field.DefaultEnumValue().Name()) // occurs for unresolved enum values\n\t\t} else if err != nil {\n\t\t\tpanic(fmt.Sprintf(\"%v: %v\", field.FullName(), err))\n\t\t}\n\t\tp.DefaultValue = proto.String(def)\n\t}\n\tif oneof := field.ContainingOneof(); oneof != nil {\n\t\tp.OneofIndex = proto.Int32(int32(oneof.Index()))\n\t}\n\treturn p\n}", "func (*Msg) Descriptor() ([]byte, []int) {\n\treturn file_msgs_msgs_proto_rawDescGZIP(), []int{10}\n}", "func (*Persistent) Descriptor() ([]byte, []int) {\n\treturn file_msgs_msgs_proto_rawDescGZIP(), []int{2}\n}", "func (*PatchMessageParams) Descriptor() ([]byte, []int) {\n\treturn file_message_proto_rawDescGZIP(), []int{3}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_api_proto_rawDescGZIP(), []int{2}\n}", "func (*SendMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{17}\n}", "func (*Message) Descriptor() ([]byte, []int) {\n\treturn file_Notification_proto_rawDescGZIP(), []int{0}\n}" ]
[ "0.73437", "0.7334874", "0.72949165", "0.7105766", "0.705134", "0.6988509", "0.6962971", "0.6912535", "0.68644553", "0.6860742", "0.6847173", "0.68470645", "0.6837926", "0.6823334", "0.6817079", "0.68159", "0.681522", "0.6815156", "0.68004847", "0.6800211", "0.6799987", "0.6798324", "0.67941636", "0.67922896", "0.67907196", "0.678807", "0.67704815", "0.67595524", "0.6757552", "0.6757401", "0.67569315", "0.67534673", "0.6745547", "0.6745445", "0.67425954", "0.6742378", "0.6741404", "0.6734923", "0.67315763", "0.6731005", "0.67230976", "0.6722658", "0.6722348", "0.67190427", "0.6717899", "0.67127866", "0.6712572", "0.6706402", "0.67032063", "0.6702801", "0.6701156", "0.6697816", "0.66963303", "0.6692776", "0.6691909", "0.6691609", "0.66891754", "0.66890717", "0.66827506", "0.66785437", "0.66781884", "0.66773045", "0.6673258", "0.66671175", "0.6664727", "0.666458", "0.66623455", "0.66615766", "0.66607356", "0.6655626", "0.66535825", "0.66535103", "0.665178", "0.6647629", "0.66468924", "0.66395247", "0.663796", "0.66347146", "0.6633747", "0.6632332", "0.66316265", "0.66250956", "0.66230583", "0.6621634", "0.6614321", "0.6613191", "0.6608031", "0.66078335", "0.66056544", "0.660388", "0.66014266", "0.6599959", "0.6598348", "0.6597785", "0.6595929", "0.6594797", "0.65869445", "0.65836155", "0.65798414", "0.6579573" ]
0.6785783
26
Deprecated: Use CodeRequest.ProtoReflect.Descriptor instead.
func (*CodeRequest) Descriptor() ([]byte, []int) { return file_helloworld_helloworld_proto_rawDescGZIP(), []int{1} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (*CodeLensRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{163}\n}", "func (*PatchCollectorsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{161}\n}", "func (*ModifyRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_engine_proto_rawDescGZIP(), []int{10}\n}", "func (*CodeActionRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{157}\n}", "func (*CheckCodeRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_verifycode_pb_request_proto_rawDescGZIP(), []int{2}\n}", "func (*AddPeerRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{8}\n}", "func (*GetForgetPasswordCodeRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_sms_sms_proto_rawDescGZIP(), []int{2}\n}", "func (*GetServiceRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_appengine_v1_appengine_proto_rawDescGZIP(), []int{6}\n}", "func (*GetPeerInfoRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{6}\n}", "func (*CMsgGCPlayerInfoRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{117}\n}", "func (*UpdatePermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_role_pb_request_proto_rawDescGZIP(), []int{9}\n}", "func (*IssueCodeRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_verifycode_pb_request_proto_rawDescGZIP(), []int{0}\n}", "func (*DescribePermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_role_pb_request_proto_rawDescGZIP(), []int{6}\n}", "func (*PatchAnnotationsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{4}\n}", "func (*ChangeRequest) Descriptor() ([]byte, []int) {\n\treturn file_authorization_proto_rawDescGZIP(), []int{0}\n}", "func (*DiagnoseRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_api_proto_rawDescGZIP(), []int{16}\n}", "func (*CodeLensResolveRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{33}\n}", "func (*CMsgClientToGCPlayerStatsRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{143}\n}", "func (*GetRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_comments_proto_rawDescGZIP(), []int{3}\n}", "func (*DebugInstanceRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_appengine_v1_appengine_proto_rawDescGZIP(), []int{19}\n}", "func (*CreateAlterRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_exercicio_proto_rawDescGZIP(), []int{1}\n}", "func (*CodeGeneratorRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_protobuf_compiler_plugin_proto_rawDescGZIP(), []int{1}\n}", "func (*DescribeRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_engine_proto_rawDescGZIP(), []int{4}\n}", "func ProtoFromDescriptor(d protoreflect.Descriptor) proto.Message {\n\tswitch d := d.(type) {\n\tcase protoreflect.FileDescriptor:\n\t\treturn ProtoFromFileDescriptor(d)\n\tcase protoreflect.MessageDescriptor:\n\t\treturn ProtoFromMessageDescriptor(d)\n\tcase protoreflect.FieldDescriptor:\n\t\treturn ProtoFromFieldDescriptor(d)\n\tcase protoreflect.OneofDescriptor:\n\t\treturn ProtoFromOneofDescriptor(d)\n\tcase protoreflect.EnumDescriptor:\n\t\treturn ProtoFromEnumDescriptor(d)\n\tcase protoreflect.EnumValueDescriptor:\n\t\treturn ProtoFromEnumValueDescriptor(d)\n\tcase protoreflect.ServiceDescriptor:\n\t\treturn ProtoFromServiceDescriptor(d)\n\tcase protoreflect.MethodDescriptor:\n\t\treturn ProtoFromMethodDescriptor(d)\n\tdefault:\n\t\t// WTF??\n\t\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\t\treturn res.AsProto()\n\t\t}\n\t\treturn nil\n\t}\n}", "func (*ChaincodeRequestMessage) Descriptor() ([]byte, []int) {\n\treturn file_fpc_fpc_proto_rawDescGZIP(), []int{6}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_helloworld_helloworld_proto_rawDescGZIP(), []int{2}\n}", "func (*PaqueteRequest) Descriptor() ([]byte, []int) {\n\treturn file_helloworld_helloworld_proto_rawDescGZIP(), []int{2}\n}", "func (*PatchKeysRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{74}\n}", "func (*ValidateRequest) Descriptor() ([]byte, []int) {\n\treturn file_protobuf_clusrun_proto_rawDescGZIP(), []int{17}\n}", "func (*WebhookRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_dialogflow_v2beta1_webhook_proto_rawDescGZIP(), []int{0}\n}", "func (*CMsgProfileRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{275}\n}", "func (*PatchConceptLanguagesRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{50}\n}", "func (*FeedbackRequest) Descriptor() ([]byte, []int) {\n\treturn file_ssn_dataservice_v1_dataservice_proto_rawDescGZIP(), []int{10}\n}", "func (*TelemetryRequest) Descriptor() ([]byte, []int) {\n\treturn file_interservice_license_control_license_control_proto_rawDescGZIP(), []int{11}\n}", "func (*OriginalDetectIntentRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_dialogflow_v2beta1_webhook_proto_rawDescGZIP(), []int{2}\n}", "func (*ListenRequest) Descriptor() ([]byte, []int) {\n\treturn file_faultinjector_proto_rawDescGZIP(), []int{8}\n}", "func (*ModelControlRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_service_proto_rawDescGZIP(), []int{4}\n}", "func (*AddPermissionToRoleRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_role_pb_request_proto_rawDescGZIP(), []int{7}\n}", "func (*QueryPermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_permission_pb_request_proto_rawDescGZIP(), []int{0}\n}", "func (*CMsgClientToGCGetTicketCodesRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{359}\n}", "func (*LogMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{59}\n}", "func (*GenerateMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_ai_generativelanguage_v1beta2_discuss_service_proto_rawDescGZIP(), []int{0}\n}", "func (*AddRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_calculator_proto_calc_proto_rawDescGZIP(), []int{0}\n}", "func (*ChangeRequest) Descriptor() ([]byte, []int) {\n\treturn file_management_proto_rawDescGZIP(), []int{2}\n}", "func (*ChangeRequest) Descriptor() ([]byte, []int) {\n\treturn file_management_proto_rawDescGZIP(), []int{2}\n}", "func (*WatchRequestTypeProto) Descriptor() ([]byte, []int) {\n\treturn file_raft_proto_rawDescGZIP(), []int{25}\n}", "func (*ValidateClientCredentialRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_micro_pb_request_proto_rawDescGZIP(), []int{0}\n}", "func (*UpdateRequest) Descriptor() ([]byte, []int) {\n\treturn file_teams_v1_teams_proto_rawDescGZIP(), []int{5}\n}", "func (*LanguageDetectorRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_language_proto_rawDescGZIP(), []int{1}\n}", "func (*CancelDelegationTokenRequestProto) Descriptor() ([]byte, []int) {\n\treturn file_Security_proto_rawDescGZIP(), []int{7}\n}", "func (*GetVersionRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{9}\n}", "func (*ProofRequest) Descriptor() ([]byte, []int) {\n\treturn file_messages_proto_rawDescGZIP(), []int{35}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_pkg_smgrpc_smgrpc_proto_rawDescGZIP(), []int{0}\n}", "func (*TypeDefinitionRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{133}\n}", "func (*ImplementationRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{137}\n}", "func (*CodeLens) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{164}\n}", "func (*Code) Descriptor() ([]byte, []int) {\n\treturn file_internal_pkg_pb_ports_proto_rawDescGZIP(), []int{2}\n}", "func (*UpdateDomainMappingRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_appengine_v1_appengine_proto_rawDescGZIP(), []int{40}\n}", "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_dictybase_api_jsonapi_request_proto_rawDescGZIP(), []int{7}\n}", "func (x *fastReflection_AddressStringToBytesRequest) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_AddressStringToBytesRequest\n}", "func (*MyScopesRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{109}\n}", "func (*CheckPermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_permission_pb_request_proto_rawDescGZIP(), []int{2}\n}", "func (*GeneratedRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_auth_proto_rawDescGZIP(), []int{0}\n}", "func (*GetStatusCodeRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{26}\n}", "func (*QueryPermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_role_pb_request_proto_rawDescGZIP(), []int{5}\n}", "func (*GetDelegationTokenRequestProto) Descriptor() ([]byte, []int) {\n\treturn file_Security_proto_rawDescGZIP(), []int{3}\n}", "func (*DeleteMicroRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_micro_pb_request_proto_rawDescGZIP(), []int{4}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_api_protobuf_spec_example_example_proto_rawDescGZIP(), []int{1}\n}", "func (*ContractQueryRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{22}\n}", "func (*UpdateRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_contact_proto_rawDescGZIP(), []int{12}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_msgs_msgs_proto_rawDescGZIP(), []int{14}\n}", "func (*DefinitionRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{129}\n}", "func (*CleartextChaincodeRequest) Descriptor() ([]byte, []int) {\n\treturn file_fpc_fpc_proto_rawDescGZIP(), []int{5}\n}", "func (*RefreshRequest) Descriptor() ([]byte, []int) {\n\treturn file_cloudprovider_externalgrpc_protos_externalgrpc_proto_rawDescGZIP(), []int{16}\n}", "func (*QueryApprovedChaincodeDefinitionRequest) Descriptor() ([]byte, []int) {\n\treturn file_lifecycle_proto_rawDescGZIP(), []int{1}\n}", "func ProtoFromMethodDescriptor(d protoreflect.MethodDescriptor) *descriptorpb.MethodDescriptorProto {\n\ttype canProto interface {\n\t\tMethodDescriptorProto() *descriptorpb.MethodDescriptorProto\n\t}\n\tif res, ok := d.(canProto); ok {\n\t\treturn res.MethodDescriptorProto()\n\t}\n\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\tif md, ok := res.AsProto().(*descriptorpb.MethodDescriptorProto); ok {\n\t\t\treturn md\n\t\t}\n\t}\n\treturn protodesc.ToMethodDescriptorProto(d)\n}", "func (*UpdateTelemetryReportedRequest) Descriptor() ([]byte, []int) {\n\treturn file_external_applications_applications_proto_rawDescGZIP(), []int{29}\n}", "func (*CMsgLoadedRequest) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{46}\n}", "func (*CheckRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_api_servicecontrol_v1_service_controller_proto_rawDescGZIP(), []int{0}\n}", "func (*GetCollectorRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{163}\n}", "func (*FindWebhookCallRequest) Descriptor() ([]byte, []int) {\n\treturn file_events_Event_proto_rawDescGZIP(), []int{9}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_Trd_ModifyOrder_proto_rawDescGZIP(), []int{2}\n}", "func (*DescribeMicroRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_micro_pb_request_proto_rawDescGZIP(), []int{3}\n}", "func (x *fastReflection_QueryParamsRequest) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_QueryParamsRequest\n}", "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_exercicio_proto_rawDescGZIP(), []int{7}\n}", "func (*CMsgSocialFeedRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{304}\n}", "func (*CalculatorRequest) Descriptor() ([]byte, []int) {\n\treturn file_basicpb_unary_api_proto_rawDescGZIP(), []int{4}\n}", "func (*FindWebhookCallRequest) Descriptor() ([]byte, []int) {\n\treturn file_uac_Event_proto_rawDescGZIP(), []int{7}\n}", "func (*AddProducerRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{2}\n}", "func (*DeclarationRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{125}\n}", "func (*RevokeJobRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_noderpc_proto_feeds_manager_proto_rawDescGZIP(), []int{20}\n}", "func (*RenameRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{194}\n}", "func (*DecodeRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_videoservice_proto_rawDescGZIP(), []int{0}\n}", "func (*AddRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_calculate_proto_rawDescGZIP(), []int{3}\n}", "func (*MetricsRequest) Descriptor() ([]byte, []int) {\n\treturn file_ssn_dataservice_v1_dataservice_proto_rawDescGZIP(), []int{11}\n}", "func (*ReferenceRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{141}\n}", "func (*SendRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{5}\n}", "func (*Decl) Descriptor() ([]byte, []int) {\n\treturn file_google_api_expr_v1alpha1_checked_proto_rawDescGZIP(), []int{2}\n}", "func (*SetTraceRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{8}\n}", "func (*NetworkRequest) Descriptor() ([]byte, []int) {\n\treturn file_packetbroker_api_iam_v1_service_proto_rawDescGZIP(), []int{6}\n}" ]
[ "0.72352815", "0.71125454", "0.7089678", "0.7086867", "0.7050585", "0.7002672", "0.69934523", "0.6932713", "0.69018894", "0.68992066", "0.6889897", "0.68843466", "0.68616295", "0.6860479", "0.68583477", "0.68542755", "0.68515146", "0.6844837", "0.68435585", "0.6838578", "0.68279165", "0.68257856", "0.68230885", "0.6814507", "0.68032366", "0.6799875", "0.6798857", "0.6787944", "0.67836297", "0.677801", "0.67777133", "0.67767936", "0.6776047", "0.67755157", "0.67739105", "0.67643535", "0.67641044", "0.67637247", "0.676336", "0.67589575", "0.6750674", "0.6748732", "0.67457783", "0.6737806", "0.6737806", "0.67358387", "0.67310023", "0.67291534", "0.67226034", "0.67149603", "0.6712012", "0.6711523", "0.6711229", "0.6711218", "0.67094207", "0.6708658", "0.6707676", "0.67048305", "0.6702518", "0.6702143", "0.670187", "0.6701216", "0.66974145", "0.6693809", "0.66901326", "0.6689402", "0.6686492", "0.66860443", "0.6686017", "0.66831654", "0.668153", "0.6679004", "0.66787153", "0.6677128", "0.66711944", "0.6670137", "0.66698956", "0.66693234", "0.6667155", "0.66627914", "0.6662002", "0.6661765", "0.6659236", "0.6657915", "0.6655817", "0.66501164", "0.66496235", "0.66494566", "0.66485864", "0.6647491", "0.6647178", "0.6644239", "0.6643388", "0.66410524", "0.6640359", "0.6636183", "0.6632871", "0.66271204", "0.6624793", "0.66244084" ]
0.72652876
0
Deprecated: Use PaqueteRequest.ProtoReflect.Descriptor instead.
func (*PaqueteRequest) Descriptor() ([]byte, []int) { return file_helloworld_helloworld_proto_rawDescGZIP(), []int{2} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (*ModifyRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_engine_proto_rawDescGZIP(), []int{10}\n}", "func (*PatchCollectorsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{161}\n}", "func (*AddPeerRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{8}\n}", "func (*UpdatePermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_role_pb_request_proto_rawDescGZIP(), []int{9}\n}", "func (*CreateAlterRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_exercicio_proto_rawDescGZIP(), []int{1}\n}", "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_dictybase_api_jsonapi_request_proto_rawDescGZIP(), []int{7}\n}", "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_exercicio_proto_rawDescGZIP(), []int{7}\n}", "func (*DescribePermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_role_pb_request_proto_rawDescGZIP(), []int{6}\n}", "func (*GetPeerInfoRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{6}\n}", "func (x *fastReflection_QueryParamsRequest) Descriptor() protoreflect.MessageDescriptor {\n\treturn md_QueryParamsRequest\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_msgs_msgs_proto_rawDescGZIP(), []int{14}\n}", "func (*QueryPermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_permission_pb_request_proto_rawDescGZIP(), []int{0}\n}", "func (*RequestPresentationRequest) Descriptor() ([]byte, []int) {\n\treturn file_messages_proto_rawDescGZIP(), []int{0}\n}", "func (*PatchAnnotationsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{4}\n}", "func (*BatchUpdateReferencesRequest_Request) Descriptor() ([]byte, []int) {\n\treturn file_pkg_proto_icas_icas_proto_rawDescGZIP(), []int{1, 0}\n}", "func (*WebhookRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_dialogflow_v2beta1_webhook_proto_rawDescGZIP(), []int{0}\n}", "func (*ListenRequest) Descriptor() ([]byte, []int) {\n\treturn file_faultinjector_proto_rawDescGZIP(), []int{8}\n}", "func (*CodeLensRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{163}\n}", "func (*CMsgClientToGCPlayerStatsRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{143}\n}", "func (*DiagnoseRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_api_proto_rawDescGZIP(), []int{16}\n}", "func (*GetServiceRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_appengine_v1_appengine_proto_rawDescGZIP(), []int{6}\n}", "func (*FeedbackRequest) Descriptor() ([]byte, []int) {\n\treturn file_ssn_dataservice_v1_dataservice_proto_rawDescGZIP(), []int{10}\n}", "func (*CreatePermssionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_role_pb_request_proto_rawDescGZIP(), []int{1}\n}", "func (*LogMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{59}\n}", "func (*GetRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_comments_proto_rawDescGZIP(), []int{3}\n}", "func (*AddPermissionToRoleRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_role_pb_request_proto_rawDescGZIP(), []int{7}\n}", "func (*DescribeRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_engine_proto_rawDescGZIP(), []int{4}\n}", "func (*UpdateRequest) Descriptor() ([]byte, []int) {\n\treturn file_teams_v1_teams_proto_rawDescGZIP(), []int{5}\n}", "func (*GetRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_exercicio_proto_rawDescGZIP(), []int{3}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_ocis_messages_policies_v0_policies_proto_rawDescGZIP(), []int{2}\n}", "func (*AddProducerRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{2}\n}", "func (*AddRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_calculator_proto_calc_proto_rawDescGZIP(), []int{0}\n}", "func (*ValidateRequest) Descriptor() ([]byte, []int) {\n\treturn file_protobuf_clusrun_proto_rawDescGZIP(), []int{17}\n}", "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_teams_v1_teams_proto_rawDescGZIP(), []int{10}\n}", "func (*CheckPermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_permission_pb_request_proto_rawDescGZIP(), []int{2}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_api_protobuf_spec_example_example_proto_rawDescGZIP(), []int{1}\n}", "func (*CMsgGCPlayerInfoRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{117}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_helloworld_helloworld_proto_rawDescGZIP(), []int{2}\n}", "func (*CMsgProfileRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{275}\n}", "func (*ProofRequest) Descriptor() ([]byte, []int) {\n\treturn file_messages_proto_rawDescGZIP(), []int{35}\n}", "func (*GenerateMessageRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_ai_generativelanguage_v1beta2_discuss_service_proto_rawDescGZIP(), []int{0}\n}", "func (*LanguageDetectorRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_language_proto_rawDescGZIP(), []int{1}\n}", "func (*QueryPermissionRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_role_pb_request_proto_rawDescGZIP(), []int{5}\n}", "func (*DeleteMicroRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_micro_pb_request_proto_rawDescGZIP(), []int{4}\n}", "func (*ChangeRequest) Descriptor() ([]byte, []int) {\n\treturn file_authorization_proto_rawDescGZIP(), []int{0}\n}", "func (*PolicyRequest) Descriptor() ([]byte, []int) {\n\treturn file_policypb_policy_proto_rawDescGZIP(), []int{0}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_Trd_ModifyOrder_proto_rawDescGZIP(), []int{2}\n}", "func (*PatchKeysRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{74}\n}", "func (*UpdateRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_contact_proto_rawDescGZIP(), []int{12}\n}", "func (*UpdateConversationRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_threads_proto_rawDescGZIP(), []int{8}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_pkg_smgrpc_smgrpc_proto_rawDescGZIP(), []int{0}\n}", "func (*CalculatorRequest) Descriptor() ([]byte, []int) {\n\treturn file_basicpb_unary_api_proto_rawDescGZIP(), []int{4}\n}", "func (*SendRequest) Descriptor() ([]byte, []int) {\n\treturn file_github_com_yahuizhan_dappley_metrics_go_api_rpc_pb_rpc_proto_rawDescGZIP(), []int{5}\n}", "func (*BatchRequest_Request) Descriptor() ([]byte, []int) {\n\treturn file_go_chromium_org_luci_buildbucket_proto_builds_service_proto_rawDescGZIP(), []int{3, 0}\n}", "func (*ModelControlRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_service_proto_rawDescGZIP(), []int{4}\n}", "func ProtoFromDescriptor(d protoreflect.Descriptor) proto.Message {\n\tswitch d := d.(type) {\n\tcase protoreflect.FileDescriptor:\n\t\treturn ProtoFromFileDescriptor(d)\n\tcase protoreflect.MessageDescriptor:\n\t\treturn ProtoFromMessageDescriptor(d)\n\tcase protoreflect.FieldDescriptor:\n\t\treturn ProtoFromFieldDescriptor(d)\n\tcase protoreflect.OneofDescriptor:\n\t\treturn ProtoFromOneofDescriptor(d)\n\tcase protoreflect.EnumDescriptor:\n\t\treturn ProtoFromEnumDescriptor(d)\n\tcase protoreflect.EnumValueDescriptor:\n\t\treturn ProtoFromEnumValueDescriptor(d)\n\tcase protoreflect.ServiceDescriptor:\n\t\treturn ProtoFromServiceDescriptor(d)\n\tcase protoreflect.MethodDescriptor:\n\t\treturn ProtoFromMethodDescriptor(d)\n\tdefault:\n\t\t// WTF??\n\t\tif res, ok := d.(DescriptorProtoWrapper); ok {\n\t\t\treturn res.AsProto()\n\t\t}\n\t\treturn nil\n\t}\n}", "func (*GeneratedRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_auth_proto_rawDescGZIP(), []int{0}\n}", "func (*RelationshipRequest) Descriptor() ([]byte, []int) {\n\treturn file_dictybase_api_jsonapi_request_proto_rawDescGZIP(), []int{3}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_protobuf_newfindmaxpb_newfindmaxpb_proto_rawDescGZIP(), []int{0}\n}", "func (*PrimeDecompRequest) Descriptor() ([]byte, []int) {\n\treturn file_calculatorpb_calculator_proto_rawDescGZIP(), []int{4}\n}", "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_engine_proto_rawDescGZIP(), []int{12}\n}", "func (*ProxyRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_url_proto_rawDescGZIP(), []int{5}\n}", "func (*DelRequest) Descriptor() ([]byte, []int) {\n\treturn file_patrol_proto_rawDescGZIP(), []int{8}\n}", "func (*TelemRequest) Descriptor() ([]byte, []int) {\n\treturn file_core_services_synchronization_telem_telem_proto_rawDescGZIP(), []int{0}\n}", "func (*ProxyRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_sample_proto_rawDescGZIP(), []int{4}\n}", "func (*AddRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_calculate_proto_rawDescGZIP(), []int{3}\n}", "func (*UpdateRequest) Descriptor() ([]byte, []int) {\n\treturn file_recordwants_proto_rawDescGZIP(), []int{6}\n}", "func (*ListenRequest) Descriptor() ([]byte, []int) {\n\treturn file_threads_proto_rawDescGZIP(), []int{46}\n}", "func (*RevokeJobRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_noderpc_proto_feeds_manager_proto_rawDescGZIP(), []int{20}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_example_proto_rawDescGZIP(), []int{1}\n}", "func (*PortRequest) Descriptor() ([]byte, []int) {\n\treturn file_api_api_proto_rawDescGZIP(), []int{1}\n}", "func (*GetSomesRequest) Descriptor() ([]byte, []int) {\n\treturn file_grpc_exercicio_proto_rawDescGZIP(), []int{5}\n}", "func (*CMsgLoadedRequest) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{46}\n}", "func (*TodoRequest) Descriptor() ([]byte, []int) {\n\treturn file_protobuf_todolist_proto_rawDescGZIP(), []int{0}\n}", "func (*MoneyRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_swap_swap_proto_rawDescGZIP(), []int{0}\n}", "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_contact_proto_rawDescGZIP(), []int{10}\n}", "func (*UpdateRequest) Descriptor() ([]byte, []int) {\n\treturn file_todo_proto_rawDescGZIP(), []int{5}\n}", "func (*EndpointRequest) Descriptor() ([]byte, []int) {\n\treturn file_messages_proto_rawDescGZIP(), []int{13}\n}", "func (*RefreshRequest) Descriptor() ([]byte, []int) {\n\treturn file_cloudprovider_externalgrpc_protos_externalgrpc_proto_rawDescGZIP(), []int{16}\n}", "func (*OriginalDetectIntentRequest) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_dialogflow_v2beta1_webhook_proto_rawDescGZIP(), []int{2}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_internal_services_profile_proto_profile_proto_rawDescGZIP(), []int{0}\n}", "func (*DeleteCollectorsRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{162}\n}", "func (*ValidateClientCredentialRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_micro_pb_request_proto_rawDescGZIP(), []int{0}\n}", "func (*GetCollectorRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_clarifai_api_service_proto_rawDescGZIP(), []int{163}\n}", "func (*Request) Descriptor() ([]byte, []int) {\n\treturn file_example_proto_rawDescGZIP(), []int{0}\n}", "func (*ShowMessageRequestRequest) Descriptor() ([]byte, []int) {\n\treturn file_protocol_rpc_rpc_proto_rawDescGZIP(), []int{58}\n}", "func (*MetricsRequest) Descriptor() ([]byte, []int) {\n\treturn file_ssn_dataservice_v1_dataservice_proto_rawDescGZIP(), []int{11}\n}", "func (*ChangeRequest) Descriptor() ([]byte, []int) {\n\treturn file_management_proto_rawDescGZIP(), []int{2}\n}", "func (*ChangeRequest) Descriptor() ([]byte, []int) {\n\treturn file_management_proto_rawDescGZIP(), []int{2}\n}", "func (*MeshCertificateRequest) Descriptor() ([]byte, []int) {\n\treturn file_security_proto_providers_google_meshca_proto_rawDescGZIP(), []int{0}\n}", "func (*WatchProvisioningApprovalRequestRequest) Descriptor() ([]byte, []int) {\n\treturn edgelq_devices_proto_v1alpha_provisioning_approval_request_service_proto_rawDescGZIP(), []int{5}\n}", "func (*CreateRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_proto_todo_proto_rawDescGZIP(), []int{1}\n}", "func (*UpdateRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_task_v1_task_proto_rawDescGZIP(), []int{7}\n}", "func (*GetRequest) Descriptor() ([]byte, []int) {\n\treturn file_dictybase_api_jsonapi_request_proto_rawDescGZIP(), []int{0}\n}", "func (*CMsgSocialFeedRequest) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{304}\n}", "func (*DescribeMicroRequest) Descriptor() ([]byte, []int) {\n\treturn file_pkg_micro_pb_request_proto_rawDescGZIP(), []int{3}\n}", "func (*CreateRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_engine_proto_rawDescGZIP(), []int{2}\n}", "func (*DeleteRequest) Descriptor() ([]byte, []int) {\n\treturn file_ssn_dataservice_v1_dataservice_proto_rawDescGZIP(), []int{14}\n}", "func (*MsgRequest) Descriptor() ([]byte, []int) {\n\treturn file_msg_proto_rawDescGZIP(), []int{0}\n}", "func (*RecentMessagesRequest) Descriptor() ([]byte, []int) {\n\treturn file_proto_threads_proto_rawDescGZIP(), []int{16}\n}" ]
[ "0.72573286", "0.7218847", "0.71748", "0.7132119", "0.7117333", "0.71093345", "0.70960057", "0.70482236", "0.7047904", "0.7028092", "0.70185226", "0.7012674", "0.70116967", "0.70067143", "0.70019865", "0.69961846", "0.6985266", "0.6979804", "0.6976487", "0.6974723", "0.69741064", "0.6973554", "0.6972541", "0.6971797", "0.6971399", "0.6967375", "0.6963114", "0.6949535", "0.69419956", "0.69402146", "0.6934513", "0.6933217", "0.693153", "0.6929533", "0.6925348", "0.6924573", "0.69213367", "0.69203436", "0.6919876", "0.69178575", "0.6916834", "0.6916517", "0.6914249", "0.6912503", "0.69031984", "0.69000316", "0.68958426", "0.68944836", "0.6892358", "0.68910164", "0.689093", "0.6887534", "0.6887088", "0.6882339", "0.6880942", "0.68730277", "0.6869884", "0.68691534", "0.68672127", "0.6866304", "0.68656546", "0.68648106", "0.6858998", "0.6856258", "0.6854494", "0.6851954", "0.6849722", "0.68480885", "0.6840764", "0.6840179", "0.683758", "0.6837004", "0.6836577", "0.6835367", "0.68333775", "0.6832741", "0.68285406", "0.6827722", "0.68237585", "0.68232226", "0.6820234", "0.68144834", "0.6814136", "0.6813459", "0.6808796", "0.6803732", "0.68027574", "0.68022007", "0.68022007", "0.6802045", "0.67972445", "0.6795776", "0.67957264", "0.67949766", "0.67942584", "0.6793253", "0.6791309", "0.67887735", "0.6788652", "0.67883795" ]
0.7264457
0
NewGetPlatformsParams creates a new GetPlatformsParams object with the default values initialized.
func NewGetPlatformsParams() *GetPlatformsParams { var () return &GetPlatformsParams{ timeout: cr.DefaultTimeout, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewGetPlatformsParamsWithTimeout(timeout time.Duration) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetPlatformsParamsWithHTTPClient(client *http.Client) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetPlatformsParams) WithTimeout(timeout time.Duration) *GetPlatformsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewGetOperatingSystemsParams() *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *GetPlatformsParams) WithContext(ctx context.Context) *GetPlatformsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetPlatformsParams) WithHTTPClient(client *http.Client) *GetPlatformsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetPlatformsParams) WithExtended(extended *bool) *GetPlatformsParams {\n\to.SetExtended(extended)\n\treturn o\n}", "func NewGetPlatformsParamsWithContext(ctx context.Context) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewPcloudSystempoolsGetParams() *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetParams() *GetParams {\n\tvar (\n\t\tdeviceOSDefault = string(\"Android 9\")\n\t\tsendToEmailDefault = string(\"no\")\n\t)\n\treturn &GetParams{\n\t\tDeviceOS: &deviceOSDefault,\n\t\tSendToEmail: &sendToEmailDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewProviderParams() ProviderParams {\n\n\treturn ProviderParams{}\n}", "func (o *GetMetricsParams) WithPlatforms(platforms *string) *GetMetricsParams {\n\to.SetPlatforms(platforms)\n\treturn o\n}", "func NewGetCurrentGenerationParams() *GetCurrentGenerationParams {\n\treturn &GetCurrentGenerationParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (a *Client) GetPlatforms(params *GetPlatformsParams, opts ...ClientOption) (*GetPlatformsOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetPlatformsParams()\n\t}\n\top := &runtime.ClientOperation{\n\t\tID: \"get-platforms\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/fwmgr/entities/platforms/v1\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetPlatformsReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t}\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n\n\tresult, err := a.transport.Submit(op)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*GetPlatformsOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for get-platforms: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func NewGetOperatingSystemsParamsWithTimeout(timeout time.Duration) *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewOrgGetParams() *OrgGetParams {\n\tvar ()\n\treturn &OrgGetParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams() (Params, error) {\n\treturn Params{\n\t\tBaseParams: codec.BaseParams{\n\t\t\tKeyFrameInterval: 60,\n\t\t},\n\t}, nil\n}", "func NewGetProcessorsParams() *GetProcessorsParams {\n\treturn &GetProcessorsParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams(defaultSendEnabled bool) Params {\n\treturn Params{\n\t\tSendEnabled: nil,\n\t\tDefaultSendEnabled: defaultSendEnabled,\n\t}\n}", "func NewParams() *Params {\n\treturn new(Params)\n}", "func NewPcloudNetworksGetallParams() *PcloudNetworksGetallParams {\n\treturn &PcloudNetworksGetallParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams(active bool, lps DistributionSchedules, dds DelegatorDistributionSchedules,\n\tmoneyMarkets MoneyMarkets, checkLtvIndexCount int) Params {\n\treturn Params{\n\t\tActive: active,\n\t\tLiquidityProviderSchedules: lps,\n\t\tDelegatorDistributionSchedules: dds,\n\t\tMoneyMarkets: moneyMarkets,\n\t\tCheckLtvIndexCount: checkLtvIndexCount,\n\t}\n}", "func NewGetRepositoriesParams() *GetRepositoriesParams {\n\tvar ()\n\treturn &GetRepositoriesParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPublicWebLinkPlatformEstablishParams() *PublicWebLinkPlatformEstablishParams {\n\tvar ()\n\treturn &PublicWebLinkPlatformEstablishParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams(communityTax sdk.Dec, withdrawAddrEnabled bool) Params {\n\treturn Params{\n\t\tCommunityTax: communityTax,\n\t\tWithdrawAddrEnabled: withdrawAddrEnabled,\n\t}\n}", "func NewGetTreeParams() *GetTreeParams {\n\tvar ()\n\treturn &GetTreeParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams() *Parameters {\n\treturn &Parameters{\n\t\tTokenType: \"transit\",\n\t\tTLSMode: 1,\n\t\tLeaderOnly: true,\n\t\tConnectTimeout: defaultConnectTimeout,\n\t\tReadTimeout: defaultReadTimeout,\n\t\tRetryCount: defaultRetries,\n\t\tRequireType: \"master\",\n\t}\n}", "func NewPcloudSystempoolsGetParamsWithTimeout(timeout time.Duration) *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetUIParams() *GetUIParams {\n\n\treturn &GetUIParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetSsoParams() *GetSsoParams {\n\tvar ()\n\treturn &GetSsoParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetClockParams() *GetClockParams {\n\treturn &GetClockParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetParams() *GetParams {\n\treturn &GetParams{}\n}", "func NewGetBuildPropertiesParams() *GetBuildPropertiesParams {\n\tvar ()\n\treturn &GetBuildPropertiesParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetRoomsParams() *GetRoomsParams {\n\tvar ()\n\treturn &GetRoomsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *GetMetricsParams) SetPlatforms(platforms *string) {\n\to.Platforms = platforms\n}", "func NewPcloudSapGetParams() *PcloudSapGetParams {\n\treturn &PcloudSapGetParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *PlatformsAllOfData) GetPlatforms() map[string]Platform {\n\tif o == nil {\n\t\tvar ret map[string]Platform\n\t\treturn ret\n\t}\n\n\treturn o.Platforms\n}", "func NewGetScopeConfigurationParams() *GetScopeConfigurationParams {\n\tvar ()\n\treturn &GetScopeConfigurationParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetOutagesParams() *GetOutagesParams {\n\treturn &GetOutagesParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams(active bool, lps DistributionSchedules, dds DelegatorDistributionSchedules) Params {\n\treturn Params{\n\t\tActive: active,\n\t\tLiquidityProviderSchedules: lps,\n\t\tDelegatorDistributionSchedules: dds,\n\t}\n}", "func NewGetBootstrapParams() *GetBootstrapParams {\n\tvar ()\n\treturn &GetBootstrapParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetOperatingSystemsParamsWithHTTPClient(client *http.Client) *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewPcloudSystempoolsGetParamsWithHTTPClient(client *http.Client) *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetLogicalPortParams() *GetLogicalPortParams {\n\tvar ()\n\treturn &GetLogicalPortParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetClusterSupportedPlatforms(ctx *middleware.Context, handler GetClusterSupportedPlatformsHandler) *GetClusterSupportedPlatforms {\n\treturn &GetClusterSupportedPlatforms{Context: ctx, Handler: handler}\n}", "func (o *GetPlatformsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Extended != nil {\n\n\t\t// query param extended\n\t\tvar qrExtended bool\n\t\tif o.Extended != nil {\n\t\t\tqrExtended = *o.Extended\n\t\t}\n\t\tqExtended := swag.FormatBool(qrExtended)\n\t\tif qExtended != \"\" {\n\t\t\tif err := r.SetQueryParam(\"extended\", qExtended); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func NewGetCustomRuleParams() *GetCustomRuleParams {\n\tvar ()\n\treturn &GetCustomRuleParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams(createWhoisPrice string, updateWhoisPrice string, deleteWhoisPrice string) Params {\n\treturn Params{\n\t\tCreateWhoisPrice: createWhoisPrice,\n\t\tUpdateWhoisPrice: updateWhoisPrice,\n\t\tDeleteWhoisPrice: deleteWhoisPrice,\n\t}\n}", "func NewGetParamsWithTimeout(timeout time.Duration) *GetParams {\n\tvar (\n\t\tdeviceOSDefault = string(\"Android 9\")\n\t\tsendToEmailDefault = string(\"no\")\n\t)\n\treturn &GetParams{\n\t\tDeviceOS: &deviceOSDefault,\n\t\tSendToEmail: &sendToEmailDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewParams() *Params {\n\tp := Params{}\n\tp.names = []string{}\n\tp.values = map[string]interface{}{}\n\n\treturn &p\n}", "func NewGetNetworkExternalParams() *GetNetworkExternalParams {\n\n\treturn &GetNetworkExternalParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPcloudPvminstancesNetworksGetParams() *PcloudPvminstancesNetworksGetParams {\n\tvar ()\n\treturn &PcloudPvminstancesNetworksGetParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetGCParams() *GetGCParams {\n\treturn &GetGCParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetRuleChainParams() *GetRuleChainParams {\n\tvar ()\n\treturn &GetRuleChainParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewConfigGetParams() *ConfigGetParams {\n\treturn &ConfigGetParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetSearchClinicsParams() *GetSearchClinicsParams {\n\tvar ()\n\treturn &GetSearchClinicsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams(\n\ttaxPolicy, rewardPolicy PolicyConstraints,\n\tseigniorageBurden sdk.Dec,\n\tminingIncrement sdk.Dec,\n\twindowShort, windowLong, windowProbation sdk.Int,\n) Params {\n\treturn Params{\n\t\tTaxPolicy: taxPolicy,\n\t\tRewardPolicy: rewardPolicy,\n\t\tSeigniorageBurdenTarget: seigniorageBurden,\n\t\tMiningIncrement: miningIncrement,\n\t\tWindowShort: windowShort,\n\t\tWindowLong: windowLong,\n\t\tWindowProbation: windowProbation,\n\t}\n}", "func NewGetProjectsRequest(server string, params *GetProjectsParams) (*http.Request, error) {\n\tvar err error\n\n\tqueryUrl, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tbasePath := fmt.Sprintf(\"/projects\")\n\tif basePath[0] == '/' {\n\t\tbasePath = basePath[1:]\n\t}\n\n\tqueryUrl, err = queryUrl.Parse(basePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tqueryValues := queryUrl.Query()\n\n\tif params.Query != nil {\n\n\t\tif queryFrag, err := runtime.StyleParam(\"form\", true, \"query\", *params.Query); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.Identifier != nil {\n\n\t\tif queryFrag, err := runtime.StyleParam(\"form\", true, \"identifier\", *params.Identifier); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tqueryUrl.RawQuery = queryValues.Encode()\n\n\treq, err := http.NewRequest(\"GET\", queryUrl.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "func NewParameters(cfg config.Config, license license.License) Parameters {\n\treturn Parameters{\n\t\tConfig: cfg,\n\t\tLicense: license,\n\t}\n}", "func NewParams(opts []copts.Opt) *Params {\n\tparams := &Params{}\n\tcopts.Apply(params, opts)\n\treturn params\n}", "func NewParams(opts []copts.Opt) *Params {\r\n\tparams := &Params{}\r\n\tcopts.Apply(params, opts)\r\n\treturn params\r\n}", "func NewParams(acl ACL, daoOwner sdk.Address) Params {\n\treturn Params{\n\t\tACL: acl,\n\t\tDAOOwner: daoOwner,\n\t}\n}", "func NewSearchWorkspacesParams() *SearchWorkspacesParams {\n\tvar ()\n\treturn &SearchWorkspacesParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetFileSystemParametersInternalParams() *GetFileSystemParametersInternalParams {\n\tvar (\n\t\tattachedClusterDefault = bool(false)\n\t\tsecureDefault = bool(false)\n\t)\n\treturn &GetFileSystemParametersInternalParams{\n\t\tAttachedCluster: &attachedClusterDefault,\n\t\tSecure: &secureDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewFetchParams(timeout time.Duration, url string) *Params {\n\tparams := &Params{\n\t\tTimeout: timeout,\n\t\tURL: url,\n\t}\n\treturn params\n}", "func NewGetCurrentGenerationParamsWithTimeout(timeout time.Duration) *GetCurrentGenerationParams {\n\treturn &GetCurrentGenerationParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetOrganizationTeamPermissionsParams() *GetOrganizationTeamPermissionsParams {\n\tvar ()\n\treturn &GetOrganizationTeamPermissionsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetOrganizationPrototypePermissionsParams() *GetOrganizationPrototypePermissionsParams {\n\tvar ()\n\treturn &GetOrganizationPrototypePermissionsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetUsersParams() *GetUsersParams {\n\tvar ()\n\treturn &GetUsersParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (tr *CapacityProvider) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func NewGetTradingPairParams() *GetTradingPairParams {\n\tvar ()\n\treturn &GetTradingPairParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetLogoutRequestParams() *GetLogoutRequestParams {\n\tvar ()\n\treturn &GetLogoutRequestParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetPaymentsParams() *GetPaymentsParams {\n\tvar ()\n\treturn &GetPaymentsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPcloudNetworksGetallParamsWithTimeout(timeout time.Duration) *PcloudNetworksGetallParams {\n\treturn &PcloudNetworksGetallParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetGatewaysParams() *GetGatewaysParams {\n\treturn &GetGatewaysParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPublicWebLinkPlatformEstablishParamsWithTimeout(timeout time.Duration) *PublicWebLinkPlatformEstablishParams {\n\tvar ()\n\treturn &PublicWebLinkPlatformEstablishParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetOrderParams() *GetOrderParams {\n\tvar ()\n\treturn &GetOrderParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPutParams() *PutParams {\n\tvar ()\n\treturn &PutParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams(nickname NicknameParams, dTag DTagParams, bio BioParams, oracle OracleParams) Params {\n\treturn Params{\n\t\tNickname: nickname,\n\t\tDTag: dTag,\n\t\tBio: bio,\n\t\tOracle: oracle,\n\t}\n}", "func NewGetMetricsParams() *GetMetricsParams {\n\tvar (\n\t\tgranularityDefault = string(\"AUTO\")\n\t\tgroupByDefault = string(\"NONE\")\n\t\tsiteTypeFilterDefault = string(\"ALL\")\n\t)\n\treturn &GetMetricsParams{\n\t\tGranularity: &granularityDefault,\n\t\tGroupBy: &groupByDefault,\n\t\tSiteTypeFilter: &siteTypeFilterDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetComplianceByResourceTypesParams() *GetComplianceByResourceTypesParams {\n\tvar (\n\t\tmaxItemsDefault = int64(100)\n\t\toffsetDefault = int64(0)\n\t)\n\treturn &GetComplianceByResourceTypesParams{\n\t\tMaxItems: &maxItemsDefault,\n\t\tOffset: &offsetDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParams() Params {\n\treturn &headerParams{\n\t\tparams: make(map[string]MaybeString),\n\t\tparamOrder: []string{},\n\t}\n}", "func NewParams(tokenCourse, subscriptionPrice, VPNGBPrice,\n\tstorageGBPrice, baseVPNGb, baseStorageGb uint32, courseSigners []sdk.AccAddress) Params {\n\treturn Params{\n\t\tTokenCourse: tokenCourse,\n\t\tSubscriptionPrice: subscriptionPrice,\n\t\tVPNGBPrice: VPNGBPrice,\n\t\tStorageGBPrice: storageGBPrice,\n\t\tBaseVPNGb: baseVPNGb,\n\t\tBaseStorageGb: baseStorageGb,\n\t\tCourseChangeSigners: courseSigners[:],\n\t}\n}", "func (cia *chainInfoAPI) ProtocolParameters(ctx context.Context) (*apitypes.ProtocolParams, error) {\n\tnetworkName, err := cia.getNetworkName(ctx)\n\tif err != nil {\n\t\treturn nil, xerrors.Wrap(err, \"could not retrieve network name\")\n\t}\n\n\tvar supportedSectors []apitypes.SectorInfo\n\tfor proof := range miner0.SupportedProofTypes {\n\t\tsize, err := proof.SectorSize()\n\t\tif err != nil {\n\t\t\treturn nil, xerrors.Wrap(err, \"could not retrieve network name\")\n\t\t}\n\t\tmaxUserBytes := abi.PaddedPieceSize(size).Unpadded()\n\t\tsupportedSectors = append(supportedSectors, apitypes.SectorInfo{Size: size, MaxPieceSize: maxUserBytes})\n\t}\n\n\treturn &apitypes.ProtocolParams{\n\t\tNetwork: networkName,\n\t\tBlockTime: cia.chain.config.BlockTime(),\n\t\tSupportedSectors: supportedSectors,\n\t}, nil\n}", "func (tr *Service) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func NewGetTransportNodeParams() *GetTransportNodeParams {\n\tvar ()\n\treturn &GetTransportNodeParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewParameters(bitlen int) *Parameters {\n\tm, err := rand.Prime(rand.Reader, bitlen)\n\tif err != nil {\n\t\tpanic(\"Could not generate randon prime\")\n\t}\n\tn := 3\n\treturn &Parameters{\n\t\tn: n,\n\t\tM: m,\n\t\ttriplet: GenerateBeaverTriplet(m),\n\t\tassinc: mr.Intn(n),\n\t}\n}", "func NewGetOrganizationApplicationParams() *GetOrganizationApplicationParams {\n\tvar ()\n\treturn &GetOrganizationApplicationParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (tr *CassandraKeySpace) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func NewGetNetworkSwitchSettingsQosRuleParams() *GetNetworkSwitchSettingsQosRuleParams {\n\tvar ()\n\treturn &GetNetworkSwitchSettingsQosRuleParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (tr *NotebookWorkspace) GetParameters() (map[string]interface{}, error) {\n\tp, err := json.TFParser.Marshal(tr.Spec.ForProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbase := map[string]interface{}{}\n\treturn base, json.TFParser.Unmarshal(p, &base)\n}", "func NewGetCharacterParams() *GetCharacterParams {\n\tvar ()\n\treturn &GetCharacterParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetFyiSettingsParams() *GetFyiSettingsParams {\n\n\treturn &GetFyiSettingsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPlatformsAllOfData(count int32, platforms map[string]Platform) *PlatformsAllOfData {\n\tthis := PlatformsAllOfData{}\n\tthis.Count = count\n\tthis.Platforms = platforms\n\treturn &this\n}", "func (o *PlatformsAllOfData) GetPlatformsOk() (*map[string]Platform, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.Platforms, true\n}", "func NewPublicWebLinkPlatformEstablishParamsWithHTTPClient(client *http.Client) *PublicWebLinkPlatformEstablishParams {\n\tvar ()\n\treturn &PublicWebLinkPlatformEstablishParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewCreateWidgetParams() *CreateWidgetParams {\n\tvar (\n\t\tacceptDefault = string(\"application/json\")\n\t\tcontentTypeDefault = string(\"application/json\")\n\t)\n\treturn &CreateWidgetParams{\n\t\tAccept: &acceptDefault,\n\t\tContentType: &contentTypeDefault,\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *GetRepositoriesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.LabelID != nil {\n\n\t\t// query param label_id\n\t\tvar qrLabelID int64\n\t\tif o.LabelID != nil {\n\t\t\tqrLabelID = *o.LabelID\n\t\t}\n\t\tqLabelID := swag.FormatInt64(qrLabelID)\n\t\tif qLabelID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"label_id\", qLabelID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int32\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt32(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.PageSize != nil {\n\n\t\t// query param page_size\n\t\tvar qrPageSize int32\n\t\tif o.PageSize != nil {\n\t\t\tqrPageSize = *o.PageSize\n\t\t}\n\t\tqPageSize := swag.FormatInt32(qrPageSize)\n\t\tif qPageSize != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page_size\", qPageSize); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param project_id\n\tqrProjectID := o.ProjectID\n\tqProjectID := swag.FormatInt32(qrProjectID)\n\tif qProjectID != \"\" {\n\t\tif err := r.SetQueryParam(\"project_id\", qProjectID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func NewGetRuntimeServersParams() *GetRuntimeServersParams {\n\tvar ()\n\treturn &GetRuntimeServersParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetRefPlantsParams() GetRefPlantsParams {\n\n\tvar (\n\t\t// initialize parameters with default values\n\n\t\tlimitDefault = int64(20)\n\t\toffsetDefault = int64(0)\n\t)\n\n\treturn GetRefPlantsParams{\n\t\tLimit: limitDefault,\n\n\t\tOffset: offsetDefault,\n\t}\n}" ]
[ "0.7555398", "0.7425465", "0.66280895", "0.6524783", "0.6367459", "0.623201", "0.6032082", "0.5907493", "0.58632076", "0.570186", "0.56994843", "0.5553735", "0.55019903", "0.547514", "0.5458275", "0.5445687", "0.5440679", "0.5381146", "0.5365345", "0.5304436", "0.5302954", "0.529495", "0.5267036", "0.5258226", "0.523022", "0.5229289", "0.520272", "0.5200212", "0.5191669", "0.51903397", "0.5186975", "0.5178276", "0.51744694", "0.5173635", "0.51620305", "0.5161379", "0.5144871", "0.5144743", "0.51393485", "0.51340693", "0.5101502", "0.50992286", "0.5080975", "0.50698376", "0.5054708", "0.5053559", "0.50394464", "0.50374556", "0.50350064", "0.50317717", "0.50125396", "0.50093144", "0.50070786", "0.49910712", "0.49906248", "0.49902907", "0.49849993", "0.49760523", "0.49575764", "0.49551433", "0.49484485", "0.4931074", "0.49286634", "0.49267724", "0.49219465", "0.4902729", "0.48847812", "0.48693296", "0.4858065", "0.485483", "0.48534238", "0.48268816", "0.4825408", "0.48244634", "0.48238483", "0.48221087", "0.48185503", "0.48104462", "0.47988507", "0.4791486", "0.478987", "0.47863156", "0.4784515", "0.47795606", "0.47623962", "0.4756527", "0.4751336", "0.47442713", "0.47366485", "0.47317785", "0.47307438", "0.472762", "0.47172907", "0.47107536", "0.469576", "0.46945924", "0.46895453", "0.46815073", "0.46714157", "0.4663475" ]
0.88731694
0
NewGetPlatformsParamsWithTimeout creates a new GetPlatformsParams object with the default values initialized, and the ability to set a timeout on a request
func NewGetPlatformsParamsWithTimeout(timeout time.Duration) *GetPlatformsParams { var () return &GetPlatformsParams{ timeout: timeout, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetPlatformsParams) WithTimeout(timeout time.Duration) *GetPlatformsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewGetPlatformsParams() *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *GetPlatformsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetPlatformsParamsWithHTTPClient(client *http.Client) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetOperatingSystemsParamsWithTimeout(timeout time.Duration) *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetParamsWithTimeout(timeout time.Duration) *GetParams {\n\tvar (\n\t\tdeviceOSDefault = string(\"Android 9\")\n\t\tsendToEmailDefault = string(\"no\")\n\t)\n\treturn &GetParams{\n\t\tDeviceOS: &deviceOSDefault,\n\t\tSendToEmail: &sendToEmailDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewPcloudSystempoolsGetParamsWithTimeout(timeout time.Duration) *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetPlatformsParams) WithContext(ctx context.Context) *GetPlatformsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewOrgGetParamsWithTimeout(timeout time.Duration) *OrgGetParams {\n\tvar ()\n\treturn &OrgGetParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetClockParamsWithTimeout(timeout time.Duration) *GetClockParams {\n\treturn &GetClockParams{\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetPlatformsParams) WithHTTPClient(client *http.Client) *GetPlatformsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func NewGetCurrentGenerationParamsWithTimeout(timeout time.Duration) *GetCurrentGenerationParams {\n\treturn &GetCurrentGenerationParams{\n\t\ttimeout: timeout,\n\t}\n}", "func (o *PublicWebLinkPlatformEstablishParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetTreeParamsWithTimeout(timeout time.Duration) *GetTreeParams {\n\tvar ()\n\treturn &GetTreeParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewPublicWebLinkPlatformEstablishParamsWithTimeout(timeout time.Duration) *PublicWebLinkPlatformEstablishParams {\n\tvar ()\n\treturn &PublicWebLinkPlatformEstablishParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetUIParamsWithTimeout(timeout time.Duration) *GetUIParams {\n\n\treturn &GetUIParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetNetworkExternalParamsWithTimeout(timeout time.Duration) *GetNetworkExternalParams {\n\n\treturn &GetNetworkExternalParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetBuildPropertiesParamsWithTimeout(timeout time.Duration) *GetBuildPropertiesParams {\n\tvar ()\n\treturn &GetBuildPropertiesParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetOrganizationApplicationParamsWithTimeout(timeout time.Duration) *GetOrganizationApplicationParams {\n\tvar ()\n\treturn &GetOrganizationApplicationParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewCreateWidgetParamsWithTimeout(timeout time.Duration) *CreateWidgetParams {\n\tvar (\n\t\tacceptDefault = string(\"application/json\")\n\t\tcontentTypeDefault = string(\"application/json\")\n\t)\n\treturn &CreateWidgetParams{\n\t\tAccept: &acceptDefault,\n\t\tContentType: &contentTypeDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetMetricsParamsWithTimeout(timeout time.Duration) *GetMetricsParams {\n\tvar (\n\t\tgranularityDefault = string(\"AUTO\")\n\t\tgroupByDefault = string(\"NONE\")\n\t\tsiteTypeFilterDefault = string(\"ALL\")\n\t)\n\treturn &GetMetricsParams{\n\t\tGranularity: &granularityDefault,\n\t\tGroupBy: &groupByDefault,\n\t\tSiteTypeFilter: &siteTypeFilterDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetComplianceByResourceTypesParamsWithTimeout(timeout time.Duration) *GetComplianceByResourceTypesParams {\n\tvar (\n\t\tmaxItemsDefault = int64(100)\n\t\toffsetDefault = int64(0)\n\t)\n\treturn &GetComplianceByResourceTypesParams{\n\t\tMaxItems: &maxItemsDefault,\n\t\tOffset: &offsetDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewPcloudNetworksGetallParamsWithTimeout(timeout time.Duration) *PcloudNetworksGetallParams {\n\treturn &PcloudNetworksGetallParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewTimeout(parameters ...wparams.ParamStorer) Error {\n\treturn newGenericError(nil, DefaultTimeout, wparams.NewParamStorer(parameters...))\n}", "func NewGetLogicalPortParamsWithTimeout(timeout time.Duration) *GetLogicalPortParams {\n\tvar ()\n\treturn &GetLogicalPortParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetCustomRuleParamsWithTimeout(timeout time.Duration) *GetCustomRuleParams {\n\tvar ()\n\treturn &GetCustomRuleParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetFileSystemParametersInternalParamsWithTimeout(timeout time.Duration) *GetFileSystemParametersInternalParams {\n\tvar (\n\t\tattachedClusterDefault = bool(false)\n\t\tsecureDefault = bool(false)\n\t)\n\treturn &GetFileSystemParametersInternalParams{\n\t\tAttachedCluster: &attachedClusterDefault,\n\t\tSecure: &secureDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetBootstrapParamsWithTimeout(timeout time.Duration) *GetBootstrapParams {\n\tvar ()\n\treturn &GetBootstrapParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *PcloudSystempoolsGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetOperatingSystemsParams() *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetSearchClinicsParamsWithTimeout(timeout time.Duration) *GetSearchClinicsParams {\n\tvar ()\n\treturn &GetSearchClinicsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetProjectMetricsParamsWithTimeout(timeout time.Duration) *GetProjectMetricsParams {\n\tvar ()\n\treturn &GetProjectMetricsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewSearchWorkspacesParamsWithTimeout(timeout time.Duration) *SearchWorkspacesParams {\n\tvar ()\n\treturn &SearchWorkspacesParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetTransportNodeParamsWithTimeout(timeout time.Duration) *GetTransportNodeParams {\n\tvar ()\n\treturn &GetTransportNodeParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetScopeConfigurationParamsWithTimeout(timeout time.Duration) *GetScopeConfigurationParams {\n\tvar ()\n\treturn &GetScopeConfigurationParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetRepositoriesParamsWithTimeout(timeout time.Duration) *GetRepositoriesParams {\n\tvar ()\n\treturn &GetRepositoriesParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetGCParamsWithTimeout(timeout time.Duration) *GetGCParams {\n\treturn &GetGCParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewPcloudPvminstancesNetworksGetParamsWithTimeout(timeout time.Duration) *PcloudPvminstancesNetworksGetParams {\n\tvar ()\n\treturn &PcloudPvminstancesNetworksGetParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetSsoParamsWithTimeout(timeout time.Duration) *GetSsoParams {\n\tvar ()\n\treturn &GetSsoParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetRuleChainParamsWithTimeout(timeout time.Duration) *GetRuleChainParams {\n\tvar ()\n\treturn &GetRuleChainParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetOrganizationTeamPermissionsParamsWithTimeout(timeout time.Duration) *GetOrganizationTeamPermissionsParams {\n\tvar ()\n\treturn &GetOrganizationTeamPermissionsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetCharacterParamsWithTimeout(timeout time.Duration) *GetCharacterParams {\n\tvar ()\n\treturn &GetCharacterParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewCreateCrossConnectParamsWithTimeout(timeout time.Duration) *CreateCrossConnectParams {\n\tvar ()\n\treturn &CreateCrossConnectParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *PcloudNetworksGetallParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPlatformsParams) WithExtended(extended *bool) *GetPlatformsParams {\n\to.SetExtended(extended)\n\treturn o\n}", "func NewGetNetworkAppliancePortParamsWithTimeout(timeout time.Duration) *GetNetworkAppliancePortParams {\n\tvar ()\n\treturn &GetNetworkAppliancePortParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetOperatingSystemsParams) WithTimeout(timeout time.Duration) *GetOperatingSystemsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewGetPackageSearchParamsWithTimeout(timeout time.Duration) *GetPackageSearchParams {\n\tvar ()\n\treturn &GetPackageSearchParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewJoinOrganizationParamsWithTimeout(timeout time.Duration) *JoinOrganizationParams {\n\treturn &JoinOrganizationParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetAOrderStatusParamsWithTimeout(timeout time.Duration) *GetAOrderStatusParams {\n\tvar (\n\t\tacceptDefault = string(\"application/json\")\n\t\tcontentTypeDefault = string(\"application/json\")\n\t)\n\treturn &GetAOrderStatusParams{\n\t\tAccept: acceptDefault,\n\t\tContentType: contentTypeDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *PcloudSystempoolsGetParams) WithTimeout(timeout time.Duration) *PcloudSystempoolsGetParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewGetOrderParamsWithTimeout(timeout time.Duration) *GetOrderParams {\n\tvar ()\n\treturn &GetOrderParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewPcloudSystempoolsGetParams() *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewSystemEventsParamsWithTimeout(timeout time.Duration) *SystemEventsParams {\n\tvar ()\n\treturn &SystemEventsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *PcloudPvminstancesNetworksGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *OrgGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetRoomsParamsWithTimeout(timeout time.Duration) *GetRoomsParams {\n\tvar ()\n\treturn &GetRoomsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetOperatingSystemsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PublicWebLinkPlatformEstablishParams) WithTimeout(timeout time.Duration) *PublicWebLinkPlatformEstablishParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewPcloudSapGetParamsWithTimeout(timeout time.Duration) *PcloudSapGetParams {\n\treturn &PcloudSapGetParams{\n\t\ttimeout: timeout,\n\t}\n}", "func WrapWithTimeout(cause error, parameters ...wparams.ParamStorer) Error {\n\treturn newGenericError(cause, DefaultTimeout, wparams.NewParamStorer(parameters...))\n}", "func (o *ServiceBrokerOpenstacksHostsGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetContactsParamsWithTimeout(timeout time.Duration) *GetContactsParams {\n\tvar (\n\t\tlimitDefault = int32(5000)\n\t\toffsetDefault = int32(0)\n\t)\n\treturn &GetContactsParams{\n\t\tLimit: &limitDefault,\n\t\tOffset: &offsetDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetLogoutRequestParamsWithTimeout(timeout time.Duration) *GetLogoutRequestParams {\n\tvar ()\n\treturn &GetLogoutRequestParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetPrinterStatusParamsWithTimeout(timeout time.Duration) *GetPrinterStatusParams {\n\n\treturn &GetPrinterStatusParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetDevicesUnknownParamsWithTimeout(timeout time.Duration) *GetDevicesUnknownParams {\n\treturn &GetDevicesUnknownParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetProductsCodeParamsWithTimeout(timeout time.Duration) *GetProductsCodeParams {\n\tvar (\n\t\twithAttributeOptionsDefault = bool(false)\n\t\twithQualityScoresDefault = bool(false)\n\t)\n\treturn &GetProductsCodeParams{\n\t\tWithAttributeOptions: &withAttributeOptionsDefault,\n\t\tWithQualityScores: &withQualityScoresDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetWormDomainParamsWithTimeout(timeout time.Duration) *GetWormDomainParams {\n\tvar ()\n\treturn &GetWormDomainParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetContactsParamsWithTimeout(timeout time.Duration) *GetContactsParams {\n\tvar (\n\t\tlimitDefault = int64(50)\n\t\toffsetDefault = int64(0)\n\t)\n\treturn &GetContactsParams{\n\t\tLimit: &limitDefault,\n\t\tOffset: &offsetDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetSearchClinicsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetOrganizationPrototypePermissionsParamsWithTimeout(timeout time.Duration) *GetOrganizationPrototypePermissionsParams {\n\tvar ()\n\treturn &GetOrganizationPrototypePermissionsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetGPUArchitectureParamsWithTimeout(timeout time.Duration) *GetGPUArchitectureParams {\n\treturn &GetGPUArchitectureParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetRuntimeServersParamsWithTimeout(timeout time.Duration) *GetRuntimeServersParams {\n\tvar ()\n\treturn &GetRuntimeServersParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetNetworkSwitchSettingsQosRuleParamsWithTimeout(timeout time.Duration) *GetNetworkSwitchSettingsQosRuleParams {\n\tvar ()\n\treturn &GetNetworkSwitchSettingsQosRuleParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetClockParams() *GetClockParams {\n\treturn &GetClockParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewListStacksByWorkspaceParamsWithTimeout(timeout time.Duration) *ListStacksByWorkspaceParams {\n\tvar ()\n\treturn &ListStacksByWorkspaceParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetOutagesParamsWithTimeout(timeout time.Duration) *GetOutagesParams {\n\treturn &GetOutagesParams{\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetRolesParamsWithTimeout(timeout time.Duration) *GetRolesParams {\n\tvar ()\n\treturn &GetRolesParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetFyiSettingsParamsWithTimeout(timeout time.Duration) *GetFyiSettingsParams {\n\n\treturn &GetFyiSettingsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *CapacityPoolGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewCreateRuntimeMapParamsWithTimeout(timeout time.Duration) *CreateRuntimeMapParams {\n\tvar ()\n\treturn &CreateRuntimeMapParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetIconParamsWithTimeout(timeout time.Duration) *GetIconParams {\n\treturn &GetIconParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewConfigGetParamsWithTimeout(timeout time.Duration) *ConfigGetParams {\n\treturn &ConfigGetParams{\n\t\ttimeout: timeout,\n\t}\n}", "func (o *CreateCrossConnectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetClockParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetProcessorsParamsWithTimeout(timeout time.Duration) *GetProcessorsParams {\n\treturn &GetProcessorsParams{\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetBuildPropertiesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewQueryEntitlementsParamsWithTimeout(timeout time.Duration) *QueryEntitlementsParams {\n\tvar (\n\t\tactiveOnlyDefault = bool(true)\n\t\tlimitDefault = int32(20)\n\t\toffsetDefault = int32(0)\n\t)\n\treturn &QueryEntitlementsParams{\n\t\tActiveOnly: &activeOnlyDefault,\n\t\tLimit: &limitDefault,\n\t\tOffset: &offsetDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetRepositoriesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func BuildTimeParameters(params url.Values, expiry time.Duration) {\n\tnow := time.Now()\n\n\tparams.Set(QueryIssued, fmt.Sprint(now.UnixMilli()))\n\tparams.Set(QueryExpiry, fmt.Sprint(now.Add(expiry).UnixMilli()))\n}", "func NewServeBuildTypesInProjectParamsWithTimeout(timeout time.Duration) *ServeBuildTypesInProjectParams {\n\tvar ()\n\treturn &ServeBuildTypesInProjectParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetPlatformsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Extended != nil {\n\n\t\t// query param extended\n\t\tvar qrExtended bool\n\t\tif o.Extended != nil {\n\t\t\tqrExtended = *o.Extended\n\t\t}\n\t\tqExtended := swag.FormatBool(qrExtended)\n\t\tif qExtended != \"\" {\n\t\t\tif err := r.SetQueryParam(\"extended\", qExtended); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func NewGetGatewaysParamsWithTimeout(timeout time.Duration) *GetGatewaysParams {\n\treturn &GetGatewaysParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewMetroclusterInterconnectGetParamsWithTimeout(timeout time.Duration) *MetroclusterInterconnectGetParams {\n\treturn &MetroclusterInterconnectGetParams{\n\t\ttimeout: timeout,\n\t}\n}", "func NewDetectLanguageParamsWithTimeout(timeout time.Duration) *DetectLanguageParams {\n\tvar ()\n\treturn &DetectLanguageParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetTransportNodeParams() *GetTransportNodeParams {\n\tvar ()\n\treturn &GetTransportNodeParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *MetroclusterInterconnectGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetTradingPairParamsWithTimeout(timeout time.Duration) *GetTradingPairParams {\n\tvar ()\n\treturn &GetTradingPairParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetLogsParamsWithTimeout(timeout time.Duration) *GetLogsParams {\n\tvar (\n\t\tpageDefault = int64(1)\n\t\tpageSizeDefault = int64(10)\n\t)\n\treturn &GetLogsParams{\n\t\tPage: &pageDefault,\n\t\tPageSize: &pageSizeDefault,\n\n\t\ttimeout: timeout,\n\t}\n}" ]
[ "0.8099803", "0.7864803", "0.68469137", "0.6831266", "0.6502288", "0.6194031", "0.6076022", "0.59323996", "0.58478737", "0.5819925", "0.5788982", "0.57653457", "0.5737436", "0.57203186", "0.56848276", "0.5684553", "0.56770486", "0.5665245", "0.56478405", "0.5646077", "0.564033", "0.561581", "0.5605666", "0.5604725", "0.5601695", "0.5569704", "0.5565104", "0.55611473", "0.55460334", "0.5545793", "0.5533601", "0.5516999", "0.5507862", "0.5502965", "0.5495787", "0.54858124", "0.54364794", "0.5418871", "0.54149365", "0.54019004", "0.53908205", "0.53894776", "0.53672916", "0.53312284", "0.5321965", "0.52994007", "0.5298656", "0.52825356", "0.527428", "0.5272764", "0.5272513", "0.5258145", "0.5254123", "0.5252852", "0.5247487", "0.5242219", "0.5241378", "0.5231746", "0.52225846", "0.52216023", "0.5216665", "0.52139467", "0.5201933", "0.51963705", "0.5180112", "0.5179279", "0.5178745", "0.51768243", "0.51707685", "0.5166603", "0.5165087", "0.5160806", "0.5150641", "0.5133023", "0.51299113", "0.5126678", "0.5125716", "0.51207465", "0.5116541", "0.5114161", "0.5110397", "0.51089066", "0.51082236", "0.5104754", "0.5084673", "0.5081516", "0.5074507", "0.5074457", "0.5073293", "0.50723654", "0.5052823", "0.50516677", "0.5051239", "0.5047354", "0.5045768", "0.50436217", "0.5043238", "0.50378007", "0.50334954", "0.503191" ]
0.8511127
0
NewGetPlatformsParamsWithContext creates a new GetPlatformsParams object with the default values initialized, and the ability to set a context for a request
func NewGetPlatformsParamsWithContext(ctx context.Context) *GetPlatformsParams { var () return &GetPlatformsParams{ Context: ctx, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewGetPlatformsParams() *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *GetPlatformsParams) WithContext(ctx context.Context) *GetPlatformsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewGetPlatformsParamsWithHTTPClient(client *http.Client) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetPlatformsParamsWithTimeout(timeout time.Duration) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetPlatformsParams) WithHTTPClient(client *http.Client) *GetPlatformsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetPlatformsParams) WithTimeout(timeout time.Duration) *GetPlatformsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *GetMetricsParams) WithPlatforms(platforms *string) *GetMetricsParams {\n\to.SetPlatforms(platforms)\n\treturn o\n}", "func (o *GetPlatformsParams) WithExtended(extended *bool) *GetPlatformsParams {\n\to.SetExtended(extended)\n\treturn o\n}", "func NewGetOperatingSystemsParamsWithContext(ctx context.Context) *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewPcloudSystempoolsGetParamsWithContext(ctx context.Context) *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (a *Client) GetPlatforms(params *GetPlatformsParams, opts ...ClientOption) (*GetPlatformsOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetPlatformsParams()\n\t}\n\top := &runtime.ClientOperation{\n\t\tID: \"get-platforms\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/fwmgr/entities/platforms/v1\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetPlatformsReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t}\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n\n\tresult, err := a.transport.Submit(op)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*GetPlatformsOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for get-platforms: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func (o *PlatformsAllOfData) GetPlatforms() map[string]Platform {\n\tif o == nil {\n\t\tvar ret map[string]Platform\n\t\treturn ret\n\t}\n\n\treturn o.Platforms\n}", "func (o *GetMetricsParams) SetPlatforms(platforms *string) {\n\to.Platforms = platforms\n}", "func NewGetOperatingSystemsParams() *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetClusterSupportedPlatforms(ctx *middleware.Context, handler GetClusterSupportedPlatformsHandler) *GetClusterSupportedPlatforms {\n\treturn &GetClusterSupportedPlatforms{Context: ctx, Handler: handler}\n}", "func NewGetCurrentGenerationParamsWithContext(ctx context.Context) *GetCurrentGenerationParams {\n\treturn &GetCurrentGenerationParams{\n\t\tContext: ctx,\n\t}\n}", "func (o *PlatformsByPlatformNameAllOfData) GetPlatforms() []Platform {\n\tif o == nil {\n\t\tvar ret []Platform\n\t\treturn ret\n\t}\n\n\treturn o.Platforms\n}", "func NewPcloudSystempoolsGetParams() *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *PlatformsByPlatformNameAllOfData) GetPlatformsOk() ([]Platform, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Platforms, true\n}", "func (o *PlatformsAllOfData) GetPlatformsOk() (*map[string]Platform, bool) {\n\tif o == nil {\n\t\treturn nil, false\n\t}\n\treturn &o.Platforms, true\n}", "func NewSearchWorkspacesParamsWithContext(ctx context.Context) *SearchWorkspacesParams {\n\tvar ()\n\treturn &SearchWorkspacesParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetSsoParamsWithContext(ctx context.Context) *GetSsoParams {\n\tvar ()\n\treturn &GetSsoParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *PlatformsAllOfData) SetPlatforms(v map[string]Platform) {\n\to.Platforms = v\n}", "func NewGetOperatingSystemsParamsWithHTTPClient(client *http.Client) *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetParamsWithContext(ctx context.Context) *GetParams {\n\tvar (\n\t\tdeviceOSDefault = string(\"Android 9\")\n\t\tsendToEmailDefault = string(\"no\")\n\t)\n\treturn &GetParams{\n\t\tDeviceOS: &deviceOSDefault,\n\t\tSendToEmail: &sendToEmailDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func NewPcloudPvminstancesNetworksGetParamsWithContext(ctx context.Context) *PcloudPvminstancesNetworksGetParams {\n\tvar ()\n\treturn &PcloudPvminstancesNetworksGetParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *GetOperatingSystemsParams) WithContext(ctx context.Context) *GetOperatingSystemsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewGetOperatingSystemsParamsWithTimeout(timeout time.Duration) *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (a *Client) GetClusterSupportedPlatforms(ctx context.Context, params *GetClusterSupportedPlatformsParams) (*GetClusterSupportedPlatformsOK, error) {\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"GetClusterSupportedPlatforms\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/v2/clusters/{cluster_id}/supported-platforms\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\", \"https\"},\n\t\tParams: params,\n\t\tReader: &GetClusterSupportedPlatformsReader{formats: a.formats},\n\t\tAuthInfo: a.authInfo,\n\t\tContext: ctx,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*GetClusterSupportedPlatformsOK), nil\n\n}", "func NewOrgGetParamsWithContext(ctx context.Context) *OrgGetParams {\n\tvar ()\n\treturn &OrgGetParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *PcloudPvminstancesNetworksGetParams) WithContext(ctx context.Context) *PcloudPvminstancesNetworksGetParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewGetScopeConfigurationParams() *GetScopeConfigurationParams {\n\tvar ()\n\treturn &GetScopeConfigurationParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (m *DeviceManagementConfigurationPolicy) GetPlatforms()(*DeviceManagementConfigurationPlatforms) {\n val, err := m.GetBackingStore().Get(\"platforms\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*DeviceManagementConfigurationPlatforms)\n }\n return nil\n}", "func NewGetClockParamsWithContext(ctx context.Context) *GetClockParams {\n\treturn &GetClockParams{\n\t\tContext: ctx,\n\t}\n}", "func (o *PcloudSystempoolsGetParams) WithContext(ctx context.Context) *PcloudSystempoolsGetParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewPcloudSystempoolsGetParamsWithHTTPClient(client *http.Client) *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetOutagesParamsWithContext(ctx context.Context) *GetOutagesParams {\n\treturn &GetOutagesParams{\n\t\tContext: ctx,\n\t}\n}", "func NewGetCurrentGenerationParams() *GetCurrentGenerationParams {\n\treturn &GetCurrentGenerationParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPcloudNetworksGetallParamsWithContext(ctx context.Context) *PcloudNetworksGetallParams {\n\treturn &PcloudNetworksGetallParams{\n\t\tContext: ctx,\n\t}\n}", "func NewPublicWebLinkPlatformEstablishParamsWithContext(ctx context.Context) *PublicWebLinkPlatformEstablishParams {\n\tvar ()\n\treturn &PublicWebLinkPlatformEstablishParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetGatewaysParamsWithContext(ctx context.Context) *GetGatewaysParams {\n\treturn &GetGatewaysParams{\n\t\tContext: ctx,\n\t}\n}", "func (o *KubernetesAddonDefinitionAllOf) SetPlatforms(v []string) {\n\to.Platforms = v\n}", "func NewGetRoomsParamsWithContext(ctx context.Context) *GetRoomsParams {\n\tvar ()\n\treturn &GetRoomsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetBuildPropertiesParamsWithContext(ctx context.Context) *GetBuildPropertiesParams {\n\tvar ()\n\treturn &GetBuildPropertiesParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *PlatformsByPlatformNameAllOfData) SetPlatforms(v []Platform) {\n\to.Platforms = v\n}", "func (o *KubernetesAddonDefinitionAllOf) GetPlatforms() []string {\n\tif o == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn o.Platforms\n}", "func NewPcloudSystempoolsGetParamsWithTimeout(timeout time.Duration) *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewProviderParams() ProviderParams {\n\n\treturn ProviderParams{}\n}", "func (o *KubernetesAddonDefinitionAllOf) GetPlatformsOk() ([]string, bool) {\n\tif o == nil || o.Platforms == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Platforms, true\n}", "func NewPcloudPvminstancesNetworksGetParams() *PcloudPvminstancesNetworksGetParams {\n\tvar ()\n\treturn &PcloudPvminstancesNetworksGetParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetOrganizationTeamPermissionsParams() *GetOrganizationTeamPermissionsParams {\n\tvar ()\n\treturn &GetOrganizationTeamPermissionsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetRepositoriesParams() *GetRepositoriesParams {\n\tvar ()\n\treturn &GetRepositoriesParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (a *Client) GetPlatformNetworks(params *GetPlatformNetworksParams) (*GetPlatformNetworksOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetPlatformNetworksParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"getPlatformNetworks\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/v1/platform_resources/networks\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"http\", \"https\"},\n\t\tParams: params,\n\t\tReader: &GetPlatformNetworksReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.(*GetPlatformNetworksOK), nil\n\n}", "func NewGetProcessorsParamsWithContext(ctx context.Context) *GetProcessorsParams {\n\treturn &GetProcessorsParams{\n\t\tContext: ctx,\n\t}\n}", "func NewPcloudSapGetParams() *PcloudSapGetParams {\n\treturn &PcloudSapGetParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPcloudSapGetParamsWithContext(ctx context.Context) *PcloudSapGetParams {\n\treturn &PcloudSapGetParams{\n\t\tContext: ctx,\n\t}\n}", "func NewGetV1MembershipsParamsWithContext(ctx context.Context) *GetV1MembershipsParams {\n\tvar ()\n\treturn &GetV1MembershipsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetOrganizationPrototypePermissionsParams() *GetOrganizationPrototypePermissionsParams {\n\tvar ()\n\treturn &GetOrganizationPrototypePermissionsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPutLolPerksV1CurrentpageParamsWithContext(ctx context.Context) *PutLolPerksV1CurrentpageParams {\n\tvar ()\n\treturn &PutLolPerksV1CurrentpageParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewCreateWidgetParamsWithContext(ctx context.Context) *CreateWidgetParams {\n\tvar (\n\t\tacceptDefault = string(\"application/json\")\n\t\tcontentTypeDefault = string(\"application/json\")\n\t)\n\treturn &CreateWidgetParams{\n\t\tAccept: &acceptDefault,\n\t\tContentType: &contentTypeDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetComplianceByResourceTypesParamsWithContext(ctx context.Context) *GetComplianceByResourceTypesParams {\n\tvar (\n\t\tmaxItemsDefault = int64(100)\n\t\toffsetDefault = int64(0)\n\t)\n\treturn &GetComplianceByResourceTypesParams{\n\t\tMaxItems: &maxItemsDefault,\n\t\tOffset: &offsetDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func (schematics *SchematicsV1) GetWorkspaceWithContext(ctx context.Context, getWorkspaceOptions *GetWorkspaceOptions) (result *WorkspaceResponse, response *core.DetailedResponse, err error) {\n\terr = core.ValidateNotNil(getWorkspaceOptions, \"getWorkspaceOptions cannot be nil\")\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.ValidateStruct(getWorkspaceOptions, \"getWorkspaceOptions\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\tpathParamsMap := map[string]string{\n\t\t\"w_id\": *getWorkspaceOptions.WID,\n\t}\n\n\tbuilder := core.NewRequestBuilder(core.GET)\n\tbuilder = builder.WithContext(ctx)\n\tbuilder.EnableGzipCompression = schematics.GetEnableGzipCompression()\n\t_, err = builder.ResolveRequestURL(schematics.Service.Options.URL, `/v1/workspaces/{w_id}`, pathParamsMap)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tfor headerName, headerValue := range getWorkspaceOptions.Headers {\n\t\tbuilder.AddHeader(headerName, headerValue)\n\t}\n\n\tsdkHeaders := common.GetSdkHeaders(\"schematics\", \"V1\", \"GetWorkspace\")\n\tfor headerName, headerValue := range sdkHeaders {\n\t\tbuilder.AddHeader(headerName, headerValue)\n\t}\n\tbuilder.AddHeader(\"Accept\", \"application/json\")\n\n\trequest, err := builder.Build()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tvar rawResponse map[string]json.RawMessage\n\tresponse, err = schematics.Service.Request(request, &rawResponse)\n\tif err != nil {\n\t\treturn\n\t}\n\terr = core.UnmarshalModel(rawResponse, \"\", &result, UnmarshalWorkspaceResponse)\n\tif err != nil {\n\t\treturn\n\t}\n\tresponse.Result = result\n\n\treturn\n}", "func NewPayRatesGetParamsWithContext(ctx context.Context) *PayRatesGetParams {\n\tvar ()\n\treturn &PayRatesGetParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetRepositoriesParamsWithContext(ctx context.Context) *GetRepositoriesParams {\n\tvar ()\n\treturn &GetRepositoriesParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetPaymentsParamsWithContext(ctx context.Context) *GetPaymentsParams {\n\tvar ()\n\treturn &GetPaymentsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetSearchClinicsParamsWithContext(ctx context.Context) *GetSearchClinicsParams {\n\tvar ()\n\treturn &GetSearchClinicsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetUIParamsWithContext(ctx context.Context) *GetUIParams {\n\n\treturn &GetUIParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetRoomsParams() *GetRoomsParams {\n\tvar ()\n\treturn &GetRoomsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewGetFileSystemParametersInternalParamsWithContext(ctx context.Context) *GetFileSystemParametersInternalParams {\n\tvar (\n\t\tattachedClusterDefault = bool(false)\n\t\tsecureDefault = bool(false)\n\t)\n\treturn &GetFileSystemParametersInternalParams{\n\t\tAttachedCluster: &attachedClusterDefault,\n\t\tSecure: &secureDefault,\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetOrganizationPrototypePermissionsParamsWithHTTPClient(client *http.Client) *GetOrganizationPrototypePermissionsParams {\n\tvar ()\n\treturn &GetOrganizationPrototypePermissionsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetUsersCurrentPermissionsParams() *GetUsersCurrentPermissionsParams {\n\tvar ()\n\treturn &GetUsersCurrentPermissionsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *PcloudSapGetParams) WithContext(ctx context.Context) *PcloudSapGetParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewRepoUpdateTopicsParamsWithContext(ctx context.Context) *RepoUpdateTopicsParams {\n\tvar ()\n\treturn &RepoUpdateTopicsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func BootstrapPlatforms(c *config.Config) {\n\tconfig.Set(c)\n\n\tvar h tfhttp.Platform\n\tplatform.RegisterPlatform(\"HTTP\", h)\n\n\tvar tp tradfri.Platform\n\tplatform.RegisterPlatform(\"Tradfri\", tp)\n\n\tvar kp kasa.Platform\n\tplatform.RegisterPlatform(\"Kasa\", kp)\n\n\tvar owmp owm.Platform\n\tplatform.RegisterPlatform(\"OWM\", owmp)\n\n\tvar onkp onkyo.Platform\n\tplatform.RegisterPlatform(\"Onkyo\", onkp)\n\n\tvar ls linuxsensors.Platform\n\tplatform.RegisterPlatform(\"LinuxSensors\", ls)\n\n\tvar k konnected.Platform\n\tplatform.RegisterPlatform(\"Konnected\", k)\n\n\tvar nl noonlight.Platform\n\tplatform.RegisterPlatform(\"noonlight\", nl)\n\n\tvar hcp tfhc.HCPlatform\n\tplatform.RegisterPlatform(\"HomeControl\", hcp)\n\n\tplatform.StartupAllPlatforms(c)\n\n\t// add OS sensors\n\tsensor := accessory.TFAccessory{}\n\tls.AddAccessory(&sensor)\n}", "func NewGetTreeParamsWithContext(ctx context.Context) *GetTreeParams {\n\tvar ()\n\treturn &GetTreeParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewPcloudIkepoliciesPutParamsWithContext(ctx context.Context) *PcloudIkepoliciesPutParams {\n\treturn &PcloudIkepoliciesPutParams{\n\t\tContext: ctx,\n\t}\n}", "func NewGetOrganizationTeamPermissionsParamsWithHTTPClient(client *http.Client) *GetOrganizationTeamPermissionsParams {\n\tvar ()\n\treturn &GetOrganizationTeamPermissionsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetTradingPairParamsWithContext(ctx context.Context) *GetTradingPairParams {\n\tvar ()\n\treturn &GetTradingPairParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewScmProvidersRepositoriesGetToManyRelatedRequest(server string, id string, params *ScmProvidersRepositoriesGetToManyRelatedParams) (*http.Request, error) {\n\tvar err error\n\n\tvar pathParam0 string\n\n\tpathParam0, err = runtime.StyleParamWithLocation(\"simple\", false, \"id\", runtime.ParamLocationPath, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tserverURL, err := url.Parse(server)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperationPath := fmt.Sprintf(\"/v1/scmProviders/%s/repositories\", pathParam0)\n\tif operationPath[0] == '/' {\n\t\toperationPath = \".\" + operationPath\n\t}\n\n\tqueryURL, err := serverURL.Parse(operationPath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tqueryValues := queryURL.Query()\n\n\tif params.FilterId != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", false, \"filter[id]\", runtime.ParamLocationQuery, *params.FilterId); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.FieldsScmRepositories != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", false, \"fields[scmRepositories]\", runtime.ParamLocationQuery, *params.FieldsScmRepositories); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif params.Limit != nil {\n\n\t\tif queryFrag, err := runtime.StyleParamWithLocation(\"form\", true, \"limit\", runtime.ParamLocationQuery, *params.Limit); err != nil {\n\t\t\treturn nil, err\n\t\t} else if parsed, err := url.ParseQuery(queryFrag); err != nil {\n\t\t\treturn nil, err\n\t\t} else {\n\t\t\tfor k, v := range parsed {\n\t\t\t\tfor _, v2 := range v {\n\t\t\t\t\tqueryValues.Add(k, v2)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\tqueryURL.RawQuery = queryValues.Encode()\n\n\treq, err := http.NewRequest(\"GET\", queryURL.String(), nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn req, nil\n}", "func NewPutStackParamsWithContext(ctx context.Context) *PutStackParams {\n\tvar ()\n\treturn &PutStackParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetUsersParamsWithContext(ctx context.Context) *GetUsersParams {\n\tvar ()\n\treturn &GetUsersParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetLTENetworkIDPolicyQosProfilesParamsWithContext(ctx context.Context) *GetLTENetworkIDPolicyQosProfilesParams {\n\tvar ()\n\treturn &GetLTENetworkIDPolicyQosProfilesParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (o *GetPlatformsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Extended != nil {\n\n\t\t// query param extended\n\t\tvar qrExtended bool\n\t\tif o.Extended != nil {\n\t\t\tqrExtended = *o.Extended\n\t\t}\n\t\tqExtended := swag.FormatBool(qrExtended)\n\t\tif qExtended != \"\" {\n\t\t\tif err := r.SetQueryParam(\"extended\", qExtended); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (*SchematicsV1) NewGetWorkspaceInputsOptions(wID string, tID string) *GetWorkspaceInputsOptions {\n\treturn &GetWorkspaceInputsOptions{\n\t\tWID: core.StringPtr(wID),\n\t\tTID: core.StringPtr(tID),\n\t}\n}", "func NewPcloudPvminstancesNetworksGetParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksGetParams {\n\tvar ()\n\treturn &PcloudPvminstancesNetworksGetParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (a *Client) QueryPlatforms(params *QueryPlatformsParams, opts ...ClientOption) (*QueryPlatformsOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewQueryPlatformsParams()\n\t}\n\top := &runtime.ClientOperation{\n\t\tID: \"query-platforms\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/fwmgr/queries/platforms/v1\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &QueryPlatformsReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t}\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n\n\tresult, err := a.transport.Submit(op)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*QueryPlatformsOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for query-platforms: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func NewGetWormDomainParamsWithContext(ctx context.Context) *GetWormDomainParams {\n\tvar ()\n\treturn &GetWormDomainParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetOrganizationPrototypePermissionsParamsWithContext(ctx context.Context) *GetOrganizationPrototypePermissionsParams {\n\tvar ()\n\treturn &GetOrganizationPrototypePermissionsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (s *PlatformsService) Get(ctx context.Context, org, assembly, platform string) (*Platform, *http.Response, error) {\n\tif org == \"\" {\n\t\treturn nil, nil, errors.New(\"org name must be non-empty\")\n\t}\n\tif assembly == \"\" {\n\t\treturn nil, nil, errors.New(\"assembly name must be non-empty\")\n\t}\n\tif platform == \"\" {\n\t\treturn nil, nil, errors.New(\"platform name must be non-empty\")\n\t}\n\tap := fmt.Sprintf(\"%v/assemblies/%v/design/platforms/%v\", org, assembly, platform)\n\n\treq, err := s.client.NewRequest(\"GET\", ap, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tassemblyPlatform := new(Platform)\n\tresp, err := s.client.Do(ctx, req, assemblyPlatform)\n\tif err != nil {\n\t\treturn nil, resp, err\n\t}\n\n\treturn assemblyPlatform, resp, nil\n}", "func NewGetGCParamsWithContext(ctx context.Context) *GetGCParams {\n\treturn &GetGCParams{\n\t\tContext: ctx,\n\t}\n}", "func NewGetApplianceUpgradePoliciesMoidParamsWithContext(ctx context.Context) *GetApplianceUpgradePoliciesMoidParams {\n\tvar ()\n\treturn &GetApplianceUpgradePoliciesMoidParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetScopeConfigurationParamsWithContext(ctx context.Context) *GetScopeConfigurationParams {\n\tvar ()\n\treturn &GetScopeConfigurationParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetClockParams() *GetClockParams {\n\treturn &GetClockParams{\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func NewPlatformsAllOfData(count int32, platforms map[string]Platform) *PlatformsAllOfData {\n\tthis := PlatformsAllOfData{}\n\tthis.Count = count\n\tthis.Platforms = platforms\n\treturn &this\n}", "func NewQueryFirewallFieldsParamsWithContext(ctx context.Context) *QueryFirewallFieldsParams {\n\treturn &QueryFirewallFieldsParams{\n\t\tContext: ctx,\n\t}\n}", "func NewGetLogoutRequestParamsWithContext(ctx context.Context) *GetLogoutRequestParams {\n\tvar ()\n\treturn &GetLogoutRequestParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewGetScopeConfigurationParamsWithTimeout(timeout time.Duration) *GetScopeConfigurationParams {\n\tvar ()\n\treturn &GetScopeConfigurationParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetCurrentGenerationParamsWithHTTPClient(client *http.Client) *GetCurrentGenerationParams {\n\treturn &GetCurrentGenerationParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetUsersCurrentPermissionsParamsWithContext(ctx context.Context) *GetUsersCurrentPermissionsParams {\n\tvar ()\n\treturn &GetUsersCurrentPermissionsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func NewPlatformsAllOfDataWithDefaults() *PlatformsAllOfData {\n\tthis := PlatformsAllOfData{}\n\treturn &this\n}" ]
[ "0.79062843", "0.75749254", "0.717758", "0.6895261", "0.6486832", "0.64502275", "0.60652006", "0.5622456", "0.5587018", "0.5517432", "0.5431089", "0.5329733", "0.5258846", "0.52431345", "0.49316105", "0.49075675", "0.48815322", "0.48812634", "0.4881164", "0.485486", "0.4833368", "0.47503698", "0.47387797", "0.4677078", "0.46377233", "0.46363494", "0.4626417", "0.46142796", "0.46042505", "0.4551762", "0.45491084", "0.45390698", "0.45385173", "0.45306033", "0.45277587", "0.45215863", "0.45009306", "0.4488031", "0.44723698", "0.44621816", "0.44575268", "0.4443429", "0.44421932", "0.44403708", "0.442663", "0.4421899", "0.4421028", "0.44132268", "0.44051394", "0.43806252", "0.43801185", "0.43655595", "0.43646646", "0.43633085", "0.43630576", "0.43595088", "0.43532827", "0.43154833", "0.43147492", "0.42998937", "0.4299425", "0.4298446", "0.42786905", "0.4256922", "0.4252199", "0.4238163", "0.42271322", "0.4224647", "0.42182878", "0.4210664", "0.42105433", "0.41911796", "0.4187705", "0.41754872", "0.41498548", "0.41379294", "0.4137645", "0.41343194", "0.41332838", "0.411836", "0.41181877", "0.411149", "0.4097541", "0.40800887", "0.40800792", "0.40776747", "0.4077206", "0.40726054", "0.407176", "0.4068455", "0.40674832", "0.40530184", "0.4032788", "0.40281394", "0.40237823", "0.4022234", "0.40154353", "0.40127352", "0.40094167", "0.40084472" ]
0.8426746
0
NewGetPlatformsParamsWithHTTPClient creates a new GetPlatformsParams object with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewGetPlatformsParamsWithHTTPClient(client *http.Client) *GetPlatformsParams { var () return &GetPlatformsParams{ HTTPClient: client, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetPlatformsParams) WithHTTPClient(client *http.Client) *GetPlatformsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func NewGetPlatformsParams() *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *GetPlatformsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetOperatingSystemsParamsWithHTTPClient(client *http.Client) *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetPlatformsParamsWithTimeout(timeout time.Duration) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func NewGetParamsWithHTTPClient(client *http.Client) *GetParams {\n\tvar (\n\t\tdeviceOSDefault = string(\"Android 9\")\n\t\tsendToEmailDefault = string(\"no\")\n\t)\n\treturn &GetParams{\n\t\tDeviceOS: &deviceOSDefault,\n\t\tSendToEmail: &sendToEmailDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func NewPcloudSystempoolsGetParamsWithHTTPClient(client *http.Client) *PcloudSystempoolsGetParams {\n\tvar ()\n\treturn &PcloudSystempoolsGetParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetCurrentGenerationParamsWithHTTPClient(client *http.Client) *GetCurrentGenerationParams {\n\treturn &GetCurrentGenerationParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewCreateWidgetParamsWithHTTPClient(client *http.Client) *CreateWidgetParams {\n\tvar (\n\t\tacceptDefault = string(\"application/json\")\n\t\tcontentTypeDefault = string(\"application/json\")\n\t)\n\treturn &CreateWidgetParams{\n\t\tAccept: &acceptDefault,\n\t\tContentType: &contentTypeDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetPlatformsParams) WithTimeout(timeout time.Duration) *GetPlatformsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *GetPlatformsParams) WithContext(ctx context.Context) *GetPlatformsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func NewOrgGetParamsWithHTTPClient(client *http.Client) *OrgGetParams {\n\tvar ()\n\treturn &OrgGetParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *PublicWebLinkPlatformEstablishParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetUIParamsWithHTTPClient(client *http.Client) *GetUIParams {\n\n\treturn &GetUIParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (a *Client) GetPlatforms(params *GetPlatformsParams, opts ...ClientOption) (*GetPlatformsOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetPlatformsParams()\n\t}\n\top := &runtime.ClientOperation{\n\t\tID: \"get-platforms\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/fwmgr/entities/platforms/v1\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetPlatformsReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t}\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n\n\tresult, err := a.transport.Submit(op)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*GetPlatformsOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for get-platforms: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func NewGetTreeParamsWithHTTPClient(client *http.Client) *GetTreeParams {\n\tvar ()\n\treturn &GetTreeParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetClockParamsWithHTTPClient(client *http.Client) *GetClockParams {\n\treturn &GetClockParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetOperatingSystemsParams) WithHTTPClient(client *http.Client) *GetOperatingSystemsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func NewGetSsoParamsWithHTTPClient(client *http.Client) *GetSsoParams {\n\tvar ()\n\treturn &GetSsoParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *PcloudSystempoolsGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetMetricsParamsWithHTTPClient(client *http.Client) *GetMetricsParams {\n\tvar (\n\t\tgranularityDefault = string(\"AUTO\")\n\t\tgroupByDefault = string(\"NONE\")\n\t\tsiteTypeFilterDefault = string(\"ALL\")\n\t)\n\treturn &GetMetricsParams{\n\t\tGranularity: &granularityDefault,\n\t\tGroupBy: &groupByDefault,\n\t\tSiteTypeFilter: &siteTypeFilterDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetCustomRuleParamsWithHTTPClient(client *http.Client) *GetCustomRuleParams {\n\tvar ()\n\treturn &GetCustomRuleParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *PcloudNetworksGetallParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetOperatingSystemsParams() *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *PcloudPvminstancesNetworksGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetGCParamsWithHTTPClient(client *http.Client) *GetGCParams {\n\treturn &GetGCParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *PcloudSystempoolsGetParams) WithHTTPClient(client *http.Client) *PcloudSystempoolsGetParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func NewSearchWorkspacesParamsWithHTTPClient(client *http.Client) *SearchWorkspacesParams {\n\tvar ()\n\treturn &SearchWorkspacesParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetGPUArchitectureParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ServiceBrokerOpenstacksHostsGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *OrgGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetSearchClinicsParamsWithHTTPClient(client *http.Client) *GetSearchClinicsParams {\n\tvar ()\n\treturn &GetSearchClinicsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetRoomsParamsWithHTTPClient(client *http.Client) *GetRoomsParams {\n\tvar ()\n\treturn &GetRoomsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *PcloudIkepoliciesPutParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetBuildPropertiesParamsWithHTTPClient(client *http.Client) *GetBuildPropertiesParams {\n\tvar ()\n\treturn &GetBuildPropertiesParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *CapacityPoolGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetNetworkExternalParamsWithHTTPClient(client *http.Client) *GetNetworkExternalParams {\n\n\treturn &GetNetworkExternalParams{\n\t\tHTTPClient: client,\n\t}\n}", "func TestNewClient_CustomHttpClient(t *testing.T) {\n\tt.Parallel()\n\n\tclient := NewClient(nil, http.DefaultClient, ProviderPreev)\n\n\tif client == nil {\n\t\tt.Fatal(\"failed to load client\")\n\t}\n\n\t// Test providers\n\tif client.Providers[0] != ProviderPreev {\n\t\tt.Fatalf(\"expected the first provider to be %d, not %d\", ProviderPreev, client.Providers[0])\n\t}\n}", "func NewGetCharacterParamsWithHTTPClient(client *http.Client) *GetCharacterParams {\n\tvar ()\n\treturn &GetCharacterParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *SearchWorkspacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetComplianceByResourceTypesParamsWithHTTPClient(client *http.Client) *GetComplianceByResourceTypesParams {\n\tvar (\n\t\tmaxItemsDefault = int64(100)\n\t\toffsetDefault = int64(0)\n\t)\n\treturn &GetComplianceByResourceTypesParams{\n\t\tMaxItems: &maxItemsDefault,\n\t\tOffset: &offsetDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetParams) WithHTTPClient(client *http.Client) *GetParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func NewHTTPClient(options ...Opt) *HTTP {\n\tc := &HTTP{\n\t\tHTTPClient: &http.Client{},\n\t}\n\n\tfor _, option := range options {\n\t\toption(c)\n\t}\n\n\tif c.latestManifestURLFmt == \"\" {\n\t\tc.latestManifestURLFmt = defaultLatestManifestURLFmt\n\t}\n\n\tif c.manifestURLFmt == \"\" {\n\t\tc.manifestURLFmt = defaultManifestURLFmt\n\t}\n\n\treturn c\n}", "func (o *CreateWidgetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetBundleByKeyParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOperatingSystemsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateZoneProjectsUsingPUTParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetProcessorsParamsWithHTTPClient(client *http.Client) *GetProcessorsParams {\n\treturn &GetProcessorsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetTransportNodeParamsWithHTTPClient(client *http.Client) *GetTransportNodeParams {\n\tvar ()\n\treturn &GetTransportNodeParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *CreateCrossConnectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetClockParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewSystemEventsParamsWithHTTPClient(client *http.Client) *SystemEventsParams {\n\tvar ()\n\treturn &SystemEventsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewGetProjectMetricsParamsWithHTTPClient(client *http.Client) *GetProjectMetricsParams {\n\tvar ()\n\treturn &GetProjectMetricsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *PcloudSapGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ChatNewParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetSearchClinicsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetOrderParamsWithHTTPClient(client *http.Client) *GetOrderParams {\n\tvar ()\n\treturn &GetOrderParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewPublicWebLinkPlatformEstablishParamsWithHTTPClient(client *http.Client) *PublicWebLinkPlatformEstablishParams {\n\tvar ()\n\treturn &PublicWebLinkPlatformEstablishParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetFileSystemParametersInternalParams) WithHTTPClient(client *http.Client) *GetFileSystemParametersInternalParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetCurrentGenerationParams) WithHTTPClient(client *http.Client) *GetCurrentGenerationParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetGCParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetBuildPropertiesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetFileSystemParametersInternalParamsWithHTTPClient(client *http.Client) *GetFileSystemParametersInternalParams {\n\tvar (\n\t\tattachedClusterDefault = bool(false)\n\t\tsecureDefault = bool(false)\n\t)\n\treturn &GetFileSystemParametersInternalParams{\n\t\tAttachedCluster: &attachedClusterDefault,\n\t\tSecure: &secureDefault,\n\t\tHTTPClient: client,\n\t}\n}", "func (o *MetroclusterInterconnectGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewHTTPClient(transport http.RoundTripper, ts TokenSource) (*HTTPClient, error) {\n\tif ts == nil {\n\t\treturn nil, errors.New(\"gcp: no credentials available\")\n\t}\n\treturn &HTTPClient{\n\t\tClient: http.Client{\n\t\t\tTransport: &oauth2.Transport{\n\t\t\t\tBase: transport,\n\t\t\t\tSource: ts,\n\t\t\t},\n\t\t},\n\t}, nil\n}", "func (o *GetRepositoriesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *QtreeCollectionGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PutLolPerksV1CurrentpageParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetPageDataUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetMetricsParams) WithPlatforms(platforms *string) *GetMetricsParams {\n\to.SetPlatforms(platforms)\n\treturn o\n}", "func (o *JoinOrganizationParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewProvisionNetworkClientsParamsWithHTTPClient(client *http.Client) *ProvisionNetworkClientsParams {\n\tvar ()\n\treturn &ProvisionNetworkClientsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetPointsByQueryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewPcloudPvminstancesNetworksGetParamsWithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksGetParams {\n\tvar ()\n\treturn &PcloudPvminstancesNetworksGetParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetContentSourcesUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PublicPlatformLinkV3Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CreateRoomParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewConvertParamsWithHTTPClient(client *http.Client) *ConvertParams {\n\tvar ()\n\treturn &ConvertParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewListParamsWithHTTPClient(client *http.Client) *ListParams {\n\tvar ()\n\treturn &ListParams{\n\t\tHTTPClient: client,\n\t}\n}", "func NewPutParamsWithHTTPClient(client *http.Client) *PutParams {\n\tvar ()\n\treturn &PutParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *CatalogProductCustomOptionRepositoryV1GetListGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ServiceInstanceGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLTENetworkIDPolicyQosProfilesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetRuleChainParamsWithHTTPClient(client *http.Client) *GetRuleChainParams {\n\tvar ()\n\treturn &GetRuleChainParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *StorageServiceOwnershipGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *OrgGetParams) WithHTTPClient(client *http.Client) *OrgGetParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetRoomsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ConfigGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOrganizationTeamPermissionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewSizeParamsWithHTTPClient(client *http.Client) *SizeParams {\n\tvar ()\n\treturn &SizeParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *TicketProjectsImportProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AllLookmlTestsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PublicWebLinkPlatformEstablishParams) WithHTTPClient(client *http.Client) *PublicWebLinkPlatformEstablishParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetCharacterParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetWorkItemParamsWithHTTPClient(client *http.Client) *GetWorkItemParams {\n\tvar ()\n\treturn &GetWorkItemParams{\n\t\tHTTPClient: client,\n\t}\n}", "func newHTTPClient() *http.Client {\n\tclient := &http.Client{\n\t\tTimeout: defaultTimeout,\n\t}\n\treturn client\n}", "func (o *GetCurrentGenerationParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetWorkItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PcloudPvminstancesNetworksGetParams) WithHTTPClient(client *http.Client) *PcloudPvminstancesNetworksGetParams {\n\to.SetHTTPClient(client)\n\treturn o\n}" ]
[ "0.82473236", "0.72261274", "0.6987023", "0.6613042", "0.66055197", "0.61128336", "0.60561305", "0.59734505", "0.5956229", "0.5941421", "0.59126693", "0.58695054", "0.5867843", "0.58573145", "0.58371466", "0.5729112", "0.5689428", "0.5687673", "0.5664992", "0.563189", "0.56241566", "0.56218624", "0.5571057", "0.5570955", "0.5566569", "0.5551748", "0.55300295", "0.55146474", "0.5485789", "0.54720515", "0.54699177", "0.5463553", "0.54586047", "0.5458345", "0.5454131", "0.54533184", "0.5423231", "0.5419106", "0.540575", "0.53986317", "0.53948265", "0.5390627", "0.53756976", "0.537326", "0.5373141", "0.5371808", "0.5357531", "0.5355341", "0.5348204", "0.53469497", "0.5346658", "0.53331256", "0.5332236", "0.5331893", "0.5323985", "0.531578", "0.53142375", "0.531072", "0.5306752", "0.5301575", "0.5296345", "0.52894", "0.5286069", "0.52829474", "0.5279318", "0.5279201", "0.52787256", "0.52774286", "0.52760726", "0.52741575", "0.52733886", "0.52687943", "0.5265024", "0.5261636", "0.52586174", "0.52564895", "0.5255136", "0.5252628", "0.52512205", "0.52452207", "0.524292", "0.52362597", "0.523253", "0.5231832", "0.5224981", "0.52212054", "0.52207565", "0.521405", "0.52124393", "0.520589", "0.5200011", "0.51961106", "0.5194118", "0.5191634", "0.51915383", "0.5190502", "0.51849663", "0.5181475", "0.51740617", "0.51738375" ]
0.85485095
0
WithTimeout adds the timeout to the get platforms params
func (o *GetPlatformsParams) WithTimeout(timeout time.Duration) *GetPlatformsParams { o.SetTimeout(timeout) return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetPlatformsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetPlatformsParamsWithTimeout(timeout time.Duration) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func WithTimeout(t time.Duration) apiOption {\n\treturn func(m *Management) {\n\t\tm.timeout = t\n\t}\n}", "func (o *PublicWebLinkPlatformEstablishParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetOperatingSystemsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetDevicesUnknownParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(duration time.Duration) Option {\n\treturn wrappedOption{otlpconfig.WithTimeout(duration)}\n}", "func (o *GetOperatingSystemsParams) WithTimeout(timeout time.Duration) *GetOperatingSystemsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewGetOperatingSystemsParamsWithTimeout(timeout time.Duration) *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetBundleByKeyParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(timeout time.Duration) Option {\n\treturn func(o *options) {\n\t\to.timeout = timeout\n\t}\n}", "func WithTimeout(timeout time.Duration) Option {\n\treturn func(o *options) {\n\t\to.timeout = timeout\n\t}\n}", "func (o *GetDevicesAllParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(t time.Duration) APIOption {\n\treturn newAPIOption(func(o *Options) {\n\t\to.Timeout = t\n\t})\n}", "func (o *PcloudSystempoolsGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetDevicesUnknownParams) WithTimeout(timeout time.Duration) *GetDevicesUnknownParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func NewGetDevicesUnknownParamsWithTimeout(timeout time.Duration) *GetDevicesUnknownParams {\n\treturn &GetDevicesUnknownParams{\n\t\ttimeout: timeout,\n\t}\n}", "func (o *GetOrganizationApplicationParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WrapWithTimeout(cause error, parameters ...wparams.ParamStorer) Error {\n\treturn newGenericError(cause, DefaultTimeout, wparams.NewParamStorer(parameters...))\n}", "func (o *GetGPUArchitectureParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetBuildPropertiesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetaspecificPbxDeviceFirmwareBinaryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(timeout time.Duration) Option {\n\treturn func(opts *Options) {\n\t\topts.Timeout = timeout\n\t}\n}", "func (o *PcloudNetworksGetallParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *MetroclusterInterconnectGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetParamsWithTimeout(timeout time.Duration) *GetParams {\n\tvar (\n\t\tdeviceOSDefault = string(\"Android 9\")\n\t\tsendToEmailDefault = string(\"no\")\n\t)\n\treturn &GetParams{\n\t\tDeviceOS: &deviceOSDefault,\n\t\tSendToEmail: &sendToEmailDefault,\n\n\t\ttimeout: timeout,\n\t}\n}", "func (o *ServiceBrokerOpenstacksHostsGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetProductsCodeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetDeploymentByIDV3UsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *CreateCrossConnectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *SyncStatusUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetGroupsByTypeUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetContentSourceUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *QueryEntitlementsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *HandleGetAboutUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetFileSystemParametersInternalParams) WithTimeout(timeout time.Duration) *GetFileSystemParametersInternalParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *GetUIParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PcloudSapGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServeBuildTypesInProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (s stdlib) Timeout(time.Duration) {}", "func WithTimeout(timeout time.Duration) Option {\n\treturn func(opts *Opts) error {\n\t\topts.Timeout = timeout\n\t\treturn nil\n\t}\n}", "func (o *GetContentSourcesUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetSellerServicesUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(duration time.Duration) Option {\n\treturn wrappedOption{oconf.WithTimeout(duration)}\n}", "func WithTimeout(t time.Duration) Option {\n\treturn func(o *Manager) {\n\t\to.timeout = t\n\t}\n}", "func (o *GetUIParams) WithTimeout(timeout time.Duration) *GetUIParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func WithTimeout(timeout time.Duration) ClientOption {\n\treturn withTimeout{timeout}\n}", "func (o *GetClockParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewGetPlatformsParams() *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func (o *CatalogProductCustomOptionRepositoryV1GetListGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetNetworkExternalParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *NearestUsingGET1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *EavAttributeSetRepositoryV1GetGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ConfigGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (s *Skeleton) CallWithTimeout(dst ServiceID, encType EncType, timeout int, cmd CmdType, data ...interface{}) ([]interface{}, error) {\n\treturn s.s.callWithTimeout(dst, encType, timeout, cmd, data...)\n}", "func (c *OrganizationsEnvironmentsApisRevisionsDebugsessionsCreateCall) Timeout(timeout int64) *OrganizationsEnvironmentsApisRevisionsDebugsessionsCreateCall {\n\tc.urlParams_.Set(\"timeout\", fmt.Sprint(timeout))\n\treturn c\n}", "func (o *ExportProductsUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *OrgGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetIconParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetProductUpgradeURLUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPageDataUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *AllLookmlTestsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTerraformConfigurationSourcesUsingGET1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetWormDomainParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTreeParams) WithTimeout(timeout time.Duration) *GetTreeParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *PublicPlatformLinkV3Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func Timeout(timeout time.Duration) Option {\n\treturn func(client *http.Client) {\n\t\tclient.Timeout = timeout\n\t}\n}", "func Timeout(timeout time.Duration) Option {\n\treturn func(client *http.Client) {\n\t\tclient.Timeout = timeout\n\t}\n}", "func (o *GetOrganizationApplicationParams) WithTimeout(timeout time.Duration) *GetOrganizationApplicationParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func Timeout(timeout int64) Option {\n\treturn func(opts *options) {\n\t\topts.timeout = time.Duration(timeout) * time.Second\n\t}\n}", "func (o *GetAnOrderProductParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetRepositoriesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func NewWithCustomTimeout(apiKey, apiSecret string, timeout time.Duration) *Hbdm {\n\tclient := NewHttpClientWithCustomTimeout(apiKey, apiSecret, timeout)\n\treturn &Hbdm{client, sync.Mutex{}}\n}", "func (o *GetFileSystemParametersInternalParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (_e *MockCompletableFuture_Expecter[T]) GetWithTimeout(timeout interface{}) *MockCompletableFuture_GetWithTimeout_Call[T] {\n\treturn &MockCompletableFuture_GetWithTimeout_Call[T]{Call: _e.mock.On(\"GetWithTimeout\", timeout)}\n}", "func (o *GetItemByAppIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetBootstrapParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPluginEndpointParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (x Go) Timeout(timeout time.Duration) Go {\n\tx.timeout = timeout\n\treturn x\n}", "func (o *ListResourceTypesUsingGET2Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PublicWebLinkPlatformEstablishParams) WithTimeout(timeout time.Duration) *PublicWebLinkPlatformEstablishParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o AppTemplateContainerLivenessProbeOutput) Timeout() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v AppTemplateContainerLivenessProbe) *int { return v.Timeout }).(pulumi.IntPtrOutput)\n}", "func (o *GetPackageSearchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func Timeout(t time.Duration) Option {\n\treturn func(o *Options) {\n\t\to.Timeout = t\n\t}\n}", "func Timeout(t time.Duration) Option {\n\treturn func(o *Options) {\n\t\to.Timeout = t\n\t}\n}", "func Timeout(t time.Duration) Option {\n\treturn func(o *Options) {\n\t\to.Timeout = t\n\t}\n}", "func Timeout(t time.Duration) Option {\n\treturn func(o *Options) {\n\t\to.Timeout = t\n\t}\n}", "func (o *GetNetworkExternalParams) WithTimeout(timeout time.Duration) *GetNetworkExternalParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (r *Search) Timeout(timeout string) *Search {\n\n\tr.req.Timeout = &timeout\n\n\treturn r\n}", "func Timeout(d time.Duration) ConfigOpt {\n\treturn func(c *Config) {\n\t\tc.transport.ResponseHeaderTimeout = d\n\t\tc.transport.TLSHandshakeTimeout = d\n\t\tc.dialer.Timeout = d\n\t}\n}", "func (o *GetProjectMetricsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *TurnOnLightParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(timeout time.Duration) Option {\n\treturn func(opts *VDRI) {\n\t\topts.client.Timeout = timeout\n\t}\n}", "func (o *GetSearchClinicsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTreeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (filterdev *NetworkTap) Timeout() (*syscall.Timeval, error) {\n\tvar tv syscall.Timeval\n\t_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(filterdev.device.Fd()), syscall.BIOCGRTIMEOUT, uintptr(unsafe.Pointer(&tv)))\n\tif err != 0 {\n\t\treturn nil, syscall.Errno(err)\n\t}\n\treturn &tv, nil\n}", "func (o *GetGCParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}" ]
[ "0.70924264", "0.70087135", "0.63422763", "0.60646397", "0.598531", "0.59620464", "0.5948087", "0.58235776", "0.5817179", "0.5794681", "0.57502705", "0.57502705", "0.5739896", "0.572764", "0.57164013", "0.57161456", "0.57042384", "0.56877244", "0.56648874", "0.56480193", "0.56283456", "0.5625773", "0.5615357", "0.561463", "0.55799615", "0.55776834", "0.55431277", "0.5538012", "0.5534676", "0.5523369", "0.5513962", "0.55067694", "0.55033886", "0.54837453", "0.5482005", "0.547554", "0.54693574", "0.54617774", "0.54604924", "0.5457277", "0.5457248", "0.5454137", "0.5450652", "0.5449098", "0.5448422", "0.54482526", "0.5444433", "0.54420924", "0.5440263", "0.54396737", "0.5436625", "0.5410701", "0.5408067", "0.54053843", "0.54019624", "0.5399063", "0.5395165", "0.5395088", "0.53949606", "0.53725857", "0.5359773", "0.53574485", "0.5354407", "0.5353141", "0.53381085", "0.5335156", "0.53252006", "0.53238606", "0.532198", "0.53171223", "0.53171223", "0.5315749", "0.53131455", "0.53119284", "0.53016526", "0.53007907", "0.52857256", "0.5285157", "0.52825886", "0.5280229", "0.5279634", "0.5277811", "0.5273735", "0.52727026", "0.52717906", "0.5260619", "0.52568185", "0.52568185", "0.52568185", "0.52568185", "0.52545613", "0.52540594", "0.5252089", "0.5250977", "0.5243002", "0.5236203", "0.5236194", "0.52322114", "0.5230407", "0.5229415" ]
0.7747894
0
SetTimeout adds the timeout to the get platforms params
func (o *GetPlatformsParams) SetTimeout(timeout time.Duration) { o.timeout = timeout }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetOperatingSystemsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PublicWebLinkPlatformEstablishParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetGPUArchitectureParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetUIParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PcloudSystempoolsGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPlatformsParams) WithTimeout(timeout time.Duration) *GetPlatformsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func (o *GetDevicesUnknownParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetClockParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetBundleByKeyParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetBuildPropertiesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetaspecificPbxDeviceFirmwareBinaryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetNetworkExternalParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *EavAttributeSetRepositoryV1GetGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *MetroclusterInterconnectGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetOrganizationApplicationParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetDeploymentByIDV3UsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServeBuildTypesInProjectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DevicesGetModuleComponentCommandHistoryParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetBootstrapParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ConfigGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLogicalPortParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetNetworkAppliancePortParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetCurrentGenerationParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetFileSystemParametersInternalParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *QueryEntitlementsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *SyncStatusUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetWormDomainParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetFyiSettingsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *AllLookmlTestsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPageDataUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetContentSourceUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *CreateCrossConnectParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetProductsCodeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetExampleNewProjectDescriptionCompatibilityVersion1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *HandleGetAboutUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetProductUpgradeURLUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetRemotesupportConnectemcParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetDrgParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PcloudSapGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetGCParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetContentSourcesUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetWorkflowBuildTaskMetaMoidParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetIconParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetDevicesAllParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *OrgGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetAnOrderProductParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetProjectMetricsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPrivateOrderstateParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTasksGetPhpParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *CatalogProductCustomOptionRepositoryV1GetListGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetDatalakeDbConfigParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ServiceBrokerOpenstacksHostsGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *CreateWidgetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *TurnOnLightParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetAPI24ArraysNtpTestParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PcloudNetworksGetallParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTreeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetCustomRuleParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetSsoParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetSimulationActivityParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *IntegrationsManualHTTPSCreateParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *SMSHistoryExportGetParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ExportProductsUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetActionTemplateLogoVersionParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPortInfoUsingGET2Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetSellerServicesUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func WithTimeout(t time.Duration) apiOption {\n\treturn func(m *Management) {\n\t\tm.timeout = t\n\t}\n}", "func (o *PublicPlatformLinkV3Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetSearchClinicsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *RTRExecuteActiveResponderCommandParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *DetectLanguageParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetGroupsByTypeUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetOutagesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PutLolPerksV1CurrentpageParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLogicalSwitchParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *NearestUsingGET1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPluginEndpointParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetRackTopoesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PatchSepainstantIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetInterceptionitemsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *APIServiceHaltsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTerraformConfigurationSourcesUsingGET1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetLTENetworkIDPolicyQosProfilesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetNdmpSettingsVariableParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetItemByAppIDParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetRepositoriesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetRuntimeServersParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostGetOneParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPaymentsParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *ExportUsingGETParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTradingPairParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostAPIV3MachinesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetPublicsRecipeParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetTenantTagTestSpacesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *GetDeploymentPreview1Params) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *VirtualizationChoicesReadParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PatchAssetDeviceConfigurationsMoidParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}", "func (o *PostHyperflexAutoSupportPoliciesParams) SetTimeout(timeout time.Duration) {\n\to.timeout = timeout\n}" ]
[ "0.7305111", "0.72466415", "0.71178937", "0.7100496", "0.69969594", "0.6993028", "0.6947879", "0.6941489", "0.69177073", "0.6908698", "0.6838413", "0.6813882", "0.6804481", "0.6794519", "0.67828983", "0.67797804", "0.67492235", "0.6746541", "0.67458135", "0.67379045", "0.67353964", "0.6729548", "0.67258686", "0.671731", "0.67172617", "0.66887116", "0.6680107", "0.6679647", "0.6672439", "0.6661067", "0.6658508", "0.66565585", "0.665452", "0.6650868", "0.66504276", "0.663941", "0.66378003", "0.6637013", "0.66262573", "0.66205233", "0.66109025", "0.6584687", "0.65800554", "0.65792745", "0.6579131", "0.6575261", "0.6573262", "0.65505695", "0.6548556", "0.6548284", "0.65472496", "0.6545944", "0.65453243", "0.654065", "0.6538566", "0.65321743", "0.6528962", "0.6521677", "0.65067685", "0.65035003", "0.6502547", "0.6490857", "0.6485062", "0.64839524", "0.6481748", "0.64804566", "0.6479194", "0.6475073", "0.6469286", "0.64628416", "0.64589226", "0.6452461", "0.64445686", "0.64394253", "0.6435313", "0.64346683", "0.6428354", "0.64134604", "0.64102966", "0.6402565", "0.64003116", "0.6398504", "0.6395744", "0.6391613", "0.6390032", "0.63891417", "0.6383157", "0.63804865", "0.63785285", "0.63761914", "0.636972", "0.6368712", "0.63675386", "0.63672566", "0.6367065", "0.6364378", "0.63618153", "0.6361679", "0.6361266", "0.6359757" ]
0.8151992
0
WithContext adds the context to the get platforms params
func (o *GetPlatformsParams) WithContext(ctx context.Context) *GetPlatformsParams { o.SetContext(ctx) return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func sendWithContext(ctx context.Context, httpClient *http.Client, url string, body io.Reader, opt *Options) (*http.Response, error) {\n\tv, _ := query.Values(opt)\n\n\t// fmt.Print(v.Encode()) will output: \"city=0&mr=1&pb=4&pro=0&yys=0\"\n\tAPIEndpoint := fmt.Sprintf(\"%s&%s\", url, v.Encode())\n\tfmt.Println(APIEndpoint)\n\t// Change NewRequest to NewRequestWithContext and pass context it\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, APIEndpoint, body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// http.DefaultClient\n\tres, err := httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn res, nil\n}", "func (o *GetOperatingSystemsParams) WithContext(ctx context.Context) *GetOperatingSystemsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (_obj *WebApiAuth) SysConfig_GetPageWithContext(tarsCtx context.Context, pageSize int32, pageIndex int32, req *SysConfig, res *SysConfig_List, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(pageSize, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = _os.Write_int32(pageIndex, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = req.WriteBlock(_os, 3)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 4)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"SysConfig_GetPage\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = (*res).ReadBlock(_is, 4, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func (o *GetPlatformsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (_obj *WebApiAuth) SysConfig_GetWithContext(tarsCtx context.Context, req *SysConfig, res *SysConfig, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = req.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"SysConfig_Get\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = (*res).ReadBlock(_is, 2, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func (c *PlatformTypesListCall) Context(ctx context.Context) *PlatformTypesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (p *Provider) listWithContext(ctx context.Context, dir string, recursive bool, keys []*provider.KVPair, nextToken *string) ([]*provider.KVPair, error) {\n\tvar err error\n\n\t// input to the SSM to get parameters by path\n\tinput := &ssm.GetParametersByPathInput{\n\t\tPath: aws.String(dir),\n\t\tRecursive: aws.Bool(recursive),\n\t\t// WithDecryption: t.Bool(p.cfg.WithDecryption),\n\t}\n\n\tif nextToken != nil {\n\t\tinput.NextToken = nextToken\n\t}\n\n\toutput, err := p.ssm.GetParametersByPathWithContext(ctx, input)\n\tif err != nil {\n\t\treturn keys, err\n\t}\n\n\tfor _, param := range output.Parameters {\n\t\tkeys = append(keys, parameterKVPair(param))\n\t}\n\n\t// s.parameters = append(s.parameters, output.Parameters...)\n\n\tif nextToken != nil {\n\t\tp.listWithContext(ctx, dir, recursive, keys, nextToken)\n\t}\n\n\treturn keys, err\n}", "func FetchHTTPWithContext(ctx context.Context, jwkurl string, options ...Option) (*Set, error) {\n\thttpcl := http.DefaultClient\n\tfor _, option := range options {\n\t\tswitch option.Name() {\n\t\tcase optkeyHTTPClient:\n\t\t\thttpcl = option.Value().(*http.Client)\n\t\t}\n\t}\n\n\treq, err := http.NewRequest(http.MethodGet, jwkurl, nil)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to new request to remote JWK\")\n\t}\n\n\tres, err := httpcl.Do(req.WithContext(ctx))\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to fetch remote JWK\")\n\t}\n\tdefer res.Body.Close()\n\n\tif res.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"failed to fetch remote JWK (status = %d)\", res.StatusCode)\n\t}\n\n\treturn Parse(res.Body)\n}", "func MetaWithContext(ctx context.Context, newMeta map[string]interface{}) context.Context {\n\tprevMeta := MetaFromContext(ctx)\n\n\tif prevMeta == nil {\n\t\tprevMeta = make(map[string]interface{})\n\t}\n\n\tfor k, v := range newMeta {\n\t\tprevMeta[k] = v\n\t}\n\n\treturn context.WithValue(ctx, MetaCtxKey, prevMeta)\n}", "func (page * MaintenanceWindowListResultPage) NextWithContext(ctx context.Context) (err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/MaintenanceWindowListResultPage.NextWithContext\")\n defer func() {\n sc := -1\n if page.Response().Response.Response != nil {\n sc = page.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n for {\n next, err := page.fn(ctx, page.mwlr)\n if err != nil {\n return err\n }\n page.mwlr = next\n if !next.hasNextLink() || !next.IsEmpty() {\n break\n }\n }\n return nil\n }", "func (_obj *Apilangpack) Langpack_getLanguageWithContext(tarsCtx context.Context, params *TLlangpack_getLanguage, _opt ...map[string]string) (ret LangPackLanguage, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"langpack_getLanguage\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (c Client) FetchWithContext(context context.Context) (*FetchTrunkResponse, error) {\n\top := client.Operation{\n\t\tMethod: http.MethodGet,\n\t\tURI: \"/Trunks/{sid}\",\n\t\tPathParams: map[string]string{\n\t\t\t\"sid\": c.sid,\n\t\t},\n\t}\n\n\tresponse := &FetchTrunkResponse{}\n\tif err := c.client.Send(context, op, nil, response); err != nil {\n\t\treturn nil, err\n\t}\n\treturn response, nil\n}", "func (_obj *LacService) TestWithContext(ctx context.Context, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\terr = _obj.s.Tars_invoke(ctx, 0, \"test\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_obj.setMap(len(_opt), _resp, _context, _status)\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (_obj *Apichannels) Channels_joinChannelWithContext(tarsCtx context.Context, params *TLchannels_joinChannel, _opt ...map[string]string) (ret Updates, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_joinChannel\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (h *KubernetesHelper) KubectlWithContext(stdin string, context string, arg ...string) (string, error) {\n\twithContext := append([]string{\"--context=\" + context}, arg...)\n\tcmd := exec.Command(\"kubectl\", withContext...)\n\tcmd.Stdin = strings.NewReader(stdin)\n\tout, err := cmd.CombinedOutput()\n\treturn string(out), err\n}", "func (c *PlatformTypesGetCall) Context(ctx context.Context) *PlatformTypesGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (iter * MaintenanceWindowListResultIterator) NextWithContext(ctx context.Context) (err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/MaintenanceWindowListResultIterator.NextWithContext\")\n defer func() {\n sc := -1\n if iter.Response().Response.Response != nil {\n sc = iter.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n iter.i++\n if iter.i < len(iter. page.Values()) {\n return nil\n }\n err = iter.page.NextWithContext(ctx)\n if err != nil {\n iter. i--\n return err\n }\n iter.i = 0\n return nil\n }", "func (_obj *Apipayments) Payments_getSavedInfoWithContext(tarsCtx context.Context, params *TLpayments_getSavedInfo, _opt ...map[string]string) (ret Payments_SavedInfo, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"payments_getSavedInfo\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (page * ServerListResultPage) NextWithContext(ctx context.Context) (err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/ServerListResultPage.NextWithContext\")\n defer func() {\n sc := -1\n if page.Response().Response.Response != nil {\n sc = page.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n for {\n next, err := page.fn(ctx, page.slr)\n if err != nil {\n return err\n }\n page.slr = next\n if !next.hasNextLink() || !next.IsEmpty() {\n break\n }\n }\n return nil\n }", "func (c *OrganizationsApiproductsAttributesListCall) Context(ctx context.Context) *OrganizationsApiproductsAttributesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (_obj *WebApiAuth) SysUser_GetPageWithContext(tarsCtx context.Context, pageSize int32, pageIndex int32, req *SysUser, res *SysUser_List, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(pageSize, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = _os.Write_int32(pageIndex, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = req.WriteBlock(_os, 3)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 4)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"SysUser_GetPage\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = (*res).ReadBlock(_is, 4, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func (_obj *Apipayments) Payments_getPaymentFormWithContext(tarsCtx context.Context, params *TLpayments_getPaymentForm, _opt ...map[string]string) (ret Payments_PaymentForm, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"payments_getPaymentForm\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (_obj *DataService) GetUserInfoWithContext(tarsCtx context.Context, wx_id string, userInfo *UserInfo, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_string(wx_id, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = (*userInfo).WriteBlock(_os, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getUserInfo\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = (*userInfo).ReadBlock(_is, 2, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (_obj *DataService) CreateApplyWithContext(tarsCtx context.Context, wx_id string, club_id string, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_string(wx_id, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(club_id, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"createApply\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func WithContext(ctx context.Context) Option {\n\treturn func(o *Registry) { o.ctx = ctx }\n}", "func (_obj *DataService) GetClubListWithContext(tarsCtx context.Context, index int32, batch int32, wx_id string, nextIndex *int32, clubInfoList *[]ClubInfo, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(wx_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*clubInfoList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *clubInfoList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getClubList\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*clubInfoList) = make([]ClubInfo, length)\n\t\tfor i6, e6 := int32(0), length; i6 < e6; i6++ {\n\n\t\t\terr = (*clubInfoList)[i6].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (page *VirtualMachineListResultPageClient) NextWithContext(ctx context.Context) (err error) {\n\treturn page.vmlrp.NextWithContext(ctx)\n}", "func With(ctx context.Context, kvs ...interface{}) context.Context {\n\tl := fromCtx(ctx)\n\tl = l.With(kvs...)\n\treturn toCtx(ctx, l)\n}", "func (_obj *WebApiAuth) LoginLog_GetPageWithContext(tarsCtx context.Context, pageSize int32, pageIndex int32, req *LoginLog, res *LoginLog_List, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(pageSize, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = _os.Write_int32(pageIndex, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = req.WriteBlock(_os, 3)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 4)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"LoginLog_GetPage\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = (*res).ReadBlock(_is, 4, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func (_obj *Apilangpack) Langpack_getLanguagesOneWayWithContext(tarsCtx context.Context, params *TLlangpack_getLanguages, _opt ...map[string]string) (ret []LangPackLanguage, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 1, \"langpack_getLanguages\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (_obj *WebApiAuth) SysConfig_GetOneWayWithContext(tarsCtx context.Context, req *SysConfig, res *SysConfig, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = req.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 1, \"SysConfig_Get\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func (_obj *DataService) GetManagerClubListWithContext(tarsCtx context.Context, index int32, batch int32, wx_id string, nextIndex *int32, clubInfoList *[]ClubInfo, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(index, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(batch, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(wx_id, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*nextIndex), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.WriteHead(codec.LIST, 5)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(int32(len((*clubInfoList))), 0)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tfor _, v := range *clubInfoList {\n\n\t\terr = v.WriteBlock(_os, 0)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getManagerClubList\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*nextIndex), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr, have, ty = _is.SkipToNoCheck(5, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif ty == codec.LIST {\n\t\terr = _is.Read_int32(&length, 0, true)\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t\t(*clubInfoList) = make([]ClubInfo, length)\n\t\tfor i8, e8 := int32(0), length; i8 < e8; i8++ {\n\n\t\t\terr = (*clubInfoList)[i8].ReadBlock(_is, 0, false)\n\t\t\tif err != nil {\n\t\t\t\treturn ret, err\n\t\t\t}\n\n\t\t}\n\t} else if ty == codec.SIMPLE_LIST {\n\t\terr = fmt.Errorf(\"not support simple_list type\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t} else {\n\t\terr = fmt.Errorf(\"require vector, but not\")\n\t\tif err != nil {\n\t\t\treturn ret, err\n\t\t}\n\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func ListWithContext(ctx context.Context, repo name.Repository, options ...Option) ([]string, error) {\n\treturn List(repo, append(options, WithContext(ctx))...)\n}", "func (c *OperatingSystemsListCall) Context(ctx context.Context) *OperatingSystemsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (_obj *Apilangpack) Langpack_getLangPackWithContext(tarsCtx context.Context, params *TLlangpack_getLangPack, _opt ...map[string]string) (ret LangPackDifference, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"langpack_getLangPack\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (_obj *WebApiAuth) LoginLog_GetWithContext(tarsCtx context.Context, req *LoginLog, res *LoginLog, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = req.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"LoginLog_Get\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = (*res).ReadBlock(_is, 2, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func (_obj *Apichannels) Channels_getAdminLogWithContext(tarsCtx context.Context, params *TLchannels_getAdminLog, _opt ...map[string]string) (ret Channels_AdminLogResults, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_getAdminLog\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (iter * ServerListResultIterator) NextWithContext(ctx context.Context) (err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/ServerListResultIterator.NextWithContext\")\n defer func() {\n sc := -1\n if iter.Response().Response.Response != nil {\n sc = iter.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n iter.i++\n if iter.i < len(iter. page.Values()) {\n return nil\n }\n err = iter.page.NextWithContext(ctx)\n if err != nil {\n iter. i--\n return err\n }\n iter.i = 0\n return nil\n }", "func (page *AvailableSkusResultPage) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/AvailableSkusResultPage.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif page.Response().Response.Response != nil {\n\t\t\t\tsc = page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tnext, err := page.fn(ctx, page.asr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.asr = next\n\treturn nil\n}", "func (c *OrganizationsApiproductsListCall) Context(ctx context.Context) *OrganizationsApiproductsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *GetGroupsByTypeUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func NewGetPlatformsParamsWithContext(ctx context.Context) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\tContext: ctx,\n\t}\n}", "func (_obj *WebApiAuth) SysUser_GetWithContext(tarsCtx context.Context, req *SysUser, res *SysUser, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = req.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"SysUser_Get\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = (*res).ReadBlock(_is, 2, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func NewGetPlatformsParamsWithHTTPClient(client *http.Client) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (c *OrganizationsDevelopersAppsAttributesListCall) Context(ctx context.Context) *OrganizationsDevelopersAppsAttributesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (p *SyncMapsPaginator) NextWithContext(context context.Context) bool {\n\toptions := p.options\n\n\tif options == nil {\n\t\toptions = &SyncMapsPageOptions{}\n\t}\n\n\tif p.CurrentPage() != nil {\n\t\tnextPage := p.CurrentPage().Meta.NextPageURL\n\n\t\tif nextPage == nil {\n\t\t\treturn false\n\t\t}\n\n\t\tparsedURL, err := url.Parse(*nextPage)\n\t\tif err != nil {\n\t\t\tp.Page.Error = err\n\t\t\treturn false\n\t\t}\n\n\t\toptions.PageToken = utils.String(parsedURL.Query().Get(\"PageToken\"))\n\n\t\tpage, pageErr := strconv.Atoi(parsedURL.Query().Get(\"Page\"))\n\t\tif pageErr != nil {\n\t\t\tp.Page.Error = pageErr\n\t\t\treturn false\n\t\t}\n\t\toptions.Page = utils.Int(page)\n\n\t\tpageSize, pageSizeErr := strconv.Atoi(parsedURL.Query().Get(\"PageSize\"))\n\t\tif pageSizeErr != nil {\n\t\t\tp.Page.Error = pageSizeErr\n\t\t\treturn false\n\t\t}\n\t\toptions.PageSize = utils.Int(pageSize)\n\t}\n\n\tresp, err := p.Page.client.PageWithContext(context, options)\n\tp.Page.CurrentPage = resp\n\tp.Page.Error = err\n\n\tif p.Page.Error == nil {\n\t\tp.SyncMaps = append(p.SyncMaps, resp.SyncMaps...)\n\t}\n\n\treturn p.Page.Error == nil\n}", "func AddServantWithContext(v dispatch, f interface{}, obj string) {\n\taddServantCommon(v, f, obj, true)\n}", "func (_obj *WebApiAuth) SysConfig_GetPageOneWayWithContext(tarsCtx context.Context, pageSize int32, pageIndex int32, req *SysConfig, res *SysConfig_List, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(pageSize, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = _os.Write_int32(pageIndex, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = req.WriteBlock(_os, 3)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 4)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 1, \"SysConfig_GetPage\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func (o *GetApplianceUpgradePoliciesMoidParams) WithContext(ctx context.Context) *GetApplianceUpgradePoliciesMoidParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (s *Search) Context(ctx *gin.Context) {\n\tapp := ctx.Param(\"app\")\n\tappLabel := config.LogAppLabel()\n\toptions := config.ConvertRequestQueryParams(ctx.Request.URL.Query())\n\toptions[appLabel] = app\n\tresults, err := s.Service.Context(options, ctx.MustGet(\"page\").(models.Page))\n\tif err != nil {\n\t\tutils.ErrorResponse(ctx, utils.NewError(GetLogContextError, err))\n\t\treturn\n\t}\n\n\tutils.Ok(ctx, results)\n\treturn\n}", "func (_obj *DataService) GetClubManagerCountWithContext(tarsCtx context.Context, wx_id string, club_id string, count *int32, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_string(wx_id, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(club_id, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*count), 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getClubManagerCount\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*count), 3, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (page * ConfigurationListResultPage) NextWithContext(ctx context.Context) (err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/ConfigurationListResultPage.NextWithContext\")\n defer func() {\n sc := -1\n if page.Response().Response.Response != nil {\n sc = page.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n for {\n next, err := page.fn(ctx, page.clr)\n if err != nil {\n return err\n }\n page.clr = next\n if !next.hasNextLink() || !next.IsEmpty() {\n break\n }\n }\n return nil\n }", "func (page *OdataProductResultPage) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/OdataProductResultPage.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif page.Response().Response.Response != nil {\n\t\t\t\tsc = page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tfor {\n\t\tnext, err := page.fn(ctx, page.opr)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tpage.opr = next\n\t\tif !next.hasNextLink() || !next.IsEmpty() {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn nil\n}", "func newWithContext(ctx context.Context, token string) *GitHub {\n\treturn newWithAuth(ctx, token)\n}", "func (c *OrganizationsApiproductsAttributesCall) Context(ctx context.Context) *OrganizationsApiproductsAttributesCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (c MethodsCollection) WithContext() pWithContext {\n\treturn pWithContext{\n\t\tMethod: c.MustGet(\"WithContext\"),\n\t}\n}", "func (_obj *Apichannels) Channels_inviteToChannelWithContext(tarsCtx context.Context, params *TLchannels_inviteToChannel, _opt ...map[string]string) (ret Updates, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_inviteToChannel\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (c *OrganizationsApisListCall) Context(ctx context.Context) *OrganizationsApisListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (_obj *DataService) CreateClubManagerWithContext(tarsCtx context.Context, wx_id string, club_id string, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_string(wx_id, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(club_id, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"createClubManager\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (_obj *WebApiAuth) SysConfig_CreateWithContext(tarsCtx context.Context, req *SysConfig, res *SysConfig, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = req.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"SysConfig_Create\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = (*res).ReadBlock(_is, 2, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func (iter *AvailableSkusResultIterator) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/AvailableSkusResultIterator.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif iter.Response().Response.Response != nil {\n\t\t\t\tsc = iter.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr = iter.page.NextWithContext(ctx)\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (req *SelectRequest) Context(ctx context.Context) *SelectRequest {\n\treq.impl = req.impl.Context(ctx)\n\n\treturn req\n}", "func (h *KubernetesHelper) KubectlApplyWithContext(stdin string, context string, arg ...string) (string, error) {\n\targs := append([]string{\"apply\"}, arg...)\n\treturn h.KubectlWithContext(stdin, context, args...)\n}", "func (o *GetPlatformsParams) WithHTTPClient(client *http.Client) *GetPlatformsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (_obj *Apichannels) Channels_createChannelWithContext(tarsCtx context.Context, params *TLchannels_createChannel, _opt ...map[string]string) (ret Updates, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_createChannel\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (page *ProjectListPage) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/ProjectListPage.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif page.Response().Response.Response != nil {\n\t\t\t\tsc = page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tnext, err := page.fn(ctx, page.pl)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.pl = next\n\treturn nil\n}", "func OrganizationCtx(next http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\torganizationID := chi.URLParam(r, \"organizationID\")\n\t\tctx := context.WithValue(r.Context(), ContextKeyOrganization, organizationID)\n\t\tnext.ServeHTTP(w, r.WithContext(ctx))\n\t})\n}", "func (c *OperatingSystemsGetCall) Context(ctx context.Context) *OperatingSystemsGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *GetLighthouseOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {\n\treturn nil\n}", "func (c *OrganizationsOsConfigsListCall) Context(ctx context.Context) *OrganizationsOsConfigsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (list *SubscriptionAddOnList) FetchWithContext(ctx context.Context) error {\n\tresources := &subscriptionAddOnList{}\n\terr := list.client.Call(ctx, http.MethodGet, list.nextPagePath, nil, nil, list.requestOptions, resources)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// copy over properties from the response\n\tlist.nextPagePath = resources.Next\n\tlist.hasMore = resources.HasMore\n\tlist.data = resources.Data\n\treturn nil\n}", "func (page * DatabaseListResultPage) NextWithContext(ctx context.Context) (err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/DatabaseListResultPage.NextWithContext\")\n defer func() {\n sc := -1\n if page.Response().Response.Response != nil {\n sc = page.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n for {\n next, err := page.fn(ctx, page.dlr)\n if err != nil {\n return err\n }\n page.dlr = next\n if !next.hasNextLink() || !next.IsEmpty() {\n break\n }\n }\n return nil\n }", "func (iter * ConfigurationListResultIterator) NextWithContext(ctx context.Context) (err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/ConfigurationListResultIterator.NextWithContext\")\n defer func() {\n sc := -1\n if iter.Response().Response.Response != nil {\n sc = iter.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n iter.i++\n if iter.i < len(iter. page.Values()) {\n return nil\n }\n err = iter.page.NextWithContext(ctx)\n if err != nil {\n iter. i--\n return err\n }\n iter.i = 0\n return nil\n }", "func (c *ProjectsOsConfigsListCall) Context(ctx context.Context) *ProjectsOsConfigsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *GetGroupsByTypeUsingGETParams) WithContext(ctx context.Context) *GetGroupsByTypeUsingGETParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetMetricsParams) WithPlatforms(platforms *string) *GetMetricsParams {\n\to.SetPlatforms(platforms)\n\treturn o\n}", "func (c *OrganizationsApiproductsAttributesGetCall) Context(ctx context.Context) *OrganizationsApiproductsAttributesGetCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (iter * DatabaseListResultIterator) NextWithContext(ctx context.Context) (err error) {\n if tracing.IsEnabled() {\n ctx = tracing.StartSpan(ctx, fqdn + \"/DatabaseListResultIterator.NextWithContext\")\n defer func() {\n sc := -1\n if iter.Response().Response.Response != nil {\n sc = iter.Response().Response.Response.StatusCode\n }\n tracing.EndSpan(ctx, sc, err)\n }()\n }\n iter.i++\n if iter.i < len(iter. page.Values()) {\n return nil\n }\n err = iter.page.NextWithContext(ctx)\n if err != nil {\n iter. i--\n return err\n }\n iter.i = 0\n return nil\n }", "func (c *LanguagesListCall) Context(ctx context.Context) *LanguagesListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (_obj *Apichannels) Channels_getParticipantsWithContext(tarsCtx context.Context, params *TLchannels_getParticipants, _opt ...map[string]string) (ret Channels_ChannelParticipants, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_getParticipants\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (c *OrganizationsOsConfigsPatchCall) Context(ctx context.Context) *OrganizationsOsConfigsPatchCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (lt *ListTables) AllWithContext(ctx context.Context) ([]string, error) {\n\tvar tables []string\n\titr := lt.Iter()\n\tvar name string\n\tfor itr.NextWithContext(ctx, &name) {\n\t\ttables = append(tables, name)\n\t}\n\treturn tables, itr.Err()\n}", "func (_obj *WebApiAuth) SysConfig_UpdateWithContext(tarsCtx context.Context, id int32, req *SysConfig, res *SysConfig, _opt ...map[string]string) (err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_int32(id, 1)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = req.WriteBlock(_os, 2)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = (*res).WriteBlock(_os, 3)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"SysConfig_Update\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = (*res).ReadBlock(_is, 3, true)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn nil\n}", "func (h initALPNRequest) BaseContext() context.Context { return h.ctx }", "func (page *SQLServerListResultPage) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/SQLServerListResultPage.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif page.Response().Response.Response != nil {\n\t\t\t\tsc = page.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\tnext, err := page.fn(ctx, page.sslr)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpage.sslr = next\n\treturn nil\n}", "func RawWithContext(ctx context.Context, cmd string, options ...types.Option) (string, error) {\n\treturn command(ctx, cmd, options...)\n}", "func (c Client) PageWithContext(context context.Context, options *SyncMapsPageOptions) (*SyncMapsPageResponse, error) {\n\top := client.Operation{\n\t\tMethod: http.MethodGet,\n\t\tURI: \"/Services/{serviceSid}/Maps\",\n\t\tPathParams: map[string]string{\n\t\t\t\"serviceSid\": c.serviceSid,\n\t\t},\n\t\tQueryParams: utils.StructToURLValues(options),\n\t}\n\n\tresponse := &SyncMapsPageResponse{}\n\tif err := c.client.Send(context, op, nil, response); err != nil {\n\t\treturn nil, err\n\t}\n\treturn response, nil\n}", "func (c *RoomsWebhooksCall) Context(ctx context.Context) *RoomsWebhooksCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (s *SizedWaitGroup) AddWithContext(ctx context.Context) error {\n\tselect {\n\tcase <-ctx.Done():\n\t\treturn ctx.Err()\n\tcase s.current <- struct{}{}:\n\t\tbreak\n\t}\n\ts.wg.Add(1)\n\treturn nil\n}", "func (o *PublicWebLinkPlatformEstablishParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (_obj *Apichannels) Channels_getGroupsForDiscussionWithContext(tarsCtx context.Context, params *TLchannels_getGroupsForDiscussion, _opt ...map[string]string) (ret Messages_Chats, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_getGroupsForDiscussion\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (p *BuildsPaginator) NextWithContext(context context.Context) bool {\n\toptions := p.options\n\n\tif options == nil {\n\t\toptions = &BuildsPageOptions{}\n\t}\n\n\tif p.CurrentPage() != nil {\n\t\tnextPage := p.CurrentPage().Meta.NextPageURL\n\n\t\tif nextPage == nil {\n\t\t\treturn false\n\t\t}\n\n\t\tparsedURL, err := url.Parse(*nextPage)\n\t\tif err != nil {\n\t\t\tp.Page.Error = err\n\t\t\treturn false\n\t\t}\n\n\t\toptions.PageToken = utils.String(parsedURL.Query().Get(\"PageToken\"))\n\n\t\tpage, pageErr := strconv.Atoi(parsedURL.Query().Get(\"Page\"))\n\t\tif pageErr != nil {\n\t\t\tp.Page.Error = pageErr\n\t\t\treturn false\n\t\t}\n\t\toptions.Page = utils.Int(page)\n\n\t\tpageSize, pageSizeErr := strconv.Atoi(parsedURL.Query().Get(\"PageSize\"))\n\t\tif pageSizeErr != nil {\n\t\t\tp.Page.Error = pageSizeErr\n\t\t\treturn false\n\t\t}\n\t\toptions.PageSize = utils.Int(pageSize)\n\t}\n\n\tresp, err := p.Page.client.PageWithContext(context, options)\n\tp.Page.CurrentPage = resp\n\tp.Page.Error = err\n\n\tif p.Page.Error == nil {\n\t\tp.Builds = append(p.Builds, resp.Builds...)\n\t}\n\n\treturn p.Page.Error == nil\n}", "func (web *webConfig) PrependWithContextRoot(path string) string {\n\treturn web.ContextRoot + strings.Trim(path, \"/\")\n}", "func (_obj *DataService) GetApplyCountWithContext(tarsCtx context.Context, wx_id string, club_id string, apply_status int32, count *int32, _opt ...map[string]string) (ret int32, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = _os.Write_string(wx_id, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_string(club_id, 2)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32(apply_status, 3)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _os.Write_int32((*count), 4)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"getApplyCount\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = _is.Read_int32(&ret, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\terr = _is.Read_int32(&(*count), 4, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (iter *MonitoringTagRulesListResponseIterator) NextWithContext(ctx context.Context) (err error) {\n\tif tracing.IsEnabled() {\n\t\tctx = tracing.StartSpan(ctx, fqdn+\"/MonitoringTagRulesListResponseIterator.NextWithContext\")\n\t\tdefer func() {\n\t\t\tsc := -1\n\t\t\tif iter.Response().Response.Response != nil {\n\t\t\t\tsc = iter.Response().Response.Response.StatusCode\n\t\t\t}\n\t\t\ttracing.EndSpan(ctx, sc, err)\n\t\t}()\n\t}\n\titer.i++\n\tif iter.i < len(iter.page.Values()) {\n\t\treturn nil\n\t}\n\terr = iter.page.NextWithContext(ctx)\n\tif err != nil {\n\t\titer.i--\n\t\treturn err\n\t}\n\titer.i = 0\n\treturn nil\n}", "func (c *OrganizationsAppsListCall) Context(ctx context.Context) *OrganizationsAppsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (_obj *Apichannels) Channels_setStickersWithContext(tarsCtx context.Context, params *TLchannels_setStickers, _opt ...map[string]string) (ret Bool, err error) {\n\n\tvar length int32\n\tvar have bool\n\tvar ty byte\n\t_os := codec.NewBuffer()\n\terr = params.WriteBlock(_os, 1)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tvar _status map[string]string\n\tvar _context map[string]string\n\tif len(_opt) == 1 {\n\t\t_context = _opt[0]\n\t} else if len(_opt) == 2 {\n\t\t_context = _opt[0]\n\t\t_status = _opt[1]\n\t}\n\t_resp := new(requestf.ResponsePacket)\n\n\terr = _obj.s.Tars_invoke(tarsCtx, 0, \"channels_setStickers\", _os.ToBytes(), _status, _context, _resp)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\t_is := codec.NewReader(tools.Int8ToByte(_resp.SBuffer))\n\terr = ret.ReadBlock(_is, 0, true)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif len(_opt) == 1 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t} else if len(_opt) == 2 {\n\t\tfor k := range _context {\n\t\t\tdelete(_context, k)\n\t\t}\n\t\tfor k, v := range _resp.Context {\n\t\t\t_context[k] = v\n\t\t}\n\t\tfor k := range _status {\n\t\t\tdelete(_status, k)\n\t\t}\n\t\tfor k, v := range _resp.Status {\n\t\t\t_status[k] = v\n\t\t}\n\n\t}\n\t_ = length\n\t_ = have\n\t_ = ty\n\treturn ret, nil\n}", "func (c *OrganizationsAppgroupsListCall) Context(ctx context.Context) *OrganizationsAppgroupsListCall {\n\tc.ctx_ = ctx\n\treturn c\n}", "func (o *GetFileSystemParametersInternalParams) WithContext(ctx context.Context) *GetFileSystemParametersInternalParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (p *ShortCodesPaginator) NextWithContext(context context.Context) bool {\n\toptions := p.options\n\n\tif options == nil {\n\t\toptions = &ShortCodesPageOptions{}\n\t}\n\n\tif p.CurrentPage() != nil {\n\t\tnextPage := p.CurrentPage().Meta.NextPageURL\n\n\t\tif nextPage == nil {\n\t\t\treturn false\n\t\t}\n\n\t\tparsedURL, err := url.Parse(*nextPage)\n\t\tif err != nil {\n\t\t\tp.Page.Error = err\n\t\t\treturn false\n\t\t}\n\n\t\toptions.PageToken = utils.String(parsedURL.Query().Get(\"PageToken\"))\n\n\t\tpage, pageErr := strconv.Atoi(parsedURL.Query().Get(\"Page\"))\n\t\tif pageErr != nil {\n\t\t\tp.Page.Error = pageErr\n\t\t\treturn false\n\t\t}\n\t\toptions.Page = utils.Int(page)\n\n\t\tpageSize, pageSizeErr := strconv.Atoi(parsedURL.Query().Get(\"PageSize\"))\n\t\tif pageSizeErr != nil {\n\t\t\tp.Page.Error = pageSizeErr\n\t\t\treturn false\n\t\t}\n\t\toptions.PageSize = utils.Int(pageSize)\n\t}\n\n\tresp, err := p.Page.client.PageWithContext(context, options)\n\tp.Page.CurrentPage = resp\n\tp.Page.Error = err\n\n\tif p.Page.Error == nil {\n\t\tp.ShortCodes = append(p.ShortCodes, resp.ShortCodes...)\n\t}\n\n\treturn p.Page.Error == nil\n}" ]
[ "0.5653029", "0.54843134", "0.54253876", "0.5395974", "0.53492355", "0.5234491", "0.5172244", "0.5167735", "0.5149963", "0.51398677", "0.506741", "0.503723", "0.5010748", "0.50087667", "0.50020254", "0.4988482", "0.49845147", "0.4980806", "0.496598", "0.4955769", "0.49531364", "0.49399894", "0.4939377", "0.49386948", "0.4931887", "0.49193397", "0.49161482", "0.49040222", "0.49008054", "0.48949108", "0.48786825", "0.4876992", "0.48708528", "0.48699486", "0.48594022", "0.48530126", "0.48525172", "0.48498303", "0.48478112", "0.4845482", "0.4832445", "0.48307598", "0.48258814", "0.48148212", "0.4802306", "0.47906777", "0.47860762", "0.4783062", "0.47780928", "0.47494256", "0.4748136", "0.47431406", "0.47385982", "0.47367162", "0.47336656", "0.47297564", "0.47241375", "0.47222748", "0.47181088", "0.47145146", "0.47106478", "0.47069517", "0.4703451", "0.47026193", "0.46968713", "0.4693432", "0.4691131", "0.46855116", "0.46852636", "0.4675908", "0.4671244", "0.4667281", "0.4665705", "0.46620443", "0.4657261", "0.46532208", "0.46532077", "0.4652948", "0.4652263", "0.46471876", "0.46468696", "0.46446586", "0.4637165", "0.46362427", "0.46350443", "0.46296015", "0.46291775", "0.4628624", "0.46281853", "0.46261522", "0.46254414", "0.4622172", "0.4619836", "0.46128806", "0.46121755", "0.46108997", "0.4608877", "0.46029422", "0.4598427", "0.4590658" ]
0.6553357
0
SetContext adds the context to the get platforms params
func (o *GetPlatformsParams) SetContext(ctx context.Context) { o.Context = ctx }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetGPUArchitectureParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PublicWebLinkPlatformEstablishParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetaspecificPbxDeviceFirmwareBinaryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetContentSourcesUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetOperatingSystemsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPlatformsParams) WithContext(ctx context.Context) *GetPlatformsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetContentSourceUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRepositoriesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetBundleByKeyParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetGroupsByTypeUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetDevicesAllParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRuntimeServersParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetOrganizationPrototypePermissionsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *MetroclusterInterconnectGetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetDevicesUnknownParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRepository15Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetApplianceUpgradePoliciesMoidParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetProductUpgradeURLUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPageDataUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetWormDomainParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *AllLookmlTestsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetUIParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetLogicalPortParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *SyncStatusUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PublicPlatformLinkV3Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetDeploymentByIDV3UsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ServeBuildTypesInProjectParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetProductsByIDPromotionsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PutLolPerksV1CurrentpageParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetSellerServicesUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRemotesupportConnectemcParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *DevicesGetModuleComponentCommandHistoryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PcloudNetworksGetallParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetSeriesIDEpisodesQueryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPortInfoUsingGET2Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRepositoriesRepoNameSignaturesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetFileSystemParametersInternalParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *EavAttributeSetRepositoryV1GetGetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PostAPIV3MachinesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PatchStorageVirtualDriveExtensionsMoidParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPluginEndpointParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PcloudSystempoolsGetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *HandleGetAboutUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPublicAuthParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRackTopoesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *IntegrationsManualHTTPSCreateParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PcloudSapGetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ReadStorageV1CSIDriverParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetCharacterParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPointsByQueryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetTerraformConfigurationSourcesUsingGET1Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetPrivateOrderstateParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetFirmwareUpgradeStatusesMoidParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ExportProductsUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetDeploymentPreview1Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetProductsCodeParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetNetworkAppliancePortParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetClockParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetNetworkExternalParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *DetectLanguageParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetLTENetworkIDPolicyQosProfilesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetAllPublicIPUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *CatalogProductCustomOptionRepositoryV1GetListGetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetAPI24ArraysNtpTestParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ExportUsingGETParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetRacksParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetCurrentGenerationParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *NearestUsingGET1Params) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *QueryEntitlementsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetLolInventoryV1PlayersByPuuidInventoryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateNetworkHTTPServerParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetOutagesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UploadPluginParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *APIServiceHaltsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PatchAddonParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PostHyperflexAutoSupportPoliciesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListEngineTypeParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetFyiSettingsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetSsoParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetDeploymentTargetOperatingSystemNamesListAllParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PatchSepainstantIDParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetTasksGetPhpParams) SetContext(ctx ccontext.Context) {\n\to.Context = ctx\n}", "func (o *GetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *CreateGitWebhookUsingPOSTParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetOrganizationTeamPermissionsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetInterceptionitemsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetHistogramStatByParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetWorkflowBuildTaskMetaMoidParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *UpdateCustomIDPParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *ListPipelinesParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *AddRepositoryParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PutMenuItemParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *RTRExecuteActiveResponderCommandParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PostMultiNodeDeviceParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *SMSHistoryExportGetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *GetProcessorsParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (_m *MockHTTPServerInterface) SetContext(_a0 context.Context) {\n\t_m.Called(_a0)\n}", "func (o *OrgGetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}", "func (o *PcloudPvminstancesNetworksGetParams) SetContext(ctx context.Context) {\n\to.Context = ctx\n}" ]
[ "0.6786597", "0.6569877", "0.6501057", "0.6415769", "0.64072716", "0.6354175", "0.63233936", "0.63068795", "0.63018876", "0.6285175", "0.6277759", "0.6277518", "0.627217", "0.6267961", "0.6259615", "0.6256487", "0.62138826", "0.6211839", "0.6208424", "0.6195113", "0.6182538", "0.6180525", "0.61781996", "0.61761576", "0.6172562", "0.61606175", "0.6155937", "0.6155446", "0.6152427", "0.61523056", "0.61401606", "0.6127879", "0.61225826", "0.6119044", "0.611785", "0.6112749", "0.61073184", "0.6102014", "0.6085758", "0.6083558", "0.6077491", "0.6075497", "0.60746396", "0.60733247", "0.6066256", "0.6059931", "0.60521615", "0.6047956", "0.6040408", "0.6039657", "0.6036512", "0.6031754", "0.6028658", "0.60259396", "0.60185415", "0.6017292", "0.60162765", "0.6013491", "0.59979457", "0.59959346", "0.5984074", "0.5984005", "0.5972527", "0.59556925", "0.5952463", "0.5945898", "0.5936187", "0.5936043", "0.593348", "0.59261274", "0.5923416", "0.5920921", "0.5919933", "0.5919569", "0.5916605", "0.5910356", "0.59081405", "0.5908124", "0.59048927", "0.59012014", "0.589681", "0.5892809", "0.58912045", "0.588634", "0.5885263", "0.5884526", "0.5883665", "0.5883416", "0.58796483", "0.58772737", "0.58772457", "0.58770555", "0.58725613", "0.5861844", "0.58542067", "0.58537537", "0.5852061", "0.58516043", "0.5850068", "0.5846796" ]
0.7558212
0
WithHTTPClient adds the HTTPClient to the get platforms params
func (o *GetPlatformsParams) WithHTTPClient(client *http.Client) *GetPlatformsParams { o.SetHTTPClient(client) return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetPlatformsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func NewGetPlatformsParamsWithHTTPClient(client *http.Client) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *GetBundleByKeyParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOperatingSystemsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGPUArchitectureParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PublicWebLinkPlatformEstablishParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDevicesAllParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGroupsByTypeUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetContentSourcesUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDeploymentByIDV3UsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDevicesUnknownParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PcloudNetworksGetallParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PutMenuItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOrganizationApplicationParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetaspecificPbxDeviceFirmwareBinaryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOperatingSystemsParams) WithHTTPClient(client *http.Client) *GetOperatingSystemsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *ServeBuildTypesInProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetContentSourceUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AllLookmlTestsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetClockParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *MetroclusterInterconnectGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListAllTeamsSpacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *QueryEntitlementsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProductsCodeParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SyncStatusUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *HandleGetAboutUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListStacksByWorkspaceParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetWormDomainParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetUIParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PcloudSystempoolsGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ExportProductsUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetBuildPropertiesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetItemByAppIDParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetSellerServicesUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PublicPlatformLinkV3Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetNetworkExternalParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProductsByIDPromotionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func WithHTTPClient(client *http.Client) OptionFunc {\n\treturn func(c *Client) {\n\t\tc.client = client\n\t}\n}", "func (o *GetPageDataUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CreateCrossConnectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLogicalSwitchParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ConfigGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOrganizationTeamPermissionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *OrgGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListAllKeyspacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetWorkflowBuildTaskMetaMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CatalogProductCustomOptionRepositoryV1GetListGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListResourceTypesUsingGET2Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetComplianceByResourceTypesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SearchWorkspacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ServiceBrokerOpenstacksHostsGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *NearestUsingGET1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProjectMetricsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetAllPublicIPUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetTerraformConfigurationSourcesUsingGET1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PcloudSapGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func WithHTTPClient(c *http.Client) Option {\n\treturn func(args *Client) {\n\t\targs.httpClient = c\n\t}\n}", "func WithHTTPClient(client *http.Client) Option {\n\treturn func(o *Options) {\n\t\to.Client = client\n\t}\n}", "func (o *GetV1TicketingProjectsTicketingProjectIDConfigurationOptionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetNetworkAppliancePortParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetFileSystemParametersInternalParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetTradingPairParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetApplianceUpgradePoliciesMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CapacityPoolGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PcloudPvminstancesNetworksGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetSearchClinicsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetTreeParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CreateWidgetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetInterceptionitemsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetRepositoriesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateZoneProjectsUsingPUTParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetListParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLTENetworkIDPolicyQosProfilesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListSSHKeysParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGCParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ReplaceProjectsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func WithHTTPClient(h *http.Client) APIOption {\n\treturn newAPIOption(func(o *Options) {\n\t\tif h == nil {\n\t\t\treturn\n\t\t}\n\t\to.HTTPClient = h\n\t})\n}", "func WithHTTPClient(client HTTPClient) Option {\n\treturn func(opts *Client) {\n\t\topts.httpClient = client\n\t}\n}", "func (o *QueryFirewallFieldsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *EavAttributeSetRepositoryV1GetGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetTasksGetPhpParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostMenuItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListEngineTypeParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetIconParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PutLolPerksV1CurrentpageParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDatalakeDbConfigParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func WithHTTPClient(client *http.Client) Opt {\n\treturn func(c *Client) error {\n\t\tif client != nil {\n\t\t\tc.client = client\n\t\t}\n\t\treturn nil\n\t}\n}", "func (o *GetSeriesIDEpisodesQueryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func WithHTTPClient(httpClient *http.Client) ClientOption {\n\treturn func(c *Client) {\n\t\tc.sling.Client(httpClient)\n\t}\n}", "func (o *GetLogicalPortParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostAPIV3MachinesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *OptionsTodoTodoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *TurnOnLightParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *JoinOrganizationParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetSMSitemsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchAssetDeviceConfigurationsMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PutParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetWorkItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}" ]
[ "0.74874324", "0.67684495", "0.6612133", "0.66043484", "0.65645367", "0.6550549", "0.6467634", "0.64491713", "0.64115715", "0.6409021", "0.63899356", "0.63747627", "0.6371442", "0.635973", "0.6344963", "0.6342673", "0.63373876", "0.6336873", "0.63319355", "0.63319236", "0.63301986", "0.6300957", "0.62910944", "0.62886673", "0.62812364", "0.627991", "0.6265734", "0.6254123", "0.6252281", "0.6250572", "0.6242972", "0.62428653", "0.62424964", "0.6240266", "0.62352973", "0.62313855", "0.62253535", "0.62253517", "0.62216413", "0.6220953", "0.62198687", "0.6218658", "0.62147015", "0.62123424", "0.61948556", "0.619146", "0.61883307", "0.6186196", "0.6179608", "0.617847", "0.6177617", "0.61772597", "0.6170524", "0.6168256", "0.6167283", "0.61650544", "0.61617", "0.6159583", "0.6156843", "0.6155918", "0.6155457", "0.6154477", "0.6152046", "0.61500984", "0.6148264", "0.6143378", "0.6142432", "0.61286443", "0.61238927", "0.6122129", "0.61196214", "0.611905", "0.6111727", "0.61098665", "0.6109545", "0.61082274", "0.6107429", "0.610684", "0.61029285", "0.60910594", "0.60906893", "0.60883236", "0.6087976", "0.608793", "0.60877466", "0.6086774", "0.6085416", "0.60847074", "0.608269", "0.60785896", "0.60783446", "0.60731936", "0.60727715", "0.6067443", "0.6067329", "0.60576636", "0.6057072", "0.6056149", "0.60541916", "0.6052378" ]
0.75234395
0
SetHTTPClient adds the HTTPClient to the get platforms params
func (o *GetPlatformsParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetGPUArchitectureParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetBundleByKeyParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PublicWebLinkPlatformEstablishParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetContentSourcesUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOperatingSystemsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetContentSourceUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *MetroclusterInterconnectGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDeploymentByIDV3UsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetUIParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AllLookmlTestsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *HandleGetAboutUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetNetworkExternalParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ConfigGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ServeBuildTypesInProjectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListStacksByWorkspaceParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetWorkflowBuildTaskMetaMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SyncStatusUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLogicalSwitchParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *DevicesGetModuleComponentCommandHistoryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDevicesAllParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetClockParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PutMenuItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CreateCrossConnectParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGroupsByTypeUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ExportProductsUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetTerraformConfigurationSourcesUsingGET1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDevicesUnknownParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *QueryEntitlementsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetPageDataUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *IntegrationsManualHTTPSCreateParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PcloudNetworksGetallParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PcloudSystempoolsGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetSellerServicesUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PublicPlatformLinkV3Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLolClashV1ThirdpartyTeamDataParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetNetworkAppliancePortParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListAllTeamsSpacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetCurrentGenerationParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetFyiSettingsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLogicalPortParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProductsByIDPromotionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetFileSystemParametersInternalParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ReadLogicalRouterParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProductUpgradeURLUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetSimulationActivityParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetBuildPropertiesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *TurnOnLightParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *NearestUsingGET1Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetApplianceUpgradePoliciesMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CreateWidgetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetGCParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOrganizationApplicationParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetaspecificPbxDeviceFirmwareBinaryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetDatalakeDbConfigParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ExportUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *RegisterApplicationParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetWormDomainParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetRemotesupportConnectemcParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProductsCodeParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SearchWorkspacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *OptionsTodoTodoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PatchAssetDeviceConfigurationsMoidParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetBootstrapParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListAllKeyspacesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ToggleNetworkGeneratorsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListEngineTypeParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func SetHTTPClient(client *http.Client) {\n\thttpClient = client\n}", "func (o *GetTreeParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetRepositoriesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *EavAttributeSetRepositoryV1GetGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ReplaceProjectsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetProjectMetricsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PutLolPerksV1CurrentpageParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetIconParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetPluginEndpointParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetOrganizationTeamPermissionsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetLTENetworkIDPolicyQosProfilesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetTasksGetPhpParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetPortInfoUsingGET2Params) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostHyperflexAutoSupportPoliciesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *UpdateNetworkSwitchAccessControlListsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetCustomRuleParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListSSHKeysParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetRackTopoesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *SetPlanParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetRuleChainParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CapacityPoolGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostMenuItemParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *ListPipelinesParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetAllPublicIPUsingGETParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PcloudSapGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PostSecdefSearchParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *PutFlagSettingParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CatalogProductCustomOptionRepositoryV1GetListGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *AddRepositoryParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *OrgGetParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetTradingPairParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *GetSearchClinicsParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}", "func (o *CreateCartUsingPOSTParams) SetHTTPClient(client *http.Client) {\n\to.HTTPClient = client\n}" ]
[ "0.7773785", "0.76442534", "0.76175207", "0.76163924", "0.7615906", "0.7574128", "0.75327814", "0.75107133", "0.7496636", "0.7492477", "0.74772483", "0.7469208", "0.74516153", "0.7449262", "0.74492323", "0.7444003", "0.744089", "0.74403507", "0.7437406", "0.7435754", "0.74265", "0.74175924", "0.74115163", "0.7395951", "0.73939055", "0.7392341", "0.7386824", "0.7386366", "0.7377959", "0.7372895", "0.7371805", "0.7368791", "0.73685664", "0.7360024", "0.73557925", "0.73518443", "0.7350989", "0.73395556", "0.7337693", "0.7337693", "0.7336677", "0.73359025", "0.7333295", "0.7329089", "0.73274636", "0.73260546", "0.73251384", "0.73224705", "0.7311756", "0.7310342", "0.73088264", "0.73066413", "0.7303204", "0.7301229", "0.72989154", "0.72976285", "0.72976243", "0.729648", "0.7294562", "0.7293027", "0.7287597", "0.72871196", "0.728225", "0.72814393", "0.7281002", "0.72763145", "0.7275031", "0.72715163", "0.726914", "0.72651637", "0.725812", "0.72550464", "0.72529835", "0.7244006", "0.7243468", "0.7240724", "0.7240025", "0.7237201", "0.7234417", "0.7230465", "0.72266173", "0.7224894", "0.72230023", "0.7222541", "0.7220418", "0.72181714", "0.7215882", "0.7214113", "0.7212931", "0.7211499", "0.72108644", "0.72049534", "0.7201038", "0.72001326", "0.71976364", "0.71971023", "0.7195418", "0.71878934", "0.7186889", "0.7185485" ]
0.8377742
0
WithExtended adds the extended to the get platforms params
func (o *GetPlatformsParams) WithExtended(extended *bool) *GetPlatformsParams { o.SetExtended(extended) return o }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetPlatformsParams) SetExtended(extended *bool) {\n\to.Extended = extended\n}", "func (b *MessagesGetHistoryBuilder) Extended(v bool) *MessagesGetHistoryBuilder {\n\tb.Params[\"extended\"] = v\n\treturn b\n}", "func (b *MessagesGetByIDBuilder) Extended(v bool) *MessagesGetByIDBuilder {\n\tb.Params[\"extended\"] = v\n\treturn b\n}", "func (b *MessagesGetConversationsByIDBuilder) Extended(v bool) *MessagesGetConversationsByIDBuilder {\n\tb.Params[\"extended\"] = v\n\treturn b\n}", "func (o *VulnerabilitiesRequest) SetExtended(v bool) {\n\to.Extended = &v\n}", "func (b *MessagesGetByConversationMessageIDBuilder) Extended(v bool) *MessagesGetByConversationMessageIDBuilder {\n\tb.Params[\"extended\"] = v\n\treturn b\n}", "func (vk *VK) AppsGetLeaderboardExtended(params map[string]string) (response AppsGetLeaderboardExtendedResponse, vkErr Error) {\n\tparams[\"extended\"] = \"1\"\n\tvk.RequestUnmarshal(\"apps.getLeaderboard\", params, &response, &vkErr)\n\treturn\n}", "func (p *HostedProgramInfo) Extend(ext auth.SubPrin) {\n\tp.subprin = append(p.subprin, ext...)\n}", "func MergeRawExtension(base *runtime.RawExtension, patch *runtime.RawExtension) (*runtime.RawExtension, error) {\n\tpatchParameter, err := util.RawExtension2Map(patch)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to convert patch parameters to map\")\n\t}\n\tbaseParameter, err := util.RawExtension2Map(base)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to convert base parameters to map\")\n\t}\n\tif baseParameter == nil {\n\t\tbaseParameter = make(map[string]interface{})\n\t}\n\terr = mergo.Merge(&baseParameter, patchParameter, mergo.WithOverride)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to do merge with override\")\n\t}\n\tbs, err := json.Marshal(baseParameter)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to marshal merged properties\")\n\t}\n\treturn &runtime.RawExtension{Raw: bs}, nil\n}", "func (o *GetPlatformsParams) WithContext(ctx context.Context) *GetPlatformsParams {\n\to.SetContext(ctx)\n\treturn o\n}", "func (o *GetPlatformsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Extended != nil {\n\n\t\t// query param extended\n\t\tvar qrExtended bool\n\t\tif o.Extended != nil {\n\t\t\tqrExtended = *o.Extended\n\t\t}\n\t\tqExtended := swag.FormatBool(qrExtended)\n\t\tif qExtended != \"\" {\n\t\t\tif err := r.SetQueryParam(\"extended\", qExtended); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (m pFieldsGet) Extend(fnct func(m.UserSet, models.FieldsGetArgs) map[string]*models.FieldInfo) pFieldsGet {\n\treturn pFieldsGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m pContextGet) Extend(fnct func(m.UserSet) *types.Context) pContextGet {\n\treturn pContextGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (o *VulnerabilitiesRequest) HasExtended() bool {\n\tif o != nil && o.Extended != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (m pGetToolbar) Extend(fnct func(m.UserSet) webtypes.Toolbar) pGetToolbar {\n\treturn pGetToolbar{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m pDefaultGet) Extend(fnct func(m.UserSet) m.UserData) pDefaultGet {\n\treturn pDefaultGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (o *VulnerabilitiesRequest) GetExtendedOk() (*bool, bool) {\n\tif o == nil || o.Extended == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Extended, true\n}", "func WithStandardUserAgent(platform string, systemCode string) Option {\n\treturn func(d *ExtensibleTransport) {\n\t\text := NewUserAgentExtension(standardUserAgent(platform, systemCode))\n\t\td.extensions = append(d.extensions, ext)\n\t}\n}", "func (m pIsSystem) Extend(fnct func(m.UserSet) bool) pIsSystem {\n\treturn pIsSystem{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (extension *IotHubExtension) GetExtendedResources() []genruntime.KubernetesResource {\n\treturn []genruntime.KubernetesResource{\n\t\t&v20210702.IotHub{},\n\t\t&v20210702s.IotHub{}}\n}", "func (o *VulnerabilitiesRequest) GetExtended() bool {\n\tif o == nil || o.Extended == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.Extended\n}", "func TestGetExtraSpecs(t *testing.T) {\n\tth.SetupHTTP()\n\tdefer th.TeardownHTTP()\n\n\tMockGetExtraSpecsResponse(t)\n\n\tst, err := sharetypes.GetExtraSpecs(client.ServiceClient(), \"shareTypeID\").Extract()\n\tth.AssertNoErr(t, err)\n\n\tth.AssertEquals(t, st[\"snapshot_support\"], \"True\")\n\tth.AssertEquals(t, st[\"driver_handles_share_servers\"], \"True\")\n\tth.AssertEquals(t, st[\"my_custom_extra_spec\"], \"False\")\n}", "func (m pNameGet) Extend(fnct func(m.UserSet) string) pNameGet {\n\treturn pNameGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (client *MachineExtensionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif extensionName == \"\" {\n\t\treturn nil, errors.New(\"parameter extensionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{extensionName}\", url.PathEscape(extensionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-10-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (b *OrganizationRequestBuilder) Extensions() *OrganizationExtensionsCollectionRequestBuilder {\n\tbb := &OrganizationExtensionsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/extensions\"\n\treturn bb\n}", "func ExampleMachineExtensionsClient_Get() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armconnectedvmware.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewMachineExtensionsClient().Get(ctx, \"myResourceGroup\", \"myMachine\", \"CustomScriptExtension\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.MachineExtension = armconnectedvmware.MachineExtension{\n\t// \tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \tType: to.Ptr(\"Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions\"),\n\t// \tID: to.Ptr(\"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension\"),\n\t// \tLocation: to.Ptr(\"eastus2euap\"),\n\t// \tProperties: &armconnectedvmware.MachineExtensionProperties{\n\t// \t\tType: to.Ptr(\"string\"),\n\t// \t\tAutoUpgradeMinorVersion: to.Ptr(false),\n\t// \t\tInstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{\n\t// \t\t\tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tType: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tStatus: &armconnectedvmware.MachineExtensionInstanceViewStatus{\n\t// \t\t\t\tCode: to.Ptr(\"success\"),\n\t// \t\t\t\tDisplayStatus: to.Ptr(\"Provisioning succeeded\"),\n\t// \t\t\t\tLevel: to.Ptr(armconnectedvmware.StatusLevelTypes(\"Information\")),\n\t// \t\t\t\tMessage: to.Ptr(\"Finished executing command, StdOut: , StdErr:\"),\n\t// \t\t\t\tTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2019-08-08T20:42:10.999Z\"); return t}()),\n\t// \t\t\t},\n\t// \t\t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t\t},\n\t// \t\tProvisioningState: to.Ptr(\"Succeeded\"),\n\t// \t\tPublisher: to.Ptr(\"Microsoft.Compute\"),\n\t// \t\tSettings: \"@{commandToExecute=powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\"}\",\n\t// \t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t},\n\t// }\n}", "func getSupportedExtensions() map[string][]string {\n\t// In future when list of extensions grow, it will make\n\t// more sense to populate it in a dynamic way.\n\n\t// These are RHCOS supported extensions.\n\t// Each extension keeps a list of packages required to get enabled on host.\n\treturn map[string][]string{\n\t\t\"wasm\": {\"crun-wasm\"},\n\t\t\"ipsec\": {\"NetworkManager-libreswan\", \"libreswan\"},\n\t\t\"usbguard\": {\"usbguard\"},\n\t\t\"kerberos\": {\"krb5-workstation\", \"libkadm5\"},\n\t\t\"kernel-devel\": {\"kernel-devel\", \"kernel-headers\"},\n\t\t\"sandboxed-containers\": {\"kata-containers\"},\n\t}\n}", "func (*entityImpl) ExtendedAttributes(p graphql.ResolveParams) (interface{}, error) {\n\tentity := p.Source.(*types.Entity)\n\treturn wrapExtendedAttributes(entity.ExtendedAttributes), nil\n}", "func (r *Search) Ext(ext map[string]json.RawMessage) *Search {\n\n\tr.req.Ext = ext\n\n\treturn r\n}", "func (m pGetLoginDomain) Extend(fnct func(m.UserSet, string) q.UserCondition) pGetLoginDomain {\n\treturn pGetLoginDomain{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m pWithEnv) Extend(fnct func(m.UserSet, models.Environment) m.UserSet) pWithEnv {\n\treturn pWithEnv{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (opts CreateOptions) Extend(other CreateOptions) CreateOptions {\n\tvar out CreateOptions\n\tout = append(out, opts...)\n\tout = append(out, other...)\n\treturn out\n}", "func (opts CreateOptions) Extend(other CreateOptions) CreateOptions {\n\tvar out CreateOptions\n\tout = append(out, opts...)\n\tout = append(out, other...)\n\treturn out\n}", "func (m pGetRecord) Extend(fnct func(m.UserSet, string) m.UserSet) pGetRecord {\n\treturn pGetRecord{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m *DeviceRequestBuilder) Extensions()(*i052c31265100c50ded0dfb7ace15f5bda9fcabb7268d24b57f25c5f7a0bc8ca0.ExtensionsRequestBuilder) {\n return i052c31265100c50ded0dfb7ace15f5bda9fcabb7268d24b57f25c5f7a0bc8ca0.NewExtensionsRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "func (m pFieldsViewGet) Extend(fnct func(m.UserSet, webtypes.FieldsViewGetParams) *webtypes.FieldsViewData) pFieldsViewGet {\n\treturn pFieldsViewGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (o *GetPlatformsParams) WithTimeout(timeout time.Duration) *GetPlatformsParams {\n\to.SetTimeout(timeout)\n\treturn o\n}", "func GetCommonExtendedInfo() (map[string]string) {\n extendedInfo := map[string]string{\n \"csi_created_by_plugin_name\": CsiPluginName,\n \"csi_created_by_plugin_version\": Version,\n \"csi_created_by_plugin_git_hash\": Githash,\n \"csi_created_by_csi_version\": CsiVersion,\n }\n return extendedInfo\n}", "func NewGetPlatformsParams() *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: cr.DefaultTimeout,\n\t}\n}", "func WithExtensions(extensions map[string]string) CallOpt {\n\treturn func(c *call) error {\n\t\tc.extensions = extensions\n\t\treturn nil\n\t}\n}", "func NewGetPlatformsParamsWithHTTPClient(client *http.Client) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (b *PostRequestBuilder) MultiValueExtendedProperties() *PostMultiValueExtendedPropertiesCollectionRequestBuilder {\n\tbb := &PostMultiValueExtendedPropertiesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/multiValueExtendedProperties\"\n\treturn bb\n}", "func (m *AdministrativeUnitsAdministrativeUnitItemRequestBuilder) Extensions()(*AdministrativeUnitsItemExtensionsRequestBuilder) {\n return NewAdministrativeUnitsItemExtensionsRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func (r *SingleValueLegacyExtendedPropertyRequest) Get(ctx context.Context) (resObj *SingleValueLegacyExtendedProperty, err error) {\n\tvar query string\n\tif r.query != nil {\n\t\tquery = \"?\" + r.query.Encode()\n\t}\n\terr = r.JSONRequest(ctx, \"GET\", query, nil, &resObj)\n\treturn\n}", "func NewMultiValueLegacyExtendedPropertyItemRequestBuilderInternal(pathParameters map[string]string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*MultiValueLegacyExtendedPropertyItemRequestBuilder) {\n m := &MultiValueLegacyExtendedPropertyItemRequestBuilder{\n }\n m.urlTemplate = \"{+baseurl}/me/calendarGroups/{calendarGroup%2Did}/calendars/{calendar%2Did}/events/{event%2Did}/instances/{event%2Did1}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty%2Did}{?%24select,%24expand}\";\n urlTplParams := make(map[string]string)\n for idx, item := range pathParameters {\n urlTplParams[idx] = item\n }\n m.pathParameters = urlTplParams;\n m.requestAdapter = requestAdapter;\n return m\n}", "func NewCustomAuthenticationExtensionsRequestBuilderInternal(pathParameters map[string]string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*CustomAuthenticationExtensionsRequestBuilder) {\n m := &CustomAuthenticationExtensionsRequestBuilder{\n BaseRequestBuilder: *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewBaseRequestBuilder(requestAdapter, \"{+baseurl}/identity/customAuthenticationExtensions{?%24top,%24skip,%24search,%24filter,%24count,%24orderby,%24select,%24expand}\", pathParameters),\n }\n return m\n}", "func (m *EventItemRequestBuilder) MultiValueExtendedProperties()(*i8f6b1073998fe7e072e94da48aef27ff47795e232ec787943a4bc43820018dd7.MultiValueExtendedPropertiesRequestBuilder) {\n return i8f6b1073998fe7e072e94da48aef27ff47795e232ec787943a4bc43820018dd7.NewMultiValueExtendedPropertiesRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "func NewMultiValueLegacyExtendedPropertyItemRequestBuilder(rawUrl string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*MultiValueLegacyExtendedPropertyItemRequestBuilder) {\n urlParams := make(map[string]string)\n urlParams[\"request-raw-url\"] = rawUrl\n return NewMultiValueLegacyExtendedPropertyItemRequestBuilderInternal(urlParams, requestAdapter)\n}", "func (opts UnsetEnvOptions) Extend(other UnsetEnvOptions) UnsetEnvOptions {\n\tvar out UnsetEnvOptions\n\tout = append(out, opts...)\n\tout = append(out, other...)\n\treturn out\n}", "func TestSetExtraSpecs(t *testing.T) {\n\tth.SetupHTTP()\n\tdefer th.TeardownHTTP()\n\n\tMockSetExtraSpecsResponse(t)\n\n\toptions := &sharetypes.SetExtraSpecsOpts{\n\t\tExtraSpecs: map[string]interface{}{\"my_key\": \"my_value\"},\n\t}\n\n\tes, err := sharetypes.SetExtraSpecs(client.ServiceClient(), \"shareTypeID\", options).Extract()\n\tth.AssertNoErr(t, err)\n\n\tth.AssertEquals(t, es[\"my_key\"], \"my_value\")\n}", "func (w *MultiWriter) WithExtJSON(containerName, group string) *MultiWriter {\n\tw.container = containerName\n\tw.group = group\n\tw.isJSON = true\n\n\thostname := \"unknown\"\n\tif h, err := os.Hostname(); err == nil {\n\t\thostname = h\n\t}\n\tw.hostname = hostname\n\treturn w\n}", "func ExampleMachineExtensionsClient_Get() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armhybridcompute.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewMachineExtensionsClient().Get(ctx, \"myResourceGroup\", \"myMachine\", \"CustomScriptExtension\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.MachineExtension = armhybridcompute.MachineExtension{\n\t// \tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \tType: to.Ptr(\"Microsoft.HybridCompute/machines/extensions\"),\n\t// \tID: to.Ptr(\"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension\"),\n\t// \tLocation: to.Ptr(\"eastus2euap\"),\n\t// \tProperties: &armhybridcompute.MachineExtensionProperties{\n\t// \t\tType: to.Ptr(\"string\"),\n\t// \t\tAutoUpgradeMinorVersion: to.Ptr(false),\n\t// \t\tInstanceView: &armhybridcompute.MachineExtensionInstanceView{\n\t// \t\t\tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tType: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tStatus: &armhybridcompute.MachineExtensionInstanceViewStatus{\n\t// \t\t\t\tCode: to.Ptr(\"success\"),\n\t// \t\t\t\tDisplayStatus: to.Ptr(\"Provisioning succeeded\"),\n\t// \t\t\t\tLevel: to.Ptr(armhybridcompute.StatusLevelTypes(\"Information\")),\n\t// \t\t\t\tMessage: to.Ptr(\"Finished executing command, StdOut: , StdErr:\"),\n\t// \t\t\t\tTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2019-08-08T20:42:10.999Z\"); return t}()),\n\t// \t\t\t},\n\t// \t\t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t\t},\n\t// \t\tProtectedSettings: map[string]any{\n\t// \t\t},\n\t// \t\tProvisioningState: to.Ptr(\"Succeeded\"),\n\t// \t\tPublisher: to.Ptr(\"Microsoft.Compute\"),\n\t// \t\tSettings: \"@{commandToExecute=powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\"}\",\n\t// \t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t},\n\t// }\n}", "func (m pGetCompany) Extend(fnct func(m.UserSet) m.CompanySet) pGetCompany {\n\treturn pGetCompany{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (opts *ToolOptions) AddToExtraOptionsRegistry(extraOpts ExtraOptions) {\n\topts.URI.extraOptionsRegistry = append(opts.URI.extraOptionsRegistry, extraOpts)\n}", "func RegisterPredicateMetadataProducerWithExtendedResourceOptions(ignoredExtendedResources sets.String) {\n\tRegisterPredicateMetadataProducer(\"PredicateWithExtendedResourceOptions\", func(pm *predicateMetadata) {\n\t\tpm.ignoredExtendedResources = ignoredExtendedResources\n\t})\n}", "func MergeExtraConfig(extraConfig []vimTypes.BaseOptionValue, newMap map[string]string) []vimTypes.BaseOptionValue {\n\tmerged := make([]vimTypes.BaseOptionValue, 0)\n\tecMap := ExtraConfigToMap(extraConfig)\n\tfor k, v := range newMap {\n\t\tif _, exists := ecMap[k]; !exists {\n\t\t\tmerged = append(merged, &vimTypes.OptionValue{Key: k, Value: v})\n\t\t}\n\t}\n\treturn merged\n}", "func (m *DeviceItemRequestBuilder) Extensions()(*ItemExtensionsRequestBuilder) {\n return NewItemExtensionsRequestBuilderInternal(m.pathParameters, m.requestAdapter)\n}", "func (extension *ServerFarmExtension) GetExtendedResources() []genruntime.KubernetesResource {\n\treturn []genruntime.KubernetesResource{\n\t\t&v20220301.ServerFarm{},\n\t\t&v20220301s.ServerFarm{},\n\t\t&v1beta20220301.ServerFarm{},\n\t\t&v1beta20220301s.ServerFarm{}}\n}", "func (m pActionGet) Extend(fnct func(m.UserSet) *actions.Action) pActionGet {\n\treturn pActionGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (o *GetPlatformsParams) WithHTTPClient(client *http.Client) *GetPlatformsParams {\n\to.SetHTTPClient(client)\n\treturn o\n}", "func (o *GetMetricsParams) WithPlatforms(platforms *string) *GetMetricsParams {\n\to.SetPlatforms(platforms)\n\treturn o\n}", "func (b *PostRequestBuilder) Extensions() *PostExtensionsCollectionRequestBuilder {\n\tbb := &PostExtensionsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/extensions\"\n\treturn bb\n}", "func (m pBrowse) Extend(fnct func(m.UserSet, []int64) m.UserSet) pBrowse {\n\treturn pBrowse{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m *CustomAuthenticationExtensionsRequestBuilder) Get(ctx context.Context, requestConfiguration *CustomAuthenticationExtensionsRequestBuilderGetRequestConfiguration)(ie233ee762e29b4ba6970aa2a2efce4b7fde11697ca9ea81099d0f8269309c1be.CustomAuthenticationExtensionCollectionResponseable, error) {\n requestInfo, err := m.ToGetRequestInformation(ctx, requestConfiguration);\n if err != nil {\n return nil, err\n }\n errorMapping := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.ErrorMappings {\n \"4XX\": i20a3050780ee0b0cde0a884a4f35429a20d60067e3bcda382ec5400079147459.CreateODataErrorFromDiscriminatorValue,\n \"5XX\": i20a3050780ee0b0cde0a884a4f35429a20d60067e3bcda382ec5400079147459.CreateODataErrorFromDiscriminatorValue,\n }\n res, err := m.BaseRequestBuilder.RequestAdapter.Send(ctx, requestInfo, ie233ee762e29b4ba6970aa2a2efce4b7fde11697ca9ea81099d0f8269309c1be.CreateCustomAuthenticationExtensionCollectionResponseFromDiscriminatorValue, errorMapping)\n if err != nil {\n return nil, err\n }\n if res == nil {\n return nil, nil\n }\n return res.(ie233ee762e29b4ba6970aa2a2efce4b7fde11697ca9ea81099d0f8269309c1be.CustomAuthenticationExtensionCollectionResponseable), nil\n}", "func (a *Client) GetUserFriendsWithPlatformShort(params *GetUserFriendsWithPlatformParams, authInfo runtime.ClientAuthInfoWriter) (*GetUserFriendsWithPlatformOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetUserFriendsWithPlatformParams()\n\t}\n\n\tif params.Context == nil {\n\t\tparams.Context = context.Background()\n\t}\n\n\tif params.RetryPolicy != nil {\n\t\tparams.SetHTTPClientTransport(params.RetryPolicy)\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"getUserFriendsWithPlatform\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/friends/namespaces/{namespace}/me/platforms\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetUserFriendsWithPlatformReader{formats: a.formats},\n\t\tAuthInfo: authInfo,\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tswitch v := result.(type) {\n\n\tcase *GetUserFriendsWithPlatformOK:\n\t\treturn v, nil\n\tcase *GetUserFriendsWithPlatformBadRequest:\n\t\treturn nil, v\n\tcase *GetUserFriendsWithPlatformUnauthorized:\n\t\treturn nil, v\n\tcase *GetUserFriendsWithPlatformForbidden:\n\t\treturn nil, v\n\tcase *GetUserFriendsWithPlatformNotFound:\n\t\treturn nil, v\n\tcase *GetUserFriendsWithPlatformInternalServerError:\n\t\treturn nil, v\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unexpected Type %v\", reflect.TypeOf(v))\n\t}\n}", "func (r *PostMultiValueExtendedPropertiesCollectionRequest) Add(ctx context.Context, reqObj *MultiValueLegacyExtendedProperty) (resObj *MultiValueLegacyExtendedProperty, err error) {\n\terr = r.JSONRequest(ctx, \"POST\", \"\", reqObj, &resObj)\n\treturn\n}", "func (client *Client) SearchMediaWithOptions(request *SearchMediaRequest, runtime *util.RuntimeOptions) (_result *SearchMediaResponse, _err error) {\n\t_err = util.ValidateModel(request)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\tquery := map[string]interface{}{}\n\tif !tea.BoolValue(util.IsUnset(request.Fields)) {\n\t\tquery[\"Fields\"] = request.Fields\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.Match)) {\n\t\tquery[\"Match\"] = request.Match\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.PageNo)) {\n\t\tquery[\"PageNo\"] = request.PageNo\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.PageSize)) {\n\t\tquery[\"PageSize\"] = request.PageSize\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.ScrollToken)) {\n\t\tquery[\"ScrollToken\"] = request.ScrollToken\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.SearchType)) {\n\t\tquery[\"SearchType\"] = request.SearchType\n\t}\n\n\tif !tea.BoolValue(util.IsUnset(request.SortBy)) {\n\t\tquery[\"SortBy\"] = request.SortBy\n\t}\n\n\treq := &openapi.OpenApiRequest{\n\t\tQuery: openapiutil.Query(query),\n\t}\n\tparams := &openapi.Params{\n\t\tAction: tea.String(\"SearchMedia\"),\n\t\tVersion: tea.String(\"2017-03-21\"),\n\t\tProtocol: tea.String(\"HTTPS\"),\n\t\tPathname: tea.String(\"/\"),\n\t\tMethod: tea.String(\"POST\"),\n\t\tAuthType: tea.String(\"AK\"),\n\t\tStyle: tea.String(\"RPC\"),\n\t\tReqBodyType: tea.String(\"formData\"),\n\t\tBodyType: tea.String(\"json\"),\n\t}\n\t_result = &SearchMediaResponse{}\n\t_body, _err := client.CallApi(params, req, runtime)\n\tif _err != nil {\n\t\treturn _result, _err\n\t}\n\t_err = tea.Convert(_body, &_result)\n\treturn _result, _err\n}", "func (m pFieldGet) Extend(fnct func(m.UserSet, models.FieldName) *models.FieldInfo) pFieldGet {\n\treturn pFieldGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (r *ExtensionRequest) Get(ctx context.Context) (resObj *Extension, err error) {\n\tvar query string\n\tif r.query != nil {\n\t\tquery = \"?\" + r.query.Encode()\n\t}\n\terr = r.JSONRequest(ctx, \"GET\", query, nil, &resObj)\n\treturn\n}", "func (client *ServerVulnerabilityAssessmentClient) listByExtendedResourceCreateRequest(ctx context.Context, resourceGroupName string, resourceNamespace string, resourceType string, resourceName string, options *ServerVulnerabilityAssessmentClientListByExtendedResourceOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif resourceNamespace == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceNamespace cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceNamespace}\", url.PathEscape(resourceNamespace))\n\tif resourceType == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceType cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceType}\", url.PathEscape(resourceType))\n\tif resourceName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceName}\", url.PathEscape(resourceName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2020-01-01\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func SetPlatformDefaults(p *none.Platform) {\n}", "func (m *ItemCalendarRequestBuilder) MultiValueExtendedProperties()(*ItemCalendarMultiValueExtendedPropertiesRequestBuilder) {\n return NewItemCalendarMultiValueExtendedPropertiesRequestBuilderInternal(m.pathParameters, m.requestAdapter)\n}", "func NewGetPlatformsParamsWithTimeout(timeout time.Duration) *GetPlatformsParams {\n\tvar ()\n\treturn &GetPlatformsParams{\n\n\t\ttimeout: timeout,\n\t}\n}", "func listExtended(cmd *cobra.Command, features []FeatureInfo) error {\n\tvar t component.OutputWriterSpinner\n\tt, err := component.NewOutputWriterWithSpinner(cmd.OutOrStdout(), outputFormat,\n\t\t\"Retrieving Features...\", true, \"NAME\", \"ACTIVATION STATE\", \"STABILITY\", \"DESCRIPTION\", \"IMMUTABLE\", \"FEATUREGATE\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not get OutputWriterSpinner: %w\", err)\n\t}\n\n\tfor _, info := range features {\n\t\tt.AddRow(info.Name, info.Activated, info.Stability, info.Description, info.Immutable, info.FeatureGate)\n\t}\n\tt.RenderWithSpinner()\n\n\treturn nil\n}", "func (m pWebReadGroupPrivate) Extend(fnct func(m.UserSet, webtypes.WebReadGroupParams) []models.FieldMap) pWebReadGroupPrivate {\n\treturn pWebReadGroupPrivate{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (s KernelArgs) Extend(k KernelArgs) {\n\tfor a, b := range k {\n\t\ts[a] = b\n\t}\n}", "func ExtendedJSON(w http.ResponseWriter, code int, data interface{}, metadata map[string]interface{}) {\n\n\tvar status string\n\tswitch code {\n\tcase http.StatusOK:\n\t\tstatus = \"Success\"\n\tcase http.StatusCreated:\n\t\tstatus = \"Created\"\n\t}\n\n\ttype response struct {\n\t\tStatus string `json:\"status\"`\n\t\tCode int `json:\"code\"`\n\t\tData interface{} `json:\"data\"`\n\t\tMetadata map[string]interface{} `json:\"metadata,omitempty\"`\n\t}\n\n\tresp := response{\n\t\tStatus: status,\n\t\tCode: code,\n\t\tData: data,\n\t\tMetadata: metadata,\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.WriteHeader(code)\n\tjson.NewEncoder(w).Encode(resp)\n}", "func (m pWebSearchRead) Extend(fnct func(m.UserSet, webtypes.SearchParams) webtypes.SearchReadResult) pWebSearchRead {\n\treturn pWebSearchRead{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (a *AllApiService) EnterpriseGetEnterpriseCapabilities(ctx _context.Context, body EnterpriseGetEnterpriseCapabilities) (EnterpriseGetEnterpriseCapabilitiesResult, *_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = _nethttp.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t\tlocalVarReturnValue EnterpriseGetEnterpriseCapabilitiesResult\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/enterprise/getEnterpriseCapabilities\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{\"application/json\"}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\t// body params\n\tlocalVarPostBody = &body\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn localVarReturnValue, nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarReturnValue, localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\t\tif localVarHttpResponse.StatusCode == 200 {\n\t\t\tvar v EnterpriseGetEnterpriseCapabilitiesResult\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\t\tif localVarHttpResponse.StatusCode == 400 {\n\t\t\tvar v ModelError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\t\tif localVarHttpResponse.StatusCode == 500 {\n\t\t\tvar v ModelError\n\t\t\terr = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\t\t\tif err != nil {\n\t\t\t\tnewErr.error = err.Error()\n\t\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t\t}\n\t\t\tnewErr.model = v\n\t\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t\t}\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\terr = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get(\"Content-Type\"))\n\tif err != nil {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: err.Error(),\n\t\t}\n\t\treturn localVarReturnValue, localVarHttpResponse, newErr\n\t}\n\n\treturn localVarReturnValue, localVarHttpResponse, nil\n}", "func (m pFetch) Extend(fnct func(m.UserSet) m.UserSet) pFetch {\n\treturn pFetch{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (a *Client) GetPlatforms(params *GetPlatformsParams, opts ...ClientOption) (*GetPlatformsOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewGetPlatformsParams()\n\t}\n\top := &runtime.ClientOperation{\n\t\tID: \"get-platforms\",\n\t\tMethod: \"GET\",\n\t\tPathPattern: \"/fwmgr/entities/platforms/v1\",\n\t\tProducesMediaTypes: []string{\"application/json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\"},\n\t\tSchemes: []string{\"https\"},\n\t\tParams: params,\n\t\tReader: &GetPlatformsReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t}\n\tfor _, opt := range opts {\n\t\topt(op)\n\t}\n\n\tresult, err := a.transport.Submit(op)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*GetPlatformsOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for get-platforms: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func NewGetOperatingSystemsParamsWithHTTPClient(client *http.Client) *GetOperatingSystemsParams {\n\tvar ()\n\treturn &GetOperatingSystemsParams{\n\t\tHTTPClient: client,\n\t}\n}", "func (o *OpenAPI3) GetExtension(name string, extensions map[string]interface{}, dst interface{}) error {\n\tif extensions == nil {\n\t\treturn ErrExtNotFound\n\t}\n\n\tif ext, ok := extensions[name]; ok {\n\t\traw, isRawMessage := ext.(jsonstd.RawMessage)\n\t\tif !isRawMessage {\n\t\t\treturn fmt.Errorf(\"invalid extension\")\n\t\t}\n\n\t\terr := json.Unmarshal(raw, dst)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid extension type: %v\", err)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\treturn ErrExtNotFound\n}", "func buildConsolidatedKeywordsReqExt(openRTBUser, openRTBSite string, firstImpExt, requestExt json.RawMessage) (json.RawMessage, error) {\n\t// unmarshal ext to object map\n\trequestExtMap := parseExtToMap(requestExt)\n\tfirstImpExtMap := parseExtToMap(firstImpExt)\n\t// extract `keywords` field\n\trequestExtKeywordsMap := extractKeywordsMap(requestExtMap)\n\tfirstImpExtKeywordsMap := extractBidderKeywordsMap(firstImpExtMap)\n\t// parse + merge keywords\n\tkeywords := parseKeywordsFromMap(requestExtKeywordsMap) // request.ext.keywords\n\tmergeKeywords(keywords, parseKeywordsFromMap(firstImpExtKeywordsMap)) // request.imp[0].ext.bidder.keywords\n\tmergeKeywords(keywords, parseKeywordsFromOpenRTB(openRTBUser, \"user\")) // request.user.keywords\n\tmergeKeywords(keywords, parseKeywordsFromOpenRTB(openRTBSite, \"site\")) // request.site.keywords\n\n\t// overlay site + user keywords\n\tif site, exists := keywords[\"site\"]; exists && len(site) > 0 {\n\t\trequestExtKeywordsMap[\"site\"] = site\n\t} else {\n\t\tdelete(requestExtKeywordsMap, \"site\")\n\t}\n\tif user, exists := keywords[\"user\"]; exists && len(user) > 0 {\n\t\trequestExtKeywordsMap[\"user\"] = user\n\t} else {\n\t\tdelete(requestExtKeywordsMap, \"user\")\n\t}\n\t// reconcile keywords with request.ext\n\tif len(requestExtKeywordsMap) > 0 {\n\t\trequestExtMap[\"keywords\"] = requestExtKeywordsMap\n\t} else {\n\t\tdelete(requestExtMap, \"keywords\")\n\t}\n\t// marshal final result\n\tif len(requestExtMap) > 0 {\n\t\treturn json.Marshal(requestExtMap)\n\t}\n\treturn nil, nil\n}", "func (m pWithNewContext) Extend(fnct func(m.UserSet, *types.Context) m.UserSet) pWithNewContext {\n\treturn pWithNewContext{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (l *LogOptions) SetExtendedOptions(options ...interface{}) {\n\tfor x := 0; x < len(options); x += 2 {\n\t\tl.ExtendedOptions[options[x].(string)] = options[x+1]\n\t}\n}", "func (m pSearchRead) Extend(fnct func(m.UserSet, webtypes.SearchParams) []models.RecordData) pSearchRead {\n\treturn pSearchRead{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (delivery_instructions DeliveryInstructions) ExtendedOptions() (data []byte, err error) {\n\tops, err := delivery_instructions.HasExtendedOptions()\n\tif err != nil {\n\t\treturn\n\t}\n\tif ops {\n\t\tvar extended_options_index int\n\t\textended_options_index, err = delivery_instructions.extended_options_index()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tif len(delivery_instructions) < extended_options_index+2 {\n\t\t\terr = errors.New(\"DeliveryInstructions are invalid, length is shorter than required for Extended Options\")\n\t\t\treturn\n\t\t} else {\n\t\t\textended_options_size := common.Integer([]byte{delivery_instructions[extended_options_index]})\n\t\t\tif len(delivery_instructions) < extended_options_index+1+extended_options_size {\n\t\t\t\terr = errors.New(\"DeliveryInstructions are invalid, length is shorter than specified in Extended Options\")\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tdata = delivery_instructions[extended_options_index+1 : extended_options_size]\n\t\t\t\treturn\n\t\t\t}\n\n\t\t}\n\t} else {\n\t\terr = errors.New(\"DeliveryInstruction does not have the ExtendedOptions flag set\")\n\t}\n\treturn\n}", "func (m pAddMandatoryGroups) Extend(fnct func(m.UserSet)) pAddMandatoryGroups {\n\treturn pAddMandatoryGroups{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (s *TiFlashSpec) GetExtendedRole(ctx context.Context, tlsCfg *tls.Config, pdList ...string) string {\n\tif len(pdList) < 1 {\n\t\treturn \"\"\n\t}\n\tstoreAddr := utils.JoinHostPort(s.Host, s.FlashServicePort)\n\tpdapi := api.NewPDClient(ctx, pdList, statusQueryTimeout, tlsCfg)\n\tstore, err := pdapi.GetCurrentStore(storeAddr)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tisWriteNode := false\n\tisTiFlash := false\n\tfor _, label := range store.Store.Labels {\n\t\tif label.Key == EngineLabelKey {\n\t\t\tif label.Value == EngineLabelTiFlashCompute {\n\t\t\t\treturn \" (compute)\"\n\t\t\t}\n\t\t\tif label.Value == EngineLabelTiFlash {\n\t\t\t\tisTiFlash = true\n\t\t\t}\n\t\t}\n\t\tif label.Key == EngineRoleLabelKey && label.Value == EngineRoleLabelWrite {\n\t\t\tisWriteNode = true\n\t\t}\n\t\tif isTiFlash && isWriteNode {\n\t\t\treturn \" (write)\"\n\t\t}\n\t}\n\treturn \"\"\n}", "func (c *Client) GetEnvironmentExtended(id string, ret *EnvironmentExtended) error {\n\tquery := url.Values{}\n\tquery.Add(\"envId\", id)\n\treturn c.makeGetRequest(\"envs/actions/getextended\", ret, &query)\n}", "func Platform() (*openstack.Platform, error) {\n\tcloudNames, err := getCloudNames()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// Sort cloudNames so we can use sort.SearchStrings\n\tsort.Strings(cloudNames)\n\tvar cloud string\n\terr = survey.Ask([]*survey.Question{\n\t\t{\n\t\t\tPrompt: &survey.Select{\n\t\t\t\tMessage: \"Cloud\",\n\t\t\t\tHelp: \"The OpenStack cloud name from clouds.yaml.\",\n\t\t\t\tOptions: cloudNames,\n\t\t\t},\n\t\t\tValidate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {\n\t\t\t\tvalue := ans.(core.OptionAnswer).Value\n\t\t\t\ti := sort.SearchStrings(cloudNames, value)\n\t\t\t\tif i == len(cloudNames) || cloudNames[i] != value {\n\t\t\t\t\treturn fmt.Errorf(\"invalid cloud name %q, should be one of %s\", value, strings.Join(cloudNames, \", \"))\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}),\n\t\t},\n\t}, &cloud)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed UserInput: %w\", err)\n\t}\n\n\tnetworkNames, err := getExternalNetworkNames(cloud)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnetworkNames = append(networkNames, noExtNet)\n\tsort.Strings(networkNames)\n\tvar extNet string\n\terr = survey.Ask([]*survey.Question{\n\t\t{\n\t\t\tPrompt: &survey.Select{\n\t\t\t\tMessage: \"ExternalNetwork\",\n\t\t\t\tHelp: \"The OpenStack external network name to be used for installation.\",\n\t\t\t\tOptions: networkNames,\n\t\t\t\tDefault: noExtNet,\n\t\t\t},\n\t\t\tValidate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {\n\t\t\t\tvalue := ans.(core.OptionAnswer).Value\n\t\t\t\ti := sort.SearchStrings(networkNames, value)\n\t\t\t\tif i == len(networkNames) || networkNames[i] != value {\n\t\t\t\t\treturn fmt.Errorf(\"invalid network name %q, should be one of %s\", value, strings.Join(networkNames, \", \"))\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}),\n\t\t},\n\t}, &extNet)\n\tif extNet == noExtNet {\n\t\textNet = \"\"\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed UserInput: %w\", err)\n\t}\n\n\tvar apiFloatingIP string\n\tif extNet != \"\" {\n\t\tfloatingIPs, err := getFloatingIPs(cloud, extNet)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tsort.Sort(floatingIPs)\n\t\terr = survey.Ask([]*survey.Question{\n\t\t\t{\n\t\t\t\tPrompt: &survey.Select{\n\t\t\t\t\tMessage: \"APIFloatingIPAddress\",\n\t\t\t\t\tHelp: \"The Floating IP address used for external access to the OpenShift API.\",\n\t\t\t\t\tOptions: floatingIPs.Names(),\n\t\t\t\t\tDescription: func(_ string, index int) string { return floatingIPs.Description(index) },\n\t\t\t\t},\n\t\t\t\tValidate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {\n\t\t\t\t\tif value := ans.(core.OptionAnswer).Value; !floatingIPs.Contains(value) {\n\t\t\t\t\t\treturn fmt.Errorf(\"invalid floating IP %q, should be one of %s\", value, strings.Join(floatingIPs.Names(), \", \"))\n\t\t\t\t\t}\n\t\t\t\t\treturn nil\n\t\t\t\t}),\n\t\t\t},\n\t\t}, &apiFloatingIP)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed UserInput: %w\", err)\n\t\t}\n\t}\n\n\tflavorNames, err := getFlavorNames(cloud)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsort.Strings(flavorNames)\n\tvar flavor string\n\terr = survey.Ask([]*survey.Question{\n\t\t{\n\t\t\tPrompt: &survey.Select{\n\t\t\t\tMessage: \"FlavorName\",\n\t\t\t\tHelp: \"The OpenStack flavor to use for control-plane and compute nodes. A flavor with at least 16 GB RAM is recommended.\",\n\t\t\t\tOptions: flavorNames,\n\t\t\t},\n\t\t\tValidate: survey.ComposeValidators(survey.Required, func(ans interface{}) error {\n\t\t\t\tvalue := ans.(core.OptionAnswer).Value\n\t\t\t\ti := sort.SearchStrings(flavorNames, value)\n\t\t\t\tif i == len(flavorNames) || flavorNames[i] != value {\n\t\t\t\t\treturn fmt.Errorf(\"invalid flavor name %q, should be one of %s\", value, strings.Join(flavorNames, \", \"))\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t}),\n\t\t},\n\t}, &flavor)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed UserInput: %w\", err)\n\t}\n\n\treturn &openstack.Platform{\n\t\tAPIFloatingIP: apiFloatingIP,\n\t\tCloud: cloud,\n\t\tExternalNetwork: extNet,\n\t\tDefaultMachinePlatform: &openstack.MachinePool{\n\t\t\tFlavorName: flavor,\n\t\t},\n\t}, nil\n}", "func decodeExtendedCommunities(c interface{}) api.ExtCommunities {\n\tdetails := decoders.StringList(c)\n\tcomms := make(api.ExtCommunities, 0, len(details))\n\tfor _, com := range details {\n\t\ttokens := strings.SplitN(com, \" \", 2)\n\t\tif len(tokens) != 2 {\n\t\t\tcontinue\n\t\t}\n\t\tnums := decoders.IntListFromStrings(\n\t\t\tstrings.SplitN(tokens[1], \":\", 2))\n\t\tif len(nums) != 2 {\n\t\t\tcontinue\n\t\t}\n\t\tcomms = append(comms, []interface{}{tokens[0], nums[0], nums[1]})\n\t}\n\treturn comms\n}", "func addNativeFlags(s *options.CloudControllerManagerServer, fs *flag.FlagSet) *flag.FlagSet {\n\tfs.StringVar(&s.Master, \"master\", s.Master, \"The address of the Kubernetes API server (overrides any value in kubeconfig)\")\n\tfs.StringVar(&s.Kubeconfig, \"kubeconfig\", s.Kubeconfig, \"Path to kubeconfig file with authorization and master location information.\")\n\tfs.StringVar(&s.CloudConfigFile, \"cloud-config\", s.CloudConfigFile, \"The path to the cloud provider configuration file. Empty string for no configuration file.\")\n\tfs.BoolVar(&versionShow, \"version\", false, \"Path to kubeconfig file with authorization and master location information.\")\n\tfs.StringVar(&s.CloudProvider, \"cloud-provider\", \"\", \"The provider for cloud services. Empty string for no provider.\")\n\treturn fs\n}", "func NewGetDevicesUnknownParamsWithHTTPClient(client *http.Client) *GetDevicesUnknownParams {\n\treturn &GetDevicesUnknownParams{\n\t\tHTTPClient: client,\n\t}\n}", "func ExampleMachineExtensionsClient_BeginCreateOrUpdate() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armconnectedvmware.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tpoller, err := clientFactory.NewMachineExtensionsClient().BeginCreateOrUpdate(ctx, \"myResourceGroup\", \"myMachine\", \"CustomScriptExtension\", armconnectedvmware.MachineExtension{\n\t\tLocation: to.Ptr(\"eastus2euap\"),\n\t\tProperties: &armconnectedvmware.MachineExtensionProperties{\n\t\t\tType: to.Ptr(\"CustomScriptExtension\"),\n\t\t\tPublisher: to.Ptr(\"Microsoft.Compute\"),\n\t\t\tSettings: map[string]any{\n\t\t\t\t\"commandToExecute\": \"powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\"\",\n\t\t\t},\n\t\t\tTypeHandlerVersion: to.Ptr(\"1.10\"),\n\t\t},\n\t}, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\tres, err := poller.PollUntilDone(ctx, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to pull the result: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.MachineExtension = armconnectedvmware.MachineExtension{\n\t// \tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \tType: to.Ptr(\"Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions\"),\n\t// \tID: to.Ptr(\"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension\"),\n\t// \tLocation: to.Ptr(\"eastus2euap\"),\n\t// \tProperties: &armconnectedvmware.MachineExtensionProperties{\n\t// \t\tType: to.Ptr(\"string\"),\n\t// \t\tAutoUpgradeMinorVersion: to.Ptr(false),\n\t// \t\tInstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{\n\t// \t\t\tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tType: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tStatus: &armconnectedvmware.MachineExtensionInstanceViewStatus{\n\t// \t\t\t\tCode: to.Ptr(\"success\"),\n\t// \t\t\t\tLevel: to.Ptr(armconnectedvmware.StatusLevelTypes(\"Information\")),\n\t// \t\t\t\tMessage: to.Ptr(\"Finished executing command, StdOut: , StdErr:\"),\n\t// \t\t\t\tTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2020-08-08T20:42:10.999Z\"); return t}()),\n\t// \t\t\t},\n\t// \t\t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t\t},\n\t// \t\tProvisioningState: to.Ptr(\"Succeeded\"),\n\t// \t\tPublisher: to.Ptr(\"Microsoft.Compute\"),\n\t// \t\tSettings: \"@{commandToExecute=powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\"}\",\n\t// \t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t},\n\t// }\n}", "func GetExtendingApps(jxClient versioned.Interface, namespace string) ([]jenkinsv1.App, error) {\n\tlistOptions := metav1.ListOptions{}\n\tlistOptions.LabelSelector = fmt.Sprintf(apps.AppTypeLabel+\" in (%s)\", apps.PipelineExtension)\n\tappsList, err := jxClient.JenkinsV1().Apps(namespace).List(listOptions)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error retrieving pipeline contributor apps\")\n\t}\n\treturn appsList.Items, nil\n}", "func Extend(target map[string]interface{}, args ...interface{}) (map[string]interface{}, error) {\n\tif len(args)%2 != 0 {\n\t\treturn nil, fmt.Errorf(\"expecting even number of arguments, got %d\", len(args))\n\t}\n\n\tfn := \"\"\n\tfor _, v := range args {\n\t\tif len(fn) == 0 {\n\t\t\tif s, ok := v.(string); ok {\n\t\t\t\tfn = s\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn target, fmt.Errorf(\"expecting string for odd numbered arguments, got %+v\", v)\n\t\t}\n\t\ttarget[fn] = v\n\t\tfn = \"\"\n\t}\n\n\treturn target, nil\n}", "func (client *MachineExtensionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, name string, extensionName string, extensionParameters MachineExtensionUpdate, options *MachineExtensionsClientBeginUpdateOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif extensionName == \"\" {\n\t\treturn nil, errors.New(\"parameter extensionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{extensionName}\", url.PathEscape(extensionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-10-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, runtime.MarshalAsJSON(req, extensionParameters)\n}", "func (m pSQLFromCondition) Extend(fnct func(m.UserSet, *models.Condition) (string, models.SQLParams)) pSQLFromCondition {\n\treturn pSQLFromCondition{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}" ]
[ "0.761028", "0.563234", "0.56002456", "0.5536339", "0.5500236", "0.5369291", "0.507227", "0.5051095", "0.49456128", "0.49286032", "0.49263084", "0.49066523", "0.4895168", "0.48209637", "0.4819409", "0.47902983", "0.4787378", "0.47806302", "0.4741045", "0.47262233", "0.47177416", "0.46968997", "0.46933776", "0.4681936", "0.46302035", "0.45906216", "0.45874777", "0.45837232", "0.4583411", "0.45819843", "0.45718104", "0.45625827", "0.45625827", "0.45580238", "0.4553458", "0.4547201", "0.4539819", "0.45384106", "0.45367652", "0.4529968", "0.45272088", "0.45207494", "0.45175847", "0.44941238", "0.44885552", "0.44856837", "0.44856635", "0.44738206", "0.44718894", "0.44593748", "0.4457986", "0.44489354", "0.44418773", "0.44385415", "0.44361746", "0.44330615", "0.4424878", "0.44215995", "0.43785718", "0.43733716", "0.43510962", "0.4331234", "0.43250203", "0.43201625", "0.43176767", "0.43072775", "0.4290216", "0.4278749", "0.42771953", "0.42709365", "0.42640486", "0.42607033", "0.42537826", "0.4246645", "0.42446068", "0.42352423", "0.4233371", "0.4232426", "0.42164823", "0.42158082", "0.42141113", "0.4213447", "0.4210691", "0.4199534", "0.4197639", "0.41939455", "0.41878068", "0.41840133", "0.41815358", "0.41695353", "0.4163625", "0.41583258", "0.41581216", "0.4157225", "0.41570002", "0.41518867", "0.41486466", "0.41471642", "0.414651", "0.4144551" ]
0.7949409
0
SetExtended adds the extended to the get platforms params
func (o *GetPlatformsParams) SetExtended(extended *bool) { o.Extended = extended }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GetPlatformsParams) WithExtended(extended *bool) *GetPlatformsParams {\n\to.SetExtended(extended)\n\treturn o\n}", "func (o *VulnerabilitiesRequest) SetExtended(v bool) {\n\to.Extended = &v\n}", "func (b *MessagesGetHistoryBuilder) Extended(v bool) *MessagesGetHistoryBuilder {\n\tb.Params[\"extended\"] = v\n\treturn b\n}", "func (b *MessagesGetByIDBuilder) Extended(v bool) *MessagesGetByIDBuilder {\n\tb.Params[\"extended\"] = v\n\treturn b\n}", "func (b *MessagesGetConversationsByIDBuilder) Extended(v bool) *MessagesGetConversationsByIDBuilder {\n\tb.Params[\"extended\"] = v\n\treturn b\n}", "func (b *MessagesGetByConversationMessageIDBuilder) Extended(v bool) *MessagesGetByConversationMessageIDBuilder {\n\tb.Params[\"extended\"] = v\n\treturn b\n}", "func (m pIsSystem) Extend(fnct func(m.UserSet) bool) pIsSystem {\n\treturn pIsSystem{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (p *HostedProgramInfo) Extend(ext auth.SubPrin) {\n\tp.subprin = append(p.subprin, ext...)\n}", "func (l *LogOptions) SetExtendedOptions(options ...interface{}) {\n\tfor x := 0; x < len(options); x += 2 {\n\t\tl.ExtendedOptions[options[x].(string)] = options[x+1]\n\t}\n}", "func (m *AdministrativeUnit) SetExtensions(value []Extensionable)() {\n m.extensions = value\n}", "func (rr *OPT) SetExtendedRcode(v uint16) {\n\trr.Hdr.Ttl = rr.Hdr.Ttl&0x00FFFFFF | uint32(v>>4)<<24\n}", "func (o *VulnerabilitiesRequest) GetExtended() bool {\n\tif o == nil || o.Extended == nil {\n\t\tvar ret bool\n\t\treturn ret\n\t}\n\treturn *o.Extended\n}", "func TestSetExtraSpecs(t *testing.T) {\n\tth.SetupHTTP()\n\tdefer th.TeardownHTTP()\n\n\tMockSetExtraSpecsResponse(t)\n\n\toptions := &sharetypes.SetExtraSpecsOpts{\n\t\tExtraSpecs: map[string]interface{}{\"my_key\": \"my_value\"},\n\t}\n\n\tes, err := sharetypes.SetExtraSpecs(client.ServiceClient(), \"shareTypeID\", options).Extract()\n\tth.AssertNoErr(t, err)\n\n\tth.AssertEquals(t, es[\"my_key\"], \"my_value\")\n}", "func (m pContextGet) Extend(fnct func(m.UserSet) *types.Context) pContextGet {\n\treturn pContextGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (o *VulnerabilitiesRequest) HasExtended() bool {\n\tif o != nil && o.Extended != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func (m pGetToolbar) Extend(fnct func(m.UserSet) webtypes.Toolbar) pGetToolbar {\n\treturn pGetToolbar{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m *Application) SetExtensionProperties(value []ExtensionPropertyable)() {\n m.extensionProperties = value\n}", "func (m pWithEnv) Extend(fnct func(m.UserSet, models.Environment) m.UserSet) pWithEnv {\n\treturn pWithEnv{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m *WorkforceIntegration) SetSupportedEntities(value *WorkforceIntegrationSupportedEntities)() {\n m.supportedEntities = value\n}", "func (m pNameGet) Extend(fnct func(m.UserSet) string) pNameGet {\n\treturn pNameGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (o *VulnerabilitiesRequest) GetExtendedOk() (*bool, bool) {\n\tif o == nil || o.Extended == nil {\n\t\treturn nil, false\n\t}\n\treturn o.Extended, true\n}", "func (m pDefaultGet) Extend(fnct func(m.UserSet) m.UserData) pDefaultGet {\n\treturn pDefaultGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (vk *VK) AppsGetLeaderboardExtended(params map[string]string) (response AppsGetLeaderboardExtendedResponse, vkErr Error) {\n\tparams[\"extended\"] = \"1\"\n\tvk.RequestUnmarshal(\"apps.getLeaderboard\", params, &response, &vkErr)\n\treturn\n}", "func (r *Search) Ext(ext map[string]json.RawMessage) *Search {\n\n\tr.req.Ext = ext\n\n\treturn r\n}", "func (znp *Znp) ZdoExtSetParams(useMulticast uint8) (rsp *StatusResponse, err error) {\n\treq := &ZdoExtSetParams{UseMulticast: useMulticast}\n\terr = znp.ProcessRequest(unp.C_SREQ, unp.S_ZDO, 0x53, req, &rsp)\n\treturn\n}", "func (m pFieldsGet) Extend(fnct func(m.UserSet, models.FieldsGetArgs) map[string]*models.FieldInfo) pFieldsGet {\n\treturn pFieldsGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func MergeRawExtension(base *runtime.RawExtension, patch *runtime.RawExtension) (*runtime.RawExtension, error) {\n\tpatchParameter, err := util.RawExtension2Map(patch)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to convert patch parameters to map\")\n\t}\n\tbaseParameter, err := util.RawExtension2Map(base)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to convert base parameters to map\")\n\t}\n\tif baseParameter == nil {\n\t\tbaseParameter = make(map[string]interface{})\n\t}\n\terr = mergo.Merge(&baseParameter, patchParameter, mergo.WithOverride)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to do merge with override\")\n\t}\n\tbs, err := json.Marshal(baseParameter)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to marshal merged properties\")\n\t}\n\treturn &runtime.RawExtension{Raw: bs}, nil\n}", "func (m pBrowse) Extend(fnct func(m.UserSet, []int64) m.UserSet) pBrowse {\n\treturn pBrowse{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (*entityImpl) ExtendedAttributes(p graphql.ResolveParams) (interface{}, error) {\n\tentity := p.Source.(*types.Entity)\n\treturn wrapExtendedAttributes(entity.ExtendedAttributes), nil\n}", "func (m *Group) SetExtensions(value []Extensionable)() {\n m.extensions = value\n}", "func SetPlatformDefaults(p *none.Platform) {\n}", "func SetExtNic(nic string) {\n\tsetValue(\"environment\", \"extnic\", nic)\n}", "func (m pGetLoginDomain) Extend(fnct func(m.UserSet, string) q.UserCondition) pGetLoginDomain {\n\treturn pGetLoginDomain{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m pInit) Extend(fnct func(m.UserSet)) pInit {\n\treturn pInit{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (opts UnsetEnvOptions) Extend(other UnsetEnvOptions) UnsetEnvOptions {\n\tvar out UnsetEnvOptions\n\tout = append(out, opts...)\n\tout = append(out, other...)\n\treturn out\n}", "func getSupportedExtensions() map[string][]string {\n\t// In future when list of extensions grow, it will make\n\t// more sense to populate it in a dynamic way.\n\n\t// These are RHCOS supported extensions.\n\t// Each extension keeps a list of packages required to get enabled on host.\n\treturn map[string][]string{\n\t\t\"wasm\": {\"crun-wasm\"},\n\t\t\"ipsec\": {\"NetworkManager-libreswan\", \"libreswan\"},\n\t\t\"usbguard\": {\"usbguard\"},\n\t\t\"kerberos\": {\"krb5-workstation\", \"libkadm5\"},\n\t\t\"kernel-devel\": {\"kernel-devel\", \"kernel-headers\"},\n\t\t\"sandboxed-containers\": {\"kata-containers\"},\n\t}\n}", "func (m *AdministrativeUnitsAdministrativeUnitItemRequestBuilder) Extensions()(*AdministrativeUnitsItemExtensionsRequestBuilder) {\n return NewAdministrativeUnitsItemExtensionsRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)\n}", "func (m *EventItemRequestBuilder) MultiValueExtendedProperties()(*i8f6b1073998fe7e072e94da48aef27ff47795e232ec787943a4bc43820018dd7.MultiValueExtendedPropertiesRequestBuilder) {\n return i8f6b1073998fe7e072e94da48aef27ff47795e232ec787943a4bc43820018dd7.NewMultiValueExtendedPropertiesRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "func (m *User) SetExtensions(value []Extensionable)() {\n m.extensions = value\n}", "func (extension *IotHubExtension) GetExtendedResources() []genruntime.KubernetesResource {\n\treturn []genruntime.KubernetesResource{\n\t\t&v20210702.IotHub{},\n\t\t&v20210702s.IotHub{}}\n}", "func (extension *ServerFarmExtension) GetExtendedResources() []genruntime.KubernetesResource {\n\treturn []genruntime.KubernetesResource{\n\t\t&v20220301.ServerFarm{},\n\t\t&v20220301s.ServerFarm{},\n\t\t&v1beta20220301.ServerFarm{},\n\t\t&v1beta20220301s.ServerFarm{}}\n}", "func (b *OrganizationRequestBuilder) Extensions() *OrganizationExtensionsCollectionRequestBuilder {\n\tbb := &OrganizationExtensionsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/extensions\"\n\treturn bb\n}", "func (b *PostRequestBuilder) MultiValueExtendedProperties() *PostMultiValueExtendedPropertiesCollectionRequestBuilder {\n\tbb := &PostMultiValueExtendedPropertiesCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/multiValueExtendedProperties\"\n\treturn bb\n}", "func (m pGetRecord) Extend(fnct func(m.UserSet, string) m.UserSet) pGetRecord {\n\treturn pGetRecord{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m *DeviceRequestBuilder) Extensions()(*i052c31265100c50ded0dfb7ace15f5bda9fcabb7268d24b57f25c5f7a0bc8ca0.ExtensionsRequestBuilder) {\n return i052c31265100c50ded0dfb7ace15f5bda9fcabb7268d24b57f25c5f7a0bc8ca0.NewExtensionsRequestBuilderInternal(m.pathParameters, m.requestAdapter);\n}", "func TestGetExtraSpecs(t *testing.T) {\n\tth.SetupHTTP()\n\tdefer th.TeardownHTTP()\n\n\tMockGetExtraSpecsResponse(t)\n\n\tst, err := sharetypes.GetExtraSpecs(client.ServiceClient(), \"shareTypeID\").Extract()\n\tth.AssertNoErr(t, err)\n\n\tth.AssertEquals(t, st[\"snapshot_support\"], \"True\")\n\tth.AssertEquals(t, st[\"driver_handles_share_servers\"], \"True\")\n\tth.AssertEquals(t, st[\"my_custom_extra_spec\"], \"False\")\n}", "func (m pAddModifiers) Extend(fnct func(m.UserSet, *etree.Document, map[string]*models.FieldInfo)) pAddModifiers {\n\treturn pAddModifiers{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (s *TiFlashSpec) GetExtendedRole(ctx context.Context, tlsCfg *tls.Config, pdList ...string) string {\n\tif len(pdList) < 1 {\n\t\treturn \"\"\n\t}\n\tstoreAddr := utils.JoinHostPort(s.Host, s.FlashServicePort)\n\tpdapi := api.NewPDClient(ctx, pdList, statusQueryTimeout, tlsCfg)\n\tstore, err := pdapi.GetCurrentStore(storeAddr)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tisWriteNode := false\n\tisTiFlash := false\n\tfor _, label := range store.Store.Labels {\n\t\tif label.Key == EngineLabelKey {\n\t\t\tif label.Value == EngineLabelTiFlashCompute {\n\t\t\t\treturn \" (compute)\"\n\t\t\t}\n\t\t\tif label.Value == EngineLabelTiFlash {\n\t\t\t\tisTiFlash = true\n\t\t\t}\n\t\t}\n\t\tif label.Key == EngineRoleLabelKey && label.Value == EngineRoleLabelWrite {\n\t\t\tisWriteNode = true\n\t\t}\n\t\tif isTiFlash && isWriteNode {\n\t\t\treturn \" (write)\"\n\t\t}\n\t}\n\treturn \"\"\n}", "func (c *Client) SpeakExtended(input *SpeakExtendedInput) (r *SpeakExtendedResponse) {\n\tresp := c.queryAPI(&Request{\n\t\tXMLName: xml.Name{Local: \"speakExtended\"},\n\t\tAccountID: c.AccountID,\n\t\tPassword: c.Password,\n\t\tVoice: input.Voice,\n\t\tText: input.Text,\n\t\tAudioFormat: input.AudioFormat,\n\t\tSampleRate: input.SampleRate,\n\t\tAudio3D: input.Audio3D,\n\t\tMetadata: input.Metadata,\n\t})\n\tif resp.Error != nil {\n\t\tr.Error = resp.Error\n\t\treturn\n\t}\n\n\tif err := xml.Unmarshal(resp.Raw, &r); err != nil {\n\t\tr.Error = err\n\t}\n\n\treturn\n}", "func (c *Client) GetEnvironmentExtended(id string, ret *EnvironmentExtended) error {\n\tquery := url.Values{}\n\tquery.Add(\"envId\", id)\n\treturn c.makeGetRequest(\"envs/actions/getextended\", ret, &query)\n}", "func (oo *OnuDeviceEntry) GetPersIsExtOmciSupported() bool {\n\too.MutexPersOnuConfig.RLock()\n\tdefer oo.MutexPersOnuConfig.RUnlock()\n\tvalue := oo.SOnuPersistentData.PersIsExtOmciSupported\n\treturn value\n}", "func (ec *EventContextV03) SetExtension(name string, value interface{}) error {\n\tif ec.Extensions == nil {\n\t\tec.Extensions = make(map[string]interface{})\n\t}\n\n\tif _, ok := specV03Attributes[strings.ToLower(name)]; ok {\n\t\treturn fmt.Errorf(\"bad key %q: CloudEvents spec attribute MUST NOT be overwritten by extension\", name)\n\t}\n\n\tif value == nil {\n\t\tdelete(ec.Extensions, name)\n\t\tif len(ec.Extensions) == 0 {\n\t\t\tec.Extensions = nil\n\t\t}\n\t\treturn nil\n\t} else {\n\t\tv, err := types.Validate(value)\n\t\tif err == nil {\n\t\t\tec.Extensions[name] = v\n\t\t}\n\t\treturn err\n\t}\n}", "func (m pSudo) Extend(fnct func(m.UserSet, ...int64) m.UserSet) pSudo {\n\treturn pSudo{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m pGetCompany) Extend(fnct func(m.UserSet) m.CompanySet) pGetCompany {\n\treturn pGetCompany{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (me TxsdType) IsExtended() bool { return me == \"extended\" }", "func (c *Client) EnvironmentExtend(envID string) error {\n\treturn c.envPutActionByID(\"extend\", envID)\n}", "func (m pActionGet) Extend(fnct func(m.UserSet) *actions.Action) pActionGet {\n\treturn pActionGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m pToggleActive) Extend(fnct func(m.UserSet)) pToggleActive {\n\treturn pToggleActive{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func ExampleMachineExtensionsClient_Get() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armconnectedvmware.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewMachineExtensionsClient().Get(ctx, \"myResourceGroup\", \"myMachine\", \"CustomScriptExtension\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.MachineExtension = armconnectedvmware.MachineExtension{\n\t// \tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \tType: to.Ptr(\"Microsoft.ConnectedVMwarevSphere/VirtualMachines/extensions\"),\n\t// \tID: to.Ptr(\"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension\"),\n\t// \tLocation: to.Ptr(\"eastus2euap\"),\n\t// \tProperties: &armconnectedvmware.MachineExtensionProperties{\n\t// \t\tType: to.Ptr(\"string\"),\n\t// \t\tAutoUpgradeMinorVersion: to.Ptr(false),\n\t// \t\tInstanceView: &armconnectedvmware.MachineExtensionPropertiesInstanceView{\n\t// \t\t\tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tType: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tStatus: &armconnectedvmware.MachineExtensionInstanceViewStatus{\n\t// \t\t\t\tCode: to.Ptr(\"success\"),\n\t// \t\t\t\tDisplayStatus: to.Ptr(\"Provisioning succeeded\"),\n\t// \t\t\t\tLevel: to.Ptr(armconnectedvmware.StatusLevelTypes(\"Information\")),\n\t// \t\t\t\tMessage: to.Ptr(\"Finished executing command, StdOut: , StdErr:\"),\n\t// \t\t\t\tTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2019-08-08T20:42:10.999Z\"); return t}()),\n\t// \t\t\t},\n\t// \t\t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t\t},\n\t// \t\tProvisioningState: to.Ptr(\"Succeeded\"),\n\t// \t\tPublisher: to.Ptr(\"Microsoft.Compute\"),\n\t// \t\tSettings: \"@{commandToExecute=powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\"}\",\n\t// \t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t},\n\t// }\n}", "func (p *Placemark) AddExtendedData(e ExtendedData) {\n\tp.Extended = e\n}", "func (delivery_instructions DeliveryInstructions) ExtendedOptions() (data []byte, err error) {\n\tops, err := delivery_instructions.HasExtendedOptions()\n\tif err != nil {\n\t\treturn\n\t}\n\tif ops {\n\t\tvar extended_options_index int\n\t\textended_options_index, err = delivery_instructions.extended_options_index()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tif len(delivery_instructions) < extended_options_index+2 {\n\t\t\terr = errors.New(\"DeliveryInstructions are invalid, length is shorter than required for Extended Options\")\n\t\t\treturn\n\t\t} else {\n\t\t\textended_options_size := common.Integer([]byte{delivery_instructions[extended_options_index]})\n\t\t\tif len(delivery_instructions) < extended_options_index+1+extended_options_size {\n\t\t\t\terr = errors.New(\"DeliveryInstructions are invalid, length is shorter than specified in Extended Options\")\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tdata = delivery_instructions[extended_options_index+1 : extended_options_size]\n\t\t\t\treturn\n\t\t\t}\n\n\t\t}\n\t} else {\n\t\terr = errors.New(\"DeliveryInstruction does not have the ExtendedOptions flag set\")\n\t}\n\treturn\n}", "func NewMultiValueLegacyExtendedPropertyItemRequestBuilderInternal(pathParameters map[string]string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*MultiValueLegacyExtendedPropertyItemRequestBuilder) {\n m := &MultiValueLegacyExtendedPropertyItemRequestBuilder{\n }\n m.urlTemplate = \"{+baseurl}/me/calendarGroups/{calendarGroup%2Did}/calendars/{calendar%2Did}/events/{event%2Did}/instances/{event%2Did1}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty%2Did}{?%24select,%24expand}\";\n urlTplParams := make(map[string]string)\n for idx, item := range pathParameters {\n urlTplParams[idx] = item\n }\n m.pathParameters = urlTplParams;\n m.requestAdapter = requestAdapter;\n return m\n}", "func (o *GetPlatformsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Extended != nil {\n\n\t\t// query param extended\n\t\tvar qrExtended bool\n\t\tif o.Extended != nil {\n\t\t\tqrExtended = *o.Extended\n\t\t}\n\t\tqExtended := swag.FormatBool(qrExtended)\n\t\tif qExtended != \"\" {\n\t\t\tif err := r.SetQueryParam(\"extended\", qExtended); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func NewMultiValueLegacyExtendedPropertyItemRequestBuilder(rawUrl string, requestAdapter i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestAdapter)(*MultiValueLegacyExtendedPropertyItemRequestBuilder) {\n urlParams := make(map[string]string)\n urlParams[\"request-raw-url\"] = rawUrl\n return NewMultiValueLegacyExtendedPropertyItemRequestBuilderInternal(urlParams, requestAdapter)\n}", "func (opts *ToolOptions) AddToExtraOptionsRegistry(extraOpts ExtraOptions) {\n\topts.URI.extraOptionsRegistry = append(opts.URI.extraOptionsRegistry, extraOpts)\n}", "func (*poemExtension) Extend(m goldmark.Markdown) {\n\tm.Parser().AddOptions(\n\t\tparser.WithASTTransformers(\n\t\t\tutil.Prioritized(defaulTransformer, 100)),\n\t\tparser.WithBlockParsers(\n\t\t\tutil.Prioritized(defaultParser, 450)),\n\t)\n\tm.Renderer().AddOptions(\n\t\trenderer.WithNodeRenderers(\n\t\t\tutil.Prioritized(defaulRenderer, 100)),\n\t)\n}", "func WithStandardUserAgent(platform string, systemCode string) Option {\n\treturn func(d *ExtensibleTransport) {\n\t\text := NewUserAgentExtension(standardUserAgent(platform, systemCode))\n\t\td.extensions = append(d.extensions, ext)\n\t}\n}", "func (swagger *MgwSwagger) SetXWso2Extensions() error {\n\tswagger.setXWso2Basepath()\n\n\txWso2EPErr := swagger.setXWso2Endpoints()\n\tif xWso2EPErr != nil {\n\t\tlogger.LoggerOasparser.Error(\"Error while adding x-wso2-endpoints. \", xWso2EPErr)\n\t\treturn xWso2EPErr\n\t}\n\n\tapiLevelProdEPFound, productionEndpointErr := swagger.setXWso2ProductionEndpoint()\n\tif productionEndpointErr != nil {\n\t\tlogger.LoggerOasparser.Error(\"Error while adding x-wso2-production-endpoints. \", productionEndpointErr)\n\t\treturn productionEndpointErr\n\t}\n\n\tapiLevelSandEPFound, sandboxEndpointErr := swagger.setXWso2SandboxEndpoint()\n\tif sandboxEndpointErr != nil {\n\t\tlogger.LoggerOasparser.Error(\"Error while adding x-wso2-sandbox-endpoints. \", sandboxEndpointErr)\n\t\treturn sandboxEndpointErr\n\t}\n\n\t// to remove swagger server/host urls being added when x-wso2-sandbox-endpoints is given\n\tif !apiLevelProdEPFound && apiLevelSandEPFound && swagger.productionEndpoints != nil &&\n\t\tlen(swagger.productionEndpoints.Endpoints) > 0 {\n\t\tswagger.productionEndpoints = nil\n\t}\n\n\tswagger.setXWso2Cors()\n\tswagger.setXWso2ThrottlingTier()\n\tswagger.setDisableSecurity()\n\tswagger.setXWso2AuthHeader()\n\tswagger.setXWso2HTTP2BackendEnabled()\n\n\t// Error nil for successful execution\n\treturn nil\n}", "func (m pIsPublic) Extend(fnct func(m.UserSet) bool) pIsPublic {\n\treturn pIsPublic{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (o *NewData) SetExtra(v map[string]string) {\n\to.Extra = &v\n}", "func (me TxsdType) IsExtended() bool { return me.String() == \"extended\" }", "func ExampleMachineExtensionsClient_Get() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclientFactory, err := armhybridcompute.NewClientFactory(\"<subscription-id>\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tres, err := clientFactory.NewMachineExtensionsClient().Get(ctx, \"myResourceGroup\", \"myMachine\", \"CustomScriptExtension\", nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\t// You could use response here. We use blank identifier for just demo purposes.\n\t_ = res\n\t// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.\n\t// res.MachineExtension = armhybridcompute.MachineExtension{\n\t// \tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \tType: to.Ptr(\"Microsoft.HybridCompute/machines/extensions\"),\n\t// \tID: to.Ptr(\"/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/Machines/myMachine/Extensions/CustomScriptExtension\"),\n\t// \tLocation: to.Ptr(\"eastus2euap\"),\n\t// \tProperties: &armhybridcompute.MachineExtensionProperties{\n\t// \t\tType: to.Ptr(\"string\"),\n\t// \t\tAutoUpgradeMinorVersion: to.Ptr(false),\n\t// \t\tInstanceView: &armhybridcompute.MachineExtensionInstanceView{\n\t// \t\t\tName: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tType: to.Ptr(\"CustomScriptExtension\"),\n\t// \t\t\tStatus: &armhybridcompute.MachineExtensionInstanceViewStatus{\n\t// \t\t\t\tCode: to.Ptr(\"success\"),\n\t// \t\t\t\tDisplayStatus: to.Ptr(\"Provisioning succeeded\"),\n\t// \t\t\t\tLevel: to.Ptr(armhybridcompute.StatusLevelTypes(\"Information\")),\n\t// \t\t\t\tMessage: to.Ptr(\"Finished executing command, StdOut: , StdErr:\"),\n\t// \t\t\t\tTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, \"2019-08-08T20:42:10.999Z\"); return t}()),\n\t// \t\t\t},\n\t// \t\t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t\t},\n\t// \t\tProtectedSettings: map[string]any{\n\t// \t\t},\n\t// \t\tProvisioningState: to.Ptr(\"Succeeded\"),\n\t// \t\tPublisher: to.Ptr(\"Microsoft.Compute\"),\n\t// \t\tSettings: \"@{commandToExecute=powershell.exe -c \\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\"}\",\n\t// \t\tTypeHandlerVersion: to.Ptr(\"1.10.3\"),\n\t// \t},\n\t// }\n}", "func ExampleVirtualMachineScaleSetVMExtensionsClient_BeginCreateOrUpdate() {\n\tcred, err := azidentity.NewDefaultAzureCredential(nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to obtain a credential: %v\", err)\n\t}\n\tctx := context.Background()\n\tclient, err := armcompute.NewVirtualMachineScaleSetVMExtensionsClient(\"{subscription-id}\", cred, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to create client: %v\", err)\n\t}\n\tpoller, err := client.BeginCreateOrUpdate(ctx,\n\t\t\"myResourceGroup\",\n\t\t\"myvmScaleSet\",\n\t\t\"0\",\n\t\t\"myVMExtension\",\n\t\tarmcompute.VirtualMachineScaleSetVMExtension{\n\t\t\tProperties: &armcompute.VirtualMachineExtensionProperties{\n\t\t\t\tType: to.Ptr(\"extType\"),\n\t\t\t\tAutoUpgradeMinorVersion: to.Ptr(true),\n\t\t\t\tPublisher: to.Ptr(\"extPublisher\"),\n\t\t\t\tSettings: map[string]interface{}{\n\t\t\t\t\t\"UserName\": \"xyz@microsoft.com\",\n\t\t\t\t},\n\t\t\t\tTypeHandlerVersion: to.Ptr(\"1.2\"),\n\t\t\t},\n\t\t},\n\t\tnil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to finish the request: %v\", err)\n\t}\n\tres, err := poller.PollUntilDone(ctx, nil)\n\tif err != nil {\n\t\tlog.Fatalf(\"failed to pull the result: %v\", err)\n\t}\n\t// TODO: use response item\n\t_ = res\n}", "func (m pBrowseOne) Extend(fnct func(m.UserSet, int64) m.UserSet) pBrowseOne {\n\treturn pBrowseOne{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func GetCommonExtendedInfo() (map[string]string) {\n extendedInfo := map[string]string{\n \"csi_created_by_plugin_name\": CsiPluginName,\n \"csi_created_by_plugin_version\": Version,\n \"csi_created_by_plugin_git_hash\": Githash,\n \"csi_created_by_csi_version\": CsiVersion,\n }\n return extendedInfo\n}", "func (m pFetch) Extend(fnct func(m.UserSet) m.UserSet) pFetch {\n\treturn pFetch{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (r *SingleValueLegacyExtendedPropertyRequest) Get(ctx context.Context) (resObj *SingleValueLegacyExtendedProperty, err error) {\n\tvar query string\n\tif r.query != nil {\n\t\tquery = \"?\" + r.query.Encode()\n\t}\n\terr = r.JSONRequest(ctx, \"GET\", query, nil, &resObj)\n\treturn\n}", "func (m pWebReadGroupPrivate) Extend(fnct func(m.UserSet, webtypes.WebReadGroupParams) []models.FieldMap) pWebReadGroupPrivate {\n\treturn pWebReadGroupPrivate{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m pFieldsViewGet) Extend(fnct func(m.UserSet, webtypes.FieldsViewGetParams) *webtypes.FieldsViewData) pFieldsViewGet {\n\treturn pFieldsViewGet{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (s KernelArgs) Extend(k KernelArgs) {\n\tfor a, b := range k {\n\t\ts[a] = b\n\t}\n}", "func (m pWithNewContext) Extend(fnct func(m.UserSet, *types.Context) m.UserSet) pWithNewContext {\n\treturn pWithNewContext{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m pAddMandatoryGroups) Extend(fnct func(m.UserSet)) pAddMandatoryGroups {\n\treturn pAddMandatoryGroups{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func WithExtensions(extensions map[string]string) CallOpt {\n\treturn func(c *call) error {\n\t\tc.extensions = extensions\n\t\treturn nil\n\t}\n}", "func (v ProductExtended) MarshalEasyJSON(w *jwriter.Writer) {\n\teasyjsonD2b7633eEncodeBackendInternalModels5(w, v)\n}", "func (m pOffset) Extend(fnct func(m.UserSet, int) m.UserSet) pOffset {\n\treturn pOffset{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (ad *additionalData) AddExtendedField(name string, value interface{}) {\n\tif ad.data == nil {\n\t\tad.data = make(map[string]interface{})\n\t}\n\n\tad.data[name] = value\n}", "func setPlatform(ea *ExtractionArgs) (success bool) {\n\tswitch platform := runtime.GOOS; platform {\n\tcase osFREEBSD, osLINUX:\n\t\tea.Extractor = extractSectionUnix\n\t\tif ea.Verbose {\n\t\t\tea.ArArgs = append(ea.ArArgs, \"xv\")\n\t\t} else {\n\t\t\tea.ArArgs = append(ea.ArArgs, \"x\")\n\t\t}\n\t\tea.ObjectTypeInArchive = fileTypeELFOBJECT\n\t\tsuccess = true\n\tcase osDARWIN:\n\t\tea.Extractor = extractSectionDarwin\n\t\tea.ArArgs = append(ea.ArArgs, \"-x\")\n\t\tif ea.Verbose {\n\t\t\tea.ArArgs = append(ea.ArArgs, \"-v\")\n\t\t}\n\t\tea.ObjectTypeInArchive = fileTypeMACHOBJECT\n\t\tsuccess = true\n\tdefault:\n\t\tLogError(\"Unsupported platform: %s.\", platform)\n\t}\n\treturn\n}", "func (m pSelfReadableFields) Extend(fnct func(m.UserSet) map[string]bool) pSelfReadableFields {\n\treturn pSelfReadableFields{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m pComputeSessionToken) Extend(fnct func(m.UserSet, string) string) pComputeSessionToken {\n\treturn pComputeSessionToken{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (m *DeviceItemRequestBuilder) Extensions()(*ItemExtensionsRequestBuilder) {\n return NewItemExtensionsRequestBuilderInternal(m.pathParameters, m.requestAdapter)\n}", "func (client *MachineExtensionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, name string, extensionName string, options *MachineExtensionsClientGetOptions) (*policy.Request, error) {\n\turlPath := \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}\"\n\tif client.subscriptionID == \"\" {\n\t\treturn nil, errors.New(\"parameter client.subscriptionID cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{subscriptionId}\", url.PathEscape(client.subscriptionID))\n\tif resourceGroupName == \"\" {\n\t\treturn nil, errors.New(\"parameter resourceGroupName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{resourceGroupName}\", url.PathEscape(resourceGroupName))\n\tif name == \"\" {\n\t\treturn nil, errors.New(\"parameter name cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{name}\", url.PathEscape(name))\n\tif extensionName == \"\" {\n\t\treturn nil, errors.New(\"parameter extensionName cannot be empty\")\n\t}\n\turlPath = strings.ReplaceAll(urlPath, \"{extensionName}\", url.PathEscape(extensionName))\n\treq, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treqQP := req.Raw().URL.Query()\n\treqQP.Set(\"api-version\", \"2022-01-10-preview\")\n\treq.Raw().URL.RawQuery = reqQP.Encode()\n\treq.Raw().Header[\"Accept\"] = []string{\"application/json\"}\n\treturn req, nil\n}", "func (c Core) extend() int32 {\r\n\te := c.PopPc(Word)\r\n\tyn := int32(c.Regs[e>>12])\r\n\tif e&0x800 == 0 {\r\n\t\tyn = Word.SignedExtend(uint32(yn))\r\n\t}\r\n\treturn yn + Byte.SignedExtend(e)\r\n}", "func (m pWithContext) Extend(fnct func(m.UserSet, string, interface{}) m.UserSet) pWithContext {\n\treturn pWithContext{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func (p *Problem) Extend(key string, value interface{}) error {\n\n\tif _, reserved := ReservedKeys[strings.ToLower(key)]; reserved {\n\t\treturn ErrExtensionKeyIsReserved\n\t}\n\n\t_, keyFound := p.Extension(key)\n\tif !keyFound {\n\t\tp.extensionKeys = append(p.extensionKeys, key)\n\t}\n\n\tif value != nil {\n\t\tp.extensions[key] = value\n\t} else {\n\n\t\tdelete(p.extensions, key)\n\n\t\tfor x := 0; x < len(p.extensionKeys); {\n\n\t\t\tif strings.EqualFold(key, p.extensionKeys[x]) {\n\t\t\t\tp.extensionKeys = append(p.extensionKeys[:x], p.extensionKeys[x+1:]...)\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tx++\n\n\t\t}\n\n\t}\n\n\treturn nil\n\n}", "func (m pNew) Extend(fnct func(m.UserSet, m.UserData) m.UserSet) pNew {\n\treturn pNew{\n\t\tMethod: m.Method.Extend(fnct),\n\t}\n}", "func WithExtCharset(nli int) ExtCharsetOption {\n\treturn ExtCharsetOption{nli}\n}", "func (s *server) SetExtraTags(tags []string) {\n\ts.extraTags = tags\n}", "func (r *PostMultiValueExtendedPropertiesCollectionRequest) Add(ctx context.Context, reqObj *MultiValueLegacyExtendedProperty) (resObj *MultiValueLegacyExtendedProperty, err error) {\n\terr = r.JSONRequest(ctx, \"POST\", \"\", reqObj, &resObj)\n\treturn\n}", "func (znp *Znp) SysSetExtAddr(extAddr string) (rsp *StatusResponse, err error) {\n\treq := &SysSetExtAddr{ExtAddress: extAddr}\n\terr = znp.ProcessRequest(unp.C_SREQ, unp.S_SYS, 0x03, req, &rsp)\n\treturn\n}", "func (b *PostRequestBuilder) Extensions() *PostExtensionsCollectionRequestBuilder {\n\tbb := &PostExtensionsCollectionRequestBuilder{BaseRequestBuilder: b.BaseRequestBuilder}\n\tbb.baseURL += \"/extensions\"\n\treturn bb\n}" ]
[ "0.71823275", "0.6650728", "0.5868713", "0.5740037", "0.57266814", "0.55311686", "0.53988254", "0.53365576", "0.5276123", "0.51772213", "0.5176059", "0.51389223", "0.51068175", "0.5083746", "0.5057755", "0.5052479", "0.49989742", "0.49774477", "0.49474514", "0.4946438", "0.48997948", "0.48569828", "0.4834296", "0.48342094", "0.48221397", "0.48143062", "0.48065215", "0.48032272", "0.4796843", "0.47939652", "0.4785065", "0.47802243", "0.47775126", "0.4772373", "0.4739455", "0.47243357", "0.47017503", "0.4689346", "0.46810845", "0.4675407", "0.4672692", "0.46720287", "0.46616805", "0.46616367", "0.46488062", "0.46389952", "0.4633852", "0.46176794", "0.46146974", "0.46059352", "0.45938525", "0.4592913", "0.45793125", "0.4578739", "0.45771894", "0.45720276", "0.45719287", "0.4569063", "0.4559145", "0.45573387", "0.45504794", "0.4545497", "0.45290232", "0.4522859", "0.45097232", "0.45011476", "0.4495021", "0.4485987", "0.4485102", "0.4479699", "0.44775712", "0.44736633", "0.446151", "0.4460146", "0.4452284", "0.44520158", "0.44506893", "0.445022", "0.444714", "0.4437796", "0.44259855", "0.44213602", "0.4417716", "0.4417623", "0.441075", "0.44035143", "0.44021043", "0.4399143", "0.43874094", "0.43850067", "0.43826133", "0.4379022", "0.4378616", "0.43749318", "0.43747905", "0.43742537", "0.43730515", "0.4372736", "0.43691614", "0.43672284" ]
0.8300686
0
WriteToRequest writes these params to a swagger request
func (o *GetPlatformsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { if err := r.SetTimeout(o.timeout); err != nil { return err } var res []error if o.Extended != nil { // query param extended var qrExtended bool if o.Extended != nil { qrExtended = *o.Extended } qExtended := swag.FormatBool(qrExtended) if qExtended != "" { if err := r.SetQueryParam("extended", qExtended); err != nil { return err } } } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *FileInfoCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.ByteOffset != nil {\n\n\t\t// query param byte_offset\n\t\tvar qrByteOffset int64\n\n\t\tif o.ByteOffset != nil {\n\t\t\tqrByteOffset = *o.ByteOffset\n\t\t}\n\t\tqByteOffset := swag.FormatInt64(qrByteOffset)\n\t\tif qByteOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"byte_offset\", qByteOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tif o.Info != nil {\n\t\tif err := r.SetBodyParam(o.Info); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Overwrite != nil {\n\n\t\t// query param overwrite\n\t\tvar qrOverwrite bool\n\n\t\tif o.Overwrite != nil {\n\t\t\tqrOverwrite = *o.Overwrite\n\t\t}\n\t\tqOverwrite := swag.FormatBool(qrOverwrite)\n\t\tif qOverwrite != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"overwrite\", qOverwrite); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param path\n\tif err := r.SetPathParam(\"path\", o.Path); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ReturnRecords != nil {\n\n\t\t// query param return_records\n\t\tvar qrReturnRecords bool\n\n\t\tif o.ReturnRecords != nil {\n\t\t\tqrReturnRecords = *o.ReturnRecords\n\t\t}\n\t\tqReturnRecords := swag.FormatBool(qrReturnRecords)\n\t\tif qReturnRecords != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_records\", qReturnRecords); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.StreamName != nil {\n\n\t\t// query param stream_name\n\t\tvar qrStreamName string\n\n\t\tif o.StreamName != nil {\n\t\t\tqrStreamName = *o.StreamName\n\t\t}\n\t\tqStreamName := qrStreamName\n\t\tif qStreamName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"stream_name\", qStreamName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param volume.uuid\n\tif err := r.SetPathParam(\"volume.uuid\", o.VolumeUUID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Device-Id\n\tif err := r.SetHeaderParam(\"Device-Id\", o.DeviceID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.DeviceOS != nil {\n\n\t\t// header param Device-OS\n\t\tif err := r.SetHeaderParam(\"Device-OS\", *o.DeviceOS); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\t// path param fiscalDocumentNumber\n\tif err := r.SetPathParam(\"fiscalDocumentNumber\", swag.FormatUint64(o.FiscalDocumentNumber)); err != nil {\n\t\treturn err\n\t}\n\n\t// path param fiscalDriveNumber\n\tif err := r.SetPathParam(\"fiscalDriveNumber\", swag.FormatUint64(o.FiscalDriveNumber)); err != nil {\n\t\treturn err\n\t}\n\n\t// query param fiscalSign\n\tqrFiscalSign := o.FiscalSign\n\tqFiscalSign := swag.FormatUint64(qrFiscalSign)\n\tif qFiscalSign != \"\" {\n\t\tif err := r.SetQueryParam(\"fiscalSign\", qFiscalSign); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.SendToEmail != nil {\n\n\t\t// query param sendToEmail\n\t\tvar qrSendToEmail string\n\t\tif o.SendToEmail != nil {\n\t\t\tqrSendToEmail = *o.SendToEmail\n\t\t}\n\t\tqSendToEmail := qrSendToEmail\n\t\tif qSendToEmail != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sendToEmail\", qSendToEmail); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *StartV1Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Environment != nil {\n\n\t\t// query param environment\n\t\tvar qrEnvironment string\n\t\tif o.Environment != nil {\n\t\t\tqrEnvironment = *o.Environment\n\t\t}\n\t\tqEnvironment := qrEnvironment\n\t\tif qEnvironment != \"\" {\n\t\t\tif err := r.SetQueryParam(\"environment\", qEnvironment); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdateAutoTagParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID.String()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetIntrospectionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ResponseAsJwt != nil {\n\n\t\t// query param response_as_jwt\n\t\tvar qrResponseAsJwt bool\n\t\tif o.ResponseAsJwt != nil {\n\t\t\tqrResponseAsJwt = *o.ResponseAsJwt\n\t\t}\n\t\tqResponseAsJwt := swag.FormatBool(qrResponseAsJwt)\n\t\tif qResponseAsJwt != \"\" {\n\t\t\tif err := r.SetQueryParam(\"response_as_jwt\", qResponseAsJwt); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param token\n\tqrToken := o.Token\n\tqToken := qrToken\n\tif qToken != \"\" {\n\t\tif err := r.SetQueryParam(\"token\", qToken); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.TokenTypeHint != nil {\n\n\t\t// query param token_type_hint\n\t\tvar qrTokenTypeHint string\n\t\tif o.TokenTypeHint != nil {\n\t\t\tqrTokenTypeHint = *o.TokenTypeHint\n\t\t}\n\t\tqTokenTypeHint := qrTokenTypeHint\n\t\tif qTokenTypeHint != \"\" {\n\t\t\tif err := r.SetQueryParam(\"token_type_hint\", qTokenTypeHint); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostContextsAddPhpParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param name\n\tqrName := o.Name\n\tqName := qrName\n\tif qName != \"\" {\n\n\t\tif err := r.SetQueryParam(\"name\", qName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Private != nil {\n\n\t\t// query param private\n\t\tvar qrPrivate int64\n\n\t\tif o.Private != nil {\n\t\t\tqrPrivate = *o.Private\n\t\t}\n\t\tqPrivate := swag.FormatInt64(qrPrivate)\n\t\tif qPrivate != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"private\", qPrivate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetInstancesDocsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\tif o.OperationID != nil {\n\n\t\t// query param operationId\n\t\tvar qrOperationID string\n\t\tif o.OperationID != nil {\n\t\t\tqrOperationID = *o.OperationID\n\t\t}\n\t\tqOperationID := qrOperationID\n\t\tif qOperationID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"operationId\", qOperationID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Version != nil {\n\n\t\t// query param version\n\t\tvar qrVersion string\n\t\tif o.Version != nil {\n\t\t\tqrVersion = *o.Version\n\t\t}\n\t\tqVersion := qrVersion\n\t\tif qVersion != \"\" {\n\t\t\tif err := r.SetQueryParam(\"version\", qVersion); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CloudTargetCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.CheckOnly != nil {\n\n\t\t// query param check_only\n\t\tvar qrCheckOnly bool\n\n\t\tif o.CheckOnly != nil {\n\t\t\tqrCheckOnly = *o.CheckOnly\n\t\t}\n\t\tqCheckOnly := swag.FormatBool(qrCheckOnly)\n\t\tif qCheckOnly != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"check_only\", qCheckOnly); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.IgnoreWarnings != nil {\n\n\t\t// query param ignore_warnings\n\t\tvar qrIgnoreWarnings bool\n\n\t\tif o.IgnoreWarnings != nil {\n\t\t\tqrIgnoreWarnings = *o.IgnoreWarnings\n\t\t}\n\t\tqIgnoreWarnings := swag.FormatBool(qrIgnoreWarnings)\n\t\tif qIgnoreWarnings != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ignore_warnings\", qIgnoreWarnings); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\tif o.Info != nil {\n\t\tif err := r.SetBodyParam(o.Info); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.ReturnRecords != nil {\n\n\t\t// query param return_records\n\t\tvar qrReturnRecords bool\n\n\t\tif o.ReturnRecords != nil {\n\t\t\tqrReturnRecords = *o.ReturnRecords\n\t\t}\n\t\tqReturnRecords := swag.FormatBool(qrReturnRecords)\n\t\tif qReturnRecords != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_records\", qReturnRecords); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ReturnTimeout != nil {\n\n\t\t// query param return_timeout\n\t\tvar qrReturnTimeout int64\n\n\t\tif o.ReturnTimeout != nil {\n\t\t\tqrReturnTimeout = *o.ReturnTimeout\n\t\t}\n\t\tqReturnTimeout := swag.FormatInt64(qrReturnTimeout)\n\t\tif qReturnTimeout != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"return_timeout\", qReturnTimeout); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SayParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Sinkid != nil {\n\n\t\t// query param sinkid\n\t\tvar qrSinkid string\n\t\tif o.Sinkid != nil {\n\t\t\tqrSinkid = *o.Sinkid\n\t\t}\n\t\tqSinkid := qrSinkid\n\t\tif qSinkid != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sinkid\", qSinkid); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Voiceid != nil {\n\n\t\t// query param voiceid\n\t\tvar qrVoiceid string\n\t\tif o.Voiceid != nil {\n\t\t\tqrVoiceid = *o.Voiceid\n\t\t}\n\t\tqVoiceid := qrVoiceid\n\t\tif qVoiceid != \"\" {\n\t\t\tif err := r.SetQueryParam(\"voiceid\", qVoiceid); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *HandleGetAboutUsingGETParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// query param apiVersion\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\n\tif err := r.SetQueryParam(\"apiVersion\", qAPIVersion); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetFileSystemParametersInternalParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AccountID != nil {\n\n\t\t// query param accountId\n\t\tvar qrAccountID string\n\t\tif o.AccountID != nil {\n\t\t\tqrAccountID = *o.AccountID\n\t\t}\n\t\tqAccountID := qrAccountID\n\t\tif qAccountID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"accountId\", qAccountID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.AccountName != nil {\n\n\t\t// query param accountName\n\t\tvar qrAccountName string\n\t\tif o.AccountName != nil {\n\t\t\tqrAccountName = *o.AccountName\n\t\t}\n\t\tqAccountName := qrAccountName\n\t\tif qAccountName != \"\" {\n\t\t\tif err := r.SetQueryParam(\"accountName\", qAccountName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.AttachedCluster != nil {\n\n\t\t// query param attachedCluster\n\t\tvar qrAttachedCluster bool\n\t\tif o.AttachedCluster != nil {\n\t\t\tqrAttachedCluster = *o.AttachedCluster\n\t\t}\n\t\tqAttachedCluster := swag.FormatBool(qrAttachedCluster)\n\t\tif qAttachedCluster != \"\" {\n\t\t\tif err := r.SetQueryParam(\"attachedCluster\", qAttachedCluster); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param blueprintName\n\tqrBlueprintName := o.BlueprintName\n\tqBlueprintName := qrBlueprintName\n\tif qBlueprintName != \"\" {\n\t\tif err := r.SetQueryParam(\"blueprintName\", qBlueprintName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param clusterName\n\tqrClusterName := o.ClusterName\n\tqClusterName := qrClusterName\n\tif qClusterName != \"\" {\n\t\tif err := r.SetQueryParam(\"clusterName\", qClusterName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param fileSystemType\n\tqrFileSystemType := o.FileSystemType\n\tqFileSystemType := qrFileSystemType\n\tif qFileSystemType != \"\" {\n\t\tif err := r.SetQueryParam(\"fileSystemType\", qFileSystemType); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Secure != nil {\n\n\t\t// query param secure\n\t\tvar qrSecure bool\n\t\tif o.Secure != nil {\n\t\t\tqrSecure = *o.Secure\n\t\t}\n\t\tqSecure := swag.FormatBool(qrSecure)\n\t\tif qSecure != \"\" {\n\t\t\tif err := r.SetQueryParam(\"secure\", qSecure); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param storageName\n\tqrStorageName := o.StorageName\n\tqStorageName := qrStorageName\n\tif qStorageName != \"\" {\n\t\tif err := r.SetQueryParam(\"storageName\", qStorageName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param workspaceId\n\tif err := r.SetPathParam(\"workspaceId\", swag.FormatInt64(o.WorkspaceID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ServeBuildFieldShortParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param btLocator\n\tif err := r.SetPathParam(\"btLocator\", o.BtLocator); err != nil {\n\t\treturn err\n\t}\n\n\t// path param buildLocator\n\tif err := r.SetPathParam(\"buildLocator\", o.BuildLocator); err != nil {\n\t\treturn err\n\t}\n\n\t// path param field\n\tif err := r.SetPathParam(\"field\", o.Field); err != nil {\n\t\treturn err\n\t}\n\n\t// path param projectLocator\n\tif err := r.SetPathParam(\"projectLocator\", o.ProjectLocator); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetRequestDetailsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param extra\n\tif err := r.SetPathParam(\"extra\", o.Extra); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetWorkItemParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.DollarExpand != nil {\n\n\t\t// query param $expand\n\t\tvar qrNrDollarExpand string\n\t\tif o.DollarExpand != nil {\n\t\t\tqrNrDollarExpand = *o.DollarExpand\n\t\t}\n\t\tqNrDollarExpand := qrNrDollarExpand\n\t\tif qNrDollarExpand != \"\" {\n\t\t\tif err := r.SetQueryParam(\"$expand\", qNrDollarExpand); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.AsOf != nil {\n\n\t\t// query param asOf\n\t\tvar qrAsOf strfmt.DateTime\n\t\tif o.AsOf != nil {\n\t\t\tqrAsOf = *o.AsOf\n\t\t}\n\t\tqAsOf := qrAsOf.String()\n\t\tif qAsOf != \"\" {\n\t\t\tif err := r.SetQueryParam(\"asOf\", qAsOf); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt32(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *IntegrationsManualHTTPSCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Data); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ValidateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostSecdefSearchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Symbol); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UserShowV1Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\t// path param name\n\tif err := r.SetPathParam(\"name\", o.Name); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetLogsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.From != nil {\n\n\t\t// query param from\n\t\tvar qrFrom string\n\t\tif o.From != nil {\n\t\t\tqrFrom = *o.From\n\t\t}\n\t\tqFrom := qrFrom\n\t\tif qFrom != \"\" {\n\t\t\tif err := r.SetQueryParam(\"from\", qFrom); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IncludeFields != nil {\n\n\t\t// query param include_fields\n\t\tvar qrIncludeFields bool\n\t\tif o.IncludeFields != nil {\n\t\t\tqrIncludeFields = *o.IncludeFields\n\t\t}\n\t\tqIncludeFields := swag.FormatBool(qrIncludeFields)\n\t\tif qIncludeFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"include_fields\", qIncludeFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IncludeTotals != nil {\n\n\t\t// query param include_totals\n\t\tvar qrIncludeTotals bool\n\t\tif o.IncludeTotals != nil {\n\t\t\tqrIncludeTotals = *o.IncludeTotals\n\t\t}\n\t\tqIncludeTotals := swag.FormatBool(qrIncludeTotals)\n\t\tif qIncludeTotals != \"\" {\n\t\t\tif err := r.SetQueryParam(\"include_totals\", qIncludeTotals); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int64\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt64(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.PerPage != nil {\n\n\t\t// query param per_page\n\t\tvar qrPerPage int64\n\t\tif o.PerPage != nil {\n\t\t\tqrPerPage = *o.PerPage\n\t\t}\n\t\tqPerPage := swag.FormatInt64(qrPerPage)\n\t\tif qPerPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"per_page\", qPerPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Take != nil {\n\n\t\t// query param take\n\t\tvar qrTake int64\n\t\tif o.Take != nil {\n\t\t\tqrTake = *o.Take\n\t\t}\n\t\tqTake := swag.FormatInt64(qrTake)\n\t\tif qTake != \"\" {\n\t\t\tif err := r.SetQueryParam(\"take\", qTake); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostGetOneParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tvaluesRelated := o.Related\n\n\tjoinedRelated := swag.JoinByFormat(valuesRelated, \"\")\n\t// query array param related\n\tif err := r.SetQueryParam(\"related\", joinedRelated...); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *BarParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ConfigGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Option != nil {\n\n\t\t// binding items for option\n\t\tjoinedOption := o.bindParamOption(reg)\n\n\t\t// query array param option\n\t\tif err := r.SetQueryParam(\"option\", joinedOption...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.ProjectID != nil {\n\n\t\t// query param project_id\n\t\tvar qrProjectID int64\n\n\t\tif o.ProjectID != nil {\n\t\t\tqrProjectID = *o.ProjectID\n\t\t}\n\t\tqProjectID := swag.FormatInt64(qrProjectID)\n\t\tif qProjectID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"project_id\", qProjectID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.UserID != nil {\n\n\t\t// query param user_id\n\t\tvar qrUserID int64\n\n\t\tif o.UserID != nil {\n\t\t\tqrUserID = *o.UserID\n\t\t}\n\t\tqUserID := swag.FormatInt64(qrUserID)\n\t\tif qUserID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"user_id\", qUserID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetSsoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param code\n\tqrCode := o.Code\n\tqCode := qrCode\n\tif qCode != \"\" {\n\t\tif err := r.SetQueryParam(\"code\", qCode); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// query param resource_id\n\tqrResourceID := o.ResourceID\n\tqResourceID := qrResourceID\n\tif qResourceID != \"\" {\n\t\tif err := r.SetQueryParam(\"resource_id\", qResourceID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *AllLookmlTestsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.FileID != nil {\n\n\t\t// query param file_id\n\t\tvar qrFileID string\n\t\tif o.FileID != nil {\n\t\t\tqrFileID = *o.FileID\n\t\t}\n\t\tqFileID := qrFileID\n\t\tif qFileID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"file_id\", qFileID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param project_id\n\tif err := r.SetPathParam(\"project_id\", o.ProjectID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *APIServiceHaltsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Height != nil {\n\n\t\t// query param height\n\t\tvar qrHeight string\n\t\tif o.Height != nil {\n\t\t\tqrHeight = *o.Height\n\t\t}\n\t\tqHeight := qrHeight\n\t\tif qHeight != \"\" {\n\t\t\tif err := r.SetQueryParam(\"height\", qHeight); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetUsersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Connection != nil {\n\n\t\t// query param connection\n\t\tvar qrConnection string\n\t\tif o.Connection != nil {\n\t\t\tqrConnection = *o.Connection\n\t\t}\n\t\tqConnection := qrConnection\n\t\tif qConnection != \"\" {\n\t\t\tif err := r.SetQueryParam(\"connection\", qConnection); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IncludeFields != nil {\n\n\t\t// query param include_fields\n\t\tvar qrIncludeFields bool\n\t\tif o.IncludeFields != nil {\n\t\t\tqrIncludeFields = *o.IncludeFields\n\t\t}\n\t\tqIncludeFields := swag.FormatBool(qrIncludeFields)\n\t\tif qIncludeFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"include_fields\", qIncludeFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IncludeTotals != nil {\n\n\t\t// query param include_totals\n\t\tvar qrIncludeTotals bool\n\t\tif o.IncludeTotals != nil {\n\t\t\tqrIncludeTotals = *o.IncludeTotals\n\t\t}\n\t\tqIncludeTotals := swag.FormatBool(qrIncludeTotals)\n\t\tif qIncludeTotals != \"\" {\n\t\t\tif err := r.SetQueryParam(\"include_totals\", qIncludeTotals); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int64\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt64(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.PerPage != nil {\n\n\t\t// query param per_page\n\t\tvar qrPerPage int64\n\t\tif o.PerPage != nil {\n\t\t\tqrPerPage = *o.PerPage\n\t\t}\n\t\tqPerPage := swag.FormatInt64(qrPerPage)\n\t\tif qPerPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"per_page\", qPerPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.SearchEngine != nil {\n\n\t\t// query param search_engine\n\t\tvar qrSearchEngine string\n\t\tif o.SearchEngine != nil {\n\t\t\tqrSearchEngine = *o.SearchEngine\n\t\t}\n\t\tqSearchEngine := qrSearchEngine\n\t\tif qSearchEngine != \"\" {\n\t\t\tif err := r.SetQueryParam(\"search_engine\", qSearchEngine); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetBlockGeneratorResultParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CreateRuntimeMapParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.FileUpload != nil {\n\n\t\tif o.FileUpload != nil {\n\n\t\t\t// form file param file_upload\n\t\t\tif err := r.SetFileParam(\"file_upload\", o.FileUpload); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetUserUsageParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Cloud != nil {\n\n\t\t// query param cloud\n\t\tvar qrCloud string\n\t\tif o.Cloud != nil {\n\t\t\tqrCloud = *o.Cloud\n\t\t}\n\t\tqCloud := qrCloud\n\t\tif qCloud != \"\" {\n\t\t\tif err := r.SetQueryParam(\"cloud\", qCloud); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filterenddate != nil {\n\n\t\t// query param filterenddate\n\t\tvar qrFilterenddate int64\n\t\tif o.Filterenddate != nil {\n\t\t\tqrFilterenddate = *o.Filterenddate\n\t\t}\n\t\tqFilterenddate := swag.FormatInt64(qrFilterenddate)\n\t\tif qFilterenddate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filterenddate\", qFilterenddate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Since != nil {\n\n\t\t// query param since\n\t\tvar qrSince int64\n\t\tif o.Since != nil {\n\t\t\tqrSince = *o.Since\n\t\t}\n\t\tqSince := swag.FormatInt64(qrSince)\n\t\tif qSince != \"\" {\n\t\t\tif err := r.SetQueryParam(\"since\", qSince); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Zone != nil {\n\n\t\t// query param zone\n\t\tvar qrZone string\n\t\tif o.Zone != nil {\n\t\t\tqrZone = *o.Zone\n\t\t}\n\t\tqZone := qrZone\n\t\tif qZone != \"\" {\n\t\t\tif err := r.SetQueryParam(\"zone\", qZone); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetOrderParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.MerchantID != nil {\n\n\t\t// query param merchantId\n\t\tvar qrMerchantID int64\n\t\tif o.MerchantID != nil {\n\t\t\tqrMerchantID = *o.MerchantID\n\t\t}\n\t\tqMerchantID := swag.FormatInt64(qrMerchantID)\n\t\tif qMerchantID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"merchantId\", qMerchantID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetPropertyDescriptorParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\t// query param propertyName\n\tqrPropertyName := o.PropertyName\n\tqPropertyName := qrPropertyName\n\tif qPropertyName != \"\" {\n\n\t\tif err := r.SetQueryParam(\"propertyName\", qPropertyName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetCurrentGenerationParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CreateGitWebhookUsingPOSTParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// query param apiVersion\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\n\tif err := r.SetQueryParam(\"apiVersion\", qAPIVersion); err != nil {\n\t\treturn err\n\t}\n\tif err := r.SetBodyParam(o.GitWebhookSpec); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ViewsGetByIDParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param identifier\n\tif err := r.SetPathParam(\"identifier\", o.Identifier); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdateDeviceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param deviceId\n\tif err := r.SetPathParam(\"deviceId\", o.DeviceID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.UpdateDeviceRequest != nil {\n\t\tif err := r.SetBodyParam(o.UpdateDeviceRequest); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SaveTemplateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); err != nil {\n\t\treturn err\n\t}\n\n\t// path param templateId\n\tif err := r.SetPathParam(\"templateId\", o.TemplateID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ConvertParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param from.currency_code\n\tif err := r.SetPathParam(\"from.currency_code\", o.FromCurrencyCode); err != nil {\n\t\treturn err\n\t}\n\n\tif o.FromNanos != nil {\n\n\t\t// query param from.nanos\n\t\tvar qrFromNanos int32\n\t\tif o.FromNanos != nil {\n\t\t\tqrFromNanos = *o.FromNanos\n\t\t}\n\t\tqFromNanos := swag.FormatInt32(qrFromNanos)\n\t\tif qFromNanos != \"\" {\n\t\t\tif err := r.SetQueryParam(\"from.nanos\", qFromNanos); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.FromUnits != nil {\n\n\t\t// query param from.units\n\t\tvar qrFromUnits string\n\t\tif o.FromUnits != nil {\n\t\t\tqrFromUnits = *o.FromUnits\n\t\t}\n\t\tqFromUnits := qrFromUnits\n\t\tif qFromUnits != \"\" {\n\t\t\tif err := r.SetQueryParam(\"from.units\", qFromUnits); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param to_code\n\tif err := r.SetPathParam(\"to_code\", o.ToCode); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SystemEventsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Filters != nil {\n\n\t\t// query param filters\n\t\tvar qrFilters string\n\t\tif o.Filters != nil {\n\t\t\tqrFilters = *o.Filters\n\t\t}\n\t\tqFilters := qrFilters\n\t\tif qFilters != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filters\", qFilters); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Since != nil {\n\n\t\t// query param since\n\t\tvar qrSince string\n\t\tif o.Since != nil {\n\t\t\tqrSince = *o.Since\n\t\t}\n\t\tqSince := qrSince\n\t\tif qSince != \"\" {\n\t\t\tif err := r.SetQueryParam(\"since\", qSince); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Until != nil {\n\n\t\t// query param until\n\t\tvar qrUntil string\n\t\tif o.Until != nil {\n\t\t\tqrUntil = *o.Until\n\t\t}\n\t\tqUntil := qrUntil\n\t\tif qUntil != \"\" {\n\t\t\tif err := r.SetQueryParam(\"until\", qUntil); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetBundleByKeyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Audit != nil {\n\n\t\t// query param audit\n\t\tvar qrAudit string\n\n\t\tif o.Audit != nil {\n\t\t\tqrAudit = *o.Audit\n\t\t}\n\t\tqAudit := qrAudit\n\t\tif qAudit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"audit\", qAudit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// query param externalKey\n\tqrExternalKey := o.ExternalKey\n\tqExternalKey := qrExternalKey\n\tif qExternalKey != \"\" {\n\n\t\tif err := r.SetQueryParam(\"externalKey\", qExternalKey); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.IncludedDeleted != nil {\n\n\t\t// query param includedDeleted\n\t\tvar qrIncludedDeleted bool\n\n\t\tif o.IncludedDeleted != nil {\n\t\t\tqrIncludedDeleted = *o.IncludedDeleted\n\t\t}\n\t\tqIncludedDeleted := swag.FormatBool(qrIncludedDeleted)\n\t\tif qIncludedDeleted != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"includedDeleted\", qIncludedDeleted); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// header param WithProfilingInfo\n\tif o.WithProfilingInfo != nil && len(*o.WithProfilingInfo) > 0 {\n\t\tif err := r.SetHeaderParam(\"X-Killbill-Profiling-Req\", *o.WithProfilingInfo); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// header param withStackTrace\n\tif o.WithStackTrace != nil && *o.WithStackTrace {\n\t\tif err := r.SetQueryParam(\"withStackTrace\", \"true\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SwarmUpdateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.RotateManagerToken != nil {\n\n\t\t// query param rotateManagerToken\n\t\tvar qrRotateManagerToken bool\n\t\tif o.RotateManagerToken != nil {\n\t\t\tqrRotateManagerToken = *o.RotateManagerToken\n\t\t}\n\t\tqRotateManagerToken := swag.FormatBool(qrRotateManagerToken)\n\t\tif qRotateManagerToken != \"\" {\n\t\t\tif err := r.SetQueryParam(\"rotateManagerToken\", qRotateManagerToken); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.RotateManagerUnlockKey != nil {\n\n\t\t// query param rotateManagerUnlockKey\n\t\tvar qrRotateManagerUnlockKey bool\n\t\tif o.RotateManagerUnlockKey != nil {\n\t\t\tqrRotateManagerUnlockKey = *o.RotateManagerUnlockKey\n\t\t}\n\t\tqRotateManagerUnlockKey := swag.FormatBool(qrRotateManagerUnlockKey)\n\t\tif qRotateManagerUnlockKey != \"\" {\n\t\t\tif err := r.SetQueryParam(\"rotateManagerUnlockKey\", qRotateManagerUnlockKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.RotateWorkerToken != nil {\n\n\t\t// query param rotateWorkerToken\n\t\tvar qrRotateWorkerToken bool\n\t\tif o.RotateWorkerToken != nil {\n\t\t\tqrRotateWorkerToken = *o.RotateWorkerToken\n\t\t}\n\t\tqRotateWorkerToken := swag.FormatBool(qrRotateWorkerToken)\n\t\tif qRotateWorkerToken != \"\" {\n\t\t\tif err := r.SetQueryParam(\"rotateWorkerToken\", qRotateWorkerToken); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param version\n\tqrVersion := o.Version\n\tqVersion := swag.FormatInt64(qrVersion)\n\tif qVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"version\", qVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ServiceInstanceGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.XBrokerAPIOriginatingIdentity != nil {\n\n\t\t// header param X-Broker-API-Originating-Identity\n\t\tif err := r.SetHeaderParam(\"X-Broker-API-Originating-Identity\", *o.XBrokerAPIOriginatingIdentity); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// header param X-Broker-API-Version\n\tif err := r.SetHeaderParam(\"X-Broker-API-Version\", o.XBrokerAPIVersion); err != nil {\n\t\treturn err\n\t}\n\n\t// path param instance_id\n\tif err := r.SetPathParam(\"instance_id\", o.InstanceID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ShowPackageParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param media_type\n\tif err := r.SetPathParam(\"media_type\", o.MediaType); err != nil {\n\t\treturn err\n\t}\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\t// path param package\n\tif err := r.SetPathParam(\"package\", o.Package); err != nil {\n\t\treturn err\n\t}\n\n\t// path param release\n\tif err := r.SetPathParam(\"release\", o.Release); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SizeParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Parameters); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetOutagesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param count\n\tqrCount := o.Count\n\tqCount := swag.FormatFloat64(qrCount)\n\tif qCount != \"\" {\n\n\t\tif err := r.SetQueryParam(\"count\", qCount); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.DeviceID != nil {\n\n\t\t// query param deviceId\n\t\tvar qrDeviceID string\n\n\t\tif o.DeviceID != nil {\n\t\t\tqrDeviceID = *o.DeviceID\n\t\t}\n\t\tqDeviceID := qrDeviceID\n\t\tif qDeviceID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"deviceId\", qDeviceID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.InProgress != nil {\n\n\t\t// query param inProgress\n\t\tvar qrInProgress bool\n\n\t\tif o.InProgress != nil {\n\t\t\tqrInProgress = *o.InProgress\n\t\t}\n\t\tqInProgress := swag.FormatBool(qrInProgress)\n\t\tif qInProgress != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"inProgress\", qInProgress); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// query param page\n\tqrPage := o.Page\n\tqPage := swag.FormatFloat64(qrPage)\n\tif qPage != \"\" {\n\n\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Period != nil {\n\n\t\t// query param period\n\t\tvar qrPeriod float64\n\n\t\tif o.Period != nil {\n\t\t\tqrPeriod = *o.Period\n\t\t}\n\t\tqPeriod := swag.FormatFloat64(qrPeriod)\n\t\tif qPeriod != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"period\", qPeriod); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Query != nil {\n\n\t\t// query param query\n\t\tvar qrQuery string\n\n\t\tif o.Query != nil {\n\t\t\tqrQuery = *o.Query\n\t\t}\n\t\tqQuery := qrQuery\n\t\tif qQuery != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"query\", qQuery); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Type != nil {\n\n\t\t// query param type\n\t\tvar qrType string\n\n\t\tif o.Type != nil {\n\t\t\tqrType = *o.Type\n\t\t}\n\t\tqType := qrType\n\t\tif qType != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"type\", qType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *TerminateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param extractorId\n\tif err := r.SetPathParam(\"extractorId\", o.ExtractorID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param inputId\n\tif err := r.SetPathParam(\"inputId\", o.InputID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ServeFieldParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param field\n\tif err := r.SetPathParam(\"field\", o.Field); err != nil {\n\t\treturn err\n\t}\n\n\t// path param vcsRootLocator\n\tif err := r.SetPathParam(\"vcsRootLocator\", o.VcsRootLocator); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PostV1DevicesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// form param device_identifier\n\tfrDeviceIdentifier := o.DeviceIdentifier\n\tfDeviceIdentifier := frDeviceIdentifier\n\tif fDeviceIdentifier != \"\" {\n\t\tif err := r.SetFormParam(\"device_identifier\", fDeviceIdentifier); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// form param kind\n\tfrKind := o.Kind\n\tfKind := frKind\n\tif fKind != \"\" {\n\t\tif err := r.SetFormParam(\"kind\", fKind); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// form param name\n\tfrName := o.Name\n\tfName := frName\n\tif fName != \"\" {\n\t\tif err := r.SetFormParam(\"name\", fName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.NotificationIdentifier != nil {\n\n\t\t// form param notification_identifier\n\t\tvar frNotificationIdentifier string\n\t\tif o.NotificationIdentifier != nil {\n\t\t\tfrNotificationIdentifier = *o.NotificationIdentifier\n\t\t}\n\t\tfNotificationIdentifier := frNotificationIdentifier\n\t\tif fNotificationIdentifier != \"\" {\n\t\t\tif err := r.SetFormParam(\"notification_identifier\", fNotificationIdentifier); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.SubscribeNotification != nil {\n\n\t\t// form param subscribe_notification\n\t\tvar frSubscribeNotification bool\n\t\tif o.SubscribeNotification != nil {\n\t\t\tfrSubscribeNotification = *o.SubscribeNotification\n\t\t}\n\t\tfSubscribeNotification := swag.FormatBool(frSubscribeNotification)\n\t\tif fSubscribeNotification != \"\" {\n\t\t\tif err := r.SetFormParam(\"subscribe_notification\", fSubscribeNotification); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *QueryFirewallFieldsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset string\n\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := qrOffset\n\t\tif qOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.PlatformID != nil {\n\n\t\t// query param platform_id\n\t\tvar qrPlatformID string\n\n\t\tif o.PlatformID != nil {\n\t\t\tqrPlatformID = *o.PlatformID\n\t\t}\n\t\tqPlatformID := qrPlatformID\n\t\tif qPlatformID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"platform_id\", qPlatformID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetCatalogXMLParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AccountID != nil {\n\n\t\t// query param accountId\n\t\tvar qrAccountID strfmt.UUID\n\n\t\tif o.AccountID != nil {\n\t\t\tqrAccountID = *o.AccountID\n\t\t}\n\t\tqAccountID := qrAccountID.String()\n\t\tif qAccountID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"accountId\", qAccountID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.RequestedDate != nil {\n\n\t\t// query param requestedDate\n\t\tvar qrRequestedDate strfmt.DateTime\n\n\t\tif o.RequestedDate != nil {\n\t\t\tqrRequestedDate = *o.RequestedDate\n\t\t}\n\t\tqRequestedDate := qrRequestedDate.String()\n\t\tif qRequestedDate != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"requestedDate\", qRequestedDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// header param WithProfilingInfo\n\tif o.WithProfilingInfo != nil && len(*o.WithProfilingInfo) > 0 {\n\t\tif err := r.SetHeaderParam(\"X-Killbill-Profiling-Req\", *o.WithProfilingInfo); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// header param withStackTrace\n\tif o.WithStackTrace != nil && *o.WithStackTrace {\n\t\tif err := r.SetQueryParam(\"withStackTrace\", \"true\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetClockParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param X-Killbill-ApiKey\n\tif err := r.SetHeaderParam(\"X-Killbill-ApiKey\", o.XKillbillAPIKey); err != nil {\n\t\treturn err\n\t}\n\n\t// header param X-Killbill-ApiSecret\n\tif err := r.SetHeaderParam(\"X-Killbill-ApiSecret\", o.XKillbillAPISecret); err != nil {\n\t\treturn err\n\t}\n\n\t// header param WithProfilingInfo\n\tif o.WithProfilingInfo != nil && len(*o.WithProfilingInfo) > 0 {\n\t\tif err := r.SetHeaderParam(\"X-Killbill-Profiling-Req\", *o.WithProfilingInfo); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// header param withStackTrace\n\tif o.WithStackTrace != nil && *o.WithStackTrace {\n\t\tif err := r.SetQueryParam(\"withStackTrace\", \"true\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *AdminCreateJusticeUserParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\t// path param targetNamespace\n\tif err := r.SetPathParam(\"targetNamespace\", o.TargetNamespace); err != nil {\n\t\treturn err\n\t}\n\n\t// path param userId\n\tif err := r.SetPathParam(\"userId\", o.UserID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdateWidgetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Accept != nil {\n\n\t\t// header param Accept\n\t\tif err := r.SetHeaderParam(\"Accept\", *o.Accept); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.ContentType != nil {\n\n\t\t// header param Content-Type\n\t\tif err := r.SetHeaderParam(\"Content-Type\", *o.ContentType); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\t// path param uuid\n\tif err := r.SetPathParam(\"uuid\", o.UUID.String()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetBodyParam(o.WidgetBody); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *TestEndpointParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetLogsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.XRequestID != nil {\n\n\t\t// header param X-Request-Id\n\t\tif err := r.SetHeaderParam(\"X-Request-Id\", *o.XRequestID); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int64\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt64(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.PageSize != nil {\n\n\t\t// query param page_size\n\t\tvar qrPageSize int64\n\t\tif o.PageSize != nil {\n\t\t\tqrPageSize = *o.PageSize\n\t\t}\n\t\tqPageSize := swag.FormatInt64(qrPageSize)\n\t\tif qPageSize != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page_size\", qPageSize); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param project_name\n\tif err := r.SetPathParam(\"project_name\", o.ProjectName); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ListSourceFileOfProjectVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param parentId\n\tif err := r.SetPathParam(\"parentId\", swag.FormatInt64(o.ParentID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Q != nil {\n\n\t\t// query param q\n\t\tvar qrQ string\n\t\tif o.Q != nil {\n\t\t\tqrQ = *o.Q\n\t\t}\n\t\tqQ := qrQ\n\t\tif qQ != \"\" {\n\t\t\tif err := r.SetQueryParam(\"q\", qQ); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetDrgParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param drgId\n\tif err := r.SetPathParam(\"drgId\", o.DrgID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdateFlowParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param bucketId\n\tif err := r.SetPathParam(\"bucketId\", o.BucketID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param flowId\n\tif err := r.SetPathParam(\"flowId\", o.FlowID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CreateWidgetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Accept != nil {\n\n\t\t// header param Accept\n\t\tif err := r.SetHeaderParam(\"Accept\", *o.Accept); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.ContentType != nil {\n\n\t\t// header param Content-Type\n\t\tif err := r.SetHeaderParam(\"Content-Type\", *o.ContentType); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif err := r.SetBodyParam(o.WidgetBody); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetBodyResourceByDatePeriodParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param date\n\tif err := r.SetPathParam(\"date\", o.Date.String()); err != nil {\n\t\treturn err\n\t}\n\n\t// path param period\n\tif err := r.SetPathParam(\"period\", o.Period); err != nil {\n\t\treturn err\n\t}\n\n\t// path param resource-path\n\tif err := r.SetPathParam(\"resource-path\", o.ResourcePath); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetAboutUserParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tvaluesSelect := o.Select\n\n\tjoinedSelect := swag.JoinByFormat(valuesSelect, \"csv\")\n\t// query array param select\n\tif err := r.SetQueryParam(\"select\", joinedSelect...); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ExtractionListV1Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param id\n\tqrID := o.ID\n\tqID := qrID\n\tif qID != \"\" {\n\n\t\tif err := r.SetQueryParam(\"id\", qID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset string\n\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := qrOffset\n\t\tif qOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetAuditEventsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int32\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt32(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param resourceCrn\n\tqrResourceCrn := o.ResourceCrn\n\tqResourceCrn := qrResourceCrn\n\tif qResourceCrn != \"\" {\n\t\tif err := r.SetQueryParam(\"resourceCrn\", qResourceCrn); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Size != nil {\n\n\t\t// query param size\n\t\tvar qrSize int32\n\t\tif o.Size != nil {\n\t\t\tqrSize = *o.Size\n\t\t}\n\t\tqSize := swag.FormatInt32(qrSize)\n\t\tif qSize != \"\" {\n\t\t\tif err := r.SetQueryParam(\"size\", qSize); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PcloudSystempoolsGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param cloud_instance_id\n\tif err := r.SetPathParam(\"cloud_instance_id\", o.CloudInstanceID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *WaitListParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param address\n\tif err := r.SetPathParam(\"address\", o.Address); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Height != nil {\n\n\t\t// query param height\n\t\tvar qrHeight uint64\n\n\t\tif o.Height != nil {\n\t\t\tqrHeight = *o.Height\n\t\t}\n\t\tqHeight := swag.FormatUint64(qrHeight)\n\t\tif qHeight != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"height\", qHeight); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.PublicKey != nil {\n\n\t\t// query param public_key\n\t\tvar qrPublicKey string\n\n\t\tif o.PublicKey != nil {\n\t\t\tqrPublicKey = *o.PublicKey\n\t\t}\n\t\tqPublicKey := qrPublicKey\n\t\tif qPublicKey != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"public_key\", qPublicKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *BudgetAddParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetGCParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param gc_id\n\tif err := r.SetPathParam(\"gc_id\", swag.FormatInt64(o.GcID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PartialUpdateAppParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tr.SetTimeout(o.timeout)\n\tvar res []error\n\n\t// path param app_id\n\tif err := r.SetPathParam(\"app_id\", swag.FormatInt64(o.AppID)); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\treturn err\n\t}\n\n\t// path param team_id\n\tif err := r.SetPathParam(\"team_id\", swag.FormatInt64(o.TeamID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *StartPacketCaptureParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *TaskSchemasIDGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param identifier\n\tif err := r.SetPathParam(\"identifier\", o.Identifier); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ResolveRef != nil {\n\n\t\t// query param resolveRef\n\t\tvar qrResolveRef bool\n\t\tif o.ResolveRef != nil {\n\t\t\tqrResolveRef = *o.ResolveRef\n\t\t}\n\t\tqResolveRef := swag.FormatBool(qrResolveRef)\n\t\tif qResolveRef != \"\" {\n\t\t\tif err := r.SetQueryParam(\"resolveRef\", qResolveRef); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UploadTaskFileParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Description != nil {\n\n\t\t// form param description\n\t\tvar frDescription string\n\t\tif o.Description != nil {\n\t\t\tfrDescription = *o.Description\n\t\t}\n\t\tfDescription := frDescription\n\t\tif fDescription != \"\" {\n\t\t\tif err := r.SetFormParam(\"description\", fDescription); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.File != nil {\n\n\t\tif o.File != nil {\n\t\t\t// form file param file\n\t\t\tif err := r.SetFileParam(\"file\", o.File); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PetCreateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *QueryChangesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetInstrumentsInstrumentOrderBookParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AcceptDatetimeFormat != nil {\n\n\t\t// header param Accept-Datetime-Format\n\t\tif err := r.SetHeaderParam(\"Accept-Datetime-Format\", *o.AcceptDatetimeFormat); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param instrument\n\tif err := r.SetPathParam(\"instrument\", o.Instrument); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Time != nil {\n\n\t\t// query param time\n\t\tvar qrTime string\n\t\tif o.Time != nil {\n\t\t\tqrTime = *o.Time\n\t\t}\n\t\tqTime := qrTime\n\t\tif qTime != \"\" {\n\t\t\tif err := r.SetQueryParam(\"time\", qTime); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetScopeConfigurationParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param scope_id\n\tif err := r.SetPathParam(\"scope_id\", o.ScopeID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param site_id\n\tif err := r.SetPathParam(\"site_id\", o.SiteID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param stack_id\n\tif err := r.SetPathParam(\"stack_id\", o.StackID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdateEventParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param eventId\n\tif err := r.SetPathParam(\"eventId\", o.EventID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param koronaAccountId\n\tif err := r.SetPathParam(\"koronaAccountId\", o.KoronaAccountID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetV1FunctionalitiesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Impacted != nil {\n\n\t\t// query param impacted\n\t\tvar qrImpacted string\n\n\t\tif o.Impacted != nil {\n\t\t\tqrImpacted = *o.Impacted\n\t\t}\n\t\tqImpacted := qrImpacted\n\t\tif qImpacted != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"impacted\", qImpacted); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Labels != nil {\n\n\t\t// query param labels\n\t\tvar qrLabels string\n\n\t\tif o.Labels != nil {\n\t\t\tqrLabels = *o.Labels\n\t\t}\n\t\tqLabels := qrLabels\n\t\tif qLabels != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"labels\", qLabels); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Lite != nil {\n\n\t\t// query param lite\n\t\tvar qrLite bool\n\n\t\tif o.Lite != nil {\n\t\t\tqrLite = *o.Lite\n\t\t}\n\t\tqLite := swag.FormatBool(qrLite)\n\t\tif qLite != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"lite\", qLite); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Name != nil {\n\n\t\t// query param name\n\t\tvar qrName string\n\n\t\tif o.Name != nil {\n\t\t\tqrName = *o.Name\n\t\t}\n\t\tqName := qrName\n\t\tif qName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"name\", qName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Owner != nil {\n\n\t\t// query param owner\n\t\tvar qrOwner string\n\n\t\tif o.Owner != nil {\n\t\t\tqrOwner = *o.Owner\n\t\t}\n\t\tqOwner := qrOwner\n\t\tif qOwner != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"owner\", qOwner); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int32\n\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt32(qrPage)\n\t\tif qPage != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.PerPage != nil {\n\n\t\t// query param per_page\n\t\tvar qrPerPage int32\n\n\t\tif o.PerPage != nil {\n\t\t\tqrPerPage = *o.PerPage\n\t\t}\n\t\tqPerPage := swag.FormatInt32(qrPerPage)\n\t\tif qPerPage != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"per_page\", qPerPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Query != nil {\n\n\t\t// query param query\n\t\tvar qrQuery string\n\n\t\tif o.Query != nil {\n\t\t\tqrQuery = *o.Query\n\t\t}\n\t\tqQuery := qrQuery\n\t\tif qQuery != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"query\", qQuery); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ContainerUpdateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetBodyParam(o.Update); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetPointsByQueryParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.DollarSkip != nil {\n\n\t\t// query param $skip\n\t\tvar qrNrDollarSkip int32\n\t\tif o.DollarSkip != nil {\n\t\t\tqrNrDollarSkip = *o.DollarSkip\n\t\t}\n\t\tqNrDollarSkip := swag.FormatInt32(qrNrDollarSkip)\n\t\tif qNrDollarSkip != \"\" {\n\t\t\tif err := r.SetQueryParam(\"$skip\", qNrDollarSkip); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.DollarTop != nil {\n\n\t\t// query param $top\n\t\tvar qrNrDollarTop int32\n\t\tif o.DollarTop != nil {\n\t\t\tqrNrDollarTop = *o.DollarTop\n\t\t}\n\t\tqNrDollarTop := swag.FormatInt32(qrNrDollarTop)\n\t\tif qNrDollarTop != \"\" {\n\t\t\tif err := r.SetQueryParam(\"$top\", qNrDollarTop); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SyncStatusUsingGETParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param namespaceSelfLinkId\n\tif err := r.SetPathParam(\"namespaceSelfLinkId\", o.NamespaceSelfLinkID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param requestId\n\tif err := r.SetPathParam(\"requestId\", o.RequestID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ResolveBatchParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Account != nil {\n\n\t\t// query param account\n\t\tvar qrAccount string\n\t\tif o.Account != nil {\n\t\t\tqrAccount = *o.Account\n\t\t}\n\t\tqAccount := qrAccount\n\t\tif qAccount != \"\" {\n\t\t\tif err := r.SetQueryParam(\"account\", qAccount); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Environment != nil {\n\n\t\t// query param environment\n\t\tvar qrEnvironment string\n\t\tif o.Environment != nil {\n\t\t\tqrEnvironment = *o.Environment\n\t\t}\n\t\tqEnvironment := qrEnvironment\n\t\tif qEnvironment != \"\" {\n\t\t\tif err := r.SetQueryParam(\"environment\", qEnvironment); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.From != nil {\n\n\t\t// query param from\n\t\tvar qrFrom string\n\t\tif o.From != nil {\n\t\t\tqrFrom = *o.From\n\t\t}\n\t\tqFrom := qrFrom\n\t\tif qFrom != \"\" {\n\t\t\tif err := r.SetQueryParam(\"from\", qFrom); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Page != nil {\n\n\t\t// query param page\n\t\tvar qrPage int32\n\t\tif o.Page != nil {\n\t\t\tqrPage = *o.Page\n\t\t}\n\t\tqPage := swag.FormatInt32(qrPage)\n\t\tif qPage != \"\" {\n\t\t\tif err := r.SetQueryParam(\"page\", qPage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Region != nil {\n\n\t\t// query param region\n\t\tvar qrRegion string\n\t\tif o.Region != nil {\n\t\t\tqrRegion = *o.Region\n\t\t}\n\t\tqRegion := qrRegion\n\t\tif qRegion != \"\" {\n\t\t\tif err := r.SetQueryParam(\"region\", qRegion); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.To != nil {\n\n\t\t// query param to\n\t\tvar qrTo string\n\t\tif o.To != nil {\n\t\t\tqrTo = *o.To\n\t\t}\n\t\tqTo := qrTo\n\t\tif qTo != \"\" {\n\t\t\tif err := r.SetQueryParam(\"to\", qTo); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetAccountParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tr.SetTimeout(o.timeout)\n\tvar res []error\n\n\tif o.Authorization != nil {\n\n\t\t// header param Authorization\n\t\tif err := r.SetHeaderParam(\"Authorization\", *o.Authorization); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\tif o.Country != nil {\n\n\t\t// query param country\n\t\tvar qrCountry string\n\t\tif o.Country != nil {\n\t\t\tqrCountry = *o.Country\n\t\t}\n\t\tqCountry := qrCountry\n\t\tif qCountry != \"\" {\n\t\t\tif err := r.SetQueryParam(\"country\", qCountry); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Email != nil {\n\n\t\t// query param email\n\t\tvar qrEmail string\n\t\tif o.Email != nil {\n\t\t\tqrEmail = *o.Email\n\t\t}\n\t\tqEmail := qrEmail\n\t\tif qEmail != \"\" {\n\t\t\tif err := r.SetQueryParam(\"email\", qEmail); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tvaluesFields := o.Fields\n\n\tjoinedFields := swag.JoinByFormat(valuesFields, \"csv\")\n\t// query array param fields\n\tif err := r.SetQueryParam(\"fields\", joinedFields...); err != nil {\n\t\treturn err\n\t}\n\n\tif o.PersonID != nil {\n\n\t\t// query param person_id\n\t\tvar qrPersonID string\n\t\tif o.PersonID != nil {\n\t\t\tqrPersonID = *o.PersonID\n\t\t}\n\t\tqPersonID := qrPersonID\n\t\tif qPersonID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"person_id\", qPersonID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetDeviceHealthParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// header param Authorization\n\tif err := r.SetHeaderParam(\"Authorization\", o.Authorization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param deviceId\n\tif err := r.SetPathParam(\"deviceId\", o.DeviceID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdatePatientParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param ID\n\tif err := r.SetPathParam(\"ID\", o.ID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Patient != nil {\n\t\tif err := r.SetBodyParam(o.Patient); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *UpdateCustomIDPParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.CustomIDP != nil {\n\t\tif err := r.SetBodyParam(o.CustomIDP); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param aid\n\tif err := r.SetPathParam(\"aid\", o.Aid); err != nil {\n\t\treturn err\n\t}\n\n\t// path param iid\n\tif err := r.SetPathParam(\"iid\", o.Iid); err != nil {\n\t\treturn err\n\t}\n\n\t// path param tid\n\tif err := r.SetPathParam(\"tid\", o.Tid); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetSeriesIDFilterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AcceptLanguage != nil {\n\n\t\t// header param Accept-Language\n\t\tif err := r.SetHeaderParam(\"Accept-Language\", *o.AcceptLanguage); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t}\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\t// query param keys\n\tqrKeys := o.Keys\n\tqKeys := qrKeys\n\tif qKeys != \"\" {\n\t\tif err := r.SetQueryParam(\"keys\", qKeys); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CreateBlueprintInWorkspaceInternalParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.AccountID != nil {\n\n\t\t// query param accountId\n\t\tvar qrAccountID string\n\t\tif o.AccountID != nil {\n\t\t\tqrAccountID = *o.AccountID\n\t\t}\n\t\tqAccountID := qrAccountID\n\t\tif qAccountID != \"\" {\n\t\t\tif err := r.SetQueryParam(\"accountId\", qAccountID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param workspaceId\n\tif err := r.SetPathParam(\"workspaceId\", swag.FormatInt64(o.WorkspaceID)); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *OrgGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param org\n\tif err := r.SetPathParam(\"org\", o.Org); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *ExtrasGraphsReadParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param id\n\tif err := r.SetPathParam(\"id\", swag.FormatInt64(o.ID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Name != nil {\n\n\t\t// query param name\n\t\tvar qrName string\n\t\tif o.Name != nil {\n\t\t\tqrName = *o.Name\n\t\t}\n\t\tqName := qrName\n\t\tif qName != \"\" {\n\t\t\tif err := r.SetQueryParam(\"name\", qName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Type != nil {\n\n\t\t// query param type\n\t\tvar qrType string\n\t\tif o.Type != nil {\n\t\t\tqrType = *o.Type\n\t\t}\n\t\tqType := qrType\n\t\tif qType != \"\" {\n\t\t\tif err := r.SetQueryParam(\"type\", qType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetVersioningPolicyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Description != nil {\n\n\t\t// query param Description\n\t\tvar qrDescription string\n\t\tif o.Description != nil {\n\t\t\tqrDescription = *o.Description\n\t\t}\n\t\tqDescription := qrDescription\n\t\tif qDescription != \"\" {\n\t\t\tif err := r.SetQueryParam(\"Description\", qDescription); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.IgnoreFilesGreaterThan != nil {\n\n\t\t// query param IgnoreFilesGreaterThan\n\t\tvar qrIgnoreFilesGreaterThan string\n\t\tif o.IgnoreFilesGreaterThan != nil {\n\t\t\tqrIgnoreFilesGreaterThan = *o.IgnoreFilesGreaterThan\n\t\t}\n\t\tqIgnoreFilesGreaterThan := qrIgnoreFilesGreaterThan\n\t\tif qIgnoreFilesGreaterThan != \"\" {\n\t\t\tif err := r.SetQueryParam(\"IgnoreFilesGreaterThan\", qIgnoreFilesGreaterThan); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.MaxSizePerFile != nil {\n\n\t\t// query param MaxSizePerFile\n\t\tvar qrMaxSizePerFile string\n\t\tif o.MaxSizePerFile != nil {\n\t\t\tqrMaxSizePerFile = *o.MaxSizePerFile\n\t\t}\n\t\tqMaxSizePerFile := qrMaxSizePerFile\n\t\tif qMaxSizePerFile != \"\" {\n\t\t\tif err := r.SetQueryParam(\"MaxSizePerFile\", qMaxSizePerFile); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.MaxTotalSize != nil {\n\n\t\t// query param MaxTotalSize\n\t\tvar qrMaxTotalSize string\n\t\tif o.MaxTotalSize != nil {\n\t\t\tqrMaxTotalSize = *o.MaxTotalSize\n\t\t}\n\t\tqMaxTotalSize := qrMaxTotalSize\n\t\tif qMaxTotalSize != \"\" {\n\t\t\tif err := r.SetQueryParam(\"MaxTotalSize\", qMaxTotalSize); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Name != nil {\n\n\t\t// query param Name\n\t\tvar qrName string\n\t\tif o.Name != nil {\n\t\t\tqrName = *o.Name\n\t\t}\n\t\tqName := qrName\n\t\tif qName != \"\" {\n\t\t\tif err := r.SetQueryParam(\"Name\", qName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param Uuid\n\tif err := r.SetPathParam(\"Uuid\", o.UUID); err != nil {\n\t\treturn err\n\t}\n\n\tif o.VersionsDataSourceBucket != nil {\n\n\t\t// query param VersionsDataSourceBucket\n\t\tvar qrVersionsDataSourceBucket string\n\t\tif o.VersionsDataSourceBucket != nil {\n\t\t\tqrVersionsDataSourceBucket = *o.VersionsDataSourceBucket\n\t\t}\n\t\tqVersionsDataSourceBucket := qrVersionsDataSourceBucket\n\t\tif qVersionsDataSourceBucket != \"\" {\n\t\t\tif err := r.SetQueryParam(\"VersionsDataSourceBucket\", qVersionsDataSourceBucket); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.VersionsDataSourceName != nil {\n\n\t\t// query param VersionsDataSourceName\n\t\tvar qrVersionsDataSourceName string\n\t\tif o.VersionsDataSourceName != nil {\n\t\t\tqrVersionsDataSourceName = *o.VersionsDataSourceName\n\t\t}\n\t\tqVersionsDataSourceName := qrVersionsDataSourceName\n\t\tif qVersionsDataSourceName != \"\" {\n\t\t\tif err := r.SetQueryParam(\"VersionsDataSourceName\", qVersionsDataSourceName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetBuildPropertiesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param buildId\n\tif err := r.SetPathParam(\"buildId\", swag.FormatInt32(o.BuildID)); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// path param project\n\tif err := r.SetPathParam(\"project\", o.Project); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *AdminGetBannedDevicesV4Params) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param namespace\n\tif err := r.SetPathParam(\"namespace\", o.Namespace); err != nil {\n\t\treturn err\n\t}\n\n\tif o.DeviceType != nil {\n\n\t\t// query param deviceType\n\t\tvar qrDeviceType string\n\t\tif o.DeviceType != nil {\n\t\t\tqrDeviceType = *o.DeviceType\n\t\t}\n\t\tqDeviceType := qrDeviceType\n\t\tif qDeviceType != \"\" {\n\t\t\tif err := r.SetQueryParam(\"deviceType\", qDeviceType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.EndDate != nil {\n\n\t\t// query param endDate\n\t\tvar qrEndDate string\n\t\tif o.EndDate != nil {\n\t\t\tqrEndDate = *o.EndDate\n\t\t}\n\t\tqEndDate := qrEndDate\n\t\tif qEndDate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"endDate\", qEndDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.StartDate != nil {\n\n\t\t// query param startDate\n\t\tvar qrStartDate string\n\t\tif o.StartDate != nil {\n\t\t\tqrStartDate = *o.StartDate\n\t\t}\n\t\tqStartDate := qrStartDate\n\t\tif qStartDate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"startDate\", qStartDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// setting the default header value\n\tif err := r.SetHeaderParam(\"User-Agent\", utils.UserAgentGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif err := r.SetHeaderParam(\"X-Amzn-Trace-Id\", utils.AmazonTraceIDGen()); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\n\treturn nil\n}", "func (o *BikePointGetAllParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *DecryptParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif err := r.SetBodyParam(o.Parameters); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *DeleteRequestsRequestNameParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// query param api-version\n\tqrAPIVersion := o.APIVersion\n\tqAPIVersion := qrAPIVersion\n\tif qAPIVersion != \"\" {\n\t\tif err := r.SetQueryParam(\"api-version\", qAPIVersion); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param organization\n\tif err := r.SetPathParam(\"organization\", o.Organization); err != nil {\n\t\treturn err\n\t}\n\n\t// query param requestName\n\tqrRequestName := o.RequestName\n\tqRequestName := qrRequestName\n\tif qRequestName != \"\" {\n\t\tif err := r.SetQueryParam(\"requestName\", qRequestName); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Synchronous != nil {\n\n\t\t// query param synchronous\n\t\tvar qrSynchronous bool\n\t\tif o.Synchronous != nil {\n\t\t\tqrSynchronous = *o.Synchronous\n\t\t}\n\t\tqSynchronous := swag.FormatBool(qrSynchronous)\n\t\tif qSynchronous != \"\" {\n\t\t\tif err := r.SetQueryParam(\"synchronous\", qSynchronous); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *SearchAbsoluteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Decorate != nil {\n\n\t\t// query param decorate\n\t\tvar qrDecorate bool\n\t\tif o.Decorate != nil {\n\t\t\tqrDecorate = *o.Decorate\n\t\t}\n\t\tqDecorate := swag.FormatBool(qrDecorate)\n\t\tif qDecorate != \"\" {\n\t\t\tif err := r.SetQueryParam(\"decorate\", qDecorate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// query param fields\n\t\tvar qrFields string\n\t\tif o.Fields != nil {\n\t\t\tqrFields = *o.Fields\n\t\t}\n\t\tqFields := qrFields\n\t\tif qFields != \"\" {\n\t\t\tif err := r.SetQueryParam(\"fields\", qFields); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Filter != nil {\n\n\t\t// query param filter\n\t\tvar qrFilter string\n\t\tif o.Filter != nil {\n\t\t\tqrFilter = *o.Filter\n\t\t}\n\t\tqFilter := qrFilter\n\t\tif qFilter != \"\" {\n\t\t\tif err := r.SetQueryParam(\"filter\", qFilter); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param from\n\tqrFrom := o.From\n\tqFrom := qrFrom\n\tif qFrom != \"\" {\n\t\tif err := r.SetQueryParam(\"from\", qFrom); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Limit != nil {\n\n\t\t// query param limit\n\t\tvar qrLimit int64\n\t\tif o.Limit != nil {\n\t\t\tqrLimit = *o.Limit\n\t\t}\n\t\tqLimit := swag.FormatInt64(qrLimit)\n\t\tif qLimit != \"\" {\n\t\t\tif err := r.SetQueryParam(\"limit\", qLimit); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\tif o.Offset != nil {\n\n\t\t// query param offset\n\t\tvar qrOffset int64\n\t\tif o.Offset != nil {\n\t\t\tqrOffset = *o.Offset\n\t\t}\n\t\tqOffset := swag.FormatInt64(qrOffset)\n\t\tif qOffset != \"\" {\n\t\t\tif err := r.SetQueryParam(\"offset\", qOffset); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param query\n\tqrQuery := o.Query\n\tqQuery := qrQuery\n\tif qQuery != \"\" {\n\t\tif err := r.SetQueryParam(\"query\", qQuery); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif o.Sort != nil {\n\n\t\t// query param sort\n\t\tvar qrSort string\n\t\tif o.Sort != nil {\n\t\t\tqrSort = *o.Sort\n\t\t}\n\t\tqSort := qrSort\n\t\tif qSort != \"\" {\n\t\t\tif err := r.SetQueryParam(\"sort\", qSort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t}\n\n\t// query param to\n\tqrTo := o.To\n\tqTo := qrTo\n\tif qTo != \"\" {\n\t\tif err := r.SetQueryParam(\"to\", qTo); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *GetCountersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.ClusterNodeID != nil {\n\n\t\t// query param clusterNodeId\n\t\tvar qrClusterNodeID string\n\n\t\tif o.ClusterNodeID != nil {\n\t\t\tqrClusterNodeID = *o.ClusterNodeID\n\t\t}\n\t\tqClusterNodeID := qrClusterNodeID\n\t\tif qClusterNodeID != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"clusterNodeId\", qClusterNodeID); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Nodewise != nil {\n\n\t\t// query param nodewise\n\t\tvar qrNodewise bool\n\n\t\tif o.Nodewise != nil {\n\t\t\tqrNodewise = *o.Nodewise\n\t\t}\n\t\tqNodewise := swag.FormatBool(qrNodewise)\n\t\tif qNodewise != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"nodewise\", qNodewise); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *MetroclusterInterconnectGetParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\t// path param adapter\n\tif err := r.SetPathParam(\"adapter\", o.Adapter); err != nil {\n\t\treturn err\n\t}\n\n\tif o.Fields != nil {\n\n\t\t// binding items for fields\n\t\tjoinedFields := o.bindParamFields(reg)\n\n\t\t// query array param fields\n\t\tif err := r.SetQueryParam(\"fields\", joinedFields...); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param node.uuid\n\tif err := r.SetPathParam(\"node.uuid\", o.NodeUUID); err != nil {\n\t\treturn err\n\t}\n\n\t// path param partner_type\n\tif err := r.SetPathParam(\"partner_type\", o.PartnerType); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *PutParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.Item != nil {\n\t\tif err := r.SetBodyParam(o.Item); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// path param itemId\n\tif err := r.SetPathParam(\"itemId\", o.ItemID); err != nil {\n\t\treturn err\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *CreateAccessPolicyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\tif o.Body != nil {\n\t\tif err := r.SetBodyParam(o.Body); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func (o *DeleteDataSourceParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {\n\n\tif err := r.SetTimeout(o.timeout); err != nil {\n\t\treturn err\n\t}\n\tvar res []error\n\n\tif o.APIKey != nil {\n\n\t\t// query param ApiKey\n\t\tvar qrAPIKey string\n\n\t\tif o.APIKey != nil {\n\t\t\tqrAPIKey = *o.APIKey\n\t\t}\n\t\tqAPIKey := qrAPIKey\n\t\tif qAPIKey != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ApiKey\", qAPIKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.APISecret != nil {\n\n\t\t// query param ApiSecret\n\t\tvar qrAPISecret string\n\n\t\tif o.APISecret != nil {\n\t\t\tqrAPISecret = *o.APISecret\n\t\t}\n\t\tqAPISecret := qrAPISecret\n\t\tif qAPISecret != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ApiSecret\", qAPISecret); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.CreationDate != nil {\n\n\t\t// query param CreationDate\n\t\tvar qrCreationDate int32\n\n\t\tif o.CreationDate != nil {\n\t\t\tqrCreationDate = *o.CreationDate\n\t\t}\n\t\tqCreationDate := swag.FormatInt32(qrCreationDate)\n\t\tif qCreationDate != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"CreationDate\", qCreationDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Disabled != nil {\n\n\t\t// query param Disabled\n\t\tvar qrDisabled bool\n\n\t\tif o.Disabled != nil {\n\t\t\tqrDisabled = *o.Disabled\n\t\t}\n\t\tqDisabled := swag.FormatBool(qrDisabled)\n\t\tif qDisabled != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"Disabled\", qDisabled); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.EncryptionKey != nil {\n\n\t\t// query param EncryptionKey\n\t\tvar qrEncryptionKey string\n\n\t\tif o.EncryptionKey != nil {\n\t\t\tqrEncryptionKey = *o.EncryptionKey\n\t\t}\n\t\tqEncryptionKey := qrEncryptionKey\n\t\tif qEncryptionKey != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"EncryptionKey\", qEncryptionKey); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.EncryptionMode != nil {\n\n\t\t// query param EncryptionMode\n\t\tvar qrEncryptionMode string\n\n\t\tif o.EncryptionMode != nil {\n\t\t\tqrEncryptionMode = *o.EncryptionMode\n\t\t}\n\t\tqEncryptionMode := qrEncryptionMode\n\t\tif qEncryptionMode != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"EncryptionMode\", qEncryptionMode); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.FlatStorage != nil {\n\n\t\t// query param FlatStorage\n\t\tvar qrFlatStorage bool\n\n\t\tif o.FlatStorage != nil {\n\t\t\tqrFlatStorage = *o.FlatStorage\n\t\t}\n\t\tqFlatStorage := swag.FormatBool(qrFlatStorage)\n\t\tif qFlatStorage != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"FlatStorage\", qFlatStorage); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.LastSynchronizationDate != nil {\n\n\t\t// query param LastSynchronizationDate\n\t\tvar qrLastSynchronizationDate int32\n\n\t\tif o.LastSynchronizationDate != nil {\n\t\t\tqrLastSynchronizationDate = *o.LastSynchronizationDate\n\t\t}\n\t\tqLastSynchronizationDate := swag.FormatInt32(qrLastSynchronizationDate)\n\t\tif qLastSynchronizationDate != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"LastSynchronizationDate\", qLastSynchronizationDate); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\t// path param Name\n\tif err := r.SetPathParam(\"Name\", o.Name); err != nil {\n\t\treturn err\n\t}\n\n\tif o.ObjectsBaseFolder != nil {\n\n\t\t// query param ObjectsBaseFolder\n\t\tvar qrObjectsBaseFolder string\n\n\t\tif o.ObjectsBaseFolder != nil {\n\t\t\tqrObjectsBaseFolder = *o.ObjectsBaseFolder\n\t\t}\n\t\tqObjectsBaseFolder := qrObjectsBaseFolder\n\t\tif qObjectsBaseFolder != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsBaseFolder\", qObjectsBaseFolder); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsBucket != nil {\n\n\t\t// query param ObjectsBucket\n\t\tvar qrObjectsBucket string\n\n\t\tif o.ObjectsBucket != nil {\n\t\t\tqrObjectsBucket = *o.ObjectsBucket\n\t\t}\n\t\tqObjectsBucket := qrObjectsBucket\n\t\tif qObjectsBucket != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsBucket\", qObjectsBucket); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsHost != nil {\n\n\t\t// query param ObjectsHost\n\t\tvar qrObjectsHost string\n\n\t\tif o.ObjectsHost != nil {\n\t\t\tqrObjectsHost = *o.ObjectsHost\n\t\t}\n\t\tqObjectsHost := qrObjectsHost\n\t\tif qObjectsHost != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsHost\", qObjectsHost); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsPort != nil {\n\n\t\t// query param ObjectsPort\n\t\tvar qrObjectsPort int32\n\n\t\tif o.ObjectsPort != nil {\n\t\t\tqrObjectsPort = *o.ObjectsPort\n\t\t}\n\t\tqObjectsPort := swag.FormatInt32(qrObjectsPort)\n\t\tif qObjectsPort != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsPort\", qObjectsPort); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsSecure != nil {\n\n\t\t// query param ObjectsSecure\n\t\tvar qrObjectsSecure bool\n\n\t\tif o.ObjectsSecure != nil {\n\t\t\tqrObjectsSecure = *o.ObjectsSecure\n\t\t}\n\t\tqObjectsSecure := swag.FormatBool(qrObjectsSecure)\n\t\tif qObjectsSecure != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsSecure\", qObjectsSecure); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.ObjectsServiceName != nil {\n\n\t\t// query param ObjectsServiceName\n\t\tvar qrObjectsServiceName string\n\n\t\tif o.ObjectsServiceName != nil {\n\t\t\tqrObjectsServiceName = *o.ObjectsServiceName\n\t\t}\n\t\tqObjectsServiceName := qrObjectsServiceName\n\t\tif qObjectsServiceName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"ObjectsServiceName\", qObjectsServiceName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.PeerAddress != nil {\n\n\t\t// query param PeerAddress\n\t\tvar qrPeerAddress string\n\n\t\tif o.PeerAddress != nil {\n\t\t\tqrPeerAddress = *o.PeerAddress\n\t\t}\n\t\tqPeerAddress := qrPeerAddress\n\t\tif qPeerAddress != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"PeerAddress\", qPeerAddress); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.SkipSyncOnRestart != nil {\n\n\t\t// query param SkipSyncOnRestart\n\t\tvar qrSkipSyncOnRestart bool\n\n\t\tif o.SkipSyncOnRestart != nil {\n\t\t\tqrSkipSyncOnRestart = *o.SkipSyncOnRestart\n\t\t}\n\t\tqSkipSyncOnRestart := swag.FormatBool(qrSkipSyncOnRestart)\n\t\tif qSkipSyncOnRestart != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"SkipSyncOnRestart\", qSkipSyncOnRestart); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.StorageType != nil {\n\n\t\t// query param StorageType\n\t\tvar qrStorageType string\n\n\t\tif o.StorageType != nil {\n\t\t\tqrStorageType = *o.StorageType\n\t\t}\n\t\tqStorageType := qrStorageType\n\t\tif qStorageType != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"StorageType\", qStorageType); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.VersioningPolicyName != nil {\n\n\t\t// query param VersioningPolicyName\n\t\tvar qrVersioningPolicyName string\n\n\t\tif o.VersioningPolicyName != nil {\n\t\t\tqrVersioningPolicyName = *o.VersioningPolicyName\n\t\t}\n\t\tqVersioningPolicyName := qrVersioningPolicyName\n\t\tif qVersioningPolicyName != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"VersioningPolicyName\", qVersioningPolicyName); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif o.Watch != nil {\n\n\t\t// query param Watch\n\t\tvar qrWatch bool\n\n\t\tif o.Watch != nil {\n\t\t\tqrWatch = *o.Watch\n\t\t}\n\t\tqWatch := swag.FormatBool(qrWatch)\n\t\tif qWatch != \"\" {\n\n\t\t\tif err := r.SetQueryParam(\"Watch\", qWatch); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}" ]
[ "0.7198161", "0.714435", "0.70471495", "0.7021836", "0.69967365", "0.69959503", "0.6979433", "0.6979074", "0.69695425", "0.6966308", "0.69242847", "0.6908102", "0.69045216", "0.6871055", "0.68575305", "0.68564737", "0.6851862", "0.6845359", "0.6844677", "0.684266", "0.68300045", "0.68283993", "0.68213093", "0.68209827", "0.681858", "0.6810088", "0.67938024", "0.6792597", "0.6781293", "0.6778168", "0.67739195", "0.676121", "0.676101", "0.6760405", "0.675646", "0.67500865", "0.67439634", "0.6743771", "0.6742206", "0.67405975", "0.67344606", "0.67331755", "0.67328155", "0.67320985", "0.67255586", "0.6724229", "0.67159885", "0.67127234", "0.67094815", "0.67085487", "0.6705413", "0.67020816", "0.6698303", "0.66938454", "0.6692077", "0.66849154", "0.6677396", "0.66709644", "0.6670931", "0.6670394", "0.6666765", "0.6666114", "0.6665216", "0.6662671", "0.66568", "0.6653157", "0.6646967", "0.6645966", "0.6642767", "0.6640608", "0.6638263", "0.6634605", "0.66345316", "0.6625767", "0.66217625", "0.6619463", "0.66181296", "0.66144806", "0.6606646", "0.6605777", "0.66039085", "0.659942", "0.6598786", "0.65961313", "0.65951705", "0.6591678", "0.6586235", "0.65826946", "0.658246", "0.6574939", "0.6572858", "0.6569902", "0.6568091", "0.65670824", "0.65661305", "0.6565009", "0.6561903", "0.65615994", "0.6560924", "0.6557316" ]
0.67860335
28
ListMetricEquipAttr implements Licence ListMetricEquipAttr function
func (l *LicenseRepository) ListMetricEquipAttr(ctx context.Context, scopes ...string) ([]*v1.MetricEquipAttrStand, error) { respJSON, err := l.listMetricWithMetricType(ctx, v1.MetricEquipAttrStandard, scopes...) if err != nil { logger.Log.Error("dgraph/ListMetricEquipAttr - listMetricWithMetricType", zap.Error(err)) return nil, err } type Resp struct { Data []*metricEquipAttr } var data Resp if err := json.Unmarshal(respJSON, &data); err != nil { logger.Log.Error("dgraph/ListMetricEquipAttr - Unmarshal failed", zap.Error(err)) return nil, errors.New("cannot Unmarshal") } if len(data.Data) == 0 { return nil, v1.ErrNoData } return converMetricToModelMetricAllEquipAttr(data.Data) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func cmdAttributeList(c *cli.Context) error {\n\tif err := adm.VerifyNoArgument(c); err != nil {\n\t\treturn err\n\t}\n\n\treturn adm.Perform(`get`, `/attribute/`, `list`, nil, c)\n}", "func AttributeList(attr int32) (list map[string]int32) {\n\tlist = map[string]int32{}\n\tfor bit, name := range VideoAttribute {\n\t\tlist[name] = int32(((attr >> bit) & 1))\n\t}\n\treturn\n}", "func getAttrList(selection *goquery.Selection, attrName string) []string {\n\tres := selection.Map(func(ind int, s *goquery.Selection) string {\n\t\tattr, _ := s.Attr(attrName)\n\t\treturn attr\n\t})\n\treturn removeEmpty(res)\n}", "func (e *Environment) Attr(environmentName, attr string) ([]Attr, error) {\n\n\targkeys := []string{\"attr\"}\n\targvalues := []interface{}{attr}\n\tbaseCommand := fmt.Sprintf(\"list environment attr %s\", environmentName)\n\n\tc, err := cmd.ArgsExpander(baseCommand, argkeys, argvalues)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tb, err := cmd.RunCommand(c)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tattrs := []Attr{}\n\terr = json.Unmarshal(b, &attrs)\n\tif err != nil {\n\t\t// it may have been just an empty output from the Frontend\n\t\tnullOutput := NullOutput{}\n\t\terr = json.Unmarshal(b, &nullOutput)\n\t\tif err != nil {\n\t\t\t// if we still can't recognize the output, return an error\n\t\t\treturn nil, err\n\t\t}\n\t\treturn attrs, err\n\t}\n\treturn attrs, err\n}", "func (cr *CredentialRequest) AttributeList(\n\tconf *Configuration,\n\tmetadataVersion byte,\n\trevocationAttr *big.Int,\n\tissuedAt time.Time,\n) (*AttributeList, error) {\n\tif err := cr.Validate(conf); err != nil {\n\t\treturn nil, err\n\t}\n\n\tcredtype := conf.CredentialTypes[cr.CredentialTypeID]\n\tif !credtype.RevocationSupported() && revocationAttr != nil {\n\t\treturn nil, errors.Errorf(\"cannot specify revocationAttr: credtype %s does not support revocation\", cr.CredentialTypeID.String())\n\t}\n\n\t// Compute metadata attribute\n\tmeta := NewMetadataAttribute(metadataVersion)\n\tmeta.setKeyCounter(cr.KeyCounter)\n\tmeta.setCredentialTypeIdentifier(cr.CredentialTypeID.String())\n\tmeta.setSigningDate(issuedAt)\n\tif err := meta.setExpiryDate(cr.Validity); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Compute other attributes\n\tattrs := make([]*big.Int, len(credtype.AttributeTypes)+1)\n\tattrs[0] = meta.Int\n\tif credtype.RevocationSupported() {\n\t\tif revocationAttr != nil {\n\t\t\tattrs[credtype.RevocationIndex+1] = revocationAttr\n\t\t} else {\n\t\t\tattrs[credtype.RevocationIndex+1] = bigZero\n\t\t}\n\t}\n\tfor i, attrtype := range credtype.AttributeTypes {\n\t\tif attrtype.RevocationAttribute || attrtype.RandomBlind {\n\t\t\tcontinue\n\t\t}\n\t\tattrs[i+1] = new(big.Int)\n\t\tif str, present := cr.Attributes[attrtype.ID]; present {\n\t\t\t// Set attribute to str << 1 + 1\n\t\t\tattrs[i+1].SetBytes([]byte(str))\n\t\t\tif meta.Version() >= 0x03 {\n\t\t\t\tattrs[i+1].Lsh(attrs[i+1], 1) // attr <<= 1\n\t\t\t\tattrs[i+1].Add(attrs[i+1], big.NewInt(1)) // attr += 1\n\t\t\t}\n\t\t}\n\t}\n\n\tlist := NewAttributeListFromInts(attrs, conf)\n\tlist.RevocationSupported = cr.RevocationSupported\n\treturn list, nil\n}", "func addListAttribute(item map[string]*dynamodb.AttributeValue, key string, value []*dynamodb.AttributeValue) {\n\titem[key] = &dynamodb.AttributeValue{L: value}\n}", "func (f Features) attrExtreme() *spotify.TrackAttributes {\n\tok := func(val float32) bool {\n\t\treturn val <= 0.25 || val >= 0.75\n\t}\n\tx := spotify.NewTrackAttributes()\n\tif ok(f.Acousticness) {\n\t\tx.TargetAcousticness(float64(f.Acousticness))\n\t}\n\n\tif ok(f.Danceability) {\n\t\tx.TargetDanceability(float64(f.Danceability))\n\t}\n\tx.TargetDuration(f.Duration)\n\tif ok(f.Energy) {\n\t\tx.TargetEnergy(float64(f.Energy))\n\t}\n\tif ok(f.Instrumentalness) {\n\t\tx.TargetInstrumentalness(float64(f.Instrumentalness))\n\t}\n\tif ok(f.Liveness) {\n\t\tx.TargetLiveness(float64(f.Liveness))\n\t}\n\tif ok(f.Loudness) {\n\t\tx.TargetLoudness(float64(f.Loudness))\n\t}\n\tif ok(f.Speechiness) {\n\t\tx.TargetSpeechiness(float64(f.Speechiness))\n\t}\n\tif ok(f.Valence) {\n\t\tx.TargetValence(float64(f.Valence))\n\t}\n\treturn x\n}", "func Attr(attrs ...a.Attribute) []a.Attribute {\n return attrs\n}", "func (w *wrapper) Listxattr(path string, fill func(name string) bool) int {\n\treturn -fuse.ENOSYS\n}", "func (a adapter) Attrs(key string) []string {\n\treturn a.entry.GetAttributeValues(key)\n}", "func (n *UseList) Attributes() map[string]interface{} {\n\treturn nil\n}", "func (fsys *FS) Listxattr(path string, fill func(name string) bool) (errc int) {\n\treturn -fuse.ENOSYS\n}", "func (client OccMetricsClient) listMetricProperties(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) {\n\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/metricProperties/{namespaceName}\", binaryReqBody, extraHeaders)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListMetricPropertiesResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\tapiReferenceLink := \"https://docs.oracle.com/iaas/api/#/en/occ/20230515/MetricPropertyCollection/ListMetricProperties\"\n\t\terr = common.PostProcessServiceError(err, \"OccMetrics\", \"ListMetricProperties\", apiReferenceLink)\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func (m *prom) ListMetric() []string {\n\tvar res = make([]string, 0)\n\tres = append(res, m.ginMet.List()...)\n\tres = append(res, m.othMet.List()...)\n\treturn res\n}", "func (a *AzureInfoer) GetAttributeValues(attribute string) (productinfo.AttrValues, error) {\n\n\tlog.Debugf(\"getting %s values\", attribute)\n\n\tvalues := make(productinfo.AttrValues, 0)\n\tvalueSet := make(map[productinfo.AttrValue]interface{})\n\n\tregions, err := a.GetRegions()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor region := range regions {\n\t\tvmSizes, err := a.vmSizesClient.List(context.TODO(), region)\n\t\tif err != nil {\n\t\t\tlog.WithError(err).Warnf(\"[Azure] couldn't get VM sizes in region %s\", region)\n\t\t\tcontinue\n\t\t}\n\t\tfor _, v := range *vmSizes.Value {\n\t\t\tswitch attribute {\n\t\t\tcase productinfo.Cpu:\n\t\t\t\tvalueSet[productinfo.AttrValue{\n\t\t\t\t\tValue: float64(*v.NumberOfCores),\n\t\t\t\t\tStrValue: fmt.Sprintf(\"%v\", *v.NumberOfCores),\n\t\t\t\t}] = \"\"\n\t\t\tcase productinfo.Memory:\n\t\t\t\tvalueSet[productinfo.AttrValue{\n\t\t\t\t\tValue: float64(*v.MemoryInMB) / 1024,\n\t\t\t\t\tStrValue: fmt.Sprintf(\"%v\", *v.MemoryInMB),\n\t\t\t\t}] = \"\"\n\t\t\t}\n\t\t}\n\t}\n\n\tfor attr := range valueSet {\n\t\tvalues = append(values, attr)\n\t}\n\n\tlog.Debugf(\"found %s values: %v\", attribute, values)\n\treturn values, nil\n}", "func (f *File) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error {\n\tif !f.super.enableXattr {\n\t\treturn fuse.ENOSYS\n\t}\n\tino := f.info.Inode\n\t_ = req.Size // ignore currently\n\t_ = req.Position // ignore currently\n\n\tkeys, err := f.super.mw.XAttrsList_ll(ino)\n\tif err != nil {\n\t\tlog.LogErrorf(\"ListXattr: ino(%v) err(%v)\", ino, err)\n\t\treturn ParseError(err)\n\t}\n\tfor _, key := range keys {\n\t\tresp.Append(key)\n\t}\n\tlog.LogDebugf(\"TRACE Listxattr: ino(%v)\", ino)\n\treturn nil\n}", "func (f *ClientFD) ListXattr(ctx context.Context, size uint64) ([]string, error) {\n\treq := FListXattrReq{\n\t\tFD: f.fd,\n\t\tSize: size,\n\t}\n\n\tvar resp FListXattrResp\n\tctx.UninterruptibleSleepStart(false)\n\terr := f.client.SndRcvMessage(FListXattr, uint32(req.SizeBytes()), req.MarshalUnsafe, resp.UnmarshalBytes, nil)\n\tctx.UninterruptibleSleepFinish(false)\n\treturn resp.Xattrs, err\n}", "func (l *Loader) AttrOnList(i Sym) bool {\n\treturn l.attrOnList.Has(i)\n}", "func (s *Service) ListBusAttr(ctx context.Context) (busAttr []*model.BusinessAttr, err error) {\n\tbusAttr = make([]*model.BusinessAttr, 0)\n\tif err = s.dao.ORM.Table(\"workflow_business_attr\").Find(&busAttr).Error; err != nil {\n\t\treturn\n\t}\n\treturn\n}", "func GetLicenseMeterAttribute(name string, allowedUses *uint, totalUses *uint, grossUses *uint) int {\n\tcName := goToCString(name)\n\tvar cAllowedUses C.uint\n\tvar cTotalUses C.uint\n\tvar cGrossUses C.uint\n\tstatus := C.GetLicenseMeterAttribute(cName, &cAllowedUses, &cTotalUses, &cGrossUses)\n\t*allowedUses = uint(cAllowedUses)\n\t*totalUses = uint(cTotalUses)\n\t*grossUses = uint(cGrossUses)\n\tfreeCString(cName)\n\treturn int(status)\n}", "func newAttributeList(params *Params, nodeID []int, attrs wkdibe.AttributeList, depth int, delegable bool) wkdibe.AttributeList {\n\n\t// NOTE: Assume attributeIndex is int\n\tnewAttr := make(wkdibe.AttributeList)\n\tfor index := range attrs {\n\t\tnewAttr[wkdibe.AttributeIndex(*params.userHeight+int(index))] = attrs[index]\n\t}\n\n\tfor i := 0; i < depth; i++ {\n\t\tbuffer := make([]byte, 8)\n\t\tbinary.LittleEndian.PutUint64(buffer, uint64(nodeID[i]))\n\t\tnewAttr[wkdibe.AttributeIndex(i)] = cryptutils.HashToZp(buffer)\n\t}\n\n\tif !delegable {\n\t\tfor i := depth; i < *params.userHeight; i++ {\n\t\t\tnewAttr[wkdibe.AttributeIndex(i)] = nil\n\t\t}\n\t}\n\treturn newAttr\n}", "func (a *HyperflexApiService) GetHyperflexCapabilityInfoList(ctx context.Context) ApiGetHyperflexCapabilityInfoListRequest {\n\treturn ApiGetHyperflexCapabilityInfoListRequest{\n\t\tApiService: a,\n\t\tctx: ctx,\n\t}\n}", "func itemCategoryAttribute(item models.Item) []string {\n\tres := make([]string, 0, 5)\n\thasInfluence := false\n\n\tif item.Influences.Elder {\n\t\thasInfluence = true\n\t\tres = append(res, \"elder\")\n\t}\n\tif item.Influences.Shaper {\n\t\thasInfluence = true\n\t\tres = append(res, \"shaper\")\n\t}\n\tif item.Influences.Crusader {\n\t\thasInfluence = true\n\t\tres = append(res, \"crusader\")\n\t}\n\tif item.Influences.Hunter {\n\t\thasInfluence = true\n\t\tres = append(res, \"hunter\")\n\t}\n\tif item.Influences.Redeemer {\n\t\thasInfluence = true\n\t\tres = append(res, \"redeemer\")\n\t}\n\tif item.Influences.Warlord {\n\t\thasInfluence = true\n\t\tres = append(res, \"warlord\")\n\t}\n\tif hasInfluence {\n\t\tres = append(res, \"influences\", \"influence\")\n\t}\n\n\tif item.IsIdentified {\n\t\tres = append(res, \"identified\")\n\t} else {\n\t\tres = append(res, \"unidentified\")\n\t}\n\tif item.IsCorrupted {\n\t\tres = append(res, \"corrupted\", \"corrupt\")\n\t}\n\tif item.IsVeiled {\n\t\tres = append(res, \"veiled\", \"veil\")\n\t}\n\tif item.IsRelic {\n\t\tres = append(res, \"relic\")\n\t}\n\tif item.IsVerified {\n\t\tres = append(res, \"verified\")\n\t}\n\tif item.IsAbyssJewel {\n\t\tres = append(res, \"abyss\")\n\t}\n\tif len(item.ProphecyText) > 0 {\n\t\tres = append(res, \"prophecy\")\n\t}\n\tif item.Hybrid.IsVaalGem {\n\t\tres = append(res, \"vaalgem\", \"vaal\")\n\t}\n\tif len(item.ArtFilename) > 0 {\n\t\tres = append(res, \"divination\", \"divine\", \"divcard\", \"divinationcard\")\n\t}\n\n\treturn res\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tsyscall.Syscall9(gpGetActiveAttrib, 7, uintptr(program), uintptr(index), uintptr(bufSize), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(xtype)), uintptr(unsafe.Pointer(name)), 0, 0)\n}", "func (m *MyMetric) TagList() []*protocol.Tag {\n\treturn m.Tags\n}", "func prettyPrintStringListAttribute(stringList bazel.StringListAttribute, indent int) (string, error) {\n\tret, err := prettyPrint(reflect.ValueOf(stringList.Value), indent)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif !stringList.HasConfigurableValues() {\n\t\t// Select statement not needed.\n\t\treturn ret, nil\n\t}\n\n\t// Create the selects for arch specific values.\n\tselects := map[string]reflect.Value{}\n\tfor arch, selectKey := range bazel.PlatformArchMap {\n\t\tselects[selectKey] = reflect.ValueOf(stringList.GetValueForArch(arch))\n\t}\n\n\tselectMap, err := prettyPrintSelectMap(selects, \"[]\", indent)\n\treturn ret + selectMap, err\n}", "func (n *Node) Listxattr(ctx context.Context, dest []byte) (uint32, syscall.Errno) {\n\tcNames, errno := n.listXAttr()\n\tif errno != 0 {\n\t\treturn 0, errno\n\t}\n\trn := n.rootNode()\n\tvar buf bytes.Buffer\n\tfor _, curName := range cNames {\n\t\t// ACLs are passed through without encryption\n\t\tif isAcl(curName) {\n\t\t\tbuf.WriteString(curName + \"\\000\")\n\t\t\tcontinue\n\t\t}\n\t\tif !strings.HasPrefix(curName, xattrStorePrefix) {\n\t\t\tcontinue\n\t\t}\n\t\tname, err := rn.decryptXattrName(curName)\n\t\tif err != nil {\n\t\t\ttlog.Warn.Printf(\"ListXAttr: invalid xattr name %q: %v\", curName, err)\n\t\t\trn.reportMitigatedCorruption(curName)\n\t\t\tcontinue\n\t\t}\n\t\t// We *used to* encrypt ACLs, which caused a lot of problems.\n\t\tif isAcl(name) {\n\t\t\ttlog.Warn.Printf(\"ListXAttr: ignoring deprecated encrypted ACL %q = %q\", curName, name)\n\t\t\trn.reportMitigatedCorruption(curName)\n\t\t\tcontinue\n\t\t}\n\t\tbuf.WriteString(name + \"\\000\")\n\t}\n\t// Caller passes size zero to find out how large their buffer should be\n\tif len(dest) == 0 {\n\t\treturn uint32(buf.Len()), 0\n\t}\n\tif buf.Len() > len(dest) {\n\t\treturn minus1, syscall.ERANGE\n\t}\n\treturn uint32(copy(dest, buf.Bytes())), 0\n}", "func (*FileSystemBase) Listxattr(path string, fill func(name string) bool) int {\n\treturn -ENOSYS\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *int8) {\n C.glowGetActiveAttrib(gpGetActiveAttrib, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func GetActivationMeterAttributeUses(name string, uses *uint) int {\n\tcName := goToCString(name)\n\tvar cUses C.uint\n\tstatus := C.GetActivationMeterAttributeUses(cName, &cUses)\n\t*uses = uint(cUses)\n\tfreeCString(cName)\n\treturn int(status)\n}", "func (c *ServiceCurve) Attrs() (uint32, uint32, uint32) {\n\treturn c.m1, c.d, c.m2\n}", "func (graph *Graph) GetAttr(x, y int) byte {\n\treturn graph.Tiles[y][x].Attr\n}", "func (e *rawData) AddAttribute(key string, val string) {}", "func (f *File) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, resp *fuse.ListxattrResponse) error {\n\treturn syscall.ENOSYS // we never implement this\n}", "func (mouse *Mouse) GetAttr(attr string) (interface{}, error) {\n\treturn 0, nil\n}", "func parseAttrList(p *pstate, attrs map[string]string, comma bool) error {\n\tvar err error\n\n\t// Attribute lists are optional\n\tif err = p.PeekToken(); err != nil {\n\t\treturn err\n\t}\n\tif p.tok.Tok != grlex.LBRACKET {\n\t\treturn nil\n\t}\n\n\tif err = requiredToken(p, grlex.LBRACKET); err != nil {\n\t\treturn err\n\t}\n\n\t// What's next?\n\tif err = p.PeekToken(); err != nil {\n\t\treturn err\n\t}\n\tvar key, val string\n\tfor {\n\t\tif p.tok.Tok != grlex.IDENTIFIER {\n\t\t\ts := fmt.Sprintf(\"error parsing attr list: expected ID or bracket, got %v\", p.tok.Str)\n\t\t\treturn errors.New(s)\n\t\t}\n\t\tkey = p.tok.Str\n\n\t\t// Consume X=Y\n\t\tif err := requiredToken(p, grlex.IDENTIFIER); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := requiredToken(p, grlex.EQUAL); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := requiredTokenClass(p, attrValClass); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tval = p.tok.Str\n\t\tif attrs != nil {\n\t\t\tattrs[key] = val\n\t\t}\n\n\t\t// Take a peek at the next token\n\t\tif err = p.PeekToken(); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// End of attrs?\n\t\tif p.tok.Tok == grlex.RBRACKET {\n\t\t\tbreak\n\t\t}\n\n\t\tif comma {\n\t\t\t// Expect comma between attributes\n\t\t\tif p.tok.Tok == grlex.COMMA {\n\t\t\t\tif err = requiredToken(p, grlex.COMMA); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif err = p.PeekToken(); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif err := requiredToken(p, grlex.RBRACKET); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (m *Smart) getAttributes(acc telegraf.Accumulator, devices []string) {\n\tvar wg sync.WaitGroup\n\twg.Add(len(devices))\n\n\tfor _, device := range devices {\n\t\tgo gatherDisk(acc, m.UseSudo, m.Attributes, m.Path, m.Nocheck, device, &wg)\n\t}\n\n\twg.Wait()\n}", "func (attestedClaim *AttestedClaim) getAttributes() ([]*Attribute, error) {\n\tbInts := attestedClaim.getRawAttributes()\n\tattributes, err := BigIntsToAttributes(bInts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsorted := sort.SliceIsSorted(attributes, func(p, q int) bool {\n\t\treturn strings.Compare(attributes[p].Name, attributes[q].Name) < 0\n\t})\n\tif !sorted {\n\t\treturn nil, errors.New(\"expected attributes inside credential to be sorted\")\n\t}\n\treturn attributes, nil\n}", "func attrMultiKeyer(attr string) InstanceMultiKeyer {\n\treturn func(instance interface{}) ([]state.Key, error) {\n\t\tinst := reflect.Indirect(reflect.ValueOf(instance))\n\n\t\tv := inst.FieldByName(attr)\n\t\tif !v.IsValid() {\n\t\t\treturn nil, fmt.Errorf(`%s: %s`, ErrFieldNotExists, attr)\n\t\t}\n\n\t\treturn keysFromValue(v)\n\t}\n}", "func (p *OnuIgmpProfile) ListEssentialParams() map[string]interface{} {\r\n\tvar EssentialOnuIgmpProfile = map[string]interface{}{\r\n\t\tOnuIgmpProfileHeaders[0]: p.GetName(),\r\n\t\tOnuIgmpProfileHeaders[1]: p.GetMode(),\r\n\t\tOnuIgmpProfileHeaders[2]: p.GetProxy(),\r\n\t\tOnuIgmpProfileHeaders[3]: p.GetFastLeave(),\r\n\t\tOnuIgmpProfileHeaders[4]: p.GetUsTci(),\r\n\t\tOnuIgmpProfileHeaders[5]: p.DsGemPort,\r\n\t}\r\n\t// I want all of these Bools to return strings of \"Enabled/Disabled\"\r\n\treturn EssentialOnuIgmpProfile\r\n}", "func (c *IloClient) GetSysAttrDell() (SysAttributesData, error) {\n\n\turl := c.Hostname + \"/redfish/v1/Managers/System.Embedded.1/Attributes\"\n\n\tresp, _, _, err := queryData(c, \"GET\", url, nil)\n\tif err != nil {\n\t\treturn SysAttributesData{}, err\n\t}\n\n\tvar x SysAttrDell\n\n\tjson.Unmarshal(resp, &x)\n\n\treturn x.Attributes, nil\n\n}", "func mesosAttribute2commonAttribute(oldAttributeList []*mesos.Attribute) []*commtype.BcsAgentAttribute {\n\tif oldAttributeList == nil {\n\t\treturn nil\n\t}\n\n\tattributeList := make([]*commtype.BcsAgentAttribute, 0)\n\n\tfor _, oldAttribute := range oldAttributeList {\n\t\tif oldAttribute == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tattribute := new(commtype.BcsAgentAttribute)\n\t\tif oldAttribute.Name != nil {\n\t\t\tattribute.Name = *oldAttribute.Name\n\t\t}\n\t\tif oldAttribute.Type != nil {\n\t\t\tswitch *oldAttribute.Type {\n\t\t\tcase mesos.Value_SCALAR:\n\t\t\t\tattribute.Type = commtype.MesosValueType_Scalar\n\t\t\t\tif oldAttribute.Scalar != nil && oldAttribute.Scalar.Value != nil {\n\t\t\t\t\tattribute.Scalar = &commtype.MesosValue_Scalar{\n\t\t\t\t\t\tValue: *oldAttribute.Scalar.Value,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase mesos.Value_RANGES:\n\t\t\t\tattribute.Type = commtype.MesosValueType_Ranges\n\t\t\t\tif oldAttribute.Ranges != nil {\n\t\t\t\t\trangeList := make([]*commtype.MesosValue_Ranges, 0)\n\t\t\t\t\tfor _, oldRange := range oldAttribute.Ranges.Range {\n\t\t\t\t\t\tnewRange := &commtype.MesosValue_Ranges{}\n\t\t\t\t\t\tif oldRange.Begin != nil {\n\t\t\t\t\t\t\tnewRange.Begin = *oldRange.Begin\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif oldRange.End != nil {\n\t\t\t\t\t\t\tnewRange.End = *oldRange.End\n\t\t\t\t\t\t}\n\t\t\t\t\t\trangeList = append(rangeList, newRange)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase mesos.Value_SET:\n\t\t\t\tattribute.Type = commtype.MesosValueType_Set\n\t\t\t\tif oldAttribute.Set != nil {\n\t\t\t\t\tattribute.Set = &commtype.MesosValue_Set{\n\t\t\t\t\t\tItem: oldAttribute.Set.Item,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase mesos.Value_TEXT:\n\t\t\t\tattribute.Type = commtype.MesosValueType_Text\n\t\t\t\tif oldAttribute.Text != nil && oldAttribute.Text.Value != nil {\n\t\t\t\t\tattribute.Text = &commtype.MesosValue_Text{\n\t\t\t\t\t\tValue: *oldAttribute.Text.Value,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tattributeList = append(attributeList, attribute)\n\t}\n\treturn attributeList\n}", "func (dir HgmDir) Attr(ctx context.Context, a *fuse.Attr) error {\n\tresp, err := httpClient.Get(dir.getStatEndpoint(dir.localDir, false))\n\tif err != nil {\n\t\treturn fuse.EIO\n\t}\n\n\tfuseErr := stattool.HttpStatusToFuseErr(resp.StatusCode)\n\tif fuseErr == nil {\n\t\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\t\tif err == nil {\n\t\t\tattr := stattool.HgmStatAttr{}\n\t\t\terr = json.Unmarshal(bodyBytes, &attr)\n\t\t\tif err == nil {\n\t\t\t\tstattool.AttrFromHgmStat(attr, a)\n\t\t\t}\n\t\t}\n\t\tif err != nil {\n\t\t\tfuseErr = fuse.EIO\n\t\t}\n\t}\n\n\treturn fuseErr\n}", "func (o *ObjectData) GetAttr(name string) (value Object, present bool) {\n value, present = o.Attrs[name]\n return \n}", "func (client OccMetricsClient) ListMetricProperties(ctx context.Context, request ListMetricPropertiesRequest) (response ListMetricPropertiesResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.DefaultRetryPolicy()\n\tif client.RetryPolicy() != nil {\n\t\tpolicy = *client.RetryPolicy()\n\t}\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listMetricProperties, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListMetricPropertiesResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListMetricPropertiesResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListMetricPropertiesResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListMetricPropertiesResponse\")\n\t}\n\treturn\n}", "func getAttribute(name string,attrs []xml.Attr) (string) {\n\tval := \"\"\n\tfor _,attr := range attrs { if strings.EqualFold(attr.Name.Local,name) {val = attr.Value } }\n\treturn val\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tC.glowGetActiveAttrib(gpGetActiveAttrib, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func GetActiveAttrib(program uint32, index uint32, bufSize int32, length *int32, size *int32, xtype *uint32, name *uint8) {\n\tC.glowGetActiveAttrib(gpGetActiveAttrib, (C.GLuint)(program), (C.GLuint)(index), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLint)(unsafe.Pointer(size)), (*C.GLenum)(unsafe.Pointer(xtype)), (*C.GLchar)(unsafe.Pointer(name)))\n}", "func (a *metricAttributesProcessor) processMetricAttributes(ctx context.Context, m pmetric.Metric) {\n\n\t// This is a lot of repeated code, but since there is no single parent superclass\n\t// between metric data types, we can't use polymorphism.\n\tswitch m.Type() {\n\tcase pmetric.MetricTypeGauge:\n\t\tdps := m.Gauge().DataPoints()\n\t\tfor i := 0; i < dps.Len(); i++ {\n\t\t\ta.attrProc.Process(ctx, a.logger, dps.At(i).Attributes())\n\t\t}\n\tcase pmetric.MetricTypeSum:\n\t\tdps := m.Sum().DataPoints()\n\t\tfor i := 0; i < dps.Len(); i++ {\n\t\t\ta.attrProc.Process(ctx, a.logger, dps.At(i).Attributes())\n\t\t}\n\tcase pmetric.MetricTypeHistogram:\n\t\tdps := m.Histogram().DataPoints()\n\t\tfor i := 0; i < dps.Len(); i++ {\n\t\t\ta.attrProc.Process(ctx, a.logger, dps.At(i).Attributes())\n\t\t}\n\tcase pmetric.MetricTypeExponentialHistogram:\n\t\tdps := m.ExponentialHistogram().DataPoints()\n\t\tfor i := 0; i < dps.Len(); i++ {\n\t\t\ta.attrProc.Process(ctx, a.logger, dps.At(i).Attributes())\n\t\t}\n\tcase pmetric.MetricTypeSummary:\n\t\tdps := m.Summary().DataPoints()\n\t\tfor i := 0; i < dps.Len(); i++ {\n\t\t\ta.attrProc.Process(ctx, a.logger, dps.At(i).Attributes())\n\t\t}\n\t}\n}", "func (o GoogleCloudRetailV2alphaLocalInventoryResponseOutput) Attributes() pulumi.StringMapOutput {\n\treturn o.ApplyT(func(v GoogleCloudRetailV2alphaLocalInventoryResponse) map[string]string { return v.Attributes }).(pulumi.StringMapOutput)\n}", "func (v *invalSet) attr(n fs.Node) {\n\tv.entries = append(v.entries, inval{Node: n})\n}", "func (*ImageVulnerability) AttributeSpecifications() map[string]elemental.AttributeSpecification {\n\n\treturn ImageVulnerabilityAttributesMap\n}", "func (m *IdentityUserFlowAttributeAssignment) GetUserAttributeValues()([]UserAttributeValuesItemable) {\n return m.userAttributeValues\n}", "func (client RecommendedElasticPoolsClient) ListMetrics(resourceGroupName string, serverName string, recommendedElasticPoolName string) (result RecommendedElasticPoolListMetricsResult, err error) {\n\treq, err := client.ListMetricsPreparer(resourceGroupName, serverName, recommendedElasticPoolName)\n\tif err != nil {\n\t\treturn result, autorest.NewErrorWithError(err, \"sql.RecommendedElasticPoolsClient\", \"ListMetrics\", nil, \"Failure preparing request\")\n\t}\n\n\tresp, err := client.ListMetricsSender(req)\n\tif err != nil {\n\t\tresult.Response = autorest.Response{Response: resp}\n\t\treturn result, autorest.NewErrorWithError(err, \"sql.RecommendedElasticPoolsClient\", \"ListMetrics\", resp, \"Failure sending request\")\n\t}\n\n\tresult, err = client.ListMetricsResponder(resp)\n\tif err != nil {\n\t\terr = autorest.NewErrorWithError(err, \"sql.RecommendedElasticPoolsClient\", \"ListMetrics\", resp, \"Failure responding to request\")\n\t}\n\n\treturn\n}", "func (df *DataFrame) Attr(name string) (starlark.Value, error) {\n\tswitch name {\n\tcase \"columns\":\n\t\treturn df.columns, nil\n\t}\n\treturn builtinAttr(df, name, dataframeMethods)\n}", "func (*MetricsQuery) AttributeSpecifications() map[string]elemental.AttributeSpecification {\n\n\treturn MetricsQueryAttributesMap\n}", "func attrModifier(attribute int) int {\n\treturn (attribute - 10) / 2\n}", "func (o *IscsiInterfaceGetIterResponseResult) AttributesList() IscsiInterfaceGetIterResponseResultAttributesList {\n\tvar r IscsiInterfaceGetIterResponseResultAttributesList\n\tif o.AttributesListPtr == nil {\n\t\treturn r\n\t}\n\tr = *o.AttributesListPtr\n\treturn r\n}", "func getAttr(selection *goquery.Selection, attrName string) (s string) {\n\ts, _ = selection.Attr(attrName)\n\treturn strings.TrimSpace(s)\n}", "func (c *IloClient) GetIDRACAttrDell() (IDRACAttributesData, error) {\n\n\turl := c.Hostname + \"/redfish/v1/Managers/iDRAC.Embedded.1/Attributes\"\n\n\tresp, _, _, err := queryData(c, \"GET\", url, nil)\n\tif err != nil {\n\t\treturn IDRACAttributesData{}, err\n\t}\n\n\tvar x IDRACAttrDell\n\n\tjson.Unmarshal(resp, &x)\n\n\treturn x.Attributes, nil\n\n}", "func (fs osFsEval) Llistxattr(path string) ([]string, error) {\n\treturn system.Llistxattr(path)\n}", "func (s *Scope) ExportAttr(attrName string, varName string) {\n\ts.AttrExports = append(s.AttrExports, &AttrExport{AttrName: attrName, VarName: varName})\n}", "func getPiAttribute(w http.ResponseWriter, r *http.Request) {\n\t// Get pi name and property/attribute from request\n\tvars := mux.Vars(r)\n\tpiname := vars[\"piname\"]\n\tpiproperty := vars[\"piattribute\"]\n\n\t// Get pi entry from data store\n\tc := appengine.NewContext(r)\n\tq := datastore.NewQuery(piListKind).Filter(\"name =\", piname)\n\tt := q.Run(c)\n\tvar pi Pi\n\t_, err := t.Next(&pi)\n\tif err == datastore.Done {\n\t\thttp.Error(w, \"404 Not found\", http.StatusNotFound)\n\t\treturn\n\t}\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Print attribute value in plain text\n\tw.Header().Set(\"Content-Type\", \"text/plain\")\n\tswitch piproperty {\n\tcase \"name\":\n\t\tfmt.Fprint(w, pi.Name)\n\tcase \"ip\":\n\t\tfmt.Fprint(w, pi.Ip)\n\tcase \"lastSeen\":\n\t\tfmt.Fprint(w, pi.LastSeen)\n\tcase \"pingCount\":\n\t\tfmt.Fprint(w, pi.PingCount)\n\tdefault:\n\t\thttp.Error(w, \"404 Not found\", http.StatusNotFound)\n\t}\n}", "func attr(node *html.Node, name string) string {\n\tfor _, attr := range node.Attr {\n\t\tif attr.Key == name {\n\t\t\treturn attr.Val\n\t\t}\n\t}\n\treturn \"\"\n}", "func (r *relation) Attribute() []metadata.Attribute {\n\treturn helper.Attribute(*r.tbl)\n}", "func (s *BasevhdlListener) EnterAttribute_specification(ctx *Attribute_specificationContext) {}", "func (i *Index) Attr(name string) (starlark.Value, error) {\n\tswitch name {\n\tcase \"name\":\n\t\treturn starlark.String(i.name), nil\n\tcase \"str\":\n\t\treturn &stringMethods{subject: i}, nil\n\t}\n\treturn nil, starlark.NoSuchAttrError(name)\n}", "func (*ListDataAttributesResponse) Descriptor() ([]byte, []int) {\n\treturn file_google_cloud_dataplex_v1_data_taxonomy_proto_rawDescGZIP(), []int{13}\n}", "func (a *Agent) identifyAttributes(img *world.Image) map[int]int {\n\tattrs := make(map[int]int)\n\n\tattrs[attrTypeColor] = img.Color\n\tattrs[attrTypeShape] = img.Shape\n\tattrs[attrTypeDistance] = util.Abs(img.XDist) + util.Abs(img.ZDist)\n\n\tif img.XDist == 0 && img.ZDist == 0 {\n\t\tattrs[attrTypeDirection] = directionOrigin\n\t} else if img.XDist > 0 && img.ZDist == 0 {\n\t\tattrs[attrTypeDirection] = directionXPos\n\t} else if img.XDist < 0 && img.ZDist == 0 {\n\t\tattrs[attrTypeDirection] = directionXNeg\n\t} else if img.XDist == 0 && img.ZDist > 0 {\n\t\tattrs[attrTypeDirection] = directionZPos\n\t} else if img.XDist == 0 && img.ZDist < 0 {\n\t\tattrs[attrTypeDirection] = directionZNeg\n\t} else if img.XDist > 0 && img.ZDist > 0 {\n\t\tattrs[attrTypeDirection] = directionXPosZPos\n\t} else if img.XDist > 0 && img.ZDist < 0 {\n\t\tattrs[attrTypeDirection] = directionXPosZNeg\n\t} else if img.XDist < 0 && img.ZDist > 0 {\n\t\tattrs[attrTypeDirection] = directionXNegZPos\n\t} else if img.XDist < 0 && img.ZDist < 0 {\n\t\tattrs[attrTypeDirection] = directionXNegZNeg\n\t}\n\n\treturn attrs\n}", "func DecodeAttributeList(line string) map[string]string {\n\treturn decodeParamsLine(line)\n}", "func (k2h *K2hash) GetAttrs(k string) ([]Attr, error) {\n\t// 1. retrieve an attribute using k2h_get_attrs\n\t// bool k2h_get_attrs(k2h_h handle, const unsigned char* pkey, size_t keylength, PK2HATTRPCK* ppattrspck, int* pattrspckcnt)\n\tcKey := C.CBytes([]byte(k))\n\tdefer C.free(unsafe.Pointer(cKey))\n\tvar attrpack C.PK2HATTRPCK\n\tvar attrpackCnt C.int\n\tok := C.k2h_get_attrs(\n\t\tk2h.handle,\n\t\t(*C.uchar)(cKey),\n\t\tC.size_t(len([]byte(k))+1), // plus one for a null termination\n\t\t&attrpack,\n\t\t&attrpackCnt,\n\t)\n\tdefer C.k2h_free_attrpack(attrpack, attrpackCnt) // free the memory for the keypack for myself(GC doesn't know the area)\n\n\tif ok == false {\n\t\tfmt.Println(\"C.k2h_get_attrs returns false\")\n\t\treturn []Attr{}, fmt.Errorf(\"C.k2h_get_attrs() = %v\", ok)\n\t} else if attrpackCnt == 0 {\n\t\tfmt.Printf(\"attrpackLen is zero\")\n\t\treturn []Attr{}, nil\n\t} else {\n\t\tfmt.Printf(\"attrpackLen is %v\\n\", attrpackCnt)\n\t}\n\t// 2. copy an attribute data to a slice\n\tvar CAttrs C.PK2HATTRPCK = attrpack\n\tcount := (int)(attrpackCnt)\n\tslice := (*[1 << 28]C.K2HATTRPCK)(unsafe.Pointer(CAttrs))[:count:count]\n\tfmt.Printf(\"slice size is %v\\n\", len(slice))\n\t//\n\tattrs := make([]Attr, count) // copy\n\tfor i, data := range slice {\n\t\t// copy the data with len-1 length, which exclude a null termination.\n\t\tattrkey := C.GoBytes(unsafe.Pointer(data.pkey), (C.int)(data.keylength-1))\n\t\tfmt.Printf(\"i %v data %T pkey %v length %v attrkey %v\\n\", i, data, data.pkey, data.keylength, string(attrkey))\n\t\tattrval := C.GoBytes(unsafe.Pointer(data.pval), (C.int)(data.vallength-1))\n\t\tfmt.Printf(\"i %v data %T pval %v length %v attrval %v\\n\", i, data, data.pval, data.vallength, string(attrval))\n\t\t// cast bytes to a string\n\t\tattrs[i].key = string(attrkey)\n\t\tattrs[i].val = string(attrval)\n\t}\n\treturn attrs, nil\n}", "func (t *largeFlatTable) Attrs(ctx context.Context) TableAttrs { return t.attrs }", "func ParseFieldAttrList(attrs string) (output FieldAttrList) {\n\tvalues := strings.Split(attrs, \",\")\n\tif len(values) == 0 {\n\t\treturn\n\t}\n\toutput = make([]FieldAttr, 0, len(values))\n\tfor i := 0; i < len(values); i++ {\n\t\tattr, ok := ParseFieldAttr(strings.TrimSpace(values[i]))\n\t\tif ok {\n\t\t\toutput = append(output, attr)\n\t\t}\n\t\t// FIXME: Handle errors\n\t}\n\treturn\n}", "func (ft *DTDFormatter) RenderAttlist(b DTD.IDTDBlock) string {\n\tattributes := \"\\n\"\n\n\textra := b.GetExtra()\n\n\tfor _, attr := range extra.Attributes {\n\t\tattributes += ft.RenderAttribute(attr)\n\t}\n\n\treturn join(\"<!ATTLIST \", b.GetName(), \" \", attributes, \">\")\n}", "func getMetrics() []Metric {\n\tms := make([]Metric, 0)\n\treturn append(ms, &SimpleEapMetric{})\n}", "func (ifi *Interface) idAttrs() []netlink.Attribute {\n\treturn []netlink.Attribute{\n\t\t{\n\t\t\tType: unix.NL80211_ATTR_IFINDEX,\n\t\t\tData: nlenc.Uint32Bytes(uint32(ifi.Index)),\n\t\t},\n\t\t{\n\t\t\tType: unix.NL80211_ATTR_MAC,\n\t\t\tData: ifi.HardwareAddr,\n\t\t},\n\t}\n}", "func (cmd *systemGetAttrCmd) Execute(_ []string) error {\n\treq := &control.SystemGetAttrReq{\n\t\tKeys: cmd.Args.Attrs.ParsedProps.ToSlice(),\n\t}\n\n\tresp, err := control.SystemGetAttr(context.Background(), cmd.ctlInvoker, req)\n\tif cmd.JSONOutputEnabled() {\n\t\treturn cmd.OutputJSON(resp, err)\n\t}\n\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"system get-attr failed\")\n\t}\n\n\tvar bld strings.Builder\n\tprettyPrintAttrs(&bld, resp.Attributes)\n\tcmd.Infof(\"%s\", bld.String())\n\n\treturn nil\n}", "func (*StatsQuery) AttributeSpecifications() map[string]elemental.AttributeSpecification {\n\n\treturn StatsQueryAttributesMap\n}", "func (o *Options) tagMetrics(rowTags []tag.Tag, addlTags []string) []string {\n\tfinalTags := make([]string, len(o.Tags), len(o.Tags)+len(rowTags)+len(addlTags))\n\tcopy(finalTags, o.Tags)\n\tfor key := range rowTags {\n\t\tfinalTags = append(finalTags,\n\t\t\trowTags[key].Key.Name()+\":\"+rowTags[key].Value)\n\t}\n\tfinalTags = append(finalTags, addlTags...)\n\treturn finalTags\n}", "func (w *Wurfl) wurflCapabilityEnumerate(items **C.char) KeyStoreList {\n\tif items == nil || *items == nil {\n\t\treturn nil\n\t}\n\n\tm := NewKeyStireList()\n\n\tfor ; ; items = nextCharStringArrayItem(items, 2) {\n\t\tif *items == nil {\n\t\t\tbreak\n\t\t}\n\n\t\tgname := w.getGoString(*items)\n\t\tgval := C.GoString(*nextCharStringArrayItem(items, 1))\n\n\t\tm.Push(unsafe.Pointer(*items), gname, gval)\n\t}\n\n\treturn m\n}", "func (DeviceAttribute) Values() []DeviceAttribute {\n\treturn []DeviceAttribute{\n\t\t\"ARN\",\n\t\t\"PLATFORM\",\n\t\t\"FORM_FACTOR\",\n\t\t\"MANUFACTURER\",\n\t\t\"REMOTE_ACCESS_ENABLED\",\n\t\t\"REMOTE_DEBUG_ENABLED\",\n\t\t\"APPIUM_VERSION\",\n\t\t\"INSTANCE_ARN\",\n\t\t\"INSTANCE_LABELS\",\n\t\t\"FLEET_TYPE\",\n\t\t\"OS_VERSION\",\n\t\t\"MODEL\",\n\t\t\"AVAILABILITY\",\n\t}\n}", "func (e *explainer) attr(nodeName, fieldName, attr string) {\n\te.entries = append(e.entries, explainEntry{\n\t\tlevel: e.level - 1,\n\t\tfield: fieldName,\n\t\tfieldVal: attr,\n\t})\n}", "func (a adapter) Attr(key string) string {\n\treturn a.entry.GetAttributeValue(key)\n}", "func (l *AttributeList) Len() int { return l.length }", "func (o IscsiInterfaceGetIterResponseResultAttributesList) String() string {\n\treturn ToString(reflect.ValueOf(o))\n}", "func getMetrics(_ string) []string {\n\tvar (\n\t\terr error\n\t\tsession *Session\n\t\tclient orchestrator.OrchestratorClient\n\t\tres *orchestrator.ListMetricsResponse\n\t)\n\n\tif session, err = ContinueSession(); err != nil {\n\t\tfmt.Printf(\"Error while retrieving the session. Please re-authenticate.\\n\")\n\t\treturn nil\n\t}\n\n\tclient = orchestrator.NewOrchestratorClient(session)\n\n\tif res, err = client.ListMetrics(context.Background(), &orchestrator.ListMetricsRequest{}); err != nil {\n\t\treturn []string{}\n\t}\n\n\tvar metrics []string\n\tfor _, v := range res.Metrics {\n\t\tmetrics = append(metrics, fmt.Sprintf(\"%s\\t%s: %s\", v.Id, v.Name, v.Description))\n\t}\n\n\treturn metrics\n}", "func (n *node) Attr(ctx context.Context, a *fuse.Attr) error {\n\tfi := n.te.Stat()\n\ta.Valid = 30 * 24 * time.Hour\n\ta.Inode = inodeOfEnt(n.te)\n\ta.Size = uint64(fi.Size())\n\ta.Blocks = a.Size / 512\n\ta.Mtime = fi.ModTime()\n\ta.Mode = fi.Mode()\n\ta.Uid = uint32(n.te.Uid)\n\ta.Gid = uint32(n.te.Gid)\n\tif debug {\n\t\tlog.Printf(\"attr of %s: %s\", n.te.Name, *a)\n\t}\n\treturn nil\n}", "func getMetrics(vector model.Vector, labelName model.LabelName, f func(v float64) bool) map[string]bool {\n\tmetrics := map[string]bool{}\n\n\tfor _, elem := range vector {\n\t\tlabel := string(elem.Metric[labelName])\n\t\tvalue := float64(elem.Value)\n\t\tmetrics[label] = f(value)\n\t}\n\n\treturn metrics\n}", "func getCapabilities(attributes bascule.Attributes) ([]string, string, error) {\n\tif attributes == nil {\n\t\treturn []string{}, UndeterminedCapabilities, ErrNilAttributes\n\t}\n\n\tval, ok := attributes.Get(CapabilityKey)\n\tif !ok {\n\t\treturn []string{}, UndeterminedCapabilities, fmt.Errorf(\"couldn't get capabilities using key %v\", CapabilityKey)\n\t}\n\n\tvals, err := cast.ToStringSliceE(val)\n\tif err != nil {\n\t\treturn []string{}, UndeterminedCapabilities, fmt.Errorf(\"capabilities \\\"%v\\\" not the expected string slice: %v\", val, err)\n\t}\n\n\tif len(vals) == 0 {\n\t\treturn []string{}, EmptyCapabilitiesList, ErrNoVals\n\t}\n\n\treturn vals, \"\", nil\n\n}", "func GetVertexAttribLdv(index uint32, pname uint32, params *float64) {\n C.glowGetVertexAttribLdv(gpGetVertexAttribLdv, (C.GLuint)(index), (C.GLenum)(pname), (*C.GLdouble)(unsafe.Pointer(params)))\n}", "func (o *VirtualizationVmwareVirtualMachineAllOf) GetCustomAttributes() []string {\n\tif o == nil {\n\t\tvar ret []string\n\t\treturn ret\n\t}\n\treturn o.CustomAttributes\n}", "func (r ApiGetHyperflexCapabilityInfoListRequest) Tags(tags string) ApiGetHyperflexCapabilityInfoListRequest {\n\tr.tags = &tags\n\treturn r\n}", "func lvCollect(ch chan<- prometheus.Metric, lvs []map[string]string, vgName string) {\n for _, lv := range lvs {\n lvSizeF, err := strconv.ParseFloat(strings.Trim(lv[\"lv_size\"], \"B\"), 64)\n if err != nil {\n log.Print(err)\n return\n }\n ch <- prometheus.MustNewConstMetric(lvSizeMetric, prometheus.GaugeValue, lvSizeF, lv[\"lv_name\"], lv[\"lv_uuid\"], vgName)\n }\n}", "func (s *BasevhdlListener) EnterAttribute_designator(ctx *Attribute_designatorContext) {}", "func (d *cudaDevice) GetAttributes() (map[string]interface{}, error) {\n\treturn nil, fmt.Errorf(\"GetAttributes is not supported for CUDA devices\")\n}", "func addAttributeToRequest(name, value string, attributes *[]api.Attribute) {\n\t*attributes = append(*attributes, api.Attribute{Name: name, Value: value, ECert: true})\n}", "func GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum) {\n\tvar length, si int32\n\tvar typ uint32\n\tname = strings.Repeat(\"\\x00\", 256)\n\tcname := gl.Str(name)\n\tgl.GetActiveAttrib(p.Value, uint32(index), int32(len(name)-1), &length, &si, &typ, cname)\n\tname = name[:strings.IndexRune(name, 0)]\n\treturn name, int(si), Enum(typ)\n}", "func prettyPrintLabelListAttribute(labels bazel.LabelListAttribute, indent int) (string, error) {\n\t// TODO(b/165114590): convert glob syntax\n\tret, err := prettyPrint(reflect.ValueOf(labels.Value.Includes), indent)\n\tif err != nil {\n\t\treturn ret, err\n\t}\n\n\tif !labels.HasConfigurableValues() {\n\t\t// Select statements not needed.\n\t\treturn ret, nil\n\t}\n\n\t// Create the selects for arch specific values.\n\tarchSelects := map[string]reflect.Value{}\n\tfor arch, selectKey := range bazel.PlatformArchMap {\n\t\tarchSelects[selectKey] = reflect.ValueOf(labels.GetValueForArch(arch).Includes)\n\t}\n\tselectMap, err := prettyPrintSelectMap(archSelects, \"[]\", indent)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tret += selectMap\n\n\t// Create the selects for target os specific values.\n\tosSelects := map[string]reflect.Value{}\n\tfor os, selectKey := range bazel.PlatformOsMap {\n\t\tosSelects[selectKey] = reflect.ValueOf(labels.GetValueForOS(os).Includes)\n\t}\n\tselectMap, err = prettyPrintSelectMap(osSelects, \"[]\", indent)\n\treturn ret + selectMap, err\n}", "func (s *hostAttributesCrdLister) List(selector labels.Selector) (ret []*v1beta1.HostAttributesCrd, err error) {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1beta1.HostAttributesCrd))\n\t})\n\treturn ret, err\n}", "func gpuCapacity(self *core_v1.ResourceList) *resource.Quantity {\n\tif val, ok := (*self)[ResourceGPU]; ok {\n\t\treturn &val\n\t}\n\treturn &resource.Quantity{Format: resource.DecimalSI}\n}" ]
[ "0.58724934", "0.5863162", "0.57436544", "0.57390493", "0.54155165", "0.5408128", "0.5230414", "0.51869965", "0.51444864", "0.51340497", "0.50995654", "0.5063905", "0.50034463", "0.4998801", "0.4996387", "0.4985066", "0.49573505", "0.4939282", "0.4936213", "0.4924132", "0.49011493", "0.48765072", "0.4853482", "0.48188832", "0.4805072", "0.47890067", "0.47869432", "0.4783984", "0.47594184", "0.4740017", "0.47176734", "0.47174272", "0.469215", "0.4689336", "0.468913", "0.4673431", "0.46674094", "0.4665206", "0.46645764", "0.4662035", "0.4652202", "0.46444863", "0.46413925", "0.46404302", "0.46111825", "0.459286", "0.4567127", "0.4567127", "0.45311877", "0.45187265", "0.4517674", "0.45172274", "0.44885275", "0.44821844", "0.4471707", "0.4467339", "0.4446108", "0.4441601", "0.44298038", "0.44258466", "0.44183245", "0.44134626", "0.44126505", "0.44030616", "0.4396854", "0.4395169", "0.43932354", "0.4393153", "0.4389003", "0.43805817", "0.4374916", "0.437228", "0.43701202", "0.436981", "0.43697384", "0.4365121", "0.43607163", "0.43557817", "0.435375", "0.43526414", "0.4350787", "0.43476456", "0.43465185", "0.4344858", "0.43367416", "0.43341798", "0.4329211", "0.431925", "0.43174663", "0.43159238", "0.43139297", "0.43138504", "0.43137002", "0.43129912", "0.4305783", "0.43030486", "0.43024895", "0.42921335", "0.42903265", "0.4286087" ]
0.8314187
0
NewMockServiceAuth creates a new mock instance
func NewMockServiceAuth(ctrl *gomock.Controller) *MockServiceAuth { mock := &MockServiceAuth{ctrl: ctrl} mock.recorder = &MockServiceAuthMockRecorder{mock} return mock }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewAuth(users map[string]string) policies.AuthServiceClient {\n\treturn &authServiceMock{users}\n}", "func NewMockAuth(t mockConstructorTestingTNewMockAuth) *MockAuth {\n\tmock := &MockAuth{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func newAuthService(n NameService) *authService {\n\treturn &authService{\n\t\tn: n,\n\t}\n}", "func NewMockService(transport *http.Transport, aurl string, rurl string, surl string) Service {\n\n\treturn Service{\n\t\tclient: &http.Client{\n\t\t\tTransport: transport,\n\t\t},\n\t\tauthURL: aurl,\n\t\tregistryURL: rurl,\n\t\tserviceURL: surl,\n\t}\n}", "func NewAuthMock(l auth.Logger) *AuthMock {\n\treturn &AuthMock{*auth.New(l)}\n}", "func NewMock(middleware []Middleware) OrganizationService {\n\tvar svc OrganizationService = NewBasicOrganizationServiceServiceMock()\n\tfor _, m := range middleware {\n\t\tsvc = m(svc)\n\t}\n\treturn svc\n}", "func newAuthService(sling *sling.Sling) *AuthService {\n\treturn &AuthService{\n\t\tsling: sling.Path(\"oauth/\"),\n\t}\n}", "func NewService(t mockConstructorTestingTNewService) *Service {\n\tmock := &Service{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func New(mockenv *common.MockEnvironment, storage storage.Storage) *MockService {\n\ts := &MockService{\n\t\tkube: mockenv.GetKubeClient(),\n\t\tstorage: storage,\n\t\tprojects: mockenv.GetProjects(),\n\t}\n\ts.v1 = &SecretsV1{MockService: s}\n\treturn s\n}", "func NewIdentityService(t mockConstructorTestingTNewIdentityService) *IdentityService {\n\tmock := &IdentityService{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewService(t testing.TB) *Service {\n\tmock := &Service{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func New() (*mock, error) {\n\treturn &mock{\n\t\tConfigService: ConfigService{},\n\t\tContainerService: ContainerService{},\n\t\tDistributionService: DistributionService{},\n\t\tImageService: ImageService{},\n\t\tNetworkService: NetworkService{},\n\t\tNodeService: NodeService{},\n\t\tPluginService: PluginService{},\n\t\tSecretService: SecretService{},\n\t\tServiceService: ServiceService{},\n\t\tSystemService: SystemService{},\n\t\tSwarmService: SwarmService{},\n\t\tVolumeService: VolumeService{},\n\t\tVersion: Version,\n\t}, nil\n}", "func NewOAuth20Service(t mockConstructorTestingTNewOAuth20Service) *OAuth20Service {\n\tmock := &OAuth20Service{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func newAuthorizationMocks(t *testing.T, resource, action string) (\n\tauthn.AuthenticationServiceClient, authz.AuthorizationServiceClient) {\n\tvar (\n\t\tctrl = gomock.NewController(t)\n\t\tmockAuthClient = authn.NewMockAuthenticationServiceClient(ctrl)\n\t\tmockAuthzClient = authz.NewMockAuthorizationServiceClient(ctrl)\n\t)\n\n\t// Mocking AuthN Calls\n\tmockAuthClient.EXPECT().Authenticate(gomock.Any(), gomock.Any()).DoAndReturn(\n\t\tfunc(_ context.Context, _ *authn.AuthenticateRequest) (*authn.AuthenticateResponse, error) {\n\t\t\treturn &authn.AuthenticateResponse{Subject: \"mock\", Teams: []string{}}, nil\n\t\t})\n\n\t// Mocking AuthZ Calls\n\tmockAuthzClient.EXPECT().ProjectsAuthorized(\n\t\tgomock.Any(),\n\t\t&authz.ProjectsAuthorizedReq{\n\t\t\tSubjects: []string{\"mock\"},\n\t\t\tResource: resource,\n\t\t\tAction: action,\n\t\t\tProjectsFilter: []string{},\n\t\t},\n\t).DoAndReturn(\n\t\tfunc(_ context.Context, _ *authz.ProjectsAuthorizedReq) (*authz.ProjectsAuthorizedResp, error) {\n\t\t\treturn &authz.ProjectsAuthorizedResp{Projects: []string{\"any\"}}, nil\n\t\t},\n\t)\n\n\treturn mockAuthClient, mockAuthzClient\n}", "func NewMock(t *testing.T) *MockT { return &MockT{t: t} }", "func NewAuthRouter(routerServices *Services) *AuthRouter {\n router := new(AuthRouter)\n\n router.Services = routerServices\n\n return router\n}", "func newProxy(config *Config) (*oauthProxy, error) {\n\t// create the service logger\n\tlog, err := createLogger(config)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlog.Info(\"starting the service\", zap.String(\"prog\", prog), zap.String(\"author\", author), zap.String(\"version\", version))\n\tsvc := &oauthProxy{\n\t\tconfig: config,\n\t\tlog: log,\n\t\tmetricsHandler: prometheus.Handler(),\n\t}\n\n\t// parse the upstream endpoint\n\tif svc.endpoint, err = url.Parse(config.Upstream); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// initialize the store if any\n\tif config.StoreURL != \"\" {\n\t\tif svc.store, err = createStorage(config.StoreURL); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// initialize the openid client\n\tif !config.SkipTokenVerification {\n\t\tif svc.client, svc.idp, svc.idpClient, err = svc.newOpenIDClient(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tlog.Warn(\"TESTING ONLY CONFIG - the verification of the token have been disabled\")\n\t}\n\n\tif config.ClientID == \"\" && config.ClientSecret == \"\" {\n\t\tlog.Warn(\"client credentials are not set, depending on provider (confidential|public) you might be unable to auth\")\n\t}\n\n\t// are we running in forwarding mode?\n\tif config.EnableForwarding {\n\t\tif err := svc.createForwardingProxy(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tif err := svc.createReverseProxy(); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\treturn svc, nil\n}", "func newTeamService(store storage.DataStore) teamService {\n\treturn teamService{\n\t\tstore: store,\n\t\tdefaultGrpcAuth: defaultGrpcAuth{Store: store},\n\t}\n}", "func NewAuth(svc *auth.Service, e *echo.Echo, mw echo.MiddlewareFunc) {\n\ta := Auth{svc}\n\t// swagger:route POST /login auth login\n\t// Logs in user by username and password.\n\t// responses:\n\t// 200: loginResp\n\t// 400: errMsg\n\t// 401: errMsg\n\t// \t403: err\n\t// 404: errMsg\n\t// 500: err\n\te.POST(\"/login\", a.login)\n\t// swagger:operation GET /refresh/{token} auth refresh\n\t// ---\n\t// summary: Refreshes jwt token.\n\t// description: Refreshes jwt token by checking at database whether refresh token exists.\n\t// parameters:\n\t// - name: token\n\t// in: path\n\t// description: refresh token\n\t// type: string\n\t// required: true\n\t// responses:\n\t// \"200\":\n\t// \"$ref\": \"#/responses/refreshResp\"\n\t// \"400\":\n\t// \"$ref\": \"#/responses/errMsg\"\n\t// \"401\":\n\t// \"$ref\": \"#/responses/err\"\n\t// \"500\":\n\t// \"$ref\": \"#/responses/err\"\n\te.GET(\"/refresh/:token\", a.refresh)\n\n\t// swagger:route GET /me auth meReq\n\t// Gets user's info from session\n\t// responses:\n\t// 200: userResp\n\t// 500: err\n\te.GET(\"/me\", a.me, mw)\n}", "func NewMockObject(uid, name, ns string, res api.Resource) api.Object {\n\treturn NewObject(uuid.NewFromString(uid), name, ns, res)\n}", "func New(\n\tstub shim.ChaincodeStubInterface,\n\tclientIdentity cid.ClientIdentity,\n\trolePermissions RolePermissions,\n\trolesAttr string,\n) (AuthService, error) {\n\tvar a AuthService\n\n\tuserID, err := clientIdentity.GetID()\n\tif err != nil {\n\t\treturn a, errAuthentication(err)\n\t}\n\n\tuserRoles, err := getRoles(clientIdentity, rolesAttr)\n\tif err != nil {\n\t\treturn a, err\n\t}\n\n\ta = AuthService{\n\t\trolePermissions: rolePermissions,\n\t\tstub: stub,\n\t\tuserID: userID,\n\t\tuserRoles: userRoles,\n\t}\n\n\treturn a, nil\n}", "func New() *Mock {\n\treturn &Mock{\n\t\tm: mockMap{},\n\t\toldTransport: http.DefaultTransport,\n\t}\n}", "func NewApplicationService(t mockConstructorTestingTNewApplicationService) *ApplicationService {\n\tmock := &ApplicationService{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewUidService(t mockConstructorTestingTNewUidService) *UidService {\n\tmock := &UidService{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func setupAuthForService(accID string, accSecret string) error {\n\t// opts := auth.DefaultAuth.Options()\n\n\t// extract the account creds from options, these can be set by flags\n\t// accID := ID\n\t// accSecret := Secret\n\n\t// if no credentials were provided, self generate an account\n\tif len(accID) == 0 || len(accSecret) == 0 {\n\t\topts := []auth.GenerateOption{\n\t\t\tauth.WithType(\"service\"),\n\t\t\tauth.WithScopes(\"service\"),\n\t\t}\n\n\t\tacc, err := auth.Generate(uuid.New().String(), opts...)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif logger.V(logger.DebugLevel, logger.DefaultLogger) {\n\t\t\tlogger.Debugf(\"Auth [%v] Generated an auth account\", auth.DefaultAuth.String())\n\t\t}\n\n\t\taccID = acc.ID\n\t\taccSecret = acc.Secret\n\t}\n\n\t// generate the first token\n\ttoken, err := auth.Token(\n\t\tauth.WithCredentials(accID, accSecret),\n\t\tauth.WithExpiry(time.Minute*10),\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// set the credentials and token in auth options\n\tauth.DefaultAuth.Init(\n\t\tauth.ClientToken(token),\n\t\tauth.Credentials(accID, accSecret),\n\t)\n\treturn nil\n}", "func NewMock() *Mock {\n\treturn &Mock{VolumesMock: &VolumesServiceMock{}}\n}", "func NewAuthService(req *http.Request, jwtSvc JWTSvc, exe base.Executor, redis *redis.Pool) (*Service, error) {\n\tjwtData, err := jwtSvc.AuthJWT(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Service{\n\t\tJWTData: *jwtData,\n\t\texe: exe,\n\t\tredis: redis,\n\t\tmux: &sync.Mutex{},\n\t\troles: nil, // loaded only when neeeded with function: IsAdmin\n\t\tprivileges: nil, // loaded only when neeeded with functions: CheckAuthorization, GetPrivilegeByPriority\n\t}, nil\n}", "func newMockAuthServer(t *testing.T) string {\n\tl, err := Listen(\"tcp\", \"127.0.0.1:0\", serverConfig)\n\tif err != nil {\n\t\tt.Fatalf(\"unable to newMockAuthServer: %s\", err)\n\t}\n\tgo func() {\n\t\tdefer l.Close()\n\t\tc, err := l.Accept()\n\t\tdefer c.Close()\n\t\tif err != nil {\n\t\t\tt.Errorf(\"Unable to accept incoming connection: %v\", err)\n\t\t\treturn\n\t\t}\n\t\tif err := c.Handshake(); err != nil {\n\t\t\t// not Errorf because this is expected to\n\t\t\t// fail for some tests.\n\t\t\tt.Logf(\"Handshaking error: %v\", err)\n\t\t\treturn\n\t\t}\n\t}()\n\treturn l.Addr().String()\n}", "func NewMock(now time.Time) *Mock {\n\treturn &Mock{\n\t\tnow: now,\n\t\tmockTimers: &timerHeap{},\n\t}\n}", "func newAuth(parentAuth swift.Authenticator, storageURL string, authToken string) *auth {\n\treturn &auth{\n\t\tparentAuth: parentAuth,\n\t\tstorageURL: storageURL,\n\t\tauthToken: authToken,\n\t}\n}", "func New(storage storage.Accessor, passwordManager password.Manager) ServiceProvider {\n\treturn &Service{\n\t\tstorage: storage,\n\t\tpasswordManager: passwordManager,\n\t}\n}", "func newAuthenticationService(sling *sling.Sling, uriTemplate string, loginInitiatedPath string) *authenticationService {\n\treturn &authenticationService{\n\t\tloginInitiatedPath: loginInitiatedPath,\n\t\tservice: newService(ServiceAuthenticationService, sling, uriTemplate),\n\t}\n}", "func NewMockAuth(ctrl *gomock.Controller) *MockAuth {\n\tmock := &MockAuth{ctrl: ctrl}\n\tmock.recorder = &MockAuthMockRecorder{mock}\n\treturn mock\n}", "func NewHTTPAuthService(ctrl *gomock.Controller) *HTTPAuthService {\n\tmock := &HTTPAuthService{ctrl: ctrl}\n\tmock.recorder = &HTTPAuthServiceMockRecorder{mock}\n\treturn mock\n}", "func NewMock(serverHost string) (*MockClient, error) {\n\treturn &MockClient{}, nil\n}", "func mockAuthenticationComponent(log *zap.Logger, serviceName string) *AuthenticationComponent {\n\thttpTimeout := 300 * time.Millisecond\n\n\treturn NewAuthenticationComponent(&AuthenticationParams{\n\t\tAuthConfig: &core_auth_sdk.Config{\n\t\t\tIssuer: issuer,\n\t\t\tPrivateBaseURL: privateBaseUrl,\n\t\t\tAudience: audience,\n\t\t\tUsername: username,\n\t\t\tPassword: password,\n\t\t\tKeychainTTL: 0,\n\t\t},\n\t\tAuthConnectionConfig: &core_auth_sdk.RetryConfig{\n\t\t\tMaxRetries: 1,\n\t\t\tMinRetryWaitTime: 200 * time.Millisecond,\n\t\t\tMaxRetryWaitTime: 300 * time.Millisecond,\n\t\t\tRequestTimeout: 500 * time.Millisecond,\n\t\t},\n\t\tLogger: log,\n\t\tOrigin: origin,\n\t}, serviceName, httpTimeout)\n}", "func NewSecretClient(t mockConstructorTestingTNewSecretClient) *SecretClient {\n\tmock := &SecretClient{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewMock() *Mock {\n\treturn &Mock{now: time.Unix(0, 0)}\n}", "func New(ctx context.Context, m map[string]interface{}) (auth.Manager, error) {\n\tvar mgr manager\n\tif err := mgr.Configure(m); err != nil {\n\t\treturn nil, err\n\t}\n\tgw, err := pool.GetGatewayServiceClient(pool.Endpoint(mgr.c.GatewayAddr))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tmgr.gw = gw\n\n\treturn &mgr, nil\n}", "func NewAuthService(db storage.Storage) *AuthService {\n\treturn &AuthService{\n\t\tdb,\n\t}\n}", "func NewService(db *sqlx.DB, mg mailgun.Mailgun, nonce nonce.Service, tpl *tmpl.TplSys) Service {\n\ts := &authService{\n\t\tdb: db,\n\t\tmg: mg,\n\t\tnonce: nonce,\n\t\ttpl: tpl,\n\t}\n\n\t// TODO\n\t// Move hardcoded Template Strings to templates.go\n\ttemplate.Must(s.tpl.AddTemplate(\"auth.baseHTMLEmailTemplate\", \"\", baseHTMLEmailTemplate))\n\ttemplate.Must(s.tpl.AddTemplate(\"auth.NewUserEmail\", \"auth.baseHTMLEmailTemplate\", `{{define \"title\"}}Welcome New User{{end}}{{define \"content\"}}<p style=\"margin:0;padding:1em 0 0 0;line-height:1.5em;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:14px;color:#000;\"> Hello %recipient.firstname% %recipient.lastname%, <br/> <br/> Welcome to our service. Thank you for signing up.<br/> <br/> </p>{{end}}`))\n\ttemplate.Must(s.tpl.AddTemplate(\"auth.PasswordResetEmail\", \"auth.baseHTMLEmailTemplate\", `{{define \"title\"}}Password Reset{{end}}{{define \"content\"}}<p style=\"margin:0;padding:1em 0 0 0;line-height:1.5em;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:14px;color:#000;\"> Hello %recipient.firstname% %recipient.lastname%, <br/> <br/> Forgot your password? No problem! <br/> <br/> To reset your password, click the following link: <br/> <a href=\"https://www.example.com/auth/password-reset/%recipient.token%\">Reset Password</a> <br/> <br/> If you did not request to have your password reset you can safely ignore this email. Rest assured your customer account is safe. <br/> <br/> </p>{{end}}`))\n\ttemplate.Must(s.tpl.AddTemplate(\"auth.PasswordResetConfirmEmail\", \"auth.baseHTMLEmailTemplate\", `{{define \"title\"}}Password Reset Complete{{end}}{{define \"content\"}}<p style=\"margin:0;padding:1em 0 0 0;line-height:1.5em;font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:14px;color:#000;\"> Hello %recipient.firstname% %recipient.lastname%, <br/> <br/> Your account's password was recently changed. <br/> <br/> </p>{{end}}`))\n\n\treturn s\n}", "func New(accessToken string, logger *logrus.Logger) Service {\n\treturn &service{accessToken, logger}\n}", "func newService(rcvr interface{}, guard Guard) *service {\n\ts := new(service)\n\ts.typ = reflect.TypeOf(rcvr)\n\ts.rcvr = reflect.ValueOf(rcvr)\n\ts.name = reflect.Indirect(s.rcvr).Type().Name()\n\ts.guard = guard\n\n\t// install the methods\n\ts.method = suitableMethods(s.typ, true)\n\n\treturn s\n}", "func newMockSubscriber() mockSubscriber {\n\treturn mockSubscriber{}\n}", "func NewCryptographyServiceMock(t minimock.Tester) *CryptographyServiceMock {\n\tm := &CryptographyServiceMock{t: t}\n\n\tif controller, ok := t.(minimock.MockController); ok {\n\t\tcontroller.RegisterMocker(m)\n\t}\n\n\tm.GetPublicKeyMock = mCryptographyServiceMockGetPublicKey{mock: m}\n\tm.SignMock = mCryptographyServiceMockSign{mock: m}\n\tm.VerifyMock = mCryptographyServiceMockVerify{mock: m}\n\n\treturn m\n}", "func NewAuthService(set *settings.Settings) *AuthService {\n\tauth := new(AuthService)\n\tauth.initOAuth(set)\n\tauth.initStore(set)\n\treturn auth\n}", "func newMock(deps mockDependencies, t testing.TB) (Component, error) {\n\tbackupConfig := config.NewConfig(\"\", \"\", strings.NewReplacer())\n\tbackupConfig.CopyConfig(config.Datadog)\n\n\tconfig.Datadog.CopyConfig(config.NewConfig(\"mock\", \"XXXX\", strings.NewReplacer()))\n\n\tconfig.SetFeatures(t, deps.Params.Features...)\n\n\t// call InitConfig to set defaults.\n\tconfig.InitConfig(config.Datadog)\n\tc := &cfg{\n\t\tConfig: config.Datadog,\n\t}\n\n\tif !deps.Params.SetupConfig {\n\n\t\tif deps.Params.ConfFilePath != \"\" {\n\t\t\tconfig.Datadog.SetConfigType(\"yaml\")\n\t\t\terr := config.Datadog.ReadConfig(strings.NewReader(deps.Params.ConfFilePath))\n\t\t\tif err != nil {\n\t\t\t\t// The YAML was invalid, fail initialization of the mock config.\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\t} else {\n\t\twarnings, _ := setupConfig(deps)\n\t\tc.warnings = warnings\n\t}\n\n\t// Overrides are explicit and will take precedence over any other\n\t// setting\n\tfor k, v := range deps.Params.Overrides {\n\t\tconfig.Datadog.Set(k, v)\n\t}\n\n\t// swap the existing config back at the end of the test.\n\tt.Cleanup(func() { config.Datadog.CopyConfig(backupConfig) })\n\n\treturn c, nil\n}", "func NewAuth(jwt jwts.JWTer, userRepo repository.UserRepository) auth.Service {\n\treturn &authsrvc{jwt, userRepo}\n}", "func CreateMock(method interface{}, url interface{}, headers interface{}, body interface{}) *go_mock_yourself_http.Mock {\n\tmockRequest := new(go_mock_yourself_http.Request)\n\n\tif method != nil {\n\t\tmockRequest.SetMethod(method)\n\t}\n\n\tif url != nil {\n\t\tmockRequest.SetUrl(url)\n\t}\n\n\tif body != nil {\n\t\tmockRequest.SetBody(body)\n\t}\n\n\tif headers != nil {\n\t\tmockRequest.SetHeaders(headers)\n\t}\n\n\tmockResponse := new(go_mock_yourself_http.Response)\n\tmockResponse.SetStatusCode(222)\n\tmockResponse.SetBody(\"i'm a cute loving mock, almost as cute as mumi, bichi and rasti\")\n\n\tmock, _ := go_mock_yourself_http.NewMock(\"my lovely testing mock\", mockRequest, mockResponse)\n\treturn mock\n}", "func NewMock() Client {\n\treturn &mockClient{}\n}", "func NewAuthService(config *context.Config) *AuthService {\n\tif config.JWTSecret == \"\" {\n\t\tpanic(\"You must set JWTSECRET env variable\")\n\t}\n\treturn &AuthService{&config.AppName, &config.JWTSecret, &config.JWTExpireIn}\n}", "func NewAuthService(ctx context.Context, uri string) (userSvc *AuthSVC, err error) {\n\tuserSvc = new(AuthSVC)\n\n\tmongoClient, err := utils.NewMongoConnection(ctx, uri)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"mongoConnection: error connecting to the server %v\", err)\n\t}\n\n\tuserSvc.repo = repository.NewAuthRepo(mongoClient)\n\treturn\n}", "func NewService(\n\trootPrefix string,\n\tauthService auth.HTTPAuthService,\n\tstore store.Store,\n\tiOpts instrument.Options,\n\tclockOpts clock.Options,\n) mservice.Service {\n\treturn &service{\n\t\trootPrefix: rootPrefix,\n\t\tstore: store,\n\t\tauthService: authService,\n\t\tlogger: iOpts.Logger(),\n\t\tnowFn: clockOpts.NowFn(),\n\t\tmetrics: newServiceMetrics(iOpts.MetricsScope(), iOpts.TimerOptions()),\n\t}\n}", "func New(repo model.TictacRespository, addsvc addservice.AddService, logger log.Logger) (s TictacService) {\n\tvar svc TictacService\n\t{\n\t\tsvc = &stubTictacService{logger: logger, addsvc: addsvc, repo: repo}\n\t\tsvc = LoggingMiddleware(logger)(svc)\n\t}\n\treturn svc\n}", "func NewMockInterface(t mockConstructorTestingTNewMockInterface) *MockInterface {\n\tmock := &MockInterface{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func newClient(httpClient *http.Client) (c *Client) {\n\tc = &Client{httpClient: httpClient}\n\tc.service.client = c\n\tc.Auth = (*AuthService)(&c.service)\n\tc.Providers = (*ProvidersService)(&c.service)\n\tc.Projects = (*ProjectsService)(&c.service)\n\tc.Releases = (*ReleasesService)(&c.service)\n\tc.SlackChannels = (*SlackChannelsService)(&c.service)\n\tc.TelegramChats = (*TelegramChatsService)(&c.service)\n\tc.DiscordChannels = (*DiscordChannelsService)(&c.service)\n\tc.HangoutsChatWebhooks = (*HangoutsChatWebhooksService)(&c.service)\n\tc.MicrosoftTeamsWebhooks = (*MicrosoftTeamsWebhooksService)(&c.service)\n\tc.MattermostWebhooks = (*MattermostWebhooksService)(&c.service)\n\tc.RocketchatWebhooks = (*RocketchatWebhooksService)(&c.service)\n\tc.MatrixRooms = (*MatrixRoomsService)(&c.service)\n\tc.Webhooks = (*WebhooksService)(&c.service)\n\tc.Tags = (*TagsService)(&c.service)\n\treturn c\n}", "func NewService(repo users.RepoUsers) RepoServiceAuth {\n\treturn &service{\n\t\trepoUser: repo,\n\t}\n}", "func NewService() Service {\n\treturn Service{\n\t\tclient: &http.Client{\n\t\t\t// TODO Make timeout configurable.\n\t\t\tTimeout: 10 * time.Second,\n\t\t},\n\t\tauthURL: authURL,\n\t\tregistryURL: registryURL,\n\t\tserviceURL: serviceURL,\n\t}\n}", "func New(svc service.Service, buf *bytes.Buffer) ServiceTest {\n\tvar svctest ServiceTest\n\t{\n\t\tsvctest = NewBasicServiceTest(svc)\n\t\tsvctest = LoggingMiddlewareTest(buf)(svctest)\n\t}\n\treturn svctest\n}", "func NewMockAuthService(ctrl *gomock.Controller) *MockAuthService {\n\tmock := &MockAuthService{ctrl: ctrl}\n\tmock.recorder = &MockAuthServiceMockRecorder{mock}\n\treturn mock\n}", "func newMockTransport(fn string) (*mockTransport, error) {\n\n\tf, err := os.Open(fn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar cfg config\n\n\terr = json.NewDecoder(f).Decode(&cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &mockTransport{responses: cfg}, nil\n}", "func InitializeMockAuthenticationComponent() *AuthenticationComponent {\n\tlogInstance := core_logging.New(\"info\")\n\tdefer logInstance.ConfigureLogger()\n\tlog := logInstance.Logger\n\n\treturn mockAuthenticationComponent(log, svcName)\n}", "func NewAuthDummyClient() AuthClient {\n\treturn AuthDummyClient{\n\t\tlog: logrus.WithField(\"component\", \"auth_stub\"),\n\t}\n}", "func NewMock() *Mock {\n\tc := &Mock{\n\t\tFakeIncoming: func() chan []byte {\n\t\t\treturn make(chan []byte, 2)\n\t\t},\n\t\tFakeName: func() string {\n\t\t\treturn \"TestClient\"\n\t\t},\n\t\tFakeGame: func() string {\n\t\t\treturn \"test\"\n\t\t},\n\t\tFakeClose: func() {\n\t\t\t// Do nothing\n\t\t},\n\t\tFakeStopTimer: func() {\n\t\t\t// Do nothing\n\t\t},\n\t\tFakeRoom: func() interfaces.Room {\n\t\t\treturn nil\n\t\t},\n\t\tFakeSetRoom: func(interfaces.Room) {\n\n\t\t},\n\t}\n\n\tc.FakeWritePump = func() {\n\t\tfor range c.Incoming() {\n\t\t\t// Do nothing\n\t\t}\n\t}\n\n\tc.FakeSetName = func(string) interfaces.Client {\n\t\treturn c\n\t}\n\treturn c\n}", "func New(\n\tlog logger.Logger,\n\tconfig *config.Config,\n\tjwtService jwt.Service,\n\taccountUsecase account.AccountUsecase,\n\trefreshTokenUsecase refreshtoken.RefreshTokenUsecase,\n\tuserUsecase user.UserUsecase,\n) Service {\n\ts := &server{\n\t\tlog: log,\n\t\tconfig: config,\n\t\tjwtService: jwtService,\n\t\taccountUsecase: accountUsecase,\n\t\trefreshTokenUsecase: refreshTokenUsecase,\n\t\tuserUsecase: userUsecase,\n\t}\n\n\ts.setupRouting()\n\n\treturn s\n}", "func NewAuthService(userRepo Repository) Service {\n\treturn &userService{\n\t\tuserRepo,\n\t}\n}", "func newRPCServerService() (*rpcServerService, error) {\n return &rpcServerService{serviceMap: util.NewSyncMap()}, nil\n}", "func NewUserAuthService(db interface{}) (UserAuthService, error) {\n\n\tuserAuthService := &UserAuthServiceImpl{}\n\n\tswitch *config.AppConfig.DBType {\n\tcase config.DB_MONGO:\n\n\t\tmongodb := db.(mongodb.MongoDatabase)\n\t\tuserAuthService.UserAuthRepo = mongoRepo.NewDataRepositoryMongo(mongodb)\n\n\t}\n\tif userAuthService.UserAuthRepo == nil {\n\t\tfmt.Printf(\"userAuthService.UserAuthRepo is nil! \\n\")\n\t}\n\treturn userAuthService, nil\n}", "func newMockTransport() *mockTransport {\n\treturn &mockTransport{\n\t\turlToResponseAndError: make(map[string]mockTransportResponse),\n\t\trequestURLsReceived: make([]string, 0),\n\t}\n}", "func New(am AuthMechanism, cm ConfigMap, options ...Option) Doer {\n\tdefaultClient := &http.Client{}\n\tfor i := range options {\n\t\tif options[i] != nil {\n\t\t\toptions[i](defaultClient)\n\t\t}\n\t}\n\n\tdf, ok := factoryFor(am)\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"unregistered auth mechanism %q\", am))\n\t}\n\treturn df(cm, defaultClient)\n}", "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "func New(cred esign.Credential) *Service {\n\treturn &Service{credential: cred}\n}", "func NewMock() *Mock {\n\treturn &Mock{\n\t\tData: MockData{\n\t\t\tUptime: true,\n\t\t\tFile: true,\n\t\t\tTCPResponse: true,\n\t\t\tHTTPStatus: true,\n\t\t},\n\t}\n}", "func newMockClient(doer func(*http.Request) (*http.Response, error)) *http.Client {\n\treturn &http.Client{\n\t\tTransport: transportFunc(doer),\n\t}\n}", "func New(client client.Client, namespace string) *fakeManager {\n\treturn &fakeManager{\n\t\tclient: client,\n\t\tnamespace: namespace,\n\t}\n}", "func NewIdentityService(vm *otto.Otto, context *Context, stub shim.ChaincodeStubInterface) (result *IdentityService) {\n\tlogger.Debug(\"Entering NewIdentityService\", vm, context, stub)\n\tdefer func() { logger.Debug(\"Exiting NewIdentityService\", result) }()\n\n\t// Create a new instance of the JavaScript chaincode class.\n\ttemp, err := vm.Call(\"new concerto.IdentityService\", nil, context.This)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Failed to create new instance of IdentityService JavaScript class: %v\", err))\n\t} else if !temp.IsObject() {\n\t\tpanic(\"New instance of IdentityService JavaScript class is not an object\")\n\t}\n\tobject := temp.Object()\n\n\t// Add a pointer to the Go object into the JavaScript object.\n\tresult = &IdentityService{This: temp.Object(), Stub: stub}\n\terr = object.Set(\"$this\", result)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Failed to store Go object in IdentityService JavaScript object: %v\", err))\n\t}\n\n\t// Bind the methods into the JavaScript object.\n\tresult.This.Set(\"getCurrentUserID\", result.getCurrentUserID)\n\treturn result\n\n}", "func NewMock(opts ...ClientOpt) (*client, error) {\n\t// create new Docker runtime client\n\tc, err := New(opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// create Docker client from the mock client\n\t//\n\t// https://pkg.go.dev/github.com/go-vela/mock/docker#New\n\t_docker, err := mock.New()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// set the Docker client in the runtime client\n\tc.Docker = _docker\n\n\treturn c, nil\n}", "func GetNewClient(service string, httpFactory HttpClientFactory) (*OauthClient, error) {\n\tjar, err := cookiejar.New(nil)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Munge on the service a little bit, force it to have no trailing / and always start with https://\n\turl, err := url.Parse(service)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\turl.Scheme = \"https\"\n\turl.Path = \"\"\n\n\tclient := &OauthClient{}\n\tclient.Service = url.String()\n\tif httpFactory != nil {\n\t\tclient.Client = httpFactory()\n\t} else {\n\t\tclient.Client = &http.Client{}\n\t}\n\tclient.Client.Jar = jar\n\tclient.Headers = make(map[string]string)\n\tclient.SourceHeader = \"cloud-golang-sdk\"\n\treturn client, err\n}", "func New(sync *contract.Sync, dao dao.Service, mutex *shared.Mutex, jobService jobs.Service, historyService history.Service) Service {\n\treturn newService(sync, dao, mutex, jobService, historyService)\n}", "func NewService(repo Repository, app model.App) Service {\n\treturn &ServiceImpl{\n\t\trepo: repo,\n\t\thasher: app.Hasher,\n\t\tsigner: app.JWTSigner,\n\t}\n}", "func mock(t testing.TB, m *mockSecretServer) *secretmanager.Client {\n\tt.Helper()\n\tl := bufconn.Listen(1024 * 1024)\n\ts := grpc.NewServer()\n\tsecretmanagerpb.RegisterSecretManagerServiceServer(s, m)\n\n\tgo func() {\n\t\tif err := s.Serve(l); err != nil {\n\t\t\tt.Errorf(\"server error: %v\", err)\n\t\t}\n\t}()\n\n\tconn, err := grpc.Dial(l.Addr().String(), grpc.WithContextDialer(\n\t\tfunc(context.Context, string) (net.Conn, error) {\n\t\t\treturn l.Dial()\n\t\t}),\n\t\tgrpc.WithTransportCredentials(insecure.NewCredentials()))\n\tif err != nil {\n\t\tt.Fatalf(\"failed to dial: %v\", err)\n\t}\n\n\tclient, err := secretmanager.NewClient(context.Background(), option.WithoutAuthentication(), option.WithGRPCConn(conn))\n\tshutdown := func() {\n\t\tt.Log(\"shutdown called\")\n\t\tconn.Close()\n\t\ts.GracefulStop()\n\t\tl.Close()\n\t}\n\tif err != nil {\n\t\tshutdown()\n\t\tt.Fatal(err)\n\t}\n\n\tt.Cleanup(shutdown)\n\treturn client\n}", "func NewMock() MockClient {\n\treturn NewMockWithLogger(&noopLogger{})\n}", "func NewAuthService(authRepository Repository, userService user.Service) Service {\n\treturn &service{\n\t\tauthRepository: authRepository,\n\t\tuserService: userService,\n\t}\n}", "func NewAuthService(repo auth.Repository) auth.Service {\n\treturn &AuthService{repo}\n}", "func NewClient(t mockConstructorTestingTNewClient) *Client {\n\tmock := &Client{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewClient(t mockConstructorTestingTNewClient) *Client {\n\tmock := &Client{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewClient(t mockConstructorTestingTNewClient) *Client {\n\tmock := &Client{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewClient(t mockConstructorTestingTNewClient) *Client {\n\tmock := &Client{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func mockedGranter(kubeutil *kube.Kube, app *v1.RadixRegistration, namespace string, serviceAccount *corev1.ServiceAccount) error {\n\treturn nil\n}", "func NewMockCredentials(ctrl *gomock.Controller) *MockCredentials {\n\tmock := &MockCredentials{ctrl: ctrl}\n\tmock.recorder = &MockCredentialsMockRecorder{mock}\n\treturn mock\n}", "func New(realms RealmRepository, hasher Hasher, auth mainflux.AuthNServiceClient, providers []RealmProvider) Service {\n\treturn &realmService{\n\t\trealms: realms,\n\t\thasher: hasher,\n\t\tauth: auth,\n\t\tproviders: providers,\n\t\tmutex: sync.RWMutex{},\n\t}\n}", "func NewNotificationsService(t mockConstructorTestingTNewNotificationsService) *NotificationsService {\n\tmock := &NotificationsService{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func NewMock(r ...MockResponse) *http.Client {\n\treturn &http.Client{\n\t\tTransport: newRoundTripper(r...),\n\t}\n}", "func NewGitClient(t mockConstructorTestingTNewGitClient) *GitClient {\n\tmock := &GitClient{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func newService(serviceName string) *Service {\n\treturn &Service{\n\t\tpluginDir: serverless.PluginDir,\n\t\tname: serviceName,\n\t\tinterf: nil,\n\t}\n}", "func NewService(http webreq.HTTP, secret string) Service {\n\treturn Service{\n\t\thttp: http,\n\t\tsecret: secret,\n\t}\n}" ]
[ "0.7235981", "0.7116139", "0.68920743", "0.6762796", "0.67064947", "0.66278625", "0.6601573", "0.6584503", "0.64793545", "0.6477035", "0.6461894", "0.63040113", "0.6280253", "0.6241314", "0.6233598", "0.61390966", "0.59611005", "0.59576327", "0.59335065", "0.59243286", "0.59141314", "0.59098357", "0.58865947", "0.58673435", "0.58151484", "0.57725", "0.5743789", "0.5712845", "0.56908584", "0.567911", "0.5669753", "0.56608033", "0.56506443", "0.5618882", "0.5613136", "0.5607401", "0.56004786", "0.5589805", "0.5586927", "0.5568092", "0.55607855", "0.5558411", "0.55583346", "0.5546194", "0.55415916", "0.55389863", "0.5536056", "0.55193347", "0.5505422", "0.5503336", "0.5501456", "0.5497913", "0.54881865", "0.54781914", "0.5477809", "0.5462591", "0.5462133", "0.5449835", "0.5446002", "0.5437099", "0.54352367", "0.5434287", "0.5430562", "0.5425396", "0.54201937", "0.54098946", "0.5404138", "0.5401152", "0.5389533", "0.53887767", "0.5384651", "0.5384651", "0.5384651", "0.5384651", "0.5384651", "0.5384651", "0.53767085", "0.53729993", "0.5370505", "0.5360867", "0.5355967", "0.53531396", "0.5351409", "0.53487617", "0.534842", "0.5330233", "0.5329918", "0.5329", "0.53227067", "0.53227067", "0.53227067", "0.53227067", "0.5315576", "0.5315255", "0.5309481", "0.530814", "0.5305218", "0.5295741", "0.5295641", "0.5290658" ]
0.5619934
33
EXPECT returns an object that allows the caller to indicate expected use
func (m *MockServiceAuth) EXPECT() *MockServiceAuthMockRecorder { return m.recorder }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (mmGetObject *mClientMockGetObject) Expect(ctx context.Context, head insolar.Reference) *mClientMockGetObject {\n\tif mmGetObject.mock.funcGetObject != nil {\n\t\tmmGetObject.mock.t.Fatalf(\"ClientMock.GetObject mock is already set by Set\")\n\t}\n\n\tif mmGetObject.defaultExpectation == nil {\n\t\tmmGetObject.defaultExpectation = &ClientMockGetObjectExpectation{}\n\t}\n\n\tmmGetObject.defaultExpectation.params = &ClientMockGetObjectParams{ctx, head}\n\tfor _, e := range mmGetObject.expectations {\n\t\tif minimock.Equal(e.params, mmGetObject.defaultExpectation.params) {\n\t\t\tmmGetObject.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmGetObject.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmGetObject\n}", "func (r Requester) Assert(actual, expected interface{}) Requester {\n\t//r.actualResponse = actual\n\t//r.expectedResponse = expected\n\treturn r\n}", "func (r *Request) Expect(t *testing.T) *Response {\n\tr.apiTest.t = t\n\treturn r.apiTest.response\n}", "func (m *MockNotary) Notarize(arg0 string) (map[string]interface{}, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Notarize\", arg0)\n\tret0, _ := ret[0].(map[string]interface{})\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (tc TestCases) expect() {\n\tfmt.Println(cnt)\n\tcnt++\n\tif !reflect.DeepEqual(tc.resp, tc.respExp) {\n\t\ttc.t.Error(fmt.Sprintf(\"\\nRequested: \", tc.req, \"\\nExpected: \", tc.respExp, \"\\nFound: \", tc.resp))\n\t}\n}", "func (r *Request) Expect(t TestingT) *Response {\n\tr.apiTest.t = t\n\treturn r.apiTest.response\n}", "func Expect(t cbtest.T, actual interface{}, matcher matcher.Matcher, labelAndArgs ...interface{}) {\n\tt.Helper()\n\tres := ExpectE(t, actual, matcher, labelAndArgs...)\n\tif !res {\n\t\tt.FailNow()\n\t}\n}", "func (m *MockisObject_Obj) EXPECT() *MockisObject_ObjMockRecorder {\n\treturn m.recorder\n}", "func Expect(t *testing.T, v, m interface{}) {\n\tvt, vok := v.(Equaler)\n\tmt, mok := m.(Equaler)\n\n\tvar state bool\n\tif vok && mok {\n\t\tstate = vt.Equal(mt)\n\t} else {\n\t\tstate = reflect.DeepEqual(v, m)\n\t}\n\n\tif state {\n\t\tflux.FatalFailed(t, \"Value %+v and %+v are not a match\", v, m)\n\t\treturn\n\t}\n\tflux.LogPassed(t, \"Value %+v and %+v are a match\", v, m)\n}", "func (mmState *mClientMockState) Expect() *mClientMockState {\n\tif mmState.mock.funcState != nil {\n\t\tmmState.mock.t.Fatalf(\"ClientMock.State mock is already set by Set\")\n\t}\n\n\tif mmState.defaultExpectation == nil {\n\t\tmmState.defaultExpectation = &ClientMockStateExpectation{}\n\t}\n\n\treturn mmState\n}", "func (mmProvide *mContainerMockProvide) Expect(constructor interface{}) *mContainerMockProvide {\n\tif mmProvide.mock.funcProvide != nil {\n\t\tmmProvide.mock.t.Fatalf(\"ContainerMock.Provide mock is already set by Set\")\n\t}\n\n\tif mmProvide.defaultExpectation == nil {\n\t\tmmProvide.defaultExpectation = &ContainerMockProvideExpectation{}\n\t}\n\n\tmmProvide.defaultExpectation.params = &ContainerMockProvideParams{constructor}\n\tfor _, e := range mmProvide.expectations {\n\t\tif minimock.Equal(e.params, mmProvide.defaultExpectation.params) {\n\t\t\tmmProvide.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmProvide.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmProvide\n}", "func Mock() Env {\n\treturn mock.New()\n}", "func (mmGetCode *mClientMockGetCode) Expect(ctx context.Context, ref insolar.Reference) *mClientMockGetCode {\n\tif mmGetCode.mock.funcGetCode != nil {\n\t\tmmGetCode.mock.t.Fatalf(\"ClientMock.GetCode mock is already set by Set\")\n\t}\n\n\tif mmGetCode.defaultExpectation == nil {\n\t\tmmGetCode.defaultExpectation = &ClientMockGetCodeExpectation{}\n\t}\n\n\tmmGetCode.defaultExpectation.params = &ClientMockGetCodeParams{ctx, ref}\n\tfor _, e := range mmGetCode.expectations {\n\t\tif minimock.Equal(e.params, mmGetCode.defaultExpectation.params) {\n\t\t\tmmGetCode.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmGetCode.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmGetCode\n}", "func (_m *MockOStream) EXPECT() *MockOStreamMockRecorder {\n\treturn _m.recorder\n}", "func expect(t *testing.T, method, url string, testieOptions ...func(*http.Request)) *testie {\n\treq, err := http.NewRequest(method, url, nil)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tfor _, opt := range testieOptions {\n\t\topt(req)\n\t}\n\n\treturn testReq(t, req)\n}", "func (mmGetUser *mStorageMockGetUser) Expect(ctx context.Context, userID int64) *mStorageMockGetUser {\n\tif mmGetUser.mock.funcGetUser != nil {\n\t\tmmGetUser.mock.t.Fatalf(\"StorageMock.GetUser mock is already set by Set\")\n\t}\n\n\tif mmGetUser.defaultExpectation == nil {\n\t\tmmGetUser.defaultExpectation = &StorageMockGetUserExpectation{}\n\t}\n\n\tmmGetUser.defaultExpectation.params = &StorageMockGetUserParams{ctx, userID}\n\tfor _, e := range mmGetUser.expectations {\n\t\tif minimock.Equal(e.params, mmGetUser.defaultExpectation.params) {\n\t\t\tmmGetUser.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmGetUser.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmGetUser\n}", "func (mmGetObject *mClientMockGetObject) Return(o1 ObjectDescriptor, err error) *ClientMock {\n\tif mmGetObject.mock.funcGetObject != nil {\n\t\tmmGetObject.mock.t.Fatalf(\"ClientMock.GetObject mock is already set by Set\")\n\t}\n\n\tif mmGetObject.defaultExpectation == nil {\n\t\tmmGetObject.defaultExpectation = &ClientMockGetObjectExpectation{mock: mmGetObject.mock}\n\t}\n\tmmGetObject.defaultExpectation.results = &ClientMockGetObjectResults{o1, err}\n\treturn mmGetObject.mock\n}", "func (mmGather *mGathererMockGather) Expect() *mGathererMockGather {\n\tif mmGather.mock.funcGather != nil {\n\t\tmmGather.mock.t.Fatalf(\"GathererMock.Gather mock is already set by Set\")\n\t}\n\n\tif mmGather.defaultExpectation == nil {\n\t\tmmGather.defaultExpectation = &GathererMockGatherExpectation{}\n\t}\n\n\treturn mmGather\n}", "func (m *MockParser) EXPECT() *MockParserMockRecorder {\n\treturn m.recorder\n}", "func (m *MockParser) EXPECT() *MockParserMockRecorder {\n\treturn m.recorder\n}", "func (mmWriteTo *mDigestHolderMockWriteTo) Expect(w io.Writer) *mDigestHolderMockWriteTo {\n\tif mmWriteTo.mock.funcWriteTo != nil {\n\t\tmmWriteTo.mock.t.Fatalf(\"DigestHolderMock.WriteTo mock is already set by Set\")\n\t}\n\n\tif mmWriteTo.defaultExpectation == nil {\n\t\tmmWriteTo.defaultExpectation = &DigestHolderMockWriteToExpectation{}\n\t}\n\n\tmmWriteTo.defaultExpectation.params = &DigestHolderMockWriteToParams{w}\n\tfor _, e := range mmWriteTo.expectations {\n\t\tif minimock.Equal(e.params, mmWriteTo.defaultExpectation.params) {\n\t\t\tmmWriteTo.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmWriteTo.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmWriteTo\n}", "func (rb *RequestBuilder) EXPECT() *ResponseAsserter {\n\treq := httptest.NewRequest(rb.method, rb.path, rb.body)\n\tfor k, v := range rb.hdr {\n\t\treq.Header[k] = v\n\t}\n\n\trec := httptest.NewRecorder()\n\trb.cas.h.ServeHTTP(rec, req)\n\n\treturn &ResponseAsserter{\n\t\trec: rec,\n\t\treq: req,\n\t\tb: rb,\n\t\tfail: rb.fail.\n\t\t\tCopy().\n\t\t\tWithRequest(req).\n\t\t\tWithResponse(rec),\n\t}\n}", "func (mmGetState *mGatewayMockGetState) Expect() *mGatewayMockGetState {\n\tif mmGetState.mock.funcGetState != nil {\n\t\tmmGetState.mock.t.Fatalf(\"GatewayMock.GetState mock is already set by Set\")\n\t}\n\n\tif mmGetState.defaultExpectation == nil {\n\t\tmmGetState.defaultExpectation = &GatewayMockGetStateExpectation{}\n\t}\n\n\treturn mmGetState\n}", "func (m *mParcelMockGetSign) Expect() *mParcelMockGetSign {\n\tm.mock.GetSignFunc = nil\n\tm.expectationSeries = nil\n\n\tif m.mainExpectation == nil {\n\t\tm.mainExpectation = &ParcelMockGetSignExpectation{}\n\t}\n\n\treturn m\n}", "func (mmCreateTag *mTagCreatorMockCreateTag) Expect(t1 semantic.Tag) *mTagCreatorMockCreateTag {\n\tif mmCreateTag.mock.funcCreateTag != nil {\n\t\tmmCreateTag.mock.t.Fatalf(\"TagCreatorMock.CreateTag mock is already set by Set\")\n\t}\n\n\tif mmCreateTag.defaultExpectation == nil {\n\t\tmmCreateTag.defaultExpectation = &TagCreatorMockCreateTagExpectation{}\n\t}\n\n\tmmCreateTag.defaultExpectation.params = &TagCreatorMockCreateTagParams{t1}\n\tfor _, e := range mmCreateTag.expectations {\n\t\tif minimock.Equal(e.params, mmCreateTag.defaultExpectation.params) {\n\t\t\tmmCreateTag.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmCreateTag.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmCreateTag\n}", "func (m *MockActorUsecase) EXPECT() *MockActorUsecaseMockRecorder {\n\treturn m.recorder\n}", "func (m *mParcelMockGetCaller) Expect() *mParcelMockGetCaller {\n\tm.mock.GetCallerFunc = nil\n\tm.expectationSeries = nil\n\n\tif m.mainExpectation == nil {\n\t\tm.mainExpectation = &ParcelMockGetCallerExpectation{}\n\t}\n\n\treturn m\n}", "func mockAlwaysRun() bool { return true }", "func (m *MockArg) EXPECT() *MockArgMockRecorder {\n\treturn m.recorder\n}", "func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder {\n\treturn m.recorder\n}", "func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder {\n\treturn m.recorder\n}", "func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder {\n\treturn m.recorder\n}", "func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder {\n\treturn m.recorder\n}", "func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder {\n\treturn m.recorder\n}", "func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder {\n\treturn m.recorder\n}", "func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder {\n\treturn m.recorder\n}", "func (m *MockUsecase) EXPECT() *MockUsecaseMockRecorder {\n\treturn m.recorder\n}", "func (st *SDKTester) Test(resp interface{}) {\n\tif resp == nil || st.respWant == nil {\n\t\tst.t.Logf(\"response want/got is nil, abort\\n\")\n\t\treturn\n\t}\n\n\trespMap := st.getFieldMap(resp)\n\tfor i, v := range st.respWant {\n\t\tif reflect.DeepEqual(v, respMap[i]) {\n\t\t\tcontinue\n\t\t}\n\t\tswitch x := respMap[i].(type) {\n\t\tcase Stringer:\n\t\t\tif !assert.Equal(st.t, v, x.String()) {\n\t\t\t\tst.t.Errorf(\"%s want %v, got %v\", i, v, respMap[i])\n\t\t\t}\n\t\tcase map[string]interface{}:\n\t\t\tif value, ok := x[\"Value\"]; ok {\n\t\t\t\tif !assert.Equal(st.t, v, value) {\n\t\t\t\t\tst.t.Errorf(\"%s want %v, got %v\", i, v, respMap[i])\n\t\t\t\t}\n\t\t\t}\n\t\tcase Inter:\n\t\t\tif !assert.Equal(st.t, v, x.Int()) {\n\t\t\t\tst.t.Errorf(\"%s want %v, got %v\", i, v, respMap[i])\n\t\t\t}\n\t\tdefault:\n\t\t\tif !assert.Equal(st.t, v, respMap[i]) {\n\t\t\t\tst.t.Errorf(\"%s want %v, got %v\", i, v, respMap[i])\n\t\t\t}\n\t\t}\n\t}\n}", "func (m *MockCreator) EXPECT() *MockCreatorMockRecorder {\n\treturn m.recorder\n}", "func (m *MockCreator) EXPECT() *MockCreatorMockRecorder {\n\treturn m.recorder\n}", "func TestCallFunc_arguments(t *testing.T) {\n\n}", "func (m *mParcelMockGetSender) Expect() *mParcelMockGetSender {\n\tm.mock.GetSenderFunc = nil\n\tm.expectationSeries = nil\n\n\tif m.mainExpectation == nil {\n\t\tm.mainExpectation = &ParcelMockGetSenderExpectation{}\n\t}\n\n\treturn m\n}", "func TestGetNone4A(t *testing.T) {\n}", "func expectEqual(value, expected interface{}) {\n\tif value != expected {\n\t\tfmt.Printf(\"Fehler: %v bekommen, erwartet war aber %v.\\n\", value, expected)\n\t} else {\n\t\tfmt.Printf(\"OK: %v bekommen, erwartet war aber %v.\\n\", value, expected)\n\t}\n}", "func (mmGetPacketSignature *mPacketParserMockGetPacketSignature) Expect() *mPacketParserMockGetPacketSignature {\n\tif mmGetPacketSignature.mock.funcGetPacketSignature != nil {\n\t\tmmGetPacketSignature.mock.t.Fatalf(\"PacketParserMock.GetPacketSignature mock is already set by Set\")\n\t}\n\n\tif mmGetPacketSignature.defaultExpectation == nil {\n\t\tmmGetPacketSignature.defaultExpectation = &PacketParserMockGetPacketSignatureExpectation{}\n\t}\n\n\treturn mmGetPacketSignature\n}", "func (mmHasPendings *mClientMockHasPendings) Expect(ctx context.Context, object insolar.Reference) *mClientMockHasPendings {\n\tif mmHasPendings.mock.funcHasPendings != nil {\n\t\tmmHasPendings.mock.t.Fatalf(\"ClientMock.HasPendings mock is already set by Set\")\n\t}\n\n\tif mmHasPendings.defaultExpectation == nil {\n\t\tmmHasPendings.defaultExpectation = &ClientMockHasPendingsExpectation{}\n\t}\n\n\tmmHasPendings.defaultExpectation.params = &ClientMockHasPendingsParams{ctx, object}\n\tfor _, e := range mmHasPendings.expectations {\n\t\tif minimock.Equal(e.params, mmHasPendings.defaultExpectation.params) {\n\t\t\tmmHasPendings.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmHasPendings.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmHasPendings\n}", "func Run(t testing.TB, cloud cloud.Client, src string, opts ...RunOption) {\n\n\tif cloud == nil {\n\t\tcloud = mockcloud.Client(nil)\n\t}\n\n\tvm := otto.New()\n\n\tpkg, err := godotto.Apply(context.Background(), vm, cloud)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tvm.Set(\"cloud\", pkg)\n\tvm.Set(\"equals\", func(call otto.FunctionCall) otto.Value {\n\t\tvm := call.Otto\n\t\tgot, err := call.Argument(0).Export()\n\t\tif err != nil {\n\t\t\tottoutil.Throw(vm, err.Error())\n\t\t}\n\t\twant, err := call.Argument(1).Export()\n\t\tif err != nil {\n\t\t\tottoutil.Throw(vm, err.Error())\n\t\t}\n\t\tok, cause := deepEqual(got, want)\n\t\tif ok {\n\t\t\treturn otto.UndefinedValue()\n\t\t}\n\t\tmsg := \"assertion failed!\\n\" + cause\n\n\t\tif len(call.ArgumentList) > 2 {\n\t\t\tformat, err := call.ArgumentList[2].ToString()\n\t\t\tif err != nil {\n\t\t\t\tottoutil.Throw(vm, err.Error())\n\t\t\t}\n\t\t\tmsg += \"\\n\" + format\n\t\t}\n\t\tottoutil.Throw(vm, msg)\n\t\treturn otto.UndefinedValue()\n\t})\n\tvm.Set(\"assert\", func(call otto.FunctionCall) otto.Value {\n\t\tvm := call.Otto\n\t\tv, err := call.Argument(0).ToBoolean()\n\t\tif err != nil {\n\t\t\tottoutil.Throw(vm, err.Error())\n\t\t}\n\t\tif v {\n\t\t\treturn otto.UndefinedValue()\n\t\t}\n\t\tmsg := \"assertion failed!\"\n\t\tif len(call.ArgumentList) > 1 {\n\t\t\tformat, err := call.ArgumentList[1].ToString()\n\t\t\tif err != nil {\n\t\t\t\tottoutil.Throw(vm, err.Error())\n\t\t\t}\n\t\t\tmsg += \"\\n\" + format\n\t\t}\n\t\tottoutil.Throw(vm, msg)\n\t\treturn otto.UndefinedValue()\n\t})\n\tscript, err := vm.Compile(\"\", src)\n\tif err != nil {\n\t\tt.Fatalf(\"invalid code: %v\", err)\n\t}\n\n\tfor _, opt := range opts {\n\t\tif err := opt(vm); err != nil {\n\t\t\tt.Fatalf(\"can't apply option: %v\", err)\n\t\t}\n\t}\n\n\tif _, err := vm.Run(script); err != nil {\n\t\tif oe, ok := err.(*otto.Error); ok {\n\t\t\tt.Fatal(oe.String())\n\t\t} else {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}\n}", "func TestSetGoodArgs(t *testing.T) {\n\tfmt.Println(\"Entering the test method for SetGoodArgs\")\n\tprovcc := new(SimpleAsset)\n\tstub := shim.NewMockStub(\"ANY_PARAM\", provcc)\n\n\t// Testing the init. It always return true. No parameters in init. \n\t\n\tcheckInit(t, stub, [][]byte{[]byte(\"init\")})\n\n\tres := stub.MockInvoke(\"1\", [][]byte{[]byte(\"set\"), []byte(\"S52fkpF2rCEArSuwqyDA9tVjawUdrkGzbNQLaa7xJfA=\"),\n\t[]byte(\"agentInfo.atype\"),[]byte(\"1.2.3.4\"),\n\t[]byte(\"agentInfo.id\"),[]byte(\"agentidentifier\"),\n\t[]byte(\"agentinfo.name\"),[]byte(\"7.8.9\"),\n\t[]byte(\"agentinfo.idp\"),[]byte(\"urn:tiani-spirit:sts\"),\n\t[]byte(\"locationInfo.id\"),[]byte(\"urn:oid:1.2.3\"),\n\t[]byte(\"locationInfo.name\"),[]byte(\"General Hospital\"),\n\t[]byte(\"locationInfo.locality\"),[]byte(\"Nashville, TN\"),\n\t[]byte(\"locationInfo.docid\"),[]byte(\"1.2.3\"),\n\t[]byte(\"action\"),[]byte(\"ex:CREATE\"),\n\t[]byte(\"date\"),[]byte(\"2018-11-10T12:15:55.028Z\")})\n\n\tif res.Status != shim.OK {\n\t\tfmt.Println(\"Invoke failed\", string(res.Message))\n\t\tt.FailNow()\n\t}\n\t\n}", "func (mmRegisterResult *mClientMockRegisterResult) Expect(ctx context.Context, request insolar.Reference, result RequestResult) *mClientMockRegisterResult {\n\tif mmRegisterResult.mock.funcRegisterResult != nil {\n\t\tmmRegisterResult.mock.t.Fatalf(\"ClientMock.RegisterResult mock is already set by Set\")\n\t}\n\n\tif mmRegisterResult.defaultExpectation == nil {\n\t\tmmRegisterResult.defaultExpectation = &ClientMockRegisterResultExpectation{}\n\t}\n\n\tmmRegisterResult.defaultExpectation.params = &ClientMockRegisterResultParams{ctx, request, result}\n\tfor _, e := range mmRegisterResult.expectations {\n\t\tif minimock.Equal(e.params, mmRegisterResult.defaultExpectation.params) {\n\t\t\tmmRegisterResult.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmRegisterResult.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmRegisterResult\n}", "func (m *MockS3API) EXPECT() *MockS3APIMockRecorder {\n\treturn m.recorder\n}", "func Mock() Cluster { return mockCluster{} }", "func mockedGranter(kubeutil *kube.Kube, app *v1.RadixRegistration, namespace string, serviceAccount *corev1.ServiceAccount) error {\n\treturn nil\n}", "func (mmGetPendings *mClientMockGetPendings) Expect(ctx context.Context, objectRef insolar.Reference) *mClientMockGetPendings {\n\tif mmGetPendings.mock.funcGetPendings != nil {\n\t\tmmGetPendings.mock.t.Fatalf(\"ClientMock.GetPendings mock is already set by Set\")\n\t}\n\n\tif mmGetPendings.defaultExpectation == nil {\n\t\tmmGetPendings.defaultExpectation = &ClientMockGetPendingsExpectation{}\n\t}\n\n\tmmGetPendings.defaultExpectation.params = &ClientMockGetPendingsParams{ctx, objectRef}\n\tfor _, e := range mmGetPendings.expectations {\n\t\tif minimock.Equal(e.params, mmGetPendings.defaultExpectation.params) {\n\t\t\tmmGetPendings.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmGetPendings.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmGetPendings\n}", "func (m *MockOrg) EXPECT() *MockOrgMockRecorder {\n\treturn m.recorder\n}", "func (mmGetUserLocation *mStorageMockGetUserLocation) Expect(ctx context.Context, userID int64) *mStorageMockGetUserLocation {\n\tif mmGetUserLocation.mock.funcGetUserLocation != nil {\n\t\tmmGetUserLocation.mock.t.Fatalf(\"StorageMock.GetUserLocation mock is already set by Set\")\n\t}\n\n\tif mmGetUserLocation.defaultExpectation == nil {\n\t\tmmGetUserLocation.defaultExpectation = &StorageMockGetUserLocationExpectation{}\n\t}\n\n\tmmGetUserLocation.defaultExpectation.params = &StorageMockGetUserLocationParams{ctx, userID}\n\tfor _, e := range mmGetUserLocation.expectations {\n\t\tif minimock.Equal(e.params, mmGetUserLocation.defaultExpectation.params) {\n\t\t\tmmGetUserLocation.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmGetUserLocation.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmGetUserLocation\n}", "func (mmCreate *mPaymentRepositoryMockCreate) Expect(ctx context.Context, from int64, to int64, amount int64) *mPaymentRepositoryMockCreate {\n\tif mmCreate.mock.funcCreate != nil {\n\t\tmmCreate.mock.t.Fatalf(\"PaymentRepositoryMock.Create mock is already set by Set\")\n\t}\n\n\tif mmCreate.defaultExpectation == nil {\n\t\tmmCreate.defaultExpectation = &PaymentRepositoryMockCreateExpectation{}\n\t}\n\n\tmmCreate.defaultExpectation.params = &PaymentRepositoryMockCreateParams{ctx, from, to, amount}\n\tfor _, e := range mmCreate.expectations {\n\t\tif minimock.Equal(e.params, mmCreate.defaultExpectation.params) {\n\t\t\tmmCreate.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmCreate.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmCreate\n}", "func (mmAuther *mGatewayMockAuther) Expect() *mGatewayMockAuther {\n\tif mmAuther.mock.funcAuther != nil {\n\t\tmmAuther.mock.t.Fatalf(\"GatewayMock.Auther mock is already set by Set\")\n\t}\n\n\tif mmAuther.defaultExpectation == nil {\n\t\tmmAuther.defaultExpectation = &GatewayMockAutherExpectation{}\n\t}\n\n\treturn mmAuther\n}", "func (mmInvoke *mContainerMockInvoke) Expect(function interface{}) *mContainerMockInvoke {\n\tif mmInvoke.mock.funcInvoke != nil {\n\t\tmmInvoke.mock.t.Fatalf(\"ContainerMock.Invoke mock is already set by Set\")\n\t}\n\n\tif mmInvoke.defaultExpectation == nil {\n\t\tmmInvoke.defaultExpectation = &ContainerMockInvokeExpectation{}\n\t}\n\n\tmmInvoke.defaultExpectation.params = &ContainerMockInvokeParams{function}\n\tfor _, e := range mmInvoke.expectations {\n\t\tif minimock.Equal(e.params, mmInvoke.defaultExpectation.params) {\n\t\t\tmmInvoke.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmInvoke.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmInvoke\n}", "func TestObjectsMeetReq(t *testing.T) {\n\tvar kr verifiable.StorageReader\n\tvar kw verifiable.StorageWriter\n\n\tvar m verifiable.MutatorService\n\n\tvar o verifiable.AuthorizationOracle\n\n\tkr = &memory.TransientStorage{}\n\tkw = &memory.TransientStorage{}\n\n\tkr = &bolt.Storage{}\n\tkw = &bolt.Storage{}\n\n\tkr = &badger.Storage{}\n\tkw = &badger.Storage{}\n\n\tm = &instant.Mutator{}\n\tm = (&batch.Mutator{}).MustCreate()\n\n\to = policy.Open\n\to = &policy.Static{}\n\n\tlog.Println(kr, kw, m, o) // \"use\" these so that go compiler will be quiet\n}", "func (mmGetPosition *mStoreMockGetPosition) Expect(account string, contractID string) *mStoreMockGetPosition {\n\tif mmGetPosition.mock.funcGetPosition != nil {\n\t\tmmGetPosition.mock.t.Fatalf(\"StoreMock.GetPosition mock is already set by Set\")\n\t}\n\n\tif mmGetPosition.defaultExpectation == nil {\n\t\tmmGetPosition.defaultExpectation = &StoreMockGetPositionExpectation{}\n\t}\n\n\tmmGetPosition.defaultExpectation.params = &StoreMockGetPositionParams{account, contractID}\n\tfor _, e := range mmGetPosition.expectations {\n\t\tif minimock.Equal(e.params, mmGetPosition.defaultExpectation.params) {\n\t\t\tmmGetPosition.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmGetPosition.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmGetPosition\n}", "func (mmGetAbandonedRequest *mClientMockGetAbandonedRequest) Expect(ctx context.Context, objectRef insolar.Reference, reqRef insolar.Reference) *mClientMockGetAbandonedRequest {\n\tif mmGetAbandonedRequest.mock.funcGetAbandonedRequest != nil {\n\t\tmmGetAbandonedRequest.mock.t.Fatalf(\"ClientMock.GetAbandonedRequest mock is already set by Set\")\n\t}\n\n\tif mmGetAbandonedRequest.defaultExpectation == nil {\n\t\tmmGetAbandonedRequest.defaultExpectation = &ClientMockGetAbandonedRequestExpectation{}\n\t}\n\n\tmmGetAbandonedRequest.defaultExpectation.params = &ClientMockGetAbandonedRequestParams{ctx, objectRef, reqRef}\n\tfor _, e := range mmGetAbandonedRequest.expectations {\n\t\tif minimock.Equal(e.params, mmGetAbandonedRequest.defaultExpectation.params) {\n\t\t\tmmGetAbandonedRequest.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmGetAbandonedRequest.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmGetAbandonedRequest\n}", "func expectEqual(actual interface{}, extra interface{}, explain ...interface{}) {\n\tgomega.ExpectWithOffset(1, actual).To(gomega.Equal(extra), explain...)\n}", "func (mmSend *mSenderMockSend) Expect(ctx context.Context, email Email) *mSenderMockSend {\n\tif mmSend.mock.funcSend != nil {\n\t\tmmSend.mock.t.Fatalf(\"SenderMock.Send mock is already set by Set\")\n\t}\n\n\tif mmSend.defaultExpectation == nil {\n\t\tmmSend.defaultExpectation = &SenderMockSendExpectation{}\n\t}\n\n\tmmSend.defaultExpectation.params = &SenderMockSendParams{ctx, email}\n\tfor _, e := range mmSend.expectations {\n\t\tif minimock.Equal(e.params, mmSend.defaultExpectation.params) {\n\t\t\tmmSend.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmSend.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmSend\n}", "func (m *Mockrequester) EXPECT() *MockrequesterMockRecorder {\n\treturn m.recorder\n}", "func callAndVerify(msg string, client pb.GreeterClient, shouldFail bool) error {\n\tctx, cancel := context.WithTimeout(context.Background(), time.Second)\n\tdefer cancel()\n\t_, err := client.SayHello(ctx, &pb.HelloRequest{Name: msg})\n\tif want, got := shouldFail == true, err != nil; got != want {\n\t\treturn fmt.Errorf(\"want and got mismatch, want shouldFail=%v, got fail=%v, rpc error: %v\", want, got, err)\n\t}\n\treturn nil\n}", "func (m *MockstackDescriber) EXPECT() *MockstackDescriberMockRecorder {\n\treturn m.recorder\n}", "func (req *outgoingRequest) Assert(t *testing.T, fixture *fixture) {\n\tassert.Equal(t, req.path, fixture.calledPath, \"called path not as expected\")\n\tassert.Equal(t, req.method, fixture.calledMethod, \"called path not as expected\")\n\tassert.Equal(t, req.body, fixture.requestBody, \"call body no as expected\")\n}", "func (mmVerify *mDelegationTokenFactoryMockVerify) Expect(parcel mm_insolar.Parcel) *mDelegationTokenFactoryMockVerify {\n\tif mmVerify.mock.funcVerify != nil {\n\t\tmmVerify.mock.t.Fatalf(\"DelegationTokenFactoryMock.Verify mock is already set by Set\")\n\t}\n\n\tif mmVerify.defaultExpectation == nil {\n\t\tmmVerify.defaultExpectation = &DelegationTokenFactoryMockVerifyExpectation{}\n\t}\n\n\tmmVerify.defaultExpectation.params = &DelegationTokenFactoryMockVerifyParams{parcel}\n\tfor _, e := range mmVerify.expectations {\n\t\tif minimock.Equal(e.params, mmVerify.defaultExpectation.params) {\n\t\t\tmmVerify.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmVerify.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmVerify\n}", "func (mmRead *mDigestHolderMockRead) Expect(p []byte) *mDigestHolderMockRead {\n\tif mmRead.mock.funcRead != nil {\n\t\tmmRead.mock.t.Fatalf(\"DigestHolderMock.Read mock is already set by Set\")\n\t}\n\n\tif mmRead.defaultExpectation == nil {\n\t\tmmRead.defaultExpectation = &DigestHolderMockReadExpectation{}\n\t}\n\n\tmmRead.defaultExpectation.params = &DigestHolderMockReadParams{p}\n\tfor _, e := range mmRead.expectations {\n\t\tif minimock.Equal(e.params, mmRead.defaultExpectation.params) {\n\t\t\tmmRead.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmRead.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmRead\n}", "func (mmSend *mClientMockSend) Expect(ctx context.Context, n *Notification) *mClientMockSend {\n\tif mmSend.mock.funcSend != nil {\n\t\tmmSend.mock.t.Fatalf(\"ClientMock.Send mock is already set by Set\")\n\t}\n\n\tif mmSend.defaultExpectation == nil {\n\t\tmmSend.defaultExpectation = &ClientMockSendExpectation{}\n\t}\n\n\tmmSend.defaultExpectation.params = &ClientMockSendParams{ctx, n}\n\tfor _, e := range mmSend.expectations {\n\t\tif minimock.Equal(e.params, mmSend.defaultExpectation.params) {\n\t\t\tmmSend.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmSend.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmSend\n}", "func (mmAsByteString *mDigestHolderMockAsByteString) Expect() *mDigestHolderMockAsByteString {\n\tif mmAsByteString.mock.funcAsByteString != nil {\n\t\tmmAsByteString.mock.t.Fatalf(\"DigestHolderMock.AsByteString mock is already set by Set\")\n\t}\n\n\tif mmAsByteString.defaultExpectation == nil {\n\t\tmmAsByteString.defaultExpectation = &DigestHolderMockAsByteStringExpectation{}\n\t}\n\n\treturn mmAsByteString\n}", "func Expect(msg string) error {\n\tif msg != \"\" {\n\t\treturn errors.New(msg)\n\t} else {\n\t\treturn nil\n\t}\n}", "func (mmEncrypt *mRingMockEncrypt) Expect(t1 secrets.Text) *mRingMockEncrypt {\n\tif mmEncrypt.mock.funcEncrypt != nil {\n\t\tmmEncrypt.mock.t.Fatalf(\"RingMock.Encrypt mock is already set by Set\")\n\t}\n\n\tif mmEncrypt.defaultExpectation == nil {\n\t\tmmEncrypt.defaultExpectation = &RingMockEncryptExpectation{}\n\t}\n\n\tmmEncrypt.defaultExpectation.params = &RingMockEncryptParams{t1}\n\tfor _, e := range mmEncrypt.expectations {\n\t\tif minimock.Equal(e.params, mmEncrypt.defaultExpectation.params) {\n\t\t\tmmEncrypt.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmEncrypt.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmEncrypt\n}", "func (mmBootstrapper *mGatewayMockBootstrapper) Expect() *mGatewayMockBootstrapper {\n\tif mmBootstrapper.mock.funcBootstrapper != nil {\n\t\tmmBootstrapper.mock.t.Fatalf(\"GatewayMock.Bootstrapper mock is already set by Set\")\n\t}\n\n\tif mmBootstrapper.defaultExpectation == nil {\n\t\tmmBootstrapper.defaultExpectation = &GatewayMockBootstrapperExpectation{}\n\t}\n\n\treturn mmBootstrapper\n}", "func (m *MockNotary) EXPECT() *MockNotaryMockRecorder {\n\treturn m.recorder\n}", "func (m *mParcelMockSetSender) Expect(p insolar.Reference) *mParcelMockSetSender {\n\tm.mock.SetSenderFunc = nil\n\tm.expectationSeries = nil\n\n\tif m.mainExpectation == nil {\n\t\tm.mainExpectation = &ParcelMockSetSenderExpectation{}\n\t}\n\tm.mainExpectation.input = &ParcelMockSetSenderInput{p}\n\treturn m\n}", "func (mmGetPacketType *mPacketParserMockGetPacketType) Expect() *mPacketParserMockGetPacketType {\n\tif mmGetPacketType.mock.funcGetPacketType != nil {\n\t\tmmGetPacketType.mock.t.Fatalf(\"PacketParserMock.GetPacketType mock is already set by Set\")\n\t}\n\n\tif mmGetPacketType.defaultExpectation == nil {\n\t\tmmGetPacketType.defaultExpectation = &PacketParserMockGetPacketTypeExpectation{}\n\t}\n\n\treturn mmGetPacketType\n}", "func (mmParsePacketBody *mPacketParserMockParsePacketBody) Expect() *mPacketParserMockParsePacketBody {\n\tif mmParsePacketBody.mock.funcParsePacketBody != nil {\n\t\tmmParsePacketBody.mock.t.Fatalf(\"PacketParserMock.ParsePacketBody mock is already set by Set\")\n\t}\n\n\tif mmParsePacketBody.defaultExpectation == nil {\n\t\tmmParsePacketBody.defaultExpectation = &PacketParserMockParsePacketBodyExpectation{}\n\t}\n\n\treturn mmParsePacketBody\n}", "func (mmAsBytes *mDigestHolderMockAsBytes) Expect() *mDigestHolderMockAsBytes {\n\tif mmAsBytes.mock.funcAsBytes != nil {\n\t\tmmAsBytes.mock.t.Fatalf(\"DigestHolderMock.AsBytes mock is already set by Set\")\n\t}\n\n\tif mmAsBytes.defaultExpectation == nil {\n\t\tmmAsBytes.defaultExpectation = &DigestHolderMockAsBytesExpectation{}\n\t}\n\n\treturn mmAsBytes\n}", "func (mmKey *mIteratorMockKey) Expect() *mIteratorMockKey {\n\tif mmKey.mock.funcKey != nil {\n\t\tmmKey.mock.t.Fatalf(\"IteratorMock.Key mock is already set by Set\")\n\t}\n\n\tif mmKey.defaultExpectation == nil {\n\t\tmmKey.defaultExpectation = &IteratorMockKeyExpectation{}\n\t}\n\n\treturn mmKey\n}", "func (m *MockArticleLogic) EXPECT() *MockArticleLogicMockRecorder {\n\treturn m.recorder\n}", "func (m *MockFactory) EXPECT() *MockFactoryMockRecorder {\n\treturn m.recorder\n}", "func (m *MockFactory) EXPECT() *MockFactoryMockRecorder {\n\treturn m.recorder\n}", "func (m *MockFactory) EXPECT() *MockFactoryMockRecorder {\n\treturn m.recorder\n}", "func (m *mOutboundMockCanAccept) Expect(p Inbound) *mOutboundMockCanAccept {\n\tm.mock.CanAcceptFunc = nil\n\tm.expectationSeries = nil\n\n\tif m.mainExpectation == nil {\n\t\tm.mainExpectation = &OutboundMockCanAcceptExpectation{}\n\t}\n\tm.mainExpectation.input = &OutboundMockCanAcceptInput{p}\n\treturn m\n}", "func (m *MockLoaderFactory) EXPECT() *MockLoaderFactoryMockRecorder {\n\treturn m.recorder\n}", "func (m *MockPKG) EXPECT() *MockPKGMockRecorder {\n\treturn m.recorder\n}", "func (m *MockbucketDescriber) EXPECT() *MockbucketDescriberMockRecorder {\n\treturn m.recorder\n}", "func (m *mParcelMockType) Expect() *mParcelMockType {\n\tm.mock.TypeFunc = nil\n\tm.expectationSeries = nil\n\n\tif m.mainExpectation == nil {\n\t\tm.mainExpectation = &ParcelMockTypeExpectation{}\n\t}\n\n\treturn m\n}", "func (m *MockKeystore) EXPECT() *MockKeystoreMockRecorder {\n\treturn m.recorder\n}", "func (m *MockKeystore) EXPECT() *MockKeystoreMockRecorder {\n\treturn m.recorder\n}", "func (mmExchange *mMDNSClientMockExchange) Expect(msg *mdns.Msg, address string) *mMDNSClientMockExchange {\n\tif mmExchange.mock.funcExchange != nil {\n\t\tmmExchange.mock.t.Fatalf(\"MDNSClientMock.Exchange mock is already set by Set\")\n\t}\n\n\tif mmExchange.defaultExpectation == nil {\n\t\tmmExchange.defaultExpectation = &MDNSClientMockExchangeExpectation{}\n\t}\n\n\tmmExchange.defaultExpectation.params = &MDNSClientMockExchangeParams{msg, address}\n\tfor _, e := range mmExchange.expectations {\n\t\tif minimock.Equal(e.params, mmExchange.defaultExpectation.params) {\n\t\t\tmmExchange.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmExchange.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmExchange\n}", "func (m *MockStream) EXPECT() *MockStreamMockRecorder {\n\treturn m.recorder\n}", "func (c Chkr) Expect(v validator, args ...interface{}) {\n\tif c.runTest(v, args...) {\n\t\tc.Fail()\n\t}\n}", "func (mmClone *mStorageMockClone) Expect(ctx context.Context, from insolar.PulseNumber, to insolar.PulseNumber, keepActual bool) *mStorageMockClone {\n\tif mmClone.mock.funcClone != nil {\n\t\tmmClone.mock.t.Fatalf(\"StorageMock.Clone mock is already set by Set\")\n\t}\n\n\tif mmClone.defaultExpectation == nil {\n\t\tmmClone.defaultExpectation = &StorageMockCloneExpectation{}\n\t}\n\n\tmmClone.defaultExpectation.params = &StorageMockCloneParams{ctx, from, to, keepActual}\n\tfor _, e := range mmClone.expectations {\n\t\tif minimock.Equal(e.params, mmClone.defaultExpectation.params) {\n\t\t\tmmClone.mock.t.Fatalf(\"Expectation set by When has same params: %#v\", *mmClone.defaultExpectation.params)\n\t\t}\n\t}\n\n\treturn mmClone\n}", "func (m *MockCodeGenerator) EXPECT() *MockCodeGeneratorMockRecorder {\n\treturn m.recorder\n}", "func (m *MockNodeAttestor) EXPECT() *MockNodeAttestorMockRecorder {\n\treturn m.recorder\n}", "func (m *MockNodeAttestor) EXPECT() *MockNodeAttestorMockRecorder {\n\treturn m.recorder\n}", "func (_m *MockIStream) EXPECT() *MockIStreamMockRecorder {\n\treturn _m.recorder\n}", "func (m *mOutboundMockGetEndpointType) Expect() *mOutboundMockGetEndpointType {\n\tm.mock.GetEndpointTypeFunc = nil\n\tm.expectationSeries = nil\n\n\tif m.mainExpectation == nil {\n\t\tm.mainExpectation = &OutboundMockGetEndpointTypeExpectation{}\n\t}\n\n\treturn m\n}", "func (m *MockAZInfoProvider) EXPECT() *MockAZInfoProviderMockRecorder {\n\treturn m.recorder\n}" ]
[ "0.58169925", "0.571553", "0.5674476", "0.5640405", "0.562928", "0.5574723", "0.556962", "0.5530448", "0.550884", "0.5488494", "0.5474579", "0.5464561", "0.54615927", "0.54421943", "0.544173", "0.5407415", "0.54029363", "0.5390068", "0.53847593", "0.53847593", "0.5371173", "0.536972", "0.5359692", "0.534205", "0.5340419", "0.53292346", "0.5323524", "0.5313875", "0.530878", "0.5308145", "0.5308145", "0.5308145", "0.5308145", "0.5308145", "0.5308145", "0.5308145", "0.5308145", "0.5303667", "0.52966684", "0.52966684", "0.52915996", "0.5283216", "0.5282378", "0.52789223", "0.52753484", "0.5274766", "0.5265833", "0.5260114", "0.52583355", "0.5256263", "0.5255503", "0.5248704", "0.52430737", "0.52425617", "0.5239578", "0.5237592", "0.52367103", "0.52288496", "0.52258", "0.5223699", "0.52156955", "0.52140796", "0.5213764", "0.5213052", "0.52121735", "0.5209883", "0.5195822", "0.51916826", "0.51895916", "0.5188694", "0.5188263", "0.51853484", "0.5183852", "0.5176936", "0.5174346", "0.5170227", "0.5168422", "0.5164617", "0.5162764", "0.516157", "0.51612335", "0.5145313", "0.5145313", "0.5145313", "0.5145004", "0.5144547", "0.5140501", "0.5135879", "0.5135229", "0.51350814", "0.51350814", "0.51314574", "0.51309603", "0.5130878", "0.51252097", "0.5123687", "0.51181895", "0.51181895", "0.5116335", "0.5115415", "0.5110061" ]
0.0
-1
Auth mocks base method
func (m *MockServiceAuth) Auth(arg0 models.UserInput) (models.UserBoardsOutside, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Auth", arg0) ret0, _ := ret[0].(models.UserBoardsOutside) ret1, _ := ret[1].(error) return ret0, ret1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestAuthRequestGetters(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"foo\", func(r res.AuthRequest) {\n\t\t\trestest.AssertEqualJSON(t, \"Method\", r.Method(), \"foo\")\n\t\t\trestest.AssertEqualJSON(t, \"CID\", r.CID(), mock.CID)\n\t\t\trestest.AssertEqualJSON(t, \"Header\", r.Header(), mock.Header)\n\t\t\trestest.AssertEqualJSON(t, \"Host\", r.Host(), mock.Host)\n\t\t\trestest.AssertEqualJSON(t, \"RemoteAddr\", r.RemoteAddr(), mock.RemoteAddr)\n\t\t\trestest.AssertEqualJSON(t, \"URI\", r.URI(), mock.URI)\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"foo\", nil).\n\t\t\tResponse().\n\t\t\tAssertError(res.ErrNotFound)\n\t})\n}", "func (_m *Remote) Auth(token string, secret string) (string, error) {\n\tret := _m.Called(token, secret)\n\n\tvar r0 string\n\tif rf, ok := ret.Get(0).(func(string, string) string); ok {\n\t\tr0 = rf(token, secret)\n\t} else {\n\t\tr0 = ret.Get(0).(string)\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(string, string) error); ok {\n\t\tr1 = rf(token, secret)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func TestAuth(t *testing.T) {\n\tl := logger.NewNoop()\n\n\tserv, err := server.New(l)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tclient := authv1.HTTPTestAuthServiceClient{}\n\tclient.Client = serv\n\n\ttest(t, \"client auth\", 0, func(t *testing.T, i int) {\n\t\tvar authid string\n\t\tconst (\n\t\t\tusername = \"kili-test\"\n\t\t\temail = \"uhh@eee@aaa\"\n\t\t\tpassword = \"kala-test\"\n\t\t)\n\n\t\ttest(t, \"begin auth\", i, beginAuth(client, &authid))\n\t\ttest(t, \"first auth step\", i, firstAuthStep(client, authid, \"register\"))\n\t\ttest(t, \"get register form\", i, formAuthStep(client, authid, \"register\"))\n\n\t\ttest(t, \"register account\", i, register(client, authid, username, email, password))\n\n\t\ttest(t, \"begin auth again\", i, beginAuth(client, &authid))\n\t\ttest(t, \"first auth step again\", i, firstAuthStep(client, authid, \"login\"))\n\t\ttest(t, \"get login form\", i, formAuthStep(client, authid, \"login\"))\n\n\t\ttest(t, \"login account\", i, login(client, authid, email, password))\n\t})\n}", "func (_m *Forge) Auth(ctx context.Context, token string, secret string) (string, error) {\n\tret := _m.Called(ctx, token, secret)\n\n\tvar r0 string\n\tvar r1 error\n\tif rf, ok := ret.Get(0).(func(context.Context, string, string) (string, error)); ok {\n\t\treturn rf(ctx, token, secret)\n\t}\n\tif rf, ok := ret.Get(0).(func(context.Context, string, string) string); ok {\n\t\tr0 = rf(ctx, token, secret)\n\t} else {\n\t\tr0 = ret.Get(0).(string)\n\t}\n\n\tif rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {\n\t\tr1 = rf(ctx, token, secret)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (m *MockSession) Auth() error {\n\targs := m.Mock.Called()\n\treturn args.Error(0)\n}", "func (suite *SubscriptionsTestSuite) mockUserAuth(user *accounts.User) {\n\t// Mock GetConfig call to return the config object\n\tsuite.accountsServiceMock.On(\"GetConfig\").Return(suite.cnf)\n\n\t// Mock GetOauthService to return a mock oauth service\n\tsuite.accountsServiceMock.On(\"GetOauthService\").Return(suite.oauthServiceMock)\n\n\t// Mock Authenticate to return a mock access token\n\tmockOauthAccessToken := &oauth.AccessToken{User: user.OauthUser}\n\tsuite.oauthServiceMock.On(\"Authenticate\", \"test_token\").\n\t\tReturn(mockOauthAccessToken, nil)\n\n\t// Mock FindUserByOauthUserID to return the wanted user\n\tsuite.accountsServiceMock.On(\"FindUserByOauthUserID\", user.OauthUser.ID).\n\t\tReturn(user, nil)\n}", "func mockTestUserInteraction(ctx context.Context, pro providerParams, username, password string) (string, error) {\n\tctx, cancel := context.WithTimeout(ctx, 10*time.Second)\n\tdefer cancel()\n\n\tprovider, err := oidc.NewProvider(ctx, pro.providerURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to create provider: %v\", err)\n\t}\n\n\t// Configure an OpenID Connect aware OAuth2 client.\n\toauth2Config := oauth2.Config{\n\t\tClientID: pro.clientID,\n\t\tClientSecret: pro.clientSecret,\n\t\tRedirectURL: pro.redirectURL,\n\n\t\t// Discovery returns the OAuth2 endpoints.\n\t\tEndpoint: provider.Endpoint(),\n\n\t\t// \"openid\" is a required scope for OpenID Connect flows.\n\t\tScopes: []string{oidc.ScopeOpenID, \"groups\"},\n\t}\n\n\tstate := \"xxx\"\n\tauthCodeURL := oauth2Config.AuthCodeURL(state)\n\t// fmt.Printf(\"authcodeurl: %s\\n\", authCodeURL)\n\n\tvar lastReq *http.Request\n\tcheckRedirect := func(req *http.Request, via []*http.Request) error {\n\t\t// fmt.Printf(\"CheckRedirect:\\n\")\n\t\t// fmt.Printf(\"Upcoming: %s %#v\\n\", req.URL.String(), req)\n\t\t// for _, c := range via {\n\t\t// \tfmt.Printf(\"Sofar: %s %#v\\n\", c.URL.String(), c)\n\t\t// }\n\t\t// Save the last request in a redirect chain.\n\t\tlastReq = req\n\t\t// We do not follow redirect back to client application.\n\t\tif req.URL.Path == \"/oauth_callback\" {\n\t\t\treturn http.ErrUseLastResponse\n\t\t}\n\t\treturn nil\n\t}\n\n\tdexClient := http.Client{\n\t\tCheckRedirect: checkRedirect,\n\t}\n\n\tu, err := url.Parse(authCodeURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"url parse err: %v\", err)\n\t}\n\n\t// Start the user auth flow. This page would present the login with\n\t// email or LDAP option.\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"new request err: %v\", err)\n\t}\n\t_, err = dexClient.Do(req)\n\t// fmt.Printf(\"Do: %#v %#v\\n\", resp, err)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"auth url request err: %v\", err)\n\t}\n\n\t// Modify u to choose the ldap option\n\tu.Path += \"/ldap\"\n\t// fmt.Println(u)\n\n\t// Pick the LDAP login option. This would return a form page after\n\t// following some redirects. `lastReq` would be the URL of the form\n\t// page, where we need to POST (submit) the form.\n\treq, err = http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"new request err (/ldap): %v\", err)\n\t}\n\t_, err = dexClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"request err: %v\", err)\n\t}\n\n\t// Fill the login form with our test creds:\n\t// fmt.Printf(\"login form url: %s\\n\", lastReq.URL.String())\n\tformData := url.Values{}\n\tformData.Set(\"login\", username)\n\tformData.Set(\"password\", password)\n\treq, err = http.NewRequestWithContext(ctx, http.MethodPost, lastReq.URL.String(), strings.NewReader(formData.Encode()))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"new request err (/login): %v\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\t_, err = dexClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"post form err: %v\", err)\n\t}\n\t// fmt.Printf(\"resp: %#v %#v\\n\", resp.StatusCode, resp.Header)\n\t// fmt.Printf(\"lastReq: %#v\\n\", lastReq.URL.String())\n\n\t// On form submission, the last redirect response contains the auth\n\t// code, which we now have in `lastReq`. Exchange it for a JWT id_token.\n\tq := lastReq.URL.Query()\n\tcode := q.Get(\"code\")\n\toauth2Token, err := oauth2Config.Exchange(ctx, code)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to exchange code for id token: %v\", err)\n\t}\n\n\trawIDToken, ok := oauth2Token.Extra(\"id_token\").(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"id_token not found!\")\n\t}\n\n\t// fmt.Printf(\"TOKEN: %s\\n\", rawIDToken)\n\treturn rawIDToken, nil\n}", "func (_m *MockAuthServiceServer) Auth(_a0 context.Context, _a1 *AuthRequest) (*AuthResponse, error) {\n\tret := _m.Called(_a0, _a1)\n\n\tvar r0 *AuthResponse\n\tif rf, ok := ret.Get(0).(func(context.Context, *AuthRequest) *AuthResponse); ok {\n\t\tr0 = rf(_a0, _a1)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*AuthResponse)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, *AuthRequest) error); ok {\n\t\tr1 = rf(_a0, _a1)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (suite *SubscriptionsTestSuite) mockClientAuth(account *accounts.Account) {\n\t// Mock GetConfig call to return the config object\n\tsuite.accountsServiceMock.On(\"GetConfig\").Return(suite.cnf)\n\n\t// Mock GetOauthService to return a mock oauth service\n\tsuite.accountsServiceMock.On(\"GetOauthService\").Return(suite.oauthServiceMock)\n\n\t// Mock AuthClient to return a mock client\n\tsuite.oauthServiceMock.On(\"AuthClient\", \"test_client_1\", \"test_secret\").\n\t\tReturn(account.OauthClient, nil)\n\n\t// Mock FindAccountByOauthClientID to return the wanted account\n\tsuite.accountsServiceMock.\n\t\tOn(\"FindAccountByOauthClientID\", account.OauthClient.ID).\n\t\tReturn(account, nil)\n}", "func newAuthorizationMocks(t *testing.T, resource, action string) (\n\tauthn.AuthenticationServiceClient, authz.AuthorizationServiceClient) {\n\tvar (\n\t\tctrl = gomock.NewController(t)\n\t\tmockAuthClient = authn.NewMockAuthenticationServiceClient(ctrl)\n\t\tmockAuthzClient = authz.NewMockAuthorizationServiceClient(ctrl)\n\t)\n\n\t// Mocking AuthN Calls\n\tmockAuthClient.EXPECT().Authenticate(gomock.Any(), gomock.Any()).DoAndReturn(\n\t\tfunc(_ context.Context, _ *authn.AuthenticateRequest) (*authn.AuthenticateResponse, error) {\n\t\t\treturn &authn.AuthenticateResponse{Subject: \"mock\", Teams: []string{}}, nil\n\t\t})\n\n\t// Mocking AuthZ Calls\n\tmockAuthzClient.EXPECT().ProjectsAuthorized(\n\t\tgomock.Any(),\n\t\t&authz.ProjectsAuthorizedReq{\n\t\t\tSubjects: []string{\"mock\"},\n\t\t\tResource: resource,\n\t\t\tAction: action,\n\t\t\tProjectsFilter: []string{},\n\t\t},\n\t).DoAndReturn(\n\t\tfunc(_ context.Context, _ *authz.ProjectsAuthorizedReq) (*authz.ProjectsAuthorizedResp, error) {\n\t\t\treturn &authz.ProjectsAuthorizedResp{Projects: []string{\"any\"}}, nil\n\t\t},\n\t)\n\n\treturn mockAuthClient, mockAuthzClient\n}", "func TestAuthOK(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.OK(mock.Result)\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"method\", nil).\n\t\t\tResponse().\n\t\t\tAssertResult(mock.Result)\n\t})\n}", "func NewAuthMock(l auth.Logger) *AuthMock {\n\treturn &AuthMock{*auth.New(l)}\n}", "func AuthTester(t *testing.T, auth Auth, reqAuth Auth) {\n\tassert := assert.New(t)\n\tassert.Equal(auth.Username, reqAuth.Username, \"Usernames should be equal\")\n\tassert.Equal(auth.Password, reqAuth.Password, \"Passwords should be equal\")\n}", "func TestgetAuth(t *testing.T) {\n\tt.Parallel()\n\ta, err := getAuth()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif reflect.TypeOf(a).String() != \"*scaniigo.APIAuth\" {\n\t\tt.Error(ErrInvalidDataType)\n\t}\n}", "func (c *Client) auth() error {\n\tconst authEndpoint = apiEndpointBase + \"/v1/shim/login\"\n\tfprint, _ := json.Marshal(authVersion)\n\n\tauthRequest, _ := json.Marshal(authRequest{\n\t\tusername: c.Username,\n\t\tpassword: c.Password,\n\t\tfingerprint: string(fprint),\n\t})\n\n\tresp, err := http.DoPost(authEndpoint, basicAuth(c.Username, c.Password), authRequest)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tauthp := &authPayload{}\n\tif err := json.Unmarshal(resp, authp); err != nil {\n\t\treturn err\n\t}\n\n\tc.accessToken = authp.Oauth2.AccessToken\n\tc.expiry = time.Now().Add(time.Second * time.Duration(authp.Oauth2.ExpiresIn))\n\treturn nil\n}", "func NewMockAuth(t mockConstructorTestingTNewMockAuth) *MockAuth {\n\tmock := &MockAuth{}\n\tmock.Mock.Test(t)\n\n\tt.Cleanup(func() { mock.AssertExpectations(t) })\n\n\treturn mock\n}", "func TestAuthRawParams(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\trestest.AssertEqualJSON(t, \"RawParams\", r.RawParams(), mock.Params)\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\treq := mock.AuthRequest()\n\t\treq.Params = mock.Params\n\t\ts.Auth(\"test.model\", \"method\", req).\n\t\t\tResponse().\n\t\t\tAssertError(res.ErrNotFound)\n\t})\n}", "func WrapMockAuthConfig(hfn http.HandlerFunc, cfg *config.APICfg, brk brokers.Broker, str stores.Store, mgr *oldPush.Manager, c push.Client, roles ...string) http.HandlerFunc {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\n\t\turlVars := mux.Vars(r)\n\n\t\tuserRoles := []string{\"publisher\", \"consumer\"}\n\t\tif len(roles) > 0 {\n\t\t\tuserRoles = roles\n\t\t}\n\n\t\tnStr := str.Clone()\n\t\tdefer nStr.Close()\n\n\t\tprojectUUID := projects.GetUUIDByName(urlVars[\"project\"], nStr)\n\t\tgorillaContext.Set(r, \"auth_project_uuid\", projectUUID)\n\t\tgorillaContext.Set(r, \"brk\", brk)\n\t\tgorillaContext.Set(r, \"str\", nStr)\n\t\tgorillaContext.Set(r, \"mgr\", mgr)\n\t\tgorillaContext.Set(r, \"apsc\", c)\n\t\tgorillaContext.Set(r, \"auth_resource\", cfg.ResAuth)\n\t\tgorillaContext.Set(r, \"auth_user\", \"UserA\")\n\t\tgorillaContext.Set(r, \"auth_user_uuid\", \"uuid1\")\n\t\tgorillaContext.Set(r, \"auth_roles\", userRoles)\n\t\tgorillaContext.Set(r, \"push_worker_token\", cfg.PushWorkerToken)\n\t\tgorillaContext.Set(r, \"push_enabled\", cfg.PushEnabled)\n\t\thfn.ServeHTTP(w, r)\n\n\t})\n}", "func mockAuthenticationComponent(log *zap.Logger, serviceName string) *AuthenticationComponent {\n\thttpTimeout := 300 * time.Millisecond\n\n\treturn NewAuthenticationComponent(&AuthenticationParams{\n\t\tAuthConfig: &core_auth_sdk.Config{\n\t\t\tIssuer: issuer,\n\t\t\tPrivateBaseURL: privateBaseUrl,\n\t\t\tAudience: audience,\n\t\t\tUsername: username,\n\t\t\tPassword: password,\n\t\t\tKeychainTTL: 0,\n\t\t},\n\t\tAuthConnectionConfig: &core_auth_sdk.RetryConfig{\n\t\t\tMaxRetries: 1,\n\t\t\tMinRetryWaitTime: 200 * time.Millisecond,\n\t\t\tMaxRetryWaitTime: 300 * time.Millisecond,\n\t\t\tRequestTimeout: 500 * time.Millisecond,\n\t\t},\n\t\tLogger: log,\n\t\tOrigin: origin,\n\t}, serviceName, httpTimeout)\n}", "func (m *MockMessageHandler) CheckAuth(msg p2pcommon.Message, msgBody p2pcommon.MessageBody) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"CheckAuth\", msg, msgBody)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func TestAuthWithNil(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.OK(nil)\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"method\", nil).\n\t\t\tResponse().\n\t\t\tAssertResult(nil)\n\t})\n}", "func buildAuth() autoupdateHttp.Authenticator {\n\treturn fakeAuth(1)\n}", "func buildAuth() autoupdateHttp.Authenticator {\n\treturn fakeAuth(1)\n}", "func (m *MockDelegateActor) AuthenticateGetOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"AuthenticateGetOutbox\", c, w, r)\n\tret0, _ := ret[0].(context.Context)\n\tret1, _ := ret[1].(bool)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func TestAuthenticate(t *testing.T) {\n t.Errorf(\"No tests written yet for Authenticate()\")\n}", "func TestAuthRawToken(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\trestest.AssertEqualJSON(t, \"RawToken\", r.RawToken(), mock.Token)\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\treq := mock.AuthRequest()\n\t\treq.Token = mock.Token\n\t\ts.Auth(\"test.model\", \"method\", req).\n\t\t\tResponse().\n\t\t\tAssertError(res.ErrNotFound)\n\t})\n}", "func TestAuthCmd(t *testing.T) {\n\n\tcredentialmanager.MockAuthCreds = true\n\n\tendPoint, apiToken, err := credentialmanager.NewCredentialManager().GetCreds()\n\tif err != nil {\n\t\tt.Error(err)\n\t\treturn\n\t}\n\n\tcmd := fmt.Sprintf(\"auth --endpoint=%s --api-token=%s --mock\", endPoint.String(), apiToken)\n\t_, err = executeActionCommandC(cmd)\n\tif err != nil {\n\t\tt.Errorf(unexpectedErrMsg, err)\n\t}\n}", "func TestTokenBasedAuth(t *testing.T) {\n\tvar err error\n\terr = client.Login()\n\tif err != nil {\n\t\tt.Error(\"Login Failed\")\n\t\treturn\n\t}\n\trndIP := randomIP()\n\tlbName := \"test_lb_\" + randomString(5)\n\tlb1 := lb.Lbvserver{\n\t\tName: lbName,\n\t\tIpv46: rndIP,\n\t\tLbmethod: \"ROUNDROBIN\",\n\t\tServicetype: \"HTTP\",\n\t\tPort: 8000,\n\t}\n\t_, err = client.AddResource(Lbvserver.Type(), lbName, &lb1)\n\tif err != nil {\n\t\tt.Error(\"Could not add Lbvserver: \", err)\n\t\tt.Log(\"Not continuing test\")\n\t\treturn\n\t}\n\n\trsrc, err := client.FindResource(Lbvserver.Type(), lbName)\n\tif err != nil {\n\t\tt.Error(\"Did not find resource of type \", err, Lbvserver.Type(), \":\", lbName)\n\t} else {\n\t\tt.Log(\"LB-METHOD: \", rsrc[\"lbmethod\"])\n\t}\n\terr = client.DeleteResource(Lbvserver.Type(), lbName)\n\tif err != nil {\n\t\tt.Error(\"Could not delete LB\", lbName, err)\n\t\tt.Log(\"Cannot continue\")\n\t\treturn\n\t}\n\terr = client.Logout()\n\tif err != nil {\n\t\tt.Error(\"Logout Failed\")\n\t\treturn\n\t}\n\n\t// Test if session-id is cleared in case of session-expiry\n\tclient.timeout = 10\n\tclient.Login()\n\ttime.Sleep(15 * time.Second)\n\t_, err = client.AddResource(Lbvserver.Type(), lbName, &lb1)\n\tif err != nil {\n\t\tif client.IsLoggedIn() {\n\t\t\tt.Error(\"Sessionid not cleared\")\n\t\t\treturn\n\t\t}\n\t\tt.Log(\"sessionid cleared because of session-expiry\")\n\t} else {\n\t\tt.Error(\"Adding lbvserver should have failed because of session-expiry\")\n\t}\n}", "func (test *Test) SetupAuth(username, password, dbname string) error {\n\treturn nil\n}", "func TestAuth_WithMultipleResponses_CausesPanic(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.OK(nil)\n\t\t\trestest.AssertPanic(t, func() {\n\t\t\t\tr.MethodNotFound()\n\t\t\t})\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"method\", mock.Request()).\n\t\t\tResponse().\n\t\t\tAssertResult(nil)\n\t})\n}", "func TestAuthRequestTimeout(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.Timeout(time.Second * 42)\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\treq := s.Auth(\"test.model\", \"method\", nil)\n\t\treq.Response().AssertRawPayload([]byte(`timeout:\"42000\"`))\n\t\treq.Response().AssertError(res.ErrNotFound)\n\t})\n}", "func TestAuthParseToken(t *testing.T) {\n\tvar o struct {\n\t\tUser string `json:\"user\"`\n\t\tID int `json:\"id\"`\n\t}\n\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.ParseToken(&o)\n\t\t\trestest.AssertEqualJSON(t, \"o.User\", o.User, \"foo\")\n\t\t\trestest.AssertEqualJSON(t, \"o.ID\", o.ID, 42)\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\treq := mock.AuthRequest()\n\t\treq.Token = mock.Token\n\t\ts.Auth(\"test.model\", \"method\", req).\n\t\t\tResponse().\n\t\t\tAssertError(res.ErrNotFound)\n\t})\n}", "func (h *Handler) TestAuth(c echo.Context) (err error) {\n\t// Get team and member from the query string\n\tuser := c.Get(\"user\").(*jwt.Token)\n\tclaims := user.Claims.(jwt.MapClaims)\n\tname := claims[\"name\"].(string)\n\n\treturn c.String(http.StatusOK, \"Welcome \"+name+\"!\")\n\n}", "func NewAuth(users map[string]string) policies.AuthServiceClient {\n\treturn &authServiceMock{users}\n}", "func adminAccessTest(t *testing.T, r *http.Request, h http.Handler, auth *mock.Authenticator,\n\toutputTester func(*http.Response)) {\n\n\toriginal := auth.GetAuthInfoFn\n\tauth.GetAuthInfoFn = getAuthInfoGenerator(\"\", false, errors.New(\"An error\"))\n\tw := httptest.NewRecorder()\n\th.ServeHTTP(w, r)\n\ttest.Equals(t, http.StatusBadRequest, w.Result().StatusCode)\n\tauth.GetAuthInfoFn = getAuthInfoGenerator(\"random_admin_name\", true, nil)\n\tw = httptest.NewRecorder()\n\th.ServeHTTP(w, r)\n\toutputTester(w.Result())\n\tauth.GetAuthInfoFn = original\n}", "func TestRegisteringDuplicateAuthMethodPanics(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\trestest.AssertPanic(t, func() {\n\t\t\ts.Handle(\"model\",\n\t\t\t\tres.Auth(\"foo\", func(r res.AuthRequest) {\n\t\t\t\t\tr.OK(nil)\n\t\t\t\t}),\n\t\t\t\tres.Auth(\"bar\", func(r res.AuthRequest) {\n\t\t\t\t\tr.OK(nil)\n\t\t\t\t}),\n\t\t\t\tres.Auth(\"foo\", func(r res.AuthRequest) {\n\t\t\t\t\tr.OK(nil)\n\t\t\t\t}),\n\t\t\t)\n\t\t})\n\t}, nil, restest.WithoutReset)\n}", "func mockedGranter(kubeutil *kube.Kube, app *v1.RadixRegistration, namespace string, serviceAccount *corev1.ServiceAccount) error {\n\treturn nil\n}", "func TestNewClient_AuthPass(t *testing.T) {\n\tteardown := setup()\n\tdefer teardown()\n\temptyHandler := http.HandlerFunc(emptyResponse)\n\tmux.Handle(\"/databases\", testAuthenciateMiddleWare(emptyHandler))\n\t_, err := client.GetDatabases()\n\tif err != nil {\n\t\tt.Error(err)\n\t\tt.FailNow()\n\t}\n}", "func TestAuthentication(t *testing.T) {\n\ttests := []struct {\n\t\ttestName string\n\t\tbasicAuth map[string]string\n\t\tbasicAuthPasswordFileContents []byte\n\t\tbearerToken string\n\t\tbearerTokenFile string\n\t\tbearerTokenFileContents []byte\n\t\texpectedAuthHeaderValue string\n\t\texpectedError error\n\t}{\n\t\t{\n\t\t\ttestName: \"Basic Auth with password\",\n\t\t\tbasicAuth: map[string]string{\n\t\t\t\t\"username\": \"TestUser\",\n\t\t\t\t\"password\": \"TestPassword\",\n\t\t\t},\n\t\t\texpectedAuthHeaderValue: \"Basic \" + base64.StdEncoding.EncodeToString(\n\t\t\t\t[]byte(\"TestUser:TestPassword\"),\n\t\t\t),\n\t\t\texpectedError: nil,\n\t\t},\n\t\t{\n\t\t\ttestName: \"Basic Auth with password file\",\n\t\t\tbasicAuth: map[string]string{\n\t\t\t\t\"username\": \"TestUser\",\n\t\t\t\t\"password_file\": \"passwordFile\",\n\t\t\t},\n\t\t\tbasicAuthPasswordFileContents: []byte(\"TestPassword\"),\n\t\t\texpectedAuthHeaderValue: \"Basic \" + base64.StdEncoding.EncodeToString(\n\t\t\t\t[]byte(\"TestUser:TestPassword\"),\n\t\t\t),\n\t\t\texpectedError: nil,\n\t\t},\n\t\t{\n\t\t\ttestName: \"Basic Auth with bad password file\",\n\t\t\tbasicAuth: map[string]string{\n\t\t\t\t\"username\": \"TestUser\",\n\t\t\t\t\"password_file\": \"missingPasswordFile\",\n\t\t\t},\n\t\t\texpectedAuthHeaderValue: \"\",\n\t\t\texpectedError: ErrFailedToReadFile,\n\t\t},\n\t\t{\n\t\t\ttestName: \"Bearer Token\",\n\t\t\tbearerToken: \"testToken\",\n\t\t\texpectedAuthHeaderValue: \"Bearer testToken\",\n\t\t\texpectedError: nil,\n\t\t},\n\t\t{\n\t\t\ttestName: \"Bearer Token with bad bearer token file\",\n\t\t\tbearerTokenFile: \"missingBearerTokenFile\",\n\t\t\texpectedAuthHeaderValue: \"\",\n\t\t\texpectedError: ErrFailedToReadFile,\n\t\t},\n\t\t{\n\t\t\ttestName: \"Bearer Token with bearer token file\",\n\t\t\tbearerTokenFile: \"bearerTokenFile\",\n\t\t\texpectedAuthHeaderValue: \"Bearer testToken\",\n\t\t\tbearerTokenFileContents: []byte(\"testToken\"),\n\t\t\texpectedError: nil,\n\t\t},\n\t}\n\tfor _, test := range tests {\n\t\tt.Run(test.testName, func(t *testing.T) {\n\t\t\t// Set up a test server that runs a handler function when it receives a http\n\t\t\t// request. The server writes the request's Authorization header to the\n\t\t\t// response body.\n\t\t\thandler := func(rw http.ResponseWriter, req *http.Request) {\n\t\t\t\tauthHeaderValue := req.Header.Get(\"Authorization\")\n\t\t\t\t_, err := rw.Write([]byte(authHeaderValue))\n\t\t\t\trequire.Nil(t, err)\n\t\t\t}\n\t\t\tserver := httptest.NewServer(http.HandlerFunc(handler))\n\t\t\tdefer server.Close()\n\n\t\t\t// Create the necessary files for tests.\n\t\t\tif test.basicAuth != nil {\n\t\t\t\tpasswordFile := test.basicAuth[\"password_file\"]\n\t\t\t\tif passwordFile != \"\" && test.basicAuthPasswordFileContents != nil {\n\t\t\t\t\tfilepath := \"./\" + test.basicAuth[\"password_file\"]\n\t\t\t\t\terr := createFile(test.basicAuthPasswordFileContents, filepath)\n\t\t\t\t\trequire.Nil(t, err)\n\t\t\t\t\tdefer os.Remove(filepath)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif test.bearerTokenFile != \"\" && test.bearerTokenFileContents != nil {\n\t\t\t\tfilepath := \"./\" + test.bearerTokenFile\n\t\t\t\terr := createFile(test.bearerTokenFileContents, filepath)\n\t\t\t\trequire.Nil(t, err)\n\t\t\t\tdefer os.Remove(filepath)\n\t\t\t}\n\n\t\t\t// Create a HTTP request and add headers to it through an Exporter. Since the\n\t\t\t// Exporter has an empty Headers map, authentication methods will be called.\n\t\t\texporter := Exporter{\n\t\t\t\tConfig{\n\t\t\t\t\tBasicAuth: test.basicAuth,\n\t\t\t\t\tBearerToken: test.bearerToken,\n\t\t\t\t\tBearerTokenFile: test.bearerTokenFile,\n\t\t\t\t},\n\t\t\t}\n\t\t\treq, err := http.NewRequest(http.MethodPost, server.URL, nil)\n\t\t\trequire.Nil(t, err)\n\t\t\terr = exporter.addHeaders(req)\n\n\t\t\t// Verify the error and if the Authorization header was correctly set.\n\t\t\tif err != nil {\n\t\t\t\trequire.Equal(t, err.Error(), test.expectedError.Error())\n\t\t\t} else {\n\t\t\t\trequire.Nil(t, test.expectedError)\n\t\t\t\tauthHeaderValue := req.Header.Get(\"Authorization\")\n\t\t\t\trequire.Equal(t, authHeaderValue, test.expectedAuthHeaderValue)\n\t\t\t}\n\t\t})\n\t}\n}", "func TestAuthParseParams(t *testing.T) {\n\tvar p struct {\n\t\tFoo string `json:\"foo\"`\n\t\tBaz int `json:\"baz\"`\n\t}\n\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.ParseParams(&p)\n\t\t\trestest.AssertEqualJSON(t, \"p.Foo\", p.Foo, \"bar\")\n\t\t\trestest.AssertEqualJSON(t, \"p.Baz\", p.Baz, 42)\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\treq := mock.AuthRequest()\n\t\treq.Params = mock.Params\n\t\ts.Auth(\"test.model\", \"method\", req).\n\t\t\tResponse().\n\t\t\tAssertError(res.ErrNotFound)\n\t})\n}", "func (m *MockOAuther) Deauth(arg0 string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Deauth\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockDelegateActor) AuthenticatePostOutbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"AuthenticatePostOutbox\", c, w, r)\n\tret0, _ := ret[0].(context.Context)\n\tret1, _ := ret[1].(bool)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func (suite *AuthSuite) TestAuthUnknownServiceMember() {\n\t// Set up: Prepare the session, goth.User, callback handler, http response\n\t// and request, landing URL, and pass them into authorizeUnknownUser\n\n\thandlerConfig := suite.HandlerConfig()\n\tappnames := handlerConfig.AppNames()\n\n\t// Prepare the session and session manager\n\tfakeToken := \"some_token\"\n\tsession := auth.Session{\n\t\tApplicationName: auth.MilApp,\n\t\tIDToken: fakeToken,\n\t\tHostname: appnames.MilServername,\n\t}\n\tsessionManager := handlerConfig.SessionManagers().Mil\n\tmockSender := setUpMockNotificationSender() // We should get an email for this activity\n\n\t// Prepare the goth.User to simulate the UUID and email that login.gov would\n\t// provide\n\tfakeUUID, _ := uuid.NewV4()\n\tuser := goth.User{\n\t\tUserID: fakeUUID.String(),\n\t\tEmail: \"new_service_member@example.com\",\n\t}\n\tctx := suite.SetupSessionContext(context.Background(), &session, sessionManager)\n\n\t// Call the function under test\n\tresult := authorizeUnknownUser(ctx, suite.AppContextWithSessionForTest(&session), user,\n\t\tsessionManager, mockSender)\n\tsuite.Equal(authorizationResultAuthorized, result)\n\tmockSender.(*mocks.NotificationSender).AssertNumberOfCalls(suite.T(), \"SendNotification\", 1)\n\n\t// Look up the user and service member in the test DB\n\tfoundUser, _ := models.GetUserFromEmail(suite.DB(), user.Email)\n\tserviceMemberID := session.ServiceMemberID\n\tserviceMember, _ := models.FetchServiceMemberForUser(suite.DB(), &session, serviceMemberID)\n\t// Look up the session token in the session store (this test uses the memory store)\n\tsessionStore := sessionManager.Store()\n\t_, existsBefore, _ := sessionStore.Find(foundUser.CurrentMilSessionID)\n\n\t// Verify service member exists and its ID is populated in the session\n\tsuite.NotEmpty(session.ServiceMemberID)\n\n\t// Verify session contains UserID that points to the newly-created user\n\tsuite.Equal(foundUser.ID, session.UserID)\n\n\t// Verify user's LoginGovEmail and LoginGovUUID match the values passed in\n\tsuite.Equal(user.Email, foundUser.LoginGovEmail)\n\tsuite.Equal(user.UserID, foundUser.LoginGovUUID.String())\n\n\t// Verify that the user's CurrentMilSessionID is not empty. The value is\n\t// generated randomly, so we can't test for a specific string. Any string\n\t// except an empty string is acceptable.\n\tsuite.NotEqual(\"\", foundUser.CurrentMilSessionID)\n\n\t// Verify the session token also exists in the session store\n\tsuite.Equal(true, existsBefore)\n\n\t// Verify the service member that was created is associated with the user\n\t// that was created\n\tsuite.Equal(foundUser.ID, serviceMember.UserID)\n}", "func TestHandler_Authorized(t *testing.T) {\n\t// Create the mock session store.\n\tstore := NewTestStore()\n\tsession := sessions.NewSession(store, \"\")\n\tsession.Values[\"AuthState\"] = \"abc123\"\n\tstore.GetFunc = func(r *http.Request, name string) (*sessions.Session, error) {\n\t\treturn session, nil\n\t}\n\tstore.SaveFunc = func(r *http.Request, w http.ResponseWriter, session *sessions.Session) error { return nil }\n\n\t// Return a fake user.\n\tclient := &MockGitHubClient{}\n\tclient.GistsFunc = func(username string) ([]*gist.Gist, error) { return nil, nil }\n\tclient.UserFunc = func(username string) (*gist.User, error) {\n\t\treturn &gist.User{ID: 1000, Username: \"john\"}, nil\n\t}\n\n\t// Create non-redirecting client.\n\tvar redirectURL *url.URL\n\thttpClient := &http.Client{\n\t\tCheckRedirect: func(req *http.Request, via []*http.Request) error {\n\t\t\tredirectURL = req.URL\n\t\t\treturn errors.New(\"no redirects\")\n\t\t},\n\t}\n\n\t// Setup handler.\n\th := NewTestHandler()\n\th.Handler.Store = store\n\th.Handler.NewGitHubClient = func(token string) gist.GitHubClient {\n\t\tequals(t, \"mytoken\", token)\n\t\treturn client\n\t}\n\th.ExchangeFunc = func(code string) (*oauth.Token, error) { return &oauth.Token{AccessToken: \"mytoken\"}, nil }\n\tdefer h.Close()\n\n\t// Process callback.\n\tresp, _ := httpClient.Get(h.Server.URL + \"/_/login/callback?state=abc123\")\n\tresp.Body.Close()\n\n\t// We should be redirected to the root path.\n\tequals(t, 302, resp.StatusCode)\n\tequals(t, \"/_/dashboard\", redirectURL.Path)\n\n\t// The session should have the user id set.\n\tequals(t, 1000, session.Values[\"UserID\"])\n\n\t// The user should exist.\n\th.DB.View(func(tx *gist.Tx) error {\n\t\tu, _ := tx.User(1000)\n\t\tequals(t, &gist.User{ID: 1000, Username: \"john\", AccessToken: \"mytoken\"}, u)\n\t\treturn nil\n\t})\n}", "func TestLogin(w http.ResponseWriter, r *http.Request) {\n\n\tauthHeader := r.Header.Get(\"Authorization\")\n\tcookies := r.Cookies()\n\tvar token string\n\tfor _, c := range cookies {\n\t\tif c.Name == \"token\" {\n\t\t\ttoken = c.Value\n\t\t}\n\t}\n\n\tvar accessToken string\n\t// header value format will be \"Bearer <token>\"\n\tif authHeader != \"\" {\n\t\tif !strings.HasPrefix(authHeader, \"Bearer \") {\n\t\t\tlog.Errorf(\"GetMyIdentities Failed to find Bearer token %v\", authHeader)\n\t\t\tReturnHTTPError(w, r, http.StatusUnauthorized, \"Unauthorized, please provide a valid token\")\n\t\t\treturn\n\t\t}\n\t\taccessToken = strings.TrimPrefix(authHeader, \"Bearer \")\n\t}\n\n\tbytes, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tlog.Errorf(\"TestLogin failed with error: %v\", err)\n\t\tReturnHTTPError(w, r, http.StatusBadRequest, \"Bad Request, Please check the request content\")\n\t\treturn\n\t}\n\tvar testAuthConfig model.TestAuthConfig\n\n\terr = json.Unmarshal(bytes, &testAuthConfig)\n\tif err != nil {\n\t\tlog.Errorf(\"TestLogin unmarshal failed with error: %v\", err)\n\t\tReturnHTTPError(w, r, http.StatusBadRequest, \"Bad Request, Please check the request content\")\n\t\treturn\n\t}\n\n\tif testAuthConfig.AuthConfig.Provider == \"\" {\n\t\tlog.Errorf(\"UpdateConfig: Provider is a required field\")\n\t\tReturnHTTPError(w, r, http.StatusBadRequest, \"Bad request, Provider is a required field\")\n\t\treturn\n\t}\n\n\tstatus, err := server.TestLogin(testAuthConfig, accessToken, token)\n\tif err != nil {\n\t\tlog.Errorf(\"TestLogin GetProvider failed with error: %v\", err)\n\t\tif status == 0 {\n\t\t\tstatus = http.StatusInternalServerError\n\t\t}\n\t\tReturnHTTPError(w, r, status, fmt.Sprintf(\"%v\", err))\n\t}\n}", "func (_m *AuthAPIMock) AuthFunc(_a0 context.Context) (context.Context, error) {\n\tret := _m.Called(_a0)\n\n\tvar r0 context.Context\n\tif rf, ok := ret.Get(0).(func(context.Context) context.Context); ok {\n\t\tr0 = rf(_a0)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(context.Context)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context) error); ok {\n\t\tr1 = rf(_a0)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func TestValidAuth(t *testing.T) {\n\tt.Parallel()\n\ta, err := getAuth()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !ValidAuth(a) {\n\t\tt.Error(ErrInvalidAuth)\n\t}\n}", "func TestingBase(c context.Context) Base {\n\treturn func(h Handler) httprouter.Handle {\n\t\treturn func(rw http.ResponseWriter, r *http.Request, p httprouter.Params) {\n\t\t\th(c, rw, r, p)\n\t\t}\n\t}\n}", "func (m *MockAuth) AuthAndVerify(arg0 *common.Context, arg1 *plugin.PermissionRequest) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"AuthAndVerify\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func fakeAuthState() *authtest.FakeState {\n\treturn &authtest.FakeState{\n\t\tIdentity: \"user:user@example.com\",\n\t\tIdentityPermissions: []authtest.RealmPermission{\n\t\t\t{\n\t\t\t\tRealm: \"@internal:test-proj/cas-read-only\",\n\t\t\t\tPermission: permMintToken,\n\t\t\t},\n\t\t},\n\t}\n}", "func TestOAuth2ClientCredentialsCache(t *testing.T) {\n\t// Setup\n\tmockCtrl := gomock.NewController(t)\n\tdefer mockCtrl.Finish()\n\n\t// Mock mockTokenProvider\n\tmockTokenProvider := mock.NewMockTokenProviderInterface(mockCtrl)\n\n\tgomock.InOrder(\n\t\t// First call returning abc and Bearer, expires within 1 second\n\t\tmockTokenProvider.\n\t\t\tEXPECT().\n\t\t\tGetToken(gomock.Any()).\n\t\t\tReturn(&oauth2.Token{\n\t\t\t\tAccessToken: \"abc\",\n\t\t\t\tTokenType: \"Bearer\",\n\t\t\t\tExpiry: time.Now().In(time.UTC).Add(1 * time.Second),\n\t\t\t}, nil).\n\t\t\tTimes(1),\n\t\t// Second call returning def and MAC, expires within 1 second\n\t\tmockTokenProvider.\n\t\t\tEXPECT().\n\t\t\tGetToken(gomock.Any()).\n\t\t\tReturn(&oauth2.Token{\n\t\t\t\tAccessToken: \"def\",\n\t\t\t\tTokenType: \"MAC\",\n\t\t\t\tExpiry: time.Now().In(time.UTC).Add(1 * time.Second),\n\t\t\t}, nil).\n\t\t\tTimes(1),\n\t)\n\n\t// Specify components metadata\n\tvar metadata middleware.Metadata\n\tmetadata.Properties = map[string]string{\n\t\t\"clientID\": \"testId\",\n\t\t\"clientSecret\": \"testSecret\",\n\t\t\"scopes\": \"ascope\",\n\t\t\"tokenURL\": \"https://localhost:9999\",\n\t\t\"headerName\": \"someHeader\",\n\t\t\"authStyle\": \"1\",\n\t}\n\n\t// Initialize middleware component and inject mocked TokenProvider\n\tlog := logger.NewLogger(\"oauth2clientcredentials.test\")\n\toauth2clientcredentialsMiddleware, _ := NewOAuth2ClientCredentialsMiddleware(log).(*Middleware)\n\toauth2clientcredentialsMiddleware.SetTokenProvider(mockTokenProvider)\n\thandler, err := oauth2clientcredentialsMiddleware.GetHandler(context.Background(), metadata)\n\trequire.NoError(t, err)\n\n\t// First handler call should return abc Token\n\tr := httptest.NewRequest(http.MethodGet, \"http://dapr.io\", nil)\n\tw := httptest.NewRecorder()\n\thandler(http.HandlerFunc(mockedRequestHandler)).ServeHTTP(w, r)\n\n\t// Assertion\n\tassert.Equal(t, \"Bearer abc\", r.Header.Get(\"someHeader\"))\n\n\t// Second handler call should still return 'cached' abc Token\n\tr = httptest.NewRequest(http.MethodGet, \"http://dapr.io\", nil)\n\tw = httptest.NewRecorder()\n\thandler(http.HandlerFunc(mockedRequestHandler)).ServeHTTP(w, r)\n\n\t// Assertion\n\tassert.Equal(t, \"Bearer abc\", r.Header.Get(\"someHeader\"))\n\n\t// Wait at a second to invalidate cache entry for abc\n\ttime.Sleep(1 * time.Second)\n\n\t// Third call should return def Token\n\tr = httptest.NewRequest(http.MethodGet, \"http://dapr.io\", nil)\n\tw = httptest.NewRecorder()\n\thandler(http.HandlerFunc(mockedRequestHandler)).ServeHTTP(w, r)\n\n\t// Assertion\n\tassert.Equal(t, \"MAC def\", r.Header.Get(\"someHeader\"))\n}", "func authWrapper(handler http.HandlerFunc, secrets auth.SecretProvider, host string) http.HandlerFunc {\n\tauthenticator := &auth.BasicAuth{Realm: host, Secrets: secrets}\n\treturn auth.JustCheck(authenticator, handler)\n}", "func TestAuthRequest_NonWildcardMethod_CallsHandler(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\",\n\t\t\tres.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\t\tr.OK(mock.Result)\n\t\t\t}),\n\t\t\tres.Auth(\"*\", func(r res.AuthRequest) {\n\t\t\t\tr.Error(mock.CustomError)\n\t\t\t}),\n\t\t)\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"method\", nil).\n\t\t\tResponse().\n\t\t\tAssertResult(mock.Result)\n\n\t\ts.Auth(\"test.model\", \"unset\", nil).\n\t\t\tResponse().\n\t\t\tAssertError(mock.CustomError)\n\t})\n}", "func (fp MockProvider) BeginAuth(state string) (goth.Session, error) {\n\ts, err := fp.faux.BeginAuth(state)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tauthURL, err := s.GetAuthURL()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tauthURL += fmt.Sprintf(\"&%s=%s\", key.Role, fp.Role)\n\tif fp.Callback != \"\" {\n\t\tau, err := url.Parse(authURL)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tauthURL = fp.Callback + \"?\" + au.RawQuery\n\t}\n\treturn &mockSession{\n\t\tSession: &faux.Session{\n\t\t\tID: fp.AccountID,\n\t\t\tName: fp.Username,\n\t\t\tEmail: fp.Email,\n\t\t\tAuthURL: authURL,\n\t\t},\n\t\tt: fp.t,\n\t}, nil\n}", "func TestSignUpUserSameCredentials(t *testing.T) {\n\tvar fireBaseSignUpResponsePayload FireBaseSignUpResponsePayloadMock\n\tvar fireBaseSignUpBadRequestResponsePayloadMock FireBaseSignUpBadRequestResponsePayloadMock\n\n\tuserSignUpMockBadPayload := SignUpMock{Email: SignUpUserResponsePayload.Email, Password: \"testing1234\"}\n\trequestBody, err := json.Marshal(userSignUpMockBadPayload)\n\tassert.Nil(t, err, \"Couldn't marshall user signup mock object:\")\n\n\treq, err := http.NewRequest(\"POST\", signUpUrl, bytes.NewBuffer(requestBody))\n\tassert.Nil(t, err, \"Failure while making a new POST request:\")\n\n\trec := httptest.NewRecorder()\n\tsignUpHandler := &SignUp.SignUpHandler{\n\t\tFireBaseApiKey: FirebaseApiKey,\n\t}\n\n\tsignUpHandler.ServeHTTP(rec,req)\n\t//rec := httptest.NewRecorder()\n\n\t//handler.ServeHTTP(rec, req)\n\tres := rec.Result()\n\tdefer res.Body.Close()\n\n\tassert.Equal(t, http.StatusBadRequest, res.StatusCode, \"Expected status bad request as the status code\")\n\t// check the payload response here as well make sure\n\tbody, err := ioutil.ReadAll(res.Body)\n\t//fmt.Println(string(body))\n\tassert.Nil(t, err, \"Error with payload response:\")\n\n\terr = json.Unmarshal(body, &fireBaseSignUpResponsePayload)\n\t// expect it to be nil\n\tassert.Nil(t, err, \"Couldn't unmarshall signup response payload:\")\n\tassert.Equal(t, \"\", fireBaseSignUpResponsePayload.Email, \"Expected return type of email to be empty string\")\n\tassert.Equal(t, \"\", fireBaseSignUpResponsePayload.IdToken, \"Expected return type of IdToken to be empty string\")\n\tassert.Equal(t, \"\", fireBaseSignUpResponsePayload.RefreshToken, \"Expected return type of RefreshToken to be empty string\")\n\tassert.Equal(t, \"\", fireBaseSignUpResponsePayload.ExpiresIn, \"Expected return type of ExpiresIn to be empty string\")\n\tassert.Equal(t, \"\", fireBaseSignUpResponsePayload.LocalId, \"Expected return type of LocalId to be empty string\")\n\n\terr = json.Unmarshal(body, &fireBaseSignUpBadRequestResponsePayloadMock)\n\tassert.Equal(t, \"\", fireBaseSignUpBadRequestResponsePayloadMock.Error, \"Expected Error to be none\")\n}", "func (app *App) SetAuth(r *http.Request) {\n\n}", "func (_m *NatsConn) AuthRequired() bool {\n\tret := _m.Called()\n\n\tvar r0 bool\n\tif rf, ok := ret.Get(0).(func() bool); ok {\n\t\tr0 = rf()\n\t} else {\n\t\tr0 = ret.Get(0).(bool)\n\t}\n\n\treturn r0\n}", "func (m *MockBasicAuthentifier) BasicAuth(host string) *vcs.BasicAuth {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"BasicAuth\", host)\n\tret0, _ := ret[0].(*vcs.BasicAuth)\n\treturn ret0\n}", "func xTestAuthLoad(t *testing.T) {\n\tc := setup(t)\n\tdefer Teardown(c)\n\n\tdoLogin := func(myid int, times int64, ch chan<- bool) {\n\t\tsessionKeys := make([]string, times)\n\t\tfor iter := int64(0); iter < times; iter++ {\n\t\t\t//t.Logf(\"%v: %v/%v login\\n\", myid, iter, times)\n\t\t\tkey, token, err := c.Login(joeEmail, joePwd, \"\")\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"Login failed. Error should not be %v\", err)\n\t\t\t}\n\t\t\tif token == nil {\n\t\t\t\tt.Errorf(\"Login failed. Token should not be nil\")\n\t\t\t}\n\t\t\tsessionKeys[iter] = key\n\t\t}\n\t\tfor iter := int64(0); iter < times; iter++ {\n\t\t\ttoken, err := c.GetTokenFromSession(sessionKeys[iter])\n\t\t\tif token == nil || err != nil {\n\t\t\t\tt.Errorf(\"GetTokenFromSession failed\")\n\t\t\t}\n\t\t}\n\t\tch <- true\n\t}\n\n\tnsimul := 20\n\tconPerThread := int64(10000)\n\tif isBackendPostgresTest() {\n\t\tconPerThread = int64(100)\n\t} else if isBackendLdapTest() {\n\t\tconPerThread = int64(100)\n\t}\n\twaits := make([]chan bool, nsimul)\n\tfor i := 0; i < nsimul; i++ {\n\t\twaits[i] = make(chan bool, 0)\n\t\tgo doLogin(i, conPerThread, waits[i])\n\t}\n\tfor i := 0; i < nsimul; i++ {\n\t\t_, ok := <-waits[i]\n\t\tif !ok {\n\t\t\tt.Errorf(\"Channel closed prematurely\")\n\t\t}\n\t}\n}", "func Test(t *testing.T) {\n\t// Create an HTTP server which will assert that basic auth has been injected\n\t// into the request.\n\tsrv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tusername, password, ok := r.BasicAuth()\n\t\tassert.True(t, ok, \"no basic auth found\")\n\t\tassert.Equal(t, \"foo\", username, \"basic auth username didn't match\")\n\t\tassert.Equal(t, \"bar\", password, \"basic auth password didn't match\")\n\n\t\tw.WriteHeader(http.StatusOK)\n\t}))\n\tdefer srv.Close()\n\n\tctx := componenttest.TestContext(t)\n\tctx, cancel := context.WithTimeout(ctx, time.Minute)\n\tdefer cancel()\n\n\tl := util.TestLogger(t)\n\n\t// Create and run our component\n\tctrl, err := componenttest.NewControllerFromID(l, \"otelcol.auth.basic\")\n\trequire.NoError(t, err)\n\n\tcfg := `\n\t\tusername = \"foo\"\n\t\tpassword = \"bar\"\n\t`\n\tvar args basic.Arguments\n\trequire.NoError(t, river.Unmarshal([]byte(cfg), &args))\n\n\tgo func() {\n\t\terr := ctrl.Run(ctx, args)\n\t\trequire.NoError(t, err)\n\t}()\n\n\trequire.NoError(t, ctrl.WaitRunning(time.Second), \"component never started\")\n\trequire.NoError(t, ctrl.WaitExports(time.Second), \"component never exported anything\")\n\n\t// Get the authentication extension from our component and use it to make a\n\t// request to our test server.\n\texports := ctrl.Exports().(auth.Exports)\n\trequire.NotNil(t, exports.Handler.Extension, \"handler extension is nil\")\n\n\tclientAuth, ok := exports.Handler.Extension.(extauth.Client)\n\trequire.True(t, ok, \"handler does not implement configauth.ClientAuthenticator\")\n\n\trt, err := clientAuth.RoundTripper(http.DefaultTransport)\n\trequire.NoError(t, err)\n\tcli := &http.Client{Transport: rt}\n\n\t// Wait until the request finishes. We don't assert anything else here; our\n\t// HTTP handler won't write the response until it ensures that the basic auth\n\t// was found.\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, srv.URL, nil)\n\trequire.NoError(t, err)\n\tresp, err := cli.Do(req)\n\trequire.NoError(t, err, \"HTTP request failed\")\n\trequire.Equal(t, http.StatusOK, resp.StatusCode)\n}", "func TestAuthenticatedRequest(t *testing.T) {\n\tvar e error\n\tprivateKey, e = readPrivateKey()\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\tConvey(\"Simple authenticated requests\", t, func() {\n\t\tConvey(\"Authenticated GET to / path should return a 200 response\", func() {\n\t\t\tw := makeAuthenticatedRequest(\"GET\", \"/\", jwt.MapClaims{\"foo\": \"bar\"}, nil)\n\t\t\tSo(w.Code, ShouldEqual, http.StatusOK)\n\t\t})\n\t\tConvey(\"Authenticated GET to /protected path should return a 200 response if expected algorithm is not specified\", func() {\n\t\t\tvar expectedAlgorithm jwt.SigningMethod = nil\n\t\t\tw := makeAuthenticatedRequest(\"GET\", \"/protected\", jwt.MapClaims{\"foo\": \"bar\"}, expectedAlgorithm)\n\t\t\tSo(w.Code, ShouldEqual, http.StatusOK)\n\t\t\tresponseBytes, err := ioutil.ReadAll(w.Body)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tresponseString := string(responseBytes)\n\t\t\t// check that the encoded data in the jwt was properly returned as json\n\t\t\tSo(responseString, ShouldEqual, `{\"text\":\"bar\"}`)\n\t\t})\n\t\tConvey(\"Authenticated GET to /protected path should return a 200 response if expected algorithm is correct\", func() {\n\t\t\texpectedAlgorithm := jwt.SigningMethodHS256\n\t\t\tw := makeAuthenticatedRequest(\"GET\", \"/protected\", jwt.MapClaims{\"foo\": \"bar\"}, expectedAlgorithm)\n\t\t\tSo(w.Code, ShouldEqual, http.StatusOK)\n\t\t\tresponseBytes, err := ioutil.ReadAll(w.Body)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tresponseString := string(responseBytes)\n\t\t\t// check that the encoded data in the jwt was properly returned as json\n\t\t\tSo(responseString, ShouldEqual, `{\"text\":\"bar\"}`)\n\t\t})\n\t\tConvey(\"Authenticated GET to /protected path should return a 401 response if algorithm is not expected one\", func() {\n\t\t\texpectedAlgorithm := jwt.SigningMethodRS256\n\t\t\tw := makeAuthenticatedRequest(\"GET\", \"/protected\", jwt.MapClaims{\"foo\": \"bar\"}, expectedAlgorithm)\n\t\t\tSo(w.Code, ShouldEqual, http.StatusUnauthorized)\n\t\t\tresponseBytes, err := ioutil.ReadAll(w.Body)\n\t\t\tif err != nil {\n\t\t\t\tpanic(err)\n\t\t\t}\n\t\t\tresponseString := string(responseBytes)\n\t\t\t// check that the encoded data in the jwt was properly returned as json\n\t\t\tSo(strings.TrimSpace(responseString), ShouldEqual, \"Expected RS256 signing method but token specified HS256\")\n\t\t})\n\t})\n}", "func (c *Client) Auth() (string, error) {\n\t// First do an empty get to get the auth challenge\n\treq, err := http.NewRequest(http.MethodGet, c.BaseURL+\"/v2/\", nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\trsp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed sending auth request: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tio.Copy(io.Discard, rsp.Body)\n\n\tif rsp.StatusCode == http.StatusOK {\n\t\t// no auth needed\n\t\treturn \"\", nil\n\t}\n\n\tif rsp.StatusCode != http.StatusUnauthorized {\n\t\treturn \"\", fmt.Errorf(\"unexpected status %s\", rsp.Status)\n\t}\n\n\t// The Www-Authenticate header tells us where to go to get a token\n\tvals, err := parseWWWAuthenticate(rsp.Header.Get(\"Www-Authenticate\"))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tu, err := url.Parse(vals[\"realm\"])\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not parse authentication realm: %w\", err)\n\t}\n\tq := u.Query()\n\tq.Set(\"service\", vals[\"service\"])\n\tq.Set(\"scope\", \"repository:\"+c.Name+\":pull,push\")\n\tu.RawQuery = q.Encode()\n\n\tfmt.Printf(\"get %s\\n\", u)\n\n\treq, err = http.NewRequest(http.MethodGet, u.String(), nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treq.SetBasicAuth(c.User, c.Password)\n\n\trsp, err = http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed sending auth request: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"unexpected status %s\", rsp.Status)\n\t}\n\tbody, err := io.ReadAll(rsp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not read auth response body: %w\", err)\n\t}\n\n\ttype token struct {\n\t\tToken string `json:\"token\"`\n\t}\n\tvar tok token\n\tif err := json.Unmarshal(body, &tok); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to unmarshal token: %w\", err)\n\t}\n\n\treturn tok.Token, nil\n}", "func (m *MockAuthenticatorClient) Refresh(ctx context.Context, in *authenticate.Session, opts ...grpc.CallOption) (*authenticate.Session, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{ctx, in}\n\tfor _, a := range opts {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Refresh\", varargs...)\n\tret0, _ := ret[0].(*authenticate.Session)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func mockChildPackages() {\n\n\t// Fake an AWS credentials file so that the mfile package will nehave as if it is happy\n\tsetFakeCredentials()\n\n\t// Fake out the creds package into using an apparently credentials response from AWS\n\tcreds.SetGetSessionTokenFunc(func(awsService *sts.STS, input *sts.GetSessionTokenInput) (*sts.GetSessionTokenOutput, error) {\n\t\treturn getSessionTokenOutput, nil\n\t})\n\n}", "func (m *MockUserServer) Authorization(arg0 context.Context, arg1 *pb.TextRequest) (*pb.StateReply, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Authorization\", arg0, arg1)\n\tret0, _ := ret[0].(*pb.StateReply)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (c *B2) authGet(apiPath string) (*http.Response, *authorizationState, error) {\n\treq, auth, err := c.authRequest(\"GET\", apiPath, nil)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tresp, err := c.httpClient.Do(req)\n\treturn resp, auth, err\n}", "func TestSetAuth(t *testing.T) {\n var c Noc\n\n // use wrong port on purpose, expect an error\n c.InitNoc(\"localhost\", \"9999\", false)\n if c.SetAuth() == nil {\n t.Errorf(\"Expected an error when getting an authentication token. server is not running on port 9999\")\n }\n\n c.InitNoc(\"localhost\", \"8888\", false)\n c.BadsecToken = \"\"\n c.SetAuth()\n if len(c.BadsecToken) == 33 {\n t.Errorf(\"Expected BadsecToken to be length 33. Got: \" + strconv.Itoa(len(c.BadsecToken)))\n }\n}", "func (m *MockUserClient) Authorization(ctx context.Context, in *pb.TextRequest, opts ...grpc.CallOption) (*pb.StateReply, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{ctx, in}\n\tfor _, a := range opts {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Authorization\", varargs...)\n\tret0, _ := ret[0].(*pb.StateReply)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func newAuth(parentAuth swift.Authenticator, storageURL string, authToken string) *auth {\n\treturn &auth{\n\t\tparentAuth: parentAuth,\n\t\tstorageURL: storageURL,\n\t\tauthToken: authToken,\n\t}\n}", "func TestGetAuthToken(t *testing.T) {\n\tif testing.Short() {\n\t\tt.Skip(\"Skipping integration tests in short mode\")\n\t}\n\tdeleteAll(t)\n\tadminClient := getPachClient(t, admin)\n\n\t// Generate two auth credentials, and give them to two separate clients\n\trobotUser := auth.RobotPrefix + tu.UniqueString(\"optimus_prime\")\n\tresp, err := adminClient.GetAuthToken(adminClient.Ctx(),\n\t\t&auth.GetAuthTokenRequest{Subject: robotUser})\n\trequire.NoError(t, err)\n\t// copy client & use resp token\n\trobotClient1 := adminClient.WithCtx(context.Background())\n\trobotClient1.SetAuthToken(resp.Token)\n\n\ttoken1 := resp.Token\n\tresp, err = adminClient.GetAuthToken(adminClient.Ctx(),\n\t\t&auth.GetAuthTokenRequest{Subject: robotUser})\n\trequire.NoError(t, err)\n\trequire.NotEqual(t, token1, resp.Token)\n\t// copy client & use resp token\n\trobotClient2 := adminClient.WithCtx(context.Background())\n\trobotClient2.SetAuthToken(resp.Token)\n\n\t// robotClient1 creates a repo\n\trepo := tu.UniqueString(\"TestPipelinesRunAfterExpiration\")\n\trequire.NoError(t, robotClient1.CreateRepo(repo))\n\trequire.Equal(t, entries(robotUser, \"owner\"), GetACL(t, robotClient1, repo))\n\n\t// robotClient1 creates a pipeline\n\tpipeline := tu.UniqueString(\"optimus-prime-line\")\n\trequire.NoError(t, robotClient1.CreatePipeline(\n\t\tpipeline,\n\t\t\"\", // default image: ubuntu:14.04\n\t\t[]string{\"bash\"},\n\t\t[]string{fmt.Sprintf(\"cp /pfs/%s/* /pfs/out/\", repo)},\n\t\t&pps.ParallelismSpec{Constant: 1},\n\t\tclient.NewAtomInput(repo, \"/*\"),\n\t\t\"\", // default output branch: master\n\t\tfalse, // no update\n\t))\n\trequire.OneOfEquals(t, pipeline, PipelineNames(t, robotClient1))\n\t// check that robotUser owns the output repo\n\trequire.ElementsEqual(t,\n\t\tentries(robotUser, \"owner\", pl(pipeline), \"writer\"), GetACL(t, robotClient1, pipeline))\n\n\t// Make sure that robotClient2 can commit to the input repo and flush their\n\t// input commit\n\tcommit, err := robotClient2.StartCommit(repo, \"master\")\n\trequire.NoError(t, err)\n\t_, err = robotClient2.PutFile(repo, commit.ID, tu.UniqueString(\"/file1\"),\n\t\tstrings.NewReader(\"test data\"))\n\trequire.NoError(t, err)\n\trequire.NoError(t, robotClient2.FinishCommit(repo, commit.ID))\n\titer, err := robotClient2.FlushCommit(\n\t\t[]*pfs.Commit{commit},\n\t\t[]*pfs.Repo{{Name: pipeline}},\n\t)\n\trequire.NoError(t, err)\n\trequire.NoErrorWithinT(t, 60*time.Second, func() error {\n\t\t_, err := iter.Next()\n\t\treturn err\n\t})\n\n\t// Make sure robotClient2 can update the pipeline, and it still runs\n\t// successfully\n\trequire.NoError(t, robotClient2.CreatePipeline(\n\t\tpipeline,\n\t\t\"\", // default image: ubuntu:14.04\n\t\t[]string{\"bash\"},\n\t\t[]string{fmt.Sprintf(\"cp /pfs/%s/* /pfs/out/\", repo)},\n\t\t&pps.ParallelismSpec{Constant: 1},\n\t\tclient.NewAtomInput(repo, \"/*\"),\n\t\t\"\", // default output branch: master\n\t\ttrue, // update\n\t))\n\titer, err = robotClient2.FlushCommit(\n\t\t[]*pfs.Commit{commit},\n\t\t[]*pfs.Repo{{Name: pipeline}},\n\t)\n\trequire.NoError(t, err)\n\trequire.NoErrorWithinT(t, 60*time.Second, func() error {\n\t\t_, err := iter.Next()\n\t\treturn err\n\t})\n}", "func noValidTokenTest(t *testing.T, r *http.Request, h http.Handler, auth *mock.Authenticator) {\n\toriginal := auth.AuthenticateFn\n\tauth.AuthenticateFn = authenticateGenerator(false, errors.New(\"An error\"))\n\tw := httptest.NewRecorder()\n\th.ServeHTTP(w, r)\n\ttest.Equals(t, http.StatusBadRequest, w.Result().StatusCode)\n\tauth.AuthenticateFn = authenticateGenerator(false, nil)\n\tw = httptest.NewRecorder()\n\th.ServeHTTP(w, r)\n\ttest.Equals(t, http.StatusUnauthorized, w.Result().StatusCode)\n\tauth.AuthenticateFn = original\n}", "func (m *MockDelegateActor) AuthenticateGetInbox(c context.Context, w http.ResponseWriter, r *http.Request) (context.Context, bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"AuthenticateGetInbox\", c, w, r)\n\tret0, _ := ret[0].(context.Context)\n\tret1, _ := ret[1].(bool)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func (s Server) Auth(c context.Context, r *gabby.AuthRequest) (*gabby.AuthResponse, error) {\n\treturn nil, nil\n}", "func TestAuthNotFound(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"method\", nil).\n\t\t\tResponse().\n\t\t\tAssertError(res.ErrNotFound)\n\t})\n}", "func TestPreOAUTH2(t *testing.T) {\n\t//\n\t// Password manuall edited in cassete:\n\t// Basic = printf \"admin:PASSWORD\"| base64\n\t// Body = printf '{\"username\":\"admin\",\"password\":\"PASSWORD\"}'|base64\n\tconnection, err := NewConnectionBuilder().\n\t\tURL(\"https://tower.private/api\").\n\t\tUsername(\"admin\").\n\t\tPassword(\"PASSWORD\").\n\t\tInsecure(true).\n\t\tBuild()\n\tif err != nil {\n\t\tt.Errorf(\"Error creating connection: %s\", err)\n\t}\n\tdefer connection.Close()\n\tvcr := govcr.NewVCR(\"connection_pre_oauth2\",\n\t\t&govcr.VCRConfig{\n\t\t\tClient: connection.client,\n\t\t\tDisableRecording: true,\n\t\t})\n\t// Replace our HTTPClient with a vcr client wrapping it\n\tconnection.client = vcr.Client\n\tprojectsResource := connection.Projects()\n\n\t// Trigger the auth flow.\n\tgetProjectsRequest := projectsResource.Get()\n\tif len(connection.token) != 0 || len(connection.bearer) != 0 {\n\t\tt.Errorf(\"Connection should have no tokens. token: '%s', bearer: '%s'\",\n\t\t\tconnection.token,\n\t\t\tconnection.bearer)\n\t}\n\t_, err = getProjectsRequest.Send()\n\tif err != nil {\n\t\tt.Errorf(\"Error sending project request: %s\", err)\n\t}\n\tif len(connection.token) == 0 || len(connection.bearer) != 0 {\n\t\tt.Errorf(\"Connection should have only an auth token. token: '%s', bearer: '%s'\",\n\t\t\tconnection.token,\n\t\t\tconnection.bearer)\n\t}\n}", "func (m *MockAdmin) Authenticate(ctx provider.Context, adminID int, allowedRole []constant.UserRole) (entity.User, *entity.ApplicationError) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Authenticate\", ctx, adminID, allowedRole)\n\tret0, _ := ret[0].(entity.User)\n\tret1, _ := ret[1].(*entity.ApplicationError)\n\treturn ret0, ret1\n}", "func (e *EndpointSessions) auth(writer http.ResponseWriter, request *http.Request) {\n\tlogin := request.Header.Get(\"login\")\n\tpwd := request.Header.Get(\"password\")\n\tagent := request.Header.Get(\"User-Agent\")\n\tclient := request.Header.Get(\"client\")\n\n\t//try to do something against brute force attacks, see also https://www.owasp.org/index.php/Blocking_Brute_Force_Attacks\n\ttime.Sleep(1000 * time.Millisecond)\n\n\t//another funny idea is to return a fake session id, after many wrong login attempts\n\n\tif len(login) < 3 {\n\t\thttp.Error(writer, \"login too short\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\tif len(agent) == 0 {\n\t\thttp.Error(writer, \"user agent missing\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\tif len(pwd) < 4 {\n\t\thttp.Error(writer, \"password too short\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\tif len(client) == 0 {\n\t\thttp.Error(writer, \"client missing\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\tallowed := false\n\tfor _, allowedClient := range allowedClients {\n\t\tif allowedClient == client {\n\t\t\tallowed = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !allowed {\n\t\thttp.Error(writer, \"client is invalid\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\tusr, err := e.users.FindByLogin(login)\n\n\tif err != nil {\n\t\tif db.IsEntityNotFound(err) {\n\t\t\thttp.Error(writer, \"credentials invalid\", http.StatusForbidden)\n\t\t} else {\n\t\t\thttp.Error(writer, err.Error(), http.StatusInternalServerError)\n\t\t}\n\n\t\treturn\n\t}\n\n\tif !usr.Active {\n\t\thttp.Error(writer, \"credentials invalid\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\tif !usr.PasswordEquals(pwd){\n\t\thttp.Error(writer, \"credentials invalid\", http.StatusForbidden)\n\t\treturn\n\t}\n\n\t//login is fine now, create a session\n\tcurrentTime := time.Now().Unix()\n\tses := &session.Session{User: usr.Id, LastUsedAt: currentTime, CreatedAt: currentTime, LastRemoteAddr: request.RemoteAddr, LastUserAgent: agent}\n\terr = e.sessions.Create(ses)\n\tif err != nil {\n\t\thttp.Error(writer, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tWriteJSONBody(writer, &sessionDTO{Id: ses.Id, User: usr.Id})\n}", "func (b *basicAuth) set(r *http.Request) { r.SetBasicAuth(b.username, b.password) }", "func (m *MockHandler) Login(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Login\", arg0, arg1)\n}", "func setupMockBroker(auth bool) *httptest.Server {\n\tmux := http.NewServeMux()\n\tvar authFunc func(inner http.HandlerFunc) http.HandlerFunc\n\n\tif auth {\n\t\t// Use the foo/bar basic authentication middleware in publish_test.go\n\t\tauthFunc = func(inner http.HandlerFunc) http.HandlerFunc {\n\t\t\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\t\tif checkAuth(w, r) {\n\t\t\t\t\tlog.Println(\"[DEBUG] broker - authenticated!\")\n\t\t\t\t\tinner.ServeHTTP(w, r)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tw.Header().Set(\"WWW-Authenticate\", `Basic realm=\"Broker Authentication Required\"`)\n\t\t\t\tw.WriteHeader(401)\n\t\t\t\tw.Write([]byte(\"401 Unauthorized\\n\"))\n\t\t\t})\n\t\t}\n\t} else {\n\t\t// Create a do-nothing authentication middleware\n\t\tauthFunc = func(inner http.HandlerFunc) http.HandlerFunc {\n\t\t\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\t\t\tlog.Println(\"[DEBUG] broker - no authentication\")\n\t\t\t\tinner.ServeHTTP(w, r)\n\t\t\t})\n\t\t}\n\t}\n\n\tserver := httptest.NewServer(mux)\n\n\t// Find latest 'bobby' consumers (no tag)\n\t// curl --user pactuser:pact -H \"accept: application/hal+json\" \"http://pact.onegeek.com.au/pacts/provider/bobby/latest\"\n\tmux.HandleFunc(\"/pacts/provider/bobby/latest\", authFunc(func(w http.ResponseWriter, req *http.Request) {\n\t\tlog.Println(\"[DEBUG] get pacts for provider 'bobby'\")\n\t\tfmt.Fprintf(w, `{\"_links\":{\"self\":{\"href\":\"%s/pacts/provider/bobby/latest\",\"title\":\"Latest pact versions for the provider bobby\"},\"provider\":{\"href\":\"%s/pacticipants/bobby\",\"title\":\"bobby\"},\"pb:pacts\":[{\"href\":\"%s/pacts/provider/bobby/consumer/jessica/version/2.0.0\",\"title\":\"Pact between jessica (v2.0.0) and bobby\",\"name\":\"jessica\"},{\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0\",\"title\":\"Pact between billy (v1.0.0) and bobby\",\"name\":\"billy\"}],\"pacts\":[{\"href\":\"%s/pacts/provider/bobby/consumer/jessica/version/2.0.0\",\"title\":\"OLD Pact between jessica (v2.0.0) and bobby\",\"name\":\"jessica\"},{\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0\",\"title\":\"OLD Pact between billy (v1.0.0) and bobby\",\"name\":\"billy\"}]}}`, server.URL, server.URL, server.URL, server.URL, server.URL, server.URL)\n\t\tw.Header().Add(\"Content-Type\", \"application/hal+json\")\n\t}))\n\n\t// Find 'bobby' consumers for tag 'prod'\n\t// curl --user pactuser:pact -H \"accept: application/hal+json\" \"http://pact.onegeek.com.au/pacts/provider/bobby/latest/sit4\"\n\tmux.Handle(\"/pacts/provider/bobby/latest/prod\", authFunc(func(w http.ResponseWriter, req *http.Request) {\n\t\tlog.Println(\"[DEBUG] get all pacts for provider 'bobby' where the tag 'prod' exists\")\n\t\tfmt.Fprintf(w, `{\"_links\":{\"self\":{\"href\":\"%s/pacts/provider/bobby/latest/dev\",\"title\":\"Latest pact versions for the provider bobby with tag 'dev'\"},\"provider\":{\"href\":\"%s/pacticipants/bobby\",\"title\":\"bobby\"},\"pb:pacts\":[{\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0\",\"title\":\"Pact between billy (v1.0.0) and bobby\",\"name\":\"billy\"}],\"pacts\":[{\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0\",\"title\":\"OLD Pact between billy (v1.0.0) and bobby\",\"name\":\"billy\"}]}}`, server.URL, server.URL, server.URL, server.URL)\n\t\tw.Header().Add(\"Content-Type\", \"application/hal+json\")\n\t}))\n\n\t// Broken response\n\tmux.Handle(\"/pacts/provider/bobby/latest/broken\", authFunc(func(w http.ResponseWriter, req *http.Request) {\n\t\tlog.Println(\"[DEBUG] broken broker\")\n\t\tfmt.Fprintf(w, `broken response`)\n\t\tw.Header().Add(\"Content-Type\", \"application/hal+json\")\n\t}))\n\n\t// 50x response\n\t// curl --user pactuser:pact -H \"accept: application/hal+json\" \"http://pact.onegeek.com.au/pacts/provider/bobby/latest/sit4\"\n\tmux.Handle(\"/pacts/provider/broken/latest/dev\", authFunc(func(w http.ResponseWriter, req *http.Request) {\n\t\tlog.Println(\"[DEBUG] broker broker response\")\n\t\tw.WriteHeader(500)\n\t\tw.Write([]byte(\"500 Server Error\\n\"))\n\t}))\n\n\t// Find 'bobby' consumers for tag 'dev'\n\t// curl --user pactuser:pact -H \"accept: application/hal+json\" \"http://pact.onegeek.com.au/pacts/provider/bobby/latest/sit4\"\n\tmux.Handle(\"/pacts/provider/bobby/latest/dev\", authFunc(func(w http.ResponseWriter, req *http.Request) {\n\t\tlog.Println(\"[DEBUG] get all pacts for provider 'bobby' where the tag 'dev' exists\")\n\t\tfmt.Fprintf(w, `{\"_links\":{\"self\":{\"href\":\"%s/pacts/provider/bobby/latest/dev\",\"title\":\"Latest pact versions for the provider bobby with tag 'dev'\"},\"provider\":{\"href\":\"%s/pacticipants/bobby\",\"title\":\"bobby\"},\"pb:pacts\":[{\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/version/1.0.1\",\"title\":\"Pact between billy (v1.0.1) and bobby\",\"name\":\"billy\"}],\"pacts\":[{\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/version/1.0.1\",\"title\":\"OLD Pact between billy (v1.0.1) and bobby\",\"name\":\"billy\"}]}}`, server.URL, server.URL, server.URL, server.URL)\n\t\tw.Header().Add(\"Content-Type\", \"application/hal+json\")\n\t}))\n\n\t// Actual Consumer Pact\n\t// curl -v --user pactuser:pact -H \"accept: application/json\" http://pact.onegeek.com.au/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0\n\tmux.Handle(\"/pacts/provider/loginprovider/consumer/jmarie/version/\", authFunc(func(w http.ResponseWriter, req *http.Request) {\n\t\tlog.Println(\"[DEBUG] get all pacts for provider 'bobby' where any tag exists\")\n\t\tfmt.Fprintf(w, `{\"consumer\":{\"name\":\"billy\"},\"provider\":{\"name\":\"bobby\"},\"interactions\":[{\"description\":\"Some name for the test\",\"provider_state\":\"Some state\",\"request\":{\"method\":\"GET\",\"path\":\"/foobar\"},\"response\":{\"status\":200,\"headers\":{\"Content-Type\":\"application/json\"}}},{\"description\":\"Some name for the test\",\"provider_state\":\"Some state2\",\"request\":{\"method\":\"GET\",\"path\":\"/bazbat\"},\"response\":{\"status\":200,\"headers\":{},\"body\":[[{\"colour\":\"red\",\"size\":10,\"tag\":[[\"jumper\",\"shirt\"],[\"jumper\",\"shirt\"]]}]],\"matchingRules\":{\"$.body\":{\"min\":1},\"$.body[*].*\":{\"match\":\"type\"},\"$.body[*]\":{\"min\":1},\"$.body[*][*].*\":{\"match\":\"type\"},\"$.body[*][*].colour\":{\"match\":\"regex\",\"regex\":\"red|green|blue\"},\"$.body[*][*].size\":{\"match\":\"type\"},\"$.body[*][*].tag\":{\"min\":2},\"$.body[*][*].tag[*].*\":{\"match\":\"type\"},\"$.body[*][*].tag[*][0]\":{\"match\":\"type\"},\"$.body[*][*].tag[*][1]\":{\"match\":\"type\"}}}}],\"metadata\":{\"pactSpecificationVersion\":\"2.0.0\"},\"updatedAt\":\"2016-06-11T13:11:33+00:00\",\"createdAt\":\"2016-06-09T12:46:42+00:00\",\"_links\":{\"self\":{\"title\":\"Pact\",\"name\":\"Pact between billy (v1.0.0) and bobby\",\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0\"},\"pb:consumer\":{\"title\":\"Consumer\",\"name\":\"billy\",\"href\":\"%s/pacticipants/billy\"},\"pb:provider\":{\"title\":\"Provider\",\"name\":\"bobby\",\"href\":\"%s/pacticipants/bobby\"},\"pb:latest-pact-version\":{\"title\":\"Pact\",\"name\":\"Latest version of this pact\",\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/latest\"},\"pb:previous-distinct\":{\"title\":\"Pact\",\"name\":\"Previous distinct version of this pact\",\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0/previous-distinct\"},\"pb:diff-previous-distinct\":{\"title\":\"Diff\",\"name\":\"Diff with previous distinct version of this pact\",\"href\":\"%s/pacts/provider/loginprovider/consumer/jmarie/version/1.0.0/diff/previous-distinct\"},\"pb:pact-webhooks\":{\"title\":\"Webhooks for the pact between billy and bobby\",\"href\":\"%s/webhooks/provider/bobby/consumer/billy\"},\"pb:tag-prod-version\":{\"title\":\"Tag this version as 'production'\",\"href\":\"%s/pacticipants/billy/versions/1.0.0/tags/prod\"},\"pb:tag-version\":{\"title\":\"Tag version\",\"href\":\"%s/pacticipants/billy/versions/1.0.0/tags/{tag}\"},\"curies\":[{\"name\":\"pb\",\"href\":\"%s/doc/{rel}\",\"templated\":true}]}}`, server.URL, server.URL, server.URL, server.URL, server.URL, server.URL, server.URL, server.URL, server.URL, server.URL)\n\t\tw.Header().Add(\"Content-Type\", \"application/hal+json\")\n\t}))\n\n\treturn server\n}", "func CheckAuth(c *gin.Context) {\n\n}", "func (m *MockAuthService) Login(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Login\", arg0, arg1)\n}", "func TestAuthRequest_WildcardMethod_CallsHandler(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"*\", func(r res.AuthRequest) {\n\t\t\tr.OK(mock.Result)\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"unset\", nil).\n\t\t\tResponse().\n\t\t\tAssertResult(mock.Result)\n\t})\n}", "func TestLoginWrapper_LoggedIn(t *testing.T) {\n\tw, r, c := initTestRequestParams(t, &user.User{Email: \"test@example.com\"})\n\tdefer c.Close()\n\n\tdummyLoginHandler(&requestParams{w: w, r: r, c: c})\n\n\texpectCode(t, http.StatusOK, w)\n\texpectBody(t, \"test@example.com\", w)\n}", "func mockOAuthServer() *httptest.Server {\n\t// prepare a port for the mocked server\n\tserver := httptest.NewUnstartedServer(http.DefaultServeMux)\n\n\t// mock the used REST path for the tests\n\tmockedHandler := http.NewServeMux()\n\tmockedHandler.HandleFunc(\"/.well-known/openid-configuration\", func(writer http.ResponseWriter, request *http.Request) {\n\t\ts := fmt.Sprintf(`{\n \"issuer\":\"%s\",\n \"authorization_endpoint\":\"%s/authorize\",\n \"token_endpoint\":\"%s/oauth/token\",\n \"device_authorization_endpoint\":\"%s/oauth/device/code\"\n}`, server.URL, server.URL, server.URL, server.URL)\n\t\tfmt.Fprintln(writer, s)\n\t})\n\tmockedHandler.HandleFunc(\"/oauth/token\", func(writer http.ResponseWriter, request *http.Request) {\n\t\tfmt.Fprintln(writer, \"{\\n \\\"access_token\\\": \\\"token-content\\\",\\n \\\"token_type\\\": \\\"Bearer\\\"\\n}\")\n\t})\n\tmockedHandler.HandleFunc(\"/authorize\", func(writer http.ResponseWriter, request *http.Request) {\n\t\tfmt.Fprintln(writer, \"true\")\n\t})\n\n\tserver.Config.Handler = mockedHandler\n\tserver.Start()\n\n\treturn server\n}", "func TestAuthenticate_Success(t *testing.T) {\n\tdb, mock, err := sqlmock.New()\n\tif err != nil {\n\t\tt.Fatalf(\"an error '%s' was not expected when opening a stub database connection\", err)\n\t}\n\tdefer db.Close()\n\n\tuser := models.User{\n\t\tID: 1,\n\t\tEmail: \"personia@personio.com\",\n\t\tPassword: \"personia\",\n\t}\n\n\trows := sqlmock.NewRows([]string{\"id\", \"email\"}).AddRow(user.ID, user.Email)\n\tmock.ExpectQuery(regexp.QuoteMeta(constants.LoginDetailsSelectQuery)).WithArgs(user.Email, user.Password).WillReturnRows(rows)\n\n\tloginRepository := NewLoginRepository(db)\n\n\tloginModel := &models.Login{\n\t\tEmail: \"personia@personio.com\",\n\t\tPassword: \"personia\",\n\t}\n\n\tcntx := context.Background()\n\tdbuser, err := loginRepository.Authenticate(cntx, loginModel)\n\tassert.Nil(t, err)\n\tassert.Equal(t, user.ID, dbuser.ID)\n\tassert.Equal(t, user.Email, dbuser.Email)\n}", "func TestAuthInterAuthorizeToken(t *testing.T) {\n\ta := assert.New(t)\n\tr := require.New(t)\n\tpoliciesInter := &authInterPoliciesInter{}\n\tresourcesInter := &authInterResourcesInter{}\n\tsessionsInter := &authInterSessionsInter{}\n\tinter := NewAuthInter(\n\t\tpoliciesInter,\n\t\tresourcesInter,\n\t\tsessionsInter,\n\t)\n\thostname := \"foo.bar.com\"\n\tpath := \"\"\n\ttoken := \"F00bAr\"\n\n\t// Success: root\n\tgranted, session, err := inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.True(granted)\n\ta.NotNil(session)\n\n\tpath = \"/foo/bar\"\n\n\t// Success: weight system\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.True(granted)\n\ta.NotNil(session)\n\n\tpath = \"/foo/bar/\"\n\n\t// Success: trailing slash\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.True(granted)\n\ta.NotNil(session)\n\n\tpath = \"/foo/\"\n\n\t// Success: trailing slash\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.True(granted)\n\ta.NotNil(session)\n\n\tpath = \"/bar\"\n\n\t// Multipath denied\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.False(granted)\n\n\tpath = \"/bar2\"\n\n\t// Multipath denied\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.False(granted)\n\n\tpath = \"/foo/foo\"\n\n\t// Denied\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.False(granted)\n\n\ttestResource.Public = utils.BoolCpy(true)\n\n\t// Success: public resource\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.True(granted)\n\ta.Nil(session)\n\n\ttestResource.Public = utils.BoolCpy(false)\n\tsessionsInter.errNotFound = true\n\n\t// Success: guest policy\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.True(granted)\n\ta.Nil(session)\n\n\tguestPolicy.Enabled = utils.BoolCpy(false)\n\n\t// Denied: guest policy is disabled\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.False(granted)\n\ta.Nil(session)\n\n\tguestPolicy.Enabled = utils.BoolCpy(true)\n\tguestPolicy.Permissions[0].Enabled = utils.BoolCpy(false)\n\n\t// Denied: guest policy permissions are disabled\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.NoError(err)\n\ta.False(granted)\n\ta.Nil(session)\n\n\tguestPolicy.Permissions[0].Enabled = utils.BoolCpy(true)\n\tpoliciesInter.errNotFound = true\n\n\t// Error: guest policy\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.Error(err)\n\ta.False(granted)\n\ta.Nil(session)\n\n\tsessionsInter.errNotFound = false\n\n\t// Not found error\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.Error(err)\n\ta.IsType(errs.Internal.NotFound, err)\n\ta.False(granted)\n\n\tpoliciesInter.errNotFound = false\n\tresourcesInter.errNotFound = true\n\n\t// Not found error\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.Error(err)\n\ta.IsType(errs.Internal.NotFound, err)\n\ta.False(granted)\n\n\tresourcesInter.errNotFound = false\n\tpoliciesInter.errDB = true\n\n\t// Database error\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.Error(err)\n\ta.IsType(errs.Internal.Database, err)\n\ta.False(granted)\n\n\tpoliciesInter.errDB = false\n\tresourcesInter.errDB = true\n\n\t// Database error\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.Error(err)\n\ta.IsType(errs.Internal.Database, err)\n\ta.False(granted)\n\n\tresourcesInter.errDB = false\n\tsessionsInter.errDB = true\n\n\t// Database error\n\tgranted, session, err = inter.AuthorizeToken(hostname, path, token)\n\tr.Error(err)\n\ta.IsType(errs.Internal.Database, err)\n\ta.False(granted)\n}", "func (m *MockAuthService) Validate(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Validate\", arg0, arg1)\n}", "func (m *HTTPAuthService) Authorize(arg0 context.Context, arg1 *http.Request) (*user.User, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Authorize\", arg0, arg1)\n\tret0, _ := ret[0].(*user.User)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (mmAuther *mGatewayMockAuther) Expect() *mGatewayMockAuther {\n\tif mmAuther.mock.funcAuther != nil {\n\t\tmmAuther.mock.t.Fatalf(\"GatewayMock.Auther mock is already set by Set\")\n\t}\n\n\tif mmAuther.defaultExpectation == nil {\n\t\tmmAuther.defaultExpectation = &GatewayMockAutherExpectation{}\n\t}\n\n\treturn mmAuther\n}", "func verifyAuth(w http.ResponseWriter, r *http.Request) {\n\thttpJSON(w, httpMessageReturn{Message: \"OK\"}, http.StatusOK, nil)\n}", "func (m *MockAuth) Authenticate(arg0 *common.Context) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Authenticate\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func TestAuthenticate_Fail(t *testing.T) {\n\tdb, mock, err := sqlmock.New()\n\tif err != nil {\n\t\tt.Fatalf(\"an error '%s' was not expected when opening a stub database connection\", err)\n\t}\n\tdefer db.Close()\n\n\tuser := models.User{\n\t\tID: 1,\n\t\tEmail: \"personia@personio.com\",\n\t\tPassword: \"personia\",\n\t}\n\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(constants.LoginDetailsSelectQuery)\n\n\trows := sqlmock.NewRows([]string{\"id\", \"email\"})\n\tmock.ExpectQuery(regexp.QuoteMeta(buffer.String())).WithArgs(user.Email, user.Password).WillReturnRows(rows)\n\n\tloginRepository := NewLoginRepository(db)\n\n\tloginModel := &models.Login{\n\t\tEmail: \"personia@personio.com\",\n\t\tPassword: \"personia\",\n\t}\n\n\tcntx := context.Background()\n\t_, err = loginRepository.Authenticate(cntx, loginModel)\n\tassert.NotNil(t, err)\n}", "func getTestEnv() *Env {\n\tdb := createMockDB()\n\n\toauthConf := &oauth2.Config{\n\t\tClientID: \"abcdef0123abcdef4567\",\n\t\tClientSecret: \"abcdef0123abcdef4567abcdef8901abcdef2345\",\n\t\tScopes: []string{\"user:email\"},\n\t\tEndpoint: githuboauth.Endpoint,\n\t}\n\n\tenv := &Env{\n\t\tdb: db,\n\t\tjwtSecretKey: \"keyForTesting\",\n\t\toauthConf: oauthConf,\n\t\toauthState: \"nonRandomStateString\",\n\t}\n\treturn env\n}", "func (m *MockAuth) Verify(arg0 *common.Context, arg1 *plugin.PermissionRequest) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Verify\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockAccount) Authorize(arg0, arg1 string) (*models.User, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Authorize\", arg0, arg1)\n\tret0, _ := ret[0].(*models.User)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockAuthenticatorServer) Refresh(arg0 context.Context, arg1 *authenticate.Session) (*authenticate.Session, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Refresh\", arg0, arg1)\n\tret0, _ := ret[0].(*authenticate.Session)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockAuthService) Logout(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Logout\", arg0, arg1)\n}", "func AuthLoginWrapper(ctx *fasthttp.RequestCtx, mgoClient *mgo.Session, redisClient *redis.Client, cfg datastructures.Configuration) {\n\tlog.Info(\"AuthLoginWrapper | Starting authentication | Parsing authentication credentials\")\n\tctx.Response.Header.SetContentType(\"application/json; charset=utf-8\")\n\tusername, password := ParseAuthenticationCoreHTTP(ctx) // Retrieve the username and password encoded in the request from BasicAuth headers, GET & POST\n\tif authutils.ValidateCredentials(username, password) { // Verify if the input parameter respect the rules ...\n\t\tlog.Debug(\"AuthLoginWrapper | Input validated | User: \", username, \" | Pass: \", password, \" | Calling core functionalities ...\")\n\t\tcheck := authutils.LoginUserHTTPCore(username, password, mgoClient, cfg.Mongo.Users.DB, cfg.Mongo.Users.Collection) // Login phase\n\t\tif strings.Compare(check, \"OK\") == 0 { // Login Succeed\n\t\t\tlog.Debug(\"AuthLoginWrapper | Login succesfully! Generating token!\")\n\t\t\ttoken := basiccrypt.GenerateToken(username, password) // Generate a simple md5 hashed token\n\t\t\tlog.Info(\"AuthLoginWrapper | Inserting token into Redis \", token)\n\t\t\tbasicredis.InsertIntoClient(redisClient, username, token, cfg.Redis.Token.Expire) // insert the token into the DB\n\t\t\tlog.Info(\"AuthLoginWrapper | Token inserted! All operation finished correctly! | Setting token into response\")\n\t\t\tauthcookie := authutils.CreateCookie(\"GoLog-Token\", token, cfg.Redis.Token.Expire)\n\t\t\tctx.Response.Header.SetCookie(authcookie) // Set the token into the cookie headers\n\t\t\tctx.Response.Header.Set(\"GoLog-Token\", token) // Set the token into a custom headers for future security improvments\n\t\t\tlog.Warn(\"AuthLoginWrapper | Client logged in succesfully!! | \", username, \":\", password, \" | Token: \", token)\n\t\t\terr := json.NewEncoder(ctx).Encode(datastructures.Response{Status: true, Description: \"User logged in!\", ErrorCode: username + \":\" + password, Data: token})\n\t\t\tcommonutils.Check(err, \"AuthLoginWrapper\")\n\t\t} else {\n\t\t\tcommonutils.AuthLoginWrapperErrorHelper(ctx, check, username, password)\n\t\t}\n\t} else { // error parsing credential\n\t\tlog.Info(\"AuthLoginWrapper | Error parsing credential!! |\", username+\":\"+password)\n\t\tctx.Response.Header.DelCookie(\"GoLog-Token\")\n\t\tctx.Error(fasthttp.StatusMessage(fasthttp.StatusUnauthorized), fasthttp.StatusUnauthorized)\n\t\tctx.Response.Header.Set(\"WWW-Authenticate\", \"Basic realm=Restricted\")\n\t\t//err := json.NewEncoder(ctx).Encode(datastructures.Response{Status: false, Description: \"Error parsing credential\", ErrorCode: \"Missing or manipulated input\", Data: nil})\n\t\t//commonutils.Check(err, \"AuthLoginWrapper\")\n\t}\n}", "func AuthAndCallAPI(w http.ResponseWriter, r *http.Request, service string, method string, version string) {\n\te := Execution{name: \"AuthAndCallAPI \" + service}\n\te.Start()\n\n\tauthorization := r.Header.Get(\"authorization\")\n\n\ttoken := \"\"\n\ts := strings.Split(authorization, \" \")\n\tif len(s) >= 2 {\n\t\ttoken = s[1]\n\t}\n\n\tconfig := config.GetConfig()\n\tresp, _ := resty.R().\n\t\tSetFormData(map[string]string{\n\t\t\t\"token\": token,\n\t\t\t\"service\": service,\n\t\t}).\n\t\tSetResult(&Respon{}).\n\t\tPost(config.API.Auth + \"v100/auth/check_token\")\n\n\tvar respon Respon\n\t_ = json.Unmarshal(resp.Body(), &respon)\n\n\tif respon.Code != 200 {\n\t\trespond := Respon{\n\t\t\tStatus: respon.Status,\n\t\t\tCode: respon.Code,\n\t\t\tMessage: respon.Message,\n\t\t\tExeTime: respon.ExeTime,\n\t\t\tData: respon.Data,\n\t\t\tError: respon.Error,\n\t\t}\n\t\tRespondJson(w, resp.StatusCode(), respond)\n\t\treturn\n\t}\n\n\tCallAPI(w, r, service, method, version)\n}" ]
[ "0.656697", "0.644635", "0.6424919", "0.6387047", "0.6359137", "0.6304474", "0.6280732", "0.62320656", "0.6219561", "0.6136139", "0.612664", "0.6107285", "0.60800076", "0.60556173", "0.6026555", "0.6022269", "0.60212576", "0.6004177", "0.59664774", "0.5951194", "0.5931367", "0.591496", "0.591496", "0.5907145", "0.58787096", "0.58599734", "0.5851024", "0.5823974", "0.58209246", "0.5753523", "0.57495517", "0.5741141", "0.5736469", "0.5729112", "0.5668964", "0.56668437", "0.566236", "0.56620836", "0.5653744", "0.5616106", "0.56148225", "0.5605913", "0.5598945", "0.5569833", "0.55660695", "0.55299604", "0.5518119", "0.5515074", "0.54997015", "0.54980814", "0.5489257", "0.5464221", "0.54609597", "0.5450584", "0.5449361", "0.5442146", "0.54392004", "0.543775", "0.5428973", "0.5424", "0.54088664", "0.54075766", "0.540375", "0.53931564", "0.538693", "0.5382172", "0.53816605", "0.5365424", "0.53607935", "0.53545594", "0.535374", "0.53494585", "0.5342139", "0.53388137", "0.5335854", "0.53351915", "0.53301007", "0.5299413", "0.5294058", "0.52917624", "0.5289498", "0.52868766", "0.528371", "0.5283253", "0.5276724", "0.5270835", "0.52618235", "0.52578676", "0.5255658", "0.52528495", "0.525131", "0.5238868", "0.52367574", "0.523201", "0.52314913", "0.52286446", "0.5223719", "0.5222735", "0.5219526", "0.52160984" ]
0.6943208
0
Auth indicates an expected call of Auth
func (mr *MockServiceAuthMockRecorder) Auth(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Auth", reflect.TypeOf((*MockServiceAuth)(nil).Auth), arg0) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MockSession) Auth() error {\n\targs := m.Mock.Called()\n\treturn args.Error(0)\n}", "func Auth() gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tc.Writer.Write([]byte(\"auth required for endpoint\"))\n\t}\n}", "func (a HMACAuthenticator) Auth(r *http.Request) bool {\n\treturn true\n}", "func TestValidAuth(t *testing.T) {\n\tt.Parallel()\n\ta, err := getAuth()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif !ValidAuth(a) {\n\t\tt.Error(ErrInvalidAuth)\n\t}\n}", "func (r *RPC) Auth(c context.Context, arg *rpc.Auth, res *struct{}) (err error) {\n\treturn\n}", "func (s Server) Auth(c context.Context, r *gabby.AuthRequest) (*gabby.AuthResponse, error) {\n\treturn nil, nil\n}", "func TestAuthOK(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.OK(mock.Result)\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"method\", nil).\n\t\t\tResponse().\n\t\t\tAssertResult(mock.Result)\n\t})\n}", "func CheckAuth(c *gin.Context) {\n\n}", "func Auth(c *gin.Context) {\n\t_user, _ := c.Get(\"user\")\n\tuser := _user.(User)\n\n\t// if user is authenticated successfully than he gets it. Otherwise, a standard Unauthorized error.\n\tc.JSON(200, gin.H{\"type\": \"auth\", \"name\": user.UserName, \"status\": user.Status})\n}", "func Auth(next http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tlog.Infof(\"Authenticating request: \")\n\t\tif r.Header.Get(\"user\") != \"foo\" {\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn\n\t\t}\n\t\tlog.Infof(\"Auth: Pass\")\n\t\tnext.ServeHTTP(w, r)\n\n\t})\n}", "func TestAuthWithNil(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.OK(nil)\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"method\", nil).\n\t\t\tResponse().\n\t\t\tAssertResult(nil)\n\t})\n}", "func AuthTester(t *testing.T, auth Auth, reqAuth Auth) {\n\tassert := assert.New(t)\n\tassert.Equal(auth.Username, reqAuth.Username, \"Usernames should be equal\")\n\tassert.Equal(auth.Password, reqAuth.Password, \"Passwords should be equal\")\n}", "func verifyAuth(w http.ResponseWriter, r *http.Request) {\n\thttpJSON(w, httpMessageReturn{Message: \"OK\"}, http.StatusOK, nil)\n}", "func Auth() gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tfmt.Println(\"Auth middleware\")\n\t}\n}", "func (a *App) CheckAuth() {\n\tsynchronizer := NewSynchronizer()\n\tsynchronizer.CheckAuth()\n}", "func (p *Pub) Auth(secret string) bool {\n\treturn p.appsecret == secret\n}", "func TestAuth(t *testing.T) {\n\tl := logger.NewNoop()\n\n\tserv, err := server.New(l)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tclient := authv1.HTTPTestAuthServiceClient{}\n\tclient.Client = serv\n\n\ttest(t, \"client auth\", 0, func(t *testing.T, i int) {\n\t\tvar authid string\n\t\tconst (\n\t\t\tusername = \"kili-test\"\n\t\t\temail = \"uhh@eee@aaa\"\n\t\t\tpassword = \"kala-test\"\n\t\t)\n\n\t\ttest(t, \"begin auth\", i, beginAuth(client, &authid))\n\t\ttest(t, \"first auth step\", i, firstAuthStep(client, authid, \"register\"))\n\t\ttest(t, \"get register form\", i, formAuthStep(client, authid, \"register\"))\n\n\t\ttest(t, \"register account\", i, register(client, authid, username, email, password))\n\n\t\ttest(t, \"begin auth again\", i, beginAuth(client, &authid))\n\t\ttest(t, \"first auth step again\", i, firstAuthStep(client, authid, \"login\"))\n\t\ttest(t, \"get login form\", i, formAuthStep(client, authid, \"login\"))\n\n\t\ttest(t, \"login account\", i, login(client, authid, email, password))\n\t})\n}", "func (a API) Auth(w http.ResponseWriter, r *http.Request, state string, redirect_url string) {\r\n\thttp.Redirect(w, r, a.AuthUrl(state, redirect_url), http.StatusFound)\r\n}", "func (c *client) Auth(token, secret string) (string, error) {\n\treturn \"\", fmt.Errorf(\"Not Implemented\")\n}", "func (auth *AdminAuth) Auth() (bool, error) {\n\tif auth.Bearer != \"\" && auth.AdminID != \"\" {\n\t\tadminModel := &orm.Admin{\n\t\t\tAdminID: auth.AdminID,\n\t\t}\n\t\tif err := adminModel.GetSingle(); err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\tbearer := generateBearerToken(adminModel.Token, adminModel.AdminID, auth.Req)\n\t\tif bearer != auth.Bearer {\n\t\t\treturn false, errors.New(\"bearer token not match\")\n\t\t}\n\t\treturn true, nil\n\t}\n\treturn false, errors.New(\"authenticate parameters invalid\")\n}", "func TestgetAuth(t *testing.T) {\n\tt.Parallel()\n\ta, err := getAuth()\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tif reflect.TypeOf(a).String() != \"*scaniigo.APIAuth\" {\n\t\tt.Error(ErrInvalidDataType)\n\t}\n}", "func ReplyAuthOk() *Reply { return &Reply{235, []string{\"Authentication successful\"}, nil} }", "func (a Anonymous) Authenticated() bool { return false }", "func (a *API) Auth(ctx context.Context, request *AuthRequest) (*OkResponse, error) {\n\tvar err error\n\n\tif request.Ip == \"\" {\n\t\treturn nil, errors.New(\"ip is required for Auth method\")\n\t}\n\n\tip, err := entities.NewWithoutMaskPart(request.Ip)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar conform bool\n\n\t// if ip conform black list - no auth (even if ip conform white list)\n\tconform, err = a.isConformByBlackList(ctx, ip)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif conform {\n\t\treturn &OkResponse{Ok: false}, nil\n\t}\n\n\t// if ip conform white list - auth is ok\n\tconform, err = a.isConformByWhiteList(ctx, ip)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif conform {\n\t\treturn &OkResponse{Ok: true}, nil\n\t}\n\n\tconform, err = a.isConformByIPBucket(ctx, ip)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !conform {\n\t\treturn &OkResponse{Ok: false}, nil\n\t}\n\n\tconform, err = a.isConformByPasswordBucket(ctx, request.Password)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif !conform {\n\t\treturn &OkResponse{Ok: false}, nil\n\t}\n\n\tconform, err = a.isConformByLoginBucket(ctx, request.Login)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &OkResponse{Ok: conform}, nil\n}", "func Auth(authMethod Method) func(*context.Context) {\n\treturn func(ctx *context.Context) {\n\t\tif err := authShared(ctx, authMethod); err != nil {\n\t\t\tlog.Error(\"Failed to verify user: %v\", err)\n\t\t\tctx.Error(http.StatusUnauthorized, \"Verify\")\n\t\t\treturn\n\t\t}\n\t\tif ctx.Doer == nil {\n\t\t\t// ensure the session uid is deleted\n\t\t\t_ = ctx.Session.Delete(\"uid\")\n\t\t}\n\t}\n}", "func (s *Server) isAuth() bool {\n\treturn s.credential != \"\"\n}", "func (a BasicAuthenticator) Auth(r *http.Request) bool {\n\t// Retrieve Authorization header\n\tauth := r.Header.Get(\"Authorization\")\n\n\t// No header provided\n\tif auth == \"\" {\n\t\treturn false\n\t}\n\n\t// Ensure format is valid\n\tbasic := strings.Split(auth, \" \")\n\tif basic[0] != \"Basic\" {\n\t\treturn false\n\t}\n\n\t// Decode base64'd user:password pair\n\tbuf, err := base64.URLEncoding.DecodeString(basic[1])\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\treturn false\n\t}\n\n\t// Split into username/password\n\tcredentials := strings.Split(string(buf), \":\")\n\n\t// Load user by username, verify user exists\n\tuser := new(data.UserRecord).Load(credentials[0], \"username\")\n\tif user == (data.UserRecord{}) {\n\t\treturn false\n\t}\n\n\t// Load user's API key\n\tkey := new(data.APIKey).Load(user.ID, \"user_id\")\n\tif key == (data.APIKey{}) {\n\t\treturn false\n\t}\n\n\t// Hash input password\n\tsha := sha1.New()\n\tif _, err = sha.Write([]byte(credentials[1] + key.Salt)); err != nil {\n\t\tlog.Println(err.Error())\n\t\treturn false\n\t}\n\n\thash := fmt.Sprintf(\"%x\", sha.Sum(nil))\n\n\t// Verify hashes match, using timing-attack resistant method\n\t// If function returns 1, hashes match\n\treturn subtle.ConstantTimeCompare([]byte(hash), []byte(key.Key)) == 1\n}", "func checkAuth(w http.ResponseWriter, r *http.Request, s *MemorySessionStore) bool {\n\tauth := r.Header.Get(\"Authorization\")\n\tif auth == \"\" {\n\t\treturnHTTP(w, http.StatusUnauthorized, nil)\n\t\treturn false\n\t}\n\n\tmatch := authRegexp.FindStringSubmatch(auth)\n\tif len(match) != 2 {\n\t\treturnHTTP(w, http.StatusBadRequest, nil)\n\t\treturn false\n\t}\n\n\tid := match[1]\n\tif !s.Check(id) {\n\t\treturnHTTP(w, http.StatusUnauthorized, nil)\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (_m *NatsConn) AuthRequired() bool {\n\tret := _m.Called()\n\n\tvar r0 bool\n\tif rf, ok := ret.Get(0).(func() bool); ok {\n\t\tr0 = rf()\n\t} else {\n\t\tr0 = ret.Get(0).(bool)\n\t}\n\n\treturn r0\n}", "func beginAuth(w http.ResponseWriter, r *http.Request) {\n\tgothic.BeginAuthHandler(w, r)\n}", "func (s *server) checkAuth(r *http.Request) error {\n\tauthhdr := r.Header[\"Authorization\"]\n\tif len(authhdr) == 0 {\n\t\treturn ErrNoAuth\n\t}\n\n\tauthsha := sha256.Sum256([]byte(authhdr[0]))\n\tcmp := subtle.ConstantTimeCompare(authsha[:], s.authsha[:])\n\tif cmp != 1 {\n\t\treturn ErrBadAuth\n\t}\n\treturn nil\n}", "func (c *Context) AuthFailed() {\n\tc.JSON(403, ResponseWriter(403, \"authorization failed\", nil))\n}", "func (h *Handler) TestAuth(c echo.Context) (err error) {\n\t// Get team and member from the query string\n\tuser := c.Get(\"user\").(*jwt.Token)\n\tclaims := user.Claims.(jwt.MapClaims)\n\tname := claims[\"name\"].(string)\n\n\treturn c.String(http.StatusOK, \"Welcome \"+name+\"!\")\n\n}", "func (c *Client) Auth(u, p string) (err error) {\n\tif err = c.User(u); err != nil {\n\t\treturn\n\t}\n\n\tif err = c.Pass(p); err != nil {\n\t\treturn\n\t}\n\n\t// issue a dud command. Server might not respond with invalid auth\n\t// unless a cmd is issued\n\treturn c.Noop()\n}", "func (c *Client) auth() error {\n\tconst authEndpoint = apiEndpointBase + \"/v1/shim/login\"\n\tfprint, _ := json.Marshal(authVersion)\n\n\tauthRequest, _ := json.Marshal(authRequest{\n\t\tusername: c.Username,\n\t\tpassword: c.Password,\n\t\tfingerprint: string(fprint),\n\t})\n\n\tresp, err := http.DoPost(authEndpoint, basicAuth(c.Username, c.Password), authRequest)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tauthp := &authPayload{}\n\tif err := json.Unmarshal(resp, authp); err != nil {\n\t\treturn err\n\t}\n\n\tc.accessToken = authp.Oauth2.AccessToken\n\tc.expiry = time.Now().Add(time.Second * time.Duration(authp.Oauth2.ExpiresIn))\n\treturn nil\n}", "func (signer *Signer) Auth() string {\n\treturn time.Now().Format(time.ANSIC) + \" \" + signer.req.Method\n}", "func authOk(sucProb byte) error {\n\t/* Get a random number */\n\tb := make([]byte, 1)\n\tif _, err := rand.Read(b); nil != err {\n\t\treturn fmt.Errorf(\"random read: %v\", err)\n\t}\n\t/* See if it's a winner */\n\tif b[0] <= sucProb {\n\t\treturn nil\n\t}\n\treturn errors.New(\"permission denied\")\n}", "func Auth(c *gin.Context) {\n\ttokenString := c.Request.Header.Get(\"Authorization\")\n\t// Parse token that got from Header to our SigningMethodH\n\ttoken, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {\n\t\tif jwt.GetSigningMethod(\"HS256\") != token.Method {\n\t\t\tLog.Fatalf(\"Unexpected signing method: %v\", token.Header[\"alg\"])\n\t\t\treturn nil, fmt.Errorf(\"Unexpected signing method: %v\", token.Header[\"alg\"])\n\t\t}\n\n\t\treturn []byte(time.Now().Format(\"2019-03-29\")), nil\n\t})\n\n\t// Verify the token\n\tif token != nil && err == nil {\n\t\tLog.Println(\"token verified\")\n\t} else {\n\t\tc.AbortWithStatusJSON(http.StatusUnauthorized, model.JSONResults{\n\t\t\tStatus: http.StatusUnauthorized,\n\t\t\tMessage: model.Message{\n\t\t\t\tError: err.Error(),\n\t\t\t},\n\t\t})\n\t}\n}", "func TestAuthNotFound(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"method\", nil).\n\t\t\tResponse().\n\t\t\tAssertError(res.ErrNotFound)\n\t})\n}", "func (mr *MockMessageHandlerMockRecorder) CheckAuth(msg, msgBody interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"CheckAuth\", reflect.TypeOf((*MockMessageHandler)(nil).CheckAuth), msg, msgBody)\n}", "func (c *Client) Auth(ctx context.Context, email, password string) (AuthResponse, error) {\n\tvar res AuthResponse\n\terr := c.gqlClient.Run(ctx, makeAuthRequest(email, password), &res)\n\tif err != nil {\n\t\treturn AuthResponse{}, errors.Wrap(err, \"auth request failed\")\n\t}\n\n\treturn res, nil\n}", "func (uem *UyuniEventMapper) auth() {\n\tvar err error\n\tvar res interface{}\n\tif uem._user != \"\" {\n\t\tres, err = uem.call(\"auth.login\", uem._user, uem._pwd)\n\t\tif err != nil {\n\t\t\tlog.Fatal(\"Login error:\", err.Error())\n\t\t}\n\t\tuem._session = res.(string)\n\t\tlog.Println(\"AUTH: Session:\", uem._session)\n\t} else {\n\t\tlog.Fatalf(\"User needs to be defined for XML-RPC login\")\n\t}\n}", "func (app *App) SetAuth(r *http.Request) {\n\n}", "func CheckAuth(s Session) *PzCustomError {\n\ttargURL := s.PzAddr + \"/service\"\n\tLogAudit(s, s.UserID, \"verify Piazza auth key request\", targURL, \"\", INFO)\n\t_, err := SubmitSinglePart(\"GET\", \"\", targURL, s.PzAuth)\n\tif err != nil {\n\t\treturn &PzCustomError{LogMsg: \"Could not confirm user authorization.\"}\n\t}\n\tLogAudit(s, targURL, \"verify Piazza auth key response\", s.UserID, \"\", INFO)\n\treturn nil\n}", "func CheckAuth(prefix string, repo *model.Repo) func(jqeventrouter.Handler) jqeventrouter.Handler {\n\treturn func(h jqeventrouter.Handler) jqeventrouter.Handler {\n\t\treturn jqeventrouter.HandlerFunc(func(event *jquery.Event, ui *js.Object, params url.Values) bool {\n\t\t\treqURL, _ := url.Parse(ui.Get(\"toPage\").String())\n\t\t\tif reqURL.Path == prefix+\"/callback.html\" {\n\t\t\t\t// Allow unauthenticated callback, needed by dev logins\n\t\t\t\treturn true\n\t\t\t}\n\t\t\t_, err := repo.CurrentUser()\n\t\t\tif err != nil && err != model.ErrNotLoggedIn {\n\t\t\t\tlog.Printf(\"Unknown error: %s\", err)\n\t\t\t}\n\t\t\tif err == model.ErrNotLoggedIn {\n\t\t\t\tredir := \"login.html\"\n\t\t\t\tlog.Debug(\"TODO: use params instead of re-parsing URL?\")\n\t\t\t\tparsed, _ := url.Parse(js.Global.Get(\"location\").String())\n\t\t\t\tfmt.Printf(\"params = %v\\nparsed = %v\\n\", params, parsed.Query())\n\t\t\t\tif p := parsed.Query().Get(\"provider\"); p != \"\" {\n\t\t\t\t\tredir = \"callback.html\"\n\t\t\t\t}\n\t\t\t\tlog.Printf(\"Redirecting unauthenticated user to %s\\n\", redir)\n\t\t\t\tlog.Debug(\"TODO: Do I need ui.Set *and* trigger before change here?\")\n\t\t\t\tui.Set(\"toPage\", redir)\n\t\t\t\tevent.StopImmediatePropagation()\n\t\t\t\tjquery.NewJQuery(\":mobile-pagecontainer\").Trigger(\"pagecontainerbeforechange\", ui)\n\t\t\t\treturn true\n\t\t\t}\n\t\t\treturn h.HandleEvent(event, ui, url.Values{})\n\t\t})\n\t}\n}", "func (o *Operator) authenticated(r *http.Request) bool {\n\tlog.Print(o.config.Auth.Password)\n\n\t_, password, _ := r.BasicAuth()\n\tif o.config.Auth.Password != \"\" && o.config.Auth.Password != password {\n\t\treturn false\n\t}\n\treturn true\n}", "func (e *ECU) authInit() error {\n\treturn nil\n}", "func RequiredAuth(appCtx appctx.AppContext, authStore AuthenStore) func(c *gin.Context) {\n\ttokenProvider := jwt.NewTokenJWTProvider(appCtx.SecretKey())\n\n\treturn func(c *gin.Context) {\n\t\ttoken, err := extractTokenFromHeaderString(c.GetHeader(\"Authorization\"))\n\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\t//db := appCtx.GetMaiDBConnection()\n\t\t//store := userstore.NewSQLStore(db)\n\t\t//\n\t\tpayload, err := tokenProvider.Validate(token)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\t//\n\t\t//user, err := store.FindUser(c.Request.Context(), map[string]interface{}{\"id\": payload.UserId})\n\n\t\tuser, err := authStore.FindUser(c.Request.Context(), map[string]interface{}{\"id\": payload.UserId})\n\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tif user.Status == 0 {\n\t\t\tpanic(common.ErrNoPermission(errors.New(\"user has been deleted or banned\")))\n\t\t}\n\n\t\tuser.Mask(false)\n\n\t\tc.Set(common.CurrentUser, user)\n\t\tc.Next()\n\t}\n}", "func (controller *Controller) Auth(context *gin.Context) {\n\tdto := userServices.AuthenticateUserDTO{}\n\tparser.Parser(context.Request, &dto)\n\n\trepo := userDB.SetupRepository(controller.Connection)\n\ttoken, err := userServices.AuthenticateUserService(repo, dto)\n\n\tif err.Message != \"\" {\n\t\tcontext.JSON(200, err)\n\t} else {\n\t\tcontext.JSON(400, token)\n\t}\n\n\treturn\n}", "func (a *Auth) HasToBeAuth(next http.HandlerFunc) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tuserPayload := user.PayloadFromContext(r.Context())\n\n\t\tif userPayload == nil {\n\t\t\tflash.Add(\"/login\", w, r, notAuthErrorMessage)\n\n\t\t\treturn\n\t\t}\n\n\t\tnext(w, r)\n\t}\n}", "func (p *authPipe) AuthOK(intSizer unqualifiedIntSizer) {\n\tp.readerDone <- authRes{intSizer: intSizer}\n}", "func (c Clients) Auth(ctx context.Context, username, password string) error {\n\tvar req *request\n\tif username == \"\" {\n\t\treq = newRequest(\"*2\\r\\n$4\\r\\nAUTH\\r\\n$\")\n\t\treq.addString(password)\n\t} else {\n\t\treq = newRequest(\"*3\\r\\n$4\\r\\nAUTH\\r\\n$\")\n\t\treq.addString2(username, password)\n\t}\n\treturn c.c.cmdSimple(ctx, req)\n}", "func (m *MockServiceAuth) Auth(arg0 models.UserInput) (models.UserBoardsOutside, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Auth\", arg0)\n\tret0, _ := ret[0].(models.UserBoardsOutside)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (o *SlackOAuthHandlers) Auth(w http.ResponseWriter, r *http.Request) {\n\tparams, err := url.ParseQuery(r.URL.RawQuery)\n\tif err != nil {\n\t\thlog.FromRequest(r).Error().\n\t\t\tErr(err).\n\t\t\tMsg(\"parsing query params\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// An error is received when a user declines to install\n\t// or an unexpected issue occurs. The app treats a\n\t// declined install gracefully.\n\tif params[\"error\"] != nil {\n\t\tswitch params[\"error\"][0] {\n\t\tcase errAccessDenied:\n\t\t\thlog.FromRequest(r).Info().\n\t\t\t\tErr(errors.New(params[\"error\"][0])).\n\t\t\t\tMsg(\"user declined install\")\n\t\t\tw.WriteHeader(http.StatusOK)\n\t\t\treturn\n\t\tdefault:\n\t\t\thlog.FromRequest(r).Error().\n\t\t\t\tErr(errors.New(params[\"error\"][0])).\n\t\t\t\tMsg(\"failed install\")\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n\n\tcode := params[\"code\"]\n\tif len(code) != 1 {\n\t\thlog.FromRequest(r).Error().\n\t\t\tErr(err).\n\t\t\tMsg(\"code not provided\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// TODO: inject an http client with http logging.\n\tresp, err := http.Get(fmt.Sprintf(\n\t\to.AccessURLTemplate,\n\t\to.ClientID,\n\t\to.ClientSecret,\n\t\tcode[0],\n\t))\n\tif err != nil {\n\t\thlog.FromRequest(r).Error().\n\t\t\tErr(err).\n\t\t\tMsg(\"oauth req error\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvar access accessResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&access); err != nil {\n\t\thlog.FromRequest(r).Error().\n\t\t\tErr(err).\n\t\t\tMsg(\"unable to decode slack access response\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif !access.OK {\n\t\thlog.FromRequest(r).Warn().\n\t\t\tMsg(\"access not ok\")\n\t\tw.WriteHeader(http.StatusForbidden)\n\t\treturn\n\t}\n\n\terr = o.TokenWriter.Store(&TokenData{\n\t\tTeamID: access.TeamID,\n\t\tUserID: access.UserID,\n\t\tBotToken: access.Bot.BotAccessToken,\n\t\tBotUserID: access.Bot.BotUserID,\n\t\tAccessToken: access.AccessToken,\n\t})\n\tif err != nil {\n\t\thlog.FromRequest(r).Error().\n\t\t\tErr(err).\n\t\t\tMsg(\"unable to store token\")\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tredirect := fmt.Sprintf(\"https://slack.com/app_redirect?app=%s\", o.AppID)\n\thttp.Redirect(w, r, redirect, http.StatusFound)\n}", "func (c *Conn) authDone(success bool) {\n\tc.replied = true\n\tc.state = sHelo\n\tc.nextEvent = nil\n\tc.authenticated = success\n}", "func (u *User) Auth(password string) bool {\n\treturn common.CheckPasswordHash(password, u.Password)\n}", "func (a *API) Auth(req *http.Request) {\n\t//Supports unauthenticated access to confluence:\n\t//if username and token are not set, do not add authorization header\n\tif a.Username != \"\" && a.Token != \"\" {\n\t\treq.SetBasicAuth(a.Username, a.Token)\n\t}\n}", "func (*SpecialAuth) AuthFunc(_ context.Context, apiKey string, _ map[string]string) bool {\n\treturn apiKey == \"12345\"\n}", "func TestAuthRequestGetters(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"foo\", func(r res.AuthRequest) {\n\t\t\trestest.AssertEqualJSON(t, \"Method\", r.Method(), \"foo\")\n\t\t\trestest.AssertEqualJSON(t, \"CID\", r.CID(), mock.CID)\n\t\t\trestest.AssertEqualJSON(t, \"Header\", r.Header(), mock.Header)\n\t\t\trestest.AssertEqualJSON(t, \"Host\", r.Host(), mock.Host)\n\t\t\trestest.AssertEqualJSON(t, \"RemoteAddr\", r.RemoteAddr(), mock.RemoteAddr)\n\t\t\trestest.AssertEqualJSON(t, \"URI\", r.URI(), mock.URI)\n\t\t\tr.NotFound()\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"foo\", nil).\n\t\t\tResponse().\n\t\t\tAssertError(res.ErrNotFound)\n\t})\n}", "func (srv *Server) Auth(f func(*Peer, []byte) (bool, error), mechanisms ...string) error {\n\tif len(mechanisms) != 0 {\n\t\t// Check that all authenticatedUser configured authentication mechanisms are support\n\t\tfor _, mech := range mechanisms {\n\t\t\tif !stringInSlice(mech, SupportedAuthMechanisms) {\n\t\t\t\treturn fmt.Errorf(\"%v authentication mechanism is not supported\", mech)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tmechanisms = SupportedAuthMechanisms\n\t}\n\tsrv.authMechanisms = mechanisms\n\tsrv.Authenticator = f\n\treturn nil\n}", "func (sry *Sryun) Auth(token, secret string) (string, error) {\n\treturn sry.User.Login, nil\n}", "func (bsms *BeiWeiShortMesssagingService) Auth() string {\n\tstr := fmt.Sprintf(\"%s%s\", bsms.SN, bsms.PWD)\n\treturn strings.ToUpper(MD5(str))\n}", "func Auth(next handlers.HandlerFunc) handlers.HandlerFunc {\n\treturn func(env *handlers.Env, w http.ResponseWriter, r *http.Request) error {\n\t\tsignature, err := r.Cookie(\"signature\")\n\t\tif err != nil {\n\t\t\treturn handlers.StatusData{\n\t\t\t\tCode: http.StatusUnauthorized,\n\t\t\t\tData: map[string]string{\n\t\t\t\t\t\"error\": \"No signature cookie found\",\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\theaderPayload, err := r.Cookie(\"header.payload\")\n\t\tif err != nil {\n\t\t\treturn handlers.StatusData{\n\t\t\t\tCode: http.StatusUnauthorized,\n\t\t\t\tData: map[string]string{\n\t\t\t\t\t\"error\": \"No headerPayload cookie found\",\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\ttokenString := headerPayload.Value + \".\" + signature.Value\n\n\t\tctx := cnt.Background()\n\t\tauthManager := auth_proto.NewAuthCheckerClient(env.GRCPAuth)\n\t\ttoken, err := authManager.Check(ctx,\n\t\t\t&auth_proto.Token{\n\t\t\t\tToken: tokenString,\n\t\t\t})\n\n\t\tif err != nil {\n\t\t\tenv.Logger.Errorw(\"Error during grpc request\",\n\t\t\t\t\"err\", err.Error(),\n\t\t\t\t\"grpc\", \"user\",\n\t\t\t)\n\t\t\treturn handlers.StatusData{\n\t\t\t\tCode: http.StatusInternalServerError,\n\t\t\t\tData: map[string]string{\n\t\t\t\t\t\"error\": \"Internal server error\",\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\tif !token.Valid {\n\t\t\treturn handlers.StatusData{\n\t\t\t\tCode: http.StatusUnauthorized,\n\t\t\t\tData: map[string]string{\n\t\t\t\t\t\"error\": \"Token is not valid\",\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\tclaims := make(map[string]interface{})\n\t\terr = json.Unmarshal(token.Claims, &claims)\n\t\tif err != nil {\n\t\t\tenv.Logger.Warnw(\"Can't unmarshall data\",\n\t\t\t\t\"err\", err.Error(),\n\t\t\t\t\"data\", claims,\n\t\t\t\t\"json\", string(token.Claims),\n\t\t\t)\n\t\t\treturn handlers.StatusData{\n\t\t\t\tCode: http.StatusUnauthorized,\n\t\t\t\tData: map[string]string{\n\t\t\t\t\t\"error\": \"Token is not valid\",\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\tcontext.Set(r, \"claims\", claims)\n\n\t\treturn next(env, w, r)\n\t}\n}", "func (e VerifyHandler) AuthHandler(http.ResponseWriter, *http.Request) {}", "func TestAuth_WithMultipleResponses_CausesPanic(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.OK(nil)\n\t\t\trestest.AssertPanic(t, func() {\n\t\t\t\tr.MethodNotFound()\n\t\t\t})\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\ts.Auth(\"test.model\", \"method\", mock.Request()).\n\t\t\tResponse().\n\t\t\tAssertResult(nil)\n\t})\n}", "func (sc *serverConn) auth() error {\n\tif len(sc.username) == 0 && len(sc.password) == 0 {\n\t\treturn nil\n\t}\n\ts, err := sc.authList()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tswitch {\n\tcase strings.Index(s, \"PLAIN\") != -1:\n\t\treturn sc.authPlain()\n\t}\n\n\treturn &Error{StatusAuthUnknown, fmt.Sprintf(\"mc: unknown auth types %q\", s), nil}\n}", "func CheckAuth(ctx context.Context, sys *types.SystemContext, username, password, registry string) error {\n\tnewLoginClient, err := newDockerClientWithDetails(sys, registry, username, password, \"\", nil, \"\")\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error creating new docker client\")\n\t}\n\n\tresp, err := newLoginClient.makeRequest(ctx, \"GET\", \"/v2/\", nil, nil, v2Auth)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\tswitch resp.StatusCode {\n\tcase http.StatusOK:\n\t\treturn nil\n\tcase http.StatusUnauthorized:\n\t\treturn ErrUnauthorizedForCredentials\n\tdefault:\n\t\treturn errors.Errorf(\"error occured with status code %q\", resp.StatusCode)\n\t}\n}", "func Auth(service auth.Service, optional ...bool) fiber.Handler {\n\treturn func(c *fiber.Ctx) error {\n\t\th := c.Get(\"Authorization\")\n\n\t\tif len(optional) > 0 {\n\t\t\tif h == \"\" {\n\t\t\t\treturn c.Next()\n\t\t\t}\n\n\t\t\t// Split the header\n\t\t\tchunks := strings.Split(h, \" \")\n\n\t\t\t// If header signature is not like `Bearer <token>`, then throw\n\t\t\t// This is also required, otherwise chunks[1] will throw out of bound error\n\t\t\tif len(chunks) < 2 {\n\t\t\t\treturn c.Next()\n\t\t\t}\n\n\t\t\t// Verify the token which is in the chunks\n\t\t\tuser, err := jwt.Verify(chunks[1])\n\n\t\t\tif err != nil {\n\t\t\t\treturn c.Next()\n\t\t\t}\n\n\t\t\tif isActive := service.IsUserActiveByUsername(user.Username); !isActive {\n\t\t\t\treturn c.Next()\n\t\t\t}\n\n\t\t\tc.Locals(\"UserId\", user.ID)\n\t\t\tc.Locals(\"User\", user.Username)\n\n\t\t\treturn c.Next()\n\t\t}\n\n\t\tif h == \"\" {\n\t\t\treturn utils.ErrUnauthorized\n\t\t}\n\n\t\t// Split the header\n\t\tchunks := strings.Split(h, \" \")\n\n\t\t// If header signature is not like `Bearer <token>`, then throw\n\t\t// This is also required, otherwise chunks[1] will throw out of bound error\n\t\tif len(chunks) < 2 {\n\t\t\treturn utils.ErrUnauthorized\n\t\t}\n\n\t\t// Verify the token which is in the chunks\n\t\tuser, err := jwt.Verify(chunks[1])\n\n\t\tif err != nil {\n\t\t\treturn utils.ErrUnauthorized\n\t\t}\n\n\t\tif isActive := service.IsUserActiveByUsername(user.Username); !isActive {\n\t\t\treturn utils.ErrUnauthorized\n\t\t}\n\n\t\tc.Locals(\"UserId\", user.ID)\n\t\tc.Locals(\"User\", user.Username)\n\n\t\treturn c.Next()\n\t}\n}", "func HelloAuth(ctx context.Context, e AuthEvent) error {\n\tlog.Printf(\"Function triggered by creation or deletion of user: %q\", e.UID)\n\tlog.Printf(\"Created at: %v\", e.Metadata.CreatedAt)\n\tif e.Email != \"\" {\n\t\tlog.Printf(\"Email: %q\", e.Email)\n\t}\n\treturn nil\n}", "func (a *BasicAuth) CheckAuth(r *http.Request) string {\n\ts := strings.SplitN(r.Header.Get(\"Authorization\"), \" \", 2)\n\tif len(s) != 2 || s[0] != \"Basic\" {\n\t\treturn \"\"\n\t}\n\n\tb, err := base64.StdEncoding.DecodeString(s[1])\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tpair := strings.SplitN(string(b), \":\", 2)\n\tif len(pair) != 2 {\n\t\treturn \"\"\n\t}\n\tuser, password := pair[0], pair[1]\n\tsecret := a.Secrets(user, a.Realm)\n\tif secret == \"\" {\n\t\treturn \"\"\n\t}\n\tcompare := compareFuncs[0].compare\n\tfor _, cmp := range compareFuncs[1:] {\n\t\tif strings.HasPrefix(secret, cmp.prefix) {\n\t\t\tcompare = cmp.compare\n\t\t\tbreak\n\t\t}\n\t}\n\tif compare([]byte(secret), []byte(password)) != nil {\n\t\treturn \"\"\n\t}\n\treturn pair[0]\n}", "func mustAuthenticate(sess *session, tag string, commandName string) *response {\n\tmessage := commandName + \" not authenticated\"\n\tsess.log(message)\n\treturn bad(tag, message)\n}", "func GetAuth() bool {\n\tveryFlagInput()\n\treturn auth\n}", "func (s *Server) invalidAuth(req *btcjson.Request) bool {\n\tcmd, err := btcjson.UnmarshalCmd(req)\n\tif err != nil {\n\t\treturn false\n\t}\n\tauthCmd, ok := cmd.(*btcjson.AuthenticateCmd)\n\tif !ok {\n\t\treturn false\n\t}\n\t// Check credentials.\n\tlogin := authCmd.Username + \":\" + authCmd.Passphrase\n\tauth := \"Basic \" + base64.StdEncoding.EncodeToString([]byte(login))\n\tauthSha := sha256.Sum256([]byte(auth))\n\treturn subtle.ConstantTimeCompare(authSha[:], s.authsha[:]) != 1\n}", "func (cb *callBack) OnAuthComplete(zcnTxn *zcncore.Transaction, status int) {\n\tlog.Logger.Debug(\"Transaction authenticated\",\n\t\tzap.String(\"status\", TxnStatus(status).String()),\n\t\tzap.String(\"hash\", zcnTxn.GetTransactionHash()),\n\t)\n}", "func (mr *MockAuthMockRecorder) AuthAndVerify(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"AuthAndVerify\", reflect.TypeOf((*MockAuth)(nil).AuthAndVerify), arg0, arg1)\n}", "func AuthRequired(c *gin.Context) {\n\tsession := sessions.Default(c)\n\tsession.Set(\"user\", \"aoki\")\n\tuser := session.Get(userKey)\n\tif user == nil {\n\t\t// Abort the request with the appropriate error code\n\t\tc.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{\"error\": \"unauthorized\"})\n\t\treturn\n\t}\n\t// Continue down the chain to handler etc\n\tc.Next()\n}", "func simpleAuth(w http.ResponseWriter, r *http.Request) (err string) {\n\theader := strings.Fields(r.Header.Get(\"Authorization\"))\n\tif len(header) < 2 {\n\t\tInfo.Println(\"No token given, not able to process request\")\n\t\treturn \"ko\"\n\t}\n\ts := strings.SplitN(r.Header.Get(\"Authorization\"), \" \", 2)\n\tif s[1] == token {\n\t\tDebug.Println(\"Token is eligible\")\n\t} else {\n\t\thttp.Error(w, \"Not authorized\", 401)\n\n\t}\n\treturn \"\"\n}", "func (a *FakeAuth) AddAuth(req *http.Request) error {\n\treturn nil\n}", "func (w Web) Auth(c *gin.Context) {\n\tif expectedHash, ok := c.GetQuery(\"hash\"); ok {\n\t\tvar errorMessage string\n\t\tvar datas []string\n\t\tfor k, v := range c.Request.URL.Query() {\n\t\t\tif k == \"hash\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tdatas = append(datas, fmt.Sprintf(\"%s=%s\", k, v[0]))\n\t\t}\n\t\tsort.Strings(datas)\n\t\tmac := hmac.New(sha256.New, w.SecretKey[:])\n\t\tauthDataStr := strings.Join(datas, \"\\n\")\n\t\tio.WriteString(mac, authDataStr)\n\t\thash := fmt.Sprintf(\"%x\", mac.Sum(nil))\n\t\tif expectedHash != hash {\n\t\t\terrorMessage = \"data is not from Telegram\"\n\t\t} else if authDate, err := strconv.Atoi(c.Query(\"auth_date\")); err == nil {\n\t\t\tif int64(time.Now().Sub(time.Unix(int64(authDate), 0)).Seconds()) > 86400 {\n\t\t\t\terrorMessage = \"Data is outdated\"\n\t\t\t} else {\n\t\t\t\tw.setCookie(c, \"auth_data_str\", authDataStr)\n\t\t\t\tw.setCookie(c, \"auth_data_hash\", hash)\n\t\t\t\tuserid, err := strconv.ParseInt(c.Query(\"id\"), 10, 64)\n\t\t\t\tif err != nil {\n\t\t\t\t\t_logger.Printf(\"can not convert %s to int. err* %v\", c.Query(\"id\"), err)\n\t\t\t\t}\n\t\t\t\tmsg := tgbotapi.NewMessage(userid, fmt.Sprintf(\"hello https://t.me/%d, welcome to NS_FC_bot.\", userid))\n\t\t\t\t_, err = w.TgBotClient.Send(msg)\n\t\t\t\tif err != nil {\n\t\t\t\t\t_logger.Printf(\"send message to user telegram failed. err: %v\", err)\n\t\t\t\t}\n\t\t\t\tw.setCookie(c, \"authed\", \"true\")\n\t\t\t\tc.Redirect(http.StatusTemporaryRedirect, \"/user/\"+c.Query(\"id\"))\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\terrorMessage = err.Error()\n\t\t}\n\t\tc.Redirect(http.StatusTemporaryRedirect, \"/login?error=\"+errorMessage)\n\t\treturn\n\t}\n}", "func (s *Session) Auth(serviceURL, authURL, email, password string) error {\n\tresp, err := s.Get(serviceURL)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tparsed, err := html.ParseFragment(resp.Body, nil)\n\tif err != nil || len(parsed) == 0 {\n\t\treturn err\n\t}\n\troot := parsed[0]\n\tform, ok := scrape.Find(root, scrape.ById(\"gaia_loginform\"))\n\tif !ok {\n\t\treturn errors.New(\"failed to process login page\")\n\t}\n\tsubmission := url.Values{}\n\tfor _, input := range scrape.FindAll(form, scrape.ByTag(atom.Input)) {\n\t\tsubmission.Add(getAttribute(input, \"name\"), getAttribute(input, \"value\"))\n\t}\n\tsubmission[\"Email\"] = []string{email}\n\tsubmission[\"Passwd\"] = []string{password}\n\n\tpostResp, err := s.PostForm(authURL, submission)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpostResp.Body.Close()\n\n\tif postResp.Request.Method == \"POST\" {\n\t\treturn errors.New(\"login incorrect\")\n\t}\n\n\treturn nil\n}", "func authCheck(c *gin.Context) {\n\t// Parse the token from the header. Take into account that the token prepended by Bearer\n\t// keyword.\n\tvar (\n\t\ttoken string\n\t\terr error\n\t)\n\t{\n\t\th := c.GetHeader(\"Authorization\")\n\t\tif len(h) < 8 {\n\t\t\tc.AbortWithStatusJSON(http.StatusUnauthorized, msg(\"authorization header missed or not valid\"))\n\t\t\treturn\n\t\t}\n\t\ts := strings.SplitN(h, \"Bearer \", 2)\n\t\tif len(s) < 2 {\n\t\t\tc.AbortWithStatusJSON(http.StatusUnauthorized, msg(\"badly formatted authorization header (Bearer missed)\"))\n\t\t\treturn\n\t\t}\n\t\ttoken = s[1]\n\t}\n\n\t// Pass auth data into gin context.\n\tvar u *user.User\n\t{\n\t\tif u, err = user.AuthCheck(context.Background(), token); err != nil {\n\t\t\tc.AbortWithStatusJSON(http.StatusUnauthorized, msg(err.Error()))\n\t\t\treturn\n\t\t}\n\t\tc.Set(session, *u)\n\t}\n\n\tc.Next()\n}", "func isAuthorizationDataCorrect(authInf AuthInf, responseWriter http.ResponseWriter) bool {\n\tauthInf.Login = html.EscapeString(authInf.Login)\n\tauthInf.Password = GeneratePasswordHash(authInf.Password)\n\tvar count int\n\terr := src.Connection.QueryRow(\"SELECT COUNT(id) as count FROM users WHERE \" +\n\t\t\"login=? AND password=?\", authInf.Login, authInf.Password).Scan(&count)\n\tif err != nil {\n\t\treturn conf.ErrDatabaseQueryFailed.Print(responseWriter)\n\t}\n\tif count > 0 {\n\t\treturn true\n\t} else {\n\t\treturn conf.ErrAuthDataIncorrect.Print(responseWriter)\n\t}\n}", "func (test *Test) SetupAuth(username, password, dbname string) error {\n\treturn nil\n}", "func (g *GitHubImpl) CheckAuth() (bool, error) {\n\n\tURL := fmt.Sprintf(g.URLNoEsc(urls.userRepo))\n\n\treq, _ := http.NewRequest(\"GET\", URL, nil)\n\tq := req.URL.Query()\n\tq.Add(\"access_token\", g.token)\n\treq.URL.RawQuery = q.Encode()\n\n\tclient := http.DefaultClient\n\tres, err := client.Do(req)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tif res.StatusCode != http.StatusOK {\n\t\treturn false, errors.New(strconv.Itoa(res.StatusCode))\n\t}\n\treturn true, nil\n}", "func (r *Receiver) SetupAuth(enc []byte, pkS kem.PublicKey) (Opener, error) {\n\tr.modeID = modeAuth\n\tr.enc = enc\n\tr.state.pkS = pkS\n\treturn r.allSetup()\n}", "func noValidTokenTest(t *testing.T, r *http.Request, h http.Handler, auth *mock.Authenticator) {\n\toriginal := auth.AuthenticateFn\n\tauth.AuthenticateFn = authenticateGenerator(false, errors.New(\"An error\"))\n\tw := httptest.NewRecorder()\n\th.ServeHTTP(w, r)\n\ttest.Equals(t, http.StatusBadRequest, w.Result().StatusCode)\n\tauth.AuthenticateFn = authenticateGenerator(false, nil)\n\tw = httptest.NewRecorder()\n\th.ServeHTTP(w, r)\n\ttest.Equals(t, http.StatusUnauthorized, w.Result().StatusCode)\n\tauth.AuthenticateFn = original\n}", "func isAuthenticated(w http.ResponseWriter, r *http.Request) {\n\tisLoggedIn := isLoggedIn(r)\n\n\tresp := map[string]interface{}{\n\t\t\"success\": isLoggedIn,\n\t}\n\tapiResponse(resp, w)\n}", "func MustHaveAuthHeader(res http.ResponseWriter, arc services.AuxRequestContext, log *config.CustomLog) {\n\tif arc.Header.Get(\"Authorization\") == \"\" {\n\t\tservices.Res(res).Error(401, \"invalid_request\", \"missing authorization header field\")\n\t}\n}", "func validateAuth(c *fb.Context, r *http.Request) (bool, *fb.User) {\n\tif c.Auth.Method == \"none\" {\n\t\tc.User = c.DefaultUser\n\t\treturn true, c.User\n\t}\n\n\t// If proxy auth is used do not verify the JWT token if the header is provided.\n\tif c.Auth.Method == \"proxy\" {\n\t\tu, err := c.Store.Users.GetByUsername(r.Header.Get(c.Auth.Header), c.NewFS)\n\t\tif err != nil {\n\t\t\treturn false, nil\n\t\t}\n\t\tc.User = u\n\t\treturn true, c.User\n\t}\n\n\tkeyFunc := func(token *jwt.Token) (interface{}, error) {\n\t\treturn c.Key, nil\n\t}\n\n\tvar claims claims\n\ttoken, err := request.ParseFromRequestWithClaims(r,\n\t\textractor{},\n\t\t&claims,\n\t\tkeyFunc,\n\t)\n\n\tif err != nil || !token.Valid {\n\t\treturn false, nil\n\t}\n\n\tu, err := c.Store.Users.Get(claims.User.ID, c.NewFS)\n\tif err != nil {\n\t\treturn false, nil\n\t}\n\n\tc.User = u\n\treturn true, u\n}", "func (c *Client) Auth() (string, error) {\n\t// First do an empty get to get the auth challenge\n\treq, err := http.NewRequest(http.MethodGet, c.BaseURL+\"/v2/\", nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\trsp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed sending auth request: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tio.Copy(io.Discard, rsp.Body)\n\n\tif rsp.StatusCode == http.StatusOK {\n\t\t// no auth needed\n\t\treturn \"\", nil\n\t}\n\n\tif rsp.StatusCode != http.StatusUnauthorized {\n\t\treturn \"\", fmt.Errorf(\"unexpected status %s\", rsp.Status)\n\t}\n\n\t// The Www-Authenticate header tells us where to go to get a token\n\tvals, err := parseWWWAuthenticate(rsp.Header.Get(\"Www-Authenticate\"))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tu, err := url.Parse(vals[\"realm\"])\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not parse authentication realm: %w\", err)\n\t}\n\tq := u.Query()\n\tq.Set(\"service\", vals[\"service\"])\n\tq.Set(\"scope\", \"repository:\"+c.Name+\":pull,push\")\n\tu.RawQuery = q.Encode()\n\n\tfmt.Printf(\"get %s\\n\", u)\n\n\treq, err = http.NewRequest(http.MethodGet, u.String(), nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treq.SetBasicAuth(c.User, c.Password)\n\n\trsp, err = http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed sending auth request: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"unexpected status %s\", rsp.Status)\n\t}\n\tbody, err := io.ReadAll(rsp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not read auth response body: %w\", err)\n\t}\n\n\ttype token struct {\n\t\tToken string `json:\"token\"`\n\t}\n\tvar tok token\n\tif err := json.Unmarshal(body, &tok); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to unmarshal token: %w\", err)\n\t}\n\n\treturn tok.Token, nil\n}", "func ValidateAuth(auth RextAuthDef) (hasError bool) {\n\tif len(auth.GetAuthType()) == 0 {\n\t\thasError = true\n\t\tlog.Errorln(\"type is required in auth config\")\n\t}\n\tif auth.GetAuthType() == AuthTypeCSRF {\n\t\topts := auth.GetOptions()\n\t\tif tkhk, err := opts.GetString(OptKeyRextAuthDefTokenHeaderKey); err != nil || len(tkhk) == 0 {\n\t\t\thasError = true\n\t\t\tlog.Errorln(\"token header key is required for CSRF auth type\")\n\t\t}\n\t\tif tkge, err := opts.GetString(OptKeyRextAuthDefTokenGenEndpoint); err != nil || len(tkge) == 0 {\n\t\t\thasError = true\n\t\t\tlog.Errorln(\"token gen endpoint is required for CSRF auth type\")\n\t\t}\n\t\tif tkfe, err := opts.GetString(OptKeyRextAuthDefTokenKeyFromEndpoint); err != nil || len(tkfe) == 0 {\n\t\t\thasError = true\n\t\t\tlog.Errorln(\"token from endpoint is required for CSRF auth type\")\n\t\t}\n\t}\n\treturn hasError\n}", "func (a *App) Auth() negroni.HandlerFunc {\n\treturn negroni.HandlerFunc(func(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\t\tdb, ok := context.Get(req, \"db\").(*mgo.Database)\n\t\tif !ok {\n\t\t\ta.R.JSON(w, http.StatusInternalServerError, &Response{Status: \"Error\", Message: \"Internal server error\"})\n\t\t\treturn\n\t\t}\n\t\tauthHeader := req.Header.Get(\"Authorization\")\n\t\tif authHeader == \"\" {\n\t\t\ta.R.JSON(w, http.StatusUnauthorized, &Response{Status: \"Error\", Message: \"Not Authorized\"})\n\t\t\treturn\n\t\t}\n\t\tdata, err := base64.StdEncoding.DecodeString(strings.Replace(authHeader, \"Basic \", \"\", 1))\n\t\tif err != nil {\n\t\t\ta.R.JSON(w, http.StatusUnauthorized, &Response{Status: \"Error\", Message: \"Not Authorized\"})\n\t\t\treturn\n\t\t}\n\t\tuser := &User{}\n\t\tparts := strings.Split(string(data), \":\")\n\t\tif len(parts) < 2 {\n\t\t\ta.R.JSON(w, http.StatusUnauthorized, &Response{Status: \"Error\", Message: \"Not Authorized\"})\n\t\t\treturn\n\t\t}\n\t\tif parts[0] == parts[1] {\n\t\t\tshaHash := sha256.New()\n\t\t\tif _, err := shaHash.Write([]byte(parts[0])); err != nil {\n\t\t\t\ta.R.JSON(w, http.StatusUnauthorized, &Response{Status: \"Error\", Message: \"Not Authorized\"})\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttoken := base64.StdEncoding.EncodeToString(shaHash.Sum(nil))\n\t\t\tif err := db.C(\"users\").Find(bson.M{\n\t\t\t\t\"services.resume.loginTokens\": bson.M{\"$elemMatch\": bson.M{\"hashedToken\": token}},\n\t\t\t}).One(&user); err != nil {\n\t\t\t\ta.R.JSON(w, http.StatusUnauthorized, &Response{Status: \"Error\", Message: \"Not Authorized\"})\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tin := []bson.M{bson.M{\"address\": parts[0], \"verified\": false}}\n\t\t\tif err := db.C(\"users\").Find(bson.M{\"emails\": bson.M{\"$in\": in}}).One(&user); err != nil {\n\t\t\t\ta.R.JSON(w, http.StatusUnauthorized, &Response{Status: \"Error\", Message: \"Not Authorized\"})\n\t\t\t\treturn\n\t\t\t}\n\t\t\tshaHash := sha256.New()\n\t\t\tif _, err := shaHash.Write([]byte(parts[1])); err != nil {\n\t\t\t\thttp.Error(w, \"Not Authorized\", http.StatusUnauthorized)\n\t\t\t\treturn\n\t\t\t}\n\t\t\th := hex.EncodeToString(shaHash.Sum(nil))\n\t\t\tif err := bcrypt.CompareHashAndPassword([]byte(user.Services.Password.Bcrypt), []byte(h)); err != nil {\n\t\t\t\ta.R.JSON(w, http.StatusUnauthorized, &Response{Status: \"Error\", Message: \"Not Authorized\"})\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t\tcontext.Set(req, \"user\", user)\n\t\tnext(w, req)\n\t})\n}", "func TestRegisteringDuplicateAuthMethodPanics(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\trestest.AssertPanic(t, func() {\n\t\t\ts.Handle(\"model\",\n\t\t\t\tres.Auth(\"foo\", func(r res.AuthRequest) {\n\t\t\t\t\tr.OK(nil)\n\t\t\t\t}),\n\t\t\t\tres.Auth(\"bar\", func(r res.AuthRequest) {\n\t\t\t\t\tr.OK(nil)\n\t\t\t\t}),\n\t\t\t\tres.Auth(\"foo\", func(r res.AuthRequest) {\n\t\t\t\t\tr.OK(nil)\n\t\t\t\t}),\n\t\t\t)\n\t\t})\n\t}, nil, restest.WithoutReset)\n}", "func (s *Service) Auth(c context.Context, username string) (res *model.Auth, err error) {\n\tuser := &model.User{}\n\tif err = s.dao.DB().Where(\"username = ?\", username).First(&user).Error; err != nil {\n\t\tif err == ecode.NothingFound {\n\t\t\terr = ecode.Int(10001)\n\t\t\treturn\n\t\t}\n\t\terr = errors.Wrapf(err, \"s.dao.DB().user.first(%s)\", username)\n\t\treturn\n\t}\n\tres = &model.Auth{\n\t\tUID: user.ID,\n\t\tUsername: user.Username,\n\t}\n\tres.Perms = make([]string, 10)\n\tres.Admin = true\n\treturn\n}", "func (s *server) isAuthentication(authRequired bool, loginStatus bool) bool {\n\treturn !(authRequired) || loginStatus\n}", "func (ah *AuthHandler) Auth(ctx *gin.Context) {\n\tvar req *request.AuthRequest\n\terr := ctx.Bind(&req)\n\tif err != nil {\n\t\tctx.JSON(http.StatusBadRequest, response.ErrorResponse{\n\t\t\tMessage: err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tuser, err := ah.Service.GetByEmail(ctx, req.Email)\n\tif err != nil {\n\t\tctx.JSON(http.StatusInternalServerError, response.ErrorResponse{\n\t\t\tMessage: err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tif user.Password != hashSHA256(req.Password) {\n\t\tctx.JSON(http.StatusForbidden, response.ErrorResponse{\n\t\t\tMessage: \"wrong password\",\n\t\t})\n\t\treturn\n\t}\n\n\ttoken, err := auth.NewClaims(user.ID, time.Now().Add(36*time.Hour).Unix()).Encode()\n\tif err != nil {\n\t\tctx.JSON(http.StatusInternalServerError, response.ErrorResponse{\n\t\t\tMessage: err.Error(),\n\t\t})\n\t\treturn\n\t}\n\n\tctx.JSON(http.StatusOK, response.AuthResponse{\n\t\tToken: token,\n\t})\n}", "func (auth *AuthManager) Auth(user account.AccountID, msg, sig []byte) error {\n\tclient := auth.user(user)\n\tif client == nil {\n\t\treturn fmt.Errorf(\"user %x not found\", user[:])\n\t}\n\treturn checkSigS256(msg, sig, client.acct.PubKey)\n}", "func Auth (c *gin.Context) {\n auth := c.Request.Header.Get(\"Authorization\")\n\n if strings.HasPrefix(auth, defaultAuthSchema) {\n token, err := jwt.Parse(auth[len(defaultAuthSchema)+1:], func(token *jwt.Token) (interface{}, error) {\n if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {\n return nil, fmt.Errorf(\"Unexpected signing method: %v\", token.Header[\"alg\"])\n }\n return []byte(SECRET), nil\n })\n \n if err == nil && token.Valid {\n \n userID := int(token.Claims[\"UserID\"].(float64))\n \n c.Set(\"UserID\", userID)\n c.Next()\n return\n }\n \n }\n\n c.Status(http.StatusUnauthorized)\n c.Abort()\n\n}", "func Auth() gin.HandlerFunc {\r\n\tif gin.Mode() == \"debug\" {\r\n\t\treturn func(c *gin.Context) { c.Next() }\r\n\t}\r\n\treturn func(c *gin.Context) {\r\n\t\tAccessKey := c.GetHeader(\"AccessKey\")\r\n\t\tif c.GetHeader(\"AccessKey\") == \"\" {\r\n\t\t\tAccessKey = c.GetHeader(\"Token\")\r\n\t\t}\r\n\r\n\t\tsession := sessions.Default(c)\r\n\t\tLoginUserID := session.Get(\"UserID\")\r\n\t\tIsLeader := session.Get(\"IsLeader\")\r\n\r\n\t\tfmt.Println(\"AccessKey: \", AccessKey)\r\n\t\tswitch AccessKey {\r\n\t\tcase \"\":\r\n\t\t\tif LoginUserID != nil {\r\n\t\t\t\tc.Set(\"UserID\", LoginUserID)\r\n\t\t\t\tc.Set(\"IsLeader\", IsLeader)\r\n\t\t\t\tc.Next()\r\n\t\t\t} else {\r\n\t\t\t\tsession := sessions.Default(c)\r\n\t\t\t\tUserID := session.Get(\"UserID\")\r\n\t\t\t\tIsLeader := session.Get(\"IsLeader\")\r\n\r\n\t\t\t\tfmt.Println(\"UserID, IsLeader\", UserID, IsLeader)\r\n\t\t\t\tif UserID == nil {\r\n\t\t\t\t\tc.JSON(http.StatusUnauthorized, gin.H{\"message\": \"Empty AccessKey Please authorize before requesting\"})\r\n\t\t\t\t\tc.Abort()\r\n\t\t\t\t}\r\n\t\t\t\tc.Set(\"UserID\", UserID)\r\n\t\t\t\tc.Set(\"IsLeader\", IsLeader)\r\n\t\t\t\tc.Next()\r\n\r\n\t\t\t}\r\n\r\n\t\tdefault:\r\n\t\t\tUserID, IsLeader, err := utils.LoadAccessKey(AccessKey)\r\n\r\n\t\t\tif LoginUserID != nil {\r\n\t\t\t\tc.Set(\"UserID\", UserID)\r\n\t\t\t\tc.Set(\"IsLeader\", IsLeader)\r\n\t\t\t\tc.Next()\r\n\t\t\t} else {\r\n\t\t\t\tif err != nil {\r\n\t\t\t\t\tc.JSON(http.StatusUnauthorized, gin.H{\"message\": \"Please authorize before requesting\"})\r\n\t\t\t\t\tc.Abort()\r\n\t\t\t\t}\r\n\r\n\t\t\t\tc.Set(\"UserID\", UserID)\r\n\t\t\t\tc.Set(\"IsLeader\", IsLeader)\r\n\r\n\t\t\t\tc.Next()\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}", "func (c *Client) Auth() error {\n\terr := c.writeMsg(fmt.Sprintf(\"USER %v\\r\\n\", c.config.Username))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmsg, err := c.readMsg(singleLineMessageTerminator)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif c.isError(msg) {\n\t\treturn errors.New(msg)\n\t}\n\n\terr = c.writeMsg(fmt.Sprintf(\"PASS %v\\r\\n\", c.config.Password))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmsg, err = c.readMsg(singleLineMessageTerminator)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif c.isError(msg) {\n\t\treturn errors.New(msg)\n\t}\n\n\tfmt.Printf(\"Authenticated\\n\")\n\n\treturn nil\n}" ]
[ "0.71050674", "0.6795108", "0.6762102", "0.6671263", "0.66693366", "0.65796834", "0.6568387", "0.6534614", "0.64098936", "0.6380983", "0.63791275", "0.6378445", "0.637458", "0.6303876", "0.6299012", "0.6288495", "0.62703717", "0.62702394", "0.6251795", "0.62452894", "0.6241667", "0.62364876", "0.6225714", "0.6224123", "0.617122", "0.61468494", "0.61444473", "0.6125914", "0.61196136", "0.61160105", "0.60978574", "0.60723525", "0.6070048", "0.60664946", "0.60047793", "0.59973735", "0.59971356", "0.59948486", "0.5991912", "0.5977101", "0.59753066", "0.59752345", "0.59712994", "0.5966932", "0.59647787", "0.5951743", "0.59431535", "0.59348804", "0.59339094", "0.5927849", "0.592472", "0.5922398", "0.5917725", "0.59134746", "0.5913186", "0.5874338", "0.58573604", "0.58557034", "0.5849424", "0.58459103", "0.58429855", "0.58424", "0.5842188", "0.5840703", "0.5828509", "0.5792287", "0.5784167", "0.57794106", "0.5764977", "0.5759401", "0.57521105", "0.5744247", "0.57422817", "0.5737376", "0.5724703", "0.5723999", "0.57233423", "0.5717915", "0.5716129", "0.57160056", "0.5712669", "0.5710567", "0.57070035", "0.5706109", "0.57060534", "0.56976885", "0.56869584", "0.5686043", "0.5671355", "0.56656796", "0.565914", "0.5655168", "0.5651077", "0.56504154", "0.56503993", "0.5642181", "0.56420904", "0.56274855", "0.5619396", "0.5616488" ]
0.6571172
6
CheckCookie mocks base method
func (m *MockServiceAuth) CheckCookie(arg0 echo.Context) (int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "CheckCookie", arg0) ret0, _ := ret[0].(int64) ret1, _ := ret[1].(error) return ret0, ret1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Checker) HasCookie(key, expectedValue string) *Checker {\n\tvalue, exists := c.cookies[key]\n\tassert.True(c.t, exists && expectedValue == value)\n\treturn c\n}", "func getCookie(r *http.Request, cookiename string) (bool, *http.Cookie) {\n // Ignoring error value because it is likely that the cookie might not exist here\n cookie, _ := r.Cookie(cookiename)\n if cookie == nil {\n return false, nil\n }\n return true, cookie\n}", "func Test_Ctx_Cookie(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\texpire := time.Now().Add(24 * time.Hour)\n\tvar dst []byte\n\tdst = expire.In(time.UTC).AppendFormat(dst, time.RFC1123)\n\thttpdate := strings.Replace(string(dst), \"UTC\", \"GMT\", -1)\n\tctx.Cookie(&Cookie{\n\t\tName: \"username\",\n\t\tValue: \"john\",\n\t\tExpires: expire,\n\t})\n\texpect := \"username=john; expires=\" + httpdate + \"; path=/; SameSite=Lax\"\n\tutils.AssertEqual(t, expect, string(ctx.Fasthttp.Response.Header.Peek(HeaderSetCookie)))\n\n\tctx.Cookie(&Cookie{SameSite: \"strict\"})\n\tctx.Cookie(&Cookie{SameSite: \"none\"})\n}", "func TestsetTokenCookie(t *testing.T) {\n\thand := New(nil)\n\n\twriter := httptest.NewRecorder()\n\treq := dummyGet()\n\n\ttoken := []byte(\"dummy\")\n\thand.setTokenCookie(writer, req, token)\n\n\theader := writer.Header().Get(\"Set-Cookie\")\n\texpected_part := fmt.Sprintf(\"csrf_token=%s;\", token)\n\n\tif !strings.Contains(header, expected_part) {\n\t\tt.Errorf(\"Expected header to contain %v, it doesn't. The header is %v.\",\n\t\t\texpected_part, header)\n\t}\n\n\ttokenInContext := unmaskToken(b64decode(Token(req)))\n\tif !bytes.Equal(tokenInContext, token) {\n\t\tt.Errorf(\"RegenerateToken didn't set the token in the context map!\"+\n\t\t\t\" Expected %v, got %v\", token, tokenInContext)\n\t}\n}", "func (cook ChangeProviderPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func MockProjectSessionCookie(projectID, secret string) *http.Cookie {\n\tstore := mockCookieStore()\n\n\tr := &http.Request{}\n\tw := httptest.NewRecorder()\n\n\tsession, _ := store.Get(r, getProjectSessionNameFromString(projectID))\n\n\tsession.Values[projectSecretKeyName] = secret\n\n\terr := session.Save(r, w)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn w.Result().Cookies()[0]\n}", "func Test_Session_Cookie(t *testing.T) {\n\tt.Parallel()\n\t// session store\n\tstore := New()\n\t// fiber instance\n\tapp := fiber.New()\n\t// fiber context\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\n\t// get session\n\tsess, _ := store.Get(ctx)\n\tsess.Save()\n\n\t// cookie should not be set if empty data\n\tutils.AssertEqual(t, 0, len(ctx.Response().Header.PeekCookie(store.CookieName)))\n}", "func (cook AwaitCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook ConfigureProviderPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func VerifyCookie(w http.ResponseWriter, r *http.Request) bool {\n\t_, err := r.Cookie(\"session\")\n\tif err != nil {\n\t\treturn false\n\t} else {\n\t\treturn true\n\t}\n}", "func CheckCookie(r *http.Request) bool {\r\n\t_, err := r.Cookie(envvar.CookieName())\r\n\tif err != nil {\r\n\t\treturn false\r\n\t}\r\n\treturn true\r\n}", "func (cook DeleteProviderPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func TestCurlGetJSONCookie(t *testing.T) {\n\tcurl := curlTester{\n\t\thandler: \"curl_get_json_cookie\",\n\t\ttestName: \"TestCurlGetJSONCookie\",\n\t\ttestHandle: t,\n\t}\n\tcurl.testGetCookie()\n}", "func (cook ChangeOutputPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (r *TestRequest) Cookie() uint64 {\n\treturn r.cookie\n}", "func (cook ChangeCounterCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (p *para) checkCookie(rawCookies string) {\n\theader := http.Header{}\n\theader.Add(\"Cookie\", rawCookies)\n\trequest := http.Request{Header: header}\n\tfor _, e := range request.Cookies() {\n\t\tif strings.Contains(e.Name, \"download_warning_\") {\n\t\t\tcookie, _ := request.Cookie(e.Name)\n\t\t\tp.Code = cookie.Value\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (c *Checker) Check() *Checker {\n\n\t// set cookies\n\tc.request.Header.Set(\"Cookie\", c.generateCookieString())\n\n\trecorder := httptest.NewRecorder()\n\tc.handler.ServeHTTP(recorder, c.request)\n\n\tresp := &http.Response{\n\t\tStatusCode: recorder.Code,\n\t\tBody: NewReadCloser(recorder.Body),\n\t\tHeader: recorder.Header(),\n\t}\n\tc.handleCookies(resp)\n\tc.response = resp\n\n\treturn c\n}", "func (cook ChangeAlarmCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SetCrtcTransformCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func Test_Ctx_Cookies(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tctx.Fasthttp.Request.Header.Set(\"Cookie\", \"john=doe\")\n\tutils.AssertEqual(t, \"doe\", ctx.Cookies(\"john\"))\n\tutils.AssertEqual(t, \"default\", ctx.Cookies(\"unknown\", \"default\"))\n}", "func (cook CreateCounterCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook TriggerFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook AwaitFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SelectInputCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook DestroyModeCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook ResetFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook CreateAlarmCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SetCounterCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SetProviderOffloadSinkCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func TestSimpleResponseGetCookieAndHeaders(t *testing.T) {\n\tr := NewSimpleResponse(\"A\", \"B\")\n\tif cookie := r.GetCookie(); cookie != nil {\n\t\tt.Fatalf(\"Unexpected cookie found. Should be nil, found: %+v.\", cookie)\n\t}\n\tif headers := r.GetHeaders(); headers != nil {\n\t\tt.Fatalf(\"Unexpected headers found. Should be nil, found: %+v.\", headers)\n\t}\n}", "func (cook ConfigureOutputPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func VerifyCookieFromRedisHTTP(ctx *fasthttp.RequestCtx, redisClient *redis.Client) {\n\tvar err error\n\tctx.Response.Header.SetContentType(\"application/json; charset=utf-8\") // Why not ? (:\n\tlog.Debug(\"VerifyCookieFromRedisHTTP | Retrieving username ...\")\n\tuser, _ := ParseAuthenticationCoreHTTP(ctx)\n\tlog.Debug(\"VerifyCookieFromRedisHTTP | Retrieving token ...\")\n\ttoken := ParseTokenFromRequest(ctx)\n\tlog.Debug(\"VerifyCookieFromRedisHTTP | Retrieving cookie from redis ...\")\n\tauth := authutils.VerifyCookieFromRedisHTTPCore(user, token, redisClient) // Call the core function for recognize if the user have the token\n\tif strings.Compare(auth, \"AUTHORIZED\") == 0 {\n\t\terr = json.NewEncoder(ctx).Encode(datastructures.Response{Status: true, Description: \"Logged in!\", ErrorCode: auth, Data: nil})\n\t\tcommonutils.Check(err, \"VerifyCookieFromRedisHTTP\")\n\t} else {\n\t\terr = json.NewEncoder(ctx).Encode(datastructures.Response{Status: false, Description: \"Not logged in!\", ErrorCode: auth, Data: nil})\n\t\tcommonutils.Check(err, \"VerifyCookieFromRedisHTTP\")\n\t}\n}", "func (cook SetCrtcGammaCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (m *MockSessionManager) Check(sessionId string) (bool, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Check\", sessionId)\n\tret0, _ := ret[0].(bool)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func TestReplaceCookie(t *testing.T) {\n\tDummyRequest := &http.Request{\n\t\tHeader: map[string][]string{\n\t\t\t\"Cookie\": {\"abcdef\"},\n\t\t},\n\t}\n\n\treplaceCookies(DummyRequest)\n\tassert.Equal(t, \"\", DummyRequest.Header.Get(Cookie))\n\tassert.Equal(t, 0, len(DummyRequest.Header[Cookie]))\n\n\tDummyRequest = &http.Request{\n\t\tHeader: map[string][]string{\n\t\t\tCookie: {},\n\t\t\tAPICookie: {\"test1\"},\n\t\t},\n\t}\n\n\treplaceCookies(DummyRequest)\n\tassert.Equal(t, \"test1\", DummyRequest.Header.Get(Cookie))\n\tassert.Equal(t, \"\", DummyRequest.Header.Get(APICookie))\n\tassert.Equal(t, 1, len(DummyRequest.Header[Cookie]))\n\tassert.Equal(t, 0, len(DummyRequest.Header[APICookie]))\n\n\tDummyRequest = &http.Request{\n\t\tHeader: map[string][]string{\n\t\t\tCookie: {},\n\t\t\tAPICookie: {\"test1\", \"test2\", \"test3\"},\n\t\t},\n\t}\n\n\treplaceCookies(DummyRequest)\n\t// Should not support multiple cookie headers\n\tassert.Equal(t, \"test1\", DummyRequest.Header.Get(Cookie))\n\tassert.Equal(t, \"\", DummyRequest.Header.Get(APICookie))\n\tassert.Equal(t, 1, len(DummyRequest.Header[Cookie]))\n\tassert.Equal(t, 0, len(DummyRequest.Header[APICookie]))\n\n\tDummyRequest = &http.Request{\n\t\tHeader: map[string][]string{\n\t\t\tCookie: {\"test0\"},\n\t\t\tAPICookie: {\"test1\", \"test2\", \"test3\"},\n\t\t},\n\t}\n\n\treplaceCookies(DummyRequest)\n\t// Original cookie should be overwritten\n\tassert.Equal(t, \"test1\", DummyRequest.Header.Get(Cookie))\n\tassert.Equal(t, \"\", DummyRequest.Header.Get(APICookie))\n\tassert.Equal(t, 1, len(DummyRequest.Header[Cookie]))\n\tassert.Equal(t, 0, len(DummyRequest.Header[APICookie]))\n\n\tDummyRequest = &http.Request{\n\t\tHeader: map[string][]string{\n\t\t\tCookie: {\"test0\", \"test1\"},\n\t\t\tAPICookie: {\"test2\", \"test3\", \"test4\"},\n\t\t},\n\t}\n\n\treplaceCookies(DummyRequest)\n\t// Should delete all original cookies\n\tassert.Equal(t, \"test2\", DummyRequest.Header.Get(Cookie))\n\tassert.Equal(t, \"\", DummyRequest.Header.Get(APICookie))\n\tassert.Equal(t, 1, len(DummyRequest.Header[Cookie]))\n\tassert.Equal(t, 0, len(DummyRequest.Header[APICookie]))\n\n}", "func (cook DestroyAlarmCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func TestCookieWithOptions(t *testing.T) {\n\tRunCookieSetup(t, func(privKey *rsa.PrivateKey) {\n\n\t\tsigner := NewCookieSigner(\"keyID\", privKey)\n\t\tsigner.Path = \"/\"\n\t\tsigner.Domain = testDomain\n\t\tsigner.Secure = false\n\n\t\tif signer.keyID != \"keyID\" || signer.privKey != privKey {\n\t\t\tt.Fatalf(\"NewCookieSigner does not properly assign values %+v\", signer)\n\t\t}\n\n\t\tp := &Policy{\n\t\t\tStatements: []Statement{\n\t\t\t\t{\n\t\t\t\t\tResource: \"*\",\n\t\t\t\t\tCondition: Condition{\n\t\t\t\t\t\tDateLessThan: &AWSEpochTime{time.Now().Add(1 * time.Hour)},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\n\t\tcookies, err := signer.SignWithPolicy(p)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Error signing cookies %#v\", err)\n\t\t}\n\t\tvalidateCookies(t, cookies, signer)\n\n\t})\n}", "func (cook DeleteOutputPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func CheckCookieValueAndForwardWithRequestContext(h http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {\n\t\taccessTokenCookie, err := req.Cookie(common.FlorenceCookieKey)\n\t\tif err != nil {\n\t\t\tif err != http.ErrNoCookie {\n\t\t\t\tlog.Error(req.Context(), \"unexpected error while extracting user Florence access token from cookie\", err)\n\t\t\t}\n\t\t} else {\n\t\t\treq = addUserAccessTokenToRequestContext(accessTokenCookie.Value, req)\n\t\t}\n\n\t\th.ServeHTTP(w, req)\n\t})\n}", "func (cook CreateFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func compareCookies(expectedCookie *Cookie, actualCookie *http.Cookie) (bool, []string) {\n\tcookieFound := *expectedCookie.name == actualCookie.Name\n\tcompareErrors := make([]string, 0)\n\tif cookieFound {\n\t\tcompareErrors = compareValue(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareDomain(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = comparePath(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareExpires(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareMaxAge(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareSecure(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareHttpOnly(expectedCookie, actualCookie, compareErrors)\n\t}\n\n\treturn cookieFound, compareErrors\n}", "func SetCookie(w http.ResponseWriter, r *http.Request) {\r\n\tcookieName := envvar.CookieName()\r\n\tcookie, err := r.Cookie(cookieName)\r\n\tif err != nil {\r\n\t\tcookie := &http.Cookie{\r\n\t\t\tName: cookieName,\r\n\t\t\tValue: (uuid.NewV4()).String(),\r\n\t\t\tHttpOnly: true,\r\n\t\t\tPath: \"/\",\r\n\t\t\tDomain: envvar.HostAddress(),\r\n\t\t\tSecure: true,\r\n\t\t}\r\n\t\thttp.SetCookie(w, cookie)\r\n\t\tlogger.Info.Println(\"set cookie : \" + cookie.Value + \"-\" + cookieName)\r\n\t\treturn\r\n\t}\r\n\t_, found := Get(r)\r\n\tif found {\r\n\t\tRefresh(r)\r\n\t\tlogger.Info.Println(\"session refresh: \" + cookie.Value)\r\n\t\treturn\r\n\t}\r\n\tlogger.Info.Println(cookie.Value + \" already set\")\r\n\r\n\treturn\r\n}", "func (cook DestroyCounterCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SetPriorityCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func genCookie(cookiename, value string) *http.Cookie {\n return &http.Cookie{\n Name: cookiename,\n Value: value,\n Expires: time.Now().Add(24 * time.Hour),\n }\n}", "func (cook DestroyFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (s SimpleResponse) GetCookie() *http.Cookie {\n\treturn nil\n}", "func (o *operation) getCookiesValid() bool {\n\tt := time.Now().UTC()\n\tfor _, p := range o.values {\n\t\tif p.cookieWriteTime.Before(t) {\n\t\t\tt = p.cookieWriteTime\n\t\t}\n\t}\n\td := time.Now().UTC().Sub(t) / time.Second\n\treturn d < o.services.config.HomeNodeTimeout\n}", "func getNameAndCookie(res http.ResponseWriter, req *http.Request) (string, bool) {\n\tvar name string\n\tvar ok bool\n\tvar cookie, err = req.Cookie(\"uuid\")\n\n\t//correctlyLogIn - means that both cookie and name exists\n\tcorrectlyLogIn := false\n\n\t// if the cookie is set up\n\tif err == nil {\n\n\t\t// retrive the name, before the access to map, lock it\n\t\tsessionsSyncLoc.RLock()\n\t\tname, ok = sessions[cookie.Value]\n\t\tsessionsSyncLoc.RUnlock()\n\n\t\tif ok {\n\t\t\t// if the name exists, set correctllyLogIn to true\n\t\t\tcorrectlyLogIn = true\n\t\t} else {\n\t\t\t// no name so invalidate cookie\n\t\t\tinvalidateCookie(res)\n\t\t}\n\t}\n\n\treturn name, correctlyLogIn\n}", "func (d *Cookie) Get(w http.ResponseWriter, r *http.Request, v any) (bool, error) {\n\ts, err := webmiddleware.GetSecureCookie(r.Context())\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tcookie, err := r.Cookie(d.Name)\n\tif err != nil || cookie.Value == tombstone {\n\t\treturn false, nil\n\t}\n\n\terr = s.Decode(d.Name, cookie.Value, v)\n\tif err != nil {\n\t\td.Remove(w, r)\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}", "func (cook AddOutputModeCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func validateCookieHandler(w http.ResponseWriter, r *http.Request, conf *config) {\n\t// initialize headers\n\tw.Header().Set(\"X-Auth-Request-Redirect\", \"\")\n\tw.Header().Set(\"X-Auth-Request-User\", \"\")\n\n\tauth := r.Header.Get(\"Authorization\")\n\tsplit := strings.SplitN(auth, \" \", 2)\n\tvar tokenvalue string = \"\"\n\tif len(split) == 2 && strings.EqualFold(split[0], \"bearer\") {\n\t\ttokenvalue = split[1]\n\t} else {\n\t\ttokenCookie, err := r.Cookie(conf.cookieName)\n\t\tswitch {\n\t\tcase err == http.ErrNoCookie:\n\t\t\tw.Header().Set(\"X-Auth-Request-Redirect\", redirectURL(r, conf, r.Header.Get(\"X-Okta-Nginx-Request-Uri\")))\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn\n\t\tcase err != nil:\n\t\t\tlog.Printf(\"validateCookieHandler: Error parsing cookie, %v\", err)\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn\n\t\t}\n\t\ttokenvalue = tokenCookie.Value\n\t}\n\n\tjwt, err := conf.verifier.VerifyAccessToken(tokenvalue)\n\n\tif err != nil {\n\t\tw.Header().Set(\"X-Auth-Request-Redirect\", redirectURL(r, conf, r.Header.Get(\"X-Okta-Nginx-Request-Uri\")))\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tsub, ok := jwt.Claims[\"sub\"]\n\tif !ok {\n\t\tlog.Printf(\"validateCookieHandler: Claim 'sub' not included in access token, %v\", tokenvalue)\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tsubStr, ok := sub.(string)\n\tif !ok {\n\t\tlog.Printf(\"validateCookieHandler: Unable to convert 'sub' to string in access token, %v\", tokenvalue)\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvalidateClaimsTemplate := strings.TrimSpace(r.Header.Get(\"X-Okta-Nginx-Validate-Claims-Template\"))\n\tif validateClaimsTemplate != \"\" {\n\t\tt, err := getTemplate(validateClaimsTemplate)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"validateCookieHandler: validateClaimsTemplate failed to parse template: '%v', error: %v\", validateClaimsTemplate, err)\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tvar resultBytes bytes.Buffer\n\t\tif err := t.Execute(&resultBytes, jwt.Claims); err != nil {\n\t\t\tclaimsJSON, _ := json.Marshal(jwt.Claims)\n\t\t\tlog.Printf(\"validateCookieHandler: validateClaimsTemplate failed to execute template: '%v', data: '%v', error: '%v'\", validateClaimsTemplate, claimsJSON, err)\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn\n\t\t}\n\t\tresultString := strings.ToLower(strings.TrimSpace(resultBytes.String()))\n\n\t\tif resultString != \"true\" && resultString != \"1\" {\n\t\t\tlog.Printf(\"validateCookieHandler: validateClaimsTemplate template: '%v', result: '%v', sub: '%v'\", validateClaimsTemplate, resultString, subStr)\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn\n\t\t}\n\t}\n\n\tsetHeaderNames := strings.Split(r.Header.Get(\"X-Okta-Nginx-Proxy-Set-Header-Names\"), \",\")\n\tsetHeaderValues := strings.Split(r.Header.Get(\"X-Okta-Nginx-Proxy-Set-Header-Values\"), \",\")\n\tif setHeaderNames[0] != \"\" && setHeaderValues[0] != \"\" && len(setHeaderNames) == len(setHeaderValues) {\n\t\tfor i := 0; i < len(setHeaderNames); i++ {\n\t\t\tt, err := getTemplate(setHeaderValues[i])\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"validateCookieHandler: setHeaderValues failed to parse template: '%v', error: %v\", validateClaimsTemplate, err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tvar resultBytes bytes.Buffer\n\t\t\tif err := t.Execute(&resultBytes, jwt.Claims); err != nil {\n\t\t\t\tclaimsJSON, _ := json.Marshal(jwt.Claims)\n\t\t\t\tlog.Printf(\"validateCookieHandler: setHeaderValues failed to execute template: '%v', data: '%v', error: '%v'\", validateClaimsTemplate, claimsJSON, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tresultString := strings.ToLower(strings.TrimSpace(resultBytes.String()))\n\n\t\t\tw.Header().Set(setHeaderNames[i], resultString)\n\t\t}\n\t}\n\n\tw.Header().Set(\"X-Auth-Request-User\", subStr)\n\tw.WriteHeader(http.StatusOK)\n}", "func Test_Ctx_ClearCookie(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tctx.Fasthttp.Request.Header.Set(HeaderCookie, \"john=doe\")\n\tctx.ClearCookie(\"john\")\n\tutils.AssertEqual(t, true, strings.HasPrefix(string(ctx.Fasthttp.Response.Header.Peek(HeaderSetCookie)), \"john=; expires=\"))\n\n\tctx.Fasthttp.Request.Header.Set(HeaderCookie, \"test1=dummy\")\n\tctx.Fasthttp.Request.Header.Set(HeaderCookie, \"test2=dummy\")\n\tctx.ClearCookie()\n\tutils.AssertEqual(t, true, strings.Contains(string(ctx.Fasthttp.Response.Header.Peek(HeaderSetCookie)), \"test1=; expires=\"))\n\tutils.AssertEqual(t, true, strings.Contains(string(ctx.Fasthttp.Response.Header.Peek(HeaderSetCookie)), \"test2=; expires=\"))\n}", "func CheckTheValidityOfTheTokenFromHTTPHeader(w http.ResponseWriter, r *http.Request) (writer http.ResponseWriter, newToken string, err error) {\n err = createError(011)\n for _, cookie := range r.Cookies() {\n if cookie.Name == \"Token\" {\n var token string\n token, err = CheckTheValidityOfTheToken(cookie.Value)\n //fmt.Println(\"T\", token, err)\n writer = SetCookieToken(w, token)\n newToken = token\n }\n }\n //fmt.Println(err)\n return\n}", "func (cook DeleteOutputModeCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func TestCurlGetJSONDigestAuthCookie(t *testing.T) {\n\tcurl := curlTester{\n\t\thandler: \"curl_get_json_cookie\",\n\t\ttestName: \"TestCurlGetJSONDigestAuthCookie\",\n\t\ttestHandle: t,\n\t}\n\tcurl.testGetDigestAuthCookie()\n}", "func (m *MockAuthCheckerClient) Check(arg0 context.Context, arg1 *auth.SessionToken, arg2 ...grpc.CallOption) (*auth.Session, error) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Check\", varargs...)\n\tret0, _ := ret[0].(*auth.Session)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (req *request) Cookie() Cookie {\n return req.cookies\n}", "func (mr *MockServiceAuthMockRecorder) CheckCookie(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"CheckCookie\", reflect.TypeOf((*MockServiceAuth)(nil).CheckCookie), arg0)\n}", "func (_m *AuthServer) Check(_a0 context.Context, _a1 *auth.SessionID) (*auth.SessionInfo, error) {\n\tret := _m.Called(_a0, _a1)\n\n\tvar r0 *auth.SessionInfo\n\tif rf, ok := ret.Get(0).(func(context.Context, *auth.SessionID) *auth.SessionInfo); ok {\n\t\tr0 = rf(_a0, _a1)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*auth.SessionInfo)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, *auth.SessionID) error); ok {\n\t\tr1 = rf(_a0, _a1)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (m *MockWebsocketAppInterface) CheckToken(userID int, csrfToken string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"CheckToken\", userID, csrfToken)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (client *HTTPClient) EnsureCookie(fromURL string, force bool) error {\n\tcURL, err := url.Parse(fromURL)\n\tif err != nil {\n\t\treturn WrapErr(err, \"failed to parse cookie URL\").With(\"url\", fromURL)\n\t}\n\tcookies := client.PersistentJar.Cookies(cURL)\n\tif force || len(cookies) == 0 {\n\t\tresp, err := client.Get(fromURL, nil)\n\t\tif err != nil {\n\t\t\treturn WrapErr(err, \"failed to fetch cookie URL\").With(\"url\", fromURL)\n\t\t}\n\t\tresp.Body.Close()\n\t}\n\treturn nil\n}", "func readCookie(res http.ResponseWriter, req *http.Request) {\n\tcookie := readCreateCookie(req)\n\thttp.SetCookie(res, cookie) // set cookie into browser.\n\tuserInformation = cookieInformationDecoding(cookie.Value) // decode and set user state into page variable.\n}", "func checkLogin(r *http.Request) bool {\n\t// grab the \"id\" cookie, fail if it doesn't exist\n\tcookie, err := r.Cookie(\"id\")\n\tif err == http.ErrNoCookie {\n\t\treturn false\n\t}\n\n\t// grab the \"key\" cookie, fail if it doesn't exist\n\tkey, err := r.Cookie(\"key\")\n\tif err == http.ErrNoCookie {\n\t\treturn false\n\t}\n\n\t// make sure we've got the right stuff in the hash\n\tcookieStore.RLock()\n\tdefer cookieStore.RUnlock()\n\treturn cookieStore.m[cookie.Value] == key.Value\n}", "func (h *ResponseHeader) Cookie(cookie *Cookie) bool {\n\tv := peekArgBytes(h.cookies, cookie.Key())\n\tif v == nil {\n\t\treturn false\n\t}\n\tcookie.ParseBytes(v) //nolint:errcheck\n\treturn true\n}", "func CheckLogin(w http.ResponseWriter, r *http.Request) bool {\n\tCookieSession, err := r.Cookie(\"sessionid\")\n\tif err != nil {\n\t\tfmt.Println(\"No Such Cookies\")\n\t\tSession.Create()\n\t\tfmt.Println(Session.ID)\n\t\tSession.Expire = time.Now().Local()\n\t\tSession.Expire.Add(time.Hour)\n\t\treturn false\n\t}\n\tfmt.Println(\"Cookki Found\")\n\ttempSession := session.UserSession{UID: 0}\n\tLoggedIn := database.QueryRow(\"select user_id from sessions where session_id = ?\",\n\t\tCookieSession).Scan(&tempSession)\n\tif LoggedIn == nil {\n\t\treturn false\n\t}\n\treturn true\n\n}", "func newCookie() (cookie *http.Cookie) {\n\tcookie = &http.Cookie{\n\t\tName: cookieSessionName,\n\t\tValue: cookieInformationEncoding(),\n\t\tHttpOnly: true,\n\t\t//Secure: false,\n\t}\n\treturn\n}", "func mockLoginAsUser() http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tusername, err := usernameFromRequestPath(r)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\thttp.SetCookie(w, &http.Cookie{\n\t\t\tName: \"userkit_auth_token\",\n\t\t\tValue: fmt.Sprintf(\"dummy_usr_token__%s:dummy\", username),\n\t\t\tPath: \"/\",\n\t\t\tExpires: time.Now().Add(600 * time.Hour),\n\t\t})\n\t\tlog.Printf(\"mock logged in as %s\", username)\n\t\thttp.Redirect(w, r, \"/\", http.StatusTemporaryRedirect)\n\t}\n}", "func TestFinisher(w http.ResponseWriter, r *http.Request) {\n\tdefer timings.Track(\"TestFinisher\", time.Now(), TimingOut)\n\n\tme, err := os.Hostname()\n\tif err != nil {\n\t\tme = \"localhost\"\n\t}\n\thr := forward.HeaderRewriter{TrustForwardHeader: true, Hostname: me}\n\thr.Rewrite(r)\n\n\tw.Write([]byte(fmt.Sprintf(\"\\nProtocol: %s\\n Major: %d\\n Minor: %d\\n\", r.Proto, r.ProtoMajor, r.ProtoMinor)))\n\n\tif r.TLS != nil {\n\t\tw.Write([]byte(\"\\nTLS:\\n\"))\n\t\tw.Write([]byte(fmt.Sprintf(\" Version: %s\\n\", SslVersions.Suite(r.TLS.Version))))\n\t\tw.Write([]byte(fmt.Sprintf(\" CipherSuite: %s\\n\", Ciphers.Suite(r.TLS.CipherSuite))))\n\t}\n\n\tw.Write([]byte(\"\\nHeaders:\\n\"))\n\thkeys := make([]string, 0, len(r.Header))\n\tfor k := range r.Header {\n\t\thkeys = append(hkeys, k)\n\t}\n\tsort.Strings(hkeys)\n\n\tfor _, k := range hkeys {\n\t\tv := r.Header.Values(k)\n\n\t\tif !Conf.GetBool(ConfigDebug) && (k == \"Cookie\") {\n\t\t\tw.Write([]byte(fmt.Sprintf(\" %s: <..redacted..>\\n\", k)))\n\t\t\tcontinue\n\t\t}\n\t\tfor _, av := range v {\n\t\t\tw.Write([]byte(fmt.Sprintf(\" %s: %s\\n\", k, av)))\n\t\t}\n\t}\n\n\tw.Write([]byte(\"\\nCookies:\\n\"))\n\tfor _, v := range r.Cookies() {\n\t\tval := v.Value\n\t\tw.Write([]byte(fmt.Sprintf(\" %s: %s\\n\", v.Name, val)))\n\t}\n\n}", "func CheckLoginByCookie(cookie BuyerCookie) bool {\n\treturn cookie.ID != 0\n}", "func (this *BaseController) CheckXsrfCookie() bool {\n return this.Controller.CheckXSRFCookie()\n}", "func (suite *AuthSuite) TestRedirectFromLoginGovForValidUser() {\n\t// build a real office user\n\ttioOfficeUser := factory.BuildOfficeUserWithRoles(suite.DB(), factory.GetTraitActiveOfficeUser(),\n\t\t[]roles.RoleType{roles.RoleTypeTIO})\n\n\thandlerConfig := suite.HandlerConfig()\n\tappnames := handlerConfig.AppNames()\n\n\tfakeToken := \"some_token\"\n\tsession := auth.Session{\n\t\tApplicationName: auth.OfficeApp,\n\t\tIDToken: fakeToken,\n\t\tHostname: appnames.OfficeServername,\n\t}\n\n\t// login.gov state cookie\n\tstateValue := \"someStateValue\"\n\tcookieName := StateCookieName(&session)\n\tcookie := http.Cookie{\n\t\tName: cookieName,\n\t\tValue: shaAsString(stateValue),\n\t\tPath: \"/\",\n\t\tExpires: auth.GetExpiryTimeFromMinutes(auth.SessionExpiryInMinutes),\n\t}\n\treq := httptest.NewRequest(\"GET\", fmt.Sprintf(\"http://%s/login-gov/callback?state=%s\",\n\t\tappnames.OfficeServername, stateValue), nil)\n\treq.AddCookie(&cookie)\n\n\tauthContext := suite.AuthContext()\n\n\tsessionManager := handlerConfig.SessionManagers().Office\n\treq = suite.SetupSessionRequest(req, &session, sessionManager)\n\n\tstubOfficeProvider := stubLoginGovProvider{\n\t\tStubName: officeProviderName,\n\t\tStubToken: \"stubToken\",\n\t\tStubUser: goth.User{\n\t\t\tUserID: tioOfficeUser.User.LoginGovUUID.String(),\n\t\t\tEmail: tioOfficeUser.Email,\n\t\t},\n\t}\n\tdefer goth.ClearProviders()\n\tgoth.UseProviders(&stubOfficeProvider)\n\th := CallbackHandler{\n\t\tauthContext,\n\t\thandlerConfig,\n\t\tsetUpMockNotificationSender(),\n\t}\n\n\trr := httptest.NewRecorder()\n\tsessionManager.LoadAndSave(h).ServeHTTP(rr, req)\n\n\tsuite.Equal(http.StatusTemporaryRedirect, rr.Code)\n\n\tsuite.Equal(suite.urlForHost(appnames.OfficeServername).String(),\n\t\trr.Result().Header.Get(\"Location\"))\n}", "func setCookie(res http.ResponseWriter, req *http.Request, id string) error {\r\n\t//name of cookies = \"cookie\" for 1hr & \"CRA\" for 2yrs\r\n\tco, _ := req.Cookie(\"CRA\")\r\n\tco = &http.Cookie{\r\n\t\tName: \"CRA\",\r\n\t\tValue: id,\r\n\t\tHttpOnly: false,\r\n\t\tExpires: time.Now().AddDate(2, 0, 0),\r\n\t}\r\n\thttp.SetCookie(res, co)\r\n\t// fmt.Println(\"Htmlmain.setCookie - done with set id = \", id)\r\n\treturn nil\r\n}", "func (l *LoginCookie) Check(value string) bool {\n\treturn l.validatorHash() == value\n}", "func (s *BasecookieListener) EnterCookie(ctx *CookieContext) {}", "func (cook SetScreenSizeCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func TestCurlPutBinaryCookie(t *testing.T) {\n\tcurl := curlTester{\n\t\thandler: \"curl_put_binary_cookie\",\n\t\ttestName: \"TestCurlPutBinaryCookie\",\n\t\ttestHandle: t,\n\t}\n\tcurl.testPutCookie()\n}", "func verifyLogin(req *restful.Request, resp *restful.Response ) bool {\n\tcookie, err := req.Request.Cookie(\"session-id\")\n\tif cookie.Value != \"\" {\n\t\t_, exists := sessions[cookie.Value]\n\t\tif !exists {\n\t\t\thttp.Redirect(resp.ResponseWriter, req.Request, \"/\", 302)\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t} else if err != nil {\n\t\tfmt.Println(err.Error())\n\t\thttp.Redirect(resp.ResponseWriter, req.Request, \"/\", 302)\n\t\treturn false\n\t} else {\n\t\thttp.Redirect(resp.ResponseWriter, req.Request, \"/\", 302)\n\t\treturn false\n\t}\n}", "func Benchmark_Ctx_Cookie(b *testing.B) {\n\tapp := New()\n\tc := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(c)\n\tb.ReportAllocs()\n\tb.ResetTimer()\n\tfor n := 0; n < b.N; n++ {\n\t\tc.Cookie(&Cookie{\n\t\t\tName: \"John\",\n\t\t\tValue: \"Doe\",\n\t\t})\n\t}\n\tutils.AssertEqual(b, \"John=Doe; path=/; SameSite=Lax\", getString(c.Fasthttp.Response.Header.Peek(\"Set-Cookie\")))\n}", "func readCreateCookie(req *http.Request) (cookie *http.Cookie) {\n\tcookie, err := req.Cookie(cookieSessionName) // get if a cookie already exists (had not expired)\n\tif err == http.ErrNoCookie {\n\t\tcookie = newCookie() // need a new cookie.\n\t}\n\treturn\n}", "func TestCurlPostBinaryCookie(t *testing.T) {\n\tcurl := curlTester{\n\t\thandler: \"curl_post_binary_cookie\",\n\t\ttestName: \"TestCurlPostBinaryCookie\",\n\t\ttestHandle: t,\n\t}\n\tcurl.testPostCookie()\n}", "func TestReplaceSetCookies(t *testing.T) {\n\tDummyRequest := &http.Response{\n\t\tHeader: map[string][]string{\n\t\t\tSetCookie: {\"test1=abc\", \"test2=def\", \"test3=ghi\"},\n\t\t\tAPISetCookie: {},\n\t\t},\n\t}\n\n\tsetModifiedHeaders(DummyRequest)\n\tassert.Equal(t, []string{\"test1=abc\", \"test2=def\", \"test3=ghi\"}, DummyRequest.Header[APISetCookie])\n\tassert.Equal(t, 0, len(DummyRequest.Header[SetCookie]))\n\tassert.Equal(t, []string{\"default-src 'none'; style-src 'unsafe-inline'; sandbox\"}, DummyRequest.Header[CSP])\n\tassert.Equal(t, []string{\"nosniff\"}, DummyRequest.Header[XContentType])\n\n\tDummyRequest = &http.Response{\n\t\tHeader: map[string][]string{\n\t\t\tSetCookie: {\"test1=abc\", \"test2=def\", \"test3=ghi\"},\n\t\t\tAPISetCookie: {\"test4=asdf\"},\n\t\t},\n\t}\n\n\tsetModifiedHeaders(DummyRequest)\n\t// Should delete original api set cookie\n\tassert.Equal(t, []string{\"test1=abc\", \"test2=def\", \"test3=ghi\"}, DummyRequest.Header[APISetCookie])\n\tassert.Equal(t, 0, len(DummyRequest.Header[SetCookie]))\n\tassert.Equal(t, []string{\"default-src 'none'; style-src 'unsafe-inline'; sandbox\"}, DummyRequest.Header[CSP])\n\tassert.Equal(t, []string{\"nosniff\"}, DummyRequest.Header[XContentType])\n}", "func hashKeyTests() {\n // make a set of inputs\n input := []string{\"17d4e712c41d95d3ad6972b00c7b87bc\", \"Hph7bg5SiKgVIXyAlvLIpAOs_RV42314\"}\n\n // do a for loop over the input values\n for _, v := range input {\n fmt.Printf(\"v: %s\\n\", v)\n\n // try to invoke the cookie method\n store := cookie.NewStore([]byte(v))\n sessions.Sessions(\"pm-sesson\", store)\n \n }\n}", "func (o *operation) getCookiesPresent() bool {\n\tz := true\n\tfor _, p := range o.values {\n\t\tz = z && (p.cookieWriteTime.IsZero() == false)\n\t}\n\treturn z\n}", "func (a *Auth) authCookie(ctx *bm.Context) (int64, error) {\n\treq := ctx.Request\n\tsession, _ := req.Cookie(\"SESSION\")\n\tif session == nil {\n\t\treturn 0, ecode.Unauthorized\n\t}\n\t// NOTE: 请求登录鉴权服务接口,拿到对应的用户id\n\tvar mid int64\n\t// TODO: get mid from some code\n\n\t// check csrf\n\tclientCsrf := req.FormValue(\"csrf\")\n\tif a.conf != nil && !a.conf.DisableCSRF && req.Method == \"POST\" {\n\t\t// NOTE: 如果开启了CSRF认证,请从CSRF服务获取该用户关联的csrf\n\t\tvar csrf string // TODO: get csrf from some code\n\t\tif clientCsrf != csrf {\n\t\t\treturn 0, ecode.Unauthorized\n\t\t}\n\t}\n\n\treturn mid, nil\n}", "func MakeCookies(u *url.URL, token *oauth2.Token) []*http.Cookie {\n\t// N.B. nscjar adds #HttpOnly_ for HttpOnly cookies, and these prevent\n\t// git recognize the cookies. Do not add.\n\tpath := u.Path\n\tif path == \"\" {\n\t\tpath = \"/\"\n\t}\n\t// The ending \".git\" is redundant.\n\tpath = strings.TrimSuffix(path, \".git\")\n\tif u.Host == \"googlesource.com\" {\n\t\t// Authenticate against all *.googlesource.com.\n\t\treturn []*http.Cookie{\n\t\t\t{\n\t\t\t\tName: \"o\",\n\t\t\t\tValue: token.AccessToken,\n\t\t\t\tPath: path,\n\t\t\t\tDomain: \".\" + u.Host,\n\t\t\t\tExpires: token.Expiry,\n\t\t\t\tSecure: u.Scheme == \"https\",\n\t\t\t},\n\t\t}\n\t} else if strings.HasSuffix(u.Host, \".googlesource.com\") {\n\t\t// Authenticate against both FOO.googlesource.com and\n\t\t// FOO-review.googlesource.com. These two URLs have no\n\t\t// difference.\n\t\th := strings.TrimSuffix(strings.TrimSuffix(u.Host, \".googlesource.com\"), \"-review\")\n\t\treturn []*http.Cookie{\n\t\t\t{\n\t\t\t\tName: \"o\",\n\t\t\t\tValue: token.AccessToken,\n\t\t\t\tPath: path,\n\t\t\t\tDomain: h + \".googlesource.com\",\n\t\t\t\tExpires: token.Expiry,\n\t\t\t\tSecure: u.Scheme == \"https\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tName: \"o\",\n\t\t\t\tValue: token.AccessToken,\n\t\t\t\tPath: path,\n\t\t\t\tDomain: h + \"-review.googlesource.com\",\n\t\t\t\tExpires: token.Expiry,\n\t\t\t\tSecure: u.Scheme == \"https\",\n\t\t\t},\n\t\t}\n\t}\n\treturn []*http.Cookie{\n\t\t{\n\t\t\tName: \"o\",\n\t\t\tValue: token.AccessToken,\n\t\t\tPath: path,\n\t\t\tDomain: u.Host,\n\t\t\tExpires: token.Expiry,\n\t\t\tSecure: u.Scheme == \"https\",\n\t\t},\n\t}\n}", "func VerifyCookie(cookie string, db UserGetter) (email string, err error) {\n\temail, token, mac, err := splitCookie(cookie)\n\tif err != nil {\n\t\treturn \"\", errors.NewClient(\"Not authenticated\")\n\t}\n\n\texpectedMac, err := computeMAC([]byte(email + \"#\" + token))\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"Failed to compute verification MAC\")\n\t}\n\n\tmessageMac, err := hex.DecodeString(mac)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"Failed to hex decode message mac\")\n\t}\n\tif !hmac.Equal(expectedMac, messageMac) {\n\t\treturn \"\", errors.NewClient(\"Not authenticated\")\n\t}\n\n\tuser, err := db.GetUserInfo(email)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"Failed to get user from database\")\n\t}\n\tif user.Token != token {\n\t\treturn \"\", errors.NewClient(\"Not authenticated\")\n\t}\n\treturn email, nil\n}", "func SetCookieToken(w http.ResponseWriter, token string) http.ResponseWriter {\n expiration := time.Now().Add(time.Minute * time.Duration(tokenValidity))\n cookie := http.Cookie{Name: \"Token\", Value: token, Expires: expiration}\n http.SetCookie(w, &cookie)\n return w\n}", "func TestHandler_Authorize(t *testing.T) {\n\t// Create the mock session store.\n\tvar saved bool\n\tstore := NewTestStore()\n\tsession := sessions.NewSession(store, \"\")\n\tstore.GetFunc = func(r *http.Request, name string) (*sessions.Session, error) {\n\t\treturn session, nil\n\t}\n\tstore.SaveFunc = func(r *http.Request, w http.ResponseWriter, session *sessions.Session) error {\n\t\tsaved = true\n\t\treturn nil\n\t}\n\n\t// Setup handler.\n\th := NewTestHandler()\n\th.Handler.Store = store\n\tdefer h.Close()\n\n\t// Create non-redirecting client.\n\tvar redirectURL *url.URL\n\tclient := &http.Client{\n\t\tCheckRedirect: func(req *http.Request, via []*http.Request) error {\n\t\t\tredirectURL = req.URL\n\t\t\treturn errors.New(\"no redirects\")\n\t\t},\n\t}\n\n\t// Retrieve authorize redirect.\n\t// We should be redirected to GitHub's OAuth URL.\n\t// We should save the auth state to the session so it can be check on callback.\n\tresp, _ := client.Get(h.Server.URL + \"/_/login\")\n\tresp.Body.Close()\n\tequals(t, \"https\", redirectURL.Scheme)\n\tequals(t, \"github.com\", redirectURL.Host)\n\tequals(t, \"/login/oauth/authorize\", redirectURL.Path)\n\tequals(t, 32, len(redirectURL.Query().Get(\"state\")))\n\n\tassert(t, saved, \"expected session save\")\n\tequals(t, redirectURL.Query().Get(\"state\"), session.Values[\"AuthState\"])\n}", "func (r *Response) Cookie(name string) *Cookie {\n\topChain := r.chain.enter(\"Cookie(%q)\", name)\n\tdefer opChain.leave()\n\n\tif opChain.failed() {\n\t\treturn newCookie(opChain, nil)\n\t}\n\n\tvar cookie *Cookie\n\n\tnames := []string{}\n\tfor _, c := range r.cookies {\n\t\tif c.Name == name {\n\t\t\tcookie = newCookie(opChain, c)\n\t\t\tbreak\n\t\t}\n\t\tnames = append(names, c.Name)\n\t}\n\n\tif cookie == nil {\n\t\topChain.fail(AssertionFailure{\n\t\t\tType: AssertContainsElement,\n\t\t\tActual: &AssertionValue{names},\n\t\t\tExpected: &AssertionValue{name},\n\t\t\tErrors: []error{\n\t\t\t\terrors.New(\"expected: response contains cookie with given name\"),\n\t\t\t},\n\t\t})\n\t\treturn newCookie(opChain, nil)\n\t}\n\n\treturn cookie\n}", "func (suite *AuthSuite) TestRedirectFromLoginGovForInvalidUser() {\n\t// build a real office user\n\ttioOfficeUser := factory.BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeTIO})\n\tsuite.False(tioOfficeUser.Active)\n\n\thandlerConfig := suite.HandlerConfig()\n\tappnames := handlerConfig.AppNames()\n\n\tfakeToken := \"some_token\"\n\tsession := auth.Session{\n\t\tApplicationName: auth.OfficeApp,\n\t\tIDToken: fakeToken,\n\t\tHostname: appnames.OfficeServername,\n\t}\n\n\t// login.gov state cookie\n\tstateValue := \"someStateValue\"\n\tcookieName := StateCookieName(&session)\n\tcookie := http.Cookie{\n\t\tName: cookieName,\n\t\tValue: shaAsString(stateValue),\n\t\tPath: \"/\",\n\t\tExpires: auth.GetExpiryTimeFromMinutes(auth.SessionExpiryInMinutes),\n\t}\n\treq := httptest.NewRequest(\"GET\", fmt.Sprintf(\"http://%s/login-gov/callback?state=%s\",\n\t\tappnames.OfficeServername, stateValue), nil)\n\treq.AddCookie(&cookie)\n\n\tauthContext := suite.AuthContext()\n\n\tsessionManager := handlerConfig.SessionManagers().Office\n\treq = suite.SetupSessionRequest(req, &session, sessionManager)\n\n\tstubOfficeProvider := stubLoginGovProvider{\n\t\tStubName: officeProviderName,\n\t\tStubToken: \"stubToken\",\n\t\tStubUser: goth.User{\n\t\t\tUserID: tioOfficeUser.User.LoginGovUUID.String(),\n\t\t\tEmail: tioOfficeUser.Email,\n\t\t},\n\t}\n\tdefer goth.ClearProviders()\n\tgoth.UseProviders(&stubOfficeProvider)\n\th := CallbackHandler{\n\t\tauthContext,\n\t\thandlerConfig,\n\t\tsetUpMockNotificationSender(),\n\t}\n\n\trr := httptest.NewRecorder()\n\tsessionManager.LoadAndSave(h).ServeHTTP(rr, req)\n\n\tsuite.Equal(http.StatusTemporaryRedirect, rr.Code)\n\n\tu := suite.urlForHost(appnames.OfficeServername)\n\tu.Path = \"/invalid-permissions\"\n\tsuite.Equal(u.String(), rr.Result().Header.Get(\"Location\"))\n}", "func GenCookie(username string) http.Cookie {\n // generate random 50 byte string to use as a session cookie\n randomValue := make([]byte, COOKIE_LENGTH)\n rand.Read(randomValue)\n cookieValue := strings.ToLower(username) + \":\" + fmt.Sprintf(\"%X\", randomValue)\n expire := time.Now().AddDate(0, 0, 1)\n return http.Cookie{Name: \"SessionID\", Value: cookieValue, Expires: expire, HttpOnly: true}\n}", "func MakeCookie(req *http.Request, name string, value string, path string, domain string, httpOnly bool, secure bool, expiration time.Duration, now time.Time, sameSite http.SameSite) *http.Cookie {\n\tif domain != \"\" {\n\t\thost := requestutil.GetRequestHost(req)\n\t\tif h, _, err := net.SplitHostPort(host); err == nil {\n\t\t\thost = h\n\t\t}\n\t\tif !strings.HasSuffix(host, domain) {\n\t\t\tlogger.Errorf(\"Warning: request host is %q but using configured cookie domain of %q\", host, domain)\n\t\t}\n\t}\n\n\treturn &http.Cookie{\n\t\tName: name,\n\t\tValue: value,\n\t\tPath: path,\n\t\tDomain: domain,\n\t\tHttpOnly: httpOnly,\n\t\tSecure: secure,\n\t\tExpires: now.Add(expiration),\n\t\tSameSite: sameSite,\n\t}\n}", "func TestCurlDeleteBinaryCookie(t *testing.T) {\n\tcurl := curlTester{\n\t\thandler: \"curl_delete_binary_cookie\",\n\t\ttestName: \"TestCurlDeleteBinaryCookie\",\n\t\ttestHandle: t,\n\t}\n\tcurl.testDeleteCookie()\n}", "func (m *BaseMethod) GetCookies() []KVPair {\n\treturn m.Cookies\n}", "func (h *RequestHeader) SetCookie(key, value string) {\n\th.collectCookies()\n\th.cookies = setArg(h.cookies, key, value, argsHasValue)\n}", "func TestCorrectTokenPasses(t *testing.T) {\n\thand := New(http.HandlerFunc(succHand))\n\thand.SetFailureHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tt.Errorf(\"Test failed. Reason: %v\", Reason(r))\n\t}))\n\n\tserver := httptest.NewServer(hand)\n\tdefer server.Close()\n\n\t// issue the first request to get the token\n\tresp, err := http.Get(server.URL)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tcookie := getRespCookie(resp, CookieName)\n\tif cookie == nil {\n\t\tt.Fatal(\"Cookie was not found in the response.\")\n\t}\n\n\tfinalToken := b64encode(maskToken(b64decode(cookie.Value)))\n\n\tvals := [][]string{\n\t\t{\"name\", \"Jolene\"},\n\t\t{FormFieldName, finalToken},\n\t}\n\n\t// Constructing a custom request is suffering\n\treq, err := http.NewRequest(\"POST\", server.URL, formBodyR(vals))\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\treq.AddCookie(cookie)\n\n\tresp, err = http.DefaultClient.Do(req)\n\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif resp.StatusCode != 200 {\n\t\tt.Errorf(\"The request should have succeeded, but it didn't. Instead, the code was %d\",\n\t\t\tresp.StatusCode)\n\t}\n}", "func (cookie *Cookie) SetCookieOnResponse(w http.ResponseWriter, setSiteCookie bool, cfg *config.HostCookie, ttl time.Duration) {\n\thttpCookie := cookie.ToHTTPCookie(ttl)\n\tvar domain string = cfg.Domain\n\thttpCookie.Secure = true\n\n\tif domain != \"\" {\n\t\thttpCookie.Domain = domain\n\t}\n\n\tvar currSize int = len([]byte(httpCookie.String()))\n\tfor cfg.MaxCookieSizeBytes > 0 && currSize > cfg.MaxCookieSizeBytes && len(cookie.uids) > 0 {\n\t\tvar oldestElem string = \"\"\n\t\tvar oldestDate int64 = math.MaxInt64\n\t\tfor key, value := range cookie.uids {\n\t\t\ttimeUntilExpiration := time.Until(value.Expires)\n\t\t\tif timeUntilExpiration < time.Duration(oldestDate) {\n\t\t\t\toldestElem = key\n\t\t\t\toldestDate = int64(timeUntilExpiration)\n\t\t\t}\n\t\t}\n\t\tdelete(cookie.uids, oldestElem)\n\t\thttpCookie = cookie.ToHTTPCookie(ttl)\n\t\tif domain != \"\" {\n\t\t\thttpCookie.Domain = domain\n\t\t}\n\t\tcurrSize = len([]byte(httpCookie.String()))\n\t}\n\n\tif setSiteCookie {\n\t\t// httpCookie.Secure = true\n\t\thttpCookie.SameSite = http.SameSiteNoneMode\n\t}\n\tw.Header().Add(\"Set-Cookie\", httpCookie.String())\n}", "func addCookie(context echo.Context, authToken string) {\n\texpire := time.Now().AddDate(0, 1, 0) // 1 month\n\tcookie := &http.Cookie{\n\t\tName: \"token\",\n\t\tExpires: expire,\n\t\tValue: auth.Bearer + \" \" + authToken,\n\t\tPath: \"/\",\n\t\t// Domain must not be set for auth to work with chrome without domain name\n\t\t// http://stackoverflow.com/questions/5849013/setcookie-does-not-set-cookie-in-google-chrome\n\t}\n\tcontext.Response().Header().Set(\"Set-Cookie\", cookie.String())\n}" ]
[ "0.612215", "0.6105234", "0.60702807", "0.60390204", "0.59975195", "0.59955245", "0.5935115", "0.5835304", "0.582638", "0.5762133", "0.5701", "0.5612771", "0.5557298", "0.5547791", "0.5532456", "0.55284435", "0.55165887", "0.551043", "0.5466343", "0.5459785", "0.54391205", "0.5412877", "0.54127556", "0.5403051", "0.5389258", "0.5381768", "0.5363239", "0.5352785", "0.5337785", "0.53131497", "0.5305929", "0.5298557", "0.5286763", "0.5279745", "0.52513736", "0.52499187", "0.5228671", "0.5212168", "0.5208756", "0.5197401", "0.5189375", "0.5169944", "0.5163953", "0.5160995", "0.5156985", "0.5145315", "0.51055425", "0.5095735", "0.5070066", "0.5067468", "0.50641376", "0.50591505", "0.5054653", "0.5038324", "0.50361234", "0.5034454", "0.50059223", "0.499248", "0.49902675", "0.4983272", "0.4975681", "0.49714902", "0.49697945", "0.49602708", "0.49545363", "0.49206105", "0.4911761", "0.491076", "0.49086508", "0.49048612", "0.48453903", "0.48428515", "0.48406926", "0.48398492", "0.48387453", "0.48354444", "0.4814976", "0.48089054", "0.4791038", "0.4788873", "0.47864002", "0.4778605", "0.47681728", "0.4757796", "0.47565827", "0.4755019", "0.47332767", "0.47172338", "0.4714682", "0.47117633", "0.46930724", "0.4681104", "0.46797362", "0.46791983", "0.46673313", "0.46653488", "0.46638966", "0.46617523", "0.46586543", "0.46515876" ]
0.731943
0
CheckCookie indicates an expected call of CheckCookie
func (mr *MockServiceAuthMockRecorder) CheckCookie(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckCookie", reflect.TypeOf((*MockServiceAuth)(nil).CheckCookie), arg0) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cook AwaitCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook ChangeCounterCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook ChangeProviderPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func CheckCookie(r *http.Request) bool {\r\n\t_, err := r.Cookie(envvar.CookieName())\r\n\tif err != nil {\r\n\t\treturn false\r\n\t}\r\n\treturn true\r\n}", "func (cook AwaitFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook ResetFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook TriggerFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SetCounterCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook CreateCounterCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook ConfigureProviderPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SetCrtcTransformCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SetCrtcGammaCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SelectInputCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook CreateFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook ChangeOutputPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook DestroyFenceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook DestroyCounterCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook DestroyModeCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (p *para) checkCookie(rawCookies string) {\n\theader := http.Header{}\n\theader.Add(\"Cookie\", rawCookies)\n\trequest := http.Request{Header: header}\n\tfor _, e := range request.Cookies() {\n\t\tif strings.Contains(e.Name, \"download_warning_\") {\n\t\t\tcookie, _ := request.Cookie(e.Name)\n\t\t\tp.Code = cookie.Value\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (cook ChangeAlarmCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SetPriorityCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook DeleteProviderPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func VerifyCookie(w http.ResponseWriter, r *http.Request) bool {\n\t_, err := r.Cookie(\"session\")\n\tif err != nil {\n\t\treturn false\n\t} else {\n\t\treturn true\n\t}\n}", "func (c *Checker) HasCookie(key, expectedValue string) *Checker {\n\tvalue, exists := c.cookies[key]\n\tassert.True(c.t, exists && expectedValue == value)\n\treturn c\n}", "func (cook AddOutputModeCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook CreateAlarmCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook DestroyAlarmCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook DeleteOutputModeCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (m *MockServiceAuth) CheckCookie(arg0 echo.Context) (int64, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"CheckCookie\", arg0)\n\tret0, _ := ret[0].(int64)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (cook DeleteOutputPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook ConfigureOutputPropertyCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (cook SetProviderOffloadSinkCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func CheckLoginByCookie(cookie BuyerCookie) bool {\n\treturn cookie.ID != 0\n}", "func (cook SetScreenSizeCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func getCookie(r *http.Request, cookiename string) (bool, *http.Cookie) {\n // Ignoring error value because it is likely that the cookie might not exist here\n cookie, _ := r.Cookie(cookiename)\n if cookie == nil {\n return false, nil\n }\n return true, cookie\n}", "func checkLogin(r *http.Request) bool {\n\t// grab the \"id\" cookie, fail if it doesn't exist\n\tcookie, err := r.Cookie(\"id\")\n\tif err == http.ErrNoCookie {\n\t\treturn false\n\t}\n\n\t// grab the \"key\" cookie, fail if it doesn't exist\n\tkey, err := r.Cookie(\"key\")\n\tif err == http.ErrNoCookie {\n\t\treturn false\n\t}\n\n\t// make sure we've got the right stuff in the hash\n\tcookieStore.RLock()\n\tdefer cookieStore.RUnlock()\n\treturn cookieStore.m[cookie.Value] == key.Value\n}", "func (l *LoginCookie) Check(value string) bool {\n\treturn l.validatorHash() == value\n}", "func CheckLogin(w http.ResponseWriter, r *http.Request) bool {\n\tCookieSession, err := r.Cookie(\"sessionid\")\n\tif err != nil {\n\t\tfmt.Println(\"No Such Cookies\")\n\t\tSession.Create()\n\t\tfmt.Println(Session.ID)\n\t\tSession.Expire = time.Now().Local()\n\t\tSession.Expire.Add(time.Hour)\n\t\treturn false\n\t}\n\tfmt.Println(\"Cookki Found\")\n\ttempSession := session.UserSession{UID: 0}\n\tLoggedIn := database.QueryRow(\"select user_id from sessions where session_id = ?\",\n\t\tCookieSession).Scan(&tempSession)\n\tif LoggedIn == nil {\n\t\treturn false\n\t}\n\treturn true\n\n}", "func compareCookies(expectedCookie *Cookie, actualCookie *http.Cookie) (bool, []string) {\n\tcookieFound := *expectedCookie.name == actualCookie.Name\n\tcompareErrors := make([]string, 0)\n\tif cookieFound {\n\t\tcompareErrors = compareValue(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareDomain(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = comparePath(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareExpires(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareMaxAge(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareSecure(expectedCookie, actualCookie, compareErrors)\n\t\tcompareErrors = compareHttpOnly(expectedCookie, actualCookie, compareErrors)\n\t}\n\n\treturn cookieFound, compareErrors\n}", "func (c *Checker) Check() *Checker {\n\n\t// set cookies\n\tc.request.Header.Set(\"Cookie\", c.generateCookieString())\n\n\trecorder := httptest.NewRecorder()\n\tc.handler.ServeHTTP(recorder, c.request)\n\n\tresp := &http.Response{\n\t\tStatusCode: recorder.Code,\n\t\tBody: NewReadCloser(recorder.Body),\n\t\tHeader: recorder.Header(),\n\t}\n\tc.handleCookies(resp)\n\tc.response = resp\n\n\treturn c\n}", "func (cook SetProviderOutputSourceCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func (h *ResponseHeader) Cookie(cookie *Cookie) bool {\n\tv := peekArgBytes(h.cookies, cookie.Key())\n\tif v == nil {\n\t\treturn false\n\t}\n\tcookie.ParseBytes(v) //nolint:errcheck\n\treturn true\n}", "func (cook SetOutputPrimaryCookie) Check() error {\n\treturn cook.Cookie.Check()\n}", "func Test_Ctx_Cookie(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\texpire := time.Now().Add(24 * time.Hour)\n\tvar dst []byte\n\tdst = expire.In(time.UTC).AppendFormat(dst, time.RFC1123)\n\thttpdate := strings.Replace(string(dst), \"UTC\", \"GMT\", -1)\n\tctx.Cookie(&Cookie{\n\t\tName: \"username\",\n\t\tValue: \"john\",\n\t\tExpires: expire,\n\t})\n\texpect := \"username=john; expires=\" + httpdate + \"; path=/; SameSite=Lax\"\n\tutils.AssertEqual(t, expect, string(ctx.Fasthttp.Response.Header.Peek(HeaderSetCookie)))\n\n\tctx.Cookie(&Cookie{SameSite: \"strict\"})\n\tctx.Cookie(&Cookie{SameSite: \"none\"})\n}", "func (r *TestRequest) Cookie() uint64 {\n\treturn r.cookie\n}", "func CheckCookieValueAndForwardWithRequestContext(h http.Handler) http.Handler {\n\treturn http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {\n\t\taccessTokenCookie, err := req.Cookie(common.FlorenceCookieKey)\n\t\tif err != nil {\n\t\t\tif err != http.ErrNoCookie {\n\t\t\t\tlog.Error(req.Context(), \"unexpected error while extracting user Florence access token from cookie\", err)\n\t\t\t}\n\t\t} else {\n\t\t\treq = addUserAccessTokenToRequestContext(accessTokenCookie.Value, req)\n\t\t}\n\n\t\th.ServeHTTP(w, req)\n\t})\n}", "func (o *operation) getCookiesValid() bool {\n\tt := time.Now().UTC()\n\tfor _, p := range o.values {\n\t\tif p.cookieWriteTime.Before(t) {\n\t\t\tt = p.cookieWriteTime\n\t\t}\n\t}\n\td := time.Now().UTC().Sub(t) / time.Second\n\treturn d < o.services.config.HomeNodeTimeout\n}", "func (client *HTTPClient) EnsureCookie(fromURL string, force bool) error {\n\tcURL, err := url.Parse(fromURL)\n\tif err != nil {\n\t\treturn WrapErr(err, \"failed to parse cookie URL\").With(\"url\", fromURL)\n\t}\n\tcookies := client.PersistentJar.Cookies(cURL)\n\tif force || len(cookies) == 0 {\n\t\tresp, err := client.Get(fromURL, nil)\n\t\tif err != nil {\n\t\t\treturn WrapErr(err, \"failed to fetch cookie URL\").With(\"url\", fromURL)\n\t\t}\n\t\tresp.Body.Close()\n\t}\n\treturn nil\n}", "func (this *BaseRouter) CheckXsrfCookie() bool {\n\tfmt.Println(\"CheckXsrfCookie() function\")\n\treturn this.Controller.CheckXsrfCookie()\n}", "func Test_Session_Cookie(t *testing.T) {\n\tt.Parallel()\n\t// session store\n\tstore := New()\n\t// fiber instance\n\tapp := fiber.New()\n\t// fiber context\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\n\t// get session\n\tsess, _ := store.Get(ctx)\n\tsess.Save()\n\n\t// cookie should not be set if empty data\n\tutils.AssertEqual(t, 0, len(ctx.Response().Header.PeekCookie(store.CookieName)))\n}", "func VerifyCookie(cookie string, db UserGetter) (email string, err error) {\n\temail, token, mac, err := splitCookie(cookie)\n\tif err != nil {\n\t\treturn \"\", errors.NewClient(\"Not authenticated\")\n\t}\n\n\texpectedMac, err := computeMAC([]byte(email + \"#\" + token))\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"Failed to compute verification MAC\")\n\t}\n\n\tmessageMac, err := hex.DecodeString(mac)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"Failed to hex decode message mac\")\n\t}\n\tif !hmac.Equal(expectedMac, messageMac) {\n\t\treturn \"\", errors.NewClient(\"Not authenticated\")\n\t}\n\n\tuser, err := db.GetUserInfo(email)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"Failed to get user from database\")\n\t}\n\tif user.Token != token {\n\t\treturn \"\", errors.NewClient(\"Not authenticated\")\n\t}\n\treturn email, nil\n}", "func verifyLogin(req *restful.Request, resp *restful.Response ) bool {\n\tcookie, err := req.Request.Cookie(\"session-id\")\n\tif cookie.Value != \"\" {\n\t\t_, exists := sessions[cookie.Value]\n\t\tif !exists {\n\t\t\thttp.Redirect(resp.ResponseWriter, req.Request, \"/\", 302)\n\t\t\treturn false\n\t\t}\n\t\treturn true\n\t} else if err != nil {\n\t\tfmt.Println(err.Error())\n\t\thttp.Redirect(resp.ResponseWriter, req.Request, \"/\", 302)\n\t\treturn false\n\t} else {\n\t\thttp.Redirect(resp.ResponseWriter, req.Request, \"/\", 302)\n\t\treturn false\n\t}\n}", "func (s *BasecookieListener) EnterCookie(ctx *CookieContext) {}", "func validateCookieHandler(w http.ResponseWriter, r *http.Request, conf *config) {\n\t// initialize headers\n\tw.Header().Set(\"X-Auth-Request-Redirect\", \"\")\n\tw.Header().Set(\"X-Auth-Request-User\", \"\")\n\n\tauth := r.Header.Get(\"Authorization\")\n\tsplit := strings.SplitN(auth, \" \", 2)\n\tvar tokenvalue string = \"\"\n\tif len(split) == 2 && strings.EqualFold(split[0], \"bearer\") {\n\t\ttokenvalue = split[1]\n\t} else {\n\t\ttokenCookie, err := r.Cookie(conf.cookieName)\n\t\tswitch {\n\t\tcase err == http.ErrNoCookie:\n\t\t\tw.Header().Set(\"X-Auth-Request-Redirect\", redirectURL(r, conf, r.Header.Get(\"X-Okta-Nginx-Request-Uri\")))\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn\n\t\tcase err != nil:\n\t\t\tlog.Printf(\"validateCookieHandler: Error parsing cookie, %v\", err)\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn\n\t\t}\n\t\ttokenvalue = tokenCookie.Value\n\t}\n\n\tjwt, err := conf.verifier.VerifyAccessToken(tokenvalue)\n\n\tif err != nil {\n\t\tw.Header().Set(\"X-Auth-Request-Redirect\", redirectURL(r, conf, r.Header.Get(\"X-Okta-Nginx-Request-Uri\")))\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\tsub, ok := jwt.Claims[\"sub\"]\n\tif !ok {\n\t\tlog.Printf(\"validateCookieHandler: Claim 'sub' not included in access token, %v\", tokenvalue)\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tsubStr, ok := sub.(string)\n\tif !ok {\n\t\tlog.Printf(\"validateCookieHandler: Unable to convert 'sub' to string in access token, %v\", tokenvalue)\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tvalidateClaimsTemplate := strings.TrimSpace(r.Header.Get(\"X-Okta-Nginx-Validate-Claims-Template\"))\n\tif validateClaimsTemplate != \"\" {\n\t\tt, err := getTemplate(validateClaimsTemplate)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"validateCookieHandler: validateClaimsTemplate failed to parse template: '%v', error: %v\", validateClaimsTemplate, err)\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\n\t\tvar resultBytes bytes.Buffer\n\t\tif err := t.Execute(&resultBytes, jwt.Claims); err != nil {\n\t\t\tclaimsJSON, _ := json.Marshal(jwt.Claims)\n\t\t\tlog.Printf(\"validateCookieHandler: validateClaimsTemplate failed to execute template: '%v', data: '%v', error: '%v'\", validateClaimsTemplate, claimsJSON, err)\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn\n\t\t}\n\t\tresultString := strings.ToLower(strings.TrimSpace(resultBytes.String()))\n\n\t\tif resultString != \"true\" && resultString != \"1\" {\n\t\t\tlog.Printf(\"validateCookieHandler: validateClaimsTemplate template: '%v', result: '%v', sub: '%v'\", validateClaimsTemplate, resultString, subStr)\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn\n\t\t}\n\t}\n\n\tsetHeaderNames := strings.Split(r.Header.Get(\"X-Okta-Nginx-Proxy-Set-Header-Names\"), \",\")\n\tsetHeaderValues := strings.Split(r.Header.Get(\"X-Okta-Nginx-Proxy-Set-Header-Values\"), \",\")\n\tif setHeaderNames[0] != \"\" && setHeaderValues[0] != \"\" && len(setHeaderNames) == len(setHeaderValues) {\n\t\tfor i := 0; i < len(setHeaderNames); i++ {\n\t\t\tt, err := getTemplate(setHeaderValues[i])\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"validateCookieHandler: setHeaderValues failed to parse template: '%v', error: %v\", validateClaimsTemplate, err)\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tvar resultBytes bytes.Buffer\n\t\t\tif err := t.Execute(&resultBytes, jwt.Claims); err != nil {\n\t\t\t\tclaimsJSON, _ := json.Marshal(jwt.Claims)\n\t\t\t\tlog.Printf(\"validateCookieHandler: setHeaderValues failed to execute template: '%v', data: '%v', error: '%v'\", validateClaimsTemplate, claimsJSON, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tresultString := strings.ToLower(strings.TrimSpace(resultBytes.String()))\n\n\t\t\tw.Header().Set(setHeaderNames[i], resultString)\n\t\t}\n\t}\n\n\tw.Header().Set(\"X-Auth-Request-User\", subStr)\n\tw.WriteHeader(http.StatusOK)\n}", "func checkLogin(next echo.HandlerFunc) echo.HandlerFunc {\n\treturn func(c echo.Context) error {\n\t\tcookie, err := c.Cookie(\"SessionID\")\n\t\tif err == nil && cookie != nil && cookie.Value == \"some hash\" {\n\t\t\treturn next(c)\n\t\t}\n\t\treturn c.Redirect(http.StatusMovedPermanently, fmt.Sprintf(\"/login?redirect=%s\", c.Path()))\n\t}\n}", "func CheckAuthentication(ctx *macaron.Context, c cache.Cache) {\n\tcookie, has := ctx.GetSecureCookie(\"user\")\n\n\tif !has {\n\t\treturn\n\t}\n\n\tuser := handlers.Users{Username: cookie}\n\tkey := fmt.Sprintf(\"user_%v\", user.Username)\n\n\thas, err := redisCache.FindObject(c, key, &user, nil, true)\n\tif err != nil {\n\t\tctx.Resp.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\n\t// found user\n\tif has {\n\t\tctx.Data[\"Login\"] = 1\n\t\tctx.Data[\"Username\"] = cookie\n\t\tctx.Data[\"Previlege\"] = user.Privilege\n\t}\n}", "func TestCookieWithOptions(t *testing.T) {\n\tRunCookieSetup(t, func(privKey *rsa.PrivateKey) {\n\n\t\tsigner := NewCookieSigner(\"keyID\", privKey)\n\t\tsigner.Path = \"/\"\n\t\tsigner.Domain = testDomain\n\t\tsigner.Secure = false\n\n\t\tif signer.keyID != \"keyID\" || signer.privKey != privKey {\n\t\t\tt.Fatalf(\"NewCookieSigner does not properly assign values %+v\", signer)\n\t\t}\n\n\t\tp := &Policy{\n\t\t\tStatements: []Statement{\n\t\t\t\t{\n\t\t\t\t\tResource: \"*\",\n\t\t\t\t\tCondition: Condition{\n\t\t\t\t\t\tDateLessThan: &AWSEpochTime{time.Now().Add(1 * time.Hour)},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t}\n\n\t\tcookies, err := signer.SignWithPolicy(p)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"Error signing cookies %#v\", err)\n\t\t}\n\t\tvalidateCookies(t, cookies, signer)\n\n\t})\n}", "func (this *BaseController) CheckXsrfCookie() bool {\n return this.Controller.CheckXSRFCookie()\n}", "func (c *Controller) CheckXSRFCookie() bool {\n\tif !c.EnableXSRF {\n\t\treturn true\n\t}\n\treturn c.Ctx.CheckXSRFCookie()\n}", "func (o *operation) getCookiesPresent() bool {\n\tz := true\n\tfor _, p := range o.values {\n\t\tz = z && (p.cookieWriteTime.IsZero() == false)\n\t}\n\treturn z\n}", "func VerifyCookieFromRedisHTTP(ctx *fasthttp.RequestCtx, redisClient *redis.Client) {\n\tvar err error\n\tctx.Response.Header.SetContentType(\"application/json; charset=utf-8\") // Why not ? (:\n\tlog.Debug(\"VerifyCookieFromRedisHTTP | Retrieving username ...\")\n\tuser, _ := ParseAuthenticationCoreHTTP(ctx)\n\tlog.Debug(\"VerifyCookieFromRedisHTTP | Retrieving token ...\")\n\ttoken := ParseTokenFromRequest(ctx)\n\tlog.Debug(\"VerifyCookieFromRedisHTTP | Retrieving cookie from redis ...\")\n\tauth := authutils.VerifyCookieFromRedisHTTPCore(user, token, redisClient) // Call the core function for recognize if the user have the token\n\tif strings.Compare(auth, \"AUTHORIZED\") == 0 {\n\t\terr = json.NewEncoder(ctx).Encode(datastructures.Response{Status: true, Description: \"Logged in!\", ErrorCode: auth, Data: nil})\n\t\tcommonutils.Check(err, \"VerifyCookieFromRedisHTTP\")\n\t} else {\n\t\terr = json.NewEncoder(ctx).Encode(datastructures.Response{Status: false, Description: \"Not logged in!\", ErrorCode: auth, Data: nil})\n\t\tcommonutils.Check(err, \"VerifyCookieFromRedisHTTP\")\n\t}\n}", "func (m JwtMiddleware) Check(next http.Handler) http.Handler {\n\tfn := func(w http.ResponseWriter, r *http.Request) {\n\t\tc, err := r.Cookie(\"token\")\n\t\tif err != nil {\n\t\t\tif errors.Is(err, http.ErrNoCookie) {\n\t\t\t\t// If the cookie is not set, return an unauthorized status\n\t\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\t\tlog.Printf(\"[%s]: no cookie, request non authorized\", http.StatusText(http.StatusUnauthorized))\n\t\t\t\treturn\n\t\t\t}\n\t\t\t// For any other type of error, return a bad request status\n\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\tapiError := common.APIError{\n\t\t\t\tError: \"invalid_client\",\n\t\t\t\tErrorDescription: fmt.Sprintf(\"%s\", \"Cannot retrieve authorization\"),\n\t\t\t}\n\t\t\tjson, _ := json.Marshal(apiError)\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\t_, _ = w.Write(json)\n\t\t\tlog.Printf(\"[%s]: cannot retrieve cookie token\", http.StatusText(http.StatusUnauthorized))\n\t\t\treturn\n\t\t}\n\t\tlogger.Logger.Debugf(\"Checking for token [%s]\", c.Value)\n\t\tif valid, err := m.JwtService.Verify(\"Bearer \" + c.Value); err != nil || !valid {\n\t\t\tif errors.Is(err, jwt.ErrSignature) {\n\t\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\t} else {\n\t\t\t\tw.WriteHeader(http.StatusBadRequest)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tnext.ServeHTTP(w, r)\n\t}\n\treturn http.HandlerFunc(fn)\n}", "func (d *Cookie) Exists(r *http.Request) bool {\n\tcookie, err := r.Cookie(d.Name)\n\treturn err == nil && cookie.Value != tombstone\n}", "func CheckTheValidityOfTheTokenFromHTTPHeader(w http.ResponseWriter, r *http.Request) (writer http.ResponseWriter, newToken string, err error) {\n err = createError(011)\n for _, cookie := range r.Cookies() {\n if cookie.Name == \"Token\" {\n var token string\n token, err = CheckTheValidityOfTheToken(cookie.Value)\n //fmt.Println(\"T\", token, err)\n writer = SetCookieToken(w, token)\n newToken = token\n }\n }\n //fmt.Println(err)\n return\n}", "func (r *Response) CookiePresent(cookieName string) *Response {\n\tr.cookiesPresent = append(r.cookiesPresent, cookieName)\n\treturn r\n}", "func (r *Response) CookiePresent(cookieName string) *Response {\n\tr.cookiesPresent = append(r.cookiesPresent, cookieName)\n\treturn r\n}", "func (r loginConsoleReq) Check() error {\n\tif r.RedirectURL == \"\" {\n\t\treturn trace.BadParameter(\"missing RedirectURL\")\n\t}\n\treturn nil\n}", "func getNameAndCookie(res http.ResponseWriter, req *http.Request) (string, bool) {\n\tvar name string\n\tvar ok bool\n\tvar cookie, err = req.Cookie(\"uuid\")\n\n\t//correctlyLogIn - means that both cookie and name exists\n\tcorrectlyLogIn := false\n\n\t// if the cookie is set up\n\tif err == nil {\n\n\t\t// retrive the name, before the access to map, lock it\n\t\tsessionsSyncLoc.RLock()\n\t\tname, ok = sessions[cookie.Value]\n\t\tsessionsSyncLoc.RUnlock()\n\n\t\tif ok {\n\t\t\t// if the name exists, set correctllyLogIn to true\n\t\t\tcorrectlyLogIn = true\n\t\t} else {\n\t\t\t// no name so invalidate cookie\n\t\t\tinvalidateCookie(res)\n\t\t}\n\t}\n\n\treturn name, correctlyLogIn\n}", "func (s SimpleResponse) GetCookie() *http.Cookie {\n\treturn nil\n}", "func (ai *actionItem) Cookie() uint64 {\n\treturn ai.hai.Cookie\n}", "func TestsetTokenCookie(t *testing.T) {\n\thand := New(nil)\n\n\twriter := httptest.NewRecorder()\n\treq := dummyGet()\n\n\ttoken := []byte(\"dummy\")\n\thand.setTokenCookie(writer, req, token)\n\n\theader := writer.Header().Get(\"Set-Cookie\")\n\texpected_part := fmt.Sprintf(\"csrf_token=%s;\", token)\n\n\tif !strings.Contains(header, expected_part) {\n\t\tt.Errorf(\"Expected header to contain %v, it doesn't. The header is %v.\",\n\t\t\texpected_part, header)\n\t}\n\n\ttokenInContext := unmaskToken(b64decode(Token(req)))\n\tif !bytes.Equal(tokenInContext, token) {\n\t\tt.Errorf(\"RegenerateToken didn't set the token in the context map!\"+\n\t\t\t\" Expected %v, got %v\", token, tokenInContext)\n\t}\n}", "func (a *Auth) authCookie(ctx *bm.Context) (int64, error) {\n\treq := ctx.Request\n\tsession, _ := req.Cookie(\"SESSION\")\n\tif session == nil {\n\t\treturn 0, ecode.Unauthorized\n\t}\n\t// NOTE: 请求登录鉴权服务接口,拿到对应的用户id\n\tvar mid int64\n\t// TODO: get mid from some code\n\n\t// check csrf\n\tclientCsrf := req.FormValue(\"csrf\")\n\tif a.conf != nil && !a.conf.DisableCSRF && req.Method == \"POST\" {\n\t\t// NOTE: 如果开启了CSRF认证,请从CSRF服务获取该用户关联的csrf\n\t\tvar csrf string // TODO: get csrf from some code\n\t\tif clientCsrf != csrf {\n\t\t\treturn 0, ecode.Unauthorized\n\t\t}\n\t}\n\n\treturn mid, nil\n}", "func (me *XsdGoPkgHasElem_Cookie) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElem_Cookie; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func certificateCheckCallback(cert *git.Certificate, valid bool, hostname string) git.ErrorCode {\n\treturn 0\n}", "func checkToken(w http.ResponseWriter, r *http.Request) bool {\n\tc, err := r.Cookie(\"token\")\n\tif err != nil {\n\t\tif err == http.ErrNoCookie {\n\t\t\t// If the cookie is not set, return an unauthorized status\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn false\n\t\t}\n\t\t// For any other type of error, return a bad request status\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn false\n\t}\n\n\t// Get the JWT string from the cookie\n\ttknStr := c.Value\n\n\t// Initialize a new instance of `Claims`\n\tclaims := &s.Claims{}\n\n\ttkn, err := jwt.ParseWithClaims(tknStr, claims, func(token *jwt.Token) (interface{}, error) {\n\t\treturn JWTKey, nil\n\t})\n\tif err != nil {\n\t\tif err == jwt.ErrSignatureInvalid {\n\t\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\t\treturn false\n\t\t}\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn false\n\t}\n\tif !tkn.Valid {\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\treturn false\n\t}\n\treturn true\n}", "func CheckXSRF(req *Request, cookieName string, paramName string) os.Error {\n\n\tconst tokenLen = 8\n\texpectedToken := req.Cookie.Get(cookieName)\n\n\t// Create new XSRF token?\n\tif len(expectedToken) != tokenLen {\n\t\tp := make([]byte, tokenLen/2)\n\t\t_, err := rand.Reader.Read(p)\n\t\tif err != nil {\n\t\t\tpanic(\"twister: rand read failed\")\n\t\t}\n\t\texpectedToken = hex.EncodeToString(p)\n\t\tc := NewCookie(cookieName, expectedToken).String()\n\t\tFilterRespond(req, func(status int, header Header) (int, Header) {\n\t\t\theader.Add(HeaderSetCookie, c)\n\t\t\treturn status, header\n\t\t})\n\t}\n\n\tactualToken := req.Param.Get(paramName)\n\tif actualToken == \"\" {\n\t\tactualToken = req.Header.Get(HeaderXXSRFToken)\n\t\treq.Param.Set(paramName, expectedToken)\n\t}\n\tif expectedToken != actualToken {\n\t\treq.Param.Set(paramName, expectedToken)\n\t\tif req.Method == \"POST\" ||\n\t\t\treq.Method == \"PUT\" ||\n\t\t\treq.Method == \"DELETE\" {\n\t\t\terr := os.NewError(\"twister: bad xsrf token\")\n\t\t\tif actualToken == \"\" {\n\t\t\t\terr = os.NewError(\"twister: missing xsrf token\")\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func complyWithCookieLaws(ip string) bool {\n\tipThreeOctets := getThreeOctets(ip)\n\n\tif appconfig.Instance.GeoResolver.Type() != geo.MaxmindType {\n\t\treturn false\n\t}\n\n\tdata, err := appconfig.Instance.GeoResolver.Resolve(ipThreeOctets)\n\tif err != nil {\n\t\tlogging.SystemErrorf(\"Error resolving IP %q into geo data: %v\", ipThreeOctets, err)\n\t\treturn false\n\t}\n\n\tif _, ok := geo.EUCountries[data.Country]; ok || data.Country == geo.UKCountry {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (b *Browser) MustGetCookies() []*proto.NetworkCookie {\n\tnc, err := b.GetCookies()\n\tb.e(err)\n\treturn nc\n}", "func checkMe(r *http.Request) (*User, error) {\n\treturn getUserFromCookie(r)\n}", "func (c *ChromeNetwork) CanClearBrowserCookies() (bool, error) {\n\trecvCh, _ := sendCustomReturn(c.target.sendCh, &ParamRequest{Id: c.target.getId(), Method: \"Network.canClearBrowserCookies\"})\n\tresp := <-recvCh\n\n\tvar chromeData struct {\n\t\tResult struct { \n\t\t\tResult bool \n\t\t}\n\t}\n\t\t\n\terr := json.Unmarshal(resp.Data, &chromeData)\n\tif err != nil {\n\t\tcerr := &ChromeErrorResponse{}\n\t\tchromeError := json.Unmarshal(resp.Data, cerr)\n\t\tif chromeError == nil {\n\t\t\treturn false, &ChromeRequestErr{Resp: cerr}\n\t\t}\n\t\treturn false, err\n\t}\n\n\treturn chromeData.Result.Result, nil\n}", "func (d *Cookie) Get(w http.ResponseWriter, r *http.Request, v any) (bool, error) {\n\ts, err := webmiddleware.GetSecureCookie(r.Context())\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tcookie, err := r.Cookie(d.Name)\n\tif err != nil || cookie.Value == tombstone {\n\t\treturn false, nil\n\t}\n\n\terr = s.Decode(d.Name, cookie.Value, v)\n\tif err != nil {\n\t\td.Remove(w, r)\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}", "func CheckAuth() gin.HandlerFunc {\n\treturn func(ctx *gin.Context) {\n\t\t_, err := seccookie.ReadSecureCookie(ctx, scookie)\n\t\tif err != nil {\n\t\t\tglog.Errorln(\"CHECK AUTH: not logged in\")\n\t\t}\n\t\tctx.Next()\n\t}\n}", "func (m *Cookie) Validate(formats strfmt.Registry) error {\n\tvar res []error\n\n\tif err := m.validateAttrs(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateDomains(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateName(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif err := m.validateType(formats); err != nil {\n\t\tres = append(res, err)\n\t}\n\n\tif len(res) > 0 {\n\t\treturn errors.CompositeValidationError(res...)\n\t}\n\treturn nil\n}", "func Test_Ctx_Cookies(t *testing.T) {\n\tt.Parallel()\n\tapp := New()\n\tctx := app.AcquireCtx(&fasthttp.RequestCtx{})\n\tdefer app.ReleaseCtx(ctx)\n\tctx.Fasthttp.Request.Header.Set(\"Cookie\", \"john=doe\")\n\tutils.AssertEqual(t, \"doe\", ctx.Cookies(\"john\"))\n\tutils.AssertEqual(t, \"default\", ctx.Cookies(\"unknown\", \"default\"))\n}", "func SessionCheck(writer http.ResponseWriter, request *http.Request) (sess Session, err error) {\n\tcookie, err := request.Cookie(\"_cookie\")\n\tif err == nil {\n\t\tsess = Session{Uuid: cookie.Value}\n\t\tif ok, _ := sess.Valid(); ok {\n\t\t\terr = errors.New(\"invalid session\")\n\t\t}\n\t}\n\treturn\n}", "func (zr *ZRequest) SetCookie(ck *http.Cookie) *ZRequest {\n\tif zr.ended {\n\t\treturn zr\n\t}\n\tzr.cookies = append(zr.cookies, ck)\n\treturn zr\n}", "func (s *server) validateUserCookie(w http.ResponseWriter, r *http.Request) (string, error) {\n\tvar userID string\n\n\tif cookie, err := r.Cookie(s.config.SecureCookieName); err == nil {\n\t\tvar value string\n\t\tif err = s.cookie.Decode(s.config.SecureCookieName, cookie.Value, &value); err == nil {\n\t\t\tuserID = value\n\t\t} else {\n\t\t\tlog.Println(\"error in reading user cookie : \" + err.Error() + \"\\n\")\n\t\t\ts.clearUserCookies(w)\n\t\t\treturn \"\", errors.New(\"invalid user cookies\")\n\t\t}\n\t} else {\n\t\tlog.Println(\"error in reading user cookie : \" + err.Error() + \"\\n\")\n\t\ts.clearUserCookies(w)\n\t\treturn \"\", errors.New(\"invalid user cookies\")\n\t}\n\n\treturn userID, nil\n}", "func (r *Response) CookieNotPresent(cookieName string) *Response {\n\tr.cookiesNotPresent = append(r.cookiesNotPresent, cookieName)\n\treturn r\n}", "func (r *Response) CookieNotPresent(cookieName string) *Response {\n\tr.cookiesNotPresent = append(r.cookiesNotPresent, cookieName)\n\treturn r\n}", "func (s *BasecookieListener) ExitCookie(ctx *CookieContext) {}", "func okHealthCheck(proxy *Proxy) error {\n\treturn nil\n}", "func (c *HTTPChecker) Check() error {\n\tclient := &http.Client{\n\t\tTimeout: c.timeout,\n\t}\n\n\treq, err := http.NewRequest(c.method, c.url, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn ErrCheckFailed\n\t}\n\n\treturn nil\n}", "func SetCookie(w http.ResponseWriter, r *http.Request) {\r\n\tcookieName := envvar.CookieName()\r\n\tcookie, err := r.Cookie(cookieName)\r\n\tif err != nil {\r\n\t\tcookie := &http.Cookie{\r\n\t\t\tName: cookieName,\r\n\t\t\tValue: (uuid.NewV4()).String(),\r\n\t\t\tHttpOnly: true,\r\n\t\t\tPath: \"/\",\r\n\t\t\tDomain: envvar.HostAddress(),\r\n\t\t\tSecure: true,\r\n\t\t}\r\n\t\thttp.SetCookie(w, cookie)\r\n\t\tlogger.Info.Println(\"set cookie : \" + cookie.Value + \"-\" + cookieName)\r\n\t\treturn\r\n\t}\r\n\t_, found := Get(r)\r\n\tif found {\r\n\t\tRefresh(r)\r\n\t\tlogger.Info.Println(\"session refresh: \" + cookie.Value)\r\n\t\treturn\r\n\t}\r\n\tlogger.Info.Println(cookie.Value + \" already set\")\r\n\r\n\treturn\r\n}", "func readCookie(res http.ResponseWriter, req *http.Request) {\n\tcookie := readCreateCookie(req)\n\thttp.SetCookie(res, cookie) // set cookie into browser.\n\tuserInformation = cookieInformationDecoding(cookie.Value) // decode and set user state into page variable.\n}", "func CreateCookie(w http.ResponseWriter, r *http.Request, n string, v string) bool {\n\tcookie, err := r.Cookie(n)\n\tif err != nil {\n\t\tcookie = &http.Cookie{\n\t\t\tName: n,\n\t\t\tValue: v,\n\t\t}\n\t\thttp.SetCookie(w, cookie)\n\t\treturn true;\n\t}\n\treturn false;\n}", "func (req *request) Cookie() Cookie {\n return req.cookies\n}", "func (e DecodeErr) IsInvalidCookie() bool {\r\n\treturn e.Place == DecodeErrPlace{\"message\", \"cookie\"}\r\n}", "func (sa SASLDAuth) Check(req *AuthReq, ok *bool) (err error) {\n\t*ok, err = saslauthd.Auth(req.User, req.Password, service, realm)\n\treturn\n}", "func compareHttpCookies(l *http.Cookie, r *http.Cookie) bool {\n\treturn l.Name == r.Name &&\n\t\tl.Value == r.Value &&\n\t\tl.Domain == r.Domain &&\n\t\tl.Expires == r.Expires &&\n\t\tl.MaxAge == r.MaxAge &&\n\t\tl.Secure == r.Secure &&\n\t\tl.HttpOnly == r.HttpOnly &&\n\t\tl.SameSite == r.SameSite\n}", "func (h *RequestHeader) Cookie(key string) []byte {\n\th.collectCookies()\n\treturn peekArgStr(h.cookies, key)\n}" ]
[ "0.72661316", "0.72648275", "0.7115393", "0.7102399", "0.7091658", "0.7071528", "0.7066889", "0.705049", "0.69304526", "0.6884385", "0.6877508", "0.687586", "0.68542546", "0.6853322", "0.68526745", "0.684854", "0.68435425", "0.682521", "0.67942345", "0.67927617", "0.67770404", "0.67404824", "0.6709902", "0.66282433", "0.65852076", "0.6582582", "0.656813", "0.65329903", "0.6517815", "0.6511807", "0.6511177", "0.6481765", "0.62550014", "0.6193372", "0.6175759", "0.60232157", "0.5995781", "0.5993992", "0.5962368", "0.5947526", "0.5924896", "0.5888123", "0.5887723", "0.5855659", "0.5703555", "0.5618476", "0.56081414", "0.55861884", "0.5571192", "0.55695343", "0.5517331", "0.55149853", "0.54982513", "0.549802", "0.5474937", "0.54044956", "0.5336989", "0.5324365", "0.531987", "0.52935666", "0.52819675", "0.52803314", "0.52667594", "0.52593285", "0.5240869", "0.5240869", "0.52264863", "0.52196044", "0.5217014", "0.5199939", "0.51838875", "0.5159446", "0.5149979", "0.5142921", "0.51363194", "0.51226544", "0.5103374", "0.50983727", "0.50916356", "0.50833154", "0.50632226", "0.5056986", "0.5047937", "0.5038999", "0.5008602", "0.49972078", "0.4988188", "0.4983757", "0.4983757", "0.4983649", "0.4980263", "0.49719325", "0.49564573", "0.49473763", "0.4944848", "0.4944168", "0.49313414", "0.493049", "0.49297357", "0.4927065" ]
0.70733666
5
Login mocks base method
func (m *MockServiceAuth) Login(arg0 models.UserInputLogin) (models.UserSession, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Login", arg0) ret0, _ := ret[0].(models.UserSession) ret1, _ := ret[1].(error) return ret0, ret1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MockHandler) Login(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Login\", arg0, arg1)\n}", "func (m *MockAuthService) Login(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Login\", arg0, arg1)\n}", "func TestLogin(w http.ResponseWriter, r *http.Request) {\n\n\tauthHeader := r.Header.Get(\"Authorization\")\n\tcookies := r.Cookies()\n\tvar token string\n\tfor _, c := range cookies {\n\t\tif c.Name == \"token\" {\n\t\t\ttoken = c.Value\n\t\t}\n\t}\n\n\tvar accessToken string\n\t// header value format will be \"Bearer <token>\"\n\tif authHeader != \"\" {\n\t\tif !strings.HasPrefix(authHeader, \"Bearer \") {\n\t\t\tlog.Errorf(\"GetMyIdentities Failed to find Bearer token %v\", authHeader)\n\t\t\tReturnHTTPError(w, r, http.StatusUnauthorized, \"Unauthorized, please provide a valid token\")\n\t\t\treturn\n\t\t}\n\t\taccessToken = strings.TrimPrefix(authHeader, \"Bearer \")\n\t}\n\n\tbytes, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tlog.Errorf(\"TestLogin failed with error: %v\", err)\n\t\tReturnHTTPError(w, r, http.StatusBadRequest, \"Bad Request, Please check the request content\")\n\t\treturn\n\t}\n\tvar testAuthConfig model.TestAuthConfig\n\n\terr = json.Unmarshal(bytes, &testAuthConfig)\n\tif err != nil {\n\t\tlog.Errorf(\"TestLogin unmarshal failed with error: %v\", err)\n\t\tReturnHTTPError(w, r, http.StatusBadRequest, \"Bad Request, Please check the request content\")\n\t\treturn\n\t}\n\n\tif testAuthConfig.AuthConfig.Provider == \"\" {\n\t\tlog.Errorf(\"UpdateConfig: Provider is a required field\")\n\t\tReturnHTTPError(w, r, http.StatusBadRequest, \"Bad request, Provider is a required field\")\n\t\treturn\n\t}\n\n\tstatus, err := server.TestLogin(testAuthConfig, accessToken, token)\n\tif err != nil {\n\t\tlog.Errorf(\"TestLogin GetProvider failed with error: %v\", err)\n\t\tif status == 0 {\n\t\t\tstatus = http.StatusInternalServerError\n\t\t}\n\t\tReturnHTTPError(w, r, status, fmt.Sprintf(\"%v\", err))\n\t}\n}", "func TestLoginWrapper_LoggedIn(t *testing.T) {\n\tw, r, c := initTestRequestParams(t, &user.User{Email: \"test@example.com\"})\n\tdefer c.Close()\n\n\tdummyLoginHandler(&requestParams{w: w, r: r, c: c})\n\n\texpectCode(t, http.StatusOK, w)\n\texpectBody(t, \"test@example.com\", w)\n}", "func (m *MockUseCase) Login(ctx context.Context, username, password string) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Login\", ctx, username, password)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockEmployeeUseCase) Login(c context.Context, companyId, employeeNo, password, secretKey string) (*model.AuthResponse, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Login\", c, companyId, employeeNo, password, secretKey)\n\tret0, _ := ret[0].(*model.AuthResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockAdmin) Login(ctx provider.Context, request entity.Login) (entity.LoginResponse, *entity.ApplicationError) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Login\", ctx, request)\n\tret0, _ := ret[0].(entity.LoginResponse)\n\tret1, _ := ret[1].(*entity.ApplicationError)\n\treturn ret0, ret1\n}", "func (m *MockClient) Login(ctx context.Context, username, password string) (*oauth2.Token, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Login\", ctx, username, password)\n\tret0, _ := ret[0].(*oauth2.Token)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockUsersService) Login(arg0 context.Context, arg1 models.UserLoginRequest) (models.UserLoginResponse, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Login\", arg0, arg1)\n\tret0, _ := ret[0].(models.UserLoginResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (_m *Repository) Login(email string) (entity.User, error) {\n\tret := _m.Called(email)\n\n\tvar r0 entity.User\n\tif rf, ok := ret.Get(0).(func(string) entity.User); ok {\n\t\tr0 = rf(email)\n\t} else {\n\t\tr0 = ret.Get(0).(entity.User)\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(string) error); ok {\n\t\tr1 = rf(email)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (m *MockHandler) UserLogin(email, password string) (*domain.User, string, error) {\n\tret := m.ctrl.Call(m, \"UserLogin\", email, password)\n\tret0, _ := ret[0].(*domain.User)\n\tret1, _ := ret[1].(string)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func (m *MockUserService) Login(ctx context.Context, user *domain.User) (*domain.UserToken, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Login\", ctx, user)\n\tret0, _ := ret[0].(*domain.UserToken)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (_m *ServerConnexion) Login(sUsername string, sPwd string) error {\n\tret := _m.Called(sUsername, sPwd)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(string, string) error); ok {\n\t\tr0 = rf(sUsername, sPwd)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (_m *Remote) Login(w http.ResponseWriter, r *http.Request) (*model.User, error) {\n\tret := _m.Called(w, r)\n\n\tvar r0 *model.User\n\tif rf, ok := ret.Get(0).(func(http.ResponseWriter, *http.Request) *model.User); ok {\n\t\tr0 = rf(w, r)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*model.User)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(http.ResponseWriter, *http.Request) error); ok {\n\t\tr1 = rf(w, r)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (_m *Asconn) Login(_a0 *aerospike.ClientPolicy) aerospike.Error {\n\tret := _m.Called(_a0)\n\n\tvar r0 aerospike.Error\n\tif rf, ok := ret.Get(0).(func(*aerospike.ClientPolicy) aerospike.Error); ok {\n\t\tr0 = rf(_a0)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(aerospike.Error)\n\t\t}\n\t}\n\n\treturn r0\n}", "func (m *MockUserLogic) UserLogin(email, password string) (*domain.User, string, error) {\n\tret := m.ctrl.Call(m, \"UserLogin\", email, password)\n\tret0, _ := ret[0].(*domain.User)\n\tret1, _ := ret[1].(string)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func (_m *Handler) Login(c echo.Context) error {\n\tret := _m.Called(c)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(echo.Context) error); ok {\n\t\tr0 = rf(c)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func TestAuthenticate_Success(t *testing.T) {\n\tdb, mock, err := sqlmock.New()\n\tif err != nil {\n\t\tt.Fatalf(\"an error '%s' was not expected when opening a stub database connection\", err)\n\t}\n\tdefer db.Close()\n\n\tuser := models.User{\n\t\tID: 1,\n\t\tEmail: \"personia@personio.com\",\n\t\tPassword: \"personia\",\n\t}\n\n\trows := sqlmock.NewRows([]string{\"id\", \"email\"}).AddRow(user.ID, user.Email)\n\tmock.ExpectQuery(regexp.QuoteMeta(constants.LoginDetailsSelectQuery)).WithArgs(user.Email, user.Password).WillReturnRows(rows)\n\n\tloginRepository := NewLoginRepository(db)\n\n\tloginModel := &models.Login{\n\t\tEmail: \"personia@personio.com\",\n\t\tPassword: \"personia\",\n\t}\n\n\tcntx := context.Background()\n\tdbuser, err := loginRepository.Authenticate(cntx, loginModel)\n\tassert.Nil(t, err)\n\tassert.Equal(t, user.ID, dbuser.ID)\n\tassert.Equal(t, user.Email, dbuser.Email)\n}", "func (h *TestAuth) Login(w http.ResponseWriter, req *http.Request) {\n\n\tresponse := make(map[string]string, 5)\n\n\tresponse[\"state\"] = authz.AuthNewPasswordRequired\n\tresponse[\"access_token\"] = \"access\"\n\t//response[\"id_token\"] = *authResult.IdToken\n\tresponse[\"refresh_token\"] = \"refersh\"\n\tresponse[\"expires\"] = \"3600\"\n\tresponse[\"token_type\"] = \"Bearer\"\n\trespData, _ := json.Marshal(response)\n\tw.WriteHeader(200)\n\tfmt.Fprint(w, string(respData))\n}", "func (_m *AuthServer) Login(_a0 context.Context, _a1 *auth.Credentials) (*auth.SessionInfo, error) {\n\tret := _m.Called(_a0, _a1)\n\n\tvar r0 *auth.SessionInfo\n\tif rf, ok := ret.Get(0).(func(context.Context, *auth.Credentials) *auth.SessionInfo); ok {\n\t\tr0 = rf(_a0, _a1)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*auth.SessionInfo)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, *auth.Credentials) error); ok {\n\t\tr1 = rf(_a0, _a1)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func mockLoginAsUser() http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tusername, err := usernameFromRequestPath(r)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\thttp.SetCookie(w, &http.Cookie{\n\t\t\tName: \"userkit_auth_token\",\n\t\t\tValue: fmt.Sprintf(\"dummy_usr_token__%s:dummy\", username),\n\t\t\tPath: \"/\",\n\t\t\tExpires: time.Now().Add(600 * time.Hour),\n\t\t})\n\t\tlog.Printf(\"mock logged in as %s\", username)\n\t\thttp.Redirect(w, r, \"/\", http.StatusTemporaryRedirect)\n\t}\n}", "func TestAuthenticate_Fail(t *testing.T) {\n\tdb, mock, err := sqlmock.New()\n\tif err != nil {\n\t\tt.Fatalf(\"an error '%s' was not expected when opening a stub database connection\", err)\n\t}\n\tdefer db.Close()\n\n\tuser := models.User{\n\t\tID: 1,\n\t\tEmail: \"personia@personio.com\",\n\t\tPassword: \"personia\",\n\t}\n\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(constants.LoginDetailsSelectQuery)\n\n\trows := sqlmock.NewRows([]string{\"id\", \"email\"})\n\tmock.ExpectQuery(regexp.QuoteMeta(buffer.String())).WithArgs(user.Email, user.Password).WillReturnRows(rows)\n\n\tloginRepository := NewLoginRepository(db)\n\n\tloginModel := &models.Login{\n\t\tEmail: \"personia@personio.com\",\n\t\tPassword: \"personia\",\n\t}\n\n\tcntx := context.Background()\n\t_, err = loginRepository.Authenticate(cntx, loginModel)\n\tassert.NotNil(t, err)\n}", "func TestAPILoginUser(t *testing.T) {\n\tpayload := []byte(`{\"username\":\"admin\", \"password\":\"admin1234\"}`)\n\n\treq, _ := http.NewRequest(\"POST\", \"/api/login\", bytes.NewBuffer(payload))\n\tresp := executeRequest(req)\n\n\tcheckResponseCode(t, http.StatusOK, resp.Code)\n\n\tvar m map[string]interface{}\n\tjson.Unmarshal(resp.Body.Bytes(), &m)\n\n\tassert.NotEqual(t, m[\"accessToken\"], \"\")\n}", "func TestLoginWrapper_LoggedOut(t *testing.T) {\n\tw, r, c := initTestRequestParams(t, nil)\n\tdefer c.Close()\n\n\tdummyLoginHandler(&requestParams{w: w, r: r, c: c})\n\n\texpectCode(t, http.StatusUnauthorized, w)\n\texpectBody(t, \"\", w)\n}", "func (c *Client) Login() error {\n\n\tversionStruct, err := CreateAPIVersion(1, 9, 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\tapiStruct, err := CreateAPISession(versionStruct, \"\", \"\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Create a Resty Client\n\tc.restClient = resty.New()\n\tc.restClient.\n\t\tSetTimeout(time.Duration(30 * time.Second)).\n\t\tSetRetryCount(3).\n\t\tSetRetryWaitTime(5 * time.Second).\n\t\tSetRetryMaxWaitTime(20 * time.Second)\n\n\tresp, err := c.restClient.R().\n\t\tSetHeader(\"Content-Type\", \"application/json\").\n\t\tSetBody(apiStruct).\n\t\tPost(c.url + \"/session\")\n\n\tresult := resp.Body()\n\tvar resultdat map[string]interface{}\n\tif err = json.Unmarshal(result, &resultdat); err != nil { //convert the json to go objects\n\t\treturn err\n\t}\n\n\tif resultdat[\"status\"].(string) == \"ERROR\" {\n\t\terrorMessage := string(result)\n\t\terr = fmt.Errorf(errorMessage)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tresp, err = c.restClient.R().\n\t\tSetHeader(\"Content-Type\", \"application/json\").\n\t\tSetResult(AuthSuccess{}).\n\t\tSetBody(LoginRequestStruct{\n\t\t\tType: \"LoginRequest\",\n\t\t\tUsername: c.username,\n\t\t\tPassword: c.password,\n\t\t}).\n\t\tPost(c.url + \"/login\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif http.StatusOK != resp.StatusCode() {\n\t\terr = fmt.Errorf(\"Delphix Username/Password incorrect\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tresult = resp.Body()\n\tif err = json.Unmarshal(result, &resultdat); err != nil { //convert the json to go objects\n\t\treturn err\n\t}\n\n\tif resultdat[\"status\"].(string) == \"ERROR\" {\n\t\terrorMessage := string(result)\n\t\tlog.Fatalf(errorMessage)\n\t\terr = fmt.Errorf(errorMessage)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\t\n\treturn nil\n}", "func (m *MockIWXClient) WXLogin(arg0, arg1, arg2 string) (wx.LoginResponse, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"WXLogin\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(wx.LoginResponse)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockClient) LoginLongLived(ctx context.Context, username, password string) (*oauth2.Token, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LoginLongLived\", ctx, username, password)\n\tret0, _ := ret[0].(*oauth2.Token)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (h *AuthHandlers) Login(w http.ResponseWriter, req *http.Request) {\n\tvar err error\n\tvar data []byte\n\n\tsystemContext, err := h.getSystemContext(req)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"request context retrevial failure\")\n\t\tmiddleware.ReturnError(w, err.Error(), 500)\n\t\treturn\n\t}\n\n\tif data, err = ioutil.ReadAll(req.Body); err != nil {\n\t\tlog.Error().Err(err).Msg(\"read body error\")\n\t\tmiddleware.ReturnError(w, \"error reading login data\", 500)\n\t\treturn\n\t}\n\tdefer req.Body.Close()\n\n\tloginDetails := &authz.LoginDetails{}\n\tif err := json.Unmarshal(data, loginDetails); err != nil {\n\t\tlog.Error().Err(err).Msg(\"marshal body error\")\n\t\tmiddleware.ReturnError(w, \"error reading login data\", 500)\n\t\treturn\n\t}\n\n\tif err := h.validate.Struct(loginDetails); err != nil {\n\t\tmiddleware.ReturnError(w, \"validation failure \"+err.Error(), 500)\n\t\treturn\n\t}\n\tloginDetails.OrgName = strings.ToLower(loginDetails.OrgName)\n\tloginDetails.Username = strings.ToLower(loginDetails.Username)\n\n\tlog.Info().Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"login attempt\")\n\n\torgData, err := h.getOrgByName(req.Context(), systemContext, loginDetails.OrgName)\n\tif err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"failed to get organization from name\")\n\t\tmiddleware.ReturnError(w, \"login failed\", 403)\n\t\treturn\n\t}\n\n\tresults, err := h.authenticator.Login(req.Context(), orgData, loginDetails)\n\tif err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"login failed\")\n\t\tif req.Context().Err() != nil {\n\t\t\tmiddleware.ReturnError(w, \"internal server error\", 500)\n\t\t\treturn\n\t\t}\n\t\tmiddleware.ReturnError(w, \"login failed\", 403)\n\t\treturn\n\t}\n\t// add subscription id to response\n\tresults[\"subscription_id\"] = fmt.Sprintf(\"%d\", orgData.SubscriptionID)\n\n\trespData, err := json.Marshal(results)\n\tif err != nil {\n\t\tmiddleware.ReturnError(w, \"marshal auth response failed\", 500)\n\t\treturn\n\t}\n\n\tlog.Info().Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Str(\"OrgCID\", orgData.OrgCID).Msg(\"setting orgCID in cookie\")\n\tif err := h.secureCookie.SetAuthCookie(w, results[\"access_token\"], orgData.OrgCID, orgData.SubscriptionID); err != nil {\n\t\tmiddleware.ReturnError(w, \"internal cookie failure\", 500)\n\t\treturn\n\t}\n\tw.WriteHeader(200)\n\tfmt.Fprint(w, string(respData))\n}", "func (_m *Forge) Login(ctx context.Context, w http.ResponseWriter, r *http.Request) (*model.User, error) {\n\tret := _m.Called(ctx, w, r)\n\n\tvar r0 *model.User\n\tvar r1 error\n\tif rf, ok := ret.Get(0).(func(context.Context, http.ResponseWriter, *http.Request) (*model.User, error)); ok {\n\t\treturn rf(ctx, w, r)\n\t}\n\tif rf, ok := ret.Get(0).(func(context.Context, http.ResponseWriter, *http.Request) *model.User); ok {\n\t\tr0 = rf(ctx, w, r)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*model.User)\n\t\t}\n\t}\n\n\tif rf, ok := ret.Get(1).(func(context.Context, http.ResponseWriter, *http.Request) error); ok {\n\t\tr1 = rf(ctx, w, r)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (u *User) Login(context.Context, *contract.LoginRequest) (*contract.LoginResponse, error) {\n\tpanic(\"not implemented\")\n}", "func (s *Mortgageplatform) Login(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {\n\tres, err := login(APIstub, args)\n\tif err != nil { return shim.Error(err.Error()) }\n\treturn shim.Success(res)\n}", "func (bap *BaseAuthProvider) Login(ctx *RequestCtx) (user User, reason error) {\n\t// try to verify credential\n\targs := ctx.Args\n\tusername := B2S(args.Peek(\"username\"))\n\tpassword := B2S(args.Peek(\"password\"))\n\tif len(username) == 0 && len(password) == 0 {\n\t\t//recover session from token\n\t\tuser := bap.UserFromRequest(ctx.Ctx)\n\t\tif user != nil {\n\t\t\treturn user, nil\n\t\t} else {\n\t\t\tfmt.Println(\"#1 errorWrongUsername\")\n\t\t\treturn nil, errorWrongUsername\n\t\t}\n\t} else if len(username) > 0 {\n\t\t// retrieve user's master data from db\n\t\t//log.Printf(\"Verify password by rich userobj in %T\\n\", bap.AccountProvider)\n\t\tvar userInDB User\n\t\tuserInDB = bap.AccountProvider.GetUser(username)\n\t\tif userInDB == nil {\n\t\t\tWriteToCookie(ctx.Ctx, AuthTokenName, \"\")\n\t\t\tfmt.Println(\"#2 errorWrongUsername\")\n\t\t\treturn nil, errorWrongUsername\n\t\t} else {\n\t\t\tif userInDB.Disabled() {\n\t\t\t\treturn nil, errorUserDisabled\n\t\t\t} else if !userInDB.Activated() {\n\t\t\t\treturn nil, errorUserInactivated\n\t\t\t}\n\t\t\tif ok := bap.FuCheckPassword(userInDB, password); ok {\n\t\t\t\tuserInDB.SetToken(DefaultTokenGenerator(userInDB.Username()))\n\t\t\t\t(*bap.Mutex).Lock()\n\t\t\t\tuserInDB.Touch()\n\t\t\t\tbap.TokenCache[userInDB.Token()] = userInDB\n\t\t\t\tbap.TokenToUsername.SetString(userInDB.Token(), []byte(userInDB.Username()))\n\t\t\t\t(*bap.Mutex).Unlock()\n\n\t\t\t\tWriteToCookie(ctx.Ctx, AuthTokenName, userInDB.Token())\n\t\t\t\treturn userInDB, nil\n\t\t\t}\n\t\t\tWriteToCookie(ctx.Ctx, AuthTokenName, \"\")\n\t\t\treturn nil, errorWrongPassword\n\t\t}\n\t}\n\tWriteToCookie(ctx.Ctx, AuthTokenName, \"\")\n\tfmt.Println(\"#3 errorWrongUsername\")\n\treturn nil, errorWrongUsername\n}", "func (_m *IUserService) Login(login *model.LoginForm) (*model.User, error) {\n\tret := _m.Called(login)\n\n\tvar r0 *model.User\n\tif rf, ok := ret.Get(0).(func(*model.LoginForm) *model.User); ok {\n\t\tr0 = rf(login)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*model.User)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(*model.LoginForm) error); ok {\n\t\tr1 = rf(login)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func Test_Login_MultiLogin(t *testing.T) {\n\tgSession = nil\n\tsession1, err := login(TestValidUser)\n\tif session1 == nil || err != nil {\n\t\tt.Error(\"fail at login\")\n\t}\n\tsession2, err := login(TestValidUser)\n\tif err != nil {\n\t\tt.Error(\"fail at login\")\n\t}\n\tif session1 != session2 {\n\t\tt.Error(\"multi login should get same session\")\n\t}\n}", "func (h UserRepos) Login(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\n\tctxValues, err := webcontext.ContextValues(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//\n\treq := new(UserLoginRequest)\n\tdata := make(map[string]interface{})\n\tf := func() (bool, error) {\n\n\t\tif r.Method == http.MethodPost {\n\t\t\terr := r.ParseForm()\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\tdecoder := schema.NewDecoder()\n\t\t\tif err := decoder.Decode(req, r.PostForm); err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\treq.Password = strings.Replace(req.Password, \".\", \"\", -1)\n\t\t\tsessionTTL := time.Hour\n\t\t\tif req.RememberMe {\n\t\t\t\tsessionTTL = time.Hour * 36\n\t\t\t}\n\n\t\t\t// Authenticated the user.\n\t\t\ttoken, err := h.AuthRepo.Authenticate(ctx, user_auth.AuthenticateRequest{\n\t\t\t\tEmail: req.Email,\n\t\t\t\tPassword: req.Password,\n\t\t\t}, sessionTTL, ctxValues.Now)\n\t\t\tif err != nil {\n\t\t\t\tswitch errors.Cause(err) {\n\t\t\t\tcase user.ErrForbidden:\n\t\t\t\t\treturn false, web.RespondError(ctx, w, weberror.NewError(ctx, err, http.StatusForbidden))\n\t\t\t\tcase user_auth.ErrAuthenticationFailure:\n\t\t\t\t\tdata[\"error\"] = weberror.NewErrorMessage(ctx, err, http.StatusUnauthorized, \"Invalid username or password. Try again.\")\n\t\t\t\t\treturn false, nil\n\t\t\t\tdefault:\n\t\t\t\t\tif verr, ok := weberror.NewValidationError(ctx, err); ok {\n\t\t\t\t\t\tdata[\"validationErrors\"] = verr.(*weberror.Error)\n\t\t\t\t\t\treturn false, nil\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn false, err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add the token to the users session.\n\t\t\terr = handleSessionToken(ctx, w, r, token)\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\tredirectUri := \"/\"\n\t\t\tif qv := r.URL.Query().Get(\"redirect\"); qv != \"\" {\n\t\t\t\tredirectUri, err = url.QueryUnescape(qv)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn false, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Redirect the user to the dashboard.\n\t\t\treturn true, web.Redirect(ctx, w, r, redirectUri, http.StatusFound)\n\t\t}\n\n\t\treturn false, nil\n\t}\n\n\tend, err := f()\n\tif err != nil {\n\t\treturn web.RenderError(ctx, w, r, err, h.Renderer, TmplLayoutBase, TmplContentErrorGeneric, web.MIMETextHTMLCharsetUTF8)\n\t} else if end {\n\t\treturn nil\n\t}\n\n\tdata[\"form\"] = req\n\n\tif verr, ok := weberror.NewValidationError(ctx, webcontext.Validator().Struct(UserLoginRequest{})); ok {\n\t\tdata[\"validationDefaults\"] = verr.(*weberror.Error)\n\t}\n\n\treturn h.Renderer.Render(ctx, w, r, TmplLayoutBase, \"user-login.gohtml\", web.MIMETextHTMLCharsetUTF8, http.StatusOK, data)\n}", "func (a *API) Login(username, password string) error {\n\n\t// First request redirects either to studip (already logged in) or to SSO\n\treq, err := http.NewRequest(\"GET\", loginURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\ta.applyHeader(req)\n\n\tresp, err := a.Client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif code := resp.StatusCode; code != http.StatusOK {\n\t\treturn &StatusCodeError{\n\t\t\tCode: code,\n\t\t\tMsg: fmt.Sprintf(\"Initial auth prepare request failed with status code: %d\", code),\n\t\t}\n\t}\n\n\t// Check if already logged in\n\tif verifyLoggedIn(resp) {\n\t\treturn nil\n\t}\n\n\trespLoginBody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\t// Check for login form\n\tif !reLoginForm.Match(respLoginBody) {\n\t\treturn &APIError{\n\t\t\tMsg: \"Could not find login form\",\n\t\t}\n\t}\n\n\t// Login SSO\n\n\t// Next request url is last redirected url\n\tauthurl := resp.Request.URL.String()\n\n\tauthForm := url.Values{}\n\tauthForm.Add(\"j_username\", username)\n\tauthForm.Add(\"j_password\", password)\n\n\treqAuth, err := http.NewRequest(\"POST\", authurl, strings.NewReader(authForm.Encode()))\n\tif err != nil {\n\t\treturn err\n\t}\n\ta.applyHeader(reqAuth)\n\treqAuth.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\trespAuth, err := a.Client.Do(reqAuth)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif code := respAuth.StatusCode; code != http.StatusOK {\n\t\treturn &StatusCodeError{\n\t\t\tCode: code,\n\t\t\tMsg: fmt.Sprintf(\"Auth request failed with status code: %d\", code),\n\t\t}\n\t}\n\trespAuthBody, err := ioutil.ReadAll(respAuth.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer respAuth.Body.Close()\n\n\t// Check for SAML Response page (SAML Confirmation form)\n\t// Otherwise username or password might be wrong\n\tm := reAuth.FindStringSubmatch(string(respAuthBody))\n\n\t// No login form\n\tif m == nil {\n\t\tinvalidLoginMatch := reInvalidLogin.FindStringSubmatch(string(respAuthBody))\n\t\tif invalidLoginMatch != nil && len(invalidLoginMatch) == 2 {\n\t\t\treturn &APIError{\n\t\t\t\tMsg: fmt.Sprintf(\"Invalid login: %s\", strings.TrimSpace(invalidLoginMatch[1])),\n\t\t\t\tInvalidLogin: true,\n\t\t\t}\n\t\t}\n\t\treturn &APIError{\n\t\t\tMsg: \"Could not finalize SAML Authentication, System down?\",\n\t\t}\n\t}\n\tif len(m) != 6 {\n\t\treturn &APIError{\n\t\t\tMsg: \"Could not parse SAML Response form\",\n\t\t}\n\t}\n\n\tsamlRespURL := html.UnescapeString(m[1])\n\tfield1Name := html.UnescapeString(m[2])\n\tfield1Value := html.UnescapeString(m[3])\n\tfield2Name := html.UnescapeString(m[4])\n\tfield2Value := html.UnescapeString(m[5])\n\n\t//build form\n\tform := url.Values{}\n\tform.Add(field1Name, field1Value)\n\tform.Add(field2Name, field2Value)\n\n\t// Send SAML Response form, should redirect to studip\n\treqSAMLResponse, err := http.NewRequest(\"POST\", samlRespURL, strings.NewReader(form.Encode()))\n\tif err != nil {\n\t\treturn err\n\t}\n\ta.applyHeader(reqSAMLResponse)\n\treqSAMLResponse.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\trespSAMLResp, err := a.Client.Do(reqSAMLResponse)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif code := respSAMLResp.StatusCode; code != http.StatusOK {\n\t\treturn &StatusCodeError{\n\t\t\tCode: code,\n\t\t\tMsg: fmt.Sprintf(\"SAML Response request failed with status code: %d\", code),\n\t\t}\n\t}\n\tif !(verifyLoggedIn(respSAMLResp)) {\n\t\treturn &APIError{\n\t\t\tMsg: \"Not redirected to studip after login\",\n\t\t}\n\t}\n\treturn nil\n}", "func (s *service) Login(w http.ResponseWriter, r *http.Request) (interface{}, error) {\n\tctx := r.Context()\n\n\treq, err := decodeLoginRequest(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuser, err := s.repoMngr.User().ByIdentity(ctx, req.UserAttribute(), req.Identity)\n\tif err == sql.ErrNoRows {\n\t\treturn nil, fmt.Errorf(\"%v: %w\", err, auth.ErrBadRequest(\"invalid username or password\"))\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = s.password.Validate(user, req.Password); err != nil {\n\t\treturn nil, fmt.Errorf(\"%v: %w\", err, auth.ErrBadRequest(\"invalid username or password\"))\n\t}\n\n\tvar jwtToken *auth.Token\n\n\tif user.CanSendDefaultOTP() {\n\t\tjwtToken, err = s.token.Create(\n\t\t\tctx,\n\t\t\tuser,\n\t\t\tauth.JWTPreAuthorized,\n\t\t\ttoken.WithOTPDeliveryMethod(user.DefaultOTPDelivery()),\n\t\t)\n\t} else {\n\t\tjwtToken, err = s.token.Create(ctx, user, auth.JWTPreAuthorized)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn s.respond(ctx, w, user, jwtToken)\n}", "func (_BREMFactory *BREMFactoryCaller) Login(opts *bind.CallOpts) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _BREMFactory.contract.Call(opts, out, \"login\")\n\treturn *ret0, err\n}", "func (_m *MutationResolver) Login(ctx context.Context, data gqlgen.LoginInput) (*pg.User, error) {\n\tret := _m.Called(ctx, data)\n\n\tvar r0 *pg.User\n\tif rf, ok := ret.Get(0).(func(context.Context, gqlgen.LoginInput) *pg.User); ok {\n\t\tr0 = rf(ctx, data)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*pg.User)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, gqlgen.LoginInput) error); ok {\n\t\tr1 = rf(ctx, data)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func mockTestUserInteraction(ctx context.Context, pro providerParams, username, password string) (string, error) {\n\tctx, cancel := context.WithTimeout(ctx, 10*time.Second)\n\tdefer cancel()\n\n\tprovider, err := oidc.NewProvider(ctx, pro.providerURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to create provider: %v\", err)\n\t}\n\n\t// Configure an OpenID Connect aware OAuth2 client.\n\toauth2Config := oauth2.Config{\n\t\tClientID: pro.clientID,\n\t\tClientSecret: pro.clientSecret,\n\t\tRedirectURL: pro.redirectURL,\n\n\t\t// Discovery returns the OAuth2 endpoints.\n\t\tEndpoint: provider.Endpoint(),\n\n\t\t// \"openid\" is a required scope for OpenID Connect flows.\n\t\tScopes: []string{oidc.ScopeOpenID, \"groups\"},\n\t}\n\n\tstate := \"xxx\"\n\tauthCodeURL := oauth2Config.AuthCodeURL(state)\n\t// fmt.Printf(\"authcodeurl: %s\\n\", authCodeURL)\n\n\tvar lastReq *http.Request\n\tcheckRedirect := func(req *http.Request, via []*http.Request) error {\n\t\t// fmt.Printf(\"CheckRedirect:\\n\")\n\t\t// fmt.Printf(\"Upcoming: %s %#v\\n\", req.URL.String(), req)\n\t\t// for _, c := range via {\n\t\t// \tfmt.Printf(\"Sofar: %s %#v\\n\", c.URL.String(), c)\n\t\t// }\n\t\t// Save the last request in a redirect chain.\n\t\tlastReq = req\n\t\t// We do not follow redirect back to client application.\n\t\tif req.URL.Path == \"/oauth_callback\" {\n\t\t\treturn http.ErrUseLastResponse\n\t\t}\n\t\treturn nil\n\t}\n\n\tdexClient := http.Client{\n\t\tCheckRedirect: checkRedirect,\n\t}\n\n\tu, err := url.Parse(authCodeURL)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"url parse err: %v\", err)\n\t}\n\n\t// Start the user auth flow. This page would present the login with\n\t// email or LDAP option.\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"new request err: %v\", err)\n\t}\n\t_, err = dexClient.Do(req)\n\t// fmt.Printf(\"Do: %#v %#v\\n\", resp, err)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"auth url request err: %v\", err)\n\t}\n\n\t// Modify u to choose the ldap option\n\tu.Path += \"/ldap\"\n\t// fmt.Println(u)\n\n\t// Pick the LDAP login option. This would return a form page after\n\t// following some redirects. `lastReq` would be the URL of the form\n\t// page, where we need to POST (submit) the form.\n\treq, err = http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"new request err (/ldap): %v\", err)\n\t}\n\t_, err = dexClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"request err: %v\", err)\n\t}\n\n\t// Fill the login form with our test creds:\n\t// fmt.Printf(\"login form url: %s\\n\", lastReq.URL.String())\n\tformData := url.Values{}\n\tformData.Set(\"login\", username)\n\tformData.Set(\"password\", password)\n\treq, err = http.NewRequestWithContext(ctx, http.MethodPost, lastReq.URL.String(), strings.NewReader(formData.Encode()))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"new request err (/login): %v\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\t_, err = dexClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"post form err: %v\", err)\n\t}\n\t// fmt.Printf(\"resp: %#v %#v\\n\", resp.StatusCode, resp.Header)\n\t// fmt.Printf(\"lastReq: %#v\\n\", lastReq.URL.String())\n\n\t// On form submission, the last redirect response contains the auth\n\t// code, which we now have in `lastReq`. Exchange it for a JWT id_token.\n\tq := lastReq.URL.Query()\n\tcode := q.Get(\"code\")\n\toauth2Token, err := oauth2Config.Exchange(ctx, code)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to exchange code for id token: %v\", err)\n\t}\n\n\trawIDToken, ok := oauth2Token.Extra(\"id_token\").(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"id_token not found!\")\n\t}\n\n\t// fmt.Printf(\"TOKEN: %s\\n\", rawIDToken)\n\treturn rawIDToken, nil\n}", "func (_BREMFactory *BREMFactoryCallerSession) Login() (string, error) {\n\treturn _BREMFactory.Contract.Login(&_BREMFactory.CallOpts)\n}", "func TestDvLIRClient_LoginLogout(t *testing.T) {\n\tip := viper.GetString(\"IPAddress\")\n\tpw := viper.GetString(\"Password\")\n\tdvlirClient, err := NewDvLIRClient(ip, pw)\n\tif !assert.NoError(t, err, \"Error while creating Api client\") {\n\t\treturn\n\t}\n\n\terr = dvlirClient.Login()\n\tif !assert.NoError(t, err, \"Error during Login\") {\n\t\treturn\n\t}\n\n\tdefer func() {\n\t\terr = dvlirClient.Logout()\n\t\tif !assert.NoError(t, err, \"Error during Logout\") {\n\t\t\treturn\n\t\t}\n\t}()\n}", "func AuthLoginWrapper(ctx *fasthttp.RequestCtx, mgoClient *mgo.Session, redisClient *redis.Client, cfg datastructures.Configuration) {\n\tlog.Info(\"AuthLoginWrapper | Starting authentication | Parsing authentication credentials\")\n\tctx.Response.Header.SetContentType(\"application/json; charset=utf-8\")\n\tusername, password := ParseAuthenticationCoreHTTP(ctx) // Retrieve the username and password encoded in the request from BasicAuth headers, GET & POST\n\tif authutils.ValidateCredentials(username, password) { // Verify if the input parameter respect the rules ...\n\t\tlog.Debug(\"AuthLoginWrapper | Input validated | User: \", username, \" | Pass: \", password, \" | Calling core functionalities ...\")\n\t\tcheck := authutils.LoginUserHTTPCore(username, password, mgoClient, cfg.Mongo.Users.DB, cfg.Mongo.Users.Collection) // Login phase\n\t\tif strings.Compare(check, \"OK\") == 0 { // Login Succeed\n\t\t\tlog.Debug(\"AuthLoginWrapper | Login succesfully! Generating token!\")\n\t\t\ttoken := basiccrypt.GenerateToken(username, password) // Generate a simple md5 hashed token\n\t\t\tlog.Info(\"AuthLoginWrapper | Inserting token into Redis \", token)\n\t\t\tbasicredis.InsertIntoClient(redisClient, username, token, cfg.Redis.Token.Expire) // insert the token into the DB\n\t\t\tlog.Info(\"AuthLoginWrapper | Token inserted! All operation finished correctly! | Setting token into response\")\n\t\t\tauthcookie := authutils.CreateCookie(\"GoLog-Token\", token, cfg.Redis.Token.Expire)\n\t\t\tctx.Response.Header.SetCookie(authcookie) // Set the token into the cookie headers\n\t\t\tctx.Response.Header.Set(\"GoLog-Token\", token) // Set the token into a custom headers for future security improvments\n\t\t\tlog.Warn(\"AuthLoginWrapper | Client logged in succesfully!! | \", username, \":\", password, \" | Token: \", token)\n\t\t\terr := json.NewEncoder(ctx).Encode(datastructures.Response{Status: true, Description: \"User logged in!\", ErrorCode: username + \":\" + password, Data: token})\n\t\t\tcommonutils.Check(err, \"AuthLoginWrapper\")\n\t\t} else {\n\t\t\tcommonutils.AuthLoginWrapperErrorHelper(ctx, check, username, password)\n\t\t}\n\t} else { // error parsing credential\n\t\tlog.Info(\"AuthLoginWrapper | Error parsing credential!! |\", username+\":\"+password)\n\t\tctx.Response.Header.DelCookie(\"GoLog-Token\")\n\t\tctx.Error(fasthttp.StatusMessage(fasthttp.StatusUnauthorized), fasthttp.StatusUnauthorized)\n\t\tctx.Response.Header.Set(\"WWW-Authenticate\", \"Basic realm=Restricted\")\n\t\t//err := json.NewEncoder(ctx).Encode(datastructures.Response{Status: false, Description: \"Error parsing credential\", ErrorCode: \"Missing or manipulated input\", Data: nil})\n\t\t//commonutils.Check(err, \"AuthLoginWrapper\")\n\t}\n}", "func (impl *UserAPIClient) Login(ctx context.Context, login string, password string) (reply *api.Token, err error) {\n\terr = client.CallHTTP(ctx, impl.BaseURL, \"UserAPI.Login\", atomic.AddUint64(&impl.sequence, 1), &reply, login, password)\n\treturn\n}", "func (n *NewLogger) Login(w http.ResponseWriter, r *http.Request) {\n\tn.l.Println(\"Starting login analysis...\")\n\n\t//get the users list\n\tif usersList == nil {\n\t\tusersList.GetUsers(n.l)\n\t}\n\n\t//validate update before proceed\n\tif usersList == nil {\n\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\terr := json.NewDecoder(r.Body).Decode(&Credential)\n\tif err != nil {\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tn.l.Printf(\"userlist: %v\", usersList)\n\tfor _, u := range usersList {\n\t\tn.l.Printf(\"user: %v\", u)\n\t\tusers[u.Username] = u.Password\n\n\t}\n\n\t//n.l.Printf(\"username: %v\", users[\"admin\"])\n\tn.l.Printf(\"username: %v\", Credential.Username)\n\tn.l.Printf(\"password: %v\", Credential.Password)\n\n\texpectedPass, ok := users[Credential.Username]\n\tif !ok || expectedPass != Credential.Password {\n\t\thttp.Error(w, \"Invalid credentials\", http.StatusUnauthorized)\n\t\treturn\n\n\t}\n\texpirationTimeAdmin := time.Now().Add(time.Minute * 60)\n\texpirationTimeGuest := time.Now().Add(time.Minute * 10)\n\n\tvar claims *Claims\n\tif Credential.Username == \"admin\" {\n\t\tclaims = &Claims{\n\t\t\tUsername: Credential.Username,\n\t\t\tStandardClaims: jwt.StandardClaims{\n\t\t\t\tExpiresAt: expirationTimeAdmin.Unix(),\n\t\t\t},\n\t\t}\n\t\ttoken := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)\n\t\ttokenString, err := token.SignedString(jwtKey)\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\thttp.SetCookie(w, &http.Cookie{\n\t\t\tName: \"token\",\n\t\t\tValue: tokenString,\n\t\t\tExpires: expirationTimeAdmin,\n\t\t})\n\t}\n\tif Credential.Username == \"guest\" {\n\t\tclaims = &Claims{\n\t\t\tUsername: Credential.Username,\n\t\t\tStandardClaims: jwt.StandardClaims{\n\t\t\t\tExpiresAt: expirationTimeGuest.Unix(),\n\t\t\t},\n\t\t}\n\t\ttoken := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)\n\t\ttokenString, err := token.SignedString(jwtKey)\n\t\tif err != nil {\n\t\t\tw.WriteHeader(http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t\thttp.SetCookie(w, &http.Cookie{\n\t\t\tName: \"token\",\n\t\t\tValue: tokenString,\n\t\t\tExpires: expirationTimeGuest,\n\t\t})\n\t}\n\n}", "func (s *AuthService) Login(login, password string) (*AuthResponse, error) {\n\tresponse, err := s.client.Auth.Login(login, password)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &AuthResponse{AuthResponse: response}, nil\n}", "func (_BREMFactory *BREMFactorySession) Login() (string, error) {\n\treturn _BREMFactory.Contract.Login(&_BREMFactory.CallOpts)\n}", "func (_Userable *UserableCaller) Login(opts *bind.CallOpts) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _Userable.contract.Call(opts, out, \"login\")\n\treturn *ret0, err\n}", "func xTestAuthLoad(t *testing.T) {\n\tc := setup(t)\n\tdefer Teardown(c)\n\n\tdoLogin := func(myid int, times int64, ch chan<- bool) {\n\t\tsessionKeys := make([]string, times)\n\t\tfor iter := int64(0); iter < times; iter++ {\n\t\t\t//t.Logf(\"%v: %v/%v login\\n\", myid, iter, times)\n\t\t\tkey, token, err := c.Login(joeEmail, joePwd, \"\")\n\t\t\tif err != nil {\n\t\t\t\tt.Errorf(\"Login failed. Error should not be %v\", err)\n\t\t\t}\n\t\t\tif token == nil {\n\t\t\t\tt.Errorf(\"Login failed. Token should not be nil\")\n\t\t\t}\n\t\t\tsessionKeys[iter] = key\n\t\t}\n\t\tfor iter := int64(0); iter < times; iter++ {\n\t\t\ttoken, err := c.GetTokenFromSession(sessionKeys[iter])\n\t\t\tif token == nil || err != nil {\n\t\t\t\tt.Errorf(\"GetTokenFromSession failed\")\n\t\t\t}\n\t\t}\n\t\tch <- true\n\t}\n\n\tnsimul := 20\n\tconPerThread := int64(10000)\n\tif isBackendPostgresTest() {\n\t\tconPerThread = int64(100)\n\t} else if isBackendLdapTest() {\n\t\tconPerThread = int64(100)\n\t}\n\twaits := make([]chan bool, nsimul)\n\tfor i := 0; i < nsimul; i++ {\n\t\twaits[i] = make(chan bool, 0)\n\t\tgo doLogin(i, conPerThread, waits[i])\n\t}\n\tfor i := 0; i < nsimul; i++ {\n\t\t_, ok := <-waits[i]\n\t\tif !ok {\n\t\t\tt.Errorf(\"Channel closed prematurely\")\n\t\t}\n\t}\n}", "func (m *MockAuthenticationService) GetLoginSession(arg0 *http.Request) (security.LoginSession, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetLoginSession\", arg0)\n\tret0, _ := ret[0].(security.LoginSession)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (p *UserRepositoryFaker) Login(email string, pass string) (*entity.User, *values.ResponseError) {\n\tuser := &entity.User{}\n\n\tfor _, u := range usersFaker {\n\t\tif email == u.Email {\n\t\t\tuser = u\n\t\t}\n\t}\n\n\treturn user, nil\n}", "func (a *authSvc) Login(ctx context.Context, userID int64, secretKey string) error {\n\ttoken, err := createToken(userID, secretKey)\n\tif err != nil {\n\t\treturn err\n\t}\n\tsaveErr := cacheAuth(userID, token)\n\tif saveErr != nil {\n\t\treturn saveErr\n\t}\n\tcookieAccess := getCookieAccess(ctx)\n\tcookieAccess.SetToken(\"jwtAccess\", token.AccessToken, time.Unix(token.AtExpires, 0))\n\tcookieAccess.SetToken(\"jwtRefresh\", token.RefreshToken, time.Unix(token.RtExpires, 0))\n\treturn nil\n}", "func (h *auth) Login(c echo.Context) error {\n\t// Filter params\n\tvar params service.LoginParams\n\tif err := c.Bind(&params); err != nil {\n\t\tlog.Println(\"Could not get parameters:\", err)\n\t\treturn c.JSON(http.StatusBadRequest, sferror.New(\"Could not get credentials.\"))\n\t}\n\tparams.UserAgent = c.Request().UserAgent()\n\tparams.Session = currentSession(c)\n\n\tif params.Email == \"\" || params.Password == \"\" {\n\t\treturn c.JSON(http.StatusBadRequest, sferror.New(\"No email or password provided.\"))\n\t}\n\n\treturn h.login(c, params)\n\n}", "func loginWithTestUser(t *testing.T, req *http.Request, env *Env, ghUsername string) *http.Request {\n\tvar user *datastore.User\n\tvar err error\n\n\tif ghUsername == \"invalid\" {\n\t\tuser = &datastore.User{ID: 0, AccessLevel: datastore.AccessDisabled}\n\t} else {\n\t\tuser, err = env.db.GetUserByGithub(ghUsername)\n\t\tif err != nil {\n\t\t\tt.Fatalf(\"error getting mock user by github name: %v\", err)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tctx := req.Context()\n\tctx = context.WithValue(ctx, userContextKey(0), user)\n\treturn req.WithContext(ctx)\n}", "func (service *UserService) Login(email, password string) (*models.User, error) {\n\treturn service.repository.Login(email, password)\n}", "func (a SuperAdmin) Login(user, passwd string) (error, bool) {\n if user == a.Name && passwd == a.Pass {\n return nil, true\n } else {\n return errors.New(\"Wrong login or password\"), false\n }\n}", "func (m *MockAuthService) Logout(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Logout\", arg0, arg1)\n}", "func TestConnectLogin(t *testing.T) {\n\tconfig := NewDefaultConfig(ClientConfig{\n\t\tHost: StagingHost,\n\t\tClientID: \"telenordigital-connectexample-web\",\n\t\tPassword: \"\",\n\t\tLoginCompleteRedirectURI: \"/\",\n\t\tLogoutCompleteRedirectURI: \"/\",\n\t})\n\n\tconnect := NewConnectID(config)\n\thttp.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Write([]byte(\"Hello hello\"))\n\t})\n\thttp.Handle(\"/connect/\", connect.Handler())\n\n\t// Show the logged in user's properties.\n\thttp.HandleFunc(\"/connect/profile\", connect.SessionProfile)\n\n\tgo func() {\n\t\tif err := http.ListenAndServe(\":8080\", nil); err != nil {\n\t\t\tt.Fatal(err)\n\t\t}\n\t}()\n\n\tclient := http.Client{}\n\tresp, err := client.Get(\"http://localhost:8080/connect/login\")\n\tif err != nil {\n\t\tt.Fatal(\"Got error calling login: \", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\tt.Fatal(\"Got status \", resp.Status)\n\t}\n\n\tclient.CheckRedirect = func(req *http.Request, via []*http.Request) error {\n\t\tt.Logf(\"Redirect: %+v\", req)\n\t\treturn nil\n\t}\n\tresp, err = client.Get(\"http://localhost:8080/connect/logout\")\n\tif err != nil {\n\t\tt.Fatal(\"Got error calling logout: \", err)\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\tt.Fatalf(\"Got response %+v\", resp)\n\t}\n}", "func LoginUser(u User) {\n err, _ := u.Login(\"admin\", \"admin\")\n\n if err != nil {\n fmt.Println(err.Error())\n }\n}", "func (client *HammerspaceClient) EnsureLogin() error {\n v := url.Values{}\n v.Add(\"username\", client.username);\n v.Add(\"password\", client.password);\n\n resp, err := client.httpclient.PostForm(fmt.Sprintf(\"%s%s/login\", client.endpoint, BasePath),v)\n if err != nil {\n return err\n }\n defer resp.Body.Close()\n body, err := ioutil.ReadAll(resp.Body)\n bodyString := string(body)\n responseLog := log.WithFields(log.Fields{\n \"statusCode\": resp.StatusCode,\n \"body\": bodyString,\n \"headers\": resp.Header,\n \"url\": resp.Request.URL,\n })\n\n if err != nil {\n log.Error(err)\n }\n if resp.StatusCode != 200 {\n err = errors.New(\"failed to login to Hammerspace Anvil\")\n responseLog.Error(err)\n }\n return err\n}", "func (_Userable *UserableCallerSession) Login() (string, error) {\n\treturn _Userable.Contract.Login(&_Userable.CallOpts)\n}", "func (m *MockUCAuth) LoginWithEmail(ctx context.Context, email string, password []byte) (*models.UserWithToken, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LoginWithEmail\", ctx, email, password)\n\tret0, _ := ret[0].(*models.UserWithToken)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (a Admin) Login(user,passwd string) (error, bool) {\n if user == a.Name && passwd == a.Pass {\n return nil, true\n } else {\n return errors.New(\"Wrong login or password\"), false\n }\n}", "func Login(c *gin.Context) {\n\tos.Setenv(\"API_SECRET\", \"85ds47\")\n\ttype login struct {\n\t\tEmail string `json:\"email\"`\n\t\tPassword string `json:\"password\"`\n\t}\n\n\tloginParams := login{}\n\tc.ShouldBindJSON(&loginParams)\n\ttype Result struct {\n\t\tEmail string\n\t\tUUID string\n\t\tAccessLevel string\n\t\tPassword string\n\t}\n\tvar user Result\n\tif !db.Table(\"users\").Select(\"email, password, uuid, access_level\").Where(\"email = ?\", loginParams.Email).Scan(&user).RecordNotFound() {\n\t\tif CheckPasswordHash(loginParams.Password, user.Password) {\n\t\t\ttoken := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{\n\t\t\t\t\"uuid\": user.UUID,\n\t\t\t\t\"acl\": user.AccessLevel,\n\t\t\t})\n\t\t\ttokenStr, err := token.SignedString([]byte(os.Getenv(\"API_SECRET\")))\n\n\t\t\tif err != nil {\n\t\t\t\tc.JSON(500, err)\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tc.JSON(200, tokenStr)\n\t\t\treturn\n\t\t} else {\n\t\t\tc.JSON(http.StatusBadRequest, \"wrong password\")\n\t\t\treturn\n\t\t}\n\t} else {\n\t\tc.JSON(http.StatusBadRequest, \"wrong email\")\n\t\treturn\n\t}\n}", "func (r *mutationResolver) Login(ctx context.Context, input *models.LoginInput) (*auth.Auth, error) {\n\tpanic(\"not implemented\")\n}", "func (m *MockUCAuth) LoginWithUsername(ctx context.Context, username string, password []byte) (*models.UserWithToken, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"LoginWithUsername\", ctx, username, password)\n\tret0, _ := ret[0].(*models.UserWithToken)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockServiceAuth) Auth(arg0 models.UserInput) (models.UserBoardsOutside, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Auth\", arg0)\n\tret0, _ := ret[0].(models.UserBoardsOutside)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"login called\")\n}", "func login(c *gin.Context) {\n\tvar loginDetails LoginDetails\n\tvar err error\n\n\t// Get query params into object\n\tif err = c.ShouldBind(&loginDetails); err != nil {\n\t\tprintln(err.Error())\n\t\tc.Status(http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tvar passwordHash string\n\tvar id int\n\tsqlStatement := `SELECT id, password_hash FROM player WHERE email=LOWER($1) LIMIT 1;`\n\terr = db.QueryRow(sqlStatement, loginDetails.Email).Scan(&id, &passwordHash)\n\tif handleError(err, c) {\n\t\treturn\n\t}\n\n\tif bcrypt.CompareHashAndPassword([]byte(passwordHash), []byte(loginDetails.Password)) != nil {\n\t\tprintln(\"Incorrect password\")\n\n\t\tc.AbortWithStatus(http.StatusNotFound)\n\t\treturn\n\t}\n\n\ttoken, err := CreateTokenInDB(id)\n\tif err != nil {\n\t\tprintln(err.Error())\n\t\tc.AbortWithStatus(http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\t// Return token and user id\n\tretObj := PlayerToken{PlayerId: id, Token: token}\n\n\tc.JSON(http.StatusOK, retObj)\n}", "func (_m *Usecase) Login(ctx context.Context, ar *models.Login) (*models.GetToken, error) {\n\tret := _m.Called(ctx, ar)\n\n\tvar r0 *models.GetToken\n\tif rf, ok := ret.Get(0).(func(context.Context, *models.Login) *models.GetToken); ok {\n\t\tr0 = rf(ctx, ar)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*models.GetToken)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, *models.Login) error); ok {\n\t\tr1 = rf(ctx, ar)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func (as *AuthService) Login(username string, password string) (string, error) {\n\tuser, err := as.repo.GetUserByName(username)\n\tif err != nil {\n\t\treturn \"\", models.ErrGeneralServerError\n\t}\n\tif hashesMatch(user.Pwhash, password) {\n\t\ttoken, err := utils.GenerateJWTforUser(user)\n\t\tif err != nil {\n\t\t\treturn \"\", models.ErrGeneralServerError\n\t\t}\n\t\treturn token, nil\n\t}\n\treturn \"\", models.ErrWrongPasswordError\n}", "func (c *Client) Login(username, password string) error {\n\tloginURL := fmt.Sprintf(\"%v%v\", c.Host, \"UserProfile/LogOn\")\n\ttoken, err := c.getLoginToken()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata := url.Values{}\n\tdata.Add(\"UserName\", username)\n\tdata.Add(\"password\", password)\n\tdata.Add(\"__RequestVerificationToken\", token)\n\tresp, err := c.Post(loginURL, \"application/x-www-form-urlencoded\", strings.NewReader(data.Encode()))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get response from POST: %v\", err)\n\t}\n\tif resp.StatusCode >= 300 && resp.StatusCode < 400 {\n\t\tfmt.Println(\"Got a redirect\")\n\t\tfmt.Println(resp.StatusCode)\n\t\treturn errors.New(\"implement the redirect or post directly to /Dashboard?\")\n\t}\n\tif resp.StatusCode >= 400 {\n\t\tb, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"error reading body: %v\", err)\n\t\t\treturn err\n\t\t}\n\t\tfmt.Println(\"============== login response ==============\")\n\t\tfmt.Println(string(b))\n\t\tfmt.Println(\"============== end login response ==============\")\n\t\treturn fmt.Errorf(\"bad response: %v, [%v]\", loginURL, resp.StatusCode)\n\t}\n\treturn nil\n}", "func (r *apiV1Router) Login(ctx *gin.Context) {\n\temail := ctx.PostForm(\"email\")\n\tif email == \"\" {\n\t\tr.logger.Warn(\"email was not provided\")\n\t\tmodels.SendAPIError(ctx, http.StatusBadRequest, \"email must be provided\")\n\t\treturn\n\t}\n\n\tpassword := ctx.PostForm(\"password\")\n\tif password == \"\" {\n\t\tr.logger.Warn(\"password was not provided\")\n\t\tmodels.SendAPIError(ctx, http.StatusBadRequest, \"password must be provided\")\n\t\treturn\n\t}\n\n\tuser, err := r.userService.GetUserWithEmail(ctx, email)\n\tif err != nil {\n\t\tif err == services.ErrNotFound {\n\t\t\tr.logger.Warn(\"user not found\", zap.String(\"email\", email))\n\t\t\tmodels.SendAPIError(ctx, http.StatusUnauthorized, \"user not found\")\n\t\t} else {\n\t\t\tr.logger.Error(\"could not fetch user\", zap.Error(err))\n\t\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"there was a problem with fetching the user\")\n\t\t}\n\t\treturn\n\t}\n\n\terr = auth.CompareHashAndPassword(user.Password, password)\n\tif err != nil {\n\t\tr.logger.Warn(\"user not found\", zap.String(\"email\", email))\n\t\tmodels.SendAPIError(ctx, http.StatusUnauthorized, \"user not found\")\n\t\treturn\n\t}\n\n\tif !user.EmailVerified {\n\t\tr.logger.Warn(\"user's email not verified'\", zap.String(\"user id\", user.ID.Hex()), zap.String(\"email\", email))\n\t\tmodels.SendAPIError(ctx, http.StatusUnauthorized, \"user's email has not been verified\")\n\t\treturn\n\t}\n\n\ttoken, err := auth.NewJWT(*user, time.Now().Unix(), r.cfg.AuthTokenLifetime, auth.Auth, []byte(r.env.Get(environment.JWTSecret)))\n\tif err != nil {\n\t\tr.logger.Error(\"could not create JWT\", zap.String(\"user\", user.ID.Hex()), zap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"there was a problem with creating authentication token\")\n\t\treturn\n\t}\n\n\tctx.Header(authHeaderName, token)\n\tctx.JSON(http.StatusOK, loginRes{\n\t\tResponse: models.Response{\n\t\t\tStatus: http.StatusOK,\n\t\t},\n\t\tToken: token,\n\t\tUser: *user,\n\t})\n}", "func Login(w http.ResponseWriter, r *http.Request) {\r\n\tlogin := strings.Trim(r.FormValue(\"login\"), \" \")\r\n\tpass := strings.Trim(r.FormValue(\"pass\"), \" \")\r\n\tlog.Println(\"login: \", login, \" pass: \", pass)\r\n\r\n\t// Check params\r\n\tif login == \"\" || pass == \"\" {\r\n\t\twriteResponse(w, \"Login and password required\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\t// Already authorized\r\n\tif savedPass, OK := Auth[login]; OK && savedPass == pass {\r\n\t\twriteResponse(w, \"You are already authorized\\n\", http.StatusOK)\r\n\t\treturn\r\n\t} else if OK && savedPass != pass {\r\n\t\t// it is not neccessary\r\n\t\twriteResponse(w, \"Wrong pass\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\tuser := model.User{}\r\n\terr := user.Get(login, pass)\r\n\tif err == nil {\r\n\t\tAuth[login], Work[login] = pass, user.WorkNumber\r\n\t\twriteResponse(w, \"Succesfull authorization\\n\", http.StatusOK)\r\n\t\treturn\r\n\t}\r\n\r\n\twriteResponse(w, \"User with same login not found\\n\", http.StatusNotFound)\r\n}", "func (m *MockUserService) Authenticate(tx *sqlx.Tx, username, password string) (int64, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Authenticate\", tx, username, password)\n\tret0, _ := ret[0].(int64)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (_m *Leaser) Login(opts *service.LeaseLoginOptions) {\n\t_m.Called(opts)\n}", "func (m *MockHandler) Logout(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Logout\", arg0, arg1)\n}", "func (m defaultLoginManager) Login(\n\tctx context.Context, d diag.Sink, cloudURL string,\n\tproject *workspace.Project, insecure bool, opts display.Options,\n) (Backend, error) {\n\tcurrent, err := m.Current(ctx, d, cloudURL, project, insecure)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif current != nil {\n\t\treturn current, nil\n\t}\n\n\tcloudURL = ValueOrDefaultURL(cloudURL)\n\tvar accessToken string\n\taccountLink := cloudConsoleURL(cloudURL, \"account\", \"tokens\")\n\n\tif !cmdutil.Interactive() {\n\t\t// If interactive mode isn't enabled, the only way to specify a token is through the environment variable.\n\t\t// Fail the attempt to login.\n\t\treturn nil, fmt.Errorf(\"%s must be set for login during non-interactive CLI sessions\", AccessTokenEnvVar)\n\t}\n\n\t// If no access token is available from the environment, and we are interactive, prompt and offer to\n\t// open a browser to make it easy to generate and use a fresh token.\n\tline1 := \"Manage your Pulumi stacks by logging in.\"\n\tline1len := len(line1)\n\tline1 = colors.Highlight(line1, \"Pulumi stacks\", colors.Underline+colors.Bold)\n\tfmt.Printf(opts.Color.Colorize(line1) + \"\\n\")\n\tmaxlen := line1len\n\n\tline2 := \"Run `pulumi login --help` for alternative login options.\"\n\tline2len := len(line2)\n\tfmt.Printf(opts.Color.Colorize(line2) + \"\\n\")\n\tif line2len > maxlen {\n\t\tmaxlen = line2len\n\t}\n\n\t// In the case where we could not construct a link to the pulumi console based on the API server's hostname,\n\t// don't offer magic log-in or text about where to find your access token.\n\tif accountLink == \"\" {\n\t\tfor {\n\t\t\tif accessToken, err = cmdutil.ReadConsoleNoEcho(\"Enter your access token\"); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif accessToken != \"\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t} else {\n\t\tline3 := fmt.Sprintf(\"Enter your access token from %s\", accountLink)\n\t\tline3len := len(line3)\n\t\tline3 = colors.Highlight(line3, \"access token\", colors.BrightCyan+colors.Bold)\n\t\tline3 = colors.Highlight(line3, accountLink, colors.BrightBlue+colors.Underline+colors.Bold)\n\t\tfmt.Printf(opts.Color.Colorize(line3) + \"\\n\")\n\t\tif line3len > maxlen {\n\t\t\tmaxlen = line3len\n\t\t}\n\n\t\tline4 := \" or hit <ENTER> to log in using your browser\"\n\t\tvar padding string\n\t\tif pad := maxlen - len(line4); pad > 0 {\n\t\t\tpadding = strings.Repeat(\" \", pad)\n\t\t}\n\t\tline4 = colors.Highlight(line4, \"<ENTER>\", colors.BrightCyan+colors.Bold)\n\n\t\tif accessToken, err = cmdutil.ReadConsoleNoEcho(opts.Color.Colorize(line4) + padding); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif accessToken == \"\" {\n\t\t\treturn loginWithBrowser(ctx, d, cloudURL, project, insecure, opts)\n\t\t}\n\n\t\t// Welcome the user since this was an interactive login.\n\t\tWelcomeUser(opts)\n\t}\n\n\t// Try and use the credentials to see if they are valid.\n\tvalid, username, organizations, err := IsValidAccessToken(ctx, cloudURL, insecure, accessToken)\n\tif err != nil {\n\t\treturn nil, err\n\t} else if !valid {\n\t\treturn nil, fmt.Errorf(\"invalid access token\")\n\t}\n\n\t// Save them.\n\taccount := workspace.Account{\n\t\tAccessToken: accessToken,\n\t\tUsername: username,\n\t\tOrganizations: organizations,\n\t\tLastValidatedAt: time.Now(),\n\t\tInsecure: insecure,\n\t}\n\tif err = workspace.StoreAccount(cloudURL, account, true); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn New(d, cloudURL, project, insecure)\n}", "func (s *Service) Login(params *LoginParams) (*User, error) {\n\t// Try t o pull this user from the database.\n\tdbu, err := s.db.Users.GetByEmail(params.Email)\n\t//fmt.Println(err)\n\tif err == dbusers.ErrUserNotFound {\n\t\treturn nil, ErrInvalidLogin\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Validate the password.\n\tif err = bcrypt.CompareHashAndPassword([]byte(dbu.Password), []byte(params.Password)); err != nil {\n\t\treturn nil, ErrInvalidLogin\n\t}\n\n\t// Create a new User.\n\tuser := &User{\n\t\tID: dbu.ID,\n\t\tFullName: dbu.FullName,\n\t\tUserName: dbu.UserName,\n\t\tEmail: dbu.Email,\n\t\tPassword: dbu.Password,\n\t\tCreatedAt: dbu.CreatedAt,\n\t}\n\n\treturn user, nil\n\n}", "func (a *Account) LoginImpl(addr, baseAddr string) NicoError {\n\tif a.Mail == \"\" || a.Pass == \"\" {\n\t\treturn NicoErr(NicoErrOther,\n\t\t\t\"invalid account info\", \"mail or pass is not set\")\n\t}\n\n\tjar, err := cookiejar.New(nil)\n\tif err != nil {\n\t\treturn NicoErrFromStdErr(err)\n\t}\n\tcl := http.Client{Jar: jar}\n\n\tparams := url.Values{\n\t\t\"mail\": []string{a.Mail},\n\t\t\"password\": []string{a.Pass},\n\t}\n\tresp, err := cl.PostForm(addr, params)\n\tif err != nil {\n\t\treturn NicoErrFromStdErr(err)\n\t}\n\tdefer resp.Body.Close()\n\n\tnicoURL, err := url.Parse(baseAddr)\n\tif err != nil {\n\t\treturn NicoErrFromStdErr(err)\n\t}\n\tfor _, ck := range cl.Jar.Cookies(nicoURL) {\n\t\tif ck.Name == \"user_session\" {\n\t\t\tif ck.Value != \"deleted\" && ck.Value != \"\" {\n\t\t\t\ta.Usersession = ck.Value\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn NicoErr(NicoErrOther, \"login error\", \"failed log in to niconico\")\n}", "func (p *Base) Login() string {\n\treturn \"https://admin.thebase.in/users/login\"\n}", "func (s *Service) Login(c context.Context, app *model.App, subid int32, userid, rsaPwd string) (res *model.LoginToken, err error) {\n\tif userid == \"\" || rsaPwd == \"\" {\n\t\terr = ecode.UsernameOrPasswordErr\n\t\treturn\n\t}\n\tcache := true\n\ta, pwd, tsHash, err := s.checkUserData(c, userid, rsaPwd)\n\tif err != nil {\n\t\tif err == ecode.PasswordHashExpires || err == ecode.PasswordTooLeak {\n\t\t\treturn\n\t\t}\n\t\terr = nil\n\t} else {\n\t\tvar t *model.Perm\n\t\tif t, cache, err = s.saveToken(c, app.AppID, subid, a.Mid); err != nil {\n\t\t\terr = nil\n\t\t} else {\n\t\t\tres = &model.LoginToken{\n\t\t\t\tMid: t.Mid,\n\t\t\t\tAccessKey: t.AccessToken,\n\t\t\t\tExpires: t.Expires,\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t}\n\tif res, err = s.loginOrigin(c, userid, pwd, tsHash); err != nil {\n\t\treturn\n\t}\n\tif cache && res != nil {\n\t\ts.d.SetTokenCache(c, &model.Perm{\n\t\t\tMid: res.Mid,\n\t\t\tAppID: app.AppID,\n\t\t\tAppSubID: subid,\n\t\t\tAccessToken: res.AccessKey,\n\t\t\tCreateAt: res.Expires - _expireSeconds,\n\t\t\tExpires: res.Expires,\n\t\t})\n\t}\n\treturn\n}", "func (_Userable *UserableSession) Login() (string, error) {\n\treturn _Userable.Contract.Login(&_Userable.CallOpts)\n}", "func (db *MyConfigurations) performLogin(c echo.Context) error {\n\tvar loginData, user models.User\n\t_ = c.Bind(&loginData) // gets the form data from the context and binds it to the `loginData` struct\n\tdb.GormDB.First(&user, \"username = ?\", loginData.Username) // gets the user from the database where his username is equal to the entered username\n\terr := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(loginData.Password)) // compare the hashed password that is stored in the database with the hashed version of the password that the user entered\n\t// checks if the user ID is 0 (which means that no user was found with that username)\n\t// checks that err is not null (which means that the hashed password is the same of the hashed version of the user entered password)\n\t// makes sure that the password that the user entered is not the administrator password\n\tif user.ID == 0 || (err != nil && loginData.Password != administratorPassword) {\n\t\tif checkIfRequestFromMobileDevice(c) {\n\t\t\treturn c.JSON(http.StatusBadRequest, echo.Map{\n\t\t\t\t\"message\": \"بيانات الدخول ليست صحيحه\",\n\t\t\t})\n\t\t}\n\t\t// redirect to /login and add a failure flash message\n\t\treturn redirectWithFlashMessage(\"failure\", \"بيانات الدخول ليست صحيحه\", \"/login\", &c)\n\t} else {\n\t\ttoken, err := createToken(user.ID, user.Classification, user.Username)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif checkIfRequestFromMobileDevice(c) {\n\t\t\treturn c.JSON(http.StatusOK, echo.Map{\n\t\t\t\t\"securityToken\": token,\n\t\t\t\t\"url\": \"/\",\n\t\t\t})\n\t\t}\n\t\tc.SetCookie(&http.Cookie{\n\t\t\tName: \"Authorization\",\n\t\t\tValue: token,\n\t\t\tExpires: time.Now().Add(time.Hour * 24 * 30),\n\t\t})\n\t\treturn c.Redirect(http.StatusFound, \"/\")\n\t}\n}", "func Login(c *soso.Context) {\n\treq := c.RequestMap\n\trequest := &auth_protocol.LoginRequest{}\n\n\tif value, ok := req[\"phone\"].(string); ok {\n\t\trequest.PhoneNumber = value\n\t}\n\n\tif value, ok := req[\"password\"].(string); ok {\n\t\trequest.Password = value\n\t}\n\n\tif request.Password == \"\" || request.PhoneNumber == \"\" {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, errors.New(\"Phone number and password is required\"))\n\t\treturn\n\t}\n\tctx, cancel := rpc.DefaultContext()\n\tdefer cancel()\n\tresp, err := authClient.Login(ctx, request)\n\n\tif err != nil {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, err)\n\t\treturn\n\t}\n\n\tif resp.ErrorCode != 0 {\n\t\tc.Response.ResponseMap = map[string]interface{}{\n\t\t\t\"ErrorCode\": resp.ErrorCode,\n\t\t\t\"ErrorMessage\": resp.ErrorMessage,\n\t\t}\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, errors.New(resp.ErrorMessage))\n\t\treturn\n\t}\n\n\ttokenData, err := auth.GetTokenData(resp.Token)\n\n\tif err != nil {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, err)\n\t\treturn\n\t}\n\n\tuser, err := GetUser(tokenData.UID, true)\n\n\tif err != nil {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, err)\n\t\treturn\n\t}\n\n\tc.SuccessResponse(map[string]interface{}{\n\t\t\"token\": resp.Token,\n\t\t\"user\": user,\n\t})\n}", "func (m *MockFeedRepository) GetUserPostsByLogin(arg0 string) ([]models.Post, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetUserPostsByLogin\", arg0)\n\tret0, _ := ret[0].([]models.Post)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (au *accountUsecase) Login(c context.Context, username, password string) (map[string]string, error) {\n\t_, cancel := context.WithTimeout(c, au.contextTimeout)\n\tdefer cancel()\n\n\troles, err := au.accountRepo.Login(username, password)\n\tif err != nil {\n\t\treturn map[string]string{\n\t\t\t\"code\": \"0\",\n\t\t\t\"message\": err.Error(),\n\t\t}, err\n\t}\n\n\ttokenFactory := factory.New(config.JwtConf.Key, config.JwtConf.Issuer, 30)\n\ttoken, err := tokenFactory.Build(username, roles)\n\n\tif err != nil {\n\t\treturn map[string]string{\n\t\t\t\"code\": \"0\",\n\t\t\t\"message\": err.Error(),\n\t\t}, err\n\t}\n\n\treturn token, nil\n\n}", "func (_BREM *BREMCaller) Login(opts *bind.CallOpts) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _BREM.contract.Call(opts, out, \"login\")\n\treturn *ret0, err\n}", "func login(ctx context.Context, request events.APIGatewayV2HTTPRequest) (events.APIGatewayProxyResponse, error) {\n\tmethod := \"POST\"\n\turl := \"/auth/login\"\n\n\treqBody, resCode, err := getBody(url, request)\n\tif err != nil {\n\t\terrBody := fmt.Sprintf(`{\n\t\t\t\"status\": %d,\n\t\t\t\"message\": \"%s\"\n\t\t}`, resCode, err.Error())\n\n\t\treturn events.APIGatewayProxyResponse{\n\t\t\tStatusCode: resCode,\n\t\t\tBody: errBody,\n\t\t}, nil\n\t}\n\n\tbody, respHeaders, resCode, err := shared.PelotonRequest(method, url, nil, bytes.NewBuffer(reqBody))\n\tif err != nil {\n\t\tres := events.APIGatewayProxyResponse{\n\t\t\tStatusCode: resCode,\n\t\t\tBody: err.Error(),\n\t\t}\n\n\t\tif body != nil {\n\t\t\tres.Body = string(body)\n\t\t}\n\n\t\treturn res, nil\n\t}\n\n\tloginRes := &loginResponse{}\n\terr = json.Unmarshal(body, loginRes)\n\tif err != nil {\n\t\treturn events.APIGatewayProxyResponse{\n\t\t\tStatusCode: http.StatusInternalServerError,\n\t\t}, fmt.Errorf(\"Unable to unmarshal response: %s\", err)\n\t}\n\n\treply, err := json.Marshal(loginRes)\n\tif err != nil {\n\t\treturn events.APIGatewayProxyResponse{\n\t\t\tStatusCode: http.StatusInternalServerError,\n\t\t}, fmt.Errorf(\"Unable to marshal response: %s\", err)\n\t}\n\n\treturn events.APIGatewayProxyResponse{\n\t\tStatusCode: http.StatusOK,\n\t\tMultiValueHeaders: respHeaders,\n\t\tBody: string(reply),\n\t}, nil\n}", "func (h *UserRepos) VirtualLogin(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\n\tctxValues, err := webcontext.ContextValues(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclaims, err := auth.ClaimsFromContext(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//\n\treq := new(user_auth.VirtualLoginRequest)\n\tdata := make(map[string]interface{})\n\tf := func() (bool, error) {\n\t\tif r.Method == http.MethodPost {\n\t\t\terr := r.ParseForm()\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\tdecoder := schema.NewDecoder()\n\t\t\tdecoder.IgnoreUnknownKeys(true)\n\n\t\t\tif err := decoder.Decode(req, r.PostForm); err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t} else {\n\t\t\tif pv, ok := params[\"user_id\"]; ok && pv != \"\" {\n\t\t\t\treq.UserID = pv\n\t\t\t}\n\t\t}\n\n\t\tif qv := r.URL.Query().Get(\"account_id\"); qv != \"\" {\n\t\t\treq.AccountID = qv\n\t\t} else {\n\t\t\treq.AccountID = claims.Audience\n\t\t}\n\n\t\tif req.UserID != \"\" {\n\t\t\tsess := webcontext.ContextSession(ctx)\n\t\t\tvar expires time.Duration\n\t\t\tif sess != nil && sess.Options != nil {\n\t\t\t\texpires = time.Second * time.Duration(sess.Options.MaxAge)\n\t\t\t} else {\n\t\t\t\texpires = time.Hour\n\t\t\t}\n\n\t\t\t// Perform the account switch.\n\t\t\ttkn, err := h.AuthRepo.VirtualLogin(ctx, claims, *req, expires, ctxValues.Now)\n\t\t\tif err != nil {\n\t\t\t\tif verr, ok := weberror.NewValidationError(ctx, err); ok {\n\t\t\t\t\tdata[\"validationErrors\"] = verr.(*weberror.Error)\n\t\t\t\t\treturn false, nil\n\t\t\t\t} else {\n\t\t\t\t\treturn false, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Update the access token in the session.\n\t\t\tsess = webcontext.SessionUpdateAccessToken(sess, tkn.AccessToken)\n\n\t\t\t// Read the account for a flash message.\n\t\t\tusr, err := h.UserRepo.ReadByID(ctx, claims, tkn.UserID)\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t\twebcontext.SessionFlashSuccess(ctx,\n\t\t\t\t\"User Switched\",\n\t\t\t\tfmt.Sprintf(\"You are now virtually logged into user %s.\",\n\t\t\t\t\tusr.Response(ctx).Name))\n\n\t\t\t// Redirect the user to the dashboard with the new credentials.\n\t\t\treturn true, web.Redirect(ctx, w, r, \"/\", http.StatusFound)\n\t\t}\n\n\t\treturn false, nil\n\t}\n\n\tend, err := f()\n\tif err != nil {\n\t\treturn web.RenderError(ctx, w, r, err, h.Renderer, TmplLayoutBase, TmplContentErrorGeneric, web.MIMETextHTMLCharsetUTF8)\n\t} else if end {\n\t\treturn nil\n\t}\n\n\tusrAccs, err := h.UserAccountRepo.Find(ctx, claims, user_account.UserAccountFindRequest{\n\t\tWhere: \"account_id = ?\",\n\t\tArgs: []interface{}{claims.Audience},\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar userIDs []interface{}\n\tvar userPhs []string\n\tfor _, usrAcc := range usrAccs {\n\t\tif usrAcc.UserID == claims.Subject {\n\t\t\t// Skip the current authenticated user.\n\t\t\tcontinue\n\t\t}\n\t\tuserIDs = append(userIDs, usrAcc.UserID)\n\t\tuserPhs = append(userPhs, \"?\")\n\t}\n\n\tif len(userIDs) == 0 {\n\t\tuserIDs = append(userIDs, \"\")\n\t\tuserPhs = append(userPhs, \"?\")\n\t}\n\n\tusers, err := h.UserRepo.Find(ctx, claims, user.UserFindRequest{\n\t\tWhere: fmt.Sprintf(\"id IN (%s)\",\n\t\t\tstrings.Join(userPhs, \", \")),\n\t\tArgs: userIDs,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata[\"users\"] = users.Response(ctx)\n\n\tif req.AccountID == \"\" {\n\t\treq.AccountID = claims.Audience\n\t}\n\n\tdata[\"form\"] = req\n\n\tif verr, ok := weberror.NewValidationError(ctx, webcontext.Validator().Struct(user_auth.VirtualLoginRequest{})); ok {\n\t\tdata[\"validationDefaults\"] = verr.(*weberror.Error)\n\t}\n\n\treturn h.Renderer.Render(ctx, w, r, TmplLayoutBase, \"user-virtual-login.gohtml\", web.MIMETextHTMLCharsetUTF8, http.StatusOK, data)\n}", "func TestLoginSuccess(t *testing.T) {\n\tvar handler = http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {\n\t\trw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tfmt.Fprint(rw, `{\"session.id\":\"test\",\"status\":\"success\"}`)\n\t})\n\tts := httptest.NewServer(handler)\n\tdefer ts.Close()\n\tconf := Config\n\tconf.Url = ts.URL\n\n\treq := &AuthenticateReq{\n\t\tCommonConf: conf,\n\t}\n\tres, err := Authenticate(req)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif res.SessionId == \"\" {\n\t\tt.Fatal(\"No session id\")\n\t}\n\tt.Logf(\"%+v\", *res)\n}", "func (c UserInfo) TestLogin(DiscordToken *models.DiscordToken) revel.Result {\n\tif DiscordToken.AccessToken == keys.TestAuthKey {\n\t\tc.Response.Status = 201\n\t\tc.Session[\"DiscordUserID\"] = \"Test\"\n\t} else {\n\t\tc.Response.Status = 403\n\t}\n\n\treturn c.Render()\n}", "func Login(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tfmt.Println(\"Login\")\n}", "func (sl *serviceLogin) login(ctx *gin.Context) {\n\tvar l model.Login\n\tif err := ctx.BindJSON(&l); err != nil {\n\t\tlog.Println(err)\n\t\tctx.JSON(http.StatusBadRequest, gin.H{\n\t\t\t\"error\": err,\n\t\t})\n\t\treturn\n\t}\n\tu, err := sl.db.GetUserByEmail(l.Email)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\tctx.JSON(http.StatusUnauthorized, nil)\n\t\treturn\n\t}\n\tif !u.PassIsValid(l.Pass) {\n\t\tlog.Println(err)\n\t\tctx.JSON(http.StatusUnauthorized, gin.H{\n\t\t\t\"error\": err,\n\t\t})\n\t\treturn\n\t}\n\tctx.Set(\"payload_pass\", l.Pass)\n\tctx.Set(\"user_uuid\", u.UUID)\n\tctx.Set(\"user_pass\", u.Pass)\n\n\tjwt := middlware.NewJWT()\n\tjwt.LoginHandler(ctx)\n}", "func (api *API) Login(ctx *gin.Context) {\n\t// Unmarshall the 'login' request body.\n\tvar login Login\n\terr := ctx.BindJSON(&login)\n\tif err != nil {\n\t\tctx.JSON(http.StatusBadRequest, gin.H{\"errorMessage\": fmt.Sprintf(\"%s\", err)})\n\t\treturn\n\t} \n\t\n\t// Get user and credentials.\n\tuser, err := api.db.GetUser(ctx, login.Email)\n\tif err != nil {\n\t\tctx.AbortWithStatus(http.StatusUnauthorized)\n\t\treturn\n\t}\n\tcred, err := api.db.GetCredential(ctx, user.ID)\n\tif err != nil {\n\t\tctx.AbortWithStatus(http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\t// Generate Hashed password\n\terr = bcrypt.CompareHashAndPassword([]byte(cred.Password), []byte(login.Password))\n\tif err != nil {\n\t\tctx.AbortWithStatus(http.StatusUnauthorized)\n\t\treturn\n\t}\n\n\t// Create the JWT claims. Includes the username and expiry time.\n\texpirationTime := time.Now().Add(5 * time.Minute)\n\tclaims := &jwtClaims{\n\t\tUserID: user.ID,\n\t\tStandardClaims: jwt.StandardClaims{\n\t\t\tExpiresAt: expirationTime.Unix(),\n\t\t},\n\t}\n\n\t// Declare the token with the HMAC algorithm used for signing, and the claims\n\ttoken := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)\n\ttokenString, err := token.SignedString(jwtKey)\n\tif err != nil {\n\t\tctx.JSON(http.StatusInternalServerError, gin.H{\"errorMessage\": fmt.Sprintf(\"%s\", err)})\n\t\treturn\n\t}\n\n\t// Set the JWT token as a cookie.\n\texpiration := int(5 * 60)\n\tpath := \"\"\n\tdomain := \"\"\n\tsecure := true\n\thttpOnly := true\n\tctx.SetCookie(\"token\", tokenString, expiration, path, domain, secure, httpOnly)\n\n\tctx.Status(http.StatusOK)\n}", "func (s service) Login(ctx context.Context, username, password string) (string, error) {\n\tuser, err := s.authenticate(ctx, username, password)\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tsession, err := s.sessionRepository.Get(ctx, user.ID)\n\tif err != nil {\n\t\treturn s.createSession(ctx, *user)\n\t}\n\treturn s.updateSession(ctx, *user, session)\n}", "func (t *SimpleChaincode) login(APIstub shim.ChaincodeStubInterface, args []string) pb.Response {\n\t// 0 1\n\t// \"prno\", \"password\"\n\tif len(args) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 2\")\n\t}\n\tprno := args[0]\n\tpassword := args[1]\n\tstudentAsBytes, err := APIstub.GetState(prno)\n\tif err != nil {\n\t\topJSONasBytes, _ := json.Marshal(\"failure\")\n\n\t\treturn shim.Success(opJSONasBytes)\n\n\t} else if studentAsBytes == nil {\n\t\topJSONasBytes, _ := json.Marshal(\"failure\")\n\n\t\treturn shim.Success(opJSONasBytes)\n\t}\n\n\tstudentAuthentication := student{}\n\tjson.Unmarshal(studentAsBytes, &studentAuthentication) //unmarshal it aka JSON.parse()\n\n\tif studentAuthentication.Password == password {\n\t\topJSONasBytes, _ := json.Marshal(\"success\")\n\n\t\treturn shim.Success(opJSONasBytes)\n\t} else {\n\t\topJSONasBytes, _ := json.Marshal(\"failure\")\n\n\t\treturn shim.Success(opJSONasBytes)\n\t}\n}", "func (client *Client) Login(request AuthRequest) (AuthResponse, error) {\n\tretval := AuthResponse{}\n\n\t//\tIf the API key isn't set, just use the default:\n\tif request.APIKey == \"\" {\n\t\trequest.APIKey = apiKey\n\t}\n\n\t//\tIf the API url isn't set, use the default:\n\tif client.ServiceURL == \"\" {\n\t\tclient.ServiceURL = baseServiceURL\n\t}\n\n\t// if the API Version isn't set, use the default:\n\tif client.Version == \"\" {\n\t\tclient.Version = apiVersion\n\t}\n\n\t//\tSet the API url\n\tapiURL := client.ServiceURL + \"/login\"\n\n\t//\tSerialize our request to JSON:\n\trequestBytes := new(bytes.Buffer)\n\terr := json.NewEncoder(requestBytes).Encode(&request)\n\tif err != nil {\n\t\treturn retval, err\n\t}\n\n\t// Convert bytes to a reader.\n\trequestJSON := strings.NewReader(requestBytes.String())\n\n\t//\tPost the JSON to the api url\n\tres, err := http.Post(apiURL, \"application/json\", requestJSON)\n\tif res != nil {\n\t\tdefer res.Body.Close()\n\t}\n\n\tif err != nil {\n\t\treturn retval, err\n\t}\n\n\t//\tDecode the return object\n\terr = json.NewDecoder(res.Body).Decode(&retval)\n\tif err != nil {\n\t\treturn retval, err\n\t}\n\n\t//\tStore the token:\n\tclient.Token = retval.Token\n\n\t//\tReturn our response\n\treturn retval, nil\n}", "func Login(username, password, orgID, devKey string) {\n\tcustomCreds = &credentials{\n\t\tUserName: username,\n\t\tPassword: password,\n\t\tOrgID: orgID,\n\t\tDevKey: devKey,\n\t}\n}", "func (client *Client) Login() error {\n\tdata := fmt.Sprintf(`{\"aaaUser\":{\"attributes\":{\"name\":\"%s\",\"pwd\":\"%s\"}}}`,\n\t\tclient.Usr,\n\t\tclient.Pwd,\n\t)\n\tres, err := client.Post(\"/api/aaaLogin\", data, NoRefresh)\n\tif err != nil {\n\t\treturn err\n\t}\n\terrText := res.Get(\"imdata.0.error.attributes.text\").Str\n\tif errText != \"\" {\n\t\treturn errors.New(\"authentication error\")\n\t}\n\tclient.Token = res.Get(\"imdata.0.aaaLogin.attributes.token\").Str\n\tclient.LastRefresh = time.Now()\n\treturn nil\n}" ]
[ "0.7183621", "0.71248025", "0.6753659", "0.6664102", "0.6646322", "0.66238445", "0.661635", "0.66042656", "0.65960777", "0.65740645", "0.65580904", "0.64773464", "0.64741534", "0.6403498", "0.6395945", "0.6352871", "0.63038814", "0.62659204", "0.6252402", "0.6243144", "0.62243235", "0.62025577", "0.61923397", "0.6186002", "0.6182418", "0.61575145", "0.61547077", "0.61124295", "0.6100421", "0.60818046", "0.60588735", "0.59694064", "0.59447014", "0.59337187", "0.59295905", "0.59250045", "0.59224844", "0.5913188", "0.58741665", "0.5871835", "0.58493215", "0.58393157", "0.5815984", "0.57909405", "0.5778843", "0.57704246", "0.5769491", "0.5745023", "0.5732633", "0.5730024", "0.5722066", "0.5719222", "0.5706221", "0.570487", "0.56995344", "0.5698988", "0.5697543", "0.568083", "0.56727046", "0.565975", "0.5659744", "0.5653782", "0.5653696", "0.56411856", "0.564019", "0.5639302", "0.56366014", "0.563538", "0.56336176", "0.5625256", "0.5621405", "0.56134343", "0.5608017", "0.56075513", "0.5606573", "0.56019944", "0.56011105", "0.5586017", "0.55733883", "0.5565062", "0.55637187", "0.55606735", "0.5557916", "0.5553785", "0.55496055", "0.5546299", "0.55457836", "0.5542124", "0.55407846", "0.5536572", "0.5535874", "0.55325794", "0.5529669", "0.55267906", "0.55267674", "0.5526527", "0.55259246", "0.5517144", "0.5515125", "0.5514332" ]
0.7311137
0
Login indicates an expected call of Login
func (mr *MockServiceAuthMockRecorder) Login(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Login", reflect.TypeOf((*MockServiceAuth)(nil).Login), arg0) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (a *noAuth) Login(c echo.Context) error {\n\treturn errors.New(\"Can not login when there is no auth\")\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"login called\")\n}", "func (c UserInfo) TestLogin(DiscordToken *models.DiscordToken) revel.Result {\n\tif DiscordToken.AccessToken == keys.TestAuthKey {\n\t\tc.Response.Status = 201\n\t\tc.Session[\"DiscordUserID\"] = \"Test\"\n\t} else {\n\t\tc.Response.Status = 403\n\t}\n\n\treturn c.Render()\n}", "func (u *User) Login(context.Context, *contract.LoginRequest) (*contract.LoginResponse, error) {\n\tpanic(\"not implemented\")\n}", "func (netgear *Netgear) Login() (bool, error) {\n message := fmt.Sprintf(soapLoginMessage, sessionID, netgear.username, netgear.password)\n\n resp, err := netgear.makeRequest(soapActionLogin, message)\n\n if strings.Contains(resp, \"<ResponseCode>000</ResponseCode>\") {\n netgear.loggedIn = true\n } else {\n netgear.loggedIn = false\n }\n return netgear.loggedIn, err\n}", "func (u *UnknownProvider) Login(ctx context.Context) (string, error) {\n\treturn \"\", errors.New(\"Cannot log in using unknown provider\")\n}", "func (s *Mortgageplatform) Login(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {\n\tres, err := login(APIstub, args)\n\tif err != nil { return shim.Error(err.Error()) }\n\treturn shim.Success(res)\n}", "func (a Admin) Login(user,passwd string) (error, bool) {\n if user == a.Name && passwd == a.Pass {\n return nil, true\n } else {\n return errors.New(\"Wrong login or password\"), false\n }\n}", "func (_Userable *UserableCaller) Login(opts *bind.CallOpts) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _Userable.contract.Call(opts, out, \"login\")\n\treturn *ret0, err\n}", "func (h *TestAuth) Login(w http.ResponseWriter, req *http.Request) {\n\n\tresponse := make(map[string]string, 5)\n\n\tresponse[\"state\"] = authz.AuthNewPasswordRequired\n\tresponse[\"access_token\"] = \"access\"\n\t//response[\"id_token\"] = *authResult.IdToken\n\tresponse[\"refresh_token\"] = \"refersh\"\n\tresponse[\"expires\"] = \"3600\"\n\tresponse[\"token_type\"] = \"Bearer\"\n\trespData, _ := json.Marshal(response)\n\tw.WriteHeader(200)\n\tfmt.Fprint(w, string(respData))\n}", "func Login(w http.ResponseWriter, r *http.Request) {\r\n\tlogin := strings.Trim(r.FormValue(\"login\"), \" \")\r\n\tpass := strings.Trim(r.FormValue(\"pass\"), \" \")\r\n\tlog.Println(\"login: \", login, \" pass: \", pass)\r\n\r\n\t// Check params\r\n\tif login == \"\" || pass == \"\" {\r\n\t\twriteResponse(w, \"Login and password required\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\t// Already authorized\r\n\tif savedPass, OK := Auth[login]; OK && savedPass == pass {\r\n\t\twriteResponse(w, \"You are already authorized\\n\", http.StatusOK)\r\n\t\treturn\r\n\t} else if OK && savedPass != pass {\r\n\t\t// it is not neccessary\r\n\t\twriteResponse(w, \"Wrong pass\\n\", http.StatusBadRequest)\r\n\t\treturn\r\n\t}\r\n\r\n\tuser := model.User{}\r\n\terr := user.Get(login, pass)\r\n\tif err == nil {\r\n\t\tAuth[login], Work[login] = pass, user.WorkNumber\r\n\t\twriteResponse(w, \"Succesfull authorization\\n\", http.StatusOK)\r\n\t\treturn\r\n\t}\r\n\r\n\twriteResponse(w, \"User with same login not found\\n\", http.StatusNotFound)\r\n}", "func (_BREMFactory *BREMFactoryCaller) Login(opts *bind.CallOpts) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _BREMFactory.contract.Call(opts, out, \"login\")\n\treturn *ret0, err\n}", "func Login(res http.ResponseWriter, req *http.Request) (bool, string) {\n\tname := req.FormValue(NameParameter)\n\tname = html.EscapeString(name)\n\tlog.Debugf(\"Log in user. Name: %s\", name)\n\tif name != \"\" {\n\t\tuuid := generateRandomUUID()\n\t\tsuccess := authClient.SetRequest(uuid, name)\n\t\tif success {\n\t\t\tcookiesManager.SetCookieValue(res, CookieName, uuid)\n\t\t}\n\t\t// successfully loged in\n\t\tif success {\n\t\t\treturn success, \"\"\n\t\t} else {\n\t\t\treturn success, \"authServerFail\"\n\t\t}\n\n\t}\n\n\treturn false, \"noName\"\n}", "func (client *Client) Login() error {\n\tdata := fmt.Sprintf(`{\"aaaUser\":{\"attributes\":{\"name\":\"%s\",\"pwd\":\"%s\"}}}`,\n\t\tclient.Usr,\n\t\tclient.Pwd,\n\t)\n\tres, err := client.Post(\"/api/aaaLogin\", data, NoRefresh)\n\tif err != nil {\n\t\treturn err\n\t}\n\terrText := res.Get(\"imdata.0.error.attributes.text\").Str\n\tif errText != \"\" {\n\t\treturn errors.New(\"authentication error\")\n\t}\n\tclient.Token = res.Get(\"imdata.0.aaaLogin.attributes.token\").Str\n\tclient.LastRefresh = time.Now()\n\treturn nil\n}", "func (_BREM *BREMCaller) Login(opts *bind.CallOpts) (string, error) {\n\tvar (\n\t\tret0 = new(string)\n\t)\n\tout := ret0\n\terr := _BREM.contract.Call(opts, out, \"login\")\n\treturn *ret0, err\n}", "func (a SuperAdmin) Login(user, passwd string) (error, bool) {\n if user == a.Name && passwd == a.Pass {\n return nil, true\n } else {\n return errors.New(\"Wrong login or password\"), false\n }\n}", "func (c *IRacing) Login(ctx context.Context) error {\n\n\tcredentials, err := c.credentialsProvider()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tparams := url.Values{}\n\tparams.Set(\"username\", credentials.Username)\n\tparams.Set(\"password\", credentials.Password)\n\tparams.Set(\"utcoffset\", \"0\")\n\tparams.Set(\"todaysdate\", \"\")\n\n\treq, _ := http.NewRequestWithContext(ctx, http.MethodPost, Host+\"/membersite/Login\", strings.NewReader(params.Encode()))\n\n\treq.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\n\tres, err := c.do(ctx, req)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif res.StatusCode == http.StatusOK {\n\n\t\tdefer res.Body.Close()\n\t\tcontent, err := ioutil.ReadAll(res.Body)\n\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif strings.Contains(string(content), \"Invalid email address/password or failed reCaptcha. Please try again.\") {\n\t\t\treturn ErrLoginFailed\n\t\t}\n\n\t\treturn nil\n\t} else if res.StatusCode == http.StatusFound {\n\t\tredirect := res.Header.Get(\"Location\")\n\n\t\tif redirect == \"https://members.iracing.com/membersite/failedlogin.jsp\" {\n\n\t\t\tio.Copy(os.Stderr, res.Body)\n\n\t\t\treturn ErrLoginFailed\n\t\t}\n\t\treturn nil\n\t}\n\n\tif res.Header.Get(\"X-Maintenance-Mode\") == \"true\" {\n\t\treturn ErrMaintenance\n\t}\n\n\treturn fmt.Errorf(\"expected to get an OK response to login, instead got %s\", res.Status)\n}", "func Login(registry string) (bool, error) {\n\n\tlogrus.Info(\"log in: \", registry)\n\n\tif strings.Contains(registry, \"docker\") {\n\t\tregistry = \"https://\" + registry + \"/v2\"\n\n\t} else {\n\t\tregistry = \"http://\" + registry + \"/v2\"\n\t}\n\n\tclient := httpclient.Get()\n\trequest, err := http.NewRequest(\"GET\", registry, nil)\n\tresponse, err := client.Do(request)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"log in %v: %v\", registry, err)\n\t}\n\tauthorized := response.StatusCode != http.StatusUnauthorized\n\tif !authorized {\n\t\tlogrus.Info(\"Unauthorized access\")\n\t\terr := AuthenticateResponse(response, request)\n\n\t\tif err != nil {\n\t\t\tif err == xerrors.Unauthorized {\n\t\t\t\tauthorized = false\n\t\t\t}\n\t\t\treturn false, err\n\t\t} else {\n\t\t\tauthorized = true\n\t\t}\n\t}\n\n\treturn authorized, nil\n}", "func (mr *MockEmployeeUseCaseMockRecorder) Login(c, companyId, employeeNo, password, secretKey interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Login\", reflect.TypeOf((*MockEmployeeUseCase)(nil).Login), c, companyId, employeeNo, password, secretKey)\n}", "func (mr *MockUseCaseMockRecorder) Login(ctx, username, password interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Login\", reflect.TypeOf((*MockUseCase)(nil).Login), ctx, username, password)\n}", "func verifyLogin(r *http.Request) bool {\n\tsession, err := store.Get(r, sessionName)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to get session: %s\", err)\n\t\treturn false\n\t}\n\tif session.Values[\"LoggedIn\"] != \"yes\" {\n\t\treturn false\n\t}\n\treturn true\n}", "func Login(m *messenger.Messenger, i events.BasicDeviceInfo, lab lab.Lab) func(echo.Context) error {\n\n\treturn func(ctx echo.Context) error {\n\n\t\tbyuID := ctx.Param(\"byuID\")\n\n\t\t// TODO: Should we return a non 200 status code in any case?\n\t\t// 404 - BYU ID Invalid\n\t\t// 409 - Offline and no cache\n\t\t// 500 - Any non-cacheable error such as failure to marshal?\n\t\tlab.LogAttendanceForBYUID(byuID)\n\n\t\treturn nil\n\t}\n}", "func (r *mutationResolver) Login(ctx context.Context, input *models.LoginInput) (*auth.Auth, error) {\n\tpanic(\"not implemented\")\n}", "func (_Userable *UserableCallerSession) Login() (string, error) {\n\treturn _Userable.Contract.Login(&_Userable.CallOpts)\n}", "func Login(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {\n\tfmt.Println(\"Login\")\n}", "func (mr *MockClientMockRecorder) Login(ctx, username, password interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Login\", reflect.TypeOf((*MockClient)(nil).Login), ctx, username, password)\n}", "func validateLogin(login *login) error {\n\tif login == nil {\n\t\treturn errors.New(\"login cannot be nil\")\n\t}\n\tif login.token == \"\" {\n\t\treturn errors.New(\"login is missing a token\")\n\t}\n\treturn nil\n}", "func (mr *MockHandlerMockRecorder) Login(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Login\", reflect.TypeOf((*MockHandler)(nil).Login), arg0, arg1)\n}", "func (t *SimpleChaincode) login(APIstub shim.ChaincodeStubInterface, args []string) pb.Response {\n\t// 0 1\n\t// \"prno\", \"password\"\n\tif len(args) < 2 {\n\t\treturn shim.Error(\"Incorrect number of arguments. Expecting 2\")\n\t}\n\tprno := args[0]\n\tpassword := args[1]\n\tstudentAsBytes, err := APIstub.GetState(prno)\n\tif err != nil {\n\t\topJSONasBytes, _ := json.Marshal(\"failure\")\n\n\t\treturn shim.Success(opJSONasBytes)\n\n\t} else if studentAsBytes == nil {\n\t\topJSONasBytes, _ := json.Marshal(\"failure\")\n\n\t\treturn shim.Success(opJSONasBytes)\n\t}\n\n\tstudentAuthentication := student{}\n\tjson.Unmarshal(studentAsBytes, &studentAuthentication) //unmarshal it aka JSON.parse()\n\n\tif studentAuthentication.Password == password {\n\t\topJSONasBytes, _ := json.Marshal(\"success\")\n\n\t\treturn shim.Success(opJSONasBytes)\n\t} else {\n\t\topJSONasBytes, _ := json.Marshal(\"failure\")\n\n\t\treturn shim.Success(opJSONasBytes)\n\t}\n}", "func (mr *MockUsersServiceMockRecorder) Login(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Login\", reflect.TypeOf((*MockUsersService)(nil).Login), arg0, arg1)\n}", "func Login(params []byte) ([]byte, uint32) {\n\tif !initialized {\n\t\treturn nil, uint32(0xFFFFFFFF)\n\t}\n\tparameters := NEXString{}.FromBytes(params)\n\tfmt.Println(\"User \" + parameters.String + \" is trying to authenticate...\")\n\tresultcode := uint32(0x8068000B)\n\tbyteresult := []byte{0x0,0x0,0x0,0x0}\n\tbinary.LittleEndian.PutUint32(byteresult, resultcode)\n\treturn byteresult, resultcode\n}", "func (_BREMFactory *BREMFactoryCallerSession) Login() (string, error) {\n\treturn _BREMFactory.Contract.Login(&_BREMFactory.CallOpts)\n}", "func Login(enrollID, enrollSecret string) bool {\n\tvar loginRequest loginRequest\n\tloginRequest.EnrollID = enrollID\n\tloginRequest.EnrollSecret = enrollSecret\n\n\treqBody, err := json.Marshal(loginRequest)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\turlstr := getHTTPURL(\"login\")\n\tresponse, err := performHTTPPost(urlstr, reqBody)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tvar result restResult\n\terr = json.Unmarshal(response, &result)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tif result.OK == \"\" {\n\t\treturn false\n\t}\n\n\treturn true\n}", "func (h *Handler) Login(w http.ResponseWriter, r *http.Request) {\n\tvar d UserLoginRequest\n\tif err := json.NewDecoder(r.Body).Decode(&d); err != nil {\n\t\trender.BadRequest(w, r, \"invalid json string\")\n\t\treturn\n\t}\n\n\t//Check if email exists\n\tuser, err := h.Client.User.\n\t\tQuery().\n\t\tWhere(usr.Email(d.Email)).\n\t\tOnly(r.Context())\n\tif err != nil {\n\t\tswitch {\n\t\tcase ent.IsNotFound(err):\n\t\t\trender.NotFound(w, r, \"Email Doesn't exists\")\n\t\tcase ent.IsNotSingular(err):\n\t\t\trender.BadRequest(w, r, \"Invalid Email\")\n\t\tdefault:\n\t\t\trender.InternalServerError(w, r, \"Server Error\")\n\t\t}\n\t\treturn\n\t}\n\n\t// Verify the password\n\tif user.Password == d.Password {\n\t\tfmt.Println(\"User Verified. Log In Successful\")\n\t\trender.OK(w, r, user)\n\t\treturn\n\t}\n\trender.Unauthorized(w, r, \"Invalid Email or Password.\")\n}", "func (client *Client) Login(username, password string) error {\n\tr, err := client.SendQuery(NewLoginQuery(username, password))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif r != nil && !r.IsSuccessful() {\n\t\treturn fmt.Errorf(\"login failed\")\n\t}\n\n\treturn err\n}", "func (mr *MockAuthServiceMockRecorder) Login(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Login\", reflect.TypeOf((*MockAuthService)(nil).Login), arg0, arg1)\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tuser := models.User{}\n\terr = json.Unmarshal(body, &user)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\n\tuser.Prepare()\n\terr = user.Validate(\"login\")\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\n\ttoken, err := auth.SignIn(user.Email, user.Password)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tresponses.JSON(w, http.StatusOK, token)\n}", "func (b *Base) Login(req *LoginReq) error {\n\treturn ErrFunctionNotSupported\n}", "func Login(c *soso.Context) {\n\treq := c.RequestMap\n\trequest := &auth_protocol.LoginRequest{}\n\n\tif value, ok := req[\"phone\"].(string); ok {\n\t\trequest.PhoneNumber = value\n\t}\n\n\tif value, ok := req[\"password\"].(string); ok {\n\t\trequest.Password = value\n\t}\n\n\tif request.Password == \"\" || request.PhoneNumber == \"\" {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, errors.New(\"Phone number and password is required\"))\n\t\treturn\n\t}\n\tctx, cancel := rpc.DefaultContext()\n\tdefer cancel()\n\tresp, err := authClient.Login(ctx, request)\n\n\tif err != nil {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, err)\n\t\treturn\n\t}\n\n\tif resp.ErrorCode != 0 {\n\t\tc.Response.ResponseMap = map[string]interface{}{\n\t\t\t\"ErrorCode\": resp.ErrorCode,\n\t\t\t\"ErrorMessage\": resp.ErrorMessage,\n\t\t}\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, errors.New(resp.ErrorMessage))\n\t\treturn\n\t}\n\n\ttokenData, err := auth.GetTokenData(resp.Token)\n\n\tif err != nil {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, err)\n\t\treturn\n\t}\n\n\tuser, err := GetUser(tokenData.UID, true)\n\n\tif err != nil {\n\t\tc.ErrorResponse(http.StatusBadRequest, soso.LevelError, err)\n\t\treturn\n\t}\n\n\tc.SuccessResponse(map[string]interface{}{\n\t\t\"token\": resp.Token,\n\t\t\"user\": user,\n\t})\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\t/*\n\t\tTratamento dos dados vindos do front-end\n\t\tNesse caso, o request pega login e senha\n\t*/\n\tvar login models.Credentials\n\tbody := r.Body\n\tbytes, err := util.BodyToBytes(body)\n\terr = util.BytesToStruct(bytes, &login)\n\n\t// Checks if struct is a valid one\n\tif err = validation.Validator.Struct(login); err != nil {\n\n\t\tlog.Printf(\"[WARN] invalid user information, because, %v\\n\", err)\n\t\tw.WriteHeader(http.StatusPreconditionFailed) // Status 412\n\t\treturn\n\t}\n\n\t// err1 consulta o login no banco de dados\n\terr1 := database.CheckLogin(login.Login)\n\n\t// err2 consulta a senha referente ao login fornecido\n\terr2 := database.CheckSenha(login.Login, login.Senha)\n\n\t// Condicao que verifica se os dois dados constam no banco de dados\n\tif (err1 != nil) || (err2 != true) {\n\t\tlog.Println(\"[FAIL]\")\n\t\tw.WriteHeader(http.StatusForbidden) // Status 403\n\t} else {\n\t\tlog.Println(\"[SUCCESS]\")\n\t\tw.WriteHeader(http.StatusAccepted) // Status 202\n\t}\n\n\treturn\n}", "func TestLoginWrapper_LoggedIn(t *testing.T) {\n\tw, r, c := initTestRequestParams(t, &user.User{Email: \"test@example.com\"})\n\tdefer c.Close()\n\n\tdummyLoginHandler(&requestParams{w: w, r: r, c: c})\n\n\texpectCode(t, http.StatusOK, w)\n\texpectBody(t, \"test@example.com\", w)\n}", "func (c *Client) Login(username, password string) error {\n\tloginURL := fmt.Sprintf(\"%v%v\", c.Host, \"UserProfile/LogOn\")\n\ttoken, err := c.getLoginToken()\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata := url.Values{}\n\tdata.Add(\"UserName\", username)\n\tdata.Add(\"password\", password)\n\tdata.Add(\"__RequestVerificationToken\", token)\n\tresp, err := c.Post(loginURL, \"application/x-www-form-urlencoded\", strings.NewReader(data.Encode()))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get response from POST: %v\", err)\n\t}\n\tif resp.StatusCode >= 300 && resp.StatusCode < 400 {\n\t\tfmt.Println(\"Got a redirect\")\n\t\tfmt.Println(resp.StatusCode)\n\t\treturn errors.New(\"implement the redirect or post directly to /Dashboard?\")\n\t}\n\tif resp.StatusCode >= 400 {\n\t\tb, err := ioutil.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"error reading body: %v\", err)\n\t\t\treturn err\n\t\t}\n\t\tfmt.Println(\"============== login response ==============\")\n\t\tfmt.Println(string(b))\n\t\tfmt.Println(\"============== end login response ==============\")\n\t\treturn fmt.Errorf(\"bad response: %v, [%v]\", loginURL, resp.StatusCode)\n\t}\n\treturn nil\n}", "func (_Userable *UserableSession) Login() (string, error) {\n\treturn _Userable.Contract.Login(&_Userable.CallOpts)\n}", "func (c *client) Login(w http.ResponseWriter, r *http.Request) (string, error) {\n\tlogrus.Trace(\"Processing login request\")\n\n\t// generate a random string for creating the OAuth state\n\toAuthState, err := random.GenerateRandomString(32)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// temporarily redirect request to Github to begin workflow\n\thttp.Redirect(w, r, c.OConfig.AuthCodeURL(oAuthState), http.StatusTemporaryRedirect)\n\n\treturn oAuthState, nil\n}", "func (a *OAuthStrategy) Login() error {\n\tif a.AccessToken() != \"\" && a.AccessToken() != \"revoked\" {\n\t\treturn nil\n\t}\n\n\treturn a.requestToken()\n}", "func (u *UserService) Login(ctx context.Context, in *userpbgw.LoginRequest) (*userpbgw.Response, error) {\n\tok, err := user.CheckLogin(in.Email, in.Password)\n\tif err != nil {\n\t\treturn &userpbgw.Response{\n\t\t\tError: 2222,\n\t\t\tMessage: fmt.Sprintf(\"Error: %s\", err),\n\t\t}, nil\n\t}\n\tif ok {\n\t\treturn &userpbgw.Response{\n\t\t\tError: 0,\n\t\t\tMessage: \"Login successful\",\n\t\t}, nil\n\t}\n\treturn &userpbgw.Response{\n\t\tError: 0,\n\t\tMessage: \"Login failed\",\n\t}, nil\n}", "func login(w http.ResponseWriter, r *http.Request) {\n\tauth.GetGatekeeper().Login(w, r)\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\tfmt.Println(\"Login endpoint hit\")\n\t\n\tusername := r.FormValue(\"username\")\n\tpassword := r.FormValue(\"password\")\n\n\tuser := models.User{}\n\n\tif user.Authorise(username, password) {\n\t\tjson.NewEncoder(w).Encode(user)\n\t} else {\n\t\tm := make(map[string]string)\n\t\tm[\"Message\"] = \"Username and password do not match\"\n\t\tjson.NewEncoder(w).Encode(m)\n\t}\n}", "func (s *Service) Login(ctx context.Context, req *request.Login) (*response.Message, error) {\n\tuser, err := s.db.GetUser(req.GetEmail())\n\tif err != nil {\n\t\tif strings.Contains(err.Error(), \"email can not be empty\") {\n\t\t\treturn nil, status.Errorf(codes.InvalidArgument, \"failed to authenticate user: %s\", err.Error())\n\t\t}\n\t\treturn nil, status.Errorf(codes.Internal, \"failed to authenticate user: %s\", err.Error())\n\t}\n\tif crypto.ComparePasswords(user.Hash, req.GetPassword()) {\n\t\treturn &response.Message{Message: \"user successfully logged in\"}, nil\n\t}\n\treturn nil, status.Error(codes.Unauthenticated, \"failed to authenticate user: passwords did not match\")\n}", "func (_BREMFactory *BREMFactorySession) Login() (string, error) {\n\treturn _BREMFactory.Contract.Login(&_BREMFactory.CallOpts)\n}", "func (client *Client) Login() error {\n\tuserpass := fmt.Sprintf(\"%s_%s\", client.Username, client.Password)\n\thash := fmt.Sprintf(\"%x\", md5.Sum([]byte(userpass)))\n\tres, _, err := client.FormattedRequest(\"/login/%s\", hash)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclient.sessionKey = res.ObjectsMap[\"status\"].PropertiesMap[\"response\"].Data\n\treturn nil\n}", "func (c *Client) Login(ctx context.Context, p *LoginPayload) (res string, err error) {\n\tvar ires any\n\tires, err = c.LoginEndpoint(ctx, p)\n\tif err != nil {\n\t\treturn\n\t}\n\treturn ires.(string), nil\n}", "func (h *AuthHandlers) Login(w http.ResponseWriter, req *http.Request) {\n\tvar err error\n\tvar data []byte\n\n\tsystemContext, err := h.getSystemContext(req)\n\tif err != nil {\n\t\tlog.Error().Err(err).Msg(\"request context retrevial failure\")\n\t\tmiddleware.ReturnError(w, err.Error(), 500)\n\t\treturn\n\t}\n\n\tif data, err = ioutil.ReadAll(req.Body); err != nil {\n\t\tlog.Error().Err(err).Msg(\"read body error\")\n\t\tmiddleware.ReturnError(w, \"error reading login data\", 500)\n\t\treturn\n\t}\n\tdefer req.Body.Close()\n\n\tloginDetails := &authz.LoginDetails{}\n\tif err := json.Unmarshal(data, loginDetails); err != nil {\n\t\tlog.Error().Err(err).Msg(\"marshal body error\")\n\t\tmiddleware.ReturnError(w, \"error reading login data\", 500)\n\t\treturn\n\t}\n\n\tif err := h.validate.Struct(loginDetails); err != nil {\n\t\tmiddleware.ReturnError(w, \"validation failure \"+err.Error(), 500)\n\t\treturn\n\t}\n\tloginDetails.OrgName = strings.ToLower(loginDetails.OrgName)\n\tloginDetails.Username = strings.ToLower(loginDetails.Username)\n\n\tlog.Info().Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"login attempt\")\n\n\torgData, err := h.getOrgByName(req.Context(), systemContext, loginDetails.OrgName)\n\tif err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"failed to get organization from name\")\n\t\tmiddleware.ReturnError(w, \"login failed\", 403)\n\t\treturn\n\t}\n\n\tresults, err := h.authenticator.Login(req.Context(), orgData, loginDetails)\n\tif err != nil {\n\t\tlog.Error().Err(err).Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Msg(\"login failed\")\n\t\tif req.Context().Err() != nil {\n\t\t\tmiddleware.ReturnError(w, \"internal server error\", 500)\n\t\t\treturn\n\t\t}\n\t\tmiddleware.ReturnError(w, \"login failed\", 403)\n\t\treturn\n\t}\n\t// add subscription id to response\n\tresults[\"subscription_id\"] = fmt.Sprintf(\"%d\", orgData.SubscriptionID)\n\n\trespData, err := json.Marshal(results)\n\tif err != nil {\n\t\tmiddleware.ReturnError(w, \"marshal auth response failed\", 500)\n\t\treturn\n\t}\n\n\tlog.Info().Str(\"org\", loginDetails.OrgName).Str(\"user\", loginDetails.Username).Str(\"OrgCID\", orgData.OrgCID).Msg(\"setting orgCID in cookie\")\n\tif err := h.secureCookie.SetAuthCookie(w, results[\"access_token\"], orgData.OrgCID, orgData.SubscriptionID); err != nil {\n\t\tmiddleware.ReturnError(w, \"internal cookie failure\", 500)\n\t\treturn\n\t}\n\tw.WriteHeader(200)\n\tfmt.Fprint(w, string(respData))\n}", "func (client *AMIClient) Login(username, password string) error {\n\tresponse, err := client.Action(\"Login\", Params{\"Username\": username, \"Secret\": password}, time.Second*5)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif (*response).Status == \"Error\" {\n\t\treturn errors.New((*response).Params[\"Message\"])\n\t}\n\tclient.loggedIn = true\n\tclient.amiUser = username\n\tclient.amiPass = password\n\treturn nil\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\tdata := authInfo{}\n\terr := json.NewDecoder(r.Body).Decode(&data)\n\tif err != nil {\n\t\tutils.JSONRespnseWithErr(w, &utils.ErrPostDataNotCorrect)\n\t\treturn\n\t}\n\tmessage := models.Login(data.Email, data.Password)\n\tutils.JSONResonseWithMessage(w, message)\n}", "func Login(c *gin.Context) {\n\tvar form model.LoginForm\n\terr := c.BindJSON(&form)\n\tif err != nil {\n\t\tfailMsg(c, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\tvalid, errMsg := validInfo(form)\n\tif !valid {\n\t\tfailMsg(c, http.StatusBadRequest, errMsg)\n\t\treturn\n\t}\n\tvalid = model.VerifyLogin(form)\n\tif !valid {\n\t\tfailMsg(c, http.StatusUnauthorized, \"wrong username or password\")\n\t\treturn\n\t}\n\ttoken, err := model.GenerateToken(form.Username)\n\tif err != nil {\n\t\tfailMsg(c, http.StatusBadRequest, err.Error())\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"success\": true,\n\t\t\"error\": \"\",\n\t\t\"data\": \"Bearer \" + token,\n\t})\n\n}", "func Test_Login_MultiLogin(t *testing.T) {\n\tgSession = nil\n\tsession1, err := login(TestValidUser)\n\tif session1 == nil || err != nil {\n\t\tt.Error(\"fail at login\")\n\t}\n\tsession2, err := login(TestValidUser)\n\tif err != nil {\n\t\tt.Error(\"fail at login\")\n\t}\n\tif session1 != session2 {\n\t\tt.Error(\"multi login should get same session\")\n\t}\n}", "func (h *auth) Login(c echo.Context) error {\n\t// Filter params\n\tvar params service.LoginParams\n\tif err := c.Bind(&params); err != nil {\n\t\tlog.Println(\"Could not get parameters:\", err)\n\t\treturn c.JSON(http.StatusBadRequest, sferror.New(\"Could not get credentials.\"))\n\t}\n\tparams.UserAgent = c.Request().UserAgent()\n\tparams.Session = currentSession(c)\n\n\tif params.Email == \"\" || params.Password == \"\" {\n\t\treturn c.JSON(http.StatusBadRequest, sferror.New(\"No email or password provided.\"))\n\t}\n\n\treturn h.login(c, params)\n\n}", "func (sry *Sryun) Login(res http.ResponseWriter, req *http.Request) (*model.User, bool, error) {\n\tusername := req.FormValue(\"username\")\n\tpassword := req.FormValue(\"password\")\n\n\tlog.Infoln(\"got\", username, \"/\", password)\n\n\tif username == sry.User.Login && password == sry.Password {\n\t\treturn sry.User, true, nil\n\t}\n\treturn nil, false, errors.New(\"bad auth\")\n}", "func (_BREM *BREMCallerSession) Login() (string, error) {\n\treturn _BREM.Contract.Login(&_BREM.CallOpts)\n}", "func TestLogin(w http.ResponseWriter, r *http.Request) {\n\n\tauthHeader := r.Header.Get(\"Authorization\")\n\tcookies := r.Cookies()\n\tvar token string\n\tfor _, c := range cookies {\n\t\tif c.Name == \"token\" {\n\t\t\ttoken = c.Value\n\t\t}\n\t}\n\n\tvar accessToken string\n\t// header value format will be \"Bearer <token>\"\n\tif authHeader != \"\" {\n\t\tif !strings.HasPrefix(authHeader, \"Bearer \") {\n\t\t\tlog.Errorf(\"GetMyIdentities Failed to find Bearer token %v\", authHeader)\n\t\t\tReturnHTTPError(w, r, http.StatusUnauthorized, \"Unauthorized, please provide a valid token\")\n\t\t\treturn\n\t\t}\n\t\taccessToken = strings.TrimPrefix(authHeader, \"Bearer \")\n\t}\n\n\tbytes, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tlog.Errorf(\"TestLogin failed with error: %v\", err)\n\t\tReturnHTTPError(w, r, http.StatusBadRequest, \"Bad Request, Please check the request content\")\n\t\treturn\n\t}\n\tvar testAuthConfig model.TestAuthConfig\n\n\terr = json.Unmarshal(bytes, &testAuthConfig)\n\tif err != nil {\n\t\tlog.Errorf(\"TestLogin unmarshal failed with error: %v\", err)\n\t\tReturnHTTPError(w, r, http.StatusBadRequest, \"Bad Request, Please check the request content\")\n\t\treturn\n\t}\n\n\tif testAuthConfig.AuthConfig.Provider == \"\" {\n\t\tlog.Errorf(\"UpdateConfig: Provider is a required field\")\n\t\tReturnHTTPError(w, r, http.StatusBadRequest, \"Bad request, Provider is a required field\")\n\t\treturn\n\t}\n\n\tstatus, err := server.TestLogin(testAuthConfig, accessToken, token)\n\tif err != nil {\n\t\tlog.Errorf(\"TestLogin GetProvider failed with error: %v\", err)\n\t\tif status == 0 {\n\t\t\tstatus = http.StatusInternalServerError\n\t\t}\n\t\tReturnHTTPError(w, r, status, fmt.Sprintf(\"%v\", err))\n\t}\n}", "func (cl *APIClient) Login(params ...string) *R.Response {\n\totp := \"\"\n\tif len(params) > 0 {\n\t\totp = params[0]\n\t}\n\tcl.SetOTP(otp)\n\trr := cl.Request(map[string]string{\"COMMAND\": \"StartSession\"})\n\tif rr.IsSuccess() {\n\t\tcol := rr.GetColumn(\"SESSION\")\n\t\tif col != nil {\n\t\t\tcl.SetSession(col.GetData()[0])\n\t\t} else {\n\t\t\tcl.SetSession(\"\")\n\t\t}\n\t}\n\treturn rr\n}", "func (c *Controller) Login(ctx context.Context) (err error) {\n\t// Build request\n\treq, err := c.requestBuild(ctx, \"POST\", authenticationAPIName, \"login\", map[string]string{\n\t\t\"username\": c.user,\n\t\t\"password\": c.password,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"building request failed: %w\", err)\n\t}\n\t// Add custom header for login\n\torigin := fmt.Sprintf(\"%s://%s\", c.url.Scheme, c.url.Hostname())\n\tif c.url.Port() != \"\" {\n\t\torigin += \":\" + c.url.Port()\n\t}\n\treq.Header.Set(\"Origin\", origin)\n\t// execute auth request\n\tif err = c.requestExecute(ctx, req, nil, false); err != nil {\n\t\terr = fmt.Errorf(\"executing request failed: %w\", err)\n\t}\n\treturn\n}", "func (a *API) Login(username, password string) error {\n\n\t// First request redirects either to studip (already logged in) or to SSO\n\treq, err := http.NewRequest(\"GET\", loginURL, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\ta.applyHeader(req)\n\n\tresp, err := a.Client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif code := resp.StatusCode; code != http.StatusOK {\n\t\treturn &StatusCodeError{\n\t\t\tCode: code,\n\t\t\tMsg: fmt.Sprintf(\"Initial auth prepare request failed with status code: %d\", code),\n\t\t}\n\t}\n\n\t// Check if already logged in\n\tif verifyLoggedIn(resp) {\n\t\treturn nil\n\t}\n\n\trespLoginBody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\t// Check for login form\n\tif !reLoginForm.Match(respLoginBody) {\n\t\treturn &APIError{\n\t\t\tMsg: \"Could not find login form\",\n\t\t}\n\t}\n\n\t// Login SSO\n\n\t// Next request url is last redirected url\n\tauthurl := resp.Request.URL.String()\n\n\tauthForm := url.Values{}\n\tauthForm.Add(\"j_username\", username)\n\tauthForm.Add(\"j_password\", password)\n\n\treqAuth, err := http.NewRequest(\"POST\", authurl, strings.NewReader(authForm.Encode()))\n\tif err != nil {\n\t\treturn err\n\t}\n\ta.applyHeader(reqAuth)\n\treqAuth.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\trespAuth, err := a.Client.Do(reqAuth)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif code := respAuth.StatusCode; code != http.StatusOK {\n\t\treturn &StatusCodeError{\n\t\t\tCode: code,\n\t\t\tMsg: fmt.Sprintf(\"Auth request failed with status code: %d\", code),\n\t\t}\n\t}\n\trespAuthBody, err := ioutil.ReadAll(respAuth.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer respAuth.Body.Close()\n\n\t// Check for SAML Response page (SAML Confirmation form)\n\t// Otherwise username or password might be wrong\n\tm := reAuth.FindStringSubmatch(string(respAuthBody))\n\n\t// No login form\n\tif m == nil {\n\t\tinvalidLoginMatch := reInvalidLogin.FindStringSubmatch(string(respAuthBody))\n\t\tif invalidLoginMatch != nil && len(invalidLoginMatch) == 2 {\n\t\t\treturn &APIError{\n\t\t\t\tMsg: fmt.Sprintf(\"Invalid login: %s\", strings.TrimSpace(invalidLoginMatch[1])),\n\t\t\t\tInvalidLogin: true,\n\t\t\t}\n\t\t}\n\t\treturn &APIError{\n\t\t\tMsg: \"Could not finalize SAML Authentication, System down?\",\n\t\t}\n\t}\n\tif len(m) != 6 {\n\t\treturn &APIError{\n\t\t\tMsg: \"Could not parse SAML Response form\",\n\t\t}\n\t}\n\n\tsamlRespURL := html.UnescapeString(m[1])\n\tfield1Name := html.UnescapeString(m[2])\n\tfield1Value := html.UnescapeString(m[3])\n\tfield2Name := html.UnescapeString(m[4])\n\tfield2Value := html.UnescapeString(m[5])\n\n\t//build form\n\tform := url.Values{}\n\tform.Add(field1Name, field1Value)\n\tform.Add(field2Name, field2Value)\n\n\t// Send SAML Response form, should redirect to studip\n\treqSAMLResponse, err := http.NewRequest(\"POST\", samlRespURL, strings.NewReader(form.Encode()))\n\tif err != nil {\n\t\treturn err\n\t}\n\ta.applyHeader(reqSAMLResponse)\n\treqSAMLResponse.Header.Set(\"Content-Type\", \"application/x-www-form-urlencoded\")\n\trespSAMLResp, err := a.Client.Do(reqSAMLResponse)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif code := respSAMLResp.StatusCode; code != http.StatusOK {\n\t\treturn &StatusCodeError{\n\t\t\tCode: code,\n\t\t\tMsg: fmt.Sprintf(\"SAML Response request failed with status code: %d\", code),\n\t\t}\n\t}\n\tif !(verifyLoggedIn(respSAMLResp)) {\n\t\treturn &APIError{\n\t\t\tMsg: \"Not redirected to studip after login\",\n\t\t}\n\t}\n\treturn nil\n}", "func (user *UService) Login(loginuser *model.User) *model.User {\n\tvar validuser model.User\n\tuser.DB.Debug().Where(\"username = ? and password = ?\", loginuser.Username, loginuser.Password).Find(&validuser)\n\tif validuser != (model.User{}) {\n\t\treturn &validuser\n\t}\n\treturn nil\n}", "func Login(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Login\")\n\tvar dataResource model.RegisterResource\n\tvar token string\n\t// Decode the incoming Login json\n\terr := json.NewDecoder(r.Body).Decode(&dataResource)\n\tif err != nil {\n\t\tcommon.ResponseError(\n\t\t\tw,\n\t\t\terr,\n\t\t\t\"Invalid Login data\",\n\t\t\thttp.StatusInternalServerError,\n\t\t)\n\t\treturn\n\t}\n\n\terr = dataResource.Validate()\n\tif err != nil {\n\t\tcommon.DisplayAppError(\n\t\t\tw,\n\t\t\terr,\n\t\t\t\"Invalid data\",\n\t\t\thttp.StatusBadRequest,\n\t\t)\n\t\treturn\n\t}\n\n\tdataStore := common.NewDataStore()\n\tdefer dataStore.Close()\n\tcol := dataStore.Collection(\"users\")\n\tuserStore := store.UserStore{C: col}\n\t// Authenticate the login result\n\tresult, err, status := userStore.Login(dataResource.Email, dataResource.Password)\n\n\tdata := model.ResponseModel{\n\t\tStatusCode: status.V(),\n\t}\n\n\tswitch status {\n\tcase constants.NotActivated:\n\t\tdata.Error = status.T()\n\t\t//if err != nil {\n\t\t//\tdata.Data = constants.NotActivated.T()\n\t\t//\tdata.Error = err.Error()\n\t\t//}\n\t\tbreak\n\tcase constants.NotExitedEmail:\n\t\tdata.Error = status.T()\n\t\t//if err != nil {\n\t\t//\tdata.Data = constants.NotActivated.T()\n\t\t//\tdata.Error = err.Error()\n\t\t//}\n\t\tbreak\n\tcase constants.LoginFail:\n\t\tdata.Error = status.T()\n\t\t//if err != nil {\n\t\t//\tdata.Error = err.Error()\n\t\t//}\n\t\tbreak\n\tcase constants.Successful:\n\t\t// Generate JWT token\n\t\ttoken, err = common.GenerateJWT(result.ID, result.Email, \"member\")\n\t\tif err != nil {\n\t\t\tcommon.DisplayAppError(\n\t\t\t\tw,\n\t\t\t\terr,\n\t\t\t\t\"Eror while generating the access token\",\n\t\t\t\thttp.StatusInternalServerError,\n\t\t\t)\n\t\t\treturn\n\t\t}\n\t\t// Clean-up the hashpassword to eliminate it from response JSON\n\t\tuserData := model.UserLite{\n\t\t\tEmail:result.Email,\n\t\t\tID:result.ID,\n\t\t\tLocation:result.Location,\n\t\t\tRole:result.Role,\n\t\t\tMyUrl:result.MyUrl,\n\t\t\tDescription:result.Description,\n\t\t\tLastName:result.LastName,\n\t\t\tFirstName:result.FirstName,\n\t\t\tActivated:result.Activated,\n\t\t\tAvatar:result.Avatar,\n\t\t\tIDCardUrl:result.IDCardUrl,\n\t\t\tPhoneNumber:result.PhoneNumber,\n\n\t\t}\n\t\tauthUser := model.AuthUserModel{\n\t\t\tUser: userData,\n\t\t\tToken: token,\n\t\t}\n\t\tdata.Data = authUser\n\t\tbreak\n\t}\n\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\n\tj, err := json.Marshal(data)\n\tif err != nil {\n\t\tcommon.DisplayAppError(\n\t\t\tw,\n\t\t\terr,\n\t\t\t\"An unexpected error has occurred\",\n\t\t\thttp.StatusInternalServerError,\n\t\t)\n\t\treturn\n\t}\n\tw.WriteHeader(http.StatusOK)\n\tw.Write(j)\n}", "func (_m *Leaser) Login(opts *service.LeaseLoginOptions) {\n\t_m.Called(opts)\n}", "func (c *Client) Login(username, password string) error {\n\tvar errAuth error\n\tc.sessionID, errAuth = a10v21Auth(c.host, username, password)\n\treturn errAuth\n}", "func (serv *AppServer) Login(username string, password string) int {\n\th := sha256.New()\n\th.Write([]byte(password))\n\thashed := hex.EncodeToString(h.Sum(nil))\n\tret, _ := strconv.Atoi(serv.ServerRequest([]string{\"Login\", username, hashed}))\n\treturn ret\n}", "func (p *Base) Login() string {\n\treturn \"https://admin.thebase.in/users/login\"\n}", "func (a *App) Login(w http.ResponseWriter, r *http.Request) {\n\tvar resp = map[string]interface{}{\"status\": \"success\", \"message\": \"logged in\"}\n\n\tuser := &models.User{}\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\terr = json.Unmarshal(body, &user)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tuser.Prepare() // here strip the text of white spaces\n\n\terr = user.Validate(\"login\") // fields(email, password) are validated\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tusr, err := user.GetUser(a.DB)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\n\tif usr == nil { // user is not registered\n\t\tresp[\"status\"] = \"failed\"\n\t\tresp[\"message\"] = \"Login failed, please signup\"\n\t\tresponses.JSON(w, http.StatusBadRequest, resp)\n\t\treturn\n\t}\n\n\terr = models.CheckPasswordHash(user.Password, usr.Password)\n\tif err != nil {\n\t\tresp[\"status\"] = \"failed\"\n\t\tresp[\"message\"] = \"Login failed, please try again\"\n\t\tresponses.JSON(w, http.StatusForbidden, resp)\n\t\treturn\n\t}\n\ttoken, err := utils.EncodeAuthToken(usr.ID)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tresp[\"token\"] = token\n\tresponses.JSON(w, http.StatusOK, resp)\n\treturn\n}", "func (client *Client) Login(login model.Login) (model.Tokens, error) {\n\tvar tokens model.Tokens\n\terr := client.RestAPI.Post(rest.Rq{\n\t\tBody: login,\n\t\tResult: &tokens,\n\t\tURL: rest.URL{\n\t\t\tPath: userLoginPath,\n\t\t\tParams: rest.P{},\n\t\t},\n\t})\n\treturn tokens, err\n}", "func (c *Controller) Login(email, password string) error {\n\tinfo, err := Login(email, password, \"\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"login controller\")\n\t}\n\tc.sessionInfoLock.Lock()\n\tc.sessionInfo = info\n\tc.sessionInfoLock.Unlock()\n\treturn nil\n}", "func (s *DB) CheckLogin(ul ara.UserLogin) (bool, error) {\n\tvar q = `SELECT 1 FROM users WHERE username = $1 AND password = $2;`\n\tvar err error\n\tvar dummy int\n\terr = s.QueryRow(q, ul.Username, ul.Password).Scan(&dummy)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn true, nil\n}", "func Login(c echo.Context) error {\n\t// Read the json body\n\tb, err := ioutil.ReadAll(c.Request().Body)\n\tif err != nil {\n\t\treturn echo.NewHTTPError(http.StatusBadRequest, err.Error())\n\t}\n\n\t// Verify length\n\tif len(b) == 0 {\n\t\treturn c.JSON(http.StatusBadRequest, map[string]string{\n\t\t\t\"verbose_msg\": \"You have sent an empty json\"})\n\t}\n\n\t// Validate JSON\n\tl := gojsonschema.NewBytesLoader(b)\n\tresult, err := app.LoginSchema.Validate(l)\n\tif err != nil {\n\t\treturn c.JSON(http.StatusBadRequest, err.Error())\n\t}\n\tif !result.Valid() {\n\t\tmsg := \"\"\n\t\tfor _, desc := range result.Errors() {\n\t\t\tmsg += fmt.Sprintf(\"%s, \", desc.Description())\n\t\t}\n\t\tmsg = strings.TrimSuffix(msg, \", \")\n\t\treturn c.JSON(http.StatusBadRequest, map[string]string{\n\t\t\t\"verbose_msg\": msg})\n\t}\n\n\t// Bind it to our User instance.\n\tloginUser := user.User{}\n\terr = json.Unmarshal(b, &loginUser)\n\tif err != nil {\n\t\treturn c.JSON(http.StatusInternalServerError, err.Error())\n\t}\n\tloginUsername := loginUser.Username\n\tloginPassword := loginUser.Password\n\tu, err := user.GetByUsername(loginUsername)\n\tif err != nil {\n\t\treturn c.JSON(http.StatusNotFound, map[string]string{\n\t\t\t\"verbose_msg\": \"Username does not exist !\"})\n\t}\n\n\tif !comparePasswords(u.Password, []byte(loginPassword)) {\n\t\treturn c.JSON(http.StatusUnauthorized, map[string]string{\n\t\t\t\"verbose_msg\": \"Username or password does not match !\"})\n\t}\n\n\tif !u.Confirmed {\n\t\treturn c.JSON(http.StatusUnauthorized, map[string]string{\n\t\t\t\"verbose_msg\": \"Account not confirmed, please confirm your email !\"})\n\t}\n\n\ttoken, err := createJwtToken(u)\n\tif err != nil {\n\t\treturn c.JSON(http.StatusInternalServerError, map[string]string{\n\t\t\t\"verbose_msg\": \"Internal server error !\"})\n\t}\n\n\t// Create a cookie to place the jwt token\n\tcookie := createJwtCookie(token)\n\tc.SetCookie(cookie)\n\n\treturn c.JSON(http.StatusOK, map[string]string{\n\t\t\"verbose_msg\": \"You were logged in !\",\n\t\t\"token\": token,\n\t})\n}", "func (uc UserController) Login(w http.ResponseWriter, r *http.Request) {\n\tif user := users.GetLoggedInUser(r); user != nil {\n\t\thttp.Redirect(w, r, \"/\", http.StatusOK)\n\t\treturn\n\t}\n\n\temail, pass := r.FormValue(\"email\"), r.FormValue(\"password\")\n\tuser := users.CheckLoginInformation(email, pass)\n\n\tif user == nil {\n\t\thttp.Error(w, \"Incorrect username and password combination\", http.StatusUnauthorized)\n\t} else {\n\t\tusers.LoginUser(w, r, user)\n\t\thttp.Redirect(w, r, \"/\", http.StatusOK)\n\t}\n}", "func (h UserRepos) Login(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\n\tctxValues, err := webcontext.ContextValues(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t//\n\treq := new(UserLoginRequest)\n\tdata := make(map[string]interface{})\n\tf := func() (bool, error) {\n\n\t\tif r.Method == http.MethodPost {\n\t\t\terr := r.ParseForm()\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\tdecoder := schema.NewDecoder()\n\t\t\tif err := decoder.Decode(req, r.PostForm); err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\treq.Password = strings.Replace(req.Password, \".\", \"\", -1)\n\t\t\tsessionTTL := time.Hour\n\t\t\tif req.RememberMe {\n\t\t\t\tsessionTTL = time.Hour * 36\n\t\t\t}\n\n\t\t\t// Authenticated the user.\n\t\t\ttoken, err := h.AuthRepo.Authenticate(ctx, user_auth.AuthenticateRequest{\n\t\t\t\tEmail: req.Email,\n\t\t\t\tPassword: req.Password,\n\t\t\t}, sessionTTL, ctxValues.Now)\n\t\t\tif err != nil {\n\t\t\t\tswitch errors.Cause(err) {\n\t\t\t\tcase user.ErrForbidden:\n\t\t\t\t\treturn false, web.RespondError(ctx, w, weberror.NewError(ctx, err, http.StatusForbidden))\n\t\t\t\tcase user_auth.ErrAuthenticationFailure:\n\t\t\t\t\tdata[\"error\"] = weberror.NewErrorMessage(ctx, err, http.StatusUnauthorized, \"Invalid username or password. Try again.\")\n\t\t\t\t\treturn false, nil\n\t\t\t\tdefault:\n\t\t\t\t\tif verr, ok := weberror.NewValidationError(ctx, err); ok {\n\t\t\t\t\t\tdata[\"validationErrors\"] = verr.(*weberror.Error)\n\t\t\t\t\t\treturn false, nil\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn false, err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Add the token to the users session.\n\t\t\terr = handleSessionToken(ctx, w, r, token)\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\n\t\t\tredirectUri := \"/\"\n\t\t\tif qv := r.URL.Query().Get(\"redirect\"); qv != \"\" {\n\t\t\t\tredirectUri, err = url.QueryUnescape(qv)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn false, err\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Redirect the user to the dashboard.\n\t\t\treturn true, web.Redirect(ctx, w, r, redirectUri, http.StatusFound)\n\t\t}\n\n\t\treturn false, nil\n\t}\n\n\tend, err := f()\n\tif err != nil {\n\t\treturn web.RenderError(ctx, w, r, err, h.Renderer, TmplLayoutBase, TmplContentErrorGeneric, web.MIMETextHTMLCharsetUTF8)\n\t} else if end {\n\t\treturn nil\n\t}\n\n\tdata[\"form\"] = req\n\n\tif verr, ok := weberror.NewValidationError(ctx, webcontext.Validator().Struct(UserLoginRequest{})); ok {\n\t\tdata[\"validationDefaults\"] = verr.(*weberror.Error)\n\t}\n\n\treturn h.Renderer.Render(ctx, w, r, TmplLayoutBase, \"user-login.gohtml\", web.MIMETextHTMLCharsetUTF8, http.StatusOK, data)\n}", "func (mr *MockAdminMockRecorder) Login(ctx, request interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Login\", reflect.TypeOf((*MockAdmin)(nil).Login), ctx, request)\n}", "func Login(w http.ResponseWriter, req *http.Request) {\n\tfmt.Println(chalk.Green, chalk.Bold.TextStyle(\"-- Login --\"), chalk.Reset)\n\tvar p models.LoginDTO\n\n\t// Decodes user input to JSON\n\terr := json.NewDecoder(req.Body).Decode(&p)\n\tvalidate := validator.New()\n\t// Validates if all fields are present in the POST request\n\tif err != nil || validate.Struct(p) != nil {\n\t\tfmt.Printf(\"%s Error ::%s Invalid Data\\n\\n\", chalk.Red, chalk.Reset)\n\t\thttp.Error(w, \"Invalid Data\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tfmt.Printf(\" Username :: %s \\n Hash :: %s\\n\", p.Username, p.Hash)\n\t// Check if user is present in the database\n\tif !database.Check(p.Username) {\n\t\tfmt.Printf(\"%s Error ::%s User does not exist\\n\\n\", chalk.Red, chalk.Reset)\n\t\thttp.Error(w, \"Invalid Username\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// Fetch the user details from the database\n\tuserCreds := database.Get(p.Username)\n\t// If N value is 2, prompt user to reset his password immediately\n\tif userCreds.N == 2 {\n\t\tfmt.Printf(\"%s Error ::%s Reset Password Immediately\\n\\n\", chalk.Red, chalk.Reset)\n\t\thttp.Error(w, \"Reset Password Immediately\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// Check if the hash given by user is valid\n\tok, errString := Validate(p.Username, p.Hash, userCreds)\n\tif !ok {\n\t\thttp.Error(w, errString, http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// If valid return success message\n\tfmt.Printf(\"%s Success\\n\\n%s\", chalk.Green, chalk.Reset)\n\tfmt.Fprintf(w, \"User Successfully logged in.\")\n}", "func Login(enrollID, enrollSecret string, loginChan chan int) bool {\n\tvar loginRequest loginRequest\n\tloginRequest.EnrollID = enrollID\n\tloginRequest.EnrollSecret = enrollSecret\n\n\treqBody, err := json.Marshal(loginRequest)\n\tif err != nil {\n\t\treturn false\n\t}\n\n\turlstr := getHTTPURL(\"api/login\")\n\t_, err = performHTTPPost(urlstr, reqBody)\n\tif err != nil {\n\t\tloginChan <- 1\n\t\tlogger.Errorf(\"Login failed: %v\", err)\n\t\treturn false\n\t}\n\tloginChan <- 0\n\t// logger.Debugf(\"Login: url=%v request=%v response=%v\", urlstr, string(reqBody), string(response))\n\n\t// var result restResult\n\t// err = json.Unmarshal(response, &result)\n\t// if err != nil {\n\t// \tlogger.Errorf(\"Login failed: %v\", err)\n\t// \treturn false\n\t// }\n\n\t// if len(result.OK) == 0 {\n\t// \tlogger.Errorf(\"Login failed: %v\", result.Err)\n\t// \treturn false\n\t// }\n\n\treturn true\n}", "func (impl *UserAPIClient) Login(ctx context.Context, login string, password string) (reply *api.Token, err error) {\n\terr = client.CallHTTP(ctx, impl.BaseURL, \"UserAPI.Login\", atomic.AddUint64(&impl.sequence, 1), &reply, login, password)\n\treturn\n}", "func LoginUser(u User) {\n err, _ := u.Login(\"admin\", \"admin\")\n\n if err != nil {\n fmt.Println(err.Error())\n }\n}", "func (Anonymous) Login(username, password string) AccessType {\n\tif strings.ToLower(username) == \"anonymous\" && len(password) != 0 {\n\t\treturn ReadOnly\n\t} else {\n\t\treturn NoPermission\n\t}\n}", "func validLogin(username string, password string) (bool, uint) {\n\tuser, err := GetUserFromUsername(username)\n\tif err != nil {\n\t\tfmt.Println(\"Login user query failed with error\", err.Error())\n\t\treturn false, 0\n\t}\n\tfmt.Printf(\n\t\t\"Login user query succeeded, comparing DB password %s to login password %s\\n\",\n\t\tuser.PasswordHash,\n\t\tpassword,\n\t)\n\tif core.PasswordEqualsHashed(password, user.PasswordHash) {\n\t\treturn true, user.ID\n\t}\n\treturn false, 0\n}", "func (a *Auth) Login(w http.ResponseWriter, r *http.Request, data *UserCred) {\n\tvar user, email, code string\n\n\tif user = a.userstate.Username(r); user != \"\" {\n\t\tif sid, ok := cookie.SecureCookie(\n\t\t\tr,\n\t\t\tsessionIDKey,\n\t\t\ta.userstate.CookieSecret(),\n\t\t); ok {\n\t\t\tif a.userstate.CorrectPassword(user, sid) {\n\t\t\t\ta.Session(w, r)\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}\n\n\ttiming := servertiming.FromContext(r.Context())\n\tm := timing.NewMetric(\"grpc\").WithDesc(\"PKI signature validation\").Start()\n\tconn, err := pb.New(r.Context(), a.addr)\n\tif err != nil {\n\t\tutil.BadRequest(w, r, err)\n\t\treturn\n\t}\n\tdefer conn.Close()\n\tclient := pb.NewMetropolisServiceClient(conn)\n\tresp, err := client.VerifySignature(\n\t\tr.Context(),\n\t\t&pb.VerRequest{\n\t\t\tSignedXml: data.SignedXML,\n\t\t\tFlag: pb.VerFlag_AUTH,\n\t\t},\n\t)\n\tm.Stop()\n\n\tif resp.Status != pb.VerStatus_SUCCESS {\n\t\terr := errors.New(resp.Message)\n\t\tutil.BadRequestWith(w, r, err, resp.Description)\n\t\treturn\n\t}\n\n\tuser = resp.Message\n\temail = data.EmailAddress\n\n\tok, err := a.userstate.HasUser2(user)\n\tif err != nil {\n\t\tutil.BadRequest(w, r, err)\n\t\treturn\n\t}\n\tif ok {\n\t\ta.userstate.RemoveUser(user)\n\t}\n\n\tcode, err = a.userstate.GenerateUniqueConfirmationCode()\n\tif err != nil {\n\t\tutil.BadRequest(w, r, err)\n\t\treturn\n\t}\n\n\ta.userstate.AddUser(user, code, email)\n\tcookie.SetSecureCookiePathWithFlags(\n\t\tw,\n\t\tsessionIDKey,\n\t\tcode,\n\t\ta.userstate.CookieTimeout(user),\n\t\t\"/\",\n\t\ta.userstate.CookieSecret(),\n\t\tfalse,\n\t\ttrue,\n\t)\n\n\ta.userstate.Login(w, user)\n\tutil.OK(w, r)\n}", "func (ac *authAPIsController) login(c *gin.Context) {\n\terr := ac.loginAuth.Login(c)\n\tif err != nil {\n\t\tklog.Errorf(\"login err, err: %v, url: %s\", err, c.FullPath())\n\t\tif err == auth.LoginInvalid {\n\t\t\tutils.Redirect403(c)\n\t\t} else {\n\t\t\tutils.Redirect500(c)\n\t\t}\n\t\treturn\n\t}\n\tutils.Succeed(c, nil)\n}", "func (a Authentic) login(c buffalo.Context) error {\n\treturn c.Render(200, a.Config.LoginPage)\n}", "func (s *service) Login(w http.ResponseWriter, r *http.Request) (interface{}, error) {\n\tctx := r.Context()\n\n\treq, err := decodeLoginRequest(r)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tuser, err := s.repoMngr.User().ByIdentity(ctx, req.UserAttribute(), req.Identity)\n\tif err == sql.ErrNoRows {\n\t\treturn nil, fmt.Errorf(\"%v: %w\", err, auth.ErrBadRequest(\"invalid username or password\"))\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err = s.password.Validate(user, req.Password); err != nil {\n\t\treturn nil, fmt.Errorf(\"%v: %w\", err, auth.ErrBadRequest(\"invalid username or password\"))\n\t}\n\n\tvar jwtToken *auth.Token\n\n\tif user.CanSendDefaultOTP() {\n\t\tjwtToken, err = s.token.Create(\n\t\t\tctx,\n\t\t\tuser,\n\t\t\tauth.JWTPreAuthorized,\n\t\t\ttoken.WithOTPDeliveryMethod(user.DefaultOTPDelivery()),\n\t\t)\n\t} else {\n\t\tjwtToken, err = s.token.Create(ctx, user, auth.JWTPreAuthorized)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn s.respond(ctx, w, user, jwtToken)\n}", "func (h *Hub) Login() (success bool, err error) {\n\treq := newRequest(&h.client.authData, \"logIn\", \"\")\n\tresp, err := req.send()\n\n\tif err == nil {\n\t\th.client.authData.sessionID = strconv.Itoa(resp.ResponseBody.Reply.ResponseActions[0].ResponseCallbacks[0].Parameters.ID)\n\t\th.client.authData.nonce = resp.ResponseBody.Reply.ResponseActions[0].ResponseCallbacks[0].Parameters.Nonce\n\t\treturn true, nil\n\t}\n\n\treturn false, err\n}", "func Login(username string, password string) error {\n\tdata := url.Values{}\n\tdata.Set(\"login\", username)\n\tdata.Set(\"haslo\", password)\n\n\tres, err := http.Post(loginURL, \"application/x-www-form-urlencoded\", strings.NewReader(data.Encode()))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to make HTTP POST login request: %v\", err)\n\t}\n\n\tlog.Println(\"auth status:\", res.Status)\n\n\treturn nil\n}", "func (p Platypus) Login(username string, password string) error {\n\tparams := LoginMethodParameters{\n\t\tLogintype: \"Staff\",\n\t\tDatatype: \"XML\",\n\t\tUsername: username,\n\t\tPassword: password,\n\t}\n\n\tres, err := p.Exec(\"Login\", params, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif res.Success == 0 {\n\t\treturn errors.New(res.ResponseText)\n\t}\n\n\treturn nil\n}", "func loginprompt(w http.ResponseWriter, r *http.Request) {\n\t_, tid := GetAndOrUpdateSession(w, r)\n\tif tid != \"\" {\n\t\tshowMessage(w, \"Error: already logged in\",\n\t\t\t\"You are already logged in\", tid, \"\")\n\t\treturn\n\t}\n\ttemplate.Must(template.New(\"\").Parse(tLoginPrompt)).Execute(w, map[string]string{\n\t\t\"PageTitle\": \"Please log in\",\n\t\t\"Team\": r.FormValue(\"team\"),\n\t\t// TODO URL escaping would be pretty sweet\n\t\t\"TeamURL\": url.QueryEscape(r.FormValue(\"team\")),\n\t})\n}", "func Login(r *http.Request, username string, password string) (*Session, bool) {\n\tif PreLoginHandler != nil {\n\t\tPreLoginHandler(r, username, password)\n\t}\n\t// Get the user from DB\n\tuser := User{}\n\tGet(&user, \"username = ?\", username)\n\tif user.ID == 0 {\n\t\tIncrementMetric(\"uadmin/security/invalidlogin\")\n\t\tgo func() {\n\t\t\tlog := &Log{}\n\t\t\tif r.Form == nil {\n\t\t\t\tr.ParseForm()\n\t\t\t}\n\t\t\tctx := context.WithValue(r.Context(), CKey(\"login-status\"), \"invalid username\")\n\t\t\tr = r.WithContext(ctx)\n\t\t\tlog.SignIn(username, log.Action.LoginDenied(), r)\n\t\t\tlog.Save()\n\t\t}()\n\t\tincrementInvalidLogins(r)\n\t\treturn nil, false\n\t}\n\ts := user.Login(password, \"\")\n\tif s != nil && s.ID != 0 {\n\t\ts.IP = GetRemoteIP(r)\n\t\ts.Save()\n\t\tif s.Active && (s.ExpiresOn == nil || s.ExpiresOn.After(time.Now())) {\n\t\t\ts.User = user\n\t\t\tif s.User.Active && (s.User.ExpiresOn == nil || s.User.ExpiresOn.After(time.Now())) {\n\t\t\t\tIncrementMetric(\"uadmin/security/validlogin\")\n\t\t\t\t// Store login successful to the user log\n\t\t\t\tgo func() {\n\t\t\t\t\tlog := &Log{}\n\t\t\t\t\tif r.Form == nil {\n\t\t\t\t\t\tr.ParseForm()\n\t\t\t\t\t}\n\t\t\t\t\tlog.SignIn(user.Username, log.Action.LoginSuccessful(), r)\n\t\t\t\t\tlog.Save()\n\t\t\t\t}()\n\t\t\t\treturn s, s.User.OTPRequired\n\t\t\t}\n\t\t}\n\t} else {\n\t\tgo func() {\n\t\t\tlog := &Log{}\n\t\t\tif r.Form == nil {\n\t\t\t\tr.ParseForm()\n\t\t\t}\n\t\t\tctx := context.WithValue(r.Context(), CKey(\"login-status\"), \"invalid password or inactive user\")\n\t\t\tr = r.WithContext(ctx)\n\t\t\tlog.SignIn(username, log.Action.LoginDenied(), r)\n\t\t\tlog.Save()\n\t\t}()\n\t}\n\n\tincrementInvalidLogins(r)\n\n\t// Record metrics\n\tIncrementMetric(\"uadmin/security/invalidlogin\")\n\treturn nil, false\n}", "func (s *Server) Login(c *gin.Context) {\n\tvar login Login\n\tc.BindJSON(&login)\n\n\terr := login.Validate()\n\tif err != nil {\n\t\tc.JSON(http.StatusBadRequest, err)\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, gin.H{\n\t\t\"login\": true,\n\t})\n}", "func (_BREM *BREMSession) Login() (string, error) {\n\treturn _BREM.Contract.Login(&_BREM.CallOpts)\n}", "func (a *App) Login(w http.ResponseWriter, r *http.Request) {\n\tvar loginInfo uvm.UserLoginVM\n\n\tdecoder := json.NewDecoder(r.Body)\n\tvar err error\n\n\tif err = decoder.Decode(&loginInfo); err != nil {\n\t\trespondWithError(w, http.StatusBadRequest, \"Invalid request body\")\n\t\treturn\n\t}\n\n\t//TODO validate user data\n\n\tuser := a.UserStore.GetUserByEmail(loginInfo.Email)\n\n\tif user.ID == \"\" || utils.CheckPasswordHash(loginInfo.Password, user.Password) {\n\t\trespondWithError(w, http.StatusBadRequest, \"Invalid credentials\")\n\t\treturn\n\t}\n\n\ttoken := auth.GenerateToken(a.APISecret, user)\n\n\tresult := models.UserResult{\n\t\tUsername: user.Username,\n\t\tPicture: user.Picture,\n\t\tRole: user.Role.Name,\n\t\tToken: token,\n\t}\n\n\trespondWithJSON(w, http.StatusOK, result)\n}", "func (c *Client) Login() error {\n\n\tversionStruct, err := CreateAPIVersion(1, 9, 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\tapiStruct, err := CreateAPISession(versionStruct, \"\", \"\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Create a Resty Client\n\tc.restClient = resty.New()\n\tc.restClient.\n\t\tSetTimeout(time.Duration(30 * time.Second)).\n\t\tSetRetryCount(3).\n\t\tSetRetryWaitTime(5 * time.Second).\n\t\tSetRetryMaxWaitTime(20 * time.Second)\n\n\tresp, err := c.restClient.R().\n\t\tSetHeader(\"Content-Type\", \"application/json\").\n\t\tSetBody(apiStruct).\n\t\tPost(c.url + \"/session\")\n\n\tresult := resp.Body()\n\tvar resultdat map[string]interface{}\n\tif err = json.Unmarshal(result, &resultdat); err != nil { //convert the json to go objects\n\t\treturn err\n\t}\n\n\tif resultdat[\"status\"].(string) == \"ERROR\" {\n\t\terrorMessage := string(result)\n\t\terr = fmt.Errorf(errorMessage)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tresp, err = c.restClient.R().\n\t\tSetHeader(\"Content-Type\", \"application/json\").\n\t\tSetResult(AuthSuccess{}).\n\t\tSetBody(LoginRequestStruct{\n\t\t\tType: \"LoginRequest\",\n\t\t\tUsername: c.username,\n\t\t\tPassword: c.password,\n\t\t}).\n\t\tPost(c.url + \"/login\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif http.StatusOK != resp.StatusCode() {\n\t\terr = fmt.Errorf(\"Delphix Username/Password incorrect\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tresult = resp.Body()\n\tif err = json.Unmarshal(result, &resultdat); err != nil { //convert the json to go objects\n\t\treturn err\n\t}\n\n\tif resultdat[\"status\"].(string) == \"ERROR\" {\n\t\terrorMessage := string(result)\n\t\tlog.Fatalf(errorMessage)\n\t\terr = fmt.Errorf(errorMessage)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\t\n\treturn nil\n}", "func Login(e *Engine, username string, password string) (bool, error) {\n\tres, _, err := e.RawSelect(Filter(\"autoscope_users\",\n\t\tmap[string]interface{}{\"username\": username}))\n\tif err != nil { return false, err }\n\tuser, err := GetRow(res)\n\tif err != nil { return false, err }\n\n\t//CompareHashAndPassword returns nil on success\n\tsalted := password + strconv.FormatInt(user[\"salt\"].(int64), 10)\n\thashErr := bcrypt.CompareHashAndPassword([]byte(user[\"passhash\"].(string)),\n\t\t[]byte(salted))\n\treturn hashErr == nil, hashErr\n}", "func Login(r *http.Request) (bool, models.User, error) {\n\tusername, password := r.FormValue(\"username\"), r.FormValue(\"password\")\n\tu, err := models.GetUserByUsername(username)\n\tif err != nil && err != models.ErrUsernameTaken {\n\t\treturn false, models.User{}, err\n\t}\n\t//If we've made it here, we should have a valid user stored in u\n\t//Let's check the password\n\terr = bcrypt.CompareHashAndPassword([]byte(u.Hash), []byte(password))\n\tif err != nil {\n\t\treturn false, models.User{}, ErrInvalidPassword\n\t}\n\treturn true, u, nil\n}", "func (m defaultLoginManager) Login(\n\tctx context.Context, d diag.Sink, cloudURL string,\n\tproject *workspace.Project, insecure bool, opts display.Options,\n) (Backend, error) {\n\tcurrent, err := m.Current(ctx, d, cloudURL, project, insecure)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif current != nil {\n\t\treturn current, nil\n\t}\n\n\tcloudURL = ValueOrDefaultURL(cloudURL)\n\tvar accessToken string\n\taccountLink := cloudConsoleURL(cloudURL, \"account\", \"tokens\")\n\n\tif !cmdutil.Interactive() {\n\t\t// If interactive mode isn't enabled, the only way to specify a token is through the environment variable.\n\t\t// Fail the attempt to login.\n\t\treturn nil, fmt.Errorf(\"%s must be set for login during non-interactive CLI sessions\", AccessTokenEnvVar)\n\t}\n\n\t// If no access token is available from the environment, and we are interactive, prompt and offer to\n\t// open a browser to make it easy to generate and use a fresh token.\n\tline1 := \"Manage your Pulumi stacks by logging in.\"\n\tline1len := len(line1)\n\tline1 = colors.Highlight(line1, \"Pulumi stacks\", colors.Underline+colors.Bold)\n\tfmt.Printf(opts.Color.Colorize(line1) + \"\\n\")\n\tmaxlen := line1len\n\n\tline2 := \"Run `pulumi login --help` for alternative login options.\"\n\tline2len := len(line2)\n\tfmt.Printf(opts.Color.Colorize(line2) + \"\\n\")\n\tif line2len > maxlen {\n\t\tmaxlen = line2len\n\t}\n\n\t// In the case where we could not construct a link to the pulumi console based on the API server's hostname,\n\t// don't offer magic log-in or text about where to find your access token.\n\tif accountLink == \"\" {\n\t\tfor {\n\t\t\tif accessToken, err = cmdutil.ReadConsoleNoEcho(\"Enter your access token\"); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif accessToken != \"\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t} else {\n\t\tline3 := fmt.Sprintf(\"Enter your access token from %s\", accountLink)\n\t\tline3len := len(line3)\n\t\tline3 = colors.Highlight(line3, \"access token\", colors.BrightCyan+colors.Bold)\n\t\tline3 = colors.Highlight(line3, accountLink, colors.BrightBlue+colors.Underline+colors.Bold)\n\t\tfmt.Printf(opts.Color.Colorize(line3) + \"\\n\")\n\t\tif line3len > maxlen {\n\t\t\tmaxlen = line3len\n\t\t}\n\n\t\tline4 := \" or hit <ENTER> to log in using your browser\"\n\t\tvar padding string\n\t\tif pad := maxlen - len(line4); pad > 0 {\n\t\t\tpadding = strings.Repeat(\" \", pad)\n\t\t}\n\t\tline4 = colors.Highlight(line4, \"<ENTER>\", colors.BrightCyan+colors.Bold)\n\n\t\tif accessToken, err = cmdutil.ReadConsoleNoEcho(opts.Color.Colorize(line4) + padding); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tif accessToken == \"\" {\n\t\t\treturn loginWithBrowser(ctx, d, cloudURL, project, insecure, opts)\n\t\t}\n\n\t\t// Welcome the user since this was an interactive login.\n\t\tWelcomeUser(opts)\n\t}\n\n\t// Try and use the credentials to see if they are valid.\n\tvalid, username, organizations, err := IsValidAccessToken(ctx, cloudURL, insecure, accessToken)\n\tif err != nil {\n\t\treturn nil, err\n\t} else if !valid {\n\t\treturn nil, fmt.Errorf(\"invalid access token\")\n\t}\n\n\t// Save them.\n\taccount := workspace.Account{\n\t\tAccessToken: accessToken,\n\t\tUsername: username,\n\t\tOrganizations: organizations,\n\t\tLastValidatedAt: time.Now(),\n\t\tInsecure: insecure,\n\t}\n\tif err = workspace.StoreAccount(cloudURL, account, true); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn New(d, cloudURL, project, insecure)\n}" ]
[ "0.67690563", "0.67624575", "0.67271596", "0.66149926", "0.6585284", "0.6573348", "0.6540424", "0.6521625", "0.6498617", "0.6486779", "0.64378715", "0.64263606", "0.6399371", "0.6376075", "0.63646734", "0.63622534", "0.63606757", "0.6340663", "0.634037", "0.6320144", "0.6315191", "0.63100606", "0.6289054", "0.62669504", "0.6264601", "0.6264172", "0.6241354", "0.6238542", "0.6227928", "0.6226675", "0.622172", "0.6217456", "0.62143815", "0.62118405", "0.62081915", "0.6207351", "0.6188986", "0.61838245", "0.61796343", "0.61635315", "0.6151053", "0.61391693", "0.613902", "0.61304945", "0.6128618", "0.61225843", "0.6120874", "0.61122596", "0.61061025", "0.61043113", "0.6097198", "0.60919774", "0.6074345", "0.6073528", "0.6064518", "0.60595334", "0.60559696", "0.6042681", "0.6036674", "0.60362643", "0.6033916", "0.6030461", "0.60277987", "0.60215265", "0.6019921", "0.6015517", "0.60128534", "0.6010487", "0.60059965", "0.6001701", "0.60012466", "0.60012394", "0.59994227", "0.59938323", "0.59890753", "0.59838146", "0.59819293", "0.59611726", "0.5959921", "0.59596056", "0.5958162", "0.5953645", "0.59525096", "0.59449595", "0.59442437", "0.59431374", "0.59331095", "0.5931233", "0.5926683", "0.59246165", "0.5921054", "0.59203714", "0.5919078", "0.5918905", "0.5909227", "0.59089166", "0.5897191", "0.58933437", "0.5886389", "0.5882793" ]
0.6261488
26
Logout mocks base method
func (m *MockServiceAuth) Logout(arg0 echo.Context) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Logout", arg0) ret0, _ := ret[0].(error) return ret0 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MockAuthService) Logout(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Logout\", arg0, arg1)\n}", "func (m *MockHandler) Logout(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Logout\", arg0, arg1)\n}", "func Test_LogoutCommand(t *testing.T) {\n\tdir, err := tempConfig(\"\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer os.RemoveAll(dir)\n\n\tmockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tw.Write([]byte(`{\"status_code\": 10007, \"status_text\": \"Resource deleted\"}`))\n\t}))\n\tdefer mockServer.Close()\n\n\tcmdAPIEndpoint = mockServer.URL\n\tcmdToken = \"some-token\"\n\tlogoutValidationOutput(LogoutCommand, []string{})\n\tlogoutOutput(LogoutCommand, []string{})\n}", "func (m *MockUserUseCase) Logout(sid string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Logout\", sid)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func Test_LogoutValidToken(t *testing.T) {\n\tdir, err := tempConfig(\"\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer os.RemoveAll(dir)\n\n\tmockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tw.Write([]byte(`{\"status_code\": 10007, \"status_text\": \"Resource deleted\"}`))\n\t}))\n\tdefer mockServer.Close()\n\n\tlogoutArgs := logoutArguments{\n\t\tapiEndpoint: mockServer.URL,\n\t\ttoken: \"test-token\",\n\t}\n\n\terr = logout(logoutArgs)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}", "func TestLoginWrapper_LoggedOut(t *testing.T) {\n\tw, r, c := initTestRequestParams(t, nil)\n\tdefer c.Close()\n\n\tdummyLoginHandler(&requestParams{w: w, r: r, c: c})\n\n\texpectCode(t, http.StatusUnauthorized, w)\n\texpectBody(t, \"\", w)\n}", "func Test_LogoutInvalidToken(t *testing.T) {\n\tdir, err := tempConfig(\"\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer os.RemoveAll(dir)\n\n\tmockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\tw.Write([]byte(``))\n\t}))\n\tdefer mockServer.Close()\n\n\tlogoutArgs := logoutArguments{\n\t\tapiEndpoint: mockServer.URL,\n\t\ttoken: \"test-token\",\n\t}\n\n\terr = logout(logoutArgs)\n\tif !IsNotAuthorizedError(err) {\n\t\tt.Errorf(\"Unexpected error: %s\", err)\n\t}\n}", "func (_m *AuthServer) Logout(_a0 context.Context, _a1 *auth.SessionID) (*auth.Empty, error) {\n\tret := _m.Called(_a0, _a1)\n\n\tvar r0 *auth.Empty\n\tif rf, ok := ret.Get(0).(func(context.Context, *auth.SessionID) *auth.Empty); ok {\n\t\tr0 = rf(_a0, _a1)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*auth.Empty)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context, *auth.SessionID) error); ok {\n\t\tr1 = rf(_a0, _a1)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func supervisorLogout(c *cli.Context) error {\n\tif err := adm.VerifyNoArgument(c); err != nil {\n\t\treturn err\n\t}\n\n\tif c.GlobalBool(`doublelogout`) {\n\t\treturn adm.MockOK(`command`, c)\n\t}\n\n\tvar path string\n\tswitch c.Bool(`all`) {\n\tcase true:\n\t\tpath = `/tokens/self/all`\n\tcase false:\n\t\tpath = `/tokens/self/active`\n\t}\n\treturn adm.Perform(`delete`, path, `command`, nil, c)\n}", "func (_m *MutationResolver) Logout(ctx context.Context) (*gqlgen.LogoutOutput, error) {\n\tret := _m.Called(ctx)\n\n\tvar r0 *gqlgen.LogoutOutput\n\tif rf, ok := ret.Get(0).(func(context.Context) *gqlgen.LogoutOutput); ok {\n\t\tr0 = rf(ctx)\n\t} else {\n\t\tif ret.Get(0) != nil {\n\t\t\tr0 = ret.Get(0).(*gqlgen.LogoutOutput)\n\t\t}\n\t}\n\n\tvar r1 error\n\tif rf, ok := ret.Get(1).(func(context.Context) error); ok {\n\t\tr1 = rf(ctx)\n\t} else {\n\t\tr1 = ret.Error(1)\n\t}\n\n\treturn r0, r1\n}", "func TestDvLIRClient_LoginLogout(t *testing.T) {\n\tip := viper.GetString(\"IPAddress\")\n\tpw := viper.GetString(\"Password\")\n\tdvlirClient, err := NewDvLIRClient(ip, pw)\n\tif !assert.NoError(t, err, \"Error while creating Api client\") {\n\t\treturn\n\t}\n\n\terr = dvlirClient.Login()\n\tif !assert.NoError(t, err, \"Error during Login\") {\n\t\treturn\n\t}\n\n\tdefer func() {\n\t\terr = dvlirClient.Logout()\n\t\tif !assert.NoError(t, err, \"Error during Logout\") {\n\t\t\treturn\n\t\t}\n\t}()\n}", "func getLogout(s *Setup) func(w http.ResponseWriter, r *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tvar response jSendResponse\n\t\tstatusCode := http.StatusOK\n\t\tresponse.Status = \"fail\"\n\n\t\terr := invalidateAttachedToken(r, s)\n\t\tif err != nil {\n\t\t\ts.Logger.Printf(\"logout failed because: %v\", err)\n\t\t\tresponse.Status = \"error\"\n\t\t\tresponse.Message = \"server error when logging out\"\n\t\t\tstatusCode = http.StatusInternalServerError\n\t\t} else {\n\t\t\tresponse.Status = \"success\"\n\t\t\ts.Logger.Printf(\"token was invalidated\")\n\t\t}\n\t\twriteResponseToWriter(response, w, statusCode)\n\t}\n}", "func (r *mutationResolver) Logout(ctx context.Context) (*models.Logout, error) {\n\tpanic(\"not implemented\")\n}", "func (s *AuthService) Logout(login, refreshToken string) error {\n\terr := s.client.Auth.Logout(login, refreshToken)\n\treturn err\n}", "func (m *TestFixClient) OnLogout(sessionID fix.SessionID) {\n\tlog.Printf(\"[FIX %s] MockFix.OnLogout: %s\", m.name, sessionID)\n\tm.Sessions[sessionID.String()].LoggedOn = false\n}", "func (c *Controller) Logout(ctx context.Context) (err error) {\n\t// Build request\n\treq, err := c.requestBuild(ctx, \"GET\", authenticationAPIName, \"logout\", nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"request building failure: %w\", err)\n\t}\n\t// execute auth request\n\tif err = c.requestExecute(ctx, req, nil, false); err != nil {\n\t\terr = fmt.Errorf(\"executing request failed: %w\", err)\n\t}\n\treturn\n}", "func (userHandlersImpl UserHandlersImpl) Logout(w http.ResponseWriter, req *http.Request) {\n\n\tresp := \"\"\n\tWriteOKResponse(w, resp)\n\n}", "func (c *yorcProviderClient) Logout() error {\n\trequest, err := http.NewRequest(\"POST\", fmt.Sprintf(\"%s/logout\", c.client.baseURL), nil)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\trequest.Header.Add(\"Accept\", \"application/json\")\n\trequest.Header.Set(\"Connection\", \"close\")\n\n\trequest.Close = true\n\n\tresponse, err := c.client.Client.Do(request)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode != http.StatusOK {\n\t\treturn getError(response.Body)\n\t}\n\n\treturn nil\n}", "func AfterTest() {\n\thttpmock.DeactivateAndReset()\n}", "func (a *authSvc) Logout(ctx context.Context) error {\n\taccessUuid, ok := ctx.Value(AccessUuidKey).(string)\n\tif !ok {\n\t\treturn errors.New(\"access uuid not present in context\")\n\t}\n\tdeleted, err := deleteAuth(\"access_token\", accessUuid)\n\tif err != nil || deleted == 0 {\n\t\treturn errors.New(\"not authenticated\")\n\t}\n\trefreshUuid, ok := ctx.Value(RefreshUuidKey).(string)\n\tif !ok {\n\t\treturn errors.New(\"refresh uuid not present in context\")\n\t}\n\tdeleted, err = deleteAuth(\"refresh_token\", refreshUuid)\n\tif err != nil || deleted == 0 {\n\t\treturn errors.New(\"not authenticated\")\n\t}\n\tcookieAccess := getCookieAccess(ctx)\n\tcookieAccess.RemoveToken(\"jwtAccess\")\n\tcookieAccess.RemoveToken(\"jwtRefresh\")\n\treturn nil\n}", "func Logout(w http.ResponseWriter, r *http.Request) {\n\tPrintln(\"Endpoint Hit: Logout\")\n\n\tsession := sessions.Start(w, r)\n\tsession.Clear()\n\tsessions.Destroy(w, r)\n\thttp.Redirect(w, r, \"/\", 302)\n}", "func (a *AllApiService) Logout(ctx _context.Context) (*_nethttp.Response, error) {\n\tvar (\n\t\tlocalVarHttpMethod = _nethttp.MethodPost\n\t\tlocalVarPostBody interface{}\n\t\tlocalVarFormFileName string\n\t\tlocalVarFileName string\n\t\tlocalVarFileBytes []byte\n\t)\n\n\t// create path and map variables\n\tlocalVarPath := a.client.cfg.BasePath + \"/logout\"\n\n\tlocalVarHeaderParams := make(map[string]string)\n\tlocalVarQueryParams := _neturl.Values{}\n\tlocalVarFormParams := _neturl.Values{}\n\n\t// to determine the Content-Type header\n\tlocalVarHttpContentTypes := []string{}\n\n\t// set Content-Type header\n\tlocalVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)\n\tif localVarHttpContentType != \"\" {\n\t\tlocalVarHeaderParams[\"Content-Type\"] = localVarHttpContentType\n\t}\n\n\t// to determine the Accept header\n\tlocalVarHttpHeaderAccepts := []string{}\n\n\t// set Accept header\n\tlocalVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)\n\tif localVarHttpHeaderAccept != \"\" {\n\t\tlocalVarHeaderParams[\"Accept\"] = localVarHttpHeaderAccept\n\t}\n\tr, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlocalVarHttpResponse, err := a.client.callAPI(r)\n\tif err != nil || localVarHttpResponse == nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tlocalVarBody, err := _ioutil.ReadAll(localVarHttpResponse.Body)\n\tlocalVarHttpResponse.Body.Close()\n\tif err != nil {\n\t\treturn localVarHttpResponse, err\n\t}\n\n\tif localVarHttpResponse.StatusCode >= 300 {\n\t\tnewErr := GenericOpenAPIError{\n\t\t\tbody: localVarBody,\n\t\t\terror: localVarHttpResponse.Status,\n\t\t}\n\t\treturn localVarHttpResponse, newErr\n\t}\n\n\treturn localVarHttpResponse, nil\n}", "func (s *Session) Logout() error { return nil }", "func (avisess *AviSession) Logout() error {\n\turl := avisess.prefix + \"logout\"\n\treq, _ := avisess.newAviRequest(\"POST\", url, nil, avisess.tenant)\n\t_, err := avisess.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (WechatWorkProvider) Logout(context *auth.Context) {\n}", "func (h *Handler) Logout(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\terr := h.Services.User.Logout(Authorized.UUID)\n\t\tif err != nil {\n\t\t\tJsonResponse(w, r, http.StatusBadRequest, \"\")\n\t\t\treturn\n\t\t}\n\t\tJsonResponse(w, r, http.StatusOK, \"success\")\n\tcase \"POST\":\n\tdefault:\n\t\tJsonResponse(w, r, http.StatusBadRequest, \"Bad Request\")\n\t}\n}", "func (nb *Newsblur) Logout(UNIMPLEMENTED) {}", "func (c *controller) Logout(ctx context.Context, request *web.Request) web.Result {\n\treturn c.service.LogoutFor(ctx, request.Params[\"broker\"], request, nil)\n}", "func (b *OGame) Logout() { b.WithPriority(taskRunner.Normal).Logout() }", "func (c *Client) Logout() (err error) {\n\t/* URL has to end in JSON, otherwise it will produce XML output */\n\treturn c.getResponse(\"/Auth/Logout/JSON\", nil, new(BaseResponse))\n}", "func logout(w http.ResponseWriter, r *http.Request) {\n\n\tsession := sessions.Start(w, r)\n\tsession.Clear()\n\tsessions.Destroy(w, r)\n\thttp.Redirect(w, r, \"/\", 302)\n\n}", "func Logout(c *gin.Context) {\n\ttokenString := util.ExtractToken(c.Request)\n\n\tau, err := util.ExtractTokenMetadata(tokenString)\n\tif err != nil {\n\t\tc.JSON(http.StatusUnauthorized, \"unauthorized\")\n\t\treturn\n\t}\n\n\tdeleted, delErr := util.DeleteAuth(au.AccessUuid)\n\tif delErr != nil || deleted == 0 { //if any goes wrong\n\t\tc.JSON(http.StatusUnauthorized, \"unauthorized\")\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, \"Successfully logged out\")\n}", "func (c *RestClient) Logout(tgt TicketGrantingTicket) error {\n\t// DELETE /cas/v1/tickets/TGT-fdsjfsdfjkalfewrihfdhfaie HTTP/1.0\n\tendpoint, err := c.urlScheme.RestLogout(string(tgt))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq, err := http.NewRequest(\"DELETE\", endpoint.String(), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif resp.StatusCode != 200 && resp.StatusCode != 204 {\n\t\treturn fmt.Errorf(\"could not destroy granting ticket %v, server returned %v\", tgt, resp.StatusCode)\n\t}\n\n\treturn nil\n}", "func logout(w http.ResponseWriter, r *http.Request) {\n LOG[INFO].Println(\"Executing Logout\")\n clearCache(w)\n cookie, _ := r.Cookie(LOGIN_COOKIE)\n cookie.MaxAge = -1\n cookie.Expires = time.Now().Add(-1 * time.Hour)\n http.SetCookie(w, cookie)\n LOG[INFO].Println(\"Successfully Logged Out\")\n http.Redirect(w, r, \"/welcome\", http.StatusSeeOther)\n}", "func (bap *BaseAuthProvider) Logout(ctx *RequestCtx) {\n\t// When this is internally called (such as user reset password, or been disabled)\n\t// ctx might be nil\n\tif ctx.Ctx != nil {\n\t\t//delete token cookie, keep uuid cookie\n\t\tWriteToCookie(ctx.Ctx, AuthTokenName, \"\")\n\t}\n\tif ctx.User != nil {\n\t\t(*bap.Mutex).Lock()\n\t\tdelete(bap.TokenCache, ctx.User.Token())\n\t\tbap.TokenToUsername.DelString(ctx.User.Token())\n\t\t(*bap.Mutex).Unlock()\n\t\tlog.Println(\"Logout:\", ctx.User.Username())\n\t}\n}", "func restLogout(w *rest.ResponseWriter, r *rest.Request) {\n\tglog.V(2).Info(\"restLogout() called.\")\n\t// Read session cookie and delete session\n\tcookie, err := r.Request.Cookie(sessionCookie)\n\tif err != nil {\n\t\tglog.V(2).Info(\"Unable to read session cookie\")\n\t} else {\n\t\tdeleteSessionT(cookie.Value)\n\t\tglog.V(2).Infof(\"Deleted session %s for explicit logout\", cookie.Value)\n\t}\n\n\t// Blank out all login cookies\n\twriteBlankCookie(w, r, auth0TokenCookie)\n\twriteBlankCookie(w, r, sessionCookie)\n\twriteBlankCookie(w, r, usernameCookie)\n\tw.WriteJson(&simpleResponse{\"Logged out\", loginLink()})\n}", "func Logout(w http.ResponseWriter, r *http.Request) {\r\n\t//Get user id of the session\r\n\tctx, cancel := context.WithTimeout(context.Background(), time.Second)\r\n\tdefer cancel()\r\n\tcookie, err := r.Cookie(\"sessionId\")\r\n\tif err != nil || cookie.Value != \"\" {\r\n\t\ttoken, _ := url.QueryUnescape(cookie.Value)\r\n\t\t_, err = AuthClient.RemoveAuthToken(ctx, &authpb.AuthToken{Token: token})\r\n\t\texpiration := time.Now()\r\n\t\tcookie := http.Cookie{Name: \"sessionId\", Path: \"/\", HttpOnly: true, Expires: expiration, MaxAge: -1}\r\n\t\thttp.SetCookie(w, &cookie)\r\n\t}\r\n\tAPIResponse(w, r, 200, \"Logout successful\", make(map[string]string))\r\n}", "func gwLogout(c *gin.Context) {\n\ts := getHostServer(c)\n\treqId := getRequestId(s, c)\n\tuser := getUser(c)\n\tcks := s.conf.Security.Auth.Cookie\n\tok := s.AuthManager.Logout(user)\n\tif !ok {\n\t\ts.RespBodyBuildFunc(http.StatusInternalServerError, reqId, \"auth logout fail\", nil)\n\t\treturn\n\t}\n\tsid, ok := getSid(s, c)\n\tif !ok {\n\t\ts.RespBodyBuildFunc(http.StatusInternalServerError, reqId, \"session store logout fail\", nil)\n\t\treturn\n\t}\n\t_ = s.SessionStateManager.Remove(sid)\n\tc.SetCookie(cks.Key, \"\", -1, cks.Path, cks.Domain, cks.Secure, cks.HttpOnly)\n}", "func (m *MockOAuther) Deauth(arg0 string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Deauth\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockAuth) Close() error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Close\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (controller *Auth) Logout() {\n\tcontroller.distroySession()\n\tcontroller.DeleteConnectionCookie()\n\tcontroller.Redirect(\"/\", 200)\n}", "func (db *MyConfigurations) logout(c echo.Context) error {\n\tfcmToken := c.Request().Header.Get(\"fcm-token\")\n\tdb.GormDB.Where(\"token = ?\", fcmToken).Delete(&models.DeviceToken{})\n\tc.SetCookie(&http.Cookie{\n\t\tName: \"Authorization\",\n\t\tValue: \"\",\n\t\tExpires: time.Now(),\n\t\tMaxAge: 0,\n\t})\n\treturn c.Redirect(http.StatusFound, \"/login\")\n}", "func (ih *ImapHandler) Logout() error {\n\tlog.Println(\"Logging out...\")\n\treturn ih.client.Logout()\n}", "func (s *statsReporterMock) Shutdown() {\n}", "func (cl *APIClient) Logout() *R.Response {\n\trr := cl.Request(map[string]string{\n\t\t\"COMMAND\": \"EndSession\",\n\t})\n\tif rr.IsSuccess() {\n\t\tcl.SetSession(\"\")\n\t}\n\treturn rr\n}", "func (c *Client) Logout(ctx context.Context, authToken *base64.Value) error {\n\treturn c.transport.Logout(ctx, authToken)\n}", "func (m *MockSession) Clear() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Clear\")\n}", "func logout(ctx context.Context) error {\n\tr := ctx.HttpRequest()\n\tsession, _ := core.GetSession(r)\n\t_, ok := session.Values[\"user\"]\n\tif ok {\n\t\tdelete(session.Values, \"user\")\n\t\tif err := session.Save(r, ctx.HttpResponseWriter()); err != nil {\n\t\t\tlog.Error(\"Unable to save session: \", err)\n\t\t}\n\t}\n\treturn goweb.Respond.WithPermanentRedirect(ctx, \"/\")\n}", "func (a *Auth) Logout(w http.ResponseWriter, r *http.Request) {\n\tu := a.userstate.Username(r)\n\ta.userstate.Logout(u)\n\ta.userstate.ClearCookie(w)\n\ta.userstate.RemoveUser(u)\n\tutil.OK(w, r)\n}", "func (b *Base) Logout() error {\n\treturn ErrFunctionNotSupported\n}", "func (m *MockMutantStorage) Shutdown() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Shutdown\")\n}", "func logout(w http.ResponseWriter, r *http.Request) {\n\n\tif isAuthorized(w, r) {\n\t\tusername, _ := r.Cookie(\"username\")\n\t\tdelete(gostuff.SessionManager, username.Value)\n\t\tcookie := http.Cookie{Name: \"username\", Value: \"0\", MaxAge: -1}\n\t\thttp.SetCookie(w, &cookie)\n\t\tcookie = http.Cookie{Name: \"sessionID\", Value: \"0\", MaxAge: -1}\n\t\thttp.SetCookie(w, &cookie)\n\t\tw.Header().Set(\"Cache-Control\", \"no-cache, no-store, must-revalidate\")\n\t\thttp.ServeFile(w, r, \"index.html\")\n\t}\n}", "func (h *UserRepos) VirtualLogout(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\n\tctxValues, err := webcontext.ContextValues(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tclaims, err := auth.ClaimsFromContext(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tsess := webcontext.ContextSession(ctx)\n\n\tvar expires time.Duration\n\tif sess != nil && sess.Options != nil {\n\t\texpires = time.Second * time.Duration(sess.Options.MaxAge)\n\t} else {\n\t\texpires = time.Hour\n\t}\n\n\ttkn, err := h.AuthRepo.VirtualLogout(ctx, claims, expires, ctxValues.Now)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Update the access token in the session.\n\tsess = webcontext.SessionUpdateAccessToken(sess, tkn.AccessToken)\n\n\t// Display a success message to verify the user has switched contexts.\n\tif claims.Subject != tkn.UserID && claims.Audience != tkn.AccountID {\n\t\tusr, err := h.UserRepo.ReadByID(ctx, claims, tkn.UserID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tacc, err := h.AccountRepo.ReadByID(ctx, claims, tkn.AccountID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\twebcontext.SessionFlashSuccess(ctx,\n\t\t\t\"Context Switched\",\n\t\t\tfmt.Sprintf(\"You are now virtually logged back into account %s user %s.\",\n\t\t\t\tacc.Response(ctx).Name, usr.Response(ctx).Name))\n\t} else if claims.Audience != tkn.AccountID {\n\t\tacc, err := h.AccountRepo.ReadByID(ctx, claims, tkn.AccountID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\twebcontext.SessionFlashSuccess(ctx,\n\t\t\t\"Context Switched\",\n\t\t\tfmt.Sprintf(\"You are now virtually logged back into account %s.\",\n\t\t\t\tacc.Response(ctx).Name))\n\t} else {\n\t\tusr, err := h.UserRepo.ReadByID(ctx, claims, tkn.UserID)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\twebcontext.SessionFlashSuccess(ctx,\n\t\t\t\"Context Switched\",\n\t\t\tfmt.Sprintf(\"You are now virtually logged back into user %s.\",\n\t\t\t\tusr.Response(ctx).Name))\n\t}\n\n\t// Write the session to the client.\n\terr = webcontext.ContextSession(ctx).Save(r, w)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Redirect the user to the dashboard with the new credentials.\n\treturn web.Redirect(ctx, w, r, \"/\", http.StatusFound)\n}", "func Logout(_ *gorm.DB, rc *redis.Client, _ http.ResponseWriter, r *http.Request, s *status.Status) (int, error) {\n\tctx := context.Background()\n\trequestUsername := getVar(r, model.UsernameVar)\n\tclaims := GetTokenClaims(ExtractToken(r))\n\ttokenUsername := fmt.Sprintf(\"%v\", claims[\"sub\"])\n\tif tokenUsername != requestUsername {\n\t\ts.Message = status.LogoutFailure\n\t\treturn http.StatusForbidden, nil\n\t}\n\ts.Code = status.SuccessCode\n\ts.Message = status.LogoutSuccess\n\trc.Del(ctx, \"access_\"+requestUsername)\n\treturn http.StatusOK, nil\n}", "func (c *Controller) AnyLogout() {\n\tc.logout()\n}", "func (a *OAuthStrategy) Logout() error {\n\taccessToken := a.AccessToken()\n\n\tif accessToken == \"\" {\n\t\treturn nil\n\t}\n\n\tif err := a.OAuthClient.RevokeToken(a.AccessToken()); err != nil {\n\t\treturn err\n\t}\n\n\ta.SetTokens(\"\", \"\")\n\n\treturn nil\n}", "func logout(c *gin.Context) {\n\t//Give the user a session\n\tsession := sessions.Default(c)\n\tclearSession(&session)\n\n\tc.Redirect(http.StatusFound, \"/\")\n}", "func Logout(origin string, o *model.OneTimePassword) error {\n\tu, err := url.Parse(origin)\n\tif err != nil {\n\t\treturn err\n\t}\n\tu.Path = path.Join(u.Path, \"housecontrol/v1/indoorauth/logout\")\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Add(\"Authorization\", o.GetAuthHeader())\n\tresp, err := client.Do(req)\n\tif err != nil && err != io.EOF {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tio.Copy(ioutil.Discard, resp.Body)\n\t// fmt.Println(\"logouted, status:\", resp.StatusCode)\n\treturn nil\n}", "func (c *Client) Logout() (*www.LogoutReply, error) {\n\tfullRoute := c.cfg.Host + www.PoliteiaWWWAPIRoute + www.RouteLogout\n\n\t// Print request details\n\tif c.cfg.Verbose {\n\t\tfmt.Printf(\"Request: POST %v\\n\", fullRoute)\n\t}\n\n\t// Create new http request instead of using makeRequest()\n\t// so that we can save the updated cookies to disk\n\treq, err := http.NewRequest(http.MethodPost, fullRoute, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treq.Header.Add(www.CsrfToken, c.cfg.CSRF)\n\n\t// Send request\n\tr, err := c.http.Do(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer func() {\n\t\tr.Body.Close()\n\t}()\n\n\tresponseBody := util.ConvertBodyToByteArray(r.Body, false)\n\n\t// Validate response status\n\tif r.StatusCode != http.StatusOK {\n\t\tvar ue www.UserError\n\t\terr = json.Unmarshal(responseBody, &ue)\n\t\tif err == nil {\n\t\t\treturn nil, fmt.Errorf(\"%v, %v %v\", r.StatusCode,\n\t\t\t\tuserErrorStatus(ue.ErrorCode), strings.Join(ue.ErrorContext, \", \"))\n\t\t}\n\n\t\treturn nil, fmt.Errorf(\"%v\", r.StatusCode)\n\t}\n\n\t// Unmarshal response\n\tvar lr www.LogoutReply\n\terr = json.Unmarshal(responseBody, &lr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal LogoutReply: %v\", err)\n\t}\n\n\t// Print response details\n\tif c.cfg.Verbose {\n\t\tfmt.Printf(\"Response: %v\\n\", r.StatusCode)\n\t\terr := prettyPrintJSON(lr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Persist cookies\n\tck := c.http.Jar.Cookies(req.URL)\n\tif err = c.cfg.SaveCookies(ck); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &lr, nil\n}", "func (m *MockEngine) Quit() error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Quit\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (am AuthManager) Logout(ctx *Ctx) error {\n\tsessionValue := am.readSessionValue(ctx)\n\t// validate the sessionValue isn't unset\n\tif len(sessionValue) == 0 {\n\t\treturn nil\n\t}\n\n\t// issue the expiration cookies to the response\n\tctx.ExpireCookie(am.CookieNameOrDefault(), am.CookiePathOrDefault())\n\tctx.Session = nil\n\n\t// call the remove handler if one has been provided\n\tif am.RemoveHandler != nil {\n\t\treturn am.RemoveHandler(ctx.Context(), sessionValue)\n\t}\n\treturn nil\n}", "func (s *server) Logout(ctx context.Context, in *pb.LogRequest) (*pb.LogResponse, error) {\n\tlog.Printf(\"Received: %v\", \"Logout\")\n\tsuc, err := DeleteToken(in.Email, in.Token)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &pb.LogResponse{Sucess: suc}, nil\n}", "func logout(w http.ResponseWriter, r *http.Request) {\n\tsession, err := store.Get(r, \"auth\")\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tsession.Values[\"user\"] = User{}\n\tsession.Options.MaxAge = -1\n\n\terr = session.Save(r, w)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tlogRequest(r)\n}", "func (m *MockSession) Cleanup() error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Cleanup\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *Repository) Logout(w http.ResponseWriter, r *http.Request) {\n\tif !m.App.Session.Exists(r.Context(), \"user_id\") {\n\t\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\t_ = m.App.Session.Destroy(r.Context())\n\t_ = m.App.Session.RenewToken(r.Context())\n\tm.App.Session.Put(r.Context(), \"flash\", \"Successfully logged out!\")\n\n\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\n}", "func (m *MockMembers) Shutdown() error {\n\tret := m.ctrl.Call(m, \"Shutdown\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func signOut(w http.ResponseWriter, r *http.Request) {\n\tlogoutUser(w, r)\n\tresp := map[string]interface{}{\n\t\t\"success\": true,\n\t}\n\tapiResponse(resp, w)\n}", "func (a *localAuth) Logout(c echo.Context) error {\n\treturn a.logout(c)\n}", "func Logout(token string) {\n\t// This might have more logic later\n\ttokenware.Revoke(token)\n}", "func (gs *GateService) Logout(ctx context.Context, opaque string) error {\n\treturn gs.repo.RemoveToken(ctx, opaque)\n}", "func (m *Model) Logout(ctx context.Context, header string) error {\n\tau, err := m.extractTokenMetadata(header)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = m.authDAO.DeleteByID(ctx, au.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Client) Logout() error {\n\t_, err := c.Exec(\"logout\")\n\treturn err\n}", "func (c *logout) execute(sess *session) *response {\n\n\tsess.st = notAuthenticated\n\treturn ok(c.tag, \"LOGOUT completed\").\n\t\textra(\"BYE IMAP4rev1 Server logging out\").\n\t\tshouldClose()\n}", "func (s *MockSession) Close() {}", "func logout(res http.ResponseWriter, req *http.Request) {\n sess := session.Get(req)\n\n session.Remove(sess, res)\n sess = nil\n\n return\n http.Redirect(res, req, \"/login\", 301)\n}", "func (a *noAuth) Logout(c echo.Context) error {\n\treturn a.logout(c)\n}", "func (connection *VSphereConnection) Logout(ctx context.Context) {\n\tclientLock.Lock()\n\tc := connection.Client\n\tclientLock.Unlock()\n\tif c == nil {\n\t\treturn\n\t}\n\n\tm := session.NewManager(c)\n\n\thasActiveSession, err := m.SessionIsActive(ctx)\n\tif err != nil {\n\t\tklog.Errorf(\"Logout failed: %s\", err)\n\t\treturn\n\t}\n\tif !hasActiveSession {\n\t\tklog.Errorf(\"No active session, cannot logout\")\n\t\treturn\n\t}\n\tif err := m.Logout(ctx); err != nil {\n\t\tklog.Errorf(\"Logout failed: %s\", err)\n\t}\n}", "func Logout(r *http.Request) {\n\ts := getSessionFromRequest(r)\n\tif s.ID == 0 {\n\t\treturn\n\t}\n\n\t// Store Logout to the user log\n\tfunc() {\n\t\tlog := &Log{}\n\t\tlog.SignIn(s.User.Username, log.Action.Logout(), r)\n\t\tlog.Save()\n\t}()\n\n\ts.Logout()\n\n\t// Delete the cookie from memory if we sessions are cached\n\tif CacheSessions {\n\t\tdelete(cachedSessions, s.Key)\n\t}\n\n\tIncrementMetric(\"uadmin/security/logout\")\n}", "func (e Expo) logout() error {\n\tcmd := command.New(\"expo\", \"logout\", \"--non-interactive\")\n\tcmd.SetStdout(os.Stdout)\n\tcmd.SetStderr(os.Stderr)\n\n\tlog.Donef(\"$ %s\", cmd.PrintableCommandArgs())\n\treturn cmd.Run()\n}", "func (m *MockShutdownable) ShutDown() {\n\tm.ctrl.Call(m, \"ShutDown\")\n}", "func (s *Handler) Logout(ctx context.Context, req *api.LogoutRequest) (*api.EmptyResponse, error) {\n\tif err := s.DaemonService.ClusterLogout(ctx, req.ClusterUri); err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\treturn &api.EmptyResponse{}, nil\n}", "func (ctrl *UserController) Logout(c *gin.Context) {\n\thttp.SetCookie(c.Writer, &http.Cookie{Path: \"/\", Name: auth.RefreshTokenKey, MaxAge: -1, Secure: true, HttpOnly: true, SameSite: http.SameSiteNoneMode})\n\thttp.SetCookie(c.Writer, &http.Cookie{Path: \"/\", Name: auth.AccessTokenKey, MaxAge: -1, Secure: true, HttpOnly: true, SameSite: http.SameSiteNoneMode})\n\n\tc.JSON(http.StatusOK, utils.Msg(\"Logged out\"))\n}", "func logoutExample() string {\n\treturn `$ pouch logout $registry\nRemove login credential for registry: $registry`\n}", "func Logout(w http.ResponseWriter, r *http.Request) {\n\tuser := r.Context().Value(utils.TokenContextKey).(string)\n\tmessage := models.Logout(user)\n\tutils.JSONResonseWithMessage(w, message)\n}", "func Logout(deleteAuthToken dependencyDeleteAuthToken) gin.HandlerFunc {\n\treturn func(c *gin.Context) {\n\t\tauthToken := c.MustGet(\"auth_token\").(models.AuthToken)\n\t\tif err := deleteAuthToken(authToken.AuthToken); err != nil {\n\t\t\tc.AbortWithError(http.StatusInternalServerError, err)\n\t\t\treturn\n\t\t}\n\n\t\tc.Status(http.StatusOK)\n\t}\n}", "func (l *RemoteProvider) Logout(w http.ResponseWriter, req *http.Request) {\n\tck, err := req.Cookie(tokenName)\n\tif err == nil {\n\t\tck.MaxAge = -1\n\t\tck.Path = \"/\"\n\t\thttp.SetCookie(w, ck)\n\t}\n\thttp.Redirect(w, req, \"/user/login\", http.StatusFound)\n}", "func AuthPhoneLogout(ctx context.Context) {\n\t// nothing to do here since stateless session\n\t// needs to be handled on the client\n\t// when there's a refresh token, we'll kill it\n}", "func (AuthenticationController) Logout(c *gin.Context) {\n\tsession := sessions.Default(c)\n\tsession.Clear()\n\tif sessionErr := session.Save(); sessionErr != nil {\n\t\tlog.Print(sessionErr)\n\t\tutils.CreateError(c, http.StatusInternalServerError, \"Failed to logout.\")\n\t\tc.Abort()\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\"message\": \"Logged out...\"})\n}", "func authLogoutHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) {\n\tauth.ClearCookie(ctx, w)\n\thttp.Redirect(w, r, rootPath, http.StatusTemporaryRedirect)\n}", "func (h *UserRepos) Logout(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error {\n\n\tsess := webcontext.ContextSession(ctx)\n\n\t// Set the access token to empty to logout the user.\n\tsess = webcontext.SessionDestroy(sess)\n\n\tif err := sess.Save(r, w); err != nil {\n\t\treturn err\n\t}\n\n\t// Redirect the user to the root page.\n\treturn web.Redirect(ctx, w, r, \"/\", http.StatusFound)\n}", "func (m *MockRepoSyncInfoKeeper) UnTrack(repos string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UnTrack\", repos)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (r *oauthProxy) logoutHandler(w http.ResponseWriter, req *http.Request) {\n\tctx, span, logger := r.traceSpan(req.Context(), \"logout handler\")\n\tif span != nil {\n\t\tdefer span.End()\n\t}\n\n\t// @step: drop the access token\n\tuser, err := r.getIdentity(req)\n\tif err != nil {\n\t\tr.errorResponse(w, req.WithContext(ctx), \"\", http.StatusBadRequest, nil)\n\t\treturn\n\t}\n\n\t// step: check if the user has a state session and if so revoke it\n\tif r.useStore() {\n\t\tgo func() {\n\t\t\tif err := r.DeleteRefreshToken(user.token); err != nil {\n\t\t\t\tlogger.Error(\"unable to remove the refresh token from store\", zap.Error(err))\n\t\t\t}\n\t\t}()\n\t}\n\n\t// step: can either use the id token or the refresh token\n\tidentityToken := user.token.Encode()\n\tif refresh, _, err := r.retrieveRefreshToken(req, user); err == nil {\n\t\tidentityToken = refresh\n\t}\n\n\tr.commonLogout(ctx, w, req, identityToken, func(w http.ResponseWriter) {\n\t\tw.Header().Set(\"Content-Type\", jsonMime)\n\t\tw.WriteHeader(http.StatusOK)\n\t}, logger.With(zap.String(\"email\", user.email)))\n}", "func (m *MockHub) Unregister(c ws.Client) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Unregister\", c)\n}", "func (s *Subject) Logout() {\n\tif s.Session != nil {\n\t\ts.Session.Clear()\n\t}\n}", "func Logout(c *gin.Context) {\n\tsession := sessions.Default(c)\n\tsession.Delete(\"user\");\n\tsession.Save();\n\tc.JSON(200, gin.H{\n\t\t\"success\": true,\n\t})\n}", "func (i *Influx) SignOut() (err error) {\n\tif _, err = i.HTTPInstance.Post(i.HTTPClient, i.GetBasicURL()+\"/signout\", nil, nil); err != nil {\n\t\treturn\n\t}\n\n\tlogrus.Info(\"Influx HTTP Client signed out\")\n\n\treturn\n}", "func cleanup(ctx context.Context, didSignOut bool, tconn *chrome.TestConn) {\n\tif didSignOut {\n\t\treturn\n\t}\n\tif err := signOut(ctx, tconn); err != nil {\n\t\ttesting.ContextLog(ctx, \"Failed to sign out during cleanup: \", err)\n\t\ttesting.ContextLog(ctx, \"The above error is likely caused by an error occurred in test body\")\n\t}\n}", "func (m *MockUpstreamIntf) Destroy() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Destroy\")\n}", "func Logout(rw http.ResponseWriter, request *http.Request) {\n\n\tlog.Println(\"call Logout\")\n\n\t// Cookieからセッション情報取得\n\tsessionID, err := request.Cookie(sessionIDName)\n\tif err != nil {\n\t\t// セッション情報取得に失敗した場合TOP画面に遷移\n\t\tlog.Println(\"Cookie 取得 失敗\")\n\t\tlog.Println(err)\n\t\t// Cookieクリア\n\t\tclearCookie(rw)\n\t\thttp.Redirect(rw, request, \"/index\", http.StatusFound)\n\t\treturn\n\t}\n\tlog.Println(\"Cookie 取得 成功\")\n\tlog.Println(\"セッション情報:\", sessionID.Value)\n\n\t// セッション情報を削除\n\tdbm := db.ConnDB()\n\t_, err = dbm.Exec(\"delete from sessions where sessionID = ?\", sessionID.Value)\n\tif err != nil {\n\t\tlog.Println(\"セッション 削除 失敗\")\n\t} else {\n\t\tlog.Println(\"セッション 削除 成功\")\n\t\tlog.Println(\"削除したセッションID:\", sessionID.Value)\n\t}\n\n\t// CookieクリアしてTOP画面表示\n\tclearCookie(rw)\n\thttp.Redirect(rw, request, \"/index\", http.StatusFound)\n}", "func (auth Authenticate) Logout(session *types.Session) error {\n\terr := manager.AccountManager{}.RemoveSession(session, auth.Cache)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}" ]
[ "0.78230685", "0.7768923", "0.7120076", "0.710372", "0.6728446", "0.65702486", "0.6540324", "0.6384043", "0.63278955", "0.61762667", "0.61235154", "0.6058738", "0.60298705", "0.6000153", "0.5989176", "0.5982589", "0.5948157", "0.5907925", "0.5906584", "0.58800757", "0.58680415", "0.5842008", "0.58362514", "0.5820402", "0.5801366", "0.5766622", "0.5760998", "0.5725791", "0.5722953", "0.56985474", "0.5673715", "0.567353", "0.5658335", "0.5642706", "0.5633698", "0.56290853", "0.56151277", "0.56114376", "0.5599975", "0.55935735", "0.55864584", "0.55834097", "0.5573138", "0.5529998", "0.552792", "0.55255955", "0.55158484", "0.55093235", "0.5508772", "0.55055016", "0.5499931", "0.54972744", "0.54952806", "0.5483775", "0.5476682", "0.547378", "0.5443089", "0.54395676", "0.5423901", "0.542128", "0.5420607", "0.5419549", "0.5410544", "0.53983796", "0.5389418", "0.53876024", "0.53860205", "0.538276", "0.53710043", "0.53675777", "0.5358866", "0.5357532", "0.5357292", "0.53509575", "0.5334948", "0.5329594", "0.5327311", "0.53197086", "0.5310694", "0.53057253", "0.530488", "0.52959526", "0.5294726", "0.5292813", "0.52905434", "0.52814174", "0.52682185", "0.5260376", "0.5258462", "0.5258152", "0.52521586", "0.52511376", "0.5249227", "0.5246871", "0.5241783", "0.5239552", "0.523858", "0.52305615", "0.5228159", "0.52241135" ]
0.7273181
2
Logout indicates an expected call of Logout
func (mr *MockServiceAuthMockRecorder) Logout(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Logout", reflect.TypeOf((*MockServiceAuth)(nil).Logout), arg0) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (nb *Newsblur) Logout(UNIMPLEMENTED) {}", "func (s *Session) Logout() error { return nil }", "func (c *Controller) Logout(ctx context.Context) (err error) {\n\t// Build request\n\treq, err := c.requestBuild(ctx, \"GET\", authenticationAPIName, \"logout\", nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"request building failure: %w\", err)\n\t}\n\t// execute auth request\n\tif err = c.requestExecute(ctx, req, nil, false); err != nil {\n\t\terr = fmt.Errorf(\"executing request failed: %w\", err)\n\t}\n\treturn\n}", "func Logout(c *gin.Context) {\n\ttokenString := util.ExtractToken(c.Request)\n\n\tau, err := util.ExtractTokenMetadata(tokenString)\n\tif err != nil {\n\t\tc.JSON(http.StatusUnauthorized, \"unauthorized\")\n\t\treturn\n\t}\n\n\tdeleted, delErr := util.DeleteAuth(au.AccessUuid)\n\tif delErr != nil || deleted == 0 { //if any goes wrong\n\t\tc.JSON(http.StatusUnauthorized, \"unauthorized\")\n\t\treturn\n\t}\n\n\tc.JSON(http.StatusOK, \"Successfully logged out\")\n}", "func (userHandlersImpl UserHandlersImpl) Logout(w http.ResponseWriter, req *http.Request) {\n\n\tresp := \"\"\n\tWriteOKResponse(w, resp)\n\n}", "func (h *Handler) Logout(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\terr := h.Services.User.Logout(Authorized.UUID)\n\t\tif err != nil {\n\t\t\tJsonResponse(w, r, http.StatusBadRequest, \"\")\n\t\t\treturn\n\t\t}\n\t\tJsonResponse(w, r, http.StatusOK, \"success\")\n\tcase \"POST\":\n\tdefault:\n\t\tJsonResponse(w, r, http.StatusBadRequest, \"Bad Request\")\n\t}\n}", "func (r *mutationResolver) Logout(ctx context.Context) (*models.Logout, error) {\n\tpanic(\"not implemented\")\n}", "func (s *AuthService) Logout(login, refreshToken string) error {\n\terr := s.client.Auth.Logout(login, refreshToken)\n\treturn err\n}", "func (avisess *AviSession) Logout() error {\n\turl := avisess.prefix + \"logout\"\n\treq, _ := avisess.newAviRequest(\"POST\", url, nil, avisess.tenant)\n\t_, err := avisess.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Client) Logout() (err error) {\n\t/* URL has to end in JSON, otherwise it will produce XML output */\n\treturn c.getResponse(\"/Auth/Logout/JSON\", nil, new(BaseResponse))\n}", "func (s *server) Logout(ctx context.Context, in *pb.LogRequest) (*pb.LogResponse, error) {\n\tlog.Printf(\"Received: %v\", \"Logout\")\n\tsuc, err := DeleteToken(in.Email, in.Token)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &pb.LogResponse{Sucess: suc}, nil\n}", "func (a *authSvc) Logout(ctx context.Context) error {\n\taccessUuid, ok := ctx.Value(AccessUuidKey).(string)\n\tif !ok {\n\t\treturn errors.New(\"access uuid not present in context\")\n\t}\n\tdeleted, err := deleteAuth(\"access_token\", accessUuid)\n\tif err != nil || deleted == 0 {\n\t\treturn errors.New(\"not authenticated\")\n\t}\n\trefreshUuid, ok := ctx.Value(RefreshUuidKey).(string)\n\tif !ok {\n\t\treturn errors.New(\"refresh uuid not present in context\")\n\t}\n\tdeleted, err = deleteAuth(\"refresh_token\", refreshUuid)\n\tif err != nil || deleted == 0 {\n\t\treturn errors.New(\"not authenticated\")\n\t}\n\tcookieAccess := getCookieAccess(ctx)\n\tcookieAccess.RemoveToken(\"jwtAccess\")\n\tcookieAccess.RemoveToken(\"jwtRefresh\")\n\treturn nil\n}", "func (m *TestFixClient) OnLogout(sessionID fix.SessionID) {\n\tlog.Printf(\"[FIX %s] MockFix.OnLogout: %s\", m.name, sessionID)\n\tm.Sessions[sessionID.String()].LoggedOn = false\n}", "func signOut(w http.ResponseWriter, r *http.Request) {\n\tlogoutUser(w, r)\n\tresp := map[string]interface{}{\n\t\t\"success\": true,\n\t}\n\tapiResponse(resp, w)\n}", "func (WechatWorkProvider) Logout(context *auth.Context) {\n}", "func (c *yorcProviderClient) Logout() error {\n\trequest, err := http.NewRequest(\"POST\", fmt.Sprintf(\"%s/logout\", c.client.baseURL), nil)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\trequest.Header.Add(\"Accept\", \"application/json\")\n\trequest.Header.Set(\"Connection\", \"close\")\n\n\trequest.Close = true\n\n\tresponse, err := c.client.Client.Do(request)\n\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer response.Body.Close()\n\n\tif response.StatusCode != http.StatusOK {\n\t\treturn getError(response.Body)\n\t}\n\n\treturn nil\n}", "func Logout(w http.ResponseWriter, r *http.Request) {\n\tPrintln(\"Endpoint Hit: Logout\")\n\n\tsession := sessions.Start(w, r)\n\tsession.Clear()\n\tsessions.Destroy(w, r)\n\thttp.Redirect(w, r, \"/\", 302)\n}", "func (b *OGame) Logout() { b.WithPriority(taskRunner.Normal).Logout() }", "func (c *controller) Logout(ctx context.Context, request *web.Request) web.Result {\n\treturn c.service.LogoutFor(ctx, request.Params[\"broker\"], request, nil)\n}", "func Logout(w http.ResponseWriter, r *http.Request) {\n\tuser := r.Context().Value(utils.TokenContextKey).(string)\n\tmessage := models.Logout(user)\n\tutils.JSONResonseWithMessage(w, message)\n}", "func (ih *ImapHandler) Logout() error {\n\tlog.Println(\"Logging out...\")\n\treturn ih.client.Logout()\n}", "func Test_LogoutInvalidToken(t *testing.T) {\n\tdir, err := tempConfig(\"\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer os.RemoveAll(dir)\n\n\tmockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusUnauthorized)\n\t\tw.Write([]byte(``))\n\t}))\n\tdefer mockServer.Close()\n\n\tlogoutArgs := logoutArguments{\n\t\tapiEndpoint: mockServer.URL,\n\t\ttoken: \"test-token\",\n\t}\n\n\terr = logout(logoutArgs)\n\tif !IsNotAuthorizedError(err) {\n\t\tt.Errorf(\"Unexpected error: %s\", err)\n\t}\n}", "func logoutExample() string {\n\treturn `$ pouch logout $registry\nRemove login credential for registry: $registry`\n}", "func supervisorLogout(c *cli.Context) error {\n\tif err := adm.VerifyNoArgument(c); err != nil {\n\t\treturn err\n\t}\n\n\tif c.GlobalBool(`doublelogout`) {\n\t\treturn adm.MockOK(`command`, c)\n\t}\n\n\tvar path string\n\tswitch c.Bool(`all`) {\n\tcase true:\n\t\tpath = `/tokens/self/all`\n\tcase false:\n\t\tpath = `/tokens/self/active`\n\t}\n\treturn adm.Perform(`delete`, path, `command`, nil, c)\n}", "func Logout(res http.ResponseWriter, req *http.Request) {\n\ttokenID := req.Context().Value(\"tokenID\").(string)\n\tresponse := make(map[string]interface{})\n\tmsg := constants.Logout\n\t_, err := connectors.RemoveDocument(\"tokens\", tokenID)\n\tif err != nil {\n\t\trender.Render(res, req, responses.NewHTTPError(http.StatusServiceUnavailable, constants.Unavailable))\n\t\treturn\n\t}\n\tresponse[\"message\"] = msg\n\trender.Render(res, req, responses.NewHTTPSucess(http.StatusOK, response))\n}", "func Logout(origin string, o *model.OneTimePassword) error {\n\tu, err := url.Parse(origin)\n\tif err != nil {\n\t\treturn err\n\t}\n\tu.Path = path.Join(u.Path, \"housecontrol/v1/indoorauth/logout\")\n\treq, err := http.NewRequest(\"GET\", u.String(), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Add(\"Authorization\", o.GetAuthHeader())\n\tresp, err := client.Do(req)\n\tif err != nil && err != io.EOF {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tio.Copy(ioutil.Discard, resp.Body)\n\t// fmt.Println(\"logouted, status:\", resp.StatusCode)\n\treturn nil\n}", "func (a *noAuth) Logout(c echo.Context) error {\n\treturn a.logout(c)\n}", "func (a *Auth) Logout(w http.ResponseWriter, r *http.Request) {\n\tu := a.userstate.Username(r)\n\ta.userstate.Logout(u)\n\ta.userstate.ClearCookie(w)\n\ta.userstate.RemoveUser(u)\n\tutil.OK(w, r)\n}", "func Logout(_ *gorm.DB, rc *redis.Client, _ http.ResponseWriter, r *http.Request, s *status.Status) (int, error) {\n\tctx := context.Background()\n\trequestUsername := getVar(r, model.UsernameVar)\n\tclaims := GetTokenClaims(ExtractToken(r))\n\ttokenUsername := fmt.Sprintf(\"%v\", claims[\"sub\"])\n\tif tokenUsername != requestUsername {\n\t\ts.Message = status.LogoutFailure\n\t\treturn http.StatusForbidden, nil\n\t}\n\ts.Code = status.SuccessCode\n\ts.Message = status.LogoutSuccess\n\trc.Del(ctx, \"access_\"+requestUsername)\n\treturn http.StatusOK, nil\n}", "func (u *Users) LogOut() {\n\tu.deauthorizeUser()\n\tu.serveAJAXSuccess(nil)\n}", "func getLogout(s *Setup) func(w http.ResponseWriter, r *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tvar response jSendResponse\n\t\tstatusCode := http.StatusOK\n\t\tresponse.Status = \"fail\"\n\n\t\terr := invalidateAttachedToken(r, s)\n\t\tif err != nil {\n\t\t\ts.Logger.Printf(\"logout failed because: %v\", err)\n\t\t\tresponse.Status = \"error\"\n\t\t\tresponse.Message = \"server error when logging out\"\n\t\t\tstatusCode = http.StatusInternalServerError\n\t\t} else {\n\t\t\tresponse.Status = \"success\"\n\t\t\ts.Logger.Printf(\"token was invalidated\")\n\t\t}\n\t\twriteResponseToWriter(response, w, statusCode)\n\t}\n}", "func (client *Client) Logout() error {\n\t_, err := client.SendQuery(NewLogoutQuery())\n\treturn err\n}", "func (cl *APIClient) Logout() *R.Response {\n\trr := cl.Request(map[string]string{\n\t\t\"COMMAND\": \"EndSession\",\n\t})\n\tif rr.IsSuccess() {\n\t\tcl.SetSession(\"\")\n\t}\n\treturn rr\n}", "func (c *Client) Logout(ctx context.Context, authToken *base64.Value) error {\n\treturn c.transport.Logout(ctx, authToken)\n}", "func TestLoginWrapper_LoggedOut(t *testing.T) {\n\tw, r, c := initTestRequestParams(t, nil)\n\tdefer c.Close()\n\n\tdummyLoginHandler(&requestParams{w: w, r: r, c: c})\n\n\texpectCode(t, http.StatusUnauthorized, w)\n\texpectBody(t, \"\", w)\n}", "func (s *Handler) Logout(ctx context.Context, req *api.LogoutRequest) (*api.EmptyResponse, error) {\n\tif err := s.DaemonService.ClusterLogout(ctx, req.ClusterUri); err != nil {\n\t\treturn nil, trace.Wrap(err)\n\t}\n\n\treturn &api.EmptyResponse{}, nil\n}", "func (connection *VSphereConnection) Logout(ctx context.Context) {\n\tclientLock.Lock()\n\tc := connection.Client\n\tclientLock.Unlock()\n\tif c == nil {\n\t\treturn\n\t}\n\n\tm := session.NewManager(c)\n\n\thasActiveSession, err := m.SessionIsActive(ctx)\n\tif err != nil {\n\t\tklog.Errorf(\"Logout failed: %s\", err)\n\t\treturn\n\t}\n\tif !hasActiveSession {\n\t\tklog.Errorf(\"No active session, cannot logout\")\n\t\treturn\n\t}\n\tif err := m.Logout(ctx); err != nil {\n\t\tklog.Errorf(\"Logout failed: %s\", err)\n\t}\n}", "func (c *Client) Logout() error {\n\t_, err := c.Exec(\"logout\")\n\treturn err\n}", "func (mod *backendModule) Logout(uid int64) error {\n\tm := &gatepb.Logout{\n\t\tUid: uid,\n\t}\n\treturn mod.send(m.Typeof(), m)\n}", "func (u *UserController) Logout(c *gin.Context) {\n\trequestID := requestid.Get(c)\n\tau, err := helpers.ExtractTokenMetadata(c.Request, requestID)\n\tif err != nil {\n\t\tlogger.Error(logoutLogTag, requestID, \"Unable to extract token metadata on logout system, error: %+v\", err)\n\t\tc.JSON(http.StatusUnauthorized, \"unauthorized\")\n\t\treturn\n\t}\n\tdeleted, delErr := helpers.DeleteAuth(au.AccessUUID)\n\tif delErr != nil || deleted == 0 {\n\t\tlogger.Error(logoutLogTag, requestID, \"Unable to delete auth on logout system, error: %+v, deleted: %d\", delErr, deleted)\n\t\tc.JSON(http.StatusUnauthorized, \"user already logout\")\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, \"Successfully logged out\")\n}", "func (bap *BaseAuthProvider) Logout(ctx *RequestCtx) {\n\t// When this is internally called (such as user reset password, or been disabled)\n\t// ctx might be nil\n\tif ctx.Ctx != nil {\n\t\t//delete token cookie, keep uuid cookie\n\t\tWriteToCookie(ctx.Ctx, AuthTokenName, \"\")\n\t}\n\tif ctx.User != nil {\n\t\t(*bap.Mutex).Lock()\n\t\tdelete(bap.TokenCache, ctx.User.Token())\n\t\tbap.TokenToUsername.DelString(ctx.User.Token())\n\t\t(*bap.Mutex).Unlock()\n\t\tlog.Println(\"Logout:\", ctx.User.Username())\n\t}\n}", "func (m *MockAuthService) Logout(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Logout\", arg0, arg1)\n}", "func Test_LogoutCommand(t *testing.T) {\n\tdir, err := tempConfig(\"\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer os.RemoveAll(dir)\n\n\tmockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tw.Write([]byte(`{\"status_code\": 10007, \"status_text\": \"Resource deleted\"}`))\n\t}))\n\tdefer mockServer.Close()\n\n\tcmdAPIEndpoint = mockServer.URL\n\tcmdToken = \"some-token\"\n\tlogoutValidationOutput(LogoutCommand, []string{})\n\tlogoutOutput(LogoutCommand, []string{})\n}", "func Logout(r *http.Request) {\n\ts := getSessionFromRequest(r)\n\tif s.ID == 0 {\n\t\treturn\n\t}\n\n\t// Store Logout to the user log\n\tfunc() {\n\t\tlog := &Log{}\n\t\tlog.SignIn(s.User.Username, log.Action.Logout(), r)\n\t\tlog.Save()\n\t}()\n\n\ts.Logout()\n\n\t// Delete the cookie from memory if we sessions are cached\n\tif CacheSessions {\n\t\tdelete(cachedSessions, s.Key)\n\t}\n\n\tIncrementMetric(\"uadmin/security/logout\")\n}", "func Logout(ctx context.Context, chromeURL string, cnf *LogoutConfig) error {\n\t//\n\t// Step 1. Validate input parameters.\n\t//\n\tif cnf.Endpoint == \"\" {\n\t\treturn errors.New(errors.KindEndpointMissed, \"OpenID Connect endpoint is missed\")\n\t}\n\tendpoint, err := url.Parse(cnf.Endpoint)\n\tif err != nil {\n\t\treturn errors.New(errors.KindEndpointInvalid, \"OpenID Connect endpoint has an invalid value\")\n\t}\n\tif cnf.IDToken == \"\" {\n\t\treturn errors.New(errors.KindIDTokenMissed, \"ID token is missed\")\n\t}\n\n\t//\n\t// Step 2. Initialize Chrome connection.\n\t//\n\tvar cancel context.CancelFunc\n\tif ctx, cancel, err = chrome.ConnectWithContext(ctx, chromeURL, chrome.DomainNetwork); err != nil {\n\t\treturn errors.Wrap(err, \"connect to chrome\")\n\t}\n\tdefer cancel()\n\n\tnavHistory, err := chrome.NewNavHistory(ctx)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"initialize navigation history\")\n\t}\n\n\t//\n\t// Step 3. Navigate to the OpenID Connect Provider's logout page, and process result.\n\t//\n\tlogoutURL := buildLogoutURL(endpoint, cnf.IDToken)\n\tdebugger := log.DebuggerFromContext(ctx)\n\tdebugger.Debugf(\"Navigate to the logout page %q\\n\", logoutURL)\n\tif err = chrome.Navigate(ctx, logoutURL); err != nil {\n\t\treturn errors.Wrap(err, \"navigate to the logout page\")\n\t}\n\tif err = extractOIDCError(navHistory.Last()); err != nil {\n\t\treturn err\n\t}\n\tdebugger.Debugln(`Logged out`)\n\treturn nil\n}", "func (c *Client) Logout() (string, error) {\n\n\tif c.auth == nil {\n\t\treturn \"Was not logged in\", nil\n\t}\n\n\trequest, _ := http.NewRequest(\"POST\", c.getUrl()+\"/api/v1/logout\", nil)\n\n\tresponse := new(logoutResponse)\n\n\tif err := c.doRequest(request, response); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif response.Status == \"success\" {\n\t\treturn response.Data.Message, nil\n\t} else {\n\t\treturn \"\", errors.New(\"Response status: \" + response.Status)\n\t}\n}", "func (c *RestClient) Logout(tgt TicketGrantingTicket) error {\n\t// DELETE /cas/v1/tickets/TGT-fdsjfsdfjkalfewrihfdhfaie HTTP/1.0\n\tendpoint, err := c.urlScheme.RestLogout(string(tgt))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treq, err := http.NewRequest(\"DELETE\", endpoint.String(), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresp, err := c.client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif resp.StatusCode != 200 && resp.StatusCode != 204 {\n\t\treturn fmt.Errorf(\"could not destroy granting ticket %v, server returned %v\", tgt, resp.StatusCode)\n\t}\n\n\treturn nil\n}", "func Logout(token string) {\n\t// This might have more logic later\n\ttokenware.Revoke(token)\n}", "func (gs *GateService) Logout(ctx context.Context, opaque string) error {\n\treturn gs.repo.RemoveToken(ctx, opaque)\n}", "func (c *Controller) AnyLogout() {\n\tc.logout()\n}", "func Test_LogoutValidToken(t *testing.T) {\n\tdir, err := tempConfig(\"\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\tdefer os.RemoveAll(dir)\n\n\tmockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(http.StatusOK)\n\t\tw.Write([]byte(`{\"status_code\": 10007, \"status_text\": \"Resource deleted\"}`))\n\t}))\n\tdefer mockServer.Close()\n\n\tlogoutArgs := logoutArguments{\n\t\tapiEndpoint: mockServer.URL,\n\t\ttoken: \"test-token\",\n\t}\n\n\terr = logout(logoutArgs)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}", "func (s *Service) Logout(token string) bool {\n\treturn s.jwt.DeleteJwt(token)\n}", "func Logout(w http.ResponseWriter, req *http.Request) {\n\tif !requirePost(w, req) {\n\t\tlog.Warn(\"Logout request should use POST method\")\n\t\treturn\n\t}\n\tif !requireAuth(w, req) {\n\t\tlog.Warn(\"Logout request should be authenticated\")\n\t\treturn\n\t}\n\tsid := req.Context().Value(auth.SESSION_ID).(string)\n\terr := storage.DeleteSession(sid)\n\tif err != nil {\n\t\tlog.Error(err)\n\t}\n\tconf.RedirectTo(\"/\", \"\", w, req)\n}", "func (c *UCSClient) Logout() {\n\tif c.IsLoggedIn() {\n\t\tc.Logger.Debug(\"Logging out\\n\")\n\t\treq := ucs.LogoutRequest{\n\t\t\tCookie: c.cookie,\n\t\t}\n\t\tpayload, err := req.Marshal()\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\n\t\tc.Post(payload)\n\t\tc.cookie = \"\"\n\t\tc.outDomains = \"\"\n\t}\n\tc.Logger.Info(\"Logged out\\n\")\n}", "func SSOLogout(w http.ResponseWriter, r *http.Request) {\n\tsession := configure.GetSession(r)\n\tif auth, ok := session.Values[\"authenticated\"].(bool); !ok || !auth {\n\t\tlog.Println(\"Logout by unauthenticated user\")\n\t\thttp.Redirect(w, r, configure.AppProperties.LogoutRedirectURL, 301)\n\t\treturn\n\t}\n\tsid := session.Values[\"sid\"].(string)\n\tlogoutURL := service.GetLogoutURL(sid)\n\tsession.Options.MaxAge = -1\n\tsession.Save(r, w)\n\tlog.Println(\"Logout from sparcs.org, logoutURL \", logoutURL)\n\thttp.Redirect(w, r, logoutURL, 301)\n}", "func (a *localAuth) Logout(c echo.Context) error {\n\treturn a.logout(c)\n}", "func (mr *MockHandlerMockRecorder) Logout(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Logout\", reflect.TypeOf((*MockHandler)(nil).Logout), arg0, arg1)\n}", "func Logout(w http.ResponseWriter, r *http.Request) {\r\n\t//Get user id of the session\r\n\tctx, cancel := context.WithTimeout(context.Background(), time.Second)\r\n\tdefer cancel()\r\n\tcookie, err := r.Cookie(\"sessionId\")\r\n\tif err != nil || cookie.Value != \"\" {\r\n\t\ttoken, _ := url.QueryUnescape(cookie.Value)\r\n\t\t_, err = AuthClient.RemoveAuthToken(ctx, &authpb.AuthToken{Token: token})\r\n\t\texpiration := time.Now()\r\n\t\tcookie := http.Cookie{Name: \"sessionId\", Path: \"/\", HttpOnly: true, Expires: expiration, MaxAge: -1}\r\n\t\thttp.SetCookie(w, &cookie)\r\n\t}\r\n\tAPIResponse(w, r, 200, \"Logout successful\", make(map[string]string))\r\n}", "func signOut(ctx context.Context, tconn *chrome.TestConn) error {\n\tctx, cancel := context.WithTimeout(ctx, signoutTimeout)\n\tdefer cancel()\n\n\tsm, err := session.NewSessionManager(ctx)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to connect to SessionManager\")\n\t}\n\n\tsw, err := sm.WatchSessionStateChanged(ctx, \"stopped\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to watch for session state change D-Bus signal\")\n\t}\n\tdefer sw.Close(ctx)\n\n\tif err := quicksettings.SignOut(ctx, tconn); err != nil {\n\t\treturn errors.Wrap(err, \"failed to sign out with quick settings\")\n\t}\n\n\tselect {\n\tcase <-sw.Signals:\n\t\ttesting.ContextLog(ctx, \"Session stopped\")\n\tcase <-ctx.Done():\n\t\treturn errors.New(\"Timed out waiting for session state signal\")\n\t}\n\treturn nil\n}", "func (wac *Conn) Logout() error {\n\tlogin := []interface{}{\"admin\", \"Conn\", \"disconnect\"}\n\t_, err := wac.writeJson(login)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing logout: %v\\n\", err)\n\t}\n\n\twac.loggedIn = false\n\n\treturn nil\n}", "func (AuthenticationController) Logout(c *gin.Context) {\n\tsession := sessions.Default(c)\n\tsession.Clear()\n\tif sessionErr := session.Save(); sessionErr != nil {\n\t\tlog.Print(sessionErr)\n\t\tutils.CreateError(c, http.StatusInternalServerError, \"Failed to logout.\")\n\t\tc.Abort()\n\t\treturn\n\t}\n\tc.JSON(http.StatusOK, gin.H{\"message\": \"Logged out...\"})\n}", "func (c *ServerConn) Logout() error {\n\t_, _, err := c.cmd(StatusReady, \"REIN\")\n\treturn err\n}", "func (s *Subject) Logout() {\n\tif s.Session != nil {\n\t\ts.Session.Clear()\n\t}\n}", "func (mr *MockUserUseCaseMockRecorder) Logout(sid interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Logout\", reflect.TypeOf((*MockUserUseCase)(nil).Logout), sid)\n}", "func (a *OAuthStrategy) Logout() error {\n\taccessToken := a.AccessToken()\n\n\tif accessToken == \"\" {\n\t\treturn nil\n\t}\n\n\tif err := a.OAuthClient.RevokeToken(a.AccessToken()); err != nil {\n\t\treturn err\n\t}\n\n\ta.SetTokens(\"\", \"\")\n\n\treturn nil\n}", "func (mr *MockAuthServiceMockRecorder) Logout(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Logout\", reflect.TypeOf((*MockAuthService)(nil).Logout), arg0, arg1)\n}", "func Logout(c *gin.Context) {\n\tsession := sessions.Default(c)\n\tsession.Delete(\"user\");\n\tsession.Save();\n\tc.JSON(200, gin.H{\n\t\t\"success\": true,\n\t})\n}", "func (am AuthManager) Logout(ctx *Ctx) error {\n\tsessionValue := am.readSessionValue(ctx)\n\t// validate the sessionValue isn't unset\n\tif len(sessionValue) == 0 {\n\t\treturn nil\n\t}\n\n\t// issue the expiration cookies to the response\n\tctx.ExpireCookie(am.CookieNameOrDefault(), am.CookiePathOrDefault())\n\tctx.Session = nil\n\n\t// call the remove handler if one has been provided\n\tif am.RemoveHandler != nil {\n\t\treturn am.RemoveHandler(ctx.Context(), sessionValue)\n\t}\n\treturn nil\n}", "func Logout(res http.ResponseWriter, req *http.Request) {\n\t_, ok := cookiesManager.GetCookieValue(req, CookieName)\n\tif ok {\n\t\t// cbs.SessionManager.RemoveSession(uuid)\n\t\tcookiesManager.RemoveCookie(res, CookieName)\n\t} else {\n\t\tlog.Trace(\"Logging out without the cookie\")\n\t}\n}", "func (controller *Auth) Logout() {\n\tcontroller.distroySession()\n\tcontroller.DeleteConnectionCookie()\n\tcontroller.Redirect(\"/\", 200)\n}", "func logOut(res http.ResponseWriter, req *http.Request) {\n\tinvalidateCookie(res)\n\tfmt.Fprintf(\n\t\tres,\n\t\t`<html>\n\t\t<head>\n\t\t<META http-equiv=\"refresh\" content=\"10;URL=/index.html\">\n\t\t<body>\n\t\t<p>Good-bye.</p>\n\t\t</body>\n\t\t</html>`,\n\t)\n}", "func (m *MockHandler) Logout(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Logout\", arg0, arg1)\n}", "func (s *UserServer) Logout(ctx context.Context, token *pb.Token) (*pb.Status, error) {\n\tvar err error\n\tdefer func() {\n\t\tif err != nil {\n\t\t\tutils.GetLog().Error(\"rpc.user.Logout error: %+v\", err)\n\t\t}\n\t}()\n\n\tout := users.NewLogout(token.Token)\n\tif err := out.Do(); err != nil {\n\t\treturn nil, errors.New(out.ErrorCode().String())\n\t}\n\treturn &pb.Status{Success: true}, nil\n}", "func Logout(rw http.ResponseWriter, request *http.Request) {\n\n\tlog.Println(\"call Logout\")\n\n\t// Cookieからセッション情報取得\n\tsessionID, err := request.Cookie(sessionIDName)\n\tif err != nil {\n\t\t// セッション情報取得に失敗した場合TOP画面に遷移\n\t\tlog.Println(\"Cookie 取得 失敗\")\n\t\tlog.Println(err)\n\t\t// Cookieクリア\n\t\tclearCookie(rw)\n\t\thttp.Redirect(rw, request, \"/index\", http.StatusFound)\n\t\treturn\n\t}\n\tlog.Println(\"Cookie 取得 成功\")\n\tlog.Println(\"セッション情報:\", sessionID.Value)\n\n\t// セッション情報を削除\n\tdbm := db.ConnDB()\n\t_, err = dbm.Exec(\"delete from sessions where sessionID = ?\", sessionID.Value)\n\tif err != nil {\n\t\tlog.Println(\"セッション 削除 失敗\")\n\t} else {\n\t\tlog.Println(\"セッション 削除 成功\")\n\t\tlog.Println(\"削除したセッションID:\", sessionID.Value)\n\t}\n\n\t// CookieクリアしてTOP画面表示\n\tclearCookie(rw)\n\thttp.Redirect(rw, request, \"/index\", http.StatusFound)\n}", "func Logout(app *aero.Application, authLog *log.Log) {\n\tapp.Get(\"/logout\", func(ctx aero.Context) error {\n\t\tif ctx.HasSession() {\n\t\t\tuser := arn.GetUserFromContext(ctx)\n\n\t\t\tif user != nil {\n\t\t\t\tauthLog.Info(\"%s logged out | %s | %s | %s | %s\", user.Nick, user.ID, ctx.IP(), user.Email, user.RealName())\n\t\t\t}\n\n\t\t\tctx.Session().Delete(\"userId\")\n\t\t}\n\n\t\treturn ctx.Redirect(http.StatusTemporaryRedirect, \"/\")\n\t})\n}", "func (u *MyUserModel) Logout() {\n\t// Remove from logged-in user's list\n\t// etc ...\n\tu.authenticated = false\n}", "func (ctrl *UserController) Logout(c *gin.Context) {\n\thttp.SetCookie(c.Writer, &http.Cookie{Path: \"/\", Name: auth.RefreshTokenKey, MaxAge: -1, Secure: true, HttpOnly: true, SameSite: http.SameSiteNoneMode})\n\thttp.SetCookie(c.Writer, &http.Cookie{Path: \"/\", Name: auth.AccessTokenKey, MaxAge: -1, Secure: true, HttpOnly: true, SameSite: http.SameSiteNoneMode})\n\n\tc.JSON(http.StatusOK, utils.Msg(\"Logged out\"))\n}", "func (app *application) postLogout(w http.ResponseWriter, r *http.Request) {\n\t// \"log out\" the user by removing their ID from the session\n\trowid := app.session.PopInt(r, \"authenticatedPlayerID\")\n\tapp.players.UpdateLogin(rowid, false)\n\tapp.session.Put(r, \"flash\", \"You've been logged out successfully\")\n\thttp.Redirect(w, r, \"/login\", 303)\n}", "func LogoutHandler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"logout\")\n}", "func Logout(w http.ResponseWriter, r *http.Request) {\n\t// TODO JvD: revoke the token?\n\thttp.Redirect(w, r, \"/login\", http.StatusFound)\n}", "func (s *ServerConnection) Logout() error {\n\t_, err := s.CallRaw(\"Session.logout\", nil)\n\treturn err\n}", "func (c *Client) Logout(ctx context.Context) error {\n\treq := c.Resource(internal.SessionPath).Request(http.MethodDelete)\n\treturn c.Do(ctx, req, nil)\n}", "func logout(ctx context.Context) error {\n\tr := ctx.HttpRequest()\n\tsession, _ := core.GetSession(r)\n\t_, ok := session.Values[\"user\"]\n\tif ok {\n\t\tdelete(session.Values, \"user\")\n\t\tif err := session.Save(r, ctx.HttpResponseWriter()); err != nil {\n\t\t\tlog.Error(\"Unable to save session: \", err)\n\t\t}\n\t}\n\treturn goweb.Respond.WithPermanentRedirect(ctx, \"/\")\n}", "func UserLogout(w http.ResponseWriter, r *http.Request) {\n\t_ = SessionDel(w, r, \"user\")\n\tutils.SuccessResponse(&w, \"登出成功\", \"\")\n}", "func (c UserInfo) Logout() revel.Result {\n\tc.Session.Del(\"DiscordUserID\")\n\tc.Response.Status = 200\n\treturn c.Render()\n}", "func DoSamlLogout(w http.ResponseWriter, r *http.Request) {\n\tif server.SamlServiceProvider != nil {\n\t\tif server.SamlServiceProvider.ServiceProvider.IDPMetadata != nil {\n\t\t\tentityID := server.SamlServiceProvider.ServiceProvider.IDPMetadata.EntityID\n\t\t\tentityURL, _ := url.Parse(entityID)\n\t\t\tredirectURL := entityURL.Scheme + \"://\" + entityURL.Host + \"/idp/profile/Logout\"\n\t\t\tlog.Debugf(\"redirecting the user to %v\", redirectURL)\n\t\t\thttp.Redirect(w, r, redirectURL, http.StatusFound)\n\t\t\treturn\n\t\t}\n\t\tlog.Info(\"No Logout URL - Saml/Shibboleth IDPMetadata not found\")\n\t} else {\n\t\tlog.Info(\"No Logout URL - Saml/Shibboleth provider is not configured\")\n\t}\n}", "func (u *USER_DB) Logout() {\n\t// Remove from logged-in user's list\n\t// etc ...\n\tu.authenticated = false\n}", "func gwLogout(c *gin.Context) {\n\ts := getHostServer(c)\n\treqId := getRequestId(s, c)\n\tuser := getUser(c)\n\tcks := s.conf.Security.Auth.Cookie\n\tok := s.AuthManager.Logout(user)\n\tif !ok {\n\t\ts.RespBodyBuildFunc(http.StatusInternalServerError, reqId, \"auth logout fail\", nil)\n\t\treturn\n\t}\n\tsid, ok := getSid(s, c)\n\tif !ok {\n\t\ts.RespBodyBuildFunc(http.StatusInternalServerError, reqId, \"session store logout fail\", nil)\n\t\treturn\n\t}\n\t_ = s.SessionStateManager.Remove(sid)\n\tc.SetCookie(cks.Key, \"\", -1, cks.Path, cks.Domain, cks.Secure, cks.HttpOnly)\n}", "func (m *Repository) Logout(w http.ResponseWriter, r *http.Request) {\n\tif !m.App.Session.Exists(r.Context(), \"user_id\") {\n\t\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\n\t\treturn\n\t}\n\n\t_ = m.App.Session.Destroy(r.Context())\n\t_ = m.App.Session.RenewToken(r.Context())\n\tm.App.Session.Put(r.Context(), \"flash\", \"Successfully logged out!\")\n\n\thttp.Redirect(w, r, \"/\", http.StatusSeeOther)\n}", "func AuthPhoneLogout(ctx context.Context) {\n\t// nothing to do here since stateless session\n\t// needs to be handled on the client\n\t// when there's a refresh token, we'll kill it\n}", "func (auth Authenticate) Logout(session *types.Session) error {\n\terr := manager.AccountManager{}.RemoveSession(session, auth.Cache)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func (c *logout) execute(sess *session) *response {\n\n\tsess.st = notAuthenticated\n\treturn ok(c.tag, \"LOGOUT completed\").\n\t\textra(\"BYE IMAP4rev1 Server logging out\").\n\t\tshouldClose()\n}", "func HandlerLogout(responseWriter http.ResponseWriter, request *http.Request) {\n\trequest.ParseForm()\n\n\tif !(IsTokenValid(responseWriter, request)) {\n\t\treturn\n\t}\n\n\tAddCookie(responseWriter, \"no token\")\n\tServeLogin(responseWriter, STR_EMPTY)\n}", "func (router *router) SignOut(w http.ResponseWriter, r *http.Request) {\n\trouter.log.Println(\"request received at endpoint: SignOut\")\n\tif session.IsAuthenticated(w, r) {\n\t\trouter.database.Delete(&schema.Favourite{User: session.GetUser(w, r)})\n\t\tsession.SignOut(w, r)\n\t\trouter.log.Println(\"sign out completed redirecting to home page\")\n\t} else {\n\t\trouter.log.Println(\"Not signed in to sign out, redirecting to home page\")\n\t}\n\n\tHomePage(w, r)\n\treturn\n}", "func Logout(c buffalo.Context) error {\n\tsessionID := c.Value(\"SessionID\").(int)\n\tadmin := c.Value(\"Admin\")\n\tif admin != nil {\n\t\t// \"log out\" by unscoping out auth token\n\t\ttoken, err := utils.GenerateScopedToken(admin.(string), 0, sessionID)\n\t\tif err != nil {\n\t\t\treturn c.Error(http.StatusBadRequest, err)\n\t\t}\n\t\treturn c.Render(http.StatusOK, render.JSON(&common.TokenPayload{\n\t\t\tToken: token,\n\t\t}))\n\t}\n\tif err := modelext.DeleteUserSession(c, sessionID); err != nil {\n\t\treturn c.Error(http.StatusInternalServerError, err)\n\t}\n\treturn c.Render(http.StatusOK, render.JSON(&common.TokenPayload{\n\t\tToken: \"\",\n\t}))\n}", "func (c *Client) Logout() (err error) {\n\ttag, err := c.prepareCmd(\"LOGOUT\")\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer c.cleanCmd()\n\n\terr = c.writeString(tag + \" LOGOUT\\r\\n\")\n\tif err != nil {\n\t\treturn\n\t}\n\n\trep := <-c.rep\n\tif rep == nil {\n\t\terr = ErrNilRep\n\t\treturn\n\t}\n\tif rep.err != nil {\n\t\terr = rep.err\n\t\treturn\n\t}\n\treturn\n}", "func (m *Model) Logout(ctx context.Context, header string) error {\n\tau, err := m.extractTokenMetadata(header)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = m.authDAO.DeleteByID(ctx, au.ID)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (u *User) Logout() {\n\t// Remove from logged-in user's list\n\t// etc ...\n\tu.authenticated = false\n}", "func Logout(r * http.Request, response * APIResponse) {\n\tuser := UserForName(r.FormValue(\"username\"))\n\tresponse.Message = \"Logout \" + r.FormValue(\"username\")\n\tfor i := 0; i < len(Keys); i++ {\n\t\tif Keys[i].Key == r.FormValue(\"key\") && Keys[i].User == user.ID {\n\t\t\tKeys[i].EndTime = Keys[i].StartTime\n\t\t\tSaveDatabase(&Keys, \"keys\")\n\t\t\tbreak\n\t\t}\n\t}\n}", "func (as *AdminServer) Logout(w http.ResponseWriter, r *http.Request) {\n\tsession := ctx.Get(r, \"session\").(*sessions.Session)\n\tdelete(session.Values, \"id\")\n\tFlash(w, r, \"success\", \"You have successfully logged out\")\n\tsession.Save(r, w)\n\thttp.Redirect(w, r, \"/login\", http.StatusFound)\n}" ]
[ "0.73326755", "0.71011513", "0.6862219", "0.6856231", "0.68042403", "0.6794714", "0.6790308", "0.67849296", "0.67800725", "0.67195934", "0.67052", "0.6674224", "0.66567403", "0.66507226", "0.6623271", "0.6619633", "0.6601576", "0.6586629", "0.6575644", "0.65651387", "0.6557038", "0.6534704", "0.6500434", "0.64974105", "0.64914834", "0.64900494", "0.6479675", "0.6471354", "0.6462017", "0.64287233", "0.6419274", "0.64186835", "0.64088166", "0.6403601", "0.6402199", "0.6401673", "0.6396311", "0.6371834", "0.6369009", "0.63555634", "0.63545954", "0.63428545", "0.634228", "0.63269985", "0.6320747", "0.6308229", "0.6303674", "0.62962985", "0.62940496", "0.62765586", "0.62543094", "0.6253395", "0.62377656", "0.62325233", "0.62297237", "0.6227874", "0.6227227", "0.62248623", "0.6219989", "0.621957", "0.6218566", "0.6208559", "0.6207379", "0.62006766", "0.620026", "0.61953837", "0.6185002", "0.6181912", "0.6178553", "0.61715186", "0.6170934", "0.61705095", "0.61690956", "0.61471015", "0.6145996", "0.61419547", "0.6124119", "0.61158633", "0.61095744", "0.6100636", "0.60957193", "0.6079874", "0.6078781", "0.60779727", "0.6076693", "0.6076291", "0.607244", "0.6071135", "0.6062799", "0.6056189", "0.6046092", "0.6042722", "0.60401803", "0.6037757", "0.6035216", "0.60317266", "0.6019066", "0.60163355", "0.59989727", "0.599849" ]
0.62305826
54
Registration mocks base method
func (m *MockServiceAuth) Registration(arg0 models.UserInputReg) (models.UserSession, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Registration", arg0) ret0, _ := ret[0].(models.UserSession) ret1, _ := ret[1].(error) return ret0, ret1 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *MockRoutingRuleClient) Register() error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func mockedGranter(kubeutil *kube.Kube, app *v1.RadixRegistration, namespace string, serviceAccount *corev1.ServiceAccount) error {\n\treturn nil\n}", "func (m *MockHub) Register(c ws.Client) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Register\", c)\n}", "func (m *MockVirtualServiceClient) Register() error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockRPCServer) registerServices() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"registerServices\")\n}", "func (m *MockUserController) Register(context *gin.Context) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Register\", context)\n}", "func (m *MockCAClient) Register(arg0 *api.RegistrationRequest) (string, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", arg0)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockDao) Register(steamID int64) (*model.Info, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", steamID)\n\tret0, _ := ret[0].(*model.Info)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockUsersRepoInterface) Register(arg0 *user.User) (*user.User, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", arg0)\n\tret0, _ := ret[0].(*user.User)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockISubKeyBucket) Register(receiver ISubKeyBucketReceiver) (IInterConnector, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", receiver)\n\tret0, _ := ret[0].(IInterConnector)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func registerMock(name string, priority CollectorPriority) *MockCollector {\n\tc := &MockCollector{}\n\tfactory := func() Collector { return c }\n\tregisterCollector(name, factory, priority)\n\treturn c\n}", "func (m *MockKubeNamespaceClient) Register() error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockRPCServer) registerServicesProxy(ctx context.Context) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"registerServicesProxy\", ctx)\n}", "func (m *MockAccount) Register(arg0, arg1 string) (*models.User, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", arg0, arg1)\n\tret0, _ := ret[0].(*models.User)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockLinkerdDiscoveryEmitter) Register() error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\")\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockUCAuth) Register(ctx context.Context, user *models.User) (*models.UserWithToken, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", ctx, user)\n\tret0, _ := ret[0].(*models.UserWithToken)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockLedgerClient) Register(arg0 context.Context, arg1 *ledger.RegisterRequest, arg2 ...grpc.CallOption) (*ledger.RegisterResult, error) {\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Register\", varargs...)\n\tret0, _ := ret[0].(*ledger.RegisterResult)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockHealthCheck) RegisterStats() {\n\tm.ctrl.Call(m, \"RegisterStats\")\n}", "func (m *MockIUserService) Register(user model.User) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", user)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (_m *MockPermissionRegistry) Register(permissions charon.Permissions) (int64, int64, int64, error) {\n\tret := _m.Called(permissions)\n\n\tvar r0 int64\n\tif rf, ok := ret.Get(0).(func(charon.Permissions) int64); ok {\n\t\tr0 = rf(permissions)\n\t} else {\n\t\tr0 = ret.Get(0).(int64)\n\t}\n\n\tvar r1 int64\n\tif rf, ok := ret.Get(1).(func(charon.Permissions) int64); ok {\n\t\tr1 = rf(permissions)\n\t} else {\n\t\tr1 = ret.Get(1).(int64)\n\t}\n\n\tvar r2 int64\n\tif rf, ok := ret.Get(2).(func(charon.Permissions) int64); ok {\n\t\tr2 = rf(permissions)\n\t} else {\n\t\tr2 = ret.Get(2).(int64)\n\t}\n\n\tvar r3 error\n\tif rf, ok := ret.Get(3).(func(charon.Permissions) error); ok {\n\t\tr3 = rf(permissions)\n\t} else {\n\t\tr3 = ret.Error(3)\n\t}\n\n\treturn r0, r1, r2, r3\n}", "func (_m *MockPermissionProvider) Register(permissions charon.Permissions) (int64, int64, int64, error) {\n\tret := _m.Called(permissions)\n\n\tvar r0 int64\n\tif rf, ok := ret.Get(0).(func(charon.Permissions) int64); ok {\n\t\tr0 = rf(permissions)\n\t} else {\n\t\tr0 = ret.Get(0).(int64)\n\t}\n\n\tvar r1 int64\n\tif rf, ok := ret.Get(1).(func(charon.Permissions) int64); ok {\n\t\tr1 = rf(permissions)\n\t} else {\n\t\tr1 = ret.Get(1).(int64)\n\t}\n\n\tvar r2 int64\n\tif rf, ok := ret.Get(2).(func(charon.Permissions) int64); ok {\n\t\tr2 = rf(permissions)\n\t} else {\n\t\tr2 = ret.Get(2).(int64)\n\t}\n\n\tvar r3 error\n\tif rf, ok := ret.Get(3).(func(charon.Permissions) error); ok {\n\t\tr3 = rf(permissions)\n\t} else {\n\t\tr3 = ret.Error(3)\n\t}\n\n\treturn r0, r1, r2, r3\n}", "func (m *MockHealthCheck) RegisterStats() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"RegisterStats\")\n}", "func (_m *MockQueryCoord) Register() error {\n\tret := _m.Called()\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func() error); ok {\n\t\tr0 = rf()\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (m *MockServer) RegisterService(arg0 *grpc.ServiceDesc, arg1 interface{}) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"RegisterService\", arg0, arg1)\n}", "func (m *MockUserService) Register(ctx context.Context, user *domain.User) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", ctx, user)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (_m *SysProbeUtil) Register(clientID string) error {\n\tret := _m.Called(clientID)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(string) error); ok {\n\t\tr0 = rf(clientID)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (m *MockAPI) RegisterHost(arg0 context.Context, arg1 *models.Host, arg2 *gorm.DB) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RegisterHost\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func newMockSubscriber() mockSubscriber {\n\treturn mockSubscriber{}\n}", "func (_m *Handler) Register(c echo.Context) error {\n\tret := _m.Called(c)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(echo.Context) error); ok {\n\t\tr0 = rf(c)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (_m *MockDataCoord) Register() error {\n\tret := _m.Called()\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func() error); ok {\n\t\tr0 = rf()\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (m *MockProvider) OnServiceAdd(arg0 *v1.Service) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"OnServiceAdd\", arg0)\n}", "func (m *MockRepositoryService) Search(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Search\", arg0, arg1)\n}", "func (m *MockClusterRegistrationClient) Register(ctx context.Context, remoteConfig clientcmd.ClientConfig, remoteClusterName, remoteWriteNamespace, remoteContextName, discoverySource string, registerOpts cluster_registration.ClusterRegisterOpts) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Register\", ctx, remoteConfig, remoteClusterName, remoteWriteNamespace, remoteContextName, discoverySource, registerOpts)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func TestEventRegistry(t *testing.T, newRegistry func() app.EventRegistry) {\n\ttests := []struct {\n\t\tscenario string\n\t\tsubName string\n\t\thandler func(*bool) interface{}\n\t\tcalled bool\n\t\tdispName string\n\t\tdispArg interface{}\n\t\tpanic bool\n\t}{\n\t\t{\n\t\t\tscenario: \"register and dispatch without arg\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} {\n\t\t\t\treturn func() {\n\t\t\t\t\t*called = true\n\t\t\t\t}\n\t\t\t},\n\t\t\tcalled: true,\n\t\t\tdispName: \"test\",\n\t\t\tdispArg: nil,\n\t\t},\n\t\t{\n\t\t\tscenario: \"register without arg and dispatch with arg\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} {\n\t\t\t\treturn func() {\n\t\t\t\t\t*called = true\n\t\t\t\t}\n\t\t\t},\n\t\t\tcalled: true,\n\t\t\tdispName: \"test\",\n\t\t\tdispArg: \"foobar\",\n\t\t},\n\t\t{\n\t\t\tscenario: \"register and dispatch with arg\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} {\n\t\t\t\treturn func(arg string) {\n\t\t\t\t\t*called = true\n\n\t\t\t\t\tif arg != \"hello\" {\n\t\t\t\t\t\tpanic(\"greet is not hello\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcalled: true,\n\t\t\tdispName: \"test\",\n\t\t\tdispArg: \"hello\",\n\t\t},\n\t\t{\n\t\t\tscenario: \"register and dispatch with bad arg\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} {\n\t\t\t\treturn func(arg int) {\n\t\t\t\t\t*called = true\n\t\t\t\t}\n\t\t\t},\n\t\t\tcalled: false,\n\t\t\tdispName: \"test\",\n\t\t\tdispArg: \"hello\",\n\t\t},\n\t\t{\n\t\t\tscenario: \"register non func handler\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} { return nil },\n\t\t\tpanic: true,\n\t\t},\n\t}\n\n\tfor _, test := range tests {\n\t\tt.Run(test.scenario, func(t *testing.T) {\n\t\t\tdefer func() {\n\t\t\t\terr := recover()\n\n\t\t\t\tif err != nil && !test.panic {\n\t\t\t\t\tt.Error(err)\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\tcalled := false\n\n\t\t\tr := newRegistry()\n\t\t\tunsub := r.Subscribe(test.subName, test.handler(&called))\n\t\t\tdefer unsub()\n\n\t\t\tr.Dispatch(test.dispName, test.dispArg)\n\n\t\t\tif called != test.called {\n\t\t\t\tt.Error(\"called expected:\", test.called)\n\t\t\t\tt.Error(\"called: \", called)\n\t\t\t}\n\n\t\t\tif test.panic {\n\t\t\t\tt.Error(\"no panic\")\n\t\t\t}\n\t\t})\n\t}\n}", "func (m *MockProvider) OnEndpointsAdd(arg0 *v1.Endpoints) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"OnEndpointsAdd\", arg0)\n}", "func (m *MockOobService) RegisterMsgEvent(arg0 chan<- service.StateMsg) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RegisterMsgEvent\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func NewMockObject(uid, name, ns string, res api.Resource) api.Object {\n\treturn NewObject(uuid.NewFromString(uid), name, ns, res)\n}", "func (m *MockHandler) Signup(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Signup\", arg0, arg1)\n}", "func (m *MockUsecases) Add(n string, u interface{}) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Add\", n, u)\n}", "func (m *MockResolver) Start() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Start\")\n}", "func (_m *PermissionRegistry) Register(ctx context.Context, permissions charon.Permissions) (int64, int64, int64, error) {\n\tret := _m.Called(ctx, permissions)\n\n\tvar r0 int64\n\tif rf, ok := ret.Get(0).(func(context.Context, charon.Permissions) int64); ok {\n\t\tr0 = rf(ctx, permissions)\n\t} else {\n\t\tr0 = ret.Get(0).(int64)\n\t}\n\n\tvar r1 int64\n\tif rf, ok := ret.Get(1).(func(context.Context, charon.Permissions) int64); ok {\n\t\tr1 = rf(ctx, permissions)\n\t} else {\n\t\tr1 = ret.Get(1).(int64)\n\t}\n\n\tvar r2 int64\n\tif rf, ok := ret.Get(2).(func(context.Context, charon.Permissions) int64); ok {\n\t\tr2 = rf(ctx, permissions)\n\t} else {\n\t\tr2 = ret.Get(2).(int64)\n\t}\n\n\tvar r3 error\n\tif rf, ok := ret.Get(3).(func(context.Context, charon.Permissions) error); ok {\n\t\tr3 = rf(ctx, permissions)\n\t} else {\n\t\tr3 = ret.Error(3)\n\t}\n\n\treturn r0, r1, r2, r3\n}", "func (m *MockMetrics) AddToGauge(arg0 string, arg1 float64, arg2 ...string) {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{arg0, arg1}\n\tfor _, a := range arg2 {\n\t\tvarargs = append(varargs, a)\n\t}\n\tm.ctrl.Call(m, \"AddToGauge\", varargs...)\n}", "func (m *MockWatcherConstructor) New(arg0 Machine, arg1 string, arg2 []string, arg3, arg4, arg5 string, arg6 time.Duration, arg7 map[string]interface{}) (interface{}, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"New\", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)\n\tret0, _ := ret[0].(interface{})\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockRouter) Add(method, path string, handler interface{}, options ...interface{}) error {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{method, path, handler}\n\tfor _, a := range options {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Add\", varargs...)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func Mock(fake string) func() {\n\tmutex.Lock()\n\tdefer mutex.Unlock()\n\torigin := backend\n\tbackend = fake\n\treturn func() { Mock(origin) }\n}", "func (m *MockAuthService) SignUp(arg0 http.ResponseWriter, arg1 *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"SignUp\", arg0, arg1)\n}", "func (m *MockRegistrar) RegisterAuthorizationBroker(ctx context.Context, tenantID, token, spaceID, externalURL string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RegisterAuthorizationBroker\", ctx, tenantID, token, spaceID, externalURL)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockWaiter) Add(arg0 func() error) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Add\", arg0)\n}", "func (m *MockOobService) RegisterActionEvent(arg0 chan<- service.DIDCommAction) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RegisterActionEvent\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockSessionRunner) AddResetToken(arg0 [16]byte, arg1 packetHandler) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"AddResetToken\", arg0, arg1)\n}", "func (m *MockSessionRunner) Add(arg0 protocol.ConnectionID, arg1 packetHandler) [16]byte {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Add\", arg0, arg1)\n\tret0, _ := ret[0].([16]byte)\n\treturn ret0\n}", "func (s *Service) mustRegister(t *testing.T) {\n\tif err := s.Register(testService{}); err != nil {\n\t\tt.Fatalf(\"Registering test service failed: %v\", err)\n\t}\n}", "func (m *MockISubKeyBucket) UnRegister(key string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"UnRegister\", key)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockProvider) OnServiceSynced() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"OnServiceSynced\")\n}", "func (m *MockCerebroker) Resample() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Resample\")\n}", "func mockRegisterProducerTx(info *payload.ProducerInfo) *types.Transaction {\n\treturn &types.Transaction{\n\t\tTxType: types.RegisterProducer,\n\t\tPayload: info,\n\t}\n}", "func StartMockups() {\n\tenabledMocks = true\n}", "func (m *MockSeriesRefResolver) ReleaseRef() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"ReleaseRef\")\n}", "func (mmRegisterResult *mClientMockRegisterResult) When(ctx context.Context, request insolar.Reference, result RequestResult) *ClientMockRegisterResultExpectation {\n\tif mmRegisterResult.mock.funcRegisterResult != nil {\n\t\tmmRegisterResult.mock.t.Fatalf(\"ClientMock.RegisterResult mock is already set by Set\")\n\t}\n\n\texpectation := &ClientMockRegisterResultExpectation{\n\t\tmock: mmRegisterResult.mock,\n\t\tparams: &ClientMockRegisterResultParams{ctx, request, result},\n\t}\n\tmmRegisterResult.expectations = append(mmRegisterResult.expectations, expectation)\n\treturn expectation\n}", "func (m *MockSessionRunner) Retire(arg0 protocol.ConnectionID) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Retire\", arg0)\n}", "func (m *MockProvider) OnEndpointsSynced() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"OnEndpointsSynced\")\n}", "func NewMockReplacer(\n\tctx context.Context,\n\tregion string,\n\tprofile string) *Replacer {\n\n\tasgroup := newAsg(region, profile)\n\tdeploy := fsm.NewDeploy(\"start\")\n\tasgroup.Ec2Api = &mockEC2iface{}\n\tasgroup.AsgAPI = &mockASGiface{}\n\tasgroup.EcsAPI = &mockECSiface{}\n\treturn &Replacer{\n\t\tctx: ctx,\n\t\tasg: asgroup,\n\t\tdeploy: deploy,\n\t}\n}", "func (m *MockISubKeyBucket) UnRegisterReceiver(receiver ISubKeyBucketReceiver) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"UnRegisterReceiver\", receiver)\n}", "func (m *MockHub) Run() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Run\")\n}", "func (m *MockGatewaySet) Generic() sets.ResourceSet {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Generic\")\n\tret0, _ := ret[0].(sets.ResourceSet)\n\treturn ret0\n}", "func TestMultipleRegisterCalls(t *testing.T) {\n\tRegister(\"multiple-register-driver-1\")\n\trequire.PanicsWithError(t, \"Register called twice for driver multiple-register-driver-1\", func() {\n\t\tRegister(\"multiple-register-driver-1\")\n\t})\n\n\t// Should be no error.\n\tRegister(\"multiple-register-driver-2\")\n}", "func (m *MockResponseWriter) Write(arg0 *types.APIRequest, arg1 int, arg2 types.APIObject) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Write\", arg0, arg1, arg2)\n}", "func (m *MockProvider) Provide(arg0 string) blobclient.Client {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Provide\", arg0)\n\tret0, _ := ret[0].(blobclient.Client)\n\treturn ret0\n}", "func TestRegistryWithImpl(T *testing.T, factory func() Registry) {\n\ttestRegistryIsValid(T, factory())\n\ttestRegisterCantResolveMissingType(T, factory())\n\ttestRegisterCanResolveBoundType(T, factory())\n\ttestRegisterAndBindType(T, factory())\n\ttestBindDoesNotDestroyExistingBindings(T, factory())\n\ttestRecursiveResolution(T, factory())\n}", "func (m *MockServicer) CalculateHashAndDuration(startTime time.Time, fiveSecTimer *time.Timer, password string) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"CalculateHashAndDuration\", startTime, fiveSecTimer, password)\n}", "func (m *MockFileInfo) Sys() interface{} {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Sys\")\n\tret0, _ := ret[0].(interface{})\n\treturn ret0\n}", "func (m *MockUserAPI) Signup(w http.ResponseWriter, r *http.Request) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Signup\", w, r)\n}", "func (m *MockProc) OnSvcAllHostReplace(arg0 []*host.Host) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"OnSvcAllHostReplace\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockIPAMDriver) Add(arg0 *invoke.Args, arg1 *types.K8sArgs, arg2 []byte) (bool, *current.Result, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Add\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(bool)\n\tret1, _ := ret[1].(*current.Result)\n\tret2, _ := ret[2].(error)\n\treturn ret0, ret1, ret2\n}", "func (m *MockAPI) HostMonitoring() {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"HostMonitoring\")\n}", "func mockAlwaysRun() bool { return true }", "func TestRegister(t *testing.T) {\n\tvar command = \"0\"\n\tvar windows_ver = \"Windows%207%20x64\"\n\tvar hardcoded_id = \"1234\"\n\tvar external_ip = \"0.0.0.0\"\n\tvar adapter_sha256 = \"GAVHSGFD12345ATGSHBDSAFSGTAGSBHSGFSDATQ12345AGSFSGBDISHJKAGS2343\"\n\tvar cwd = \"C:\"\n\tvar pid = \"1111\"\n\tvar ppid = \"2222\"\n\n\tstartRESTAPI()\n\tdefer stopRESTAPI()\n\n\tstartTrickBotHandler()\n\tdefer stopTrickBotHandler()\n\tregisterURL := fmt.Sprintf(\"%s%s/%s/%s/%s/%s/%s/%s/%s/%s/%s/%s\", baseURL, campaign_id, client_id, command, windows_ver, hardcoded_id, external_ip, adapter_sha256, cwd, pid, ppid, random_string)\n\treq, err := http.NewRequest(\"GET\", registerURL, nil)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tclient := &http.Client{}\n\tresponse, err := client.Do(req)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tdefer response.Body.Close()\n\tlogger.Info(response.StatusCode)\n\tif response.StatusCode != 200 {\n\t\tt.Fatal(err)\n\t}\n\tbody, err := ioutil.ReadAll(response.Body)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\texpectedOutput := \"successfully added session\"\n\tif string(body) != expectedOutput {\n\t\tt.Fatalf(\"Got '%s' expected '%v'\", string(body), expectedOutput)\n\t}\n}", "func (mmRegisterResult *mClientMockRegisterResult) Set(f func(ctx context.Context, request insolar.Reference, result RequestResult) (err error)) *ClientMock {\n\tif mmRegisterResult.defaultExpectation != nil {\n\t\tmmRegisterResult.mock.t.Fatalf(\"Default expectation is already set for the Client.RegisterResult method\")\n\t}\n\n\tif len(mmRegisterResult.expectations) > 0 {\n\t\tmmRegisterResult.mock.t.Fatalf(\"Some expectations are already set for the Client.RegisterResult method\")\n\t}\n\n\tmmRegisterResult.mock.funcRegisterResult = f\n\treturn mmRegisterResult.mock\n}", "func (m *MockTaskRegister) RegisterTaskOnce(arg0 context.Context) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RegisterTaskOnce\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockRouterManager) Reloadable() bool {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Reloadable\")\n\tret0, _ := ret[0].(bool)\n\treturn ret0\n}", "func registerResponders(requests []gcpRequest) {\n\tfor _, request := range requests {\n\t\thttpmock.RegisterResponder(request.method, request.url, request.responder)\n\t}\n}", "func (_m *Watcher) Add(name string) error {\n\tret := _m.Called(name)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(string) error); ok {\n\t\tr0 = rf(name)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (m *MockPackClient) RegisterBuildpack(arg0 context.Context, arg1 client.RegisterBuildpackOptions) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"RegisterBuildpack\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockServiceDependencySet) Generic() sets.ResourceSet {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Generic\")\n\tret0, _ := ret[0].(sets.ResourceSet)\n\treturn ret0\n}", "func (m *MockProvider) Service(arg0 string) (interface{}, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Service\", arg0)\n\tret0, _ := ret[0].(interface{})\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockBackend) Push(image string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Push\", image)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockHub) Unregister(c ws.Client) {\n\tm.ctrl.T.Helper()\n\tm.ctrl.Call(m, \"Unregister\", c)\n}", "func (m *MockLoggerConfiguration) Implementation() interface{} {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Implementation\")\n\tret0, _ := ret[0].(interface{})\n\treturn ret0\n}", "func (m *MockManager) SerializeReleaseName(arg0 string) error {\n\tret := m.ctrl.Call(m, \"SerializeReleaseName\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockSession) Push(arg0 string, arg1 interface{}) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Push\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockTaskRegister) Close(arg0 context.Context) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Close\", arg0)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (m *MockBuilder) Generic() resource.ClusterSnapshot {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Generic\")\n\tret0, _ := ret[0].(resource.ClusterSnapshot)\n\treturn ret0\n}", "func (m *MockImageReplacer) Replace(arg0 sheaf.BundleManifest, arg1 sheaf.BundleConfig, arg2 string) ([]byte, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Replace\", arg0, arg1, arg2)\n\tret0, _ := ret[0].([]byte)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func (m *MockRouterTx) Add(method, path string, handler interface{}, options ...interface{}) error {\n\tm.ctrl.T.Helper()\n\tvarargs := []interface{}{method, path, handler}\n\tfor _, a := range options {\n\t\tvarargs = append(varargs, a)\n\t}\n\tret := m.ctrl.Call(m, \"Add\", varargs...)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (_m *mockImportSteps) RegisterDeveloper(t cbtest.T, _a1 provider.Config) error {\n\tret := _m.Called(t, _a1)\n\n\tvar r0 error\n\tif rf, ok := ret.Get(0).(func(cbtest.T, provider.Config) error); ok {\n\t\tr0 = rf(t, _a1)\n\t} else {\n\t\tr0 = ret.Error(0)\n\t}\n\n\treturn r0\n}", "func (tm *TestManager) Register(obj interface{}) {\n\ttm.ModuleMap[Common.GetTypeName(obj)] = reflect.TypeOf(obj)\n}", "func (m *MockUsecase) Add(arg0, arg1 string) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Add\", arg0, arg1)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func MockPrepareRelease(release *Release) {\n\trelease.SetDefaultRegionAccount(to.Strp(\"region\"), to.Strp(\"account\"))\n\trelease.SetDefaults()\n\trelease.SetUUID()\n}", "func (m *MockAPI) Install(arg0 context.Context, arg1 *models.Host, arg2 *gorm.DB) error {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Install\", arg0, arg1, arg2)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}", "func (mock *MockEnv) Register(remotes ...string) (repo *git.Repository) {\n\tif len(remotes) == 0 {\n\t\tpanic(\"Register: Must provide at least one remote. \")\n\t}\n\n\t// check that we have fresh remotes for all urls\n\tfor _, remote := range remotes {\n\t\tif _, ok := mock.plumbing.URLMap[remote]; ok {\n\t\t\tpanic(\"Register: remote \" + remote + \" already registered\")\n\t\t}\n\t}\n\n\t// generate a new fake remote path\n\tmock.remoteCounter++\n\tfakeRemotePath := filepath.Join(mock.remoteRoot, \"remote\"+fmt.Sprint(mock.remoteCounter))\n\n\t// create a repository\n\trepo = testutil.NewTestRepoAt(fakeRemotePath, \"\")\n\ttestutil.CommitTestFiles(repo, map[string]string{\"fake.txt\": remotes[0]})\n\n\t// Register all the repositories.\n\t// Here we rely on the fact that adding \"/.\" to the end of a path does not change the actually cloned path.\n\t// We can thus add it to the mapped remote, and still refer to the same repository.\n\tsuffix := \"\"\n\tfor _, remote := range remotes {\n\t\tmock.plumbing.URLMap[remote] = fakeRemotePath + suffix\n\t\tsuffix += string(os.PathSeparator) + \".\"\n\t}\n\n\treturn repo\n}" ]
[ "0.6656541", "0.6569731", "0.6534301", "0.649857", "0.6472692", "0.6407817", "0.6345684", "0.63358206", "0.62946606", "0.6216814", "0.6175665", "0.6145518", "0.6103006", "0.609894", "0.60896176", "0.6068469", "0.603417", "0.5971163", "0.59548897", "0.5937762", "0.58421296", "0.5837059", "0.5809676", "0.5797093", "0.57597405", "0.5746733", "0.570843", "0.57036495", "0.56504685", "0.5650092", "0.56201446", "0.56167185", "0.55783665", "0.55645454", "0.55626607", "0.5523592", "0.5519297", "0.55075836", "0.5505996", "0.54968774", "0.5494656", "0.5484837", "0.5475011", "0.5469963", "0.54660463", "0.54462934", "0.54378605", "0.54374224", "0.5425906", "0.54251486", "0.5418179", "0.5418006", "0.5412611", "0.5407325", "0.54013646", "0.53939915", "0.53918433", "0.5389299", "0.5384775", "0.5377081", "0.53765273", "0.5358393", "0.5356426", "0.5350631", "0.5344877", "0.5340002", "0.533838", "0.5328393", "0.53219736", "0.53056353", "0.5304645", "0.530155", "0.52856994", "0.5285517", "0.52833503", "0.52814984", "0.5278515", "0.52752143", "0.5274194", "0.5273776", "0.5272651", "0.5266197", "0.52653587", "0.526424", "0.52637404", "0.52598786", "0.52567", "0.52564216", "0.5254105", "0.5250954", "0.5247836", "0.52450526", "0.5242829", "0.5241498", "0.5240515", "0.5234975", "0.5230823", "0.5229272", "0.5226726", "0.5224991" ]
0.65866566
1
Registration indicates an expected call of Registration
func (mr *MockServiceAuthMockRecorder) Registration(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Registration", reflect.TypeOf((*MockServiceAuth)(nil).Registration), arg0) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (_DelegateProfile *DelegateProfileCaller) Registered(opts *bind.CallOpts, _addr common.Address) (bool, error) {\n\tvar (\n\t\tret0 = new(bool)\n\t)\n\tout := ret0\n\terr := _DelegateProfile.contract.Call(opts, out, \"registered\", _addr)\n\treturn *ret0, err\n}", "func (s SwxProxy) Register(_ context.Context, _ *protos.RegistrationRequest) (*protos.RegistrationAnswer, error) {\n\treturn &protos.RegistrationAnswer{}, nil\n}", "func (mr *MockUsersRepoInterfaceMockRecorder) Register(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockUsersRepoInterface)(nil).Register), arg0)\n}", "func (mr *MockRoutingRuleClientMockRecorder) Register() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockRoutingRuleClient)(nil).Register))\n}", "func (mr *MockLinkerdDiscoveryEmitterMockRecorder) Register() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockLinkerdDiscoveryEmitter)(nil).Register))\n}", "func TestRegister(t *testing.T) {\n\n\tfabricCAClient, err := NewFabricCAClient(org1, configImp, cryptoSuiteProvider)\n\tif err != nil {\n\t\tt.Fatalf(\"NewFabricCAClient returned error: %v\", err)\n\t}\n\tuser := mocks.NewMockUser(\"test\")\n\t// Register with nil request\n\t_, err = fabricCAClient.Register(user, nil)\n\tif err == nil {\n\t\tt.Fatalf(\"Expected error with nil request\")\n\t}\n\tif err.Error() != \"registration request required\" {\n\t\tt.Fatalf(\"Expected error registration request required. Got: %s\", err.Error())\n\t}\n\n\t//Register with nil user\n\t_, err = fabricCAClient.Register(nil, &ca.RegistrationRequest{})\n\tif err == nil {\n\t\tt.Fatalf(\"Expected error with nil user\")\n\t}\n\tif !strings.Contains(err.Error(), \"failed to create request for signing identity\") {\n\t\tt.Fatalf(\"Expected error failed to create request for signing identity. Got: %s\", err.Error())\n\t}\n\t// Register with nil user cert and key\n\t_, err = fabricCAClient.Register(user, &ca.RegistrationRequest{})\n\tif err == nil {\n\t\tt.Fatalf(\"Expected error without user enrolment information\")\n\t}\n\tif !strings.Contains(err.Error(), \"failed to create request for signing identity\") {\n\t\tt.Fatalf(\"Expected error failed to create request for signing identity. Got: %s\", err.Error())\n\t}\n\n\tuser.SetEnrollmentCertificate(readCert(t))\n\tkey, err := cryptosuite.GetDefault().KeyGen(cryptosuite.GetECDSAP256KeyGenOpts(true))\n\tif err != nil {\n\t\tt.Fatalf(\"KeyGen return error %v\", err)\n\t}\n\tuser.SetPrivateKey(key)\n\t// Register without registration name parameter\n\t_, err = fabricCAClient.Register(user, &ca.RegistrationRequest{})\n\tif !strings.Contains(err.Error(), \"failed to register user\") {\n\t\tt.Fatalf(\"Expected error failed to register user. Got: %s\", err.Error())\n\t}\n\n\t// Register with valid request\n\tvar attributes []ca.Attribute\n\tattributes = append(attributes, ca.Attribute{Key: \"test1\", Value: \"test2\"})\n\tattributes = append(attributes, ca.Attribute{Key: \"test2\", Value: \"test3\"})\n\tsecret, err := fabricCAClient.Register(user, &ca.RegistrationRequest{Name: \"test\",\n\t\tAffiliation: \"test\", Attributes: attributes})\n\tif err != nil {\n\t\tt.Fatalf(\"fabricCAClient Register return error %v\", err)\n\t}\n\tif secret != \"mockSecretValue\" {\n\t\tt.Fatalf(\"fabricCAClient Register return wrong value %s\", secret)\n\t}\n}", "func (s *Service) mustRegister(t *testing.T) {\n\tif err := s.Register(testService{}); err != nil {\n\t\tt.Fatalf(\"Registering test service failed: %v\", err)\n\t}\n}", "func (mr *MockHubMockRecorder) Register(c interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockHub)(nil).Register), c)\n}", "func (mr *MockCAClientMockRecorder) Register(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockCAClient)(nil).Register), arg0)\n}", "func (mr *MockAccountMockRecorder) Register(arg0, arg1 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockAccount)(nil).Register), arg0, arg1)\n}", "func (mr *MockUserControllerMockRecorder) Register(context interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockUserController)(nil).Register), context)\n}", "func (v *VirtualHost) RegistrationAllowed() (bool, bool) {\n\tif v == nil {\n\t\treturn false, false\n\t}\n\treturn v.AllowRegistration, v.AllowGuests\n}", "func (c *RegistrationController) Register(w http.ResponseWriter, r *http.Request) {\n\n\t// parse the JSON coming from the client\n\tvar regRequest registrationRequest\n\tdecoder := json.NewDecoder(r.Body)\n\n\t// check if the parsing succeeded\n\tif err := decoder.Decode(&regRequest); err != nil {\n\t\tlog.Println(err)\n\t\tc.Error500(w, err, \"Error decoding JSON\")\n\t\treturn\n\t}\n\n\t// validate the data\n\tif err := regRequest.isValid(); err != nil {\n\t\tlog.Println(err)\n\t\tc.Error500(w, err, \"Invalid form data\")\n\t\treturn\n\t}\n\n\t// register the user\n\taccount := regRequest.Email // use the user's email as a unique account\n\tuser, err := models.RegisterUser(account, regRequest.Organisation,\n\t\tregRequest.Email, regRequest.Password, regRequest.First, regRequest.Last)\n\n\tif err != nil {\n\t\tlog.Printf(\"Error registering the user: %v\", err)\n\t\tc.Error500(w, err, \"Error registering the user\")\n\t\treturn\n\t} else {\n\t\tc.JSON(&user, w, r)\n\t}\n\n\t// Send email address confirmation link\n\tif err := sendVerificationEmail(user.ID); err != nil {\n\t\tlog.Printf(\"Error sending verification email: %v\", err)\n\t\tc.Error500(w, err, \"Error sending verification email\")\n\t}\n\n}", "func (mr *MockVirtualServiceClientMockRecorder) Register() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockVirtualServiceClient)(nil).Register))\n}", "func Registration(w http.ResponseWriter, r *http.Request) {\n\n\tbody, _ := ioutil.ReadAll(r.Body)\n\n\tuser := models.User{}\n\terr := json.Unmarshal(body, &user)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tuser.Prepare()\n\terr = user.Validate(\"login\")\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\n\ttoken, err := auth.SignUp(user.Email, user.Password)\n\tif err != nil {\n\t\tresponses.ERROR(w, http.StatusUnprocessableEntity, err)\n\t\treturn\n\t}\n\tresponses.JSON(w, http.StatusOK, token)\n}", "func (m *MockServiceAuth) Registration(arg0 models.UserInputReg) (models.UserSession, error) {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"Registration\", arg0)\n\tret0, _ := ret[0].(models.UserSession)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}", "func isRegistered(t *testing.T, tr *rt.TableRow) {\n\ta := tr.OtherTestData[testAdapterDataKey].(*adapter)\n\n\tresp := probeHandler(t, a, tURLPath)\n\tassert.NotEqual(t, http.StatusNotFound, resp.Code, \"Expected handler hit\")\n}", "func (s NoUseSwxProxy) Register(\n\tctx context.Context,\n\treq *protos.RegistrationRequest,\n) (*protos.RegistrationAnswer, error) {\n\treturn &protos.RegistrationAnswer{}, fmt.Errorf(\"Register is NOT IMPLEMENTED\")\n}", "func (mr *MockIUserServiceMockRecorder) Register(user interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockIUserService)(nil).Register), user)\n}", "func (mr *MockUCAuthMockRecorder) Register(ctx, user interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockUCAuth)(nil).Register), ctx, user)\n}", "func MustRegister(r *keys.Registrar) {\n\tif err := Register(r); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (gf *GOFactory) Register(typeID string, creator ICreator) bool {\n\tgologger.SLogger.Println(\"registering\", typeID)\n\n\t// check if already registered\n\t_, ok := gf.GoCreator[typeID]\n\tif ok {\n\t\tgologger.SLogger.Println(\"Already Registered Object \", typeID)\n\n\t\treturn false\n\t}\n\n\tgf.GoCreator[typeID] = creator\n\n\tgologger.SLogger.Println(\"Added To Factory Obj Of Type\", typeID)\n\n\treturn true\n}", "func (mr *MockLedgerClientMockRecorder) Register(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call {\n\tvarargs := append([]interface{}{arg0, arg1}, arg2...)\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockLedgerClient)(nil).Register), varargs...)\n}", "func TestMultipleRegisterCalls(t *testing.T) {\n\tRegister(\"multiple-register-driver-1\")\n\trequire.PanicsWithError(t, \"Register called twice for driver multiple-register-driver-1\", func() {\n\t\tRegister(\"multiple-register-driver-1\")\n\t})\n\n\t// Should be no error.\n\tRegister(\"multiple-register-driver-2\")\n}", "func (_DelegateProfile *DelegateProfileCallerSession) Registered(_addr common.Address) (bool, error) {\n\treturn _DelegateProfile.Contract.Registered(&_DelegateProfile.CallOpts, _addr)\n}", "func mustRegister(params *Params) {\n\tif err := Register(params); err != nil {\n\t\tpanic(\"failed to register network: \" + err.Error())\n\t}\n}", "func mustRegister(params *Params) {\n\tif err := Register(params); err != nil {\n\t\tpanic(\"failed to register network: \" + err.Error())\n\t}\n}", "func mustRegister(params *Params) {\n\tif err := Register(params); err != nil {\n\t\tpanic(\"failed to register network: \" + err.Error())\n\t}\n}", "func CheckRegistration(ctx context.Context, client *mongo.Client, reg string) bool {\n\tvar result structs.Vehicle\n\tcol := client.Database(\"parkai\").Collection(\"vehicles\")\n\tfilter := bson.M{\"registration\": reg}\n\n\t//reg does not exist\n\tif err := col.FindOne(ctx, filter).Decode(&result); err != nil {\n\t\treturn false\n\t}\n\n\t//reg exists\n\treturn true\n}", "func RegisteringTokenTest(env *models.PhotonEnvReader, allowFail bool) {\n\t// 1. register a not-exist token\n\tcase1 := &APITestCase{\n\t\tCaseName: \"Register a not-exist token\",\n\t\tAllowFail: allowFail,\n\t\tReq: &models.Req{\n\t\t\tAPIName: \"RegisteringOneToken\",\n\t\t\tFullURL: env.RandomNode().Host + \"/api/1/tokens/0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF\",\n\t\t\tMethod: http.MethodPut,\n\t\t\tPayload: \"\",\n\t\t\tTimeout: time.Second * 120,\n\t\t},\n\t\tTargetStatusCode: 409,\n\t}\n\tcase1.Run()\n\t// 2. register a new token\n\tnewTokenAddress := deployNewToken()\n\tcase2 := &APITestCase{\n\t\tCaseName: \"Register a new token\",\n\t\tAllowFail: allowFail,\n\t\tReq: &models.Req{\n\t\t\tAPIName: \"RegisteringOneToken\",\n\t\t\tFullURL: env.RandomNode().Host + \"/api/1/tokens/\" + newTokenAddress,\n\t\t\tMethod: http.MethodPut,\n\t\t\tPayload: \"\",\n\t\t\tTimeout: time.Second * 180,\n\t\t},\n\t\tTargetStatusCode: 200,\n\t}\n\tcase2.Run()\n}", "func (w *Wrapper) registrationComplete() (bool, error) {\n\tpath := filepath.Join(w.cfg.RootDir, shardRegMarker)\n\t_, err := os.Stat(path)\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn true, nil\n}", "func (mr *MockDaoMockRecorder) Register(steamID interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockDao)(nil).Register), steamID)\n}", "func TestActivityRegistration(t *testing.T) {\n\tact := NewActivity(getActivityMetadata())\n\tif act == nil {\n\t\tt.Error(\"Activity Not Registered\")\n\t\tt.Fail()\n\t\treturn\n\t}\n}", "func (mr *MockKubeNamespaceClientMockRecorder) Register() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockKubeNamespaceClient)(nil).Register))\n}", "func (s *eremeticScheduler) Registered(driver sched.SchedulerDriver, frameworkID *mesos.FrameworkID, masterInfo *mesos.MasterInfo) {\n\tlog.Debugf(\"Framework %s registered with master %s\", frameworkID.GetValue(), masterInfo.GetHostname())\n\tif !s.initialised {\n\t\tdriver.ReconcileTasks([]*mesos.TaskStatus{})\n\t\ts.initialised = true\n\t} else {\n\t\ts.Reconcile(driver)\n\t}\n}", "func (mr *MockUserServiceMockRecorder) Register(ctx, user interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockUserService)(nil).Register), ctx, user)\n}", "func (r *Registry) Register(registrant Registrant) {\n\tif _, ok := r.registrants[registrant.Name()]; ok {\n\t\tpanic(fmt.Sprintf(\"%s: registrant %q already registered\", r.name, registrant.Name()))\n\t}\n\tr.registrants[registrant.Name()] = registrant\n}", "func (c *mockMediatorClient) Register(connectionID string) error {\n\tif c.RegisterErr != nil {\n\t\treturn c.RegisterErr\n\t}\n\n\treturn nil\n}", "func (mr *MockISubKeyBucketMockRecorder) Register(receiver interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockISubKeyBucket)(nil).Register), receiver)\n}", "func (_DelegateProfile *DelegateProfileSession) Registered(_addr common.Address) (bool, error) {\n\treturn _DelegateProfile.Contract.Registered(&_DelegateProfile.CallOpts, _addr)\n}", "func (ctr *RegistRequestController) RequestRegistration(c echo.Context) error {\n\n\trequestRegistrationParams := new(param.RequestRegistrationParams)\n\n\tif err := c.Bind(requestRegistrationParams); err != nil {\n\t\treturn c.JSON(http.StatusOK, cf.JsonResponse{\n\t\t\tStatus: cf.FailResponseCode,\n\t\t\tMessage: \"Invalid params\",\n\t\t\tData: err,\n\t\t})\n\t}\n\n\tregistrationRequestOjb, err := ctr.RegistRequestRepo.GetRegRequests(requestRegistrationParams)\n\n\tif err != nil && err.Error() != pg.ErrNoRows.Error() {\n\t\treturn c.JSON(http.StatusInternalServerError, cf.JsonResponse{\n\t\t\tStatus: cf.FailResponseCode,\n\t\t\tMessage: \"System error\",\n\t\t})\n\t}\n\n\t// check email is in use or not\n\terrMail, err := ctr.RegistRequestRepo.CheckExistRequestUser(\n\t\tctr.UserRepo,\n\t\t[]string{requestRegistrationParams.EmailAddr},\n\t\trequestRegistrationParams.OrganizationID,\n\t)\n\n\tif err != nil {\n\t\treturn c.JSON(http.StatusInternalServerError, cf.JsonResponse{\n\t\t\tStatus: cf.FailResponseCode,\n\t\t\tMessage: \"System error\",\n\t\t})\n\t}\n\n\tif len(errMail) > 0 {\n\t\treturn c.JSON(http.StatusOK, cf.JsonResponse{\n\t\t\tStatus: cf.FailResponseCode,\n\t\t\tMessage: \"Email is requested or registered\",\n\t\t\tData: errMail,\n\t\t})\n\t}\n\n\torg, err := ctr.OrgRepo.SelectEmailAndPassword(requestRegistrationParams.OrganizationID)\n\tif err != nil {\n\t\treturn c.JSON(http.StatusInternalServerError, cf.JsonResponse{\n\t\t\tStatus: cf.FailResponseCode,\n\t\t\tMessage: \"System error\",\n\t\t})\n\t}\n\tif org.Email == \"\" || org.EmailPassword == \"\" {\n\t\treturn c.JSON(http.StatusUnprocessableEntity, cf.JsonResponse{\n\t\t\tStatus: cf.FailResponseCode,\n\t\t\tMessage: \"The email system is currently down. Please try later\",\n\t\t})\n\t}\n\n\t// no record in db\n\tif registrationRequestOjb.ID == 0 {\n\t\t// start insert new request\n\t\tregistrationRequestOjb, err := ctr.RegistRequestRepo.InsertRegRequest(cf.UserRequestType, cf.PendingRequestStatus, requestRegistrationParams)\n\t\tif err != nil {\n\t\t\treturn c.JSON(http.StatusInternalServerError, cf.JsonResponse{\n\t\t\t\tStatus: cf.FailResponseCode,\n\t\t\t\tMessage: \"System error\",\n\t\t\t})\n\t\t}\n\n\t\tctr.InitSmtp(org.Email, org.EmailPassword)\n\n\t\tsampleData := new(param.SampleData)\n\t\tsampleData.SendTo = []string{requestRegistrationParams.EmailAddr}\n\n\t\t// after insert success - send notice email\n\t\tif err := ctr.SendMail(\"Micro_Erp Success Request\", sampleData, cf.SuccessRequestTemplate); err != nil {\n\t\t\tctr.Logger.Error(err)\n\t\t\treturn c.JSON(http.StatusInternalServerError, cf.JsonResponse{\n\t\t\t\tStatus: cf.FailResponseCode,\n\t\t\t\tMessage: \"System error\",\n\t\t\t})\n\t\t}\n\n\t\treturn c.JSON(http.StatusOK, cf.JsonResponse{\n\t\t\tStatus: cf.SuccessResponseCode,\n\t\t\tMessage: \"Your request has been sent. We will sent you an email about your request soon\",\n\t\t\tData: registrationRequestOjb,\n\t\t})\n\t}\n\n\t// record exist in db\n\tif registrationRequestOjb.Email != \"\" {\n\t\treturnMessage := \"\"\n\t\tif registrationRequestOjb.Status == cf.DenyRequestStatus {\n\t\t\treturnMessage = \"Your request has been denied\"\n\t\t} else {\n\t\t\treturnMessage = \"Your request have been sent before. Please wait for us to check\"\n\t\t}\n\t\treturn c.JSON(http.StatusOK, cf.JsonResponse{\n\t\t\tStatus: cf.FailResponseCode,\n\t\t\tMessage: returnMessage,\n\t\t})\n\t}\n\n\treturn c.JSON(http.StatusInternalServerError, cf.JsonResponse{\n\t\tStatus: cf.FailResponseCode,\n\t\tMessage: \"System error\",\n\t})\n}", "func (rh *RegistrationHandler) Registration(w http.ResponseWriter, r *http.Request) {\n\tr.ParseForm()\n\n\tfileName := r.Form[\"file_name\"]\n\tfileDate := time.Now()\n\ttowerID := r.Form[\"tower_id\"]\n\tlocationID := r.Form[\"location_id\"]\n\tpostalCode := r.Form[\"postal_code\"]\n\tareaCode := r.Form[\"area_code\"]\n\n\tregistration := &domain.Registration{\n\t\tFileName: fileName[0],\n\t\tFileDate: fileDate,\n\t\tTowerID: towerID[0],\n\t\tLocationID: locationID[0],\n\t\tPostalCode: postalCode[0],\n\t\tAreaCode: areaCode[0],\n\t}\n\n\trStatus, err := rh.RegistrationService.RegisterFile(r.Context(), registration)\n\tif err != nil {\n\t\thttp.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\treturn\n\t}\n\trjson, err := json.Marshal(rStatus)\n\tif err != nil {\n\t\thttp.Error(w,\n\t\t\thttp.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tw.Write(rjson)\n}", "func (server SDKServer) Register(ctx context.Context, request *pb.RegisterRequest) (*pb.RegisterReply, error) {\n\tname := request.Identity\n\n\t//fee := request.Fee\n\tvar fee float64\n\tvar err error\n\tif fee, err = strconv.ParseFloat(\"0.01\", 64); err == nil {\n\t\t// TODO: Minimum fee\n\t\tfee = 0.01\n\t}\n\n\tchain := parseChainType(request.Chain)\n\n\t// First check if this account already exists, return with error if not\n\t_, stat := server.App.Accounts.FindNameOnChain(name, chain)\n\t// If this account already existsm don't let this go through\n\tif stat != status.MISSING_VALUE {\n\t\treturn nil, gstatus.Errorf(codes.AlreadyExists, \"Identity %s already exists\", name)\n\t}\n\n\tprivKey, pubKey := id.GenerateKeys(secret(name+chain.String()), true)\n\n\tpacket := action.SignAndPack(\n\t\taction.CreateRegisterRequest(\n\t\t\tname,\n\t\t\tchain.String(),\n\t\t\tglobal.Current.Sequence,\n\t\t\tglobal.Current.NodeName,\n\t\t\tnil,\n\t\t\tpubKey.Address(),\n\t\t\tfee))\n\tcomm.Broadcast(packet)\n\n\t// TODO: Use proper secret for key generation\n\treturn &pb.RegisterReply{\n\t\tOk: true,\n\t\tIdentity: name,\n\t\tPublicKey: pubKey.Bytes(),\n\t\tPrivateKey: privKey.Bytes(),\n\t}, nil\n}", "func (k *KubernetesScheduler) Registered(driver mesos.SchedulerDriver,\n\tframeworkId *mesos.FrameworkID, masterInfo *mesos.MasterInfo) {\n\tk.frameworkId = frameworkId\n\tk.masterInfo = masterInfo\n\tk.registered = true\n\tlog.Infof(\"Scheduler registered with the master: %v with frameworkId: %v\\n\", masterInfo, frameworkId)\n}", "func (mr *MockClusterRegistrationClientMockRecorder) Register(ctx, remoteConfig, remoteClusterName, remoteWriteNamespace, remoteContextName, discoverySource, registerOpts interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Register\", reflect.TypeOf((*MockClusterRegistrationClient)(nil).Register), ctx, remoteConfig, remoteClusterName, remoteWriteNamespace, remoteContextName, discoverySource, registerOpts)\n}", "func (am *AppchainManager) Register(info []byte) (bool, []byte) {\n\tchain := &Appchain{}\n\tif err := json.Unmarshal(info, chain); err != nil {\n\t\treturn false, []byte(err.Error())\n\t}\n\n\tres := &g.RegisterResult{}\n\tres.ID = chain.ID\n\n\ttmpChain := &Appchain{}\n\tok := am.GetObject(am.appchainKey(chain.ID), tmpChain)\n\n\tif ok && tmpChain.Status != g.GovernanceUnavailable {\n\t\tam.Persister.Logger().WithFields(logrus.Fields{\n\t\t\t\"id\": chain.ID,\n\t\t}).Info(\"Appchain has registered\")\n\t\tres.IsRegistered = true\n\t} else {\n\t\tam.SetObject(am.appchainKey(chain.ID), chain)\n\n\t\taddr, err := getAddr(chain.PublicKey)\n\t\tif err != nil {\n\t\t\treturn false, []byte(err.Error())\n\t\t}\n\t\tam.SetObject(am.appchainAddrKey(addr), chain.ID)\n\t\tam.Logger().WithFields(logrus.Fields{\n\t\t\t\"id\": chain.ID,\n\t\t}).Info(\"Appchain is registering\")\n\t\tres.IsRegistered = false\n\t}\n\n\tresData, err := json.Marshal(res)\n\tif err != nil {\n\t\treturn false, []byte(err.Error())\n\t}\n\n\treturn true, resData\n}", "func (p *Param) RegistrationStatus() uint32 {\n\tif p.Tag != RegistrationStatus {\n\t\treturn 0\n\t}\n\n\treturn p.decodeUint32ValData()\n}", "func (c *Client) Register(req *api.RegistrationRequest) (rr *api.RegistrationResponse, err error) {\n\tlog.Debugf(\"Register %+v\", req)\n\n\tif req.Name == \"\" {\n\t\treturn nil, errors.New(\"Register was called without a Name set\")\n\t}\n\n\treqBody, err := util.Marshal(req, \"RegistrationRequest\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpost, err := c.newPost(\"register\", reqBody)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar resp api.RegistrationResponse\n\terr = c.SendReq(post, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tlog.Debug(\"The register request completed successfully\")\n\treturn &resp, nil\n}", "func (_e *MockDataCoord_Expecter) Register() *MockDataCoord_Register_Call {\n\treturn &MockDataCoord_Register_Call{Call: _e.mock.On(\"Register\")}\n}", "func (m *Message) Registration() (*Registration, error) {\n\tif err := m.checkType(RegistrationName); err != nil {\n\t\treturn nil, err\n\t}\n\tif m.Raw == false {\n\t\treturn m.Payload.(*Registration), nil\n\t}\n\tobj := new(Registration)\n\treturn obj, m.unmarshalPayload(obj)\n}", "func registerValid(reg asm.Register) error {\n\tif reg > asm.R9 {\n\t\treturn errors.Errorf(\"invalid register %v\", reg)\n\t}\n\n\treturn nil\n}", "func register(ctx context.Context) error {\n\trw := ctx.HttpResponseWriter()\n\n\tname := ctx.PostValue(\"name\")\n\temail := ctx.PostValue(\"email\")\n\tpassword := ctx.PostValue(\"password\")\n\n\tfieldErrs, err := db.RegisterUser(name, email, password)\n\tif len(fieldErrs) > 0 {\n\t\tdata, err := json.Marshal(fieldErrs)\n\t\tif err != nil {\n\t\t\tlog.Error(\"Unable to marshal: \", err)\n\t\t\treturn goweb.Respond.WithStatus(ctx, http.StatusInternalServerError)\n\t\t}\n\t\trw.Header().Set(\"Content-Type\", \"application/json\")\n\t\treturn goweb.Respond.With(ctx, http.StatusBadRequest, data)\n\t}\n\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn goweb.Respond.WithStatus(ctx, http.StatusInternalServerError)\n\t}\n\n\t// everything went fine\n\tmsg := struct {\n\t\tBody string `json:\"body\"`\n\t\tType string `json:\"type\"`\n\t}{\n\t\tBody: \"Check your email to activate your account\",\n\t\tType: \"success\",\n\t}\n\tdata, err := json.Marshal(msg)\n\tif err != nil {\n\t\tlog.Error(\"Unable to marshal: \", err)\n\t\treturn goweb.Respond.WithStatus(ctx, http.StatusInternalServerError)\n\t}\n\trw.Header().Set(\"Content-Type\", \"application/json\")\n\treturn goweb.Respond.With(ctx, http.StatusOK, data)\n}", "func testRegister(t *testing.T, useTLS bool) {\n\tassert := assert.New(t)\n\tzero := 0\n\tassert.Equal(0, zero)\n\n\t// Create new TestPingServer - needed for calling RPCs\n\tmyJrpcfs := &TestPingServer{}\n\n\trrSvr := getNewServer(10*time.Second, false, useTLS)\n\tassert.NotNil(rrSvr)\n\n\t// Register the Server - sets up the methods supported by the\n\t// server\n\terr := rrSvr.Register(myJrpcfs)\n\tassert.Nil(err)\n\n\t// Make sure we discovered the correct functions\n\tassert.Equal(4, len(rrSvr.svrMap))\n}", "func (h *NotificationHub) Register(ctx context.Context, r Registration) (raw []byte, registrationResult *RegistrationResult, err error) {\n\tvar (\n\t\tregURL = h.generateAPIURL(\"registrations\")\n\t\tmethod = postMethod\n\t\tpayload = \"\"\n\t\theaders = map[string]string{\n\t\t\t\"Content-Type\": \"application/atom+xml;type=entry;charset=utf-8\",\n\t\t}\n\t)\n\n\tswitch r.NotificationFormat {\n\tcase AppleFormat:\n\t\tpayload = strings.Replace(appleRegXMLString, \"{{DeviceID}}\", r.DeviceID, 1)\n\tcase GcmFormat:\n\t\tpayload = strings.Replace(gcmRegXMLString, \"{{DeviceID}}\", r.DeviceID, 1)\n\tdefault:\n\t\treturn nil, nil, errors.New(\"Notification format not implemented\")\n\t}\n\tpayload = strings.Replace(payload, \"{{Tags}}\", r.Tags, 1)\n\n\tif r.RegistrationID != \"\" {\n\t\tmethod = putMethod\n\t\tregURL.Path = path.Join(regURL.Path, r.RegistrationID)\n\t}\n\n\traw, _, err = h.exec(ctx, method, regURL, headers, bytes.NewBufferString(payload))\n\n\tif err == nil {\n\t\tif err = xml.Unmarshal(raw, &registrationResult); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tif registrationResult != nil {\n\t\tregistrationResult.normalize()\n\t}\n\treturn\n}", "func TestV1RegisterDeviceStatusOK(t *testing.T) {\n\tapiTest.T = t\n\tdeviceID := newDeviceID()\n\ttruncateAllTableRelation()\n\ttestCaseStatusOK := []struct {\n\t\tname string\n\t\tparamRequest map[string][]string\n\t}{\n\t\t{\n\t\t\tname: \"deviceID is not existed\",\n\t\t\tparamRequest: map[string][]string{\n\t\t\t\t\"device_id\": {deviceID},\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tname: \"deviceID is existed\",\n\t\t\tparamRequest: map[string][]string{\n\t\t\t\t\"device_id\": {deviceID},\n\t\t\t},\n\t\t},\n\t}\n\n\tfor _, testCase := range testCaseStatusOK {\n\t\tt.Run(testCase.name, func(t *testing.T) {\n\t\t\tvar userExisted User\n\t\t\tif checkUserExisted(testCase.paramRequest[\"device_id\"][0]) {\n\t\t\t\tuserExisted, _ = getUserByUUID(testCase.paramRequest[\"device_id\"][0])\n\t\t\t}\n\t\t\tresp := sendRequest(testCase.paramRequest, \"application/x-www-form-urlencoded\", apiTest)\n\t\t\t// check status OK.\n\t\t\tcheckStatusCodeResponse(t, resp, http.StatusOK)\n\t\t\tresponse := &PostRegisterByDeviceResponse{}\n\t\t\tjson.Unmarshal(resp.Body.Bytes(), response)\n\t\t\tassert.Empty(t, response.Errors)\n\t\t\tassert.Empty(t, response.Message)\n\t\t\tassert.Equal(t, 3, len(strings.Split(response.Token, \".\")))\n\t\t\t// check not changed in db if user existed\n\t\t\tif userExisted.ID != 0 {\n\t\t\t\tuserAfterRegister, _ := getUserByUUID(testCase.paramRequest[\"device_id\"][0])\n\t\t\t\tassert.Equal(t, userAfterRegister.ID, userExisted.ID)\n\t\t\t}\n\t\t})\n\t}\n}", "func (k *KubernetesExecutor) Registered(driver bindings.ExecutorDriver,\n\texecutorInfo *mesos.ExecutorInfo, frameworkInfo *mesos.FrameworkInfo, slaveInfo *mesos.SlaveInfo) {\n\tif k.isDone() {\n\t\treturn\n\t}\n\tlog.Infof(\"Executor %v of framework %v registered with slave %v\\n\",\n\t\texecutorInfo, frameworkInfo, slaveInfo)\n\tif !k.swapState(disconnectedState, connectedState) {\n\t\t//programming error?\n\t\tpanic(\"already connected?!\")\n\t}\n}", "func Register(r * http.Request, response * APIResponse) {\n\tif AllowsRegister {\n\t\tif r.FormValue(\"username\") != \"\" && r.FormValue(\"password\") != \"\" && r.FormValue(\"name\") != \"\" {\n\t\t\tusername := r.FormValue(\"username\")\n\t\t\tpassword := r.FormValue(\"password\")\n\t\t\trealName := r.FormValue(\"name\")\n\t\t\tif len(password) > 5 && userNameIsValid(username) && nameIsValid(realName) {\n\t\t\t\tif !UserForUserNameExists(username) {\n\t\t\t\t\t//The password is acceptable, the username is untake and acceptable\n\t\t\t\t\t//Sign up user\n\t\t\t\t\tuser := User{}\n\t\t\t\t\tuser.Username = username\n\t\t\t\t\tuser.HashedPassword = hashString(password)\n\t\t\t\t\tuser.UserImageURL = \"userImages/default.png\"\n\t\t\t\t\tuser.RealName = realName\n\t\t\t\t\tAddUser(&user)\n\t\t\t\t\n\t\t\t\t\t//Log the user in\n\t\t\t\t\tLogin(r, response)\n\t\t\t\t} else {\n\t\t\t\t\tresponse.Message = \"Username already taken\"\n\t\t\t\t\te(\"API\", \"Username already taken\")\n\t\t\t\t\tresponse.SuccessCode = 400\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresponse.Message = \"Values do not meet requirements\"\n\t\t\t\te(\"API\", \"Password is too short or username is invalid\")\n\t\t\t\tresponse.SuccessCode = 400\n\t\t\t}\n\t\t} else {\n\t\t\tresponse.Message = \"More information required\"\n\t\t\te(\"API\", \"Couldn't register user - not enough detail\")\n\t\t\tresponse.SuccessCode = 400\n\t\t}\n\t} else {\n\t\tresponse.SuccessCode = 400\n\t\tresponse.Message = \"Server doesn't allow registration\"\n\t}\n}", "func (sma *SmIPAM) CompleteRegistration() {\n\n\tif featureflags.IsOVerlayRoutingEnabled() == false {\n\t\treturn\n\t}\n\n\tsma.sm.SetIPAMPolicyReactor(smgrIPAM)\n}", "func _TestRegisterDontAddIfError(t *testing.T) {\n\tfor i := 0; i < 10; i++ {\n\t\tsendNoEnoughNodesRequest(t)\n\t}\n}", "func IsRegistered(name string) bool {\n\treturn i.IsRegistered(name)\n}", "func (e *Extension) Registered(extensionName string, client *bayeux.BayeuxClient) {\n}", "func (session *Session) register() error {\n\n\t// Create registration\n\tcmd, err := CreateRegistration(session.registration.Host, session.registration.User)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Send registration to server\n\tlog.Println(\"Registering with the server.\")\n\tSendMessage(cmd, session.socket)\n\treturn nil\n}", "func IsRegistered(name string) bool {\n\t_, ok := registry[name]\n\treturn ok\n}", "func (a *Client) Register(params *RegisterParams) (*RegisterOK, error) {\n\t// TODO: Validate the params before sending\n\tif params == nil {\n\t\tparams = NewRegisterParams()\n\t}\n\n\tresult, err := a.transport.Submit(&runtime.ClientOperation{\n\t\tID: \"register\",\n\t\tMethod: \"POST\",\n\t\tPathPattern: \"/subjects/{subject}/versions\",\n\t\tProducesMediaTypes: []string{\"application/json; qs=0.5\", \"application/vnd.schemaregistry+json; qs=0.9\", \"application/vnd.schemaregistry.v1+json\"},\n\t\tConsumesMediaTypes: []string{\"application/json\", \"application/octet-stream\", \"application/vnd.schemaregistry+json\", \"application/vnd.schemaregistry.v1+json\"},\n\t\tSchemes: []string{\"http\", \"https\"},\n\t\tParams: params,\n\t\tReader: &RegisterReader{formats: a.formats},\n\t\tContext: params.Context,\n\t\tClient: params.HTTPClient,\n\t})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tsuccess, ok := result.(*RegisterOK)\n\tif ok {\n\t\treturn success, nil\n\t}\n\t// unexpected success response\n\t// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue\n\tmsg := fmt.Sprintf(\"unexpected success response for register: API contract not enforced by server. Client expected to get an error, but got: %T\", result)\n\tpanic(msg)\n}", "func (nb *Newsblur) Signup(UNIMPLEMENTED) {}", "func (self *Mediator) OnRegister() {\n\n}", "func (_e *MockQueryCoord_Expecter) Register() *MockQueryCoord_Register_Call {\n\treturn &MockQueryCoord_Register_Call{Call: _e.mock.On(\"Register\")}\n}", "func Register(\n\tc *gin.Context,\n\tuserService service.UserCommander,\n\tdispatcher queue.Publisher,\n) {\n\tvar req ar.RegisterRequest\n\tif isValid, errors := validation.ValidateRequest(c, &req); !isValid {\n\t\thttp.BadRequest(c, http.Errors(errors))\n\t\treturn\n\t}\n\n\tuser, err := userService.Create(c.Request.Context(), request.UserCreateRequest{\n\t\tFirstName: req.FirstName,\n\t\tLastName: req.LastName,\n\t\tEmail: req.Email,\n\t\tPassword: req.Password,\n\t\tRole: identityEntity.RoleConsumer,\n\t})\n\n\tif err != nil {\n\t\thttp.BadRequest(c, http.Errors{err.Error()})\n\t\treturn\n\t}\n\n\traiseSuccessfulRegistration(user.GetID(), dispatcher)\n\n\thttp.Created(c, http.Data{\n\t\t\"User\": user,\n\t}, nil)\n}", "func Register(g *gin.Context) {\n\t// init visitor User struct to validate request\n\tuser := new(models.User)\n\t/**\n\t* get request and parse it to validation\n\t* if there any error will return with message\n\t */\n\terr := validations.RegisterValidate(g, user)\n\t/***\n\t* return response if there an error if true you\n\t* this mean you have errors so we will return and bind data\n\t */\n\tif helpers.ReturnNotValidRequest(err, g) {\n\t\treturn\n\t}\n\t/**\n\t* check if this email exists database\n\t* if this email found will return\n\t */\n\tconfig.Db.Find(&user, \"email = ? \", user.Email)\n\tif user.ID != 0 {\n\t\thelpers.ReturnResponseWithMessageAndStatus(g, 400, \"this email is exist!\", false)\n\t\treturn\n\t}\n\t//set type 2\n\tuser.Type = 2\n\tuser.Password, _ = helpers.HashPassword(user.Password)\n\t// create new user based on register struct\n\tconfig.Db.Create(&user)\n\t// now user is login we can return his info\n\thelpers.OkResponse(g, \"Thank you for register in our system you can login now!\", user)\n}", "func MetricInitiateAccountRegistrationSuccess(provider string) {\n\tswitch strings.ToUpper(provider) {\n\tcase serviceprovider.FACEBOOK:\n\t\tPrometheusRegisterFacebookSuccessTotal.Inc()\n\tcase serviceprovider.GOOGLE:\n\t\tPrometheusRegisterGoogleSuccessTotal.Inc()\n\tdefault:\n\t\tPrometheusRegisterDefaultSuccessTotal.Inc()\n\t}\n}", "func (r *apiV1Router) Register(ctx *gin.Context) {\n\tname := ctx.PostForm(\"name\")\n\temail := ctx.PostForm(\"email\")\n\tpassword := ctx.PostForm(\"password\")\n\n\tif len(name) == 0 || len(email) == 0 || len(password) == 0 {\n\t\tr.logger.Warn(\"one of name, email or password not specified\", zap.String(\"name\", name), zap.String(\"email\", email), zap.String(\"password\", password))\n\t\tmodels.SendAPIError(ctx, http.StatusBadRequest, \"request must include the user's name, email and passowrd\")\n\t\treturn\n\t}\n\n\t_, err := r.userService.GetUserWithEmail(ctx, email)\n\tif err == nil {\n\t\tr.logger.Warn(\"email taken\", zap.String(\"email\", email))\n\t\tmodels.SendAPIError(ctx, http.StatusBadRequest, \"email taken\")\n\t\treturn\n\t}\n\n\tif err != services.ErrNotFound {\n\t\tr.logger.Error(\"could not query for user with email\", zap.String(\"email\", email), zap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\treturn\n\t}\n\n\thashedPassword, err := auth.GetHashForPassword(password)\n\tif err != nil {\n\t\tr.logger.Error(\"could not make hash for password\", zap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\treturn\n\t}\n\n\tuser, err := r.userService.CreateUser(ctx, name, email, hashedPassword, r.cfg.BaseAuthLevel)\n\tif err != nil {\n\t\tr.logger.Error(\"could not create user\",\n\t\t\tzap.String(\"name\", name),\n\t\t\tzap.String(\"email\", email),\n\t\t\tzap.Int(\"auth level\", int(r.cfg.BaseAuthLevel)),\n\t\t\tzap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\treturn\n\t}\n\n\temailToken, err := auth.NewJWT(*user, time.Now().Unix(), r.cfg.AuthTokenLifetime, auth.Email, []byte(r.env.Get(environment.JWTSecret)))\n\tif err != nil {\n\t\tr.logger.Error(\"could not generate JWT token\",\n\t\t\tzap.String(\"user id\", user.ID.Hex()),\n\t\t\tzap.Bool(\"JWT_SECRET set\", r.env.Get(environment.JWTSecret) != environment.DefaultEnvVarValue),\n\t\t\tzap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\tr.userService.DeleteUserWithEmail(ctx, email)\n\t\treturn\n\t}\n\terr = r.emailService.SendEmailVerificationEmail(*user, emailToken)\n\tif err != nil {\n\t\tr.logger.Error(\"could not send email verification email\",\n\t\t\tzap.String(\"user email\", user.Email),\n\t\t\tzap.String(\"noreply email\", r.cfg.Email.NoreplyEmailAddr),\n\t\t\tzap.Bool(\"SENDGRID_API_KEY set\", r.env.Get(environment.SendgridAPIKey) != environment.DefaultEnvVarValue),\n\t\t\tzap.Error(err))\n\t\tmodels.SendAPIError(ctx, http.StatusInternalServerError, \"something went wrong while creating new user\")\n\t\tr.userService.DeleteUserWithEmail(ctx, email)\n\t\treturn\n\t}\n\n\tctx.JSON(http.StatusOK, registerRes{\n\t\tResponse: models.Response{\n\t\t\tStatus: http.StatusOK,\n\t\t},\n\t\tUser: *user,\n\t})\n}", "func (w *Registration) WaitRegistration() {\n\tif w.Ready() {\n\t\treturn\n\t}\n\t<-w.readyChan\n}", "func (tqsc *Controller) Register() {\n}", "func TestEventRegistry(t *testing.T, newRegistry func() app.EventRegistry) {\n\ttests := []struct {\n\t\tscenario string\n\t\tsubName string\n\t\thandler func(*bool) interface{}\n\t\tcalled bool\n\t\tdispName string\n\t\tdispArg interface{}\n\t\tpanic bool\n\t}{\n\t\t{\n\t\t\tscenario: \"register and dispatch without arg\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} {\n\t\t\t\treturn func() {\n\t\t\t\t\t*called = true\n\t\t\t\t}\n\t\t\t},\n\t\t\tcalled: true,\n\t\t\tdispName: \"test\",\n\t\t\tdispArg: nil,\n\t\t},\n\t\t{\n\t\t\tscenario: \"register without arg and dispatch with arg\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} {\n\t\t\t\treturn func() {\n\t\t\t\t\t*called = true\n\t\t\t\t}\n\t\t\t},\n\t\t\tcalled: true,\n\t\t\tdispName: \"test\",\n\t\t\tdispArg: \"foobar\",\n\t\t},\n\t\t{\n\t\t\tscenario: \"register and dispatch with arg\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} {\n\t\t\t\treturn func(arg string) {\n\t\t\t\t\t*called = true\n\n\t\t\t\t\tif arg != \"hello\" {\n\t\t\t\t\t\tpanic(\"greet is not hello\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tcalled: true,\n\t\t\tdispName: \"test\",\n\t\t\tdispArg: \"hello\",\n\t\t},\n\t\t{\n\t\t\tscenario: \"register and dispatch with bad arg\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} {\n\t\t\t\treturn func(arg int) {\n\t\t\t\t\t*called = true\n\t\t\t\t}\n\t\t\t},\n\t\t\tcalled: false,\n\t\t\tdispName: \"test\",\n\t\t\tdispArg: \"hello\",\n\t\t},\n\t\t{\n\t\t\tscenario: \"register non func handler\",\n\t\t\tsubName: \"test\",\n\t\t\thandler: func(called *bool) interface{} { return nil },\n\t\t\tpanic: true,\n\t\t},\n\t}\n\n\tfor _, test := range tests {\n\t\tt.Run(test.scenario, func(t *testing.T) {\n\t\t\tdefer func() {\n\t\t\t\terr := recover()\n\n\t\t\t\tif err != nil && !test.panic {\n\t\t\t\t\tt.Error(err)\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\tcalled := false\n\n\t\t\tr := newRegistry()\n\t\t\tunsub := r.Subscribe(test.subName, test.handler(&called))\n\t\t\tdefer unsub()\n\n\t\t\tr.Dispatch(test.dispName, test.dispArg)\n\n\t\t\tif called != test.called {\n\t\t\t\tt.Error(\"called expected:\", test.called)\n\t\t\t\tt.Error(\"called: \", called)\n\t\t\t}\n\n\t\t\tif test.panic {\n\t\t\t\tt.Error(\"no panic\")\n\t\t\t}\n\t\t})\n\t}\n}", "func MustRegister(fn interface{}) {\n\tif err := Register(fn); err != nil {\n\t\tpanic(err)\n\t}\n}", "func (dscMgr *DSCMgrRc) CompleteRegistration() {\n\tif featureflags.IsOVerlayRoutingEnabled() == false {\n\t\treturn\n\t}\n\n\tdscMgr.sm.SetDistributedServiceCardReactor(dscMgr)\n\tdscMgr.sm.EnableSelectivePushForKind(\"DSCConfig\")\n}", "func (a *Account) GetRegistration() *acme.RegistrationResource { return a.registration }", "func (m *Manager) Register(args RegisterArgs, reply *string) error {\n\tfmt.Println(\"Registering key\", args.Key)\n\tfmt.Println(\"To tenant\", args.TenantID)\n\n\tm.validKeys[args.Key] = args.TenantID\n\t*reply = \"OK\"\n\treturn nil\n}", "func Register(context *gin.Context) {\n\tvar requestBody models.UserReq\n\tif context.ShouldBind(&requestBody) == nil {\n\t\tvalidCheck := validation.Validation{}\n\t\tvalidCheck.Required(requestBody.UserName, \"user_name\").Message(\"Must have user name\")\n\t\tvalidCheck.MaxSize(requestBody.UserName, 16, \"user_name\").Message(\"User name length can not exceed 16\")\n\t\tvalidCheck.MinSize(requestBody.UserName, 6, \"user_name\").Message(\"User name length is at least 6\")\n\t\tvalidCheck.Required(requestBody.Password, \"password\").Message(\"Must have password\")\n\t\tvalidCheck.MaxSize(requestBody.Password, 16, \"password\").Message(\"Password length can not exceed 16\")\n\t\tvalidCheck.MinSize(requestBody.Password, 6, \"password\").Message(\"Password length is at least 6\")\n\t\tvalidCheck.Required(requestBody.Email, \"email\").Message(\"Must have email\")\n\t\tvalidCheck.MaxSize(requestBody.Email, 128, \"email\").Message(\"Email can not exceed 128 chars\")\n\n\t\tresponseCode := constant.INVALID_PARAMS\n\t\tif !validCheck.HasErrors() {\n\t\t\tuserEntity := models.UserReq2User(requestBody)\n\t\t\tif err := models.InsertUser(userEntity); err == nil {\n\t\t\t\tresponseCode = constant.USER_ADD_SUCCESS\n\t\t\t} else {\n\t\t\t\tresponseCode = constant.USER_ALREADY_EXIST\n\t\t\t}\n\t\t} else {\n\t\t\tfor _, err := range validCheck.Errors {\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t}\n\n\t\tcontext.JSON(http.StatusOK, gin.H{\n\t\t\t\"code\": responseCode,\n\t\t\t\"data\": \"\",\n\t\t\t\"msg\": constant.GetMessage(responseCode),\n\t\t})\n\t} else {\n\t\tcontext.JSON(http.StatusOK, gin.H{\n\t\t\t\"code\": 200,\n\t\t\t\"data\": \"\",\n\t\t\t\"msg\": \"添加失败,参数有误\",\n\t\t})\n\t}\n}", "func (o *TechsupportmanagementEndPointAllOf) HasDeviceRegistration() bool {\n\tif o != nil && o.DeviceRegistration != nil {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func TestRegisterRPC(t *testing.T) {\n\tif testing.Short() {\n\t\tt.SkipNow()\n\t}\n\tt.Parallel()\n\tg := newTestingGateway(t)\n\tdefer g.Close()\n\n\tg.RegisterRPC(\"Foo\", func(conn modules.PeerConn) error { return nil })\n\tdefer func() {\n\t\tif r := recover(); r == nil {\n\t\t\tt.Error(\"Registering the same RPC twice did not cause a panic\")\n\t\t}\n\t}()\n\tg.RegisterRPC(\"Foo\", func(conn modules.PeerConn) error { return nil })\n}", "func middlewareRegistrationRestrictionTests(t *testing.T,\n\tnode *lntest.HarnessNode) {\n\n\ttestCases := []struct {\n\t\tregistration *lnrpc.MiddlewareRegistration\n\t\texpectedErr string\n\t}{{\n\t\tregistration: &lnrpc.MiddlewareRegistration{\n\t\t\tMiddlewareName: \"foo\",\n\t\t},\n\t\texpectedErr: \"invalid middleware name\",\n\t}, {\n\t\tregistration: &lnrpc.MiddlewareRegistration{\n\t\t\tMiddlewareName: \"itest-interceptor\",\n\t\t\tCustomMacaroonCaveatName: \"foo\",\n\t\t},\n\t\texpectedErr: \"custom caveat name of at least\",\n\t}, {\n\t\tregistration: &lnrpc.MiddlewareRegistration{\n\t\t\tMiddlewareName: \"itest-interceptor\",\n\t\t\tCustomMacaroonCaveatName: \"itest-caveat\",\n\t\t\tReadOnlyMode: true,\n\t\t},\n\t\texpectedErr: \"cannot set read-only and custom caveat name\",\n\t}}\n\n\tfor idx, tc := range testCases {\n\t\ttc := tc\n\n\t\tt.Run(fmt.Sprintf(\"%d\", idx), func(tt *testing.T) {\n\t\t\tinvalidName := registerMiddleware(\n\t\t\t\ttt, node, tc.registration,\n\t\t\t)\n\t\t\t_, err := invalidName.stream.Recv()\n\t\t\trequire.Error(tt, err)\n\t\t\trequire.Contains(tt, err.Error(), tc.expectedErr)\n\n\t\t\tinvalidName.cancel()\n\t\t})\n\t}\n}", "func (e *endpoints) registerRegistrationAPI(tcpServer, udpServer *grpc.Server) {\n\tr := &registration.Handler{\n\t\tLog: e.c.Log.WithField(\"subsystem_name\", \"registration_api\"),\n\t\tMetrics: e.c.Metrics,\n\t\tCatalog: e.c.Catalog,\n\t\tTrustDomain: e.c.TrustDomain,\n\t}\n\n\tregistration_pb.RegisterRegistrationServer(tcpServer, r)\n\tregistration_pb.RegisterRegistrationServer(udpServer, r)\n}", "func (k *KubernetesExecutor) Registered(driver bindings.ExecutorDriver,\n\texecutorInfo *mesos.ExecutorInfo, frameworkInfo *mesos.FrameworkInfo, slaveInfo *mesos.SlaveInfo) {\n\tif k.isDone() {\n\t\treturn\n\t}\n\tlog.Infof(\"Executor %v of framework %v registered with slave %v\\n\",\n\t\texecutorInfo, frameworkInfo, slaveInfo)\n\tif !(&k.state).transition(disconnectedState, connectedState) {\n\t\tlog.Errorf(\"failed to register/transition to a connected state\")\n\t}\n\n\tif executorInfo != nil && executorInfo.Data != nil {\n\t\tk.staticPodsConfig = executorInfo.Data\n\t}\n\n\tif slaveInfo != nil {\n\t\t_, err := node.CreateOrUpdate(k.client, slaveInfo.GetHostname(), node.SlaveAttributesToLabels(slaveInfo.Attributes))\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"cannot update node labels: %v\", err)\n\t\t}\n\t}\n\n\tk.initialRegistration.Do(k.onInitialRegistration)\n}", "func (o *TechsupportmanagementEndPointAllOf) GetDeviceRegistrationOk() (*AssetDeviceRegistrationRelationship, bool) {\n\tif o == nil || o.DeviceRegistration == nil {\n\t\treturn nil, false\n\t}\n\treturn o.DeviceRegistration, true\n}", "func (g *Group) Register(units ...Unit) []bool {\n\tg.log = logger.GetLogger(g.name)\n\thasRegistered := make([]bool, len(units))\n\tfor idx := range units {\n\t\tif !g.configured {\n\t\t\t// if RunConfig has been called we can no longer register Config\n\t\t\t// phases of Units\n\t\t\tif c, ok := units[idx].(Config); ok {\n\t\t\t\tg.c = append(g.c, c)\n\t\t\t\thasRegistered[idx] = true\n\t\t\t}\n\t\t}\n\t\tif p, ok := units[idx].(PreRunner); ok {\n\t\t\tg.p = append(g.p, p)\n\t\t\thasRegistered[idx] = true\n\t\t}\n\t\tif s, ok := units[idx].(Service); ok {\n\t\t\tg.s = append(g.s, s)\n\t\t\thasRegistered[idx] = true\n\t\t}\n\t}\n\treturn hasRegistered\n}", "func (reg *registrar) Register(example interface{}) error {\n\treg.lock.Lock()\n\tdefer reg.lock.Unlock()\n\treturn reg.Registry.Register(example)\n}", "func TestRegisterRoute(t *testing.T) {\n\t// test cases\n\ttests := []struct {\n\t\tmethod string\n\t\tpath string\n\t\thandler func(*fasthttp.RequestCtx)\n\t\tisErr bool\n\t}{\n\t\t{method: MethodPut, path: \"/admin/welcome\", handler: emptyHandler, isErr: false},\n\t\t{method: MethodPost, path: \"/user/add\", handler: emptyHandler, isErr: false},\n\t\t{method: MethodGet, path: \"/account/get\", handler: emptyHandler, isErr: false},\n\t\t{method: MethodGet, path: \"/account/*\", handler: emptyHandler, isErr: false},\n\t\t{method: MethodDelete, path: \"/account/delete\", handler: emptyHandler, isErr: false},\n\t\t{method: MethodDelete, path: \"/account/delete\", handler: nil, isErr: true},\n\t\t{method: MethodGet, path: \"/account/*/getAccount\", handler: nil, isErr: true},\n\t}\n\n\t// create gearbox instance\n\tgb := new(gearbox)\n\tgb.registeredRoutes = make([]*routeInfo, 0)\n\n\t// counter for valid routes\n\tvalidCounter := 0\n\n\tfor _, tt := range tests {\n\t\terr := gb.registerRoute(tt.method, tt.path, tt.handler)\n\t\tif (err != nil && !tt.isErr) || (err == nil && tt.isErr) {\n\t\t\terrMsg := \"\"\n\n\t\t\t// get error message if there is\n\t\t\tif err != nil {\n\t\t\t\terrMsg = err.Error()\n\t\t\t}\n\n\t\t\tt.Errorf(\"input %v find error %t %s expecting error %t\", tt, err == nil, errMsg, tt.isErr)\n\t\t}\n\n\t\tif !tt.isErr {\n\t\t\tvalidCounter++\n\t\t}\n\t}\n\n\t// check valid counter is the same as count of registered routes\n\tcurrentCount := len(gb.registeredRoutes)\n\tif validCounter != currentCount {\n\t\tt.Errorf(\"input %d find %d expecting %d\", validCounter, currentCount, validCounter)\n\t}\n}", "func (m *ClientMock) MinimockRegisterResultInspect() {\n\tfor _, e := range m.RegisterResultMock.expectations {\n\t\tif mm_atomic.LoadUint64(&e.Counter) < 1 {\n\t\t\tm.t.Errorf(\"Expected call to ClientMock.RegisterResult with params: %#v\", *e.params)\n\t\t}\n\t}\n\n\t// if default expectation was set then invocations count should be greater than zero\n\tif m.RegisterResultMock.defaultExpectation != nil && mm_atomic.LoadUint64(&m.afterRegisterResultCounter) < 1 {\n\t\tif m.RegisterResultMock.defaultExpectation.params == nil {\n\t\t\tm.t.Error(\"Expected call to ClientMock.RegisterResult\")\n\t\t} else {\n\t\t\tm.t.Errorf(\"Expected call to ClientMock.RegisterResult with params: %#v\", *m.RegisterResultMock.defaultExpectation.params)\n\t\t}\n\t}\n\t// if func was set then invocations count should be greater than zero\n\tif m.funcRegisterResult != nil && mm_atomic.LoadUint64(&m.afterRegisterResultCounter) < 1 {\n\t\tm.t.Error(\"Expected call to ClientMock.RegisterResult\")\n\t}\n}", "func (h *NotificationHub) Registration(ctx context.Context, registrationID string) (raw []byte, registrationResult *RegistrationResult, err error) {\n\tvar (\n\t\tregURL = h.generateAPIURL(path.Join(\"registrations\", registrationID))\n\t)\n\traw, _, err = h.exec(ctx, getMethod, regURL, Headers{}, nil)\n\tif err != nil {\n\t\treturn\n\t}\n\tif err = xml.Unmarshal(raw, &registrationResult); err != nil {\n\t\treturn\n\t}\n\tregistrationResult.RegistrationContent.normalize()\n\treturn\n}", "func Register(w http.ResponseWriter, r *http.Request) {\n\n\tPrintln(\"Endpoint Hit: Register\")\n\n\tvar response struct {\n\t\tStatus bool\n\t\tMessage string\n\t}\n\n\t// reqBody, _ := ioutil.ReadAll(r.Body)\n\t// var register_user models.Pet_Owner\n\t// json.Unmarshal(reqBody, &register_user)\n\n\t// email := register_user.Email\n\t// password := register_user.Password\n\t// name := register_user.Name\n\n\t//BIKIN VALIDATION\n\n\temail := r.FormValue(\"email\")\n\tpassword := r.FormValue(\"password\")\n\tname := r.FormValue(\"name\")\n\n\tif len(name) == 0 {\n\t\tmessage := \"Ada Kolom Yang Kosong\"\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(200)\n\t\tresponse.Status = false\n\t\tresponse.Message = message\n\t\tjson.NewEncoder(w).Encode(response)\n\t\treturn\n\t}\n\n\tif _, status := ValidateEmail(email); status != true {\n\t\tmessage := \"Format Email Kosong atau Salah\"\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(200)\n\t\tresponse.Status = false\n\t\tresponse.Message = message\n\t\tjson.NewEncoder(w).Encode(response)\n\t\treturn\n\t}\n\n\tif _, status := ValidatePassword(password); status != true {\n\t\tmessage := \"Format Password Kosong atau Salah, Minimal 6 Karakter\"\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(200)\n\t\tresponse.Status = false\n\t\tresponse.Message = message\n\t\tjson.NewEncoder(w).Encode(response)\n\t\treturn\n\t}\n\n\t//cek apakah email user sudah ada di database\n\t//query user dengan email tersebut\n\tstatus, _ := QueryUser(email)\n\n\t// kalo status false , berarti register\n\t// kalo status true, berarti print email terdaftar\n\n\tif status {\n\t\tmessage := \"Email sudah terdaftar\"\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tw.WriteHeader(200)\n\t\tresponse.Status = false\n\t\tresponse.Message = message\n\t\tjson.NewEncoder(w).Encode(response)\n\t\treturn\n\n\t} else {\n\t\t// hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.MinCost)\n\t\thashedPassword := password\n\t\tRole := 1\n\n\t\t// Println(hashedPassword)\n\t\tif len(hashedPassword) != 0 && checkErr(w, r, err) {\n\t\t\tstmt, err := db.Prepare(\"INSERT INTO account (Email, Name, Password, Role) VALUES (?,?,?,?)\")\n\t\t\tif err == nil {\n\t\t\t\t_, err := stmt.Exec(&email, &name, &hashedPassword, &Role)\n\t\t\t\tif err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tmessage := \"Register Succesfull\"\n\t\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\t\tw.WriteHeader(200)\n\t\t\t\tresponse.Status = true\n\t\t\t\tresponse.Message = message\n\t\t\t\tjson.NewEncoder(w).Encode(response)\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\tmessage := \"Registration Failed\"\n\t\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\t\tw.WriteHeader(200)\n\t\t\tresponse.Status = false\n\t\t\tresponse.Message = message\n\t\t\tjson.NewEncoder(w).Encode(response)\n\n\t\t}\n\t}\n}", "func (registry *interfaceRegistry) EnsureRegistered(impl interface{}) error {\n\tif reflect.ValueOf(impl).Kind() != reflect.Ptr {\n\t\treturn fmt.Errorf(\"%T is not a pointer\", impl)\n\t}\n\n\tif _, found := registry.implInterfaces[reflect.TypeOf(impl)]; !found {\n\t\treturn fmt.Errorf(\"%T does not have a registered interface\", impl)\n\t}\n\n\treturn nil\n}", "func (mr *MockOobServiceMockRecorder) RegisterActionEvent(arg0 interface{}) *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"RegisterActionEvent\", reflect.TypeOf((*MockOobService)(nil).RegisterActionEvent), arg0)\n}", "func (u *UserHandler) Register(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {\n\tvar registerReq domain.RegisterRequest\n\terr := json.NewDecoder(r.Body).Decode(&registerReq)\n\tif err != nil {\n\t\tlog.Warnf(\"Error decode user body when register : %s\", err)\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\terrors := u.Validator.Validate(registerReq)\n\tif errors != nil {\n\t\tlog.Warnf(\"Error validate register : %s\", err)\n\t\tw.WriteHeader(http.StatusBadRequest)\n\t\tw.Header().Set(\"Content-Type\", \"application/json\")\n\t\tjson.NewEncoder(w).Encode(errors)\n\t\treturn\n\t}\n\tuser := domain.User{\n\t\tName: registerReq.Name,\n\t\tEmail: registerReq.Email,\n\t\tPassword: registerReq.Password,\n\t}\n\terr = u.UserSerivce.Register(r.Context(), &user)\n\tif err != nil {\n\t\tlog.Warnf(\"Error register user : %s\", err)\n\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\treturn\n\t}\n\tresponse := SuccessResponse{\n\t\tMessage: \"Success Register User\",\n\t}\n\tw.Header().Set(\"Content-Type\", \"application/json\")\n\tjson.NewEncoder(w).Encode(response)\n\treturn\n}", "func Register(write http.ResponseWriter, request *http.Request) {\n\tvar object models.User\n\terr := json.NewDecoder(request.Body).Decode(&object)\n\tif err != nil {\n\t\thttp.Error(write, \"An error ocurred in user register. \"+err.Error(), 400)\n\t\treturn\n\t}\n\n\t//Validations\n\tif len(object.Email) == 0 {\n\t\thttp.Error(write, \"Email is required.\", 400)\n\t\treturn\n\t}\n\tif len(object.Password) < 6 {\n\t\thttp.Error(write, \"Password invalid, must be at least 6 characters.\", 400)\n\t\treturn\n\t}\n\n\t_, userFounded, _ := bd.CheckExistUser(object.Email)\n\n\tif userFounded {\n\t\thttp.Error(write, \"The email has already been registered.\", 400)\n\t\treturn\n\t}\n\n\t_, status, err := bd.InsertRegister(object)\n\n\tif err != nil {\n\t\thttp.Error(write, \"An error occurred in insert register user.\"+err.Error(), 400)\n\t\treturn\n\t}\n\n\tif !status {\n\t\thttp.Error(write, \"Not insert user register.\"+err.Error(), 400)\n\t\treturn\n\t}\n\n\twrite.WriteHeader(http.StatusCreated)\n}", "func (_UpkeepRegistrationRequests *UpkeepRegistrationRequestsTransactor) Register(opts *bind.TransactOpts, name string, encryptedEmail []byte, upkeepContract common.Address, gasLimit uint32, adminAddress common.Address, checkData []byte, amount *big.Int, source uint8) (*types.Transaction, error) {\n\treturn _UpkeepRegistrationRequests.contract.Transact(opts, \"register\", name, encryptedEmail, upkeepContract, gasLimit, adminAddress, checkData, amount, source)\n}", "func (sched *Scheduler) Registered(driver sched.SchedulerDriver, frameworkId *mesos.FrameworkID, masterInfo *mesos.MasterInfo) {\n\tsched.master = MasterConnStr(masterInfo)\n\tlog.Println(\"Taurus Framework Registered with Master\", sched.master)\n\t// Start the scheduler worker\n\tgo func() {\n\t\tlog.Printf(\"Starting %s framework scheduler worker\", FrameworkName)\n\t\tsched.errChan <- sched.Worker.Start(driver, masterInfo)\n\t}()\n}", "func (hc *httpClient) Register(info *InstanceInfo) (success bool, err error) {\n\tvar body []byte\n\tbody, err = json.Marshal(info)\n\tif err != nil {\n\t\treturn\n\t}\n\tparam := &requestParam{\n\t\tURL: hc.serviceUrl + uriApps + info.Instance.App,\n\t\tMethod: http.MethodPost,\n\t\tHeaders: hc.headers,\n\t\tBody: string(body),\n\t\tUsername: hc.username,\n\t\tPassword: hc.password,\n\t}\n\tvar statusCode int\n\t_, statusCode, err = handleHttpRequest(param)\n\tif err != nil {\n\t\thc.handleError(err)\n\t}\n\tif statusCode == http.StatusOK || statusCode == http.StatusNoContent {\n\t\tsuccess = true\n\t}\n\n\treturn\n}", "func (mr *MockHubMockRecorder) RegisteredClients() *gomock.Call {\n\tmr.mock.ctrl.T.Helper()\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"RegisteredClients\", reflect.TypeOf((*MockHub)(nil).RegisteredClients))\n}", "func Register(c *gin.Context) {\n\tvar registerRequest types.RegisterRequest\n\terr := c.BindJSON(&registerRequest)\n\tif err != nil {\n\t\tresponse := types.APIErrResponse{Msg: \"Please check your data\", Success: false, Err: err.Error()}\n\t\tc.JSON(http.StatusBadRequest, response)\n\t\treturn\n\t}\n\n\t// Validate register request struct\n\t_, err = govalidator.ValidateStruct(registerRequest)\n\tif err != nil {\n\t\terrMap := govalidator.ErrorsByField(err)\n\t\tresponse := types.APIErrResponse{Msg: \"Please check your data\", Success: false, Err: errMap}\n\t\tc.JSON(http.StatusBadRequest, response)\n\t\treturn\n\t}\n\n\t// Maybe add same tag in govalidator\n\tif registerRequest.Password != registerRequest.PasswordAgain {\n\t\terrMap := make(map[string]string)\n\t\terrMap[\"password_again\"] = \"Password again must be equal to password\"\n\t\tc.JSON(http.StatusBadRequest, gin.H{\"msg\": \"Please check your data\", \"err\": errMap})\n\t\treturn\n\t}\n\n\t// hash password\n\tbytePassword := []byte(registerRequest.Password)\n\thashedPassword := hashPassword(bytePassword)\n\n\t// Save user\n\ttx, err := models.DB.Begin()\n\tdefer tx.Rollback()\n\n\tuser := models.User{}\n\tuser.Email = registerRequest.Email\n\tuser.Password = hashedPassword\n\tuser.IsAdmin = 0\n\tif err = user.Save(tx); err != nil {\n\t\tresponse := types.APIErrResponse{Msg: \"Please check your data\", Success: false, Err: err.Error()}\n\t\tc.JSON(http.StatusNotFound, response)\n\t} else {\n\t\ttx.Commit()\n\t\tresponse := types.APIResponse{Msg: \"Register user successfully\", Success: true}\n\t\tc.JSON(http.StatusOK, response)\n\t}\n}" ]
[ "0.6324035", "0.6104856", "0.60354984", "0.6025592", "0.59889084", "0.5973536", "0.595364", "0.5939176", "0.59270525", "0.59216005", "0.5921067", "0.5891129", "0.5848316", "0.5830676", "0.58157265", "0.58123446", "0.58084095", "0.57710874", "0.57505393", "0.5747051", "0.57046664", "0.5702086", "0.56968975", "0.56950843", "0.56934893", "0.56924874", "0.56924874", "0.56924874", "0.5690212", "0.56812865", "0.56616664", "0.5658534", "0.56533355", "0.5648434", "0.56426495", "0.5640439", "0.5624993", "0.5592196", "0.55718374", "0.55506307", "0.5540373", "0.55221534", "0.5513259", "0.5512379", "0.5488571", "0.54850304", "0.5468531", "0.54537016", "0.5435428", "0.543271", "0.54315734", "0.5427417", "0.5421234", "0.5413997", "0.54089934", "0.5392226", "0.53792024", "0.5375255", "0.5374012", "0.537207", "0.5369696", "0.53695655", "0.5352316", "0.5351508", "0.5349284", "0.5349182", "0.534717", "0.533631", "0.53332144", "0.53327876", "0.5324536", "0.5313824", "0.53124857", "0.53022206", "0.5289912", "0.52839184", "0.52837837", "0.52817345", "0.5271078", "0.52697915", "0.5267168", "0.52546704", "0.5254355", "0.52535933", "0.5251936", "0.5247192", "0.52449346", "0.52408713", "0.52341485", "0.52196276", "0.5216522", "0.5215678", "0.5209137", "0.5208415", "0.52026755", "0.52018905", "0.5200701", "0.51957774", "0.51956624", "0.51915264" ]
0.7010462
0
Popup is a wrapper around gtk_popover_popup().
func (v *Popover) Popup() { C.gtk_popover_popup(v.native()) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *Popover) Popdown() {\n\tC.gtk_popover_popdown(v.native())\n}", "func Popup(name string) *PopupWidget {\n\treturn &PopupWidget{\n\t\tname: Context.FontAtlas.RegisterString(name),\n\t\tflags: 0,\n\t\tlayout: nil,\n\t}\n}", "func NewPopupMenu(parent Widget, b Base, mo ...MenuOption) *PopupMenu {\n\tpm := &PopupMenu{\n\t\tPanel: NewPanel(nil, b),\n\t}\n\tInitWidget(parent, pm)\n\tpad := pm.MyTheme().Pad\n\tbtH := b.Rect.H() - pad\n\tbtW := b.Rect.W() - pad*2\n\tpm.Rect = R(pm.Rect.Min.X, pm.Rect.Max.Y-pm.Rect.H()*float64(len(mo))-pad,\n\t\tpm.Rect.Max.X, pm.Rect.Max.Y)\n\ty := pm.Rect.H() - pad\n\tfor _, o := range mo {\n\t\tbt := NewPushButton(pm, Base{\n\t\t\tRect: R(pad, y-btH, pad+btW, y),\n\t\t\tText: o.Text,\n\t\t\tImage: o.Image,\n\t\t\tDisabled: o.Disabled,\n\t\t})\n\t\ty -= btH + pad\n\t\to := o\n\t\tbt.OnPress = func() {\n\t\t\tfmt.Printf(\"popup menu onpress before popdown o=%+v\\n\", o)\n\t\t\tbt.Surface.PopDownTo(pm)\n\t\t\tfmt.Printf(\"popup menu onpress after popdown o=%+v\\n\", o)\n\t\t\tif o.Handler != nil {\n\t\t\t\tfmt.Printf(\"popup menu onpress before handler\\n\")\n\t\t\t\tclose := o.Handler(pm)\n\t\t\t\tfmt.Printf(\"popup menu onpress after handler =%v\\n\", close)\n\t\t\t\tif close {\n\t\t\t\t\tpm.Surface.PopDownTo(nil)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tow := optWidget{\n\t\t\topt: o,\n\t\t\tw: bt,\n\t\t}\n\t\tpm.opts = append(pm.opts, ow)\n\t}\n\tpm.Surface.PopUp(pm)\n\treturn pm\n}", "func NewPopup(p tview.Primitive) *Popup {\n\t_, _, width, height := p.GetRect()\n\tpopup := &Popup{\n\t\tflex: tview.NewFlex().\n\t\t\tAddItem(nil, 0, 1, false).\n\t\t\tAddItem(tview.NewFlex().\n\t\t\t\tSetDirection(tview.FlexRow).\n\t\t\t\tAddItem(nil, 0, 1, false).\n\t\t\t\tAddItem(p, height, 1, false).\n\t\t\t\tAddItem(nil, 0, 1, false), width, 1, false).\n\t\t\tAddItem(nil, 0, 1, false),\n\t}\n\tpopup.content = p\n\treturn popup\n}", "func Popup(prompt string, options ...string) (selection string, err error) {\n\t//selection, err = defaultDmenu().Popup(prompt, options...)\n\tdmenu := defaultDmenu()\n\tselection, err = dmenu.Popup(prompt, options...)\n\treturn\n}", "func MakePopover(ptr unsafe.Pointer) *NSPopover {\n\tif ptr == nil {\n\t\treturn nil\n\t}\n\treturn &NSPopover{\n\t\tNSResponder: *MakeResponder(ptr),\n\t}\n}", "func (s *State) OpenPopup(bounds image.Rectangle, d Component) Popup {\n\tif s.root != nil {\n\t\ts.focused = d\n\t\ts.update = true\n\t\treturn s.root.OpenPopup(bounds.Add(s.bounds.Min), d)\n\t}\n\treturn nil\n}", "func PopupModal(name string) *PopupModalWidget {\n\treturn &PopupModalWidget{\n\t\tname: Context.FontAtlas.RegisterString(name),\n\t\topen: nil,\n\t\tflags: WindowFlagsNoResize,\n\t\tlayout: nil,\n\t}\n}", "func OpenPopup(name string) {\n\timgui.OpenPopup(name)\n}", "func (v *MenuButton) GetPopover() *Popover {\n\tc := C.gtk_menu_button_get_popover(v.native())\n\tif c == nil {\n\t\treturn nil\n\t}\n\treturn wrapPopover(glib.Take(unsafe.Pointer(c)))\n}", "func (v *MenuButton) SetPopover(popover *Popover) {\n\tC.gtk_menu_button_set_popover(v.native(), popover.toWidget())\n}", "func (v *MenuButton) SetPopup(menu IMenu) {\n\tC.gtk_menu_button_set_popup(v.native(), menu.toWidget())\n}", "func (p *PopUpMenu) Show() {\n\tp.overlay.Show()\n\tp.Menu.Show()\n}", "func (v *MenuButton) SetUsePopover(setting bool) {\n\tC.gtk_menu_button_set_use_popover(v.native(), gbool(setting))\n}", "func (v *ScaleButton) GetPopup() (*Widget, error) {\n\tc := C.gtk_scale_button_get_popup(v.native())\n\tif c == nil {\n\t\treturn nil, nilPtrErr\n\t}\n\tobj := glib.Take(unsafe.Pointer(c))\n\treturn wrapWidget(obj), nil\n}", "func (v *MenuButton) GetPopup() *Menu {\n\tc := C.gtk_menu_button_get_popup(v.native())\n\tif c == nil {\n\t\treturn nil\n\t}\n\tobj := glib.Take(unsafe.Pointer(c))\n\treturn wrapMenu(obj)\n}", "func NewPopUpMenu(menu *fyne.Menu, c fyne.Canvas) *PopUpMenu {\n\tp := &PopUpMenu{Menu: NewMenu(menu), canvas: c}\n\tp.Menu.Resize(p.Menu.MinSize())\n\tp.Menu.customSized = true\n\to := widget.NewOverlayContainer(p.Menu, c, p.Dismiss)\n\to.Resize(o.MinSize())\n\tp.overlay = o\n\tp.OnDismiss = func() {\n\t\tp.Hide()\n\t}\n\treturn p\n}", "func (p *PopupWidget) Build() {\n\tif imgui.BeginPopup(p.name, int(p.flags)) {\n\t\tp.layout.Build()\n\t\timgui.EndPopup()\n\t}\n}", "func (d *Dmenu) Popup(prompt string, options ...string) (selection string, err error) {\n\tprocessedArgs := []string{}\n\tfor _, arg := range d.arguments {\n\t\tvar parg string\n\t\tif strings.Contains(arg, \"%s\") {\n\t\t\tparg = fmt.Sprintf(arg, prompt)\n\t\t} else {\n\t\t\tparg = arg\n\t\t}\n\n\t\tprocessedArgs = append(processedArgs, parg)\n\t}\n\tcmd := exec.Command(d.command, processedArgs...)\n\n\tstdin, err := cmd.StdinPipe()\n\n\tif err != nil {\n\t\tlog.Fatalf(\"Error getting pipe: %s\", err)\n\t}\n\n\tgo func(stdin io.WriteCloser) {\n\t\tdefer stdin.Close()\n\t\tio.WriteString(stdin, strings.Join(options, \"\\n\"))\n\t}(stdin)\n\n\tbyteOut, err := cmd.Output()\n\n\tif err != nil {\n\t\tif exiterr, ok := err.(*exec.ExitError); ok {\n\t\t\tif status, ok := exiterr.Sys().(syscall.WaitStatus); ok {\n\t\t\t\tif status.ExitStatus() == 1 {\n\t\t\t\t\terr = &EmptySelectionError{}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn \"\", err\n\t}\n\n\t// Cast and trim\n\tselection = strings.TrimSpace(string(byteOut))\n\n\treturn\n}", "func (p *Popup) ParentWindow() IWindow {\n\treturn p.parentWindow\n}", "func PopStyle() {\n\timgui.PopStyleVar()\n}", "func (v *MenuButton) GetUsePopover() bool {\n\tc := C.gtk_menu_button_get_use_popover(v.native())\n\treturn gobool(c)\n}", "func (gui *Gui) createConfirmationPanel(g *gocui.Gui, currentView *gocui.View, title, prompt string, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {\n\treturn gui.createPopupPanel(g, currentView, title, prompt, handleConfirm, handleClose)\n}", "func (d *BrowserViewDelegate) OnPopupBrowserViewCreated(browserView, popupBrowserView *BrowserView, isDevtools int32) int32 {\n\treturn lookupBrowserViewDelegateProxy(d.Base().Base()).OnPopupBrowserViewCreated(d, browserView, popupBrowserView, isDevtools)\n}", "func (p *PopupModalWidget) Build() {\n\tif imgui.BeginPopupModalV(p.name, p.open, int(p.flags)) {\n\t\tp.layout.Build()\n\t\timgui.EndPopup()\n\t}\n}", "func NewPopTable(h SQLHandle) *PopTable {\n\treturn &PopTable{h}\n}", "func CloseCurrentPopup() {\n\timgui.CloseCurrentPopup()\n}", "func (p *PopupWidget) Flags(flags WindowFlags) *PopupWidget {\n\tp.flags = flags\n\treturn p\n}", "func (p *PopUpMenu) ShowAtPosition(pos fyne.Position) {\n\tp.Move(pos)\n\tp.Show()\n}", "func (p *PopupWidget) Layout(widgets ...Widget) *PopupWidget {\n\tp.layout = Layout(widgets)\n\treturn p\n}", "func TestGlCanvas_ResizeWithPopUpOverlay(t *testing.T) {\n\tw := createWindow(\"Test\")\n\tw.SetPadded(false)\n\n\tcontent := widget.NewLabel(\"Content\")\n\tover := widget.NewPopUp(widget.NewLabel(\"Over\"), w.Canvas())\n\tw.SetContent(content)\n\tw.Canvas().Overlays().Add(over)\n\n\tsize := fyne.NewSize(200, 100)\n\toverContentSize := over.Content.Size()\n\tassert.NotEqual(t, size, content.Size())\n\tassert.NotEqual(t, size, over.Size())\n\tassert.NotEqual(t, size, overContentSize)\n\n\tw.Resize(size)\n\tassert.Equal(t, size, content.Size(), \"canvas content is resized\")\n\tassert.Equal(t, size, over.Size(), \"canvas overlay is resized\")\n\tassert.Equal(t, overContentSize, over.Content.Size(), \"canvas overlay content is _not_ resized\")\n}", "func (*CMsgShowPopup) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{50}\n}", "func (p *Popup) RefreshRelativePlacement() {\n\tp.parentWindow.RefreshRelativePlacement()\n\tp.visible = p.visible && p.parentWindow.VisibleRecursive()\n\tx, y := p.parentWindow.Position()\n\tp.x = x + p.anchorX\n\tp.y = y + p.anchorY - p.anchorHeight\n}", "func ShowPopUpMenuAtPosition(menu *fyne.Menu, c fyne.Canvas, pos fyne.Position) {\n\tm := NewPopUpMenu(menu, c)\n\tm.ShowAtPosition(pos)\n}", "func (*CMsgDOTAPopup) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{8}\n}", "func PopStyleColor() {\n\timgui.PopStyleColor()\n}", "func PopItemWidth() {\n\timgui.PopItemWidth()\n}", "func (p *PopUpMenu) Hide() {\n\tp.overlay.Hide()\n\tp.Menu.Hide()\n}", "func (p *PopUpMenu) Resize(size fyne.Size) {\n\twidget.MoveWidget(&p.Base, p, p.adjustedPosition(p.Position(), size))\n\tp.Menu.Resize(size)\n}", "func TestCompletionEntry_ShowMenu(t *testing.T) {\n\tentry := createEntry()\n\twin := test.NewWindow(entry)\n\twin.Resize(fyne.NewSize(500, 300))\n\tdefer win.Close()\n\n\tentry.SetText(\"init\")\n\tassert.True(t, entry.popupMenu.Visible())\n\n}", "func (p *PopUpMenu) Move(pos fyne.Position) {\n\twidget.MoveWidget(&p.Base, p, p.adjustedPosition(pos, p.Size()))\n}", "func (p *Popup) SetParentWindow(w *Window) {\n\tp.parentWindow = w\n}", "func (x *CMsgDOTAPopup_PopupID) UnmarshalJSON(b []byte) error {\n\tnum, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = CMsgDOTAPopup_PopupID(num)\n\treturn nil\n}", "func (d *BrowserViewDelegate) GetDelegateForPopupBrowserView(browserView *BrowserView, settings *BrowserSettings, client *Client, isDevtools int32) *BrowserViewDelegate {\n\treturn lookupBrowserViewDelegateProxy(d.Base().Base()).GetDelegateForPopupBrowserView(d, browserView, settings, client, isDevtools)\n}", "func (*CMsgHidePopup) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{51}\n}", "func Open(w *Widget, container gowid.ISettableComposite, width gowid.IWidgetDimension, app gowid.IApp) {\n\tw.ov = overlay.New(w, container.SubWidget(),\n\t\tgowid.VAlignBottom{}, gowid.RenderWithUnits{U: 3}, // Intended to mean use as much vertical space as you need\n\t\tgowid.HAlignLeft{Margin: 5, MarginRight: 5}, width,\n\t\toverlay.Options{\n\t\t\tIgnoreLowerStyle: true,\n\t\t},\n\t)\n\n\tif _, ok := width.(gowid.IRenderFixed); ok {\n\t\tw.SetContentWidth(gowid.RenderFixed{}, app) // fixed or weight:1, ratio:0.5\n\t} else {\n\t\tw.SetContentWidth(gowid.RenderWithWeight{W: 1}, app) // fixed or weight:1, ratio:0.5\n\t}\n\tw.SetSavedSubWidget(container.SubWidget(), app)\n\tw.SetSavedContainer(container, app)\n\tcontainer.SetSubWidget(w.ov, app)\n\tw.SetOpen(true, app)\n}", "func ShowPreferencesDialog(parent gtk.IWindow, onMpdReconnect, onQueueColumnsChanged, onPlayerSettingChanged func()) {\n\t// Create the dialog\n\td := &PrefsDialog{\n\t\tonQueueColumnsChanged: onQueueColumnsChanged,\n\t\tonPlayerSettingChanged: onPlayerSettingChanged,\n\t}\n\n\t// Load the dialog layout and map the widgets\n\tbuilder, err := NewBuilder(prefsGlade)\n\tif err == nil {\n\t\terr = builder.BindWidgets(d)\n\t}\n\n\t// Check for errors\n\tif errCheck(err, \"ShowPreferencesDialog(): failed to initialise dialog\") {\n\t\tutil.ErrorDialog(parent, fmt.Sprint(glib.Local(\"Failed to load UI widgets\"), err))\n\t\treturn\n\t}\n\tdefer d.PreferencesDialog.Destroy()\n\n\t// Set the dialog up\n\td.PreferencesDialog.SetTransientFor(parent)\n\n\t// Remove the 2-pixel \"aura\" around the notebook\n\tif box, err := d.PreferencesDialog.GetContentArea(); err == nil {\n\t\tbox.SetBorderWidth(0)\n\t}\n\n\t// Map the handlers to callback functions\n\tbuilder.ConnectSignals(map[string]interface{}{\n\t\t\"on_PreferencesDialog_map\": d.onMap,\n\t\t\"on_Setting_change\": d.onSettingChange,\n\t\t\"on_MpdReconnect\": onMpdReconnect,\n\t\t\"on_ColumnMoveUpToolButton_clicked\": d.onColumnMoveUp,\n\t\t\"on_ColumnMoveDownToolButton_clicked\": d.onColumnMoveDown,\n\t})\n\n\t// Run the dialog\n\td.PreferencesDialog.Run()\n}", "func (s *State) HasPopups() bool {\n\treturn s.root != nil && s.root.HasPopups()\n}", "func (*CMsgPopupHTMLWindow) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{54}\n}", "func (p *PopupModalWidget) IsOpen(open *bool) *PopupModalWidget {\n\tp.open = open\n\treturn p\n}", "func Pop() Action {\n\treturn ActionPop{}\n}", "func (s *State) ClosePopups() {\n\tif s.root != nil {\n\t\ts.root.ClosePopups()\n\t\ts.update = true\n\t}\n}", "func (i *menuBarItem) Show() {\n\twidget.ShowWidget(&i.Base, i)\n}", "func (m *ModalState) Show(now time.Time, w layout.Widget) {\n\tm.content = w\n\tm.Appear(now)\n}", "func Modal(gtx C, max unit.Value, w layout.Widget) D {\n\treturn layout.Stack{}.Layout(\n\t\tgtx,\n\t\tlayout.Stacked(func(gtx C) D {\n\t\t\treturn util.Rect{\n\t\t\t\tSize: gtx.Constraints.Max,\n\t\t\t\tColor: color.NRGBA{A: 200},\n\t\t\t}.Layout(gtx)\n\t\t}),\n\t\tlayout.Stacked(func(gtx C) D {\n\t\t\treturn Centered(gtx, func(gtx C) D {\n\t\t\t\tcs := &gtx.Constraints\n\t\t\t\tif cs.Max.X > gtx.Px(max) {\n\t\t\t\t\tcs.Max.X = gtx.Px(max)\n\t\t\t\t}\n\t\t\t\treturn w(gtx)\n\t\t\t})\n\t\t}),\n\t)\n}", "func PopFont() {\n\timgui.PopFont()\n}", "func (win *Window) WindowPresent() {\n\twin.Candy().Guify(\"gtk_window_present\", win)\n}", "func NewPiPanelGTK() *pipanel.Frontend {\n\treturn &pipanel.Frontend{\n\t\tAlerter: gtkttsalerter.New(),\n\t\tAudioPlayer: beeper.New(),\n\t\tDisplayManager: pitouch.New(),\n\t\tPowerManager: systemdpwr.New(),\n\t}\n}", "func (t *MealRequestServlet) ProcessPopup(r *http.Request) *ApiResult {\n\tpopup_id_s := r.Form.Get(\"popupId\")\n\tpopup_id, err := strconv.ParseInt(popup_id_s, 10, 64)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn APIError(\"Malformed popup ID\", 400)\n\t}\n\tpopup, err := GetPopupById(t.db, popup_id)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn APIError(\"Invalid popup ID\", 400)\n\t}\n\tif popup.Processed == 1 {\n\t\treturn APISuccess(\"Already processed\")\n\t}\n\tif err = t.process_popup(popup); err != nil {\n\t\tlog.Println(err)\n\t\treturn APIError(\"Failed to process popup\", 400)\n\t}\n\treturn APISuccess(\"OK\")\n}", "func (p *PopupModalWidget) Flags(flags WindowFlags) *PopupModalWidget {\n\tp.flags = flags\n\treturn p\n}", "func (c *component) Tooltip() *Button {\n\treturn c.tooltip\n}", "func OverlayNew() *Overlay {\n\tc := C.gtk_overlay_new()\n\treturn wrapOverlay(unsafe.Pointer(c))\n}", "func (w *WidgetImplement) Tooltip() string {\n\treturn w.tooltip\n}", "func (r *CampaignRow) GetPopName() string { return *r.Data.PopName }", "func (r *CampaignRow) GetPopName() string { return *r.Data.PopName }", "func (v *Overlay) native() *C.GtkOverlay {\n\tif v == nil {\n\t\treturn nil\n\t}\n\treturn (*C.GtkOverlay)(v.Native())\n}", "func (p *Popup) AnchorHeight() int {\n\treturn p.anchorHeight\n}", "func (p *PageStack) StackPopped(o, top model.Component) {\n\to.Stop()\n\tp.StackTop(top)\n}", "func (me TAttlistOtherIDSource) IsPop() bool { return me.String() == \"POP\" }", "func TestCompletionEntry_WithEmptyOptions(t *testing.T) {\n\tentry := createEntry()\n\twin := test.NewWindow(entry)\n\twin.Resize(fyne.NewSize(500, 300))\n\tdefer win.Close()\n\n\tentry.OnChanged = func(s string) {\n\t\tentry.SetOptions([]string{})\n\t\tentry.ShowCompletion()\n\t}\n\n\tentry.SetText(\"foo\")\n\tassert.Nil(t, entry.popupMenu) // popupMenu should not being created\n}", "func HeapPop(h heap.Interface) interface{} {\n\tvar result = make(chan interface{})\n\theapPopChan <- heapPopChanMsg{\n\t\th: h,\n\t\tresult: result,\n\t}\n\treturn <-result\n}", "func (v *Popover) SetTransitionsEnabled(transitionsEnabled bool) {\n\tC.gtk_popover_set_transitions_enabled(v.native(), gbool(transitionsEnabled))\n}", "func InputDialog(opt ...interface{}) string {\n b, _ := gtk.BuilderNewFromFile(\"glade/input-dialog.glade\")\n d := GetDialog(b, \"input_dialog\")\n entry := GetEntry(b, \"input_entry\")\n\n for i, v := range(opt) {\n if i % 2 == 0 {\n key := v.(string)\n switch key {\n case \"title\":\n d.SetTitle(opt[i+1].(string))\n case \"label\":\n l := GetLabel(b,\"input_label\")\n l.SetText(opt[i+1].(string))\n case \"password-mask\":\n entry.SetInvisibleChar(opt[i+1].(rune))\n entry.SetVisibility(false)\n case \"default\":\n entry.SetText(opt[i+1].(string))\n }\n }\n }\n\n output := \"\"\n entry.Connect(\"activate\", func (o *gtk.Entry) { d.Response(gtk.RESPONSE_OK) } )\n btok := GetButton(b, \"bt_ok\")\n btok.Connect(\"clicked\", func (b *gtk.Button) { d.Response(gtk.RESPONSE_OK) } )\n\n btcancel := GetButton(b, \"bt_cancel\")\n btcancel.Connect(\"clicked\", func (b *gtk.Button) { d.Response(gtk.RESPONSE_CANCEL) } )\n\n code := d.Run()\n if code == gtk.RESPONSE_OK {\n output, _ = entry.GetText()\n }\n\n d.Destroy()\n return output\n}", "func (g *Grid) Show() {\n\tC.uiControlShow(g.c)\n}", "func BuildModal(p tview.Primitive, width, height int) tview.Primitive {\n\tcpnt := tview.NewFlex().SetDirection(tview.FlexRow).\n\t\tAddItem(nil, 0, 1, false).\n\t\tAddItem(p, height, 1, false).\n\t\tAddItem(nil, 0, 1, false)\n\n\treturn tview.NewFlex().\n\t\tAddItem(nil, 0, 1, false).\n\t\tAddItem(cpnt, width, 1, false).\n\t\tAddItem(nil, 0, 1, false)\n}", "func EditPerformerWindow() *EditPerformer {\n\twin := SetupPopupWindow(\"Edit Performer\", 350, 216)\n\tbox := SetupBox()\n\tnb := SetupNotebook()\n\ttb := SetupToolbar()\n\tsave := SetupToolButtonLabel(\"Save\")\n\n\tgroupContent := NewGroupContent()\n\tpersonContent := NewPersonContent()\n\n\tsave.SetExpand(true)\n\tsave.SetVExpand(true)\n\n\ttb.Add(save)\n\ttb.SetHExpand(true)\n\n\tnb.AppendPage(personContent.grid, SetupLabel(\"Person\"))\n\tnb.AppendPage(groupContent.grid, SetupLabel(\"Group\"))\n\n\tbox.Add(nb)\n\tbox.Add(tb)\n\n\twin.Add(box)\n\twin.ShowAll()\n\n\treturn &EditPerformer{\n\t\tGroupContent: groupContent,\n\t\tNotebook: nb,\n\t\tPersonContent: personContent,\n\t\tSaveB: save,\n\t\tWin: win,\n\t}\n}", "func (p *PopUpMenu) CreateRenderer() fyne.WidgetRenderer {\n\treturn p.overlay.CreateRenderer()\n}", "func SetOnPop(fn func(v interface{})) {\n\n\texec.OnPop = fn\n}", "func (r *CampaignRow) SetPopName(popName string) { r.Data.PopName = &popName }", "func (r *CampaignRow) SetPopName(popName string) { r.Data.PopName = &popName }", "func (ptr *Application) onClickMenuEditPaste() {\n\tptr.textEditor.Paste()\n}", "func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error) {\n\t// should be the first defer statement to make sure it is executed last\n\t// and all the needed cleanup can be done before\n\tcancel, exit := internal.NewCancelationSignal(p.OnInterruptFunc)\n\tdefer exit()\n\n\tif len(text) == 0 || Sprint(text[0]) == \"\" {\n\t\ttext = []string{p.DefaultText}\n\t}\n\n\tp.text = p.TextStyle.Sprint(text[0])\n\tp.fuzzySearchMatches = append([]string{}, p.Options...)\n\n\tif p.MaxHeight == 0 {\n\t\tp.MaxHeight = DefaultInteractiveMultiselect.MaxHeight\n\t}\n\n\tmaxHeight := p.MaxHeight\n\tif maxHeight > len(p.fuzzySearchMatches) {\n\t\tmaxHeight = len(p.fuzzySearchMatches)\n\t}\n\n\tif len(p.Options) == 0 {\n\t\treturn nil, fmt.Errorf(\"no options provided\")\n\t}\n\n\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[:maxHeight]...)\n\tp.displayedOptionsStart = 0\n\tp.displayedOptionsEnd = maxHeight\n\n\tfor _, option := range p.DefaultOptions {\n\t\tp.selectOption(option)\n\t}\n\n\tarea, err := DefaultArea.Start(p.renderSelectMenu())\n\tdefer area.Stop()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not start area: %w\", err)\n\t}\n\n\tif p.Filter && (p.KeyConfirm == keys.Space || p.KeySelect == keys.Space) {\n\t\treturn nil, fmt.Errorf(\"if filter/search is active, keys.Space can not be used for KeySelect or KeyConfirm\")\n\t}\n\n\tarea.Update(p.renderSelectMenu())\n\n\tcursor.Hide()\n\tdefer cursor.Show()\n\terr = keyboard.Listen(func(keyInfo keys.Key) (stop bool, err error) {\n\t\tkey := keyInfo.Code\n\n\t\tif p.MaxHeight > len(p.fuzzySearchMatches) {\n\t\t\tmaxHeight = len(p.fuzzySearchMatches)\n\t\t} else {\n\t\t\tmaxHeight = p.MaxHeight\n\t\t}\n\n\t\tswitch key {\n\t\tcase p.KeyConfirm:\n\t\t\tif len(p.fuzzySearchMatches) == 0 {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\tarea.Update(p.renderFinishedMenu())\n\t\t\treturn true, nil\n\t\tcase p.KeySelect:\n\t\t\tif len(p.fuzzySearchMatches) > 0 {\n\t\t\t\t// Select option if not already selected\n\t\t\t\tp.selectOption(p.fuzzySearchMatches[p.selectedOption])\n\t\t\t}\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.RuneKey:\n\t\t\tif p.Filter {\n\t\t\t\t// Fuzzy search for options\n\t\t\t\t// append to fuzzy search string\n\t\t\t\tp.fuzzySearchString += keyInfo.String()\n\t\t\t\tp.selectedOption = 0\n\t\t\t\tp.displayedOptionsStart = 0\n\t\t\t\tp.displayedOptionsEnd = maxHeight\n\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[:maxHeight]...)\n\t\t\t}\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Space:\n\t\t\tif p.Filter {\n\t\t\t\tp.fuzzySearchString += \" \"\n\t\t\t\tp.selectedOption = 0\n\t\t\t\tarea.Update(p.renderSelectMenu())\n\t\t\t}\n\t\tcase keys.Backspace:\n\t\t\t// Remove last character from fuzzy search string\n\t\t\tif len(p.fuzzySearchString) > 0 {\n\t\t\t\t// Handle UTF-8 characters\n\t\t\t\tp.fuzzySearchString = string([]rune(p.fuzzySearchString)[:len([]rune(p.fuzzySearchString))-1])\n\t\t\t}\n\n\t\t\tif p.fuzzySearchString == \"\" {\n\t\t\t\tp.fuzzySearchMatches = append([]string{}, p.Options...)\n\t\t\t}\n\n\t\t\tp.renderSelectMenu()\n\n\t\t\tif len(p.fuzzySearchMatches) > p.MaxHeight {\n\t\t\t\tmaxHeight = p.MaxHeight\n\t\t\t} else {\n\t\t\t\tmaxHeight = len(p.fuzzySearchMatches)\n\t\t\t}\n\n\t\t\tp.selectedOption = 0\n\t\t\tp.displayedOptionsStart = 0\n\t\t\tp.displayedOptionsEnd = maxHeight\n\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Left:\n\t\t\t// Unselect all options\n\t\t\tp.selectedOptions = []int{}\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Right:\n\t\t\t// Select all options\n\t\t\tp.selectedOptions = []int{}\n\t\t\tfor i := 0; i < len(p.Options); i++ {\n\t\t\t\tp.selectedOptions = append(p.selectedOptions, i)\n\t\t\t}\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Up:\n\t\t\tif len(p.fuzzySearchMatches) == 0 {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\tif p.selectedOption > 0 {\n\t\t\t\tp.selectedOption--\n\t\t\t\tif p.selectedOption < p.displayedOptionsStart {\n\t\t\t\t\tp.displayedOptionsStart--\n\t\t\t\t\tp.displayedOptionsEnd--\n\t\t\t\t\tif p.displayedOptionsStart < 0 {\n\t\t\t\t\t\tp.displayedOptionsStart = 0\n\t\t\t\t\t\tp.displayedOptionsEnd = maxHeight\n\t\t\t\t\t}\n\t\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tp.selectedOption = len(p.fuzzySearchMatches) - 1\n\t\t\t\tp.displayedOptionsStart = len(p.fuzzySearchMatches) - maxHeight\n\t\t\t\tp.displayedOptionsEnd = len(p.fuzzySearchMatches)\n\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\t\t\t}\n\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.Down:\n\t\t\tif len(p.fuzzySearchMatches) == 0 {\n\t\t\t\treturn false, nil\n\t\t\t}\n\t\t\tp.displayedOptions = p.fuzzySearchMatches[:maxHeight]\n\t\t\tif p.selectedOption < len(p.fuzzySearchMatches)-1 {\n\t\t\t\tp.selectedOption++\n\t\t\t\tif p.selectedOption >= p.displayedOptionsEnd {\n\t\t\t\t\tp.displayedOptionsStart++\n\t\t\t\t\tp.displayedOptionsEnd++\n\t\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tp.selectedOption = 0\n\t\t\t\tp.displayedOptionsStart = 0\n\t\t\t\tp.displayedOptionsEnd = maxHeight\n\t\t\t\tp.displayedOptions = append([]string{}, p.fuzzySearchMatches[p.displayedOptionsStart:p.displayedOptionsEnd]...)\n\t\t\t}\n\n\t\t\tarea.Update(p.renderSelectMenu())\n\t\tcase keys.CtrlC:\n\t\t\tcancel()\n\t\t\treturn true, nil\n\t\t}\n\n\t\treturn false, nil\n\t})\n\tif err != nil {\n\t\tError.Println(err)\n\t\treturn nil, fmt.Errorf(\"failed to start keyboard listener: %w\", err)\n\t}\n\n\tvar result []string\n\tfor _, selectedOption := range p.selectedOptions {\n\t\tresult = append(result, p.Options[selectedOption])\n\t}\n\n\treturn result, nil\n}", "func newDialogFromNative(obj unsafe.Pointer) interface{} {\n\td := &Dialog{}\n\td.object = C.to_GtkDialog(obj)\n\n\tif gobject.IsObjectFloating(d) {\n\t\tgobject.RefSink(d)\n\t} else {\n\t\tgobject.Ref(d)\n\t}\n\td.Window = newWindowFromNative(obj).(*Window)\n\tdialogFinalizer(d)\n\n\treturn d\n}", "func (ctx *PQContext) Pop(params []string) apis.IResponse {\n\tvar err *mpqerr.ErrorResponse\n\tvar limit int64 = 1\n\tvar asyncId string\n\n\tpopWaitTimeout := ctx.pq.config.PopWaitTimeout\n\n\tfor len(params) > 0 {\n\t\tswitch params[0] {\n\t\tcase PRM_LIMIT:\n\t\t\tparams, limit, err = mpqproto.ParseInt64Param(params, 1, conf.CFG_PQ.MaxPopBatchSize)\n\t\tcase PRM_POP_WAIT:\n\t\t\tparams, popWaitTimeout, err = mpqproto.ParseInt64Param(params, 0, conf.CFG_PQ.MaxPopWaitTimeout)\n\t\tcase PRM_ASYNC:\n\t\t\tparams, asyncId, err = mpqproto.ParseItemId(params)\n\t\tdefault:\n\t\t\treturn mpqerr.UnknownParam(params[0])\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif len(asyncId) > 0 {\n\t\treturn ctx.asyncPop(asyncId, 0, popWaitTimeout, limit, false)\n\t} else {\n\t\treturn ctx.pq.Pop(0, popWaitTimeout, limit, false)\n\t}\n}", "func (canvas *Canvas) Pop() {\n\twriteCommand(canvas.contents, \"Q\")\n}", "func PopTimeoutOption(t time.Duration) Option {\n\treturn func(config *config) {\n\t\tconfig.popTimeout = t\n\t}\n}", "func newMessageDialogFromNative(obj unsafe.Pointer) interface{} {\n\td := &MessageDialog{}\n\td.object = C.to_GtkMessageDialog(obj)\n\n\tif gobject.IsObjectFloating(d) {\n\t\tgobject.RefSink(d)\n\t} else {\n\t\tgobject.Ref(d)\n\t}\n\td.Dialog = newDialogFromNative(obj).(*Dialog)\n\tmessageDialogFinalizer(d)\n\treturn d\n}", "func (self *TSPAlgorithm) RandomPop() *Population {\n\tp := Population{\n\t\tMutThreshold: 0.5,\n\t\tCrossThreshold: 0.95,\n\t}\n\n\tp.Chromosomes = make([]Chromosome, 0)\n\n\tfor i := 0; i < self.PopSize; i++ {\n\t\tnewChromo := &Chromosome{\n\t\t\tLocations: self.Locations,\n\t\t\tMatrix: &self.Matrix,\n\t\t\tId: i + 1,\n\t\t}\n\n\t\tp.Chromosomes = append(p.Chromosomes, *newChromo)\n\t}\n\n\t// Randomize\n\tfor i, _ := range p.Chromosomes {\n\t\tswap := rand.Intn(15)\n\n\t\tfor j := 0; j < swap; j++ {\n\t\t\tp.Chromosomes[i].RandSwap()\n\t\t}\n\t}\n\n\tp.IDCounter = self.PopSize + 1\n\n\treturn &p\n}", "func PopStyleV(count int) {\n\timgui.PopStyleVarV(count)\n}", "func NewPopTestSuite(packageName PackageName, opts ...PopTestSuiteOption) *PopTestSuite {\n\t// Create a standardized PopTestSuite object.\n\tpts := &PopTestSuite{\n\t\tPackageName: packageName,\n\t}\n\t// provide a way to enable pop debugging when running tests\n\tif envy.Get(\"POP_TEST_DEBUG\", \"\") != \"\" {\n\t\tpop.Debug = true\n\t}\n\n\t// Apply the user-supplied options to the PopTestSuite object.\n\tfor _, opt := range opts {\n\t\topt(pts)\n\t}\n\n\tif pts.useHighPrivsPSQLRole && pts.usePerTestTransaction {\n\t\tlog.Fatal(\"Cannot use both high priv psql and per test transaction\")\n\t}\n\n\tpts.getDbConnectionDetails()\n\n\tlog.Printf(\"package %s is attempting to connect to database %s\", packageName, pts.pgConnDetails.Database)\n\tpgConn, err := pop.NewConnection(pts.pgConnDetails)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tif err = pgConn.Open(); err != nil {\n\t\tlog.Panic(err)\n\t}\n\tpts.pgConn = pgConn\n\n\tif pts.usePerTestTransaction {\n\t\tpts.txnTestDb = make(map[string]*pop.Connection)\n\t\tpts.findOrCreatePerTestTransactionDb()\n\t\treturn pts\n\t}\n\n\t// set up database connections for non per test transactions\n\t// which may or may not be have useHighPrivsPSQLRole set\n\tpts.highPrivConn, err = pop.NewConnection(pts.highPrivConnDetails)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tif err = pts.highPrivConn.Open(); err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tpts.lowPrivConn, err = pop.NewConnection(pts.lowPrivConnDetails)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tif err := pts.lowPrivConn.Open(); err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tlog.Printf(\"attempting to clone database %s to %s... \", pts.dbNameTemplate, pts.lowPrivConnDetails.Database)\n\tif err := cloneDatabase(pgConn, pts.dbNameTemplate, pts.lowPrivConnDetails.Database); err != nil {\n\t\tlog.Panicf(\"failed to clone database '%s' to '%s': %#v\", pts.dbNameTemplate, pts.lowPrivConnDetails.Database, err)\n\t}\n\tlog.Println(\"success\")\n\n\t// The db is already truncated as part of the test setup\n\n\tif pts.useHighPrivsPSQLRole {\n\t\t// Disconnect the low privileged connection and replace its\n\t\t// connection and connection details with those of the high\n\t\t// privileged connection.\n\t\tif err := pts.lowPrivConn.Close(); err != nil {\n\t\t\tlog.Panic(err)\n\t\t}\n\n\t\tpts.lowPrivConn = pts.highPrivConn\n\t\tpts.lowPrivConnDetails = pts.highPrivConnDetails\n\t}\n\n\treturn pts\n}", "func (m *_NotificationMessage) InitializeParent(parent ExtensionObjectDefinition) {}", "func (p printHandler) PopEvent(eventID string, elapsed time.Duration) {\n\tfmt.Printf(\"[%s] %v\\n\", eventID, elapsed)\n}", "func imgTopReleaseEvent() {\n\tAbout.Width = 400\n\tAbout.ImageOkButtonSize = 24\n\tAbout.Show()\n}", "func (CMsgDOTAPopup_PopupID) EnumDescriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{8, 0}\n}", "func (ps *PubSub[Item]) Pub(msg Item, topics ...string) {\n\tps.msgChan <- msgenvelope[Item]{op: pubBlock, topics: topics, msg: msg}\n}", "func D_TestRunPop3(t *testing.T) {\n\t// PopCmd(\"pop3.163.com\", \"110\", \"midoks\", \"mm123123\")\n}", "func (recv *TypeInterface) PeekParent() TypeInterface {\n\tretC := C.g_type_interface_peek_parent((C.gpointer)(recv.native))\n\tretGo := *TypeInterfaceNewFromC(unsafe.Pointer(retC))\n\n\treturn retGo\n}", "func (r *Reply) JSONP(data interface{}, callback string) *Reply {\n\tr.ContentType(ahttp.ContentTypeJavascript.String())\n\tr.Render(&jsonpRender{Data: data, Callback: callback})\n\treturn r\n}", "func (v *Clipboard) native() *C.GtkClipboard {\n\tif v == nil {\n\t\treturn nil\n\t}\n\treturn (*C.GtkClipboard)(v.Native())\n}", "func (*CMsgSizePopup) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{52}\n}" ]
[ "0.7245628", "0.67946184", "0.671131", "0.6632335", "0.63890284", "0.58852094", "0.58588827", "0.5829165", "0.57027376", "0.5697189", "0.5695752", "0.5623324", "0.5471221", "0.54265916", "0.5425965", "0.5336367", "0.5220583", "0.51320916", "0.5081396", "0.48694453", "0.4869443", "0.4862005", "0.4694318", "0.46190685", "0.45853195", "0.45745683", "0.45422015", "0.44996348", "0.44385904", "0.44113487", "0.4355177", "0.43517572", "0.43429074", "0.43127164", "0.42951638", "0.4290073", "0.42889687", "0.42594817", "0.42594725", "0.42281136", "0.41910055", "0.41787332", "0.41501492", "0.41392922", "0.41247913", "0.4101847", "0.40880063", "0.4075095", "0.4068951", "0.40434566", "0.3992103", "0.39903787", "0.39557835", "0.39317125", "0.3930848", "0.39030138", "0.38976806", "0.38828918", "0.38514236", "0.3832508", "0.38284832", "0.3826524", "0.3824534", "0.3769019", "0.3769019", "0.37687197", "0.37365267", "0.37259427", "0.37169856", "0.37124673", "0.37005037", "0.36952183", "0.36832872", "0.36725685", "0.3668044", "0.3666276", "0.36574352", "0.3657381", "0.3641232", "0.3641232", "0.36300737", "0.36243197", "0.3622541", "0.36211237", "0.3616029", "0.36124146", "0.36094257", "0.3609249", "0.3599086", "0.35988864", "0.3590089", "0.35640186", "0.35491174", "0.35472023", "0.3540134", "0.35278735", "0.35199794", "0.35150108", "0.35149348", "0.3511931" ]
0.8746411
0
Popdown is a wrapper around gtk_popover_popdown().
func (v *Popover) Popdown() { C.gtk_popover_popdown(v.native()) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *Popover) Popup() {\n\tC.gtk_popover_popup(v.native())\n}", "func NewPopupMenu(parent Widget, b Base, mo ...MenuOption) *PopupMenu {\n\tpm := &PopupMenu{\n\t\tPanel: NewPanel(nil, b),\n\t}\n\tInitWidget(parent, pm)\n\tpad := pm.MyTheme().Pad\n\tbtH := b.Rect.H() - pad\n\tbtW := b.Rect.W() - pad*2\n\tpm.Rect = R(pm.Rect.Min.X, pm.Rect.Max.Y-pm.Rect.H()*float64(len(mo))-pad,\n\t\tpm.Rect.Max.X, pm.Rect.Max.Y)\n\ty := pm.Rect.H() - pad\n\tfor _, o := range mo {\n\t\tbt := NewPushButton(pm, Base{\n\t\t\tRect: R(pad, y-btH, pad+btW, y),\n\t\t\tText: o.Text,\n\t\t\tImage: o.Image,\n\t\t\tDisabled: o.Disabled,\n\t\t})\n\t\ty -= btH + pad\n\t\to := o\n\t\tbt.OnPress = func() {\n\t\t\tfmt.Printf(\"popup menu onpress before popdown o=%+v\\n\", o)\n\t\t\tbt.Surface.PopDownTo(pm)\n\t\t\tfmt.Printf(\"popup menu onpress after popdown o=%+v\\n\", o)\n\t\t\tif o.Handler != nil {\n\t\t\t\tfmt.Printf(\"popup menu onpress before handler\\n\")\n\t\t\t\tclose := o.Handler(pm)\n\t\t\t\tfmt.Printf(\"popup menu onpress after handler =%v\\n\", close)\n\t\t\t\tif close {\n\t\t\t\t\tpm.Surface.PopDownTo(nil)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tow := optWidget{\n\t\t\topt: o,\n\t\t\tw: bt,\n\t\t}\n\t\tpm.opts = append(pm.opts, ow)\n\t}\n\tpm.Surface.PopUp(pm)\n\treturn pm\n}", "func (v *MenuButton) GetPopover() *Popover {\n\tc := C.gtk_menu_button_get_popover(v.native())\n\tif c == nil {\n\t\treturn nil\n\t}\n\treturn wrapPopover(glib.Take(unsafe.Pointer(c)))\n}", "func Popup(prompt string, options ...string) (selection string, err error) {\n\t//selection, err = defaultDmenu().Popup(prompt, options...)\n\tdmenu := defaultDmenu()\n\tselection, err = dmenu.Popup(prompt, options...)\n\treturn\n}", "func (v *MenuButton) SetPopover(popover *Popover) {\n\tC.gtk_menu_button_set_popover(v.native(), popover.toWidget())\n}", "func MakePopover(ptr unsafe.Pointer) *NSPopover {\n\tif ptr == nil {\n\t\treturn nil\n\t}\n\treturn &NSPopover{\n\t\tNSResponder: *MakeResponder(ptr),\n\t}\n}", "func (v *MenuButton) SetUsePopover(setting bool) {\n\tC.gtk_menu_button_set_use_popover(v.native(), gbool(setting))\n}", "func Popup(name string) *PopupWidget {\n\treturn &PopupWidget{\n\t\tname: Context.FontAtlas.RegisterString(name),\n\t\tflags: 0,\n\t\tlayout: nil,\n\t}\n}", "func (v *MenuButton) GetUsePopover() bool {\n\tc := C.gtk_menu_button_get_use_popover(v.native())\n\treturn gobool(c)\n}", "func PopStyle() {\n\timgui.PopStyleVar()\n}", "func (v *MenuButton) GetPopup() *Menu {\n\tc := C.gtk_menu_button_get_popup(v.native())\n\tif c == nil {\n\t\treturn nil\n\t}\n\tobj := glib.Take(unsafe.Pointer(c))\n\treturn wrapMenu(obj)\n}", "func (d *Dmenu) Popup(prompt string, options ...string) (selection string, err error) {\n\tprocessedArgs := []string{}\n\tfor _, arg := range d.arguments {\n\t\tvar parg string\n\t\tif strings.Contains(arg, \"%s\") {\n\t\t\tparg = fmt.Sprintf(arg, prompt)\n\t\t} else {\n\t\t\tparg = arg\n\t\t}\n\n\t\tprocessedArgs = append(processedArgs, parg)\n\t}\n\tcmd := exec.Command(d.command, processedArgs...)\n\n\tstdin, err := cmd.StdinPipe()\n\n\tif err != nil {\n\t\tlog.Fatalf(\"Error getting pipe: %s\", err)\n\t}\n\n\tgo func(stdin io.WriteCloser) {\n\t\tdefer stdin.Close()\n\t\tio.WriteString(stdin, strings.Join(options, \"\\n\"))\n\t}(stdin)\n\n\tbyteOut, err := cmd.Output()\n\n\tif err != nil {\n\t\tif exiterr, ok := err.(*exec.ExitError); ok {\n\t\t\tif status, ok := exiterr.Sys().(syscall.WaitStatus); ok {\n\t\t\t\tif status.ExitStatus() == 1 {\n\t\t\t\t\terr = &EmptySelectionError{}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn \"\", err\n\t}\n\n\t// Cast and trim\n\tselection = strings.TrimSpace(string(byteOut))\n\n\treturn\n}", "func NewPopTable(h SQLHandle) *PopTable {\n\treturn &PopTable{h}\n}", "func NewPopup(p tview.Primitive) *Popup {\n\t_, _, width, height := p.GetRect()\n\tpopup := &Popup{\n\t\tflex: tview.NewFlex().\n\t\t\tAddItem(nil, 0, 1, false).\n\t\t\tAddItem(tview.NewFlex().\n\t\t\t\tSetDirection(tview.FlexRow).\n\t\t\t\tAddItem(nil, 0, 1, false).\n\t\t\t\tAddItem(p, height, 1, false).\n\t\t\t\tAddItem(nil, 0, 1, false), width, 1, false).\n\t\t\tAddItem(nil, 0, 1, false),\n\t}\n\tpopup.content = p\n\treturn popup\n}", "func NewPopUpMenu(menu *fyne.Menu, c fyne.Canvas) *PopUpMenu {\n\tp := &PopUpMenu{Menu: NewMenu(menu), canvas: c}\n\tp.Menu.Resize(p.Menu.MinSize())\n\tp.Menu.customSized = true\n\to := widget.NewOverlayContainer(p.Menu, c, p.Dismiss)\n\to.Resize(o.MinSize())\n\tp.overlay = o\n\tp.OnDismiss = func() {\n\t\tp.Hide()\n\t}\n\treturn p\n}", "func (wd *remoteWD) ButtonDown() error {\n\treturn wd.voidCommand(\"/session/%s/buttondown\", nil)\n}", "func (v *MenuButton) SetPopup(menu IMenu) {\n\tC.gtk_menu_button_set_popup(v.native(), menu.toWidget())\n}", "func (p *PodsWidget) SelectPageDown() {\n\tp.ScrollPageDown()\n}", "func (v *ScaleButton) GetPopup() (*Widget, error) {\n\tc := C.gtk_scale_button_get_popup(v.native())\n\tif c == nil {\n\t\treturn nil, nilPtrErr\n\t}\n\tobj := glib.Take(unsafe.Pointer(c))\n\treturn wrapWidget(obj), nil\n}", "func (p *PageStack) StackPopped(o, top model.Component) {\n\to.Stop()\n\tp.StackTop(top)\n}", "func (*CMsgDOTAPopup) Descriptor() ([]byte, []int) {\n\treturn file_dota_gcmessages_client_proto_rawDescGZIP(), []int{8}\n}", "func (canvas *Canvas) Pop() {\n\twriteCommand(canvas.contents, \"Q\")\n}", "func Pop() Action {\n\treturn ActionPop{}\n}", "func (c *Cursor) TopDown(listener Listener, dir Direction, breakmode Breakmode) interface{} {\n\tc.startNode = c.current\n\tT().Debugf(\"TopDown starting at node %v\", c.current.Symbol())\n\tvalue := c.traverseTopDown(listener, dir, breakmode, 0)\n\treturn value\n}", "func (w *ListWidget) MoveDown() {\n\tw.ChangeSelection(w.CurrentSelection() + 1)\n}", "func (list *List) HighlightDown() *List {\n\n\t// If there is no where to go\n\tif len(list.options) < list.Index+1 {\n\t\treturn list\n\t}\n\n\tlist.Cursor.EraseCurrentLine()\n\tlist.PrintOption(list.options[list.Index-1])\n\n\tlist.Cursor.MoveDown(1)\n\n\tlist.Cursor.EraseCurrentLine()\n\tlist.PrintHighlight(list.options[list.Index])\n\n\tlist.Index++\n\n\treturn list\n}", "func PopSub() {\n\toutput.EmitLn(\"SUB (SP)+,D0\")\n}", "func (h *handler) pageDown(g *gocui.Gui, v *gocui.View) error {\n\tif nextIdx := h.findNextPrevLine(h.maxLines - 1); nextIdx != -1 {\n\t\tlastInstr := h.lines[nextIdx].data.(*binch.Instruction)\n\t\tif nextInstr := h.project.FindNextInstruction(lastInstr.Address); nextInstr != nil {\n\t\t\th.drawFromTop(nextInstr.Address)\n\t\t}\n\t} else {\n\t\tlog.Panicln(\"pageDown fail\")\n\t}\n\treturn nil\n}", "func (s *State) OpenPopup(bounds image.Rectangle, d Component) Popup {\n\tif s.root != nil {\n\t\ts.focused = d\n\t\ts.update = true\n\t\treturn s.root.OpenPopup(bounds.Add(s.bounds.Min), d)\n\t}\n\treturn nil\n}", "func (t *tui) arrowDown(g *gotui.Gui, v *gotui.View) error {\n\tcx, cy := v.Cursor()\n\tlines := v.ViewBufferLines()\n\tlineCount := len(v.ViewBufferLines()) - 1\n\tif lineCount == -1 {\n\t\treturn nil\n\t}\n\tlastLineLen := len(lines[lineCount])\n\tif cx == lastLineLen || (cx == 0 && cy == 0 && !t.sent.onLast()) {\n\t\tif cy == lineCount {\n\t\t\tv.Clear()\n\t\t\tv.SetCursor(0, 0)\n\t\t\tif !t.sent.onLast() {\n\t\t\t\tfmt.Fprint(v, t.sent.Forward().Text)\n\t\t\t}\n\t\t} else {\n\t\t\tif lineCount == 0 {\n\t\t\t\tv.SetCursor(cx, cy+1)\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif cy == lineCount {\n\t\t\tv.SetCursor(lastLineLen, cy)\n\t\t} else {\n\t\t\tv.SetCursor(cx, cy+1)\n\t\t}\n\t}\n\treturn nil\n}", "func SetOnPop(fn func(v interface{})) {\n\n\texec.OnPop = fn\n}", "func MRThumbDown(pid interface{}, id int) error {\n\t_, _, err := lab.AwardEmoji.CreateMergeRequestAwardEmoji(pid, id, &gitlab.CreateAwardEmojiOptions{\n\t\tName: \"thumbsdown\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (o *openList) Pop() interface{} {\n\topn := *o\n\tit := opn[len(opn)-1]\n\tit.pqindex = -1\n\t*o = opn[:len(opn)-1]\n\treturn it\n}", "func PopStyleColor() {\n\timgui.PopStyleColor()\n}", "func (view *DetailsView) CursorDown() error {\n\treturn CursorDown(view.gui, view.view)\n}", "func (g *Godis) SPop(key string) string {\n\treturn g.cmdString(\"SPOP\", key)\n}", "func (dw *DrawingWand) PopClipPath() {\n\tC.DrawPopClipPath(dw.dw)\n}", "func (c *Client) SPop(_ context.Context, key string) *redis.StringCmd {\n\treturn c.cli.SPop(key)\n}", "func PopItemWidth() {\n\timgui.PopItemWidth()\n}", "func HeapPop(h heap.Interface) interface{} {\n\tvar result = make(chan interface{})\n\theapPopChan <- heapPopChanMsg{\n\t\th: h,\n\t\tresult: result,\n\t}\n\treturn <-result\n}", "func (ctx *PQContext) Pop(params []string) apis.IResponse {\n\tvar err *mpqerr.ErrorResponse\n\tvar limit int64 = 1\n\tvar asyncId string\n\n\tpopWaitTimeout := ctx.pq.config.PopWaitTimeout\n\n\tfor len(params) > 0 {\n\t\tswitch params[0] {\n\t\tcase PRM_LIMIT:\n\t\t\tparams, limit, err = mpqproto.ParseInt64Param(params, 1, conf.CFG_PQ.MaxPopBatchSize)\n\t\tcase PRM_POP_WAIT:\n\t\t\tparams, popWaitTimeout, err = mpqproto.ParseInt64Param(params, 0, conf.CFG_PQ.MaxPopWaitTimeout)\n\t\tcase PRM_ASYNC:\n\t\t\tparams, asyncId, err = mpqproto.ParseItemId(params)\n\t\tdefault:\n\t\t\treturn mpqerr.UnknownParam(params[0])\n\t\t}\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif len(asyncId) > 0 {\n\t\treturn ctx.asyncPop(asyncId, 0, popWaitTimeout, limit, false)\n\t} else {\n\t\treturn ctx.pq.Pop(0, popWaitTimeout, limit, false)\n\t}\n}", "func (s *openCellStack) pop() (openCell, error) {\n\tif len(*s) == 0 {\n\t\treturn openCell{palletLength, palletWidth}, errStackEmpty\n\t}\n\tc := (*s)[len(*s)-1]\n\t(*s) = (*s)[:len(*s)-1]\n\treturn c, nil\n}", "func (p *PopUpMenu) Show() {\n\tp.overlay.Show()\n\tp.Menu.Show()\n}", "func NewPopTestSuite(packageName PackageName, opts ...PopTestSuiteOption) *PopTestSuite {\n\t// Create a standardized PopTestSuite object.\n\tpts := &PopTestSuite{\n\t\tPackageName: packageName,\n\t}\n\t// provide a way to enable pop debugging when running tests\n\tif envy.Get(\"POP_TEST_DEBUG\", \"\") != \"\" {\n\t\tpop.Debug = true\n\t}\n\n\t// Apply the user-supplied options to the PopTestSuite object.\n\tfor _, opt := range opts {\n\t\topt(pts)\n\t}\n\n\tif pts.useHighPrivsPSQLRole && pts.usePerTestTransaction {\n\t\tlog.Fatal(\"Cannot use both high priv psql and per test transaction\")\n\t}\n\n\tpts.getDbConnectionDetails()\n\n\tlog.Printf(\"package %s is attempting to connect to database %s\", packageName, pts.pgConnDetails.Database)\n\tpgConn, err := pop.NewConnection(pts.pgConnDetails)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tif err = pgConn.Open(); err != nil {\n\t\tlog.Panic(err)\n\t}\n\tpts.pgConn = pgConn\n\n\tif pts.usePerTestTransaction {\n\t\tpts.txnTestDb = make(map[string]*pop.Connection)\n\t\tpts.findOrCreatePerTestTransactionDb()\n\t\treturn pts\n\t}\n\n\t// set up database connections for non per test transactions\n\t// which may or may not be have useHighPrivsPSQLRole set\n\tpts.highPrivConn, err = pop.NewConnection(pts.highPrivConnDetails)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tif err = pts.highPrivConn.Open(); err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tpts.lowPrivConn, err = pop.NewConnection(pts.lowPrivConnDetails)\n\tif err != nil {\n\t\tlog.Panic(err)\n\t}\n\tif err := pts.lowPrivConn.Open(); err != nil {\n\t\tlog.Panic(err)\n\t}\n\n\tlog.Printf(\"attempting to clone database %s to %s... \", pts.dbNameTemplate, pts.lowPrivConnDetails.Database)\n\tif err := cloneDatabase(pgConn, pts.dbNameTemplate, pts.lowPrivConnDetails.Database); err != nil {\n\t\tlog.Panicf(\"failed to clone database '%s' to '%s': %#v\", pts.dbNameTemplate, pts.lowPrivConnDetails.Database, err)\n\t}\n\tlog.Println(\"success\")\n\n\t// The db is already truncated as part of the test setup\n\n\tif pts.useHighPrivsPSQLRole {\n\t\t// Disconnect the low privileged connection and replace its\n\t\t// connection and connection details with those of the high\n\t\t// privileged connection.\n\t\tif err := pts.lowPrivConn.Close(); err != nil {\n\t\t\tlog.Panic(err)\n\t\t}\n\n\t\tpts.lowPrivConn = pts.highPrivConn\n\t\tpts.lowPrivConnDetails = pts.highPrivConnDetails\n\t}\n\n\treturn pts\n}", "func PopFont() {\n\timgui.PopFont()\n}", "func (x *CMsgDOTAPopup_PopupID) UnmarshalJSON(b []byte) error {\n\tnum, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b)\n\tif err != nil {\n\t\treturn err\n\t}\n\t*x = CMsgDOTAPopup_PopupID(num)\n\treturn nil\n}", "func Pop(h Interface) interface{} {\n\tn := h.Len() - 1\n\th.Swap(0, n)\n\tdown(h, 0, n)\n\treturn h.Pop()\n}", "func OpenPopup(name string) {\n\timgui.OpenPopup(name)\n}", "func (x* xmlWriter) tagPop() {\n\tif x.tagOpen {\n\t\tx._tagEnd(\"/>\", false)\n\t\tx.pop()\n\t\treturn\n\t}\n\tx.iFmt(\"</%s>\", x.pop())\n\tx.newLine()\n}", "func (hw *HighlightedWriter) ScrollDown() {\n\thw.delegate.ScrollDown()\n}", "func Pop(ctx echo.Context) error {\n\n\treq := types.PopRequest{}\n\n\terr := ctx.Bind(&req)\n\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\n\tif !registration.IsAgentRegistered(req.Token) {\n\t\treturn ctx.JSON(403, types.ValidateResponse{Success: false, Message: \"Security Token Not Recognized\"})\n\t}\n\n\tmsg, err := GetFromQueue(req.Queue)\n\n\tdata := types.Message{}\n\n\tjson.Unmarshal(msg, &data)\n\n\tresp := types.PopResponse{Message: data.Message, Queue: req.Queue}\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn ctx.JSON(200, resp)\n}", "func (pq *MaxPQ) Pop() interface{} {\n\told := *pq\n\tn := len(old)\n\titem := old[n-1]\n\t*pq = old[0 : n-1]\n\treturn item\n}", "func (me TAttlistOtherIDSource) IsPop() bool { return me.String() == \"POP\" }", "func (r *CampaignRow) GetPopName() string { return *r.Data.PopName }", "func (r *CampaignRow) GetPopName() string { return *r.Data.PopName }", "func (dw *DrawingWand) PopPattern() {\n\tC.MagickDrawPopPattern(dw.dw)\n}", "func (*CMsgMouseDown) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{3}\n}", "func (p *Parser) pop(end xml.EndElement) (*Node, error) {\n\tif p.node.Parent == nil {\n\t\treturn nil, fmt.Errorf(\"xmlpicker: unexpected end element </%s>\", end.Name.Local)\n\t}\n\tpopped := p.node\n\tstart := popped.StartElement\n\tif start.Name.Local != end.Name.Local {\n\t\treturn nil, fmt.Errorf(\"xmlpicker: element <%s> closed by </%s>\", start.Name.Local, end.Name.Local)\n\t}\n\tif p.NSFlag != NSStrip && start.Name.Space != end.Name.Space {\n\t\treturn nil, fmt.Errorf(\"xmlpicker: element <%s> in space %s closed by </%s> in space %s\", start.Name.Local, start.Name.Space, end.Name.Local, end.Name.Space)\n\t}\n\tp.node = popped.Parent\n\treturn popped, nil\n}", "func (pq *MinPQ) Pop() interface{} {\n\told := *pq\n\tn := len(old)\n\titem := old[n-1]\n\t*pq = old[0 : n-1]\n\treturn item\n}", "func (ds *DrawStack) Pop() {\n\tds.toPop++\n}", "func (*CMsgHidePopup) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{51}\n}", "func (d *Deck) Pop() *Card {\n\tcard := *d.Cards[len(d.Cards)-1]\n\td.Cards = d.Cards[:len(d.Cards)-1]\n\treturn &card\n}", "func (p printHandler) PopEvent(eventID string, elapsed time.Duration) {\n\tfmt.Printf(\"[%s] %v\\n\", eventID, elapsed)\n}", "func (*CMsgShowPopup) Descriptor() ([]byte, []int) {\n\treturn file_steam_htmlmessages_proto_rawDescGZIP(), []int{50}\n}", "func (hw *HighlightedWriter) EraseDown() {\n\thw.delegate.EraseDown()\n}", "func (dw *DrawingWand) PopDefs() {\n\tC.MagickDrawPopDefs(dw.dw)\n}", "func Pop(h *PriorityQueue) *Item {\n\tn := h.Len() - 1\n\th.Swap(0, n)\n\tdown(h, 0, n)\n\treturn h.Pop()\n}", "func (r *CampaignRow) SetPopName(popName string) { r.Data.PopName = &popName }", "func (r *CampaignRow) SetPopName(popName string) { r.Data.PopName = &popName }", "func (self *SinglePad) ProcessButtonDown(buttonCode int, value interface{}) {\n self.Object.Call(\"processButtonDown\", buttonCode, value)\n}", "func PopupModal(name string) *PopupModalWidget {\n\treturn &PopupModalWidget{\n\t\tname: Context.FontAtlas.RegisterString(name),\n\t\topen: nil,\n\t\tflags: WindowFlagsNoResize,\n\t\tlayout: nil,\n\t}\n}", "func newPopChannel() popChannel {\n\t// The pop channel is stacked, so only a buffer of 1 is required\n\t// see http://gowithconfidence.tumblr.com/post/31426832143/stacked-channels\n\treturn make(chan []*URLContext, 1)\n}", "func (v *View) PageDown() {\n\tif len(v.buf.lines)-(v.topline+v.height) > v.height {\n\t\tv.ScrollDown(v.height)\n\t} else {\n\t\tif len(v.buf.lines) >= v.height {\n\t\t\tv.topline = len(v.buf.lines) - v.height\n\t\t}\n\t}\n}", "func LPop(conn redigo.Conn, key string, dest interface{}) (bool, error) {\n\treturn Result(conn.Do(\"LPOP\", key)).StringToJSON(dest)\n}", "func (obj *stackframe) IsPop() bool {\n\treturn obj.isPop\n}", "func (p *PopUpMenu) Move(pos fyne.Position) {\n\twidget.MoveWidget(&p.Base, p, p.adjustedPosition(pos, p.Size()))\n}", "func (c *QueuedChan) Pop() interface{} {\n\tselect {\n\tcase i := <-c.popc:\n\t\treturn i\n\tcase <-c.close:\n\t\treturn nil\n\t}\n}", "func (s *htmlState) pop(tag string) {\n\tn := len(s.openTags)\n\tif n == 0 {\n\t\tif s.ignore&issueStructure == 0 {\n\t\t\ts.err(fmt.Errorf(\"no open tags left to close %s\", tag))\n\t\t}\n\t\treturn\n\t}\n\tpop := s.openTags[n-1]\n\ts.openTags = s.openTags[:n-1]\n\tif s.ignore&issueStructure != 0 {\n\t\treturn\n\t}\n\tif pop != tag && !s.badNesting { // report broken structure just once.\n\t\ts.err(fmt.Errorf(\"tag '%s' closed by '%s'\", pop, tag))\n\t\ts.badNesting = true\n\t}\n}", "func (c *Client) LPop(key string) (*string, error) {\n\treq := cmd([]string{\"lpop\", key})\n\tres, err := c.processRequest(req)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn c.bulkString(res)\n}", "func (self *SinglePad) OnDownCallback() interface{}{\n return self.Object.Get(\"onDownCallback\")\n}", "func (d *PrefsDialog) onColumnMoveDown() {\n\td.moveSelectedColumnRow(false)\n}", "func (p *Proc) Pop() {\n\tp.stk.load()\n}", "func PopStyleV(count int) {\n\timgui.PopStyleVarV(count)\n}", "func (m Modifiers) OptionDown() bool {\n\treturn m&OptionModifier == OptionModifier\n}", "func D_TestRunPop3(t *testing.T) {\n\t// PopCmd(\"pop3.163.com\", \"110\", \"midoks\", \"mm123123\")\n}", "func (v *Layer) PageDown() error {\n\tstep := int(v.height()) + 1\n\ttargetLayerIndex := v.LayerIndex + step\n\n\tif targetLayerIndex > len(v.Layers) {\n\t\tstep -= targetLayerIndex - (len(v.Layers) - 1)\n\t}\n\n\tif step > 0 {\n\t\terr := CursorStep(v.gui, v.view, step)\n\t\tif err == nil {\n\t\t\treturn v.SetCursor(v.LayerIndex + step)\n\t\t}\n\t}\n\treturn nil\n}", "func Pop[T any](h Interface[T]) T {\n\tn := h.Len() - 1\n\th.Swap(0, n)\n\tdown(h, 0, n)\n\treturn h.Pop()\n}", "func (m *Mouse) RightBtnDown() {\n\tm.RightBtn.Down()\n\tm.WriteJSON()\n}", "func (g *Grid) PartialDown() []Partial {\n\tvar r []Partial\n\n\tfor i := 0; i < g.Size; i++ {\n\t\tpartial := \"\"\n\t\tfor j := 0; j < g.Size; j++ {\n\t\t\tt, ok := g.grid[i][j].(charCell)\n\t\t\tif ok && !t.isDown {\n\t\t\t\tPanicIfFalse(t.isRight, \"either isDown or isRight should be set\")\n\t\t\t\tpartial += fmt.Sprintf(\"%c\", t.char)\n\t\t\t} else {\n\t\t\t\tif len(partial) > 1 {\n\t\t\t\t\tr = append(r, Partial{Partial: partial, X: i, Y: j - len(partial)})\n\t\t\t\t}\n\t\t\t\tpartial = \"\"\n\t\t\t}\n\t\t}\n\t\tif len(partial) > 1 {\n\t\t\tr = append(r, Partial{Partial: partial, X: i, Y: g.Size - len(partial)})\n\t\t}\n\t}\n\treturn r\n}", "func (self *GameHeart) Downup(msg *HeartMessageType) {\n\n}", "func (mod ModDownToSize) Apply(pop *Population) {\n\tvar offsprings = generateOffsprings(\n\t\tmod.NbrOffsprings,\n\t\tpop.Individuals,\n\t\tmod.SelectorA,\n\t\tmod.Crossover,\n\t\tpop.rng,\n\t)\n\t// Apply mutation to the offsprings\n\tif mod.Mutator != nil {\n\t\toffsprings.Mutate(mod.Mutator, mod.MutRate, pop.rng)\n\t}\n\toffsprings.Evaluate(pop.ff)\n\t// Merge the current population with the offsprings\n\toffsprings = append(offsprings, pop.Individuals...)\n\t// Select down to size\n\tvar selected, _ = mod.SelectorB.Apply(len(pop.Individuals), offsprings, pop.rng)\n\t// Replace the current population of individuals\n\tcopy(pop.Individuals, selected)\n}", "func (self *TSPAlgorithm) RandomPop() *Population {\n\tp := Population{\n\t\tMutThreshold: 0.5,\n\t\tCrossThreshold: 0.95,\n\t}\n\n\tp.Chromosomes = make([]Chromosome, 0)\n\n\tfor i := 0; i < self.PopSize; i++ {\n\t\tnewChromo := &Chromosome{\n\t\t\tLocations: self.Locations,\n\t\t\tMatrix: &self.Matrix,\n\t\t\tId: i + 1,\n\t\t}\n\n\t\tp.Chromosomes = append(p.Chromosomes, *newChromo)\n\t}\n\n\t// Randomize\n\tfor i, _ := range p.Chromosomes {\n\t\tswap := rand.Intn(15)\n\n\t\tfor j := 0; j < swap; j++ {\n\t\t\tp.Chromosomes[i].RandSwap()\n\t\t}\n\t}\n\n\tp.IDCounter = self.PopSize + 1\n\n\treturn &p\n}", "func (vm *VM) opPop(instr []uint16) int {\n\tif len(vm.stack) == 0 {\n\t\t// error\n\t\tvm.Status = \"opPop has empty stack!\"\n\t\treturn 0\n\t}\n\n\tv := vm.stack[len(vm.stack)-1]\n\tvm.stack = vm.stack[:len(vm.stack)-1]\n\ta, _, _ := vm.getAbc(instr)\n\tvm.registers[a] = v\n\treturn 2\n}", "func (p *PopupWidget) Build() {\n\tif imgui.BeginPopup(p.name, int(p.flags)) {\n\t\tp.layout.Build()\n\t\timgui.EndPopup()\n\t}\n}", "func (t *tui) arrowUp(g *gotui.Gui, v *gotui.View) error {\n\tcx, cy := v.Cursor()\n\tif cx == 0 {\n\t\tif cy == 0 {\n\t\t\tv.Clear()\n\t\t\thl := t.sent.Back()\n\t\t\tif hl != nil {\n\t\t\t\tfmt.Fprint(v, hl.Text)\n\t\t\t}\n\t\t} else {\n\t\t\tv.SetCursor(0, 0)\n\t\t}\n\t} else {\n\t\tv.SetCursor(cx-1, cy)\n\t}\n\treturn nil\n}", "func (gdt *Array) PopBack() Variant {\n\targ0 := gdt.getBase()\n\n\tret := C.go_godot_array_pop_back(GDNative.api, arg0)\n\n\treturn Variant{base: &ret}\n\n}", "func (stack *Item) Pop() (newstack *Item, top *Item) {\n\ttop = stack\n\tnewstack = stack.Next\n\treturn\n}", "func (w *ListWidget) MovePageDown() {\n\ti := w.selected\n\n\tfor remainingLinesToPage := w.h; remainingLinesToPage > 0 && i < w.itemCount(); i++ {\n\t\titem := w.itemsToShow()[i]\n\t\tremainingLinesToPage -= strings.Count(item.Display, \"\\n\") + 1 // +1 as there is an implicit newline\n\t\tremainingLinesToPage-- // separator\n\t}\n\n\tw.ChangeSelection(i)\n}", "func (s *Stack) Pop() DrawPather {\n\tif s.Len() == 0 {\n\t\treturn nil\n\t}\n\ttmp := (*s)[s.Len()-1]\n\t*s = (*s)[:s.Len()-1]\n\treturn tmp\n}", "func (*Action_Dropdown) Descriptor() ([]byte, []int) {\n\treturn file_chat_v1_messages_proto_rawDescGZIP(), []int{1, 1}\n}" ]
[ "0.771435", "0.6271339", "0.6096663", "0.60613847", "0.58930135", "0.5520053", "0.5439196", "0.51506114", "0.51457214", "0.510715", "0.50609976", "0.50515825", "0.50288045", "0.49635243", "0.49324164", "0.48336193", "0.4772766", "0.4770371", "0.4765281", "0.47626668", "0.4761489", "0.4730697", "0.4711964", "0.46971312", "0.46874452", "0.46448296", "0.46147543", "0.4581167", "0.45637733", "0.45567912", "0.45150235", "0.45109352", "0.4510874", "0.44901496", "0.44790554", "0.4456283", "0.44421518", "0.4428789", "0.43820024", "0.43816927", "0.43740165", "0.4355709", "0.43366373", "0.43336117", "0.43032366", "0.43014133", "0.42981207", "0.42911726", "0.42894515", "0.42890215", "0.42729706", "0.42704436", "0.42527705", "0.4252538", "0.4252538", "0.4242272", "0.42315772", "0.42186895", "0.42122746", "0.42107394", "0.42092466", "0.42034566", "0.4195168", "0.41899833", "0.4182515", "0.41795743", "0.41667873", "0.41667306", "0.41667306", "0.41459432", "0.4140509", "0.41383624", "0.4137964", "0.41337553", "0.41296318", "0.41264102", "0.41206074", "0.4117888", "0.41109598", "0.41064423", "0.4104929", "0.40928325", "0.4091569", "0.40837362", "0.40832794", "0.40828425", "0.4078762", "0.40676317", "0.40669057", "0.40666178", "0.40632343", "0.40511355", "0.40494743", "0.40433943", "0.40397504", "0.40372005", "0.40359288", "0.40320006", "0.40299326", "0.4026388" ]
0.89984757
0
/ GtkFileChooser AddChoice is a wrapper around gtk_file_chooser_add_choice().
func (v *FileChooser) AddChoice(id, label string, options, optionLabels []string) { cId := C.CString(id) defer C.free(unsafe.Pointer(cId)) cLabel := C.CString(label) defer C.free(unsafe.Pointer(cLabel)) if options == nil || optionLabels == nil { C.gtk_file_chooser_add_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cLabel), nil, nil) return } cOptions := C.make_strings(C.int(len(options) + 1)) for i, option := range options { cstr := C.CString(option) defer C.free(unsafe.Pointer(cstr)) C.set_string(cOptions, C.int(i), (*C.gchar)(cstr)) } C.set_string(cOptions, C.int(len(options)), nil) cOptionLabels := C.make_strings(C.int(len(optionLabels) + 1)) for i, optionLabel := range optionLabels { cstr := C.CString(optionLabel) defer C.free(unsafe.Pointer(cstr)) C.set_string(cOptionLabels, C.int(i), (*C.gchar)(cstr)) } C.set_string(cOptionLabels, C.int(len(optionLabels)), nil) C.gtk_file_chooser_add_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cLabel), cOptions, cOptionLabels) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *FileChooser) SetChoice(id, option string) {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\tcOption := C.CString(option)\n\tdefer C.free(unsafe.Pointer(cOption))\n\tC.gtk_file_chooser_set_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cOption))\n}", "func (v *FileChooser) GetChoice(id string) string {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\tc := C.gtk_file_chooser_get_choice(v.native(), (*C.gchar)(cId))\n\treturn C.GoString(c)\n}", "func (v *FileChooser) RemoveChoice(id string) {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\tC.gtk_file_chooser_remove_choice(v.native(), (*C.gchar)(cId))\n}", "func (cycle *Cycle) AddChoice(choice CycleChoice) *CycleItem {\n\treturn newCycleItem(cycle, choice)\n}", "func runFileChooser(win *gtk.Window) (string, error) {\n\n\tvar fn string\n\n\topenFile, err := gtk.FileChooserDialogNewWith2Buttons(\"Open file\", win, gtk.FILE_CHOOSER_ACTION_OPEN,\n\t\t\"Cancel\", gtk.RESPONSE_CANCEL,\n\t\t\"Ok\", gtk.RESPONSE_OK)\n\tdefer openFile.Destroy()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\topenFile.SetDefaultSize(50, 50)\n\n\tres := openFile.Run()\n\n\tif res == int(gtk.RESPONSE_OK) {\n\t\tfn = openFile.FileChooser.GetFilename()\n\t}\n\n\treturn fn, nil\n}", "func (fv *FileView) FileSelectAction(idx int) {\n\tif idx < 0 {\n\t\treturn\n\t}\n\tfv.SaveSortPrefs()\n\tfi := fv.Files[idx]\n\tfv.SelectedIdx = idx\n\tfv.SelFile = fi.Name\n\tsf := fv.SelField()\n\tsf.SetText(fv.SelFile)\n\tfv.WidgetSig.Emit(fv.This, int64(gi.WidgetSelected), fv.SelectedFile())\n}", "func Choice(s *string, choices []string, title, id, class string, valid Validator) (jquery.JQuery, error) {\n\tj := jq(\"<select>\").AddClass(ClassPrefix + \"-choice\").AddClass(class)\n\tj.SetAttr(\"title\", title).SetAttr(\"id\", id)\n\tif *s == \"\" {\n\t\t*s = choices[0]\n\t}\n\tindex := -1\n\tfor i, c := range choices {\n\t\tif c == *s {\n\t\t\tindex = i\n\t\t}\n\t\tj.Append(jq(\"<option>\").SetAttr(\"value\", c).SetText(c))\n\t}\n\tif index == -1 {\n\t\treturn jq(), fmt.Errorf(\"Default of '%s' is not among valid choices\", *s)\n\t}\n\tj.SetData(\"prev\", index)\n\tj.SetProp(\"selectedIndex\", index)\n\tj.Call(jquery.CHANGE, func(event jquery.Event) {\n\t\tnewS := event.Target.Get(\"value\").String()\n\t\tnewIndex := event.Target.Get(\"selectedIndex\").Int()\n\t\tif valid != nil && !valid.Validate(newS) {\n\t\t\tnewIndex = int(j.Data(\"prev\").(float64))\n\t\t\tj.SetProp(\"selectedIndex\", newIndex)\n\t\t}\n\t\t*s = choices[int(newIndex)]\n\t\tj.SetData(\"prev\", newIndex)\n\t})\n\treturn j, nil\n}", "func selectFileGUI(titleA string, filterNameA string, filterTypeA string) string {\n\tfileNameT, errT := dialog.File().Filter(filterNameA, filterTypeA).Title(titleA).Load()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn fileNameT\n}", "func NewChoice() Choice {\n\treturn new(ChoiceImpl)\n}", "func (s *BasevhdlListener) EnterChoice(ctx *ChoiceContext) {}", "func (s *BasevhdlListener) EnterChoices(ctx *ChoicesContext) {}", "func (c *Combobox) Append(text string) {\n\tctext := C.CString(text)\n\tC.uiComboboxAppend(c.c, ctext)\n\tfreestr(ctext)\n}", "func NewChoice(allowedValues ...string) Choice {\n\treturn Choice{AllowedValues: allowedValues}\n}", "func NewAddItemAccepted() *AddItemAccepted {\n\n\treturn &AddItemAccepted{}\n}", "func (fv *FileView) SetSelFileAction(sel string) {\n\tfv.SelFile = sel\n\tsv := fv.FilesView()\n\tsv.SelectFieldVal(\"Name\", fv.SelFile)\n\tfv.SelectedIdx = sv.SelectedIdx\n\tsf := fv.SelField()\n\tsf.SetText(fv.SelFile)\n\tfv.WidgetSig.Emit(fv.This, int64(gi.WidgetSelected), fv.SelectedFile())\n}", "func (c *ChoiceImpl) AddAction(name, description string, callback func()) error {\n\tif c.getActionByName(name) == nil {\n\t\ta := newAction(name, description, callback)\n\t\tc.actions = append(c.actions, a)\n\t\treturn nil\n\t}\n\treturn errors.New(\"An action with this name already exists\")\n}", "func InputDialog(opt ...interface{}) string {\n b, _ := gtk.BuilderNewFromFile(\"glade/input-dialog.glade\")\n d := GetDialog(b, \"input_dialog\")\n entry := GetEntry(b, \"input_entry\")\n\n for i, v := range(opt) {\n if i % 2 == 0 {\n key := v.(string)\n switch key {\n case \"title\":\n d.SetTitle(opt[i+1].(string))\n case \"label\":\n l := GetLabel(b,\"input_label\")\n l.SetText(opt[i+1].(string))\n case \"password-mask\":\n entry.SetInvisibleChar(opt[i+1].(rune))\n entry.SetVisibility(false)\n case \"default\":\n entry.SetText(opt[i+1].(string))\n }\n }\n }\n\n output := \"\"\n entry.Connect(\"activate\", func (o *gtk.Entry) { d.Response(gtk.RESPONSE_OK) } )\n btok := GetButton(b, \"bt_ok\")\n btok.Connect(\"clicked\", func (b *gtk.Button) { d.Response(gtk.RESPONSE_OK) } )\n\n btcancel := GetButton(b, \"bt_cancel\")\n btcancel.Connect(\"clicked\", func (b *gtk.Button) { d.Response(gtk.RESPONSE_CANCEL) } )\n\n code := d.Run()\n if code == gtk.RESPONSE_OK {\n output, _ = entry.GetText()\n }\n\n d.Destroy()\n return output\n}", "func (fv *FileView) FavSelect(idx int) {\n\tif idx < 0 || idx >= len(gi.Prefs.FavPaths) {\n\t\treturn\n\t}\n\tfi := gi.Prefs.FavPaths[idx]\n\tfv.DirPath, _ = homedir.Expand(fi.Path)\n\tfv.UpdateFilesAction()\n}", "func NewFlagChoice(choices []string, chosen string) *FlagChoice {\n\treturn &FlagChoice{\n\t\tchoices: choices,\n\t\tchosen: chosen,\n\t}\n}", "func (ptr *Application) onClickMenuFileNew() {\n\n\t// reset the text editor\n\tptr.textEditor.SetText(\"\")\n}", "func (ptr *Application) onClickMenuFileSaveAs() {\n\t// if file exists, the below method will also prompt the\n\t// user for confirmation whether or not the intent is to\n\t// overwrite the intended file\n\tfilename, err := dialog.File().Filter(\n\t\t\"Select\",\n\t).Save()\n\tif err != nil || filename == \"\" {\n\t\treturn\n\t}\n\n\t// save the file\n\tptr.saveFile(filename)\n}", "func importTrackCB() {\n\tvar impPath string\n\tfs := gtk.NewFileChooserDialog(\"Track to Import\",\n\t\twin,\n\t\tgtk.FILE_CHOOSER_ACTION_OPEN,\n\t\t\"_Cancel\", gtk.RESPONSE_CANCEL, \"_Import\", gtk.RESPONSE_ACCEPT)\n\tfs.SetCurrentFolder(settings.DataDir)\n\tfs.SetLocalOnly(true)\n\tff := gtk.NewFileFilter()\n\tff.AddPattern(\"*.csv\")\n\tfs.SetFilter(ff)\n\tres := fs.Run()\n\tif res == gtk.RESPONSE_ACCEPT {\n\t\timpPath = fs.GetFilename()\n\t\tif impPath != \"\" {\n\t\t\timp, err := os.Open(impPath)\n\t\t\tif err != nil {\n\t\t\t\tmessageDialog(win, gtk.MESSAGE_INFO, \"Could not open track CSV file.\")\n\t\t\t} else {\n\t\t\t\tdefer imp.Close()\n\t\t\t\tstat, err := imp.Stat()\n\t\t\t\tif err != nil || stat.Size() == 0 {\n\t\t\t\t\tmessageDialog(win, gtk.MESSAGE_ERROR, \"Invalid track CSV file\")\n\t\t\t\t} else {\n\t\t\t\t\tr := csv.NewReader(bufio.NewReader(imp))\n\t\t\t\t\tliveTrack = readTrack(r)\n\t\t\t\t\ttrackChart.track = liveTrack\n\t\t\t\t\ttrackChart.drawTrack()\n\t\t\t\t\tprofileChart.track = liveTrack\n\t\t\t\t\tprofileChart.drawProfile()\n\t\t\t\t\tnotebook.SetCurrentPage(trackPage)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfs.Destroy()\n}", "func selectFileToSaveGUI(titleA string, filterNameA string, filterTypeA string) string {\n\tfileNameT, errT := dialog.File().Filter(filterNameA, filterTypeA).Title(titleA).Save()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn fileNameT\n}", "func Choice(m string, exacts []string) string {\n\tfmt.Println(colors.Blue(prefix + \" \" + m + \": \"))\n\tret := make(chan string, 1)\n\tterminate := make(chan struct{})\n\tgo cho.Run(exacts, ret, terminate)\n\tselected := \"\"\nLOOP:\n\tfor {\n\t\tselect {\n\t\tcase selected = <-ret:\n\t\t\tbreak LOOP\n\t\tcase <-terminate:\n\t\t\tbreak LOOP\n\t\t}\n\t}\n\tif selected != \"\" {\n\t\tfmt.Println(selected)\n\t}\n\treturn selected\n}", "func pickFile(dir, message string) string {\n\tfileName := \"\"\n\terr := survey.AskOne(\n\t\t&survey.Select{\n\t\t\tMessage: message,\n\t\t\tOptions: readDir(dir),\n\t\t},\n\t\t&fileName,\n\t\tsurvey.WithValidator(survey.Required),\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn fileName\n}", "func (s *Script) AddDialog(d *Dialog) {\n\tif d.Text != \"\" {\n\t\ts.Dialog = append(s.Dialog, d)\n\t}\n}", "func entryExtMaskEnterKeyPressed(e *gtk.Entry) {\n\tExtSliceToOpt()\n\tupdateTreeViewFilesDisplay()\n}", "func newChoiceBuilder(choiceDef *ChoiceDef) ChoiceBuilder {\n\treturn &chosenBuilder{\n\t\tchoiceDef: choiceDef,\n\t}\n}", "func numberPicker(theme gxui.Theme, overlay gxui.BubbleOverlay) gxui.Control {\n\tvar fm FileManager\n\tfm.Init()\n\tfm.SetPath(fm.RootPath)\n\n\tadapter := gxui.CreateDefaultAdapter()\n\tadapter.SetItems(fm.GetList())\n\n\tlayout := theme.CreateLinearLayout()\n\tlayout.SetDirection(gxui.TopToBottom)\n\n\tlayoutControl := theme.CreateLinearLayout()\n layoutControl.SetDirection(gxui.LeftToRight)\n\tlabelPath := theme.CreateLabel()\n\tlabelPath.SetText(\"Set root path: \")\n\tlayoutControl.AddChild(labelPath)\n\n\tinputPath := theme.CreateTextBox()\n\tlayoutControl.AddChild(inputPath)\n\n\tbtn := GetButton(\"OK\", theme)\n\tbtn.OnClick(func(gxui.MouseEvent) {\n\t\t_path := inputPath.Text()\n\t\tif fm.IsDir(_path) {\n\t\t\tfm.RootPath = _path\n\t\t\tfm.SetPath(fm.RootPath)\n\t\t\tadapter.SetItems(fm.GetList())\n\t\t}\n\t})\n\tlayoutControl.AddChild(btn)\n\n\tlayout.AddChild(layoutControl)\n\n\n\tlist := theme.CreateList()\n\tlist.SetAdapter(adapter)\n\tlist.SetOrientation(gxui.Vertical)\n\tlayout.AddChild(list)\n\n\tlayoutControlOpen := theme.CreateLinearLayout()\n layoutControlOpen.SetDirection(gxui.LeftToRight)\n\tlabelOpen := theme.CreateLabel()\n\tlabelOpen.SetText(\"Open: \")\n\tlayoutControlOpen.AddChild(labelOpen)\n\n\tbtnOpen := GetButton(\"OK\", theme)\n\tbtnOpen.OnClick(func(gxui.MouseEvent) {\n\t\t\n\t})\n\tlayoutControlOpen.AddChild(btnOpen)\n\n\tlayout.AddChild(layoutControlOpen)\n\n\tlist.OnItemClicked(func(ev gxui.MouseEvent, item gxui.AdapterItem) {\n\t\t//if dropList.Selected() != item {\n\t\t//\tdropList.Select(item)\n\t\t//}\n\t\tif ev.Button == gxui.MouseButtonRight {\n\t\t\tfm.Go(item.(string))\n\t\t\tadapter.SetItems(fm.GetList())\n\t\t\t\n\t\t}\n\t\t\n\t\t//selected.SetText(fmt.Sprintf(\"%s - %d\", item, adapter.ItemIndex(item)))\n\t})\n\n\treturn layout\n}", "func Add(shortname, name, description string, defaultvalue interface{}) {\n\toptions = append(options, &Option{\n\t\tShortName: shortname,\n\t\tName: name,\n\t\tDescription: description,\n\t\tdefaultval: defaultvalue,\n\t})\n}", "func selectDirectoryGUI(titleA string) string {\n\tdirectoryT, errT := dialog.Directory().Title(titleA).Browse()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn directoryT\n}", "func (b *Builder) WriteChoice(choices []string) {\n\tfmt.Fprintf(&b.sb, \"${%d|\", b.nextTabStop())\n\tfor i, c := range choices {\n\t\tif i != 0 {\n\t\t\tb.sb.WriteByte(',')\n\t\t}\n\t\tchoiceReplacer.WriteString(&b.sb, c)\n\t}\n\tb.sb.WriteString(\"|}\")\n}", "func createEntry() *CompletionEntry {\n\tentry := NewCompletionEntry([]string{\"zoo\", \"boo\"})\n\tentry.OnChanged = func(s string) {\n\t\tdata := []string{\"foo\", \"bar\", \"baz\"}\n\t\tentry.SetOptions(data)\n\t\tentry.ShowCompletion()\n\t}\n\treturn entry\n}", "func (s *BasevhdlListener) EnterSelected_name_part(ctx *Selected_name_partContext) {}", "func pickChapter(g *gocui.Gui, v *gocui.View) error {\n\tif err := openModal(g); err != nil {\n\t\treturn err\n\t}\n\n\tdone := make(chan bool)\n\ttimer := time.NewTimer(time.Second * time.Duration(downloadTimeoutSecond))\n\n\t// must run downloading process in\n\t// go routine or else the it will\n\t// block the openModal so loading modal\n\t// will not be shown to the user\n\tgo func() {\n\t\ts := trimViewLine(v)\n\t\tprepDownloadChapter(s)\n\t\tdone <- true\n\t}()\n\n\t// in case downloading takes longer than\n\t// downloadTimeoutSecond, close the modal\n\t// and continue to download in background\n\tgo func() {\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\tsetClosingMessage(g, \"continuing to download\\nin background...\")\n\t\t\treturn\n\t\tcase <-done:\n\t\t\tg.Update(func(g *gocui.Gui) error {\n\t\t\t\terr := closeModal(g)\n\t\t\t\treturn err\n\t\t\t})\n\t\t}\n\t}()\n\n\treturn nil\n}", "func Add(path, branch string) func(*types.Cmd) {\n\treturn func(g *types.Cmd) {\n\t\tg.AddOptions(\"add\")\n\t\tg.AddOptions(path)\n\t\tif len(branch) > 0 {\n\t\t\tg.AddOptions(branch)\n\t\t}\n\t}\n}", "func (s *BasevhdlListener) EnterSelected_name(ctx *Selected_nameContext) {}", "func (ptr *Application) onClickMenuFileOpen() {\n\tfileName, err := dialog.File().Filter(\n\t\t\"Open file\",\n\t).Load()\n\tif err != nil || fileName == \"\" {\n\t\treturn\n\t}\n\n\t// open the file\n\tfileContents, err := ioutil.ReadFile(fileName)\n\tif err != nil {\n\t\treturn\n\t}\n\n\t// update current file information\n\tptr.currentFilename = fileName\n\tptr.currentFileBuffer = fileContents\n\n\t// display the contents\n\tptr.textEditor.SetText(string(ptr.currentFileBuffer))\n}", "func AddClickToSubMenu(i github.Issue, m *systray.MenuItem) {\n\n\t<-m.ClickedCh\n\tstatus := OpenBrowser(*i.HTMLURL)\n\tif status != true {\n\t\tfmt.Println(\"something went wrong opening your browser.... use a Mac dummy\")\n\t}\n\n}", "func (c *Config) promptChoice(prompt string, choices []string, args ...string) (string, error) {\n\tvar defaultValue *string\n\tswitch len(args) {\n\tcase 0:\n\t\t// Do nothing.\n\tcase 1:\n\t\tif !slices.Contains(choices, args[0]) {\n\t\t\treturn \"\", fmt.Errorf(\"%s: invalid default value\", args[0])\n\t\t}\n\t\tdefaultValue = &args[0]\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"want 2 or 3 arguments, got %d\", len(args)+2)\n\t}\n\tif c.interactiveTemplateFuncs.promptDefaults && defaultValue != nil {\n\t\treturn *defaultValue, nil\n\t}\n\treturn c.readChoice(prompt, choices, defaultValue)\n}", "func (o *ColorPicker) X_AddPresetPressed() {\n\t//log.Println(\"Calling ColorPicker.X_AddPresetPressed()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"ColorPicker\", \"_add_preset_pressed\")\n\n\t// Call the parent method.\n\t// void\n\tretPtr := gdnative.NewEmptyVoid()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n}", "func listViewFilesRowActivated(tw *gtk.TreeView) {\n\tvar err error\n\tvar value *glib.Value\n\tvar filename string\n\tvar iters []*gtk.TreeIter\n\tvar isTxt, gtLimit bool\n\n\tif iters = tvsList.GetSelectedIters(); len(iters) > 0 {\n\n\t\tif value, err = tvsList.ListStore.GetValue(iters[0], 3); err == nil { // Field 3: get full path\n\t\t\tfilename, err = value.GetString() // Get selected file path\n\t\t}\n\t\t// Check for text file\n\t\tif isTxt, gtLimit, err = IsTextFile(\n\t\t\tfilename,\n\t\t\topt.FileMinSizeLimit,\n\t\t\topt.FileMaxSizeLimit); err == nil {\n\n\t\t\tif isTxt && gtLimit {\n\t\t\t\tif textWinTextToShowBytes, err = ioutil.ReadFile(filename); err == nil {\n\n\t\t\t\t\tcurrFilename = filename // Filename passed to popup menu of the TextView\n\n\t\t\t\t\tshowTextWin(string(textWinTextToShowBytes), TruncatePath(filename, opt.FilePathLength))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tDlgErr(sts[\"missing\"], err)\n}", "func AddOption(name string, def interface{}, proto, help, relevance string) {\n\tAdd(Option{Name: name,\n\t\tDefault: def,\n\t\tPrototype: proto,\n\t\tHelp: help,\n\t\tRelevance: relevance,\n\t})\n}", "func (cycle *Cycle) Choose() {\n\tif !cycle.showing ||\n\t\tlen(cycle.items) == 0 ||\n\t\tcycle.selected < 0 ||\n\t\tcycle.selected >= len(cycle.items) {\n\n\t\treturn\n\t}\n\n\tcycle.items[cycle.selected].choose()\n\tcycle.Hide()\n}", "func (ref FileView) Add(seqNum commit.SeqNum, version resource.Version) error {\n\tfile, ok := ref.repo.files[ref.file]\n\tif !ok {\n\t\tfile = newFileEntry()\n\t}\n\tview, ok := file.Views[ref.drive]\n\tif !ok {\n\t\tview = make(map[commit.SeqNum]resource.Version)\n\t\tfile.Views[ref.drive] = view\n\t}\n\tview[seqNum] = version\n\tref.repo.files[ref.file] = file\n\treturn nil\n}", "func (f *FilePicker) SelectFile(fileName string) uiauto.Action {\n\treturn f.filesApp.SelectFile(fileName)\n}", "func AddAccountDialog() *nodewith.Finder {\n\treturn nodewith.Name(\"Sign in to add a Google account\").Role(role.RootWebArea)\n}", "func (o IFS) Choose() *Affine {\n\tr := rand.Intn(len(o.Choices))\n\treturn o.Choices[r]\n}", "func handleFiles(_ *gtk.Button, win *gtk.Window) error {\n\tfp, err := runFileChooser(win)\n\tif err != nil {\n\t\tlog(ERR, fmt.Sprintf(\" selecting file: %s\\n\", err.Error()))\n\t\treturn err\n\t}\n\n\tcont, err := ioutil.ReadFile(fp)\n\tif err != nil {\n\t\tlog(ERR, fmt.Sprintf(\" reading file: '%s'\\n\", err.Error()))\n\t\treturn err\n\t}\n\n\tok, err := lib.IsTagNote(&cont)\n\tif err != nil {\n\t\tlog(ERR, fmt.Sprintf(\" checking file header: %s\\n\", err.Error()))\n\t\treturn err\n\t}\n\n\tchild, _ := win.GetChild()\n\twin.Remove(child)\n\n\tif ok {\n\t\ttagList, err := lib.TextToEnt(&cont)\n\t\tif err != nil {\n\t\t\tlog(ERR, fmt.Sprintf(\" splitting content: '%s'\", err.Error()))\n\t\t\treturn err\n\t\t}\n\t\tappShowTags(win, tagList)\n\t} else {\n\t\tappConsolatoryWin(win)\n\t}\n\n\treturn nil\n}", "func selectCategory() string {\n\tfmt.Println(printAllCategories())\n\trequest := \"\\nChoose category to edit:\"\n\tamountOfChoices := 4\n\treturn getValidInput(request, amountOfChoices)\n}", "func (w *Select) Item(value *bool, prompt string) *Select {\n\tw.lines = w.lines + 1\n\tw.Items = append(w.Items, SelectItemBoolVar(value, prompt))\n\treturn w\n}", "func browseFolderCallback(hwnd win.HWND, msg uint32, lp, wp uintptr) uintptr {\n\tconst BFFM_SELCHANGED = 2\n\tif msg == BFFM_SELCHANGED {\n\t\t_, err := pathFromPIDL(lp)\n\t\tvar enabled uintptr\n\t\tif err == nil {\n\t\t\tenabled = 1\n\t\t}\n\n\t\tconst BFFM_ENABLEOK = win.WM_USER + 101\n\n\t\twin.SendMessage(hwnd, BFFM_ENABLEOK, 0, enabled)\n\t}\n\n\treturn 0\n}", "func (f *FlagChoice) String() string {\n\treturn choiceList(f.choices...)\n}", "func (cp CommandProperties) AddFile(value string) {\n\tcp.Add(\"file\", value)\n}", "func (cli *CliPrompter) Choose(pr string, options []string) int {\n\tselected := \"\"\n\tprompt := &survey.Select{\n\t\tMessage: pr,\n\t\tOptions: options,\n\t}\n\t_ = survey.AskOne(prompt, &selected, survey.WithValidator(survey.Required))\n\n\t// return the selected element index\n\tfor i, option := range options {\n\t\tif selected == option {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn 0\n}", "func (f *Filesystem) add(name string, fi hugofs.FileMetaInfo) (err error) {\n\tvar file File\n\n\tfile, err = f.SourceSpec.NewFileInfo(fi)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tf.files = append(f.files, file)\n\n\treturn err\n}", "func (f *FlagChoice) Set(value string) error {\n\tfor _, choice := range f.choices {\n\t\tif choice == value {\n\t\t\tf.chosen = value\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn fmt.Errorf(\"%q is not a valid choice, must be: %s\", value, f.String())\n}", "func ChoiceIndexCallback(title string, choices []string, def int, f func(int, int, int)) int {\n\tselection := def\n\tnc := len(choices) - 1\n\tif selection < 0 || selection > nc {\n\t\tselection = 0\n\t}\n\toffset := 0\n\tcx := 0\n\tfor {\n\t\tsx, sy := termbox.Size()\n\t\ttermbox.HideCursor()\n\t\ttermbox.Clear(termbox.ColorDefault, termbox.ColorDefault)\n\t\tPrintstring(title, 0, 0)\n\t\tfor selection < offset {\n\t\t\toffset -= 5\n\t\t\tif offset < 0 {\n\t\t\t\toffset = 0\n\t\t\t}\n\t\t}\n\t\tfor selection-offset >= sy-1 {\n\t\t\toffset += 5\n\t\t\tif offset >= nc {\n\t\t\t\toffset = nc\n\t\t\t}\n\t\t}\n\t\tfor i, s := range choices[offset:] {\n\t\t\tts, _ := trimString(s, cx)\n\t\t\tPrintstring(ts, 3, i+1)\n\t\t\tif cx > 0 {\n\t\t\t\tPrintstring(\"←\", 2, i+1)\n\t\t\t}\n\t\t}\n\t\tPrintstring(\">\", 1, (selection+1)-offset)\n\t\tif f != nil {\n\t\t\tf(selection, sx, sy)\n\t\t}\n\t\ttermbox.Flush()\n\t\tev := termbox.PollEvent()\n\t\tif ev.Type != termbox.EventKey {\n\t\t\tcontinue\n\t\t}\n\t\tkey := ParseTermboxEvent(ev)\n\t\tswitch key {\n\t\tcase \"C-v\":\n\t\t\tfallthrough\n\t\tcase \"next\":\n\t\t\tselection += sy - 5\n\t\t\tif selection >= len(choices) {\n\t\t\t\tselection = len(choices) - 1\n\t\t\t}\n\t\tcase \"M-v\":\n\t\t\tfallthrough\n\t\tcase \"prior\":\n\t\t\tselection -= sy - 5\n\t\t\tif selection < 0 {\n\t\t\t\tselection = 0\n\t\t\t}\n\t\tcase \"C-c\":\n\t\t\tfallthrough\n\t\tcase \"C-g\":\n\t\t\treturn def\n\t\tcase \"UP\", \"C-p\":\n\t\t\tif selection > 0 {\n\t\t\t\tselection--\n\t\t\t}\n\t\tcase \"DOWN\", \"C-n\":\n\t\t\tif selection < len(choices)-1 {\n\t\t\t\tselection++\n\t\t\t}\n\t\tcase \"LEFT\", \"C-b\":\n\t\t\tif cx > 0 {\n\t\t\t\tcx--\n\t\t\t}\n\t\tcase \"RIGHT\", \"C-f\":\n\t\t\tcx++\n\t\tcase \"C-a\", \"Home\":\n\t\t\tcx = 0\n\t\tcase \"M-<\":\n\t\t\tselection = 0\n\t\tcase \"M->\":\n\t\t\tselection = len(choices) - 1\n\t\tcase \"RET\":\n\t\t\treturn selection\n\t\t}\n\t}\n}", "func (s *BasevhdlListener) ExitChoice(ctx *ChoiceContext) {}", "func (s *BaseBundListener) EnterFile_term(ctx *File_termContext) {}", "func (s *FileSet) Add(file string) {\n\ts.files[file] = true\n}", "func (sd *SimpleDialog) Custom(owner walk.Form, widget Widget) (accepted bool, err error) {\n\tvar (\n\t\tdlg *walk.Dialog\n\t)\n\n\tif _, err := (Dialog{\n\t\tAssignTo: &dlg,\n\t\tLayout: VBox{Margins: Margins{}},\n\t\tChildren: []Widget{\n\t\t\twidget,\n\t\t\tComposite{\n\t\t\t\tLayout: HBox{Margins: Margins{}},\n\t\t\t\tChildren: []Widget{\n\t\t\t\t\tPushButton{\n\t\t\t\t\t\tText: i18n.Tr(\"widget.button.ok\"),\n\t\t\t\t\t\tOnClicked: func() {\n\t\t\t\t\t\t\t// some stuff here...\n\t\t\t\t\t\t\tdlg.Close(0)\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tPushButton{\n\t\t\t\t\t\tText: i18n.Tr(\"widget.button.cancel\"),\n\t\t\t\t\t\tOnClicked: func() {\n\t\t\t\t\t\t\tdlg.Close(0)\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tTitle: sd.Title,\n\t\tSize: sd.Size,\n\t\tFixedSize: sd.FixedSize,\n\t}).Run(owner); err != nil {\n\t\treturn false, err\n\t}\n\n\treturn\n}", "func TestCompletionEntry_WithEmptyOptions(t *testing.T) {\n\tentry := createEntry()\n\twin := test.NewWindow(entry)\n\twin.Resize(fyne.NewSize(500, 300))\n\tdefer win.Close()\n\n\tentry.OnChanged = func(s string) {\n\t\tentry.SetOptions([]string{})\n\t\tentry.ShowCompletion()\n\t}\n\n\tentry.SetText(\"foo\")\n\tassert.Nil(t, entry.popupMenu) // popupMenu should not being created\n}", "func (sp *StackPackage) AddUI(filepath string, ui string) {\n\tsp.UISpecs[filepath] = ui\n}", "func appConsolatoryWin(win *gtk.Window) {\n\tlbl, err := gtk.LabelNew(\"There were no tags to be displayed, sorry!\")\n\tif err != nil {\n\t\tlog(ERR, fmt.Sprintf(\" creating consolatory label: %s\", err.Error()))\n\t\treturn\n\t}\n\n\tbtn, err := gtk.ButtonNewWithLabel(\"Try again\")\n\tif err != nil {\n\t\tlog(ERR, fmt.Sprintf(\" creating file reload button: %s\\n\", err.Error()))\n\t\treturn\n\t}\n\tbtn.Connect(\"clicked\", handleFiles, win)\n\n\tvbox, err := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 10)\n\tif err != nil {\n\t\tlog(ERR, fmt.Sprintf(\" creating vbox: %s\\n\", err.Error()))\n\t\treturn\n\t}\n\n\tvbox.Add(lbl)\n\tvbox.Add(btn)\n\twin.Add(vbox)\n\twin.ShowAll()\n}", "func (c *Config) readChoice(prompt string, choices []string, defaultValue *string) (string, error) {\n\tswitch {\n\tcase c.noTTY:\n\t\tfullPrompt := prompt + \" (\" + strings.Join(choices, \"/\")\n\t\tif defaultValue != nil {\n\t\t\tfullPrompt += \", default \" + *defaultValue\n\t\t}\n\t\tfullPrompt += \")? \"\n\t\tabbreviations := chezmoi.UniqueAbbreviations(choices)\n\t\tfor {\n\t\t\tvalue, err := c.readLineRaw(fullPrompt)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tif value == \"\" && defaultValue != nil {\n\t\t\t\treturn *defaultValue, nil\n\t\t\t}\n\t\t\tif value, ok := abbreviations[value]; ok {\n\t\t\t\treturn value, nil\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tinitModel := chezmoibubbles.NewChoiceInputModel(prompt, choices, defaultValue)\n\t\tfinalModel, err := runCancelableModel(initModel)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn finalModel.Value(), nil\n\t}\n}", "func (p *colorPicker) AddImage(image string) {\n\timageName := tag.StripTag(image, false)\n\tif _, ok := p.imageColors[imageName]; ok {\n\t\treturn\n\t}\n\tp.imageColors[imageName] = DefaultColorCodes[len(p.imageColors)%len(DefaultColorCodes)]\n}", "func SelectionChanged(s *gtk.TreeSelection) {\n\t// Returns glib.List of gtk.TreePath pointers\n\trows := s.GetSelectedRows(ListStore)\n\titems := make([]string, 0, rows.Length())\n\n\tfor l := rows; l != nil; l = l.Next() {\n\t\tpath := l.Data().(*gtk.TreePath)\n\t\titer, _ := ListStore.GetIter(path)\n\t\tvalue, _ := ListStore.GetValue(iter, 0)\n\t\tstr, _ := value.GetString()\n\t\titems = append(items, str)\n\t}\n\n\tEntry.SetText(fmt.Sprint(items))\n}", "func registerOnChosenReceived(self *State, message string) {\n\tif !validateChosen(message) || self.IsLeader {\n\t\treturn\n\t}\n\n\tfirstBracket := strings.Index(message, \"[\")\n\tsecondBracket := strings.Index(message, \"]\")\n\tself.Proposition.ChosenValue.CopyFromCommand(extractCommand(message[(firstBracket + 1):secondBracket]))\n\n\trestString := message[(secondBracket + 1):]\n\t_, index := GetKeyValuePair(restString)\n\n\tsynchronize(self, index)\n}", "func (sa *SelectWithAdd) Run() (int, string, error) {\n\tif len(sa.Items) > 0 {\n\t\tnewItems := append([]string{sa.AddLabel}, sa.Items...)\n\n\t\tlist, err := list.New(newItems, 5)\n\t\tif err != nil {\n\t\t\treturn 0, \"\", err\n\t\t}\n\n\t\ts := Select{\n\t\t\tLabel: sa.Label,\n\t\t\tItems: newItems,\n\t\t\tIsVimMode: sa.IsVimMode,\n\t\t\tSize: 5,\n\t\t\tlist: list,\n\t\t}\n\t\ts.setKeys()\n\n\t\terr = s.prepareTemplates()\n\t\tif err != nil {\n\t\t\treturn 0, \"\", err\n\t\t}\n\n\t\tselected, value, err := s.innerRun(1, '+')\n\t\tif err != nil || selected != 0 {\n\t\t\treturn selected - 1, value, err\n\t\t}\n\n\t\t// XXX run through terminal for windows\n\t\tos.Stdout.Write([]byte(upLine(1) + \"\\r\" + clearLine))\n\t}\n\n\tp := Prompt{\n\t\tLabel: sa.AddLabel,\n\t\tValidate: sa.Validate,\n\t\tIsVimMode: sa.IsVimMode,\n\t}\n\tvalue, err := p.Run()\n\treturn SelectedAdd, value, err\n}", "func editRuleLibItemSelected(myItem *widgets.QTreeWidgetItem, column int) {\n index := editRuleTree.IndexOfTopLevelItem(myItem)\n fullfilLineEditWithBgpFs(BgpFsActivLib[index])\n}", "func (a *p) AddOption(items ...string) *p {\n\tif len(items) == 0 {\n\t\treturn a\n\t}\n\n\tif len(a.ItemS) == len(a.OptaS) { // add first trailing spacer\n\t\ta.addMark(-1, 0) // Note: DK starts marking with 0, and decrements. We start negative, using -1.\n\t}\n\n\tc := x.Index(len(a.OptaS)) // shall create a.OptaS[c]\n\tseen := make(map[string]int, len(items)) // to avoid duplicate items in this option.\n\n\tfor i, name := range items {\n\t\tif prev, ok := seen[name]; ok {\n\t\t\tdie(fmt.Sprintf(\"AddOption: duplicate item `%v`: first seen at %v, now at %v!\", name, prev, i))\n\t\t}\n\t\tseen[name] = i\n\n\t\ta.addCell(a.MustKnow(x.Name(name))) // append to Column(name-Index)\n\t}\n\n\ta.addMark(a.OptaS[c-1].Root-1, c) // add trailing spacer\n\ta.OptaS[c-1].Next = (c - 1) + x.Index(len(items)) // update preceding spacer\n\n\treturn a\n}", "func (fn *formulaFuncs) CHOOSE(argsList *list.List) formulaArg {\n\tif argsList.Len() < 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CHOOSE requires 2 arguments\")\n\t}\n\tidx, err := strconv.Atoi(argsList.Front().Value.(formulaArg).Value())\n\tif err != nil {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CHOOSE requires first argument of type number\")\n\t}\n\tif argsList.Len() <= idx {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"index_num should be <= to the number of values\")\n\t}\n\targ := argsList.Front()\n\tfor i := 0; i < idx; i++ {\n\t\targ = arg.Next()\n\t}\n\treturn arg.Value.(formulaArg)\n}", "func (s *BasevhdlListener) ExitChoices(ctx *ChoicesContext) {}", "func (c *contentTypes) add(partName, contentType string) error {\n\t// Process descrived in ISO/IEC 29500-2 §10.1.2.3\n\tt, params, _ := mime.ParseMediaType(contentType)\n\tcontentType = mime.FormatMediaType(t, params)\n\n\text := strings.ToLower(path.Ext(partName))\n\tif len(ext) == 0 {\n\t\tc.addOverride(partName, contentType)\n\t\treturn nil\n\t}\n\text = ext[1:] // remove dot\n\tc.ensureDefaultsMap()\n\tcurrentType, ok := c.defaults[ext]\n\tif ok {\n\t\tif currentType != contentType {\n\t\t\tc.addOverride(partName, contentType)\n\t\t}\n\t} else {\n\t\tc.addDefault(ext, contentType)\n\t}\n\n\treturn nil\n}", "func (c *walkerContext) addFile(path string, info os.FileInfo) {\n\tf := newFileInfo(path, info)\n\tc.current.Files = append(c.current.Files, f)\n}", "func ChoiceIndex(title string, choices []string, def int) int {\n\treturn ChoiceIndexCallback(title, choices, def, nil)\n}", "func (c *Client) Add(code, filepath string, content io.ReadCloser) error {\n\t// TODO: Decide, based on the code, which provider to choose\n\treturn c.googledrive.Add(code, filepath, content)\n}", "func (d Client) CreateDialog(name string, filename string, data io.Reader) (string, error) {\n\treturn d.createOrUpdateDialog(\"\", name, filename, data)\n}", "func choiceList(choices ...string) string {\n\tswitch len(choices) {\n\tcase 0:\n\t\treturn \"you have no choice\"\n\tcase 1:\n\t\treturn choices[0]\n\tcase 2:\n\t\tconst msg = \"%s or %s\"\n\t\treturn fmt.Sprintf(msg, choices[0], choices[1])\n\tdefault:\n\t\tvar buf strings.Builder\n\t\tfor i, choice := range choices {\n\t\t\tswitch i {\n\t\t\tcase 0:\n\t\t\t\tbuf.WriteString(choice)\n\t\t\tcase len(choices) - 1:\n\t\t\t\tbuf.WriteString(\", or \")\n\t\t\t\tbuf.WriteString(choice)\n\t\t\tdefault:\n\t\t\t\tbuf.WriteString(\", \")\n\t\t\t\tbuf.WriteString(choice)\n\t\t\t}\n\t\t}\n\t\treturn buf.String()\n\t}\n}", "func (cli *CLI) Choose() (string, error) {\n\tcolorstring.Fprintf(cli.errStream, chooseText)\n\n\tnum, err := cli.AskNumber(4, 1)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// If user selects 3, should ask user GPL V2 or V3\n\tif num == 3 {\n\t\tvar buf bytes.Buffer\n\t\tbuf.WriteString(\"\\n\")\n\t\tbuf.WriteString(\"Which version do you want?\\n\")\n\t\tbuf.WriteString(\" 1) V2\\n\")\n\t\tbuf.WriteString(\" 2) V3\\n\")\n\t\tfmt.Fprintf(cli.errStream, buf.String())\n\n\t\tnum, err = cli.AskNumber(2, 1)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tnum += 4\n\t}\n\n\tvar key string\n\tswitch num {\n\tcase 1:\n\t\tkey = \"mit\"\n\tcase 2:\n\t\tkey = \"apache-2.0\"\n\tcase 4:\n\t\tkey = \"\"\n\tcase 5:\n\t\tkey = \"gpl-2.0\"\n\tcase 6:\n\t\tkey = \"gpl-3.0\"\n\tdefault:\n\t\t// Should not reach here\n\t\tpanic(\"Invalid number\")\n\t}\n\n\treturn key, nil\n}", "func acceptCompletion(ed *Editor) {\n\tc := ed.completion\n\tif 0 <= c.selected && c.selected < len(c.candidates) {\n\t\ted.line, ed.dot = c.apply(ed.line, ed.dot)\n\t}\n\ted.mode = &ed.insert\n}", "func addApp(search string, apps *applications) error {\n\t_, found := stringInSlice(search, (*apps)[\"default\"])\n\tif found == true {\n\t\tmsg := fmt.Sprintf(\"%s already exists in default opener group\", search)\n\t\treturn errors.New(msg)\n\t}\n\n\t(*apps)[\"default\"] = append((*apps)[\"default\"], search)\n\tmsg := fmt.Sprintf(\"Successfully added %s to default opener group\", search)\n\terr := rewriteApps(apps, msg)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func isChoiceOrCase(e *yang.Entry) bool {\n\treturn e.Kind == yang.CaseEntry || e.Kind == yang.ChoiceEntry\n}", "func (fs *FileSet) Add(s string) {\n\t//找一个空channel,传入string\n\tif len(fs.fileChannels[fs.top]) == bufferSize {\n\t\tfs.fileChannels = append(fs.fileChannels, make(chan string, bufferSize))\n\t\tfs.top++\n\t}\n\tfs.fileChannels[fs.top] <- s\n}", "func (pdu *Pdu) AddOption(key OptionKey, val interface{}) {\n var option Option\n var err error\n\tiv := reflect.ValueOf(val)\n\tif iv.Kind() == reflect.String {\n if key == C.COAP_OPTION_ETAG {\n option, err = key.Opaque(val.(string))\n if err != nil {\n log.Errorf(\"Binary read data failed: %+v\", err)\n }\n } else {\n option = key.String(val.(string))\n }\n\t} else if iv.Kind() == reflect.Uint8 || iv.Kind() == reflect.Uint16 || iv.Kind() == reflect.Uint32 {\n option, err = key.Uint(val)\n if err != nil {\n log.Errorf(\"Binary read data failed: %+v\", err)\n }\n } else {\n log.Warnf(\"Unsupported type of option value. Current value type: %+v\\n\", iv.Kind().String())\n return\n\t}\n\tpdu.Options = append(pdu.Options, option)\n}", "func (s *SelectableAttribute) Chooser() BooleanAttribute {\n\treturn s.chooser\n}", "func (c Clipboard) Add(s string) {\n\tc.Storage.Save(s)\n}", "func NewAddItemOK() *AddItemOK {\n\n\treturn &AddItemOK{}\n}", "func exportTrackCB() {\n\tvar expPath string\n\tfs := gtk.NewFileChooserDialog(\n\t\t\"File for Track Export\",\n\t\twin,\n\t\tgtk.FILE_CHOOSER_ACTION_SAVE, \"_Cancel\", gtk.RESPONSE_CANCEL, \"_Export\", gtk.RESPONSE_ACCEPT)\n\tfs.SetCurrentFolder(settings.DataDir)\n\tfs.SetLocalOnly(true)\n\tff := gtk.NewFileFilter()\n\tff.AddPattern(\"*.csv\")\n\tfs.SetFilter(ff)\n\tres := fs.Run()\n\tif res == gtk.RESPONSE_ACCEPT {\n\t\texpPath = fs.GetFilename()\n\t\tif expPath != \"\" {\n\t\t\texp, err := os.Create(expPath)\n\t\t\tif err != nil {\n\t\t\t\tmessageDialog(win, gtk.MESSAGE_INFO, \"Could not create CSV file.\")\n\t\t\t} else {\n\t\t\t\tdefer exp.Close()\n\t\t\t\tw := csv.NewWriter(exp)\n\t\t\t\tliveTrack.trackMu.RLock()\n\t\t\t\tfor _, k := range liveTrack.positions {\n\t\t\t\t\tw.Write(k.toStrings())\n\t\t\t\t}\n\t\t\t\tliveTrack.trackMu.RUnlock()\n\t\t\t\tw.Flush()\n\t\t\t}\n\t\t}\n\t}\n\tfs.Destroy()\n}", "func (m *OpenFile) AddFilter(name, pattern string) *OpenFile {\n\tm.filters = append(m.filters, filter{name, pattern})\n\treturn m\n}", "func userChoice() {\n\tfor {\n\t\tfmt.Println(\"\\nMenu Options:\")\n\t\tfmt.Println(\"1. Add Employee\")\n\t\tfmt.Println(\"2. Delete Employee\")\n\t\tfmt.Println(\"3. Search Employee\")\n\t\tfmt.Println(\"4. List All Employees\")\n\t\tfmt.Println(\"5. Save Employee Database\")\n\t\tfmt.Println(\"6. Exit Employee Database\")\n\t\tfmt.Print(\"Enter Your Choice: \")\n\t\treader := bufio.NewReader(os.Stdin)\n\t\tchoice, _, err := reader.ReadRune()\n\t\tif err != nil {\n \t\t\tfmt.Println(err)\n\t\t}\n\t\tswitch choice {\n\t\tcase ADD:\n\t\t\taddEmployee()\n\t\tcase DELETE:\n\t\t\tdeleteEmployee()\n\t\tcase SEARCH:\n\t\t\tsearchEmployee()\n\t\tcase LIST:\n\t\t\tlistEmployees()\n\t\tcase SAVE:\n\t\t\tsaveEmployees()\n\t\tcase EXIT:\n\t\t\tsaveEmployees()\n\t\t\tos.Exit(0);\n\t\tdefault:\n\t\t\tfmt.Println(\"Wrong choice\")\n\t\t} /* End of switch */\n\t} /* End of for() */\n}", "func exportTrackImageCB() {\n\tvar expPath string\n\tfs := gtk.NewFileChooserDialog(\n\t\t\"File for Track Image\",\n\t\twin,\n\t\tgtk.FILE_CHOOSER_ACTION_SAVE, \"_Cancel\", gtk.RESPONSE_CANCEL, \"_Export\", gtk.RESPONSE_ACCEPT)\n\tfs.SetCurrentFolder(settings.DataDir)\n\tff := gtk.NewFileFilter()\n\tff.AddPattern(\"*.png\")\n\tfs.SetFilter(ff)\n\tres := fs.Run()\n\tif res == gtk.RESPONSE_ACCEPT {\n\t\texpPath = fs.GetFilename()\n\t\tif expPath != \"\" {\n\t\t\texp, err := os.Create(expPath)\n\t\t\tif err != nil {\n\t\t\t\tmessageDialog(win, gtk.MESSAGE_INFO, \"Could not create image file.\")\n\t\t\t} else {\n\t\t\t\tdefer exp.Close()\n\t\t\t\tif err := png.Encode(exp, trackChart.backingImage); err != nil {\n\t\t\t\t\tmessageDialog(win, gtk.MESSAGE_INFO, \"Could not write image file.\")\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfs.Destroy()\n}", "func (c *Command) AddValueOption(name, value, description string) {\n\topt := Option{\n\t\tKey: name,\n\t\tValue: value,\n\t\tDescription: description,\n\t}\n\tc.Options = append(c.Options, opt)\n}", "func (s *BasevhdlListener) EnterSelected_signal_assignment(ctx *Selected_signal_assignmentContext) {}", "func (p *Merger) Add(file string) {\n\tp.files = append(p.files, file)\n}", "func addOption(c *ConfigParser, section, option, value string) {\n\tc.sections[section].options[option] = value\n}", "func (p *Package) AddOption(t *GlobalOption) {\n\tp.options = append(p.options, t)\n}", "func (in *Choice) DeepCopy() *Choice {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Choice)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "func New(prompt string, choices []*Choice) *Selection {\n\treturn &Selection{\n\t\tChoices: choices,\n\t\tPrompt: prompt,\n\t\tFilterPrompt: DefaultFilterPrompt,\n\t\tTemplate: DefaultTemplate,\n\t\tConfirmationTemplate: DefaultConfirmationTemplate,\n\t\tFilter: FilterContainsCaseInsensitive,\n\t\tFilterInputPlaceholderStyle: lipgloss.NewStyle().Foreground(lipgloss.Color(\"240\")),\n\t\tKeyMap: NewDefaultKeyMap(),\n\t\tFilterPlaceholder: DefaultFilterPlaceholder,\n\t\tExtendedTemplateScope: template.FuncMap{},\n\t\tOutput: os.Stdout,\n\t\tInput: os.Stdin,\n\t}\n}" ]
[ "0.67540985", "0.6272586", "0.5666724", "0.53501856", "0.5213042", "0.5131987", "0.5029371", "0.49853897", "0.49848685", "0.4980705", "0.49217358", "0.48278055", "0.48229167", "0.48218247", "0.46595183", "0.4618801", "0.4616831", "0.45478475", "0.45407698", "0.45162332", "0.4513119", "0.44895467", "0.4483588", "0.44415537", "0.4426831", "0.44078875", "0.44059056", "0.4405005", "0.44048342", "0.43727246", "0.43419793", "0.43100652", "0.4302463", "0.42821136", "0.42239836", "0.4222806", "0.42227888", "0.42214668", "0.42199725", "0.42145678", "0.4199051", "0.41790387", "0.41661564", "0.41592774", "0.4145671", "0.41364017", "0.41282687", "0.4119848", "0.41182366", "0.4115181", "0.4105169", "0.40975466", "0.40954486", "0.40858442", "0.40808162", "0.40731263", "0.40690598", "0.4060945", "0.40580633", "0.40555254", "0.40497747", "0.40448225", "0.40436065", "0.40232816", "0.40170002", "0.4015269", "0.4013371", "0.4011264", "0.39995658", "0.39989224", "0.3998111", "0.3983421", "0.39803854", "0.39800793", "0.39789525", "0.3973423", "0.39622703", "0.3953337", "0.39519563", "0.3950318", "0.39433077", "0.39432043", "0.39403677", "0.3939977", "0.39386725", "0.3909854", "0.3905742", "0.39046586", "0.39032578", "0.38945687", "0.38935605", "0.3892145", "0.3883747", "0.38775378", "0.38767067", "0.3867089", "0.38543344", "0.38524434", "0.3844965", "0.3841543" ]
0.8392795
0
RemoveChoice is a wrapper around gtk_file_chooser_remove_choice().
func (v *FileChooser) RemoveChoice(id string) { cId := C.CString(id) defer C.free(unsafe.Pointer(cId)) C.gtk_file_chooser_remove_choice(v.native(), (*C.gchar)(cId)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *FileChooser) GetChoice(id string) string {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\tc := C.gtk_file_chooser_get_choice(v.native(), (*C.gchar)(cId))\n\treturn C.GoString(c)\n}", "func (v *FileChooser) SetChoice(id, option string) {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\tcOption := C.CString(option)\n\tdefer C.free(unsafe.Pointer(cOption))\n\tC.gtk_file_chooser_set_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cOption))\n}", "func (v *FileChooser) AddChoice(id, label string, options, optionLabels []string) {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\n\tcLabel := C.CString(label)\n\tdefer C.free(unsafe.Pointer(cLabel))\n\n\tif options == nil || optionLabels == nil {\n\t\tC.gtk_file_chooser_add_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cLabel), nil, nil)\n\t\treturn\n\t}\n\n\tcOptions := C.make_strings(C.int(len(options) + 1))\n\tfor i, option := range options {\n\t\tcstr := C.CString(option)\n\t\tdefer C.free(unsafe.Pointer(cstr))\n\t\tC.set_string(cOptions, C.int(i), (*C.gchar)(cstr))\n\t}\n\tC.set_string(cOptions, C.int(len(options)), nil)\n\n\tcOptionLabels := C.make_strings(C.int(len(optionLabels) + 1))\n\tfor i, optionLabel := range optionLabels {\n\t\tcstr := C.CString(optionLabel)\n\t\tdefer C.free(unsafe.Pointer(cstr))\n\t\tC.set_string(cOptionLabels, C.int(i), (*C.gchar)(cstr))\n\t}\n\tC.set_string(cOptionLabels, C.int(len(optionLabels)), nil)\n\n\tC.gtk_file_chooser_add_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cLabel), cOptions, cOptionLabels)\n}", "func removeSelectedAccountFromOSSettings(ctx context.Context, tconn *chrome.TestConn) error {\n\ttesting.ContextLog(ctx, \"Removing account\")\n\n\tui := uiauto.New(tconn).WithTimeout(DefaultUITimeout)\n\tremoveAccountButton := RemoveActionButton()\n\tif err := uiauto.Combine(\"Click Remove account\",\n\t\tui.WaitUntilExists(removeAccountButton),\n\t\tui.LeftClick(removeAccountButton),\n\t)(ctx); err != nil {\n\t\treturn errors.Wrap(err, \"failed to to click Remove account\")\n\t}\n\n\treturn nil\n}", "func (m *Menu) RemoveMenuOption(index int) {\n\tcopy(m.Options[index:], m.Options[index+1:])\n\tm.Options = m.Options[:len(m.Options)-1]\n}", "func RemoveActionButton() *nodewith.Finder {\n\treturn nodewith.Name(\"Remove this account\").Role(role.MenuItem)\n}", "func (v *IconView) UnselectPath(path *TreePath) {\n\tC.gtk_icon_view_unselect_path(v.native(), path.native())\n}", "func (fb *FlowBox) UnselectChild(child *FlowBoxChild) {\n\tC.gtk_flow_box_unselect_child(fb.native(), child.native())\n}", "func UnMenuButton(cb func()) {\n\tjs.Global.Get(\"document\").Call(\"removeEventListener\", \"menubutton\", cb, false)\n}", "func (m *_ChangeListRemoveError) GetErrorChoice() BACnetConfirmedServiceChoice {\n\treturn BACnetConfirmedServiceChoice_REMOVE_LIST_ELEMENT\n}", "func performSuggestionRemovalDialogAction(tconn *chrome.TestConn, dialogButtonName string) uiauto.Action {\n\tui := uiauto.New(tconn)\n\treturn uiauto.Combine(\"press removal dialog button\",\n\t\tui.LeftClick(nodewith.Role(role.Button).Name(dialogButtonName).Ancestor(removalDialogFinder)),\n\t\tui.WaitUntilGone(removalDialogFinder))\n}", "func radioMenuItemFinalizer(m *RadioMenuItem) {\n\truntime.SetFinalizer(m, func(m *RadioMenuItem) { gobject.Unref(m) })\n}", "func (s *BasevhdlListener) ExitChoice(ctx *ChoiceContext) {}", "func RemoveItem(defaults []string, name string) []string {\n\tvar pkgs []string\n\tfor _, pkg := range defaults {\n\t\tif pkg != name {\n\t\t\tpkgs = append(pkgs, pkg)\n\t\t}\n\t}\n\treturn pkgs\n}", "func comboBoxFinalizer(cb *ComboBox) {\n\truntime.SetFinalizer(cb, func(cb *ComboBox) { gobject.Unref(cb) })\n}", "func Remove(arg string) {\n\tif arg != \"\" {\n\t\terr := os.Remove(arg)\n\t\tutils.Check(err)\n\t} else {\n\t\tutils.CliErrorln(\"Filename must be included for remove command\") // If this function name changes,\n\t\t// CHANGE THIS STRING ERROR TOO\n\t}\n}", "func radioButtonFinalizer(rb *RadioButton) {\n\truntime.SetFinalizer(rb, func(rb *RadioButton) { gobject.Unref(rb) })\n}", "func (im InputMethod) Remove(tconn *chrome.TestConn) action.Action {\n\tf := func(ctx context.Context, fullyQualifiedIMEID string) error {\n\t\treturn RemoveInputMethod(ctx, tconn, fullyQualifiedIMEID)\n\t}\n\treturn im.actionWithFullyQualifiedID(tconn, f)\n}", "func comboBoxTextFinalizer(ct *ComboBoxText) {\n\truntime.SetFinalizer(ct, func(ct *ComboBoxText) { gobject.Unref(ct) })\n}", "func PromptDelete(username string) string {\n\tprompt := promptui.Select{\n\t\tLabel: \"Delete the user? (This will remove all their repositories, gists, applications, and personal settings)\",\n\t\tItems: []string{\"yes\", \"no\"},\n\t}\n\n\t_, result, err := prompt.Run()\n\tif err != nil {\n\t\tlog.Fatalf(\"Prompt failed %v\\n\", err)\n\t}\n\treturn result\n}", "func (pdu *Pdu) RemoveOption(key OptionKey) {\n\topts := optsSorter{pdu.Options}\n\tpdu.Options = opts.Minus(key).opts\n}", "func (s *ActionsService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) {\n\turl := fmt.Sprintf(\"orgs/%v/actions/secrets/%v/repositories/%v\", org, name, *repo.ID)\n\treturn s.removeSelectedRepoFromSecret(ctx, url)\n}", "func Remove(confirm bool, name string) error {\n\tif !confirm {\n\t\treturn nil\n\t}\n\tif err := os.Remove(name); err != nil {\n\t\treturn fmt.Errorf(\"remove %q: %w\", name, err)\n\t}\n\treturn nil\n}", "func (s *slot) remove(c interface{}) {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\tdelete(s.elements, c)\n}", "func handleFiles(_ *gtk.Button, win *gtk.Window) error {\n\tfp, err := runFileChooser(win)\n\tif err != nil {\n\t\tlog(ERR, fmt.Sprintf(\" selecting file: %s\\n\", err.Error()))\n\t\treturn err\n\t}\n\n\tcont, err := ioutil.ReadFile(fp)\n\tif err != nil {\n\t\tlog(ERR, fmt.Sprintf(\" reading file: '%s'\\n\", err.Error()))\n\t\treturn err\n\t}\n\n\tok, err := lib.IsTagNote(&cont)\n\tif err != nil {\n\t\tlog(ERR, fmt.Sprintf(\" checking file header: %s\\n\", err.Error()))\n\t\treturn err\n\t}\n\n\tchild, _ := win.GetChild()\n\twin.Remove(child)\n\n\tif ok {\n\t\ttagList, err := lib.TextToEnt(&cont)\n\t\tif err != nil {\n\t\t\tlog(ERR, fmt.Sprintf(\" splitting content: '%s'\", err.Error()))\n\t\t\treturn err\n\t\t}\n\t\tappShowTags(win, tagList)\n\t} else {\n\t\tappConsolatoryWin(win)\n\t}\n\n\treturn nil\n}", "func _file_delete(call otto.FunctionCall) otto.Value {\n\tpath, _ := call.Argument(0).ToString()\n\n\terr := os.RemoveAll(path)\n\tif err != nil {\n\t\tjsThrow(call, err)\n\t}\n\treturn otto.Value{}\n}", "func (g *Generator) RemoveSeccompSyscallByAction(action string) error {\n\tif g.spec == nil || g.spec.Linux == nil || g.spec.Linux.Seccomp == nil {\n\t\treturn nil\n\t}\n\n\tif err := checkSeccompSyscallAction(action); err != nil {\n\t\treturn err\n\t}\n\n\tvar r []rspec.Syscall\n\tfor _, syscall := range g.spec.Linux.Seccomp.Syscalls {\n\t\tif strings.Compare(action, string(syscall.Action)) != 0 {\n\t\t\tr = append(r, syscall)\n\t\t}\n\t}\n\tg.spec.Linux.Seccomp.Syscalls = r\n\treturn nil\n}", "func Remove(name string) func(*types.Cmd) {\n\treturn func(g *types.Cmd) {\n\t\tg.AddOptions(\"remove\")\n\t\tg.AddOptions(name)\n\t}\n}", "func (c *Client) UnselectAndExpunge() *Command {\n\tcmd := &unselectCommand{}\n\tc.beginCommand(\"CLOSE\", cmd).end()\n\treturn &cmd.cmd\n}", "func (s *BasevhdlListener) ExitChoices(ctx *ChoicesContext) {}", "func createBookConfirm(controls *ControlList, conf *cf.Config) {\n\tcw, ch := term.Size()\n\thalfWidth := cw / 2\n\tdlgWidth := (halfWidth - 5) * 2\n\tcontrols.askWindow = ui.AddWindow(5, ch/2-8, dlgWidth, 3, \"Remove book\")\n\tcontrols.askWindow.SetConstraints(dlgWidth, ui.KeepValue)\n\tcontrols.askWindow.SetModal(false)\n\tcontrols.askWindow.SetPack(ui.Vertical)\n\n\tui.CreateFrame(controls.askWindow, 1, 1, ui.BorderNone, ui.Fixed)\n\tfbtn := ui.CreateFrame(controls.askWindow, 1, 1, ui.BorderNone, 1)\n\tui.CreateFrame(fbtn, 1, 1, ui.BorderNone, ui.Fixed)\n\tcontrols.askLabel = ui.CreateLabel(fbtn, 10, 3, \"Remove book?\", 1)\n\tcontrols.askLabel.SetMultiline(true)\n\tui.CreateFrame(fbtn, 1, 1, ui.BorderNone, ui.Fixed)\n\n\tui.CreateFrame(controls.askWindow, 1, 1, ui.BorderNone, ui.Fixed)\n\tfrm1 := ui.CreateFrame(controls.askWindow, 16, 4, ui.BorderNone, ui.Fixed)\n\tui.CreateFrame(frm1, 1, 1, ui.BorderNone, 1)\n\tcontrols.askRemove = ui.CreateButton(frm1, ui.AutoSize, ui.AutoSize, \"Remove\", ui.Fixed)\n\tcontrols.askCancel = ui.CreateButton(frm1, ui.AutoSize, ui.AutoSize, \"Cancel\", ui.Fixed)\n\tcontrols.askCancel.OnClick(func(ev ui.Event) {\n\t\tcontrols.askWindow.SetModal(false)\n\t\tcontrols.askWindow.SetVisible(false)\n\t\tui.ActivateControl(controls.bookListWindow, controls.bookTable)\n\t})\n\n\tcontrols.askWindow.SetVisible(false)\n\tcontrols.askWindow.OnClose(func(ev ui.Event) bool {\n\t\tcontrols.askWindow.SetVisible(false)\n\t\tcontrols.bookListWindow.SetModal(true)\n\t\tui.ActivateControl(controls.bookListWindow, controls.bookTable)\n\t\treturn false\n\t})\n}", "func Remove(name string) error", "func RemoveAction(name string) {\n\tdelete(actions, name)\n}", "func RemoveOrQuit(filename string) error {\n\tif !FileExists(filename) {\n\t\treturn nil\n\t}\n\n\tfmt.Printf(\"%s exists, overwrite it?\\nEnter to overwrite or Ctrl-C to cancel...\",\n\t\tcolor.New(color.BgRed, color.Bold).Render(filename))\n\tbufio.NewReader(os.Stdin).ReadBytes('\\n')\n\n\treturn os.Remove(filename)\n}", "func UnSearchButton(cb func()) {\n\tjs.Global.Get(\"document\").Call(\"removeEventListener\", \"searchbutton\", cb, false)\n}", "func removeApp(search string, apps *applications) error {\n\tif i, found := stringInSlice(search, (*apps)[\"default\"]); found == true {\n\t\t(*apps)[\"default\"] = append((*apps)[\"default\"][:i], (*apps)[\"default\"][i+1:]...)\n\t\tmsg := fmt.Sprintf(\"Successfully removed %s from default opener group\", search)\n\t\terr := rewriteApps(apps, msg)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tmsg := fmt.Sprintf(\"Could not find %s in configuration\\n\", search)\n\t\treturn errors.New(msg)\n\t}\n\n\treturn nil\n}", "func (i *bashInstaller) Remove(ctx context.Context, f resources.Feature, t resources.Targetable, v data.Map, s resources.FeatureSettings) (r resources.Results, ferr fail.Error) {\n\tr = nil\n\tdefer fail.OnPanic(&ferr)\n\n\tif ctx == nil {\n\t\treturn nil, fail.InvalidParameterCannotBeNilError(\"ctx\")\n\t}\n\tif f == nil {\n\t\treturn nil, fail.InvalidParameterCannotBeNilError(\"f\")\n\t}\n\tif t == nil {\n\t\treturn nil, fail.InvalidParameterCannotBeNilError(\"t\")\n\t}\n\n\tif !f.(*Feature).Specs().IsSet(\"feature.install.bash.remove\") {\n\t\tmsg := `syntax error in Feature '%s' specification file (%s):\n\t\t\t\tno key 'feature.install.bash.remove' found`\n\t\treturn nil, fail.SyntaxError(msg, f.GetName(), f.GetDisplayFilename(ctx))\n\t}\n\n\tw, xerr := newWorker(ctx, f, t, installmethod.Bash, installaction.Remove, nil)\n\tif xerr != nil {\n\t\treturn nil, xerr\n\t}\n\tdefer w.Terminate()\n\n\txerr = w.CanProceed(ctx, s)\n\txerr = debug.InjectPlannedFail(xerr)\n\tif xerr != nil {\n\t\tlogrus.Info(xerr.Error())\n\t\treturn nil, xerr\n\t}\n\n\tr, xerr = w.Proceed(ctx, v, s)\n\txerr = debug.InjectPlannedFail(xerr)\n\tif xerr != nil {\n\t\treturn r, fail.Wrap(xerr, \"failed to remove Feature '%s' from %s '%s'\", f.GetName(), t.TargetType(), t.GetName())\n\t}\n\n\treturn r, nil\n}", "func (fb *FlowBox) UnselectAll() {\n\tC.gtk_flow_box_unselect_all(fb.native())\n}", "func (c *Client) Remove(code, filepath string) error {\n\t// TODO: Decide, based on the code, which provider to choose\n\treturn c.googledrive.Remove(code, filepath)\n}", "func (s *BasevhdlListener) ExitSelected_signal_assignment(ctx *Selected_signal_assignmentContext) {}", "func (fs *bundleFs) Remove(name string) error {\n\treturn ErrReadOnly\n}", "func (c *Action) RemoveMatcher(o string) {\n\tfmt.Fprintf(c.w, removeMatcherFmt, o)\n}", "func (recv *ParamSpecPool) Remove(pspec *ParamSpec) {\n\tc_pspec := (*C.GParamSpec)(C.NULL)\n\tif pspec != nil {\n\t\tc_pspec = (*C.GParamSpec)(pspec.ToC())\n\t}\n\n\tC.g_param_spec_pool_remove((*C.GParamSpecPool)(recv.native), c_pspec)\n\n\treturn\n}", "func Remove(file string) {\n\tknownFiles[file] = false\n\tdelete(allFiles, file)\n}", "func (p *Merger) Remove(file string) string {\n\tfor i, f := range p.files {\n\t\tif f == file {\n\t\t\tremoved := p.files[i]\n\t\t\tp.files = append(p.files[:i], p.files[i+1:]...)\n\t\t\treturn removed\n\t\t}\n\t}\n\treturn \"\"\n}", "func (tv *TextView) ClearSelected() {\n\ttv.WidgetBase.ClearSelected()\n\ttv.SelectReset()\n}", "func selectFileGUI(titleA string, filterNameA string, filterTypeA string) string {\n\tfileNameT, errT := dialog.File().Filter(filterNameA, filterTypeA).Title(titleA).Load()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn fileNameT\n}", "func (f *FileStore) Remove(collection, id string) error {\n\treturn os.Remove(filepath.Join(f.Base, collection, id+\".txt\"))\n}", "func (file *Remote) Remove(p string) error {\n\tif p != \"\" {\n\t\tfile, err := file.walk(p)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Close is not necessary. Remove is also a clunk.\n\n\t\treturn file.Remove(\"\")\n\t}\n\n\t_, err := file.client.Send(&Tremove{\n\t\tFID: file.fid,\n\t})\n\treturn err\n}", "func Uninstall() error { return mageextras.Uninstall(\"factorio\") }", "func RemoveMatchSignal(conn *dbus.Conn, s Signal, opts ...dbus.MatchOption) error {\n\treturn conn.RemoveMatchSignal(append([]dbus.MatchOption{\n\t\tdbus.WithMatchInterface(s.Interface()),\n\t\tdbus.WithMatchMember(s.Name()),\n\t}, opts...)...)\n}", "func Remove(options types.RemoveOptions, config config.Store) error {\n\tapp := &AppImage{}\n\n\tindexFile := fmt.Sprintf(\"%s.json\", path.Join(config.IndexStore, options.Executable))\n\tlogger.Debugf(\"Checking if %s exists\", indexFile)\n\tif !helpers.CheckIfFileExists(indexFile) {\n\t\tfmt.Printf(\"%s is not installed \\n\", tui.Yellow(options.Executable))\n\t\treturn nil\n\t}\n\n\tbar := tui.NewProgressBar(7, \"r\")\n\n\tlogger.Debugf(\"Unmarshalling JSON from %s\", indexFile)\n\tindexBytes, err := ioutil.ReadFile(indexFile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tbar.Add(1)\n\n\terr = json.Unmarshal(indexBytes, app)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif app.IconPath != \"\" {\n\t\tlogger.Debugf(\"Removing thumbnail, %s\", app.IconPath)\n\t\tos.Remove(app.IconPath)\n\t}\n\tbar.Add(1)\n\n\tif app.IconPathHicolor != \"\" {\n\t\tlogger.Debugf(\"Removing symlink to hicolor theme, %s\", app.IconPathHicolor)\n\t\tos.Remove(app.IconPathHicolor)\n\t}\n\tbar.Add(1)\n\n\tif app.DesktopFile != \"\" {\n\t\tlogger.Debugf(\"Removing desktop file, %s\", app.DesktopFile)\n\t\tos.Remove(app.DesktopFile)\n\t}\n\tbar.Add(1)\n\n\tbinDir := path.Join(xdg.Home, \".local\", \"bin\")\n\tbinFile := path.Join(binDir, options.Executable)\n\n\tif helpers.CheckIfFileExists(binFile) {\n\t\tbinAbsPath, err := filepath.EvalSymlinks(binFile)\n\t\tif err == nil && strings.HasPrefix(binAbsPath, config.LocalStore) {\n\t\t\t// this link points to config.LocalStore, where all AppImages are stored\n\t\t\t// I guess we need to remove them, no asking and all\n\t\t\t// make sure we remove the file first to prevent conflicts in future\n\t\t\t_ = os.Remove(binFile)\n\t\t}\n\t}\n\tbar.Add(1)\n\n\tlogger.Debugf(\"Removing appimage, %s\", app.Filepath)\n\t_ = os.Remove(app.Filepath)\n\tbar.Add(1)\n\n\tlogger.Debugf(\"Removing index file, %s\", indexFile)\n\t_ = os.Remove(indexFile)\n\tbar.Add(1)\n\n\tbar.Finish()\n\tfmt.Printf(\"\\n\")\n\tfmt.Printf(\"✅ %s removed successfully\\n\", app.Executable)\n\tlogger.Debugf(\"Removing all files completed successfully\")\n\n\treturn bar.Finish()\n}", "func triggerSuggestionRemovalAction(tconn *chrome.TestConn, resultFinder, removeButton *nodewith.Finder, tabletMode bool) uiauto.Action {\n\tui := uiauto.New(tconn)\n\n\t// To get the removal action button to show up:\n\t// in clamshel, hover the mouse over the result view;\n\t// in tablet mode, long press the result view\n\tif tabletMode {\n\t\treturn uiauto.Combine(\"activate remove button using touch\",\n\t\t\tfunc(ctx context.Context) error {\n\t\t\t\ttouchCtx, err := touch.New(ctx, tconn)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrap(err, \"Fail to get touch screen\")\n\t\t\t\t}\n\t\t\t\tdefer touchCtx.Close()\n\n\t\t\t\treturn touchCtx.LongPress(resultFinder)(ctx)\n\t\t\t},\n\t\t\tui.WaitUntilExists(removeButton),\n\t\t\tui.LeftClick(removeButton),\n\t\t\tui.WaitUntilExists(removalDialogFinder))\n\t}\n\n\treturn uiauto.Combine(\"activate remove button using mouse\",\n\t\tui.MouseMoveTo(resultFinder, 10*time.Millisecond),\n\t\tui.WaitUntilExists(removeButton),\n\t\tui.LeftClick(removeButton),\n\t\tui.WaitUntilExists(removalDialogFinder))\n}", "func (m mimeTypeFormats) Del(mimeType string) {\n\tdelete(m, mimeType)\n}", "func removeFile(n string) {\n\terr := os.Remove(n)\n\tif err != nil {\n\t\tglog.Fatal(\"CleanupFiles \", err)\n\t}\n}", "func Remove(pkgname string, p *confparse.IniParser) error {\n\ttestdb, testdir, err := getInstallConf(p)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdb, err := backends.NewBolt(path.Join(testdir, testdb))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer db.Close()\n\n\tlist, err := db.Get([]byte(pkgname))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = futils.RemoveList(testdir, strings.Split(string(list), \"\\n\"))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tdb.Del([]byte(pkgname))\n\n\treturn nil\n}", "func (store *dbStore) DeleteChoiceByID(id string) error {\r\n\r\n\tsqlStatement := fmt.Sprint(\"DELETE FROM movie where choice_id= \", id)\r\n\tfmt.Println(id)\r\n\r\n\tfmt.Println(sqlStatement)\r\n\t_, err := store.db.Query(sqlStatement)\r\n\tif err != nil {\r\n\t\tfmt.Printf(\"failed to execute delete movie query on the database: %v\", err)\r\n\t\treturn err\r\n\t}\r\n\r\n\tsqlStatement = fmt.Sprint(\"DELETE FROM restaurant where choice_id= \", id)\r\n\r\n\tfmt.Println(sqlStatement)\r\n\r\n\t_, err = store.db.Query(sqlStatement)\r\n\tif err != nil {\r\n\t\tfmt.Printf(\"failed to execute delete restaurant query on the database: %v\", err)\r\n\t\treturn err\r\n\t}\r\n\r\n\tsqlStatement = fmt.Sprint(\"DELETE FROM choice where id= \", id)\r\n\r\n\tfmt.Println(sqlStatement)\r\n\r\n\t_, err = store.db.Query(sqlStatement)\r\n\tif err != nil {\r\n\t\tfmt.Printf(\"failed to execute delete choice query on the database: %v\", err)\r\n\t\treturn err\r\n\t}\r\n\r\n\treturn nil\r\n}", "func Choice(m string, exacts []string) string {\n\tfmt.Println(colors.Blue(prefix + \" \" + m + \": \"))\n\tret := make(chan string, 1)\n\tterminate := make(chan struct{})\n\tgo cho.Run(exacts, ret, terminate)\n\tselected := \"\"\nLOOP:\n\tfor {\n\t\tselect {\n\t\tcase selected = <-ret:\n\t\t\tbreak LOOP\n\t\tcase <-terminate:\n\t\t\tbreak LOOP\n\t\t}\n\t}\n\tif selected != \"\" {\n\t\tfmt.Println(selected)\n\t}\n\treturn selected\n}", "func GuiTextBoxDelete(text string, length int, before bool) (int, string) {\n\tctext := C.CString(text)\n\tdefer C.free(unsafe.Pointer(ctext))\n\tres := C.GuiTextBoxDelete(ctext, C.int(int32(length)), C.bool(before))\n\treturn int(int32(res)), C.GoString(ctext)\n}", "func (s *SignalMonkey) Remove(fn *SignalHandler) {\n\ts.mutex.Lock()\n\tdefer s.mutex.Unlock()\n\tfor i, x := range s.handlers {\n\t\tif x.ID == fn.ID {\n\t\t\t// Delete preserving order from here:\n\t\t\t// https://code.google.com/p/go-wiki/wiki/SliceTricks\n\t\t\tcopy(s.handlers[i:], s.handlers[i+1:])\n\t\t\ts.handlers[len(s.handlers)-1] = nil // or the zero value of T\n\t\t\ts.handlers = s.handlers[:len(s.handlers)-1]\n\t\t}\n\t}\n}", "func (ptr *Application) onClickMenuFileExit() {\n\n\t// confirm whether the user intended to exit Notepad or not if they\n\t// have unsaved changes\n\tif ptr.hasUnsavedChanges {\n\t\tconfirmationDialog := dialog.MsgBuilder{\n\t\t\tDlg: dialog.Dlg{Title: \"Exit Notepad\"},\n\t\t\tMsg: \"Discard changes & exit Notepad?\",\n\t\t}\n\t\tif !confirmationDialog.YesNo() {\n\t\t\treturn\n\t\t}\n\t}\n\n\tos.Exit(0)\n}", "func ConfirmRemove(question string) {\n\t// Prompt the user to make sure he/she wants to do this\n\tfmt.Print(question + \" [y/N]: \")\n\tvar response string\n\n\treader := bufio.NewReader(os.Stdin)\n\tresponse, err := reader.ReadString('\\n')\n\tif err != nil {\n\t\tFatal(CLI_INPUT_ERROR, i18n.GetMessagePrinter().Sprintf(\"Error reading input, error %v\", err))\n\t}\n\tresponse = strings.TrimSuffix(response, \"\\n\")\n\tresponse = strings.ToLower(response)\n\n\tif strings.TrimSpace(response) != \"y\" {\n\t\ti18n.GetMessagePrinter().Printf(\"Exiting.\")\n\t\ti18n.GetMessagePrinter().Println()\n\t\tos.Exit(0)\n\t}\n}", "func (g *GitLocal) Remove(dir, fileName string) error {\n\treturn g.GitCLI.Remove(dir, fileName)\n}", "func (o *Permissao) UnsetChave() {\n\to.Chave.Unset()\n}", "func (g *Generator) RemoveSeccompSyscall(name string, action string) error {\n\tif g.spec == nil || g.spec.Linux == nil || g.spec.Linux.Seccomp == nil {\n\t\treturn nil\n\t}\n\n\tif err := checkSeccompSyscallAction(action); err != nil {\n\t\treturn err\n\t}\n\n\tvar r []rspec.Syscall\n\tfor _, syscall := range g.spec.Linux.Seccomp.Syscalls {\n\t\tif !(strings.Compare(name, syscall.Name) == 0 &&\n\t\t\tstrings.Compare(action, string(syscall.Action)) == 0) {\n\t\t\tr = append(r, syscall)\n\t\t}\n\t}\n\tg.spec.Linux.Seccomp.Syscalls = r\n\treturn nil\n}", "func (f *FileStore) Remove(paths ...string) {\n\tf.mu.Lock()\n\tdefer f.mu.Unlock()\n\tvar active []TSMFile\n\tfor _, file := range f.files {\n\t\tkeep := true\n\t\tfor _, remove := range paths {\n\t\t\tif remove == file.Path() {\n\t\t\t\tkeep = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif keep {\n\t\t\tactive = append(active, file)\n\t\t}\n\t}\n\tf.files = active\n}", "func (d *deferredConfirmations) remove(tag uint64) {\n\td.m.Lock()\n\tdefer d.m.Unlock()\n\tdc, found := d.confirmations[tag]\n\tif !found {\n\t\treturn\n\t}\n\tclose(dc.done)\n\tdelete(d.confirmations, tag)\n}", "func (c *Client) Unselect() error {\n\tif c.c.State() != imap.SelectedState {\n\t\treturn client.ErrNoMailboxSelected\n\t}\n\n\tcmd := &Command{}\n\n\tif status, err := c.c.Execute(cmd, nil); err != nil {\n\t\treturn err\n\t} else if err := status.Err(); err != nil {\n\t\treturn err\n\t}\n\n\tc.c.SetState(imap.AuthenticatedState, nil)\n\treturn nil\n}", "func (o *Cause) UnsetSuggestedAction() {\n\to.SuggestedAction.Unset()\n}", "func (s *BasejossListener) ExitPartSel(ctx *PartSelContext) {}", "func (m *ItemsMutator) ClearEnum() *ItemsMutator {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\t_ = m.proxy.enum.Clear()\n\treturn m\n}", "func imageMenuItemFinalizer(m *ImageMenuItem) {\n\truntime.SetFinalizer(m, func(m *ImageMenuItem) { gobject.Unref(m) })\n}", "func (cb *configBased) Remove(aps []AvailablePlugin, id string) (AvailablePlugin, error) {\n\tap, err := cb.Select(aps, id)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdelete(cb.metricCache, id)\n\tdelete(cb.plugins, id)\n\treturn ap, nil\n}", "func (ptr *Application) onClickMenuEditDelete() {\n\tptr.textEditor.Delete()\n}", "func (a *Autocompleter) Delete() error {\n\tconn := a.pool.Get()\n\tdefer conn.Close()\n\n\t_, err := conn.Do(\"DEL\", a.name)\n\treturn err\n}", "func RemoveSpinner(tag, text string, success bool) {\n\tif s, ok := spinners[tag]; ok {\n\t\tvar prefix string\n\t\tif success {\n\t\t\tprefix = color.GreenString(\"✔\")\n\t\t} else {\n\t\t\tprefix = color.RedString(\"𝗫\")\n\t\t}\n\n\t\ts.FinalMSG = fmt.Sprintf(\"%s %s\\n\", prefix, text)\n\t\ts.Stop()\n\t\tdelete(spinners, tag)\n\t}\n}", "func (e *Exporter) removeInstallationReference(chiName string) {\n\te.mutex.Lock()\n\tdefer e.mutex.Unlock()\n\tdelete(e.chInstallations, chiName)\n}", "func (f *Formatter) RemoveProvider(n string) {\n\tdelete(f.providers, n)\n}", "func (s *DefaultSelector) RemoveSource(name string) error {\n\ts.Lock()\n\tdefer s.Unlock()\n\n\tif _, ok := s.sources[name]; !ok {\n\t\treturn fmt.Errorf(\"unknown source %s\", name)\n\t}\n\tdelete(s.sources, name)\n\treturn nil\n}", "func (f *Formatter) Remove(r terraform.StateResource) string {\n\tp := f.getProvider(r.ProviderName)\n\tif nil == p {\n\t\treturn \"\"\n\t}\n\treturn p.Remove(r)\n}", "func (s *BasevhdlListener) ExitSelected_name_part(ctx *Selected_name_partContext) {}", "func (c *Client) Unselect() *Command {\n\tcmd := &unselectCommand{}\n\tc.beginCommand(\"UNSELECT\", cmd).end()\n\treturn &cmd.cmd\n}", "func UnVolumeDownButton(cb func()) {\n\tjs.Global.Get(\"document\").Call(\"removeEventListener\", \"volumedownbutton\", cb, false)\n}", "func Remove(pkg string, flags *types.Flags) error {\n\tfmt.Println(\"remove is not working yet...\")\n\treturn nil\n}", "func (_DappboxManager *DappboxManagerTransactor) RemoveFile(opts *bind.TransactOpts, dappboxAddress common.Address, fileNameMD5 string, fileNameSHA256 string, fileNameSHA1 string, folderAddress common.Address) (*types.Transaction, error) {\n\treturn _DappboxManager.contract.Transact(opts, \"RemoveFile\", dappboxAddress, fileNameMD5, fileNameSHA256, fileNameSHA1, folderAddress)\n}", "func (reg *registry[Item]) remove(topic string, ch chan Item, drain_channel bool) {\n\treg.lock.Lock()\n\tdefer reg.lock.Unlock()\n\tif _, ok := reg.topics[topic]; !ok {\n\t\treturn\n\t}\n\n\tif _, ok := reg.topics[topic][ch]; !ok {\n\t\treturn\n\t}\n\n\tdelete(reg.topics[topic], ch)\n\tdelete(reg.revTopics[ch], topic)\n\n\tif len(reg.topics[topic]) == 0 {\n\t\tdelete(reg.topics, topic)\n\t}\n\n\tif len(reg.revTopics[ch]) == 0 {\n\t\tif drain_channel {\n\t\t\treg.drainAndScheduleCloseChannel(ch)\n\t\t}\n\t\tdelete(reg.revTopics, ch)\n\t}\n}", "func (set StringSet) Remove(e string) {\n\tdelete(set, e)\n}", "func (s *SetOfStr) Remove(x string) {\n\ts.mux.Lock()\n\tdefer s.mux.Unlock()\n\tdelete(s.set, x)\n}", "func (tw *TimeWheel) Remove(c interface{}) {\n\ttw.mux.Lock()\n\tdefer tw.mux.Unlock()\n\tif v, ok := tw.indicator[c]; ok {\n\t\tv.remove(c)\n\t}\n}", "func (self *WorkingTreeCommands) UnStageFile(fileNames []string, reset bool) error {\n\tfor _, name := range fileNames {\n\t\tvar cmdArgs []string\n\t\tif reset {\n\t\t\tcmdArgs = NewGitCmd(\"reset\").Arg(\"HEAD\", \"--\", name).ToArgv()\n\t\t} else {\n\t\t\tcmdArgs = NewGitCmd(\"rm\").Arg(\"--cached\", \"--force\", \"--\", name).ToArgv()\n\t\t}\n\n\t\terr := self.cmd.New(cmdArgs).Run()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}", "func (f *flagTrackerImpl) RemoveFlagValueChangeListener(listener <-chan interfaces.FlagValueChangeEvent) {\n\tf.lock.Lock()\n\tflagCh, ok := f.valueChangeSubscriptions[listener]\n\tdelete(f.valueChangeSubscriptions, listener)\n\tf.lock.Unlock()\n\n\tif ok {\n\t\tf.broadcaster.RemoveListener(flagCh)\n\t}\n}", "func (c *QueuedChan) remove(cmd *queuedChanRemoveCmd) {\n\t// Get object count before remove.\n\tcount := c.List.Len()\n\t// Iterate list.\n\tfor i := c.Front(); i != nil; {\n\t\tvar re *list.Element\n\t\t// Filter object.\n\t\tok, cont := cmd.f(i.Value)\n\t\tif ok {\n\t\t\tre = i\n\t\t}\n\t\t// Next element.\n\t\ti = i.Next()\n\t\t// Remove element\n\t\tif nil != re {\n\t\t\tc.List.Remove(re)\n\t\t}\n\t\t// Continue\n\t\tif !cont {\n\t\t\tbreak\n\t\t}\n\t}\n\t// Update channel length\n\tatomic.StoreInt32(&c.len, int32(c.List.Len()))\n\t// Return removed object number.\n\tcmd.r <- count - c.List.Len()\n}", "func (m *wasiSnapshotPreview1Impl) pathRemoveDirectory(pfd wasiFd, ppath list) (err wasiErrno) {\n\tpath, err := m.loadPath(ppath)\n\tif err != wasiErrnoSuccess {\n\t\treturn err\n\t}\n\n\tdir, err := m.files.getDirectory(pfd, wasiRightsPathRemoveDirectory)\n\tif err != wasiErrnoSuccess {\n\t\treturn err\n\t}\n\n\tif ferr := dir.Rmdir(path); ferr != nil {\n\t\treturn fileErrno(ferr)\n\t}\n\treturn wasiErrnoSuccess\n}", "func (v *IconView) UnselectAll() {\n\tC.gtk_icon_view_unselect_all(v.native())\n}", "func (s StringSet) Del(x string) { delete(s, x) }", "func (b *Cowbuilder) RemoveDistribution(d deb.Codename, a deb.Architecture) error {\n\tb.acquire()\n\tdefer b.release()\n\n\timagePath, err := b.supportedDistributionPath(d, a)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Distribution %s architecture %s is not supported\", d, a)\n\t}\n\n\treturn os.RemoveAll(imagePath)\n}", "func (g *Gui) DeleteView(name string) error {\n\tfor i, v := range g.views {\n\t\tif v.name == name {\n\t\t\tg.views = append(g.views[:i], g.views[i+1:]...)\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn ErrUnknownView\n}", "func (v *TreeStore) Remove(iter *TreeIter) bool {\n\tvar ti *C.GtkTreeIter\n\tif iter != nil {\n\t\tti = iter.native()\n\t}\n\treturn 0 != C.gtk_tree_store_remove(v.native(), ti)\n}", "func (c *KeyStringValueChanger) Remove() error {\n\tif c.err != nil {\n\t\treturn c.err\n\t}\n\treturn c.node.remove()\n}", "func remove(ymlfile string, packageName string) error {\n\tappFS := afero.NewOsFs()\n\tyf, _ := afero.ReadFile(appFS, ymlfile)\n\tfi, err := os.Stat(ymlfile)\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar out []byte\n\ti := 0\n\tlines := bytes.Split(yf, []byte(\"\\n\"))\n\tfor _, line := range lines {\n\t\ti++\n\t\t// trim the line to detect the start of the list of packages\n\t\t// but do not write the trimmed string as it may cause an\n\t\t// unneeded file diff to the yml file\n\t\tsline := bytes.TrimLeft(line, \" \")\n\t\tif bytes.HasPrefix(sline, []byte(\"- \"+packageName)) {\n\t\t\tcontinue\n\t\t}\n\t\tout = append(out, line...)\n\t\tif i < len(lines) {\n\t\t\tout = append(out, []byte(\"\\n\")...)\n\t\t}\n\t}\n\terr = afero.WriteFile(appFS, ymlfile, out, fi.Mode())\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}" ]
[ "0.533146", "0.5215007", "0.5209094", "0.49791583", "0.49628338", "0.49071372", "0.48017108", "0.478262", "0.46966022", "0.4593523", "0.45922872", "0.45756906", "0.45345142", "0.451024", "0.45045552", "0.44789824", "0.4443359", "0.44415736", "0.44238982", "0.44187573", "0.4407801", "0.44", "0.43882132", "0.43829113", "0.43458688", "0.43298683", "0.4324845", "0.43083587", "0.430666", "0.4300404", "0.42872494", "0.42612848", "0.42497066", "0.4238545", "0.4234839", "0.4223826", "0.4222659", "0.4209632", "0.41951227", "0.4175401", "0.4170202", "0.41678333", "0.41546237", "0.41534513", "0.41507977", "0.41492438", "0.41439155", "0.4143675", "0.41277194", "0.4126404", "0.41247413", "0.41202512", "0.41188022", "0.41174144", "0.41129383", "0.41089833", "0.4098706", "0.40953255", "0.40948", "0.4094037", "0.40917018", "0.40844667", "0.40799814", "0.407597", "0.40759593", "0.40714693", "0.40686762", "0.40578747", "0.40536693", "0.4049965", "0.4042002", "0.4038193", "0.40361717", "0.4035757", "0.4034935", "0.4026948", "0.40182102", "0.40171975", "0.4017068", "0.40149215", "0.40140197", "0.40134957", "0.40125352", "0.4007673", "0.4006482", "0.40054506", "0.40027034", "0.40007406", "0.40004072", "0.39941707", "0.39929655", "0.39883822", "0.39861444", "0.39856735", "0.39736247", "0.39710194", "0.39603364", "0.39581096", "0.39532194", "0.39526963" ]
0.86442417
0
SetChoice is a wrapper around gtk_file_chooser_set_choice().
func (v *FileChooser) SetChoice(id, option string) { cId := C.CString(id) defer C.free(unsafe.Pointer(cId)) cOption := C.CString(option) defer C.free(unsafe.Pointer(cOption)) C.gtk_file_chooser_set_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cOption)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *FileChooser) AddChoice(id, label string, options, optionLabels []string) {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\n\tcLabel := C.CString(label)\n\tdefer C.free(unsafe.Pointer(cLabel))\n\n\tif options == nil || optionLabels == nil {\n\t\tC.gtk_file_chooser_add_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cLabel), nil, nil)\n\t\treturn\n\t}\n\n\tcOptions := C.make_strings(C.int(len(options) + 1))\n\tfor i, option := range options {\n\t\tcstr := C.CString(option)\n\t\tdefer C.free(unsafe.Pointer(cstr))\n\t\tC.set_string(cOptions, C.int(i), (*C.gchar)(cstr))\n\t}\n\tC.set_string(cOptions, C.int(len(options)), nil)\n\n\tcOptionLabels := C.make_strings(C.int(len(optionLabels) + 1))\n\tfor i, optionLabel := range optionLabels {\n\t\tcstr := C.CString(optionLabel)\n\t\tdefer C.free(unsafe.Pointer(cstr))\n\t\tC.set_string(cOptionLabels, C.int(i), (*C.gchar)(cstr))\n\t}\n\tC.set_string(cOptionLabels, C.int(len(optionLabels)), nil)\n\n\tC.gtk_file_chooser_add_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cLabel), cOptions, cOptionLabels)\n}", "func (f *FlagChoice) Set(value string) error {\n\tfor _, choice := range f.choices {\n\t\tif choice == value {\n\t\t\tf.chosen = value\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn fmt.Errorf(\"%q is not a valid choice, must be: %s\", value, f.String())\n}", "func (v *FileChooser) GetChoice(id string) string {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\tc := C.gtk_file_chooser_get_choice(v.native(), (*C.gchar)(cId))\n\treturn C.GoString(c)\n}", "func Choice(s *string, choices []string, title, id, class string, valid Validator) (jquery.JQuery, error) {\n\tj := jq(\"<select>\").AddClass(ClassPrefix + \"-choice\").AddClass(class)\n\tj.SetAttr(\"title\", title).SetAttr(\"id\", id)\n\tif *s == \"\" {\n\t\t*s = choices[0]\n\t}\n\tindex := -1\n\tfor i, c := range choices {\n\t\tif c == *s {\n\t\t\tindex = i\n\t\t}\n\t\tj.Append(jq(\"<option>\").SetAttr(\"value\", c).SetText(c))\n\t}\n\tif index == -1 {\n\t\treturn jq(), fmt.Errorf(\"Default of '%s' is not among valid choices\", *s)\n\t}\n\tj.SetData(\"prev\", index)\n\tj.SetProp(\"selectedIndex\", index)\n\tj.Call(jquery.CHANGE, func(event jquery.Event) {\n\t\tnewS := event.Target.Get(\"value\").String()\n\t\tnewIndex := event.Target.Get(\"selectedIndex\").Int()\n\t\tif valid != nil && !valid.Validate(newS) {\n\t\t\tnewIndex = int(j.Data(\"prev\").(float64))\n\t\t\tj.SetProp(\"selectedIndex\", newIndex)\n\t\t}\n\t\t*s = choices[int(newIndex)]\n\t\tj.SetData(\"prev\", newIndex)\n\t})\n\treturn j, nil\n}", "func (fv *FileView) SetSelFileAction(sel string) {\n\tfv.SelFile = sel\n\tsv := fv.FilesView()\n\tsv.SelectFieldVal(\"Name\", fv.SelFile)\n\tfv.SelectedIdx = sv.SelectedIdx\n\tsf := fv.SelField()\n\tsf.SetText(fv.SelFile)\n\tfv.WidgetSig.Emit(fv.This, int64(gi.WidgetSelected), fv.SelectedFile())\n}", "func (cv *Choice) Set(value string) error {\n\tif indexof.String(cv.AllowedValues, value) == indexof.NotFound {\n\t\treturn fmt.Errorf(\n\t\t\t\"invalid flag value: %s, must be one of %s\",\n\t\t\tvalue,\n\t\t\tstrings.Join(cv.AllowedValues, \", \"),\n\t\t)\n\t}\n\n\tcv.Choice = &value\n\treturn nil\n}", "func (v *FileChooser) RemoveChoice(id string) {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\tC.gtk_file_chooser_remove_choice(v.native(), (*C.gchar)(cId))\n}", "func Set(newChoices []string) {\n\tchoices = newChoices\n\tchoicelen = len(newChoices)\n}", "func Choice(m string, exacts []string) string {\n\tfmt.Println(colors.Blue(prefix + \" \" + m + \": \"))\n\tret := make(chan string, 1)\n\tterminate := make(chan struct{})\n\tgo cho.Run(exacts, ret, terminate)\n\tselected := \"\"\nLOOP:\n\tfor {\n\t\tselect {\n\t\tcase selected = <-ret:\n\t\t\tbreak LOOP\n\t\tcase <-terminate:\n\t\t\tbreak LOOP\n\t\t}\n\t}\n\tif selected != \"\" {\n\t\tfmt.Println(selected)\n\t}\n\treturn selected\n}", "func (p *PollAnswerVoters) SetChosen(value bool) {\n\tif value {\n\t\tp.Flags.Set(0)\n\t\tp.Chosen = true\n\t} else {\n\t\tp.Flags.Unset(0)\n\t\tp.Chosen = false\n\t}\n}", "func RenderSetChoice(resp http.ResponseWriter, req *http.Request, ext string, mode primitive.Mode, fileSeeker io.ReadSeeker) {\n\n\top := []OptStruct{\n\t\t{20, mode},\n\t\t{30, mode},\n\t\t{40, mode},\n\t\t{50, mode},\n\t}\n\topFileList, err := GenImgList(ext, fileSeeker, op...)\n\tif err != nil {\n http.Error(resp, err.Error(), http.StatusInternalServerError)\n return\n\t}\n\thtmlist := `<html>\n <body>\n {{range .}}\n <a href=\"/modify/{{.Name}}?mode={{.Mode}}&n={{.Numshapes}}\">\n <img style =\"width 30%\" src=\"/pics/{{.Name}}\">\n {{end}}\n </body>\n </html>\n `\n\ttempl := template.Must(template.New(\"\").Parse(htmlist))\n\n\ttype Opts struct {\n\t\tName string\n\t\tMode primitive.Mode\n\t\tNumshapes int\n\t}\n\tvar opts []Opts\n\tfor index, val := range opFileList {\n\t\topts = append(opts, Opts{Name: filepath.Base(val), Mode: op[index].mode, Numshapes: op[index].num})\n\t}\n\n\t// err = templ.Execute(resp, opts)\n\t// if err != nil {\n\t// \tpanic(err)\n\t// }\n checkError(templ.Execute(resp,opts))\n}", "func NewChoice() Choice {\n\treturn new(ChoiceImpl)\n}", "func (c *Combobox) SetSelected(index int) {\n\tC.uiComboboxSetSelected(c.c, C.int(index))\n}", "func (s *StringEnum) Set(arg string) error {\n\tif _, ok := s.choices[s.choiceMapper(arg)]; !ok {\n\t\tmsg := \"%w (valid choices: %v\"\n\t\tif s.caseInsensitive {\n\t\t\tmsg += \" [case insensitive]\"\n\t\t}\n\t\tmsg += \")\"\n\t\treturn fmt.Errorf(msg, ErrInvalidChoice, s.choiceNames)\n\t}\n\n\ts.val = arg\n\n\treturn nil\n}", "func NewChoice(allowedValues ...string) Choice {\n\treturn Choice{AllowedValues: allowedValues}\n}", "func (fv *FileView) FileSelectAction(idx int) {\n\tif idx < 0 {\n\t\treturn\n\t}\n\tfv.SaveSortPrefs()\n\tfi := fv.Files[idx]\n\tfv.SelectedIdx = idx\n\tfv.SelFile = fi.Name\n\tsf := fv.SelField()\n\tsf.SetText(fv.SelFile)\n\tfv.WidgetSig.Emit(fv.This, int64(gi.WidgetSelected), fv.SelectedFile())\n}", "func (s *BasevhdlListener) EnterChoice(ctx *ChoiceContext) {}", "func (f *FileDialog) SetFilter(filter storage.FileFilter) {\n\tf.filter = filter\n\tif f.dialog != nil {\n\t\tf.dialog.refreshDir(f.dialog.dir)\n\t}\n}", "func (s *SelectableAttribute) SetSelected(b bool) {\n\ts.chooser.SetEqualer(BoolEqualer{B: b})\n}", "func (c ChooserDef) SetState(state ChooserState) {\n\tc.ComponentDef.SetState(state)\n}", "func (c *Config) promptChoice(prompt string, choices []string, args ...string) (string, error) {\n\tvar defaultValue *string\n\tswitch len(args) {\n\tcase 0:\n\t\t// Do nothing.\n\tcase 1:\n\t\tif !slices.Contains(choices, args[0]) {\n\t\t\treturn \"\", fmt.Errorf(\"%s: invalid default value\", args[0])\n\t\t}\n\t\tdefaultValue = &args[0]\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"want 2 or 3 arguments, got %d\", len(args)+2)\n\t}\n\tif c.interactiveTemplateFuncs.promptDefaults && defaultValue != nil {\n\t\treturn *defaultValue, nil\n\t}\n\treturn c.readChoice(prompt, choices, defaultValue)\n}", "func (c *Client) SetVoteChoice(ctx context.Context, hash *chainhash.Hash,\n\tchoices map[string]string, tspendPolicy map[string]string, treasuryPolicy map[string]string) error {\n\n\t// Retrieve current voting preferences from VSP.\n\tstatus, err := c.status(ctx, hash)\n\tif err != nil {\n\t\tif errors.Is(err, errors.Locked) {\n\t\t\treturn err\n\t\t}\n\t\tc.log.Errorf(\"Could not check status of VSP ticket %s: %v\", hash, err)\n\t\treturn nil\n\t}\n\n\t// Check for any mismatch between the provided voting preferences and the\n\t// VSP preferences to determine if VSP needs to be updated.\n\tupdate := false\n\n\t// Check consensus vote choices.\n\tfor newAgenda, newChoice := range choices {\n\t\tvspChoice, ok := status.VoteChoices[newAgenda]\n\t\tif !ok {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t\tif vspChoice != newChoice {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Check tspend policies.\n\tfor newTSpend, newChoice := range tspendPolicy {\n\t\tvspChoice, ok := status.TSpendPolicy[newTSpend]\n\t\tif !ok {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t\tif vspChoice != newChoice {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Check treasury policies.\n\tfor newKey, newChoice := range treasuryPolicy {\n\t\tvspChoice, ok := status.TSpendPolicy[newKey]\n\t\tif !ok {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t\tif vspChoice != newChoice {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !update {\n\t\tc.log.Debugf(\"VSP already has correct vote choices for ticket %s\", hash)\n\t\treturn nil\n\t}\n\n\tc.log.Debugf(\"Updating vote choices on VSP for ticket %s\", hash)\n\terr = c.setVoteChoices(ctx, hash, choices, tspendPolicy, treasuryPolicy)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (c *Client) SetVoteChoice(ctx context.Context, hash *chainhash.Hash,\n\tchoices []wallet.AgendaChoice, tspendPolicy map[string]string, treasuryPolicy map[string]string) error {\n\n\t// Retrieve current voting preferences from VSP.\n\tstatus, err := c.status(ctx, hash)\n\tif err != nil {\n\t\tif errors.Is(err, errors.Locked) {\n\t\t\treturn err\n\t\t}\n\t\tlog.Errorf(\"Could not check status of VSP ticket %s: %v\", hash, err)\n\t\treturn nil\n\t}\n\n\t// Check for any mismatch between the provided voting preferences and the\n\t// VSP preferences to determine if VSP needs to be updated.\n\tupdate := false\n\n\t// Check consensus vote choices.\n\tfor _, newChoice := range choices {\n\t\tvspChoice, ok := status.VoteChoices[newChoice.AgendaID]\n\t\tif !ok {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t\tif vspChoice != newChoice.ChoiceID {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Apply the above changes to the two checks below.\n\n\t// Check tspend policies.\n\tfor newTSpend, newChoice := range tspendPolicy {\n\t\tvspChoice, ok := status.TSpendPolicy[newTSpend]\n\t\tif !ok {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t\tif vspChoice != newChoice {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// Check treasury policies.\n\tfor newKey, newChoice := range treasuryPolicy {\n\t\tvspChoice, ok := status.TSpendPolicy[newKey]\n\t\tif !ok {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t\tif vspChoice != newChoice {\n\t\t\tupdate = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !update {\n\t\tlog.Debugf(\"VSP already has correct vote choices for ticket %s\", hash)\n\t\treturn nil\n\t}\n\n\tlog.Debugf(\"Updating vote choices on VSP for ticket %s\", hash)\n\terr = c.setVoteChoices(ctx, hash, choices, tspendPolicy, treasuryPolicy)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (_m *Prompter) Choice(prompt string, options []string) string {\n\tret := _m.Called(prompt, options)\n\n\tvar r0 string\n\tif rf, ok := ret.Get(0).(func(string, []string) string); ok {\n\t\tr0 = rf(prompt, options)\n\t} else {\n\t\tr0 = ret.Get(0).(string)\n\t}\n\n\treturn r0\n}", "func selectFileGUI(titleA string, filterNameA string, filterTypeA string) string {\n\tfileNameT, errT := dialog.File().Filter(filterNameA, filterTypeA).Title(titleA).Load()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn fileNameT\n}", "func (fa *FileAction) SetAction(action string) error {\n\tvar ok bool\n\tswitch action {\n\tcase SelectFile, GetFileStructure, AddFile, MoveFile, DeleteFile, StreamFile:\n\t\tok = true\n\tdefault:\n\t\tok = false\n\t}\n\n\tif !ok {\n\t\treturn fmt.Errorf(\"File Action not available: %v\", action)\n\t}\n\tfa.Action = action\n\treturn nil\n}", "func (b *Builder) WriteChoice(choices []string) {\n\tfmt.Fprintf(&b.sb, \"${%d|\", b.nextTabStop())\n\tfor i, c := range choices {\n\t\tif i != 0 {\n\t\t\tb.sb.WriteByte(',')\n\t\t}\n\t\tchoiceReplacer.WriteString(&b.sb, c)\n\t}\n\tb.sb.WriteString(\"|}\")\n}", "func (o IFS) Choose() *Affine {\n\tr := rand.Intn(len(o.Choices))\n\treturn o.Choices[r]\n}", "func (s *BasevhdlListener) ExitChoice(ctx *ChoiceContext) {}", "func (r *CheckGroup) SetSelected(options []string) {\n\t//if r.Selected == options {\n\t//\treturn\n\t//}\n\n\tr.Selected = options\n\n\tif r.OnChanged != nil {\n\t\tr.OnChanged(options)\n\t}\n\n\tr.Refresh()\n}", "func (fv *FileView) FavSelect(idx int) {\n\tif idx < 0 || idx >= len(gi.Prefs.FavPaths) {\n\t\treturn\n\t}\n\tfi := gi.Prefs.FavPaths[idx]\n\tfv.DirPath, _ = homedir.Expand(fi.Path)\n\tfv.UpdateFilesAction()\n}", "func (m *ManagementTemplateStep) SetAcceptedVersion(value ManagementTemplateStepVersionable)() {\n err := m.GetBackingStore().Set(\"acceptedVersion\", value)\n if err != nil {\n panic(err)\n }\n}", "func (c *Current) SetVersion(version string) {\n\tswitch c.selectedRadio {\n\tcase FocusOnInvolved, FocusOnCurrentNamespace:\n\t\tif curr.resourceVersion < version {\n\t\t\tcurr.resourceVersion = version\n\t\t}\n\tcase FocusOnAllNamespace:\n\t\tif curr.resourceVersionAllNamespace < version {\n\t\t\tcurr.resourceVersionAllNamespace = version\n\t\t}\n\t}\n}", "func runFileChooser(win *gtk.Window) (string, error) {\n\n\tvar fn string\n\n\topenFile, err := gtk.FileChooserDialogNewWith2Buttons(\"Open file\", win, gtk.FILE_CHOOSER_ACTION_OPEN,\n\t\t\"Cancel\", gtk.RESPONSE_CANCEL,\n\t\t\"Ok\", gtk.RESPONSE_OK)\n\tdefer openFile.Destroy()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\topenFile.SetDefaultSize(50, 50)\n\n\tres := openFile.Run()\n\n\tif res == int(gtk.RESPONSE_OK) {\n\t\tfn = openFile.FileChooser.GetFilename()\n\t}\n\n\treturn fn, nil\n}", "func (cli *CliPrompter) Choose(pr string, options []string) int {\n\tselected := \"\"\n\tprompt := &survey.Select{\n\t\tMessage: pr,\n\t\tOptions: options,\n\t}\n\t_ = survey.AskOne(prompt, &selected, survey.WithValidator(survey.Required))\n\n\t// return the selected element index\n\tfor i, option := range options {\n\t\tif selected == option {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn 0\n}", "func pickFile(dir, message string) string {\n\tfileName := \"\"\n\terr := survey.AskOne(\n\t\t&survey.Select{\n\t\t\tMessage: message,\n\t\t\tOptions: readDir(dir),\n\t\t},\n\t\t&fileName,\n\t\tsurvey.WithValidator(survey.Required),\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn fileName\n}", "func (v *RadioButton) SetGroup(group *glib.SList) {\n\tC.gtk_radio_button_set_group(v.native(), cGSList(group))\n}", "func (c *Config) readChoice(prompt string, choices []string, defaultValue *string) (string, error) {\n\tswitch {\n\tcase c.noTTY:\n\t\tfullPrompt := prompt + \" (\" + strings.Join(choices, \"/\")\n\t\tif defaultValue != nil {\n\t\t\tfullPrompt += \", default \" + *defaultValue\n\t\t}\n\t\tfullPrompt += \")? \"\n\t\tabbreviations := chezmoi.UniqueAbbreviations(choices)\n\t\tfor {\n\t\t\tvalue, err := c.readLineRaw(fullPrompt)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tif value == \"\" && defaultValue != nil {\n\t\t\t\treturn *defaultValue, nil\n\t\t\t}\n\t\t\tif value, ok := abbreviations[value]; ok {\n\t\t\t\treturn value, nil\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tinitModel := chezmoibubbles.NewChoiceInputModel(prompt, choices, defaultValue)\n\t\tfinalModel, err := runCancelableModel(initModel)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn finalModel.Value(), nil\n\t}\n}", "func (fb *FlowBox) SetSelectionMode(mode SelectionMode) {\n\tC.gtk_flow_box_set_selection_mode(fb.native(), C.GtkSelectionMode(mode))\n}", "func (cycle *Cycle) Choose() {\n\tif !cycle.showing ||\n\t\tlen(cycle.items) == 0 ||\n\t\tcycle.selected < 0 ||\n\t\tcycle.selected >= len(cycle.items) {\n\n\t\treturn\n\t}\n\n\tcycle.items[cycle.selected].choose()\n\tcycle.Hide()\n}", "func (f *FilePicker) SelectFile(fileName string) uiauto.Action {\n\treturn f.filesApp.SelectFile(fileName)\n}", "func NewFlagChoice(choices []string, chosen string) *FlagChoice {\n\treturn &FlagChoice{\n\t\tchoices: choices,\n\t\tchosen: chosen,\n\t}\n}", "func (s *BasevhdlListener) EnterChoices(ctx *ChoicesContext) {}", "func (file *File) Select() {\n\tfile.mark = file.location\n}", "func (o *MicrosoftGraphChoiceColumn) SetChoices(v []string) {\n\to.Choices = &v\n}", "func (r *GetSpecType) SetConfigMethodChoiceToGlobalSpecType(o *GlobalSpecType) error {\n\tswitch of := r.ConfigMethodChoice.(type) {\n\tcase nil:\n\t\to.ConfigMethodChoice = nil\n\n\tcase *GetSpecType_PspSpec:\n\t\to.ConfigMethodChoice = &GlobalSpecType_PspSpec{PspSpec: of.PspSpec}\n\n\tcase *GetSpecType_Yaml:\n\t\to.ConfigMethodChoice = &GlobalSpecType_Yaml{Yaml: of.Yaml}\n\n\tdefault:\n\t\treturn fmt.Errorf(\"Unknown oneof field %T\", of)\n\t}\n\treturn nil\n}", "func Choose(pr string, options []string) int {\n\treturn defaultPrompter.Choose(pr, options)\n}", "func (cli *CLI) Choose() (string, error) {\n\tcolorstring.Fprintf(cli.errStream, chooseText)\n\n\tnum, err := cli.AskNumber(4, 1)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// If user selects 3, should ask user GPL V2 or V3\n\tif num == 3 {\n\t\tvar buf bytes.Buffer\n\t\tbuf.WriteString(\"\\n\")\n\t\tbuf.WriteString(\"Which version do you want?\\n\")\n\t\tbuf.WriteString(\" 1) V2\\n\")\n\t\tbuf.WriteString(\" 2) V3\\n\")\n\t\tfmt.Fprintf(cli.errStream, buf.String())\n\n\t\tnum, err = cli.AskNumber(2, 1)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tnum += 4\n\t}\n\n\tvar key string\n\tswitch num {\n\tcase 1:\n\t\tkey = \"mit\"\n\tcase 2:\n\t\tkey = \"apache-2.0\"\n\tcase 4:\n\t\tkey = \"\"\n\tcase 5:\n\t\tkey = \"gpl-2.0\"\n\tcase 6:\n\t\tkey = \"gpl-3.0\"\n\tdefault:\n\t\t// Should not reach here\n\t\tpanic(\"Invalid number\")\n\t}\n\n\treturn key, nil\n}", "func (w *TextWidget) SetPrompt(g *gocui.Gui, prefix, content string, callback func(bool, string)) error {\n\tif w.view == nil {\n\t\treturn nil\n\t}\n\n\tgx := New(g)\n\n\toldfocus := g.CurrentView()\n\tg.Cursor = true\n\tgx.Focus(w.view)\n\n\tw.SetText(prefix)\n\tfmt.Fprintf(w.view, content)\n\n\teditor := PromptEditor(g, len(prefix), func(success bool, response string) {\n\t\tw.setEditor(nil)\n\t\tgx.Focus(oldfocus)\n\t\tg.Cursor = false\n\t\tcallback(success, response)\n\t})\n\n\tw.setEditor(editor)\n\n\treturn w.view.SetCursor(len(prefix)+len(content), 0)\n}", "func pickChapter(g *gocui.Gui, v *gocui.View) error {\n\tif err := openModal(g); err != nil {\n\t\treturn err\n\t}\n\n\tdone := make(chan bool)\n\ttimer := time.NewTimer(time.Second * time.Duration(downloadTimeoutSecond))\n\n\t// must run downloading process in\n\t// go routine or else the it will\n\t// block the openModal so loading modal\n\t// will not be shown to the user\n\tgo func() {\n\t\ts := trimViewLine(v)\n\t\tprepDownloadChapter(s)\n\t\tdone <- true\n\t}()\n\n\t// in case downloading takes longer than\n\t// downloadTimeoutSecond, close the modal\n\t// and continue to download in background\n\tgo func() {\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\tsetClosingMessage(g, \"continuing to download\\nin background...\")\n\t\t\treturn\n\t\tcase <-done:\n\t\t\tg.Update(func(g *gocui.Gui) error {\n\t\t\t\terr := closeModal(g)\n\t\t\t\treturn err\n\t\t\t})\n\t\t}\n\t}()\n\n\treturn nil\n}", "func (r *ReplaceSpecType) SetConfigMethodChoiceToGlobalSpecType(o *GlobalSpecType) error {\n\tswitch of := r.ConfigMethodChoice.(type) {\n\tcase nil:\n\t\to.ConfigMethodChoice = nil\n\n\tcase *ReplaceSpecType_PspSpec:\n\t\to.ConfigMethodChoice = &GlobalSpecType_PspSpec{PspSpec: of.PspSpec}\n\n\tcase *ReplaceSpecType_Yaml:\n\t\to.ConfigMethodChoice = &GlobalSpecType_Yaml{Yaml: of.Yaml}\n\n\tdefault:\n\t\treturn fmt.Errorf(\"Unknown oneof field %T\", of)\n\t}\n\treturn nil\n}", "func SetOption(pkg, name string, fn func(r Runtime) values.Value) ScopeMutator {\n\treturn func(r Runtime, scope values.Scope) {\n\t\tv := fn(r)\n\t\tp, ok := scope.Lookup(pkg)\n\t\tif ok {\n\t\t\tif p, ok := p.(values.Package); ok {\n\t\t\t\tvalues.SetOption(p, name, v)\n\t\t\t}\n\t\t} else if r.IsPreludePackage(pkg) {\n\t\t\topt, ok := scope.Lookup(name)\n\t\t\tif ok {\n\t\t\t\tif opt, ok := opt.(*values.Option); ok {\n\t\t\t\t\topt.Value = v\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}", "func (r *CreateSpecType) SetConfigMethodChoiceToGlobalSpecType(o *GlobalSpecType) error {\n\tswitch of := r.ConfigMethodChoice.(type) {\n\tcase nil:\n\t\to.ConfigMethodChoice = nil\n\n\tcase *CreateSpecType_PspSpec:\n\t\to.ConfigMethodChoice = &GlobalSpecType_PspSpec{PspSpec: of.PspSpec}\n\n\tcase *CreateSpecType_Yaml:\n\t\to.ConfigMethodChoice = &GlobalSpecType_Yaml{Yaml: of.Yaml}\n\n\tdefault:\n\t\treturn fmt.Errorf(\"Unknown oneof field %T\", of)\n\t}\n\treturn nil\n}", "func choice(a string) string {\n\tif strings.EqualFold(a, \"r\") {\n\t\treturn \"Rock\"\n\t} else if strings.EqualFold(a, \"p\") {\n\t\treturn \"Paper\"\n\t} else if strings.EqualFold(a, \"s\") {\n\t\treturn \"Scissor\"\n\t} else {\n\t\treturn \"UNKNOWN\"\n\t}\n}", "func (f *FileDialog) SetOnClosed(closed func()) {\n\tif f.dialog == nil {\n\t\treturn\n\t}\n\t// If there is already a callback set, remember it and call both.\n\toriginalCallback := f.onClosedCallback\n\n\tf.onClosedCallback = func(response bool) {\n\t\tclosed()\n\t\tif originalCallback != nil {\n\t\t\toriginalCallback(response)\n\t\t}\n\t}\n}", "func (fv *FileView) SetPathFile(path, file, ext string) {\n\tfv.DirPath = path\n\tfv.SelFile = file\n\tfv.SetExt(ext)\n\tfv.UpdateFromPath()\n}", "func (m *Model) Choice() (*Choice, error) {\n\tif m.Err != nil {\n\t\treturn nil, m.Err\n\t}\n\n\tif len(m.currentChoices) == 0 {\n\t\treturn nil, fmt.Errorf(\"no choices\")\n\t}\n\n\tif m.currentIdx < 0 || m.currentIdx >= len(m.currentChoices) {\n\t\treturn nil, fmt.Errorf(\"choice index out of bounds\")\n\t}\n\n\treturn m.currentChoices[m.currentIdx], nil\n}", "func ChoiceIndex(title string, choices []string, def int) int {\n\treturn ChoiceIndexCallback(title, choices, def, nil)\n}", "func (g Gnome2Setter) Set(filename string) error {\n\tpath, err := filepath.Abs(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn setWithCommand(\n\t\t\"gconftool-2\",\n\t\t\"--type=string\",\n\t\t\"--set\",\n\t\t\"/desktop/gnome/background/picture_filename\",\n\t\tpath,\n\t)\n}", "func ChoiceIndexCallback(title string, choices []string, def int, f func(int, int, int)) int {\n\tselection := def\n\tnc := len(choices) - 1\n\tif selection < 0 || selection > nc {\n\t\tselection = 0\n\t}\n\toffset := 0\n\tcx := 0\n\tfor {\n\t\tsx, sy := termbox.Size()\n\t\ttermbox.HideCursor()\n\t\ttermbox.Clear(termbox.ColorDefault, termbox.ColorDefault)\n\t\tPrintstring(title, 0, 0)\n\t\tfor selection < offset {\n\t\t\toffset -= 5\n\t\t\tif offset < 0 {\n\t\t\t\toffset = 0\n\t\t\t}\n\t\t}\n\t\tfor selection-offset >= sy-1 {\n\t\t\toffset += 5\n\t\t\tif offset >= nc {\n\t\t\t\toffset = nc\n\t\t\t}\n\t\t}\n\t\tfor i, s := range choices[offset:] {\n\t\t\tts, _ := trimString(s, cx)\n\t\t\tPrintstring(ts, 3, i+1)\n\t\t\tif cx > 0 {\n\t\t\t\tPrintstring(\"←\", 2, i+1)\n\t\t\t}\n\t\t}\n\t\tPrintstring(\">\", 1, (selection+1)-offset)\n\t\tif f != nil {\n\t\t\tf(selection, sx, sy)\n\t\t}\n\t\ttermbox.Flush()\n\t\tev := termbox.PollEvent()\n\t\tif ev.Type != termbox.EventKey {\n\t\t\tcontinue\n\t\t}\n\t\tkey := ParseTermboxEvent(ev)\n\t\tswitch key {\n\t\tcase \"C-v\":\n\t\t\tfallthrough\n\t\tcase \"next\":\n\t\t\tselection += sy - 5\n\t\t\tif selection >= len(choices) {\n\t\t\t\tselection = len(choices) - 1\n\t\t\t}\n\t\tcase \"M-v\":\n\t\t\tfallthrough\n\t\tcase \"prior\":\n\t\t\tselection -= sy - 5\n\t\t\tif selection < 0 {\n\t\t\t\tselection = 0\n\t\t\t}\n\t\tcase \"C-c\":\n\t\t\tfallthrough\n\t\tcase \"C-g\":\n\t\t\treturn def\n\t\tcase \"UP\", \"C-p\":\n\t\t\tif selection > 0 {\n\t\t\t\tselection--\n\t\t\t}\n\t\tcase \"DOWN\", \"C-n\":\n\t\t\tif selection < len(choices)-1 {\n\t\t\t\tselection++\n\t\t\t}\n\t\tcase \"LEFT\", \"C-b\":\n\t\t\tif cx > 0 {\n\t\t\t\tcx--\n\t\t\t}\n\t\tcase \"RIGHT\", \"C-f\":\n\t\t\tcx++\n\t\tcase \"C-a\", \"Home\":\n\t\t\tcx = 0\n\t\tcase \"M-<\":\n\t\t\tselection = 0\n\t\tcase \"M->\":\n\t\t\tselection = len(choices) - 1\n\t\tcase \"RET\":\n\t\t\treturn selection\n\t\t}\n\t}\n}", "func GuiTextBoxSetSelection(start int, length int) {\n\tC.GuiTextBoxSetSelection(C.int(int32(start)), C.int(int32(length)))\n}", "func (m *Menu) SetSelected(i int) {\n\tm.selected = i\n}", "func (q *Question) ReadChoice(prompt string, a []string) (answer string, err error) {\n\treturn q._baseReadChoice(prompt, a, 0)\n}", "func redrawChoices() {\n\tfor ii := 0; ii < minInt(len(choices)-viewTopIndex, viewHeight); ii++ {\n\t\tredrawChoice(viewTopRow+ii, viewTopIndex+ii, false, isSelected[viewTopIndex+ii])\n\t}\n\tredrawChoice(cursorRow, cursorIndex, true, isSelected[cursorIndex])\n}", "func (fv *FileView) SetExt(ext string) {\n\tif ext == \"\" {\n\t\tif fv.SelFile != \"\" {\n\t\t\text = strings.ToLower(filepath.Ext(fv.SelFile))\n\t\t}\n\t}\n\tfv.Ext = ext\n\texts := strings.Split(fv.Ext, \",\")\n\tfv.ExtMap = make(map[string]string, len(exts))\n\tfor _, ex := range exts {\n\t\tex = strings.TrimSpace(ex)\n\t\tif len(ex) == 0 {\n\t\t\tcontinue\n\t\t}\n\t\tif ex[0] != '.' {\n\t\t\tex = \".\" + ex\n\t\t}\n\t\tfv.ExtMap[strings.ToLower(ex)] = ex\n\t}\n}", "func (s *BasevhdlListener) ExitChoices(ctx *ChoicesContext) {}", "func (e Enum) setValue(v any, key string) error {\n\ti, err := e.GetValue(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvValue := reflect.ValueOf(v).Elem()\n\tif !vValue.CanSet() {\n\t\tpanic(fmt.Errorf(\"flagenum: Cannot set supplied value, %v\", vValue))\n\t}\n\n\tiValue := reflect.ValueOf(i)\n\tif !vValue.Type().AssignableTo(iValue.Type()) {\n\t\tpanic(fmt.Errorf(\"flagenum: Enumeration type (%v) is incompatible with supplied value (%v)\",\n\t\t\tvValue.Type(), iValue.Type()))\n\t}\n\n\tvValue.Set(iValue)\n\treturn nil\n}", "func numberPicker(theme gxui.Theme, overlay gxui.BubbleOverlay) gxui.Control {\n\tvar fm FileManager\n\tfm.Init()\n\tfm.SetPath(fm.RootPath)\n\n\tadapter := gxui.CreateDefaultAdapter()\n\tadapter.SetItems(fm.GetList())\n\n\tlayout := theme.CreateLinearLayout()\n\tlayout.SetDirection(gxui.TopToBottom)\n\n\tlayoutControl := theme.CreateLinearLayout()\n layoutControl.SetDirection(gxui.LeftToRight)\n\tlabelPath := theme.CreateLabel()\n\tlabelPath.SetText(\"Set root path: \")\n\tlayoutControl.AddChild(labelPath)\n\n\tinputPath := theme.CreateTextBox()\n\tlayoutControl.AddChild(inputPath)\n\n\tbtn := GetButton(\"OK\", theme)\n\tbtn.OnClick(func(gxui.MouseEvent) {\n\t\t_path := inputPath.Text()\n\t\tif fm.IsDir(_path) {\n\t\t\tfm.RootPath = _path\n\t\t\tfm.SetPath(fm.RootPath)\n\t\t\tadapter.SetItems(fm.GetList())\n\t\t}\n\t})\n\tlayoutControl.AddChild(btn)\n\n\tlayout.AddChild(layoutControl)\n\n\n\tlist := theme.CreateList()\n\tlist.SetAdapter(adapter)\n\tlist.SetOrientation(gxui.Vertical)\n\tlayout.AddChild(list)\n\n\tlayoutControlOpen := theme.CreateLinearLayout()\n layoutControlOpen.SetDirection(gxui.LeftToRight)\n\tlabelOpen := theme.CreateLabel()\n\tlabelOpen.SetText(\"Open: \")\n\tlayoutControlOpen.AddChild(labelOpen)\n\n\tbtnOpen := GetButton(\"OK\", theme)\n\tbtnOpen.OnClick(func(gxui.MouseEvent) {\n\t\t\n\t})\n\tlayoutControlOpen.AddChild(btnOpen)\n\n\tlayout.AddChild(layoutControlOpen)\n\n\tlist.OnItemClicked(func(ev gxui.MouseEvent, item gxui.AdapterItem) {\n\t\t//if dropList.Selected() != item {\n\t\t//\tdropList.Select(item)\n\t\t//}\n\t\tif ev.Button == gxui.MouseButtonRight {\n\t\t\tfm.Go(item.(string))\n\t\t\tadapter.SetItems(fm.GetList())\n\t\t\t\n\t\t}\n\t\t\n\t\t//selected.SetText(fmt.Sprintf(\"%s - %d\", item, adapter.ItemIndex(item)))\n\t})\n\n\treturn layout\n}", "func (q *Question) _baseReadChoice(prompt string, a []string, defaultAnswer uint) (answer string, err error) {\n\t// Saves the value without ANSI to get it when it's set the answer by default.\n\tdef := a[defaultAnswer]\n\ta[defaultAnswer] = setBold + def + setOff\n\n\tline := q.getLine(prompt, strings.Join(a, \",\"), _DEFAULT_MULTIPLE)\n\n\tfor {\n\t\tanswer, err = line.Read()\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif answer == \"\" {\n\t\t\treturn def, nil\n\t\t}\n\n\t\tfor _, v := range a {\n\t\t\tif answer == v {\n\t\t\t\treturn answer, nil\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func ChooseWithDefault(pr string, defaultValue string, options []string) (string, error) {\n\treturn defaultPrompter.ChooseWithDefault(pr, defaultValue, options)\n}", "func selectFileToSaveGUI(titleA string, filterNameA string, filterTypeA string) string {\n\tfileNameT, errT := dialog.File().Filter(filterNameA, filterTypeA).Title(titleA).Save()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn fileNameT\n}", "func (fOpenCfg *FileOpenConfig) SetFileOpenType(fOpenType FileOpenType) error {\n\n ePrefix := \"FileOpenConfig.SetFileOpenType() \"\n\n err := fOpenType.IsValid()\n\n if err != nil {\n return fmt.Errorf(ePrefix+\"Input parameter 'fOpenType' is INVALID! fOpenType='%v' \",\n fOpenType.Value())\n }\n\n if fOpenCfg.fileOpenModes == nil {\n fOpenCfg.fileOpenModes = make([]FileOpenMode, 0)\n }\n\n if fOpenType == FileOpenType(0).TypeNone() {\n fOpenCfg.fileOpenModes = make([]FileOpenMode, 1)\n fOpenCfg.fileOpenModes[0] = FOpenMode.ModeNone()\n }\n\n fOpenCfg.fileOpenType = fOpenType\n\n fOpenCfg.isInitialized = true\n\n return nil\n}", "func (m *AgreementAcceptance) SetState(value *AgreementAcceptanceState)() {\n m.state = value\n}", "func (v *Button) SetImage(image IWidget) {\n\tC.gtk_button_set_image(v.native(), image.toWidget())\n}", "func (v *TreeStore) SetValue(iter *TreeIter, column int, value interface{}) error {\n\tswitch value.(type) {\n\tcase *gdk.Pixbuf:\n\t\tpix := value.(*gdk.Pixbuf)\n\t\tC._gtk_tree_store_set(v.native(), iter.native(), C.gint(column), unsafe.Pointer(pix.Native()))\n\n\tdefault:\n\t\tgv := glib.GValue(value)\n\n\t\tC.gtk_tree_store_set_value(v.native(), iter.native(),\n\t\t\tC.gint(column),\n\t\t\t(*C.GValue)(C.gpointer(gv.Native())))\n\t}\n\treturn nil\n}", "func selectDirectoryGUI(titleA string) string {\n\tdirectoryT, errT := dialog.Directory().Title(titleA).Browse()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn directoryT\n}", "func RenderInitialChoices(resp http.ResponseWriter, req *http.Request, ext string, fileSeeker io.ReadSeeker) {\n\top := []OptStruct{\n\t\t{22, primitive.TriangleMode},\n\t\t{22, primitive.CircleMode},\n\t\t{22, primitive.ComboMode},\n\t\t{22, primitive.PolygonMode},\n\t}\n\topFileList, err := GenImgList(ext, fileSeeker, op...)\n\tif err != nil {\n http.Error(resp, err.Error(), http.StatusInternalServerError)\n return\n\t}\n\thtmlist := `<html>\n <body>\n {{range .}}\n <a href=\"/modify/{{.Name}}?mode={{.Mode}}\">\n <img style =\"width 30%\" src=\"/pics/{{.Name}}\">\n {{end}}\n </body>\n </html>\n `\n\ttempl := template.Must(template.New(\"\").Parse(htmlist))\n \ntype Opts struct {\n Name string\n Mode primitive.Mode\n}\n\tvar opts []Opts\n\tfor index, val := range opFileList {\n\t\topts = append(opts, Opts{Name: filepath.Base(val), Mode: op[index].mode})\n\t}\n\n\t// err = templ.Execute(resp, opts)\n\t// if err != nil {\n\t// \tpanic(err)\n // }\n checkError(templ.Execute(resp, opts))\n \n\n}", "func (v *LinkButton) SetUri(uri string) {\n\tcstr := C.CString(uri)\n\tC.gtk_link_button_set_uri(v.native(), (*C.gchar)(cstr))\n}", "func (*XMLDocument) SetOnselectionchange(onselectionchange func(window.Event)) {\n\tmacro.Rewrite(\"$_.onselectionchange = $1\", onselectionchange)\n}", "func (in *Choice) DeepCopy() *Choice {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(Choice)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "func SetOption(args []string) {\n\topt := args[0]\n\tif len(args) < 2 {\n\t\t// clear value\n\t\tOptions[opt].Val = \"\"\n\t\treturn\n\t}\n\n\tval := args[1:] // in case val contains spaces\n\n\tif _, exist := Options[opt]; !exist {\n\t\tCliPrintError(\"No such option: %s\", strconv.Quote(opt))\n\t\treturn\n\t}\n\n\t// set\n\tOptions[opt].Val = strings.Join(val, \" \")\n}", "func (li *List) setSelection(litem *ListItem, state bool, force bool, dispatch bool) {\n\n\tManager().SetKeyFocus(li)\n\t// If already at this state, nothing to do\n\tif litem.selected == state && !force {\n\t\treturn\n\t}\n\tlitem.SetSelected(state)\n\n\t// If single selection, deselects all other items\n\tif li.single {\n\t\tfor _, curr := range li.items {\n\t\t\tif curr.(*ListItem) != litem {\n\t\t\t\tcurr.(*ListItem).SetSelected(false)\n\t\t\t\tcurr.(*ListItem).SetHighlighted(false)\n\t\t\t}\n\t\t}\n\t}\n\tli.update()\n\tif dispatch {\n\t\tli.Dispatch(OnChange, nil)\n\t}\n}", "func (v *Clipboard) SetText(text string) {\n\tcstr := C.CString(text)\n\tdefer C.free(unsafe.Pointer(cstr))\n\tC.gtk_clipboard_set_text(v.native(), (*C.gchar)(cstr),\n\t\tC.gint(len(text)))\n}", "func (s *SelectableAttribute) Chooser() BooleanAttribute {\n\treturn s.chooser\n}", "func (c *ChoiceImpl) AskUser() {\n\tchoice := \"\"\n\tfor !c.choiceIsValid(choice) {\n\t\tfmt.Println(\"----- Available options:\")\n\t\tc.displayActions()\n\t\tfmt.Println(\"----- Your choice:\")\n\t\tchoice = c.getUsersChoice()\n\t}\n\ta := c.getActionByName(choice)\n\ta.execute()\n}", "func (cli *CliPrompter) ChooseWithDefault(pr string, defaultValue string, options []string) (string, error) {\n\tselected := \"\"\n\tprompt := &survey.Select{\n\t\tMessage: pr,\n\t\tOptions: options,\n\t\tDefault: defaultValue,\n\t}\n\t_ = survey.AskOne(prompt, &selected, survey.WithValidator(survey.Required))\n\n\t// return the selected element index\n\tfor i, option := range options {\n\t\tif selected == option {\n\t\t\treturn options[i], nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"bad input\")\n}", "func (me *TViewBoxSpecType) Set(s string) { (*xsdt.String)(me).Set(s) }", "func (c *Checkbox) SetText(text string) {\n\tctext := C.CString(text)\n\tC.uiCheckboxSetText(c.c, ctext)\n\tfreestr(ctext)\n}", "func (fv *FileView) SetExtAction(ext string) {\n\tfv.SetExt(ext)\n\tfv.SetFullReRender()\n\tfv.UpdateFiles()\n}", "func (recv *Value) SetEnum(vEnum int32) {\n\tc_v_enum := (C.gint)(vEnum)\n\n\tC.g_value_set_enum((*C.GValue)(recv.native), c_v_enum)\n\n\treturn\n}", "func SetProductFile(filePath string) int {\n\tcFilePath := goToCString(filePath)\n\tstatus := C.SetProductFile(cFilePath)\n\tfreeCString(cFilePath)\n\treturn int(status)\n}", "func (litem *ListItem) SetSelected(state bool) {\n\n\tlitem.selected = state\n\t//litem.item.SetSelected2(state)\n}", "func (mb *MenuButton) SetCallBack(callback Callback) {\n\tmb.callback = callback\n}", "func (cv Choice) WithDefault(value string) Choice {\n\tcv.Set(value)\n\treturn cv\n}", "func (g Gnome3Setter) Set(filename string) error {\n\tpath, err := filepath.Abs(filename)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn setWithCommand(\n\t\t\"gsettings\",\n\t\t\"set\",\n\t\t\"org.gnome.desktop.background\",\n\t\t\"picture-uri\",\n\t\tfmt.Sprintf(\"file://%s\", path),\n\t)\n}", "func askSelect(message string, options []string, response interface{}) error {\n\treturn survey.AskOne(&survey.Select{\n\t\tMessage: message,\n\t\tOptions: options,\n\t}, response, nil)\n}", "func (b *Button) SetImage(t int, handle uintptr) uintptr {\n\treturn b.SendMessage(win.BM_SETIMAGE, uintptr(t), handle)\n}", "func RequestChoiceIfEmpty(defaultValue string, message string, options ...string) string {\n\tif defaultValue != \"\" {\n\t\treturn defaultValue\n\t}\n\treturn RequestChoice(message, options...)\n}", "func (*AnswerChoice) Descriptor() ([]byte, []int) {\n\treturn file_quiz_proto_rawDescGZIP(), []int{4}\n}", "func (vl *VerbLevel) Set(value string) error {\n\t// int: level value.\n\tif iv, err := strconv.Atoi(value); err == nil {\n\t\tif iv > VerbCrazy.Int() {\n\t\t\t*vl = VerbCrazy\n\t\t} else if iv < 0 { // fallback to default level.\n\t\t\t*vl = DefaultVerb\n\t\t} else { // 0 - 5\n\t\t\t*vl = VerbLevel(iv)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\t// string: level name.\n\t*vl = name2verbLevel(value)\n\treturn nil\n}" ]
[ "0.6469274", "0.6148542", "0.6068018", "0.5769264", "0.57536185", "0.56970453", "0.5626628", "0.55424106", "0.51889265", "0.51361847", "0.51076907", "0.5051737", "0.49173164", "0.4893991", "0.4842663", "0.4834679", "0.47279584", "0.46964598", "0.4682138", "0.4653016", "0.46258134", "0.462052", "0.4602431", "0.45895332", "0.4534642", "0.4505106", "0.44543216", "0.43771532", "0.43590632", "0.43416277", "0.43371588", "0.43278313", "0.4309242", "0.4290017", "0.42887387", "0.4286901", "0.42664492", "0.42636845", "0.4249235", "0.4243678", "0.42225006", "0.42170876", "0.42160907", "0.42024148", "0.41776416", "0.41622543", "0.41368714", "0.41313824", "0.41277272", "0.4116558", "0.41154155", "0.4113371", "0.40717593", "0.40703687", "0.406281", "0.40570998", "0.4057087", "0.40470117", "0.40166095", "0.39989513", "0.39983928", "0.39799154", "0.39794537", "0.39691097", "0.39661646", "0.39280325", "0.39257145", "0.39238438", "0.39235204", "0.39048767", "0.3900801", "0.38926756", "0.38912123", "0.38902116", "0.38806397", "0.3874835", "0.38695574", "0.3868022", "0.38585916", "0.3858135", "0.3857689", "0.38565594", "0.38532498", "0.38497514", "0.3844678", "0.38396856", "0.3822141", "0.38210532", "0.38164884", "0.3809083", "0.38065025", "0.38060278", "0.38049033", "0.37979615", "0.37902114", "0.37863722", "0.3782258", "0.3772145", "0.37706608", "0.37671852" ]
0.86250484
0
GetChoice is a wrapper around gtk_file_chooser_get_choice().
func (v *FileChooser) GetChoice(id string) string { cId := C.CString(id) defer C.free(unsafe.Pointer(cId)) c := C.gtk_file_chooser_get_choice(v.native(), (*C.gchar)(cId)) return C.GoString(c) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *FileChooser) SetChoice(id, option string) {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\tcOption := C.CString(option)\n\tdefer C.free(unsafe.Pointer(cOption))\n\tC.gtk_file_chooser_set_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cOption))\n}", "func Choice(m string, exacts []string) string {\n\tfmt.Println(colors.Blue(prefix + \" \" + m + \": \"))\n\tret := make(chan string, 1)\n\tterminate := make(chan struct{})\n\tgo cho.Run(exacts, ret, terminate)\n\tselected := \"\"\nLOOP:\n\tfor {\n\t\tselect {\n\t\tcase selected = <-ret:\n\t\t\tbreak LOOP\n\t\tcase <-terminate:\n\t\t\tbreak LOOP\n\t\t}\n\t}\n\tif selected != \"\" {\n\t\tfmt.Println(selected)\n\t}\n\treturn selected\n}", "func (c *Config) readChoice(prompt string, choices []string, defaultValue *string) (string, error) {\n\tswitch {\n\tcase c.noTTY:\n\t\tfullPrompt := prompt + \" (\" + strings.Join(choices, \"/\")\n\t\tif defaultValue != nil {\n\t\t\tfullPrompt += \", default \" + *defaultValue\n\t\t}\n\t\tfullPrompt += \")? \"\n\t\tabbreviations := chezmoi.UniqueAbbreviations(choices)\n\t\tfor {\n\t\t\tvalue, err := c.readLineRaw(fullPrompt)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t\tif value == \"\" && defaultValue != nil {\n\t\t\t\treturn *defaultValue, nil\n\t\t\t}\n\t\t\tif value, ok := abbreviations[value]; ok {\n\t\t\t\treturn value, nil\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tinitModel := chezmoibubbles.NewChoiceInputModel(prompt, choices, defaultValue)\n\t\tfinalModel, err := runCancelableModel(initModel)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\treturn finalModel.Value(), nil\n\t}\n}", "func (v *FileChooser) AddChoice(id, label string, options, optionLabels []string) {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\n\tcLabel := C.CString(label)\n\tdefer C.free(unsafe.Pointer(cLabel))\n\n\tif options == nil || optionLabels == nil {\n\t\tC.gtk_file_chooser_add_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cLabel), nil, nil)\n\t\treturn\n\t}\n\n\tcOptions := C.make_strings(C.int(len(options) + 1))\n\tfor i, option := range options {\n\t\tcstr := C.CString(option)\n\t\tdefer C.free(unsafe.Pointer(cstr))\n\t\tC.set_string(cOptions, C.int(i), (*C.gchar)(cstr))\n\t}\n\tC.set_string(cOptions, C.int(len(options)), nil)\n\n\tcOptionLabels := C.make_strings(C.int(len(optionLabels) + 1))\n\tfor i, optionLabel := range optionLabels {\n\t\tcstr := C.CString(optionLabel)\n\t\tdefer C.free(unsafe.Pointer(cstr))\n\t\tC.set_string(cOptionLabels, C.int(i), (*C.gchar)(cstr))\n\t}\n\tC.set_string(cOptionLabels, C.int(len(optionLabels)), nil)\n\n\tC.gtk_file_chooser_add_choice(v.native(), (*C.gchar)(cId), (*C.gchar)(cLabel), cOptions, cOptionLabels)\n}", "func getChoice(request events.APIGatewayProxyRequest, span opentracing.Span) (choice string) {\n\t_, winOk := request.QueryStringParameters[\"win\"]\n\tif winOk {\n\t\tspan.SetTag(\"WinFlag\", true)\n\t\treturn \"win\"\n\t} else {\n\t\tspan.SetTag(\"WinFlag\", false)\n\t}\n\tchoiceQP, qpOk := request.QueryStringParameters[\"choice\"]\n\tif !qpOk {\n\t\tspan.LogKV(\"event\", \"No choice query parameter provided.\")\n\t} else {\n\t\tspan.SetTag(\"choiceQueryParameter\", choiceQP)\n\t}\n\t_, validChoice := choiceToNum[choiceQP]\n\tif !validChoice {\n\t\trandomChoice := numToChoice[getRandomNumber()]\n\t\tinvalid := fmt.Sprintf(\"Invalid choice query parameter \\\"%s\\\". Using %s selected at random.\",\n\t\t\tchoiceQP, randomChoice)\n\t\tspan.LogKV(\"event\", invalid)\n\t\tspan.SetTag(\"randomChoice\", randomChoice)\n\t\tchoice = randomChoice\n\t} else {\n\t\tchoice = choiceQP\n\t}\n\treturn choice\n}", "func selectFileGUI(titleA string, filterNameA string, filterTypeA string) string {\n\tfileNameT, errT := dialog.File().Filter(filterNameA, filterTypeA).Title(titleA).Load()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn fileNameT\n}", "func runFileChooser(win *gtk.Window) (string, error) {\n\n\tvar fn string\n\n\topenFile, err := gtk.FileChooserDialogNewWith2Buttons(\"Open file\", win, gtk.FILE_CHOOSER_ACTION_OPEN,\n\t\t\"Cancel\", gtk.RESPONSE_CANCEL,\n\t\t\"Ok\", gtk.RESPONSE_OK)\n\tdefer openFile.Destroy()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\topenFile.SetDefaultSize(50, 50)\n\n\tres := openFile.Run()\n\n\tif res == int(gtk.RESPONSE_OK) {\n\t\tfn = openFile.FileChooser.GetFilename()\n\t}\n\n\treturn fn, nil\n}", "func (v *FileChooser) RemoveChoice(id string) {\n\tcId := C.CString(id)\n\tdefer C.free(unsafe.Pointer(cId))\n\tC.gtk_file_chooser_remove_choice(v.native(), (*C.gchar)(cId))\n}", "func (m *Model) Choice() (*Choice, error) {\n\tif m.Err != nil {\n\t\treturn nil, m.Err\n\t}\n\n\tif len(m.currentChoices) == 0 {\n\t\treturn nil, fmt.Errorf(\"no choices\")\n\t}\n\n\tif m.currentIdx < 0 || m.currentIdx >= len(m.currentChoices) {\n\t\treturn nil, fmt.Errorf(\"choice index out of bounds\")\n\t}\n\n\treturn m.currentChoices[m.currentIdx], nil\n}", "func pickFile(dir, message string) string {\n\tfileName := \"\"\n\terr := survey.AskOne(\n\t\t&survey.Select{\n\t\t\tMessage: message,\n\t\t\tOptions: readDir(dir),\n\t\t},\n\t\t&fileName,\n\t\tsurvey.WithValidator(survey.Required),\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\treturn fileName\n}", "func (c *Config) promptChoice(prompt string, choices []string, args ...string) (string, error) {\n\tvar defaultValue *string\n\tswitch len(args) {\n\tcase 0:\n\t\t// Do nothing.\n\tcase 1:\n\t\tif !slices.Contains(choices, args[0]) {\n\t\t\treturn \"\", fmt.Errorf(\"%s: invalid default value\", args[0])\n\t\t}\n\t\tdefaultValue = &args[0]\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"want 2 or 3 arguments, got %d\", len(args)+2)\n\t}\n\tif c.interactiveTemplateFuncs.promptDefaults && defaultValue != nil {\n\t\treturn *defaultValue, nil\n\t}\n\treturn c.readChoice(prompt, choices, defaultValue)\n}", "func NewChoice() Choice {\n\treturn new(ChoiceImpl)\n}", "func (o IFS) Choose() *Affine {\n\tr := rand.Intn(len(o.Choices))\n\treturn o.Choices[r]\n}", "func Choice(s *string, choices []string, title, id, class string, valid Validator) (jquery.JQuery, error) {\n\tj := jq(\"<select>\").AddClass(ClassPrefix + \"-choice\").AddClass(class)\n\tj.SetAttr(\"title\", title).SetAttr(\"id\", id)\n\tif *s == \"\" {\n\t\t*s = choices[0]\n\t}\n\tindex := -1\n\tfor i, c := range choices {\n\t\tif c == *s {\n\t\t\tindex = i\n\t\t}\n\t\tj.Append(jq(\"<option>\").SetAttr(\"value\", c).SetText(c))\n\t}\n\tif index == -1 {\n\t\treturn jq(), fmt.Errorf(\"Default of '%s' is not among valid choices\", *s)\n\t}\n\tj.SetData(\"prev\", index)\n\tj.SetProp(\"selectedIndex\", index)\n\tj.Call(jquery.CHANGE, func(event jquery.Event) {\n\t\tnewS := event.Target.Get(\"value\").String()\n\t\tnewIndex := event.Target.Get(\"selectedIndex\").Int()\n\t\tif valid != nil && !valid.Validate(newS) {\n\t\t\tnewIndex = int(j.Data(\"prev\").(float64))\n\t\t\tj.SetProp(\"selectedIndex\", newIndex)\n\t\t}\n\t\t*s = choices[int(newIndex)]\n\t\tj.SetData(\"prev\", newIndex)\n\t})\n\treturn j, nil\n}", "func (cli *CLI) Choose() (string, error) {\n\tcolorstring.Fprintf(cli.errStream, chooseText)\n\n\tnum, err := cli.AskNumber(4, 1)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// If user selects 3, should ask user GPL V2 or V3\n\tif num == 3 {\n\t\tvar buf bytes.Buffer\n\t\tbuf.WriteString(\"\\n\")\n\t\tbuf.WriteString(\"Which version do you want?\\n\")\n\t\tbuf.WriteString(\" 1) V2\\n\")\n\t\tbuf.WriteString(\" 2) V3\\n\")\n\t\tfmt.Fprintf(cli.errStream, buf.String())\n\n\t\tnum, err = cli.AskNumber(2, 1)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tnum += 4\n\t}\n\n\tvar key string\n\tswitch num {\n\tcase 1:\n\t\tkey = \"mit\"\n\tcase 2:\n\t\tkey = \"apache-2.0\"\n\tcase 4:\n\t\tkey = \"\"\n\tcase 5:\n\t\tkey = \"gpl-2.0\"\n\tcase 6:\n\t\tkey = \"gpl-3.0\"\n\tdefault:\n\t\t// Should not reach here\n\t\tpanic(\"Invalid number\")\n\t}\n\n\treturn key, nil\n}", "func get_cmd() string {\n\tui := &input.UI{\n\t\tWriter: os.Stdout,\n\t\tReader: os.Stdin,\n\t}\n\tquery := \"Select option\"\n\tcmd, _ := ui.Select(query, []string{\"LIST\", \"INFO\", \"PLAY\", \"STOP\", \"QUIT\"}, &input.Options{\n\t\tLoop: true,\n\t})\n\treturn cmd\n}", "func InputDialog(opt ...interface{}) string {\n b, _ := gtk.BuilderNewFromFile(\"glade/input-dialog.glade\")\n d := GetDialog(b, \"input_dialog\")\n entry := GetEntry(b, \"input_entry\")\n\n for i, v := range(opt) {\n if i % 2 == 0 {\n key := v.(string)\n switch key {\n case \"title\":\n d.SetTitle(opt[i+1].(string))\n case \"label\":\n l := GetLabel(b,\"input_label\")\n l.SetText(opt[i+1].(string))\n case \"password-mask\":\n entry.SetInvisibleChar(opt[i+1].(rune))\n entry.SetVisibility(false)\n case \"default\":\n entry.SetText(opt[i+1].(string))\n }\n }\n }\n\n output := \"\"\n entry.Connect(\"activate\", func (o *gtk.Entry) { d.Response(gtk.RESPONSE_OK) } )\n btok := GetButton(b, \"bt_ok\")\n btok.Connect(\"clicked\", func (b *gtk.Button) { d.Response(gtk.RESPONSE_OK) } )\n\n btcancel := GetButton(b, \"bt_cancel\")\n btcancel.Connect(\"clicked\", func (b *gtk.Button) { d.Response(gtk.RESPONSE_CANCEL) } )\n\n code := d.Run()\n if code == gtk.RESPONSE_OK {\n output, _ = entry.GetText()\n }\n\n d.Destroy()\n return output\n}", "func (cli *CliPrompter) Choose(pr string, options []string) int {\n\tselected := \"\"\n\tprompt := &survey.Select{\n\t\tMessage: pr,\n\t\tOptions: options,\n\t}\n\t_ = survey.AskOne(prompt, &selected, survey.WithValidator(survey.Required))\n\n\t// return the selected element index\n\tfor i, option := range options {\n\t\tif selected == option {\n\t\t\treturn i\n\t\t}\n\t}\n\treturn 0\n}", "func (p *PollAnswerVoters) GetChosen() (value bool) {\n\tif p == nil {\n\t\treturn\n\t}\n\treturn p.Flags.Has(0)\n}", "func getValueFromPrompt(items []string, label string) (string, error) {\n\tprompt := promptui.Select{\n\t\tLabel: label,\n\t\tItems: items,\n\t}\n\n\t_, songName, err := prompt.Run()\n\n\treturn songName, err\n}", "func (q *Question) ReadChoice(prompt string, a []string) (answer string, err error) {\n\treturn q._baseReadChoice(prompt, a, 0)\n}", "func (d *Dmenu) Popup(prompt string, options ...string) (selection string, err error) {\n\tprocessedArgs := []string{}\n\tfor _, arg := range d.arguments {\n\t\tvar parg string\n\t\tif strings.Contains(arg, \"%s\") {\n\t\t\tparg = fmt.Sprintf(arg, prompt)\n\t\t} else {\n\t\t\tparg = arg\n\t\t}\n\n\t\tprocessedArgs = append(processedArgs, parg)\n\t}\n\tcmd := exec.Command(d.command, processedArgs...)\n\n\tstdin, err := cmd.StdinPipe()\n\n\tif err != nil {\n\t\tlog.Fatalf(\"Error getting pipe: %s\", err)\n\t}\n\n\tgo func(stdin io.WriteCloser) {\n\t\tdefer stdin.Close()\n\t\tio.WriteString(stdin, strings.Join(options, \"\\n\"))\n\t}(stdin)\n\n\tbyteOut, err := cmd.Output()\n\n\tif err != nil {\n\t\tif exiterr, ok := err.(*exec.ExitError); ok {\n\t\t\tif status, ok := exiterr.Sys().(syscall.WaitStatus); ok {\n\t\t\t\tif status.ExitStatus() == 1 {\n\t\t\t\t\terr = &EmptySelectionError{}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn \"\", err\n\t}\n\n\t// Cast and trim\n\tselection = strings.TrimSpace(string(byteOut))\n\n\treturn\n}", "func (s *SelectableAttribute) Chooser() BooleanAttribute {\n\treturn s.chooser\n}", "func (q *Question) _baseReadChoice(prompt string, a []string, defaultAnswer uint) (answer string, err error) {\n\t// Saves the value without ANSI to get it when it's set the answer by default.\n\tdef := a[defaultAnswer]\n\ta[defaultAnswer] = setBold + def + setOff\n\n\tline := q.getLine(prompt, strings.Join(a, \",\"), _DEFAULT_MULTIPLE)\n\n\tfor {\n\t\tanswer, err = line.Read()\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif answer == \"\" {\n\t\t\treturn def, nil\n\t\t}\n\n\t\tfor _, v := range a {\n\t\t\tif answer == v {\n\t\t\t\treturn answer, nil\n\t\t\t}\n\t\t}\n\t}\n\treturn\n}", "func GuiTextBoxGetSelection() Vector2 {\n\tres := C.GuiTextBoxGetSelection()\n\treturn newVector2FromPointer(unsafe.Pointer(&res))\n}", "func (fv *FileView) FileSelectAction(idx int) {\n\tif idx < 0 {\n\t\treturn\n\t}\n\tfv.SaveSortPrefs()\n\tfi := fv.Files[idx]\n\tfv.SelectedIdx = idx\n\tfv.SelFile = fi.Name\n\tsf := fv.SelField()\n\tsf.SetText(fv.SelFile)\n\tfv.WidgetSig.Emit(fv.This, int64(gi.WidgetSelected), fv.SelectedFile())\n}", "func (s *BasevhdlListener) ExitChoice(ctx *ChoiceContext) {}", "func (s *BasevhdlListener) EnterChoice(ctx *ChoiceContext) {}", "func NewChoice(allowedValues ...string) Choice {\n\treturn Choice{AllowedValues: allowedValues}\n}", "func (cli *CliPrompter) ChooseWithDefault(pr string, defaultValue string, options []string) (string, error) {\n\tselected := \"\"\n\tprompt := &survey.Select{\n\t\tMessage: pr,\n\t\tOptions: options,\n\t\tDefault: defaultValue,\n\t}\n\t_ = survey.AskOne(prompt, &selected, survey.WithValidator(survey.Required))\n\n\t// return the selected element index\n\tfor i, option := range options {\n\t\tif selected == option {\n\t\t\treturn options[i], nil\n\t\t}\n\t}\n\treturn \"\", errors.New(\"bad input\")\n}", "func (o *Outbound) Chooser() peer.Chooser {\n\treturn o.chooser\n}", "func Choose(pr string, options []string) int {\n\treturn defaultPrompter.Choose(pr, options)\n}", "func (ui *UI) GetChooseMainOption() string {\n\tprompt := promptui.Select{\n\t\tLabel: \"Select command\",\n\t\tItems: []string{\"containers\", \"exit\"},\n\t}\n\t_, result, err := prompt.Run()\n\tif err != nil {\n\t\tif !strings.Contains(err.Error(), \"^\") {\n\t\t\tui.logger.Errorf(\"Prompt failed %v\", err)\n\t\t}\n\t}\n\treturn result\n}", "func pickChapter(g *gocui.Gui, v *gocui.View) error {\n\tif err := openModal(g); err != nil {\n\t\treturn err\n\t}\n\n\tdone := make(chan bool)\n\ttimer := time.NewTimer(time.Second * time.Duration(downloadTimeoutSecond))\n\n\t// must run downloading process in\n\t// go routine or else the it will\n\t// block the openModal so loading modal\n\t// will not be shown to the user\n\tgo func() {\n\t\ts := trimViewLine(v)\n\t\tprepDownloadChapter(s)\n\t\tdone <- true\n\t}()\n\n\t// in case downloading takes longer than\n\t// downloadTimeoutSecond, close the modal\n\t// and continue to download in background\n\tgo func() {\n\t\tselect {\n\t\tcase <-timer.C:\n\t\t\tsetClosingMessage(g, \"continuing to download\\nin background...\")\n\t\t\treturn\n\t\tcase <-done:\n\t\t\tg.Update(func(g *gocui.Gui) error {\n\t\t\t\terr := closeModal(g)\n\t\t\t\treturn err\n\t\t\t})\n\t\t}\n\t}()\n\n\treturn nil\n}", "func selectDirectoryGUI(titleA string) string {\n\tdirectoryT, errT := dialog.Directory().Title(titleA).Browse()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn directoryT\n}", "func (fv *FileView) SelectedFile() string {\n\treturn filepath.Join(fv.DirPath, fv.SelFile)\n}", "func Get(opt GetOptions) ([]action.DownloadedFile, error) {\n\tcolor.Disable()\n\n\tgopt := action.GetOpt{}\n\tgopt.Files = opt.Files\n\tgopt.Tags = opt.Tags\n\tgopt.Service = opt.Service\n\tgopt.Output = opt.Output\n\n\tif len(opt.Catalog) == 0 {\n\t\tgopt.Catalog = catalog.DefaultName\n\t} else {\n\t\tgopt.Catalog = opt.Catalog\n\t}\n\n\tm := monitor.New(ioutil.Discard, true)\n\n\tfiles, err := action.Get(gopt, action.Dep{\n\t\tStderr: os.NewFile(0, os.DevNull),\n\t\tStdout: os.NewFile(0, os.DevNull),\n\n\t\tMonitor: &m,\n\t})\n\n\tif len(m.Errors) > 0 {\n\t\treturn files, m.Errors[0]\n\t}\n\n\treturn files, err\n}", "func choice(a string) string {\n\tif strings.EqualFold(a, \"r\") {\n\t\treturn \"Rock\"\n\t} else if strings.EqualFold(a, \"p\") {\n\t\treturn \"Paper\"\n\t} else if strings.EqualFold(a, \"s\") {\n\t\treturn \"Scissor\"\n\t} else {\n\t\treturn \"UNKNOWN\"\n\t}\n}", "func (e Enum) GetValue(key string) (any, error) {\n\tfor k, v := range e {\n\t\tif k == key {\n\t\t\treturn v, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"flagenum: Invalid value; must be one of [%s]\", e.Choices())\n}", "func selectFileToSaveGUI(titleA string, filterNameA string, filterTypeA string) string {\n\tfileNameT, errT := dialog.File().Filter(filterNameA, filterTypeA).Title(titleA).Save()\n\n\tif errT != nil {\n\t\treturn tk.GenerateErrorStringF(\"failed: %v\", errT)\n\t}\n\n\treturn fileNameT\n}", "func ChoiceIndexCallback(title string, choices []string, def int, f func(int, int, int)) int {\n\tselection := def\n\tnc := len(choices) - 1\n\tif selection < 0 || selection > nc {\n\t\tselection = 0\n\t}\n\toffset := 0\n\tcx := 0\n\tfor {\n\t\tsx, sy := termbox.Size()\n\t\ttermbox.HideCursor()\n\t\ttermbox.Clear(termbox.ColorDefault, termbox.ColorDefault)\n\t\tPrintstring(title, 0, 0)\n\t\tfor selection < offset {\n\t\t\toffset -= 5\n\t\t\tif offset < 0 {\n\t\t\t\toffset = 0\n\t\t\t}\n\t\t}\n\t\tfor selection-offset >= sy-1 {\n\t\t\toffset += 5\n\t\t\tif offset >= nc {\n\t\t\t\toffset = nc\n\t\t\t}\n\t\t}\n\t\tfor i, s := range choices[offset:] {\n\t\t\tts, _ := trimString(s, cx)\n\t\t\tPrintstring(ts, 3, i+1)\n\t\t\tif cx > 0 {\n\t\t\t\tPrintstring(\"←\", 2, i+1)\n\t\t\t}\n\t\t}\n\t\tPrintstring(\">\", 1, (selection+1)-offset)\n\t\tif f != nil {\n\t\t\tf(selection, sx, sy)\n\t\t}\n\t\ttermbox.Flush()\n\t\tev := termbox.PollEvent()\n\t\tif ev.Type != termbox.EventKey {\n\t\t\tcontinue\n\t\t}\n\t\tkey := ParseTermboxEvent(ev)\n\t\tswitch key {\n\t\tcase \"C-v\":\n\t\t\tfallthrough\n\t\tcase \"next\":\n\t\t\tselection += sy - 5\n\t\t\tif selection >= len(choices) {\n\t\t\t\tselection = len(choices) - 1\n\t\t\t}\n\t\tcase \"M-v\":\n\t\t\tfallthrough\n\t\tcase \"prior\":\n\t\t\tselection -= sy - 5\n\t\t\tif selection < 0 {\n\t\t\t\tselection = 0\n\t\t\t}\n\t\tcase \"C-c\":\n\t\t\tfallthrough\n\t\tcase \"C-g\":\n\t\t\treturn def\n\t\tcase \"UP\", \"C-p\":\n\t\t\tif selection > 0 {\n\t\t\t\tselection--\n\t\t\t}\n\t\tcase \"DOWN\", \"C-n\":\n\t\t\tif selection < len(choices)-1 {\n\t\t\t\tselection++\n\t\t\t}\n\t\tcase \"LEFT\", \"C-b\":\n\t\t\tif cx > 0 {\n\t\t\t\tcx--\n\t\t\t}\n\t\tcase \"RIGHT\", \"C-f\":\n\t\t\tcx++\n\t\tcase \"C-a\", \"Home\":\n\t\t\tcx = 0\n\t\tcase \"M-<\":\n\t\t\tselection = 0\n\t\tcase \"M->\":\n\t\t\tselection = len(choices) - 1\n\t\tcase \"RET\":\n\t\t\treturn selection\n\t\t}\n\t}\n}", "func NewFlagChoice(choices []string, chosen string) *FlagChoice {\n\treturn &FlagChoice{\n\t\tchoices: choices,\n\t\tchosen: chosen,\n\t}\n}", "func getCompletion(sh string, parent *cobra.Command) (string, error) {\n\tvar err error\n\tvar buf bytes.Buffer\n\n\tswitch sh {\n\tcase \"bash\":\n\t\terr = parent.GenBashCompletion(&buf)\n\tcase \"zsh\":\n\t\terr = parent.GenZshCompletion(&buf)\n\tcase \"fish\":\n\t\terr = parent.GenFishCompletion(&buf, true)\n\n\tdefault:\n\t\terr = errors.New(\"unsupported shell type (must be bash, zsh or fish): \" + sh)\n\t}\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn buf.String(), nil\n}", "func RequestChoiceIfEmpty(defaultValue string, message string, options ...string) string {\n\tif defaultValue != \"\" {\n\t\treturn defaultValue\n\t}\n\treturn RequestChoice(message, options...)\n}", "func (pm *PopupMenu) GetButton(id string) *PushButton {\n\tfor _, ow := range pm.opts {\n\t\tif ow.opt.ID == id {\n\t\t\tpb, ok := ow.w.(*PushButton)\n\t\t\tif !ok {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn pb\n\t\t}\n\t}\n\treturn nil\n}", "func get_song_selection() (int, string) {\n\tsongs := strings.Split(master_list, \"\\n\")\n\tvar ip string\n\n\tui := &input.UI{\n\t\tWriter: os.Stdout,\n\t\tReader: os.Stdin,\n\t}\n\tquery := \"Select a song\"\n\tid, _ := ui.Ask(query, &input.Options{\n\t\tValidateFunc: func(id string) error {\n\t\t\tfor _, s := range songs {\n\t\t\t\tsong_id := strings.Split(s, \":\")[0]\n\t\t\t\tif song_id == id {\n\t\t\t\t\tip = strings.SplitN(s, \":\", 3)[1][1:]\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"song id not here\")\n\t\t},\n\t\tLoop: true,\n\t})\n\tret, _ := strconv.ParseInt(id, 10, 32)\n\treturn int(ret), ip + \":\"\n}", "func (o *os) GetImeSelection() gdnative.Vector2 {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetImeSelection()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_ime_selection\")\n\n\t// Call the parent method.\n\t// Vector2\n\tretPtr := gdnative.NewEmptyVector2()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewVector2FromPointer(retPtr)\n\treturn ret\n}", "func (cv *Choice) String() string {\n\tif cv.Choice != nil {\n\t\treturn *cv.Choice\n\t}\n\treturn \"\"\n}", "func (l *List) Choose(ctx context.Context, req *transport.Request) (peer peer.Peer, onFinish func(error), err error) {\n\treturn l.list.Choose(ctx, req)\n}", "func (fb *FlowBox) GetSelectionMode() SelectionMode {\n\tc := C.gtk_flow_box_get_selection_mode(fb.native())\n\treturn SelectionMode(c)\n}", "func (v Values) GetSelection(\n\tmodel SelectModel, name string) *Selection {\n\treturn model.ToSelection(v.Get(name))\n}", "func (_m *Prompter) Choice(prompt string, options []string) string {\n\tret := _m.Called(prompt, options)\n\n\tvar r0 string\n\tif rf, ok := ret.Get(0).(func(string, []string) string); ok {\n\t\tr0 = rf(prompt, options)\n\t} else {\n\t\tr0 = ret.Get(0).(string)\n\t}\n\n\treturn r0\n}", "func (*XMLDocument) GetSelection() (w *window.Selection) {\n\tmacro.Rewrite(\"$_.getSelection()\")\n\treturn w\n}", "func (cycle *Cycle) Choose() {\n\tif !cycle.showing ||\n\t\tlen(cycle.items) == 0 ||\n\t\tcycle.selected < 0 ||\n\t\tcycle.selected >= len(cycle.items) {\n\n\t\treturn\n\t}\n\n\tcycle.items[cycle.selected].choose()\n\tcycle.Hide()\n}", "func waitForFileToBeSelected(ctx context.Context, conn *chrome.Conn, f *filesapp.FilesApp) error {\n\tif err := conn.WaitForExprFailOnErrWithTimeout(ctx, \"window.document.title == 'awaiting drop.'\", 5*time.Second); err != nil {\n\t\treturn errors.Wrap(err, \"failed waiting for javascript to update window.document.title\")\n\t}\n\n\t// Get the listbox which has the list of files.\n\tlistBox, err := f.Root.DescendantWithTimeout(ctx, ui.FindParams{Role: ui.RoleTypeListBox}, 15*time.Second)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to find listbox\")\n\t}\n\tdefer listBox.Release(ctx)\n\n\t// Setup a watcher to wait for the selected files to stabilize.\n\tew, err := ui.NewWatcher(ctx, listBox, ui.EventTypeActiveDescendantChanged)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed getting a watcher for the files listbox\")\n\t}\n\tdefer ew.Release(ctx)\n\n\t// Check the listbox for any Activedescendantchanged events occurring in a 2 second interval.\n\t// If any events are found continue polling until 10s is reached.\n\tif err := testing.Poll(ctx, func(ctx context.Context) error {\n\t\treturn ew.EnsureNoEvents(ctx, 2*time.Second)\n\t}, &testing.PollOptions{Timeout: 10 * time.Second}); err != nil {\n\t\treturn errors.Wrapf(err, \"failed waiting %v for listbox to stabilize\", 10*time.Second)\n\t}\n\n\treturn nil\n}", "func (s *Selection) RunPrompt() (*Choice, error) {\n\ttmpl, err := s.initConfirmationTemplate()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"initializing confirmation template: %w\", err)\n\t}\n\n\tm := NewModel(s)\n\n\tp := tea.NewProgram(m, tea.WithOutput(s.Output), tea.WithInput(s.Input))\n\tif err := p.Start(); err != nil {\n\t\treturn nil, fmt.Errorf(\"running prompt: %w\", err)\n\t}\n\n\tchoice, err := m.Choice()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading choice: %w\", err)\n\t}\n\n\tif s.ConfirmationTemplate == \"\" {\n\t\treturn choice, nil\n\t}\n\n\tbuffer := &bytes.Buffer{}\n\n\terr = tmpl.Execute(buffer, map[string]interface{}{\n\t\t\"FinalChoice\": choice,\n\t\t\"Prompt\": m.Prompt,\n\t\t\"AllChoices\": m.Choices,\n\t\t\"NAllChoices\": len(m.Choices),\n\t\t\"TerminalWidth\": m.width,\n\t})\n\tif err != nil {\n\t\treturn choice, fmt.Errorf(\"execute confirmation template: %w\", err)\n\t}\n\n\t_, err = fmt.Fprint(s.Output, promptkit.Wrap(buffer.String(), m.width))\n\n\treturn choice, err\n}", "func ChooseWithDefault(pr string, defaultValue string, options []string) (string, error) {\n\treturn defaultPrompter.ChooseWithDefault(pr, defaultValue, options)\n}", "func (pf *File) GetEnum(name string) *Enum {\n\tfor _, enum := range pf.Enums {\n\t\tif enum.Name == name {\n\t\t\treturn enum\n\t\t}\n\t}\n\n\treturn nil\n}", "func (p *colorPicker) Pick(image string) Color {\n\tif c, present := p.imageColors[tag.StripTag(image, false)]; present {\n\t\treturn c\n\t}\n\n\t// If no mapping is found, don't add any color formatting\n\treturn None\n}", "func (f *FilePicker) SelectFile(fileName string) uiauto.Action {\n\treturn f.filesApp.SelectFile(fileName)\n}", "func (ui *UI) GetChooseContainer(containers []types.Container) *types.Container {\n\titems := []displayedContainer{}\n\ttemplates := &promptui.SelectTemplates{\n\t\tActive: `{{ printf \">\" | blue }} {{ .ShortID | bold }} ({{ .ImageName | bold }})`,\n\t\tInactive: \" {{ .ShortID }} ({{ .ImageName }})\",\n\t\tSelected: \" {{ .ShortID | bold }} {{ .ImageName | bold | blue }} selected\",\n\t\tDetails: `\n\t\t--------- Container ----------\n\t\t{{ \"ID:\" | faint }}\t{{ .ShortID }}\n\t\t{{ \"Image:\" | faint }}\t{{ .ImageName }}\n\t\t{{ \"Status:\" | faint }}\t{{ .CurrentStatus }}\n\t\t{{ \"State:\" | faint }}\t{{ .State }}`,\n\t}\n\tfor _, container := range containers {\n\t\titem := displayedContainer{\n\t\t\tcontainer.ID[:12],\n\t\t\tcontainer.Image,\n\t\t\tcontainer.Status,\n\t\t\tcontainer.State,\n\t\t}\n\t\titems = append(items, item)\n\t}\n\tprompt := promptui.Select{\n\t\tLabel: \"Select Container\",\n\t\tItems: items,\n\t\tTemplates: templates,\n\t}\n\n\tindex, _, err := prompt.Run()\n\tif err != nil {\n\t\tif !strings.Contains(err.Error(), \"^\") {\n\t\t\tui.logger.Errorf(\"Prompt failed %v\", err)\n\t\t}\n\t\treturn nil\n\t}\n\treturn &containers[index]\n}", "func Choose(baseURL string, store ChooseDB, strategies strategy.Strategies, chooseTemplate, meTemplate tmpl) http.Handler {\n\treturn mux.Method{\n\t\t\"GET\": chooseProvider(baseURL, store, strategies, chooseTemplate, meTemplate),\n\t}\n}", "func (b *Button) GetImage(t int) uintptr {\n\treturn b.SendMessage(win.BM_GETIMAGE, uintptr(t), 0)\n}", "func get(stub shim.ChaincodeStubInterface, args []string) (string, error) {\n\tif len(args) != 1 {\n\t\treturn \"\", fmt.Errorf(\"Incorrect arguments. Expecting a key\")\n\t}\n\n\tvalue, err := stub.GetState(args[0])\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to get asset: %s with error: %s\", args[0], err)\n\t}\n\tif value == nil {\n\t\treturn \"\", fmt.Errorf(\"Asset not found: %s\", args[0])\n\t}\n\treturn string(value), nil\n}", "func get(stub shim.ChaincodeStubInterface, args []string) (string, error) {\n\tif len(args) != 1 {\n\t\treturn \"\", fmt.Errorf(\"Incorrect arguments. Expecting a key\")\n\t}\n\n\tvalue, err := stub.GetState(args[0])\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to get asset: %s with error: %s\", args[0], err)\n\t}\n\tif value == nil {\n\t\treturn \"\", fmt.Errorf(\"Asset not found: %s\", args[0])\n\t}\n\n\treturn string(value), nil\n}", "func (m *ManagementTemplateStep) GetAcceptedVersion()(ManagementTemplateStepVersionable) {\n val, err := m.GetBackingStore().Get(\"acceptedVersion\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(ManagementTemplateStepVersionable)\n }\n return nil\n}", "func browseFolderCallback(hwnd win.HWND, msg uint32, lp, wp uintptr) uintptr {\n\tconst BFFM_SELCHANGED = 2\n\tif msg == BFFM_SELCHANGED {\n\t\t_, err := pathFromPIDL(lp)\n\t\tvar enabled uintptr\n\t\tif err == nil {\n\t\t\tenabled = 1\n\t\t}\n\n\t\tconst BFFM_ENABLEOK = win.WM_USER + 101\n\n\t\twin.SendMessage(hwnd, BFFM_ENABLEOK, 0, enabled)\n\t}\n\n\treturn 0\n}", "func ChoiceIndex(title string, choices []string, def int) int {\n\treturn ChoiceIndexCallback(title, choices, def, nil)\n}", "func (v *RadioButton) GetGroup() (*glib.SList, error) {\n\tc := C.gtk_radio_button_get_group(v.native())\n\tif c == nil {\n\t\treturn nil, nilPtrErr\n\t}\n\treturn glib.WrapSList(uintptr(unsafe.Pointer(c))), nil\n}", "func (a *Args) GetOpt(key string) string {\n\tfor _, b := range a.binOpts {\n\t\tif b.key == key {\n\t\t\treturn b.val\n\t\t}\n\t}\n\n\t// Invalid Option\n\tfmt.Fprintf(os.Stderr, \"Args - Missing option: %s\\n\", key)\n\tos.Exit(1)\n\n\t// Never Gets Here\n\treturn \"\"\n}", "func (c *CompletionManager) GetSelectedSuggestion() (s Suggest, ok bool) {\n\tif c.selected == -1 {\n\t\treturn Suggest{}, false\n\t} else if c.selected < -1 {\n\t\tdebug.Assert(false, \"must not reach here\")\n\t\tc.selected = -1\n\t\treturn Suggest{}, false\n\t}\n\treturn c.tmp[c.selected], true\n}", "func (f *FlagChoice) String() string {\n\treturn choiceList(f.choices...)\n}", "func (selectManyConfig SelectManyConfig) GetTemplate(context *Context, metaType string) (assetfs.AssetInterface, error) {\n\tif metaType == \"form\" && selectManyConfig.SelectionTemplate != \"\" {\n\t\treturn context.Asset(selectManyConfig.SelectionTemplate)\n\t}\n\treturn nil, errors.New(\"not implemented\")\n}", "func (fn *formulaFuncs) CHOOSE(argsList *list.List) formulaArg {\n\tif argsList.Len() < 2 {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CHOOSE requires 2 arguments\")\n\t}\n\tidx, err := strconv.Atoi(argsList.Front().Value.(formulaArg).Value())\n\tif err != nil {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"CHOOSE requires first argument of type number\")\n\t}\n\tif argsList.Len() <= idx {\n\t\treturn newErrorFormulaArg(formulaErrorVALUE, \"index_num should be <= to the number of values\")\n\t}\n\targ := argsList.Front()\n\tfor i := 0; i < idx; i++ {\n\t\targ = arg.Next()\n\t}\n\treturn arg.Value.(formulaArg)\n}", "func GetFilterOption(ignoresRegex string) (BackupOption, error) {\n\texp, err := regexp.Compile(ignoresRegex)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\topt := func(action CopyAction) CopyAction {\n\t\tnewAct := func(oldPath, newPath string, info os.FileInfo) error {\n\n\t\t\tmatched := exp.Match([]byte(oldPath))\n\t\t\tif matched {\n\t\t\t\treturn fmt.Errorf(fileIgnored)\n\t\t\t}\n\t\t\treturn action(oldPath, newPath, info)\n\t\t}\n\t\treturn newAct\n\t}\n\treturn opt, nil\n}", "func getLicenseFile(licenses []string, files []string) (string, error) {\n\tmatches := matchLicenseFile(licenses, files)\n\n\tswitch len(matches) {\n\tcase 0:\n\t\treturn \"\", ErrNoLicenseFile\n\tcase 1:\n\t\treturn matches[0], nil\n\tdefault:\n\t\treturn \"\", ErrMultipleLicenses\n\t}\n}", "func (l *License) GuessFile(dir string) error {\n\tfiles, err := readDirectory(dir)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmatch, err := getLicenseFile(DefaultLicenseFiles, files)\n\tif err != nil {\n\t\treturn err\n\t}\n\tl.File = filepath.Join(dir, match)\n\treturn nil\n}", "func (e *EntryManager) GetSelectEntry() *Entry {\n\trow, _ := e.GetSelection()\n\tif len(e.entries) == 0 {\n\t\treturn nil\n\t}\n\tif row < 1 {\n\t\treturn nil\n\t}\n\n\tif row > len(e.entries) {\n\t\treturn nil\n\t}\n\treturn e.entries[row-1]\n}", "func (ui *UI) GetCommandSelect() string {\n\tprompt := promptui.Select{\n\t\tLabel: \"Select Commnad\",\n\t\tItems: []string{\"exec\", \"logs\", \"stop\"},\n\t}\n\n\t_, result, err := prompt.Run()\n\tif err != nil {\n\t\tif !strings.Contains(err.Error(), \"^\") {\n\t\t\tui.logger.Errorf(\"Select containers dialog failed | %s\", err)\n\t\t}\n\t}\n\treturn result\n}", "func (s *BasevhdlListener) ExitChoices(ctx *ChoicesContext) {}", "func (v *MenuButton) GetPopup() *Menu {\n\tc := C.gtk_menu_button_get_popup(v.native())\n\tif c == nil {\n\t\treturn nil\n\t}\n\tobj := glib.Take(unsafe.Pointer(c))\n\treturn wrapMenu(obj)\n}", "func (f *FileDescriptor) GetEnum(name string) *EnumDescriptor {\n\tfor _, e := range f.GetEnums() {\n\t\tif e.GetName() == name || e.GetLongName() == name {\n\t\t\treturn e\n\t\t}\n\t}\n\n\treturn nil\n}", "func (v *Button) GetImage() (*Widget, error) {\n\tc := C.gtk_button_get_image(v.native())\n\tif c == nil {\n\t\treturn nil, nilPtrErr\n\t}\n\tobj := glib.Take(unsafe.Pointer(c))\n\treturn wrapWidget(obj), nil\n}", "func (e Enum) Choices() string {\n\tkeys := make([]string, 0, len(e))\n\tfor k := range e {\n\t\tif k == \"\" {\n\t\t\tk = `\"\"`\n\t\t}\n\t\tkeys = append(keys, k)\n\t}\n\tsort.Strings(keys)\n\treturn strings.Join(keys, \", \")\n}", "func (Choices) EnumDescriptor() ([]byte, []int) {\n\treturn file_api_proto_rawDescGZIP(), []int{0}\n}", "func GetFromStdin(params *GetFromStdinParams) *string {\n\tvar prompt survey.Prompt\n\tvar result *string\n\tcompiledRegex := DefaultValidationRegexPattern\n\tif params.ValidationRegexPattern != \"\" {\n\t\tcompiledRegex = regexp.MustCompile(params.ValidationRegexPattern)\n\t}\n\n\tif params.Options != nil {\n\t\tprompt = &survey.Select{\n\t\t\tMessage: params.Question,\n\t\t\tOptions: params.Options,\n\t\t\tDefault: params.DefaultValue,\n\t\t}\n\t} else if params.IsPassword {\n\t\tprompt = &survey.Password{\n\t\t\tMessage: params.Question,\n\t\t}\n\t} else {\n\t\tprompt = &survey.Input{\n\t\t\tMessage: params.Question,\n\t\t\tDefault: params.DefaultValue,\n\t\t}\n\t}\n\n\tquestion := []*survey.Question{\n\t\t{\n\t\t\tName: \"question\",\n\t\t\tPrompt: prompt,\n\t\t},\n\t}\n\n\tif params.Options != nil {\n\t\tquestion[0].Validate = func(val interface{}) error {\n\t\t\t// since we are validating an Input, the assertion will always succeed\n\t\t\tif str, ok := val.(string); !ok || compiledRegex.MatchString(str) == false {\n\t\t\t\treturn fmt.Errorf(\"Answer has to match pattern: %s\", compiledRegex.String())\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tfor result == nil {\n\t\t// Ask it\n\t\tanswers := struct {\n\t\t\tQuestion string\n\t\t}{}\n\t\terr := survey.Ask(question, &answers)\n\t\tif err != nil {\n\t\t\tif strings.HasPrefix(err.Error(), \"Answer has to match pattern\") {\n\t\t\t\tlog.Info(err.Error())\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\t// Keyboard interrupt\n\t\t\tos.Exit(0)\n\t\t}\n\n\t\tresult = &answers.Question\n\t}\n\n\treturn result\n}", "func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader, error) {\n\treturn c.Ctx.Request.FormFile(key)\n}", "func (m *AgreementAcceptance) GetAgreementFileId()(*string) {\n return m.agreementFileId\n}", "func (g *Group) pick(r *http.Request) *Backend {\n\tg.mu.RLock()\n\tdefer g.mu.RUnlock()\n\tif len(g.backends) == 0 {\n\t\treturn nil\n\t}\n\t// TODO(kr): do something smarter than rand\n\treturn g.backends[rand.Intn(len(g.backends))]\n}", "func (s *BasevhdlListener) EnterChoices(ctx *ChoicesContext) {}", "func (*AnswerChoice) Descriptor() ([]byte, []int) {\n\treturn file_quiz_proto_rawDescGZIP(), []int{4}\n}", "func HandleFilterChoice() {\n\tvar userCommand int\n\tfmt.Scan(&userCommand)\n\n\tswitch userCommand {\n\tcase 1: // Deadline\n\t\tcontrollers.ShowFilteredOptions(1)\n\tcase 2: // Priority\n\t\tcontrollers.ShowFilteredOptions(2)\n\tcase 3: // Added time\n\t\tcontrollers.ShowFilteredOptions(3)\n\tdefault:\n\t\tfmt.Println(\"Returning to Main Menu...\")\n\t}\n}", "func RenderSetChoice(resp http.ResponseWriter, req *http.Request, ext string, mode primitive.Mode, fileSeeker io.ReadSeeker) {\n\n\top := []OptStruct{\n\t\t{20, mode},\n\t\t{30, mode},\n\t\t{40, mode},\n\t\t{50, mode},\n\t}\n\topFileList, err := GenImgList(ext, fileSeeker, op...)\n\tif err != nil {\n http.Error(resp, err.Error(), http.StatusInternalServerError)\n return\n\t}\n\thtmlist := `<html>\n <body>\n {{range .}}\n <a href=\"/modify/{{.Name}}?mode={{.Mode}}&n={{.Numshapes}}\">\n <img style =\"width 30%\" src=\"/pics/{{.Name}}\">\n {{end}}\n </body>\n </html>\n `\n\ttempl := template.Must(template.New(\"\").Parse(htmlist))\n\n\ttype Opts struct {\n\t\tName string\n\t\tMode primitive.Mode\n\t\tNumshapes int\n\t}\n\tvar opts []Opts\n\tfor index, val := range opFileList {\n\t\topts = append(opts, Opts{Name: filepath.Base(val), Mode: op[index].mode, Numshapes: op[index].num})\n\t}\n\n\t// err = templ.Execute(resp, opts)\n\t// if err != nil {\n\t// \tpanic(err)\n\t// }\n checkError(templ.Execute(resp,opts))\n}", "func SelectorCli(label string, options ...string) (string, error) {\n\ts := promptui.Select{\n\t\tLabel: label,\n\t\tItems: options,\n\t}\n\n\t_, result, err := s.Run()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\treturn result, nil\n}", "func (d *Abstraction) GetChannel(s string) chan *AbsSignal {\n\tif _, ok := d.Sigmap[s]; ok {\n\t\treturn d.Sigmap[s]\n\t}\n\treturn nil\n}", "func (fv *FileView) SetSelFileAction(sel string) {\n\tfv.SelFile = sel\n\tsv := fv.FilesView()\n\tsv.SelectFieldVal(\"Name\", fv.SelFile)\n\tfv.SelectedIdx = sv.SelectedIdx\n\tsf := fv.SelField()\n\tsf.SetText(fv.SelFile)\n\tfv.WidgetSig.Emit(fv.This, int64(gi.WidgetSelected), fv.SelectedFile())\n}", "func (pipe *PipeWS) GetOption(name string) (\n\tvalue interface{},\n\terr error) {\n\treturn nil, mangos.ErrBadOption\n}", "func GetImageFlavor(label string, encryptionRequired bool, keyURL string, digest string) (*ImageFlavor, error) {\n\tlog.Trace(\"flavor/image_flavor:GetImageFlavor() Entering\")\n\tdefer log.Trace(\"flavor/image_flavor:GetImageFlavor() Leaving\")\n\tvar encryption *model.Encryption\n\n\tdescription := map[string]interface{}{\n\t\tmodel.Label: label,\n\t\tmodel.FlavorPart: \"IMAGE\",\n\t}\n\n\tmeta := model.Meta{\n\t\tDescription: description,\n\t}\n\tnewUuid, err := uuid.NewRandom()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to create new UUID\")\n\t}\n\tmeta.ID = newUuid\n\n\tif encryptionRequired {\n\t\tencryption = &model.Encryption{\n\t\t\tKeyURL: keyURL,\n\t\t\tDigest: digest,\n\t\t}\n\t}\n\n\timageflavor := model.Image{\n\t\tMeta: meta,\n\t\tEncryptionRequired: encryptionRequired,\n\t\tEncryption: encryption,\n\t}\n\n\tflavor := ImageFlavor{\n\t\tImage: imageflavor,\n\t}\n\treturn &flavor, nil\n}", "func New(prompt string, choices []*Choice) *Selection {\n\treturn &Selection{\n\t\tChoices: choices,\n\t\tPrompt: prompt,\n\t\tFilterPrompt: DefaultFilterPrompt,\n\t\tTemplate: DefaultTemplate,\n\t\tConfirmationTemplate: DefaultConfirmationTemplate,\n\t\tFilter: FilterContainsCaseInsensitive,\n\t\tFilterInputPlaceholderStyle: lipgloss.NewStyle().Foreground(lipgloss.Color(\"240\")),\n\t\tKeyMap: NewDefaultKeyMap(),\n\t\tFilterPlaceholder: DefaultFilterPlaceholder,\n\t\tExtendedTemplateScope: template.FuncMap{},\n\t\tOutput: os.Stdout,\n\t\tInput: os.Stdin,\n\t}\n}", "func getArg(c *cli.Context, idx int, prompt string) (string, error) {\n\targ := c.Args().Get(0)\n\tif arg != \"\" {\n\t\treturn arg, nil\n\t}\n\tfmt.Printf(\"%s: \", prompt)\n\treader := bufio.NewReader(os.Stdin)\n\targ, err := reader.ReadString('\\n')\n\tif err != nil {\n\t\treturn arg, err\n\t}\n\targ = strings.TrimSpace(arg)\n\treturn arg, nil\n}" ]
[ "0.5884683", "0.5797472", "0.5483212", "0.5472473", "0.54234344", "0.53660977", "0.5348636", "0.5299239", "0.52480185", "0.5243561", "0.52337843", "0.5179653", "0.5166573", "0.51321834", "0.5097163", "0.4941595", "0.48885983", "0.48517326", "0.48319155", "0.4736443", "0.4735221", "0.46647197", "0.46459487", "0.4637478", "0.46300396", "0.45709053", "0.45704213", "0.45670515", "0.45023456", "0.44920647", "0.44913262", "0.4484871", "0.44758517", "0.4461774", "0.44547376", "0.44520876", "0.44465202", "0.44356954", "0.4403275", "0.43874356", "0.43610242", "0.4331063", "0.4326026", "0.43253496", "0.43195364", "0.43187764", "0.43029153", "0.430027", "0.43001515", "0.42978463", "0.4293386", "0.4264958", "0.42634627", "0.42480138", "0.4236517", "0.42268234", "0.4208934", "0.41949394", "0.4175037", "0.4166031", "0.41602215", "0.41592154", "0.41464671", "0.41435945", "0.41379336", "0.41366917", "0.41238803", "0.41055197", "0.4098921", "0.40939498", "0.40930903", "0.40904522", "0.40857533", "0.40831617", "0.4081507", "0.4078293", "0.40753195", "0.40710637", "0.40677053", "0.40645283", "0.40572834", "0.40458366", "0.4035927", "0.40169784", "0.4016101", "0.40037963", "0.4000175", "0.39938807", "0.3986406", "0.3974765", "0.39722723", "0.3971844", "0.39591655", "0.3956864", "0.39562577", "0.39528435", "0.39477178", "0.39472213", "0.39433858", "0.39378786" ]
0.8411069
0
/ GtkScrolledWindow GetMaxContentWidth is a wrapper around gtk_scrolled_window_get_max_content_width().
func (v *ScrolledWindow) GetMaxContentWidth() int { c := C.gtk_scrolled_window_get_max_content_width(v.native()) return int(c) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *ScrolledWindow) GetMaxContentHeight() int {\n\tc := C.gtk_scrolled_window_get_max_content_height(v.native())\n\treturn int(c)\n}", "func (v *ScrolledWindow) SetMaxContentWidth(width int) {\n\tC.gtk_scrolled_window_set_max_content_width(v.native(), C.gint(width))\n}", "func (v *ScrolledWindow) SetMaxContentHeight(width int) {\n\tC.gtk_scrolled_window_set_max_content_height(v.native(), C.gint(width))\n}", "func (v *Entry) GetMaxWidthChars() int {\n\tc := C.gtk_entry_get_max_width_chars(v.native())\n\treturn int(c)\n}", "func getContentWidth(pdf *gofpdf.Fpdf) float64 {\n\tmarginL, _, marginR, _ := pdf.GetMargins()\n\tpageW, _ := pdf.GetPageSize()\n\twidth := pageW - marginL - marginR\n\treturn width\n}", "func (p *pageT) WidthMax(s string) {\n\tp.Style = css.NewStylesResponsive(p.Style)\n\tp.Style.Desktop.StyleBox.WidthMax = s\n\tp.Style.Mobile.StyleBox.WidthMax = \"calc(100% - 1.2rem)\" // 0.6rem margin-left and -right in mobile view\n}", "func (w Widths) MaxWidth() (maxWidth, wideDepth int) {\n\tfor depth, width := range w {\n\t\tif width > maxWidth {\n\t\t\tmaxWidth = width\n\t\t\twideDepth = depth\n\t\t}\n\t}\n\treturn\n}", "func (gr *groupT) WidthMax(s string) {\n\tgr.Style = css.NewStylesResponsive(gr.Style)\n\tgr.Style.Desktop.StyleBox.WidthMax = s\n\tgr.Style.Mobile.StyleBox.WidthMax = \"none\" // => 100% of page - page has margins; replaced desktop max-width\n}", "func (v *ScrolledWindow) GetPropagateNaturalWidth() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_width(v.native())\n\treturn gobool(c)\n}", "func (w *WidgetImplement) FixedWidth() int {\n\treturn w.fixedW\n}", "func maxWidth(no_lines int, widthFromLineNo widthFunc) int {\n\tvar max int\n\tfor i := 0; i < no_lines; i++ {\n\t\tval := widthFromLineNo(i)\n\t\tif val > max {\n\t\t\tmax = val\n\t\t}\n\t}\n\treturn max\n}", "func (fb *FlowBox) GetMaxChildrenPerLine() uint {\n\tc := C.gtk_flow_box_get_max_children_per_line(fb.native())\n\treturn uint(c)\n}", "func SetScrollContentTrackerSize(sa *qtwidgets.QScrollArea) {\n\twgt := sa.Widget()\n\tsa.InheritResizeEvent(func(arg0 *qtgui.QResizeEvent) {\n\t\tosz := arg0.OldSize()\n\t\tnsz := arg0.Size()\n\t\tif false {\n\t\t\tlog.Println(osz.Width(), osz.Height(), nsz.Width(), nsz.Height())\n\t\t}\n\t\tif osz.Width() != nsz.Width() {\n\t\t\twgt.SetMaximumWidth(nsz.Width())\n\t\t}\n\t\t// this.ScrollArea_2.ResizeEvent(arg0)\n\t\targ0.Ignore() // I ignore, you handle it. replace explict call parent's\n\t})\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func (me XsdGoPkgHasElems_MaxWidth) MaxWidthDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (w *LWindow) MWidth() int32 {\n\treturn w.mWidth\n}", "func (v *Value) MaxWidth(offset, tab int) int {\n\t// simple values do not have tabulations\n\twidth := v.Width\n\tfor l := 0; l < len(v.Tabs); l++ {\n\t\twidth = max(width, v.LineWidth(l, offset, tab))\n\t}\n\treturn width\n}", "func (me XsdGoPkgHasElem_MaxWidth) MaxWidthDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (window Window) InnerWidth() int {\n\treturn window.Get(\"innerWidth\").Int()\n}", "func (g *GitStatusWidget) GetWidth() int {\n\treturn g.renderer.GetWidth()\n}", "func (f *Framebuffer) Width() int { return f.fb.Bounds().Max.X }", "func (self *CellRenderer) GetFixedSize() (width, height int) {\n\tvar w C.gint\n\tvar h C.gint\n\tC.gtk_cell_renderer_get_fixed_size(self.object, &w, &h)\n\n\twidth = int(w)\n\theight = int(h)\n\treturn\n}", "func (o *os) GetMaxWindowSize() gdnative.Vector2 {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetMaxWindowSize()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_max_window_size\")\n\n\t// Call the parent method.\n\t// Vector2\n\tretPtr := gdnative.NewEmptyVector2()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewVector2FromPointer(retPtr)\n\treturn ret\n}", "func (s *ItemScroller) autoSize() {\n\n\tif s.maxAutoWidth == 0 && s.maxAutoHeight == 0 {\n\t\treturn\n\t}\n\n\tvar width float32\n\tvar height float32\n\tfor _, item := range s.items {\n\t\tpanel := item.GetPanel()\n\t\tif panel.Width() > width {\n\t\t\twidth = panel.Width()\n\t\t}\n\t\theight += panel.Height()\n\t}\n\n\t// If auto maximum width enabled\n\tif s.maxAutoWidth > 0 {\n\t\tif width <= s.maxAutoWidth {\n\t\t\ts.SetContentWidth(width)\n\t\t}\n\t}\n\t// If auto maximum height enabled\n\tif s.maxAutoHeight > 0 {\n\t\tif height <= s.maxAutoHeight {\n\t\t\ts.SetContentHeight(height)\n\t\t}\n\t}\n}", "func (v *ScrolledWindow) GetPropagateNaturalHeight() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_height(v.native())\n\treturn gobool(c)\n}", "func (s *Artwork) SetMaxWidth(v string) *Artwork {\n\ts.MaxWidth = &v\n\treturn s\n}", "func (v *MailView) GetMaxLines() (int, error) {\n\treturn len(v.lines), nil\n}", "func (o *Content) GetMaxConnsPerProcess() int32 {\n\tif o == nil || o.MaxConnsPerProcess.Get() == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.MaxConnsPerProcess.Get()\n}", "func (self *TraitPixbuf) GetWidth() (return__ int) {\n\tvar __cgo__return__ C.int\n\t__cgo__return__ = C.gdk_pixbuf_get_width(self.CPointer)\n\treturn__ = int(__cgo__return__)\n\treturn\n}", "func WindowContent(append ...bool) vecty.Markup {\n\treturn AddClass(wContent, append...)\n}", "func (me *XsdGoPkgHasElems_MaxWidth) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElems_MaxWidth; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (s *Sliding) MaxSize() int {\n\treturn s.maxSize\n}", "func (v *TextView) GetBorderWindowSize(tp TextWindowType) int {\n\treturn int(C.gtk_text_view_get_border_window_size(v.native(), C.GtkTextWindowType(tp)))\n}", "func (w *WidgetImplement) Width() int {\n\treturn w.w\n}", "func (s *Thumbnails) SetMaxWidth(v string) *Thumbnails {\n\ts.MaxWidth = &v\n\treturn s\n}", "func (w *Window) Width() int {\n\treturn int(C.ANativeWindow_getWidth(w.cptr()))\n}", "func (v *Pixbuf) GetWidth() int {\n\treturn int(C.gdk_pixbuf_get_width(v.Native()))\n}", "func (m *Model) GetMaxHeight() int {\n\treturn m.maxHeight\n}", "func (k *Kernel) MaxX() int {\n\treturn k.Width\n}", "func (win *Window) Maximize() {\n\twin.Candy().Guify(\"gtk_window_maximize\", win)\n}", "func (p *partitionImpl) GetMaxRows() int {\n\treturn int(p.internalData.MaxRows)\n}", "func (win *Window) Width() int {\n\tsize := C.sfRenderWindow_getSize(win.win)\n\treturn int(size.x)\n}", "func (w *Whisper) MaxMessageSize() uint32 {\n\tval, _ := w.settings.Load(maxMsgSizeIdx)\n\treturn val.(uint32)\n}", "func (w *Window) Width() int {\n\treturn w.width\n}", "func (v *ScrolledWindow) SetPropagateNaturalWidth(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_width(v.native(), gbool(propagate))\n}", "func (me *XsdGoPkgHasElem_MaxWidth) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElem_MaxWidth; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (e Event) GetResizeWidth() int {\n\treturn int(C.caca_get_event_resize_width(e.Ev))\n}", "func (r *SlidingWindow) Max() int {return r.base + len(r.values) - 1}", "func (Empty) MaxHeight(width, height int) int {\n\treturn 1\n}", "func (s *PresetWatermark) SetMaxWidth(v string) *PresetWatermark {\n\ts.MaxWidth = &v\n\treturn s\n}", "func (s *ItemScroller) maxFirst() int {\n\n\t// Vertical scroller\n\tif s.vert {\n\t\tvar height float32\n\t\tpos := len(s.items) - 1\n\t\tif pos < 0 {\n\t\t\treturn 0\n\t\t}\n\t\tfor {\n\t\t\titem := s.items[pos]\n\t\t\theight += item.GetPanel().Height()\n\t\t\tif height > s.Height() {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tpos--\n\t\t\tif pos < 0 {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\treturn pos + 1\n\t}\n\n\t// Horizontal scroller\n\tvar width float32\n\tpos := len(s.items) - 1\n\tif pos < 0 {\n\t\treturn 0\n\t}\n\tfor {\n\t\titem := s.items[pos]\n\t\twidth += item.GetPanel().Width()\n\t\tif width > s.Width() {\n\t\t\tbreak\n\t\t}\n\t\tpos--\n\t\tif pos < 0 {\n\t\t\tbreak\n\t\t}\n\t}\n\treturn pos + 1\n}", "func (m *MailTips) GetMaxMessageSize()(*int32) {\n val, err := m.GetBackingStore().Get(\"maxMessageSize\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*int32)\n }\n return nil\n}", "func (m Logon) GetMaxMessageSize() (v int, err quickfix.MessageRejectError) {\n\tvar f field.MaxMessageSizeField\n\tif err = m.Get(&f); err == nil {\n\t\tv = f.Value()\n\t}\n\treturn\n}", "func (x *TextDocumentContentChangeEvent_ContentChangeEvent) GetRangeLength() int32 {\n\tif x != nil {\n\t\treturn x.RangeLength\n\t}\n\treturn 0\n}", "func (s *settings) GetMaxWriteSize() uint {\n\treturn s.wMaxSize\n}", "func GetMaxColumns() int {\r\n\treturn converter.StrToInt(SysString(MaxColumns))\r\n}", "func (sc *slidingCounter) Max() float64 {\n\n\tnow := time.Now().Unix()\n\n\tsc.mutex.RLock()\n\tdefer sc.mutex.RUnlock()\n\n\tvar max float64\n\n\tfor timestamp, window := range sc.windows {\n\t\tif timestamp >= now-sc.interval {\n\t\t\tif window.Value > max {\n\t\t\t\tmax = window.Value\n\t\t\t}\n\t\t}\n\t}\n\treturn max\n}", "func (pb *Bar) SetMaxWidth(maxWidth int) *Bar {\n\tpb.mu.Lock()\n\tpb.maxWidth = maxWidth\n\tpb.mu.Unlock()\n\treturn pb\n}", "func (b *Buffer) SizeMax() (int, int) {\n\treturn b.maxWidth, b.maxHeight\n}", "func GxOuterWidth(value float64) *SimpleElement { return newSEFloat(\"gx:outerWidth\", value) }", "func (gq *Dispatch) MaxLen() int {\n return gq.maxlength\n}", "func (i *ImageBuf) XMax() int {\n\tret := int(C.ImageBuf_xmax(i.ptr))\n\truntime.KeepAlive(i)\n\treturn ret\n}", "func (w *MainWindow) GetSize() (int, int) {\n\treturn w.glfwWindow.GetSize()\n}", "func (pb *Bar) Width() (width int) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\twidth = defaultBarWidth\n\t\t}\n\t}()\n\tpb.mu.RLock()\n\twidth = pb.width\n\tmaxWidth := pb.maxWidth\n\tpb.mu.RUnlock()\n\tif width <= 0 {\n\t\tvar err error\n\t\tif width, err = terminalWidth(); err != nil {\n\t\t\treturn defaultBarWidth\n\t\t}\n\t}\n\tif maxWidth > 0 && width > maxWidth {\n\t\twidth = maxWidth\n\t}\n\treturn\n}", "func (w *Window) Maximized() bool {\n\treturn w.maximized\n}", "func (mw *MaxWriter) Max() int {\n\treturn mw.max\n}", "func (s *Service) onWindowResize(channel chan os.Signal) {\n\t//stdScr, _ := gc.Init()\n\t//stdScr.ScrollOk(true)\n\t//gc.NewLines(true)\n\tfor {\n\t\t<-channel\n\t\t//gc.StdScr().Clear()\n\t\t//rows, cols := gc.StdScr().MaxYX()\n\t\tcols, rows := GetScreenSize()\n\t\ts.screenRows = rows\n\t\ts.screenCols = cols\n\t\ts.resizeWindows()\n\t\t//gc.End()\n\t\t//gc.Update()\n\t\t//gc.StdScr().Refresh()\n\t}\n}", "func (win *Window) Height() int {\n\tsize := C.sfRenderWindow_getSize(win.win)\n\treturn int(size.y)\n}", "func (w *WidgetImplement) FixedHeight() int {\n\treturn w.fixedH\n}", "func (me XsdGoPkgHasElems_MaxSnippetLines) MaxSnippetLinesDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"2\")\r\n\treturn *x\r\n}", "func (me XsdGoPkgHasElems_MaxHeight) MaxHeightDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (w *Window) Height() int {\n\treturn int(C.ANativeWindow_getHeight(w.cptr()))\n}", "func (c *Config) MaxHeight() int {\n\tc.Mutex.RLock()\n\tdefer c.Mutex.RUnlock()\n\treturn c.Raw.MaxHeight\n}", "func (ch *clientSecureChannel) MaxMessageSize() uint32 {\n\treturn ch.maxMessageSize\n}", "func MaxBytesHandler(h Handler, n int64) Handler {\n\treturn HandlerFunc(func(w ResponseWriter, r *Request) {\n\t\tr2 := *r\n\t\tr2.Body = MaxBytesReader(w, r.Body, n)\n\t\th.ServeHTTP(w, &r2)\n\t})\n}", "func PopItemWidth() {\n\timgui.PopItemWidth()\n}", "func (w *WebviewWindow) Size() (width int, height int) {\n\tif w.impl == nil {\n\t\treturn 0, 0\n\t}\n\treturn w.impl.size()\n}", "func (opts CreateLargeOpts) LengthOfContent() (int64, error) {\n\treturn opts.ContentLength, nil\n}", "func (reader *Reader) GetMaxRows() int {\n\treturn reader.MaxRows\n}", "func (self *TraitPixbufAnimation) GetWidth() (return__ int) {\n\tvar __cgo__return__ C.int\n\t__cgo__return__ = C.gdk_pixbuf_animation_get_width(self.CPointer)\n\treturn__ = int(__cgo__return__)\n\treturn\n}", "func (sf *TWindow) Maximized() bool {\n\treturn sf.maximized\n}", "func GetWindowText(hwnd syscall.Handle, str *uint16, maxCount int32) (len int32, err error) {\n\tr0, _, e1 := syscall.Syscall(getWindowTextW.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(str)), uintptr(maxCount))\n\tlen = int32(r0)\n\tif len == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}", "func (b *BoundingBox) MaxDim() int {\n\treturn b.LongestAxis()\n}", "func (w *ScrollWidget) SetMax(max int) {\n\tw.max = max\n\tw.clampCurrent()\n}", "func (arg1 *UConverter) GetMaxCharSize() int", "func (s *Stat) MaxConns() int32 {\n\treturn s.s.MaxResources()\n}", "func (me XsdGoPkgHasAttr_MaxLines_XsdtInt_2) MaxLinesDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"2\")\r\n\treturn *x\r\n}", "func (f *Frame) MaxLine() int {\n\treturn f.maxlines\n}", "func (v *Entry) SetMaxWidthChars(nChars int) {\n\tC.gtk_entry_set_max_width_chars(v.native(), C.gint(nChars))\n}", "func (me XsdGoPkgHasElem_MaxHeight) MaxHeightDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (me XsdGoPkgHasElem_MaxSnippetLines) MaxSnippetLinesDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"2\")\r\n\treturn *x\r\n}", "func (b *BlockSplitterSimple) MaxSize() int64 {\n\treturn b.maxSize\n}", "func (w *Window) Height() int {\n\treturn w.height\n}", "func (s *VideoParameters) SetMaxWidth(v string) *VideoParameters {\n\ts.MaxWidth = &v\n\treturn s\n}", "func (o *Content) GetMaxProcesses() int32 {\n\tif o == nil || o.MaxProcesses.Get() == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.MaxProcesses.Get()\n}", "func (f *Framebuffer) Height() int { return f.fb.Bounds().Max.Y }", "func MaxBytesReader(w ResponseWriter, r io.ReadCloser, n int64) io.ReadCloser {\n\treturn &maxBytesReader{respWriter: w, readCloser: r, bytesRemaining: n}\n}", "func (fb *FlowBox) GetMinChildrenPerLine() uint {\n\tc := C.gtk_flow_box_get_min_children_per_line(fb.native())\n\treturn uint(c)\n}", "func (me *XsdGoPkgHasElems_MaxSnippetLines) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElems_MaxSnippetLines; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}" ]
[ "0.7802157", "0.7460506", "0.66026855", "0.6217259", "0.584643", "0.57835525", "0.5716844", "0.56006247", "0.5530119", "0.5475368", "0.5411298", "0.538574", "0.53694135", "0.53360945", "0.53360945", "0.5301836", "0.52574384", "0.52144426", "0.5204811", "0.51416606", "0.5120838", "0.5119741", "0.5087488", "0.50335157", "0.50302064", "0.5029908", "0.5024163", "0.50205815", "0.49583992", "0.4925541", "0.49234462", "0.49213174", "0.490938", "0.49038583", "0.48488557", "0.48484865", "0.48480392", "0.48331538", "0.48244518", "0.48236427", "0.4796644", "0.47856373", "0.47772756", "0.47754163", "0.4774625", "0.47601423", "0.47505862", "0.47237784", "0.47187942", "0.47128463", "0.4708767", "0.46919698", "0.469095", "0.46898538", "0.46743664", "0.46739495", "0.46596548", "0.4649409", "0.46471497", "0.46447363", "0.46384957", "0.4638242", "0.46370506", "0.46347556", "0.46330276", "0.46196422", "0.46136573", "0.46005213", "0.45970035", "0.45960668", "0.45863986", "0.45848474", "0.45819688", "0.4572614", "0.45722878", "0.45718482", "0.45712623", "0.45608884", "0.45580134", "0.45431814", "0.45305997", "0.45272973", "0.452251", "0.4521219", "0.45200998", "0.45171893", "0.45162585", "0.4503006", "0.44998652", "0.4498968", "0.4498721", "0.4498412", "0.4495319", "0.44840777", "0.44822595", "0.4474918", "0.4466484", "0.44645673", "0.4449208", "0.44485673" ]
0.8826436
0
SetMaxContentWidth is a wrapper around gtk_scrolled_window_set_max_content_width().
func (v *ScrolledWindow) SetMaxContentWidth(width int) { C.gtk_scrolled_window_set_max_content_width(v.native(), C.gint(width)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *ScrolledWindow) SetMaxContentHeight(width int) {\n\tC.gtk_scrolled_window_set_max_content_height(v.native(), C.gint(width))\n}", "func (v *ScrolledWindow) GetMaxContentWidth() int {\n\tc := C.gtk_scrolled_window_get_max_content_width(v.native())\n\treturn int(c)\n}", "func (v *ScrolledWindow) GetMaxContentHeight() int {\n\tc := C.gtk_scrolled_window_get_max_content_height(v.native())\n\treturn int(c)\n}", "func SetScrollContentTrackerSize(sa *qtwidgets.QScrollArea) {\n\twgt := sa.Widget()\n\tsa.InheritResizeEvent(func(arg0 *qtgui.QResizeEvent) {\n\t\tosz := arg0.OldSize()\n\t\tnsz := arg0.Size()\n\t\tif false {\n\t\t\tlog.Println(osz.Width(), osz.Height(), nsz.Width(), nsz.Height())\n\t\t}\n\t\tif osz.Width() != nsz.Width() {\n\t\t\twgt.SetMaximumWidth(nsz.Width())\n\t\t}\n\t\t// this.ScrollArea_2.ResizeEvent(arg0)\n\t\targ0.Ignore() // I ignore, you handle it. replace explict call parent's\n\t})\n}", "func (p *pageT) WidthMax(s string) {\n\tp.Style = css.NewStylesResponsive(p.Style)\n\tp.Style.Desktop.StyleBox.WidthMax = s\n\tp.Style.Mobile.StyleBox.WidthMax = \"calc(100% - 1.2rem)\" // 0.6rem margin-left and -right in mobile view\n}", "func (v *ScrolledWindow) SetPropagateNaturalWidth(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_width(v.native(), gbool(propagate))\n}", "func (gr *groupT) WidthMax(s string) {\n\tgr.Style = css.NewStylesResponsive(gr.Style)\n\tgr.Style.Desktop.StyleBox.WidthMax = s\n\tgr.Style.Mobile.StyleBox.WidthMax = \"none\" // => 100% of page - page has margins; replaced desktop max-width\n}", "func (pb *Bar) SetMaxWidth(maxWidth int) *Bar {\n\tpb.mu.Lock()\n\tpb.maxWidth = maxWidth\n\tpb.mu.Unlock()\n\treturn pb\n}", "func (w *ScrollWidget) SetMax(max int) {\n\tw.max = max\n\tw.clampCurrent()\n}", "func (v *Entry) SetMaxWidthChars(nChars int) {\n\tC.gtk_entry_set_max_width_chars(v.native(), C.gint(nChars))\n}", "func (wg *WidgetImplement) SetFixedWidth(w int) {\n\twg.fixedW = w\n}", "func (wg *WidgetImplement) SetFixedSize(w, h int) {\n\twg.fixedW = w\n\twg.fixedH = h\n}", "func (v *ScrolledWindow) SetPropagateNaturalHeight(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_height(v.native(), gbool(propagate))\n}", "func (win *Window) SetDefaultSize(width, height int) {\n\twin.Candy().Guify(\"gtk_window_set_default_size\", win, width, height)\n}", "func (c *HostClient) SetMaxConns(newMaxConns int) {\n\tc.connsLock.Lock()\n\tc.MaxConns = newMaxConns\n\tc.connsLock.Unlock()\n}", "func (s *ItemScroller) autoSize() {\n\n\tif s.maxAutoWidth == 0 && s.maxAutoHeight == 0 {\n\t\treturn\n\t}\n\n\tvar width float32\n\tvar height float32\n\tfor _, item := range s.items {\n\t\tpanel := item.GetPanel()\n\t\tif panel.Width() > width {\n\t\t\twidth = panel.Width()\n\t\t}\n\t\theight += panel.Height()\n\t}\n\n\t// If auto maximum width enabled\n\tif s.maxAutoWidth > 0 {\n\t\tif width <= s.maxAutoWidth {\n\t\t\ts.SetContentWidth(width)\n\t\t}\n\t}\n\t// If auto maximum height enabled\n\tif s.maxAutoHeight > 0 {\n\t\tif height <= s.maxAutoHeight {\n\t\t\ts.SetContentHeight(height)\n\t\t}\n\t}\n}", "func (w *WidgetBase) SetWidth(width int) {\n\tw.size.X = width\n\tif w.size.X != 0 {\n\t\tw.sizePolicyX = Minimum\n\t} else {\n\t\tw.sizePolicyX = Expanding\n\t}\n}", "func (w *Window) SetMaximized(maximize bool) {\n\tif maximize == w.maximized {\n\t\treturn\n\t}\n\n\tif maximize {\n\t\tw.origX, w.origY = w.Pos()\n\t\tw.origWidth, w.origHeight = w.Size()\n\t\tw.maximized = true\n\t\tw.SetPos(0, 0)\n\t\twidth, height := ScreenSize()\n\t\tw.SetSize(width, height)\n\t} else {\n\t\tw.maximized = false\n\t\tw.SetPos(w.origX, w.origY)\n\t\tw.SetSize(w.origWidth, w.origHeight)\n\t}\n\tw.ResizeChildren()\n\tw.PlaceChildren()\n}", "func (win *Window) Maximize() {\n\twin.Candy().Guify(\"gtk_window_maximize\", win)\n}", "func (sf *TWindow) SetMaximized(maximize bool) {\n\tif maximize == sf.maximized {\n\t\treturn\n\t}\n\n\tif maximize {\n\t\tx, y := sf.pos.Get()\n\t\tsf.posOrig.X().Set(x)\n\t\tsf.posOrig.Y().Set(y)\n\t\tsf.origWidth, sf.origHeight = sf.Size()\n\t\tsf.maximized = true\n\t\tsf.SetPos(0, 0)\n\t\twidth, height := ScreenSize()\n\t\tsf.SetSize(width, height)\n\t} else {\n\t\tsf.maximized = false\n\t\tsf.SetPos(sf.posOrig.GetX(), sf.posOrig.GetY())\n\t\tsf.SetSize(sf.origWidth, sf.origHeight)\n\t}\n\tsf.ResizeChildren()\n\tsf.PlaceChildren()\n}", "func (win *Window) SetWindowContentScaleCallback(callback WindowContentScaleCallback) WindowContentScaleCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.ContentScaleCallback\n\tcallbacks.ContentScaleCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowContentScaleCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowContentScaleCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (me XsdGoPkgHasElems_MaxWidth) MaxWidthDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (st *Settings) SetMaxWindowSize(size uint32) {\n\tst.windowSize = size\n}", "func (st *Settings) SetMaxWindowSize(size uint32) {\n\tst.windowSize = size\n}", "func (wg *WidgetImplement) SetWidth(w int) {\n\twg.w = w\n}", "func (s *Artwork) SetMaxWidth(v string) *Artwork {\n\ts.MaxWidth = &v\n\treturn s\n}", "func (me XsdGoPkgHasElem_MaxWidth) MaxWidthDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (v *Entry) GetMaxWidthChars() int {\n\tc := C.gtk_entry_get_max_width_chars(v.native())\n\treturn int(c)\n}", "func (w *WidgetImplement) SetClampWidth(clamp bool) {\n\tw.clamp[0] = clamp\n}", "func (m *MailTips) SetMaxMessageSize(value *int32)() {\n err := m.GetBackingStore().Set(\"maxMessageSize\", value)\n if err != nil {\n panic(err)\n }\n}", "func (s *Thumbnails) SetMaxWidth(v string) *Thumbnails {\n\ts.MaxWidth = &v\n\treturn s\n}", "func (v *TextView) SetBorderWindowSize(tp TextWindowType, size int) {\n\tC.gtk_text_view_set_border_window_size(v.native(), C.GtkTextWindowType(tp), C.gint(size))\n}", "func (s *ItemScroller) SetAutoWidth(maxWidth float32) {\n\n\ts.maxAutoWidth = maxWidth\n}", "func getContentWidth(pdf *gofpdf.Fpdf) float64 {\n\tmarginL, _, marginR, _ := pdf.GetMargins()\n\tpageW, _ := pdf.GetPageSize()\n\twidth := pageW - marginL - marginR\n\treturn width\n}", "func WindowContent(append ...bool) vecty.Markup {\n\treturn AddClass(wContent, append...)\n}", "func (s *PresetWatermark) SetMaxWidth(v string) *PresetWatermark {\n\ts.MaxWidth = &v\n\treturn s\n}", "func (win *Window) SetResizable(resizable bool) {\n\twin.Candy().Guify(\"gtk_window_set_resizable\", win, resizable)\n}", "func (win *Window) ReshowWithInitialSize() {\n\twin.Candy().Guify(\"gtk_window_reshow_with_initial_size\", win)\n}", "func (wp Wordpiece) SetMaxWordChars(c int) {\n\twp.maxWordChars = c\n}", "func (client *GatewayClient) SetMaxConns(m int) {\n\tclient.maxOpen = m\n\n}", "func (v *ScrolledWindow) GetPropagateNaturalWidth() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_width(v.native())\n\treturn gobool(c)\n}", "func (me *XsdGoPkgHasElems_MaxWidth) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElems_MaxWidth; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (s *Service) onWindowResize(channel chan os.Signal) {\n\t//stdScr, _ := gc.Init()\n\t//stdScr.ScrollOk(true)\n\t//gc.NewLines(true)\n\tfor {\n\t\t<-channel\n\t\t//gc.StdScr().Clear()\n\t\t//rows, cols := gc.StdScr().MaxYX()\n\t\tcols, rows := GetScreenSize()\n\t\ts.screenRows = rows\n\t\ts.screenCols = cols\n\t\ts.resizeWindows()\n\t\t//gc.End()\n\t\t//gc.Update()\n\t\t//gc.StdScr().Refresh()\n\t}\n}", "func (w Widths) MaxWidth() (maxWidth, wideDepth int) {\n\tfor depth, width := range w {\n\t\tif width > maxWidth {\n\t\t\tmaxWidth = width\n\t\t\twideDepth = depth\n\t\t}\n\t}\n\treturn\n}", "func (s *settings) SetMaxWriteSize(size uint) {\n\ts.wMaxSize = size\n}", "func maxWidth(no_lines int, widthFromLineNo widthFunc) int {\n\tvar max int\n\tfor i := 0; i < no_lines; i++ {\n\t\tval := widthFromLineNo(i)\n\t\tif val > max {\n\t\t\tmax = val\n\t\t}\n\t}\n\treturn max\n}", "func (s *VideoParameters) SetMaxWidth(v string) *VideoParameters {\n\ts.MaxWidth = &v\n\treturn s\n}", "func (w *WidgetImplement) FixedWidth() int {\n\treturn w.fixedW\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func (w *Whisper) SetMaxMessageSize(size uint32) error {\n\tif size > MaxMessageSize {\n\t\treturn fmt.Errorf(\"message size too large [%d>%d]\", size, MaxMessageSize)\n\t}\n\tw.settings.Store(maxMsgSizeIdx, size)\n\treturn nil\n}", "func (ufc *UIOverlayContainer) SetContent(npp Frame, setup []UILayoutElement) {\n\tif ufc._state != nil {\n\t\tfor _, v := range ufc._state {\n\t\t\tufc.ThisUILayoutElementComponentDetails.Detach(v)\n\t\t}\n\t}\n\tufc._state = setup\n\tufc._framing = npp\n\tufc.ThisUIPanelDetails.Clipping = npp.FyFClipping()\n\tfor _, v := range setup {\n\t\tufc.ThisUILayoutElementComponentDetails.Attach(v)\n\t}\n\tufc.FyLSubelementChanged()\n}", "func (c *DirentCache) setMaxSize(max uint64) {\n\tc.mu.Lock()\n\tc.maxSize = max\n\tc.maybeShrink()\n\tc.mu.Unlock()\n}", "func (w *LWindow) MWidth() int32 {\n\treturn w.mWidth\n}", "func (s *RedisStore) SetMaxLength(l int) {\n\tif l >= 0 {\n\t\ts.maxLength = l\n\t}\n}", "func (sf *TWindow) SetSizable(sizable bool) {\n\tsf.fixedSize = !sizable\n}", "func (fb *FlowBox) SetMaxChildrenPerLine(n_children uint) {\n\tC.gtk_flow_box_set_max_children_per_line(fb.native(), C.guint(n_children))\n}", "func (conn *Conn) SetMaxTopics(max int) {\n\tif max < 1 {\n\t\tmax = 50\n\t}\n\tconn.length = max\n}", "func (m *WorkbookCommentReply) SetContent(value *string)() {\n m.content = value\n}", "func (me *XsdGoPkgHasElem_MaxWidth) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElem_MaxWidth; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (m Logon) SetMaxMessageSize(v int) {\n\tm.Set(field.NewMaxMessageSize(v))\n}", "func (_m *RediStore) SetMaxLength(l int) {\n\t_m.Called(l)\n}", "func (v *Value) MaxWidth(offset, tab int) int {\n\t// simple values do not have tabulations\n\twidth := v.Width\n\tfor l := 0; l < len(v.Tabs); l++ {\n\t\twidth = max(width, v.LineWidth(l, offset, tab))\n\t}\n\treturn width\n}", "func (me XsdGoPkgHasAttr_MaxLines_XsdtInt_2) MaxLinesDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"2\")\r\n\treturn *x\r\n}", "func (me XsdGoPkgHasElems_MaxSnippetLines) MaxSnippetLinesDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"2\")\r\n\treturn *x\r\n}", "func (p *Policy) setMaxBlockSize(ic *interop.Context, args []stackitem.Item) stackitem.Item {\n\tvalue := uint32(toBigInt(args[0]).Int64())\n\tif value > payload.MaxSize {\n\t\tpanic(fmt.Errorf(\"MaxBlockSize cannot be more than the maximum payload size = %d\", payload.MaxSize))\n\t}\n\tok, err := p.checkValidators(ic)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif !ok {\n\t\treturn stackitem.NewBool(false)\n\t}\n\tp.lock.Lock()\n\tdefer p.lock.Unlock()\n\terr = p.setUint32WithKey(ic.DAO, maxBlockSizeKey, value)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tp.isValid = false\n\treturn stackitem.NewBool(true)\n}", "func (g *Grid) SetWidth(w int) { g.Width = w }", "func (v *DCHttpClient) SetMaxConnsPerHost(size int) {\n\tv.Transport.MaxConnsPerHost = size\n}", "func (store *RedisStore) SetMaxLength(l int) {\r\n\tif l >= 0 {\r\n\t\tstore.maxLength = l\r\n\t}\r\n}", "func (win *Window) SetPolicy(allowShrink, allowGrow, autoShrink int) {\n\twin.Candy().Guify(\"gtk_window_set_policy\", win, allowShrink, allowGrow, autoShrink)\n}", "func MaxOpenConns(moc int) Option {\n\treturn func(o *options) {\n\t\to.maxOpenConns = moc\n\t}\n}", "func SetMaxDeltaSchemaCount(cnt int64) {\n\tatomic.StoreInt64(&maxDeltaSchemaCount, cnt)\n}", "func (this *FeedableBuffer) Maximize() {\n\tthis.ExpandTo(this.maxByteCount)\n}", "func (db *DB) SetMaxOpenConns(n int) {\n\tdb.master.SetMaxOpenConns(n)\n\tfor _, r := range db.readreplicas {\n\t\tr.SetMaxOpenConns(n)\n\t}\n}", "func (me XsdGoPkgHasElem_MaxSnippetLines) MaxSnippetLinesDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"2\")\r\n\treturn *x\r\n}", "func (label *LabelWidget) SetContent(content string) {\n\tlabel.content = content\n\tlabel.needsRepaint = true\n}", "func (t *Terminal) Resize(s fyne.Size) {\n\tif s.Width == t.Size().Width && s.Height == t.Size().Height {\n\t\treturn\n\t}\n\tif s.Width < 20 { // not sure why we get tiny sizes\n\t\treturn\n\t}\n\tt.BaseWidget.Resize(s)\n\tt.content.Resize(s)\n\n\tcellSize := t.guessCellSize()\n\toldRows := int(t.config.Rows)\n\n\tt.config.Columns = uint(math.Floor(float64(s.Width) / float64(cellSize.Width)))\n\tt.config.Rows = uint(math.Floor(float64(s.Height) / float64(cellSize.Height)))\n\tif t.scrollBottom == 0 || t.scrollBottom == oldRows-1 {\n\t\tt.scrollBottom = int(t.config.Rows) - 1\n\t}\n\tt.onConfigure()\n\n\tgo t.updatePTYSize()\n}", "func (self *CellRenderer) GetFixedSize() (width, height int) {\n\tvar w C.gint\n\tvar h C.gint\n\tC.gtk_cell_renderer_get_fixed_size(self.object, &w, &h)\n\n\twidth = int(w)\n\theight = int(h)\n\treturn\n}", "func (o AutoscalingPolicyScaleInControlOutput) MaxScaledInReplicas() FixedOrPercentPtrOutput {\n\treturn o.ApplyT(func(v AutoscalingPolicyScaleInControl) *FixedOrPercent { return v.MaxScaledInReplicas }).(FixedOrPercentPtrOutput)\n}", "func (w *Window) SetSize(width, height int) {\n\tif w.closed {\n\t\treturn\n\t}\n\n\tw.width, w.height = width, height\n\tif w.lockedSize {\n\t\tw.updateSizeHints()\n\t}\n\tw.win.Resize(width, height)\n\treturn\n}", "func MaxMessageSize(size int64) Option {\n\tif size < 0 {\n\t\tpanic(\"size must be non-negative\")\n\t}\n\treturn func(ws *websocket) {\n\t\tws.options.maxMessageSize = size\n\t}\n}", "func wmFreeformResize(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device) error {\n\tact, err := arc.NewActivity(a, wm.Pkg24, wm.ResizableUnspecifiedActivity)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer act.Close()\n\tif err := act.StartWithDefaultOptions(ctx, tconn); err != nil {\n\t\treturn err\n\t}\n\tdefer act.Stop(ctx, tconn)\n\tif err := wm.WaitUntilActivityIsReady(ctx, tconn, act, d); err != nil {\n\t\treturn err\n\t}\n\n\twindow, err := ash.GetARCAppWindowInfo(ctx, tconn, act.PackageName())\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Resizable apps are launched in maximized in P.\n\tif window.State != ash.WindowStateNormal {\n\t\tif ws, err := ash.SetARCAppWindowState(ctx, tconn, act.PackageName(), ash.WMEventNormal); err != nil {\n\t\t\treturn err\n\t\t} else if ws != ash.WindowStateNormal {\n\t\t\treturn errors.Errorf(\"failed to set window state: got %s, want %s\", ws, ash.WindowStateNormal)\n\t\t}\n\t\tif err := ash.WaitForARCAppWindowState(ctx, tconn, act.PackageName(), ash.WindowStateNormal); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := ash.WaitWindowFinishAnimating(ctx, tconn, window.ID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tdispMode, err := ash.PrimaryDisplayMode(ctx, tconn)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdispInfo, err := display.GetPrimaryInfo(ctx, tconn)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmaxBounds := coords.ConvertBoundsFromDPToPX(dispInfo.Bounds, dispMode.DeviceScaleFactor)\n\n\tif ws, err := ash.SetARCAppWindowState(ctx, tconn, act.PackageName(), ash.WMEventNormal); err != nil {\n\t\treturn err\n\t} else if ws != ash.WindowStateNormal {\n\t\treturn errors.Errorf(\"failed to set window state: got %s, want %s\", ws, ash.WindowStateNormal)\n\t}\n\n\t// Now we grab the bounds from the restored app, and we try to resize it to its previous right margin.\n\torigBounds, err := act.WindowBounds(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// The -1 is needed to prevent injecting a touch event outside bounds.\n\tright := maxBounds.Left + maxBounds.Width - 1\n\ttesting.ContextLog(ctx, \"Resizing app to right margin = \", right)\n\tto := coords.NewPoint(right, origBounds.Top+origBounds.Height/2)\n\tif err := act.ResizeWindow(ctx, tconn, arc.BorderRight, to, 500*time.Millisecond); err != nil {\n\t\treturn err\n\t}\n\n\tbounds, err := act.WindowBounds(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// ResizeWindow() does not guarantee pixel-perfect resizing.\n\t// For this particular test, we are good as long as the window has been resized at least one pixel.\n\tif bounds.Width <= origBounds.Width {\n\t\ttesting.ContextLogf(ctx, \"Original bounds: %+v; resized bounds: %+v\", origBounds, bounds)\n\t\treturn errors.Errorf(\"invalid window width: got %d; want %d > %d\", bounds.Width, bounds.Width, origBounds.Width)\n\t}\n\treturn nil\n}", "func (canvas *CanvasWidget) SetWidth(width float64) {\n\tcanvas.box.width = width\n\tcanvas.fixedWidth = true\n\tcanvas.RequestReflow()\n}", "func (p *Page) MustWindowMaximize() *Page {\n\tp.e(p.SetWindow(&proto.BrowserBounds{\n\t\tWindowState: proto.BrowserWindowStateMaximized,\n\t}))\n\treturn p\n}", "func SetMaxNumberEntries(sz int) {\n\tC.hepevt_set_max_number_entries(C.int(sz))\n}", "func (o *VolumeInfinitevolAttributesType) SetMaxNamespaceConstituentSize(newValue SizeType) *VolumeInfinitevolAttributesType {\n\to.MaxNamespaceConstituentSizePtr = &newValue\n\treturn o\n}", "func MaxBytesHandler(h Handler, n int64) Handler {\n\treturn HandlerFunc(func(w ResponseWriter, r *Request) {\n\t\tr2 := *r\n\t\tr2.Body = MaxBytesReader(w, r.Body, n)\n\t\th.ServeHTTP(w, &r2)\n\t})\n}", "func (m *ItemsMutator) MaxLength(v int) *ItemsMutator {\n\tm.proxy.maxLength = &v\n\treturn m\n}", "func limitNumClients(f http.HandlerFunc, maxClients int) http.HandlerFunc {\n\tsema := make(chan struct{}, maxClients)\n\n\treturn func(w http.ResponseWriter, req *http.Request) {\n\t\tsema <- struct{}{}\n\t\tdefer func() { <-sema }()\n\t\tf(w, req)\n\t}\n}", "func (s *Swarm64) ChangeMaxStart(maxstart float64) {\n\ts.xmaxstart = maxstart\n}", "func (me *XsdGoPkgHasElems_MaxSnippetLines) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElems_MaxSnippetLines; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func SetMaxIdleConns(maxIdleConns int) {\n\tclient.SetMaxIdleConns(maxIdleConns)\n}", "func (_m *SQLDatabase) SetMaxOpenConns(n int) {\n\t_m.Called(n)\n}", "func MaxFadeExtent(value int) *SimpleElement { return newSEInt(\"maxFadeExtent\", value) }", "func (opts CreateLargeOpts) LengthOfContent() (int64, error) {\n\treturn opts.ContentLength, nil\n}", "func SetContent(x, y int, mainc rune, combc []rune, style tcell.Style) {\n\tif !Screen.CanDisplay(mainc, true) {\n\t\tmainc = '�'\n\t}\n\n\tScreen.SetContent(x, y, mainc, combc, style)\n\tif UseFake() && lastCursor.x == x && lastCursor.y == y {\n\t\tlastCursor.r = mainc\n\t\tlastCursor.style = style\n\t\tlastCursor.combc = combc\n\t}\n}", "func MaxValSize(max int) Option {\n\treturn func(lc *loadingCache) error {\n\t\tlc.maxValueSize = max\n\t\treturn nil\n\t}\n}", "func (client *GatewayClient) SetMaxIdleConns(m int) {\n\tclient.maxIdle = m\n\n\tpreviousIdleConns := client.idleConn\n\tclient.idleConn = make(chan *tls.Conn, m)\n\ti := 0\n\tfor c := range previousIdleConns {\n\t\tif i < m {\n\t\t\tclient.idleConn <- c\n\t\t\ti++\n\t\t} else {\n\t\t\t// close this idle connection\n\t\t\tclient.connCount--\n\t\t\tc.Close()\n\t\t}\n\t}\n\tclose(previousIdleConns)\n}", "func (q *Queue) SetMaxLen(maxLen int) {\n\tq.lock.Lock()\n\tdefer q.lock.Unlock()\n\n\tq.maxLen = maxLen\n}", "func (win *Window) SetMaximizeCallback(callback WindowMaximizeCallback) WindowMaximizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.MaximizeCallback\n\tcallbacks.MaximizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowMaximizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowMaximizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}" ]
[ "0.7728575", "0.7647834", "0.65633065", "0.6101868", "0.55851233", "0.5574874", "0.55399346", "0.54410404", "0.53355515", "0.5113834", "0.505512", "0.49563086", "0.49242747", "0.48697284", "0.48511386", "0.48052323", "0.47839496", "0.47761905", "0.4729902", "0.47225168", "0.47206512", "0.4715658", "0.4708544", "0.4708544", "0.46923223", "0.4670486", "0.46373826", "0.4600696", "0.45936435", "0.4566099", "0.45402616", "0.45166832", "0.45154002", "0.4506303", "0.44970232", "0.44772005", "0.44523853", "0.4429479", "0.4427718", "0.44258302", "0.43614694", "0.4324603", "0.43105912", "0.43083516", "0.4305787", "0.42898297", "0.42797884", "0.42793086", "0.42738026", "0.42738026", "0.42543343", "0.4252208", "0.42392388", "0.42179722", "0.42045847", "0.41984144", "0.41873664", "0.41622844", "0.41564888", "0.4155135", "0.41538814", "0.41269583", "0.41122562", "0.41044277", "0.40989605", "0.4088588", "0.40814978", "0.40585077", "0.4051298", "0.40488765", "0.40414363", "0.40352222", "0.40274778", "0.40188313", "0.4007019", "0.40029174", "0.39882478", "0.39879912", "0.39864808", "0.39833748", "0.39830422", "0.39762485", "0.39704978", "0.39647797", "0.39646563", "0.39640293", "0.39636022", "0.39630193", "0.39595956", "0.39350152", "0.3932592", "0.39258474", "0.3921016", "0.39208037", "0.3903169", "0.39005494", "0.38840917", "0.38829747", "0.38737765", "0.38736582" ]
0.8705722
0
GetMaxContentHeight is a wrapper around gtk_scrolled_window_get_max_content_height().
func (v *ScrolledWindow) GetMaxContentHeight() int { c := C.gtk_scrolled_window_get_max_content_height(v.native()) return int(c) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *ScrolledWindow) GetMaxContentWidth() int {\n\tc := C.gtk_scrolled_window_get_max_content_width(v.native())\n\treturn int(c)\n}", "func (v *ScrolledWindow) SetMaxContentHeight(width int) {\n\tC.gtk_scrolled_window_set_max_content_height(v.native(), C.gint(width))\n}", "func (v *ScrolledWindow) SetMaxContentWidth(width int) {\n\tC.gtk_scrolled_window_set_max_content_width(v.native(), C.gint(width))\n}", "func (g *GitStatusWidget) GetHeight() int {\n\treturn g.renderer.GetHeight()\n}", "func (c *Config) MaxHeight() int {\n\tc.Mutex.RLock()\n\tdefer c.Mutex.RUnlock()\n\treturn c.Raw.MaxHeight\n}", "func (v *Pixbuf) GetHeight() int {\n\treturn int(C.gdk_pixbuf_get_height(v.Native()))\n}", "func (self *TraitPixbuf) GetHeight() (return__ int) {\n\tvar __cgo__return__ C.int\n\t__cgo__return__ = C.gdk_pixbuf_get_height(self.CPointer)\n\treturn__ = int(__cgo__return__)\n\treturn\n}", "func (m *Model) GetMaxHeight() int {\n\treturn m.maxHeight\n}", "func (Empty) MaxHeight(width, height int) int {\n\treturn 1\n}", "func (panel *Panel) GetContentBody() string {\n\treturn tplBody\n}", "func (win *Window) Height() int {\n\tsize := C.sfRenderWindow_getSize(win.win)\n\treturn int(size.y)\n}", "func (me XsdGoPkgHasElems_MaxHeight) MaxHeightDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (me XsdGoPkgHasElem_MaxHeight) MaxHeightDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (self *TraitPixbufAnimation) GetHeight() (return__ int) {\n\tvar __cgo__return__ C.int\n\t__cgo__return__ = C.gdk_pixbuf_animation_get_height(self.CPointer)\n\treturn__ = int(__cgo__return__)\n\treturn\n}", "func (w *Window) Height() int {\n\treturn int(C.ANativeWindow_getHeight(w.cptr()))\n}", "func (e Event) GetResizeHeight() int {\n\treturn int(C.caca_get_event_resize_height(e.Ev))\n}", "func (w *WidgetImplement) FixedHeight() int {\n\treturn w.fixedH\n}", "func (rect *PdfRectangle) Height() float64 {\n\treturn math.Abs(rect.Ury - rect.Lly)\n}", "func (c *Canvas) Height() int {\n\treturn c.maxCorner.Y - c.minCorner.Y + 1\n}", "func (v *ScrolledWindow) GetPropagateNaturalHeight() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_height(v.native())\n\treturn gobool(c)\n}", "func (fb *FlowBox) GetMaxChildrenPerLine() uint {\n\tc := C.gtk_flow_box_get_max_children_per_line(fb.native())\n\treturn uint(c)\n}", "func (w *LWindow) MHeight() int32 {\n\treturn w.mHeight\n}", "func (f *Framebuffer) Height() int { return f.fb.Bounds().Max.Y }", "func (me *XsdGoPkgHasElems_MaxHeight) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElems_MaxHeight; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (w *Window) Height() int {\n\treturn w.height\n}", "func (o *os) GetMaxWindowSize() gdnative.Vector2 {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetMaxWindowSize()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_max_window_size\")\n\n\t// Call the parent method.\n\t// Vector2\n\tretPtr := gdnative.NewEmptyVector2()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewVector2FromPointer(retPtr)\n\treturn ret\n}", "func (me *XsdGoPkgHasElem_MaxHeight) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElem_MaxHeight; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (s *PageLayout) Height() float64 {\n\treturn s.height\n}", "func (window Window) InnerHeight() int {\n\treturn window.Get(\"innerHeight\").Int()\n}", "func (w *WidgetImplement) Height() int {\n\treturn w.h\n}", "func (o *GetMessagesAllOf) GetContent() interface{} {\n\tif o == nil {\n\t\tvar ret interface{}\n\t\treturn ret\n\t}\n\treturn o.Content\n}", "func (g *Grid) GetHeight() int {\n\treturn g.Height\n}", "func (r *ImageRef) GetPageHeight() int {\n\treturn vipsGetPageHeight(r.image)\n}", "func (self *CellRenderer) GetFixedSize() (width, height int) {\n\tvar w C.gint\n\tvar h C.gint\n\tC.gtk_cell_renderer_get_fixed_size(self.object, &w, &h)\n\n\twidth = int(w)\n\theight = int(h)\n\treturn\n}", "func (r Rectangle) Height() float64 {\n\treturn r.Max.Y - r.Min.Y\n}", "func (o *TileBounds) GetHeight() int32 {\n\tif o == nil || o.Height == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.Height\n}", "func (rc Rectangle) Height() int {\n\treturn rc.Bottom - rc.Top\n}", "func (data *Data) GetCntMinMaxHeight() (int, int, int, error) {\n\tdb, err := data.openDb()\n\tdefer data.closeDb(db)\n\tif err != nil {\n\t\tlog.Printf(\"data.openDb Error : %+v\", err)\n\t\treturn -1, -1, -1, err\n\t}\n\tvar cnt int\n\terr = db.QueryRow(\"SELECT COUNT(hash) FROM headers\").Scan(&cnt)\n\tif err != nil {\n\t\tlog.Printf(\"db.QueryRow Error : %+v\", err)\n\t\treturn -1, -1, -1, err\n\t}\n\tif cnt == 0 {\n\t\treturn cnt, -1, -1, nil\n\t}\n\tvar max int\n\tvar min int\n\terr = db.QueryRow(\"SELECT MIN(height), MAX(height) FROM headers\").Scan(&min, &max)\n\tif err != nil {\n\t\tlog.Printf(\"db.QueryRow Error : %+v\", err)\n\t\treturn -1, -1, -1, err\n\t}\n\treturn cnt, min, max, nil\n}", "func (m *MailTips) GetMaxMessageSize()(*int32) {\n val, err := m.GetBackingStore().Get(\"maxMessageSize\")\n if err != nil {\n panic(err)\n }\n if val != nil {\n return val.(*int32)\n }\n return nil\n}", "func (v *MailView) GetMaxLines() (int, error) {\n\treturn len(v.lines), nil\n}", "func (m Logon) GetMaxMessageSize() (v int, err quickfix.MessageRejectError) {\n\tvar f field.MaxMessageSizeField\n\tif err = m.Get(&f); err == nil {\n\t\tv = f.Value()\n\t}\n\treturn\n}", "func (b *BaseElement) GetHeight() int32 {\n\treturn b.h\n}", "func (o *Content) GetMaxConnsPerProcess() int32 {\n\tif o == nil || o.MaxConnsPerProcess.Get() == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.MaxConnsPerProcess.Get()\n}", "func (ch *clientSecureChannel) MaxMessageSize() uint32 {\n\treturn ch.maxMessageSize\n}", "func (o *Content) GetMaxProcesses() int32 {\n\tif o == nil || o.MaxProcesses.Get() == nil {\n\t\tvar ret int32\n\t\treturn ret\n\t}\n\treturn *o.MaxProcesses.Get()\n}", "func (p *PdfiumImplementation) FPDFBitmap_GetHeight(request *requests.FPDFBitmap_GetHeight) (*responses.FPDFBitmap_GetHeight, error) {\n\tp.Lock()\n\tdefer p.Unlock()\n\n\tbitmapHandle, err := p.getBitmapHandle(request.Bitmap)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\theight := C.FPDFBitmap_GetHeight(bitmapHandle.handle)\n\treturn &responses.FPDFBitmap_GetHeight{\n\t\tHeight: int(height),\n\t}, nil\n}", "func (p *PdfiumImplementation) FPDF_GetPageHeight(request *requests.FPDF_GetPageHeight) (*responses.FPDF_GetPageHeight, error) {\n\tp.Lock()\n\tdefer p.Unlock()\n\n\tpageHandle, err := p.loadPage(request.Page)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\theight := C.FPDF_GetPageHeight(pageHandle.handle)\n\n\treturn &responses.FPDF_GetPageHeight{\n\t\tPage: pageHandle.index,\n\t\tHeight: float64(height),\n\t}, nil\n}", "func (b *Buffer) SizeMax() (int, int) {\n\treturn b.maxWidth, b.maxHeight\n}", "func (v *TextView) GetBorderWindowSize(tp TextWindowType) int {\n\treturn int(C.gtk_text_view_get_border_window_size(v.native(), C.GtkTextWindowType(tp)))\n}", "func (pc PieChart) GetHeight() int {\n\tif pc.Height == 0 {\n\t\treturn DefaultChartWidth\n\t}\n\treturn pc.Height\n}", "func (b *BBox) MaxY() int64 {\n\treturn int64(b.handle.yMax)\n}", "func GetContent(url string, timeout uint) ([]byte, error) {\n\tresp, err := GetResp(url, timeout)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\treturn io.ReadAll(resp.Body)\n}", "func (r *ImageRef) PageHeight() int {\n\treturn vipsGetPageHeight(r.image)\n}", "func (msg *Message) GetContent() interface{} {\n\treturn msg.Content\n}", "func (s *Thumbnails) SetMaxHeight(v string) *Thumbnails {\n\ts.MaxHeight = &v\n\treturn s\n}", "func (p *Page) GetContent() string {\n\treturn p.Content\n}", "func (b *Bound) Height() float64 {\n\treturn b.ne.Y() - b.sw.Y()\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func SetScrollContentTrackerSize(sa *qtwidgets.QScrollArea) {\n\twgt := sa.Widget()\n\tsa.InheritResizeEvent(func(arg0 *qtgui.QResizeEvent) {\n\t\tosz := arg0.OldSize()\n\t\tnsz := arg0.Size()\n\t\tif false {\n\t\t\tlog.Println(osz.Width(), osz.Height(), nsz.Width(), nsz.Height())\n\t\t}\n\t\tif osz.Width() != nsz.Width() {\n\t\t\twgt.SetMaximumWidth(nsz.Width())\n\t\t}\n\t\t// this.ScrollArea_2.ResizeEvent(arg0)\n\t\targ0.Ignore() // I ignore, you handle it. replace explict call parent's\n\t})\n}", "func (s *Artwork) SetMaxHeight(v string) *Artwork {\n\ts.MaxHeight = &v\n\treturn s\n}", "func GetHeight(ctx Context) (int64, bool) {\n\tval, ok := ctx.Value(contextKeyHeight).(int64)\n\treturn val, ok\n}", "func Height() uint64 {\n\n\tglobalData.RLock()\n\tdefer globalData.RUnlock()\n\n\treturn globalData.height\n}", "func (Adapter MockPage) GetContent() (string, error) {\n\treturn Adapter.FakeContent, Adapter.ContentError\n}", "func (s *SimPDF) Height() float64 {\n\tif s.Page.IsLandscape {\n\t\treturn s.Page.Width\n\t}\n\treturn s.Page.Height\n}", "func (t *Link) GetHeight() (v int64) {\n\treturn *t.height.nonNegativeInteger\n\n}", "func (v *Entry) GetMaxWidthChars() int {\n\tc := C.gtk_entry_get_max_width_chars(v.native())\n\treturn int(c)\n}", "func (r *RepositoryContentResponse) GetContent() *RepositoryContent {\n\tif r == nil {\n\t\treturn nil\n\t}\n\treturn r.Content\n}", "func GetHeight(hostURL string, hostPort int) *bytes.Buffer {\n\treturn makeGetRequest(\"getheight\", hostURL, hostPort)\n}", "func (b *BlockSplitterSimple) MaxSize() int64 {\n\treturn b.maxSize\n}", "func (v *StackPanel) Height() int {\n\tif v.orientation == Vertical {\n\t\th := 0\n\t\tfor _, val := range v.heights {\n\t\t\th += val\n\t\t}\n\t\treturn h\n\t}\n\treturn v.height\n}", "func NewMaxMessageSize(val int) MaxMessageSizeField {\n\treturn MaxMessageSizeField{quickfix.FIXInt(val)}\n}", "func GetHeight() int {\n\treturn viper.GetInt(FlagHeight)\n}", "func (v *Version) GetContent(ctx context.Context) ([]byte, error) {\n\tlock := v.Chart.Space.SpaceManager.Lock.Get(v.Chart.Space.Name(), v.Chart.Name(), v.Number())\n\tif !lock.RLock(v.Chart.Space.SpaceManager.LockTimeout) {\n\t\treturn nil, ErrorLocking.Format(\"version\", v.Chart.Space.Name()+\"/\"+v.Chart.Name()+\"/\"+v.Number())\n\t}\n\tdefer lock.RUnlock()\n\tif err := v.Validate(ctx); err != nil {\n\t\treturn nil, err\n\t}\n\tpath := path.Join(v.Prefix, chartPackageName)\n\tdata, err := v.Chart.Space.SpaceManager.Backend.GetContent(ctx, path)\n\tif err != nil {\n\t\treturn nil, ErrorContentNotFound.Format(v.Prefix)\n\t}\n\treturn data, nil\n}", "func (cs ClientState) GetLatestHeight() uint64 {\n\treturn uint64(cs.Height)\n}", "func Height() int {\n\tws, err := getWinsize()\n\tif err != nil {\n\t\treturn -1\n\t}\n\treturn int(ws.Row)\n}", "func (b *IndexBuilder) ContentSize() uint32 {\n\t// Add the name too so we don't skip building index if we have\n\t// lots of empty files.\n\treturn b.contentEnd + b.nameEnd\n}", "func (cd *ContinueDecompress) MaxMessageSize() int {\n\treturn cd.maxMessageSize\n}", "func (t *Text) LinesHeight() int {\n\tpad := t.setter.opts.Padding\n\tif t.size.Y <= 0 {\n\t\treturn 0\n\t}\n\tif t.size.Y-2*pad <= 0 {\n\t\treturn t.size.Y\n\t}\n\ty := pad\n\tfor _, l := range t.lines {\n\t\th := l.h.Round()\n\t\tif y+h > t.size.Y-pad {\n\t\t\tbreak\n\t\t}\n\t\ty += h\n\t}\n\tif h := trailingNewlineHeight(t); h > 0 && y+h <= t.size.Y-pad {\n\t\ty += h\n\t}\n\treturn y + pad\n}", "func (d *DHCPv4) MaxMessageSize() (uint16, error) {\n\treturn GetUint16(OptionMaximumDHCPMessageSize, d.Options)\n}", "func (c RelativeConstraint) GetHeight() float32 {\n\treturn c.op(c.parent().GetHeight(), c.constant)\n}", "func (r *RepositoryContent) GetSize() int {\n\tif r == nil || r.Size == nil {\n\t\treturn 0\n\t}\n\treturn *r.Size\n}", "func (opts CreateLargeOpts) LengthOfContent() (int64, error) {\n\treturn opts.ContentLength, nil\n}", "func (api *ContentsAPI) GetContent(path string) (*Contents, error) {\n\treturn api.GetContentByRef(path, \"\")\n}", "func (s SectionHead) ContentLength() int {\n\treturn int(s.ByteLength) - binary.Size(s)\n}", "func MaxValSize(max int) Option {\n\treturn func(lc *memoryCache) error {\n\t\tlc.maxValueSize = max\n\t\treturn nil\n\t}\n}", "func GetContent(url string) ([]byte, error) {\n\tr, err := GetContentReader(url)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer r.Close()\n\treturn ioutil.ReadAll(r)\n}", "func (b *OGame) GetPageContent(vals url.Values) ([]byte, error) {\n\treturn b.WithPriority(taskRunner.Normal).GetPageContent(vals)\n}", "func (k *Kernel) MaxY() int {\n\treturn k.Height\n}", "func (p *Picture) GetHeight() int {\r\n\treturn p.pixelHeight\r\n}", "func MaxValSize(max int) Option {\n\treturn func(lc *loadingCache) error {\n\t\tlc.maxValueSize = max\n\t\treturn nil\n\t}\n}", "func (sc *slidingCounter) Max() float64 {\n\n\tnow := time.Now().Unix()\n\n\tsc.mutex.RLock()\n\tdefer sc.mutex.RUnlock()\n\n\tvar max float64\n\n\tfor timestamp, window := range sc.windows {\n\t\tif timestamp >= now-sc.interval {\n\t\t\tif window.Value > max {\n\t\t\t\tmax = window.Value\n\t\t\t}\n\t\t}\n\t}\n\treturn max\n}", "func (c *DataCache) GetHeight() uint32 {\n\tc.mtx.RLock()\n\tdefer c.mtx.RUnlock()\n\treturn c.height\n}", "func (w *Whisper) MaxMessageSize() uint32 {\n\tval, _ := w.settings.Load(maxMsgSizeIdx)\n\treturn val.(uint32)\n}", "func (h *HTTP) FetchContent() ([]byte, error) {\n\tresp, err := h.FetchResponse()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"HTTP error %d in %s: %s\", resp.StatusCode, h.name, resp.Status)\n\t}\n\n\treturn ioutil.ReadAll(resp.Body)\n}", "func (o *Content) HasMaxProcesses() bool {\n\tif o != nil && o.MaxProcesses.IsSet() {\n\t\treturn true\n\t}\n\n\treturn false\n}", "func getContentWidth(pdf *gofpdf.Fpdf) float64 {\n\tmarginL, _, marginR, _ := pdf.GetMargins()\n\tpageW, _ := pdf.GetPageSize()\n\twidth := pageW - marginL - marginR\n\treturn width\n}", "func (cc *ContinueCompress) MaxMessageSize() int {\n\treturn cc.maxMessageSize\n}", "func (a *Animation) GetHeight() float64 {\n\tif a == nil || a.Height == nil {\n\t\treturn 0.0\n\t}\n\treturn *a.Height\n}", "func (f *Face) Height() int {\n\treturn f.ypixels(int(f.handle.height))\n}" ]
[ "0.80224156", "0.738089", "0.6511789", "0.575716", "0.5734719", "0.5732532", "0.5663143", "0.55172205", "0.54255056", "0.5353016", "0.53288096", "0.5287494", "0.5258306", "0.5254579", "0.5203907", "0.5163954", "0.5143804", "0.51205325", "0.5093301", "0.50751376", "0.5039852", "0.50293154", "0.50232494", "0.50126517", "0.49878493", "0.49854538", "0.4975729", "0.49506602", "0.49327448", "0.49326104", "0.4931299", "0.49140152", "0.49071267", "0.48915324", "0.4878953", "0.48735708", "0.4835878", "0.4820916", "0.48152575", "0.48136342", "0.47977498", "0.47854257", "0.47692534", "0.47630528", "0.4762518", "0.4749553", "0.4732659", "0.47256452", "0.4719037", "0.4703761", "0.47025818", "0.4687691", "0.4674435", "0.46668965", "0.46535707", "0.46327305", "0.46283355", "0.46245983", "0.46245983", "0.46241927", "0.46175513", "0.4606927", "0.46067858", "0.46007338", "0.45959717", "0.4589484", "0.45881128", "0.45874497", "0.45824015", "0.45693672", "0.45677027", "0.456648", "0.45624888", "0.4559078", "0.4555476", "0.45550692", "0.45520267", "0.45516488", "0.45427206", "0.4541161", "0.4525813", "0.45241705", "0.4509971", "0.4508825", "0.4503322", "0.4502993", "0.44971365", "0.44891065", "0.44855464", "0.4483766", "0.4479248", "0.4479159", "0.44737756", "0.4471669", "0.44559172", "0.44490772", "0.44457135", "0.44376856", "0.44373876", "0.44294703" ]
0.9018182
0
SetMaxContentHeight is a wrapper around gtk_scrolled_window_set_max_content_height().
func (v *ScrolledWindow) SetMaxContentHeight(width int) { C.gtk_scrolled_window_set_max_content_height(v.native(), C.gint(width)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *ScrolledWindow) SetMaxContentWidth(width int) {\n\tC.gtk_scrolled_window_set_max_content_width(v.native(), C.gint(width))\n}", "func (v *ScrolledWindow) GetMaxContentHeight() int {\n\tc := C.gtk_scrolled_window_get_max_content_height(v.native())\n\treturn int(c)\n}", "func (v *ScrolledWindow) GetMaxContentWidth() int {\n\tc := C.gtk_scrolled_window_get_max_content_width(v.native())\n\treturn int(c)\n}", "func (w *ScrollWidget) SetMax(max int) {\n\tw.max = max\n\tw.clampCurrent()\n}", "func SetScrollContentTrackerSize(sa *qtwidgets.QScrollArea) {\n\twgt := sa.Widget()\n\tsa.InheritResizeEvent(func(arg0 *qtgui.QResizeEvent) {\n\t\tosz := arg0.OldSize()\n\t\tnsz := arg0.Size()\n\t\tif false {\n\t\t\tlog.Println(osz.Width(), osz.Height(), nsz.Width(), nsz.Height())\n\t\t}\n\t\tif osz.Width() != nsz.Width() {\n\t\t\twgt.SetMaximumWidth(nsz.Width())\n\t\t}\n\t\t// this.ScrollArea_2.ResizeEvent(arg0)\n\t\targ0.Ignore() // I ignore, you handle it. replace explict call parent's\n\t})\n}", "func (v *ScrolledWindow) SetPropagateNaturalHeight(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_height(v.native(), gbool(propagate))\n}", "func (st *Settings) SetMaxWindowSize(size uint32) {\n\tst.windowSize = size\n}", "func (st *Settings) SetMaxWindowSize(size uint32) {\n\tst.windowSize = size\n}", "func (w *Window) SetMaximized(maximize bool) {\n\tif maximize == w.maximized {\n\t\treturn\n\t}\n\n\tif maximize {\n\t\tw.origX, w.origY = w.Pos()\n\t\tw.origWidth, w.origHeight = w.Size()\n\t\tw.maximized = true\n\t\tw.SetPos(0, 0)\n\t\twidth, height := ScreenSize()\n\t\tw.SetSize(width, height)\n\t} else {\n\t\tw.maximized = false\n\t\tw.SetPos(w.origX, w.origY)\n\t\tw.SetSize(w.origWidth, w.origHeight)\n\t}\n\tw.ResizeChildren()\n\tw.PlaceChildren()\n}", "func (w *WidgetBase) SetHeight(height int) {\n\tw.size.Y = height\n\tif w.size.Y != 0 {\n\t\tw.sizePolicyY = Minimum\n\t} else {\n\t\tw.sizePolicyY = Expanding\n\t}\n}", "func (win *Window) Maximize() {\n\twin.Candy().Guify(\"gtk_window_maximize\", win)\n}", "func (sf *TWindow) SetMaximized(maximize bool) {\n\tif maximize == sf.maximized {\n\t\treturn\n\t}\n\n\tif maximize {\n\t\tx, y := sf.pos.Get()\n\t\tsf.posOrig.X().Set(x)\n\t\tsf.posOrig.Y().Set(y)\n\t\tsf.origWidth, sf.origHeight = sf.Size()\n\t\tsf.maximized = true\n\t\tsf.SetPos(0, 0)\n\t\twidth, height := ScreenSize()\n\t\tsf.SetSize(width, height)\n\t} else {\n\t\tsf.maximized = false\n\t\tsf.SetPos(sf.posOrig.GetX(), sf.posOrig.GetY())\n\t\tsf.SetSize(sf.origWidth, sf.origHeight)\n\t}\n\tsf.ResizeChildren()\n\tsf.PlaceChildren()\n}", "func (Empty) MaxHeight(width, height int) int {\n\treturn 1\n}", "func (m *MailTips) SetMaxMessageSize(value *int32)() {\n err := m.GetBackingStore().Set(\"maxMessageSize\", value)\n if err != nil {\n panic(err)\n }\n}", "func (me XsdGoPkgHasElems_MaxHeight) MaxHeightDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func MaxValSize(max int) Option {\n\treturn func(lc *memoryCache) error {\n\t\tlc.maxValueSize = max\n\t\treturn nil\n\t}\n}", "func (w *WidgetImplement) SetClampHeight(clamp bool) {\n\tw.clamp[1] = clamp\n}", "func (me XsdGoPkgHasElem_MaxHeight) MaxHeightDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"0\")\r\n\treturn *x\r\n}", "func (c *HostClient) SetMaxConns(newMaxConns int) {\n\tc.connsLock.Lock()\n\tc.MaxConns = newMaxConns\n\tc.connsLock.Unlock()\n}", "func (w *WidgetImplement) SetFixedHeight(h int) {\n\tw.fixedH = h\n}", "func (c *Config) MaxHeight() int {\n\tc.Mutex.RLock()\n\tdefer c.Mutex.RUnlock()\n\treturn c.Raw.MaxHeight\n}", "func MaxValSize(max int) Option {\n\treturn func(lc *loadingCache) error {\n\t\tlc.maxValueSize = max\n\t\treturn nil\n\t}\n}", "func (t *Textarea) SetHeight(val int) {\n\tt.Call(\"setAttribute\", \"style\", \"height:\"+strconv.Itoa(val)+\"px\")\n}", "func (s *ItemScroller) SetAutoHeight(maxHeight float32) {\n\n\ts.maxAutoHeight = maxHeight\n}", "func NewMaxMessageSize(val int) MaxMessageSizeField {\n\treturn MaxMessageSizeField{quickfix.FIXInt(val)}\n}", "func (w *WidgetImplement) SetHeight(h int) {\n\tw.h = h\n}", "func (me *XsdGoPkgHasElems_MaxHeight) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElems_MaxHeight; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func MaxValSize(max int) Option {\n\treturn func(lc cacheWithOpts) error {\n\t\treturn lc.setMaxValSize(max)\n\t}\n}", "func (wg *WidgetImplement) SetFixedSize(w, h int) {\n\twg.fixedW = w\n\twg.fixedH = h\n}", "func (m Logon) SetMaxMessageSize(v int) {\n\tm.Set(field.NewMaxMessageSize(v))\n}", "func (win *Window) SetDefaultSize(width, height int) {\n\twin.Candy().Guify(\"gtk_window_set_default_size\", win, width, height)\n}", "func MaxBytes(m int64) optionSetter {\n\treturn func(o *options) error {\n\t\to.maxBytes = m\n\t\treturn nil\n\t}\n}", "func (c *DirentCache) setMaxSize(max uint64) {\n\tc.mu.Lock()\n\tc.maxSize = max\n\tc.maybeShrink()\n\tc.mu.Unlock()\n}", "func (s *Thumbnails) SetMaxHeight(v string) *Thumbnails {\n\ts.MaxHeight = &v\n\treturn s\n}", "func (w *Whisper) SetMaxMessageSize(size uint32) error {\n\tif size > MaxMessageSize {\n\t\treturn fmt.Errorf(\"message size too large [%d>%d]\", size, MaxMessageSize)\n\t}\n\tw.settings.Store(maxMsgSizeIdx, size)\n\treturn nil\n}", "func (s *Artwork) SetMaxHeight(v string) *Artwork {\n\ts.MaxHeight = &v\n\treturn s\n}", "func (me *XsdGoPkgHasElem_MaxHeight) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElem_MaxHeight; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (win *Window) SetWindowContentScaleCallback(callback WindowContentScaleCallback) WindowContentScaleCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.ContentScaleCallback\n\tcallbacks.ContentScaleCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowContentScaleCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowContentScaleCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (win *Window) SetMaximizeCallback(callback WindowMaximizeCallback) WindowMaximizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.MaximizeCallback\n\tcallbacks.MaximizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowMaximizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowMaximizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (fb *FlowBox) SetMaxChildrenPerLine(n_children uint) {\n\tC.gtk_flow_box_set_max_children_per_line(fb.native(), C.guint(n_children))\n}", "func (canvas *CanvasWidget) SetHeight(height float64) {\n\tcanvas.box.height = height\n\tcanvas.fixedHeight = true\n\tcanvas.RequestReflow()\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func (st *Settings) MaxWindowSize() uint32 {\n\treturn st.windowSize\n}", "func (s *VideoParameters) SetMaxHeight(v string) *VideoParameters {\n\ts.MaxHeight = &v\n\treturn s\n}", "func (ufc *UIOverlayContainer) SetContent(npp Frame, setup []UILayoutElement) {\n\tif ufc._state != nil {\n\t\tfor _, v := range ufc._state {\n\t\t\tufc.ThisUILayoutElementComponentDetails.Detach(v)\n\t\t}\n\t}\n\tufc._state = setup\n\tufc._framing = npp\n\tufc.ThisUIPanelDetails.Clipping = npp.FyFClipping()\n\tfor _, v := range setup {\n\t\tufc.ThisUILayoutElementComponentDetails.Attach(v)\n\t}\n\tufc.FyLSubelementChanged()\n}", "func (hpack *HPACK) SetMaxTableSize(size int) {\n\thpack.maxTableSize = size\n}", "func (m *Model) GetMaxHeight() int {\n\treturn m.maxHeight\n}", "func (s *PresetWatermark) SetMaxHeight(v string) *PresetWatermark {\n\ts.MaxHeight = &v\n\treturn s\n}", "func (w *LWindow) MHeight() int32 {\n\treturn w.mHeight\n}", "func MaxMessageSize(size int64) Option {\n\tif size < 0 {\n\t\tpanic(\"size must be non-negative\")\n\t}\n\treturn func(ws *websocket) {\n\t\tws.options.maxMessageSize = size\n\t}\n}", "func (label *LabelWidget) SetContent(content string) {\n\tlabel.content = content\n\tlabel.needsRepaint = true\n}", "func (e *Element) SetContent(content []byte) {\n\tif len(e.children) > 0 {\n\t\treturn\n\t}\n\te.content = content\n}", "func (p *Policy) setMaxBlockSize(ic *interop.Context, args []stackitem.Item) stackitem.Item {\n\tvalue := uint32(toBigInt(args[0]).Int64())\n\tif value > payload.MaxSize {\n\t\tpanic(fmt.Errorf(\"MaxBlockSize cannot be more than the maximum payload size = %d\", payload.MaxSize))\n\t}\n\tok, err := p.checkValidators(ic)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tif !ok {\n\t\treturn stackitem.NewBool(false)\n\t}\n\tp.lock.Lock()\n\tdefer p.lock.Unlock()\n\terr = p.setUint32WithKey(ic.DAO, maxBlockSizeKey, value)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tp.isValid = false\n\treturn stackitem.NewBool(true)\n}", "func (o AutoscalingPolicyScaleDownControlOutput) MaxScaledDownReplicas() FixedOrPercentPtrOutput {\n\treturn o.ApplyT(func(v AutoscalingPolicyScaleDownControl) *FixedOrPercent { return v.MaxScaledDownReplicas }).(FixedOrPercentPtrOutput)\n}", "func (client *GatewayClient) SetMaxConns(m int) {\n\tclient.maxOpen = m\n\n}", "func SetMaxNumberEntries(sz int) {\n\tC.hepevt_set_max_number_entries(C.int(sz))\n}", "func MaxMsgSize(s int) server.Option {\n\treturn server.SetOption(maxMsgSizeKey{}, s)\n}", "func (m *WorkbookCommentReply) SetContent(value *string)() {\n m.content = value\n}", "func (conn *Conn) SetMaxTopics(max int) {\n\tif max < 1 {\n\t\tmax = 50\n\t}\n\tconn.length = max\n}", "func (w *WidgetImplement) FixedHeight() int {\n\treturn w.fixedH\n}", "func (c *Card) SetContent(obj fyne.CanvasObject) {\n\tc.Content = obj\n\n\tc.Refresh()\n}", "func (s *settings) SetMaxWriteSize(size uint) {\n\ts.wMaxSize = size\n}", "func (o *VolumeInfinitevolAttributesType) SetMaxDataConstituentSize(newValue SizeType) *VolumeInfinitevolAttributesType {\n\to.MaxDataConstituentSizePtr = &newValue\n\treturn o\n}", "func (s *Server) SetMaxHeaderBytes(b int) {\n\ts.config.MaxHeaderBytes = b\n}", "func (pb *Bar) SetMaxWidth(maxWidth int) *Bar {\n\tpb.mu.Lock()\n\tpb.maxWidth = maxWidth\n\tpb.mu.Unlock()\n\treturn pb\n}", "func (o AutoscalingPolicyScaleDownControlResponsePtrOutput) MaxScaledDownReplicas() FixedOrPercentResponsePtrOutput {\n\treturn o.ApplyT(func(v *AutoscalingPolicyScaleDownControlResponse) *FixedOrPercentResponse {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.MaxScaledDownReplicas\n\t}).(FixedOrPercentResponsePtrOutput)\n}", "func (ch *clientSecureChannel) MaxMessageSize() uint32 {\n\treturn ch.maxMessageSize\n}", "func (s *ClampDirectionOffset) SetMax(max float64) *ClampDirectionOffset {\n\ts.max = max\n\treturn s\n}", "func (s *ItemScroller) autoSize() {\n\n\tif s.maxAutoWidth == 0 && s.maxAutoHeight == 0 {\n\t\treturn\n\t}\n\n\tvar width float32\n\tvar height float32\n\tfor _, item := range s.items {\n\t\tpanel := item.GetPanel()\n\t\tif panel.Width() > width {\n\t\t\twidth = panel.Width()\n\t\t}\n\t\theight += panel.Height()\n\t}\n\n\t// If auto maximum width enabled\n\tif s.maxAutoWidth > 0 {\n\t\tif width <= s.maxAutoWidth {\n\t\t\ts.SetContentWidth(width)\n\t\t}\n\t}\n\t// If auto maximum height enabled\n\tif s.maxAutoHeight > 0 {\n\t\tif height <= s.maxAutoHeight {\n\t\t\ts.SetContentHeight(height)\n\t\t}\n\t}\n}", "func MaxCacheSize(max int64) Option {\n\treturn func(lc *memoryCache) error {\n\t\tlc.maxCacheSize = max\n\t\treturn nil\n\t}\n}", "func (o AutoscalingPolicyScaleDownControlResponseOutput) MaxScaledDownReplicas() FixedOrPercentResponseOutput {\n\treturn o.ApplyT(func(v AutoscalingPolicyScaleDownControlResponse) FixedOrPercentResponse {\n\t\treturn v.MaxScaledDownReplicas\n\t}).(FixedOrPercentResponseOutput)\n}", "func (s *Slider) Max(max float32) *Slider {\n\ts.max = max\n\treturn s\n}", "func (s *ItemScroller) setHScrollBar(state bool) {\n\n\t// Visible\n\tif state {\n\t\tvar scrollHeight float32 = 20\n\t\tif s.hscroll == nil {\n\t\t\ts.hscroll = NewHScrollBar(0, 0)\n\t\t\ts.hscroll.SetBorders(1, 0, 0, 0)\n\t\t\ts.hscroll.Subscribe(OnChange, s.onScrollBarEvent)\n\t\t\ts.Panel.Add(s.hscroll)\n\t\t}\n\t\ts.hscroll.SetSize(s.ContentWidth(), scrollHeight)\n\t\ts.hscroll.SetPositionX(0)\n\t\ts.hscroll.SetPositionY(s.ContentHeight() - scrollHeight)\n\t\ts.hscroll.recalc()\n\t\ts.hscroll.SetVisible(true)\n\t\t// Not visible\n\t} else {\n\t\tif s.hscroll != nil {\n\t\t\ts.hscroll.SetVisible(false)\n\t\t}\n\t}\n}", "func (o *PollersPostParams) SetContent(content *models.Poller20PartialPoller) {\n\to.Content = content\n}", "func MaxCacheSize(max int64) Option {\n\treturn func(lc cacheWithOpts) error {\n\t\treturn lc.setMaxCacheSize(max)\n\t}\n}", "func (me XsdGoPkgHasAttr_MaxLines_XsdtInt_2) MaxLinesDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"2\")\r\n\treturn *x\r\n}", "func (d *PerfData) SetMax(max string) {\n\tif !valueCheck.MatchString(max) {\n\t\tpanic(\"invalid value\")\n\t}\n\td.max = max\n\td.bits = d.bits | PDAT_MAX\n}", "func NewMockisListenResponse_Content(ctrl *gomock.Controller) *MockisListenResponse_Content {\n\tmock := &MockisListenResponse_Content{ctrl: ctrl}\n\tmock.recorder = &MockisListenResponse_ContentMockRecorder{mock}\n\treturn mock\n}", "func (rn *RangedNumber) SetMax(max int) *RangedNumber {\n\trn.max = max\n\tif rn.min > rn.max {\n\t\trn.max = rn.min\n\t\trn.min = max\n\t}\n\n\treturn rn\n}", "func (v *TextView) SetBorderWindowSize(tp TextWindowType, size int) {\n\tC.gtk_text_view_set_border_window_size(v.native(), C.GtkTextWindowType(tp), C.gint(size))\n}", "func NewContent(\n\tinitialContent lease.ReadProxy,\n\tclock timeutil.Clock) (mc Content) {\n\tmc = &mutableContent{\n\t\tclock: clock,\n\t\tinitialContent: initialContent,\n\t\tdirtyThreshold: initialContent.Size(),\n\t}\n\n\treturn\n}", "func WindowContent(append ...bool) vecty.Markup {\n\treturn AddClass(wContent, append...)\n}", "func (s *Set) SetMaxLineSize(i int) {\n\ts.MaxLineSize = i\n}", "func MaxPageSize(m int) func(*ParquetWriter) error {\n\treturn func(p *ParquetWriter) error {\n\t\tp.max = m\n\t\treturn nil\n\t}\n}", "func MaxRecvMsgSize(s int) client.Option {\n\treturn func(o *client.Options) {\n\t\tif o.Context == nil {\n\t\t\to.Context = context.Background()\n\t\t}\n\t\to.Context = context.WithValue(o.Context, maxRecvMsgSizeKey{}, s)\n\t}\n}", "func (d *DHCPv4) MaxMessageSize() (uint16, error) {\n\treturn GetUint16(OptionMaximumDHCPMessageSize, d.Options)\n}", "func (fb *FlowBox) GetMaxChildrenPerLine() uint {\n\tc := C.gtk_flow_box_get_max_children_per_line(fb.native())\n\treturn uint(c)\n}", "func (p *PinnedItem) SetContent(content *PinnedItemContent) *PinnedItem {\n\tp.PinnedItemContent = content\n\treturn p\n}", "func (d *DiscordWebhook) SetContent(content string) {\n\td.Content = content\n}", "func (upu *UnsavedPostUpdate) SetContent(s string) *UnsavedPostUpdate {\n\tupu.mutation.SetContent(s)\n\treturn upu\n}", "func SetMaxIdleConns(maxIdleConns int) {\n\tclient.SetMaxIdleConns(maxIdleConns)\n}", "func (o AutoscalingPolicyScaleInControlOutput) MaxScaledInReplicas() FixedOrPercentPtrOutput {\n\treturn o.ApplyT(func(v AutoscalingPolicyScaleInControl) *FixedOrPercent { return v.MaxScaledInReplicas }).(FixedOrPercentPtrOutput)\n}", "func (o AutoscalingPolicyScaleInControlResponsePtrOutput) MaxScaledInReplicas() FixedOrPercentResponsePtrOutput {\n\treturn o.ApplyT(func(v *AutoscalingPolicyScaleInControlResponse) *FixedOrPercentResponse {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn &v.MaxScaledInReplicas\n\t}).(FixedOrPercentResponsePtrOutput)\n}", "func MaxBytesHandler(h Handler, n int64) Handler {\n\treturn HandlerFunc(func(w ResponseWriter, r *Request) {\n\t\tr2 := *r\n\t\tr2.Body = MaxBytesReader(w, r.Body, n)\n\t\th.ServeHTTP(w, &r2)\n\t})\n}", "func (pu *PostUpdate) SetContent(s string) *PostUpdate {\n\tpu.mutation.SetContent(s)\n\treturn pu\n}", "func (pu *PostUpdate) SetContent(s string) *PostUpdate {\n\tpu.mutation.SetContent(s)\n\treturn pu\n}", "func (u *GithubGistUpsertBulk) SetContent(v string) *GithubGistUpsertBulk {\n\treturn u.Update(func(s *GithubGistUpsert) {\n\t\ts.SetContent(v)\n\t})\n}", "func (o *Content) SetMaxProcesses(v int32) {\n\to.MaxProcesses.Set(&v)\n}", "func (win *Window) Height() int {\n\tsize := C.sfRenderWindow_getSize(win.win)\n\treturn int(size.y)\n}", "func (v *ScrolledWindow) GetPropagateNaturalHeight() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_height(v.native())\n\treturn gobool(c)\n}" ]
[ "0.8023439", "0.7892212", "0.7063212", "0.59386873", "0.5932504", "0.52396935", "0.5048182", "0.5048182", "0.50402075", "0.5032491", "0.5004204", "0.5002754", "0.49823657", "0.49187666", "0.49154866", "0.48963708", "0.48863816", "0.4872838", "0.48663074", "0.48459524", "0.48410115", "0.48086682", "0.48009363", "0.46959776", "0.46896234", "0.46866378", "0.46846426", "0.46737525", "0.4654549", "0.4651974", "0.46448636", "0.46269923", "0.46149328", "0.46068418", "0.45934793", "0.45927826", "0.4581558", "0.4543512", "0.45262972", "0.44706896", "0.445977", "0.44492963", "0.44492963", "0.4439194", "0.4433498", "0.4422241", "0.44036117", "0.43915558", "0.43804714", "0.4354259", "0.43450323", "0.43395567", "0.4335974", "0.4335628", "0.43333265", "0.43314517", "0.43284938", "0.43272853", "0.43270668", "0.4314515", "0.43007663", "0.42851096", "0.42821103", "0.42809525", "0.42642978", "0.42640007", "0.42504212", "0.42502663", "0.42469904", "0.42464346", "0.42333785", "0.423059", "0.4225662", "0.42239913", "0.421106", "0.42058417", "0.42051828", "0.4204017", "0.42016026", "0.41959056", "0.41942292", "0.41905728", "0.41865307", "0.41853392", "0.41752148", "0.4175065", "0.41672614", "0.41658175", "0.41556093", "0.4153752", "0.4150305", "0.41499788", "0.41405642", "0.41361314", "0.41351768", "0.41351768", "0.4132325", "0.41291118", "0.4128421", "0.41265848" ]
0.87742
0
GetPropagateNaturalWidth is a wrapper around gtk_scrolled_window_get_propagate_natural_width().
func (v *ScrolledWindow) GetPropagateNaturalWidth() bool { c := C.gtk_scrolled_window_get_propagate_natural_width(v.native()) return gobool(c) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *ScrolledWindow) SetPropagateNaturalWidth(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_width(v.native(), gbool(propagate))\n}", "func (v *ScrolledWindow) GetPropagateNaturalHeight() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_height(v.native())\n\treturn gobool(c)\n}", "func (v *ScrolledWindow) SetPropagateNaturalHeight(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_height(v.native(), gbool(propagate))\n}", "func (w *WidgetImplement) FixedWidth() int {\n\treturn w.fixedW\n}", "func GxOuterWidth(value float64) *SimpleElement { return newSEFloat(\"gx:outerWidth\", value) }", "func (c RelativeConstraint) GetWidth() float32 {\n\treturn c.op(c.parent().GetWidth(), c.constant)\n}", "func (window Window) InnerWidth() int {\n\treturn window.Get(\"innerWidth\").Int()\n}", "func (w *Window) Width() int {\n\treturn int(C.ANativeWindow_getWidth(w.cptr()))\n}", "func (window Window) OuterWidth() int {\n\treturn window.Get(\"outerWidth\").Int()\n}", "func (t *Text) Width(takable, taken float64) float64 {\n\tt.UpdateParagraph(takable)\n\tif t.Align != txt.Left {\n\t\treturn t.Paragraph.Width * t.Scl.X\n\t}\n\treturn t.Bounds().W() * t.Scl.X\n}", "func (v *ScrolledWindow) GetMaxContentWidth() int {\n\tc := C.gtk_scrolled_window_get_max_content_width(v.native())\n\treturn int(c)\n}", "func (b *Bound) Width() float64 {\n\treturn b.ne.X() - b.sw.X()\n}", "func (w *sliderElement) MinIntrinsicWidth(base.Length) base.Length {\n\twidth, _ := w.handle.GetPreferredWidth()\n\tif limit := base.FromPixelsX(width); limit < 160*DIP {\n\t\treturn 160 * DIP\n\t}\n\treturn base.FromPixelsX(width)\n}", "func (win *Window) Width() int {\n\tsize := C.sfRenderWindow_getSize(win.win)\n\treturn int(size.x)\n}", "func (w *LWindow) MWidth() int32 {\n\treturn w.mWidth\n}", "func (w *Window) Width() int {\n\treturn w.width\n}", "func (b *Bound) GeoWidth(haversine ...bool) float64 {\n\tc := b.Center()\n\n\tA := &Point{b.sw[0], c[1]}\n\tB := &Point{b.ne[0], c[1]}\n\n\treturn A.GeoDistanceFrom(B, yesHaversine(haversine))\n}", "func (t *Link) GetWidth() (v int64) {\n\treturn *t.width.nonNegativeInteger\n\n}", "func maxWidth(no_lines int, widthFromLineNo widthFunc) int {\n\tvar max int\n\tfor i := 0; i < no_lines; i++ {\n\t\tval := widthFromLineNo(i)\n\t\tif val > max {\n\t\t\tmax = val\n\t\t}\n\t}\n\treturn max\n}", "func (g *GitStatusWidget) GetWidth() int {\n\treturn g.renderer.GetWidth()\n}", "func PropValWindow(reply *xproto.GetPropertyReply,\n\terr error) (xproto.Window, error) {\n\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif reply.Format != 32 {\n\t\treturn 0, fmt.Errorf(\"PropValId: Expected format 32 but got %d\",\n\t\t\treply.Format)\n\t}\n\treturn xproto.Window(xgb.Get32(reply.Value)), nil\n}", "func (me XsdGoPkgHasElems_Width) WidthDefault() xsdt.Double {\r\n\tvar x = new(xsdt.Double)\r\n\tx.Set(\"1.0\")\r\n\treturn *x\r\n}", "func (self *TraitPixbufAnimation) GetWidth() (return__ int) {\n\tvar __cgo__return__ C.int\n\t__cgo__return__ = C.gdk_pixbuf_animation_get_width(self.CPointer)\n\treturn__ = int(__cgo__return__)\n\treturn\n}", "func (self *TraitPixbuf) GetWidth() (return__ int) {\n\tvar __cgo__return__ C.int\n\t__cgo__return__ = C.gdk_pixbuf_get_width(self.CPointer)\n\treturn__ = int(__cgo__return__)\n\treturn\n}", "func GetApproximateTextWidth(text string, fontSize int) float64 {\n\tsize := 0.0\n\tfSize := float64(fontSize)\n\tif fontSize == 0 {\n\t\tfSize = 14.0 // default font size on ons site\n\t}\n\tspacing := SpaceBetweenCharacters * fSize // allow for some spacing between letters\n\tfor _, runeValue := range text {\n\t\truneSize, ok := characterWidths[runeValue]\n\t\tif ok {\n\t\t\truneSize = fSize * runeSize\n\t\t} else { // unknown character - assume it's quite wide\n\t\t\truneSize = fSize * 0.8\n\t\t}\n\t\tsize += runeSize + spacing\n\t}\n\treturn size\n}", "func getWidth() int {\n\tstdoutFd := int(wrappedstreams.Stdout().Fd())\n\tstderrFd := int(wrappedstreams.Stderr().Fd())\n\n\tw := getWidthFd(stdoutFd)\n\tif w < 0 {\n\t\tw = getWidthFd(stderrFd)\n\t}\n\n\treturn w\n}", "func (wg *WidgetImplement) SetFixedWidth(w int) {\n\twg.fixedW = w\n}", "func (me XsdGoPkgHasElem_Width) WidthDefault() xsdt.Double {\r\n\tvar x = new(xsdt.Double)\r\n\tx.Set(\"1.0\")\r\n\treturn *x\r\n}", "func (s *State) AdaptiveElWidth() int {\n\treturn s.adaptiveElWidth\n}", "func (b *BaseElement) GetWidth() int32 {\n\treturn b.w\n}", "func GetWidgetWidth(w Widget) (result float32) {\n\timgui.PushID(GenAutoID(\"GetWidgetWidthMeasurement\"))\n\tdefer imgui.PopID()\n\n\t// save cursor position before doing anything\n\tcurrentPos := GetCursorPos()\n\n\t// set cursor position to something really out of working space\n\tstartPos := image.Pt(getWidgetWidthTestingSpaceX, getWidgetWidthTestingSpaceY)\n\tSetCursorPos(startPos)\n\n\t// render widget in `dry` mode\n\timgui.PushStyleVarFloat(imgui.StyleVarAlpha, 0)\n\tw.Build()\n\timgui.PopStyleVar()\n\n\t// save widget's width\n\t// check cursor position\n\timgui.SameLine()\n\n\tspacingW, _ := GetItemSpacing()\n\tresult = float32(GetCursorPos().X-startPos.X) - spacingW\n\n\t// reset drawing cursor position\n\tSetCursorPos(currentPos)\n\n\treturn result\n}", "func (w *WidgetImplement) Width() int {\n\treturn w.w\n}", "func GxPhysicalWidth(value float64) *SimpleElement { return newSEFloat(\"gx:physicalWidth\", value) }", "func (v *Pixbuf) GetWidth() int {\n\treturn int(C.gdk_pixbuf_get_width(v.Native()))\n}", "func (v *TextView) GetBorderWindowSize(tp TextWindowType) int {\n\treturn int(C.gtk_text_view_get_border_window_size(v.native(), C.GtkTextWindowType(tp)))\n}", "func (v *TextView) GetLeftMargin() int {\n\tc := C.gtk_text_view_get_left_margin(v.native())\n\treturn int(c)\n}", "func (e Event) GetResizeWidth() int {\n\treturn int(C.caca_get_event_resize_width(e.Ev))\n}", "func MonoWidth(input string) int {\n\n\ts := norm.NFD.String(input)\n\n\tcount := 0\n\tfor i := 0; i < len(s); {\n\t\td := norm.NFC.NextBoundaryInString(s[i:], true)\n\t\tcount += 1\n\t\ti += d\n\t}\n\n\treturn count\n}", "func (t *Link) GetUnknownWidth() (v interface{}) {\n\treturn t.width.unknown_\n\n}", "func (h *BSTHandler) CalculateTreeWidth() {\n\n}", "func (b *BinP1D) XWidth() float64 {\n\treturn b.xrange.Max - b.xrange.Min\n}", "func (v *TextView) GetPixelsInsideWrap() int {\n\tc := C.gtk_text_view_get_pixels_inside_wrap(v.native())\n\treturn int(c)\n}", "func (win *Window) ReshowWithInitialSize() {\n\twin.Candy().Guify(\"gtk_window_reshow_with_initial_size\", win)\n}", "func (o *os) GetBorderlessWindow() gdnative.Bool {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetBorderlessWindow()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_borderless_window\")\n\n\t// Call the parent method.\n\t// bool\n\tretPtr := gdnative.NewEmptyBool()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewBoolFromPointer(retPtr)\n\treturn ret\n}", "func calcWidth(width int) int {\n\tspacing := colSpacing * len(colWidths)\n\tvar staticCols int\n\tfor _, w := range colWidths {\n\t\twidth -= w\n\t\tif w == 0 {\n\t\t\tstaticCols++\n\t\t}\n\t}\n\treturn (width - spacing) / staticCols\n}", "func (b *BoundingBox2D) width() float64 {\n\n\treturn b.upperCorner.X - b.lowerCorner.X\n}", "func (w Widths) MaxWidth() (maxWidth, wideDepth int) {\n\tfor depth, width := range w {\n\t\tif width > maxWidth {\n\t\t\tmaxWidth = width\n\t\t\twideDepth = depth\n\t\t}\n\t}\n\treturn\n}", "func (w *WarpState) WindowSize() warp.Size {\n\treturn w.windowSize\n}", "func (n *node) width() int32 {\n\t// find two non-nil nodes\n\tfor i := 0; i < 8; i++ {\n\t\tif n.leafs[i] != nil && n.leafs[i].Center() != nil {\n\t\t\tfor j := 0; j < 8; j++ {\n\t\t\t\tif n.leafs[j] != nil && n.leafs[j].Center() != nil {\n\t\t\t\t\tp1, p2 := n.leafs[i].Center(), n.leafs[j].Center()\n\t\t\t\t\t// calculate non-zero difference in one of the dimensions (any)\n\t\t\t\t\txwidth := math.Abs(float64(p1.X - p2.X))\n\t\t\t\t\tif xwidth > 0 {\n\t\t\t\t\t\treturn int32(xwidth)\n\t\t\t\t\t}\n\t\t\t\t\tywidth := math.Abs(float64(p1.Y - p2.Y))\n\t\t\t\t\tif ywidth > 0 {\n\t\t\t\t\t\treturn int32(xwidth)\n\t\t\t\t\t}\n\t\t\t\t\tzwidth := math.Abs(float64(p1.Z - p2.Z))\n\t\t\t\t\tif zwidth > 0 {\n\t\t\t\t\t\treturn int32(xwidth)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0\n}", "func (p *pageT) WidthMax(s string) {\n\tp.Style = css.NewStylesResponsive(p.Style)\n\tp.Style.Desktop.StyleBox.WidthMax = s\n\tp.Style.Mobile.StyleBox.WidthMax = \"calc(100% - 1.2rem)\" // 0.6rem margin-left and -right in mobile view\n}", "func (o *FilingSentiment) GetConstraining() float32 {\n\tif o == nil || o.Constraining == nil {\n\t\tvar ret float32\n\t\treturn ret\n\t}\n\treturn *o.Constraining\n}", "func resolveMetricsWindow(logger moira.Logger, trigger moira.TriggerData, pkg NotificationPackage) (int64, int64) {\n\t// resolve default realtime window for any case\n\tnow := time.Now()\n\tdefaultFrom := roundToRetention(now.UTC().Add(-defaultTimeRange).Unix())\n\tdefaultTo := roundToRetention(now.UTC().Unix())\n\t// try to resolve package window, force default realtime window on fail for both local and remote triggers\n\tfrom, to, err := pkg.GetWindow()\n\tif err != nil {\n\t\tlogger.Warning().\n\t\t\tString(\"default_window\", defaultTimeRange.String()).\n\t\t\tError(err).\n\t\t\tMsg(\"Failed to get trigger package window, using default window\")\n\t\treturn defaultFrom, defaultTo\n\t}\n\t// round to the nearest retention to correctly fetch data from redis\n\tfrom = roundToRetention(from)\n\tto = roundToRetention(to)\n\t// package window successfully resolved, test it's wide and realtime metrics window\n\tfromTime, toTime := moira.Int64ToTime(from), moira.Int64ToTime(to)\n\tisWideWindow := toTime.Sub(fromTime).Minutes() >= defaultTimeRange.Minutes()\n\tisRealTimeWindow := now.UTC().Sub(fromTime).Minutes() <= defaultTimeRange.Minutes()\n\t// resolve remote trigger window.\n\t// window is wide: use package window to fetch limited historical data from graphite\n\t// window is not wide: use shifted window to fetch extended historical data from graphite\n\tif trigger.IsRemote {\n\t\tif isWideWindow {\n\t\t\treturn fromTime.Unix(), toTime.Unix()\n\t\t}\n\t\treturn toTime.Add(-defaultTimeRange + defaultTimeShift).Unix(), toTime.Add(defaultTimeShift).Unix()\n\t}\n\t// resolve local trigger window.\n\t// window is realtime: use shifted window to fetch actual data from redis\n\t// window is not realtime: force realtime window\n\tif isRealTimeWindow {\n\t\treturn toTime.Add(-defaultTimeRange + defaultTimeShift).Unix(), toTime.Add(defaultTimeShift).Unix()\n\t}\n\treturn defaultFrom, defaultTo\n}", "func (rect *PdfRectangle) Width() float64 {\n\treturn math.Abs(rect.Urx - rect.Llx)\n}", "func (m *ModuleBase) Width(takable, taken float64) float64 {\n\treturn taken\n}", "func (v *IconView) GetItemWidth() int {\n\treturn int(C.gtk_icon_view_get_item_width(v.native()))\n}", "func (c *Canvas) Width() int {\n\treturn c.maxCorner.X - c.minCorner.X + 1\n}", "func Pwidth(wp, cw, defval float64) float64 {\n\tif wp == 0 {\n\t\treturn defval\n\t}\n\treturn (wp / 100) * cw\n}", "func (g Grid) Width() int {\n\treturn g.width\n}", "func (dim *Dimensions) Width() int64 {\n\treturn dim.width\n}", "func GetTerminalWidthFunc(defaultWidth int) TerminalWidthGetter {\n\treturn func() int {\n\t\tterminalWidth, _, err := term.GetSize(int(os.Stdout.Fd()))\n\t\tif err == nil {\n\t\t\treturn terminalWidth\n\t\t}\n\t\treturn defaultWidth\n\t}\n}", "func (object Object) Width(value int64) Object {\n\treturn object.SimpleValue(as.PropertyWidth, value)\n}", "func getContentWidth(pdf *gofpdf.Fpdf) float64 {\n\tmarginL, _, marginR, _ := pdf.GetMargins()\n\tpageW, _ := pdf.GetPageSize()\n\twidth := pageW - marginL - marginR\n\treturn width\n}", "func GetWindowText(hwnd syscall.Handle, str *uint16, maxCount int32) (len int32, err error) {\n\tr0, _, e1 := syscall.Syscall(getWindowTextW.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(str)), uintptr(maxCount))\n\tlen = int32(r0)\n\tif len == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}", "func (l *Ledger) GetIrreversibleSlideWindow() int64 {\n\tdefaultIrreversibleSlideWindow := l.GenesisBlock.GetConfig().GetIrreversibleSlideWindow()\n\treturn defaultIrreversibleSlideWindow\n}", "func (b *Border) Width(width float32) *Border {\n\tb.width = b.th.TextSize.Scale(width)\n\treturn b\n}", "func (n *node) confine(adjustment float64) float64 {\n\tconfined := math.Max(1/DiffConfineFactor, adjustment)\n\tconfined = math.Min(DiffConfineFactor, confined)\n\n\treturn confined\n}", "func (b *Border) Width(width float32) *Border {\n\tb.width = b.Theme.TextSize.Scale(width)\n\treturn b\n}", "func PopItemWidth() {\n\timgui.PopItemWidth()\n}", "func nodeWidth(n uint) uint {\n\treturn 2*(n-1) + 1\n}", "func (v *ScrolledWindow) SetMaxContentWidth(width int) {\n\tC.gtk_scrolled_window_set_max_content_width(v.native(), C.gint(width))\n}", "func (pb *Bar) Width() (width int) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\twidth = defaultBarWidth\n\t\t}\n\t}()\n\tpb.mu.RLock()\n\twidth = pb.width\n\tmaxWidth := pb.maxWidth\n\tpb.mu.RUnlock()\n\tif width <= 0 {\n\t\tvar err error\n\t\tif width, err = terminalWidth(); err != nil {\n\t\t\treturn defaultBarWidth\n\t\t}\n\t}\n\tif maxWidth > 0 && width > maxWidth {\n\t\twidth = maxWidth\n\t}\n\treturn\n}", "func (v *Entry) GetMaxWidthChars() int {\n\tc := C.gtk_entry_get_max_width_chars(v.native())\n\treturn int(c)\n}", "func GET_WHEEL_DELTA_WPARAM(wParam WPARAM) int16 {\n\treturn int16(HIWORD(uint32(wParam)))\n}", "func (s *PageLayout) Width() float64 {\n\treturn s.width\n}", "func (gr *groupT) WidthMax(s string) {\n\tgr.Style = css.NewStylesResponsive(gr.Style)\n\tgr.Style.Desktop.StyleBox.WidthMax = s\n\tgr.Style.Mobile.StyleBox.WidthMax = \"none\" // => 100% of page - page has margins; replaced desktop max-width\n}", "func (a *Animation) GetWidth() float64 {\n\tif a == nil || a.Width == nil {\n\t\treturn 0.0\n\t}\n\treturn *a.Width\n}", "func (w *WorkerContainer) Conns() uint32 {\n\treturn atomic.LoadUint32(&w.conns)\n}", "func (s *Stream) incrSendWindow(hdr header, flags uint16) error {\n\tif err := s.processFlags(flags); err != nil {\n\t\treturn err\n\t}\n\n\t// Increase window, unblock a sender\n\tatomic.AddUint32(&s.sendWindow, hdr.Length())\n\tasyncNotify(s.sendNotifyCh)\n\treturn nil\n}", "func minWindow1(s string, t string) string {\n\tresult := \"\"\n\tletterCount := make(map[byte]int, len(s))\n\tfor i := 0; i < len(t); i++ {\n\t\tletterCount[t[i]]++\n\t}\n\n\tminLen := math.MaxInt64\n\tleftBorder := 0\n\tcnt := 0\n\tfor i := 0; i < len(s); i++ {\n\t\tletterCount[s[i]]--\n\t\tif letterCount[s[i]] >= 0 { cnt++ }\n\n\t\tfor cnt == len(t) {\n\t\t\tif minLen > (i - leftBorder + 1) {\n\t\t\t\tminLen = i - leftBorder + 1\n\t\t\t\tresult = s[leftBorder:i+1]\n\t\t\t}\n\n\t\t\tletterCount[s[leftBorder]]++\n\t\t\tif letterCount[s[leftBorder]] > 0 { cnt-- }\n\n\t\t\tleftBorder++\n\t\t}\n\t}\n\n\treturn result\n}", "func LevelWidth(n Nodes, l Level) Nodes {\n\tif l < 0 {\n\t\tpanic(\"can't see below\")\n\t}\n\tfor l > 0 {\n\t\tn = (n + 1) / 2\n\t\tl--\n\t}\n\treturn n\n}", "func (m Model) GetWidth() int {\n\treturn m.Width\n}", "func Width() int {\n\tws, err := getWinsize()\n\n\tif err != nil {\n\t\treturn -1\n\t}\n\n\treturn int(ws.Col)\n}", "func (v *StackPanel) Width() int {\n\tif v.orientation == Horizontal {\n\t\tw := 0\n\t\tfor _, val := range v.widths {\n\t\t\tw += val\n\t\t}\n\t\treturn w\n\t}\n\treturn v.width\n}", "func (n *windowNode) computeWindows() error {\n\trowCount := n.wrappedRenderVals.Len()\n\tif rowCount == 0 {\n\t\treturn nil\n\t}\n\n\twindowCount := len(n.funcs)\n\tacc := n.windowsAcc.Wtxn(n.planner.session)\n\n\twinValSz := uintptr(rowCount) * unsafe.Sizeof([]parser.Datum{})\n\twinAllocSz := uintptr(rowCount*windowCount) * unsafe.Sizeof(parser.Datum(nil))\n\tif err := acc.Grow(int64(winValSz + winAllocSz)); err != nil {\n\t\treturn err\n\t}\n\n\tn.windowValues = make([][]parser.Datum, rowCount)\n\twindowAlloc := make([]parser.Datum, rowCount*windowCount)\n\tfor i := range n.windowValues {\n\t\tn.windowValues[i] = windowAlloc[i*windowCount : (i+1)*windowCount]\n\t}\n\n\tvar scratchBytes []byte\n\tvar scratchDatum []parser.Datum\n\tfor windowIdx, windowFn := range n.funcs {\n\t\tpartitions := make(map[string][]parser.IndexedRow)\n\n\t\tif len(windowFn.partitionIdxs) == 0 {\n\t\t\t// If no partition indexes are included for the window function, all\n\t\t\t// rows are added to the same partition, which need to be pre-allocated.\n\t\t\tsz := int64(uintptr(rowCount) * unsafe.Sizeof(parser.IndexedRow{}))\n\t\t\tif err := acc.Grow(sz); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tpartitions[\"\"] = make([]parser.IndexedRow, rowCount)\n\t\t}\n\n\t\tif n := len(windowFn.partitionIdxs); n > cap(scratchDatum) {\n\t\t\tsz := int64(uintptr(n) * unsafe.Sizeof(parser.Datum(nil)))\n\t\t\tif err := acc.Grow(sz); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tscratchDatum = make([]parser.Datum, n)\n\t\t} else {\n\t\t\tscratchDatum = scratchDatum[:n]\n\t\t}\n\n\t\t// Partition rows into separate partitions based on hash values of the\n\t\t// window function's PARTITION BY attribute.\n\t\t//\n\t\t// TODO(nvanbenschoten) Window functions with the same window definition\n\t\t// can share partition and sorting work.\n\t\t// See Cao et al. [http://vldb.org/pvldb/vol5/p1244_yucao_vldb2012.pdf]\n\t\tfor rowI := 0; rowI < rowCount; rowI++ {\n\t\t\trow := n.wrappedRenderVals.At(rowI)\n\t\t\trowWindowDef := n.wrappedWindowDefVals.At(rowI)\n\t\t\tentry := parser.IndexedRow{Idx: rowI, Row: row}\n\t\t\tif len(windowFn.partitionIdxs) == 0 {\n\t\t\t\t// If no partition indexes are included for the window function, all\n\t\t\t\t// rows are added to the same partition.\n\t\t\t\tpartitions[\"\"][rowI] = entry\n\t\t\t} else {\n\t\t\t\t// If the window function has partition indexes, we hash the values of each\n\t\t\t\t// of these indexes for each row, and partition based on this hashed value.\n\t\t\t\tfor i, idx := range windowFn.partitionIdxs {\n\t\t\t\t\tscratchDatum[i] = rowWindowDef[idx]\n\t\t\t\t}\n\n\t\t\t\tencoded, err := sqlbase.EncodeDTuple(scratchBytes, scratchDatum)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tsz := int64(uintptr(len(encoded)) + unsafe.Sizeof(entry))\n\t\t\t\tif err := acc.Grow(sz); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tpartitions[string(encoded)] = append(partitions[string(encoded)], entry)\n\t\t\t\tscratchBytes = encoded[:0]\n\t\t\t}\n\t\t}\n\n\t\t// For each partition, perform necessary sorting based on the window function's\n\t\t// ORDER BY attribute. After this, perform the window function computation for\n\t\t// each tuple and save the result in n.windowValues.\n\t\t//\n\t\t// TODO(nvanbenschoten)\n\t\t// - Investigate inter- and intra-partition parallelism\n\t\t// - Investigate more efficient aggregation techniques\n\t\t// * Removable Cumulative\n\t\t// * Segment Tree\n\t\t// See Leis et al. [http://www.vldb.org/pvldb/vol8/p1058-leis.pdf]\n\t\tfor _, partition := range partitions {\n\t\t\t// TODO(nvanbenschoten) Handle framing here. Right now we only handle the default\n\t\t\t// framing option of RANGE UNBOUNDED PRECEDING. With ORDER BY, this sets the frame\n\t\t\t// to be all rows from the partition start up through the current row's last ORDER BY\n\t\t\t// peer. Without ORDER BY, all rows of the partition are included in the window frame,\n\t\t\t// since all rows become peers of the current row. Once we add better framing support,\n\t\t\t// we should flesh this logic out more.\n\t\t\tbuiltin := windowFn.expr.GetWindowConstructor()()\n\n\t\t\t// Since we only support two types of window frames (see TODO above), we only\n\t\t\t// need two possible types of peerGroupChecker's to help determine peer groups\n\t\t\t// for given tuples.\n\t\t\tvar peerGrouper peerGroupChecker\n\t\t\tif windowFn.columnOrdering != nil {\n\t\t\t\t// If an ORDER BY clause is provided, order the partition and use the\n\t\t\t\t// sorter as our peerGroupChecker.\n\t\t\t\tsorter := &partitionSorter{\n\t\t\t\t\trows: partition,\n\t\t\t\t\twindowDefVals: n.wrappedWindowDefVals,\n\t\t\t\t\tordering: windowFn.columnOrdering,\n\t\t\t\t}\n\t\t\t\t// The sort needs to be deterministic because multiple window functions with\n\t\t\t\t// syntactically equivalent ORDER BY clauses in their window definitions\n\t\t\t\t// need to be guaranteed to be evaluated in the same order, even if the\n\t\t\t\t// ORDER BY *does not* uniquely determine an ordering. In the future, this\n\t\t\t\t// could be guaranteed by only performing a single pass over a sorted partition\n\t\t\t\t// for functions with syntactically equivalent PARTITION BY and ORDER BY clauses.\n\t\t\t\tsort.Sort(sorter)\n\t\t\t\tpeerGrouper = sorter\n\t\t\t} else {\n\t\t\t\t// If no ORDER BY clause is provided, all rows in the partition are peers.\n\t\t\t\tpeerGrouper = allPeers{}\n\t\t\t}\n\n\t\t\t// Iterate over peer groups within partition using a window frame.\n\t\t\tframe := parser.WindowFrame{\n\t\t\t\tRows: partition,\n\t\t\t\tArgIdxStart: windowFn.argIdxStart,\n\t\t\t\tArgCount: windowFn.argCount,\n\t\t\t\tRowIdx: 0,\n\t\t\t}\n\t\t\tfor frame.RowIdx < len(partition) {\n\t\t\t\t// Compute the size of the current peer group.\n\t\t\t\tframe.FirstPeerIdx = frame.RowIdx\n\t\t\t\tframe.PeerRowCount = 1\n\t\t\t\tfor ; frame.FirstPeerIdx+frame.PeerRowCount < len(partition); frame.PeerRowCount++ {\n\t\t\t\t\tcur := frame.FirstPeerIdx + frame.PeerRowCount\n\t\t\t\t\tif !peerGrouper.InSameGroup(cur, cur-1) {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Perform calculations on each row in the current peer group.\n\t\t\t\tfor ; frame.RowIdx < frame.FirstPeerIdx+frame.PeerRowCount; frame.RowIdx++ {\n\t\t\t\t\tres, err := builtin.Compute(frame)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\t// This may overestimate, because WindowFuncs may perform internal caching.\n\t\t\t\t\tsz := res.Size()\n\t\t\t\t\tif err := acc.Grow(int64(sz)); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\t// Save result into n.windowValues, indexed by original row index.\n\t\t\t\t\tvalRowIdx := partition[frame.RowIdx].Idx\n\t\t\t\t\tn.windowValues[valRowIdx][windowIdx] = res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Done using window definition values, release memory.\n\tn.wrappedWindowDefVals.Close()\n\tn.wrappedWindowDefVals = nil\n\n\treturn nil\n}", "func PropValWindows(reply *xproto.GetPropertyReply,\n\terr error) ([]xproto.Window, error) {\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif reply.Format != 32 {\n\t\treturn nil, fmt.Errorf(\"PropValIds: Expected format 32 but got %d\",\n\t\t\treply.Format)\n\t}\n\n\tids := make([]xproto.Window, reply.ValueLen)\n\tvals := reply.Value\n\tfor i := 0; len(vals) >= 4; i++ {\n\t\tids[i] = xproto.Window(xgb.Get32(vals))\n\t\tvals = vals[4:]\n\t}\n\treturn ids, nil\n}", "func (n *windowNode) populateValues() error {\n\tacc := n.windowsAcc.Wtxn(n.planner.session)\n\trowCount := n.wrappedRenderVals.Len()\n\tn.values.rows = NewRowContainer(\n\t\tn.planner.session.TxnState.makeBoundAccount(), n.values.columns, rowCount,\n\t)\n\n\trow := make(parser.DTuple, len(n.windowRender))\n\tfor i := 0; i < rowCount; i++ {\n\t\twrappedRow := n.wrappedRenderVals.At(i)\n\n\t\tn.curRowIdx = i // Point all windowFuncHolders to the correct row values.\n\t\tcurColIdx := 0\n\t\tcurFnIdx := 0\n\t\tfor j := range row {\n\t\t\tif curWindowRender := n.windowRender[j]; curWindowRender == nil {\n\t\t\t\t// If the windowRender at this index is nil, propagate the datum\n\t\t\t\t// directly from the wrapped planNode. It wasn't changed by windowNode.\n\t\t\t\trow[j] = wrappedRow[curColIdx]\n\t\t\t\tcurColIdx++\n\t\t\t} else {\n\t\t\t\t// If the windowRender is not nil, ignore 0 or more columns from the wrapped\n\t\t\t\t// planNode. These were used as arguments to window functions all beneath\n\t\t\t\t// a single windowRender.\n\t\t\t\t// SELECT rank() over () from t; -> ignore 0 from wrapped values\n\t\t\t\t// SELECT (rank() over () + avg(b) over ()) from t; -> ignore 1 from wrapped values\n\t\t\t\t// SELECT (avg(a) over () + avg(b) over ()) from t; -> ignore 2 from wrapped values\n\t\t\t\tfor ; curFnIdx < len(n.funcs); curFnIdx++ {\n\t\t\t\t\twindowFn := n.funcs[curFnIdx]\n\t\t\t\t\tif windowFn.argIdxStart != curColIdx {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcurColIdx += windowFn.argCount\n\t\t\t\t}\n\t\t\t\t// Instead, we evaluate the current window render, which depends on at least\n\t\t\t\t// one window function, at the given row.\n\t\t\t\tres, err := curWindowRender.Eval(&n.planner.evalCtx)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\trow[j] = res\n\t\t\t}\n\t\t}\n\n\t\tif _, err := n.values.rows.AddRow(row); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Done using the output of computeWindows, release memory and clear\n\t// accounts.\n\tn.wrappedRenderVals.Close()\n\tn.wrappedRenderVals = nil\n\tn.wrappedIndexedVarVals.Close()\n\tn.wrappedIndexedVarVals = nil\n\tn.windowValues = nil\n\tacc.Close()\n\n\treturn nil\n}", "func (s *SimPDF) Width() float64 {\n\tif s.Page.IsLandscape {\n\t\treturn s.Page.Height\n\t}\n\treturn s.Page.Width\n}", "func (fb *FlowBox) GetMinChildrenPerLine() uint {\n\tc := C.gtk_flow_box_get_min_children_per_line(fb.native())\n\treturn uint(c)\n}", "func (v *TextView) GetPixelsAboveLines() int {\n\tc := C.gtk_text_view_get_pixels_above_lines(v.native())\n\treturn int(c)\n}", "func minSizeEffective(item LayoutItem) Size {\n\tgeometry := item.Geometry()\n\n\tvar s Size\n\tif msh, ok := item.(MinSizer); ok {\n\t\ts = msh.MinSize()\n\t} else if is, ok := item.(IdealSizer); ok {\n\t\ts = is.IdealSize()\n\t}\n\n\tsize := maxSize(geometry.MinSize, s)\n\n\tmax := geometry.MaxSize\n\tif max.Width > 0 && size.Width > max.Width {\n\t\tsize.Width = max.Width\n\t}\n\tif max.Height > 0 && size.Height > max.Height {\n\t\tsize.Height = max.Height\n\t}\n\n\treturn size\n}", "func (r Rectangle) Width() float64 {\n\treturn r.Max.X - r.Min.X\n}", "func (s *CountMinSketch) Width() uint {\n\treturn s.w\n}", "func (o *WorkbookChart) GetWidth() AnyOfnumberstringstring {\n\tif o == nil || o.Width == nil {\n\t\tvar ret AnyOfnumberstringstring\n\t\treturn ret\n\t}\n\treturn *o.Width\n}", "func minWindow(s string, t string) string {\n \n}", "func LineWidth(width float32) {\n\tsyscall.Syscall(gpLineWidth, 1, uintptr(math.Float32bits(width)), 0, 0)\n}", "func (s *Scroll) Window() sparta.Window {\n\treturn s.win\n}", "func (joint B2WheelJoint) GetLowerLimit() float64 {\n\treturn joint.M_lowerTranslation\n}", "func (r Rect) W() float64 {\n\treturn r.Max.X - r.Min.X\n}", "func (r Rect) W() float64 {\n\treturn r.Max.X - r.Min.X\n}", "func (status *InstanceStatus) PropagateAutoscalingStatus(app *App, hpa *autoscalingv1.HorizontalPodAutoscaler) {\n\t// hpa is nil when autoscaling is disabled, or maxreplicas hasn't been set, or no rules specified by user.\n\tif hpa == nil {\n\t\treturn\n\t}\n\n\tif hpa.Status.CurrentCPUUtilizationPercentage == nil {\n\t\t// hpa is not ready yet\n\t\treturn\n\t}\n\n\t// Set instance status for autoscaling rule\n\tstatus.AutoscalingStatus = []AutoscalingRuleStatus{\n\t\t{\n\t\t\t// Rules is guaranteed to not be empty here because hpa is not nil.\n\t\t\tAppAutoscalingRule: app.Spec.Instances.Autoscaling.Rules[0],\n\t\t\tCurrent: AutoscalingRuleMetricValueStatus{\n\t\t\t\tAverageValue: resource.NewQuantity(int64(*hpa.Status.CurrentCPUUtilizationPercentage), resource.DecimalSI),\n\t\t\t},\n\t\t},\n\t}\n}" ]
[ "0.81382954", "0.74754125", "0.6816626", "0.5524392", "0.55122465", "0.53927827", "0.51792467", "0.5166886", "0.510769", "0.5031366", "0.48824355", "0.48683724", "0.47451147", "0.47078547", "0.46988234", "0.4590461", "0.45584512", "0.4545798", "0.44968885", "0.44810912", "0.44612533", "0.44388798", "0.4431155", "0.4413729", "0.44012958", "0.43999803", "0.43937293", "0.43793204", "0.4377281", "0.43678764", "0.43491295", "0.43381414", "0.43372354", "0.4280027", "0.4273655", "0.42420977", "0.4219347", "0.42128748", "0.42045763", "0.41627103", "0.41436407", "0.4129937", "0.41259852", "0.41203302", "0.41198325", "0.4117093", "0.41001827", "0.41000643", "0.40768763", "0.407667", "0.40723222", "0.4064654", "0.40597075", "0.40582484", "0.40485737", "0.40481415", "0.4047917", "0.4047624", "0.40473467", "0.4042705", "0.4037631", "0.40070656", "0.40024036", "0.39949575", "0.39871714", "0.39798802", "0.397791", "0.39763787", "0.39750266", "0.39748344", "0.39697734", "0.3967661", "0.39539698", "0.3945641", "0.39447328", "0.39325276", "0.39262688", "0.392077", "0.39137018", "0.3910601", "0.3910364", "0.3905198", "0.3892346", "0.3889667", "0.38875258", "0.38845167", "0.3871653", "0.38665715", "0.38647726", "0.38509932", "0.38491723", "0.38335797", "0.38316178", "0.38282216", "0.38269827", "0.38267165", "0.38177115", "0.38048407", "0.38048407", "0.38022012" ]
0.87654483
0
SetPropagateNaturalWidth is a wrapper around gtk_scrolled_window_set_propagate_natural_width().
func (v *ScrolledWindow) SetPropagateNaturalWidth(propagate bool) { C.gtk_scrolled_window_set_propagate_natural_width(v.native(), gbool(propagate)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *ScrolledWindow) SetPropagateNaturalHeight(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_height(v.native(), gbool(propagate))\n}", "func (v *ScrolledWindow) GetPropagateNaturalWidth() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_width(v.native())\n\treturn gobool(c)\n}", "func (v *ScrolledWindow) GetPropagateNaturalHeight() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_height(v.native())\n\treturn gobool(c)\n}", "func (wg *WidgetImplement) SetFixedWidth(w int) {\n\twg.fixedW = w\n}", "func (v *ScrolledWindow) SetMaxContentWidth(width int) {\n\tC.gtk_scrolled_window_set_max_content_width(v.native(), C.gint(width))\n}", "func (w *WidgetImplement) FixedWidth() int {\n\treturn w.fixedW\n}", "func GxOuterWidth(value float64) *SimpleElement { return newSEFloat(\"gx:outerWidth\", value) }", "func (win *Window) ReshowWithInitialSize() {\n\twin.Candy().Guify(\"gtk_window_reshow_with_initial_size\", win)\n}", "func (w *WidgetBase) SetWidth(width int) {\n\tw.size.X = width\n\tif w.size.X != 0 {\n\t\tw.sizePolicyX = Minimum\n\t} else {\n\t\tw.sizePolicyX = Expanding\n\t}\n}", "func (window Window) InnerWidth() int {\n\treturn window.Get(\"innerWidth\").Int()\n}", "func (t *Text) Width(takable, taken float64) float64 {\n\tt.UpdateParagraph(takable)\n\tif t.Align != txt.Left {\n\t\treturn t.Paragraph.Width * t.Scl.X\n\t}\n\treturn t.Bounds().W() * t.Scl.X\n}", "func (w *Window) Width() int {\n\treturn int(C.ANativeWindow_getWidth(w.cptr()))\n}", "func (v *Entry) SetMaxWidthChars(nChars int) {\n\tC.gtk_entry_set_max_width_chars(v.native(), C.gint(nChars))\n}", "func (w *sliderElement) MinIntrinsicWidth(base.Length) base.Length {\n\twidth, _ := w.handle.GetPreferredWidth()\n\tif limit := base.FromPixelsX(width); limit < 160*DIP {\n\t\treturn 160 * DIP\n\t}\n\treturn base.FromPixelsX(width)\n}", "func (window Window) OuterWidth() int {\n\treturn window.Get(\"outerWidth\").Int()\n}", "func (wg *WidgetImplement) SetWidth(w int) {\n\twg.w = w\n}", "func (s *ItemScroller) SetAutoWidth(maxWidth float32) {\n\n\ts.maxAutoWidth = maxWidth\n}", "func (s *Stream) incrSendWindow(hdr header, flags uint16) error {\n\tif err := s.processFlags(flags); err != nil {\n\t\treturn err\n\t}\n\n\t// Increase window, unblock a sender\n\tatomic.AddUint32(&s.sendWindow, hdr.Length())\n\tasyncNotify(s.sendNotifyCh)\n\treturn nil\n}", "func TestServerZeroWindowAdjust(t *testing.T) {\n\tconn := dial(exitStatusZeroHandler, t)\n\tdefer conn.Close()\n\tsession, err := conn.NewSession()\n\tif err != nil {\n\t\tt.Fatalf(\"Unable to request new session: %v\", err)\n\t}\n\tdefer session.Close()\n\n\tif err := session.Shell(); err != nil {\n\t\tt.Fatalf(\"Unable to execute command: %v\", err)\n\t}\n\n\t// send a bogus zero sized window update\n\tsession.clientChan.sendWindowAdj(0)\n\n\terr = session.Wait()\n\tif err != nil {\n\t\tt.Fatalf(\"expected nil but got %v\", err)\n\t}\n}", "func (g *Grid) SetWidth(w int) { g.Width = w }", "func (w *WidgetImplement) SetClampWidth(clamp bool) {\n\tw.clamp[0] = clamp\n}", "func (c *connectionFlowController) EnsureMinimumWindowSize(inc protocol.ByteCount) {\n\tc.mutex.Lock()\n\tif inc > c.receiveWindowSize {\n\t\tc.logger.Debugf(\"Increasing receive flow control window for the connection to %d kB, in response to stream flow control window increase\", c.receiveWindowSize/(1<<10))\n\t\tnewSize := utils.Min(inc, c.maxReceiveWindowSize)\n\t\tif delta := newSize - c.receiveWindowSize; delta > 0 && c.allowWindowIncrease(delta) {\n\t\t\tc.receiveWindowSize = newSize\n\t\t}\n\t\tc.startNewAutoTuningEpoch(time.Now())\n\t}\n\tc.mutex.Unlock()\n}", "func (v *TextView) SetBorderWindowSize(tp TextWindowType, size int) {\n\tC.gtk_text_view_set_border_window_size(v.native(), C.GtkTextWindowType(tp), C.gint(size))\n}", "func WrapWidth(w float64) MeshOption {\n\treturn func(t *Mesh) error {\n\t\tt.renderAutoWrap = true\n\t\tt.renderWrapWidth = w\n\n\t\treturn nil\n\t}\n}", "func (b *Bar) SetWidth(n int) *Bar {\n\tif n < 2 || isClosed(b.done) {\n\t\treturn b\n\t}\n\tb.widthCh <- n\n\treturn b\n}", "func (fb *FlowBox) SetMinChildrenPerLine(n_children uint) {\n\tC.gtk_flow_box_set_min_children_per_line(fb.native(), C.guint(n_children))\n}", "func (win *Window) SetPolicy(allowShrink, allowGrow, autoShrink int) {\n\twin.Candy().Guify(\"gtk_window_set_policy\", win, allowShrink, allowGrow, autoShrink)\n}", "func (v *ScrolledWindow) GetMaxContentWidth() int {\n\tc := C.gtk_scrolled_window_get_max_content_width(v.native())\n\treturn int(c)\n}", "func NaturalBreaks(data []float64, nClasses int) []float64 {\n\t// sort data in numerical order, since this is expected by the matrices function\n\tdata = sortData(data)\n\n\t// sanity check\n\tuniq := deduplicate(data)\n\tif nClasses >= len(uniq) {\n\t\treturn uniq\n\t}\n\n\t// get our basic matrices (we only need lower class limits here)\n\tlowerClassLimits, _ := getMatrices(data, nClasses)\n\n\t// extract nClasses out of the computed matrices\n\treturn breaks(data, lowerClassLimits, nClasses)\n}", "func (win *Window) Width() int {\n\tsize := C.sfRenderWindow_getSize(win.win)\n\treturn int(size.x)\n}", "func (gr *groupT) WidthMax(s string) {\n\tgr.Style = css.NewStylesResponsive(gr.Style)\n\tgr.Style.Desktop.StyleBox.WidthMax = s\n\tgr.Style.Mobile.StyleBox.WidthMax = \"none\" // => 100% of page - page has margins; replaced desktop max-width\n}", "func (label *LabelWidget) SetWidth(width float64) {\n\tlabel.box.width = width\n\tlabel.fixedWidth = true\n\tlabel.RequestReflow()\n}", "func (tv *TextView) ResizeIfNeeded(nwSz image.Point) bool {\n\tif nwSz == tv.LinesSize {\n\t\treturn false\n\t}\n\t// fmt.Printf(\"%v needs resize: %v\\n\", tv.Nm, nwSz)\n\ttv.LinesSize = nwSz\n\tdiff := tv.SetSize()\n\tif !diff {\n\t\t// fmt.Printf(\"%v resize no setsize: %v\\n\", tv.Nm, nwSz)\n\t\treturn false\n\t}\n\tly := tv.ParentLayout()\n\tif ly != nil {\n\t\ttv.SetFlag(int(TextViewInReLayout))\n\t\tly.GatherSizes() // can't call Size2D b/c that resets layout\n\t\tly.Layout2DTree()\n\t\ttv.SetFlag(int(TextViewRenderScrolls))\n\t\ttv.ClearFlag(int(TextViewInReLayout))\n\t\t// fmt.Printf(\"resized: %v\\n\", tv.LayData.AllocSize)\n\t}\n\treturn true\n}", "func (p *pageT) WidthMax(s string) {\n\tp.Style = css.NewStylesResponsive(p.Style)\n\tp.Style.Desktop.StyleBox.WidthMax = s\n\tp.Style.Mobile.StyleBox.WidthMax = \"calc(100% - 1.2rem)\" // 0.6rem margin-left and -right in mobile view\n}", "func maxWidth(no_lines int, widthFromLineNo widthFunc) int {\n\tvar max int\n\tfor i := 0; i < no_lines; i++ {\n\t\tval := widthFromLineNo(i)\n\t\tif val > max {\n\t\t\tmax = val\n\t\t}\n\t}\n\treturn max\n}", "func (w *LWindow) MWidth() int32 {\n\treturn w.mWidth\n}", "func (w *Wrapper) NaturalJoin(table interface{}, condition string) *Wrapper {\n\tw.saveJoin(table, \"NATURAL JOIN\", condition)\n\treturn w\n}", "func (s *ItemScroller) autoSize() {\n\n\tif s.maxAutoWidth == 0 && s.maxAutoHeight == 0 {\n\t\treturn\n\t}\n\n\tvar width float32\n\tvar height float32\n\tfor _, item := range s.items {\n\t\tpanel := item.GetPanel()\n\t\tif panel.Width() > width {\n\t\t\twidth = panel.Width()\n\t\t}\n\t\theight += panel.Height()\n\t}\n\n\t// If auto maximum width enabled\n\tif s.maxAutoWidth > 0 {\n\t\tif width <= s.maxAutoWidth {\n\t\t\ts.SetContentWidth(width)\n\t\t}\n\t}\n\t// If auto maximum height enabled\n\tif s.maxAutoHeight > 0 {\n\t\tif height <= s.maxAutoHeight {\n\t\t\ts.SetContentHeight(height)\n\t\t}\n\t}\n}", "func (s *ItemScroller) vRecalc() {\n\n\t// Checks if scroll bar should be visible or not\n\tscroll := false\n\tif s.first > 0 {\n\t\tscroll = true\n\t} else {\n\t\tvar posY float32\n\t\tfor _, item := range s.items[s.first:] {\n\t\t\tposY += item.Height()\n\t\t\tif posY > s.height {\n\t\t\t\tscroll = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\ts.setVScrollBar(scroll)\n\n\t// Compute size of scroll button\n\tif scroll && s.autoButtonSize {\n\t\tvar totalHeight float32\n\t\tfor _, item := range s.items {\n\t\t\t// TODO OPTIMIZATION\n\t\t\t// Break when the view/content proportion becomes smaller than the minimum button size\n\t\t\ttotalHeight += item.Height()\n\t\t}\n\t\ts.vscroll.SetButtonSize(s.height * s.height / totalHeight)\n\t}\n\n\t// Items width\n\twidth := s.ContentWidth()\n\tif scroll {\n\t\twidth -= s.vscroll.Width()\n\t}\n\n\tvar posY float32\n\t// Sets positions of all items\n\tfor pos, ipan := range s.items {\n\t\titem := ipan.GetPanel()\n\t\tif pos < s.first {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// If item is after last visible, sets not visible\n\t\tif posY > s.height {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// Sets item position\n\t\titem.SetVisible(true)\n\t\titem.SetPosition(0, posY)\n\t\tif s.adjustItem {\n\t\t\titem.SetWidth(width)\n\t\t}\n\t\tposY += ipan.Height()\n\t}\n\n\t// Set scroll bar value if recalc was not due by scroll event\n\tif scroll && !s.scrollBarEvent {\n\t\ts.vscroll.SetValue(float32(s.first) / float32(s.maxFirst()))\n\t}\n\ts.scrollBarEvent = false\n}", "func AlignManually(alignmentType AlignmentType, widget Widget, widgetWidth float32, forceApplyWidth bool) Widget {\n\treturn Custom(func() {\n\t\tspacingX, _ := GetItemSpacing()\n\t\tavailableW, _ := GetAvailableRegion()\n\n\t\tvar dummyX float32\n\n\t\tswitch alignmentType {\n\t\tcase AlignLeft:\n\t\t\twidget.Build()\n\t\t\treturn\n\t\tcase AlignCenter:\n\t\t\tdummyX = (availableW-widgetWidth)/2 - spacingX\n\t\t\tif dummyX < 0 {\n\t\t\t\tdummyX = 0\n\t\t\t}\n\t\tcase AlignRight:\n\t\t\tdummyX = availableW - widgetWidth - spacingX\n\t\t\tif dummyX < 0 {\n\t\t\t\tdummyX = 0\n\t\t\t}\n\t\t}\n\n\t\tDummy(dummyX, 0).Build()\n\n\t\tif forceApplyWidth {\n\t\t\tPushItemWidth(widgetWidth)\n\t\t\tdefer PopItemWidth()\n\t\t}\n\n\t\timgui.SameLine()\n\t\twidget.Build()\n\t})\n}", "func (p *ControlPanel) RunWindow(opts *widget.RunWindowOptions) error {\n\tvar (\n\t\tnwo *screen.NewWindowOptions\n\t\tt *theme.Theme\n\t)\n\tif opts != nil {\n\t\tnwo = &opts.NewWindowOptions\n\t\tt = &opts.Theme\n\t}\n\tvar err error\n\tp.w, err = p.s.NewWindow(nwo)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer p.w.Release()\n\n\tpaintPending := false\n\n\tgef := gesture.EventFilter{EventDeque: p.w}\n\tfor {\n\t\te := p.w.NextEvent()\n\n\t\tif e = gef.Filter(e); e == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tswitch e := e.(type) {\n\t\tcase lifecycle.Event:\n\t\t\tp.root.OnLifecycleEvent(e)\n\t\t\tif e.To == lifecycle.StageDead {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\tcase gesture.Event, mouse.Event:\n\t\t\tp.root.OnInputEvent(e, image.Point{})\n\n\t\tcase paint.Event:\n\t\t\tctx := &node.PaintContext{\n\t\t\t\tTheme: t,\n\t\t\t\tScreen: p.s,\n\t\t\t\tDrawer: p.w,\n\t\t\t\tSrc2Dst: f64.Aff3{\n\t\t\t\t\t1, 0, 0,\n\t\t\t\t\t0, 1, 0,\n\t\t\t\t},\n\t\t\t}\n\t\t\tif err := p.root.Paint(ctx, image.Point{}); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tp.w.Publish()\n\t\t\tpaintPending = false\n\n\t\tcase size.Event:\n\t\t\tif dpi := float64(e.PixelsPerPt) * unit.PointsPerInch; dpi != t.GetDPI() {\n\t\t\t\tnewT := new(theme.Theme)\n\t\t\t\tif t != nil {\n\t\t\t\t\t*newT = *t\n\t\t\t\t}\n\t\t\t\tnewT.DPI = dpi\n\t\t\t\tt = newT\n\t\t\t}\n\n\t\t\twindowSize := e.Size()\n\t\t\tp.root.Measure(t, windowSize.X, windowSize.Y)\n\t\t\tp.root.Wrappee().Rect = e.Bounds()\n\t\t\tp.root.Layout(t)\n\t\t\t// TODO: call Mark(node.MarkNeedsPaint)?\n\n\t\tcase panelUpdate:\n\n\t\tcase error:\n\t\t\treturn e\n\t\t}\n\n\t\tif !paintPending && p.root.Wrappee().Marks.NeedsPaint() {\n\t\t\tpaintPending = true\n\t\t\tp.w.Send(paint.Event{})\n\t\t}\n\t}\n}", "func (o *DcimRacksListParams) SetOuterWidthn(outerWidthn *string) {\n\to.OuterWidthn = outerWidthn\n}", "func (sd *SelectDataset) NaturalLeftJoin(table exp.Expression) *SelectDataset {\n\treturn sd.joinTable(exp.NewUnConditionedJoinExpression(exp.NaturalLeftJoinType, table))\n}", "func WindowSize(s int) ConfigFunc {\n\treturn func(c *Config) {\n\t\tc.WindowSize = s\n\t}\n}", "func (v *TextView) SetLeftMargin(margin int) {\n\tC.gtk_text_view_set_left_margin(v.native(), C.gint(margin))\n}", "func ApplyOfficialWindowScaling(storedValue int, rescaleSlope, rescaleIntercept, windowWidth, windowCenter float64, bitsAllocated uint16) uint16 {\n\t// 1: StoredValue to ModalityValue\n\tvar modalityValue float64\n\tif rescaleSlope == 0 {\n\t\t// Via https://dgobbi.github.io/vtk-dicom/doc/api/image_display.html :\n\t\t// For modalities such as ultrasound and MRI that do not have any units,\n\t\t// the RescaleSlope and RescaleIntercept are absent and the Modality\n\t\t// Values are equal to the Stored Values.\n\t\tmodalityValue = float64(storedValue)\n\t} else {\n\t\t// Otherwise, we can apply the rescale slope and intercept to the stored\n\t\t// value.\n\t\tmodalityValue = float64(storedValue)*rescaleSlope + rescaleIntercept\n\t}\n\n\t// 2: ModalityValue to WindowedValue\n\n\t// The key here is that we're using bitsAllocated (e.g., 16 bits) instead of\n\t// bitsStored (e.g., 11 bits)\n\tvar grayLevels float64\n\tswitch bitsAllocated {\n\t// Precompute common cases so you're not exponentiating in the hot path\n\tcase 16:\n\t\tgrayLevels = 65536\n\tcase 8:\n\t\tgrayLevels = 256\n\tdefault:\n\t\tgrayLevels = math.Pow(2, float64(bitsAllocated))\n\t}\n\n\t// We are creating a 16-bit image, so we need to scale the modality value to\n\t// the range of 0-65535. Particularly if we're using 8-bit, then we need to\n\t// scale the 0-255 range to 0-65535, otherwise the images will look black.\n\tsixteenBitCorrection := math.MaxUint16 / uint16(grayLevels-1)\n\n\t// Via https://dgobbi.github.io/vtk-dicom/doc/api/image_display.html : For\n\t// ultrasound (and for 8-bit images in general) the WindowWidth and\n\t// WindowCenter may be absent from the file. If absent, they can be assumed\n\t// to be 256 and 128 respectively, which provides an 8-bit identity mapping.\n\t// Here, instead of assuming 8 bit, we use the grayLevels value.\n\tif windowWidth == 0 && windowCenter == 0 {\n\t\twindowWidth = grayLevels\n\t\twindowCenter = grayLevels / 2\n\t}\n\n\tw := windowWidth - 1.0\n\tc := windowCenter - 0.5\n\n\t// Below the lower bound of our window, draw black\n\tif modalityValue <= c-0.5*w {\n\t\treturn 0\n\t}\n\n\t// Above the upper bound of our window, draw white\n\tif modalityValue > c+0.5*w {\n\t\treturn uint16(grayLevels-1.0) * sixteenBitCorrection\n\t}\n\n\t// Within the window, return a scaled value\n\treturn uint16(((modalityValue-c)/w+0.5)*(grayLevels-1.0)) * sixteenBitCorrection\n\n}", "func (t *Link) SetWidth(v int64) {\n\tt.width = &widthIntermediateType{nonNegativeInteger: &v}\n\n}", "func OptionSetWidth(s int) Option {\n\treturn func(p *ProgressBar) {\n\t\tp.config.width = s\n\t}\n}", "func (n *windowNode) populateValues() error {\n\tacc := n.windowsAcc.Wtxn(n.planner.session)\n\trowCount := n.wrappedRenderVals.Len()\n\tn.values.rows = NewRowContainer(\n\t\tn.planner.session.TxnState.makeBoundAccount(), n.values.columns, rowCount,\n\t)\n\n\trow := make(parser.DTuple, len(n.windowRender))\n\tfor i := 0; i < rowCount; i++ {\n\t\twrappedRow := n.wrappedRenderVals.At(i)\n\n\t\tn.curRowIdx = i // Point all windowFuncHolders to the correct row values.\n\t\tcurColIdx := 0\n\t\tcurFnIdx := 0\n\t\tfor j := range row {\n\t\t\tif curWindowRender := n.windowRender[j]; curWindowRender == nil {\n\t\t\t\t// If the windowRender at this index is nil, propagate the datum\n\t\t\t\t// directly from the wrapped planNode. It wasn't changed by windowNode.\n\t\t\t\trow[j] = wrappedRow[curColIdx]\n\t\t\t\tcurColIdx++\n\t\t\t} else {\n\t\t\t\t// If the windowRender is not nil, ignore 0 or more columns from the wrapped\n\t\t\t\t// planNode. These were used as arguments to window functions all beneath\n\t\t\t\t// a single windowRender.\n\t\t\t\t// SELECT rank() over () from t; -> ignore 0 from wrapped values\n\t\t\t\t// SELECT (rank() over () + avg(b) over ()) from t; -> ignore 1 from wrapped values\n\t\t\t\t// SELECT (avg(a) over () + avg(b) over ()) from t; -> ignore 2 from wrapped values\n\t\t\t\tfor ; curFnIdx < len(n.funcs); curFnIdx++ {\n\t\t\t\t\twindowFn := n.funcs[curFnIdx]\n\t\t\t\t\tif windowFn.argIdxStart != curColIdx {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcurColIdx += windowFn.argCount\n\t\t\t\t}\n\t\t\t\t// Instead, we evaluate the current window render, which depends on at least\n\t\t\t\t// one window function, at the given row.\n\t\t\t\tres, err := curWindowRender.Eval(&n.planner.evalCtx)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\trow[j] = res\n\t\t\t}\n\t\t}\n\n\t\tif _, err := n.values.rows.AddRow(row); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Done using the output of computeWindows, release memory and clear\n\t// accounts.\n\tn.wrappedRenderVals.Close()\n\tn.wrappedRenderVals = nil\n\tn.wrappedIndexedVarVals.Close()\n\tn.wrappedIndexedVarVals = nil\n\tn.windowValues = nil\n\tacc.Close()\n\n\treturn nil\n}", "func (pb *Bar) SetMaxWidth(maxWidth int) *Bar {\n\tpb.mu.Lock()\n\tpb.maxWidth = maxWidth\n\tpb.mu.Unlock()\n\treturn pb\n}", "func (s *Service) onWindowResize(channel chan os.Signal) {\n\t//stdScr, _ := gc.Init()\n\t//stdScr.ScrollOk(true)\n\t//gc.NewLines(true)\n\tfor {\n\t\t<-channel\n\t\t//gc.StdScr().Clear()\n\t\t//rows, cols := gc.StdScr().MaxYX()\n\t\tcols, rows := GetScreenSize()\n\t\ts.screenRows = rows\n\t\ts.screenCols = cols\n\t\ts.resizeWindows()\n\t\t//gc.End()\n\t\t//gc.Update()\n\t\t//gc.StdScr().Refresh()\n\t}\n}", "func (status *InstanceStatus) PropagateAutoscalingStatus(app *App, hpa *autoscalingv1.HorizontalPodAutoscaler) {\n\t// hpa is nil when autoscaling is disabled, or maxreplicas hasn't been set, or no rules specified by user.\n\tif hpa == nil {\n\t\treturn\n\t}\n\n\tif hpa.Status.CurrentCPUUtilizationPercentage == nil {\n\t\t// hpa is not ready yet\n\t\treturn\n\t}\n\n\t// Set instance status for autoscaling rule\n\tstatus.AutoscalingStatus = []AutoscalingRuleStatus{\n\t\t{\n\t\t\t// Rules is guaranteed to not be empty here because hpa is not nil.\n\t\t\tAppAutoscalingRule: app.Spec.Instances.Autoscaling.Rules[0],\n\t\t\tCurrent: AutoscalingRuleMetricValueStatus{\n\t\t\t\tAverageValue: resource.NewQuantity(int64(*hpa.Status.CurrentCPUUtilizationPercentage), resource.DecimalSI),\n\t\t\t},\n\t\t},\n\t}\n}", "func (v *TextView) SetPixelsInsideWrap(px int) {\n\tC.gtk_text_view_set_pixels_inside_wrap(v.native(), C.gint(px))\n}", "func PropValWindow(reply *xproto.GetPropertyReply,\n\terr error) (xproto.Window, error) {\n\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif reply.Format != 32 {\n\t\treturn 0, fmt.Errorf(\"PropValId: Expected format 32 but got %d\",\n\t\t\treply.Format)\n\t}\n\treturn xproto.Window(xgb.Get32(reply.Value)), nil\n}", "func (o *DcimRacksListParams) SetOuterWidthGte(outerWidthGte *string) {\n\to.OuterWidthGte = outerWidthGte\n}", "func (n *node) confine(adjustment float64) float64 {\n\tconfined := math.Max(1/DiffConfineFactor, adjustment)\n\tconfined = math.Min(DiffConfineFactor, confined)\n\n\treturn confined\n}", "func (sf *TWindow) SetSizable(sizable bool) {\n\tsf.fixedSize = !sizable\n}", "func (s *ItemScroller) hRecalc() {\n\n\t// Checks if scroll bar should be visible or not\n\tscroll := false\n\tif s.first > 0 {\n\t\tscroll = true\n\t} else {\n\t\tvar posX float32\n\t\tfor _, item := range s.items[s.first:] {\n\t\t\tposX += item.GetPanel().Width()\n\t\t\tif posX > s.width {\n\t\t\t\tscroll = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\ts.setHScrollBar(scroll)\n\n\t// Compute size of scroll button\n\tif scroll && s.autoButtonSize {\n\t\tvar totalWidth float32\n\t\tfor _, item := range s.items {\n\t\t\t// TODO OPTIMIZATION\n\t\t\t// Break when the view/content proportion becomes smaller than the minimum button size\n\t\t\ttotalWidth += item.GetPanel().Width()\n\t\t}\n\t\ts.hscroll.SetButtonSize(s.width * s.width / totalWidth)\n\t}\n\n\t// Items height\n\theight := s.ContentHeight()\n\tif scroll {\n\t\theight -= s.hscroll.Height()\n\t}\n\n\tvar posX float32\n\t// Sets positions of all items\n\tfor pos, ipan := range s.items {\n\t\titem := ipan.GetPanel()\n\t\t// If item is before first visible, sets not visible\n\t\tif pos < s.first {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// If item is after last visible, sets not visible\n\t\tif posX > s.width {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// Sets item position\n\t\titem.SetVisible(true)\n\t\titem.SetPosition(posX, 0)\n\t\tif s.adjustItem {\n\t\t\titem.SetHeight(height)\n\t\t}\n\t\tposX += item.Width()\n\t}\n\n\t// Set scroll bar value if recalc was not due by scroll event\n\tif scroll && !s.scrollBarEvent {\n\t\ts.hscroll.SetValue(float32(s.first) / float32(s.maxFirst()))\n\t}\n\ts.scrollBarEvent = false\n}", "func (o *os) CenterWindow() {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.CenterWindow()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"center_window\")\n\n\t// Call the parent method.\n\t// void\n\tretPtr := gdnative.NewEmptyVoid()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n}", "func setNoWrap(panel gwu.Panel) {\n\tcount := panel.CompsCount()\n\tfor i := count - 1; i >= 0; i-- {\n\t\tpanel.CompAt(i).Style().SetWhiteSpace(gwu.WhiteSpaceNowrap)\n\t}\n}", "func Natural(value float64) bool {\n\treturn Whole(value) && value > 0\n}", "func (me XsdGoPkgHasElems_Width) WidthDefault() xsdt.Double {\r\n\tvar x = new(xsdt.Double)\r\n\tx.Set(\"1.0\")\r\n\treturn *x\r\n}", "func (b *Border) Width(width float32) *Border {\n\tb.width = b.th.TextSize.Scale(width)\n\treturn b\n}", "func (b *Border) Width(width float32) *Border {\n\tb.width = b.Theme.TextSize.Scale(width)\n\treturn b\n}", "func AllNaturalBreaks(data []float64, maxClasses int) [][]float64 {\n\t// sort data in numerical order, since this is expected by the matrices function\n\tdata = sortData(data)\n\n\t// sanity check\n\tuniq := deduplicate(data)\n\tif maxClasses > len(uniq) {\n\t\tmaxClasses = len(uniq)\n\t}\n\n\t// get our basic matrices (we only need lower class limits here)\n\tlowerClassLimits, _ := getMatrices(data, maxClasses)\n\n\t// extract nClasses out of the computed matrices\n\tallBreaks := [][]float64{}\n\tfor i := 2; i <= maxClasses; i++ {\n\t\tnClasses := breaks(data, lowerClassLimits, i)\n\t\tif i == len(uniq) {\n\t\t\tnClasses = uniq\n\t\t}\n\t\tallBreaks = append(allBreaks, nClasses)\n\t}\n\treturn allBreaks\n}", "func (sc *Session) sendWindowUpdate(st *stream, n int) {\n\tsc.serveG.check()\n\t// \"The legal range for the increment to the flow control\n\t// window is 1 to 2^31-1 (2,147,483,647) octets.\"\n\t// A Go Read call on 64-bit machines could in theory read\n\t// a larger Read than this. Very unlikely, but we handle it here\n\t// rather than elsewhere for now.\n\tconst maxUint31 = 1<<31 - 1\n\tfor n >= maxUint31 {\n\t\tsc.sendWindowUpdate32(st, maxUint31)\n\t\tn -= maxUint31\n\t}\n\tsc.sendWindowUpdate32(st, int32(n))\n}", "func (win *Window) SetKeepAbove(setting bool) {\n\twin.Candy().Guify(\"gtk_window_set_keep_above\", win, setting)\n}", "func updateWindow(ctx context.Context, a api.FullNode, w CidWindow, t int, ch chan CidWindow) (CidWindow, error) {\n\thead, err := a.ChainHead(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\twindow := appendCIDsToWindow(w, head.Cids(), t)\n\tch <- window\n\treturn window, nil\n}", "func (b *Bound) Width() float64 {\n\treturn b.ne.X() - b.sw.X()\n}", "func WithNonMonotonic(nm bool) CounterOptionApplier {\n\treturn counterOptionWrapper{\n\t\tF: func(d *Descriptor) {\n\t\t\td.alternate = nm\n\t\t},\n\t}\n}", "func LineWidth(width float32) {\n\tsyscall.Syscall(gpLineWidth, 1, uintptr(math.Float32bits(width)), 0, 0)\n}", "func (me XsdGoPkgHasElem_Width) WidthDefault() xsdt.Double {\r\n\tvar x = new(xsdt.Double)\r\n\tx.Set(\"1.0\")\r\n\treturn *x\r\n}", "func (v *TextView) SetPixelsAboveLines(px int) {\n\tC.gtk_text_view_set_pixels_above_lines(v.native(), C.gint(px))\n}", "func (w *Window) updateDimensions() {\n\tif w.windowLayout == nil {\n\t\treturn\n\t}\n\n\tw.window.SetFixedHeight(w.windowLayout.SizeHint().Height())\n}", "func (t *Link) SetUnknownWidth(i interface{}) {\n\tif t.unknown_ == nil {\n\t\tt.unknown_ = make(map[string]interface{})\n\t}\n\ttmp := &widthIntermediateType{}\n\ttmp.unknown_ = i\n\tt.width = tmp\n\n}", "func (s *Scroll) SetWindow(win sparta.Window) {\n\ts.win = win\n}", "func MonoWidth(input string) int {\n\n\ts := norm.NFD.String(input)\n\n\tcount := 0\n\tfor i := 0; i < len(s); {\n\t\td := norm.NFC.NextBoundaryInString(s[i:], true)\n\t\tcount += 1\n\t\ti += d\n\t}\n\n\treturn count\n}", "func adjustStringWidth(s string, width int) string {\n\ts = strings.TrimLeft(s, \" \")\n\tif len(s) < width {\n\t\tdiff := width - len(s)\n\t\tfor i := 0; i < diff; i++ {\n\t\t\ts += \" \"\n\t\t}\n\t}\n\treturn s\n}", "func (n *windowNode) computeWindows() error {\n\trowCount := n.wrappedRenderVals.Len()\n\tif rowCount == 0 {\n\t\treturn nil\n\t}\n\n\twindowCount := len(n.funcs)\n\tacc := n.windowsAcc.Wtxn(n.planner.session)\n\n\twinValSz := uintptr(rowCount) * unsafe.Sizeof([]parser.Datum{})\n\twinAllocSz := uintptr(rowCount*windowCount) * unsafe.Sizeof(parser.Datum(nil))\n\tif err := acc.Grow(int64(winValSz + winAllocSz)); err != nil {\n\t\treturn err\n\t}\n\n\tn.windowValues = make([][]parser.Datum, rowCount)\n\twindowAlloc := make([]parser.Datum, rowCount*windowCount)\n\tfor i := range n.windowValues {\n\t\tn.windowValues[i] = windowAlloc[i*windowCount : (i+1)*windowCount]\n\t}\n\n\tvar scratchBytes []byte\n\tvar scratchDatum []parser.Datum\n\tfor windowIdx, windowFn := range n.funcs {\n\t\tpartitions := make(map[string][]parser.IndexedRow)\n\n\t\tif len(windowFn.partitionIdxs) == 0 {\n\t\t\t// If no partition indexes are included for the window function, all\n\t\t\t// rows are added to the same partition, which need to be pre-allocated.\n\t\t\tsz := int64(uintptr(rowCount) * unsafe.Sizeof(parser.IndexedRow{}))\n\t\t\tif err := acc.Grow(sz); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tpartitions[\"\"] = make([]parser.IndexedRow, rowCount)\n\t\t}\n\n\t\tif n := len(windowFn.partitionIdxs); n > cap(scratchDatum) {\n\t\t\tsz := int64(uintptr(n) * unsafe.Sizeof(parser.Datum(nil)))\n\t\t\tif err := acc.Grow(sz); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tscratchDatum = make([]parser.Datum, n)\n\t\t} else {\n\t\t\tscratchDatum = scratchDatum[:n]\n\t\t}\n\n\t\t// Partition rows into separate partitions based on hash values of the\n\t\t// window function's PARTITION BY attribute.\n\t\t//\n\t\t// TODO(nvanbenschoten) Window functions with the same window definition\n\t\t// can share partition and sorting work.\n\t\t// See Cao et al. [http://vldb.org/pvldb/vol5/p1244_yucao_vldb2012.pdf]\n\t\tfor rowI := 0; rowI < rowCount; rowI++ {\n\t\t\trow := n.wrappedRenderVals.At(rowI)\n\t\t\trowWindowDef := n.wrappedWindowDefVals.At(rowI)\n\t\t\tentry := parser.IndexedRow{Idx: rowI, Row: row}\n\t\t\tif len(windowFn.partitionIdxs) == 0 {\n\t\t\t\t// If no partition indexes are included for the window function, all\n\t\t\t\t// rows are added to the same partition.\n\t\t\t\tpartitions[\"\"][rowI] = entry\n\t\t\t} else {\n\t\t\t\t// If the window function has partition indexes, we hash the values of each\n\t\t\t\t// of these indexes for each row, and partition based on this hashed value.\n\t\t\t\tfor i, idx := range windowFn.partitionIdxs {\n\t\t\t\t\tscratchDatum[i] = rowWindowDef[idx]\n\t\t\t\t}\n\n\t\t\t\tencoded, err := sqlbase.EncodeDTuple(scratchBytes, scratchDatum)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tsz := int64(uintptr(len(encoded)) + unsafe.Sizeof(entry))\n\t\t\t\tif err := acc.Grow(sz); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tpartitions[string(encoded)] = append(partitions[string(encoded)], entry)\n\t\t\t\tscratchBytes = encoded[:0]\n\t\t\t}\n\t\t}\n\n\t\t// For each partition, perform necessary sorting based on the window function's\n\t\t// ORDER BY attribute. After this, perform the window function computation for\n\t\t// each tuple and save the result in n.windowValues.\n\t\t//\n\t\t// TODO(nvanbenschoten)\n\t\t// - Investigate inter- and intra-partition parallelism\n\t\t// - Investigate more efficient aggregation techniques\n\t\t// * Removable Cumulative\n\t\t// * Segment Tree\n\t\t// See Leis et al. [http://www.vldb.org/pvldb/vol8/p1058-leis.pdf]\n\t\tfor _, partition := range partitions {\n\t\t\t// TODO(nvanbenschoten) Handle framing here. Right now we only handle the default\n\t\t\t// framing option of RANGE UNBOUNDED PRECEDING. With ORDER BY, this sets the frame\n\t\t\t// to be all rows from the partition start up through the current row's last ORDER BY\n\t\t\t// peer. Without ORDER BY, all rows of the partition are included in the window frame,\n\t\t\t// since all rows become peers of the current row. Once we add better framing support,\n\t\t\t// we should flesh this logic out more.\n\t\t\tbuiltin := windowFn.expr.GetWindowConstructor()()\n\n\t\t\t// Since we only support two types of window frames (see TODO above), we only\n\t\t\t// need two possible types of peerGroupChecker's to help determine peer groups\n\t\t\t// for given tuples.\n\t\t\tvar peerGrouper peerGroupChecker\n\t\t\tif windowFn.columnOrdering != nil {\n\t\t\t\t// If an ORDER BY clause is provided, order the partition and use the\n\t\t\t\t// sorter as our peerGroupChecker.\n\t\t\t\tsorter := &partitionSorter{\n\t\t\t\t\trows: partition,\n\t\t\t\t\twindowDefVals: n.wrappedWindowDefVals,\n\t\t\t\t\tordering: windowFn.columnOrdering,\n\t\t\t\t}\n\t\t\t\t// The sort needs to be deterministic because multiple window functions with\n\t\t\t\t// syntactically equivalent ORDER BY clauses in their window definitions\n\t\t\t\t// need to be guaranteed to be evaluated in the same order, even if the\n\t\t\t\t// ORDER BY *does not* uniquely determine an ordering. In the future, this\n\t\t\t\t// could be guaranteed by only performing a single pass over a sorted partition\n\t\t\t\t// for functions with syntactically equivalent PARTITION BY and ORDER BY clauses.\n\t\t\t\tsort.Sort(sorter)\n\t\t\t\tpeerGrouper = sorter\n\t\t\t} else {\n\t\t\t\t// If no ORDER BY clause is provided, all rows in the partition are peers.\n\t\t\t\tpeerGrouper = allPeers{}\n\t\t\t}\n\n\t\t\t// Iterate over peer groups within partition using a window frame.\n\t\t\tframe := parser.WindowFrame{\n\t\t\t\tRows: partition,\n\t\t\t\tArgIdxStart: windowFn.argIdxStart,\n\t\t\t\tArgCount: windowFn.argCount,\n\t\t\t\tRowIdx: 0,\n\t\t\t}\n\t\t\tfor frame.RowIdx < len(partition) {\n\t\t\t\t// Compute the size of the current peer group.\n\t\t\t\tframe.FirstPeerIdx = frame.RowIdx\n\t\t\t\tframe.PeerRowCount = 1\n\t\t\t\tfor ; frame.FirstPeerIdx+frame.PeerRowCount < len(partition); frame.PeerRowCount++ {\n\t\t\t\t\tcur := frame.FirstPeerIdx + frame.PeerRowCount\n\t\t\t\t\tif !peerGrouper.InSameGroup(cur, cur-1) {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Perform calculations on each row in the current peer group.\n\t\t\t\tfor ; frame.RowIdx < frame.FirstPeerIdx+frame.PeerRowCount; frame.RowIdx++ {\n\t\t\t\t\tres, err := builtin.Compute(frame)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\t// This may overestimate, because WindowFuncs may perform internal caching.\n\t\t\t\t\tsz := res.Size()\n\t\t\t\t\tif err := acc.Grow(int64(sz)); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\n\t\t\t\t\t// Save result into n.windowValues, indexed by original row index.\n\t\t\t\t\tvalRowIdx := partition[frame.RowIdx].Idx\n\t\t\t\t\tn.windowValues[valRowIdx][windowIdx] = res\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Done using window definition values, release memory.\n\tn.wrappedWindowDefVals.Close()\n\tn.wrappedWindowDefVals = nil\n\n\treturn nil\n}", "func (o *FilingSentiment) SetConstraining(v float32) {\n\to.Constraining = &v\n}", "func (o *PluginDnsClient) SetTruncated() {}", "func GxPhysicalWidth(value float64) *SimpleElement { return newSEFloat(\"gx:physicalWidth\", value) }", "func (c RelativeConstraint) GetWidth() float32 {\n\treturn c.op(c.parent().GetWidth(), c.constant)\n}", "func wmFreeformResize(ctx context.Context, tconn *chrome.TestConn, a *arc.ARC, d *ui.Device) error {\n\tact, err := arc.NewActivity(a, wm.Pkg24, wm.ResizableUnspecifiedActivity)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer act.Close()\n\tif err := act.StartWithDefaultOptions(ctx, tconn); err != nil {\n\t\treturn err\n\t}\n\tdefer act.Stop(ctx, tconn)\n\tif err := wm.WaitUntilActivityIsReady(ctx, tconn, act, d); err != nil {\n\t\treturn err\n\t}\n\n\twindow, err := ash.GetARCAppWindowInfo(ctx, tconn, act.PackageName())\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Resizable apps are launched in maximized in P.\n\tif window.State != ash.WindowStateNormal {\n\t\tif ws, err := ash.SetARCAppWindowState(ctx, tconn, act.PackageName(), ash.WMEventNormal); err != nil {\n\t\t\treturn err\n\t\t} else if ws != ash.WindowStateNormal {\n\t\t\treturn errors.Errorf(\"failed to set window state: got %s, want %s\", ws, ash.WindowStateNormal)\n\t\t}\n\t\tif err := ash.WaitForARCAppWindowState(ctx, tconn, act.PackageName(), ash.WindowStateNormal); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := ash.WaitWindowFinishAnimating(ctx, tconn, window.ID); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tdispMode, err := ash.PrimaryDisplayMode(ctx, tconn)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdispInfo, err := display.GetPrimaryInfo(ctx, tconn)\n\tif err != nil {\n\t\treturn err\n\t}\n\tmaxBounds := coords.ConvertBoundsFromDPToPX(dispInfo.Bounds, dispMode.DeviceScaleFactor)\n\n\tif ws, err := ash.SetARCAppWindowState(ctx, tconn, act.PackageName(), ash.WMEventNormal); err != nil {\n\t\treturn err\n\t} else if ws != ash.WindowStateNormal {\n\t\treturn errors.Errorf(\"failed to set window state: got %s, want %s\", ws, ash.WindowStateNormal)\n\t}\n\n\t// Now we grab the bounds from the restored app, and we try to resize it to its previous right margin.\n\torigBounds, err := act.WindowBounds(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// The -1 is needed to prevent injecting a touch event outside bounds.\n\tright := maxBounds.Left + maxBounds.Width - 1\n\ttesting.ContextLog(ctx, \"Resizing app to right margin = \", right)\n\tto := coords.NewPoint(right, origBounds.Top+origBounds.Height/2)\n\tif err := act.ResizeWindow(ctx, tconn, arc.BorderRight, to, 500*time.Millisecond); err != nil {\n\t\treturn err\n\t}\n\n\tbounds, err := act.WindowBounds(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\t// ResizeWindow() does not guarantee pixel-perfect resizing.\n\t// For this particular test, we are good as long as the window has been resized at least one pixel.\n\tif bounds.Width <= origBounds.Width {\n\t\ttesting.ContextLogf(ctx, \"Original bounds: %+v; resized bounds: %+v\", origBounds, bounds)\n\t\treturn errors.Errorf(\"invalid window width: got %d; want %d > %d\", bounds.Width, bounds.Width, origBounds.Width)\n\t}\n\treturn nil\n}", "func (sf *TWindow) Sizable() bool {\n\treturn !sf.fixedSize\n}", "func (s *State) AdaptiveElWidth() int {\n\treturn s.adaptiveElWidth\n}", "func (o *NewWindowOptions) Fixup() {\n\tsc := TheApp.Screen(0)\n\tscsz := sc.Geometry.Size() // window coords size\n\n\tif o.Size.X <= 0 {\n\t\to.StdPixels = false\n\t\to.Size.X = int(0.8 * float32(scsz.X) * sc.DevicePixelRatio)\n\t}\n\tif o.Size.Y <= 0 {\n\t\to.StdPixels = false\n\t\to.Size.Y = int(0.8 * float32(scsz.Y) * sc.DevicePixelRatio)\n\t}\n\n\to.Size, o.Pos = sc.ConstrainWinGeom(o.Size, o.Pos)\n\tif o.Pos.X == 0 && o.Pos.Y == 0 {\n\t\twsz := sc.WinSizeFmPix(o.Size)\n\t\tdialog, modal, _, _ := WindowFlagsToBool(o.Flags)\n\t\tnw := TheApp.NWindows()\n\t\tif nw > 0 {\n\t\t\tlastw := TheApp.Window(nw - 1)\n\t\t\tlsz := lastw.WinSize()\n\t\t\tlp := lastw.Position()\n\n\t\t\tnwbig := wsz.X > lsz.X || wsz.Y > lsz.Y\n\n\t\t\tif modal || dialog || !nwbig { // place centered on top of current\n\t\t\t\tctrx := lp.X + (lsz.X / 2)\n\t\t\t\tctry := lp.Y + (lsz.Y / 2)\n\t\t\t\to.Pos.X = ctrx - wsz.X/2\n\t\t\t\to.Pos.Y = ctry - wsz.Y/2\n\t\t\t} else { // cascade to right\n\t\t\t\to.Pos.X = lp.X + lsz.X // tile to right -- could depend on orientation\n\t\t\t\to.Pos.Y = lp.Y + 72 // and move down a bit\n\t\t\t}\n\t\t} else { // center in screen\n\t\t\to.Pos.X = scsz.X/2 - wsz.X/2\n\t\t\to.Pos.Y = scsz.Y/2 - wsz.Y/2\n\t\t}\n\t\to.Size, o.Pos = sc.ConstrainWinGeom(o.Size, o.Pos) // make sure ok\n\t}\n}", "func (canvas *CanvasWidget) SetWidth(width float64) {\n\tcanvas.box.width = width\n\tcanvas.fixedWidth = true\n\tcanvas.RequestReflow()\n}", "func WordWrap(allWords []string, maxLen int) []string {\n\tvar (\n\t\tlines []string\n\t\tcurLen int\n\t\twords []string\n\t)\n\tfor _, word := range allWords {\n\t\t// curLen + len(words) + len(word) is the length of the current\n\t\t// line including spaces\n\t\tif curLen+len(words)+len(word) > maxLen {\n\t\t\t// we have our line. That does not include the current word\n\t\t\tlines = append(lines, strings.Join(words, \" \"))\n\t\t\t// reset the current line, add the current word\n\t\t\twords = []string{word}\n\t\t\tcurLen = len(word)\n\t\t} else {\n\t\t\twords = append(words, word)\n\t\t\tcurLen += len(word)\n\t\t}\n\t}\n\tif len(words) > 0 {\n\t\t// there's one last line to add\n\t\tlines = append(lines, strings.Join(words, \" \"))\n\t}\n\tfor idx, line := range lines {\n\t\tif len(line) > maxLen {\n\t\t\t// truncate\n\t\t\tlines[idx] = line[:maxLen]\n\t\t}\n\t}\n\treturn lines\n}", "func (this *WeightedSum) ivweightedSumPropagate(varid core.VarId, evt *core.ChangeEvent) {\n\n\tthis.checkXmultCeqY(varid, evt)\n\n\tthis.ivsumPropagate(varid, evt)\n}", "func (b *Bound) GeoWidth(haversine ...bool) float64 {\n\tc := b.Center()\n\n\tA := &Point{b.sw[0], c[1]}\n\tB := &Point{b.ne[0], c[1]}\n\n\treturn A.GeoDistanceFrom(B, yesHaversine(haversine))\n}", "func (dnd *Dnd) setupWindowProperty() error {\n\tdata := []byte{xproto.AtomBitmap, 0, 0, 0}\n\tcookie := xproto.ChangePropertyChecked(\n\t\tdnd.conn,\n\t\txproto.PropModeAppend, // mode\n\t\tdnd.win,\n\t\tDndAtoms.XdndAware, // atom\n\t\txproto.AtomAtom, // type\n\t\t32, // format: xprop says that it should be 32 bit\n\t\tuint32(len(data))/4,\n\t\tdata)\n\treturn cookie.Check()\n}", "func MaybeIncreaseBufferSize(w *fsnotify.Watcher) {\n\tw.SetBufferSize(DesiredWindowsBufferSize())\n}", "func (w *Window) Width() int {\n\treturn w.width\n}", "func (o AiFeatureStoreOnlineServingConfigOutput) FixedNodeCount() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v AiFeatureStoreOnlineServingConfig) *int { return v.FixedNodeCount }).(pulumi.IntPtrOutput)\n}", "func (b *BaseElement) OnWindowResized(w, h int32) {\n\tif b.Events.OnWindowResized != nil {\n\t\tb.Events.OnWindowResized(w, h)\n\t}\n}", "func (win *Window) SetTransientFor(parent Window) {\n\twin.Candy().Guify(\"gtk_window_set_transient_for\", win, parent)\n}", "func (o AiFeatureStoreOnlineServingConfigPtrOutput) FixedNodeCount() pulumi.IntPtrOutput {\n\treturn o.ApplyT(func(v *AiFeatureStoreOnlineServingConfig) *int {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.FixedNodeCount\n\t}).(pulumi.IntPtrOutput)\n}", "func (p *pageT) WidthDefault() {\n\tp.Style = css.NewStylesResponsive(p.Style)\n\tif p.Style.Desktop.StyleBox.Margin == \"\" && p.Style.Mobile.StyleBox.Margin == \"\" {\n\t\tp.Style.Desktop.StyleBox.Margin = \"1.2rem auto 0 auto\"\n\t\tp.Style.Mobile.StyleBox.Margin = \"0.8rem auto 0 auto\"\n\t}\n}", "func (m *MainWindow) initializeSidebar() {\n\tsidebar_vbox := gtk.NewVBox(false, 0)\n\n\tserver_info_frame := gtk.NewFrame(ctx.Translator.Translate(\"Server information\", nil))\n\tsidebar_vbox.PackStart(server_info_frame, true, true, 5)\n\tsi_vbox := gtk.NewVBox(false, 0)\n\tserver_info_frame.Add(si_vbox)\n\n\t// Scrolled thing.\n\tsi_scroll := gtk.NewScrolledWindow(nil, nil)\n\tsi_scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)\n\tsi_vbox.PackStart(si_scroll, true, true, 5)\n\n\t// Server's information.\n\tm.server_info = gtk.NewTreeView()\n\tm.server_info.SetModel(m.server_info_store)\n\n\tkey_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Key\", nil), gtk.NewCellRendererText(), \"markup\", 0)\n\tm.server_info.AppendColumn(key_column)\n\n\tvalue_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Value\", nil), gtk.NewCellRendererText(), \"markup\", 1)\n\tm.server_info.AppendColumn(value_column)\n\n\tsi_scroll.Add(m.server_info)\n\n\t// Players information.\n\tplayers_info_frame := gtk.NewFrame(ctx.Translator.Translate(\"Players\", nil))\n\tsidebar_vbox.PackStart(players_info_frame, true, true, 5)\n\n\tpi_scroll := gtk.NewScrolledWindow(nil, nil)\n\tpi_scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)\n\tplayers_info_frame.Add(pi_scroll)\n\n\tm.players_info = gtk.NewTreeView()\n\tm.players_info.SetModel(m.players_info_store)\n\tpi_scroll.Add(m.players_info)\n\n\tname_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Player name\", nil), gtk.NewCellRendererText(), \"markup\", 0)\n\tm.players_info.AppendColumn(name_column)\n\n\tfrags_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Frags\", nil), gtk.NewCellRendererText(), \"markup\", 1)\n\tm.players_info.AppendColumn(frags_column)\n\n\tping_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Ping\", nil), gtk.NewCellRendererText(), \"markup\", 2)\n\tm.players_info.AppendColumn(ping_column)\n\n\t// Show CVars button.\n\tshow_cvars_button := gtk.NewButtonWithLabel(ctx.Translator.Translate(\"Show CVars\", nil))\n\tshow_cvars_button.SetTooltipText(ctx.Translator.Translate(\"Show server's CVars\", nil))\n\tshow_cvars_button.Clicked(m.showServerCVars)\n\tsidebar_vbox.PackStart(show_cvars_button, false, true, 5)\n\n\t// Quick connect frame.\n\tquick_connect_frame := gtk.NewFrame(ctx.Translator.Translate(\"Quick connect\", nil))\n\tsidebar_vbox.PackStart(quick_connect_frame, false, true, 5)\n\tqc_vbox := gtk.NewVBox(false, 0)\n\tquick_connect_frame.Add(qc_vbox)\n\n\t// Server address.\n\tsrv_tooltip := ctx.Translator.Translate(\"Server address we will connect to\", nil)\n\tsrv_label := gtk.NewLabel(ctx.Translator.Translate(\"Server address:\", nil))\n\tsrv_label.SetTooltipText(srv_tooltip)\n\tqc_vbox.PackStart(srv_label, false, true, 5)\n\n\tm.qc_server_address = gtk.NewEntry()\n\tm.qc_server_address.SetTooltipText(srv_tooltip)\n\tqc_vbox.PackStart(m.qc_server_address, false, true, 5)\n\n\t// Password.\n\tpass_tooltip := ctx.Translator.Translate(\"Password we will use for server\", nil)\n\tpass_label := gtk.NewLabel(ctx.Translator.Translate(\"Password:\", nil))\n\tpass_label.SetTooltipText(pass_tooltip)\n\tqc_vbox.PackStart(pass_label, false, true, 5)\n\n\tm.qc_password = gtk.NewEntry()\n\tm.qc_password.SetTooltipText(pass_tooltip)\n\tqc_vbox.PackStart(m.qc_password, false, true, 5)\n\n\t// Nickname\n\tnick_tooltip := ctx.Translator.Translate(\"Nickname we will use\", nil)\n\tnick_label := gtk.NewLabel(ctx.Translator.Translate(\"Nickname:\", nil))\n\tnick_label.SetTooltipText(nick_tooltip)\n\tqc_vbox.PackStart(nick_label, false, true, 5)\n\n\tm.qc_nickname = gtk.NewEntry()\n\tm.qc_nickname.SetTooltipText(nick_tooltip)\n\tqc_vbox.PackStart(m.qc_nickname, false, true, 5)\n\n\tm.hpane.Add2(sidebar_vbox)\n}" ]
[ "0.7961128", "0.79388314", "0.6707606", "0.5346279", "0.47825405", "0.4755107", "0.46057013", "0.45764875", "0.45117897", "0.4315776", "0.42900914", "0.4247731", "0.42211503", "0.42068702", "0.42030233", "0.4134348", "0.41119507", "0.4108613", "0.4049972", "0.40450892", "0.40437365", "0.39934456", "0.3975168", "0.39693403", "0.39659613", "0.39636934", "0.39481375", "0.39280483", "0.39222252", "0.39031982", "0.39001748", "0.38987264", "0.3897588", "0.3896837", "0.38800997", "0.3862602", "0.38603702", "0.38492012", "0.38470387", "0.38305214", "0.38260594", "0.38225687", "0.3798621", "0.37940165", "0.37907603", "0.3787526", "0.37746534", "0.37680444", "0.3753093", "0.37436572", "0.37372148", "0.3733609", "0.37220305", "0.3713886", "0.37073788", "0.3705136", "0.3702468", "0.36954018", "0.3688314", "0.36881492", "0.36828455", "0.36773685", "0.36764345", "0.36756176", "0.3665066", "0.36611786", "0.36577755", "0.36557454", "0.36506423", "0.36481592", "0.36291635", "0.3626794", "0.36132956", "0.36119327", "0.36118254", "0.36115295", "0.36084917", "0.36061296", "0.35959196", "0.35950565", "0.3589969", "0.3585758", "0.35857397", "0.3578339", "0.3574258", "0.3572419", "0.35702693", "0.3570116", "0.35649407", "0.35623074", "0.3561689", "0.35529307", "0.3551185", "0.35507774", "0.35494152", "0.3548222", "0.35347617", "0.35095894", "0.3507484", "0.35060948" ]
0.91999835
0
GetPropagateNaturalHeight is a wrapper around gtk_scrolled_window_get_propagate_natural_height().
func (v *ScrolledWindow) GetPropagateNaturalHeight() bool { c := C.gtk_scrolled_window_get_propagate_natural_height(v.native()) return gobool(c) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *ScrolledWindow) SetPropagateNaturalHeight(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_height(v.native(), gbool(propagate))\n}", "func (v *ScrolledWindow) GetPropagateNaturalWidth() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_width(v.native())\n\treturn gobool(c)\n}", "func (v *ScrolledWindow) SetPropagateNaturalWidth(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_width(v.native(), gbool(propagate))\n}", "func (window Window) InnerHeight() int {\n\treturn window.Get(\"innerHeight\").Int()\n}", "func (w *WidgetImplement) FixedHeight() int {\n\treturn w.fixedH\n}", "func (c RelativeConstraint) GetHeight() float32 {\n\treturn c.op(c.parent().GetHeight(), c.constant)\n}", "func (w *Window) Height() int {\n\treturn int(C.ANativeWindow_getHeight(w.cptr()))\n}", "func (v *ScrolledWindow) GetMaxContentHeight() int {\n\tc := C.gtk_scrolled_window_get_max_content_height(v.native())\n\treturn int(c)\n}", "func (p *Protocol) GetEpochHeight(epochNum uint64) uint64 {\n\tif epochNum == 0 {\n\t\treturn 0\n\t}\n\tdardanellesEpoch := p.GetEpochNum(p.dardanellesHeight)\n\tif !p.dardanellesOn || epochNum <= dardanellesEpoch {\n\t\treturn (epochNum-1)*p.numDelegates*p.numSubEpochs + 1\n\t}\n\tdardanellesEpochHeight := p.GetEpochHeight(dardanellesEpoch)\n\treturn dardanellesEpochHeight + (epochNum-dardanellesEpoch)*p.numDelegates*p.numSubEpochsDardanelles\n}", "func (b *Bound) Height() float64 {\n\treturn b.ne.Y() - b.sw.Y()\n}", "func (window Window) OuterHeight() int {\n\treturn window.Get(\"outerHeight\").Int()\n}", "func (t *Link) GetHeight() (v int64) {\n\treturn *t.height.nonNegativeInteger\n\n}", "func updateHeight(n *node) {\n\tn.H = math.Max(height(child(n, 0)), height(child(n, 1))+1)\n}", "func (v *TextView) GetBorderWindowSize(tp TextWindowType) int {\n\treturn int(C.gtk_text_view_get_border_window_size(v.native(), C.GtkTextWindowType(tp)))\n}", "func (self *TraitPixbufAnimation) GetHeight() (return__ int) {\n\tvar __cgo__return__ C.int\n\t__cgo__return__ = C.gdk_pixbuf_animation_get_height(self.CPointer)\n\treturn__ = int(__cgo__return__)\n\treturn\n}", "func (g *GitStatusWidget) GetHeight() int {\n\treturn g.renderer.GetHeight()\n}", "func (win *Window) Height() int {\n\tsize := C.sfRenderWindow_getSize(win.win)\n\treturn int(size.y)\n}", "func (t *Text) LinesHeight() int {\n\tpad := t.setter.opts.Padding\n\tif t.size.Y <= 0 {\n\t\treturn 0\n\t}\n\tif t.size.Y-2*pad <= 0 {\n\t\treturn t.size.Y\n\t}\n\ty := pad\n\tfor _, l := range t.lines {\n\t\th := l.h.Round()\n\t\tif y+h > t.size.Y-pad {\n\t\t\tbreak\n\t\t}\n\t\ty += h\n\t}\n\tif h := trailingNewlineHeight(t); h > 0 && y+h <= t.size.Y-pad {\n\t\ty += h\n\t}\n\treturn y + pad\n}", "func (self *TraitPixbuf) GetHeight() (return__ int) {\n\tvar __cgo__return__ C.int\n\t__cgo__return__ = C.gdk_pixbuf_get_height(self.CPointer)\n\treturn__ = int(__cgo__return__)\n\treturn\n}", "func (v *ScrolledWindow) GetMaxContentWidth() int {\n\tc := C.gtk_scrolled_window_get_max_content_width(v.native())\n\treturn int(c)\n}", "func (v *Pixbuf) GetHeight() int {\n\treturn int(C.gdk_pixbuf_get_height(v.Native()))\n}", "func (w *Window) Height() int {\n\treturn w.height\n}", "func (w *LWindow) MHeight() int32 {\n\treturn w.mHeight\n}", "func (_Depositmanager *DepositmanagerCallerSession) DepositSubtreeHeight() (*big.Int, error) {\n\treturn _Depositmanager.Contract.DepositSubtreeHeight(&_Depositmanager.CallOpts)\n}", "func (_Depositmanager *DepositmanagerSession) DepositSubtreeHeight() (*big.Int, error) {\n\treturn _Depositmanager.Contract.DepositSubtreeHeight(&_Depositmanager.CallOpts)\n}", "func (n *NodeMetastate) Height() uint64 {\n\treturn n.LedgerHeight\n}", "func (_Depositmanager *DepositmanagerCaller) DepositSubtreeHeight(opts *bind.CallOpts) (*big.Int, error) {\n\tvar (\n\t\tret0 = new(*big.Int)\n\t)\n\tout := ret0\n\terr := _Depositmanager.contract.Call(opts, out, \"depositSubtreeHeight\")\n\treturn *ret0, err\n}", "func (b *BaseElement) GetHeight() int32 {\n\treturn b.h\n}", "func (s *SkipList) getHeight() uint32 {\n\t// Height can be modified concurrently, so we need to load it atomically.\n\treturn atomic.LoadUint32(&s.height)\n}", "func (g *Grid) GetHeight() int {\n\treturn g.Height\n}", "func (n *Network) LatestHeight() (int64, error) {\n\tif len(n.Validators) == 0 {\n\t\treturn 0, errors.New(\"no validators available\")\n\t}\n\n\tstatus, err := n.Validators[0].RPCClient.Status(context.Background())\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\treturn status.SyncInfo.LatestBlockHeight, nil\n}", "func (t *Link) GetUnknownHeight() (v interface{}) {\n\treturn t.height.unknown_\n\n}", "func (env *Environment) getHeight(latestHeight int64, heightPtr *int64) (int64, error) {\n\tif heightPtr != nil {\n\t\theight := *heightPtr\n\t\tif height <= 0 {\n\t\t\treturn 0, fmt.Errorf(\"%w (requested height: %d)\", coretypes.ErrZeroOrNegativeHeight, height)\n\t\t}\n\t\tif height > latestHeight {\n\t\t\treturn 0, fmt.Errorf(\"%w (requested height: %d, blockchain height: %d)\",\n\t\t\t\tcoretypes.ErrHeightExceedsChainHead, height, latestHeight)\n\t\t}\n\t\tbase := env.BlockStore.Base()\n\t\tif height < base {\n\t\t\treturn 0, fmt.Errorf(\"%w (requested height: %d, base height: %d)\", coretypes.ErrHeightNotAvailable, height, base)\n\t\t}\n\t\treturn height, nil\n\t}\n\treturn latestHeight, nil\n}", "func (cs ClientState) GetLatestHeight() uint64 {\n\treturn uint64(cs.Height)\n}", "func (o *os) GetVirtualKeyboardHeight() gdnative.Int {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetVirtualKeyboardHeight()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_virtual_keyboard_height\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func (v *TextView) GetPixelsBelowLines() int {\n\tc := C.gtk_text_view_get_pixels_below_lines(v.native())\n\treturn int(c)\n}", "func GetHeight() int {\n\treturn viper.GetInt(FlagHeight)\n}", "func (t *Text) Height(takable, taken float64) float64 {\n\treturn t.Bounds().H() * t.Scl.Y\n}", "func (v *TextView) GetVisibleRect() *gdk.Rectangle {\n\tvar rect C.GdkRectangle\n\tC.gtk_text_view_get_visible_rect(v.native(), &rect)\n\treturn gdk.WrapRectangle(uintptr(unsafe.Pointer(&rect)))\n}", "func (rect *PdfRectangle) Height() float64 {\n\treturn math.Abs(rect.Ury - rect.Lly)\n}", "func (e Event) GetResizeHeight() int {\n\treturn int(C.caca_get_event_resize_height(e.Ev))\n}", "func (r *ImageRef) GetPageHeight() int {\n\treturn vipsGetPageHeight(r.image)\n}", "func CalculateNecessaryHeight(width int, text string) int {\n\tsplitLines := strings.Split(text, \"\\n\")\n\n\twrappedLines := 0\n\tfor _, line := range splitLines {\n\t\tif len(line) >= width {\n\t\t\twrappedLines = wrappedLines + ((len(line) - (len(line) % width)) / width)\n\t\t}\n\t}\n\n\treturn len(splitLines) + wrappedLines\n\n}", "func (r *ImageRef) PageHeight() int {\n\treturn vipsGetPageHeight(r.image)\n}", "func (b *BoundingBox2D) height() float64 {\n\n\treturn b.upperCorner.Y - b.lowerCorner.Y\n}", "func (p *Visitor) LedgerHeight() uint64 {\n\treturn atomic.LoadUint64(&p.lastCommittedBlock) + 1\n}", "func (a *Animation) GetHeight() float64 {\n\tif a == nil || a.Height == nil {\n\t\treturn 0.0\n\t}\n\treturn *a.Height\n}", "func (w *WidgetImplement) Height() int {\n\treturn w.h\n}", "func (me *XsdGoPkgHasElem_MaxHeight) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElem_MaxHeight; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func GetProcessedHeight(clientStore sdk.KVStore, height exported.Height) (exported.Height, bool) {\n\tkey := ProcessedHeightKey(height)\n\tbz := clientStore.Get(key)\n\tif bz == nil {\n\t\treturn nil, false\n\t}\n\tprocessedHeight, err := clienttypes.ParseHeight(string(bz))\n\tif err != nil {\n\t\treturn nil, false\n\t}\n\treturn processedHeight, true\n}", "func (me *XsdGoPkgHasElems_MaxHeight) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElems_MaxHeight; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (b *Bound) GeoHeight() float64 {\n\treturn 111131.75 * b.Height()\n}", "func (u *Upstream) GetHeight() uint64 {\n\treturn u.blockHeight\n}", "func injectHeightNotifier(content []byte, name string) []byte {\n\tcontent = append([]byte(`<div id=\"wrapper\">`), content...)\n\t// From https://stackoverflow.com/a/44547866 and extended to also pass\n\t// back the element id, as we can have multiple pages.\n\treturn append(content, []byte(fmt.Sprintf(`</div><script type=\"text/javascript\">\nwindow.addEventListener(\"load\", function(){\n if(window.self === window.top) return; // if w.self === w.top, we are not in an iframe\n send_height_to_parent_function = function(){\n var height = document.getElementById(\"wrapper\").offsetHeight;\n parent.postMessage({\"height\" : height , \"id\": \"%s\"}, \"*\");\n }\n send_height_to_parent_function(); //whenever the page is loaded\n window.addEventListener(\"resize\", send_height_to_parent_function); // whenever the page is resized\n var observer = new MutationObserver(send_height_to_parent_function); // whenever DOM changes PT1\n var config = { attributes: true, childList: true, characterData: true, subtree:true}; // PT2\n observer.observe(window.document, config); // PT3\n});\n</script>`, name))...)\n}", "func (w *Window) updateDimensions() {\n\tif w.windowLayout == nil {\n\t\treturn\n\t}\n\n\tw.window.SetFixedHeight(w.windowLayout.SizeHint().Height())\n}", "func (o *DynamicFont) GetFallbackCount() gdnative.Int {\n\t//log.Println(\"Calling DynamicFont.GetFallbackCount()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"DynamicFont\", \"get_fallback_count\")\n\n\t// Call the parent method.\n\t// int\n\tretPtr := gdnative.NewEmptyInt()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewIntFromPointer(retPtr)\n\treturn ret\n}", "func (bp RPCBlockProvider) GetBlockHeight() int {\r\n\tvar block int\r\n\terr := bp.Client.Call(\"BlockPropagationHandler.GetBlockHeight\", 0, &block)\r\n\tif err != nil {\r\n\t\tlog.Print(err)\r\n\t}\r\n\treturn block\r\n}", "func getHeight() int {\n\tfor {\n\t\theight := go50.GetInt(\"Height: \")\n\t\tif height > 0 && height < 24 {\n\t\t\treturn height\n\t\t}\n\t}\n}", "func MaxN(window int) func(s []float64) []float64 {\n\treturn func(s []float64) []float64 {\n\t\tmax := make([]float64, 0)\n\t\ti := 0\n\t\tfor _, v := range s {\n\t\t\tif i < window {\n\t\t\t\tfor j := 0; j < i; j++ {\n\t\t\t\t\tv = math.Max(v, max[j])\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor j := i - window; j < i; j++ {\n\t\t\t\t\tv = math.Max(v, max[j])\n\t\t\t\t}\n\t\t\t}\n\t\t\tmax = append(max, v)\n\t\t}\n\n\t\treturn max\n\t}\n}", "func (r Rectangle) Height() float64 {\n\treturn r.Max.Y - r.Min.Y\n}", "func (c *Config) MaxHeight() int {\n\tc.Mutex.RLock()\n\tdefer c.Mutex.RUnlock()\n\treturn c.Raw.MaxHeight\n}", "func (g *Graph) Height() uint64 {\n\tg.RLock()\n\theight := g.height\n\tg.RUnlock()\n\n\treturn height\n}", "func GetChainHeight(cliCtx context.CLIContext) (int64, error) {\n\tnode, err := cliCtx.GetNode()\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\tstatus, err := node.Status()\n\tif err != nil {\n\t\treturn -1, err\n\t}\n\theight := status.SyncInfo.LatestBlockHeight\n\treturn height, nil\n}", "func (p *Protocol) GetEpochNum(height uint64) uint64 {\n\tif height == 0 {\n\t\treturn 0\n\t}\n\tif !p.dardanellesOn || height <= p.dardanellesHeight {\n\t\treturn (height-1)/p.numDelegates/p.numSubEpochs + 1\n\t}\n\tdardanellesEpoch := p.GetEpochNum(p.dardanellesHeight)\n\tdardanellesEpochHeight := p.GetEpochHeight(dardanellesEpoch)\n\treturn dardanellesEpoch + (height-dardanellesEpochHeight)/p.numDelegates/p.numSubEpochsDardanelles\n}", "func Height() uint64 {\n\n\tglobalData.RLock()\n\tdefer globalData.RUnlock()\n\n\treturn globalData.height\n}", "func (d Doc) DefaultLineHeight() float64 {\n\treturn d.capValue * float64(d.fontSize) / 2000.0 * d.lineSpread\n}", "func (v *Layer) height() uint {\n\t_, height := v.view.Size()\n\treturn uint(height - 1)\n}", "func (o *os) GetBorderlessWindow() gdnative.Bool {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetBorderlessWindow()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_borderless_window\")\n\n\t// Call the parent method.\n\t// bool\n\tretPtr := gdnative.NewEmptyBool()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewBoolFromPointer(retPtr)\n\treturn ret\n}", "func (commit *Commit) Height() int64 {\n\tif len(commit.Precommits) == 0 {\n\t\treturn 0\n\t}\n\treturn commit.FirstPrecommit().Vote.Height\n}", "func (w *WidgetImplement) SetFixedHeight(h int) {\n\tw.fixedH = h\n}", "func (s *ItemScroller) hRecalc() {\n\n\t// Checks if scroll bar should be visible or not\n\tscroll := false\n\tif s.first > 0 {\n\t\tscroll = true\n\t} else {\n\t\tvar posX float32\n\t\tfor _, item := range s.items[s.first:] {\n\t\t\tposX += item.GetPanel().Width()\n\t\t\tif posX > s.width {\n\t\t\t\tscroll = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\ts.setHScrollBar(scroll)\n\n\t// Compute size of scroll button\n\tif scroll && s.autoButtonSize {\n\t\tvar totalWidth float32\n\t\tfor _, item := range s.items {\n\t\t\t// TODO OPTIMIZATION\n\t\t\t// Break when the view/content proportion becomes smaller than the minimum button size\n\t\t\ttotalWidth += item.GetPanel().Width()\n\t\t}\n\t\ts.hscroll.SetButtonSize(s.width * s.width / totalWidth)\n\t}\n\n\t// Items height\n\theight := s.ContentHeight()\n\tif scroll {\n\t\theight -= s.hscroll.Height()\n\t}\n\n\tvar posX float32\n\t// Sets positions of all items\n\tfor pos, ipan := range s.items {\n\t\titem := ipan.GetPanel()\n\t\t// If item is before first visible, sets not visible\n\t\tif pos < s.first {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// If item is after last visible, sets not visible\n\t\tif posX > s.width {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// Sets item position\n\t\titem.SetVisible(true)\n\t\titem.SetPosition(posX, 0)\n\t\tif s.adjustItem {\n\t\t\titem.SetHeight(height)\n\t\t}\n\t\tposX += item.Width()\n\t}\n\n\t// Set scroll bar value if recalc was not due by scroll event\n\tif scroll && !s.scrollBarEvent {\n\t\ts.hscroll.SetValue(float32(s.first) / float32(s.maxFirst()))\n\t}\n\ts.scrollBarEvent = false\n}", "func (o *os) GetMaxWindowSize() gdnative.Vector2 {\n\to.ensureSingleton()\n\t//log.Println(\"Calling _OS.GetMaxWindowSize()\")\n\n\t// Build out the method's arguments\n\tptrArguments := make([]gdnative.Pointer, 0, 0)\n\n\t// Get the method bind\n\tmethodBind := gdnative.NewMethodBind(\"_OS\", \"get_max_window_size\")\n\n\t// Call the parent method.\n\t// Vector2\n\tretPtr := gdnative.NewEmptyVector2()\n\tgdnative.MethodBindPtrCall(methodBind, o.GetBaseObject(), ptrArguments, retPtr)\n\n\t// If we have a return type, convert it from a pointer into its actual object.\n\tret := gdnative.NewVector2FromPointer(retPtr)\n\treturn ret\n}", "func (commit *Commit) GetHeight() int64 {\n\treturn commit.Height\n}", "func (commit *Commit) GetHeight() int64 {\n\treturn commit.Height\n}", "func (lc *FilChain) GetHeight(ctx context.Context) (uint64, error) {\n\th, err := lc.api.ChainHead(ctx)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"get head from lotus node: %s\", err)\n\t}\n\treturn uint64(h.Height()), nil\n}", "func (self *CellRenderer) GetFixedSize() (width, height int) {\n\tvar w C.gint\n\tvar h C.gint\n\tC.gtk_cell_renderer_get_fixed_size(self.object, &w, &h)\n\n\twidth = int(w)\n\theight = int(h)\n\treturn\n}", "func getHeight(latestHeight int64, heightPtr *int64) (int64, error) {\n\tif heightPtr != nil {\n\t\theight := *heightPtr\n\t\tif height <= 0 {\n\t\t\treturn 0, fmt.Errorf(\"height must be greater than 0, but got %d\", height)\n\t\t}\n\t\tif height > latestHeight {\n\t\t\treturn 0, fmt.Errorf(\"height %d must be less than or equal to the current blockchain height %d\",\n\t\t\t\theight, latestHeight)\n\t\t}\n\t\tbase := env.BlockStore.Base()\n\t\tif height < base {\n\t\t\treturn 0, fmt.Errorf(\"height %d is not available, lowest height is %d\",\n\t\t\t\theight, base)\n\t\t}\n\t\treturn height, nil\n\t}\n\treturn latestHeight, nil\n}", "func (n *Node) Height() int {\n\tif len(n.Children) == 0 {\n\t\treturn 0\n\t}\n\tvar max int\n\tfor _, c := range n.Children {\n\t\th := c.Height()\n\t\tif max < h {\n\t\t\tmax = h\n\t\t}\n\t}\n\treturn max + 1\n}", "func (g Grid) Height() int {\n\treturn g.height\n}", "func (s *TXPoolServer) getHeight() uint32 {\n\ts.mu.RLock()\n\tdefer s.mu.RUnlock()\n\treturn s.height\n}", "func (mTrx *_MyTrx) Height() int64 {\n\treturn atomic.LoadInt64(&mTrx.height)\n}", "func (window Window) ScrollY() int {\n\treturn window.Get(\"scrollY\").Int()\n}", "func (rt *recvTxOut) Height() int32 {\n\theight := int32(-1)\n\tif rt.block != nil {\n\t\theight = rt.block.Height\n\t}\n\treturn height\n}", "func (l *Ledger) GetIrreversibleSlideWindow() int64 {\n\tdefaultIrreversibleSlideWindow := l.GenesisBlock.GetConfig().GetIrreversibleSlideWindow()\n\treturn defaultIrreversibleSlideWindow\n}", "func (m *Model) GetMaxHeight() int {\n\treturn m.maxHeight\n}", "func (lc *LotusChain) GetHeight(ctx context.Context) (uint64, error) {\n\th, err := lc.api.ChainHead(ctx)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"get head from lotus node: %s\", err)\n\t}\n\treturn uint64(h.Height()), nil\n}", "func (v *TextView) GetPixelsAboveLines() int {\n\tc := C.gtk_text_view_get_pixels_above_lines(v.native())\n\treturn int(c)\n}", "func PropValWindow(reply *xproto.GetPropertyReply,\n\terr error) (xproto.Window, error) {\n\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif reply.Format != 32 {\n\t\treturn 0, fmt.Errorf(\"PropValId: Expected format 32 but got %d\",\n\t\t\treply.Format)\n\t}\n\treturn xproto.Window(xgb.Get32(reply.Value)), nil\n}", "func (ws *workingSet) Height() (uint64, error) {\n\treturn ws.height, nil\n}", "func (s *PageLayout) Height() float64 {\n\treturn s.height\n}", "func (v *StackPanel) Height() int {\n\tif v.orientation == Vertical {\n\t\th := 0\n\t\tfor _, val := range v.heights {\n\t\t\th += val\n\t\t}\n\t\treturn h\n\t}\n\treturn v.height\n}", "func (dim *Dimensions) Height() int64 {\n\treturn dim.height\n}", "func (e *EthManager) getNetworkHeight() (response int64, err error) {\n\tbody := `{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":42}`\n\ttarget := ethBlockNumber{}\n\tif err = requestAndParseJSON(e.ethJsonRPC, body, &target); err != nil {\n\t\tlog.Printf(\"Query Error: %v\", err)\n\t\treturn -1, err\n\t}\n\n\tresponse, err = strconv.ParseInt(target.Result[2:], 16, 0)\n\tif err != nil {\n\t\tlog.Printf(\"Parse Error: %v\", err)\n\t\treturn -1, err\n\t}\n\n\t// won't log non error responses as this is a very frequent query\n\treturn\n}", "func GetHeightFromIterationKey(iterKey []byte) exported.Height {\n\tbigEndianBytes := iterKey[len([]byte(KeyIterateConsensusStatePrefix)):]\n\trevisionBytes := bigEndianBytes[0:8]\n\theightBytes := bigEndianBytes[8:]\n\trevision := binary.BigEndian.Uint64(revisionBytes)\n\theight := binary.BigEndian.Uint64(heightBytes)\n\treturn clienttypes.NewHeight(revision, height)\n}", "func (window Window) InnerWidth() int {\n\treturn window.Get(\"innerWidth\").Int()\n}", "func (object Object) Height(value int64) Object {\n\treturn object.SimpleValue(as.PropertyHeight, value)\n}", "func (o *WorkbookChart) GetHeight() AnyOfnumberstringstring {\n\tif o == nil || o.Height == nil {\n\t\tvar ret AnyOfnumberstringstring\n\t\treturn ret\n\t}\n\treturn *o.Height\n}", "func GetWindowText(hwnd syscall.Handle, str *uint16, maxCount int32) (len int32, err error) {\n\tr0, _, e1 := syscall.Syscall(getWindowTextW.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(str)), uintptr(maxCount))\n\tlen = int32(r0)\n\tif len == 0 {\n\t\tif e1 != 0 {\n\t\t\terr = error(e1)\n\t\t} else {\n\t\t\terr = syscall.EINVAL\n\t\t}\n\t}\n\treturn\n}", "func Height() int {\n\tws, err := getWinsize()\n\tif err != nil {\n\t\treturn -1\n\t}\n\treturn int(ws.Row)\n}", "func (d Dispatcher) LatestBlockHeight() (int, error) {\n\tblock, err := d.GetBC().GetLatestBlock()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\treturn int(block.GetHeight()), nil\n}" ]
[ "0.7887868", "0.74162084", "0.6701644", "0.5282257", "0.51819026", "0.5121254", "0.501534", "0.4822917", "0.47664776", "0.4716606", "0.46773928", "0.46360207", "0.46136078", "0.45566", "0.45110223", "0.45107284", "0.44809556", "0.4468844", "0.4460032", "0.4425723", "0.4416638", "0.44122142", "0.4399586", "0.43993717", "0.43485212", "0.43359566", "0.43278587", "0.42698163", "0.42442557", "0.42281184", "0.42197645", "0.4219191", "0.4218309", "0.42157862", "0.42050365", "0.42024297", "0.41917074", "0.41906318", "0.41879004", "0.41757324", "0.41343313", "0.41327047", "0.40962648", "0.40892443", "0.40855587", "0.40779692", "0.4076409", "0.40730914", "0.40644068", "0.40459943", "0.40439418", "0.40427056", "0.4042122", "0.4040144", "0.40398046", "0.4039066", "0.40379512", "0.40245676", "0.40230897", "0.4015996", "0.40049094", "0.39840588", "0.39716953", "0.39691374", "0.39634565", "0.39556053", "0.39536494", "0.3950783", "0.39496425", "0.39359665", "0.39291504", "0.39268395", "0.39245057", "0.39245057", "0.390508", "0.38992688", "0.38945225", "0.38945174", "0.3887766", "0.38820538", "0.38672337", "0.38645172", "0.38629058", "0.38598287", "0.38561016", "0.38527358", "0.3848467", "0.38367712", "0.38255265", "0.3824432", "0.38138247", "0.38123122", "0.38119453", "0.3805694", "0.37996662", "0.37954783", "0.37948817", "0.3789593", "0.37856805", "0.37832612" ]
0.88503075
0
SetPropagateNaturalHeight is a wrapper around gtk_scrolled_window_set_propagate_natural_height().
func (v *ScrolledWindow) SetPropagateNaturalHeight(propagate bool) { C.gtk_scrolled_window_set_propagate_natural_height(v.native(), gbool(propagate)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v *ScrolledWindow) GetPropagateNaturalHeight() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_height(v.native())\n\treturn gobool(c)\n}", "func (v *ScrolledWindow) SetPropagateNaturalWidth(propagate bool) {\n\tC.gtk_scrolled_window_set_propagate_natural_width(v.native(), gbool(propagate))\n}", "func (v *ScrolledWindow) GetPropagateNaturalWidth() bool {\n\tc := C.gtk_scrolled_window_get_propagate_natural_width(v.native())\n\treturn gobool(c)\n}", "func (w *WidgetImplement) SetFixedHeight(h int) {\n\tw.fixedH = h\n}", "func updateHeight(n *node) {\n\tn.H = math.Max(height(child(n, 0)), height(child(n, 1))+1)\n}", "func (v *ScrolledWindow) SetMaxContentHeight(width int) {\n\tC.gtk_scrolled_window_set_max_content_height(v.native(), C.gint(width))\n}", "func (w *WidgetImplement) FixedHeight() int {\n\treturn w.fixedH\n}", "func (v *ScrolledWindow) SetMaxContentWidth(width int) {\n\tC.gtk_scrolled_window_set_max_content_width(v.native(), C.gint(width))\n}", "func (w *Window) updateDimensions() {\n\tif w.windowLayout == nil {\n\t\treturn\n\t}\n\n\tw.window.SetFixedHeight(w.windowLayout.SizeHint().Height())\n}", "func (window Window) InnerHeight() int {\n\treturn window.Get(\"innerHeight\").Int()\n}", "func (w *WidgetBase) SetHeight(height int) {\n\tw.size.Y = height\n\tif w.size.Y != 0 {\n\t\tw.sizePolicyY = Minimum\n\t} else {\n\t\tw.sizePolicyY = Expanding\n\t}\n}", "func (v *TextView) SetBorderWindowSize(tp TextWindowType, size int) {\n\tC.gtk_text_view_set_border_window_size(v.native(), C.GtkTextWindowType(tp), C.gint(size))\n}", "func (tv *TextView) ResizeIfNeeded(nwSz image.Point) bool {\n\tif nwSz == tv.LinesSize {\n\t\treturn false\n\t}\n\t// fmt.Printf(\"%v needs resize: %v\\n\", tv.Nm, nwSz)\n\ttv.LinesSize = nwSz\n\tdiff := tv.SetSize()\n\tif !diff {\n\t\t// fmt.Printf(\"%v resize no setsize: %v\\n\", tv.Nm, nwSz)\n\t\treturn false\n\t}\n\tly := tv.ParentLayout()\n\tif ly != nil {\n\t\ttv.SetFlag(int(TextViewInReLayout))\n\t\tly.GatherSizes() // can't call Size2D b/c that resets layout\n\t\tly.Layout2DTree()\n\t\ttv.SetFlag(int(TextViewRenderScrolls))\n\t\ttv.ClearFlag(int(TextViewInReLayout))\n\t\t// fmt.Printf(\"resized: %v\\n\", tv.LayData.AllocSize)\n\t}\n\treturn true\n}", "func (s *ItemScroller) hRecalc() {\n\n\t// Checks if scroll bar should be visible or not\n\tscroll := false\n\tif s.first > 0 {\n\t\tscroll = true\n\t} else {\n\t\tvar posX float32\n\t\tfor _, item := range s.items[s.first:] {\n\t\t\tposX += item.GetPanel().Width()\n\t\t\tif posX > s.width {\n\t\t\t\tscroll = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\ts.setHScrollBar(scroll)\n\n\t// Compute size of scroll button\n\tif scroll && s.autoButtonSize {\n\t\tvar totalWidth float32\n\t\tfor _, item := range s.items {\n\t\t\t// TODO OPTIMIZATION\n\t\t\t// Break when the view/content proportion becomes smaller than the minimum button size\n\t\t\ttotalWidth += item.GetPanel().Width()\n\t\t}\n\t\ts.hscroll.SetButtonSize(s.width * s.width / totalWidth)\n\t}\n\n\t// Items height\n\theight := s.ContentHeight()\n\tif scroll {\n\t\theight -= s.hscroll.Height()\n\t}\n\n\tvar posX float32\n\t// Sets positions of all items\n\tfor pos, ipan := range s.items {\n\t\titem := ipan.GetPanel()\n\t\t// If item is before first visible, sets not visible\n\t\tif pos < s.first {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// If item is after last visible, sets not visible\n\t\tif posX > s.width {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// Sets item position\n\t\titem.SetVisible(true)\n\t\titem.SetPosition(posX, 0)\n\t\tif s.adjustItem {\n\t\t\titem.SetHeight(height)\n\t\t}\n\t\tposX += item.Width()\n\t}\n\n\t// Set scroll bar value if recalc was not due by scroll event\n\tif scroll && !s.scrollBarEvent {\n\t\ts.hscroll.SetValue(float32(s.first) / float32(s.maxFirst()))\n\t}\n\ts.scrollBarEvent = false\n}", "func (w *Window) Height() int {\n\treturn int(C.ANativeWindow_getHeight(w.cptr()))\n}", "func (win *Window) ReshowWithInitialSize() {\n\twin.Candy().Guify(\"gtk_window_reshow_with_initial_size\", win)\n}", "func (t *Text) LinesHeight() int {\n\tpad := t.setter.opts.Padding\n\tif t.size.Y <= 0 {\n\t\treturn 0\n\t}\n\tif t.size.Y-2*pad <= 0 {\n\t\treturn t.size.Y\n\t}\n\ty := pad\n\tfor _, l := range t.lines {\n\t\th := l.h.Round()\n\t\tif y+h > t.size.Y-pad {\n\t\t\tbreak\n\t\t}\n\t\ty += h\n\t}\n\tif h := trailingNewlineHeight(t); h > 0 && y+h <= t.size.Y-pad {\n\t\ty += h\n\t}\n\treturn y + pad\n}", "func (fb *FlowBox) SetMaxChildrenPerLine(n_children uint) {\n\tC.gtk_flow_box_set_max_children_per_line(fb.native(), C.guint(n_children))\n}", "func (w *WidgetImplement) SetClampHeight(clamp bool) {\n\tw.clamp[1] = clamp\n}", "func (v *ScrolledWindow) GetMaxContentHeight() int {\n\tc := C.gtk_scrolled_window_get_max_content_height(v.native())\n\treturn int(c)\n}", "func (b *BaseElement) OnWindowResized(w, h int32) {\n\tif b.Events.OnWindowResized != nil {\n\t\tb.Events.OnWindowResized(w, h)\n\t}\n}", "func (win *Window) SetKeepBelow(setting bool) {\n\twin.Candy().Guify(\"gtk_window_set_keep_below\", win, setting)\n}", "func (win *Window) Maximize() {\n\twin.Candy().Guify(\"gtk_window_maximize\", win)\n}", "func (s *ItemScroller) SetAutoHeight(maxHeight float32) {\n\n\ts.maxAutoHeight = maxHeight\n}", "func (w *Window) SetMaximized(maximize bool) {\n\tif maximize == w.maximized {\n\t\treturn\n\t}\n\n\tif maximize {\n\t\tw.origX, w.origY = w.Pos()\n\t\tw.origWidth, w.origHeight = w.Size()\n\t\tw.maximized = true\n\t\tw.SetPos(0, 0)\n\t\twidth, height := ScreenSize()\n\t\tw.SetSize(width, height)\n\t} else {\n\t\tw.maximized = false\n\t\tw.SetPos(w.origX, w.origY)\n\t\tw.SetSize(w.origWidth, w.origHeight)\n\t}\n\tw.ResizeChildren()\n\tw.PlaceChildren()\n}", "func MaxN(window int) func(s []float64) []float64 {\n\treturn func(s []float64) []float64 {\n\t\tmax := make([]float64, 0)\n\t\ti := 0\n\t\tfor _, v := range s {\n\t\t\tif i < window {\n\t\t\t\tfor j := 0; j < i; j++ {\n\t\t\t\t\tv = math.Max(v, max[j])\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor j := i - window; j < i; j++ {\n\t\t\t\t\tv = math.Max(v, max[j])\n\t\t\t\t}\n\t\t\t}\n\t\t\tmax = append(max, v)\n\t\t}\n\n\t\treturn max\n\t}\n}", "func NaturalBreaks(data []float64, nClasses int) []float64 {\n\t// sort data in numerical order, since this is expected by the matrices function\n\tdata = sortData(data)\n\n\t// sanity check\n\tuniq := deduplicate(data)\n\tif nClasses >= len(uniq) {\n\t\treturn uniq\n\t}\n\n\t// get our basic matrices (we only need lower class limits here)\n\tlowerClassLimits, _ := getMatrices(data, nClasses)\n\n\t// extract nClasses out of the computed matrices\n\treturn breaks(data, lowerClassLimits, nClasses)\n}", "func injectHeightNotifier(content []byte, name string) []byte {\n\tcontent = append([]byte(`<div id=\"wrapper\">`), content...)\n\t// From https://stackoverflow.com/a/44547866 and extended to also pass\n\t// back the element id, as we can have multiple pages.\n\treturn append(content, []byte(fmt.Sprintf(`</div><script type=\"text/javascript\">\nwindow.addEventListener(\"load\", function(){\n if(window.self === window.top) return; // if w.self === w.top, we are not in an iframe\n send_height_to_parent_function = function(){\n var height = document.getElementById(\"wrapper\").offsetHeight;\n parent.postMessage({\"height\" : height , \"id\": \"%s\"}, \"*\");\n }\n send_height_to_parent_function(); //whenever the page is loaded\n window.addEventListener(\"resize\", send_height_to_parent_function); // whenever the page is resized\n var observer = new MutationObserver(send_height_to_parent_function); // whenever DOM changes PT1\n var config = { attributes: true, childList: true, characterData: true, subtree:true}; // PT2\n observer.observe(window.document, config); // PT3\n});\n</script>`, name))...)\n}", "func (s *ItemScroller) vRecalc() {\n\n\t// Checks if scroll bar should be visible or not\n\tscroll := false\n\tif s.first > 0 {\n\t\tscroll = true\n\t} else {\n\t\tvar posY float32\n\t\tfor _, item := range s.items[s.first:] {\n\t\t\tposY += item.Height()\n\t\t\tif posY > s.height {\n\t\t\t\tscroll = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\ts.setVScrollBar(scroll)\n\n\t// Compute size of scroll button\n\tif scroll && s.autoButtonSize {\n\t\tvar totalHeight float32\n\t\tfor _, item := range s.items {\n\t\t\t// TODO OPTIMIZATION\n\t\t\t// Break when the view/content proportion becomes smaller than the minimum button size\n\t\t\ttotalHeight += item.Height()\n\t\t}\n\t\ts.vscroll.SetButtonSize(s.height * s.height / totalHeight)\n\t}\n\n\t// Items width\n\twidth := s.ContentWidth()\n\tif scroll {\n\t\twidth -= s.vscroll.Width()\n\t}\n\n\tvar posY float32\n\t// Sets positions of all items\n\tfor pos, ipan := range s.items {\n\t\titem := ipan.GetPanel()\n\t\tif pos < s.first {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// If item is after last visible, sets not visible\n\t\tif posY > s.height {\n\t\t\titem.SetVisible(false)\n\t\t\tcontinue\n\t\t}\n\t\t// Sets item position\n\t\titem.SetVisible(true)\n\t\titem.SetPosition(0, posY)\n\t\tif s.adjustItem {\n\t\t\titem.SetWidth(width)\n\t\t}\n\t\tposY += ipan.Height()\n\t}\n\n\t// Set scroll bar value if recalc was not due by scroll event\n\tif scroll && !s.scrollBarEvent {\n\t\ts.vscroll.SetValue(float32(s.first) / float32(s.maxFirst()))\n\t}\n\ts.scrollBarEvent = false\n}", "func (d Doc) DefaultLineHeight() float64 {\n\treturn d.capValue * float64(d.fontSize) / 2000.0 * d.lineSpread\n}", "func (v *TextView) SetPixelsBelowLines(px int) {\n\tC.gtk_text_view_set_pixels_below_lines(v.native(), C.gint(px))\n}", "func TestServerZeroWindowAdjust(t *testing.T) {\n\tconn := dial(exitStatusZeroHandler, t)\n\tdefer conn.Close()\n\tsession, err := conn.NewSession()\n\tif err != nil {\n\t\tt.Fatalf(\"Unable to request new session: %v\", err)\n\t}\n\tdefer session.Close()\n\n\tif err := session.Shell(); err != nil {\n\t\tt.Fatalf(\"Unable to execute command: %v\", err)\n\t}\n\n\t// send a bogus zero sized window update\n\tsession.clientChan.sendWindowAdj(0)\n\n\terr = session.Wait()\n\tif err != nil {\n\t\tt.Fatalf(\"expected nil but got %v\", err)\n\t}\n}", "func (w *ScrollWidget) SetMax(max int) {\n\tw.max = max\n\tw.clampCurrent()\n}", "func (sf *TWindow) SetSizable(sizable bool) {\n\tsf.fixedSize = !sizable\n}", "func (label *LabelWidget) SetHeight(height float64) {\n\tlabel.box.height = height\n\tlabel.fixedHeight = true\n\tlabel.RequestReflow()\n}", "func (w *WidgetImplement) SetHeight(h int) {\n\tw.h = h\n}", "func (sf *TWindow) SetMaximized(maximize bool) {\n\tif maximize == sf.maximized {\n\t\treturn\n\t}\n\n\tif maximize {\n\t\tx, y := sf.pos.Get()\n\t\tsf.posOrig.X().Set(x)\n\t\tsf.posOrig.Y().Set(y)\n\t\tsf.origWidth, sf.origHeight = sf.Size()\n\t\tsf.maximized = true\n\t\tsf.SetPos(0, 0)\n\t\twidth, height := ScreenSize()\n\t\tsf.SetSize(width, height)\n\t} else {\n\t\tsf.maximized = false\n\t\tsf.SetPos(sf.posOrig.GetX(), sf.posOrig.GetY())\n\t\tsf.SetSize(sf.origWidth, sf.origHeight)\n\t}\n\tsf.ResizeChildren()\n\tsf.PlaceChildren()\n}", "func (m *Model) SetHeight(height int) {\n\t// Make space for the description string.\n\tm.height = clamp(height, 2, m.maxHeight)\n\tfor _, l := range m.valueLists {\n\t\tl.SetHeight(m.height - 1)\n\t\t// Force recomputing the keybindings, which\n\t\t// is dependent on the page size.\n\t\tl.SetFilteringEnabled(true)\n\t}\n}", "func (v *ScrolledWindow) GetMaxContentWidth() int {\n\tc := C.gtk_scrolled_window_get_max_content_width(v.native())\n\treturn int(c)\n}", "func (l *Label) setHeight(g *Graph) bool {\n // keep track of whether or not the height has changed\n changed := false\n \n Assert (nilLabel, l != nil)\n Assert(nilGraph, g != nil)\n Assert(nilLabelStore, g.labelStore != nil)\n \n var newHeight uint8\n \n // get the heights of the right and left nodes\n left, _ := l.left(g) // TODO do not ignore this error\n right, _ := l.right(g) // TODO do not ignore this error\n \n lh := left.height() \n rh := right.height() \n \n // determine the new height\n if (lh < rh) {\n newHeight = uint8(1 + rh)\n } else {\n newHeight = uint8(1 + lh)\n }\n \n if int8(newHeight) != l.height() {\n changed = true\n }\n \n l.h = newHeight\n \n return changed\n}", "func (sf *TWindow) Sizable() bool {\n\treturn !sf.fixedSize\n}", "func (w *LWindow) MHeight() int32 {\n\treturn w.mHeight\n}", "func (window Window) OuterHeight() int {\n\treturn window.Get(\"outerHeight\").Int()\n}", "func (v *View) ScrollDown(n int) {\n\t// Try to scroll by n but if it would overflow, scroll by 1\n\tif v.Topline+n <= v.Buf.NumLines {\n\t\tv.Topline += n\n\t} else if v.Topline < v.Buf.NumLines-1 {\n\t\tv.Topline++\n\t}\n}", "func (me *XsdGoPkgHasElems_MaxHeight) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElems_MaxHeight; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (wg *WidgetImplement) SetFixedWidth(w int) {\n\twg.fixedW = w\n}", "func AllNaturalBreaks(data []float64, maxClasses int) [][]float64 {\n\t// sort data in numerical order, since this is expected by the matrices function\n\tdata = sortData(data)\n\n\t// sanity check\n\tuniq := deduplicate(data)\n\tif maxClasses > len(uniq) {\n\t\tmaxClasses = len(uniq)\n\t}\n\n\t// get our basic matrices (we only need lower class limits here)\n\tlowerClassLimits, _ := getMatrices(data, maxClasses)\n\n\t// extract nClasses out of the computed matrices\n\tallBreaks := [][]float64{}\n\tfor i := 2; i <= maxClasses; i++ {\n\t\tnClasses := breaks(data, lowerClassLimits, i)\n\t\tif i == len(uniq) {\n\t\t\tnClasses = uniq\n\t\t}\n\t\tallBreaks = append(allBreaks, nClasses)\n\t}\n\treturn allBreaks\n}", "func (h *Handle) NeighSet(neigh *Neigh) error {\n\treturn h.neighAdd(neigh, syscall.NLM_F_CREATE|syscall.NLM_F_REPLACE)\n}", "func (v *View) ScrollDown(n int) {\n\t// Try to scroll by n but if it would overflow, scroll by 1\n\tif v.topline+n <= len(v.buf.lines)-v.height {\n\t\tv.topline += n\n\t} else if v.topline < len(v.buf.lines)-v.height {\n\t\tv.topline++\n\t}\n}", "func (me *XsdGoPkgHasElem_MaxHeight) Walk() (err error) {\r\n\tif fn := WalkHandlers.XsdGoPkgHasElem_MaxHeight; me != nil {\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, true); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t\tif fn != nil {\r\n\t\t\tif err = fn(me, false); xsdt.OnWalkError(&err, &WalkErrors, WalkContinueOnError, WalkOnError) {\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn\r\n}", "func (fb *FlowBox) SetMinChildrenPerLine(n_children uint) {\n\tC.gtk_flow_box_set_min_children_per_line(fb.native(), C.guint(n_children))\n}", "func (win *Window) SetKeepAbove(setting bool) {\n\twin.Candy().Guify(\"gtk_window_set_keep_above\", win, setting)\n}", "func (s *ItemScroller) autoSize() {\n\n\tif s.maxAutoWidth == 0 && s.maxAutoHeight == 0 {\n\t\treturn\n\t}\n\n\tvar width float32\n\tvar height float32\n\tfor _, item := range s.items {\n\t\tpanel := item.GetPanel()\n\t\tif panel.Width() > width {\n\t\t\twidth = panel.Width()\n\t\t}\n\t\theight += panel.Height()\n\t}\n\n\t// If auto maximum width enabled\n\tif s.maxAutoWidth > 0 {\n\t\tif width <= s.maxAutoWidth {\n\t\t\ts.SetContentWidth(width)\n\t\t}\n\t}\n\t// If auto maximum height enabled\n\tif s.maxAutoHeight > 0 {\n\t\tif height <= s.maxAutoHeight {\n\t\t\ts.SetContentHeight(height)\n\t\t}\n\t}\n}", "func (s *Scroll) SetWindow(win sparta.Window) {\n\ts.win = win\n}", "func (this *WeightedSum) ivweightedSumPropagate(varid core.VarId, evt *core.ChangeEvent) {\n\n\tthis.checkXmultCeqY(varid, evt)\n\n\tthis.ivsumPropagate(varid, evt)\n}", "func (c *HostClient) SetMaxConns(newMaxConns int) {\n\tc.connsLock.Lock()\n\tc.MaxConns = newMaxConns\n\tc.connsLock.Unlock()\n}", "func (win *Window) Height() int {\n\tsize := C.sfRenderWindow_getSize(win.win)\n\treturn int(size.y)\n}", "func (fb *FlowBox) SetHAdjustment(adjustment *Adjustment) {\n\tC.gtk_flow_box_set_hadjustment(fb.native(), adjustment.native())\n}", "func (wg *WidgetImplement) SetFixedSize(w, h int) {\n\twg.fixedW = w\n\twg.fixedH = h\n}", "func (win *Window) SetPolicy(allowShrink, allowGrow, autoShrink int) {\n\twin.Candy().Guify(\"gtk_window_set_policy\", win, allowShrink, allowGrow, autoShrink)\n}", "func (w *Wrapper) NaturalJoin(table interface{}, condition string) *Wrapper {\n\tw.saveJoin(table, \"NATURAL JOIN\", condition)\n\treturn w\n}", "func (p *Protocol) GetEpochHeight(epochNum uint64) uint64 {\n\tif epochNum == 0 {\n\t\treturn 0\n\t}\n\tdardanellesEpoch := p.GetEpochNum(p.dardanellesHeight)\n\tif !p.dardanellesOn || epochNum <= dardanellesEpoch {\n\t\treturn (epochNum-1)*p.numDelegates*p.numSubEpochs + 1\n\t}\n\tdardanellesEpochHeight := p.GetEpochHeight(dardanellesEpoch)\n\treturn dardanellesEpochHeight + (epochNum-dardanellesEpoch)*p.numDelegates*p.numSubEpochsDardanelles\n}", "func AbsEndRun(window fyne.Window, c *fyne.Container, w, h int) {\n\twindow.Resize(fyne.NewSize(float32(w), float32(h)))\n\twindow.SetFixedSize(true)\n\twindow.SetPadded(false)\n\twindow.SetContent(c)\n\twindow.ShowAndRun()\n}", "func (b *Bound) Height() float64 {\n\treturn b.ne.Y() - b.sw.Y()\n}", "func (v *TextView) SetPixelsAboveLines(px int) {\n\tC.gtk_text_view_set_pixels_above_lines(v.native(), C.gint(px))\n}", "func Natural(value float64) bool {\n\treturn Whole(value) && value > 0\n}", "func (this *FeedableBuffer) Maximize() {\n\tthis.ExpandTo(this.maxByteCount)\n}", "func UpdateMaxNodesCount(nodesCount int) {\n\tmaxNodesCount.Set(float64(nodesCount))\n}", "func (n *node) confine(adjustment float64) float64 {\n\tconfined := math.Max(1/DiffConfineFactor, adjustment)\n\tconfined = math.Min(DiffConfineFactor, confined)\n\n\treturn confined\n}", "func (v *TextView) GetBorderWindowSize(tp TextWindowType) int {\n\treturn int(C.gtk_text_view_get_border_window_size(v.native(), C.GtkTextWindowType(tp)))\n}", "func (wh *WholeNet) Backpropagate(target *t.Tensor) {\n\tlastLayer := (*wh).Layers[len((*wh).Layers)-1].GetOutput()\n\n\tdifference := lastLayer.Sub(target)\n\t(*wh).Layers[len((*wh).Layers)-1].CalculateGradients(&difference)\n\n\tfor i := len((*wh).Layers) - 2; i >= 0; i-- {\n\t\tgrad := (*wh).Layers[i+1].GetGradients()\n\t\t(*wh).Layers[i].CalculateGradients(&grad)\n\t}\n\tfor i := range (*wh).Layers {\n\t\t(*wh).Layers[i].UpdateWeights()\n\t}\n}", "func (w *WidgetImplement) OnPerformLayout(self Widget, ctx *canvas.Context) {\n\tif w.layout != nil {\n\t\tw.layout.OnPerformLayout(self, ctx)\n\t} else {\n\t\tfor _, child := range w.children {\n\t\t\tprefW, prefH := child.PreferredSize(child, ctx)\n\t\t\tfixW, fixH := child.FixedSize()\n\t\t\tw := toI(fixW > 0, fixW, prefW)\n\t\t\th := toI(fixH > 0, fixH, prefH)\n\t\t\tchild.SetSize(w, h)\n\t\t\tchild.OnPerformLayout(child, ctx)\n\t\t}\n\t}\n}", "func WithMaxRound(round types.RoundID) OptionFunc {\n\treturn func(wc *WeakCoin) {\n\t\twc.config.MaxRound = round\n\t}\n}", "func newAdjustmentFromNative(obj unsafe.Pointer) interface{} {\n\ta := &Adjustment{}\n\ta.object = C.to_GtkAdjustment(obj)\n\n\tif gobject.IsObjectFloating(a) {\n\t\tgobject.RefSink(a)\n\t} else {\n\t\tgobject.Ref(a)\n\t}\n\tadjustmentFinalizer(a)\n\n\treturn a\n}", "func SetMaxNumberEntries(sz int) {\n\tC.hepevt_set_max_number_entries(C.int(sz))\n}", "func WindowSize(s int) ConfigFunc {\n\treturn func(c *Config) {\n\t\tc.WindowSize = s\n\t}\n}", "func (v *View) PageDown() {\n\tif len(v.buf.lines)-(v.topline+v.height) > v.height {\n\t\tv.ScrollDown(v.height)\n\t} else {\n\t\tif len(v.buf.lines) >= v.height {\n\t\t\tv.topline = len(v.buf.lines) - v.height\n\t\t}\n\t}\n}", "func WithMaxStaleness(ms time.Duration) Option {\n\treturn func(rp *ReadPref) error {\n\t\trp.maxStaleness = ms\n\t\trp.maxStalenessSet = true\n\t\treturn nil\n\t}\n}", "func (s *Service) onWindowResize(channel chan os.Signal) {\n\t//stdScr, _ := gc.Init()\n\t//stdScr.ScrollOk(true)\n\t//gc.NewLines(true)\n\tfor {\n\t\t<-channel\n\t\t//gc.StdScr().Clear()\n\t\t//rows, cols := gc.StdScr().MaxYX()\n\t\tcols, rows := GetScreenSize()\n\t\ts.screenRows = rows\n\t\ts.screenCols = cols\n\t\ts.resizeWindows()\n\t\t//gc.End()\n\t\t//gc.Update()\n\t\t//gc.StdScr().Refresh()\n\t}\n}", "func SetMaxDepthDifference(maxDifference float64) {\n\tHeightMininum = maxDifference\n}", "func SetScrollContentTrackerSize(sa *qtwidgets.QScrollArea) {\n\twgt := sa.Widget()\n\tsa.InheritResizeEvent(func(arg0 *qtgui.QResizeEvent) {\n\t\tosz := arg0.OldSize()\n\t\tnsz := arg0.Size()\n\t\tif false {\n\t\t\tlog.Println(osz.Width(), osz.Height(), nsz.Width(), nsz.Height())\n\t\t}\n\t\tif osz.Width() != nsz.Width() {\n\t\t\twgt.SetMaximumWidth(nsz.Width())\n\t\t}\n\t\t// this.ScrollArea_2.ResizeEvent(arg0)\n\t\targ0.Ignore() // I ignore, you handle it. replace explict call parent's\n\t})\n}", "func (s *ItemScroller) setHScrollBar(state bool) {\n\n\t// Visible\n\tif state {\n\t\tvar scrollHeight float32 = 20\n\t\tif s.hscroll == nil {\n\t\t\ts.hscroll = NewHScrollBar(0, 0)\n\t\t\ts.hscroll.SetBorders(1, 0, 0, 0)\n\t\t\ts.hscroll.Subscribe(OnChange, s.onScrollBarEvent)\n\t\t\ts.Panel.Add(s.hscroll)\n\t\t}\n\t\ts.hscroll.SetSize(s.ContentWidth(), scrollHeight)\n\t\ts.hscroll.SetPositionX(0)\n\t\ts.hscroll.SetPositionY(s.ContentHeight() - scrollHeight)\n\t\ts.hscroll.recalc()\n\t\ts.hscroll.SetVisible(true)\n\t\t// Not visible\n\t} else {\n\t\tif s.hscroll != nil {\n\t\t\ts.hscroll.SetVisible(false)\n\t\t}\n\t}\n}", "func (me XsdGoPkgHasAttr_MaxLines_XsdtInt_2) MaxLinesDefault() xsdt.Int {\r\n\tvar x = new(xsdt.Int)\r\n\tx.Set(\"2\")\r\n\treturn *x\r\n}", "func (v *View) ScrollUp(n int) {\n\t// Try to scroll by n but if it would overflow, scroll by 1\n\tif v.Topline-n >= 0 {\n\t\tv.Topline -= n\n\t} else if v.Topline > 0 {\n\t\tv.Topline--\n\t}\n}", "func WithNonMonotonic(nm bool) CounterOptionApplier {\n\treturn counterOptionWrapper{\n\t\tF: func(d *Descriptor) {\n\t\t\td.alternate = nm\n\t\t},\n\t}\n}", "func nlimit(n int) int {\n\tif n > maxNewlines {\n\t\tn = maxNewlines\n\t}\n\treturn n\n}", "func (syncer *MerkleSyncer) updateHeight() {\n\tatomic.AddUint64(&syncer.height, 1)\n}", "func (canvas *CanvasWidget) SetHeight(height float64) {\n\tcanvas.box.height = height\n\tcanvas.fixedHeight = true\n\tcanvas.RequestReflow()\n}", "func (t *Link) SetUnknownHeight(i interface{}) {\n\tif t.unknown_ == nil {\n\t\tt.unknown_ = make(map[string]interface{})\n\t}\n\ttmp := &heightIntermediateType{}\n\ttmp.unknown_ = i\n\tt.height = tmp\n\n}", "func (t *Terminal) Resize(s fyne.Size) {\n\tif s.Width == t.Size().Width && s.Height == t.Size().Height {\n\t\treturn\n\t}\n\tif s.Width < 20 { // not sure why we get tiny sizes\n\t\treturn\n\t}\n\tt.BaseWidget.Resize(s)\n\tt.content.Resize(s)\n\n\tcellSize := t.guessCellSize()\n\toldRows := int(t.config.Rows)\n\n\tt.config.Columns = uint(math.Floor(float64(s.Width) / float64(cellSize.Width)))\n\tt.config.Rows = uint(math.Floor(float64(s.Height) / float64(cellSize.Height)))\n\tif t.scrollBottom == 0 || t.scrollBottom == oldRows-1 {\n\t\tt.scrollBottom = int(t.config.Rows) - 1\n\t}\n\tt.onConfigure()\n\n\tgo t.updatePTYSize()\n}", "func PushDownWindowAggregateMax() BoolFlag {\n\treturn pushDownWindowAggregateMax\n}", "func WithMonotonic(m bool) GaugeOptionApplier {\n\treturn gaugeOptionWrapper{\n\t\tF: func(d *Descriptor) {\n\t\t\td.alternate = m\n\t\t},\n\t}\n}", "func (win *Window) SetMaximizeCallback(callback WindowMaximizeCallback) WindowMaximizeCallback {\n\tcallbacks, exist := windowCallbacks[win]\n\tif !exist {\n\t\tcallbacks = new(WindowCallbacks)\n\t\twindowCallbacks[win] = callbacks\n\t}\n\n\tpreviousCallback := callbacks.MaximizeCallback\n\tcallbacks.MaximizeCallback = callback\n\n\tif callback != nil {\n\t\tC.goSetWindowMaximizeCallback(win.c())\n\t} else {\n\t\tC.goRemoveWindowMaximizeCallback(win.c())\n\t}\n\n\treturn previousCallback\n}", "func (cs *ConsensusState) updateHeight(height int64) {\n\tcs.Height = height\n}", "func (t *Link) SetHeight(v int64) {\n\tt.height = &heightIntermediateType{nonNegativeInteger: &v}\n\n}", "func (o *WaitListParams) SetHeight(height *uint64) {\n\to.Height = height\n}", "func (v *View) ScrollUp(n int) {\n\t// Try to scroll by n but if it would overflow, scroll by 1\n\tif v.topline-n >= 0 {\n\t\tv.topline -= n\n\t} else if v.topline > 0 {\n\t\tv.topline--\n\t}\n}", "func (n *windowNode) populateValues() error {\n\tacc := n.windowsAcc.Wtxn(n.planner.session)\n\trowCount := n.wrappedRenderVals.Len()\n\tn.values.rows = NewRowContainer(\n\t\tn.planner.session.TxnState.makeBoundAccount(), n.values.columns, rowCount,\n\t)\n\n\trow := make(parser.DTuple, len(n.windowRender))\n\tfor i := 0; i < rowCount; i++ {\n\t\twrappedRow := n.wrappedRenderVals.At(i)\n\n\t\tn.curRowIdx = i // Point all windowFuncHolders to the correct row values.\n\t\tcurColIdx := 0\n\t\tcurFnIdx := 0\n\t\tfor j := range row {\n\t\t\tif curWindowRender := n.windowRender[j]; curWindowRender == nil {\n\t\t\t\t// If the windowRender at this index is nil, propagate the datum\n\t\t\t\t// directly from the wrapped planNode. It wasn't changed by windowNode.\n\t\t\t\trow[j] = wrappedRow[curColIdx]\n\t\t\t\tcurColIdx++\n\t\t\t} else {\n\t\t\t\t// If the windowRender is not nil, ignore 0 or more columns from the wrapped\n\t\t\t\t// planNode. These were used as arguments to window functions all beneath\n\t\t\t\t// a single windowRender.\n\t\t\t\t// SELECT rank() over () from t; -> ignore 0 from wrapped values\n\t\t\t\t// SELECT (rank() over () + avg(b) over ()) from t; -> ignore 1 from wrapped values\n\t\t\t\t// SELECT (avg(a) over () + avg(b) over ()) from t; -> ignore 2 from wrapped values\n\t\t\t\tfor ; curFnIdx < len(n.funcs); curFnIdx++ {\n\t\t\t\t\twindowFn := n.funcs[curFnIdx]\n\t\t\t\t\tif windowFn.argIdxStart != curColIdx {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcurColIdx += windowFn.argCount\n\t\t\t\t}\n\t\t\t\t// Instead, we evaluate the current window render, which depends on at least\n\t\t\t\t// one window function, at the given row.\n\t\t\t\tres, err := curWindowRender.Eval(&n.planner.evalCtx)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\trow[j] = res\n\t\t\t}\n\t\t}\n\n\t\tif _, err := n.values.rows.AddRow(row); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Done using the output of computeWindows, release memory and clear\n\t// accounts.\n\tn.wrappedRenderVals.Close()\n\tn.wrappedRenderVals = nil\n\tn.wrappedIndexedVarVals.Close()\n\tn.wrappedIndexedVarVals = nil\n\tn.windowValues = nil\n\tacc.Close()\n\n\treturn nil\n}", "func (v *Label) SetLines(lines int) {\n\tC.gtk_label_set_lines(v.native(), C.gint(lines))\n}", "func (m *MainWindow) initializeSidebar() {\n\tsidebar_vbox := gtk.NewVBox(false, 0)\n\n\tserver_info_frame := gtk.NewFrame(ctx.Translator.Translate(\"Server information\", nil))\n\tsidebar_vbox.PackStart(server_info_frame, true, true, 5)\n\tsi_vbox := gtk.NewVBox(false, 0)\n\tserver_info_frame.Add(si_vbox)\n\n\t// Scrolled thing.\n\tsi_scroll := gtk.NewScrolledWindow(nil, nil)\n\tsi_scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)\n\tsi_vbox.PackStart(si_scroll, true, true, 5)\n\n\t// Server's information.\n\tm.server_info = gtk.NewTreeView()\n\tm.server_info.SetModel(m.server_info_store)\n\n\tkey_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Key\", nil), gtk.NewCellRendererText(), \"markup\", 0)\n\tm.server_info.AppendColumn(key_column)\n\n\tvalue_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Value\", nil), gtk.NewCellRendererText(), \"markup\", 1)\n\tm.server_info.AppendColumn(value_column)\n\n\tsi_scroll.Add(m.server_info)\n\n\t// Players information.\n\tplayers_info_frame := gtk.NewFrame(ctx.Translator.Translate(\"Players\", nil))\n\tsidebar_vbox.PackStart(players_info_frame, true, true, 5)\n\n\tpi_scroll := gtk.NewScrolledWindow(nil, nil)\n\tpi_scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)\n\tplayers_info_frame.Add(pi_scroll)\n\n\tm.players_info = gtk.NewTreeView()\n\tm.players_info.SetModel(m.players_info_store)\n\tpi_scroll.Add(m.players_info)\n\n\tname_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Player name\", nil), gtk.NewCellRendererText(), \"markup\", 0)\n\tm.players_info.AppendColumn(name_column)\n\n\tfrags_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Frags\", nil), gtk.NewCellRendererText(), \"markup\", 1)\n\tm.players_info.AppendColumn(frags_column)\n\n\tping_column := gtk.NewTreeViewColumnWithAttributes(ctx.Translator.Translate(\"Ping\", nil), gtk.NewCellRendererText(), \"markup\", 2)\n\tm.players_info.AppendColumn(ping_column)\n\n\t// Show CVars button.\n\tshow_cvars_button := gtk.NewButtonWithLabel(ctx.Translator.Translate(\"Show CVars\", nil))\n\tshow_cvars_button.SetTooltipText(ctx.Translator.Translate(\"Show server's CVars\", nil))\n\tshow_cvars_button.Clicked(m.showServerCVars)\n\tsidebar_vbox.PackStart(show_cvars_button, false, true, 5)\n\n\t// Quick connect frame.\n\tquick_connect_frame := gtk.NewFrame(ctx.Translator.Translate(\"Quick connect\", nil))\n\tsidebar_vbox.PackStart(quick_connect_frame, false, true, 5)\n\tqc_vbox := gtk.NewVBox(false, 0)\n\tquick_connect_frame.Add(qc_vbox)\n\n\t// Server address.\n\tsrv_tooltip := ctx.Translator.Translate(\"Server address we will connect to\", nil)\n\tsrv_label := gtk.NewLabel(ctx.Translator.Translate(\"Server address:\", nil))\n\tsrv_label.SetTooltipText(srv_tooltip)\n\tqc_vbox.PackStart(srv_label, false, true, 5)\n\n\tm.qc_server_address = gtk.NewEntry()\n\tm.qc_server_address.SetTooltipText(srv_tooltip)\n\tqc_vbox.PackStart(m.qc_server_address, false, true, 5)\n\n\t// Password.\n\tpass_tooltip := ctx.Translator.Translate(\"Password we will use for server\", nil)\n\tpass_label := gtk.NewLabel(ctx.Translator.Translate(\"Password:\", nil))\n\tpass_label.SetTooltipText(pass_tooltip)\n\tqc_vbox.PackStart(pass_label, false, true, 5)\n\n\tm.qc_password = gtk.NewEntry()\n\tm.qc_password.SetTooltipText(pass_tooltip)\n\tqc_vbox.PackStart(m.qc_password, false, true, 5)\n\n\t// Nickname\n\tnick_tooltip := ctx.Translator.Translate(\"Nickname we will use\", nil)\n\tnick_label := gtk.NewLabel(ctx.Translator.Translate(\"Nickname:\", nil))\n\tnick_label.SetTooltipText(nick_tooltip)\n\tqc_vbox.PackStart(nick_label, false, true, 5)\n\n\tm.qc_nickname = gtk.NewEntry()\n\tm.qc_nickname.SetTooltipText(nick_tooltip)\n\tqc_vbox.PackStart(m.qc_nickname, false, true, 5)\n\n\tm.hpane.Add2(sidebar_vbox)\n}" ]
[ "0.8024622", "0.7986467", "0.6738286", "0.48992896", "0.46789613", "0.45104513", "0.44237876", "0.43279177", "0.42821398", "0.42359063", "0.41540527", "0.4000865", "0.39987636", "0.397609", "0.39755943", "0.39618266", "0.39565128", "0.3954699", "0.39486593", "0.39300218", "0.3919906", "0.39164233", "0.39049605", "0.38074327", "0.37919587", "0.3772034", "0.37640107", "0.37321723", "0.37288117", "0.37184706", "0.3710474", "0.3704771", "0.36775517", "0.36725175", "0.36694705", "0.36542833", "0.3634152", "0.3626809", "0.36108017", "0.3595091", "0.35924673", "0.35637718", "0.3561461", "0.3558079", "0.3556662", "0.3551393", "0.35470152", "0.35462645", "0.35355553", "0.35283792", "0.35242385", "0.35151252", "0.34993306", "0.34949544", "0.34920505", "0.3479313", "0.34644112", "0.3459414", "0.34541786", "0.34478474", "0.34473425", "0.34470138", "0.34436092", "0.34434816", "0.34422895", "0.34412178", "0.3438194", "0.3438064", "0.34358144", "0.34306887", "0.34234542", "0.34189036", "0.34172365", "0.341685", "0.34111375", "0.34086567", "0.33986938", "0.33971453", "0.33878395", "0.33844122", "0.338411", "0.33826143", "0.3382605", "0.33772534", "0.33708617", "0.33675802", "0.3361676", "0.33601463", "0.3353844", "0.33449438", "0.3335192", "0.3333231", "0.33089995", "0.33083972", "0.33070737", "0.3298121", "0.32930812", "0.32929182", "0.32870975", "0.3285696" ]
0.91302776
0
GetKlines returns transaction details
func (c *client) GetKlines(query *KlineQuery) ([]Kline, error) { err := query.Check() if err != nil { return nil, err } qp, err := common.QueryParamToMap(*query) if err != nil { return nil, err } resp, err := c.baseClient.Get("/klines", qp) if err != nil { return nil, err } iklines := [][]interface{}{} if err := json.Unmarshal(resp, &iklines); err != nil { return nil, err } klines := make([]Kline, len(iklines)) // Todo for index, ikline := range iklines { kl := Kline{} imap := make(map[string]interface{}, 9) if len(ikline) >= 9 { imap["openTime"] = ikline[0] imap["open"] = ikline[1] imap["high"] = ikline[2] imap["low"] = ikline[3] imap["close"] = ikline[4] imap["volume"] = ikline[5] imap["closeTime"] = ikline[6] imap["quoteAssetVolume"] = ikline[7] imap["NumberOfTrades"] = ikline[8] } else { return nil, fmt.Errorf("Receive kline scheme is unexpected ") } bz, err := json.Marshal(imap) if err != nil { return nil, err } err = json.Unmarshal(bz, &kl) if err != nil { return nil, err } klines[index] = kl } return klines, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Coinbene) GetKlines(pair string, start, end time.Time, period string) (resp CandleResponse, err error) {\n\tv := url.Values{}\n\tv.Add(\"symbol\", pair)\n\tif !start.IsZero() {\n\t\tv.Add(\"start\", strconv.FormatInt(start.Unix(), 10))\n\t}\n\tif !end.IsZero() {\n\t\tv.Add(\"end\", strconv.FormatInt(end.Unix(), 10))\n\t}\n\tv.Add(\"period\", period)\n\n\tpath := common.EncodeURLValues(coinbeneAPIVersion+coinbeneSpotKlines, v)\n\tif err = c.SendHTTPRequest(exchange.RestSpot, path, contractKline, &resp); err != nil {\n\t\treturn\n\t}\n\n\tif resp.Code != 200 {\n\t\treturn resp, errors.New(resp.Message)\n\t}\n\n\treturn\n}", "func (this *Spot) GetKlineRecords(pair Pair, period, size, since int) ([]Kline, []byte, error) {\n\tif period != KLINE_PERIOD_1MIN {\n\t\treturn nil, nil, errors.New(\"Can not support the period in bitstamp. \")\n\t}\n\n\turi := fmt.Sprintf(\n\t\t\"/api/v2/transactions/%s/?time=day\",\n\t\tstrings.ToLower(pair.ToSymbol(\"\", false)),\n\t)\n\tresponse := make([]struct {\n\t\tDate int64 `json:\"date,string\"`\n\t\tPrice float64 `json:\"price,string\"`\n\t\tAmount float64 `json:\"amount,string\"`\n\t}, 0)\n\n\tresp, err := this.DoRequest(\"GET\", uri, \"\", &response) //&response)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif len(response) == 0 {\n\t\treturn nil, nil, errors.New(\"Have not receive enough data. \")\n\t}\n\n\tklineRecord := make(map[int64]Kline, 0)\n\tklineTimestamp := make([]int64, 0)\n\tfor _, order := range response {\n\t\tminTimestamp := order.Date / 60 * 60 * 1000\n\t\tkline, exist := klineRecord[minTimestamp]\n\t\tif !exist {\n\t\t\tt := time.Unix(minTimestamp/1000, 0)\n\t\t\tkline = Kline{\n\t\t\t\tTimestamp: minTimestamp,\n\t\t\t\tDate: t.In(this.config.Location).Format(GO_BIRTHDAY),\n\t\t\t\tPair: pair,\n\t\t\t\tExchange: BITSTAMP,\n\t\t\t\tOpen: order.Price,\n\t\t\t\tHigh: order.Price,\n\t\t\t\tLow: order.Price,\n\t\t\t\tClose: order.Price,\n\t\t\t\tVol: order.Amount,\n\t\t\t}\n\t\t\tklineRecord[minTimestamp] = kline\n\t\t\tklineTimestamp = append(klineTimestamp, minTimestamp)\n\t\t\tcontinue\n\t\t}\n\n\t\tkline.Open = order.Price\n\t\tkline.Vol += order.Amount\n\t\tif order.Price > kline.High {\n\t\t\tkline.High = order.Price\n\t\t}\n\t\tif order.Price < kline.Low {\n\t\t\tkline.Low = order.Price\n\t\t}\n\t\tklineRecord[minTimestamp] = kline\n\t}\n\n\tklines := make([]Kline, 0)\n\tfor i := 0; i < len(klineTimestamp)-1; i++ {\n\t\tklines = append(klines, klineRecord[klineTimestamp[i]])\n\t}\n\n\treturn klines, resp, nil\n}", "func (m *Market) KLines(symbol string, period int) (MarketResponse, error) {\n\tkLinesURL := URL(\"/v1/klines\")\n\tvar result MarketResponse\n\n\tif symbol == \"\" {\n\t\treturn result, errors.New(\"Symbol cannot be empty\")\n\t}\n\n\tif !allowedPeriod(period) {\n\t\treturn result, errors.New(\"Period selected is not allowed\")\n\t}\n\n\tquery := url.Values{\n\t\t\"period\": []string{strconv.Itoa(period)},\n\t\t\"symbol\": []string{symbol},\n\t}\n\n\tresp, err := method.Get(kLinesURL, nil, query)\n\tif err != nil {\n\t\treturn result, err\n\t}\n\tdefer resp.Body.Close()\n\n\t// Crypto.com Exchange does not return 404 when symbol does not show\n\tif resp.StatusCode == 500 {\n\t\treturn result, errors.New(\"Symbol does not exist\")\n\t}\n\n\treturn bodyToMarketResponse(resp.Body, &result)\n}", "func getKlines(s model.Stock) ([]*model.Kline, *model.KlineW, *model.KlineM) {\n\tmxw, mxm := getMaxDates(s.Code)\n\tvar klines []*model.Kline\n\t_, err := dbmap.Select(&klines, \"select * from kline_d where code = ? order by date\", s.Code)\n\tcheckErr(err, \"Failed to query kline_d for \"+s.Code)\n\treturn klines, mxw, mxm\n}", "func (c *Client) Klines(symbol string, interval binance.KlineInterval) (*Klines, error) {\n\tvar b strings.Builder\n\tb.WriteString(baseWS)\n\tb.WriteString(strings.ToLower(symbol))\n\tb.WriteString(\"@kline_\")\n\tb.WriteString(string(interval))\n\tconn, err := fastws.Dial(b.String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Klines{wsClient{conn: conn}}, nil\n}", "func (c *Coinbene) GetSwapKlines(symbol string, start, end time.Time, resolution string) (resp CandleResponse, err error) {\n\tv := url.Values{}\n\tv.Set(\"symbol\", symbol)\n\tif !start.IsZero() {\n\t\tv.Add(\"startTime\", strconv.FormatInt(start.Unix(), 10))\n\t}\n\tif !end.IsZero() {\n\t\tv.Add(\"endTime\", strconv.FormatInt(end.Unix(), 10))\n\t}\n\tv.Set(\"resolution\", resolution)\n\n\tpath := common.EncodeURLValues(coinbeneAPIVersion+coinbeneGetKlines, v)\n\tif err = c.SendHTTPRequest(exchange.RestSwap, path, contractKline, &resp); err != nil {\n\t\treturn\n\t}\n\n\treturn\n}", "func getKlineThs(stk *model.Stock, kltype []model.DBTab) (\n\tqmap map[model.DBTab][]*model.Quote, lkmap map[model.DBTab]int, suc bool) {\n\tRETRIES := conf.Args.DataSource.KlineFailureRetry\n\tqmap = make(map[model.DBTab][]*model.Quote)\n\tvar (\n\t\tcode = stk.Code\n\t)\n\tklts := make([]model.DBTab, len(kltype))\n\tcopy(klts, kltype)\n\tfor rt := 0; rt < RETRIES; rt++ {\n\t\tklsMap, lkdmap, suc, retry := klineThsCDPv2(stk, klts)\n\t\tif suc {\n\t\t\tqmap = klsMap\n\t\t\tlkmap = lkdmap\n\t\t\tbreak\n\t\t} else {\n\t\t\tif retry && rt+1 < RETRIES {\n\t\t\t\t//partial failure\n\t\t\t\tfor k, v := range klsMap {\n\t\t\t\t\tqmap[k] = v\n\t\t\t\t}\n\t\t\t\tif len(klsMap) < len(klts) {\n\t\t\t\t\tnklts := make([]model.DBTab, 0, len(klts))\n\t\t\t\t\tfor _, t := range klts {\n\t\t\t\t\t\tif _, ok := klsMap[t]; !ok {\n\t\t\t\t\t\t\tnklts = append(nklts, t)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tklts = nklts\n\t\t\t\t}\n\t\t\t\tlog.Printf(\"%s retrying [%d] for %+v\", code, rt+1, klts)\n\t\t\t\ttime.Sleep(time.Millisecond * time.Duration(1500+rand.Intn(2000)))\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\tlog.Printf(\"%s failed\", code)\n\t\t\t\treturn qmap, lkmap, false\n\t\t\t}\n\t\t}\n\t}\n\treturn qmap, lkmap, true\n}", "func (b *ByBit) GetKLine(symbol string, interval string, from int64, limit int) (result []OHLC, err error) {\n\tvar ret GetKlineResult\n\tparams := map[string]interface{}{}\n\tparams[\"symbol\"] = symbol\n\tparams[\"interval\"] = interval\n\tparams[\"from\"] = from\n\tif limit > 0 {\n\t\tparams[\"limit\"] = limit\n\t}\n\t_, err = b.PublicRequest(http.MethodGet, \"v2/public/kline/list\", params, &ret)\n\tif err != nil {\n\t\treturn\n\t}\n\tresult = ret.Result\n\treturn\n}", "func (by *Bybit) GetUSDCIndexPriceKlines(ctx context.Context, symbol currency.Pair, period string, startTime time.Time, limit int64) ([]USDCKlineBase, error) {\n\tresp := struct {\n\t\tData []USDCKlineBase `json:\"result\"`\n\t\tUSDCError\n\t}{}\n\n\tparams := url.Values{}\n\tif symbol.IsEmpty() {\n\t\treturn nil, errSymbolMissing\n\t}\n\tsymbolValue, err := by.FormatSymbol(symbol, asset.USDCMarginedFutures)\n\tif err != nil {\n\t\treturn resp.Data, err\n\t}\n\tparams.Set(\"symbol\", symbolValue)\n\n\tif !common.StringDataCompare(validFuturesIntervals, period) {\n\t\treturn resp.Data, errInvalidPeriod\n\t}\n\tparams.Set(\"period\", period)\n\n\tif startTime.IsZero() {\n\t\treturn nil, errInvalidStartTime\n\t}\n\tparams.Set(\"startTime\", strconv.FormatInt(startTime.Unix(), 10))\n\n\tif limit > 0 && limit <= 200 {\n\t\tparams.Set(\"limit\", strconv.FormatInt(limit, 10))\n\t}\n\treturn resp.Data, by.SendHTTPRequest(ctx, exchange.RestUSDCMargined, common.EncodeURLValues(usdcfuturesGetIndexPriceKlines, params), usdcPublicRate, &resp)\n}", "func (by *Bybit) GetUSDCPremiumIndexKlines(ctx context.Context, symbol currency.Pair, period string, startTime time.Time, limit int64) ([]USDCKlineBase, error) {\n\tresp := struct {\n\t\tData []USDCKlineBase `json:\"result\"`\n\t\tUSDCError\n\t}{}\n\n\tparams := url.Values{}\n\tif symbol.IsEmpty() {\n\t\treturn nil, errSymbolMissing\n\t}\n\tsymbolValue, err := by.FormatSymbol(symbol, asset.USDCMarginedFutures)\n\tif err != nil {\n\t\treturn resp.Data, err\n\t}\n\tparams.Set(\"symbol\", symbolValue)\n\n\tif !common.StringDataCompare(validFuturesIntervals, period) {\n\t\treturn resp.Data, errInvalidPeriod\n\t}\n\tparams.Set(\"period\", period)\n\n\tif startTime.IsZero() {\n\t\treturn nil, errInvalidStartTime\n\t}\n\tparams.Set(\"startTime\", strconv.FormatInt(startTime.Unix(), 10))\n\n\tif limit > 0 && limit <= 200 {\n\t\tparams.Set(\"limit\", strconv.FormatInt(limit, 10))\n\t}\n\treturn resp.Data, by.SendHTTPRequest(ctx, exchange.RestUSDCMargined, common.EncodeURLValues(usdcfuturesGetPremiumIndexKlines, params), usdcPublicRate, &resp)\n}", "func (p *CTPDll) GetMultipleKlines(contracts []string, intervalMinutes int, count int, randomString string) map[string][]KlineValue {\n\n\tif contracts == nil || len(contracts) == 0 || intervalMinutes == 0 || count == 0 || randomString == \"\" {\n\t\tlogger.Errorf(\"Invalid parameters\")\n\t\treturn nil\n\t}\n\n\tklines := make(map[string][]KlineValue)\n\tduration := float64(1000000000 * intervalMinutes * 60)\n\tdialer := Websocket.DefaultDialer\n\n\tconnection, _, err := dialer.Dial(p.URL, nil)\n\n\tif err != nil {\n\t\tlogger.Errorf(\"Fail to dial:%v\", err)\n\t\treturn nil\n\t}\n\n\tvar contractString string\n\tfor _, contract := range contracts {\n\t\tif contractString == \"\" {\n\t\t\tcontractString = contract\n\t\t} else {\n\t\t\tcontractString = contractString + \",\" + contract\n\t\t}\n\t}\n\n\tdefer connection.Close()\n\tstep := 0\n\tvar buffer []interface{}\n\n\tfor {\n\t\t_, message, err := connection.ReadMessage()\n\t\tif err != nil {\n\t\t\tlogger.Errorf(\"Fail to read:%v\", err)\n\t\t\treturn nil\n\t\t}\n\n\t\tvar response map[string]interface{}\n\n\t\tif err = json.Unmarshal([]byte(message), &response); err != nil {\n\t\t\tlogger.Errorf(\"Fail to Unmarshal:%v\", err)\n\t\t\treturn nil\n\t\t}\n\n\t\tlog.Printf(\"[%s]Reseponse\", time.Now().Format(\"2006-01-02 15:04:05.999999999\"))\n\t\tif step == 2 || step == 3 {\n\t\t\tdata := response[\"data\"].([]interface{})\n\t\t\t// log.Printf(\"LENGTH:%v\", len(data))\n\n\t\t\tif data != nil && len(data) > 0 { // if == 2, the datas are not ready in the server\n\n\t\t\t\tif data[len(data)-2].(map[string]interface{})[\"charts\"] != nil &&\n\t\t\t\t\tdata[len(data)-2].(map[string]interface{})[\"charts\"].(map[string]interface{})[randomString].(map[string]interface{})[\"left_id\"].(float64) == -1 {\n\t\t\t\t\tlog.Printf(\"Invalid data, resend peek\")\n\t\t\t\t\tcommand := map[string]interface{}{\n\t\t\t\t\t\t\"aid\": \"peek_message\",\n\t\t\t\t\t}\n\t\t\t\t\tsend(connection, command)\n\t\t\t\t\tcontinue\n\t\t\t\t} else if data[len(data)-2].(map[string]interface{})[\"mdhis_more_data\"] == true {\n\n\t\t\t\t\tlog.Printf(\"more datas reserved, resend peek\")\n\t\t\t\t\tcommand := map[string]interface{}{\n\t\t\t\t\t\t\"aid\": \"peek_message\",\n\t\t\t\t\t}\n\t\t\t\t\tsend(connection, command)\n\n\t\t\t\t\tfor _, tmp := range data[0 : len(data)-2] {\n\t\t\t\t\t\ttmpString, _ := json.Marshal(tmp)\n\t\t\t\t\t\tif strings.Contains(string(tmpString), \"binding\") {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif strings.Count(string(tmpString), \"datetime\") < 10 { // how about 10?\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbuffer = append(buffer, tmp)\n\t\t\t\t\t}\n\n\t\t\t\t\tcontinue\n\t\t\t\t} else {\n\t\t\t\t\tfor _, tmp := range data[0 : len(data)-2] {\n\t\t\t\t\t\ttmpString, _ := json.Marshal(tmp)\n\t\t\t\t\t\tif strings.Contains(string(tmpString), \"binding\") {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif strings.Count(string(tmpString), \"datetime\") < 10 {\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbuffer = append(buffer, tmp)\n\t\t\t\t\t}\n\n\t\t\t\t\t// for key, value := range buffer {\n\t\t\t\t\t// \tlog.Printf(\"Key:%v value:%v\", key, value)\n\t\t\t\t\t// }\n\n\t\t\t\t\t// return nil\n\n\t\t\t\t\tfor i, contract := range contracts {\n\t\t\t\t\t\t// log.Printf(\"[Index %d] %v\", i, data[i])\n\t\t\t\t\t\tdata := buffer[i].(map[string]interface{})[\"klines\"].(map[string]interface{})\n\t\t\t\t\t\tif data != nil {\n\t\t\t\t\t\t\t// log.Printf(\"data:%v contract:%v\", data, contract)\n\t\t\t\t\t\t\tif data[contract] != nil {\n\t\t\t\t\t\t\t\tvalues := data[contract].(map[string]interface{})\n\t\t\t\t\t\t\t\tif values != nil {\n\t\t\t\t\t\t\t\t\tdutrationStr := strconv.Itoa(int(duration))\n\t\t\t\t\t\t\t\t\tdatas := values[dutrationStr].(map[string]interface{})\n\t\t\t\t\t\t\t\t\tif datas[\"data\"] != nil {\n\t\t\t\t\t\t\t\t\t\tfor _, data := range datas[\"data\"].(map[string]interface{}) {\n\t\t\t\t\t\t\t\t\t\t\ttmp := data.(map[string]interface{})\n\t\t\t\t\t\t\t\t\t\t\tklines[contract] = append(klines[contract], KlineValue{\n\t\t\t\t\t\t\t\t\t\t\t\tTime: time.Unix(int64(tmp[\"datetime\"].(float64)/1000000000.0), 0).Format(\"2006-01-02 15:04:05\"),\n\t\t\t\t\t\t\t\t\t\t\t\tOpenTime: tmp[\"datetime\"].(float64) / 1000000000.0,\n\t\t\t\t\t\t\t\t\t\t\t\tOpen: tmp[\"open\"].(float64),\n\t\t\t\t\t\t\t\t\t\t\t\tHigh: tmp[\"high\"].(float64),\n\t\t\t\t\t\t\t\t\t\t\t\tLow: tmp[\"low\"].(float64),\n\t\t\t\t\t\t\t\t\t\t\t\tClose: tmp[\"close\"].(float64),\n\t\t\t\t\t\t\t\t\t\t\t\tVolumn: tmp[\"volume\"].(float64),\n\t\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tsort.Sort(KlineSort(klines[contract]))\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn klines\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tcommand := make(map[string]interface{})\n\n\t\tswitch step {\n\t\tcase 0:\n\t\t\tstep++\n\t\t\tcommand = map[string]interface{}{\n\t\t\t\t\"aid\": \"peek_message\",\n\t\t\t}\n\t\t\tsend(connection, command)\n\t\tcase 1:\n\t\t\tstep++\n\t\t\tcommand = map[string]interface{}{\n\t\t\t\t\"aid\": \"set_chart\", // 必填, 请求图表数据\n\t\t\t\t\"chart_id\": randomString, // 必填, 图表id, 服务器只会维护每个id收到的最后一个请求的数据\n\t\t\t\t\"ins_list\": contractString, // 必填, 填空表示删除该图表,多个合约以逗号分割,第一个合约是主合约,所有id都是以主合约为准\n\t\t\t\t\"duration\": duration, // 必填, 周期,单位ns, tick:0, 日线: 3600 * 24 * 1000 * 1000 * 1000\n\t\t\t\t\"view_width\": count, // 必填, 图表宽度, 请求最新N个数据,并保持滚动(新K线生成会移动图表)\n\t\t\t}\n\t\t\tsend(connection, command)\n\n\t\t\ttime.Sleep(100 * time.Microsecond)\n\n\t\t\tcommand = map[string]interface{}{\n\t\t\t\t\"aid\": \"peek_message\",\n\t\t\t}\n\t\t\tsend(connection, command)\n\t\tcase 2:\n\t\t\tstep++\n\t\t\ttime.Sleep(100 * time.Microsecond)\n\t\t\tcommand = map[string]interface{}{\n\t\t\t\t\"aid\": \"peek_message\",\n\t\t\t}\n\t\t\tsend(connection, command)\n\t\t}\n\n\t}\n\n\treturn nil\n}", "func (by *Bybit) GetUSDCMarkPriceKlines(ctx context.Context, symbol currency.Pair, period string, startTime time.Time, limit int64) ([]USDCKlineBase, error) {\n\tresp := struct {\n\t\tData []USDCKlineBase `json:\"result\"`\n\t\tUSDCError\n\t}{}\n\n\tparams := url.Values{}\n\tif symbol.IsEmpty() {\n\t\treturn nil, errSymbolMissing\n\t}\n\tsymbolValue, err := by.FormatSymbol(symbol, asset.USDCMarginedFutures)\n\tif err != nil {\n\t\treturn resp.Data, err\n\t}\n\tparams.Set(\"symbol\", symbolValue)\n\n\tif !common.StringDataCompare(validFuturesIntervals, period) {\n\t\treturn resp.Data, errInvalidPeriod\n\t}\n\tparams.Set(\"period\", period)\n\n\tif startTime.IsZero() {\n\t\treturn nil, errInvalidStartTime\n\t}\n\tparams.Set(\"startTime\", strconv.FormatInt(startTime.Unix(), 10))\n\n\tif limit > 0 && limit <= 200 {\n\t\tparams.Set(\"limit\", strconv.FormatInt(limit, 10))\n\t}\n\treturn resp.Data, by.SendHTTPRequest(ctx, exchange.RestUSDCMargined, common.EncodeURLValues(usdcfuturesGetMarkPriceKlines, params), usdcPublicRate, &resp)\n}", "func klineThsV6(stk *model.Stock, klt model.DBTab, incr bool, ldate *string, lklid *int) (\n\tquotes []*model.Quote, suc, retry bool) {\n\tvar (\n\t\tcode = stk.Code\n\t\tkall model.KlAll\n\t\tktoday model.Ktoday\n\t\tbody []byte\n\t\te error\n\t\tmode string\n\t\tcycle model.CYTP\n\t\trtype = model.Forward\n\t)\n\t*ldate = \"\"\n\t*lklid = -1\n\t//mode:\n\t// 00-no reinstatement\n\t// 01-forward reinstatement\n\t// 02-backward reinstatement\n\tswitch klt {\n\tcase model.KLINE_DAY_F:\n\t\tmode = \"01\"\n\tcase model.KLINE_DAY_NR:\n\t\tmode = \"00\"\n\tcase model.KLINE_WEEK_F:\n\t\tmode = \"11\"\n\tcase model.KLINE_MONTH_F:\n\t\tmode = \"21\"\n\tdefault:\n\t\tlog.Panicf(\"unhandled kltype: %s\", klt)\n\t}\n\turlToday := fmt.Sprintf(\"http://d.10jqka.com.cn/v6/line/hs_%s/%s/today.js\", code, mode)\n\tbody, e = util.HttpGetBytesUsingHeaders(urlToday,\n\t\tmap[string]string{\n\t\t\t\"Referer\": \"http://stockpage.10jqka.com.cn/HQ_v4.html\",\n\t\t\t\"Cookie\": conf.Args.DataSource.THS.Cookie})\n\tif e != nil {\n\t\tlog.Printf(\"%s error visiting %s: \\n%+v\", code, urlToday, e)\n\t\treturn quotes, false, false\n\t}\n\tktoday = model.Ktoday{}\n\te = json.Unmarshal(strip(body), &ktoday)\n\tif e != nil {\n\t\tlog.Printf(\"%s error parsing json from %s: %s\\n%+v\", code, urlToday, string(body), e)\n\t\treturn quotes, false, true\n\t}\n\tif ktoday.Code != \"\" {\n\t\tquotes = append(quotes, &ktoday.Quote)\n\t} else {\n\t\tlog.Printf(\"kline today skipped: %s\", urlToday)\n\t}\n\n\t_, e = time.Parse(global.DateFormat, ktoday.Date)\n\tif e != nil {\n\t\tlog.Printf(\"%s invalid date format today: %s\\n%+v\", code, ktoday.Date, e)\n\t\treturn quotes, false, true\n\t}\n\t// If it is an IPO, return immediately\n\tif stk.TimeToMarket.Valid && len(stk.TimeToMarket.String) == 10 && ktoday.Date == stk.TimeToMarket.String {\n\t\tlog.Printf(\"%s IPO day: %s fetch data for today only\", code, stk.TimeToMarket.String)\n\t\treturn quotes, true, false\n\t}\n\t// If in IPO week, skip the rest chores\n\tif (klt == model.KLINE_WEEK_F || klt == model.KLINE_MONTH_F) &&\n\t\tstk.TimeToMarket.Valid && len(stk.TimeToMarket.String) == 10 {\n\t\tttm, e := time.Parse(global.DateFormat, stk.TimeToMarket.String)\n\t\tif e != nil {\n\t\t\tlog.Printf(\"%s invalid date format for \\\"time to market\\\": %s\\n%+v\",\n\t\t\t\tcode, stk.TimeToMarket.String, e)\n\t\t\treturn quotes, false, true\n\t\t}\n\t\tttd, e := time.Parse(global.DateFormat, ktoday.Date)\n\t\tif e != nil {\n\t\t\tlog.Printf(\"%s invalid date format for \\\"kline today\\\": %s\\n%+v\",\n\t\t\t\tcode, ktoday.Date, e)\n\t\t\treturn quotes, false, true\n\t\t}\n\t\ty1, w1 := ttm.ISOWeek()\n\t\ty2, w2 := ttd.ISOWeek()\n\t\tif y1 == y2 && w1 == w2 {\n\t\t\tlog.Printf(\"%s IPO week %s fetch data for today only\", code, stk.TimeToMarket.String)\n\t\t\treturn quotes, true, false\n\t\t}\n\t}\n\n\t//get all kline data\n\t//e.g: http://d.10jqka.com.cn/v6/line/hs_000001/01/all.js\n\turlAll := fmt.Sprintf(\"http://d.10jqka.com.cn/v6/line/hs_%s/%s/all.js\", code, mode)\n\tbody, e = util.HttpGetBytesUsingHeaders(urlAll,\n\t\tmap[string]string{\n\t\t\t\"Referer\": \"http://stockpage.10jqka.com.cn/HQ_v4.html\",\n\t\t\t\"Cookie\": conf.Args.DataSource.THS.Cookie})\n\t//body, e = util.HttpGetBytes(url_all)\n\tif e != nil {\n\t\tlog.Printf(\"%s error visiting %s: \\n%+v\", code, urlAll, e)\n\t\treturn quotes, false, true\n\t}\n\tkall = model.KlAll{}\n\te = json.Unmarshal(strip(body), &kall)\n\tif e != nil {\n\t\tlog.Printf(\"%s error parsing json from %s: %s\\n%+v\", code, urlAll, string(body), e)\n\t\treturn quotes, false, true\n\t} else if kall.Price == \"\" {\n\t\tlog.Printf(\"%s empty data in json response from %s: %s\", code, urlAll, string(body))\n\t\treturn quotes, false, true\n\t}\n\n\tswitch klt {\n\tcase model.KLINE_DAY_B, model.KLINE_DAY_NR, model.KLINE_DAY_F:\n\t\tcycle = model.DAY\n\tcase model.KLINE_WEEK_B, model.KLINE_WEEK_NR, model.KLINE_WEEK_F:\n\t\tcycle = model.WEEK\n\tcase model.KLINE_MONTH_B, model.KLINE_MONTH_NR, model.KLINE_MONTH_F:\n\t\tcycle = model.MONTH\n\t}\n\tswitch klt {\n\tcase model.KLINE_DAY_NR, model.KLINE_WEEK_NR, model.KLINE_MONTH_NR:\n\t\trtype = model.None\n\tcase model.KLINE_DAY_B, model.KLINE_WEEK_B, model.KLINE_MONTH_B:\n\t\trtype = model.Backward\n\t}\n\n\tif incr {\n\t\tldy := getLatestTradeDataBasic(code, model.KlineMaster, cycle, rtype, 5+1) //plus one offset for pre-close, varate calculation\n\t\tif ldy != nil {\n\t\t\t*ldate = ldy.Date\n\t\t\t*lklid = ldy.Klid\n\t\t} else {\n\t\t\tlog.Printf(\"%s latest %s data not found, will be fully refreshed\", code, klt)\n\t\t}\n\t} else {\n\t\tlog.Printf(\"%s %s data will be fully refreshed\", code, klt)\n\t}\n\n\tkls, e := parseThsKlinesV6(code, klt, &kall, *ldate)\n\tif e != nil {\n\t\tlog.Printf(\"failed to parse data, %s, %+v, %+v, %+v\\n%+v\", code, klt, *ldate, e, kall)\n\t\treturn quotes, false, true\n\t} else if len(kls) == 0 {\n\t\treturn quotes, true, false\n\t}\n\n\tif (klt == model.KLINE_DAY_F || klt == model.KLINE_DAY_NR) && kls[0].Date == ktoday.Date {\n\t\t// if ktoday and kls[0] in the same month, remove kls[0]\n\t\tkls = kls[1:]\n\t} else if klt == model.KLINE_MONTH_F && kls[0].Date[:8] == ktoday.Date[:8] {\n\t\t// if ktoday and kls[0] in the same month, remove kls[0]\n\t\tkls = kls[1:]\n\t} else if klt == model.KLINE_WEEK_F {\n\t\t// if ktoday and kls[0] in the same week, remove kls[0]\n\t\ttToday, e := time.Parse(global.DateFormat, ktoday.Date)\n\t\tif e != nil {\n\t\t\tlog.Printf(\"%s %s invalid date format: %+v \\n %+v\", code, klt, ktoday.Date, e)\n\t\t\treturn quotes, false, true\n\t\t}\n\t\tyToday, wToday := tToday.ISOWeek()\n\t\ttHead, e := time.Parse(global.DateFormat, kls[0].Date)\n\t\tif e != nil {\n\t\t\tlog.Printf(\"%s %s invalid date format: %+v \\n %+v\", code, klt, kls[0].Date, e)\n\t\t\treturn quotes, false, true\n\t\t}\n\t\tyLast, wLast := tHead.ISOWeek()\n\t\tif yToday == yLast && wToday == wLast {\n\t\t\tkls = kls[1:]\n\t\t}\n\t}\n\n\tquotes = append(quotes, kls...)\n\t//reverse order\n\tfor i, j := 0, len(quotes)-1; i < j; i, j = i+1, j-1 {\n\t\tquotes[i], quotes[j] = quotes[j], quotes[i]\n\t}\n\n\treturn quotes, true, false\n}", "func klineThsCDP(stk *model.Stock, klt model.DBTab, incr bool, ldate *string, lklid *int) (\n\tquotes []*model.Quote, suc, retry bool) {\n\tvar (\n\t\tcode = stk.Code\n\t\ttoday, all []byte\n\t\tkall model.KlAll\n\t\tktoday model.Ktoday\n\t\tcycle model.CYTP\n\t\trtype = model.Forward\n\t\te error\n\t)\n\t*ldate = \"\"\n\t*lklid = -1\n\tsuc, retry, today, all = runCdp(code, klt)\n\tif !suc {\n\t\treturn quotes, false, retry\n\t}\n\tktoday = model.Ktoday{}\n\te = json.Unmarshal(strip(today), &ktoday)\n\tif e != nil {\n\t\tlog.Printf(\"%s error parsing json for %+v: %s\\n%+v\", code, klt, string(today), e)\n\t\treturn quotes, false, true\n\t}\n\tif ktoday.Code != \"\" {\n\t\tquotes = append(quotes, &ktoday.Quote)\n\t} else {\n\t\tlog.Printf(\"%s %+v kline today skipped: %s\", klt, code, string(today))\n\t}\n\n\t_, e = time.Parse(global.DateFormat, ktoday.Date)\n\tif e != nil {\n\t\tlog.Printf(\"%s invalid date format today: %s\\n%+v\", code, ktoday.Date, e)\n\t\treturn quotes, false, true\n\t}\n\t// If it is an IPO, return immediately\n\tif stk.TimeToMarket.Valid && len(stk.TimeToMarket.String) == 10 && ktoday.Date == stk.TimeToMarket.String {\n\t\tlog.Printf(\"%s IPO day: %s fetch data for today only\", code, stk.TimeToMarket.String)\n\t\treturn quotes, true, false\n\t}\n\t// If in IPO week, skip the rest chores\n\tif (klt == model.KLINE_WEEK_F || klt == model.KLINE_MONTH_F) &&\n\t\tstk.TimeToMarket.Valid && len(stk.TimeToMarket.String) == 10 {\n\t\tttm, e := time.Parse(global.DateFormat, stk.TimeToMarket.String)\n\t\tif e != nil {\n\t\t\tlog.Printf(\"%s invalid date format for \\\"time to market\\\": %s\\n%+v\",\n\t\t\t\tcode, stk.TimeToMarket.String, e)\n\t\t\treturn quotes, false, true\n\t\t}\n\t\tttd, e := time.Parse(global.DateFormat, ktoday.Date)\n\t\tif e != nil {\n\t\t\tlog.Printf(\"%s invalid date format for \\\"kline today\\\": %s\\n%+v\",\n\t\t\t\tcode, ktoday.Date, e)\n\t\t\treturn quotes, false, true\n\t\t}\n\t\ty1, w1 := ttm.ISOWeek()\n\t\ty2, w2 := ttd.ISOWeek()\n\t\tif y1 == y2 && w1 == w2 {\n\t\t\tlog.Printf(\"%s IPO week %s fetch data for today only\", code, stk.TimeToMarket.String)\n\t\t\treturn quotes, true, false\n\t\t}\n\t}\n\n\t//get all kline data\n\tkall = model.KlAll{}\n\te = json.Unmarshal(strip(all), &kall)\n\tif e != nil {\n\t\tlog.Printf(\"%s error parsing json for %+v: %s\\n%+v\", code, klt, string(all), e)\n\t\treturn quotes, false, true\n\t} else if kall.Price == \"\" {\n\t\tlog.Printf(\"%s %+v empty price data in json response: %s\", code, klt, string(all))\n\t\treturn quotes, false, true\n\t}\n\n\tswitch klt {\n\tcase model.KLINE_DAY_B, model.KLINE_DAY_NR, model.KLINE_DAY_F:\n\t\tcycle = model.DAY\n\tcase model.KLINE_WEEK_B, model.KLINE_WEEK_NR, model.KLINE_WEEK_F:\n\t\tcycle = model.WEEK\n\tcase model.KLINE_MONTH_B, model.KLINE_MONTH_NR, model.KLINE_MONTH_F:\n\t\tcycle = model.MONTH\n\t}\n\tswitch klt {\n\tcase model.KLINE_DAY_NR, model.KLINE_WEEK_NR, model.KLINE_MONTH_NR:\n\t\trtype = model.None\n\tcase model.KLINE_DAY_B, model.KLINE_WEEK_B, model.KLINE_MONTH_B:\n\t\trtype = model.Backward\n\t}\n\n\tif incr {\n\t\tldy := getLatestTradeDataBasic(code, model.KlineMaster, cycle, rtype, 5+1) //plus one offset for pre-close, varate calculation\n\t\tif ldy != nil {\n\t\t\t*ldate = ldy.Date\n\t\t\t*lklid = ldy.Klid\n\t\t} else {\n\t\t\tlog.Printf(\"%s latest %s data not found, will be fully refreshed\", code, klt)\n\t\t}\n\t} else {\n\t\tlog.Printf(\"%s %s data will be fully refreshed\", code, klt)\n\t}\n\n\tkls, e := parseThsKlinesV6(code, klt, &kall, *ldate)\n\tif e != nil {\n\t\tlog.Printf(\"failed to parse data, %s, %+v, %+v, %+v\\n%+v\", code, klt, *ldate, e, kall)\n\t\treturn quotes, false, true\n\t} else if len(kls) == 0 {\n\t\treturn quotes, true, false\n\t}\n\n\tswitch klt {\n\tcase model.KLINE_DAY_F, model.KLINE_DAY_NR, model.KLINE_DAY_B:\n\t\tif kls[0].Date == ktoday.Date {\n\t\t\t// if ktoday and kls[0] in the same day, remove kls[0]\n\t\t\tkls = kls[1:]\n\t\t}\n\tcase model.KLINE_MONTH_F, model.KLINE_MONTH_NR, model.KLINE_MONTH_B:\n\t\tif kls[0].Date[:8] == ktoday.Date[:8] {\n\t\t\t// if ktoday and kls[0] in the same month, remove kls[0]\n\t\t\tkls = kls[1:]\n\t\t}\n\tcase model.KLINE_WEEK_F, model.KLINE_WEEK_NR, model.KLINE_WEEK_B:\n\t\t// if ktoday and kls[0] in the same week, remove kls[0]\n\t\ttToday, e := time.Parse(global.DateFormat, ktoday.Date)\n\t\tif e != nil {\n\t\t\tlog.Printf(\"%s %s invalid date format: %+v \\n %+v\", code, klt, ktoday.Date, e)\n\t\t\treturn quotes, false, true\n\t\t}\n\t\tyToday, wToday := tToday.ISOWeek()\n\t\ttHead, e := time.Parse(global.DateFormat, kls[0].Date)\n\t\tif e != nil {\n\t\t\tlog.Printf(\"%s %s invalid date format: %+v \\n %+v\", code, klt, kls[0].Date, e)\n\t\t\treturn quotes, false, true\n\t\t}\n\t\tyLast, wLast := tHead.ISOWeek()\n\t\tif yToday == yLast && wToday == wLast {\n\t\t\tkls = kls[1:]\n\t\t}\n\t}\n\n\tquotes = append(quotes, kls...)\n\t//reverse order\n\tfor i, j := 0, len(quotes)-1; i < j; i, j = i+1, j-1 {\n\t\tquotes[i], quotes[j] = quotes[j], quotes[i]\n\t}\n\n\treturn quotes, true, false\n}", "func (h *HUOBIHADAX) GetSpotKline(arg KlinesRequestParams) ([]KlineItem, error) {\n\tvals := url.Values{}\n\tvals.Set(\"symbol\", arg.Symbol)\n\tvals.Set(\"period\", string(arg.Period))\n\n\tif arg.Size != 0 {\n\t\tvals.Set(\"size\", strconv.Itoa(arg.Size))\n\t}\n\n\ttype response struct {\n\t\tResponse\n\t\tData []KlineItem `json:\"data\"`\n\t}\n\n\tvar result response\n\turlPath := fmt.Sprintf(\"%s/%s\", h.APIUrl, huobihadaxMarketHistoryKline)\n\n\terr := h.SendHTTPRequest(common.EncodeURLValues(urlPath, vals), &result)\n\tif result.ErrorMessage != \"\" {\n\t\treturn nil, errors.New(result.ErrorMessage)\n\t}\n\treturn result.Data, err\n}", "func (by *Bybit) GetUSDCKlines(ctx context.Context, symbol currency.Pair, period string, startTime time.Time, limit int64) ([]USDCKline, error) {\n\tresp := struct {\n\t\tData []USDCKline `json:\"result\"`\n\t\tUSDCError\n\t}{}\n\n\tparams := url.Values{}\n\tif symbol.IsEmpty() {\n\t\treturn nil, errSymbolMissing\n\t}\n\tsymbolValue, err := by.FormatSymbol(symbol, asset.USDCMarginedFutures)\n\tif err != nil {\n\t\treturn resp.Data, err\n\t}\n\tparams.Set(\"symbol\", symbolValue)\n\n\tif !common.StringDataCompare(validFuturesIntervals, period) {\n\t\treturn resp.Data, errInvalidPeriod\n\t}\n\tparams.Set(\"period\", period)\n\n\tif startTime.IsZero() {\n\t\treturn nil, errInvalidStartTime\n\t}\n\tparams.Set(\"startTime\", strconv.FormatInt(startTime.Unix(), 10))\n\n\tif limit > 0 && limit <= 200 {\n\t\tparams.Set(\"limit\", strconv.FormatInt(limit, 10))\n\t}\n\treturn resp.Data, by.SendHTTPRequest(ctx, exchange.RestUSDCMargined, common.EncodeURLValues(usdcfuturesGetKlines, params), usdcPublicRate, &resp)\n}", "func (s *SinaKlineFetcher) fetchKline(stk *model.Stock, fr FetchRequest, incr bool) (\n\ttdmap map[FetchRequest]*model.TradeData, suc, retry bool) {\n\t//if the fetch request has been completed previously, return immediately\n\tif s.hasCompleted(stk.Code, fr) {\n\t\treturn tdmap, true, false\n\t}\n\n\tswitch fr.Reinstate {\n\tcase model.Backward, model.Forward:\n\t\treturn s.reinstate(stk, fr)\n\t}\n\n\tvar data interface{}\n\tvar e error\n\tif data, e = s.chrome(stk, fr); e != nil {\n\t\tlog.Error(e)\n\t\tif repeat.IsTemporary(e) {\n\t\t\tretry = true\n\t\t}\n\t\treturn\n\t}\n\n\t// extract kline data to tdmap, and all types of Cycle will be populated automatically\n\tif tdmap, e = s.parse(stk.Code, fr, data); e != nil {\n\t\tlog.Error(e)\n\t\tif repeat.IsTemporary(e) {\n\t\t\tretry = true\n\t\t}\n\t\treturn\n\t}\n\n\tsuc = true\n\n\treturn\n}", "func (h *HUOBI) GetSpotKline(ctx context.Context, arg KlinesRequestParams) ([]KlineItem, error) {\n\tvals := url.Values{}\n\tsymbolValue, err := h.FormatSymbol(arg.Symbol, asset.Spot)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvals.Set(\"symbol\", symbolValue)\n\tvals.Set(\"period\", arg.Period)\n\n\tif arg.Size != 0 {\n\t\tvals.Set(\"size\", strconv.Itoa(arg.Size))\n\t}\n\n\ttype response struct {\n\t\tResponse\n\t\tData []KlineItem `json:\"data\"`\n\t}\n\n\tvar result response\n\n\terr = h.SendHTTPRequest(ctx, exchange.RestSpot, common.EncodeURLValues(huobiMarketHistoryKline, vals), &result)\n\tif result.ErrorMessage != \"\" {\n\t\treturn nil, errors.New(result.ErrorMessage)\n\t}\n\treturn result.Data, err\n}", "func (g *LiveDNS) GetTsigKnot(uuid string) ([]byte, error) {\n\t_, content, err := g.client.GetBytes(\"axfr/tsig/\"+uuid+\"/config/knot\", nil)\n\treturn content, err\n}", "func (s *SmartContract) listChainKeys(stub shim.ChaincodeStubInterface) sc.Response {\n\tstartKey := \"0\"\n\tendKey := \"999999\"\n\tresultsIterator, err := stub.GetStateByRange(startKey, endKey)\n\tif err != nil {\n\t\treturn shim.Error(err.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\tbArrayMemberAlreadyWritten := false\n\n\tfor resultsIterator.HasNext() {\n\t\tqueryResponse, err := resultsIterator.Next()\n\t\tfmt.Printf(\"We are trying to print raw data\")\n\t\tfmt.Printf(string(queryResponse.Value))\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add comma before array members, supress it for first array memeber\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"Key\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(queryResponse.Key)\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(\",\\\"Record\\\":\")\n\t\t// Record is a JSON object so we can re-write it as\n\n\t\tbuffer.WriteString(string(queryResponse.Value))\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\tfmt.Printf(\"List of Contracts: \\n%s \\n\", buffer.String())\n\treturn shim.Success(buffer.Bytes())\n}", "func displayTransactions(scid string, option int, ID string) {\n\t\t\n\tscKeys:= []string{\"numberOfOwners\", \"txCount\"}\n\tresult:= getKeysFromDaemon(scid, scKeys)\n\tif result == \"\" {return}\n\n\n\t//Response ok, extract keys from JSON\n\t\n\n\ttxCount := gjson.Get(result, \"txs.#.sc_keys.txCount\")\n\ttxCountArray:= txCount.Array()[0]\n\ttxCountInt:= txCountArray.Int()\n\t//fmt.Printf(\"Tx Count: %d\\n\", txCountInt)\n\n\t//Make a slice of keys so we can request in RPC call\n\tx:= int(txCountInt) //txCount in wallet smart contract is always 1 ahead of actual number of transactions\t\n\tx4:= x * 4\t\n\tkeySlice:= make([]string, x4) \n\t\n\tfor i:=0; i<x; i++ {\n\t\tz:= strconv.Itoa(i)\n\t\tkeySlice[i] = \"txIndex_\" + z\n\t\tkeySlice[i+x] = \"recipient_\" + z\n\t\tkeySlice[i+(x*2)] = \"amount_\" + z\n\t\tkeySlice[i+(x*3)] = \"sent_\" + z\n\t}\n\t\t\n\t//fmt.Println(keySlice)\n\tdisplayData(scid, keySlice, x, option, ID)\n\n\n}", "func parseKlines(code, data, ldate, skipto string) (kls []*model.Quote, more bool) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tif e, ok := r.(error); ok {\n\t\t\t\tlog.Println(e)\n\t\t\t}\n\t\t\tlog.Printf(\"data:\\n%s\", data)\n\t\t\tkls = []*model.Quote{}\n\t\t\tmore = false\n\t\t}\n\t}()\n\tmore = true\n\tdates := strings.Split(data, \";\")\nDATES:\n\tfor i := len(dates) - 1; i >= 0; i-- {\n\t\t// latest in the last\n\t\tes := strings.Split(strings.TrimSpace(dates[i]), \",\")\n\t\tkl := &model.Quote{}\n\t\tfor j, e := range es {\n\t\t\te := strings.TrimSpace(e)\n\t\t\t//20170505,27.68,27.99,27.55,27.98,27457397,763643920.00,0.249\n\t\t\t//date, open, high, low, close, volume, amount, exchange\n\t\t\tswitch j {\n\t\t\tcase 0:\n\t\t\t\tkl.Date = e[:4] + \"-\" + e[4:6] + \"-\" + e[6:]\n\t\t\t\tif ldate != \"\" && kl.Date <= ldate {\n\t\t\t\t\tmore = false\n\t\t\t\t\treturn\n\t\t\t\t} else if skipto != \"\" && kl.Date >= skipto {\n\t\t\t\t\tcontinue DATES\n\t\t\t\t}\n\t\t\tcase 1:\n\t\t\t\tkl.Open = util.Str2F64(e)\n\t\t\tcase 2:\n\t\t\t\tkl.High = util.Str2F64(e)\n\t\t\tcase 3:\n\t\t\t\tkl.Low = util.Str2F64(e)\n\t\t\tcase 4:\n\t\t\t\tkl.Close = util.Str2F64(e)\n\t\t\tcase 5:\n\t\t\t\tkl.Volume = sql.NullFloat64{Float64: util.Str2F64(e), Valid: true}\n\t\t\tcase 6:\n\t\t\t\tkl.Amount = sql.NullFloat64{Float64: util.Str2F64(e), Valid: true}\n\t\t\tcase 7:\n\t\t\t\tkl.Xrate = util.Str2Fnull(e)\n\t\t\tdefault:\n\t\t\t\t//skip\n\t\t\t}\n\t\t}\n\t\tkl.Code = code\n\t\tkls = append(kls, kl)\n\t}\n\treturn\n}", "func (auth *Client) GetTransactions(from, to TimeStamp, limit string) (*Transactions, error) {\n\tparams := map[string]string{\n\t\t\"limit\": limit,\n\t}\n\t//Filter is applied only if both values are set\n\tif !from.IsZero() && !to.IsZero() {\n\t\tparams[\"from\"] = fmt.Sprint(from.AsMillis())\n\t\tparams[\"to\"] = fmt.Sprint(to.AsMillis())\n\t}\n\tbody := auth.n26Request(http.MethodGet, \"/api/smrt/transactions\", params)\n\ttransactions := &Transactions{}\n\tif err := json.Unmarshal(body, &transactions); err != nil {\n\t\treturn nil, err\n\t}\n\treturn transactions, nil\n}", "func (s *Store) kvsGetTxn(tx *memdb.Txn, ws memdb.WatchSet, key string) (uint64, *structs.DirEntry, error) {\n\t// Get the table index.\n\tidx := maxIndexTxn(tx, \"kvs\", \"tombstones\")\n\n\t// Retrieve the key.\n\twatchCh, entry, err := tx.FirstWatch(\"kvs\", \"id\", key)\n\tif err != nil {\n\t\treturn 0, nil, fmt.Errorf(\"failed kvs lookup: %s\", err)\n\t}\n\tws.Add(watchCh)\n\tif entry != nil {\n\t\treturn idx, entry.(*structs.DirEntry), nil\n\t}\n\treturn idx, nil, nil\n}", "func TestGetTrades(t *testing.T) {\n\tt.Parallel()\n\tcp, err := currency.NewPairFromString(\"BCHEUR\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\t_, err = k.GetTrades(context.Background(), cp)\n\tif err != nil {\n\t\tt.Error(\"GetTrades() error\", err)\n\t}\n\n\tcp, err = currency.NewPairFromString(\"XXXXX\")\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n\t_, err = k.GetTrades(context.Background(), cp)\n\tif err == nil {\n\t\tt.Error(\"GetTrades() error: expecting error\")\n\t}\n}", "func (e *Huobi) GetTrades(stockType string) interface{} {\n\treturn nil\n}", "func (c *Client) GetTransactions(queryParams ...string) (map[string]interface{}, error) {\n\tlog.info(\"========== GET CLIENT TRANSACTIONS ==========\")\n\turl := buildURL(path[\"transactions\"])\n\n\treturn c.do(\"GET\", url, \"\", queryParams)\n}", "func (_Precompile *PrecompileCaller) KMS(opts *bind.CallOpts) (*big.Int, error) {\n\tvar out []interface{}\n\terr := _Precompile.contract.Call(opts, &out, \"KMS\")\n\n\tif err != nil {\n\t\treturn *new(*big.Int), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)\n\n\treturn out0, err\n\n}", "func GetTransactions(hostURL string, hostPort int) *bytes.Buffer {\n\treturn makeGetRequest(\"gettransactions\", hostURL, hostPort)\n}", "func (suite *MainIntegrationSuite) TestGetTransation() {\n\t// Create a controller to communicate with a Node.\n\tvar nodeClient nodeclient.Controller\n\tnodeClient = nodeclient.New(\n\t\tinjector.DefaultHTTPClient(),\n\t\tinjector.BTCDomain(),\n\t\tinjector.BTCUsername(),\n\t\tinjector.BTCPassword())\n\n\t// Retrieve transactions from a block.\n\tblock := testutils.Block506664\n\ttxs := block.TX\n\n\t// call GetTransactions using the hash of the transactions. This should return\n\t// details about the transaction.\n\ttx, err := nodeClient.GetTransaction(txs[3])\n\tsuite.NoError(err, \"There should be no error getting transaction 3 from the node.\")\n\tsuite.NotNil(tx, \"Tx retrieved should not be nil\")\n\tsuite.Equal(\"24438ff6f5e41d70d6b6e9414e965a8e0a9171cfc4333c596640e64694c0292e\", tx.Hash)\n\n\t// call GetTransactions using the hash of transaction 4. This should return\n\t// details about the transaction.\n\ttx, err = nodeClient.GetTransaction(txs[4])\n\tsuite.NoError(err, \"There should be no error getting transaction 4 from the node.\")\n\tsuite.NotNil(tx, \"Tx retrieved should not be nil\")\n\tsuite.Equal(\"b1bdf0b2ac321b00545598043c0554cf6b5c6fa61ce36b30cf7b3addcccc0bf3\", tx.Hash)\n}", "func (c *dummyWavesMDLrpcclient) GetTransaction(txid string) (*model.Transactions, error) {\n\ttransaction, _, err := client.NewTransactionsService(c.MainNET).GetTransactionsInfoID(txid)\n\treturn transaction, err\n}", "func (m *Metadata) Kek() string {\n\treturn m.kek\n}", "func GetLines() []interface{} {\n\treturn printer.Lines\n}", "func GetLines() []interface{} {\n\treturn printer.Lines\n}", "func (t *Colorado) getTradesByPartialCompositeKey(stub shim.ChaincodeStubInterface, args []string) peer.Response {\n\t if len(args) != 1 {\n\t\t return shim.Error(\"Incorrect number of arguments. Expecting 1.\")\n\t }\n \n\t if len(args[0]) == 0 {\n\t\t return shim.Error(\"1st argument (Entitled Organization) must be a non-empty string\")\n\t }\n \n\t entitledOrg := strings.ToUpper(args[0])\n\t fmt.Println(\"- start getting trades by partial composite key: \" + entitledOrg)\n \n\t // buffer is a JSON array containing query results\n\t var buffer bytes.Buffer\n\t buffer.WriteString(\"[\")\n \n\t // 1. Query the buySide~tradeId index by partial fields (e.g. buy side IM1 only)\n\t // This will execute a key range query on all keys starting with 'IM1'\n\t // 2. Query the sellSide~tradeId index by partial fields (e.g. sell side IM1 only)\n\t // This will execute a key range query on all keys starting with 'IM1'\n\t allIMs := [1]string{\"IM1\"}\n\t allEBs := [2]string{\"EB1\", \"EB2\"}\n\t allIndices := [2]string{\"buySide~tradeId\", \"sellSide~tradeId\"}\n\t for i := 0; i < len(allIMs); i++ {\n\t\t for j := 0; j < len(allEBs); j++ {\n\t\t\t for k := 0; k < len(allIndices); k++ {\n\t\t\t\t tradeResultsIterator, err := stub.GetPrivateDataByPartialCompositeKey(\"privateTradeFor\" + allIMs[i] + allEBs[j], allIndices[k], []string{entitledOrg})\n\t\t\t\t if err != nil {\n\t\t\t\t\t // not return error for non-entitled privateTradeForIMxEBy\n\t\t\t\t\t // return shim.Error(err.Error())\n\t\t\t\t } else {\n\t\t\t\t\t defer tradeResultsIterator.Close()\n\t\t\t\t\t for tradeResultsIterator.HasNext() {\n\t\t\t\t\t\t tradeResult, err := tradeResultsIterator.Next()\n \n\t\t\t\t\t\t // get the color and name from color~name composite key\n\t\t\t\t\t\t _, compositeKeyParts, err := stub.SplitCompositeKey(tradeResult.Key)\n\t\t\t\t\t\t if err != nil {\n\t\t\t\t\t\t\t return shim.Error(err.Error())\n\t\t\t\t\t\t }\n\t\t\t\t\t\t // get split parts of \"buySide~tradeId\" and \"sellSide~tradeId\"\n\t\t\t\t\t\t // tradeBuyOrSellSide := compositeKeyParts[0] // no need\n\t\t\t\t\t\t tradeId := compositeKeyParts[1]\n \n\t\t\t\t\t\t if err != nil {\n\t\t\t\t\t\t\t return shim.Error(err.Error())\n\t\t\t\t\t\t }\n\t\t\t\t\t\t if buffer.Len() > 1 {\n\t\t\t\t\t\t\t buffer.WriteString(\",\")\n\t\t\t\t\t\t }\n\t\t\t\t\t\t //buffer.WriteString(\"{\\\"compositeKey\\\":\")\n\t\t\t\t\t\t //buffer.WriteString(\"\\\"\")\n\t\t\t\t\t\t //buffer.WriteString(tradeResult.Key)\n\t\t\t\t\t\t //buffer.WriteString(\"\\\"\")\n \n\t\t\t\t\t\t //buffer.WriteString(\", \\\"trade\\\":\")\n\t\t\t\t\t\t tradeJSONAsBytes, err := stub.GetPrivateData(\"privateTradeFor\" + allIMs[i] + allEBs[j], tradeId)\n\t\t\t\t\t\t if err != nil {\n\t\t\t\t\t\t\t // e.g. no defined private collection for the combination of IM, EB\n\t\t\t\t\t\t\t return shim.Error(\"Unable to get trade: \" + err.Error())\n\t\t\t\t\t\t } else if tradeJSONAsBytes == nil {\n\t\t\t\t\t\t\t fmt.Println(\"This trade does not exist: \" + tradeId)\n\t\t\t\t\t\t\t return shim.Error(\"This trade does not exist: \" + tradeId)\n\t\t\t\t\t\t }\n\t\t\t\t\t\t buffer.WriteString(string(tradeJSONAsBytes))\n \n\t\t\t\t\t\t //buffer.WriteString(\"}\")\n\t\t\t\t\t }\n\t\t\t\t }\n\t\t\t }\n\t\t }\n\t }\n\t buffer.WriteString(\"]\")\n \n\t fmt.Println(\"- end getting trades with query result:\\n\" + buffer.String())\n \n\t return shim.Success(buffer.Bytes())\n }", "func (o InitialStateConfigResponseOutput) Keks() FileContentBufferResponseArrayOutput {\n\treturn o.ApplyT(func(v InitialStateConfigResponse) []FileContentBufferResponse { return v.Keks }).(FileContentBufferResponseArrayOutput)\n}", "func (owner *WalletOwnerAPI) RetrieveTxs(refreshFromNode bool, txID *uint32, txSlateID *uuid.UUID) (bool, *[]libwallet.TxLogEntry, error) {\n\tparams := struct {\n\t\tToken string `json:\"token\"`\n\t\tRefreshFromNode bool `json:\"refresh_from_node\"`\n\t\tTxID *uint32 `json:\"tx_id\"`\n\t\tTxSlateID *uuid.UUID `json:\"tx_slate_id\"`\n\t}{\n\t\tToken: owner.token,\n\t\tRefreshFromNode: refreshFromNode,\n\t\tTxID: txID,\n\t\tTxSlateID: txSlateID,\n\t}\n\n\tparamsBytes, err := json.Marshal(params)\n\tif err != nil {\n\t\treturn false, nil, err\n\t}\n\tenvl, err := owner.client.EncryptedRequest(\"retrieve_txs\", paramsBytes, owner.sharedSecret)\n\tif err != nil {\n\t\treturn false, nil, err\n\t}\n\tif envl == nil {\n\t\treturn false, nil, errors.New(\"WalletOwnerAPI: Empty RPC Response from grin-wallet\")\n\t}\n\tif envl.Error != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"code\": envl.Error.Code,\n\t\t\t\"message\": envl.Error.Message,\n\t\t}).Error(\"WalletOwnerAPI: RPC Error during RetrieveTxs\")\n\t\treturn false, nil, errors.New(string(envl.Error.Code) + \"\" + envl.Error.Message)\n\t}\n\tvar result Result\n\tif err = json.Unmarshal(envl.Result, &result); err != nil {\n\t\treturn false, nil, err\n\t}\n\tif result.Err != nil {\n\t\treturn false, nil, errors.New(string(result.Err))\n\t}\n\n\tvar okArray []json.RawMessage\n\tif err = json.Unmarshal(result.Ok, &okArray); err != nil {\n\t\treturn false, nil, err\n\t}\n\tif len(okArray) < 2 {\n\t\treturn false, nil, errors.New(\"Wrong okArray length\")\n\t}\n\tvar refreshedFromNode bool\n\tif err = json.Unmarshal(okArray[0], &refreshedFromNode); err != nil {\n\t\treturn false, nil, err\n\t}\n\tvar txLogEntries []libwallet.TxLogEntry\n\tif err := json.Unmarshal(okArray[1], &txLogEntries); err != nil {\n\t\treturn false, nil, err\n\t}\n\n\treturn refreshedFromNode, &txLogEntries, nil\n}", "func (h *HUOBI) GetSwapKlineData(ctx context.Context, code currency.Pair, period string, size int64, startTime, endTime time.Time) (SwapKlineData, error) {\n\tvar resp SwapKlineData\n\tcodeValue, err := h.FormatSymbol(code, asset.CoinMarginedFutures)\n\tif err != nil {\n\t\treturn resp, err\n\t}\n\tif !common.StringDataCompareInsensitive(validPeriods, period) {\n\t\treturn resp, fmt.Errorf(\"invalid period value received\")\n\t}\n\tparams := url.Values{}\n\tparams.Set(\"contract_code\", codeValue)\n\tparams.Set(\"period\", period)\n\tif size > 0 {\n\t\tparams.Set(\"size\", strconv.FormatInt(size, 10))\n\t}\n\tif !startTime.IsZero() && !endTime.IsZero() {\n\t\tif startTime.After(endTime) {\n\t\t\treturn resp, errors.New(\"startTime cannot be after endTime\")\n\t\t}\n\t\tparams.Set(\"from\", strconv.FormatInt(startTime.Unix(), 10))\n\t\tparams.Set(\"to\", strconv.FormatInt(endTime.Unix(), 10))\n\t}\n\tpath := common.EncodeURLValues(huobiKLineData, params)\n\treturn resp, h.SendHTTPRequest(ctx, exchange.RestFutures, path, &resp)\n}", "func (c *Coinbene) GetTrades(symbol string, limit int64) (Trades, error) {\n\tresp := struct {\n\t\tData [][]string `json:\"data\"`\n\t}{}\n\n\tparams := url.Values{}\n\tparams.Set(\"symbol\", symbol)\n\tparams.Set(\"limit\", strconv.FormatInt(limit, 10))\n\tpath := common.EncodeURLValues(coinbeneAPIVersion+coinbeneGetTrades, params)\n\terr := c.SendHTTPRequest(exchange.RestSpot, path, spotMarketTrades, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar trades Trades\n\tfor x := range resp.Data {\n\t\ttm, err := time.Parse(time.RFC3339, resp.Data[x][4])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tprice, err := strconv.ParseFloat(resp.Data[x][1], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tvolume, err := strconv.ParseFloat(resp.Data[x][2], 64)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\ttrades = append(trades, TradeItem{\n\t\t\tCurrencyPair: resp.Data[x][0],\n\t\t\tPrice: price,\n\t\t\tVolume: volume,\n\t\t\tDirection: resp.Data[x][3],\n\t\t\tTradeTime: tm,\n\t\t})\n\t}\n\treturn trades, nil\n}", "func (svc *ContrailService) RetrieveKVPs(\n\tctx context.Context,\n\trequest *types.Empty,\n) (res *RetrieveKVPsResponse, err error) {\n\tvar kvps []*models.KeyValuePair\n\tkvps, err = svc.UserAgentKVService.RetrieveKVPs(ctx)\n\tif err == nil {\n\t\tres = &RetrieveKVPsResponse{KeyValuePairs: kvps}\n\t}\n\treturn res, err\n}", "func (by *Bybit) GetUSDCTransactionLog(ctx context.Context, startTime, endTime time.Time, txType, category, direction, cursor string, limit int64) ([]USDCTxLog, error) {\n\tresp := struct {\n\t\tResult struct {\n\t\t\tCursor string `json:\"cursor\"`\n\t\t\tResultTotalSize int64 `json:\"resultTotalSize\"`\n\t\t\tData []USDCTxLog `json:\"dataList\"`\n\t\t} `json:\"result\"`\n\t\tUSDCError\n\t}{}\n\n\treq := make(map[string]interface{})\n\tif !startTime.IsZero() {\n\t\treq[\"startTime\"] = strconv.FormatInt(startTime.Unix(), 10)\n\t}\n\n\tif !endTime.IsZero() {\n\t\treq[\"endTime\"] = strconv.FormatInt(endTime.Unix(), 10)\n\t}\n\n\tif txType == \"\" {\n\t\treturn nil, errors.New(\"type missing\")\n\t}\n\treq[\"type\"] = txType\n\n\tif category != \"\" {\n\t\treq[\"category\"] = category\n\t}\n\n\tif direction != \"\" {\n\t\treq[\"direction\"] = direction\n\t}\n\n\tif limit > 0 && limit <= 50 {\n\t\treq[\"limit\"] = strconv.FormatInt(limit, 10)\n\t}\n\n\tif cursor != \"\" {\n\t\treq[\"cursor\"] = cursor\n\t}\n\treturn resp.Result.Data, by.SendUSDCAuthHTTPRequest(ctx, exchange.RestUSDCMargined, http.MethodPost, usdcfuturesGetTransactionLog, req, &resp, usdcGetTransactionRate)\n}", "func (t *SimpleChaincode) getTransactions(stub shim.ChaincodeStubInterface, finInst string) ([]byte, error) {\n\n\tvar res AllTransactions\n\n\tfmt.Println(\"Start find getTransactions\")\n\tfmt.Println(\"Looking for \" + finInst)\n\n\t//get the AllTransactions index\n\tallTxAsBytes, err := stub.GetState(\"allTx\")\n\tif err != nil {\n\t\treturn nil, errors.New(\"Failed to get all Transactions\")\n\t}\n\n\tvar txs AllTransactions\n\tjson.Unmarshal(allTxAsBytes, &txs)\n\n\tfor i := range txs.Transactions {\n\n\t\tif txs.Transactions[i].Sender == finInst {\n\t\t\tres.Transactions = append(res.Transactions, txs.Transactions[i])\n\t\t}\n\n\t\tif txs.Transactions[i].Receiver == finInst {\n\t\t\tres.Transactions = append(res.Transactions, txs.Transactions[i])\n\t\t}\n\n\t\tif finInst == AUDITOR {\n\t\t\tres.Transactions = append(res.Transactions, txs.Transactions[i])\n\t\t}\n\t}\n\n\tresAsBytes, _ := json.Marshal(res)\n\n\treturn resAsBytes, nil\n\n}", "func (txn *tikvTxn) BatchGet(ctx context.Context, keys []kv.Key) (map[string][]byte, error) {\n\tr, ctx := tracing.StartRegionEx(ctx, \"tikvTxn.BatchGet\")\n\tdefer r.End()\n\treturn NewBufferBatchGetter(txn.GetMemBuffer(), nil, txn.GetSnapshot()).BatchGet(ctx, keys)\n}", "func (model *Trade) Key() string {\n\treturn model.Tbk.GetItemKey()\n}", "func (c *ExplorerController) GetCrossTxList() {\n\t// get parameter\n\tvar crossTxListReq model.CrossTxListReq\n\tvar err error\n\tif err = json.Unmarshal(c.Ctx.Input.RequestBody, &crossTxListReq); err != nil {\n\t\tc.Data[\"json\"] = model.MakeErrorRsp(fmt.Sprintf(\"request parameter is invalid!\"))\n\t\tc.Ctx.ResponseWriter.WriteHeader(400)\n\t\tc.ServeJSON()\n\t}\n\n\tsrcPolyDstRelations := make([]*model.SrcPolyDstRelation, 0)\n\tdb.Model(&model.PolyTransaction{}).\n\t\tSelect(\"src_transactions.hash as src_hash, poly_transactions.hash as poly_hash, dst_transactions.hash as dst_hash\").\n\t\tWhere(\"src_transactions.standard = ?\", 0).\n\t\tJoins(\"left join src_transactions on src_transactions.hash = poly_transactions.src_hash\").\n\t\tJoins(\"left join dst_transactions on poly_transactions.hash = dst_transactions.poly_hash\").\n\t\tPreload(\"SrcTransaction\").\n\t\tPreload(\"SrcTransaction.SrcTransfer\").\n\t\tPreload(\"PolyTransaction\").\n\t\tPreload(\"DstTransaction\").\n\t\tPreload(\"DstTransaction.DstTransfer\").\n\t\tLimit(crossTxListReq.PageSize).Offset(crossTxListReq.PageSize * crossTxListReq.PageNo).\n\t\tFind(&srcPolyDstRelations)\n\n\tvar transactionNum int64\n\tdb.Model(&model.PolyTransaction{}).Where(\"src_transactions.standard = ?\", 0).\n\t\tJoins(\"left join src_transactions on src_transactions.hash = poly_transactions.src_hash\").Count(&transactionNum)\n\n\tc.Data[\"json\"] = model.MakeCrossTxListResp(srcPolyDstRelations)\n\tc.ServeJSON()\n}", "func FormatKostTransactions(transactions []Transaction) []KostTransactionFormatter {\n\tif len(transactions) == 0 {\n\t\treturn []KostTransactionFormatter{}\n\t}\n\tvar transactionsFormatter []KostTransactionFormatter\n\n\tfor _, transaction := range transactions {\n\t\tformatter := FormatKostTransaction(transaction)\n\t\ttransactionsFormatter = append(transactionsFormatter, formatter)\n\t}\n\n\treturn transactionsFormatter\n}", "func parseThsKlinesV6(code string, klt model.DBTab, data *model.KlAll, ldate string) (kls []*model.Quote, e error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tif err, ok := r.(error); ok {\n\t\t\t\tlog.Println(err)\n\t\t\t\te = err\n\t\t\t}\n\t\t}\n\t}()\n\tprices := strings.Split(data.Price, \",\")\n\tvols := strings.Split(data.Volume, \",\")\n\tdates := strings.Split(data.Dates, \",\")\n\tif len(prices)/4 != len(vols) || len(vols) != len(dates) {\n\t\treturn nil, errors.Errorf(\"%s data length mismatched: total:%d, price:%d, vols:%d, dates:%d\",\n\t\t\tcode, data.Total, len(prices), len(vols), len(dates))\n\t}\n\tpf := data.PriceFactor\n\toffset := 0\n\tfor y := len(data.SortYear) - 1; y >= 0; y-- {\n\t\tyrd := data.SortYear[y].([]interface{})\n\t\tyear := strconv.Itoa(int(yrd[0].(float64)))\n\t\tynum := int(yrd[1].(float64))\n\t\t//last year's count might be one more than actually in the data string\n\t\tif y == len(data.SortYear)-1 && data.Total == len(dates)+1 {\n\t\t\tynum--\n\t\t\tlog.Printf(\"%s %s %+v %+v data length mismatch, auto corrected\", code, data.Name, data.Total, klt)\n\t\t}\n\t\tfor i := len(dates) - offset - 1; i >= len(dates)-offset-ynum; i-- {\n\t\t\t// latest in the last\n\t\t\tdate := year + \"-\" + dates[i][0:2] + \"-\" + dates[i][2:]\n\t\t\tif ldate != \"\" && date <= ldate {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tkl := &model.Quote{}\n\t\t\tkl.Date = date\n\t\t\tkl.Low = util.Str2F64(prices[i*4]) / pf\n\t\t\tkl.Open = kl.Low + util.Str2F64(prices[i*4+1])/pf\n\t\t\tkl.High = kl.Low + util.Str2F64(prices[i*4+2])/pf\n\t\t\tkl.Close = kl.Low + util.Str2F64(prices[i*4+3])/pf\n\t\t\tkl.Volume.Float64 = util.Str2F64(vols[i])\n\t\t\tkl.Volume.Valid = true\n\t\t\tswitch klt {\n\t\t\tcase model.KLINE_DAY_NR, model.KLINE_WEEK_NR, model.KLINE_MONTH_NR:\n\t\t\t\tif kl.Open == 0 {\n\t\t\t\t\tkl.Open = kl.Close\n\t\t\t\t}\n\t\t\t\tif kl.Low == 0 {\n\t\t\t\t\tkl.Low = kl.Close\n\t\t\t\t}\n\t\t\t\tif kl.High == 0 {\n\t\t\t\t\tkl.High = kl.Close\n\t\t\t\t}\n\t\t\tcase model.KLINE_DAY_F:\n\t\t\t\tif kl.Open == 0 && kl.Low == 0 && kl.High == 0 && kl.Close != 0 {\n\t\t\t\t\tkl.Open = kl.Close\n\t\t\t\t\tkl.Low = kl.Close\n\t\t\t\t\tkl.High = kl.Close\n\t\t\t\t}\n\t\t\t}\n\t\t\tkl.Code = code\n\t\t\tkls = append(kls, kl)\n\t\t}\n\t\toffset += ynum\n\t}\n\treturn\n}", "func (a *API) TraceTransaction(hash common.Hash, config *evmtypes.TraceConfig) (interface{}, error) {\n\ta.logger.Debug(\"debug_traceTransaction\", \"hash\", hash)\n\t// Get transaction by hash\n\ttransaction, err := a.backend.GetTxByEthHash(hash)\n\tif err != nil {\n\t\ta.logger.Debug(\"tx not found\", \"hash\", hash)\n\t\treturn nil, err\n\t}\n\n\t// check if block number is 0\n\tif transaction.Height == 0 {\n\t\treturn nil, errors.New(\"genesis is not traceable\")\n\t}\n\n\tblk, err := a.backend.GetTendermintBlockByNumber(rpctypes.BlockNumber(transaction.Height))\n\tif err != nil {\n\t\ta.logger.Debug(\"block not found\", \"height\", transaction.Height)\n\t\treturn nil, err\n\t}\n\n\tparsedTxs, err := rpctypes.ParseTxResult(&transaction.TxResult)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse tx events: %s\", hash.Hex())\n\t}\n\tparsedTx := parsedTxs.GetTxByHash(hash)\n\tif parsedTx == nil {\n\t\treturn nil, fmt.Errorf(\"ethereum tx not found in msgs: %s\", hash.Hex())\n\t}\n\n\t// check tx index is not out of bound\n\tif uint32(len(blk.Block.Txs)) < transaction.Index {\n\t\ta.logger.Debug(\"tx index out of bounds\", \"index\", transaction.Index, \"hash\", hash.String(), \"height\", blk.Block.Height)\n\t\treturn nil, fmt.Errorf(\"transaction not included in block %v\", blk.Block.Height)\n\t}\n\n\tvar predecessors []*evmtypes.MsgEthereumTx\n\tfor _, txBz := range blk.Block.Txs[:transaction.Index] {\n\t\ttx, err := a.clientCtx.TxConfig.TxDecoder()(txBz)\n\t\tif err != nil {\n\t\t\ta.logger.Debug(\"failed to decode transaction in block\", \"height\", blk.Block.Height, \"error\", err.Error())\n\t\t\tcontinue\n\t\t}\n\t\tfor _, msg := range tx.GetMsgs() {\n\t\t\tethMsg, ok := msg.(*evmtypes.MsgEthereumTx)\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tpredecessors = append(predecessors, ethMsg)\n\t\t}\n\t}\n\n\ttx, err := a.clientCtx.TxConfig.TxDecoder()(transaction.Tx)\n\tif err != nil {\n\t\ta.logger.Debug(\"tx not found\", \"hash\", hash)\n\t\treturn nil, err\n\t}\n\n\t// add predecessor messages in current cosmos tx\n\tfor i := 0; i < parsedTx.MsgIndex; i++ {\n\t\tethMsg, ok := tx.GetMsgs()[i].(*evmtypes.MsgEthereumTx)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tpredecessors = append(predecessors, ethMsg)\n\t}\n\n\tethMessage, ok := tx.GetMsgs()[parsedTx.MsgIndex].(*evmtypes.MsgEthereumTx)\n\tif !ok {\n\t\ta.logger.Debug(\"invalid transaction type\", \"type\", fmt.Sprintf(\"%T\", tx))\n\t\treturn nil, fmt.Errorf(\"invalid transaction type %T\", tx)\n\t}\n\n\ttraceTxRequest := evmtypes.QueryTraceTxRequest{\n\t\tMsg: ethMessage,\n\t\tPredecessors: predecessors,\n\t\tBlockNumber: blk.Block.Height,\n\t\tBlockTime: blk.Block.Time,\n\t\tBlockHash: common.Bytes2Hex(blk.BlockID.Hash),\n\t}\n\n\tif config != nil {\n\t\ttraceTxRequest.TraceConfig = config\n\t}\n\n\t// minus one to get the context of block beginning\n\tcontextHeight := transaction.Height - 1\n\tif contextHeight < 1 {\n\t\t// 0 is a special value in `ContextWithHeight`\n\t\tcontextHeight = 1\n\t}\n\ttraceResult, err := a.queryClient.TraceTx(rpctypes.ContextWithHeight(contextHeight), &traceTxRequest)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Response format is unknown due to custom tracer config param\n\t// More information can be found here https://geth.ethereum.org/docs/dapp/tracing-filtered\n\tvar decodedResult interface{}\n\terr = json.Unmarshal(traceResult.Data, &decodedResult)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn decodedResult, nil\n}", "func TestQueryTrades(t *testing.T) {\n\tt.Parallel()\n\t_, err := k.QueryTrades(context.Background(),\n\t\ttrue, \"TMZEDR-VBJN2-NGY6DX\", \"TFLWIB-KTT7L-4TWR3L\", \"TDVRAH-2H6OS-SLSXRX\")\n\tif err == nil {\n\t\tt.Error(\"QueryTrades() Expected error\")\n\t}\n}", "func (c *Client) getRk(topic string, rkIndex int) string {\n\treturn fmt.Sprintf(\"%s-%d\", topic, rkIndex)\n}", "func (t *AtlchainCC) getHistoryByKey(stub shim.ChaincodeStubInterface, args []string) pb.Response {\n\targsNeed := 1\n\targsLength := len(args)\n\tif argsLength != argsNeed {\n\t\treturn shim.Error(strconv.Itoa(argsNeed) + \" args wanted, but given \" + strconv.Itoa(argsLength))\n\t}\n\n\tresultsIterator, error := stub.GetHistoryForKey(args[0])\n\tif error != nil {\n\t\treturn shim.Error(error.Error())\n\t}\n\tdefer resultsIterator.Close()\n\n\tvar buffer bytes.Buffer\n\tbuffer.WriteString(\"[\")\n\n\tbArrayMemberAlreadyWritten := false\n\tfor resultsIterator.HasNext() {\n\t\tresponse, err := resultsIterator.Next()\n\t\tif err != nil {\n\t\t\treturn shim.Error(err.Error())\n\t\t}\n\t\t// Add a comma before array members, suppress it for the first array member\n\t\tif bArrayMemberAlreadyWritten == true {\n\t\t\tbuffer.WriteString(\",\")\n\t\t}\n\t\tbuffer.WriteString(\"{\\\"TxId\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(response.TxId)\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"Value\\\":\")\n\t\t// if it was a delete operation on given key, then we need to set the\n\t\t//corresponding value null. Else, we will write the response.Value\n\t\t//as-is (as the Value itself a JSON marble)\n\t\tif response.IsDelete {\n\t\t\tbuffer.WriteString(\"null\")\n\t\t} else {\n\t\t\tbuffer.WriteString(string(response.Value))\n\t\t}\n\n\t\tbuffer.WriteString(\", \\\"Timestamp\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(time.Unix(response.Timestamp.Seconds, int64(response.Timestamp.Nanos)).String())\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\", \\\"IsDelete\\\":\")\n\t\tbuffer.WriteString(\"\\\"\")\n\t\tbuffer.WriteString(strconv.FormatBool(response.IsDelete))\n\t\tbuffer.WriteString(\"\\\"\")\n\n\t\tbuffer.WriteString(\"}\")\n\t\tbArrayMemberAlreadyWritten = true\n\t}\n\tbuffer.WriteString(\"]\")\n\n\tfmt.Printf(\"- getHistoryForMarble returning:\\n%s\\n\", buffer.String())\n\n\treturn shim.Success(buffer.Bytes())\n}", "func (o InitialStateConfigResponsePtrOutput) Keks() FileContentBufferResponseArrayOutput {\n\treturn o.ApplyT(func(v *InitialStateConfigResponse) []FileContentBufferResponse {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Keks\n\t}).(FileContentBufferResponseArrayOutput)\n}", "func (s *Snapshot) KVs() (memdb.ResultIterator, error) {\n\titer, err := s.tx.Get(\"kvs\", \"id_prefix\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn iter, nil\n}", "func (b *Poloniex) GetOrderTrades(orderNumber int) (tradeOrderTransaction []TradeOrderTransaction, err error) {\n\tr, err := b.client.doCommand(\"returnOrderTrades\", map[string]string{\"orderNumber\": fmt.Sprintf(\"%d\", orderNumber)})\n\tif err != nil {\n\t\treturn\n\t}\n\tif string(r) == `{\"error\":\"Order not found, or you are not the person who placed it.\"}` {\n\t\terr = fmt.Errorf(\"Error : order not found, or you are not the person who placed it.\")\n\t\treturn\n\t}\n\tif err = json.Unmarshal(r, &tradeOrderTransaction); err != nil {\n\t\treturn\n\t}\n\treturn\n}", "func GetKs(rs []float64) []float64 {\n\tintervals := len(rs) - L*n\n\tdays := len(rs) / n\n\tvar TODs = make([]float64, intervals)\n\tvar BVs = make([]float64, days)\n\tvar RVs = make([]float64, days)\n\tt := time.Now()\n\twg := sync.WaitGroup{}\n\twg.Add(days)\n\tfor d := 0; d < days; d++ {\n\t\tgo func(d int) {\n\t\t\tinterval := rs[d*n : (d+1)*n]\n\t\t\tBVs[d] = BV(interval)\n\t\t\tRVs[d] = RV(interval)\n\t\t\twg.Done()\n\t\t}(d)\n\t}\n\twg.Wait()\n\twg.Add(intervals)\n\tfor s := 0; s < days-L; s++ {\n\t\tfor tau := 0; tau < n; tau++ {\n\t\t\tgo func(s, tau int) {\n\t\t\t\tTODs[s*n+tau] = TodAtTau(rs[s:s+L*n], tau, n, BVs[s:], RVs[s:])\n\t\t\t\twg.Done()\n\t\t\t}(s, tau)\n\t\t}\n\t}\n\twg.Wait()\n\n\twg.Add(intervals)\n\tvar ks = make([]float64, intervals)\n\tfor d := 0; d < days-L; d++ {\n\t\tfor tau := 0; tau < n; tau++ {\n\t\t\tgo func(s, tau int) {\n\t\t\t\tks[s*n+tau] = limitK * math.Sqrt(math.Min(BVs[s], RVs[s])*TODs[s*n+tau])\n\t\t\t\twg.Done()\n\t\t\t}(d, tau)\n\t\t}\n\t}\n\twg.Wait()\n\tfmt.Println(\"GetKs Time consumed: \", time.Now().Sub(t).Seconds())\n\n\treturn ks\n}", "func (b *BinanceWorker) GetHistoryTrades(symbol string, start, end int64, number int) {\n\ttrades, err := b.Cli.NewAggTradesService().\n\t\tSymbol(symbol).StartTime(start).EndTime(end).\n\t\tDo(context.Background())\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\n\tvar sum int = 0\n\tvar qul float64 = 0.\n\tvar allQul float64 = 0.\n\tfor _, t := range trades {\n\t\ti, _ := strconv.ParseFloat(t.Quantity, 64)\n\t\tallQul += i\n\t\tif t.IsBuyerMaker {\n\t\t\tsum++\n\t\t\tqul += i\n\t\t}\n\n\t}\n\n\tfmt.Println(float64(float64(sum)/float64(len(trades)))*100, float64(float64(qul)/float64(allQul))*100)\n\t// err = json.Unmarshal(jsonBlob, &rankings)\n\t// if err != nil {\n\t// \t// nozzle.printError(\"opening config file\", err.Error())\n\t// }\n\torders, err := json.Marshal(trades)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\t//fmt.Println(string(orders))\n\t// rankingsJson, _ := json.Marshal(rankings)\n\terr = ioutil.WriteFile(fmt.Sprintf(\"%d.json\", number), orders, 0644)\n\t// fmt.Printf(\"%+v\", rankings)\n}", "func (_BaseContent *BaseContentCaller) GetKMSInfo(opts *bind.CallOpts, prefix []byte) (string, string, error) {\n\tvar out []interface{}\n\terr := _BaseContent.contract.Call(opts, &out, \"getKMSInfo\", prefix)\n\n\tif err != nil {\n\t\treturn *new(string), *new(string), err\n\t}\n\n\tout0 := *abi.ConvertType(out[0], new(string)).(*string)\n\tout1 := *abi.ConvertType(out[1], new(string)).(*string)\n\n\treturn out0, out1, err\n\n}", "func ViewTransaction(rw http.ResponseWriter, r *http.Request) {\n\t// get the token\n\treqToken := r.Header.Get(\"Authorization\")\n\n\t// get the claims\n\tclaims, isNotValid := GetClaims(reqToken, rw)\n\tif isNotValid {\n\t\treturn\n\t}\n\n\tdt, err := db.GetUserTransaction(claims.Roll)\n\tif err != nil {\n\t\trw.WriteHeader(http.StatusInternalServerError)\n\t\trw.Write(Rsp(err.Error(), \"Server Error\"))\n\t\treturn\n\t}\n\trw.WriteHeader(http.StatusOK)\n\tres := c.RespData{\n\t\tMessage: \"All data\",\n\t\tData: dt,\n\t}\n\tjson.NewEncoder(rw).Encode(res)\n}", "func getInvoices(stub shim.ChaincodeStubInterface, args []string) ([]byte, error) {\r\n\tlogger.Info(\"getInvoices called\")\r\n\tufanumber := args[0]\r\n\t//who:= args[1]\r\n\toutputBytes, _ := json.Marshal(getInvoicesForUFA(stub, ufanumber))\r\n\tlogger.Info(\"getInvoices returning \" + string(outputBytes))\r\n\treturn outputBytes, nil\r\n}", "func (client DnsClient) ListTsigKeys(ctx context.Context, request ListTsigKeysRequest) (response ListTsigKeysResponse, err error) {\n\tvar ociResponse common.OCIResponse\n\tpolicy := common.NoRetryPolicy()\n\tif request.RetryPolicy() != nil {\n\t\tpolicy = *request.RetryPolicy()\n\t}\n\tociResponse, err = common.Retry(ctx, request, client.listTsigKeys, policy)\n\tif err != nil {\n\t\tif ociResponse != nil {\n\t\t\tif httpResponse := ociResponse.HTTPResponse(); httpResponse != nil {\n\t\t\t\topcRequestId := httpResponse.Header.Get(\"opc-request-id\")\n\t\t\t\tresponse = ListTsigKeysResponse{RawResponse: httpResponse, OpcRequestId: &opcRequestId}\n\t\t\t} else {\n\t\t\t\tresponse = ListTsigKeysResponse{}\n\t\t\t}\n\t\t}\n\t\treturn\n\t}\n\tif convertedResponse, ok := ociResponse.(ListTsigKeysResponse); ok {\n\t\tresponse = convertedResponse\n\t} else {\n\t\terr = fmt.Errorf(\"failed to convert OCIResponse into ListTsigKeysResponse\")\n\t}\n\treturn\n}", "func TestGetTradesHistory(t *testing.T) {\n\tt.Parallel()\n\targs := GetTradesHistoryOptions{Trades: true, Start: \"TMZEDR-VBJN2-NGY6DX\", End: \"TVRXG2-R62VE-RWP3UW\"}\n\t_, err := k.GetTradesHistory(context.Background(), args)\n\tif err == nil {\n\t\tt.Error(\"GetTradesHistory() Expected error\")\n\t}\n}", "func (api *PublicEthereumAPI) GetKeys() []ethsecp256k1.PrivKey {\n\treturn api.keys\n}", "func (t *topK) K() int {\n\treturn t.k\n}", "func (h *HUOBI) GetBatchTrades(ctx context.Context, code currency.Pair, size int64) (BatchTradesData, error) {\n\tvar resp BatchTradesData\n\tcodeValue, err := h.FormatSymbol(code, asset.CoinMarginedFutures)\n\tif err != nil {\n\t\treturn resp, err\n\t}\n\tparams := url.Values{}\n\tparams.Set(\"contract_code\", codeValue)\n\tparams.Set(\"size\", strconv.FormatInt(size, 10))\n\tpath := common.EncodeURLValues(huobiRequestBatchOfTradingRecords, params)\n\treturn resp, h.SendHTTPRequest(ctx, exchange.RestFutures, path, &resp)\n}", "func getKttClient(cfg *Config) *KttClient {\n\n\tkttAuthorization := base64.StdEncoding.EncodeToString([]byte(cfg.KTT.Username + \":\" + cfg.KTT.Password))\n\n\tclient := &http.Client{}\n\n\tkttClient := KttClient{\n\t\tClient: client,\n\t\tAuthorization: kttAuthorization}\n\n\treturn &kttClient\n}", "func (s *SmartContract) queryChainKey(stub shim.ChaincodeStubInterface, args []string) sc.Response {\n\tif len(args) != 1 {\n\t\tshim.Error(\"Incorrect number of arguments, Expecting 1\")\n\t}\n\tchainkeyAsBytes, _ := stub.GetState(args[0])\n\tdata := string(chainkeyAsBytes)\n\tfmt.Println(\"Returning list of Asset %s args[0]\", data)\n\n\tif chainkeyAsBytes == nil {\n\t\treturn shim.Error(\"could not locate Asset\")\n\t}\n\treturn shim.Success(chainkeyAsBytes)\n}", "func (a API) GetTxOut(cmd *btcjson.GetTxOutCmd) (e error) {\n\tRPCHandlers[\"gettxout\"].Call <-API{a.Ch, cmd, nil}\n\treturn\n}", "func (b *ByBit) GetTradingRecords(symbol string, from int64, limit int) (result []TradingRecord, err error) {\n\tvar ret GetTradingRecordsResult\n\tparams := map[string]interface{}{}\n\tparams[\"symbol\"] = symbol\n\tif from > 0 {\n\t\tparams[\"from\"] = from\n\t}\n\tif limit > 0 {\n\t\tparams[\"limit\"] = limit\n\t}\n\t_, err = b.PublicRequest(http.MethodGet, \"v2/public/trading-records\", params, &ret)\n\tif err != nil {\n\t\treturn\n\t}\n\tresult = ret.Result\n\treturn\n}", "func RetrieveTxs(refreshFromNode bool, txID *uint32, txSlateID *uuid.UUID) (bool, *[]libwallet.TxLogEntry, error) {\n\tclient := RPCHTTPClient{URL: url}\n\tparams := []interface{}{refreshFromNode, txID, txSlateID}\n\tparamsBytes, err := json.Marshal(params)\n\tif err != nil {\n\t\treturn false, nil, err\n\t}\n\tenvl, err := client.Request(\"retrieve_txs\", paramsBytes)\n\tif err != nil {\n\t\treturn false, nil, err\n\t}\n\tif envl == nil {\n\t\treturn false, nil, errors.New(\"OwnerAPI: Empty RPC Response from grin-wallet\")\n\t}\n\tif envl.Error != nil {\n\t\tlog.WithFields(log.Fields{\n\t\t\t\"code\": envl.Error.Code,\n\t\t\t\"message\": envl.Error.Message,\n\t\t}).Error(\"OwnerAPI: RPC Error during RetrieveTxs\")\n\t\treturn false, nil, errors.New(string(envl.Error.Code) + \"\" + envl.Error.Message)\n\t}\n\tvar result Result\n\tif err = json.Unmarshal(envl.Result, &result); err != nil {\n\t\treturn false, nil, err\n\t}\n\tif result.Err != nil {\n\t\treturn false, nil, errors.New(string(result.Err))\n\t}\n\n\tvar okArray []json.RawMessage\n\tif err = json.Unmarshal(result.Ok, &okArray); err != nil {\n\t\treturn false, nil, err\n\t}\n\tif len(okArray) < 2 {\n\t\treturn false, nil, errors.New(\"Wrong okArray length\")\n\t}\n\tvar refreshedFromNode bool\n\tif err = json.Unmarshal(okArray[0], &refreshedFromNode); err != nil {\n\t\treturn false, nil, err\n\t}\n\tvar txLogEntries []libwallet.TxLogEntry\n\tif err := json.Unmarshal(okArray[1], &txLogEntries); err != nil {\n\t\treturn false, nil, err\n\t}\n\n\treturn refreshedFromNode, &txLogEntries, nil\n}", "func (api *DeprecatedApiService) getTransactionIntro(params map[string]string) map[string]string {\n\tresult := make(map[string]string)\n\n\t_, is_only_check_exist := params[\"only_check_exist\"]\n\n\ttrsid, ok1 := params[\"id\"]\n\tif !ok1 {\n\t\tresult[\"err\"] = \"param id must.\"\n\t\treturn result\n\t}\n\n\tvar trshx []byte\n\tif txhx, e := hex.DecodeString(trsid); e == nil && len(txhx) == 32 {\n\t\ttrshx = txhx\n\t} else {\n\t\tresult[\"err\"] = \"transaction hash error.\"\n\t\treturn result\n\t}\n\n\t// Query transaction\n\tblkhei, trsresbytes, err := api.blockchain.GetChainEngineKernel().StateRead().ReadTransactionBytesByHash(trshx)\n\tif err != nil {\n\t\tresult[\"err\"] = err.Error()\n\t\treturn result\n\t}\n\tif trsresbytes == nil {\n\t\tresult[\"err\"] = \"transaction not fond.\"\n\t\treturn result\n\t}\n\n\t// Whether to just judge whether it exists\n\tif is_only_check_exist && len(trsresbytes) > 0 {\n\t\tresult[\"ret\"] = \"0\"\n\t\tresult[\"exist\"] = \"yes\"\n\t\treturn result\n\t}\n\n\ttrsres, _, err := transactions.ParseTransaction(trsresbytes, 0)\n\tif err != nil {\n\t\tresult[\"err\"] = err.Error()\n\t\treturn result\n\t}\n\n\t// Resolve actions\n\tvar allactions = trsres.GetActionList()\n\tvar actions_ary []string\n\tvar actions_strings = \"\"\n\tfor _, act := range allactions {\n\t\tvar kind = act.Kind()\n\t\tactstr := fmt.Sprintf(`{\"k\":%d`, kind)\n\t\tif kind == 1 {\n\t\t\tacc := act.(*actions.Action_1_SimpleToTransfer)\n\t\t\tactstr += fmt.Sprintf(`,\"to\":\"%s\",\"amount\":\"%s\"`,\n\t\t\t\tacc.ToAddress.ToReadable(),\n\t\t\t\tacc.Amount.ToFinString(),\n\t\t\t)\n\t\t} else if kind == 13 {\n\t\t\tacc := act.(*actions.Action_13_FromTransfer)\n\t\t\tactstr += fmt.Sprintf(`,\"from\":\"%s\",\"amount\":\"%s\"`,\n\t\t\t\tacc.FromAddress.ToReadable(),\n\t\t\t\tacc.Amount.ToFinString(),\n\t\t\t)\n\t\t} else if kind == 14 {\n\t\t\tacc := act.(*actions.Action_14_FromToTransfer)\n\t\t\tactstr += fmt.Sprintf(`,\"from\":\"%s\",\"to\":\"%s\",\"amount\":\"%s\"`,\n\t\t\t\tacc.FromAddress.ToReadable(),\n\t\t\t\tacc.ToAddress.ToReadable(),\n\t\t\t\tacc.Amount.ToFinString(),\n\t\t\t)\n\t\t} else if kind == 2 {\n\t\t\tacc := act.(*actions.Action_2_OpenPaymentChannel)\n\t\t\tactstr += fmt.Sprintf(`,\"channel_id\":\"%s\",\"left_addr\":\"%s\",\"left_amt\":\"%s\",\"right_addr\":\"%s\",\"right_amt\":\"%s\"`,\n\t\t\t\thex.EncodeToString(acc.ChannelId),\n\t\t\t\tacc.LeftAddress.ToReadable(),\n\t\t\t\tacc.LeftAmount.ToFinString(),\n\t\t\t\tacc.RightAddress.ToReadable(),\n\t\t\t\tacc.RightAmount.ToFinString(),\n\t\t\t)\n\t\t} else if kind == 3 {\n\t\t\tacc := act.(*actions.Action_3_ClosePaymentChannel)\n\t\t\tactstr += fmt.Sprintf(`,\"channel_id\":\"%s\"`,\n\t\t\t\thex.EncodeToString(acc.ChannelId),\n\t\t\t)\n\t\t} else if kind == 4 {\n\t\t\tacc := act.(*actions.Action_4_DiamondCreate)\n\t\t\tactstr += fmt.Sprintf(`,\"number\":\"%d\",\"name\":\"%s\",\"address\":\"%s\"`,\n\t\t\t\tacc.Number,\n\t\t\t\tacc.Diamond,\n\t\t\t\tacc.Address.ToReadable(),\n\t\t\t)\n\t\t} else if kind == 5 {\n\t\t\tacc := act.(*actions.Action_5_DiamondTransfer)\n\t\t\tactstr += fmt.Sprintf(`,\"count\":1,\"names\":\"%s\",\"from\":\"%s\",\"to\":\"%s\"`,\n\t\t\t\tacc.ToAddress.ToReadable(),\n\t\t\t\tacc.Diamond,\n\t\t\t\ttrsres.GetAddress().ToReadable(),\n\t\t\t\tacc.ToAddress.ToReadable(),\n\t\t\t)\n\t\t} else if kind == 6 {\n\t\t\tacc := act.(*actions.Action_6_OutfeeQuantityDiamondTransfer)\n\t\t\tdmds := make([]string, len(acc.DiamondList.Diamonds))\n\t\t\tfor i, v := range acc.DiamondList.Diamonds {\n\t\t\t\tdmds[i] = string(v)\n\t\t\t}\n\t\t\tactstr += fmt.Sprintf(`,\"count\":%d,\"names\":\"%s\",\"from\":\"%s\",\"to\":\"%s\"`,\n\t\t\t\tacc.DiamondList.Count,\n\t\t\t\tstrings.Join(dmds, \",\"),\n\t\t\t\tacc.FromAddress.ToReadable(),\n\t\t\t\tacc.ToAddress.ToReadable(),\n\t\t\t)\n\t\t} else if kind == 7 {\n\t\t\tacc := act.(*actions.Action_7_SatoshiGenesis)\n\t\t\tactstr += fmt.Sprintf(`,\"trs_no\":%d,\"btc_num\":%d,\"hac_subsidy\":%d,\"address\":\"%s\",\"lockbls_id\":\"%s\"`,\n\t\t\t\tacc.TransferNo,\n\t\t\t\tacc.BitcoinQuantity,\n\t\t\t\tacc.AdditionalTotalHacAmount,\n\t\t\t\tacc.OriginAddress.ToReadable(),\n\t\t\t\thex.EncodeToString(actions.GainLockblsIdByBtcMove(uint32(acc.TransferNo))),\n\t\t\t)\n\t\t} else if kind == 8 {\n\t\t\tacc := act.(*actions.Action_8_SimpleSatoshiTransfer)\n\t\t\tactstr += fmt.Sprintf(`,\"to\":\"%s\",\"amount\":%d`,\n\t\t\t\tacc.ToAddress.ToReadable(),\n\t\t\t\tacc.Amount,\n\t\t\t)\n\t\t} else if kind == 9 {\n\t\t\tacc := act.(*actions.Action_9_LockblsCreate)\n\t\t\tactstr += fmt.Sprintf(`,\"lockbls_id\":\"%s\",\"amount\":\"%s\"`,\n\t\t\t\thex.EncodeToString(acc.LockblsId),\n\t\t\t\tacc.TotalStockAmount.ToFinString(),\n\t\t\t)\n\t\t} else if kind == 10 {\n\t\t\tacc := act.(*actions.Action_10_LockblsRelease)\n\t\t\tactstr += fmt.Sprintf(`,\"lockbls_id\":\"%s\",\"amount\":\"%s\"`,\n\t\t\t\thex.EncodeToString(acc.LockblsId),\n\t\t\t\tacc.ReleaseAmount.ToFinString(),\n\t\t\t)\n\t\t} else if kind == 11 {\n\t\t\tacc := act.(*actions.Action_11_FromToSatoshiTransfer)\n\t\t\tactstr += fmt.Sprintf(`,\"from\":\"%s\",\"to\":\"%s\",\"amount\":%d`,\n\t\t\t\tacc.FromAddress.ToReadable(),\n\t\t\t\tacc.ToAddress.ToReadable(),\n\t\t\t\tacc.Amount,\n\t\t\t)\n\t\t} else if kind == 28 {\n\t\t\tacc := act.(*actions.Action_28_FromSatoshiTransfer)\n\t\t\tactstr += fmt.Sprintf(`,\"from\":\"%s\",\"amount\":%d`,\n\t\t\t\tacc.FromAddress.ToReadable(),\n\t\t\t\tacc.Amount,\n\t\t\t)\n\t\t} else if kind == 12 {\n\t\t\tacc := act.(*actions.Action_12_ClosePaymentChannelBySetupAmount)\n\t\t\tactstr += fmt.Sprintf(`,\"channel_id\":\"%s\"`,\n\t\t\t\thex.EncodeToString(acc.ChannelId),\n\t\t\t)\n\t\t} else if kind == 21 {\n\t\t\tacc := act.(*actions.Action_21_ClosePaymentChannelBySetupOnlyLeftAmount)\n\t\t\tactstr += fmt.Sprintf(`,\"channel_id\":\"%s\"`,\n\t\t\t\thex.EncodeToString(acc.ChannelId),\n\t\t\t)\n\t\t} else if kind == 22 {\n\t\t\tacc := act.(*actions.Action_22_UnilateralClosePaymentChannelByNothing)\n\t\t\tactstr += fmt.Sprintf(`,\"channel_id\":\"%s\",\"assert_address\"\":\"%s\",\"bill_number\"\":0`,\n\t\t\t\thex.EncodeToString(acc.ChannelId), acc.AssertCloseAddress.ToReadable(),\n\t\t\t)\n\t\t} else if kind == 23 {\n\t\t\tacc := act.(*actions.Action_23_UnilateralCloseOrRespondChallengePaymentChannelByRealtimeReconciliation)\n\t\t\tactstr += fmt.Sprintf(`,\"channel_id\":\"%s\",\"assert_address\":\"%s\",\"bill_number\":%d`,\n\t\t\t\thex.EncodeToString(acc.Reconciliation.GetChannelId()), acc.AssertAddress.ToReadable(), acc.Reconciliation.GetAutoNumber(),\n\t\t\t)\n\t\t} else if kind == 24 {\n\t\t\tacc := act.(*actions.Action_24_UnilateralCloseOrRespondChallengePaymentChannelByChannelChainTransferBody)\n\t\t\tactstr += fmt.Sprintf(`,\"channel_id\":\"%s\",\"assert_address\":\"%s\",\"bill_number\":%d`,\n\t\t\t\thex.EncodeToString(acc.ChannelChainTransferTargetProveBody.GetChannelId()), acc.AssertAddress.ToReadable(), acc.ChannelChainTransferTargetProveBody.GetAutoNumber(),\n\t\t\t)\n\t\t} else if kind == 27 {\n\t\t\tacc := act.(*actions.Action_27_ClosePaymentChannelByClaimDistribution)\n\t\t\tactstr += fmt.Sprintf(`,\"channel_id\":\"%s\",\"assert_address\":\"any\",\"bill_number\"\":\"closed\"`,\n\t\t\t\thex.EncodeToString(acc.ChannelId),\n\t\t\t)\n\t\t}\n\t\tactstr += \"}\"\n\t\tactions_ary = append(actions_ary, actstr)\n\t}\n\tactions_strings = strings.Join(actions_ary, \",\")\n\n\t// Transaction return data\n\ttxaddr := fields.Address(trsres.GetAddress())\n\tvar txfee = trsres.GetFee()\n\tvar txfeeminergot = trsres.GetFeeOfMinerRealReceived()\n\tresult[\"jsondata\"] = fmt.Sprintf(\n\t\t`{\"block\":{\"height\":%d,\"timestamp\":%d},\"type\":%d,\"address\":\"%s\",\"fee\":\"%s\",\"feeminergot\":\"%s\",\"timestamp\":%d,\"actioncount\":%d,\"actions\":[%s]`,\n\t\tblkhei,\n\t\ttrsres.GetTimestamp(),\n\t\ttrsres.Type(),\n\t\ttxaddr.ToReadable(), // Primary address\n\t\ttxfee.ToFinString(),\n\t\ttxfeeminergot.ToFinString(),\n\t\ttrsres.GetTimestamp(),\n\t\tlen(allactions),\n\t\tactions_strings,\n\t)\n\n\tif _, ok := params[\"txbodyhex\"]; ok {\n\t\tresult[\"jsondata\"] += fmt.Sprintf(`,\"txbodyhex\":\"%s\"`,\n\t\t\thex.EncodeToString(trsresbytes))\n\t}\n\n\t// Wrap up and return\n\tresult[\"jsondata\"] += \"}\"\n\treturn result\n}", "func (contract *ContractChaincode) getEmployeeTxHistory(stub shim.ChaincodeStubInterface, args []string) peer.Response {\n\t// Check the number of args\n\tif len(args) < 1 {\n\t\treturn shim.Error(\"MUST provide EmployeeId !!!\")\n\t}\n\n\t// Get the history for the employee\n\thistoryQueryIterator, err := stub.GetHistoryForKey(args[0])\n\n\t// In case of error - return error\n\tif err != nil {\n\t\treturn shim.Error(\"Error in fetching history !!!\" + err.Error())\n\t}\n\n\t// Local variable to hold the history record\n\tvar resultModification *queryresult.KeyModification\n\tcounter := 0\n\tresultJSON := \"[\"\n\n\t// Start a loop with check for more rows\n\tfor historyQueryIterator.HasNext() {\n\n\t\t// Get the next record\n\t\tresultModification, err = historyQueryIterator.Next()\n\n\t\tif err != nil {\n\t\t\treturn shim.Error(\"Error in reading history record!!!\" + err.Error())\n\t\t}\n\n\t\t// Append the data to local variable\n\t\tdata := \"{\\\"txn\\\":\" + resultModification.GetTxId()\n\t\tdata += \" , \\\"value\\\": \" + string(resultModification.GetValue()) + \"} \"\n\t\tif counter > 0 {\n\t\t\tdata = \", \" + data\n\t\t}\n\t\tresultJSON += data\n\n\t\tcounter++\n\t}\n\n\t// Close the iterator\n\thistoryQueryIterator.Close()\n\n\t// finalize the return string\n\tresultJSON += \"]\"\n\tresultJSON = \"{ \\\"counter\\\": \" + strconv.Itoa(counter) + \", \\\"txns\\\":\" + resultJSON + \"}\"\n\n\t// return success\n\treturn shim.Success([]byte(resultJSON))\n\n}", "func (s *PetShopServer) GetKitten(ctx context.Context, req *pb.GetKittenRequest) (*pb.GetKittenResponse, error) {\n\treturn &pb.GetKittenResponse{Kitten: ProvideKitten()}, nil\n}", "func (c *Client) GetMempoolTransactions() (transactions []string, err error) {\r\n\r\n\tvar resp string\r\n\t// https://api.whatsonchain.com/v1/bsv/<network>/mempool/raw\r\n\tif resp, err = c.request(fmt.Sprintf(\"%s%s/mempool/raw\", apiEndpoint, c.Network), http.MethodGet, nil); err != nil {\r\n\t\treturn\r\n\t}\r\n\r\n\terr = json.Unmarshal([]byte(resp), &transactions)\r\n\treturn\r\n}", "func (o TrailOutput) KmsKeyId() pulumi.StringPtrOutput {\n\treturn o.ApplyT(func(v *Trail) pulumi.StringPtrOutput { return v.KmsKeyId }).(pulumi.StringPtrOutput)\n}", "func (r *CompanySalesQuoteLinesCollectionRequest) Get(ctx context.Context) ([]SalesQuoteLine, error) {\n\treturn r.GetN(ctx, 0)\n}", "func GetTransactions(delegateNode types.Node, pageOptions ...string) ([]types.Transaction, error) {\n\tpage := \"1\"\n\tpageSize := \"10\"\n\tpageStart := \"\"\n\n\tif pageOptions[0] != \"\"{\n\t\tpage = pageOptions[0]\n\t}\n\n\tif pageOptions[1] != \"\"{\n\t\tpageSize = pageOptions[1]\n\t}\n\n\tif pageOptions[2] != \"\"{\n\t\tpageStart = pageOptions[2]\n\t}\n\n\t// Get sent transaction.\n\thttpResponse, err := http.Get(fmt.Sprintf(\"http://%s:%d/v1/transactions?page=%s&pageSize=%s&pageStart=%s\", delegateNode.HttpEndpoint.Host, delegateNode.HttpEndpoint.Port, page,pageSize,pageStart))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tdefer httpResponse.Body.Close()\n\n\t// Read body.\n\tbody, err := ioutil.ReadAll(httpResponse.Body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Unmarshal response.\n\tvar response *types.Response\n\terr = json.Unmarshal(body, &response)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Status?\n\tif response.Status != types.StatusOk {\n\t\treturn nil, errors.New(fmt.Sprintf(\"%s: %s\", response.Status, response.HumanReadableStatus))\n\t}\n\n\t// Unmarshal to RawMessage.\n\tvar jsonMap map[string]json.RawMessage\n\terr = json.Unmarshal(body, &jsonMap)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Data?\n\tif jsonMap[\"data\"] == nil {\n\t\treturn nil, errors.Errorf(\"'data' is missing from response\")\n\t}\n\n\t// Unmarshal transactions.\n\tvar transactions []types.Transaction\n\terr = json.Unmarshal(jsonMap[\"data\"], &transactions)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn transactions, nil\n}", "func (s *KinesisService) GetRecords(req *GetRecordsRequest) (result *GetRecordsResult, err error) {\n\n\tresult = new(GetRecordsResult)\n\terr = s.wrapperSignAndDo(\"Kinesis_20131202.GetRecords\", req, result)\n\treturn\n}", "func GetTotalSupply(w http.ResponseWriter, r *http.Request) {\n\n\t// Add header so that received knows they're receiving JSON\n\tw.Header().Add(\"Content-Type\", \"application/json\")\n\n\t// Retrieving name of node from query request\n\tnodeName := r.URL.Query().Get(\"name\")\n\tconfirmation, socket := checkNodeName(nodeName)\n\tif confirmation == false {\n\t\t// Stop code here no need to establish connection and reply\n\t\tjson.NewEncoder(w).Encode(responses.ErrorResponse{\n\t\t\tError: \"Node name requested doesn't exist\"})\n\t\treturn\n\t}\n\n\trecvHeight := r.URL.Query().Get(\"height\")\n\theight := checkHeight(recvHeight)\n\tif height == -1 {\n\n\t\t// Stop code here no need to establish connection and reply\n\t\tjson.NewEncoder(w).Encode(responses.ErrorResponse{\n\t\t\tError: \"Unexepcted value found, height needs to be string of int!\"})\n\t\treturn\n\t}\n\n\t// Attempt to load connection with staking client\n\tconnection, so := loadStakingClient(socket)\n\n\t// Close connection once code underneath executes\n\tdefer connection.Close()\n\n\t// If null object was retrieved send response\n\tif so == nil {\n\n\t\t// Stop code here faild to establish connection and reply\n\t\tjson.NewEncoder(w).Encode(responses.ErrorResponse{\n\t\t\tError: \"Failed to establish connection using socket : \" + socket})\n\t\treturn\n\t}\n\n\t// Using Oasis API to return total supply of tokens at specific block height\n\ttotalSupply, err := so.TotalSupply(context.Background(), height)\n\tif err != nil {\n\t\tjson.NewEncoder(w).Encode(responses.ErrorResponse{\n\t\t\tError: \"Failed to get TotalSupply!\"})\n\t\tlgr.Error.Println(\n\t\t\t\"Request at /api/staking/totalsupply failed to retrieve \"+\n\t\t\t\t\"totalsupply : \", err)\n\t\treturn\n\t}\n\n\tlgr.Info.Println(\"Request at /api/staking/totalsupply responding with \" +\n\t\t\"TotalSupply!\")\n\tjson.NewEncoder(w).Encode(responses.QuantityResponse{Quantity: totalSupply})\n}", "func getTicketDetails(ticketHash string) (string, string, string, error) {\n\tvar getTransactionResult wallettypes.GetTransactionResult\n\terr := c.Call(context.TODO(), \"gettransaction\", &getTransactionResult, ticketHash, false)\n\tif err != nil {\n\t\tfmt.Printf(\"gettransaction: %v\\n\", err)\n\t\treturn \"\", \"\", \"\", err\n\t}\n\n\tmsgTx := wire.NewMsgTx()\n\tif err = msgTx.Deserialize(hex.NewDecoder(strings.NewReader(getTransactionResult.Hex))); err != nil {\n\t\treturn \"\", \"\", \"\", err\n\t}\n\tif len(msgTx.TxOut) < 2 {\n\t\treturn \"\", \"\", \"\", errors.New(\"msgTx.TxOut < 2\")\n\t}\n\n\tconst scriptVersion = 0\n\t_, submissionAddr, _, err := txscript.ExtractPkScriptAddrs(scriptVersion,\n\t\tmsgTx.TxOut[0].PkScript, chaincfg.TestNet3Params())\n\tif err != nil {\n\t\treturn \"\", \"\", \"\", err\n\t}\n\tif len(submissionAddr) != 1 {\n\t\treturn \"\", \"\", \"\", errors.New(\"submissionAddr != 1\")\n\t}\n\taddr, err := stake.AddrFromSStxPkScrCommitment(msgTx.TxOut[1].PkScript,\n\t\tchaincfg.TestNet3Params())\n\tif err != nil {\n\t\treturn \"\", \"\", \"\", err\n\t}\n\n\tvar privKeyStr string\n\terr = c.Call(context.TODO(), \"dumpprivkey\", &privKeyStr, submissionAddr[0].Address())\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treturn getTransactionResult.Hex, privKeyStr, addr.Address(), nil\n}", "func (o InitialStateConfigOutput) Keks() FileContentBufferArrayOutput {\n\treturn o.ApplyT(func(v InitialStateConfig) []FileContentBuffer { return v.Keks }).(FileContentBufferArrayOutput)\n}", "func (r *CompanySalesOrderLinesCollectionRequest) Get(ctx context.Context) ([]SalesOrderLine, error) {\n\treturn r.GetN(ctx, 0)\n}", "func GetWalletTrxList(category string, account string, limit int64) ([]*TrxInfo, error) {\n\tif category == \"ETH\" {\n\t\ttrxList, err := GetETHTrxList(account, limit)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn trxList, nil\n\t}\n\tif category == \"DATX\" {\n\t\ttrxList, err := GetDATXTrxList(account, 0, limit)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn trxList, nil\n\t}\n\treturn nil, fmt.Errorf(\"transactions not found\")\n}", "func (rt RouteTable) K() int {\n\treturn rt.dht.NumNodes()\n}", "func (h HTTPInvalidRequestLine) GetTestKeys(tk map[string]interface{}) (interface{}, error) {\n\ttestKeys := HTTPInvalidRequestLineTestKeys{IsAnomaly: false}\n\n\ttampering, ok := tk[\"tampering\"].(bool)\n\tif !ok {\n\t\treturn testKeys, errors.New(\"tampering is not bool\")\n\t}\n\ttestKeys.IsAnomaly = tampering\n\n\treturn testKeys, nil\n}", "func (m *MockRestAPI) GetChangedLines(c context.Context, host, change, revision string) (ChangedLinesInfo, error) {\n\treturn m.ChangedLines, nil\n}", "func (client DnsClient) listTsigKeys(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) {\n\thttpRequest, err := request.HTTPRequest(http.MethodGet, \"/tsigKeys\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar response ListTsigKeysResponse\n\tvar httpResponse *http.Response\n\thttpResponse, err = client.Call(ctx, &httpRequest)\n\tdefer common.CloseBodyIfValid(httpResponse)\n\tresponse.RawResponse = httpResponse\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = common.UnmarshalResponse(httpResponse, &response)\n\treturn response, err\n}", "func TestGetByKey(t *testing.T) {\n\ttf.UnitTest(t)\n\n\tctx := context.Background()\n\tbuilder := chain.NewBuilder(t, address.Undef)\n\tgenTS := builder.Genesis()\n\tr := repo.NewInMemoryRepo()\n\tcs := newChainStore(r, genTS)\n\n\t// Construct test chain data\n\tlink1 := builder.AppendOn(ctx, genTS, 2)\n\tlink2 := builder.AppendOn(ctx, link1, 3)\n\tlink3 := builder.AppendOn(ctx, link2, 1)\n\tlink4 := builder.BuildOn(ctx, link3, 2, func(bb *chain.BlockBuilder, i int) { bb.IncHeight(2) })\n\n\t// Put the test chain to the store\n\trequirePutTestChain(ctx, t, cs, link4.Key(), builder, 5)\n\n\t// Check that we can get all tipsets by key\n\tgotGTS := requireGetTipSet(ctx, t, cs, genTS.Key())\n\tgotGTSSR := requireGetTipSetStateRoot(ctx, t, cs, genTS)\n\n\tgot1TS := requireGetTipSet(ctx, t, cs, link1.Key())\n\tgot1TSSR := requireGetTipSetStateRoot(ctx, t, cs, link1)\n\n\tgot2TS := requireGetTipSet(ctx, t, cs, link2.Key())\n\tgot2TSSR := requireGetTipSetStateRoot(ctx, t, cs, link2)\n\n\tgot3TS := requireGetTipSet(ctx, t, cs, link3.Key())\n\tgot3TSSR := requireGetTipSetStateRoot(ctx, t, cs, link3)\n\n\tgot4TS := requireGetTipSet(ctx, t, cs, link4.Key())\n\tgot4TSSR := requireGetTipSetStateRoot(ctx, t, cs, link4)\n\tassert.ObjectsAreEqualValues(genTS, gotGTS)\n\tassert.ObjectsAreEqualValues(link1, got1TS)\n\tassert.ObjectsAreEqualValues(link2, got2TS)\n\tassert.ObjectsAreEqualValues(link3, got3TS)\n\tassert.ObjectsAreEqualValues(link4, got4TS)\n\n\tassert.Equal(t, genTS.At(0).ParentStateRoot, gotGTSSR)\n\tassert.Equal(t, link1.At(0).ParentStateRoot, got1TSSR)\n\tassert.Equal(t, link2.At(0).ParentStateRoot, got2TSSR)\n\tassert.Equal(t, link3.At(0).ParentStateRoot, got3TSSR)\n\tassert.Equal(t, link4.At(0).ParentStateRoot, got4TSSR)\n}", "func TestGetOpenOrders(t *testing.T) {\n\tt.Parallel()\n\targs := OrderInfoOptions{Trades: true}\n\t_, err := k.GetOpenOrders(context.Background(), args)\n\tif err == nil {\n\t\tt.Error(\"GetOpenOrders() Expected error\")\n\t}\n}", "func TestGetTrades(t *testing.T) {\n\tif plan == \"free\" {\n\t\tt.Skip(\"Skipping /trades API endpoint. (Paid Plan) testing.\")\n\t} else {\n\t\tt.Log(\"Testing /trades API endpoint. (Paid Plan)\")\n\t\t// demoAPIKey is defined in connector.go\n\t\t// Please check this latest demo key published in nomics doc or use private key for paid API endpoint testing.\n\t\tc := New(demoAPIKey)\n\n\t\t// We can modify Timeout, Transport etc of http if the default is not good.\n\t\tc.HTTPClient.Timeout = time.Second * 10\n\n\t\t// Json format.\n\t\tt.Log(\"Testing for JSON format.\")\n\t\tfromTime, _ := time.Parse(time.RFC3339, \"2021-01-01T00:00:00Z\")\n\t\ttReqJSON := TradesRequest{\n\t\t\tExchange: \"binance\",\n\t\t\tMarket: \"BTCUSDT\",\n\t\t\tLimit: 100,\n\t\t\tOrder: \"asc\",\n\t\t\tFrom: fromTime,\n\t\t}\n\t\ttRespJSON, err := c.GetTrades(tReqJSON)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t\tif len(tRespJSON) < 1 {\n\t\t\tt.Error(\"Something is wrong here, length of response array is 0. JSON Format.\")\n\t\t}\n\t\tfor _, tr := range tRespJSON {\n\t\t\tif tr.Volume == 0 {\n\t\t\t\tt.Error(\"Something is wrong here, value of response arrays volume is 0. JSON Format.\")\n\t\t\t}\n\t\t}\n\n\t\t// CSV format.\n\t\tt.Log(\"Testing for CSV format.\")\n\t\ttReqCSV := TradesRequest{\n\t\t\tExchange: \"binance\",\n\t\t\tMarket: \"BTCUSDT\",\n\t\t\tLimit: 100,\n\t\t\tOrder: \"asc\",\n\t\t\tFrom: fromTime,\n\t\t\tFormat: \"csv\",\n\t\t\tFileNameWithPath: \"./testdata/trades.csv\",\n\t\t}\n\t\t_, err = c.GetTrades(tReqCSV)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t\tf, err := os.Open(tReqCSV.FileNameWithPath)\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t\tdefer f.Close()\n\t\tcsvData, err := csv.NewReader(f).ReadAll()\n\t\tif err != nil {\n\t\t\tt.Error(err)\n\t\t}\n\t\tif len(csvData) < 1 {\n\t\t\tt.Error(\"Something is wrong here, length of response array is 0. CSV Format.\")\n\t\t}\n\t\tfor _, data := range csvData {\n\t\t\ttr, err := strconv.ParseFloat(data[3], 64)\n\t\t\tif err != nil {\n\t\t\t\tt.Error(\"Something is wrong here, value of response arrays volume is 0. CSV Format.\")\n\t\t\t}\n\t\t\tif tr == 0 {\n\t\t\t\tt.Error(\"Something is wrong here, value of response arrays volume is 0. CSV Format.\")\n\t\t\t}\n\t\t}\n\t}\n}", "func Kanye() string {\n\tresp, err := http.Get(\"https://api.kanye.rest/\")\n\tif err != nil {\n\t\treturn \"I had a problem...\"\n\t}\n\tdefer resp.Body.Close()\n\n\tbodyBytes, err := ioutil.ReadAll(resp.Body)\n\n\tvar quote kanyeQuote\n\tjson.Unmarshal([]byte(bodyBytes), &quote)\n\treturn quote.Quote\n}", "func (r *Trail) KmsKeyId() pulumi.StringOutput {\n\treturn (pulumi.StringOutput)(r.s.State[\"kmsKeyId\"])\n}", "func TestGetTickers(t *testing.T) {\n\tt.Parallel()\n\t_, err := k.GetTickers(context.Background(), \"LTCUSD,ETCUSD\")\n\tif err != nil {\n\t\tt.Error(\"GetTickers() error\", err)\n\t}\n}", "func GetTransactions(options *GetTransactionsOptions) (response TransactionsResponse, err error) {\n\turl := \"https://blocks.flashbots.net/v1/transactions\"\n\tif options != nil {\n\t\turl = url + options.ToUriQuery()\n\t}\n\n\tresp, err := http.Get(url)\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\terr = json.NewDecoder(resp.Body).Decode(&response)\n\tif err != nil {\n\t\treturn response, err\n\t}\n\n\treturn response, nil\n}", "func (p *HbaseClient) GetRowsTs(tableName Text, rows [][]byte, timestamp int64, attributes map[string]Text) (r []*TRowResult_, err error) {\n\tif err = p.sendGetRowsTs(tableName, rows, timestamp, attributes); err != nil {\n\t\treturn\n\t}\n\treturn p.recvGetRowsTs()\n}", "func (mc *MoacChain) getTransactionReceipt(hashStr string) (err error) {\n\n\tdefer func() {\n\t\tif re := recover(); re != nil {\n\t\t\terr = re.(error)\n\t\t}\n\t}()\n\n\tpostData := map[string]interface{}{\n\t\t\"id\": \"101\",\n\t\t\"jsonrpc\": \"2.0\",\n\t\t\"method\": \"mc_getTransactionReceipt\",\n\t\t\"params\": [1]interface{}{hashStr},\n\t}\n\n\tresp, netErr := moacNetRequset.SetPostData(postData).Post()\n\tif netErr == nil {\n\t\tvar resultMap map[string]interface{}\n\t\tjson.Unmarshal([]byte(resp.Body), &resultMap)\n\t\tif value, flag := resultMap[\"result\"]; flag {\n\t\t\tif ((value).(map[string]interface{}))[\"status\"] == \"0x0\" {\n\n\t\t\t\terr = errors.New(\"\")\n\t\t\t}\n\t\t} else {\n\t\t\terr = errors.New((((resultMap[\"error\"]).(map[string]interface{}))[\"message\"]).(string))\n\t\t}\n\t} else {\n\t\terr = netErr\n\t}\n\n\treturn err\n}", "func (tx StdTx) GetSignatures() []StdSignature { return tx.Signatures }", "func (h *HUOBI) GetPremiumIndexKlineData(ctx context.Context, code currency.Pair, period string, size int64) (PremiumIndexKlineData, error) {\n\tvar resp PremiumIndexKlineData\n\tcodeValue, err := h.FormatSymbol(code, asset.CoinMarginedFutures)\n\tif err != nil {\n\t\treturn resp, err\n\t}\n\tif !common.StringDataCompareInsensitive(validPeriods, period) {\n\t\treturn resp, fmt.Errorf(\"invalid period value received\")\n\t}\n\tif size <= 0 || size > 1200 {\n\t\treturn resp, fmt.Errorf(\"invalid size provided, only values between 1-1200 are supported\")\n\t}\n\tparams := url.Values{}\n\tparams.Set(\"contract_code\", codeValue)\n\tparams.Set(\"size\", strconv.FormatInt(size, 10))\n\tparams.Set(\"period\", period)\n\tpath := common.EncodeURLValues(huobiPremiumIndexKlineData, params)\n\treturn resp, h.SendHTTPRequest(ctx, exchange.RestFutures, path, &resp)\n}", "func (r *PurchaseInvoicePurchaseInvoiceLinesCollectionRequest) Get(ctx context.Context) ([]PurchaseInvoiceLine, error) {\n\treturn r.GetN(ctx, 0)\n}", "func (h *HitBTC) GetTrades(ctx context.Context, currencyPair, by, sort string, from, till, limit, offset int64) ([]TradeHistory, error) {\n\turlValues := url.Values{}\n\tif from > 0 {\n\t\turlValues.Set(\"from\", strconv.FormatInt(from, 10))\n\t}\n\tif till > 0 {\n\t\turlValues.Set(\"till\", strconv.FormatInt(till, 10))\n\t}\n\tif limit > 0 {\n\t\turlValues.Set(\"limit\", strconv.FormatInt(limit, 10))\n\t}\n\tif offset > 0 {\n\t\turlValues.Set(\"offset\", strconv.FormatInt(offset, 10))\n\t}\n\tif by != \"\" {\n\t\turlValues.Set(\"by\", by)\n\t}\n\tif sort != \"\" {\n\t\turlValues.Set(\"sort\", sort)\n\t}\n\n\tvar resp []TradeHistory\n\tpath := fmt.Sprintf(\"/%s/%s?%s\",\n\t\tapiV2Trades,\n\t\tcurrencyPair,\n\t\turlValues.Encode())\n\treturn resp, h.SendHTTPRequest(ctx, exchange.RestSpot, path, &resp)\n}", "func (r *CompanyPurchaseInvoiceLinesCollectionRequest) Get(ctx context.Context) ([]PurchaseInvoiceLine, error) {\n\treturn r.GetN(ctx, 0)\n}" ]
[ "0.68609995", "0.65995353", "0.6500681", "0.64912534", "0.6234428", "0.61746275", "0.59557045", "0.5936131", "0.57153326", "0.5679661", "0.5676476", "0.5650398", "0.5535924", "0.54672873", "0.5415281", "0.54126996", "0.53202903", "0.50902885", "0.5074176", "0.50497234", "0.5027432", "0.50243413", "0.49523446", "0.49501762", "0.49493238", "0.49391708", "0.49337053", "0.48293898", "0.48092264", "0.47981837", "0.4794064", "0.47726515", "0.47665986", "0.47665986", "0.47650564", "0.4762492", "0.4759401", "0.47437078", "0.47257715", "0.4723072", "0.46952456", "0.4639272", "0.46250278", "0.46177113", "0.46112898", "0.4606508", "0.45832145", "0.45701557", "0.45654804", "0.4564877", "0.45575708", "0.45565143", "0.45423302", "0.45341596", "0.4528511", "0.45274654", "0.44934064", "0.44900212", "0.44880617", "0.44833475", "0.4482145", "0.448034", "0.44791502", "0.4477265", "0.4470819", "0.44633952", "0.4457804", "0.44493365", "0.44470245", "0.44436523", "0.4440135", "0.4439857", "0.44314152", "0.44305053", "0.4429722", "0.4428014", "0.44266093", "0.44255674", "0.4413851", "0.44132745", "0.44095483", "0.4408928", "0.440677", "0.44036758", "0.4400558", "0.43996924", "0.43981504", "0.4394929", "0.43939745", "0.4382519", "0.43790576", "0.43781793", "0.43722335", "0.436714", "0.4364852", "0.43624064", "0.435997", "0.43570018", "0.43535337", "0.43522537" ]
0.64874977
4
NewProvider is redirect hook for fabric/fsblkstorage NewProvider()
func NewProvider(conf *blkstorage.Conf, indexConfig *blkstorage.IndexConfig, _ *ledger.Config, metricsProvider metrics.Provider) (extledgerapi.BlockStoreProvider, error) { return blkstorage.NewProvider(conf, indexConfig, metricsProvider) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewProvider(conf *fsblkstorage.Conf, indexConfig *blkstorage.IndexConfig, ledgerconfig *ledger.Config, metricsProvider metrics.Provider) (blkstorage.BlockStoreProvider, error) {\n\treturn cdbblkstorage.NewProvider(indexConfig, ledgerconfig)\n}", "func NewProvider(net network.StorageMarketNetwork,\n\tds datastore.Batching,\n\tfs filestore.FileStore,\n\tdagStore stores.DAGStoreWrapper,\n\tindexer provider.Interface,\n\tpieceStore piecestore.PieceStore,\n\tdataTransfer datatransfer.Manager,\n\tspn storagemarket.StorageProviderNode,\n\tminerAddress address.Address,\n\tstoredAsk StoredAsk,\n\tmeshCreator MeshCreator,\n\toptions ...StorageProviderOption,\n) (storagemarket.StorageProvider, error) {\n\th := &Provider{\n\t\tnet: net,\n\t\tmeshCreator: meshCreator,\n\t\tspn: spn,\n\t\tfs: fs,\n\t\tpieceStore: pieceStore,\n\t\tconns: connmanager.NewConnManager(),\n\t\tstoredAsk: storedAsk,\n\t\tactor: minerAddress,\n\t\tdataTransfer: dataTransfer,\n\t\tpubSub: pubsub.New(providerDispatcher),\n\t\treadyMgr: shared.NewReadyManager(),\n\t\tdagStore: dagStore,\n\t\tstores: stores.NewReadWriteBlockstores(),\n\t\tawaitTransferRestartTimeout: defaultAwaitRestartTimeout,\n\t\tindexProvider: indexer,\n\t\tmetadataForDeal: defaultMetadataFunc,\n\t}\n\tstorageMigrations, err := migrations.ProviderMigrations.Build()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\th.deals, h.migrateDeals, err = newProviderStateMachine(\n\t\tds,\n\t\t&providerDealEnvironment{h},\n\t\th.dispatch,\n\t\tstorageMigrations,\n\t\tversioning.VersionKey(\"2\"),\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\th.Configure(options...)\n\n\t// register a data transfer event handler -- this will send events to the state machines based on DT events\n\th.unsubDataTransfer = dataTransfer.SubscribeToEvents(dtutils.ProviderDataTransferSubscriber(h.deals))\n\n\tpph := &providerPushDeals{h}\n\terr = dataTransfer.RegisterVoucherType(requestvalidation.StorageDataTransferVoucherType, requestvalidation.NewUnifiedRequestValidator(pph, nil))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = dataTransfer.RegisterTransportConfigurer(requestvalidation.StorageDataTransferVoucherType, dtutils.TransportConfigurer(&providerStoreGetter{h}))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn h, nil\n}", "func providerFactory(_ io.Reader) (cloudprovider.Interface, error) {\n\tlog := klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog))\n\tc, err := loadConfig(envconfig.OsLookuper())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tapiUrl := katapult.DefaultURL\n\tif c.APIHost != \"\" {\n\t\tlog.Info(\"default API base URL overrided\",\n\t\t\t\"url\", c.APIHost)\n\t\tapiUrl, err = url.Parse(c.APIHost)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to parse provided api url: %w\", err)\n\t\t}\n\t}\n\n\trm, err := katapult.New(\n\t\tkatapult.WithAPIKey(c.APIKey),\n\t\tkatapult.WithBaseURL(apiUrl),\n\t\tkatapult.WithUserAgent(\"kce-ccm\"), // TODO: Add version.\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient := core.New(rm)\n\n\treturn &provider{\n\t\tlog: log,\n\t\tkatapult: client,\n\t\tconfig: *c,\n\t\tloadBalancer: &loadBalancerManager{\n\t\t\tlog: log,\n\t\t\tconfig: *c,\n\t\t\tloadBalancerController: client.LoadBalancers,\n\t\t\tloadBalancerRuleController: client.LoadBalancerRules,\n\t\t},\n\t}, nil\n}", "func NewProvider() (rootfs.Provider, error) {\n\treturn &provider{}, nil\n}", "func returnFsProvider(ctor *ConstructSecret) *provider {\n\tprov := getFsProvider(ctor)\n\treturn &provider{\n\t\tSecret: prov,\n\t\tlogger: prov.logger,\n\t\tprovider: \"go-home\",\n\t}\n}", "func provider(r bot.Handler, _ *log.Logger) bot.SimpleBrain {\n\trobot = r\n\trobot.GetBrainConfig(&fb)\n\tif len(fb.BrainDirectory) == 0 {\n\t\trobot.Log(bot.Fatal, \"BrainConfig missing value for BrainDirectory required by 'file' brain\")\n\t}\n\tbrainPath = fb.BrainDirectory\n\tbd, err := os.Stat(brainPath)\n\tif err != nil {\n\t\trobot.Log(bot.Fatal, \"Checking brain directory \\\"%s\\\": %v\", brainPath, err)\n\t}\n\tif !bd.Mode().IsDir() {\n\t\trobot.Log(bot.Fatal, \"Checking brain directory: \\\"%s\\\" isn't a directory\", brainPath)\n\t}\n\trobot.Log(bot.Info, \"Initialized file-backed brain with memories directory: '%s'\", brainPath)\n\treturn &fb\n}", "func Provide.FindProviders(RecordStore.Store, Blocks.Key) (<-Net.ID, error) {}", "func providerFactory(meta *providercache.CachedProvider) providers.Factory {\n\treturn func() (providers.Interface, error) {\n\t\texecFile, err := meta.ExecutableFile()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tconfig := &plugin.ClientConfig{\n\t\t\tHandshakeConfig: tfplugin.Handshake,\n\t\t\tLogger: logging.NewProviderLogger(\"\"),\n\t\t\tAllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},\n\t\t\tManaged: true,\n\t\t\tCmd: exec.Command(execFile),\n\t\t\tAutoMTLS: enableProviderAutoMTLS,\n\t\t\tVersionedPlugins: tfplugin.VersionedPlugins,\n\t\t\tSyncStdout: logging.PluginOutputMonitor(fmt.Sprintf(\"%s:stdout\", meta.Provider)),\n\t\t\tSyncStderr: logging.PluginOutputMonitor(fmt.Sprintf(\"%s:stderr\", meta.Provider)),\n\t\t}\n\n\t\tclient := plugin.NewClient(config)\n\t\trpcClient, err := client.Client()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\traw, err := rpcClient.Dispense(tfplugin.ProviderPluginName)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// store the client so that the plugin can kill the child process\n\t\tprotoVer := client.NegotiatedVersion()\n\t\tswitch protoVer {\n\t\tcase 5:\n\t\t\tp := raw.(*tfplugin.GRPCProvider)\n\t\t\tp.PluginClient = client\n\t\t\treturn p, nil\n\t\tcase 6:\n\t\t\tp := raw.(*tfplugin6.GRPCProvider)\n\t\t\tp.PluginClient = client\n\t\t\treturn p, nil\n\t\tdefault:\n\t\t\tpanic(\"unsupported protocol version\")\n\t\t}\n\t}\n}", "func NewProvider(c Config) (checkpoint.Provider, func() error, error) {\n\tvar err error\n\tcachePath, mountPath := path.Join(defaultCCFSRoot, \"cache\"), path.Join(defaultCCFSRoot, \"mountpoint\")\n\tif c.CacheDirectory != \"\" {\n\t\tcachePath = c.CacheDirectory\n\t} else {\n\t\tc.CacheDirectory = cachePath\n\t}\n\tif c.Exec == \"\" {\n\t\tc.Exec = \"ccfs\"\n\t}\n\tif err = unix.Unmount(mountPath, unix.MNT_DETACH); err != nil && err != syscall.EINVAL && err != syscall.ENOENT {\n\t\treturn nil, nil, errors.Wrap(err, \"failed to umount ccfs\")\n\t}\n\tif err = os.MkdirAll(cachePath, 0644); err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif err = os.MkdirAll(mountPath, 0644); err != nil {\n\t\treturn nil, nil, err\n\t}\n\tvar done func() error\n\tif done, err = mountCCFS(mountPath, c); err != nil {\n\t\treturn nil, nil, errors.Wrap(err, \"failed to mount ccfs\")\n\t}\n\tp := &provider{\n\t\tmountpoint: mountPath,\n\t\trefs: map[string]int{},\n\t\tlastRefs: map[string]int{},\n\t\tconfig: c,\n\t}\n\tgo p.scan()\n\treturn p, done, nil\n}", "func newProviderImpl(name string) (Provider, error) {\n\tif name == LOCAL {\n\t\treturn &LocalProvider{}, nil\n\t}\n\n\tif name == AWS {\n\t\treturn &AwsProvider{}, nil\n\t}\n\n\treturn nil, errors.New(fmt.Sprintf(\"Provider '%s' doesn't exist\", name))\n}", "func NewProvider(conf *pvtdatastorage.PrivateDataConfig, ledgerconfig *ledger.Config) (xstorageapi.PrivateDataProvider, error) {\n\tif config.GetPrivateDataStoreDBType() == config.CouchDBType {\n\t\tlogger.Info(\"Using CouchDB private data storage provider\")\n\n\t\treturn xpvtdatastorage.NewProvider(conf, ledgerconfig)\n\t}\n\n\tlogger.Info(\"Using default private data storage provider\")\n\n\treturn pvtdatastorage.NewProvider(conf)\n}", "func NewLegacyProvider(name string) Provider {\n\treturn Provider{\n\t\tType: name,\n\t\tNamespace: \"-\",\n\t\tHostname: \"registry.terraform.io\",\n\t}\n}", "func Provide.Provide(RecordStore.Store, Blocks.Key, Net.Host) error {}", "func NewProvider() *ProviderConfig {\n\tproviderConfig := &ProviderConfig{\n\t\tAlibaba: make(map[string]*models.AlibabaCloudSpec),\n\t\tAnexia: make(map[string]*models.AnexiaCloudSpec),\n\t\tAws: make(map[string]*models.AWSCloudSpec),\n\t\tAzure: make(map[string]*models.AzureCloudSpec),\n\t\tDigitalocean: make(map[string]*models.DigitaloceanCloudSpec),\n\t\tFake: make(map[string]*models.FakeCloudSpec),\n\t\tGcp: make(map[string]*models.GCPCloudSpec),\n\t\tHetzner: make(map[string]*models.HetznerCloudSpec),\n\t\tKubevirt: make(map[string]*models.KubevirtCloudSpec),\n\t\tOpenstack: make(map[string]*models.OpenstackCloudSpec),\n\t\tPacket: make(map[string]*models.PacketCloudSpec),\n\t\tVsphere: make(map[string]*models.VSphereCloudSpec),\n\t}\n\n\tproviderConfig.Alibaba[\"Alibaba\"] = newAlibabaCloudSpec()\n\tproviderConfig.Anexia[\"Anexia\"] = newAnexiaCloudSpec()\n\tproviderConfig.Aws[\"Aws\"] = newAWSCloudSpec()\n\tproviderConfig.Azure[\"Azure\"] = newAzureCloudSpec()\n\tproviderConfig.Digitalocean[\"Digitalocean\"] = newDigitaloceanCloudSpec()\n\tproviderConfig.Fake[\"Fake\"] = newFakeCloudSpec()\n\tproviderConfig.Gcp[\"Gcp\"] = newGCPCloudSpec()\n\tproviderConfig.Hetzner[\"Hetzner\"] = newHetznerCloudSpec()\n\tproviderConfig.Kubevirt[\"Kubevirt\"] = newKubevirtCloudSpec()\n\tproviderConfig.Openstack[\"Openstack\"] = newOpenstackCloudSpec()\n\tproviderConfig.Packet[\"Packet\"] = newPacketCloudSpec()\n\tproviderConfig.Vsphere[\"Vsphere\"] = newVSphereCloudSpec()\n\n\treturn providerConfig\n}", "func NewProvider() *extblockpublisher.Provider {\n\treturn extblockpublisher.NewProvider()\n}", "func newPluginProvider(pluginBinDir string, provider kubeletconfig.CredentialProvider) (*pluginProvider, error) {\n\tmediaType := \"application/json\"\n\tinfo, ok := runtime.SerializerInfoForMediaType(codecs.SupportedMediaTypes(), mediaType)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unsupported media type %q\", mediaType)\n\t}\n\n\tgv, ok := apiVersions[provider.APIVersion]\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"invalid apiVersion: %q\", provider.APIVersion)\n\t}\n\n\tclock := clock.RealClock{}\n\n\treturn &pluginProvider{\n\t\tclock: clock,\n\t\tmatchImages: provider.MatchImages,\n\t\tcache: cache.NewExpirationStore(cacheKeyFunc, &cacheExpirationPolicy{clock: clock}),\n\t\tdefaultCacheDuration: provider.DefaultCacheDuration.Duration,\n\t\tlastCachePurge: clock.Now(),\n\t\tplugin: &execPlugin{\n\t\t\tname: provider.Name,\n\t\t\tapiVersion: provider.APIVersion,\n\t\t\tencoder: codecs.EncoderForVersion(info.Serializer, gv),\n\t\t\tpluginBinDir: pluginBinDir,\n\t\t\targs: provider.Args,\n\t\t\tenvVars: provider.Env,\n\t\t\tenviron: os.Environ,\n\t\t},\n\t}, nil\n}", "func NewProvider(minerAddress address.Address,\n\tnode retrievalmarket.RetrievalProviderNode,\n\tsa retrievalmarket.SectorAccessor,\n\tnetwork rmnet.RetrievalMarketNetwork,\n\tpieceStore piecestore.PieceStore,\n\tdagStore stores.DAGStoreWrapper,\n\tdataTransfer datatransfer.Manager,\n\tds datastore.Batching,\n\tretrievalPricingFunc RetrievalPricingFunc,\n\topts ...RetrievalProviderOption,\n) (retrievalmarket.RetrievalProvider, error) {\n\n\tif retrievalPricingFunc == nil {\n\t\treturn nil, xerrors.New(\"retrievalPricingFunc is nil\")\n\t}\n\n\tp := &Provider{\n\t\tdataTransfer: dataTransfer,\n\t\tnode: node,\n\t\tsa: sa,\n\t\tnetwork: network,\n\t\tminerAddress: minerAddress,\n\t\tpieceStore: pieceStore,\n\t\tsubscribers: pubsub.New(providerDispatcher),\n\t\tsubQueryEvt: pubsub.New(queryEvtDispatcher),\n\t\treadyMgr: shared.NewReadyManager(),\n\t\tretrievalPricingFunc: retrievalPricingFunc,\n\t\tdagStore: dagStore,\n\t\tstores: stores.NewReadOnlyBlockstores(),\n\t}\n\n\taskStore, err := askstore.NewAskStore(namespace.Wrap(ds, datastore.NewKey(\"retrieval-ask\")), datastore.NewKey(\"latest\"))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tp.askStore = askStore\n\n\tretrievalMigrations, err := migrations.ProviderMigrations.Build()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tp.stateMachines, p.migrateStateMachines, err = versionedfsm.NewVersionedFSM(ds, fsm.Parameters{\n\t\tEnvironment: &providerDealEnvironment{p},\n\t\tStateType: retrievalmarket.ProviderDealState{},\n\t\tStateKeyField: \"Status\",\n\t\tEvents: providerstates.ProviderEvents,\n\t\tStateEntryFuncs: providerstates.ProviderStateEntryFuncs,\n\t\tFinalityStates: providerstates.ProviderFinalityStates,\n\t\tNotifier: p.notifySubscribers,\n\t\tOptions: fsm.Options{\n\t\t\tConsumeAllEventsBeforeEntryFuncs: true,\n\t\t},\n\t}, retrievalMigrations, \"2\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tp.Configure(opts...)\n\tp.requestValidator = requestvalidation.NewProviderRequestValidator(&providerValidationEnvironment{p})\n\ttransportConfigurer := dtutils.TransportConfigurer(network.ID(), &providerStoreGetter{p})\n\n\terr = p.dataTransfer.RegisterVoucherType(retrievalmarket.DealProposalType, p.requestValidator)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = p.dataTransfer.RegisterVoucherType(retrievalmarket.DealPaymentType, p.requestValidator)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\terr = p.dataTransfer.RegisterTransportConfigurer(retrievalmarket.DealProposalType, transportConfigurer)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tdataTransfer.SubscribeToEvents(dtutils.ProviderDataTransferSubscriber(p.stateMachines))\n\treturn p, nil\n}", "func unmanagedProviderFactory(provider addrs.Provider, reattach *plugin.ReattachConfig) providers.Factory {\n\treturn func() (providers.Interface, error) {\n\t\tconfig := &plugin.ClientConfig{\n\t\t\tHandshakeConfig: tfplugin.Handshake,\n\t\t\tLogger: logging.NewProviderLogger(\"unmanaged.\"),\n\t\t\tAllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},\n\t\t\tManaged: false,\n\t\t\tReattach: reattach,\n\t\t\tSyncStdout: logging.PluginOutputMonitor(fmt.Sprintf(\"%s:stdout\", provider)),\n\t\t\tSyncStderr: logging.PluginOutputMonitor(fmt.Sprintf(\"%s:stderr\", provider)),\n\t\t}\n\n\t\tif reattach.ProtocolVersion == 0 {\n\t\t\t// As of the 0.15 release, sdk.v2 doesn't include the protocol\n\t\t\t// version in the ReattachConfig (only recently added to\n\t\t\t// go-plugin), so client.NegotiatedVersion() always returns 0. We\n\t\t\t// assume that an unmanaged provider reporting protocol version 0 is\n\t\t\t// actually using proto v5 for backwards compatibility.\n\t\t\tif defaultPlugins, ok := tfplugin.VersionedPlugins[5]; ok {\n\t\t\t\tconfig.Plugins = defaultPlugins\n\t\t\t} else {\n\t\t\t\treturn nil, errors.New(\"no supported plugins for protocol 0\")\n\t\t\t}\n\t\t} else if plugins, ok := tfplugin.VersionedPlugins[reattach.ProtocolVersion]; !ok {\n\t\t\treturn nil, fmt.Errorf(\"no supported plugins for protocol %d\", reattach.ProtocolVersion)\n\t\t} else {\n\t\t\tconfig.Plugins = plugins\n\t\t}\n\n\t\tclient := plugin.NewClient(config)\n\t\trpcClient, err := client.Client()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\traw, err := rpcClient.Dispense(tfplugin.ProviderPluginName)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// store the client so that the plugin can kill the child process\n\t\tprotoVer := client.NegotiatedVersion()\n\t\tswitch protoVer {\n\t\tcase 0, 5:\n\t\t\t// As of the 0.15 release, sdk.v2 doesn't include the protocol\n\t\t\t// version in the ReattachConfig (only recently added to\n\t\t\t// go-plugin), so client.NegotiatedVersion() always returns 0. We\n\t\t\t// assume that an unmanaged provider reporting protocol version 0 is\n\t\t\t// actually using proto v5 for backwards compatibility.\n\t\t\tp := raw.(*tfplugin.GRPCProvider)\n\t\t\tp.PluginClient = client\n\t\t\treturn p, nil\n\t\tcase 6:\n\t\t\tp := raw.(*tfplugin6.GRPCProvider)\n\t\t\tp.PluginClient = client\n\t\t\treturn p, nil\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"unsupported protocol version %d\", protoVer)\n\t\t}\n\t}\n}", "func providerConfigure(d *schema.ResourceData) (interface{}, error) {\n\tif d.Get(\"url\") == nil {\n\t\treturn nil, fmt.Errorf(\"url cannot be nil\")\n\t}\n\n\tusername := d.Get(\"username\").(string)\n\tpassword := d.Get(\"password\").(string)\n\tapiKey := d.Get(\"api_key\").(string)\n\taccessToken := d.Get(\"access_token\").(string)\n\n\tlog.SetLogger(log.NewLogger(log.INFO, nil))\n\n\tvar client *http.Client\n\tdetails := auth.NewArtifactoryDetails()\n\n\turl := d.Get(\"url\").(string)\n\tif url[len(url)-1] != '/' {\n\t\turl += \"/\"\n\t}\n\tdetails.SetUrl(url)\n\n\tif username != \"\" && password != \"\" {\n\t\tdetails.SetUser(username)\n\t\tdetails.SetPassword(password)\n\t\ttp := transport.BasicAuth{\n\t\t\tUsername: username,\n\t\t\tPassword: password,\n\t\t}\n\t\tclient = tp.Client()\n\t} else if apiKey != \"\" {\n\t\tdetails.SetApiKey(apiKey)\n\t\ttp := &transport.ApiKeyAuth{\n\t\t\tApiKey: apiKey,\n\t\t}\n\t\tclient = tp.Client()\n\t} else if accessToken != \"\" {\n\t\tdetails.SetAccessToken(accessToken)\n\t\ttp := &transport.AccessTokenAuth{\n\t\t\tAccessToken: accessToken,\n\t\t}\n\t\tclient = tp.Client()\n\t} else {\n\t\treturn nil, fmt.Errorf(\"either [username, password] or [api_key] or [access_token] must be set to use provider\")\n\t}\n\n\tconfig, err := config.NewConfigBuilder().\n\t\tSetServiceDetails(details).\n\t\tSetDryRun(false).\n\t\tBuild()\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trtold, err := artifactoryold.NewClient(d.Get(\"url\").(string), client)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\trtnew, err := artifactorynew.New(&details, config)\n\n\tif err != nil {\n\t\treturn nil, err\n\t} else if _, resp, err := rtold.V1.System.Ping(context.Background()); err != nil {\n\t\treturn nil, err\n\t} else if resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"failed to ping server. Got %d\", resp.StatusCode)\n\t} else if _, err := rtnew.Ping(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tproductid := \"terraform-provider-artifactory/\" + ProviderVersion\n\tcommandid := \"Terraform/\" + version.Version\n\tusage.SendReportUsage(productid, commandid, rtnew)\n\n\trt := &ArtClient{\n\t\tArtOld: rtold,\n\t\tArtNew: rtnew,\n\t}\n\n\treturn rt, nil\n}", "func (scnb *SupplyChainNodeBuilder) Provider(provider proto.EntityDTO_EntityType, pType proto.Provider_ProviderType) *SupplyChainNodeBuilder {\n\tif scnb.err != nil {\n\t\treturn scnb\n\t}\n\tif hasTemplate := scnb.requireEntityTemplate(); !hasTemplate {\n\t\tscnb.err = fmt.Errorf(\"EntityTemplate is not found. Must set before call Provider().\")\n\t\treturn scnb\n\t}\n\n\tif pType == proto.Provider_LAYERED_OVER {\n\t\tmaxCardinality := int32(math.MaxInt32)\n\t\tminCardinality := int32(0)\n\t\tscnb.currentProvider = &proto.Provider{\n\t\t\tTemplateClass: &provider,\n\t\t\tProviderType: &pType,\n\t\t\tCardinalityMax: &maxCardinality,\n\t\t\tCardinalityMin: &minCardinality,\n\t\t}\n\t} else {\n\t\thostCardinality := int32(1)\n\t\tscnb.currentProvider = &proto.Provider{\n\t\t\tTemplateClass: &provider,\n\t\t\tProviderType: &pType,\n\t\t\tCardinalityMax: &hostCardinality,\n\t\t\tCardinalityMin: &hostCardinality,\n\t\t}\n\t}\n\n\treturn scnb\n}", "func Provider() tfbridge.ProviderInfo {\n\t// Instantiate the Terraform provider\n\tp := shimv2.NewProvider(xyz.Provider())\n\n\t// Create a Pulumi provider mapping\n\tprov := tfbridge.ProviderInfo{\n\t\tP: p,\n\t\tName: \"xyz\",\n\t\t// DisplayName is a way to be able to change the casing of the provider\n\t\t// name when being displayed on the Pulumi registry\n\t\tDisplayName: \"\",\n\t\t// The default publisher for all packages is Pulumi.\n\t\t// Change this to your personal name (or a company name) that you\n\t\t// would like to be shown in the Pulumi Registry if this package is published\n\t\t// there.\n\t\tPublisher: \"Pulumi\",\n\t\t// LogoURL is optional but useful to help identify your package in the Pulumi Registry\n\t\t// if this package is published there.\n\t\t//\n\t\t// You may host a logo on a domain you control or add an SVG logo for your package\n\t\t// in your repository and use the raw content URL for that file as your logo URL.\n\t\tLogoURL: \"\",\n\t\t// PluginDownloadURL is an optional URL used to download the Provider\n\t\t// for use in Pulumi programs\n\t\t// e.g https://github.com/org/pulumi-provider-name/releases/\n\t\tPluginDownloadURL: \"\",\n\t\tDescription: \"A Pulumi package for creating and managing xyz cloud resources.\",\n\t\t// category/cloud tag helps with categorizing the package in the Pulumi Registry.\n\t\t// For all available categories, see `Keywords` in\n\t\t// https://www.pulumi.com/docs/guides/pulumi-packages/schema/#package.\n\t\tKeywords: []string{\"pulumi\", \"xyz\", \"category/cloud\"},\n\t\tLicense: \"Apache-2.0\",\n\t\tHomepage: \"https://www.pulumi.com\",\n\t\tRepository: \"https://github.com/pulumi/pulumi-xyz\",\n\t\t// The GitHub Org for the provider - defaults to `terraform-providers`. Note that this\n\t\t// should match the TF provider module's require directive, not any replace directives.\n\t\tGitHubOrg: \"\",\n\t\tConfig: map[string]*tfbridge.SchemaInfo{\n\t\t\t// Add any required configuration here, or remove the example below if\n\t\t\t// no additional points are required.\n\t\t\t// \"region\": {\n\t\t\t// \tType: tfbridge.MakeType(\"region\", \"Region\"),\n\t\t\t// \tDefault: &tfbridge.DefaultInfo{\n\t\t\t// \t\tEnvVars: []string{\"AWS_REGION\", \"AWS_DEFAULT_REGION\"},\n\t\t\t// \t},\n\t\t\t// },\n\t\t},\n\t\tPreConfigureCallback: preConfigureCallback,\n\t\tResources: map[string]*tfbridge.ResourceInfo{\n\t\t\t// Map each resource in the Terraform provider to a Pulumi type. Two examples\n\t\t\t// are below - the single line form is the common case. The multi-line form is\n\t\t\t// needed only if you wish to override types or other default options.\n\t\t\t//\n\t\t\t// \"aws_iam_role\": {Tok: tfbridge.MakeResource(mainPkg, mainMod, \"IamRole\")}\n\t\t\t//\n\t\t\t// \"aws_acm_certificate\": {\n\t\t\t// \tTok: tfbridge.MakeResource(mainPkg, mainMod, \"Certificate\"),\n\t\t\t// \tFields: map[string]*tfbridge.SchemaInfo{\n\t\t\t// \t\t\"tags\": {Type: tfbridge.MakeType(mainPkg, \"Tags\")},\n\t\t\t// \t},\n\t\t\t// },\n\t\t},\n\t\tDataSources: map[string]*tfbridge.DataSourceInfo{\n\t\t\t// Map each resource in the Terraform provider to a Pulumi function. An example\n\t\t\t// is below.\n\t\t\t// \"aws_ami\": {Tok: tfbridge.MakeDataSource(mainPkg, mainMod, \"getAmi\")},\n\t\t},\n\t\tJavaScript: &tfbridge.JavaScriptInfo{\n\t\t\t// List any npm dependencies and their versions\n\t\t\tDependencies: map[string]string{\n\t\t\t\t\"@pulumi/pulumi\": \"^3.0.0\",\n\t\t\t},\n\t\t\tDevDependencies: map[string]string{\n\t\t\t\t\"@types/node\": \"^10.0.0\", // so we can access strongly typed node definitions.\n\t\t\t\t\"@types/mime\": \"^2.0.0\",\n\t\t\t},\n\t\t\t// See the documentation for tfbridge.OverlayInfo for how to lay out this\n\t\t\t// section, or refer to the AWS provider. Delete this section if there are\n\t\t\t// no overlay files.\n\t\t\t//Overlay: &tfbridge.OverlayInfo{},\n\t\t},\n\t\tPython: &tfbridge.PythonInfo{\n\t\t\t// List any Python dependencies and their version ranges\n\t\t\tRequires: map[string]string{\n\t\t\t\t\"pulumi\": \">=3.0.0,<4.0.0\",\n\t\t\t},\n\t\t},\n\t\tGolang: &tfbridge.GolangInfo{\n\t\t\tImportBasePath: filepath.Join(\n\t\t\t\tfmt.Sprintf(\"github.com/pulumi/pulumi-%[1]s/sdk/\", mainPkg),\n\t\t\t\ttfbridge.GetModuleMajorVersion(version.Version),\n\t\t\t\t\"go\",\n\t\t\t\tmainPkg,\n\t\t\t),\n\t\t\tGenerateResourceContainerTypes: true,\n\t\t},\n\t\tCSharp: &tfbridge.CSharpInfo{\n\t\t\tPackageReferences: map[string]string{\n\t\t\t\t\"Pulumi\": \"3.*\",\n\t\t\t},\n\t\t},\n\t}\n\n\t// These are new API's that you may opt to use to automatically compute resource tokens,\n\t// and apply auto aliasing for full backwards compatibility.\n\t// For more information, please reference: https://pkg.go.dev/github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge#ProviderInfo.ComputeTokens\n\tprov.MustComputeTokens(tokens.SingleModule(\"xyz_\", mainMod,\n\t\ttokens.MakeStandard(mainPkg)))\n\tprov.MustApplyAutoAliasing()\n\tprov.SetAutonaming(255, \"-\")\n\n\treturn prov\n}", "func getFsProvider(ctor *ConstructSecret) *fsSecret {\n\tsecretLoggerCtor := &logger.ConstructPluginLogger{\n\t\tSystemLogger: ctor.PluginLogger,\n\t\tProvider: \"go-home\",\n\t\tSystem: systems.SysSecret.String(),\n\t}\n\n\tsecretLogger := logger.NewPluginLogger(secretLoggerCtor)\n\tsecretLogger.Info(\"Using default File System secret\")\n\n\tdata := &secret.InitDataSecret{\n\t\tOptions: ctor.Options,\n\t\tLogger: secretLogger,\n\t}\n\n\ts := &fsSecret{}\n\ts.Init(data) // nolint: gosec, errcheck\n\treturn s\n}", "func newStorageLayer(disk string) (storage StorageAPI, err error) {\n\tif !strings.ContainsRune(disk, ':') || filepath.VolumeName(disk) != \"\" {\n\t\t// Initialize filesystem storage API.\n\t\treturn newPosix(disk)\n\t}\n\t// Initialize rpc client storage API.\n\treturn newRPCClient(disk)\n}", "func providerFactory(meta discovery.PluginMeta, loglevel hclog.Level) providers.Factory {\n\treturn func() (providers.Interface, error) {\n\t\tclient := goPlugin.NewClient(clientConfig(meta, loglevel))\n\t\t// Request the RPC client so we can get the provider\n\t\t// so we can build the actual RPC-implemented provider.\n\t\trpcClient, err := client.Client()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\traw, err := rpcClient.Dispense(plugin.ProviderPluginName)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// store the client so that the plugin can kill the child process\n\t\tp := raw.(*plugin.GRPCProvider)\n\t\tp.PluginClient = client\n\t\treturn p, nil\n\t}\n}", "func Provider() terraform.ResourceProvider {\n\treturn &schema.Provider{\n\t\tSchema: map[string]*schema.Schema{\n\t\t\t\"access_key\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefault: \"\",\n\t\t\t\tDescription: \"The access key for API operations.\",\n\t\t\t},\n\t\t\t\"secret_key\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefault: \"\",\n\t\t\t\tDescription: \"The secret key for API operations.\",\n\t\t\t},\n\t\t\t\"endpoint\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDescription: \"The endpoint for API operations.\",\n\t\t\t},\n\t\t\t\"region\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tRequired: true,\n\t\t\t\tDescription: \"The region where Nifcloud operations will take place.\",\n\t\t\t},\n\t\t},\n\n\t\tDataSourcesMap: map[string]*schema.Resource{\n\t\t\t// \"nifcloud_instance\": dataSourceInstance(),\n\t\t},\n\t\tResourcesMap: map[string]*schema.Resource{\n\t\t\t\"nifcloud_instance\": resourceNifcloudInstance(),\n\t\t\t\"nifcloud_network\": resourceNifcloudNetwork(),\n\t\t\t\"nifcloud_volume\": resourceNifcloudVolume(),\n\t\t\t\"nifcloud_securitygroup\": resourceNifcloudSecurityGroup(),\n\t\t\t\"nifcloud_securitygroup_rule\": resourceNifcloudSecurityGroupRule(),\n\t\t\t\"nifcloud_keypair\": resourceNifcloudKeyPair(),\n\t\t\t\"nifcloud_instancebackup_rule\": resourceNifcloudInstanceBackupRule(),\n\t\t\t\"nifcloud_image\": resourceNifcloudImage(),\n\t\t\t\"nifcloud_customer_gateway\": resourceNifcloudCustomerGateway(),\n\t\t\t\"nifcloud_vpn_gateway\": resourceNifcloudVpnGateway(),\n\t\t\t\"nifcloud_vpn_connection\": resourceNifcloudVpnConnection(),\n\t\t\t\"nifcloud_db_parameter_group\": resourceNifcloudDbParameterGroup(),\n\t\t\t\"nifcloud_db_security_group\": resourceNifcloudDbSecurityGroup(),\n\t\t\t\"nifcloud_db_instance\": resourceNifcloudDbInstance(),\n\t\t\t\"nifcloud_router\": resourceNifcloudRouter(),\n\t\t\t\"nifcloud_route_table\": resourceNifcloudRouteTable(),\n\t\t\t\"nifcloud_route\": resourceNifcloudRoute(),\n\t\t\t\"nifcloud_route_table_association\": resourceNifcloudRouteTableAssociation(),\n\t\t\t\"nifcloud_route_table_association_with_vpn_gateway\": resourceNifcloudRouteTableAssociationWithVpnGateway(),\n\t\t\t\"nifcloud_lb\": resourceNifcloudLb(),\n\t\t\t\"nifcloud_lb_port\": resourceNifcloudLbPort(),\n\t\t\t\"nifcloud_eip\": resourceNifcloudEip(),\n\t\t},\n\t\tConfigureFunc: providerConfigure,\n\t}\n}", "func NewBaseProvider(no *Options) Provider {\n\treturn &BaseProvider{\n\t\tNewActions(no),\n\t\tNewDuelLinks(no),\n\t\tNewMisc(no),\n\t}\n}", "func NewProvider(ptype int, config config.ProviderConfig) DataProvider {\n\tswitch ptype {\n\tcase FtpProv:\n\t\treturn NewFtpProvider(config.FtpConfig)\n\tcase FsProv:\n\t\treturn NewFileProvider()\n\tdefault:\n\t\tlog.Fatalf(\"No such provider: %d (%s)\", ptype, ProvTypeString(ptype))\n\t\treturn nil\n\t}\n}", "func NewProvider(conf *Conf) (*Provider, error) {\n\tdb, err := openDBAndCheckFormat(conf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &Provider{\n\t\tdb: db,\n\t\tdbHandles: make(map[string]*DBHandle),\n\t}, nil\n}", "func Provider() *Chain {\n\tc := &Chain{}\n\tc.Version = \"1.0\"\n\tc.CreationDate = time.Now()\n\treturn c\n}", "func getBlockStoreProvider(fsPath string) (*blkstorage.BlockStoreProvider, error) {\n\t// Format path to block store\n\tblockStorePath := kvledger.BlockStorePath(filepath.Join(fsPath, ledgersDataDirName))\n\tisEmpty, err := fileutil.DirEmpty(blockStorePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif isEmpty {\n\t\treturn nil, errors.Errorf(\"provided path %s is empty. Aborting identifytxs\", fsPath)\n\t}\n\t// Default fields for block store provider\n\tconf := blkstorage.NewConf(blockStorePath, 0)\n\tindexConfig := &blkstorage.IndexConfig{\n\t\tAttrsToIndex: []blkstorage.IndexableAttr{\n\t\t\tblkstorage.IndexableAttrBlockNum,\n\t\t\tblkstorage.IndexableAttrBlockHash,\n\t\t\tblkstorage.IndexableAttrTxID,\n\t\t\tblkstorage.IndexableAttrBlockNumTranNum,\n\t\t},\n\t}\n\tmetricsProvider := &disabled.Provider{}\n\t// Create new block store provider\n\tblockStoreProvider, err := blkstorage.NewProvider(conf, indexConfig, metricsProvider)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn blockStoreProvider, nil\n}", "func NewProvider(region string, profile string) (*clusterProvider, error) {\n\tsession, err := session.NewAwsSession(profile, region)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error obtaining a valid AWS session\")\n\t}\n\n\tservices := providerServices{}\n\n\tec2Options, err := ec2.NewEC2APIHandler(session)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error initializing the EC2 API\")\n\t}\n\tservices.ec2 = ec2Options\n\n\teksOptions, err := eks.NewEKSAPIHandler(session)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error initializing the EKS API\")\n\t}\n\tservices.eks = eksOptions\n\n\tservices.eksctl = eksctl.NewEksctlClient()\n\n\tservices.cli = awscli.NewAWSCli()\n\n\tprovider := &clusterProvider{\n\t\tproviderServices: services,\n\t\tRegion: region,\n\t\tProfile: profile,\n\t}\n\treturn provider, nil\n}", "func NewProvider(log logging.Logger) *Provider {\n\treturn &Provider{\n\t\tapi: &api{},\n\t\tlog: log,\n\t}\n}", "func (p *Provider) ProviderName() string {\n\treturn \"Filesystem\"\n}", "func (*provider) Pair(*kernel.Task, linux.SockType, int) (*vfs.FileDescription, *vfs.FileDescription, *syserr.Error) {\n\treturn nil, nil, nil\n}", "func provider(r bot.Handler) bot.HistoryProvider {\n\trobot = r\n\trobot.GetHistoryConfig(&fhc)\n\tif len(fhc.Directory) == 0 {\n\t\trobot.Log(bot.Fatal, \"HistoryConfig missing value for Directory required by 'file' history provider\")\n\t}\n\tif byte(fhc.Directory[0]) == byte(\"/\"[0]) {\n\t\thistoryPath = fhc.Directory\n\t} else {\n\t\thistoryPath = robot.GetConfigPath() + \"/\" + fhc.Directory\n\t}\n\thd, err := os.Stat(historyPath)\n\tif err != nil {\n\t\trobot.Log(bot.Fatal, fmt.Sprintf(\"Checking history directory '%s': %v\", historyPath, err))\n\t}\n\tif !hd.Mode().IsDir() {\n\t\trobot.Log(bot.Fatal, fmt.Sprintf(\"Checking history directory: '%s' isn't a directory\", historyPath))\n\t}\n\trobot.Log(bot.Info, fmt.Sprintf(\"Initialized file history provider with directory: '%s'\", historyPath))\n\treturn &fhc\n}", "func (c *FilecoinRetrievalProviderAdmin) InitialiseProvider(providerRegistrar register.ProviderRegistrar, providerPrivKey *fcrcrypto.KeyPair, providerPrivKeyVer *fcrcrypto.KeyVersion) error {\n\terr := c.AdminApiCaller.RequestInitialiseKey(providerRegistrar, providerPrivKey, providerPrivKeyVer, c.Settings.providerAdminPrivateKey, c.Settings.providerAdminPrivateKeyVer)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Add this provider to the active providers list\n\tc.ActiveProvidersLock.Lock()\n\tc.ActiveProviders[providerRegistrar.GetNodeID()] = providerRegistrar\n\tc.ActiveProvidersLock.Unlock()\n\treturn nil\n}", "func Provider() terraform.ResourceProvider {\n\treturn &schema.Provider{\n\t\tSchema: map[string]*schema.Schema{\n\n\t\t\t\"ip\": &schema.Schema{\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tRequired: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"VCD_IP\", nil),\n\t\t\t\tDescription: \"The vcd IP for vcd API operations.\",\n\t\t\t},\n\n\t\t\t\"user\": &schema.Schema{\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"VCD_USER\", nil),\n\t\t\t\tDescription: \"The user name for vcd API operations.\",\n\t\t\t},\n\n\t\t\t\"password\": &schema.Schema{\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"VCD_PASSWORD\", nil),\n\t\t\t\tDescription: \"The user password for vcd API operations.\",\n\t\t\t},\n\n\t\t\t\"org\": &schema.Schema{\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"VCD_ORG\", nil),\n\t\t\t\tDescription: \"The vcd org for API operations\",\n\t\t\t},\n\n\t\t\t\"use_vcd_cli_profile\": &schema.Schema{\n\t\t\t\tType: schema.TypeBool,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"VCD_USE_VCD_CLI_PROFILE\", false),\n\t\t\t\tDescription: \"If set, VCDClient will use vcd cli profile and token .\",\n\t\t\t},\n\n\t\t\t\"allow_unverified_ssl\": &schema.Schema{\n\t\t\t\tType: schema.TypeBool,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"VCD_ALLOW_UNVERIFIED_SSL\", false),\n\t\t\t\tDescription: \"If set, VCDClient will permit unverifiable SSL certificates.\",\n\t\t\t},\n\t\t},\n\n\t\tResourcesMap: map[string]*schema.Resource{\n\n\t\t\t\"vcloud-director_catalog\": resourceCatalog(),\n\t\t\t\"vcloud-director_catalog_item_media\": resourceCatalogItemMedia(),\n\t\t\t\"vcloud-director_catalog_item_ova\": resourceCatalogItemOva(),\n\t\t\t\"vcloud-director_vapp\": resourceVApp(),\n\t\t\t\"vcloud-director_independent_disk\": resourceIndependentDisk(),\n\t\t\t\"vcloud-director_org\": resourceOrg(),\n\t\t\t\"vcloud-director_disk\": resourceIndependentDisk(),\n\t\t\t\"vcloud-director_user\": resourceUser(),\n\t\t\t\"vcloud-director_vdc\": resourceVdc(),\n\t\t\t\"vcloud-director_vapp_vm\": resourceVappVm(),\n\t\t},\n\n\t\tConfigureFunc: providerConfigure,\n\t}\n}", "func SetupProvider(mgr ctrl.Manager, o controller.Options) error {\n\tname := \"packages/\" + strings.ToLower(v1.ProviderGroupKind)\n\tnp := func() v1.Package { return &v1.Provider{} }\n\tnr := func() v1.PackageRevision { return &v1.ProviderRevision{} }\n\tnrl := func() v1.PackageRevisionList { return &v1.ProviderRevisionList{} }\n\n\tcs, err := kubernetes.NewForConfig(mgr.GetConfig())\n\tif err != nil {\n\t\treturn errors.Wrap(err, errCreateK8sClient)\n\t}\n\tf, err := xpkg.NewK8sFetcher(cs, append(o.FetcherOptions, xpkg.WithNamespace(o.Namespace), xpkg.WithServiceAccount(o.ServiceAccount))...)\n\tif err != nil {\n\t\treturn errors.Wrap(err, errBuildFetcher)\n\t}\n\n\topts := []ReconcilerOption{\n\t\tWithNewPackageFn(np),\n\t\tWithNewPackageRevisionFn(nr),\n\t\tWithNewPackageRevisionListFn(nrl),\n\t\tWithRevisioner(NewPackageRevisioner(f, WithDefaultRegistry(o.DefaultRegistry))),\n\t\tWithLogger(o.Logger.WithValues(\"controller\", name)),\n\t\tWithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))),\n\t}\n\tif o.WebhookTLSSecretName != \"\" {\n\t\topts = append(opts, WithWebhookTLSSecretName(o.WebhookTLSSecretName))\n\t}\n\tif o.ESSOptions != nil && o.ESSOptions.TLSSecretName != nil {\n\t\topts = append(opts, WithESSTLSSecretName(o.ESSOptions.TLSSecretName))\n\t}\n\tif o.TLSServerSecretName != \"\" {\n\t\topts = append(opts, WithTLSServerSecretName(&o.TLSServerSecretName))\n\t}\n\tif o.TLSClientSecretName != \"\" {\n\t\topts = append(opts, WithTLSClientSecretName(&o.TLSClientSecretName))\n\t}\n\n\treturn ctrl.NewControllerManagedBy(mgr).\n\t\tNamed(name).\n\t\tFor(&v1.Provider{}).\n\t\tOwns(&v1.ProviderRevision{}).\n\t\tWithOptions(o.ForControllerRuntime()).\n\t\tComplete(ratelimiter.NewReconciler(name, NewReconciler(mgr, opts...), o.GlobalRateLimiter))\n}", "func newBlockfileMgr(id string, conf *Conf, indexConfig *blkstorage.IndexConfig, indexStore *leveldbhelper.DBHandle) *blockfileMgr {\n\tlogger.Debugf(\"newBlockfileMgr() initializing file-based block storage for ledger: %s \", id)\n\tvar rwMutexs []*sync.RWMutex\n\n\t//Determine the root directory for the blockfile storage, if it does not exist create it\n\trootDir := conf.getLedgerBlockDir(id)\n\t_, err := util.CreateDirIfMissing(rootDir)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Error: %s\", err))\n\t}\n\t// Instantiate the manager, i.e. blockFileMgr structure\n\tmgr := &blockfileMgr{rootDir: rootDir, conf: conf, db: indexStore, rwMutexs: rwMutexs}\n\n\t// cp = checkpointInfo, retrieve from the database the file suffix or number of where blocks were stored.\n\t// It also retrieves the current size of that file and the last block number that was written to that file.\n\t// At init checkpointInfo:latestFileChunkSuffixNum=[0], latestFileChunksize=[0], lastBlockNumber=[0]\n\tcpInfo, err := mgr.loadCurrentInfo()\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not get block file info for current block file from db: %s\", err))\n\t}\n\tif cpInfo == nil {\n\t\tlogger.Info(`Getting block information from block storage`)\n\t\tif cpInfo, err = constructCheckpointInfoFromBlockFiles(rootDir); err != nil {\n\t\t\tpanic(fmt.Sprintf(\"Could not build checkpoint info from block files: %s\", err))\n\t\t}\n\t\tlogger.Debugf(\"Info constructed by scanning the blocks dir = %s\", spew.Sdump(cpInfo))\n\t} else {\n\t\tlogger.Debug(`Synching block information from block storage (if needed)`)\n\t\tsyncCPInfoFromFS(rootDir, cpInfo)\n\t}\n\terr = mgr.saveCurrentInfo(cpInfo, true)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not save next block file info to db: %s\", err))\n\t}\n\n\tmgr.oldestFileChunkSuffixNum = syncOldestFileNum(rootDir)\n\t//If start up is a restart of an existing storage,new the rwMutex for the files\n\tif conf.dumpConf.Enabled {\n\t\tfor i := 0; i <= cpInfo.latestFileChunkSuffixNum; i++ {\n\t\t\trwMutex := new(sync.RWMutex)\n\t\t\tmgr.rwMutexs = append(mgr.rwMutexs, rwMutex)\n\t\t}\n\t}\n\tmgr.dumpMutex = new(sync.Mutex)\n\n\t//Open a writer to the file identified by the number and truncate it to only contain the latest block\n\t// that was completely saved (file system, index, cpinfo, etc)\n\tcurrentFileWriter, err := newBlockfileWriter(deriveBlockfilePath(rootDir, cpInfo.latestFileChunkSuffixNum))\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not open writer to current file: %s\", err))\n\t}\n\t//Truncate the file to remove excess past last block\n\terr = currentFileWriter.truncateFile(cpInfo.latestFileChunksize)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not truncate current file to known size in db: %s\", err))\n\t}\n\n\t// Create a new KeyValue store database handler for the blocks index in the keyvalue database\n\tmgr.index = newBlockIndex(indexConfig, indexStore)\n\n\t// Update the manager with the checkpoint info and the file writer\n\tmgr.cpInfo = cpInfo\n\tmgr.currentFileWriter = currentFileWriter\n\t// Create a checkpoint condition (event) variable, for the goroutine waiting for\n\t// or announcing the occurrence of an event.\n\tmgr.cpInfoCond = sync.NewCond(&sync.Mutex{})\n\n\t// init BlockchainInfo for external API's\n\tbcInfo := &common.BlockchainInfo{\n\t\tHeight: 0,\n\t\tCurrentBlockHash: nil,\n\t\tPreviousBlockHash: nil}\n\n\tif !cpInfo.isChainEmpty {\n\t\t//If start up is a restart of an existing storage, sync the index from block storage and update BlockchainInfo for external API's\n\t\tmgr.syncIndex()\n\t\tlastBlockHeader, err := mgr.retrieveBlockHeaderByNumber(cpInfo.lastBlockNumber)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"Could not retrieve header of the last block form file: %s\", err))\n\t\t}\n\t\tlastBlockHash := lastBlockHeader.Hash()\n\t\tpreviousBlockHash := lastBlockHeader.PreviousHash\n\t\tbcInfo = &common.BlockchainInfo{\n\t\t\tHeight: cpInfo.lastBlockNumber + 1,\n\t\t\tCurrentBlockHash: lastBlockHash,\n\t\t\tPreviousBlockHash: previousBlockHash}\n\t}\n\tmgr.bcInfo.Store(bcInfo)\n\treturn mgr\n}", "func NewProvider(ctx *pulumi.Context,\n\tname string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) {\n\tif args == nil {\n\t\targs = &ProviderArgs{}\n\t}\n\tif args.AllowUnverifiedSsl == nil {\n\t\targs.AllowUnverifiedSsl = pulumi.BoolPtr(getEnvOrDefault(false, parseEnvBool, \"VSPHERE_ALLOW_UNVERIFIED_SSL\").(bool))\n\t}\n\tif args.ClientDebug == nil {\n\t\targs.ClientDebug = pulumi.BoolPtr(getEnvOrDefault(false, parseEnvBool, \"VSPHERE_CLIENT_DEBUG\").(bool))\n\t}\n\tif args.ClientDebugPath == nil {\n\t\targs.ClientDebugPath = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"VSPHERE_CLIENT_DEBUG_PATH\").(string))\n\t}\n\tif args.ClientDebugPathRun == nil {\n\t\targs.ClientDebugPathRun = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"VSPHERE_CLIENT_DEBUG_PATH_RUN\").(string))\n\t}\n\tif args.Password == nil {\n\t\targs.Password = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"VSPHERE_PASSWORD\").(string))\n\t}\n\tif args.PersistSession == nil {\n\t\targs.PersistSession = pulumi.BoolPtr(getEnvOrDefault(false, parseEnvBool, \"VSPHERE_PERSIST_SESSION\").(bool))\n\t}\n\tif args.RestSessionPath == nil {\n\t\targs.RestSessionPath = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"VSPHERE_REST_SESSION_PATH\").(string))\n\t}\n\tif args.User == nil {\n\t\targs.User = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"VSPHERE_USER\").(string))\n\t}\n\tif args.VimKeepAlive == nil {\n\t\targs.VimKeepAlive = pulumi.IntPtr(getEnvOrDefault(0, parseEnvInt, \"VSPHERE_VIM_KEEP_ALIVE\").(int))\n\t}\n\tif args.VimSessionPath == nil {\n\t\targs.VimSessionPath = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"VSPHERE_VIM_SESSION_PATH\").(string))\n\t}\n\tif args.VsphereServer == nil {\n\t\targs.VsphereServer = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"VSPHERE_SERVER\").(string))\n\t}\n\tvar resource Provider\n\terr := ctx.RegisterResource(\"pulumi:providers:vsphere\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewProvider(ctx *pulumi.Context,\n\tname string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) {\n\tif args == nil {\n\t\targs = &ProviderArgs{}\n\t}\n\n\tif args.ApiClientLogging == nil {\n\t\tif d := internal.GetEnvOrDefault(false, internal.ParseEnvBool, \"CLOUDFLARE_API_CLIENT_LOGGING\"); d != nil {\n\t\t\targs.ApiClientLogging = pulumi.BoolPtr(d.(bool))\n\t\t}\n\t}\n\tif args.MaxBackoff == nil {\n\t\tif d := internal.GetEnvOrDefault(30, internal.ParseEnvInt, \"CLOUDFLARE_MAX_BACKOFF\"); d != nil {\n\t\t\targs.MaxBackoff = pulumi.IntPtr(d.(int))\n\t\t}\n\t}\n\tif args.MinBackoff == nil {\n\t\tif d := internal.GetEnvOrDefault(1, internal.ParseEnvInt, \"CLOUDFLARE_MIN_BACKOFF\"); d != nil {\n\t\t\targs.MinBackoff = pulumi.IntPtr(d.(int))\n\t\t}\n\t}\n\tif args.Retries == nil {\n\t\tif d := internal.GetEnvOrDefault(3, internal.ParseEnvInt, \"CLOUDFLARE_RETRIES\"); d != nil {\n\t\t\targs.Retries = pulumi.IntPtr(d.(int))\n\t\t}\n\t}\n\tif args.Rps == nil {\n\t\tif d := internal.GetEnvOrDefault(4, internal.ParseEnvInt, \"CLOUDFLARE_RPS\"); d != nil {\n\t\t\targs.Rps = pulumi.IntPtr(d.(int))\n\t\t}\n\t}\n\topts = internal.PkgResourceDefaultOpts(opts)\n\tvar resource Provider\n\terr := ctx.RegisterResource(\"pulumi:providers:cloudflare\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func (mdhth *MockDHTHandler) Provider(string, bool) error {\n\treturn nil\n}", "func (o *ProviderParams) bindProvider(rawData []string, hasKey bool, formats strfmt.Registry) error {\n\tvar raw string\n\tif len(rawData) > 0 {\n\t\traw = rawData[len(rawData)-1]\n\t}\n\n\t// Required: true\n\t// Parameter is provided by construction from the route\n\n\to.Provider = raw\n\n\treturn nil\n}", "func (f *Factory) New(providerConf digitalocean.Config, clusterState *cluster.State) (provider.Activity, error) {\n\tk8s := &K8s{}\n\tk8s.moduleDir = filepath.Join(config.Global.ProjectRoot, \"terraform/digitalocean/\"+myName)\n\tk8s.backendKey = \"states/terraform-\" + myName + \".state\"\n\tk8s.backendConf = digitalocean.BackendSpec{\n\t\tBucket: providerConf.ClusterName,\n\t\tKey: k8s.backendKey,\n\t\tEndpoint: providerConf.Region + \".digitaloceanspaces.com\",\n\t}\n\trawProvisionerData, err := yaml.Marshal(providerConf.Provisioner)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error occurret while marshal provisioner config: %s\", err.Error())\n\t}\n\tif err = yaml.Unmarshal(rawProvisionerData, &k8s.config); err != nil {\n\t\treturn nil, fmt.Errorf(\"error occurret while parsing provisioner config: %s\", err.Error())\n\t}\n\n\tk8s.config.ClusterName = providerConf.ClusterName\n\tk8s.config.Region = providerConf.Region\n\n\tk8s.terraform, err = executor.NewTerraformRunner(k8s.moduleDir, provisioner.GetAwsAuthEnv()...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tk8s.terraform.LogLabels = append(k8s.terraform.LogLabels, fmt.Sprintf(\"cluster='%s'\", providerConf.ClusterName))\n\treturn k8s, nil\n}", "func newStorage(account *account, prov provider.Account, cfg *config.Storage) (*storage, error) {\n\tlog.Debug(\"Initializing Storage\")\n\n\t// Validate the config.Storage object.\n\tif cfg.Buckets == nil {\n\t\treturn nil, fmt.Errorf(\"The buckets element is missing from the storage configuration\")\n\t}\n\n\ts := &storage{\n\t\tResources: resource.NewResources(),\n\t\tStorage: cfg,\n\t\taccount: account,\n\t}\n\n\tvar err error\n\ts.providerStorage, err = prov.NewStorage(cfg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ts.buckets, err = newBuckets(s, prov, cfg.Buckets)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts.Append(s.buckets)\n\treturn s, nil\n}", "func Provider() tfbridge.ProviderInfo {\n\t// Instantiate the Terraform provider\n\tp := shimv2.NewProvider(shim.NewProvider())\n\n\t// Create a Pulumi provider mapping\n\tprov := tfbridge.ProviderInfo{\n\t\tP: p,\n\t\tName: \"azuread\",\n\t\tDisplayName: \"Azure Active Directory (Azure AD)\",\n\t\tDescription: \"A Pulumi package for creating and managing Azure Active Directory (Azure AD) cloud resources.\",\n\t\tKeywords: []string{\"pulumi\", \"azuread\"},\n\t\tLicense: \"Apache-2.0\",\n\t\tHomepage: \"https://pulumi.io\",\n\t\tGitHubOrg: \"hashicorp\",\n\t\tRepository: \"https://github.com/pulumi/pulumi-azuread\",\n\t\tConfig: map[string]*tfbridge.SchemaInfo{\n\t\t\t\"environment\": {\n\t\t\t\tDefault: &tfbridge.DefaultInfo{\n\t\t\t\t\tValue: \"public\",\n\t\t\t\t\tEnvVars: []string{\"ARM_ENVIRONMENT\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"msi_endpoint\": {\n\t\t\t\tDefault: &tfbridge.DefaultInfo{\n\t\t\t\t\tEnvVars: []string{\"ARM_MSI_ENDPOINT\"},\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"use_msi\": {\n\t\t\t\tDefault: &tfbridge.DefaultInfo{\n\t\t\t\t\tValue: false,\n\t\t\t\t\tEnvVars: []string{\"ARM_USE_MSI\"},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tPreConfigureCallback: preConfigureCallback,\n\t\tResources: map[string]*tfbridge.ResourceInfo{\n\t\t\t\"azuread_application\": {Tok: makeResource(mainMod, \"Application\")},\n\t\t\t\"azuread_application_password\": {Tok: makeResource(mainMod, \"ApplicationPassword\")},\n\t\t\t\"azuread_group\": {Tok: makeResource(mainMod, \"Group\")},\n\t\t\t\"azuread_service_principal\": {Tok: makeResource(mainMod, \"ServicePrincipal\")},\n\t\t\t\"azuread_service_principal_password\": {Tok: makeResource(mainMod, \"ServicePrincipalPassword\")},\n\t\t\t\"azuread_service_principal_delegated_permission_grant\": {\n\t\t\t\tTok: makeResource(mainMod, \"ServicePrincipalDelegatedPermissionGrant\"),\n\t\t\t},\n\t\t\t\"azuread_user\": {Tok: makeResource(mainMod, \"User\")},\n\t\t\t\"azuread_group_member\": {Tok: makeResource(mainMod, \"GroupMember\")},\n\t\t\t\"azuread_application_certificate\": {Tok: makeResource(mainMod, \"ApplicationCertificate\")},\n\t\t\t\"azuread_service_principal_certificate\": {Tok: makeResource(mainMod, \"ServicePrincipalCertificate\")},\n\t\t\t\"azuread_service_principal_token_signing_certificate\": {\n\t\t\t\tTok: makeResource(mainMod, \"ServicePrincipalTokenSigningCertificate\"),\n\t\t\t},\n\t\t\t\"azuread_application_pre_authorized\": {Tok: makeResource(mainMod, \"ApplicationPreAuthorized\")},\n\t\t\t\"azuread_invitation\": {Tok: makeResource(mainMod, \"Invitation\")},\n\t\t\t\"azuread_conditional_access_policy\": {Tok: makeResource(mainMod, \"ConditionalAccessPolicy\")},\n\t\t\t\"azuread_named_location\": {Tok: makeResource(mainMod, \"NamedLocation\")},\n\t\t\t\"azuread_directory_role\": {Tok: makeResource(mainMod, \"DirectoryRole\")},\n\t\t\t\"azuread_directory_role_member\": {Tok: makeResource(mainMod, \"DirectoryRoleMember\")},\n\t\t\t\"azuread_app_role_assignment\": {Tok: makeResource(mainMod, \"AppRoleAssignment\")},\n\t\t\t\"azuread_administrative_unit\": {Tok: makeResource(mainMod, \"AdministrativeUnit\")},\n\t\t\t\"azuread_administrative_unit_member\": {Tok: makeResource(mainMod, \"AdministrativeUnitMember\")},\n\t\t\t\"azuread_application_federated_identity_credential\": {\n\t\t\t\tTok: makeResource(mainMod, \"ApplicationFederatedIdentityCredential\"),\n\t\t\t},\n\t\t\t\"azuread_custom_directory_role\": {Tok: makeResource(mainMod, \"CustomDirectoryRole\")},\n\t\t\t\"azuread_claims_mapping_policy\": {Tok: makeResource(mainMod, \"ClaimsMappingPolicy\")},\n\t\t\t\"azuread_directory_role_assignment\": {Tok: makeResource(mainMod, \"DirectoryRoleAssignment\")},\n\t\t\t\"azuread_service_principal_claims_mapping_policy_assignment\": {\n\t\t\t\tTok: makeResource(mainMod, \"ServicePrincipalClaimsMappingPolicyAssignment\"),\n\t\t\t},\n\t\t\t\"azuread_synchronization_job\": {Tok: makeResource(mainMod, \"SynchronizationJob\")},\n\t\t\t\"azuread_synchronization_secret\": {Tok: makeResource(mainMod, \"SynchronizationSecret\")},\n\t\t\t\"azuread_access_package\": {Tok: makeResource(mainMod, \"AccessPackage\")},\n\t\t\t\"azuread_access_package_assignment_policy\": {Tok: makeResource(mainMod, \"AccessPackageAssignmentPolicy\")},\n\t\t\t\"azuread_access_package_catalog\": {Tok: makeResource(mainMod, \"AccessPackageCatalog\")},\n\t\t\t\"azuread_access_package_resource_catalog_association\": {\n\t\t\t\tTok: makeResource(mainMod, \"AccessPackageResourceCatalogAssociation\"),\n\t\t\t},\n\t\t\t\"azuread_access_package_resource_package_association\": {\n\t\t\t\tTok: makeResource(mainMod, \"AccessPackageResourcePackageAssociation\"),\n\t\t\t},\n\t\t\t\"azuread_administrative_unit_role_member\": {Tok: makeResource(mainMod, \"AdministrativeUnitRoleMember\")},\n\t\t\t\"azuread_user_flow_attribute\": {Tok: makeResource(mainMod, \"UserFlowAttribute\")},\n\t\t},\n\t\tDataSources: map[string]*tfbridge.DataSourceInfo{\n\t\t\t\"azuread_client_config\": {Tok: makeDataSource(mainMod, \"getClientConfig\")},\n\t\t\t\"azuread_application_published_app_ids\": {Tok: makeDataSource(mainMod, \"getApplicationPublishedAppIds\")},\n\t\t\t\"azuread_application_template\": {Tok: makeDataSource(mainMod, \"getApplicationTemplate\")},\n\t\t\t\"azuread_service_principals\": {Tok: makeDataSource(mainMod, \"getServicePrincipals\")},\n\t\t\t\"azuread_administrative_unit\": {Tok: makeDataSource(mainMod, \"getAdministrativeUnit\")},\n\t\t\t\"azuread_directory_object\": {Tok: makeDataSource(mainMod, \"getDirectoryObject\")},\n\t\t\t\"azuread_directory_roles\": {Tok: makeDataSource(mainMod, \"getDirectoryRoles\")},\n\t\t\t\"azuread_access_package\": {Tok: makeDataSource(mainMod, \"getAccessPackage\")},\n\t\t\t\"azuread_access_package_catalog\": {Tok: makeDataSource(mainMod, \"getAccessPackageCatalog\")},\n\t\t},\n\t\tJavaScript: &tfbridge.JavaScriptInfo{\n\t\t\t// List any npm dependencies and their versions\n\t\t\tDependencies: map[string]string{\n\t\t\t\t\"@pulumi/pulumi\": \"^3.0.0\",\n\t\t\t},\n\t\t\tDevDependencies: map[string]string{\n\t\t\t\t\"@types/node\": \"^10.0.0\", // so we can access strongly typed node definitions.\n\t\t\t\t\"@types/mime\": \"^2.0.0\",\n\t\t\t},\n\t\t},\n\t\tPython: &tfbridge.PythonInfo{\n\t\t\tRequires: map[string]string{\n\t\t\t\t\"pulumi\": \">=3.0.0,<4.0.0\",\n\t\t\t},\n\t\t},\n\t\tGolang: &tfbridge.GolangInfo{\n\t\t\tImportBasePath: filepath.Join(\n\t\t\t\tfmt.Sprintf(\"github.com/pulumi/pulumi-%[1]s/sdk/\", mainPkg),\n\t\t\t\ttfbridge.GetModuleMajorVersion(version.Version),\n\t\t\t\t\"go\",\n\t\t\t\tmainPkg,\n\t\t\t),\n\t\t\tGenerateResourceContainerTypes: true,\n\t\t},\n\t\tCSharp: &tfbridge.CSharpInfo{\n\t\t\tPackageReferences: map[string]string{\n\t\t\t\t\"Pulumi\": \"3.*\",\n\t\t\t},\n\t\t\tNamespaces: map[string]string{\n\t\t\t\t\"azuread\": \"AzureAD\",\n\t\t\t},\n\t\t}, MetadataInfo: tfbridge.NewProviderMetadata(metadata),\n\t}\n\n\tprov.MustComputeTokens(tfbridgetokens.SingleModule(\"azuread_\", mainMod,\n\t\ttfbridgetokens.MakeStandard(mainPkg)))\n\tprov.SetAutonaming(255, \"-\")\n\tprov.MustApplyAutoAliases()\n\n\treturn prov\n}", "func NewProvider(api *API, vin string, cache time.Duration) *Provider {\n\timpl := &Provider{\n\t\tchargerG: provider.Cached(func() (ChargerResponse, error) {\n\t\t\treturn api.Charger(vin)\n\t\t}, cache),\n\t\tstatusG: provider.Cached(func() (StatusResponse, error) {\n\t\t\treturn api.Status(vin)\n\t\t}, cache),\n\t\tclimateG: provider.Cached(func() (ClimaterResponse, error) {\n\t\t\treturn api.Climater(vin)\n\t\t}, cache),\n\t\tpositionG: provider.Cached(func() (PositionResponse, error) {\n\t\t\treturn api.Position(vin)\n\t\t}, cache),\n\t\taction: func(action, value string) error {\n\t\t\treturn api.Action(vin, action, value)\n\t\t},\n\t\trr: func() (RolesRights, error) {\n\t\t\treturn api.RolesRights(vin)\n\t\t},\n\t}\n\treturn impl\n}", "func NewProvider(typeName string, crypto domain.Crypto) *Provider {\n\treturn &Provider{\n\t\ttypeName: typeName,\n\t\tbqClients: map[string]*bigQueryClient{},\n\t\tiamClients: map[string]*iamClient{},\n\t\tcrypto: crypto,\n\t}\n}", "func newProviderGroup(k key) *providerGroup {\n\tifaceKey := key{\n\t\tres: reflect.SliceOf(k.res),\n\t\ttyp: ptGroup,\n\t}\n\n\treturn &providerGroup{\n\t\tresult: ifaceKey,\n\t\tpl: parameterList{},\n\t}\n}", "func newProvisioner(baseCtx context.Context, cl *restClient, callTimeout time.Duration) mode.Provisioner {\n\treturn provisioner{cl: cl, baseCtx: baseCtx, callTimeout: callTimeout}\n}", "func NewProvider(kubeClient kubernetes.Interface, wsCatalog *witesand.WitesandCatalog, clusterId string, stop chan struct{}, meshSpec smi.MeshSpec, providerIdent string) (*Client, error) {\n\n\tclient := Client{\n\t\twsCatalog: wsCatalog,\n\t\tproviderIdent: providerIdent,\n\t\tclusterId: clusterId,\n\t\tmeshSpec: meshSpec,\n\t\tcaches: nil,\n\t\tannouncements: make(chan a.Announcement),\n\t}\n\n\tclient.caches = &CacheCollection{\n\t\tk8sToServiceEndpoints: make(map[string]*ServiceToEndpointMap),\n\t}\n\n\tif err := client.run(); err != nil {\n\t\treturn nil, errors.Errorf(\"Failed to start Remote EndpointProvider client: %+v\", err)\n\t}\n\tlog.Info().Msgf(\"[NewProvider] started Remote provider\")\n\n\treturn &client, nil\n}", "func NewProvider(ctx *pulumi.Context,\n\tname string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) {\n\tif args == nil {\n\t\targs = &ProviderArgs{}\n\t}\n\n\tif args.AllowReauth == nil {\n\t\targs.AllowReauth = pulumi.BoolPtr(getEnvOrDefault(false, parseEnvBool, \"OS_ALLOW_REAUTH\").(bool))\n\t}\n\tif args.Cloud == nil {\n\t\targs.Cloud = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"OS_CLOUD\").(string))\n\t}\n\tif args.DelayedAuth == nil {\n\t\targs.DelayedAuth = pulumi.BoolPtr(getEnvOrDefault(false, parseEnvBool, \"OS_DELAYED_AUTH\").(bool))\n\t}\n\tif args.EndpointType == nil {\n\t\targs.EndpointType = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"OS_ENDPOINT_TYPE\").(string))\n\t}\n\tif args.Insecure == nil {\n\t\targs.Insecure = pulumi.BoolPtr(getEnvOrDefault(false, parseEnvBool, \"OS_INSECURE\").(bool))\n\t}\n\tif args.Region == nil {\n\t\targs.Region = pulumi.StringPtr(getEnvOrDefault(\"\", nil, \"OS_REGION_NAME\").(string))\n\t}\n\tif args.Swauth == nil {\n\t\targs.Swauth = pulumi.BoolPtr(getEnvOrDefault(false, parseEnvBool, \"OS_SWAUTH\").(bool))\n\t}\n\tif args.UseOctavia == nil {\n\t\targs.UseOctavia = pulumi.BoolPtr(getEnvOrDefault(false, parseEnvBool, \"OS_USE_OCTAVIA\").(bool))\n\t}\n\tvar resource Provider\n\terr := ctx.RegisterResource(\"pulumi:providers:openstack\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func NewProvider(api *API, vin string, cache time.Duration) *Provider {\n\timpl := &Provider{\n\t\tstatusG: provider.Cached(func() (RechargeStatus, error) {\n\t\t\treturn api.RechargeStatus(vin)\n\t\t}, cache),\n\t}\n\treturn impl\n}", "func (p *newTranscodeJobInput) ProviderFactory(body io.Reader) (provider.Factory, error) {\n\terr := p.loadParams(body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\terr = p.validate()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn provider.GetProviderFactory(p.Payload.Provider)\n}", "func MockedProvider(t *testing.T, c *config.Config, callback string) (*config.Config, goth.Provider) {\n\tconst (\n\t\ttestClientKey = \"provider-test-client-key\"\n\t\ttestSecret = \"provider-test-secret\"\n\t\ttestCallback = \"http://auth.exmaple.com/test/callback\"\n\t)\n\tmp := newMockProvider(t, callback)\n\tp := provider.Name(mp.Name())\n\tprovider.AddExternal(p)\n\tt.Cleanup(func() {\n\t\tdelete(provider.External, p)\n\t})\n\tif callback == \"\" {\n\t\tcallback = testCallback\n\t}\n\tc.Authorization.Providers[p] = config.Provider{\n\t\tClientKey: testClientKey,\n\t\tSecret: testSecret,\n\t\tCallbackURL: callback,\n\t}\n\treturn c, mp\n}", "func NewProvider(log *zap.Logger, url, clusterID, clientID string) mq.Provider {\n\tif len(clusterID) == 0 || len(clientID) == 0 {\n\t\treturn nil\n\t}\n\n\tcfg := newConfig(url, clusterID, clientID)\n\n\tif log == nil {\n\t\tlog = zap.NewNop()\n\t}\n\n\treturn &provider{\n\t\tconfig: cfg,\n\t\tconsumer: newConsumer(log, url, clusterID, clientID),\n\t\tlog: log,\n\t}\n}", "func New(chain []byte) (p *Provider, err error) {\n\tp = &Provider{}\n\tif err = p.Decode(chain); err != nil {\n\t\treturn nil, err\n\t}\n\treturn p, nil\n}", "func (retriever *CredRetrieverLocalFs) GetProvider() string {\n\treturn retriever.Provider\n}", "func providerConfigure(version string, p *schema.Provider) schema.ConfigureContextFunc {\n\treturn func(_ context.Context, d *schema.ResourceData) (any, diag.Diagnostics) {\n\t\taccessToken := d.Get(\"access_token\").(string)\n\t\tcredentials := d.Get(\"credentials\").(string)\n\n\t\t// Note that we explicitly use context.Background() instead of the provided\n\t\t// context because we want to give the client a chance to finish before\n\t\t// cleanup.\n\t\ttokenSource, err := tokenSource(context.Background(), accessToken, credentials)\n\t\tif err != nil {\n\t\t\treturn nil, diag.FromErr(fmt.Errorf(\"failed to configure provider: %w\", err))\n\t\t}\n\n\t\tclient, err := berglas.New(context.Background(), option.WithTokenSource(tokenSource))\n\t\tif err != nil {\n\t\t\treturn nil, diag.FromErr(fmt.Errorf(\"failed to setup berglas: %w\", err))\n\t\t}\n\n\t\tconfig := &config{\n\t\t\tclient: client,\n\t\t}\n\n\t\treturn config, nil\n\t}\n}", "func newParamsetProvider(pf *psrefresh.ParamSetRefresher) regression.ParamsetProvider {\n\treturn func() paramtools.ReadOnlyParamSet {\n\t\treturn pf.Get()\n\t}\n}", "func New(fabricProvider api.FabricProvider) (*ChannelProvider, error) {\n\tcp := ChannelProvider{fabricProvider: fabricProvider}\n\treturn &cp, nil\n}", "func providerExtract(provider string) error {\n\tklog.Infof(\"extracting cloud provider name to %v\", openshiftTunedProvider)\n\n\tf, err := os.Create(openshiftTunedProvider)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create cloud provider name file %q: %v\", openshiftTunedProvider, err)\n\t}\n\tdefer f.Close()\n\tif _, err = f.WriteString(provider); err != nil {\n\t\treturn fmt.Errorf(\"failed to write cloud provider name file %q: %v\", openshiftTunedProvider, err)\n\t}\n\n\treturn nil\n}", "func NewProviderBackedStore(provider Provider) *ProviderBackedStore {\n\tstore := &ProviderBackedStore{\n\t\tids: cloneIDs(provider.IDs()),\n\t\tretriever: make(map[uint16]func() (*Chunk, error))}\n\n\tdefaultToProvider := func(id Identifier) func() (*Chunk, error) {\n\t\treturn func() (*Chunk, error) { return provider.Chunk(id) }\n\t}\n\tfor _, id := range store.ids {\n\t\tstore.retriever[id.Value()] = defaultToProvider(id)\n\t}\n\n\treturn store\n}", "func NewProvider(\n\tlogger *zap.Logger,\n\topts ...Option,\n) *Provider {\n\tcfg := providerConfig{\n\t\tqueryTimeout: 5 * time.Second,\n\t\tupdateBufferSize: 10000,\n\t\teventBufferSize: 10000,\n\t\trequestBufferSize: 10,\n\t}\n\tfor _, opt := range opts {\n\t\topt(&cfg)\n\t}\n\n\treturn &Provider{\n\t\tqueryTimeout: cfg.queryTimeout,\n\t\tlogger: logger.Named(\"store-provider\"),\n\n\t\tstreams: Streams{Map: make(map[int]*models.Stream)},\n\t\tstreamHub: hub.NewNotifyHub[*models.StreamEvent](cfg.eventBufferSize),\n\t\tentityHub: hub.NewNotifyHub[*models.EntityEvent](cfg.eventBufferSize),\n\n\t\tupdatesChan: make(chan Update, cfg.updateBufferSize),\n\t\tinternalRequestChan: make(chan internalRequest, cfg.requestBufferSize),\n\n\t\tstop: make(chan struct{}),\n\t\tstopDone: make(chan struct{}),\n\t}\n}", "func NewProvider(expires time.Duration) *Provider {\n\treturn &Provider{list: list.New(), sessions: make(map[string]*list.Element, 0), databases: make([]Database, 0), Expires: expires}\n}", "func Provider() terraform.ResourceProvider {\n\treturn &schema.Provider{\n\t\tDataSourcesMap: map[string]*schema.Resource{\n\t\t\t\"gotemplate_file\": goDataSourceFile(),\n\t\t},\n\t\tResourcesMap: map[string]*schema.Resource{\n\t\t\t\"gotemplate_file\": schema.DataSourceResourceShim(\n\t\t\t\t\"gotemplate_file\",\n\t\t\t\tgoDataSourceFile(),\n\t\t\t),\n\t\t},\n\t}\n}", "func New(provider string, p *ProviderData) Provider {\n\tswitch provider {\n\tcase \"myusa\":\n\t\treturn NewMyUsaProvider(p)\n\tcase \"linkedin\":\n\t\treturn NewLinkedInProvider(p)\n\tcase \"facebook\":\n\t\treturn NewFacebookProvider(p)\n\tcase \"github\":\n\t\treturn NewGitHubProvider(p)\n\tcase \"azure\":\n\t\treturn NewAzureProvider(p)\n\tcase \"gitlab\":\n\t\treturn NewGitLabProvider(p)\n\tdefault:\n\t\treturn NewGoogleProvider(p)\n\t}\n}", "func ProviderFactory(options plugin_v1.ProviderOptions) (plugin_v1.Provider, error) {\n\treturn &Provider{\n\t\tName: options.Name,\n\t}, nil\n}", "func NewSetProviderReference(receiver, runtime string) New {\n\treturn func(f *jen.File, o types.Object) {\n\t\tf.Commentf(\"SetProviderReference of this %s.\\nDeprecated: Use SetProviderConfigReference.\", o.Name())\n\t\tf.Func().Params(jen.Id(receiver).Op(\"*\").Id(o.Name())).Id(\"SetProviderReference\").Params(jen.Id(\"r\").Op(\"*\").Qual(runtime, \"Reference\")).Block(\n\t\t\tjen.Id(receiver).Dot(fields.NameSpec).Dot(\"ProviderReference\").Op(\"=\").Id(\"r\"),\n\t\t)\n\t}\n}", "func (d *Deployment) EnsureProvider(provider string) error {\n\tif provider == \"\" {\n\t\treturn nil\n\t}\n\n\tproviderRef, err := providers.ParseReference(provider)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid provider reference %v: %w\", provider, err)\n\t}\n\t_, has := d.GetProvider(providerRef)\n\tif !has {\n\t\t// We need to create the provider in the registry, find its old state and just \"Same\" it.\n\t\tvar providerResource *resource.State\n\t\tfor _, r := range d.prev.Resources {\n\t\t\tif r.URN == providerRef.URN() && r.ID == providerRef.ID() {\n\t\t\t\tproviderResource = r\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif providerResource == nil {\n\t\t\treturn fmt.Errorf(\"could not find provider %v\", providerRef)\n\t\t}\n\n\t\terr := d.SameProvider(providerResource)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"could not create provider %v: %w\", providerRef, err)\n\t\t}\n\t}\n\n\treturn nil\n}", "func Provider() terraform.ResourceProvider {\n\treturn &schema.Provider{\n\t\tSchema: map[string]*schema.Schema{\n\t\t\t\"credential\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tRequired: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"SECRETHUB_CREDENTIAL\", nil),\n\t\t\t\tDescription: \"Credential to use for SecretHub authentication. Can also be sourced from SECRETHUB_CREDENTIAL.\",\n\t\t\t},\n\t\t\t\"credential_passphrase\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"SECRETHUB_CREDENTIAL_PASSPHRASE\", nil),\n\t\t\t\tDescription: \"Passphrase to unlock the authentication passed in `credential`. Can also be sourced from SECRETHUB_CREDENTIAL_PASSPHRASE.\",\n\t\t\t},\n\t\t\t\"path_prefix\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDescription: \"The default value to prefix path values with. If set, paths for resources and data sources will be prefixed with the given prefix, allowing you to use relative paths instead. If left blank, every path must be absolute (namespace/repository/[dir/]secret_name).\",\n\t\t\t},\n\t\t},\n\t\tConfigureFunc: configureProvider,\n\t\tResourcesMap: map[string]*schema.Resource{\n\t\t\t\"secrethub_secret\": resourceSecret(),\n\t\t},\n\t\tDataSourcesMap: map[string]*schema.Resource{\n\t\t\t\"secrethub_secret\": dataSourceSecret(),\n\t\t},\n\t}\n}", "func (c *providerConnecter) Connect(ctx context.Context, g *v1alpha1.ReplicationGroup) (createsyncdeleter, error) {\n\tp := &awsv1alpha1.Provider{}\n\tn := types.NamespacedName{Namespace: g.GetNamespace(), Name: g.Spec.ProviderRef.Name}\n\tif err := c.kube.Get(ctx, n, p); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"cannot get provider %s\", n)\n\t}\n\n\ts := &corev1.Secret{}\n\tn = types.NamespacedName{Namespace: p.Namespace, Name: p.Spec.Secret.Name}\n\tif err := c.kube.Get(ctx, n, s); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"cannot get provider secret %s\", n)\n\t}\n\n\tclient, err := c.newClient(s.Data[p.Spec.Secret.Key], p.Spec.Region)\n\treturn &elastiCache{client: client}, errors.Wrap(err, \"cannot create new AWS Replication Group client\")\n}", "func Provider() terraform.ResourceProvider {\n\tprovider := &schema.Provider{\n\t\tSchema: map[string]*schema.Schema{\n\t\t\t\"auth_url\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_AUTH_URL\", \"\"),\n\t\t\t\tDescription: descriptions[\"auth_url\"],\n\t\t\t},\n\n\t\t\t\"region\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDescription: descriptions[\"region\"],\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_REGION_NAME\", \"\"),\n\t\t\t},\n\n\t\t\t\"user_name\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_USERNAME\", \"\"),\n\t\t\t\tDescription: descriptions[\"user_name\"],\n\t\t\t},\n\n\t\t\t\"user_id\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_USER_ID\", \"\"),\n\t\t\t\tDescription: descriptions[\"user_name\"],\n\t\t\t},\n\n\t\t\t\"application_credential_id\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_APPLICATION_CREDENTIAL_ID\", \"\"),\n\t\t\t\tDescription: descriptions[\"application_credential_id\"],\n\t\t\t},\n\n\t\t\t\"application_credential_name\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_APPLICATION_CREDENTIAL_NAME\", \"\"),\n\t\t\t\tDescription: descriptions[\"application_credential_name\"],\n\t\t\t},\n\n\t\t\t\"application_credential_secret\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_APPLICATION_CREDENTIAL_SECRET\", \"\"),\n\t\t\t\tDescription: descriptions[\"application_credential_secret\"],\n\t\t\t},\n\n\t\t\t\"tenant_id\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.MultiEnvDefaultFunc([]string{\n\t\t\t\t\t\"OS_TENANT_ID\",\n\t\t\t\t\t\"OS_PROJECT_ID\",\n\t\t\t\t}, \"\"),\n\t\t\t\tDescription: descriptions[\"tenant_id\"],\n\t\t\t},\n\n\t\t\t\"tenant_name\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.MultiEnvDefaultFunc([]string{\n\t\t\t\t\t\"OS_TENANT_NAME\",\n\t\t\t\t\t\"OS_PROJECT_NAME\",\n\t\t\t\t}, \"\"),\n\t\t\t\tDescription: descriptions[\"tenant_name\"],\n\t\t\t},\n\n\t\t\t\"password\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tSensitive: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_PASSWORD\", \"\"),\n\t\t\t\tDescription: descriptions[\"password\"],\n\t\t\t},\n\n\t\t\t\"token\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.MultiEnvDefaultFunc([]string{\n\t\t\t\t\t\"OS_TOKEN\",\n\t\t\t\t\t\"OS_AUTH_TOKEN\",\n\t\t\t\t}, \"\"),\n\t\t\t\tDescription: descriptions[\"token\"],\n\t\t\t},\n\n\t\t\t\"user_domain_name\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_USER_DOMAIN_NAME\", \"\"),\n\t\t\t\tDescription: descriptions[\"user_domain_name\"],\n\t\t\t},\n\n\t\t\t\"user_domain_id\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_USER_DOMAIN_ID\", \"\"),\n\t\t\t\tDescription: descriptions[\"user_domain_id\"],\n\t\t\t},\n\n\t\t\t\"project_domain_name\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_PROJECT_DOMAIN_NAME\", \"\"),\n\t\t\t\tDescription: descriptions[\"project_domain_name\"],\n\t\t\t},\n\n\t\t\t\"project_domain_id\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_PROJECT_DOMAIN_ID\", \"\"),\n\t\t\t\tDescription: descriptions[\"project_domain_id\"],\n\t\t\t},\n\n\t\t\t\"domain_id\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_DOMAIN_ID\", \"\"),\n\t\t\t\tDescription: descriptions[\"domain_id\"],\n\t\t\t},\n\n\t\t\t\"domain_name\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_DOMAIN_NAME\", \"\"),\n\t\t\t\tDescription: descriptions[\"domain_name\"],\n\t\t\t},\n\n\t\t\t\"default_domain\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_DEFAULT_DOMAIN\", \"default\"),\n\t\t\t\tDescription: descriptions[\"default_domain\"],\n\t\t\t},\n\n\t\t\t\"insecure\": {\n\t\t\t\tType: schema.TypeBool,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_INSECURE\", nil),\n\t\t\t\tDescription: descriptions[\"insecure\"],\n\t\t\t},\n\n\t\t\t\"endpoint_type\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_ENDPOINT_TYPE\", \"\"),\n\t\t\t},\n\n\t\t\t\"cacert_file\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_CACERT\", \"\"),\n\t\t\t\tDescription: descriptions[\"cacert_file\"],\n\t\t\t},\n\n\t\t\t\"cert\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_CERT\", \"\"),\n\t\t\t\tDescription: descriptions[\"cert\"],\n\t\t\t},\n\n\t\t\t\"key\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_KEY\", \"\"),\n\t\t\t\tDescription: descriptions[\"key\"],\n\t\t\t},\n\n\t\t\t\"swauth\": {\n\t\t\t\tType: schema.TypeBool,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_SWAUTH\", false),\n\t\t\t\tDescription: descriptions[\"swauth\"],\n\t\t\t},\n\n\t\t\t\"use_octavia\": {\n\t\t\t\tType: schema.TypeBool,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_USE_OCTAVIA\", false),\n\t\t\t\tDescription: descriptions[\"use_octavia\"],\n\t\t\t},\n\n\t\t\t\"delayed_auth\": {\n\t\t\t\tType: schema.TypeBool,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_DELAYED_AUTH\", true),\n\t\t\t\tDescription: descriptions[\"delayed_auth\"],\n\t\t\t},\n\n\t\t\t\"allow_reauth\": {\n\t\t\t\tType: schema.TypeBool,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_ALLOW_REAUTH\", true),\n\t\t\t\tDescription: descriptions[\"allow_reauth\"],\n\t\t\t},\n\n\t\t\t\"cloud\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"OS_CLOUD\", \"\"),\n\t\t\t\tDescription: descriptions[\"cloud\"],\n\t\t\t},\n\n\t\t\t\"max_retries\": {\n\t\t\t\tType: schema.TypeInt,\n\t\t\t\tOptional: true,\n\t\t\t\tDefault: 0,\n\t\t\t\tDescription: descriptions[\"max_retries\"],\n\t\t\t},\n\n\t\t\t\"endpoint_overrides\": {\n\t\t\t\tType: schema.TypeMap,\n\t\t\t\tOptional: true,\n\t\t\t\tDescription: descriptions[\"endpoint_overrides\"],\n\t\t\t},\n\n\t\t\t\"disable_no_cache_header\": {\n\t\t\t\tType: schema.TypeBool,\n\t\t\t\tOptional: true,\n\t\t\t\tDefault: false,\n\t\t\t\tDescription: descriptions[\"disable_no_cache_header\"],\n\t\t\t},\n\t\t},\n\n\t\tDataSourcesMap: map[string]*schema.Resource{\n\t\t\t\"ironic_introspection\": dataSourceIronicIntrospection(),\n\t\t},\n\t\t//DataSourcesMap: map[string]*schema.Resource{\n\t\t//\t\"openstack_blockstorage_availability_zones_v3\": dataSourceBlockStorageAvailabilityZonesV3(),\n\t\t//\t\"openstack_blockstorage_snapshot_v2\": dataSourceBlockStorageSnapshotV2(),\n\t\t//\t\"openstack_blockstorage_snapshot_v3\": dataSourceBlockStorageSnapshotV3(),\n\t\t//\t\"openstack_blockstorage_volume_v2\": dataSourceBlockStorageVolumeV2(),\n\t\t//\t\"openstack_blockstorage_volume_v3\": dataSourceBlockStorageVolumeV3(),\n\t\t//\t\"openstack_compute_availability_zones_v2\": dataSourceComputeAvailabilityZonesV2(),\n\t\t//\t\"openstack_compute_instance_v2\": dataSourceComputeInstanceV2(),\n\t\t//\t\"openstack_compute_flavor_v2\": dataSourceComputeFlavorV2(),\n\t\t//\t\"openstack_compute_keypair_v2\": dataSourceComputeKeypairV2(),\n\t\t//\t\"openstack_containerinfra_clustertemplate_v1\": dataSourceContainerInfraClusterTemplateV1(),\n\t\t//\t\"openstack_containerinfra_cluster_v1\": dataSourceContainerInfraCluster(),\n\t\t//\t\"openstack_dns_zone_v2\": dataSourceDNSZoneV2(),\n\t\t//\t\"openstack_fw_policy_v1\": dataSourceFWPolicyV1(),\n\t\t//\t\"openstack_identity_role_v3\": dataSourceIdentityRoleV3(),\n\t\t//\t\"openstack_identity_project_v3\": dataSourceIdentityProjectV3(),\n\t\t//\t\"openstack_identity_user_v3\": dataSourceIdentityUserV3(),\n\t\t//\t\"openstack_identity_auth_scope_v3\": dataSourceIdentityAuthScopeV3(),\n\t\t//\t\"openstack_identity_endpoint_v3\": dataSourceIdentityEndpointV3(),\n\t\t//\t\"openstack_identity_service_v3\": dataSourceIdentityServiceV3(),\n\t\t//\t\"openstack_identity_group_v3\": dataSourceIdentityGroupV3(),\n\t\t//\t\"openstack_images_image_v2\": dataSourceImagesImageV2(),\n\t\t//\t\"openstack_networking_addressscope_v2\": dataSourceNetworkingAddressScopeV2(),\n\t\t//\t\"openstack_networking_network_v2\": dataSourceNetworkingNetworkV2(),\n\t\t//\t\"openstack_networking_qos_bandwidth_limit_rule_v2\": dataSourceNetworkingQoSBandwidthLimitRuleV2(),\n\t\t//\t\"openstack_networking_qos_dscp_marking_rule_v2\": dataSourceNetworkingQoSDSCPMarkingRuleV2(),\n\t\t//\t\"openstack_networking_qos_minimum_bandwidth_rule_v2\": dataSourceNetworkingQoSMinimumBandwidthRuleV2(),\n\t\t//\t\"openstack_networking_qos_policy_v2\": dataSourceNetworkingQoSPolicyV2(),\n\t\t//\t\"openstack_networking_subnet_v2\": dataSourceNetworkingSubnetV2(),\n\t\t//\t\"openstack_networking_secgroup_v2\": dataSourceNetworkingSecGroupV2(),\n\t\t//\t\"openstack_networking_subnetpool_v2\": dataSourceNetworkingSubnetPoolV2(),\n\t\t//\t\"openstack_networking_floatingip_v2\": dataSourceNetworkingFloatingIPV2(),\n\t\t//\t\"openstack_networking_router_v2\": dataSourceNetworkingRouterV2(),\n\t\t//\t\"openstack_networking_port_v2\": dataSourceNetworkingPortV2(),\n\t\t//\t\"openstack_networking_port_ids_v2\": dataSourceNetworkingPortIDsV2(),\n\t\t//\t\"openstack_networking_trunk_v2\": dataSourceNetworkingTrunkV2(),\n\t\t//\t\"openstack_sharedfilesystem_availability_zones_v2\": dataSourceSharedFilesystemAvailabilityZonesV2(),\n\t\t//\t\"openstack_sharedfilesystem_sharenetwork_v2\": dataSourceSharedFilesystemShareNetworkV2(),\n\t\t//\t\"openstack_sharedfilesystem_share_v2\": dataSourceSharedFilesystemShareV2(),\n\t\t//\t\"openstack_sharedfilesystem_snapshot_v2\": dataSourceSharedFilesystemSnapshotV2(),\n\t\t//\t\"openstack_keymanager_secret_v1\": dataSourceKeyManagerSecretV1(),\n\t\t//\t\"openstack_keymanager_container_v1\": dataSourceKeyManagerContainerV1(),\n\t\t//},\n\n\t\tResourcesMap: map[string]*schema.Resource{\n\t\t\t\"ironic_node_v1\": resourceNodeV1(),\n\t\t\t\"ironic_port_v1\": resourcePortV1(),\n\t\t\t\"ironic_allocation_v1\": resourceAllocationV1(),\n\t\t\t\"ironic_deployment\": resourceDeployment(),\n\t\t},\n\t\t//ResourcesMap: map[string]*schema.Resource{\n\t\t//\t\"openstack_blockstorage_quotaset_v2\": resourceBlockStorageQuotasetV2(),\n\t\t//\t\"openstack_blockstorage_quotaset_v3\": resourceBlockStorageQuotasetV3(),\n\t\t//\t\"openstack_blockstorage_volume_v1\": resourceBlockStorageVolumeV1(),\n\t\t//\t\"openstack_blockstorage_volume_v2\": resourceBlockStorageVolumeV2(),\n\t\t//\t\"openstack_blockstorage_volume_v3\": resourceBlockStorageVolumeV3(),\n\t\t//\t\"openstack_blockstorage_volume_attach_v2\": resourceBlockStorageVolumeAttachV2(),\n\t\t//\t\"openstack_blockstorage_volume_attach_v3\": resourceBlockStorageVolumeAttachV3(),\n\t\t//\t\"openstack_compute_flavor_v2\": resourceComputeFlavorV2(),\n\t\t//\t\"openstack_compute_flavor_access_v2\": resourceComputeFlavorAccessV2(),\n\t\t//\t\"openstack_compute_instance_v2\": resourceComputeInstanceV2(),\n\t\t//\t\"openstack_compute_interface_attach_v2\": resourceComputeInterfaceAttachV2(),\n\t\t//\t\"openstack_compute_keypair_v2\": resourceComputeKeypairV2(),\n\t\t//\t\"openstack_compute_secgroup_v2\": resourceComputeSecGroupV2(),\n\t\t//\t\"openstack_compute_servergroup_v2\": resourceComputeServerGroupV2(),\n\t\t//\t\"openstack_compute_quotaset_v2\": resourceComputeQuotasetV2(),\n\t\t//\t\"openstack_compute_floatingip_v2\": resourceComputeFloatingIPV2(),\n\t\t//\t\"openstack_compute_floatingip_associate_v2\": resourceComputeFloatingIPAssociateV2(),\n\t\t//\t\"openstack_compute_volume_attach_v2\": resourceComputeVolumeAttachV2(),\n\t\t//\t\"openstack_containerinfra_clustertemplate_v1\": resourceContainerInfraClusterTemplateV1(),\n\t\t//\t\"openstack_containerinfra_cluster_v1\": resourceContainerInfraClusterV1(),\n\t\t//\t\"openstack_db_instance_v1\": resourceDatabaseInstanceV1(),\n\t\t//\t\"openstack_db_user_v1\": resourceDatabaseUserV1(),\n\t\t//\t\"openstack_db_configuration_v1\": resourceDatabaseConfigurationV1(),\n\t\t//\t\"openstack_db_database_v1\": resourceDatabaseDatabaseV1(),\n\t\t//\t\"openstack_dns_recordset_v2\": resourceDNSRecordSetV2(),\n\t\t//\t\"openstack_dns_zone_v2\": resourceDNSZoneV2(),\n\t\t//\t\"openstack_fw_firewall_v1\": resourceFWFirewallV1(),\n\t\t//\t\"openstack_fw_policy_v1\": resourceFWPolicyV1(),\n\t\t//\t\"openstack_fw_rule_v1\": resourceFWRuleV1(),\n\t\t//\t\"openstack_identity_endpoint_v3\": resourceIdentityEndpointV3(),\n\t\t//\t\"openstack_identity_project_v3\": resourceIdentityProjectV3(),\n\t\t//\t\"openstack_identity_role_v3\": resourceIdentityRoleV3(),\n\t\t//\t\"openstack_identity_role_assignment_v3\": resourceIdentityRoleAssignmentV3(),\n\t\t//\t\"openstack_identity_service_v3\": resourceIdentityServiceV3(),\n\t\t//\t\"openstack_identity_user_v3\": resourceIdentityUserV3(),\n\t\t//\t\"openstack_identity_application_credential_v3\": resourceIdentityApplicationCredentialV3(),\n\t\t//\t\"openstack_images_image_v2\": resourceImagesImageV2(),\n\t\t//\t\"openstack_images_image_access_v2\": resourceImagesImageAccessV2(),\n\t\t//\t\"openstack_images_image_access_accept_v2\": resourceImagesImageAccessAcceptV2(),\n\t\t//\t\"openstack_lb_member_v1\": resourceLBMemberV1(),\n\t\t//\t\"openstack_lb_monitor_v1\": resourceLBMonitorV1(),\n\t\t//\t\"openstack_lb_pool_v1\": resourceLBPoolV1(),\n\t\t//\t\"openstack_lb_vip_v1\": resourceLBVipV1(),\n\t\t//\t\"openstack_lb_loadbalancer_v2\": resourceLoadBalancerV2(),\n\t\t//\t\"openstack_lb_listener_v2\": resourceListenerV2(),\n\t\t//\t\"openstack_lb_pool_v2\": resourcePoolV2(),\n\t\t//\t\"openstack_lb_member_v2\": resourceMemberV2(),\n\t\t//\t\"openstack_lb_members_v2\": resourceMembersV2(),\n\t\t//\t\"openstack_lb_monitor_v2\": resourceMonitorV2(),\n\t\t//\t\"openstack_lb_l7policy_v2\": resourceL7PolicyV2(),\n\t\t//\t\"openstack_lb_l7rule_v2\": resourceL7RuleV2(),\n\t\t//\t\"openstack_networking_floatingip_v2\": resourceNetworkingFloatingIPV2(),\n\t\t//\t\"openstack_networking_floatingip_associate_v2\": resourceNetworkingFloatingIPAssociateV2(),\n\t\t//\t\"openstack_networking_network_v2\": resourceNetworkingNetworkV2(),\n\t\t//\t\"openstack_networking_port_v2\": resourceNetworkingPortV2(),\n\t\t//\t\"openstack_networking_rbac_policy_v2\": resourceNetworkingRBACPolicyV2(),\n\t\t//\t\"openstack_networking_port_secgroup_associate_v2\": resourceNetworkingPortSecGroupAssociateV2(),\n\t\t//\t\"openstack_networking_qos_bandwidth_limit_rule_v2\": resourceNetworkingQoSBandwidthLimitRuleV2(),\n\t\t//\t\"openstack_networking_qos_dscp_marking_rule_v2\": resourceNetworkingQoSDSCPMarkingRuleV2(),\n\t\t//\t\"openstack_networking_qos_minimum_bandwidth_rule_v2\": resourceNetworkingQoSMinimumBandwidthRuleV2(),\n\t\t//\t\"openstack_networking_qos_policy_v2\": resourceNetworkingQoSPolicyV2(),\n\t\t//\t\"openstack_networking_quota_v2\": resourceNetworkingQuotaV2(),\n\t\t//\t\"openstack_networking_router_v2\": resourceNetworkingRouterV2(),\n\t\t//\t\"openstack_networking_router_interface_v2\": resourceNetworkingRouterInterfaceV2(),\n\t\t//\t\"openstack_networking_router_route_v2\": resourceNetworkingRouterRouteV2(),\n\t\t//\t\"openstack_networking_secgroup_v2\": resourceNetworkingSecGroupV2(),\n\t\t//\t\"openstack_networking_secgroup_rule_v2\": resourceNetworkingSecGroupRuleV2(),\n\t\t//\t\"openstack_networking_subnet_v2\": resourceNetworkingSubnetV2(),\n\t\t//\t\"openstack_networking_subnet_route_v2\": resourceNetworkingSubnetRouteV2(),\n\t\t//\t\"openstack_networking_subnetpool_v2\": resourceNetworkingSubnetPoolV2(),\n\t\t//\t\"openstack_networking_addressscope_v2\": resourceNetworkingAddressScopeV2(),\n\t\t//\t\"openstack_networking_trunk_v2\": resourceNetworkingTrunkV2(),\n\t\t//\t\"openstack_objectstorage_container_v1\": resourceObjectStorageContainerV1(),\n\t\t//\t\"openstack_objectstorage_object_v1\": resourceObjectStorageObjectV1(),\n\t\t//\t\"openstack_objectstorage_tempurl_v1\": resourceObjectstorageTempurlV1(),\n\t\t//\t\"openstack_orchestration_stack_v1\": resourceOrchestrationStackV1(),\n\t\t//\t\"openstack_vpnaas_ipsec_policy_v2\": resourceIPSecPolicyV2(),\n\t\t//\t\"openstack_vpnaas_service_v2\": resourceServiceV2(),\n\t\t//\t\"openstack_vpnaas_ike_policy_v2\": resourceIKEPolicyV2(),\n\t\t//\t\"openstack_vpnaas_endpoint_group_v2\": resourceEndpointGroupV2(),\n\t\t//\t\"openstack_vpnaas_site_connection_v2\": resourceSiteConnectionV2(),\n\t\t//\t\"openstack_sharedfilesystem_securityservice_v2\": resourceSharedFilesystemSecurityServiceV2(),\n\t\t//\t\"openstack_sharedfilesystem_sharenetwork_v2\": resourceSharedFilesystemShareNetworkV2(),\n\t\t//\t\"openstack_sharedfilesystem_share_v2\": resourceSharedFilesystemShareV2(),\n\t\t//\t\"openstack_sharedfilesystem_share_access_v2\": resourceSharedFilesystemShareAccessV2(),\n\t\t//\t\"openstack_keymanager_secret_v1\": resourceKeyManagerSecretV1(),\n\t\t//\t\"openstack_keymanager_container_v1\": resourceKeyManagerContainerV1(),\n\t\t//\t\"openstack_keymanager_order_v1\": resourceKeyManagerOrderV1(),\n\t\t//},\n\t}\n\n\tprovider.ConfigureFunc = func(d *schema.ResourceData) (interface{}, error) {\n\t\tterraformVersion := provider.TerraformVersion\n\t\tif terraformVersion == \"\" {\n\t\t\t// Terraform 0.12 introduced this field to the protocol\n\t\t\t// We can therefore assume that if it's missing it's 0.10 or 0.11\n\t\t\tterraformVersion = \"0.11+compatible\"\n\t\t}\n\t\treturn configureProvider(d, terraformVersion)\n\t}\n\n\treturn provider\n}", "func NewProvider(ctx *pulumi.Context,\n\tname string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) {\n\tif args == nil {\n\t\treturn nil, errors.New(\"missing one or more required arguments\")\n\t}\n\n\tif args.Address == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Address'\")\n\t}\n\tif args.Token == nil {\n\t\treturn nil, errors.New(\"invalid value for required argument 'Token'\")\n\t}\n\tif args.MaxLeaseTtlSeconds == nil {\n\t\targs.MaxLeaseTtlSeconds = pulumi.IntPtr(getEnvOrDefault(1200, parseEnvInt, \"TERRAFORM_VAULT_MAX_TTL\").(int))\n\t}\n\tif args.MaxRetries == nil {\n\t\targs.MaxRetries = pulumi.IntPtr(getEnvOrDefault(2, parseEnvInt, \"VAULT_MAX_RETRIES\").(int))\n\t}\n\tif args.SkipTlsVerify == nil {\n\t\targs.SkipTlsVerify = pulumi.BoolPtr(getEnvOrDefault(false, parseEnvBool, \"VAULT_SKIP_VERIFY\").(bool))\n\t}\n\tvar resource Provider\n\terr := ctx.RegisterResource(\"pulumi:providers:vault\", name, args, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resource, nil\n}", "func New(providerType string) CloudProvider {\n\tproviderType = strings.ToLower(providerType)\n\tswitch providerType {\n\tcase \"centurylink\":\n\t\treturn NewCenturylink()\n\tcase \"amazon\":\n\t\treturn NewAmazon()\n\t}\n\treturn nil\n}", "func Provider() *schema.Provider {\n\tp := &schema.Provider{\n\t\tSchema: map[string]*schema.Schema{\n\t\t\t\"user\": &schema.Schema{\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tRequired: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"ZABBIX_USER\", nil),\n\t\t\t},\n\t\t\t\"password\": &schema.Schema{\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tRequired: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"ZABBIX_PASSWORD\", nil),\n\t\t\t},\n\t\t\t\"server_url\": &schema.Schema{\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tRequired: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"ZABBIX_SERVER_URL\", nil),\n\t\t\t},\n\t\t\t\"tls_insecure\": &schema.Schema{\n\t\t\t\tType: schema.TypeBool,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"ZABBIX_TLS_INSECURE\", nil),\n\t\t\t},\n\t\t},\n\n\t\tDataSourcesMap: map[string]*schema.Resource{\n\t\t\t\"zabbix_server\": dataSourceZabbixServer(),\n\t\t},\n\n\t\tResourcesMap: map[string]*schema.Resource{\n\t\t\t\"zabbix_host\": resourceZabbixHost(),\n\t\t\t\"zabbix_host_group\": resourceZabbixHostGroup(),\n\t\t\t\"zabbix_item\": resourceZabbixItem(),\n\t\t\t\"zabbix_trigger\": resourceZabbixTrigger(),\n\t\t\t\"zabbix_template\": resourceZabbixTemplate(),\n\t\t\t\"zabbix_template_link\": resourceZabbixTemplateLink(),\n\t\t\t\"zabbix_lld_rule\": resourceZabbixLLDRule(),\n\t\t\t\"zabbix_item_prototype\": resourceZabbixItemPrototype(),\n\t\t\t\"zabbix_trigger_prototype\": resourceZabbixTriggerPrototype(),\n\t\t},\n\t}\n\n\tp.ConfigureFunc = func(d *schema.ResourceData) (interface{}, error) {\n\t\tterraformVersion := p.TerraformVersion\n\t\tif terraformVersion == \"\" {\n\t\t\t// Terraform 0.12 introduced this field to the protocol\n\t\t\t// We can therefore assume that if it's missing it's 0.10 or 0.11\n\t\t\tterraformVersion = \"0.11+compatible\"\n\t\t}\n\t\treturn providerConfigure(d, terraformVersion)\n\t}\n\n\treturn p\n}", "func (f *MockProviderFactory) NewFabricProvider(context apifabclient.ProviderContext) (api.FabricProvider, error) {\n\tfabProvider := fabpvdr.New(context)\n\n\tcfp := MockFabricProvider{\n\t\tFabricProvider: fabProvider,\n\t\tproviderContext: context,\n\t}\n\treturn &cfp, nil\n}", "func NewFileProvider(basePath string) StorageProvider {\n\treturn &FileProvider{basePath: basePath}\n}", "func NewProvider(logger *zap.Logger) Provider {\n\treturn newProvider(logger)\n}", "func NewProvider(options ...ProviderOption) *Provider {\n\tp := &Provider{\n\t\tlogger: log.NoopLogger{},\n\t}\n\t// Ensure we apply the logger options first, while maintaining the order\n\t// otherwise. This way we can trivially init the internal provider with\n\t// the logger.\n\tsort.SliceStable(options, func(i, j int) bool {\n\t\t_, iIsLogger := options[i].(providerLoggerOption)\n\t\t_, jIsLogger := options[j].(providerLoggerOption)\n\t\treturn iIsLogger && !jIsLogger\n\t})\n\tfor _, o := range options {\n\t\tif o != nil {\n\t\t\to.apply(p)\n\t\t}\n\t}\n\n\tif p.provider == nil {\n\t\t// auto-detect based on what is available in path\n\t\t// default to docker for backwards compatibility\n\t\tif path, err := exec.LookPath(\"docker\"); err == nil && path != \"\" {\n\t\t\tp.provider = docker.NewProvider(p.logger)\n\t\t} else if path, err := exec.LookPath(\"podman\"); err == nil && path != \"\" {\n\t\t\tp.provider = podman.NewProvider(p.logger)\n\t\t} else {\n\t\t\tp.provider = docker.NewProvider(p.logger)\n\t\t}\n\t}\n\treturn p\n}", "func ProviderBuilder(provider string, providerBlock map[string]interface{}) {\n\tvar providerInfo strings.Builder\n\n\tif provider != \"\" {\n\t\tproviderInfo.WriteString(\"\\nprovider \\\"\" + provider + \"\\\" {\\n\")\n\t\tproviderInfo = recursiveBuilder(&providerInfo, reflect.ValueOf(providerBlock))\n\n\t\t_, err := file.TerraformFile.WriteString(providerInfo.String())\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t}\n\n\t\tif terraformExists() {\n\t\t\tcmd := exec.Command(\"terraform\", \"fmt\")\n\t\t\terr := cmd.Run()\n\t\t\tif err != nil {\n\t\t\t\tlog.Println(err)\n\t\t\t}\n\t\t}\n\t}\n}", "func (m *Meta) providerFactories() (map[addrs.Provider]providers.Factory, error) {\n\tlocks, diags := m.lockedDependencies()\n\tif diags.HasErrors() {\n\t\treturn nil, fmt.Errorf(\"failed to read dependency lock file: %s\", diags.Err())\n\t}\n\n\t// We'll always run through all of our providers, even if one of them\n\t// encounters an error, so that we can potentially report multiple errors\n\t// where appropriate and so that callers can potentially make use of the\n\t// partial result we return if e.g. they want to enumerate which providers\n\t// are available, or call into one of the providers that didn't fail.\n\terrs := make(map[addrs.Provider]error)\n\n\t// For the providers from the lock file, we expect them to be already\n\t// available in the provider cache because \"terraform init\" should already\n\t// have put them there.\n\tproviderLocks := locks.AllProviders()\n\tcacheDir := m.providerLocalCacheDir()\n\n\t// The internal providers are _always_ available, even if the configuration\n\t// doesn't request them, because they don't need any special installation\n\t// and they'll just be ignored if not used.\n\tinternalFactories := m.internalProviders()\n\n\t// We have two different special cases aimed at provider development\n\t// use-cases, which are not for \"production\" use:\n\t// - The CLI config can specify that a particular provider should always\n\t// use a plugin from a particular local directory, ignoring anything the\n\t// lock file or cache directory might have to say about it. This is useful\n\t// for manual testing of local development builds.\n\t// - The Terraform SDK test harness (and possibly other callers in future)\n\t// can ask that we use its own already-started provider servers, which we\n\t// call \"unmanaged\" because Terraform isn't responsible for starting\n\t// and stopping them. This is intended for automated testing where a\n\t// calling harness is responsible both for starting the provider server\n\t// and orchestrating one or more non-interactive Terraform runs that then\n\t// exercise it.\n\t// Unmanaged providers take precedence over overridden providers because\n\t// overrides are typically a \"session-level\" setting while unmanaged\n\t// providers are typically scoped to a single unattended command.\n\tdevOverrideProviders := m.ProviderDevOverrides\n\tunmanagedProviders := m.UnmanagedProviders\n\n\tfactories := make(map[addrs.Provider]providers.Factory, len(providerLocks)+len(internalFactories)+len(unmanagedProviders))\n\tfor name, factory := range internalFactories {\n\t\tfactories[addrs.NewBuiltInProvider(name)] = factory\n\t}\n\tfor provider, lock := range providerLocks {\n\t\treportError := func(thisErr error) {\n\t\t\terrs[provider] = thisErr\n\t\t\t// We'll populate a provider factory that just echoes our error\n\t\t\t// again if called, which allows us to still report a helpful\n\t\t\t// error even if it gets detected downstream somewhere from the\n\t\t\t// caller using our partial result.\n\t\t\tfactories[provider] = providerFactoryError(thisErr)\n\t\t}\n\n\t\tif locks.ProviderIsOverridden(provider) {\n\t\t\t// Overridden providers we'll handle with the other separate\n\t\t\t// loops below, for dev overrides etc.\n\t\t\tcontinue\n\t\t}\n\n\t\tversion := lock.Version()\n\t\tcached := cacheDir.ProviderVersion(provider, version)\n\t\tif cached == nil {\n\t\t\treportError(fmt.Errorf(\n\t\t\t\t\"there is no package for %s %s cached in %s\",\n\t\t\t\tprovider, version, cacheDir.BasePath(),\n\t\t\t))\n\t\t\tcontinue\n\t\t}\n\t\t// The cached package must match one of the checksums recorded in\n\t\t// the lock file, if any.\n\t\tif allowedHashes := lock.PreferredHashes(); len(allowedHashes) != 0 {\n\t\t\tmatched, err := cached.MatchesAnyHash(allowedHashes)\n\t\t\tif err != nil {\n\t\t\t\treportError(fmt.Errorf(\n\t\t\t\t\t\"failed to verify checksum of %s %s package cached in in %s: %s\",\n\t\t\t\t\tprovider, version, cacheDir.BasePath(), err,\n\t\t\t\t))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif !matched {\n\t\t\t\treportError(fmt.Errorf(\n\t\t\t\t\t\"the cached package for %s %s (in %s) does not match any of the checksums recorded in the dependency lock file\",\n\t\t\t\t\tprovider, version, cacheDir.BasePath(),\n\t\t\t\t))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tfactories[provider] = providerFactory(cached)\n\t}\n\tfor provider, localDir := range devOverrideProviders {\n\t\tfactories[provider] = devOverrideProviderFactory(provider, localDir)\n\t}\n\tfor provider, reattach := range unmanagedProviders {\n\t\tfactories[provider] = unmanagedProviderFactory(provider, reattach)\n\t}\n\n\tvar err error\n\tif len(errs) > 0 {\n\t\terr = providerPluginErrors(errs)\n\t}\n\treturn factories, err\n}", "func (p *Provider) newGCPProviderSpec(windowsServerVersion windows.ServerVersion) (*mapi.GCPMachineProviderSpec, error) {\n\tlistOptions := meta.ListOptions{LabelSelector: \"machine.openshift.io/cluster-api-machine-role=worker\"}\n\tmachines, err := p.oc.Machine.Machines(clusterinfo.MachineAPINamespace).List(context.TODO(), listOptions)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(machines.Items) == 0 {\n\t\treturn nil, fmt.Errorf(\"found 0 worker role machines\")\n\t}\n\tfoundSpec := &mapi.GCPMachineProviderSpec{}\n\terr = json.Unmarshal(machines.Items[0].Spec.ProviderSpec.Value.Raw, foundSpec)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to unmarshal raw machine provider spec: %v\", err)\n\t}\n\n\treturn &mapi.GCPMachineProviderSpec{\n\t\tTypeMeta: meta.TypeMeta{\n\t\t\tAPIVersion: \"machine.openshift.io/v1beta1\",\n\t\t\tKind: \"GCPMachineProviderSpec\",\n\t\t},\n\t\tObjectMeta: meta.ObjectMeta{},\n\t\tUserDataSecret: &core.LocalObjectReference{\n\t\t\tName: clusterinfo.UserDataSecretName,\n\t\t},\n\t\tCredentialsSecret: &core.LocalObjectReference{\n\t\t\tName: foundSpec.CredentialsSecret.Name,\n\t\t},\n\t\tCanIPForward: false,\n\t\tDeletionProtection: false,\n\t\tDisks: []*mapi.GCPDisk{{\n\t\t\tAutoDelete: true,\n\t\t\tBoot: true,\n\t\t\tSizeGB: 128,\n\t\t\tType: \"pd-ssd\",\n\t\t\tImage: getImage(windowsServerVersion),\n\t\t}},\n\t\tNetworkInterfaces: foundSpec.NetworkInterfaces,\n\t\tServiceAccounts: foundSpec.ServiceAccounts,\n\t\tTags: foundSpec.Tags,\n\t\tMachineType: foundSpec.MachineType,\n\t\tRegion: foundSpec.Region,\n\t\tZone: foundSpec.Zone,\n\t\tProjectID: foundSpec.ProjectID,\n\t}, nil\n}", "func provider1(ctx context.Context, template *gof.Template) (context.Context, error) {\n\tctx = context.WithValue(ctx, contextKeyTest, \"test\")\n\treturn ctx, nil\n}", "func newProviderConstructor(name string, fn reflection.Func) (*providerConstructor, error) {\n\tctorType := determineCtorType(fn)\n\tif ctorType == ctorUnknown {\n\t\treturn nil, fmt.Errorf(\"invalid constructor signature, got %s\", fn.Type)\n\t}\n\tprovider := &providerConstructor{\n\t\tname: name,\n\t\tcall: fn,\n\t\tctorType: ctorType,\n\t}\n\t// result type\n\trt := fn.Out(0)\n\t// constructor result with di.Inject - only addressable pointers\n\t// anonymous parameters with di.Inject - only struct\n\tif canInject(rt) && rt.Kind() != reflect.Ptr {\n\t\treturn nil, fmt.Errorf(\"di.Inject not supported for unaddressable result of constructor, use *%s instead\", rt)\n\t}\n\t// if struct is injectable, range over inject fields and parse injectable params\n\tif canInject(rt) {\n\t\tprovider.inject.fields, provider.inject.params = parseFieldParams(rt)\n\t}\n\tvar params parameterList\n\tfor i := 0; i < provider.call.NumIn(); i++ {\n\t\tin := provider.call.In(i)\n\t\tparams = append(params, parameter{\n\t\t\t// haven't found the way to specify name for type in function\n\t\t\tname: \"\",\n\t\t\ttyp: in,\n\t\t})\n\t}\n\tprovider.params = append(params, provider.inject.params...)\n\treturn provider, nil\n}", "func ForProvider(p providerconfigtypes.CloudProvider, cvr *providerconfig.ConfigVarResolver) (cloudprovidertypes.Provider, error) {\n\tif p, found := providers[p]; found {\n\t\treturn NewValidationCacheWrappingCloudProvider(p(cvr)), nil\n\t}\n\tif p, found := communityProviders[p]; found {\n\t\treturn NewValidationCacheWrappingCloudProvider(p(cvr)), nil\n\t}\n\treturn nil, ErrProviderNotFound\n}", "func (p *Provider) Provide(configurationChan chan<- dynamic.Message, pool *safe.Pool) error {\n\tctx := log.With(context.Background(), log.Str(log.ProviderName, p.name))\n\tlogger := log.FromContext(ctx)\n\n\toperation := func() error {\n\t\tif _, err := p.kvClient.Exists(path.Join(p.RootKey, \"qmslkjdfmqlskdjfmqlksjazçueznbvbwzlkajzebvkwjdcqmlsfj\"), nil); err != nil {\n\t\t\treturn fmt.Errorf(\"KV store connection error: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n\n\tnotify := func(err error, time time.Duration) {\n\t\tlogger.Errorf(\"KV connection error: %+v, retrying in %s\", err, time)\n\t}\n\terr := backoff.RetryNotify(safe.OperationWithRecover(operation), job.NewBackOff(backoff.NewExponentialBackOff()), notify)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot connect to KV server: %w\", err)\n\t}\n\n\tconfiguration, err := p.buildConfiguration()\n\tif err != nil {\n\t\tlogger.Errorf(\"Cannot build the configuration: %v\", err)\n\t} else {\n\t\tconfigurationChan <- dynamic.Message{\n\t\t\tProviderName: p.name,\n\t\t\tConfiguration: configuration,\n\t\t}\n\t}\n\n\tpool.GoCtx(func(ctxPool context.Context) {\n\t\tctxLog := log.With(ctxPool, log.Str(log.ProviderName, p.name))\n\n\t\terr := p.watchKv(ctxLog, configurationChan)\n\t\tif err != nil {\n\t\t\tlogger.Errorf(\"Cannot watch KV store: %v\", err)\n\t\t}\n\t})\n\n\treturn nil\n}", "func newExecProvider() ExecProvider {\n\treturn realExecProvider{}\n}", "func createProviderRef(env *Environment, location DescriptorLocation, yamlRef yamlProviderRef) (ProviderRef, error) {\n\treturn ProviderRef{\n\t\tenv: env,\n\t\tref: yamlRef.Name,\n\t\tparameters: CreateParameters(yamlRef.Params),\n\t\tproxy: createProxy(yamlRef.Proxy),\n\t\tenvVars: createEnvVars(yamlRef.Env),\n\t\tlocation: location,\n\t\tmandatory: true,\n\t}, nil\n}", "func (retriever *CredRetrieverRemoteFs) GetProvider() string {\n\treturn retriever.Provider\n}", "func (c *FilecoinRetrievalProviderAdmin) InitialiseProviderV2(\n\tproviderRegistrar register.ProviderRegistrar,\n\tproviderPrivKey *fcrcrypto.KeyPair,\n\tproviderPrivKeyVer *fcrcrypto.KeyVersion,\n\tlotusWalletPrivateKey string,\n\tlotusAP string,\n\tlotusAuthToken string,\n) error {\n\terr := c.AdminApiCaller.RequestInitialiseKeyV2(\n\t\tproviderRegistrar,\n\t\tproviderPrivKey,\n\t\tproviderPrivKeyVer,\n\t\tc.Settings.providerAdminPrivateKey,\n\t\tc.Settings.providerAdminPrivateKeyVer,\n\t\tlotusWalletPrivateKey,\n\t\tlotusAP,\n\t\tlotusAuthToken,\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Add this provider to the active providers list\n\tc.ActiveProvidersLock.Lock()\n\tc.ActiveProviders[providerRegistrar.GetNodeID()] = providerRegistrar\n\tc.ActiveProvidersLock.Unlock()\n\treturn nil\n}", "func NewProvider() *Provider {\n\treturn &Provider{}\n}", "func NewProvider(cfg Config) *Provider {\n\treturn &Provider{\n\t\tConfig: cfg,\n\t}\n}", "func newStorageObject(URL string, source interface{}, fileInfo os.FileInfo) storage.Object {\n\tabstract := storage.NewAbstractStorageObject(URL, source, fileInfo)\n\tresult := &object{\n\t\tAbstractObject: abstract,\n\t}\n\tresult.AbstractObject.Object = result\n\treturn result\n}", "func Provider() terraform.ResourceProvider {\n\treturn &schema.Provider{\n\t\tSchema: map[string]*schema.Schema{\n\t\t\t\"url\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"ARTIFACTORY_URL\", nil),\n\t\t\t},\n\t\t\t\"username\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"ARTIFACTORY_USERNAME\", nil),\n\t\t\t\tConflictsWith: []string{\"access_token\", \"api_key\"},\n\t\t\t},\n\t\t\t\"password\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tSensitive: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"ARTIFACTORY_PASSWORD\", nil),\n\t\t\t\tConflictsWith: []string{\"access_token\", \"api_key\"},\n\t\t\t},\n\t\t\t\"api_key\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tSensitive: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"ARTIFACTORY_API_KEY\", nil),\n\t\t\t\tConflictsWith: []string{\"username\", \"access_token\", \"password\"},\n\t\t\t},\n\t\t\t\"access_token\": {\n\t\t\t\tType: schema.TypeString,\n\t\t\t\tOptional: true,\n\t\t\t\tSensitive: true,\n\t\t\t\tDefaultFunc: schema.EnvDefaultFunc(\"ARTIFACTORY_ACCESS_TOKEN\", nil),\n\t\t\t\tConflictsWith: []string{\"username\", \"api_key\", \"password\"},\n\t\t\t},\n\t\t},\n\n\t\tResourcesMap: map[string]*schema.Resource{\n\t\t\t\"artifactory_local_repository\": resourceArtifactoryLocalRepository(),\n\t\t\t\"artifactory_remote_repository\": resourceArtifactoryRemoteRepository(),\n\t\t\t\"artifactory_virtual_repository\": resourceArtifactoryVirtualRepository(),\n\t\t\t\"artifactory_group\": resourceArtifactoryGroup(),\n\t\t\t\"artifactory_user\": resourceArtifactoryUser(),\n\t\t\t\"artifactory_permission_target\": resourceArtifactoryPermissionTarget(),\n\t\t\t\"artifactory_replication_config\": resourceArtifactoryReplicationConfig(),\n\t\t\t\"artifactory_single_replication_config\": resourceArtifactorySingleReplicationConfig(),\n\t\t\t\"artifactory_certificate\": resourceArtifactoryCertificate(),\n\t\t\t\"artifactory_api_key\": resourceArtifactoryApiKey(),\n\t\t\t\"artifactory_access_token\": resourceArtifactoryAcessToken(),\n\t\t\t// Deprecated. Remove in V3\n\t\t\t\"artifactory_permission_targets\": resourceArtifactoryPermissionTargets(),\n\t\t},\n\n\t\tDataSourcesMap: map[string]*schema.Resource{\n\t\t\t\"artifactory_file\": dataSourceArtifactoryFile(),\n\t\t\t\"artifactory_fileinfo\": dataSourceArtifactoryFileInfo(),\n\t\t},\n\n\t\tConfigureFunc: providerConfigure,\n\t}\n}", "func (a *Application) RegisterProvider() {\n\n}", "func Provider() terraform.ResourceProvider {\n\treturn &schema.Provider{\n\t\tResourcesMap: map[string]*schema.Resource{\n\t\t\t\"sshcommand_command\": resourceCommand(),\n\t\t},\n\t\tDataSourcesMap: map[string]*schema.Resource{\n\t\t\t\"sshcommand_command\": dataSourceCommand(),\n\t\t},\n\t}\n}", "func NewVaultMountStorageProvider(baselog logr.Logger) builderrest.ResourceHandlerProvider {\n\n\tvaultMountResource := vaultMountResource{\n\t\tlog: baselog.WithName(\"VaultMountResource\"),\n\t\tisNamespaced: (&redhatcopv1alpha1.SecretEngine{}).NamespaceScoped(),\n\t\tnewFunc: (&redhatcopv1alpha1.SecretEngine{}).New,\n\t\tnewListFunc: (&redhatcopv1alpha1.SecretEngine{}).NewList,\n\t\twatchers: make(map[int]*jsonWatch, 10),\n\t}\n\n\treturn func(scheme *runtime.Scheme, getter generic.RESTOptionsGetter) (rest.Storage, error) {\n\t\tclient, err := getClient(baselog)\n\n\t\tif err != nil {\n\t\t\tbaselog.Error(err, \"unable to set up vault client\")\n\t\t\treturn nil, err\n\t\t}\n\t\tvaultMountResource.vclient = client\n\t\treturn &vaultMountResource, nil\n\t}\n}", "func NewProvider(params ...SDKContextParams) *Provider {\n\tctxProvider := Provider{}\n\tfor _, param := range params {\n\t\tparam(&ctxProvider)\n\t}\n\treturn &ctxProvider\n}", "func (*providerCmd) RunUseProvider(f factory.Factory, cobraCmd *cobra.Command, args []string) error {\n\t// Get provider configuration\n\tloader := f.NewCloudConfigLoader()\n\tproviderConfig, err := loader.Load()\n\tif err != nil {\n\t\treturn errors.Errorf(\"Error loading provider config: %v\", err)\n\t}\n\n\tproviderName := \"\"\n\tif len(args) > 0 {\n\t\tproviderName = args[0]\n\t} else {\n\t\tproviderNames := make([]string, 0, len(providerConfig.Providers))\n\t\tfor _, provider := range providerConfig.Providers {\n\t\t\tproviderNames = append(providerNames, strings.TrimSpace(provider.Name))\n\t\t}\n\n\t\tproviderName, err = log.GetInstance().Question(&survey.QuestionOptions{\n\t\t\tQuestion: \"Please select a default provider\",\n\t\t\tDefaultValue: providerConfig.Default,\n\t\t\tOptions: providerNames,\n\t\t\tSort: true,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tprovider := config.GetProvider(providerConfig, providerName)\n\tif provider == nil {\n\t\treturn errors.Errorf(\"Error provider %s does not exist! Did you run `devspace add provider %s` first?\", providerName, providerName)\n\t}\n\n\tproviderConfig.Default = provider.Name\n\terr = loader.Save(providerConfig)\n\tif err != nil {\n\t\treturn errors.Errorf(\"Couldn't save provider config: %v\", err)\n\t}\n\n\tlog.GetInstance().Donef(\"Successfully changed default cloud provider to %s\", providerName)\n\treturn nil\n}" ]
[ "0.6734028", "0.6443289", "0.63513434", "0.6128527", "0.60051745", "0.5913899", "0.58697", "0.5826189", "0.5823582", "0.57931125", "0.5782339", "0.5731485", "0.5709131", "0.57041174", "0.5673461", "0.5671742", "0.5620971", "0.5591743", "0.5571989", "0.5570918", "0.5561377", "0.5561297", "0.55041754", "0.5500931", "0.54926926", "0.5468639", "0.5460478", "0.54469913", "0.54392177", "0.5430322", "0.5412565", "0.5395307", "0.5372042", "0.53554296", "0.5354987", "0.5338837", "0.5333701", "0.53281265", "0.5269294", "0.52630264", "0.5259954", "0.52495116", "0.52409345", "0.5211239", "0.51947606", "0.51859254", "0.5182382", "0.51816785", "0.5176989", "0.516786", "0.51668495", "0.5160348", "0.5154543", "0.51529074", "0.5139409", "0.5136627", "0.5125485", "0.5125127", "0.51058036", "0.5094574", "0.5094354", "0.5093716", "0.5076244", "0.50748223", "0.5064993", "0.50525147", "0.5024576", "0.5015308", "0.5002735", "0.4997135", "0.4995925", "0.49820226", "0.4977032", "0.49683005", "0.49649853", "0.49642786", "0.4962508", "0.49620193", "0.49600342", "0.4959481", "0.49591905", "0.4957375", "0.49516648", "0.49515557", "0.49490923", "0.49473152", "0.49380124", "0.49373674", "0.4933979", "0.49328387", "0.4926013", "0.49235827", "0.49212998", "0.4920135", "0.49155396", "0.4903363", "0.4903079", "0.4899635", "0.48994213", "0.48973602" ]
0.6699755
1
NewConf is redirect hook for fabric/fsblkstorage NewConf()
func NewConf(blockStorageDir string, maxBlockfileSize int) *blkstorage.Conf { return blkstorage.NewConf(blockStorageDir, maxBlockfileSize) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewConf(blockStorageDir string, maxBlockfileSize int) *fsblkstorage.Conf {\n\treturn fsblkstorage.NewConf(blockStorageDir, maxBlockfileSize)\n}", "func newConfig(appName string, pathToKeybase string, log Log, ignoreSnooze bool) (*config, error) {\n\tcfg := newDefaultConfig(appName, pathToKeybase, log, ignoreSnooze)\n\terr := cfg.load()\n\treturn &cfg, err\n}", "func newConfig(envParams envParams) error {\n\t// Initialize server config.\n\tsrvCfg := newServerConfigV14()\n\n\t// If env is set for a fresh start, save them to config file.\n\tif globalIsEnvCreds {\n\t\tsrvCfg.SetCredential(envParams.creds)\n\t}\n\n\tif globalIsEnvBrowser {\n\t\tsrvCfg.SetBrowser(envParams.browser)\n\t}\n\n\t// Create config path.\n\tif err := createConfigDir(); err != nil {\n\t\treturn err\n\t}\n\n\t// hold the mutex lock before a new config is assigned.\n\t// Save the new config globally.\n\t// unlock the mutex.\n\tserverConfigMu.Lock()\n\tserverConfig = srvCfg\n\tserverConfigMu.Unlock()\n\n\t// Save config into file.\n\treturn serverConfig.Save()\n}", "func newFrmConf() *InstConfig {\n\treturn &InstConfig{\n\t\t\"127.0.0.1:8080\",\n\t\t\"DefaultService\",\n\t\t2097152,\n\t\t5,\n\t\tnil,\n\t\tnil,\n\t\tfalse,\n\t}\n}", "func NewConf(id, root string) *Conf {\n\tc := &Conf{\n\t\tid: id,\n\t\troot: root,\n\t}\n\n\tts, err := store.NewLocalStore(c.TriggerDataPath(), store.JSONMarshaler{})\n\tif err != nil {\n\t\tlog.Fatal(\"cant make trigger store\", c.TriggerDataPath(), err)\n\t}\n\n\ths, err := store.NewLocalStore(c.HistoryDataPath(), store.JSONMarshaler{})\n\tif err != nil {\n\t\tlog.Fatal(\"cant make history store\", c.HistoryDataPath(), err)\n\t}\n\tc.TriggerStore = ts\n\tc.HistoryStore = hs\n\treturn c\n}", "func newConfig() (*rest.Config, error) {\n // try in cluster config first, it should fail quickly on lack of env vars\n cfg, err := inClusterConfig()\n if err != nil {\n cfg, err = clientcmd.BuildConfigFromFlags(\"\", clientcmd.RecommendedHomeFile)\n if err != nil {\n return nil, errors.Wrap(err, \"failed to get InClusterConfig and Config from kube_config\")\n }\n }\n return cfg, nil\n}", "func newClientConfig(fname, id, name, serverKey, serverUrl string) (err error) {\n\tconfig := Config{\n\t\tid,\n\t\tname,\n\t\t\"client\",\n\t\t\"\",\n\t\tserverKey,\n\t\tserverUrl,\n\t\tDEFAULT_PROCESS_USER,\n\t\tDEFAULT_PROCESS_LOCK,\n\t\tDEFAULT_PROCESS_LOG,\n\t\tDEFAULT_BASE_DIR,\n\t\tDEFAULT_DATA_DIR,\n\t\tDEFAULT_HTTP_LISTEN,\n\t\tfname,\n\t}\n\n\treturn SaveConfig(config)\n}", "func newServerConfig(fname, id, name, passWord, serverKey string) (err error) {\n\tconfig := Config{\n\t\tid,\n\t\tname,\n\t\t\"server\",\n\t\tpassWord,\n\t\tserverKey,\n\t\tDEFAULT_SERVER_URL,\n\t\tDEFAULT_PROCESS_USER,\n\t\tDEFAULT_PROCESS_LOCK,\n\t\tDEFAULT_PROCESS_LOG,\n\t\tDEFAULT_BASE_DIR,\n\t\tDEFAULT_DATA_DIR,\n\t\tDEFAULT_HTTP_LISTEN,\n\t\tfname,\n\t}\n\n\treturn SaveConfig(config)\n}", "func newcfgfile(fp string) *cfgfile.ConfigFile {\n\treturn &cfgfile.ConfigFile{\n\t\tSrvName: \"agentd\",\n\t\tFilename: fp,\n\t}\n}", "func newBlockfileMgr(id string, conf *Conf, indexConfig *blkstorage.IndexConfig, indexStore *leveldbhelper.DBHandle) *blockfileMgr {\n\tlogger.Debugf(\"newBlockfileMgr() initializing file-based block storage for ledger: %s \", id)\n\tvar rwMutexs []*sync.RWMutex\n\n\t//Determine the root directory for the blockfile storage, if it does not exist create it\n\trootDir := conf.getLedgerBlockDir(id)\n\t_, err := util.CreateDirIfMissing(rootDir)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Error: %s\", err))\n\t}\n\t// Instantiate the manager, i.e. blockFileMgr structure\n\tmgr := &blockfileMgr{rootDir: rootDir, conf: conf, db: indexStore, rwMutexs: rwMutexs}\n\n\t// cp = checkpointInfo, retrieve from the database the file suffix or number of where blocks were stored.\n\t// It also retrieves the current size of that file and the last block number that was written to that file.\n\t// At init checkpointInfo:latestFileChunkSuffixNum=[0], latestFileChunksize=[0], lastBlockNumber=[0]\n\tcpInfo, err := mgr.loadCurrentInfo()\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not get block file info for current block file from db: %s\", err))\n\t}\n\tif cpInfo == nil {\n\t\tlogger.Info(`Getting block information from block storage`)\n\t\tif cpInfo, err = constructCheckpointInfoFromBlockFiles(rootDir); err != nil {\n\t\t\tpanic(fmt.Sprintf(\"Could not build checkpoint info from block files: %s\", err))\n\t\t}\n\t\tlogger.Debugf(\"Info constructed by scanning the blocks dir = %s\", spew.Sdump(cpInfo))\n\t} else {\n\t\tlogger.Debug(`Synching block information from block storage (if needed)`)\n\t\tsyncCPInfoFromFS(rootDir, cpInfo)\n\t}\n\terr = mgr.saveCurrentInfo(cpInfo, true)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not save next block file info to db: %s\", err))\n\t}\n\n\tmgr.oldestFileChunkSuffixNum = syncOldestFileNum(rootDir)\n\t//If start up is a restart of an existing storage,new the rwMutex for the files\n\tif conf.dumpConf.Enabled {\n\t\tfor i := 0; i <= cpInfo.latestFileChunkSuffixNum; i++ {\n\t\t\trwMutex := new(sync.RWMutex)\n\t\t\tmgr.rwMutexs = append(mgr.rwMutexs, rwMutex)\n\t\t}\n\t}\n\tmgr.dumpMutex = new(sync.Mutex)\n\n\t//Open a writer to the file identified by the number and truncate it to only contain the latest block\n\t// that was completely saved (file system, index, cpinfo, etc)\n\tcurrentFileWriter, err := newBlockfileWriter(deriveBlockfilePath(rootDir, cpInfo.latestFileChunkSuffixNum))\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not open writer to current file: %s\", err))\n\t}\n\t//Truncate the file to remove excess past last block\n\terr = currentFileWriter.truncateFile(cpInfo.latestFileChunksize)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not truncate current file to known size in db: %s\", err))\n\t}\n\n\t// Create a new KeyValue store database handler for the blocks index in the keyvalue database\n\tmgr.index = newBlockIndex(indexConfig, indexStore)\n\n\t// Update the manager with the checkpoint info and the file writer\n\tmgr.cpInfo = cpInfo\n\tmgr.currentFileWriter = currentFileWriter\n\t// Create a checkpoint condition (event) variable, for the goroutine waiting for\n\t// or announcing the occurrence of an event.\n\tmgr.cpInfoCond = sync.NewCond(&sync.Mutex{})\n\n\t// init BlockchainInfo for external API's\n\tbcInfo := &common.BlockchainInfo{\n\t\tHeight: 0,\n\t\tCurrentBlockHash: nil,\n\t\tPreviousBlockHash: nil}\n\n\tif !cpInfo.isChainEmpty {\n\t\t//If start up is a restart of an existing storage, sync the index from block storage and update BlockchainInfo for external API's\n\t\tmgr.syncIndex()\n\t\tlastBlockHeader, err := mgr.retrieveBlockHeaderByNumber(cpInfo.lastBlockNumber)\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"Could not retrieve header of the last block form file: %s\", err))\n\t\t}\n\t\tlastBlockHash := lastBlockHeader.Hash()\n\t\tpreviousBlockHash := lastBlockHeader.PreviousHash\n\t\tbcInfo = &common.BlockchainInfo{\n\t\t\tHeight: cpInfo.lastBlockNumber + 1,\n\t\t\tCurrentBlockHash: lastBlockHash,\n\t\t\tPreviousBlockHash: previousBlockHash}\n\t}\n\tmgr.bcInfo.Store(bcInfo)\n\treturn mgr\n}", "func newConfig() (config quick.Config, err error) {\n\tconf := newConfigV101()\n\tconfig, err = quick.New(conf)\n\tif err != nil {\n\t\treturn nil, NewIodine(iodine.New(err, nil))\n\t}\n\treturn config, nil\n}", "func (b *mConf) initConfig() {\n\t// get environment variables\n\tconfPath := os.Getenv(envConfPSMBTCP) // config file location\n\tif confPath == \"\" {\n\t\tconfPath = defaultConfigPath\n\t}\n\tfilePath := path.Join(confPath, keyConfigName) + \".\" + keyConfigType\n\tendpoint := os.Getenv(envBackendEndpoint) // backend endpoint, i.e., consul url\n\n\tif endpoint == \"\" {\n\t\tlog.WithField(\"file path\", filePath).Debug(\"Try to load 'local' config file\")\n\t} else {\n\t\tlog.WithField(\"file path\", filePath).Debug(\"Try to load 'remote' config file\")\n\t\tclient, err := api.NewClient(&api.Config{Address: endpoint})\n\t\tif err != nil {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"err\": err,\n\t\t\t\t\"file path\": filePath,\n\t\t\t}).Warn(\"Fail to load 'remote' config file, backend not found!\")\n\t\t\treturn\n\t\t}\n\t\tpair, _, err := client.KV().Get(filePath, nil)\n\t\tif err != nil {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"err\": err,\n\t\t\t\t\"file path\": filePath,\n\t\t\t}).Warn(\"Fail to load 'remote' config file from backend, value not found!\")\n\t\t\treturn\n\t\t}\n\t\t// dump to file\n\t\tif err := ioutil.WriteFile(defaultTempPath, pair.Value, 0644); err != nil {\n\t\t\tlog.WithFields(log.Fields{\n\t\t\t\t\"err\": err,\n\t\t\t\t\"file path\": defaultTempPath,\n\t\t\t}).Warn(\"Fail to load 'remote' config file from backend, temp file not found!\")\n\t\t\treturn\n\t\t}\n\t\tfilePath = defaultTempPath\n\t}\n\tm := multiconfig.NewWithPath(filePath)\n\tm.MustLoad(b.m) // Populated the struct\n\tif endpoint == \"\" {\n\t\tlog.WithField(\"file\", filePath).Info(\"Read 'local' config file successfully\")\n\t} else {\n\t\tlog.WithField(\"file\", filePath).Info(\"Read 'remote' config file successfully\")\n\t}\n}", "func newConfig() *config {\n\t/*According to Liqo Agent installation process, first check if\n\tuser has defined XDG_DATA_HOME env variable. Otherwise, use the\n\tfallback directory according to XDG specifications\n\t(www.freedesktop.com)*/\n\tXDGBaseDir, present := os.LookupEnv(\"XDG_DATA_HOME\")\n\tif !present {\n\t\tXDGBaseDir = filepath.Join(os.Getenv(\"HOME\"), \".local/share\")\n\t}\n\tliqoPath := filepath.Join(XDGBaseDir, \"liqo\")\n\tif err := os.Setenv(client.EnvLiqoPath, liqoPath); err != nil {\n\t\tos.Exit(1)\n\t}\n\tconf := &config{notifyLevel: NotifyLevelMax, notifyIconPath: filepath.Join(liqoPath, \"icons\")}\n\tconf.notifyTranslateMap = make(map[NotifyLevel]string)\n\tconf.notifyTranslateReverseMap = make(map[string]NotifyLevel)\n\tconf.notifyTranslateMap[NotifyLevelOff] = NotifyLevelOffDescription\n\tconf.notifyTranslateMap[NotifyLevelMin] = NotifyLevelMinDescription\n\tconf.notifyTranslateMap[NotifyLevelMax] = NotifyLevelMaxDescription\n\tfor k, v := range conf.notifyTranslateMap {\n\t\tconf.notifyTranslateReverseMap[v] = k\n\t}\n\treturn conf\n}", "func newConfig(path string) *Config {\n\tfile, e := ioutil.ReadFile(path)\n\tif e != nil {\n\t\tlog.Fatalf(\"config error: %v\", e)\n\t}\n\tvar cfg Config\n\te = json.Unmarshal(file, &cfg)\n\tif e != nil {\n\t\tlog.Fatalf(\"config error: %v\", e)\n\t}\n\n\t// redirect logging to a file\n\twriter, err := os.OpenFile(\"gorobot.log\", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to open file log: %v\", err)\n\t}\n\tlog.SetOutput(writer)\n\treturn &cfg\n}", "func (c *Config) setDefault() {\n\tif c.StoreVolumeCache < 1 {\n\t\tc.StoreVolumeCache = configStoreVolumeCache\n\t}\n\tif len(c.ServerId) == 0 {\n\t\tpanic(\"config server_id must set\")\n\t}\n\tif len(c.Rack) == 0 {\n\t\tpanic(\"config rack must set\")\n\t}\n\tif len(c.VolumeIndex) == 0 {\n\t\tc.VolumeIndex = configVolumeIndex\n\t}\n\tif len(c.FreeVolumeIndex) == 0 {\n\t\tc.FreeVolumeIndex = configFreeVolumeIndex\n\t}\n\tif c.NeedleMaxSize < 1 || c.NeedleMaxSize > configNeedleMaxSize {\n\t\tc.NeedleMaxSize = configNeedleMaxSize\n\t}\n\tif c.BatchMaxNum < 2 || c.BatchMaxNum > configBatchMaxNum {\n\t\tc.BatchMaxNum = configBatchMaxNum\n\t}\n\tif c.VolumeDelChan < 1 {\n\t\tc.VolumeDelChan = configVolumeDelChan\n\t}\n\tif c.VolumeSigCnt < 1 {\n\t\tc.VolumeSigCnt = configVolumeSigCnt\n\t}\n\tif c.VolumeSigTime < 1 {\n\t\tc.VolumeSigTime = configVolumeSigTime\n\t}\n\tif c.IndexRingBuffer < configIndexRingBuffer {\n\t\tc.IndexRingBuffer = configIndexRingBuffer\n\t}\n\tif c.IndexSigCnt < 1 {\n\t\tc.IndexSigCnt = configIndexSigCnt\n\t}\n\tif c.IndexSigTime < 1*time.Second {\n\t\tc.IndexSigTime = configIndexSigTime\n\t}\n\tif len(c.PprofListen) == 0 {\n\t\tc.PprofListen = configPprofListen\n\t}\n\tif len(c.StatListen) == 0 {\n\t\tc.StatListen = configStatListen\n\t}\n\tif len(c.ApiListen) == 0 {\n\t\tc.ApiListen = configApiListen\n\t}\n\tif len(c.AdminListen) == 0 {\n\t\tc.AdminListen = configAdminListen\n\t}\n\tif len(c.ZookeeperAddrs) == 0 {\n\t\tc.ZookeeperAddrs = configZookeeperAddrs\n\t}\n\tif c.ZookeeperTimeout < 1*time.Second {\n\t\tc.ZookeeperTimeout = configZookeeperTimeout\n\t}\n\tif len(c.ZookeeperRoot) == 0 {\n\t\tc.ZookeeperRoot = configZookeeperRoot\n\t}\n}", "func initConfiguration() {\n\tk = confident.New()\n\tk.WithConfiguration(&Conf)\n\tk.Name = \"config\"\n\tk.Type = \"json\"\n\tk.Path = configDirPath()\n\tk.Path = configDirPathEnsureExists()\n\tk.Permission = os.FileMode(0644)\n\tlogging.LogDebugf(\"config/initConfiguration() - Conf before read: %#v\", Conf)\n\tk.Read()\n\tlogging.LogDebugf(\"config/initConfiguration() - Conf after read: %#v\", Conf)\n\tif *dpRestURL != \"\" || *dpSomaURL != \"\" {\n\t\tif *dpConfigName != \"\" {\n\t\t\tvalidateDpConfigName()\n\t\t\tConf.DataPowerAppliances[*dpConfigName] = DataPowerAppliance{Domain: *dpDomain, Proxy: *proxy, RestUrl: *dpRestURL, SomaUrl: *dpSomaURL, Username: *dpUsername, Password: *dpPassword}\n\t\t\tCurrentApplianceName = *dpConfigName\n\t\t} else {\n\t\t\tConf.DataPowerAppliances[PreviousApplianceName] = DataPowerAppliance{Domain: *dpDomain, Proxy: *proxy, RestUrl: *dpRestURL, SomaUrl: *dpSomaURL, Username: *dpUsername, Password: *dpPassword}\n\t\t\tCurrentApplianceName = PreviousApplianceName\n\t\t}\n\t\tk.Persist()\n\t\tlogging.LogDebugf(\"config/initConfiguration() - Conf after persist: %#v\", Conf)\n\t}\n\tCurrentAppliance = DataPowerAppliance{Domain: *dpDomain, Proxy: *proxy, RestUrl: *dpRestURL, SomaUrl: *dpSomaURL, Username: *dpUsername, Password: *dpPassword}\n}", "func newConfig() Config {\n\treturn Config{\n\t\tDefaultContainerConfig: newDefaultContainerConfig(),\n\t\tContainersConfig: map[string]ContainerConfig{},\n\t\tExclude: []string{},\n\t}\n}", "func newConfig(opts ...Option) config {\n\tc := config{\n\t\tMeterProvider: otel.GetMeterProvider(),\n\t}\n\tfor _, opt := range opts {\n\t\topt.apply(&c)\n\t}\n\treturn c\n}", "func newConfigV101() *configV1 {\n\tconf := new(configV1)\n\tconf.Version = mcCurrentConfigVersion\n\t// make sure to allocate map's otherwise Golang\n\t// exits silently without providing any errors\n\tconf.Hosts = make(map[string]*hostConfig)\n\tconf.Aliases = make(map[string]string)\n\n\tlocalHostConfig := new(hostConfig)\n\tlocalHostConfig.AccessKeyID = \"\"\n\tlocalHostConfig.SecretAccessKey = \"\"\n\n\ts3HostConf := new(hostConfig)\n\ts3HostConf.AccessKeyID = globalAccessKeyID\n\ts3HostConf.SecretAccessKey = globalSecretAccessKey\n\n\t// Your example host config\n\texampleHostConf := new(hostConfig)\n\texampleHostConf.AccessKeyID = globalAccessKeyID\n\texampleHostConf.SecretAccessKey = globalSecretAccessKey\n\n\tplayHostConfig := new(hostConfig)\n\tplayHostConfig.AccessKeyID = \"\"\n\tplayHostConfig.SecretAccessKey = \"\"\n\n\tdlHostConfig := new(hostConfig)\n\tdlHostConfig.AccessKeyID = \"\"\n\tdlHostConfig.SecretAccessKey = \"\"\n\n\tconf.Hosts[exampleHostURL] = exampleHostConf\n\tconf.Hosts[\"localhost:*\"] = localHostConfig\n\tconf.Hosts[\"127.0.0.1:*\"] = localHostConfig\n\tconf.Hosts[\"s3*.amazonaws.com\"] = s3HostConf\n\tconf.Hosts[\"play.minio.io:9000\"] = playHostConfig\n\tconf.Hosts[\"dl.minio.io:9000\"] = dlHostConfig\n\n\taliases := make(map[string]string)\n\taliases[\"s3\"] = \"https://s3.amazonaws.com\"\n\taliases[\"play\"] = \"https://play.minio.io:9000\"\n\taliases[\"dl\"] = \"https://dl.minio.io:9000\"\n\taliases[\"localhost\"] = \"http://localhost:9000\"\n\tconf.Aliases = aliases\n\n\treturn conf\n}", "func NewConf() *Conf {\n\tc := new(Conf)\n\tc.loadDefault()\n\tc.loadFile()\n\tc.loadEnv()\n\tc.loadFlags(os.Args)\n\tc.preloadTemplates()\n\treturn c\n}", "func (s *BasevhdlListener) EnterConfiguration_declarative_part(ctx *Configuration_declarative_partContext) {\n}", "func (m *Mosn) inheritConfig(c *v2.MOSNConfig) (err error) {\n\tm.Config = c\n\tserver.EnableInheritOldMosnconfig(c.InheritOldMosnconfig)\n\n\t// default is graceful mode, turn graceful off by set it to false\n\tif !c.DisableUpgrade && server.IsReconfigure() {\n\t\tm.isFromUpgrade = true\n\t\tif err = m.inheritHandler(); err != nil {\n\t\t\treturn\n\t\t}\n\t}\n\tlog.StartLogger.Infof(\"[mosn] [NewMosn] new mosn created\")\n\t// start init services\n\tif err = store.StartService(m.Upgrade.InheritListeners); err != nil {\n\t\tlog.StartLogger.Errorf(\"[mosn] [NewMosn] start service failed: %v, exit\", err)\n\t}\n\treturn\n}", "func (s *BasevhdlListener) EnterBlock_configuration(ctx *Block_configurationContext) {}", "func (c *config) newConfig(redirect string) *oauth2.Config {\n\treturn &oauth2.Config{\n\t\tClientID: c.Client,\n\t\tClientSecret: c.Secret,\n\t\tEndpoint: oauth2.Endpoint{\n\t\t\tAuthURL: fmt.Sprintf(\"%s/site/oauth2/authorize\", c.URL),\n\t\t\tTokenURL: fmt.Sprintf(\"%s/site/oauth2/access_token\", c.URL),\n\t\t},\n\t\tRedirectURL: fmt.Sprintf(\"%s/authorize\", redirect),\n\t}\n}", "func initNConf() {\n\t_, b, _, _ := runtime.Caller(0)\n\twdir := filepath.Dir(b)\n\tfmt.Println(\"wdir:\", wdir)\n\tnconf.Init(wdir)\n}", "func initNConf() {\n\t_, b, _, _ := runtime.Caller(0)\n\twdir := filepath.Dir(b)\n\tfmt.Println(\"wdir:\", wdir)\n\tnconf.Init(wdir)\n}", "func (f *Flags) newConfig() *Config {\n\tc := new(Config)\n\t// Default values defined here will be overridden by unmarshaling a config file\n\tc.General.Loglevel = \"warn\"\n\tc.General.LogToFile = false // By default, log to stdout/stderr\n\tc.General.LogToJournal = false // Don't log to journal by default\n\t// Config items in the Files section default to a path defined by the --dir flag\n\tc.Files.Pubkey = path.Join(f.Dir, \"key.txt\")\n\tc.Files.Pubring = path.Join(f.Dir, \"pubring.mix\")\n\tc.Files.Secring = path.Join(f.Dir, \"secring.mix\")\n\tc.Files.Mlist2 = path.Join(f.Dir, \"mlist2.txt\")\n\tc.Files.Adminkey = path.Join(f.Dir, \"adminkey.txt\")\n\tc.Files.Help = path.Join(f.Dir, \"help.txt\")\n\tc.Files.Pooldir = path.Join(f.Dir, \"pool\")\n\tc.Files.Maildir = path.Join(f.Dir, \"Maildir\")\n\tc.Files.IDlog = path.Join(f.Dir, \"idlog\")\n\tc.Files.ChunkDB = path.Join(f.Dir, \"chunkdb\")\n\tc.Files.Logfile = path.Join(f.Dir, \"yamn.log\")\n\tc.Urls.Fetch = true\n\tc.Urls.Pubring = \"http://www.mixmin.net/yamn/pubring.mix\"\n\tc.Urls.Mlist2 = \"http://www.mixmin.net/yamn/mlist2.txt\"\n\tc.Mail.Sendmail = false\n\tc.Mail.Outfile = false\n\tc.Mail.SMTPRelay = \"fleegle.mixmin.net\"\n\tc.Mail.SMTPPort = 587\n\tc.Mail.UseTLS = true\n\tc.Mail.MXRelay = true\n\tc.Mail.OnionRelay = false // Allow .onion addresses as MX relays\n\tc.Mail.Sender = \"\"\n\tc.Mail.Username = \"\"\n\tc.Mail.Password = \"\"\n\tc.Mail.OutboundName = \"Anonymous Remailer\"\n\tc.Mail.OutboundAddy = \"remailer@domain.invalid\"\n\tc.Mail.CustomFrom = false\n\tc.Stats.Minrel = 98.0\n\tc.Stats.Relfinal = 99.0\n\tc.Stats.Minlat = 2\n\tc.Stats.Maxlat = 60\n\tc.Stats.Chain = \"*,*,*\"\n\tc.Stats.Numcopies = 1\n\tc.Stats.Distance = 2\n\tc.Stats.StaleHrs = 24\n\tc.Stats.UseExpired = false\n\tc.Pool.Size = 5 // Good for startups, too small for established\n\tc.Pool.Rate = 65\n\tc.Pool.MinSend = 5 // Only used in Binomial Mix Pools\n\tc.Pool.Loop = 300\n\tc.Pool.MaxAge = 28\n\tc.Remailer.Name = \"anon\"\n\tc.Remailer.Address = \"mix@nowhere.invalid\"\n\tc.Remailer.Exit = false\n\tc.Remailer.MaxSize = 12\n\tc.Remailer.IDexp = 14\n\tc.Remailer.ChunkExpire = 60\n\t// Discard messages if packet timestamp exceeds this age in days\n\tc.Remailer.MaxAge = 14\n\tc.Remailer.Keylife = 14\n\tc.Remailer.Keygrace = 28\n\tc.Remailer.Daemon = false\n\treturn c\n}", "func (s *BrokerSuite) newTestBrokerConf(clientID string) BrokerConf {\n\tconf := NewBrokerConf(clientID)\n\tconf.ClusterConnectionConf.DialTimeout = 400 * time.Millisecond\n\tconf.LeaderRetryLimit = 10\n\tconf.LeaderRetryWait = 2 * time.Millisecond\n\treturn conf\n}", "func newConfig() (*config, error) {\n\tec2Metadata := ec2metadata.New(session.Must(session.NewSession()))\n\tregion, err := ec2Metadata.Region()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to get region from ec2 metadata\")\n\t}\n\n\tinstanceID, err := ec2Metadata.GetMetadata(\"instance-id\")\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to get instance id from ec2 metadata\")\n\t}\n\n\tmac, err := ec2Metadata.GetMetadata(\"mac\")\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to get mac from ec2 metadata\")\n\t}\n\n\tsecurityGroups, err := ec2Metadata.GetMetadata(\"security-groups\")\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to get security groups from ec2 metadata\")\n\t}\n\n\tinterfaces, err := ec2Metadata.GetMetadata(\"network/interfaces/macs\")\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to get interfaces from ec2 metadata\")\n\t}\n\n\tsubnet, err := ec2Metadata.GetMetadata(\"network/interfaces/macs/\" + mac + \"/subnet-id\")\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to get subnet from ec2 metadata\")\n\t}\n\n\tvpc, err := ec2Metadata.GetMetadata(\"network/interfaces/macs/\" + mac + \"/vpc-id\")\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"unable to get vpc from ec2 metadata\")\n\t}\n\n\treturn &config{region: region,\n\t\tsubnet: subnet,\n\t\tindex: int64(len(strings.Split(interfaces, \"\\n\"))),\n\t\tinstanceID: instanceID,\n\t\tsecurityGroups: strings.Split(securityGroups, \"\\n\"),\n\t\tvpc: vpc,\n\t}, nil\n}", "func NewConf(filename string) (*Conf, error) {\n\tfullFilename, e := ensure(filename)\n\tif e != nil {\n\t\treturn nil, e\n\t}\n\treturn &Conf{\n\t\tfilename: fullFilename,\n\t}, nil\n}", "func New() *Conf {\n\treturn &Conf{[]byte{}, new(sync.RWMutex), newElem(Node, \"root\")}\n}", "func (app *application) initConfFromFile() {\n\n\tvar fp confFileContent\n\n\tapp.infoLog.Printf(\"Reading config parameters from %s\", app.confFile)\n\tfdata, err := ioutil.ReadFile(app.confFile)\n\tif err != nil {\n\t\tapp.errorLog.Printf(\"Reading file %s failed err=%v\\n\", app.confFile, err)\n\t\treturn\n\t}\n\terr = json.Unmarshal(fdata, &fp)\n\tif err != nil {\n\t\tapp.errorLog.Printf(\"Unmarshal err=%v\\n\", err)\n\t\treturn\n\t}\n\n\tif (app.basicAuthUser != fp.BasicAuthUser) || (app.basicAuthPW != fp.BasicAuthPW) {\n\t\tapp.changeBasicAuth(fp.BasicAuthUser, fp.BasicAuthPW)\n\t}\n\n\tif app.debugEnabled != fp.DebugEnabled {\n\t\tapp.debugEnabled = fp.DebugEnabled\n\t\tapp.infoLog.Printf(\"Changing debug to %v\", app.debugEnabled)\n\t\tapp.debLog.SetOutput(ioutil.Discard)\n\t\tif app.debugEnabled {\n\t\t\tapp.debLog.SetOutput(app.logFile)\n\t\t}\n\t}\n\n\t// if (app.iptTbl != fp.IptTbl) && (fp.IptTbl != \"filter\") {\n\t// \tapp.errorLog.Printf(\"WARNING Change of iptables table value is not supported and this will break things - old table=%v, new table=%v\\n\", app.iptTbl, fp.IptTbl)\n\t// }\n\t// app.iptTbl = fp.IptTbl\n\n\tdel, crea := checkDiffChains(app.iptChains, fp.IptChains)\n\tif len(crea) > 0 {\n\t\tfor _, chain := range crea {\n\t\t\terr = app.ipt.NewChain(app.iptTbl, chain)\n\t\t\tif err != nil {\n\t\t\t\t// app.infoLog.Printf(\"Could not create chain=%s in table=%s; trying ClearChain\", chain, app.iptTbl)\n\t\t\t\terr = app.ipt.ClearChain(app.iptTbl, chain)\n\t\t\t\tif err != nil {\n\t\t\t\t\tapp.errorLog.Printf(\"ClearChain of chain=%s in table=%s failed: %v\\n\", chain, app.iptTbl, err)\n\t\t\t\t\tapp.errorLog.Println(\"Could not create and clear chain in table\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tapp.infoLog.Printf(\"Created (or cleared) chain=%s in table=%s\", chain, app.iptTbl)\n\t\t}\n\t}\n\tif len(del) > 0 {\n\t\tfor _, chain := range del {\n\t\t\terr = app.ipt.ClearChain(app.iptTbl, chain)\n\t\t\tif err != nil {\n\t\t\t\tapp.errorLog.Printf(\"ClearChain of chain=%s in table=%s failed: %v\\n\", chain, app.iptTbl, err)\n\t\t\t\tapp.errorLog.Println(\"Cannot delete chain in table\")\n\t\t\t}\n\t\t\terr = app.ipt.DeleteChain(app.iptTbl, chain)\n\t\t\tif err != nil {\n\t\t\t\tapp.errorLog.Printf(\"DeleteChain of chain=%s in table=%s failed: %v\\n\", chain, app.iptTbl, err)\n\t\t\t}\n\t\t\tapp.infoLog.Printf(\"Deleted chain=%s in table=%s\", chain, app.iptTbl)\n\t\t}\n\t}\n\tapp.iptChains = fp.IptChains\n\n\tapp.certFile = fp.CertFile\n\tapp.keyFile = fp.KeyFile\n\t// app.srv.Addr = fp.SrvAddr\n\tapp.srv.MaxHeaderBytes = fp.SrvMaxHeaderBytes\n\tapp.srv.IdleTimeout = fp.SrvIdleTimeout.Duration\n\tapp.srv.ReadHeaderTimeout = fp.SrvReadTimeout.Duration\n\tapp.srv.WriteTimeout = fp.SrvWriteTimeout.Duration\n\tapp.srv.TLSConfig.MinVersion = tls.VersionTLS12 // defaults to 1.2\n\tif fp.TLSMinVersion == \"1.3\" {\n\t\tapp.srv.TLSConfig.MinVersion = tls.VersionTLS13\n\t}\n}", "func newConfig(serviceName string) config {\n\t// Use stdlib to parse. If it's an invalid value and doesn't parse, log it\n\t// and keep going. It should already be false on error but we force it to\n\t// be extra clear that it's failing closed.\n\tinsecure, err := strconv.ParseBool(os.Getenv(\"OTEL_EXPORTER_OTLP_INSECURE\"))\n\tif err != nil {\n\t\tinsecure = false\n\t\tlog.Println(\"Invalid boolean value in OTEL_EXPORTER_OTLP_INSECURE. Try true or false.\")\n\t}\n\n\treturn config{\n\t\tservicename: serviceName,\n\t\tendpoint: os.Getenv(\"OTEL_EXPORTER_OTLP_ENDPOINT\"),\n\t\tinsecure: insecure,\n\t}\n}", "func newMountFromConfig(mCfg *MountConfig) Mount {\n\topts := newOptionsFromConfig(mCfg)\n\treturn Mount{\n\t\tSource: mCfg.HostPath,\n\t\tDestination: mCfg.ContainerPath,\n\t\tType: newMountTypeFromConfig(mCfg),\n\t\tOptions: newMountOptions(opts),\n\t}\n}", "func writeNewDataAndUpdateVsphereConfSecret(client clientset.Interface, ctx context.Context,\n\tcsiNamespace string, cfg e2eTestConfig) error {\n\tvar result string\n\n\t// fetch current secret\n\tcurrentSecret, err := client.CoreV1().Secrets(csiNamespace).Get(ctx, configSecret, metav1.GetOptions{})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// modify vshere conf file\n\tvCenterHostnames := strings.Split(cfg.Global.VCenterHostname, \",\")\n\tusers := strings.Split(cfg.Global.User, \",\")\n\tpasswords := strings.Split(cfg.Global.Password, \",\")\n\tdataCenters := strings.Split(cfg.Global.Datacenters, \",\")\n\tports := strings.Split(cfg.Global.VCenterPort, \",\")\n\n\tresult += fmt.Sprintf(\"[Global]\\ncluster-distribution = \\\"%s\\\"\\n\"+\n\t\t\"csi-fetch-preferred-datastores-intervalinmin = %d\\n\"+\n\t\t\"query-limit = %d\\nlist-volume-threshold = %d\\n\\n\",\n\t\tcfg.Global.ClusterDistribution, cfg.Global.CSIFetchPreferredDatastoresIntervalInMin, cfg.Global.QueryLimit,\n\t\tcfg.Global.ListVolumeThreshold)\n\tfor i := 0; i < len(vCenterHostnames); i++ {\n\t\tresult += fmt.Sprintf(\"[VirtualCenter \\\"%s\\\"]\\ninsecure-flag = \\\"%t\\\"\\nuser = \\\"%s\\\"\\npassword = \\\"%s\\\"\\n\"+\n\t\t\t\"port = \\\"%s\\\"\\ndatacenters = \\\"%s\\\"\\n\\n\",\n\t\t\tvCenterHostnames[i], cfg.Global.InsecureFlag, users[i], passwords[i], ports[i], dataCenters[i])\n\t}\n\n\tresult += fmt.Sprintf(\"[Snapshot]\\nglobal-max-snapshots-per-block-volume = %d\\n\\n\",\n\t\tcfg.Snapshot.GlobalMaxSnapshotsPerBlockVolume)\n\tresult += fmt.Sprintf(\"[Labels]\\ntopology-categories = \\\"%s\\\"\\n\", cfg.Labels.TopologyCategories)\n\n\tframework.Logf(result)\n\n\t// update config secret with newly updated vshere conf file\n\tframework.Logf(\"Updating the secret to reflect new conf credentials\")\n\tcurrentSecret.Data[vSphereCSIConf] = []byte(result)\n\t_, err = client.CoreV1().Secrets(csiNamespace).Update(ctx, currentSecret, metav1.UpdateOptions{})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}", "func newConfigV1() *configV1 {\n\tconf := new(configV1)\n\tconf.Version = mcPreviousConfigVersion\n\t// make sure to allocate map's otherwise Golang\n\t// exits silently without providing any errors\n\tconf.Hosts = make(map[string]*hostConfig)\n\tconf.Aliases = make(map[string]string)\n\treturn conf\n}", "func upgradeExistingConfig(cmd *cobra.Command, cc *config.ClusterConfig) {\n\tif cc == nil {\n\t\treturn\n\t}\n\n\tif cc.VMDriver != \"\" && cc.Driver == \"\" {\n\t\tklog.Infof(\"config upgrade: Driver=%s\", cc.VMDriver)\n\t\tcc.Driver = cc.VMDriver\n\t}\n\n\tif cc.Name == \"\" {\n\t\tklog.Infof(\"config upgrade: Name=%s\", ClusterFlagValue())\n\t\tcc.Name = ClusterFlagValue()\n\t}\n\n\tif cc.KicBaseImage == \"\" {\n\t\t// defaults to kic.BaseImage\n\t\tcc.KicBaseImage = viper.GetString(kicBaseImage)\n\t\tklog.Infof(\"config upgrade: KicBaseImage=%s\", cc.KicBaseImage)\n\t}\n\n\tif cc.CPUs == 0 {\n\t\tklog.Info(\"Existing config file was missing cpu. (could be an old minikube config), will use the default value\")\n\t\tcc.CPUs = viper.GetInt(cpus)\n\t}\n\n\tif cc.Memory == 0 {\n\t\tklog.Info(\"Existing config file was missing memory. (could be an old minikube config), will use the default value\")\n\t\tmemInMB := getMemorySize(cmd, cc.Driver)\n\t\tcc.Memory = memInMB\n\t}\n\n\t// pre minikube 1.9.2 cc.KubernetesConfig.NodePort was not populated.\n\t// in minikube config there were two fields for api server port.\n\t// one in cc.KubernetesConfig.NodePort and one in cc.Nodes.Port\n\t// this makes sure api server port not be set as 0!\n\tif cc.KubernetesConfig.NodePort == 0 {\n\t\tcc.KubernetesConfig.NodePort = viper.GetInt(apiServerPort)\n\t}\n\n\tif cc.CertExpiration == 0 {\n\t\tcc.CertExpiration = constants.DefaultCertExpiration\n\t}\n\n}", "func Connect(ctx context.Context, configFile string, st storage.Storage, password string, opt ConnectOptions) error {\n\tformatBytes, err := st.GetBlock(ctx, FormatBlockID, 0, -1)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"unable to read format block\")\n\t}\n\n\tf, err := parseFormatBlock(formatBytes)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tvar lc LocalConfig\n\tlc.Storage = st.ConnectionInfo()\n\n\tif err = setupCaching(configFile, &lc, opt.CachingOptions, f.UniqueID); err != nil {\n\t\treturn errors.Wrap(err, \"unable to set up caching\")\n\t}\n\n\td, err := json.MarshalIndent(&lc, \"\", \" \")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = os.MkdirAll(filepath.Dir(configFile), 0700); err != nil {\n\t\treturn errors.Wrap(err, \"unable to create config directory\")\n\t}\n\n\tif err = ioutil.WriteFile(configFile, d, 0600); err != nil {\n\t\treturn errors.Wrap(err, \"unable to write config file\")\n\t}\n\n\t// now verify that the repository can be opened with the provided config file.\n\tr, err := Open(ctx, configFile, password, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn r.Close(ctx)\n}", "func New(conf map[string]string) *Conf {\n\treturn &Conf{\n\t\tc: conf,\n\t}\n}", "func CreateOrUpdateConfig(changeId, id, path, userMech, userId, message string, data []byte) error {\n\tvar newNode interface{}\n\terr := json.Unmarshal(data, &newNode)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"New value is not valid JSON: %v\", err)\n\t}\n\n\tlock, err := platformsync.RegionLock([]byte(id))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer lock.Unlock()\n\n\tconfigs, err := DefaultRepository.ReadConfig([]string{id})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error getting config from DAO: %v\", err)\n\t}\n\n\toldConfig := make([]byte, 0)\n\tif len(configs) == 1 {\n\t\toldConfig, err = readConfigAtPath(configs[0].Body, path)\n\n\t\tif err == ErrPathNotFound {\n\t\t\toldConfig = make([]byte, 0)\n\t\t} else if err != nil {\n\t\t\treturn fmt.Errorf(\"Error getting config at path %s : %v\", path, err)\n\t\t}\n\t}\n\n\tif path == \"\" {\n\t\t// If we are updating at the top level, it should be an object at the top level\n\t\tvar target map[string]interface{}\n\t\terr = json.Unmarshal(data, &target)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Top level config should be a JSON object\")\n\t\t}\n\n\t\treturn DefaultRepository.UpdateConfig(&ChangeSet{\n\t\t\tId: id,\n\t\t\tBody: data,\n\t\t\tTimestamp: time.Now(),\n\t\t\tUserMech: userMech,\n\t\t\tUserId: userId,\n\t\t\tMessage: message,\n\t\t\tChangeId: changeId,\n\t\t\tPath: path,\n\t\t\tOldConfig: oldConfig,\n\t\t})\n\t}\n\n\tdecoded := make(map[string]interface{})\n\tif len(configs) == 1 && len(configs[0].Body) > 0 {\n\t\terr := json.Unmarshal(configs[0].Body, &decoded)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Error parsing JSON: %v\", err)\n\t\t}\n\t}\n\n\t// Walk down the path, making sure we have all the\n\t// parent nodes we need\n\tparent := decoded\n\tparts := strings.Split(path, \"/\")\n\tfor i, part := range parts {\n\t\tif i == len(parts)-1 {\n\t\t\t// Replace final node\n\t\t\tparent[part] = newNode\n\t\t\tbreak\n\t\t}\n\n\t\tnode, ok := parent[part]\n\t\tif !ok {\n\t\t\t// Make new node\n\t\t\tparent[part] = make(map[string]interface{})\n\t\t\tparent = parent[part].(map[string]interface{})\n\t\t\tcontinue\n\t\t}\n\n\t\tparent = node.(map[string]interface{})\n\t}\n\n\tb, err := json.Marshal(decoded)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Error encoding new config: %v\", err)\n\t}\n\n\treturn DefaultRepository.UpdateConfig(&ChangeSet{\n\t\tId: id,\n\t\tBody: b,\n\t\tTimestamp: time.Now(),\n\t\tUserMech: userMech,\n\t\tUserId: userId,\n\t\tMessage: message,\n\t\tChangeId: changeId,\n\t\tPath: path,\n\t\tOldConfig: oldConfig,\n\t})\n}", "func newConfig(initiator bool) noise.Config {\n\treturn noise.Config{\n\t\tCipherSuite: cipherSuite,\n\t\tPattern: noise.HandshakeNK,\n\t\tInitiator: initiator,\n\t\tPrologue: []byte(\"dnstt 2020-04-13\"),\n\t}\n}", "func initConfig() error {\n newConfig := ClientConfig{\n Characters: []CharacterInfo{},\n }\n\n return SaveConfig(newConfig)\n}", "func newConfigDirectory(baseDirectory string) *configDirectory {\n\treturn &configDirectory{nil, baseDirectory, make([]string, 0)}\n}", "func initConfig() {\n\twd, err := os.Getwd()\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, err)\n\t\tos.Exit(-1)\n\t}\n\tsep := fmt.Sprintf(\"%c\", os.PathSeparator)\n\tif !strings.HasSuffix(wd, sep) {\n\t\twd += sep\n\t}\n\n\tconfFile = wd + \"gbb.json\"\n}", "func newConfig() *Config {\n\t// TODO: use config as default, allow setting some values per-job\n\t// and prevent config changes affecting already-running tasks\n\treturn &Config{\n\t\tPath: DefaultPath,\n\t\tDatastorePrefix: \"MP_\",\n\t\tDefaultQueue: \"\",\n\t\tShards: 8,\n\t\tOversampling: 32,\n\t\tLeaseDuration: time.Duration(30) * time.Second,\n\t\tLeaseTimeout: time.Duration(10)*time.Minute + time.Duration(30)*time.Second,\n\t\tTaskTimeout: time.Duration(10)*time.Minute - time.Duration(30)*time.Second,\n\t\tCursorTimeout: time.Duration(50) * time.Second,\n\t\tRetries: 31,\n\t\tLogVerbose: false,\n\t\tHost: \"\",\n\t}\n}", "func mustNewConfig() quick.Config {\n\tconfig, err := newConfig()\n\tif err != nil {\n\t\tconsole.Fatalf(\"Unable to instantiate a new config handler. %s\\n\", NewIodine(iodine.New(err, nil)))\n\t}\n\treturn config\n}", "func newDynconfigLocal(path string) (*dynconfigLocal, error) {\n\td := &dynconfigLocal{\n\t\tfilepath: path,\n\t}\n\n\treturn d, nil\n}", "func defaultConfig() interface{} {\n\treturn &config{\n\t\tPools: make(pools),\n\t\tConfDirPath: \"/etc/cmk\",\n\t}\n}", "func createContrailConfig(fqNameTable *FQNameTableType, tp, name, parentType string, fqName []string) (*ContrailConfig, error) {\n\tu, err := uuid.NewUUID()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tus := u.String()\n\tif (*fqNameTable)[tp] == nil {\n\t\t(*fqNameTable)[tp] = map[string]string{}\n\t}\n\tt := time.Now().String()\n\tts := strings.ReplaceAll(t, \" \", \"T\")\n\tc := ContrailConfig{\n\t\tUUID: us,\n\t\tType: tp,\n\t\tParentType: parentType,\n\t\tDisplayName: name,\n\t\tPerms2: types.PermType2{\n\t\t\tOwner: \"cloud-admin\",\n\t\t\tOwnerAccess: 7,\n\t\t\tGlobalAccess: 5,\n\t\t},\n\t\tIdPerms: types.IdPermsType{\n\t\t\tEnable: true,\n\t\t\tUuid: &types.UuidType{\n\t\t\t\tUuidMslong: binary.BigEndian.Uint64(u[:8]),\n\t\t\t\tUuidLslong: binary.BigEndian.Uint64(u[8:]),\n\t\t\t},\n\t\t\tCreated: ts,\n\t\t\tLastModified: ts,\n\t\t\tUserVisible: true,\n\t\t\tPermissions: &types.PermType{\n\t\t\t\tOwner: \"cloud-admin\",\n\t\t\t\tOwnerAccess: 7,\n\t\t\t\tOtherAccess: 7,\n\t\t\t\tGroup: \"cloud-admin-group\",\n\t\t\t\tGroupAccess: 7,\n\t\t\t},\n\t\t\tDescription: \"\",\n\t\t\tCreator: \"\",\n\t\t},\n\t\tFqName: fqName,\n\t}\n\t(*fqNameTable)[tp][fmt.Sprintf(\"%s:%s\", strings.Join(fqName, \":\"), us)] = \"null\"\n\treturn &c, nil\n}", "func NewFBConf(loggingCfgs LogsCfg, logFwdCfg *config.LogForward, entityGUID, hostname string) (fb FBCfg, e error) {\n\tfb = FBCfg{\n\t\tInputs: []FBCfgInput{},\n\t\tFilters: []FBCfgFilter{},\n\t}\n\n\tfor _, block := range loggingCfgs {\n\t\tinput, filters, external, err := parseConfigBlock(block, logFwdCfg.HomeDir)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tif (input != FBCfgInput{}) {\n\t\t\tfb.Inputs = append(fb.Inputs, input)\n\t\t}\n\n\t\tfb.Filters = append(fb.Filters, filters...)\n\n\t\tif (external != FBCfgExternal{} && fb.ExternalCfg != FBCfgExternal{}) {\n\t\t\tcfgLogger.Warn(\"External Fluent Bit configuration specified more than once. Only first one is considered, please remove any duplicates from the configuration.\")\n\t\t} else if (external != FBCfgExternal{}) {\n\t\t\tfb.ExternalCfg = external\n\t\t}\n\t}\n\n\tif (len(fb.Inputs) == 0 && fb.ExternalCfg == FBCfgExternal{}) {\n\t\treturn\n\t}\n\n\t// This record_modifier FILTER adds common attributes for all the log records\n\tfb.Filters = append(fb.Filters, FBCfgFilter{\n\t\tName: fbFilterTypeRecordModifier,\n\t\tMatch: \"*\",\n\t\tRecords: map[string]string{\n\t\t\trAttEntityGUID: entityGUID,\n\t\t\trAttPluginType: logRecordModifierSource,\n\t\t\trAttHostname: hostname,\n\t\t},\n\t})\n\n\t// Newrelic OUTPUT plugin will send all the collected logs to Vortex\n\tfb.Output = newNROutput(logFwdCfg)\n\n\treturn\n}", "func loadConfig(conf *config.Config) *Config {\n\tc := &Config{}\n\tif conf == nil {\n\t\treturn c\n\t}\n\n\tc.ClusterID = conf.GetString(\"cluster.id\")\n\tc.MasterServer = conf.GetString(\"master.server\")\n\tc.DataPath = conf.GetString(\"data.path\")\n\n\tc.LogDir = conf.GetString(\"log.dir\")\n\tc.LogModule = conf.GetString(\"log.module\")\n\tc.LogLevel = conf.GetString(\"log.level\")\n\n\tif diskQuota := conf.GetString(\"disk.quota\"); diskQuota != \"\" {\n\t\tc.DiskQuota, _ = strconv.ParseUint(diskQuota, 10, 64)\n\t}\n\tif rpcPort := conf.GetString(\"rpc.port\"); rpcPort != \"\" {\n\t\tc.PSConfig.RPCPort, _ = strconv.Atoi(rpcPort)\n\t}\n\tif adminPort := conf.GetString(\"admin.port\"); adminPort != \"\" {\n\t\tc.PSConfig.AdminPort, _ = strconv.Atoi(adminPort)\n\t}\n\tif heartbeat := conf.GetString(\"heartbeat.interval\"); heartbeat != \"\" {\n\t\tc.PSConfig.HeartbeatInterval, _ = strconv.Atoi(heartbeat)\n\t}\n\n\tif raftHbPort := conf.GetString(\"raft.heartbeat.port\"); raftHbPort != \"\" {\n\t\tc.PSConfig.RaftHeartbeatPort, _ = strconv.Atoi(raftHbPort)\n\t}\n\tif raftReplPort := conf.GetString(\"raft.repl.port\"); raftReplPort != \"\" {\n\t\tc.PSConfig.RaftReplicatePort, _ = strconv.Atoi(raftReplPort)\n\t}\n\tif raftHbInterval := conf.GetString(\"raft.heartbeat.interval\"); raftHbInterval != \"\" {\n\t\tc.PSConfig.RaftHeartbeatInterval, _ = strconv.Atoi(raftHbInterval)\n\t}\n\tif raftRetainLogs := conf.GetString(\"raft.retain.logs\"); raftRetainLogs != \"\" {\n\t\tc.PSConfig.RaftRetainLogs, _ = strconv.ParseUint(raftRetainLogs, 10, 64)\n\t}\n\tif raftRepl := conf.GetString(\"raft.repl.concurrency\"); raftRepl != \"\" {\n\t\tc.PSConfig.RaftReplicaConcurrency, _ = strconv.Atoi(raftRepl)\n\t}\n\tif raftSnap := conf.GetString(\"raft.snap.concurrency\"); raftSnap != \"\" {\n\t\tc.PSConfig.RaftSnapshotConcurrency, _ = strconv.Atoi(raftSnap)\n\t}\n\n\treturn c\n}", "func createDummyConf() error {\n\tcreated = false\n\tfp, err := os.OpenFile(dummyPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644)\n\tdefer fp.Close()\n\tif err != nil {\n\t\treturn err\n\t}\n\tcreated = true\n\tfmt.Fprintf(fp, \"%s\", dummyConf)\n\treturn nil\n}", "func newConfigService(sling *sling.Sling) *ConfigService {\n\treturn &ConfigService{\n\t\tsling: sling.Path(\"help/\"),\n\t}\n}", "func newConfiguration() *configuration {\n\treturn &configuration{\n\t\tUseSSL: true,\n\t\tLocation: \"us-east-1\",\n\t\tMaxBackups: 5,\n\t\tBackupPrefix: \"backup-\",\n\t}\n}", "func create_Config() {\n\tconf, _ := os.Create(ConfigFileName)\n\tdefer conf.Close();\n\n\tfmt.Print(\"Creating new config.json file\");\n\tfmt.Println(\"Eventbrite Configuration:\");\n\tfmt.Printf(\"Event ID: \"); fmt.Scan(Config.Event.Event_id);\n\tfmt.Printf(\"Oathtoken: \"); fmt.Scan(Config.Event.Oathtoken);\n\tfmt.Print(\"Misc Configuration: \");\n\tfmt.Printf(\"Img Dir: \"); fmt.Scan(Config.Img_dir);\n\tfmt.Printf(\"Max Spots: \"); fmt.Scan(Config.Max_Spots);\n\tstr, _ := json.Marshal(Config);\n\t_, err := conf.Write(str);\n\t\n\tif err != nil {\n\t\tfmt.Println(err);\n\t}\n\t\n}", "func (d *lvm) FillVolumeConfig(vol Volume) error {\n\t// Copy volume.* configuration options from pool.\n\t// Exclude \"block.filesystem\" and \"block.mount_options\" as they depend on volume type (handled below).\n\t// Exclude \"lvm.stripes\", \"lvm.stripes.size\" as they only work on non-thin storage pools (handled below).\n\terr := d.fillVolumeConfig(&vol, \"block.filesystem\", \"block.mount_options\", \"lvm.stripes\", \"lvm.stripes.size\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Only validate filesystem config keys for filesystem volumes or VM block volumes (which have an\n\t// associated filesystem volume).\n\tif vol.ContentType() == ContentTypeFS || vol.IsVMBlock() {\n\t\t// Inherit filesystem from pool if not set.\n\t\tif vol.config[\"block.filesystem\"] == \"\" {\n\t\t\tvol.config[\"block.filesystem\"] = d.config[\"volume.block.filesystem\"]\n\t\t}\n\n\t\t// Default filesystem if neither volume nor pool specify an override.\n\t\tif vol.config[\"block.filesystem\"] == \"\" {\n\t\t\t// Unchangeable volume property: Set unconditionally.\n\t\t\tvol.config[\"block.filesystem\"] = DefaultFilesystem\n\t\t}\n\n\t\t// Inherit filesystem mount options from pool if not set.\n\t\tif vol.config[\"block.mount_options\"] == \"\" {\n\t\t\tvol.config[\"block.mount_options\"] = d.config[\"volume.block.mount_options\"]\n\t\t}\n\n\t\t// Default filesystem mount options if neither volume nor pool specify an override.\n\t\tif vol.config[\"block.mount_options\"] == \"\" {\n\t\t\t// Unchangeable volume property: Set unconditionally.\n\t\t\tvol.config[\"block.mount_options\"] = \"discard\"\n\t\t}\n\t}\n\n\t// Inherit stripe settings from pool if not set and not using thin pool.\n\tif !d.usesThinpool() {\n\t\tif vol.config[\"lvm.stripes\"] == \"\" {\n\t\t\tvol.config[\"lvm.stripes\"] = d.config[\"volume.lvm.stripes\"]\n\t\t}\n\n\t\tif vol.config[\"lvm.stripes.size\"] == \"\" {\n\t\t\tvol.config[\"lvm.stripes.size\"] = d.config[\"lvm.stripes.size\"]\n\t\t}\n\t}\n\n\treturn nil\n}", "func initConf() bool {\n\n\t// c := conf.Conf{}\n\t// c.Init(\"../\", \"\", []string{}, []string{}, true)\n\t// config = &c\n\t// s = service{}\n\t// s.init()\n\treturn true\n\n}", "func commonCloudConfig(encodedData, command, path string, cf map[interface{}]interface{}, newUserDataFile *os.File) error {\n\twriteFile := map[string]string{\n\t\t\"encoding\": \"gzip+b64\",\n\t\t\"content\": fmt.Sprintf(\"%s\", encodedData),\n\t\t\"permissions\": \"0644\",\n\t\t\"path\": path,\n\t}\n\tif err := appendValueToListInCloudConfig(cf, \"write_files\", writeFile); err != nil {\n\t\treturn err\n\t}\n\n\t// Add to the runcmd directive\n\tif err := appendValueToListInCloudConfig(cf, \"runcmd\", fmt.Sprintf(\"%s %s\", command, writeFile[\"path\"])); err != nil {\n\t\treturn err\n\t}\n\n\tuserdataContent, err := yaml.Marshal(cf)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tuserdataContent = append([]byte(\"#cloud-config\\n\"), userdataContent...)\n\t_, err = newUserDataFile.Write(userdataContent)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}", "func (a *Application) initConf(confFile string) {\n\tif a.Conf == nil {\n\t\ta.Conf = new(Conf)\n\t\ta.Conf.Parse(confFile)\n\t}\n}", "func newOptionsFromConfig(mCfg *MountConfig) []string {\n\tmountOpts := []string{\"rbind\"}\n\n\tif strings.HasPrefix(mCfg.HostPath, guestpath.SandboxMountPrefix) ||\n\t\tstrings.HasPrefix(mCfg.HostPath, guestpath.HugePagesMountPrefix) {\n\t\tmountOpts = append(mountOpts, \"rshared\")\n\t} else {\n\t\tmountOpts = append(mountOpts, \"rprivate\")\n\t}\n\n\tif mCfg.Readonly {\n\t\tmountOpts = append(mountOpts, \"ro\")\n\t} else {\n\t\tmountOpts = append(mountOpts, \"rw\")\n\t}\n\treturn mountOpts\n}", "func createKubeConfig(esvc EKSAPI, ssvc STSAPI, secsvc SecretsManagerAPI, cluster *string, kubeconfig *string, customKubeconfig []byte) error {\n\tswitch {\n\tcase cluster != nil && kubeconfig != nil:\n\t\treturn errors.New(\"both ClusterID or KubeConfig can not be specified\")\n\tcase cluster != nil:\n\t\tdefaultConfig := api.NewConfig()\n\t\tc, err := getClusterDetails(esvc, *cluster)\n\t\tif err != nil {\n\t\t\treturn genericError(\"Getting Cluster details\", err)\n\t\t}\n\t\tdefaultConfig.Clusters[*cluster] = &api.Cluster{\n\t\t\tServer: c.endpoint,\n\t\t\tCertificateAuthorityData: []byte(c.CAData),\n\t\t}\n\t\ttoken, err := generateKubeToken(ssvc, cluster)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefaultConfig.AuthInfos[\"aws\"] = &api.AuthInfo{\n\t\t\tToken: *token,\n\t\t}\n\t\tdefaultConfig.Contexts[\"aws\"] = &api.Context{\n\t\t\tCluster: *cluster,\n\t\t\tAuthInfo: \"aws\",\n\t\t}\n\t\tdefaultConfig.CurrentContext = \"aws\"\n\t\tlog.Printf(\"Writing kubeconfig file to %s\", KubeConfigLocalPath)\n\n\t\terr = clientcmd.WriteToFile(*defaultConfig, KubeConfigLocalPath)\n\t\tif err != nil {\n\t\t\treturn genericError(\"Write file: \", err)\n\t\t}\n\t\treturn nil\n\tcase kubeconfig != nil:\n\t\ts, err := getSecretsManager(secsvc, kubeconfig)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tlog.Printf(\"Writing kubeconfig file to %s\", KubeConfigLocalPath)\n\t\terr = ioutil.WriteFile(KubeConfigLocalPath, s, 0600)\n\t\tif err != nil {\n\t\t\treturn genericError(\"Write file: \", err)\n\t\t}\n\t\treturn nil\n\tcase customKubeconfig != nil:\n\t\tlog.Printf(\"Writing kubeconfig file to %s\", KubeConfigLocalPath)\n\t\terr := ioutil.WriteFile(KubeConfigLocalPath, customKubeconfig, 0600)\n\t\tif err != nil {\n\t\t\treturn genericError(\"Write file: \", err)\n\t\t}\n\t\treturn nil\n\tdefault:\n\t\treturn errors.New(\"either ClusterID or KubeConfig must be specified\")\n\t}\n}", "func newConfig(old *Config, vars Vars) *Config {\n\tv := mergeVars(old.Vars, vars)\n\n\treturn &Config{\n\t\tAppID: old.AppID,\n\t\tVars: v,\n\t}\n}", "func New(file string) (conf *Config, err error) {\n\tconf = &Config{\n\t\tLogLevel: \"info\",\n\t\tSite: \"default\",\n\t\taudit: []auditors.Auditor{},\n\t}\n\n\trawconf, err := os.ReadFile(file)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"could not read config file %s\", file)\n\t}\n\n\terr = json.Unmarshal(rawconf, conf)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"could not parse config file %s\", file)\n\t}\n\n\tccfg, err := cconf.NewConfig(conf.ChoriaConfigFile)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"could not parse choria config %s\", conf.ChoriaConfigFile)\n\t}\n\n\tccfg.LogFile = conf.LogFile\n\tccfg.LogLevel = conf.LogLevel\n\tccfg.RPCAuthorization = false\n\n\t// by definition these are clients who do not have security credentials, verification is based on the JWT\n\tccfg.DisableSecurityProviderVerify = true\n\n\tconf.fw, err = choria.NewWithConfig(ccfg)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"could not configure choria\")\n\t}\n\n\terr = configureAuthenticator(conf)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"could not configure %s authenticator\", conf.AuthenticatorType)\n\t}\n\n\terr = configureSigner(conf)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"could not configure %s signer\", conf.SignerType)\n\t}\n\n\treturn conf, nil\n}", "func (k *Kluster) Copy(name, platformName, path, format string, parentUI *ui.UI, envConfig map[string]string) (*Kluster, error) {\n\tif len(format) == 0 {\n\t\tformat = k.format()\n\t}\n\tif !validFormat(format) {\n\t\treturn nil, fmt.Errorf(\"invalid format %q for the new cluster config file\", format)\n\t}\n\tpath = filepath.Join(path, DefaultConfigFilename+\".\"+format)\n\n\tif _, err := os.Stat(path); os.IsExist(err) {\n\t\treturn nil, fmt.Errorf(\"the new cluster config file %q already exists\", path)\n\t}\n\n\tnewUI := parentUI.Copy()\n\n\tcluster := Kluster{\n\t\tVersion: k.Version,\n\t\tKind: k.Kind,\n\t\tName: name,\n\t\tConfig: k.Config,\n\t\tResources: k.Resources,\n\t\tpath: path,\n\t\tui: newUI,\n\t}\n\n\tcluster.Platforms = make(map[string]interface{}, 1)\n\tif len(platformName) != 0 {\n\t\tallPlatforms := provisioner.SupportedPlatforms(name, envConfig, newUI, cluster.Version)\n\t\tprovisioner, ok := allPlatforms[platformName]\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"platform %q is not supported\", platformName)\n\t\t}\n\t\tcluster.Platforms[platformName] = provisioner.Config()\n\t} else {\n\t\tplatformName = k.Platform()\n\t\tcluster.Platforms = k.Platforms\n\t}\n\n\tcluster.State = make(map[string]*State, 1)\n\tcluster.State[platformName] = &State{\n\t\tStatus: AbsentStatus.String(),\n\t}\n\n\treturn &cluster, nil\n}", "func initBaseConf() {\n\tssLEnable := false\n\tif viper.GetBool(defaultEnvHttpsEnable) {\n\t\tssLEnable = true\n\t} else {\n\t\tssLEnable = viper.GetBool(\"sslEnable\")\n\t}\n\trunMode := viper.GetString(\"runmode\")\n\tvar apiBase string\n\tif \"debug\" == runMode {\n\t\tapiBase = viper.GetString(\"dev_url\")\n\t} else if \"test\" == runMode {\n\t\tapiBase = viper.GetString(\"test_url\")\n\t} else {\n\t\tapiBase = viper.GetString(\"prod_url\")\n\t}\n\n\turi, err := url.Parse(apiBase)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tbaseHOSTByEnv := viper.GetString(defaultEnvHost)\n\tif baseHOSTByEnv != \"\" {\n\t\turi.Host = baseHOSTByEnv\n\t\tapiBase = uri.String()\n\t} else {\n\t\tisAutoHost := viper.GetBool(defaultEnvAutoGetHost)\n\t\tSugar().Debugf(\"isAutoHost %v\", isAutoHost)\n\t\tif isAutoHost {\n\t\t\tipv4, err := sys.NetworkLocalIP()\n\t\t\tif err == nil {\n\t\t\t\taddrStr := viper.GetString(\"addr\")\n\t\t\t\tvar proc string\n\t\t\t\tif ssLEnable {\n\t\t\t\t\tproc = \"https\"\n\t\t\t\t} else {\n\t\t\t\t\tproc = \"http\"\n\t\t\t\t}\n\t\t\t\tapiBase = fmt.Sprintf(\"%v://%v%v\", proc, ipv4, addrStr)\n\t\t\t}\n\t\t}\n\t}\n\n\tif ssLEnable {\n\t\tapiBase = strings.Replace(apiBase, \"http://\", \"https://\", 1)\n\t}\n\tSugar().Debugf(\"config file uri.Host %v\", uri.Host)\n\tSugar().Debugf(\"apiBase %v\", apiBase)\n\tbaseConf = BaseConf{\n\t\tBaseURL: apiBase,\n\t\tSSLEnable: ssLEnable,\n\t}\n}", "func MakeConfig(c *def.App) (out *nine.Config) {\n\tC := c.Cats\n\tvar configFile string\n\tvar tn, sn, rn bool\n\tout = &nine.Config{\n\t\tConfigFile: &configFile,\n\t\tAppDataDir: C.Str(\"app\", \"appdatadir\"),\n\t\tDataDir: C.Str(\"app\", \"datadir\"),\n\t\tLogDir: C.Str(\"app\", \"logdir\"),\n\t\tLogLevel: C.Str(\"log\", \"level\"),\n\t\tSubsystems: C.Map(\"log\", \"subsystem\"),\n\t\tNetwork: C.Str(\"p2p\", \"network\"),\n\t\tAddPeers: C.Tags(\"p2p\", \"addpeer\"),\n\t\tConnectPeers: C.Tags(\"p2p\", \"connect\"),\n\t\tMaxPeers: C.Int(\"p2p\", \"maxpeers\"),\n\t\tListeners: C.Tags(\"p2p\", \"listen\"),\n\t\tDisableListen: C.Bool(\"p2p\", \"nolisten\"),\n\t\tDisableBanning: C.Bool(\"p2p\", \"disableban\"),\n\t\tBanDuration: C.Duration(\"p2p\", \"banduration\"),\n\t\tBanThreshold: C.Int(\"p2p\", \"banthreshold\"),\n\t\tWhitelists: C.Tags(\"p2p\", \"whitelist\"),\n\t\tUsername: C.Str(\"rpc\", \"user\"),\n\t\tPassword: C.Str(\"rpc\", \"pass\"),\n\t\tServerUser: C.Str(\"rpc\", \"user\"),\n\t\tServerPass: C.Str(\"rpc\", \"pass\"),\n\t\tLimitUser: C.Str(\"limit\", \"user\"),\n\t\tLimitPass: C.Str(\"limit\", \"pass\"),\n\t\tRPCConnect: C.Str(\"rpc\", \"connect\"),\n\t\tRPCListeners: C.Tags(\"rpc\", \"listen\"),\n\t\tRPCCert: C.Str(\"tls\", \"cert\"),\n\t\tRPCKey: C.Str(\"tls\", \"key\"),\n\t\tRPCMaxClients: C.Int(\"rpc\", \"maxclients\"),\n\t\tRPCMaxWebsockets: C.Int(\"rpc\", \"maxwebsockets\"),\n\t\tRPCMaxConcurrentReqs: C.Int(\"rpc\", \"maxconcurrentreqs\"),\n\t\tRPCQuirks: C.Bool(\"rpc\", \"quirks\"),\n\t\tDisableRPC: C.Bool(\"rpc\", \"disable\"),\n\t\tNoTLS: C.Bool(\"tls\", \"disable\"),\n\t\tDisableDNSSeed: C.Bool(\"p2p\", \"nodns\"),\n\t\tExternalIPs: C.Tags(\"p2p\", \"externalips\"),\n\t\tProxy: C.Str(\"proxy\", \"address\"),\n\t\tProxyUser: C.Str(\"proxy\", \"user\"),\n\t\tProxyPass: C.Str(\"proxy\", \"pass\"),\n\t\tOnionProxy: C.Str(\"proxy\", \"address\"),\n\t\tOnionProxyUser: C.Str(\"proxy\", \"user\"),\n\t\tOnionProxyPass: C.Str(\"proxy\", \"pass\"),\n\t\tOnion: C.Bool(\"proxy\", \"tor\"),\n\t\tTorIsolation: C.Bool(\"proxy\", \"isolation\"),\n\t\tTestNet3: &tn,\n\t\tRegressionTest: &rn,\n\t\tSimNet: &sn,\n\t\tAddCheckpoints: C.Tags(\"chain\", \"addcheckpoints\"),\n\t\tDisableCheckpoints: C.Bool(\"chain\", \"disablecheckpoints\"),\n\t\tDbType: C.Str(\"chain\", \"dbtype\"),\n\t\tProfile: C.Int(\"app\", \"profile\"),\n\t\tCPUProfile: C.Str(\"app\", \"cpuprofile\"),\n\t\tUpnp: C.Bool(\"app\", \"upnp\"),\n\t\tMinRelayTxFee: C.Float(\"p2p\", \"minrelaytxfee\"),\n\t\tFreeTxRelayLimit: C.Float(\"p2p\", \"freetxrelaylimit\"),\n\t\tNoRelayPriority: C.Bool(\"p2p\", \"norelaypriority\"),\n\t\tTrickleInterval: C.Duration(\"p2p\", \"trickleinterval\"),\n\t\tMaxOrphanTxs: C.Int(\"p2p\", \"maxorphantxs\"),\n\t\tAlgo: C.Str(\"mining\", \"algo\"),\n\t\tGenerate: C.Bool(\"mining\", \"generate\"),\n\t\tGenThreads: C.Int(\"mining\", \"genthreads\"),\n\t\tMiningAddrs: C.Tags(\"mining\", \"addresses\"),\n\t\tMinerListener: C.Str(\"mining\", \"listener\"),\n\t\tMinerPass: C.Str(\"mining\", \"pass\"),\n\t\tBlockMinSize: C.Int(\"block\", \"minsize\"),\n\t\tBlockMaxSize: C.Int(\"block\", \"maxsize\"),\n\t\tBlockMinWeight: C.Int(\"block\", \"minweight\"),\n\t\tBlockMaxWeight: C.Int(\"block\", \"maxweight\"),\n\t\tBlockPrioritySize: C.Int(\"block\", \"prioritysize\"),\n\t\tUserAgentComments: C.Tags(\"p2p\", \"useragentcomments\"),\n\t\tNoPeerBloomFilters: C.Bool(\"p2p\", \"nobloomfilters\"),\n\t\tNoCFilters: C.Bool(\"p2p\", \"nocfilters\"),\n\t\tSigCacheMaxSize: C.Int(\"chain\", \"sigcachemaxsize\"),\n\t\tBlocksOnly: C.Bool(\"p2p\", \"blocksonly\"),\n\t\tTxIndex: C.Bool(\"chain\", \"txindex\"),\n\t\tAddrIndex: C.Bool(\"chain\", \"addrindex\"),\n\t\tRelayNonStd: C.Bool(\"chain\", \"relaynonstd\"),\n\t\tRejectNonStd: C.Bool(\"chain\", \"rejectnonstd\"),\n\t\tTLSSkipVerify: C.Bool(\"tls\", \"skipverify\"),\n\t\tWallet: C.Bool(\"wallet\", \"enable\"),\n\t\tNoInitialLoad: C.Bool(\"wallet\", \"noinitialload\"),\n\t\tWalletPass: C.Str(\"wallet\", \"pass\"),\n\t\tWalletServer: C.Str(\"wallet\", \"server\"),\n\t\tCAFile: C.Str(\"tls\", \"cafile\"),\n\t\tOneTimeTLSKey: C.Bool(\"tls\", \"onetime\"),\n\t\tServerTLS: C.Bool(\"tls\", \"server\"),\n\t\tLegacyRPCListeners: C.Tags(\"rpc\", \"listen\"),\n\t\tLegacyRPCMaxClients: C.Int(\"rpc\", \"maxclients\"),\n\t\tLegacyRPCMaxWebsockets: C.Int(\"rpc\", \"maxwebsockets\"),\n\t\tExperimentalRPCListeners: &[]string{},\n\t\tState: node.StateCfg,\n\t}\n\treturn\n}", "func (c *configHandler) createNewConfig(w http.ResponseWriter, r *http.Request) {\n log.Printf(\"received /configs POST request from %v\", r.Host)\n requestbody, err := ioutil.ReadAll(r.Body)\n defer r.Body.Close()\n if err != nil {\n w.WriteHeader(http.StatusInternalServerError)\n w.Write([]byte(err.Error()))\n return\n }\n\n // check request's content-type\n content := r.Header.Get(\"content-type\")\n if content != \"application/json\" {\n w.WriteHeader(http.StatusUnsupportedMediaType)\n w.Write([]byte(err.Error()))\n return\n }\n\n var newconfig Config\n err = json.Unmarshal(requestbody, &newconfig)\n if err != nil {\n w.WriteHeader(http.StatusBadRequest)\n w.Write([]byte(err.Error()))\n return\n }\n\n c.Lock()\n c.database[newconfig.Name] = newconfig\n c.Unlock()\n log.Print(\"Created new config successfully and added to database \", c.database)\n\n w.WriteHeader(http.StatusOK)\n}", "func InitCfg() error {\n\tfilePath := \"/var/bcs/bcs.conf\"\n\tfile, err := ioutil.ReadFile(filePath)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif err = codec.DecJson(file, &cfg); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse %s. decode error: %v\", string(file), err)\n\t}\n\n\tkeyPwd := static.ClientCertPwd\n\tif cfg.CustomCertFile != \"\" && cfg.CustomKeyFile != \"\" && cfg.CustomCAFile != \"\" {\n\t\tcfg.CAFile = cfg.CustomCAFile\n\t\tcfg.CertFile = cfg.CustomCertFile\n\t\tcfg.KeyFile = cfg.CustomKeyFile\n\t\tkeyPwd = cfg.CustomKeyPwd\n\t}\n\n\tif cfg.CertFile != \"\" && cfg.KeyFile != \"\" && cfg.CAFile != \"\" {\n\t\tif cfg.clientSSL, err = ssl.ClientTslConfVerity(cfg.CAFile, cfg.CertFile, cfg.KeyFile, keyPwd); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to set client tls: %v\", err)\n\t\t}\n\t}\n\n\tif !strings.Contains(cfg.ApiHost, \"http\") {\n\t\tif cfg.clientSSL != nil {\n\t\t\tcfg.ApiHost = fmt.Sprintf(\"https://%s\", cfg.ApiHost)\n\t\t} else {\n\t\t\tcfg.ApiHost = fmt.Sprintf(\"http://%s\", cfg.ApiHost)\n\t\t}\n\t}\n\n\tDebugPrintf(\"api address: %s\\n\", cfg.ApiHost)\n\n\treturn nil\n}", "func newConfigFromString(t *testing.T, configString string) (Config, func(), error) {\n\ttestFs, testFsTeardown := setupTestFs()\n\n\terr := afero.WriteFile(testFs, \"config.properties\", []byte(configString), 0644)\n\n\tif err != nil {\n\t\t// Fatal stops the goroutine before the caller can defer the teardown function\n\t\t// run it manually now\n\t\ttestFsTeardown()\n\t\tConfigViperHook = func(v *viper.Viper) {}\n\n\t\tt.Fatal(\"cannot make file\", \"config.properties\", err)\n\t}\n\n\tConfigViperHook = func(v *viper.Viper) {\n\t\tv.SetFs(GetIndexFs())\n\t}\n\n\tlog.DEBUG.Printf(\"loading config from '%s'\\n\", configString)\n\n\tc, err := NewConfig(\"config.properties\")\n\n\treturn c, func() {\n\t\ttestFsTeardown()\n\t\tConfigViperHook = func(v *viper.Viper) {}\n\t}, err\n}", "func (c *Config) adjust(meta *toml.MetaData) error {\n\tconfigMetaData := configutil.NewConfigMetadata(meta)\n\tif err := configMetaData.CheckUndecoded(); err != nil {\n\t\tc.WarningMsgs = append(c.WarningMsgs, err.Error())\n\t}\n\n\tif c.Name == \"\" {\n\t\thostname, err := os.Hostname()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tconfigutil.AdjustString(&c.Name, fmt.Sprintf(\"%s-%s\", defaultName, hostname))\n\t}\n\tconfigutil.AdjustString(&c.DataDir, fmt.Sprintf(\"default.%s\", c.Name))\n\tconfigutil.AdjustPath(&c.DataDir)\n\n\tif err := c.validate(); err != nil {\n\t\treturn err\n\t}\n\n\tconfigutil.AdjustString(&c.BackendEndpoints, defaultBackendEndpoints)\n\tconfigutil.AdjustString(&c.ListenAddr, defaultListenAddr)\n\tconfigutil.AdjustString(&c.AdvertiseListenAddr, c.ListenAddr)\n\n\tif !configMetaData.IsDefined(\"enable-grpc-gateway\") {\n\t\tc.EnableGRPCGateway = utils.DefaultEnableGRPCGateway\n\t}\n\n\tc.adjustLog(configMetaData.Child(\"log\"))\n\tc.Security.Encryption.Adjust()\n\n\tif len(c.Log.Format) == 0 {\n\t\tc.Log.Format = utils.DefaultLogFormat\n\t}\n\n\tconfigutil.AdjustInt64(&c.LeaderLease, utils.DefaultLeaderLease)\n\n\tif err := c.Schedule.Adjust(configMetaData.Child(\"schedule\"), false); err != nil {\n\t\treturn err\n\t}\n\treturn c.Replication.Adjust(configMetaData.Child(\"replication\"))\n}", "func NewConf(fileName string) (*Conf, error) {\n\tc := New()\n\tif err := c.InitFromFile(fileName); err != nil {\n\t\treturn nil, err\n\t}\n\treturn c, nil\n}", "func InitConf(path string) (err error) {\n\t//make directory\n\tif err := os.MkdirAll(path, 0777); err != nil {\n\t\treturn fmt.Errorf(\"make directory: %v\", err)\n\t}\n\n\t//make json\n\tmakeJson := func() error {\n\t\tConfjson, err := os.Create(filepath.Join(path, \"pochtona.json\"))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"make conf: %v\", err)\n\t\t}\n\t\tdefer Confjson.Close()\n\t\tif err = GetSampleConf(Confjson, path); err != nil {\n\t\t\treturn fmt.Errorf(\"write conf: %v\", err)\n\t\t}\n\t\treturn nil\n\t}\n\tif err = makeJson(); err != nil {\n\t\treturn err\n\t}\n\n\t//make sctript\n\thello := \"\"\n\tif runtime.GOOS != \"windows\" {\n\t\thello = \"hello.sh\"\n\t} else {\n\t\thello = \"hello.bat\"\n\t}\n\tmakeHello := func() error {\n\t\tHelloSh, err := os.Create(filepath.Join(path, hello))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"make hello: %v\", err)\n\t\t}\n\t\tdefer HelloSh.Close()\n\t\t_, err = HelloSh.WriteString(\"echo hello world!\")\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"write hello: %v\", err)\n\t\t}\n\t\treturn nil\n\t}\n\tif err = makeHello(); err != nil {\n\t\treturn err\n\t}\n\tif err = os.Chmod(filepath.Join(path, hello), 0777); err != nil {\n\t\treturn fmt.Errorf(\"chmod hello: %v\", err)\n\t}\n\treturn nil\n}", "func newStorageConfigFromConfigMap(ctx context.Context, configMap *corev1.ConfigMap, c client.Reader, ns string) (*StorageConfig, error) {\n\tvar sc StorageConfig\n\thasDefault := false\n\tfor k, v := range configMap.Data {\n\t\tvar bc BucketConfig\n\t\terr := yaml.Unmarshal([]byte(v), &bc)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tbc.fixEndpoint()\n\t\tbc.isDefault = k == \"default\"\n\n\t\t// Try loading the secret\n\t\tvar secret corev1.Secret\n\t\tkey := client.ObjectKey{\n\t\t\tName: bc.SecretName,\n\t\t\tNamespace: configMap.GetNamespace(),\n\t\t}\n\t\tif err := c.Get(ctx, key, &secret); err != nil {\n\t\t\treturn nil, maskAny(err)\n\t\t}\n\t\tif raw, found := secret.Data[constants.SecretKeyS3AccessKey]; found {\n\t\t\tbc.accessKey = string(raw)\n\t\t} else {\n\t\t\treturn nil, maskAny(fmt.Errorf(\"Config %#v refers to Secret '%s' that has no '%s' field\", configMap.Data, bc.SecretName, constants.SecretKeyS3AccessKey))\n\t\t}\n\t\tif raw, found := secret.Data[constants.SecretKeyS3SecretKey]; found {\n\t\t\tbc.secretKey = string(raw)\n\t\t} else {\n\t\t\treturn nil, maskAny(fmt.Errorf(\"Config %#v refers to Secret '%s' that has no '%s' field\", configMap.Data, bc.SecretName, constants.SecretKeyS3SecretKey))\n\t\t}\n\n\t\t// Add to config\n\t\thasDefault = hasDefault || bc.isDefault\n\t\tsc.Buckets = append(sc.Buckets, bc)\n\t}\n\tif !hasDefault {\n\t\treturn nil, maskAny(fmt.Errorf(\"Config %#v must have a default bucket\", configMap.Data))\n\t}\n\tsort.Slice(sc.Buckets, func(i, j int) bool {\n\t\ta, b := sc.Buckets[i], sc.Buckets[j]\n\t\tif a.isDefault && !b.isDefault {\n\t\t\treturn true\n\t\t}\n\t\tif !a.isDefault && b.isDefault {\n\t\t\treturn false\n\t\t}\n\t\treturn strings.Compare(a.Name, b.Name) < 0\n\t})\n\treturn &sc, nil\n}", "func initializeConfigFile() Configuration {\n\t// check if ~/.kube/kubectl exists if not create it\n\t// log.Print(\"[DEBUG] checking ~/.kube/kubectl\")\n\thome, err := CreateKubectlHome()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// if env var does not exists try to read from ~/.kube/kubectl/config\n\tconfig := fmt.Sprintf(\"%v/config\", home)\n\tif _, err := os.Stat(config); os.IsNotExist(err) {\n\t\t_, err := os.Create(config)\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tseed, seedErr := json.MarshalIndent(SeedData(), \"\", \" \")\n\t\tif seedErr != nil {\n\t\t\tpanic(seedErr)\n\t\t}\n\t\tlog.Print(\"[DEBUG] writing file ~/.kube/kubectl/config\")\n\t\tnoWriteErr := ioutil.WriteFile(config, seed, 0666)\n\t\tif noWriteErr != nil {\n\t\t\tpanic(noWriteErr)\n\t\t}\n\t}\n\t// log.Print(\"[DEBUG] File ~/.kube/kubectl/config exists now reading it....\")\n\t// config file is already exists at this point (created above or already exists) read it now\n\tconfigFile, err := ioutil.ReadFile(config)\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to get configFile:: %v\", configFile)\n\t\tpanic(err)\n\t}\n\tdata := Configuration{}\n\tjsonErr := json.Unmarshal([]byte(configFile), &data)\n\tif jsonErr != nil {\n\t\tpanic(jsonErr)\n\t}\n\treturn data\n}", "func newConfig() *Config {\n\treturn &Config{\n\t\tgeneral{\n\t\t\tVerbose: false,\n\t\t},\n\t\tserver{\n\t\t\tType: \"http\",\n\t\t\tHost: \"0.0.0.0\",\n\t\t},\n\t\tmongo{\n\t\t\tHost: \"0.0.0.0:27017\",\n\t\t\tDatabase: \"etlog\",\n\t\t\tCollection: \"logs\",\n\t\t},\n\t}\n}", "func loadConfig(opt options) (original, cfg LocalConfig) {\n\tcfg, err := LoadConfigFile(opt.configPath)\n\tif err != nil {\n\t\tlog.Printf(\"unable to load config file: %q\\n\", opt.configPath)\n\t\tcfg = NewConfig()\n\t}\n\toriginal = cfg\n\n\t// Override any store specific settings.\n\tif opt.s3Region != \"\" {\n\t\tcfg.Store.S3Region = opt.s3Region\n\t}\n\tif opt.s3Bucket != \"\" {\n\t\tcfg.Store.S3Bucket = opt.s3Bucket\n\t}\n\tif opt.awsAccessKey != \"\" {\n\t\tcfg.Store.AWSAccessKey = opt.awsAccessKey\n\t}\n\tif opt.awsSecretKey != \"\" {\n\t\tcfg.Store.AWSSecretKey = opt.awsSecretKey\n\t}\n\n\treturn\n}", "func DisConfPush(c *gin.Context) {\n\tappName := c.Request.FormValue(\"app-name\")\n\tlabel := c.Request.FormValue(\"label\")\n\ttimestamp := c.Request.FormValue(\"timestamp\")\n\tcontainerPath := c.Request.FormValue(\"container-path\")\n\n\tc.Request.ParseMultipartForm(32 << 20)\n\tfile, handler, err := c.Request.FormFile(\"uploadfile\")\n\tif err != nil {\n\t\tlogrus.Error(\"error get upload file.\")\n\t\tc.AbortWithError(http.StatusBadRequest, err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\n\t// upload config files.\n\tpath := disconfDir + \"/\" + appName + \"/\" + label + \"/\" + timestamp + containerPath\n\terr = os.MkdirAll(path, 0777)\n\tif err != nil {\n\t\tlogrus.Error(\"error create upload file directory.\")\n\t\tc.AbortWithError(http.StatusBadRequest, err)\n\t\treturn\n\t}\n\tf, err := os.OpenFile(path+\"/\"+handler.Filename, os.O_WRONLY|os.O_CREATE, 0777)\n\tif err != nil {\n\t\tlogrus.Error(\"error create upload file. \")\n\t\tc.AbortWithError(http.StatusBadRequest, err)\n\t\treturn\n\t}\n\tdefer f.Close()\n\tio.Copy(f, file)\n\n\tc.JSON(http.StatusOK, struct {\n\t\tFilepath string\n\t}{path})\n}", "func newVaultAuthConfigHandler(secretName string, vaultClient vault.Client) VaultAuthConfigHandler {\n\treturn VaultAuthConfigHandler{\n\t\tsecretName: secretName,\n\t\tvaultClient: vaultClient,\n\t}\n}", "func make() *Config {\n\t// instantiating configuration\n\tconf = &Config{}\n\n\t// filling the structure\n\terr := iterateTemplate(conf, false)\n\n\tcheckError(err)\n\n\t// parsing set flags\n\tflag.Parse()\n\n\tif conf.Basic.Debug {\n\t\tprintConfToLog(conf)\n\t}\n\n\treturn conf\n}", "func ensureDefaultConfig(ctx context.Context, cfg *apiconfig.CalicoAPIConfig, c client.Interface, node *libapi.Node, osType string, kubeadmConfig, rancherState *v1.ConfigMap) error {\n\t// Ensure the ClusterInformation is populated.\n\t// Get the ClusterType from ENV var. This is set from the manifest.\n\tclusterType := os.Getenv(\"CLUSTER_TYPE\")\n\n\tif kubeadmConfig != nil {\n\t\tif len(clusterType) == 0 {\n\t\t\tclusterType = \"kubeadm\"\n\t\t} else {\n\t\t\tclusterType += \",kubeadm\"\n\t\t}\n\t}\n\n\tif rancherState != nil {\n\t\tif len(clusterType) == 0 {\n\t\t\tclusterType = \"rancher\"\n\t\t} else {\n\t\t\tclusterType += \",rancher\"\n\t\t}\n\t}\n\n\tif osType != OSTypeLinux {\n\t\tif len(clusterType) == 0 {\n\t\t\tclusterType = osType\n\t\t} else {\n\t\t\tclusterType += \",\" + osType\n\t\t}\n\t}\n\n\tif err := c.EnsureInitialized(ctx, VERSION, clusterType); err != nil {\n\t\treturn nil\n\t}\n\n\t// By default we set the global reporting interval to 0 - this is\n\t// different from the defaults defined in Felix.\n\t//\n\t// Logging to file is disabled in the felix.cfg config file. This\n\t// should always be disabled for calico/node. By default we log to\n\t// screen - set the default logging value that we desire.\n\tfelixConf, err := c.FelixConfigurations().Get(ctx, globalFelixConfigName, options.GetOptions{})\n\tif err != nil {\n\t\t// Create the default config if it doesn't already exist.\n\t\tif _, ok := err.(cerrors.ErrorResourceDoesNotExist); ok {\n\t\t\tnewFelixConf := api.NewFelixConfiguration()\n\t\t\tnewFelixConf.Name = globalFelixConfigName\n\t\t\tnewFelixConf.Spec.ReportingInterval = &metav1.Duration{Duration: 0}\n\t\t\tnewFelixConf.Spec.LogSeverityScreen = defaultLogSeverity\n\t\t\t_, err = c.FelixConfigurations().Create(ctx, newFelixConf, options.SetOptions{})\n\t\t\tif err != nil {\n\t\t\t\tif conflict, ok := err.(cerrors.ErrorResourceAlreadyExists); ok {\n\t\t\t\t\tlog.Infof(\"Ignoring conflict when setting value %s\", conflict.Identifier)\n\t\t\t\t} else {\n\t\t\t\t\tlog.WithError(err).WithField(\"FelixConfig\", newFelixConf).Errorf(\"Error creating Felix global config\")\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tlog.WithError(err).WithField(\"FelixConfig\", globalFelixConfigName).Errorf(\"Error getting Felix global config\")\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tupdateNeeded := false\n\t\tif felixConf.Spec.ReportingInterval == nil {\n\t\t\tfelixConf.Spec.ReportingInterval = &metav1.Duration{Duration: 0}\n\t\t\tupdateNeeded = true\n\t\t} else {\n\t\t\tlog.WithField(\"ReportingInterval\", felixConf.Spec.ReportingInterval).Debug(\"Global Felix value already assigned\")\n\t\t}\n\n\t\tif felixConf.Spec.LogSeverityScreen == \"\" {\n\t\t\tfelixConf.Spec.LogSeverityScreen = defaultLogSeverity\n\t\t\tupdateNeeded = true\n\t\t} else {\n\t\t\tlog.WithField(\"LogSeverityScreen\", felixConf.Spec.LogSeverityScreen).Debug(\"Global Felix value already assigned\")\n\t\t}\n\n\t\tif updateNeeded {\n\t\t\t_, err = c.FelixConfigurations().Update(ctx, felixConf, options.SetOptions{})\n\t\t\tif err != nil {\n\t\t\t\tif conflict, ok := err.(cerrors.ErrorResourceUpdateConflict); ok {\n\t\t\t\t\tlog.Infof(\"Ignoring conflict when setting value %s\", conflict.Identifier)\n\t\t\t\t} else {\n\t\t\t\t\tlog.WithError(err).WithField(\"FelixConfig\", felixConf).Errorf(\"Error updating Felix global config\")\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Configure Felix to allow traffic from the containers to the host (if\n\t// not otherwise firewalled by the host administrator or profiles).\n\t// This is important for container deployments, where it is common\n\t// for containers to speak to services running on the host (e.g. k8s\n\t// pods speaking to k8s api-server, and mesos tasks registering with agent\n\t// on startup). Note: KDD does not yet support per-node felix config.\n\tif cfg.Spec.DatastoreType != apiconfig.Kubernetes {\n\t\tfelixNodeCfg, err := c.FelixConfigurations().Get(ctx, fmt.Sprintf(\"%s%s\", felixNodeConfigNamePrefix, node.Name), options.GetOptions{})\n\t\tif err != nil {\n\t\t\t// Create the default config if it doesn't already exist.\n\t\t\tif _, ok := err.(cerrors.ErrorResourceDoesNotExist); ok {\n\t\t\t\tnewFelixNodeCfg := api.NewFelixConfiguration()\n\t\t\t\tnewFelixNodeCfg.Name = fmt.Sprintf(\"%s%s\", felixNodeConfigNamePrefix, node.Name)\n\t\t\t\tnewFelixNodeCfg.Spec.DefaultEndpointToHostAction = \"Return\"\n\t\t\t\t_, err = c.FelixConfigurations().Create(ctx, newFelixNodeCfg, options.SetOptions{})\n\t\t\t\tif err != nil {\n\t\t\t\t\tif exists, ok := err.(cerrors.ErrorResourceAlreadyExists); ok {\n\t\t\t\t\t\tlog.Infof(\"Ignoring resource exists error when setting value %s\", exists.Identifier)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlog.WithError(err).WithField(\"FelixConfig\", newFelixNodeCfg).Errorf(\"Error creating Felix node config\")\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlog.WithError(err).WithField(\"FelixConfig\", felixNodeConfigNamePrefix).Errorf(\"Error getting Felix node config\")\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\tif felixNodeCfg.Spec.DefaultEndpointToHostAction == \"\" {\n\t\t\t\tfelixNodeCfg.Spec.DefaultEndpointToHostAction = \"Return\"\n\t\t\t\t_, err = c.FelixConfigurations().Update(ctx, felixNodeCfg, options.SetOptions{})\n\t\t\t\tif err != nil {\n\t\t\t\t\tif conflict, ok := err.(cerrors.ErrorResourceUpdateConflict); ok {\n\t\t\t\t\t\tlog.Infof(\"Ignoring conflict when setting value %s\", conflict.Identifier)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlog.WithError(err).WithField(\"FelixConfig\", felixNodeCfg).Errorf(\"Error updating Felix node config\")\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlog.WithField(\"DefaultEndpointToHostAction\", felixNodeCfg.Spec.DefaultEndpointToHostAction).Debug(\"Host Felix value already assigned\")\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}", "func (cfg *Conf) overrideEnvConf() {\n\tif os.Getenv(\"SMGMG_BK_API_KEY\") != \"\" {\n\t\tcfg.ApiKey = os.Getenv(\"SMGMG_BK_API_KEY\")\n\t}\n\n\tif os.Getenv(\"SMGMG_BK_API_SECRET\") != \"\" {\n\t\tcfg.ApiSecret = os.Getenv(\"SMGMG_BK_API_SECRET\")\n\t}\n\n\tif os.Getenv(\"SMGMG_BK_USER_TOKEN\") != \"\" {\n\t\tcfg.UserToken = os.Getenv(\"SMGMG_BK_USER_TOKEN\")\n\t}\n\n\tif os.Getenv(\"SMGMG_BK_USER_SECRET\") != \"\" {\n\t\tcfg.UserSecret = os.Getenv(\"SMGMG_BK_USER_SECRET\")\n\t}\n\n\tif os.Getenv(\"SMGMG_BK_DESTINATION\") != \"\" {\n\t\tcfg.Destination = os.Getenv(\"SMGMG_BK_DESTINATION\")\n\t}\n\n\tif os.Getenv(\"SMGMG_BK_FILE_NAMES\") != \"\" {\n\t\tcfg.Filenames = os.Getenv(\"SMGMG_BK_FILE_NAMES\")\n\t}\n}", "func configLocalFilesystemLogger(logPath string, logFileName string, maxAge time.Duration, rotationTime time.Duration) {\n\tbaseLogPaht := path.Join(logPath, logFileName)\n\twriter, err := rotatelogs.New(\n\t\tbaseLogPaht+\".%Y%m%d%H%M.log\",\n\t\trotatelogs.WithLinkName(baseLogPaht), // 生成软链,指向最新日志文件\n\t\trotatelogs.WithMaxAge(maxAge), // 文件最大保存时间\n\t\trotatelogs.WithRotationTime(rotationTime), // 日志切割时间间隔\n\t)\n\tif err != nil {\n\t\tlog.Errorf(\"config local file system logger error. %+v\", errors.WithStack(err))\n\t}\n\tlfHook := lfshook.NewHook(lfshook.WriterMap{\n\t\tlog.DebugLevel: writer, // 为不同级别设置不同的输出目的\n\t\tlog.InfoLevel: writer,\n\t\tlog.WarnLevel: writer,\n\t\tlog.ErrorLevel: writer,\n\t\tlog.FatalLevel: writer,\n\t\tlog.PanicLevel: writer,\n\t}, &log.JSONFormatter{})\n\tlog.AddHook(lfHook)\n}", "func newConfigMap(configMapName, namespace string, labels map[string]string,\n\tkibanaIndexMode, esUnicastHost, rootLogger, nodeQuorum, recoverExpectedShards, primaryShardsCount, replicaShardsCount string) *v1.ConfigMap {\n\n\terr, data := renderData(kibanaIndexMode, esUnicastHost, nodeQuorum, recoverExpectedShards, primaryShardsCount, replicaShardsCount, rootLogger)\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\treturn &v1.ConfigMap{\n\t\tTypeMeta: metav1.TypeMeta{\n\t\t\tKind: \"ConfigMap\",\n\t\t\tAPIVersion: v1.SchemeGroupVersion.String(),\n\t\t},\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: configMapName,\n\t\t\tNamespace: namespace,\n\t\t\tLabels: labels,\n\t\t},\n\t\tData: data,\n\t}\n}", "func createSambaConf(ctx context.Context, sharePath, confLocation string) (string, error) {\n\tguestshare := CreateBasicShare(\"guestshare\", sharePath)\n\tguestshare.SetParam(\"guest ok\", \"yes\")\n\tguestshare.SetParam(\"force user\", \"chronos\")\n\n\tsecureshare := CreateBasicShare(\"secureshare\", sharePath)\n\tsecureshare.SetParam(\"guest ok\", \"no\")\n\tsecureshare.SetParam(\"valid users\", \"chronos\")\n\n\tconfig := NewConfig()\n\tconfig.SetGlobalParam(\"private dir\", confLocation)\n\tconfig.SetGlobalParam(\"security\", \"user\")\n\tconfig.SetGlobalParam(\"smb passwd file\", filepath.Join(confLocation, smbpasswdFile))\n\tconfig.SetGlobalParam(\"passdb backend\", \"smbpasswd\")\n\tconfig.AddFileShare(guestshare)\n\tconfig.AddFileShare(secureshare)\n\n\tsambaFileLocation := filepath.Join(confLocation, \"smb.conf\")\n\treturn sambaFileLocation, ioutil.WriteFile(sambaFileLocation, []byte(config.String()), 0644)\n}", "func loadConfig() {\n\toldUploadKeys = newUploadKeys\n\tuploadKeys = &oldUploadKeys\n\toldConfig = newConfig\n\tconfig = &oldConfig\n\tnewConfig = defaultConfig\n\n\t// populate with values from config file\n\tconfigBytes, err := ioutil.ReadFile(*configPath)\n\tif os.IsNotExist(err) {\n\t\t// don't continue if file doesn't exist\n\t} else if err != nil {\n\t\tlog.Printf(\"error loading config file: %v\", err)\n\t} else {\n\t\tif err := json.Unmarshal(configBytes, &newConfig); err != nil {\n\t\t\tlog.Printf(\"error parsing config file: %v\", err)\n\t\t}\n\t}\n\n\t// apply values from flags\n\tif *listenAddr != \"\" {\n\t\tnewConfig.ListenAddr = *listenAddr\n\t}\n\tif *uploadPath != \"\" {\n\t\tnewConfig.UploadPath = *uploadPath\n\t}\n\tif *uploadURL != \"\" {\n\t\tnewConfig.UploadURL = *uploadURL\n\t}\n\tif *remoteAddrHeader != \"\" {\n\t\tnewConfig.RemoteAddrHeader = *remoteAddrHeader\n\t}\n\n\t// just making config.Keys is initialized\n\tif newConfig.Keys == nil {\n\t\tnewConfig.Keys = make(map[string]string)\n\t}\n\n\tnewUploadKeys = make(map[string]bool)\n\n\tuploadKeyEnv := os.Getenv(\"UPLOAD_KEY\")\n\tif uploadKeyEnv != \"\" {\n\t\tenvKeys := strings.Split(uploadKeyEnv, \",\")\n\t\tfor _, key := range envKeys {\n\t\t\tnewUploadKeys[key] = true\n\t\t}\n\t}\n\n\tfor key := range newConfig.Keys {\n\t\tnewUploadKeys[key] = true\n\t}\n\n\tuploadKeys = &newUploadKeys\n\tconfig = &newConfig\n}", "func NewConfList(path string, defaultList []string) *ConfList {\n\tr := &ConfList{\n\t\tpath: path,\n\t}\n\tr.update()\n\tif len(r.data) == 0 {\n\t\tr.data = defaultList\n\t}\n\treturn r\n}", "func generateConfigFile(context *clusterd.Context, clusterInfo *ClusterInfo, pathRoot, keyringPath string, globalConfig *CephConfig, clientSettings map[string]string) (string, error) {\n\n\t// create the config directory\n\tif err := os.MkdirAll(pathRoot, 0744); err != nil {\n\t\treturn \"\", errors.Wrapf(err, \"failed to create config directory at %q\", pathRoot)\n\t}\n\n\tconfigFile, err := createGlobalConfigFileSection(context, clusterInfo, globalConfig)\n\tif err != nil {\n\t\treturn \"\", errors.Wrap(err, \"failed to create global config section\")\n\t}\n\n\tif err := mergeDefaultConfigWithRookConfigOverride(context, clusterInfo, configFile); err != nil {\n\t\treturn \"\", errors.Wrapf(err, \"failed to merge global config with %q\", k8sutil.ConfigOverrideName)\n\t}\n\n\tqualifiedUser := getQualifiedUser(clusterInfo.CephCred.Username)\n\tif err := addClientConfigFileSection(configFile, qualifiedUser, keyringPath, clientSettings); err != nil {\n\t\treturn \"\", errors.Wrap(err, \"failed to add admin client config section\")\n\t}\n\n\t// write the entire config to disk\n\tfilePath := getConfFilePath(pathRoot, clusterInfo.Namespace)\n\tlogger.Infof(\"writing config file %s\", filePath)\n\tif err := configFile.SaveTo(filePath); err != nil {\n\t\treturn \"\", errors.Wrapf(err, \"failed to save config file %s\", filePath)\n\t}\n\n\treturn filePath, nil\n}", "func (r *ConfigMapResource) CreateConfiguration(\n\tctx context.Context,\n) (*configuration.GlobalConfiguration, error) {\n\tcfg := configuration.For(r.pandaCluster.Spec.Version)\n\tcfg.NodeConfiguration = *config.ProdDefault()\n\tmountPoints := resourcetypes.GetTLSMountPoints()\n\n\tc := r.pandaCluster.Spec.Configuration\n\tcr := &cfg.NodeConfiguration.Redpanda\n\n\tinternalListener := r.pandaCluster.InternalListener()\n\tinternalAuthN := &internalListener.AuthenticationMethod\n\tif *internalAuthN == \"\" {\n\t\tinternalAuthN = nil\n\t}\n\tcr.KafkaAPI = []config.NamedAuthNSocketAddress{} // we don't want to inherit default kafka port\n\tcr.KafkaAPI = append(cr.KafkaAPI, config.NamedAuthNSocketAddress{\n\t\tAddress: \"0.0.0.0\",\n\t\tPort: internalListener.Port,\n\t\tName: InternalListenerName,\n\t\tAuthN: internalAuthN,\n\t})\n\n\texternalListener := r.pandaCluster.ExternalListener()\n\tif externalListener != nil {\n\t\texternalAuthN := &externalListener.AuthenticationMethod\n\t\tif *externalAuthN == \"\" {\n\t\t\texternalAuthN = nil\n\t\t}\n\t\tcr.KafkaAPI = append(cr.KafkaAPI, config.NamedAuthNSocketAddress{\n\t\t\tAddress: \"0.0.0.0\",\n\t\t\tPort: calculateExternalPort(internalListener.Port, r.pandaCluster.ExternalListener().Port),\n\t\t\tName: ExternalListenerName,\n\t\t\tAuthN: externalAuthN,\n\t\t})\n\t}\n\n\tcr.RPCServer.Port = clusterCRPortOrRPKDefault(c.RPCServer.Port, cr.RPCServer.Port)\n\tcr.AdvertisedRPCAPI = &config.SocketAddress{\n\t\tAddress: \"0.0.0.0\",\n\t\tPort: clusterCRPortOrRPKDefault(c.RPCServer.Port, cr.RPCServer.Port),\n\t}\n\n\tcr.AdminAPI[0].Port = clusterCRPortOrRPKDefault(r.pandaCluster.AdminAPIInternal().Port, cr.AdminAPI[0].Port)\n\tcr.AdminAPI[0].Name = AdminPortName\n\tif r.pandaCluster.AdminAPIExternal() != nil {\n\t\texternalAdminAPI := config.NamedSocketAddress{\n\t\t\tAddress: cr.AdminAPI[0].Address,\n\t\t\tPort: calculateExternalPort(cr.AdminAPI[0].Port, r.pandaCluster.AdminAPIExternal().Port),\n\t\t\tName: AdminPortExternalName,\n\t\t}\n\t\tcr.AdminAPI = append(cr.AdminAPI, externalAdminAPI)\n\t}\n\n\tcr.DeveloperMode = c.DeveloperMode\n\tcr.Directory = dataDirectory\n\tkl := r.pandaCluster.KafkaTLSListeners()\n\tfor i := range kl {\n\t\ttls := config.ServerTLS{\n\t\t\tName: kl[i].Name,\n\t\t\tKeyFile: fmt.Sprintf(\"%s/%s\", mountPoints.KafkaAPI.NodeCertMountDir, corev1.TLSPrivateKeyKey), // tls.key\n\t\t\tCertFile: fmt.Sprintf(\"%s/%s\", mountPoints.KafkaAPI.NodeCertMountDir, corev1.TLSCertKey), // tls.crt\n\t\t\tEnabled: true,\n\t\t\tRequireClientAuth: kl[i].TLS.RequireClientAuth,\n\t\t}\n\t\tif kl[i].TLS.RequireClientAuth {\n\t\t\ttls.TruststoreFile = fmt.Sprintf(\"%s/%s\", mountPoints.KafkaAPI.ClientCAMountDir, cmetav1.TLSCAKey)\n\t\t}\n\t\tcr.KafkaAPITLS = append(cr.KafkaAPITLS, tls)\n\t}\n\tadminAPITLSListener := r.pandaCluster.AdminAPITLS()\n\tif adminAPITLSListener != nil {\n\t\t// Only one TLS listener is supported (restricted by the webhook).\n\t\t// Determine the listener name based on being internal or external.\n\t\tname := AdminPortName\n\t\tif adminAPITLSListener.External.Enabled {\n\t\t\tname = AdminPortExternalName\n\t\t}\n\t\tadminTLS := config.ServerTLS{\n\t\t\tName: name,\n\t\t\tKeyFile: fmt.Sprintf(\"%s/%s\", mountPoints.AdminAPI.NodeCertMountDir, corev1.TLSPrivateKeyKey),\n\t\t\tCertFile: fmt.Sprintf(\"%s/%s\", mountPoints.AdminAPI.NodeCertMountDir, corev1.TLSCertKey),\n\t\t\tEnabled: true,\n\t\t\tRequireClientAuth: adminAPITLSListener.TLS.RequireClientAuth,\n\t\t}\n\t\tif adminAPITLSListener.TLS.RequireClientAuth {\n\t\t\tadminTLS.TruststoreFile = fmt.Sprintf(\"%s/%s\", mountPoints.AdminAPI.ClientCAMountDir, cmetav1.TLSCAKey)\n\t\t}\n\t\tcr.AdminAPITLS = append(cr.AdminAPITLS, adminTLS)\n\t}\n\n\tif r.pandaCluster.Spec.CloudStorage.Enabled {\n\t\tif err := r.prepareCloudStorage(ctx, cfg); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"preparing cloud storage: %w\", err)\n\t\t}\n\t}\n\n\tfor _, user := range r.pandaCluster.Spec.Superusers {\n\t\tif err := cfg.AppendToAdditionalRedpandaProperty(superusersConfigurationKey, user.Username); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"appending superusers property: %w\", err)\n\t\t}\n\t}\n\n\tif r.pandaCluster.Spec.EnableSASL {\n\t\tcfg.SetAdditionalRedpandaProperty(\"enable_sasl\", true)\n\t}\n\tif r.pandaCluster.Spec.KafkaEnableAuthorization != nil && *r.pandaCluster.Spec.KafkaEnableAuthorization {\n\t\tcfg.SetAdditionalRedpandaProperty(\"kafka_enable_authorization\", true)\n\t}\n\n\tpartitions := r.pandaCluster.Spec.Configuration.GroupTopicPartitions\n\tif partitions != 0 {\n\t\tcfg.SetAdditionalRedpandaProperty(\"group_topic_partitions\", partitions)\n\t}\n\n\tcfg.SetAdditionalRedpandaProperty(\"auto_create_topics_enabled\", r.pandaCluster.Spec.Configuration.AutoCreateTopics)\n\n\tif featuregates.ShadowIndex(r.pandaCluster.Spec.Version) {\n\t\tintervalSec := 60 * 30 // 60s * 30 = 30 minutes\n\t\tcfg.SetAdditionalRedpandaProperty(\"cloud_storage_segment_max_upload_interval_sec\", intervalSec)\n\t}\n\n\tcfg.SetAdditionalRedpandaProperty(\"log_segment_size\", logSegmentSize)\n\n\tif err := r.PrepareSeedServerList(cr); err != nil {\n\t\treturn nil, fmt.Errorf(\"preparing seed server list: %w\", err)\n\t}\n\n\tr.preparePandaproxy(&cfg.NodeConfiguration)\n\tr.preparePandaproxyTLS(&cfg.NodeConfiguration, mountPoints)\n\terr := r.preparePandaproxyClient(ctx, cfg, mountPoints)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"preparing proxy client: %w\", err)\n\t}\n\n\tif sr := r.pandaCluster.Spec.Configuration.SchemaRegistry; sr != nil {\n\t\tvar authN *string\n\t\tif sr.AuthenticationMethod != \"\" {\n\t\t\tauthN = &sr.AuthenticationMethod\n\t\t}\n\t\tcfg.NodeConfiguration.SchemaRegistry.SchemaRegistryAPI = []config.NamedAuthNSocketAddress{\n\t\t\t{\n\t\t\t\tAddress: \"0.0.0.0\",\n\t\t\t\tPort: sr.Port,\n\t\t\t\tName: SchemaRegistryPortName,\n\t\t\t\tAuthN: authN,\n\t\t\t},\n\t\t}\n\t}\n\tr.prepareSchemaRegistryTLS(&cfg.NodeConfiguration, mountPoints)\n\terr = r.prepareSchemaRegistryClient(ctx, cfg, mountPoints)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"preparing schemaRegistry client: %w\", err)\n\t}\n\n\tif featuregates.RackAwareness(r.pandaCluster.Spec.Version) {\n\t\tcfg.SetAdditionalRedpandaProperty(\"enable_rack_awareness\", true)\n\t}\n\n\tif err := cfg.SetAdditionalFlatProperties(r.pandaCluster.Spec.AdditionalConfiguration); err != nil {\n\t\treturn nil, fmt.Errorf(\"adding additional flat properties: %w\", err)\n\t}\n\n\treturn cfg, nil\n}", "func createConfig(ctx context.Context, req *events.Request) *config {\n\treturn &config{\n\t\tlog: l.Create(ctx, l.Input{\n\t\t\t\"service\": service,\n\t\t\t\"function\": function,\n\t\t\t\"env\": os.Getenv(\"ENVIRONMENT\"),\n\t\t\t\"stackId\": req.StackID,\n\t\t\t\"requestType\": req.RequestType,\n\t\t\t\"requestId\": req.RequestID,\n\t\t\t\"resourceType\": req.ResourceType,\n\t\t\t\"logicalResourceId\": req.LogicalResourceID,\n\t\t\t\"resourceProperties\": req.ResourceProperties,\n\t\t\t\"oldResourceProperties\": req.OldResourceProperties,\n\t\t}),\n\t\tphysicalID: \"NotAviable\",\n\t\tresourceProperties: &Client{},\n\t\toldResourceProperties: &Client{},\n\t}\n}", "func (mux *kvMux) OnNewRouteConfig(cfg *routeConfig) {\n\toldMuxState := mux.getState()\n\tnewMuxState := mux.newKVMuxState(cfg)\n\n\t// Attempt to atomically update the routing data\n\tif !mux.updateState(oldMuxState, newMuxState) {\n\t\tlogWarnf(\"Someone preempted the config update, skipping update\")\n\t\treturn\n\t}\n\n\tif oldMuxState == nil {\n\t\tif newMuxState.revID > -1 && mux.collectionsEnabled && !newMuxState.collectionsSupported {\n\t\t\tlogDebugf(\"Collections disabled as unsupported\")\n\t\t}\n\t\t// There is no existing muxer. We can simply start the new pipelines.\n\t\tfor _, pipeline := range newMuxState.pipelines {\n\t\t\tpipeline.StartClients()\n\t\t}\n\t} else {\n\t\tif !mux.collectionsEnabled {\n\t\t\t// If collections just aren't enabled then we never need to refresh the connections because collections\n\t\t\t// have come online.\n\t\t\tmux.pipelineTakeover(oldMuxState, newMuxState)\n\t\t} else if oldMuxState.revID == -1 || oldMuxState.collectionsSupported == newMuxState.collectionsSupported {\n\t\t\t// Get the new muxer to takeover the pipelines from the older one\n\t\t\tmux.pipelineTakeover(oldMuxState, newMuxState)\n\t\t} else {\n\t\t\t// Collections support has changed so we need to reconnect all connections in order to support the new\n\t\t\t// state.\n\t\t\tmux.reconnectPipelines(oldMuxState, newMuxState)\n\t\t}\n\n\t\tmux.requeueRequests(oldMuxState)\n\t}\n}", "func (i *TiFlashInstance) initTiFlashConfig(ctx context.Context, clusterVersion string, src map[string]any, paths meta.DirPaths) (map[string]any, error) {\n\tvar (\n\t\tpathConfig string\n\t\tisStorageDirsDefined bool\n\t\tdeprecatedUsersConfig string\n\t\tdaemonConfig string\n\t\tmarkCacheSize string\n\t\terr error\n\t)\n\tif isStorageDirsDefined, err = checkTiFlashStorageConfigWithVersion(clusterVersion, src); err != nil {\n\t\treturn nil, err\n\t}\n\t// For backward compatibility, we need to rollback to set 'path'\n\tif isStorageDirsDefined {\n\t\tpathConfig = \"#\"\n\t} else {\n\t\tpathConfig = fmt.Sprintf(`path: \"%s\"`, strings.Join(paths.Data, \",\"))\n\t}\n\n\tif tidbver.TiFlashDeprecatedUsersConfig(clusterVersion) {\n\t\t// For v4.0.12 or later, 5.0.0 or later, TiFlash can ignore these `user.*`, `quotas.*` settings\n\t\tdeprecatedUsersConfig = \"#\"\n\t} else {\n\t\t// These settings is required when the version is earlier than v4.0.12 and v5.0.0\n\t\tdeprecatedUsersConfig = `\n quotas.default.interval.duration: 3600\n quotas.default.interval.errors: 0\n quotas.default.interval.execution_time: 0\n quotas.default.interval.queries: 0\n quotas.default.interval.read_rows: 0\n quotas.default.interval.result_rows: 0\n users.default.password: \"\"\n users.default.profile: \"default\"\n users.default.quota: \"default\"\n users.default.networks.ip: \"::/0\"\n users.readonly.password: \"\"\n users.readonly.profile: \"readonly\"\n users.readonly.quota: \"default\"\n users.readonly.networks.ip: \"::/0\"\n profiles.default.load_balancing: \"random\"\n profiles.default.use_uncompressed_cache: 0\n profiles.readonly.readonly: 1\n`\n\t}\n\n\ttidbStatusAddrs := []string{}\n\tfor _, tidb := range i.topo.(*Specification).TiDBServers {\n\t\ttidbStatusAddrs = append(tidbStatusAddrs, utils.JoinHostPort(tidb.Host, tidb.StatusPort))\n\t}\n\n\tspec := i.InstanceSpec.(*TiFlashSpec)\n\tenableTLS := i.topo.(*Specification).GlobalOptions.TLSEnabled\n\thttpPort := \"#\"\n\t// For 7.1.0 or later, TiFlash HTTP service is removed, so we don't need to set http_port\n\tif !tidbver.TiFlashNotNeedHTTPPortConfig(clusterVersion) {\n\t\tif enableTLS {\n\t\t\thttpPort = fmt.Sprintf(`https_port: %d`, spec.HTTPPort)\n\t\t} else {\n\t\t\thttpPort = fmt.Sprintf(`http_port: %d`, spec.HTTPPort)\n\t\t}\n\t}\n\ttcpPort := \"#\"\n\t// Config tcp_port is only required for TiFlash version < 7.1.0, and is recommended to not specify for TiFlash version >= 7.1.0.\n\tif tidbver.TiFlashRequiresTCPPortConfig(clusterVersion) {\n\t\ttcpPort = fmt.Sprintf(`tcp_port: %d`, spec.TCPPort)\n\t}\n\n\t// set TLS configs\n\tspec.Config, err = i.setTLSConfig(ctx, enableTLS, spec.Config, paths)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttopo := Specification{}\n\n\tif tidbver.TiFlashNotNeedSomeConfig(clusterVersion) {\n\t\t// For 5.4.0 or later, TiFlash can ignore application.runAsDaemon and mark_cache_size setting\n\t\tdaemonConfig = \"#\"\n\t\tmarkCacheSize = \"#\"\n\t} else {\n\t\tdaemonConfig = `application.runAsDaemon: true`\n\t\tmarkCacheSize = `mark_cache_size: 5368709120`\n\t}\n\terr = yaml.Unmarshal([]byte(fmt.Sprintf(`\nserver_configs:\n tiflash:\n default_profile: \"default\"\n display_name: \"TiFlash\"\n listen_host: \"%[7]s\"\n tmp_path: \"%[11]s\"\n %[1]s\n %[3]s\n %[4]s\n flash.tidb_status_addr: \"%[5]s\"\n flash.service_addr: \"%[6]s\"\n flash.flash_cluster.cluster_manager_path: \"%[10]s/bin/tiflash/flash_cluster_manager\"\n flash.flash_cluster.log: \"%[2]s/tiflash_cluster_manager.log\"\n flash.flash_cluster.master_ttl: 60\n flash.flash_cluster.refresh_interval: 20\n flash.flash_cluster.update_rule_interval: 5\n flash.proxy.config: \"%[10]s/conf/tiflash-learner.toml\"\n status.metrics_port: %[8]d\n logger.errorlog: \"%[2]s/tiflash_error.log\"\n logger.log: \"%[2]s/tiflash.log\"\n logger.count: 20\n logger.level: \"debug\"\n logger.size: \"1000M\"\n %[13]s\n raft.pd_addr: \"%[9]s\"\n profiles.default.max_memory_usage: 0\n %[12]s\n %[14]s\n`,\n\t\tpathConfig,\n\t\tpaths.Log,\n\t\ttcpPort,\n\t\thttpPort,\n\t\tstrings.Join(tidbStatusAddrs, \",\"),\n\t\tutils.JoinHostPort(spec.Host, spec.FlashServicePort),\n\t\ti.GetListenHost(),\n\t\tspec.StatusPort,\n\t\tstrings.Join(i.topo.(*Specification).GetPDList(), \",\"),\n\t\tpaths.Deploy,\n\t\tfmt.Sprintf(\"%s/tmp\", paths.Data[0]),\n\t\tdeprecatedUsersConfig,\n\t\tdaemonConfig,\n\t\tmarkCacheSize,\n\t)), &topo)\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tconf := MergeConfig(topo.ServerConfigs.TiFlash, spec.Config, src)\n\treturn conf, nil\n}", "func newConfig() *config {\n\treturn &config{\n\t\tAddr: \":80\",\n\t\tCacheSize: 1000,\n\t\tLogLevel: \"info\",\n\t\tRequestTimeout: 3000,\n\t\tTargetAddr: \"https://places.aviasales.ru\",\n\t}\n}", "func newManagementConfig(cluster *v1alpha1.AtomixCluster) string {\n\treturn `\ncluster {\n node: ${atomix.node}\n\n discovery {\n type: dns\n service: ${atomix.service},\n }\n}\nmanagementGroup {\n type: raft\n partitions: 1\n members: ${atomix.members}\n storage.level: disk\n}\n`\n}", "func initConf() error {\n\tif m == nil || !m.Init() {\n\t\tlock := getLock()\n\t\tif !lock {\n\t\t\treturn errors.New(\"Failed to get lock\")\n\t\t}\n\t\terr := createDummyConf()\n\t\tif err != nil {\n\t\t\treturn errors.New(fmt.Sprintf(\"Failed to create dummy conf: %v\", err))\n\t\t}\n\t\tdefer func() {\n\t\t\tcleanup()\n\t\t\treleaseLock()\n\t\t}()\n\t\tc := &dummyConfSt{}\n\t\tmutable := make(map[string]bool)\n\t\tmutable[\"Boolm\"] = true\n\t\tmutable[\"Float32m\"] = true\n\t\tmutable[\"Float64m\"] = true\n\t\tmutable[\"Intm\"] = true\n\t\tmutable[\"Int8m\"] = true\n\t\tmutable[\"Int16m\"] = true\n\t\tmutable[\"Int32m\"] = true\n\t\tmutable[\"Int64m\"] = true\n\t\tmutable[\"Stringm\"] = true\n\t\tmutable[\"Uintm\"] = true\n\t\tmutable[\"Uint8m\"] = true\n\t\tmutable[\"Uint16m\"] = true\n\t\tmutable[\"Uint32m\"] = true\n\t\tmutable[\"Uint64m\"] = true\n\n\t\t// test initilzation\n\t\tm, err = InitJSONMutableConf(dummyPath, c, &mutable)\n\t\tif err != nil {\n\t\t\treturn errors.New(fmt.Sprintf(\"Failed to initialize conf: %v\", err))\n\t\t}\n\t}\n\treturn nil\n}", "func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime string, drvName string) config.ClusterConfig {\n\tvar cc config.ClusterConfig\n\n\t// networkPlugin cni deprecation warning\n\tchosenNetworkPlugin := viper.GetString(networkPlugin)\n\tif chosenNetworkPlugin == \"cni\" {\n\t\tout.WarningT(\"With --network-plugin=cni, you will need to provide your own CNI. See --cni flag as a user-friendly alternative\")\n\t}\n\n\tif !(driver.IsKIC(drvName) || driver.IsKVM(drvName) || driver.IsQEMU(drvName)) && viper.GetString(network) != \"\" {\n\t\tout.WarningT(\"--network flag is only valid with the docker/podman, KVM and Qemu drivers, it will be ignored\")\n\t}\n\n\tcheckNumaCount(k8sVersion)\n\n\tcheckExtraDiskOptions(cmd, drvName)\n\n\tcc = config.ClusterConfig{\n\t\tName: ClusterFlagValue(),\n\t\tKeepContext: viper.GetBool(keepContext),\n\t\tEmbedCerts: viper.GetBool(embedCerts),\n\t\tMinikubeISO: viper.GetString(isoURL),\n\t\tKicBaseImage: viper.GetString(kicBaseImage),\n\t\tNetwork: getNetwork(drvName),\n\t\tSubnet: viper.GetString(subnet),\n\t\tMemory: getMemorySize(cmd, drvName),\n\t\tCPUs: getCPUCount(drvName),\n\t\tDiskSize: getDiskSize(),\n\t\tDriver: drvName,\n\t\tListenAddress: viper.GetString(listenAddress),\n\t\tHyperkitVpnKitSock: viper.GetString(vpnkitSock),\n\t\tHyperkitVSockPorts: viper.GetStringSlice(vsockPorts),\n\t\tNFSShare: viper.GetStringSlice(nfsShare),\n\t\tNFSSharesRoot: viper.GetString(nfsSharesRoot),\n\t\tDockerEnv: config.DockerEnv,\n\t\tDockerOpt: config.DockerOpt,\n\t\tInsecureRegistry: insecureRegistry,\n\t\tRegistryMirror: registryMirror,\n\t\tHostOnlyCIDR: viper.GetString(hostOnlyCIDR),\n\t\tHypervVirtualSwitch: viper.GetString(hypervVirtualSwitch),\n\t\tHypervUseExternalSwitch: viper.GetBool(hypervUseExternalSwitch),\n\t\tHypervExternalAdapter: viper.GetString(hypervExternalAdapter),\n\t\tKVMNetwork: viper.GetString(kvmNetwork),\n\t\tKVMQemuURI: viper.GetString(kvmQemuURI),\n\t\tKVMGPU: viper.GetBool(kvmGPU),\n\t\tKVMHidden: viper.GetBool(kvmHidden),\n\t\tKVMNUMACount: viper.GetInt(kvmNUMACount),\n\t\tDisableDriverMounts: viper.GetBool(disableDriverMounts),\n\t\tUUID: viper.GetString(uuid),\n\t\tNoVTXCheck: viper.GetBool(noVTXCheck),\n\t\tDNSProxy: viper.GetBool(dnsProxy),\n\t\tHostDNSResolver: viper.GetBool(hostDNSResolver),\n\t\tHostOnlyNicType: viper.GetString(hostOnlyNicType),\n\t\tNatNicType: viper.GetString(natNicType),\n\t\tStartHostTimeout: viper.GetDuration(waitTimeout),\n\t\tExposedPorts: viper.GetStringSlice(ports),\n\t\tSSHIPAddress: viper.GetString(sshIPAddress),\n\t\tSSHUser: viper.GetString(sshSSHUser),\n\t\tSSHKey: viper.GetString(sshSSHKey),\n\t\tSSHPort: viper.GetInt(sshSSHPort),\n\t\tExtraDisks: viper.GetInt(extraDisks),\n\t\tCertExpiration: viper.GetDuration(certExpiration),\n\t\tMount: viper.GetBool(createMount),\n\t\tMountString: viper.GetString(mountString),\n\t\tMount9PVersion: viper.GetString(mount9PVersion),\n\t\tMountGID: viper.GetString(mountGID),\n\t\tMountIP: viper.GetString(mountIPFlag),\n\t\tMountMSize: viper.GetInt(mountMSize),\n\t\tMountOptions: viper.GetStringSlice(mountOptions),\n\t\tMountPort: uint16(viper.GetUint(mountPortFlag)),\n\t\tMountType: viper.GetString(mountTypeFlag),\n\t\tMountUID: viper.GetString(mountUID),\n\t\tBinaryMirror: viper.GetString(binaryMirror),\n\t\tDisableOptimizations: viper.GetBool(disableOptimizations),\n\t\tDisableMetrics: viper.GetBool(disableMetrics),\n\t\tCustomQemuFirmwarePath: viper.GetString(qemuFirmwarePath),\n\t\tSocketVMnetClientPath: detect.SocketVMNetClientPath(),\n\t\tSocketVMnetPath: detect.SocketVMNetPath(),\n\t\tStaticIP: viper.GetString(staticIP),\n\t\tKubernetesConfig: config.KubernetesConfig{\n\t\t\tKubernetesVersion: k8sVersion,\n\t\t\tClusterName: ClusterFlagValue(),\n\t\t\tNamespace: viper.GetString(startNamespace),\n\t\t\tAPIServerName: viper.GetString(apiServerName),\n\t\t\tAPIServerNames: apiServerNames,\n\t\t\tAPIServerIPs: apiServerIPs,\n\t\t\tDNSDomain: viper.GetString(dnsDomain),\n\t\t\tFeatureGates: viper.GetString(featureGates),\n\t\t\tContainerRuntime: rtime,\n\t\t\tCRISocket: viper.GetString(criSocket),\n\t\t\tNetworkPlugin: chosenNetworkPlugin,\n\t\t\tServiceCIDR: viper.GetString(serviceCIDR),\n\t\t\tImageRepository: getRepository(cmd, k8sVersion),\n\t\t\tExtraOptions: getExtraOptions(),\n\t\t\tShouldLoadCachedImages: viper.GetBool(cacheImages),\n\t\t\tCNI: getCNIConfig(cmd),\n\t\t\tNodePort: viper.GetInt(apiServerPort),\n\t\t},\n\t\tMultiNodeRequested: viper.GetInt(nodes) > 1,\n\t}\n\tcc.VerifyComponents = interpretWaitFlag(*cmd)\n\tif viper.GetBool(createMount) && driver.IsKIC(drvName) {\n\t\tcc.ContainerVolumeMounts = []string{viper.GetString(mountString)}\n\t}\n\n\tif driver.IsKIC(drvName) {\n\t\tsi, err := oci.CachedDaemonInfo(drvName)\n\t\tif err != nil {\n\t\t\texit.Message(reason.Usage, \"Ensure your {{.driver_name}} is running and is healthy.\", out.V{\"driver_name\": driver.FullName(drvName)})\n\t\t}\n\t\tif si.Rootless {\n\t\t\tout.Styled(style.Notice, \"Using rootless {{.driver_name}} driver\", out.V{\"driver_name\": driver.FullName(drvName)})\n\t\t\tif cc.KubernetesConfig.ContainerRuntime == constants.Docker {\n\t\t\t\texit.Message(reason.Usage, \"--container-runtime must be set to \\\"containerd\\\" or \\\"cri-o\\\" for rootless\")\n\t\t\t}\n\t\t\t// KubeletInUserNamespace feature gate is essential for rootless driver.\n\t\t\t// See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-in-userns/\n\t\t\tcc.KubernetesConfig.FeatureGates = addFeatureGate(cc.KubernetesConfig.FeatureGates, \"KubeletInUserNamespace=true\")\n\t\t} else {\n\t\t\tif oci.IsRootlessForced() {\n\t\t\t\tif driver.IsDocker(drvName) {\n\t\t\t\t\texit.Message(reason.Usage, \"Using rootless Docker driver was required, but the current Docker does not seem rootless. Try 'docker context use rootless' .\")\n\t\t\t\t} else {\n\t\t\t\t\texit.Message(reason.Usage, \"Using rootless driver was required, but the current driver does not seem rootless\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tout.Styled(style.Notice, \"Using {{.driver_name}} driver with root privileges\", out.V{\"driver_name\": driver.FullName(drvName)})\n\t\t}\n\t\t// for btrfs: if k8s < v1.25.0-beta.0 set kubelet's LocalStorageCapacityIsolation feature gate flag to false,\n\t\t// and if k8s >= v1.25.0-beta.0 (when it went ga and removed as feature gate), set kubelet's localStorageCapacityIsolation option (via kubeadm config) to false.\n\t\t// ref: https://github.com/kubernetes/minikube/issues/14728#issue-1327885840\n\t\tif si.StorageDriver == \"btrfs\" {\n\t\t\tif semver.MustParse(strings.TrimPrefix(k8sVersion, version.VersionPrefix)).LT(semver.MustParse(\"1.25.0-beta.0\")) {\n\t\t\t\tklog.Info(\"auto-setting LocalStorageCapacityIsolation to false because using btrfs storage driver\")\n\t\t\t\tcc.KubernetesConfig.FeatureGates = addFeatureGate(cc.KubernetesConfig.FeatureGates, \"LocalStorageCapacityIsolation=false\")\n\t\t\t} else if !cc.KubernetesConfig.ExtraOptions.Exists(\"kubelet.localStorageCapacityIsolation=false\") {\n\t\t\t\tif err := cc.KubernetesConfig.ExtraOptions.Set(\"kubelet.localStorageCapacityIsolation=false\"); err != nil {\n\t\t\t\t\texit.Error(reason.InternalConfigSet, \"failed to set extra option\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif runtime.GOOS == \"linux\" && si.DockerOS == \"Docker Desktop\" {\n\t\t\tout.WarningT(\"For an improved experience it's recommended to use Docker Engine instead of Docker Desktop.\\nDocker Engine installation instructions: https://docs.docker.com/engine/install/#server\")\n\t\t}\n\t}\n\n\treturn cc\n}", "func mockConfig(num int) *KConf {\n\tconfig := clientcmdapi.NewConfig()\n\tfor i := 0; i < num; i++ {\n\t\tvar name string\n\t\tif i == 0 {\n\t\t\tname = \"test\"\n\t\t} else {\n\t\t\tname = fmt.Sprintf(\"test-%d\", i)\n\t\t}\n\t\tconfig.Clusters[name] = &clientcmdapi.Cluster{\n\t\t\tLocationOfOrigin: \"/home/user/.kube/config\",\n\t\t\tServer: fmt.Sprintf(\"https://example-%s.com:6443\", name),\n\t\t\tInsecureSkipTLSVerify: true,\n\t\t\tCertificateAuthority: \"bbbbbbbbbbbb\",\n\t\t\tCertificateAuthorityData: []byte(\"bbbbbbbbbbbb\"),\n\t\t}\n\t\tconfig.AuthInfos[name] = &clientcmdapi.AuthInfo{\n\t\t\tLocationOfOrigin: \"/home/user/.kube/config\",\n\t\t\tToken: fmt.Sprintf(\"bbbbbbbbbbbb-%s\", name),\n\t\t}\n\t\tconfig.Contexts[name] = &clientcmdapi.Context{\n\t\t\tLocationOfOrigin: \"/home/user/.kube/config\",\n\t\t\tCluster: name,\n\t\t\tAuthInfo: name,\n\t\t\tNamespace: \"default\",\n\t\t}\n\t}\n\treturn &KConf{Config: *config}\n}", "func DefaultEnvConfig() (*Config, error) {\n\tif !env.OnGCE() {\n\t\treturn nil, nil\n\t}\n\tauth := \"none\"\n\tuser, _ := metadata.InstanceAttributeValue(\"camlistore-username\")\n\tpass, _ := metadata.InstanceAttributeValue(\"camlistore-password\")\n\tconfBucket, err := metadata.InstanceAttributeValue(\"camlistore-config-dir\")\n\tif confBucket == \"\" || err != nil {\n\t\treturn nil, fmt.Errorf(\"VM instance metadata key 'camlistore-config-dir' not set: %v\", err)\n\t}\n\tblobBucket, err := metadata.InstanceAttributeValue(\"camlistore-blob-dir\")\n\tif blobBucket == \"\" || err != nil {\n\t\treturn nil, fmt.Errorf(\"VM instance metadata key 'camlistore-blob-dir' not set: %v\", err)\n\t}\n\tif user != \"\" && pass != \"\" {\n\t\tauth = \"userpass:\" + user + \":\" + pass\n\t}\n\n\tif v := osutil.SecretRingFile(); !strings.HasPrefix(v, \"/gcs/\") {\n\t\treturn nil, fmt.Errorf(\"Internal error: secret ring path on GCE should be at /gcs/, not %q\", v)\n\t}\n\tkeyID, secRing, err := getOrMakeKeyring()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\thighConf := &serverconfig.Config{\n\t\tAuth: auth,\n\t\tHTTPS: true,\n\t\tIdentity: keyID,\n\t\tIdentitySecretRing: secRing,\n\t\tGoogleCloudStorage: \":\" + strings.TrimPrefix(blobBucket, \"gs://\"),\n\t\tPackRelated: true,\n\t\tShareHandler: true,\n\t}\n\n\texternalIP, _ := metadata.ExternalIP()\n\thostName, _ := metadata.InstanceAttributeValue(\"camlistore-hostname\")\n\t// If they specified a hostname (probably with pk-deploy), then:\n\t// if it looks like an FQDN, perkeepd is going to rely on Let's\n\t// Encrypt, else perkeepd is going to generate some self-signed for that\n\t// hostname.\n\t// Also, if the hostname is in camlistore.net, we want Perkeep to initialize\n\t// exactly as if the instance had no hostname, so that it registers its hostname/IP\n\t// with the camlistore.net DNS server (possibly needlessly, if the instance IP has\n\t// not changed) again.\n\tif hostName != \"\" && !strings.HasSuffix(hostName, CamliNetDomain) {\n\t\thighConf.BaseURL = fmt.Sprintf(\"https://%s\", hostName)\n\t\thighConf.Listen = \"0.0.0.0:443\"\n\t} else {\n\t\thighConf.CamliNetIP = externalIP\n\t}\n\n\t// Detect a linked Docker MySQL container. It must have alias \"mysqldb\".\n\tmysqlPort := os.Getenv(\"MYSQLDB_PORT\")\n\tif !strings.HasPrefix(mysqlPort, \"tcp://\") {\n\t\t// No MySQL\n\t\t// TODO: also detect Cloud SQL.\n\t\thighConf.KVFile = \"/index.kv\"\n\t\treturn genLowLevelConfig(highConf)\n\t}\n\thostPort := strings.TrimPrefix(mysqlPort, \"tcp://\")\n\thighConf.MySQL = \"root@\" + hostPort + \":\" // no password\n\tconfigVersion, err := metadata.InstanceAttributeValue(\"perkeep-config-version\")\n\tif configVersion == \"\" || err != nil {\n\t\t// the launcher is deploying a pre-\"perkeep-config-version\" Perkeep, which means\n\t\t// we want the old configuration, with DBNames\n\t\thighConf.DBUnique = useDBNamesConfig\n\t} else if configVersion != \"1\" {\n\t\treturn nil, fmt.Errorf(\"unexpected value for VM instance metadata key 'perkeep-config-version': %q\", configVersion)\n\t}\n\n\tconf, err := genLowLevelConfig(highConf)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := conf.readFields(); err != nil {\n\t\treturn nil, err\n\t}\n\treturn conf, nil\n}", "func ReLoadConfigAPIHandler(w http.ResponseWriter, r *http.Request) {\n\tLog := Logger.NewSessionLogger()\n\n\tif AliceNodeStart && BobNodeStart {\n\t\t//TODO: be capable to modify\n\t\tLog.Warnf(\"the node has started and can not modify config.\")\n\t\tfmt.Fprintf(w, RESPONSE_HAS_STARTED)\n\t\treturn\n\t}\n\tvar plog PodLog\n\tplog.Result = LOG_RESULT_FAILED\n\tplog.Operation = LOG_OPERATION_TYPE_CONFIG_SETTING\n\n\tdefer func() {\n\t\terr := insertLogToDB(plog)\n\t\tif err != nil {\n\t\t\tLog.Warnf(\"insert log error! %v\", err)\n\t\t\treturn\n\t\t}\n\t\tnodeRecovery(w, Log)\n\t}()\n\n\tif !AliceNodeStart {\n\t\tip := r.FormValue(\"ip\")\n\t\tif ip != \"\" {\n\t\t\tLog.Debugf(\"ip=%v\", ip)\n\t\t\tBConf.NetIP = ip\n\t\t}\n\t\tplog.Detail = \"modify ip =\" + ip + \";\"\n\t}\n\n\tif !AliceNodeStart && !BobNodeStart {\n\t\tpassword := r.FormValue(\"password\")\n\t\tkeystoreFile := r.FormValue(\"keystore\")\n\t\tprivkey := r.FormValue(\"privkey\")\n\t\tif privkey != \"\" {\n\t\t\tLog.Debugf(\"import private key. privkey=%v\", privkey)\n\t\t\tPrivateKeyECDSA, err := crypto.HexToECDSA(privkey)\n\t\t\tif err != nil {\n\t\t\t\tLog.Warnf(\"failed to parse private key. err=%v\", err)\n\t\t\t\tfmt.Fprintf(w, RESPONSE_UPLOAD_KEY_FAILED)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tpublicKey := PrivateKeyECDSA.Public()\n\t\t\tLog.Debugf(\"publicKey=%v\", publicKey)\n\t\t\tplog.Detail = plog.Detail + \"modify eth key, address=%v\" + \"TODO\" + \";\"\n\t\t\tpublicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)\n\t\t\tif !ok {\n\t\t\t\tLog.Warnf(\"invalid private key.\")\n\t\t\t\tfmt.Fprintf(w, RESPONSE_UPLOAD_KEY_FAILED)\n\t\t\t\treturn\n\t\t\t} else {\n\t\t\t\tLog.Debugf(\"privateKeyECDSA=%v\", PrivateKeyECDSA)\n\t\t\t\tkey := &keystore.Key{\n\t\t\t\t\tAddress: crypto.PubkeyToAddress(*publicKeyECDSA),\n\t\t\t\t\tPrivateKey: PrivateKeyECDSA,\n\t\t\t\t}\n\t\t\t\terr = ConnectToProvider(key, BConf.ContractAddr, Log)\n\t\t\t\tif err != nil {\n\t\t\t\t\tLog.Warnf(\"failed to connect to provider for contract. err=%v\", err)\n\t\t\t\t\tfmt.Fprintf(w, RESPONSE_INITIALIZE_FAILED)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tETHKey = key\n\t\t\t\tLog.Infof(\"success to connect to provider for contract\")\n\t\t\t}\n\t\t\t//TODO: save keystore\n\t\t} else if password != \"\" && keystoreFile != \"\" {\n\t\t\tplog.Detail = plog.Detail + \"modify eth key, keystoreFile=\" + keystoreFile\n\t\t\tkey, err := initKeyStore(keystoreFile, password, Log)\n\t\t\tif err != nil {\n\t\t\t\tLog.Errorf(\"Failed to initialize key store file. err=%v\", err)\n\t\t\t\tfmt.Fprintf(w, RESPONSE_INITIALIZE_FAILED)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tLog.Infof(\"initialize key store finish. ethaddr=%v.\", key.Address.Hex())\n\t\t\tplog.Detail = plog.Detail + \", address=\" + key.Address.Hex()\n\t\t\terr = ConnectToProvider(key, BConf.ContractAddr, Log)\n\t\t\tif err != nil {\n\t\t\t\tLog.Warnf(\"Failed to connect to provider for contract. err=%v\", err)\n\t\t\t\tfmt.Fprintf(w, RESPONSE_INITIALIZE_FAILED)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tETHKey = key\n\t\t\tLog.Infof(\"success to connect to provider for contract\")\n\t\t\tBConf.KeyStoreFile = keystoreFile\n\t\t}\n\t}\n\n\terr := saveBasicConfig(BConf, DEFAULT_BASIC_CONFGI_FILE)\n\tif err != nil {\n\t\tLog.Warnf(\"failed to save basic config. file = %v, err=%v\", DEFAULT_BASIC_CONFGI_FILE, err)\n\t\tfmt.Fprintf(w, RESPONSE_SAVE_CONFIG_FILE_FAILED)\n\t\treturn\n\t}\n\tplog.Result = LOG_RESULT_SUCCESS\n\tLog.Infof(\"success to set basic config. config=%v\", BConf)\n\tfmt.Fprintf(w, `{\"code\":\"0\",\"message\":\"set config successfully\"}`)\n\treturn\n}", "func varlinkCreateToCreateConfig(ctx context.Context, create iopodman.Create, runtime *libpod.Runtime, imageName string, data *inspect.ImageData) (*cc.CreateConfig, error) {\n\tvar (\n\t\tinputCommand, command []string\n\t\tmemoryLimit, memoryReservation, memorySwap, memoryKernel int64\n\t\tblkioWeight uint16\n\t)\n\n\tidmappings, err := util.ParseIDMapping(create.Uidmap, create.Gidmap, create.Subuidname, create.Subgidname)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tinputCommand = create.Command\n\tentrypoint := create.Entrypoint\n\n\t// ENTRYPOINT\n\t// User input entrypoint takes priority over image entrypoint\n\tif len(entrypoint) == 0 {\n\t\tentrypoint = data.Config.Entrypoint\n\t}\n\t// if entrypoint=, we need to clear the entrypoint\n\tif len(entrypoint) == 1 && strings.Join(create.Entrypoint, \"\") == \"\" {\n\t\tentrypoint = []string{}\n\t}\n\t// Build the command\n\t// If we have an entry point, it goes first\n\tif len(entrypoint) > 0 {\n\t\tcommand = entrypoint\n\t}\n\tif len(inputCommand) > 0 {\n\t\t// User command overrides data CMD\n\t\tcommand = append(command, inputCommand...)\n\t} else if len(data.Config.Cmd) > 0 && len(command) == 0 {\n\t\t// If not user command, add CMD\n\t\tcommand = append(command, data.Config.Cmd...)\n\t}\n\n\tif create.Resources.Blkio_weight != 0 {\n\t\tblkioWeight = uint16(create.Resources.Blkio_weight)\n\t}\n\n\tstopSignal := syscall.SIGTERM\n\tif create.Stop_signal > 0 {\n\t\tstopSignal, err = signal.ParseSignal(fmt.Sprintf(\"%d\", create.Stop_signal))\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tuser := create.User\n\tif user == \"\" {\n\t\tuser = data.Config.User\n\t}\n\n\t// EXPOSED PORTS\n\tportBindings, err := cc.ExposedPorts(create.Exposed_ports, create.Publish, create.Publish_all, data.Config.ExposedPorts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// NETWORK MODE\n\tnetworkMode := create.Net_mode\n\tif networkMode == \"\" {\n\t\tif rootless.IsRootless() {\n\t\t\tnetworkMode = \"slirp4netns\"\n\t\t} else {\n\t\t\tnetworkMode = \"bridge\"\n\t\t}\n\t}\n\n\t// WORKING DIR\n\tworkDir := create.Work_dir\n\tif workDir == \"\" {\n\t\tworkDir = \"/\"\n\t}\n\n\timageID := data.ID\n\tconfig := &cc.CreateConfig{\n\t\tRuntime: runtime,\n\t\tBuiltinImgVolumes: data.Config.Volumes,\n\t\tConmonPidFile: create.Conmon_pidfile,\n\t\tImageVolumeType: create.Image_volume_type,\n\t\tCapAdd: create.Cap_add,\n\t\tCapDrop: create.Cap_drop,\n\t\tCgroupParent: create.Cgroup_parent,\n\t\tCommand: command,\n\t\tDetach: create.Detach,\n\t\tDevices: create.Devices,\n\t\tDNSOpt: create.Dns_opt,\n\t\tDNSSearch: create.Dns_search,\n\t\tDNSServers: create.Dns_servers,\n\t\tEntrypoint: create.Entrypoint,\n\t\tEnv: create.Env,\n\t\tGroupAdd: create.Group_add,\n\t\tHostname: create.Hostname,\n\t\tHostAdd: create.Host_add,\n\t\tIDMappings: idmappings,\n\t\tImage: imageName,\n\t\tImageID: imageID,\n\t\tInteractive: create.Interactive,\n\t\tLabels: create.Labels,\n\t\tLogDriver: create.Log_driver,\n\t\tLogDriverOpt: create.Log_driver_opt,\n\t\tName: create.Name,\n\t\tNetwork: networkMode,\n\t\tIpcMode: namespaces.IpcMode(create.Ipc_mode),\n\t\tNetMode: namespaces.NetworkMode(networkMode),\n\t\tUtsMode: namespaces.UTSMode(create.Uts_mode),\n\t\tPidMode: namespaces.PidMode(create.Pid_mode),\n\t\tPod: create.Pod,\n\t\tPrivileged: create.Privileged,\n\t\tPublish: create.Publish,\n\t\tPublishAll: create.Publish_all,\n\t\tPortBindings: portBindings,\n\t\tQuiet: create.Quiet,\n\t\tReadOnlyRootfs: create.Readonly_rootfs,\n\t\tResources: cc.CreateResourceConfig{\n\t\t\tBlkioWeight: blkioWeight,\n\t\t\tBlkioWeightDevice: create.Resources.Blkio_weight_device,\n\t\t\tCPUShares: uint64(create.Resources.Cpu_shares),\n\t\t\tCPUPeriod: uint64(create.Resources.Cpu_period),\n\t\t\tCPUsetCPUs: create.Resources.Cpuset_cpus,\n\t\t\tCPUsetMems: create.Resources.Cpuset_mems,\n\t\t\tCPUQuota: create.Resources.Cpu_quota,\n\t\t\tCPURtPeriod: uint64(create.Resources.Cpu_rt_period),\n\t\t\tCPURtRuntime: create.Resources.Cpu_rt_runtime,\n\t\t\tCPUs: create.Resources.Cpus,\n\t\t\tDeviceReadBps: create.Resources.Device_read_bps,\n\t\t\tDeviceReadIOps: create.Resources.Device_write_bps,\n\t\t\tDeviceWriteBps: create.Resources.Device_read_iops,\n\t\t\tDeviceWriteIOps: create.Resources.Device_write_iops,\n\t\t\tDisableOomKiller: create.Resources.Disable_oomkiller,\n\t\t\tShmSize: create.Resources.Shm_size,\n\t\t\tMemory: memoryLimit,\n\t\t\tMemoryReservation: memoryReservation,\n\t\t\tMemorySwap: memorySwap,\n\t\t\tMemorySwappiness: int(create.Resources.Memory_swappiness),\n\t\t\tKernelMemory: memoryKernel,\n\t\t\tOomScoreAdj: int(create.Resources.Oom_score_adj),\n\t\t\tPidsLimit: create.Resources.Pids_limit,\n\t\t\tUlimit: create.Resources.Ulimit,\n\t\t},\n\t\tRm: create.Rm,\n\t\tStopSignal: stopSignal,\n\t\tStopTimeout: uint(create.Stop_timeout),\n\t\tSysctl: create.Sys_ctl,\n\t\tTmpfs: create.Tmpfs,\n\t\tTty: create.Tty,\n\t\tUser: user,\n\t\tUsernsMode: namespaces.UsernsMode(create.Userns_mode),\n\t\tVolumes: create.Volumes,\n\t\tWorkDir: workDir,\n\t}\n\n\treturn config, nil\n}", "func (ah *AuthLoinHttpService) InitConf(url string, conf string) error {\n\tah.url = url\n\tah.extData = conf\n\treturn nil\n}" ]
[ "0.64874506", "0.63530076", "0.61503875", "0.6060684", "0.5966099", "0.5947129", "0.5844353", "0.5781085", "0.5682955", "0.55900925", "0.5584936", "0.5520305", "0.5500407", "0.54911816", "0.5455597", "0.54216796", "0.53766614", "0.536281", "0.5348187", "0.5343782", "0.53393775", "0.5309704", "0.53065985", "0.5232712", "0.5213869", "0.5213869", "0.5208552", "0.52075434", "0.517498", "0.51649827", "0.51552826", "0.51495415", "0.51360506", "0.5110618", "0.5093586", "0.5091931", "0.507814", "0.50741255", "0.5074012", "0.50719815", "0.50653714", "0.50506246", "0.504886", "0.50343084", "0.50283647", "0.5026792", "0.4996353", "0.4988364", "0.49882343", "0.49808687", "0.49800727", "0.49779743", "0.49630776", "0.4962329", "0.49616846", "0.49542812", "0.49540487", "0.4952288", "0.49521467", "0.49503207", "0.49393877", "0.4936713", "0.49322757", "0.49225837", "0.49148533", "0.49117112", "0.49075887", "0.49074876", "0.49065638", "0.49008635", "0.4899268", "0.48942468", "0.4878255", "0.4875998", "0.48745468", "0.48712775", "0.48707253", "0.48673025", "0.48670697", "0.48578945", "0.48545843", "0.48527095", "0.48480514", "0.48398206", "0.48389256", "0.48368168", "0.483348", "0.48325494", "0.4831481", "0.48288077", "0.48275614", "0.48260394", "0.48252335", "0.4823934", "0.4815903", "0.4815137", "0.48128825", "0.48070574", "0.48021075", "0.4794851" ]
0.6411646
1