id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3,400 | juju/juju | state/volume.go | PlanInfo | func (v *volumeAttachmentPlan) PlanInfo() (VolumeAttachmentPlanInfo, error) {
if v.doc.PlanInfo == nil {
return VolumeAttachmentPlanInfo{}, errors.NotProvisionedf("volume attachment plan %q on %q", v.doc.Volume, v.doc.Machine)
}
return *v.doc.PlanInfo, nil
} | go | func (v *volumeAttachmentPlan) PlanInfo() (VolumeAttachmentPlanInfo, error) {
if v.doc.PlanInfo == nil {
return VolumeAttachmentPlanInfo{}, errors.NotProvisionedf("volume attachment plan %q on %q", v.doc.Volume, v.doc.Machine)
}
return *v.doc.PlanInfo, nil
} | [
"func",
"(",
"v",
"*",
"volumeAttachmentPlan",
")",
"PlanInfo",
"(",
")",
"(",
"VolumeAttachmentPlanInfo",
",",
"error",
")",
"{",
"if",
"v",
".",
"doc",
".",
"PlanInfo",
"==",
"nil",
"{",
"return",
"VolumeAttachmentPlanInfo",
"{",
"}",
",",
"errors",
".",... | // PlanInfo is required to implement VolumeAttachment. | [
"PlanInfo",
"is",
"required",
"to",
"implement",
"VolumeAttachment",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L335-L340 |
3,401 | juju/juju | state/volume.go | Volume | func (v *volumeAttachment) Volume() names.VolumeTag {
return names.NewVolumeTag(v.doc.Volume)
} | go | func (v *volumeAttachment) Volume() names.VolumeTag {
return names.NewVolumeTag(v.doc.Volume)
} | [
"func",
"(",
"v",
"*",
"volumeAttachment",
")",
"Volume",
"(",
")",
"names",
".",
"VolumeTag",
"{",
"return",
"names",
".",
"NewVolumeTag",
"(",
"v",
".",
"doc",
".",
"Volume",
")",
"\n",
"}"
] | // Volume is required to implement VolumeAttachment. | [
"Volume",
"is",
"required",
"to",
"implement",
"VolumeAttachment",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L350-L352 |
3,402 | juju/juju | state/volume.go | Info | func (v *volumeAttachment) Info() (VolumeAttachmentInfo, error) {
if v.doc.Info == nil {
host := storageAttachmentHost(v.doc.Host)
return VolumeAttachmentInfo{}, errors.NotProvisionedf("volume attachment %q on %q", v.doc.Volume, names.ReadableString(host))
}
return *v.doc.Info, nil
} | go | func (v *volumeAttachment) Info() (VolumeAttachmentInfo, error) {
if v.doc.Info == nil {
host := storageAttachmentHost(v.doc.Host)
return VolumeAttachmentInfo{}, errors.NotProvisionedf("volume attachment %q on %q", v.doc.Volume, names.ReadableString(host))
}
return *v.doc.Info, nil
} | [
"func",
"(",
"v",
"*",
"volumeAttachment",
")",
"Info",
"(",
")",
"(",
"VolumeAttachmentInfo",
",",
"error",
")",
"{",
"if",
"v",
".",
"doc",
".",
"Info",
"==",
"nil",
"{",
"host",
":=",
"storageAttachmentHost",
"(",
"v",
".",
"doc",
".",
"Host",
")"... | // Info is required to implement VolumeAttachment. | [
"Info",
"is",
"required",
"to",
"implement",
"VolumeAttachment",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L365-L371 |
3,403 | juju/juju | state/volume.go | Params | func (v *volumeAttachment) Params() (VolumeAttachmentParams, bool) {
if v.doc.Params == nil {
return VolumeAttachmentParams{}, false
}
return *v.doc.Params, true
} | go | func (v *volumeAttachment) Params() (VolumeAttachmentParams, bool) {
if v.doc.Params == nil {
return VolumeAttachmentParams{}, false
}
return *v.doc.Params, true
} | [
"func",
"(",
"v",
"*",
"volumeAttachment",
")",
"Params",
"(",
")",
"(",
"VolumeAttachmentParams",
",",
"bool",
")",
"{",
"if",
"v",
".",
"doc",
".",
"Params",
"==",
"nil",
"{",
"return",
"VolumeAttachmentParams",
"{",
"}",
",",
"false",
"\n",
"}",
"\n... | // Params is required to implement VolumeAttachment. | [
"Params",
"is",
"required",
"to",
"implement",
"VolumeAttachment",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L374-L379 |
3,404 | juju/juju | state/volume.go | Volume | func (sb *storageBackend) Volume(tag names.VolumeTag) (Volume, error) {
v, err := getVolumeByTag(sb.mb, tag)
return v, err
} | go | func (sb *storageBackend) Volume(tag names.VolumeTag) (Volume, error) {
v, err := getVolumeByTag(sb.mb, tag)
return v, err
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"Volume",
"(",
"tag",
"names",
".",
"VolumeTag",
")",
"(",
"Volume",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"getVolumeByTag",
"(",
"sb",
".",
"mb",
",",
"tag",
")",
"\n",
"return",
"v",
",",
... | // Volume returns the Volume with the specified name. | [
"Volume",
"returns",
"the",
"Volume",
"with",
"the",
"specified",
"name",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L382-L385 |
3,405 | juju/juju | state/volume.go | StorageInstanceVolume | func (sb *storageBackend) StorageInstanceVolume(tag names.StorageTag) (Volume, error) {
v, err := sb.storageInstanceVolume(tag)
return v, err
} | go | func (sb *storageBackend) StorageInstanceVolume(tag names.StorageTag) (Volume, error) {
v, err := sb.storageInstanceVolume(tag)
return v, err
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"StorageInstanceVolume",
"(",
"tag",
"names",
".",
"StorageTag",
")",
"(",
"Volume",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"sb",
".",
"storageInstanceVolume",
"(",
"tag",
")",
"\n",
"return",
"v",
... | // StorageInstanceVolume returns the Volume assigned to the specified
// storage instance. | [
"StorageInstanceVolume",
"returns",
"the",
"Volume",
"assigned",
"to",
"the",
"specified",
"storage",
"instance",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L466-L469 |
3,406 | juju/juju | state/volume.go | VolumeAttachment | func (sb *storageBackend) VolumeAttachment(host names.Tag, volume names.VolumeTag) (VolumeAttachment, error) {
coll, cleanup := sb.mb.db().GetCollection(volumeAttachmentsC)
defer cleanup()
var att volumeAttachment
err := coll.FindId(volumeAttachmentId(host.Id(), volume.Id())).One(&att.doc)
if err == mgo.ErrNotFound {
return nil, errors.NotFoundf("volume %q on %q", volume.Id(), names.ReadableString(host))
} else if err != nil {
return nil, errors.Annotatef(err, "getting volume %q on %q", volume.Id(), names.ReadableString(host))
}
return &att, nil
} | go | func (sb *storageBackend) VolumeAttachment(host names.Tag, volume names.VolumeTag) (VolumeAttachment, error) {
coll, cleanup := sb.mb.db().GetCollection(volumeAttachmentsC)
defer cleanup()
var att volumeAttachment
err := coll.FindId(volumeAttachmentId(host.Id(), volume.Id())).One(&att.doc)
if err == mgo.ErrNotFound {
return nil, errors.NotFoundf("volume %q on %q", volume.Id(), names.ReadableString(host))
} else if err != nil {
return nil, errors.Annotatef(err, "getting volume %q on %q", volume.Id(), names.ReadableString(host))
}
return &att, nil
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"VolumeAttachment",
"(",
"host",
"names",
".",
"Tag",
",",
"volume",
"names",
".",
"VolumeTag",
")",
"(",
"VolumeAttachment",
",",
"error",
")",
"{",
"coll",
",",
"cleanup",
":=",
"sb",
".",
"mb",
".",
"db... | // VolumeAttachment returns the VolumeAttachment corresponding to
// the specified volume and machine. | [
"VolumeAttachment",
"returns",
"the",
"VolumeAttachment",
"corresponding",
"to",
"the",
"specified",
"volume",
"and",
"machine",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L473-L485 |
3,407 | juju/juju | state/volume.go | MachineVolumeAttachments | func (sb *storageBackend) MachineVolumeAttachments(machine names.MachineTag) ([]VolumeAttachment, error) {
attachments, err := sb.volumeAttachments(bson.D{{"hostid", machine.Id()}})
if err != nil {
return nil, errors.Annotatef(err, "getting volume attachments for machine %q", machine.Id())
}
return attachments, nil
} | go | func (sb *storageBackend) MachineVolumeAttachments(machine names.MachineTag) ([]VolumeAttachment, error) {
attachments, err := sb.volumeAttachments(bson.D{{"hostid", machine.Id()}})
if err != nil {
return nil, errors.Annotatef(err, "getting volume attachments for machine %q", machine.Id())
}
return attachments, nil
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"MachineVolumeAttachments",
"(",
"machine",
"names",
".",
"MachineTag",
")",
"(",
"[",
"]",
"VolumeAttachment",
",",
"error",
")",
"{",
"attachments",
",",
"err",
":=",
"sb",
".",
"volumeAttachments",
"(",
"bson... | // MachineVolumeAttachments returns all of the VolumeAttachments for the
// specified machine. | [
"MachineVolumeAttachments",
"returns",
"all",
"of",
"the",
"VolumeAttachments",
"for",
"the",
"specified",
"machine",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L503-L509 |
3,408 | juju/juju | state/volume.go | UnitVolumeAttachments | func (sb *storageBackend) UnitVolumeAttachments(unit names.UnitTag) ([]VolumeAttachment, error) {
attachments, err := sb.volumeAttachments(bson.D{{"hostid", unit.Id()}})
if err != nil {
return nil, errors.Annotatef(err, "getting volume attachments for unit %q", unit.Id())
}
return attachments, nil
} | go | func (sb *storageBackend) UnitVolumeAttachments(unit names.UnitTag) ([]VolumeAttachment, error) {
attachments, err := sb.volumeAttachments(bson.D{{"hostid", unit.Id()}})
if err != nil {
return nil, errors.Annotatef(err, "getting volume attachments for unit %q", unit.Id())
}
return attachments, nil
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"UnitVolumeAttachments",
"(",
"unit",
"names",
".",
"UnitTag",
")",
"(",
"[",
"]",
"VolumeAttachment",
",",
"error",
")",
"{",
"attachments",
",",
"err",
":=",
"sb",
".",
"volumeAttachments",
"(",
"bson",
".",... | // UnitVolumeAttachments returns all of the VolumeAttachments for the
// specified unit. | [
"UnitVolumeAttachments",
"returns",
"all",
"of",
"the",
"VolumeAttachments",
"for",
"the",
"specified",
"unit",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L513-L519 |
3,409 | juju/juju | state/volume.go | VolumeAttachments | func (sb *storageBackend) VolumeAttachments(volume names.VolumeTag) ([]VolumeAttachment, error) {
attachments, err := sb.volumeAttachments(bson.D{{"volumeid", volume.Id()}})
if err != nil {
return nil, errors.Annotatef(err, "getting volume attachments for volume %q", volume.Id())
}
return attachments, nil
} | go | func (sb *storageBackend) VolumeAttachments(volume names.VolumeTag) ([]VolumeAttachment, error) {
attachments, err := sb.volumeAttachments(bson.D{{"volumeid", volume.Id()}})
if err != nil {
return nil, errors.Annotatef(err, "getting volume attachments for volume %q", volume.Id())
}
return attachments, nil
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"VolumeAttachments",
"(",
"volume",
"names",
".",
"VolumeTag",
")",
"(",
"[",
"]",
"VolumeAttachment",
",",
"error",
")",
"{",
"attachments",
",",
"err",
":=",
"sb",
".",
"volumeAttachments",
"(",
"bson",
".",... | // VolumeAttachments returns all of the VolumeAttachments for the specified
// volume. | [
"VolumeAttachments",
"returns",
"all",
"of",
"the",
"VolumeAttachments",
"for",
"the",
"specified",
"volume",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L523-L529 |
3,410 | juju/juju | state/volume.go | VolumeAttachmentPlans | func (sb *storageBackend) VolumeAttachmentPlans(volume names.VolumeTag) ([]VolumeAttachmentPlan, error) {
attachmentPlans, err := sb.volumeAttachmentPlans(bson.D{{"volumeid", volume.Id()}})
if err != nil {
return nil, errors.Annotatef(err, "getting volume attachment plans for volume %q", volume.Id())
}
return attachmentPlans, nil
} | go | func (sb *storageBackend) VolumeAttachmentPlans(volume names.VolumeTag) ([]VolumeAttachmentPlan, error) {
attachmentPlans, err := sb.volumeAttachmentPlans(bson.D{{"volumeid", volume.Id()}})
if err != nil {
return nil, errors.Annotatef(err, "getting volume attachment plans for volume %q", volume.Id())
}
return attachmentPlans, nil
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"VolumeAttachmentPlans",
"(",
"volume",
"names",
".",
"VolumeTag",
")",
"(",
"[",
"]",
"VolumeAttachmentPlan",
",",
"error",
")",
"{",
"attachmentPlans",
",",
"err",
":=",
"sb",
".",
"volumeAttachmentPlans",
"(",
... | // VolumeAttachmentPlans returns all of the VolumeAttachmentPlans for the specified
// volume. | [
"VolumeAttachmentPlans",
"returns",
"all",
"of",
"the",
"VolumeAttachmentPlans",
"for",
"the",
"specified",
"volume",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L560-L566 |
3,411 | juju/juju | state/volume.go | removeMachineVolumesOps | func (sb *storageBackend) removeMachineVolumesOps(m *Machine) ([]txn.Op, error) {
// A machine cannot transition to Dead if it has any detachable storage
// attached, so any attachments are for machine-bound storage.
//
// Even if a volume is "non-detachable", there still exist volume
// attachments, and they may be removed independently of the volume.
// For example, the user may request that the volume be destroyed.
// This will cause the volume to become Dying, and the attachment to
// be Dying, then Dead, and finally removed. Only once the attachment
// is removed will the volume transition to Dead and then be removed.
// Therefore, there may be volumes that are bound, but not attached,
// to the machine.
machineVolumes, err := sb.volumes(bson.D{{"hostid", m.Id()}})
if err != nil {
return nil, errors.Trace(err)
}
ops := make([]txn.Op, 0, 2*len(machineVolumes)+len(m.doc.Volumes))
for _, volumeId := range m.doc.Volumes {
ops = append(ops, txn.Op{
C: volumeAttachmentsC,
Id: volumeAttachmentId(m.Id(), volumeId),
Assert: txn.DocExists,
Remove: true,
})
}
for _, v := range machineVolumes {
if v.doc.StorageId != "" {
// The volume is assigned to a storage instance;
// make sure we also remove the storage instance.
// There should be no storage attachments remaining,
// as the units must have been removed before the
// machine can be; and the storage attachments must
// have been removed before the unit can be.
ops = append(ops,
txn.Op{
C: storageInstancesC,
Id: v.doc.StorageId,
Assert: txn.DocExists,
Remove: true,
},
)
}
ops = append(ops, sb.removeVolumeOps(v.VolumeTag())...)
}
return ops, nil
} | go | func (sb *storageBackend) removeMachineVolumesOps(m *Machine) ([]txn.Op, error) {
// A machine cannot transition to Dead if it has any detachable storage
// attached, so any attachments are for machine-bound storage.
//
// Even if a volume is "non-detachable", there still exist volume
// attachments, and they may be removed independently of the volume.
// For example, the user may request that the volume be destroyed.
// This will cause the volume to become Dying, and the attachment to
// be Dying, then Dead, and finally removed. Only once the attachment
// is removed will the volume transition to Dead and then be removed.
// Therefore, there may be volumes that are bound, but not attached,
// to the machine.
machineVolumes, err := sb.volumes(bson.D{{"hostid", m.Id()}})
if err != nil {
return nil, errors.Trace(err)
}
ops := make([]txn.Op, 0, 2*len(machineVolumes)+len(m.doc.Volumes))
for _, volumeId := range m.doc.Volumes {
ops = append(ops, txn.Op{
C: volumeAttachmentsC,
Id: volumeAttachmentId(m.Id(), volumeId),
Assert: txn.DocExists,
Remove: true,
})
}
for _, v := range machineVolumes {
if v.doc.StorageId != "" {
// The volume is assigned to a storage instance;
// make sure we also remove the storage instance.
// There should be no storage attachments remaining,
// as the units must have been removed before the
// machine can be; and the storage attachments must
// have been removed before the unit can be.
ops = append(ops,
txn.Op{
C: storageInstancesC,
Id: v.doc.StorageId,
Assert: txn.DocExists,
Remove: true,
},
)
}
ops = append(ops, sb.removeVolumeOps(v.VolumeTag())...)
}
return ops, nil
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"removeMachineVolumesOps",
"(",
"m",
"*",
"Machine",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"// A machine cannot transition to Dead if it has any detachable storage",
"// attached, so any attachments ... | // removeMachineVolumesOps returns txn.Ops to remove non-persistent volumes
// bound or attached to the specified machine. This is used when the given
// machine is being removed from state. | [
"removeMachineVolumesOps",
"returns",
"txn",
".",
"Ops",
"to",
"remove",
"non",
"-",
"persistent",
"volumes",
"bound",
"or",
"attached",
"to",
"the",
"specified",
"machine",
".",
"This",
"is",
"used",
"when",
"the",
"given",
"machine",
"is",
"being",
"removed"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L598-L644 |
3,412 | juju/juju | state/volume.go | isDetachableVolumeTag | func isDetachableVolumeTag(db Database, tag names.VolumeTag) (bool, error) {
doc, err := getVolumeDocByTag(db, tag)
if err != nil {
return false, errors.Trace(err)
}
return detachableVolumeDoc(&doc), nil
} | go | func isDetachableVolumeTag(db Database, tag names.VolumeTag) (bool, error) {
doc, err := getVolumeDocByTag(db, tag)
if err != nil {
return false, errors.Trace(err)
}
return detachableVolumeDoc(&doc), nil
} | [
"func",
"isDetachableVolumeTag",
"(",
"db",
"Database",
",",
"tag",
"names",
".",
"VolumeTag",
")",
"(",
"bool",
",",
"error",
")",
"{",
"doc",
",",
"err",
":=",
"getVolumeDocByTag",
"(",
"db",
",",
"tag",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // isDetachableVolumeTag reports whether or not the volume with the specified
// tag is detachable. | [
"isDetachableVolumeTag",
"reports",
"whether",
"or",
"not",
"the",
"volume",
"with",
"the",
"specified",
"tag",
"is",
"detachable",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L648-L654 |
3,413 | juju/juju | state/volume.go | isDetachableVolumePool | func isDetachableVolumePool(im *storageBackend, pool string) (bool, error) {
_, provider, _, err := poolStorageProvider(im, pool)
if err != nil {
return false, errors.Trace(err)
}
if provider.Scope() == storage.ScopeMachine {
// Any storage created by a machine cannot be detached from
// the machine, and must be destroyed along with it.
return false, nil
}
if provider.Dynamic() {
// NOTE(axw) In theory, we don't know ahead of time
// whether the storage will be Persistent, as the model
// allows for a dynamic storage provider to create non-
// persistent storage. None of the storage providers do
// this, so we assume it will be persistent for now.
//
// TODO(axw) get rid of the Persistent field from Volume
// and Filesystem. We only need to care whether the
// storage is dynamic and model-scoped.
return true, nil
}
// Volume is static, so it will be tied to the machine.
return false, nil
} | go | func isDetachableVolumePool(im *storageBackend, pool string) (bool, error) {
_, provider, _, err := poolStorageProvider(im, pool)
if err != nil {
return false, errors.Trace(err)
}
if provider.Scope() == storage.ScopeMachine {
// Any storage created by a machine cannot be detached from
// the machine, and must be destroyed along with it.
return false, nil
}
if provider.Dynamic() {
// NOTE(axw) In theory, we don't know ahead of time
// whether the storage will be Persistent, as the model
// allows for a dynamic storage provider to create non-
// persistent storage. None of the storage providers do
// this, so we assume it will be persistent for now.
//
// TODO(axw) get rid of the Persistent field from Volume
// and Filesystem. We only need to care whether the
// storage is dynamic and model-scoped.
return true, nil
}
// Volume is static, so it will be tied to the machine.
return false, nil
} | [
"func",
"isDetachableVolumePool",
"(",
"im",
"*",
"storageBackend",
",",
"pool",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"_",
",",
"provider",
",",
"_",
",",
"err",
":=",
"poolStorageProvider",
"(",
"im",
",",
"pool",
")",
"\n",
"if",
"err"... | // isDetachableVolumePool reports whether or not the given storage
// pool will create a volume that is not inherently bound to a machine,
// and therefore can be detached. | [
"isDetachableVolumePool",
"reports",
"whether",
"or",
"not",
"the",
"given",
"storage",
"pool",
"will",
"create",
"a",
"volume",
"that",
"is",
"not",
"inherently",
"bound",
"to",
"a",
"machine",
"and",
"therefore",
"can",
"be",
"detached",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L675-L699 |
3,414 | juju/juju | state/volume.go | DetachVolume | func (sb *storageBackend) DetachVolume(host names.Tag, volume names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "detaching volume %s from %s", volume.Id(), names.ReadableString(host))
// If the volume is backing a filesystem, the volume cannot be detached
// until the filesystem has been detached.
if _, err := sb.volumeFilesystemAttachment(host, volume); err == nil {
return &errContainsFilesystem{errors.New("volume contains attached filesystem")}
} else if !errors.IsNotFound(err) {
return errors.Trace(err)
}
buildTxn := func(attempt int) ([]txn.Op, error) {
va, err := sb.VolumeAttachment(host, volume)
if err != nil {
return nil, errors.Trace(err)
}
if va.Life() != Alive {
return nil, jujutxn.ErrNoOperations
}
detachable, err := isDetachableVolumeTag(sb.mb.db(), volume)
if err != nil {
return nil, errors.Trace(err)
}
if !detachable {
return nil, errors.New("volume is not detachable")
}
if plans, err := sb.machineVolumeAttachmentPlans(host, volume); err != nil {
return nil, errors.Trace(err)
} else {
if len(plans) > 0 {
return detachStorageAttachmentOps(host, volume), nil
}
}
return detachVolumeOps(host, volume), nil
}
return sb.mb.db().Run(buildTxn)
} | go | func (sb *storageBackend) DetachVolume(host names.Tag, volume names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "detaching volume %s from %s", volume.Id(), names.ReadableString(host))
// If the volume is backing a filesystem, the volume cannot be detached
// until the filesystem has been detached.
if _, err := sb.volumeFilesystemAttachment(host, volume); err == nil {
return &errContainsFilesystem{errors.New("volume contains attached filesystem")}
} else if !errors.IsNotFound(err) {
return errors.Trace(err)
}
buildTxn := func(attempt int) ([]txn.Op, error) {
va, err := sb.VolumeAttachment(host, volume)
if err != nil {
return nil, errors.Trace(err)
}
if va.Life() != Alive {
return nil, jujutxn.ErrNoOperations
}
detachable, err := isDetachableVolumeTag(sb.mb.db(), volume)
if err != nil {
return nil, errors.Trace(err)
}
if !detachable {
return nil, errors.New("volume is not detachable")
}
if plans, err := sb.machineVolumeAttachmentPlans(host, volume); err != nil {
return nil, errors.Trace(err)
} else {
if len(plans) > 0 {
return detachStorageAttachmentOps(host, volume), nil
}
}
return detachVolumeOps(host, volume), nil
}
return sb.mb.db().Run(buildTxn)
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"DetachVolume",
"(",
"host",
"names",
".",
"Tag",
",",
"volume",
"names",
".",
"VolumeTag",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"errors",
".",
"DeferredAnnotatef",
"(",
"&",
"err",
",",
"\"",
"\""... | // DetachVolume marks the volume attachment identified by the specified machine
// and volume tags as Dying, if it is Alive. DetachVolume will fail with a
// IsContainsFilesystem error if the volume contains an attached filesystem; the
// filesystem attachment must be removed first. DetachVolume will fail for
// inherently machine-bound volumes. | [
"DetachVolume",
"marks",
"the",
"volume",
"attachment",
"identified",
"by",
"the",
"specified",
"machine",
"and",
"volume",
"tags",
"as",
"Dying",
"if",
"it",
"is",
"Alive",
".",
"DetachVolume",
"will",
"fail",
"with",
"a",
"IsContainsFilesystem",
"error",
"if",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L706-L740 |
3,415 | juju/juju | state/volume.go | RemoveVolumeAttachment | func (sb *storageBackend) RemoveVolumeAttachment(host names.Tag, volume names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "removing attachment of volume %s from %s", volume.Id(), names.ReadableString(host))
buildTxn := func(attempt int) ([]txn.Op, error) {
attachment, err := sb.VolumeAttachment(host, volume)
if errors.IsNotFound(err) && attempt > 0 {
// We only ignore IsNotFound on attempts after the
// first, since we expect the volume attachment to
// be there initially.
return nil, jujutxn.ErrNoOperations
}
if err != nil {
return nil, errors.Trace(err)
}
if attachment.Life() != Dying {
return nil, errors.New("volume attachment is not dying")
}
v, err := getVolumeByTag(sb.mb, volume)
if err != nil {
return nil, errors.Trace(err)
}
return removeVolumeAttachmentOps(host, v), nil
}
return sb.mb.db().Run(buildTxn)
} | go | func (sb *storageBackend) RemoveVolumeAttachment(host names.Tag, volume names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "removing attachment of volume %s from %s", volume.Id(), names.ReadableString(host))
buildTxn := func(attempt int) ([]txn.Op, error) {
attachment, err := sb.VolumeAttachment(host, volume)
if errors.IsNotFound(err) && attempt > 0 {
// We only ignore IsNotFound on attempts after the
// first, since we expect the volume attachment to
// be there initially.
return nil, jujutxn.ErrNoOperations
}
if err != nil {
return nil, errors.Trace(err)
}
if attachment.Life() != Dying {
return nil, errors.New("volume attachment is not dying")
}
v, err := getVolumeByTag(sb.mb, volume)
if err != nil {
return nil, errors.Trace(err)
}
return removeVolumeAttachmentOps(host, v), nil
}
return sb.mb.db().Run(buildTxn)
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"RemoveVolumeAttachment",
"(",
"host",
"names",
".",
"Tag",
",",
"volume",
"names",
".",
"VolumeTag",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"errors",
".",
"DeferredAnnotatef",
"(",
"&",
"err",
",",
"\... | // RemoveVolumeAttachment removes the volume attachment from state.
// RemoveVolumeAttachment will fail if the attachment is not Dying. | [
"RemoveVolumeAttachment",
"removes",
"the",
"volume",
"attachment",
"from",
"state",
".",
"RemoveVolumeAttachment",
"will",
"fail",
"if",
"the",
"attachment",
"is",
"not",
"Dying",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L771-L794 |
3,416 | juju/juju | state/volume.go | DestroyVolume | func (sb *storageBackend) DestroyVolume(tag names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "destroying volume %s", tag.Id())
if _, err := sb.VolumeFilesystem(tag); err == nil {
return &errContainsFilesystem{errors.New("volume contains filesystem")}
} else if !errors.IsNotFound(err) {
return errors.Trace(err)
}
buildTxn := func(attempt int) ([]txn.Op, error) {
volume, err := getVolumeByTag(sb.mb, tag)
if errors.IsNotFound(err) && attempt > 0 {
// On the first attempt, we expect it to exist.
return nil, jujutxn.ErrNoOperations
} else if err != nil {
return nil, errors.Trace(err)
}
if volume.doc.StorageId != "" {
return nil, errors.Errorf(
"volume is assigned to %s",
names.ReadableString(names.NewStorageTag(volume.doc.StorageId)),
)
}
if volume.Life() != Alive {
return nil, jujutxn.ErrNoOperations
}
hasNoStorageAssignment := bson.D{{"$or", []bson.D{
{{"storageid", ""}},
{{"storageid", bson.D{{"$exists", false}}}},
}}}
return destroyVolumeOps(sb, volume, false, hasNoStorageAssignment)
}
return sb.mb.db().Run(buildTxn)
} | go | func (sb *storageBackend) DestroyVolume(tag names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "destroying volume %s", tag.Id())
if _, err := sb.VolumeFilesystem(tag); err == nil {
return &errContainsFilesystem{errors.New("volume contains filesystem")}
} else if !errors.IsNotFound(err) {
return errors.Trace(err)
}
buildTxn := func(attempt int) ([]txn.Op, error) {
volume, err := getVolumeByTag(sb.mb, tag)
if errors.IsNotFound(err) && attempt > 0 {
// On the first attempt, we expect it to exist.
return nil, jujutxn.ErrNoOperations
} else if err != nil {
return nil, errors.Trace(err)
}
if volume.doc.StorageId != "" {
return nil, errors.Errorf(
"volume is assigned to %s",
names.ReadableString(names.NewStorageTag(volume.doc.StorageId)),
)
}
if volume.Life() != Alive {
return nil, jujutxn.ErrNoOperations
}
hasNoStorageAssignment := bson.D{{"$or", []bson.D{
{{"storageid", ""}},
{{"storageid", bson.D{{"$exists", false}}}},
}}}
return destroyVolumeOps(sb, volume, false, hasNoStorageAssignment)
}
return sb.mb.db().Run(buildTxn)
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"DestroyVolume",
"(",
"tag",
"names",
".",
"VolumeTag",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"errors",
".",
"DeferredAnnotatef",
"(",
"&",
"err",
",",
"\"",
"\"",
",",
"tag",
".",
"Id",
"(",
")",... | // DestroyVolume ensures that the volume and any attachments to it will be
// destroyed and removed from state at some point in the future. DestroyVolume
// will fail with an IsContainsFilesystem error if the volume contains a
// filesystem; the filesystem must be fully removed first. | [
"DestroyVolume",
"ensures",
"that",
"the",
"volume",
"and",
"any",
"attachments",
"to",
"it",
"will",
"be",
"destroyed",
"and",
"removed",
"from",
"state",
"at",
"some",
"point",
"in",
"the",
"future",
".",
"DestroyVolume",
"will",
"fail",
"with",
"an",
"IsC... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L875-L906 |
3,417 | juju/juju | state/volume.go | RemoveVolume | func (sb *storageBackend) RemoveVolume(tag names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "removing volume %s", tag.Id())
buildTxn := func(attempt int) ([]txn.Op, error) {
volume, err := sb.Volume(tag)
if errors.IsNotFound(err) {
return nil, jujutxn.ErrNoOperations
} else if err != nil {
return nil, errors.Trace(err)
}
if volume.Life() != Dead {
return nil, errors.New("volume is not dead")
}
return sb.removeVolumeOps(tag), nil
}
return sb.mb.db().Run(buildTxn)
} | go | func (sb *storageBackend) RemoveVolume(tag names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "removing volume %s", tag.Id())
buildTxn := func(attempt int) ([]txn.Op, error) {
volume, err := sb.Volume(tag)
if errors.IsNotFound(err) {
return nil, jujutxn.ErrNoOperations
} else if err != nil {
return nil, errors.Trace(err)
}
if volume.Life() != Dead {
return nil, errors.New("volume is not dead")
}
return sb.removeVolumeOps(tag), nil
}
return sb.mb.db().Run(buildTxn)
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"RemoveVolume",
"(",
"tag",
"names",
".",
"VolumeTag",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"errors",
".",
"DeferredAnnotatef",
"(",
"&",
"err",
",",
"\"",
"\"",
",",
"tag",
".",
"Id",
"(",
")",
... | // RemoveVolume removes the volume from state. RemoveVolume will fail if
// the volume is not Dead, which implies that it still has attachments. | [
"RemoveVolume",
"removes",
"the",
"volume",
"from",
"state",
".",
"RemoveVolume",
"will",
"fail",
"if",
"the",
"volume",
"is",
"not",
"Dead",
"which",
"implies",
"that",
"it",
"still",
"has",
"attachments",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L964-L979 |
3,418 | juju/juju | state/volume.go | addVolumeOps | func (sb *storageBackend) addVolumeOps(params VolumeParams, hostId string) ([]txn.Op, names.VolumeTag, error) {
params, err := sb.volumeParamsWithDefaults(params)
if err != nil {
return nil, names.VolumeTag{}, errors.Trace(err)
}
detachable, err := isDetachableVolumePool(sb, params.Pool)
if err != nil {
return nil, names.VolumeTag{}, errors.Trace(err)
}
origHostId := hostId
hostId, err = sb.validateVolumeParams(params, hostId)
if err != nil {
return nil, names.VolumeTag{}, errors.Annotate(err, "validating volume params")
}
name, err := newVolumeName(sb.mb, hostId)
if err != nil {
return nil, names.VolumeTag{}, errors.Annotate(err, "cannot generate volume name")
}
statusDoc := statusDoc{
Status: status.Pending,
Updated: sb.mb.clock().Now().UnixNano(),
}
doc := volumeDoc{
Name: name,
StorageId: params.storage.Id(),
}
if params.volumeInfo != nil {
// We're importing an already provisioned volume into the
// model. Set provisioned info rather than params, and set
// the status to "detached".
statusDoc.Status = status.Detached
doc.Info = params.volumeInfo
} else {
// Every new volume is created with one attachment.
doc.Params = ¶ms
doc.AttachmentCount = 1
}
if !detachable {
doc.HostId = origHostId
}
return sb.newVolumeOps(doc, statusDoc), names.NewVolumeTag(name), nil
} | go | func (sb *storageBackend) addVolumeOps(params VolumeParams, hostId string) ([]txn.Op, names.VolumeTag, error) {
params, err := sb.volumeParamsWithDefaults(params)
if err != nil {
return nil, names.VolumeTag{}, errors.Trace(err)
}
detachable, err := isDetachableVolumePool(sb, params.Pool)
if err != nil {
return nil, names.VolumeTag{}, errors.Trace(err)
}
origHostId := hostId
hostId, err = sb.validateVolumeParams(params, hostId)
if err != nil {
return nil, names.VolumeTag{}, errors.Annotate(err, "validating volume params")
}
name, err := newVolumeName(sb.mb, hostId)
if err != nil {
return nil, names.VolumeTag{}, errors.Annotate(err, "cannot generate volume name")
}
statusDoc := statusDoc{
Status: status.Pending,
Updated: sb.mb.clock().Now().UnixNano(),
}
doc := volumeDoc{
Name: name,
StorageId: params.storage.Id(),
}
if params.volumeInfo != nil {
// We're importing an already provisioned volume into the
// model. Set provisioned info rather than params, and set
// the status to "detached".
statusDoc.Status = status.Detached
doc.Info = params.volumeInfo
} else {
// Every new volume is created with one attachment.
doc.Params = ¶ms
doc.AttachmentCount = 1
}
if !detachable {
doc.HostId = origHostId
}
return sb.newVolumeOps(doc, statusDoc), names.NewVolumeTag(name), nil
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"addVolumeOps",
"(",
"params",
"VolumeParams",
",",
"hostId",
"string",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"names",
".",
"VolumeTag",
",",
"error",
")",
"{",
"params",
",",
"err",
":=",
"sb",
"."... | // addVolumeOps returns txn.Ops to create a new volume with the specified
// parameters. If the supplied host ID is non-empty, and the storage
// provider is machine-scoped, then the volume will be scoped to that
// machine. | [
"addVolumeOps",
"returns",
"txn",
".",
"Ops",
"to",
"create",
"a",
"new",
"volume",
"with",
"the",
"specified",
"parameters",
".",
"If",
"the",
"supplied",
"host",
"ID",
"is",
"non",
"-",
"empty",
"and",
"the",
"storage",
"provider",
"is",
"machine",
"-",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1014-L1055 |
3,419 | juju/juju | state/volume.go | validateVolumeParams | func (sb *storageBackend) validateVolumeParams(params VolumeParams, machineId string) (maybeMachineId string, _ error) {
if err := validateStoragePool(sb, params.Pool, storage.StorageKindBlock, &machineId); err != nil {
return "", err
}
if params.Size == 0 {
return "", errors.New("invalid size 0")
}
return machineId, nil
} | go | func (sb *storageBackend) validateVolumeParams(params VolumeParams, machineId string) (maybeMachineId string, _ error) {
if err := validateStoragePool(sb, params.Pool, storage.StorageKindBlock, &machineId); err != nil {
return "", err
}
if params.Size == 0 {
return "", errors.New("invalid size 0")
}
return machineId, nil
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"validateVolumeParams",
"(",
"params",
"VolumeParams",
",",
"machineId",
"string",
")",
"(",
"maybeMachineId",
"string",
",",
"_",
"error",
")",
"{",
"if",
"err",
":=",
"validateStoragePool",
"(",
"sb",
",",
"pa... | // validateVolumeParams validates the volume parameters, and returns the
// machine ID to use as the scope in the volume tag. | [
"validateVolumeParams",
"validates",
"the",
"volume",
"parameters",
"and",
"returns",
"the",
"machine",
"ID",
"to",
"use",
"as",
"the",
"scope",
"in",
"the",
"volume",
"tag",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1092-L1100 |
3,420 | juju/juju | state/volume.go | ParseVolumeAttachmentId | func ParseVolumeAttachmentId(id string) (names.Tag, names.VolumeTag, error) {
fields := strings.SplitN(id, ":", 2)
isValidHost := names.IsValidMachine(fields[0]) || names.IsValidUnit(fields[0])
if len(fields) != 2 || !isValidHost || !names.IsValidVolume(fields[1]) {
return names.MachineTag{}, names.VolumeTag{}, errors.Errorf("invalid volume attachment ID %q", id)
}
var hostTag names.Tag
if names.IsValidMachine(fields[0]) {
hostTag = names.NewMachineTag(fields[0])
} else {
hostTag = names.NewUnitTag(fields[0])
}
volumeTag := names.NewVolumeTag(fields[1])
return hostTag, volumeTag, nil
} | go | func ParseVolumeAttachmentId(id string) (names.Tag, names.VolumeTag, error) {
fields := strings.SplitN(id, ":", 2)
isValidHost := names.IsValidMachine(fields[0]) || names.IsValidUnit(fields[0])
if len(fields) != 2 || !isValidHost || !names.IsValidVolume(fields[1]) {
return names.MachineTag{}, names.VolumeTag{}, errors.Errorf("invalid volume attachment ID %q", id)
}
var hostTag names.Tag
if names.IsValidMachine(fields[0]) {
hostTag = names.NewMachineTag(fields[0])
} else {
hostTag = names.NewUnitTag(fields[0])
}
volumeTag := names.NewVolumeTag(fields[1])
return hostTag, volumeTag, nil
} | [
"func",
"ParseVolumeAttachmentId",
"(",
"id",
"string",
")",
"(",
"names",
".",
"Tag",
",",
"names",
".",
"VolumeTag",
",",
"error",
")",
"{",
"fields",
":=",
"strings",
".",
"SplitN",
"(",
"id",
",",
"\"",
"\"",
",",
"2",
")",
"\n",
"isValidHost",
"... | // ParseVolumeAttachmentId parses a string as a volume attachment ID,
// returning the host and volume components. | [
"ParseVolumeAttachmentId",
"parses",
"a",
"string",
"as",
"a",
"volume",
"attachment",
"ID",
"returning",
"the",
"host",
"and",
"volume",
"components",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1110-L1124 |
3,421 | juju/juju | state/volume.go | createMachineVolumeAttachmentsOps | func createMachineVolumeAttachmentsOps(hostId string, attachments []volumeAttachmentTemplate) []txn.Op {
ops := make([]txn.Op, len(attachments))
for i, attachment := range attachments {
paramsCopy := attachment.params
ops[i] = txn.Op{
C: volumeAttachmentsC,
Id: volumeAttachmentId(hostId, attachment.tag.Id()),
Assert: txn.DocMissing,
Insert: &volumeAttachmentDoc{
Volume: attachment.tag.Id(),
Host: hostId,
Params: ¶msCopy,
},
}
if attachment.existing {
ops = append(ops, txn.Op{
C: volumesC,
Id: attachment.tag.Id(),
Assert: txn.DocExists,
Update: bson.D{{"$inc", bson.D{{"attachmentcount", 1}}}},
})
}
}
return ops
} | go | func createMachineVolumeAttachmentsOps(hostId string, attachments []volumeAttachmentTemplate) []txn.Op {
ops := make([]txn.Op, len(attachments))
for i, attachment := range attachments {
paramsCopy := attachment.params
ops[i] = txn.Op{
C: volumeAttachmentsC,
Id: volumeAttachmentId(hostId, attachment.tag.Id()),
Assert: txn.DocMissing,
Insert: &volumeAttachmentDoc{
Volume: attachment.tag.Id(),
Host: hostId,
Params: ¶msCopy,
},
}
if attachment.existing {
ops = append(ops, txn.Op{
C: volumesC,
Id: attachment.tag.Id(),
Assert: txn.DocExists,
Update: bson.D{{"$inc", bson.D{{"attachmentcount", 1}}}},
})
}
}
return ops
} | [
"func",
"createMachineVolumeAttachmentsOps",
"(",
"hostId",
"string",
",",
"attachments",
"[",
"]",
"volumeAttachmentTemplate",
")",
"[",
"]",
"txn",
".",
"Op",
"{",
"ops",
":=",
"make",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"len",
"(",
"attachments",
")",... | // createMachineVolumeAttachmentInfo creates volume attachments
// for the specified host, and attachment parameters keyed
// by volume tags. The caller is responsible for incrementing
// the volume's attachmentcount field. | [
"createMachineVolumeAttachmentInfo",
"creates",
"volume",
"attachments",
"for",
"the",
"specified",
"host",
"and",
"attachment",
"parameters",
"keyed",
"by",
"volume",
"tags",
".",
"The",
"caller",
"is",
"responsible",
"for",
"incrementing",
"the",
"volume",
"s",
"a... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1136-L1160 |
3,422 | juju/juju | state/volume.go | setMachineVolumeAttachmentInfo | func setMachineVolumeAttachmentInfo(sb *storageBackend, machineId string, attachments map[names.VolumeTag]VolumeAttachmentInfo) (err error) {
defer errors.DeferredAnnotatef(&err, "cannot set volume attachment info for machine %s", machineId)
machineTag := names.NewMachineTag(machineId)
for volumeTag, info := range attachments {
if err := sb.setVolumeAttachmentInfo(machineTag, volumeTag, info); err != nil {
return errors.Annotatef(err, "setting attachment info for volume %s", volumeTag.Id())
}
}
return nil
} | go | func setMachineVolumeAttachmentInfo(sb *storageBackend, machineId string, attachments map[names.VolumeTag]VolumeAttachmentInfo) (err error) {
defer errors.DeferredAnnotatef(&err, "cannot set volume attachment info for machine %s", machineId)
machineTag := names.NewMachineTag(machineId)
for volumeTag, info := range attachments {
if err := sb.setVolumeAttachmentInfo(machineTag, volumeTag, info); err != nil {
return errors.Annotatef(err, "setting attachment info for volume %s", volumeTag.Id())
}
}
return nil
} | [
"func",
"setMachineVolumeAttachmentInfo",
"(",
"sb",
"*",
"storageBackend",
",",
"machineId",
"string",
",",
"attachments",
"map",
"[",
"names",
".",
"VolumeTag",
"]",
"VolumeAttachmentInfo",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"errors",
".",
"DeferredA... | // setMachineVolumeAttachmentInfo sets the volume attachment
// info for the specified machine. Each volume attachment info
// structure is keyed by the name of the volume it corresponds
// to. | [
"setMachineVolumeAttachmentInfo",
"sets",
"the",
"volume",
"attachment",
"info",
"for",
"the",
"specified",
"machine",
".",
"Each",
"volume",
"attachment",
"info",
"structure",
"is",
"keyed",
"by",
"the",
"name",
"of",
"the",
"volume",
"it",
"corresponds",
"to",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1166-L1175 |
3,423 | juju/juju | state/volume.go | SetVolumeAttachmentInfo | func (sb *storageBackend) SetVolumeAttachmentInfo(hostTag names.Tag, volumeTag names.VolumeTag, info VolumeAttachmentInfo) (err error) {
defer errors.DeferredAnnotatef(&err, "cannot set info for volume attachment %s:%s", volumeTag.Id(), hostTag.Id())
v, err := sb.Volume(volumeTag)
if err != nil {
return errors.Trace(err)
}
// Ensure volume is provisioned before setting attachment info.
// A volume cannot go from being provisioned to unprovisioned,
// so there is no txn.Op for this below.
if _, err := v.Info(); err != nil {
return errors.Trace(err)
}
// Also ensure the machine is provisioned.
if _, ok := hostTag.(names.MachineTag); ok {
m, err := sb.machine(hostTag.Id())
if err != nil {
return errors.Trace(err)
}
if _, err := m.InstanceId(); err != nil {
return errors.Trace(err)
}
}
return sb.setVolumeAttachmentInfo(hostTag, volumeTag, info)
} | go | func (sb *storageBackend) SetVolumeAttachmentInfo(hostTag names.Tag, volumeTag names.VolumeTag, info VolumeAttachmentInfo) (err error) {
defer errors.DeferredAnnotatef(&err, "cannot set info for volume attachment %s:%s", volumeTag.Id(), hostTag.Id())
v, err := sb.Volume(volumeTag)
if err != nil {
return errors.Trace(err)
}
// Ensure volume is provisioned before setting attachment info.
// A volume cannot go from being provisioned to unprovisioned,
// so there is no txn.Op for this below.
if _, err := v.Info(); err != nil {
return errors.Trace(err)
}
// Also ensure the machine is provisioned.
if _, ok := hostTag.(names.MachineTag); ok {
m, err := sb.machine(hostTag.Id())
if err != nil {
return errors.Trace(err)
}
if _, err := m.InstanceId(); err != nil {
return errors.Trace(err)
}
}
return sb.setVolumeAttachmentInfo(hostTag, volumeTag, info)
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"SetVolumeAttachmentInfo",
"(",
"hostTag",
"names",
".",
"Tag",
",",
"volumeTag",
"names",
".",
"VolumeTag",
",",
"info",
"VolumeAttachmentInfo",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"errors",
".",
"Defe... | // SetVolumeAttachmentInfo sets the VolumeAttachmentInfo for the specified
// volume attachment. | [
"SetVolumeAttachmentInfo",
"sets",
"the",
"VolumeAttachmentInfo",
"for",
"the",
"specified",
"volume",
"attachment",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1179-L1202 |
3,424 | juju/juju | state/volume.go | RemoveVolumeAttachmentPlan | func (sb *storageBackend) RemoveVolumeAttachmentPlan(hostTag names.Tag, volume names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "removing attachment plan of volume %s from machine %s", volume.Id(), hostTag.Id())
buildTxn := func(attempt int) ([]txn.Op, error) {
plans, err := sb.machineVolumeAttachmentPlans(hostTag, volume)
if errors.IsNotFound(err) {
return nil, jujutxn.ErrNoOperations
}
if err != nil {
return nil, errors.Trace(err)
}
// We should only have one plan for a volume
if plans != nil && len(plans) > 0 {
if plans[0].Life() != Dying {
return nil, jujutxn.ErrNoOperations
}
} else {
return nil, jujutxn.ErrNoOperations
}
return removeVolumeAttachmentPlanOps(hostTag, volume), nil
}
return sb.mb.db().Run(buildTxn)
} | go | func (sb *storageBackend) RemoveVolumeAttachmentPlan(hostTag names.Tag, volume names.VolumeTag) (err error) {
defer errors.DeferredAnnotatef(&err, "removing attachment plan of volume %s from machine %s", volume.Id(), hostTag.Id())
buildTxn := func(attempt int) ([]txn.Op, error) {
plans, err := sb.machineVolumeAttachmentPlans(hostTag, volume)
if errors.IsNotFound(err) {
return nil, jujutxn.ErrNoOperations
}
if err != nil {
return nil, errors.Trace(err)
}
// We should only have one plan for a volume
if plans != nil && len(plans) > 0 {
if plans[0].Life() != Dying {
return nil, jujutxn.ErrNoOperations
}
} else {
return nil, jujutxn.ErrNoOperations
}
return removeVolumeAttachmentPlanOps(hostTag, volume), nil
}
return sb.mb.db().Run(buildTxn)
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"RemoveVolumeAttachmentPlan",
"(",
"hostTag",
"names",
".",
"Tag",
",",
"volume",
"names",
".",
"VolumeTag",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"errors",
".",
"DeferredAnnotatef",
"(",
"&",
"err",
",... | // RemoveVolumeAttachmentPlan removes the volume attachment plan from state. | [
"RemoveVolumeAttachmentPlan",
"removes",
"the",
"volume",
"attachment",
"plan",
"from",
"state",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1361-L1382 |
3,425 | juju/juju | state/volume.go | removeVolumeAttachmentPlanOps | func removeVolumeAttachmentPlanOps(hostTag names.Tag, volume names.VolumeTag) []txn.Op {
detachOps := detachVolumeOps(hostTag, volume)
removeOps := []txn.Op{{
C: volumeAttachmentPlanC,
Id: volumeAttachmentId(hostTag.Id(), volume.Id()),
Assert: bson.D{{"life", Dying}},
Remove: true,
}}
removeOps = append(removeOps, detachOps...)
return removeOps
} | go | func removeVolumeAttachmentPlanOps(hostTag names.Tag, volume names.VolumeTag) []txn.Op {
detachOps := detachVolumeOps(hostTag, volume)
removeOps := []txn.Op{{
C: volumeAttachmentPlanC,
Id: volumeAttachmentId(hostTag.Id(), volume.Id()),
Assert: bson.D{{"life", Dying}},
Remove: true,
}}
removeOps = append(removeOps, detachOps...)
return removeOps
} | [
"func",
"removeVolumeAttachmentPlanOps",
"(",
"hostTag",
"names",
".",
"Tag",
",",
"volume",
"names",
".",
"VolumeTag",
")",
"[",
"]",
"txn",
".",
"Op",
"{",
"detachOps",
":=",
"detachVolumeOps",
"(",
"hostTag",
",",
"volume",
")",
"\n",
"removeOps",
":=",
... | // removeVolumeAttachmentPlanOps removes the plan from state and sets the volume attachment to Dying.
// this will trigger the storageprovisioner on the controller to eventually detach the volume from
// the machine. | [
"removeVolumeAttachmentPlanOps",
"removes",
"the",
"plan",
"from",
"state",
"and",
"sets",
"the",
"volume",
"attachment",
"to",
"Dying",
".",
"this",
"will",
"trigger",
"the",
"storageprovisioner",
"on",
"the",
"controller",
"to",
"eventually",
"detach",
"the",
"v... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1387-L1397 |
3,426 | juju/juju | state/volume.go | setProvisionedVolumeInfo | func setProvisionedVolumeInfo(sb *storageBackend, volumes map[names.VolumeTag]VolumeInfo) error {
for volumeTag, info := range volumes {
if err := sb.SetVolumeInfo(volumeTag, info); err != nil {
return errors.Trace(err)
}
}
return nil
} | go | func setProvisionedVolumeInfo(sb *storageBackend, volumes map[names.VolumeTag]VolumeInfo) error {
for volumeTag, info := range volumes {
if err := sb.SetVolumeInfo(volumeTag, info); err != nil {
return errors.Trace(err)
}
}
return nil
} | [
"func",
"setProvisionedVolumeInfo",
"(",
"sb",
"*",
"storageBackend",
",",
"volumes",
"map",
"[",
"names",
".",
"VolumeTag",
"]",
"VolumeInfo",
")",
"error",
"{",
"for",
"volumeTag",
",",
"info",
":=",
"range",
"volumes",
"{",
"if",
"err",
":=",
"sb",
".",... | // setProvisionedVolumeInfo sets the initial info for newly
// provisioned volumes. If non-empty, machineId must be the
// machine ID associated with the volumes. | [
"setProvisionedVolumeInfo",
"sets",
"the",
"initial",
"info",
"for",
"newly",
"provisioned",
"volumes",
".",
"If",
"non",
"-",
"empty",
"machineId",
"must",
"be",
"the",
"machine",
"ID",
"associated",
"with",
"the",
"volumes",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1402-L1409 |
3,427 | juju/juju | state/volume.go | SetVolumeInfo | func (sb *storageBackend) SetVolumeInfo(tag names.VolumeTag, info VolumeInfo) (err error) {
defer errors.DeferredAnnotatef(&err, "cannot set info for volume %q", tag.Id())
if info.VolumeId == "" {
return errors.New("volume ID not set")
}
// TODO(axw) we should reject info without VolumeId set; can't do this
// until the providers all set it correctly.
buildTxn := func(attempt int) ([]txn.Op, error) {
v, err := sb.Volume(tag)
if err != nil {
return nil, errors.Trace(err)
}
// If the volume has parameters, unset them when
// we set info for the first time, ensuring that
// params and info are mutually exclusive.
var unsetParams bool
var ops []txn.Op
if params, ok := v.Params(); ok {
info.Pool = params.Pool
unsetParams = true
} else {
// Ensure immutable properties do not change.
oldInfo, err := v.Info()
if err != nil {
return nil, err
}
if err := validateVolumeInfoChange(info, oldInfo); err != nil {
return nil, err
}
}
ops = append(ops, setVolumeInfoOps(tag, info, unsetParams)...)
return ops, nil
}
return sb.mb.db().Run(buildTxn)
} | go | func (sb *storageBackend) SetVolumeInfo(tag names.VolumeTag, info VolumeInfo) (err error) {
defer errors.DeferredAnnotatef(&err, "cannot set info for volume %q", tag.Id())
if info.VolumeId == "" {
return errors.New("volume ID not set")
}
// TODO(axw) we should reject info without VolumeId set; can't do this
// until the providers all set it correctly.
buildTxn := func(attempt int) ([]txn.Op, error) {
v, err := sb.Volume(tag)
if err != nil {
return nil, errors.Trace(err)
}
// If the volume has parameters, unset them when
// we set info for the first time, ensuring that
// params and info are mutually exclusive.
var unsetParams bool
var ops []txn.Op
if params, ok := v.Params(); ok {
info.Pool = params.Pool
unsetParams = true
} else {
// Ensure immutable properties do not change.
oldInfo, err := v.Info()
if err != nil {
return nil, err
}
if err := validateVolumeInfoChange(info, oldInfo); err != nil {
return nil, err
}
}
ops = append(ops, setVolumeInfoOps(tag, info, unsetParams)...)
return ops, nil
}
return sb.mb.db().Run(buildTxn)
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"SetVolumeInfo",
"(",
"tag",
"names",
".",
"VolumeTag",
",",
"info",
"VolumeInfo",
")",
"(",
"err",
"error",
")",
"{",
"defer",
"errors",
".",
"DeferredAnnotatef",
"(",
"&",
"err",
",",
"\"",
"\"",
",",
"t... | // SetVolumeInfo sets the VolumeInfo for the specified volume. | [
"SetVolumeInfo",
"sets",
"the",
"VolumeInfo",
"for",
"the",
"specified",
"volume",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1412-L1446 |
3,428 | juju/juju | state/volume.go | AllVolumes | func (sb *storageBackend) AllVolumes() ([]Volume, error) {
volumes, err := sb.volumes(nil)
if err != nil {
return nil, errors.Annotate(err, "cannot get volumes")
}
return volumesToInterfaces(volumes), nil
} | go | func (sb *storageBackend) AllVolumes() ([]Volume, error) {
volumes, err := sb.volumes(nil)
if err != nil {
return nil, errors.Annotate(err, "cannot get volumes")
}
return volumesToInterfaces(volumes), nil
} | [
"func",
"(",
"sb",
"*",
"storageBackend",
")",
"AllVolumes",
"(",
")",
"(",
"[",
"]",
"Volume",
",",
"error",
")",
"{",
"volumes",
",",
"err",
":=",
"sb",
".",
"volumes",
"(",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",... | // AllVolumes returns all Volumes scoped to the model. | [
"AllVolumes",
"returns",
"all",
"Volumes",
"scoped",
"to",
"the",
"model",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/volume.go#L1483-L1489 |
3,429 | juju/juju | worker/instancepoller/updater.go | watchMachinesLoop | func watchMachinesLoop(context updaterContext, machinesWatcher watcher.StringsWatcher) (err error) {
p := &updater{
context: context,
machines: make(map[names.MachineTag]chan struct{}),
machineDead: make(chan machine),
}
defer func() {
// TODO(fwereade): is this a home-grown sync.WaitGroup or something?
// strongly suspect these machine goroutines could be managed rather
// less opaquely if we made them all workers.
for len(p.machines) > 0 {
delete(p.machines, (<-p.machineDead).Tag())
}
}()
for {
select {
case <-p.context.dying():
return p.context.errDying()
case ids, ok := <-machinesWatcher.Changes():
if !ok {
return errors.New("machines watcher closed")
}
tags := make([]names.MachineTag, len(ids))
for i := range ids {
tags[i] = names.NewMachineTag(ids[i])
}
if err := p.startMachines(tags); err != nil {
return err
}
case m := <-p.machineDead:
delete(p.machines, m.Tag())
}
}
} | go | func watchMachinesLoop(context updaterContext, machinesWatcher watcher.StringsWatcher) (err error) {
p := &updater{
context: context,
machines: make(map[names.MachineTag]chan struct{}),
machineDead: make(chan machine),
}
defer func() {
// TODO(fwereade): is this a home-grown sync.WaitGroup or something?
// strongly suspect these machine goroutines could be managed rather
// less opaquely if we made them all workers.
for len(p.machines) > 0 {
delete(p.machines, (<-p.machineDead).Tag())
}
}()
for {
select {
case <-p.context.dying():
return p.context.errDying()
case ids, ok := <-machinesWatcher.Changes():
if !ok {
return errors.New("machines watcher closed")
}
tags := make([]names.MachineTag, len(ids))
for i := range ids {
tags[i] = names.NewMachineTag(ids[i])
}
if err := p.startMachines(tags); err != nil {
return err
}
case m := <-p.machineDead:
delete(p.machines, m.Tag())
}
}
} | [
"func",
"watchMachinesLoop",
"(",
"context",
"updaterContext",
",",
"machinesWatcher",
"watcher",
".",
"StringsWatcher",
")",
"(",
"err",
"error",
")",
"{",
"p",
":=",
"&",
"updater",
"{",
"context",
":",
"context",
",",
"machines",
":",
"make",
"(",
"map",
... | // watchMachinesLoop watches for changes provided by the given
// machinesWatcher and starts machine goroutines to deal with them,
// using the provided newMachineContext function to create the
// appropriate context for each new machine tag. | [
"watchMachinesLoop",
"watches",
"for",
"changes",
"provided",
"by",
"the",
"given",
"machinesWatcher",
"and",
"starts",
"machine",
"goroutines",
"to",
"deal",
"with",
"them",
"using",
"the",
"provided",
"newMachineContext",
"function",
"to",
"create",
"the",
"approp... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/instancepoller/updater.go#L86-L119 |
3,430 | juju/juju | worker/instancepoller/updater.go | runMachine | func runMachine(context machineContext, m machine, changed <-chan struct{}, died chan<- machine, clock clock.Clock) {
defer func() {
// We can't just send on the died channel because the
// central loop might be trying to write to us on the
// changed channel.
for {
select {
case died <- m:
return
case <-changed:
}
}
}()
if err := machineLoop(context, m, changed, clock); err != nil {
context.kill(err)
}
} | go | func runMachine(context machineContext, m machine, changed <-chan struct{}, died chan<- machine, clock clock.Clock) {
defer func() {
// We can't just send on the died channel because the
// central loop might be trying to write to us on the
// changed channel.
for {
select {
case died <- m:
return
case <-changed:
}
}
}()
if err := machineLoop(context, m, changed, clock); err != nil {
context.kill(err)
}
} | [
"func",
"runMachine",
"(",
"context",
"machineContext",
",",
"m",
"machine",
",",
"changed",
"<-",
"chan",
"struct",
"{",
"}",
",",
"died",
"chan",
"<-",
"machine",
",",
"clock",
"clock",
".",
"Clock",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"// We c... | // runMachine processes the address and status publishing for a given machine.
// We assume that the machine is alive when this is first called. | [
"runMachine",
"processes",
"the",
"address",
"and",
"status",
"publishing",
"for",
"a",
"given",
"machine",
".",
"We",
"assume",
"that",
"the",
"machine",
"is",
"alive",
"when",
"this",
"is",
"first",
"called",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/instancepoller/updater.go#L166-L182 |
3,431 | juju/juju | worker/instancepoller/updater.go | pollInstanceInfo | func pollInstanceInfo(context machineContext, m machine) (instInfo instanceInfo, err error) {
instInfo = instanceInfo{}
instId, err := m.InstanceId()
// We can't ask the machine for its addresses if it isn't provisioned yet.
if params.IsCodeNotProvisioned(err) {
return instanceInfo{}, err
}
if err != nil {
return instanceInfo{}, errors.Annotate(err, "cannot get machine's instance id")
}
instInfo, err = context.instanceInfo(instId)
if err != nil {
// TODO (anastasiamac 2016-02-01) This does not look like it needs to be removed now.
if params.IsCodeNotImplemented(err) {
return instanceInfo{}, err
}
logger.Warningf("cannot get instance info for instance %q: %v", instId, err)
return instInfo, nil
}
if instStat, err := m.InstanceStatus(); err != nil {
// This should never occur since the machine is provisioned.
// But just in case, we reset polled status so we try again next time.
logger.Warningf("cannot get current instance status for machine %v: %v", m.Id(), err)
instInfo.status = instance.Status{status.Unknown, ""}
} else {
// TODO(perrito666) add status validation.
currentInstStatus := instance.Status{
Status: status.Status(instStat.Status),
Message: instStat.Info,
}
if instInfo.status != currentInstStatus {
logger.Infof("machine %q instance status changed from %q to %q", m.Id(), currentInstStatus, instInfo.status)
if err = m.SetInstanceStatus(instInfo.status.Status, instInfo.status.Message, nil); err != nil {
logger.Errorf("cannot set instance status on %q: %v", m, err)
return instanceInfo{}, err
}
}
}
if m.Life() != params.Dead {
providerAddresses, err := m.ProviderAddresses()
if err != nil {
return instanceInfo{}, err
}
if !addressesEqual(providerAddresses, instInfo.addresses) {
logger.Infof("machine %q has new addresses: %v", m.Id(), instInfo.addresses)
if err := m.SetProviderAddresses(instInfo.addresses...); err != nil {
logger.Errorf("cannot set addresses on %q: %v", m, err)
return instanceInfo{}, err
}
}
}
return instInfo, nil
} | go | func pollInstanceInfo(context machineContext, m machine) (instInfo instanceInfo, err error) {
instInfo = instanceInfo{}
instId, err := m.InstanceId()
// We can't ask the machine for its addresses if it isn't provisioned yet.
if params.IsCodeNotProvisioned(err) {
return instanceInfo{}, err
}
if err != nil {
return instanceInfo{}, errors.Annotate(err, "cannot get machine's instance id")
}
instInfo, err = context.instanceInfo(instId)
if err != nil {
// TODO (anastasiamac 2016-02-01) This does not look like it needs to be removed now.
if params.IsCodeNotImplemented(err) {
return instanceInfo{}, err
}
logger.Warningf("cannot get instance info for instance %q: %v", instId, err)
return instInfo, nil
}
if instStat, err := m.InstanceStatus(); err != nil {
// This should never occur since the machine is provisioned.
// But just in case, we reset polled status so we try again next time.
logger.Warningf("cannot get current instance status for machine %v: %v", m.Id(), err)
instInfo.status = instance.Status{status.Unknown, ""}
} else {
// TODO(perrito666) add status validation.
currentInstStatus := instance.Status{
Status: status.Status(instStat.Status),
Message: instStat.Info,
}
if instInfo.status != currentInstStatus {
logger.Infof("machine %q instance status changed from %q to %q", m.Id(), currentInstStatus, instInfo.status)
if err = m.SetInstanceStatus(instInfo.status.Status, instInfo.status.Message, nil); err != nil {
logger.Errorf("cannot set instance status on %q: %v", m, err)
return instanceInfo{}, err
}
}
}
if m.Life() != params.Dead {
providerAddresses, err := m.ProviderAddresses()
if err != nil {
return instanceInfo{}, err
}
if !addressesEqual(providerAddresses, instInfo.addresses) {
logger.Infof("machine %q has new addresses: %v", m.Id(), instInfo.addresses)
if err := m.SetProviderAddresses(instInfo.addresses...); err != nil {
logger.Errorf("cannot set addresses on %q: %v", m, err)
return instanceInfo{}, err
}
}
}
return instInfo, nil
} | [
"func",
"pollInstanceInfo",
"(",
"context",
"machineContext",
",",
"m",
"machine",
")",
"(",
"instInfo",
"instanceInfo",
",",
"err",
"error",
")",
"{",
"instInfo",
"=",
"instanceInfo",
"{",
"}",
"\n",
"instId",
",",
"err",
":=",
"m",
".",
"InstanceId",
"("... | // pollInstanceInfo checks the current provider addresses and status
// for the given machine's instance, and sets them on the machine if they've changed. | [
"pollInstanceInfo",
"checks",
"the",
"current",
"provider",
"addresses",
"and",
"status",
"for",
"the",
"given",
"machine",
"s",
"instance",
"and",
"sets",
"them",
"on",
"the",
"machine",
"if",
"they",
"ve",
"changed",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/instancepoller/updater.go#L251-L304 |
3,432 | juju/juju | worker/instancepoller/updater.go | addressesEqual | func addressesEqual(a0, a1 []network.Address) bool {
if len(a0) != len(a1) {
logger.Tracef("address lists have different lengths %d != %d for %v != %v",
len(a0), len(a1), a0, a1)
return false
}
ca0 := make([]network.Address, len(a0))
copy(ca0, a0)
network.SortAddresses(ca0)
ca1 := make([]network.Address, len(a1))
copy(ca1, a1)
network.SortAddresses(ca1)
for i := range ca0 {
if ca0[i] != ca1[i] {
logger.Tracef("address entry at offset %d has a different value for %v != %v",
i, ca0, ca1)
return false
}
}
return true
} | go | func addressesEqual(a0, a1 []network.Address) bool {
if len(a0) != len(a1) {
logger.Tracef("address lists have different lengths %d != %d for %v != %v",
len(a0), len(a1), a0, a1)
return false
}
ca0 := make([]network.Address, len(a0))
copy(ca0, a0)
network.SortAddresses(ca0)
ca1 := make([]network.Address, len(a1))
copy(ca1, a1)
network.SortAddresses(ca1)
for i := range ca0 {
if ca0[i] != ca1[i] {
logger.Tracef("address entry at offset %d has a different value for %v != %v",
i, ca0, ca1)
return false
}
}
return true
} | [
"func",
"addressesEqual",
"(",
"a0",
",",
"a1",
"[",
"]",
"network",
".",
"Address",
")",
"bool",
"{",
"if",
"len",
"(",
"a0",
")",
"!=",
"len",
"(",
"a1",
")",
"{",
"logger",
".",
"Tracef",
"(",
"\"",
"\"",
",",
"len",
"(",
"a0",
")",
",",
"... | // addressesEqual compares the addresses of the machine and the instance information. | [
"addressesEqual",
"compares",
"the",
"addresses",
"of",
"the",
"machine",
"and",
"the",
"instance",
"information",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/instancepoller/updater.go#L307-L329 |
3,433 | juju/juju | state/collection.go | Count | func (c *modelStateCollection) Count() (int, error) {
return c.WriteCollection.Find(bson.D{{"model-uuid", c.modelUUID}}).Count()
} | go | func (c *modelStateCollection) Count() (int, error) {
return c.WriteCollection.Find(bson.D{{"model-uuid", c.modelUUID}}).Count()
} | [
"func",
"(",
"c",
"*",
"modelStateCollection",
")",
"Count",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"c",
".",
"WriteCollection",
".",
"Find",
"(",
"bson",
".",
"D",
"{",
"{",
"\"",
"\"",
",",
"c",
".",
"modelUUID",
"}",
"}",
")",... | // Count returns the number of documents in the collection that belong
// to the model that the modelStateCollection is filtering on. | [
"Count",
"returns",
"the",
"number",
"of",
"documents",
"in",
"the",
"collection",
"that",
"belong",
"to",
"the",
"model",
"that",
"the",
"modelStateCollection",
"is",
"filtering",
"on",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/collection.go#L33-L35 |
3,434 | juju/juju | state/collection.go | Insert | func (c *modelStateCollection) Insert(docs ...interface{}) error {
var mungedDocs []interface{}
for _, doc := range docs {
mungedDoc, err := mungeDocForMultiModel(doc, c.modelUUID, modelUUIDRequired)
if err != nil {
return errors.Trace(err)
}
mungedDocs = append(mungedDocs, mungedDoc)
}
return c.WriteCollection.Insert(mungedDocs...)
} | go | func (c *modelStateCollection) Insert(docs ...interface{}) error {
var mungedDocs []interface{}
for _, doc := range docs {
mungedDoc, err := mungeDocForMultiModel(doc, c.modelUUID, modelUUIDRequired)
if err != nil {
return errors.Trace(err)
}
mungedDocs = append(mungedDocs, mungedDoc)
}
return c.WriteCollection.Insert(mungedDocs...)
} | [
"func",
"(",
"c",
"*",
"modelStateCollection",
")",
"Insert",
"(",
"docs",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"mungedDocs",
"[",
"]",
"interface",
"{",
"}",
"\n",
"for",
"_",
",",
"doc",
":=",
"range",
"docs",
"{",
"mungedDoc",
"... | // Insert adds one or more documents to a collection. If the document
// id is a string the model UUID prefix will be automatically
// added to it. The model-uuid field will also be automatically added if
// it is missing. An error will be returned if an model-uuid field is
// provided but is the wrong value. | [
"Insert",
"adds",
"one",
"or",
"more",
"documents",
"to",
"a",
"collection",
".",
"If",
"the",
"document",
"id",
"is",
"a",
"string",
"the",
"model",
"UUID",
"prefix",
"will",
"be",
"automatically",
"added",
"to",
"it",
".",
"The",
"model",
"-",
"uuid",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/collection.go#L68-L78 |
3,435 | juju/juju | state/collection.go | UpdateId | func (c *modelStateCollection) UpdateId(id interface{}, update interface{}) error {
if sid, ok := id.(string); ok {
return c.WriteCollection.UpdateId(ensureModelUUID(c.modelUUID, sid), update)
}
return c.WriteCollection.UpdateId(bson.D{{"_id", id}}, update)
} | go | func (c *modelStateCollection) UpdateId(id interface{}, update interface{}) error {
if sid, ok := id.(string); ok {
return c.WriteCollection.UpdateId(ensureModelUUID(c.modelUUID, sid), update)
}
return c.WriteCollection.UpdateId(bson.D{{"_id", id}}, update)
} | [
"func",
"(",
"c",
"*",
"modelStateCollection",
")",
"UpdateId",
"(",
"id",
"interface",
"{",
"}",
",",
"update",
"interface",
"{",
"}",
")",
"error",
"{",
"if",
"sid",
",",
"ok",
":=",
"id",
".",
"(",
"string",
")",
";",
"ok",
"{",
"return",
"c",
... | // UpdateId finds a single document by _id and modifies it according to the
// update document. The id must be a string or bson.ObjectId. The model
// UUID will be automatically prefixed on to the id if it's a string and the
// prefix isn't there already. | [
"UpdateId",
"finds",
"a",
"single",
"document",
"by",
"_id",
"and",
"modifies",
"it",
"according",
"to",
"the",
"update",
"document",
".",
"The",
"id",
"must",
"be",
"a",
"string",
"or",
"bson",
".",
"ObjectId",
".",
"The",
"model",
"UUID",
"will",
"be",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/collection.go#L100-L105 |
3,436 | juju/juju | apiserver/facades/client/action/run.go | getAllUnitNames | func getAllUnitNames(st *state.State, units, services []string) (result []names.Tag, err error) {
var leaders map[string]string
getLeader := func(appName string) (string, error) {
if leaders == nil {
var err error
leaders, err = st.ApplicationLeaders()
if err != nil {
return "", err
}
}
if leader, ok := leaders[appName]; ok {
return leader, nil
}
return "", errors.Errorf("could not determine leader for %q", appName)
}
// Replace units matching $app/leader with the appropriate unit for
// the leader.
unitsSet := set.NewStrings()
for _, unit := range units {
if !strings.HasSuffix(unit, "leader") {
unitsSet.Add(unit)
continue
}
app := strings.Split(unit, "/")[0]
leaderUnit, err := getLeader(app)
if err != nil {
return nil, common.ServerError(err)
}
unitsSet.Add(leaderUnit)
}
for _, name := range services {
service, err := st.Application(name)
if err != nil {
return nil, err
}
units, err := service.AllUnits()
if err != nil {
return nil, err
}
for _, unit := range units {
unitsSet.Add(unit.Name())
}
}
for _, unitName := range unitsSet.SortedValues() {
if !names.IsValidUnit(unitName) {
return nil, errors.Errorf("invalid unit name %q", unitName)
}
result = append(result, names.NewUnitTag(unitName))
}
return result, nil
} | go | func getAllUnitNames(st *state.State, units, services []string) (result []names.Tag, err error) {
var leaders map[string]string
getLeader := func(appName string) (string, error) {
if leaders == nil {
var err error
leaders, err = st.ApplicationLeaders()
if err != nil {
return "", err
}
}
if leader, ok := leaders[appName]; ok {
return leader, nil
}
return "", errors.Errorf("could not determine leader for %q", appName)
}
// Replace units matching $app/leader with the appropriate unit for
// the leader.
unitsSet := set.NewStrings()
for _, unit := range units {
if !strings.HasSuffix(unit, "leader") {
unitsSet.Add(unit)
continue
}
app := strings.Split(unit, "/")[0]
leaderUnit, err := getLeader(app)
if err != nil {
return nil, common.ServerError(err)
}
unitsSet.Add(leaderUnit)
}
for _, name := range services {
service, err := st.Application(name)
if err != nil {
return nil, err
}
units, err := service.AllUnits()
if err != nil {
return nil, err
}
for _, unit := range units {
unitsSet.Add(unit.Name())
}
}
for _, unitName := range unitsSet.SortedValues() {
if !names.IsValidUnit(unitName) {
return nil, errors.Errorf("invalid unit name %q", unitName)
}
result = append(result, names.NewUnitTag(unitName))
}
return result, nil
} | [
"func",
"getAllUnitNames",
"(",
"st",
"*",
"state",
".",
"State",
",",
"units",
",",
"services",
"[",
"]",
"string",
")",
"(",
"result",
"[",
"]",
"names",
".",
"Tag",
",",
"err",
"error",
")",
"{",
"var",
"leaders",
"map",
"[",
"string",
"]",
"str... | // getAllUnitNames returns a sequence of valid Unit objects from state. If any
// of the application names or unit names are not found, an error is returned. | [
"getAllUnitNames",
"returns",
"a",
"sequence",
"of",
"valid",
"Unit",
"objects",
"from",
"state",
".",
"If",
"any",
"of",
"the",
"application",
"names",
"or",
"unit",
"names",
"are",
"not",
"found",
"an",
"error",
"is",
"returned",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/action/run.go#L22-L76 |
3,437 | juju/juju | apiserver/facades/client/action/run.go | Run | func (a *ActionAPI) Run(run params.RunParams) (results params.ActionResults, err error) {
if err := a.checkCanAdmin(); err != nil {
return results, err
}
if err := a.check.ChangeAllowed(); err != nil {
return results, errors.Trace(err)
}
units, err := getAllUnitNames(a.state, run.Units, run.Applications)
if err != nil {
return results, errors.Trace(err)
}
machines := make([]names.Tag, len(run.Machines))
for i, machineId := range run.Machines {
if !names.IsValidMachine(machineId) {
return results, errors.Errorf("invalid machine id %q", machineId)
}
machines[i] = names.NewMachineTag(machineId)
}
actionParams := a.createActionsParams(append(units, machines...), run.Commands, run.Timeout)
return queueActions(a, actionParams)
} | go | func (a *ActionAPI) Run(run params.RunParams) (results params.ActionResults, err error) {
if err := a.checkCanAdmin(); err != nil {
return results, err
}
if err := a.check.ChangeAllowed(); err != nil {
return results, errors.Trace(err)
}
units, err := getAllUnitNames(a.state, run.Units, run.Applications)
if err != nil {
return results, errors.Trace(err)
}
machines := make([]names.Tag, len(run.Machines))
for i, machineId := range run.Machines {
if !names.IsValidMachine(machineId) {
return results, errors.Errorf("invalid machine id %q", machineId)
}
machines[i] = names.NewMachineTag(machineId)
}
actionParams := a.createActionsParams(append(units, machines...), run.Commands, run.Timeout)
return queueActions(a, actionParams)
} | [
"func",
"(",
"a",
"*",
"ActionAPI",
")",
"Run",
"(",
"run",
"params",
".",
"RunParams",
")",
"(",
"results",
"params",
".",
"ActionResults",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"a",
".",
"checkCanAdmin",
"(",
")",
";",
"err",
"!=",
"n... | // Run the commands specified on the machines identified through the
// list of machines, units and services. | [
"Run",
"the",
"commands",
"specified",
"on",
"the",
"machines",
"identified",
"through",
"the",
"list",
"of",
"machines",
"units",
"and",
"services",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/action/run.go#L80-L105 |
3,438 | juju/juju | apiserver/facades/client/action/run.go | RunOnAllMachines | func (a *ActionAPI) RunOnAllMachines(run params.RunParams) (results params.ActionResults, err error) {
if err := a.checkCanAdmin(); err != nil {
return results, err
}
if err := a.check.ChangeAllowed(); err != nil {
return results, errors.Trace(err)
}
machines, err := a.state.AllMachines()
if err != nil {
return results, err
}
machineTags := make([]names.Tag, len(machines))
for i, machine := range machines {
machineTags[i] = machine.Tag()
}
actionParams := a.createActionsParams(machineTags, run.Commands, run.Timeout)
return queueActions(a, actionParams)
} | go | func (a *ActionAPI) RunOnAllMachines(run params.RunParams) (results params.ActionResults, err error) {
if err := a.checkCanAdmin(); err != nil {
return results, err
}
if err := a.check.ChangeAllowed(); err != nil {
return results, errors.Trace(err)
}
machines, err := a.state.AllMachines()
if err != nil {
return results, err
}
machineTags := make([]names.Tag, len(machines))
for i, machine := range machines {
machineTags[i] = machine.Tag()
}
actionParams := a.createActionsParams(machineTags, run.Commands, run.Timeout)
return queueActions(a, actionParams)
} | [
"func",
"(",
"a",
"*",
"ActionAPI",
")",
"RunOnAllMachines",
"(",
"run",
"params",
".",
"RunParams",
")",
"(",
"results",
"params",
".",
"ActionResults",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"a",
".",
"checkCanAdmin",
"(",
")",
";",
"err",... | // RunOnAllMachines attempts to run the specified command on all the machines. | [
"RunOnAllMachines",
"attempts",
"to",
"run",
"the",
"specified",
"command",
"on",
"all",
"the",
"machines",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/action/run.go#L108-L129 |
3,439 | juju/juju | worker/migrationflag/manifold.go | bounceErrChanged | func bounceErrChanged(err error) error {
if errors.Cause(err) == ErrChanged {
return dependency.ErrBounce
}
return err
} | go | func bounceErrChanged(err error) error {
if errors.Cause(err) == ErrChanged {
return dependency.ErrBounce
}
return err
} | [
"func",
"bounceErrChanged",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"errors",
".",
"Cause",
"(",
"err",
")",
"==",
"ErrChanged",
"{",
"return",
"dependency",
".",
"ErrBounce",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] | // bounceErrChanged converts ErrChanged to dependency.ErrBounce. | [
"bounceErrChanged",
"converts",
"ErrChanged",
"to",
"dependency",
".",
"ErrBounce",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/migrationflag/manifold.go#L81-L86 |
3,440 | juju/juju | upgrades/steps_237.go | stateStepsFor237 | func stateStepsFor237() []Step {
return []Step{
&upgradeStep{
description: "ensure container-image-stream isn't set in applications",
targets: []Target{DatabaseMaster},
run: func(context Context) error {
return context.State().RemoveContainerImageStreamFromNonModelSettings()
},
},
}
} | go | func stateStepsFor237() []Step {
return []Step{
&upgradeStep{
description: "ensure container-image-stream isn't set in applications",
targets: []Target{DatabaseMaster},
run: func(context Context) error {
return context.State().RemoveContainerImageStreamFromNonModelSettings()
},
},
}
} | [
"func",
"stateStepsFor237",
"(",
")",
"[",
"]",
"Step",
"{",
"return",
"[",
"]",
"Step",
"{",
"&",
"upgradeStep",
"{",
"description",
":",
"\"",
"\"",
",",
"targets",
":",
"[",
"]",
"Target",
"{",
"DatabaseMaster",
"}",
",",
"run",
":",
"func",
"(",
... | // stateStepsFor237 returns upgrade steps for Juju 2.3.7 that manipulate state directly. | [
"stateStepsFor237",
"returns",
"upgrade",
"steps",
"for",
"Juju",
"2",
".",
"3",
".",
"7",
"that",
"manipulate",
"state",
"directly",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/upgrades/steps_237.go#L7-L17 |
3,441 | juju/juju | cmd/jujud/main.go | hookToolMain | func hookToolMain(commandName string, ctx *cmd.Context, args []string) (code int, err error) {
code = 1
contextId, err := getenv("JUJU_CONTEXT_ID")
if err != nil {
return
}
dir, err := getwd()
if err != nil {
return
}
req := jujuc.Request{
ContextId: contextId,
Dir: dir,
CommandName: commandName,
Args: args[1:],
}
socketPath, err := getenv("JUJU_AGENT_SOCKET")
if err != nil {
return
}
client, err := sockets.Dial(socketPath)
if err != nil {
return
}
defer client.Close()
var resp exec.ExecResponse
err = client.Call("Jujuc.Main", req, &resp)
if err != nil && err.Error() == jujuc.ErrNoStdin.Error() {
req.Stdin, err = ioutil.ReadAll(os.Stdin)
if err != nil {
err = errors.Annotate(err, "cannot read stdin")
return
}
req.StdinSet = true
err = client.Call("Jujuc.Main", req, &resp)
}
if err != nil {
return
}
os.Stdout.Write(resp.Stdout)
os.Stderr.Write(resp.Stderr)
return resp.Code, nil
} | go | func hookToolMain(commandName string, ctx *cmd.Context, args []string) (code int, err error) {
code = 1
contextId, err := getenv("JUJU_CONTEXT_ID")
if err != nil {
return
}
dir, err := getwd()
if err != nil {
return
}
req := jujuc.Request{
ContextId: contextId,
Dir: dir,
CommandName: commandName,
Args: args[1:],
}
socketPath, err := getenv("JUJU_AGENT_SOCKET")
if err != nil {
return
}
client, err := sockets.Dial(socketPath)
if err != nil {
return
}
defer client.Close()
var resp exec.ExecResponse
err = client.Call("Jujuc.Main", req, &resp)
if err != nil && err.Error() == jujuc.ErrNoStdin.Error() {
req.Stdin, err = ioutil.ReadAll(os.Stdin)
if err != nil {
err = errors.Annotate(err, "cannot read stdin")
return
}
req.StdinSet = true
err = client.Call("Jujuc.Main", req, &resp)
}
if err != nil {
return
}
os.Stdout.Write(resp.Stdout)
os.Stderr.Write(resp.Stderr)
return resp.Code, nil
} | [
"func",
"hookToolMain",
"(",
"commandName",
"string",
",",
"ctx",
"*",
"cmd",
".",
"Context",
",",
"args",
"[",
"]",
"string",
")",
"(",
"code",
"int",
",",
"err",
"error",
")",
"{",
"code",
"=",
"1",
"\n",
"contextId",
",",
"err",
":=",
"getenv",
... | // hookToolMain uses JUJU_CONTEXT_ID and JUJU_AGENT_SOCKET to ask a running unit agent
// to execute a Command on our behalf. Individual commands should be exposed
// by symlinking the command name to this executable. | [
"hookToolMain",
"uses",
"JUJU_CONTEXT_ID",
"and",
"JUJU_AGENT_SOCKET",
"to",
"ask",
"a",
"running",
"unit",
"agent",
"to",
"execute",
"a",
"Command",
"on",
"our",
"behalf",
".",
"Individual",
"commands",
"should",
"be",
"exposed",
"by",
"symlinking",
"the",
"com... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/jujud/main.go#L97-L139 |
3,442 | juju/juju | cmd/jujud/main.go | jujuDMain | func jujuDMain(args []string, ctx *cmd.Context) (code int, err error) {
// Assuming an average of 200 bytes per log message, use up to
// 200MB for the log buffer.
defer logger.Debugf("jujud complete, code %d, err %v", code, err)
bufferedLogger, err := logsender.InstallBufferedLogWriter(1048576)
if err != nil {
return 1, errors.Trace(err)
}
// Set the default transport to use the in-process proxy
// configuration.
if err := proxy.DefaultConfig.Set(proxyutils.DetectProxies()); err != nil {
return 1, errors.Trace(err)
}
if err := proxy.DefaultConfig.InstallInDefaultTransport(); err != nil {
return 1, errors.Trace(err)
}
jujud := jujucmd.NewSuperCommand(cmd.SuperCommandParams{
Name: "jujud",
Doc: jujudDoc,
})
jujud.Log.NewWriter = func(target io.Writer) loggo.Writer {
return &jujudWriter{target: target}
}
jujud.Register(agentcmd.NewBootstrapCommand())
// TODO(katco-): AgentConf type is doing too much. The
// MachineAgent type has called out the separate concerns; the
// AgentConf should be split up to follow suit.
agentConf := agentcmd.NewAgentConf("")
machineAgentFactory := agentcmd.MachineAgentFactoryFn(
agentConf,
bufferedLogger,
agentcmd.DefaultIntrospectionSocketName,
upgrades.PreUpgradeSteps,
"",
)
jujud.Register(agentcmd.NewMachineAgentCmd(ctx, machineAgentFactory, agentConf, agentConf))
unitAgent, err := agentcmd.NewUnitAgent(ctx, bufferedLogger)
if err != nil {
return -1, errors.Trace(err)
}
jujud.Register(unitAgent)
caasOperatorAgent, err := agentcmd.NewCaasOperatorAgent(ctx, bufferedLogger)
if err != nil {
return -1, errors.Trace(err)
}
jujud.Register(caasOperatorAgent)
jujud.Register(agentcmd.NewCheckConnectionCommand(agentConf, agentcmd.ConnectAsAgent))
code = cmd.Main(jujud, ctx, args[1:])
return code, nil
} | go | func jujuDMain(args []string, ctx *cmd.Context) (code int, err error) {
// Assuming an average of 200 bytes per log message, use up to
// 200MB for the log buffer.
defer logger.Debugf("jujud complete, code %d, err %v", code, err)
bufferedLogger, err := logsender.InstallBufferedLogWriter(1048576)
if err != nil {
return 1, errors.Trace(err)
}
// Set the default transport to use the in-process proxy
// configuration.
if err := proxy.DefaultConfig.Set(proxyutils.DetectProxies()); err != nil {
return 1, errors.Trace(err)
}
if err := proxy.DefaultConfig.InstallInDefaultTransport(); err != nil {
return 1, errors.Trace(err)
}
jujud := jujucmd.NewSuperCommand(cmd.SuperCommandParams{
Name: "jujud",
Doc: jujudDoc,
})
jujud.Log.NewWriter = func(target io.Writer) loggo.Writer {
return &jujudWriter{target: target}
}
jujud.Register(agentcmd.NewBootstrapCommand())
// TODO(katco-): AgentConf type is doing too much. The
// MachineAgent type has called out the separate concerns; the
// AgentConf should be split up to follow suit.
agentConf := agentcmd.NewAgentConf("")
machineAgentFactory := agentcmd.MachineAgentFactoryFn(
agentConf,
bufferedLogger,
agentcmd.DefaultIntrospectionSocketName,
upgrades.PreUpgradeSteps,
"",
)
jujud.Register(agentcmd.NewMachineAgentCmd(ctx, machineAgentFactory, agentConf, agentConf))
unitAgent, err := agentcmd.NewUnitAgent(ctx, bufferedLogger)
if err != nil {
return -1, errors.Trace(err)
}
jujud.Register(unitAgent)
caasOperatorAgent, err := agentcmd.NewCaasOperatorAgent(ctx, bufferedLogger)
if err != nil {
return -1, errors.Trace(err)
}
jujud.Register(caasOperatorAgent)
jujud.Register(agentcmd.NewCheckConnectionCommand(agentConf, agentcmd.ConnectAsAgent))
code = cmd.Main(jujud, ctx, args[1:])
return code, nil
} | [
"func",
"jujuDMain",
"(",
"args",
"[",
"]",
"string",
",",
"ctx",
"*",
"cmd",
".",
"Context",
")",
"(",
"code",
"int",
",",
"err",
"error",
")",
"{",
"// Assuming an average of 200 bytes per log message, use up to",
"// 200MB for the log buffer.",
"defer",
"logger",... | // Main registers subcommands for the jujud executable, and hands over control
// to the cmd package. | [
"Main",
"registers",
"subcommands",
"for",
"the",
"jujud",
"executable",
"and",
"hands",
"over",
"control",
"to",
"the",
"cmd",
"package",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/jujud/main.go#L143-L201 |
3,443 | juju/juju | worker/storageprovisioner/caasworker.go | saveApplicationWorker | func (p *provisioner) saveApplicationWorker(appName string, aw worker.Worker) {
p.mu.Lock()
defer p.mu.Unlock()
if p.provisioners == nil {
p.provisioners = make(map[string]worker.Worker)
}
p.provisioners[appName] = aw
} | go | func (p *provisioner) saveApplicationWorker(appName string, aw worker.Worker) {
p.mu.Lock()
defer p.mu.Unlock()
if p.provisioners == nil {
p.provisioners = make(map[string]worker.Worker)
}
p.provisioners[appName] = aw
} | [
"func",
"(",
"p",
"*",
"provisioner",
")",
"saveApplicationWorker",
"(",
"appName",
"string",
",",
"aw",
"worker",
".",
"Worker",
")",
"{",
"p",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",... | // These helper methods protect the provisioners map so we can access for testing. | [
"These",
"helper",
"methods",
"protect",
"the",
"provisioners",
"map",
"so",
"we",
"can",
"access",
"for",
"testing",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/storageprovisioner/caasworker.go#L62-L70 |
3,444 | juju/juju | api/action/run.go | RunOnAllMachines | func (c *Client) RunOnAllMachines(commands string, timeout time.Duration) ([]params.ActionResult, error) {
var results params.ActionResults
args := params.RunParams{Commands: commands, Timeout: timeout}
err := c.facade.FacadeCall("RunOnAllMachines", args, &results)
return results.Results, err
} | go | func (c *Client) RunOnAllMachines(commands string, timeout time.Duration) ([]params.ActionResult, error) {
var results params.ActionResults
args := params.RunParams{Commands: commands, Timeout: timeout}
err := c.facade.FacadeCall("RunOnAllMachines", args, &results)
return results.Results, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RunOnAllMachines",
"(",
"commands",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"[",
"]",
"params",
".",
"ActionResult",
",",
"error",
")",
"{",
"var",
"results",
"params",
".",
"ActionResults",
"\n... | // RunOnAllMachines runs the command on all the machines with the specified
// timeout. | [
"RunOnAllMachines",
"runs",
"the",
"command",
"on",
"all",
"the",
"machines",
"with",
"the",
"specified",
"timeout",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/action/run.go#L14-L19 |
3,445 | juju/juju | api/action/run.go | Run | func (c *Client) Run(run params.RunParams) ([]params.ActionResult, error) {
var results params.ActionResults
err := c.facade.FacadeCall("Run", run, &results)
return results.Results, err
} | go | func (c *Client) Run(run params.RunParams) ([]params.ActionResult, error) {
var results params.ActionResults
err := c.facade.FacadeCall("Run", run, &results)
return results.Results, err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Run",
"(",
"run",
"params",
".",
"RunParams",
")",
"(",
"[",
"]",
"params",
".",
"ActionResult",
",",
"error",
")",
"{",
"var",
"results",
"params",
".",
"ActionResults",
"\n",
"err",
":=",
"c",
".",
"facade",
... | // Run the Commands specified on the machines identified through the ids
// provided in the machines, applications and units slices. | [
"Run",
"the",
"Commands",
"specified",
"on",
"the",
"machines",
"identified",
"through",
"the",
"ids",
"provided",
"in",
"the",
"machines",
"applications",
"and",
"units",
"slices",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/action/run.go#L23-L27 |
3,446 | juju/juju | state/stateenvirons/config.go | CloudAPIVersion | func (g EnvironConfigGetter) CloudAPIVersion(spec environs.CloudSpec) (string, error) {
// Only CAAS models have an API version we care about right now.
if g.Model.Type() == state.ModelTypeIAAS {
return "", nil
}
cfg, err := g.ModelConfig()
if err != nil {
return "", errors.Trace(err)
}
ctrlCfg, err := g.ControllerConfig()
if err != nil {
return "", errors.Trace(err)
}
newBroker := g.NewContainerBroker
if newBroker == nil {
newBroker = caas.New
}
broker, err := newBroker(environs.OpenParams{
ControllerUUID: ctrlCfg.ControllerUUID(),
Cloud: spec,
Config: cfg,
})
if err != nil {
return "", errors.Trace(err)
}
return broker.APIVersion()
} | go | func (g EnvironConfigGetter) CloudAPIVersion(spec environs.CloudSpec) (string, error) {
// Only CAAS models have an API version we care about right now.
if g.Model.Type() == state.ModelTypeIAAS {
return "", nil
}
cfg, err := g.ModelConfig()
if err != nil {
return "", errors.Trace(err)
}
ctrlCfg, err := g.ControllerConfig()
if err != nil {
return "", errors.Trace(err)
}
newBroker := g.NewContainerBroker
if newBroker == nil {
newBroker = caas.New
}
broker, err := newBroker(environs.OpenParams{
ControllerUUID: ctrlCfg.ControllerUUID(),
Cloud: spec,
Config: cfg,
})
if err != nil {
return "", errors.Trace(err)
}
return broker.APIVersion()
} | [
"func",
"(",
"g",
"EnvironConfigGetter",
")",
"CloudAPIVersion",
"(",
"spec",
"environs",
".",
"CloudSpec",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Only CAAS models have an API version we care about right now.",
"if",
"g",
".",
"Model",
".",
"Type",
"(",
"... | // CloudAPIVersion returns the cloud API version for the cloud with the given spec. | [
"CloudAPIVersion",
"returns",
"the",
"cloud",
"API",
"version",
"for",
"the",
"cloud",
"with",
"the",
"given",
"spec",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/stateenvirons/config.go#L31-L57 |
3,447 | juju/juju | state/stateenvirons/config.go | GetNewEnvironFunc | func GetNewEnvironFunc(newEnviron environs.NewEnvironFunc) NewEnvironFunc {
return func(st *state.State) (environs.Environ, error) {
m, err := st.Model()
if err != nil {
return nil, errors.Trace(err)
}
g := EnvironConfigGetter{State: st, Model: m}
return environs.GetEnviron(g, newEnviron)
}
} | go | func GetNewEnvironFunc(newEnviron environs.NewEnvironFunc) NewEnvironFunc {
return func(st *state.State) (environs.Environ, error) {
m, err := st.Model()
if err != nil {
return nil, errors.Trace(err)
}
g := EnvironConfigGetter{State: st, Model: m}
return environs.GetEnviron(g, newEnviron)
}
} | [
"func",
"GetNewEnvironFunc",
"(",
"newEnviron",
"environs",
".",
"NewEnvironFunc",
")",
"NewEnvironFunc",
"{",
"return",
"func",
"(",
"st",
"*",
"state",
".",
"State",
")",
"(",
"environs",
".",
"Environ",
",",
"error",
")",
"{",
"m",
",",
"err",
":=",
"... | // GetNewEnvironFunc returns a NewEnvironFunc, that constructs Environs
// using the given environs.NewEnvironFunc. | [
"GetNewEnvironFunc",
"returns",
"a",
"NewEnvironFunc",
"that",
"constructs",
"Environs",
"using",
"the",
"given",
"environs",
".",
"NewEnvironFunc",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/stateenvirons/config.go#L102-L111 |
3,448 | juju/juju | state/stateenvirons/config.go | GetNewCAASBrokerFunc | func GetNewCAASBrokerFunc(newBroker caas.NewContainerBrokerFunc) NewCAASBrokerFunc {
return func(st *state.State) (caas.Broker, error) {
m, err := st.Model()
if err != nil {
return nil, errors.Trace(err)
}
g := EnvironConfigGetter{State: st, Model: m}
cloudSpec, err := g.CloudSpec()
if err != nil {
return nil, errors.Trace(err)
}
cfg, err := g.ModelConfig()
if err != nil {
return nil, errors.Trace(err)
}
ctrlCfg, err := g.ControllerConfig()
if err != nil {
return nil, errors.Trace(err)
}
return newBroker(environs.OpenParams{
ControllerUUID: ctrlCfg.ControllerUUID(),
Cloud: cloudSpec,
Config: cfg,
})
}
} | go | func GetNewCAASBrokerFunc(newBroker caas.NewContainerBrokerFunc) NewCAASBrokerFunc {
return func(st *state.State) (caas.Broker, error) {
m, err := st.Model()
if err != nil {
return nil, errors.Trace(err)
}
g := EnvironConfigGetter{State: st, Model: m}
cloudSpec, err := g.CloudSpec()
if err != nil {
return nil, errors.Trace(err)
}
cfg, err := g.ModelConfig()
if err != nil {
return nil, errors.Trace(err)
}
ctrlCfg, err := g.ControllerConfig()
if err != nil {
return nil, errors.Trace(err)
}
return newBroker(environs.OpenParams{
ControllerUUID: ctrlCfg.ControllerUUID(),
Cloud: cloudSpec,
Config: cfg,
})
}
} | [
"func",
"GetNewCAASBrokerFunc",
"(",
"newBroker",
"caas",
".",
"NewContainerBrokerFunc",
")",
"NewCAASBrokerFunc",
"{",
"return",
"func",
"(",
"st",
"*",
"state",
".",
"State",
")",
"(",
"caas",
".",
"Broker",
",",
"error",
")",
"{",
"m",
",",
"err",
":=",... | // GetNewCAASBrokerFunc returns a NewCAASBrokerFunc, that constructs CAAS brokers
// using the given caas.NewContainerBrokerFunc. | [
"GetNewCAASBrokerFunc",
"returns",
"a",
"NewCAASBrokerFunc",
"that",
"constructs",
"CAAS",
"brokers",
"using",
"the",
"given",
"caas",
".",
"NewContainerBrokerFunc",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/stateenvirons/config.go#L119-L144 |
3,449 | juju/juju | state/modeluser.go | setModelAccess | func (st *State) setModelAccess(access permission.Access, userGlobalKey, modelUUID string) error {
if err := permission.ValidateModelAccess(access); err != nil {
return errors.Trace(err)
}
op := updatePermissionOp(modelKey(modelUUID), userGlobalKey, access)
err := st.db().RunTransactionFor(modelUUID, []txn.Op{op})
if err == txn.ErrAborted {
return errors.NotFoundf("existing permissions")
}
return errors.Trace(err)
} | go | func (st *State) setModelAccess(access permission.Access, userGlobalKey, modelUUID string) error {
if err := permission.ValidateModelAccess(access); err != nil {
return errors.Trace(err)
}
op := updatePermissionOp(modelKey(modelUUID), userGlobalKey, access)
err := st.db().RunTransactionFor(modelUUID, []txn.Op{op})
if err == txn.ErrAborted {
return errors.NotFoundf("existing permissions")
}
return errors.Trace(err)
} | [
"func",
"(",
"st",
"*",
"State",
")",
"setModelAccess",
"(",
"access",
"permission",
".",
"Access",
",",
"userGlobalKey",
",",
"modelUUID",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"permission",
".",
"ValidateModelAccess",
"(",
"access",
")",
";",
"... | // setModelAccess changes the user's access permissions on the model. | [
"setModelAccess",
"changes",
"the",
"user",
"s",
"access",
"permissions",
"on",
"the",
"model",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L34-L44 |
3,450 | juju/juju | state/modeluser.go | LastModelConnection | func (m *Model) LastModelConnection(user names.UserTag) (time.Time, error) {
lastConnections, closer := m.st.db().GetRawCollection(modelUserLastConnectionC)
defer closer()
username := user.Id()
var lastConn modelUserLastConnectionDoc
err := lastConnections.FindId(m.st.docID(username)).Select(bson.D{{"last-connection", 1}}).One(&lastConn)
if err != nil {
if err == mgo.ErrNotFound {
err = errors.Wrap(err, NeverConnectedError(username))
}
return time.Time{}, errors.Trace(err)
}
return lastConn.LastConnection.UTC(), nil
} | go | func (m *Model) LastModelConnection(user names.UserTag) (time.Time, error) {
lastConnections, closer := m.st.db().GetRawCollection(modelUserLastConnectionC)
defer closer()
username := user.Id()
var lastConn modelUserLastConnectionDoc
err := lastConnections.FindId(m.st.docID(username)).Select(bson.D{{"last-connection", 1}}).One(&lastConn)
if err != nil {
if err == mgo.ErrNotFound {
err = errors.Wrap(err, NeverConnectedError(username))
}
return time.Time{}, errors.Trace(err)
}
return lastConn.LastConnection.UTC(), nil
} | [
"func",
"(",
"m",
"*",
"Model",
")",
"LastModelConnection",
"(",
"user",
"names",
".",
"UserTag",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"lastConnections",
",",
"closer",
":=",
"m",
".",
"st",
".",
"db",
"(",
")",
".",
"GetRawCollecti... | // LastModelConnection returns when this User last connected through the API
// in UTC. The resulting time will be nil if the user has never logged in. | [
"LastModelConnection",
"returns",
"when",
"this",
"User",
"last",
"connected",
"through",
"the",
"API",
"in",
"UTC",
".",
"The",
"resulting",
"time",
"will",
"be",
"nil",
"if",
"the",
"user",
"has",
"never",
"logged",
"in",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L48-L63 |
3,451 | juju/juju | state/modeluser.go | IsNeverConnectedError | func IsNeverConnectedError(err error) bool {
_, ok := errors.Cause(err).(NeverConnectedError)
return ok
} | go | func IsNeverConnectedError(err error) bool {
_, ok := errors.Cause(err).(NeverConnectedError)
return ok
} | [
"func",
"IsNeverConnectedError",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
".",
"(",
"NeverConnectedError",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsNeverConnectedError returns true if err is of type NeverConnectedError. | [
"IsNeverConnectedError",
"returns",
"true",
"if",
"err",
"is",
"of",
"type",
"NeverConnectedError",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L76-L79 |
3,452 | juju/juju | state/modeluser.go | UpdateLastModelConnection | func (m *Model) UpdateLastModelConnection(user names.UserTag) error {
return m.updateLastModelConnection(user, m.st.nowToTheSecond())
} | go | func (m *Model) UpdateLastModelConnection(user names.UserTag) error {
return m.updateLastModelConnection(user, m.st.nowToTheSecond())
} | [
"func",
"(",
"m",
"*",
"Model",
")",
"UpdateLastModelConnection",
"(",
"user",
"names",
".",
"UserTag",
")",
"error",
"{",
"return",
"m",
".",
"updateLastModelConnection",
"(",
"user",
",",
"m",
".",
"st",
".",
"nowToTheSecond",
"(",
")",
")",
"\n",
"}"
... | // UpdateLastModelConnection updates the last connection time of the model user. | [
"UpdateLastModelConnection",
"updates",
"the",
"last",
"connection",
"time",
"of",
"the",
"model",
"user",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L82-L84 |
3,453 | juju/juju | state/modeluser.go | modelUser | func (st *State) modelUser(modelUUID string, user names.UserTag) (userAccessDoc, error) {
modelUser := userAccessDoc{}
modelUsers, closer := st.db().GetCollectionFor(modelUUID, modelUsersC)
defer closer()
username := strings.ToLower(user.Id())
err := modelUsers.FindId(username).One(&modelUser)
if err == mgo.ErrNotFound {
return userAccessDoc{}, errors.NotFoundf("model user %q", username)
}
if err != nil {
return userAccessDoc{}, errors.Trace(err)
}
// DateCreated is inserted as UTC, but read out as local time. So we
// convert it back to UTC here.
modelUser.DateCreated = modelUser.DateCreated.UTC()
return modelUser, nil
} | go | func (st *State) modelUser(modelUUID string, user names.UserTag) (userAccessDoc, error) {
modelUser := userAccessDoc{}
modelUsers, closer := st.db().GetCollectionFor(modelUUID, modelUsersC)
defer closer()
username := strings.ToLower(user.Id())
err := modelUsers.FindId(username).One(&modelUser)
if err == mgo.ErrNotFound {
return userAccessDoc{}, errors.NotFoundf("model user %q", username)
}
if err != nil {
return userAccessDoc{}, errors.Trace(err)
}
// DateCreated is inserted as UTC, but read out as local time. So we
// convert it back to UTC here.
modelUser.DateCreated = modelUser.DateCreated.UTC()
return modelUser, nil
} | [
"func",
"(",
"st",
"*",
"State",
")",
"modelUser",
"(",
"modelUUID",
"string",
",",
"user",
"names",
".",
"UserTag",
")",
"(",
"userAccessDoc",
",",
"error",
")",
"{",
"modelUser",
":=",
"userAccessDoc",
"{",
"}",
"\n",
"modelUsers",
",",
"closer",
":=",... | // ModelUser a model userAccessDoc. | [
"ModelUser",
"a",
"model",
"userAccessDoc",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L108-L125 |
3,454 | juju/juju | state/modeluser.go | removeModelUser | func (st *State) removeModelUser(user names.UserTag) error {
ops := removeModelUserOps(st.ModelUUID(), user)
err := st.db().RunTransaction(ops)
if err == txn.ErrAborted {
err = errors.NewNotFound(nil, fmt.Sprintf("model user %q does not exist", user.Id()))
}
if err != nil {
return errors.Trace(err)
}
return nil
} | go | func (st *State) removeModelUser(user names.UserTag) error {
ops := removeModelUserOps(st.ModelUUID(), user)
err := st.db().RunTransaction(ops)
if err == txn.ErrAborted {
err = errors.NewNotFound(nil, fmt.Sprintf("model user %q does not exist", user.Id()))
}
if err != nil {
return errors.Trace(err)
}
return nil
} | [
"func",
"(",
"st",
"*",
"State",
")",
"removeModelUser",
"(",
"user",
"names",
".",
"UserTag",
")",
"error",
"{",
"ops",
":=",
"removeModelUserOps",
"(",
"st",
".",
"ModelUUID",
"(",
")",
",",
"user",
")",
"\n",
"err",
":=",
"st",
".",
"db",
"(",
"... | // removeModelUser removes a user from the database. | [
"removeModelUser",
"removes",
"a",
"user",
"from",
"the",
"database",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L162-L172 |
3,455 | juju/juju | state/modeluser.go | isUserSuperuser | func (st *State) isUserSuperuser(user names.UserTag) (bool, error) {
access, err := st.UserAccess(user, st.controllerTag)
if err != nil {
// TODO(jam): 2017-11-27 We weren't suppressing NotFound here so that we would know when someone asked for
// the list of models of a user that doesn't exist.
// However, now we will not even check if its a known user if they aren't asking for all=true.
return false, errors.Trace(err)
}
isControllerSuperuser := (access.Access == permission.SuperuserAccess)
return isControllerSuperuser, nil
} | go | func (st *State) isUserSuperuser(user names.UserTag) (bool, error) {
access, err := st.UserAccess(user, st.controllerTag)
if err != nil {
// TODO(jam): 2017-11-27 We weren't suppressing NotFound here so that we would know when someone asked for
// the list of models of a user that doesn't exist.
// However, now we will not even check if its a known user if they aren't asking for all=true.
return false, errors.Trace(err)
}
isControllerSuperuser := (access.Access == permission.SuperuserAccess)
return isControllerSuperuser, nil
} | [
"func",
"(",
"st",
"*",
"State",
")",
"isUserSuperuser",
"(",
"user",
"names",
".",
"UserTag",
")",
"(",
"bool",
",",
"error",
")",
"{",
"access",
",",
"err",
":=",
"st",
".",
"UserAccess",
"(",
"user",
",",
"st",
".",
"controllerTag",
")",
"\n",
"... | // isUserSuperuser if this user has the Superuser access on the controller. | [
"isUserSuperuser",
"if",
"this",
"user",
"has",
"the",
"Superuser",
"access",
"on",
"the",
"controller",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L175-L185 |
3,456 | juju/juju | state/modeluser.go | modelQueryForUser | func (st *State) modelQueryForUser(user names.UserTag, isSuperuser bool) (mongo.Query, SessionCloser, error) {
var modelQuery mongo.Query
models, closer := st.db().GetCollection(modelsC)
if isSuperuser {
// Fast path, we just return all the models that aren't Importing
modelQuery = models.Find(bson.M{"migration-mode": bson.M{"$ne": MigrationModeImporting}})
} else {
// Start by looking up model uuids that the user has access to, and then load only the records that are
// included in that set
var modelUUID struct {
UUID string `bson:"object-uuid"`
}
modelUsers, userCloser := st.db().GetRawCollection(modelUsersC)
defer userCloser()
query := modelUsers.Find(bson.D{{"user", user.Id()}})
query.Select(bson.M{"object-uuid": 1, "_id": 0})
query.Batch(100)
iter := query.Iter()
var modelUUIDs []string
for iter.Next(&modelUUID) {
modelUUIDs = append(modelUUIDs, modelUUID.UUID)
}
if err := iter.Close(); err != nil {
closer()
return nil, nil, errors.Trace(err)
}
modelQuery = models.Find(bson.M{
"_id": bson.M{"$in": modelUUIDs},
"migration-mode": bson.M{"$ne": MigrationModeImporting},
})
}
modelQuery.Sort("name", "owner")
return modelQuery, closer, nil
} | go | func (st *State) modelQueryForUser(user names.UserTag, isSuperuser bool) (mongo.Query, SessionCloser, error) {
var modelQuery mongo.Query
models, closer := st.db().GetCollection(modelsC)
if isSuperuser {
// Fast path, we just return all the models that aren't Importing
modelQuery = models.Find(bson.M{"migration-mode": bson.M{"$ne": MigrationModeImporting}})
} else {
// Start by looking up model uuids that the user has access to, and then load only the records that are
// included in that set
var modelUUID struct {
UUID string `bson:"object-uuid"`
}
modelUsers, userCloser := st.db().GetRawCollection(modelUsersC)
defer userCloser()
query := modelUsers.Find(bson.D{{"user", user.Id()}})
query.Select(bson.M{"object-uuid": 1, "_id": 0})
query.Batch(100)
iter := query.Iter()
var modelUUIDs []string
for iter.Next(&modelUUID) {
modelUUIDs = append(modelUUIDs, modelUUID.UUID)
}
if err := iter.Close(); err != nil {
closer()
return nil, nil, errors.Trace(err)
}
modelQuery = models.Find(bson.M{
"_id": bson.M{"$in": modelUUIDs},
"migration-mode": bson.M{"$ne": MigrationModeImporting},
})
}
modelQuery.Sort("name", "owner")
return modelQuery, closer, nil
} | [
"func",
"(",
"st",
"*",
"State",
")",
"modelQueryForUser",
"(",
"user",
"names",
".",
"UserTag",
",",
"isSuperuser",
"bool",
")",
"(",
"mongo",
".",
"Query",
",",
"SessionCloser",
",",
"error",
")",
"{",
"var",
"modelQuery",
"mongo",
".",
"Query",
"\n",
... | // modelsForUser gives you the information about all models that a user has access to.
// This includes the name and UUID, as well as the last time the user connected to that model. | [
"modelsForUser",
"gives",
"you",
"the",
"information",
"about",
"all",
"models",
"that",
"a",
"user",
"has",
"access",
"to",
".",
"This",
"includes",
"the",
"name",
"and",
"UUID",
"as",
"well",
"as",
"the",
"last",
"time",
"the",
"user",
"connected",
"to",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L234-L267 |
3,457 | juju/juju | state/modeluser.go | ModelBasicInfoForUser | func (st *State) ModelBasicInfoForUser(user names.UserTag) ([]ModelAccessInfo, error) {
isSuperuser, err := st.isUserSuperuser(user)
if err != nil {
return nil, errors.Trace(err)
}
modelQuery, closer1, err := st.modelQueryForUser(user, isSuperuser)
if err != nil {
return nil, errors.Trace(err)
}
defer closer1()
modelQuery.Select(bson.M{"_id": 1, "name": 1, "owner": 1, "type": 1})
var accessInfo []ModelAccessInfo
if err := modelQuery.All(&accessInfo); err != nil {
return nil, errors.Trace(err)
}
// Now we need to find the last-connection time for each model for this user
username := user.Id()
connDocIds := make([]string, len(accessInfo))
for i, acc := range accessInfo {
connDocIds[i] = acc.UUID + ":" + username
}
lastConnections, closer2 := st.db().GetRawCollection(modelUserLastConnectionC)
defer closer2()
query := lastConnections.Find(bson.M{"_id": bson.M{"$in": connDocIds}})
query.Select(bson.M{"last-connection": 1, "_id": 0, "model-uuid": 1})
query.Batch(100)
iter := query.Iter()
lastConns := make(map[string]time.Time, len(connDocIds))
var connInfo modelUserLastConnectionDoc
for iter.Next(&connInfo) {
lastConns[connInfo.ModelUUID] = connInfo.LastConnection
}
if err := iter.Close(); err != nil {
return nil, errors.Trace(err)
}
for i := range accessInfo {
uuid := accessInfo[i].UUID
accessInfo[i].LastConnection = lastConns[uuid]
}
return accessInfo, nil
} | go | func (st *State) ModelBasicInfoForUser(user names.UserTag) ([]ModelAccessInfo, error) {
isSuperuser, err := st.isUserSuperuser(user)
if err != nil {
return nil, errors.Trace(err)
}
modelQuery, closer1, err := st.modelQueryForUser(user, isSuperuser)
if err != nil {
return nil, errors.Trace(err)
}
defer closer1()
modelQuery.Select(bson.M{"_id": 1, "name": 1, "owner": 1, "type": 1})
var accessInfo []ModelAccessInfo
if err := modelQuery.All(&accessInfo); err != nil {
return nil, errors.Trace(err)
}
// Now we need to find the last-connection time for each model for this user
username := user.Id()
connDocIds := make([]string, len(accessInfo))
for i, acc := range accessInfo {
connDocIds[i] = acc.UUID + ":" + username
}
lastConnections, closer2 := st.db().GetRawCollection(modelUserLastConnectionC)
defer closer2()
query := lastConnections.Find(bson.M{"_id": bson.M{"$in": connDocIds}})
query.Select(bson.M{"last-connection": 1, "_id": 0, "model-uuid": 1})
query.Batch(100)
iter := query.Iter()
lastConns := make(map[string]time.Time, len(connDocIds))
var connInfo modelUserLastConnectionDoc
for iter.Next(&connInfo) {
lastConns[connInfo.ModelUUID] = connInfo.LastConnection
}
if err := iter.Close(); err != nil {
return nil, errors.Trace(err)
}
for i := range accessInfo {
uuid := accessInfo[i].UUID
accessInfo[i].LastConnection = lastConns[uuid]
}
return accessInfo, nil
} | [
"func",
"(",
"st",
"*",
"State",
")",
"ModelBasicInfoForUser",
"(",
"user",
"names",
".",
"UserTag",
")",
"(",
"[",
"]",
"ModelAccessInfo",
",",
"error",
")",
"{",
"isSuperuser",
",",
"err",
":=",
"st",
".",
"isUserSuperuser",
"(",
"user",
")",
"\n",
"... | // ModelBasicInfoForUser gives you the information about all models that a user has access to.
// This includes the name and UUID, as well as the last time the user connected to that model. | [
"ModelBasicInfoForUser",
"gives",
"you",
"the",
"information",
"about",
"all",
"models",
"that",
"a",
"user",
"has",
"access",
"to",
".",
"This",
"includes",
"the",
"name",
"and",
"UUID",
"as",
"well",
"as",
"the",
"last",
"time",
"the",
"user",
"connected",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L279-L319 |
3,458 | juju/juju | state/modeluser.go | IsControllerAdmin | func (st *State) IsControllerAdmin(user names.UserTag) (bool, error) {
model, err := st.Model()
if err != nil {
return false, errors.Trace(err)
}
ua, err := st.UserAccess(user, model.ControllerTag())
if errors.IsNotFound(err) {
return false, nil
}
if err != nil {
return false, errors.Trace(err)
}
return ua.Access == permission.SuperuserAccess, nil
} | go | func (st *State) IsControllerAdmin(user names.UserTag) (bool, error) {
model, err := st.Model()
if err != nil {
return false, errors.Trace(err)
}
ua, err := st.UserAccess(user, model.ControllerTag())
if errors.IsNotFound(err) {
return false, nil
}
if err != nil {
return false, errors.Trace(err)
}
return ua.Access == permission.SuperuserAccess, nil
} | [
"func",
"(",
"st",
"*",
"State",
")",
"IsControllerAdmin",
"(",
"user",
"names",
".",
"UserTag",
")",
"(",
"bool",
",",
"error",
")",
"{",
"model",
",",
"err",
":=",
"st",
".",
"Model",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fa... | // IsControllerAdmin returns true if the user specified has Super User Access. | [
"IsControllerAdmin",
"returns",
"true",
"if",
"the",
"user",
"specified",
"has",
"Super",
"User",
"Access",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/modeluser.go#L379-L392 |
3,459 | juju/juju | agent/agent.go | SetAPIHostPorts | func (s APIHostPortsSetter) SetAPIHostPorts(servers [][]network.HostPort) error {
return s.ChangeConfig(func(c ConfigSetter) error {
c.SetAPIHostPorts(servers)
return nil
})
} | go | func (s APIHostPortsSetter) SetAPIHostPorts(servers [][]network.HostPort) error {
return s.ChangeConfig(func(c ConfigSetter) error {
c.SetAPIHostPorts(servers)
return nil
})
} | [
"func",
"(",
"s",
"APIHostPortsSetter",
")",
"SetAPIHostPorts",
"(",
"servers",
"[",
"]",
"[",
"]",
"network",
".",
"HostPort",
")",
"error",
"{",
"return",
"s",
".",
"ChangeConfig",
"(",
"func",
"(",
"c",
"ConfigSetter",
")",
"error",
"{",
"c",
".",
"... | // SetAPIHostPorts is the APIAddressSetter interface. | [
"SetAPIHostPorts",
"is",
"the",
"APIAddressSetter",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L73-L78 |
3,460 | juju/juju | agent/agent.go | Migrate | func (p *Paths) Migrate(newPaths Paths) {
if newPaths.DataDir != "" {
p.DataDir = newPaths.DataDir
}
if newPaths.LogDir != "" {
p.LogDir = newPaths.LogDir
}
if newPaths.MetricsSpoolDir != "" {
p.MetricsSpoolDir = newPaths.MetricsSpoolDir
}
if newPaths.ConfDir != "" {
p.ConfDir = newPaths.ConfDir
}
} | go | func (p *Paths) Migrate(newPaths Paths) {
if newPaths.DataDir != "" {
p.DataDir = newPaths.DataDir
}
if newPaths.LogDir != "" {
p.LogDir = newPaths.LogDir
}
if newPaths.MetricsSpoolDir != "" {
p.MetricsSpoolDir = newPaths.MetricsSpoolDir
}
if newPaths.ConfDir != "" {
p.ConfDir = newPaths.ConfDir
}
} | [
"func",
"(",
"p",
"*",
"Paths",
")",
"Migrate",
"(",
"newPaths",
"Paths",
")",
"{",
"if",
"newPaths",
".",
"DataDir",
"!=",
"\"",
"\"",
"{",
"p",
".",
"DataDir",
"=",
"newPaths",
".",
"DataDir",
"\n",
"}",
"\n",
"if",
"newPaths",
".",
"LogDir",
"!=... | // Migrate assigns the directory locations specified from the new path configuration. | [
"Migrate",
"assigns",
"the",
"directory",
"locations",
"specified",
"from",
"the",
"new",
"path",
"configuration",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L97-L110 |
3,461 | juju/juju | agent/agent.go | NewPathsWithDefaults | func NewPathsWithDefaults(p Paths) Paths {
paths := DefaultPaths
if p.DataDir != "" {
paths.DataDir = p.DataDir
}
if p.LogDir != "" {
paths.LogDir = p.LogDir
}
if p.MetricsSpoolDir != "" {
paths.MetricsSpoolDir = p.MetricsSpoolDir
}
if p.ConfDir != "" {
paths.ConfDir = p.ConfDir
}
return paths
} | go | func NewPathsWithDefaults(p Paths) Paths {
paths := DefaultPaths
if p.DataDir != "" {
paths.DataDir = p.DataDir
}
if p.LogDir != "" {
paths.LogDir = p.LogDir
}
if p.MetricsSpoolDir != "" {
paths.MetricsSpoolDir = p.MetricsSpoolDir
}
if p.ConfDir != "" {
paths.ConfDir = p.ConfDir
}
return paths
} | [
"func",
"NewPathsWithDefaults",
"(",
"p",
"Paths",
")",
"Paths",
"{",
"paths",
":=",
"DefaultPaths",
"\n",
"if",
"p",
".",
"DataDir",
"!=",
"\"",
"\"",
"{",
"paths",
".",
"DataDir",
"=",
"p",
".",
"DataDir",
"\n",
"}",
"\n",
"if",
"p",
".",
"LogDir",... | // NewPathsWithDefaults returns a Paths struct initialized with default locations if not otherwise specified. | [
"NewPathsWithDefaults",
"returns",
"a",
"Paths",
"struct",
"initialized",
"with",
"default",
"locations",
"if",
"not",
"otherwise",
"specified",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L113-L128 |
3,462 | juju/juju | agent/agent.go | LogFilename | func LogFilename(c Config) string {
return filepath.Join(c.LogDir(), c.Tag().String()+".log")
} | go | func LogFilename(c Config) string {
return filepath.Join(c.LogDir(), c.Tag().String()+".log")
} | [
"func",
"LogFilename",
"(",
"c",
"Config",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"c",
".",
"LogDir",
"(",
")",
",",
"c",
".",
"Tag",
"(",
")",
".",
"String",
"(",
")",
"+",
"\"",
"\"",
")",
"\n",
"}"
] | // LogFileName returns the filename for the Agent's log file. | [
"LogFileName",
"returns",
"the",
"filename",
"for",
"the",
"Agent",
"s",
"log",
"file",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L322-L324 |
3,463 | juju/juju | agent/agent.go | MachineLockLogFilename | func MachineLockLogFilename(c Config) string {
return filepath.Join(c.LogDir(), machinelock.Filename)
} | go | func MachineLockLogFilename(c Config) string {
return filepath.Join(c.LogDir(), machinelock.Filename)
} | [
"func",
"MachineLockLogFilename",
"(",
"c",
"Config",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"c",
".",
"LogDir",
"(",
")",
",",
"machinelock",
".",
"Filename",
")",
"\n",
"}"
] | // MachineLockLogFilename returns the filename for the machine lock log file. | [
"MachineLockLogFilename",
"returns",
"the",
"filename",
"for",
"the",
"machine",
"lock",
"log",
"file",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L327-L329 |
3,464 | juju/juju | agent/agent.go | NewAgentConfig | func NewAgentConfig(configParams AgentConfigParams) (ConfigSetterWriter, error) {
if configParams.Paths.DataDir == "" {
return nil, errors.Trace(requiredError("data directory"))
}
if configParams.Tag == nil {
return nil, errors.Trace(requiredError("entity tag"))
}
switch configParams.Tag.(type) {
case names.MachineTag, names.UnitTag, names.ApplicationTag:
// These are the only three type of tags that can represent an agent
// IAAS - machine and unit
// CAAS - application
default:
return nil, errors.Errorf("entity tag must be MachineTag, UnitTag or ApplicationTag, got %T", configParams.Tag)
}
if configParams.UpgradedToVersion == version.Zero {
return nil, errors.Trace(requiredError("upgradedToVersion"))
}
if configParams.Password == "" {
return nil, errors.Trace(requiredError("password"))
}
if uuid := configParams.Controller.Id(); uuid == "" {
return nil, errors.Trace(requiredError("controller"))
} else if !names.IsValidController(uuid) {
return nil, errors.Errorf("%q is not a valid controller uuid", uuid)
}
if uuid := configParams.Model.Id(); uuid == "" {
return nil, errors.Trace(requiredError("model"))
} else if !names.IsValidModel(uuid) {
return nil, errors.Errorf("%q is not a valid model uuid", uuid)
}
if len(configParams.CACert) == 0 {
return nil, errors.Trace(requiredError("CA certificate"))
}
// Note that the password parts of the state and api information are
// blank. This is by design: we want to generate a secure password
// for new agents. So, we create this config without a current password
// which signals to apicaller worker that it should try to connect using old password.
// When/if this connection is successful, apicaller worker will generate
// a new secure password and update this agent's config.
config := &configInternal{
paths: NewPathsWithDefaults(configParams.Paths),
jobs: configParams.Jobs,
upgradedToVersion: configParams.UpgradedToVersion,
tag: configParams.Tag,
nonce: configParams.Nonce,
controller: configParams.Controller,
model: configParams.Model,
caCert: configParams.CACert,
oldPassword: configParams.Password,
values: configParams.Values,
mongoVersion: configParams.MongoVersion.String(),
mongoMemoryProfile: configParams.MongoMemoryProfile.String(),
}
if len(configParams.APIAddresses) > 0 {
config.apiDetails = &apiDetails{
addresses: configParams.APIAddresses,
}
}
if err := config.check(); err != nil {
return nil, err
}
if config.values == nil {
config.values = make(map[string]string)
}
config.configFilePath = ConfigPath(config.paths.DataDir, config.tag)
return config, nil
} | go | func NewAgentConfig(configParams AgentConfigParams) (ConfigSetterWriter, error) {
if configParams.Paths.DataDir == "" {
return nil, errors.Trace(requiredError("data directory"))
}
if configParams.Tag == nil {
return nil, errors.Trace(requiredError("entity tag"))
}
switch configParams.Tag.(type) {
case names.MachineTag, names.UnitTag, names.ApplicationTag:
// These are the only three type of tags that can represent an agent
// IAAS - machine and unit
// CAAS - application
default:
return nil, errors.Errorf("entity tag must be MachineTag, UnitTag or ApplicationTag, got %T", configParams.Tag)
}
if configParams.UpgradedToVersion == version.Zero {
return nil, errors.Trace(requiredError("upgradedToVersion"))
}
if configParams.Password == "" {
return nil, errors.Trace(requiredError("password"))
}
if uuid := configParams.Controller.Id(); uuid == "" {
return nil, errors.Trace(requiredError("controller"))
} else if !names.IsValidController(uuid) {
return nil, errors.Errorf("%q is not a valid controller uuid", uuid)
}
if uuid := configParams.Model.Id(); uuid == "" {
return nil, errors.Trace(requiredError("model"))
} else if !names.IsValidModel(uuid) {
return nil, errors.Errorf("%q is not a valid model uuid", uuid)
}
if len(configParams.CACert) == 0 {
return nil, errors.Trace(requiredError("CA certificate"))
}
// Note that the password parts of the state and api information are
// blank. This is by design: we want to generate a secure password
// for new agents. So, we create this config without a current password
// which signals to apicaller worker that it should try to connect using old password.
// When/if this connection is successful, apicaller worker will generate
// a new secure password and update this agent's config.
config := &configInternal{
paths: NewPathsWithDefaults(configParams.Paths),
jobs: configParams.Jobs,
upgradedToVersion: configParams.UpgradedToVersion,
tag: configParams.Tag,
nonce: configParams.Nonce,
controller: configParams.Controller,
model: configParams.Model,
caCert: configParams.CACert,
oldPassword: configParams.Password,
values: configParams.Values,
mongoVersion: configParams.MongoVersion.String(),
mongoMemoryProfile: configParams.MongoMemoryProfile.String(),
}
if len(configParams.APIAddresses) > 0 {
config.apiDetails = &apiDetails{
addresses: configParams.APIAddresses,
}
}
if err := config.check(); err != nil {
return nil, err
}
if config.values == nil {
config.values = make(map[string]string)
}
config.configFilePath = ConfigPath(config.paths.DataDir, config.tag)
return config, nil
} | [
"func",
"NewAgentConfig",
"(",
"configParams",
"AgentConfigParams",
")",
"(",
"ConfigSetterWriter",
",",
"error",
")",
"{",
"if",
"configParams",
".",
"Paths",
".",
"DataDir",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"errors",
".",
"Trace",
"(",
"require... | // NewAgentConfig returns a new config object suitable for use for a
// machine or unit agent. | [
"NewAgentConfig",
"returns",
"a",
"new",
"config",
"object",
"suitable",
"for",
"use",
"for",
"a",
"machine",
"or",
"unit",
"agent",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L414-L481 |
3,465 | juju/juju | agent/agent.go | NewStateMachineConfig | func NewStateMachineConfig(configParams AgentConfigParams, serverInfo params.StateServingInfo) (ConfigSetterWriter, error) {
if serverInfo.Cert == "" {
return nil, errors.Trace(requiredError("controller cert"))
}
if serverInfo.PrivateKey == "" {
return nil, errors.Trace(requiredError("controller key"))
}
if serverInfo.CAPrivateKey == "" {
return nil, errors.Trace(requiredError("ca cert key"))
}
if serverInfo.StatePort == 0 {
return nil, errors.Trace(requiredError("state port"))
}
if serverInfo.APIPort == 0 {
return nil, errors.Trace(requiredError("api port"))
}
config, err := NewAgentConfig(configParams)
if err != nil {
return nil, err
}
config.SetStateServingInfo(serverInfo)
return config, nil
} | go | func NewStateMachineConfig(configParams AgentConfigParams, serverInfo params.StateServingInfo) (ConfigSetterWriter, error) {
if serverInfo.Cert == "" {
return nil, errors.Trace(requiredError("controller cert"))
}
if serverInfo.PrivateKey == "" {
return nil, errors.Trace(requiredError("controller key"))
}
if serverInfo.CAPrivateKey == "" {
return nil, errors.Trace(requiredError("ca cert key"))
}
if serverInfo.StatePort == 0 {
return nil, errors.Trace(requiredError("state port"))
}
if serverInfo.APIPort == 0 {
return nil, errors.Trace(requiredError("api port"))
}
config, err := NewAgentConfig(configParams)
if err != nil {
return nil, err
}
config.SetStateServingInfo(serverInfo)
return config, nil
} | [
"func",
"NewStateMachineConfig",
"(",
"configParams",
"AgentConfigParams",
",",
"serverInfo",
"params",
".",
"StateServingInfo",
")",
"(",
"ConfigSetterWriter",
",",
"error",
")",
"{",
"if",
"serverInfo",
".",
"Cert",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",... | // NewStateMachineConfig returns a configuration suitable for
// a machine running the controller. | [
"NewStateMachineConfig",
"returns",
"a",
"configuration",
"suitable",
"for",
"a",
"machine",
"running",
"the",
"controller",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L485-L507 |
3,466 | juju/juju | agent/agent.go | Dir | func Dir(dataDir string, tag names.Tag) string {
// Note: must use path, not filepath, as this
// function is used by the client on Windows.
return path.Join(BaseDir(dataDir), tag.String())
} | go | func Dir(dataDir string, tag names.Tag) string {
// Note: must use path, not filepath, as this
// function is used by the client on Windows.
return path.Join(BaseDir(dataDir), tag.String())
} | [
"func",
"Dir",
"(",
"dataDir",
"string",
",",
"tag",
"names",
".",
"Tag",
")",
"string",
"{",
"// Note: must use path, not filepath, as this",
"// function is used by the client on Windows.",
"return",
"path",
".",
"Join",
"(",
"BaseDir",
"(",
"dataDir",
")",
",",
"... | // Dir returns the agent-specific data directory. | [
"Dir",
"returns",
"the",
"agent",
"-",
"specific",
"data",
"directory",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L518-L522 |
3,467 | juju/juju | agent/agent.go | ReadConfig | func ReadConfig(configFilePath string) (ConfigSetterWriter, error) {
var (
format formatter
config *configInternal
)
configData, err := ioutil.ReadFile(configFilePath)
if err != nil {
return nil, errors.Annotatef(err, "cannot read agent config %q", configFilePath)
}
format, config, err = parseConfigData(configData)
if err != nil {
return nil, err
}
logger.Debugf("read agent config, format %q", format.version())
config.configFilePath = configFilePath
return config, nil
} | go | func ReadConfig(configFilePath string) (ConfigSetterWriter, error) {
var (
format formatter
config *configInternal
)
configData, err := ioutil.ReadFile(configFilePath)
if err != nil {
return nil, errors.Annotatef(err, "cannot read agent config %q", configFilePath)
}
format, config, err = parseConfigData(configData)
if err != nil {
return nil, err
}
logger.Debugf("read agent config, format %q", format.version())
config.configFilePath = configFilePath
return config, nil
} | [
"func",
"ReadConfig",
"(",
"configFilePath",
"string",
")",
"(",
"ConfigSetterWriter",
",",
"error",
")",
"{",
"var",
"(",
"format",
"formatter",
"\n",
"config",
"*",
"configInternal",
"\n",
")",
"\n",
"configData",
",",
"err",
":=",
"ioutil",
".",
"ReadFile... | // ReadConfig reads configuration data from the given location. | [
"ReadConfig",
"reads",
"configuration",
"data",
"from",
"the",
"given",
"location",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L532-L548 |
3,468 | juju/juju | agent/agent.go | MongoVersion | func (c *configInternal) MongoVersion() mongo.Version {
v, err := mongo.NewVersion(c.mongoVersion)
if err != nil {
return mongo.Mongo24
}
return v
} | go | func (c *configInternal) MongoVersion() mongo.Version {
v, err := mongo.NewVersion(c.mongoVersion)
if err != nil {
return mongo.Mongo24
}
return v
} | [
"func",
"(",
"c",
"*",
"configInternal",
")",
"MongoVersion",
"(",
")",
"mongo",
".",
"Version",
"{",
"v",
",",
"err",
":=",
"mongo",
".",
"NewVersion",
"(",
"c",
".",
"mongoVersion",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"mongo",
".",
... | // MongoVersion implements Config. | [
"MongoVersion",
"implements",
"Config",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L736-L742 |
3,469 | juju/juju | agent/agent.go | MongoMemoryProfile | func (c *configInternal) MongoMemoryProfile() mongo.MemoryProfile {
mprof := mongo.MemoryProfile(c.mongoMemoryProfile)
if err := mprof.Validate(); err != nil {
return mongo.MemoryProfileLow
}
return mongo.MemoryProfile(c.mongoMemoryProfile)
} | go | func (c *configInternal) MongoMemoryProfile() mongo.MemoryProfile {
mprof := mongo.MemoryProfile(c.mongoMemoryProfile)
if err := mprof.Validate(); err != nil {
return mongo.MemoryProfileLow
}
return mongo.MemoryProfile(c.mongoMemoryProfile)
} | [
"func",
"(",
"c",
"*",
"configInternal",
")",
"MongoMemoryProfile",
"(",
")",
"mongo",
".",
"MemoryProfile",
"{",
"mprof",
":=",
"mongo",
".",
"MemoryProfile",
"(",
"c",
".",
"mongoMemoryProfile",
")",
"\n",
"if",
"err",
":=",
"mprof",
".",
"Validate",
"("... | // MongoMemoryProfile implements Config. | [
"MongoMemoryProfile",
"implements",
"Config",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L745-L751 |
3,470 | juju/juju | agent/agent.go | SetMongoVersion | func (c *configInternal) SetMongoVersion(v mongo.Version) {
c.mongoVersion = v.String()
} | go | func (c *configInternal) SetMongoVersion(v mongo.Version) {
c.mongoVersion = v.String()
} | [
"func",
"(",
"c",
"*",
"configInternal",
")",
"SetMongoVersion",
"(",
"v",
"mongo",
".",
"Version",
")",
"{",
"c",
".",
"mongoVersion",
"=",
"v",
".",
"String",
"(",
")",
"\n",
"}"
] | // SetMongoVersion implements configSetterOnly. | [
"SetMongoVersion",
"implements",
"configSetterOnly",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L754-L756 |
3,471 | juju/juju | agent/agent.go | SetMongoMemoryProfile | func (c *configInternal) SetMongoMemoryProfile(v mongo.MemoryProfile) {
c.mongoMemoryProfile = v.String()
} | go | func (c *configInternal) SetMongoMemoryProfile(v mongo.MemoryProfile) {
c.mongoMemoryProfile = v.String()
} | [
"func",
"(",
"c",
"*",
"configInternal",
")",
"SetMongoMemoryProfile",
"(",
"v",
"mongo",
".",
"MemoryProfile",
")",
"{",
"c",
".",
"mongoMemoryProfile",
"=",
"v",
".",
"String",
"(",
")",
"\n",
"}"
] | // SetMongoMemoryProfile implements configSetterOnly. | [
"SetMongoMemoryProfile",
"implements",
"configSetterOnly",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L759-L761 |
3,472 | juju/juju | agent/agent.go | WriteCommands | func (c *configInternal) WriteCommands(renderer shell.Renderer) ([]string, error) {
data, err := c.Render()
if err != nil {
return nil, errors.Trace(err)
}
commands := renderer.MkdirAll(c.Dir())
filename := c.File(AgentConfigFilename)
commands = append(commands, renderer.WriteFile(filename, data)...)
commands = append(commands, renderer.Chmod(filename, 0600)...)
return commands, nil
} | go | func (c *configInternal) WriteCommands(renderer shell.Renderer) ([]string, error) {
data, err := c.Render()
if err != nil {
return nil, errors.Trace(err)
}
commands := renderer.MkdirAll(c.Dir())
filename := c.File(AgentConfigFilename)
commands = append(commands, renderer.WriteFile(filename, data)...)
commands = append(commands, renderer.Chmod(filename, 0600)...)
return commands, nil
} | [
"func",
"(",
"c",
"*",
"configInternal",
")",
"WriteCommands",
"(",
"renderer",
"shell",
".",
"Renderer",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"c",
".",
"Render",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // WriteCommands is defined on Config interface. | [
"WriteCommands",
"is",
"defined",
"on",
"Config",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L789-L799 |
3,473 | juju/juju | agent/agent.go | APIInfo | func (c *configInternal) APIInfo() (*api.Info, bool) {
if c.apiDetails == nil || c.apiDetails.addresses == nil {
return nil, false
}
servingInfo, isController := c.StateServingInfo()
addrs := c.apiDetails.addresses
// For controller we return only localhost - we should not connect
// to other controllers if we can talk locally.
if isController {
port := servingInfo.APIPort
// If the controller has been configured with a controller api port,
// we return that instead of the normal api port.
if servingInfo.ControllerAPIPort != 0 {
port = servingInfo.ControllerAPIPort
}
// TODO(macgreagoir) IPv6. Ubuntu still always provides IPv4
// loopback, and when/if this changes localhost should resolve
// to IPv6 loopback in any case (lp:1644009). Review.
localAPIAddr := net.JoinHostPort("localhost", strconv.Itoa(port))
addrs = []string{localAPIAddr}
}
return &api.Info{
Addrs: addrs,
Password: c.apiDetails.password,
CACert: c.caCert,
Tag: c.tag,
Nonce: c.nonce,
ModelTag: c.model,
}, true
} | go | func (c *configInternal) APIInfo() (*api.Info, bool) {
if c.apiDetails == nil || c.apiDetails.addresses == nil {
return nil, false
}
servingInfo, isController := c.StateServingInfo()
addrs := c.apiDetails.addresses
// For controller we return only localhost - we should not connect
// to other controllers if we can talk locally.
if isController {
port := servingInfo.APIPort
// If the controller has been configured with a controller api port,
// we return that instead of the normal api port.
if servingInfo.ControllerAPIPort != 0 {
port = servingInfo.ControllerAPIPort
}
// TODO(macgreagoir) IPv6. Ubuntu still always provides IPv4
// loopback, and when/if this changes localhost should resolve
// to IPv6 loopback in any case (lp:1644009). Review.
localAPIAddr := net.JoinHostPort("localhost", strconv.Itoa(port))
addrs = []string{localAPIAddr}
}
return &api.Info{
Addrs: addrs,
Password: c.apiDetails.password,
CACert: c.caCert,
Tag: c.tag,
Nonce: c.nonce,
ModelTag: c.model,
}, true
} | [
"func",
"(",
"c",
"*",
"configInternal",
")",
"APIInfo",
"(",
")",
"(",
"*",
"api",
".",
"Info",
",",
"bool",
")",
"{",
"if",
"c",
".",
"apiDetails",
"==",
"nil",
"||",
"c",
".",
"apiDetails",
".",
"addresses",
"==",
"nil",
"{",
"return",
"nil",
... | // APIInfo is defined on Config interface. | [
"APIInfo",
"is",
"defined",
"on",
"Config",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L802-L831 |
3,474 | juju/juju | agent/agent.go | MongoInfo | func (c *configInternal) MongoInfo() (info *mongo.MongoInfo, ok bool) {
ssi, ok := c.StateServingInfo()
if !ok {
return nil, false
}
// We return localhost first and then all addresses of known API
// endpoints - this lets us connect to other Mongo instances and start
// state even if our own Mongo has not started yet (see lp:1749383 #1).
// TODO(macgreagoir) IPv6. Ubuntu still always provides IPv4 loopback,
// and when/if this changes localhost should resolve to IPv6 loopback
// in any case (lp:1644009). Review.
local := net.JoinHostPort("localhost", strconv.Itoa(ssi.StatePort))
addrs := []string{local}
for _, addr := range c.apiDetails.addresses {
host, _, err := net.SplitHostPort(addr)
if err != nil {
return nil, false
}
if host := net.JoinHostPort(host, strconv.Itoa(ssi.StatePort)); host != local {
addrs = append(addrs, host)
}
}
return &mongo.MongoInfo{
Info: mongo.Info{
Addrs: addrs,
CACert: c.caCert,
},
Password: c.statePassword,
Tag: c.tag,
}, true
} | go | func (c *configInternal) MongoInfo() (info *mongo.MongoInfo, ok bool) {
ssi, ok := c.StateServingInfo()
if !ok {
return nil, false
}
// We return localhost first and then all addresses of known API
// endpoints - this lets us connect to other Mongo instances and start
// state even if our own Mongo has not started yet (see lp:1749383 #1).
// TODO(macgreagoir) IPv6. Ubuntu still always provides IPv4 loopback,
// and when/if this changes localhost should resolve to IPv6 loopback
// in any case (lp:1644009). Review.
local := net.JoinHostPort("localhost", strconv.Itoa(ssi.StatePort))
addrs := []string{local}
for _, addr := range c.apiDetails.addresses {
host, _, err := net.SplitHostPort(addr)
if err != nil {
return nil, false
}
if host := net.JoinHostPort(host, strconv.Itoa(ssi.StatePort)); host != local {
addrs = append(addrs, host)
}
}
return &mongo.MongoInfo{
Info: mongo.Info{
Addrs: addrs,
CACert: c.caCert,
},
Password: c.statePassword,
Tag: c.tag,
}, true
} | [
"func",
"(",
"c",
"*",
"configInternal",
")",
"MongoInfo",
"(",
")",
"(",
"info",
"*",
"mongo",
".",
"MongoInfo",
",",
"ok",
"bool",
")",
"{",
"ssi",
",",
"ok",
":=",
"c",
".",
"StateServingInfo",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"... | // MongoInfo is defined on Config interface. | [
"MongoInfo",
"is",
"defined",
"on",
"Config",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/agent/agent.go#L834-L865 |
3,475 | juju/juju | apiserver/restrict_caasmodel.go | isCAASModelFacade | func isCAASModelFacade(facadeName string) bool {
return caasModelFacadeNames.Contains(facadeName) ||
commonModelFacadeNames.Contains(facadeName) ||
commonFacadeNames.Contains(facadeName)
} | go | func isCAASModelFacade(facadeName string) bool {
return caasModelFacadeNames.Contains(facadeName) ||
commonModelFacadeNames.Contains(facadeName) ||
commonFacadeNames.Contains(facadeName)
} | [
"func",
"isCAASModelFacade",
"(",
"facadeName",
"string",
")",
"bool",
"{",
"return",
"caasModelFacadeNames",
".",
"Contains",
"(",
"facadeName",
")",
"||",
"commonModelFacadeNames",
".",
"Contains",
"(",
"facadeName",
")",
"||",
"commonFacadeNames",
".",
"Contains"... | // isCAASModelFacade reports whether the given facade name can be accessed
// using the controller connection. | [
"isCAASModelFacade",
"reports",
"whether",
"the",
"given",
"facade",
"name",
"can",
"be",
"accessed",
"using",
"the",
"controller",
"connection",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/restrict_caasmodel.go#L94-L98 |
3,476 | juju/juju | cmd/juju/common/errors.go | UserErr | func (e *TermsRequiredError) UserErr() error {
terms := strings.Join(e.Terms, " ")
return errors.Wrap(e,
errors.Errorf(`Declined: some terms require agreement. Try: "juju agree %s"`, terms))
} | go | func (e *TermsRequiredError) UserErr() error {
terms := strings.Join(e.Terms, " ")
return errors.Wrap(e,
errors.Errorf(`Declined: some terms require agreement. Try: "juju agree %s"`, terms))
} | [
"func",
"(",
"e",
"*",
"TermsRequiredError",
")",
"UserErr",
"(",
")",
"error",
"{",
"terms",
":=",
"strings",
".",
"Join",
"(",
"e",
".",
"Terms",
",",
"\"",
"\"",
")",
"\n",
"return",
"errors",
".",
"Wrap",
"(",
"e",
",",
"errors",
".",
"Errorf",... | // UserErr returns an error containing a user-friendly message describing how
// to agree to required terms. | [
"UserErr",
"returns",
"an",
"error",
"containing",
"a",
"user",
"-",
"friendly",
"message",
"describing",
"how",
"to",
"agree",
"to",
"required",
"terms",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/common/errors.go#L56-L60 |
3,477 | juju/juju | environs/instances/image.go | String | func (ic *InstanceConstraint) String() string {
return fmt.Sprintf(
"{region: %s, series: %s, arches: %s, constraints: %s, storage: %s}",
ic.Region,
ic.Series,
ic.Arches,
ic.Constraints,
ic.Storage,
)
} | go | func (ic *InstanceConstraint) String() string {
return fmt.Sprintf(
"{region: %s, series: %s, arches: %s, constraints: %s, storage: %s}",
ic.Region,
ic.Series,
ic.Arches,
ic.Constraints,
ic.Storage,
)
} | [
"func",
"(",
"ic",
"*",
"InstanceConstraint",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"ic",
".",
"Region",
",",
"ic",
".",
"Series",
",",
"ic",
".",
"Arches",
",",
"ic",
".",
"Constraints",
","... | // String returns a human readable form of this InstanceConstraint. | [
"String",
"returns",
"a",
"human",
"readable",
"form",
"of",
"this",
"InstanceConstraint",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/instances/image.go#L39-L48 |
3,478 | juju/juju | environs/instances/image.go | match | func (image Image) match(itype InstanceType) imageMatch {
if !image.matchArch(itype.Arches) {
return nonMatch
}
if itype.VirtType == nil || image.VirtType == *itype.VirtType {
return exactMatch
}
if image.VirtType == "" {
// Image doesn't specify virtualisation type. We allow it
// to match, but prefer exact matches.
return partialMatch
}
return nonMatch
} | go | func (image Image) match(itype InstanceType) imageMatch {
if !image.matchArch(itype.Arches) {
return nonMatch
}
if itype.VirtType == nil || image.VirtType == *itype.VirtType {
return exactMatch
}
if image.VirtType == "" {
// Image doesn't specify virtualisation type. We allow it
// to match, but prefer exact matches.
return partialMatch
}
return nonMatch
} | [
"func",
"(",
"image",
"Image",
")",
"match",
"(",
"itype",
"InstanceType",
")",
"imageMatch",
"{",
"if",
"!",
"image",
".",
"matchArch",
"(",
"itype",
".",
"Arches",
")",
"{",
"return",
"nonMatch",
"\n",
"}",
"\n",
"if",
"itype",
".",
"VirtType",
"==",... | // match returns true if the image can run on the supplied instance type. | [
"match",
"returns",
"true",
"if",
"the",
"image",
"can",
"run",
"on",
"the",
"supplied",
"instance",
"type",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/instances/image.go#L170-L183 |
3,479 | juju/juju | worker/externalcontrollerupdater/externalcontrollerupdater.go | New | func New(
externalControllers ExternalControllerUpdaterClient,
newExternalControllerWatcherClient NewExternalControllerWatcherClientFunc,
clock clock.Clock,
) (worker.Worker, error) {
w := updaterWorker{
watchExternalControllers: externalControllers.WatchExternalControllers,
externalControllerInfo: externalControllers.ExternalControllerInfo,
setExternalControllerInfo: externalControllers.SetExternalControllerInfo,
newExternalControllerWatcherClient: newExternalControllerWatcherClient,
runner: worker.NewRunner(worker.RunnerParams{
// One of the controller watchers fails should not
// prevent the others from running.
IsFatal: func(error) bool { return false },
// If the API connection fails, try again in 1 minute.
RestartDelay: time.Minute,
Clock: clock,
}),
}
if err := catacomb.Invoke(catacomb.Plan{
Site: &w.catacomb,
Work: w.loop,
Init: []worker.Worker{w.runner},
}); err != nil {
return nil, errors.Trace(err)
}
return &w, nil
} | go | func New(
externalControllers ExternalControllerUpdaterClient,
newExternalControllerWatcherClient NewExternalControllerWatcherClientFunc,
clock clock.Clock,
) (worker.Worker, error) {
w := updaterWorker{
watchExternalControllers: externalControllers.WatchExternalControllers,
externalControllerInfo: externalControllers.ExternalControllerInfo,
setExternalControllerInfo: externalControllers.SetExternalControllerInfo,
newExternalControllerWatcherClient: newExternalControllerWatcherClient,
runner: worker.NewRunner(worker.RunnerParams{
// One of the controller watchers fails should not
// prevent the others from running.
IsFatal: func(error) bool { return false },
// If the API connection fails, try again in 1 minute.
RestartDelay: time.Minute,
Clock: clock,
}),
}
if err := catacomb.Invoke(catacomb.Plan{
Site: &w.catacomb,
Work: w.loop,
Init: []worker.Worker{w.runner},
}); err != nil {
return nil, errors.Trace(err)
}
return &w, nil
} | [
"func",
"New",
"(",
"externalControllers",
"ExternalControllerUpdaterClient",
",",
"newExternalControllerWatcherClient",
"NewExternalControllerWatcherClientFunc",
",",
"clock",
"clock",
".",
"Clock",
",",
")",
"(",
"worker",
".",
"Worker",
",",
"error",
")",
"{",
"w",
... | // New returns a new external controller updater worker. | [
"New",
"returns",
"a",
"new",
"external",
"controller",
"updater",
"worker",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/externalcontrollerupdater/externalcontrollerupdater.go#L58-L86 |
3,480 | juju/juju | provider/common/mocks/availability_zone.go | NewMockAvailabilityZone | func NewMockAvailabilityZone(ctrl *gomock.Controller) *MockAvailabilityZone {
mock := &MockAvailabilityZone{ctrl: ctrl}
mock.recorder = &MockAvailabilityZoneMockRecorder{mock}
return mock
} | go | func NewMockAvailabilityZone(ctrl *gomock.Controller) *MockAvailabilityZone {
mock := &MockAvailabilityZone{ctrl: ctrl}
mock.recorder = &MockAvailabilityZoneMockRecorder{mock}
return mock
} | [
"func",
"NewMockAvailabilityZone",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockAvailabilityZone",
"{",
"mock",
":=",
"&",
"MockAvailabilityZone",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockAvailabilityZoneMockR... | // NewMockAvailabilityZone creates a new mock instance | [
"NewMockAvailabilityZone",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/mocks/availability_zone.go#L24-L28 |
3,481 | juju/juju | provider/common/mocks/availability_zone.go | Available | func (m *MockAvailabilityZone) Available() bool {
ret := m.ctrl.Call(m, "Available")
ret0, _ := ret[0].(bool)
return ret0
} | go | func (m *MockAvailabilityZone) Available() bool {
ret := m.ctrl.Call(m, "Available")
ret0, _ := ret[0].(bool)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAvailabilityZone",
")",
"Available",
"(",
")",
"bool",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"bool",
")",
"\n... | // Available mocks base method | [
"Available",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/mocks/availability_zone.go#L36-L40 |
3,482 | juju/juju | provider/common/mocks/availability_zone.go | Available | func (mr *MockAvailabilityZoneMockRecorder) Available() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Available", reflect.TypeOf((*MockAvailabilityZone)(nil).Available))
} | go | func (mr *MockAvailabilityZoneMockRecorder) Available() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Available", reflect.TypeOf((*MockAvailabilityZone)(nil).Available))
} | [
"func",
"(",
"mr",
"*",
"MockAvailabilityZoneMockRecorder",
")",
"Available",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
"... | // Available indicates an expected call of Available | [
"Available",
"indicates",
"an",
"expected",
"call",
"of",
"Available"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/mocks/availability_zone.go#L43-L45 |
3,483 | juju/juju | apiserver/logsink/mocks/metrics_collector_mock.go | NewMockMetricsCollector | func NewMockMetricsCollector(ctrl *gomock.Controller) *MockMetricsCollector {
mock := &MockMetricsCollector{ctrl: ctrl}
mock.recorder = &MockMetricsCollectorMockRecorder{mock}
return mock
} | go | func NewMockMetricsCollector(ctrl *gomock.Controller) *MockMetricsCollector {
mock := &MockMetricsCollector{ctrl: ctrl}
mock.recorder = &MockMetricsCollectorMockRecorder{mock}
return mock
} | [
"func",
"NewMockMetricsCollector",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockMetricsCollector",
"{",
"mock",
":=",
"&",
"MockMetricsCollector",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockMetricsCollectorMockR... | // NewMockMetricsCollector creates a new mock instance | [
"NewMockMetricsCollector",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/logsink/mocks/metrics_collector_mock.go#L25-L29 |
3,484 | juju/juju | apiserver/logsink/mocks/metrics_collector_mock.go | Connections | func (m *MockMetricsCollector) Connections() prometheus.Gauge {
ret := m.ctrl.Call(m, "Connections")
ret0, _ := ret[0].(prometheus.Gauge)
return ret0
} | go | func (m *MockMetricsCollector) Connections() prometheus.Gauge {
ret := m.ctrl.Call(m, "Connections")
ret0, _ := ret[0].(prometheus.Gauge)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockMetricsCollector",
")",
"Connections",
"(",
")",
"prometheus",
".",
"Gauge",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"... | // Connections mocks base method | [
"Connections",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/logsink/mocks/metrics_collector_mock.go#L37-L41 |
3,485 | juju/juju | apiserver/logsink/mocks/metrics_collector_mock.go | LogReadCount | func (m *MockMetricsCollector) LogReadCount(arg0, arg1 string) prometheus.Counter {
ret := m.ctrl.Call(m, "LogReadCount", arg0, arg1)
ret0, _ := ret[0].(prometheus.Counter)
return ret0
} | go | func (m *MockMetricsCollector) LogReadCount(arg0, arg1 string) prometheus.Counter {
ret := m.ctrl.Call(m, "LogReadCount", arg0, arg1)
ret0, _ := ret[0].(prometheus.Counter)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockMetricsCollector",
")",
"LogReadCount",
"(",
"arg0",
",",
"arg1",
"string",
")",
"prometheus",
".",
"Counter",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
",",
"arg1",
")",
"\... | // LogReadCount mocks base method | [
"LogReadCount",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/logsink/mocks/metrics_collector_mock.go#L49-L53 |
3,486 | juju/juju | apiserver/logsink/mocks/metrics_collector_mock.go | LogReadCount | func (mr *MockMetricsCollectorMockRecorder) LogReadCount(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogReadCount", reflect.TypeOf((*MockMetricsCollector)(nil).LogReadCount), arg0, arg1)
} | go | func (mr *MockMetricsCollectorMockRecorder) LogReadCount(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LogReadCount", reflect.TypeOf((*MockMetricsCollector)(nil).LogReadCount), arg0, arg1)
} | [
"func",
"(",
"mr",
"*",
"MockMetricsCollectorMockRecorder",
")",
"LogReadCount",
"(",
"arg0",
",",
"arg1",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".... | // LogReadCount indicates an expected call of LogReadCount | [
"LogReadCount",
"indicates",
"an",
"expected",
"call",
"of",
"LogReadCount"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/logsink/mocks/metrics_collector_mock.go#L56-L58 |
3,487 | juju/juju | apiserver/logsink/mocks/metrics_collector_mock.go | PingFailureCount | func (m *MockMetricsCollector) PingFailureCount(arg0 string) prometheus.Counter {
ret := m.ctrl.Call(m, "PingFailureCount", arg0)
ret0, _ := ret[0].(prometheus.Counter)
return ret0
} | go | func (m *MockMetricsCollector) PingFailureCount(arg0 string) prometheus.Counter {
ret := m.ctrl.Call(m, "PingFailureCount", arg0)
ret0, _ := ret[0].(prometheus.Counter)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockMetricsCollector",
")",
"PingFailureCount",
"(",
"arg0",
"string",
")",
"prometheus",
".",
"Counter",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
... | // PingFailureCount mocks base method | [
"PingFailureCount",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/logsink/mocks/metrics_collector_mock.go#L73-L77 |
3,488 | juju/juju | apiserver/logsink/mocks/metrics_collector_mock.go | TotalConnections | func (m *MockMetricsCollector) TotalConnections() prometheus.Counter {
ret := m.ctrl.Call(m, "TotalConnections")
ret0, _ := ret[0].(prometheus.Counter)
return ret0
} | go | func (m *MockMetricsCollector) TotalConnections() prometheus.Counter {
ret := m.ctrl.Call(m, "TotalConnections")
ret0, _ := ret[0].(prometheus.Counter)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockMetricsCollector",
")",
"TotalConnections",
"(",
")",
"prometheus",
".",
"Counter",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
"... | // TotalConnections mocks base method | [
"TotalConnections",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/logsink/mocks/metrics_collector_mock.go#L85-L89 |
3,489 | juju/juju | worker/applicationscaler/shim.go | NewFacade | func NewFacade(apiCaller base.APICaller) (Facade, error) {
return applicationscaler.NewAPI(
apiCaller,
watcher.NewStringsWatcher,
), nil
} | go | func NewFacade(apiCaller base.APICaller) (Facade, error) {
return applicationscaler.NewAPI(
apiCaller,
watcher.NewStringsWatcher,
), nil
} | [
"func",
"NewFacade",
"(",
"apiCaller",
"base",
".",
"APICaller",
")",
"(",
"Facade",
",",
"error",
")",
"{",
"return",
"applicationscaler",
".",
"NewAPI",
"(",
"apiCaller",
",",
"watcher",
".",
"NewStringsWatcher",
",",
")",
",",
"nil",
"\n",
"}"
] | // NewFacade creates a Facade from a base.APICaller.
// It's a sensible value for ManifoldConfig.NewFacade. | [
"NewFacade",
"creates",
"a",
"Facade",
"from",
"a",
"base",
".",
"APICaller",
".",
"It",
"s",
"a",
"sensible",
"value",
"for",
"ManifoldConfig",
".",
"NewFacade",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/applicationscaler/shim.go#L14-L19 |
3,490 | juju/juju | worker/raft/rafttransport/streamlayer.go | Close | func (l *streamLayer) Close() error {
l.tomb.Kill(nil)
return l.tomb.Wait()
} | go | func (l *streamLayer) Close() error {
l.tomb.Kill(nil)
return l.tomb.Wait()
} | [
"func",
"(",
"l",
"*",
"streamLayer",
")",
"Close",
"(",
")",
"error",
"{",
"l",
".",
"tomb",
".",
"Kill",
"(",
"nil",
")",
"\n",
"return",
"l",
".",
"tomb",
".",
"Wait",
"(",
")",
"\n",
"}"
] | // Close closes the layer. | [
"Close",
"closes",
"the",
"layer",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/raft/rafttransport/streamlayer.go#L108-L111 |
3,491 | juju/juju | worker/raft/rafttransport/streamlayer.go | Addr | func (l *streamLayer) Addr() net.Addr {
select {
case <-l.tomb.Dying():
return invalidAddr
case <-l.clock.After(AddrTimeout):
logger.Errorf("streamLayer.Addr timed out waiting for API address")
// Stop this (and parent) worker.
l.tomb.Kill(ErrAddressTimeout)
return invalidAddr
case addr := <-l.addr:
return addr
}
} | go | func (l *streamLayer) Addr() net.Addr {
select {
case <-l.tomb.Dying():
return invalidAddr
case <-l.clock.After(AddrTimeout):
logger.Errorf("streamLayer.Addr timed out waiting for API address")
// Stop this (and parent) worker.
l.tomb.Kill(ErrAddressTimeout)
return invalidAddr
case addr := <-l.addr:
return addr
}
} | [
"func",
"(",
"l",
"*",
"streamLayer",
")",
"Addr",
"(",
")",
"net",
".",
"Addr",
"{",
"select",
"{",
"case",
"<-",
"l",
".",
"tomb",
".",
"Dying",
"(",
")",
":",
"return",
"invalidAddr",
"\n",
"case",
"<-",
"l",
".",
"clock",
".",
"After",
"(",
... | // Addr returns the local address for the layer. | [
"Addr",
"returns",
"the",
"local",
"address",
"for",
"the",
"layer",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/raft/rafttransport/streamlayer.go#L116-L128 |
3,492 | juju/juju | component/all/resource.go | registerForServer | func (r resources) registerForServer() error {
r.registerState()
r.registerAgentWorkers()
r.registerHookContext()
return nil
} | go | func (r resources) registerForServer() error {
r.registerState()
r.registerAgentWorkers()
r.registerHookContext()
return nil
} | [
"func",
"(",
"r",
"resources",
")",
"registerForServer",
"(",
")",
"error",
"{",
"r",
".",
"registerState",
"(",
")",
"\n",
"r",
".",
"registerAgentWorkers",
"(",
")",
"\n",
"r",
".",
"registerHookContext",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // RegisterForServer is the top-level registration method
// for the component in a jujud context. | [
"RegisterForServer",
"is",
"the",
"top",
"-",
"level",
"registration",
"method",
"for",
"the",
"component",
"in",
"a",
"jujud",
"context",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/component/all/resource.go#L28-L33 |
3,493 | juju/juju | component/all/resource.go | registerAgentWorkers | func (r resources) registerAgentWorkers() {
if !markRegistered(resource.ComponentName, "agent-workers") {
return
}
charmrevisionupdater.RegisterLatestCharmHandler("resources", resourceadapters.NewLatestCharmHandler)
} | go | func (r resources) registerAgentWorkers() {
if !markRegistered(resource.ComponentName, "agent-workers") {
return
}
charmrevisionupdater.RegisterLatestCharmHandler("resources", resourceadapters.NewLatestCharmHandler)
} | [
"func",
"(",
"r",
"resources",
")",
"registerAgentWorkers",
"(",
")",
"{",
"if",
"!",
"markRegistered",
"(",
"resource",
".",
"ComponentName",
",",
"\"",
"\"",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"charmrevisionupdater",
".",
"RegisterLatestCharmHandler",
"(... | // registerAgentWorkers adds the resources workers to the agents. | [
"registerAgentWorkers",
"adds",
"the",
"resources",
"workers",
"to",
"the",
"agents",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/component/all/resource.go#L44-L50 |
3,494 | juju/juju | provider/common/mocks/zoned_environ.go | NewMockZonedEnviron | func NewMockZonedEnviron(ctrl *gomock.Controller) *MockZonedEnviron {
mock := &MockZonedEnviron{ctrl: ctrl}
mock.recorder = &MockZonedEnvironMockRecorder{mock}
return mock
} | go | func NewMockZonedEnviron(ctrl *gomock.Controller) *MockZonedEnviron {
mock := &MockZonedEnviron{ctrl: ctrl}
mock.recorder = &MockZonedEnvironMockRecorder{mock}
return mock
} | [
"func",
"NewMockZonedEnviron",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockZonedEnviron",
"{",
"mock",
":=",
"&",
"MockZonedEnviron",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockZonedEnvironMockRecorder",
"{",... | // NewMockZonedEnviron creates a new mock instance | [
"NewMockZonedEnviron",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/mocks/zoned_environ.go#L33-L37 |
3,495 | juju/juju | provider/common/mocks/zoned_environ.go | AdoptResources | func (m *MockZonedEnviron) AdoptResources(arg0 context.ProviderCallContext, arg1 string, arg2 version.Number) error {
ret := m.ctrl.Call(m, "AdoptResources", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockZonedEnviron) AdoptResources(arg0 context.ProviderCallContext, arg1 string, arg2 version.Number) error {
ret := m.ctrl.Call(m, "AdoptResources", arg0, arg1, arg2)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockZonedEnviron",
")",
"AdoptResources",
"(",
"arg0",
"context",
".",
"ProviderCallContext",
",",
"arg1",
"string",
",",
"arg2",
"version",
".",
"Number",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
... | // AdoptResources mocks base method | [
"AdoptResources",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/mocks/zoned_environ.go#L45-L49 |
3,496 | juju/juju | provider/common/mocks/zoned_environ.go | AvailabilityZones | func (m *MockZonedEnviron) AvailabilityZones(arg0 context.ProviderCallContext) ([]common.AvailabilityZone, error) {
ret := m.ctrl.Call(m, "AvailabilityZones", arg0)
ret0, _ := ret[0].([]common.AvailabilityZone)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockZonedEnviron) AvailabilityZones(arg0 context.ProviderCallContext) ([]common.AvailabilityZone, error) {
ret := m.ctrl.Call(m, "AvailabilityZones", arg0)
ret0, _ := ret[0].([]common.AvailabilityZone)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockZonedEnviron",
")",
"AvailabilityZones",
"(",
"arg0",
"context",
".",
"ProviderCallContext",
")",
"(",
"[",
"]",
"common",
".",
"AvailabilityZone",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
... | // AvailabilityZones mocks base method | [
"AvailabilityZones",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/mocks/zoned_environ.go#L70-L75 |
3,497 | juju/juju | provider/common/mocks/zoned_environ.go | ConstraintsValidator | func (m *MockZonedEnviron) ConstraintsValidator(arg0 context.ProviderCallContext) (constraints.Validator, error) {
ret := m.ctrl.Call(m, "ConstraintsValidator", arg0)
ret0, _ := ret[0].(constraints.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockZonedEnviron) ConstraintsValidator(arg0 context.ProviderCallContext) (constraints.Validator, error) {
ret := m.ctrl.Call(m, "ConstraintsValidator", arg0)
ret0, _ := ret[0].(constraints.Validator)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockZonedEnviron",
")",
"ConstraintsValidator",
"(",
"arg0",
"context",
".",
"ProviderCallContext",
")",
"(",
"constraints",
".",
"Validator",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\""... | // ConstraintsValidator mocks base method | [
"ConstraintsValidator",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/mocks/zoned_environ.go#L108-L113 |
3,498 | juju/juju | provider/common/mocks/zoned_environ.go | DeriveAvailabilityZones | func (m *MockZonedEnviron) DeriveAvailabilityZones(arg0 context.ProviderCallContext, arg1 environs.StartInstanceParams) ([]string, error) {
ret := m.ctrl.Call(m, "DeriveAvailabilityZones", arg0, arg1)
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockZonedEnviron) DeriveAvailabilityZones(arg0 context.ProviderCallContext, arg1 environs.StartInstanceParams) ([]string, error) {
ret := m.ctrl.Call(m, "DeriveAvailabilityZones", arg0, arg1)
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockZonedEnviron",
")",
"DeriveAvailabilityZones",
"(",
"arg0",
"context",
".",
"ProviderCallContext",
",",
"arg1",
"environs",
".",
"StartInstanceParams",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
... | // DeriveAvailabilityZones mocks base method | [
"DeriveAvailabilityZones",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/mocks/zoned_environ.go#L146-L151 |
3,499 | juju/juju | provider/common/mocks/zoned_environ.go | Destroy | func (m *MockZonedEnviron) Destroy(arg0 context.ProviderCallContext) error {
ret := m.ctrl.Call(m, "Destroy", arg0)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockZonedEnviron) Destroy(arg0 context.ProviderCallContext) error {
ret := m.ctrl.Call(m, "Destroy", arg0)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockZonedEnviron",
")",
"Destroy",
"(",
"arg0",
"context",
".",
"ProviderCallContext",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",... | // Destroy mocks base method | [
"Destroy",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/mocks/zoned_environ.go#L159-L163 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.