anchor dict | positive dict | negative dict |
|---|---|---|
{
"audio": "",
"image": "",
"text": "func (m stringMap) String() string {\n\tpairs := make([]string, 0, len(*m.mapping))\n\tfor name, value := range *m.mapping {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tpairs = append(pairs, name+\"=\"+value)\n\t}\n\treturn strings.Join(pairs, \";\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " mapping.Resource,\n\t\tCodec: mapping.Codec,\n\t\tVersioner: mapping.MetadataAccessor,\n\t\tNamespaceScoped: mapping.Scope.Name() == meta.RESTScopeNameNamespace,\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *modelAgent) CurrentConfig() agent.Config {\n\treturn &modelAgentConfig{\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tConfig: a.Agent.CurrentConfig(),\n\t\tmodelUUID: a.modelUUID,\n\t\tcontrollerUUID: a.controllerUUID,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif config == nil {\n\t\treturn version.Number{}, errors.Errorf(\"%s agent conf is not found\", machineAgent)\n\t}\n\treturn config.UpgradedToVersion(), nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *modelAgentConfig) APIInfo() (*api.Info, bool) {\n\tinfo, ok := c.Config.APIInfo()\n\tif !ok {\n\t\treturn nil, false",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t}\n\tinfo.ModelTag = names.NewModelTag(c.modelUUID)\n\treturn info, true\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error) {\n\tinfo, err := s.daemon.CmdSystemInfo()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn info, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewWorker(config Config) (worker.Worker, error) {\n\tif err := config.Validate(); err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\tpaths := NewPaths(config.DataDir, names.NewApplicationTag(config.Application))\n\tdeployer, err := jujucharm.NewDeployer(\n\t\tpaths.S... | {
"audio": "",
"image": "",
"text": "\n\n\t\t\t// One of the uniter workers failing should not\n\t\t\t// prevent the others from running.\n\t\t\tIsFatal: func(error) bool { return false },\n\n\t\t\t// For any failures, try again in 3 seconds.\n\t\t\tRestartDelay: 3 * time.Second,\n\t\t}),\n\t}\n\tif err := cataco... | {
"audio": "",
"image": "",
"text": "\tclient, err := client.New(\n\t\tconfig.TritonURL,\n\t\tconfig.MantaURL,\n\t\tconfig.AccountName,\n\t\tconfig.Signers...,\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn newServiceGroupClient(client), nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func Juju1xEnvConfigExists() bool {\n\tdir := OldJujuHomeDir()\n\tif dir == \"\" {\n\t\treturn false\n\t}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t_, err := os.Stat(filepath.Join(dir, \"environments.yaml\"))\n\treturn err == nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tif _, ok := ret.Directories[path]; !ok {\n\t\t\t\tdir := old.Directories[path].Diff(newdir)\n\t\t\t\tret.Directories[path] = dir\n\t\t\t\tanyChanged.add(dir.Overall)\n\t\t\t}\n\t\t}\n\n\t\treturn anyChanged.status()\n\t})\n\treturn ret\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func OldJujuHomeDir() string {\n\tJujuHomeDir := os.Getenv(oldJujuHomeEnvKey)\n\tif JujuHomeDir == \"\" {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tif runtime.GOOS == \"windows\" {\n\t\t\tJujuHomeDir = oldJujuHomeWin()\n\t\t} else {\n\t\t\tJujuHomeDir = oldJujuHomeLinux()\n\t\t}\n\t}\n\treturn JujuHomeDir\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := os.Getenv(envVar); val != \"\" {\n\t\treturn &val\n\t}\n\treturn def\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *Facade) Prune(maxHistoryTime time.Duration, maxHistoryMB int) error {\n\tp := params.StatusHistoryPruneArgs{\n\t\tMaxHistoryTime: maxHistoryTime,",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tMaxHistoryMB: maxHistoryMB,\n\t}\n\treturn s.facade.FacadeCall(\"Prune\", p, nil)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn func(p *Prompt) error {\n\t\tp.keyBindMode = m\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewMockSummary(ctrl *gomock.Controller) *MockSummary {\n\tmock := &MockSummary{ctrl: ctrl}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tmock.recorder = &MockSummaryMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tmock := &MockDockerMetadataClient{ctrl: ctrl}\n\tmock.recorder = &MockDockerMetadataClientMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockSummaryMockRecorder) Collect(arg0 interface{}) *gomock.Call {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Collect\", reflect.TypeOf((*MockSummary)(nil).Collect), arg0)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn nil, ErrInvalidParams()\n\t}\n\n\tmr.m.RLock()\n\tmd, ok := mr.r[r.Method]\n\tmr.m.RUnlock()\n\tif !ok {\n\t\treturn nil, ErrMethodNotFound()\n\t}\n\n\treturn md.Handler, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockSummary) Observe(arg0",
"video": ""
} | {
"audio": "",
"image": "",
"text": " float64) {\n\tm.ctrl.Call(m, \"Observe\", arg0)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\terr = b.Do(k, func(mc *memcached.Client, vb uint16) error {\n\t\tresult, err = mc.Observe(vb, k)\n\t\treturn err\n\t})\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (l *handler) Handle(c net.Conn, abort <-chan struct{}) error {\n\tdefer c.Close()\n\n\t// TODO(fwereade): 2016-03-17 lp:1558657\n\terr := c.SetDeadline(time.Now().Add(spool.DefaultTimeout))\n\tif err != nil {\n\t\treturn errors.Annotate(err, \"failed to set the deadline\"... | {
"audio": "",
"image": "",
"text": "\terr = l.config.charmdir.Visit(func() error {\n\t\treturn l.do(c)\n\t}, abort)\n\tif err != nil {\n\t\tfmt.Fprintf(c, \"error: %v\\n\", err.Error())\n\t} else {\n\t\tfmt.Fprintf(c, \"ok\\n\")\n\t}\n\treturn errors.Trace(err)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " errors.Annotate(err, \"failed to unmarshal JobConfig\").Err()\n\t}\n\treturn func(c context.Context, keys []*datastore.Key) error {\n\t\treturn m.Func(c, j.ID, cfg, keys)\n\t}, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewProvisionerWorker(config Config) (worker.Worker, error) {\n\tp := &provisioner{\n\t\tprovisionerFacade: config.Facade,\n\t\tbroker: config.Broker,\n\t\tmodelTag: config.ModelTag,\n\t\tagentConfig: config.AgentConfig,\n\t\tclock: ",
... | {
"audio": "",
"image": "",
"text": " config.Clock,\n\t}\n\terr := catacomb.Invoke(catacomb.Plan{\n\t\tSite: &p.catacomb,\n\t\tWork: p.loop,\n\t})\n\treturn p, err\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " config.APIKey,\n\t\tRequester: config.Requester,\n\t\tReadTimeout: config.ReadTimeout,\n\t\tWriteTimeout: config.WriteTimeout,\n\t\tHeaders: config.Headers,\n\t\tExtraUserAgent: config.ExtraUserAgent,\n\t}\n\n\treturn &Client{\n\t\tappID: config... |
{
"audio": "",
"image": "",
"text": "func (p *provisioner) ensureOperators(apps []string) error {\n\tvar appPasswords []apicaasprovisioner.ApplicationPassword\n\toperatorConfig := make([]*caas.OperatorConfig, len(apps))\n\tfor i, app := range apps {\n\t\topState, err := p.broker.OperatorExists(app)\n\t\tif err !=... | {
"audio": "",
"image": "",
"text": "\tvar password string\n\t\tif !opState.Exists {\n\t\t\tif password, err = utils.RandomPassword(); err != nil {\n\t\t\t\treturn errors.Trace(err)\n\t\t\t}\n\t\t\tappPasswords = append(appPasswords, apicaasprovisioner.ApplicationPassword{Name: app, Password: password})\n\t\t}\n\... | {
"audio": "",
"image": "",
"text": "\n\tif err != nil {\n\t\tconn.Apps().Update(bson.M{\"name\": app.Name}, bson.M{\"$addToSet\": bson.M{\"teams\": team.Name}})\n\t\treturn err\n\t}\n\tfor _, user := range users {\n\t\tperms, err := user.Permissions()\n\t\tif err != nil {\n\t\t\tconn.Apps().Update(bson.M{\"name\... |
{
"audio": "",
"image": "",
"text": "func Manifold(config ManifoldConfig) dependency.Manifold {\n\treturn dependency.Manifold{\n\t\tInputs: []string{\n\t\t\tconfig.AgentName,\n\t\t\tconfig.ClockName,",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\t\tconfig.ControllerPortName,\n\t\t\tconfig.StateName,\n\t\t},\n\t\tStart: config.start,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t}\n\n\t\tconfig.URL = normalizeURL(config.URL)\n\n\t\treturn newBackendImplementation(backendType, config)\n\n\tcase UploadsBackend:\n\t\tif config.URL == \"\" {\n\t\t\tconfig.URL = uploadsURL\n\t\t}\n\n\t\tconfig.URL = normalizeURL(config.URL)\n\n\t\treturn newBackendImpl... |
{
"audio": "",
"image": "",
"text": "func (c *enableHACommand) Run(ctx *cmd.Context) error {\n\tcontrollerName, err := c.ControllerName()\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif err := common.ValidateIaasController(c.CommandBase, c.Info().Name, controllerName, c.ClientStore()); err != nil {\n\... | {
"audio": "",
"image": "",
"text": "\n\t\treturn block.ProcessBlockedError(err, block.BlockChange)\n\t}\n\n\tresult := availabilityInfo{\n\t\tAdded: machineTagsToIds(enableHAResult.Added...),\n\t\tRemoved: machineTagsToIds(enableHAResult.Removed...),\n\t\tMaintained: machineTagsToIds(enableHAResult.Maint... | {
"audio": "",
"image": "",
"text": " just one, don't prompt, just use it.\n\t\tc.Region = cloud.Regions[0].Name\n\tdefault:\n\t\tc.Region, err = queryRegion(c.Cloud, cloud.Regions, scanner, ctx.Stdout)\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t}\n\n\tdefName := defaultControllerName(c.Cloud,... |
{
"audio": "",
"image": "",
"text": "func machineTagsToIds(tags ...string) []string {\n\tvar result []string\n\n\tfor _, rawTag := range tags {\n\t\ttag, err := names.ParseTag(rawTag)\n\t\tif err != nil {\n\t\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tcontinue\n\t\t}\n\t\tresult = append(result, tag.Id())\n\t}\n\treturn result\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error) {\n\tvar tags []string\n\tif tag != \"\" {\n\t\ttags = []string{tag}\n\t}\n\treturn h.service(service, tags, passingOnly, q, true)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (ro *resourceOpener) OpenResource(name string) (o resource.Opened, err error) {\n\tif ro.unit == nil {\n\t\treturn resource.Opened{}, errors.Errorf(\"missing unit\")\n\t}\n\tapp, err := ro.unit.Application()\n\tif err != nil {\n\t\treturn resource.Opened{}, errors.Trace(e... | {
"audio": "",
"image": "",
"text": " csOpener.NewClient()\n\tif err != nil {\n\t\treturn resource.Opened{}, errors.Trace(err)\n\t}\n\n\tcache := &charmstoreEntityCache{\n\t\tst: ro.res,\n\t\tuserID: ro.userID,\n\t\tunit: ro.unit,\n\t\tapplicationID: ro.unit.ApplicationName(),\n\t}\n\n\... | {
"audio": "",
"image": "",
"text": " nil {\n\t\tro.buffer.Reject(batch)\n\t\treturn err\n\t}\n\tro.buffer.Accept(batch)\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (config Config) Validate() error {\n\tif config.Facade == nil {\n\t\treturn errors.NotValidf(\"nil Facade\")\n\t}\n\tif config.CredentialAPI == nil {\n\t\treturn errors.NotValidf(\"nil CredentialAPI\")",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t}\n\tif config.Destroyer == nil {\n\t\treturn errors.NotValidf(\"nil Destroyer\")\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " config.Topic == \"\" {\n\t\treturn errors.NotValidf(\"empty Topic\")\n\t}\n\tif config.Target == nil {\n\t\treturn errors.NotValidf(\"nil Target\")\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewUndertaker(config Config) (*Undertaker, error) {\n\tif err := config.Validate(); err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\n\tu := &Undertaker{\n\t\tconfig: config,\n\t}\n\terr := catacomb.Invoke(catacomb.Plan{\n\t\tSite: &u.catacomb,\n\t\tWork: u.run,\n\t... | {
"audio": "",
"image": "",
"text": "\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\tu.setCallCtx(common.NewCloudCallContext(config.CredentialAPI, u.catacomb.Dying))\n\treturn u, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := catacomb.Invoke(catacomb.Plan{\n\t\tSite: &w.catacomb,\n\t\tWork: w.loop,\n\t\tInit: []worker.Worker{w.controller},\n\t}); err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\treturn w, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func ImportModel(importer StateImporter, getClaimer ClaimerFunc, bytes []byte) (*state.Model, *state.State, error) {\n\tmodel, err := description.Deserialize(bytes)\n\tif err != nil {\n\t\treturn nil, nil, errors.Trace(err)\n\t}\n\n\tdbModel, dbState, err := importer.Import(mo... | {
"audio": "",
"image": "",
"text": "\n\t\t// just because we migrated a model, so this time needs to be\n\t\t// long enough to make sure we cover the time taken to migrate\n\t\t// a reasonable sized model. We don't yet know how long this\n\t\t// is going to be, but we need something.\n\t\t// TODO(babbageclunk): ... | {
"audio": "",
"image": "",
"text": "\n\t}\n\n\tmodel, err := st.Model()\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\tif model.Type() == state.ModelTypeCAAS {\n\t\treturn nil, errors.NotSupportedf(\"high availability on kubernetes controllers\")\n\t}\n\n\treturn &HighAvailabilityAPI{\n\t\tstate: ... |
{
"audio": "",
"image": "",
"text": "func (c *UploadBinariesConfig) Validate() error {\n\tif c.CharmDownloader == nil {\n\t\treturn errors.NotValidf(\"missing CharmDownloader\")\n\t}\n\tif c.CharmUploader == nil {\n\t\treturn errors.NotValidf(\"missing CharmUploader\")\n\t}\n\tif c.ToolsDownloader == nil {\n\t\tr... | {
"audio": "",
"image": "",
"text": "\treturn errors.NotValidf(\"missing ToolsUploader\")\n\t}\n\tif c.ResourceDownloader == nil {\n\t\treturn errors.NotValidf(\"missing ResourceDownloader\")\n\t}\n\tif c.ResourceUploader == nil {\n\t\treturn errors.NotValidf(\"missing ResourceUploader\")\n\t}\n\treturn nil\n}",
... | {
"audio": "",
"image": "",
"text": " config.Topic == \"\" {\n\t\treturn errors.NotValidf(\"empty Topic\")\n\t}\n\tif config.Target == nil {\n\t\treturn errors.NotValidf(\"nil Target\")\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func UploadBinaries(config UploadBinariesConfig) error {\n\tif err := config.Validate(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif err := uploadCharms(config); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif err := uploadTools(config); err != nil",
"video":... | {
"audio": "",
"image": "",
"text": " {\n\t\treturn errors.Trace(err)\n\t}\n\tif err := uploadResources(config); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tif err = dec.Decode(&config); err != nil {\n\t\treturn\n\t}\n\n\tconfig.Info.Version = os.ExpandEnv(config.Info.Version)\n\terr = config.Validate()\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *factory) Recorder(declaredMetrics map[string]corecharm.Metric, charmURL, unitTag string) (MetricRecorder,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error) {\n\treturn NewJSONMetricRecorder(MetricRecorderConfig{\n\t\tSpoolDir: f.spoolDir,\n\t\tMetrics: declaredMetrics,\n\t\tCharmURL: charmURL,\n\t\tUnitTag: unitTag,\n\t})\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Filters(func(f *mesos.Filters) {\n\t\tf.RefuseSeconds = &asFloat\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func Manifold(config ManifoldConfig) dependency.Manifold {\n\tmanifold := engine.AgentManifold(engine.AgentManifoldConfig(config),",
"video": ""
} | {
"audio": "",
"image": "",
"text": " newWorker)\n\tmanifold.Output = outputFunc\n\treturn manifold\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " engine.tasksLock.RUnlock()\n\t_, ok := engine.managedTasks[arn]\n\treturn ok\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newWorker(a agent.Agent) (worker.Worker, error) {\n\tmetricsSpoolDir := a.CurrentConfig().MetricsSpoolDir()\n\terr := checkSpoolDir(metricsSpoolDir)\n\tif err != nil {\n\t\treturn nil, errors.Annotatef(err, \"error checking spool directory %q\", metricsSpoolDir)\n\t}\n\tw... | {
"audio": "",
"image": "",
"text": " &spoolWorker{factory: newFactory(metricsSpoolDir)}\n\tw.tomb.Go(func() error {\n\t\t<-w.tomb.Dying()\n\t\treturn nil\n\t})\n\treturn w, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn nil, err\n\t}\n\n\tfn := func(p *Plan) (BlockingParamVal, interface{}, error) {\n\t\tagent := p.client.Agent()\n\t\topts := makeQueryOptionsWithContext(p, false)\n\t\tdefer p.cancelFunc()\n\n\t\tleaf, meta, err := agent.ConnectCALeaf(serviceName, &opts)\n\t\tif err !=... |
{
"audio": "",
"image": "",
"text": "func FormatPayload(payload payload.FullPayloadInfo) FormattedPayload {\n\tvar labels []string\n\tif len(payload.Labels) > 0 {\n\t\tlabels = make([]string, len(payload.Labels))\n\t\tcopy(labels, payload.Labels)\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\treturn FormattedPayload{\n\t\tUnit: payload.Unit,\n\t\tMachine: payload.Machine,\n\t\tID: payload.ID,\n\t\tType: payload.Type,\n\t\tClass: payload.Name,\n\t\tLabels: labels,\n\t\t// TODO(ericsnow) Explicitly convert to a string?\n\t\tStatus: payload.Status... | {
"audio": "",
"image": "",
"text": " {\n\to.Payload = payload\n\treturn o\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mock *MockContainer) EnsureCachedImage(params kvm.StartParams) error {\n\timageCacheCalls++",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tmock.StartParams = params\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tkvms = append(kvms, kvm)\n\t\t\t}\n\t\t}\n\t\tt.current = kvms\n\t}()\n\tfor len(t.removals) > 0 {\n\t\tkvm := t.removals[0]\n\t\tif _, err := stmt.ExecContext(c, kvm.HostnameId); err != nil {\n\t\t\t// Defer ensures the slice of KVMs is updated even if we exit early.\n\... |
{
"audio": "",
"image": "",
"text": "func (mock *MockContainer) Stop() error {\n\tif !mock.started {\n\t\treturn fmt.Errorf(\"container",
"video": ""
} | {
"audio": "",
"image": "",
"text": " is not running\")\n\t}\n\tmock.started = false\n\tmock.factory.notify(Stopped, mock.name)\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\t\tif k.APIConn.HasSynced() {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\tcase <-timeout:\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t})\n\n\tc.OnShutdown(func() error {\n\t\treturn k.APIConn.Stop()\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func SourcePrecheck(\n\tbackend PrecheckBackend,\n\tmodelPresence ModelPresence,\n\tcontrollerPresence ModelPresence,\n) error {\n\tctx := precheckContext{backend, modelPresence}\n\tif err := ctx.checkModel(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\tif err := ctx.... | {
"audio": "",
"image": "",
"text": "\t} else if cleanupNeeded {\n\t\treturn errors.New(\"cleanup needed\")\n\t}\n\n\t// Check the source controller.\n\tcontrollerBackend, err := backend.ControllerBackend()\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tcontrollerCtx := precheckContext{controllerBackend... | {
"audio": "",
"image": "",
"text": "\n\t}\n\tif err := p.processEachContainer(args, ctx); err != nil {\n\t\treturn ctx.result, errors.Trace(err)\n\t}\n\treturn ctx.result, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func TargetPrecheck(backend PrecheckBackend, pool Pool, modelInfo coremigration.ModelInfo, presence ModelPresence) error {\n\tif err := modelInfo.Validate(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\t// This check is necessary because there is a window between the\n... | {
"audio": "",
"image": "",
"text": "\t// Check for conflicts with existing models\n\tmodelUUIDs, err := backend.AllModelUUIDs()\n\tif err != nil {\n\t\treturn errors.Annotate(err, \"retrieving models\")\n\t}\n\tfor _, modelUUID := range modelUUIDs {\n\t\tmodel, release, err := pool.GetModel(modelUUID)\n\t\tif er... | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\treturn empty, errors.Annotate(err, \"retrieving model owner\")\n\t}\n\n\tvers, err := api.backend.AgentVersion()\n\tif err != nil {\n\t\treturn empty, errors.Annotate(err, \"retrieving agent version\")\n\t}\n\n\treturn params.MigrationModelInfo{\n\t\tUUID: ... |
{
"audio": "",
"image": "",
"text": "func IsMetricsDataError(err error) bool {\n\t_, ok :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " errors.Cause(err).(*errMetricsData)\n\treturn ok\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\treturn func(req *http.Request, ctx *ProxyCtx) bool {\n\t\t_, ok := hostSet[req.URL.Host]\n\t\treturn ok\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func APIMetricBatch(batch MetricBatch) params.MetricBatchParam {\n\tmetrics := make([]params.Metric, len(batch.Metrics))\n\tfor i, metric := range batch.Metrics {\n\t\tmetrics[i] = params.Metric{\n\t\t\tKey: ",
"video": ""
} | {
"audio": "",
"image": "",
"text": " metric.Key,\n\t\t\tValue: metric.Value,\n\t\t\tTime: metric.Time,\n\t\t\tLabels: metric.Labels,\n\t\t}\n\t}\n\treturn params.MetricBatchParam{\n\t\tTag: batch.UnitTag,\n\t\tBatch: params.MetricBatch{\n\t\t\tUUID: batch.UUID,\n\t\t\tCharmURL: batch.CharmURL,\n\t\t\tCre... | {
"audio": "",
"image": "",
"text": "\tndb.batch.Close()\n\tndb.batch = ndb.db.NewBatch()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewJSONMetricRecorder(config MetricRecorderConfig) (rec *JSONMetricRecorder, rErr error) {\n\tmbUUID, err := utils.NewUUID()\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\n\trecorder := &JSONMetricRecorder{\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tspoolDir: config.SpoolDir,\n\t\tuuid: mbUUID,\n\t\tcharmURL: config.CharmURL,\n\t\t// TODO(fwereade): 2016-03-17 lp:1558657\n\t\tcreated: time.Now().UTC(),\n\t\tvalidMetrics: config.Metrics,\n\t\tunitTag: config.UnitTag,\n\t}\n\tif err := recorder.open(); err !... | {
"audio": "",
"image": "",
"text": " trace.BadParameter(err.Error())\n\t\t}\n\t\tutils.UTC(&ws.Spec.BearerTokenExpires)\n\t\tutils.UTC(&ws.Spec.Expires)\n\n\t\tif err := ws.CheckAndSetDefaults(); err != nil {\n\t\t\treturn nil, trace.Wrap(err)\n\t\t}\n\n\t\treturn &ws, nil\n\t}\n\n\treturn nil, trace.BadParamete... |
{
"audio": "",
"image": "",
"text": "func (m *JSONMetricRecorder) Close() error {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\n\terr := m.file.Close()\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\t// We have an exclusive lock on this metric batch here, because\n\t// metricsFile.Close was able to rena... | {
"audio": "",
"image": "",
"text": "\t// Now write the meta file so that JSONMetricReader discovers a finished\n\t// pair of files.\n\terr = m.recordMetaData()\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " MetricCollector) {\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\n\tm.registry = append(m.registry, initMetricCollector)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *JSONMetricRecorder) AddMetric(\n\tkey, value string, created time.Time, labels map[string]string) (err error) {\n\tdefer func() {\n\t\tif err != nil {\n\t\t\terr = &errMetricsData{err}\n\t\t}\n\t}()\n\terr = m.validateMetric(key, value)\n\tif err != nil {\n\t",
"vid... | {
"audio": "",
"image": "",
"text": "\treturn errors.Trace(err)\n\t}\n\tm.lock.Lock()\n\tdefer m.lock.Unlock()\n\treturn errors.Trace(m.enc.Encode(jujuc.Metric{\n\t\tKey: key,\n\t\tValue: value,\n\t\tTime: created,\n\t\tLabels: labels,\n\t}))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tkey, err := item.Key.Link(scope, m.KeySpec)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvalue, err := item.Value.Link(scope, m.ValueSpec)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// TODO(abg): Duplicate key check\n\t\titems[i] = ConstantVal... |
{
"audio": "",
"image": "",
"text": "func (m *JSONMetricRecorder) IsDeclaredMetric(key",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string) bool {\n\t_, ok := m.validMetrics[key]\n\treturn ok\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tvalue(&meta)\n\tm.Key = meta.Key\n\tm.ValueKind = meta.ValueKind\n\tm.ValueString = meta.ValueString\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewJSONMetricReader(spoolDir string) (*JSONMetricReader, error) {\n\tif _, err := os.Stat(spoolDir); err != nil {\n\t\treturn nil, errors.Annotatef(err,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"failed to open spool directory %q\", spoolDir)\n\t}\n\treturn &JSONMetricReader{\n\t\tdir: spoolDir,\n\t}, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif spath == mpath {\n\t\treturn\n\t}\n\n\t_, err := os.Stat(spath)\n\tif err != nil {\n\t\tspath = mpath\n\t}\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (r *JSONMetricReader) Read() (_ []MetricBatch, err error) {\n\tdefer func() {\n\t\tif err != nil {\n\t\t\terr = &errMetricsData{err}\n\t\t}\n\t}()\n\n\tvar batches []MetricBatch\n\n\twalker := func(path string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t\tbatch.Metrics, err = decodeMetrics(filepath.Join(r.dir, batch.UUID))\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t\tif len(batch.Metrics) > 0 {\n\t\t\tbatches = append(batches, batch)\n\t\t}\n\t\treturn nil\n\t}\n\tif err := filepath.Walk(r.dir, ... | {
"audio": "",
"image": "",
"text": "\t\tfilepath.Walk(rootPath, func(path string, info os.FileInfo, err error) error {\n\t\t\t\tmatched, err := filepath.Match(\"*.json\", info.Name())\n\t\t\t\tif err != nil {\n\t\t\t\t\twarn(err)\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\t\t\t\tif matched {\n\t\t\t\t\tc <- path\n\t\t\t... |
{
"audio": "",
"image": "",
"text": "func (r *JSONMetricReader) Remove(uuid string) error {\n\tmetaFile := filepath.Join(r.dir, fmt.Sprintf(\"%s.meta\", uuid))\n\tdataFile := filepath.Join(r.dir, uuid)",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\terr := os.Remove(metaFile)\n\tif err != nil && !os.IsNotExist(err) {\n\t\treturn errors.Trace(err)\n\t}\n\terr = os.Remove(dataFile)\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tdata = data + fmt.Sprintf(\"%s = \\\"%s\\\"\\n\", k, v)\n\t}\n\tcfile := filepath.Join(dir, \"config.toml\")\n\treturn ioutil.WriteFile(cfile, []byte(data), 0666)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (cl *deployClient) AddPendingResources(applicationID string, chID charmstore.CharmID, csMac *macaroon.Macaroon, resources []charmresource.Resource) ([]string, error) {\n\treturn cl.Client.AddPendingResources(client.AddPendingResourcesArgs{\n\t\tApplicationID:",
"video":... | {
"audio": "",
"image": "",
"text": " applicationID,\n\t\tCharmID: chID,\n\t\tCharmStoreMacaroon: csMac,\n\t\tResources: resources,\n\t})\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " acct.Attr(acctAttrInstanceURL),\n\t\tAccessToken: acct.Attr(importer.AcctAttrAccessToken),\n\t})\n\n\tcl.Client = *ctxutil.Client(ctx)\n\treturn cl\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (rc *rawConn) checkOperation(projectID string, op *compute.Operation) (*compute.Operation, error) {\n\tvar call opDoer\n\tif op.Zone != \"\" {\n\t\tzoneName := path.Base(op.Zone)\n\t\tcall = rc.ZoneOperations.Get(projectID, zoneName, op.Name)\n\t} else if op.Region != \"\... | {
"audio": "",
"image": "",
"text": " region, op.Name)\n\t} else {\n\t\tcall = rc.GlobalOperations.Get(projectID, op.Name)\n\t}\n\n\toperation, err := doOpCall(call)\n\tif err != nil {\n\t\treturn nil, errors.Annotatef(err, \"request for GCE operation %q failed\", op.Name)\n\t}\n\treturn operation, nil\n}",
"vi... | {
"audio": "",
"image": "",
"text": "\top.releaseDeferred = []int{}\n\top.shouldRollback = true\n\top.dryRun = dryRun\n\treturn op\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (rc *rawConn) ListMachineTypes(projectID, zone string) (*compute.MachineTypeList, error) {\n\top := rc.MachineTypes.List(projectID, zone)",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tmachines, err := op.Do()\n\tif err != nil {\n\t\treturn nil, errors.Annotatef(err, \"listing machine types for project %q and zone %q\", projectID, zone)\n\t}\n\treturn machines, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil {\n\t\treturn fmt.Errorf(\"Decoding response for zones list: %s\", err)\n\t}\n\n\tfor _, zone := range zones.Zones {\n\t\tif zone.Name == vm.Zone.Name {\n\t\t\tvm.Zone.ID = zone.Id\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn fmt.Errorf(\"Zone ID for %q could not be found\",... |
{
"audio": "",
"image": "",
"text": "func (c *Config) Validate() error {\n\tif c.Logger == nil {\n\t\treturn errors.NotValidf(\"missing logger\")\n\t}\n\tif c.WatcherFactory == nil {\n\t\treturn errors.NotValidf(\"missing watcher factory\")\n\t}\n\tif c.PrometheusRegisterer == nil",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\treturn errors.NotValidf(\"missing prometheus registerer\")\n\t}\n\tif c.Cleanup == nil {\n\t\treturn errors.NotValidf(\"missing cleanup func\")\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " config.Topic == \"\" {\n\t\treturn errors.NotValidf(\"empty Topic\")\n\t}\n\tif config.Target == nil {\n\t\treturn errors.NotValidf(\"nil Target\")\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewWorker(config Config) (worker.Worker, error) {\n\tif err := config.Validate(); err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\tw := &cacheWorker{\n\t\tconfig: config,\n\t\tchanges: make(chan interface{}),\n\t}\n\tcontroller, err := cache.NewController(\n\t\tca... | {
"audio": "",
"image": "",
"text": " err := catacomb.Invoke(catacomb.Plan{\n\t\tSite: &w.catacomb,\n\t\tWork: w.loop,\n\t\tInit: []worker.Worker{w.controller},\n\t}); err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\treturn w, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tctx := context.Background()\n\t_, err := w.session.Execute(ctx, \"BEGIN\")\n\tif err != nil {\n\t\treturn false, 0, errors.Trace(err)\n\t}\n\tdoGC, safePoint, err := w.checkPrepare(ctx)\n\tif doGC {\n\t\t_, err = w.session.Execute(ctx, \"COMMIT\")\n\t\tif err != nil {\n\t\t\... |
{
"audio": "",
"image": "",
"text": "func runForAllModelStates(pool *StatePool, runner func(st *State) error) error {\n\tst := pool.SystemState()\n\tmodels, closer := st.db().GetCollection(modelsC)\n\tdefer closer()\n\n\tvar modelDocs []bson.M\n\terr := models.Find(nil).Select(bson.M{\"_id\": 1}).All(&modelDocs)\... | {
"audio": "",
"image": "",
"text": "\t\treturn errors.Annotatef(err, \"failed to open model %q\", modelUUID)\n\t\t}\n\t\tdefer func() {\n\t\t\tmodel.Release()\n\t\t}()\n\t\tif err := runner(model.State); err != nil {\n\t\t\treturn errors.Annotatef(err, \"model UUID %q\", modelUUID)\n\t\t}\n\t}\n\treturn nil\n}",... | {
"audio": "",
"image": "",
"text": "\tfor i, pool := range p.Pools {\n\t\terr := a.storageAccess.RemoveStoragePool(pool.Name)\n\t\tif err != nil {\n\t\t\tresults.Results[i].Error = common.ServerError(err)\n\t\t}\n\t}\n\treturn results, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func readBsonDField(d bson.D, name string) (interface{}, bool) {\n\tfor i := range",
"video": ""
} | {
"audio": "",
"image": "",
"text": " d {\n\t\tfield := &d[i]\n\t\tif field.Name == name {\n\t\t\treturn field.Value, true\n\t\t}\n\t}\n\treturn nil, false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " append(ids, i)\n\t}\n\tsort.Slice(ids, func(i, j int) bool {\n\t\treturn ids[i].CreationDate.After(ids[j].CreationDate)\n\t})\n\tfor _, i := range ids {\n\t\treturn i\n\t}\n\treturn Identity{}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func replaceBsonDField(d bson.D, name string, value interface{}) error {\n\tfor i, field := range d {\n\t\tif field.Name == name {\n\t\t\tnewField := field\n\t\t\tnewField.Value = value\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\td[i] = newField\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn errors.NotFoundf(\"field %q\", name)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " range s {\n\t\tif value.Name == name {\n\t\t\tresult := value.CredentialAttr\n\t\t\treturn &result, true\n\t\t}\n\t}\n\treturn nil, false\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func RenameAddModelPermission(pool *StatePool) error {\n\tst := pool.SystemState()\n\tcoll, closer := st.db().GetRawCollection(permissionsC)\n\tdefer closer()\n\tupgradesLogger.Infof(\"migrating addmodel permission\")\n\n\titer := coll.Find(bson.M{\"access\": \"addmodel\"}).It... | {
"audio": "",
"image": "",
"text": "\n\n\t\tops = append(ops, txn.Op{\n\t\t\tC: permissionsC,\n\t\t\tId: id,\n\t\t\tAssert: txn.DocExists,\n\t\t\tUpdate: bson.D{{\"$set\", bson.D{{\"access\", \"add-model\"}}}},\n\t\t})\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tre... | {
"audio": "",
"image": "",
"text": " doc.DocId,\n\t\t\tAssert: txn.DocExists,\n\t\t\tUpdate: bson.M{\"$set\": bson.M{\"access\": \"login\"}},\n\t\t})\n\t\tops = append(ops,\n\t\t\tcreatePermissionOp(cloudGlobalKey(controllerInfo.CloudName), doc.SubjectGlobalKey, permission.AddModelAccess))\n\t}\n\n\tif err :... |
{
"audio": "",
"image": "",
"text": "func StripLocalUserDomain(pool *StatePool) error {\n\tst := pool.SystemState()\n\tvar ops []txn.Op\n\tmore, err := stripLocalFromFields(st, cloudCredentialsC, \"_id\", \"owner\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tops = append(ops, more...)\n\n\tmore, err = stripLocalF... | {
"audio": "",
"image": "",
"text": "\treturn err\n\t}\n\tops = append(ops, more...)\n\n\tmore, err = stripLocalFromFields(st, controllerUsersC, \"_id\", \"user\", \"createdby\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tops = append(ops, more...)\n\n\tmore, err = stripLocalFromFields(st, modelUsersC, \"_id\", \... | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\t\t\t\top.AddError(err)\n\t\t\t\t}\n\t\t\t\tops = append(ops, epOps...)\n\t\t\t} else {\n\t\t\t\t// When 'force' is set, this call will return both needed operations\n\t\t\t\t// as well as all operational errors encountered.\n\t\t\t\t// If the 'force' is not ... |
{
"audio": "",
"image": "",
"text": "func AddMigrationAttempt(pool *StatePool) error {\n\tst := pool.SystemState()\n\tcoll, closer := st.db().GetRawCollection(migrationsC)\n\tdefer closer()\n\n\tquery := coll.Find(bson.M{\"attempt\": bson.M{\"$exists\": false}})\n\tquery = query.Select(bson.M{\"_id\": 1})\n\titer... | {
"audio": "",
"image": "",
"text": "\n\t\tops = append(ops, txn.Op{\n\t\t\tC: migrationsC,\n\t\t\tId: id,\n\t\t\tAssert: txn.DocExists,\n\t\t\tUpdate: bson.D{{\"$set\", bson.D{{\"attempt\", attempt}}}},\n\t\t})\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Annotate(err, \"iterating mig... | {
"audio": "",
"image": "",
"text": " doc.DocID,\n\t\t\t\tAssert: txn.DocExists,\n\t\t\t\tUpdate: bson.M{\"$set\": bson.M{\"settings\": doc.Settings}},\n\t\t\t})\n\t\t}\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif len(ops) > 0 {\n\t\treturn errors.Trace(st.runRawTransactio... |
{
"audio": "",
"image": "",
"text": "func AddLocalCharmSequences(pool *StatePool) error {\n\tst := pool.SystemState()\n\tcharmsColl, closer := st.db().GetRawCollection(charmsC)\n\tdefer closer()\n\n\tquery := bson.M{\n\t\t\"url\": bson.M{\"$regex\": \"^local:\"},\n\t}\n\tvar docs []bson.M\n\terr := charmsColl.Fin... | {
"audio": "",
"image": "",
"text": " ok := doc[\"life\"].(int); !ok {\n\t\t\tupgradesLogger.Errorf(\"invalid life for charm: %s\", id)\n\t\t\tcontinue\n\t\t} else if life == int(Dead) {\n\t\t\tdeadIds = append(deadIds, id)\n\t\t}\n\n\t}\n\n\tsequences, closer := st.db().GetRawCollection(sequenceC)\n\tdefer close... | {
"audio": "",
"image": "",
"text": " hash.String()\n\t\tunit, ok := hashToUnit[stringHash]\n\t\tif !ok {\n\t\t\tlog.Errorf(\"did not find Unit %v in list of all units\", stringHash)\n\t\t\treturn nil\n\t\t}\n\t\treturn unit\n\t}\n\n\tunits := make([]job.Unit, 0)\n\tfor _, dir := range res.Node.Nodes {\n\t\tu, er... |
{
"audio": "",
"image": "",
"text": "func UpdateLegacyLXDCloudCredentials(\n\tst *State,\n\tendpoint string,\n\tcredential cloud.Credential,\n) error {\n\tcloudOps, err := updateLegacyLXDCloudsOps(st, endpoint)\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tcredOps, err := updateLegacyLXDCredentialsOps(... | {
"audio": "",
"image": "",
"text": " credential)\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\treturn st.db().RunTransaction(append(cloudOps, credOps...))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t}\n\n\tmodel, err := st.Model()\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\tif model.Type() == state.ModelTypeCAAS {\n\t\treturn nil, errors.NotSupportedf(\"high availability on kubernetes controllers\")\n\t}\n\n\treturn &HighAvailabilityAPI{\n\t\tstate: ... |
{
"audio": "",
"image": "",
"text": "func UpgradeNoProxyDefaults(pool *StatePool) error {\n\tst := pool.SystemState()\n\tvar ops []txn.Op\n\tcoll, closer := st.db().GetRawCollection(settingsC)\n\tdefer closer()\n\titer := coll.Find(bson.D{}).Iter()\n\tdefer iter.Close()\n\tvar doc settingsDoc\n\tfor iter.Next(&do... | {
"audio": "",
"image": "",
"text": "\t\tC: settingsC,\n\t\t\tId: doc.DocID,\n\t\t\tAssert: txn.DocExists,\n\t\t\tUpdate: bson.M{\"$set\": bson.M{\"settings\": doc.Settings}},\n\t\t})\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif len(ops) > 0 {\n\t\treturn errors.T... | {
"audio": "",
"image": "",
"text": " doc.DocId,\n\t\t\tAssert: txn.DocExists,\n\t\t\tUpdate: bson.M{\"$set\": bson.M{\"access\": \"login\"}},\n\t\t})\n\t\tops = append(ops,\n\t\t\tcreatePermissionOp(cloudGlobalKey(controllerInfo.CloudName), doc.SubjectGlobalKey, permission.AddModelAccess))\n\t}\n\n\tif err :... |
{
"audio": "",
"image": "",
"text": "func RemoveNilValueApplicationSettings(pool *StatePool) error {\n\tst := pool.SystemState()\n\tcoll, closer := st.db().GetRawCollection(settingsC)\n\tdefer closer()\n\titer := coll.Find(bson.M{\"_id\": bson.M{\"$regex\": \"^.*:a#.*\"}}).Iter()\n\tdefer iter.Close()\n\tvar ops ... | {
"audio": "",
"image": "",
"text": " doc.DocID,\n\t\t\t\tAssert: txn.DocExists,\n\t\t\t\tUpdate: bson.M{\"$set\": bson.M{\"settings\": doc.Settings}},\n\t\t\t})\n\t\t}\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif len(ops) > 0 {\n\t\treturn errors.Trace(st.runRawTransactio... | {
"audio": "",
"image": "",
"text": "\n\n\t\tops = append(ops, txn.Op{\n\t\t\tC: permissionsC,\n\t\t\tId: id,\n\t\t\tAssert: txn.DocExists,\n\t\t\tUpdate: bson.D{{\"$set\", bson.D{{\"access\", \"add-model\"}}}},\n\t\t})\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tre... |
{
"audio": "",
"image": "",
"text": "func AddControllerLogCollectionsSizeSettings(pool *StatePool) error {\n\tst := pool.SystemState()\n\tcoll, closer := st.db().GetRawCollection(controllersC)\n\tdefer closer()\n\tvar doc settingsDoc\n\tif err := coll.FindId(controllerSettingsGlobalKey).One(&doc); err != nil {\n\... | {
"audio": "",
"image": "",
"text": "\tmaybeUpdateSettings(doc.Settings, controller.MaxTxnLogSize, fmt.Sprintf(\"%vM\", controller.DefaultMaxTxnLogCollectionMB)) || settingsChanged\n\tif settingsChanged {\n\t\tops = append(ops, txn.Op{\n\t\t\tC: controllersC,\n\t\t\tId: doc.DocID,\n\t\t\tAssert: txn.DocE... | {
"audio": "",
"image": "",
"text": " doc.DocID,\n\t\t\t\tAssert: txn.DocExists,\n\t\t\t\tUpdate: bson.M{\"$set\": bson.M{\"settings\": doc.Settings}},\n\t\t\t})\n\t\t}\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif len(ops) > 0 {\n\t\treturn errors.Trace(st.runRawTransactio... |
{
"audio": "",
"image": "",
"text": "func applyToAllModelSettings(st *State, change func(*settingsDoc) (bool, error)) error {\n\tuuids, err := st.AllModelUUIDs()\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\n\tcoll, closer := st.db().GetRawCollection(settingsC)\n\tdefer closer()\n\n\tvar ids []string\n... | {
"audio": "",
"image": "",
"text": "\n\n\tvar ops []txn.Op\n\tvar doc settingsDoc\n\tfor iter.Next(&doc) {\n\t\tsettingsChanged, err := change(&doc)\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t\tif settingsChanged {\n\t\t\tops = append(ops, txn.Op{\n\t\t\t\tC: settingsC,\n\t\t\t\tId: ... | {
"audio": "",
"image": "",
"text": " doc.DocID,\n\t\t\t\tAssert: txn.DocExists,\n\t\t\t\tUpdate: bson.M{\"$set\": bson.M{\"settings\": doc.Settings}},\n\t\t\t})\n\t\t}\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif len(ops) > 0 {\n\t\treturn errors.Trace(st.runRawTransactio... |
{
"audio": "",
"image": "",
"text": "func AddStatusHistoryPruneSettings(pool *StatePool) error {\n\tst := pool.SystemState()\n\terr := applyToAllModelSettings(st, func(doc *settingsDoc) (bool, error) {\n\t\tsettingsChanged :=\n\t\t\tmaybeUpdateSettings(doc.Settings, config.MaxStatusHistoryAge, config.DefaultStatu... | {
"audio": "",
"image": "",
"text": "\tmaybeUpdateSettings(doc.Settings, config.MaxStatusHistorySize, config.DefaultStatusHistorySize) || settingsChanged\n\t\treturn settingsChanged, nil\n\t})\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tfor i, pool := range p.Pools {\n\t\terr := a.storageAccess.RemoveStoragePool(pool.Name)\n\t\tif err != nil {\n\t\t\tresults.Results[i].Error = common.ServerError(err)\n\t\t}\n\t}\n\treturn results, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func AddActionPruneSettings(pool *StatePool) error {\n\tst := pool.SystemState()\n\terr := applyToAllModelSettings(st, func(doc *settingsDoc) (bool, error) {\n\t\tsettingsChanged :=\n\t\t\tmaybeUpdateSettings(doc.Settings, config.MaxActionResultsAge, config.DefaultActionResult... | {
"audio": "",
"image": "",
"text": "\tmaybeUpdateSettings(doc.Settings, config.MaxActionResultsSize, config.DefaultActionResultsSize) || settingsChanged\n\t\treturn settingsChanged, nil\n\t})\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tfor i, pool := range p.Pools {\n\t\terr := a.storageAccess.RemoveStoragePool(pool.Name)\n\t\tif err != nil {\n\t\t\tresults.Results[i].Error = common.ServerError(err)\n\t\t}\n\t}\n\treturn results, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func AddUpdateStatusHookSettings(pool *StatePool) error {\n\tst := pool.SystemState()\n\terr := applyToAllModelSettings(st, func(doc *settingsDoc) (bool, error) {\n\t\tsettingsChanged :=\n\t\t\tmaybeUpdateSettings(doc.Settings,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " config.UpdateStatusHookInterval, config.DefaultUpdateStatusHookInterval)\n\t\treturn settingsChanged, nil\n\t})\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tfor i, pool := range p.Pools {\n\t\terr := a.storageAccess.RemoveStoragePool(pool.Name)\n\t\tif err != nil {\n\t\t\tresults.Results[i].Error = common.ServerError(err)\n\t\t}\n\t}\n\treturn results, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func SplitLogCollections(pool *StatePool) error {\n\tst := pool.SystemState()\n\tsession := st.MongoSession()\n\tdb := session.DB(logsDB)\n\toldLogs := db.C(\"logs\")\n\n\t// If we haven't seen any particular model, we need to initialise\n\t// the logs collection with the righ... | {
"audio": "",
"image": "",
"text": " in which case we'd get a duplicate\n\t\t\t// id error (this is OK).\n\t\t\tif !mgo.IsDup(err) {\n\t\t\t\treturn errors.Annotate(err, \"failed to insert log record\")\n\t\t\t}\n\t\t}\n\t\tdoc = nil\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}... | {
"audio": "",
"image": "",
"text": " doc.DocID,\n\t\t\t\tAssert: txn.DocExists,\n\t\t\t\tUpdate: bson.M{\"$set\": bson.M{\"settings\": doc.Settings}},\n\t\t\t})\n\t\t}\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif len(ops) > 0 {\n\t\treturn errors.Trace(st.runRawTransactio... |
{
"audio": "",
"image": "",
"text": "func MoveOldAuditLog(pool *StatePool) error {\n\tst := pool.SystemState()\n\tnames, err := st.MongoSession().DB(\"juju\").CollectionNames()\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif !set.NewStrings(names...).Contains(\"audit.log\") {\n\t\t// No audit log coll... | {
"audio": "",
"image": "",
"text": "\n\t\treturn errors.Trace(coll.DropCollection())\n\t}\n\tsession := st.MongoSession()\n\trenameCommand := bson.D{\n\t\t{\"renameCollection\", \"juju.audit.log\"},\n\t\t{\"to\", \"juju.old-audit.log\"},\n\t}\n\treturn errors.Trace(session.Run(renameCommand, nil))\n}",
"video"... | {
"audio": "",
"image": "",
"text": "\n\t\t\tsuspendOps, err := st.suspendRevokedRelationsOps(offerUUID, user.Id())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Trace(err)\n\t\t\t}\n\t\t\tops = append(ops, suspendOps...)\n\t\t}\n\t\treturn ops, nil\n\t}\n\n\terr = st.db().Run(buildTxn)\n\treturn errors.Trac... |
{
"audio": "",
"image": "",
"text": "func DeleteCloudImageMetadata(pool *StatePool) error {\n\tst := pool.SystemState()\n\tcoll, closer := st.db().GetRawCollection(cloudimagemetadataC)\n\tdefer closer()\n\n\tbulk := coll.Bulk()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tbulk.Unordered()\n\tbulk.RemoveAll(bson.D{{\"source\", bson.D{{\"$ne\", \"custom\"}}}})\n\t_, err := bulk.Run()\n\treturn errors.Annotate(err, \"deleting cloud image metadata records\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := c.Pool.Get()\n\tdefer conn.Close()\n\n\treturn unlinkCollection(conn, db.ExportCollection)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func MoveMongoSpaceToHASpaceConfig(pool *StatePool) error {\n\tst := pool.SystemState()\n\t// Holds Mongo space fields removed from controllersDoc.\n\ttype controllersUpgradeDoc struct {\n\t\tMongoSpaceName string `bson:\"mongo-space-name\"`\n\t\tMongoSpaceState string `bson:... | {
"audio": "",
"image": "",
"text": " := settings.Get(controller.JujuHASpace); ok {\n\t\t\tupgradesLogger.Debugf(\"not copying mongo-space-name %q to juju-ha-space - already set to %q\",\n\t\t\t\tmongoSpace, haSpace)\n\t\t} else {\n\t\t\tsettings.Set(controller.JujuHASpace, mongoSpace)\n\t\t\tif _, err = settings... | {
"audio": "",
"image": "",
"text": " doc.DocID,\n\t\t\t\tAssert: txn.DocExists,\n\t\t\t\tUpdate: bson.M{\"$set\": bson.M{\"settings\": doc.Settings}},\n\t\t\t})\n\t\t}\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif len(ops) > 0 {\n\t\treturn errors.Trace(st.runRawTransactio... |
{
"audio": "",
"image": "",
"text": "func CreateMissingApplicationConfig(pool *StatePool) error {\n\tst := pool.SystemState()\n\tsettingsColl, settingsCloser := st.db().GetRawCollection(settingsC)\n\tdefer settingsCloser()\n\n\tvar applicationConfigIDs []struct {\n\t\tID string `bson:\"_id\"`\n\t}\n\tsettingsColl... | {
"audio": "",
"image": "",
"text": "\tappConfID := fmt.Sprintf(\"%s:%s\", app.ModelUUID, applicationConfigKey(app.Name))\n\t\tif !allIDs.Contains(appConfID) {\n\t\t\tnewOp := createSettingsOp(settingsC, appConfID, emptySettings)\n\t\t\t// createSettingsOp assumes you're using a model-specific state, which will a... | {
"audio": "",
"image": "",
"text": "\tdefer c.Unlock()\n\n\tfor id := range c.cache {\n\t\tif _, ok := liveContainers[id]; !ok {\n\t\t\tdelete(c.cache, id)\n\t\t}\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func RemoveVotingMachineIds(pool *StatePool) error {\n\tst := pool.SystemState()\n\tcontrollerColl, controllerCloser := st.db().GetRawCollection(controllersC)\n\tdefer controllerCloser()\n\t// The votingmachineids field is just a denormalization of Machine.WantsVote() so we ca... | {
"audio": "",
"image": "",
"text": "\n\terr := controllerColl.UpdateId(modelGlobalKey, bson.M{\"$unset\": bson.M{\"votingmachineids\": 1}})\n\tif err != nil {\n\t\treturn errors.Annotate(err, \"removing votingmachineids\")\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " range pool.conns {\n\t\tif candidate == conn {\n\t\t\t// remove the connection, not preserving order\n\t\t\tpool.conns[i], pool.conns = pool.conns[len(pool.conns)-1], pool.conns[:len(pool.conns)-1]\n\n\t\t\t// lost a connection, so fill the pool\n\t\t\tgo pool.fill()\n\t\t\tb... |
{
"audio": "",
"image": "",
"text": "func AddCloudModelCounts(pool *StatePool) error {\n\tst := pool.SystemState()\n\tcloudsColl, closer := st.db().GetCollection(cloudsC)\n\tdefer closer()\n\n\tvar clouds []cloudDoc\n\terr := cloudsColl.Find(nil).All(&clouds)\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\... | {
"audio": "",
"image": "",
"text": "\t\t}\n\t\t_, currentCount, err := countCloudModelRefOp(st, c.Name)\n\t\tif err != nil {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\t\tif n != currentCount {\n\t\t\top, err := nsRefcounts.CreateOrIncRefOp(refCountColl, cloudModelRefCountKey(c.Name), n-currentCount)\n\t\t\tif err... | {
"audio": "",
"image": "",
"text": " != nil {\n\t\treturn bi.closer.Close()\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func UpgradeContainerImageStreamDefault(pool *StatePool) error {\n\tst := pool.SystemState()\n\terr := applyToAllModelSettings(st, func(doc *settingsDoc) (bool, error) {\n\t\tciStreamVal, keySet := doc.Settings[config.ContainerImageStreamKey]\n\t\tif keySet {\n\t\t\tif ciStrea... | {
"audio": "",
"image": "",
"text": "\t\t\t\treturn false, nil\n\t\t\t}\n\t\t}\n\t\tdoc.Settings[config.ContainerImageStreamKey] = \"released\"\n\t\treturn true, nil\n\t})\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tfor i, pool := range p.Pools {\n\t\terr := a.storageAccess.RemoveStoragePool(pool.Name)\n\t\tif err != nil {\n\t\t\tresults.Results[i].Error = common.ServerError(err)\n\t\t}\n\t}\n\treturn results, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func ReplicaSetMembers(pool *StatePool) ([]replicaset.Member, error) {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " replicaset.CurrentMembers(pool.SystemState().MongoSession())\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " = NewRouter(f)\n\n\t// Setup the default error handler\n\tf.SetHTTPErrorHandler(f.defaultErrorHandler)\n\n\t// Setup a new context pool\n\tf.pool.New = func() interface{} {\n\t\treturn NewContext(new(Request), new(Response), f)\n\t}\n\n\treturn\n\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func LegacyLeases(pool *StatePool, localTime time.Time) (map[corelease.Key]corelease.Info, error) {\n\tst := pool.SystemState()\n\treader, err := globalclock.NewReader(globalclock.ReaderConfig{\n\t\tConfig: globalclock.Config{\n\t\t\tCollection: globalClockC,\n\t\t\tMongo: ... | {
"audio": "",
"image": "",
"text": " int64 `bson:\"start\"`\n\t\tDuration time.Duration `bson:\"duration\"`\n\t}\n\n\tfor iter.Next(&doc) {\n\t\tstartTime := time.Unix(0, doc.Start)\n\t\tglobalExpiry := startTime.Add(doc.Duration)\n\t\tremaining := globalExpiry.Sub(globalTime)\n\t\tlocalExpiry := localT... | {
"audio": "",
"image": "",
"text": " doc.DocID,\n\t\t\t\tAssert: txn.DocExists,\n\t\t\t\tUpdate: bson.M{\"$set\": bson.M{\"settings\": doc.Settings}},\n\t\t\t})\n\t\t}\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tif len(ops) > 0 {\n\t\treturn errors.Trace(st.runRawTransactio... |
{
"audio": "",
"image": "",
"text": "func MigrateAddModelPermissions(pool *StatePool) error {\n\tst := pool.SystemState()\n\tcontrollerInfo, err := st.ControllerInfo()\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tcoll, closer := st.db().GetRawCollection(permissionsC)\n\tdefer closer()\n\n\tquery := bs... | {
"audio": "",
"image": "",
"text": " doc.DocId,\n\t\t\tAssert: txn.DocExists,\n\t\t\tUpdate: bson.M{\"$set\": bson.M{\"access\": \"login\"}},\n\t\t})\n\t\tops = append(ops,\n\t\t\tcreatePermissionOp(cloudGlobalKey(controllerInfo.CloudName), doc.SubjectGlobalKey, permission.AddModelAccess))\n\t}\n\n\tif err :... | {
"audio": "",
"image": "",
"text": "\n\n\t\tops = append(ops, txn.Op{\n\t\t\tC: permissionsC,\n\t\t\tId: id,\n\t\t\tAssert: txn.DocExists,\n\t\t\tUpdate: bson.D{{\"$set\", bson.D{{\"access\", \"add-model\"}}}},\n\t\t})\n\t}\n\tif err := iter.Close(); err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tre... |
{
"audio": "",
"image": "",
"text": "func SetEnableDiskUUIDOnVsphere(pool *StatePool) error {\n\treturn errors.Trace(applyToAllModelSettings(pool.SystemState(), func(doc *settingsDoc) (bool, error) {\n\t\ttypeVal, found := doc.Settings[\"type\"]\n\t\tif !found {\n\t\t\treturn false, nil\n\t\t}\n\t\ttypeStr, ok :=... | {
"audio": "",
"image": "",
"text": "\t\tif found {\n\t\t\t// If the config option's already been set don't change\n\t\t\t// it.\n\t\t\treturn false, nil\n\t\t}\n\t\tdoc.Settings[\"enable-disk-uuid\"] = false\n\t\treturn true, nil\n\t}))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tch, err = a.st.Charm(a.doc.CharmURL)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\treturn ch, a.doc.ForceCharm, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func UpdateInheritedControllerConfig(pool *StatePool) error {\n\tst := pool.SystemState()\n\tmodel, err := st.Model()\n\tif err != nil {\n\t\treturn errors.Trace(err)\n\t}\n\tkey := cloudGlobalKey(model.Cloud())\n\n\tvar ops []txn.Op\n\tcoll, closer := st.db().GetRawCollection... | {
"audio": "",
"image": "",
"text": "\tvar doc settingsDoc\n\tfor iter.Next(&doc) {\n\t\tops = append(ops, txn.Op{\n\t\t\tC: globalSettingsC,\n\t\t\tId: doc.DocID,\n\t\t\tRemove: true,\n\t\t\tAssert: txn.DocExists,\n\t\t})\n\t\tdoc.DocID = key\n\t\tops = append(ops, txn.Op{\n\t\t\tC: globalSettingsC... | {
"audio": "",
"image": "",
"text": " doc.DocId,\n\t\t\tAssert: txn.DocExists,\n\t\t\tUpdate: bson.M{\"$set\": bson.M{\"access\": \"login\"}},\n\t\t})\n\t\tops = append(ops,\n\t\t\tcreatePermissionOp(cloudGlobalKey(controllerInfo.CloudName), doc.SubjectGlobalKey, permission.AddModelAccess))\n\t}\n\n\tif err :... |
{
"audio": "",
"image": "",
"text": "func EnsureDefaultModificationStatus(pool *StatePool) error {\n\tst := pool.SystemState()\n\tdb := st.db()\n\n\tmachineCol, machineCloser := db.GetRawCollection(machinesC)\n\tdefer machineCloser()\n\tmachineIter := machineCol.Find(nil).Iter()\n\tdefer machineIter.Close()\n\n\t... | {
"audio": "",
"image": "",
"text": "\t\t} else if err != mgo.ErrNotFound {\n\t\t\treturn errors.Trace(err)\n\t\t}\n\n\t\trawDoc := statusDoc{\n\t\t\tModelUUID: machine.ModelUUID,\n\t\t\tStatus: status.Idle,\n\t\t\tUpdated: updatedTime,\n\t\t}\n\t\tops = append(ops, txn.Op{\n\t\t\tC: statusesC,\n\t\t\tI... | {
"audio": "",
"image": "",
"text": "\n\t\t// Use before hook to save out the session\n\t\trw := res.(martini.ResponseWriter)\n\t\trw.Before(func(martini.ResponseWriter) {\n\t\t\tif s.Written() {\n\t\t\t\tcheck(s.Session().Save(r, res), l)\n\t\t\t}\n\t\t})\n\n\t\t// clear the context, we don't need to use\n\t\t//... |
{
"audio": "",
"image": "",
"text": "func EnsureApplicationDeviceConstraints(pool *StatePool) error {\n\tst := pool.SystemState()\n\tdb := st.db()\n\n\tapplicationCol, applicationCloser := db.GetRawCollection(applicationsC)\n\tdefer applicationCloser()\n\tapplicationIter := applicationCol.Find(nil).Iter()\n\tdefe... | {
"audio": "",
"image": "",
"text": "\t\tlocalID := applicationDeviceConstraintsKey(application.Name, application.CharmURL)\n\t\tkey := ensureModelUUID(application.ModelUUID, localID)\n\n\t\t// We only need to migrate applications that don't have a device\n\t\t// constraints document. So we need to first check if... | {
"audio": "",
"image": "",
"text": " := c.Pool.Get()\n\tdefer conn.Close()\n\n\treturn unlinkCollection(conn, db.ExportCollection)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func RemoveInstanceCharmProfileDataCollection(pool *StatePool) error {\n\tdb := pool.SystemState().MongoSession().DB(jujuDB)\n\tinstanceCharmProfileData := db.C(\"instanceCharmProfileData\")\n\tif err := instanceCharmProfileData.DropCollection(); err != nil {\n\t\t// If the na... | {
"audio": "",
"image": "",
"text": " that's fine.\n\t\tif isMgoNamespaceNotFound(err) {\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.Annotate(err, \"failed to drop instanceCharmProfileData collection\")\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := c.Pool.Get()\n\tdefer conn.Close()\n\n\treturn unlinkCollection(conn, db.ExportCollection)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *VolumeSource) CreateVolumes(ctx context.ProviderCallContext, params []storage.VolumeParams) ([]storage.CreateVolumesResult, error)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\ts.MethodCall(s, \"CreateVolumes\", ctx, params)\n\tif s.CreateVolumesFunc != nil {\n\t\treturn s.CreateVolumesFunc(ctx, params)\n\t}\n\treturn nil, errors.NotImplementedf(\"CreateVolumes\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *VolumeSource) ListVolumes(ctx context.ProviderCallContext) ([]string, error)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\ts.MethodCall(s, \"ListVolumes\", ctx)\n\tif s.ListVolumesFunc != nil {\n\t\treturn s.ListVolumesFunc(ctx)\n\t}\n\treturn nil, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *VolumeSource) DescribeVolumes(ctx context.ProviderCallContext, volIds []string) ([]storage.DescribeVolumesResult, error) {\n\ts.MethodCall(s, \"DescribeVolumes\", ctx, volIds)\n\tif s.DescribeVolumesFunc",
"video": ""
} | {
"audio": "",
"image": "",
"text": " != nil {\n\t\treturn s.DescribeVolumesFunc(ctx, volIds)\n\t}\n\treturn nil, errors.NotImplementedf(\"DescribeVolumes\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *VolumeSource) DestroyVolumes(ctx context.ProviderCallContext, volIds []string) ([]error, error) {\n\ts.MethodCall(s, \"DestroyVolumes\", ctx, volIds)\n\tif s.DestroyVolumesFunc != nil {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn s.DestroyVolumesFunc(ctx, volIds)\n\t}\n\treturn nil, errors.NotImplementedf(\"DestroyVolumes\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *VolumeSource) ReleaseVolumes(ctx context.ProviderCallContext, volIds []string) ([]error, error) {\n\ts.MethodCall(s, \"ReleaseVolumes\", ctx, volIds)\n\tif s.ReleaseVolumesFunc != nil {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn s.ReleaseVolumesFunc(ctx, volIds)\n\t}\n\treturn nil, errors.NotImplementedf(\"ReleaseVolumes\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *VolumeSource) ValidateVolumeParams(params storage.VolumeParams) error {\n\ts.MethodCall(s, \"ValidateVolumeParams\", params)\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " s.ValidateVolumeParamsFunc != nil {\n\t\treturn s.ValidateVolumeParamsFunc(params)\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bridge,\n\t\tMemory: params.Memory,\n\t\tCpuCores: params.CpuCores,\n\t\tRootDisk: params.RootDisk,\n\t\tInterfaces: interfaces,\n\t}); err != nil {\n\t\treturn err\n\t}\n\n\tlogger.Debugf(\"Set machine %s to autostart\", c.name)\n\tif para... |
{
"audio": "",
"image": "",
"text": "func (s *VolumeSource) AttachVolumes(ctx context.ProviderCallContext, params []storage.VolumeAttachmentParams) ([]storage.AttachVolumesResult, error) {\n\ts.MethodCall(s, \"AttachVolumes\", ctx, params)\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " s.AttachVolumesFunc != nil {\n\t\treturn s.AttachVolumesFunc(ctx, params)\n\t}\n\treturn nil, errors.NotImplementedf(\"AttachVolumes\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *VolumeSource) DetachVolumes(ctx context.ProviderCallContext, params []storage.VolumeAttachmentParams) ([]error, error) {\n\ts.MethodCall(s, \"DetachVolumes\", ctx, params)\n\tif s.DetachVolumesFunc",
"video": ""
} | {
"audio": "",
"image": "",
"text": " != nil {\n\t\treturn s.DetachVolumesFunc(ctx, params)\n\t}\n\treturn nil, errors.NotImplementedf(\"DetachVolumes\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewAgentEntityWatcher(st state.EntityFinder, resources facade.Resources, getCanWatch GetAuthFunc) *AgentEntityWatcher {\n\treturn &AgentEntityWatcher{\n\t\tst: ",
"video": ""
} | {
"audio": "",
"image": "",
"text": " st,\n\t\tresources: resources,\n\t\tgetCanWatch: getCanWatch,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\t\treturn authorizer.AuthOwner(tag)\n\t\t}, nil\n\t}\n\taccessUnit := func() (common.AuthFunc, error) {\n\t\treturn func(tag names.Tag) bool {\n\t\t\treturn false\n\t\t}, nil\n\t}\n\n\treturn &API{\n\t\tst: st,\n\t\tresources: resources,\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (a *AgentEntityWatcher) Watch(args params.Entities) (params.NotifyWatchResults, error) {\n\tresult := params.NotifyWatchResults{\n\t\tResults: make([]params.NotifyWatchResult, len(args.Entities)),\n\t}\n\tif len(args.Entities) == 0 {\n\t\treturn result, nil\n\t}\n\tcanWat... | {
"audio": "",
"image": "",
"text": "\n\t\t\tcontinue\n\t\t}\n\t\terr = ErrPerm\n\t\twatcherId := \"\"\n\t\tif canWatch(tag) {\n\t\t\twatcherId, err = a.watchEntity(tag)\n\t\t}\n\t\tresult.Results[i].NotifyWatcherId = watcherId\n\t\tresult.Results[i].Error = ServerError(err)\n\t}\n\treturn result, nil\n}",
"vid... | {
"audio": "",
"image": "",
"text": "\tfor i, arg := range args.Storage {\n\t\tdetails, err := a.importStorage(arg)\n\t\tif err != nil {\n\t\t\tresults[i].Error = common.ServerError(err)\n\t\t\tcontinue\n\t\t}\n\t\tresults[i].Result = details\n\t}\n\treturn params.ImportStorageResults{Results: results}, nil\n}",
... |
{
"audio": "",
"image": "",
"text": "func (c *CommandBase) dumpMetadata(ctx *cmd.Context, result *params.BackupsMetadataResult) {\n\t// TODO: (hml) 2018-04-26\n\t// fix how --quiet and --verbose are handled with backup/restore commands\n\t// should be ctx.Verbosef() here\n\tfmt.Fprintf(ctx.Stdout, \"backup ID: ... | {
"audio": "",
"image": "",
"text": " %v\\n\", result.Started)\n\tfmt.Fprintf(ctx.Stdout, \"finished: %v\\n\", result.Finished)\n\tfmt.Fprintf(ctx.Stdout, \"notes: %q\\n\", result.Notes)\n\n\tfmt.Fprintf(ctx.Stdout, \"model ID: %q\\n\", result.Model)\n\tfmt.Fprintf(ctx.Stdout, \"machine... | {
"audio": "",
"image": "",
"text": " *Context {\n\tfmt.Fprintf(ctx.Writer(), format, args...)\n\treturn ctx\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (cfg ProviderConfig) Validate() error {\n\tif cfg.NewStorageClient == nil {\n\t\treturn errors.NotValidf(\"nil NewStorageClient\")\n\t}\n\tif cfg.RetryClock == nil {\n\t\treturn errors.NotValidf(\"nil RetryClock\")\n\t}\n\tif cfg.RandomWindowsAdminPassword == nil {\n\t\tr... | {
"audio": "",
"image": "",
"text": "\treturn errors.NotValidf(\"nil GenerateSSHKey\")\n\t}\n\tif cfg.ServicePrincipalCreator == nil {\n\t\treturn errors.NotValidf(\"nil ServicePrincipalCreator\")\n\t}\n\tif cfg.AzureCLI == nil {\n\t\treturn errors.NotValidf(\"nil AzureCLI\")\n\t}\n\treturn nil\n}",
"video": ""... | {
"audio": "",
"image": "",
"text": " config.Topic == \"\" {\n\t\treturn errors.NotValidf(\"empty Topic\")\n\t}\n\tif config.Target == nil {\n\t\treturn errors.NotValidf(\"nil Target\")\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewEnvironProvider(config ProviderConfig) (*azureEnvironProvider, error) {\n\tif err := config.Validate(); err != nil {\n\t\treturn nil, errors.Annotate(err, \"validating environ provider configuration\")\n\t}\n\treturn &azureEnvironProvider{\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tenvironProviderCredentials: environProviderCredentials{\n\t\t\tservicePrincipalCreator: config.ServicePrincipalCreator,\n\t\t\tazureCLI: config.AzureCLI,\n\t\t},\n\t\tconfig: config,\n\t}, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"\", 0)\n\n\tmaybeOverrideDuration := func(d time.Duration, target *time.Duration) {\n\t\tif d != 0 {\n\t\t\t*target = d\n\t\t}\n\t}\n\tmaybeOverrideDuration(config.ElectionTimeout, &raftConfig.ElectionTimeout)\n\tmaybeOverrideDuration(config.HeartbeatTimeout, &raftConfig.He... |
{
"audio": "",
"image": "",
"text": "func NewLeadershipPinningAPI(caller base.APICaller) *LeadershipPinningAPI {\n\tfacadeCaller",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := base.NewFacadeCaller(\n\t\tcaller,\n\t\tleadershipFacade,\n\t)\n\treturn NewLeadershipPinningAPIFromFacade(facadeCaller)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " non-empty.\n\tif headers[\"X-Uber-Source\"] == \"\" {\n\t\theaders[\"X-Uber-Source\"] = caller\n\t}\n\treturn headers\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *LeadershipPinningAPI) PinnedLeadership() (map[string][]names.Tag, error) {\n\tvar callResult params.PinnedLeadershipResult\n\terr := a.facade.FacadeCall(\"PinnedLeadership\", nil, &callResult)\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\n\tpinned := m... | {
"audio": "",
"image": "",
"text": "\tentityTags := make([]names.Tag, len(entities))\n\t\tfor i, e := range entities {\n\t\t\ttag, err := names.ParseTag(e)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Trace(err)\n\t\t\t}\n\t\t\tentityTags[i] = tag\n\t\t}\n\n\t\tpinned[app] = entityTags\n\t}\n\treturn pinne... | {
"audio": "",
"image": "",
"text": " nil, errors.Errorf(\"expected one result, got %d\", len(results.Results))\n\t}\n\tresult := results.Results[0]\n\tif err := result.Error; err != nil {\n\t\treturn nil, errors.Trace(result.Error)\n\t}\n\tw := api.newWatcher(api.facade.RawAPICaller(), result)\n\treturn w, nil\n... |
{
"audio": "",
"image": "",
"text": "func (a *LeadershipPinningAPI) PinMachineApplications() (map[string]error, error) {\n\tres,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := a.pinMachineAppsOps(\"PinMachineApplications\")\n\treturn res, errors.Trace(err)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tdrone: client.New(),\n\t\tconnect: func(a *Adaptor) error {\n\t\t\treturn a.drone.Connect()\n\t\t},\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *LeadershipPinningAPI) pinMachineAppsOps(callName string) (map[string]error, error) {\n\tvar callResult params.PinApplicationsResults\n\terr := a.facade.FacadeCall(callName, nil, &callResult)\n\tif err != nil {\n\t\treturn nil, errors.Trace(err)\n\t}\n\n\tcallResults :... | {
"audio": "",
"image": "",
"text": " make(map[string]error, len(callResults))\n\tfor _, res := range callResults {\n\t\tvar appErr error\n\t\tif res.Error != nil {\n\t\t\tappErr = res.Error\n\t\t}\n\t\tresult[res.ApplicationName] = appErr\n\t}\n\treturn result, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t}\n\tvar results params.ErrorResults\n\terr := st.facade.FacadeCall(\"SetMachineBlockDevices\", args, &results)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn results.OneError()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewUniterResolver(cfg ResolverConfig) resolver.Resolver {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn &uniterResolver{\n\t\tconfig: cfg,\n\t\tretryHookTimerStarted: false,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error {\n\t\tc.Resolver = resolver\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *uniterResolver) nextOpConflicted(\n\tlocalState resolver.LocalState,\n\tremoteState remotestate.Snapshot,\n\topFactory operation.Factory,\n) (operation.Operation, error) {\n\tif remoteState.ResolvedMode != params.ResolvedNone {\n\t\tif err := s.config.ClearResolved();... | {
"audio": "",
"image": "",
"text": "\t\t}\n\t\treturn opFactory.NewResolvedUpgrade(localState.CharmURL)\n\t}\n\tif remoteState.ForceCharmUpgrade && charmModified(localState, remoteState) {\n\t\treturn opFactory.NewRevertUpgrade(remoteState.CharmURL)\n\t}\n\treturn nil, resolver.ErrWaiting\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t}\n\t}\n\tfor filesystemTag := range params.filesystemAttachments {\n\t\tfilesystem, err := sb.Filesystem(filesystemTag)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Trace(err)\n\t\t}\n\t\tif params, ok := filesystem.Params(); ok {\n\t\t\tpools.Add(params.Pool)\n\t\t} el... |
{
"audio": "",
"image": "",
"text": "func (NopResolver) NextOp(resolver.LocalState, remotestate.Snapshot, operation.Factory) (operation.Operation,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error) {\n\treturn nil, resolver.ErrNoOperation\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " a write sample\n\t\t\t\tDataTypeFields: DataTypeFields{Type: &voidString},\n\t\t\t\tParameters: []Parameter{},\n\t\t\t\tNickname: route.Operation,\n\t\t\t\tResponseMessages: composeResponseMessages(route, &decl, &sws.config)}\n\n\t\t\toperation.Consumes = rout... |
{
"audio": "",
"image": "",
"text": "func (f *fortress) Lockdown(abort Abort) error {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " f.allowGuests(false, abort)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(f *Forwarder) error {\n\t\tf.httpForwarder.flushInterval = flushInterval\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *fortress) Visit(visit Visit, abort Abort) error {\n\tresult := make(chan error)\n\tselect {\n\tcase <-f.tomb.Dying():\n\t\treturn ErrShutdown\n\tcase <-abort:\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\treturn ErrAborted\n\tcase f.guestTickets <- guestTicket{visit, result}:\n\t\treturn <-result\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tcase <-done:\n\tcase <-w.tomb.Dying():\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *fortress) allowGuests(allowGuests bool, abort Abort) error {\n\tresult := make(chan error)\n\tselect {\n\tcase <-f.tomb.Dying():\n\t\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " ErrShutdown\n\tcase f.guardTickets <- guardTicket{allowGuests, abort, result}:\n\t\treturn <-result\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(f *Forwarder) error {\n\t\tf.httpForwarder.flushInterval = flushInterval\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *fortress) loop() error {\n\tvar active sync.WaitGroup\n\tdefer active.Wait()\n\n\t// guestTickets will be set on Unlock and cleared at the start of Lockdown.\n\tvar guestTickets <-chan guestTicket\n\tfor {\n\t\tselect {\n\t\tcase <-f.tomb.Dying():\n\t\t\treturn tomb.E... | {
"audio": "",
"image": "",
"text": " about abuse but\n\t\t\t// (2) remain comprehensible and functional in the face of aborted\n\t\t\t// Lockdowns.\n\t\t\tif ticket.allowGuests {\n\t\t\t\tguestTickets = f.guestTickets\n\t\t\t} else {\n\t\t\t\tguestTickets = nil\n\t\t\t}\n\t\t\tgo ticket.complete(active.Wait)\n\t... | {
"audio": "",
"image": "",
"text": "\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\tsm.mu.Unlock()\n\t\t\treturn nil, errors.Wrapf(ctx.Err(), \"no active session for %s\", id)\n\t\tdefault:\n\t\t}\n\t\tvar ok bool\n\t\tc, ok = sm.sessions[id]\n\t\tif !ok || c.closed() {\n\t\t\tsm.updateCondition.Wait()\n\t\... |
{
"audio": "",
"image": "",
"text": "func GenerateClientCertificate() (*Certificate, error) {\n\tcert, key, err := shared.GenerateMemCert(true)\n\tif err != nil {\n\t\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil, errors.Trace(err)\n\t}\n\treturn NewCertificate(cert, key), nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " error {\n\terr := s.StoreClean(key, prop, cleanup)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn s.Flag(key)\n}",
"video": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.