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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
155,100 | juju/juju | provider/maas/maas2storage.go | URL | func (stor *maas2Storage) URL(name string) (string, error) {
name = stor.prefixWithPrivateNamespace(name)
file, err := stor.maasController.GetFile(name)
if err != nil {
return "", errors.Trace(err)
}
return file.AnonymousURL(), nil
} | go | func (stor *maas2Storage) URL(name string) (string, error) {
name = stor.prefixWithPrivateNamespace(name)
file, err := stor.maasController.GetFile(name)
if err != nil {
return "", errors.Trace(err)
}
return file.AnonymousURL(), nil
} | [
"func",
"(",
"stor",
"*",
"maas2Storage",
")",
"URL",
"(",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"name",
"=",
"stor",
".",
"prefixWithPrivateNamespace",
"(",
"name",
")",
"\n",
"file",
",",
"err",
":=",
"stor",
".",
"maasControl... | // URL implements storage.StorageReader | [
"URL",
"implements",
"storage",
".",
"StorageReader"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/maas/maas2storage.go#L69-L76 |
155,101 | juju/juju | provider/maas/maas2storage.go | Put | func (stor *maas2Storage) Put(name string, r io.Reader, length int64) error {
name = stor.prefixWithPrivateNamespace(name)
args := gomaasapi.AddFileArgs{Filename: name, Reader: r, Length: length}
return stor.maasController.AddFile(args)
} | go | func (stor *maas2Storage) Put(name string, r io.Reader, length int64) error {
name = stor.prefixWithPrivateNamespace(name)
args := gomaasapi.AddFileArgs{Filename: name, Reader: r, Length: length}
return stor.maasController.AddFile(args)
} | [
"func",
"(",
"stor",
"*",
"maas2Storage",
")",
"Put",
"(",
"name",
"string",
",",
"r",
"io",
".",
"Reader",
",",
"length",
"int64",
")",
"error",
"{",
"name",
"=",
"stor",
".",
"prefixWithPrivateNamespace",
"(",
"name",
")",
"\n",
"args",
":=",
"gomaas... | // Put implements storage.StorageWriter | [
"Put",
"implements",
"storage",
".",
"StorageWriter"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/maas/maas2storage.go#L91-L95 |
155,102 | juju/juju | provider/maas/maas2storage.go | Remove | func (stor *maas2Storage) Remove(name string) error {
name = stor.prefixWithPrivateNamespace(name)
file, err := stor.maasController.GetFile(name)
if err != nil {
return errors.Trace(err)
}
return file.Delete()
} | go | func (stor *maas2Storage) Remove(name string) error {
name = stor.prefixWithPrivateNamespace(name)
file, err := stor.maasController.GetFile(name)
if err != nil {
return errors.Trace(err)
}
return file.Delete()
} | [
"func",
"(",
"stor",
"*",
"maas2Storage",
")",
"Remove",
"(",
"name",
"string",
")",
"error",
"{",
"name",
"=",
"stor",
".",
"prefixWithPrivateNamespace",
"(",
"name",
")",
"\n",
"file",
",",
"err",
":=",
"stor",
".",
"maasController",
".",
"GetFile",
"(... | // Remove implements storage.StorageWriter | [
"Remove",
"implements",
"storage",
".",
"StorageWriter"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/maas/maas2storage.go#L98-L105 |
155,103 | juju/juju | cmd/juju/caas/aks.go | listResourceGroups | func (a *aks) listResourceGroups(clusters []cluster) ([]resourceGroupDetails, error) {
usedRG := set.Strings{}
for _, c := range clusters {
usedRG.Add(c.resourceGroup)
}
// It seems that any resource group that has a non-null 'managedBy' is a
// generated RG i.e. via the creation of the cluster itself.
cmd := []string{
"az", "group", "list",
"--output", "json",
"--query", `"[?properties.provisioningState=='Succeeded']"`,
}
result, err := runCommand(a, cmd, "")
err = collapseRunError(result, err)
if err != nil {
return nil, errors.Trace(err)
}
var groups []resourceGroupDetails
if err := json.Unmarshal(result.Stdout, &groups); err != nil {
return nil, errors.Trace(err)
}
var filteredGroups []resourceGroupDetails
for _, group := range groups {
if usedRG.Contains(group.Name) {
filteredGroups = append(filteredGroups, group)
}
}
return filteredGroups, nil
} | go | func (a *aks) listResourceGroups(clusters []cluster) ([]resourceGroupDetails, error) {
usedRG := set.Strings{}
for _, c := range clusters {
usedRG.Add(c.resourceGroup)
}
// It seems that any resource group that has a non-null 'managedBy' is a
// generated RG i.e. via the creation of the cluster itself.
cmd := []string{
"az", "group", "list",
"--output", "json",
"--query", `"[?properties.provisioningState=='Succeeded']"`,
}
result, err := runCommand(a, cmd, "")
err = collapseRunError(result, err)
if err != nil {
return nil, errors.Trace(err)
}
var groups []resourceGroupDetails
if err := json.Unmarshal(result.Stdout, &groups); err != nil {
return nil, errors.Trace(err)
}
var filteredGroups []resourceGroupDetails
for _, group := range groups {
if usedRG.Contains(group.Name) {
filteredGroups = append(filteredGroups, group)
}
}
return filteredGroups, nil
} | [
"func",
"(",
"a",
"*",
"aks",
")",
"listResourceGroups",
"(",
"clusters",
"[",
"]",
"cluster",
")",
"(",
"[",
"]",
"resourceGroupDetails",
",",
"error",
")",
"{",
"usedRG",
":=",
"set",
".",
"Strings",
"{",
"}",
"\n",
"for",
"_",
",",
"c",
":=",
"r... | // will list resource groups used by the passed clusters | [
"will",
"list",
"resource",
"groups",
"used",
"by",
"the",
"passed",
"clusters"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/caas/aks.go#L171-L202 |
155,104 | juju/juju | worker/containerbroker/mocks/agent_mock.go | NewMockAgent | func NewMockAgent(ctrl *gomock.Controller) *MockAgent {
mock := &MockAgent{ctrl: ctrl}
mock.recorder = &MockAgentMockRecorder{mock}
return mock
} | go | func NewMockAgent(ctrl *gomock.Controller) *MockAgent {
mock := &MockAgent{ctrl: ctrl}
mock.recorder = &MockAgentMockRecorder{mock}
return mock
} | [
"func",
"NewMockAgent",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockAgent",
"{",
"mock",
":=",
"&",
"MockAgent",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockAgentMockRecorder",
"{",
"mock",
"}",
"\n",
... | // NewMockAgent creates a new mock instance | [
"NewMockAgent",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L32-L36 |
155,105 | juju/juju | worker/containerbroker/mocks/agent_mock.go | ChangeConfig | func (m *MockAgent) ChangeConfig(arg0 agent.ConfigMutator) error {
ret := m.ctrl.Call(m, "ChangeConfig", arg0)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockAgent) ChangeConfig(arg0 agent.ConfigMutator) error {
ret := m.ctrl.Call(m, "ChangeConfig", arg0)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAgent",
")",
"ChangeConfig",
"(",
"arg0",
"agent",
".",
"ConfigMutator",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
... | // ChangeConfig mocks base method | [
"ChangeConfig",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L44-L48 |
155,106 | juju/juju | worker/containerbroker/mocks/agent_mock.go | ChangeConfig | func (mr *MockAgentMockRecorder) ChangeConfig(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeConfig", reflect.TypeOf((*MockAgent)(nil).ChangeConfig), arg0)
} | go | func (mr *MockAgentMockRecorder) ChangeConfig(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeConfig", reflect.TypeOf((*MockAgent)(nil).ChangeConfig), arg0)
} | [
"func",
"(",
"mr",
"*",
"MockAgentMockRecorder",
")",
"ChangeConfig",
"(",
"arg0",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
... | // ChangeConfig indicates an expected call of ChangeConfig | [
"ChangeConfig",
"indicates",
"an",
"expected",
"call",
"of",
"ChangeConfig"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L51-L53 |
155,107 | juju/juju | worker/containerbroker/mocks/agent_mock.go | CurrentConfig | func (m *MockAgent) CurrentConfig() agent.Config {
ret := m.ctrl.Call(m, "CurrentConfig")
ret0, _ := ret[0].(agent.Config)
return ret0
} | go | func (m *MockAgent) CurrentConfig() agent.Config {
ret := m.ctrl.Call(m, "CurrentConfig")
ret0, _ := ret[0].(agent.Config)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAgent",
")",
"CurrentConfig",
"(",
")",
"agent",
".",
"Config",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"agent"... | // CurrentConfig mocks base method | [
"CurrentConfig",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L56-L60 |
155,108 | juju/juju | worker/containerbroker/mocks/agent_mock.go | NewMockConfig | func NewMockConfig(ctrl *gomock.Controller) *MockConfig {
mock := &MockConfig{ctrl: ctrl}
mock.recorder = &MockConfigMockRecorder{mock}
return mock
} | go | func NewMockConfig(ctrl *gomock.Controller) *MockConfig {
mock := &MockConfig{ctrl: ctrl}
mock.recorder = &MockConfigMockRecorder{mock}
return mock
} | [
"func",
"NewMockConfig",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockConfig",
"{",
"mock",
":=",
"&",
"MockConfig",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockConfigMockRecorder",
"{",
"mock",
"}",
"\n"... | // NewMockConfig creates a new mock instance | [
"NewMockConfig",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L79-L83 |
155,109 | juju/juju | worker/containerbroker/mocks/agent_mock.go | APIAddresses | func (m *MockConfig) APIAddresses() ([]string, error) {
ret := m.ctrl.Call(m, "APIAddresses")
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockConfig) APIAddresses() ([]string, error) {
ret := m.ctrl.Call(m, "APIAddresses")
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"APIAddresses",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
... | // APIAddresses mocks base method | [
"APIAddresses",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L91-L96 |
155,110 | juju/juju | worker/containerbroker/mocks/agent_mock.go | APIAddresses | func (mr *MockConfigMockRecorder) APIAddresses() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "APIAddresses", reflect.TypeOf((*MockConfig)(nil).APIAddresses))
} | go | func (mr *MockConfigMockRecorder) APIAddresses() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "APIAddresses", reflect.TypeOf((*MockConfig)(nil).APIAddresses))
} | [
"func",
"(",
"mr",
"*",
"MockConfigMockRecorder",
")",
"APIAddresses",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"... | // APIAddresses indicates an expected call of APIAddresses | [
"APIAddresses",
"indicates",
"an",
"expected",
"call",
"of",
"APIAddresses"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L99-L101 |
155,111 | juju/juju | worker/containerbroker/mocks/agent_mock.go | APIInfo | func (m *MockConfig) APIInfo() (*api.Info, bool) {
ret := m.ctrl.Call(m, "APIInfo")
ret0, _ := ret[0].(*api.Info)
ret1, _ := ret[1].(bool)
return ret0, ret1
} | go | func (m *MockConfig) APIInfo() (*api.Info, bool) {
ret := m.ctrl.Call(m, "APIInfo")
ret0, _ := ret[0].(*api.Info)
ret1, _ := ret[1].(bool)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"APIInfo",
"(",
")",
"(",
"*",
"api",
".",
"Info",
",",
"bool",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
... | // APIInfo mocks base method | [
"APIInfo",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L104-L109 |
155,112 | juju/juju | worker/containerbroker/mocks/agent_mock.go | Jobs | func (m *MockConfig) Jobs() []multiwatcher.MachineJob {
ret := m.ctrl.Call(m, "Jobs")
ret0, _ := ret[0].([]multiwatcher.MachineJob)
return ret0
} | go | func (m *MockConfig) Jobs() []multiwatcher.MachineJob {
ret := m.ctrl.Call(m, "Jobs")
ret0, _ := ret[0].([]multiwatcher.MachineJob)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"Jobs",
"(",
")",
"[",
"]",
"multiwatcher",
".",
"MachineJob",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",... | // Jobs mocks base method | [
"Jobs",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L165-L169 |
155,113 | juju/juju | worker/containerbroker/mocks/agent_mock.go | MongoInfo | func (m *MockConfig) MongoInfo() (*mongo.MongoInfo, bool) {
ret := m.ctrl.Call(m, "MongoInfo")
ret0, _ := ret[0].(*mongo.MongoInfo)
ret1, _ := ret[1].(bool)
return ret0, ret1
} | go | func (m *MockConfig) MongoInfo() (*mongo.MongoInfo, bool) {
ret := m.ctrl.Call(m, "MongoInfo")
ret0, _ := ret[0].(*mongo.MongoInfo)
ret1, _ := ret[1].(bool)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"MongoInfo",
"(",
")",
"(",
"*",
"mongo",
".",
"MongoInfo",
",",
"bool",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",... | // MongoInfo mocks base method | [
"MongoInfo",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L225-L230 |
155,114 | juju/juju | worker/containerbroker/mocks/agent_mock.go | MongoMemoryProfile | func (m *MockConfig) MongoMemoryProfile() mongo.MemoryProfile {
ret := m.ctrl.Call(m, "MongoMemoryProfile")
ret0, _ := ret[0].(mongo.MemoryProfile)
return ret0
} | go | func (m *MockConfig) MongoMemoryProfile() mongo.MemoryProfile {
ret := m.ctrl.Call(m, "MongoMemoryProfile")
ret0, _ := ret[0].(mongo.MemoryProfile)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"MongoMemoryProfile",
"(",
")",
"mongo",
".",
"MemoryProfile",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"... | // MongoMemoryProfile mocks base method | [
"MongoMemoryProfile",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L238-L242 |
155,115 | juju/juju | worker/containerbroker/mocks/agent_mock.go | MongoVersion | func (m *MockConfig) MongoVersion() mongo.Version {
ret := m.ctrl.Call(m, "MongoVersion")
ret0, _ := ret[0].(mongo.Version)
return ret0
} | go | func (m *MockConfig) MongoVersion() mongo.Version {
ret := m.ctrl.Call(m, "MongoVersion")
ret0, _ := ret[0].(mongo.Version)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"MongoVersion",
"(",
")",
"mongo",
".",
"Version",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"mongo... | // MongoVersion mocks base method | [
"MongoVersion",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L250-L254 |
155,116 | juju/juju | worker/containerbroker/mocks/agent_mock.go | StateServingInfo | func (m *MockConfig) StateServingInfo() (params.StateServingInfo, bool) {
ret := m.ctrl.Call(m, "StateServingInfo")
ret0, _ := ret[0].(params.StateServingInfo)
ret1, _ := ret[1].(bool)
return ret0, ret1
} | go | func (m *MockConfig) StateServingInfo() (params.StateServingInfo, bool) {
ret := m.ctrl.Call(m, "StateServingInfo")
ret0, _ := ret[0].(params.StateServingInfo)
ret1, _ := ret[1].(bool)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"StateServingInfo",
"(",
")",
"(",
"params",
".",
"StateServingInfo",
",",
"bool",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret"... | // StateServingInfo mocks base method | [
"StateServingInfo",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L286-L291 |
155,117 | juju/juju | worker/containerbroker/mocks/agent_mock.go | SystemIdentityPath | func (m *MockConfig) SystemIdentityPath() string {
ret := m.ctrl.Call(m, "SystemIdentityPath")
ret0, _ := ret[0].(string)
return ret0
} | go | func (m *MockConfig) SystemIdentityPath() string {
ret := m.ctrl.Call(m, "SystemIdentityPath")
ret0, _ := ret[0].(string)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"SystemIdentityPath",
"(",
")",
"string",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"string",
")",
... | // SystemIdentityPath mocks base method | [
"SystemIdentityPath",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L299-L303 |
155,118 | juju/juju | worker/containerbroker/mocks/agent_mock.go | UpgradedToVersion | func (m *MockConfig) UpgradedToVersion() version.Number {
ret := m.ctrl.Call(m, "UpgradedToVersion")
ret0, _ := ret[0].(version.Number)
return ret0
} | go | func (m *MockConfig) UpgradedToVersion() version.Number {
ret := m.ctrl.Call(m, "UpgradedToVersion")
ret0, _ := ret[0].(version.Number)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"UpgradedToVersion",
"(",
")",
"version",
".",
"Number",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
... | // UpgradedToVersion mocks base method | [
"UpgradedToVersion",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L323-L327 |
155,119 | juju/juju | worker/containerbroker/mocks/agent_mock.go | Value | func (m *MockConfig) Value(arg0 string) string {
ret := m.ctrl.Call(m, "Value", arg0)
ret0, _ := ret[0].(string)
return ret0
} | go | func (m *MockConfig) Value(arg0 string) string {
ret := m.ctrl.Call(m, "Value", arg0)
ret0, _ := ret[0].(string)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"Value",
"(",
"arg0",
"string",
")",
"string",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
... | // Value mocks base method | [
"Value",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L335-L339 |
155,120 | juju/juju | worker/containerbroker/mocks/agent_mock.go | Value | func (mr *MockConfigMockRecorder) Value(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Value", reflect.TypeOf((*MockConfig)(nil).Value), arg0)
} | go | func (mr *MockConfigMockRecorder) Value(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Value", reflect.TypeOf((*MockConfig)(nil).Value), arg0)
} | [
"func",
"(",
"mr",
"*",
"MockConfigMockRecorder",
")",
"Value",
"(",
"arg0",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\""... | // Value indicates an expected call of Value | [
"Value",
"indicates",
"an",
"expected",
"call",
"of",
"Value"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L342-L344 |
155,121 | juju/juju | worker/containerbroker/mocks/agent_mock.go | WriteCommands | func (m *MockConfig) WriteCommands(arg0 shell.Renderer) ([]string, error) {
ret := m.ctrl.Call(m, "WriteCommands", arg0)
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockConfig) WriteCommands(arg0 shell.Renderer) ([]string, error) {
ret := m.ctrl.Call(m, "WriteCommands", arg0)
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockConfig",
")",
"WriteCommands",
"(",
"arg0",
"shell",
".",
"Renderer",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n... | // WriteCommands mocks base method | [
"WriteCommands",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/agent_mock.go#L347-L352 |
155,122 | juju/juju | state/restore.go | Validate | func (status RestoreStatus) Validate() error {
switch status {
case RestorePending, RestoreInProgress, RestoreFinished:
case RestoreChecked, RestoreFailed, RestoreNotActive:
default:
return errors.Errorf("unknown restore status: %v", status)
}
return nil
} | go | func (status RestoreStatus) Validate() error {
switch status {
case RestorePending, RestoreInProgress, RestoreFinished:
case RestoreChecked, RestoreFailed, RestoreNotActive:
default:
return errors.Errorf("unknown restore status: %v", status)
}
return nil
} | [
"func",
"(",
"status",
"RestoreStatus",
")",
"Validate",
"(",
")",
"error",
"{",
"switch",
"status",
"{",
"case",
"RestorePending",
",",
"RestoreInProgress",
",",
"RestoreFinished",
":",
"case",
"RestoreChecked",
",",
"RestoreFailed",
",",
"RestoreNotActive",
":",... | // Validate returns an errors if status' value is not known. | [
"Validate",
"returns",
"an",
"errors",
"if",
"status",
"value",
"is",
"not",
"known",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/restore.go#L18-L26 |
155,123 | juju/juju | state/restore.go | Status | func (info *RestoreInfo) Status() (RestoreStatus, error) {
restoreInfo, closer := info.st.db().GetCollection(restoreInfoC)
defer closer()
var doc struct {
Status RestoreStatus `bson:"status"`
}
err := restoreInfo.FindId(currentRestoreId).One(&doc)
switch errors.Cause(err) {
case nil:
case mgo.ErrNotFound:
return RestoreNotActive, nil
default:
return "", errors.Annotate(err, "cannot read restore info")
}
if err := doc.Status.Validate(); err != nil {
return "", errors.Trace(err)
}
return doc.Status, nil
} | go | func (info *RestoreInfo) Status() (RestoreStatus, error) {
restoreInfo, closer := info.st.db().GetCollection(restoreInfoC)
defer closer()
var doc struct {
Status RestoreStatus `bson:"status"`
}
err := restoreInfo.FindId(currentRestoreId).One(&doc)
switch errors.Cause(err) {
case nil:
case mgo.ErrNotFound:
return RestoreNotActive, nil
default:
return "", errors.Annotate(err, "cannot read restore info")
}
if err := doc.Status.Validate(); err != nil {
return "", errors.Trace(err)
}
return doc.Status, nil
} | [
"func",
"(",
"info",
"*",
"RestoreInfo",
")",
"Status",
"(",
")",
"(",
"RestoreStatus",
",",
"error",
")",
"{",
"restoreInfo",
",",
"closer",
":=",
"info",
".",
"st",
".",
"db",
"(",
")",
".",
"GetCollection",
"(",
"restoreInfoC",
")",
"\n",
"defer",
... | // Status returns the current Restore doc status | [
"Status",
"returns",
"the",
"current",
"Restore",
"doc",
"status"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/restore.go#L65-L85 |
155,124 | juju/juju | state/restore.go | PurgeTxn | func (info *RestoreInfo) PurgeTxn() error {
restoreInfo, closer := info.st.db().GetRawCollection(restoreInfoC)
defer closer()
r := txn.NewRunner(restoreInfo)
return r.PurgeMissing(restoreInfoC)
} | go | func (info *RestoreInfo) PurgeTxn() error {
restoreInfo, closer := info.st.db().GetRawCollection(restoreInfoC)
defer closer()
r := txn.NewRunner(restoreInfo)
return r.PurgeMissing(restoreInfoC)
} | [
"func",
"(",
"info",
"*",
"RestoreInfo",
")",
"PurgeTxn",
"(",
")",
"error",
"{",
"restoreInfo",
",",
"closer",
":=",
"info",
".",
"st",
".",
"db",
"(",
")",
".",
"GetRawCollection",
"(",
"restoreInfoC",
")",
"\n",
"defer",
"closer",
"(",
")",
"\n",
... | // PurgeTxn purges missing transition from restoreInfoC collection.
// These can be caused because this collection is heavy use while backing
// up and mongo 3.2 does not like this. | [
"PurgeTxn",
"purges",
"missing",
"transition",
"from",
"restoreInfoC",
"collection",
".",
"These",
"can",
"be",
"caused",
"because",
"this",
"collection",
"is",
"heavy",
"use",
"while",
"backing",
"up",
"and",
"mongo",
"3",
".",
"2",
"does",
"not",
"like",
"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/restore.go#L90-L95 |
155,125 | juju/juju | state/restore.go | SetStatus | func (info *RestoreInfo) SetStatus(status RestoreStatus) error {
if err := status.Validate(); err != nil {
return errors.Trace(err)
}
buildTxn := func(_ int) ([]txn.Op, error) {
current, err := info.Status()
if err != nil {
return nil, errors.Annotate(err, "cannot read current status")
}
if current == status {
return nil, jujutxn.ErrNoOperations
}
ops, err := setRestoreStatusOps(current, status)
if err != nil {
return nil, errors.Trace(err)
}
return ops, nil
}
if err := info.st.db().Run(buildTxn); err != nil {
return errors.Annotatef(err, "setting status %q", status)
}
return nil
} | go | func (info *RestoreInfo) SetStatus(status RestoreStatus) error {
if err := status.Validate(); err != nil {
return errors.Trace(err)
}
buildTxn := func(_ int) ([]txn.Op, error) {
current, err := info.Status()
if err != nil {
return nil, errors.Annotate(err, "cannot read current status")
}
if current == status {
return nil, jujutxn.ErrNoOperations
}
ops, err := setRestoreStatusOps(current, status)
if err != nil {
return nil, errors.Trace(err)
}
return ops, nil
}
if err := info.st.db().Run(buildTxn); err != nil {
return errors.Annotatef(err, "setting status %q", status)
}
return nil
} | [
"func",
"(",
"info",
"*",
"RestoreInfo",
")",
"SetStatus",
"(",
"status",
"RestoreStatus",
")",
"error",
"{",
"if",
"err",
":=",
"status",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Trace",
"(",
"err",
")",
"\n... | // SetStatus sets the status of the current restore. Checks are made
// to ensure that status changes are performed in the correct order. | [
"SetStatus",
"sets",
"the",
"status",
"of",
"the",
"current",
"restore",
".",
"Checks",
"are",
"made",
"to",
"ensure",
"that",
"status",
"changes",
"are",
"performed",
"in",
"the",
"correct",
"order",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/restore.go#L99-L122 |
155,126 | juju/juju | state/restore.go | setRestoreStatusOps | func setRestoreStatusOps(before, after RestoreStatus) ([]txn.Op, error) {
errInvalid := errors.Errorf("invalid restore transition: %s => %s", before, after)
switch after {
case RestorePending:
switch before {
case RestoreNotActive:
return createRestoreStatusPendingOps(), nil
case RestoreFailed, RestoreChecked:
default:
return nil, errInvalid
}
case RestoreFailed:
switch before {
case RestoreNotActive, RestoreChecked:
return nil, errInvalid
}
case RestoreInProgress:
if before != RestorePending {
return nil, errInvalid
}
case RestoreFinished:
// RestoreFinished is set after a restore so we cannot ensure
// what will be on the db state since it will deppend on
// what was set during backup.
switch before {
case RestoreNotActive:
return createRestoreStatusFinishedOps(), nil
case RestoreFailed:
// except for the case of Failed,this is most likely a race condition.
return nil, errInvalid
}
case RestoreChecked:
if before != RestoreFinished {
return nil, errInvalid
}
default:
return nil, errInvalid
}
return updateRestoreStatusChangeOps(before, after), nil
} | go | func setRestoreStatusOps(before, after RestoreStatus) ([]txn.Op, error) {
errInvalid := errors.Errorf("invalid restore transition: %s => %s", before, after)
switch after {
case RestorePending:
switch before {
case RestoreNotActive:
return createRestoreStatusPendingOps(), nil
case RestoreFailed, RestoreChecked:
default:
return nil, errInvalid
}
case RestoreFailed:
switch before {
case RestoreNotActive, RestoreChecked:
return nil, errInvalid
}
case RestoreInProgress:
if before != RestorePending {
return nil, errInvalid
}
case RestoreFinished:
// RestoreFinished is set after a restore so we cannot ensure
// what will be on the db state since it will deppend on
// what was set during backup.
switch before {
case RestoreNotActive:
return createRestoreStatusFinishedOps(), nil
case RestoreFailed:
// except for the case of Failed,this is most likely a race condition.
return nil, errInvalid
}
case RestoreChecked:
if before != RestoreFinished {
return nil, errInvalid
}
default:
return nil, errInvalid
}
return updateRestoreStatusChangeOps(before, after), nil
} | [
"func",
"setRestoreStatusOps",
"(",
"before",
",",
"after",
"RestoreStatus",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"errInvalid",
":=",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"before",
",",
"after",
")",
"\n",
"switch",
... | // setRestoreStatusOps checks the validity of the supplied transition,
// and returns either an error or a list of transaction operations that
// will apply the transition. | [
"setRestoreStatusOps",
"checks",
"the",
"validity",
"of",
"the",
"supplied",
"transition",
"and",
"returns",
"either",
"an",
"error",
"or",
"a",
"list",
"of",
"transaction",
"operations",
"that",
"will",
"apply",
"the",
"transition",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/restore.go#L127-L167 |
155,127 | juju/juju | state/restore.go | createRestoreStatusFinishedOps | func createRestoreStatusFinishedOps() []txn.Op {
return []txn.Op{{
C: restoreInfoC,
Id: currentRestoreId,
Assert: txn.DocMissing,
Insert: bson.D{{"status", RestoreFinished}},
}}
} | go | func createRestoreStatusFinishedOps() []txn.Op {
return []txn.Op{{
C: restoreInfoC,
Id: currentRestoreId,
Assert: txn.DocMissing,
Insert: bson.D{{"status", RestoreFinished}},
}}
} | [
"func",
"createRestoreStatusFinishedOps",
"(",
")",
"[",
"]",
"txn",
".",
"Op",
"{",
"return",
"[",
"]",
"txn",
".",
"Op",
"{",
"{",
"C",
":",
"restoreInfoC",
",",
"Id",
":",
"currentRestoreId",
",",
"Assert",
":",
"txn",
".",
"DocMissing",
",",
"Inser... | // createRestoreStatusFinishedOps is useful when setting finished on
// a non initated restore document. | [
"createRestoreStatusFinishedOps",
"is",
"useful",
"when",
"setting",
"finished",
"on",
"a",
"non",
"initated",
"restore",
"document",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/restore.go#L171-L178 |
155,128 | juju/juju | state/restore.go | createRestoreStatusPendingOps | func createRestoreStatusPendingOps() []txn.Op {
return []txn.Op{{
C: restoreInfoC,
Id: currentRestoreId,
Assert: txn.DocMissing,
Insert: bson.D{{"status", RestorePending}},
}}
} | go | func createRestoreStatusPendingOps() []txn.Op {
return []txn.Op{{
C: restoreInfoC,
Id: currentRestoreId,
Assert: txn.DocMissing,
Insert: bson.D{{"status", RestorePending}},
}}
} | [
"func",
"createRestoreStatusPendingOps",
"(",
")",
"[",
"]",
"txn",
".",
"Op",
"{",
"return",
"[",
"]",
"txn",
".",
"Op",
"{",
"{",
"C",
":",
"restoreInfoC",
",",
"Id",
":",
"currentRestoreId",
",",
"Assert",
":",
"txn",
".",
"DocMissing",
",",
"Insert... | // createRestoreStatusPendingOps is the only valid way to create a
// restore document. | [
"createRestoreStatusPendingOps",
"is",
"the",
"only",
"valid",
"way",
"to",
"create",
"a",
"restore",
"document",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/restore.go#L182-L189 |
155,129 | juju/juju | state/restore.go | updateRestoreStatusChangeOps | func updateRestoreStatusChangeOps(before, after RestoreStatus) []txn.Op {
return []txn.Op{{
C: restoreInfoC,
Id: currentRestoreId,
Assert: bson.D{{"status", before}},
Update: bson.D{{"$set", bson.D{{"status", after}}}},
}}
} | go | func updateRestoreStatusChangeOps(before, after RestoreStatus) []txn.Op {
return []txn.Op{{
C: restoreInfoC,
Id: currentRestoreId,
Assert: bson.D{{"status", before}},
Update: bson.D{{"$set", bson.D{{"status", after}}}},
}}
} | [
"func",
"updateRestoreStatusChangeOps",
"(",
"before",
",",
"after",
"RestoreStatus",
")",
"[",
"]",
"txn",
".",
"Op",
"{",
"return",
"[",
"]",
"txn",
".",
"Op",
"{",
"{",
"C",
":",
"restoreInfoC",
",",
"Id",
":",
"currentRestoreId",
",",
"Assert",
":",
... | // updateRestoreStatusChangeOps will set the restore doc status to
// after, so long as the doc's status is before. | [
"updateRestoreStatusChangeOps",
"will",
"set",
"the",
"restore",
"doc",
"status",
"to",
"after",
"so",
"long",
"as",
"the",
"doc",
"s",
"status",
"is",
"before",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/restore.go#L193-L200 |
155,130 | juju/juju | state/migration_export.go | ExportPartial | func (st *State) ExportPartial(cfg ExportConfig) (description.Model, error) {
return st.exportImpl(cfg)
} | go | func (st *State) ExportPartial(cfg ExportConfig) (description.Model, error) {
return st.exportImpl(cfg)
} | [
"func",
"(",
"st",
"*",
"State",
")",
"ExportPartial",
"(",
"cfg",
"ExportConfig",
")",
"(",
"description",
".",
"Model",
",",
"error",
")",
"{",
"return",
"st",
".",
"exportImpl",
"(",
"cfg",
")",
"\n",
"}"
] | // ExportPartial the current model for the State optionally skipping
// aspects as defined by the ExportConfig. | [
"ExportPartial",
"the",
"current",
"model",
"for",
"the",
"State",
"optionally",
"skipping",
"aspects",
"as",
"defined",
"by",
"the",
"ExportConfig",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/migration_export.go#L48-L50 |
155,131 | juju/juju | state/migration_export.go | getAnnotations | func (e *exporter) getAnnotations(key string) map[string]string {
result, found := e.annotations[key]
if found {
delete(e.annotations, key)
}
return result.Annotations
} | go | func (e *exporter) getAnnotations(key string) map[string]string {
result, found := e.annotations[key]
if found {
delete(e.annotations, key)
}
return result.Annotations
} | [
"func",
"(",
"e",
"*",
"exporter",
")",
"getAnnotations",
"(",
"key",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"result",
",",
"found",
":=",
"e",
".",
"annotations",
"[",
"key",
"]",
"\n",
"if",
"found",
"{",
"delete",
"(",
"e",
"."... | // getAnnotations doesn't really care if there are any there or not
// for the key, but if they were there, they are removed so we can
// check at the end of the export for anything we have forgotten. | [
"getAnnotations",
"doesn",
"t",
"really",
"care",
"if",
"there",
"are",
"any",
"there",
"or",
"not",
"for",
"the",
"key",
"but",
"if",
"they",
"were",
"there",
"they",
"are",
"removed",
"so",
"we",
"can",
"check",
"at",
"the",
"end",
"of",
"the",
"expo... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/migration_export.go#L1461-L1467 |
155,132 | juju/juju | environs/open.go | New | func New(args OpenParams) (Environ, error) {
p, err := Provider(args.Cloud.Type)
if err != nil {
return nil, errors.Trace(err)
}
return Open(p, args)
} | go | func New(args OpenParams) (Environ, error) {
p, err := Provider(args.Cloud.Type)
if err != nil {
return nil, errors.Trace(err)
}
return Open(p, args)
} | [
"func",
"New",
"(",
"args",
"OpenParams",
")",
"(",
"Environ",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"Provider",
"(",
"args",
".",
"Cloud",
".",
"Type",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Trac... | // New returns a new environment based on the provided configuration. | [
"New",
"returns",
"a",
"new",
"environment",
"based",
"on",
"the",
"provided",
"configuration",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/open.go#L17-L23 |
155,133 | juju/juju | environs/open.go | Open | func Open(p EnvironProvider, args OpenParams) (Environ, error) {
if envProvider, ok := p.(CloudEnvironProvider); !ok {
return nil, errors.NotValidf("cloud environ provider %T", p)
} else {
return envProvider.Open(args)
}
} | go | func Open(p EnvironProvider, args OpenParams) (Environ, error) {
if envProvider, ok := p.(CloudEnvironProvider); !ok {
return nil, errors.NotValidf("cloud environ provider %T", p)
} else {
return envProvider.Open(args)
}
} | [
"func",
"Open",
"(",
"p",
"EnvironProvider",
",",
"args",
"OpenParams",
")",
"(",
"Environ",
",",
"error",
")",
"{",
"if",
"envProvider",
",",
"ok",
":=",
"p",
".",
"(",
"CloudEnvironProvider",
")",
";",
"!",
"ok",
"{",
"return",
"nil",
",",
"errors",
... | // Open creates an Environ instance and errors if the provider is not for a cloud. | [
"Open",
"creates",
"an",
"Environ",
"instance",
"and",
"errors",
"if",
"the",
"provider",
"is",
"not",
"for",
"a",
"cloud",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/open.go#L26-L32 |
155,134 | juju/juju | environs/open.go | Destroy | func Destroy(
controllerName string,
env ControllerDestroyer,
ctx context.ProviderCallContext,
store jujuclient.ControllerStore,
) error {
details, err := store.ControllerByName(controllerName)
if errors.IsNotFound(err) {
// No controller details, nothing to do.
return nil
} else if err != nil {
return errors.Trace(err)
}
if err := env.DestroyController(ctx, details.ControllerUUID); err != nil {
return errors.Trace(err)
}
err = store.RemoveController(controllerName)
if err != nil && !errors.IsNotFound(err) {
return errors.Trace(err)
}
return nil
} | go | func Destroy(
controllerName string,
env ControllerDestroyer,
ctx context.ProviderCallContext,
store jujuclient.ControllerStore,
) error {
details, err := store.ControllerByName(controllerName)
if errors.IsNotFound(err) {
// No controller details, nothing to do.
return nil
} else if err != nil {
return errors.Trace(err)
}
if err := env.DestroyController(ctx, details.ControllerUUID); err != nil {
return errors.Trace(err)
}
err = store.RemoveController(controllerName)
if err != nil && !errors.IsNotFound(err) {
return errors.Trace(err)
}
return nil
} | [
"func",
"Destroy",
"(",
"controllerName",
"string",
",",
"env",
"ControllerDestroyer",
",",
"ctx",
"context",
".",
"ProviderCallContext",
",",
"store",
"jujuclient",
".",
"ControllerStore",
",",
")",
"error",
"{",
"details",
",",
"err",
":=",
"store",
".",
"Co... | // Destroy destroys the controller and, if successful,
// its associated configuration data from the given store. | [
"Destroy",
"destroys",
"the",
"controller",
"and",
"if",
"successful",
"its",
"associated",
"configuration",
"data",
"from",
"the",
"given",
"store",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/open.go#L36-L57 |
155,135 | juju/juju | cmd/juju/application/deploy.go | NewDeployCommand | func NewDeployCommand() modelcmd.ModelCommand {
steps := []DeployStep{
&RegisterMeteredCharm{
PlanURL: romulus.DefaultAPIRoot,
RegisterPath: "/plan/authorize",
QueryPath: "/charm",
},
&ValidateLXDProfileCharm{},
}
deployCmd := &DeployCommand{
Steps: steps,
}
deployCmd.NewAPIRoot = func() (DeployAPI, error) {
apiRoot, err := deployCmd.ModelCommandBase.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
controllerAPIRoot, err := deployCmd.NewControllerAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
csURL, err := getCharmStoreAPIURL(controllerAPIRoot)
if err != nil {
return nil, errors.Trace(err)
}
mURL, err := deployCmd.getMeteringAPIURL(controllerAPIRoot)
if err != nil {
return nil, errors.Trace(err)
}
bakeryClient, err := deployCmd.BakeryClient()
if err != nil {
return nil, errors.Trace(err)
}
cstoreClient := newCharmStoreClient(bakeryClient, csURL).WithChannel(deployCmd.Channel)
return &deployAPIAdapter{
Connection: apiRoot,
apiClient: &apiClient{Client: apiRoot.Client()},
charmsClient: &charmsClient{Client: apicharms.NewClient(apiRoot)},
applicationClient: &applicationClient{Client: application.NewClient(apiRoot)},
modelConfigClient: &modelConfigClient{Client: modelconfig.NewClient(apiRoot)},
charmstoreClient: &charmstoreClient{&charmstoreClientShim{cstoreClient}},
annotationsClient: &annotationsClient{Client: annotations.NewClient(apiRoot)},
charmRepoClient: &charmRepoClient{charmrepo.NewCharmStoreFromClient(cstoreClient)},
plansClient: &plansClient{planURL: mURL},
}, nil
}
return modelcmd.Wrap(deployCmd)
} | go | func NewDeployCommand() modelcmd.ModelCommand {
steps := []DeployStep{
&RegisterMeteredCharm{
PlanURL: romulus.DefaultAPIRoot,
RegisterPath: "/plan/authorize",
QueryPath: "/charm",
},
&ValidateLXDProfileCharm{},
}
deployCmd := &DeployCommand{
Steps: steps,
}
deployCmd.NewAPIRoot = func() (DeployAPI, error) {
apiRoot, err := deployCmd.ModelCommandBase.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
controllerAPIRoot, err := deployCmd.NewControllerAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
csURL, err := getCharmStoreAPIURL(controllerAPIRoot)
if err != nil {
return nil, errors.Trace(err)
}
mURL, err := deployCmd.getMeteringAPIURL(controllerAPIRoot)
if err != nil {
return nil, errors.Trace(err)
}
bakeryClient, err := deployCmd.BakeryClient()
if err != nil {
return nil, errors.Trace(err)
}
cstoreClient := newCharmStoreClient(bakeryClient, csURL).WithChannel(deployCmd.Channel)
return &deployAPIAdapter{
Connection: apiRoot,
apiClient: &apiClient{Client: apiRoot.Client()},
charmsClient: &charmsClient{Client: apicharms.NewClient(apiRoot)},
applicationClient: &applicationClient{Client: application.NewClient(apiRoot)},
modelConfigClient: &modelConfigClient{Client: modelconfig.NewClient(apiRoot)},
charmstoreClient: &charmstoreClient{&charmstoreClientShim{cstoreClient}},
annotationsClient: &annotationsClient{Client: annotations.NewClient(apiRoot)},
charmRepoClient: &charmRepoClient{charmrepo.NewCharmStoreFromClient(cstoreClient)},
plansClient: &plansClient{planURL: mURL},
}, nil
}
return modelcmd.Wrap(deployCmd)
} | [
"func",
"NewDeployCommand",
"(",
")",
"modelcmd",
".",
"ModelCommand",
"{",
"steps",
":=",
"[",
"]",
"DeployStep",
"{",
"&",
"RegisterMeteredCharm",
"{",
"PlanURL",
":",
"romulus",
".",
"DefaultAPIRoot",
",",
"RegisterPath",
":",
"\"",
"\"",
",",
"QueryPath",
... | // NewDeployCommand returns a command to deploy applications. | [
"NewDeployCommand",
"returns",
"a",
"command",
"to",
"deploy",
"applications",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/deploy.go#L234-L284 |
155,136 | juju/juju | cmd/juju/application/deploy.go | resolveBundleURL | func resolveBundleURL(store URLResolver, maybeBundle string) (*charm.URL, params.Channel, error) {
userRequestedURL, err := charm.ParseURL(maybeBundle)
if err != nil {
return nil, "", errors.Trace(err)
}
// Charm or bundle has been supplied as a URL so we resolve and
// deploy using the store.
storeCharmOrBundleURL, channel, _, err := resolveCharm(store.ResolveWithChannel, userRequestedURL)
if err != nil {
return nil, "", errors.Trace(err)
}
if storeCharmOrBundleURL.Series != "bundle" {
logger.Debugf(
`cannot interpret as charmstore bundle: %v (series) != "bundle"`,
storeCharmOrBundleURL.Series,
)
return nil, "", errors.NotValidf("charmstore bundle %q", maybeBundle)
}
return storeCharmOrBundleURL, channel, nil
} | go | func resolveBundleURL(store URLResolver, maybeBundle string) (*charm.URL, params.Channel, error) {
userRequestedURL, err := charm.ParseURL(maybeBundle)
if err != nil {
return nil, "", errors.Trace(err)
}
// Charm or bundle has been supplied as a URL so we resolve and
// deploy using the store.
storeCharmOrBundleURL, channel, _, err := resolveCharm(store.ResolveWithChannel, userRequestedURL)
if err != nil {
return nil, "", errors.Trace(err)
}
if storeCharmOrBundleURL.Series != "bundle" {
logger.Debugf(
`cannot interpret as charmstore bundle: %v (series) != "bundle"`,
storeCharmOrBundleURL.Series,
)
return nil, "", errors.NotValidf("charmstore bundle %q", maybeBundle)
}
return storeCharmOrBundleURL, channel, nil
} | [
"func",
"resolveBundleURL",
"(",
"store",
"URLResolver",
",",
"maybeBundle",
"string",
")",
"(",
"*",
"charm",
".",
"URL",
",",
"params",
".",
"Channel",
",",
"error",
")",
"{",
"userRequestedURL",
",",
"err",
":=",
"charm",
".",
"ParseURL",
"(",
"maybeBun... | // resolveBundleURL tries to interpret maybeBundle as a charmstore
// bundle. If it turns out to be a bundle, the resolved URL and
// channel are returned. If it isn't but there wasn't a problem
// checking it, it returns a nil charm URL. | [
"resolveBundleURL",
"tries",
"to",
"interpret",
"maybeBundle",
"as",
"a",
"charmstore",
"bundle",
".",
"If",
"it",
"turns",
"out",
"to",
"be",
"a",
"bundle",
"the",
"resolved",
"URL",
"and",
"channel",
"are",
"returned",
".",
"If",
"it",
"isn",
"t",
"but",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/deploy.go#L1432-L1452 |
155,137 | juju/juju | cmd/juju/application/deploy.go | getFlags | func getFlags(flagSet *gnuflag.FlagSet, flagNames []string) []string {
flags := make([]string, 0, flagSet.NFlag())
flagSet.Visit(func(flag *gnuflag.Flag) {
for _, name := range flagNames {
if flag.Name == name {
flags = append(flags, flagWithMinus(name))
}
}
})
return flags
} | go | func getFlags(flagSet *gnuflag.FlagSet, flagNames []string) []string {
flags := make([]string, 0, flagSet.NFlag())
flagSet.Visit(func(flag *gnuflag.Flag) {
for _, name := range flagNames {
if flag.Name == name {
flags = append(flags, flagWithMinus(name))
}
}
})
return flags
} | [
"func",
"getFlags",
"(",
"flagSet",
"*",
"gnuflag",
".",
"FlagSet",
",",
"flagNames",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"flags",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"flagSet",
".",
"NFlag",
"(",
")",
")",
"\n",
"... | // getFlags returns the flags with the given names. Only flags that are set and
// whose name is included in flagNames are included. | [
"getFlags",
"returns",
"the",
"flags",
"with",
"the",
"given",
"names",
".",
"Only",
"flags",
"that",
"are",
"set",
"and",
"whose",
"name",
"is",
"included",
"in",
"flagNames",
"are",
"included",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/deploy.go#L1584-L1594 |
155,138 | juju/juju | cmd/juju/application/removeunit.go | Run | func (c *removeUnitCommand) Run(ctx *cmd.Context) error {
noWaitSet := false
forceSet := false
c.fs.Visit(func(flag *gnuflag.Flag) {
if flag.Name == "no-wait" {
noWaitSet = true
} else if flag.Name == "force" {
forceSet = true
}
})
if !forceSet && noWaitSet {
return errors.NotValidf("--no-wait without --force")
}
client, apiVersion, err := c.getAPI()
if err != nil {
return err
}
defer client.Close()
if apiVersion < 4 {
return c.removeUnitsDeprecated(ctx, client)
}
if err := c.validateArgsByModelType(); err != nil {
return errors.Trace(err)
}
modelType, err := c.ModelType()
if err != nil {
return err
}
if modelType == model.CAAS {
return c.removeCaasUnits(ctx, client)
}
if c.DestroyStorage && apiVersion < 5 {
return errors.New("--destroy-storage is not supported by this controller")
}
return c.removeUnits(ctx, client)
} | go | func (c *removeUnitCommand) Run(ctx *cmd.Context) error {
noWaitSet := false
forceSet := false
c.fs.Visit(func(flag *gnuflag.Flag) {
if flag.Name == "no-wait" {
noWaitSet = true
} else if flag.Name == "force" {
forceSet = true
}
})
if !forceSet && noWaitSet {
return errors.NotValidf("--no-wait without --force")
}
client, apiVersion, err := c.getAPI()
if err != nil {
return err
}
defer client.Close()
if apiVersion < 4 {
return c.removeUnitsDeprecated(ctx, client)
}
if err := c.validateArgsByModelType(); err != nil {
return errors.Trace(err)
}
modelType, err := c.ModelType()
if err != nil {
return err
}
if modelType == model.CAAS {
return c.removeCaasUnits(ctx, client)
}
if c.DestroyStorage && apiVersion < 5 {
return errors.New("--destroy-storage is not supported by this controller")
}
return c.removeUnits(ctx, client)
} | [
"func",
"(",
"c",
"*",
"removeUnitCommand",
")",
"Run",
"(",
"ctx",
"*",
"cmd",
".",
"Context",
")",
"error",
"{",
"noWaitSet",
":=",
"false",
"\n",
"forceSet",
":=",
"false",
"\n",
"c",
".",
"fs",
".",
"Visit",
"(",
"func",
"(",
"flag",
"*",
"gnuf... | // Run connects to the environment specified on the command line and destroys
// units therein. | [
"Run",
"connects",
"to",
"the",
"environment",
"specified",
"on",
"the",
"command",
"line",
"and",
"destroys",
"units",
"therein",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/removeunit.go#L222-L262 |
155,139 | juju/juju | jujuclient/controllers.go | ReadControllersFile | func ReadControllersFile(file string) (*Controllers, error) {
data, err := ioutil.ReadFile(file)
if err != nil {
if os.IsNotExist(err) {
return &Controllers{}, nil
}
if os.IsPermission(err) {
u, userErr := utils.LocalUsername()
if userErr != nil {
return nil, err
}
if ok, fileErr := utils.IsFileOwner(file, u); fileErr == nil && !ok {
err = errors.Annotatef(err, "ownership of the file is not the same as the current user")
}
}
return nil, err
}
controllers, err := ParseControllers(data)
if err != nil {
return nil, err
}
return controllers, nil
} | go | func ReadControllersFile(file string) (*Controllers, error) {
data, err := ioutil.ReadFile(file)
if err != nil {
if os.IsNotExist(err) {
return &Controllers{}, nil
}
if os.IsPermission(err) {
u, userErr := utils.LocalUsername()
if userErr != nil {
return nil, err
}
if ok, fileErr := utils.IsFileOwner(file, u); fileErr == nil && !ok {
err = errors.Annotatef(err, "ownership of the file is not the same as the current user")
}
}
return nil, err
}
controllers, err := ParseControllers(data)
if err != nil {
return nil, err
}
return controllers, nil
} | [
"func",
"ReadControllersFile",
"(",
"file",
"string",
")",
"(",
"*",
"Controllers",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"os",
".",
"IsNotExist",
"("... | // ReadControllersFile loads all controllers defined in a given file.
// If the file is not found, it is not an error. | [
"ReadControllersFile",
"loads",
"all",
"controllers",
"defined",
"in",
"a",
"given",
"file",
".",
"If",
"the",
"file",
"is",
"not",
"found",
"it",
"is",
"not",
"an",
"error",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/jujuclient/controllers.go#L25-L47 |
155,140 | juju/juju | jujuclient/controllers.go | WriteControllersFile | func WriteControllersFile(controllers *Controllers) error {
data, err := yaml.Marshal(controllers)
if err != nil {
return errors.Annotate(err, "cannot marshal yaml controllers")
}
return utils.AtomicWriteFile(JujuControllersPath(), data, os.FileMode(0600))
} | go | func WriteControllersFile(controllers *Controllers) error {
data, err := yaml.Marshal(controllers)
if err != nil {
return errors.Annotate(err, "cannot marshal yaml controllers")
}
return utils.AtomicWriteFile(JujuControllersPath(), data, os.FileMode(0600))
} | [
"func",
"WriteControllersFile",
"(",
"controllers",
"*",
"Controllers",
")",
"error",
"{",
"data",
",",
"err",
":=",
"yaml",
".",
"Marshal",
"(",
"controllers",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Annotate",
"(",
"err",
",... | // WriteControllersFile marshals to YAML details of the given controllers
// and writes it to the controllers file. | [
"WriteControllersFile",
"marshals",
"to",
"YAML",
"details",
"of",
"the",
"given",
"controllers",
"and",
"writes",
"it",
"to",
"the",
"controllers",
"file",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/jujuclient/controllers.go#L51-L57 |
155,141 | juju/juju | jujuclient/controllers.go | ParseControllers | func ParseControllers(data []byte) (*Controllers, error) {
var result Controllers
err := yaml.Unmarshal(data, &result)
if err != nil {
return nil, errors.Annotate(err, "cannot unmarshal yaml controllers metadata")
}
return &result, nil
} | go | func ParseControllers(data []byte) (*Controllers, error) {
var result Controllers
err := yaml.Unmarshal(data, &result)
if err != nil {
return nil, errors.Annotate(err, "cannot unmarshal yaml controllers metadata")
}
return &result, nil
} | [
"func",
"ParseControllers",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"Controllers",
",",
"error",
")",
"{",
"var",
"result",
"Controllers",
"\n",
"err",
":=",
"yaml",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"result",
")",
"\n",
"if",
"err",
"!=... | // ParseControllers parses the given YAML bytes into controllers metadata. | [
"ParseControllers",
"parses",
"the",
"given",
"YAML",
"bytes",
"into",
"controllers",
"metadata",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/jujuclient/controllers.go#L60-L67 |
155,142 | juju/juju | worker/uniter/runner/context/contextfactory.go | NewContextFactory | func NewContextFactory(config FactoryConfig) (ContextFactory, error) {
unit, err := config.State.Unit(config.UnitTag)
if err != nil {
return nil, errors.Trace(err)
}
m, err := config.State.Model()
if err != nil {
return nil, errors.Trace(err)
}
var (
machineTag names.MachineTag
zone string
)
if m.ModelType == model.IAAS {
machineTag, err = unit.AssignedMachine()
if err != nil {
return nil, errors.Trace(err)
}
zone, err = unit.AvailabilityZone()
if err != nil {
return nil, errors.Trace(err)
}
}
principal, ok, err := unit.PrincipalName()
if err != nil {
return nil, errors.Trace(err)
} else if !ok {
principal = ""
}
f := &contextFactory{
unit: unit,
state: config.State,
tracker: config.Tracker,
paths: config.Paths,
modelUUID: m.UUID,
modelName: m.Name,
machineTag: machineTag,
getRelationInfos: config.GetRelationInfos,
relationCaches: map[int]*RelationCache{},
storage: config.Storage,
rand: rand.New(rand.NewSource(time.Now().Unix())),
clock: config.Clock,
zone: zone,
principal: principal,
modelType: m.ModelType,
}
return f, nil
} | go | func NewContextFactory(config FactoryConfig) (ContextFactory, error) {
unit, err := config.State.Unit(config.UnitTag)
if err != nil {
return nil, errors.Trace(err)
}
m, err := config.State.Model()
if err != nil {
return nil, errors.Trace(err)
}
var (
machineTag names.MachineTag
zone string
)
if m.ModelType == model.IAAS {
machineTag, err = unit.AssignedMachine()
if err != nil {
return nil, errors.Trace(err)
}
zone, err = unit.AvailabilityZone()
if err != nil {
return nil, errors.Trace(err)
}
}
principal, ok, err := unit.PrincipalName()
if err != nil {
return nil, errors.Trace(err)
} else if !ok {
principal = ""
}
f := &contextFactory{
unit: unit,
state: config.State,
tracker: config.Tracker,
paths: config.Paths,
modelUUID: m.UUID,
modelName: m.Name,
machineTag: machineTag,
getRelationInfos: config.GetRelationInfos,
relationCaches: map[int]*RelationCache{},
storage: config.Storage,
rand: rand.New(rand.NewSource(time.Now().Unix())),
clock: config.Clock,
zone: zone,
principal: principal,
modelType: m.ModelType,
}
return f, nil
} | [
"func",
"NewContextFactory",
"(",
"config",
"FactoryConfig",
")",
"(",
"ContextFactory",
",",
"error",
")",
"{",
"unit",
",",
"err",
":=",
"config",
".",
"State",
".",
"Unit",
"(",
"config",
".",
"UnitTag",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"re... | // NewContextFactory returns a ContextFactory capable of creating execution contexts backed
// by the supplied unit's supplied API connection. | [
"NewContextFactory",
"returns",
"a",
"ContextFactory",
"capable",
"of",
"creating",
"execution",
"contexts",
"backed",
"by",
"the",
"supplied",
"unit",
"s",
"supplied",
"API",
"connection",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/context/contextfactory.go#L102-L151 |
155,143 | juju/juju | worker/uniter/runner/context/contextfactory.go | newId | func (f *contextFactory) newId(name string) string {
return fmt.Sprintf("%s-%s-%d", f.unit.Name(), name, f.rand.Int63())
} | go | func (f *contextFactory) newId(name string) string {
return fmt.Sprintf("%s-%s-%d", f.unit.Name(), name, f.rand.Int63())
} | [
"func",
"(",
"f",
"*",
"contextFactory",
")",
"newId",
"(",
"name",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"f",
".",
"unit",
".",
"Name",
"(",
")",
",",
"name",
",",
"f",
".",
"rand",
".",
"Int63",
... | // newId returns a probably-unique identifier for a new context, containing the
// supplied string. | [
"newId",
"returns",
"a",
"probably",
"-",
"unique",
"identifier",
"for",
"a",
"new",
"context",
"containing",
"the",
"supplied",
"string",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/context/contextfactory.go#L155-L157 |
155,144 | juju/juju | worker/uniter/runner/context/contextfactory.go | coreContext | func (f *contextFactory) coreContext() (*HookContext, error) {
leadershipContext := newLeadershipContext(
f.state.LeadershipSettings,
f.tracker,
f.unit.Name(),
)
ctx := &HookContext{
unit: f.unit,
state: f.state,
LeadershipContext: leadershipContext,
uuid: f.modelUUID,
modelName: f.modelName,
unitName: f.unit.Name(),
assignedMachineTag: f.machineTag,
relations: f.getContextRelations(),
relationId: -1,
pendingPorts: make(map[PortRange]PortRangeInfo),
storage: f.storage,
clock: f.clock,
componentDir: f.paths.ComponentDir,
componentFuncs: registeredComponentFuncs,
availabilityzone: f.zone,
principal: f.principal,
}
if err := f.updateContext(ctx); err != nil {
return nil, err
}
return ctx, nil
} | go | func (f *contextFactory) coreContext() (*HookContext, error) {
leadershipContext := newLeadershipContext(
f.state.LeadershipSettings,
f.tracker,
f.unit.Name(),
)
ctx := &HookContext{
unit: f.unit,
state: f.state,
LeadershipContext: leadershipContext,
uuid: f.modelUUID,
modelName: f.modelName,
unitName: f.unit.Name(),
assignedMachineTag: f.machineTag,
relations: f.getContextRelations(),
relationId: -1,
pendingPorts: make(map[PortRange]PortRangeInfo),
storage: f.storage,
clock: f.clock,
componentDir: f.paths.ComponentDir,
componentFuncs: registeredComponentFuncs,
availabilityzone: f.zone,
principal: f.principal,
}
if err := f.updateContext(ctx); err != nil {
return nil, err
}
return ctx, nil
} | [
"func",
"(",
"f",
"*",
"contextFactory",
")",
"coreContext",
"(",
")",
"(",
"*",
"HookContext",
",",
"error",
")",
"{",
"leadershipContext",
":=",
"newLeadershipContext",
"(",
"f",
".",
"state",
".",
"LeadershipSettings",
",",
"f",
".",
"tracker",
",",
"f"... | // coreContext creates a new context with all unspecialised fields filled in. | [
"coreContext",
"creates",
"a",
"new",
"context",
"with",
"all",
"unspecialised",
"fields",
"filled",
"in",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/context/contextfactory.go#L160-L188 |
155,145 | juju/juju | worker/uniter/runner/context/contextfactory.go | ActionContext | func (f *contextFactory) ActionContext(actionData *ActionData) (*HookContext, error) {
if actionData == nil {
return nil, errors.New("nil actionData specified")
}
ctx, err := f.coreContext()
if err != nil {
return nil, errors.Trace(err)
}
ctx.actionData = actionData
ctx.id = f.newId(actionData.Name)
return ctx, nil
} | go | func (f *contextFactory) ActionContext(actionData *ActionData) (*HookContext, error) {
if actionData == nil {
return nil, errors.New("nil actionData specified")
}
ctx, err := f.coreContext()
if err != nil {
return nil, errors.Trace(err)
}
ctx.actionData = actionData
ctx.id = f.newId(actionData.Name)
return ctx, nil
} | [
"func",
"(",
"f",
"*",
"contextFactory",
")",
"ActionContext",
"(",
"actionData",
"*",
"ActionData",
")",
"(",
"*",
"HookContext",
",",
"error",
")",
"{",
"if",
"actionData",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\""... | // ActionContext is part of the ContextFactory interface. | [
"ActionContext",
"is",
"part",
"of",
"the",
"ContextFactory",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/context/contextfactory.go#L191-L202 |
155,146 | juju/juju | worker/uniter/runner/context/contextfactory.go | HookContext | func (f *contextFactory) HookContext(hookInfo hook.Info) (*HookContext, error) {
ctx, err := f.coreContext()
if err != nil {
return nil, errors.Trace(err)
}
hookName := string(hookInfo.Kind)
if hookInfo.Kind.IsRelation() {
ctx.relationId = hookInfo.RelationId
ctx.remoteUnitName = hookInfo.RemoteUnit
relation, found := ctx.relations[hookInfo.RelationId]
if !found {
return nil, errors.Errorf("unknown relation id: %v", hookInfo.RelationId)
}
if hookInfo.Kind == hooks.RelationDeparted {
relation.cache.RemoveMember(hookInfo.RemoteUnit)
} else if hookInfo.RemoteUnit != "" {
// Clear remote settings cache for changing remote unit.
relation.cache.InvalidateMember(hookInfo.RemoteUnit)
}
hookName = fmt.Sprintf("%s-%s", relation.Name(), hookInfo.Kind)
}
if hookInfo.Kind.IsStorage() {
ctx.storageTag = names.NewStorageTag(hookInfo.StorageId)
if _, err := ctx.storage.Storage(ctx.storageTag); err != nil {
return nil, errors.Annotatef(err, "could not retrieve storage for id: %v", hookInfo.StorageId)
}
storageName, err := names.StorageName(hookInfo.StorageId)
if err != nil {
return nil, errors.Trace(err)
}
hookName = fmt.Sprintf("%s-%s", storageName, hookName)
}
ctx.id = f.newId(hookName)
return ctx, nil
} | go | func (f *contextFactory) HookContext(hookInfo hook.Info) (*HookContext, error) {
ctx, err := f.coreContext()
if err != nil {
return nil, errors.Trace(err)
}
hookName := string(hookInfo.Kind)
if hookInfo.Kind.IsRelation() {
ctx.relationId = hookInfo.RelationId
ctx.remoteUnitName = hookInfo.RemoteUnit
relation, found := ctx.relations[hookInfo.RelationId]
if !found {
return nil, errors.Errorf("unknown relation id: %v", hookInfo.RelationId)
}
if hookInfo.Kind == hooks.RelationDeparted {
relation.cache.RemoveMember(hookInfo.RemoteUnit)
} else if hookInfo.RemoteUnit != "" {
// Clear remote settings cache for changing remote unit.
relation.cache.InvalidateMember(hookInfo.RemoteUnit)
}
hookName = fmt.Sprintf("%s-%s", relation.Name(), hookInfo.Kind)
}
if hookInfo.Kind.IsStorage() {
ctx.storageTag = names.NewStorageTag(hookInfo.StorageId)
if _, err := ctx.storage.Storage(ctx.storageTag); err != nil {
return nil, errors.Annotatef(err, "could not retrieve storage for id: %v", hookInfo.StorageId)
}
storageName, err := names.StorageName(hookInfo.StorageId)
if err != nil {
return nil, errors.Trace(err)
}
hookName = fmt.Sprintf("%s-%s", storageName, hookName)
}
ctx.id = f.newId(hookName)
return ctx, nil
} | [
"func",
"(",
"f",
"*",
"contextFactory",
")",
"HookContext",
"(",
"hookInfo",
"hook",
".",
"Info",
")",
"(",
"*",
"HookContext",
",",
"error",
")",
"{",
"ctx",
",",
"err",
":=",
"f",
".",
"coreContext",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{"... | // HookContext is part of the ContextFactory interface. | [
"HookContext",
"is",
"part",
"of",
"the",
"ContextFactory",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/context/contextfactory.go#L205-L239 |
155,147 | juju/juju | worker/uniter/runner/context/contextfactory.go | CommandContext | func (f *contextFactory) CommandContext(commandInfo CommandInfo) (*HookContext, error) {
ctx, err := f.coreContext()
if err != nil {
return nil, errors.Trace(err)
}
relationId, remoteUnitName, err := inferRemoteUnit(ctx.relations, commandInfo)
if err != nil {
return nil, errors.Trace(err)
}
ctx.relationId = relationId
ctx.remoteUnitName = remoteUnitName
ctx.id = f.newId("run-commands")
return ctx, nil
} | go | func (f *contextFactory) CommandContext(commandInfo CommandInfo) (*HookContext, error) {
ctx, err := f.coreContext()
if err != nil {
return nil, errors.Trace(err)
}
relationId, remoteUnitName, err := inferRemoteUnit(ctx.relations, commandInfo)
if err != nil {
return nil, errors.Trace(err)
}
ctx.relationId = relationId
ctx.remoteUnitName = remoteUnitName
ctx.id = f.newId("run-commands")
return ctx, nil
} | [
"func",
"(",
"f",
"*",
"contextFactory",
")",
"CommandContext",
"(",
"commandInfo",
"CommandInfo",
")",
"(",
"*",
"HookContext",
",",
"error",
")",
"{",
"ctx",
",",
"err",
":=",
"f",
".",
"coreContext",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // CommandContext is part of the ContextFactory interface. | [
"CommandContext",
"is",
"part",
"of",
"the",
"ContextFactory",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/context/contextfactory.go#L242-L255 |
155,148 | juju/juju | worker/uniter/runner/context/contextfactory.go | getContextRelations | func (f *contextFactory) getContextRelations() map[int]*ContextRelation {
contextRelations := map[int]*ContextRelation{}
relationInfos := f.getRelationInfos()
relationCaches := map[int]*RelationCache{}
for id, info := range relationInfos {
relationUnit := info.RelationUnit
memberNames := info.MemberNames
cache, found := f.relationCaches[id]
if found {
cache.Prune(memberNames)
} else {
cache = NewRelationCache(relationUnit.ReadSettings, memberNames)
}
relationCaches[id] = cache
contextRelations[id] = NewContextRelation(relationUnit, cache)
}
f.relationCaches = relationCaches
return contextRelations
} | go | func (f *contextFactory) getContextRelations() map[int]*ContextRelation {
contextRelations := map[int]*ContextRelation{}
relationInfos := f.getRelationInfos()
relationCaches := map[int]*RelationCache{}
for id, info := range relationInfos {
relationUnit := info.RelationUnit
memberNames := info.MemberNames
cache, found := f.relationCaches[id]
if found {
cache.Prune(memberNames)
} else {
cache = NewRelationCache(relationUnit.ReadSettings, memberNames)
}
relationCaches[id] = cache
contextRelations[id] = NewContextRelation(relationUnit, cache)
}
f.relationCaches = relationCaches
return contextRelations
} | [
"func",
"(",
"f",
"*",
"contextFactory",
")",
"getContextRelations",
"(",
")",
"map",
"[",
"int",
"]",
"*",
"ContextRelation",
"{",
"contextRelations",
":=",
"map",
"[",
"int",
"]",
"*",
"ContextRelation",
"{",
"}",
"\n",
"relationInfos",
":=",
"f",
".",
... | // getContextRelations updates the factory's relation caches, and uses them
// to construct ContextRelations for a fresh context. | [
"getContextRelations",
"updates",
"the",
"factory",
"s",
"relation",
"caches",
"and",
"uses",
"them",
"to",
"construct",
"ContextRelations",
"for",
"a",
"fresh",
"context",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/context/contextfactory.go#L259-L277 |
155,149 | juju/juju | apiserver/common/machinestatus.go | MachineStatus | func (c *ModelPresenceContext) MachineStatus(machine MachineStatusGetter) (status.StatusInfo, error) {
machineStatus, err := machine.Status()
if err != nil {
return status.StatusInfo{}, err
}
if !canMachineBeDown(machineStatus) {
// The machine still being provisioned - there's no point in
// enquiring about the agent liveness.
return machineStatus, nil
}
agentAlive, err := c.machinePresence(machine)
if err != nil {
// We don't want any presence errors affecting status.
logger.Debugf("error determining presence for machine %s: %v", machine.Id(), err)
return machineStatus, nil
}
if machine.Life() != state.Dead && !agentAlive {
machineStatus.Status = status.Down
machineStatus.Message = "agent is not communicating with the server"
}
return machineStatus, nil
} | go | func (c *ModelPresenceContext) MachineStatus(machine MachineStatusGetter) (status.StatusInfo, error) {
machineStatus, err := machine.Status()
if err != nil {
return status.StatusInfo{}, err
}
if !canMachineBeDown(machineStatus) {
// The machine still being provisioned - there's no point in
// enquiring about the agent liveness.
return machineStatus, nil
}
agentAlive, err := c.machinePresence(machine)
if err != nil {
// We don't want any presence errors affecting status.
logger.Debugf("error determining presence for machine %s: %v", machine.Id(), err)
return machineStatus, nil
}
if machine.Life() != state.Dead && !agentAlive {
machineStatus.Status = status.Down
machineStatus.Message = "agent is not communicating with the server"
}
return machineStatus, nil
} | [
"func",
"(",
"c",
"*",
"ModelPresenceContext",
")",
"MachineStatus",
"(",
"machine",
"MachineStatusGetter",
")",
"(",
"status",
".",
"StatusInfo",
",",
"error",
")",
"{",
"machineStatus",
",",
"err",
":=",
"machine",
".",
"Status",
"(",
")",
"\n",
"if",
"e... | // MachineStatus returns the machine agent status for a given
// machine, with special handling for agent presence. | [
"MachineStatus",
"returns",
"the",
"machine",
"agent",
"status",
"for",
"a",
"given",
"machine",
"with",
"special",
"handling",
"for",
"agent",
"presence",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/machinestatus.go#L22-L45 |
155,150 | juju/juju | tools/marshal.go | GetBSON | func (t *Tools) GetBSON() (interface{}, error) {
if t == nil {
return nil, nil
}
return &toolsDoc{t.Version, t.URL, t.Size, t.SHA256}, nil
} | go | func (t *Tools) GetBSON() (interface{}, error) {
if t == nil {
return nil, nil
}
return &toolsDoc{t.Version, t.URL, t.Size, t.SHA256}, nil
} | [
"func",
"(",
"t",
"*",
"Tools",
")",
"GetBSON",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"t",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"return",
"&",
"toolsDoc",
"{",
"t",
".",
"Version",
",",
... | // GetBSON returns the structure to be serialized for the tools as a generic
// interface. | [
"GetBSON",
"returns",
"the",
"structure",
"to",
"be",
"serialized",
"for",
"the",
"tools",
"as",
"a",
"generic",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/tools/marshal.go#L20-L25 |
155,151 | juju/juju | tools/marshal.go | SetBSON | func (t *Tools) SetBSON(raw bson.Raw) error {
if raw.Kind == 10 {
// Preserve the nil value in that case.
return bson.SetZero
}
var doc toolsDoc
if err := raw.Unmarshal(&doc); err != nil {
return err
}
t.Version = doc.Version
t.URL = doc.URL
t.Size = doc.Size
t.SHA256 = doc.SHA256
return nil
} | go | func (t *Tools) SetBSON(raw bson.Raw) error {
if raw.Kind == 10 {
// Preserve the nil value in that case.
return bson.SetZero
}
var doc toolsDoc
if err := raw.Unmarshal(&doc); err != nil {
return err
}
t.Version = doc.Version
t.URL = doc.URL
t.Size = doc.Size
t.SHA256 = doc.SHA256
return nil
} | [
"func",
"(",
"t",
"*",
"Tools",
")",
"SetBSON",
"(",
"raw",
"bson",
".",
"Raw",
")",
"error",
"{",
"if",
"raw",
".",
"Kind",
"==",
"10",
"{",
"// Preserve the nil value in that case.",
"return",
"bson",
".",
"SetZero",
"\n",
"}",
"\n",
"var",
"doc",
"t... | // SetBSON updates the internal members with the data stored in the bson.Raw
// parameter. | [
"SetBSON",
"updates",
"the",
"internal",
"members",
"with",
"the",
"data",
"stored",
"in",
"the",
"bson",
".",
"Raw",
"parameter",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/tools/marshal.go#L29-L43 |
155,152 | juju/juju | api/modelmanager/modelmanager.go | CreateModel | func (c *Client) CreateModel(
name, owner, cloud, cloudRegion string,
cloudCredential names.CloudCredentialTag,
config map[string]interface{},
) (base.ModelInfo, error) {
var result base.ModelInfo
if !names.IsValidUser(owner) {
return result, errors.Errorf("invalid owner name %q", owner)
}
var cloudTag string
if cloud != "" {
if !names.IsValidCloud(cloud) {
return result, errors.Errorf("invalid cloud name %q", cloud)
}
cloudTag = names.NewCloudTag(cloud).String()
}
var cloudCredentialTag string
if cloudCredential != (names.CloudCredentialTag{}) {
cloudCredentialTag = cloudCredential.String()
}
createArgs := params.ModelCreateArgs{
Name: name,
OwnerTag: names.NewUserTag(owner).String(),
Config: config,
CloudTag: cloudTag,
CloudRegion: cloudRegion,
CloudCredentialTag: cloudCredentialTag,
}
var modelInfo params.ModelInfo
err := c.facade.FacadeCall("CreateModel", createArgs, &modelInfo)
if err != nil {
// We don't want the message to contain the "(already exists)" suffix.
if rpcErr, ok := errors.Cause(err).(*rpc.RequestError); ok {
return result, errors.New(rpcErr.Message)
}
return result, errors.Trace(err)
}
return convertParamsModelInfo(modelInfo)
} | go | func (c *Client) CreateModel(
name, owner, cloud, cloudRegion string,
cloudCredential names.CloudCredentialTag,
config map[string]interface{},
) (base.ModelInfo, error) {
var result base.ModelInfo
if !names.IsValidUser(owner) {
return result, errors.Errorf("invalid owner name %q", owner)
}
var cloudTag string
if cloud != "" {
if !names.IsValidCloud(cloud) {
return result, errors.Errorf("invalid cloud name %q", cloud)
}
cloudTag = names.NewCloudTag(cloud).String()
}
var cloudCredentialTag string
if cloudCredential != (names.CloudCredentialTag{}) {
cloudCredentialTag = cloudCredential.String()
}
createArgs := params.ModelCreateArgs{
Name: name,
OwnerTag: names.NewUserTag(owner).String(),
Config: config,
CloudTag: cloudTag,
CloudRegion: cloudRegion,
CloudCredentialTag: cloudCredentialTag,
}
var modelInfo params.ModelInfo
err := c.facade.FacadeCall("CreateModel", createArgs, &modelInfo)
if err != nil {
// We don't want the message to contain the "(already exists)" suffix.
if rpcErr, ok := errors.Cause(err).(*rpc.RequestError); ok {
return result, errors.New(rpcErr.Message)
}
return result, errors.Trace(err)
}
return convertParamsModelInfo(modelInfo)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateModel",
"(",
"name",
",",
"owner",
",",
"cloud",
",",
"cloudRegion",
"string",
",",
"cloudCredential",
"names",
".",
"CloudCredentialTag",
",",
"config",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
... | // CreateModel creates a new model using the model config,
// cloud region and credential specified in the args. | [
"CreateModel",
"creates",
"a",
"new",
"model",
"using",
"the",
"model",
"config",
"cloud",
"region",
"and",
"credential",
"specified",
"in",
"the",
"args",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelmanager/modelmanager.go#L47-L85 |
155,153 | juju/juju | api/modelmanager/modelmanager.go | DumpModel | func (c *Client) DumpModel(model names.ModelTag, simplified bool) (map[string]interface{}, error) {
if bestVer := c.BestAPIVersion(); bestVer < 3 {
logger.Debugf("calling older dump model on v%d", bestVer)
if simplified {
logger.Warningf("simplified dump-model not available, server too old")
}
return c.dumpModelV2(model)
}
var results params.StringResults
entities := params.DumpModelRequest{
Entities: []params.Entity{{Tag: model.String()}},
Simplified: simplified,
}
err := c.facade.FacadeCall("DumpModels", entities, &results)
if err != nil {
return nil, errors.Trace(err)
}
if count := len(results.Results); count != 1 {
return nil, errors.Errorf("unexpected result count: %d", count)
}
result := results.Results[0]
if result.Error != nil {
return nil, result.Error
}
// Parse back into a map.
var asMap map[string]interface{}
err = yaml.Unmarshal([]byte(result.Result), &asMap)
if err != nil {
return nil, errors.Trace(err)
}
return asMap, nil
} | go | func (c *Client) DumpModel(model names.ModelTag, simplified bool) (map[string]interface{}, error) {
if bestVer := c.BestAPIVersion(); bestVer < 3 {
logger.Debugf("calling older dump model on v%d", bestVer)
if simplified {
logger.Warningf("simplified dump-model not available, server too old")
}
return c.dumpModelV2(model)
}
var results params.StringResults
entities := params.DumpModelRequest{
Entities: []params.Entity{{Tag: model.String()}},
Simplified: simplified,
}
err := c.facade.FacadeCall("DumpModels", entities, &results)
if err != nil {
return nil, errors.Trace(err)
}
if count := len(results.Results); count != 1 {
return nil, errors.Errorf("unexpected result count: %d", count)
}
result := results.Results[0]
if result.Error != nil {
return nil, result.Error
}
// Parse back into a map.
var asMap map[string]interface{}
err = yaml.Unmarshal([]byte(result.Result), &asMap)
if err != nil {
return nil, errors.Trace(err)
}
return asMap, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DumpModel",
"(",
"model",
"names",
".",
"ModelTag",
",",
"simplified",
"bool",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"bestVer",
":=",
"c",
".",
"BestAPIVersion... | // DumpModel returns the serialized database agnostic model representation. | [
"DumpModel",
"returns",
"the",
"serialized",
"database",
"agnostic",
"model",
"representation",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelmanager/modelmanager.go#L317-L351 |
155,154 | juju/juju | api/modelmanager/modelmanager.go | DestroyModel | func (c *Client) DestroyModel(tag names.ModelTag, destroyStorage, force *bool, maxWait *time.Duration) error {
var args interface{}
if c.BestAPIVersion() < 4 {
if destroyStorage == nil || !*destroyStorage {
return errors.New("this Juju controller requires destroyStorage to be true")
}
args = params.Entities{Entities: []params.Entity{{Tag: tag.String()}}}
} else {
arg := params.DestroyModelParams{
ModelTag: tag.String(),
DestroyStorage: destroyStorage,
}
if c.BestAPIVersion() > 6 {
arg.Force = force
arg.MaxWait = maxWait
}
args = params.DestroyModelsParams{Models: []params.DestroyModelParams{arg}}
}
var results params.ErrorResults
if err := c.facade.FacadeCall("DestroyModels", args, &results); err != nil {
return errors.Trace(err)
}
if n := len(results.Results); n != 1 {
return errors.Errorf("expected 1 result, got %d", n)
}
if err := results.Results[0].Error; err != nil {
return errors.Trace(err)
}
return nil
} | go | func (c *Client) DestroyModel(tag names.ModelTag, destroyStorage, force *bool, maxWait *time.Duration) error {
var args interface{}
if c.BestAPIVersion() < 4 {
if destroyStorage == nil || !*destroyStorage {
return errors.New("this Juju controller requires destroyStorage to be true")
}
args = params.Entities{Entities: []params.Entity{{Tag: tag.String()}}}
} else {
arg := params.DestroyModelParams{
ModelTag: tag.String(),
DestroyStorage: destroyStorage,
}
if c.BestAPIVersion() > 6 {
arg.Force = force
arg.MaxWait = maxWait
}
args = params.DestroyModelsParams{Models: []params.DestroyModelParams{arg}}
}
var results params.ErrorResults
if err := c.facade.FacadeCall("DestroyModels", args, &results); err != nil {
return errors.Trace(err)
}
if n := len(results.Results); n != 1 {
return errors.Errorf("expected 1 result, got %d", n)
}
if err := results.Results[0].Error; err != nil {
return errors.Trace(err)
}
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DestroyModel",
"(",
"tag",
"names",
".",
"ModelTag",
",",
"destroyStorage",
",",
"force",
"*",
"bool",
",",
"maxWait",
"*",
"time",
".",
"Duration",
")",
"error",
"{",
"var",
"args",
"interface",
"{",
"}",
"\n",
... | // DestroyModel puts the specified model into a "dying" state, which will
// cause the model's resources to be cleaned up, after which the model will
// be removed. | [
"DestroyModel",
"puts",
"the",
"specified",
"model",
"into",
"a",
"dying",
"state",
"which",
"will",
"cause",
"the",
"model",
"s",
"resources",
"to",
"be",
"cleaned",
"up",
"after",
"which",
"the",
"model",
"will",
"be",
"removed",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelmanager/modelmanager.go#L397-L426 |
155,155 | juju/juju | api/modelmanager/modelmanager.go | GrantModel | func (c *Client) GrantModel(user, access string, modelUUIDs ...string) error {
return c.modifyModelUser(params.GrantModelAccess, user, access, modelUUIDs)
} | go | func (c *Client) GrantModel(user, access string, modelUUIDs ...string) error {
return c.modifyModelUser(params.GrantModelAccess, user, access, modelUUIDs)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GrantModel",
"(",
"user",
",",
"access",
"string",
",",
"modelUUIDs",
"...",
"string",
")",
"error",
"{",
"return",
"c",
".",
"modifyModelUser",
"(",
"params",
".",
"GrantModelAccess",
",",
"user",
",",
"access",
",... | // GrantModel grants a user access to the specified models. | [
"GrantModel",
"grants",
"a",
"user",
"access",
"to",
"the",
"specified",
"models",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelmanager/modelmanager.go#L429-L431 |
155,156 | juju/juju | api/modelmanager/modelmanager.go | RevokeModel | func (c *Client) RevokeModel(user, access string, modelUUIDs ...string) error {
return c.modifyModelUser(params.RevokeModelAccess, user, access, modelUUIDs)
} | go | func (c *Client) RevokeModel(user, access string, modelUUIDs ...string) error {
return c.modifyModelUser(params.RevokeModelAccess, user, access, modelUUIDs)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RevokeModel",
"(",
"user",
",",
"access",
"string",
",",
"modelUUIDs",
"...",
"string",
")",
"error",
"{",
"return",
"c",
".",
"modifyModelUser",
"(",
"params",
".",
"RevokeModelAccess",
",",
"user",
",",
"access",
... | // RevokeModel revokes a user's access to the specified models. | [
"RevokeModel",
"revokes",
"a",
"user",
"s",
"access",
"to",
"the",
"specified",
"models",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelmanager/modelmanager.go#L434-L436 |
155,157 | juju/juju | api/modelmanager/modelmanager.go | ModelDefaults | func (c *Client) ModelDefaults(cloud string) (config.ModelDefaultAttributes, error) {
if c.BestAPIVersion() < 6 {
if cloud != "" {
return nil, errors.Errorf("model defaults for cloud %s not supported for this version of Juju", cloud)
}
return c.legacyModelDefaults()
}
results := params.ModelDefaultsResults{}
args := params.Entities{
Entities: []params.Entity{{Tag: names.NewCloudTag(cloud).String()}},
}
err := c.facade.FacadeCall("ModelDefaultsForClouds", args, &results)
if err != nil {
return nil, errors.Trace(err)
}
if len(results.Results) != 1 {
return nil, errors.Errorf("expected one result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return nil, errors.Trace(result.Error)
}
values := make(config.ModelDefaultAttributes)
for name, val := range result.Config {
setting := config.AttributeDefaultValues{
Default: val.Default,
Controller: val.Controller,
}
for _, region := range val.Regions {
setting.Regions = append(setting.Regions, config.RegionDefaultValue{
Name: region.RegionName,
Value: region.Value})
}
values[name] = setting
}
return values, nil
} | go | func (c *Client) ModelDefaults(cloud string) (config.ModelDefaultAttributes, error) {
if c.BestAPIVersion() < 6 {
if cloud != "" {
return nil, errors.Errorf("model defaults for cloud %s not supported for this version of Juju", cloud)
}
return c.legacyModelDefaults()
}
results := params.ModelDefaultsResults{}
args := params.Entities{
Entities: []params.Entity{{Tag: names.NewCloudTag(cloud).String()}},
}
err := c.facade.FacadeCall("ModelDefaultsForClouds", args, &results)
if err != nil {
return nil, errors.Trace(err)
}
if len(results.Results) != 1 {
return nil, errors.Errorf("expected one result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return nil, errors.Trace(result.Error)
}
values := make(config.ModelDefaultAttributes)
for name, val := range result.Config {
setting := config.AttributeDefaultValues{
Default: val.Default,
Controller: val.Controller,
}
for _, region := range val.Regions {
setting.Regions = append(setting.Regions, config.RegionDefaultValue{
Name: region.RegionName,
Value: region.Value})
}
values[name] = setting
}
return values, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ModelDefaults",
"(",
"cloud",
"string",
")",
"(",
"config",
".",
"ModelDefaultAttributes",
",",
"error",
")",
"{",
"if",
"c",
".",
"BestAPIVersion",
"(",
")",
"<",
"6",
"{",
"if",
"cloud",
"!=",
"\"",
"\"",
"{",... | // ModelDefaults returns the default values for various sources used when
// creating a new model on the specified cloud. | [
"ModelDefaults",
"returns",
"the",
"default",
"values",
"for",
"various",
"sources",
"used",
"when",
"creating",
"a",
"new",
"model",
"on",
"the",
"specified",
"cloud",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelmanager/modelmanager.go#L483-L520 |
155,158 | juju/juju | api/modelmanager/modelmanager.go | SetModelDefaults | func (c *Client) SetModelDefaults(cloud, region string, config map[string]interface{}) error {
var cloudTag string
if cloud != "" {
cloudTag = names.NewCloudTag(cloud).String()
}
args := params.SetModelDefaults{
Config: []params.ModelDefaultValues{{
Config: config,
CloudTag: cloudTag,
CloudRegion: region,
}},
}
var result params.ErrorResults
err := c.facade.FacadeCall("SetModelDefaults", args, &result)
if err != nil {
return err
}
return result.OneError()
} | go | func (c *Client) SetModelDefaults(cloud, region string, config map[string]interface{}) error {
var cloudTag string
if cloud != "" {
cloudTag = names.NewCloudTag(cloud).String()
}
args := params.SetModelDefaults{
Config: []params.ModelDefaultValues{{
Config: config,
CloudTag: cloudTag,
CloudRegion: region,
}},
}
var result params.ErrorResults
err := c.facade.FacadeCall("SetModelDefaults", args, &result)
if err != nil {
return err
}
return result.OneError()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetModelDefaults",
"(",
"cloud",
",",
"region",
"string",
",",
"config",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"var",
"cloudTag",
"string",
"\n",
"if",
"cloud",
"!=",
"\"",
"\"",
"... | // SetModelDefaults updates the specified default model config values. | [
"SetModelDefaults",
"updates",
"the",
"specified",
"default",
"model",
"config",
"values",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelmanager/modelmanager.go#L545-L563 |
155,159 | juju/juju | api/modelmanager/modelmanager.go | UnsetModelDefaults | func (c *Client) UnsetModelDefaults(cloud, region string, keys ...string) error {
var cloudTag string
if cloud != "" {
cloudTag = names.NewCloudTag(cloud).String()
}
args := params.UnsetModelDefaults{
Keys: []params.ModelUnsetKeys{{
Keys: keys,
CloudTag: cloudTag,
CloudRegion: region,
}},
}
var result params.ErrorResults
err := c.facade.FacadeCall("UnsetModelDefaults", args, &result)
if err != nil {
return err
}
return result.OneError()
} | go | func (c *Client) UnsetModelDefaults(cloud, region string, keys ...string) error {
var cloudTag string
if cloud != "" {
cloudTag = names.NewCloudTag(cloud).String()
}
args := params.UnsetModelDefaults{
Keys: []params.ModelUnsetKeys{{
Keys: keys,
CloudTag: cloudTag,
CloudRegion: region,
}},
}
var result params.ErrorResults
err := c.facade.FacadeCall("UnsetModelDefaults", args, &result)
if err != nil {
return err
}
return result.OneError()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UnsetModelDefaults",
"(",
"cloud",
",",
"region",
"string",
",",
"keys",
"...",
"string",
")",
"error",
"{",
"var",
"cloudTag",
"string",
"\n",
"if",
"cloud",
"!=",
"\"",
"\"",
"{",
"cloudTag",
"=",
"names",
".",
... | // UnsetModelDefaults removes the specified default model config values. | [
"UnsetModelDefaults",
"removes",
"the",
"specified",
"default",
"model",
"config",
"values",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelmanager/modelmanager.go#L566-L584 |
155,160 | juju/juju | api/modelmanager/modelmanager.go | ChangeModelCredential | func (c *Client) ChangeModelCredential(model names.ModelTag, credential names.CloudCredentialTag) error {
if bestVer := c.BestAPIVersion(); bestVer < 5 {
return errors.NotImplementedf("ChangeModelCredential in version %v", bestVer)
}
var out params.ErrorResults
in := params.ChangeModelCredentialsParams{
[]params.ChangeModelCredentialParams{
{ModelTag: model.String(), CloudCredentialTag: credential.String()},
},
}
err := c.facade.FacadeCall("ChangeModelCredential", in, &out)
if err != nil {
return errors.Trace(err)
}
return out.OneError()
} | go | func (c *Client) ChangeModelCredential(model names.ModelTag, credential names.CloudCredentialTag) error {
if bestVer := c.BestAPIVersion(); bestVer < 5 {
return errors.NotImplementedf("ChangeModelCredential in version %v", bestVer)
}
var out params.ErrorResults
in := params.ChangeModelCredentialsParams{
[]params.ChangeModelCredentialParams{
{ModelTag: model.String(), CloudCredentialTag: credential.String()},
},
}
err := c.facade.FacadeCall("ChangeModelCredential", in, &out)
if err != nil {
return errors.Trace(err)
}
return out.OneError()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ChangeModelCredential",
"(",
"model",
"names",
".",
"ModelTag",
",",
"credential",
"names",
".",
"CloudCredentialTag",
")",
"error",
"{",
"if",
"bestVer",
":=",
"c",
".",
"BestAPIVersion",
"(",
")",
";",
"bestVer",
"<... | // ChangeModelCredential replaces cloud credential for a given model with the provided one. | [
"ChangeModelCredential",
"replaces",
"cloud",
"credential",
"for",
"a",
"given",
"model",
"with",
"the",
"provided",
"one",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelmanager/modelmanager.go#L587-L604 |
155,161 | juju/juju | worker/singular/flag.go | Validate | func (config FlagConfig) Validate() error {
if config.Clock == nil {
return errors.NotValidf("nil Clock")
}
if config.Facade == nil {
return errors.NotValidf("nil Facade")
}
if config.Duration <= 0 {
return errors.NotValidf("non-positive Duration")
}
return nil
} | go | func (config FlagConfig) Validate() error {
if config.Clock == nil {
return errors.NotValidf("nil Clock")
}
if config.Facade == nil {
return errors.NotValidf("nil Facade")
}
if config.Duration <= 0 {
return errors.NotValidf("non-positive Duration")
}
return nil
} | [
"func",
"(",
"config",
"FlagConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"config",
".",
"Clock",
"==",
"nil",
"{",
"return",
"errors",
".",
"NotValidf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"config",
".",
"Facade",
"==",
"nil",
"... | // Validate returns an error if the config cannot be expected to run a
// FlagWorker. | [
"Validate",
"returns",
"an",
"error",
"if",
"the",
"config",
"cannot",
"be",
"expected",
"to",
"run",
"a",
"FlagWorker",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/singular/flag.go#L31-L42 |
155,162 | juju/juju | worker/singular/flag.go | run | func (flag *FlagWorker) run() error {
runFunc := waitVacant
if flag.valid {
runFunc = keepOccupied
}
err := runFunc(flag.config, flag.catacomb.Dying())
return errors.Trace(err)
} | go | func (flag *FlagWorker) run() error {
runFunc := waitVacant
if flag.valid {
runFunc = keepOccupied
}
err := runFunc(flag.config, flag.catacomb.Dying())
return errors.Trace(err)
} | [
"func",
"(",
"flag",
"*",
"FlagWorker",
")",
"run",
"(",
")",
"error",
"{",
"runFunc",
":=",
"waitVacant",
"\n",
"if",
"flag",
".",
"valid",
"{",
"runFunc",
"=",
"keepOccupied",
"\n",
"}",
"\n",
"err",
":=",
"runFunc",
"(",
"flag",
".",
"config",
","... | // run invokes a suitable runFunc, depending on the value of .valid. | [
"run",
"invokes",
"a",
"suitable",
"runFunc",
"depending",
"on",
"the",
"value",
"of",
".",
"valid",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/singular/flag.go#L103-L110 |
155,163 | juju/juju | worker/singular/flag.go | keepOccupied | func keepOccupied(config FlagConfig, abort <-chan struct{}) error {
for {
select {
case <-abort:
return nil
case <-sleep(config):
success, err := claim(config)
if err != nil {
return errors.Trace(err)
}
if !success {
return ErrRefresh
}
}
}
} | go | func keepOccupied(config FlagConfig, abort <-chan struct{}) error {
for {
select {
case <-abort:
return nil
case <-sleep(config):
success, err := claim(config)
if err != nil {
return errors.Trace(err)
}
if !success {
return ErrRefresh
}
}
}
} | [
"func",
"keepOccupied",
"(",
"config",
"FlagConfig",
",",
"abort",
"<-",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"for",
"{",
"select",
"{",
"case",
"<-",
"abort",
":",
"return",
"nil",
"\n",
"case",
"<-",
"sleep",
"(",
"config",
")",
":",
"suc... | // keepOccupied is a runFunc that tries to keep a flag valid. | [
"keepOccupied",
"is",
"a",
"runFunc",
"that",
"tries",
"to",
"keep",
"a",
"flag",
"valid",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/singular/flag.go#L113-L128 |
155,164 | juju/juju | worker/singular/flag.go | claim | func claim(config FlagConfig) (bool, error) {
err := config.Facade.Claim(config.Duration)
cause := errors.Cause(err)
switch cause {
case nil:
return true, nil
case lease.ErrClaimDenied:
return false, nil
}
return false, errors.Trace(err)
} | go | func claim(config FlagConfig) (bool, error) {
err := config.Facade.Claim(config.Duration)
cause := errors.Cause(err)
switch cause {
case nil:
return true, nil
case lease.ErrClaimDenied:
return false, nil
}
return false, errors.Trace(err)
} | [
"func",
"claim",
"(",
"config",
"FlagConfig",
")",
"(",
"bool",
",",
"error",
")",
"{",
"err",
":=",
"config",
".",
"Facade",
".",
"Claim",
"(",
"config",
".",
"Duration",
")",
"\n",
"cause",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
"\n",
"sw... | // claim claims model ownership on behalf of a controller, and returns
// true if the attempt succeeded. | [
"claim",
"claims",
"model",
"ownership",
"on",
"behalf",
"of",
"a",
"controller",
"and",
"returns",
"true",
"if",
"the",
"attempt",
"succeeded",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/singular/flag.go#L132-L142 |
155,165 | juju/juju | worker/singular/flag.go | waitVacant | func waitVacant(config FlagConfig, _ <-chan struct{}) error {
if err := config.Facade.Wait(); err != nil {
return errors.Trace(err)
}
return ErrRefresh
} | go | func waitVacant(config FlagConfig, _ <-chan struct{}) error {
if err := config.Facade.Wait(); err != nil {
return errors.Trace(err)
}
return ErrRefresh
} | [
"func",
"waitVacant",
"(",
"config",
"FlagConfig",
",",
"_",
"<-",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"if",
"err",
":=",
"config",
".",
"Facade",
".",
"Wait",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Trace",
"("... | // wait is a runFunc that ignores its abort chan and always returns an error;
// either because of a failed api call, or a successful one, which indicates
// that no lease is held; hence, that the worker should be bounced. | [
"wait",
"is",
"a",
"runFunc",
"that",
"ignores",
"its",
"abort",
"chan",
"and",
"always",
"returns",
"an",
"error",
";",
"either",
"because",
"of",
"a",
"failed",
"api",
"call",
"or",
"a",
"successful",
"one",
"which",
"indicates",
"that",
"no",
"lease",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/singular/flag.go#L152-L157 |
155,166 | juju/juju | api/modelupgrader/modelupgrader.go | ModelEnvironVersion | func (c *Client) ModelEnvironVersion(tag names.ModelTag) (int, error) {
args := params.Entities{
Entities: []params.Entity{{Tag: tag.String()}},
}
var results params.IntResults
err := c.facade.FacadeCall("ModelEnvironVersion", &args, &results)
if err != nil {
return -1, errors.Trace(err)
}
if len(results.Results) != 1 {
return -1, errors.Errorf("expected 1 result, got %d", len(results.Results))
}
if err := results.Results[0].Error; err != nil {
return -1, err
}
return results.Results[0].Result, nil
} | go | func (c *Client) ModelEnvironVersion(tag names.ModelTag) (int, error) {
args := params.Entities{
Entities: []params.Entity{{Tag: tag.String()}},
}
var results params.IntResults
err := c.facade.FacadeCall("ModelEnvironVersion", &args, &results)
if err != nil {
return -1, errors.Trace(err)
}
if len(results.Results) != 1 {
return -1, errors.Errorf("expected 1 result, got %d", len(results.Results))
}
if err := results.Results[0].Error; err != nil {
return -1, err
}
return results.Results[0].Result, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ModelEnvironVersion",
"(",
"tag",
"names",
".",
"ModelTag",
")",
"(",
"int",
",",
"error",
")",
"{",
"args",
":=",
"params",
".",
"Entities",
"{",
"Entities",
":",
"[",
"]",
"params",
".",
"Entity",
"{",
"{",
... | // ModelEnvironVersion returns the current version of the environ corresponding
// to the specified model. | [
"ModelEnvironVersion",
"returns",
"the",
"current",
"version",
"of",
"the",
"environ",
"corresponding",
"to",
"the",
"specified",
"model",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelupgrader/modelupgrader.go#L34-L50 |
155,167 | juju/juju | api/modelupgrader/modelupgrader.go | SetModelEnvironVersion | func (c *Client) SetModelEnvironVersion(tag names.ModelTag, v int) error {
args := params.SetModelEnvironVersions{
Models: []params.SetModelEnvironVersion{{
ModelTag: tag.String(),
Version: v,
}},
}
var results params.ErrorResults
err := c.facade.FacadeCall("SetModelEnvironVersion", &args, &results)
if err != nil {
return errors.Trace(err)
}
return results.OneError()
} | go | func (c *Client) SetModelEnvironVersion(tag names.ModelTag, v int) error {
args := params.SetModelEnvironVersions{
Models: []params.SetModelEnvironVersion{{
ModelTag: tag.String(),
Version: v,
}},
}
var results params.ErrorResults
err := c.facade.FacadeCall("SetModelEnvironVersion", &args, &results)
if err != nil {
return errors.Trace(err)
}
return results.OneError()
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetModelEnvironVersion",
"(",
"tag",
"names",
".",
"ModelTag",
",",
"v",
"int",
")",
"error",
"{",
"args",
":=",
"params",
".",
"SetModelEnvironVersions",
"{",
"Models",
":",
"[",
"]",
"params",
".",
"SetModelEnvironV... | // SetModelEnvironVersion sets the current version of the environ corresponding
// to the specified model. | [
"SetModelEnvironVersion",
"sets",
"the",
"current",
"version",
"of",
"the",
"environ",
"corresponding",
"to",
"the",
"specified",
"model",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelupgrader/modelupgrader.go#L74-L87 |
155,168 | juju/juju | api/modelupgrader/modelupgrader.go | WatchModelEnvironVersion | func (c *Client) WatchModelEnvironVersion(tag names.ModelTag) (watcher.NotifyWatcher, error) {
return common.Watch(c.facade, "WatchModelEnvironVersion", tag)
} | go | func (c *Client) WatchModelEnvironVersion(tag names.ModelTag) (watcher.NotifyWatcher, error) {
return common.Watch(c.facade, "WatchModelEnvironVersion", tag)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"WatchModelEnvironVersion",
"(",
"tag",
"names",
".",
"ModelTag",
")",
"(",
"watcher",
".",
"NotifyWatcher",
",",
"error",
")",
"{",
"return",
"common",
".",
"Watch",
"(",
"c",
".",
"facade",
",",
"\"",
"\"",
",",
... | // WatchModelEnvironVersion starts a NotifyWatcher that notifies the caller upon
// changes to the environ version of the model with the specified tag. | [
"WatchModelEnvironVersion",
"starts",
"a",
"NotifyWatcher",
"that",
"notifies",
"the",
"caller",
"upon",
"changes",
"to",
"the",
"environ",
"version",
"of",
"the",
"model",
"with",
"the",
"specified",
"tag",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelupgrader/modelupgrader.go#L91-L93 |
155,169 | juju/juju | worker/containerbroker/mocks/dependency_mock.go | Abort | func (m *MockContext) Abort() <-chan struct{} {
ret := m.ctrl.Call(m, "Abort")
ret0, _ := ret[0].(<-chan struct{})
return ret0
} | go | func (m *MockContext) Abort() <-chan struct{} {
ret := m.ctrl.Call(m, "Abort")
ret0, _ := ret[0].(<-chan struct{})
return ret0
} | [
"func",
"(",
"m",
"*",
"MockContext",
")",
"Abort",
"(",
")",
"<-",
"chan",
"struct",
"{",
"}",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
... | // Abort mocks base method | [
"Abort",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/dependency_mock.go#L36-L40 |
155,170 | juju/juju | worker/containerbroker/mocks/dependency_mock.go | Abort | func (mr *MockContextMockRecorder) Abort() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Abort", reflect.TypeOf((*MockContext)(nil).Abort))
} | go | func (mr *MockContextMockRecorder) Abort() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Abort", reflect.TypeOf((*MockContext)(nil).Abort))
} | [
"func",
"(",
"mr",
"*",
"MockContextMockRecorder",
")",
"Abort",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"TypeOf... | // Abort indicates an expected call of Abort | [
"Abort",
"indicates",
"an",
"expected",
"call",
"of",
"Abort"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/containerbroker/mocks/dependency_mock.go#L43-L45 |
155,171 | juju/juju | api/highavailability/client.go | EnableHA | func (c *Client) EnableHA(
numControllers int, cons constraints.Value, placement []string,
) (params.ControllersChanges, error) {
var results params.ControllersChangeResults
arg := params.ControllersSpecs{
Specs: []params.ControllersSpec{{
NumControllers: numControllers,
Constraints: cons,
Placement: placement,
}}}
err := c.facade.FacadeCall("EnableHA", arg, &results)
if err != nil {
return params.ControllersChanges{}, err
}
if len(results.Results) != 1 {
return params.ControllersChanges{}, errors.Errorf("expected 1 result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return params.ControllersChanges{}, result.Error
}
return result.Result, nil
} | go | func (c *Client) EnableHA(
numControllers int, cons constraints.Value, placement []string,
) (params.ControllersChanges, error) {
var results params.ControllersChangeResults
arg := params.ControllersSpecs{
Specs: []params.ControllersSpec{{
NumControllers: numControllers,
Constraints: cons,
Placement: placement,
}}}
err := c.facade.FacadeCall("EnableHA", arg, &results)
if err != nil {
return params.ControllersChanges{}, err
}
if len(results.Results) != 1 {
return params.ControllersChanges{}, errors.Errorf("expected 1 result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return params.ControllersChanges{}, result.Error
}
return result.Result, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"EnableHA",
"(",
"numControllers",
"int",
",",
"cons",
"constraints",
".",
"Value",
",",
"placement",
"[",
"]",
"string",
",",
")",
"(",
"params",
".",
"ControllersChanges",
",",
"error",
")",
"{",
"var",
"results",
... | // EnableHA ensures the availability of Juju controllers. | [
"EnableHA",
"ensures",
"the",
"availability",
"of",
"Juju",
"controllers",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/highavailability/client.go#L32-L56 |
155,172 | juju/juju | api/highavailability/client.go | MongoUpgradeMode | func (c *Client) MongoUpgradeMode(v mongo.Version) (params.MongoUpgradeResults, error) {
arg := params.UpgradeMongoParams{
Target: params.MongoVersion{
Major: v.Major,
Minor: v.Minor,
Patch: v.Patch,
StorageEngine: string(v.StorageEngine),
},
}
results := params.MongoUpgradeResults{}
if err := c.facade.FacadeCall("StopHAReplicationForUpgrade", arg, &results); err != nil {
return results, errors.Annotate(err, "can not enter mongo upgrade mode")
}
return results, nil
} | go | func (c *Client) MongoUpgradeMode(v mongo.Version) (params.MongoUpgradeResults, error) {
arg := params.UpgradeMongoParams{
Target: params.MongoVersion{
Major: v.Major,
Minor: v.Minor,
Patch: v.Patch,
StorageEngine: string(v.StorageEngine),
},
}
results := params.MongoUpgradeResults{}
if err := c.facade.FacadeCall("StopHAReplicationForUpgrade", arg, &results); err != nil {
return results, errors.Annotate(err, "can not enter mongo upgrade mode")
}
return results, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"MongoUpgradeMode",
"(",
"v",
"mongo",
".",
"Version",
")",
"(",
"params",
".",
"MongoUpgradeResults",
",",
"error",
")",
"{",
"arg",
":=",
"params",
".",
"UpgradeMongoParams",
"{",
"Target",
":",
"params",
".",
"Mon... | // MongoUpgradeMode will make all Slave members of the HA
// to shut down their mongo server. | [
"MongoUpgradeMode",
"will",
"make",
"all",
"Slave",
"members",
"of",
"the",
"HA",
"to",
"shut",
"down",
"their",
"mongo",
"server",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/highavailability/client.go#L60-L74 |
155,173 | juju/juju | api/highavailability/client.go | ResumeHAReplicationAfterUpgrade | func (c *Client) ResumeHAReplicationAfterUpgrade(members []replicaset.Member) error {
arg := params.ResumeReplicationParams{
Members: members,
}
if err := c.facade.FacadeCall("ResumeHAReplicationAfterUpgrad", arg, nil); err != nil {
return errors.Annotate(err, "can not resume ha")
}
return nil
} | go | func (c *Client) ResumeHAReplicationAfterUpgrade(members []replicaset.Member) error {
arg := params.ResumeReplicationParams{
Members: members,
}
if err := c.facade.FacadeCall("ResumeHAReplicationAfterUpgrad", arg, nil); err != nil {
return errors.Annotate(err, "can not resume ha")
}
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ResumeHAReplicationAfterUpgrade",
"(",
"members",
"[",
"]",
"replicaset",
".",
"Member",
")",
"error",
"{",
"arg",
":=",
"params",
".",
"ResumeReplicationParams",
"{",
"Members",
":",
"members",
",",
"}",
"\n",
"if",
... | // ResumeHAReplicationAfterUpgrade makes all members part of HA again. | [
"ResumeHAReplicationAfterUpgrade",
"makes",
"all",
"members",
"part",
"of",
"HA",
"again",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/highavailability/client.go#L77-L85 |
155,174 | juju/juju | state/globalclock/updater.go | Advance | func (u *Updater) Advance(d time.Duration, _ <-chan struct{}) error {
if d < 0 {
return errors.NotValidf("duration %s", d)
}
coll, closer := u.collection()
defer closer()
new := u.time.Add(d)
if err := coll.Update(matchTimeDoc(u.time), setTimeDoc(new)); err != nil {
if err == mgo.ErrNotFound {
// The document can only be not found if the clock
// was updated by another updater concurrently. We
// re-read the clock, and return a specific error
// to indicate to the user that they should try
// again later.
t, err := readClock(coll)
if err != nil {
return errors.Annotate(err, "refreshing time after write conflict")
}
u.time = t
return globalclock.ErrConcurrentUpdate
}
return errors.Annotatef(err,
"adding %s to current time %s", d, u.time,
)
}
u.time = new
return nil
} | go | func (u *Updater) Advance(d time.Duration, _ <-chan struct{}) error {
if d < 0 {
return errors.NotValidf("duration %s", d)
}
coll, closer := u.collection()
defer closer()
new := u.time.Add(d)
if err := coll.Update(matchTimeDoc(u.time), setTimeDoc(new)); err != nil {
if err == mgo.ErrNotFound {
// The document can only be not found if the clock
// was updated by another updater concurrently. We
// re-read the clock, and return a specific error
// to indicate to the user that they should try
// again later.
t, err := readClock(coll)
if err != nil {
return errors.Annotate(err, "refreshing time after write conflict")
}
u.time = t
return globalclock.ErrConcurrentUpdate
}
return errors.Annotatef(err,
"adding %s to current time %s", d, u.time,
)
}
u.time = new
return nil
} | [
"func",
"(",
"u",
"*",
"Updater",
")",
"Advance",
"(",
"d",
"time",
".",
"Duration",
",",
"_",
"<-",
"chan",
"struct",
"{",
"}",
")",
"error",
"{",
"if",
"d",
"<",
"0",
"{",
"return",
"errors",
".",
"NotValidf",
"(",
"\"",
"\"",
",",
"d",
")",
... | // Advance adds the given duration to the global clock, ensuring
// that the clock has not been updated concurrently.
//
// Advance will return ErrConcurrentUpdate if another updater
// updates the clock concurrently. In this case, the updater
// will refresh its view of the clock, and the caller can
// attempt Advance later.
//
// If Advance returns any error other than ErrConcurrentUpdate,
// the Updater should be considered invalid, and the caller
// should obtain a new Updater. Failing to do so could lead
// to non-monotonic time, since there is no way of knowing in
// general whether or not the database was updated. | [
"Advance",
"adds",
"the",
"given",
"duration",
"to",
"the",
"global",
"clock",
"ensuring",
"that",
"the",
"clock",
"has",
"not",
"been",
"updated",
"concurrently",
".",
"Advance",
"will",
"return",
"ErrConcurrentUpdate",
"if",
"another",
"updater",
"updates",
"t... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/globalclock/updater.go#L62-L90 |
155,175 | juju/juju | state/globalclock/updater.go | ensureClock | func (u *Updater) ensureClock() (time.Time, error) {
coll, closer := u.collection()
defer closer()
// Read the existing clock document if it's there, initialising
// it with a zero time otherwise.
var doc clockDoc
if _, err := coll.FindId(clockDocID).Apply(mgo.Change{
// We can't use $set here, as otherwise we'll
// overwrite an existing document.
Update: bson.D{{"$inc", bson.D{{"time", 0}}}},
Upsert: true,
}, &doc); err != nil {
return time.Time{}, errors.Annotate(err, "upserting clock document")
}
return doc.time(), nil
} | go | func (u *Updater) ensureClock() (time.Time, error) {
coll, closer := u.collection()
defer closer()
// Read the existing clock document if it's there, initialising
// it with a zero time otherwise.
var doc clockDoc
if _, err := coll.FindId(clockDocID).Apply(mgo.Change{
// We can't use $set here, as otherwise we'll
// overwrite an existing document.
Update: bson.D{{"$inc", bson.D{{"time", 0}}}},
Upsert: true,
}, &doc); err != nil {
return time.Time{}, errors.Annotate(err, "upserting clock document")
}
return doc.time(), nil
} | [
"func",
"(",
"u",
"*",
"Updater",
")",
"ensureClock",
"(",
")",
"(",
"time",
".",
"Time",
",",
"error",
")",
"{",
"coll",
",",
"closer",
":=",
"u",
".",
"collection",
"(",
")",
"\n",
"defer",
"closer",
"(",
")",
"\n\n",
"// Read the existing clock docu... | // ensureClock creates the initial epoch document if it doesn't already exist.
// Otherwise, the most recently written time is returned. | [
"ensureClock",
"creates",
"the",
"initial",
"epoch",
"document",
"if",
"it",
"doesn",
"t",
"already",
"exist",
".",
"Otherwise",
"the",
"most",
"recently",
"written",
"time",
"is",
"returned",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/globalclock/updater.go#L94-L110 |
155,176 | juju/juju | apiserver/facade/registry.go | Register | func (f *Registry) Register(name string, version int, factory Factory, facadeType reflect.Type) error {
if f.facades == nil {
f.facades = make(map[string]versions, 1)
}
record := record{
factory: factory,
facadeType: facadeType,
}
if vers, ok := f.facades[name]; ok {
if _, ok := vers[version]; ok {
fullname := fmt.Sprintf("%s(%d)", name, version)
return fmt.Errorf("object %q already registered", fullname)
}
vers[version] = record
} else {
f.facades[name] = versions{version: record}
}
return nil
} | go | func (f *Registry) Register(name string, version int, factory Factory, facadeType reflect.Type) error {
if f.facades == nil {
f.facades = make(map[string]versions, 1)
}
record := record{
factory: factory,
facadeType: facadeType,
}
if vers, ok := f.facades[name]; ok {
if _, ok := vers[version]; ok {
fullname := fmt.Sprintf("%s(%d)", name, version)
return fmt.Errorf("object %q already registered", fullname)
}
vers[version] = record
} else {
f.facades[name] = versions{version: record}
}
return nil
} | [
"func",
"(",
"f",
"*",
"Registry",
")",
"Register",
"(",
"name",
"string",
",",
"version",
"int",
",",
"factory",
"Factory",
",",
"facadeType",
"reflect",
".",
"Type",
")",
"error",
"{",
"if",
"f",
".",
"facades",
"==",
"nil",
"{",
"f",
".",
"facades... | // Register adds a single named facade at a given version to the registry.
// Factory will be called when someone wants to instantiate an object of
// this facade, and facadeType defines the concrete type that the returned object will be.
// The Type information is used to define what methods will be exported in the
// API, and it must exactly match the actual object returned by the factory. | [
"Register",
"adds",
"a",
"single",
"named",
"facade",
"at",
"a",
"given",
"version",
"to",
"the",
"registry",
".",
"Factory",
"will",
"be",
"called",
"when",
"someone",
"wants",
"to",
"instantiate",
"an",
"object",
"of",
"this",
"facade",
"and",
"facadeType"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facade/registry.go#L53-L71 |
155,177 | juju/juju | apiserver/facade/registry.go | lookup | func (f *Registry) lookup(name string, version int) (record, error) {
if versions, ok := f.facades[name]; ok {
if record, ok := versions[version]; ok {
return record, nil
}
}
return record{}, errors.NotFoundf("%s(%d)", name, version)
} | go | func (f *Registry) lookup(name string, version int) (record, error) {
if versions, ok := f.facades[name]; ok {
if record, ok := versions[version]; ok {
return record, nil
}
}
return record{}, errors.NotFoundf("%s(%d)", name, version)
} | [
"func",
"(",
"f",
"*",
"Registry",
")",
"lookup",
"(",
"name",
"string",
",",
"version",
"int",
")",
"(",
"record",
",",
"error",
")",
"{",
"if",
"versions",
",",
"ok",
":=",
"f",
".",
"facades",
"[",
"name",
"]",
";",
"ok",
"{",
"if",
"record",
... | // lookup translates a facade name and version into a record. | [
"lookup",
"translates",
"a",
"facade",
"name",
"and",
"version",
"into",
"a",
"record",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facade/registry.go#L74-L81 |
155,178 | juju/juju | apiserver/facade/registry.go | GetFactory | func (f *Registry) GetFactory(name string, version int) (Factory, error) {
record, err := f.lookup(name, version)
if err != nil {
return nil, err
}
return record.factory, nil
} | go | func (f *Registry) GetFactory(name string, version int) (Factory, error) {
record, err := f.lookup(name, version)
if err != nil {
return nil, err
}
return record.factory, nil
} | [
"func",
"(",
"f",
"*",
"Registry",
")",
"GetFactory",
"(",
"name",
"string",
",",
"version",
"int",
")",
"(",
"Factory",
",",
"error",
")",
"{",
"record",
",",
"err",
":=",
"f",
".",
"lookup",
"(",
"name",
",",
"version",
")",
"\n",
"if",
"err",
... | // GetFactory returns just the Factory for a given Facade name and version.
// See also GetType for getting the type information instead of the creation factory. | [
"GetFactory",
"returns",
"just",
"the",
"Factory",
"for",
"a",
"given",
"Facade",
"name",
"and",
"version",
".",
"See",
"also",
"GetType",
"for",
"getting",
"the",
"type",
"information",
"instead",
"of",
"the",
"creation",
"factory",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facade/registry.go#L85-L91 |
155,179 | juju/juju | apiserver/facade/registry.go | List | func (f *Registry) List() []Description {
names := make([]string, 0, len(f.facades))
for name := range f.facades {
names = append(names, name)
}
sort.Strings(names)
descriptions := make([]Description, 0, len(f.facades))
for _, name := range names {
facades := f.facades[name]
description := descriptionFromVersions(name, facades)
if len(description.Versions) > 0 {
descriptions = append(descriptions, description)
}
}
return descriptions
} | go | func (f *Registry) List() []Description {
names := make([]string, 0, len(f.facades))
for name := range f.facades {
names = append(names, name)
}
sort.Strings(names)
descriptions := make([]Description, 0, len(f.facades))
for _, name := range names {
facades := f.facades[name]
description := descriptionFromVersions(name, facades)
if len(description.Versions) > 0 {
descriptions = append(descriptions, description)
}
}
return descriptions
} | [
"func",
"(",
"f",
"*",
"Registry",
")",
"List",
"(",
")",
"[",
"]",
"Description",
"{",
"names",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"f",
".",
"facades",
")",
")",
"\n",
"for",
"name",
":=",
"range",
"f",
".",
"f... | // List returns a slice describing each of the registered Facades. | [
"List",
"returns",
"a",
"slice",
"describing",
"each",
"of",
"the",
"registered",
"Facades",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facade/registry.go#L126-L141 |
155,180 | juju/juju | apiserver/facade/registry.go | ListDetails | func (f *Registry) ListDetails() []Details {
names := make([]string, 0, len(f.facades))
for name := range f.facades {
names = append(names, name)
}
sort.Strings(names)
var details []Details
for _, name := range names {
for v, info := range f.facades[name] {
details = append(details, Details{
Name: name,
Version: v,
Factory: info.factory,
Type: info.facadeType,
})
}
}
return details
} | go | func (f *Registry) ListDetails() []Details {
names := make([]string, 0, len(f.facades))
for name := range f.facades {
names = append(names, name)
}
sort.Strings(names)
var details []Details
for _, name := range names {
for v, info := range f.facades[name] {
details = append(details, Details{
Name: name,
Version: v,
Factory: info.factory,
Type: info.facadeType,
})
}
}
return details
} | [
"func",
"(",
"f",
"*",
"Registry",
")",
"ListDetails",
"(",
")",
"[",
"]",
"Details",
"{",
"names",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"f",
".",
"facades",
")",
")",
"\n",
"for",
"name",
":=",
"range",
"f",
".",
... | // ListDetails returns information about all the facades
// registered in f, ordered lexically by name. | [
"ListDetails",
"returns",
"information",
"about",
"all",
"the",
"facades",
"registered",
"in",
"f",
"ordered",
"lexically",
"by",
"name",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facade/registry.go#L161-L179 |
155,181 | juju/juju | apiserver/facade/registry.go | Discard | func (f *Registry) Discard(name string, version int) {
if versions, ok := f.facades[name]; ok {
delete(versions, version)
if len(versions) == 0 {
delete(f.facades, name)
}
}
} | go | func (f *Registry) Discard(name string, version int) {
if versions, ok := f.facades[name]; ok {
delete(versions, version)
if len(versions) == 0 {
delete(f.facades, name)
}
}
} | [
"func",
"(",
"f",
"*",
"Registry",
")",
"Discard",
"(",
"name",
"string",
",",
"version",
"int",
")",
"{",
"if",
"versions",
",",
"ok",
":=",
"f",
".",
"facades",
"[",
"name",
"]",
";",
"ok",
"{",
"delete",
"(",
"versions",
",",
"version",
")",
"... | // Discard gets rid of a registration that has already been done. Calling
// discard on an entry that is not present is not considered an error. | [
"Discard",
"gets",
"rid",
"of",
"a",
"registration",
"that",
"has",
"already",
"been",
"done",
".",
"Calling",
"discard",
"on",
"an",
"entry",
"that",
"is",
"not",
"present",
"is",
"not",
"considered",
"an",
"error",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facade/registry.go#L183-L190 |
155,182 | juju/juju | apiserver/facade/registry.go | validateNewFacade | func validateNewFacade(funcValue reflect.Value) (bool, error) {
if !funcValue.IsValid() {
return false, fmt.Errorf("cannot wrap nil")
}
if funcValue.Kind() != reflect.Func {
return false, fmt.Errorf("wrong type %q is not a function", funcValue.Kind())
}
funcType := funcValue.Type()
funcName := runtime.FuncForPC(funcValue.Pointer()).Name()
badSigError := errors.Errorf(""+
"function %q does not have the signature "+
"func (facade.Context) (*Type, error), or "+
"func (*state.State, facade.Resources, facade.Authorizer) (*Type, error)", funcName)
if funcType.NumOut() != 2 {
return false, errors.Trace(badSigError)
}
var (
facadeType reflect.Type
nice bool
)
inArgCount := funcType.NumIn()
switch inArgCount {
case 1:
facadeType = reflect.TypeOf((*niceFactory)(nil)).Elem()
nice = true
case 3:
facadeType = reflect.TypeOf((*nastyFactory)(nil)).Elem()
default:
return false, errors.Trace(badSigError)
}
isSame := true
for i := 0; i < inArgCount; i++ {
if funcType.In(i) != facadeType.In(i) {
isSame = false
break
}
}
if funcType.Out(1) != facadeType.Out(1) {
isSame = false
}
if !isSame {
return false, errors.Trace(badSigError)
}
return nice, nil
} | go | func validateNewFacade(funcValue reflect.Value) (bool, error) {
if !funcValue.IsValid() {
return false, fmt.Errorf("cannot wrap nil")
}
if funcValue.Kind() != reflect.Func {
return false, fmt.Errorf("wrong type %q is not a function", funcValue.Kind())
}
funcType := funcValue.Type()
funcName := runtime.FuncForPC(funcValue.Pointer()).Name()
badSigError := errors.Errorf(""+
"function %q does not have the signature "+
"func (facade.Context) (*Type, error), or "+
"func (*state.State, facade.Resources, facade.Authorizer) (*Type, error)", funcName)
if funcType.NumOut() != 2 {
return false, errors.Trace(badSigError)
}
var (
facadeType reflect.Type
nice bool
)
inArgCount := funcType.NumIn()
switch inArgCount {
case 1:
facadeType = reflect.TypeOf((*niceFactory)(nil)).Elem()
nice = true
case 3:
facadeType = reflect.TypeOf((*nastyFactory)(nil)).Elem()
default:
return false, errors.Trace(badSigError)
}
isSame := true
for i := 0; i < inArgCount; i++ {
if funcType.In(i) != facadeType.In(i) {
isSame = false
break
}
}
if funcType.Out(1) != facadeType.Out(1) {
isSame = false
}
if !isSame {
return false, errors.Trace(badSigError)
}
return nice, nil
} | [
"func",
"validateNewFacade",
"(",
"funcValue",
"reflect",
".",
"Value",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"!",
"funcValue",
".",
"IsValid",
"(",
")",
"{",
"return",
"false",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
... | // validateNewFacade ensures that the facade factory we have has the right
// input and output parameters for being used as a NewFoo function. | [
"validateNewFacade",
"ensures",
"that",
"the",
"facade",
"factory",
"we",
"have",
"has",
"the",
"right",
"input",
"and",
"output",
"parameters",
"for",
"being",
"used",
"as",
"a",
"NewFoo",
"function",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facade/registry.go#L200-L248 |
155,183 | juju/juju | state/watcher/watcher.go | match | func (k watchKey) match(k1 watchKey) bool {
if k.c != k1.c {
return false
}
if k.id == nil {
// k refers to entire collection
return true
}
return k.id == k1.id
} | go | func (k watchKey) match(k1 watchKey) bool {
if k.c != k1.c {
return false
}
if k.id == nil {
// k refers to entire collection
return true
}
return k.id == k1.id
} | [
"func",
"(",
"k",
"watchKey",
")",
"match",
"(",
"k1",
"watchKey",
")",
"bool",
"{",
"if",
"k",
".",
"c",
"!=",
"k1",
".",
"c",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"k",
".",
"id",
"==",
"nil",
"{",
"// k refers to entire collection",
"re... | // match returns whether the receiving watch key,
// which may refer to a particular item or
// an entire collection, matches k1, which refers
// to a particular item. | [
"match",
"returns",
"whether",
"the",
"receiving",
"watch",
"key",
"which",
"may",
"refer",
"to",
"a",
"particular",
"item",
"or",
"an",
"entire",
"collection",
"matches",
"k1",
"which",
"refers",
"to",
"a",
"particular",
"item",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/watcher/watcher.go#L139-L148 |
155,184 | juju/juju | state/watcher/watcher.go | WatchCollection | func (w *Watcher) WatchCollection(collection string, ch chan<- Change) {
w.WatchCollectionWithFilter(collection, ch, nil)
} | go | func (w *Watcher) WatchCollection(collection string, ch chan<- Change) {
w.WatchCollectionWithFilter(collection, ch, nil)
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"WatchCollection",
"(",
"collection",
"string",
",",
"ch",
"chan",
"<-",
"Change",
")",
"{",
"w",
".",
"WatchCollectionWithFilter",
"(",
"collection",
",",
"ch",
",",
"nil",
")",
"\n",
"}"
] | // WatchCollection starts watching the given collection.
// An event will be sent onto ch whenever the txn-revno field is observed
// to change after a transaction is applied for any document in the collection. | [
"WatchCollection",
"starts",
"watching",
"the",
"given",
"collection",
".",
"An",
"event",
"will",
"be",
"sent",
"onto",
"ch",
"whenever",
"the",
"txn",
"-",
"revno",
"field",
"is",
"observed",
"to",
"change",
"after",
"a",
"transaction",
"is",
"applied",
"f... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/watcher/watcher.go#L329-L331 |
155,185 | juju/juju | state/watcher/watcher.go | WatchCollectionWithFilter | func (w *Watcher) WatchCollectionWithFilter(collection string, ch chan<- Change, filter func(interface{}) bool) {
w.sendAndWaitReq(reqWatch{
key: watchKey{collection, nil},
info: watchInfo{ch, 0, filter},
registeredCh: make(chan error),
})
} | go | func (w *Watcher) WatchCollectionWithFilter(collection string, ch chan<- Change, filter func(interface{}) bool) {
w.sendAndWaitReq(reqWatch{
key: watchKey{collection, nil},
info: watchInfo{ch, 0, filter},
registeredCh: make(chan error),
})
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"WatchCollectionWithFilter",
"(",
"collection",
"string",
",",
"ch",
"chan",
"<-",
"Change",
",",
"filter",
"func",
"(",
"interface",
"{",
"}",
")",
"bool",
")",
"{",
"w",
".",
"sendAndWaitReq",
"(",
"reqWatch",
"{"... | // WatchCollectionWithFilter starts watching the given collection.
// An event will be sent onto ch whenever the txn-revno field is observed
// to change after a transaction is applied for any document in the collection, so long as the
// specified filter function returns true when called with the document id value. | [
"WatchCollectionWithFilter",
"starts",
"watching",
"the",
"given",
"collection",
".",
"An",
"event",
"will",
"be",
"sent",
"onto",
"ch",
"whenever",
"the",
"txn",
"-",
"revno",
"field",
"is",
"observed",
"to",
"change",
"after",
"a",
"transaction",
"is",
"appl... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/watcher/watcher.go#L337-L343 |
155,186 | juju/juju | state/watcher/watcher.go | Unwatch | func (w *Watcher) Unwatch(collection string, id interface{}, ch chan<- Change) {
if id == nil {
panic("watcher: cannot unwatch a document with nil id")
}
w.sendReq(reqUnwatch{watchKey{collection, id}, ch})
} | go | func (w *Watcher) Unwatch(collection string, id interface{}, ch chan<- Change) {
if id == nil {
panic("watcher: cannot unwatch a document with nil id")
}
w.sendReq(reqUnwatch{watchKey{collection, id}, ch})
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"Unwatch",
"(",
"collection",
"string",
",",
"id",
"interface",
"{",
"}",
",",
"ch",
"chan",
"<-",
"Change",
")",
"{",
"if",
"id",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"w",
"."... | // Unwatch stops watching the given collection and document id via ch. | [
"Unwatch",
"stops",
"watching",
"the",
"given",
"collection",
"and",
"document",
"id",
"via",
"ch",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/watcher/watcher.go#L346-L351 |
155,187 | juju/juju | state/watcher/watcher.go | initLastId | func (w *Watcher) initLastId() error {
var entry struct {
Id interface{} `bson:"_id"`
}
err := w.log.Find(nil).Sort("-$natural").One(&entry)
if err != nil && err != mgo.ErrNotFound {
return errors.Trace(err)
}
w.lastId = entry.Id
return nil
} | go | func (w *Watcher) initLastId() error {
var entry struct {
Id interface{} `bson:"_id"`
}
err := w.log.Find(nil).Sort("-$natural").One(&entry)
if err != nil && err != mgo.ErrNotFound {
return errors.Trace(err)
}
w.lastId = entry.Id
return nil
} | [
"func",
"(",
"w",
"*",
"Watcher",
")",
"initLastId",
"(",
")",
"error",
"{",
"var",
"entry",
"struct",
"{",
"Id",
"interface",
"{",
"}",
"`bson:\"_id\"`",
"\n",
"}",
"\n",
"err",
":=",
"w",
".",
"log",
".",
"Find",
"(",
"nil",
")",
".",
"Sort",
"... | // initLastId reads the most recent changelog document and initializes
// lastId with it. This causes all history that precedes the creation
// of the watcher to be ignored. | [
"initLastId",
"reads",
"the",
"most",
"recent",
"changelog",
"document",
"and",
"initializes",
"lastId",
"with",
"it",
".",
"This",
"causes",
"all",
"history",
"that",
"precedes",
"the",
"creation",
"of",
"the",
"watcher",
"to",
"be",
"ignored",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/watcher/watcher.go#L523-L533 |
155,188 | juju/juju | apiserver/facades/agent/upgradeseries/upgradeseries.go | NewAPI | func NewAPI(ctx facade.Context) (*API, error) {
leadership, err := common.NewLeadershipPinningFacade(ctx)
if err != nil {
if errors.IsNotImplemented(errors.Cause(err)) {
leadership = disabledLeadershipPinningFacade{}
} else {
return nil, errors.Trace(err)
}
}
return NewUpgradeSeriesAPI(common.UpgradeSeriesState{St: ctx.State()}, ctx.Resources(), ctx.Auth(), leadership)
} | go | func NewAPI(ctx facade.Context) (*API, error) {
leadership, err := common.NewLeadershipPinningFacade(ctx)
if err != nil {
if errors.IsNotImplemented(errors.Cause(err)) {
leadership = disabledLeadershipPinningFacade{}
} else {
return nil, errors.Trace(err)
}
}
return NewUpgradeSeriesAPI(common.UpgradeSeriesState{St: ctx.State()}, ctx.Resources(), ctx.Auth(), leadership)
} | [
"func",
"NewAPI",
"(",
"ctx",
"facade",
".",
"Context",
")",
"(",
"*",
"API",
",",
"error",
")",
"{",
"leadership",
",",
"err",
":=",
"common",
".",
"NewLeadershipPinningFacade",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"errors",
"... | // NewAPI creates a new instance of the API with the given context | [
"NewAPI",
"creates",
"a",
"new",
"instance",
"of",
"the",
"API",
"with",
"the",
"given",
"context"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/upgradeseries/upgradeseries.go#L30-L40 |
155,189 | juju/juju | apiserver/facades/agent/upgradeseries/upgradeseries.go | NewUpgradeSeriesAPI | func NewUpgradeSeriesAPI(
st common.UpgradeSeriesBackend,
resources facade.Resources,
authorizer facade.Authorizer,
leadership common.LeadershipPinningAPI,
) (*API, error) {
if !authorizer.AuthMachineAgent() {
return nil, common.ErrPerm
}
accessMachine := func() (common.AuthFunc, error) {
return func(tag names.Tag) bool {
return authorizer.AuthOwner(tag)
}, nil
}
accessUnit := func() (common.AuthFunc, error) {
return func(tag names.Tag) bool {
return false
}, nil
}
return &API{
st: st,
resources: resources,
auth: authorizer,
UpgradeSeriesAPI: common.NewUpgradeSeriesAPI(st, resources, authorizer, accessMachine, accessUnit, logger),
LeadershipPinningAPI: leadership,
}, nil
} | go | func NewUpgradeSeriesAPI(
st common.UpgradeSeriesBackend,
resources facade.Resources,
authorizer facade.Authorizer,
leadership common.LeadershipPinningAPI,
) (*API, error) {
if !authorizer.AuthMachineAgent() {
return nil, common.ErrPerm
}
accessMachine := func() (common.AuthFunc, error) {
return func(tag names.Tag) bool {
return authorizer.AuthOwner(tag)
}, nil
}
accessUnit := func() (common.AuthFunc, error) {
return func(tag names.Tag) bool {
return false
}, nil
}
return &API{
st: st,
resources: resources,
auth: authorizer,
UpgradeSeriesAPI: common.NewUpgradeSeriesAPI(st, resources, authorizer, accessMachine, accessUnit, logger),
LeadershipPinningAPI: leadership,
}, nil
} | [
"func",
"NewUpgradeSeriesAPI",
"(",
"st",
"common",
".",
"UpgradeSeriesBackend",
",",
"resources",
"facade",
".",
"Resources",
",",
"authorizer",
"facade",
".",
"Authorizer",
",",
"leadership",
"common",
".",
"LeadershipPinningAPI",
",",
")",
"(",
"*",
"API",
",... | // NewUpgradeSeriesAPI creates a new instance of the API server using the
// dedicated state indirection. | [
"NewUpgradeSeriesAPI",
"creates",
"a",
"new",
"instance",
"of",
"the",
"API",
"server",
"using",
"the",
"dedicated",
"state",
"indirection",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/upgradeseries/upgradeseries.go#L44-L72 |
155,190 | juju/juju | apiserver/facades/agent/upgradeseries/upgradeseries.go | MachineStatus | func (a *API) MachineStatus(args params.Entities) (params.UpgradeSeriesStatusResults, error) {
result := params.UpgradeSeriesStatusResults{}
canAccess, err := a.AccessMachine()
if err != nil {
return result, err
}
results := make([]params.UpgradeSeriesStatusResult, len(args.Entities))
for i, entity := range args.Entities {
machine, err := a.authAndMachine(entity, canAccess)
if err != nil {
results[i].Error = common.ServerError(err)
continue
}
status, err := machine.UpgradeSeriesStatus()
if err != nil {
results[i].Error = common.ServerError(err)
continue
}
results[i].Status = status
}
result.Results = results
return result, nil
} | go | func (a *API) MachineStatus(args params.Entities) (params.UpgradeSeriesStatusResults, error) {
result := params.UpgradeSeriesStatusResults{}
canAccess, err := a.AccessMachine()
if err != nil {
return result, err
}
results := make([]params.UpgradeSeriesStatusResult, len(args.Entities))
for i, entity := range args.Entities {
machine, err := a.authAndMachine(entity, canAccess)
if err != nil {
results[i].Error = common.ServerError(err)
continue
}
status, err := machine.UpgradeSeriesStatus()
if err != nil {
results[i].Error = common.ServerError(err)
continue
}
results[i].Status = status
}
result.Results = results
return result, nil
} | [
"func",
"(",
"a",
"*",
"API",
")",
"MachineStatus",
"(",
"args",
"params",
".",
"Entities",
")",
"(",
"params",
".",
"UpgradeSeriesStatusResults",
",",
"error",
")",
"{",
"result",
":=",
"params",
".",
"UpgradeSeriesStatusResults",
"{",
"}",
"\n\n",
"canAcce... | // MachineStatus gets the current upgrade-series status of a machine. | [
"MachineStatus",
"gets",
"the",
"current",
"upgrade",
"-",
"series",
"status",
"of",
"a",
"machine",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/upgradeseries/upgradeseries.go#L75-L100 |
155,191 | juju/juju | apiserver/facades/agent/upgradeseries/upgradeseries.go | SetMachineStatus | func (a *API) SetMachineStatus(args params.UpgradeSeriesStatusParams) (params.ErrorResults, error) {
result := params.ErrorResults{}
canAccess, err := a.AccessMachine()
if err != nil {
return result, err
}
results := make([]params.ErrorResult, len(args.Params))
for i, param := range args.Params {
machine, err := a.authAndMachine(param.Entity, canAccess)
if err != nil {
results[i].Error = common.ServerError(err)
continue
}
err = machine.SetUpgradeSeriesStatus(param.Status, param.Message)
if err != nil {
results[i].Error = common.ServerError(err)
}
}
result.Results = results
return result, nil
} | go | func (a *API) SetMachineStatus(args params.UpgradeSeriesStatusParams) (params.ErrorResults, error) {
result := params.ErrorResults{}
canAccess, err := a.AccessMachine()
if err != nil {
return result, err
}
results := make([]params.ErrorResult, len(args.Params))
for i, param := range args.Params {
machine, err := a.authAndMachine(param.Entity, canAccess)
if err != nil {
results[i].Error = common.ServerError(err)
continue
}
err = machine.SetUpgradeSeriesStatus(param.Status, param.Message)
if err != nil {
results[i].Error = common.ServerError(err)
}
}
result.Results = results
return result, nil
} | [
"func",
"(",
"a",
"*",
"API",
")",
"SetMachineStatus",
"(",
"args",
"params",
".",
"UpgradeSeriesStatusParams",
")",
"(",
"params",
".",
"ErrorResults",
",",
"error",
")",
"{",
"result",
":=",
"params",
".",
"ErrorResults",
"{",
"}",
"\n\n",
"canAccess",
"... | // SetMachineStatus sets the current upgrade-series status of a machine. | [
"SetMachineStatus",
"sets",
"the",
"current",
"upgrade",
"-",
"series",
"status",
"of",
"a",
"machine",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/upgradeseries/upgradeseries.go#L103-L126 |
155,192 | juju/juju | apiserver/facades/agent/upgradeseries/upgradeseries.go | TargetSeries | func (a *API) TargetSeries(args params.Entities) (params.StringResults, error) {
result := params.StringResults{}
canAccess, err := a.AccessMachine()
if err != nil {
return result, err
}
results := make([]params.StringResult, len(args.Entities))
for i, entity := range args.Entities {
machine, err := a.authAndMachine(entity, canAccess)
if err != nil {
results[i].Error = common.ServerError(err)
continue
}
target, err := machine.UpgradeSeriesTarget()
if err != nil {
results[i].Error = common.ServerError(err)
}
results[i].Result = target
}
result.Results = results
return result, nil
} | go | func (a *API) TargetSeries(args params.Entities) (params.StringResults, error) {
result := params.StringResults{}
canAccess, err := a.AccessMachine()
if err != nil {
return result, err
}
results := make([]params.StringResult, len(args.Entities))
for i, entity := range args.Entities {
machine, err := a.authAndMachine(entity, canAccess)
if err != nil {
results[i].Error = common.ServerError(err)
continue
}
target, err := machine.UpgradeSeriesTarget()
if err != nil {
results[i].Error = common.ServerError(err)
}
results[i].Result = target
}
result.Results = results
return result, nil
} | [
"func",
"(",
"a",
"*",
"API",
")",
"TargetSeries",
"(",
"args",
"params",
".",
"Entities",
")",
"(",
"params",
".",
"StringResults",
",",
"error",
")",
"{",
"result",
":=",
"params",
".",
"StringResults",
"{",
"}",
"\n\n",
"canAccess",
",",
"err",
":="... | // TargetSeries returns the series that a machine has been locked
// for upgrading to. | [
"TargetSeries",
"returns",
"the",
"series",
"that",
"a",
"machine",
"has",
"been",
"locked",
"for",
"upgrading",
"to",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/upgradeseries/upgradeseries.go#L130-L154 |
155,193 | juju/juju | apiserver/facades/agent/upgradeseries/upgradeseries.go | StartUnitCompletion | func (a *API) StartUnitCompletion(args params.UpgradeSeriesStartUnitCompletionParam) (params.ErrorResults, error) {
result := params.ErrorResults{
Results: make([]params.ErrorResult, len(args.Entities)),
}
canAccess, err := a.AccessMachine()
if err != nil {
return params.ErrorResults{}, err
}
for i, entity := range args.Entities {
machine, err := a.authAndMachine(entity, canAccess)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
err = machine.StartUpgradeSeriesUnitCompletion(args.Message)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
}
return result, nil
} | go | func (a *API) StartUnitCompletion(args params.UpgradeSeriesStartUnitCompletionParam) (params.ErrorResults, error) {
result := params.ErrorResults{
Results: make([]params.ErrorResult, len(args.Entities)),
}
canAccess, err := a.AccessMachine()
if err != nil {
return params.ErrorResults{}, err
}
for i, entity := range args.Entities {
machine, err := a.authAndMachine(entity, canAccess)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
err = machine.StartUpgradeSeriesUnitCompletion(args.Message)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
}
return result, nil
} | [
"func",
"(",
"a",
"*",
"API",
")",
"StartUnitCompletion",
"(",
"args",
"params",
".",
"UpgradeSeriesStartUnitCompletionParam",
")",
"(",
"params",
".",
"ErrorResults",
",",
"error",
")",
"{",
"result",
":=",
"params",
".",
"ErrorResults",
"{",
"Results",
":",
... | // StartUnitCompletion starts the upgrade series completion phase for all subordinate
// units of a given machine. | [
"StartUnitCompletion",
"starts",
"the",
"upgrade",
"series",
"completion",
"phase",
"for",
"all",
"subordinate",
"units",
"of",
"a",
"given",
"machine",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/upgradeseries/upgradeseries.go#L158-L179 |
155,194 | juju/juju | apiserver/facades/agent/upgradeseries/upgradeseries.go | FinishUpgradeSeries | func (a *API) FinishUpgradeSeries(args params.UpdateSeriesArgs) (params.ErrorResults, error) {
result := params.ErrorResults{
Results: make([]params.ErrorResult, len(args.Args)),
}
canAccess, err := a.AccessMachine()
if err != nil {
return params.ErrorResults{}, err
}
for i, arg := range args.Args {
machine, err := a.authAndMachine(arg.Entity, canAccess)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
// Actually running "do-release-upgrade" is not required to complete a
// series upgrade, so we compare the incoming host OS with the machine.
// Only update if they differ, because calling UpgradeSeriesTarget
// cascades through units and subordinates to verify series support,
// which we might as well skip unless an update is required.
ms := machine.Series()
if arg.Series == ms {
logger.Debugf("%q series is unchanged from %q", arg.Entity.Tag, ms)
} else {
if err := machine.UpdateMachineSeries(arg.Series, true); err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
}
err = machine.RemoveUpgradeSeriesLock()
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
}
return result, nil
} | go | func (a *API) FinishUpgradeSeries(args params.UpdateSeriesArgs) (params.ErrorResults, error) {
result := params.ErrorResults{
Results: make([]params.ErrorResult, len(args.Args)),
}
canAccess, err := a.AccessMachine()
if err != nil {
return params.ErrorResults{}, err
}
for i, arg := range args.Args {
machine, err := a.authAndMachine(arg.Entity, canAccess)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
// Actually running "do-release-upgrade" is not required to complete a
// series upgrade, so we compare the incoming host OS with the machine.
// Only update if they differ, because calling UpgradeSeriesTarget
// cascades through units and subordinates to verify series support,
// which we might as well skip unless an update is required.
ms := machine.Series()
if arg.Series == ms {
logger.Debugf("%q series is unchanged from %q", arg.Entity.Tag, ms)
} else {
if err := machine.UpdateMachineSeries(arg.Series, true); err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
}
err = machine.RemoveUpgradeSeriesLock()
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
}
return result, nil
} | [
"func",
"(",
"a",
"*",
"API",
")",
"FinishUpgradeSeries",
"(",
"args",
"params",
".",
"UpdateSeriesArgs",
")",
"(",
"params",
".",
"ErrorResults",
",",
"error",
")",
"{",
"result",
":=",
"params",
".",
"ErrorResults",
"{",
"Results",
":",
"make",
"(",
"[... | // FinishUpgradeSeries is the last action in the upgrade workflow and is
// called after all machine and unit statuses are "completed".
// It updates the machine series to reflect the completed upgrade, then
// removes the upgrade-series lock. | [
"FinishUpgradeSeries",
"is",
"the",
"last",
"action",
"in",
"the",
"upgrade",
"workflow",
"and",
"is",
"called",
"after",
"all",
"machine",
"and",
"unit",
"statuses",
"are",
"completed",
".",
"It",
"updates",
"the",
"machine",
"series",
"to",
"reflect",
"the",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/upgradeseries/upgradeseries.go#L185-L222 |
155,195 | juju/juju | apiserver/facades/agent/upgradeseries/upgradeseries.go | UnitsCompleted | func (a *API) UnitsCompleted(args params.Entities) (params.EntitiesResults, error) {
result, err := a.unitsInState(args, model.UpgradeSeriesCompleted)
return result, errors.Trace(err)
} | go | func (a *API) UnitsCompleted(args params.Entities) (params.EntitiesResults, error) {
result, err := a.unitsInState(args, model.UpgradeSeriesCompleted)
return result, errors.Trace(err)
} | [
"func",
"(",
"a",
"*",
"API",
")",
"UnitsCompleted",
"(",
"args",
"params",
".",
"Entities",
")",
"(",
"params",
".",
"EntitiesResults",
",",
"error",
")",
"{",
"result",
",",
"err",
":=",
"a",
".",
"unitsInState",
"(",
"args",
",",
"model",
".",
"Up... | // UnitsCompleted returns the units running on this machine that have completed
// the upgrade-series workflow and are in their normal running state. | [
"UnitsCompleted",
"returns",
"the",
"units",
"running",
"on",
"this",
"machine",
"that",
"have",
"completed",
"the",
"upgrade",
"-",
"series",
"workflow",
"and",
"are",
"in",
"their",
"normal",
"running",
"state",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/upgradeseries/upgradeseries.go#L234-L237 |
155,196 | juju/juju | provider/azure/instance.go | Status | func (inst *azureInstance) Status(ctx context.ProviderCallContext) instance.Status {
instanceStatus := status.Empty
message := inst.provisioningState
switch inst.provisioningState {
case "Succeeded":
// TODO(axw) once a VM has been started, we should
// start using its power state to show if it's
// really running or not. This is just a nice to
// have, since we should not expect a VM to ever
// be stopped.
instanceStatus = status.Running
message = ""
case "Canceled", "Failed":
// TODO(axw) if the provisioning state is "Failed", then we
// should use the error message from the deployment description
// as the Message. The error details are not currently exposed
// in the Azure SDK. See:
// https://github.com/Azure/azure-sdk-for-go/issues/399
instanceStatus = status.ProvisioningError
case "Running":
message = ""
fallthrough
default:
instanceStatus = status.Provisioning
}
return instance.Status{
Status: instanceStatus,
Message: message,
}
} | go | func (inst *azureInstance) Status(ctx context.ProviderCallContext) instance.Status {
instanceStatus := status.Empty
message := inst.provisioningState
switch inst.provisioningState {
case "Succeeded":
// TODO(axw) once a VM has been started, we should
// start using its power state to show if it's
// really running or not. This is just a nice to
// have, since we should not expect a VM to ever
// be stopped.
instanceStatus = status.Running
message = ""
case "Canceled", "Failed":
// TODO(axw) if the provisioning state is "Failed", then we
// should use the error message from the deployment description
// as the Message. The error details are not currently exposed
// in the Azure SDK. See:
// https://github.com/Azure/azure-sdk-for-go/issues/399
instanceStatus = status.ProvisioningError
case "Running":
message = ""
fallthrough
default:
instanceStatus = status.Provisioning
}
return instance.Status{
Status: instanceStatus,
Message: message,
}
} | [
"func",
"(",
"inst",
"*",
"azureInstance",
")",
"Status",
"(",
"ctx",
"context",
".",
"ProviderCallContext",
")",
"instance",
".",
"Status",
"{",
"instanceStatus",
":=",
"status",
".",
"Empty",
"\n",
"message",
":=",
"inst",
".",
"provisioningState",
"\n",
"... | // Status is specified in the Instance interface. | [
"Status",
"is",
"specified",
"in",
"the",
"Instance",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/instance.go#L43-L72 |
155,197 | juju/juju | provider/azure/instance.go | setInstanceAddresses | func setInstanceAddresses(
ctx context.ProviderCallContext,
resourceGroup string,
nicClient network.InterfacesClient,
pipClient network.PublicIPAddressesClient,
instances []*azureInstance,
) (err error) {
instanceNics, err := instanceNetworkInterfaces(ctx, resourceGroup, nicClient)
if err != nil {
return errors.Annotate(err, "listing network interfaces")
}
instancePips, err := instancePublicIPAddresses(ctx, resourceGroup, pipClient)
if err != nil {
return errors.Annotate(err, "listing public IP addresses")
}
for _, inst := range instances {
inst.networkInterfaces = instanceNics[inst.Id()]
inst.publicIPAddresses = instancePips[inst.Id()]
}
return nil
} | go | func setInstanceAddresses(
ctx context.ProviderCallContext,
resourceGroup string,
nicClient network.InterfacesClient,
pipClient network.PublicIPAddressesClient,
instances []*azureInstance,
) (err error) {
instanceNics, err := instanceNetworkInterfaces(ctx, resourceGroup, nicClient)
if err != nil {
return errors.Annotate(err, "listing network interfaces")
}
instancePips, err := instancePublicIPAddresses(ctx, resourceGroup, pipClient)
if err != nil {
return errors.Annotate(err, "listing public IP addresses")
}
for _, inst := range instances {
inst.networkInterfaces = instanceNics[inst.Id()]
inst.publicIPAddresses = instancePips[inst.Id()]
}
return nil
} | [
"func",
"setInstanceAddresses",
"(",
"ctx",
"context",
".",
"ProviderCallContext",
",",
"resourceGroup",
"string",
",",
"nicClient",
"network",
".",
"InterfacesClient",
",",
"pipClient",
"network",
".",
"PublicIPAddressesClient",
",",
"instances",
"[",
"]",
"*",
"az... | // setInstanceAddresses queries Azure for the NICs and public IPs associated
// with the given set of instances. This assumes that the instances'
// VirtualMachines are up-to-date, and that there are no concurrent accesses
// to the instances. | [
"setInstanceAddresses",
"queries",
"Azure",
"for",
"the",
"NICs",
"and",
"public",
"IPs",
"associated",
"with",
"the",
"given",
"set",
"of",
"instances",
".",
"This",
"assumes",
"that",
"the",
"instances",
"VirtualMachines",
"are",
"up",
"-",
"to",
"-",
"date"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/instance.go#L78-L98 |
155,198 | juju/juju | provider/azure/instance.go | instanceNetworkInterfaces | func instanceNetworkInterfaces(
ctx context.ProviderCallContext,
resourceGroup string,
nicClient network.InterfacesClient,
) (map[instance.Id][]network.Interface, error) {
sdkCtx := stdcontext.Background()
nicsResult, err := nicClient.ListComplete(sdkCtx, resourceGroup)
if err != nil {
return nil, errorutils.HandleCredentialError(errors.Annotate(err, "listing network interfaces"), ctx)
}
if nicsResult.Response().IsEmpty() {
return nil, nil
}
instanceNics := make(map[instance.Id][]network.Interface)
for ; nicsResult.NotDone(); err = nicsResult.NextWithContext(sdkCtx) {
nic := nicsResult.Value()
instanceId := instance.Id(to.String(nic.Tags[jujuMachineNameTag]))
instanceNics[instanceId] = append(instanceNics[instanceId], nic)
}
return instanceNics, nil
} | go | func instanceNetworkInterfaces(
ctx context.ProviderCallContext,
resourceGroup string,
nicClient network.InterfacesClient,
) (map[instance.Id][]network.Interface, error) {
sdkCtx := stdcontext.Background()
nicsResult, err := nicClient.ListComplete(sdkCtx, resourceGroup)
if err != nil {
return nil, errorutils.HandleCredentialError(errors.Annotate(err, "listing network interfaces"), ctx)
}
if nicsResult.Response().IsEmpty() {
return nil, nil
}
instanceNics := make(map[instance.Id][]network.Interface)
for ; nicsResult.NotDone(); err = nicsResult.NextWithContext(sdkCtx) {
nic := nicsResult.Value()
instanceId := instance.Id(to.String(nic.Tags[jujuMachineNameTag]))
instanceNics[instanceId] = append(instanceNics[instanceId], nic)
}
return instanceNics, nil
} | [
"func",
"instanceNetworkInterfaces",
"(",
"ctx",
"context",
".",
"ProviderCallContext",
",",
"resourceGroup",
"string",
",",
"nicClient",
"network",
".",
"InterfacesClient",
",",
")",
"(",
"map",
"[",
"instance",
".",
"Id",
"]",
"[",
"]",
"network",
".",
"Inte... | // instanceNetworkInterfaces lists all network interfaces in the resource
// group, and returns a mapping from instance ID to the network interfaces
// associated with that instance. | [
"instanceNetworkInterfaces",
"lists",
"all",
"network",
"interfaces",
"in",
"the",
"resource",
"group",
"and",
"returns",
"a",
"mapping",
"from",
"instance",
"ID",
"to",
"the",
"network",
"interfaces",
"associated",
"with",
"that",
"instance",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/instance.go#L103-L123 |
155,199 | juju/juju | provider/azure/instance.go | instancePublicIPAddresses | func instancePublicIPAddresses(
ctx context.ProviderCallContext,
resourceGroup string,
pipClient network.PublicIPAddressesClient,
) (map[instance.Id][]network.PublicIPAddress, error) {
sdkCtx := stdcontext.Background()
pipsResult, err := pipClient.ListComplete(sdkCtx, resourceGroup)
if err != nil {
return nil, errorutils.HandleCredentialError(errors.Annotate(err, "listing public IP addresses"), ctx)
}
if pipsResult.Response().IsEmpty() {
return nil, nil
}
instancePips := make(map[instance.Id][]network.PublicIPAddress)
for ; pipsResult.NotDone(); err = pipsResult.NextWithContext(sdkCtx) {
pip := pipsResult.Value()
instanceId := instance.Id(to.String(pip.Tags[jujuMachineNameTag]))
instancePips[instanceId] = append(instancePips[instanceId], pip)
}
return instancePips, nil
} | go | func instancePublicIPAddresses(
ctx context.ProviderCallContext,
resourceGroup string,
pipClient network.PublicIPAddressesClient,
) (map[instance.Id][]network.PublicIPAddress, error) {
sdkCtx := stdcontext.Background()
pipsResult, err := pipClient.ListComplete(sdkCtx, resourceGroup)
if err != nil {
return nil, errorutils.HandleCredentialError(errors.Annotate(err, "listing public IP addresses"), ctx)
}
if pipsResult.Response().IsEmpty() {
return nil, nil
}
instancePips := make(map[instance.Id][]network.PublicIPAddress)
for ; pipsResult.NotDone(); err = pipsResult.NextWithContext(sdkCtx) {
pip := pipsResult.Value()
instanceId := instance.Id(to.String(pip.Tags[jujuMachineNameTag]))
instancePips[instanceId] = append(instancePips[instanceId], pip)
}
return instancePips, nil
} | [
"func",
"instancePublicIPAddresses",
"(",
"ctx",
"context",
".",
"ProviderCallContext",
",",
"resourceGroup",
"string",
",",
"pipClient",
"network",
".",
"PublicIPAddressesClient",
",",
")",
"(",
"map",
"[",
"instance",
".",
"Id",
"]",
"[",
"]",
"network",
".",
... | // interfacePublicIPAddresses lists all public IP addresses in the resource
// group, and returns a mapping from instance ID to the public IP addresses
// associated with that instance. | [
"interfacePublicIPAddresses",
"lists",
"all",
"public",
"IP",
"addresses",
"in",
"the",
"resource",
"group",
"and",
"returns",
"a",
"mapping",
"from",
"instance",
"ID",
"to",
"the",
"public",
"IP",
"addresses",
"associated",
"with",
"that",
"instance",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/instance.go#L128-L148 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.