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,300
juju/juju
cloudconfig/cloudinit/interface.go
New
func New(ser string) (CloudConfig, error) { seriesos, err := series.GetOSFromSeries(ser) if err != nil { return nil, err } switch seriesos { case os.Windows: renderer, _ := shell.NewRenderer("powershell") return &windowsCloudConfig{ &cloudConfig{ series: ser, renderer: renderer, attrs: make(map[string]interface{}), }, }, nil case os.Ubuntu: renderer, _ := shell.NewRenderer("bash") return &ubuntuCloudConfig{ &cloudConfig{ series: ser, paccmder: commands.NewAptPackageCommander(), pacconfer: config.NewAptPackagingConfigurer(ser), renderer: renderer, attrs: make(map[string]interface{}), }, }, nil case os.CentOS: renderer, _ := shell.NewRenderer("bash") return &centOSCloudConfig{ cloudConfig: &cloudConfig{ series: ser, paccmder: commands.NewYumPackageCommander(), pacconfer: config.NewYumPackagingConfigurer(ser), renderer: renderer, attrs: make(map[string]interface{}), }, helper: centOSHelper{}, }, nil case os.OpenSUSE: renderer, _ := shell.NewRenderer("bash") return &centOSCloudConfig{ cloudConfig: &cloudConfig{ series: ser, paccmder: commands.NewZypperPackageCommander(), pacconfer: config.NewZypperPackagingConfigurer(ser), renderer: renderer, attrs: make(map[string]interface{}), }, helper: openSUSEHelper{ paccmder: commands.NewZypperPackageCommander(), }, }, nil default: return nil, errors.NotFoundf("cloudconfig for series %q", ser) } }
go
func New(ser string) (CloudConfig, error) { seriesos, err := series.GetOSFromSeries(ser) if err != nil { return nil, err } switch seriesos { case os.Windows: renderer, _ := shell.NewRenderer("powershell") return &windowsCloudConfig{ &cloudConfig{ series: ser, renderer: renderer, attrs: make(map[string]interface{}), }, }, nil case os.Ubuntu: renderer, _ := shell.NewRenderer("bash") return &ubuntuCloudConfig{ &cloudConfig{ series: ser, paccmder: commands.NewAptPackageCommander(), pacconfer: config.NewAptPackagingConfigurer(ser), renderer: renderer, attrs: make(map[string]interface{}), }, }, nil case os.CentOS: renderer, _ := shell.NewRenderer("bash") return &centOSCloudConfig{ cloudConfig: &cloudConfig{ series: ser, paccmder: commands.NewYumPackageCommander(), pacconfer: config.NewYumPackagingConfigurer(ser), renderer: renderer, attrs: make(map[string]interface{}), }, helper: centOSHelper{}, }, nil case os.OpenSUSE: renderer, _ := shell.NewRenderer("bash") return &centOSCloudConfig{ cloudConfig: &cloudConfig{ series: ser, paccmder: commands.NewZypperPackageCommander(), pacconfer: config.NewZypperPackagingConfigurer(ser), renderer: renderer, attrs: make(map[string]interface{}), }, helper: openSUSEHelper{ paccmder: commands.NewZypperPackageCommander(), }, }, nil default: return nil, errors.NotFoundf("cloudconfig for series %q", ser) } }
[ "func", "New", "(", "ser", "string", ")", "(", "CloudConfig", ",", "error", ")", "{", "seriesos", ",", "err", ":=", "series", ".", "GetOSFromSeries", "(", "ser", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n"...
// New returns a new Config with no options set.
[ "New", "returns", "a", "new", "Config", "with", "no", "options", "set", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/interface.go#L410-L465
155,301
juju/juju
core/application/config.go
NewConfig
func NewConfig(attrs map[string]interface{}, schema environschema.Fields, defaults schema.Defaults) (*Config, error) { cfg := &Config{schema: schema, defaults: defaults} if err := cfg.setAttributes(attrs); err != nil { return nil, errors.Trace(err) } return cfg, nil }
go
func NewConfig(attrs map[string]interface{}, schema environschema.Fields, defaults schema.Defaults) (*Config, error) { cfg := &Config{schema: schema, defaults: defaults} if err := cfg.setAttributes(attrs); err != nil { return nil, errors.Trace(err) } return cfg, nil }
[ "func", "NewConfig", "(", "attrs", "map", "[", "string", "]", "interface", "{", "}", ",", "schema", "environschema", ".", "Fields", ",", "defaults", "schema", ".", "Defaults", ")", "(", "*", "Config", ",", "error", ")", "{", "cfg", ":=", "&", "Config",...
// NewConfig returns a new config instance with the given attributes and // allowing for the extra provider attributes.
[ "NewConfig", "returns", "a", "new", "config", "instance", "with", "the", "given", "attributes", "and", "allowing", "for", "the", "extra", "provider", "attributes", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/application/config.go#L27-L33
155,302
juju/juju
core/application/config.go
KnownConfigKeys
func KnownConfigKeys(schema environschema.Fields) set.Strings { result := set.NewStrings() for name := range schema { result.Add(name) } return result }
go
func KnownConfigKeys(schema environschema.Fields) set.Strings { result := set.NewStrings() for name := range schema { result.Add(name) } return result }
[ "func", "KnownConfigKeys", "(", "schema", "environschema", ".", "Fields", ")", "set", ".", "Strings", "{", "result", ":=", "set", ".", "NewStrings", "(", ")", "\n", "for", "name", ":=", "range", "schema", "{", "result", ".", "Add", "(", "name", ")", "\...
// KnownConfigKeys returns the valid application config keys.
[ "KnownConfigKeys", "returns", "the", "valid", "application", "config", "keys", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/application/config.go#L53-L59
155,303
juju/juju
core/application/config.go
Attributes
func (c *Config) Attributes() ConfigAttributes { if c == nil { return nil } result := make(ConfigAttributes) for k, v := range c.attributes { result[k] = v } return result }
go
func (c *Config) Attributes() ConfigAttributes { if c == nil { return nil } result := make(ConfigAttributes) for k, v := range c.attributes { result[k] = v } return result }
[ "func", "(", "c", "*", "Config", ")", "Attributes", "(", ")", "ConfigAttributes", "{", "if", "c", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "result", ":=", "make", "(", "ConfigAttributes", ")", "\n", "for", "k", ",", "v", ":=", "range", "...
// Attributes returns all the config attributes.
[ "Attributes", "returns", "all", "the", "config", "attributes", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/application/config.go#L78-L87
155,304
juju/juju
core/application/config.go
Get
func (c ConfigAttributes) Get(attrName string, defaultValue interface{}) interface{} { if val, ok := c[attrName]; ok { return val } return defaultValue }
go
func (c ConfigAttributes) Get(attrName string, defaultValue interface{}) interface{} { if val, ok := c[attrName]; ok { return val } return defaultValue }
[ "func", "(", "c", "ConfigAttributes", ")", "Get", "(", "attrName", "string", ",", "defaultValue", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "val", ",", "ok", ":=", "c", "[", "attrName", "]", ";", "ok", "{", "return", "val", "\n", ...
// Get gets the specified attribute.
[ "Get", "gets", "the", "specified", "attribute", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/application/config.go#L90-L95
155,305
juju/juju
core/application/config.go
GetBool
func (c ConfigAttributes) GetBool(attrName string, defaultValue bool) bool { if val, ok := c[attrName]; ok { return val.(bool) } return defaultValue }
go
func (c ConfigAttributes) GetBool(attrName string, defaultValue bool) bool { if val, ok := c[attrName]; ok { return val.(bool) } return defaultValue }
[ "func", "(", "c", "ConfigAttributes", ")", "GetBool", "(", "attrName", "string", ",", "defaultValue", "bool", ")", "bool", "{", "if", "val", ",", "ok", ":=", "c", "[", "attrName", "]", ";", "ok", "{", "return", "val", ".", "(", "bool", ")", "\n", "...
// GetInt gets the specified bool attribute.
[ "GetInt", "gets", "the", "specified", "bool", "attribute", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/application/config.go#L98-L103
155,306
juju/juju
core/application/config.go
GetInt
func (c ConfigAttributes) GetInt(attrName string, defaultValue int) int { if val, ok := c[attrName]; ok { if value, ok := val.(float64); ok { return int(value) } return val.(int) } return defaultValue }
go
func (c ConfigAttributes) GetInt(attrName string, defaultValue int) int { if val, ok := c[attrName]; ok { if value, ok := val.(float64); ok { return int(value) } return val.(int) } return defaultValue }
[ "func", "(", "c", "ConfigAttributes", ")", "GetInt", "(", "attrName", "string", ",", "defaultValue", "int", ")", "int", "{", "if", "val", ",", "ok", ":=", "c", "[", "attrName", "]", ";", "ok", "{", "if", "value", ",", "ok", ":=", "val", ".", "(", ...
// GetInt gets the specified int attribute.
[ "GetInt", "gets", "the", "specified", "int", "attribute", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/application/config.go#L106-L114
155,307
juju/juju
core/application/config.go
GetString
func (c ConfigAttributes) GetString(attrName string, defaultValue string) string { if val, ok := c[attrName]; ok { return val.(string) } return defaultValue }
go
func (c ConfigAttributes) GetString(attrName string, defaultValue string) string { if val, ok := c[attrName]; ok { return val.(string) } return defaultValue }
[ "func", "(", "c", "ConfigAttributes", ")", "GetString", "(", "attrName", "string", ",", "defaultValue", "string", ")", "string", "{", "if", "val", ",", "ok", ":=", "c", "[", "attrName", "]", ";", "ok", "{", "return", "val", ".", "(", "string", ")", "...
// GetString gets the specified string attribute.
[ "GetString", "gets", "the", "specified", "string", "attribute", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/application/config.go#L117-L122
155,308
juju/juju
state/metricsmanager.go
MetricsManager
func (st *State) MetricsManager() (*MetricsManager, error) { mm, err := st.getMetricsManager() if errors.IsNotFound(err) { return st.newMetricsManager() } else if err != nil { return nil, errors.Trace(err) } return mm, nil }
go
func (st *State) MetricsManager() (*MetricsManager, error) { mm, err := st.getMetricsManager() if errors.IsNotFound(err) { return st.newMetricsManager() } else if err != nil { return nil, errors.Trace(err) } return mm, nil }
[ "func", "(", "st", "*", "State", ")", "MetricsManager", "(", ")", "(", "*", "MetricsManager", ",", "error", ")", "{", "mm", ",", "err", ":=", "st", ".", "getMetricsManager", "(", ")", "\n", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "...
// MetricsManager returns an existing metricsmanager, or a new one if non exists.
[ "MetricsManager", "returns", "an", "existing", "metricsmanager", "or", "a", "new", "one", "if", "non", "exists", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/metricsmanager.go#L54-L62
155,309
juju/juju
state/metricsmanager.go
SetLastSuccessfulSend
func (m *MetricsManager) SetLastSuccessfulSend(t time.Time) error { var status *bson.M if m.status.Code != meterString[MeterGreen] { status = &bson.M{ "$set": bson.M{ "code": meterString[MeterGreen], "info": "", }, } } err := m.updateMetricsManager( bson.M{ "$set": bson.M{ "lastsuccessfulsend": t.UTC(), "consecutiveerrors": 0, }, }, status, ) if err != nil { return errors.Trace(err) } m.doc.LastSuccessfulSend = t.UTC() m.doc.ConsecutiveErrors = 0 return nil }
go
func (m *MetricsManager) SetLastSuccessfulSend(t time.Time) error { var status *bson.M if m.status.Code != meterString[MeterGreen] { status = &bson.M{ "$set": bson.M{ "code": meterString[MeterGreen], "info": "", }, } } err := m.updateMetricsManager( bson.M{ "$set": bson.M{ "lastsuccessfulsend": t.UTC(), "consecutiveerrors": 0, }, }, status, ) if err != nil { return errors.Trace(err) } m.doc.LastSuccessfulSend = t.UTC() m.doc.ConsecutiveErrors = 0 return nil }
[ "func", "(", "m", "*", "MetricsManager", ")", "SetLastSuccessfulSend", "(", "t", "time", ".", "Time", ")", "error", "{", "var", "status", "*", "bson", ".", "M", "\n", "if", "m", ".", "status", ".", "Code", "!=", "meterString", "[", "MeterGreen", "]", ...
// SetLastSuccessfulSend sets the last successful send time to the input time.
[ "SetLastSuccessfulSend", "sets", "the", "last", "successful", "send", "time", "to", "the", "input", "time", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/metricsmanager.go#L163-L189
155,310
juju/juju
state/metricsmanager.go
IncrementConsecutiveErrors
func (m *MetricsManager) IncrementConsecutiveErrors() error { m1 := MetricsManager{ st: m.st, doc: m.doc, } m1.doc.ConsecutiveErrors++ newStatus := m1.MeterStatus() var statusUpdate *bson.M if newStatus != m.MeterStatus() { statusUpdate = &bson.M{ "$set": bson.M{ "code": meterString[newStatus.Code], "info": newStatus.Info, "model-uuid": m.st.ModelUUID(), }, } } err := m.updateMetricsManager( bson.M{"$inc": bson.M{"consecutiveerrors": 1}}, statusUpdate, ) if err != nil { return errors.Trace(err) } m.doc.ConsecutiveErrors++ return nil }
go
func (m *MetricsManager) IncrementConsecutiveErrors() error { m1 := MetricsManager{ st: m.st, doc: m.doc, } m1.doc.ConsecutiveErrors++ newStatus := m1.MeterStatus() var statusUpdate *bson.M if newStatus != m.MeterStatus() { statusUpdate = &bson.M{ "$set": bson.M{ "code": meterString[newStatus.Code], "info": newStatus.Info, "model-uuid": m.st.ModelUUID(), }, } } err := m.updateMetricsManager( bson.M{"$inc": bson.M{"consecutiveerrors": 1}}, statusUpdate, ) if err != nil { return errors.Trace(err) } m.doc.ConsecutiveErrors++ return nil }
[ "func", "(", "m", "*", "MetricsManager", ")", "IncrementConsecutiveErrors", "(", ")", "error", "{", "m1", ":=", "MetricsManager", "{", "st", ":", "m", ".", "st", ",", "doc", ":", "m", ".", "doc", ",", "}", "\n", "m1", ".", "doc", ".", "ConsecutiveErr...
// IncrementConsecutiveErrors adds 1 to the consecutive errors count.
[ "IncrementConsecutiveErrors", "adds", "1", "to", "the", "consecutive", "errors", "count", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/metricsmanager.go#L227-L254
155,311
juju/juju
state/metricsmanager.go
MeterStatus
func (m *MetricsManager) MeterStatus() MeterStatus { if m.ConsecutiveErrors() < metricsManagerConsecutiveErrorThreshold { return MeterStatus{Code: MeterGreen, Info: "ok"} } if m.gracePeriodExceeded() { return MeterStatus{Code: MeterRed, Info: "failed to send metrics, exceeded grace period"} } return MeterStatus{Code: MeterAmber, Info: "failed to send metrics"} }
go
func (m *MetricsManager) MeterStatus() MeterStatus { if m.ConsecutiveErrors() < metricsManagerConsecutiveErrorThreshold { return MeterStatus{Code: MeterGreen, Info: "ok"} } if m.gracePeriodExceeded() { return MeterStatus{Code: MeterRed, Info: "failed to send metrics, exceeded grace period"} } return MeterStatus{Code: MeterAmber, Info: "failed to send metrics"} }
[ "func", "(", "m", "*", "MetricsManager", ")", "MeterStatus", "(", ")", "MeterStatus", "{", "if", "m", ".", "ConsecutiveErrors", "(", ")", "<", "metricsManagerConsecutiveErrorThreshold", "{", "return", "MeterStatus", "{", "Code", ":", "MeterGreen", ",", "Info", ...
// MeterStatus returns the overall state of the MetricsManager as a meter status summary.
[ "MeterStatus", "returns", "the", "overall", "state", "of", "the", "MetricsManager", "as", "a", "meter", "status", "summary", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/metricsmanager.go#L263-L271
155,312
juju/juju
cmd/juju/cachedimages/cachedimages.go
NewImagesManagerClient
func (c *CachedImagesCommandBase) NewImagesManagerClient() (*imagemanager.Client, error) { root, err := c.NewAPIRoot() if err != nil { return nil, err } return imagemanager.NewClient(root), nil }
go
func (c *CachedImagesCommandBase) NewImagesManagerClient() (*imagemanager.Client, error) { root, err := c.NewAPIRoot() if err != nil { return nil, err } return imagemanager.NewClient(root), nil }
[ "func", "(", "c", "*", "CachedImagesCommandBase", ")", "NewImagesManagerClient", "(", ")", "(", "*", "imagemanager", ".", "Client", ",", "error", ")", "{", "root", ",", "err", ":=", "c", ".", "NewAPIRoot", "(", ")", "\n", "if", "err", "!=", "nil", "{",...
// NewImagesManagerClient returns a imagemanager client for the root api endpoint // that the environment command returns.
[ "NewImagesManagerClient", "returns", "a", "imagemanager", "client", "for", "the", "root", "api", "endpoint", "that", "the", "environment", "command", "returns", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/cachedimages/cachedimages.go#L20-L26
155,313
juju/juju
apiserver/facades/agent/diskmanager/diskmanager.go
NewDiskManagerAPI
func NewDiskManagerAPI( st *state.State, resources facade.Resources, authorizer facade.Authorizer, ) (*DiskManagerAPI, error) { if !authorizer.AuthMachineAgent() { return nil, common.ErrPerm } authEntityTag := authorizer.GetAuthTag() getAuthFunc := func() (common.AuthFunc, error) { return func(tag names.Tag) bool { // A machine agent can always access its own machine. return tag == authEntityTag }, nil } return &DiskManagerAPI{ st: getState(st), authorizer: authorizer, getAuthFunc: getAuthFunc, }, nil }
go
func NewDiskManagerAPI( st *state.State, resources facade.Resources, authorizer facade.Authorizer, ) (*DiskManagerAPI, error) { if !authorizer.AuthMachineAgent() { return nil, common.ErrPerm } authEntityTag := authorizer.GetAuthTag() getAuthFunc := func() (common.AuthFunc, error) { return func(tag names.Tag) bool { // A machine agent can always access its own machine. return tag == authEntityTag }, nil } return &DiskManagerAPI{ st: getState(st), authorizer: authorizer, getAuthFunc: getAuthFunc, }, nil }
[ "func", "NewDiskManagerAPI", "(", "st", "*", "state", ".", "State", ",", "resources", "facade", ".", "Resources", ",", "authorizer", "facade", ".", "Authorizer", ",", ")", "(", "*", "DiskManagerAPI", ",", "error", ")", "{", "if", "!", "authorizer", ".", ...
// NewDiskManagerAPI creates a new server-side DiskManager API facade.
[ "NewDiskManagerAPI", "creates", "a", "new", "server", "-", "side", "DiskManager", "API", "facade", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/diskmanager/diskmanager.go#L28-L51
155,314
juju/juju
provider/oracle/network/util.go
GetMacAndIP
func GetMacAndIP(address []string) (mac string, ip string, err error) { if address == nil { err = errors.New("Empty address slice given") return } for _, val := range address { valIp := net.ParseIP(val) if valIp != nil { ip = val continue } if _, err = net.ParseMAC(val); err != nil { err = errors.Errorf("The address is not an mac neither an ip %s", val) break } mac = val } return }
go
func GetMacAndIP(address []string) (mac string, ip string, err error) { if address == nil { err = errors.New("Empty address slice given") return } for _, val := range address { valIp := net.ParseIP(val) if valIp != nil { ip = val continue } if _, err = net.ParseMAC(val); err != nil { err = errors.Errorf("The address is not an mac neither an ip %s", val) break } mac = val } return }
[ "func", "GetMacAndIP", "(", "address", "[", "]", "string", ")", "(", "mac", "string", ",", "ip", "string", ",", "err", "error", ")", "{", "if", "address", "==", "nil", "{", "err", "=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "return", "...
// GetMacAndIp is a helper function that returns a mac and an IP, // given a list of strings containing both. This type of array // is returned by the oracle API as part of instance details.
[ "GetMacAndIp", "is", "a", "helper", "function", "that", "returns", "a", "mac", "and", "an", "IP", "given", "a", "list", "of", "strings", "containing", "both", ".", "This", "type", "of", "array", "is", "returned", "by", "the", "oracle", "API", "as", "part...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/util.go#L15-L33
155,315
juju/juju
payload/filter.go
Filter
func Filter(payloads []FullPayloadInfo, predicates ...PayloadPredicate) []FullPayloadInfo { var results []FullPayloadInfo for _, payload := range payloads { if matched := filterOne(payload, predicates); matched { results = append(results, payload) } } return results }
go
func Filter(payloads []FullPayloadInfo, predicates ...PayloadPredicate) []FullPayloadInfo { var results []FullPayloadInfo for _, payload := range payloads { if matched := filterOne(payload, predicates); matched { results = append(results, payload) } } return results }
[ "func", "Filter", "(", "payloads", "[", "]", "FullPayloadInfo", ",", "predicates", "...", "PayloadPredicate", ")", "[", "]", "FullPayloadInfo", "{", "var", "results", "[", "]", "FullPayloadInfo", "\n", "for", "_", ",", "payload", ":=", "range", "payloads", "...
// Filter applies the provided predicates to the payloads and returns // only those that matched.
[ "Filter", "applies", "the", "provided", "predicates", "to", "the", "payloads", "and", "returns", "only", "those", "that", "matched", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/payload/filter.go#L18-L26
155,316
juju/juju
payload/filter.go
Match
func Match(payload FullPayloadInfo, pattern string) bool { pattern = strings.ToLower(pattern) switch { case strings.ToLower(payload.Name) == pattern: return true case strings.ToLower(payload.Type) == pattern: return true case strings.ToLower(payload.ID) == pattern: return true case strings.ToLower(payload.Status) == pattern: return true case strings.ToLower(payload.Unit) == pattern: return true case strings.ToLower(payload.Machine) == pattern: return true default: for _, tag := range payload.Labels { if strings.ToLower(tag) == pattern { return true } } } return false }
go
func Match(payload FullPayloadInfo, pattern string) bool { pattern = strings.ToLower(pattern) switch { case strings.ToLower(payload.Name) == pattern: return true case strings.ToLower(payload.Type) == pattern: return true case strings.ToLower(payload.ID) == pattern: return true case strings.ToLower(payload.Status) == pattern: return true case strings.ToLower(payload.Unit) == pattern: return true case strings.ToLower(payload.Machine) == pattern: return true default: for _, tag := range payload.Labels { if strings.ToLower(tag) == pattern { return true } } } return false }
[ "func", "Match", "(", "payload", "FullPayloadInfo", ",", "pattern", "string", ")", "bool", "{", "pattern", "=", "strings", ".", "ToLower", "(", "pattern", ")", "\n\n", "switch", "{", "case", "strings", ".", "ToLower", "(", "payload", ".", "Name", ")", "=...
// Match determines if the given payload matches the pattern.
[ "Match", "determines", "if", "the", "given", "payload", "matches", "the", "pattern", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/payload/filter.go#L59-L83
155,317
juju/juju
pubsub/centralhub/centralhub.go
New
func New(origin names.MachineTag) *pubsub.StructuredHub { return pubsub.NewStructuredHub( &pubsub.StructuredHubConfig{ Logger: loggo.GetLogger("juju.centralhub"), Marshaller: &yamlMarshaller{}, Annotations: map[string]interface{}{ "origin": origin.String(), }, PostProcess: ensureStringMaps, }) }
go
func New(origin names.MachineTag) *pubsub.StructuredHub { return pubsub.NewStructuredHub( &pubsub.StructuredHubConfig{ Logger: loggo.GetLogger("juju.centralhub"), Marshaller: &yamlMarshaller{}, Annotations: map[string]interface{}{ "origin": origin.String(), }, PostProcess: ensureStringMaps, }) }
[ "func", "New", "(", "origin", "names", ".", "MachineTag", ")", "*", "pubsub", ".", "StructuredHub", "{", "return", "pubsub", ".", "NewStructuredHub", "(", "&", "pubsub", ".", "StructuredHubConfig", "{", "Logger", ":", "loggo", ".", "GetLogger", "(", "\"", ...
// New returns a new structured hub using yaml marshalling with an origin // specified. The post processing ensures that the maps all have string keys // so they messages can be marshalled between apiservers.
[ "New", "returns", "a", "new", "structured", "hub", "using", "yaml", "marshalling", "with", "an", "origin", "specified", ".", "The", "post", "processing", "ensures", "that", "the", "maps", "all", "have", "string", "keys", "so", "they", "messages", "can", "be"...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/pubsub/centralhub/centralhub.go#L18-L29
155,318
juju/juju
pubsub/centralhub/centralhub.go
Unmarshal
func (*yamlMarshaller) Unmarshal(data []byte, v interface{}) error { return yaml.Unmarshal(data, v) }
go
func (*yamlMarshaller) Unmarshal(data []byte, v interface{}) error { return yaml.Unmarshal(data, v) }
[ "func", "(", "*", "yamlMarshaller", ")", "Unmarshal", "(", "data", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "error", "{", "return", "yaml", ".", "Unmarshal", "(", "data", ",", "v", ")", "\n", "}" ]
// Unmarshal implements Marshaller.
[ "Unmarshal", "implements", "Marshaller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/pubsub/centralhub/centralhub.go#L39-L41
155,319
juju/juju
caas/config.go
ConfigSchema
func ConfigSchema(providerFields environschema.Fields) (environschema.Fields, error) { fields, err := configSchema(providerFields) if err != nil { return nil, errors.Trace(err) } return fields, nil }
go
func ConfigSchema(providerFields environschema.Fields) (environschema.Fields, error) { fields, err := configSchema(providerFields) if err != nil { return nil, errors.Trace(err) } return fields, nil }
[ "func", "ConfigSchema", "(", "providerFields", "environschema", ".", "Fields", ")", "(", "environschema", ".", "Fields", ",", "error", ")", "{", "fields", ",", "err", ":=", "configSchema", "(", "providerFields", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// ConfigSchema returns the valid fields for a CAAS application config.
[ "ConfigSchema", "returns", "the", "valid", "fields", "for", "a", "CAAS", "application", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/config.go#L37-L43
155,320
juju/juju
caas/config.go
ConfigDefaults
func ConfigDefaults(providerDefaults schema.Defaults) schema.Defaults { defaults := schema.Defaults{ JujuApplicationPath: JujuDefaultApplicationPath, } for key, value := range providerDefaults { if value == schema.Omit { continue } defaults[key] = value } return defaults }
go
func ConfigDefaults(providerDefaults schema.Defaults) schema.Defaults { defaults := schema.Defaults{ JujuApplicationPath: JujuDefaultApplicationPath, } for key, value := range providerDefaults { if value == schema.Omit { continue } defaults[key] = value } return defaults }
[ "func", "ConfigDefaults", "(", "providerDefaults", "schema", ".", "Defaults", ")", "schema", ".", "Defaults", "{", "defaults", ":=", "schema", ".", "Defaults", "{", "JujuApplicationPath", ":", "JujuDefaultApplicationPath", ",", "}", "\n", "for", "key", ",", "val...
// ConfigDefaults returns the default values for a CAAS application config.
[ "ConfigDefaults", "returns", "the", "default", "values", "for", "a", "CAAS", "application", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/config.go#L60-L71
155,321
juju/juju
cmd/juju/common/cloudcredential.go
GetOrDetectCredential
func GetOrDetectCredential( ctx *cmd.Context, store jujuclient.CredentialGetter, provider environs.EnvironProvider, args modelcmd.GetCredentialsParams, ) (_ *jujucloud.Credential, chosenCredentialName, regionName string, isDetected bool, _ error) { fail := func(err error) (*jujucloud.Credential, string, string, bool, error) { return nil, "", "", false, err } credential, chosenCredentialName, regionName, err := modelcmd.GetCredentials(ctx, store, args) if !errors.IsNotFound(err) || args.CredentialName != "" { return credential, chosenCredentialName, regionName, false, err } // No credential was explicitly specified, and no credential was found // in the credential store; have the provider detect credentials from // the environment. ctx.Verbosef("no credentials found, checking environment") detected, err := modelcmd.DetectCredential(args.Cloud.Name, provider) if errors.Cause(err) == modelcmd.ErrMultipleCredentials { return fail(ErrMultipleDetectedCredentials) } else if err != nil { return fail(errors.Trace(err)) } // We have one credential so extract it from the map. var oneCredential jujucloud.Credential for chosenCredentialName, oneCredential = range detected.AuthCredentials { } regionName = args.CloudRegion if regionName == "" { regionName = detected.DefaultRegion } // Finalize the credential against the cloud/region. region, err := ChooseCloudRegion(args.Cloud, regionName) if err != nil { return fail(err) } credential, err = modelcmd.FinalizeFileContent(&oneCredential, provider) if err != nil { return nil, "", "", false, modelcmd.AnnotateWithFinalizationError(err, chosenCredentialName, args.Cloud.Name) } credential, err = provider.FinalizeCredential( ctx, environs.FinalizeCredentialParams{ Credential: *credential, CloudEndpoint: region.Endpoint, CloudStorageEndpoint: region.StorageEndpoint, CloudIdentityEndpoint: region.IdentityEndpoint, }, ) if err != nil { return fail(errors.Trace(err)) } return credential, chosenCredentialName, regionName, true, nil }
go
func GetOrDetectCredential( ctx *cmd.Context, store jujuclient.CredentialGetter, provider environs.EnvironProvider, args modelcmd.GetCredentialsParams, ) (_ *jujucloud.Credential, chosenCredentialName, regionName string, isDetected bool, _ error) { fail := func(err error) (*jujucloud.Credential, string, string, bool, error) { return nil, "", "", false, err } credential, chosenCredentialName, regionName, err := modelcmd.GetCredentials(ctx, store, args) if !errors.IsNotFound(err) || args.CredentialName != "" { return credential, chosenCredentialName, regionName, false, err } // No credential was explicitly specified, and no credential was found // in the credential store; have the provider detect credentials from // the environment. ctx.Verbosef("no credentials found, checking environment") detected, err := modelcmd.DetectCredential(args.Cloud.Name, provider) if errors.Cause(err) == modelcmd.ErrMultipleCredentials { return fail(ErrMultipleDetectedCredentials) } else if err != nil { return fail(errors.Trace(err)) } // We have one credential so extract it from the map. var oneCredential jujucloud.Credential for chosenCredentialName, oneCredential = range detected.AuthCredentials { } regionName = args.CloudRegion if regionName == "" { regionName = detected.DefaultRegion } // Finalize the credential against the cloud/region. region, err := ChooseCloudRegion(args.Cloud, regionName) if err != nil { return fail(err) } credential, err = modelcmd.FinalizeFileContent(&oneCredential, provider) if err != nil { return nil, "", "", false, modelcmd.AnnotateWithFinalizationError(err, chosenCredentialName, args.Cloud.Name) } credential, err = provider.FinalizeCredential( ctx, environs.FinalizeCredentialParams{ Credential: *credential, CloudEndpoint: region.Endpoint, CloudStorageEndpoint: region.StorageEndpoint, CloudIdentityEndpoint: region.IdentityEndpoint, }, ) if err != nil { return fail(errors.Trace(err)) } return credential, chosenCredentialName, regionName, true, nil }
[ "func", "GetOrDetectCredential", "(", "ctx", "*", "cmd", ".", "Context", ",", "store", "jujuclient", ".", "CredentialGetter", ",", "provider", "environs", ".", "EnvironProvider", ",", "args", "modelcmd", ".", "GetCredentialsParams", ",", ")", "(", "_", "*", "j...
// GetOrDetectCredential returns a credential to use for given cloud. This // function first calls modelcmd.GetCredentials, and returns its results if it // finds credentials. If modelcmd.GetCredentials cannot find a credential, and a // credential has not been specified by name, then this function will attempt to // detect credentials from the environment. // // If multiple credentials are found in the client store, then // modelcmd.ErrMultipleCredentials is returned. If multiple credentials are // detected by the provider, then ErrMultipleDetectedCredentials is returned.
[ "GetOrDetectCredential", "returns", "a", "credential", "to", "use", "for", "given", "cloud", ".", "This", "function", "first", "calls", "modelcmd", ".", "GetCredentials", "and", "returns", "its", "results", "if", "it", "finds", "credentials", ".", "If", "modelcm...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/common/cloudcredential.go#L66-L124
155,322
juju/juju
cmd/juju/common/cloudcredential.go
OutputUpdateCredentialModelResult
func OutputUpdateCredentialModelResult(ctx *cmd.Context, models []params.UpdateCredentialModelResult, showValid bool) { var valid []string invalid := map[string][]error{} for _, m := range models { if len(m.Errors) == 0 { valid = append(valid, m.ModelName) continue } else { var mError []error for _, anErr := range m.Errors { mError = append(mError, errors.Trace(anErr.Error)) } invalid[m.ModelName] = mError } } if showValid && len(valid) > 0 { ctx.Infof("Credential valid for:") for _, v := range valid { ctx.Infof(" %v", v) } } if len(invalid) > 0 { // ensure we sort the valid, invalid slices so that the output is consistent i := 0 names := make([]string, len(invalid)) for k := range invalid { names[i] = k i++ } sort.Strings(names) ctx.Infof("Credential invalid for:") for _, v := range names { ctx.Infof(" %v:", v) for _, e := range invalid[v] { ctx.Infof(" %v", e) } } } }
go
func OutputUpdateCredentialModelResult(ctx *cmd.Context, models []params.UpdateCredentialModelResult, showValid bool) { var valid []string invalid := map[string][]error{} for _, m := range models { if len(m.Errors) == 0 { valid = append(valid, m.ModelName) continue } else { var mError []error for _, anErr := range m.Errors { mError = append(mError, errors.Trace(anErr.Error)) } invalid[m.ModelName] = mError } } if showValid && len(valid) > 0 { ctx.Infof("Credential valid for:") for _, v := range valid { ctx.Infof(" %v", v) } } if len(invalid) > 0 { // ensure we sort the valid, invalid slices so that the output is consistent i := 0 names := make([]string, len(invalid)) for k := range invalid { names[i] = k i++ } sort.Strings(names) ctx.Infof("Credential invalid for:") for _, v := range names { ctx.Infof(" %v:", v) for _, e := range invalid[v] { ctx.Infof(" %v", e) } } } }
[ "func", "OutputUpdateCredentialModelResult", "(", "ctx", "*", "cmd", ".", "Context", ",", "models", "[", "]", "params", ".", "UpdateCredentialModelResult", ",", "showValid", "bool", ")", "{", "var", "valid", "[", "]", "string", "\n", "invalid", ":=", "map", ...
// OutputUpdateCredentialModelResult prints detailed results of UpdateCredentialsCheckModels.
[ "OutputUpdateCredentialModelResult", "prints", "detailed", "results", "of", "UpdateCredentialsCheckModels", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/common/cloudcredential.go#L141-L181
155,323
juju/juju
cmd/juju/action/list.go
Init
func (c *listCommand) Init(args []string) error { if c.out.Name() == "tabular" && c.fullSchema { return errors.New("full schema not compatible with tabular output") } switch len(args) { case 0: return errors.New("no application name specified") case 1: svcName := args[0] if !names.IsValidApplication(svcName) { return errors.Errorf("invalid application name %q", svcName) } c.applicationTag = names.NewApplicationTag(svcName) return nil default: return cmd.CheckEmpty(args[1:]) } }
go
func (c *listCommand) Init(args []string) error { if c.out.Name() == "tabular" && c.fullSchema { return errors.New("full schema not compatible with tabular output") } switch len(args) { case 0: return errors.New("no application name specified") case 1: svcName := args[0] if !names.IsValidApplication(svcName) { return errors.Errorf("invalid application name %q", svcName) } c.applicationTag = names.NewApplicationTag(svcName) return nil default: return cmd.CheckEmpty(args[1:]) } }
[ "func", "(", "c", "*", "listCommand", ")", "Init", "(", "args", "[", "]", "string", ")", "error", "{", "if", "c", ".", "out", ".", "Name", "(", ")", "==", "\"", "\"", "&&", "c", ".", "fullSchema", "{", "return", "errors", ".", "New", "(", "\"",...
// Init validates the application name and any other options.
[ "Init", "validates", "the", "application", "name", "and", "any", "other", "options", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/action/list.go#L76-L93
155,324
juju/juju
cmd/juju/action/list.go
Run
func (c *listCommand) Run(ctx *cmd.Context) error { api, err := c.NewActionAPIClient() if err != nil { return err } defer api.Close() actions, err := api.ApplicationCharmActions(params.Entity{Tag: c.applicationTag.String()}) if err != nil { return err } if c.fullSchema { verboseSpecs := make(map[string]interface{}) for k, v := range actions { verboseSpecs[k] = v.Params } if c.out.Name() == "default" { return c.out.WriteFormatter(ctx, cmd.FormatYaml, verboseSpecs) } else { return c.out.Write(ctx, verboseSpecs) } } shortOutput := make(map[string]string) var sortedNames []string for name, action := range actions { shortOutput[name] = action.Description if shortOutput[name] == "" { shortOutput[name] = "No description" } sortedNames = append(sortedNames, name) } naturalsort.Sort(sortedNames) var output interface{} switch c.out.Name() { case "yaml", "json": output = shortOutput default: if len(sortedNames) == 0 { ctx.Infof("No actions defined for %s.", c.applicationTag.Id()) return nil } var list []listOutput for _, name := range sortedNames { list = append(list, listOutput{name, shortOutput[name]}) } output = list } if c.out.Name() == "default" { return c.out.WriteFormatter(ctx, c.printTabular, output) } else { return c.out.Write(ctx, output) } }
go
func (c *listCommand) Run(ctx *cmd.Context) error { api, err := c.NewActionAPIClient() if err != nil { return err } defer api.Close() actions, err := api.ApplicationCharmActions(params.Entity{Tag: c.applicationTag.String()}) if err != nil { return err } if c.fullSchema { verboseSpecs := make(map[string]interface{}) for k, v := range actions { verboseSpecs[k] = v.Params } if c.out.Name() == "default" { return c.out.WriteFormatter(ctx, cmd.FormatYaml, verboseSpecs) } else { return c.out.Write(ctx, verboseSpecs) } } shortOutput := make(map[string]string) var sortedNames []string for name, action := range actions { shortOutput[name] = action.Description if shortOutput[name] == "" { shortOutput[name] = "No description" } sortedNames = append(sortedNames, name) } naturalsort.Sort(sortedNames) var output interface{} switch c.out.Name() { case "yaml", "json": output = shortOutput default: if len(sortedNames) == 0 { ctx.Infof("No actions defined for %s.", c.applicationTag.Id()) return nil } var list []listOutput for _, name := range sortedNames { list = append(list, listOutput{name, shortOutput[name]}) } output = list } if c.out.Name() == "default" { return c.out.WriteFormatter(ctx, c.printTabular, output) } else { return c.out.Write(ctx, output) } }
[ "func", "(", "c", "*", "listCommand", ")", "Run", "(", "ctx", "*", "cmd", ".", "Context", ")", "error", "{", "api", ",", "err", ":=", "c", ".", "NewActionAPIClient", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n",...
// Run grabs the Actions spec from the api. It then sets up a sensible // output format for the map.
[ "Run", "grabs", "the", "Actions", "spec", "from", "the", "api", ".", "It", "then", "sets", "up", "a", "sensible", "output", "format", "for", "the", "map", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/action/list.go#L97-L155
155,325
juju/juju
cmd/juju/action/list.go
printTabular
func (c *listCommand) printTabular(writer io.Writer, value interface{}) error { list, ok := value.([]listOutput) if !ok { return errors.New("unexpected value") } tw := output.TabWriter(writer) fmt.Fprintf(tw, "%s\t%s\n", "Action", "Description") for _, value := range list { fmt.Fprintf(tw, "%s\t%s\n", value.action, strings.TrimSpace(value.description)) } tw.Flush() return nil }
go
func (c *listCommand) printTabular(writer io.Writer, value interface{}) error { list, ok := value.([]listOutput) if !ok { return errors.New("unexpected value") } tw := output.TabWriter(writer) fmt.Fprintf(tw, "%s\t%s\n", "Action", "Description") for _, value := range list { fmt.Fprintf(tw, "%s\t%s\n", value.action, strings.TrimSpace(value.description)) } tw.Flush() return nil }
[ "func", "(", "c", "*", "listCommand", ")", "printTabular", "(", "writer", "io", ".", "Writer", ",", "value", "interface", "{", "}", ")", "error", "{", "list", ",", "ok", ":=", "value", ".", "(", "[", "]", "listOutput", ")", "\n", "if", "!", "ok", ...
// printTabular prints the list of actions in tabular format
[ "printTabular", "prints", "the", "list", "of", "actions", "in", "tabular", "format" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/action/list.go#L163-L176
155,326
juju/juju
charmstore/client.go
NewCachingClient
func NewCachingClient(cache MacaroonCache, server string) (Client, error) { return newCachingClient(cache, server, makeWrapper) }
go
func NewCachingClient(cache MacaroonCache, server string) (Client, error) { return newCachingClient(cache, server, makeWrapper) }
[ "func", "NewCachingClient", "(", "cache", "MacaroonCache", ",", "server", "string", ")", "(", "Client", ",", "error", ")", "{", "return", "newCachingClient", "(", "cache", ",", "server", ",", "makeWrapper", ")", "\n", "}" ]
// NewCachingClient returns a Juju charm store client that stores and retrieves // macaroons for calls in the given cache. The client will use server as the // charmstore url.
[ "NewCachingClient", "returns", "a", "Juju", "charm", "store", "client", "that", "stores", "and", "retrieves", "macaroons", "for", "calls", "in", "the", "given", "cache", ".", "The", "client", "will", "use", "server", "as", "the", "charmstore", "url", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/client.go#L41-L43
155,327
juju/juju
charmstore/client.go
makeMetadataHeader
func makeMetadataHeader(modelMetadata, charmMetadata map[string]string) map[string][]string { if len(modelMetadata) == 0 && len(charmMetadata) == 0 { return nil } headers := make([]string, 0, len(modelMetadata)+len(charmMetadata)) // We expect the deployed architecture for a charm to be singular, // but it is possible for deployment across multiple architectures. // We need to handle this, which violates the general case following. if arch, ok := charmMetadata["arch"]; ok { for _, a := range strings.Split(arch, ",") { headers = append(headers, fmt.Sprintf("arch=%s", a)) } delete(charmMetadata, "arch") } addHeaders := func(metadata map[string]string) { for k, v := range metadata { headers = append(headers, fmt.Sprintf("%s=%s", k, v)) } } addHeaders(modelMetadata) addHeaders(charmMetadata) sort.Strings(headers) return map[string][]string{jujuMetadataHTTPHeader: headers} }
go
func makeMetadataHeader(modelMetadata, charmMetadata map[string]string) map[string][]string { if len(modelMetadata) == 0 && len(charmMetadata) == 0 { return nil } headers := make([]string, 0, len(modelMetadata)+len(charmMetadata)) // We expect the deployed architecture for a charm to be singular, // but it is possible for deployment across multiple architectures. // We need to handle this, which violates the general case following. if arch, ok := charmMetadata["arch"]; ok { for _, a := range strings.Split(arch, ",") { headers = append(headers, fmt.Sprintf("arch=%s", a)) } delete(charmMetadata, "arch") } addHeaders := func(metadata map[string]string) { for k, v := range metadata { headers = append(headers, fmt.Sprintf("%s=%s", k, v)) } } addHeaders(modelMetadata) addHeaders(charmMetadata) sort.Strings(headers) return map[string][]string{jujuMetadataHTTPHeader: headers} }
[ "func", "makeMetadataHeader", "(", "modelMetadata", ",", "charmMetadata", "map", "[", "string", "]", "string", ")", "map", "[", "string", "]", "[", "]", "string", "{", "if", "len", "(", "modelMetadata", ")", "==", "0", "&&", "len", "(", "charmMetadata", ...
// makeMetadataHeader takes the input model and charm metadata and transforms // it into a header suitable for supply with a "Latest" request via the client.
[ "makeMetadataHeader", "takes", "the", "input", "model", "and", "charm", "metadata", "and", "transforms", "it", "into", "a", "header", "suitable", "for", "supply", "with", "a", "Latest", "request", "via", "the", "client", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/client.go#L142-L168
155,328
juju/juju
charmstore/client.go
ResourceInfo
func (c Client) ResourceInfo(req ResourceRequest) (resource.Resource, error) { if err := c.jar.Activate(req.Charm); err != nil { return resource.Resource{}, errors.Trace(err) } defer c.jar.Deactivate() meta, err := c.csWrapper.ResourceMeta(req.Channel, req.Charm, req.Name, req.Revision) if err != nil { return resource.Resource{}, errors.Trace(err) } res, err := csparams.API2Resource(meta) if err != nil { return resource.Resource{}, errors.Trace(err) } return res, nil }
go
func (c Client) ResourceInfo(req ResourceRequest) (resource.Resource, error) { if err := c.jar.Activate(req.Charm); err != nil { return resource.Resource{}, errors.Trace(err) } defer c.jar.Deactivate() meta, err := c.csWrapper.ResourceMeta(req.Channel, req.Charm, req.Name, req.Revision) if err != nil { return resource.Resource{}, errors.Trace(err) } res, err := csparams.API2Resource(meta) if err != nil { return resource.Resource{}, errors.Trace(err) } return res, nil }
[ "func", "(", "c", "Client", ")", "ResourceInfo", "(", "req", "ResourceRequest", ")", "(", "resource", ".", "Resource", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "jar", ".", "Activate", "(", "req", ".", "Charm", ")", ";", "err", "!=", "ni...
// ResourceInfo returns the metadata for the given resource from the charmstore.
[ "ResourceInfo", "returns", "the", "metadata", "for", "the", "given", "resource", "from", "the", "charmstore", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/client.go#L231-L245
155,329
juju/juju
charmstore/client.go
ListResources
func (c Client) ListResources(charms []CharmID) ([][]resource.Resource, error) { results := make([][]resource.Resource, len(charms)) for i, ch := range charms { res, err := c.listResources(ch) if err != nil { if csclient.IsAuthorizationError(err) || errors.Cause(err) == csparams.ErrNotFound { // Ignore authorization errors and not-found errors so we get some results // even if others fail. continue } return nil, errors.Trace(err) } results[i] = res } return results, nil }
go
func (c Client) ListResources(charms []CharmID) ([][]resource.Resource, error) { results := make([][]resource.Resource, len(charms)) for i, ch := range charms { res, err := c.listResources(ch) if err != nil { if csclient.IsAuthorizationError(err) || errors.Cause(err) == csparams.ErrNotFound { // Ignore authorization errors and not-found errors so we get some results // even if others fail. continue } return nil, errors.Trace(err) } results[i] = res } return results, nil }
[ "func", "(", "c", "Client", ")", "ListResources", "(", "charms", "[", "]", "CharmID", ")", "(", "[", "]", "[", "]", "resource", ".", "Resource", ",", "error", ")", "{", "results", ":=", "make", "(", "[", "]", "[", "]", "resource", ".", "Resource", ...
// ListResources returns a list of resources for each of the given charms.
[ "ListResources", "returns", "a", "list", "of", "resources", "for", "each", "of", "the", "given", "charms", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/client.go#L248-L263
155,330
juju/juju
charmstore/client.go
ListResources
func (c csclientImpl) ListResources(channel csparams.Channel, id *charm.URL) ([]csparams.Resource, error) { client := c.WithChannel(channel) return client.ListResources(id) }
go
func (c csclientImpl) ListResources(channel csparams.Channel, id *charm.URL) ([]csparams.Resource, error) { client := c.WithChannel(channel) return client.ListResources(id) }
[ "func", "(", "c", "csclientImpl", ")", "ListResources", "(", "channel", "csparams", ".", "Channel", ",", "id", "*", "charm", ".", "URL", ")", "(", "[", "]", "csparams", ".", "Resource", ",", "error", ")", "{", "client", ":=", "c", ".", "WithChannel", ...
// ListResources gets the latest resources for the charm URL on the channel.
[ "ListResources", "gets", "the", "latest", "resources", "for", "the", "charm", "URL", "on", "the", "channel", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/client.go#L302-L305
155,331
juju/juju
charmstore/client.go
GetResource
func (c csclientImpl) GetResource(channel csparams.Channel, id *charm.URL, name string, revision int) (csclient.ResourceData, error) { client := c.WithChannel(channel) return client.GetResource(id, name, revision) }
go
func (c csclientImpl) GetResource(channel csparams.Channel, id *charm.URL, name string, revision int) (csclient.ResourceData, error) { client := c.WithChannel(channel) return client.GetResource(id, name, revision) }
[ "func", "(", "c", "csclientImpl", ")", "GetResource", "(", "channel", "csparams", ".", "Channel", ",", "id", "*", "charm", ".", "URL", ",", "name", "string", ",", "revision", "int", ")", "(", "csclient", ".", "ResourceData", ",", "error", ")", "{", "cl...
// GetResource downloads the bytes and some metadata about the bytes for the revisioned resource.
[ "GetResource", "downloads", "the", "bytes", "and", "some", "metadata", "about", "the", "bytes", "for", "the", "revisioned", "resource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/client.go#L308-L311
155,332
juju/juju
charmstore/client.go
ResourceMeta
func (c csclientImpl) ResourceMeta(channel csparams.Channel, id *charm.URL, name string, revision int) (csparams.Resource, error) { client := c.WithChannel(channel) return client.ResourceMeta(id, name, revision) }
go
func (c csclientImpl) ResourceMeta(channel csparams.Channel, id *charm.URL, name string, revision int) (csparams.Resource, error) { client := c.WithChannel(channel) return client.ResourceMeta(id, name, revision) }
[ "func", "(", "c", "csclientImpl", ")", "ResourceMeta", "(", "channel", "csparams", ".", "Channel", ",", "id", "*", "charm", ".", "URL", ",", "name", "string", ",", "revision", "int", ")", "(", "csparams", ".", "Resource", ",", "error", ")", "{", "clien...
// ResourceInfo gets the full metadata for the revisioned resource.
[ "ResourceInfo", "gets", "the", "full", "metadata", "for", "the", "revisioned", "resource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/client.go#L314-L317
155,333
juju/juju
cmd/juju/application/removeapplication.go
NewRemoveApplicationCommand
func NewRemoveApplicationCommand() cmd.Command { c := &removeApplicationCommand{} c.newAPIFunc = func() (RemoveApplicationAPI, int, error) { return c.getAPI() } return modelcmd.Wrap(c) }
go
func NewRemoveApplicationCommand() cmd.Command { c := &removeApplicationCommand{} c.newAPIFunc = func() (RemoveApplicationAPI, int, error) { return c.getAPI() } return modelcmd.Wrap(c) }
[ "func", "NewRemoveApplicationCommand", "(", ")", "cmd", ".", "Command", "{", "c", ":=", "&", "removeApplicationCommand", "{", "}", "\n", "c", ".", "newAPIFunc", "=", "func", "(", ")", "(", "RemoveApplicationAPI", ",", "int", ",", "error", ")", "{", "return...
// NewRemoveApplicationCommand returns a command which removes an application.
[ "NewRemoveApplicationCommand", "returns", "a", "command", "which", "removes", "an", "application", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/removeapplication.go#L24-L30
155,334
juju/juju
apiserver/common/machine.go
StateJobs
func StateJobs(jobs []multiwatcher.MachineJob) ([]state.MachineJob, error) { newJobs := make([]state.MachineJob, len(jobs)) for i, job := range jobs { newJob, err := machineJobFromParams(job) if err != nil { return nil, err } newJobs[i] = newJob } return newJobs, nil }
go
func StateJobs(jobs []multiwatcher.MachineJob) ([]state.MachineJob, error) { newJobs := make([]state.MachineJob, len(jobs)) for i, job := range jobs { newJob, err := machineJobFromParams(job) if err != nil { return nil, err } newJobs[i] = newJob } return newJobs, nil }
[ "func", "StateJobs", "(", "jobs", "[", "]", "multiwatcher", ".", "MachineJob", ")", "(", "[", "]", "state", ".", "MachineJob", ",", "error", ")", "{", "newJobs", ":=", "make", "(", "[", "]", "state", ".", "MachineJob", ",", "len", "(", "jobs", ")", ...
// StateJobs translates a slice of multiwatcher jobs to their equivalents in state.
[ "StateJobs", "translates", "a", "slice", "of", "multiwatcher", "jobs", "to", "their", "equivalents", "in", "state", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/machine.go#L19-L29
155,335
juju/juju
apiserver/common/machine.go
machineJobFromParams
func machineJobFromParams(job multiwatcher.MachineJob) (state.MachineJob, error) { switch job { case multiwatcher.JobHostUnits: return state.JobHostUnits, nil case multiwatcher.JobManageModel: return state.JobManageModel, nil default: return -1, errors.Errorf("invalid machine job %q", job) } }
go
func machineJobFromParams(job multiwatcher.MachineJob) (state.MachineJob, error) { switch job { case multiwatcher.JobHostUnits: return state.JobHostUnits, nil case multiwatcher.JobManageModel: return state.JobManageModel, nil default: return -1, errors.Errorf("invalid machine job %q", job) } }
[ "func", "machineJobFromParams", "(", "job", "multiwatcher", ".", "MachineJob", ")", "(", "state", ".", "MachineJob", ",", "error", ")", "{", "switch", "job", "{", "case", "multiwatcher", ".", "JobHostUnits", ":", "return", "state", ".", "JobHostUnits", ",", ...
// machineJobFromParams returns the job corresponding to multiwatcher.MachineJob.
[ "machineJobFromParams", "returns", "the", "job", "corresponding", "to", "multiwatcher", ".", "MachineJob", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/machine.go#L32-L41
155,336
juju/juju
core/raftlease/store.go
UnpinLease
func (s *Store) UnpinLease(key lease.Key, entity string, stop <-chan struct{}) error { return errors.Trace(s.pinOp(OperationUnpin, key, entity, stop)) }
go
func (s *Store) UnpinLease(key lease.Key, entity string, stop <-chan struct{}) error { return errors.Trace(s.pinOp(OperationUnpin, key, entity, stop)) }
[ "func", "(", "s", "*", "Store", ")", "UnpinLease", "(", "key", "lease", ".", "Key", ",", "entity", "string", ",", "stop", "<-", "chan", "struct", "{", "}", ")", "error", "{", "return", "errors", ".", "Trace", "(", "s", ".", "pinOp", "(", "Operation...
// UnpinLease is part of lease.Store.
[ "UnpinLease", "is", "part", "of", "lease", ".", "Store", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/raftlease/store.go#L163-L165
155,337
juju/juju
core/raftlease/store.go
Advance
func (s *Store) Advance(duration time.Duration, stop <-chan struct{}) error { s.prevTimeMu.Lock() defer s.prevTimeMu.Unlock() newTime := s.prevTime.Add(duration) err := s.runOnLeader(&Command{ Version: CommandVersion, Operation: OperationSetTime, OldTime: s.prevTime, NewTime: newTime, }, stop) if globalclock.IsConcurrentUpdate(err) { // Someone else updated before us - get the new time. s.prevTime = s.fsm.GlobalTime() } else if lease.IsTimeout(err) { // Convert this to a globalclock timeout to match the Updater // interface. err = globalclock.ErrTimeout } else if err == nil { s.prevTime = newTime } return errors.Trace(err) }
go
func (s *Store) Advance(duration time.Duration, stop <-chan struct{}) error { s.prevTimeMu.Lock() defer s.prevTimeMu.Unlock() newTime := s.prevTime.Add(duration) err := s.runOnLeader(&Command{ Version: CommandVersion, Operation: OperationSetTime, OldTime: s.prevTime, NewTime: newTime, }, stop) if globalclock.IsConcurrentUpdate(err) { // Someone else updated before us - get the new time. s.prevTime = s.fsm.GlobalTime() } else if lease.IsTimeout(err) { // Convert this to a globalclock timeout to match the Updater // interface. err = globalclock.ErrTimeout } else if err == nil { s.prevTime = newTime } return errors.Trace(err) }
[ "func", "(", "s", "*", "Store", ")", "Advance", "(", "duration", "time", ".", "Duration", ",", "stop", "<-", "chan", "struct", "{", "}", ")", "error", "{", "s", ".", "prevTimeMu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "prevTimeMu", ".", ...
// Advance is part of globalclock.Updater.
[ "Advance", "is", "part", "of", "globalclock", ".", "Updater", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/raftlease/store.go#L184-L205
155,338
juju/juju
core/raftlease/store.go
RecoverError
func RecoverError(resp *ResponseError) error { if resp == nil { return nil } switch resp.Code { case "invalid": return lease.ErrInvalid case "concurrent-update": return globalclock.ErrConcurrentUpdate default: return errors.New(resp.Message) } }
go
func RecoverError(resp *ResponseError) error { if resp == nil { return nil } switch resp.Code { case "invalid": return lease.ErrInvalid case "concurrent-update": return globalclock.ErrConcurrentUpdate default: return errors.New(resp.Message) } }
[ "func", "RecoverError", "(", "resp", "*", "ResponseError", ")", "error", "{", "if", "resp", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "switch", "resp", ".", "Code", "{", "case", "\"", "\"", ":", "return", "lease", ".", "ErrInvalid", "\n", "...
// RecoverError converts a ResponseError back into the specific error // it represents, or into a generic error if it wasn't one of the // singleton errors handled.
[ "RecoverError", "converts", "a", "ResponseError", "back", "into", "the", "specific", "error", "it", "represents", "or", "into", "a", "generic", "error", "if", "it", "wasn", "t", "one", "of", "the", "singleton", "errors", "handled", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/raftlease/store.go#L321-L333
155,339
juju/juju
state/charmref.go
appCharmIncRefOps
func appCharmIncRefOps(mb modelBackend, appName string, curl *charm.URL, canCreate bool) ([]txn.Op, error) { charms, closer := mb.db().GetCollection(charmsC) defer closer() // If we're migrating. charm document will not be present. But // if we're not migrating, we need to check the charm is alive. var checkOps []txn.Op count, err := charms.FindId(curl.String()).Count() if err != nil { return nil, errors.Annotate(err, "charm") } else if count != 0 { checkOp, err := nsLife.aliveOp(charms, curl.String()) if err != nil { return nil, errors.Annotate(err, "charm") } checkOps = []txn.Op{checkOp} } refcounts, closer := mb.db().GetCollection(refcountsC) defer closer() getIncRefOp := nsRefcounts.CreateOrIncRefOp if !canCreate { getIncRefOp = nsRefcounts.StrictIncRefOp } settingsKey := applicationCharmConfigKey(appName, curl) settingsOp, err := getIncRefOp(refcounts, settingsKey, 1) if err != nil { return nil, errors.Annotate(err, "settings reference") } storageConstraintsKey := applicationStorageConstraintsKey(appName, curl) storageConstraintsOp, err := getIncRefOp(refcounts, storageConstraintsKey, 1) if err != nil { return nil, errors.Annotate(err, "storage constraints reference") } charmKey := charmGlobalKey(curl) charmOp, err := getIncRefOp(refcounts, charmKey, 1) if err != nil { return nil, errors.Annotate(err, "charm reference") } return append(checkOps, settingsOp, storageConstraintsOp, charmOp), nil }
go
func appCharmIncRefOps(mb modelBackend, appName string, curl *charm.URL, canCreate bool) ([]txn.Op, error) { charms, closer := mb.db().GetCollection(charmsC) defer closer() // If we're migrating. charm document will not be present. But // if we're not migrating, we need to check the charm is alive. var checkOps []txn.Op count, err := charms.FindId(curl.String()).Count() if err != nil { return nil, errors.Annotate(err, "charm") } else if count != 0 { checkOp, err := nsLife.aliveOp(charms, curl.String()) if err != nil { return nil, errors.Annotate(err, "charm") } checkOps = []txn.Op{checkOp} } refcounts, closer := mb.db().GetCollection(refcountsC) defer closer() getIncRefOp := nsRefcounts.CreateOrIncRefOp if !canCreate { getIncRefOp = nsRefcounts.StrictIncRefOp } settingsKey := applicationCharmConfigKey(appName, curl) settingsOp, err := getIncRefOp(refcounts, settingsKey, 1) if err != nil { return nil, errors.Annotate(err, "settings reference") } storageConstraintsKey := applicationStorageConstraintsKey(appName, curl) storageConstraintsOp, err := getIncRefOp(refcounts, storageConstraintsKey, 1) if err != nil { return nil, errors.Annotate(err, "storage constraints reference") } charmKey := charmGlobalKey(curl) charmOp, err := getIncRefOp(refcounts, charmKey, 1) if err != nil { return nil, errors.Annotate(err, "charm reference") } return append(checkOps, settingsOp, storageConstraintsOp, charmOp), nil }
[ "func", "appCharmIncRefOps", "(", "mb", "modelBackend", ",", "appName", "string", ",", "curl", "*", "charm", ".", "URL", ",", "canCreate", "bool", ")", "(", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "charms", ",", "closer", ":=", "mb", ".",...
// appCharmIncRefOps returns the operations necessary to record a reference // to a charm and its per-application settings and storage constraints // documents. It will fail if the charm is not Alive.
[ "appCharmIncRefOps", "returns", "the", "operations", "necessary", "to", "record", "a", "reference", "to", "a", "charm", "and", "its", "per", "-", "application", "settings", "and", "storage", "constraints", "documents", ".", "It", "will", "fail", "if", "the", "...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charmref.go#L17-L59
155,340
juju/juju
state/charmref.go
finalAppCharmRemoveOps
func finalAppCharmRemoveOps(appName string, curl *charm.URL) []txn.Op { settingsKey := applicationCharmConfigKey(appName, curl) removeSettingsOp := txn.Op{ C: settingsC, Id: settingsKey, Remove: true, } // ensure removing storage constraints doc storageConstraintsKey := applicationStorageConstraintsKey(appName, curl) removeStorageConstraintsOp := removeStorageConstraintsOp(storageConstraintsKey) // ensure removing device constraints doc deviceConstraintsKey := applicationDeviceConstraintsKey(appName, curl) removeDeviceConstraintsOp := removeDeviceConstraintsOp(deviceConstraintsKey) cleanupOp := newCleanupOp(cleanupCharm, curl.String()) return []txn.Op{removeSettingsOp, removeStorageConstraintsOp, removeDeviceConstraintsOp, cleanupOp} }
go
func finalAppCharmRemoveOps(appName string, curl *charm.URL) []txn.Op { settingsKey := applicationCharmConfigKey(appName, curl) removeSettingsOp := txn.Op{ C: settingsC, Id: settingsKey, Remove: true, } // ensure removing storage constraints doc storageConstraintsKey := applicationStorageConstraintsKey(appName, curl) removeStorageConstraintsOp := removeStorageConstraintsOp(storageConstraintsKey) // ensure removing device constraints doc deviceConstraintsKey := applicationDeviceConstraintsKey(appName, curl) removeDeviceConstraintsOp := removeDeviceConstraintsOp(deviceConstraintsKey) cleanupOp := newCleanupOp(cleanupCharm, curl.String()) return []txn.Op{removeSettingsOp, removeStorageConstraintsOp, removeDeviceConstraintsOp, cleanupOp} }
[ "func", "finalAppCharmRemoveOps", "(", "appName", "string", ",", "curl", "*", "charm", ".", "URL", ")", "[", "]", "txn", ".", "Op", "{", "settingsKey", ":=", "applicationCharmConfigKey", "(", "appName", ",", "curl", ")", "\n", "removeSettingsOp", ":=", "txn"...
// finalAppCharmRemoveOps returns operations to delete the settings // and storage, device constraints documents and queue a charm cleanup.
[ "finalAppCharmRemoveOps", "returns", "operations", "to", "delete", "the", "settings", "and", "storage", "device", "constraints", "documents", "and", "queue", "a", "charm", "cleanup", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charmref.go#L129-L145
155,341
juju/juju
state/charmref.go
charmDestroyOps
func charmDestroyOps(st modelBackend, curl *charm.URL) ([]txn.Op, error) { db := st.db() charms, closer := db.GetCollection(charmsC) defer closer() charmKey := curl.String() charmOp, err := nsLife.destroyOp(charms, charmKey, nil) if err != nil { return nil, errors.Annotate(err, "charm") } refcounts, closer := db.GetCollection(refcountsC) defer closer() refcountKey := charmGlobalKey(curl) refcountOp, err := nsRefcounts.RemoveOp(refcounts, refcountKey, 0) switch errors.Cause(err) { case nil: case errRefcountChanged: return nil, errCharmInUse default: return nil, errors.Annotate(err, "charm reference") } return []txn.Op{charmOp, refcountOp}, nil }
go
func charmDestroyOps(st modelBackend, curl *charm.URL) ([]txn.Op, error) { db := st.db() charms, closer := db.GetCollection(charmsC) defer closer() charmKey := curl.String() charmOp, err := nsLife.destroyOp(charms, charmKey, nil) if err != nil { return nil, errors.Annotate(err, "charm") } refcounts, closer := db.GetCollection(refcountsC) defer closer() refcountKey := charmGlobalKey(curl) refcountOp, err := nsRefcounts.RemoveOp(refcounts, refcountKey, 0) switch errors.Cause(err) { case nil: case errRefcountChanged: return nil, errCharmInUse default: return nil, errors.Annotate(err, "charm reference") } return []txn.Op{charmOp, refcountOp}, nil }
[ "func", "charmDestroyOps", "(", "st", "modelBackend", ",", "curl", "*", "charm", ".", "URL", ")", "(", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "db", ":=", "st", ".", "db", "(", ")", "\n", "charms", ",", "closer", ":=", "db", ".", "G...
// charmDestroyOps implements the logic of charm.Destroy.
[ "charmDestroyOps", "implements", "the", "logic", "of", "charm", ".", "Destroy", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charmref.go#L148-L173
155,342
juju/juju
apiserver/facades/controller/resumer/resumer.go
NewResumerAPI
func NewResumerAPI(st *state.State, _ facade.Resources, authorizer facade.Authorizer) (*ResumerAPI, error) { if !authorizer.AuthController() { return nil, common.ErrPerm } return &ResumerAPI{ st: getState(st), auth: authorizer, }, nil }
go
func NewResumerAPI(st *state.State, _ facade.Resources, authorizer facade.Authorizer) (*ResumerAPI, error) { if !authorizer.AuthController() { return nil, common.ErrPerm } return &ResumerAPI{ st: getState(st), auth: authorizer, }, nil }
[ "func", "NewResumerAPI", "(", "st", "*", "state", ".", "State", ",", "_", "facade", ".", "Resources", ",", "authorizer", "facade", ".", "Authorizer", ")", "(", "*", "ResumerAPI", ",", "error", ")", "{", "if", "!", "authorizer", ".", "AuthController", "("...
// NewResumerAPI creates a new instance of the Resumer API.
[ "NewResumerAPI", "creates", "a", "new", "instance", "of", "the", "Resumer", "API", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/controller/resumer/resumer.go#L21-L29
155,343
juju/juju
storage/poolmanager/interface.go
CreateSettings
func (m MemSettings) CreateSettings(key string, settings map[string]interface{}) error { if _, ok := m.Settings[key]; ok { return errors.AlreadyExistsf("settings with key %q", key) } m.Settings[key] = settings return nil }
go
func (m MemSettings) CreateSettings(key string, settings map[string]interface{}) error { if _, ok := m.Settings[key]; ok { return errors.AlreadyExistsf("settings with key %q", key) } m.Settings[key] = settings return nil }
[ "func", "(", "m", "MemSettings", ")", "CreateSettings", "(", "key", "string", ",", "settings", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "if", "_", ",", "ok", ":=", "m", ".", "Settings", "[", "key", "]", ";", "ok", "{", ...
// CreateSettings is part of the SettingsManager interface.
[ "CreateSettings", "is", "part", "of", "the", "SettingsManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/interface.go#L47-L53
155,344
juju/juju
storage/poolmanager/interface.go
ReplaceSettings
func (m MemSettings) ReplaceSettings(key string, settings map[string]interface{}) error { if _, ok := m.Settings[key]; !ok { return errors.NotFoundf("settings with key %q", key) } m.Settings[key] = settings return nil }
go
func (m MemSettings) ReplaceSettings(key string, settings map[string]interface{}) error { if _, ok := m.Settings[key]; !ok { return errors.NotFoundf("settings with key %q", key) } m.Settings[key] = settings return nil }
[ "func", "(", "m", "MemSettings", ")", "ReplaceSettings", "(", "key", "string", ",", "settings", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "if", "_", ",", "ok", ":=", "m", ".", "Settings", "[", "key", "]", ";", "!", "ok", ...
// ReplaceSettings is part of the SettingsManager interface.
[ "ReplaceSettings", "is", "part", "of", "the", "SettingsManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/interface.go#L56-L62
155,345
juju/juju
storage/poolmanager/interface.go
ReadSettings
func (m MemSettings) ReadSettings(key string) (map[string]interface{}, error) { settings, ok := m.Settings[key] if !ok { return nil, errors.NotFoundf("settings with key %q", key) } return settings, nil }
go
func (m MemSettings) ReadSettings(key string) (map[string]interface{}, error) { settings, ok := m.Settings[key] if !ok { return nil, errors.NotFoundf("settings with key %q", key) } return settings, nil }
[ "func", "(", "m", "MemSettings", ")", "ReadSettings", "(", "key", "string", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "settings", ",", "ok", ":=", "m", ".", "Settings", "[", "key", "]", "\n", "if", "!", "...
// ReadSettings is part of the SettingsManager interface.
[ "ReadSettings", "is", "part", "of", "the", "SettingsManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/interface.go#L65-L71
155,346
juju/juju
storage/poolmanager/interface.go
RemoveSettings
func (m MemSettings) RemoveSettings(key string) error { if _, ok := m.Settings[key]; !ok { return errors.NotFoundf("settings with key %q", key) } delete(m.Settings, key) return nil }
go
func (m MemSettings) RemoveSettings(key string) error { if _, ok := m.Settings[key]; !ok { return errors.NotFoundf("settings with key %q", key) } delete(m.Settings, key) return nil }
[ "func", "(", "m", "MemSettings", ")", "RemoveSettings", "(", "key", "string", ")", "error", "{", "if", "_", ",", "ok", ":=", "m", ".", "Settings", "[", "key", "]", ";", "!", "ok", "{", "return", "errors", ".", "NotFoundf", "(", "\"", "\"", ",", "...
// RemoveSettings is part of the SettingsManager interface.
[ "RemoveSettings", "is", "part", "of", "the", "SettingsManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/interface.go#L74-L80
155,347
juju/juju
storage/poolmanager/interface.go
ListSettings
func (m MemSettings) ListSettings(keyPrefix string) (map[string]map[string]interface{}, error) { result := make(map[string]map[string]interface{}) for key, settings := range m.Settings { if !strings.HasPrefix(key, keyPrefix) { continue } result[key] = settings } return result, nil }
go
func (m MemSettings) ListSettings(keyPrefix string) (map[string]map[string]interface{}, error) { result := make(map[string]map[string]interface{}) for key, settings := range m.Settings { if !strings.HasPrefix(key, keyPrefix) { continue } result[key] = settings } return result, nil }
[ "func", "(", "m", "MemSettings", ")", "ListSettings", "(", "keyPrefix", "string", ")", "(", "map", "[", "string", "]", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "result", ":=", "make", "(", "map", "[", "string", "]", ...
// ListSettings is part of the SettingsManager interface.
[ "ListSettings", "is", "part", "of", "the", "SettingsManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/interface.go#L83-L92
155,348
juju/juju
core/cache/model.go
Config
func (m *Model) Config() map[string]interface{} { m.mu.Lock() cfg := make(map[string]interface{}, len(m.details.Config)) for k, v := range m.details.Config { cfg[k] = v } m.mu.Unlock() m.metrics.ModelConfigReads.Inc() return cfg }
go
func (m *Model) Config() map[string]interface{} { m.mu.Lock() cfg := make(map[string]interface{}, len(m.details.Config)) for k, v := range m.details.Config { cfg[k] = v } m.mu.Unlock() m.metrics.ModelConfigReads.Inc() return cfg }
[ "func", "(", "m", "*", "Model", ")", "Config", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "cfg", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "len...
// Config returns the current model config.
[ "Config", "returns", "the", "current", "model", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L65-L74
155,349
juju/juju
core/cache/model.go
WatchConfig
func (m *Model) WatchConfig(keys ...string) *ConfigWatcher { return newConfigWatcher(keys, m.hashCache, m.hub, m.topic(modelConfigChange), m.Resident) }
go
func (m *Model) WatchConfig(keys ...string) *ConfigWatcher { return newConfigWatcher(keys, m.hashCache, m.hub, m.topic(modelConfigChange), m.Resident) }
[ "func", "(", "m", "*", "Model", ")", "WatchConfig", "(", "keys", "...", "string", ")", "*", "ConfigWatcher", "{", "return", "newConfigWatcher", "(", "keys", ",", "m", ".", "hashCache", ",", "m", ".", "hub", ",", "m", ".", "topic", "(", "modelConfigChan...
// WatchConfig creates a watcher for the model config.
[ "WatchConfig", "creates", "a", "watcher", "for", "the", "model", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L82-L84
155,350
juju/juju
core/cache/model.go
Application
func (m *Model) Application(appName string) (*Application, error) { defer m.doLocked()() app, found := m.applications[appName] if !found { return nil, errors.NotFoundf("application %q", appName) } return app, nil }
go
func (m *Model) Application(appName string) (*Application, error) { defer m.doLocked()() app, found := m.applications[appName] if !found { return nil, errors.NotFoundf("application %q", appName) } return app, nil }
[ "func", "(", "m", "*", "Model", ")", "Application", "(", "appName", "string", ")", "(", "*", "Application", ",", "error", ")", "{", "defer", "m", ".", "doLocked", "(", ")", "(", ")", "\n\n", "app", ",", "found", ":=", "m", ".", "applications", "[",...
// Application returns the application for the input name. // If the application is not found, a NotFoundError is returned.
[ "Application", "returns", "the", "application", "for", "the", "input", "name", ".", "If", "the", "application", "is", "not", "found", "a", "NotFoundError", "is", "returned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L102-L110
155,351
juju/juju
core/cache/model.go
Charm
func (m *Model) Charm(charmURL string) (*Charm, error) { defer m.doLocked()() charm, found := m.charms[charmURL] if !found { return nil, errors.NotFoundf("charm %q", charmURL) } return charm, nil }
go
func (m *Model) Charm(charmURL string) (*Charm, error) { defer m.doLocked()() charm, found := m.charms[charmURL] if !found { return nil, errors.NotFoundf("charm %q", charmURL) } return charm, nil }
[ "func", "(", "m", "*", "Model", ")", "Charm", "(", "charmURL", "string", ")", "(", "*", "Charm", ",", "error", ")", "{", "defer", "m", ".", "doLocked", "(", ")", "(", ")", "\n\n", "charm", ",", "found", ":=", "m", ".", "charms", "[", "charmURL", ...
// Charm returns the charm for the input charmURL. // If the charm is not found, a NotFoundError is returned.
[ "Charm", "returns", "the", "charm", "for", "the", "input", "charmURL", ".", "If", "the", "charm", "is", "not", "found", "a", "NotFoundError", "is", "returned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L114-L122
155,352
juju/juju
core/cache/model.go
Machines
func (m *Model) Machines() map[string]*Machine { machines := make(map[string]*Machine) m.mu.Lock() for k, v := range m.machines { machines[k] = v } m.mu.Unlock() return machines }
go
func (m *Model) Machines() map[string]*Machine { machines := make(map[string]*Machine) m.mu.Lock() for k, v := range m.machines { machines[k] = v } m.mu.Unlock() return machines }
[ "func", "(", "m", "*", "Model", ")", "Machines", "(", ")", "map", "[", "string", "]", "*", "Machine", "{", "machines", ":=", "make", "(", "map", "[", "string", "]", "*", "Machine", ")", "\n\n", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "for"...
// Machines makes a copy of the model's machine collection and returns it.
[ "Machines", "makes", "a", "copy", "of", "the", "model", "s", "machine", "collection", "and", "returns", "it", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L125-L135
155,353
juju/juju
core/cache/model.go
Machine
func (m *Model) Machine(machineId string) (*Machine, error) { defer m.doLocked()() machine, found := m.machines[machineId] if !found { return nil, errors.NotFoundf("machine %q", machineId) } return machine, nil }
go
func (m *Model) Machine(machineId string) (*Machine, error) { defer m.doLocked()() machine, found := m.machines[machineId] if !found { return nil, errors.NotFoundf("machine %q", machineId) } return machine, nil }
[ "func", "(", "m", "*", "Model", ")", "Machine", "(", "machineId", "string", ")", "(", "*", "Machine", ",", "error", ")", "{", "defer", "m", ".", "doLocked", "(", ")", "(", ")", "\n\n", "machine", ",", "found", ":=", "m", ".", "machines", "[", "ma...
// Machine returns the machine with the input id. // If the machine is not found, a NotFoundError is returned.
[ "Machine", "returns", "the", "machine", "with", "the", "input", "id", ".", "If", "the", "machine", "is", "not", "found", "a", "NotFoundError", "is", "returned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L139-L147
155,354
juju/juju
core/cache/model.go
WatchMachines
func (m *Model) WatchMachines() (*PredicateStringsWatcher, error) { defer m.doLocked()() // Create a compiled regexp to match machines not containers. compiled, err := m.machineRegexp() if err != nil { return nil, err } fn := regexpPredicate(compiled) // Gather initial slice of machines in this model. machines := make([]string, 0) for k := range m.machines { if fn(k) { machines = append(machines, k) } } w := newPredicateStringsWatcher(fn, machines...) deregister := m.registerWorker(w) unsub := m.hub.Subscribe(m.topic(modelAddRemoveMachine), w.changed) w.tomb.Go(func() error { <-w.tomb.Dying() unsub() deregister() return nil }) return w, nil }
go
func (m *Model) WatchMachines() (*PredicateStringsWatcher, error) { defer m.doLocked()() // Create a compiled regexp to match machines not containers. compiled, err := m.machineRegexp() if err != nil { return nil, err } fn := regexpPredicate(compiled) // Gather initial slice of machines in this model. machines := make([]string, 0) for k := range m.machines { if fn(k) { machines = append(machines, k) } } w := newPredicateStringsWatcher(fn, machines...) deregister := m.registerWorker(w) unsub := m.hub.Subscribe(m.topic(modelAddRemoveMachine), w.changed) w.tomb.Go(func() error { <-w.tomb.Dying() unsub() deregister() return nil }) return w, nil }
[ "func", "(", "m", "*", "Model", ")", "WatchMachines", "(", ")", "(", "*", "PredicateStringsWatcher", ",", "error", ")", "{", "defer", "m", ".", "doLocked", "(", ")", "(", ")", "\n\n", "// Create a compiled regexp to match machines not containers.", "compiled", "...
// WatchMachines returns a PredicateStringsWatcher to notify about // added and removed machines in the model. The initial event contains // a slice of the current machine ids. Containers are excluded.
[ "WatchMachines", "returns", "a", "PredicateStringsWatcher", "to", "notify", "about", "added", "and", "removed", "machines", "in", "the", "model", ".", "The", "initial", "event", "contains", "a", "slice", "of", "the", "current", "machine", "ids", ".", "Containers...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L152-L182
155,355
juju/juju
core/cache/model.go
Unit
func (m *Model) Unit(unitName string) (*Unit, error) { defer m.doLocked()() unit, found := m.units[unitName] if !found { return nil, errors.NotFoundf("unit %q", unitName) } return unit, nil }
go
func (m *Model) Unit(unitName string) (*Unit, error) { defer m.doLocked()() unit, found := m.units[unitName] if !found { return nil, errors.NotFoundf("unit %q", unitName) } return unit, nil }
[ "func", "(", "m", "*", "Model", ")", "Unit", "(", "unitName", "string", ")", "(", "*", "Unit", ",", "error", ")", "{", "defer", "m", ".", "doLocked", "(", ")", "(", ")", "\n\n", "unit", ",", "found", ":=", "m", ".", "units", "[", "unitName", "]...
// Unit returns the unit with the input name. // If the unit is not found, a NotFoundError is returned.
[ "Unit", "returns", "the", "unit", "with", "the", "input", "name", ".", "If", "the", "unit", "is", "not", "found", "a", "NotFoundError", "is", "returned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L186-L194
155,356
juju/juju
core/cache/model.go
updateApplication
func (m *Model) updateApplication(ch ApplicationChange, rm *residentManager) { m.mu.Lock() app, found := m.applications[ch.Name] if !found { app = newApplication(m.metrics, m.hub, rm.new()) m.applications[ch.Name] = app } app.setDetails(ch) m.mu.Unlock() }
go
func (m *Model) updateApplication(ch ApplicationChange, rm *residentManager) { m.mu.Lock() app, found := m.applications[ch.Name] if !found { app = newApplication(m.metrics, m.hub, rm.new()) m.applications[ch.Name] = app } app.setDetails(ch) m.mu.Unlock() }
[ "func", "(", "m", "*", "Model", ")", "updateApplication", "(", "ch", "ApplicationChange", ",", "rm", "*", "residentManager", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n\n", "app", ",", "found", ":=", "m", ".", "applications", "[", "ch", ".",...
// updateApplication adds or updates the application in the model.
[ "updateApplication", "adds", "or", "updates", "the", "application", "in", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L197-L208
155,357
juju/juju
core/cache/model.go
removeApplication
func (m *Model) removeApplication(ch RemoveApplication) error { defer m.doLocked()() app, ok := m.applications[ch.Name] if ok { if err := app.evict(); err != nil { return errors.Trace(err) } delete(m.applications, ch.Name) } return nil }
go
func (m *Model) removeApplication(ch RemoveApplication) error { defer m.doLocked()() app, ok := m.applications[ch.Name] if ok { if err := app.evict(); err != nil { return errors.Trace(err) } delete(m.applications, ch.Name) } return nil }
[ "func", "(", "m", "*", "Model", ")", "removeApplication", "(", "ch", "RemoveApplication", ")", "error", "{", "defer", "m", ".", "doLocked", "(", ")", "(", ")", "\n\n", "app", ",", "ok", ":=", "m", ".", "applications", "[", "ch", ".", "Name", "]", "...
// removeApplication removes the application from the model.
[ "removeApplication", "removes", "the", "application", "from", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L211-L222
155,358
juju/juju
core/cache/model.go
updateCharm
func (m *Model) updateCharm(ch CharmChange, rm *residentManager) { m.mu.Lock() charm, found := m.charms[ch.CharmURL] if !found { charm = newCharm(m.metrics, m.hub, rm.new()) m.charms[ch.CharmURL] = charm } charm.setDetails(ch) m.mu.Unlock() }
go
func (m *Model) updateCharm(ch CharmChange, rm *residentManager) { m.mu.Lock() charm, found := m.charms[ch.CharmURL] if !found { charm = newCharm(m.metrics, m.hub, rm.new()) m.charms[ch.CharmURL] = charm } charm.setDetails(ch) m.mu.Unlock() }
[ "func", "(", "m", "*", "Model", ")", "updateCharm", "(", "ch", "CharmChange", ",", "rm", "*", "residentManager", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n\n", "charm", ",", "found", ":=", "m", ".", "charms", "[", "ch", ".", "CharmURL", ...
// updateCharm adds or updates the charm in the model.
[ "updateCharm", "adds", "or", "updates", "the", "charm", "in", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L225-L236
155,359
juju/juju
core/cache/model.go
removeCharm
func (m *Model) removeCharm(ch RemoveCharm) error { defer m.doLocked()() charm, ok := m.charms[ch.CharmURL] if ok { if err := charm.evict(); err != nil { return errors.Trace(err) } delete(m.charms, ch.CharmURL) } return nil }
go
func (m *Model) removeCharm(ch RemoveCharm) error { defer m.doLocked()() charm, ok := m.charms[ch.CharmURL] if ok { if err := charm.evict(); err != nil { return errors.Trace(err) } delete(m.charms, ch.CharmURL) } return nil }
[ "func", "(", "m", "*", "Model", ")", "removeCharm", "(", "ch", "RemoveCharm", ")", "error", "{", "defer", "m", ".", "doLocked", "(", ")", "(", ")", "\n\n", "charm", ",", "ok", ":=", "m", ".", "charms", "[", "ch", ".", "CharmURL", "]", "\n", "if",...
// removeCharm removes the charm from the model.
[ "removeCharm", "removes", "the", "charm", "from", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L239-L250
155,360
juju/juju
core/cache/model.go
updateUnit
func (m *Model) updateUnit(ch UnitChange, rm *residentManager) { m.mu.Lock() unit, found := m.units[ch.Name] if !found { unit = newUnit(m.metrics, m.hub, rm.new()) m.units[ch.Name] = unit } unit.setDetails(ch) m.mu.Unlock() }
go
func (m *Model) updateUnit(ch UnitChange, rm *residentManager) { m.mu.Lock() unit, found := m.units[ch.Name] if !found { unit = newUnit(m.metrics, m.hub, rm.new()) m.units[ch.Name] = unit } unit.setDetails(ch) m.mu.Unlock() }
[ "func", "(", "m", "*", "Model", ")", "updateUnit", "(", "ch", "UnitChange", ",", "rm", "*", "residentManager", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n\n", "unit", ",", "found", ":=", "m", ".", "units", "[", "ch", ".", "Name", "]", ...
// updateUnit adds or updates the unit in the model.
[ "updateUnit", "adds", "or", "updates", "the", "unit", "in", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L253-L264
155,361
juju/juju
core/cache/model.go
removeUnit
func (m *Model) removeUnit(ch RemoveUnit) error { defer m.doLocked()() unit, ok := m.units[ch.Name] if ok { m.hub.Publish(m.topic(modelUnitLXDProfileRemove), unitLXDProfileRemove{name: ch.Name, appName: unit.details.Application}) if err := unit.evict(); err != nil { return errors.Trace(err) } delete(m.units, ch.Name) } return nil }
go
func (m *Model) removeUnit(ch RemoveUnit) error { defer m.doLocked()() unit, ok := m.units[ch.Name] if ok { m.hub.Publish(m.topic(modelUnitLXDProfileRemove), unitLXDProfileRemove{name: ch.Name, appName: unit.details.Application}) if err := unit.evict(); err != nil { return errors.Trace(err) } delete(m.units, ch.Name) } return nil }
[ "func", "(", "m", "*", "Model", ")", "removeUnit", "(", "ch", "RemoveUnit", ")", "error", "{", "defer", "m", ".", "doLocked", "(", ")", "(", ")", "\n\n", "unit", ",", "ok", ":=", "m", ".", "units", "[", "ch", ".", "Name", "]", "\n", "if", "ok",...
// removeUnit removes the unit from the model.
[ "removeUnit", "removes", "the", "unit", "from", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L274-L286
155,362
juju/juju
core/cache/model.go
updateMachine
func (m *Model) updateMachine(ch MachineChange, rm *residentManager) { m.mu.Lock() machine, found := m.machines[ch.Id] if !found { machine = newMachine(m, rm.new()) m.machines[ch.Id] = machine m.hub.Publish(m.topic(modelAddRemoveMachine), []string{ch.Id}) } machine.setDetails(ch) m.mu.Unlock() }
go
func (m *Model) updateMachine(ch MachineChange, rm *residentManager) { m.mu.Lock() machine, found := m.machines[ch.Id] if !found { machine = newMachine(m, rm.new()) m.machines[ch.Id] = machine m.hub.Publish(m.topic(modelAddRemoveMachine), []string{ch.Id}) } machine.setDetails(ch) m.mu.Unlock() }
[ "func", "(", "m", "*", "Model", ")", "updateMachine", "(", "ch", "MachineChange", ",", "rm", "*", "residentManager", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n\n", "machine", ",", "found", ":=", "m", ".", "machines", "[", "ch", ".", "Id",...
// updateMachine adds or updates the machine in the model.
[ "updateMachine", "adds", "or", "updates", "the", "machine", "in", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L289-L301
155,363
juju/juju
core/cache/model.go
removeMachine
func (m *Model) removeMachine(ch RemoveMachine) error { defer m.doLocked()() machine, ok := m.machines[ch.Id] if ok { m.hub.Publish(m.topic(modelAddRemoveMachine), []string{ch.Id}) if err := machine.evict(); err != nil { return errors.Trace(err) } delete(m.machines, ch.Id) } return nil }
go
func (m *Model) removeMachine(ch RemoveMachine) error { defer m.doLocked()() machine, ok := m.machines[ch.Id] if ok { m.hub.Publish(m.topic(modelAddRemoveMachine), []string{ch.Id}) if err := machine.evict(); err != nil { return errors.Trace(err) } delete(m.machines, ch.Id) } return nil }
[ "func", "(", "m", "*", "Model", ")", "removeMachine", "(", "ch", "RemoveMachine", ")", "error", "{", "defer", "m", ".", "doLocked", "(", ")", "(", ")", "\n\n", "machine", ",", "ok", ":=", "m", ".", "machines", "[", "ch", ".", "Id", "]", "\n", "if...
// removeMachine removes the machine from the model.
[ "removeMachine", "removes", "the", "machine", "from", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L304-L316
155,364
juju/juju
core/cache/model.go
topic
func (m *Model) topic(suffix string) string { return modelTopic(m.details.ModelUUID, suffix) }
go
func (m *Model) topic(suffix string) string { return modelTopic(m.details.ModelUUID, suffix) }
[ "func", "(", "m", "*", "Model", ")", "topic", "(", "suffix", "string", ")", "string", "{", "return", "modelTopic", "(", "m", ".", "details", ".", "ModelUUID", ",", "suffix", ")", "\n", "}" ]
// topic prefixes the input string with the model UUID.
[ "topic", "prefixes", "the", "input", "string", "with", "the", "model", "UUID", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/model.go#L319-L321
155,365
juju/juju
worker/provisioner/logging.go
loggedErrorStack
func loggedErrorStack(err error) error { if featureflag.Enabled(feature.LogErrorStack) { logger.Errorf("error stack:\n%s", errors.ErrorStack(err)) } return err }
go
func loggedErrorStack(err error) error { if featureflag.Enabled(feature.LogErrorStack) { logger.Errorf("error stack:\n%s", errors.ErrorStack(err)) } return err }
[ "func", "loggedErrorStack", "(", "err", "error", ")", "error", "{", "if", "featureflag", ".", "Enabled", "(", "feature", ".", "LogErrorStack", ")", "{", "logger", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "errors", ".", "ErrorStack", "(", "err", ")", ...
// loggedErrorStack is a developer helper function that will cause the error // stack of the error to be printed out at error severity if and only if the // "log-error-stack" feature flag has been specified. The passed in error // is also the return value of this function.
[ "loggedErrorStack", "is", "a", "developer", "helper", "function", "that", "will", "cause", "the", "error", "stack", "of", "the", "error", "to", "be", "printed", "out", "at", "error", "severity", "if", "and", "only", "if", "the", "log", "-", "error", "-", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/provisioner/logging.go#L17-L22
155,366
juju/juju
api/common/life.go
Life
func Life(caller base.FacadeCaller, tags []names.Tag) ([]params.LifeResult, error) { if len(tags) == 0 { return []params.LifeResult{}, nil } var result params.LifeResults entities := make([]params.Entity, len(tags)) for i, t := range tags { entities[i] = params.Entity{t.String()} } args := params.Entities{Entities: entities} if err := caller.FacadeCall("Life", args, &result); err != nil { return []params.LifeResult{}, err } return result.Results, nil }
go
func Life(caller base.FacadeCaller, tags []names.Tag) ([]params.LifeResult, error) { if len(tags) == 0 { return []params.LifeResult{}, nil } var result params.LifeResults entities := make([]params.Entity, len(tags)) for i, t := range tags { entities[i] = params.Entity{t.String()} } args := params.Entities{Entities: entities} if err := caller.FacadeCall("Life", args, &result); err != nil { return []params.LifeResult{}, err } return result.Results, nil }
[ "func", "Life", "(", "caller", "base", ".", "FacadeCaller", ",", "tags", "[", "]", "names", ".", "Tag", ")", "(", "[", "]", "params", ".", "LifeResult", ",", "error", ")", "{", "if", "len", "(", "tags", ")", "==", "0", "{", "return", "[", "]", ...
// Life requests the life cycle of the given entities from the given // server-side API facade via the given caller.
[ "Life", "requests", "the", "life", "cycle", "of", "the", "given", "entities", "from", "the", "given", "server", "-", "side", "API", "facade", "via", "the", "given", "caller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/life.go#L16-L30
155,367
juju/juju
api/common/life.go
OneLife
func OneLife(caller base.FacadeCaller, tag names.Tag) (params.Life, error) { result, err := Life(caller, []names.Tag{tag}) if err != nil { return "", err } if len(result) != 1 { return "", errors.Errorf("expected 1 result, got %d", len(result)) } if err := result[0].Error; err != nil { return "", err } return result[0].Life, nil }
go
func OneLife(caller base.FacadeCaller, tag names.Tag) (params.Life, error) { result, err := Life(caller, []names.Tag{tag}) if err != nil { return "", err } if len(result) != 1 { return "", errors.Errorf("expected 1 result, got %d", len(result)) } if err := result[0].Error; err != nil { return "", err } return result[0].Life, nil }
[ "func", "OneLife", "(", "caller", "base", ".", "FacadeCaller", ",", "tag", "names", ".", "Tag", ")", "(", "params", ".", "Life", ",", "error", ")", "{", "result", ",", "err", ":=", "Life", "(", "caller", ",", "[", "]", "names", ".", "Tag", "{", "...
// OneLife requests the life cycle of the given entity from the given // server-side API facade via the given caller.
[ "OneLife", "requests", "the", "life", "cycle", "of", "the", "given", "entity", "from", "the", "given", "server", "-", "side", "API", "facade", "via", "the", "given", "caller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/life.go#L34-L46
155,368
juju/juju
worker/unitassigner/manifold.go
Manifold
func Manifold(config ManifoldConfig) dependency.Manifold { return engine.APIManifold( engine.APIManifoldConfig(config), manifoldStart, ) }
go
func Manifold(config ManifoldConfig) dependency.Manifold { return engine.APIManifold( engine.APIManifoldConfig(config), manifoldStart, ) }
[ "func", "Manifold", "(", "config", "ManifoldConfig", ")", "dependency", ".", "Manifold", "{", "return", "engine", ".", "APIManifold", "(", "engine", ".", "APIManifoldConfig", "(", "config", ")", ",", "manifoldStart", ",", ")", "\n", "}" ]
// Manifold returns a Manifold that runs a unitassigner worker.
[ "Manifold", "returns", "a", "Manifold", "that", "runs", "a", "unitassigner", "worker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/unitassigner/manifold.go#L20-L25
155,369
juju/juju
cmd/jujud/agent/unit/manifolds.go
SetStatus
func (a *noopStatusSetter) SetStatus(setableStatus status.Status, info string, data map[string]interface{}) error { return nil }
go
func (a *noopStatusSetter) SetStatus(setableStatus status.Status, info string, data map[string]interface{}) error { return nil }
[ "func", "(", "a", "*", "noopStatusSetter", ")", "SetStatus", "(", "setableStatus", "status", ".", "Status", ",", "info", "string", ",", "data", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "return", "nil", "\n", "}" ]
// SetStatus implements upgradesteps.StatusSetter
[ "SetStatus", "implements", "upgradesteps", ".", "StatusSetter" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/jujud/agent/unit/manifolds.go#L399-L401
155,370
juju/juju
apiserver/config.go
DefaultRateLimitConfig
func DefaultRateLimitConfig() RateLimitConfig { return RateLimitConfig{ LoginRateLimit: defaultLoginRateLimit, LoginMinPause: defaultLoginMinPause, LoginMaxPause: defaultLoginMaxPause, LoginRetryPause: defaultLoginRetryPause, ConnMinPause: defaultConnMinPause, ConnMaxPause: defaultConnMaxPause, ConnLookbackWindow: defaultConnLookbackWindow, ConnLowerThreshold: defaultConnLowerThreshold, ConnUpperThreshold: defaultConnUpperThreshold, } }
go
func DefaultRateLimitConfig() RateLimitConfig { return RateLimitConfig{ LoginRateLimit: defaultLoginRateLimit, LoginMinPause: defaultLoginMinPause, LoginMaxPause: defaultLoginMaxPause, LoginRetryPause: defaultLoginRetryPause, ConnMinPause: defaultConnMinPause, ConnMaxPause: defaultConnMaxPause, ConnLookbackWindow: defaultConnLookbackWindow, ConnLowerThreshold: defaultConnLowerThreshold, ConnUpperThreshold: defaultConnUpperThreshold, } }
[ "func", "DefaultRateLimitConfig", "(", ")", "RateLimitConfig", "{", "return", "RateLimitConfig", "{", "LoginRateLimit", ":", "defaultLoginRateLimit", ",", "LoginMinPause", ":", "defaultLoginMinPause", ",", "LoginMaxPause", ":", "defaultLoginMaxPause", ",", "LoginRetryPause"...
// DefaultRateLimitConfig returns a RateLimtConfig struct with // all attributes set to their default values.
[ "DefaultRateLimitConfig", "returns", "a", "RateLimtConfig", "struct", "with", "all", "attributes", "set", "to", "their", "default", "values", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/config.go#L43-L55
155,371
juju/juju
apiserver/config.go
Validate
func (c RateLimitConfig) Validate() error { if c.LoginRateLimit <= 0 || c.LoginRateLimit > 100 { return errors.NotValidf("login-rate-limit %d <= 0 or > 100", c.LoginRateLimit) } if c.LoginMinPause < 0 || c.LoginMinPause > 100*time.Millisecond { return errors.NotValidf("login-min-pause %d < 0 or > 100ms", c.LoginMinPause) } if c.LoginMaxPause < 0 || c.LoginMaxPause > 5*time.Second { return errors.NotValidf("login-max-pause %d < 0 or > 5s", c.LoginMaxPause) } if c.LoginRetryPause < 0 || c.LoginRetryPause > 10*time.Second { return errors.NotValidf("login-retry-pause %d < 0 or > 10s", c.LoginRetryPause) } if c.ConnMinPause < 0 || c.ConnMinPause > 100*time.Millisecond { return errors.NotValidf("conn-min-pause %d < 0 or > 100ms", c.ConnMinPause) } if c.ConnMaxPause < 0 || c.ConnMaxPause > 10*time.Second { return errors.NotValidf("conn-max-pause %d < 0 or > 10s", c.ConnMaxPause) } if c.ConnLookbackWindow < 0 || c.ConnLookbackWindow > 5*time.Second { return errors.NotValidf("conn-lookback-window %d < 0 or > 5s", c.ConnMaxPause) } return nil }
go
func (c RateLimitConfig) Validate() error { if c.LoginRateLimit <= 0 || c.LoginRateLimit > 100 { return errors.NotValidf("login-rate-limit %d <= 0 or > 100", c.LoginRateLimit) } if c.LoginMinPause < 0 || c.LoginMinPause > 100*time.Millisecond { return errors.NotValidf("login-min-pause %d < 0 or > 100ms", c.LoginMinPause) } if c.LoginMaxPause < 0 || c.LoginMaxPause > 5*time.Second { return errors.NotValidf("login-max-pause %d < 0 or > 5s", c.LoginMaxPause) } if c.LoginRetryPause < 0 || c.LoginRetryPause > 10*time.Second { return errors.NotValidf("login-retry-pause %d < 0 or > 10s", c.LoginRetryPause) } if c.ConnMinPause < 0 || c.ConnMinPause > 100*time.Millisecond { return errors.NotValidf("conn-min-pause %d < 0 or > 100ms", c.ConnMinPause) } if c.ConnMaxPause < 0 || c.ConnMaxPause > 10*time.Second { return errors.NotValidf("conn-max-pause %d < 0 or > 10s", c.ConnMaxPause) } if c.ConnLookbackWindow < 0 || c.ConnLookbackWindow > 5*time.Second { return errors.NotValidf("conn-lookback-window %d < 0 or > 5s", c.ConnMaxPause) } return nil }
[ "func", "(", "c", "RateLimitConfig", ")", "Validate", "(", ")", "error", "{", "if", "c", ".", "LoginRateLimit", "<=", "0", "||", "c", ".", "LoginRateLimit", ">", "100", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ",", "c", ".", "Login...
// Validate validates the rate limit configuration. // We apply arbitrary but sensible upper limits to prevent // typos from introducing obviously bad config.
[ "Validate", "validates", "the", "rate", "limit", "configuration", ".", "We", "apply", "arbitrary", "but", "sensible", "upper", "limits", "to", "prevent", "typos", "from", "introducing", "obviously", "bad", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/config.go#L60-L83
155,372
juju/juju
apiserver/config.go
Validate
func (cfg LogSinkConfig) Validate() error { if cfg.DBLoggerBufferSize <= 0 || cfg.DBLoggerBufferSize > 1000 { return errors.NotValidf("DBLoggerBufferSize %d <= 0 or > 1000", cfg.DBLoggerBufferSize) } if cfg.DBLoggerFlushInterval <= 0 || cfg.DBLoggerFlushInterval > 10*time.Second { return errors.NotValidf("DBLoggerFlushInterval %s <= 0 or > 10 seconds", cfg.DBLoggerFlushInterval) } if cfg.RateLimitBurst <= 0 { return errors.NotValidf("RateLimitBurst %d <= 0", cfg.RateLimitBurst) } if cfg.RateLimitRefill <= 0 { return errors.NotValidf("RateLimitRefill %s <= 0", cfg.RateLimitRefill) } return nil }
go
func (cfg LogSinkConfig) Validate() error { if cfg.DBLoggerBufferSize <= 0 || cfg.DBLoggerBufferSize > 1000 { return errors.NotValidf("DBLoggerBufferSize %d <= 0 or > 1000", cfg.DBLoggerBufferSize) } if cfg.DBLoggerFlushInterval <= 0 || cfg.DBLoggerFlushInterval > 10*time.Second { return errors.NotValidf("DBLoggerFlushInterval %s <= 0 or > 10 seconds", cfg.DBLoggerFlushInterval) } if cfg.RateLimitBurst <= 0 { return errors.NotValidf("RateLimitBurst %d <= 0", cfg.RateLimitBurst) } if cfg.RateLimitRefill <= 0 { return errors.NotValidf("RateLimitRefill %s <= 0", cfg.RateLimitRefill) } return nil }
[ "func", "(", "cfg", "LogSinkConfig", ")", "Validate", "(", ")", "error", "{", "if", "cfg", ".", "DBLoggerBufferSize", "<=", "0", "||", "cfg", ".", "DBLoggerBufferSize", ">", "1000", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ",", "cfg", ...
// Validate validates the logsink endpoint configuration.
[ "Validate", "validates", "the", "logsink", "endpoint", "configuration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/config.go#L105-L119
155,373
juju/juju
apiserver/config.go
DefaultLogSinkConfig
func DefaultLogSinkConfig() LogSinkConfig { return LogSinkConfig{ DBLoggerBufferSize: defaultDBLoggerBufferSize, DBLoggerFlushInterval: defaultDBLoggerFlushInterval, RateLimitBurst: defaultLogSinkRateLimitBurst, RateLimitRefill: defaultLogSinkRateLimitRefill, } }
go
func DefaultLogSinkConfig() LogSinkConfig { return LogSinkConfig{ DBLoggerBufferSize: defaultDBLoggerBufferSize, DBLoggerFlushInterval: defaultDBLoggerFlushInterval, RateLimitBurst: defaultLogSinkRateLimitBurst, RateLimitRefill: defaultLogSinkRateLimitRefill, } }
[ "func", "DefaultLogSinkConfig", "(", ")", "LogSinkConfig", "{", "return", "LogSinkConfig", "{", "DBLoggerBufferSize", ":", "defaultDBLoggerBufferSize", ",", "DBLoggerFlushInterval", ":", "defaultDBLoggerFlushInterval", ",", "RateLimitBurst", ":", "defaultLogSinkRateLimitBurst",...
// DefaultLogSinkConfig returns a LogSinkConfig with default values.
[ "DefaultLogSinkConfig", "returns", "a", "LogSinkConfig", "with", "default", "values", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/config.go#L122-L129
155,374
juju/juju
worker/httpserverargs/manifold.go
Validate
func (config ManifoldConfig) Validate() error { if config.ClockName == "" { return errors.NotValidf("empty ClockName") } if config.ControllerPortName == "" { return errors.NotValidf("empty ControllerPortName") } if config.StateName == "" { return errors.NotValidf("empty StateName") } if config.NewStateAuthenticator == nil { return errors.NotValidf("nil NewStateAuthenticator") } return nil }
go
func (config ManifoldConfig) Validate() error { if config.ClockName == "" { return errors.NotValidf("empty ClockName") } if config.ControllerPortName == "" { return errors.NotValidf("empty ControllerPortName") } if config.StateName == "" { return errors.NotValidf("empty StateName") } if config.NewStateAuthenticator == nil { return errors.NotValidf("nil NewStateAuthenticator") } return nil }
[ "func", "(", "config", "ManifoldConfig", ")", "Validate", "(", ")", "error", "{", "if", "config", ".", "ClockName", "==", "\"", "\"", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "config", ".", "ControllerPort...
// Validate checks that we have all of the things we need.
[ "Validate", "checks", "that", "we", "have", "all", "of", "the", "things", "we", "need", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/httpserverargs/manifold.go#L31-L45
155,375
juju/juju
apiserver/apiserverhttp/mux.go
NewMux
func NewMux(opts ...muxOption) *Mux { m := &Mux{ p: pat.New(), added: make(map[string][]patternHandler), } for _, opt := range opts { opt(m) } return m }
go
func NewMux(opts ...muxOption) *Mux { m := &Mux{ p: pat.New(), added: make(map[string][]patternHandler), } for _, opt := range opts { opt(m) } return m }
[ "func", "NewMux", "(", "opts", "...", "muxOption", ")", "*", "Mux", "{", "m", ":=", "&", "Mux", "{", "p", ":", "pat", ".", "New", "(", ")", ",", "added", ":", "make", "(", "map", "[", "string", "]", "[", "]", "patternHandler", ")", ",", "}", ...
// NewMux returns a new, empty mux.
[ "NewMux", "returns", "a", "new", "empty", "mux", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/apiserverhttp/mux.go#L46-L55
155,376
juju/juju
apiserver/apiserverhttp/mux.go
AddHandler
func (m *Mux) AddHandler(meth, pat string, h http.Handler) error { m.mu.Lock() defer m.mu.Unlock() for _, ph := range m.added[meth] { if ph.pat == pat { return errors.AlreadyExistsf("handler for %s %q", meth, pat) } } m.added[meth] = append(m.added[meth], patternHandler{pat, h}) m.recreate() return nil }
go
func (m *Mux) AddHandler(meth, pat string, h http.Handler) error { m.mu.Lock() defer m.mu.Unlock() for _, ph := range m.added[meth] { if ph.pat == pat { return errors.AlreadyExistsf("handler for %s %q", meth, pat) } } m.added[meth] = append(m.added[meth], patternHandler{pat, h}) m.recreate() return nil }
[ "func", "(", "m", "*", "Mux", ")", "AddHandler", "(", "meth", ",", "pat", "string", ",", "h", "http", ".", "Handler", ")", "error", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "Unlock", "(", ")", "\n", "for...
// AddHandler adds an http.Handler for the given method and pattern. // AddHandler returns an error if there already exists a handler for // the method and pattern. // // This is safe to call concurrently with m.ServeHTTP and m.RemoveHandler.
[ "AddHandler", "adds", "an", "http", ".", "Handler", "for", "the", "given", "method", "and", "pattern", ".", "AddHandler", "returns", "an", "error", "if", "there", "already", "exists", "a", "handler", "for", "the", "method", "and", "pattern", ".", "This", "...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/apiserverhttp/mux.go#L75-L86
155,377
juju/juju
apiserver/apiserverhttp/mux.go
RemoveHandler
func (m *Mux) RemoveHandler(meth, pat string) { m.mu.Lock() defer m.mu.Unlock() phs, ok := m.added[meth] if !ok { return } for i, ph := range phs { if ph.pat != pat { continue } head, tail := phs[:i], phs[i+1:] m.added[meth] = append(head, tail...) m.recreate() return } }
go
func (m *Mux) RemoveHandler(meth, pat string) { m.mu.Lock() defer m.mu.Unlock() phs, ok := m.added[meth] if !ok { return } for i, ph := range phs { if ph.pat != pat { continue } head, tail := phs[:i], phs[i+1:] m.added[meth] = append(head, tail...) m.recreate() return } }
[ "func", "(", "m", "*", "Mux", ")", "RemoveHandler", "(", "meth", ",", "pat", "string", ")", "{", "m", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "mu", ".", "Unlock", "(", ")", "\n", "phs", ",", "ok", ":=", "m", ".", "added", ...
// RemoveHandler removes the http.Handler for the given method and pattern, // if any. If there is no handler registered with the method and pattern, // this is a no-op. // // This is safe to call concurrently with m.ServeHTTP and m.AddHandler.
[ "RemoveHandler", "removes", "the", "http", ".", "Handler", "for", "the", "given", "method", "and", "pattern", "if", "any", ".", "If", "there", "is", "no", "handler", "registered", "with", "the", "method", "and", "pattern", "this", "is", "a", "no", "-", "...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/apiserverhttp/mux.go#L93-L109
155,378
juju/juju
core/network/portrange.go
Validate
func (p PortRange) Validate() error { proto := strings.ToLower(p.Protocol) if proto != "tcp" && proto != "udp" && proto != "icmp" { return errors.Errorf(`invalid protocol %q, expected "tcp", "udp", or "icmp"`, proto) } if proto == "icmp" { if p.FromPort == p.ToPort && p.FromPort == -1 { return nil } return errors.Errorf(`protocol "icmp" doesn't support any ports; got "%v"`, p.FromPort) } err := errors.Errorf( "invalid port range %d-%d/%s", p.FromPort, p.ToPort, p.Protocol, ) switch { case p.FromPort > p.ToPort: return err case p.FromPort < 1 || p.FromPort > 65535: return err case p.ToPort < 1 || p.ToPort > 65535: return err } return nil }
go
func (p PortRange) Validate() error { proto := strings.ToLower(p.Protocol) if proto != "tcp" && proto != "udp" && proto != "icmp" { return errors.Errorf(`invalid protocol %q, expected "tcp", "udp", or "icmp"`, proto) } if proto == "icmp" { if p.FromPort == p.ToPort && p.FromPort == -1 { return nil } return errors.Errorf(`protocol "icmp" doesn't support any ports; got "%v"`, p.FromPort) } err := errors.Errorf( "invalid port range %d-%d/%s", p.FromPort, p.ToPort, p.Protocol, ) switch { case p.FromPort > p.ToPort: return err case p.FromPort < 1 || p.FromPort > 65535: return err case p.ToPort < 1 || p.ToPort > 65535: return err } return nil }
[ "func", "(", "p", "PortRange", ")", "Validate", "(", ")", "error", "{", "proto", ":=", "strings", ".", "ToLower", "(", "p", ".", "Protocol", ")", "\n", "if", "proto", "!=", "\"", "\"", "&&", "proto", "!=", "\"", "\"", "&&", "proto", "!=", "\"", "...
// IsValid determines if the port range is valid.
[ "IsValid", "determines", "if", "the", "port", "range", "is", "valid", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/network/portrange.go#L23-L49
155,379
juju/juju
core/network/portrange.go
ConflictsWith
func (a PortRange) ConflictsWith(b PortRange) bool { if a.Protocol != b.Protocol { return false } return a.ToPort >= b.FromPort && b.ToPort >= a.FromPort }
go
func (a PortRange) ConflictsWith(b PortRange) bool { if a.Protocol != b.Protocol { return false } return a.ToPort >= b.FromPort && b.ToPort >= a.FromPort }
[ "func", "(", "a", "PortRange", ")", "ConflictsWith", "(", "b", "PortRange", ")", "bool", "{", "if", "a", ".", "Protocol", "!=", "b", ".", "Protocol", "{", "return", "false", "\n", "}", "\n", "return", "a", ".", "ToPort", ">=", "b", ".", "FromPort", ...
// ConflictsWith determines if the two port ranges conflict.
[ "ConflictsWith", "determines", "if", "the", "two", "port", "ranges", "conflict", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/network/portrange.go#L52-L57
155,380
juju/juju
core/network/portrange.go
MustParsePortRange
func MustParsePortRange(portRange string) PortRange { portrange, err := ParsePortRange(portRange) if err != nil { panic(err) } return portrange }
go
func MustParsePortRange(portRange string) PortRange { portrange, err := ParsePortRange(portRange) if err != nil { panic(err) } return portrange }
[ "func", "MustParsePortRange", "(", "portRange", "string", ")", "PortRange", "{", "portrange", ",", "err", ":=", "ParsePortRange", "(", "portRange", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "portrange", ...
// MustParsePortRange converts a raw port-range string into a PortRange. // If the string is invalid, the function panics.
[ "MustParsePortRange", "converts", "a", "raw", "port", "-", "range", "string", "into", "a", "PortRange", ".", "If", "the", "string", "is", "invalid", "the", "function", "panics", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/network/portrange.go#L173-L179
155,381
juju/juju
apiserver/common/crossmodel/auth.go
NewAuthContext
func NewAuthContext( pool StatePool, localOfferThirdPartyBakeryService authentication.BakeryService, localOfferBakeryService authentication.ExpirableStorageBakeryService, ) (*AuthContext, error) { ctxt := &AuthContext{ pool: pool, clock: clock.WallClock, localOfferBakeryService: localOfferBakeryService, localOfferThirdPartyBakeryService: localOfferThirdPartyBakeryService, } return ctxt, nil }
go
func NewAuthContext( pool StatePool, localOfferThirdPartyBakeryService authentication.BakeryService, localOfferBakeryService authentication.ExpirableStorageBakeryService, ) (*AuthContext, error) { ctxt := &AuthContext{ pool: pool, clock: clock.WallClock, localOfferBakeryService: localOfferBakeryService, localOfferThirdPartyBakeryService: localOfferThirdPartyBakeryService, } return ctxt, nil }
[ "func", "NewAuthContext", "(", "pool", "StatePool", ",", "localOfferThirdPartyBakeryService", "authentication", ".", "BakeryService", ",", "localOfferBakeryService", "authentication", ".", "ExpirableStorageBakeryService", ",", ")", "(", "*", "AuthContext", ",", "error", "...
// NewAuthContext creates a new authentication context for checking // macaroons used with application offer requests.
[ "NewAuthContext", "creates", "a", "new", "authentication", "context", "for", "checking", "macaroons", "used", "with", "application", "offer", "requests", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/crossmodel/auth.go#L54-L66
155,382
juju/juju
apiserver/common/crossmodel/auth.go
WithClock
func (a *AuthContext) WithClock(clock clock.Clock) *AuthContext { ctxtCopy := *a ctxtCopy.clock = clock return &ctxtCopy }
go
func (a *AuthContext) WithClock(clock clock.Clock) *AuthContext { ctxtCopy := *a ctxtCopy.clock = clock return &ctxtCopy }
[ "func", "(", "a", "*", "AuthContext", ")", "WithClock", "(", "clock", "clock", ".", "Clock", ")", "*", "AuthContext", "{", "ctxtCopy", ":=", "*", "a", "\n", "ctxtCopy", ".", "clock", "=", "clock", "\n", "return", "&", "ctxtCopy", "\n", "}" ]
// WithClock creates a new authentication context // using the specified clock.
[ "WithClock", "creates", "a", "new", "authentication", "context", "using", "the", "specified", "clock", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/crossmodel/auth.go#L70-L74
155,383
juju/juju
apiserver/common/crossmodel/auth.go
WithDischargeURL
func (a *AuthContext) WithDischargeURL(offerAccessEndpoint string) *AuthContext { ctxtCopy := *a ctxtCopy.offerAccessEndpoint = offerAccessEndpoint return &ctxtCopy }
go
func (a *AuthContext) WithDischargeURL(offerAccessEndpoint string) *AuthContext { ctxtCopy := *a ctxtCopy.offerAccessEndpoint = offerAccessEndpoint return &ctxtCopy }
[ "func", "(", "a", "*", "AuthContext", ")", "WithDischargeURL", "(", "offerAccessEndpoint", "string", ")", "*", "AuthContext", "{", "ctxtCopy", ":=", "*", "a", "\n", "ctxtCopy", ".", "offerAccessEndpoint", "=", "offerAccessEndpoint", "\n", "return", "&", "ctxtCop...
// WithDischargeURL create an auth context based on this context and used // to perform third party discharges at the specified URL.
[ "WithDischargeURL", "create", "an", "auth", "context", "based", "on", "this", "context", "and", "used", "to", "perform", "third", "party", "discharges", "at", "the", "specified", "URL", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/crossmodel/auth.go#L78-L82
155,384
juju/juju
apiserver/common/crossmodel/auth.go
CheckOfferAccessCaveat
func (a *AuthContext) CheckOfferAccessCaveat(caveat string) (*offerPermissionCheck, error) { op, rest, err := checkers.ParseCaveat(caveat) if err != nil { return nil, errors.Annotatef(err, "cannot parse caveat %q", caveat) } if op != offerPermissionCaveat { return nil, checkers.ErrCaveatNotRecognized } var details offerPermissionCheck err = yaml.Unmarshal([]byte(rest), &details) if err != nil { return nil, errors.Trace(err) } logger.Debugf("offer access caveat details: %+v", details) if !names.IsValidModel(details.SourceModelUUID) { return nil, errors.NotValidf("source-model-uuid %q", details.SourceModelUUID) } if !names.IsValidUser(details.User) { return nil, errors.NotValidf("username %q", details.User) } if err := permission.ValidateOfferAccess(permission.Access(details.Permission)); err != nil { return nil, errors.NotValidf("permission %q", details.Permission) } return &details, nil }
go
func (a *AuthContext) CheckOfferAccessCaveat(caveat string) (*offerPermissionCheck, error) { op, rest, err := checkers.ParseCaveat(caveat) if err != nil { return nil, errors.Annotatef(err, "cannot parse caveat %q", caveat) } if op != offerPermissionCaveat { return nil, checkers.ErrCaveatNotRecognized } var details offerPermissionCheck err = yaml.Unmarshal([]byte(rest), &details) if err != nil { return nil, errors.Trace(err) } logger.Debugf("offer access caveat details: %+v", details) if !names.IsValidModel(details.SourceModelUUID) { return nil, errors.NotValidf("source-model-uuid %q", details.SourceModelUUID) } if !names.IsValidUser(details.User) { return nil, errors.NotValidf("username %q", details.User) } if err := permission.ValidateOfferAccess(permission.Access(details.Permission)); err != nil { return nil, errors.NotValidf("permission %q", details.Permission) } return &details, nil }
[ "func", "(", "a", "*", "AuthContext", ")", "CheckOfferAccessCaveat", "(", "caveat", "string", ")", "(", "*", "offerPermissionCheck", ",", "error", ")", "{", "op", ",", "rest", ",", "err", ":=", "checkers", ".", "ParseCaveat", "(", "caveat", ")", "\n", "i...
// CheckOfferAccessCaveat checks that the specified caveat required to be satisfied // to gain access to an offer is valid, and returns the attributes return to check // that the caveat is satisfied.
[ "CheckOfferAccessCaveat", "checks", "that", "the", "specified", "caveat", "required", "to", "be", "satisfied", "to", "gain", "access", "to", "an", "offer", "is", "valid", "and", "returns", "the", "attributes", "return", "to", "check", "that", "the", "caveat", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/crossmodel/auth.go#L92-L116
155,385
juju/juju
apiserver/common/crossmodel/auth.go
CreateConsumeOfferMacaroon
func (a *AuthContext) CreateConsumeOfferMacaroon(offer *params.ApplicationOfferDetails, username string) (*macaroon.Macaroon, error) { sourceModelTag, err := names.ParseModelTag(offer.SourceModelTag) if err != nil { return nil, errors.Trace(err) } expiryTime := a.clock.Now().Add(localOfferPermissionExpiryTime) bakery, err := a.localOfferBakeryService.ExpireStorageAfter(localOfferPermissionExpiryTime) if err != nil { return nil, errors.Trace(err) } return bakery.NewMacaroon( []checkers.Caveat{ checkers.TimeBeforeCaveat(expiryTime), checkers.DeclaredCaveat(sourcemodelKey, sourceModelTag.Id()), checkers.DeclaredCaveat(offeruuidKey, offer.OfferUUID), checkers.DeclaredCaveat(usernameKey, username), }) }
go
func (a *AuthContext) CreateConsumeOfferMacaroon(offer *params.ApplicationOfferDetails, username string) (*macaroon.Macaroon, error) { sourceModelTag, err := names.ParseModelTag(offer.SourceModelTag) if err != nil { return nil, errors.Trace(err) } expiryTime := a.clock.Now().Add(localOfferPermissionExpiryTime) bakery, err := a.localOfferBakeryService.ExpireStorageAfter(localOfferPermissionExpiryTime) if err != nil { return nil, errors.Trace(err) } return bakery.NewMacaroon( []checkers.Caveat{ checkers.TimeBeforeCaveat(expiryTime), checkers.DeclaredCaveat(sourcemodelKey, sourceModelTag.Id()), checkers.DeclaredCaveat(offeruuidKey, offer.OfferUUID), checkers.DeclaredCaveat(usernameKey, username), }) }
[ "func", "(", "a", "*", "AuthContext", ")", "CreateConsumeOfferMacaroon", "(", "offer", "*", "params", ".", "ApplicationOfferDetails", ",", "username", "string", ")", "(", "*", "macaroon", ".", "Macaroon", ",", "error", ")", "{", "sourceModelTag", ",", "err", ...
// CreateConsumeOfferMacaroon creates a macaroon that authorises access to the specified offer.
[ "CreateConsumeOfferMacaroon", "creates", "a", "macaroon", "that", "authorises", "access", "to", "the", "specified", "offer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/crossmodel/auth.go#L203-L222
155,386
juju/juju
apiserver/common/crossmodel/auth.go
CreateRemoteRelationMacaroon
func (a *AuthContext) CreateRemoteRelationMacaroon(sourceModelUUID, offerUUID string, username string, rel names.Tag) (*macaroon.Macaroon, error) { expiryTime := a.clock.Now().Add(localOfferPermissionExpiryTime) bakery, err := a.localOfferBakeryService.ExpireStorageAfter(localOfferPermissionExpiryTime) if err != nil { return nil, errors.Trace(err) } offerMacaroon, err := bakery.NewMacaroon( []checkers.Caveat{ checkers.TimeBeforeCaveat(expiryTime), checkers.DeclaredCaveat(sourcemodelKey, sourceModelUUID), checkers.DeclaredCaveat(offeruuidKey, offerUUID), checkers.DeclaredCaveat(usernameKey, username), checkers.DeclaredCaveat(relationKey, rel.Id()), }) return offerMacaroon, err }
go
func (a *AuthContext) CreateRemoteRelationMacaroon(sourceModelUUID, offerUUID string, username string, rel names.Tag) (*macaroon.Macaroon, error) { expiryTime := a.clock.Now().Add(localOfferPermissionExpiryTime) bakery, err := a.localOfferBakeryService.ExpireStorageAfter(localOfferPermissionExpiryTime) if err != nil { return nil, errors.Trace(err) } offerMacaroon, err := bakery.NewMacaroon( []checkers.Caveat{ checkers.TimeBeforeCaveat(expiryTime), checkers.DeclaredCaveat(sourcemodelKey, sourceModelUUID), checkers.DeclaredCaveat(offeruuidKey, offerUUID), checkers.DeclaredCaveat(usernameKey, username), checkers.DeclaredCaveat(relationKey, rel.Id()), }) return offerMacaroon, err }
[ "func", "(", "a", "*", "AuthContext", ")", "CreateRemoteRelationMacaroon", "(", "sourceModelUUID", ",", "offerUUID", "string", ",", "username", "string", ",", "rel", "names", ".", "Tag", ")", "(", "*", "macaroon", ".", "Macaroon", ",", "error", ")", "{", "...
// CreateRemoteRelationMacaroon creates a macaroon that authorises access to the specified relation.
[ "CreateRemoteRelationMacaroon", "creates", "a", "macaroon", "that", "authorises", "access", "to", "the", "specified", "relation", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/crossmodel/auth.go#L225-L242
155,387
juju/juju
apiserver/common/crossmodel/auth.go
Authenticator
func (a *AuthContext) Authenticator(sourceModelUUID, offerUUID string) *authenticator { auth := &authenticator{ clock: a.clock, bakery: a.localOfferBakeryService, ctxt: a, sourceModelUUID: sourceModelUUID, offerUUID: offerUUID, offerAccessEndpoint: a.offerAccessEndpoint, } return auth }
go
func (a *AuthContext) Authenticator(sourceModelUUID, offerUUID string) *authenticator { auth := &authenticator{ clock: a.clock, bakery: a.localOfferBakeryService, ctxt: a, sourceModelUUID: sourceModelUUID, offerUUID: offerUUID, offerAccessEndpoint: a.offerAccessEndpoint, } return auth }
[ "func", "(", "a", "*", "AuthContext", ")", "Authenticator", "(", "sourceModelUUID", ",", "offerUUID", "string", ")", "*", "authenticator", "{", "auth", ":=", "&", "authenticator", "{", "clock", ":", "a", ".", "clock", ",", "bakery", ":", "a", ".", "local...
// Authenticator returns an instance used to authenticate macaroons used to // access the specified offer.
[ "Authenticator", "returns", "an", "instance", "used", "to", "authenticate", "macaroons", "used", "to", "access", "the", "specified", "offer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/crossmodel/auth.go#L267-L277
155,388
juju/juju
apiserver/common/crossmodel/auth.go
CheckOfferMacaroons
func (a *authenticator) CheckOfferMacaroons(offerUUID string, mac macaroon.Slice) (map[string]string, error) { requiredValues := map[string]string{ sourcemodelKey: a.sourceModelUUID, offeruuidKey: offerUUID, } return a.checkMacaroons(mac, requiredValues) }
go
func (a *authenticator) CheckOfferMacaroons(offerUUID string, mac macaroon.Slice) (map[string]string, error) { requiredValues := map[string]string{ sourcemodelKey: a.sourceModelUUID, offeruuidKey: offerUUID, } return a.checkMacaroons(mac, requiredValues) }
[ "func", "(", "a", "*", "authenticator", ")", "CheckOfferMacaroons", "(", "offerUUID", "string", ",", "mac", "macaroon", ".", "Slice", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "requiredValues", ":=", "map", "[", "string", "]"...
// CheckOfferMacaroons verifies that the specified macaroons allow access to the offer.
[ "CheckOfferMacaroons", "verifies", "that", "the", "specified", "macaroons", "allow", "access", "to", "the", "offer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/crossmodel/auth.go#L341-L347
155,389
juju/juju
apiserver/common/crossmodel/auth.go
CheckRelationMacaroons
func (a *authenticator) CheckRelationMacaroons(relationTag names.Tag, mac macaroon.Slice) error { requiredValues := map[string]string{ sourcemodelKey: a.sourceModelUUID, relationKey: relationTag.Id(), } _, err := a.checkMacaroons(mac, requiredValues) return err }
go
func (a *authenticator) CheckRelationMacaroons(relationTag names.Tag, mac macaroon.Slice) error { requiredValues := map[string]string{ sourcemodelKey: a.sourceModelUUID, relationKey: relationTag.Id(), } _, err := a.checkMacaroons(mac, requiredValues) return err }
[ "func", "(", "a", "*", "authenticator", ")", "CheckRelationMacaroons", "(", "relationTag", "names", ".", "Tag", ",", "mac", "macaroon", ".", "Slice", ")", "error", "{", "requiredValues", ":=", "map", "[", "string", "]", "string", "{", "sourcemodelKey", ":", ...
// CheckRelationMacaroons verifies that the specified macaroons allow access to the relation.
[ "CheckRelationMacaroons", "verifies", "that", "the", "specified", "macaroons", "allow", "access", "to", "the", "relation", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/crossmodel/auth.go#L350-L357
155,390
juju/juju
upgrades/steps_26.go
stateStepsFor26
func stateStepsFor26() []Step { return []Step{ &upgradeStep{ description: "update k8s storage config", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().UpdateKubernetesStorageConfig() }, }, &upgradeStep{ description: "remove instanceCharmProfileData collection", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().RemoveInstanceCharmProfileDataCollection() }, }, } }
go
func stateStepsFor26() []Step { return []Step{ &upgradeStep{ description: "update k8s storage config", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().UpdateKubernetesStorageConfig() }, }, &upgradeStep{ description: "remove instanceCharmProfileData collection", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().RemoveInstanceCharmProfileDataCollection() }, }, } }
[ "func", "stateStepsFor26", "(", ")", "[", "]", "Step", "{", "return", "[", "]", "Step", "{", "&", "upgradeStep", "{", "description", ":", "\"", "\"", ",", "targets", ":", "[", "]", "Target", "{", "DatabaseMaster", "}", ",", "run", ":", "func", "(", ...
// stateStepsFor26 returns upgrade steps for Juju 2.6 that manipulate state directly.
[ "stateStepsFor26", "returns", "upgrade", "steps", "for", "Juju", "2", ".", "6", "that", "manipulate", "state", "directly", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/upgrades/steps_26.go#L7-L24
155,391
juju/juju
apiserver/common/credentialcommon/cloudcredential.go
InvalidateModelCredential
func (api *CredentialManagerAPI) InvalidateModelCredential(args params.InvalidateCredentialArg) (params.ErrorResult, error) { err := api.backend.InvalidateModelCredential(args.Reason) if err != nil { return params.ErrorResult{Error: common.ServerError(err)}, nil } return params.ErrorResult{}, nil }
go
func (api *CredentialManagerAPI) InvalidateModelCredential(args params.InvalidateCredentialArg) (params.ErrorResult, error) { err := api.backend.InvalidateModelCredential(args.Reason) if err != nil { return params.ErrorResult{Error: common.ServerError(err)}, nil } return params.ErrorResult{}, nil }
[ "func", "(", "api", "*", "CredentialManagerAPI", ")", "InvalidateModelCredential", "(", "args", "params", ".", "InvalidateCredentialArg", ")", "(", "params", ".", "ErrorResult", ",", "error", ")", "{", "err", ":=", "api", ".", "backend", ".", "InvalidateModelCre...
// InvalidateModelCredential marks the cloud credential for this model as invalid.
[ "InvalidateModelCredential", "marks", "the", "cloud", "credential", "for", "this", "model", "as", "invalid", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/credentialcommon/cloudcredential.go#L26-L32
155,392
juju/juju
api/imagemanager/client.go
ListImages
func (c *Client) ListImages(kind, series, arch string) ([]params.ImageMetadata, error) { p := params.ImageFilterParams{ Images: []params.ImageSpec{ {Kind: kind, Series: series, Arch: arch}, }, } var result params.ListImageResult err := c.facade.FacadeCall("ListImages", p, &result) return result.Result, err }
go
func (c *Client) ListImages(kind, series, arch string) ([]params.ImageMetadata, error) { p := params.ImageFilterParams{ Images: []params.ImageSpec{ {Kind: kind, Series: series, Arch: arch}, }, } var result params.ListImageResult err := c.facade.FacadeCall("ListImages", p, &result) return result.Result, err }
[ "func", "(", "c", "*", "Client", ")", "ListImages", "(", "kind", ",", "series", ",", "arch", "string", ")", "(", "[", "]", "params", ".", "ImageMetadata", ",", "error", ")", "{", "p", ":=", "params", ".", "ImageFilterParams", "{", "Images", ":", "[",...
// ListImages returns the images.
[ "ListImages", "returns", "the", "images", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/imagemanager/client.go#L24-L33
155,393
juju/juju
api/imagemanager/client.go
DeleteImage
func (c *Client) DeleteImage(kind, series, arch string) error { p := params.ImageFilterParams{ Images: []params.ImageSpec{ {Kind: kind, Series: series, Arch: arch}, }, } results := new(params.ErrorResults) err := c.facade.FacadeCall("DeleteImages", p, results) if err != nil { return err } return results.OneError() }
go
func (c *Client) DeleteImage(kind, series, arch string) error { p := params.ImageFilterParams{ Images: []params.ImageSpec{ {Kind: kind, Series: series, Arch: arch}, }, } results := new(params.ErrorResults) err := c.facade.FacadeCall("DeleteImages", p, results) if err != nil { return err } return results.OneError() }
[ "func", "(", "c", "*", "Client", ")", "DeleteImage", "(", "kind", ",", "series", ",", "arch", "string", ")", "error", "{", "p", ":=", "params", ".", "ImageFilterParams", "{", "Images", ":", "[", "]", "params", ".", "ImageSpec", "{", "{", "Kind", ":",...
// DeleteImage deletes the specified image.
[ "DeleteImage", "deletes", "the", "specified", "image", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/imagemanager/client.go#L36-L48
155,394
juju/juju
state/machine_linklayerdevices.go
AllLinkLayerDevices
func (m *Machine) AllLinkLayerDevices() ([]*LinkLayerDevice, error) { var allDevices []*LinkLayerDevice callbackFunc := func(resultDoc *linkLayerDeviceDoc) { allDevices = append(allDevices, newLinkLayerDevice(m.st, *resultDoc)) } if err := m.forEachLinkLayerDeviceDoc(nil, callbackFunc); err != nil { return nil, errors.Trace(err) } return allDevices, nil }
go
func (m *Machine) AllLinkLayerDevices() ([]*LinkLayerDevice, error) { var allDevices []*LinkLayerDevice callbackFunc := func(resultDoc *linkLayerDeviceDoc) { allDevices = append(allDevices, newLinkLayerDevice(m.st, *resultDoc)) } if err := m.forEachLinkLayerDeviceDoc(nil, callbackFunc); err != nil { return nil, errors.Trace(err) } return allDevices, nil }
[ "func", "(", "m", "*", "Machine", ")", "AllLinkLayerDevices", "(", ")", "(", "[", "]", "*", "LinkLayerDevice", ",", "error", ")", "{", "var", "allDevices", "[", "]", "*", "LinkLayerDevice", "\n", "callbackFunc", ":=", "func", "(", "resultDoc", "*", "link...
// AllLinkLayerDevices returns all exiting link-layer devices of the machine.
[ "AllLinkLayerDevices", "returns", "all", "exiting", "link", "-", "layer", "devices", "of", "the", "machine", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/machine_linklayerdevices.go#L54-L64
155,395
juju/juju
state/machine_linklayerdevices.go
RemoveAllLinkLayerDevices
func (m *Machine) RemoveAllLinkLayerDevices() error { ops, err := m.removeAllLinkLayerDevicesOps() if err != nil { return errors.Trace(err) } return m.st.db().RunTransaction(ops) }
go
func (m *Machine) RemoveAllLinkLayerDevices() error { ops, err := m.removeAllLinkLayerDevicesOps() if err != nil { return errors.Trace(err) } return m.st.db().RunTransaction(ops) }
[ "func", "(", "m", "*", "Machine", ")", "RemoveAllLinkLayerDevices", "(", ")", "error", "{", "ops", ",", "err", ":=", "m", ".", "removeAllLinkLayerDevicesOps", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ...
// RemoveAllLinkLayerDevices removes all existing link-layer devices of the // machine in a single transaction. No error is returned when some or all of the // devices were already removed.
[ "RemoveAllLinkLayerDevices", "removes", "all", "existing", "link", "-", "layer", "devices", "of", "the", "machine", "in", "a", "single", "transaction", ".", "No", "error", "is", "returned", "when", "some", "or", "all", "of", "the", "devices", "were", "already"...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/machine_linklayerdevices.go#L105-L112
155,396
juju/juju
state/machine_linklayerdevices.go
RemoveAllAddresses
func (m *Machine) RemoveAllAddresses() error { ops, err := m.removeAllAddressesOps() if err != nil { return errors.Trace(err) } return m.st.db().RunTransaction(ops) }
go
func (m *Machine) RemoveAllAddresses() error { ops, err := m.removeAllAddressesOps() if err != nil { return errors.Trace(err) } return m.st.db().RunTransaction(ops) }
[ "func", "(", "m", "*", "Machine", ")", "RemoveAllAddresses", "(", ")", "error", "{", "ops", ",", "err", ":=", "m", ".", "removeAllAddressesOps", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", ...
// RemoveAllAddresses removes all assigned addresses to all devices of the // machine, in a single transaction. No error is returned when some or all of // the addresses were already removed.
[ "RemoveAllAddresses", "removes", "all", "assigned", "addresses", "to", "all", "devices", "of", "the", "machine", "in", "a", "single", "transaction", ".", "No", "error", "is", "returned", "when", "some", "or", "all", "of", "the", "addresses", "were", "already",...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/machine_linklayerdevices.go#L849-L856
155,397
juju/juju
state/machine_linklayerdevices.go
AllAddresses
func (m *Machine) AllAddresses() ([]*Address, error) { var allAddresses []*Address callbackFunc := func(resultDoc *ipAddressDoc) { allAddresses = append(allAddresses, newIPAddress(m.st, *resultDoc)) } findQuery := findAddressesQuery(m.doc.Id, "") if err := m.st.forEachIPAddressDoc(findQuery, callbackFunc); err != nil { return nil, errors.Trace(err) } return allAddresses, nil }
go
func (m *Machine) AllAddresses() ([]*Address, error) { var allAddresses []*Address callbackFunc := func(resultDoc *ipAddressDoc) { allAddresses = append(allAddresses, newIPAddress(m.st, *resultDoc)) } findQuery := findAddressesQuery(m.doc.Id, "") if err := m.st.forEachIPAddressDoc(findQuery, callbackFunc); err != nil { return nil, errors.Trace(err) } return allAddresses, nil }
[ "func", "(", "m", "*", "Machine", ")", "AllAddresses", "(", ")", "(", "[", "]", "*", "Address", ",", "error", ")", "{", "var", "allAddresses", "[", "]", "*", "Address", "\n", "callbackFunc", ":=", "func", "(", "resultDoc", "*", "ipAddressDoc", ")", "...
// AllAddresses returns the all addresses assigned to all devices of the // machine.
[ "AllAddresses", "returns", "the", "all", "addresses", "assigned", "to", "all", "devices", "of", "the", "machine", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/machine_linklayerdevices.go#L865-L876
155,398
juju/juju
state/machine_linklayerdevices.go
AllSpaces
func (m *Machine) AllSpaces() (set.Strings, error) { // TODO(jam): 2016-12-18 This should evolve to look at the // LinkLayerDevices directly, instead of using the Addresses the devices // are in to link back to spaces. spaces := set.NewStrings() addresses, err := m.AllAddresses() if err != nil { return nil, errors.Trace(err) } for _, address := range addresses { subnet, err := address.Subnet() if err != nil { if errors.IsNotFound(err) { // We don't know what this subnet is, so it can't be a space. It // might just be the loopback device. continue } return nil, errors.Trace(err) } spaceName := subnet.SpaceName() if spaceName != "" { spaces.Add(spaceName) } } logger.Tracef("machine %q found AllSpaces() = %s", m.Id(), network.QuoteSpaceSet(spaces)) return spaces, nil }
go
func (m *Machine) AllSpaces() (set.Strings, error) { // TODO(jam): 2016-12-18 This should evolve to look at the // LinkLayerDevices directly, instead of using the Addresses the devices // are in to link back to spaces. spaces := set.NewStrings() addresses, err := m.AllAddresses() if err != nil { return nil, errors.Trace(err) } for _, address := range addresses { subnet, err := address.Subnet() if err != nil { if errors.IsNotFound(err) { // We don't know what this subnet is, so it can't be a space. It // might just be the loopback device. continue } return nil, errors.Trace(err) } spaceName := subnet.SpaceName() if spaceName != "" { spaces.Add(spaceName) } } logger.Tracef("machine %q found AllSpaces() = %s", m.Id(), network.QuoteSpaceSet(spaces)) return spaces, nil }
[ "func", "(", "m", "*", "Machine", ")", "AllSpaces", "(", ")", "(", "set", ".", "Strings", ",", "error", ")", "{", "// TODO(jam): 2016-12-18 This should evolve to look at the", "// LinkLayerDevices directly, instead of using the Addresses the devices", "// are in to link back to...
// AllSpaces returns the set of spaces that this machine is actively // connected to.
[ "AllSpaces", "returns", "the", "set", "of", "spaces", "that", "this", "machine", "is", "actively", "connected", "to", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/machine_linklayerdevices.go#L880-L907
155,399
juju/juju
state/machine_linklayerdevices.go
deviceMapToSortedList
func deviceMapToSortedList(deviceMap map[string]*LinkLayerDevice) []*LinkLayerDevice { names := make([]string, 0, len(deviceMap)) for name := range deviceMap { // name must == device.Name() names = append(names, name) } sortedNames := network.NaturallySortDeviceNames(names...) result := make([]*LinkLayerDevice, len(sortedNames)) for i, name := range sortedNames { result[i] = deviceMap[name] } return result }
go
func deviceMapToSortedList(deviceMap map[string]*LinkLayerDevice) []*LinkLayerDevice { names := make([]string, 0, len(deviceMap)) for name := range deviceMap { // name must == device.Name() names = append(names, name) } sortedNames := network.NaturallySortDeviceNames(names...) result := make([]*LinkLayerDevice, len(sortedNames)) for i, name := range sortedNames { result[i] = deviceMap[name] } return result }
[ "func", "deviceMapToSortedList", "(", "deviceMap", "map", "[", "string", "]", "*", "LinkLayerDevice", ")", "[", "]", "*", "LinkLayerDevice", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "deviceMap", ")", ")", "\n", "f...
// deviceMapToSortedList takes a map from device name to LinkLayerDevice // object, and returns the list of LinkLayerDevice object using // NaturallySortDeviceNames
[ "deviceMapToSortedList", "takes", "a", "map", "from", "device", "name", "to", "LinkLayerDevice", "object", "and", "returns", "the", "list", "of", "LinkLayerDevice", "object", "using", "NaturallySortDeviceNames" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/machine_linklayerdevices.go#L929-L941