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
156,700
juju/juju
cmd/juju/commands/upgrademodel.go
makeUploadVersion
func makeUploadVersion(vers version.Number, existing coretools.Versions) version.Number { vers.Build++ for _, t := range existing { if t.AgentVersion().Major != vers.Major || t.AgentVersion().Minor != vers.Minor || t.AgentVersion().Patch != vers.Patch { continue } if t.AgentVersion().Build >= vers.Build { vers.Build = t.AgentVersion().Build + 1 } } return vers }
go
func makeUploadVersion(vers version.Number, existing coretools.Versions) version.Number { vers.Build++ for _, t := range existing { if t.AgentVersion().Major != vers.Major || t.AgentVersion().Minor != vers.Minor || t.AgentVersion().Patch != vers.Patch { continue } if t.AgentVersion().Build >= vers.Build { vers.Build = t.AgentVersion().Build + 1 } } return vers }
[ "func", "makeUploadVersion", "(", "vers", "version", ".", "Number", ",", "existing", "coretools", ".", "Versions", ")", "version", ".", "Number", "{", "vers", ".", "Build", "++", "\n", "for", "_", ",", "t", ":=", "range", "existing", "{", "if", "t", "....
// makeUploadVersion returns a copy of the supplied version with a build number // higher than any of the supplied tools that share its major, minor and patch.
[ "makeUploadVersion", "returns", "a", "copy", "of", "the", "supplied", "version", "with", "a", "build", "number", "higher", "than", "any", "of", "the", "supplied", "tools", "that", "share", "its", "major", "minor", "and", "patch", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/commands/upgrademodel.go#L836-L847
156,701
juju/juju
worker/raft/manifold.go
Manifold
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{ config.ClockName, config.AgentName, config.TransportName, }, Start: config.start, Output: raftOutput, } }
go
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{ config.ClockName, config.AgentName, config.TransportName, }, Start: config.start, Output: raftOutput, } }
[ "func", "Manifold", "(", "config", "ManifoldConfig", ")", "dependency", ".", "Manifold", "{", "return", "dependency", ".", "Manifold", "{", "Inputs", ":", "[", "]", "string", "{", "config", ".", "ClockName", ",", "config", ".", "AgentName", ",", "config", ...
// Manifold returns a dependency.Manifold that will run a raft worker.
[ "Manifold", "returns", "a", "dependency", ".", "Manifold", "that", "will", "run", "a", "raft", "worker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/raft/manifold.go#L56-L66
156,702
juju/juju
cmd/juju/charmcmd/charm.go
NewSuperCommand
func NewSuperCommand() *Command { charmCmd := &Command{ SuperCommand: *cmd.NewSuperCommand( cmd.SuperCommandParams{ Name: "charm", Doc: resource.DeprecatedSince + charmDoc, UsagePrefix: "juju", Purpose: resource.Deprecated + charmPurpose, }, ), } charmCmd.Register(resource.NewListCharmResourcesCommand(nil)) return charmCmd }
go
func NewSuperCommand() *Command { charmCmd := &Command{ SuperCommand: *cmd.NewSuperCommand( cmd.SuperCommandParams{ Name: "charm", Doc: resource.DeprecatedSince + charmDoc, UsagePrefix: "juju", Purpose: resource.Deprecated + charmPurpose, }, ), } charmCmd.Register(resource.NewListCharmResourcesCommand(nil)) return charmCmd }
[ "func", "NewSuperCommand", "(", ")", "*", "Command", "{", "charmCmd", ":=", "&", "Command", "{", "SuperCommand", ":", "*", "cmd", ".", "NewSuperCommand", "(", "cmd", ".", "SuperCommandParams", "{", "Name", ":", "\"", "\"", ",", "Doc", ":", "resource", "....
// NewSuperCommand returns a new charm super-command.
[ "NewSuperCommand", "returns", "a", "new", "charm", "super", "-", "command", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/charmcmd/charm.go#L25-L38
156,703
juju/juju
environs/manual/common.go
RecordMachineInState
func RecordMachineInState(client ProvisioningClientAPI, machineParams params.AddMachineParams) (machineId string, err error) { results, err := client.AddMachines([]params.AddMachineParams{machineParams}) if err != nil { return "", errors.Trace(err) } // Currently, only one machine is added, but in future there may be several added in one call. machineInfo := results[0] if machineInfo.Error != nil { return "", machineInfo.Error } return machineInfo.Machine, nil }
go
func RecordMachineInState(client ProvisioningClientAPI, machineParams params.AddMachineParams) (machineId string, err error) { results, err := client.AddMachines([]params.AddMachineParams{machineParams}) if err != nil { return "", errors.Trace(err) } // Currently, only one machine is added, but in future there may be several added in one call. machineInfo := results[0] if machineInfo.Error != nil { return "", machineInfo.Error } return machineInfo.Machine, nil }
[ "func", "RecordMachineInState", "(", "client", "ProvisioningClientAPI", ",", "machineParams", "params", ".", "AddMachineParams", ")", "(", "machineId", "string", ",", "err", "error", ")", "{", "results", ",", "err", ":=", "client", ".", "AddMachines", "(", "[", ...
// RecordMachineInState records and saves into the state machine the provisioned machine
[ "RecordMachineInState", "records", "and", "saves", "into", "the", "state", "machine", "the", "provisioned", "machine" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/manual/common.go#L19-L30
156,704
juju/juju
api/modelconfig/modelconfig.go
ModelGet
func (c *Client) ModelGet() (map[string]interface{}, error) { result := params.ModelConfigResults{} err := c.facade.FacadeCall("ModelGet", nil, &result) if err != nil { return nil, errors.Trace(err) } values := make(map[string]interface{}) for name, val := range result.Config { values[name] = val.Value } return values, nil }
go
func (c *Client) ModelGet() (map[string]interface{}, error) { result := params.ModelConfigResults{} err := c.facade.FacadeCall("ModelGet", nil, &result) if err != nil { return nil, errors.Trace(err) } values := make(map[string]interface{}) for name, val := range result.Config { values[name] = val.Value } return values, nil }
[ "func", "(", "c", "*", "Client", ")", "ModelGet", "(", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "result", ":=", "params", ".", "ModelConfigResults", "{", "}", "\n", "err", ":=", "c", ".", "facade", ".", ...
// ModelGet returns all model settings.
[ "ModelGet", "returns", "all", "model", "settings", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelconfig/modelconfig.go#L29-L40
156,705
juju/juju
api/modelconfig/modelconfig.go
ModelGetWithMetadata
func (c *Client) ModelGetWithMetadata() (config.ConfigValues, error) { result := params.ModelConfigResults{} err := c.facade.FacadeCall("ModelGet", nil, &result) if err != nil { return nil, errors.Trace(err) } values := make(config.ConfigValues) for name, val := range result.Config { values[name] = config.ConfigValue{ Value: val.Value, Source: val.Source, } } return values, nil }
go
func (c *Client) ModelGetWithMetadata() (config.ConfigValues, error) { result := params.ModelConfigResults{} err := c.facade.FacadeCall("ModelGet", nil, &result) if err != nil { return nil, errors.Trace(err) } values := make(config.ConfigValues) for name, val := range result.Config { values[name] = config.ConfigValue{ Value: val.Value, Source: val.Source, } } return values, nil }
[ "func", "(", "c", "*", "Client", ")", "ModelGetWithMetadata", "(", ")", "(", "config", ".", "ConfigValues", ",", "error", ")", "{", "result", ":=", "params", ".", "ModelConfigResults", "{", "}", "\n", "err", ":=", "c", ".", "facade", ".", "FacadeCall", ...
// ModelGetWithMetadata returns all model settings along with extra // metadata like the source of the setting value.
[ "ModelGetWithMetadata", "returns", "all", "model", "settings", "along", "with", "extra", "metadata", "like", "the", "source", "of", "the", "setting", "value", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelconfig/modelconfig.go#L44-L58
156,706
juju/juju
api/modelconfig/modelconfig.go
ModelSet
func (c *Client) ModelSet(config map[string]interface{}) error { args := params.ModelSet{Config: config} return c.facade.FacadeCall("ModelSet", args, nil) }
go
func (c *Client) ModelSet(config map[string]interface{}) error { args := params.ModelSet{Config: config} return c.facade.FacadeCall("ModelSet", args, nil) }
[ "func", "(", "c", "*", "Client", ")", "ModelSet", "(", "config", "map", "[", "string", "]", "interface", "{", "}", ")", "error", "{", "args", ":=", "params", ".", "ModelSet", "{", "Config", ":", "config", "}", "\n", "return", "c", ".", "facade", "....
// ModelSet sets the given key-value pairs in the model.
[ "ModelSet", "sets", "the", "given", "key", "-", "value", "pairs", "in", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelconfig/modelconfig.go#L61-L64
156,707
juju/juju
api/modelconfig/modelconfig.go
ModelUnset
func (c *Client) ModelUnset(keys ...string) error { args := params.ModelUnset{Keys: keys} return c.facade.FacadeCall("ModelUnset", args, nil) }
go
func (c *Client) ModelUnset(keys ...string) error { args := params.ModelUnset{Keys: keys} return c.facade.FacadeCall("ModelUnset", args, nil) }
[ "func", "(", "c", "*", "Client", ")", "ModelUnset", "(", "keys", "...", "string", ")", "error", "{", "args", ":=", "params", ".", "ModelUnset", "{", "Keys", ":", "keys", "}", "\n", "return", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", "...
// ModelUnset sets the given key-value pairs in the model.
[ "ModelUnset", "sets", "the", "given", "key", "-", "value", "pairs", "in", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelconfig/modelconfig.go#L67-L70
156,708
juju/juju
api/modelconfig/modelconfig.go
SetSLALevel
func (c *Client) SetSLALevel(level, owner string, creds []byte) error { args := params.ModelSLA{ ModelSLAInfo: params.ModelSLAInfo{ Level: level, Owner: owner, }, Credentials: creds, } return c.facade.FacadeCall("SetSLALevel", args, nil) }
go
func (c *Client) SetSLALevel(level, owner string, creds []byte) error { args := params.ModelSLA{ ModelSLAInfo: params.ModelSLAInfo{ Level: level, Owner: owner, }, Credentials: creds, } return c.facade.FacadeCall("SetSLALevel", args, nil) }
[ "func", "(", "c", "*", "Client", ")", "SetSLALevel", "(", "level", ",", "owner", "string", ",", "creds", "[", "]", "byte", ")", "error", "{", "args", ":=", "params", ".", "ModelSLA", "{", "ModelSLAInfo", ":", "params", ".", "ModelSLAInfo", "{", "Level"...
// SetSLALevel sets the support level for the given model.
[ "SetSLALevel", "sets", "the", "support", "level", "for", "the", "given", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelconfig/modelconfig.go#L73-L82
156,709
juju/juju
api/modelconfig/modelconfig.go
SLALevel
func (c *Client) SLALevel() (string, error) { var result params.StringResult err := c.facade.FacadeCall("SLALevel", nil, &result) if err != nil { return "", errors.Trace(err) } return result.Result, nil }
go
func (c *Client) SLALevel() (string, error) { var result params.StringResult err := c.facade.FacadeCall("SLALevel", nil, &result) if err != nil { return "", errors.Trace(err) } return result.Result, nil }
[ "func", "(", "c", "*", "Client", ")", "SLALevel", "(", ")", "(", "string", ",", "error", ")", "{", "var", "result", "params", ".", "StringResult", "\n", "err", ":=", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "nil", ",", "&", "r...
// SLALevel gets the support level for the given model.
[ "SLALevel", "gets", "the", "support", "level", "for", "the", "given", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelconfig/modelconfig.go#L85-L92
156,710
juju/juju
api/modelconfig/modelconfig.go
Sequences
func (c *Client) Sequences() (map[string]int, error) { if c.BestAPIVersion() < 2 { return nil, errors.NotSupportedf("Sequences on v1 facade") } var result params.ModelSequencesResult err := c.facade.FacadeCall("Sequences", nil, &result) if err != nil { return nil, errors.Trace(err) } return result.Sequences, nil }
go
func (c *Client) Sequences() (map[string]int, error) { if c.BestAPIVersion() < 2 { return nil, errors.NotSupportedf("Sequences on v1 facade") } var result params.ModelSequencesResult err := c.facade.FacadeCall("Sequences", nil, &result) if err != nil { return nil, errors.Trace(err) } return result.Sequences, nil }
[ "func", "(", "c", "*", "Client", ")", "Sequences", "(", ")", "(", "map", "[", "string", "]", "int", ",", "error", ")", "{", "if", "c", ".", "BestAPIVersion", "(", ")", "<", "2", "{", "return", "nil", ",", "errors", ".", "NotSupportedf", "(", "\""...
// Sequences returns all sequence names and next values.
[ "Sequences", "returns", "all", "sequence", "names", "and", "next", "values", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/modelconfig/modelconfig.go#L95-L105
156,711
juju/juju
apiserver/facades/controller/statushistory/pruner.go
Prune
func (api *API) Prune(p params.StatusHistoryPruneArgs) error { if !api.authorizer.AuthController() { return common.ErrPerm } return state.PruneStatusHistory(api.st, p.MaxHistoryTime, p.MaxHistoryMB) }
go
func (api *API) Prune(p params.StatusHistoryPruneArgs) error { if !api.authorizer.AuthController() { return common.ErrPerm } return state.PruneStatusHistory(api.st, p.MaxHistoryTime, p.MaxHistoryMB) }
[ "func", "(", "api", "*", "API", ")", "Prune", "(", "p", "params", ".", "StatusHistoryPruneArgs", ")", "error", "{", "if", "!", "api", ".", "authorizer", ".", "AuthController", "(", ")", "{", "return", "common", ".", "ErrPerm", "\n", "}", "\n", "return"...
// Prune endpoint removes status history entries until // only the ones newer than now - p.MaxHistoryTime remain and // the history is smaller than p.MaxHistoryMB.
[ "Prune", "endpoint", "removes", "status", "history", "entries", "until", "only", "the", "ones", "newer", "than", "now", "-", "p", ".", "MaxHistoryTime", "remain", "and", "the", "history", "is", "smaller", "than", "p", ".", "MaxHistoryMB", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/controller/statushistory/pruner.go#L37-L42
156,712
juju/juju
upgrades/steps_245.go
stepsFor245
func stepsFor245() []Step { return []Step{ &upgradeStep{ description: "update exec.start.sh log path if incorrect", targets: []Target{AllMachines}, run: correctServiceFileLogPath, }, } }
go
func stepsFor245() []Step { return []Step{ &upgradeStep{ description: "update exec.start.sh log path if incorrect", targets: []Target{AllMachines}, run: correctServiceFileLogPath, }, } }
[ "func", "stepsFor245", "(", ")", "[", "]", "Step", "{", "return", "[", "]", "Step", "{", "&", "upgradeStep", "{", "description", ":", "\"", "\"", ",", "targets", ":", "[", "]", "Target", "{", "AllMachines", "}", ",", "run", ":", "correctServiceFileLogP...
// stepsFor245 returns upgrade steps for Juju 2.4.5
[ "stepsFor245", "returns", "upgrade", "steps", "for", "Juju", "2", ".", "4", ".", "5" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/upgrades/steps_245.go#L13-L21
156,713
juju/juju
worker/uniter/runner/jujuc/server.go
CommandNames
func CommandNames() (names []string) { for name := range allEnabledCommands() { names = append(names, name) } sort.Strings(names) return }
go
func CommandNames() (names []string) { for name := range allEnabledCommands() { names = append(names, name) } sort.Strings(names) return }
[ "func", "CommandNames", "(", ")", "(", "names", "[", "]", "string", ")", "{", "for", "name", ":=", "range", "allEnabledCommands", "(", ")", "{", "names", "=", "append", "(", "names", ",", "name", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "...
// CommandNames returns the names of all jujuc commands.
[ "CommandNames", "returns", "the", "names", "of", "all", "jujuc", "commands", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/server.go#L99-L105
156,714
juju/juju
worker/uniter/runner/jujuc/server.go
NewCommand
func NewCommand(ctx Context, name string) (cmd.Command, error) { f := allEnabledCommands()[name] if f == nil { return nil, errors.Errorf("unknown command: %s", name) } command, err := f(ctx) if err != nil { return nil, errors.Trace(err) } return command, nil }
go
func NewCommand(ctx Context, name string) (cmd.Command, error) { f := allEnabledCommands()[name] if f == nil { return nil, errors.Errorf("unknown command: %s", name) } command, err := f(ctx) if err != nil { return nil, errors.Trace(err) } return command, nil }
[ "func", "NewCommand", "(", "ctx", "Context", ",", "name", "string", ")", "(", "cmd", ".", "Command", ",", "error", ")", "{", "f", ":=", "allEnabledCommands", "(", ")", "[", "name", "]", "\n", "if", "f", "==", "nil", "{", "return", "nil", ",", "erro...
// NewCommand returns an instance of the named Command, initialized to execute // against the supplied Context.
[ "NewCommand", "returns", "an", "instance", "of", "the", "named", "Command", "initialized", "to", "execute", "against", "the", "supplied", "Context", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/server.go#L109-L119
156,715
juju/juju
worker/uniter/runner/jujuc/server.go
Main
func (j *Jujuc) Main(req Request, resp *exec.ExecResponse) error { if req.CommandName == "" { return badReqErrorf("command not specified") } if !filepath.IsAbs(req.Dir) { return badReqErrorf("Dir is not absolute") } c, err := j.getCmd(req.ContextId, req.CommandName) if err != nil { return badReqErrorf("%s", err) } var stdin io.Reader if req.StdinSet { stdin = bytes.NewReader(req.Stdin) } else { // noStdinReader will error with ErrNoStdin // if its Read method is called. stdin = noStdinReader{} } var stdout, stderr bytes.Buffer ctx := &cmd.Context{ Dir: req.Dir, Stdin: stdin, Stdout: &stdout, Stderr: &stderr, } j.mu.Lock() defer j.mu.Unlock() // Beware, reducing the log level of the following line will lead // to passwords leaking if passed as args. logger.Tracef("running hook tool %q %q", req.CommandName, req.Args) logger.Debugf("running hook tool %q", req.CommandName) logger.Tracef("hook context id %q; dir %q", req.ContextId, req.Dir) wrapper := &cmdWrapper{c, nil} resp.Code = cmd.Main(wrapper, ctx, req.Args) if errors.Cause(wrapper.err) == ErrNoStdin { return ErrNoStdin } resp.Stdout = stdout.Bytes() resp.Stderr = stderr.Bytes() return nil }
go
func (j *Jujuc) Main(req Request, resp *exec.ExecResponse) error { if req.CommandName == "" { return badReqErrorf("command not specified") } if !filepath.IsAbs(req.Dir) { return badReqErrorf("Dir is not absolute") } c, err := j.getCmd(req.ContextId, req.CommandName) if err != nil { return badReqErrorf("%s", err) } var stdin io.Reader if req.StdinSet { stdin = bytes.NewReader(req.Stdin) } else { // noStdinReader will error with ErrNoStdin // if its Read method is called. stdin = noStdinReader{} } var stdout, stderr bytes.Buffer ctx := &cmd.Context{ Dir: req.Dir, Stdin: stdin, Stdout: &stdout, Stderr: &stderr, } j.mu.Lock() defer j.mu.Unlock() // Beware, reducing the log level of the following line will lead // to passwords leaking if passed as args. logger.Tracef("running hook tool %q %q", req.CommandName, req.Args) logger.Debugf("running hook tool %q", req.CommandName) logger.Tracef("hook context id %q; dir %q", req.ContextId, req.Dir) wrapper := &cmdWrapper{c, nil} resp.Code = cmd.Main(wrapper, ctx, req.Args) if errors.Cause(wrapper.err) == ErrNoStdin { return ErrNoStdin } resp.Stdout = stdout.Bytes() resp.Stderr = stderr.Bytes() return nil }
[ "func", "(", "j", "*", "Jujuc", ")", "Main", "(", "req", "Request", ",", "resp", "*", "exec", ".", "ExecResponse", ")", "error", "{", "if", "req", ".", "CommandName", "==", "\"", "\"", "{", "return", "badReqErrorf", "(", "\"", "\"", ")", "\n", "}",...
// Main runs the Command specified by req, and fills in resp. A single command // is run at a time.
[ "Main", "runs", "the", "Command", "specified", "by", "req", "and", "fills", "in", "resp", ".", "A", "single", "command", "is", "run", "at", "a", "time", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/server.go#L151-L192
156,716
juju/juju
worker/uniter/runner/jujuc/server.go
NewServer
func NewServer(getCmd CmdGetter, socketPath string) (*Server, error) { server := rpc.NewServer() if err := server.Register(&Jujuc{getCmd: getCmd}); err != nil { return nil, err } listener, err := sockets.Listen(socketPath) if err != nil { return nil, errors.Annotate(err, "listening to jujuc socket") } s := &Server{ socketPath: socketPath, listener: listener, server: server, closed: make(chan bool), closing: make(chan bool), } return s, nil }
go
func NewServer(getCmd CmdGetter, socketPath string) (*Server, error) { server := rpc.NewServer() if err := server.Register(&Jujuc{getCmd: getCmd}); err != nil { return nil, err } listener, err := sockets.Listen(socketPath) if err != nil { return nil, errors.Annotate(err, "listening to jujuc socket") } s := &Server{ socketPath: socketPath, listener: listener, server: server, closed: make(chan bool), closing: make(chan bool), } return s, nil }
[ "func", "NewServer", "(", "getCmd", "CmdGetter", ",", "socketPath", "string", ")", "(", "*", "Server", ",", "error", ")", "{", "server", ":=", "rpc", ".", "NewServer", "(", ")", "\n", "if", "err", ":=", "server", ".", "Register", "(", "&", "Jujuc", "...
// NewServer creates an RPC server bound to socketPath, which can execute // remote command invocations against an appropriate Context. It will not // actually do so until Run is called.
[ "NewServer", "creates", "an", "RPC", "server", "bound", "to", "socketPath", "which", "can", "execute", "remote", "command", "invocations", "against", "an", "appropriate", "Context", ".", "It", "will", "not", "actually", "do", "so", "until", "Run", "is", "calle...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/server.go#L208-L225
156,717
juju/juju
worker/charmrevision/worker.go
Validate
func (config Config) Validate() error { if config.RevisionUpdater == nil { return errors.NotValidf("nil RevisionUpdater") } if config.Clock == nil { return errors.NotValidf("nil Clock") } if config.Period <= 0 { return errors.NotValidf("non-positive Period") } return nil }
go
func (config Config) Validate() error { if config.RevisionUpdater == nil { return errors.NotValidf("nil RevisionUpdater") } if config.Clock == nil { return errors.NotValidf("nil Clock") } if config.Period <= 0 { return errors.NotValidf("non-positive Period") } return nil }
[ "func", "(", "config", "Config", ")", "Validate", "(", ")", "error", "{", "if", "config", ".", "RevisionUpdater", "==", "nil", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "config", ".", "Clock", "==", "nil"...
// Validate returns an error if the configuration cannot be expected // to start a functional worker.
[ "Validate", "returns", "an", "error", "if", "the", "configuration", "cannot", "be", "expected", "to", "start", "a", "functional", "worker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/charmrevision/worker.go#L46-L57
156,718
juju/juju
worker/charmrevision/worker.go
NewWorker
func NewWorker(config Config) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } w := &revisionUpdateWorker{ config: config, } w.tomb.Go(w.loop) return w, nil }
go
func NewWorker(config Config) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } w := &revisionUpdateWorker{ config: config, } w.tomb.Go(w.loop) return w, nil }
[ "func", "NewWorker", "(", "config", "Config", ")", "(", "worker", ".", "Worker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err",...
// NewWorker returns a worker that calls UpdateLatestRevisions on the // configured RevisionUpdater, once when started and subsequently every // Period.
[ "NewWorker", "returns", "a", "worker", "that", "calls", "UpdateLatestRevisions", "on", "the", "configured", "RevisionUpdater", "once", "when", "started", "and", "subsequently", "every", "Period", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/charmrevision/worker.go#L62-L71
156,719
juju/juju
provider/oracle/network/environ.go
NewEnviron
func NewEnviron(api NetworkingAPI, env commonProvider.OracleInstancer) *Environ { return &Environ{ client: api, env: env, } }
go
func NewEnviron(api NetworkingAPI, env commonProvider.OracleInstancer) *Environ { return &Environ{ client: api, env: env, } }
[ "func", "NewEnviron", "(", "api", "NetworkingAPI", ",", "env", "commonProvider", ".", "OracleInstancer", ")", "*", "Environ", "{", "return", "&", "Environ", "{", "client", ":", "api", ",", "env", ":", "env", ",", "}", "\n", "}" ]
// NewEnviron returns a new instance of Environ
[ "NewEnviron", "returns", "a", "new", "instance", "of", "Environ" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/environ.go#L51-L56
156,720
juju/juju
provider/oracle/network/environ.go
getSubnetInfoAsMap
func (e Environ) getSubnetInfoAsMap() (map[string]network.SubnetInfo, error) { subnets, err := e.getSubnetInfo() if err != nil { return nil, err } ret := make(map[string]network.SubnetInfo, len(subnets)) for _, val := range subnets { ret[string(val.ProviderId)] = val } return ret, nil }
go
func (e Environ) getSubnetInfoAsMap() (map[string]network.SubnetInfo, error) { subnets, err := e.getSubnetInfo() if err != nil { return nil, err } ret := make(map[string]network.SubnetInfo, len(subnets)) for _, val := range subnets { ret[string(val.ProviderId)] = val } return ret, nil }
[ "func", "(", "e", "Environ", ")", "getSubnetInfoAsMap", "(", ")", "(", "map", "[", "string", "]", "network", ".", "SubnetInfo", ",", "error", ")", "{", "subnets", ",", "err", ":=", "e", ".", "getSubnetInfo", "(", ")", "\n", "if", "err", "!=", "nil", ...
// getSubnetInfoAsMap will return the subnet information // for the getSubnetInfo as a map rather than a slice
[ "getSubnetInfoAsMap", "will", "return", "the", "subnet", "information", "for", "the", "getSubnetInfo", "as", "a", "map", "rather", "than", "a", "slice" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/environ.go#L118-L128
156,721
juju/juju
provider/oracle/network/environ.go
getSubnetInfo
func (e Environ) getSubnetInfo() ([]network.SubnetInfo, error) { networks, err := e.client.AllIpNetworks(nil) if err != nil { return nil, errors.Trace(err) } subnets := make([]network.SubnetInfo, len(networks.Result)) idx := 0 for _, val := range networks.Result { var spaceId network.Id if val.IpNetworkExchange != nil { spaceId = network.Id(*val.IpNetworkExchange) } subnets[idx] = network.SubnetInfo{ ProviderId: network.Id(val.Name), CIDR: val.IpAddressPrefix, SpaceProviderId: spaceId, AvailabilityZones: []string{ "default", }, } idx++ } return subnets, nil }
go
func (e Environ) getSubnetInfo() ([]network.SubnetInfo, error) { networks, err := e.client.AllIpNetworks(nil) if err != nil { return nil, errors.Trace(err) } subnets := make([]network.SubnetInfo, len(networks.Result)) idx := 0 for _, val := range networks.Result { var spaceId network.Id if val.IpNetworkExchange != nil { spaceId = network.Id(*val.IpNetworkExchange) } subnets[idx] = network.SubnetInfo{ ProviderId: network.Id(val.Name), CIDR: val.IpAddressPrefix, SpaceProviderId: spaceId, AvailabilityZones: []string{ "default", }, } idx++ } return subnets, nil }
[ "func", "(", "e", "Environ", ")", "getSubnetInfo", "(", ")", "(", "[", "]", "network", ".", "SubnetInfo", ",", "error", ")", "{", "networks", ",", "err", ":=", "e", ".", "client", ".", "AllIpNetworks", "(", "nil", ")", "\n", "if", "err", "!=", "nil...
// getSubnetInfo returns subnet information for all subnets known to // the oracle provider
[ "getSubnetInfo", "returns", "subnet", "information", "for", "all", "subnets", "known", "to", "the", "oracle", "provider" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/environ.go#L132-L155
156,722
juju/juju
provider/oracle/network/environ.go
NetworkInterfaces
func (e Environ) NetworkInterfaces(ctx context.ProviderCallContext, instId instance.Id) ([]network.InterfaceInfo, error) { instance, err := e.env.Details(instId) if err != nil { return nil, err } if len(instance.Networking) == 0 { return []network.InterfaceInfo{}, nil } subnetInfo, err := e.getSubnetInfoAsMap() if err != nil { return nil, errors.Trace(err) } nicAttributes := e.getNicAttributes(instance) interfaces := make([]network.InterfaceInfo, 0, len(instance.Networking)) idx := 0 for nicName, nicObj := range instance.Networking { // gsamfira: While the API may hold any alphanumeric NIC name // of up to 4 characters, inside an ubuntu instance, // the NIC will always be named eth0 (where 0 is the index of the NIC). // NICs inside the instance will be ordered in the same way the API // returns them; i.e. first element returned by the API will be eth0, // second element will be eth1 and so on. Sorting is done // alphanumerically it makes sense to use the name that will be // seen by the juju agent instead of the name that shows up // in the provider. // TODO (gsamfira): Check NIC naming in CentOS and Windows. name := fmt.Sprintf("eth%s", strconv.Itoa(idx)) deviceIndex := idx idx += 1 deviceAttributes, ok := nicAttributes[nicName] if !ok { return nil, errors.Errorf( "failed to get NIC attributes for %q", nicName) } mac, ip, err := GetMacAndIP(deviceAttributes.Address) if err != nil { return nil, err } addr := network.NewScopedAddress(ip, network.ScopeCloudLocal) nic := network.InterfaceInfo{ InterfaceName: name, DeviceIndex: deviceIndex, ProviderId: network.Id(deviceAttributes.Id), MACAddress: mac, Address: addr, InterfaceType: network.EthernetInterface, } // gsamfira: VEthernet NICs are connected to shared networks // I have not found a way to interrogate details about the shared // networks available inside the oracle cloud. There is some // documentation on the matter here: // // https://docs.oracle.com/cloud-machine/latest/stcomputecs/ELUAP/GUID-8CBE0F4E-E376-4C93-BB56-884836273168.htm // // but I have not been able to get any information about the // shared networks using the resources described there. // We only populate Space information for NICs attached to // IPNetworks (user defined) if nicObj.GetType() == common.VNic { nicSubnetDetails := subnetInfo[deviceAttributes.Ipnetwork] nic.ProviderSpaceId = nicSubnetDetails.SpaceProviderId nic.ProviderSubnetId = nicSubnetDetails.ProviderId nic.CIDR = nicSubnetDetails.CIDR } interfaces = append(interfaces, nic) } return interfaces, nil }
go
func (e Environ) NetworkInterfaces(ctx context.ProviderCallContext, instId instance.Id) ([]network.InterfaceInfo, error) { instance, err := e.env.Details(instId) if err != nil { return nil, err } if len(instance.Networking) == 0 { return []network.InterfaceInfo{}, nil } subnetInfo, err := e.getSubnetInfoAsMap() if err != nil { return nil, errors.Trace(err) } nicAttributes := e.getNicAttributes(instance) interfaces := make([]network.InterfaceInfo, 0, len(instance.Networking)) idx := 0 for nicName, nicObj := range instance.Networking { // gsamfira: While the API may hold any alphanumeric NIC name // of up to 4 characters, inside an ubuntu instance, // the NIC will always be named eth0 (where 0 is the index of the NIC). // NICs inside the instance will be ordered in the same way the API // returns them; i.e. first element returned by the API will be eth0, // second element will be eth1 and so on. Sorting is done // alphanumerically it makes sense to use the name that will be // seen by the juju agent instead of the name that shows up // in the provider. // TODO (gsamfira): Check NIC naming in CentOS and Windows. name := fmt.Sprintf("eth%s", strconv.Itoa(idx)) deviceIndex := idx idx += 1 deviceAttributes, ok := nicAttributes[nicName] if !ok { return nil, errors.Errorf( "failed to get NIC attributes for %q", nicName) } mac, ip, err := GetMacAndIP(deviceAttributes.Address) if err != nil { return nil, err } addr := network.NewScopedAddress(ip, network.ScopeCloudLocal) nic := network.InterfaceInfo{ InterfaceName: name, DeviceIndex: deviceIndex, ProviderId: network.Id(deviceAttributes.Id), MACAddress: mac, Address: addr, InterfaceType: network.EthernetInterface, } // gsamfira: VEthernet NICs are connected to shared networks // I have not found a way to interrogate details about the shared // networks available inside the oracle cloud. There is some // documentation on the matter here: // // https://docs.oracle.com/cloud-machine/latest/stcomputecs/ELUAP/GUID-8CBE0F4E-E376-4C93-BB56-884836273168.htm // // but I have not been able to get any information about the // shared networks using the resources described there. // We only populate Space information for NICs attached to // IPNetworks (user defined) if nicObj.GetType() == common.VNic { nicSubnetDetails := subnetInfo[deviceAttributes.Ipnetwork] nic.ProviderSpaceId = nicSubnetDetails.SpaceProviderId nic.ProviderSubnetId = nicSubnetDetails.ProviderId nic.CIDR = nicSubnetDetails.CIDR } interfaces = append(interfaces, nic) } return interfaces, nil }
[ "func", "(", "e", "Environ", ")", "NetworkInterfaces", "(", "ctx", "context", ".", "ProviderCallContext", ",", "instId", "instance", ".", "Id", ")", "(", "[", "]", "network", ".", "InterfaceInfo", ",", "error", ")", "{", "instance", ",", "err", ":=", "e"...
// NetworkInterfaces is defined on the environs.Networking interface.
[ "NetworkInterfaces", "is", "defined", "on", "the", "environs", ".", "Networking", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/environ.go#L158-L231
156,723
juju/juju
provider/oracle/network/environ.go
getNicAttributes
func (e Environ) getNicAttributes(instance response.Instance) map[string]response.Network { if instance.Attributes.Network == nil { return map[string]response.Network{} } n := len(instance.Attributes.Network) ret := make(map[string]response.Network, n) for name, obj := range instance.Attributes.Network { tmp := strings.TrimPrefix(name, `nimbula_vcable-`) ret[tmp] = obj } return ret }
go
func (e Environ) getNicAttributes(instance response.Instance) map[string]response.Network { if instance.Attributes.Network == nil { return map[string]response.Network{} } n := len(instance.Attributes.Network) ret := make(map[string]response.Network, n) for name, obj := range instance.Attributes.Network { tmp := strings.TrimPrefix(name, `nimbula_vcable-`) ret[tmp] = obj } return ret }
[ "func", "(", "e", "Environ", ")", "getNicAttributes", "(", "instance", "response", ".", "Instance", ")", "map", "[", "string", "]", "response", ".", "Network", "{", "if", "instance", ".", "Attributes", ".", "Network", "==", "nil", "{", "return", "map", "...
// getNicAttributes returns all network cards attributes from a oracle instance
[ "getNicAttributes", "returns", "all", "network", "cards", "attributes", "from", "a", "oracle", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/environ.go#L234-L245
156,724
juju/juju
provider/oracle/network/environ.go
canAccessNetworkAPI
func (e *Environ) canAccessNetworkAPI() (bool, error) { _, err := e.client.AllAcls(nil) if err != nil { if api.IsMethodNotAllowed(err) { return false, nil } return false, errors.Trace(err) } return true, nil }
go
func (e *Environ) canAccessNetworkAPI() (bool, error) { _, err := e.client.AllAcls(nil) if err != nil { if api.IsMethodNotAllowed(err) { return false, nil } return false, errors.Trace(err) } return true, nil }
[ "func", "(", "e", "*", "Environ", ")", "canAccessNetworkAPI", "(", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "err", ":=", "e", ".", "client", ".", "AllAcls", "(", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "if", "api", ".", "IsM...
// canAccessNetworkAPI checks whether or not we have access to the necessary // API endpoints needed for spaces support
[ "canAccessNetworkAPI", "checks", "whether", "or", "not", "we", "have", "access", "to", "the", "necessary", "API", "endpoints", "needed", "for", "spaces", "support" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/environ.go#L249-L258
156,725
juju/juju
provider/oracle/network/environ.go
SupportsSpaces
func (e Environ) SupportsSpaces(ctx context.ProviderCallContext) (bool, error) { logger.Infof("checking for spaces support") access, err := e.canAccessNetworkAPI() if err != nil { return false, errors.Trace(err) } if access { return true, nil } return false, nil }
go
func (e Environ) SupportsSpaces(ctx context.ProviderCallContext) (bool, error) { logger.Infof("checking for spaces support") access, err := e.canAccessNetworkAPI() if err != nil { return false, errors.Trace(err) } if access { return true, nil } return false, nil }
[ "func", "(", "e", "Environ", ")", "SupportsSpaces", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "bool", ",", "error", ")", "{", "logger", ".", "Infof", "(", "\"", "\"", ")", "\n", "access", ",", "err", ":=", "e", ".", "canAccessNetwork...
// SupportsSpaces is defined on the environs.Networking interface.
[ "SupportsSpaces", "is", "defined", "on", "the", "environs", ".", "Networking", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/environ.go#L261-L271
156,726
juju/juju
provider/oracle/network/environ.go
SupportsSpaceDiscovery
func (e Environ) SupportsSpaceDiscovery(ctx context.ProviderCallContext) (bool, error) { access, err := e.canAccessNetworkAPI() if err != nil { return false, errors.Trace(err) } if access { return true, nil } return false, nil }
go
func (e Environ) SupportsSpaceDiscovery(ctx context.ProviderCallContext) (bool, error) { access, err := e.canAccessNetworkAPI() if err != nil { return false, errors.Trace(err) } if access { return true, nil } return false, nil }
[ "func", "(", "e", "Environ", ")", "SupportsSpaceDiscovery", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "bool", ",", "error", ")", "{", "access", ",", "err", ":=", "e", ".", "canAccessNetworkAPI", "(", ")", "\n", "if", "err", "!=", "nil"...
// SupportsSpaceDiscovery is defined on the environs.Networking interface.
[ "SupportsSpaceDiscovery", "is", "defined", "on", "the", "environs", ".", "Networking", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/environ.go#L274-L283
156,727
juju/juju
provider/oracle/network/environ.go
Spaces
func (e Environ) Spaces(ctx context.ProviderCallContext) ([]network.SpaceInfo, error) { networks, err := e.getSubnetInfo() if err != nil { return nil, errors.Trace(err) } exchanges := map[string]network.SpaceInfo{} for _, val := range networks { if val.SpaceProviderId == "" { continue } logger.Infof("found network %s with space %s", string(val.ProviderId), string(val.SpaceProviderId)) providerID := string(val.SpaceProviderId) tmp := strings.Split(providerID, `/`) name := tmp[len(tmp)-1] // Oracle allows us to attach an IP network to a space belonging to // another user using the web portal. We recompose the provider ID // (which is unique) and compare to the provider ID of the space. // If they match, the space belongs to us tmpProviderId := e.client.ComposeName(name) if tmpProviderId != providerID { continue } if space, ok := exchanges[name]; !ok { logger.Infof("creating new space obj for %s and adding %s", name, string(val.ProviderId)) exchanges[name] = network.SpaceInfo{ Name: name, ProviderId: val.SpaceProviderId, Subnets: []network.SubnetInfo{ val, }, } } else { logger.Infof("appending subnet %s to %s", string(val.ProviderId), space.Name) space.Subnets = append(space.Subnets, val) exchanges[name] = space } } var ret []network.SpaceInfo for _, val := range exchanges { ret = append(ret, val) } logger.Infof("returning spaces: %v", ret) return ret, nil }
go
func (e Environ) Spaces(ctx context.ProviderCallContext) ([]network.SpaceInfo, error) { networks, err := e.getSubnetInfo() if err != nil { return nil, errors.Trace(err) } exchanges := map[string]network.SpaceInfo{} for _, val := range networks { if val.SpaceProviderId == "" { continue } logger.Infof("found network %s with space %s", string(val.ProviderId), string(val.SpaceProviderId)) providerID := string(val.SpaceProviderId) tmp := strings.Split(providerID, `/`) name := tmp[len(tmp)-1] // Oracle allows us to attach an IP network to a space belonging to // another user using the web portal. We recompose the provider ID // (which is unique) and compare to the provider ID of the space. // If they match, the space belongs to us tmpProviderId := e.client.ComposeName(name) if tmpProviderId != providerID { continue } if space, ok := exchanges[name]; !ok { logger.Infof("creating new space obj for %s and adding %s", name, string(val.ProviderId)) exchanges[name] = network.SpaceInfo{ Name: name, ProviderId: val.SpaceProviderId, Subnets: []network.SubnetInfo{ val, }, } } else { logger.Infof("appending subnet %s to %s", string(val.ProviderId), space.Name) space.Subnets = append(space.Subnets, val) exchanges[name] = space } } var ret []network.SpaceInfo for _, val := range exchanges { ret = append(ret, val) } logger.Infof("returning spaces: %v", ret) return ret, nil }
[ "func", "(", "e", "Environ", ")", "Spaces", "(", "ctx", "context", ".", "ProviderCallContext", ")", "(", "[", "]", "network", ".", "SpaceInfo", ",", "error", ")", "{", "networks", ",", "err", ":=", "e", ".", "getSubnetInfo", "(", ")", "\n", "if", "er...
// Spaces is defined on the environs.Networking interface.
[ "Spaces", "is", "defined", "on", "the", "environs", ".", "Networking", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/oracle/network/environ.go#L306-L353
156,728
juju/juju
rpc/server.go
IsRequest
func (hdr *Header) IsRequest() bool { return hdr.Request.Type != "" || hdr.Request.Action != "" }
go
func (hdr *Header) IsRequest() bool { return hdr.Request.Type != "" || hdr.Request.Action != "" }
[ "func", "(", "hdr", "*", "Header", ")", "IsRequest", "(", ")", "bool", "{", "return", "hdr", ".", "Request", ".", "Type", "!=", "\"", "\"", "||", "hdr", ".", "Request", ".", "Action", "!=", "\"", "\"", "\n", "}" ]
// IsRequest returns whether the header represents an RPC request. If // it is not a request, it is a response.
[ "IsRequest", "returns", "whether", "the", "header", "represents", "an", "RPC", "request", ".", "If", "it", "is", "not", "a", "request", "it", "is", "a", "response", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/server.go#L93-L95
156,729
juju/juju
rpc/server.go
NewConn
func NewConn(codec Codec, factory RecorderFactory) *Conn { return &Conn{ codec: codec, clientPending: make(map[uint64]*Call), recorderFactory: ensureFactory(factory), } }
go
func NewConn(codec Codec, factory RecorderFactory) *Conn { return &Conn{ codec: codec, clientPending: make(map[uint64]*Call), recorderFactory: ensureFactory(factory), } }
[ "func", "NewConn", "(", "codec", "Codec", ",", "factory", "RecorderFactory", ")", "*", "Conn", "{", "return", "&", "Conn", "{", "codec", ":", "codec", ",", "clientPending", ":", "make", "(", "map", "[", "uint64", "]", "*", "Call", ")", ",", "recorderFa...
// NewConn creates a new connection that uses the given codec for // transport, but it does not start it. Conn.Start must be called // before any requests are sent or received. If recorderFactory is // non-nil, it will be called to get a new recorder for every request.
[ "NewConn", "creates", "a", "new", "connection", "that", "uses", "the", "given", "codec", "for", "transport", "but", "it", "does", "not", "start", "it", ".", "Conn", ".", "Start", "must", "be", "called", "before", "any", "requests", "are", "sent", "or", "...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/server.go#L173-L179
156,730
juju/juju
rpc/server.go
ServeRoot
func (conn *Conn) ServeRoot(root Root, factory RecorderFactory, transformErrors func(error) error) { conn.serve(root, factory, transformErrors) }
go
func (conn *Conn) ServeRoot(root Root, factory RecorderFactory, transformErrors func(error) error) { conn.serve(root, factory, transformErrors) }
[ "func", "(", "conn", "*", "Conn", ")", "ServeRoot", "(", "root", "Root", ",", "factory", "RecorderFactory", ",", "transformErrors", "func", "(", "error", ")", "error", ")", "{", "conn", ".", "serve", "(", "root", ",", "factory", ",", "transformErrors", "...
// ServeRoot is like Serve except that it gives the root object dynamic // control over what methods are available instead of using reflection // on the type. // // The server executes each client request by calling FindMethod to obtain a // method to invoke. It invokes that method with the request parameters, // possibly returning some result. // // The Kill method will be called when the connection is closed.
[ "ServeRoot", "is", "like", "Serve", "except", "that", "it", "gives", "the", "root", "object", "dynamic", "control", "over", "what", "methods", "are", "available", "instead", "of", "using", "reflection", "on", "the", "type", ".", "The", "server", "executes", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/server.go#L254-L256
156,731
juju/juju
rpc/server.go
Close
func (conn *Conn) Close() error { conn.mutex.Lock() if conn.closing { conn.mutex.Unlock() // Golang's net/rpc returns rpc.ErrShutdown if you ask to close // a closing or shutdown connection. Our choice is that Close // is an idempotent way to ask for resources to be released and // isn't a failure if called multiple times. return nil } conn.closing = true if conn.root != nil { // Kill calls down into the resources to stop all the resources which // includes watchers. The watches need to be killed in order for their // API methods to return, otherwise they are just waiting. conn.root.Kill() } conn.mutex.Unlock() // Wait for any outstanding server requests to complete // and write their replies before closing the codec. We // cancel the context so that any requests that would // block will be notified that the server is shutting // down. conn.cancelContext() conn.srvPending.Wait() conn.mutex.Lock() if conn.root != nil { // It is possible that since we last Killed the root, other resources // may have been added during some of the pending call resoulutions. // So to release these resources, double tap the root. conn.root.Kill() } conn.mutex.Unlock() // Closing the codec should cause the input loop to terminate. if err := conn.codec.Close(); err != nil { logger.Debugf("error closing codec: %v", err) } <-conn.dead return conn.inputLoopError }
go
func (conn *Conn) Close() error { conn.mutex.Lock() if conn.closing { conn.mutex.Unlock() // Golang's net/rpc returns rpc.ErrShutdown if you ask to close // a closing or shutdown connection. Our choice is that Close // is an idempotent way to ask for resources to be released and // isn't a failure if called multiple times. return nil } conn.closing = true if conn.root != nil { // Kill calls down into the resources to stop all the resources which // includes watchers. The watches need to be killed in order for their // API methods to return, otherwise they are just waiting. conn.root.Kill() } conn.mutex.Unlock() // Wait for any outstanding server requests to complete // and write their replies before closing the codec. We // cancel the context so that any requests that would // block will be notified that the server is shutting // down. conn.cancelContext() conn.srvPending.Wait() conn.mutex.Lock() if conn.root != nil { // It is possible that since we last Killed the root, other resources // may have been added during some of the pending call resoulutions. // So to release these resources, double tap the root. conn.root.Kill() } conn.mutex.Unlock() // Closing the codec should cause the input loop to terminate. if err := conn.codec.Close(); err != nil { logger.Debugf("error closing codec: %v", err) } <-conn.dead return conn.inputLoopError }
[ "func", "(", "conn", "*", "Conn", ")", "Close", "(", ")", "error", "{", "conn", ".", "mutex", ".", "Lock", "(", ")", "\n", "if", "conn", ".", "closing", "{", "conn", ".", "mutex", ".", "Unlock", "(", ")", "\n", "// Golang's net/rpc returns rpc.ErrShutd...
// Close closes the connection and its underlying codec; it returns when // all requests have been terminated. // // If the connection is serving requests, and the root value implements // the Killer interface, its Kill method will be called. The codec will // then be closed only when all its outstanding server calls have // completed. // // Calling Close multiple times is not an error.
[ "Close", "closes", "the", "connection", "and", "its", "underlying", "codec", ";", "it", "returns", "when", "all", "requests", "have", "been", "terminated", ".", "If", "the", "connection", "is", "serving", "requests", "and", "the", "root", "value", "implements"...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/server.go#L291-L334
156,732
juju/juju
rpc/server.go
input
func (conn *Conn) input() { err := conn.loop() conn.sending.Lock() defer conn.sending.Unlock() conn.mutex.Lock() defer conn.mutex.Unlock() if conn.closing || errors.Cause(err) == io.EOF { err = ErrShutdown } else { // Make the error available for Conn.Close to see. conn.inputLoopError = err } // Terminate all client requests. for _, call := range conn.clientPending { call.Error = err call.done() } conn.clientPending = nil conn.shutdown = true close(conn.dead) }
go
func (conn *Conn) input() { err := conn.loop() conn.sending.Lock() defer conn.sending.Unlock() conn.mutex.Lock() defer conn.mutex.Unlock() if conn.closing || errors.Cause(err) == io.EOF { err = ErrShutdown } else { // Make the error available for Conn.Close to see. conn.inputLoopError = err } // Terminate all client requests. for _, call := range conn.clientPending { call.Error = err call.done() } conn.clientPending = nil conn.shutdown = true close(conn.dead) }
[ "func", "(", "conn", "*", "Conn", ")", "input", "(", ")", "{", "err", ":=", "conn", ".", "loop", "(", ")", "\n", "conn", ".", "sending", ".", "Lock", "(", ")", "\n", "defer", "conn", ".", "sending", ".", "Unlock", "(", ")", "\n", "conn", ".", ...
// input reads messages from the connection and handles them // appropriately.
[ "input", "reads", "messages", "from", "the", "connection", "and", "handles", "them", "appropriately", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/server.go#L363-L384
156,733
juju/juju
rpc/server.go
loop
func (conn *Conn) loop() error { defer conn.cancelContext() for { var hdr Header err := conn.codec.ReadHeader(&hdr) switch { case errors.Cause(err) == io.EOF: // handle sentinel error specially return err case err != nil: return errors.Annotate(err, "codec.ReadHeader error") case hdr.IsRequest(): if err := conn.handleRequest(&hdr); err != nil { return errors.Annotatef(err, "codec.handleRequest %#v error", hdr) } default: if err := conn.handleResponse(&hdr); err != nil { return errors.Annotatef(err, "codec.handleResponse %#v error", hdr) } } } }
go
func (conn *Conn) loop() error { defer conn.cancelContext() for { var hdr Header err := conn.codec.ReadHeader(&hdr) switch { case errors.Cause(err) == io.EOF: // handle sentinel error specially return err case err != nil: return errors.Annotate(err, "codec.ReadHeader error") case hdr.IsRequest(): if err := conn.handleRequest(&hdr); err != nil { return errors.Annotatef(err, "codec.handleRequest %#v error", hdr) } default: if err := conn.handleResponse(&hdr); err != nil { return errors.Annotatef(err, "codec.handleResponse %#v error", hdr) } } } }
[ "func", "(", "conn", "*", "Conn", ")", "loop", "(", ")", "error", "{", "defer", "conn", ".", "cancelContext", "(", ")", "\n", "for", "{", "var", "hdr", "Header", "\n", "err", ":=", "conn", ".", "codec", ".", "ReadHeader", "(", "&", "hdr", ")", "\...
// loop implements the looping part of Conn.input.
[ "loop", "implements", "the", "looping", "part", "of", "Conn", ".", "input", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/server.go#L387-L408
156,734
juju/juju
rpc/server.go
bindRequest
func (conn *Conn) bindRequest(hdr *Header) (boundRequest, error) { conn.mutex.Lock() root := conn.root transformErrors := conn.transformErrors conn.mutex.Unlock() if root == nil { return boundRequest{}, errors.New("no service") } caller, err := root.FindMethod( hdr.Request.Type, hdr.Request.Version, hdr.Request.Action) if err != nil { if _, ok := err.(*rpcreflect.CallNotImplementedError); ok { err = &serverError{ error: err, } } else { err = transformErrors(err) } return boundRequest{}, err } return boundRequest{ MethodCaller: caller, transformErrors: transformErrors, hdr: *hdr, }, nil }
go
func (conn *Conn) bindRequest(hdr *Header) (boundRequest, error) { conn.mutex.Lock() root := conn.root transformErrors := conn.transformErrors conn.mutex.Unlock() if root == nil { return boundRequest{}, errors.New("no service") } caller, err := root.FindMethod( hdr.Request.Type, hdr.Request.Version, hdr.Request.Action) if err != nil { if _, ok := err.(*rpcreflect.CallNotImplementedError); ok { err = &serverError{ error: err, } } else { err = transformErrors(err) } return boundRequest{}, err } return boundRequest{ MethodCaller: caller, transformErrors: transformErrors, hdr: *hdr, }, nil }
[ "func", "(", "conn", "*", "Conn", ")", "bindRequest", "(", "hdr", "*", "Header", ")", "(", "boundRequest", ",", "error", ")", "{", "conn", ".", "mutex", ".", "Lock", "(", ")", "\n", "root", ":=", "conn", ".", "root", "\n", "transformErrors", ":=", ...
// bindRequest searches for methods implementing the // request held in the given header and returns // a boundRequest that can call those methods.
[ "bindRequest", "searches", "for", "methods", "implementing", "the", "request", "held", "in", "the", "given", "header", "and", "returns", "a", "boundRequest", "that", "can", "call", "those", "methods", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/server.go#L520-L546
156,735
juju/juju
rpc/server.go
runRequest
func (conn *Conn) runRequest( req boundRequest, arg reflect.Value, version int, recorder Recorder, ) { // If the request causes a panic, ensure we log that before closing the connection. defer func() { if panicResult := recover(); panicResult != nil { logger.Criticalf( "panic running request %+v with arg %+v: %v\n%v", req, arg, panicResult, string(debug.Stack())) conn.writeErrorResponse(&req.hdr, errors.Errorf("%v", panicResult), recorder) } }() defer conn.srvPending.Done() // Create a request-specific context, cancelled when the // request returns. // // TODO(axw) provide a means for clients to cancel a request. ctx, cancel := context.WithCancel(conn.context) defer cancel() rv, err := req.Call(ctx, req.hdr.Request.Id, arg) if err != nil { err = conn.writeErrorResponse(&req.hdr, req.transformErrors(err), recorder) } else { hdr := &Header{ RequestId: req.hdr.RequestId, Version: version, } var rvi interface{} if rv.IsValid() { rvi = rv.Interface() } else { rvi = struct{}{} } if err := recorder.HandleReply(req.hdr.Request, hdr, rvi); err != nil { logger.Errorf("error recording reply %+v: %T %+v", hdr, err, err) } conn.sending.Lock() err = conn.codec.WriteMessage(hdr, rvi) conn.sending.Unlock() } if err != nil { // If the message failed due to the other end closing the socket, that // is expected when an agent restarts so no need to log an error. // The error type here is errors.errorString so all we can do is a match // on the error string content. msg := err.Error() if !strings.Contains(msg, "websocket: close sent") && !strings.Contains(msg, "write: broken pipe") { logger.Errorf("error writing response: %T %+v", err, err) } } }
go
func (conn *Conn) runRequest( req boundRequest, arg reflect.Value, version int, recorder Recorder, ) { // If the request causes a panic, ensure we log that before closing the connection. defer func() { if panicResult := recover(); panicResult != nil { logger.Criticalf( "panic running request %+v with arg %+v: %v\n%v", req, arg, panicResult, string(debug.Stack())) conn.writeErrorResponse(&req.hdr, errors.Errorf("%v", panicResult), recorder) } }() defer conn.srvPending.Done() // Create a request-specific context, cancelled when the // request returns. // // TODO(axw) provide a means for clients to cancel a request. ctx, cancel := context.WithCancel(conn.context) defer cancel() rv, err := req.Call(ctx, req.hdr.Request.Id, arg) if err != nil { err = conn.writeErrorResponse(&req.hdr, req.transformErrors(err), recorder) } else { hdr := &Header{ RequestId: req.hdr.RequestId, Version: version, } var rvi interface{} if rv.IsValid() { rvi = rv.Interface() } else { rvi = struct{}{} } if err := recorder.HandleReply(req.hdr.Request, hdr, rvi); err != nil { logger.Errorf("error recording reply %+v: %T %+v", hdr, err, err) } conn.sending.Lock() err = conn.codec.WriteMessage(hdr, rvi) conn.sending.Unlock() } if err != nil { // If the message failed due to the other end closing the socket, that // is expected when an agent restarts so no need to log an error. // The error type here is errors.errorString so all we can do is a match // on the error string content. msg := err.Error() if !strings.Contains(msg, "websocket: close sent") && !strings.Contains(msg, "write: broken pipe") { logger.Errorf("error writing response: %T %+v", err, err) } } }
[ "func", "(", "conn", "*", "Conn", ")", "runRequest", "(", "req", "boundRequest", ",", "arg", "reflect", ".", "Value", ",", "version", "int", ",", "recorder", "Recorder", ",", ")", "{", "// If the request causes a panic, ensure we log that before closing the connection...
// runRequest runs the given request and sends the reply.
[ "runRequest", "runs", "the", "given", "request", "and", "sends", "the", "reply", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/server.go#L549-L604
156,736
juju/juju
worker/uniter/actions/resolver.go
NextOp
func (r *actionsResolver) NextOp( localState resolver.LocalState, remoteState remotestate.Snapshot, opFactory operation.Factory, ) (operation.Operation, error) { // If there are no operation left to be run, then we cannot return the // error signaling such here, we must first check to see if an action is // already running (that has been interrupted) before we declare that // there is nothing to do. nextAction, err := nextAction(remoteState.Actions, localState.CompletedActions) if err != nil && err != resolver.ErrNoOperation { return nil, err } switch localState.Kind { case operation.RunHook: // We can still run actions if the unit is in a hook error state. if localState.Step == operation.Pending && err == nil { return opFactory.NewAction(nextAction) } case operation.RunAction: if localState.Hook != nil { logger.Infof("found incomplete action %v; ignoring", localState.ActionId) logger.Infof("recommitting prior %q hook", localState.Hook.Kind) return opFactory.NewSkipHook(*localState.Hook) } else { logger.Infof("%q hook is nil", operation.RunAction) // If the next action is the same as what the uniter is // currently running then this means that the uniter was // some how interrupted (killed) when running the action // and before updating the remote state to indicate that // the action was completed. The only safe thing to do // is fail the action, since rerunning an arbitrary // command can potentially be hazardous. if nextAction == *localState.ActionId { return opFactory.NewFailAction(*localState.ActionId) } // If the next action is different then what the uniter // is currently running, then the uniter may have been // interrupted while running the action but the remote // state was updated. Thus, the semantics of // (re)preparing the running operation should move the // uniter's state along safely. Thus, we return the // running action. return opFactory.NewAction(*localState.ActionId) } case operation.Continue: if err != resolver.ErrNoOperation { return opFactory.NewAction(nextAction) } } return nil, resolver.ErrNoOperation }
go
func (r *actionsResolver) NextOp( localState resolver.LocalState, remoteState remotestate.Snapshot, opFactory operation.Factory, ) (operation.Operation, error) { // If there are no operation left to be run, then we cannot return the // error signaling such here, we must first check to see if an action is // already running (that has been interrupted) before we declare that // there is nothing to do. nextAction, err := nextAction(remoteState.Actions, localState.CompletedActions) if err != nil && err != resolver.ErrNoOperation { return nil, err } switch localState.Kind { case operation.RunHook: // We can still run actions if the unit is in a hook error state. if localState.Step == operation.Pending && err == nil { return opFactory.NewAction(nextAction) } case operation.RunAction: if localState.Hook != nil { logger.Infof("found incomplete action %v; ignoring", localState.ActionId) logger.Infof("recommitting prior %q hook", localState.Hook.Kind) return opFactory.NewSkipHook(*localState.Hook) } else { logger.Infof("%q hook is nil", operation.RunAction) // If the next action is the same as what the uniter is // currently running then this means that the uniter was // some how interrupted (killed) when running the action // and before updating the remote state to indicate that // the action was completed. The only safe thing to do // is fail the action, since rerunning an arbitrary // command can potentially be hazardous. if nextAction == *localState.ActionId { return opFactory.NewFailAction(*localState.ActionId) } // If the next action is different then what the uniter // is currently running, then the uniter may have been // interrupted while running the action but the remote // state was updated. Thus, the semantics of // (re)preparing the running operation should move the // uniter's state along safely. Thus, we return the // running action. return opFactory.NewAction(*localState.ActionId) } case operation.Continue: if err != resolver.ErrNoOperation { return opFactory.NewAction(nextAction) } } return nil, resolver.ErrNoOperation }
[ "func", "(", "r", "*", "actionsResolver", ")", "NextOp", "(", "localState", "resolver", ".", "LocalState", ",", "remoteState", "remotestate", ".", "Snapshot", ",", "opFactory", "operation", ".", "Factory", ",", ")", "(", "operation", ".", "Operation", ",", "...
// NextOp implements the resolver.Resolver interface.
[ "NextOp", "implements", "the", "resolver", ".", "Resolver", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/actions/resolver.go#L39-L92
156,737
juju/juju
core/migration/phase.go
String
func (p Phase) String() string { i := int(p) if i >= 0 && i < len(phaseNames) { return phaseNames[i] } return "UNKNOWN" }
go
func (p Phase) String() string { i := int(p) if i >= 0 && i < len(phaseNames) { return phaseNames[i] } return "UNKNOWN" }
[ "func", "(", "p", "Phase", ")", "String", "(", ")", "string", "{", "i", ":=", "int", "(", "p", ")", "\n", "if", "i", ">=", "0", "&&", "i", "<", "len", "(", "phaseNames", ")", "{", "return", "phaseNames", "[", "i", "]", "\n", "}", "\n", "retur...
// String returns the name of an model migration phase constant.
[ "String", "returns", "the", "name", "of", "an", "model", "migration", "phase", "constant", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/migration/phase.go#L41-L47
156,738
juju/juju
core/migration/phase.go
CanTransitionTo
func (p Phase) CanTransitionTo(targetPhase Phase) bool { nextPhases, exists := validTransitions[p] if !exists { return false } for _, nextPhase := range nextPhases { if nextPhase == targetPhase { return true } } return false }
go
func (p Phase) CanTransitionTo(targetPhase Phase) bool { nextPhases, exists := validTransitions[p] if !exists { return false } for _, nextPhase := range nextPhases { if nextPhase == targetPhase { return true } } return false }
[ "func", "(", "p", "Phase", ")", "CanTransitionTo", "(", "targetPhase", "Phase", ")", "bool", "{", "nextPhases", ",", "exists", ":=", "validTransitions", "[", "p", "]", "\n", "if", "!", "exists", "{", "return", "false", "\n", "}", "\n", "for", "_", ",",...
// CanTransitionTo returns true if the given phase is a valid next // model migration phase.
[ "CanTransitionTo", "returns", "true", "if", "the", "given", "phase", "is", "a", "valid", "next", "model", "migration", "phase", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/migration/phase.go#L51-L62
156,739
juju/juju
core/migration/phase.go
IsTerminal
func (p Phase) IsTerminal() bool { for _, t := range terminalPhases { if p == t { return true } } return false }
go
func (p Phase) IsTerminal() bool { for _, t := range terminalPhases { if p == t { return true } } return false }
[ "func", "(", "p", "Phase", ")", "IsTerminal", "(", ")", "bool", "{", "for", "_", ",", "t", ":=", "range", "terminalPhases", "{", "if", "p", "==", "t", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsTerminal returns true if the phase is one which signifies the end // of a migration.
[ "IsTerminal", "returns", "true", "if", "the", "phase", "is", "one", "which", "signifies", "the", "end", "of", "a", "migration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/migration/phase.go#L66-L73
156,740
juju/juju
core/migration/phase.go
IsRunning
func (p Phase) IsRunning() bool { if p.IsTerminal() { return false } switch p { case QUIESCE, IMPORT, VALIDATION, SUCCESS: return true default: return false } }
go
func (p Phase) IsRunning() bool { if p.IsTerminal() { return false } switch p { case QUIESCE, IMPORT, VALIDATION, SUCCESS: return true default: return false } }
[ "func", "(", "p", "Phase", ")", "IsRunning", "(", ")", "bool", "{", "if", "p", ".", "IsTerminal", "(", ")", "{", "return", "false", "\n", "}", "\n", "switch", "p", "{", "case", "QUIESCE", ",", "IMPORT", ",", "VALIDATION", ",", "SUCCESS", ":", "retu...
// IsRunning returns true if the phase indicates the migration is // active and up to or at the SUCCESS phase. It returns false if the // phase is one of the final cleanup phases or indicates an failed // migration.
[ "IsRunning", "returns", "true", "if", "the", "phase", "indicates", "the", "migration", "is", "active", "and", "up", "to", "or", "at", "the", "SUCCESS", "phase", ".", "It", "returns", "false", "if", "the", "phase", "is", "one", "of", "the", "final", "clea...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/migration/phase.go#L79-L89
156,741
juju/juju
core/migration/phase.go
ParsePhase
func ParsePhase(target string) (Phase, bool) { for p, name := range phaseNames { if target == name { return Phase(p), true } } return UNKNOWN, false }
go
func ParsePhase(target string) (Phase, bool) { for p, name := range phaseNames { if target == name { return Phase(p), true } } return UNKNOWN, false }
[ "func", "ParsePhase", "(", "target", "string", ")", "(", "Phase", ",", "bool", ")", "{", "for", "p", ",", "name", ":=", "range", "phaseNames", "{", "if", "target", "==", "name", "{", "return", "Phase", "(", "p", ")", ",", "true", "\n", "}", "\n", ...
// ParsePhase converts a string model migration phase name // to its constant value.
[ "ParsePhase", "converts", "a", "string", "model", "migration", "phase", "name", "to", "its", "constant", "value", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/migration/phase.go#L119-L126
156,742
juju/juju
worker/apiconfigwatcher/manifold.go
Manifold
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{config.AgentName}, Start: func(context dependency.Context) (worker.Worker, error) { if config.AgentConfigChanged == nil { return nil, errors.NotValidf("nil AgentConfigChanged") } var a agent.Agent if err := context.Get(config.AgentName, &a); err != nil { return nil, err } w := &apiconfigwatcher{ agent: a, agentConfigChanged: config.AgentConfigChanged, addrs: getAPIAddresses(a), } w.tomb.Go(w.loop) return w, nil }, } }
go
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{config.AgentName}, Start: func(context dependency.Context) (worker.Worker, error) { if config.AgentConfigChanged == nil { return nil, errors.NotValidf("nil AgentConfigChanged") } var a agent.Agent if err := context.Get(config.AgentName, &a); err != nil { return nil, err } w := &apiconfigwatcher{ agent: a, agentConfigChanged: config.AgentConfigChanged, addrs: getAPIAddresses(a), } w.tomb.Go(w.loop) return w, nil }, } }
[ "func", "Manifold", "(", "config", "ManifoldConfig", ")", "dependency", ".", "Manifold", "{", "return", "dependency", ".", "Manifold", "{", "Inputs", ":", "[", "]", "string", "{", "config", ".", "AgentName", "}", ",", "Start", ":", "func", "(", "context", ...
// Manifold returns a dependency.Manifold which wraps an agent's // voyeur.Value which is set whenever the agent config is // changed. When the API server addresses in the config change the // manifold will bounce itself. // // The manifold is intended to be a dependency for the api-caller // manifold and is required to support model migrations.
[ "Manifold", "returns", "a", "dependency", ".", "Manifold", "which", "wraps", "an", "agent", "s", "voyeur", ".", "Value", "which", "is", "set", "whenever", "the", "agent", "config", "is", "changed", ".", "When", "the", "API", "server", "addresses", "in", "t...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/apiconfigwatcher/manifold.go#L33-L55
156,743
juju/juju
cmd/juju/storage/add.go
NewAddCommand
func NewAddCommand() cmd.Command { cmd := &addCommand{} cmd.newAPIFunc = func() (StorageAddAPI, error) { return cmd.NewStorageAPI() } return modelcmd.Wrap(cmd) }
go
func NewAddCommand() cmd.Command { cmd := &addCommand{} cmd.newAPIFunc = func() (StorageAddAPI, error) { return cmd.NewStorageAPI() } return modelcmd.Wrap(cmd) }
[ "func", "NewAddCommand", "(", ")", "cmd", ".", "Command", "{", "cmd", ":=", "&", "addCommand", "{", "}", "\n", "cmd", ".", "newAPIFunc", "=", "func", "(", ")", "(", "StorageAddAPI", ",", "error", ")", "{", "return", "cmd", ".", "NewStorageAPI", "(", ...
// NewAddCommand returns a command used to add unit storage.
[ "NewAddCommand", "returns", "a", "command", "used", "to", "add", "unit", "storage", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/storage/add.go#L24-L30
156,744
juju/juju
environs/config/config.go
ParseHarvestMode
func ParseHarvestMode(description string) (HarvestMode, error) { description = strings.ToLower(description) for method, descr := range harvestingMethodToFlag { if description == descr { return method, nil } } return 0, fmt.Errorf("unknown harvesting method: %s", description) }
go
func ParseHarvestMode(description string) (HarvestMode, error) { description = strings.ToLower(description) for method, descr := range harvestingMethodToFlag { if description == descr { return method, nil } } return 0, fmt.Errorf("unknown harvesting method: %s", description) }
[ "func", "ParseHarvestMode", "(", "description", "string", ")", "(", "HarvestMode", ",", "error", ")", "{", "description", "=", "strings", ".", "ToLower", "(", "description", ")", "\n", "for", "method", ",", "descr", ":=", "range", "harvestingMethodToFlag", "{"...
// ParseHarvestMode parses description of harvesting method and // returns the representation.
[ "ParseHarvestMode", "parses", "description", "of", "harvesting", "method", "and", "returns", "the", "representation", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L254-L262
156,745
juju/juju
environs/config/config.go
String
func (method HarvestMode) String() string { if description, ok := harvestingMethodToFlag[method]; ok { return description } panic("Unknown harvesting method.") }
go
func (method HarvestMode) String() string { if description, ok := harvestingMethodToFlag[method]; ok { return description } panic("Unknown harvesting method.") }
[ "func", "(", "method", "HarvestMode", ")", "String", "(", ")", "string", "{", "if", "description", ",", "ok", ":=", "harvestingMethodToFlag", "[", "method", "]", ";", "ok", "{", "return", "description", "\n", "}", "\n", "panic", "(", "\"", "\"", ")", "...
// String returns the description of the harvesting mode.
[ "String", "returns", "the", "description", "of", "the", "harvesting", "mode", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L294-L299
156,746
juju/juju
environs/config/config.go
PreferredSeries
func PreferredSeries(cfg HasDefaultSeries) string { if series, ok := cfg.DefaultSeries(); ok { return series } return jujuversion.SupportedLTS() }
go
func PreferredSeries(cfg HasDefaultSeries) string { if series, ok := cfg.DefaultSeries(); ok { return series } return jujuversion.SupportedLTS() }
[ "func", "PreferredSeries", "(", "cfg", "HasDefaultSeries", ")", "string", "{", "if", "series", ",", "ok", ":=", "cfg", ".", "DefaultSeries", "(", ")", ";", "ok", "{", "return", "series", "\n", "}", "\n", "return", "jujuversion", ".", "SupportedLTS", "(", ...
// PreferredSeries returns the preferred series to use when a charm does not // explicitly specify a series.
[ "PreferredSeries", "returns", "the", "preferred", "series", "to", "use", "when", "a", "charm", "does", "not", "explicitly", "specify", "a", "series", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L322-L327
156,747
juju/juju
environs/config/config.go
ProcessDeprecatedAttributes
func ProcessDeprecatedAttributes(attrs map[string]interface{}) map[string]interface{} { processedAttrs := make(map[string]interface{}, len(attrs)) for k, v := range attrs { processedAttrs[k] = v } // No deprecated attributes at the moment. return processedAttrs }
go
func ProcessDeprecatedAttributes(attrs map[string]interface{}) map[string]interface{} { processedAttrs := make(map[string]interface{}, len(attrs)) for k, v := range attrs { processedAttrs[k] = v } // No deprecated attributes at the moment. return processedAttrs }
[ "func", "ProcessDeprecatedAttributes", "(", "attrs", "map", "[", "string", "]", "interface", "{", "}", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "processedAttrs", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ",",...
// ProcessDeprecatedAttributes gathers any deprecated attributes in attrs and adds or replaces // them with new name value pairs for the replacement attrs. // Ths ensures that older versions of Juju which require that deprecated // attribute values still be used will work as expected.
[ "ProcessDeprecatedAttributes", "gathers", "any", "deprecated", "attributes", "in", "attrs", "and", "adds", "or", "replaces", "them", "with", "new", "name", "value", "pairs", "for", "the", "replacement", "attrs", ".", "Ths", "ensures", "that", "older", "versions", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L525-L532
156,748
juju/juju
environs/config/config.go
CoerceForStorage
func CoerceForStorage(attrs map[string]interface{}) map[string]interface{} { coercedAttrs := make(map[string]interface{}, len(attrs)) for attrName, attrValue := range attrs { if attrName == ResourceTagsKey { // Resource Tags are specified by the user as a string but transformed // to a map when config is parsed. We want to store as a string. var tagsSlice []string if tags, ok := attrValue.(map[string]string); ok { for resKey, resValue := range tags { tagsSlice = append(tagsSlice, fmt.Sprintf("%v=%v", resKey, resValue)) } attrValue = strings.Join(tagsSlice, " ") } } coercedAttrs[attrName] = attrValue } return coercedAttrs }
go
func CoerceForStorage(attrs map[string]interface{}) map[string]interface{} { coercedAttrs := make(map[string]interface{}, len(attrs)) for attrName, attrValue := range attrs { if attrName == ResourceTagsKey { // Resource Tags are specified by the user as a string but transformed // to a map when config is parsed. We want to store as a string. var tagsSlice []string if tags, ok := attrValue.(map[string]string); ok { for resKey, resValue := range tags { tagsSlice = append(tagsSlice, fmt.Sprintf("%v=%v", resKey, resValue)) } attrValue = strings.Join(tagsSlice, " ") } } coercedAttrs[attrName] = attrValue } return coercedAttrs }
[ "func", "CoerceForStorage", "(", "attrs", "map", "[", "string", "]", "interface", "{", "}", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "coercedAttrs", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "len", "...
// CoerceForStorage transforms attributes prior to being saved in a persistent store.
[ "CoerceForStorage", "transforms", "attributes", "prior", "to", "being", "saved", "in", "a", "persistent", "store", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L535-L552
156,749
juju/juju
environs/config/config.go
ensureStringMaps
func ensureStringMaps(in string) (map[string]interface{}, error) { userDataMap := make(map[string]interface{}) if err := yaml.Unmarshal([]byte(in), &userDataMap); err != nil { return nil, errors.Annotate(err, "must be valid YAML") } out, err := utils.ConformYAML(userDataMap) if err != nil { return nil, err } return out.(map[string]interface{}), nil }
go
func ensureStringMaps(in string) (map[string]interface{}, error) { userDataMap := make(map[string]interface{}) if err := yaml.Unmarshal([]byte(in), &userDataMap); err != nil { return nil, errors.Annotate(err, "must be valid YAML") } out, err := utils.ConformYAML(userDataMap) if err != nil { return nil, err } return out.(map[string]interface{}), nil }
[ "func", "ensureStringMaps", "(", "in", "string", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "userDataMap", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "if", "err", ":=", "...
// ensureStringMaps takes in a string and returns YAML in a map // where all keys of any nested maps are strings.
[ "ensureStringMaps", "takes", "in", "a", "string", "and", "returns", "YAML", "in", "a", "map", "where", "all", "keys", "of", "any", "nested", "maps", "are", "strings", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L752-L762
156,750
juju/juju
environs/config/config.go
asString
func (c *Config) asString(name string) string { value, _ := c.defined[name].(string) return value }
go
func (c *Config) asString(name string) string { value, _ := c.defined[name].(string) return value }
[ "func", "(", "c", "*", "Config", ")", "asString", "(", "name", "string", ")", "string", "{", "value", ",", "_", ":=", "c", ".", "defined", "[", "name", "]", ".", "(", "string", ")", "\n", "return", "value", "\n", "}" ]
// asString is a private helper method to keep the ugly string casting // in once place. It returns the given named attribute as a string, // returning "" if it isn't found.
[ "asString", "is", "a", "private", "helper", "method", "to", "keep", "the", "ugly", "string", "casting", "in", "once", "place", ".", "It", "returns", "the", "given", "named", "attribute", "as", "a", "string", "returning", "if", "it", "isn", "t", "found", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L788-L791
156,751
juju/juju
environs/config/config.go
DefaultSeries
func (c *Config) DefaultSeries() (string, bool) { s, ok := c.defined["default-series"] if !ok { return "", false } switch s := s.(type) { case string: return s, s != "" default: logger.Errorf("invalid default-series: %q", s) return "", false } }
go
func (c *Config) DefaultSeries() (string, bool) { s, ok := c.defined["default-series"] if !ok { return "", false } switch s := s.(type) { case string: return s, s != "" default: logger.Errorf("invalid default-series: %q", s) return "", false } }
[ "func", "(", "c", "*", "Config", ")", "DefaultSeries", "(", ")", "(", "string", ",", "bool", ")", "{", "s", ",", "ok", ":=", "c", ".", "defined", "[", "\"", "\"", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", ",", "false", "\n", "}",...
// DefaultSeries returns the configured default Ubuntu series for the environment, // and whether the default series was explicitly configured on the environment.
[ "DefaultSeries", "returns", "the", "configured", "default", "Ubuntu", "series", "for", "the", "environment", "and", "whether", "the", "default", "series", "was", "explicitly", "configured", "on", "the", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L820-L832
156,752
juju/juju
environs/config/config.go
AuthorizedKeys
func (c *Config) AuthorizedKeys() string { value, _ := c.defined[AuthorizedKeysKey].(string) return value }
go
func (c *Config) AuthorizedKeys() string { value, _ := c.defined[AuthorizedKeysKey].(string) return value }
[ "func", "(", "c", "*", "Config", ")", "AuthorizedKeys", "(", ")", "string", "{", "value", ",", "_", ":=", "c", ".", "defined", "[", "AuthorizedKeysKey", "]", ".", "(", "string", ")", "\n", "return", "value", "\n", "}" ]
// AuthorizedKeys returns the content for ssh's authorized_keys file.
[ "AuthorizedKeys", "returns", "the", "content", "for", "ssh", "s", "authorized_keys", "file", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L835-L838
156,753
juju/juju
environs/config/config.go
ProxySSH
func (c *Config) ProxySSH() bool { value, _ := c.defined["proxy-ssh"].(bool) return value }
go
func (c *Config) ProxySSH() bool { value, _ := c.defined["proxy-ssh"].(bool) return value }
[ "func", "(", "c", "*", "Config", ")", "ProxySSH", "(", ")", "bool", "{", "value", ",", "_", ":=", "c", ".", "defined", "[", "\"", "\"", "]", ".", "(", "bool", ")", "\n", "return", "value", "\n", "}" ]
// ProxySSH returns a flag indicating whether SSH commands // should be proxied through the API server.
[ "ProxySSH", "returns", "a", "flag", "indicating", "whether", "SSH", "commands", "should", "be", "proxied", "through", "the", "API", "server", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L842-L845
156,754
juju/juju
environs/config/config.go
NetBondReconfigureDelay
func (c *Config) NetBondReconfigureDelay() int { value, _ := c.defined[NetBondReconfigureDelayKey].(int) return value }
go
func (c *Config) NetBondReconfigureDelay() int { value, _ := c.defined[NetBondReconfigureDelayKey].(int) return value }
[ "func", "(", "c", "*", "Config", ")", "NetBondReconfigureDelay", "(", ")", "int", "{", "value", ",", "_", ":=", "c", ".", "defined", "[", "NetBondReconfigureDelayKey", "]", ".", "(", "int", ")", "\n", "return", "value", "\n", "}" ]
// NetBondReconfigureDelay returns the duration in seconds that should be // passed to the bridge script when bridging bonded interfaces.
[ "NetBondReconfigureDelay", "returns", "the", "duration", "in", "seconds", "that", "should", "be", "passed", "to", "the", "bridge", "script", "when", "bridging", "bonded", "interfaces", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L849-L852
156,755
juju/juju
environs/config/config.go
LegacyProxySettings
func (c *Config) LegacyProxySettings() proxy.Settings { return proxy.Settings{ Http: c.HTTPProxy(), Https: c.HTTPSProxy(), Ftp: c.FTPProxy(), NoProxy: c.NoProxy(), } }
go
func (c *Config) LegacyProxySettings() proxy.Settings { return proxy.Settings{ Http: c.HTTPProxy(), Https: c.HTTPSProxy(), Ftp: c.FTPProxy(), NoProxy: c.NoProxy(), } }
[ "func", "(", "c", "*", "Config", ")", "LegacyProxySettings", "(", ")", "proxy", ".", "Settings", "{", "return", "proxy", ".", "Settings", "{", "Http", ":", "c", ".", "HTTPProxy", "(", ")", ",", "Https", ":", "c", ".", "HTTPSProxy", "(", ")", ",", "...
// LegacyProxySettings returns all four proxy settings; http, https, ftp, and no // proxy. These are considered legacy as using these values will cause the environment // to be updated, which has shown to not work in many cases. It is being kept to avoid // breaking environments where it is sufficient.
[ "LegacyProxySettings", "returns", "all", "four", "proxy", "settings", ";", "http", "https", "ftp", "and", "no", "proxy", ".", "These", "are", "considered", "legacy", "as", "using", "these", "values", "will", "cause", "the", "environment", "to", "be", "updated"...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L864-L871
156,756
juju/juju
environs/config/config.go
HasLegacyProxy
func (c *Config) HasLegacyProxy() bool { // We exclude the no proxy value as it has default value. return c.HTTPProxy() != "" || c.HTTPSProxy() != "" || c.FTPProxy() != "" }
go
func (c *Config) HasLegacyProxy() bool { // We exclude the no proxy value as it has default value. return c.HTTPProxy() != "" || c.HTTPSProxy() != "" || c.FTPProxy() != "" }
[ "func", "(", "c", "*", "Config", ")", "HasLegacyProxy", "(", ")", "bool", "{", "// We exclude the no proxy value as it has default value.", "return", "c", ".", "HTTPProxy", "(", ")", "!=", "\"", "\"", "||", "c", ".", "HTTPSProxy", "(", ")", "!=", "\"", "\"",...
// HasLegacyProxy returns true if there is any proxy set using the old legacy proxy keys.
[ "HasLegacyProxy", "returns", "true", "if", "there", "is", "any", "proxy", "set", "using", "the", "old", "legacy", "proxy", "keys", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L874-L879
156,757
juju/juju
environs/config/config.go
HasJujuProxy
func (c *Config) HasJujuProxy() bool { // We exclude the no proxy value as it has default value. return c.JujuHTTPProxy() != "" || c.JujuHTTPSProxy() != "" || c.JujuFTPProxy() != "" }
go
func (c *Config) HasJujuProxy() bool { // We exclude the no proxy value as it has default value. return c.JujuHTTPProxy() != "" || c.JujuHTTPSProxy() != "" || c.JujuFTPProxy() != "" }
[ "func", "(", "c", "*", "Config", ")", "HasJujuProxy", "(", ")", "bool", "{", "// We exclude the no proxy value as it has default value.", "return", "c", ".", "JujuHTTPProxy", "(", ")", "!=", "\"", "\"", "||", "c", ".", "JujuHTTPSProxy", "(", ")", "!=", "\"", ...
// HasJujuProxy returns true if there is any proxy set using the new juju-proxy keys.
[ "HasJujuProxy", "returns", "true", "if", "there", "is", "any", "proxy", "set", "using", "the", "new", "juju", "-", "proxy", "keys", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L882-L887
156,758
juju/juju
environs/config/config.go
JujuProxySettings
func (c *Config) JujuProxySettings() proxy.Settings { return proxy.Settings{ Http: c.JujuHTTPProxy(), Https: c.JujuHTTPSProxy(), Ftp: c.JujuFTPProxy(), NoProxy: c.JujuNoProxy(), } }
go
func (c *Config) JujuProxySettings() proxy.Settings { return proxy.Settings{ Http: c.JujuHTTPProxy(), Https: c.JujuHTTPSProxy(), Ftp: c.JujuFTPProxy(), NoProxy: c.JujuNoProxy(), } }
[ "func", "(", "c", "*", "Config", ")", "JujuProxySettings", "(", ")", "proxy", ".", "Settings", "{", "return", "proxy", ".", "Settings", "{", "Http", ":", "c", ".", "JujuHTTPProxy", "(", ")", ",", "Https", ":", "c", ".", "JujuHTTPSProxy", "(", ")", ",...
// JujuProxySettings returns all four proxy settings that have been set using the // juju- prefixed proxy settings. These values determine the current best practice // for proxies.
[ "JujuProxySettings", "returns", "all", "four", "proxy", "settings", "that", "have", "been", "set", "using", "the", "juju", "-", "prefixed", "proxy", "settings", ".", "These", "values", "determine", "the", "current", "best", "practice", "for", "proxies", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L892-L899
156,759
juju/juju
environs/config/config.go
addSchemeIfMissing
func addSchemeIfMissing(defaultScheme string, url string) string { if url != "" && !strings.Contains(url, "://") { url = defaultScheme + "://" + url } return url }
go
func addSchemeIfMissing(defaultScheme string, url string) string { if url != "" && !strings.Contains(url, "://") { url = defaultScheme + "://" + url } return url }
[ "func", "addSchemeIfMissing", "(", "defaultScheme", "string", ",", "url", "string", ")", "string", "{", "if", "url", "!=", "\"", "\"", "&&", "!", "strings", ".", "Contains", "(", "url", ",", "\"", "\"", ")", "{", "url", "=", "defaultScheme", "+", "\"",...
// addSchemeIfMissing adds a scheme to a URL if it is missing
[ "addSchemeIfMissing", "adds", "a", "scheme", "to", "a", "URL", "if", "it", "is", "missing" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L954-L959
156,760
juju/juju
environs/config/config.go
AptProxySettings
func (c *Config) AptProxySettings() proxy.Settings { return proxy.Settings{ Http: c.AptHTTPProxy(), Https: c.AptHTTPSProxy(), Ftp: c.AptFTPProxy(), NoProxy: c.AptNoProxy(), } }
go
func (c *Config) AptProxySettings() proxy.Settings { return proxy.Settings{ Http: c.AptHTTPProxy(), Https: c.AptHTTPSProxy(), Ftp: c.AptFTPProxy(), NoProxy: c.AptNoProxy(), } }
[ "func", "(", "c", "*", "Config", ")", "AptProxySettings", "(", ")", "proxy", ".", "Settings", "{", "return", "proxy", ".", "Settings", "{", "Http", ":", "c", ".", "AptHTTPProxy", "(", ")", ",", "Https", ":", "c", ".", "AptHTTPSProxy", "(", ")", ",", ...
// AptProxySettings returns all three proxy settings; http, https and ftp.
[ "AptProxySettings", "returns", "all", "three", "proxy", "settings", ";", "http", "https", "and", "ftp", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L962-L969
156,761
juju/juju
environs/config/config.go
AptHTTPProxy
func (c *Config) AptHTTPProxy() string { return addSchemeIfMissing("http", c.getWithFallback(AptHTTPProxyKey, JujuHTTPProxyKey, HTTPProxyKey)) }
go
func (c *Config) AptHTTPProxy() string { return addSchemeIfMissing("http", c.getWithFallback(AptHTTPProxyKey, JujuHTTPProxyKey, HTTPProxyKey)) }
[ "func", "(", "c", "*", "Config", ")", "AptHTTPProxy", "(", ")", "string", "{", "return", "addSchemeIfMissing", "(", "\"", "\"", ",", "c", ".", "getWithFallback", "(", "AptHTTPProxyKey", ",", "JujuHTTPProxyKey", ",", "HTTPProxyKey", ")", ")", "\n", "}" ]
// AptHTTPProxy returns the apt http proxy for the environment. // Falls back to the default http-proxy if not specified.
[ "AptHTTPProxy", "returns", "the", "apt", "http", "proxy", "for", "the", "environment", ".", "Falls", "back", "to", "the", "default", "http", "-", "proxy", "if", "not", "specified", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L973-L975
156,762
juju/juju
environs/config/config.go
AptHTTPSProxy
func (c *Config) AptHTTPSProxy() string { return addSchemeIfMissing("https", c.getWithFallback(AptHTTPSProxyKey, JujuHTTPSProxyKey, HTTPSProxyKey)) }
go
func (c *Config) AptHTTPSProxy() string { return addSchemeIfMissing("https", c.getWithFallback(AptHTTPSProxyKey, JujuHTTPSProxyKey, HTTPSProxyKey)) }
[ "func", "(", "c", "*", "Config", ")", "AptHTTPSProxy", "(", ")", "string", "{", "return", "addSchemeIfMissing", "(", "\"", "\"", ",", "c", ".", "getWithFallback", "(", "AptHTTPSProxyKey", ",", "JujuHTTPSProxyKey", ",", "HTTPSProxyKey", ")", ")", "\n", "}" ]
// AptHTTPSProxy returns the apt https proxy for the environment. // Falls back to the default https-proxy if not specified.
[ "AptHTTPSProxy", "returns", "the", "apt", "https", "proxy", "for", "the", "environment", ".", "Falls", "back", "to", "the", "default", "https", "-", "proxy", "if", "not", "specified", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L979-L981
156,763
juju/juju
environs/config/config.go
AptFTPProxy
func (c *Config) AptFTPProxy() string { return addSchemeIfMissing("ftp", c.getWithFallback(AptFTPProxyKey, JujuFTPProxyKey, FTPProxyKey)) }
go
func (c *Config) AptFTPProxy() string { return addSchemeIfMissing("ftp", c.getWithFallback(AptFTPProxyKey, JujuFTPProxyKey, FTPProxyKey)) }
[ "func", "(", "c", "*", "Config", ")", "AptFTPProxy", "(", ")", "string", "{", "return", "addSchemeIfMissing", "(", "\"", "\"", ",", "c", ".", "getWithFallback", "(", "AptFTPProxyKey", ",", "JujuFTPProxyKey", ",", "FTPProxyKey", ")", ")", "\n", "}" ]
// AptFTPProxy returns the apt ftp proxy for the environment. // Falls back to the default ftp-proxy if not specified.
[ "AptFTPProxy", "returns", "the", "apt", "ftp", "proxy", "for", "the", "environment", ".", "Falls", "back", "to", "the", "default", "ftp", "-", "proxy", "if", "not", "specified", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L985-L987
156,764
juju/juju
environs/config/config.go
AptNoProxy
func (c *Config) AptNoProxy() string { value := c.asString(AptNoProxyKey) if value == "" { if c.HasLegacyProxy() { value = c.asString(NoProxyKey) } else { value = c.asString(JujuNoProxyKey) } } return value }
go
func (c *Config) AptNoProxy() string { value := c.asString(AptNoProxyKey) if value == "" { if c.HasLegacyProxy() { value = c.asString(NoProxyKey) } else { value = c.asString(JujuNoProxyKey) } } return value }
[ "func", "(", "c", "*", "Config", ")", "AptNoProxy", "(", ")", "string", "{", "value", ":=", "c", ".", "asString", "(", "AptNoProxyKey", ")", "\n", "if", "value", "==", "\"", "\"", "{", "if", "c", ".", "HasLegacyProxy", "(", ")", "{", "value", "=", ...
// AptNoProxy returns the 'apt-no-proxy' for the environment.
[ "AptNoProxy", "returns", "the", "apt", "-", "no", "-", "proxy", "for", "the", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L990-L1000
156,765
juju/juju
environs/config/config.go
SnapProxySettings
func (c *Config) SnapProxySettings() proxy.Settings { return proxy.Settings{ Http: c.SnapHTTPProxy(), Https: c.SnapHTTPSProxy(), } }
go
func (c *Config) SnapProxySettings() proxy.Settings { return proxy.Settings{ Http: c.SnapHTTPProxy(), Https: c.SnapHTTPSProxy(), } }
[ "func", "(", "c", "*", "Config", ")", "SnapProxySettings", "(", ")", "proxy", ".", "Settings", "{", "return", "proxy", ".", "Settings", "{", "Http", ":", "c", ".", "SnapHTTPProxy", "(", ")", ",", "Https", ":", "c", ".", "SnapHTTPSProxy", "(", ")", ",...
// SnapProxySettings returns the two proxy settings; http, and https.
[ "SnapProxySettings", "returns", "the", "two", "proxy", "settings", ";", "http", "and", "https", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1008-L1013
156,766
juju/juju
environs/config/config.go
LogFwdSyslog
func (c *Config) LogFwdSyslog() (*syslog.RawConfig, bool) { partial := false var lfCfg syslog.RawConfig if s, ok := c.defined[LogForwardEnabled]; ok { partial = true lfCfg.Enabled = s.(bool) } if s, ok := c.defined[LogFwdSyslogHost]; ok && s != "" { partial = true lfCfg.Host = s.(string) } if s, ok := c.defined[LogFwdSyslogCACert]; ok && s != "" { partial = true lfCfg.CACert = s.(string) } if s, ok := c.defined[LogFwdSyslogClientCert]; ok && s != "" { partial = true lfCfg.ClientCert = s.(string) } if s, ok := c.defined[LogFwdSyslogClientKey]; ok && s != "" { partial = true lfCfg.ClientKey = s.(string) } if !partial { return nil, false } return &lfCfg, true }
go
func (c *Config) LogFwdSyslog() (*syslog.RawConfig, bool) { partial := false var lfCfg syslog.RawConfig if s, ok := c.defined[LogForwardEnabled]; ok { partial = true lfCfg.Enabled = s.(bool) } if s, ok := c.defined[LogFwdSyslogHost]; ok && s != "" { partial = true lfCfg.Host = s.(string) } if s, ok := c.defined[LogFwdSyslogCACert]; ok && s != "" { partial = true lfCfg.CACert = s.(string) } if s, ok := c.defined[LogFwdSyslogClientCert]; ok && s != "" { partial = true lfCfg.ClientCert = s.(string) } if s, ok := c.defined[LogFwdSyslogClientKey]; ok && s != "" { partial = true lfCfg.ClientKey = s.(string) } if !partial { return nil, false } return &lfCfg, true }
[ "func", "(", "c", "*", "Config", ")", "LogFwdSyslog", "(", ")", "(", "*", "syslog", ".", "RawConfig", ",", "bool", ")", "{", "partial", ":=", "false", "\n", "var", "lfCfg", "syslog", ".", "RawConfig", "\n\n", "if", "s", ",", "ok", ":=", "c", ".", ...
// LogFwdSyslog returns the syslog forwarding config.
[ "LogFwdSyslog", "returns", "the", "syslog", "forwarding", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1036-L1069
156,767
juju/juju
environs/config/config.go
AgentVersion
func (c *Config) AgentVersion() (version.Number, bool) { if v, ok := c.defined[AgentVersionKey].(string); ok { n, err := version.Parse(v) if err != nil { panic(err) // We should have checked it earlier. } return n, true } return version.Zero, false }
go
func (c *Config) AgentVersion() (version.Number, bool) { if v, ok := c.defined[AgentVersionKey].(string); ok { n, err := version.Parse(v) if err != nil { panic(err) // We should have checked it earlier. } return n, true } return version.Zero, false }
[ "func", "(", "c", "*", "Config", ")", "AgentVersion", "(", ")", "(", "version", ".", "Number", ",", "bool", ")", "{", "if", "v", ",", "ok", ":=", "c", ".", "defined", "[", "AgentVersionKey", "]", ".", "(", "string", ")", ";", "ok", "{", "n", ",...
// AgentVersion returns the proposed version number for the agent tools, // and whether it has been set. Once an environment is bootstrapped, this // must always be valid.
[ "AgentVersion", "returns", "the", "proposed", "version", "number", "for", "the", "agent", "tools", "and", "whether", "it", "has", "been", "set", ".", "Once", "an", "environment", "is", "bootstrapped", "this", "must", "always", "be", "valid", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1081-L1090
156,768
juju/juju
environs/config/config.go
AgentMetadataURL
func (c *Config) AgentMetadataURL() (string, bool) { if url, ok := c.defined[AgentMetadataURLKey]; ok && url != "" { return url.(string), true } return "", false }
go
func (c *Config) AgentMetadataURL() (string, bool) { if url, ok := c.defined[AgentMetadataURLKey]; ok && url != "" { return url.(string), true } return "", false }
[ "func", "(", "c", "*", "Config", ")", "AgentMetadataURL", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "url", ",", "ok", ":=", "c", ".", "defined", "[", "AgentMetadataURLKey", "]", ";", "ok", "&&", "url", "!=", "\"", "\"", "{", "return", ...
// AgentMetadataURL returns the URL that locates the agent tarballs and metadata, // and whether it has been set.
[ "AgentMetadataURL", "returns", "the", "URL", "that", "locates", "the", "agent", "tarballs", "and", "metadata", "and", "whether", "it", "has", "been", "set", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1094-L1099
156,769
juju/juju
environs/config/config.go
ImageMetadataURL
func (c *Config) ImageMetadataURL() (string, bool) { if url, ok := c.defined["image-metadata-url"]; ok && url != "" { return url.(string), true } return "", false }
go
func (c *Config) ImageMetadataURL() (string, bool) { if url, ok := c.defined["image-metadata-url"]; ok && url != "" { return url.(string), true } return "", false }
[ "func", "(", "c", "*", "Config", ")", "ImageMetadataURL", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "url", ",", "ok", ":=", "c", ".", "defined", "[", "\"", "\"", "]", ";", "ok", "&&", "url", "!=", "\"", "\"", "{", "return", "url", ...
// ImageMetadataURL returns the URL at which the metadata used to locate image // ids is located, and whether it has been set.
[ "ImageMetadataURL", "returns", "the", "URL", "at", "which", "the", "metadata", "used", "to", "locate", "image", "ids", "is", "located", "and", "whether", "it", "has", "been", "set", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1103-L1108
156,770
juju/juju
environs/config/config.go
ContainerImageMetadataURL
func (c *Config) ContainerImageMetadataURL() (string, bool) { if url, ok := c.defined[ContainerImageMetadataURLKey]; ok && url != "" { return url.(string), true } return "", false }
go
func (c *Config) ContainerImageMetadataURL() (string, bool) { if url, ok := c.defined[ContainerImageMetadataURLKey]; ok && url != "" { return url.(string), true } return "", false }
[ "func", "(", "c", "*", "Config", ")", "ContainerImageMetadataURL", "(", ")", "(", "string", ",", "bool", ")", "{", "if", "url", ",", "ok", ":=", "c", ".", "defined", "[", "ContainerImageMetadataURLKey", "]", ";", "ok", "&&", "url", "!=", "\"", "\"", ...
// ContainerImageMetadataURL returns the URL at which the metadata used to // locate container OS image ids is located, and whether it has been set.
[ "ContainerImageMetadataURL", "returns", "the", "URL", "at", "which", "the", "metadata", "used", "to", "locate", "container", "OS", "image", "ids", "is", "located", "and", "whether", "it", "has", "been", "set", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1112-L1117
156,771
juju/juju
environs/config/config.go
Development
func (c *Config) Development() bool { value, _ := c.defined["development"].(bool) return value }
go
func (c *Config) Development() bool { value, _ := c.defined["development"].(bool) return value }
[ "func", "(", "c", "*", "Config", ")", "Development", "(", ")", "bool", "{", "value", ",", "_", ":=", "c", ".", "defined", "[", "\"", "\"", "]", ".", "(", "bool", ")", "\n", "return", "value", "\n", "}" ]
// Development returns whether the environment is in development mode.
[ "Development", "returns", "whether", "the", "environment", "is", "in", "development", "mode", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1120-L1123
156,772
juju/juju
environs/config/config.go
EnableOSRefreshUpdate
func (c *Config) EnableOSRefreshUpdate() bool { if val, ok := c.defined["enable-os-refresh-update"].(bool); !ok { return true } else { return val } }
go
func (c *Config) EnableOSRefreshUpdate() bool { if val, ok := c.defined["enable-os-refresh-update"].(bool); !ok { return true } else { return val } }
[ "func", "(", "c", "*", "Config", ")", "EnableOSRefreshUpdate", "(", ")", "bool", "{", "if", "val", ",", "ok", ":=", "c", ".", "defined", "[", "\"", "\"", "]", ".", "(", "bool", ")", ";", "!", "ok", "{", "return", "true", "\n", "}", "else", "{",...
// EnableOSRefreshUpdate returns whether or not newly provisioned // instances should run their respective OS's update capability.
[ "EnableOSRefreshUpdate", "returns", "whether", "or", "not", "newly", "provisioned", "instances", "should", "run", "their", "respective", "OS", "s", "update", "capability", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1127-L1133
156,773
juju/juju
environs/config/config.go
EnableOSUpgrade
func (c *Config) EnableOSUpgrade() bool { if val, ok := c.defined["enable-os-upgrade"].(bool); !ok { return true } else { return val } }
go
func (c *Config) EnableOSUpgrade() bool { if val, ok := c.defined["enable-os-upgrade"].(bool); !ok { return true } else { return val } }
[ "func", "(", "c", "*", "Config", ")", "EnableOSUpgrade", "(", ")", "bool", "{", "if", "val", ",", "ok", ":=", "c", ".", "defined", "[", "\"", "\"", "]", ".", "(", "bool", ")", ";", "!", "ok", "{", "return", "true", "\n", "}", "else", "{", "re...
// EnableOSUpgrade returns whether or not newly provisioned instances // should run their respective OS's upgrade capability.
[ "EnableOSUpgrade", "returns", "whether", "or", "not", "newly", "provisioned", "instances", "should", "run", "their", "respective", "OS", "s", "upgrade", "capability", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1137-L1143
156,774
juju/juju
environs/config/config.go
AutomaticallyRetryHooks
func (c *Config) AutomaticallyRetryHooks() bool { if val, ok := c.defined["automatically-retry-hooks"].(bool); !ok { return true } else { return val } }
go
func (c *Config) AutomaticallyRetryHooks() bool { if val, ok := c.defined["automatically-retry-hooks"].(bool); !ok { return true } else { return val } }
[ "func", "(", "c", "*", "Config", ")", "AutomaticallyRetryHooks", "(", ")", "bool", "{", "if", "val", ",", "ok", ":=", "c", ".", "defined", "[", "\"", "\"", "]", ".", "(", "bool", ")", ";", "!", "ok", "{", "return", "true", "\n", "}", "else", "{...
// AutomaticallyRetryHooks returns whether we should automatically retry hooks. // By default this should be true.
[ "AutomaticallyRetryHooks", "returns", "whether", "we", "should", "automatically", "retry", "hooks", ".", "By", "default", "this", "should", "be", "true", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1164-L1170
156,775
juju/juju
environs/config/config.go
TransmitVendorMetrics
func (c *Config) TransmitVendorMetrics() bool { if val, ok := c.defined[TransmitVendorMetricsKey].(bool); !ok { return true } else { return val } }
go
func (c *Config) TransmitVendorMetrics() bool { if val, ok := c.defined[TransmitVendorMetricsKey].(bool); !ok { return true } else { return val } }
[ "func", "(", "c", "*", "Config", ")", "TransmitVendorMetrics", "(", ")", "bool", "{", "if", "val", ",", "ok", ":=", "c", ".", "defined", "[", "TransmitVendorMetricsKey", "]", ".", "(", "bool", ")", ";", "!", "ok", "{", "return", "true", "\n", "}", ...
// TransmitVendorMetrics returns whether the controller sends charm-collected metrics // in this model for anonymized aggregate analytics. By default this should be true.
[ "TransmitVendorMetrics", "returns", "whether", "the", "controller", "sends", "charm", "-", "collected", "metrics", "in", "this", "model", "for", "anonymized", "aggregate", "analytics", ".", "By", "default", "this", "should", "be", "true", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1174-L1180
156,776
juju/juju
environs/config/config.go
ProvisionerHarvestMode
func (c *Config) ProvisionerHarvestMode() HarvestMode { if v, ok := c.defined[ProvisionerHarvestModeKey].(string); ok { if method, err := ParseHarvestMode(v); err != nil { // This setting should have already been validated. Don't // burden the caller with handling any errors. panic(err) } else { return method } } else { return HarvestDestroyed } }
go
func (c *Config) ProvisionerHarvestMode() HarvestMode { if v, ok := c.defined[ProvisionerHarvestModeKey].(string); ok { if method, err := ParseHarvestMode(v); err != nil { // This setting should have already been validated. Don't // burden the caller with handling any errors. panic(err) } else { return method } } else { return HarvestDestroyed } }
[ "func", "(", "c", "*", "Config", ")", "ProvisionerHarvestMode", "(", ")", "HarvestMode", "{", "if", "v", ",", "ok", ":=", "c", ".", "defined", "[", "ProvisionerHarvestModeKey", "]", ".", "(", "string", ")", ";", "ok", "{", "if", "method", ",", "err", ...
// ProvisionerHarvestMode reports the harvesting methodology the // provisioner should take.
[ "ProvisionerHarvestMode", "reports", "the", "harvesting", "methodology", "the", "provisioner", "should", "take", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1184-L1196
156,777
juju/juju
environs/config/config.go
ImageStream
func (c *Config) ImageStream() string { v, _ := c.defined["image-stream"].(string) if v != "" { return v } return "released" }
go
func (c *Config) ImageStream() string { v, _ := c.defined["image-stream"].(string) if v != "" { return v } return "released" }
[ "func", "(", "c", "*", "Config", ")", "ImageStream", "(", ")", "string", "{", "v", ",", "_", ":=", "c", ".", "defined", "[", "\"", "\"", "]", ".", "(", "string", ")", "\n", "if", "v", "!=", "\"", "\"", "{", "return", "v", "\n", "}", "\n", "...
// ImageStream returns the simplestreams stream // used to identify which image ids to search // when starting an instance.
[ "ImageStream", "returns", "the", "simplestreams", "stream", "used", "to", "identify", "which", "image", "ids", "to", "search", "when", "starting", "an", "instance", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1201-L1207
156,778
juju/juju
environs/config/config.go
AgentStream
func (c *Config) AgentStream() string { v, _ := c.defined[AgentStreamKey].(string) if v != "" { return v } return "released" }
go
func (c *Config) AgentStream() string { v, _ := c.defined[AgentStreamKey].(string) if v != "" { return v } return "released" }
[ "func", "(", "c", "*", "Config", ")", "AgentStream", "(", ")", "string", "{", "v", ",", "_", ":=", "c", ".", "defined", "[", "AgentStreamKey", "]", ".", "(", "string", ")", "\n", "if", "v", "!=", "\"", "\"", "{", "return", "v", "\n", "}", "\n",...
// AgentStream returns the simplestreams stream // used to identify which tools to use when // when bootstrapping or upgrading an environment.
[ "AgentStream", "returns", "the", "simplestreams", "stream", "used", "to", "identify", "which", "tools", "to", "use", "when", "when", "bootstrapping", "or", "upgrading", "an", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1212-L1218
156,779
juju/juju
environs/config/config.go
ContainerImageStream
func (c *Config) ContainerImageStream() string { v, _ := c.defined[ContainerImageStreamKey].(string) if v != "" { return v } return "released" }
go
func (c *Config) ContainerImageStream() string { v, _ := c.defined[ContainerImageStreamKey].(string) if v != "" { return v } return "released" }
[ "func", "(", "c", "*", "Config", ")", "ContainerImageStream", "(", ")", "string", "{", "v", ",", "_", ":=", "c", ".", "defined", "[", "ContainerImageStreamKey", "]", ".", "(", "string", ")", "\n", "if", "v", "!=", "\"", "\"", "{", "return", "v", "\...
// ContainerImageStream returns the simplestreams stream used to identify which // image ids to search when starting a container.
[ "ContainerImageStream", "returns", "the", "simplestreams", "stream", "used", "to", "identify", "which", "image", "ids", "to", "search", "when", "starting", "a", "container", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1222-L1228
156,780
juju/juju
environs/config/config.go
DisableNetworkManagement
func (c *Config) DisableNetworkManagement() (bool, bool) { v, ok := c.defined["disable-network-management"].(bool) return v, ok }
go
func (c *Config) DisableNetworkManagement() (bool, bool) { v, ok := c.defined["disable-network-management"].(bool) return v, ok }
[ "func", "(", "c", "*", "Config", ")", "DisableNetworkManagement", "(", ")", "(", "bool", ",", "bool", ")", "{", "v", ",", "ok", ":=", "c", ".", "defined", "[", "\"", "\"", "]", ".", "(", "bool", ")", "\n", "return", "v", ",", "ok", "\n", "}" ]
// DisableNetworkManagement reports whether Juju is allowed to // configure and manage networking inside the environment.
[ "DisableNetworkManagement", "reports", "whether", "Juju", "is", "allowed", "to", "configure", "and", "manage", "networking", "inside", "the", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1240-L1243
156,781
juju/juju
environs/config/config.go
IgnoreMachineAddresses
func (c *Config) IgnoreMachineAddresses() (bool, bool) { v, ok := c.defined[IgnoreMachineAddresses].(bool) return v, ok }
go
func (c *Config) IgnoreMachineAddresses() (bool, bool) { v, ok := c.defined[IgnoreMachineAddresses].(bool) return v, ok }
[ "func", "(", "c", "*", "Config", ")", "IgnoreMachineAddresses", "(", ")", "(", "bool", ",", "bool", ")", "{", "v", ",", "ok", ":=", "c", ".", "defined", "[", "IgnoreMachineAddresses", "]", ".", "(", "bool", ")", "\n", "return", "v", ",", "ok", "\n"...
// IgnoreMachineAddresses reports whether Juju will discover // and store machine addresses on startup.
[ "IgnoreMachineAddresses", "reports", "whether", "Juju", "will", "discover", "and", "store", "machine", "addresses", "on", "startup", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1247-L1250
156,782
juju/juju
environs/config/config.go
StorageDefaultBlockSource
func (c *Config) StorageDefaultBlockSource() (string, bool) { bs := c.asString(StorageDefaultBlockSourceKey) return bs, bs != "" }
go
func (c *Config) StorageDefaultBlockSource() (string, bool) { bs := c.asString(StorageDefaultBlockSourceKey) return bs, bs != "" }
[ "func", "(", "c", "*", "Config", ")", "StorageDefaultBlockSource", "(", ")", "(", "string", ",", "bool", ")", "{", "bs", ":=", "c", ".", "asString", "(", "StorageDefaultBlockSourceKey", ")", "\n", "return", "bs", ",", "bs", "!=", "\"", "\"", "\n", "}" ...
// StorageDefaultBlockSource returns the default block storage // source for the environment.
[ "StorageDefaultBlockSource", "returns", "the", "default", "block", "storage", "source", "for", "the", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1254-L1257
156,783
juju/juju
environs/config/config.go
StorageDefaultFilesystemSource
func (c *Config) StorageDefaultFilesystemSource() (string, bool) { bs := c.asString(StorageDefaultFilesystemSourceKey) return bs, bs != "" }
go
func (c *Config) StorageDefaultFilesystemSource() (string, bool) { bs := c.asString(StorageDefaultFilesystemSourceKey) return bs, bs != "" }
[ "func", "(", "c", "*", "Config", ")", "StorageDefaultFilesystemSource", "(", ")", "(", "string", ",", "bool", ")", "{", "bs", ":=", "c", ".", "asString", "(", "StorageDefaultFilesystemSourceKey", ")", "\n", "return", "bs", ",", "bs", "!=", "\"", "\"", "\...
// StorageDefaultFilesystemSource returns the default filesystem // storage source for the environment.
[ "StorageDefaultFilesystemSource", "returns", "the", "default", "filesystem", "storage", "source", "for", "the", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1261-L1264
156,784
juju/juju
environs/config/config.go
ResourceTags
func (c *Config) ResourceTags() (map[string]string, bool) { tags, err := c.resourceTags() if err != nil { panic(err) // should be prevented by Validate } return tags, tags != nil }
go
func (c *Config) ResourceTags() (map[string]string, bool) { tags, err := c.resourceTags() if err != nil { panic(err) // should be prevented by Validate } return tags, tags != nil }
[ "func", "(", "c", "*", "Config", ")", "ResourceTags", "(", ")", "(", "map", "[", "string", "]", "string", ",", "bool", ")", "{", "tags", ",", "err", ":=", "c", ".", "resourceTags", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "e...
// ResourceTags returns a set of tags to set on environment resources // that Juju creates and manages, if the provider supports them. These // tags have no special meaning to Juju, but may be used for existing // chargeback accounting schemes or other identification purposes.
[ "ResourceTags", "returns", "a", "set", "of", "tags", "to", "set", "on", "environment", "resources", "that", "Juju", "creates", "and", "manages", "if", "the", "provider", "supports", "them", ".", "These", "tags", "have", "no", "special", "meaning", "to", "Juj...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1270-L1276
156,785
juju/juju
environs/config/config.go
MaxStatusHistorySizeMB
func (c *Config) MaxStatusHistorySizeMB() uint { // Value has already been validated. val, _ := utils.ParseSize(c.mustString(MaxStatusHistorySize)) return uint(val) }
go
func (c *Config) MaxStatusHistorySizeMB() uint { // Value has already been validated. val, _ := utils.ParseSize(c.mustString(MaxStatusHistorySize)) return uint(val) }
[ "func", "(", "c", "*", "Config", ")", "MaxStatusHistorySizeMB", "(", ")", "uint", "{", "// Value has already been validated.", "val", ",", "_", ":=", "utils", ".", "ParseSize", "(", "c", ".", "mustString", "(", "MaxStatusHistorySize", ")", ")", "\n", "return",...
// MaxStatusHistorySizeMB is the maximum size in MiB which the status history // collection can grow to before being pruned.
[ "MaxStatusHistorySizeMB", "is", "the", "maximum", "size", "in", "MiB", "which", "the", "status", "history", "collection", "can", "grow", "to", "before", "being", "pruned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1301-L1305
156,786
juju/juju
environs/config/config.go
UpdateStatusHookInterval
func (c *Config) UpdateStatusHookInterval() time.Duration { // TODO(wallyworld) - remove this work around when possible as // we already have a defaulting mechanism for config. // It's only here to guard against using Juju clients >= 2.2 // with Juju controllers running 2.1.x raw := c.asString(UpdateStatusHookInterval) if raw == "" { raw = DefaultUpdateStatusHookInterval } // Value has already been validated. val, _ := time.ParseDuration(raw) return val }
go
func (c *Config) UpdateStatusHookInterval() time.Duration { // TODO(wallyworld) - remove this work around when possible as // we already have a defaulting mechanism for config. // It's only here to guard against using Juju clients >= 2.2 // with Juju controllers running 2.1.x raw := c.asString(UpdateStatusHookInterval) if raw == "" { raw = DefaultUpdateStatusHookInterval } // Value has already been validated. val, _ := time.ParseDuration(raw) return val }
[ "func", "(", "c", "*", "Config", ")", "UpdateStatusHookInterval", "(", ")", "time", ".", "Duration", "{", "// TODO(wallyworld) - remove this work around when possible as", "// we already have a defaulting mechanism for config.", "// It's only here to guard against using Juju clients >=...
// UpdateStatusHookInterval is how often to run the charm // update-status hook.
[ "UpdateStatusHookInterval", "is", "how", "often", "to", "run", "the", "charm", "update", "-", "status", "hook", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1321-L1333
156,787
juju/juju
environs/config/config.go
EgressSubnets
func (c *Config) EgressSubnets() []string { raw := c.asString(EgressSubnets) if raw == "" { return []string{} } // Value has already been validated. rawAddr := strings.Split(raw, ",") result := make([]string, len(rawAddr)) for i, addr := range rawAddr { result[i] = strings.TrimSpace(addr) } return result }
go
func (c *Config) EgressSubnets() []string { raw := c.asString(EgressSubnets) if raw == "" { return []string{} } // Value has already been validated. rawAddr := strings.Split(raw, ",") result := make([]string, len(rawAddr)) for i, addr := range rawAddr { result[i] = strings.TrimSpace(addr) } return result }
[ "func", "(", "c", "*", "Config", ")", "EgressSubnets", "(", ")", "[", "]", "string", "{", "raw", ":=", "c", ".", "asString", "(", "EgressSubnets", ")", "\n", "if", "raw", "==", "\"", "\"", "{", "return", "[", "]", "string", "{", "}", "\n", "}", ...
// EgressSubnets are the source addresses from which traffic from this model // originates if the model is deployed such that NAT or similar is in use.
[ "EgressSubnets", "are", "the", "source", "addresses", "from", "which", "traffic", "from", "this", "model", "originates", "if", "the", "model", "is", "deployed", "such", "that", "NAT", "or", "similar", "is", "in", "use", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1337-L1349
156,788
juju/juju
environs/config/config.go
FanConfig
func (c *Config) FanConfig() (network.FanConfig, error) { // At this point we are sure that the line is valid. return network.ParseFanConfig(c.asString(FanConfig)) }
go
func (c *Config) FanConfig() (network.FanConfig, error) { // At this point we are sure that the line is valid. return network.ParseFanConfig(c.asString(FanConfig)) }
[ "func", "(", "c", "*", "Config", ")", "FanConfig", "(", ")", "(", "network", ".", "FanConfig", ",", "error", ")", "{", "// At this point we are sure that the line is valid.", "return", "network", ".", "ParseFanConfig", "(", "c", ".", "asString", "(", "FanConfig"...
// FanConfig is the configuration of FAN network running in the model.
[ "FanConfig", "is", "the", "configuration", "of", "FAN", "network", "running", "in", "the", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1352-L1355
156,789
juju/juju
environs/config/config.go
CloudInitUserData
func (c *Config) CloudInitUserData() map[string]interface{} { raw := c.asString(CloudInitUserDataKey) if raw == "" { return nil } // The raw data has already passed Validate() conformingUserDataMap, _ := ensureStringMaps(raw) return conformingUserDataMap }
go
func (c *Config) CloudInitUserData() map[string]interface{} { raw := c.asString(CloudInitUserDataKey) if raw == "" { return nil } // The raw data has already passed Validate() conformingUserDataMap, _ := ensureStringMaps(raw) return conformingUserDataMap }
[ "func", "(", "c", "*", "Config", ")", "CloudInitUserData", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "raw", ":=", "c", ".", "asString", "(", "CloudInitUserDataKey", ")", "\n", "if", "raw", "==", "\"", "\"", "{", "return", "nil"...
// CloudInitUserData returns a copy of the raw user data attributes // that were specified by the user.
[ "CloudInitUserData", "returns", "a", "copy", "of", "the", "raw", "user", "data", "attributes", "that", "were", "specified", "by", "the", "user", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1359-L1367
156,790
juju/juju
environs/config/config.go
UnknownAttrs
func (c *Config) UnknownAttrs() map[string]interface{} { newAttrs := make(map[string]interface{}) for k, v := range c.unknown { newAttrs[k] = v } return newAttrs }
go
func (c *Config) UnknownAttrs() map[string]interface{} { newAttrs := make(map[string]interface{}) for k, v := range c.unknown { newAttrs[k] = v } return newAttrs }
[ "func", "(", "c", "*", "Config", ")", "UnknownAttrs", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "newAttrs", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "for", "k", ",", "v", ":=", "range"...
// UnknownAttrs returns a copy of the raw configuration attributes // that are supposedly specific to the environment type. They could // also be wrong attributes, though. Only the specific environment // implementation can tell.
[ "UnknownAttrs", "returns", "a", "copy", "of", "the", "raw", "configuration", "attributes", "that", "are", "supposedly", "specific", "to", "the", "environment", "type", ".", "They", "could", "also", "be", "wrong", "attributes", "though", ".", "Only", "the", "sp...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1379-L1385
156,791
juju/juju
environs/config/config.go
AllAttrs
func (c *Config) AllAttrs() map[string]interface{} { allAttrs := c.UnknownAttrs() for k, v := range c.defined { allAttrs[k] = v } return allAttrs }
go
func (c *Config) AllAttrs() map[string]interface{} { allAttrs := c.UnknownAttrs() for k, v := range c.defined { allAttrs[k] = v } return allAttrs }
[ "func", "(", "c", "*", "Config", ")", "AllAttrs", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "allAttrs", ":=", "c", ".", "UnknownAttrs", "(", ")", "\n", "for", "k", ",", "v", ":=", "range", "c", ".", "defined", "{", "allAttr...
// AllAttrs returns a copy of the raw configuration attributes.
[ "AllAttrs", "returns", "a", "copy", "of", "the", "raw", "configuration", "attributes", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1388-L1394
156,792
juju/juju
environs/config/config.go
Remove
func (c *Config) Remove(attrs []string) (*Config, error) { defined := c.AllAttrs() for _, k := range attrs { delete(defined, k) } return New(NoDefaults, defined) }
go
func (c *Config) Remove(attrs []string) (*Config, error) { defined := c.AllAttrs() for _, k := range attrs { delete(defined, k) } return New(NoDefaults, defined) }
[ "func", "(", "c", "*", "Config", ")", "Remove", "(", "attrs", "[", "]", "string", ")", "(", "*", "Config", ",", "error", ")", "{", "defined", ":=", "c", ".", "AllAttrs", "(", ")", "\n", "for", "_", ",", "k", ":=", "range", "attrs", "{", "delete...
// Remove returns a new configuration that has the attributes of c minus attrs.
[ "Remove", "returns", "a", "new", "configuration", "that", "has", "the", "attributes", "of", "c", "minus", "attrs", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1397-L1403
156,793
juju/juju
environs/config/config.go
Apply
func (c *Config) Apply(attrs map[string]interface{}) (*Config, error) { defined := c.AllAttrs() for k, v := range attrs { defined[k] = v } return New(NoDefaults, defined) }
go
func (c *Config) Apply(attrs map[string]interface{}) (*Config, error) { defined := c.AllAttrs() for k, v := range attrs { defined[k] = v } return New(NoDefaults, defined) }
[ "func", "(", "c", "*", "Config", ")", "Apply", "(", "attrs", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "*", "Config", ",", "error", ")", "{", "defined", ":=", "c", ".", "AllAttrs", "(", ")", "\n", "for", "k", ",", "v", ":=", ...
// Apply returns a new configuration that has the attributes of c plus attrs.
[ "Apply", "returns", "a", "new", "configuration", "that", "has", "the", "attributes", "of", "c", "plus", "attrs", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1406-L1412
156,794
juju/juju
environs/config/config.go
allDefaults
func allDefaults() schema.Defaults { d := schema.Defaults{} configDefaults := ConfigDefaults() for attr, val := range configDefaults { d[attr] = val } for attr, val := range alwaysOptional { if _, ok := d[attr]; !ok { d[attr] = val } } return d }
go
func allDefaults() schema.Defaults { d := schema.Defaults{} configDefaults := ConfigDefaults() for attr, val := range configDefaults { d[attr] = val } for attr, val := range alwaysOptional { if _, ok := d[attr]; !ok { d[attr] = val } } return d }
[ "func", "allDefaults", "(", ")", "schema", ".", "Defaults", "{", "d", ":=", "schema", ".", "Defaults", "{", "}", "\n", "configDefaults", ":=", "ConfigDefaults", "(", ")", "\n", "for", "attr", ",", "val", ":=", "range", "configDefaults", "{", "d", "[", ...
// allDefaults returns a schema.Defaults that contains // defaults to be used when creating a new config with // UseDefaults.
[ "allDefaults", "returns", "a", "schema", ".", "Defaults", "that", "contains", "defaults", "to", "be", "used", "when", "creating", "a", "new", "config", "with", "UseDefaults", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1513-L1525
156,795
juju/juju
environs/config/config.go
SpecializeCharmRepo
func SpecializeCharmRepo(repo charmrepo.Interface, cfg *Config) charmrepo.Interface { type specializer interface { WithTestMode() charmrepo.Interface } if store, ok := repo.(specializer); ok { if cfg.TestMode() { return store.WithTestMode() } } return repo }
go
func SpecializeCharmRepo(repo charmrepo.Interface, cfg *Config) charmrepo.Interface { type specializer interface { WithTestMode() charmrepo.Interface } if store, ok := repo.(specializer); ok { if cfg.TestMode() { return store.WithTestMode() } } return repo }
[ "func", "SpecializeCharmRepo", "(", "repo", "charmrepo", ".", "Interface", ",", "cfg", "*", "Config", ")", "charmrepo", ".", "Interface", "{", "type", "specializer", "interface", "{", "WithTestMode", "(", ")", "charmrepo", ".", "Interface", "\n", "}", "\n", ...
// SpecializeCharmRepo customizes a repository for a given configuration. // It returns a charm repository with test mode enabled if applicable.
[ "SpecializeCharmRepo", "customizes", "a", "repository", "for", "a", "given", "configuration", ".", "It", "returns", "a", "charm", "repository", "with", "test", "mode", "enabled", "if", "applicable", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1596-L1606
156,796
juju/juju
environs/config/config.go
ProxyConfigMap
func ProxyConfigMap(proxySettings proxy.Settings) map[string]interface{} { settings := make(map[string]interface{}) addIfNotEmpty(settings, HTTPProxyKey, proxySettings.Http) addIfNotEmpty(settings, HTTPSProxyKey, proxySettings.Https) addIfNotEmpty(settings, FTPProxyKey, proxySettings.Ftp) addIfNotEmpty(settings, NoProxyKey, proxySettings.NoProxy) return settings }
go
func ProxyConfigMap(proxySettings proxy.Settings) map[string]interface{} { settings := make(map[string]interface{}) addIfNotEmpty(settings, HTTPProxyKey, proxySettings.Http) addIfNotEmpty(settings, HTTPSProxyKey, proxySettings.Https) addIfNotEmpty(settings, FTPProxyKey, proxySettings.Ftp) addIfNotEmpty(settings, NoProxyKey, proxySettings.NoProxy) return settings }
[ "func", "ProxyConfigMap", "(", "proxySettings", "proxy", ".", "Settings", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "settings", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "addIfNotEmpty", "(", "setti...
// ProxyConfigMap returns a map suitable to be applied to a Config to update // proxy settings.
[ "ProxyConfigMap", "returns", "a", "map", "suitable", "to", "be", "applied", "to", "a", "Config", "to", "update", "proxy", "settings", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1616-L1623
156,797
juju/juju
environs/config/config.go
AptProxyConfigMap
func AptProxyConfigMap(proxySettings proxy.Settings) map[string]interface{} { settings := make(map[string]interface{}) addIfNotEmpty(settings, AptHTTPProxyKey, proxySettings.Http) addIfNotEmpty(settings, AptHTTPSProxyKey, proxySettings.Https) addIfNotEmpty(settings, AptFTPProxyKey, proxySettings.Ftp) addIfNotEmpty(settings, AptNoProxyKey, proxySettings.NoProxy) return settings }
go
func AptProxyConfigMap(proxySettings proxy.Settings) map[string]interface{} { settings := make(map[string]interface{}) addIfNotEmpty(settings, AptHTTPProxyKey, proxySettings.Http) addIfNotEmpty(settings, AptHTTPSProxyKey, proxySettings.Https) addIfNotEmpty(settings, AptFTPProxyKey, proxySettings.Ftp) addIfNotEmpty(settings, AptNoProxyKey, proxySettings.NoProxy) return settings }
[ "func", "AptProxyConfigMap", "(", "proxySettings", "proxy", ".", "Settings", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "settings", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n", "addIfNotEmpty", "(", "se...
// AptProxyConfigMap returns a map suitable to be applied to a Config to update // proxy settings.
[ "AptProxyConfigMap", "returns", "a", "map", "suitable", "to", "be", "applied", "to", "a", "Config", "to", "update", "proxy", "settings", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1627-L1634
156,798
juju/juju
environs/config/config.go
Schema
func Schema(extra environschema.Fields) (environschema.Fields, error) { fields := make(environschema.Fields) for name, field := range configSchema { if controller.ControllerOnlyAttribute(name) { return nil, errors.Errorf("config field %q clashes with controller config", name) } fields[name] = field } for name, field := range extra { if controller.ControllerOnlyAttribute(name) { return nil, errors.Errorf("config field %q clashes with controller config", name) } if _, ok := fields[name]; ok { return nil, errors.Errorf("config field %q clashes with global config", name) } fields[name] = field } return fields, nil }
go
func Schema(extra environschema.Fields) (environschema.Fields, error) { fields := make(environschema.Fields) for name, field := range configSchema { if controller.ControllerOnlyAttribute(name) { return nil, errors.Errorf("config field %q clashes with controller config", name) } fields[name] = field } for name, field := range extra { if controller.ControllerOnlyAttribute(name) { return nil, errors.Errorf("config field %q clashes with controller config", name) } if _, ok := fields[name]; ok { return nil, errors.Errorf("config field %q clashes with global config", name) } fields[name] = field } return fields, nil }
[ "func", "Schema", "(", "extra", "environschema", ".", "Fields", ")", "(", "environschema", ".", "Fields", ",", "error", ")", "{", "fields", ":=", "make", "(", "environschema", ".", "Fields", ")", "\n", "for", "name", ",", "field", ":=", "range", "configS...
// Schema returns a configuration schema that includes both // the given extra fields and all the fields defined in this package. // It returns an error if extra defines any fields defined in this // package.
[ "Schema", "returns", "a", "configuration", "schema", "that", "includes", "both", "the", "given", "extra", "fields", "and", "all", "the", "fields", "defined", "in", "this", "package", ".", "It", "returns", "an", "error", "if", "extra", "defines", "any", "fiel...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/config/config.go#L1640-L1658
156,799
juju/juju
environs/sync/sync.go
SyncTools
func SyncTools(syncContext *SyncContext) error { sourceDataSource, err := selectSourceDatasource(syncContext) if err != nil { return errors.Trace(err) } logger.Infof("listing available agent binaries") if syncContext.MajorVersion == 0 && syncContext.MinorVersion == 0 { syncContext.MajorVersion = jujuversion.Current.Major syncContext.MinorVersion = -1 if !syncContext.AllVersions { syncContext.MinorVersion = jujuversion.Current.Minor } } toolsDir := syncContext.Stream // If no stream has been specified, assume "released" for non-devel versions of Juju. if syncContext.Stream == "" { // We now store the tools in a directory named after their stream, but the // legacy behaviour is to store all tools in a single "releases" directory. toolsDir = envtools.ReleasedStream // Always use the primary stream here - the user can specify // to override that decision. syncContext.Stream = envtools.PreferredStreams(&jujuversion.Current, false, "")[0] } // For backwards compatibility with cloud storage, if there are no tools in the specified stream, // double check the release stream. // TODO - remove this when we no longer need to support cloud storage upgrades. streams := []string{syncContext.Stream, envtools.ReleasedStream} sourceTools, err := envtools.FindToolsForCloud( []simplestreams.DataSource{sourceDataSource}, simplestreams.CloudSpec{}, streams, syncContext.MajorVersion, syncContext.MinorVersion, coretools.Filter{}) if err != nil { return errors.Trace(err) } logger.Infof("found %d agent binaries", len(sourceTools)) if !syncContext.AllVersions { var latest version.Number latest, sourceTools = sourceTools.Newest() logger.Infof("found %d recent agent binaries (version %s)", len(sourceTools), latest) } for _, tool := range sourceTools { logger.Debugf("found source agent binary: %v", tool) } logger.Infof("listing target agent binaries storage") targetTools, err := syncContext.TargetToolsFinder.FindTools(syncContext.MajorVersion, syncContext.Stream) switch err { case nil, coretools.ErrNoMatches, envtools.ErrNoTools: default: return errors.Trace(err) } for _, tool := range targetTools { logger.Debugf("found target agent binary: %v", tool) } missing := sourceTools.Exclude(targetTools) logger.Infof("found %d agent binaries in target; %d agent binaries to be copied", len(targetTools), len(missing)) if syncContext.DryRun { for _, tools := range missing { logger.Infof("copying %s from %s", tools.Version, tools.URL) } return nil } err = copyTools(toolsDir, syncContext.Stream, missing, syncContext.TargetToolsUploader) if err != nil { return err } logger.Infof("copied %d agent binaries", len(missing)) return nil }
go
func SyncTools(syncContext *SyncContext) error { sourceDataSource, err := selectSourceDatasource(syncContext) if err != nil { return errors.Trace(err) } logger.Infof("listing available agent binaries") if syncContext.MajorVersion == 0 && syncContext.MinorVersion == 0 { syncContext.MajorVersion = jujuversion.Current.Major syncContext.MinorVersion = -1 if !syncContext.AllVersions { syncContext.MinorVersion = jujuversion.Current.Minor } } toolsDir := syncContext.Stream // If no stream has been specified, assume "released" for non-devel versions of Juju. if syncContext.Stream == "" { // We now store the tools in a directory named after their stream, but the // legacy behaviour is to store all tools in a single "releases" directory. toolsDir = envtools.ReleasedStream // Always use the primary stream here - the user can specify // to override that decision. syncContext.Stream = envtools.PreferredStreams(&jujuversion.Current, false, "")[0] } // For backwards compatibility with cloud storage, if there are no tools in the specified stream, // double check the release stream. // TODO - remove this when we no longer need to support cloud storage upgrades. streams := []string{syncContext.Stream, envtools.ReleasedStream} sourceTools, err := envtools.FindToolsForCloud( []simplestreams.DataSource{sourceDataSource}, simplestreams.CloudSpec{}, streams, syncContext.MajorVersion, syncContext.MinorVersion, coretools.Filter{}) if err != nil { return errors.Trace(err) } logger.Infof("found %d agent binaries", len(sourceTools)) if !syncContext.AllVersions { var latest version.Number latest, sourceTools = sourceTools.Newest() logger.Infof("found %d recent agent binaries (version %s)", len(sourceTools), latest) } for _, tool := range sourceTools { logger.Debugf("found source agent binary: %v", tool) } logger.Infof("listing target agent binaries storage") targetTools, err := syncContext.TargetToolsFinder.FindTools(syncContext.MajorVersion, syncContext.Stream) switch err { case nil, coretools.ErrNoMatches, envtools.ErrNoTools: default: return errors.Trace(err) } for _, tool := range targetTools { logger.Debugf("found target agent binary: %v", tool) } missing := sourceTools.Exclude(targetTools) logger.Infof("found %d agent binaries in target; %d agent binaries to be copied", len(targetTools), len(missing)) if syncContext.DryRun { for _, tools := range missing { logger.Infof("copying %s from %s", tools.Version, tools.URL) } return nil } err = copyTools(toolsDir, syncContext.Stream, missing, syncContext.TargetToolsUploader) if err != nil { return err } logger.Infof("copied %d agent binaries", len(missing)) return nil }
[ "func", "SyncTools", "(", "syncContext", "*", "SyncContext", ")", "error", "{", "sourceDataSource", ",", "err", ":=", "selectSourceDatasource", "(", "syncContext", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", ...
// SyncTools copies the Juju tools tarball from the official bucket // or a specified source directory into the user's environment.
[ "SyncTools", "copies", "the", "Juju", "tools", "tarball", "from", "the", "official", "bucket", "or", "a", "specified", "source", "directory", "into", "the", "user", "s", "environment", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/sync/sync.go#L76-L148