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
sequencelengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
sequencelengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
156,200
juju/juju
api/leadership/client.go
prepareClaimLeadership
func (c *client) prepareClaimLeadership(appId, unitId string, duration time.Duration) params.ClaimLeadershipParams { return params.ClaimLeadershipParams{ names.NewApplicationTag(appId).String(), names.NewUnitTag(unitId).String(), duration.Seconds(), } }
go
func (c *client) prepareClaimLeadership(appId, unitId string, duration time.Duration) params.ClaimLeadershipParams { return params.ClaimLeadershipParams{ names.NewApplicationTag(appId).String(), names.NewUnitTag(unitId).String(), duration.Seconds(), } }
[ "func", "(", "c", "*", "client", ")", "prepareClaimLeadership", "(", "appId", ",", "unitId", "string", ",", "duration", "time", ".", "Duration", ")", "params", ".", "ClaimLeadershipParams", "{", "return", "params", ".", "ClaimLeadershipParams", "{", "names", ".", "NewApplicationTag", "(", "appId", ")", ".", "String", "(", ")", ",", "names", ".", "NewUnitTag", "(", "unitId", ")", ".", "String", "(", ")", ",", "duration", ".", "Seconds", "(", ")", ",", "}", "\n", "}" ]
// // Prepare functions for building bulk-calls. // // prepareClaimLeadership creates a single set of params in // preparation for making a bulk call.
[ "Prepare", "functions", "for", "building", "bulk", "-", "calls", ".", "prepareClaimLeadership", "creates", "a", "single", "set", "of", "params", "in", "preparation", "for", "making", "a", "bulk", "call", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/leadership/client.go#L72-L78
156,201
juju/juju
api/action/pruner.go
NewFacade
func NewFacade(caller base.APICaller) *Facade { facadeCaller := base.NewFacadeCaller(caller, apiName) return &Facade{facade: facadeCaller, ModelWatcher: common.NewModelWatcher(facadeCaller)} }
go
func NewFacade(caller base.APICaller) *Facade { facadeCaller := base.NewFacadeCaller(caller, apiName) return &Facade{facade: facadeCaller, ModelWatcher: common.NewModelWatcher(facadeCaller)} }
[ "func", "NewFacade", "(", "caller", "base", ".", "APICaller", ")", "*", "Facade", "{", "facadeCaller", ":=", "base", ".", "NewFacadeCaller", "(", "caller", ",", "apiName", ")", "\n", "return", "&", "Facade", "{", "facade", ":", "facadeCaller", ",", "ModelWatcher", ":", "common", ".", "NewModelWatcher", "(", "facadeCaller", ")", "}", "\n", "}" ]
// NewFacade builds a facade for the action pruner endpoints
[ "NewFacade", "builds", "a", "facade", "for", "the", "action", "pruner", "endpoints" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/action/pruner.go#L23-L26
156,202
juju/juju
worker/raft/reporter.go
Report
func (w *Worker) Report() map[string]interface{} { out := make(map[string]interface{}) r, err := w.Raft() if err != nil { out[dependency.KeyError] = err.Error() return out } state := r.State() out[dependency.KeyState] = state.String() out["leader"] = r.Leader() out["index"] = map[string]interface{}{ "applied": r.AppliedIndex(), "last": r.LastIndex(), } if state != raft.Leader { lastContact := "never" if t := r.LastContact(); !t.IsZero() { lastContact = humanize.Time(t) } out["last-contact"] = lastContact } config := make(map[string]interface{}) future := r.GetConfiguration() if err := future.Error(); err != nil { config[dependency.KeyError] = err.Error() } else { servers := make(map[string]interface{}) for _, server := range future.Configuration().Servers { servers[string(server.ID)] = map[string]interface{}{ "suffrage": server.Suffrage.String(), "address": server.Address, } } config["servers"] = servers } out["cluster-config"] = config return out }
go
func (w *Worker) Report() map[string]interface{} { out := make(map[string]interface{}) r, err := w.Raft() if err != nil { out[dependency.KeyError] = err.Error() return out } state := r.State() out[dependency.KeyState] = state.String() out["leader"] = r.Leader() out["index"] = map[string]interface{}{ "applied": r.AppliedIndex(), "last": r.LastIndex(), } if state != raft.Leader { lastContact := "never" if t := r.LastContact(); !t.IsZero() { lastContact = humanize.Time(t) } out["last-contact"] = lastContact } config := make(map[string]interface{}) future := r.GetConfiguration() if err := future.Error(); err != nil { config[dependency.KeyError] = err.Error() } else { servers := make(map[string]interface{}) for _, server := range future.Configuration().Servers { servers[string(server.ID)] = map[string]interface{}{ "suffrage": server.Suffrage.String(), "address": server.Address, } } config["servers"] = servers } out["cluster-config"] = config return out }
[ "func", "(", "w", "*", "Worker", ")", "Report", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "out", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "r", ",", "err", ":=", "w", ".", "Raft", "(", ")", "\n", "if", "err", "!=", "nil", "{", "out", "[", "dependency", ".", "KeyError", "]", "=", "err", ".", "Error", "(", ")", "\n", "return", "out", "\n", "}", "\n\n", "state", ":=", "r", ".", "State", "(", ")", "\n", "out", "[", "dependency", ".", "KeyState", "]", "=", "state", ".", "String", "(", ")", "\n", "out", "[", "\"", "\"", "]", "=", "r", ".", "Leader", "(", ")", "\n", "out", "[", "\"", "\"", "]", "=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "r", ".", "AppliedIndex", "(", ")", ",", "\"", "\"", ":", "r", ".", "LastIndex", "(", ")", ",", "}", "\n", "if", "state", "!=", "raft", ".", "Leader", "{", "lastContact", ":=", "\"", "\"", "\n", "if", "t", ":=", "r", ".", "LastContact", "(", ")", ";", "!", "t", ".", "IsZero", "(", ")", "{", "lastContact", "=", "humanize", ".", "Time", "(", "t", ")", "\n", "}", "\n", "out", "[", "\"", "\"", "]", "=", "lastContact", "\n", "}", "\n\n", "config", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "future", ":=", "r", ".", "GetConfiguration", "(", ")", "\n", "if", "err", ":=", "future", ".", "Error", "(", ")", ";", "err", "!=", "nil", "{", "config", "[", "dependency", ".", "KeyError", "]", "=", "err", ".", "Error", "(", ")", "\n", "}", "else", "{", "servers", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "for", "_", ",", "server", ":=", "range", "future", ".", "Configuration", "(", ")", ".", "Servers", "{", "servers", "[", "string", "(", "server", ".", "ID", ")", "]", "=", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "server", ".", "Suffrage", ".", "String", "(", ")", ",", "\"", "\"", ":", "server", ".", "Address", ",", "}", "\n", "}", "\n", "config", "[", "\"", "\"", "]", "=", "servers", "\n", "}", "\n", "out", "[", "\"", "\"", "]", "=", "config", "\n\n", "return", "out", "\n", "}" ]
// Report is part of the dependency.Reporter interface.
[ "Report", "is", "part", "of", "the", "dependency", ".", "Reporter", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/raft/reporter.go#L13-L53
156,203
juju/juju
storage/poolmanager/poolmanager.go
New
func New(settings SettingsManager, registry storage.ProviderRegistry) PoolManager { return &poolManager{settings, registry} }
go
func New(settings SettingsManager, registry storage.ProviderRegistry) PoolManager { return &poolManager{settings, registry} }
[ "func", "New", "(", "settings", "SettingsManager", ",", "registry", "storage", ".", "ProviderRegistry", ")", "PoolManager", "{", "return", "&", "poolManager", "{", "settings", ",", "registry", "}", "\n", "}" ]
// New returns a PoolManager implementation using the specified state.
[ "New", "returns", "a", "PoolManager", "implementation", "using", "the", "specified", "state", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/poolmanager.go#L25-L27
156,204
juju/juju
storage/poolmanager/poolmanager.go
Create
func (pm *poolManager) Create(name string, providerType storage.ProviderType, attrs map[string]interface{}) (*storage.Config, error) { if name == "" { return nil, MissingNameError } if providerType == "" { return nil, MissingTypeError } cfg, err := pm.validatedConfig(name, providerType, attrs) if err != nil { return nil, errors.Trace(err) } poolAttrs := cfg.Attrs() poolAttrs[Name] = name poolAttrs[Type] = string(providerType) if err := pm.settings.CreateSettings(globalKey(name), poolAttrs); err != nil { return nil, errors.Annotatef(err, "creating pool %q", name) } return cfg, nil }
go
func (pm *poolManager) Create(name string, providerType storage.ProviderType, attrs map[string]interface{}) (*storage.Config, error) { if name == "" { return nil, MissingNameError } if providerType == "" { return nil, MissingTypeError } cfg, err := pm.validatedConfig(name, providerType, attrs) if err != nil { return nil, errors.Trace(err) } poolAttrs := cfg.Attrs() poolAttrs[Name] = name poolAttrs[Type] = string(providerType) if err := pm.settings.CreateSettings(globalKey(name), poolAttrs); err != nil { return nil, errors.Annotatef(err, "creating pool %q", name) } return cfg, nil }
[ "func", "(", "pm", "*", "poolManager", ")", "Create", "(", "name", "string", ",", "providerType", "storage", ".", "ProviderType", ",", "attrs", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "storage", ".", "Config", ",", "error", ")", "{", "if", "name", "==", "\"", "\"", "{", "return", "nil", ",", "MissingNameError", "\n", "}", "\n", "if", "providerType", "==", "\"", "\"", "{", "return", "nil", ",", "MissingTypeError", "\n", "}", "\n\n", "cfg", ",", "err", ":=", "pm", ".", "validatedConfig", "(", "name", ",", "providerType", ",", "attrs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "poolAttrs", ":=", "cfg", ".", "Attrs", "(", ")", "\n", "poolAttrs", "[", "Name", "]", "=", "name", "\n", "poolAttrs", "[", "Type", "]", "=", "string", "(", "providerType", ")", "\n", "if", "err", ":=", "pm", ".", "settings", ".", "CreateSettings", "(", "globalKey", "(", "name", ")", ",", "poolAttrs", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "return", "cfg", ",", "nil", "\n", "}" ]
// Create is defined on PoolManager interface.
[ "Create", "is", "defined", "on", "PoolManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/poolmanager.go#L43-L63
156,205
juju/juju
storage/poolmanager/poolmanager.go
Delete
func (pm *poolManager) Delete(name string) error { err := pm.settings.RemoveSettings(globalKey(name)) if err == nil || errors.IsNotFound(err) { return nil } return errors.Annotatef(err, "deleting pool %q", name) }
go
func (pm *poolManager) Delete(name string) error { err := pm.settings.RemoveSettings(globalKey(name)) if err == nil || errors.IsNotFound(err) { return nil } return errors.Annotatef(err, "deleting pool %q", name) }
[ "func", "(", "pm", "*", "poolManager", ")", "Delete", "(", "name", "string", ")", "error", "{", "err", ":=", "pm", ".", "settings", ".", "RemoveSettings", "(", "globalKey", "(", "name", ")", ")", "\n", "if", "err", "==", "nil", "||", "errors", ".", "IsNotFound", "(", "err", ")", "{", "return", "nil", "\n", "}", "\n", "return", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "name", ")", "\n", "}" ]
// Delete is defined on PoolManager interface.
[ "Delete", "is", "defined", "on", "PoolManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/poolmanager.go#L82-L88
156,206
juju/juju
storage/poolmanager/poolmanager.go
Replace
func (pm *poolManager) Replace(name, provider string, attrs map[string]interface{}) error { if name == "" { return MissingNameError } var providerType storage.ProviderType // Use the existing provider type unless explicitly overwritten. if provider != "" { providerType = storage.ProviderType(provider) } else { existingConfig, err := pm.Get(name) if err != nil { return errors.Trace(err) } providerType = existingConfig.Provider() } attrs[Type] = providerType attrs[Name] = name cfg, err := pm.validatedConfig(name, providerType, attrs) if err != nil { return errors.Trace(err) } validatedAttrs := cfg.Attrs() validatedAttrs[Name] = name validatedAttrs[Type] = string(providerType) return pm.settings.ReplaceSettings(globalKey(name), attrs) }
go
func (pm *poolManager) Replace(name, provider string, attrs map[string]interface{}) error { if name == "" { return MissingNameError } var providerType storage.ProviderType // Use the existing provider type unless explicitly overwritten. if provider != "" { providerType = storage.ProviderType(provider) } else { existingConfig, err := pm.Get(name) if err != nil { return errors.Trace(err) } providerType = existingConfig.Provider() } attrs[Type] = providerType attrs[Name] = name cfg, err := pm.validatedConfig(name, providerType, attrs) if err != nil { return errors.Trace(err) } validatedAttrs := cfg.Attrs() validatedAttrs[Name] = name validatedAttrs[Type] = string(providerType) return pm.settings.ReplaceSettings(globalKey(name), attrs) }
[ "func", "(", "pm", "*", "poolManager", ")", "Replace", "(", "name", ",", "provider", "string", ",", "attrs", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "if", "name", "==", "\"", "\"", "{", "return", "MissingNameError", "\n", "}", "\n", "var", "providerType", "storage", ".", "ProviderType", "\n", "// Use the existing provider type unless explicitly overwritten.", "if", "provider", "!=", "\"", "\"", "{", "providerType", "=", "storage", ".", "ProviderType", "(", "provider", ")", "\n", "}", "else", "{", "existingConfig", ",", "err", ":=", "pm", ".", "Get", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "providerType", "=", "existingConfig", ".", "Provider", "(", ")", "\n", "}", "\n", "attrs", "[", "Type", "]", "=", "providerType", "\n", "attrs", "[", "Name", "]", "=", "name", "\n", "cfg", ",", "err", ":=", "pm", ".", "validatedConfig", "(", "name", ",", "providerType", ",", "attrs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "validatedAttrs", ":=", "cfg", ".", "Attrs", "(", ")", "\n", "validatedAttrs", "[", "Name", "]", "=", "name", "\n", "validatedAttrs", "[", "Type", "]", "=", "string", "(", "providerType", ")", "\n", "return", "pm", ".", "settings", ".", "ReplaceSettings", "(", "globalKey", "(", "name", ")", ",", "attrs", ")", "\n", "}" ]
// Replace is defined on PoolManager interface.
[ "Replace", "is", "defined", "on", "PoolManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/poolmanager.go#L91-L116
156,207
juju/juju
storage/poolmanager/poolmanager.go
Get
func (pm *poolManager) Get(name string) (*storage.Config, error) { settings, err := pm.settings.ReadSettings(globalKey(name)) if err != nil { if errors.IsNotFound(err) { return nil, errors.NotFoundf("pool %q", name) } else { return nil, errors.Annotatef(err, "reading pool %q", name) } } return pm.configFromSettings(settings) }
go
func (pm *poolManager) Get(name string) (*storage.Config, error) { settings, err := pm.settings.ReadSettings(globalKey(name)) if err != nil { if errors.IsNotFound(err) { return nil, errors.NotFoundf("pool %q", name) } else { return nil, errors.Annotatef(err, "reading pool %q", name) } } return pm.configFromSettings(settings) }
[ "func", "(", "pm", "*", "poolManager", ")", "Get", "(", "name", "string", ")", "(", "*", "storage", ".", "Config", ",", "error", ")", "{", "settings", ",", "err", ":=", "pm", ".", "settings", ".", "ReadSettings", "(", "globalKey", "(", "name", ")", ")", "\n", "if", "err", "!=", "nil", "{", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "NotFoundf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "else", "{", "return", "nil", ",", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "name", ")", "\n", "}", "\n", "}", "\n", "return", "pm", ".", "configFromSettings", "(", "settings", ")", "\n", "}" ]
// Get is defined on PoolManager interface.
[ "Get", "is", "defined", "on", "PoolManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/poolmanager.go#L119-L129
156,208
juju/juju
storage/poolmanager/poolmanager.go
List
func (pm *poolManager) List() ([]*storage.Config, error) { settings, err := pm.settings.ListSettings(globalKeyPrefix) if err != nil { return nil, errors.Annotate(err, "listing pool settings") } var result []*storage.Config for _, attrs := range settings { cfg, err := pm.configFromSettings(attrs) if err != nil { return nil, errors.Trace(err) } result = append(result, cfg) } return result, nil }
go
func (pm *poolManager) List() ([]*storage.Config, error) { settings, err := pm.settings.ListSettings(globalKeyPrefix) if err != nil { return nil, errors.Annotate(err, "listing pool settings") } var result []*storage.Config for _, attrs := range settings { cfg, err := pm.configFromSettings(attrs) if err != nil { return nil, errors.Trace(err) } result = append(result, cfg) } return result, nil }
[ "func", "(", "pm", "*", "poolManager", ")", "List", "(", ")", "(", "[", "]", "*", "storage", ".", "Config", ",", "error", ")", "{", "settings", ",", "err", ":=", "pm", ".", "settings", ".", "ListSettings", "(", "globalKeyPrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "var", "result", "[", "]", "*", "storage", ".", "Config", "\n", "for", "_", ",", "attrs", ":=", "range", "settings", "{", "cfg", ",", "err", ":=", "pm", ".", "configFromSettings", "(", "attrs", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "result", "=", "append", "(", "result", ",", "cfg", ")", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// List is defined on PoolManager interface.
[ "List", "is", "defined", "on", "PoolManager", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/poolmanager/poolmanager.go#L132-L146
156,209
juju/juju
worker/migrationflag/worker.go
Validate
func (config Config) Validate() error { if config.Facade == nil { return errors.NotValidf("nil Facade") } if !utils.IsValidUUIDString(config.Model) { return errors.NotValidf("Model %q", config.Model) } if config.Check == nil { return errors.NotValidf("nil Check") } return nil }
go
func (config Config) Validate() error { if config.Facade == nil { return errors.NotValidf("nil Facade") } if !utils.IsValidUUIDString(config.Model) { return errors.NotValidf("Model %q", config.Model) } if config.Check == nil { return errors.NotValidf("nil Check") } return nil }
[ "func", "(", "config", "Config", ")", "Validate", "(", ")", "error", "{", "if", "config", ".", "Facade", "==", "nil", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "!", "utils", ".", "IsValidUUIDString", "(", "config", ".", "Model", ")", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ",", "config", ".", "Model", ")", "\n", "}", "\n", "if", "config", ".", "Check", "==", "nil", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate returns an error if the config cannot be expected to // drive a functional Worker.
[ "Validate", "returns", "an", "error", "if", "the", "config", "cannot", "be", "expected", "to", "drive", "a", "functional", "Worker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/migrationflag/worker.go#L43-L54
156,210
juju/juju
worker/migrationflag/worker.go
New
func New(config Config) (*Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } phase, err := config.Facade.Phase(config.Model) if err != nil { return nil, errors.Trace(err) } w := &Worker{ config: config, phase: phase, } err = catacomb.Invoke(catacomb.Plan{ Site: &w.catacomb, Work: w.loop, }) if err != nil { return nil, errors.Trace(err) } return w, nil }
go
func New(config Config) (*Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } phase, err := config.Facade.Phase(config.Model) if err != nil { return nil, errors.Trace(err) } w := &Worker{ config: config, phase: phase, } err = catacomb.Invoke(catacomb.Plan{ Site: &w.catacomb, Work: w.loop, }) if err != nil { return nil, errors.Trace(err) } return w, nil }
[ "func", "New", "(", "config", "Config", ")", "(", "*", "Worker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "phase", ",", "err", ":=", "config", ".", "Facade", ".", "Phase", "(", "config", ".", "Model", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "w", ":=", "&", "Worker", "{", "config", ":", "config", ",", "phase", ":", "phase", ",", "}", "\n", "err", "=", "catacomb", ".", "Invoke", "(", "catacomb", ".", "Plan", "{", "Site", ":", "&", "w", ".", "catacomb", ",", "Work", ":", "w", ".", "loop", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "w", ",", "nil", "\n", "}" ]
// New returns a Worker that tracks the result of the configured // Check on the Model's migration phase, as exposed by the Facade.
[ "New", "returns", "a", "Worker", "that", "tracks", "the", "result", "of", "the", "configured", "Check", "on", "the", "Model", "s", "migration", "phase", "as", "exposed", "by", "the", "Facade", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/migrationflag/worker.go#L58-L79
156,211
juju/juju
cmd/juju/romulus/sla/sla.go
NewSLACommand
func NewSLACommand() cmd.Command { slaCommand := &slaCommand{ newSLAClient: newSLAClient, newAuthorizationClient: newAuthorizationClient, } slaCommand.newAPIRoot = slaCommand.NewAPIRoot return modelcmd.Wrap(slaCommand) }
go
func NewSLACommand() cmd.Command { slaCommand := &slaCommand{ newSLAClient: newSLAClient, newAuthorizationClient: newAuthorizationClient, } slaCommand.newAPIRoot = slaCommand.NewAPIRoot return modelcmd.Wrap(slaCommand) }
[ "func", "NewSLACommand", "(", ")", "cmd", ".", "Command", "{", "slaCommand", ":=", "&", "slaCommand", "{", "newSLAClient", ":", "newSLAClient", ",", "newAuthorizationClient", ":", "newAuthorizationClient", ",", "}", "\n", "slaCommand", ".", "newAPIRoot", "=", "slaCommand", ".", "NewAPIRoot", "\n", "return", "modelcmd", ".", "Wrap", "(", "slaCommand", ")", "\n", "}" ]
// NewSLACommand returns a new command that is used to set SLA credentials for a // deployed application.
[ "NewSLACommand", "returns", "a", "new", "command", "that", "is", "used", "to", "set", "SLA", "credentials", "for", "a", "deployed", "application", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/romulus/sla/sla.go#L69-L76
156,212
juju/juju
cmd/juju/romulus/sla/sla.go
SetFlags
func (c *slaCommand) SetFlags(f *gnuflag.FlagSet) { c.ModelCommandBase.SetFlags(f) c.out.AddFlags(f, "tabular", map[string]cmd.Formatter{ "tabular": formatTabular, "json": cmd.FormatJson, "yaml": cmd.FormatYaml, }) f.StringVar(&c.Budget, "budget", "", "the maximum spend for the model") }
go
func (c *slaCommand) SetFlags(f *gnuflag.FlagSet) { c.ModelCommandBase.SetFlags(f) c.out.AddFlags(f, "tabular", map[string]cmd.Formatter{ "tabular": formatTabular, "json": cmd.FormatJson, "yaml": cmd.FormatYaml, }) f.StringVar(&c.Budget, "budget", "", "the maximum spend for the model") }
[ "func", "(", "c", "*", "slaCommand", ")", "SetFlags", "(", "f", "*", "gnuflag", ".", "FlagSet", ")", "{", "c", ".", "ModelCommandBase", ".", "SetFlags", "(", "f", ")", "\n", "c", ".", "out", ".", "AddFlags", "(", "f", ",", "\"", "\"", ",", "map", "[", "string", "]", "cmd", ".", "Formatter", "{", "\"", "\"", ":", "formatTabular", ",", "\"", "\"", ":", "cmd", ".", "FormatJson", ",", "\"", "\"", ":", "cmd", ".", "FormatYaml", ",", "}", ")", "\n", "f", ".", "StringVar", "(", "&", "c", ".", "Budget", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "}" ]
// SetFlags sets additional flags for the support command.
[ "SetFlags", "sets", "additional", "flags", "for", "the", "support", "command", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/romulus/sla/sla.go#L93-L101
156,213
juju/juju
worker/externalcontrollerupdater/manifold.go
Manifold
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{ config.APICallerName, }, Start: func(context dependency.Context) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } var apiCaller base.APICaller if err := context.Get(config.APICallerName, &apiCaller); err != nil { return nil, err } return manifoldStart(apiCaller, config.NewExternalControllerWatcherClient) }, } }
go
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{ config.APICallerName, }, Start: func(context dependency.Context) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } var apiCaller base.APICaller if err := context.Get(config.APICallerName, &apiCaller); err != nil { return nil, err } return manifoldStart(apiCaller, config.NewExternalControllerWatcherClient) }, } }
[ "func", "Manifold", "(", "config", "ManifoldConfig", ")", "dependency", ".", "Manifold", "{", "return", "dependency", ".", "Manifold", "{", "Inputs", ":", "[", "]", "string", "{", "config", ".", "APICallerName", ",", "}", ",", "Start", ":", "func", "(", "context", "dependency", ".", "Context", ")", "(", "worker", ".", "Worker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "var", "apiCaller", "base", ".", "APICaller", "\n", "if", "err", ":=", "context", ".", "Get", "(", "config", ".", "APICallerName", ",", "&", "apiCaller", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "manifoldStart", "(", "apiCaller", ",", "config", ".", "NewExternalControllerWatcherClient", ")", "\n", "}", ",", "}", "\n", "}" ]
// Manifold returns a Manifold that runs an externalcontrollerupdater worker.
[ "Manifold", "returns", "a", "Manifold", "that", "runs", "an", "externalcontrollerupdater", "worker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/externalcontrollerupdater/manifold.go#L36-L52
156,214
juju/juju
cmd/juju/application/register.go
SetFlags
func (r *RegisterMeteredCharm) SetFlags(f *gnuflag.FlagSet) { f.IntVar(&r.IncreaseBudget, "increase-budget", 0, "increase model budget allocation by this amount") f.StringVar(&r.Plan, "plan", "", "plan to deploy charm under") }
go
func (r *RegisterMeteredCharm) SetFlags(f *gnuflag.FlagSet) { f.IntVar(&r.IncreaseBudget, "increase-budget", 0, "increase model budget allocation by this amount") f.StringVar(&r.Plan, "plan", "", "plan to deploy charm under") }
[ "func", "(", "r", "*", "RegisterMeteredCharm", ")", "SetFlags", "(", "f", "*", "gnuflag", ".", "FlagSet", ")", "{", "f", ".", "IntVar", "(", "&", "r", ".", "IncreaseBudget", ",", "\"", "\"", ",", "0", ",", "\"", "\"", ")", "\n", "f", ".", "StringVar", "(", "&", "r", ".", "Plan", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "}" ]
// SetFlags implements DeployStep.
[ "SetFlags", "implements", "DeployStep", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/register.go#L39-L42
156,215
juju/juju
api/instancepoller/instancepoller.go
NewAPI
func NewAPI(caller base.APICaller) *API { if caller == nil { panic("caller is nil") } facadeCaller := base.NewFacadeCaller(caller, instancePollerFacade) return &API{ ModelWatcher: common.NewModelWatcher(facadeCaller), facade: facadeCaller, } }
go
func NewAPI(caller base.APICaller) *API { if caller == nil { panic("caller is nil") } facadeCaller := base.NewFacadeCaller(caller, instancePollerFacade) return &API{ ModelWatcher: common.NewModelWatcher(facadeCaller), facade: facadeCaller, } }
[ "func", "NewAPI", "(", "caller", "base", ".", "APICaller", ")", "*", "API", "{", "if", "caller", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "facadeCaller", ":=", "base", ".", "NewFacadeCaller", "(", "caller", ",", "instancePollerFacade", ")", "\n", "return", "&", "API", "{", "ModelWatcher", ":", "common", ".", "NewModelWatcher", "(", "facadeCaller", ")", ",", "facade", ":", "facadeCaller", ",", "}", "\n", "}" ]
// NewAPI creates a new client-side InstancePoller facade.
[ "NewAPI", "creates", "a", "new", "client", "-", "side", "InstancePoller", "facade", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/instancepoller/instancepoller.go#L27-L36
156,216
juju/juju
api/instancepoller/instancepoller.go
WatchModelMachines
func (api *API) WatchModelMachines() (watcher.StringsWatcher, error) { var result params.StringsWatchResult err := api.facade.FacadeCall("WatchModelMachines", nil, &result) if err != nil { return nil, err } if result.Error != nil { return nil, result.Error } return newStringsWatcher(api.facade.RawAPICaller(), result), nil }
go
func (api *API) WatchModelMachines() (watcher.StringsWatcher, error) { var result params.StringsWatchResult err := api.facade.FacadeCall("WatchModelMachines", nil, &result) if err != nil { return nil, err } if result.Error != nil { return nil, result.Error } return newStringsWatcher(api.facade.RawAPICaller(), result), nil }
[ "func", "(", "api", "*", "API", ")", "WatchModelMachines", "(", ")", "(", "watcher", ".", "StringsWatcher", ",", "error", ")", "{", "var", "result", "params", ".", "StringsWatchResult", "\n", "err", ":=", "api", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "nil", ",", "&", "result", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "result", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "result", ".", "Error", "\n", "}", "\n", "return", "newStringsWatcher", "(", "api", ".", "facade", ".", "RawAPICaller", "(", ")", ",", "result", ")", ",", "nil", "\n", "}" ]
// WatchModelMachines return a StringsWatcher reporting waiting for the // model configuration to change.
[ "WatchModelMachines", "return", "a", "StringsWatcher", "reporting", "waiting", "for", "the", "model", "configuration", "to", "change", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/instancepoller/instancepoller.go#L52-L62
156,217
juju/juju
api/metricsmanager/client.go
NewClient
func NewClient(apiCaller base.APICaller) (*Client, error) { modelTag, ok := apiCaller.ModelTag() if !ok { return nil, errors.New("metricsmanager client is not appropriate for controller-only API") } facade := base.NewFacadeCaller(apiCaller, "MetricsManager") return &Client{ modelTag: modelTag, facade: facade, }, nil }
go
func NewClient(apiCaller base.APICaller) (*Client, error) { modelTag, ok := apiCaller.ModelTag() if !ok { return nil, errors.New("metricsmanager client is not appropriate for controller-only API") } facade := base.NewFacadeCaller(apiCaller, "MetricsManager") return &Client{ modelTag: modelTag, facade: facade, }, nil }
[ "func", "NewClient", "(", "apiCaller", "base", ".", "APICaller", ")", "(", "*", "Client", ",", "error", ")", "{", "modelTag", ",", "ok", ":=", "apiCaller", ".", "ModelTag", "(", ")", "\n", "if", "!", "ok", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n\n", "}", "\n", "facade", ":=", "base", ".", "NewFacadeCaller", "(", "apiCaller", ",", "\"", "\"", ")", "\n", "return", "&", "Client", "{", "modelTag", ":", "modelTag", ",", "facade", ":", "facade", ",", "}", ",", "nil", "\n", "}" ]
// NewClient creates a new client for accessing the metricsmanager api
[ "NewClient", "creates", "a", "new", "client", "for", "accessing", "the", "metricsmanager", "api" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/metricsmanager/client.go#L31-L42
156,218
juju/juju
cloudconfig/podcfg/image.go
GetControllerImagePath
func (cfg *ControllerPodConfig) GetControllerImagePath() string { return GetJujuOCIImagePath(cfg.Controller.Config, cfg.JujuVersion) }
go
func (cfg *ControllerPodConfig) GetControllerImagePath() string { return GetJujuOCIImagePath(cfg.Controller.Config, cfg.JujuVersion) }
[ "func", "(", "cfg", "*", "ControllerPodConfig", ")", "GetControllerImagePath", "(", ")", "string", "{", "return", "GetJujuOCIImagePath", "(", "cfg", ".", "Controller", ".", "Config", ",", "cfg", ".", "JujuVersion", ")", "\n", "}" ]
// GetControllerImagePath returns oci image path of jujud for a controller.
[ "GetControllerImagePath", "returns", "oci", "image", "path", "of", "jujud", "for", "a", "controller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/podcfg/image.go#L22-L24
156,219
juju/juju
cloudconfig/podcfg/image.go
GetJujuDbOCIImagePath
func (cfg *ControllerPodConfig) GetJujuDbOCIImagePath() string { imageRepo := cfg.Controller.Config.CAASImageRepo() if imageRepo == "" { imageRepo = jujudOCINamespace } v := jujudbVersion return fmt.Sprintf("%s/%s:%d.%d", imageRepo, jujudbOCIName, v.Major, v.Minor) }
go
func (cfg *ControllerPodConfig) GetJujuDbOCIImagePath() string { imageRepo := cfg.Controller.Config.CAASImageRepo() if imageRepo == "" { imageRepo = jujudOCINamespace } v := jujudbVersion return fmt.Sprintf("%s/%s:%d.%d", imageRepo, jujudbOCIName, v.Major, v.Minor) }
[ "func", "(", "cfg", "*", "ControllerPodConfig", ")", "GetJujuDbOCIImagePath", "(", ")", "string", "{", "imageRepo", ":=", "cfg", ".", "Controller", ".", "Config", ".", "CAASImageRepo", "(", ")", "\n", "if", "imageRepo", "==", "\"", "\"", "{", "imageRepo", "=", "jujudOCINamespace", "\n", "}", "\n", "v", ":=", "jujudbVersion", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "imageRepo", ",", "jujudbOCIName", ",", "v", ".", "Major", ",", "v", ".", "Minor", ")", "\n", "}" ]
// GetJujuDbOCIImagePath returns the juju-db oci image path.
[ "GetJujuDbOCIImagePath", "returns", "the", "juju", "-", "db", "oci", "image", "path", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/podcfg/image.go#L27-L34
156,220
juju/juju
cloudconfig/podcfg/image.go
GetJujuOCIImagePath
func GetJujuOCIImagePath(controllerCfg controller.Config, ver version.Number) string { // First check the deprecated "caas-operator-image-path" config. imagePath := rebuildOldOperatorImagePath( controllerCfg.CAASOperatorImagePath(), ver, ) if imagePath != "" { return imagePath } return imageRepoToPath(controllerCfg.CAASImageRepo(), ver) }
go
func GetJujuOCIImagePath(controllerCfg controller.Config, ver version.Number) string { // First check the deprecated "caas-operator-image-path" config. imagePath := rebuildOldOperatorImagePath( controllerCfg.CAASOperatorImagePath(), ver, ) if imagePath != "" { return imagePath } return imageRepoToPath(controllerCfg.CAASImageRepo(), ver) }
[ "func", "GetJujuOCIImagePath", "(", "controllerCfg", "controller", ".", "Config", ",", "ver", "version", ".", "Number", ")", "string", "{", "// First check the deprecated \"caas-operator-image-path\" config.", "imagePath", ":=", "rebuildOldOperatorImagePath", "(", "controllerCfg", ".", "CAASOperatorImagePath", "(", ")", ",", "ver", ",", ")", "\n", "if", "imagePath", "!=", "\"", "\"", "{", "return", "imagePath", "\n", "}", "\n", "return", "imageRepoToPath", "(", "controllerCfg", ".", "CAASImageRepo", "(", ")", ",", "ver", ")", "\n", "}" ]
// GetJujuOCIImagePath returns the jujud oci image path.
[ "GetJujuOCIImagePath", "returns", "the", "jujud", "oci", "image", "path", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/podcfg/image.go#L42-L51
156,221
juju/juju
charmstore/jar.go
newMacaroonJar
func newMacaroonJar(cache MacaroonCache, serverURL *url.URL) (*macaroonJar, error) { jar, err := cookiejar.New(nil) if err != nil { return nil, errors.Trace(err) } return &macaroonJar{ underlying: jar, cache: cache, serverURL: serverURL, }, nil }
go
func newMacaroonJar(cache MacaroonCache, serverURL *url.URL) (*macaroonJar, error) { jar, err := cookiejar.New(nil) if err != nil { return nil, errors.Trace(err) } return &macaroonJar{ underlying: jar, cache: cache, serverURL: serverURL, }, nil }
[ "func", "newMacaroonJar", "(", "cache", "MacaroonCache", ",", "serverURL", "*", "url", ".", "URL", ")", "(", "*", "macaroonJar", ",", "error", ")", "{", "jar", ",", "err", ":=", "cookiejar", ".", "New", "(", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "&", "macaroonJar", "{", "underlying", ":", "jar", ",", "cache", ":", "cache", ",", "serverURL", ":", "serverURL", ",", "}", ",", "nil", "\n", "}" ]
// newMacaroonJar returns a new macaroonJar wrapping the given cache and // expecting to be used against the given URL. Both the cache and url must // be non-nil.
[ "newMacaroonJar", "returns", "a", "new", "macaroonJar", "wrapping", "the", "given", "cache", "and", "expecting", "to", "be", "used", "against", "the", "given", "URL", ".", "Both", "the", "cache", "and", "url", "must", "be", "non", "-", "nil", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/jar.go#L20-L30
156,222
juju/juju
charmstore/jar.go
reset
func (j *macaroonJar) reset() error { j.err = nil j.currentCharm = nil // clear out the cookie jar to ensure we don't have any cruft left over. underlying, err := cookiejar.New(nil) if err != nil { // currently this is impossible, since the above never actually // returns an error return errors.Trace(err) } j.underlying = underlying return nil }
go
func (j *macaroonJar) reset() error { j.err = nil j.currentCharm = nil // clear out the cookie jar to ensure we don't have any cruft left over. underlying, err := cookiejar.New(nil) if err != nil { // currently this is impossible, since the above never actually // returns an error return errors.Trace(err) } j.underlying = underlying return nil }
[ "func", "(", "j", "*", "macaroonJar", ")", "reset", "(", ")", "error", "{", "j", ".", "err", "=", "nil", "\n", "j", ".", "currentCharm", "=", "nil", "\n\n", "// clear out the cookie jar to ensure we don't have any cruft left over.", "underlying", ",", "err", ":=", "cookiejar", ".", "New", "(", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "// currently this is impossible, since the above never actually", "// returns an error", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "j", ".", "underlying", "=", "underlying", "\n", "return", "nil", "\n", "}" ]
// reset empties the cookiejar and disables the functionality of storing // macaroons in SetCookies.
[ "reset", "empties", "the", "cookiejar", "and", "disables", "the", "functionality", "of", "storing", "macaroons", "in", "SetCookies", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/jar.go#L89-L102
156,223
juju/juju
charmstore/jar.go
SetCookies
func (j *macaroonJar) SetCookies(u *url.URL, cookies []*http.Cookie) { j.underlying.SetCookies(u, cookies) if j.currentCharm == nil { // nothing else to do return } mac, err := extractMacaroon(cookies) if err != nil { j.err = errors.Trace(err) logger.Errorf(err.Error()) return } if mac == nil { return } if err := j.cache.Set(j.currentCharm, mac); err != nil { j.err = errors.Trace(err) logger.Errorf("Failed to store macaroon for %s: %s", j.currentCharm, err) } }
go
func (j *macaroonJar) SetCookies(u *url.URL, cookies []*http.Cookie) { j.underlying.SetCookies(u, cookies) if j.currentCharm == nil { // nothing else to do return } mac, err := extractMacaroon(cookies) if err != nil { j.err = errors.Trace(err) logger.Errorf(err.Error()) return } if mac == nil { return } if err := j.cache.Set(j.currentCharm, mac); err != nil { j.err = errors.Trace(err) logger.Errorf("Failed to store macaroon for %s: %s", j.currentCharm, err) } }
[ "func", "(", "j", "*", "macaroonJar", ")", "SetCookies", "(", "u", "*", "url", ".", "URL", ",", "cookies", "[", "]", "*", "http", ".", "Cookie", ")", "{", "j", ".", "underlying", ".", "SetCookies", "(", "u", ",", "cookies", ")", "\n\n", "if", "j", ".", "currentCharm", "==", "nil", "{", "// nothing else to do", "return", "\n", "}", "\n\n", "mac", ",", "err", ":=", "extractMacaroon", "(", "cookies", ")", "\n", "if", "err", "!=", "nil", "{", "j", ".", "err", "=", "errors", ".", "Trace", "(", "err", ")", "\n", "logger", ".", "Errorf", "(", "err", ".", "Error", "(", ")", ")", "\n", "return", "\n", "}", "\n", "if", "mac", "==", "nil", "{", "return", "\n", "}", "\n", "if", "err", ":=", "j", ".", "cache", ".", "Set", "(", "j", ".", "currentCharm", ",", "mac", ")", ";", "err", "!=", "nil", "{", "j", ".", "err", "=", "errors", ".", "Trace", "(", "err", ")", "\n", "logger", ".", "Errorf", "(", "\"", "\"", ",", "j", ".", "currentCharm", ",", "err", ")", "\n", "}", "\n", "}" ]
// SetCookies handles the receipt of the cookies in a reply for the // given URL. Cookies do not persist past a successive call to Activate or // Deactivate. If the jar is currently activated, macaroons set via this method // will be stored in the underlying MacaroonCache for the currently activated // charm.
[ "SetCookies", "handles", "the", "receipt", "of", "the", "cookies", "in", "a", "reply", "for", "the", "given", "URL", ".", "Cookies", "do", "not", "persist", "past", "a", "successive", "call", "to", "Activate", "or", "Deactivate", ".", "If", "the", "jar", "is", "currently", "activated", "macaroons", "set", "via", "this", "method", "will", "be", "stored", "in", "the", "underlying", "MacaroonCache", "for", "the", "currently", "activated", "charm", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/jar.go#L109-L130
156,224
juju/juju
charmstore/jar.go
Cookies
func (j macaroonJar) Cookies(u *url.URL) []*http.Cookie { return j.underlying.Cookies(u) }
go
func (j macaroonJar) Cookies(u *url.URL) []*http.Cookie { return j.underlying.Cookies(u) }
[ "func", "(", "j", "macaroonJar", ")", "Cookies", "(", "u", "*", "url", ".", "URL", ")", "[", "]", "*", "http", ".", "Cookie", "{", "return", "j", ".", "underlying", ".", "Cookies", "(", "u", ")", "\n", "}" ]
// Cookies returns the cookies stored in the underlying cookiejar.
[ "Cookies", "returns", "the", "cookies", "stored", "in", "the", "underlying", "cookiejar", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/charmstore/jar.go#L133-L135
156,225
juju/juju
cmd/juju/gui/upgradegui.go
Init
func (c *upgradeGUICommand) Init(args []string) error { if len(args) == 1 { if c.list { return errors.New("cannot provide arguments if --list is provided") } c.versOrPath = args[0] return nil } return cmd.CheckEmpty(args) }
go
func (c *upgradeGUICommand) Init(args []string) error { if len(args) == 1 { if c.list { return errors.New("cannot provide arguments if --list is provided") } c.versOrPath = args[0] return nil } return cmd.CheckEmpty(args) }
[ "func", "(", "c", "*", "upgradeGUICommand", ")", "Init", "(", "args", "[", "]", "string", ")", "error", "{", "if", "len", "(", "args", ")", "==", "1", "{", "if", "c", ".", "list", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "c", ".", "versOrPath", "=", "args", "[", "0", "]", "\n", "return", "nil", "\n", "}", "\n", "return", "cmd", ".", "CheckEmpty", "(", "args", ")", "\n", "}" ]
// Init implements the cmd.Command interface.
[ "Init", "implements", "the", "cmd", ".", "Command", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/gui/upgradegui.go#L77-L86
156,226
juju/juju
cmd/juju/gui/upgradegui.go
remoteArchiveMetadata
func remoteArchiveMetadata() ([]*gui.Metadata, error) { source := gui.NewDataSource(common.GUIDataSourceBaseURL()) allMeta, err := guiFetchMetadata(gui.ReleasedStream, source) if err != nil { return nil, errors.Annotate(err, "cannot retrieve Juju GUI archive info") } if len(allMeta) == 0 { return nil, errors.New("no available Juju GUI archives found") } return allMeta, nil }
go
func remoteArchiveMetadata() ([]*gui.Metadata, error) { source := gui.NewDataSource(common.GUIDataSourceBaseURL()) allMeta, err := guiFetchMetadata(gui.ReleasedStream, source) if err != nil { return nil, errors.Annotate(err, "cannot retrieve Juju GUI archive info") } if len(allMeta) == 0 { return nil, errors.New("no available Juju GUI archives found") } return allMeta, nil }
[ "func", "remoteArchiveMetadata", "(", ")", "(", "[", "]", "*", "gui", ".", "Metadata", ",", "error", ")", "{", "source", ":=", "gui", ".", "NewDataSource", "(", "common", ".", "GUIDataSourceBaseURL", "(", ")", ")", "\n", "allMeta", ",", "err", ":=", "guiFetchMetadata", "(", "gui", ".", "ReleasedStream", ",", "source", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "allMeta", ")", "==", "0", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "allMeta", ",", "nil", "\n", "}" ]
// remoteArchiveMetadata returns Juju GUI archive metadata from simplestreams.
[ "remoteArchiveMetadata", "returns", "Juju", "GUI", "archive", "metadata", "from", "simplestreams", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/gui/upgradegui.go#L242-L252
156,227
juju/juju
cmd/juju/gui/upgradegui.go
findMetadataVersion
func findMetadataVersion(allMeta []*gui.Metadata, vers version.Number) (*gui.Metadata, error) { for _, metadata := range allMeta { if metadata.Version == vers { return metadata, nil } } return nil, errors.NotFoundf("Juju GUI release version %s", vers) }
go
func findMetadataVersion(allMeta []*gui.Metadata, vers version.Number) (*gui.Metadata, error) { for _, metadata := range allMeta { if metadata.Version == vers { return metadata, nil } } return nil, errors.NotFoundf("Juju GUI release version %s", vers) }
[ "func", "findMetadataVersion", "(", "allMeta", "[", "]", "*", "gui", ".", "Metadata", ",", "vers", "version", ".", "Number", ")", "(", "*", "gui", ".", "Metadata", ",", "error", ")", "{", "for", "_", ",", "metadata", ":=", "range", "allMeta", "{", "if", "metadata", ".", "Version", "==", "vers", "{", "return", "metadata", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "NotFoundf", "(", "\"", "\"", ",", "vers", ")", "\n", "}" ]
// findMetadataVersion returns the metadata in allMeta with the given version.
[ "findMetadataVersion", "returns", "the", "metadata", "in", "allMeta", "with", "the", "given", "version", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/gui/upgradegui.go#L255-L262
156,228
juju/juju
cmd/juju/gui/upgradegui.go
hashAndSize
func hashAndSize(r io.Reader) (hash string, size int64, err error) { h := sha256.New() size, err = io.Copy(h, r) if err != nil { return "", 0, errors.Annotate(err, "cannot calculate archive hash") } return fmt.Sprintf("%x", h.Sum(nil)), size, nil }
go
func hashAndSize(r io.Reader) (hash string, size int64, err error) { h := sha256.New() size, err = io.Copy(h, r) if err != nil { return "", 0, errors.Annotate(err, "cannot calculate archive hash") } return fmt.Sprintf("%x", h.Sum(nil)), size, nil }
[ "func", "hashAndSize", "(", "r", "io", ".", "Reader", ")", "(", "hash", "string", ",", "size", "int64", ",", "err", "error", ")", "{", "h", ":=", "sha256", ".", "New", "(", ")", "\n", "size", ",", "err", "=", "io", ".", "Copy", "(", "h", ",", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "0", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "h", ".", "Sum", "(", "nil", ")", ")", ",", "size", ",", "nil", "\n", "}" ]
// hashAndSize returns the SHA256 hash and size of the data included in r.
[ "hashAndSize", "returns", "the", "SHA256", "hash", "and", "size", "of", "the", "data", "included", "in", "r", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/gui/upgradegui.go#L293-L300
156,229
juju/juju
cmd/juju/gui/upgradegui.go
existingVersionInfo
func existingVersionInfo(client *controller.Client, vers version.Number) (hash string, current bool, err error) { versions, err := clientGUIArchives(client) if err != nil { return "", false, errors.Annotate(err, "cannot retrieve GUI versions from the controller") } for _, v := range versions { if v.Version == vers { return v.SHA256, v.Current, nil } } return "", false, nil }
go
func existingVersionInfo(client *controller.Client, vers version.Number) (hash string, current bool, err error) { versions, err := clientGUIArchives(client) if err != nil { return "", false, errors.Annotate(err, "cannot retrieve GUI versions from the controller") } for _, v := range versions { if v.Version == vers { return v.SHA256, v.Current, nil } } return "", false, nil }
[ "func", "existingVersionInfo", "(", "client", "*", "controller", ".", "Client", ",", "vers", "version", ".", "Number", ")", "(", "hash", "string", ",", "current", "bool", ",", "err", "error", ")", "{", "versions", ",", "err", ":=", "clientGUIArchives", "(", "client", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "false", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "for", "_", ",", "v", ":=", "range", "versions", "{", "if", "v", ".", "Version", "==", "vers", "{", "return", "v", ".", "SHA256", ",", "v", ".", "Current", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "\"", "\"", ",", "false", ",", "nil", "\n", "}" ]
// existingVersionInfo returns the hash of the existing GUI archive at the // given version and reports whether that's the current version served by the // controller. If the given version is not present in the server, an empty // hash is returned.
[ "existingVersionInfo", "returns", "the", "hash", "of", "the", "existing", "GUI", "archive", "at", "the", "given", "version", "and", "reports", "whether", "that", "s", "the", "current", "version", "served", "by", "the", "controller", ".", "If", "the", "given", "version", "is", "not", "present", "in", "the", "server", "an", "empty", "hash", "is", "returned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/gui/upgradegui.go#L306-L317
156,230
juju/juju
cmd/juju/gui/upgradegui.go
storeArchive
func storeArchive(r io.Reader) (readSeekCloser, error) { f, err := ioutil.TempFile("", "gui-archive") if err != nil { return nil, errors.Annotate(err, "cannot create a temporary file to save the Juju GUI archive") } if _, err = io.Copy(f, r); err != nil { return nil, errors.Annotate(err, "cannot retrieve Juju GUI archive") } if _, err = f.Seek(0, 0); err != nil { return nil, errors.Annotate(err, "cannot seek temporary archive file") } return deleteOnCloseFile{f}, nil }
go
func storeArchive(r io.Reader) (readSeekCloser, error) { f, err := ioutil.TempFile("", "gui-archive") if err != nil { return nil, errors.Annotate(err, "cannot create a temporary file to save the Juju GUI archive") } if _, err = io.Copy(f, r); err != nil { return nil, errors.Annotate(err, "cannot retrieve Juju GUI archive") } if _, err = f.Seek(0, 0); err != nil { return nil, errors.Annotate(err, "cannot seek temporary archive file") } return deleteOnCloseFile{f}, nil }
[ "func", "storeArchive", "(", "r", "io", ".", "Reader", ")", "(", "readSeekCloser", ",", "error", ")", "{", "f", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "_", ",", "err", "=", "io", ".", "Copy", "(", "f", ",", "r", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "_", ",", "err", "=", "f", ".", "Seek", "(", "0", ",", "0", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "return", "deleteOnCloseFile", "{", "f", "}", ",", "nil", "\n", "}" ]
// storeArchive saves the Juju GUI archive in the given reader in a temporary // file. The resulting returned readSeekCloser is deleted when closed.
[ "storeArchive", "saves", "the", "Juju", "GUI", "archive", "in", "the", "given", "reader", "in", "a", "temporary", "file", ".", "The", "resulting", "returned", "readSeekCloser", "is", "deleted", "when", "closed", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/gui/upgradegui.go#L321-L333
156,231
juju/juju
cmd/juju/gui/upgradegui.go
Close
func (f deleteOnCloseFile) Close() error { f.File.Close() os.Remove(f.Name()) return nil }
go
func (f deleteOnCloseFile) Close() error { f.File.Close() os.Remove(f.Name()) return nil }
[ "func", "(", "f", "deleteOnCloseFile", ")", "Close", "(", ")", "error", "{", "f", ".", "File", ".", "Close", "(", ")", "\n", "os", ".", "Remove", "(", "f", ".", "Name", "(", ")", ")", "\n", "return", "nil", "\n", "}" ]
// Close closes the file.
[ "Close", "closes", "the", "file", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/gui/upgradegui.go#L347-L351
156,232
juju/juju
worker/diskmanager/lsblk.go
addHardwareInfo
func addHardwareInfo(dev *storage.BlockDevice) error { logger.Tracef(`executing "udevadm info" for %s`, dev.DeviceName) output, err := exec.Command( "udevadm", "info", "-q", "property", "--name", dev.DeviceName, ).CombinedOutput() if err != nil { msg := "udevadm failed" if output := bytes.TrimSpace(output); len(output) > 0 { msg += fmt.Sprintf(" (%s)", output) } return errors.Annotate(err, msg) } var devpath, idBus, idSerial, wwnWithExtension string s := bufio.NewScanner(bytes.NewReader(output)) for s.Scan() { line := s.Text() sep := strings.IndexRune(line, '=') if sep == -1 { logger.Debugf("unexpected udevadm output line: %q", line) continue } key, value := line[:sep], line[sep+1:] switch key { case "DEVPATH": devpath = value case "DEVLINKS": dev.DeviceLinks = strings.Split(value, " ") case "ID_BUS": idBus = value case "ID_SERIAL": idSerial = value case "ID_WWN": dev.WWN = value case "ID_WWN_WITH_EXTENSION": wwnWithExtension = value default: logger.Tracef("ignoring line: %q", line) } } if err := s.Err(); err != nil { return errors.Annotate(err, "cannot parse udevadm output") } // For cases where there are logical disks attached to a // controller (eg RAID), the controller itself has a WWN // which is the ID_WWN value and each disk has a WWN with // a vendor extension ID_WWN_WITH_EXTENSION added to // identify the disk via the /dev/disk/by-id path. if wwnWithExtension != "" { dev.WWN = wwnWithExtension } if idBus != "" && idSerial != "" { // ID_BUS will be something like "scsi" or "ata"; // ID_SERIAL will be something like ${MODEL}_${SERIALNO}; // and together they make up the symlink in /dev/disk/by-id. dev.HardwareId = idBus + "-" + idSerial } // For devices on the SCSI bus, we include the address. This is to // support storage providers where the SCSI address may be specified, // but the device name can not (and may change, depending on timing). if idBus == "scsi" && devpath != "" { // DEVPATH will be "<uninteresting stuff>/<SCSI address>/block/<device>". re := regexp.MustCompile(fmt.Sprintf( `^.*/(\d+):(\d+):(\d+):(\d+)/block/%s$`, regexp.QuoteMeta(dev.DeviceName), )) submatch := re.FindStringSubmatch(devpath) if submatch != nil { // We use the address scheme used by lshw: bus@address. We don't use // lshw because it does things we don't need, and that slows it down. // // In DEVPATH, the address format is "H:C:T:L" ([H]ost, [C]hannel, // [T]arget, [L]un); the lshw address format is "H:C.T.L" dev.BusAddress = fmt.Sprintf( "scsi@%s:%s.%s.%s", submatch[1], submatch[2], submatch[3], submatch[4], ) } else { logger.Debugf( "non matching DEVPATH for %q: %q", dev.DeviceName, devpath, ) } } return nil }
go
func addHardwareInfo(dev *storage.BlockDevice) error { logger.Tracef(`executing "udevadm info" for %s`, dev.DeviceName) output, err := exec.Command( "udevadm", "info", "-q", "property", "--name", dev.DeviceName, ).CombinedOutput() if err != nil { msg := "udevadm failed" if output := bytes.TrimSpace(output); len(output) > 0 { msg += fmt.Sprintf(" (%s)", output) } return errors.Annotate(err, msg) } var devpath, idBus, idSerial, wwnWithExtension string s := bufio.NewScanner(bytes.NewReader(output)) for s.Scan() { line := s.Text() sep := strings.IndexRune(line, '=') if sep == -1 { logger.Debugf("unexpected udevadm output line: %q", line) continue } key, value := line[:sep], line[sep+1:] switch key { case "DEVPATH": devpath = value case "DEVLINKS": dev.DeviceLinks = strings.Split(value, " ") case "ID_BUS": idBus = value case "ID_SERIAL": idSerial = value case "ID_WWN": dev.WWN = value case "ID_WWN_WITH_EXTENSION": wwnWithExtension = value default: logger.Tracef("ignoring line: %q", line) } } if err := s.Err(); err != nil { return errors.Annotate(err, "cannot parse udevadm output") } // For cases where there are logical disks attached to a // controller (eg RAID), the controller itself has a WWN // which is the ID_WWN value and each disk has a WWN with // a vendor extension ID_WWN_WITH_EXTENSION added to // identify the disk via the /dev/disk/by-id path. if wwnWithExtension != "" { dev.WWN = wwnWithExtension } if idBus != "" && idSerial != "" { // ID_BUS will be something like "scsi" or "ata"; // ID_SERIAL will be something like ${MODEL}_${SERIALNO}; // and together they make up the symlink in /dev/disk/by-id. dev.HardwareId = idBus + "-" + idSerial } // For devices on the SCSI bus, we include the address. This is to // support storage providers where the SCSI address may be specified, // but the device name can not (and may change, depending on timing). if idBus == "scsi" && devpath != "" { // DEVPATH will be "<uninteresting stuff>/<SCSI address>/block/<device>". re := regexp.MustCompile(fmt.Sprintf( `^.*/(\d+):(\d+):(\d+):(\d+)/block/%s$`, regexp.QuoteMeta(dev.DeviceName), )) submatch := re.FindStringSubmatch(devpath) if submatch != nil { // We use the address scheme used by lshw: bus@address. We don't use // lshw because it does things we don't need, and that slows it down. // // In DEVPATH, the address format is "H:C:T:L" ([H]ost, [C]hannel, // [T]arget, [L]un); the lshw address format is "H:C.T.L" dev.BusAddress = fmt.Sprintf( "scsi@%s:%s.%s.%s", submatch[1], submatch[2], submatch[3], submatch[4], ) } else { logger.Debugf( "non matching DEVPATH for %q: %q", dev.DeviceName, devpath, ) } } return nil }
[ "func", "addHardwareInfo", "(", "dev", "*", "storage", ".", "BlockDevice", ")", "error", "{", "logger", ".", "Tracef", "(", "`executing \"udevadm info\" for %s`", ",", "dev", ".", "DeviceName", ")", "\n", "output", ",", "err", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "dev", ".", "DeviceName", ",", ")", ".", "CombinedOutput", "(", ")", "\n", "if", "err", "!=", "nil", "{", "msg", ":=", "\"", "\"", "\n", "if", "output", ":=", "bytes", ".", "TrimSpace", "(", "output", ")", ";", "len", "(", "output", ")", ">", "0", "{", "msg", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "output", ")", "\n", "}", "\n", "return", "errors", ".", "Annotate", "(", "err", ",", "msg", ")", "\n", "}", "\n\n", "var", "devpath", ",", "idBus", ",", "idSerial", ",", "wwnWithExtension", "string", "\n\n", "s", ":=", "bufio", ".", "NewScanner", "(", "bytes", ".", "NewReader", "(", "output", ")", ")", "\n", "for", "s", ".", "Scan", "(", ")", "{", "line", ":=", "s", ".", "Text", "(", ")", "\n", "sep", ":=", "strings", ".", "IndexRune", "(", "line", ",", "'='", ")", "\n", "if", "sep", "==", "-", "1", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "line", ")", "\n", "continue", "\n", "}", "\n", "key", ",", "value", ":=", "line", "[", ":", "sep", "]", ",", "line", "[", "sep", "+", "1", ":", "]", "\n", "switch", "key", "{", "case", "\"", "\"", ":", "devpath", "=", "value", "\n", "case", "\"", "\"", ":", "dev", ".", "DeviceLinks", "=", "strings", ".", "Split", "(", "value", ",", "\"", "\"", ")", "\n", "case", "\"", "\"", ":", "idBus", "=", "value", "\n", "case", "\"", "\"", ":", "idSerial", "=", "value", "\n", "case", "\"", "\"", ":", "dev", ".", "WWN", "=", "value", "\n", "case", "\"", "\"", ":", "wwnWithExtension", "=", "value", "\n", "default", ":", "logger", ".", "Tracef", "(", "\"", "\"", ",", "line", ")", "\n", "}", "\n", "}", "\n", "if", "err", ":=", "s", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "// For cases where there are logical disks attached to a", "// controller (eg RAID), the controller itself has a WWN", "// which is the ID_WWN value and each disk has a WWN with", "// a vendor extension ID_WWN_WITH_EXTENSION added to", "// identify the disk via the /dev/disk/by-id path.", "if", "wwnWithExtension", "!=", "\"", "\"", "{", "dev", ".", "WWN", "=", "wwnWithExtension", "\n", "}", "\n", "if", "idBus", "!=", "\"", "\"", "&&", "idSerial", "!=", "\"", "\"", "{", "// ID_BUS will be something like \"scsi\" or \"ata\";", "// ID_SERIAL will be something like ${MODEL}_${SERIALNO};", "// and together they make up the symlink in /dev/disk/by-id.", "dev", ".", "HardwareId", "=", "idBus", "+", "\"", "\"", "+", "idSerial", "\n", "}", "\n\n", "// For devices on the SCSI bus, we include the address. This is to", "// support storage providers where the SCSI address may be specified,", "// but the device name can not (and may change, depending on timing).", "if", "idBus", "==", "\"", "\"", "&&", "devpath", "!=", "\"", "\"", "{", "// DEVPATH will be \"<uninteresting stuff>/<SCSI address>/block/<device>\".", "re", ":=", "regexp", ".", "MustCompile", "(", "fmt", ".", "Sprintf", "(", "`^.*/(\\d+):(\\d+):(\\d+):(\\d+)/block/%s$`", ",", "regexp", ".", "QuoteMeta", "(", "dev", ".", "DeviceName", ")", ",", ")", ")", "\n", "submatch", ":=", "re", ".", "FindStringSubmatch", "(", "devpath", ")", "\n", "if", "submatch", "!=", "nil", "{", "// We use the address scheme used by lshw: bus@address. We don't use", "// lshw because it does things we don't need, and that slows it down.", "//", "// In DEVPATH, the address format is \"H:C:T:L\" ([H]ost, [C]hannel,", "// [T]arget, [L]un); the lshw address format is \"H:C.T.L\"", "dev", ".", "BusAddress", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "submatch", "[", "1", "]", ",", "submatch", "[", "2", "]", ",", "submatch", "[", "3", "]", ",", "submatch", "[", "4", "]", ",", ")", "\n", "}", "else", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "dev", ".", "DeviceName", ",", "devpath", ",", ")", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// addHardwareInfo adds additional information about the hardware, and how it is // attached to the machine, to the given BlockDevice.
[ "addHardwareInfo", "adds", "additional", "information", "about", "the", "hardware", "and", "how", "it", "is", "attached", "to", "the", "machine", "to", "the", "given", "BlockDevice", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/diskmanager/lsblk.go#L176-L267
156,233
juju/juju
apiserver/pinger.go
NewPinger
func NewPinger(st *state.State, resources facade.Resources, authorizer facade.Authorizer) (Pinger, error) { pingTimeout, ok := resources.Get("pingTimeout").(*pingTimeout) if !ok { return nullPinger{}, nil } return pingTimeout, nil }
go
func NewPinger(st *state.State, resources facade.Resources, authorizer facade.Authorizer) (Pinger, error) { pingTimeout, ok := resources.Get("pingTimeout").(*pingTimeout) if !ok { return nullPinger{}, nil } return pingTimeout, nil }
[ "func", "NewPinger", "(", "st", "*", "state", ".", "State", ",", "resources", "facade", ".", "Resources", ",", "authorizer", "facade", ".", "Authorizer", ")", "(", "Pinger", ",", "error", ")", "{", "pingTimeout", ",", "ok", ":=", "resources", ".", "Get", "(", "\"", "\"", ")", ".", "(", "*", "pingTimeout", ")", "\n", "if", "!", "ok", "{", "return", "nullPinger", "{", "}", ",", "nil", "\n", "}", "\n", "return", "pingTimeout", ",", "nil", "\n", "}" ]
// NewPinger returns an object that can be pinged by calling its Ping method. // If this method is not called frequently enough, the connection will be // dropped.
[ "NewPinger", "returns", "an", "object", "that", "can", "be", "pinged", "by", "calling", "its", "Ping", "method", ".", "If", "this", "method", "is", "not", "called", "frequently", "enough", "the", "connection", "will", "be", "dropped", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/pinger.go#L20-L26
156,234
juju/juju
apiserver/pinger.go
newPingTimeout
func newPingTimeout(action func(), clock clock.Clock, timeout time.Duration) Pinger { pt := &pingTimeout{ action: action, clock: clock, timeout: timeout, reset: make(chan struct{}), } pt.tomb.Go(pt.loop) return pt }
go
func newPingTimeout(action func(), clock clock.Clock, timeout time.Duration) Pinger { pt := &pingTimeout{ action: action, clock: clock, timeout: timeout, reset: make(chan struct{}), } pt.tomb.Go(pt.loop) return pt }
[ "func", "newPingTimeout", "(", "action", "func", "(", ")", ",", "clock", "clock", ".", "Clock", ",", "timeout", "time", ".", "Duration", ")", "Pinger", "{", "pt", ":=", "&", "pingTimeout", "{", "action", ":", "action", ",", "clock", ":", "clock", ",", "timeout", ":", "timeout", ",", "reset", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n", "pt", ".", "tomb", ".", "Go", "(", "pt", ".", "loop", ")", "\n", "return", "pt", "\n", "}" ]
// newPingTimeout returns a new pingTimeout instance // that invokes the given action asynchronously if there // is more than the given timeout interval between calls // to its Ping method.
[ "newPingTimeout", "returns", "a", "new", "pingTimeout", "instance", "that", "invokes", "the", "given", "action", "asynchronously", "if", "there", "is", "more", "than", "the", "given", "timeout", "interval", "between", "calls", "to", "its", "Ping", "method", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/pinger.go#L49-L58
156,235
juju/juju
apiserver/pinger.go
Stop
func (pt *pingTimeout) Stop() error { pt.tomb.Kill(nil) return pt.tomb.Wait() }
go
func (pt *pingTimeout) Stop() error { pt.tomb.Kill(nil) return pt.tomb.Wait() }
[ "func", "(", "pt", "*", "pingTimeout", ")", "Stop", "(", ")", "error", "{", "pt", ".", "tomb", ".", "Kill", "(", "nil", ")", "\n", "return", "pt", ".", "tomb", ".", "Wait", "(", ")", "\n", "}" ]
// Stop terminates the ping timeout.
[ "Stop", "terminates", "the", "ping", "timeout", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/pinger.go#L70-L73
156,236
juju/juju
apiserver/pinger.go
loop
func (pt *pingTimeout) loop() error { for { select { case <-pt.tomb.Dying(): return tomb.ErrDying case <-pt.reset: case <-pt.clock.After(pt.timeout): go pt.action() return errors.New("ping timeout") } } }
go
func (pt *pingTimeout) loop() error { for { select { case <-pt.tomb.Dying(): return tomb.ErrDying case <-pt.reset: case <-pt.clock.After(pt.timeout): go pt.action() return errors.New("ping timeout") } } }
[ "func", "(", "pt", "*", "pingTimeout", ")", "loop", "(", ")", "error", "{", "for", "{", "select", "{", "case", "<-", "pt", ".", "tomb", ".", "Dying", "(", ")", ":", "return", "tomb", ".", "ErrDying", "\n", "case", "<-", "pt", ".", "reset", ":", "case", "<-", "pt", ".", "clock", ".", "After", "(", "pt", ".", "timeout", ")", ":", "go", "pt", ".", "action", "(", ")", "\n", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "}" ]
// loop waits for a reset signal, otherwise it performs // the initially passed action.
[ "loop", "waits", "for", "a", "reset", "signal", "otherwise", "it", "performs", "the", "initially", "passed", "action", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/pinger.go#L77-L88
156,237
juju/juju
apiserver/common/credentialcommon/backend.go
AllMachines
func (st stateShim) AllMachines() ([]Machine, error) { machines, err := st.State.AllMachines() if err != nil { return nil, errors.Trace(err) } result := make([]Machine, len(machines)) for i, m := range machines { result[i] = m } return result, nil }
go
func (st stateShim) AllMachines() ([]Machine, error) { machines, err := st.State.AllMachines() if err != nil { return nil, errors.Trace(err) } result := make([]Machine, len(machines)) for i, m := range machines { result[i] = m } return result, nil }
[ "func", "(", "st", "stateShim", ")", "AllMachines", "(", ")", "(", "[", "]", "Machine", ",", "error", ")", "{", "machines", ",", "err", ":=", "st", ".", "State", ".", "AllMachines", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "result", ":=", "make", "(", "[", "]", "Machine", ",", "len", "(", "machines", ")", ")", "\n", "for", "i", ",", "m", ":=", "range", "machines", "{", "result", "[", "i", "]", "=", "m", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// AllMachines implements PersistentBackend.AllMachines.
[ "AllMachines", "implements", "PersistentBackend", ".", "AllMachines", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/credentialcommon/backend.go#L96-L106
156,238
juju/juju
apiserver/common/credentialcommon/backend.go
Model
func (st stateShim) Model() (Model, error) { m, err := st.State.Model() return m, err }
go
func (st stateShim) Model() (Model, error) { m, err := st.State.Model() return m, err }
[ "func", "(", "st", "stateShim", ")", "Model", "(", ")", "(", "Model", ",", "error", ")", "{", "m", ",", "err", ":=", "st", ".", "State", ".", "Model", "(", ")", "\n", "return", "m", ",", "err", "\n", "}" ]
// Model implements PersistentBackend.Model.
[ "Model", "implements", "PersistentBackend", ".", "Model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/credentialcommon/backend.go#L109-L112
156,239
juju/juju
api/base/mocks/clientfacade_mock.go
NewMockAPICallCloser
func NewMockAPICallCloser(ctrl *gomock.Controller) *MockAPICallCloser { mock := &MockAPICallCloser{ctrl: ctrl} mock.recorder = &MockAPICallCloserMockRecorder{mock} return mock }
go
func NewMockAPICallCloser(ctrl *gomock.Controller) *MockAPICallCloser { mock := &MockAPICallCloser{ctrl: ctrl} mock.recorder = &MockAPICallCloserMockRecorder{mock} return mock }
[ "func", "NewMockAPICallCloser", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockAPICallCloser", "{", "mock", ":=", "&", "MockAPICallCloser", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockAPICallCloserMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockAPICallCloser creates a new mock instance
[ "NewMockAPICallCloser", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/base/mocks/clientfacade_mock.go#L30-L34
156,240
juju/juju
api/base/mocks/clientfacade_mock.go
APICall
func (m *MockAPICallCloser) APICall(arg0 string, arg1 int, arg2, arg3 string, arg4, arg5 interface{}) error { ret := m.ctrl.Call(m, "APICall", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockAPICallCloser) APICall(arg0 string, arg1 int, arg2, arg3 string, arg4, arg5 interface{}) error { ret := m.ctrl.Call(m, "APICall", arg0, arg1, arg2, arg3, arg4, arg5) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockAPICallCloser", ")", "APICall", "(", "arg0", "string", ",", "arg1", "int", ",", "arg2", ",", "arg3", "string", ",", "arg4", ",", "arg5", "interface", "{", "}", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", ",", "arg5", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// APICall mocks base method
[ "APICall", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/base/mocks/clientfacade_mock.go#L42-L46
156,241
juju/juju
api/base/mocks/clientfacade_mock.go
APICall
func (mr *MockAPICallCloserMockRecorder) APICall(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "APICall", reflect.TypeOf((*MockAPICallCloser)(nil).APICall), arg0, arg1, arg2, arg3, arg4, arg5) }
go
func (mr *MockAPICallCloserMockRecorder) APICall(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "APICall", reflect.TypeOf((*MockAPICallCloser)(nil).APICall), arg0, arg1, arg2, arg3, arg4, arg5) }
[ "func", "(", "mr", "*", "MockAPICallCloserMockRecorder", ")", "APICall", "(", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", ",", "arg5", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockAPICallCloser", ")", "(", "nil", ")", ".", "APICall", ")", ",", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", ",", "arg5", ")", "\n", "}" ]
// APICall indicates an expected call of APICall
[ "APICall", "indicates", "an", "expected", "call", "of", "APICall" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/base/mocks/clientfacade_mock.go#L49-L51
156,242
juju/juju
api/base/mocks/clientfacade_mock.go
BestFacadeVersion
func (m *MockAPICallCloser) BestFacadeVersion(arg0 string) int { ret := m.ctrl.Call(m, "BestFacadeVersion", arg0) ret0, _ := ret[0].(int) return ret0 }
go
func (m *MockAPICallCloser) BestFacadeVersion(arg0 string) int { ret := m.ctrl.Call(m, "BestFacadeVersion", arg0) ret0, _ := ret[0].(int) return ret0 }
[ "func", "(", "m", "*", "MockAPICallCloser", ")", "BestFacadeVersion", "(", "arg0", "string", ")", "int", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "int", ")", "\n", "return", "ret0", "\n", "}" ]
// BestFacadeVersion mocks base method
[ "BestFacadeVersion", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/base/mocks/clientfacade_mock.go#L66-L70
156,243
juju/juju
api/base/mocks/clientfacade_mock.go
ConnectStream
func (mr *MockAPICallCloserMockRecorder) ConnectStream(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConnectStream", reflect.TypeOf((*MockAPICallCloser)(nil).ConnectStream), arg0, arg1) }
go
func (mr *MockAPICallCloserMockRecorder) ConnectStream(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConnectStream", reflect.TypeOf((*MockAPICallCloser)(nil).ConnectStream), arg0, arg1) }
[ "func", "(", "mr", "*", "MockAPICallCloserMockRecorder", ")", "ConnectStream", "(", "arg0", ",", "arg1", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockAPICallCloser", ")", "(", "nil", ")", ".", "ConnectStream", ")", ",", "arg0", ",", "arg1", ")", "\n", "}" ]
// ConnectStream indicates an expected call of ConnectStream
[ "ConnectStream", "indicates", "an", "expected", "call", "of", "ConnectStream" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/base/mocks/clientfacade_mock.go#L111-L113
156,244
juju/juju
api/base/mocks/clientfacade_mock.go
NewMockClientFacade
func NewMockClientFacade(ctrl *gomock.Controller) *MockClientFacade { mock := &MockClientFacade{ctrl: ctrl} mock.recorder = &MockClientFacadeMockRecorder{mock} return mock }
go
func NewMockClientFacade(ctrl *gomock.Controller) *MockClientFacade { mock := &MockClientFacade{ctrl: ctrl} mock.recorder = &MockClientFacadeMockRecorder{mock} return mock }
[ "func", "NewMockClientFacade", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockClientFacade", "{", "mock", ":=", "&", "MockClientFacade", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockClientFacadeMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockClientFacade creates a new mock instance
[ "NewMockClientFacade", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/base/mocks/clientfacade_mock.go#L153-L157
156,245
juju/juju
apiserver/params/apierror.go
ErrCode
func ErrCode(err error) string { type ErrorCoder interface { ErrorCode() string } switch err := errors.Cause(err).(type) { case ErrorCoder: return err.ErrorCode() default: return "" } }
go
func ErrCode(err error) string { type ErrorCoder interface { ErrorCode() string } switch err := errors.Cause(err).(type) { case ErrorCoder: return err.ErrorCode() default: return "" } }
[ "func", "ErrCode", "(", "err", "error", ")", "string", "{", "type", "ErrorCoder", "interface", "{", "ErrorCode", "(", ")", "string", "\n", "}", "\n", "switch", "err", ":=", "errors", ".", "Cause", "(", "err", ")", ".", "(", "type", ")", "{", "case", "ErrorCoder", ":", "return", "err", ".", "ErrorCode", "(", ")", "\n", "default", ":", "return", "\"", "\"", "\n", "}", "\n", "}" ]
// ErrCode returns the error code associated with // the given error, or the empty string if there // is none.
[ "ErrCode", "returns", "the", "error", "code", "associated", "with", "the", "given", "error", "or", "the", "empty", "string", "if", "there", "is", "none", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/params/apierror.go#L181-L191
156,246
juju/juju
provider/openstack/cinder.go
VolumeSource
func (p *cinderProvider) VolumeSource(providerConfig *storage.Config) (storage.VolumeSource, error) { if err := p.ValidateConfig(providerConfig); err != nil { return nil, err } source := &cinderVolumeSource{ storageAdapter: p.storageAdapter, envName: p.envName, modelUUID: p.modelUUID, namespace: p.namespace, } return source, nil }
go
func (p *cinderProvider) VolumeSource(providerConfig *storage.Config) (storage.VolumeSource, error) { if err := p.ValidateConfig(providerConfig); err != nil { return nil, err } source := &cinderVolumeSource{ storageAdapter: p.storageAdapter, envName: p.envName, modelUUID: p.modelUUID, namespace: p.namespace, } return source, nil }
[ "func", "(", "p", "*", "cinderProvider", ")", "VolumeSource", "(", "providerConfig", "*", "storage", ".", "Config", ")", "(", "storage", ".", "VolumeSource", ",", "error", ")", "{", "if", "err", ":=", "p", ".", "ValidateConfig", "(", "providerConfig", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "source", ":=", "&", "cinderVolumeSource", "{", "storageAdapter", ":", "p", ".", "storageAdapter", ",", "envName", ":", "p", ".", "envName", ",", "modelUUID", ":", "p", ".", "modelUUID", ",", "namespace", ":", "p", ".", "namespace", ",", "}", "\n", "return", "source", ",", "nil", "\n", "}" ]
// VolumeSource implements storage.Provider.
[ "VolumeSource", "implements", "storage", ".", "Provider", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L153-L164
156,247
juju/juju
provider/openstack/cinder.go
FilesystemSource
func (p *cinderProvider) FilesystemSource(providerConfig *storage.Config) (storage.FilesystemSource, error) { return nil, errors.NotSupportedf("filesystems") }
go
func (p *cinderProvider) FilesystemSource(providerConfig *storage.Config) (storage.FilesystemSource, error) { return nil, errors.NotSupportedf("filesystems") }
[ "func", "(", "p", "*", "cinderProvider", ")", "FilesystemSource", "(", "providerConfig", "*", "storage", ".", "Config", ")", "(", "storage", ".", "FilesystemSource", ",", "error", ")", "{", "return", "nil", ",", "errors", ".", "NotSupportedf", "(", "\"", "\"", ")", "\n", "}" ]
// FilesystemSource implements storage.Provider.
[ "FilesystemSource", "implements", "storage", ".", "Provider", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L167-L169
156,248
juju/juju
provider/openstack/cinder.go
Supports
func (p *cinderProvider) Supports(kind storage.StorageKind) bool { switch kind { case storage.StorageKindBlock: return true } return false }
go
func (p *cinderProvider) Supports(kind storage.StorageKind) bool { switch kind { case storage.StorageKindBlock: return true } return false }
[ "func", "(", "p", "*", "cinderProvider", ")", "Supports", "(", "kind", "storage", ".", "StorageKind", ")", "bool", "{", "switch", "kind", "{", "case", "storage", ".", "StorageKindBlock", ":", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// Supports implements storage.Provider.
[ "Supports", "implements", "storage", ".", "Provider", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L172-L178
156,249
juju/juju
provider/openstack/cinder.go
ValidateConfig
func (p *cinderProvider) ValidateConfig(cfg *storage.Config) error { // TODO(axw) 2015-05-01 #1450737 // Reject attempts to create non-persistent volumes. _, err := newCinderConfig(cfg.Attrs()) return errors.Trace(err) }
go
func (p *cinderProvider) ValidateConfig(cfg *storage.Config) error { // TODO(axw) 2015-05-01 #1450737 // Reject attempts to create non-persistent volumes. _, err := newCinderConfig(cfg.Attrs()) return errors.Trace(err) }
[ "func", "(", "p", "*", "cinderProvider", ")", "ValidateConfig", "(", "cfg", "*", "storage", ".", "Config", ")", "error", "{", "// TODO(axw) 2015-05-01 #1450737", "// Reject attempts to create non-persistent volumes.", "_", ",", "err", ":=", "newCinderConfig", "(", "cfg", ".", "Attrs", "(", ")", ")", "\n", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}" ]
// ValidateConfig implements storage.Provider.
[ "ValidateConfig", "implements", "storage", ".", "Provider", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L186-L191
156,250
juju/juju
provider/openstack/cinder.go
CreateVolumes
func (s *cinderVolumeSource) CreateVolumes(ctx context.ProviderCallContext, args []storage.VolumeParams) ([]storage.CreateVolumesResult, error) { results := make([]storage.CreateVolumesResult, len(args)) for i, arg := range args { volume, err := s.createVolume(arg) if err != nil { results[i].Error = errors.Trace(err) if denied := common.MaybeHandleCredentialError(IsAuthorisationFailure, err, ctx); denied { // If it is an unauthorised error, no need to continue since we will 100% fail... break } continue } results[i].Volume = volume } return results, nil }
go
func (s *cinderVolumeSource) CreateVolumes(ctx context.ProviderCallContext, args []storage.VolumeParams) ([]storage.CreateVolumesResult, error) { results := make([]storage.CreateVolumesResult, len(args)) for i, arg := range args { volume, err := s.createVolume(arg) if err != nil { results[i].Error = errors.Trace(err) if denied := common.MaybeHandleCredentialError(IsAuthorisationFailure, err, ctx); denied { // If it is an unauthorised error, no need to continue since we will 100% fail... break } continue } results[i].Volume = volume } return results, nil }
[ "func", "(", "s", "*", "cinderVolumeSource", ")", "CreateVolumes", "(", "ctx", "context", ".", "ProviderCallContext", ",", "args", "[", "]", "storage", ".", "VolumeParams", ")", "(", "[", "]", "storage", ".", "CreateVolumesResult", ",", "error", ")", "{", "results", ":=", "make", "(", "[", "]", "storage", ".", "CreateVolumesResult", ",", "len", "(", "args", ")", ")", "\n", "for", "i", ",", "arg", ":=", "range", "args", "{", "volume", ",", "err", ":=", "s", ".", "createVolume", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "results", "[", "i", "]", ".", "Error", "=", "errors", ".", "Trace", "(", "err", ")", "\n", "if", "denied", ":=", "common", ".", "MaybeHandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", ";", "denied", "{", "// If it is an unauthorised error, no need to continue since we will 100% fail...", "break", "\n", "}", "\n", "continue", "\n", "}", "\n", "results", "[", "i", "]", ".", "Volume", "=", "volume", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// CreateVolumes implements storage.VolumeSource.
[ "CreateVolumes", "implements", "storage", ".", "VolumeSource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L218-L233
156,251
juju/juju
provider/openstack/cinder.go
modelCinderVolumes
func modelCinderVolumes(storageAdapter OpenstackStorage, modelUUID string) ([]cinder.Volume, error) { return cinderVolumes(storageAdapter, func(v *cinder.Volume) bool { return v.Metadata[tags.JujuModel] == modelUUID }) }
go
func modelCinderVolumes(storageAdapter OpenstackStorage, modelUUID string) ([]cinder.Volume, error) { return cinderVolumes(storageAdapter, func(v *cinder.Volume) bool { return v.Metadata[tags.JujuModel] == modelUUID }) }
[ "func", "modelCinderVolumes", "(", "storageAdapter", "OpenstackStorage", ",", "modelUUID", "string", ")", "(", "[", "]", "cinder", ".", "Volume", ",", "error", ")", "{", "return", "cinderVolumes", "(", "storageAdapter", ",", "func", "(", "v", "*", "cinder", ".", "Volume", ")", "bool", "{", "return", "v", ".", "Metadata", "[", "tags", ".", "JujuModel", "]", "==", "modelUUID", "\n", "}", ")", "\n", "}" ]
// modelCinderVolumes returns all of the cinder volumes for the model.
[ "modelCinderVolumes", "returns", "all", "of", "the", "cinder", "volumes", "for", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L287-L291
156,252
juju/juju
provider/openstack/cinder.go
controllerCinderVolumes
func controllerCinderVolumes(storageAdapter OpenstackStorage, controllerUUID string) ([]cinder.Volume, error) { return cinderVolumes(storageAdapter, func(v *cinder.Volume) bool { return v.Metadata[tags.JujuController] == controllerUUID }) }
go
func controllerCinderVolumes(storageAdapter OpenstackStorage, controllerUUID string) ([]cinder.Volume, error) { return cinderVolumes(storageAdapter, func(v *cinder.Volume) bool { return v.Metadata[tags.JujuController] == controllerUUID }) }
[ "func", "controllerCinderVolumes", "(", "storageAdapter", "OpenstackStorage", ",", "controllerUUID", "string", ")", "(", "[", "]", "cinder", ".", "Volume", ",", "error", ")", "{", "return", "cinderVolumes", "(", "storageAdapter", ",", "func", "(", "v", "*", "cinder", ".", "Volume", ")", "bool", "{", "return", "v", ".", "Metadata", "[", "tags", ".", "JujuController", "]", "==", "controllerUUID", "\n", "}", ")", "\n", "}" ]
// controllerCinderVolumes returns all of the cinder volumes for the model.
[ "controllerCinderVolumes", "returns", "all", "of", "the", "cinder", "volumes", "for", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L294-L298
156,253
juju/juju
provider/openstack/cinder.go
cinderVolumes
func cinderVolumes(storageAdapter OpenstackStorage, pred func(*cinder.Volume) bool) ([]cinder.Volume, error) { allCinderVolumes, err := storageAdapter.GetVolumesDetail() if err != nil { return nil, err } var matching []cinder.Volume for _, v := range allCinderVolumes { if pred(&v) { matching = append(matching, v) } } return matching, nil }
go
func cinderVolumes(storageAdapter OpenstackStorage, pred func(*cinder.Volume) bool) ([]cinder.Volume, error) { allCinderVolumes, err := storageAdapter.GetVolumesDetail() if err != nil { return nil, err } var matching []cinder.Volume for _, v := range allCinderVolumes { if pred(&v) { matching = append(matching, v) } } return matching, nil }
[ "func", "cinderVolumes", "(", "storageAdapter", "OpenstackStorage", ",", "pred", "func", "(", "*", "cinder", ".", "Volume", ")", "bool", ")", "(", "[", "]", "cinder", ".", "Volume", ",", "error", ")", "{", "allCinderVolumes", ",", "err", ":=", "storageAdapter", ".", "GetVolumesDetail", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "matching", "[", "]", "cinder", ".", "Volume", "\n", "for", "_", ",", "v", ":=", "range", "allCinderVolumes", "{", "if", "pred", "(", "&", "v", ")", "{", "matching", "=", "append", "(", "matching", ",", "v", ")", "\n", "}", "\n", "}", "\n", "return", "matching", ",", "nil", "\n", "}" ]
// cinderVolumes returns all of the cinder volumes matching the given predicate.
[ "cinderVolumes", "returns", "all", "of", "the", "cinder", "volumes", "matching", "the", "given", "predicate", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L301-L313
156,254
juju/juju
provider/openstack/cinder.go
DescribeVolumes
func (s *cinderVolumeSource) DescribeVolumes(ctx context.ProviderCallContext, volumeIds []string) ([]storage.DescribeVolumesResult, error) { // In most cases, it is quicker to get all volumes and loop // locally than to make several round-trips to the provider. cinderVolumes, err := s.storageAdapter.GetVolumesDetail() if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return nil, errors.Trace(err) } volumesById := make(map[string]*cinder.Volume) for i, volume := range cinderVolumes { volumesById[volume.ID] = &cinderVolumes[i] } results := make([]storage.DescribeVolumesResult, len(volumeIds)) for i, volumeId := range volumeIds { cinderVolume, ok := volumesById[volumeId] if !ok { results[i].Error = errors.NotFoundf("volume %q", volumeId) continue } info := cinderToJujuVolumeInfo(cinderVolume) results[i].VolumeInfo = &info } return results, nil }
go
func (s *cinderVolumeSource) DescribeVolumes(ctx context.ProviderCallContext, volumeIds []string) ([]storage.DescribeVolumesResult, error) { // In most cases, it is quicker to get all volumes and loop // locally than to make several round-trips to the provider. cinderVolumes, err := s.storageAdapter.GetVolumesDetail() if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return nil, errors.Trace(err) } volumesById := make(map[string]*cinder.Volume) for i, volume := range cinderVolumes { volumesById[volume.ID] = &cinderVolumes[i] } results := make([]storage.DescribeVolumesResult, len(volumeIds)) for i, volumeId := range volumeIds { cinderVolume, ok := volumesById[volumeId] if !ok { results[i].Error = errors.NotFoundf("volume %q", volumeId) continue } info := cinderToJujuVolumeInfo(cinderVolume) results[i].VolumeInfo = &info } return results, nil }
[ "func", "(", "s", "*", "cinderVolumeSource", ")", "DescribeVolumes", "(", "ctx", "context", ".", "ProviderCallContext", ",", "volumeIds", "[", "]", "string", ")", "(", "[", "]", "storage", ".", "DescribeVolumesResult", ",", "error", ")", "{", "// In most cases, it is quicker to get all volumes and loop", "// locally than to make several round-trips to the provider.", "cinderVolumes", ",", "err", ":=", "s", ".", "storageAdapter", ".", "GetVolumesDetail", "(", ")", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "volumesById", ":=", "make", "(", "map", "[", "string", "]", "*", "cinder", ".", "Volume", ")", "\n", "for", "i", ",", "volume", ":=", "range", "cinderVolumes", "{", "volumesById", "[", "volume", ".", "ID", "]", "=", "&", "cinderVolumes", "[", "i", "]", "\n", "}", "\n", "results", ":=", "make", "(", "[", "]", "storage", ".", "DescribeVolumesResult", ",", "len", "(", "volumeIds", ")", ")", "\n", "for", "i", ",", "volumeId", ":=", "range", "volumeIds", "{", "cinderVolume", ",", "ok", ":=", "volumesById", "[", "volumeId", "]", "\n", "if", "!", "ok", "{", "results", "[", "i", "]", ".", "Error", "=", "errors", ".", "NotFoundf", "(", "\"", "\"", ",", "volumeId", ")", "\n", "continue", "\n", "}", "\n", "info", ":=", "cinderToJujuVolumeInfo", "(", "cinderVolume", ")", "\n", "results", "[", "i", "]", ".", "VolumeInfo", "=", "&", "info", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// DescribeVolumes implements storage.VolumeSource.
[ "DescribeVolumes", "implements", "storage", ".", "VolumeSource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L324-L347
156,255
juju/juju
provider/openstack/cinder.go
DestroyVolumes
func (s *cinderVolumeSource) DestroyVolumes(ctx context.ProviderCallContext, volumeIds []string) ([]error, error) { return foreachVolume(ctx, s.storageAdapter, volumeIds, destroyVolume), nil }
go
func (s *cinderVolumeSource) DestroyVolumes(ctx context.ProviderCallContext, volumeIds []string) ([]error, error) { return foreachVolume(ctx, s.storageAdapter, volumeIds, destroyVolume), nil }
[ "func", "(", "s", "*", "cinderVolumeSource", ")", "DestroyVolumes", "(", "ctx", "context", ".", "ProviderCallContext", ",", "volumeIds", "[", "]", "string", ")", "(", "[", "]", "error", ",", "error", ")", "{", "return", "foreachVolume", "(", "ctx", ",", "s", ".", "storageAdapter", ",", "volumeIds", ",", "destroyVolume", ")", ",", "nil", "\n", "}" ]
// DestroyVolumes implements storage.VolumeSource.
[ "DestroyVolumes", "implements", "storage", ".", "VolumeSource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L350-L352
156,256
juju/juju
provider/openstack/cinder.go
ReleaseVolumes
func (s *cinderVolumeSource) ReleaseVolumes(ctx context.ProviderCallContext, volumeIds []string) ([]error, error) { return foreachVolume(ctx, s.storageAdapter, volumeIds, releaseVolume), nil }
go
func (s *cinderVolumeSource) ReleaseVolumes(ctx context.ProviderCallContext, volumeIds []string) ([]error, error) { return foreachVolume(ctx, s.storageAdapter, volumeIds, releaseVolume), nil }
[ "func", "(", "s", "*", "cinderVolumeSource", ")", "ReleaseVolumes", "(", "ctx", "context", ".", "ProviderCallContext", ",", "volumeIds", "[", "]", "string", ")", "(", "[", "]", "error", ",", "error", ")", "{", "return", "foreachVolume", "(", "ctx", ",", "s", ".", "storageAdapter", ",", "volumeIds", ",", "releaseVolume", ")", ",", "nil", "\n", "}" ]
// ReleaseVolumes implements storage.VolumeSource.
[ "ReleaseVolumes", "implements", "storage", ".", "VolumeSource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L355-L357
156,257
juju/juju
provider/openstack/cinder.go
ValidateVolumeParams
func (s *cinderVolumeSource) ValidateVolumeParams(params storage.VolumeParams) error { _, err := newCinderConfig(params.Attributes) return errors.Trace(err) }
go
func (s *cinderVolumeSource) ValidateVolumeParams(params storage.VolumeParams) error { _, err := newCinderConfig(params.Attributes) return errors.Trace(err) }
[ "func", "(", "s", "*", "cinderVolumeSource", ")", "ValidateVolumeParams", "(", "params", "storage", ".", "VolumeParams", ")", "error", "{", "_", ",", "err", ":=", "newCinderConfig", "(", "params", ".", "Attributes", ")", "\n", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}" ]
// ValidateVolumeParams implements storage.VolumeSource.
[ "ValidateVolumeParams", "implements", "storage", ".", "VolumeSource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L458-L461
156,258
juju/juju
provider/openstack/cinder.go
AttachVolumes
func (s *cinderVolumeSource) AttachVolumes(ctx context.ProviderCallContext, args []storage.VolumeAttachmentParams) ([]storage.AttachVolumesResult, error) { results := make([]storage.AttachVolumesResult, len(args)) for i, arg := range args { attachment, err := s.attachVolume(arg) if err != nil { results[i].Error = errors.Trace(err) if denial := common.MaybeHandleCredentialError(IsAuthorisationFailure, err, ctx); denial { // We do not want to continue here as we'll 100% fail if we got unauthorised error. break } continue } results[i].VolumeAttachment = attachment } return results, nil }
go
func (s *cinderVolumeSource) AttachVolumes(ctx context.ProviderCallContext, args []storage.VolumeAttachmentParams) ([]storage.AttachVolumesResult, error) { results := make([]storage.AttachVolumesResult, len(args)) for i, arg := range args { attachment, err := s.attachVolume(arg) if err != nil { results[i].Error = errors.Trace(err) if denial := common.MaybeHandleCredentialError(IsAuthorisationFailure, err, ctx); denial { // We do not want to continue here as we'll 100% fail if we got unauthorised error. break } continue } results[i].VolumeAttachment = attachment } return results, nil }
[ "func", "(", "s", "*", "cinderVolumeSource", ")", "AttachVolumes", "(", "ctx", "context", ".", "ProviderCallContext", ",", "args", "[", "]", "storage", ".", "VolumeAttachmentParams", ")", "(", "[", "]", "storage", ".", "AttachVolumesResult", ",", "error", ")", "{", "results", ":=", "make", "(", "[", "]", "storage", ".", "AttachVolumesResult", ",", "len", "(", "args", ")", ")", "\n", "for", "i", ",", "arg", ":=", "range", "args", "{", "attachment", ",", "err", ":=", "s", ".", "attachVolume", "(", "arg", ")", "\n", "if", "err", "!=", "nil", "{", "results", "[", "i", "]", ".", "Error", "=", "errors", ".", "Trace", "(", "err", ")", "\n", "if", "denial", ":=", "common", ".", "MaybeHandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", ";", "denial", "{", "// We do not want to continue here as we'll 100% fail if we got unauthorised error.", "break", "\n", "}", "\n", "continue", "\n", "}", "\n", "results", "[", "i", "]", ".", "VolumeAttachment", "=", "attachment", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// AttachVolumes implements storage.VolumeSource.
[ "AttachVolumes", "implements", "storage", ".", "VolumeSource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L464-L479
156,259
juju/juju
provider/openstack/cinder.go
ImportVolume
func (s *cinderVolumeSource) ImportVolume(ctx context.ProviderCallContext, volumeId string, resourceTags map[string]string) (storage.VolumeInfo, error) { volume, err := s.storageAdapter.GetVolume(volumeId) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return storage.VolumeInfo{}, errors.Annotate(err, "getting volume") } if volume.Status != volumeStatusAvailable { return storage.VolumeInfo{}, errors.Errorf( "cannot import volume %q with status %q", volumeId, volume.Status, ) } if _, err := s.storageAdapter.SetVolumeMetadata(volumeId, resourceTags); err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return storage.VolumeInfo{}, errors.Annotatef(err, "tagging volume %q", volumeId) } return cinderToJujuVolumeInfo(volume), nil }
go
func (s *cinderVolumeSource) ImportVolume(ctx context.ProviderCallContext, volumeId string, resourceTags map[string]string) (storage.VolumeInfo, error) { volume, err := s.storageAdapter.GetVolume(volumeId) if err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return storage.VolumeInfo{}, errors.Annotate(err, "getting volume") } if volume.Status != volumeStatusAvailable { return storage.VolumeInfo{}, errors.Errorf( "cannot import volume %q with status %q", volumeId, volume.Status, ) } if _, err := s.storageAdapter.SetVolumeMetadata(volumeId, resourceTags); err != nil { common.HandleCredentialError(IsAuthorisationFailure, err, ctx) return storage.VolumeInfo{}, errors.Annotatef(err, "tagging volume %q", volumeId) } return cinderToJujuVolumeInfo(volume), nil }
[ "func", "(", "s", "*", "cinderVolumeSource", ")", "ImportVolume", "(", "ctx", "context", ".", "ProviderCallContext", ",", "volumeId", "string", ",", "resourceTags", "map", "[", "string", "]", "string", ")", "(", "storage", ".", "VolumeInfo", ",", "error", ")", "{", "volume", ",", "err", ":=", "s", ".", "storageAdapter", ".", "GetVolume", "(", "volumeId", ")", "\n", "if", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "storage", ".", "VolumeInfo", "{", "}", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "if", "volume", ".", "Status", "!=", "volumeStatusAvailable", "{", "return", "storage", ".", "VolumeInfo", "{", "}", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "volumeId", ",", "volume", ".", "Status", ",", ")", "\n", "}", "\n", "if", "_", ",", "err", ":=", "s", ".", "storageAdapter", ".", "SetVolumeMetadata", "(", "volumeId", ",", "resourceTags", ")", ";", "err", "!=", "nil", "{", "common", ".", "HandleCredentialError", "(", "IsAuthorisationFailure", ",", "err", ",", "ctx", ")", "\n", "return", "storage", ".", "VolumeInfo", "{", "}", ",", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "volumeId", ")", "\n", "}", "\n", "return", "cinderToJujuVolumeInfo", "(", "volume", ")", ",", "nil", "\n", "}" ]
// ImportVolume is part of the storage.VolumeImporter interface.
[ "ImportVolume", "is", "part", "of", "the", "storage", ".", "VolumeImporter", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L517-L533
156,260
juju/juju
provider/openstack/cinder.go
DetachVolumes
func (s *cinderVolumeSource) DetachVolumes(ctx context.ProviderCallContext, args []storage.VolumeAttachmentParams) ([]error, error) { return detachVolumes(ctx, s.storageAdapter, args), nil }
go
func (s *cinderVolumeSource) DetachVolumes(ctx context.ProviderCallContext, args []storage.VolumeAttachmentParams) ([]error, error) { return detachVolumes(ctx, s.storageAdapter, args), nil }
[ "func", "(", "s", "*", "cinderVolumeSource", ")", "DetachVolumes", "(", "ctx", "context", ".", "ProviderCallContext", ",", "args", "[", "]", "storage", ".", "VolumeAttachmentParams", ")", "(", "[", "]", "error", ",", "error", ")", "{", "return", "detachVolumes", "(", "ctx", ",", "s", ".", "storageAdapter", ",", "args", ")", ",", "nil", "\n", "}" ]
// DetachVolumes implements storage.VolumeSource.
[ "DetachVolumes", "implements", "storage", ".", "VolumeSource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L557-L559
156,261
juju/juju
provider/openstack/cinder.go
CreateVolume
func (ga *openstackStorageAdapter) CreateVolume(args cinder.CreateVolumeVolumeParams) (*cinder.Volume, error) { resp, err := ga.cinderClient.CreateVolume(args) if err != nil { return nil, err } return &resp.Volume, nil }
go
func (ga *openstackStorageAdapter) CreateVolume(args cinder.CreateVolumeVolumeParams) (*cinder.Volume, error) { resp, err := ga.cinderClient.CreateVolume(args) if err != nil { return nil, err } return &resp.Volume, nil }
[ "func", "(", "ga", "*", "openstackStorageAdapter", ")", "CreateVolume", "(", "args", "cinder", ".", "CreateVolumeVolumeParams", ")", "(", "*", "cinder", ".", "Volume", ",", "error", ")", "{", "resp", ",", "err", ":=", "ga", ".", "cinderClient", ".", "CreateVolume", "(", "args", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "resp", ".", "Volume", ",", "nil", "\n", "}" ]
// CreateVolume is part of the OpenstackStorage interface.
[ "CreateVolume", "is", "part", "of", "the", "OpenstackStorage", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L665-L671
156,262
juju/juju
provider/openstack/cinder.go
GetVolumesDetail
func (ga *openstackStorageAdapter) GetVolumesDetail() ([]cinder.Volume, error) { resp, err := ga.cinderClient.GetVolumesDetail() if err != nil { return nil, err } return resp.Volumes, nil }
go
func (ga *openstackStorageAdapter) GetVolumesDetail() ([]cinder.Volume, error) { resp, err := ga.cinderClient.GetVolumesDetail() if err != nil { return nil, err } return resp.Volumes, nil }
[ "func", "(", "ga", "*", "openstackStorageAdapter", ")", "GetVolumesDetail", "(", ")", "(", "[", "]", "cinder", ".", "Volume", ",", "error", ")", "{", "resp", ",", "err", ":=", "ga", ".", "cinderClient", ".", "GetVolumesDetail", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "return", "resp", ".", "Volumes", ",", "nil", "\n", "}" ]
// GetVolumesDetail is part of the OpenstackStorage interface.
[ "GetVolumesDetail", "is", "part", "of", "the", "OpenstackStorage", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L674-L680
156,263
juju/juju
provider/openstack/cinder.go
GetVolume
func (ga *openstackStorageAdapter) GetVolume(volumeId string) (*cinder.Volume, error) { resp, err := ga.cinderClient.GetVolume(volumeId) if err != nil { if gooseerrors.IsNotFound(err) { return nil, errors.NotFoundf("volume %q", volumeId) } return nil, err } return &resp.Volume, nil }
go
func (ga *openstackStorageAdapter) GetVolume(volumeId string) (*cinder.Volume, error) { resp, err := ga.cinderClient.GetVolume(volumeId) if err != nil { if gooseerrors.IsNotFound(err) { return nil, errors.NotFoundf("volume %q", volumeId) } return nil, err } return &resp.Volume, nil }
[ "func", "(", "ga", "*", "openstackStorageAdapter", ")", "GetVolume", "(", "volumeId", "string", ")", "(", "*", "cinder", ".", "Volume", ",", "error", ")", "{", "resp", ",", "err", ":=", "ga", ".", "cinderClient", ".", "GetVolume", "(", "volumeId", ")", "\n", "if", "err", "!=", "nil", "{", "if", "gooseerrors", ".", "IsNotFound", "(", "err", ")", "{", "return", "nil", ",", "errors", ".", "NotFoundf", "(", "\"", "\"", ",", "volumeId", ")", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "resp", ".", "Volume", ",", "nil", "\n", "}" ]
// GetVolume is part of the OpenstackStorage interface.
[ "GetVolume", "is", "part", "of", "the", "OpenstackStorage", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L683-L692
156,264
juju/juju
provider/openstack/cinder.go
SetVolumeMetadata
func (ga *openstackStorageAdapter) SetVolumeMetadata(volumeId string, metadata map[string]string) (map[string]string, error) { return ga.cinderClient.SetVolumeMetadata(volumeId, metadata) }
go
func (ga *openstackStorageAdapter) SetVolumeMetadata(volumeId string, metadata map[string]string) (map[string]string, error) { return ga.cinderClient.SetVolumeMetadata(volumeId, metadata) }
[ "func", "(", "ga", "*", "openstackStorageAdapter", ")", "SetVolumeMetadata", "(", "volumeId", "string", ",", "metadata", "map", "[", "string", "]", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "return", "ga", ".", "cinderClient", ".", "SetVolumeMetadata", "(", "volumeId", ",", "metadata", ")", "\n", "}" ]
// SetVolumeMetadata is part of the OpenstackStorage interface.
[ "SetVolumeMetadata", "is", "part", "of", "the", "OpenstackStorage", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L695-L697
156,265
juju/juju
provider/openstack/cinder.go
DeleteVolume
func (ga *openstackStorageAdapter) DeleteVolume(volumeId string) error { if err := ga.cinderClient.DeleteVolume(volumeId); err != nil { if gooseerrors.IsNotFound(err) { return errors.NotFoundf("volume %q", volumeId) } return err } return nil }
go
func (ga *openstackStorageAdapter) DeleteVolume(volumeId string) error { if err := ga.cinderClient.DeleteVolume(volumeId); err != nil { if gooseerrors.IsNotFound(err) { return errors.NotFoundf("volume %q", volumeId) } return err } return nil }
[ "func", "(", "ga", "*", "openstackStorageAdapter", ")", "DeleteVolume", "(", "volumeId", "string", ")", "error", "{", "if", "err", ":=", "ga", ".", "cinderClient", ".", "DeleteVolume", "(", "volumeId", ")", ";", "err", "!=", "nil", "{", "if", "gooseerrors", ".", "IsNotFound", "(", "err", ")", "{", "return", "errors", ".", "NotFoundf", "(", "\"", "\"", ",", "volumeId", ")", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// DeleteVolume is part of the OpenstackStorage interface.
[ "DeleteVolume", "is", "part", "of", "the", "OpenstackStorage", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L700-L708
156,266
juju/juju
provider/openstack/cinder.go
DetachVolume
func (ga *openstackStorageAdapter) DetachVolume(serverId, attachmentId string) error { if err := ga.novaClient.DetachVolume(serverId, attachmentId); err != nil { if gooseerrors.IsNotFound(err) { return errors.NewNotFound(nil, fmt.Sprintf("volume %q is not attached to server %q", attachmentId, serverId, ), ) } return err } return nil }
go
func (ga *openstackStorageAdapter) DetachVolume(serverId, attachmentId string) error { if err := ga.novaClient.DetachVolume(serverId, attachmentId); err != nil { if gooseerrors.IsNotFound(err) { return errors.NewNotFound(nil, fmt.Sprintf("volume %q is not attached to server %q", attachmentId, serverId, ), ) } return err } return nil }
[ "func", "(", "ga", "*", "openstackStorageAdapter", ")", "DetachVolume", "(", "serverId", ",", "attachmentId", "string", ")", "error", "{", "if", "err", ":=", "ga", ".", "novaClient", ".", "DetachVolume", "(", "serverId", ",", "attachmentId", ")", ";", "err", "!=", "nil", "{", "if", "gooseerrors", ".", "IsNotFound", "(", "err", ")", "{", "return", "errors", ".", "NewNotFound", "(", "nil", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "attachmentId", ",", "serverId", ",", ")", ",", ")", "\n", "}", "\n", "return", "err", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// DetachVolume is part of the OpenstackStorage interface.
[ "DetachVolume", "is", "part", "of", "the", "OpenstackStorage", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/openstack/cinder.go#L711-L723
156,267
juju/juju
apiserver/facades/agent/keyupdater/authorisedkeys.go
NewKeyUpdaterAPI
func NewKeyUpdaterAPI( st *state.State, resources facade.Resources, authorizer facade.Authorizer, ) (*KeyUpdaterAPI, error) { // Only machine agents have access to the keyupdater service. if !authorizer.AuthMachineAgent() { return nil, common.ErrPerm } // No-one else except the machine itself can only read a machine's own credentials. getCanRead := func() (common.AuthFunc, error) { return authorizer.AuthOwner, nil } m, err := st.Model() if err != nil { return nil, errors.Trace(err) } return &KeyUpdaterAPI{state: st, model: m, resources: resources, authorizer: authorizer, getCanRead: getCanRead}, nil }
go
func NewKeyUpdaterAPI( st *state.State, resources facade.Resources, authorizer facade.Authorizer, ) (*KeyUpdaterAPI, error) { // Only machine agents have access to the keyupdater service. if !authorizer.AuthMachineAgent() { return nil, common.ErrPerm } // No-one else except the machine itself can only read a machine's own credentials. getCanRead := func() (common.AuthFunc, error) { return authorizer.AuthOwner, nil } m, err := st.Model() if err != nil { return nil, errors.Trace(err) } return &KeyUpdaterAPI{state: st, model: m, resources: resources, authorizer: authorizer, getCanRead: getCanRead}, nil }
[ "func", "NewKeyUpdaterAPI", "(", "st", "*", "state", ".", "State", ",", "resources", "facade", ".", "Resources", ",", "authorizer", "facade", ".", "Authorizer", ",", ")", "(", "*", "KeyUpdaterAPI", ",", "error", ")", "{", "// Only machine agents have access to the keyupdater service.", "if", "!", "authorizer", ".", "AuthMachineAgent", "(", ")", "{", "return", "nil", ",", "common", ".", "ErrPerm", "\n", "}", "\n", "// No-one else except the machine itself can only read a machine's own credentials.", "getCanRead", ":=", "func", "(", ")", "(", "common", ".", "AuthFunc", ",", "error", ")", "{", "return", "authorizer", ".", "AuthOwner", ",", "nil", "\n", "}", "\n", "m", ",", "err", ":=", "st", ".", "Model", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "&", "KeyUpdaterAPI", "{", "state", ":", "st", ",", "model", ":", "m", ",", "resources", ":", "resources", ",", "authorizer", ":", "authorizer", ",", "getCanRead", ":", "getCanRead", "}", ",", "nil", "\n", "}" ]
// NewKeyUpdaterAPI creates a new server-side keyupdater API end point.
[ "NewKeyUpdaterAPI", "creates", "a", "new", "server", "-", "side", "keyupdater", "API", "end", "point", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/keyupdater/authorisedkeys.go#L37-L55
156,268
juju/juju
apiserver/facades/agent/keyupdater/authorisedkeys.go
WatchAuthorisedKeys
func (api *KeyUpdaterAPI) WatchAuthorisedKeys(arg params.Entities) (params.NotifyWatchResults, error) { results := make([]params.NotifyWatchResult, len(arg.Entities)) canRead, err := api.getCanRead() if err != nil { return params.NotifyWatchResults{}, err } for i, entity := range arg.Entities { tag, err := names.ParseTag(entity.Tag) if err != nil { results[i].Error = common.ServerError(err) continue } // 1. Check permissions if !canRead(tag) { results[i].Error = common.ServerError(common.ErrPerm) continue } // 2. Check entity exists if _, err := api.state.FindEntity(tag); err != nil { if errors.IsNotFound(err) { results[i].Error = common.ServerError(common.ErrPerm) } else { results[i].Error = common.ServerError(err) } continue } // 3. Watch for changes watch := api.model.WatchForModelConfigChanges() // Consume the initial event. if _, ok := <-watch.Changes(); ok { results[i].NotifyWatcherId = api.resources.Register(watch) } else { err = watcher.EnsureErr(watch) } results[i].Error = common.ServerError(err) } return params.NotifyWatchResults{Results: results}, nil }
go
func (api *KeyUpdaterAPI) WatchAuthorisedKeys(arg params.Entities) (params.NotifyWatchResults, error) { results := make([]params.NotifyWatchResult, len(arg.Entities)) canRead, err := api.getCanRead() if err != nil { return params.NotifyWatchResults{}, err } for i, entity := range arg.Entities { tag, err := names.ParseTag(entity.Tag) if err != nil { results[i].Error = common.ServerError(err) continue } // 1. Check permissions if !canRead(tag) { results[i].Error = common.ServerError(common.ErrPerm) continue } // 2. Check entity exists if _, err := api.state.FindEntity(tag); err != nil { if errors.IsNotFound(err) { results[i].Error = common.ServerError(common.ErrPerm) } else { results[i].Error = common.ServerError(err) } continue } // 3. Watch for changes watch := api.model.WatchForModelConfigChanges() // Consume the initial event. if _, ok := <-watch.Changes(); ok { results[i].NotifyWatcherId = api.resources.Register(watch) } else { err = watcher.EnsureErr(watch) } results[i].Error = common.ServerError(err) } return params.NotifyWatchResults{Results: results}, nil }
[ "func", "(", "api", "*", "KeyUpdaterAPI", ")", "WatchAuthorisedKeys", "(", "arg", "params", ".", "Entities", ")", "(", "params", ".", "NotifyWatchResults", ",", "error", ")", "{", "results", ":=", "make", "(", "[", "]", "params", ".", "NotifyWatchResult", ",", "len", "(", "arg", ".", "Entities", ")", ")", "\n\n", "canRead", ",", "err", ":=", "api", ".", "getCanRead", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "NotifyWatchResults", "{", "}", ",", "err", "\n", "}", "\n", "for", "i", ",", "entity", ":=", "range", "arg", ".", "Entities", "{", "tag", ",", "err", ":=", "names", ".", "ParseTag", "(", "entity", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n", "// 1. Check permissions", "if", "!", "canRead", "(", "tag", ")", "{", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "common", ".", "ErrPerm", ")", "\n", "continue", "\n", "}", "\n", "// 2. Check entity exists", "if", "_", ",", "err", ":=", "api", ".", "state", ".", "FindEntity", "(", "tag", ")", ";", "err", "!=", "nil", "{", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "common", ".", "ErrPerm", ")", "\n", "}", "else", "{", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "continue", "\n", "}", "\n", "// 3. Watch for changes", "watch", ":=", "api", ".", "model", ".", "WatchForModelConfigChanges", "(", ")", "\n", "// Consume the initial event.", "if", "_", ",", "ok", ":=", "<-", "watch", ".", "Changes", "(", ")", ";", "ok", "{", "results", "[", "i", "]", ".", "NotifyWatcherId", "=", "api", ".", "resources", ".", "Register", "(", "watch", ")", "\n", "}", "else", "{", "err", "=", "watcher", ".", "EnsureErr", "(", "watch", ")", "\n", "}", "\n", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "params", ".", "NotifyWatchResults", "{", "Results", ":", "results", "}", ",", "nil", "\n", "}" ]
// WatchAuthorisedKeys starts a watcher to track changes to the authorised ssh keys // for the specified machines. // The current implementation relies on global authorised keys being stored in the model config. // This will change as new user management and authorisation functionality is added.
[ "WatchAuthorisedKeys", "starts", "a", "watcher", "to", "track", "changes", "to", "the", "authorised", "ssh", "keys", "for", "the", "specified", "machines", ".", "The", "current", "implementation", "relies", "on", "global", "authorised", "keys", "being", "stored", "in", "the", "model", "config", ".", "This", "will", "change", "as", "new", "user", "management", "and", "authorisation", "functionality", "is", "added", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/keyupdater/authorisedkeys.go#L61-L99
156,269
juju/juju
apiserver/facades/agent/keyupdater/authorisedkeys.go
AuthorisedKeys
func (api *KeyUpdaterAPI) AuthorisedKeys(arg params.Entities) (params.StringsResults, error) { if len(arg.Entities) == 0 { return params.StringsResults{}, nil } results := make([]params.StringsResult, len(arg.Entities)) // For now, authorised keys are global, common to all machines. var keys []string config, configErr := api.model.ModelConfig() if configErr == nil { keys = ssh.SplitAuthorisedKeys(config.AuthorizedKeys()) } canRead, err := api.getCanRead() if err != nil { return params.StringsResults{}, err } for i, entity := range arg.Entities { tag, err := names.ParseTag(entity.Tag) if err != nil { results[i].Error = common.ServerError(err) continue } // 1. Check permissions if !canRead(tag) { results[i].Error = common.ServerError(common.ErrPerm) continue } // 2. Check entity exists if _, err := api.state.FindEntity(tag); err != nil { if errors.IsNotFound(err) { results[i].Error = common.ServerError(common.ErrPerm) } else { results[i].Error = common.ServerError(err) } continue } // 3. Get keys if configErr == nil { results[i].Result = keys } else { err = configErr } results[i].Error = common.ServerError(err) } return params.StringsResults{Results: results}, nil }
go
func (api *KeyUpdaterAPI) AuthorisedKeys(arg params.Entities) (params.StringsResults, error) { if len(arg.Entities) == 0 { return params.StringsResults{}, nil } results := make([]params.StringsResult, len(arg.Entities)) // For now, authorised keys are global, common to all machines. var keys []string config, configErr := api.model.ModelConfig() if configErr == nil { keys = ssh.SplitAuthorisedKeys(config.AuthorizedKeys()) } canRead, err := api.getCanRead() if err != nil { return params.StringsResults{}, err } for i, entity := range arg.Entities { tag, err := names.ParseTag(entity.Tag) if err != nil { results[i].Error = common.ServerError(err) continue } // 1. Check permissions if !canRead(tag) { results[i].Error = common.ServerError(common.ErrPerm) continue } // 2. Check entity exists if _, err := api.state.FindEntity(tag); err != nil { if errors.IsNotFound(err) { results[i].Error = common.ServerError(common.ErrPerm) } else { results[i].Error = common.ServerError(err) } continue } // 3. Get keys if configErr == nil { results[i].Result = keys } else { err = configErr } results[i].Error = common.ServerError(err) } return params.StringsResults{Results: results}, nil }
[ "func", "(", "api", "*", "KeyUpdaterAPI", ")", "AuthorisedKeys", "(", "arg", "params", ".", "Entities", ")", "(", "params", ".", "StringsResults", ",", "error", ")", "{", "if", "len", "(", "arg", ".", "Entities", ")", "==", "0", "{", "return", "params", ".", "StringsResults", "{", "}", ",", "nil", "\n", "}", "\n", "results", ":=", "make", "(", "[", "]", "params", ".", "StringsResult", ",", "len", "(", "arg", ".", "Entities", ")", ")", "\n\n", "// For now, authorised keys are global, common to all machines.", "var", "keys", "[", "]", "string", "\n", "config", ",", "configErr", ":=", "api", ".", "model", ".", "ModelConfig", "(", ")", "\n", "if", "configErr", "==", "nil", "{", "keys", "=", "ssh", ".", "SplitAuthorisedKeys", "(", "config", ".", "AuthorizedKeys", "(", ")", ")", "\n", "}", "\n\n", "canRead", ",", "err", ":=", "api", ".", "getCanRead", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "StringsResults", "{", "}", ",", "err", "\n", "}", "\n", "for", "i", ",", "entity", ":=", "range", "arg", ".", "Entities", "{", "tag", ",", "err", ":=", "names", ".", "ParseTag", "(", "entity", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n", "// 1. Check permissions", "if", "!", "canRead", "(", "tag", ")", "{", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "common", ".", "ErrPerm", ")", "\n", "continue", "\n", "}", "\n", "// 2. Check entity exists", "if", "_", ",", "err", ":=", "api", ".", "state", ".", "FindEntity", "(", "tag", ")", ";", "err", "!=", "nil", "{", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "common", ".", "ErrPerm", ")", "\n", "}", "else", "{", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "continue", "\n", "}", "\n", "// 3. Get keys", "if", "configErr", "==", "nil", "{", "results", "[", "i", "]", ".", "Result", "=", "keys", "\n", "}", "else", "{", "err", "=", "configErr", "\n", "}", "\n", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "params", ".", "StringsResults", "{", "Results", ":", "results", "}", ",", "nil", "\n", "}" ]
// AuthorisedKeys reports the authorised ssh keys for the specified machines. // The current implementation relies on global authorised keys being stored in the model config. // This will change as new user management and authorisation functionality is added.
[ "AuthorisedKeys", "reports", "the", "authorised", "ssh", "keys", "for", "the", "specified", "machines", ".", "The", "current", "implementation", "relies", "on", "global", "authorised", "keys", "being", "stored", "in", "the", "model", "config", ".", "This", "will", "change", "as", "new", "user", "management", "and", "authorisation", "functionality", "is", "added", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/keyupdater/authorisedkeys.go#L104-L150
156,270
juju/juju
worker/raft/rafttransport/worker.go
NewWorker
func NewWorker(config Config) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } apiPorts := config.APIInfo.Ports() if n := len(apiPorts); n != 1 { return nil, errors.Errorf("api.Info has %d unique ports, expected 1", n) } w := &Worker{ config: config, connections: make(chan net.Conn), dialRequests: make(chan dialRequest), apiPort: apiPorts[0], } const logPrefix = "[transport] " logWriter := &raftutil.LoggoWriter{logger, loggo.DEBUG} logLogger := log.New(logWriter, logPrefix, 0) stream, err := newStreamLayer(config.LocalID, config.Hub, w.connections, config.Clock, &Dialer{ APIInfo: config.APIInfo, DialRaw: w.dialRaw, Path: config.Path, }) if err != nil { return nil, errors.Trace(err) } transport := raft.NewNetworkTransportWithConfig(&raft.NetworkTransportConfig{ Logger: logLogger, MaxPool: maxPoolSize, Stream: stream, Timeout: config.Timeout, }) w.Transport = transport var h http.Handler = NewHandler(w.connections, w.catacomb.Dying()) h = &httpcontext.BasicAuthHandler{ Handler: h, Authenticator: w.config.Authenticator, Authorizer: httpcontext.AuthorizerFunc(controllerAuthorizer), } h = &httpcontext.ImpliedModelHandler{ Handler: h, ModelUUID: w.config.APIInfo.ModelTag.Id(), } w.config.Mux.AddHandler("GET", w.config.Path, h) if err := catacomb.Invoke(catacomb.Plan{ Site: &w.catacomb, Work: func() error { defer transport.Close() defer w.config.Mux.RemoveHandler("GET", w.config.Path) return w.loop() }, Init: []worker.Worker{stream}, }); err != nil { transport.Close() w.config.Mux.RemoveHandler("GET", w.config.Path) return nil, errors.Trace(err) } return w, nil }
go
func NewWorker(config Config) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } apiPorts := config.APIInfo.Ports() if n := len(apiPorts); n != 1 { return nil, errors.Errorf("api.Info has %d unique ports, expected 1", n) } w := &Worker{ config: config, connections: make(chan net.Conn), dialRequests: make(chan dialRequest), apiPort: apiPorts[0], } const logPrefix = "[transport] " logWriter := &raftutil.LoggoWriter{logger, loggo.DEBUG} logLogger := log.New(logWriter, logPrefix, 0) stream, err := newStreamLayer(config.LocalID, config.Hub, w.connections, config.Clock, &Dialer{ APIInfo: config.APIInfo, DialRaw: w.dialRaw, Path: config.Path, }) if err != nil { return nil, errors.Trace(err) } transport := raft.NewNetworkTransportWithConfig(&raft.NetworkTransportConfig{ Logger: logLogger, MaxPool: maxPoolSize, Stream: stream, Timeout: config.Timeout, }) w.Transport = transport var h http.Handler = NewHandler(w.connections, w.catacomb.Dying()) h = &httpcontext.BasicAuthHandler{ Handler: h, Authenticator: w.config.Authenticator, Authorizer: httpcontext.AuthorizerFunc(controllerAuthorizer), } h = &httpcontext.ImpliedModelHandler{ Handler: h, ModelUUID: w.config.APIInfo.ModelTag.Id(), } w.config.Mux.AddHandler("GET", w.config.Path, h) if err := catacomb.Invoke(catacomb.Plan{ Site: &w.catacomb, Work: func() error { defer transport.Close() defer w.config.Mux.RemoveHandler("GET", w.config.Path) return w.loop() }, Init: []worker.Worker{stream}, }); err != nil { transport.Close() w.config.Mux.RemoveHandler("GET", w.config.Path) return nil, errors.Trace(err) } return w, nil }
[ "func", "NewWorker", "(", "config", "Config", ")", "(", "worker", ".", "Worker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "apiPorts", ":=", "config", ".", "APIInfo", ".", "Ports", "(", ")", "\n", "if", "n", ":=", "len", "(", "apiPorts", ")", ";", "n", "!=", "1", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "n", ")", "\n", "}", "\n\n", "w", ":=", "&", "Worker", "{", "config", ":", "config", ",", "connections", ":", "make", "(", "chan", "net", ".", "Conn", ")", ",", "dialRequests", ":", "make", "(", "chan", "dialRequest", ")", ",", "apiPort", ":", "apiPorts", "[", "0", "]", ",", "}", "\n\n", "const", "logPrefix", "=", "\"", "\"", "\n", "logWriter", ":=", "&", "raftutil", ".", "LoggoWriter", "{", "logger", ",", "loggo", ".", "DEBUG", "}", "\n", "logLogger", ":=", "log", ".", "New", "(", "logWriter", ",", "logPrefix", ",", "0", ")", "\n", "stream", ",", "err", ":=", "newStreamLayer", "(", "config", ".", "LocalID", ",", "config", ".", "Hub", ",", "w", ".", "connections", ",", "config", ".", "Clock", ",", "&", "Dialer", "{", "APIInfo", ":", "config", ".", "APIInfo", ",", "DialRaw", ":", "w", ".", "dialRaw", ",", "Path", ":", "config", ".", "Path", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "transport", ":=", "raft", ".", "NewNetworkTransportWithConfig", "(", "&", "raft", ".", "NetworkTransportConfig", "{", "Logger", ":", "logLogger", ",", "MaxPool", ":", "maxPoolSize", ",", "Stream", ":", "stream", ",", "Timeout", ":", "config", ".", "Timeout", ",", "}", ")", "\n", "w", ".", "Transport", "=", "transport", "\n\n", "var", "h", "http", ".", "Handler", "=", "NewHandler", "(", "w", ".", "connections", ",", "w", ".", "catacomb", ".", "Dying", "(", ")", ")", "\n", "h", "=", "&", "httpcontext", ".", "BasicAuthHandler", "{", "Handler", ":", "h", ",", "Authenticator", ":", "w", ".", "config", ".", "Authenticator", ",", "Authorizer", ":", "httpcontext", ".", "AuthorizerFunc", "(", "controllerAuthorizer", ")", ",", "}", "\n", "h", "=", "&", "httpcontext", ".", "ImpliedModelHandler", "{", "Handler", ":", "h", ",", "ModelUUID", ":", "w", ".", "config", ".", "APIInfo", ".", "ModelTag", ".", "Id", "(", ")", ",", "}", "\n\n", "w", ".", "config", ".", "Mux", ".", "AddHandler", "(", "\"", "\"", ",", "w", ".", "config", ".", "Path", ",", "h", ")", "\n\n", "if", "err", ":=", "catacomb", ".", "Invoke", "(", "catacomb", ".", "Plan", "{", "Site", ":", "&", "w", ".", "catacomb", ",", "Work", ":", "func", "(", ")", "error", "{", "defer", "transport", ".", "Close", "(", ")", "\n", "defer", "w", ".", "config", ".", "Mux", ".", "RemoveHandler", "(", "\"", "\"", ",", "w", ".", "config", ".", "Path", ")", "\n", "return", "w", ".", "loop", "(", ")", "\n", "}", ",", "Init", ":", "[", "]", "worker", ".", "Worker", "{", "stream", "}", ",", "}", ")", ";", "err", "!=", "nil", "{", "transport", ".", "Close", "(", ")", "\n", "w", ".", "config", ".", "Mux", ".", "RemoveHandler", "(", "\"", "\"", ",", "w", ".", "config", ".", "Path", ")", "\n", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "w", ",", "nil", "\n", "}" ]
// NewWorker returns a new apiserver-based raft transport worker, // with the given configuration. The worker itself implements // raft.Transport.
[ "NewWorker", "returns", "a", "new", "apiserver", "-", "based", "raft", "transport", "worker", "with", "the", "given", "configuration", ".", "The", "worker", "itself", "implements", "raft", ".", "Transport", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/raft/rafttransport/worker.go#L118-L181
156,271
juju/juju
worker/raft/rafttransport/worker.go
dialRaw
func (w *Worker) dialRaw(address raft.ServerAddress, timeout time.Duration) (net.Conn, error) { // Give precedence to the worker dying. select { case <-w.catacomb.Dying(): return nil, w.errDialWorkerStopped() default: } ctx := context.Background() if timeout != 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, timeout) defer cancel() } resultCh := make(chan dialResult) req := dialRequest{ ctx: ctx, address: string(address), result: resultCh, } select { case <-w.catacomb.Dying(): return nil, w.errDialWorkerStopped() case <-ctx.Done(): return nil, dialRequestTimeoutError{} case w.dialRequests <- req: } select { case res := <-resultCh: return res.conn, res.err case <-ctx.Done(): return nil, dialRequestTimeoutError{} case <-w.catacomb.Dying(): return nil, w.errDialWorkerStopped() } }
go
func (w *Worker) dialRaw(address raft.ServerAddress, timeout time.Duration) (net.Conn, error) { // Give precedence to the worker dying. select { case <-w.catacomb.Dying(): return nil, w.errDialWorkerStopped() default: } ctx := context.Background() if timeout != 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, timeout) defer cancel() } resultCh := make(chan dialResult) req := dialRequest{ ctx: ctx, address: string(address), result: resultCh, } select { case <-w.catacomb.Dying(): return nil, w.errDialWorkerStopped() case <-ctx.Done(): return nil, dialRequestTimeoutError{} case w.dialRequests <- req: } select { case res := <-resultCh: return res.conn, res.err case <-ctx.Done(): return nil, dialRequestTimeoutError{} case <-w.catacomb.Dying(): return nil, w.errDialWorkerStopped() } }
[ "func", "(", "w", "*", "Worker", ")", "dialRaw", "(", "address", "raft", ".", "ServerAddress", ",", "timeout", "time", ".", "Duration", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "// Give precedence to the worker dying.", "select", "{", "case", "<-", "w", ".", "catacomb", ".", "Dying", "(", ")", ":", "return", "nil", ",", "w", ".", "errDialWorkerStopped", "(", ")", "\n", "default", ":", "}", "\n\n", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "if", "timeout", "!=", "0", "{", "var", "cancel", "context", ".", "CancelFunc", "\n", "ctx", ",", "cancel", "=", "context", ".", "WithTimeout", "(", "ctx", ",", "timeout", ")", "\n", "defer", "cancel", "(", ")", "\n", "}", "\n\n", "resultCh", ":=", "make", "(", "chan", "dialResult", ")", "\n", "req", ":=", "dialRequest", "{", "ctx", ":", "ctx", ",", "address", ":", "string", "(", "address", ")", ",", "result", ":", "resultCh", ",", "}", "\n", "select", "{", "case", "<-", "w", ".", "catacomb", ".", "Dying", "(", ")", ":", "return", "nil", ",", "w", ".", "errDialWorkerStopped", "(", ")", "\n", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "nil", ",", "dialRequestTimeoutError", "{", "}", "\n", "case", "w", ".", "dialRequests", "<-", "req", ":", "}", "\n\n", "select", "{", "case", "res", ":=", "<-", "resultCh", ":", "return", "res", ".", "conn", ",", "res", ".", "err", "\n", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "return", "nil", ",", "dialRequestTimeoutError", "{", "}", "\n", "case", "<-", "w", ".", "catacomb", ".", "Dying", "(", ")", ":", "return", "nil", ",", "w", ".", "errDialWorkerStopped", "(", ")", "\n", "}", "\n", "}" ]
// dialRaw dials a new TLS connection to the controller identified // by the given address. The address is expected to be the stringified // tag of a controller machine agent. The resulting connection is // appropriate for use as Dialer.DialRaw.
[ "dialRaw", "dials", "a", "new", "TLS", "connection", "to", "the", "controller", "identified", "by", "the", "given", "address", ".", "The", "address", "is", "expected", "to", "be", "the", "stringified", "tag", "of", "a", "controller", "machine", "agent", ".", "The", "resulting", "connection", "is", "appropriate", "for", "use", "as", "Dialer", ".", "DialRaw", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/raft/rafttransport/worker.go#L220-L257
156,272
juju/juju
provider/gce/environ_availzones.go
AvailabilityZones
func (env *environ) AvailabilityZones(ctx context.ProviderCallContext) ([]common.AvailabilityZone, error) { zones, err := env.gce.AvailabilityZones(env.cloud.Region) if err != nil { return nil, google.HandleCredentialError(errors.Trace(err), ctx) } var result []common.AvailabilityZone for _, zone := range zones { if zone.Deprecated() { continue } // We make a copy since the loop var keeps the same pointer. zoneCopy := zone result = append(result, &zoneCopy) } return result, nil }
go
func (env *environ) AvailabilityZones(ctx context.ProviderCallContext) ([]common.AvailabilityZone, error) { zones, err := env.gce.AvailabilityZones(env.cloud.Region) if err != nil { return nil, google.HandleCredentialError(errors.Trace(err), ctx) } var result []common.AvailabilityZone for _, zone := range zones { if zone.Deprecated() { continue } // We make a copy since the loop var keeps the same pointer. zoneCopy := zone result = append(result, &zoneCopy) } return result, nil }
[ "func", "(", "env", "*", "environ", ")", "AvailabilityZones", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "[", "]", "common", ".", "AvailabilityZone", ",", "error", ")", "{", "zones", ",", "err", ":=", "env", ".", "gce", ".", "AvailabilityZones", "(", "env", ".", "cloud", ".", "Region", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "google", ".", "HandleCredentialError", "(", "errors", ".", "Trace", "(", "err", ")", ",", "ctx", ")", "\n", "}", "\n\n", "var", "result", "[", "]", "common", ".", "AvailabilityZone", "\n", "for", "_", ",", "zone", ":=", "range", "zones", "{", "if", "zone", ".", "Deprecated", "(", ")", "{", "continue", "\n", "}", "\n", "// We make a copy since the loop var keeps the same pointer.", "zoneCopy", ":=", "zone", "\n", "result", "=", "append", "(", "result", ",", "&", "zoneCopy", ")", "\n", "}", "\n", "return", "result", ",", "nil", "\n", "}" ]
// AvailabilityZones returns all availability zones in the environment.
[ "AvailabilityZones", "returns", "all", "availability", "zones", "in", "the", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/environ_availzones.go#L18-L34
156,273
juju/juju
provider/gce/environ_availzones.go
InstanceAvailabilityZoneNames
func (env *environ) InstanceAvailabilityZoneNames(ctx context.ProviderCallContext, ids []instance.Id) ([]string, error) { instances, err := env.Instances(ctx, ids) if err != nil && err != environs.ErrPartialInstances && err != environs.ErrNoInstances { return nil, errors.Trace(err) } // We let the two environs errors pass on through. However, we do // not use errors.Trace in that case since callers may not call // errors.Cause. results := make([]string, len(ids)) for i, inst := range instances { if eInst := inst.(*environInstance); eInst != nil { results[i] = eInst.base.ZoneName } } return results, err }
go
func (env *environ) InstanceAvailabilityZoneNames(ctx context.ProviderCallContext, ids []instance.Id) ([]string, error) { instances, err := env.Instances(ctx, ids) if err != nil && err != environs.ErrPartialInstances && err != environs.ErrNoInstances { return nil, errors.Trace(err) } // We let the two environs errors pass on through. However, we do // not use errors.Trace in that case since callers may not call // errors.Cause. results := make([]string, len(ids)) for i, inst := range instances { if eInst := inst.(*environInstance); eInst != nil { results[i] = eInst.base.ZoneName } } return results, err }
[ "func", "(", "env", "*", "environ", ")", "InstanceAvailabilityZoneNames", "(", "ctx", "context", ".", "ProviderCallContext", ",", "ids", "[", "]", "instance", ".", "Id", ")", "(", "[", "]", "string", ",", "error", ")", "{", "instances", ",", "err", ":=", "env", ".", "Instances", "(", "ctx", ",", "ids", ")", "\n", "if", "err", "!=", "nil", "&&", "err", "!=", "environs", ".", "ErrPartialInstances", "&&", "err", "!=", "environs", ".", "ErrNoInstances", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "// We let the two environs errors pass on through. However, we do", "// not use errors.Trace in that case since callers may not call", "// errors.Cause.", "results", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "ids", ")", ")", "\n", "for", "i", ",", "inst", ":=", "range", "instances", "{", "if", "eInst", ":=", "inst", ".", "(", "*", "environInstance", ")", ";", "eInst", "!=", "nil", "{", "results", "[", "i", "]", "=", "eInst", ".", "base", ".", "ZoneName", "\n", "}", "\n", "}", "\n\n", "return", "results", ",", "err", "\n", "}" ]
// InstanceAvailabilityZoneNames returns the names of the availability // zones for the specified instances. The error returned follows the same // rules as Environ.Instances.
[ "InstanceAvailabilityZoneNames", "returns", "the", "names", "of", "the", "availability", "zones", "for", "the", "specified", "instances", ".", "The", "error", "returned", "follows", "the", "same", "rules", "as", "Environ", ".", "Instances", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/environ_availzones.go#L39-L56
156,274
juju/juju
apiserver/stateauthenticator/locallogin.go
AddHandlers
func (h *localLoginHandlers) AddHandlers(mux *apiserverhttp.Mux) { var errorMapper httprequest.ErrorMapper = httpbakery.ErrorToResponse var handleJSON = errorMapper.HandleJSON makeHandler := func(h httprouter.Handle) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { h(w, req, nil) }) } dischargeMux := http.NewServeMux() httpbakery.AddDischargeHandler( dischargeMux, localUserIdentityLocationPath, h.authCtxt.localUserThirdPartyBakeryService, h.checkThirdPartyCaveat, ) dischargeMux.Handle( localUserIdentityLocationPath+"/login", makeHandler(handleJSON(h.serveLogin)), ) dischargeMux.Handle( localUserIdentityLocationPath+"/wait", makeHandler(handleJSON(h.serveWait)), ) mux.AddHandler("POST", localUserIdentityLocationPath+"/discharge", dischargeMux) mux.AddHandler("GET", localUserIdentityLocationPath+"/publickey", dischargeMux) mux.AddHandler("GET", localUserIdentityLocationPath+"/wait", dischargeMux) mux.AddHandler("GET", localUserIdentityLocationPath+"/login", dischargeMux) mux.AddHandler("POST", localUserIdentityLocationPath+"/login", dischargeMux) }
go
func (h *localLoginHandlers) AddHandlers(mux *apiserverhttp.Mux) { var errorMapper httprequest.ErrorMapper = httpbakery.ErrorToResponse var handleJSON = errorMapper.HandleJSON makeHandler := func(h httprouter.Handle) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { h(w, req, nil) }) } dischargeMux := http.NewServeMux() httpbakery.AddDischargeHandler( dischargeMux, localUserIdentityLocationPath, h.authCtxt.localUserThirdPartyBakeryService, h.checkThirdPartyCaveat, ) dischargeMux.Handle( localUserIdentityLocationPath+"/login", makeHandler(handleJSON(h.serveLogin)), ) dischargeMux.Handle( localUserIdentityLocationPath+"/wait", makeHandler(handleJSON(h.serveWait)), ) mux.AddHandler("POST", localUserIdentityLocationPath+"/discharge", dischargeMux) mux.AddHandler("GET", localUserIdentityLocationPath+"/publickey", dischargeMux) mux.AddHandler("GET", localUserIdentityLocationPath+"/wait", dischargeMux) mux.AddHandler("GET", localUserIdentityLocationPath+"/login", dischargeMux) mux.AddHandler("POST", localUserIdentityLocationPath+"/login", dischargeMux) }
[ "func", "(", "h", "*", "localLoginHandlers", ")", "AddHandlers", "(", "mux", "*", "apiserverhttp", ".", "Mux", ")", "{", "var", "errorMapper", "httprequest", ".", "ErrorMapper", "=", "httpbakery", ".", "ErrorToResponse", "\n", "var", "handleJSON", "=", "errorMapper", ".", "HandleJSON", "\n", "makeHandler", ":=", "func", "(", "h", "httprouter", ".", "Handle", ")", "http", ".", "Handler", "{", "return", "http", ".", "HandlerFunc", "(", "func", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "h", "(", "w", ",", "req", ",", "nil", ")", "\n", "}", ")", "\n", "}", "\n", "dischargeMux", ":=", "http", ".", "NewServeMux", "(", ")", "\n", "httpbakery", ".", "AddDischargeHandler", "(", "dischargeMux", ",", "localUserIdentityLocationPath", ",", "h", ".", "authCtxt", ".", "localUserThirdPartyBakeryService", ",", "h", ".", "checkThirdPartyCaveat", ",", ")", "\n", "dischargeMux", ".", "Handle", "(", "localUserIdentityLocationPath", "+", "\"", "\"", ",", "makeHandler", "(", "handleJSON", "(", "h", ".", "serveLogin", ")", ")", ",", ")", "\n", "dischargeMux", ".", "Handle", "(", "localUserIdentityLocationPath", "+", "\"", "\"", ",", "makeHandler", "(", "handleJSON", "(", "h", ".", "serveWait", ")", ")", ",", ")", "\n", "mux", ".", "AddHandler", "(", "\"", "\"", ",", "localUserIdentityLocationPath", "+", "\"", "\"", ",", "dischargeMux", ")", "\n", "mux", ".", "AddHandler", "(", "\"", "\"", ",", "localUserIdentityLocationPath", "+", "\"", "\"", ",", "dischargeMux", ")", "\n", "mux", ".", "AddHandler", "(", "\"", "\"", ",", "localUserIdentityLocationPath", "+", "\"", "\"", ",", "dischargeMux", ")", "\n", "mux", ".", "AddHandler", "(", "\"", "\"", ",", "localUserIdentityLocationPath", "+", "\"", "\"", ",", "dischargeMux", ")", "\n", "mux", ".", "AddHandler", "(", "\"", "\"", ",", "localUserIdentityLocationPath", "+", "\"", "\"", ",", "dischargeMux", ")", "\n", "}" ]
// AddHandlers adds the local login handlers to the given mux.
[ "AddHandlers", "adds", "the", "local", "login", "handlers", "to", "the", "given", "mux", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/stateauthenticator/locallogin.go#L35-L63
156,275
juju/juju
apiserver/facades/agent/uniter/mocks/lxdprofile.go
NewMockLXDProfileBackend
func NewMockLXDProfileBackend(ctrl *gomock.Controller) *MockLXDProfileBackend { mock := &MockLXDProfileBackend{ctrl: ctrl} mock.recorder = &MockLXDProfileBackendMockRecorder{mock} return mock }
go
func NewMockLXDProfileBackend(ctrl *gomock.Controller) *MockLXDProfileBackend { mock := &MockLXDProfileBackend{ctrl: ctrl} mock.recorder = &MockLXDProfileBackendMockRecorder{mock} return mock }
[ "func", "NewMockLXDProfileBackend", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockLXDProfileBackend", "{", "mock", ":=", "&", "MockLXDProfileBackend", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockLXDProfileBackendMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockLXDProfileBackend creates a new mock instance
[ "NewMockLXDProfileBackend", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/mocks/lxdprofile.go#L28-L32
156,276
juju/juju
apiserver/facades/agent/uniter/mocks/lxdprofile.go
NewMockLXDProfileMachine
func NewMockLXDProfileMachine(ctrl *gomock.Controller) *MockLXDProfileMachine { mock := &MockLXDProfileMachine{ctrl: ctrl} mock.recorder = &MockLXDProfileMachineMockRecorder{mock} return mock }
go
func NewMockLXDProfileMachine(ctrl *gomock.Controller) *MockLXDProfileMachine { mock := &MockLXDProfileMachine{ctrl: ctrl} mock.recorder = &MockLXDProfileMachineMockRecorder{mock} return mock }
[ "func", "NewMockLXDProfileMachine", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockLXDProfileMachine", "{", "mock", ":=", "&", "MockLXDProfileMachine", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockLXDProfileMachineMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockLXDProfileMachine creates a new mock instance
[ "NewMockLXDProfileMachine", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/mocks/lxdprofile.go#L77-L81
156,277
juju/juju
apiserver/facades/agent/uniter/mocks/lxdprofile.go
RemoveUpgradeCharmProfileData
func (m *MockLXDProfileMachine) RemoveUpgradeCharmProfileData(arg0 string) error { ret := m.ctrl.Call(m, "RemoveUpgradeCharmProfileData", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockLXDProfileMachine) RemoveUpgradeCharmProfileData(arg0 string) error { ret := m.ctrl.Call(m, "RemoveUpgradeCharmProfileData", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockLXDProfileMachine", ")", "RemoveUpgradeCharmProfileData", "(", "arg0", "string", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")", "\n", "return", "ret0", "\n", "}" ]
// RemoveUpgradeCharmProfileData mocks base method
[ "RemoveUpgradeCharmProfileData", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/mocks/lxdprofile.go#L89-L93
156,278
juju/juju
apiserver/facades/agent/uniter/mocks/lxdprofile.go
RemoveUpgradeCharmProfileData
func (mr *MockLXDProfileMachineMockRecorder) RemoveUpgradeCharmProfileData(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveUpgradeCharmProfileData", reflect.TypeOf((*MockLXDProfileMachine)(nil).RemoveUpgradeCharmProfileData), arg0) }
go
func (mr *MockLXDProfileMachineMockRecorder) RemoveUpgradeCharmProfileData(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveUpgradeCharmProfileData", reflect.TypeOf((*MockLXDProfileMachine)(nil).RemoveUpgradeCharmProfileData), arg0) }
[ "func", "(", "mr", "*", "MockLXDProfileMachineMockRecorder", ")", "RemoveUpgradeCharmProfileData", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockLXDProfileMachine", ")", "(", "nil", ")", ".", "RemoveUpgradeCharmProfileData", ")", ",", "arg0", ")", "\n", "}" ]
// RemoveUpgradeCharmProfileData indicates an expected call of RemoveUpgradeCharmProfileData
[ "RemoveUpgradeCharmProfileData", "indicates", "an", "expected", "call", "of", "RemoveUpgradeCharmProfileData" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/mocks/lxdprofile.go#L96-L98
156,279
juju/juju
apiserver/facades/agent/uniter/mocks/lxdprofile.go
NewMockLXDProfileUnit
func NewMockLXDProfileUnit(ctrl *gomock.Controller) *MockLXDProfileUnit { mock := &MockLXDProfileUnit{ctrl: ctrl} mock.recorder = &MockLXDProfileUnitMockRecorder{mock} return mock }
go
func NewMockLXDProfileUnit(ctrl *gomock.Controller) *MockLXDProfileUnit { mock := &MockLXDProfileUnit{ctrl: ctrl} mock.recorder = &MockLXDProfileUnitMockRecorder{mock} return mock }
[ "func", "NewMockLXDProfileUnit", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockLXDProfileUnit", "{", "mock", ":=", "&", "MockLXDProfileUnit", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockLXDProfileUnitMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockLXDProfileUnit creates a new mock instance
[ "NewMockLXDProfileUnit", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/mocks/lxdprofile.go#L125-L129
156,280
juju/juju
apiserver/facades/agent/uniter/mocks/lxdprofile.go
AssignedMachineId
func (m *MockLXDProfileUnit) AssignedMachineId() (string, error) { ret := m.ctrl.Call(m, "AssignedMachineId") ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockLXDProfileUnit) AssignedMachineId() (string, error) { ret := m.ctrl.Call(m, "AssignedMachineId") ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockLXDProfileUnit", ")", "AssignedMachineId", "(", ")", "(", "string", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "string", ")", "\n", "ret1", ",", "_", ":=", "ret", "[", "1", "]", ".", "(", "error", ")", "\n", "return", "ret0", ",", "ret1", "\n", "}" ]
// AssignedMachineId mocks base method
[ "AssignedMachineId", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/mocks/lxdprofile.go#L137-L142
156,281
juju/juju
apiserver/facades/agent/uniter/mocks/lxdprofile.go
WatchLXDProfileUpgradeNotifications
func (mr *MockLXDProfileUnitMockRecorder) WatchLXDProfileUpgradeNotifications() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WatchLXDProfileUpgradeNotifications", reflect.TypeOf((*MockLXDProfileUnit)(nil).WatchLXDProfileUpgradeNotifications)) }
go
func (mr *MockLXDProfileUnitMockRecorder) WatchLXDProfileUpgradeNotifications() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WatchLXDProfileUpgradeNotifications", reflect.TypeOf((*MockLXDProfileUnit)(nil).WatchLXDProfileUpgradeNotifications)) }
[ "func", "(", "mr", "*", "MockLXDProfileUnitMockRecorder", ")", "WatchLXDProfileUpgradeNotifications", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockLXDProfileUnit", ")", "(", "nil", ")", ".", "WatchLXDProfileUpgradeNotifications", ")", ")", "\n", "}" ]
// WatchLXDProfileUpgradeNotifications indicates an expected call of WatchLXDProfileUpgradeNotifications
[ "WatchLXDProfileUpgradeNotifications", "indicates", "an", "expected", "call", "of", "WatchLXDProfileUpgradeNotifications" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/mocks/lxdprofile.go#L182-L184
156,282
juju/juju
apiserver/facades/client/bundle/state.go
GetExportConfig
func (m *stateShim) GetExportConfig() state.ExportConfig { var cfg state.ExportConfig cfg.SkipActions = true cfg.SkipCloudImageMetadata = true cfg.SkipCredentials = true cfg.SkipIPAddresses = true cfg.SkipSSHHostKeys = true cfg.SkipStatusHistory = true cfg.SkipLinkLayerDevices = true cfg.SkipRelationData = true cfg.SkipMachineAgentBinaries = true cfg.SkipUnitAgentBinaries = true cfg.SkipInstanceData = true return cfg }
go
func (m *stateShim) GetExportConfig() state.ExportConfig { var cfg state.ExportConfig cfg.SkipActions = true cfg.SkipCloudImageMetadata = true cfg.SkipCredentials = true cfg.SkipIPAddresses = true cfg.SkipSSHHostKeys = true cfg.SkipStatusHistory = true cfg.SkipLinkLayerDevices = true cfg.SkipRelationData = true cfg.SkipMachineAgentBinaries = true cfg.SkipUnitAgentBinaries = true cfg.SkipInstanceData = true return cfg }
[ "func", "(", "m", "*", "stateShim", ")", "GetExportConfig", "(", ")", "state", ".", "ExportConfig", "{", "var", "cfg", "state", ".", "ExportConfig", "\n", "cfg", ".", "SkipActions", "=", "true", "\n", "cfg", ".", "SkipCloudImageMetadata", "=", "true", "\n", "cfg", ".", "SkipCredentials", "=", "true", "\n", "cfg", ".", "SkipIPAddresses", "=", "true", "\n", "cfg", ".", "SkipSSHHostKeys", "=", "true", "\n", "cfg", ".", "SkipStatusHistory", "=", "true", "\n", "cfg", ".", "SkipLinkLayerDevices", "=", "true", "\n", "cfg", ".", "SkipRelationData", "=", "true", "\n", "cfg", ".", "SkipMachineAgentBinaries", "=", "true", "\n", "cfg", ".", "SkipUnitAgentBinaries", "=", "true", "\n", "cfg", ".", "SkipInstanceData", "=", "true", "\n\n", "return", "cfg", "\n", "}" ]
// GetExportConfig implements Backend.GetExportConfig.
[ "GetExportConfig", "implements", "Backend", ".", "GetExportConfig", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/bundle/state.go#L22-L37
156,283
juju/juju
state/storage.go
NewStorageBackend
func NewStorageBackend(st *State) (*storageBackend, error) { // TODO(wallyworld) - we should be passing in a Model not a State // (but need to move stuff off State first) m, err := st.Model() if err != nil { return nil, errors.Trace(err) } registry, err := st.storageProviderRegistry() if err != nil { return nil, errors.Annotate(err, "getting storage provider registry") } return &storageBackend{ mb: st, registry: registry, settings: NewStateSettings(st), modelType: m.Type(), config: m.ModelConfig, application: st.Application, allApplications: st.AllApplications, unit: st.Unit, machine: st.Machine, }, nil }
go
func NewStorageBackend(st *State) (*storageBackend, error) { // TODO(wallyworld) - we should be passing in a Model not a State // (but need to move stuff off State first) m, err := st.Model() if err != nil { return nil, errors.Trace(err) } registry, err := st.storageProviderRegistry() if err != nil { return nil, errors.Annotate(err, "getting storage provider registry") } return &storageBackend{ mb: st, registry: registry, settings: NewStateSettings(st), modelType: m.Type(), config: m.ModelConfig, application: st.Application, allApplications: st.AllApplications, unit: st.Unit, machine: st.Machine, }, nil }
[ "func", "NewStorageBackend", "(", "st", "*", "State", ")", "(", "*", "storageBackend", ",", "error", ")", "{", "// TODO(wallyworld) - we should be passing in a Model not a State", "// (but need to move stuff off State first)", "m", ",", "err", ":=", "st", ".", "Model", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "registry", ",", "err", ":=", "st", ".", "storageProviderRegistry", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "return", "&", "storageBackend", "{", "mb", ":", "st", ",", "registry", ":", "registry", ",", "settings", ":", "NewStateSettings", "(", "st", ")", ",", "modelType", ":", "m", ".", "Type", "(", ")", ",", "config", ":", "m", ".", "ModelConfig", ",", "application", ":", "st", ".", "Application", ",", "allApplications", ":", "st", ".", "AllApplications", ",", "unit", ":", "st", ".", "Unit", ",", "machine", ":", "st", ".", "Machine", ",", "}", ",", "nil", "\n", "}" ]
// NewStorageBackend creates a backend for managing storage.
[ "NewStorageBackend", "creates", "a", "backend", "for", "managing", "storage", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L86-L109
156,284
juju/juju
state/storage.go
entityStorageRefcountKey
func entityStorageRefcountKey(owner names.Tag, storageName string) string { return fmt.Sprintf("storage#%s#%s", owner.String(), storageName) }
go
func entityStorageRefcountKey(owner names.Tag, storageName string) string { return fmt.Sprintf("storage#%s#%s", owner.String(), storageName) }
[ "func", "entityStorageRefcountKey", "(", "owner", "names", ".", "Tag", ",", "storageName", "string", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "owner", ".", "String", "(", ")", ",", "storageName", ")", "\n", "}" ]
// entityStorageRefcountKey returns a key for refcounting charm storage // for a specific entity. Each time a storage instance is created, the // named store's refcount is incremented; and decremented when removed.
[ "entityStorageRefcountKey", "returns", "a", "key", "for", "refcounting", "charm", "storage", "for", "a", "specific", "entity", ".", "Each", "time", "a", "storage", "instance", "is", "created", "the", "named", "store", "s", "refcount", "is", "incremented", ";", "and", "decremented", "when", "removed", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L199-L201
156,285
juju/juju
state/storage.go
newStorageInstanceId
func newStorageInstanceId(mb modelBackend, store string) (string, error) { seq, err := sequence(mb, "stores") if err != nil { return "", errors.Trace(err) } return fmt.Sprintf("%s/%v", store, seq), nil }
go
func newStorageInstanceId(mb modelBackend, store string) (string, error) { seq, err := sequence(mb, "stores") if err != nil { return "", errors.Trace(err) } return fmt.Sprintf("%s/%v", store, seq), nil }
[ "func", "newStorageInstanceId", "(", "mb", "modelBackend", ",", "store", "string", ")", "(", "string", ",", "error", ")", "{", "seq", ",", "err", ":=", "sequence", "(", "mb", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "store", ",", "seq", ")", ",", "nil", "\n", "}" ]
// newStorageInstanceId returns a unique storage instance name. The name // incorporates the storage name as defined in the charm storage metadata, // and a unique sequence number.
[ "newStorageInstanceId", "returns", "a", "unique", "storage", "instance", "name", ".", "The", "name", "incorporates", "the", "storage", "name", "as", "defined", "in", "the", "charm", "storage", "metadata", "and", "a", "unique", "sequence", "number", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L255-L261
156,286
juju/juju
state/storage.go
StorageInstance
func (sb *storageBackend) StorageInstance(tag names.StorageTag) (StorageInstance, error) { s, err := sb.storageInstance(tag) return s, err }
go
func (sb *storageBackend) StorageInstance(tag names.StorageTag) (StorageInstance, error) { s, err := sb.storageInstance(tag) return s, err }
[ "func", "(", "sb", "*", "storageBackend", ")", "StorageInstance", "(", "tag", "names", ".", "StorageTag", ")", "(", "StorageInstance", ",", "error", ")", "{", "s", ",", "err", ":=", "sb", ".", "storageInstance", "(", "tag", ")", "\n", "return", "s", ",", "err", "\n", "}" ]
// StorageInstance returns the StorageInstance with the specified tag.
[ "StorageInstance", "returns", "the", "StorageInstance", "with", "the", "specified", "tag", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L268-L271
156,287
juju/juju
state/storage.go
AllStorageInstances
func (sb *storageBackend) AllStorageInstances() ([]StorageInstance, error) { storageInstances, err := sb.storageInstances(nil) if err != nil { return nil, errors.Trace(err) } out := make([]StorageInstance, len(storageInstances)) for i, s := range storageInstances { out[i] = s } return out, nil }
go
func (sb *storageBackend) AllStorageInstances() ([]StorageInstance, error) { storageInstances, err := sb.storageInstances(nil) if err != nil { return nil, errors.Trace(err) } out := make([]StorageInstance, len(storageInstances)) for i, s := range storageInstances { out[i] = s } return out, nil }
[ "func", "(", "sb", "*", "storageBackend", ")", "AllStorageInstances", "(", ")", "(", "[", "]", "StorageInstance", ",", "error", ")", "{", "storageInstances", ",", "err", ":=", "sb", ".", "storageInstances", "(", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "out", ":=", "make", "(", "[", "]", "StorageInstance", ",", "len", "(", "storageInstances", ")", ")", "\n", "for", "i", ",", "s", ":=", "range", "storageInstances", "{", "out", "[", "i", "]", "=", "s", "\n", "}", "\n", "return", "out", ",", "nil", "\n", "}" ]
// AllStorageInstances lists all storage instances currently in state // for this Juju model.
[ "AllStorageInstances", "lists", "all", "storage", "instances", "currently", "in", "state", "for", "this", "Juju", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L289-L299
156,288
juju/juju
state/storage.go
RemoveStoragePool
func (sb *storageBackend) RemoveStoragePool(poolName string) error { storageCollection, closer := sb.mb.db().GetCollection(storageInstancesC) defer closer() // TODO: Improve the data model to have a count of in use pools so we can // make these checks as an assert and not queries. var inUse bool cfg, err := sb.config() if err != nil { return errors.Trace(err) } operatorStorage, ok := cfg.AllAttrs()[k8sprovider.OperatorStorageKey] if sb.modelType == ModelTypeCAAS && ok && operatorStorage == poolName { apps, err := sb.allApplications() if err != nil { return errors.Trace(err) } inUse = len(apps) > 0 } else { query := bson.D{{"constraints.pool", bson.D{{"$eq", poolName}}}} pools, err := storageCollection.Find(query).Count() if err != nil { return errors.Trace(err) } inUse = pools > 0 } if inUse { return errors.Errorf("storage pool %q in use", poolName) } pm := poolmanager.New(sb.settings, sb.registry) return pm.Delete(poolName) }
go
func (sb *storageBackend) RemoveStoragePool(poolName string) error { storageCollection, closer := sb.mb.db().GetCollection(storageInstancesC) defer closer() // TODO: Improve the data model to have a count of in use pools so we can // make these checks as an assert and not queries. var inUse bool cfg, err := sb.config() if err != nil { return errors.Trace(err) } operatorStorage, ok := cfg.AllAttrs()[k8sprovider.OperatorStorageKey] if sb.modelType == ModelTypeCAAS && ok && operatorStorage == poolName { apps, err := sb.allApplications() if err != nil { return errors.Trace(err) } inUse = len(apps) > 0 } else { query := bson.D{{"constraints.pool", bson.D{{"$eq", poolName}}}} pools, err := storageCollection.Find(query).Count() if err != nil { return errors.Trace(err) } inUse = pools > 0 } if inUse { return errors.Errorf("storage pool %q in use", poolName) } pm := poolmanager.New(sb.settings, sb.registry) return pm.Delete(poolName) }
[ "func", "(", "sb", "*", "storageBackend", ")", "RemoveStoragePool", "(", "poolName", "string", ")", "error", "{", "storageCollection", ",", "closer", ":=", "sb", ".", "mb", ".", "db", "(", ")", ".", "GetCollection", "(", "storageInstancesC", ")", "\n", "defer", "closer", "(", ")", "\n\n", "// TODO: Improve the data model to have a count of in use pools so we can", "// make these checks as an assert and not queries.", "var", "inUse", "bool", "\n", "cfg", ",", "err", ":=", "sb", ".", "config", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "operatorStorage", ",", "ok", ":=", "cfg", ".", "AllAttrs", "(", ")", "[", "k8sprovider", ".", "OperatorStorageKey", "]", "\n", "if", "sb", ".", "modelType", "==", "ModelTypeCAAS", "&&", "ok", "&&", "operatorStorage", "==", "poolName", "{", "apps", ",", "err", ":=", "sb", ".", "allApplications", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "inUse", "=", "len", "(", "apps", ")", ">", "0", "\n", "}", "else", "{", "query", ":=", "bson", ".", "D", "{", "{", "\"", "\"", ",", "bson", ".", "D", "{", "{", "\"", "\"", ",", "poolName", "}", "}", "}", "}", "\n", "pools", ",", "err", ":=", "storageCollection", ".", "Find", "(", "query", ")", ".", "Count", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "inUse", "=", "pools", ">", "0", "\n", "}", "\n", "if", "inUse", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "poolName", ")", "\n", "}", "\n\n", "pm", ":=", "poolmanager", ".", "New", "(", "sb", ".", "settings", ",", "sb", ".", "registry", ")", "\n", "return", "pm", ".", "Delete", "(", "poolName", ")", "\n", "}" ]
// RemoveStoragePool removes a pool only if its not currently in use
[ "RemoveStoragePool", "removes", "a", "pool", "only", "if", "its", "not", "currently", "in", "use" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L302-L334
156,289
juju/juju
state/storage.go
IsStorageAttachedError
func IsStorageAttachedError(err error) bool { _, ok := errors.Cause(err).(storageAttachedError) return ok }
go
func IsStorageAttachedError(err error) bool { _, ok := errors.Cause(err).(storageAttachedError) return ok }
[ "func", "IsStorageAttachedError", "(", "err", "error", ")", "bool", "{", "_", ",", "ok", ":=", "errors", ".", "Cause", "(", "err", ")", ".", "(", "storageAttachedError", ")", "\n", "return", "ok", "\n", "}" ]
// IsStorageAttachedError reports whether or not the given error was caused // by an operation on storage that should not be, but is, attached.
[ "IsStorageAttachedError", "reports", "whether", "or", "not", "the", "given", "error", "was", "caused", "by", "an", "operation", "on", "storage", "that", "should", "not", "be", "but", "is", "attached", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L357-L360
156,290
juju/juju
state/storage.go
DestroyStorageInstance
func (sb *storageBackend) DestroyStorageInstance(tag names.StorageTag, destroyAttachments bool, force bool, maxWait time.Duration) (err error) { defer errors.DeferredAnnotatef(&err, "cannot destroy storage %q", tag.Id()) return sb.destroyStorageInstance(tag, destroyAttachments, false, force, maxWait) }
go
func (sb *storageBackend) DestroyStorageInstance(tag names.StorageTag, destroyAttachments bool, force bool, maxWait time.Duration) (err error) { defer errors.DeferredAnnotatef(&err, "cannot destroy storage %q", tag.Id()) return sb.destroyStorageInstance(tag, destroyAttachments, false, force, maxWait) }
[ "func", "(", "sb", "*", "storageBackend", ")", "DestroyStorageInstance", "(", "tag", "names", ".", "StorageTag", ",", "destroyAttachments", "bool", ",", "force", "bool", ",", "maxWait", "time", ".", "Duration", ")", "(", "err", "error", ")", "{", "defer", "errors", ".", "DeferredAnnotatef", "(", "&", "err", ",", "\"", "\"", ",", "tag", ".", "Id", "(", ")", ")", "\n", "return", "sb", ".", "destroyStorageInstance", "(", "tag", ",", "destroyAttachments", ",", "false", ",", "force", ",", "maxWait", ")", "\n", "}" ]
// DestroyStorageInstance ensures that the storage instance will be removed at // some point, after the cloud storage resources have been destroyed. // // If "destroyAttachments" is true, then DestroyStorageInstance will destroy // any attachments first; if there are no attachments, then the storage instance // is removed immediately. If "destroyAttached" is instead false and there are // existing storage attachments, then DestroyStorageInstance will return an error // satisfying IsStorageAttachedError.
[ "DestroyStorageInstance", "ensures", "that", "the", "storage", "instance", "will", "be", "removed", "at", "some", "point", "after", "the", "cloud", "storage", "resources", "have", "been", "destroyed", ".", "If", "destroyAttachments", "is", "true", "then", "DestroyStorageInstance", "will", "destroy", "any", "attachments", "first", ";", "if", "there", "are", "no", "attachments", "then", "the", "storage", "instance", "is", "removed", "immediately", ".", "If", "destroyAttached", "is", "instead", "false", "and", "there", "are", "existing", "storage", "attachments", "then", "DestroyStorageInstance", "will", "return", "an", "error", "satisfying", "IsStorageAttachedError", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L370-L373
156,291
juju/juju
state/storage.go
validateRemoveOwnerStorageInstanceOps
func validateRemoveOwnerStorageInstanceOps(si *storageInstance) ([]txn.Op, error) { var ops []txn.Op var charmMeta *charm.Meta owner := si.maybeOwner() switch owner.Kind() { case names.ApplicationTagKind: app, err := si.sb.application(owner.Id()) if err != nil { return nil, errors.Trace(err) } if app.Life() != Alive { return nil, nil } ch, _, err := app.Charm() if err != nil { return nil, errors.Trace(err) } charmMeta = ch.Meta() ops = append(ops, txn.Op{ C: applicationsC, Id: app.Name(), Assert: bson.D{ {"life", Alive}, {"charmurl", ch.URL}, }, }) case names.UnitTagKind: u, err := si.sb.unit(owner.Id()) if err != nil { return nil, errors.Trace(err) } if u.Life() != Alive { return nil, nil } ch, err := u.charm() if err != nil { return nil, errors.Trace(err) } charmMeta = ch.Meta() ops = append(ops, txn.Op{ C: unitsC, Id: u.doc.Name, Assert: bson.D{{"life", Alive}}, }) ops = append(ops, u.assertCharmOps(ch)...) default: return nil, errors.Errorf( "invalid storage owner %s", names.ReadableString(owner), ) } _, currentCountOp, err := validateStorageCountChange( si.sb, owner, si.StorageName(), -1, charmMeta, ) if err != nil { return nil, errors.Trace(err) } ops = append(ops, currentCountOp) return ops, nil }
go
func validateRemoveOwnerStorageInstanceOps(si *storageInstance) ([]txn.Op, error) { var ops []txn.Op var charmMeta *charm.Meta owner := si.maybeOwner() switch owner.Kind() { case names.ApplicationTagKind: app, err := si.sb.application(owner.Id()) if err != nil { return nil, errors.Trace(err) } if app.Life() != Alive { return nil, nil } ch, _, err := app.Charm() if err != nil { return nil, errors.Trace(err) } charmMeta = ch.Meta() ops = append(ops, txn.Op{ C: applicationsC, Id: app.Name(), Assert: bson.D{ {"life", Alive}, {"charmurl", ch.URL}, }, }) case names.UnitTagKind: u, err := si.sb.unit(owner.Id()) if err != nil { return nil, errors.Trace(err) } if u.Life() != Alive { return nil, nil } ch, err := u.charm() if err != nil { return nil, errors.Trace(err) } charmMeta = ch.Meta() ops = append(ops, txn.Op{ C: unitsC, Id: u.doc.Name, Assert: bson.D{{"life", Alive}}, }) ops = append(ops, u.assertCharmOps(ch)...) default: return nil, errors.Errorf( "invalid storage owner %s", names.ReadableString(owner), ) } _, currentCountOp, err := validateStorageCountChange( si.sb, owner, si.StorageName(), -1, charmMeta, ) if err != nil { return nil, errors.Trace(err) } ops = append(ops, currentCountOp) return ops, nil }
[ "func", "validateRemoveOwnerStorageInstanceOps", "(", "si", "*", "storageInstance", ")", "(", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "var", "ops", "[", "]", "txn", ".", "Op", "\n", "var", "charmMeta", "*", "charm", ".", "Meta", "\n", "owner", ":=", "si", ".", "maybeOwner", "(", ")", "\n", "switch", "owner", ".", "Kind", "(", ")", "{", "case", "names", ".", "ApplicationTagKind", ":", "app", ",", "err", ":=", "si", ".", "sb", ".", "application", "(", "owner", ".", "Id", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "app", ".", "Life", "(", ")", "!=", "Alive", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "ch", ",", "_", ",", "err", ":=", "app", ".", "Charm", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "charmMeta", "=", "ch", ".", "Meta", "(", ")", "\n", "ops", "=", "append", "(", "ops", ",", "txn", ".", "Op", "{", "C", ":", "applicationsC", ",", "Id", ":", "app", ".", "Name", "(", ")", ",", "Assert", ":", "bson", ".", "D", "{", "{", "\"", "\"", ",", "Alive", "}", ",", "{", "\"", "\"", ",", "ch", ".", "URL", "}", ",", "}", ",", "}", ")", "\n", "case", "names", ".", "UnitTagKind", ":", "u", ",", "err", ":=", "si", ".", "sb", ".", "unit", "(", "owner", ".", "Id", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "u", ".", "Life", "(", ")", "!=", "Alive", "{", "return", "nil", ",", "nil", "\n", "}", "\n", "ch", ",", "err", ":=", "u", ".", "charm", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "charmMeta", "=", "ch", ".", "Meta", "(", ")", "\n", "ops", "=", "append", "(", "ops", ",", "txn", ".", "Op", "{", "C", ":", "unitsC", ",", "Id", ":", "u", ".", "doc", ".", "Name", ",", "Assert", ":", "bson", ".", "D", "{", "{", "\"", "\"", ",", "Alive", "}", "}", ",", "}", ")", "\n", "ops", "=", "append", "(", "ops", ",", "u", ".", "assertCharmOps", "(", "ch", ")", "...", ")", "\n", "default", ":", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "names", ".", "ReadableString", "(", "owner", ")", ",", ")", "\n", "}", "\n", "_", ",", "currentCountOp", ",", "err", ":=", "validateStorageCountChange", "(", "si", ".", "sb", ",", "owner", ",", "si", ".", "StorageName", "(", ")", ",", "-", "1", ",", "charmMeta", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "ops", "=", "append", "(", "ops", ",", "currentCountOp", ")", "\n", "return", "ops", ",", "nil", "\n", "}" ]
// validateRemoveOwnerStorageInstanceOps checks that the given storage // instance can be removed from its current owner, returning txn.Ops to // ensure the same in a transaction. If the owner is not alive, then charm // storage requirements are ignored.
[ "validateRemoveOwnerStorageInstanceOps", "checks", "that", "the", "given", "storage", "instance", "can", "be", "removed", "from", "its", "current", "owner", "returning", "txn", ".", "Ops", "to", "ensure", "the", "same", "in", "a", "transaction", ".", "If", "the", "owner", "is", "not", "alive", "then", "charm", "storage", "requirements", "are", "ignored", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L616-L675
156,292
juju/juju
state/storage.go
validateStorageCountChange
func validateStorageCountChange( im *storageBackend, owner names.Tag, storageName string, n int, charmMeta *charm.Meta, ) (current int, _ txn.Op, _ error) { currentCountOp, currentCount, err := im.countEntityStorageInstances(owner, storageName) if err != nil { return -1, txn.Op{}, errors.Trace(err) } charmStorage := charmMeta.Storage[storageName] if err := validateCharmStorageCountChange(charmStorage, currentCount, n); err != nil { return -1, txn.Op{}, errors.Trace(err) } return currentCount, currentCountOp, nil }
go
func validateStorageCountChange( im *storageBackend, owner names.Tag, storageName string, n int, charmMeta *charm.Meta, ) (current int, _ txn.Op, _ error) { currentCountOp, currentCount, err := im.countEntityStorageInstances(owner, storageName) if err != nil { return -1, txn.Op{}, errors.Trace(err) } charmStorage := charmMeta.Storage[storageName] if err := validateCharmStorageCountChange(charmStorage, currentCount, n); err != nil { return -1, txn.Op{}, errors.Trace(err) } return currentCount, currentCountOp, nil }
[ "func", "validateStorageCountChange", "(", "im", "*", "storageBackend", ",", "owner", "names", ".", "Tag", ",", "storageName", "string", ",", "n", "int", ",", "charmMeta", "*", "charm", ".", "Meta", ",", ")", "(", "current", "int", ",", "_", "txn", ".", "Op", ",", "_", "error", ")", "{", "currentCountOp", ",", "currentCount", ",", "err", ":=", "im", ".", "countEntityStorageInstances", "(", "owner", ",", "storageName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "txn", ".", "Op", "{", "}", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "charmStorage", ":=", "charmMeta", ".", "Storage", "[", "storageName", "]", "\n", "if", "err", ":=", "validateCharmStorageCountChange", "(", "charmStorage", ",", "currentCount", ",", "n", ")", ";", "err", "!=", "nil", "{", "return", "-", "1", ",", "txn", ".", "Op", "{", "}", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "currentCount", ",", "currentCountOp", ",", "nil", "\n", "}" ]
// validateStorageCountChange validates the desired storage count change, // and returns the current storage count, and a txn.Op that ensures the // current storage count does not change before the transaction is executed.
[ "validateStorageCountChange", "validates", "the", "desired", "storage", "count", "change", "and", "returns", "the", "current", "storage", "count", "and", "a", "txn", ".", "Op", "that", "ensures", "the", "current", "storage", "count", "does", "not", "change", "before", "the", "transaction", "is", "executed", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L680-L694
156,293
juju/juju
state/storage.go
increfEntityStorageOp
func increfEntityStorageOp(mb modelBackend, owner names.Tag, storageName string, n int) (txn.Op, error) { refcounts, closer := mb.db().GetCollection(refcountsC) defer closer() storageRefcountKey := entityStorageRefcountKey(owner, storageName) incRefOp, err := nsRefcounts.CreateOrIncRefOp(refcounts, storageRefcountKey, n) return incRefOp, errors.Trace(err) }
go
func increfEntityStorageOp(mb modelBackend, owner names.Tag, storageName string, n int) (txn.Op, error) { refcounts, closer := mb.db().GetCollection(refcountsC) defer closer() storageRefcountKey := entityStorageRefcountKey(owner, storageName) incRefOp, err := nsRefcounts.CreateOrIncRefOp(refcounts, storageRefcountKey, n) return incRefOp, errors.Trace(err) }
[ "func", "increfEntityStorageOp", "(", "mb", "modelBackend", ",", "owner", "names", ".", "Tag", ",", "storageName", "string", ",", "n", "int", ")", "(", "txn", ".", "Op", ",", "error", ")", "{", "refcounts", ",", "closer", ":=", "mb", ".", "db", "(", ")", ".", "GetCollection", "(", "refcountsC", ")", "\n", "defer", "closer", "(", ")", "\n", "storageRefcountKey", ":=", "entityStorageRefcountKey", "(", "owner", ",", "storageName", ")", "\n", "incRefOp", ",", "err", ":=", "nsRefcounts", ".", "CreateOrIncRefOp", "(", "refcounts", ",", "storageRefcountKey", ",", "n", ")", "\n", "return", "incRefOp", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}" ]
// increfEntityStorageOp returns a txn.Op that increments the reference // count for a storage instance for a given application or unit. This // should be called when creating a shared storage instance, or when // attaching a non-shared storage instance to a unit.
[ "increfEntityStorageOp", "returns", "a", "txn", ".", "Op", "that", "increments", "the", "reference", "count", "for", "a", "storage", "instance", "for", "a", "given", "application", "or", "unit", ".", "This", "should", "be", "called", "when", "creating", "a", "shared", "storage", "instance", "or", "when", "attaching", "a", "non", "-", "shared", "storage", "instance", "to", "a", "unit", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L700-L706
156,294
juju/juju
state/storage.go
decrefEntityStorageOp
func decrefEntityStorageOp(mb modelBackend, owner names.Tag, storageName string) (txn.Op, error) { refcounts, closer := mb.db().GetCollection(refcountsC) defer closer() storageRefcountKey := entityStorageRefcountKey(owner, storageName) decRefOp, _, err := nsRefcounts.DyingDecRefOp(refcounts, storageRefcountKey) if err != nil { return txn.Op{}, errors.Trace(err) } return decRefOp, nil }
go
func decrefEntityStorageOp(mb modelBackend, owner names.Tag, storageName string) (txn.Op, error) { refcounts, closer := mb.db().GetCollection(refcountsC) defer closer() storageRefcountKey := entityStorageRefcountKey(owner, storageName) decRefOp, _, err := nsRefcounts.DyingDecRefOp(refcounts, storageRefcountKey) if err != nil { return txn.Op{}, errors.Trace(err) } return decRefOp, nil }
[ "func", "decrefEntityStorageOp", "(", "mb", "modelBackend", ",", "owner", "names", ".", "Tag", ",", "storageName", "string", ")", "(", "txn", ".", "Op", ",", "error", ")", "{", "refcounts", ",", "closer", ":=", "mb", ".", "db", "(", ")", ".", "GetCollection", "(", "refcountsC", ")", "\n", "defer", "closer", "(", ")", "\n", "storageRefcountKey", ":=", "entityStorageRefcountKey", "(", "owner", ",", "storageName", ")", "\n", "decRefOp", ",", "_", ",", "err", ":=", "nsRefcounts", ".", "DyingDecRefOp", "(", "refcounts", ",", "storageRefcountKey", ")", "\n", "if", "err", "!=", "nil", "{", "return", "txn", ".", "Op", "{", "}", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "decRefOp", ",", "nil", "\n", "}" ]
// decrefEntityStorageOp returns a txn.Op that decrements the reference // count for a storage instance from a given application or unit. This // should be called when removing a shared storage instance, or when // detaching a non-shared storage instance from a unit.
[ "decrefEntityStorageOp", "returns", "a", "txn", ".", "Op", "that", "decrements", "the", "reference", "count", "for", "a", "storage", "instance", "from", "a", "given", "application", "or", "unit", ".", "This", "should", "be", "called", "when", "removing", "a", "shared", "storage", "instance", "or", "when", "detaching", "a", "non", "-", "shared", "storage", "instance", "from", "a", "unit", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L712-L721
156,295
juju/juju
state/storage.go
unitAssignedMachineStorageOps
func unitAssignedMachineStorageOps( sb *storageBackend, unitTag names.UnitTag, charmMeta *charm.Meta, series string, storage *storageInstance, machineAssignable machineAssignable, ) (ops []txn.Op, err error) { m, err := machineAssignable.machine() if err != nil { if errors.IsNotAssigned(err) { // The unit is not assigned to a machine; return // txn.Op that ensures that this remains the case // until the transaction is committed. return []txn.Op{machineAssignable.noAssignedMachineOp()}, nil } return nil, errors.Trace(err) } storageParams, err := storageParamsForStorageInstance( sb, charmMeta, unitTag, series, storage, ) if err != nil { return nil, errors.Trace(err) } if err := validateDynamicMachineStorageParams(m, storageParams); err != nil { return nil, errors.Trace(err) } storageOps, volumeAttachments, filesystemAttachments, err := sb.hostStorageOps( m.doc.Id, storageParams, ) if err != nil { return nil, errors.Trace(err) } attachmentOps, err := addMachineStorageAttachmentsOps( m, volumeAttachments, filesystemAttachments, ) if err != nil { return nil, errors.Trace(err) } storageOps = append(storageOps, attachmentOps...) return storageOps, nil }
go
func unitAssignedMachineStorageOps( sb *storageBackend, unitTag names.UnitTag, charmMeta *charm.Meta, series string, storage *storageInstance, machineAssignable machineAssignable, ) (ops []txn.Op, err error) { m, err := machineAssignable.machine() if err != nil { if errors.IsNotAssigned(err) { // The unit is not assigned to a machine; return // txn.Op that ensures that this remains the case // until the transaction is committed. return []txn.Op{machineAssignable.noAssignedMachineOp()}, nil } return nil, errors.Trace(err) } storageParams, err := storageParamsForStorageInstance( sb, charmMeta, unitTag, series, storage, ) if err != nil { return nil, errors.Trace(err) } if err := validateDynamicMachineStorageParams(m, storageParams); err != nil { return nil, errors.Trace(err) } storageOps, volumeAttachments, filesystemAttachments, err := sb.hostStorageOps( m.doc.Id, storageParams, ) if err != nil { return nil, errors.Trace(err) } attachmentOps, err := addMachineStorageAttachmentsOps( m, volumeAttachments, filesystemAttachments, ) if err != nil { return nil, errors.Trace(err) } storageOps = append(storageOps, attachmentOps...) return storageOps, nil }
[ "func", "unitAssignedMachineStorageOps", "(", "sb", "*", "storageBackend", ",", "unitTag", "names", ".", "UnitTag", ",", "charmMeta", "*", "charm", ".", "Meta", ",", "series", "string", ",", "storage", "*", "storageInstance", ",", "machineAssignable", "machineAssignable", ",", ")", "(", "ops", "[", "]", "txn", ".", "Op", ",", "err", "error", ")", "{", "m", ",", "err", ":=", "machineAssignable", ".", "machine", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "errors", ".", "IsNotAssigned", "(", "err", ")", "{", "// The unit is not assigned to a machine; return", "// txn.Op that ensures that this remains the case", "// until the transaction is committed.", "return", "[", "]", "txn", ".", "Op", "{", "machineAssignable", ".", "noAssignedMachineOp", "(", ")", "}", ",", "nil", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "storageParams", ",", "err", ":=", "storageParamsForStorageInstance", "(", "sb", ",", "charmMeta", ",", "unitTag", ",", "series", ",", "storage", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "validateDynamicMachineStorageParams", "(", "m", ",", "storageParams", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "storageOps", ",", "volumeAttachments", ",", "filesystemAttachments", ",", "err", ":=", "sb", ".", "hostStorageOps", "(", "m", ".", "doc", ".", "Id", ",", "storageParams", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "attachmentOps", ",", "err", ":=", "addMachineStorageAttachmentsOps", "(", "m", ",", "volumeAttachments", ",", "filesystemAttachments", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "storageOps", "=", "append", "(", "storageOps", ",", "attachmentOps", "...", ")", "\n", "return", "storageOps", ",", "nil", "\n", "}" ]
// unitAssignedMachineStorageOps returns ops for creating volumes, filesystems // and their attachments to the machine that the specified unit is assigned to, // corresponding to the specified storage instance. // // If the unit is not assigned to a machine, then ops will be returned to assert // this, and no error will be returned.
[ "unitAssignedMachineStorageOps", "returns", "ops", "for", "creating", "volumes", "filesystems", "and", "their", "attachments", "to", "the", "machine", "that", "the", "specified", "unit", "is", "assigned", "to", "corresponding", "to", "the", "specified", "storage", "instance", ".", "If", "the", "unit", "is", "not", "assigned", "to", "a", "machine", "then", "ops", "will", "be", "returned", "to", "assert", "this", "and", "no", "error", "will", "be", "returned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L902-L944
156,296
juju/juju
state/storage.go
createStorageAttachmentOp
func createStorageAttachmentOp(storage names.StorageTag, unit names.UnitTag) txn.Op { return txn.Op{ C: storageAttachmentsC, Id: storageAttachmentId(unit.Id(), storage.Id()), Assert: txn.DocMissing, Insert: &storageAttachmentDoc{ Unit: unit.Id(), StorageInstance: storage.Id(), }, } }
go
func createStorageAttachmentOp(storage names.StorageTag, unit names.UnitTag) txn.Op { return txn.Op{ C: storageAttachmentsC, Id: storageAttachmentId(unit.Id(), storage.Id()), Assert: txn.DocMissing, Insert: &storageAttachmentDoc{ Unit: unit.Id(), StorageInstance: storage.Id(), }, } }
[ "func", "createStorageAttachmentOp", "(", "storage", "names", ".", "StorageTag", ",", "unit", "names", ".", "UnitTag", ")", "txn", ".", "Op", "{", "return", "txn", ".", "Op", "{", "C", ":", "storageAttachmentsC", ",", "Id", ":", "storageAttachmentId", "(", "unit", ".", "Id", "(", ")", ",", "storage", ".", "Id", "(", ")", ")", ",", "Assert", ":", "txn", ".", "DocMissing", ",", "Insert", ":", "&", "storageAttachmentDoc", "{", "Unit", ":", "unit", ".", "Id", "(", ")", ",", "StorageInstance", ":", "storage", ".", "Id", "(", ")", ",", "}", ",", "}", "\n", "}" ]
// createStorageAttachmentOps returns a txn.Op for creating a storage attachment. // The caller is responsible for updating the attachmentcount field of the storage // instance.
[ "createStorageAttachmentOps", "returns", "a", "txn", ".", "Op", "for", "creating", "a", "storage", "attachment", ".", "The", "caller", "is", "responsible", "for", "updating", "the", "attachmentcount", "field", "of", "the", "storage", "instance", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L949-L959
156,297
juju/juju
state/storage.go
StorageAttachments
func (sb *storageBackend) StorageAttachments(storage names.StorageTag) ([]StorageAttachment, error) { query := bson.D{{"storageid", storage.Id()}} attachments, err := sb.storageAttachments(query) if err != nil { return nil, errors.Annotatef(err, "cannot get storage attachments for storage %s", storage.Id()) } return attachments, nil }
go
func (sb *storageBackend) StorageAttachments(storage names.StorageTag) ([]StorageAttachment, error) { query := bson.D{{"storageid", storage.Id()}} attachments, err := sb.storageAttachments(query) if err != nil { return nil, errors.Annotatef(err, "cannot get storage attachments for storage %s", storage.Id()) } return attachments, nil }
[ "func", "(", "sb", "*", "storageBackend", ")", "StorageAttachments", "(", "storage", "names", ".", "StorageTag", ")", "(", "[", "]", "StorageAttachment", ",", "error", ")", "{", "query", ":=", "bson", ".", "D", "{", "{", "\"", "\"", ",", "storage", ".", "Id", "(", ")", "}", "}", "\n", "attachments", ",", "err", ":=", "sb", ".", "storageAttachments", "(", "query", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "storage", ".", "Id", "(", ")", ")", "\n", "}", "\n", "return", "attachments", ",", "nil", "\n", "}" ]
// StorageAttachments returns the StorageAttachments for the specified storage // instance.
[ "StorageAttachments", "returns", "the", "StorageAttachments", "for", "the", "specified", "storage", "instance", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L963-L970
156,298
juju/juju
state/storage.go
UnitStorageAttachments
func (sb *storageBackend) UnitStorageAttachments(unit names.UnitTag) ([]StorageAttachment, error) { query := bson.D{{"unitid", unit.Id()}} attachments, err := sb.storageAttachments(query) if err != nil { return nil, errors.Annotatef(err, "cannot get storage attachments for unit %s", unit.Id()) } return attachments, nil }
go
func (sb *storageBackend) UnitStorageAttachments(unit names.UnitTag) ([]StorageAttachment, error) { query := bson.D{{"unitid", unit.Id()}} attachments, err := sb.storageAttachments(query) if err != nil { return nil, errors.Annotatef(err, "cannot get storage attachments for unit %s", unit.Id()) } return attachments, nil }
[ "func", "(", "sb", "*", "storageBackend", ")", "UnitStorageAttachments", "(", "unit", "names", ".", "UnitTag", ")", "(", "[", "]", "StorageAttachment", ",", "error", ")", "{", "query", ":=", "bson", ".", "D", "{", "{", "\"", "\"", ",", "unit", ".", "Id", "(", ")", "}", "}", "\n", "attachments", ",", "err", ":=", "sb", ".", "storageAttachments", "(", "query", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotatef", "(", "err", ",", "\"", "\"", ",", "unit", ".", "Id", "(", ")", ")", "\n", "}", "\n", "return", "attachments", ",", "nil", "\n", "}" ]
// UnitStorageAttachments returns the StorageAttachments for the specified unit.
[ "UnitStorageAttachments", "returns", "the", "StorageAttachments", "for", "the", "specified", "unit", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L973-L980
156,299
juju/juju
state/storage.go
StorageAttachment
func (sb *storageBackend) StorageAttachment(storage names.StorageTag, unit names.UnitTag) (StorageAttachment, error) { att, err := sb.storageAttachment(storage, unit) if err != nil { return nil, errors.Trace(err) } return att, nil }
go
func (sb *storageBackend) StorageAttachment(storage names.StorageTag, unit names.UnitTag) (StorageAttachment, error) { att, err := sb.storageAttachment(storage, unit) if err != nil { return nil, errors.Trace(err) } return att, nil }
[ "func", "(", "sb", "*", "storageBackend", ")", "StorageAttachment", "(", "storage", "names", ".", "StorageTag", ",", "unit", "names", ".", "UnitTag", ")", "(", "StorageAttachment", ",", "error", ")", "{", "att", ",", "err", ":=", "sb", ".", "storageAttachment", "(", "storage", ",", "unit", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "att", ",", "nil", "\n", "}" ]
// StorageAttachment returns the StorageAttachment with the specified tags.
[ "StorageAttachment", "returns", "the", "StorageAttachment", "with", "the", "specified", "tags", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/storage.go#L998-L1004