_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q4700 | AssignedUnits | train | func (mr *MockGenerationMockRecorder) AssignedUnits() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AssignedUnits", reflect.TypeOf((*MockGeneration)(nil).AssignedUnits))
} | go | {
"resource": ""
} |
q4701 | Commit | train | func (m *MockGeneration) Commit(arg0 string) (int, error) {
ret := m.ctrl.Call(m, "Commit", arg0)
ret0, _ := ret[0].(int)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q4702 | Created | train | func (m *MockGeneration) Created() int64 {
ret := m.ctrl.Call(m, "Created")
ret0, _ := ret[0].(int64)
return ret0
} | go | {
"resource": ""
} |
q4703 | CreatedBy | train | func (m *MockGeneration) CreatedBy() string {
ret := m.ctrl.Call(m, "CreatedBy")
ret0, _ := ret[0].(string)
return ret0
} | go | {
"resource": ""
} |
q4704 | DefaultCharmConfig | train | func (m *MockApplication) DefaultCharmConfig() (charm_v6.Settings, error) {
ret := m.ctrl.Call(m, "DefaultCharmConfig")
ret0, _ := ret[0].(charm_v6.Settings)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q4705 | UnitNames | train | func (m *MockApplication) UnitNames() ([]string, error) {
ret := m.ctrl.Call(m, "UnitNames")
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q4706 | invoke | train | func (b block) invoke(ch chan<- block) error {
for {
select {
case <-b.stop:
return errStopped
case <-b.cancel:
return lease.ErrWaitCancelled
case ch <- b:
ch = nil
case <-b.unblock:
return nil
}
}
} | go | {
"resource": ""
} |
q4707 | add | train | func (b blocks) add(block block) {
b[block.leaseKey] = append(b[block.leaseKey], block.unblock)
} | go | {
"resource": ""
} |
q4708 | unblock | train | func (b blocks) unblock(lease lease.Key) {
unblocks := b[lease]
delete(b, lease)
for _, unblock := range unblocks {
close(unblock)
}
} | go | {
"resource": ""
} |
q4709 | NewLock | train | func NewLock(agentConfig agent.Config) gate.Lock {
lock := gate.NewLock()
if wrench.IsActive(wrenchKey(agentConfig), "always-try-upgrade") {
// Always enter upgrade mode. This allows test of upgrades
// even when there's actually no upgrade steps to run.
return lock
}
// Build numbers are irrelevant to upgr... | go | {
"resource": ""
} |
q4710 | NewWorker | train | func NewWorker(
upgradeComplete gate.Lock,
agent agent.Agent,
apiConn api.Connection,
jobs []multiwatcher.MachineJob,
openState func() (*state.StatePool, error),
preUpgradeSteps func(st *state.StatePool, agentConf agent.Config, isController, isMasterServer, isCaas bool) error,
machine StatusSetter,
isCaas bool,... | go | {
"resource": ""
} |
q4711 | runUpgrades | train | func (w *upgradesteps) runUpgrades() error {
upgradeInfo, err := w.prepareForUpgrade()
if err != nil {
return err
}
if wrench.IsActive(w.wrenchKey(), "fail-upgrade") {
return errors.New("wrench")
}
if err := w.agent.ChangeConfig(w.runUpgradeSteps); err != nil {
return err
}
if err := w.finaliseUpgrade(... | go | {
"resource": ""
} |
q4712 | runUpgradeSteps | train | func (w *upgradesteps) runUpgradeSteps(agentConfig agent.ConfigSetter) error {
var upgradeErr error
w.machine.SetStatus(status.Started, fmt.Sprintf("upgrading to %v", w.toVersion), nil)
stBackend := upgrades.NewStateBackend(w.pool)
context := upgrades.NewContext(agentConfig, w.apiConn, stBackend)
logger.Infof("st... | go | {
"resource": ""
} |
q4713 | jobsToTargets | train | func jobsToTargets(jobs []multiwatcher.MachineJob, isMaster bool) (targets []upgrades.Target) {
if jobs == nil {
return
}
for _, job := range jobs {
switch job {
case multiwatcher.JobManageModel:
targets = append(targets, upgrades.Controller)
if isMaster {
targets = append(targets, upgrades.DatabaseM... | go | {
"resource": ""
} |
q4714 | Validate | train | func (config Config) Validate() error {
if config.Facade == nil {
return errors.NotValidf("nil Facade")
}
return nil
} | go | {
"resource": ""
} |
q4715 | New | train | func New(config Config) (worker.Worker, error) {
if err := config.Validate(); err != nil {
return nil, errors.Trace(err)
}
swConfig := watcher.StringsConfig{
Handler: &handler{config},
}
return watcher.NewStringsWorker(swConfig)
} | go | {
"resource": ""
} |
q4716 | Handle | train | func (handler *handler) Handle(_ <-chan struct{}, applications []string) error {
return handler.config.Facade.Rescale(applications)
} | go | {
"resource": ""
} |
q4717 | docIDInt64 | train | func docIDInt64(modelUUID string, localID int64) string {
return modelUUID + ":" + strconv.FormatInt(localID, 10)
} | go | {
"resource": ""
} |
q4718 | NewDeadWatcher | train | func NewDeadWatcher(err error) *Watcher {
var w Watcher
w.tomb.Kill(errors.Trace(err))
return &w
} | go | {
"resource": ""
} |
q4719 | NewWatcher | train | func NewWatcher(base *mgo.Collection, modelTag names.ModelTag) *Watcher {
w := &Watcher{
modelUUID: modelTag.Id(),
base: base,
pings: pingsC(base),
beings: beingsC(base),
beingKey: make(map[int64]string),
beingSeq: make(map[string]int64),
watches: make(map[string][]chan<- Ch... | go | {
"resource": ""
} |
q4720 | Watch | train | func (w *Watcher) Watch(key string, ch chan<- Change) {
w.sendReq(reqWatch{key, ch})
} | go | {
"resource": ""
} |
q4721 | Unwatch | train | func (w *Watcher) Unwatch(key string, ch chan<- Change) {
w.sendReq(reqUnwatch{key, ch})
} | go | {
"resource": ""
} |
q4722 | Sync | train | func (w *Watcher) Sync() {
done := make(chan bool)
w.sendReq(reqSync{done})
select {
case <-done:
case <-w.tomb.Dying():
}
} | go | {
"resource": ""
} |
q4723 | Alive | train | func (w *Watcher) Alive(key string) (bool, error) {
result := make(chan bool, 1)
w.sendReq(reqAlive{key, result})
var alive bool
select {
case alive = <-result:
case <-w.tomb.Dying():
return false, errors.Errorf("cannot check liveness: watcher is dying")
}
logger.Tracef("[%s] Alive(%q) -> %v", w.modelUUID[:6]... | go | {
"resource": ""
} |
q4724 | loop | train | func (w *Watcher) loop() error {
var err error
if w.delta, err = clockDelta(w.base); err != nil {
return errors.Trace(err)
}
// Always sync before handling request.
if err := w.sync(); err != nil {
return errors.Trace(err)
}
w.next = time.After(time.Duration(period) * time.Second)
for {
select {
case <-... | go | {
"resource": ""
} |
q4725 | checkShouldPrune | train | func (w *Watcher) checkShouldPrune() {
chanceToPrune := float64(w.syncsSinceLastPrune) * psuedoRandomFactor
if chanceToPrune < 1.0 && rand.Float64() > chanceToPrune {
return
}
// When we decide to prune, we also drop our old cached beings
logger.Debugf("watcher %q decided to prune %q and %q", w.modelUUID, w.bein... | go | {
"resource": ""
} |
q4726 | decompressPings | train | func decompressPings(maps []map[string]int64) ([]int64, error) {
if len(maps) == 0 {
return nil, nil
}
// First step, merge all value structures together.
// Every ping has a bit field in an int64. However, bitwise-or preserves
// everything that was ever alive without having to decode them multiple times.
base... | go | {
"resource": ""
} |
q4727 | sync | train | func (w *Watcher) sync() error {
session := w.pings.Database.Session.Copy()
defer session.Close()
pings, err := w.lookupPings(session)
if err != nil {
return err
}
dead, err := w.lookForDead(pings)
if err != nil {
return err
}
alive, unknownSeqs, err := w.handleAlive(pings)
if err != nil {
return err
}... | go | {
"resource": ""
} |
q4728 | NewPinger | train | func NewPinger(base *mgo.Collection, modelTag names.ModelTag, key string, recorderFunc func() PingRecorder) *Pinger {
return &Pinger{
base: base,
pings: pingsC(base),
beingKey: key,
modelUUID: modelTag.Id(),
recorderFunc: recorderFunc,
}
} | go | {
"resource": ""
} |
q4729 | Start | train | func (p *Pinger) Start() error {
p.mu.Lock()
defer p.mu.Unlock()
if p.started {
return errors.Errorf("pinger already started")
}
p.tomb = tomb.Tomb{}
if err := p.prepare(); err != nil {
return errors.Trace(err)
}
logger.Tracef("[%s] starting pinger for %q with seq=%d", p.modelUUID[:6], p.beingKey, p.beingSe... | go | {
"resource": ""
} |
q4730 | Stop | train | func (p *Pinger) Stop() error {
p.mu.Lock()
defer p.mu.Unlock()
if p.started {
logger.Tracef("[%s] stopping pinger for %q with seq=%d", p.modelUUID[:6], p.beingKey, p.beingSeq)
}
p.tomb.Kill(nil)
err := p.tomb.Wait()
// TODO ping one more time to guarantee a late timeout.
p.started = false
return errors.Trac... | go | {
"resource": ""
} |
q4731 | killStarted | train | func (p *Pinger) killStarted() error {
p.tomb.Kill(nil)
killErr := p.tomb.Wait()
p.started = false
slot := p.lastSlot
udoc := bson.D{
{"$set", bson.D{{"slot", slot}}},
{"$inc", bson.D{{"dead." + p.fieldKey, p.fieldBit}}}}
session := p.pings.Database.Session.Copy()
defer session.Close()
pings := p.pings.Wit... | go | {
"resource": ""
} |
q4732 | killStopped | train | func (p *Pinger) killStopped() error {
if err := p.prepare(); err != nil {
return err
}
// TODO(perrito666) 2016-05-02 lp:1558657
slot := timeSlot(time.Now(), p.delta)
udoc := bson.D{
{"$set", bson.D{{"slot", slot}}},
{"$inc", bson.D{
{"dead." + p.fieldKey, p.fieldBit},
{"alive." + p.fieldKey, p.fieldB... | go | {
"resource": ""
} |
q4733 | loop | train | func (p *Pinger) loop() error {
for {
select {
case <-p.tomb.Dying():
return errors.Trace(tomb.ErrDying)
case <-time.After(time.Duration(float64(period+1)*0.75) * time.Second):
if err := p.ping(); err != nil {
return errors.Trace(err)
}
}
}
} | go | {
"resource": ""
} |
q4734 | prepare | train | func (p *Pinger) prepare() error {
change := mgo.Change{
Update: bson.D{{"$inc", bson.D{{"seq", int64(1)}}}},
Upsert: true,
ReturnNew: true,
}
session := p.base.Database.Session.Copy()
defer session.Close()
base := p.base.With(session)
seqs := seqsC(base)
var seq struct{ Seq int64 }
seqID := docIDSt... | go | {
"resource": ""
} |
q4735 | ping | train | func (p *Pinger) ping() (err error) {
logger.Tracef("[%s] pinging %q with seq=%d", p.modelUUID[:6], p.beingKey, p.beingSeq)
defer func() {
// If the session is killed from underneath us, it panics when we
// try to copy it, so deal with that here.
if v := recover(); v != nil {
err = fmt.Errorf("%v", v)
}
... | go | {
"resource": ""
} |
q4736 | clockDelta | train | func clockDelta(c *mgo.Collection) (time.Duration, error) {
var server struct {
time.Time `bson:"retval"`
}
var isMaster struct {
LocalTime time.Time `bson:"localTime"`
}
var after time.Time
var before time.Time
var serverDelay time.Duration
supportsMasterLocalTime := true
session := c.Database.Session.Cop... | go | {
"resource": ""
} |
q4737 | timeSlot | train | func timeSlot(now time.Time, delta time.Duration) int64 {
fakeMutex.Lock()
fake := !fakeNow.IsZero()
if fake {
now = fakeNow
}
slot := now.Add(delta).Unix()
slot -= slot % period
if fake {
slot += int64(fakeOffset) * period
}
fakeMutex.Unlock()
return slot
} | go | {
"resource": ""
} |
q4738 | realTimeSlot | train | func realTimeSlot() {
fakeMutex.Lock()
fakeNow = time.Time{}
fakeOffset = 0
fakeMutex.Unlock()
logger.Infof("not faking presence time. Real time slot in use.")
} | go | {
"resource": ""
} |
q4739 | RemovePresenceForModel | train | func RemovePresenceForModel(base *mgo.Collection, modelTag names.ModelTag) error {
errs := make([]error, 0)
for _, f := range []func(*mgo.Collection) *mgo.Collection{pingsC, beingsC, seqsC} {
err := removeModelFromCollection(f(base), modelTag.Id())
if err != nil {
errs = append(errs, err)
}
}
if len(errs) ... | go | {
"resource": ""
} |
q4740 | CheckName | train | func CheckName(name string) (string, error) {
// Validate given name.
if !names.IsValidSpace(name) {
return "", errors.Errorf("%q is not a valid space name", name)
}
return name, nil
} | go | {
"resource": ""
} |
q4741 | CheckCIDRs | train | func CheckCIDRs(args []string, cidrsOptional bool) (set.Strings, error) {
// Validate any given CIDRs.
CIDRs := set.NewStrings()
for _, arg := range args {
_, ipNet, err := net.ParseCIDR(arg)
if err != nil {
logger.Debugf("cannot parse %q: %v", arg, err)
return CIDRs, errors.Errorf("%q is not a valid CIDR"... | go | {
"resource": ""
} |
q4742 | NewAPI | train | func (c *SpaceCommandBase) NewAPI() (SpaceAPI, error) {
if c.api != nil {
// Already addd.
return c.api, nil
}
root, err := c.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
// This is tested with a feature test.
shim := &mvpAPIShim{
apiState: root,
facade: spaces.NewAPI(root),
}
retu... | go | {
"resource": ""
} |
q4743 | updateCharmDir | train | func updateCharmDir(opState operation.State, guard fortress.Guard, abort fortress.Abort) error {
var changing bool
// Determine if the charm content is changing.
if opState.Kind == operation.Install || opState.Kind == operation.Upgrade {
changing = true
} else if opState.Kind == operation.RunHook && opState.Hook... | go | {
"resource": ""
} |
q4744 | NewMockStorageV1Interface | train | func NewMockStorageV1Interface(ctrl *gomock.Controller) *MockStorageV1Interface {
mock := &MockStorageV1Interface{ctrl: ctrl}
mock.recorder = &MockStorageV1InterfaceMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q4745 | StorageClasses | train | func (m *MockStorageV1Interface) StorageClasses() v11.StorageClassInterface {
ret := m.ctrl.Call(m, "StorageClasses")
ret0, _ := ret[0].(v11.StorageClassInterface)
return ret0
} | go | {
"resource": ""
} |
q4746 | NewMockStorageClassInterface | train | func NewMockStorageClassInterface(ctrl *gomock.Controller) *MockStorageClassInterface {
mock := &MockStorageClassInterface{ctrl: ctrl}
mock.recorder = &MockStorageClassInterfaceMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q4747 | Phase | train | func (mig *modelMigration) Phase() (migration.Phase, error) {
phase, ok := migration.ParsePhase(mig.statusDoc.Phase)
if !ok {
return phase, errors.Errorf("invalid phase in DB: %v", mig.statusDoc.Phase)
}
return phase, nil
} | go | {
"resource": ""
} |
q4748 | TargetInfo | train | func (mig *modelMigration) TargetInfo() (*migration.TargetInfo, error) {
authTag, err := names.ParseUserTag(mig.doc.TargetAuthTag)
if err != nil {
return nil, errors.Trace(err)
}
macs, err := jsonToMacaroons(mig.doc.TargetMacaroons)
if err != nil {
return nil, errors.Trace(err)
}
return &migration.TargetInfo... | go | {
"resource": ""
} |
q4749 | SetPhase | train | func (mig *modelMigration) SetPhase(nextPhase migration.Phase) error {
now := mig.st.clock().Now().UnixNano()
phase, err := mig.Phase()
if err != nil {
return errors.Trace(err)
}
if nextPhase == phase {
return nil // Already at that phase. Nothing to do.
}
if !phase.CanTransitionTo(nextPhase) {
return er... | go | {
"resource": ""
} |
q4750 | migStatusHistoryAndOps | train | func migStatusHistoryAndOps(st *State, phase migration.Phase, now int64, msg string) ([]txn.Op, error) {
switch phase {
case migration.REAP, migration.DONE:
// if we're reaping/have reaped the model, setting status on it is both
// pointless and potentially problematic.
return nil, nil
}
model, err := st.Mode... | go | {
"resource": ""
} |
q4751 | SetStatusMessage | train | func (mig *modelMigration) SetStatusMessage(text string) error {
phase, err := mig.Phase()
if err != nil {
return errors.Trace(err)
}
ops, err := migStatusHistoryAndOps(mig.st, phase, mig.st.clock().Now().UnixNano(), text)
if err != nil {
return errors.Trace(err)
}
ops = append(ops, txn.Op{
C: migra... | go | {
"resource": ""
} |
q4752 | SubmitMinionReport | train | func (mig *modelMigration) SubmitMinionReport(tag names.Tag, phase migration.Phase, success bool) error {
globalKey, err := agentTagToGlobalKey(tag)
if err != nil {
return errors.Trace(err)
}
docID := mig.minionReportId(phase, globalKey)
doc := modelMigMinionSyncDoc{
Id: docID,
MigrationId: mig.Id()... | go | {
"resource": ""
} |
q4753 | MinionReports | train | func (mig *modelMigration) MinionReports() (*MinionReports, error) {
all, err := mig.getAllAgents()
if err != nil {
return nil, errors.Trace(err)
}
phase, err := mig.Phase()
if err != nil {
return nil, errors.Annotate(err, "retrieving phase")
}
coll, closer := mig.st.db().GetCollection(migrationsMinionSync... | go | {
"resource": ""
} |
q4754 | WatchMinionReports | train | func (mig *modelMigration) WatchMinionReports() (NotifyWatcher, error) {
phase, err := mig.Phase()
if err != nil {
return nil, errors.Annotate(err, "retrieving phase")
}
prefix := mig.minionReportId(phase, "")
filter := func(rawId interface{}) bool {
id, ok := rawId.(string)
if !ok {
return false
}
re... | go | {
"resource": ""
} |
q4755 | Refresh | train | func (mig *modelMigration) Refresh() error {
// Only the status document is updated. The modelMigDoc is static
// after creation.
statusColl, closer := mig.st.db().GetCollection(migrationsStatusC)
defer closer()
var statusDoc modelMigStatusDoc
err := statusColl.FindId(mig.doc.Id).One(&statusDoc)
if err == mgo.Er... | go | {
"resource": ""
} |
q4756 | ModelUserAccess | train | func (mig *modelMigration) ModelUserAccess(tag names.Tag) permission.Access {
id := tag.Id()
for _, user := range mig.doc.ModelUsers {
if user.UserID == id {
return user.Access
}
}
return permission.NoAccess
} | go | {
"resource": ""
} |
q4757 | Validate | train | func (spec *MigrationSpec) Validate() error {
if !names.IsValidUser(spec.InitiatedBy.Id()) {
return errors.NotValidf("InitiatedBy")
}
return spec.TargetInfo.Validate()
} | go | {
"resource": ""
} |
q4758 | Migration | train | func (st *State) Migration(id string) (ModelMigration, error) {
migColl, closer := st.db().GetCollection(migrationsC)
defer closer()
mig, err := st.migrationFromQuery(migColl.FindId(id))
if err != nil {
return nil, errors.Trace(err)
}
return mig, nil
} | go | {
"resource": ""
} |
q4759 | IsMigrationActive | train | func IsMigrationActive(st *State, modelUUID string) (bool, error) {
active, closer := st.db().GetCollection(migrationsActiveC)
defer closer()
n, err := active.FindId(modelUUID).Count()
if err != nil {
return false, errors.Trace(err)
}
return n > 0, nil
} | go | {
"resource": ""
} |
q4760 | Decorate | train | func (housing Housing) Decorate(base dependency.Manifold) dependency.Manifold {
manifold := base
// Apply Occupy wrapping first, so that it will be the last
// wrapper to execute before calling the original Start func, so
// as to minimise the time we hold the fortress open.
if housing.Occupy != "" {
manifold.In... | go | {
"resource": ""
} |
q4761 | List | train | func (a API) List(args params.PayloadListArgs) (params.PayloadListResults, error) {
var r params.PayloadListResults
payloads, err := a.backend.ListAll()
if err != nil {
return r, errors.Trace(err)
}
filters, err := payload.BuildPredicatesFor(args.Patterns)
if err != nil {
return r, errors.Trace(err)
}
pay... | go | {
"resource": ""
} |
q4762 | PopValue | train | func (m ManagerConfig) PopValue(key string) string {
value := m[key]
delete(m, key)
return value
} | go | {
"resource": ""
} |
q4763 | WarnAboutUnused | train | func (m ManagerConfig) WarnAboutUnused() {
for key, value := range m {
logger.Infof("unused config option: %q -> %q", key, value)
}
} | go | {
"resource": ""
} |
q4764 | ServeHTTP | train | func (h *RestHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var err error
switch r.Method {
case "GET":
err = errors.Annotate(h.GetHandler(w, r), "cannot retrieve model data")
default:
err = emitUnsupportedMethodErr(r.Method)
}
if err != nil {
if err := sendJSONError(w, r, errors.Trace(er... | go | {
"resource": ""
} |
q4765 | ServeGet | train | func (h *modelRestHandler) ServeGet(w http.ResponseWriter, r *http.Request) error {
if r.Method != "GET" {
return errors.Trace(emitUnsupportedMethodErr(r.Method))
}
st, _, err := h.ctxt.stateForRequestAuthenticated(r)
if err != nil {
return errors.Trace(err)
}
defer st.Release()
return errors.Trace(h.proce... | go | {
"resource": ""
} |
q4766 | processGet | train | func (h *modelRestHandler) processGet(r *http.Request, w http.ResponseWriter, st *state.State) error {
query := r.URL.Query()
entity := query.Get(":entity")
// TODO(wallyworld) - support more than just "remote-application"
switch entity {
case "remote-application":
return h.processRemoteApplication(r, w, st)
de... | go | {
"resource": ""
} |
q4767 | processRemoteApplication | train | func (h *modelRestHandler) processRemoteApplication(r *http.Request, w http.ResponseWriter, st *state.State) error {
query := r.URL.Query()
name := query.Get(":name")
remoteApp, err := st.RemoteApplication(name)
if err != nil {
return errors.Trace(err)
}
attribute := query.Get(":attribute")
// TODO(wallyworld)... | go | {
"resource": ""
} |
q4768 | NewMockNotifyWatcher | train | func NewMockNotifyWatcher(ctrl *gomock.Controller) *MockNotifyWatcher {
mock := &MockNotifyWatcher{ctrl: ctrl}
mock.recorder = &MockNotifyWatcherMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q4769 | NewMockStringsWatcher | train | func NewMockStringsWatcher(ctrl *gomock.Controller) *MockStringsWatcher {
mock := &MockStringsWatcher{ctrl: ctrl}
mock.recorder = &MockStringsWatcherMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q4770 | checkImageList | train | func checkImageList(c EnvironAPI) ([]*imagemetadata.ImageMetadata, error) {
if c == nil {
return nil, errors.NotFoundf("oracle client")
}
// take a list of all images that are in the oracle cloud account
resp, err := c.AllImageLists(nil)
if err != nil {
return nil, errors.Trace(err)
}
// if we don't have a... | go | {
"resource": ""
} |
q4771 | getImageName | train | func getImageName(c EnvironAPI, id string) (string, error) {
if id == "" {
return "", errors.NotFoundf("empty id")
}
resp, err := c.AllImageLists(nil)
if err != nil {
return "", errors.Trace(err)
}
// if we don't have any images that are in
// the oracle cloud account under your username namespace
// we s... | go | {
"resource": ""
} |
q4772 | Validate | train | func (config StringsConfig) Validate() error {
if config.Handler == nil {
return errors.NotValidf("nil Handler")
}
return nil
} | go | {
"resource": ""
} |
q4773 | NewStringsWorker | train | func NewStringsWorker(config StringsConfig) (*StringsWorker, error) {
if err := config.Validate(); err != nil {
return nil, errors.Trace(err)
}
sw := &StringsWorker{
config: config,
}
err := catacomb.Invoke(catacomb.Plan{
Site: &sw.catacomb,
Work: sw.loop,
})
if err != nil {
return nil, errors.Trace(er... | go | {
"resource": ""
} |
q4774 | NewManagedFilesystemSource | train | func NewManagedFilesystemSource(
volumeBlockDevices map[names.VolumeTag]storage.BlockDevice,
filesystems map[names.FilesystemTag]storage.Filesystem,
) storage.FilesystemSource {
return &managedFilesystemSource{
logAndExec,
&osDirFuncs{logAndExec},
volumeBlockDevices, filesystems,
}
} | go | {
"resource": ""
} |
q4775 | isDiskDevice | train | func isDiskDevice(devicePath string) bool {
var last rune
for _, r := range devicePath {
last = r
}
return !unicode.IsDigit(last)
} | go | {
"resource": ""
} |
q4776 | watchMachine | train | func watchMachine(ctx *context, tag names.MachineTag) {
_, ok := ctx.machines[tag]
if ok {
return
}
w, err := newMachineWatcher(ctx.config.Machines, tag, ctx.machineChanges)
if err != nil {
ctx.kill(errors.Trace(err))
} else if err := ctx.addWorker(w); err != nil {
ctx.kill(errors.Trace(err))
} else {
ct... | go | {
"resource": ""
} |
q4777 | refreshMachine | train | func refreshMachine(ctx *context, tag names.MachineTag) error {
w, ok := ctx.machines[tag]
if !ok {
return errors.Errorf("machine %s is not being watched", tag.Id())
}
stopAndRemove := func() error {
worker.Stop(w)
delete(ctx.machines, tag)
return nil
}
results, err := ctx.config.Machines.InstanceIds([]na... | go | {
"resource": ""
} |
q4778 | machineProvisioned | train | func machineProvisioned(ctx *context, tag names.MachineTag, instanceId instance.Id) {
for _, params := range ctx.incompleteVolumeParams {
if params.Attachment.Machine != tag || params.Attachment.InstanceId != "" {
continue
}
params.Attachment.InstanceId = instanceId
updatePendingVolume(ctx, params)
}
for ... | go | {
"resource": ""
} |
q4779 | Manifold | train | func Manifold(config ManifoldConfig) dependency.Manifold {
inputs := []string{config.ClockName}
if config.StateName != "" {
inputs = append(inputs, config.StateName)
} else {
inputs = append(inputs, config.LeaseManagerName)
}
if config.RaftName != "" {
inputs = append(inputs, config.RaftName)
}
return depe... | go | {
"resource": ""
} |
q4780 | init | train | func (w *MachineLXDProfileWatcher) init(machine *Machine) error {
units, err := machine.Units()
if err != nil {
return errors.Annotatef(err, "failed to get units to start MachineLXDProfileWatcher")
}
for _, unit := range units {
appName := unit.Application()
unitName := unit.Name()
if info, found := w.app... | go | {
"resource": ""
} |
q4781 | applicationCharmURLChange | train | func (w *MachineLXDProfileWatcher) applicationCharmURLChange(topic string, value interface{}) {
// We don't want to respond to any events until we have been fully initialized.
select {
case <-w.initialized:
case <-w.tomb.Dying():
return
}
var notify bool
defer func(notify *bool) {
if *notify {
w.notify()
... | go | {
"resource": ""
} |
q4782 | addUnit | train | func (w *MachineLXDProfileWatcher) addUnit(topic string, value interface{}) {
// We don't want to respond to any events until we have been fully initialized.
select {
case <-w.initialized:
case <-w.tomb.Dying():
return
}
var notify bool
defer func(notify *bool) {
if *notify {
logger.Tracef("notifying due ... | go | {
"resource": ""
} |
q4783 | removeUnit | train | func (w *MachineLXDProfileWatcher) removeUnit(topic string, value interface{}) {
// We don't want to respond to any events until we have been fully initialized.
select {
case <-w.initialized:
case <-w.tomb.Dying():
return
}
var notify bool
defer func(notify *bool) {
if *notify {
logger.Tracef("notifying d... | go | {
"resource": ""
} |
q4784 | provisionedChange | train | func (w *MachineLXDProfileWatcher) provisionedChange(topic string, _ interface{}) {
// We don't want to respond to any events until we have been fully initialized.
select {
case <-w.initialized:
case <-w.tomb.Dying():
return
}
logger.Tracef("notifying due to machine-%s now provisioned", w.machineId)
w.metrics... | go | {
"resource": ""
} |
q4785 | ToParams | train | func (job MachineJob) ToParams() multiwatcher.MachineJob {
if jujuJob, ok := jobNames[job]; ok {
return jujuJob
}
return multiwatcher.MachineJob(fmt.Sprintf("<unknown job %d>", int(job)))
} | go | {
"resource": ""
} |
q4786 | paramsJobsFromJobs | train | func paramsJobsFromJobs(jobs []MachineJob) []multiwatcher.MachineJob {
jujuJobs := make([]multiwatcher.MachineJob, len(jobs))
for i, machineJob := range jobs {
jujuJobs[i] = machineJob.ToParams()
}
return jujuJobs
} | go | {
"resource": ""
} |
q4787 | MigrationValue | train | func (job MachineJob) MigrationValue() string {
if value, ok := jobMigrationValue[job]; ok {
return value
}
return "unknown"
} | go | {
"resource": ""
} |
q4788 | ContainerType | train | func (m *Machine) ContainerType() instance.ContainerType {
return instance.ContainerType(m.doc.ContainerType)
} | go | {
"resource": ""
} |
q4789 | SetKeepInstance | train | func (m *Machine) SetKeepInstance(keepInstance bool) error {
ops := []txn.Op{{
C: instanceDataC,
Id: m.doc.DocID,
Assert: txn.DocExists,
Update: bson.D{{"$set", bson.D{{"keep-instance", keepInstance}}}},
}}
if err := m.st.db().RunTransaction(ops); err != nil {
// If instance doc doesn't exist, tha... | go | {
"resource": ""
} |
q4790 | KeepInstance | train | func (m *Machine) KeepInstance() (bool, error) {
instData, err := getInstanceData(m.st, m.Id())
if err != nil {
return false, err
}
return instData.KeepInstance, nil
} | go | {
"resource": ""
} |
q4791 | CharmProfiles | train | func (m *Machine) CharmProfiles() ([]string, error) {
instData, err := getInstanceData(m.st, m.Id())
if errors.IsNotFound(err) {
err = errors.NotProvisionedf("machine %v", m.Id())
}
if err != nil {
return nil, err
}
return instData.CharmProfiles, nil
} | go | {
"resource": ""
} |
q4792 | SetCharmProfiles | train | func (m *Machine) SetCharmProfiles(profiles []string) error {
if len(profiles) == 0 {
return nil
}
buildTxn := func(attempt int) ([]txn.Op, error) {
if attempt > 0 {
if err := m.Refresh(); err != nil {
return nil, errors.Trace(err)
}
}
// Exit early if the Machine profiles doesn't need to change.
... | go | {
"resource": ""
} |
q4793 | WantsVote | train | func (m *Machine) WantsVote() bool {
return wantsVote(m.doc.Jobs, m.doc.NoVote)
} | go | {
"resource": ""
} |
q4794 | SetHasVote | train | func (m *Machine) SetHasVote(hasVote bool) error {
op := m.UpdateOperation()
op.HasVote = &hasVote
if err := m.st.ApplyOperation(op); err != nil {
return errors.Trace(err)
}
m.doc.HasVote = hasVote
return nil
} | go | {
"resource": ""
} |
q4795 | SetStopMongoUntilVersion | train | func (m *Machine) SetStopMongoUntilVersion(v mongo.Version) error {
ops := []txn.Op{{
C: machinesC,
Id: m.doc.DocID,
Update: bson.D{{"$set", bson.D{{"stopmongountilversion", v.String()}}}},
}}
if err := m.st.db().RunTransaction(ops); err != nil {
return fmt.Errorf("cannot set StopMongoUntilVersion %... | go | {
"resource": ""
} |
q4796 | StopMongoUntilVersion | train | func (m *Machine) StopMongoUntilVersion() (mongo.Version, error) {
return mongo.NewVersion(m.doc.StopMongoUntilVersion)
} | go | {
"resource": ""
} |
q4797 | IsManual | train | func (m *Machine) IsManual() (bool, error) {
// Apart from the bootstrap machine, manually provisioned
// machines have a nonce prefixed with "manual:". This is
// unique to manual provisioning.
if strings.HasPrefix(m.doc.Nonce, manualMachinePrefix) {
return true, nil
}
// The bootstrap machine uses BootstrapNo... | go | {
"resource": ""
} |
q4798 | AgentTools | train | func (m *Machine) AgentTools() (*tools.Tools, error) {
if m.doc.Tools == nil {
return nil, errors.NotFoundf("agent binaries for machine %v", m)
}
tools := *m.doc.Tools
return &tools, nil
} | go | {
"resource": ""
} |
q4799 | checkVersionValidity | train | func checkVersionValidity(v version.Binary) error {
if v.Series == "" || v.Arch == "" {
return fmt.Errorf("empty series or arch")
}
return nil
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.