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
153,800
juju/juju
utils/stringforwarder/stringforwarder.go
invokeCallback
func (f *StringForwarder) invokeCallback(callback func(string), msg string) { f.mu.Unlock() defer f.mu.Lock() callback(msg) }
go
func (f *StringForwarder) invokeCallback(callback func(string), msg string) { f.mu.Unlock() defer f.mu.Lock() callback(msg) }
[ "func", "(", "f", "*", "StringForwarder", ")", "invokeCallback", "(", "callback", "func", "(", "string", ")", ",", "msg", "string", ")", "{", "f", ".", "mu", ".", "Unlock", "(", ")", "\n", "defer", "f", ".", "mu", ".", "Lock", "(", ")", "\n", "ca...
// invokeCallback invokes the given callback with a message, // unlocking the forwarder's mutex for the duration of the // callback.
[ "invokeCallback", "invokes", "the", "given", "callback", "with", "a", "message", "unlocking", "the", "forwarder", "s", "mutex", "for", "the", "duration", "of", "the", "callback", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/utils/stringforwarder/stringforwarder.go#L89-L93
153,801
juju/juju
worker/uniter/runner/jujuc/credential-get.go
NewCredentialGetCommand
func NewCredentialGetCommand(ctx Context) (cmd.Command, error) { return &CredentialGetCommand{ctx: ctx}, nil }
go
func NewCredentialGetCommand(ctx Context) (cmd.Command, error) { return &CredentialGetCommand{ctx: ctx}, nil }
[ "func", "NewCredentialGetCommand", "(", "ctx", "Context", ")", "(", "cmd", ".", "Command", ",", "error", ")", "{", "return", "&", "CredentialGetCommand", "{", "ctx", ":", "ctx", "}", ",", "nil", "\n", "}" ]
// NewCredentialGetCommand returns a new CredentialGetCommand with the given context.
[ "NewCredentialGetCommand", "returns", "a", "new", "CredentialGetCommand", "with", "the", "given", "context", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/credential-get.go#L22-L24
153,802
juju/juju
service/snap/snap.go
Validate
func (backgroundService *BackgroundService) Validate() error { name := backgroundService.Name if name == "" { return errors.NotValidf("backgroundService.Name must be non-empty -") } if !snapNameRe.MatchString(name) { return errors.NotValidf("backgroundService.Name (%s) fails validation check -", name) } return nil }
go
func (backgroundService *BackgroundService) Validate() error { name := backgroundService.Name if name == "" { return errors.NotValidf("backgroundService.Name must be non-empty -") } if !snapNameRe.MatchString(name) { return errors.NotValidf("backgroundService.Name (%s) fails validation check -", name) } return nil }
[ "func", "(", "backgroundService", "*", "BackgroundService", ")", "Validate", "(", ")", "error", "{", "name", ":=", "backgroundService", ".", "Name", "\n", "if", "name", "==", "\"", "\"", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\...
// Validate checks that the construction parameters of // backgroundService are valid. Successful validation // returns nil.
[ "Validate", "checks", "that", "the", "construction", "parameters", "of", "backgroundService", "are", "valid", ".", "Successful", "validation", "returns", "nil", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L53-L64
153,803
juju/juju
service/snap/snap.go
SetSnapConfig
func SetSnapConfig(snap string, key string, value string) error { if key == "" { return errors.NotValidf("key must not be empty") } cmd := exec.Command(Command, "set", snap, fmt.Sprintf("%s=%s", key, value)) _, err := cmd.Output() if err != nil { return errors.Annotate(err, fmt.Sprintf("setting snap %s config %s to %s", snap, key, value)) } return nil }
go
func SetSnapConfig(snap string, key string, value string) error { if key == "" { return errors.NotValidf("key must not be empty") } cmd := exec.Command(Command, "set", snap, fmt.Sprintf("%s=%s", key, value)) _, err := cmd.Output() if err != nil { return errors.Annotate(err, fmt.Sprintf("setting snap %s config %s to %s", snap, key, value)) } return nil }
[ "func", "SetSnapConfig", "(", "snap", "string", ",", "key", "string", ",", "value", "string", ")", "error", "{", "if", "key", "==", "\"", "\"", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "cmd", ":=", "exec", ...
// SetSnapConfig sets a snap's key to value.
[ "SetSnapConfig", "sets", "a", "snap", "s", "key", "to", "value", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L151-L163
153,804
juju/juju
service/snap/snap.go
ListServices
func ListServices() ([]string, error) { fullCommand := strings.Fields(ListCommand()) services, err := utils.RunCommand(fullCommand[0], fullCommand[1:]...) if err != nil { return []string{}, errors.Trace(err) } return strings.Split(services, "\n"), nil }
go
func ListServices() ([]string, error) { fullCommand := strings.Fields(ListCommand()) services, err := utils.RunCommand(fullCommand[0], fullCommand[1:]...) if err != nil { return []string{}, errors.Trace(err) } return strings.Split(services, "\n"), nil }
[ "func", "ListServices", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "fullCommand", ":=", "strings", ".", "Fields", "(", "ListCommand", "(", ")", ")", "\n", "services", ",", "err", ":=", "utils", ".", "RunCommand", "(", "fullCommand", "["...
// ListServices returns a list of services that are being managed by snap.
[ "ListServices", "returns", "a", "list", "of", "services", "that", "are", "being", "managed", "by", "snap", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L173-L180
153,805
juju/juju
service/snap/snap.go
Validate
func (s Service) Validate() error { var validationErrors = []error{} err := s.app.Validate() if err != nil { validationErrors = append(validationErrors, err) } for _, prerequisite := range s.app.Prerequisites { err = prerequisite.Validate() if err != nil { validationErrors = append(validationErrors, err) } } if len(validationErrors) == 0 { return nil } return errors.Errorf("snap.Service validation failed %v", validationErrors) }
go
func (s Service) Validate() error { var validationErrors = []error{} err := s.app.Validate() if err != nil { validationErrors = append(validationErrors, err) } for _, prerequisite := range s.app.Prerequisites { err = prerequisite.Validate() if err != nil { validationErrors = append(validationErrors, err) } } if len(validationErrors) == 0 { return nil } return errors.Errorf("snap.Service validation failed %v", validationErrors) }
[ "func", "(", "s", "Service", ")", "Validate", "(", ")", "error", "{", "var", "validationErrors", "=", "[", "]", "error", "{", "}", "\n\n", "err", ":=", "s", ".", "app", ".", "Validate", "(", ")", "\n", "if", "err", "!=", "nil", "{", "validationErro...
// Validate validates that snap.Service has been correctly configured. // Validate returns nil when successful and an error when successful.
[ "Validate", "validates", "that", "snap", ".", "Service", "has", "been", "correctly", "configured", ".", "Validate", "returns", "nil", "when", "successful", "and", "an", "error", "when", "successful", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L255-L275
153,806
juju/juju
service/snap/snap.go
Install
func (s Service) Install() error { commands, err := s.InstallCommands() if err != nil { return errors.Trace(err) } for _, cmd := range commands { if cmd == "" { continue } logger.Infof("command: %v", cmd) cmdParts := strings.Fields(cmd) executable := cmdParts[0] args := cmdParts[1:] out, err := utils.RunCommand(executable, args...) if err != nil { return errors.Annotatef(err, "output: %v", out) } } return nil }
go
func (s Service) Install() error { commands, err := s.InstallCommands() if err != nil { return errors.Trace(err) } for _, cmd := range commands { if cmd == "" { continue } logger.Infof("command: %v", cmd) cmdParts := strings.Fields(cmd) executable := cmdParts[0] args := cmdParts[1:] out, err := utils.RunCommand(executable, args...) if err != nil { return errors.Annotatef(err, "output: %v", out) } } return nil }
[ "func", "(", "s", "Service", ")", "Install", "(", ")", "error", "{", "commands", ",", "err", ":=", "s", ".", "InstallCommands", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "fo...
// Install installs the snap and its background services. // // Install is part of the service.Service interface.
[ "Install", "installs", "the", "snap", "and", "its", "background", "services", ".", "Install", "is", "part", "of", "the", "service", ".", "Service", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L316-L336
153,807
juju/juju
service/snap/snap.go
Installed
func (s Service) Installed() (bool, error) { installed, _, _, err := s.status() if err != nil { return false, errors.Trace(err) } return installed, nil }
go
func (s Service) Installed() (bool, error) { installed, _, _, err := s.status() if err != nil { return false, errors.Trace(err) } return installed, nil }
[ "func", "(", "s", "Service", ")", "Installed", "(", ")", "(", "bool", ",", "error", ")", "{", "installed", ",", "_", ",", "_", ",", "err", ":=", "s", ".", "status", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "errors"...
// Installed returns true if the service has been successfully installed. // // Installed is part of the service.Service interface.
[ "Installed", "returns", "true", "if", "the", "service", "has", "been", "successfully", "installed", ".", "Installed", "is", "part", "of", "the", "service", ".", "Service", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L341-L347
153,808
juju/juju
service/snap/snap.go
InstallCommands
func (s Service) InstallCommands() ([]string, error) { commands := make([]string, 0, 1+len(s.app.Prerequisites)) confinementPolicy := confimentParameterAsString(s.app.ConfinementPolicy) for _, prerequisite := range s.app.Prerequisites { command := fmt.Sprintf("%v install --channel=%v %v %v", s.executable, prerequisite.Channel, confinementPolicy, prerequisite.Name, ) logger.Infof("preparing command: %v", command) commands = append(commands, command) } command := fmt.Sprintf("%v install --channel=%v %v %v", s.executable, s.app.Channel, confinementPolicy, s.app.Name, ) logger.Infof("preparing command: %v", command) commands = append(commands, command) return commands, nil }
go
func (s Service) InstallCommands() ([]string, error) { commands := make([]string, 0, 1+len(s.app.Prerequisites)) confinementPolicy := confimentParameterAsString(s.app.ConfinementPolicy) for _, prerequisite := range s.app.Prerequisites { command := fmt.Sprintf("%v install --channel=%v %v %v", s.executable, prerequisite.Channel, confinementPolicy, prerequisite.Name, ) logger.Infof("preparing command: %v", command) commands = append(commands, command) } command := fmt.Sprintf("%v install --channel=%v %v %v", s.executable, s.app.Channel, confinementPolicy, s.app.Name, ) logger.Infof("preparing command: %v", command) commands = append(commands, command) return commands, nil }
[ "func", "(", "s", "Service", ")", "InstallCommands", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "commands", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "1", "+", "len", "(", "s", ".", "app", ".", "Prerequisites", ")", ...
// InstallCommands returns a slice of shell commands that is // executed independently, in serial, by a shell. When the // final command returns with a 0 exit code, the installation // will be deemed to have been successful. // // InstallCommands is part of the service.Service interface
[ "InstallCommands", "returns", "a", "slice", "of", "shell", "commands", "that", "is", "executed", "independently", "in", "serial", "by", "a", "shell", ".", "When", "the", "final", "command", "returns", "with", "a", "0", "exit", "code", "the", "installation", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L355-L379
153,809
juju/juju
service/snap/snap.go
StartCommands
func (s Service) StartCommands() ([]string, error) { commands := make([]string, 0, 1+len(s.app.Prerequisites)) for _, prerequisite := range s.app.Prerequisites { commands = append(commands, prerequisite.StartCommands(s.executable)...) } commands = append(commands, s.app.StartCommands(s.executable)...) return commands, nil }
go
func (s Service) StartCommands() ([]string, error) { commands := make([]string, 0, 1+len(s.app.Prerequisites)) for _, prerequisite := range s.app.Prerequisites { commands = append(commands, prerequisite.StartCommands(s.executable)...) } commands = append(commands, s.app.StartCommands(s.executable)...) return commands, nil }
[ "func", "(", "s", "Service", ")", "StartCommands", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "commands", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "1", "+", "len", "(", "s", ".", "app", ".", "Prerequisites", ")", ")...
// StartCommands returns a slice of strings. that are // shell commands to be executed by a shell which start the service.
[ "StartCommands", "returns", "a", "slice", "of", "strings", ".", "that", "are", "shell", "commands", "to", "be", "executed", "by", "a", "shell", "which", "start", "the", "service", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L390-L397
153,810
juju/juju
service/snap/snap.go
Start
func (s Service) Start() error { running, err := s.Running() if err != nil { return errors.Trace(err) } if running { return nil } commands, err := s.StartCommands() if err != nil { return errors.Trace(err) } for _, command := range commands { commandParts := strings.Fields(command) out, err := utils.RunCommand(commandParts[0], commandParts[1:]...) if err != nil { if strings.Contains(out, "has no services") { continue } return errors.Annotatef(err, "%v -> %v", command, out) } } return nil }
go
func (s Service) Start() error { running, err := s.Running() if err != nil { return errors.Trace(err) } if running { return nil } commands, err := s.StartCommands() if err != nil { return errors.Trace(err) } for _, command := range commands { commandParts := strings.Fields(command) out, err := utils.RunCommand(commandParts[0], commandParts[1:]...) if err != nil { if strings.Contains(out, "has no services") { continue } return errors.Annotatef(err, "%v -> %v", command, out) } } return nil }
[ "func", "(", "s", "Service", ")", "Start", "(", ")", "error", "{", "running", ",", "err", ":=", "s", ".", "Running", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "runni...
// Start starts the service, returning nil when successful. // If the service is already running, Start does not restart it. // // Start is part of the service.ServiceActions interface
[ "Start", "starts", "the", "service", "returning", "nil", "when", "successful", ".", "If", "the", "service", "is", "already", "running", "Start", "does", "not", "restart", "it", ".", "Start", "is", "part", "of", "the", "service", ".", "ServiceActions", "inter...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L429-L454
153,811
juju/juju
service/snap/snap.go
Restart
func (s *Service) Restart() error { args := []string{"restart", s.Name()} return s.execThenExpect(args, "Restarted.") }
go
func (s *Service) Restart() error { args := []string{"restart", s.Name()} return s.execThenExpect(args, "Restarted.") }
[ "func", "(", "s", "*", "Service", ")", "Restart", "(", ")", "error", "{", "args", ":=", "[", "]", "string", "{", "\"", "\"", ",", "s", ".", "Name", "(", ")", "}", "\n", "return", "s", ".", "execThenExpect", "(", "args", ",", "\"", "\"", ")", ...
// Restart restarts the service, or starts if it's not currently // running. // // Restart is part of the service.RestartableService interface
[ "Restart", "restarts", "the", "service", "or", "starts", "if", "it", "s", "not", "currently", "running", ".", "Restart", "is", "part", "of", "the", "service", ".", "RestartableService", "interface" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/snap/snap.go#L491-L494
153,812
juju/juju
worker/lease/manager.go
NewDeadManager
func NewDeadManager(err error) *Manager { var secretary dummySecretary m := Manager{ config: ManagerConfig{ Secretary: func(_ string) (Secretary, error) { return secretary, nil }, }, } _ = catacomb.Invoke(catacomb.Plan{ Site: &m.catacomb, Work: func() error { return errors.Trace(err) }, }) return &m }
go
func NewDeadManager(err error) *Manager { var secretary dummySecretary m := Manager{ config: ManagerConfig{ Secretary: func(_ string) (Secretary, error) { return secretary, nil }, }, } _ = catacomb.Invoke(catacomb.Plan{ Site: &m.catacomb, Work: func() error { return errors.Trace(err) }, }) return &m }
[ "func", "NewDeadManager", "(", "err", "error", ")", "*", "Manager", "{", "var", "secretary", "dummySecretary", "\n", "m", ":=", "Manager", "{", "config", ":", "ManagerConfig", "{", "Secretary", ":", "func", "(", "_", "string", ")", "(", "Secretary", ",", ...
// NewDeadManager returns a manager that's already dead // and always returns the given error.
[ "NewDeadManager", "returns", "a", "manager", "that", "s", "already", "dead", "and", "always", "returns", "the", "given", "error", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L48-L64
153,813
juju/juju
worker/lease/manager.go
loop
func (manager *Manager) loop() error { if collector, ok := manager.config.Store.(prometheus.Collector); ok && manager.config.PrometheusRegisterer != nil { // The store implements the collector interface, but the lease.Store // does not expose those. _ = manager.config.PrometheusRegisterer.Register(collector) defer manager.config.PrometheusRegisterer.Unregister(collector) } defer manager.wg.Wait() blocks := make(blocks) manager.setupInitialTimer() for { if err := manager.choose(blocks); err != nil { manager.config.Logger.Tracef("[%s] exiting main loop with error: %v", manager.logContext, err) return errors.Trace(err) } } }
go
func (manager *Manager) loop() error { if collector, ok := manager.config.Store.(prometheus.Collector); ok && manager.config.PrometheusRegisterer != nil { // The store implements the collector interface, but the lease.Store // does not expose those. _ = manager.config.PrometheusRegisterer.Register(collector) defer manager.config.PrometheusRegisterer.Unregister(collector) } defer manager.wg.Wait() blocks := make(blocks) manager.setupInitialTimer() for { if err := manager.choose(blocks); err != nil { manager.config.Logger.Tracef("[%s] exiting main loop with error: %v", manager.logContext, err) return errors.Trace(err) } } }
[ "func", "(", "manager", "*", "Manager", ")", "loop", "(", ")", "error", "{", "if", "collector", ",", "ok", ":=", "manager", ".", "config", ".", "Store", ".", "(", "prometheus", ".", "Collector", ")", ";", "ok", "&&", "manager", ".", "config", ".", ...
// loop runs until the manager is stopped.
[ "loop", "runs", "until", "the", "manager", "is", "stopped", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L153-L170
153,814
juju/juju
worker/lease/manager.go
choose
func (manager *Manager) choose(blocks blocks) error { select { case <-manager.catacomb.Dying(): return manager.catacomb.ErrDying() case check := <-manager.checks: return manager.handleCheck(check) case now := <-manager.timer.Chan(): manager.tick(now, blocks) case <-manager.expireDone: manager.checkBlocks(blocks) case claim := <-manager.claims: manager.wg.Add(1) go manager.retryingClaim(claim) case pin := <-manager.pins: manager.handlePin(pin) case unpin := <-manager.unpins: manager.handleUnpin(unpin) case block := <-manager.blocks: // TODO(raftlease): Include the other key items. manager.config.Logger.Tracef("[%s] adding block for: %s", manager.logContext, block.leaseKey.Lease) blocks.add(block) if _, exists := manager.lookupLease(block.leaseKey); !exists { // Nobody holds this lease, so immediately unblock it. blocks.unblock(block.leaseKey) } } return nil }
go
func (manager *Manager) choose(blocks blocks) error { select { case <-manager.catacomb.Dying(): return manager.catacomb.ErrDying() case check := <-manager.checks: return manager.handleCheck(check) case now := <-manager.timer.Chan(): manager.tick(now, blocks) case <-manager.expireDone: manager.checkBlocks(blocks) case claim := <-manager.claims: manager.wg.Add(1) go manager.retryingClaim(claim) case pin := <-manager.pins: manager.handlePin(pin) case unpin := <-manager.unpins: manager.handleUnpin(unpin) case block := <-manager.blocks: // TODO(raftlease): Include the other key items. manager.config.Logger.Tracef("[%s] adding block for: %s", manager.logContext, block.leaseKey.Lease) blocks.add(block) if _, exists := manager.lookupLease(block.leaseKey); !exists { // Nobody holds this lease, so immediately unblock it. blocks.unblock(block.leaseKey) } } return nil }
[ "func", "(", "manager", "*", "Manager", ")", "choose", "(", "blocks", "blocks", ")", "error", "{", "select", "{", "case", "<-", "manager", ".", "catacomb", ".", "Dying", "(", ")", ":", "return", "manager", ".", "catacomb", ".", "ErrDying", "(", ")", ...
// choose breaks the select out of loop to make the blocking logic clearer.
[ "choose", "breaks", "the", "select", "out", "of", "loop", "to", "make", "the", "blocking", "logic", "clearer", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L178-L206
153,815
juju/juju
worker/lease/manager.go
Checker
func (manager *Manager) Checker(namespace, modelUUID string) (lease.Checker, error) { return manager.bind(namespace, modelUUID) }
go
func (manager *Manager) Checker(namespace, modelUUID string) (lease.Checker, error) { return manager.bind(namespace, modelUUID) }
[ "func", "(", "manager", "*", "Manager", ")", "Checker", "(", "namespace", ",", "modelUUID", "string", ")", "(", "lease", ".", "Checker", ",", "error", ")", "{", "return", "manager", ".", "bind", "(", "namespace", ",", "modelUUID", ")", "\n", "}" ]
// Checker returns a lease.Checker for the specified namespace and model.
[ "Checker", "returns", "a", "lease", ".", "Checker", "for", "the", "specified", "namespace", "and", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L222-L224
153,816
juju/juju
worker/lease/manager.go
retryingClaim
func (manager *Manager) retryingClaim(claim claim) { defer manager.wg.Done() var ( err error success bool ) for a := manager.startRetry(); a.Next(); { success, err = manager.handleClaim(claim) if !lease.IsTimeout(err) && !lease.IsInvalid(err) { break } if a.More() { if lease.IsInvalid(err) { manager.config.Logger.Tracef("[%s] request by %s for lease %s %v, retrying...", manager.logContext, claim.holderName, claim.leaseKey.Lease, err) } else { manager.config.Logger.Tracef("[%s] timed out handling claim by %s for lease %s, retrying...", manager.logContext, claim.holderName, claim.leaseKey.Lease) } } } if err == nil { if !success { claim.respond(lease.ErrClaimDenied) return } // now, this isn't strictly true, as the lease can be given for longer // than the requested duration. However, it cannot be shorter. // Doing it this way, we'll wake up, and then see we can sleep // for a bit longer. But we'll always wake up in time. manager.ensureNextTimeout(claim.duration) // respond after ensuring the timeout, at least for the test suite to be sure // the timer has been updated by the time it gets Claim() to return. claim.respond(nil) } else { switch { case lease.IsTimeout(err): claim.respond(lease.ErrTimeout) manager.config.Logger.Warningf("[%s] retrying timed out while handling claim %q for %q", manager.logContext, claim.leaseKey, claim.holderName) case lease.IsInvalid(err): // we want to see this, but it doesn't indicate something a user can do something about manager.config.Logger.Infof("[%s] got %v after %d retries, denying claim %q for %q", manager.logContext, err, maxRetries, claim.leaseKey, claim.holderName) claim.respond(lease.ErrClaimDenied) default: // Stop the main loop because we got an abnormal error manager.catacomb.Kill(errors.Trace(err)) } } }
go
func (manager *Manager) retryingClaim(claim claim) { defer manager.wg.Done() var ( err error success bool ) for a := manager.startRetry(); a.Next(); { success, err = manager.handleClaim(claim) if !lease.IsTimeout(err) && !lease.IsInvalid(err) { break } if a.More() { if lease.IsInvalid(err) { manager.config.Logger.Tracef("[%s] request by %s for lease %s %v, retrying...", manager.logContext, claim.holderName, claim.leaseKey.Lease, err) } else { manager.config.Logger.Tracef("[%s] timed out handling claim by %s for lease %s, retrying...", manager.logContext, claim.holderName, claim.leaseKey.Lease) } } } if err == nil { if !success { claim.respond(lease.ErrClaimDenied) return } // now, this isn't strictly true, as the lease can be given for longer // than the requested duration. However, it cannot be shorter. // Doing it this way, we'll wake up, and then see we can sleep // for a bit longer. But we'll always wake up in time. manager.ensureNextTimeout(claim.duration) // respond after ensuring the timeout, at least for the test suite to be sure // the timer has been updated by the time it gets Claim() to return. claim.respond(nil) } else { switch { case lease.IsTimeout(err): claim.respond(lease.ErrTimeout) manager.config.Logger.Warningf("[%s] retrying timed out while handling claim %q for %q", manager.logContext, claim.leaseKey, claim.holderName) case lease.IsInvalid(err): // we want to see this, but it doesn't indicate something a user can do something about manager.config.Logger.Infof("[%s] got %v after %d retries, denying claim %q for %q", manager.logContext, err, maxRetries, claim.leaseKey, claim.holderName) claim.respond(lease.ErrClaimDenied) default: // Stop the main loop because we got an abnormal error manager.catacomb.Kill(errors.Trace(err)) } } }
[ "func", "(", "manager", "*", "Manager", ")", "retryingClaim", "(", "claim", "claim", ")", "{", "defer", "manager", ".", "wg", ".", "Done", "(", ")", "\n", "var", "(", "err", "error", "\n", "success", "bool", "\n", ")", "\n", "for", "a", ":=", "mana...
// retryingClaim handles timeouts when claiming, and responds to the // claiming party when it eventually succeeds or fails, or if it times // out after a number of retries.
[ "retryingClaim", "handles", "timeouts", "when", "claiming", "and", "responds", "to", "the", "claiming", "party", "when", "it", "eventually", "succeeds", "or", "fails", "or", "if", "it", "times", "out", "after", "a", "number", "of", "retries", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L244-L295
153,817
juju/juju
worker/lease/manager.go
handleCheck
func (manager *Manager) handleCheck(check check) error { key := check.leaseKey store := manager.config.Store manager.config.Logger.Tracef("[%s] handling Check for lease %s on behalf of %s", manager.logContext, key.Lease, check.holderName) info, found := manager.lookupLease(key) if !found || info.Holder != check.holderName { // TODO(jam): 2019-02-05 Currently raftlease.Store.Refresh does nothing. // We probably shouldn't have this refresh-and-try-again if it is going to be a no-op. // Instead we should probably just report failure. if found { manager.config.Logger.Tracef("[%s] handling Check for lease %s on behalf of %s, found held by %s, refreshing", manager.logContext, key.Lease, check.holderName, info.Holder) } else { manager.config.Logger.Tracef("[%s] handling Check for lease %s on behalf of %s, not found, refreshing", manager.logContext, key.Lease, check.holderName) } if err := store.Refresh(); err != nil { return errors.Trace(err) } info, found = manager.lookupLease(key) if !found { // Someone thought they were the leader and held a Claim or they wouldn't // have tried to do a mutating operation. However, when they actually // got to this point, we detected that they were, actually, out of // date. Schedule a sync manager.ensureNextTimeout(time.Millisecond) } } var response error if !found || info.Holder != check.holderName { manager.config.Logger.Tracef("[%s] handling Check for lease %s on behalf of %s, not held", manager.logContext, key.Lease, check.holderName) response = lease.ErrNotHeld } else if check.trapdoorKey != nil { response = info.Trapdoor(check.attempt, check.trapdoorKey) } check.respond(errors.Trace(response)) return nil }
go
func (manager *Manager) handleCheck(check check) error { key := check.leaseKey store := manager.config.Store manager.config.Logger.Tracef("[%s] handling Check for lease %s on behalf of %s", manager.logContext, key.Lease, check.holderName) info, found := manager.lookupLease(key) if !found || info.Holder != check.holderName { // TODO(jam): 2019-02-05 Currently raftlease.Store.Refresh does nothing. // We probably shouldn't have this refresh-and-try-again if it is going to be a no-op. // Instead we should probably just report failure. if found { manager.config.Logger.Tracef("[%s] handling Check for lease %s on behalf of %s, found held by %s, refreshing", manager.logContext, key.Lease, check.holderName, info.Holder) } else { manager.config.Logger.Tracef("[%s] handling Check for lease %s on behalf of %s, not found, refreshing", manager.logContext, key.Lease, check.holderName) } if err := store.Refresh(); err != nil { return errors.Trace(err) } info, found = manager.lookupLease(key) if !found { // Someone thought they were the leader and held a Claim or they wouldn't // have tried to do a mutating operation. However, when they actually // got to this point, we detected that they were, actually, out of // date. Schedule a sync manager.ensureNextTimeout(time.Millisecond) } } var response error if !found || info.Holder != check.holderName { manager.config.Logger.Tracef("[%s] handling Check for lease %s on behalf of %s, not held", manager.logContext, key.Lease, check.holderName) response = lease.ErrNotHeld } else if check.trapdoorKey != nil { response = info.Trapdoor(check.attempt, check.trapdoorKey) } check.respond(errors.Trace(response)) return nil }
[ "func", "(", "manager", "*", "Manager", ")", "handleCheck", "(", "check", "check", ")", "error", "{", "key", ":=", "check", ".", "leaseKey", "\n", "store", ":=", "manager", ".", "config", ".", "Store", "\n", "manager", ".", "config", ".", "Logger", "."...
// handleCheck processes and responds to the supplied check. It will only return // unrecoverable errors; mere untruth of the assertion just indicates a bad // request, and is communicated back to the check's originator.
[ "handleCheck", "processes", "and", "responds", "to", "the", "supplied", "check", ".", "It", "will", "only", "return", "unrecoverable", "errors", ";", "mere", "untruth", "of", "the", "assertion", "just", "indicates", "a", "bad", "request", "and", "is", "communi...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L344-L385
153,818
juju/juju
worker/lease/manager.go
tick
func (manager *Manager) tick(now time.Time, blocks blocks) { manager.config.Logger.Tracef("[%s] tick at %v, running expiry checks\n", manager.logContext, now) // If we need to expire leases we should do it, otherwise this // is just an opportunity to check for blocks that need to be // notified. if !manager.config.Store.Autoexpire() { manager.wg.Add(1) go manager.retryingExpire(now) // We wait for manager.retryingExpire to finish before we checkBlocks } else { manager.checkBlocks(blocks) } }
go
func (manager *Manager) tick(now time.Time, blocks blocks) { manager.config.Logger.Tracef("[%s] tick at %v, running expiry checks\n", manager.logContext, now) // If we need to expire leases we should do it, otherwise this // is just an opportunity to check for blocks that need to be // notified. if !manager.config.Store.Autoexpire() { manager.wg.Add(1) go manager.retryingExpire(now) // We wait for manager.retryingExpire to finish before we checkBlocks } else { manager.checkBlocks(blocks) } }
[ "func", "(", "manager", "*", "Manager", ")", "tick", "(", "now", "time", ".", "Time", ",", "blocks", "blocks", ")", "{", "manager", ".", "config", ".", "Logger", ".", "Tracef", "(", "\"", "\\n", "\"", ",", "manager", ".", "logContext", ",", "now", ...
// tick triggers when we think a lease might be expiring, so we check if there // are leases to expire, and then unblock anything that is no longer blocked, // and then compute the next time we should wake up.
[ "tick", "triggers", "when", "we", "think", "a", "lease", "might", "be", "expiring", "so", "we", "check", "if", "there", "are", "leases", "to", "expire", "and", "then", "unblock", "anything", "that", "is", "no", "longer", "blocked", "and", "then", "compute"...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L390-L402
153,819
juju/juju
worker/lease/manager.go
computeNextTimeout
func (manager *Manager) computeNextTimeout(lastTick time.Time, leases map[lease.Key]lease.Info) { now := manager.config.Clock.Now() nextTick := now.Add(manager.config.MaxSleep) for _, info := range leases { if !info.Expiry.After(lastTick) { // The previous expire will expire this lease eventually, or // the manager will die with an error. Either way, we // don't need to worry about expiries in a previous expire // here. continue } if info.Expiry.After(nextTick) { continue } nextTick = info.Expiry } manager.config.Logger.Tracef("[%s] next expire in %v %v", manager.logContext, nextTick.Sub(now).Round(time.Millisecond), nextTick) manager.setNextTimeout(nextTick) }
go
func (manager *Manager) computeNextTimeout(lastTick time.Time, leases map[lease.Key]lease.Info) { now := manager.config.Clock.Now() nextTick := now.Add(manager.config.MaxSleep) for _, info := range leases { if !info.Expiry.After(lastTick) { // The previous expire will expire this lease eventually, or // the manager will die with an error. Either way, we // don't need to worry about expiries in a previous expire // here. continue } if info.Expiry.After(nextTick) { continue } nextTick = info.Expiry } manager.config.Logger.Tracef("[%s] next expire in %v %v", manager.logContext, nextTick.Sub(now).Round(time.Millisecond), nextTick) manager.setNextTimeout(nextTick) }
[ "func", "(", "manager", "*", "Manager", ")", "computeNextTimeout", "(", "lastTick", "time", ".", "Time", ",", "leases", "map", "[", "lease", ".", "Key", "]", "lease", ".", "Info", ")", "{", "now", ":=", "manager", ".", "config", ".", "Clock", ".", "N...
// computeNextTimeout iterates the leases and finds out what the next time we // want to wake up, expire any leases and then handle any unblocks that happen. // It is based on the MaxSleep time, and on any expire that is going to expire // after now but before MaxSleep. // it's worth checking for stalled collaborators.
[ "computeNextTimeout", "iterates", "the", "leases", "and", "finds", "out", "what", "the", "next", "time", "we", "want", "to", "wake", "up", "expire", "any", "leases", "and", "then", "handle", "any", "unblocks", "that", "happen", ".", "It", "is", "based", "o...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L422-L441
153,820
juju/juju
worker/lease/manager.go
ensureNextTimeout
func (manager *Manager) ensureNextTimeout(d time.Duration) { manager.muNextTimeout.Lock() next := manager.nextTimeout proposed := manager.config.Clock.Now().Add(d) if next.After(proposed) { manager.config.Logger.Tracef("[%s] ensuring we wake up before %v at %v\n", manager.logContext, d, proposed) manager.nextTimeout = proposed manager.timer.Reset(d) } manager.muNextTimeout.Unlock() }
go
func (manager *Manager) ensureNextTimeout(d time.Duration) { manager.muNextTimeout.Lock() next := manager.nextTimeout proposed := manager.config.Clock.Now().Add(d) if next.After(proposed) { manager.config.Logger.Tracef("[%s] ensuring we wake up before %v at %v\n", manager.logContext, d, proposed) manager.nextTimeout = proposed manager.timer.Reset(d) } manager.muNextTimeout.Unlock() }
[ "func", "(", "manager", "*", "Manager", ")", "ensureNextTimeout", "(", "d", "time", ".", "Duration", ")", "{", "manager", ".", "muNextTimeout", ".", "Lock", "(", ")", "\n", "next", ":=", "manager", ".", "nextTimeout", "\n", "proposed", ":=", "manager", "...
// ensureNextTimeout makes sure that the next timeout happens no-later than // duration from now.
[ "ensureNextTimeout", "makes", "sure", "that", "the", "next", "timeout", "happens", "no", "-", "later", "than", "duration", "from", "now", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L473-L484
153,821
juju/juju
worker/lease/manager.go
retryingExpire
func (manager *Manager) retryingExpire(now time.Time) { manager.config.Logger.Tracef("[%s] expire looking for leases to expire\n", manager.logContext) defer manager.wg.Done() var err error for a := manager.startRetry(); a.Next(); { err = manager.expire(now) if !lease.IsTimeout(err) { break } if a.More() { manager.config.Logger.Tracef("[%s] timed out during expire, retrying...", manager.logContext) } } // Don't bother sending an error if we're dying - this avoids a // race in the tests. select { case <-manager.catacomb.Dying(): manager.config.Logger.Tracef("[%s] expire exiting early do to manager shutdown", manager.logContext) return default: } if lease.IsTimeout(err) { // We don't crash on timeouts to avoid bouncing the API server. manager.config.Logger.Warningf("[%s] retrying timed out in expire", manager.logContext) return } if err != nil { manager.catacomb.Kill(errors.Trace(err)) } else { // If we send back an error, then the main loop won't listen for expireDone select { case <-manager.catacomb.Dying(): return case manager.expireDone <- struct{}{}: } } }
go
func (manager *Manager) retryingExpire(now time.Time) { manager.config.Logger.Tracef("[%s] expire looking for leases to expire\n", manager.logContext) defer manager.wg.Done() var err error for a := manager.startRetry(); a.Next(); { err = manager.expire(now) if !lease.IsTimeout(err) { break } if a.More() { manager.config.Logger.Tracef("[%s] timed out during expire, retrying...", manager.logContext) } } // Don't bother sending an error if we're dying - this avoids a // race in the tests. select { case <-manager.catacomb.Dying(): manager.config.Logger.Tracef("[%s] expire exiting early do to manager shutdown", manager.logContext) return default: } if lease.IsTimeout(err) { // We don't crash on timeouts to avoid bouncing the API server. manager.config.Logger.Warningf("[%s] retrying timed out in expire", manager.logContext) return } if err != nil { manager.catacomb.Kill(errors.Trace(err)) } else { // If we send back an error, then the main loop won't listen for expireDone select { case <-manager.catacomb.Dying(): return case manager.expireDone <- struct{}{}: } } }
[ "func", "(", "manager", "*", "Manager", ")", "retryingExpire", "(", "now", "time", ".", "Time", ")", "{", "manager", ".", "config", ".", "Logger", ".", "Tracef", "(", "\"", "\\n", "\"", ",", "manager", ".", "logContext", ")", "\n", "defer", "manager", ...
// retryingExpire runs expire and retries any timeouts.
[ "retryingExpire", "runs", "expire", "and", "retries", "any", "timeouts", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/lease/manager.go#L487-L524
153,822
juju/juju
state/relationnetworks.go
Save
func (rin *relationNetworksState) Save(relationKey string, adminOverride bool, cidrs []string) (RelationNetworks, error) { logger.Debugf("save %v networks for %v: %v", rin.direction, relationKey, cidrs) for _, cidr := range cidrs { if _, _, err := net.ParseCIDR(cidr); err != nil { return nil, errors.NotValidf("CIDR %q", cidr) } } label := relationNetworkDefault if adminOverride { label = relationNetworkAdmin } doc := relationNetworksDoc{ Id: rin.st.docID(relationNetworkDocID(relationKey, rin.direction, label)), RelationKey: relationKey, CIDRS: cidrs, } buildTxn := func(int) ([]txn.Op, error) { model, err := rin.st.Model() if err != nil { return nil, errors.Annotate(err, "failed to load model") } if err := checkModelActive(rin.st); err != nil { return nil, errors.Trace(err) } if _, err := rin.st.KeyRelation(relationKey); err != nil { return nil, errors.Trace(err) } relationExistsAssert := txn.Op{ C: relationsC, Id: rin.st.docID(relationKey), Assert: txn.DocExists, } existing, err := rin.Networks(relationKey) if err != nil && !errors.IsNotFound(err) { return nil, errors.Trace(err) } var ops []txn.Op if err == nil { ops = []txn.Op{{ C: relationNetworksC, Id: existing.Id(), Assert: txn.DocExists, Update: bson.D{ {"$set", bson.D{{"cidrs", cidrs}}}, }, }, model.assertActiveOp(), relationExistsAssert} } else { doc.CIDRS = cidrs ops = []txn.Op{{ C: relationNetworksC, Id: doc.Id, Assert: txn.DocMissing, Insert: doc, }, model.assertActiveOp(), relationExistsAssert} } return ops, nil } if err := rin.st.db().Run(buildTxn); err != nil { return nil, errors.Annotatef(err, "failed to create relation %v networks", rin.direction) } return &relationNetworks{ st: rin.st, doc: doc, }, nil }
go
func (rin *relationNetworksState) Save(relationKey string, adminOverride bool, cidrs []string) (RelationNetworks, error) { logger.Debugf("save %v networks for %v: %v", rin.direction, relationKey, cidrs) for _, cidr := range cidrs { if _, _, err := net.ParseCIDR(cidr); err != nil { return nil, errors.NotValidf("CIDR %q", cidr) } } label := relationNetworkDefault if adminOverride { label = relationNetworkAdmin } doc := relationNetworksDoc{ Id: rin.st.docID(relationNetworkDocID(relationKey, rin.direction, label)), RelationKey: relationKey, CIDRS: cidrs, } buildTxn := func(int) ([]txn.Op, error) { model, err := rin.st.Model() if err != nil { return nil, errors.Annotate(err, "failed to load model") } if err := checkModelActive(rin.st); err != nil { return nil, errors.Trace(err) } if _, err := rin.st.KeyRelation(relationKey); err != nil { return nil, errors.Trace(err) } relationExistsAssert := txn.Op{ C: relationsC, Id: rin.st.docID(relationKey), Assert: txn.DocExists, } existing, err := rin.Networks(relationKey) if err != nil && !errors.IsNotFound(err) { return nil, errors.Trace(err) } var ops []txn.Op if err == nil { ops = []txn.Op{{ C: relationNetworksC, Id: existing.Id(), Assert: txn.DocExists, Update: bson.D{ {"$set", bson.D{{"cidrs", cidrs}}}, }, }, model.assertActiveOp(), relationExistsAssert} } else { doc.CIDRS = cidrs ops = []txn.Op{{ C: relationNetworksC, Id: doc.Id, Assert: txn.DocMissing, Insert: doc, }, model.assertActiveOp(), relationExistsAssert} } return ops, nil } if err := rin.st.db().Run(buildTxn); err != nil { return nil, errors.Annotatef(err, "failed to create relation %v networks", rin.direction) } return &relationNetworks{ st: rin.st, doc: doc, }, nil }
[ "func", "(", "rin", "*", "relationNetworksState", ")", "Save", "(", "relationKey", "string", ",", "adminOverride", "bool", ",", "cidrs", "[", "]", "string", ")", "(", "RelationNetworks", ",", "error", ")", "{", "logger", ".", "Debugf", "(", "\"", "\"", "...
// Save stores the specified networks for the relation.
[ "Save", "stores", "the", "specified", "networks", "for", "the", "relation", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationnetworks.go#L96-L163
153,823
juju/juju
state/relationnetworks.go
Networks
func (rin *relationNetworksState) Networks(relationKey string) (RelationNetworks, error) { coll, closer := rin.st.db().GetCollection(relationNetworksC) defer closer() var doc relationNetworksDoc err := coll.FindId(relationNetworkDocID(relationKey, rin.direction, relationNetworkAdmin)).One(&doc) if err == mgo.ErrNotFound { err = coll.FindId(relationNetworkDocID(relationKey, rin.direction, relationNetworkDefault)).One(&doc) } if err == mgo.ErrNotFound { return nil, errors.NotFoundf("%v networks for relation %v", rin.direction, relationKey) } if err != nil { return nil, errors.Trace(err) } return &relationNetworks{ st: rin.st, doc: doc, }, nil }
go
func (rin *relationNetworksState) Networks(relationKey string) (RelationNetworks, error) { coll, closer := rin.st.db().GetCollection(relationNetworksC) defer closer() var doc relationNetworksDoc err := coll.FindId(relationNetworkDocID(relationKey, rin.direction, relationNetworkAdmin)).One(&doc) if err == mgo.ErrNotFound { err = coll.FindId(relationNetworkDocID(relationKey, rin.direction, relationNetworkDefault)).One(&doc) } if err == mgo.ErrNotFound { return nil, errors.NotFoundf("%v networks for relation %v", rin.direction, relationKey) } if err != nil { return nil, errors.Trace(err) } return &relationNetworks{ st: rin.st, doc: doc, }, nil }
[ "func", "(", "rin", "*", "relationNetworksState", ")", "Networks", "(", "relationKey", "string", ")", "(", "RelationNetworks", ",", "error", ")", "{", "coll", ",", "closer", ":=", "rin", ".", "st", ".", "db", "(", ")", ".", "GetCollection", "(", "relatio...
// Networks returns the networks for the specified relation.
[ "Networks", "returns", "the", "networks", "for", "the", "specified", "relation", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationnetworks.go#L166-L185
153,824
juju/juju
provider/maas/maas2instance.go
OpenPorts
func (mi *maas2Instance) OpenPorts(ctx context.ProviderCallContext, machineId string, rules []network.IngressRule) error { logger.Debugf("unimplemented OpenPorts() called") return nil }
go
func (mi *maas2Instance) OpenPorts(ctx context.ProviderCallContext, machineId string, rules []network.IngressRule) error { logger.Debugf("unimplemented OpenPorts() called") return nil }
[ "func", "(", "mi", "*", "maas2Instance", ")", "OpenPorts", "(", "ctx", "context", ".", "ProviderCallContext", ",", "machineId", "string", ",", "rules", "[", "]", "network", ".", "IngressRule", ")", "error", "{", "logger", ".", "Debugf", "(", "\"", "\"", ...
// MAAS does not do firewalling so these port methods do nothing.
[ "MAAS", "does", "not", "do", "firewalling", "so", "these", "port", "methods", "do", "nothing", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/maas/maas2instance.go#L104-L107
153,825
juju/juju
state/mocks/clock_mock.go
NewMockClock
func NewMockClock(ctrl *gomock.Controller) *MockClock { mock := &MockClock{ctrl: ctrl} mock.recorder = &MockClockMockRecorder{mock} return mock }
go
func NewMockClock(ctrl *gomock.Controller) *MockClock { mock := &MockClock{ctrl: ctrl} mock.recorder = &MockClockMockRecorder{mock} return mock }
[ "func", "NewMockClock", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockClock", "{", "mock", ":=", "&", "MockClock", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockClockMockRecorder", "{", "mock", "}", "\n", ...
// NewMockClock creates a new mock instance
[ "NewMockClock", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/mocks/clock_mock.go#L26-L30
153,826
juju/juju
state/mocks/clock_mock.go
After
func (mr *MockClockMockRecorder) After(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "After", reflect.TypeOf((*MockClock)(nil).After), arg0) }
go
func (mr *MockClockMockRecorder) After(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "After", reflect.TypeOf((*MockClock)(nil).After), arg0) }
[ "func", "(", "mr", "*", "MockClockMockRecorder", ")", "After", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"",...
// After indicates an expected call of After
[ "After", "indicates", "an", "expected", "call", "of", "After" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/mocks/clock_mock.go#L45-L47
153,827
juju/juju
state/mocks/clock_mock.go
AfterFunc
func (m *MockClock) AfterFunc(arg0 time.Duration, arg1 func()) clock.Timer { ret := m.ctrl.Call(m, "AfterFunc", arg0, arg1) ret0, _ := ret[0].(clock.Timer) return ret0 }
go
func (m *MockClock) AfterFunc(arg0 time.Duration, arg1 func()) clock.Timer { ret := m.ctrl.Call(m, "AfterFunc", arg0, arg1) ret0, _ := ret[0].(clock.Timer) return ret0 }
[ "func", "(", "m", "*", "MockClock", ")", "AfterFunc", "(", "arg0", "time", ".", "Duration", ",", "arg1", "func", "(", ")", ")", "clock", ".", "Timer", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ",",...
// AfterFunc mocks base method
[ "AfterFunc", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/mocks/clock_mock.go#L50-L54
153,828
juju/juju
state/mocks/clock_mock.go
Now
func (mr *MockClockMockRecorder) Now() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Now", reflect.TypeOf((*MockClock)(nil).Now)) }
go
func (mr *MockClockMockRecorder) Now() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Now", reflect.TypeOf((*MockClock)(nil).Now)) }
[ "func", "(", "mr", "*", "MockClockMockRecorder", ")", "Now", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", ...
// Now indicates an expected call of Now
[ "Now", "indicates", "an", "expected", "call", "of", "Now" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/mocks/clock_mock.go#L81-L83
153,829
juju/juju
environs/simplestreams/json.go
UnmarshalJSON
func (c *ItemCollection) UnmarshalJSON(b []byte) error { var raw itemCollection if err := json.Unmarshal(b, &raw); err != nil { return err } c.rawItems = raw.Items c.Items = make(map[string]interface{}, len(raw.Items)) c.Arch = raw.Arch c.Version = raw.Version c.Series = raw.Series c.RegionName = raw.RegionName c.Endpoint = raw.Endpoint for key, rawv := range raw.Items { var v interface{} if err := json.Unmarshal([]byte(*rawv), &v); err != nil { return err } c.Items[key] = v } return nil }
go
func (c *ItemCollection) UnmarshalJSON(b []byte) error { var raw itemCollection if err := json.Unmarshal(b, &raw); err != nil { return err } c.rawItems = raw.Items c.Items = make(map[string]interface{}, len(raw.Items)) c.Arch = raw.Arch c.Version = raw.Version c.Series = raw.Series c.RegionName = raw.RegionName c.Endpoint = raw.Endpoint for key, rawv := range raw.Items { var v interface{} if err := json.Unmarshal([]byte(*rawv), &v); err != nil { return err } c.Items[key] = v } return nil }
[ "func", "(", "c", "*", "ItemCollection", ")", "UnmarshalJSON", "(", "b", "[", "]", "byte", ")", "error", "{", "var", "raw", "itemCollection", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "raw", ")", ";", "err", "!=", "nil"...
// ItemsCollection.UnmarshalJSON unmarshals the ItemCollection, // storing the raw bytes for each item. These can later be // unmarshalled again into product-specific types.
[ "ItemsCollection", ".", "UnmarshalJSON", "unmarshals", "the", "ItemCollection", "storing", "the", "raw", "bytes", "for", "each", "item", ".", "These", "can", "later", "be", "unmarshalled", "again", "into", "product", "-", "specific", "types", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/simplestreams/json.go#L25-L45
153,830
juju/juju
cmd/juju/storage/pooldelete.go
NewPoolRemoveCommand
func NewPoolRemoveCommand() cmd.Command { cmd := &poolRemoveCommand{} cmd.newAPIFunc = func() (PoolRemoveAPI, error) { return cmd.NewStorageAPI() } return modelcmd.Wrap(cmd) }
go
func NewPoolRemoveCommand() cmd.Command { cmd := &poolRemoveCommand{} cmd.newAPIFunc = func() (PoolRemoveAPI, error) { return cmd.NewStorageAPI() } return modelcmd.Wrap(cmd) }
[ "func", "NewPoolRemoveCommand", "(", ")", "cmd", ".", "Command", "{", "cmd", ":=", "&", "poolRemoveCommand", "{", "}", "\n", "cmd", ".", "newAPIFunc", "=", "func", "(", ")", "(", "PoolRemoveAPI", ",", "error", ")", "{", "return", "cmd", ".", "NewStorageA...
// NewPoolRemoveCommand returns a command that removes the named storage pool.
[ "NewPoolRemoveCommand", "returns", "a", "command", "that", "removes", "the", "named", "storage", "pool", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/storage/pooldelete.go#L36-L42
153,831
juju/juju
worker/machineactions/worker.go
NewMachineActionsWorker
func NewMachineActionsWorker(config WorkerConfig) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } swConfig := watcher.StringsConfig{ Handler: &handler{config}, } return watcher.NewStringsWorker(swConfig) }
go
func NewMachineActionsWorker(config WorkerConfig) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } swConfig := watcher.StringsConfig{ Handler: &handler{config}, } return watcher.NewStringsWorker(swConfig) }
[ "func", "NewMachineActionsWorker", "(", "config", "WorkerConfig", ")", "(", "worker", ".", "Worker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Tra...
// NewMachineActionsWorker returns a worker.Worker that watches for actions // enqueued on this machine and tries to execute them.
[ "NewMachineActionsWorker", "returns", "a", "worker", ".", "Worker", "that", "watches", "for", "actions", "enqueued", "on", "this", "machine", "and", "tries", "to", "execute", "them", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/machineactions/worker.go#L53-L61
153,832
juju/juju
worker/machineactions/worker.go
Handle
func (h *handler) Handle(_ <-chan struct{}, actionsSlice []string) error { for _, actionId := range actionsSlice { ok := names.IsValidAction(actionId) if !ok { return errors.Errorf("got invalid action id %s", actionId) } actionTag := names.NewActionTag(actionId) action, err := h.config.Facade.Action(actionTag) if err != nil { return errors.Annotatef(err, "could not retrieve action %s", actionId) } err = h.config.Facade.ActionBegin(actionTag) if err != nil { return errors.Annotatef(err, "could not begin action %s", action.Name()) } // We try to handle the action. The result returned from handling the action is // sent through using ActionFinish. We only stop the loop if ActionFinish fails. var finishErr error results, err := h.config.HandleAction(action.Name(), action.Params()) if err != nil { finishErr = h.config.Facade.ActionFinish(actionTag, params.ActionFailed, nil, err.Error()) } else { finishErr = h.config.Facade.ActionFinish(actionTag, params.ActionCompleted, results, "") } if finishErr != nil { return errors.Trace(finishErr) } } return nil }
go
func (h *handler) Handle(_ <-chan struct{}, actionsSlice []string) error { for _, actionId := range actionsSlice { ok := names.IsValidAction(actionId) if !ok { return errors.Errorf("got invalid action id %s", actionId) } actionTag := names.NewActionTag(actionId) action, err := h.config.Facade.Action(actionTag) if err != nil { return errors.Annotatef(err, "could not retrieve action %s", actionId) } err = h.config.Facade.ActionBegin(actionTag) if err != nil { return errors.Annotatef(err, "could not begin action %s", action.Name()) } // We try to handle the action. The result returned from handling the action is // sent through using ActionFinish. We only stop the loop if ActionFinish fails. var finishErr error results, err := h.config.HandleAction(action.Name(), action.Params()) if err != nil { finishErr = h.config.Facade.ActionFinish(actionTag, params.ActionFailed, nil, err.Error()) } else { finishErr = h.config.Facade.ActionFinish(actionTag, params.ActionCompleted, results, "") } if finishErr != nil { return errors.Trace(finishErr) } } return nil }
[ "func", "(", "h", "*", "handler", ")", "Handle", "(", "_", "<-", "chan", "struct", "{", "}", ",", "actionsSlice", "[", "]", "string", ")", "error", "{", "for", "_", ",", "actionId", ":=", "range", "actionsSlice", "{", "ok", ":=", "names", ".", "IsV...
// Handle is part of the watcher.StringsHandler interface. // It should give us any actions currently enqueued for this machine. // We try to execute every action before returning
[ "Handle", "is", "part", "of", "the", "watcher", ".", "StringsHandler", "interface", ".", "It", "should", "give", "us", "any", "actions", "currently", "enqueued", "for", "this", "machine", ".", "We", "try", "to", "execute", "every", "action", "before", "retur...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/machineactions/worker.go#L94-L126
153,833
juju/juju
state/applicationoffers.go
ApplicationOfferEndpoint
func ApplicationOfferEndpoint(offer crossmodel.ApplicationOffer, relationName string) (Endpoint, error) { for _, ep := range offer.Endpoints { if ep.Name == relationName { return Endpoint{ ApplicationName: offer.ApplicationName, Relation: ep, }, nil } } return Endpoint{}, errors.NotFoundf("relation %q on application offer %q", relationName, offer.String()) }
go
func ApplicationOfferEndpoint(offer crossmodel.ApplicationOffer, relationName string) (Endpoint, error) { for _, ep := range offer.Endpoints { if ep.Name == relationName { return Endpoint{ ApplicationName: offer.ApplicationName, Relation: ep, }, nil } } return Endpoint{}, errors.NotFoundf("relation %q on application offer %q", relationName, offer.String()) }
[ "func", "ApplicationOfferEndpoint", "(", "offer", "crossmodel", ".", "ApplicationOffer", ",", "relationName", "string", ")", "(", "Endpoint", ",", "error", ")", "{", "for", "_", ",", "ep", ":=", "range", "offer", ".", "Endpoints", "{", "if", "ep", ".", "Na...
// ApplicationOfferEndpoint returns from the specified offer, the relation endpoint // with the supplied name, if it exists.
[ "ApplicationOfferEndpoint", "returns", "from", "the", "specified", "offer", "the", "relation", "endpoint", "with", "the", "supplied", "name", "if", "it", "exists", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L71-L81
153,834
juju/juju
state/applicationoffers.go
ApplicationOfferForUUID
func (s *applicationOffers) ApplicationOfferForUUID(offerUUID string) (*crossmodel.ApplicationOffer, error) { offerDoc, err := s.offerQuery(bson.D{{"offer-uuid", offerUUID}}) if err != nil { if err == mgo.ErrNotFound { return nil, errors.NotFoundf("application offer %q", offerUUID) } return nil, errors.Annotatef(err, "cannot load application offer %q", offerUUID) } return s.makeApplicationOffer(*offerDoc) }
go
func (s *applicationOffers) ApplicationOfferForUUID(offerUUID string) (*crossmodel.ApplicationOffer, error) { offerDoc, err := s.offerQuery(bson.D{{"offer-uuid", offerUUID}}) if err != nil { if err == mgo.ErrNotFound { return nil, errors.NotFoundf("application offer %q", offerUUID) } return nil, errors.Annotatef(err, "cannot load application offer %q", offerUUID) } return s.makeApplicationOffer(*offerDoc) }
[ "func", "(", "s", "*", "applicationOffers", ")", "ApplicationOfferForUUID", "(", "offerUUID", "string", ")", "(", "*", "crossmodel", ".", "ApplicationOffer", ",", "error", ")", "{", "offerDoc", ",", "err", ":=", "s", ".", "offerQuery", "(", "bson", ".", "D...
// ApplicationOfferForUUID returns the application offer for the UUID.
[ "ApplicationOfferForUUID", "returns", "the", "application", "offer", "for", "the", "UUID", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L115-L124
153,835
juju/juju
state/applicationoffers.go
AllApplicationOffers
func (s *applicationOffers) AllApplicationOffers() (offers []*crossmodel.ApplicationOffer, _ error) { applicationOffersCollection, closer := s.st.db().GetCollection(applicationOffersC) defer closer() var docs []applicationOfferDoc err := applicationOffersCollection.Find(bson.D{}).All(&docs) if err != nil { return nil, errors.Errorf("cannot get all application offers") } for _, doc := range docs { offer, err := s.makeApplicationOffer(doc) if err != nil { return nil, errors.Trace(err) } offers = append(offers, offer) } return offers, nil }
go
func (s *applicationOffers) AllApplicationOffers() (offers []*crossmodel.ApplicationOffer, _ error) { applicationOffersCollection, closer := s.st.db().GetCollection(applicationOffersC) defer closer() var docs []applicationOfferDoc err := applicationOffersCollection.Find(bson.D{}).All(&docs) if err != nil { return nil, errors.Errorf("cannot get all application offers") } for _, doc := range docs { offer, err := s.makeApplicationOffer(doc) if err != nil { return nil, errors.Trace(err) } offers = append(offers, offer) } return offers, nil }
[ "func", "(", "s", "*", "applicationOffers", ")", "AllApplicationOffers", "(", ")", "(", "offers", "[", "]", "*", "crossmodel", ".", "ApplicationOffer", ",", "_", "error", ")", "{", "applicationOffersCollection", ",", "closer", ":=", "s", ".", "st", ".", "d...
// AllApplicationOffers returns all application offers in the model.
[ "AllApplicationOffers", "returns", "all", "application", "offers", "in", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L127-L144
153,836
juju/juju
state/applicationoffers.go
RemoveOfferOperation
func (s *applicationOffers) RemoveOfferOperation(offerName string, force bool) *RemoveOfferOperation { return &RemoveOfferOperation{ offers: &applicationOffers{s.st}, offerName: offerName, ForcedOperation: ForcedOperation{Force: force}, } }
go
func (s *applicationOffers) RemoveOfferOperation(offerName string, force bool) *RemoveOfferOperation { return &RemoveOfferOperation{ offers: &applicationOffers{s.st}, offerName: offerName, ForcedOperation: ForcedOperation{Force: force}, } }
[ "func", "(", "s", "*", "applicationOffers", ")", "RemoveOfferOperation", "(", "offerName", "string", ",", "force", "bool", ")", "*", "RemoveOfferOperation", "{", "return", "&", "RemoveOfferOperation", "{", "offers", ":", "&", "applicationOffers", "{", "s", ".", ...
// RemoveOfferOperation returns a model operation that will allow relation to leave scope.
[ "RemoveOfferOperation", "returns", "a", "model", "operation", "that", "will", "allow", "relation", "to", "leave", "scope", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L147-L153
153,837
juju/juju
state/applicationoffers.go
Remove
func (s *applicationOffers) Remove(offerName string, force bool) error { op := s.RemoveOfferOperation(offerName, force) err := s.st.ApplyOperation(op) // TODO (anastasiamac 2019-04-10) we can surfacing these errors to the user. // These are non-fatal operational errors that occurred during force and are // collected in the operation, op.Errors. return err }
go
func (s *applicationOffers) Remove(offerName string, force bool) error { op := s.RemoveOfferOperation(offerName, force) err := s.st.ApplyOperation(op) // TODO (anastasiamac 2019-04-10) we can surfacing these errors to the user. // These are non-fatal operational errors that occurred during force and are // collected in the operation, op.Errors. return err }
[ "func", "(", "s", "*", "applicationOffers", ")", "Remove", "(", "offerName", "string", ",", "force", "bool", ")", "error", "{", "op", ":=", "s", ".", "RemoveOfferOperation", "(", "offerName", ",", "force", ")", "\n", "err", ":=", "s", ".", "st", ".", ...
// Remove deletes the application offer for offerName immediately.
[ "Remove", "deletes", "the", "application", "offer", "for", "offerName", "immediately", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L207-L214
153,838
juju/juju
state/applicationoffers.go
removeApplicationOffersOps
func removeApplicationOffersOps(st *State, application string) ([]txn.Op, error) { // Check how many offer refs there are. If there are none, there's // nothing more to do. If there are refs, we assume that the number // if refs is the same as what we find below. If there is a // discrepancy, then it'll result in a transaction failure, and // we'll retry. countRefsOp, n, err := countApplicationOffersRefOp(st, application) if err != nil { return nil, errors.Trace(err) } if n == 0 { return []txn.Op{countRefsOp}, nil } applicationOffersCollection, closer := st.db().GetCollection(applicationOffersC) defer closer() query := bson.D{{"application-name", application}} var docs []applicationOfferDoc if err := applicationOffersCollection.Find(query).All(&docs); err != nil { return nil, errors.Annotatef(err, "reading application %q offers", application) } var ops []txn.Op for _, doc := range docs { ops = append(ops, txn.Op{ C: applicationOffersC, Id: doc.OfferName, Assert: txn.DocExists, Remove: true, }) } offerRefCountKey := applicationOffersRefCountKey(application) removeRefsOp := nsRefcounts.JustRemoveOp(refcountsC, offerRefCountKey, len(docs)) return append(ops, removeRefsOp), nil }
go
func removeApplicationOffersOps(st *State, application string) ([]txn.Op, error) { // Check how many offer refs there are. If there are none, there's // nothing more to do. If there are refs, we assume that the number // if refs is the same as what we find below. If there is a // discrepancy, then it'll result in a transaction failure, and // we'll retry. countRefsOp, n, err := countApplicationOffersRefOp(st, application) if err != nil { return nil, errors.Trace(err) } if n == 0 { return []txn.Op{countRefsOp}, nil } applicationOffersCollection, closer := st.db().GetCollection(applicationOffersC) defer closer() query := bson.D{{"application-name", application}} var docs []applicationOfferDoc if err := applicationOffersCollection.Find(query).All(&docs); err != nil { return nil, errors.Annotatef(err, "reading application %q offers", application) } var ops []txn.Op for _, doc := range docs { ops = append(ops, txn.Op{ C: applicationOffersC, Id: doc.OfferName, Assert: txn.DocExists, Remove: true, }) } offerRefCountKey := applicationOffersRefCountKey(application) removeRefsOp := nsRefcounts.JustRemoveOp(refcountsC, offerRefCountKey, len(docs)) return append(ops, removeRefsOp), nil }
[ "func", "removeApplicationOffersOps", "(", "st", "*", "State", ",", "application", "string", ")", "(", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "// Check how many offer refs there are. If there are none, there's", "// nothing more to do. If there are refs, we ass...
// removeApplicationOffersOps returns txn.Ops that will remove all offers for // the specified application. No assertions on the application or the offer // connections are made; the caller is responsible for ensuring that offer // connections have already been removed, or will be removed along with the // offers.
[ "removeApplicationOffersOps", "returns", "txn", ".", "Ops", "that", "will", "remove", "all", "offers", "for", "the", "specified", "application", ".", "No", "assertions", "on", "the", "application", "or", "the", "offer", "connections", "are", "made", ";", "the", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L320-L354
153,839
juju/juju
state/applicationoffers.go
AddOffer
func (s *applicationOffers) AddOffer(offerArgs crossmodel.AddApplicationOfferArgs) (_ *crossmodel.ApplicationOffer, err error) { defer errors.DeferredAnnotatef(&err, "cannot add application offer %q", offerArgs.OfferName) if err := s.validateOfferArgs(offerArgs); err != nil { return nil, err } model, err := s.st.Model() if err != nil { return nil, errors.Trace(err) } else if model.Life() != Alive { return nil, errors.Errorf("model is no longer alive") } uuid, err := utils.NewUUID() if err != nil { return nil, errors.Trace(err) } doc := s.makeApplicationOfferDoc(s.st, uuid.String(), offerArgs) result, err := s.makeApplicationOffer(doc) if err != nil { return nil, errors.Trace(err) } buildTxn := func(attempt int) ([]txn.Op, error) { // If we've tried once already and failed, check that // model may have been destroyed. if attempt > 0 { if err := checkModelActive(s.st); err != nil { return nil, errors.Trace(err) } _, err := s.ApplicationOffer(offerArgs.OfferName) if err == nil { return nil, errDuplicateApplicationOffer } } incRefOp, err := incApplicationOffersRefOp(s.st, offerArgs.ApplicationName) if err != nil { return nil, errors.Trace(err) } ops := []txn.Op{ model.assertActiveOp(), { C: applicationOffersC, Id: doc.DocID, Assert: txn.DocMissing, Insert: doc, }, incRefOp, } return ops, nil } err = s.st.db().Run(buildTxn) if err != nil { return nil, errors.Trace(err) } // Ensure the owner has admin access to the offer. offerTag := names.NewApplicationOfferTag(doc.OfferName) owner := names.NewUserTag(offerArgs.Owner) err = s.st.CreateOfferAccess(offerTag, owner, permission.AdminAccess) if err != nil { return nil, errors.Annotate(err, "granting admin permission to the offer owner") } // Add in any read access permissions. for _, user := range offerArgs.HasRead { readerTag := names.NewUserTag(user) err = s.st.CreateOfferAccess(offerTag, readerTag, permission.ReadAccess) if err != nil { return nil, errors.Annotatef(err, "granting read permission to %q", user) } } return result, nil }
go
func (s *applicationOffers) AddOffer(offerArgs crossmodel.AddApplicationOfferArgs) (_ *crossmodel.ApplicationOffer, err error) { defer errors.DeferredAnnotatef(&err, "cannot add application offer %q", offerArgs.OfferName) if err := s.validateOfferArgs(offerArgs); err != nil { return nil, err } model, err := s.st.Model() if err != nil { return nil, errors.Trace(err) } else if model.Life() != Alive { return nil, errors.Errorf("model is no longer alive") } uuid, err := utils.NewUUID() if err != nil { return nil, errors.Trace(err) } doc := s.makeApplicationOfferDoc(s.st, uuid.String(), offerArgs) result, err := s.makeApplicationOffer(doc) if err != nil { return nil, errors.Trace(err) } buildTxn := func(attempt int) ([]txn.Op, error) { // If we've tried once already and failed, check that // model may have been destroyed. if attempt > 0 { if err := checkModelActive(s.st); err != nil { return nil, errors.Trace(err) } _, err := s.ApplicationOffer(offerArgs.OfferName) if err == nil { return nil, errDuplicateApplicationOffer } } incRefOp, err := incApplicationOffersRefOp(s.st, offerArgs.ApplicationName) if err != nil { return nil, errors.Trace(err) } ops := []txn.Op{ model.assertActiveOp(), { C: applicationOffersC, Id: doc.DocID, Assert: txn.DocMissing, Insert: doc, }, incRefOp, } return ops, nil } err = s.st.db().Run(buildTxn) if err != nil { return nil, errors.Trace(err) } // Ensure the owner has admin access to the offer. offerTag := names.NewApplicationOfferTag(doc.OfferName) owner := names.NewUserTag(offerArgs.Owner) err = s.st.CreateOfferAccess(offerTag, owner, permission.AdminAccess) if err != nil { return nil, errors.Annotate(err, "granting admin permission to the offer owner") } // Add in any read access permissions. for _, user := range offerArgs.HasRead { readerTag := names.NewUserTag(user) err = s.st.CreateOfferAccess(offerTag, readerTag, permission.ReadAccess) if err != nil { return nil, errors.Annotatef(err, "granting read permission to %q", user) } } return result, nil }
[ "func", "(", "s", "*", "applicationOffers", ")", "AddOffer", "(", "offerArgs", "crossmodel", ".", "AddApplicationOfferArgs", ")", "(", "_", "*", "crossmodel", ".", "ApplicationOffer", ",", "err", "error", ")", "{", "defer", "errors", ".", "DeferredAnnotatef", ...
// AddOffer adds a new application offering to the directory.
[ "AddOffer", "adds", "a", "new", "application", "offering", "to", "the", "directory", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L379-L449
153,840
juju/juju
state/applicationoffers.go
UpdateOffer
func (s *applicationOffers) UpdateOffer(offerArgs crossmodel.AddApplicationOfferArgs) (_ *crossmodel.ApplicationOffer, err error) { defer errors.DeferredAnnotatef(&err, "cannot update application offer %q", offerArgs.ApplicationName) if err := s.validateOfferArgs(offerArgs); err != nil { return nil, err } model, err := s.st.Model() if err != nil { return nil, errors.Trace(err) } else if model.Life() != Alive { return nil, errors.Errorf("model is no longer alive") } offer, err := s.ApplicationOffer(offerArgs.OfferName) if err != nil { // This will either be NotFound or some other error. // In either case, we return the error. return nil, errors.Trace(err) } doc := s.makeApplicationOfferDoc(s.st, offer.OfferUUID, offerArgs) var refOps []txn.Op if offerArgs.ApplicationName != offer.ApplicationName { incRefOp, err := incApplicationOffersRefOp(s.st, offerArgs.ApplicationName) if err != nil { return nil, errors.Trace(err) } decRefOp, err := decApplicationOffersRefOp(s.st, offer.ApplicationName) if err != nil { return nil, errors.Trace(err) } refOps = append(refOps, incRefOp, decRefOp) } buildTxn := func(attempt int) ([]txn.Op, error) { // If we've tried once already and failed, check that // model may have been destroyed. if attempt > 0 { if err := checkModelActive(s.st); err != nil { return nil, errors.Trace(err) } _, err := s.ApplicationOffer(offerArgs.OfferName) if err != nil { // This will either be NotFound or some other error. // In either case, we return the error. return nil, errors.Trace(err) } } ops := []txn.Op{ model.assertActiveOp(), { C: applicationOffersC, Id: doc.DocID, Assert: txn.DocExists, Update: bson.M{"$set": doc}, }, } ops = append(ops, refOps...) return ops, nil } err = s.st.db().Run(buildTxn) if err != nil { return nil, errors.Trace(err) } return s.makeApplicationOffer(doc) }
go
func (s *applicationOffers) UpdateOffer(offerArgs crossmodel.AddApplicationOfferArgs) (_ *crossmodel.ApplicationOffer, err error) { defer errors.DeferredAnnotatef(&err, "cannot update application offer %q", offerArgs.ApplicationName) if err := s.validateOfferArgs(offerArgs); err != nil { return nil, err } model, err := s.st.Model() if err != nil { return nil, errors.Trace(err) } else if model.Life() != Alive { return nil, errors.Errorf("model is no longer alive") } offer, err := s.ApplicationOffer(offerArgs.OfferName) if err != nil { // This will either be NotFound or some other error. // In either case, we return the error. return nil, errors.Trace(err) } doc := s.makeApplicationOfferDoc(s.st, offer.OfferUUID, offerArgs) var refOps []txn.Op if offerArgs.ApplicationName != offer.ApplicationName { incRefOp, err := incApplicationOffersRefOp(s.st, offerArgs.ApplicationName) if err != nil { return nil, errors.Trace(err) } decRefOp, err := decApplicationOffersRefOp(s.st, offer.ApplicationName) if err != nil { return nil, errors.Trace(err) } refOps = append(refOps, incRefOp, decRefOp) } buildTxn := func(attempt int) ([]txn.Op, error) { // If we've tried once already and failed, check that // model may have been destroyed. if attempt > 0 { if err := checkModelActive(s.st); err != nil { return nil, errors.Trace(err) } _, err := s.ApplicationOffer(offerArgs.OfferName) if err != nil { // This will either be NotFound or some other error. // In either case, we return the error. return nil, errors.Trace(err) } } ops := []txn.Op{ model.assertActiveOp(), { C: applicationOffersC, Id: doc.DocID, Assert: txn.DocExists, Update: bson.M{"$set": doc}, }, } ops = append(ops, refOps...) return ops, nil } err = s.st.db().Run(buildTxn) if err != nil { return nil, errors.Trace(err) } return s.makeApplicationOffer(doc) }
[ "func", "(", "s", "*", "applicationOffers", ")", "UpdateOffer", "(", "offerArgs", "crossmodel", ".", "AddApplicationOfferArgs", ")", "(", "_", "*", "crossmodel", ".", "ApplicationOffer", ",", "err", "error", ")", "{", "defer", "errors", ".", "DeferredAnnotatef",...
// UpdateOffer replaces an existing offer at the same URL.
[ "UpdateOffer", "replaces", "an", "existing", "offer", "at", "the", "same", "URL", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L452-L515
153,841
juju/juju
state/applicationoffers.go
ListOffers
func (s *applicationOffers) ListOffers(filters ...crossmodel.ApplicationOfferFilter) ([]crossmodel.ApplicationOffer, error) { applicationOffersCollection, closer := s.st.db().GetCollection(applicationOffersC) defer closer() var offerDocs []applicationOfferDoc if len(filters) == 0 { err := applicationOffersCollection.Find(nil).All(&offerDocs) if err != nil { return nil, errors.Trace(err) } } for _, filter := range filters { var mgoQuery bson.D elems := s.makeFilterTerm(filter) mgoQuery = append(mgoQuery, elems...) var docs []applicationOfferDoc err := applicationOffersCollection.Find(mgoQuery).All(&docs) if err != nil { return nil, errors.Trace(err) } docs, err = s.filterOffers(docs, filter) if err != nil { return nil, errors.Trace(err) } offerDocs = append(offerDocs, docs...) } sort.Sort(offerSlice(offerDocs)) offers := make([]crossmodel.ApplicationOffer, len(offerDocs)) for i, doc := range offerDocs { offer, err := s.makeApplicationOffer(doc) if err != nil { return nil, errors.Trace(err) } offers[i] = *offer } return offers, nil }
go
func (s *applicationOffers) ListOffers(filters ...crossmodel.ApplicationOfferFilter) ([]crossmodel.ApplicationOffer, error) { applicationOffersCollection, closer := s.st.db().GetCollection(applicationOffersC) defer closer() var offerDocs []applicationOfferDoc if len(filters) == 0 { err := applicationOffersCollection.Find(nil).All(&offerDocs) if err != nil { return nil, errors.Trace(err) } } for _, filter := range filters { var mgoQuery bson.D elems := s.makeFilterTerm(filter) mgoQuery = append(mgoQuery, elems...) var docs []applicationOfferDoc err := applicationOffersCollection.Find(mgoQuery).All(&docs) if err != nil { return nil, errors.Trace(err) } docs, err = s.filterOffers(docs, filter) if err != nil { return nil, errors.Trace(err) } offerDocs = append(offerDocs, docs...) } sort.Sort(offerSlice(offerDocs)) offers := make([]crossmodel.ApplicationOffer, len(offerDocs)) for i, doc := range offerDocs { offer, err := s.makeApplicationOffer(doc) if err != nil { return nil, errors.Trace(err) } offers[i] = *offer } return offers, nil }
[ "func", "(", "s", "*", "applicationOffers", ")", "ListOffers", "(", "filters", "...", "crossmodel", ".", "ApplicationOfferFilter", ")", "(", "[", "]", "crossmodel", ".", "ApplicationOffer", ",", "error", ")", "{", "applicationOffersCollection", ",", "closer", ":...
// ListOffers returns the application offers matching any one of the filter terms.
[ "ListOffers", "returns", "the", "application", "offers", "matching", "any", "one", "of", "the", "filter", "terms", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L547-L586
153,842
juju/juju
state/applicationoffers.go
filterOffers
func (s *applicationOffers) filterOffers( in []applicationOfferDoc, filter crossmodel.ApplicationOfferFilter, ) ([]applicationOfferDoc, error) { out, err := s.filterOffersByEndpoint(in, filter.Endpoints) if err != nil { return nil, errors.Trace(err) } out, err = s.filterOffersByConnectedUser(out, filter.ConnectedUsers) if err != nil { return nil, errors.Trace(err) } return s.filterOffersByAllowedConsumer(out, filter.AllowedConsumers) }
go
func (s *applicationOffers) filterOffers( in []applicationOfferDoc, filter crossmodel.ApplicationOfferFilter, ) ([]applicationOfferDoc, error) { out, err := s.filterOffersByEndpoint(in, filter.Endpoints) if err != nil { return nil, errors.Trace(err) } out, err = s.filterOffersByConnectedUser(out, filter.ConnectedUsers) if err != nil { return nil, errors.Trace(err) } return s.filterOffersByAllowedConsumer(out, filter.AllowedConsumers) }
[ "func", "(", "s", "*", "applicationOffers", ")", "filterOffers", "(", "in", "[", "]", "applicationOfferDoc", ",", "filter", "crossmodel", ".", "ApplicationOfferFilter", ",", ")", "(", "[", "]", "applicationOfferDoc", ",", "error", ")", "{", "out", ",", "err"...
// filterOffers takes a list of offers resulting from a db query // and performs additional filtering which cannot be done via mongo.
[ "filterOffers", "takes", "a", "list", "of", "offers", "resulting", "from", "a", "db", "query", "and", "performs", "additional", "filtering", "which", "cannot", "be", "done", "via", "mongo", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L590-L604
153,843
juju/juju
state/applicationoffers.go
WatchOfferStatus
func (st *State) WatchOfferStatus(offerUUID string) (NotifyWatcher, error) { oa := NewApplicationOffers(st) offer, err := oa.ApplicationOfferForUUID(offerUUID) if err != nil { return nil, errors.Trace(err) } filter := func(id interface{}) bool { k, err := st.strictLocalID(id.(string)) if err != nil { return false } // Does the app name match? if strings.HasPrefix(k, "a#") && k[2:] == offer.ApplicationName { return true } // Maybe it is a status change for a unit of the app. if !strings.HasPrefix(k, "u#") && !strings.HasSuffix(k, "#charm") { return false } k = strings.TrimRight(k[2:], "#charm") if !names.IsValidUnit(k) { return false } unitApp, _ := names.UnitApplication(k) return unitApp == offer.ApplicationName } return newNotifyCollWatcher(st, statusesC, filter), nil }
go
func (st *State) WatchOfferStatus(offerUUID string) (NotifyWatcher, error) { oa := NewApplicationOffers(st) offer, err := oa.ApplicationOfferForUUID(offerUUID) if err != nil { return nil, errors.Trace(err) } filter := func(id interface{}) bool { k, err := st.strictLocalID(id.(string)) if err != nil { return false } // Does the app name match? if strings.HasPrefix(k, "a#") && k[2:] == offer.ApplicationName { return true } // Maybe it is a status change for a unit of the app. if !strings.HasPrefix(k, "u#") && !strings.HasSuffix(k, "#charm") { return false } k = strings.TrimRight(k[2:], "#charm") if !names.IsValidUnit(k) { return false } unitApp, _ := names.UnitApplication(k) return unitApp == offer.ApplicationName } return newNotifyCollWatcher(st, statusesC, filter), nil }
[ "func", "(", "st", "*", "State", ")", "WatchOfferStatus", "(", "offerUUID", "string", ")", "(", "NotifyWatcher", ",", "error", ")", "{", "oa", ":=", "NewApplicationOffers", "(", "st", ")", "\n", "offer", ",", "err", ":=", "oa", ".", "ApplicationOfferForUUI...
// WatchOfferStatus returns a NotifyWatcher that notifies of changes // to the offer's status.
[ "WatchOfferStatus", "returns", "a", "NotifyWatcher", "that", "notifies", "of", "changes", "to", "the", "offer", "s", "status", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/applicationoffers.go#L749-L779
153,844
juju/juju
apiserver/facades/client/usermanager/usermanager.go
NewUserManagerAPI
func NewUserManagerAPI( st *state.State, resources facade.Resources, authorizer facade.Authorizer, ) (*UserManagerAPI, error) { if !authorizer.AuthClient() { return nil, common.ErrPerm } // Since we know this is a user tag (because AuthClient is true), // we just do the type assertion to the UserTag. apiUser, _ := authorizer.GetAuthTag().(names.UserTag) // Pretty much all of the user manager methods have special casing for admin // users, so look once when we start and remember if the user is an admin. isAdmin, err := authorizer.HasPermission(permission.SuperuserAccess, st.ControllerTag()) if err != nil { return nil, errors.Trace(err) } return &UserManagerAPI{ state: st, authorizer: authorizer, check: common.NewBlockChecker(st), apiUser: apiUser, isAdmin: isAdmin, }, nil }
go
func NewUserManagerAPI( st *state.State, resources facade.Resources, authorizer facade.Authorizer, ) (*UserManagerAPI, error) { if !authorizer.AuthClient() { return nil, common.ErrPerm } // Since we know this is a user tag (because AuthClient is true), // we just do the type assertion to the UserTag. apiUser, _ := authorizer.GetAuthTag().(names.UserTag) // Pretty much all of the user manager methods have special casing for admin // users, so look once when we start and remember if the user is an admin. isAdmin, err := authorizer.HasPermission(permission.SuperuserAccess, st.ControllerTag()) if err != nil { return nil, errors.Trace(err) } return &UserManagerAPI{ state: st, authorizer: authorizer, check: common.NewBlockChecker(st), apiUser: apiUser, isAdmin: isAdmin, }, nil }
[ "func", "NewUserManagerAPI", "(", "st", "*", "state", ".", "State", ",", "resources", "facade", ".", "Resources", ",", "authorizer", "facade", ".", "Authorizer", ",", ")", "(", "*", "UserManagerAPI", ",", "error", ")", "{", "if", "!", "authorizer", ".", ...
// NewUserManagerAPI provides the signature required for facade registration.
[ "NewUserManagerAPI", "provides", "the", "signature", "required", "for", "facade", "registration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/usermanager/usermanager.go#L33-L59
153,845
juju/juju
apiserver/facades/client/usermanager/usermanager.go
AddUser
func (api *UserManagerAPI) AddUser(args params.AddUsers) (params.AddUserResults, error) { var result params.AddUserResults if err := api.check.ChangeAllowed(); err != nil { return result, errors.Trace(err) } if len(args.Users) == 0 { return result, nil } // Create the results list to populate. result.Results = make([]params.AddUserResult, len(args.Users)) isSuperUser, err := api.hasControllerAdminAccess() if err != nil { return result, errors.Trace(err) } if !isSuperUser { return result, common.ErrPerm } for i, arg := range args.Users { var user *state.User var err error if arg.Password != "" { user, err = api.state.AddUser(arg.Username, arg.DisplayName, arg.Password, api.apiUser.Id()) } else { user, err = api.state.AddUserWithSecretKey(arg.Username, arg.DisplayName, api.apiUser.Id()) } if err != nil { err = errors.Annotate(err, "failed to create user") result.Results[i].Error = common.ServerError(err) continue } else { result.Results[i] = params.AddUserResult{ Tag: user.Tag().String(), SecretKey: user.SecretKey(), } } } return result, nil }
go
func (api *UserManagerAPI) AddUser(args params.AddUsers) (params.AddUserResults, error) { var result params.AddUserResults if err := api.check.ChangeAllowed(); err != nil { return result, errors.Trace(err) } if len(args.Users) == 0 { return result, nil } // Create the results list to populate. result.Results = make([]params.AddUserResult, len(args.Users)) isSuperUser, err := api.hasControllerAdminAccess() if err != nil { return result, errors.Trace(err) } if !isSuperUser { return result, common.ErrPerm } for i, arg := range args.Users { var user *state.User var err error if arg.Password != "" { user, err = api.state.AddUser(arg.Username, arg.DisplayName, arg.Password, api.apiUser.Id()) } else { user, err = api.state.AddUserWithSecretKey(arg.Username, arg.DisplayName, api.apiUser.Id()) } if err != nil { err = errors.Annotate(err, "failed to create user") result.Results[i].Error = common.ServerError(err) continue } else { result.Results[i] = params.AddUserResult{ Tag: user.Tag().String(), SecretKey: user.SecretKey(), } } } return result, nil }
[ "func", "(", "api", "*", "UserManagerAPI", ")", "AddUser", "(", "args", "params", ".", "AddUsers", ")", "(", "params", ".", "AddUserResults", ",", "error", ")", "{", "var", "result", "params", ".", "AddUserResults", "\n\n", "if", "err", ":=", "api", ".",...
// AddUser adds a user with a username, and either a password or // a randomly generated secret key which will be returned.
[ "AddUser", "adds", "a", "user", "with", "a", "username", "and", "either", "a", "password", "or", "a", "randomly", "generated", "secret", "key", "which", "will", "be", "returned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/usermanager/usermanager.go#L71-L114
153,846
juju/juju
apiserver/facades/client/usermanager/usermanager.go
EnableUser
func (api *UserManagerAPI) EnableUser(users params.Entities) (params.ErrorResults, error) { isSuperUser, err := api.hasControllerAdminAccess() if err != nil { return params.ErrorResults{}, errors.Trace(err) } if !isSuperUser { return params.ErrorResults{}, common.ErrPerm } if err := api.check.ChangeAllowed(); err != nil { return params.ErrorResults{}, errors.Trace(err) } return api.enableUserImpl(users, "enable", (*state.User).Enable) }
go
func (api *UserManagerAPI) EnableUser(users params.Entities) (params.ErrorResults, error) { isSuperUser, err := api.hasControllerAdminAccess() if err != nil { return params.ErrorResults{}, errors.Trace(err) } if !isSuperUser { return params.ErrorResults{}, common.ErrPerm } if err := api.check.ChangeAllowed(); err != nil { return params.ErrorResults{}, errors.Trace(err) } return api.enableUserImpl(users, "enable", (*state.User).Enable) }
[ "func", "(", "api", "*", "UserManagerAPI", ")", "EnableUser", "(", "users", "params", ".", "Entities", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "isSuperUser", ",", "err", ":=", "api", ".", "hasControllerAdminAccess", "(", ")", "\n",...
// EnableUser enables one or more users. If the user is already enabled, // the action is considered a success.
[ "EnableUser", "enables", "one", "or", "more", "users", ".", "If", "the", "user", "is", "already", "enabled", "the", "action", "is", "considered", "a", "success", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/usermanager/usermanager.go#L186-L199
153,847
juju/juju
apiserver/facades/client/usermanager/usermanager.go
SetPassword
func (api *UserManagerAPI) SetPassword(args params.EntityPasswords) (params.ErrorResults, error) { if err := api.check.ChangeAllowed(); err != nil { return params.ErrorResults{}, errors.Trace(err) } var result params.ErrorResults if len(args.Changes) == 0 { return result, nil } // Create the results list to populate. result.Results = make([]params.ErrorResult, len(args.Changes)) for i, arg := range args.Changes { if err := api.setPassword(arg); err != nil { result.Results[i].Error = common.ServerError(err) } } return result, nil }
go
func (api *UserManagerAPI) SetPassword(args params.EntityPasswords) (params.ErrorResults, error) { if err := api.check.ChangeAllowed(); err != nil { return params.ErrorResults{}, errors.Trace(err) } var result params.ErrorResults if len(args.Changes) == 0 { return result, nil } // Create the results list to populate. result.Results = make([]params.ErrorResult, len(args.Changes)) for i, arg := range args.Changes { if err := api.setPassword(arg); err != nil { result.Results[i].Error = common.ServerError(err) } } return result, nil }
[ "func", "(", "api", "*", "UserManagerAPI", ")", "SetPassword", "(", "args", "params", ".", "EntityPasswords", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "if", "err", ":=", "api", ".", "check", ".", "ChangeAllowed", "(", ")", ";", ...
// SetPassword changes the stored password for the specified users.
[ "SetPassword", "changes", "the", "stored", "password", "for", "the", "specified", "users", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/usermanager/usermanager.go#L348-L367
153,848
juju/juju
api/retrystrategy/retrystrategy.go
RetryStrategy
func (c *Client) RetryStrategy(agentTag names.Tag) (params.RetryStrategy, error) { var results params.RetryStrategyResults args := params.Entities{ Entities: []params.Entity{{Tag: agentTag.String()}}, } err := c.facade.FacadeCall("RetryStrategy", args, &results) if err != nil { return params.RetryStrategy{}, errors.Trace(err) } if len(results.Results) != 1 { return params.RetryStrategy{}, fmt.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return params.RetryStrategy{}, errors.Trace(result.Error) } return *result.Result, nil }
go
func (c *Client) RetryStrategy(agentTag names.Tag) (params.RetryStrategy, error) { var results params.RetryStrategyResults args := params.Entities{ Entities: []params.Entity{{Tag: agentTag.String()}}, } err := c.facade.FacadeCall("RetryStrategy", args, &results) if err != nil { return params.RetryStrategy{}, errors.Trace(err) } if len(results.Results) != 1 { return params.RetryStrategy{}, fmt.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return params.RetryStrategy{}, errors.Trace(result.Error) } return *result.Result, nil }
[ "func", "(", "c", "*", "Client", ")", "RetryStrategy", "(", "agentTag", "names", ".", "Tag", ")", "(", "params", ".", "RetryStrategy", ",", "error", ")", "{", "var", "results", "params", ".", "RetryStrategyResults", "\n", "args", ":=", "params", ".", "En...
// RetryStrategy returns the configuration for the agent specified by the agentTag.
[ "RetryStrategy", "returns", "the", "configuration", "for", "the", "agent", "specified", "by", "the", "agentTag", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/retrystrategy/retrystrategy.go#L30-L47
153,849
juju/juju
api/retrystrategy/retrystrategy.go
WatchRetryStrategy
func (c *Client) WatchRetryStrategy(agentTag names.Tag) (watcher.NotifyWatcher, error) { var results params.NotifyWatchResults args := params.Entities{ Entities: []params.Entity{{Tag: agentTag.String()}}, } err := c.facade.FacadeCall("WatchRetryStrategy", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, fmt.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, errors.Trace(result.Error) } w := apiwatcher.NewNotifyWatcher(c.facade.RawAPICaller(), result) return w, nil }
go
func (c *Client) WatchRetryStrategy(agentTag names.Tag) (watcher.NotifyWatcher, error) { var results params.NotifyWatchResults args := params.Entities{ Entities: []params.Entity{{Tag: agentTag.String()}}, } err := c.facade.FacadeCall("WatchRetryStrategy", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, fmt.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, errors.Trace(result.Error) } w := apiwatcher.NewNotifyWatcher(c.facade.RawAPICaller(), result) return w, nil }
[ "func", "(", "c", "*", "Client", ")", "WatchRetryStrategy", "(", "agentTag", "names", ".", "Tag", ")", "(", "watcher", ".", "NotifyWatcher", ",", "error", ")", "{", "var", "results", "params", ".", "NotifyWatchResults", "\n", "args", ":=", "params", ".", ...
// WatchRetryStrategy returns a notify watcher that looks for changes in the // retry strategy config for the agent specified by agentTag // Right now only the boolean that decides whether we retry can be modified.
[ "WatchRetryStrategy", "returns", "a", "notify", "watcher", "that", "looks", "for", "changes", "in", "the", "retry", "strategy", "config", "for", "the", "agent", "specified", "by", "agentTag", "Right", "now", "only", "the", "boolean", "that", "decides", "whether"...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/retrystrategy/retrystrategy.go#L52-L70
153,850
juju/juju
api/lifeflag/facade.go
NewFacade
func NewFacade(caller base.APICaller, newWatcher NewWatcherFunc) *Facade { return &Facade{ caller: base.NewFacadeCaller(caller, "LifeFlag"), newWatcher: newWatcher, } }
go
func NewFacade(caller base.APICaller, newWatcher NewWatcherFunc) *Facade { return &Facade{ caller: base.NewFacadeCaller(caller, "LifeFlag"), newWatcher: newWatcher, } }
[ "func", "NewFacade", "(", "caller", "base", ".", "APICaller", ",", "newWatcher", "NewWatcherFunc", ")", "*", "Facade", "{", "return", "&", "Facade", "{", "caller", ":", "base", ".", "NewFacadeCaller", "(", "caller", ",", "\"", "\"", ")", ",", "newWatcher",...
// NewFacade returns a new Facade using the supplied caller.
[ "NewFacade", "returns", "a", "new", "Facade", "using", "the", "supplied", "caller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/lifeflag/facade.go#L26-L31
153,851
juju/juju
api/lifeflag/facade.go
Watch
func (facade *Facade) Watch(entity names.Tag) (watcher.NotifyWatcher, error) { args := params.Entities{ Entities: []params.Entity{{Tag: entity.String()}}, } var results params.NotifyWatchResults err := facade.caller.FacadeCall("Watch", args, &results) if err != nil { return nil, errors.Trace(err) } if count := len(results.Results); count != 1 { return nil, errors.Errorf("expected 1 Watch result, got %d", count) } result := results.Results[0] if err := result.Error; err != nil { if params.IsCodeNotFound(err) { return nil, ErrNotFound } return nil, errors.Trace(result.Error) } w := facade.newWatcher(facade.caller.RawAPICaller(), result) return w, nil }
go
func (facade *Facade) Watch(entity names.Tag) (watcher.NotifyWatcher, error) { args := params.Entities{ Entities: []params.Entity{{Tag: entity.String()}}, } var results params.NotifyWatchResults err := facade.caller.FacadeCall("Watch", args, &results) if err != nil { return nil, errors.Trace(err) } if count := len(results.Results); count != 1 { return nil, errors.Errorf("expected 1 Watch result, got %d", count) } result := results.Results[0] if err := result.Error; err != nil { if params.IsCodeNotFound(err) { return nil, ErrNotFound } return nil, errors.Trace(result.Error) } w := facade.newWatcher(facade.caller.RawAPICaller(), result) return w, nil }
[ "func", "(", "facade", "*", "Facade", ")", "Watch", "(", "entity", "names", ".", "Tag", ")", "(", "watcher", ".", "NotifyWatcher", ",", "error", ")", "{", "args", ":=", "params", ".", "Entities", "{", "Entities", ":", "[", "]", "params", ".", "Entity...
// Watch returns a NotifyWatcher that sends a value whenever the // entity's life value may have changed; or ErrNotFound; or some // other error.
[ "Watch", "returns", "a", "NotifyWatcher", "that", "sends", "a", "value", "whenever", "the", "entity", "s", "life", "value", "may", "have", "changed", ";", "or", "ErrNotFound", ";", "or", "some", "other", "error", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/lifeflag/facade.go#L49-L70
153,852
juju/juju
api/lifeflag/facade.go
Life
func (facade *Facade) Life(entity names.Tag) (life.Value, error) { args := params.Entities{ Entities: []params.Entity{{Tag: entity.String()}}, } var results params.LifeResults err := facade.caller.FacadeCall("Life", args, &results) if err != nil { return "", errors.Trace(err) } if count := len(results.Results); count != 1 { return "", errors.Errorf("expected 1 Life result, got %d", count) } result := results.Results[0] if err := result.Error; err != nil { if params.IsCodeNotFound(err) { return "", ErrNotFound } return "", errors.Trace(result.Error) } life := life.Value(result.Life) if err := life.Validate(); err != nil { return "", errors.Trace(err) } return life, nil }
go
func (facade *Facade) Life(entity names.Tag) (life.Value, error) { args := params.Entities{ Entities: []params.Entity{{Tag: entity.String()}}, } var results params.LifeResults err := facade.caller.FacadeCall("Life", args, &results) if err != nil { return "", errors.Trace(err) } if count := len(results.Results); count != 1 { return "", errors.Errorf("expected 1 Life result, got %d", count) } result := results.Results[0] if err := result.Error; err != nil { if params.IsCodeNotFound(err) { return "", ErrNotFound } return "", errors.Trace(result.Error) } life := life.Value(result.Life) if err := life.Validate(); err != nil { return "", errors.Trace(err) } return life, nil }
[ "func", "(", "facade", "*", "Facade", ")", "Life", "(", "entity", "names", ".", "Tag", ")", "(", "life", ".", "Value", ",", "error", ")", "{", "args", ":=", "params", ".", "Entities", "{", "Entities", ":", "[", "]", "params", ".", "Entity", "{", ...
// Life returns the entity's life value; or ErrNotFound; or some // other error.
[ "Life", "returns", "the", "entity", "s", "life", "value", ";", "or", "ErrNotFound", ";", "or", "some", "other", "error", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/lifeflag/facade.go#L74-L98
153,853
juju/juju
core/constraints/constraints.go
resolveAlias
func resolveAlias(key string) string { if canonical, ok := rawAliases[key]; ok { return canonical } return key }
go
func resolveAlias(key string) string { if canonical, ok := rawAliases[key]; ok { return canonical } return key }
[ "func", "resolveAlias", "(", "key", "string", ")", "string", "{", "if", "canonical", ",", "ok", ":=", "rawAliases", "[", "key", "]", ";", "ok", "{", "return", "canonical", "\n", "}", "\n", "return", "key", "\n", "}" ]
// resolveAlias returns the canonical representation of the given key, if it'a // an alias listed in aliases, otherwise it returns the original key.
[ "resolveAlias", "returns", "the", "canonical", "representation", "of", "the", "given", "key", "if", "it", "a", "an", "alias", "listed", "in", "aliases", "otherwise", "it", "returns", "the", "original", "key", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L108-L113
153,854
juju/juju
core/constraints/constraints.go
IncludeSpaces
func (v *Value) IncludeSpaces() []string { if v.Spaces == nil { return nil } return v.extractItems(*v.Spaces, true) }
go
func (v *Value) IncludeSpaces() []string { if v.Spaces == nil { return nil } return v.extractItems(*v.Spaces, true) }
[ "func", "(", "v", "*", "Value", ")", "IncludeSpaces", "(", ")", "[", "]", "string", "{", "if", "v", ".", "Spaces", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "v", ".", "extractItems", "(", "*", "v", ".", "Spaces", ",", "true", ...
// IncludeSpaces returns a list of spaces to include when starting a // machine, if specified.
[ "IncludeSpaces", "returns", "a", "list", "of", "spaces", "to", "include", "when", "starting", "a", "machine", "if", "specified", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L174-L179
153,855
juju/juju
core/constraints/constraints.go
ExcludeSpaces
func (v *Value) ExcludeSpaces() []string { if v.Spaces == nil { return nil } return v.extractItems(*v.Spaces, false) }
go
func (v *Value) ExcludeSpaces() []string { if v.Spaces == nil { return nil } return v.extractItems(*v.Spaces, false) }
[ "func", "(", "v", "*", "Value", ")", "ExcludeSpaces", "(", ")", "[", "]", "string", "{", "if", "v", ".", "Spaces", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "return", "v", ".", "extractItems", "(", "*", "v", ".", "Spaces", ",", "false",...
// ExcludeSpaces returns a list of spaces to exclude when starting a // machine, if specified. They are given in the spaces constraint with // a "^" prefix to the name, which is stripped before returning.
[ "ExcludeSpaces", "returns", "a", "list", "of", "spaces", "to", "exclude", "when", "starting", "a", "machine", "if", "specified", ".", "They", "are", "given", "in", "the", "spaces", "constraint", "with", "a", "^", "prefix", "to", "the", "name", "which", "is...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L184-L189
153,856
juju/juju
core/constraints/constraints.go
HasSpaces
func (v *Value) HasSpaces() bool { return v.Spaces != nil && len(*v.Spaces) > 0 }
go
func (v *Value) HasSpaces() bool { return v.Spaces != nil && len(*v.Spaces) > 0 }
[ "func", "(", "v", "*", "Value", ")", "HasSpaces", "(", ")", "bool", "{", "return", "v", ".", "Spaces", "!=", "nil", "&&", "len", "(", "*", "v", ".", "Spaces", ")", ">", "0", "\n", "}" ]
// HasSpaces returns whether any spaces constraints were specified.
[ "HasSpaces", "returns", "whether", "any", "spaces", "constraints", "were", "specified", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L192-L194
153,857
juju/juju
core/constraints/constraints.go
HasZones
func (v *Value) HasZones() bool { return v.Zones != nil && len(*v.Zones) > 0 }
go
func (v *Value) HasZones() bool { return v.Zones != nil && len(*v.Zones) > 0 }
[ "func", "(", "v", "*", "Value", ")", "HasZones", "(", ")", "bool", "{", "return", "v", ".", "Zones", "!=", "nil", "&&", "len", "(", "*", "v", ".", "Zones", ")", ">", "0", "\n", "}" ]
// HasZones returns whether any zone constraints were specified.
[ "HasZones", "returns", "whether", "any", "zone", "constraints", "were", "specified", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L202-L204
153,858
juju/juju
core/constraints/constraints.go
String
func (v Value) String() string { var strs []string if v.Arch != nil { strs = append(strs, "arch="+*v.Arch) } if v.Container != nil { strs = append(strs, "container="+string(*v.Container)) } if v.CpuCores != nil { strs = append(strs, "cores="+uintStr(*v.CpuCores)) } if v.CpuPower != nil { strs = append(strs, "cpu-power="+uintStr(*v.CpuPower)) } if v.InstanceType != nil { strs = append(strs, "instance-type="+(*v.InstanceType)) } if v.Mem != nil { s := uintStr(*v.Mem) if s != "" { s += "M" } strs = append(strs, "mem="+s) } if v.RootDisk != nil { s := uintStr(*v.RootDisk) if s != "" { s += "M" } strs = append(strs, "root-disk="+s) } if v.RootDiskSource != nil { s := *v.RootDiskSource strs = append(strs, "root-disk-source="+s) } if v.Tags != nil { s := strings.Join(*v.Tags, ",") strs = append(strs, "tags="+s) } if v.Spaces != nil { s := strings.Join(*v.Spaces, ",") strs = append(strs, "spaces="+s) } if v.VirtType != nil { strs = append(strs, "virt-type="+(*v.VirtType)) } if v.Zones != nil { s := strings.Join(*v.Zones, ",") strs = append(strs, "zones="+s) } return strings.Join(strs, " ") }
go
func (v Value) String() string { var strs []string if v.Arch != nil { strs = append(strs, "arch="+*v.Arch) } if v.Container != nil { strs = append(strs, "container="+string(*v.Container)) } if v.CpuCores != nil { strs = append(strs, "cores="+uintStr(*v.CpuCores)) } if v.CpuPower != nil { strs = append(strs, "cpu-power="+uintStr(*v.CpuPower)) } if v.InstanceType != nil { strs = append(strs, "instance-type="+(*v.InstanceType)) } if v.Mem != nil { s := uintStr(*v.Mem) if s != "" { s += "M" } strs = append(strs, "mem="+s) } if v.RootDisk != nil { s := uintStr(*v.RootDisk) if s != "" { s += "M" } strs = append(strs, "root-disk="+s) } if v.RootDiskSource != nil { s := *v.RootDiskSource strs = append(strs, "root-disk-source="+s) } if v.Tags != nil { s := strings.Join(*v.Tags, ",") strs = append(strs, "tags="+s) } if v.Spaces != nil { s := strings.Join(*v.Spaces, ",") strs = append(strs, "spaces="+s) } if v.VirtType != nil { strs = append(strs, "virt-type="+(*v.VirtType)) } if v.Zones != nil { s := strings.Join(*v.Zones, ",") strs = append(strs, "zones="+s) } return strings.Join(strs, " ") }
[ "func", "(", "v", "Value", ")", "String", "(", ")", "string", "{", "var", "strs", "[", "]", "string", "\n", "if", "v", ".", "Arch", "!=", "nil", "{", "strs", "=", "append", "(", "strs", ",", "\"", "\"", "+", "*", "v", ".", "Arch", ")", "\n", ...
// String expresses a constraints.Value in the language in which it was specified.
[ "String", "expresses", "a", "constraints", ".", "Value", "in", "the", "language", "in", "which", "it", "was", "specified", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L207-L258
153,859
juju/juju
core/constraints/constraints.go
GoString
func (v Value) GoString() string { var values []string if v.Arch != nil { values = append(values, fmt.Sprintf("Arch: %q", *v.Arch)) } if v.CpuCores != nil { values = append(values, fmt.Sprintf("Cores: %v", *v.CpuCores)) } if v.CpuPower != nil { values = append(values, fmt.Sprintf("CpuPower: %v", *v.CpuPower)) } if v.Mem != nil { values = append(values, fmt.Sprintf("Mem: %v", *v.Mem)) } if v.RootDisk != nil { values = append(values, fmt.Sprintf("RootDisk: %v", *v.RootDisk)) } if v.InstanceType != nil { values = append(values, fmt.Sprintf("InstanceType: %q", *v.InstanceType)) } if v.Container != nil { values = append(values, fmt.Sprintf("Container: %q", *v.Container)) } if v.Tags != nil && *v.Tags != nil { values = append(values, fmt.Sprintf("Tags: %q", *v.Tags)) } else if v.Tags != nil { values = append(values, "Tags: (*[]string)(nil)") } if v.Spaces != nil && *v.Spaces != nil { values = append(values, fmt.Sprintf("Spaces: %q", *v.Spaces)) } else if v.Spaces != nil { values = append(values, "Spaces: (*[]string)(nil)") } if v.VirtType != nil { values = append(values, fmt.Sprintf("VirtType: %q", *v.VirtType)) } if v.Zones != nil && *v.Zones != nil { values = append(values, fmt.Sprintf("Zones: %q", *v.Zones)) } else if v.Zones != nil { values = append(values, "Zones: (*[]string)(nil)") } return fmt.Sprintf("{%s}", strings.Join(values, ", ")) }
go
func (v Value) GoString() string { var values []string if v.Arch != nil { values = append(values, fmt.Sprintf("Arch: %q", *v.Arch)) } if v.CpuCores != nil { values = append(values, fmt.Sprintf("Cores: %v", *v.CpuCores)) } if v.CpuPower != nil { values = append(values, fmt.Sprintf("CpuPower: %v", *v.CpuPower)) } if v.Mem != nil { values = append(values, fmt.Sprintf("Mem: %v", *v.Mem)) } if v.RootDisk != nil { values = append(values, fmt.Sprintf("RootDisk: %v", *v.RootDisk)) } if v.InstanceType != nil { values = append(values, fmt.Sprintf("InstanceType: %q", *v.InstanceType)) } if v.Container != nil { values = append(values, fmt.Sprintf("Container: %q", *v.Container)) } if v.Tags != nil && *v.Tags != nil { values = append(values, fmt.Sprintf("Tags: %q", *v.Tags)) } else if v.Tags != nil { values = append(values, "Tags: (*[]string)(nil)") } if v.Spaces != nil && *v.Spaces != nil { values = append(values, fmt.Sprintf("Spaces: %q", *v.Spaces)) } else if v.Spaces != nil { values = append(values, "Spaces: (*[]string)(nil)") } if v.VirtType != nil { values = append(values, fmt.Sprintf("VirtType: %q", *v.VirtType)) } if v.Zones != nil && *v.Zones != nil { values = append(values, fmt.Sprintf("Zones: %q", *v.Zones)) } else if v.Zones != nil { values = append(values, "Zones: (*[]string)(nil)") } return fmt.Sprintf("{%s}", strings.Join(values, ", ")) }
[ "func", "(", "v", "Value", ")", "GoString", "(", ")", "string", "{", "var", "values", "[", "]", "string", "\n", "if", "v", ".", "Arch", "!=", "nil", "{", "values", "=", "append", "(", "values", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", ...
// GoString allows printing a constraints.Value nicely with the fmt // package, especially when nested inside other types.
[ "GoString", "allows", "printing", "a", "constraints", ".", "Value", "nicely", "with", "the", "fmt", "package", "especially", "when", "nested", "inside", "other", "types", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L262-L304
153,860
juju/juju
core/constraints/constraints.go
Parse
func Parse(args ...string) (Value, error) { v, _, err := ParseWithAliases(args...) return v, err }
go
func Parse(args ...string) (Value, error) { v, _, err := ParseWithAliases(args...) return v, err }
[ "func", "Parse", "(", "args", "...", "string", ")", "(", "Value", ",", "error", ")", "{", "v", ",", "_", ",", "err", ":=", "ParseWithAliases", "(", "args", "...", ")", "\n", "return", "v", ",", "err", "\n", "}" ]
// Parse constructs a constraints.Value from the supplied arguments, // each of which must contain only spaces and name=value pairs. If any // name is specified more than once, an error is returned.
[ "Parse", "constructs", "a", "constraints", ".", "Value", "from", "the", "supplied", "arguments", "each", "of", "which", "must", "contain", "only", "spaces", "and", "name", "=", "value", "pairs", ".", "If", "any", "name", "is", "specified", "more", "than", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L316-L319
153,861
juju/juju
core/constraints/constraints.go
ParseWithAliases
func ParseWithAliases(args ...string) (cons Value, aliases map[string]string, err error) { aliases = make(map[string]string) for _, arg := range args { raws := strings.Split(strings.TrimSpace(arg), " ") for _, raw := range raws { if raw == "" { continue } name, val, err := splitRaw(raw) if err != nil { return Value{}, nil, errors.Trace(err) } if canonical, ok := rawAliases[name]; ok { aliases[name] = canonical name = canonical } if err := cons.setRaw(name, val); err != nil { return Value{}, aliases, errors.Trace(err) } } } return cons, aliases, nil }
go
func ParseWithAliases(args ...string) (cons Value, aliases map[string]string, err error) { aliases = make(map[string]string) for _, arg := range args { raws := strings.Split(strings.TrimSpace(arg), " ") for _, raw := range raws { if raw == "" { continue } name, val, err := splitRaw(raw) if err != nil { return Value{}, nil, errors.Trace(err) } if canonical, ok := rawAliases[name]; ok { aliases[name] = canonical name = canonical } if err := cons.setRaw(name, val); err != nil { return Value{}, aliases, errors.Trace(err) } } } return cons, aliases, nil }
[ "func", "ParseWithAliases", "(", "args", "...", "string", ")", "(", "cons", "Value", ",", "aliases", "map", "[", "string", "]", "string", ",", "err", "error", ")", "{", "aliases", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "for...
// ParseWithAliases constructs a constraints.Value from the supplied arguments, each // of which must contain only spaces and name=value pairs. If any name is // specified more than once, an error is returned. The aliases map returned // contains a map of aliases used, and their canonical values.
[ "ParseWithAliases", "constructs", "a", "constraints", ".", "Value", "from", "the", "supplied", "arguments", "each", "of", "which", "must", "contain", "only", "spaces", "and", "name", "=", "value", "pairs", ".", "If", "any", "name", "is", "specified", "more", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L325-L347
153,862
juju/juju
core/constraints/constraints.go
Merge
func Merge(values ...Value) (Value, error) { var args []string for _, value := range values { args = append(args, value.String()) } return Parse(args...) }
go
func Merge(values ...Value) (Value, error) { var args []string for _, value := range values { args = append(args, value.String()) } return Parse(args...) }
[ "func", "Merge", "(", "values", "...", "Value", ")", "(", "Value", ",", "error", ")", "{", "var", "args", "[", "]", "string", "\n", "for", "_", ",", "value", ":=", "range", "values", "{", "args", "=", "append", "(", "args", ",", "value", ".", "St...
// Merge returns the effective constraints after merging any given // existing values.
[ "Merge", "returns", "the", "effective", "constraints", "after", "merging", "any", "given", "existing", "values", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L351-L357
153,863
juju/juju
core/constraints/constraints.go
MustParse
func MustParse(args ...string) Value { v, err := Parse(args...) if err != nil { panic(err) } return v }
go
func MustParse(args ...string) Value { v, err := Parse(args...) if err != nil { panic(err) } return v }
[ "func", "MustParse", "(", "args", "...", "string", ")", "Value", "{", "v", ",", "err", ":=", "Parse", "(", "args", "...", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "v", "\n", "}" ]
// MustParse constructs a constraints.Value from the supplied arguments, // as Parse, but panics on failure.
[ "MustParse", "constructs", "a", "constraints", ".", "Value", "from", "the", "supplied", "arguments", "as", "Parse", "but", "panics", "on", "failure", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L361-L367
153,864
juju/juju
core/constraints/constraints.go
attributesWithValues
func (v *Value) attributesWithValues() map[string]interface{} { // These can never fail, so we ignore the error for the sake of keeping our // API clean. I'm sorry (but not that sorry). b, _ := json.Marshal(v) result := map[string]interface{}{} _ = json.Unmarshal(b, &result) return result }
go
func (v *Value) attributesWithValues() map[string]interface{} { // These can never fail, so we ignore the error for the sake of keeping our // API clean. I'm sorry (but not that sorry). b, _ := json.Marshal(v) result := map[string]interface{}{} _ = json.Unmarshal(b, &result) return result }
[ "func", "(", "v", "*", "Value", ")", "attributesWithValues", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "// These can never fail, so we ignore the error for the sake of keeping our", "// API clean. I'm sorry (but not that sorry).", "b", ",", "_", ":...
// attributesWithValues returns the non-zero attribute tags and their values from the constraint.
[ "attributesWithValues", "returns", "the", "non", "-", "zero", "attribute", "tags", "and", "their", "values", "from", "the", "constraint", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L388-L395
153,865
juju/juju
core/constraints/constraints.go
hasAny
func (v *Value) hasAny(attrTags ...string) []string { attributes := v.attributesWithValues() var result []string for _, tag := range attrTags { _, ok := attributes[resolveAlias(tag)] if ok { result = append(result, tag) } } return result }
go
func (v *Value) hasAny(attrTags ...string) []string { attributes := v.attributesWithValues() var result []string for _, tag := range attrTags { _, ok := attributes[resolveAlias(tag)] if ok { result = append(result, tag) } } return result }
[ "func", "(", "v", "*", "Value", ")", "hasAny", "(", "attrTags", "...", "string", ")", "[", "]", "string", "{", "attributes", ":=", "v", ".", "attributesWithValues", "(", ")", "\n", "var", "result", "[", "]", "string", "\n", "for", "_", ",", "tag", ...
// hasAny returns any attrTags for which the constraint has a non-nil value.
[ "hasAny", "returns", "any", "attrTags", "for", "which", "the", "constraint", "has", "a", "non", "-", "nil", "value", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L405-L415
153,866
juju/juju
core/constraints/constraints.go
without
func (v *Value) without(attrTags ...string) Value { attributes := v.attributesWithValues() for _, tag := range attrTags { delete(attributes, resolveAlias(tag)) } return fromAttributes(attributes) }
go
func (v *Value) without(attrTags ...string) Value { attributes := v.attributesWithValues() for _, tag := range attrTags { delete(attributes, resolveAlias(tag)) } return fromAttributes(attributes) }
[ "func", "(", "v", "*", "Value", ")", "without", "(", "attrTags", "...", "string", ")", "Value", "{", "attributes", ":=", "v", ".", "attributesWithValues", "(", ")", "\n", "for", "_", ",", "tag", ":=", "range", "attrTags", "{", "delete", "(", "attribute...
// without returns a copy of the constraint without values for // the specified attributes.
[ "without", "returns", "a", "copy", "of", "the", "constraint", "without", "values", "for", "the", "specified", "attributes", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L419-L425
153,867
juju/juju
core/constraints/constraints.go
HasContainer
func (v *Value) HasContainer() bool { return v.Container != nil && *v.Container != "" && *v.Container != instance.NONE }
go
func (v *Value) HasContainer() bool { return v.Container != nil && *v.Container != "" && *v.Container != instance.NONE }
[ "func", "(", "v", "*", "Value", ")", "HasContainer", "(", ")", "bool", "{", "return", "v", ".", "Container", "!=", "nil", "&&", "*", "v", ".", "Container", "!=", "\"", "\"", "&&", "*", "v", ".", "Container", "!=", "instance", ".", "NONE", "\n", "...
// HasContainer returns true if the constraints.Value specifies a container.
[ "HasContainer", "returns", "true", "if", "the", "constraints", ".", "Value", "specifies", "a", "container", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L558-L560
153,868
juju/juju
core/constraints/constraints.go
parseCommaDelimited
func parseCommaDelimited(s string) *[]string { if s == "" { return &[]string{} } t := strings.Split(s, ",") return &t }
go
func parseCommaDelimited(s string) *[]string { if s == "" { return &[]string{} } t := strings.Split(s, ",") return &t }
[ "func", "parseCommaDelimited", "(", "s", "string", ")", "*", "[", "]", "string", "{", "if", "s", "==", "\"", "\"", "{", "return", "&", "[", "]", "string", "{", "}", "\n", "}", "\n", "t", ":=", "strings", ".", "Split", "(", "s", ",", "\"", "\"",...
// parseCommaDelimited returns the items in the value s. We expect the // items to be comma delimited strings.
[ "parseCommaDelimited", "returns", "the", "items", "in", "the", "value", "s", ".", "We", "expect", "the", "items", "to", "be", "comma", "delimited", "strings", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/constraints/constraints.go#L702-L708
153,869
juju/juju
provider/common/disk.go
MinRootDiskSizeGiB
func MinRootDiskSizeGiB(series string) uint64 { // See comment below that explains why we're ignoring the error os, _ := jujuseries.GetOSFromSeries(series) switch os { case jujuos.Ubuntu, jujuos.CentOS, jujuos.OpenSUSE: return 8 case jujuos.Windows: return 40 // By default we just return a "sane" default, since the error will just // be returned by the api and seen in juju status default: return 8 } }
go
func MinRootDiskSizeGiB(series string) uint64 { // See comment below that explains why we're ignoring the error os, _ := jujuseries.GetOSFromSeries(series) switch os { case jujuos.Ubuntu, jujuos.CentOS, jujuos.OpenSUSE: return 8 case jujuos.Windows: return 40 // By default we just return a "sane" default, since the error will just // be returned by the api and seen in juju status default: return 8 } }
[ "func", "MinRootDiskSizeGiB", "(", "series", "string", ")", "uint64", "{", "// See comment below that explains why we're ignoring the error", "os", ",", "_", ":=", "jujuseries", ".", "GetOSFromSeries", "(", "series", ")", "\n", "switch", "os", "{", "case", "jujuos", ...
// MinRootDiskSizeGiB is the minimum size for the root disk of an // instance, in Gigabytes. This value accommodates the anticipated // size of the initial image, any updates, and future application // data.
[ "MinRootDiskSizeGiB", "is", "the", "minimum", "size", "for", "the", "root", "disk", "of", "an", "instance", "in", "Gigabytes", ".", "This", "value", "accommodates", "the", "anticipated", "size", "of", "the", "initial", "image", "any", "updates", "and", "future...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/disk.go#L15-L28
153,870
juju/juju
state/errors.go
IsCharmAlreadyUploadedError
func IsCharmAlreadyUploadedError(err interface{}) bool { if err == nil { return false } // In case of a wrapped error, check the cause first. value := err cause := errors.Cause(err.(error)) if cause != nil { value = cause } _, ok := value.(*ErrCharmAlreadyUploaded) return ok }
go
func IsCharmAlreadyUploadedError(err interface{}) bool { if err == nil { return false } // In case of a wrapped error, check the cause first. value := err cause := errors.Cause(err.(error)) if cause != nil { value = cause } _, ok := value.(*ErrCharmAlreadyUploaded) return ok }
[ "func", "IsCharmAlreadyUploadedError", "(", "err", "interface", "{", "}", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "// In case of a wrapped error, check the cause first.", "value", ":=", "err", "\n", "cause", ":=", "er...
// IsCharmAlreadyUploadedError returns if the given error is // ErrCharmAlreadyUploaded.
[ "IsCharmAlreadyUploadedError", "returns", "if", "the", "given", "error", "is", "ErrCharmAlreadyUploaded", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/errors.go#L30-L42
153,871
juju/juju
state/errors.go
IsNotAlive
func IsNotAlive(err error) bool { _, ok := errors.Cause(err).(notAliveError) return ok }
go
func IsNotAlive(err error) bool { _, ok := errors.Cause(err).(notAliveError) return ok }
[ "func", "IsNotAlive", "(", "err", "error", ")", "bool", "{", "_", ",", "ok", ":=", "errors", ".", "Cause", "(", "err", ")", ".", "(", "notAliveError", ")", "\n", "return", "ok", "\n", "}" ]
// IsNotAlive returns true if err is cause by a not alive error.
[ "IsNotAlive", "returns", "true", "if", "err", "is", "cause", "by", "a", "not", "alive", "error", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/errors.go#L63-L66
153,872
juju/juju
state/errors.go
NewProviderIDNotUniqueError
func NewProviderIDNotUniqueError(providerIDs ...network.Id) error { stringIDs := make([]string, len(providerIDs)) for i, providerID := range providerIDs { stringIDs[i] = string(providerID) } return newProviderIDNotUniqueErrorFromStrings(stringIDs) }
go
func NewProviderIDNotUniqueError(providerIDs ...network.Id) error { stringIDs := make([]string, len(providerIDs)) for i, providerID := range providerIDs { stringIDs[i] = string(providerID) } return newProviderIDNotUniqueErrorFromStrings(stringIDs) }
[ "func", "NewProviderIDNotUniqueError", "(", "providerIDs", "...", "network", ".", "Id", ")", "error", "{", "stringIDs", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "providerIDs", ")", ")", "\n", "for", "i", ",", "providerID", ":=", "range", "...
// NewProviderIDNotUniqueError returns an instance of ErrProviderIDNotUnique // initialized with the given duplicate provider IDs.
[ "NewProviderIDNotUniqueError", "returns", "an", "instance", "of", "ErrProviderIDNotUnique", "initialized", "with", "the", "given", "duplicate", "provider", "IDs", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/errors.go#L98-L104
153,873
juju/juju
state/errors.go
IsProviderIDNotUniqueError
func IsProviderIDNotUniqueError(err interface{}) bool { if err == nil { return false } // In case of a wrapped error, check the cause first. value := err cause := errors.Cause(err.(error)) if cause != nil { value = cause } _, ok := value.(*ErrProviderIDNotUnique) return ok }
go
func IsProviderIDNotUniqueError(err interface{}) bool { if err == nil { return false } // In case of a wrapped error, check the cause first. value := err cause := errors.Cause(err.(error)) if cause != nil { value = cause } _, ok := value.(*ErrProviderIDNotUnique) return ok }
[ "func", "IsProviderIDNotUniqueError", "(", "err", "interface", "{", "}", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "// In case of a wrapped error, check the cause first.", "value", ":=", "err", "\n", "cause", ":=", "err...
// IsProviderIDNotUniqueError returns if the given error or its cause is // ErrProviderIDNotUnique.
[ "IsProviderIDNotUniqueError", "returns", "if", "the", "given", "error", "or", "its", "cause", "is", "ErrProviderIDNotUnique", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/errors.go#L114-L126
153,874
juju/juju
state/errors.go
IsParentDeviceHasChildrenError
func IsParentDeviceHasChildrenError(err interface{}) bool { if err == nil { return false } // In case of a wrapped error, check the cause first. value := err cause := errors.Cause(err.(error)) if cause != nil { value = cause } _, ok := value.(*ErrParentDeviceHasChildren) return ok }
go
func IsParentDeviceHasChildrenError(err interface{}) bool { if err == nil { return false } // In case of a wrapped error, check the cause first. value := err cause := errors.Cause(err.(error)) if cause != nil { value = cause } _, ok := value.(*ErrParentDeviceHasChildren) return ok }
[ "func", "IsParentDeviceHasChildrenError", "(", "err", "interface", "{", "}", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "// In case of a wrapped error, check the cause first.", "value", ":=", "err", "\n", "cause", ":=", ...
// IsParentDeviceHasChildrenError returns if the given error or its cause is // ErrParentDeviceHasChildren.
[ "IsParentDeviceHasChildrenError", "returns", "if", "the", "given", "error", "or", "its", "cause", "is", "ErrParentDeviceHasChildren", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/errors.go#L149-L161
153,875
juju/juju
state/errors.go
IsIncompatibleSeriesError
func IsIncompatibleSeriesError(err interface{}) bool { if err == nil { return false } // In case of a wrapped error, check the cause first. value := err cause := errors.Cause(err.(error)) if cause != nil { value = cause } _, ok := value.(*ErrIncompatibleSeries) return ok }
go
func IsIncompatibleSeriesError(err interface{}) bool { if err == nil { return false } // In case of a wrapped error, check the cause first. value := err cause := errors.Cause(err.(error)) if cause != nil { value = cause } _, ok := value.(*ErrIncompatibleSeries) return ok }
[ "func", "IsIncompatibleSeriesError", "(", "err", "interface", "{", "}", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "// In case of a wrapped error, check the cause first.", "value", ":=", "err", "\n", "cause", ":=", "erro...
// IsIncompatibleSeriesError returns if the given error or its cause is // ErrIncompatibleSeries.
[ "IsIncompatibleSeriesError", "returns", "if", "the", "given", "error", "or", "its", "cause", "is", "ErrIncompatibleSeries", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/errors.go#L178-L190
153,876
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
NewMockInstanceMutaterState
func NewMockInstanceMutaterState(ctrl *gomock.Controller) *MockInstanceMutaterState { mock := &MockInstanceMutaterState{ctrl: ctrl} mock.recorder = &MockInstanceMutaterStateMockRecorder{mock} return mock }
go
func NewMockInstanceMutaterState(ctrl *gomock.Controller) *MockInstanceMutaterState { mock := &MockInstanceMutaterState{ctrl: ctrl} mock.recorder = &MockInstanceMutaterStateMockRecorder{mock} return mock }
[ "func", "NewMockInstanceMutaterState", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockInstanceMutaterState", "{", "mock", ":=", "&", "MockInstanceMutaterState", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockInstanceM...
// NewMockInstanceMutaterState creates a new mock instance
[ "NewMockInstanceMutaterState", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L28-L32
153,877
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
ControllerTimestamp
func (m *MockInstanceMutaterState) ControllerTimestamp() (*time.Time, error) { ret := m.ctrl.Call(m, "ControllerTimestamp") ret0, _ := ret[0].(*time.Time) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockInstanceMutaterState) ControllerTimestamp() (*time.Time, error) { ret := m.ctrl.Call(m, "ControllerTimestamp") ret0, _ := ret[0].(*time.Time) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockInstanceMutaterState", ")", "ControllerTimestamp", "(", ")", "(", "*", "time", ".", "Time", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":...
// ControllerTimestamp mocks base method
[ "ControllerTimestamp", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L40-L45
153,878
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
ControllerTimestamp
func (mr *MockInstanceMutaterStateMockRecorder) ControllerTimestamp() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ControllerTimestamp", reflect.TypeOf((*MockInstanceMutaterState)(nil).ControllerTimestamp)) }
go
func (mr *MockInstanceMutaterStateMockRecorder) ControllerTimestamp() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ControllerTimestamp", reflect.TypeOf((*MockInstanceMutaterState)(nil).ControllerTimestamp)) }
[ "func", "(", "mr", "*", "MockInstanceMutaterStateMockRecorder", ")", "ControllerTimestamp", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", ...
// ControllerTimestamp indicates an expected call of ControllerTimestamp
[ "ControllerTimestamp", "indicates", "an", "expected", "call", "of", "ControllerTimestamp" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L48-L50
153,879
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
FindEntity
func (m *MockInstanceMutaterState) FindEntity(arg0 names_v2.Tag) (state.Entity, error) { ret := m.ctrl.Call(m, "FindEntity", arg0) ret0, _ := ret[0].(state.Entity) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockInstanceMutaterState) FindEntity(arg0 names_v2.Tag) (state.Entity, error) { ret := m.ctrl.Call(m, "FindEntity", arg0) ret0, _ := ret[0].(state.Entity) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockInstanceMutaterState", ")", "FindEntity", "(", "arg0", "names_v2", ".", "Tag", ")", "(", "state", ".", "Entity", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0",...
// FindEntity mocks base method
[ "FindEntity", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L53-L58
153,880
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
NewMockMachine
func NewMockMachine(ctrl *gomock.Controller) *MockMachine { mock := &MockMachine{ctrl: ctrl} mock.recorder = &MockMachineMockRecorder{mock} return mock }
go
func NewMockMachine(ctrl *gomock.Controller) *MockMachine { mock := &MockMachine{ctrl: ctrl} mock.recorder = &MockMachineMockRecorder{mock} return mock }
[ "func", "NewMockMachine", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockMachine", "{", "mock", ":=", "&", "MockMachine", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockMachineMockRecorder", "{", "mock", "}", ...
// NewMockMachine creates a new mock instance
[ "NewMockMachine", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L77-L81
153,881
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
SetModificationStatus
func (m *MockMachine) SetModificationStatus(arg0 status.StatusInfo) error { ret := m.ctrl.Call(m, "SetModificationStatus", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockMachine) SetModificationStatus(arg0 status.StatusInfo) error { ret := m.ctrl.Call(m, "SetModificationStatus", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockMachine", ")", "SetModificationStatus", "(", "arg0", "status", ".", "StatusInfo", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", ...
// SetModificationStatus mocks base method
[ "SetModificationStatus", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L101-L105
153,882
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
NewMockLXDProfile
func NewMockLXDProfile(ctrl *gomock.Controller) *MockLXDProfile { mock := &MockLXDProfile{ctrl: ctrl} mock.recorder = &MockLXDProfileMockRecorder{mock} return mock }
go
func NewMockLXDProfile(ctrl *gomock.Controller) *MockLXDProfile { mock := &MockLXDProfile{ctrl: ctrl} mock.recorder = &MockLXDProfileMockRecorder{mock} return mock }
[ "func", "NewMockLXDProfile", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockLXDProfile", "{", "mock", ":=", "&", "MockLXDProfile", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockLXDProfileMockRecorder", "{", "mock...
// NewMockLXDProfile creates a new mock instance
[ "NewMockLXDProfile", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L124-L128
153,883
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
Devices
func (m *MockLXDProfile) Devices() map[string]map[string]string { ret := m.ctrl.Call(m, "Devices") ret0, _ := ret[0].(map[string]map[string]string) return ret0 }
go
func (m *MockLXDProfile) Devices() map[string]map[string]string { ret := m.ctrl.Call(m, "Devices") ret0, _ := ret[0].(map[string]map[string]string) return ret0 }
[ "func", "(", "m", "*", "MockLXDProfile", ")", "Devices", "(", ")", "map", "[", "string", "]", "map", "[", "string", "]", "string", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", ...
// Devices mocks base method
[ "Devices", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L160-L164
153,884
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
Empty
func (m *MockLXDProfile) Empty() bool { ret := m.ctrl.Call(m, "Empty") ret0, _ := ret[0].(bool) return ret0 }
go
func (m *MockLXDProfile) Empty() bool { ret := m.ctrl.Call(m, "Empty") ret0, _ := ret[0].(bool) return ret0 }
[ "func", "(", "m", "*", "MockLXDProfile", ")", "Empty", "(", ")", "bool", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "bool", ")", "\n", "retu...
// Empty mocks base method
[ "Empty", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L172-L176
153,885
juju/juju
apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go
ValidateConfigDevices
func (m *MockLXDProfile) ValidateConfigDevices() error { ret := m.ctrl.Call(m, "ValidateConfigDevices") ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockLXDProfile) ValidateConfigDevices() error { ret := m.ctrl.Call(m, "ValidateConfigDevices") ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockLXDProfile", ")", "ValidateConfigDevices", "(", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "error", ")...
// ValidateConfigDevices mocks base method
[ "ValidateConfigDevices", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/instancemutater_mock.go#L184-L188
153,886
juju/juju
worker/retrystrategy/worker.go
NewRetryStrategyWorker
func NewRetryStrategyWorker(config WorkerConfig) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{ Handler: retryStrategyHandler{config}, }) if err != nil { return nil, errors.Trace(err) } return &RetryStrategyWorker{w, config.RetryStrategy}, nil }
go
func NewRetryStrategyWorker(config WorkerConfig) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{ Handler: retryStrategyHandler{config}, }) if err != nil { return nil, errors.Trace(err) } return &RetryStrategyWorker{w, config.RetryStrategy}, nil }
[ "func", "NewRetryStrategyWorker", "(", "config", "WorkerConfig", ")", "(", "worker", ".", "Worker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trac...
// NewRetryStrategyWorker returns a worker.Worker that returns the current // retry strategy and bounces when it changes.
[ "NewRetryStrategyWorker", "returns", "a", "worker", ".", "Worker", "that", "returns", "the", "current", "retry", "strategy", "and", "bounces", "when", "it", "changes", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/retrystrategy/worker.go#L53-L64
153,887
juju/juju
worker/retrystrategy/worker.go
SetUp
func (h retryStrategyHandler) SetUp() (watcher.NotifyWatcher, error) { return h.config.Facade.WatchRetryStrategy(h.config.AgentTag) }
go
func (h retryStrategyHandler) SetUp() (watcher.NotifyWatcher, error) { return h.config.Facade.WatchRetryStrategy(h.config.AgentTag) }
[ "func", "(", "h", "retryStrategyHandler", ")", "SetUp", "(", ")", "(", "watcher", ".", "NotifyWatcher", ",", "error", ")", "{", "return", "h", ".", "config", ".", "Facade", ".", "WatchRetryStrategy", "(", "h", ".", "config", ".", "AgentTag", ")", "\n", ...
// SetUp is part of the watcher.NotifyHandler interface.
[ "SetUp", "is", "part", "of", "the", "watcher", ".", "NotifyHandler", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/retrystrategy/worker.go#L77-L79
153,888
juju/juju
worker/retrystrategy/worker.go
Handle
func (h retryStrategyHandler) Handle(_ <-chan struct{}) error { newRetryStrategy, err := h.config.Facade.RetryStrategy(h.config.AgentTag) if err != nil { return errors.Trace(err) } if newRetryStrategy != h.config.RetryStrategy { return errors.Errorf("bouncing retrystrategy worker to get new values") } return nil }
go
func (h retryStrategyHandler) Handle(_ <-chan struct{}) error { newRetryStrategy, err := h.config.Facade.RetryStrategy(h.config.AgentTag) if err != nil { return errors.Trace(err) } if newRetryStrategy != h.config.RetryStrategy { return errors.Errorf("bouncing retrystrategy worker to get new values") } return nil }
[ "func", "(", "h", "retryStrategyHandler", ")", "Handle", "(", "_", "<-", "chan", "struct", "{", "}", ")", "error", "{", "newRetryStrategy", ",", "err", ":=", "h", ".", "config", ".", "Facade", ".", "RetryStrategy", "(", "h", ".", "config", ".", "AgentT...
// Handle is part of the watcher.NotifyHandler interface. // Whenever a valid change is encountered the worker bounces, // making the dependents bounce and get the new value
[ "Handle", "is", "part", "of", "the", "watcher", ".", "NotifyHandler", "interface", ".", "Whenever", "a", "valid", "change", "is", "encountered", "the", "worker", "bounces", "making", "the", "dependents", "bounce", "and", "get", "the", "new", "value" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/retrystrategy/worker.go#L84-L93
153,889
juju/juju
cmd/juju/controller/kill.go
NewKillCommand
func NewKillCommand() modelcmd.Command { cmd := killCommand{clock: clock.WallClock} cmd.environsDestroy = environs.Destroy return wrapKillCommand(&cmd) }
go
func NewKillCommand() modelcmd.Command { cmd := killCommand{clock: clock.WallClock} cmd.environsDestroy = environs.Destroy return wrapKillCommand(&cmd) }
[ "func", "NewKillCommand", "(", ")", "modelcmd", ".", "Command", "{", "cmd", ":=", "killCommand", "{", "clock", ":", "clock", ".", "WallClock", "}", "\n", "cmd", ".", "environsDestroy", "=", "environs", ".", "Destroy", "\n", "return", "wrapKillCommand", "(", ...
// NewKillCommand returns a command to kill a controller. Killing is a // forceful destroy.
[ "NewKillCommand", "returns", "a", "command", "to", "kill", "a", "controller", ".", "Killing", "is", "a", "forceful", "destroy", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/controller/kill.go#L47-L51
153,890
juju/juju
cmd/juju/controller/kill.go
wrapKillCommand
func wrapKillCommand(kill *killCommand) modelcmd.Command { return modelcmd.WrapController( kill, modelcmd.WrapControllerSkipControllerFlags, modelcmd.WrapControllerSkipDefaultController, ) }
go
func wrapKillCommand(kill *killCommand) modelcmd.Command { return modelcmd.WrapController( kill, modelcmd.WrapControllerSkipControllerFlags, modelcmd.WrapControllerSkipDefaultController, ) }
[ "func", "wrapKillCommand", "(", "kill", "*", "killCommand", ")", "modelcmd", ".", "Command", "{", "return", "modelcmd", ".", "WrapController", "(", "kill", ",", "modelcmd", ".", "WrapControllerSkipControllerFlags", ",", "modelcmd", ".", "WrapControllerSkipDefaultContr...
// wrapKillCommand provides the common wrapping used by tests and // the default NewKillCommand above.
[ "wrapKillCommand", "provides", "the", "common", "wrapping", "used", "by", "tests", "and", "the", "default", "NewKillCommand", "above", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/controller/kill.go#L55-L61
153,891
juju/juju
cmd/juju/controller/kill.go
DirectDestroyRemaining
func (c *killCommand) DirectDestroyRemaining(ctx *cmd.Context, api destroyControllerAPI) { hasErrors := false hostedConfig, err := api.HostedModelConfigs() if err != nil { hasErrors = true logger.Errorf("unable to retrieve hosted model config: %v", err) } ctrlUUID := "" // try to get controller UUID or just ignore. if ctrlCfg, err := api.ControllerConfig(); err == nil { ctrlUUID = ctrlCfg.ControllerUUID() } else { logger.Warningf("getting controller config from API: %v", err) } for _, model := range hostedConfig { if model.Error != nil { // We can only display model name here since // the error coming from api can be anything // including the parsing of the model owner tag. // Only model name is guaranteed to be set in the result // when an error is returned. hasErrors = true logger.Errorf("could not kill %s directly: %v", model.Name, model.Error) continue } ctx.Infof("Killing %s/%s directly", model.Owner.Id(), model.Name) cfg, err := config.New(config.NoDefaults, model.Config) if err != nil { logger.Errorf(err.Error()) hasErrors = true continue } p, err := environs.Provider(model.CloudSpec.Type) if err != nil { logger.Errorf(err.Error()) hasErrors = true continue } // TODO(caas) - only cloud providers support Destroy() if cloudProvider, ok := p.(environs.CloudEnvironProvider); ok { env, err := environs.Open(cloudProvider, environs.OpenParams{ ControllerUUID: ctrlUUID, Cloud: model.CloudSpec, Config: cfg, }) if err != nil { logger.Errorf(err.Error()) hasErrors = true continue } cloudCallCtx := cloudCallContext(c.credentialAPIFunctionForModel(model.Name)) if err := env.Destroy(cloudCallCtx); err != nil { logger.Errorf(err.Error()) hasErrors = true continue } } ctx.Infof(" done") } if hasErrors { logger.Errorf("there were problems destroying some models, manual intervention may be necessary to ensure resources are released") } else { ctx.Infof("All hosted models destroyed, cleaning up controller machines") } }
go
func (c *killCommand) DirectDestroyRemaining(ctx *cmd.Context, api destroyControllerAPI) { hasErrors := false hostedConfig, err := api.HostedModelConfigs() if err != nil { hasErrors = true logger.Errorf("unable to retrieve hosted model config: %v", err) } ctrlUUID := "" // try to get controller UUID or just ignore. if ctrlCfg, err := api.ControllerConfig(); err == nil { ctrlUUID = ctrlCfg.ControllerUUID() } else { logger.Warningf("getting controller config from API: %v", err) } for _, model := range hostedConfig { if model.Error != nil { // We can only display model name here since // the error coming from api can be anything // including the parsing of the model owner tag. // Only model name is guaranteed to be set in the result // when an error is returned. hasErrors = true logger.Errorf("could not kill %s directly: %v", model.Name, model.Error) continue } ctx.Infof("Killing %s/%s directly", model.Owner.Id(), model.Name) cfg, err := config.New(config.NoDefaults, model.Config) if err != nil { logger.Errorf(err.Error()) hasErrors = true continue } p, err := environs.Provider(model.CloudSpec.Type) if err != nil { logger.Errorf(err.Error()) hasErrors = true continue } // TODO(caas) - only cloud providers support Destroy() if cloudProvider, ok := p.(environs.CloudEnvironProvider); ok { env, err := environs.Open(cloudProvider, environs.OpenParams{ ControllerUUID: ctrlUUID, Cloud: model.CloudSpec, Config: cfg, }) if err != nil { logger.Errorf(err.Error()) hasErrors = true continue } cloudCallCtx := cloudCallContext(c.credentialAPIFunctionForModel(model.Name)) if err := env.Destroy(cloudCallCtx); err != nil { logger.Errorf(err.Error()) hasErrors = true continue } } ctx.Infof(" done") } if hasErrors { logger.Errorf("there were problems destroying some models, manual intervention may be necessary to ensure resources are released") } else { ctx.Infof("All hosted models destroyed, cleaning up controller machines") } }
[ "func", "(", "c", "*", "killCommand", ")", "DirectDestroyRemaining", "(", "ctx", "*", "cmd", ".", "Context", ",", "api", "destroyControllerAPI", ")", "{", "hasErrors", ":=", "false", "\n", "hostedConfig", ",", "err", ":=", "api", ".", "HostedModelConfigs", "...
// DirectDestroyRemaining will attempt to directly destroy any remaining // models that have machines left.
[ "DirectDestroyRemaining", "will", "attempt", "to", "directly", "destroy", "any", "remaining", "models", "that", "have", "machines", "left", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/controller/kill.go#L180-L244
153,892
juju/juju
cmd/juju/controller/kill.go
WaitForModels
func (c *killCommand) WaitForModels(ctx *cmd.Context, api destroyControllerAPI, uuid string) error { thirtySeconds := (time.Second * 30) updateStatus := newTimedStatusUpdater(ctx, api, uuid, c.clock) envStatus := updateStatus(0) lastStatus := envStatus.controller lastChange := c.clock.Now().Truncate(time.Second) deadline := lastChange.Add(c.timeout) // Check for both undead models and live machines, as machines may be // in the controller model. for ; hasUnreclaimedResources(envStatus) && (deadline.After(c.clock.Now())); envStatus = updateStatus(5 * time.Second) { now := c.clock.Now().Truncate(time.Second) if envStatus.controller != lastStatus { lastStatus = envStatus.controller lastChange = now deadline = lastChange.Add(c.timeout) } timeSinceLastChange := now.Sub(lastChange) timeUntilDestruction := deadline.Sub(now) warning := "" // We want to show the warning if it has been more than 30 seconds since // the last change, or we are within 30 seconds of our timeout. if timeSinceLastChange > thirtySeconds || timeUntilDestruction < thirtySeconds { warning = fmt.Sprintf(", will kill machines directly in %s", timeUntilDestruction) } ctx.Infof("%s%s", fmtCtrStatus(envStatus.controller), warning) for _, modelStatus := range envStatus.models { ctx.Verbosef(fmtModelStatus(modelStatus)) } } if hasUnreclaimedResources(envStatus) { return errors.New("timed out") } else { ctx.Infof("All hosted models reclaimed, cleaning up controller machines") } return nil }
go
func (c *killCommand) WaitForModels(ctx *cmd.Context, api destroyControllerAPI, uuid string) error { thirtySeconds := (time.Second * 30) updateStatus := newTimedStatusUpdater(ctx, api, uuid, c.clock) envStatus := updateStatus(0) lastStatus := envStatus.controller lastChange := c.clock.Now().Truncate(time.Second) deadline := lastChange.Add(c.timeout) // Check for both undead models and live machines, as machines may be // in the controller model. for ; hasUnreclaimedResources(envStatus) && (deadline.After(c.clock.Now())); envStatus = updateStatus(5 * time.Second) { now := c.clock.Now().Truncate(time.Second) if envStatus.controller != lastStatus { lastStatus = envStatus.controller lastChange = now deadline = lastChange.Add(c.timeout) } timeSinceLastChange := now.Sub(lastChange) timeUntilDestruction := deadline.Sub(now) warning := "" // We want to show the warning if it has been more than 30 seconds since // the last change, or we are within 30 seconds of our timeout. if timeSinceLastChange > thirtySeconds || timeUntilDestruction < thirtySeconds { warning = fmt.Sprintf(", will kill machines directly in %s", timeUntilDestruction) } ctx.Infof("%s%s", fmtCtrStatus(envStatus.controller), warning) for _, modelStatus := range envStatus.models { ctx.Verbosef(fmtModelStatus(modelStatus)) } } if hasUnreclaimedResources(envStatus) { return errors.New("timed out") } else { ctx.Infof("All hosted models reclaimed, cleaning up controller machines") } return nil }
[ "func", "(", "c", "*", "killCommand", ")", "WaitForModels", "(", "ctx", "*", "cmd", ".", "Context", ",", "api", "destroyControllerAPI", ",", "uuid", "string", ")", "error", "{", "thirtySeconds", ":=", "(", "time", ".", "Second", "*", "30", ")", "\n", "...
// WaitForModels will wait for the models to bring themselves down nicely. // It will return the UUIDs of any models that need to be removed forceably.
[ "WaitForModels", "will", "wait", "for", "the", "models", "to", "bring", "themselves", "down", "nicely", ".", "It", "will", "return", "the", "UUIDs", "of", "any", "models", "that", "need", "to", "be", "removed", "forceably", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/controller/kill.go#L261-L297
153,893
juju/juju
resource/context/internal/context.go
ContextDownload
func ContextDownload(deps ContextDownloadDeps) (path string, err error) { // TODO(katco): Potential race-condition: two commands running at // once. Solve via collision using os.Mkdir() with a uniform // temp dir name (e.g. "<datadir>/.<res name>.download")? resDirSpec := deps.NewContextDirectorySpec() remote, err := deps.OpenResource() if err != nil { return "", errors.Trace(err) } defer deps.CloseAndLog(remote, "remote resource") path = resDirSpec.Resolve(remote.Info().Path) isUpToDate, err := resDirSpec.IsUpToDate(remote.Content()) if err != nil { return "", errors.Trace(err) } if isUpToDate { // We're up to date already! return path, nil } if err := deps.Download(resDirSpec, remote); err != nil { return "", errors.Trace(err) } return path, nil }
go
func ContextDownload(deps ContextDownloadDeps) (path string, err error) { // TODO(katco): Potential race-condition: two commands running at // once. Solve via collision using os.Mkdir() with a uniform // temp dir name (e.g. "<datadir>/.<res name>.download")? resDirSpec := deps.NewContextDirectorySpec() remote, err := deps.OpenResource() if err != nil { return "", errors.Trace(err) } defer deps.CloseAndLog(remote, "remote resource") path = resDirSpec.Resolve(remote.Info().Path) isUpToDate, err := resDirSpec.IsUpToDate(remote.Content()) if err != nil { return "", errors.Trace(err) } if isUpToDate { // We're up to date already! return path, nil } if err := deps.Download(resDirSpec, remote); err != nil { return "", errors.Trace(err) } return path, nil }
[ "func", "ContextDownload", "(", "deps", "ContextDownloadDeps", ")", "(", "path", "string", ",", "err", "error", ")", "{", "// TODO(katco): Potential race-condition: two commands running at", "// once. Solve via collision using os.Mkdir() with a uniform", "// temp dir name (e.g. \"<da...
// ContextDownload downloads the named resource and returns the path // to which it was downloaded. If the resource does not exist or has // not been uploaded yet then errors.NotFound is returned. // // Note that the downloaded file is checked for correctness.
[ "ContextDownload", "downloads", "the", "named", "resource", "and", "returns", "the", "path", "to", "which", "it", "was", "downloaded", ".", "If", "the", "resource", "does", "not", "exist", "or", "has", "not", "been", "uploaded", "yet", "then", "errors", ".",...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/resource/context/internal/context.go#L17-L45
153,894
juju/juju
resource/context/internal/context.go
NewContextDirectorySpec
func NewContextDirectorySpec(dataDir, name string, deps DirectorySpecDeps) ContextDirectorySpec { return &contextDirectorySpec{ DirectorySpec: NewDirectorySpec(dataDir, name, deps), } }
go
func NewContextDirectorySpec(dataDir, name string, deps DirectorySpecDeps) ContextDirectorySpec { return &contextDirectorySpec{ DirectorySpec: NewDirectorySpec(dataDir, name, deps), } }
[ "func", "NewContextDirectorySpec", "(", "dataDir", ",", "name", "string", ",", "deps", "DirectorySpecDeps", ")", "ContextDirectorySpec", "{", "return", "&", "contextDirectorySpec", "{", "DirectorySpec", ":", "NewDirectorySpec", "(", "dataDir", ",", "name", ",", "dep...
// NewContextDirectorySpec returns a new directory spec for the context.
[ "NewContextDirectorySpec", "returns", "a", "new", "directory", "spec", "for", "the", "context", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/resource/context/internal/context.go#L80-L84
153,895
juju/juju
api/instancemutater/mocks/caller_mock.go
NewMockAPICaller
func NewMockAPICaller(ctrl *gomock.Controller) *MockAPICaller { mock := &MockAPICaller{ctrl: ctrl} mock.recorder = &MockAPICallerMockRecorder{mock} return mock }
go
func NewMockAPICaller(ctrl *gomock.Controller) *MockAPICaller { mock := &MockAPICaller{ctrl: ctrl} mock.recorder = &MockAPICallerMockRecorder{mock} return mock }
[ "func", "NewMockAPICaller", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockAPICaller", "{", "mock", ":=", "&", "MockAPICaller", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockAPICallerMockRecorder", "{", "mock", ...
// NewMockAPICaller creates a new mock instance
[ "NewMockAPICaller", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/instancemutater/mocks/caller_mock.go#L30-L34
153,896
juju/juju
api/instancemutater/mocks/caller_mock.go
BakeryClient
func (m *MockAPICaller) BakeryClient() *httpbakery.Client { ret := m.ctrl.Call(m, "BakeryClient") ret0, _ := ret[0].(*httpbakery.Client) return ret0 }
go
func (m *MockAPICaller) BakeryClient() *httpbakery.Client { ret := m.ctrl.Call(m, "BakeryClient") ret0, _ := ret[0].(*httpbakery.Client) return ret0 }
[ "func", "(", "m", "*", "MockAPICaller", ")", "BakeryClient", "(", ")", "*", "httpbakery", ".", "Client", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", ...
// BakeryClient mocks base method
[ "BakeryClient", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/instancemutater/mocks/caller_mock.go#L54-L58
153,897
juju/juju
api/instancemutater/mocks/caller_mock.go
BestFacadeVersion
func (mr *MockAPICallerMockRecorder) BestFacadeVersion(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BestFacadeVersion", reflect.TypeOf((*MockAPICaller)(nil).BestFacadeVersion), arg0) }
go
func (mr *MockAPICallerMockRecorder) BestFacadeVersion(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BestFacadeVersion", reflect.TypeOf((*MockAPICaller)(nil).BestFacadeVersion), arg0) }
[ "func", "(", "mr", "*", "MockAPICallerMockRecorder", ")", "BestFacadeVersion", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",",...
// BestFacadeVersion indicates an expected call of BestFacadeVersion
[ "BestFacadeVersion", "indicates", "an", "expected", "call", "of", "BestFacadeVersion" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/instancemutater/mocks/caller_mock.go#L73-L75
153,898
juju/juju
api/instancemutater/mocks/caller_mock.go
ConnectControllerStream
func (m *MockAPICaller) ConnectControllerStream(arg0 string, arg1 url.Values, arg2 http.Header) (base.Stream, error) { ret := m.ctrl.Call(m, "ConnectControllerStream", arg0, arg1, arg2) ret0, _ := ret[0].(base.Stream) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockAPICaller) ConnectControllerStream(arg0 string, arg1 url.Values, arg2 http.Header) (base.Stream, error) { ret := m.ctrl.Call(m, "ConnectControllerStream", arg0, arg1, arg2) ret0, _ := ret[0].(base.Stream) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockAPICaller", ")", "ConnectControllerStream", "(", "arg0", "string", ",", "arg1", "url", ".", "Values", ",", "arg2", "http", ".", "Header", ")", "(", "base", ".", "Stream", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctr...
// ConnectControllerStream mocks base method
[ "ConnectControllerStream", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/instancemutater/mocks/caller_mock.go#L78-L83
153,899
juju/juju
api/instancemutater/mocks/caller_mock.go
ConnectStream
func (m *MockAPICaller) ConnectStream(arg0 string, arg1 url.Values) (base.Stream, error) { ret := m.ctrl.Call(m, "ConnectStream", arg0, arg1) ret0, _ := ret[0].(base.Stream) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockAPICaller) ConnectStream(arg0 string, arg1 url.Values) (base.Stream, error) { ret := m.ctrl.Call(m, "ConnectStream", arg0, arg1) ret0, _ := ret[0].(base.Stream) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockAPICaller", ")", "ConnectStream", "(", "arg0", "string", ",", "arg1", "url", ".", "Values", ")", "(", "base", ".", "Stream", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\""...
// ConnectStream mocks base method
[ "ConnectStream", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/instancemutater/mocks/caller_mock.go#L91-L96