id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
157,400
juju/juju
worker/retrystrategy/manifold.go
Manifold
func Manifold(config ManifoldConfig) dependency.Manifold { typedConfig := engine.AgentAPIManifoldConfig{ AgentName: config.AgentName, APICallerName: config.APICallerName, } manifold := engine.AgentAPIManifold(typedConfig, config.start) manifold.Output = config.output return manifold }
go
func Manifold(config ManifoldConfig) dependency.Manifold { typedConfig := engine.AgentAPIManifoldConfig{ AgentName: config.AgentName, APICallerName: config.APICallerName, } manifold := engine.AgentAPIManifold(typedConfig, config.start) manifold.Output = config.output return manifold }
[ "func", "Manifold", "(", "config", "ManifoldConfig", ")", "dependency", ".", "Manifold", "{", "typedConfig", ":=", "engine", ".", "AgentAPIManifoldConfig", "{", "AgentName", ":", "config", ".", "AgentName", ",", "APICallerName", ":", "config", ".", "APICallerName"...
// Manifold returns a dependency manifold that runs a hook retry strategy worker, // using the agent name and the api connection resources named in the supplied config.
[ "Manifold", "returns", "a", "dependency", "manifold", "that", "runs", "a", "hook", "retry", "strategy", "worker", "using", "the", "agent", "name", "and", "the", "api", "connection", "resources", "named", "in", "the", "supplied", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/retrystrategy/manifold.go#L28-L36
157,401
juju/juju
cmd/jujud/util/util.go
IsFatal
func IsFatal(err error) bool { err = errors.Cause(err) switch err { case jworker.ErrTerminateAgent, jworker.ErrRebootMachine, jworker.ErrShutdownMachine, jworker.ErrRestartAgent: return true } if isUpgraded(err) { return true } _, ok := err.(*FatalError) return ok }
go
func IsFatal(err error) bool { err = errors.Cause(err) switch err { case jworker.ErrTerminateAgent, jworker.ErrRebootMachine, jworker.ErrShutdownMachine, jworker.ErrRestartAgent: return true } if isUpgraded(err) { return true } _, ok := err.(*FatalError) return ok }
[ "func", "IsFatal", "(", "err", "error", ")", "bool", "{", "err", "=", "errors", ".", "Cause", "(", "err", ")", "\n", "switch", "err", "{", "case", "jworker", ".", "ErrTerminateAgent", ",", "jworker", ".", "ErrRebootMachine", ",", "jworker", ".", "ErrShut...
// IsFatal determines if an error is fatal to the process.
[ "IsFatal", "determines", "if", "an", "error", "is", "fatal", "to", "the", "process", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/jujud/util/util.go#L36-L48
157,402
juju/juju
cmd/jujud/util/util.go
MoreImportantError
func MoreImportantError(err0, err1 error) error { if importance(err0) > importance(err1) { return err0 } return err1 }
go
func MoreImportantError(err0, err1 error) error { if importance(err0) > importance(err1) { return err0 } return err1 }
[ "func", "MoreImportantError", "(", "err0", ",", "err1", "error", ")", "error", "{", "if", "importance", "(", "err0", ")", ">", "importance", "(", "err1", ")", "{", "return", "err0", "\n", "}", "\n", "return", "err1", "\n", "}" ]
// MoreImportantError returns the most important error
[ "MoreImportantError", "returns", "the", "most", "important", "error" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/jujud/util/util.go#L90-L95
157,403
juju/juju
cmd/jujud/util/util.go
AgentDone
func AgentDone(logger loggo.Logger, err error) error { err = errors.Cause(err) switch err { case jworker.ErrTerminateAgent, jworker.ErrRebootMachine, jworker.ErrShutdownMachine: // These errors are swallowed here because we want to exit // the agent process without error, to avoid the init system // restarting us. err = nil } if ug, ok := err.(*upgrader.UpgradeReadyError); ok { if err := ug.ChangeAgentTools(); err != nil { // Return and let the init system deal with the restart. err = errors.Annotate(err, "cannot change agent binaries") logger.Infof(err.Error()) return err } } if err == jworker.ErrRestartAgent { logger.Warningf("agent restarting") } return err }
go
func AgentDone(logger loggo.Logger, err error) error { err = errors.Cause(err) switch err { case jworker.ErrTerminateAgent, jworker.ErrRebootMachine, jworker.ErrShutdownMachine: // These errors are swallowed here because we want to exit // the agent process without error, to avoid the init system // restarting us. err = nil } if ug, ok := err.(*upgrader.UpgradeReadyError); ok { if err := ug.ChangeAgentTools(); err != nil { // Return and let the init system deal with the restart. err = errors.Annotate(err, "cannot change agent binaries") logger.Infof(err.Error()) return err } } if err == jworker.ErrRestartAgent { logger.Warningf("agent restarting") } return err }
[ "func", "AgentDone", "(", "logger", "loggo", ".", "Logger", ",", "err", "error", ")", "error", "{", "err", "=", "errors", ".", "Cause", "(", "err", ")", "\n", "switch", "err", "{", "case", "jworker", ".", "ErrTerminateAgent", ",", "jworker", ".", "ErrR...
// AgentDone processes the error returned by an exiting agent.
[ "AgentDone", "processes", "the", "error", "returned", "by", "an", "exiting", "agent", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/jujud/util/util.go#L98-L119
157,404
juju/juju
cmd/jujud/util/util.go
ConnectionIsFatal
func ConnectionIsFatal(logger loggo.Logger, conns ...Breakable) func(err error) bool { return func(err error) bool { if IsFatal(err) { return true } for _, conn := range conns { if ConnectionIsDead(logger, conn) { return true } } return false } }
go
func ConnectionIsFatal(logger loggo.Logger, conns ...Breakable) func(err error) bool { return func(err error) bool { if IsFatal(err) { return true } for _, conn := range conns { if ConnectionIsDead(logger, conn) { return true } } return false } }
[ "func", "ConnectionIsFatal", "(", "logger", "loggo", ".", "Logger", ",", "conns", "...", "Breakable", ")", "func", "(", "err", "error", ")", "bool", "{", "return", "func", "(", "err", "error", ")", "bool", "{", "if", "IsFatal", "(", "err", ")", "{", ...
// ConnectionIsFatal returns a function suitable for passing as the // isFatal argument to worker.NewRunner, that diagnoses an error as // fatal if the connection has failed or if the error is otherwise // fatal.
[ "ConnectionIsFatal", "returns", "a", "function", "suitable", "for", "passing", "as", "the", "isFatal", "argument", "to", "worker", ".", "NewRunner", "that", "diagnoses", "an", "error", "as", "fatal", "if", "the", "connection", "has", "failed", "or", "if", "the...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/jujud/util/util.go#L130-L142
157,405
juju/juju
cmd/jujud/util/util.go
NewEnsureServerParams
func NewEnsureServerParams(agentConfig agent.Config) (mongo.EnsureServerParams, error) { // If oplog size is specified in the agent configuration, use that. // Otherwise leave the default zero value to indicate to EnsureServer // that it should calculate the size. var oplogSize int if oplogSizeString := agentConfig.Value(agent.MongoOplogSize); oplogSizeString != "" { var err error if oplogSize, err = strconv.Atoi(oplogSizeString); err != nil { return mongo.EnsureServerParams{}, fmt.Errorf("invalid oplog size: %q", oplogSizeString) } } // If numa ctl preference is specified in the agent configuration, use that. // Otherwise leave the default false value to indicate to EnsureServer // that numactl should not be used. var numaCtlPolicy bool if numaCtlString := agentConfig.Value(agent.NUMACtlPreference); numaCtlString != "" { var err error if numaCtlPolicy, err = strconv.ParseBool(numaCtlString); err != nil { return mongo.EnsureServerParams{}, fmt.Errorf("invalid numactl preference: %q", numaCtlString) } } si, ok := agentConfig.StateServingInfo() if !ok { return mongo.EnsureServerParams{}, fmt.Errorf("agent config has no state serving info") } params := mongo.EnsureServerParams{ APIPort: si.APIPort, StatePort: si.StatePort, Cert: si.Cert, PrivateKey: si.PrivateKey, CAPrivateKey: si.CAPrivateKey, SharedSecret: si.SharedSecret, SystemIdentity: si.SystemIdentity, DataDir: agentConfig.DataDir(), OplogSize: oplogSize, SetNUMAControlPolicy: numaCtlPolicy, MemoryProfile: agentConfig.MongoMemoryProfile(), } return params, nil }
go
func NewEnsureServerParams(agentConfig agent.Config) (mongo.EnsureServerParams, error) { // If oplog size is specified in the agent configuration, use that. // Otherwise leave the default zero value to indicate to EnsureServer // that it should calculate the size. var oplogSize int if oplogSizeString := agentConfig.Value(agent.MongoOplogSize); oplogSizeString != "" { var err error if oplogSize, err = strconv.Atoi(oplogSizeString); err != nil { return mongo.EnsureServerParams{}, fmt.Errorf("invalid oplog size: %q", oplogSizeString) } } // If numa ctl preference is specified in the agent configuration, use that. // Otherwise leave the default false value to indicate to EnsureServer // that numactl should not be used. var numaCtlPolicy bool if numaCtlString := agentConfig.Value(agent.NUMACtlPreference); numaCtlString != "" { var err error if numaCtlPolicy, err = strconv.ParseBool(numaCtlString); err != nil { return mongo.EnsureServerParams{}, fmt.Errorf("invalid numactl preference: %q", numaCtlString) } } si, ok := agentConfig.StateServingInfo() if !ok { return mongo.EnsureServerParams{}, fmt.Errorf("agent config has no state serving info") } params := mongo.EnsureServerParams{ APIPort: si.APIPort, StatePort: si.StatePort, Cert: si.Cert, PrivateKey: si.PrivateKey, CAPrivateKey: si.CAPrivateKey, SharedSecret: si.SharedSecret, SystemIdentity: si.SystemIdentity, DataDir: agentConfig.DataDir(), OplogSize: oplogSize, SetNUMAControlPolicy: numaCtlPolicy, MemoryProfile: agentConfig.MongoMemoryProfile(), } return params, nil }
[ "func", "NewEnsureServerParams", "(", "agentConfig", "agent", ".", "Config", ")", "(", "mongo", ".", "EnsureServerParams", ",", "error", ")", "{", "// If oplog size is specified in the agent configuration, use that.", "// Otherwise leave the default zero value to indicate to Ensure...
// NewEnsureServerParams creates an EnsureServerParams from an agent // configuration.
[ "NewEnsureServerParams", "creates", "an", "EnsureServerParams", "from", "an", "agent", "configuration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/jujud/util/util.go#L189-L233
157,406
juju/juju
api/common/stream/stream.go
Open
func Open(conn base.StreamConnector, path string, cfg interface{}) (base.Stream, error) { attrs, err := query.Values(cfg) if err != nil { return nil, errors.Annotate(err, "failed to generate URL query from config") } stream, err := conn.ConnectStream(path, attrs) if err != nil { return nil, errors.Annotatef(err, "cannot connect to %s", path) } return stream, nil }
go
func Open(conn base.StreamConnector, path string, cfg interface{}) (base.Stream, error) { attrs, err := query.Values(cfg) if err != nil { return nil, errors.Annotate(err, "failed to generate URL query from config") } stream, err := conn.ConnectStream(path, attrs) if err != nil { return nil, errors.Annotatef(err, "cannot connect to %s", path) } return stream, nil }
[ "func", "Open", "(", "conn", "base", ".", "StreamConnector", ",", "path", "string", ",", "cfg", "interface", "{", "}", ")", "(", "base", ".", "Stream", ",", "error", ")", "{", "attrs", ",", "err", ":=", "query", ".", "Values", "(", "cfg", ")", "\n"...
// Open opens a streaming connection to the endpoint path that conforms // to the provided config.
[ "Open", "opens", "a", "streaming", "connection", "to", "the", "endpoint", "path", "that", "conforms", "to", "the", "provided", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/stream/stream.go#L15-L25
157,407
juju/juju
api/applicationscaler/api.go
NewAPI
func NewAPI(caller base.APICaller, newWatcher NewWatcherFunc) *API { return &API{ caller: base.NewFacadeCaller(caller, "ApplicationScaler"), newWatcher: newWatcher, } }
go
func NewAPI(caller base.APICaller, newWatcher NewWatcherFunc) *API { return &API{ caller: base.NewFacadeCaller(caller, "ApplicationScaler"), newWatcher: newWatcher, } }
[ "func", "NewAPI", "(", "caller", "base", ".", "APICaller", ",", "newWatcher", "NewWatcherFunc", ")", "*", "API", "{", "return", "&", "API", "{", "caller", ":", "base", ".", "NewFacadeCaller", "(", "caller", ",", "\"", "\"", ")", ",", "newWatcher", ":", ...
// NewAPI returns a new API using the supplied caller.
[ "NewAPI", "returns", "a", "new", "API", "using", "the", "supplied", "caller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/applicationscaler/api.go#L28-L33
157,408
juju/juju
api/applicationscaler/api.go
Watch
func (api *API) Watch() (watcher.StringsWatcher, error) { var result params.StringsWatchResult err := api.caller.FacadeCall("Watch", nil, &result) if err != nil { return nil, errors.Trace(err) } if result.Error != nil { return nil, errors.Trace(result.Error) } w := api.newWatcher(api.caller.RawAPICaller(), result) return w, nil }
go
func (api *API) Watch() (watcher.StringsWatcher, error) { var result params.StringsWatchResult err := api.caller.FacadeCall("Watch", nil, &result) if err != nil { return nil, errors.Trace(err) } if result.Error != nil { return nil, errors.Trace(result.Error) } w := api.newWatcher(api.caller.RawAPICaller(), result) return w, nil }
[ "func", "(", "api", "*", "API", ")", "Watch", "(", ")", "(", "watcher", ".", "StringsWatcher", ",", "error", ")", "{", "var", "result", "params", ".", "StringsWatchResult", "\n", "err", ":=", "api", ".", "caller", ".", "FacadeCall", "(", "\"", "\"", ...
// Watch returns a StringsWatcher that delivers the names of applications // that may need to be rescaled.
[ "Watch", "returns", "a", "StringsWatcher", "that", "delivers", "the", "names", "of", "applications", "that", "may", "need", "to", "be", "rescaled", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/applicationscaler/api.go#L37-L48
157,409
juju/juju
api/applicationscaler/api.go
Rescale
func (api *API) Rescale(applications []string) error { args := params.Entities{ Entities: make([]params.Entity, len(applications)), } for i, application := range applications { if !names.IsValidApplication(application) { return errors.NotValidf("application name %q", application) } tag := names.NewApplicationTag(application) args.Entities[i].Tag = tag.String() } var results params.ErrorResults err := api.caller.FacadeCall("Rescale", args, &results) if err != nil { return errors.Trace(err) } for _, result := range results.Results { if result.Error != nil { if err == nil { err = result.Error } else { logger.Errorf("additional rescale error: %v", err) } } } return errors.Trace(err) }
go
func (api *API) Rescale(applications []string) error { args := params.Entities{ Entities: make([]params.Entity, len(applications)), } for i, application := range applications { if !names.IsValidApplication(application) { return errors.NotValidf("application name %q", application) } tag := names.NewApplicationTag(application) args.Entities[i].Tag = tag.String() } var results params.ErrorResults err := api.caller.FacadeCall("Rescale", args, &results) if err != nil { return errors.Trace(err) } for _, result := range results.Results { if result.Error != nil { if err == nil { err = result.Error } else { logger.Errorf("additional rescale error: %v", err) } } } return errors.Trace(err) }
[ "func", "(", "api", "*", "API", ")", "Rescale", "(", "applications", "[", "]", "string", ")", "error", "{", "args", ":=", "params", ".", "Entities", "{", "Entities", ":", "make", "(", "[", "]", "params", ".", "Entity", ",", "len", "(", "applications"...
// Rescale requests that all supplied application names be rescaled to // their minimum configured sizes. It returns the first error it // encounters.
[ "Rescale", "requests", "that", "all", "supplied", "application", "names", "be", "rescaled", "to", "their", "minimum", "configured", "sizes", ".", "It", "returns", "the", "first", "error", "it", "encounters", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/applicationscaler/api.go#L53-L79
157,410
juju/juju
provider/common/errors.go
ZoneIndependentError
func ZoneIndependentError(err error) error { if err == nil { return nil } wrapped := errors.Wrap(err, zoneIndependentError{err}) wrapped.(*errors.Err).SetLocation(1) return wrapped }
go
func ZoneIndependentError(err error) error { if err == nil { return nil } wrapped := errors.Wrap(err, zoneIndependentError{err}) wrapped.(*errors.Err).SetLocation(1) return wrapped }
[ "func", "ZoneIndependentError", "(", "err", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "wrapped", ":=", "errors", ".", "Wrap", "(", "err", ",", "zoneIndependentError", "{", "err", "}", ")", "\n", "wrapp...
// ZoneIndependentError wraps the given error such that it // satisfies environs.IsAvailabilityZoneIndependent.
[ "ZoneIndependentError", "wraps", "the", "given", "error", "such", "that", "it", "satisfies", "environs", ".", "IsAvailabilityZoneIndependent", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/errors.go#L17-L24
157,411
juju/juju
provider/common/errors.go
MaybeHandleCredentialError
func MaybeHandleCredentialError(isAuthError func(error) bool, err error, ctx context.ProviderCallContext) bool { denied := isAuthError(errors.Cause(err)) if ctx != nil && denied { invalidateErr := ctx.InvalidateCredential("cloud denied access") if invalidateErr != nil { logger.Warningf("could not invalidate stored cloud credential on the controller: %v", invalidateErr) } } return denied }
go
func MaybeHandleCredentialError(isAuthError func(error) bool, err error, ctx context.ProviderCallContext) bool { denied := isAuthError(errors.Cause(err)) if ctx != nil && denied { invalidateErr := ctx.InvalidateCredential("cloud denied access") if invalidateErr != nil { logger.Warningf("could not invalidate stored cloud credential on the controller: %v", invalidateErr) } } return denied }
[ "func", "MaybeHandleCredentialError", "(", "isAuthError", "func", "(", "error", ")", "bool", ",", "err", "error", ",", "ctx", "context", ".", "ProviderCallContext", ")", "bool", "{", "denied", ":=", "isAuthError", "(", "errors", ".", "Cause", "(", "err", ")"...
// MaybeHandleCredentialError determines if a given error relates to an invalid credential. // If it is, the credential is invalidated and the return bool is true.
[ "MaybeHandleCredentialError", "determines", "if", "a", "given", "error", "relates", "to", "an", "invalid", "credential", ".", "If", "it", "is", "the", "credential", "is", "invalidated", "and", "the", "return", "bool", "is", "true", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/errors.go#L88-L97
157,412
juju/juju
provider/common/errors.go
HandleCredentialError
func HandleCredentialError(isAuthError func(error) bool, err error, ctx context.ProviderCallContext) { MaybeHandleCredentialError(isAuthError, err, ctx) }
go
func HandleCredentialError(isAuthError func(error) bool, err error, ctx context.ProviderCallContext) { MaybeHandleCredentialError(isAuthError, err, ctx) }
[ "func", "HandleCredentialError", "(", "isAuthError", "func", "(", "error", ")", "bool", ",", "err", "error", ",", "ctx", "context", ".", "ProviderCallContext", ")", "{", "MaybeHandleCredentialError", "(", "isAuthError", ",", "err", ",", "ctx", ")", "\n", "}" ]
// HandleCredentialError determines if a given error relates to an invalid credential.
[ "HandleCredentialError", "determines", "if", "a", "given", "error", "relates", "to", "an", "invalid", "credential", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/errors.go#L100-L102
157,413
juju/juju
caas/kubernetes/provider/provider.go
Open
func (p kubernetesEnvironProvider) Open(args environs.OpenParams) (caas.Broker, error) { logger.Debugf("opening model %q.", args.Config.Name()) if err := p.validateCloudSpec(args.Cloud); err != nil { return nil, errors.Annotate(err, "validating cloud spec") } k8sRestConfig, err := cloudSpecToK8sRestConfig(args.Cloud) if err != nil { return nil, errors.Trace(err) } broker, err := NewK8sBroker( args.ControllerUUID, k8sRestConfig, args.Config, newK8sClient, newKubernetesWatcher, jujuclock.WallClock, ) if err != nil { return nil, err } return controllerCorelation(broker) }
go
func (p kubernetesEnvironProvider) Open(args environs.OpenParams) (caas.Broker, error) { logger.Debugf("opening model %q.", args.Config.Name()) if err := p.validateCloudSpec(args.Cloud); err != nil { return nil, errors.Annotate(err, "validating cloud spec") } k8sRestConfig, err := cloudSpecToK8sRestConfig(args.Cloud) if err != nil { return nil, errors.Trace(err) } broker, err := NewK8sBroker( args.ControllerUUID, k8sRestConfig, args.Config, newK8sClient, newKubernetesWatcher, jujuclock.WallClock, ) if err != nil { return nil, err } return controllerCorelation(broker) }
[ "func", "(", "p", "kubernetesEnvironProvider", ")", "Open", "(", "args", "environs", ".", "OpenParams", ")", "(", "caas", ".", "Broker", ",", "error", ")", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "args", ".", "Config", ".", "Name", "(", "...
// Open is part of the ContainerEnvironProvider interface.
[ "Open", "is", "part", "of", "the", "ContainerEnvironProvider", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/provider.go#L99-L115
157,414
juju/juju
caas/kubernetes/provider/provider.go
ParsePodSpec
func (kubernetesEnvironProvider) ParsePodSpec(in string) (*caas.PodSpec, error) { spec, err := parseK8sPodSpec(in) if err != nil { return nil, errors.Trace(err) } return spec, spec.Validate() }
go
func (kubernetesEnvironProvider) ParsePodSpec(in string) (*caas.PodSpec, error) { spec, err := parseK8sPodSpec(in) if err != nil { return nil, errors.Trace(err) } return spec, spec.Validate() }
[ "func", "(", "kubernetesEnvironProvider", ")", "ParsePodSpec", "(", "in", "string", ")", "(", "*", "caas", ".", "PodSpec", ",", "error", ")", "{", "spec", ",", "err", ":=", "parseK8sPodSpec", "(", "in", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// ParsePodSpec is part of the ContainerEnvironProvider interface.
[ "ParsePodSpec", "is", "part", "of", "the", "ContainerEnvironProvider", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/provider.go#L118-L124
157,415
juju/juju
core/auditlog/auditlog.go
AddRequest
func (r *Recorder) AddRequest(m RequestArgs) error { return errors.Trace(r.log.AddRequest(Request{ ConversationID: r.callID, ConnectionID: r.connectionID, RequestID: m.RequestID, When: r.clock.Now().Format(time.RFC3339), Facade: m.Facade, Method: m.Method, Version: m.Version, Args: m.Args, })) }
go
func (r *Recorder) AddRequest(m RequestArgs) error { return errors.Trace(r.log.AddRequest(Request{ ConversationID: r.callID, ConnectionID: r.connectionID, RequestID: m.RequestID, When: r.clock.Now().Format(time.RFC3339), Facade: m.Facade, Method: m.Method, Version: m.Version, Args: m.Args, })) }
[ "func", "(", "r", "*", "Recorder", ")", "AddRequest", "(", "m", "RequestArgs", ")", "error", "{", "return", "errors", ".", "Trace", "(", "r", ".", "log", ".", "AddRequest", "(", "Request", "{", "ConversationID", ":", "r", ".", "callID", ",", "Connectio...
// AddRequest records a method call to the API.
[ "AddRequest", "records", "a", "method", "call", "to", "the", "API", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/auditlog/auditlog.go#L144-L155
157,416
juju/juju
core/auditlog/auditlog.go
AddResponse
func (r *Recorder) AddResponse(m ResponseErrorsArgs) error { return errors.Trace(r.log.AddResponse(ResponseErrors{ ConversationID: r.callID, ConnectionID: r.connectionID, RequestID: m.RequestID, When: r.clock.Now().Format(time.RFC3339), Errors: m.Errors, })) }
go
func (r *Recorder) AddResponse(m ResponseErrorsArgs) error { return errors.Trace(r.log.AddResponse(ResponseErrors{ ConversationID: r.callID, ConnectionID: r.connectionID, RequestID: m.RequestID, When: r.clock.Now().Format(time.RFC3339), Errors: m.Errors, })) }
[ "func", "(", "r", "*", "Recorder", ")", "AddResponse", "(", "m", "ResponseErrorsArgs", ")", "error", "{", "return", "errors", ".", "Trace", "(", "r", ".", "log", ".", "AddResponse", "(", "ResponseErrors", "{", "ConversationID", ":", "r", ".", "callID", "...
// AddResponse records the result of a method call to the API.
[ "AddResponse", "records", "the", "result", "of", "a", "method", "call", "to", "the", "API", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/auditlog/auditlog.go#L158-L166
157,417
juju/juju
core/auditlog/auditlog.go
newConversationID
func newConversationID() string { buf := make([]byte, 8) rand.Read(buf) // Can't fail return hex.EncodeToString(buf) }
go
func newConversationID() string { buf := make([]byte, 8) rand.Read(buf) // Can't fail return hex.EncodeToString(buf) }
[ "func", "newConversationID", "(", ")", "string", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "8", ")", "\n", "rand", ".", "Read", "(", "buf", ")", "// Can't fail", "\n", "return", "hex", ".", "EncodeToString", "(", "buf", ")", "\n", "}" ]
// newConversationID generates a random 64bit integer as hex - this // will be used to link the requests and responses with the command // the user issued. We don't use the API server's connection ID here // because that starts from 0 and increments, so it resets when the // API server is restarted. The conversation ID needs to be unique // across restarts, otherwise we'd attribute requests to the wrong // conversation.
[ "newConversationID", "generates", "a", "random", "64bit", "integer", "as", "hex", "-", "this", "will", "be", "used", "to", "link", "the", "requests", "and", "responses", "with", "the", "command", "the", "user", "issued", ".", "We", "don", "t", "use", "the"...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/auditlog/auditlog.go#L175-L179
157,418
juju/juju
core/auditlog/auditlog.go
AddConversation
func (a *auditLogFile) AddConversation(c Conversation) error { return errors.Trace(a.addRecord(Record{Conversation: &c})) }
go
func (a *auditLogFile) AddConversation(c Conversation) error { return errors.Trace(a.addRecord(Record{Conversation: &c})) }
[ "func", "(", "a", "*", "auditLogFile", ")", "AddConversation", "(", "c", "Conversation", ")", "error", "{", "return", "errors", ".", "Trace", "(", "a", ".", "addRecord", "(", "Record", "{", "Conversation", ":", "&", "c", "}", ")", ")", "\n", "}" ]
// AddConversation implements AuditLog.
[ "AddConversation", "implements", "AuditLog", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/auditlog/auditlog.go#L209-L211
157,419
juju/juju
core/auditlog/auditlog.go
AddRequest
func (a *auditLogFile) AddRequest(m Request) error { return errors.Trace(a.addRecord(Record{Request: &m})) }
go
func (a *auditLogFile) AddRequest(m Request) error { return errors.Trace(a.addRecord(Record{Request: &m})) }
[ "func", "(", "a", "*", "auditLogFile", ")", "AddRequest", "(", "m", "Request", ")", "error", "{", "return", "errors", ".", "Trace", "(", "a", ".", "addRecord", "(", "Record", "{", "Request", ":", "&", "m", "}", ")", ")", "\n\n", "}" ]
// AddRequest implements AuditLog.
[ "AddRequest", "implements", "AuditLog", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/auditlog/auditlog.go#L214-L217
157,420
juju/juju
core/auditlog/auditlog.go
AddResponse
func (a *auditLogFile) AddResponse(m ResponseErrors) error { return errors.Trace(a.addRecord(Record{Errors: &m})) }
go
func (a *auditLogFile) AddResponse(m ResponseErrors) error { return errors.Trace(a.addRecord(Record{Errors: &m})) }
[ "func", "(", "a", "*", "auditLogFile", ")", "AddResponse", "(", "m", "ResponseErrors", ")", "error", "{", "return", "errors", ".", "Trace", "(", "a", ".", "addRecord", "(", "Record", "{", "Errors", ":", "&", "m", "}", ")", ")", "\n", "}" ]
// AddResponse implements AuditLog.
[ "AddResponse", "implements", "AuditLog", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/auditlog/auditlog.go#L220-L222
157,421
juju/juju
payload/api/private/client/unitfacade.go
Track
func (c UnitFacadeClient) Track(payloads ...payload.Payload) ([]payload.Result, error) { args := internal.Payloads2TrackArgs(payloads) var rs params.PayloadResults if err := c.FacadeCall("Track", &args, &rs); err != nil { return nil, errors.Trace(err) } return api2results(rs) }
go
func (c UnitFacadeClient) Track(payloads ...payload.Payload) ([]payload.Result, error) { args := internal.Payloads2TrackArgs(payloads) var rs params.PayloadResults if err := c.FacadeCall("Track", &args, &rs); err != nil { return nil, errors.Trace(err) } return api2results(rs) }
[ "func", "(", "c", "UnitFacadeClient", ")", "Track", "(", "payloads", "...", "payload", ".", "Payload", ")", "(", "[", "]", "payload", ".", "Result", ",", "error", ")", "{", "args", ":=", "internal", ".", "Payloads2TrackArgs", "(", "payloads", ")", "\n\n"...
// Track calls the Track API server method.
[ "Track", "calls", "the", "Track", "API", "server", "method", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/payload/api/private/client/unitfacade.go#L30-L39
157,422
juju/juju
payload/api/private/client/unitfacade.go
List
func (c UnitFacadeClient) List(fullIDs ...string) ([]payload.Result, error) { var ids []string if len(fullIDs) > 0 { actual, err := c.lookUp(fullIDs) if err != nil { return nil, errors.Trace(err) } ids = actual } args := internal.IDs2ListArgs(ids) var rs params.PayloadResults if err := c.FacadeCall("List", &args, &rs); err != nil { return nil, errors.Trace(err) } return api2results(rs) }
go
func (c UnitFacadeClient) List(fullIDs ...string) ([]payload.Result, error) { var ids []string if len(fullIDs) > 0 { actual, err := c.lookUp(fullIDs) if err != nil { return nil, errors.Trace(err) } ids = actual } args := internal.IDs2ListArgs(ids) var rs params.PayloadResults if err := c.FacadeCall("List", &args, &rs); err != nil { return nil, errors.Trace(err) } return api2results(rs) }
[ "func", "(", "c", "UnitFacadeClient", ")", "List", "(", "fullIDs", "...", "string", ")", "(", "[", "]", "payload", ".", "Result", ",", "error", ")", "{", "var", "ids", "[", "]", "string", "\n", "if", "len", "(", "fullIDs", ")", ">", "0", "{", "ac...
// List calls the List API server method.
[ "List", "calls", "the", "List", "API", "server", "method", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/payload/api/private/client/unitfacade.go#L42-L59
157,423
juju/juju
payload/api/private/client/unitfacade.go
LookUp
func (c UnitFacadeClient) LookUp(fullIDs ...string) ([]payload.Result, error) { if len(fullIDs) == 0 { // Unlike List(), LookUp doesn't fall back to looking up all IDs. return nil, nil } args := internal.FullIDs2LookUpArgs(fullIDs) var rs params.PayloadResults if err := c.FacadeCall("LookUp", &args, &rs); err != nil { return nil, err } return api2results(rs) }
go
func (c UnitFacadeClient) LookUp(fullIDs ...string) ([]payload.Result, error) { if len(fullIDs) == 0 { // Unlike List(), LookUp doesn't fall back to looking up all IDs. return nil, nil } args := internal.FullIDs2LookUpArgs(fullIDs) var rs params.PayloadResults if err := c.FacadeCall("LookUp", &args, &rs); err != nil { return nil, err } return api2results(rs) }
[ "func", "(", "c", "UnitFacadeClient", ")", "LookUp", "(", "fullIDs", "...", "string", ")", "(", "[", "]", "payload", ".", "Result", ",", "error", ")", "{", "if", "len", "(", "fullIDs", ")", "==", "0", "{", "// Unlike List(), LookUp doesn't fall back to looki...
// LookUp calls the LookUp API server method.
[ "LookUp", "calls", "the", "LookUp", "API", "server", "method", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/payload/api/private/client/unitfacade.go#L62-L75
157,424
juju/juju
payload/api/private/client/unitfacade.go
SetStatus
func (c UnitFacadeClient) SetStatus(status string, fullIDs ...string) ([]payload.Result, error) { ids, err := c.lookUp(fullIDs) if err != nil { return nil, errors.Trace(err) } args := internal.IDs2SetStatusArgs(ids, status) var rs params.PayloadResults if err := c.FacadeCall("SetStatus", &args, &rs); err != nil { return nil, err } return api2results(rs) }
go
func (c UnitFacadeClient) SetStatus(status string, fullIDs ...string) ([]payload.Result, error) { ids, err := c.lookUp(fullIDs) if err != nil { return nil, errors.Trace(err) } args := internal.IDs2SetStatusArgs(ids, status) var rs params.PayloadResults if err := c.FacadeCall("SetStatus", &args, &rs); err != nil { return nil, err } return api2results(rs) }
[ "func", "(", "c", "UnitFacadeClient", ")", "SetStatus", "(", "status", "string", ",", "fullIDs", "...", "string", ")", "(", "[", "]", "payload", ".", "Result", ",", "error", ")", "{", "ids", ",", "err", ":=", "c", ".", "lookUp", "(", "fullIDs", ")", ...
// SetStatus calls the SetStatus API server method.
[ "SetStatus", "calls", "the", "SetStatus", "API", "server", "method", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/payload/api/private/client/unitfacade.go#L78-L91
157,425
juju/juju
payload/api/private/client/unitfacade.go
Untrack
func (c UnitFacadeClient) Untrack(fullIDs ...string) ([]payload.Result, error) { logger.Tracef("Calling untrack API: %q", fullIDs) ids, err := c.lookUp(fullIDs) if err != nil { return nil, errors.Trace(err) } args := internal.IDs2UntrackArgs(ids) var rs params.PayloadResults if err := c.FacadeCall("Untrack", &args, &rs); err != nil { return nil, err } return api2results(rs) }
go
func (c UnitFacadeClient) Untrack(fullIDs ...string) ([]payload.Result, error) { logger.Tracef("Calling untrack API: %q", fullIDs) ids, err := c.lookUp(fullIDs) if err != nil { return nil, errors.Trace(err) } args := internal.IDs2UntrackArgs(ids) var rs params.PayloadResults if err := c.FacadeCall("Untrack", &args, &rs); err != nil { return nil, err } return api2results(rs) }
[ "func", "(", "c", "UnitFacadeClient", ")", "Untrack", "(", "fullIDs", "...", "string", ")", "(", "[", "]", "payload", ".", "Result", ",", "error", ")", "{", "logger", ".", "Tracef", "(", "\"", "\"", ",", "fullIDs", ")", "\n\n", "ids", ",", "err", "...
// Untrack calls the Untrack API server method.
[ "Untrack", "calls", "the", "Untrack", "API", "server", "method", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/payload/api/private/client/unitfacade.go#L94-L109
157,426
juju/juju
apiserver/common/mocks/leadership.go
NewMockLeadershipPinningBackend
func NewMockLeadershipPinningBackend(ctrl *gomock.Controller) *MockLeadershipPinningBackend { mock := &MockLeadershipPinningBackend{ctrl: ctrl} mock.recorder = &MockLeadershipPinningBackendMockRecorder{mock} return mock }
go
func NewMockLeadershipPinningBackend(ctrl *gomock.Controller) *MockLeadershipPinningBackend { mock := &MockLeadershipPinningBackend{ctrl: ctrl} mock.recorder = &MockLeadershipPinningBackendMockRecorder{mock} return mock }
[ "func", "NewMockLeadershipPinningBackend", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockLeadershipPinningBackend", "{", "mock", ":=", "&", "MockLeadershipPinningBackend", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "M...
// NewMockLeadershipPinningBackend creates a new mock instance
[ "NewMockLeadershipPinningBackend", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/mocks/leadership.go#L25-L29
157,427
juju/juju
apiserver/common/mocks/leadership.go
NewMockLeadershipMachine
func NewMockLeadershipMachine(ctrl *gomock.Controller) *MockLeadershipMachine { mock := &MockLeadershipMachine{ctrl: ctrl} mock.recorder = &MockLeadershipMachineMockRecorder{mock} return mock }
go
func NewMockLeadershipMachine(ctrl *gomock.Controller) *MockLeadershipMachine { mock := &MockLeadershipMachine{ctrl: ctrl} mock.recorder = &MockLeadershipMachineMockRecorder{mock} return mock }
[ "func", "NewMockLeadershipMachine", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockLeadershipMachine", "{", "mock", ":=", "&", "MockLeadershipMachine", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockLeadershipMachineM...
// NewMockLeadershipMachine creates a new mock instance
[ "NewMockLeadershipMachine", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/mocks/leadership.go#L61-L65
157,428
juju/juju
apiserver/common/mocks/leadership.go
ApplicationNames
func (m *MockLeadershipMachine) ApplicationNames() ([]string, error) { ret := m.ctrl.Call(m, "ApplicationNames") ret0, _ := ret[0].([]string) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockLeadershipMachine) ApplicationNames() ([]string, error) { ret := m.ctrl.Call(m, "ApplicationNames") ret0, _ := ret[0].([]string) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockLeadershipMachine", ")", "ApplicationNames", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", ...
// ApplicationNames mocks base method
[ "ApplicationNames", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/mocks/leadership.go#L73-L78
157,429
juju/juju
apiserver/common/mocks/leadership.go
ApplicationNames
func (mr *MockLeadershipMachineMockRecorder) ApplicationNames() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplicationNames", reflect.TypeOf((*MockLeadershipMachine)(nil).ApplicationNames)) }
go
func (mr *MockLeadershipMachineMockRecorder) ApplicationNames() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplicationNames", reflect.TypeOf((*MockLeadershipMachine)(nil).ApplicationNames)) }
[ "func", "(", "mr", "*", "MockLeadershipMachineMockRecorder", ")", "ApplicationNames", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "refle...
// ApplicationNames indicates an expected call of ApplicationNames
[ "ApplicationNames", "indicates", "an", "expected", "call", "of", "ApplicationNames" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/mocks/leadership.go#L81-L83
157,430
juju/juju
cmd/juju/caas/mocks/runner_mock.go
NewMockCommandRunner
func NewMockCommandRunner(ctrl *gomock.Controller) *MockCommandRunner { mock := &MockCommandRunner{ctrl: ctrl} mock.recorder = &MockCommandRunnerMockRecorder{mock} return mock }
go
func NewMockCommandRunner(ctrl *gomock.Controller) *MockCommandRunner { mock := &MockCommandRunner{ctrl: ctrl} mock.recorder = &MockCommandRunnerMockRecorder{mock} return mock }
[ "func", "NewMockCommandRunner", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockCommandRunner", "{", "mock", ":=", "&", "MockCommandRunner", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockCommandRunnerMockRecorder", ...
// NewMockCommandRunner creates a new mock instance
[ "NewMockCommandRunner", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/caas/mocks/runner_mock.go#L25-L29
157,431
juju/juju
cmd/juju/caas/mocks/runner_mock.go
RunCommands
func (m *MockCommandRunner) RunCommands(arg0 exec.RunParams) (*exec.ExecResponse, error) { ret := m.ctrl.Call(m, "RunCommands", arg0) ret0, _ := ret[0].(*exec.ExecResponse) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockCommandRunner) RunCommands(arg0 exec.RunParams) (*exec.ExecResponse, error) { ret := m.ctrl.Call(m, "RunCommands", arg0) ret0, _ := ret[0].(*exec.ExecResponse) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockCommandRunner", ")", "RunCommands", "(", "arg0", "exec", ".", "RunParams", ")", "(", "*", "exec", ".", "ExecResponse", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", ...
// RunCommands mocks base method
[ "RunCommands", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/caas/mocks/runner_mock.go#L37-L42
157,432
juju/juju
cmd/juju/caas/mocks/runner_mock.go
RunCommands
func (mr *MockCommandRunnerMockRecorder) RunCommands(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunCommands", reflect.TypeOf((*MockCommandRunner)(nil).RunCommands), arg0) }
go
func (mr *MockCommandRunnerMockRecorder) RunCommands(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunCommands", reflect.TypeOf((*MockCommandRunner)(nil).RunCommands), arg0) }
[ "func", "(", "mr", "*", "MockCommandRunnerMockRecorder", ")", "RunCommands", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", ...
// RunCommands indicates an expected call of RunCommands
[ "RunCommands", "indicates", "an", "expected", "call", "of", "RunCommands" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/caas/mocks/runner_mock.go#L45-L47
157,433
juju/juju
payload/api/helpers.go
Payload2api
func Payload2api(p payload.FullPayloadInfo) params.Payload { labels := make([]string, len(p.Labels)) copy(labels, p.Labels) var unitTag string if p.Unit != "" { unitTag = names.NewUnitTag(p.Unit).String() } var machineTag string if p.Machine != "" { machineTag = names.NewMachineTag(p.Machine).String() } return params.Payload{ Class: p.Name, Type: p.Type, ID: p.ID, Status: p.Status, Labels: labels, Unit: unitTag, Machine: machineTag, } }
go
func Payload2api(p payload.FullPayloadInfo) params.Payload { labels := make([]string, len(p.Labels)) copy(labels, p.Labels) var unitTag string if p.Unit != "" { unitTag = names.NewUnitTag(p.Unit).String() } var machineTag string if p.Machine != "" { machineTag = names.NewMachineTag(p.Machine).String() } return params.Payload{ Class: p.Name, Type: p.Type, ID: p.ID, Status: p.Status, Labels: labels, Unit: unitTag, Machine: machineTag, } }
[ "func", "Payload2api", "(", "p", "payload", ".", "FullPayloadInfo", ")", "params", ".", "Payload", "{", "labels", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "p", ".", "Labels", ")", ")", "\n", "copy", "(", "labels", ",", "p", ".", "Lab...
// Payload2api converts a payload.FullPayloadInfo struct into // a Payload struct.
[ "Payload2api", "converts", "a", "payload", ".", "FullPayloadInfo", "struct", "into", "a", "Payload", "struct", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/payload/api/helpers.go#L30-L52
157,434
juju/juju
payload/api/helpers.go
API2Payload
func API2Payload(apiInfo params.Payload) (payload.FullPayloadInfo, error) { labels := make([]string, len(apiInfo.Labels)) copy(labels, apiInfo.Labels) var unit, machine string var empty payload.FullPayloadInfo if apiInfo.Unit != "" { tag, err := names.ParseUnitTag(apiInfo.Unit) if err != nil { return empty, errors.Trace(err) } unit = tag.Id() } if apiInfo.Machine != "" { tag, err := names.ParseMachineTag(apiInfo.Machine) if err != nil { return empty, errors.Trace(err) } machine = tag.Id() } return payload.FullPayloadInfo{ Payload: payload.Payload{ PayloadClass: charm.PayloadClass{ Name: apiInfo.Class, Type: apiInfo.Type, }, ID: apiInfo.ID, Status: apiInfo.Status, Labels: labels, Unit: unit, }, Machine: machine, }, nil }
go
func API2Payload(apiInfo params.Payload) (payload.FullPayloadInfo, error) { labels := make([]string, len(apiInfo.Labels)) copy(labels, apiInfo.Labels) var unit, machine string var empty payload.FullPayloadInfo if apiInfo.Unit != "" { tag, err := names.ParseUnitTag(apiInfo.Unit) if err != nil { return empty, errors.Trace(err) } unit = tag.Id() } if apiInfo.Machine != "" { tag, err := names.ParseMachineTag(apiInfo.Machine) if err != nil { return empty, errors.Trace(err) } machine = tag.Id() } return payload.FullPayloadInfo{ Payload: payload.Payload{ PayloadClass: charm.PayloadClass{ Name: apiInfo.Class, Type: apiInfo.Type, }, ID: apiInfo.ID, Status: apiInfo.Status, Labels: labels, Unit: unit, }, Machine: machine, }, nil }
[ "func", "API2Payload", "(", "apiInfo", "params", ".", "Payload", ")", "(", "payload", ".", "FullPayloadInfo", ",", "error", ")", "{", "labels", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "apiInfo", ".", "Labels", ")", ")", "\n", "copy", ...
// API2Payload converts an API Payload info struct into // a payload.FullPayloadInfo struct.
[ "API2Payload", "converts", "an", "API", "Payload", "info", "struct", "into", "a", "payload", ".", "FullPayloadInfo", "struct", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/payload/api/helpers.go#L56-L90
157,435
juju/juju
service/systemd/service.go
ListServices
func ListServices() ([]string, error) { // TODO(ericsnow) conn.ListUnits misses some inactive units, so we // would need conn.ListUnitFiles. Such a method has been requested. // (see https://github.com/coreos/go-systemd/issues/76). In the // meantime we use systemctl at the shell to list the services. // Once that is addressed upstream we can just call listServices here. names, err := Cmdline{}.ListAll() if err != nil { return nil, errors.Trace(err) } return names, nil }
go
func ListServices() ([]string, error) { // TODO(ericsnow) conn.ListUnits misses some inactive units, so we // would need conn.ListUnitFiles. Such a method has been requested. // (see https://github.com/coreos/go-systemd/issues/76). In the // meantime we use systemctl at the shell to list the services. // Once that is addressed upstream we can just call listServices here. names, err := Cmdline{}.ListAll() if err != nil { return nil, errors.Trace(err) } return names, nil }
[ "func", "ListServices", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "// TODO(ericsnow) conn.ListUnits misses some inactive units, so we", "// would need conn.ListUnitFiles. Such a method has been requested.", "// (see https://github.com/coreos/go-systemd/issues/76). In the...
// ListServices returns the list of installed service names.
[ "ListServices", "returns", "the", "list", "of", "installed", "service", "names", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L42-L53
157,436
juju/juju
service/systemd/service.go
NewServiceWithDefaults
func NewServiceWithDefaults(name string, conf common.Conf) (*Service, error) { svc, err := NewService(name, conf, LibSystemdDir, NewDBusAPI, renderer.Join(paths.NixDataDir, "init")) return svc, errors.Trace(err) }
go
func NewServiceWithDefaults(name string, conf common.Conf) (*Service, error) { svc, err := NewService(name, conf, LibSystemdDir, NewDBusAPI, renderer.Join(paths.NixDataDir, "init")) return svc, errors.Trace(err) }
[ "func", "NewServiceWithDefaults", "(", "name", "string", ",", "conf", "common", ".", "Conf", ")", "(", "*", "Service", ",", "error", ")", "{", "svc", ",", "err", ":=", "NewService", "(", "name", ",", "conf", ",", "LibSystemdDir", ",", "NewDBusAPI", ",", ...
// NewServiceWithDefaults returns a new systemd service reference populated // with sensible defaults.
[ "NewServiceWithDefaults", "returns", "a", "new", "systemd", "service", "reference", "populated", "with", "sensible", "defaults", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L78-L81
157,437
juju/juju
service/systemd/service.go
NewService
func NewService( name string, conf common.Conf, dataDir string, newDBus DBusAPIFactory, fallBackDirName string, ) (*Service, error) { confName := name + ".service" var volName string if conf.ExecStart != "" { volName = renderer.VolumeName(common.Unquote(strings.Fields(conf.ExecStart)[0])) } dirName := volName + renderer.Join(dataDir, name) service := &Service{ Service: common.Service{ Name: name, // Conf is set in setConf. }, ConfName: confName, UnitName: confName, DirName: dirName, FallBackDirName: fallBackDirName, newDBus: newDBus, } if err := service.setConf(conf); err != nil { return nil, errors.Trace(err) } return service, nil }
go
func NewService( name string, conf common.Conf, dataDir string, newDBus DBusAPIFactory, fallBackDirName string, ) (*Service, error) { confName := name + ".service" var volName string if conf.ExecStart != "" { volName = renderer.VolumeName(common.Unquote(strings.Fields(conf.ExecStart)[0])) } dirName := volName + renderer.Join(dataDir, name) service := &Service{ Service: common.Service{ Name: name, // Conf is set in setConf. }, ConfName: confName, UnitName: confName, DirName: dirName, FallBackDirName: fallBackDirName, newDBus: newDBus, } if err := service.setConf(conf); err != nil { return nil, errors.Trace(err) } return service, nil }
[ "func", "NewService", "(", "name", "string", ",", "conf", "common", ".", "Conf", ",", "dataDir", "string", ",", "newDBus", "DBusAPIFactory", ",", "fallBackDirName", "string", ",", ")", "(", "*", "Service", ",", "error", ")", "{", "confName", ":=", "name", ...
// NewService returns a new reference to an object that implements the Service // interface for systemd.
[ "NewService", "returns", "a", "new", "reference", "to", "an", "object", "that", "implements", "the", "Service", "interface", "for", "systemd", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L85-L112
157,438
juju/juju
service/systemd/service.go
Installed
func (s *Service) Installed() (bool, error) { names, err := ListServices() if err != nil { return false, s.errorf(err, "failed to list services") } for _, name := range names { if name == s.Service.Name { return true, nil } } return false, nil }
go
func (s *Service) Installed() (bool, error) { names, err := ListServices() if err != nil { return false, s.errorf(err, "failed to list services") } for _, name := range names { if name == s.Service.Name { return true, nil } } return false, nil }
[ "func", "(", "s", "*", "Service", ")", "Installed", "(", ")", "(", "bool", ",", "error", ")", "{", "names", ",", "err", ":=", "ListServices", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "s", ".", "errorf", "(", "err", ...
// Installed implements Service.
[ "Installed", "implements", "Service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L208-L219
157,439
juju/juju
service/systemd/service.go
Exists
func (s *Service) Exists() (bool, error) { if s.NoConf() { return false, s.errorf(nil, "no conf expected") } same, err := s.check() if err != nil { return false, errors.Trace(err) } return same, nil }
go
func (s *Service) Exists() (bool, error) { if s.NoConf() { return false, s.errorf(nil, "no conf expected") } same, err := s.check() if err != nil { return false, errors.Trace(err) } return same, nil }
[ "func", "(", "s", "*", "Service", ")", "Exists", "(", ")", "(", "bool", ",", "error", ")", "{", "if", "s", ".", "NoConf", "(", ")", "{", "return", "false", ",", "s", ".", "errorf", "(", "nil", ",", "\"", "\"", ")", "\n", "}", "\n\n", "same", ...
// Exists implements Service.
[ "Exists", "implements", "Service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L222-L232
157,440
juju/juju
service/systemd/service.go
Running
func (s *Service) Running() (bool, error) { conn, err := s.newConn() if err != nil { return false, errors.Trace(err) } defer conn.Close() units, err := conn.ListUnits() if err != nil { return false, s.errorf(err, "failed to query services from dbus") } for _, unit := range units { if unit.Name == s.UnitName { running := unit.LoadState == "loaded" && unit.ActiveState == "active" return running, nil } } return false, nil }
go
func (s *Service) Running() (bool, error) { conn, err := s.newConn() if err != nil { return false, errors.Trace(err) } defer conn.Close() units, err := conn.ListUnits() if err != nil { return false, s.errorf(err, "failed to query services from dbus") } for _, unit := range units { if unit.Name == s.UnitName { running := unit.LoadState == "loaded" && unit.ActiveState == "active" return running, nil } } return false, nil }
[ "func", "(", "s", "*", "Service", ")", "Running", "(", ")", "(", "bool", ",", "error", ")", "{", "conn", ",", "err", ":=", "s", ".", "newConn", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "errors", ".", "Trace", "(", ...
// Running implements Service.
[ "Running", "implements", "Service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L276-L295
157,441
juju/juju
service/systemd/service.go
Start
func (s *Service) Start() error { err := s.start() if errors.IsAlreadyExists(err) { logger.Debugf("service %q already running", s.Name()) return nil } else if err != nil { logger.Errorf("service %q failed to start: %v", s.Name(), err) return err } logger.Debugf("service %q successfully started", s.Name()) return nil }
go
func (s *Service) Start() error { err := s.start() if errors.IsAlreadyExists(err) { logger.Debugf("service %q already running", s.Name()) return nil } else if err != nil { logger.Errorf("service %q failed to start: %v", s.Name(), err) return err } logger.Debugf("service %q successfully started", s.Name()) return nil }
[ "func", "(", "s", "*", "Service", ")", "Start", "(", ")", "error", "{", "err", ":=", "s", ".", "start", "(", ")", "\n", "if", "errors", ".", "IsAlreadyExists", "(", "err", ")", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "s", ".", "Name...
// Start implements Service.
[ "Start", "implements", "Service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L298-L309
157,442
juju/juju
service/systemd/service.go
Stop
func (s *Service) Stop() error { err := s.stop() if errors.IsNotFound(err) { logger.Debugf("service %q not running", s.Name()) return nil } else if err != nil { logger.Errorf("service %q failed to stop: %v", s.Name(), err) return err } logger.Debugf("service %q successfully stopped", s.Name()) return nil }
go
func (s *Service) Stop() error { err := s.stop() if errors.IsNotFound(err) { logger.Debugf("service %q not running", s.Name()) return nil } else if err != nil { logger.Errorf("service %q failed to stop: %v", s.Name(), err) return err } logger.Debugf("service %q successfully stopped", s.Name()) return nil }
[ "func", "(", "s", "*", "Service", ")", "Stop", "(", ")", "error", "{", "err", ":=", "s", ".", "stop", "(", ")", "\n", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "s", ".", "Name", "(...
// Stop implements Service.
[ "Stop", "implements", "Service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L358-L369
157,443
juju/juju
service/systemd/service.go
Remove
func (s *Service) Remove() error { err := s.remove() if errors.IsNotFound(err) { logger.Debugf("service %q not installed", s.Name()) return nil } else if err != nil { logger.Errorf("failed to remove service %q: %v", s.Name(), err) return err } logger.Debugf("service %q successfully removed", s.Name()) return nil }
go
func (s *Service) Remove() error { err := s.remove() if errors.IsNotFound(err) { logger.Debugf("service %q not installed", s.Name()) return nil } else if err != nil { logger.Errorf("failed to remove service %q: %v", s.Name(), err) return err } logger.Debugf("service %q successfully removed", s.Name()) return nil }
[ "func", "(", "s", "*", "Service", ")", "Remove", "(", ")", "error", "{", "err", ":=", "s", ".", "remove", "(", ")", "\n", "if", "errors", ".", "IsNotFound", "(", "err", ")", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "s", ".", "Name", ...
// Remove implements Service.
[ "Remove", "implements", "Service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L400-L411
157,444
juju/juju
service/systemd/service.go
Install
func (s *Service) Install() error { if s.NoConf() { return s.errorf(nil, "missing conf") } err := s.install() if errors.IsAlreadyExists(err) { logger.Debugf("service %q already installed", s.Name()) return nil } else if err != nil { logger.Errorf("failed to install service %q: %v", s.Name(), err) return err } logger.Debugf("service %q successfully installed", s.Name()) return nil }
go
func (s *Service) Install() error { if s.NoConf() { return s.errorf(nil, "missing conf") } err := s.install() if errors.IsAlreadyExists(err) { logger.Debugf("service %q already installed", s.Name()) return nil } else if err != nil { logger.Errorf("failed to install service %q: %v", s.Name(), err) return err } logger.Debugf("service %q successfully installed", s.Name()) return nil }
[ "func", "(", "s", "*", "Service", ")", "Install", "(", ")", "error", "{", "if", "s", ".", "NoConf", "(", ")", "{", "return", "s", ".", "errorf", "(", "nil", ",", "\"", "\"", ")", "\n", "}", "\n\n", "err", ":=", "s", ".", "install", "(", ")", ...
// Install implements Service.
[ "Install", "implements", "Service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L450-L465
157,445
juju/juju
service/systemd/service.go
InstallCommands
func (s *Service) InstallCommands() ([]string, error) { if s.NoConf() { return nil, s.errorf(nil, "missing conf") } name := s.Name() dirname := s.DirName data, err := s.serialize() if err != nil { return nil, errors.Trace(err) } cmdList := []string{ cmds.mkdirs(dirname), } if s.Script != nil { scriptName := renderer.Base(renderer.ScriptFilename("exec-start", "")) cmdList = append(cmdList, []string{ // TODO(ericsnow) Use the renderer here. cmds.writeFile(scriptName, dirname, s.Script), cmds.chmod(scriptName, dirname, 0755), }...) } cmdList = append(cmdList, []string{ cmds.writeConf(name, dirname, data), cmds.link(name, dirname), cmds.reload(), cmds.enableLinked(name, dirname), }...) return cmdList, nil }
go
func (s *Service) InstallCommands() ([]string, error) { if s.NoConf() { return nil, s.errorf(nil, "missing conf") } name := s.Name() dirname := s.DirName data, err := s.serialize() if err != nil { return nil, errors.Trace(err) } cmdList := []string{ cmds.mkdirs(dirname), } if s.Script != nil { scriptName := renderer.Base(renderer.ScriptFilename("exec-start", "")) cmdList = append(cmdList, []string{ // TODO(ericsnow) Use the renderer here. cmds.writeFile(scriptName, dirname, s.Script), cmds.chmod(scriptName, dirname, 0755), }...) } cmdList = append(cmdList, []string{ cmds.writeConf(name, dirname, data), cmds.link(name, dirname), cmds.reload(), cmds.enableLinked(name, dirname), }...) return cmdList, nil }
[ "func", "(", "s", "*", "Service", ")", "InstallCommands", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "s", ".", "NoConf", "(", ")", "{", "return", "nil", ",", "s", ".", "errorf", "(", "nil", ",", "\"", "\"", ")", "\n", "}...
// InstallCommands implements Service.
[ "InstallCommands", "implements", "Service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L531-L562
157,446
juju/juju
service/systemd/service.go
StartCommands
func (s *Service) StartCommands() ([]string, error) { name := s.Name() cmdList := []string{ cmds.start(name), } return cmdList, nil }
go
func (s *Service) StartCommands() ([]string, error) { name := s.Name() cmdList := []string{ cmds.start(name), } return cmdList, nil }
[ "func", "(", "s", "*", "Service", ")", "StartCommands", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "name", ":=", "s", ".", "Name", "(", ")", "\n", "cmdList", ":=", "[", "]", "string", "{", "cmds", ".", "start", "(", "name", ")",...
// StartCommands implements Service.
[ "StartCommands", "implements", "Service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L565-L571
157,447
juju/juju
service/systemd/service.go
WriteService
func (s *Service) WriteService() error { filename, err := s.writeConf() if err != nil { return errors.Trace(err) } // If systemd is not the running init system, // then do not attempt to use it for linking unit files. if !IsRunning() { return nil } conn, err := s.newConn() if err != nil { return errors.Trace(err) } defer conn.Close() runtime, force := false, true if _, err = conn.LinkUnitFiles([]string{filename}, runtime, force); err != nil { return s.errorf(err, "dbus link request failed") } err = conn.Reload() if err != nil { return s.errorf(err, "dbus post-link daemon reload request failed") } if _, _, err = conn.EnableUnitFiles([]string{filename}, runtime, force); err != nil { return s.errorf(err, "dbus enable request failed") } return nil }
go
func (s *Service) WriteService() error { filename, err := s.writeConf() if err != nil { return errors.Trace(err) } // If systemd is not the running init system, // then do not attempt to use it for linking unit files. if !IsRunning() { return nil } conn, err := s.newConn() if err != nil { return errors.Trace(err) } defer conn.Close() runtime, force := false, true if _, err = conn.LinkUnitFiles([]string{filename}, runtime, force); err != nil { return s.errorf(err, "dbus link request failed") } err = conn.Reload() if err != nil { return s.errorf(err, "dbus post-link daemon reload request failed") } if _, _, err = conn.EnableUnitFiles([]string{filename}, runtime, force); err != nil { return s.errorf(err, "dbus enable request failed") } return nil }
[ "func", "(", "s", "*", "Service", ")", "WriteService", "(", ")", "error", "{", "filename", ",", "err", ":=", "s", ".", "writeConf", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n...
// WriteService implements UpgradableService.WriteService
[ "WriteService", "implements", "UpgradableService", ".", "WriteService" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L574-L607
157,448
juju/juju
service/systemd/service.go
SysdReload
func SysdReload() error { err := Cmdline{}.reload() if err != nil { logger.Errorf("services not reloaded %v\n", err) return err } return nil }
go
func SysdReload() error { err := Cmdline{}.reload() if err != nil { logger.Errorf("services not reloaded %v\n", err) return err } return nil }
[ "func", "SysdReload", "(", ")", "error", "{", "err", ":=", "Cmdline", "{", "}", ".", "reload", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Errorf", "(", "\"", "\\n", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\...
// SysdReload reloads Service daemon.
[ "SysdReload", "reloads", "Service", "daemon", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/systemd/service.go#L610-L617
157,449
juju/juju
environs/tools/versionfile.go
ParseVersions
func ParseVersions(r io.Reader) (*Versions, error) { data, err := ioutil.ReadAll(r) if err != nil { return nil, err } var results Versions err = yaml.Unmarshal(data, &results) if err != nil { return nil, errors.Trace(err) } return &results, nil }
go
func ParseVersions(r io.Reader) (*Versions, error) { data, err := ioutil.ReadAll(r) if err != nil { return nil, err } var results Versions err = yaml.Unmarshal(data, &results) if err != nil { return nil, errors.Trace(err) } return &results, nil }
[ "func", "ParseVersions", "(", "r", "io", ".", "Reader", ")", "(", "*", "Versions", ",", "error", ")", "{", "data", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", ...
// ParseVersions constructs a versions object from a reader..
[ "ParseVersions", "constructs", "a", "versions", "object", "from", "a", "reader", ".." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/tools/versionfile.go#L28-L39
157,450
juju/juju
environs/tools/versionfile.go
VersionsMatching
func (v *Versions) VersionsMatching(r io.Reader) ([]string, error) { hash := sha256.New() _, err := io.Copy(hash, r) if err != nil { return nil, errors.Trace(err) } return v.versionsMatchingHash(hex.EncodeToString(hash.Sum(nil))), nil }
go
func (v *Versions) VersionsMatching(r io.Reader) ([]string, error) { hash := sha256.New() _, err := io.Copy(hash, r) if err != nil { return nil, errors.Trace(err) } return v.versionsMatchingHash(hex.EncodeToString(hash.Sum(nil))), nil }
[ "func", "(", "v", "*", "Versions", ")", "VersionsMatching", "(", "r", "io", ".", "Reader", ")", "(", "[", "]", "string", ",", "error", ")", "{", "hash", ":=", "sha256", ".", "New", "(", ")", "\n", "_", ",", "err", ":=", "io", ".", "Copy", "(", ...
// VersionsMatching returns all version numbers for which the SHA256 // matches the content of the reader passed in.
[ "VersionsMatching", "returns", "all", "version", "numbers", "for", "which", "the", "SHA256", "matches", "the", "content", "of", "the", "reader", "passed", "in", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/tools/versionfile.go#L43-L50
157,451
juju/juju
environs/tools/versionfile.go
versionsMatchingHash
func (v *Versions) versionsMatchingHash(h string) []string { logger.Debugf("looking for sha256 %s", h) var results []string for i := range v.Versions { if v.Versions[i].SHA256 == h { results = append(results, v.Versions[i].Version) } } return results }
go
func (v *Versions) versionsMatchingHash(h string) []string { logger.Debugf("looking for sha256 %s", h) var results []string for i := range v.Versions { if v.Versions[i].SHA256 == h { results = append(results, v.Versions[i].Version) } } return results }
[ "func", "(", "v", "*", "Versions", ")", "versionsMatchingHash", "(", "h", "string", ")", "[", "]", "string", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "h", ")", "\n", "var", "results", "[", "]", "string", "\n", "for", "i", ":=", "range", ...
// versionsMatchingHash returns all version numbers for which the SHA256 // matches the hash passed in.
[ "versionsMatchingHash", "returns", "all", "version", "numbers", "for", "which", "the", "SHA256", "matches", "the", "hash", "passed", "in", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/tools/versionfile.go#L54-L63
157,452
juju/juju
cmd/juju/romulus/resolve.go
Resolve
func (r *CharmStoreResolver) Resolve(client *httpbakery.Client, charmURL string) (string, error) { repo := charmrepo.NewCharmStore(charmrepo.NewCharmStoreParams{ BakeryClient: client, URL: r.csURL, }) curl, err := charm.ParseURL(charmURL) if err != nil { return "", errors.Annotate(err, "could not parse charm url") } // ignore local charm urls if curl.Schema == "local" { return charmURL, nil } resolvedURL, _, err := repo.Resolve(curl) if err != nil { return "", errors.Trace(err) } return resolvedURL.String(), nil }
go
func (r *CharmStoreResolver) Resolve(client *httpbakery.Client, charmURL string) (string, error) { repo := charmrepo.NewCharmStore(charmrepo.NewCharmStoreParams{ BakeryClient: client, URL: r.csURL, }) curl, err := charm.ParseURL(charmURL) if err != nil { return "", errors.Annotate(err, "could not parse charm url") } // ignore local charm urls if curl.Schema == "local" { return charmURL, nil } resolvedURL, _, err := repo.Resolve(curl) if err != nil { return "", errors.Trace(err) } return resolvedURL.String(), nil }
[ "func", "(", "r", "*", "CharmStoreResolver", ")", "Resolve", "(", "client", "*", "httpbakery", ".", "Client", ",", "charmURL", "string", ")", "(", "string", ",", "error", ")", "{", "repo", ":=", "charmrepo", ".", "NewCharmStore", "(", "charmrepo", ".", "...
// Resolve implements the CharmResolver interface.
[ "Resolve", "implements", "the", "CharmResolver", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/romulus/resolve.go#L46-L65
157,453
juju/juju
worker/fanconfigurer/manifold.go
Manifold
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{ config.APICallerName, }, Output: func(in worker.Worker, out interface{}) error { inWorker, _ := in.(*FanConfigurer) if inWorker == nil { return errors.Errorf("in should be a %T; got %T", inWorker, in) } switch outPointer := out.(type) { case *bool: *outPointer = true default: return errors.Errorf("out should be *bool; got %T", out) } return nil }, Start: func(context dependency.Context) (worker.Worker, error) { var apiCaller base.APICaller if err := context.Get(config.APICallerName, &apiCaller); err != nil { return nil, errors.Trace(err) } facade := apifanconfigurer.NewFacade(apiCaller) fanconfigurer, err := NewFanConfigurer(FanConfigurerConfig{ Facade: facade, }, config.Clock) return fanconfigurer, errors.Annotate(err, "creating fanconfigurer orchestrator") }, } }
go
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{ config.APICallerName, }, Output: func(in worker.Worker, out interface{}) error { inWorker, _ := in.(*FanConfigurer) if inWorker == nil { return errors.Errorf("in should be a %T; got %T", inWorker, in) } switch outPointer := out.(type) { case *bool: *outPointer = true default: return errors.Errorf("out should be *bool; got %T", out) } return nil }, Start: func(context dependency.Context) (worker.Worker, error) { var apiCaller base.APICaller if err := context.Get(config.APICallerName, &apiCaller); err != nil { return nil, errors.Trace(err) } facade := apifanconfigurer.NewFacade(apiCaller) fanconfigurer, err := NewFanConfigurer(FanConfigurerConfig{ Facade: facade, }, config.Clock) return fanconfigurer, errors.Annotate(err, "creating fanconfigurer orchestrator") }, } }
[ "func", "Manifold", "(", "config", "ManifoldConfig", ")", "dependency", ".", "Manifold", "{", "return", "dependency", ".", "Manifold", "{", "Inputs", ":", "[", "]", "string", "{", "config", ".", "APICallerName", ",", "}", ",", "Output", ":", "func", "(", ...
// Manifold returns a dependency manifold that runs a fan configurer // worker, using the resource names defined in the supplied config.
[ "Manifold", "returns", "a", "dependency", "manifold", "that", "runs", "a", "fan", "configurer", "worker", "using", "the", "resource", "names", "defined", "in", "the", "supplied", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/fanconfigurer/manifold.go#L26-L58
157,454
juju/juju
core/status/status_history.go
Validate
func (f *StatusHistoryFilter) Validate() error { s := f.Size > 0 t := f.FromDate != nil d := f.Delta != nil switch { case !(s || t || d): return errors.NotValidf("missing filter parameters") case s && t: return errors.NotValidf("Size and Date together") case s && d: return errors.NotValidf("Size and Delta together") case t && d: return errors.NotValidf("Date and Delta together") } return nil }
go
func (f *StatusHistoryFilter) Validate() error { s := f.Size > 0 t := f.FromDate != nil d := f.Delta != nil switch { case !(s || t || d): return errors.NotValidf("missing filter parameters") case s && t: return errors.NotValidf("Size and Date together") case s && d: return errors.NotValidf("Size and Delta together") case t && d: return errors.NotValidf("Date and Delta together") } return nil }
[ "func", "(", "f", "*", "StatusHistoryFilter", ")", "Validate", "(", ")", "error", "{", "s", ":=", "f", ".", "Size", ">", "0", "\n", "t", ":=", "f", ".", "FromDate", "!=", "nil", "\n", "d", ":=", "f", ".", "Delta", "!=", "nil", "\n\n", "switch", ...
// Validate checks that the minimum requirements of a StatusHistoryFilter are met.
[ "Validate", "checks", "that", "the", "minimum", "requirements", "of", "a", "StatusHistoryFilter", "are", "met", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/status/status_history.go#L27-L43
157,455
juju/juju
core/status/status_history.go
Valid
func (k HistoryKind) Valid() bool { switch k { case KindUnit, KindUnitAgent, KindWorkload, KindMachineInstance, KindMachine, KindContainerInstance, KindContainer: return true } return false }
go
func (k HistoryKind) Valid() bool { switch k { case KindUnit, KindUnitAgent, KindWorkload, KindMachineInstance, KindMachine, KindContainerInstance, KindContainer: return true } return false }
[ "func", "(", "k", "HistoryKind", ")", "Valid", "(", ")", "bool", "{", "switch", "k", "{", "case", "KindUnit", ",", "KindUnitAgent", ",", "KindWorkload", ",", "KindMachineInstance", ",", "KindMachine", ",", "KindContainerInstance", ",", "KindContainer", ":", "r...
// Valid will return true if the current kind is a valid one.
[ "Valid", "will", "return", "true", "if", "the", "current", "kind", "is", "a", "valid", "one", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/status/status_history.go#L104-L112
157,456
juju/juju
core/status/status_history.go
AllHistoryKind
func AllHistoryKind() map[HistoryKind]string { return map[HistoryKind]string{ KindUnit: "statuses for specified unit and its workload", KindUnitAgent: "statuses from the agent that is managing a unit", KindWorkload: "statuses for unit's workload", KindMachineInstance: "statuses that occur due to provisioning of a machine", KindMachine: "status of the agent that is managing a machine", KindContainerInstance: "statuses from the agent that is managing containers", KindContainer: "statuses from the containers only and not their host machines", } }
go
func AllHistoryKind() map[HistoryKind]string { return map[HistoryKind]string{ KindUnit: "statuses for specified unit and its workload", KindUnitAgent: "statuses from the agent that is managing a unit", KindWorkload: "statuses for unit's workload", KindMachineInstance: "statuses that occur due to provisioning of a machine", KindMachine: "status of the agent that is managing a machine", KindContainerInstance: "statuses from the agent that is managing containers", KindContainer: "statuses from the containers only and not their host machines", } }
[ "func", "AllHistoryKind", "(", ")", "map", "[", "HistoryKind", "]", "string", "{", "return", "map", "[", "HistoryKind", "]", "string", "{", "KindUnit", ":", "\"", "\"", ",", "KindUnitAgent", ":", "\"", "\"", ",", "KindWorkload", ":", "\"", "\"", ",", "...
// AllHistoryKind will return all valid HistoryKinds.
[ "AllHistoryKind", "will", "return", "all", "valid", "HistoryKinds", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/status/status_history.go#L115-L125
157,457
juju/juju
cmd/jujud/agent/model/errors.go
IgnoreErrRemoved
func IgnoreErrRemoved(err error) error { cause := errors.Cause(err) if cause == ErrRemoved { return nil } return err }
go
func IgnoreErrRemoved(err error) error { cause := errors.Cause(err) if cause == ErrRemoved { return nil } return err }
[ "func", "IgnoreErrRemoved", "(", "err", "error", ")", "error", "{", "cause", ":=", "errors", ".", "Cause", "(", "err", ")", "\n", "if", "cause", "==", "ErrRemoved", "{", "return", "nil", "\n", "}", "\n", "return", "err", "\n", "}" ]
// IgnoreErrRemoved returns nil if passed an error caused by ErrRemoved, // and otherwise returns the original error.
[ "IgnoreErrRemoved", "returns", "nil", "if", "passed", "an", "error", "caused", "by", "ErrRemoved", "and", "otherwise", "returns", "the", "original", "error", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/jujud/agent/model/errors.go#L46-L52
157,458
juju/juju
cmd/juju/commands/debuglog.go
Run
func (c *debugLogCommand) Run(ctx *cmd.Context) (err error) { if c.tail { c.params.NoTail = false } else if c.notail { c.params.NoTail = true } else { // Set the default tail option to true if the caller is // using a terminal. c.params.NoTail = !isTerminal(ctx.Stdout) } client, err := getDebugLogAPI(c) if err != nil { return err } defer client.Close() messages, err := client.WatchDebugLog(c.params) if err != nil { return err } writer := ansiterm.NewWriter(ctx.Stdout) if c.color { writer.SetColorCapable(true) } for { msg, ok := <-messages if !ok { break } c.writeLogRecord(writer, msg) } return nil }
go
func (c *debugLogCommand) Run(ctx *cmd.Context) (err error) { if c.tail { c.params.NoTail = false } else if c.notail { c.params.NoTail = true } else { // Set the default tail option to true if the caller is // using a terminal. c.params.NoTail = !isTerminal(ctx.Stdout) } client, err := getDebugLogAPI(c) if err != nil { return err } defer client.Close() messages, err := client.WatchDebugLog(c.params) if err != nil { return err } writer := ansiterm.NewWriter(ctx.Stdout) if c.color { writer.SetColorCapable(true) } for { msg, ok := <-messages if !ok { break } c.writeLogRecord(writer, msg) } return nil }
[ "func", "(", "c", "*", "debugLogCommand", ")", "Run", "(", "ctx", "*", "cmd", ".", "Context", ")", "(", "err", "error", ")", "{", "if", "c", ".", "tail", "{", "c", ".", "params", ".", "NoTail", "=", "false", "\n", "}", "else", "if", "c", ".", ...
// Run retrieves the debug log via the API.
[ "Run", "retrieves", "the", "debug", "log", "via", "the", "API", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/commands/debuglog.go#L259-L292
157,459
juju/juju
cmd/juju/resource/formatter.go
FormatCharmResource
func FormatCharmResource(res charmresource.Resource) FormattedCharmResource { return FormattedCharmResource{ Name: res.Name, Type: res.Type.String(), Path: res.Path, Description: res.Description, Revision: res.Revision, Origin: res.Origin.String(), Fingerprint: res.Fingerprint.String(), // ...the hex string. Size: res.Size, } }
go
func FormatCharmResource(res charmresource.Resource) FormattedCharmResource { return FormattedCharmResource{ Name: res.Name, Type: res.Type.String(), Path: res.Path, Description: res.Description, Revision: res.Revision, Origin: res.Origin.String(), Fingerprint: res.Fingerprint.String(), // ...the hex string. Size: res.Size, } }
[ "func", "FormatCharmResource", "(", "res", "charmresource", ".", "Resource", ")", "FormattedCharmResource", "{", "return", "FormattedCharmResource", "{", "Name", ":", "res", ".", "Name", ",", "Type", ":", "res", ".", "Type", ".", "String", "(", ")", ",", "Pa...
// FormatCharmResource converts the resource info into a FormattedCharmResource.
[ "FormatCharmResource", "converts", "the", "resource", "info", "into", "a", "FormattedCharmResource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/resource/formatter.go#L49-L60
157,460
juju/juju
cmd/juju/resource/formatter.go
FormatAppResource
func FormatAppResource(res resource.Resource) FormattedAppResource { used := !res.IsPlaceholder() result := FormattedAppResource{ ID: res.ID, ApplicationID: res.ApplicationID, Name: res.Name, Type: res.Type.String(), Path: res.Path, Description: res.Description, Origin: res.Origin.String(), Fingerprint: res.Fingerprint.String(), Size: res.Size, Used: used, Timestamp: res.Timestamp, Username: res.Username, CombinedRevision: combinedRevision(res), CombinedOrigin: combinedOrigin(used, res), UsedYesNo: usedYesNo(used), } // Have to check since revision 0 is still a valid revision. if res.Revision >= 0 { result.Revision = fmt.Sprintf("%v", res.Revision) } else { result.Revision = "-" } return result }
go
func FormatAppResource(res resource.Resource) FormattedAppResource { used := !res.IsPlaceholder() result := FormattedAppResource{ ID: res.ID, ApplicationID: res.ApplicationID, Name: res.Name, Type: res.Type.String(), Path: res.Path, Description: res.Description, Origin: res.Origin.String(), Fingerprint: res.Fingerprint.String(), Size: res.Size, Used: used, Timestamp: res.Timestamp, Username: res.Username, CombinedRevision: combinedRevision(res), CombinedOrigin: combinedOrigin(used, res), UsedYesNo: usedYesNo(used), } // Have to check since revision 0 is still a valid revision. if res.Revision >= 0 { result.Revision = fmt.Sprintf("%v", res.Revision) } else { result.Revision = "-" } return result }
[ "func", "FormatAppResource", "(", "res", "resource", ".", "Resource", ")", "FormattedAppResource", "{", "used", ":=", "!", "res", ".", "IsPlaceholder", "(", ")", "\n", "result", ":=", "FormattedAppResource", "{", "ID", ":", "res", ".", "ID", ",", "Applicatio...
// FormatAppResource converts the resource info into a FormattedAppResource.
[ "FormatAppResource", "converts", "the", "resource", "info", "into", "a", "FormattedAppResource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/resource/formatter.go#L63-L89
157,461
juju/juju
cmd/juju/resource/formatter.go
FormatApplicationDetails
func FormatApplicationDetails(sr resource.ApplicationResources) (FormattedApplicationDetails, error) { var formatted FormattedApplicationDetails details, err := detailedResources("", sr) if err != nil { return formatted, errors.Trace(err) } updates, err := sr.Updates() if err != nil { return formatted, errors.Trace(err) } formatted = FormattedApplicationDetails{ Resources: details, Updates: make([]FormattedCharmResource, len(updates)), } for i, u := range updates { formatted.Updates[i] = FormatCharmResource(u) } return formatted, nil }
go
func FormatApplicationDetails(sr resource.ApplicationResources) (FormattedApplicationDetails, error) { var formatted FormattedApplicationDetails details, err := detailedResources("", sr) if err != nil { return formatted, errors.Trace(err) } updates, err := sr.Updates() if err != nil { return formatted, errors.Trace(err) } formatted = FormattedApplicationDetails{ Resources: details, Updates: make([]FormattedCharmResource, len(updates)), } for i, u := range updates { formatted.Updates[i] = FormatCharmResource(u) } return formatted, nil }
[ "func", "FormatApplicationDetails", "(", "sr", "resource", ".", "ApplicationResources", ")", "(", "FormattedApplicationDetails", ",", "error", ")", "{", "var", "formatted", "FormattedApplicationDetails", "\n", "details", ",", "err", ":=", "detailedResources", "(", "\"...
// FormatApplicationDetails converts a ApplicationResources value into a formatted value // for display on the command line.
[ "FormatApplicationDetails", "converts", "a", "ApplicationResources", "value", "into", "a", "formatted", "value", "for", "display", "on", "the", "command", "line", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/resource/formatter.go#L113-L131
157,462
juju/juju
cmd/juju/resource/formatter.go
FormatDetailResource
func FormatDetailResource(tag names.UnitTag, svc, unit resource.Resource, progress int64) (FormattedDetailResource, error) { // note that the unit resource can be a zero value here, to indicate that // the unit has not downloaded that resource yet. unitNum, err := unitNum(tag) if err != nil { return FormattedDetailResource{}, errors.Trace(err) } progressStr := "" fUnit := FormatAppResource(unit) expected := FormatAppResource(svc) revProgress := expected.CombinedRevision if progress >= 0 { progressStr = "100%" if expected.Size > 0 { progressStr = fmt.Sprintf("%.f%%", float64(progress)*100.0/float64(expected.Size)) } if fUnit.CombinedRevision != expected.CombinedRevision { revProgress = fmt.Sprintf("%s (fetching: %s)", expected.CombinedRevision, progressStr) } } return FormattedDetailResource{ UnitID: tag.Id(), UnitNumber: unitNum, Unit: fUnit, Expected: expected, Progress: progress, RevProgress: revProgress, }, nil }
go
func FormatDetailResource(tag names.UnitTag, svc, unit resource.Resource, progress int64) (FormattedDetailResource, error) { // note that the unit resource can be a zero value here, to indicate that // the unit has not downloaded that resource yet. unitNum, err := unitNum(tag) if err != nil { return FormattedDetailResource{}, errors.Trace(err) } progressStr := "" fUnit := FormatAppResource(unit) expected := FormatAppResource(svc) revProgress := expected.CombinedRevision if progress >= 0 { progressStr = "100%" if expected.Size > 0 { progressStr = fmt.Sprintf("%.f%%", float64(progress)*100.0/float64(expected.Size)) } if fUnit.CombinedRevision != expected.CombinedRevision { revProgress = fmt.Sprintf("%s (fetching: %s)", expected.CombinedRevision, progressStr) } } return FormattedDetailResource{ UnitID: tag.Id(), UnitNumber: unitNum, Unit: fUnit, Expected: expected, Progress: progress, RevProgress: revProgress, }, nil }
[ "func", "FormatDetailResource", "(", "tag", "names", ".", "UnitTag", ",", "svc", ",", "unit", "resource", ".", "Resource", ",", "progress", "int64", ")", "(", "FormattedDetailResource", ",", "error", ")", "{", "// note that the unit resource can be a zero value here, ...
// FormatDetailResource converts the arguments into a FormattedApplicationResource.
[ "FormatDetailResource", "converts", "the", "arguments", "into", "a", "FormattedApplicationResource", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/resource/formatter.go#L134-L163
157,463
juju/juju
cmd/juju/resource/formatter.go
detailedResources
func detailedResources(unit string, sr resource.ApplicationResources) ([]FormattedDetailResource, error) { var formatted []FormattedDetailResource for _, ur := range sr.UnitResources { if unit == "" || unit == ur.Tag.Id() { units := resourceMap(ur.Resources) for _, svc := range sr.Resources { progress, ok := ur.DownloadProgress[svc.Name] if !ok { progress = -1 } f, err := FormatDetailResource(ur.Tag, svc, units[svc.Name], progress) if err != nil { return nil, errors.Trace(err) } formatted = append(formatted, f) } if unit != "" { break } } } return formatted, nil }
go
func detailedResources(unit string, sr resource.ApplicationResources) ([]FormattedDetailResource, error) { var formatted []FormattedDetailResource for _, ur := range sr.UnitResources { if unit == "" || unit == ur.Tag.Id() { units := resourceMap(ur.Resources) for _, svc := range sr.Resources { progress, ok := ur.DownloadProgress[svc.Name] if !ok { progress = -1 } f, err := FormatDetailResource(ur.Tag, svc, units[svc.Name], progress) if err != nil { return nil, errors.Trace(err) } formatted = append(formatted, f) } if unit != "" { break } } } return formatted, nil }
[ "func", "detailedResources", "(", "unit", "string", ",", "sr", "resource", ".", "ApplicationResources", ")", "(", "[", "]", "FormattedDetailResource", ",", "error", ")", "{", "var", "formatted", "[", "]", "FormattedDetailResource", "\n", "for", "_", ",", "ur",...
// detailedResources shows the version of each resource on each unit, with the // corresponding version of the resource that exists in the controller. if unit // is non-empty, only units matching that unitID will be returned.
[ "detailedResources", "shows", "the", "version", "of", "each", "resource", "on", "each", "unit", "with", "the", "corresponding", "version", "of", "the", "resource", "that", "exists", "in", "the", "controller", ".", "if", "unit", "is", "non", "-", "empty", "on...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/resource/formatter.go#L212-L234
157,464
juju/juju
provider/cloudsigma/environcaps.go
ConstraintsValidator
func (env *environ) ConstraintsValidator(ctx context.ProviderCallContext) (constraints.Validator, error) { validator := constraints.NewValidator() validator.RegisterUnsupported(unsupportedConstraints) return validator, nil }
go
func (env *environ) ConstraintsValidator(ctx context.ProviderCallContext) (constraints.Validator, error) { validator := constraints.NewValidator() validator.RegisterUnsupported(unsupportedConstraints) return validator, nil }
[ "func", "(", "env", "*", "environ", ")", "ConstraintsValidator", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "constraints", ".", "Validator", ",", "error", ")", "{", "validator", ":=", "constraints", ".", "NewValidator", "(", ")", "\n", "val...
// ConstraintsValidator returns a Validator instance which // is used to validate and merge constraints.
[ "ConstraintsValidator", "returns", "a", "Validator", "instance", "which", "is", "used", "to", "validate", "and", "merge", "constraints", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/cloudsigma/environcaps.go#L20-L24
157,465
juju/juju
apiserver/common/ensuredead.go
NewDeadEnsurer
func NewDeadEnsurer(st state.EntityFinder, getCanModify GetAuthFunc) *DeadEnsurer { return &DeadEnsurer{ st: st, getCanModify: getCanModify, } }
go
func NewDeadEnsurer(st state.EntityFinder, getCanModify GetAuthFunc) *DeadEnsurer { return &DeadEnsurer{ st: st, getCanModify: getCanModify, } }
[ "func", "NewDeadEnsurer", "(", "st", "state", ".", "EntityFinder", ",", "getCanModify", "GetAuthFunc", ")", "*", "DeadEnsurer", "{", "return", "&", "DeadEnsurer", "{", "st", ":", "st", ",", "getCanModify", ":", "getCanModify", ",", "}", "\n", "}" ]
// NewDeadEnsurer returns a new DeadEnsurer. The GetAuthFunc will be // used on each invocation of EnsureDead to determine current // permissions.
[ "NewDeadEnsurer", "returns", "a", "new", "DeadEnsurer", ".", "The", "GetAuthFunc", "will", "be", "used", "on", "each", "invocation", "of", "EnsureDead", "to", "determine", "current", "permissions", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/ensuredead.go#L24-L29
157,466
juju/juju
apiserver/facades/agent/presence/pinger.go
Validate
func (config Config) Validate() error { if config.Identity == nil { return errors.NotValidf("nil Identity") } if config.Start == nil { return errors.NotValidf("nil Start") } if config.Clock == nil { return errors.NotValidf("nil Clock") } if config.RetryDelay <= 0 { return errors.NotValidf("non-positive RetryDelay") } return nil }
go
func (config Config) Validate() error { if config.Identity == nil { return errors.NotValidf("nil Identity") } if config.Start == nil { return errors.NotValidf("nil Start") } if config.Clock == nil { return errors.NotValidf("nil Clock") } if config.RetryDelay <= 0 { return errors.NotValidf("non-positive RetryDelay") } return nil }
[ "func", "(", "config", "Config", ")", "Validate", "(", ")", "error", "{", "if", "config", ".", "Identity", "==", "nil", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "config", ".", "Start", "==", "nil", "{"...
// Validate returns an error if Config cannot be expected to drive a // Worker.
[ "Validate", "returns", "an", "error", "if", "Config", "cannot", "be", "expected", "to", "drive", "a", "Worker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/presence/pinger.go#L50-L64
157,467
juju/juju
apiserver/facades/agent/presence/pinger.go
loop
func (w *Worker) loop() error { var delay time.Duration for { select { case <-w.catacomb.Dying(): return w.catacomb.ErrDying() case <-w.config.Clock.After(delay): maybePinger := w.maybeStartPinger() w.reportRunning() w.waitPinger(maybePinger) } delay = w.config.RetryDelay } }
go
func (w *Worker) loop() error { var delay time.Duration for { select { case <-w.catacomb.Dying(): return w.catacomb.ErrDying() case <-w.config.Clock.After(delay): maybePinger := w.maybeStartPinger() w.reportRunning() w.waitPinger(maybePinger) } delay = w.config.RetryDelay } }
[ "func", "(", "w", "*", "Worker", ")", "loop", "(", ")", "error", "{", "var", "delay", "time", ".", "Duration", "\n", "for", "{", "select", "{", "case", "<-", "w", ".", "catacomb", ".", "Dying", "(", ")", ":", "return", "w", ".", "catacomb", ".", ...
// loop runs Pingers until w is stopped.
[ "loop", "runs", "Pingers", "until", "w", "is", "stopped", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/presence/pinger.go#L133-L146
157,468
juju/juju
apiserver/facades/agent/presence/pinger.go
maybeStartPinger
func (w *Worker) maybeStartPinger() Pinger { w.logger.Tracef("starting pinger...") pinger, err := w.config.Start() if err != nil { w.logger.Errorf("cannot start pinger: %v", err) return nil } w.logger.Tracef("pinger started") return pinger }
go
func (w *Worker) maybeStartPinger() Pinger { w.logger.Tracef("starting pinger...") pinger, err := w.config.Start() if err != nil { w.logger.Errorf("cannot start pinger: %v", err) return nil } w.logger.Tracef("pinger started") return pinger }
[ "func", "(", "w", "*", "Worker", ")", "maybeStartPinger", "(", ")", "Pinger", "{", "w", ".", "logger", ".", "Tracef", "(", "\"", "\"", ")", "\n", "pinger", ",", "err", ":=", "w", ".", "config", ".", "Start", "(", ")", "\n", "if", "err", "!=", "...
// maybeStartPinger starts and returns a new Pinger; or, if it // encounters an error, logs it and returns nil.
[ "maybeStartPinger", "starts", "and", "returns", "a", "new", "Pinger", ";", "or", "if", "it", "encounters", "an", "error", "logs", "it", "and", "returns", "nil", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/presence/pinger.go#L150-L159
157,469
juju/juju
apiserver/facades/agent/presence/pinger.go
waitPinger
func (w *Worker) waitPinger(pinger Pinger) { if pinger == nil { return } // Set up a channel that will last as long as this method call. done := make(chan struct{}) defer close(done) // Start a goroutine to stop the Pinger if the worker is killed. // If the enclosing method completes, we know that the Pinger // has already stopped, and we can return immediately. // // Note that we ignore errors out of Stop(), depending on the // Pinger to manage errors properly and report them via Wait() // below. go func() { select { case <-done: case <-w.catacomb.Dying(): w.logger.Tracef("stopping pinger") pinger.Stop() } }() // Now, just wait for the Pinger to stop. It might be caused by // the Worker's death, or it might have failed on its own; in // any case, errors are worth recording, but we don't need to // respond in any way because that's loop()'s responsibility. w.logger.Tracef("waiting for pinger...") if err := pinger.Wait(); err != nil { w.logger.Errorf("pinger failed: %v", err) } }
go
func (w *Worker) waitPinger(pinger Pinger) { if pinger == nil { return } // Set up a channel that will last as long as this method call. done := make(chan struct{}) defer close(done) // Start a goroutine to stop the Pinger if the worker is killed. // If the enclosing method completes, we know that the Pinger // has already stopped, and we can return immediately. // // Note that we ignore errors out of Stop(), depending on the // Pinger to manage errors properly and report them via Wait() // below. go func() { select { case <-done: case <-w.catacomb.Dying(): w.logger.Tracef("stopping pinger") pinger.Stop() } }() // Now, just wait for the Pinger to stop. It might be caused by // the Worker's death, or it might have failed on its own; in // any case, errors are worth recording, but we don't need to // respond in any way because that's loop()'s responsibility. w.logger.Tracef("waiting for pinger...") if err := pinger.Wait(); err != nil { w.logger.Errorf("pinger failed: %v", err) } }
[ "func", "(", "w", "*", "Worker", ")", "waitPinger", "(", "pinger", "Pinger", ")", "{", "if", "pinger", "==", "nil", "{", "return", "\n", "}", "\n\n", "// Set up a channel that will last as long as this method call.", "done", ":=", "make", "(", "chan", "struct", ...
// waitPinger waits for the death of either the pinger or the worker; // stops the pinger if necessary; and returns once the pinger is // finished. If pinger is nil, it returns immediately.
[ "waitPinger", "waits", "for", "the", "death", "of", "either", "the", "pinger", "or", "the", "worker", ";", "stops", "the", "pinger", "if", "necessary", ";", "and", "returns", "once", "the", "pinger", "is", "finished", ".", "If", "pinger", "is", "nil", "i...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/presence/pinger.go#L176-L209
157,470
juju/juju
api/interface.go
Ports
func (info *Info) Ports() []int { ports := set.NewInts() hostPorts, err := network.ParseHostPorts(info.Addrs...) if err != nil { // Addresses have already been validated. panic(err) } for _, hp := range hostPorts { ports.Add(hp.Port) } return ports.Values() }
go
func (info *Info) Ports() []int { ports := set.NewInts() hostPorts, err := network.ParseHostPorts(info.Addrs...) if err != nil { // Addresses have already been validated. panic(err) } for _, hp := range hostPorts { ports.Add(hp.Port) } return ports.Values() }
[ "func", "(", "info", "*", "Info", ")", "Ports", "(", ")", "[", "]", "int", "{", "ports", ":=", "set", ".", "NewInts", "(", ")", "\n", "hostPorts", ",", "err", ":=", "network", ".", "ParseHostPorts", "(", "info", ".", "Addrs", "...", ")", "\n", "i...
// Ports returns the unique ports for the api addresses.
[ "Ports", "returns", "the", "unique", "ports", "for", "the", "api", "addresses", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/interface.go#L88-L99
157,471
juju/juju
api/interface.go
Validate
func (info *Info) Validate() error { if len(info.Addrs) == 0 { return errors.NotValidf("missing addresses") } if _, err := network.ParseHostPorts(info.Addrs...); err != nil { return errors.NotValidf("host addresses: %v", err) } if info.SkipLogin { if info.Tag != nil { return errors.NotValidf("specifying Tag and SkipLogin") } if info.Password != "" { return errors.NotValidf("specifying Password and SkipLogin") } if len(info.Macaroons) > 0 { return errors.NotValidf("specifying Macaroons and SkipLogin") } } return nil }
go
func (info *Info) Validate() error { if len(info.Addrs) == 0 { return errors.NotValidf("missing addresses") } if _, err := network.ParseHostPorts(info.Addrs...); err != nil { return errors.NotValidf("host addresses: %v", err) } if info.SkipLogin { if info.Tag != nil { return errors.NotValidf("specifying Tag and SkipLogin") } if info.Password != "" { return errors.NotValidf("specifying Password and SkipLogin") } if len(info.Macaroons) > 0 { return errors.NotValidf("specifying Macaroons and SkipLogin") } } return nil }
[ "func", "(", "info", "*", "Info", ")", "Validate", "(", ")", "error", "{", "if", "len", "(", "info", ".", "Addrs", ")", "==", "0", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "_", ",", "err", ":=", ...
// Validate validates the API info.
[ "Validate", "validates", "the", "API", "info", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/interface.go#L102-L121
157,472
juju/juju
api/interface.go
DefaultDialOpts
func DefaultDialOpts() DialOpts { return DialOpts{ DialAddressInterval: 50 * time.Millisecond, Timeout: 10 * time.Minute, RetryDelay: 2 * time.Second, } }
go
func DefaultDialOpts() DialOpts { return DialOpts{ DialAddressInterval: 50 * time.Millisecond, Timeout: 10 * time.Minute, RetryDelay: 2 * time.Second, } }
[ "func", "DefaultDialOpts", "(", ")", "DialOpts", "{", "return", "DialOpts", "{", "DialAddressInterval", ":", "50", "*", "time", ".", "Millisecond", ",", "Timeout", ":", "10", "*", "time", ".", "Minute", ",", "RetryDelay", ":", "2", "*", "time", ".", "Sec...
// DefaultDialOpts returns a DialOpts representing the default // parameters for contacting a controller.
[ "DefaultDialOpts", "returns", "a", "DialOpts", "representing", "the", "default", "parameters", "for", "contacting", "a", "controller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/interface.go#L205-L211
157,473
juju/juju
container/kvm/initialisation.go
getPackageManager
func getPackageManager() (manager.PackageManager, error) { hostSeries, err := series.HostSeries() if err != nil { return nil, errors.Trace(err) } return manager.NewPackageManager(hostSeries) }
go
func getPackageManager() (manager.PackageManager, error) { hostSeries, err := series.HostSeries() if err != nil { return nil, errors.Trace(err) } return manager.NewPackageManager(hostSeries) }
[ "func", "getPackageManager", "(", ")", "(", "manager", ".", "PackageManager", ",", "error", ")", "{", "hostSeries", ",", "err", ":=", "series", ".", "HostSeries", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trac...
// getPackageManager is a helper function which returns the // package manager implementation for the current system.
[ "getPackageManager", "is", "a", "helper", "function", "which", "returns", "the", "package", "manager", "implementation", "for", "the", "current", "system", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/kvm/initialisation.go#L48-L54
157,474
juju/juju
container/kvm/initialisation.go
ensurePool
func ensurePool(poolInfo *libvirtPool, pathfinder func(string) (string, error), runCmd runFunc, chownFunc func(string) error) error { poolDir, err := guestPath(pathfinder) if err != nil { return errors.Trace(err) } if poolInfo == nil { poolInfo = &libvirtPool{} } if poolInfo.Name == "" { if err = definePool(poolDir, runCmd, chownFunc); err != nil { return errors.Trace(err) } } else { logger.Debugf(`pool %q already created`, poolInfo.Name) } if poolInfo.State != "running" { if err = buildPool(runCmd); err != nil { return errors.Trace(err) } if err = startPool(runCmd); err != nil { return errors.Trace(err) } } else { logger.Debugf(`pool %q already active`, poolInfo.Name) } if poolInfo.Autostart != "yes" { if err = autostartPool(runCmd); err != nil { return errors.Trace(err) } } // We have to set ownership of the guest pool directory after running virsh // commands above, because it appears that the libvirt-bin version that // ships with trusty sets the ownership of the pool directory to the user // running the commands -- root in our case. Which causes container // initialization to fail as we couldn't write volumes to the pool. We // write them as libvirt-qemu:kvm so that libvirt -- which runs as that // user -- can read them to boot the domains. if err = chownFunc(poolDir); err != nil { return errors.Trace(err) } return nil }
go
func ensurePool(poolInfo *libvirtPool, pathfinder func(string) (string, error), runCmd runFunc, chownFunc func(string) error) error { poolDir, err := guestPath(pathfinder) if err != nil { return errors.Trace(err) } if poolInfo == nil { poolInfo = &libvirtPool{} } if poolInfo.Name == "" { if err = definePool(poolDir, runCmd, chownFunc); err != nil { return errors.Trace(err) } } else { logger.Debugf(`pool %q already created`, poolInfo.Name) } if poolInfo.State != "running" { if err = buildPool(runCmd); err != nil { return errors.Trace(err) } if err = startPool(runCmd); err != nil { return errors.Trace(err) } } else { logger.Debugf(`pool %q already active`, poolInfo.Name) } if poolInfo.Autostart != "yes" { if err = autostartPool(runCmd); err != nil { return errors.Trace(err) } } // We have to set ownership of the guest pool directory after running virsh // commands above, because it appears that the libvirt-bin version that // ships with trusty sets the ownership of the pool directory to the user // running the commands -- root in our case. Which causes container // initialization to fail as we couldn't write volumes to the pool. We // write them as libvirt-qemu:kvm so that libvirt -- which runs as that // user -- can read them to boot the domains. if err = chownFunc(poolDir); err != nil { return errors.Trace(err) } return nil }
[ "func", "ensurePool", "(", "poolInfo", "*", "libvirtPool", ",", "pathfinder", "func", "(", "string", ")", "(", "string", ",", "error", ")", ",", "runCmd", "runFunc", ",", "chownFunc", "func", "(", "string", ")", "error", ")", "error", "{", "poolDir", ","...
// ensurePool creates the libvirt storage pool and ensures its is active. // runCmd and chownFunc are here for testing. runCmd so we can check the // right shell out calls are made, and chownFunc because we cannot chown // unless we are root.
[ "ensurePool", "creates", "the", "libvirt", "storage", "pool", "and", "ensures", "its", "is", "active", ".", "runCmd", "and", "chownFunc", "are", "here", "for", "testing", ".", "runCmd", "so", "we", "can", "check", "the", "right", "shell", "out", "calls", "...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/kvm/initialisation.go#L93-L141
157,475
juju/juju
container/kvm/initialisation.go
definePool
func definePool(dir string, runCmd runFunc, _ func(string) error) error { // Permissions gleaned from https://goo.gl/SZIw14 // The command itself would change the permissions to match anyhow. err := os.MkdirAll(dir, 0755) if err != nil { return errors.Trace(err) } // The dashes are empty positional args for other types of pool storage: // e.g. file, lvm, scsi, disk, NFS. Newer versions support using only named // args (--type, --target) but this is backwards compatible for trusty. output, err := runCmd( "", virsh, "pool-define-as", poolName, "dir", "-", "-", "-", "-", dir) if err != nil { return errors.Trace(err) } logger.Debugf("pool-define-as output %s", output) return nil }
go
func definePool(dir string, runCmd runFunc, _ func(string) error) error { // Permissions gleaned from https://goo.gl/SZIw14 // The command itself would change the permissions to match anyhow. err := os.MkdirAll(dir, 0755) if err != nil { return errors.Trace(err) } // The dashes are empty positional args for other types of pool storage: // e.g. file, lvm, scsi, disk, NFS. Newer versions support using only named // args (--type, --target) but this is backwards compatible for trusty. output, err := runCmd( "", virsh, "pool-define-as", poolName, "dir", "-", "-", "-", "-", dir) if err != nil { return errors.Trace(err) } logger.Debugf("pool-define-as output %s", output) return nil }
[ "func", "definePool", "(", "dir", "string", ",", "runCmd", "runFunc", ",", "_", "func", "(", "string", ")", "error", ")", "error", "{", "// Permissions gleaned from https://goo.gl/SZIw14", "// The command itself would change the permissions to match anyhow.", "err", ":=", ...
// definePool creates the required directories and changes ownership of the // guest directory so that libvirt-qemu can read, write, and execute its // guest volumes.
[ "definePool", "creates", "the", "required", "directories", "and", "changes", "ownership", "of", "the", "guest", "directory", "so", "that", "libvirt", "-", "qemu", "can", "read", "write", "and", "execute", "its", "guest", "volumes", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/kvm/initialisation.go#L146-L171
157,476
juju/juju
container/kvm/initialisation.go
buildPool
func buildPool(runCmd runFunc) error { // This can run without error if the pool isn't active. output, err := runCmd("", virsh, "pool-build", poolName) if err != nil { return errors.Trace(err) } logger.Debugf("pool-build output %s", output) return nil }
go
func buildPool(runCmd runFunc) error { // This can run without error if the pool isn't active. output, err := runCmd("", virsh, "pool-build", poolName) if err != nil { return errors.Trace(err) } logger.Debugf("pool-build output %s", output) return nil }
[ "func", "buildPool", "(", "runCmd", "runFunc", ")", "error", "{", "// This can run without error if the pool isn't active.", "output", ",", "err", ":=", "runCmd", "(", "\"", "\"", ",", "virsh", ",", "\"", "\"", ",", "poolName", ")", "\n", "if", "err", "!=", ...
// buildPool sets up libvirt internals for the guest pool.
[ "buildPool", "sets", "up", "libvirt", "internals", "for", "the", "guest", "pool", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/kvm/initialisation.go#L192-L200
157,477
juju/juju
cmd/juju/storage/poolcreate.go
NewPoolCreateCommand
func NewPoolCreateCommand() cmd.Command { cmd := &poolCreateCommand{} cmd.newAPIFunc = func() (PoolCreateAPI, error) { return cmd.NewStorageAPI() } return modelcmd.Wrap(cmd) }
go
func NewPoolCreateCommand() cmd.Command { cmd := &poolCreateCommand{} cmd.newAPIFunc = func() (PoolCreateAPI, error) { return cmd.NewStorageAPI() } return modelcmd.Wrap(cmd) }
[ "func", "NewPoolCreateCommand", "(", ")", "cmd", ".", "Command", "{", "cmd", ":=", "&", "poolCreateCommand", "{", "}", "\n", "cmd", ".", "newAPIFunc", "=", "func", "(", ")", "(", "PoolCreateAPI", ",", "error", ")", "{", "return", "cmd", ".", "NewStorageA...
// NewPoolCreateCommand returns a command that creates or defines a storage pool
[ "NewPoolCreateCommand", "returns", "a", "command", "that", "creates", "or", "defines", "a", "storage", "pool" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/storage/poolcreate.go#L60-L66
157,478
juju/juju
apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go
NewMockModelCache
func NewMockModelCache(ctrl *gomock.Controller) *MockModelCache { mock := &MockModelCache{ctrl: ctrl} mock.recorder = &MockModelCacheMockRecorder{mock} return mock }
go
func NewMockModelCache(ctrl *gomock.Controller) *MockModelCache { mock := &MockModelCache{ctrl: ctrl} mock.recorder = &MockModelCacheMockRecorder{mock} return mock }
[ "func", "NewMockModelCache", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockModelCache", "{", "mock", ":=", "&", "MockModelCache", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockModelCacheMockRecorder", "{", "mock...
// NewMockModelCache creates a new mock instance
[ "NewMockModelCache", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go#L28-L32
157,479
juju/juju
apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go
NewMockModelCacheMachine
func NewMockModelCacheMachine(ctrl *gomock.Controller) *MockModelCacheMachine { mock := &MockModelCacheMachine{ctrl: ctrl} mock.recorder = &MockModelCacheMachineMockRecorder{mock} return mock }
go
func NewMockModelCacheMachine(ctrl *gomock.Controller) *MockModelCacheMachine { mock := &MockModelCacheMachine{ctrl: ctrl} mock.recorder = &MockModelCacheMachineMockRecorder{mock} return mock }
[ "func", "NewMockModelCacheMachine", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockModelCacheMachine", "{", "mock", ":=", "&", "MockModelCacheMachine", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockModelCacheMachineM...
// NewMockModelCacheMachine creates a new mock instance
[ "NewMockModelCacheMachine", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go#L115-L119
157,480
juju/juju
apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go
NewMockModelCacheApplication
func NewMockModelCacheApplication(ctrl *gomock.Controller) *MockModelCacheApplication { mock := &MockModelCacheApplication{ctrl: ctrl} mock.recorder = &MockModelCacheApplicationMockRecorder{mock} return mock }
go
func NewMockModelCacheApplication(ctrl *gomock.Controller) *MockModelCacheApplication { mock := &MockModelCacheApplication{ctrl: ctrl} mock.recorder = &MockModelCacheApplicationMockRecorder{mock} return mock }
[ "func", "NewMockModelCacheApplication", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockModelCacheApplication", "{", "mock", ":=", "&", "MockModelCacheApplication", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockModelC...
// NewMockModelCacheApplication creates a new mock instance
[ "NewMockModelCacheApplication", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go#L202-L206
157,481
juju/juju
apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go
CharmURL
func (m *MockModelCacheApplication) CharmURL() string { ret := m.ctrl.Call(m, "CharmURL") ret0, _ := ret[0].(string) return ret0 }
go
func (m *MockModelCacheApplication) CharmURL() string { ret := m.ctrl.Call(m, "CharmURL") ret0, _ := ret[0].(string) return ret0 }
[ "func", "(", "m", "*", "MockModelCacheApplication", ")", "CharmURL", "(", ")", "string", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "string", ")...
// CharmURL mocks base method
[ "CharmURL", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go#L214-L218
157,482
juju/juju
apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go
CharmURL
func (mr *MockModelCacheApplicationMockRecorder) CharmURL() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CharmURL", reflect.TypeOf((*MockModelCacheApplication)(nil).CharmURL)) }
go
func (mr *MockModelCacheApplicationMockRecorder) CharmURL() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CharmURL", reflect.TypeOf((*MockModelCacheApplication)(nil).CharmURL)) }
[ "func", "(", "mr", "*", "MockModelCacheApplicationMockRecorder", ")", "CharmURL", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect",...
// CharmURL indicates an expected call of CharmURL
[ "CharmURL", "indicates", "an", "expected", "call", "of", "CharmURL" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go#L221-L223
157,483
juju/juju
apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go
NewMockModelCacheUnit
func NewMockModelCacheUnit(ctrl *gomock.Controller) *MockModelCacheUnit { mock := &MockModelCacheUnit{ctrl: ctrl} mock.recorder = &MockModelCacheUnitMockRecorder{mock} return mock }
go
func NewMockModelCacheUnit(ctrl *gomock.Controller) *MockModelCacheUnit { mock := &MockModelCacheUnit{ctrl: ctrl} mock.recorder = &MockModelCacheUnitMockRecorder{mock} return mock }
[ "func", "NewMockModelCacheUnit", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockModelCacheUnit", "{", "mock", ":=", "&", "MockModelCacheUnit", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockModelCacheUnitMockRecorder"...
// NewMockModelCacheUnit creates a new mock instance
[ "NewMockModelCacheUnit", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go#L237-L241
157,484
juju/juju
apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go
NewMockModelCacheCharm
func NewMockModelCacheCharm(ctrl *gomock.Controller) *MockModelCacheCharm { mock := &MockModelCacheCharm{ctrl: ctrl} mock.recorder = &MockModelCacheCharmMockRecorder{mock} return mock }
go
func NewMockModelCacheCharm(ctrl *gomock.Controller) *MockModelCacheCharm { mock := &MockModelCacheCharm{ctrl: ctrl} mock.recorder = &MockModelCacheCharmMockRecorder{mock} return mock }
[ "func", "NewMockModelCacheCharm", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockModelCacheCharm", "{", "mock", ":=", "&", "MockModelCacheCharm", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockModelCacheCharmMockRecor...
// NewMockModelCacheCharm creates a new mock instance
[ "NewMockModelCacheCharm", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/modelcache_mock.go#L272-L276
157,485
juju/juju
cmd/juju/application/addunit.go
IncompatibleModel
func (c *addUnitCommand) IncompatibleModel(err error) error { if err == nil { return nil } msg := ` add-unit is not allowed on Kubernetes models. Instead, use juju scale-application. See juju help scale-application. `[1:] return errors.New(msg) }
go
func (c *addUnitCommand) IncompatibleModel(err error) error { if err == nil { return nil } msg := ` add-unit is not allowed on Kubernetes models. Instead, use juju scale-application. See juju help scale-application. `[1:] return errors.New(msg) }
[ "func", "(", "c", "*", "addUnitCommand", ")", "IncompatibleModel", "(", "err", "error", ")", "error", "{", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "msg", ":=", "`\nadd-unit is not allowed on Kubernetes models.\nInstead, use juju scale-applic...
// IncompatibleModel returns an error if the command is being run against // a model with which it is not compatible.
[ "IncompatibleModel", "returns", "an", "error", "if", "the", "command", "is", "being", "run", "against", "a", "model", "with", "which", "it", "is", "not", "compatible", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/addunit.go#L176-L186
157,486
juju/juju
cmd/juju/application/addunit.go
Run
func (c *addUnitCommand) Run(ctx *cmd.Context) error { apiclient, err := c.getAPI() if err != nil { return err } defer apiclient.Close() if c.unknownModel { if err := c.validateArgsByModelType(); err != nil { return errors.Trace(err) } } modelType, err := c.ModelType() if err != nil { return err } if modelType == model.CAAS { _, err = apiclient.ScaleApplication(application.ScaleApplicationParams{ ApplicationName: c.ApplicationName, ScaleChange: c.NumUnits, }) if params.IsCodeUnauthorized(err) { common.PermissionsMessage(ctx.Stderr, "scale an application") } return block.ProcessBlockedError(err, block.BlockChange) } if len(c.AttachStorage) > 0 && apiclient.BestAPIVersion() < 5 { // AddUnitsPArams.AttachStorage is only supported from // Application API version 5 and onwards. return errors.New("this juju controller does not support --attach-storage") } for i, p := range c.Placement { if p.Scope == "model-uuid" { p.Scope = apiclient.ModelUUID() } c.Placement[i] = p } _, err = apiclient.AddUnits(application.AddUnitsParams{ ApplicationName: c.ApplicationName, NumUnits: c.NumUnits, Placement: c.Placement, AttachStorage: c.AttachStorage, }) if params.IsCodeUnauthorized(err) { common.PermissionsMessage(ctx.Stderr, "add a unit") } return block.ProcessBlockedError(err, block.BlockChange) }
go
func (c *addUnitCommand) Run(ctx *cmd.Context) error { apiclient, err := c.getAPI() if err != nil { return err } defer apiclient.Close() if c.unknownModel { if err := c.validateArgsByModelType(); err != nil { return errors.Trace(err) } } modelType, err := c.ModelType() if err != nil { return err } if modelType == model.CAAS { _, err = apiclient.ScaleApplication(application.ScaleApplicationParams{ ApplicationName: c.ApplicationName, ScaleChange: c.NumUnits, }) if params.IsCodeUnauthorized(err) { common.PermissionsMessage(ctx.Stderr, "scale an application") } return block.ProcessBlockedError(err, block.BlockChange) } if len(c.AttachStorage) > 0 && apiclient.BestAPIVersion() < 5 { // AddUnitsPArams.AttachStorage is only supported from // Application API version 5 and onwards. return errors.New("this juju controller does not support --attach-storage") } for i, p := range c.Placement { if p.Scope == "model-uuid" { p.Scope = apiclient.ModelUUID() } c.Placement[i] = p } _, err = apiclient.AddUnits(application.AddUnitsParams{ ApplicationName: c.ApplicationName, NumUnits: c.NumUnits, Placement: c.Placement, AttachStorage: c.AttachStorage, }) if params.IsCodeUnauthorized(err) { common.PermissionsMessage(ctx.Stderr, "add a unit") } return block.ProcessBlockedError(err, block.BlockChange) }
[ "func", "(", "c", "*", "addUnitCommand", ")", "Run", "(", "ctx", "*", "cmd", ".", "Context", ")", "error", "{", "apiclient", ",", "err", ":=", "c", ".", "getAPI", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", ...
// Run connects to the environment specified on the command line // and calls AddUnits for the given application.
[ "Run", "connects", "to", "the", "environment", "specified", "on", "the", "command", "line", "and", "calls", "AddUnits", "for", "the", "given", "application", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/addunit.go#L249-L300
157,487
juju/juju
core/status/status.go
KnownModificationStatus
func (status Status) KnownModificationStatus() bool { switch status { case Idle, Applied, Error, Unknown: return true } return false }
go
func (status Status) KnownModificationStatus() bool { switch status { case Idle, Applied, Error, Unknown: return true } return false }
[ "func", "(", "status", "Status", ")", "KnownModificationStatus", "(", ")", "bool", "{", "switch", "status", "{", "case", "Idle", ",", "Applied", ",", "Error", ",", "Unknown", ":", "return", "true", "\n", "}", "\n", "return", "false", "\n", "}" ]
// KnownModificationStatus returns true if the status has a known value for // a modification of an instance.
[ "KnownModificationStatus", "returns", "true", "if", "the", "status", "has", "a", "known", "value", "for", "a", "modification", "of", "an", "instance", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/status/status.go#L245-L255
157,488
juju/juju
core/status/status.go
KnownAgentStatus
func (status Status) KnownAgentStatus() bool { switch status { case Allocating, Error, Failed, Rebooting, Executing, Idle: return true } return false }
go
func (status Status) KnownAgentStatus() bool { switch status { case Allocating, Error, Failed, Rebooting, Executing, Idle: return true } return false }
[ "func", "(", "status", "Status", ")", "KnownAgentStatus", "(", ")", "bool", "{", "switch", "status", "{", "case", "Allocating", ",", "Error", ",", "Failed", ",", "Rebooting", ",", "Executing", ",", "Idle", ":", "return", "true", "\n", "}", "\n", "return"...
// KnownAgentStatus returns true if status has a known value for an agent. // It includes every status that has ever been valid for a unit or machine agent. // This is used by the apiserver client facade to filter out unknown values.
[ "KnownAgentStatus", "returns", "true", "if", "status", "has", "a", "known", "value", "for", "an", "agent", ".", "It", "includes", "every", "status", "that", "has", "ever", "been", "valid", "for", "a", "unit", "or", "machine", "agent", ".", "This", "is", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/status/status.go#L274-L286
157,489
juju/juju
core/status/status.go
KnownWorkloadStatus
func (status Status) KnownWorkloadStatus() bool { if ValidWorkloadStatus(status) { return true } switch status { case Error: // include error so that we can filter on what the spec says is valid return true default: return false } }
go
func (status Status) KnownWorkloadStatus() bool { if ValidWorkloadStatus(status) { return true } switch status { case Error: // include error so that we can filter on what the spec says is valid return true default: return false } }
[ "func", "(", "status", "Status", ")", "KnownWorkloadStatus", "(", ")", "bool", "{", "if", "ValidWorkloadStatus", "(", "status", ")", "{", "return", "true", "\n", "}", "\n", "switch", "status", "{", "case", "Error", ":", "// include error so that we can filter on...
// KnownWorkloadStatus returns true if status has a known value for a workload. // It includes every status that has ever been valid for a unit agent. // This is used by the apiserver client facade to filter out unknown values.
[ "KnownWorkloadStatus", "returns", "true", "if", "status", "has", "a", "known", "value", "for", "a", "workload", ".", "It", "includes", "every", "status", "that", "has", "ever", "been", "valid", "for", "a", "unit", "agent", ".", "This", "is", "used", "by", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/status/status.go#L291-L301
157,490
juju/juju
provider/common/destroy.go
Destroy
func Destroy(env environs.Environ, ctx context.ProviderCallContext) error { logger.Infof("destroying model %q", env.Config().Name()) if err := destroyInstances(env, ctx); err != nil { return errors.Annotate(err, "destroying instances") } if err := destroyStorage(env, ctx); err != nil { return errors.Annotate(err, "destroying storage") } return nil }
go
func Destroy(env environs.Environ, ctx context.ProviderCallContext) error { logger.Infof("destroying model %q", env.Config().Name()) if err := destroyInstances(env, ctx); err != nil { return errors.Annotate(err, "destroying instances") } if err := destroyStorage(env, ctx); err != nil { return errors.Annotate(err, "destroying storage") } return nil }
[ "func", "Destroy", "(", "env", "environs", ".", "Environ", ",", "ctx", "context", ".", "ProviderCallContext", ")", "error", "{", "logger", ".", "Infof", "(", "\"", "\"", ",", "env", ".", "Config", "(", ")", ".", "Name", "(", ")", ")", "\n", "if", "...
// Destroy is a common implementation of the Destroy method defined on // environs.Environ; we strongly recommend that this implementation be // used when writing a new provider.
[ "Destroy", "is", "a", "common", "implementation", "of", "the", "Destroy", "method", "defined", "on", "environs", ".", "Environ", ";", "we", "strongly", "recommend", "that", "this", "implementation", "be", "used", "when", "writing", "a", "new", "provider", "." ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/destroy.go#L20-L29
157,491
juju/juju
state/pool.go
Release
func (ps *PooledState) Release() bool { if ps.isSystemState || ps.released { return false } removed, err := ps.pool.release(ps.modelUUID, ps.itemKey) if err != nil { logger.Errorf("releasing state back to pool: %s", err.Error()) } ps.released = true return removed }
go
func (ps *PooledState) Release() bool { if ps.isSystemState || ps.released { return false } removed, err := ps.pool.release(ps.modelUUID, ps.itemKey) if err != nil { logger.Errorf("releasing state back to pool: %s", err.Error()) } ps.released = true return removed }
[ "func", "(", "ps", "*", "PooledState", ")", "Release", "(", ")", "bool", "{", "if", "ps", ".", "isSystemState", "||", "ps", ".", "released", "{", "return", "false", "\n", "}", "\n\n", "removed", ",", "err", ":=", "ps", ".", "pool", ".", "release", ...
// Release indicates that the pooled state is no longer required // and can be removed from the pool if there are no other references // to it. // The return indicates whether the released state was actually removed // from the pool - items marked for removal are only removed when released // by all other reference holders.
[ "Release", "indicates", "that", "the", "pooled", "state", "is", "no", "longer", "required", "and", "can", "be", "removed", "from", "the", "pool", "if", "there", "are", "no", "other", "references", "to", "it", ".", "The", "return", "indicates", "whether", "...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/pool.go#L61-L72
157,492
juju/juju
state/pool.go
OpenStatePool
func OpenStatePool(args OpenParams) (*StatePool, error) { logger.Tracef("opening state pool") if err := args.Validate(); err != nil { return nil, errors.Annotate(err, "validating args") } pool := &StatePool{ pool: make(map[string]*PoolItem), hub: pubsub.NewSimpleHub(nil), } session := args.MongoSession.Copy() st, err := open( args.ControllerModelTag, session, args.InitDatabaseFunc, nil, args.NewPolicy, args.Clock, args.RunTransactionObserver, ) if err != nil { session.Close() return nil, errors.Trace(err) } defer func() { if err != nil { if closeErr := st.Close(); closeErr != nil { logger.Errorf("closing State for %s: %v", args.ControllerModelTag, closeErr) } } }() // If the InitDatabaseFunc is set, then we are initializing the // database, and the model won't be there. So we only look for the model // if we aren't initializing. if args.InitDatabaseFunc == nil { if _, err = st.Model(); err != nil { return nil, errors.Trace(mongo.MaybeUnauthorizedf(err, "cannot read model %s", args.ControllerModelTag.Id())) } } if err = st.start(args.ControllerTag, pool.hub); err != nil { return nil, errors.Trace(err) } pool.systemState = st // When creating the txn watchers and the worker to keep it running // we really want to use wall clocks. Otherwise the events never get // noticed. The clocks in the runner and the txn watcher are used to // control polling, and never return the actual times. pool.watcherRunner = worker.NewRunner(worker.RunnerParams{ // TODO add a Logger parameter to RunnerParams: // Logger: loggo.GetLogger(logger.Name() + ".txnwatcher"), IsFatal: func(err error) bool { return errors.Cause(err) == errPoolClosed }, RestartDelay: time.Second, Clock: args.Clock, }) pool.watcherRunner.StartWorker(txnLogWorker, func() (worker.Worker, error) { return watcher.NewTxnWatcher( watcher.TxnWatcherConfig{ ChangeLog: st.getTxnLogCollection(), Hub: pool.hub, Clock: args.Clock, Logger: loggo.GetLogger("juju.state.pool.txnwatcher"), }) }) return pool, nil }
go
func OpenStatePool(args OpenParams) (*StatePool, error) { logger.Tracef("opening state pool") if err := args.Validate(); err != nil { return nil, errors.Annotate(err, "validating args") } pool := &StatePool{ pool: make(map[string]*PoolItem), hub: pubsub.NewSimpleHub(nil), } session := args.MongoSession.Copy() st, err := open( args.ControllerModelTag, session, args.InitDatabaseFunc, nil, args.NewPolicy, args.Clock, args.RunTransactionObserver, ) if err != nil { session.Close() return nil, errors.Trace(err) } defer func() { if err != nil { if closeErr := st.Close(); closeErr != nil { logger.Errorf("closing State for %s: %v", args.ControllerModelTag, closeErr) } } }() // If the InitDatabaseFunc is set, then we are initializing the // database, and the model won't be there. So we only look for the model // if we aren't initializing. if args.InitDatabaseFunc == nil { if _, err = st.Model(); err != nil { return nil, errors.Trace(mongo.MaybeUnauthorizedf(err, "cannot read model %s", args.ControllerModelTag.Id())) } } if err = st.start(args.ControllerTag, pool.hub); err != nil { return nil, errors.Trace(err) } pool.systemState = st // When creating the txn watchers and the worker to keep it running // we really want to use wall clocks. Otherwise the events never get // noticed. The clocks in the runner and the txn watcher are used to // control polling, and never return the actual times. pool.watcherRunner = worker.NewRunner(worker.RunnerParams{ // TODO add a Logger parameter to RunnerParams: // Logger: loggo.GetLogger(logger.Name() + ".txnwatcher"), IsFatal: func(err error) bool { return errors.Cause(err) == errPoolClosed }, RestartDelay: time.Second, Clock: args.Clock, }) pool.watcherRunner.StartWorker(txnLogWorker, func() (worker.Worker, error) { return watcher.NewTxnWatcher( watcher.TxnWatcherConfig{ ChangeLog: st.getTxnLogCollection(), Hub: pool.hub, Clock: args.Clock, Logger: loggo.GetLogger("juju.state.pool.txnwatcher"), }) }) return pool, nil }
[ "func", "OpenStatePool", "(", "args", "OpenParams", ")", "(", "*", "StatePool", ",", "error", ")", "{", "logger", ".", "Tracef", "(", "\"", "\"", ")", "\n", "if", "err", ":=", "args", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return...
// OpenStatePool returns a new StatePool instance.
[ "OpenStatePool", "returns", "a", "new", "StatePool", "instance", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/pool.go#L121-L186
157,493
juju/juju
state/pool.go
Get
func (p *StatePool) Get(modelUUID string) (*PooledState, error) { p.mu.Lock() defer p.mu.Unlock() if p.pool == nil { return nil, errors.New("pool is closed") } if modelUUID == p.systemState.ModelUUID() { return newPooledState(p.systemState, p, modelUUID, true), nil } item, ok := p.pool[modelUUID] if ok && item.remove { // Disallow further usage of a pool item marked for removal. return nil, errors.NewNotFound(nil, fmt.Sprintf("model %v has been removed", modelUUID)) } p.sourceKey++ key := p.sourceKey source := string(debug.Stack()) // Already have a state in the pool for this model; use it. if ok { item.referenceSources[key] = source ps := newPooledState(item.state, p, modelUUID, false) ps.itemKey = key return ps, nil } // Don't create any new pool objects if the state pool is in the // process of closing down. if p.closing { return nil, errors.New("pool is closing") } // We need a new state and pool item. st, err := p.openState(modelUUID) if err != nil { return nil, errors.Trace(err) } p.pool[modelUUID] = &PoolItem{ modelUUID: modelUUID, state: st, referenceSources: map[uint64]string{ key: source, }, } ps := newPooledState(st, p, modelUUID, false) ps.itemKey = key return ps, nil }
go
func (p *StatePool) Get(modelUUID string) (*PooledState, error) { p.mu.Lock() defer p.mu.Unlock() if p.pool == nil { return nil, errors.New("pool is closed") } if modelUUID == p.systemState.ModelUUID() { return newPooledState(p.systemState, p, modelUUID, true), nil } item, ok := p.pool[modelUUID] if ok && item.remove { // Disallow further usage of a pool item marked for removal. return nil, errors.NewNotFound(nil, fmt.Sprintf("model %v has been removed", modelUUID)) } p.sourceKey++ key := p.sourceKey source := string(debug.Stack()) // Already have a state in the pool for this model; use it. if ok { item.referenceSources[key] = source ps := newPooledState(item.state, p, modelUUID, false) ps.itemKey = key return ps, nil } // Don't create any new pool objects if the state pool is in the // process of closing down. if p.closing { return nil, errors.New("pool is closing") } // We need a new state and pool item. st, err := p.openState(modelUUID) if err != nil { return nil, errors.Trace(err) } p.pool[modelUUID] = &PoolItem{ modelUUID: modelUUID, state: st, referenceSources: map[uint64]string{ key: source, }, } ps := newPooledState(st, p, modelUUID, false) ps.itemKey = key return ps, nil }
[ "func", "(", "p", "*", "StatePool", ")", "Get", "(", "modelUUID", "string", ")", "(", "*", "PooledState", ",", "error", ")", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "if", "p", ...
// Get returns a PooledState for a given model, creating a new State instance // if required. // If the State has been marked for removal, an error is returned.
[ "Get", "returns", "a", "PooledState", "for", "a", "given", "model", "creating", "a", "new", "State", "instance", "if", "required", ".", "If", "the", "State", "has", "been", "marked", "for", "removal", "an", "error", "is", "returned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/pool.go#L191-L243
157,494
juju/juju
state/pool.go
GetModel
func (p *StatePool) GetModel(modelUUID string) (*Model, PoolHelper, error) { ps, err := p.Get(modelUUID) if err != nil { return nil, nil, errors.Trace(err) } model, err := ps.Model() if err != nil { ps.Release() return nil, nil, errors.Trace(err) } return model, ps, nil }
go
func (p *StatePool) GetModel(modelUUID string) (*Model, PoolHelper, error) { ps, err := p.Get(modelUUID) if err != nil { return nil, nil, errors.Trace(err) } model, err := ps.Model() if err != nil { ps.Release() return nil, nil, errors.Trace(err) } return model, ps, nil }
[ "func", "(", "p", "*", "StatePool", ")", "GetModel", "(", "modelUUID", "string", ")", "(", "*", "Model", ",", "PoolHelper", ",", "error", ")", "{", "ps", ",", "err", ":=", "p", ".", "Get", "(", "modelUUID", ")", "\n", "if", "err", "!=", "nil", "{...
// GetModel is a convenience method for getting a Model for a State.
[ "GetModel", "is", "a", "convenience", "method", "for", "getting", "a", "Model", "for", "a", "State", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/pool.go#L263-L276
157,495
juju/juju
state/pool.go
release
func (p *StatePool) release(modelUUID string, key uint64) (bool, error) { if modelUUID == p.systemState.ModelUUID() { // We do not monitor usage of the controller's state. return false, nil } p.mu.Lock() defer p.mu.Unlock() if p.pool == nil { return false, errors.New("pool is closed") } item, ok := p.pool[modelUUID] if !ok { return false, errors.Errorf("unable to return unknown model %v to the pool", modelUUID) } if item.refCount() == 0 { return false, errors.Errorf("state pool refcount for model %v is already 0", modelUUID) } delete(item.referenceSources, key) return p.maybeRemoveItem(item) }
go
func (p *StatePool) release(modelUUID string, key uint64) (bool, error) { if modelUUID == p.systemState.ModelUUID() { // We do not monitor usage of the controller's state. return false, nil } p.mu.Lock() defer p.mu.Unlock() if p.pool == nil { return false, errors.New("pool is closed") } item, ok := p.pool[modelUUID] if !ok { return false, errors.Errorf("unable to return unknown model %v to the pool", modelUUID) } if item.refCount() == 0 { return false, errors.Errorf("state pool refcount for model %v is already 0", modelUUID) } delete(item.referenceSources, key) return p.maybeRemoveItem(item) }
[ "func", "(", "p", "*", "StatePool", ")", "release", "(", "modelUUID", "string", ",", "key", "uint64", ")", "(", "bool", ",", "error", ")", "{", "if", "modelUUID", "==", "p", ".", "systemState", ".", "ModelUUID", "(", ")", "{", "// We do not monitor usage...
// release indicates that the client has finished using the State. If the // state has been marked for removal, it will be closed and removed // when the final Release is done; if there are no references, it will be // closed and removed immediately. The boolean result reports whether or // not the state was closed and removed.
[ "release", "indicates", "that", "the", "client", "has", "finished", "using", "the", "State", ".", "If", "the", "state", "has", "been", "marked", "for", "removal", "it", "will", "be", "closed", "and", "removed", "when", "the", "final", "Release", "is", "don...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/pool.go#L283-L305
157,496
juju/juju
state/pool.go
SystemState
func (p *StatePool) SystemState() *State { p.mu.Lock() defer p.mu.Unlock() // State pool is closed, no more access to the system state. if p.pool == nil { return nil } return p.systemState }
go
func (p *StatePool) SystemState() *State { p.mu.Lock() defer p.mu.Unlock() // State pool is closed, no more access to the system state. if p.pool == nil { return nil } return p.systemState }
[ "func", "(", "p", "*", "StatePool", ")", "SystemState", "(", ")", "*", "State", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n", "// State pool is closed, no more access to the system state.", "if", ...
// SystemState returns the State passed in to NewStatePool.
[ "SystemState", "returns", "the", "State", "passed", "in", "to", "NewStatePool", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/pool.go#L343-L351
157,497
juju/juju
state/pool.go
Close
func (p *StatePool) Close() error { p.mu.Lock() // A nil pool map indicates that the pool has already been closed. if p.pool == nil { p.mu.Unlock() return nil } logger.Tracef("state pool closed from:\n%s", debug.Stack()) // Before we go through and close the state pool objects, we need to // stop all the workers running in the state objects. If anyone had asked // for a mutliwatcher, an all watcher worker is stated in the state object's // workers. These need to be stopped before we start closing connections // as those workers use the pool. p.closing = true p.mu.Unlock() for uuid, item := range p.pool { if err := item.state.stopWorkers(); err != nil { logger.Infof("state workers for model %s did not stop: %v", uuid, err) } } if err := p.systemState.stopWorkers(); err != nil { logger.Infof("state workers for controller model did not stop: %v", err) } // Reacquire the lock to modify the pool. // Hopefully by now any workers running that may have released objects // to the pool should be fine. p.mu.Lock() pool := p.pool p.pool = nil var lastErr error // We release the lock as we are closing the state objects to allow // other goroutines that may be attempting to Get a model from the pool // to continue. The Get method will fail with a closed pool. // We do this just in case the workers didn't stop above when we were trying. p.mu.Unlock() for _, item := range pool { if item.refCount() != 0 || item.remove { logger.Warningf( "state for %v leaked from pool - references: %v, removed: %v", item.state.ModelUUID(), item.refCount(), item.remove, ) } err := item.state.Close() if err != nil { lastErr = err } } p.mu.Lock() if p.watcherRunner != nil { worker.Stop(p.watcherRunner) } p.mu.Unlock() // As with above and the other watchers. Unlock while releas if err := p.systemState.Close(); err != nil { lastErr = err } return errors.Annotate(lastErr, "at least one error closing a state") }
go
func (p *StatePool) Close() error { p.mu.Lock() // A nil pool map indicates that the pool has already been closed. if p.pool == nil { p.mu.Unlock() return nil } logger.Tracef("state pool closed from:\n%s", debug.Stack()) // Before we go through and close the state pool objects, we need to // stop all the workers running in the state objects. If anyone had asked // for a mutliwatcher, an all watcher worker is stated in the state object's // workers. These need to be stopped before we start closing connections // as those workers use the pool. p.closing = true p.mu.Unlock() for uuid, item := range p.pool { if err := item.state.stopWorkers(); err != nil { logger.Infof("state workers for model %s did not stop: %v", uuid, err) } } if err := p.systemState.stopWorkers(); err != nil { logger.Infof("state workers for controller model did not stop: %v", err) } // Reacquire the lock to modify the pool. // Hopefully by now any workers running that may have released objects // to the pool should be fine. p.mu.Lock() pool := p.pool p.pool = nil var lastErr error // We release the lock as we are closing the state objects to allow // other goroutines that may be attempting to Get a model from the pool // to continue. The Get method will fail with a closed pool. // We do this just in case the workers didn't stop above when we were trying. p.mu.Unlock() for _, item := range pool { if item.refCount() != 0 || item.remove { logger.Warningf( "state for %v leaked from pool - references: %v, removed: %v", item.state.ModelUUID(), item.refCount(), item.remove, ) } err := item.state.Close() if err != nil { lastErr = err } } p.mu.Lock() if p.watcherRunner != nil { worker.Stop(p.watcherRunner) } p.mu.Unlock() // As with above and the other watchers. Unlock while releas if err := p.systemState.Close(); err != nil { lastErr = err } return errors.Annotate(lastErr, "at least one error closing a state") }
[ "func", "(", "p", "*", "StatePool", ")", "Close", "(", ")", "error", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "// A nil pool map indicates that the pool has already been closed.", "if", "p", ".", "pool", "==", "nil", "{", "p", ".", "mu", ".", "U...
// Close closes all State instances in the pool.
[ "Close", "closes", "all", "State", "instances", "in", "the", "pool", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/pool.go#L354-L416
157,498
juju/juju
state/pool.go
IntrospectionReport
func (p *StatePool) IntrospectionReport() string { p.mu.Lock() defer p.mu.Unlock() removeCount := 0 buff := &bytes.Buffer{} for uuid, item := range p.pool { if item.remove { removeCount++ } fmt.Fprintf(buff, "\nModel: %s\n", uuid) fmt.Fprintf(buff, " Marked for removal: %v\n", item.remove) fmt.Fprintf(buff, " Reference count: %v\n", item.refCount()) index := 0 for _, ref := range item.referenceSources { index++ fmt.Fprintf(buff, " [%d]\n%s\n", index, ref) } item.state.workers.Runner.Report() } return fmt.Sprintf(""+ "Model count: %d models\n"+ "Marked for removal: %d models\n"+ "\n%s", len(p.pool), removeCount, buff) }
go
func (p *StatePool) IntrospectionReport() string { p.mu.Lock() defer p.mu.Unlock() removeCount := 0 buff := &bytes.Buffer{} for uuid, item := range p.pool { if item.remove { removeCount++ } fmt.Fprintf(buff, "\nModel: %s\n", uuid) fmt.Fprintf(buff, " Marked for removal: %v\n", item.remove) fmt.Fprintf(buff, " Reference count: %v\n", item.refCount()) index := 0 for _, ref := range item.referenceSources { index++ fmt.Fprintf(buff, " [%d]\n%s\n", index, ref) } item.state.workers.Runner.Report() } return fmt.Sprintf(""+ "Model count: %d models\n"+ "Marked for removal: %d models\n"+ "\n%s", len(p.pool), removeCount, buff) }
[ "func", "(", "p", "*", "StatePool", ")", "IntrospectionReport", "(", ")", "string", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "removeCount", ":=", "0", "\n", "buff", ":=", "&", "by...
// IntrospectionReport produces the output for the introspection worker // in order to look inside the state pool.
[ "IntrospectionReport", "produces", "the", "output", "for", "the", "introspection", "worker", "in", "order", "to", "look", "inside", "the", "state", "pool", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/pool.go#L420-L446
157,499
juju/juju
resource/resourceadapters/charmstore.go
GetResource
func (cache *charmstoreEntityCache) GetResource(name string) (resource.Resource, error) { return cache.st.GetResource(cache.applicationID, name) }
go
func (cache *charmstoreEntityCache) GetResource(name string) (resource.Resource, error) { return cache.st.GetResource(cache.applicationID, name) }
[ "func", "(", "cache", "*", "charmstoreEntityCache", ")", "GetResource", "(", "name", "string", ")", "(", "resource", ".", "Resource", ",", "error", ")", "{", "return", "cache", ".", "st", ".", "GetResource", "(", "cache", ".", "applicationID", ",", "name",...
// GetResource implements charmstore.EntityCache.
[ "GetResource", "implements", "charmstore", ".", "EntityCache", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/resource/resourceadapters/charmstore.go#L30-L32