_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q3600 | AddSpace | train | func (st *State) AddSpace(name string, providerId network.Id, subnets []string, isPublic bool) (newSpace *Space, err error) {
defer errors.DeferredAnnotatef(&err, "adding space %q", name)
if !names.IsValidSpace(name) {
return nil, errors.NewNotValid(nil, "invalid space name")
}
spaceDoc := spaceDoc{
Life: ... | go | {
"resource": ""
} |
q3601 | Space | train | func (st *State) Space(name string) (*Space, error) {
spaces, closer := st.db().GetCollection(spacesC)
defer closer()
var doc spaceDoc
err := spaces.FindId(name).One(&doc)
if err == mgo.ErrNotFound {
return nil, errors.NotFoundf("space %q", name)
}
if err != nil {
return nil, errors.Annotatef(err, "cannot g... | go | {
"resource": ""
} |
q3602 | AllSpaces | train | func (st *State) AllSpaces() ([]*Space, error) {
spacesCollection, closer := st.db().GetCollection(spacesC)
defer closer()
docs := []spaceDoc{}
err := spacesCollection.Find(nil).All(&docs)
if err != nil {
return nil, errors.Annotatef(err, "cannot get all spaces")
}
spaces := make([]*Space, len(docs))
for i, ... | go | {
"resource": ""
} |
q3603 | EnsureDead | train | func (s *Space) EnsureDead() (err error) {
defer errors.DeferredAnnotatef(&err, "cannot set space %q to dead", s)
if s.doc.Life == Dead {
return nil
}
ops := []txn.Op{{
C: spacesC,
Id: s.doc.Name,
Update: bson.D{{"$set", bson.D{{"life", Dead}}}},
Assert: isAliveDoc,
}}
txnErr := s.st.db().Ru... | go | {
"resource": ""
} |
q3604 | Remove | train | func (s *Space) Remove() (err error) {
defer errors.DeferredAnnotatef(&err, "cannot remove space %q", s)
if s.doc.Life != Dead {
return errors.New("space is not dead")
}
ops := []txn.Op{{
C: spacesC,
Id: s.doc.Name,
Remove: true,
Assert: isDeadDoc,
}}
if s.ProviderId() != "" {
ops = append(... | go | {
"resource": ""
} |
q3605 | NewMockUpgradeSeriesBackend | train | func NewMockUpgradeSeriesBackend(ctrl *gomock.Controller) *MockUpgradeSeriesBackend {
mock := &MockUpgradeSeriesBackend{ctrl: ctrl}
mock.recorder = &MockUpgradeSeriesBackendMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q3606 | NewMockUpgradeSeriesMachine | train | func NewMockUpgradeSeriesMachine(ctrl *gomock.Controller) *MockUpgradeSeriesMachine {
mock := &MockUpgradeSeriesMachine{ctrl: ctrl}
mock.recorder = &MockUpgradeSeriesMachineMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q3607 | RemoveUpgradeSeriesLock | train | func (m *MockUpgradeSeriesMachine) RemoveUpgradeSeriesLock() error {
ret := m.ctrl.Call(m, "RemoveUpgradeSeriesLock")
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q3608 | RemoveUpgradeSeriesLock | train | func (mr *MockUpgradeSeriesMachineMockRecorder) RemoveUpgradeSeriesLock() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveUpgradeSeriesLock", reflect.TypeOf((*MockUpgradeSeriesMachine)(nil).RemoveUpgradeSeriesLock))
} | go | {
"resource": ""
} |
q3609 | Series | train | func (m *MockUpgradeSeriesMachine) Series() string {
ret := m.ctrl.Call(m, "Series")
ret0, _ := ret[0].(string)
return ret0
} | go | {
"resource": ""
} |
q3610 | SetUpgradeSeriesStatus | train | func (m *MockUpgradeSeriesMachine) SetUpgradeSeriesStatus(arg0 model.UpgradeSeriesStatus, arg1 string) error {
ret := m.ctrl.Call(m, "SetUpgradeSeriesStatus", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q3611 | StartUpgradeSeriesUnitCompletion | train | func (m *MockUpgradeSeriesMachine) StartUpgradeSeriesUnitCompletion(arg0 string) error {
ret := m.ctrl.Call(m, "StartUpgradeSeriesUnitCompletion", arg0)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q3612 | UpdateMachineSeries | train | func (m *MockUpgradeSeriesMachine) UpdateMachineSeries(arg0 string, arg1 bool) error {
ret := m.ctrl.Call(m, "UpdateMachineSeries", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
} | go | {
"resource": ""
} |
q3613 | UpgradeSeriesStatus | train | func (m *MockUpgradeSeriesMachine) UpgradeSeriesStatus() (model.UpgradeSeriesStatus, error) {
ret := m.ctrl.Call(m, "UpgradeSeriesStatus")
ret0, _ := ret[0].(model.UpgradeSeriesStatus)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q3614 | UpgradeSeriesTarget | train | func (m *MockUpgradeSeriesMachine) UpgradeSeriesTarget() (string, error) {
ret := m.ctrl.Call(m, "UpgradeSeriesTarget")
ret0, _ := ret[0].(string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q3615 | UpgradeSeriesUnitStatuses | train | func (m *MockUpgradeSeriesMachine) UpgradeSeriesUnitStatuses() (map[string]state.UpgradeSeriesUnitStatus, error) {
ret := m.ctrl.Call(m, "UpgradeSeriesUnitStatuses")
ret0, _ := ret[0].(map[string]state.UpgradeSeriesUnitStatus)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | {
"resource": ""
} |
q3616 | NewMockUpgradeSeriesUnit | train | func NewMockUpgradeSeriesUnit(ctrl *gomock.Controller) *MockUpgradeSeriesUnit {
mock := &MockUpgradeSeriesUnit{ctrl: ctrl}
mock.recorder = &MockUpgradeSeriesUnitMockRecorder{mock}
return mock
} | go | {
"resource": ""
} |
q3617 | UpgradeSeriesStatus | train | func (mr *MockUpgradeSeriesUnitMockRecorder) UpgradeSeriesStatus() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpgradeSeriesStatus", reflect.TypeOf((*MockUpgradeSeriesUnit)(nil).UpgradeSeriesStatus))
} | go | {
"resource": ""
} |
q3618 | RegisterContainerProvider | train | func RegisterContainerProvider(name string, p ContainerEnvironProvider, alias ...string) (unregister func()) {
if err := environs.GlobalProviderRegistry().RegisterProvider(p, name, alias...); err != nil {
panic(fmt.Errorf("juju: %v", err))
}
return func() {
environs.GlobalProviderRegistry().UnregisterProvider(na... | go | {
"resource": ""
} |
q3619 | Open | train | func Open(p environs.EnvironProvider, args environs.OpenParams) (Broker, error) {
if envProvider, ok := p.(ContainerEnvironProvider); !ok {
return nil, errors.NotValidf("container environ provider %T", p)
} else {
return envProvider.Open(args)
}
} | go | {
"resource": ""
} |
q3620 | DeployApplication | train | func DeployApplication(st ApplicationDeployer, args DeployApplicationParams) (Application, error) {
charmConfig, err := args.Charm.Config().ValidateSettings(args.CharmConfig)
if err != nil {
return nil, errors.Trace(err)
}
if args.Charm.Meta().Subordinate {
if args.NumUnits != 0 {
return nil, fmt.Errorf("sub... | go | {
"resource": ""
} |
q3621 | addUnits | train | func addUnits(
unitAdder UnitAdder,
appName string,
n int,
placement []*instance.Placement,
attachStorage []names.StorageTag,
assignUnits bool,
) ([]Unit, error) {
units := make([]Unit, n)
// Hard code for now till we implement a different approach.
policy := state.AssignCleanEmpty
// TODO what do we do if we... | go | {
"resource": ""
} |
q3622 | Info | train | func (c *BootstrapCommand) Info() *cmd.Info {
return jujucmd.Info(&cmd.Info{
Name: "bootstrap-state",
Purpose: "initialize juju state",
})
} | go | {
"resource": ""
} |
q3623 | SetFlags | train | func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet) {
c.AgentConf.AddFlags(f)
f.DurationVar(&c.Timeout, "timeout", time.Duration(0), "set the bootstrap timeout")
} | go | {
"resource": ""
} |
q3624 | populateTools | train | func (c *BootstrapCommand) populateTools(st *state.State, env environs.BootstrapEnviron) error {
agentConfig := c.CurrentConfig()
dataDir := agentConfig.DataDir()
hostSeries, err := series.HostSeries()
if err != nil {
return errors.Trace(err)
}
current := version.Binary{
Number: jujuversion.Current,
Arch: ... | go | {
"resource": ""
} |
q3625 | populateGUIArchive | train | func (c *BootstrapCommand) populateGUIArchive(st *state.State, env environs.BootstrapEnviron) error {
agentConfig := c.CurrentConfig()
dataDir := agentConfig.DataDir()
guistorage, err := st.GUIStorage()
if err != nil {
return errors.Trace(err)
}
defer guistorage.Close()
gui, err := agenttools.ReadGUIArchive(da... | go | {
"resource": ""
} |
q3626 | saveCustomImageMetadata | train | func (c *BootstrapCommand) saveCustomImageMetadata(st *state.State, env environs.BootstrapEnviron, imageMetadata []*imagemetadata.ImageMetadata) error {
logger.Debugf("saving custom image metadata")
return storeImageMetadataInState(st, env, "custom", simplestreams.CUSTOM_CLOUD_DATA, imageMetadata)
} | go | {
"resource": ""
} |
q3627 | storeImageMetadataInState | train | func storeImageMetadataInState(st *state.State, env environs.BootstrapEnviron, source string, priority int, existingMetadata []*imagemetadata.ImageMetadata) error {
if len(existingMetadata) == 0 {
return nil
}
cfg := env.Config()
metadataState := make([]cloudimagemetadata.Metadata, len(existingMetadata))
for i, ... | go | {
"resource": ""
} |
q3628 | NewWorker | train | func NewWorker() worker.Worker {
var w terminationWorker
c := make(chan os.Signal, 1)
signal.Notify(c, TerminationSignal)
w.tomb.Go(func() error {
defer signal.Stop(c)
return w.loop(c)
})
return &w
} | go | {
"resource": ""
} |
q3629 | NewListCommand | train | func NewListCommand() cmd.Command {
cmd := &listCommand{}
cmd.newAPIFunc = func() (StorageListAPI, error) {
return cmd.NewStorageAPI()
}
return modelcmd.Wrap(cmd)
} | go | {
"resource": ""
} |
q3630 | GetCombinedStorageInfo | train | func GetCombinedStorageInfo(p GetCombinedStorageInfoParams) (*CombinedStorage, error) {
combined := &CombinedStorage{}
if p.WantFilesystems {
filesystems, err := generateListFilesystemsOutput(p.Context, p.APIClient, p.Ids)
if err != nil {
return nil, errors.Trace(err)
}
combined.Filesystems = filesystems
... | go | {
"resource": ""
} |
q3631 | generateListStorageOutput | train | func generateListStorageOutput(ctx *cmd.Context, api StorageListAPI) (map[string]StorageInfo, error) {
results, err := api.ListStorageDetails()
if err != nil {
return nil, errors.Trace(err)
}
if len(results) == 0 {
return nil, nil
}
return formatStorageDetails(results)
} | go | {
"resource": ""
} |
q3632 | Empty | train | func (c *CombinedStorage) Empty() bool {
return len(c.StorageInstances) == 0 && len(c.Filesystems) == 0 && len(c.Volumes) == 0
} | go | {
"resource": ""
} |
q3633 | formatListTabularOne | train | func formatListTabularOne(writer io.Writer, value interface{}) error {
return formatListTabular(writer, value, false)
} | go | {
"resource": ""
} |
q3634 | FormatListTabularAll | train | func FormatListTabularAll(writer io.Writer, value interface{}) error {
return formatListTabular(writer, value, true)
} | go | {
"resource": ""
} |
q3635 | Manifold | train | func Manifold(config ManifoldConfig) dependency.Manifold {
return dependency.Manifold{
Inputs: []string{
config.AgentName,
config.APICallerName,
},
Start: func(context dependency.Context) (worker.Worker, error) {
var agent agent.Agent
if err := context.Get(config.AgentName, &agent); err != nil {
... | go | {
"resource": ""
} |
q3636 | ApplicationInstances | train | func ApplicationInstances(st *State, application string) ([]instance.Id, error) {
units, err := allUnits(st, application)
if err != nil {
return nil, err
}
instanceIds := make([]instance.Id, 0, len(units))
for _, unit := range units {
machineId, err := unit.AssignedMachineId()
if errors.IsNotAssigned(err) {
... | go | {
"resource": ""
} |
q3637 | ApplicationMachines | train | func ApplicationMachines(st *State, application string) ([]string, error) {
machines, err := st.AllMachines()
if err != nil {
return nil, err
}
applicationName := unitAppName(application)
var machineIds []string
for _, machine := range machines {
principalSet := set.NewStrings()
for _, principal := range ma... | go | {
"resource": ""
} |
q3638 | NewAddressOnSpace | train | func NewAddressOnSpace(spaceName string, value string) Address {
addr := NewAddress(value)
addr.SpaceName = SpaceName(spaceName)
return addr
} | go | {
"resource": ""
} |
q3639 | NewAddresses | train | func NewAddresses(inAddresses ...string) (outAddresses []Address) {
outAddresses = make([]Address, len(inAddresses))
for i, address := range inAddresses {
outAddresses[i] = NewAddress(address)
}
return outAddresses
} | go | {
"resource": ""
} |
q3640 | NewAddressesOnSpace | train | func NewAddressesOnSpace(spaceName string, inAddresses ...string) (outAddresses []Address) {
outAddresses = make([]Address, len(inAddresses))
for i, address := range inAddresses {
outAddresses[i] = NewAddressOnSpace(spaceName, address)
}
return outAddresses
} | go | {
"resource": ""
} |
q3641 | DeriveAddressType | train | func DeriveAddressType(value string) AddressType {
ip := net.ParseIP(value)
switch {
case ip == nil:
// TODO(gz): Check value is a valid hostname
return HostName
case ip.To4() != nil:
return IPv4Address
case ip.To16() != nil:
return IPv6Address
default:
panic("Unknown form of IP address")
}
} | go | {
"resource": ""
} |
q3642 | deriveScope | train | func deriveScope(addr Address) Scope {
if addr.Type == HostName {
return addr.Scope
}
ip := net.ParseIP(addr.Value)
if ip == nil {
return addr.Scope
}
if ip.IsLoopback() {
return ScopeMachineLocal
}
if isIPv4PrivateNetworkAddress(addr.Type, ip) ||
isIPv6UniqueLocalAddress(addr.Type, ip) {
return Scope... | go | {
"resource": ""
} |
q3643 | ExactScopeMatch | train | func ExactScopeMatch(addr Address, addrScopes ...Scope) bool {
for _, scope := range addrScopes {
if addr.Scope == scope {
return true
}
}
return false
} | go | {
"resource": ""
} |
q3644 | SelectAddressesBySpaceNames | train | func SelectAddressesBySpaceNames(addresses []Address, spaceNames ...SpaceName) ([]Address, bool) {
if len(spaceNames) == 0 {
logger.Errorf("addresses not filtered - no spaces given.")
return addresses, false
}
var selectedAddresses []Address
for _, addr := range addresses {
if spaceNameList(spaceNames).Index... | go | {
"resource": ""
} |
q3645 | SelectHostPortsBySpaceNames | train | func SelectHostPortsBySpaceNames(hps []HostPort, spaceNames ...SpaceName) ([]HostPort, bool) {
if len(spaceNames) == 0 {
logger.Errorf("host ports not filtered - no spaces given.")
return hps, false
}
var selectedHostPorts []HostPort
for _, hp := range hps {
if spaceNameList(spaceNames).IndexOf(hp.SpaceName)... | go | {
"resource": ""
} |
q3646 | SelectPublicHostPort | train | func SelectPublicHostPort(hps []HostPort) string {
index := bestAddressIndex(len(hps), func(i int) Address {
return hps[i].Address
}, publicMatch)
if index < 0 {
return ""
}
return hps[index].NetAddr()
} | go | {
"resource": ""
} |
q3647 | SelectInternalAddresses | train | func SelectInternalAddresses(addresses []Address, machineLocal bool) []Address {
indexes := bestAddressIndexes(len(addresses), func(i int) Address {
return addresses[i]
}, internalAddressMatcher(machineLocal))
if len(indexes) == 0 {
return nil
}
out := make([]Address, 0, len(indexes))
for _, index := range i... | go | {
"resource": ""
} |
q3648 | SelectInternalHostPort | train | func SelectInternalHostPort(hps []HostPort, machineLocal bool) string {
index := bestAddressIndex(len(hps), func(i int) Address {
return hps[i].Address
}, internalAddressMatcher(machineLocal))
if index < 0 {
return ""
}
return hps[index].NetAddr()
} | go | {
"resource": ""
} |
q3649 | SelectInternalHostPorts | train | func SelectInternalHostPorts(hps []HostPort, machineLocal bool) []string {
indexes := bestAddressIndexes(len(hps), func(i int) Address {
return hps[i].Address
}, internalAddressMatcher(machineLocal))
out := make([]string, 0, len(indexes))
for _, index := range indexes {
out = append(out, hps[index].NetAddr())
... | go | {
"resource": ""
} |
q3650 | DecimalToIPv4 | train | func DecimalToIPv4(addr uint32) net.IP {
bytes := make([]byte, 4)
binary.BigEndian.PutUint32(bytes, addr)
return net.IP(bytes)
} | go | {
"resource": ""
} |
q3651 | IPv4ToDecimal | train | func IPv4ToDecimal(ipv4Addr net.IP) (uint32, error) {
ip := ipv4Addr.To4()
if ip == nil {
return 0, errors.Errorf("%q is not a valid IPv4 address", ipv4Addr.String())
}
return binary.BigEndian.Uint32([]byte(ip)), nil
} | go | {
"resource": ""
} |
q3652 | machineBlockDevicesChanged | train | func machineBlockDevicesChanged(ctx *context) error {
volumeTags := make([]names.VolumeTag, 0, len(ctx.incompleteFilesystemParams))
// We must query volumes for both incomplete filesystems
// and incomplete filesystem attachments, because even
// though a filesystem attachment cannot exist without a
// filesystem,... | go | {
"resource": ""
} |
q3653 | processPendingVolumeBlockDevices | train | func processPendingVolumeBlockDevices(ctx *context) error {
if len(ctx.pendingVolumeBlockDevices) == 0 {
logger.Tracef("no pending volume block devices")
return nil
}
volumeTags := make([]names.VolumeTag, len(ctx.pendingVolumeBlockDevices))
for i, tag := range ctx.pendingVolumeBlockDevices.SortedValues() {
vo... | go | {
"resource": ""
} |
q3654 | refreshVolumeBlockDevices | train | func refreshVolumeBlockDevices(ctx *context, volumeTags []names.VolumeTag) error {
machineTag, ok := ctx.config.Scope.(names.MachineTag)
if !ok {
// This function should only be called by machine-scoped
// storage provisioners.
logger.Warningf("refresh block devices, expected machine tag, got %v", ctx.config.Sc... | go | {
"resource": ""
} |
q3655 | NewLayeredStorage | train | func NewLayeredStorage(s ...Storage) (Storage, error) {
if len(s) <= 1 {
return nil, errors.Errorf("expected multiple stores")
}
return layeredStorage(s), nil
} | go | {
"resource": ""
} |
q3656 | Add | train | func (s layeredStorage) Add(r io.Reader, m Metadata) error {
return s[0].Add(r, m)
} | go | {
"resource": ""
} |
q3657 | Open | train | func (s layeredStorage) Open(v string) (Metadata, io.ReadCloser, error) {
var m Metadata
var rc io.ReadCloser
var err error
for _, s := range s {
m, rc, err = s.Open(v)
if !errors.IsNotFound(err) {
break
}
}
return m, rc, err
} | go | {
"resource": ""
} |
q3658 | Metadata | train | func (s layeredStorage) Metadata(v string) (Metadata, error) {
var m Metadata
var err error
for _, s := range s {
m, err = s.Metadata(v)
if !errors.IsNotFound(err) {
break
}
}
return m, err
} | go | {
"resource": ""
} |
q3659 | AllMetadata | train | func (s layeredStorage) AllMetadata() ([]Metadata, error) {
seen := set.NewStrings()
var all []Metadata
for _, s := range s {
sm, err := s.AllMetadata()
if err != nil {
return nil, err
}
for _, m := range sm {
if seen.Contains(m.Version) {
continue
}
all = append(all, m)
seen.Add(m.Version... | go | {
"resource": ""
} |
q3660 | Unstage | train | func (staged StagedResource) Unstage() error {
buildTxn := func(attempt int) ([]txn.Op, error) {
if attempt > 0 {
// The op has no assert so we should not get here.
return nil, errors.New("unstaging the resource failed")
}
ops := newRemoveStagedResourceOps(staged.id)
return ops, nil
}
if err := staged... | go | {
"resource": ""
} |
q3661 | Activate | train | func (staged StagedResource) Activate() error {
buildTxn := func(attempt int) ([]txn.Op, error) {
// This is an "upsert".
var ops []txn.Op
switch attempt {
case 0:
ops = newInsertResourceOps(staged.stored)
case 1:
ops = newUpdateResourceOps(staged.stored)
default:
return nil, errors.New("setting t... | go | {
"resource": ""
} |
q3662 | Id | train | func (a *action) Id() string {
return a.st.localID(a.doc.DocId)
} | go | {
"resource": ""
} |
q3663 | Results | train | func (a *action) Results() (map[string]interface{}, string) {
return a.doc.Results, a.doc.Message
} | go | {
"resource": ""
} |
q3664 | Begin | train | func (a *action) Begin() (Action, error) {
m, err := a.Model()
if err != nil {
return nil, errors.Trace(err)
}
err = m.st.db().RunTransaction([]txn.Op{
{
C: actionsC,
Id: a.doc.DocId,
Assert: bson.D{{"status", ActionPending}},
Update: bson.D{{"$set", bson.D{
{"status", ActionRunning},
... | go | {
"resource": ""
} |
q3665 | Finish | train | func (a *action) Finish(results ActionResults) (Action, error) {
return a.removeAndLog(results.Status, results.Results, results.Message)
} | go | {
"resource": ""
} |
q3666 | removeAndLog | train | func (a *action) removeAndLog(finalStatus ActionStatus, results map[string]interface{}, message string) (Action, error) {
m, err := a.Model()
if err != nil {
return nil, errors.Trace(err)
}
err = m.st.db().RunTransaction([]txn.Op{
{
C: actionsC,
Id: a.doc.DocId,
Assert: bson.D{{"status", bson.D{
... | go | {
"resource": ""
} |
q3667 | newAction | train | func newAction(st *State, adoc actionDoc) Action {
return &action{
st: st,
doc: adoc,
}
} | go | {
"resource": ""
} |
q3668 | newActionDoc | train | func newActionDoc(mb modelBackend, receiverTag names.Tag, actionName string, parameters map[string]interface{}) (actionDoc, actionNotificationDoc, error) {
prefix := ensureActionMarker(receiverTag.Id())
actionId, err := NewUUID()
if err != nil {
return actionDoc{}, actionNotificationDoc{}, err
}
actionLogger.Deb... | go | {
"resource": ""
} |
q3669 | Action | train | func (m *Model) Action(id string) (Action, error) {
actionLogger.Tracef("Action() %q", id)
st := m.st
actions, closer := st.db().GetCollection(actionsC)
defer closer()
doc := actionDoc{}
err := actions.FindId(id).One(&doc)
if err == mgo.ErrNotFound {
return nil, errors.NotFoundf("action %q", id)
}
if err !=... | go | {
"resource": ""
} |
q3670 | AllActions | train | func (m *Model) AllActions() ([]Action, error) {
actionLogger.Tracef("AllActions()")
actions, closer := m.st.db().GetCollection(actionsC)
defer closer()
results := []Action{}
docs := []actionDoc{}
err := actions.Find(nil).All(&docs)
if err != nil {
return nil, errors.Annotatef(err, "cannot get all actions")
... | go | {
"resource": ""
} |
q3671 | ActionByTag | train | func (m *Model) ActionByTag(tag names.ActionTag) (Action, error) {
return m.Action(tag.Id())
} | go | {
"resource": ""
} |
q3672 | FindActionTagsByPrefix | train | func (m *Model) FindActionTagsByPrefix(prefix string) []names.ActionTag {
actionLogger.Tracef("FindActionTagsByPrefix() %q", prefix)
var results []names.ActionTag
var doc struct {
Id string `bson:"_id"`
}
actions, closer := m.st.db().GetCollection(actionsC)
defer closer()
iter := actions.Find(bson.D{{"_id", ... | go | {
"resource": ""
} |
q3673 | FindActionsByName | train | func (m *Model) FindActionsByName(name string) ([]Action, error) {
var results []Action
var doc actionDoc
actions, closer := m.st.db().GetCollection(actionsC)
defer closer()
iter := actions.Find(bson.D{{"name", name}}).Iter()
for iter.Next(&doc) {
results = append(results, newAction(m.st, doc))
}
return res... | go | {
"resource": ""
} |
q3674 | matchingActions | train | func (st *State) matchingActions(ar ActionReceiver) ([]Action, error) {
return st.matchingActionsByReceiverId(ar.Tag().Id())
} | go | {
"resource": ""
} |
q3675 | matchingActionsByReceiverId | train | func (st *State) matchingActionsByReceiverId(id string) ([]Action, error) {
var doc actionDoc
var actions []Action
actionsCollection, closer := st.db().GetCollection(actionsC)
defer closer()
iter := actionsCollection.Find(bson.D{{"receiver", id}}).Iter()
for iter.Next(&doc) {
actions = append(actions, newActi... | go | {
"resource": ""
} |
q3676 | matchingActionsPending | train | func (st *State) matchingActionsPending(ar ActionReceiver) ([]Action, error) {
completed := bson.D{{"status", ActionPending}}
return st.matchingActionsByReceiverAndStatus(ar.Tag(), completed)
} | go | {
"resource": ""
} |
q3677 | matchingActionsRunning | train | func (st *State) matchingActionsRunning(ar ActionReceiver) ([]Action, error) {
completed := bson.D{{"status", ActionRunning}}
return st.matchingActionsByReceiverAndStatus(ar.Tag(), completed)
} | go | {
"resource": ""
} |
q3678 | matchingActionsCompleted | train | func (st *State) matchingActionsCompleted(ar ActionReceiver) ([]Action, error) {
completed := bson.D{{"$or", []bson.D{
{{"status", ActionCompleted}},
{{"status", ActionCancelled}},
{{"status", ActionFailed}},
}}}
return st.matchingActionsByReceiverAndStatus(ar.Tag(), completed)
} | go | {
"resource": ""
} |
q3679 | matchingActionsByReceiverAndStatus | train | func (st *State) matchingActionsByReceiverAndStatus(tag names.Tag, statusCondition bson.D) ([]Action, error) {
var doc actionDoc
var actions []Action
actionsCollection, closer := st.db().GetCollection(actionsC)
defer closer()
sel := append(bson.D{{"receiver", tag.Id()}}, statusCondition...)
iter := actionsColle... | go | {
"resource": ""
} |
q3680 | CharmInfo | train | func (c *Client) CharmInfo(charmURL string) (*CharmInfo, error) {
args := params.CharmURL{URL: charmURL}
var info params.CharmInfo
if err := c.facade.FacadeCall("CharmInfo", args, &info); err != nil {
return nil, errors.Trace(err)
}
meta, err := convertCharmMeta(info.Meta)
if err != nil {
return nil, errors.T... | go | {
"resource": ""
} |
q3681 | NewAddCloudCommand | train | func NewAddCloudCommand(cloudMetadataStore CloudMetadataStore) cmd.Command {
cloudCallCtx := context.NewCloudCallContext()
store := jujuclient.NewFileClientStore()
c := &AddCloudCommand{
OptionalControllerCommand: modelcmd.OptionalControllerCommand{Store: store},
cloudMetadataStore: cloudMetadataStore,
... | go | {
"resource": ""
} |
q3682 | Run | train | func (c *AddCloudCommand) Run(ctxt *cmd.Context) error {
if c.CloudFile == "" && c.controllerName == "" {
return c.runInteractive(ctxt)
}
var newCloud *jujucloud.Cloud
var err error
if c.CloudFile != "" {
newCloud, err = c.readCloudFromFile(ctxt)
} else {
// No cloud file specified so we try and use a name... | go | {
"resource": ""
} |
q3683 | addCertificate | train | func addCertificate(data []byte) (string, []byte, error) {
vals, err := ensureStringMaps(string(data))
if err != nil {
return "", nil, err
}
name, ok := vals[jujucloud.CertFilenameKey]
if !ok {
return "", nil, errors.NotFoundf("yaml has no certificate file")
}
filename := name.(string)
if ok && filename != ... | go | {
"resource": ""
} |
q3684 | addableCloudProviders | train | func addableCloudProviders() (providers []string, unsupported []string, _ error) {
allproviders := environs.RegisteredProviders()
for _, name := range allproviders {
provider, err := environs.Provider(name)
if err != nil {
// should be impossible
return nil, nil, errors.Trace(err)
}
if provider.CloudSc... | go | {
"resource": ""
} |
q3685 | nameExists | train | func nameExists(name string, public map[string]jujucloud.Cloud) (string, error) {
if _, ok := public[name]; ok {
return fmt.Sprintf("%q is the name of a public cloud", name), nil
}
builtin, err := common.BuiltInClouds()
if err != nil {
return "", errors.Trace(err)
}
if _, ok := builtin[name]; ok {
return fm... | go | {
"resource": ""
} |
q3686 | New | train | func New(backend Backend, resources facade.Resources, auth facade.Authorizer) (*Facade, error) {
if !auth.AuthMachineAgent() && !auth.AuthUnitAgent() && !auth.AuthApplicationAgent() {
return nil, common.ErrPerm
}
return &Facade{
backend: backend,
resources: resources,
}, nil
} | go | {
"resource": ""
} |
q3687 | Phase | train | func (facade *Facade) Phase(entities params.Entities) params.PhaseResults {
count := len(entities.Entities)
results := params.PhaseResults{
Results: make([]params.PhaseResult, count),
}
for i, entity := range entities.Entities {
phase, err := facade.onePhase(entity.Tag)
results.Results[i].Phase = phase
resu... | go | {
"resource": ""
} |
q3688 | onePhase | train | func (facade *Facade) onePhase(tagString string) (string, error) {
if err := facade.auth(tagString); err != nil {
return "", errors.Trace(err)
}
phase, err := facade.backend.MigrationPhase()
if err != nil {
return "", errors.Trace(err)
}
return phase.String(), nil
} | go | {
"resource": ""
} |
q3689 | Watch | train | func (facade *Facade) Watch(entities params.Entities) params.NotifyWatchResults {
count := len(entities.Entities)
results := params.NotifyWatchResults{
Results: make([]params.NotifyWatchResult, count),
}
for i, entity := range entities.Entities {
id, err := facade.oneWatch(entity.Tag)
results.Results[i].Notif... | go | {
"resource": ""
} |
q3690 | Manifold | train | func Manifold(config ManifoldConfig) dependency.Manifold {
return dependency.Manifold{
Inputs: []string{
config.AgentName,
config.MetricSpoolName,
config.CharmDirName,
},
Start: func(context dependency.Context) (worker.Worker, error) {
collector, err := newCollect(config, context)
if err != nil {
... | go | {
"resource": ""
} |
q3691 | Do | train | func (w *collect) Do(stop <-chan struct{}) (err error) {
defer func() {
// See bug https://pad/lv/1733469
// If this function which is run by a PeriodicWorker
// exits with an error, we need to call stop() to
// ensure the listener socket is closed.
if err != nil {
w.stop()
}
}()
config := w.agent.Cu... | go | {
"resource": ""
} |
q3692 | NewCredentialValidatorAPI | train | func NewCredentialValidatorAPI(ctx facade.Context) (*CredentialValidatorAPI, error) {
return internalNewCredentialValidatorAPI(NewBackend(NewStateShim(ctx.State())), ctx.Resources(), ctx.Auth())
} | go | {
"resource": ""
} |
q3693 | NewCredentialValidatorAPIv1 | train | func NewCredentialValidatorAPIv1(ctx facade.Context) (*CredentialValidatorAPIV1, error) {
v2, err := NewCredentialValidatorAPI(ctx)
if err != nil {
return nil, err
}
return &CredentialValidatorAPIV1{v2}, nil
} | go | {
"resource": ""
} |
q3694 | WatchCredential | train | func (api *CredentialValidatorAPI) WatchCredential(tag params.Entity) (params.NotifyWatchResult, error) {
fail := func(failure error) (params.NotifyWatchResult, error) {
return params.NotifyWatchResult{}, common.ServerError(failure)
}
credentialTag, err := names.ParseCloudCredentialTag(tag.Tag)
if err != nil {
... | go | {
"resource": ""
} |
q3695 | ModelCredential | train | func (api *CredentialValidatorAPI) ModelCredential() (params.ModelCredential, error) {
c, err := api.backend.ModelCredential()
if err != nil {
return params.ModelCredential{}, common.ServerError(err)
}
return params.ModelCredential{
Model: c.Model.String(),
CloudCredential: c.Credential.String(),
... | go | {
"resource": ""
} |
q3696 | WatchModelCredential | train | func (api *CredentialValidatorAPI) WatchModelCredential() (params.NotifyWatchResult, error) {
result := params.NotifyWatchResult{}
watch, err := api.backend.WatchModelCredential()
if err != nil {
return result, common.ServerError(err)
}
// Consume the initial event. Technically, API calls to Watch
// 'transmit... | go | {
"resource": ""
} |
q3697 | NewFacade | train | func NewFacade(
resources facade.Resources,
authorizer facade.Authorizer,
st CAASUnitProvisionerState,
sb StorageBackend,
db DeviceBackend,
storagePoolManager poolmanager.PoolManager,
registry storage.ProviderRegistry,
clock clock.Clock,
) (*Facade, error) {
if !authorizer.AuthController() {
return nil, comm... | go | {
"resource": ""
} |
q3698 | WatchApplicationsScale | train | func (f *Facade) WatchApplicationsScale(args params.Entities) (params.NotifyWatchResults, error) {
results := params.NotifyWatchResults{
Results: make([]params.NotifyWatchResult, len(args.Entities)),
}
for i, arg := range args.Entities {
id, err := f.watchApplicationScale(arg.Tag)
if err != nil {
results.Re... | go | {
"resource": ""
} |
q3699 | WatchPodSpec | train | func (f *Facade) WatchPodSpec(args params.Entities) (params.NotifyWatchResults, error) {
model, err := f.state.Model()
if err != nil {
return params.NotifyWatchResults{}, errors.Trace(err)
}
results := params.NotifyWatchResults{
Results: make([]params.NotifyWatchResult, len(args.Entities)),
}
for i, arg := ra... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.