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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
juju/juju | apiserver/facades/agent/instancemutater/mocks/facade_mock.go | AuthOwner | func (m *MockAuthorizer) AuthOwner(arg0 names_v2.Tag) bool {
ret := m.ctrl.Call(m, "AuthOwner", arg0)
ret0, _ := ret[0].(bool)
return ret0
} | go | func (m *MockAuthorizer) AuthOwner(arg0 names_v2.Tag) bool {
ret := m.ctrl.Call(m, "AuthOwner", arg0)
ret0, _ := ret[0].(bool)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAuthorizer",
")",
"AuthOwner",
"(",
"arg0",
"names_v2",
".",
"Tag",
")",
"bool",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",... | // AuthOwner mocks base method | [
"AuthOwner",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/facade_mock.go#L344-L348 | train |
juju/juju | apiserver/facades/agent/instancemutater/mocks/facade_mock.go | ConnectedModel | func (m *MockAuthorizer) ConnectedModel() string {
ret := m.ctrl.Call(m, "ConnectedModel")
ret0, _ := ret[0].(string)
return ret0
} | go | func (m *MockAuthorizer) ConnectedModel() string {
ret := m.ctrl.Call(m, "ConnectedModel")
ret0, _ := ret[0].(string)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAuthorizer",
")",
"ConnectedModel",
"(",
")",
"string",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"string",
")",
... | // ConnectedModel mocks base method | [
"ConnectedModel",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/facade_mock.go#L368-L372 | train |
juju/juju | apiserver/facades/agent/instancemutater/mocks/facade_mock.go | GetAuthTag | func (m *MockAuthorizer) GetAuthTag() names_v2.Tag {
ret := m.ctrl.Call(m, "GetAuthTag")
ret0, _ := ret[0].(names_v2.Tag)
return ret0
} | go | func (m *MockAuthorizer) GetAuthTag() names_v2.Tag {
ret := m.ctrl.Call(m, "GetAuthTag")
ret0, _ := ret[0].(names_v2.Tag)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAuthorizer",
")",
"GetAuthTag",
"(",
")",
"names_v2",
".",
"Tag",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"name... | // GetAuthTag mocks base method | [
"GetAuthTag",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/facade_mock.go#L380-L384 | train |
juju/juju | apiserver/facades/agent/instancemutater/mocks/facade_mock.go | HasPermission | func (m *MockAuthorizer) HasPermission(arg0 permission.Access, arg1 names_v2.Tag) (bool, error) {
ret := m.ctrl.Call(m, "HasPermission", arg0, arg1)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockAuthorizer) HasPermission(arg0 permission.Access, arg1 names_v2.Tag) (bool, error) {
ret := m.ctrl.Call(m, "HasPermission", arg0, arg1)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockAuthorizer",
")",
"HasPermission",
"(",
"arg0",
"permission",
".",
"Access",
",",
"arg1",
"names_v2",
".",
"Tag",
")",
"(",
"bool",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",... | // HasPermission mocks base method | [
"HasPermission",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/facade_mock.go#L392-L397 | train |
juju/juju | apiserver/facades/agent/instancemutater/mocks/facade_mock.go | HasPermission | func (mr *MockAuthorizerMockRecorder) HasPermission(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasPermission", reflect.TypeOf((*MockAuthorizer)(nil).HasPermission), arg0, arg1)
} | go | func (mr *MockAuthorizerMockRecorder) HasPermission(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasPermission", reflect.TypeOf((*MockAuthorizer)(nil).HasPermission), arg0, arg1)
} | [
"func",
"(",
"mr",
"*",
"MockAuthorizerMockRecorder",
")",
"HasPermission",
"(",
"arg0",
",",
"arg1",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
... | // HasPermission indicates an expected call of HasPermission | [
"HasPermission",
"indicates",
"an",
"expected",
"call",
"of",
"HasPermission"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/instancemutater/mocks/facade_mock.go#L400-L402 | train |
juju/juju | worker/uniter/runlistener.go | NewRunListener | func NewRunListener(cfg RunListenerConfig) (*RunListener, error) {
if err := cfg.Validate(); err != nil {
return nil, errors.Trace(err)
}
listener, err := sockets.Listen(cfg.SocketPath)
if err != nil {
return nil, errors.Trace(err)
}
runListener := &RunListener{
RunListenerConfig: cfg,
listener: listener,
server: rpc.NewServer(),
closed: make(chan struct{}),
closing: make(chan struct{}),
}
if err := runListener.server.Register(&JujuRunServer{runListener}); err != nil {
return nil, errors.Trace(err)
}
go runListener.Run()
return runListener, nil
} | go | func NewRunListener(cfg RunListenerConfig) (*RunListener, error) {
if err := cfg.Validate(); err != nil {
return nil, errors.Trace(err)
}
listener, err := sockets.Listen(cfg.SocketPath)
if err != nil {
return nil, errors.Trace(err)
}
runListener := &RunListener{
RunListenerConfig: cfg,
listener: listener,
server: rpc.NewServer(),
closed: make(chan struct{}),
closing: make(chan struct{}),
}
if err := runListener.server.Register(&JujuRunServer{runListener}); err != nil {
return nil, errors.Trace(err)
}
go runListener.Run()
return runListener, nil
} | [
"func",
"NewRunListener",
"(",
"cfg",
"RunListenerConfig",
")",
"(",
"*",
"RunListener",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Trace",
"(",
"er... | // NewRunListener returns a new RunListener that is listening on given
// socket or named pipe passed in. If a valid RunListener is returned, is
// has the go routine running, and should be closed by the creator
// when they are done with it. | [
"NewRunListener",
"returns",
"a",
"new",
"RunListener",
"that",
"is",
"listening",
"on",
"given",
"socket",
"or",
"named",
"pipe",
"passed",
"in",
".",
"If",
"a",
"valid",
"RunListener",
"is",
"returned",
"is",
"has",
"the",
"go",
"routine",
"running",
"and"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runlistener.go#L82-L102 | train |
juju/juju | worker/uniter/runlistener.go | Run | func (s *RunListener) Run() (err error) {
logger.Debugf("juju-run listener running")
var conn net.Conn
for {
conn, err = s.listener.Accept()
if err != nil {
break
}
s.wg.Add(1)
go func(conn net.Conn) {
s.server.ServeConn(conn)
s.wg.Done()
}(conn)
}
logger.Debugf("juju-run listener stopping")
select {
case <-s.closing:
// Someone has called Close(), so it is overwhelmingly likely that
// the error from Accept is a direct result of the Listener being
// closed, and can therefore be safely ignored.
err = nil
default:
}
s.wg.Wait()
close(s.closed)
return
} | go | func (s *RunListener) Run() (err error) {
logger.Debugf("juju-run listener running")
var conn net.Conn
for {
conn, err = s.listener.Accept()
if err != nil {
break
}
s.wg.Add(1)
go func(conn net.Conn) {
s.server.ServeConn(conn)
s.wg.Done()
}(conn)
}
logger.Debugf("juju-run listener stopping")
select {
case <-s.closing:
// Someone has called Close(), so it is overwhelmingly likely that
// the error from Accept is a direct result of the Listener being
// closed, and can therefore be safely ignored.
err = nil
default:
}
s.wg.Wait()
close(s.closed)
return
} | [
"func",
"(",
"s",
"*",
"RunListener",
")",
"Run",
"(",
")",
"(",
"err",
"error",
")",
"{",
"logger",
".",
"Debugf",
"(",
"\"",
"\"",
")",
"\n",
"var",
"conn",
"net",
".",
"Conn",
"\n",
"for",
"{",
"conn",
",",
"err",
"=",
"s",
".",
"listener",
... | // Run accepts new connections until it encounters an error, or until Close is
// called, and then blocks until all existing connections have been closed. | [
"Run",
"accepts",
"new",
"connections",
"until",
"it",
"encounters",
"an",
"error",
"or",
"until",
"Close",
"is",
"called",
"and",
"then",
"blocks",
"until",
"all",
"existing",
"connections",
"have",
"been",
"closed",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runlistener.go#L106-L132 | train |
juju/juju | worker/uniter/runlistener.go | RunCommands | func (r *JujuRunServer) RunCommands(args RunCommandsArgs, result *exec.ExecResponse) error {
logger.Debugf("RunCommands: %+v", args)
runResult, err := r.runner.RunCommands(args)
if err != nil {
return errors.Annotate(err, "r.runner.RunCommands")
}
*result = *runResult
return err
} | go | func (r *JujuRunServer) RunCommands(args RunCommandsArgs, result *exec.ExecResponse) error {
logger.Debugf("RunCommands: %+v", args)
runResult, err := r.runner.RunCommands(args)
if err != nil {
return errors.Annotate(err, "r.runner.RunCommands")
}
*result = *runResult
return err
} | [
"func",
"(",
"r",
"*",
"JujuRunServer",
")",
"RunCommands",
"(",
"args",
"RunCommandsArgs",
",",
"result",
"*",
"exec",
".",
"ExecResponse",
")",
"error",
"{",
"logger",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"args",
")",
"\n",
"runResult",
",",
"err",
"... | // RunCommands delegates the actual running to the runner and populates the
// response structure. | [
"RunCommands",
"delegates",
"the",
"actual",
"running",
"to",
"the",
"runner",
"and",
"populates",
"the",
"response",
"structure",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runlistener.go#L194-L202 | train |
juju/juju | worker/uniter/runlistener.go | NewChannelCommandRunner | func NewChannelCommandRunner(cfg ChannelCommandRunnerConfig) (*ChannelCommandRunner, error) {
if err := cfg.Validate(); err != nil {
return nil, errors.Trace(err)
}
return &ChannelCommandRunner{cfg}, nil
} | go | func NewChannelCommandRunner(cfg ChannelCommandRunnerConfig) (*ChannelCommandRunner, error) {
if err := cfg.Validate(); err != nil {
return nil, errors.Trace(err)
}
return &ChannelCommandRunner{cfg}, nil
} | [
"func",
"NewChannelCommandRunner",
"(",
"cfg",
"ChannelCommandRunnerConfig",
")",
"(",
"*",
"ChannelCommandRunner",
",",
"error",
")",
"{",
"if",
"err",
":=",
"cfg",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
"... | // NewChannelCommandRunner returns a new ChannelCommandRunner with the
// given configuration. | [
"NewChannelCommandRunner",
"returns",
"a",
"new",
"ChannelCommandRunner",
"with",
"the",
"given",
"configuration",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runlistener.go#L239-L244 | train |
juju/juju | worker/uniter/runlistener.go | RunCommands | func (c *ChannelCommandRunner) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error) {
type responseInfo struct {
response *exec.ExecResponse
err error
}
// NOTE(axw) the response channel must be synchronous so that the
// response is received before the uniter resumes operation, and
// potentially aborts. This prevents a race when rebooting.
responseChan := make(chan responseInfo)
responseFunc := func(response *exec.ExecResponse, err error) {
select {
case <-c.config.Abort:
case responseChan <- responseInfo{response, err}:
}
}
id := c.config.Commands.AddCommand(
operation.CommandArgs{
Commands: args.Commands,
RelationId: args.RelationId,
RemoteUnitName: args.RemoteUnitName,
ForceRemoteUnit: args.ForceRemoteUnit,
},
responseFunc,
)
select {
case <-c.config.Abort:
return nil, errCommandAborted
case c.config.CommandChannel <- id:
}
select {
case <-c.config.Abort:
return nil, errCommandAborted
case response := <-responseChan:
return response.response, response.err
}
} | go | func (c *ChannelCommandRunner) RunCommands(args RunCommandsArgs) (results *exec.ExecResponse, err error) {
type responseInfo struct {
response *exec.ExecResponse
err error
}
// NOTE(axw) the response channel must be synchronous so that the
// response is received before the uniter resumes operation, and
// potentially aborts. This prevents a race when rebooting.
responseChan := make(chan responseInfo)
responseFunc := func(response *exec.ExecResponse, err error) {
select {
case <-c.config.Abort:
case responseChan <- responseInfo{response, err}:
}
}
id := c.config.Commands.AddCommand(
operation.CommandArgs{
Commands: args.Commands,
RelationId: args.RelationId,
RemoteUnitName: args.RemoteUnitName,
ForceRemoteUnit: args.ForceRemoteUnit,
},
responseFunc,
)
select {
case <-c.config.Abort:
return nil, errCommandAborted
case c.config.CommandChannel <- id:
}
select {
case <-c.config.Abort:
return nil, errCommandAborted
case response := <-responseChan:
return response.response, response.err
}
} | [
"func",
"(",
"c",
"*",
"ChannelCommandRunner",
")",
"RunCommands",
"(",
"args",
"RunCommandsArgs",
")",
"(",
"results",
"*",
"exec",
".",
"ExecResponse",
",",
"err",
"error",
")",
"{",
"type",
"responseInfo",
"struct",
"{",
"response",
"*",
"exec",
".",
"E... | // RunCommands executes the supplied run commands by registering the
// arguments in a runcommands.Commands, and then sending the returned
// ID to a channel and waiting for a response callback. | [
"RunCommands",
"executes",
"the",
"supplied",
"run",
"commands",
"by",
"registering",
"the",
"arguments",
"in",
"a",
"runcommands",
".",
"Commands",
"and",
"then",
"sending",
"the",
"returned",
"ID",
"to",
"a",
"channel",
"and",
"waiting",
"for",
"a",
"respons... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runlistener.go#L249-L287 | train |
juju/juju | worker/uniter/runner/jujuc/leader-set.go | NewLeaderSetCommand | func NewLeaderSetCommand(ctx Context) (cmd.Command, error) {
return &leaderSetCommand{ctx: ctx}, nil
} | go | func NewLeaderSetCommand(ctx Context) (cmd.Command, error) {
return &leaderSetCommand{ctx: ctx}, nil
} | [
"func",
"NewLeaderSetCommand",
"(",
"ctx",
"Context",
")",
"(",
"cmd",
".",
"Command",
",",
"error",
")",
"{",
"return",
"&",
"leaderSetCommand",
"{",
"ctx",
":",
"ctx",
"}",
",",
"nil",
"\n",
"}"
] | // NewLeaderSetCommand returns a new leaderSetCommand with the given context. | [
"NewLeaderSetCommand",
"returns",
"a",
"new",
"leaderSetCommand",
"with",
"the",
"given",
"context",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/leader-set.go#L22-L24 | train |
juju/juju | apiserver/common/action.go | ParamsActionExecutionResultsToStateActionResults | func ParamsActionExecutionResultsToStateActionResults(arg params.ActionExecutionResult) (state.ActionResults, error) {
var status state.ActionStatus
switch arg.Status {
case params.ActionCancelled:
status = state.ActionCancelled
case params.ActionCompleted:
status = state.ActionCompleted
case params.ActionFailed:
status = state.ActionFailed
case params.ActionPending:
status = state.ActionPending
default:
return state.ActionResults{}, errors.Errorf("unrecognized action status '%s'", arg.Status)
}
return state.ActionResults{
Status: status,
Results: arg.Results,
Message: arg.Message,
}, nil
} | go | func ParamsActionExecutionResultsToStateActionResults(arg params.ActionExecutionResult) (state.ActionResults, error) {
var status state.ActionStatus
switch arg.Status {
case params.ActionCancelled:
status = state.ActionCancelled
case params.ActionCompleted:
status = state.ActionCompleted
case params.ActionFailed:
status = state.ActionFailed
case params.ActionPending:
status = state.ActionPending
default:
return state.ActionResults{}, errors.Errorf("unrecognized action status '%s'", arg.Status)
}
return state.ActionResults{
Status: status,
Results: arg.Results,
Message: arg.Message,
}, nil
} | [
"func",
"ParamsActionExecutionResultsToStateActionResults",
"(",
"arg",
"params",
".",
"ActionExecutionResult",
")",
"(",
"state",
".",
"ActionResults",
",",
"error",
")",
"{",
"var",
"status",
"state",
".",
"ActionStatus",
"\n",
"switch",
"arg",
".",
"Status",
"{... | // ParamsActionExecutionResultsToStateActionResults does exactly what
// the name implies. | [
"ParamsActionExecutionResultsToStateActionResults",
"does",
"exactly",
"what",
"the",
"name",
"implies",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L19-L38 | train |
juju/juju | apiserver/common/action.go | TagToActionReceiverFn | func TagToActionReceiverFn(findEntity func(names.Tag) (state.Entity, error)) func(tag string) (state.ActionReceiver, error) {
return func(tag string) (state.ActionReceiver, error) {
receiverTag, err := names.ParseTag(tag)
if err != nil {
return nil, errors.NotValidf("%s", tag)
}
entity, err := findEntity(receiverTag)
if err != nil {
return nil, errors.NotFoundf("%s", receiverTag)
}
receiver, ok := entity.(state.ActionReceiver)
if !ok {
return nil, errors.NotImplementedf("action receiver interface on entity %s", tag)
}
return receiver, nil
}
} | go | func TagToActionReceiverFn(findEntity func(names.Tag) (state.Entity, error)) func(tag string) (state.ActionReceiver, error) {
return func(tag string) (state.ActionReceiver, error) {
receiverTag, err := names.ParseTag(tag)
if err != nil {
return nil, errors.NotValidf("%s", tag)
}
entity, err := findEntity(receiverTag)
if err != nil {
return nil, errors.NotFoundf("%s", receiverTag)
}
receiver, ok := entity.(state.ActionReceiver)
if !ok {
return nil, errors.NotImplementedf("action receiver interface on entity %s", tag)
}
return receiver, nil
}
} | [
"func",
"TagToActionReceiverFn",
"(",
"findEntity",
"func",
"(",
"names",
".",
"Tag",
")",
"(",
"state",
".",
"Entity",
",",
"error",
")",
")",
"func",
"(",
"tag",
"string",
")",
"(",
"state",
".",
"ActionReceiver",
",",
"error",
")",
"{",
"return",
"f... | // TagToActionReceiver takes a tag string and tries to convert it to an
// ActionReceiver. It needs a findEntity function passed in that can search for the tags in state. | [
"TagToActionReceiver",
"takes",
"a",
"tag",
"string",
"and",
"tries",
"to",
"convert",
"it",
"to",
"an",
"ActionReceiver",
".",
"It",
"needs",
"a",
"findEntity",
"function",
"passed",
"in",
"that",
"can",
"search",
"for",
"the",
"tags",
"in",
"state",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L42-L58 | train |
juju/juju | apiserver/common/action.go | AuthAndActionFromTagFn | func AuthAndActionFromTagFn(canAccess AuthFunc, getActionByTag func(names.ActionTag) (state.Action, error)) func(string) (state.Action, error) {
return func(tag string) (state.Action, error) {
actionTag, err := names.ParseActionTag(tag)
if err != nil {
return nil, errors.Trace(err)
}
action, err := getActionByTag(actionTag)
if err != nil {
return nil, errors.Trace(err)
}
receiverTag, err := names.ActionReceiverTag(action.Receiver())
if err != nil {
return nil, errors.Trace(err)
}
if !canAccess(receiverTag) {
return nil, ErrPerm
}
return action, nil
}
} | go | func AuthAndActionFromTagFn(canAccess AuthFunc, getActionByTag func(names.ActionTag) (state.Action, error)) func(string) (state.Action, error) {
return func(tag string) (state.Action, error) {
actionTag, err := names.ParseActionTag(tag)
if err != nil {
return nil, errors.Trace(err)
}
action, err := getActionByTag(actionTag)
if err != nil {
return nil, errors.Trace(err)
}
receiverTag, err := names.ActionReceiverTag(action.Receiver())
if err != nil {
return nil, errors.Trace(err)
}
if !canAccess(receiverTag) {
return nil, ErrPerm
}
return action, nil
}
} | [
"func",
"AuthAndActionFromTagFn",
"(",
"canAccess",
"AuthFunc",
",",
"getActionByTag",
"func",
"(",
"names",
".",
"ActionTag",
")",
"(",
"state",
".",
"Action",
",",
"error",
")",
")",
"func",
"(",
"string",
")",
"(",
"state",
".",
"Action",
",",
"error",
... | // AuthAndActionFromTagFn takes in an authorizer function and a function that can fetch action by tags from state
// and returns a function that can fetch an action from state by id and check the authorization. | [
"AuthAndActionFromTagFn",
"takes",
"in",
"an",
"authorizer",
"function",
"and",
"a",
"function",
"that",
"can",
"fetch",
"action",
"by",
"tags",
"from",
"state",
"and",
"returns",
"a",
"function",
"that",
"can",
"fetch",
"an",
"action",
"from",
"state",
"by",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L62-L81 | train |
juju/juju | apiserver/common/action.go | BeginActions | func BeginActions(args params.Entities, actionFn func(string) (state.Action, error)) params.ErrorResults {
results := params.ErrorResults{Results: make([]params.ErrorResult, len(args.Entities))}
for i, arg := range args.Entities {
action, err := actionFn(arg.Tag)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
_, err = action.Begin()
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
}
return results
} | go | func BeginActions(args params.Entities, actionFn func(string) (state.Action, error)) params.ErrorResults {
results := params.ErrorResults{Results: make([]params.ErrorResult, len(args.Entities))}
for i, arg := range args.Entities {
action, err := actionFn(arg.Tag)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
_, err = action.Begin()
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
}
return results
} | [
"func",
"BeginActions",
"(",
"args",
"params",
".",
"Entities",
",",
"actionFn",
"func",
"(",
"string",
")",
"(",
"state",
".",
"Action",
",",
"error",
")",
")",
"params",
".",
"ErrorResults",
"{",
"results",
":=",
"params",
".",
"ErrorResults",
"{",
"Re... | // BeginActions calls begin on every action passed in through args.
// It's a helper function currently used by the uniter and by machineactions
// It needs an actionFn that can fetch an action from state using it's id, that's usually created by AuthAndActionFromTagFn | [
"BeginActions",
"calls",
"begin",
"on",
"every",
"action",
"passed",
"in",
"through",
"args",
".",
"It",
"s",
"a",
"helper",
"function",
"currently",
"used",
"by",
"the",
"uniter",
"and",
"by",
"machineactions",
"It",
"needs",
"an",
"actionFn",
"that",
"can"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L86-L104 | train |
juju/juju | apiserver/common/action.go | FinishActions | func FinishActions(args params.ActionExecutionResults, actionFn func(string) (state.Action, error)) params.ErrorResults {
results := params.ErrorResults{Results: make([]params.ErrorResult, len(args.Results))}
for i, arg := range args.Results {
action, err := actionFn(arg.ActionTag)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
actionResults, err := ParamsActionExecutionResultsToStateActionResults(arg)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
_, err = action.Finish(actionResults)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
}
return results
} | go | func FinishActions(args params.ActionExecutionResults, actionFn func(string) (state.Action, error)) params.ErrorResults {
results := params.ErrorResults{Results: make([]params.ErrorResult, len(args.Results))}
for i, arg := range args.Results {
action, err := actionFn(arg.ActionTag)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
actionResults, err := ParamsActionExecutionResultsToStateActionResults(arg)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
_, err = action.Finish(actionResults)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
}
return results
} | [
"func",
"FinishActions",
"(",
"args",
"params",
".",
"ActionExecutionResults",
",",
"actionFn",
"func",
"(",
"string",
")",
"(",
"state",
".",
"Action",
",",
"error",
")",
")",
"params",
".",
"ErrorResults",
"{",
"results",
":=",
"params",
".",
"ErrorResults... | // FinishActions saves the result of a completed Action.
// It's a helper function currently used by the uniter and by machineactions
// It needs an actionFn that can fetch an action from state using it's id that's usually created by AuthAndActionFromTagFn | [
"FinishActions",
"saves",
"the",
"result",
"of",
"a",
"completed",
"Action",
".",
"It",
"s",
"a",
"helper",
"function",
"currently",
"used",
"by",
"the",
"uniter",
"and",
"by",
"machineactions",
"It",
"needs",
"an",
"actionFn",
"that",
"can",
"fetch",
"an",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L109-L132 | train |
juju/juju | apiserver/common/action.go | Actions | func Actions(args params.Entities, actionFn func(string) (state.Action, error)) params.ActionResults {
results := params.ActionResults{
Results: make([]params.ActionResult, len(args.Entities)),
}
for i, arg := range args.Entities {
action, err := actionFn(arg.Tag)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
if action.Status() != state.ActionPending {
results.Results[i].Error = ServerError(ErrActionNotAvailable)
continue
}
results.Results[i].Action = ¶ms.Action{
Name: action.Name(),
Parameters: action.Parameters(),
}
}
return results
} | go | func Actions(args params.Entities, actionFn func(string) (state.Action, error)) params.ActionResults {
results := params.ActionResults{
Results: make([]params.ActionResult, len(args.Entities)),
}
for i, arg := range args.Entities {
action, err := actionFn(arg.Tag)
if err != nil {
results.Results[i].Error = ServerError(err)
continue
}
if action.Status() != state.ActionPending {
results.Results[i].Error = ServerError(ErrActionNotAvailable)
continue
}
results.Results[i].Action = ¶ms.Action{
Name: action.Name(),
Parameters: action.Parameters(),
}
}
return results
} | [
"func",
"Actions",
"(",
"args",
"params",
".",
"Entities",
",",
"actionFn",
"func",
"(",
"string",
")",
"(",
"state",
".",
"Action",
",",
"error",
")",
")",
"params",
".",
"ActionResults",
"{",
"results",
":=",
"params",
".",
"ActionResults",
"{",
"Resul... | // Actions returns the Actions by Tags passed in and ensures that the receiver asking for
// them is the same one that has the action.
// It's a helper function currently used by the uniter and by machineactions.
// It needs an actionFn that can fetch an action from state using it's id that's usually created by AuthAndActionFromTagFn | [
"Actions",
"returns",
"the",
"Actions",
"by",
"Tags",
"passed",
"in",
"and",
"ensures",
"that",
"the",
"receiver",
"asking",
"for",
"them",
"is",
"the",
"same",
"one",
"that",
"has",
"the",
"action",
".",
"It",
"s",
"a",
"helper",
"function",
"currently",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L138-L160 | train |
juju/juju | apiserver/common/action.go | WatchOneActionReceiverNotifications | func WatchOneActionReceiverNotifications(tagToActionReceiver func(tag string) (state.ActionReceiver, error), registerFunc func(r facade.Resource) string) func(names.Tag) (params.StringsWatchResult, error) {
return func(tag names.Tag) (params.StringsWatchResult, error) {
nothing := params.StringsWatchResult{}
receiver, err := tagToActionReceiver(tag.String())
if err != nil {
return nothing, err
}
watch := receiver.WatchActionNotifications()
if changes, ok := <-watch.Changes(); ok {
return params.StringsWatchResult{
StringsWatcherId: registerFunc(watch),
Changes: changes,
}, nil
}
return nothing, watcher.EnsureErr(watch)
}
} | go | func WatchOneActionReceiverNotifications(tagToActionReceiver func(tag string) (state.ActionReceiver, error), registerFunc func(r facade.Resource) string) func(names.Tag) (params.StringsWatchResult, error) {
return func(tag names.Tag) (params.StringsWatchResult, error) {
nothing := params.StringsWatchResult{}
receiver, err := tagToActionReceiver(tag.String())
if err != nil {
return nothing, err
}
watch := receiver.WatchActionNotifications()
if changes, ok := <-watch.Changes(); ok {
return params.StringsWatchResult{
StringsWatcherId: registerFunc(watch),
Changes: changes,
}, nil
}
return nothing, watcher.EnsureErr(watch)
}
} | [
"func",
"WatchOneActionReceiverNotifications",
"(",
"tagToActionReceiver",
"func",
"(",
"tag",
"string",
")",
"(",
"state",
".",
"ActionReceiver",
",",
"error",
")",
",",
"registerFunc",
"func",
"(",
"r",
"facade",
".",
"Resource",
")",
"string",
")",
"func",
... | // WatchOneActionReceiverNotifications to create a watcher for one receiver.
// It needs a tagToActionReceiver function and a registerFunc to register
// resources.
// It's a helper function currently used by the uniter and by machineactions | [
"WatchOneActionReceiverNotifications",
"to",
"create",
"a",
"watcher",
"for",
"one",
"receiver",
".",
"It",
"needs",
"a",
"tagToActionReceiver",
"function",
"and",
"a",
"registerFunc",
"to",
"register",
"resources",
".",
"It",
"s",
"a",
"helper",
"function",
"curr... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L166-L183 | train |
juju/juju | apiserver/common/action.go | WatchActionNotifications | func WatchActionNotifications(args params.Entities, canAccess AuthFunc, watchOne func(names.Tag) (params.StringsWatchResult, error)) params.StringsWatchResults {
result := params.StringsWatchResults{
Results: make([]params.StringsWatchResult, len(args.Entities)),
}
for i, entity := range args.Entities {
tag, err := names.ActionReceiverFromTag(entity.Tag)
if err != nil {
result.Results[i].Error = ServerError(err)
continue
}
err = ErrPerm
if canAccess(tag) {
result.Results[i], err = watchOne(tag)
}
result.Results[i].Error = ServerError(err)
}
return result
} | go | func WatchActionNotifications(args params.Entities, canAccess AuthFunc, watchOne func(names.Tag) (params.StringsWatchResult, error)) params.StringsWatchResults {
result := params.StringsWatchResults{
Results: make([]params.StringsWatchResult, len(args.Entities)),
}
for i, entity := range args.Entities {
tag, err := names.ActionReceiverFromTag(entity.Tag)
if err != nil {
result.Results[i].Error = ServerError(err)
continue
}
err = ErrPerm
if canAccess(tag) {
result.Results[i], err = watchOne(tag)
}
result.Results[i].Error = ServerError(err)
}
return result
} | [
"func",
"WatchActionNotifications",
"(",
"args",
"params",
".",
"Entities",
",",
"canAccess",
"AuthFunc",
",",
"watchOne",
"func",
"(",
"names",
".",
"Tag",
")",
"(",
"params",
".",
"StringsWatchResult",
",",
"error",
")",
")",
"params",
".",
"StringsWatchResu... | // WatchActionNotifications returns a StringsWatcher for observing incoming actions towards an actionreceiver.
// It's a helper function currently used by the uniter and by machineactions
// canAccess is passed in by the respective caller to provide authorization.
// watchOne is usually a function created by WatchOneActionReceiverNotifications | [
"WatchActionNotifications",
"returns",
"a",
"StringsWatcher",
"for",
"observing",
"incoming",
"actions",
"towards",
"an",
"actionreceiver",
".",
"It",
"s",
"a",
"helper",
"function",
"currently",
"used",
"by",
"the",
"uniter",
"and",
"by",
"machineactions",
"canAcce... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L189-L208 | train |
juju/juju | apiserver/common/action.go | ConvertActions | func ConvertActions(ar state.ActionReceiver, fn GetActionsFn) ([]params.ActionResult, error) {
items := []params.ActionResult{}
actions, err := fn()
if err != nil {
return items, err
}
for _, action := range actions {
if action == nil {
continue
}
items = append(items, MakeActionResult(ar.Tag(), action))
}
return items, nil
} | go | func ConvertActions(ar state.ActionReceiver, fn GetActionsFn) ([]params.ActionResult, error) {
items := []params.ActionResult{}
actions, err := fn()
if err != nil {
return items, err
}
for _, action := range actions {
if action == nil {
continue
}
items = append(items, MakeActionResult(ar.Tag(), action))
}
return items, nil
} | [
"func",
"ConvertActions",
"(",
"ar",
"state",
".",
"ActionReceiver",
",",
"fn",
"GetActionsFn",
")",
"(",
"[",
"]",
"params",
".",
"ActionResult",
",",
"error",
")",
"{",
"items",
":=",
"[",
"]",
"params",
".",
"ActionResult",
"{",
"}",
"\n",
"actions",
... | // ConvertActions takes a generic getActionsFn to obtain a slice
// of state.Action and then converts them to the API slice of
// params.ActionResult. | [
"ConvertActions",
"takes",
"a",
"generic",
"getActionsFn",
"to",
"obtain",
"a",
"slice",
"of",
"state",
".",
"Action",
"and",
"then",
"converts",
"them",
"to",
"the",
"API",
"slice",
"of",
"params",
".",
"ActionResult",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L217-L230 | train |
juju/juju | apiserver/common/action.go | MakeActionResult | func MakeActionResult(actionReceiverTag names.Tag, action state.Action) params.ActionResult {
output, message := action.Results()
return params.ActionResult{
Action: ¶ms.Action{
Receiver: actionReceiverTag.String(),
Tag: action.ActionTag().String(),
Name: action.Name(),
Parameters: action.Parameters(),
},
Status: string(action.Status()),
Message: message,
Output: output,
Enqueued: action.Enqueued(),
Started: action.Started(),
Completed: action.Completed(),
}
} | go | func MakeActionResult(actionReceiverTag names.Tag, action state.Action) params.ActionResult {
output, message := action.Results()
return params.ActionResult{
Action: ¶ms.Action{
Receiver: actionReceiverTag.String(),
Tag: action.ActionTag().String(),
Name: action.Name(),
Parameters: action.Parameters(),
},
Status: string(action.Status()),
Message: message,
Output: output,
Enqueued: action.Enqueued(),
Started: action.Started(),
Completed: action.Completed(),
}
} | [
"func",
"MakeActionResult",
"(",
"actionReceiverTag",
"names",
".",
"Tag",
",",
"action",
"state",
".",
"Action",
")",
"params",
".",
"ActionResult",
"{",
"output",
",",
"message",
":=",
"action",
".",
"Results",
"(",
")",
"\n",
"return",
"params",
".",
"A... | // MakeActionResult does the actual type conversion from state.Action
// to params.ActionResult. | [
"MakeActionResult",
"does",
"the",
"actual",
"type",
"conversion",
"from",
"state",
".",
"Action",
"to",
"params",
".",
"ActionResult",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/action.go#L234-L250 | train |
juju/juju | cmd/juju/firewall/listrules.go | NewListFirewallRulesCommand | func NewListFirewallRulesCommand() cmd.Command {
cmd := &listFirewallRulesCommand{}
cmd.newAPIFunc = func() (ListFirewallRulesAPI, error) {
root, err := cmd.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
return firewallrules.NewClient(root), nil
}
return modelcmd.Wrap(cmd)
} | go | func NewListFirewallRulesCommand() cmd.Command {
cmd := &listFirewallRulesCommand{}
cmd.newAPIFunc = func() (ListFirewallRulesAPI, error) {
root, err := cmd.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
return firewallrules.NewClient(root), nil
}
return modelcmd.Wrap(cmd)
} | [
"func",
"NewListFirewallRulesCommand",
"(",
")",
"cmd",
".",
"Command",
"{",
"cmd",
":=",
"&",
"listFirewallRulesCommand",
"{",
"}",
"\n",
"cmd",
".",
"newAPIFunc",
"=",
"func",
"(",
")",
"(",
"ListFirewallRulesAPI",
",",
"error",
")",
"{",
"root",
",",
"e... | // NewListFirewallRulesCommand returns a command to list firewall rules. | [
"NewListFirewallRulesCommand",
"returns",
"a",
"command",
"to",
"list",
"firewall",
"rules",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/firewall/listrules.go#L32-L43 | train |
juju/juju | state/refcounts_ns.go | LazyCreateOp | func (ns nsRefcounts_) LazyCreateOp(coll mongo.Collection, key string) (txn.Op, bool, error) {
if exists, err := ns.exists(coll, key); err != nil {
return txn.Op{}, false, errors.Trace(err)
} else if exists {
return txn.Op{}, false, nil
}
return ns.JustCreateOp(coll.Name(), key, 0), true, nil
} | go | func (ns nsRefcounts_) LazyCreateOp(coll mongo.Collection, key string) (txn.Op, bool, error) {
if exists, err := ns.exists(coll, key); err != nil {
return txn.Op{}, false, errors.Trace(err)
} else if exists {
return txn.Op{}, false, nil
}
return ns.JustCreateOp(coll.Name(), key, 0), true, nil
} | [
"func",
"(",
"ns",
"nsRefcounts_",
")",
"LazyCreateOp",
"(",
"coll",
"mongo",
".",
"Collection",
",",
"key",
"string",
")",
"(",
"txn",
".",
"Op",
",",
"bool",
",",
"error",
")",
"{",
"if",
"exists",
",",
"err",
":=",
"ns",
".",
"exists",
"(",
"col... | // LazyCreateOp returns a txn.Op that creates a refcount document; or
// false if the document already exists. | [
"LazyCreateOp",
"returns",
"a",
"txn",
".",
"Op",
"that",
"creates",
"a",
"refcount",
"document",
";",
"or",
"false",
"if",
"the",
"document",
"already",
"exists",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L52-L59 | train |
juju/juju | state/refcounts_ns.go | StrictCreateOp | func (ns nsRefcounts_) StrictCreateOp(coll mongo.Collection, key string, value int) (txn.Op, error) {
if exists, err := ns.exists(coll, key); err != nil {
return txn.Op{}, errors.Trace(err)
} else if exists {
return txn.Op{}, errors.New("refcount already exists")
}
return ns.JustCreateOp(coll.Name(), key, value), nil
} | go | func (ns nsRefcounts_) StrictCreateOp(coll mongo.Collection, key string, value int) (txn.Op, error) {
if exists, err := ns.exists(coll, key); err != nil {
return txn.Op{}, errors.Trace(err)
} else if exists {
return txn.Op{}, errors.New("refcount already exists")
}
return ns.JustCreateOp(coll.Name(), key, value), nil
} | [
"func",
"(",
"ns",
"nsRefcounts_",
")",
"StrictCreateOp",
"(",
"coll",
"mongo",
".",
"Collection",
",",
"key",
"string",
",",
"value",
"int",
")",
"(",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"if",
"exists",
",",
"err",
":=",
"ns",
".",
"exists",
... | // StrictCreateOp returns a txn.Op that creates a refcount document as
// configured, or an error if the document already exists. | [
"StrictCreateOp",
"returns",
"a",
"txn",
".",
"Op",
"that",
"creates",
"a",
"refcount",
"document",
"as",
"configured",
"or",
"an",
"error",
"if",
"the",
"document",
"already",
"exists",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L63-L70 | train |
juju/juju | state/refcounts_ns.go | CreateOrIncRefOp | func (ns nsRefcounts_) CreateOrIncRefOp(coll mongo.Collection, key string, n int) (txn.Op, error) {
if exists, err := ns.exists(coll, key); err != nil {
return txn.Op{}, errors.Trace(err)
} else if !exists {
return ns.JustCreateOp(coll.Name(), key, n), nil
}
return ns.JustIncRefOp(coll.Name(), key, n), nil
} | go | func (ns nsRefcounts_) CreateOrIncRefOp(coll mongo.Collection, key string, n int) (txn.Op, error) {
if exists, err := ns.exists(coll, key); err != nil {
return txn.Op{}, errors.Trace(err)
} else if !exists {
return ns.JustCreateOp(coll.Name(), key, n), nil
}
return ns.JustIncRefOp(coll.Name(), key, n), nil
} | [
"func",
"(",
"ns",
"nsRefcounts_",
")",
"CreateOrIncRefOp",
"(",
"coll",
"mongo",
".",
"Collection",
",",
"key",
"string",
",",
"n",
"int",
")",
"(",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"if",
"exists",
",",
"err",
":=",
"ns",
".",
"exists",
"... | // CreateOrIncrefOp returns a txn.Op that creates a refcount document as
// configured with a specified value; or increments any such refcount doc
// that already exists. | [
"CreateOrIncrefOp",
"returns",
"a",
"txn",
".",
"Op",
"that",
"creates",
"a",
"refcount",
"document",
"as",
"configured",
"with",
"a",
"specified",
"value",
";",
"or",
"increments",
"any",
"such",
"refcount",
"doc",
"that",
"already",
"exists",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L75-L82 | train |
juju/juju | state/refcounts_ns.go | AliveDecRefOp | func (ns nsRefcounts_) AliveDecRefOp(coll mongo.Collection, key string) (txn.Op, error) {
if refcount, err := ns.read(coll, key); err != nil {
return txn.Op{}, errors.Trace(err)
} else if refcount < 1 {
return txn.Op{}, errors.Annotatef(errRefcountAlreadyZero, "%s(%s)", coll.Name(), key)
}
return ns.justDecRefOp(coll.Name(), key, 0), nil
} | go | func (ns nsRefcounts_) AliveDecRefOp(coll mongo.Collection, key string) (txn.Op, error) {
if refcount, err := ns.read(coll, key); err != nil {
return txn.Op{}, errors.Trace(err)
} else if refcount < 1 {
return txn.Op{}, errors.Annotatef(errRefcountAlreadyZero, "%s(%s)", coll.Name(), key)
}
return ns.justDecRefOp(coll.Name(), key, 0), nil
} | [
"func",
"(",
"ns",
"nsRefcounts_",
")",
"AliveDecRefOp",
"(",
"coll",
"mongo",
".",
"Collection",
",",
"key",
"string",
")",
"(",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"if",
"refcount",
",",
"err",
":=",
"ns",
".",
"read",
"(",
"coll",
",",
"ke... | // AliveDecRefOp returns a txn.Op that decrements the value of a
// refcount doc, or an error if the doc does not exist or the count
// would go below 0. | [
"AliveDecRefOp",
"returns",
"a",
"txn",
".",
"Op",
"that",
"decrements",
"the",
"value",
"of",
"a",
"refcount",
"doc",
"or",
"an",
"error",
"if",
"the",
"doc",
"does",
"not",
"exist",
"or",
"the",
"count",
"would",
"go",
"below",
"0",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L98-L105 | train |
juju/juju | state/refcounts_ns.go | DyingDecRefOp | func (ns nsRefcounts_) DyingDecRefOp(coll mongo.Collection, key string) (txn.Op, bool, error) {
refcount, err := ns.read(coll, key)
if err != nil {
return txn.Op{}, false, errors.Trace(err)
}
if refcount < 1 {
return txn.Op{}, false, errors.Annotatef(errRefcountAlreadyZero, "%s(%s)", coll.Name(), key)
} else if refcount > 1 {
return ns.justDecRefOp(coll.Name(), key, 1), false, nil
}
return ns.JustRemoveOp(coll.Name(), key, 1), true, nil
} | go | func (ns nsRefcounts_) DyingDecRefOp(coll mongo.Collection, key string) (txn.Op, bool, error) {
refcount, err := ns.read(coll, key)
if err != nil {
return txn.Op{}, false, errors.Trace(err)
}
if refcount < 1 {
return txn.Op{}, false, errors.Annotatef(errRefcountAlreadyZero, "%s(%s)", coll.Name(), key)
} else if refcount > 1 {
return ns.justDecRefOp(coll.Name(), key, 1), false, nil
}
return ns.JustRemoveOp(coll.Name(), key, 1), true, nil
} | [
"func",
"(",
"ns",
"nsRefcounts_",
")",
"DyingDecRefOp",
"(",
"coll",
"mongo",
".",
"Collection",
",",
"key",
"string",
")",
"(",
"txn",
".",
"Op",
",",
"bool",
",",
"error",
")",
"{",
"refcount",
",",
"err",
":=",
"ns",
".",
"read",
"(",
"coll",
"... | // DyingDecRefOp returns a txn.Op that decrements the value of a
// refcount doc and deletes it if the count reaches 0; if the Op will
// cause a delete, the bool result will be true. It will return an error
// if the doc does not exist or the count would go below 0. | [
"DyingDecRefOp",
"returns",
"a",
"txn",
".",
"Op",
"that",
"decrements",
"the",
"value",
"of",
"a",
"refcount",
"doc",
"and",
"deletes",
"it",
"if",
"the",
"count",
"reaches",
"0",
";",
"if",
"the",
"Op",
"will",
"cause",
"a",
"delete",
"the",
"bool",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L111-L122 | train |
juju/juju | state/refcounts_ns.go | RemoveOp | func (ns nsRefcounts_) RemoveOp(coll mongo.Collection, key string, value int) (txn.Op, error) {
refcount, err := ns.read(coll, key)
if err != nil {
return txn.Op{}, errors.Trace(err)
}
if refcount != value {
logger.Tracef("reference of %s(%q) had %d refs, expected %d", coll.Name(), key, refcount, value)
return txn.Op{}, errRefcountChanged
}
return ns.JustRemoveOp(coll.Name(), key, value), nil
} | go | func (ns nsRefcounts_) RemoveOp(coll mongo.Collection, key string, value int) (txn.Op, error) {
refcount, err := ns.read(coll, key)
if err != nil {
return txn.Op{}, errors.Trace(err)
}
if refcount != value {
logger.Tracef("reference of %s(%q) had %d refs, expected %d", coll.Name(), key, refcount, value)
return txn.Op{}, errRefcountChanged
}
return ns.JustRemoveOp(coll.Name(), key, value), nil
} | [
"func",
"(",
"ns",
"nsRefcounts_",
")",
"RemoveOp",
"(",
"coll",
"mongo",
".",
"Collection",
",",
"key",
"string",
",",
"value",
"int",
")",
"(",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"refcount",
",",
"err",
":=",
"ns",
".",
"read",
"(",
"coll"... | // RemoveOp returns a txn.Op that removes a refcount doc so long as its
// refcount is the supplied value, or an error. | [
"RemoveOp",
"returns",
"a",
"txn",
".",
"Op",
"that",
"removes",
"a",
"refcount",
"doc",
"so",
"long",
"as",
"its",
"refcount",
"is",
"the",
"supplied",
"value",
"or",
"an",
"error",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L126-L136 | train |
juju/juju | state/refcounts_ns.go | CurrentOp | func (ns nsRefcounts_) CurrentOp(coll mongo.Collection, key string) (txn.Op, int, error) {
refcount, err := ns.read(coll, key)
if errors.IsNotFound(err) {
return txn.Op{
C: coll.Name(),
Id: key,
Assert: txn.DocMissing,
}, 0, nil
}
if err != nil {
return txn.Op{}, -1, errors.Trace(err)
}
return txn.Op{
C: coll.Name(),
Id: key,
Assert: bson.D{{"refcount", refcount}},
}, refcount, nil
} | go | func (ns nsRefcounts_) CurrentOp(coll mongo.Collection, key string) (txn.Op, int, error) {
refcount, err := ns.read(coll, key)
if errors.IsNotFound(err) {
return txn.Op{
C: coll.Name(),
Id: key,
Assert: txn.DocMissing,
}, 0, nil
}
if err != nil {
return txn.Op{}, -1, errors.Trace(err)
}
return txn.Op{
C: coll.Name(),
Id: key,
Assert: bson.D{{"refcount", refcount}},
}, refcount, nil
} | [
"func",
"(",
"ns",
"nsRefcounts_",
")",
"CurrentOp",
"(",
"coll",
"mongo",
".",
"Collection",
",",
"key",
"string",
")",
"(",
"txn",
".",
"Op",
",",
"int",
",",
"error",
")",
"{",
"refcount",
",",
"err",
":=",
"ns",
".",
"read",
"(",
"coll",
",",
... | // CurrentOp returns the current reference count value, and a txn.Op that
// asserts that the refcount has that value, or an error. If the refcount
// doc does not exist, then the op will assert that the document does not
// exist instead, and no error is returned. | [
"CurrentOp",
"returns",
"the",
"current",
"reference",
"count",
"value",
"and",
"a",
"txn",
".",
"Op",
"that",
"asserts",
"that",
"the",
"refcount",
"has",
"that",
"value",
"or",
"an",
"error",
".",
"If",
"the",
"refcount",
"doc",
"does",
"not",
"exist",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L142-L159 | train |
juju/juju | state/refcounts_ns.go | JustRemoveOp | func (ns nsRefcounts_) JustRemoveOp(collName, key string, count int) txn.Op {
op := txn.Op{
C: collName,
Id: key,
Remove: true,
}
if count >= 0 {
op.Assert = bson.D{{"refcount", count}}
}
return op
} | go | func (ns nsRefcounts_) JustRemoveOp(collName, key string, count int) txn.Op {
op := txn.Op{
C: collName,
Id: key,
Remove: true,
}
if count >= 0 {
op.Assert = bson.D{{"refcount", count}}
}
return op
} | [
"func",
"(",
"ns",
"nsRefcounts_",
")",
"JustRemoveOp",
"(",
"collName",
",",
"key",
"string",
",",
"count",
"int",
")",
"txn",
".",
"Op",
"{",
"op",
":=",
"txn",
".",
"Op",
"{",
"C",
":",
"collName",
",",
"Id",
":",
"key",
",",
"Remove",
":",
"t... | // JustRemoveOp returns a txn.Op that deletes a refcount doc so long as
// the refcount matches count. You should avoid using this method in
// most cases. | [
"JustRemoveOp",
"returns",
"a",
"txn",
".",
"Op",
"that",
"deletes",
"a",
"refcount",
"doc",
"so",
"long",
"as",
"the",
"refcount",
"matches",
"count",
".",
"You",
"should",
"avoid",
"using",
"this",
"method",
"in",
"most",
"cases",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L188-L198 | train |
juju/juju | state/refcounts_ns.go | exists | func (nsRefcounts_) exists(coll mongo.Collection, key string) (bool, error) {
count, err := coll.FindId(key).Count()
if err != nil {
return false, errors.Trace(err)
}
return count != 0, nil
} | go | func (nsRefcounts_) exists(coll mongo.Collection, key string) (bool, error) {
count, err := coll.FindId(key).Count()
if err != nil {
return false, errors.Trace(err)
}
return count != 0, nil
} | [
"func",
"(",
"nsRefcounts_",
")",
"exists",
"(",
"coll",
"mongo",
".",
"Collection",
",",
"key",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"count",
",",
"err",
":=",
"coll",
".",
"FindId",
"(",
"key",
")",
".",
"Count",
"(",
")",
"\n",
... | // exists returns whether the identified refcount doc exists. | [
"exists",
"returns",
"whether",
"the",
"identified",
"refcount",
"doc",
"exists",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L215-L221 | train |
juju/juju | state/refcounts_ns.go | read | func (nsRefcounts_) read(coll mongo.Collection, key string) (int, error) {
var doc refcountDoc
if err := coll.FindId(key).One(&doc); err == mgo.ErrNotFound {
return 0, errors.NotFoundf("refcount %q", key)
} else if err != nil {
return 0, errors.Trace(err)
}
return doc.RefCount, nil
} | go | func (nsRefcounts_) read(coll mongo.Collection, key string) (int, error) {
var doc refcountDoc
if err := coll.FindId(key).One(&doc); err == mgo.ErrNotFound {
return 0, errors.NotFoundf("refcount %q", key)
} else if err != nil {
return 0, errors.Trace(err)
}
return doc.RefCount, nil
} | [
"func",
"(",
"nsRefcounts_",
")",
"read",
"(",
"coll",
"mongo",
".",
"Collection",
",",
"key",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"doc",
"refcountDoc",
"\n",
"if",
"err",
":=",
"coll",
".",
"FindId",
"(",
"key",
")",
".",
"On... | // read returns the value stored in the identified refcount doc. | [
"read",
"returns",
"the",
"value",
"stored",
"in",
"the",
"identified",
"refcount",
"doc",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/refcounts_ns.go#L224-L232 | train |
juju/juju | provider/lxd/config.go | newConfig | func newConfig(cfg *config.Config) *environConfig {
return &environConfig{
Config: cfg,
attrs: cfg.UnknownAttrs(),
}
} | go | func newConfig(cfg *config.Config) *environConfig {
return &environConfig{
Config: cfg,
attrs: cfg.UnknownAttrs(),
}
} | [
"func",
"newConfig",
"(",
"cfg",
"*",
"config",
".",
"Config",
")",
"*",
"environConfig",
"{",
"return",
"&",
"environConfig",
"{",
"Config",
":",
"cfg",
",",
"attrs",
":",
"cfg",
".",
"UnknownAttrs",
"(",
")",
",",
"}",
"\n",
"}"
] | // newConfig builds a new environConfig from the provided Config and
// returns it. | [
"newConfig",
"builds",
"a",
"new",
"environConfig",
"from",
"the",
"provided",
"Config",
"and",
"returns",
"it",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/lxd/config.go#L32-L37 | train |
juju/juju | provider/lxd/config.go | newValidConfig | func newValidConfig(cfg *config.Config) (*environConfig, error) {
// Ensure that the provided config is valid.
if err := config.Validate(cfg, nil); err != nil {
return nil, errors.Trace(err)
}
// Build the config.
ecfg := newConfig(cfg)
// Do final (more complex, provider-specific) validation.
if err := ecfg.validate(); err != nil {
return nil, errors.Trace(err)
}
return ecfg, nil
} | go | func newValidConfig(cfg *config.Config) (*environConfig, error) {
// Ensure that the provided config is valid.
if err := config.Validate(cfg, nil); err != nil {
return nil, errors.Trace(err)
}
// Build the config.
ecfg := newConfig(cfg)
// Do final (more complex, provider-specific) validation.
if err := ecfg.validate(); err != nil {
return nil, errors.Trace(err)
}
return ecfg, nil
} | [
"func",
"newValidConfig",
"(",
"cfg",
"*",
"config",
".",
"Config",
")",
"(",
"*",
"environConfig",
",",
"error",
")",
"{",
"// Ensure that the provided config is valid.",
"if",
"err",
":=",
"config",
".",
"Validate",
"(",
"cfg",
",",
"nil",
")",
";",
"err",... | // newValidConfig builds a new environConfig from the provided Config
// and returns it. This includes applying the provided defaults
// values, if any. The resulting config values are validated. | [
"newValidConfig",
"builds",
"a",
"new",
"environConfig",
"from",
"the",
"provided",
"Config",
"and",
"returns",
"it",
".",
"This",
"includes",
"applying",
"the",
"provided",
"defaults",
"values",
"if",
"any",
".",
"The",
"resulting",
"config",
"values",
"are",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/lxd/config.go#L42-L57 | train |
juju/juju | provider/lxd/config.go | validate | func (c *environConfig) validate() error {
_, err := c.ValidateUnknownAttrs(configFields, configDefaults)
if err != nil {
return errors.Trace(err)
}
// There are currently no known extra fields for LXD
return nil
} | go | func (c *environConfig) validate() error {
_, err := c.ValidateUnknownAttrs(configFields, configDefaults)
if err != nil {
return errors.Trace(err)
}
// There are currently no known extra fields for LXD
return nil
} | [
"func",
"(",
"c",
"*",
"environConfig",
")",
"validate",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"ValidateUnknownAttrs",
"(",
"configFields",
",",
"configDefaults",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Tr... | // validate validates LXD-specific configuration. | [
"validate",
"validates",
"LXD",
"-",
"specific",
"configuration",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/lxd/config.go#L60-L67 | train |
juju/juju | container/broker/host_preparer.go | NewHostPreparer | func NewHostPreparer(params HostPreparerParams) *HostPreparer {
return &HostPreparer{
api: params.API,
observeNetworkFunc: params.ObserveNetworkFunc,
acquireLockFunc: params.AcquireLockFunc,
createBridger: params.CreateBridger,
abortChan: params.AbortChan,
machineTag: params.MachineTag,
logger: params.Logger,
}
} | go | func NewHostPreparer(params HostPreparerParams) *HostPreparer {
return &HostPreparer{
api: params.API,
observeNetworkFunc: params.ObserveNetworkFunc,
acquireLockFunc: params.AcquireLockFunc,
createBridger: params.CreateBridger,
abortChan: params.AbortChan,
machineTag: params.MachineTag,
logger: params.Logger,
}
} | [
"func",
"NewHostPreparer",
"(",
"params",
"HostPreparerParams",
")",
"*",
"HostPreparer",
"{",
"return",
"&",
"HostPreparer",
"{",
"api",
":",
"params",
".",
"API",
",",
"observeNetworkFunc",
":",
"params",
".",
"ObserveNetworkFunc",
",",
"acquireLockFunc",
":",
... | // NewHostPreparer creates a HostPreparer using the supplied parameters | [
"NewHostPreparer",
"creates",
"a",
"HostPreparer",
"using",
"the",
"supplied",
"parameters"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/broker/host_preparer.go#L54-L64 | train |
juju/juju | container/broker/host_preparer.go | Prepare | func (hp *HostPreparer) Prepare(containerTag names.MachineTag) error {
devicesToBridge, reconfigureDelay, err := hp.api.HostChangesForContainer(containerTag)
if err != nil {
return errors.Annotate(err, "unable to setup network")
}
if len(devicesToBridge) == 0 {
hp.logger.Debugf("container %q requires no additional bridges", containerTag)
return nil
}
bridger, err := hp.createBridger()
if err != nil {
return errors.Trace(err)
}
hp.logger.Debugf("bridging %+v devices on host %q for container %q with delay=%v",
devicesToBridge, hp.machineTag.String(), containerTag.String(), reconfigureDelay)
releaser, err := hp.acquireLockFunc("bridging devices", hp.abortChan)
if err != nil {
return errors.Annotatef(err, "failed to acquire machine lock for bridging")
}
defer releaser()
// TODO(jam): 2017-02-15 bridger.Bridge should probably also take AbortChan
// if it is going to have reconfigureDelay
err = bridger.Bridge(devicesToBridge, reconfigureDelay)
if err != nil {
return errors.Annotate(err, "failed to bridge devices")
}
// We just changed the hosts' network setup so discover new
// interfaces/devices and propagate to state.
observedConfig, err := hp.observeNetworkFunc()
if err != nil {
return errors.Annotate(err, "cannot discover observed network config")
}
if len(observedConfig) > 0 {
hp.logger.Debugf("updating observed network config for %q to %#v", hp.machineTag.String(), observedConfig)
err := hp.api.SetHostMachineNetworkConfig(hp.machineTag, observedConfig)
if err != nil {
return errors.Trace(err)
}
}
return nil
} | go | func (hp *HostPreparer) Prepare(containerTag names.MachineTag) error {
devicesToBridge, reconfigureDelay, err := hp.api.HostChangesForContainer(containerTag)
if err != nil {
return errors.Annotate(err, "unable to setup network")
}
if len(devicesToBridge) == 0 {
hp.logger.Debugf("container %q requires no additional bridges", containerTag)
return nil
}
bridger, err := hp.createBridger()
if err != nil {
return errors.Trace(err)
}
hp.logger.Debugf("bridging %+v devices on host %q for container %q with delay=%v",
devicesToBridge, hp.machineTag.String(), containerTag.String(), reconfigureDelay)
releaser, err := hp.acquireLockFunc("bridging devices", hp.abortChan)
if err != nil {
return errors.Annotatef(err, "failed to acquire machine lock for bridging")
}
defer releaser()
// TODO(jam): 2017-02-15 bridger.Bridge should probably also take AbortChan
// if it is going to have reconfigureDelay
err = bridger.Bridge(devicesToBridge, reconfigureDelay)
if err != nil {
return errors.Annotate(err, "failed to bridge devices")
}
// We just changed the hosts' network setup so discover new
// interfaces/devices and propagate to state.
observedConfig, err := hp.observeNetworkFunc()
if err != nil {
return errors.Annotate(err, "cannot discover observed network config")
}
if len(observedConfig) > 0 {
hp.logger.Debugf("updating observed network config for %q to %#v", hp.machineTag.String(), observedConfig)
err := hp.api.SetHostMachineNetworkConfig(hp.machineTag, observedConfig)
if err != nil {
return errors.Trace(err)
}
}
return nil
} | [
"func",
"(",
"hp",
"*",
"HostPreparer",
")",
"Prepare",
"(",
"containerTag",
"names",
".",
"MachineTag",
")",
"error",
"{",
"devicesToBridge",
",",
"reconfigureDelay",
",",
"err",
":=",
"hp",
".",
"api",
".",
"HostChangesForContainer",
"(",
"containerTag",
")"... | // Prepare applies changes to the host machine that are necessary to create
// the requested container. | [
"Prepare",
"applies",
"changes",
"to",
"the",
"host",
"machine",
"that",
"are",
"necessary",
"to",
"create",
"the",
"requested",
"container",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/broker/host_preparer.go#L68-L114 | train |
juju/juju | state/backups/create.go | create | func create(args *createArgs) (_ *createResult, err error) {
// Prepare the backup builder.
builder, err := newBuilder(args.backupDir, args.filesToBackUp, args.db)
if err != nil {
return nil, errors.Trace(err)
}
defer func() {
if cerr := builder.cleanUp(args.noDownload); cerr != nil {
cerr.Log(logger)
if err == nil {
err = cerr
}
}
}()
// Inject the metadata file.
if args.metadataReader == nil {
return nil, errors.New("missing metadataReader")
}
if err := builder.injectMetadataFile(args.metadataReader); err != nil {
return nil, errors.Trace(err)
}
// Build the backup.
if err := builder.buildAll(); err != nil {
return nil, errors.Trace(err)
}
// Get the result.
result, err := builder.result()
if err != nil {
return nil, errors.Trace(err)
}
// Return the result. Note that the entire build workspace will be
// deleted at the end of this function. This includes the backup
// archive file we built. However, the handle to that file in the
// result will still be open and readable.
// If we ever support state machines on Windows, this will need to
// change (you can't delete open files on Windows).
return result, nil
} | go | func create(args *createArgs) (_ *createResult, err error) {
// Prepare the backup builder.
builder, err := newBuilder(args.backupDir, args.filesToBackUp, args.db)
if err != nil {
return nil, errors.Trace(err)
}
defer func() {
if cerr := builder.cleanUp(args.noDownload); cerr != nil {
cerr.Log(logger)
if err == nil {
err = cerr
}
}
}()
// Inject the metadata file.
if args.metadataReader == nil {
return nil, errors.New("missing metadataReader")
}
if err := builder.injectMetadataFile(args.metadataReader); err != nil {
return nil, errors.Trace(err)
}
// Build the backup.
if err := builder.buildAll(); err != nil {
return nil, errors.Trace(err)
}
// Get the result.
result, err := builder.result()
if err != nil {
return nil, errors.Trace(err)
}
// Return the result. Note that the entire build workspace will be
// deleted at the end of this function. This includes the backup
// archive file we built. However, the handle to that file in the
// result will still be open and readable.
// If we ever support state machines on Windows, this will need to
// change (you can't delete open files on Windows).
return result, nil
} | [
"func",
"create",
"(",
"args",
"*",
"createArgs",
")",
"(",
"_",
"*",
"createResult",
",",
"err",
"error",
")",
"{",
"// Prepare the backup builder.",
"builder",
",",
"err",
":=",
"newBuilder",
"(",
"args",
".",
"backupDir",
",",
"args",
".",
"filesToBackUp"... | // create builds a new backup archive file and returns it. It also
// updates the metadata with the file info. | [
"create",
"builds",
"a",
"new",
"backup",
"archive",
"file",
"and",
"returns",
"it",
".",
"It",
"also",
"updates",
"the",
"metadata",
"with",
"the",
"file",
"info",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/backups/create.go#L47-L87 | train |
juju/juju | controller/config.go | ControllerOnlyAttribute | func ControllerOnlyAttribute(attr string) bool {
for _, a := range ControllerOnlyConfigAttributes {
if attr == a {
return true
}
}
return false
} | go | func ControllerOnlyAttribute(attr string) bool {
for _, a := range ControllerOnlyConfigAttributes {
if attr == a {
return true
}
}
return false
} | [
"func",
"ControllerOnlyAttribute",
"(",
"attr",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"a",
":=",
"range",
"ControllerOnlyConfigAttributes",
"{",
"if",
"attr",
"==",
"a",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"... | // ControllerOnlyAttribute returns true if the specified attribute name
// is only relevant for a controller. | [
"ControllerOnlyAttribute",
"returns",
"true",
"if",
"the",
"specified",
"attribute",
"name",
"is",
"only",
"relevant",
"for",
"a",
"controller",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L320-L327 | train |
juju/juju | controller/config.go | mustInt | func (c Config) mustInt(name string) int {
// Values obtained over the api are encoded as float64.
if value, ok := c[name].(float64); ok {
return int(value)
}
value, _ := c[name].(int)
if value == 0 {
panic(errors.Errorf("empty value for %q found in configuration", name))
}
return value
} | go | func (c Config) mustInt(name string) int {
// Values obtained over the api are encoded as float64.
if value, ok := c[name].(float64); ok {
return int(value)
}
value, _ := c[name].(int)
if value == 0 {
panic(errors.Errorf("empty value for %q found in configuration", name))
}
return value
} | [
"func",
"(",
"c",
"Config",
")",
"mustInt",
"(",
"name",
"string",
")",
"int",
"{",
"// Values obtained over the api are encoded as float64.",
"if",
"value",
",",
"ok",
":=",
"c",
"[",
"name",
"]",
".",
"(",
"float64",
")",
";",
"ok",
"{",
"return",
"int",... | // mustInt returns the named attribute as an integer, panicking if
// it is not found or is zero. Zero values should have been
// diagnosed at Validate time. | [
"mustInt",
"returns",
"the",
"named",
"attribute",
"as",
"an",
"integer",
"panicking",
"if",
"it",
"is",
"not",
"found",
"or",
"is",
"zero",
".",
"Zero",
"values",
"should",
"have",
"been",
"diagnosed",
"at",
"Validate",
"time",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L358-L368 | train |
juju/juju | controller/config.go | APIPortOpenDelay | func (c Config) APIPortOpenDelay() time.Duration {
v := c.asString(APIPortOpenDelay)
// We know that v must be a parseable time.Duration for the config
// to be valid.
d, _ := time.ParseDuration(v)
return d
} | go | func (c Config) APIPortOpenDelay() time.Duration {
v := c.asString(APIPortOpenDelay)
// We know that v must be a parseable time.Duration for the config
// to be valid.
d, _ := time.ParseDuration(v)
return d
} | [
"func",
"(",
"c",
"Config",
")",
"APIPortOpenDelay",
"(",
")",
"time",
".",
"Duration",
"{",
"v",
":=",
"c",
".",
"asString",
"(",
"APIPortOpenDelay",
")",
"\n",
"// We know that v must be a parseable time.Duration for the config",
"// to be valid.",
"d",
",",
"_",
... | // APIPortOpenDelay returns the duration to wait before opening
// the APIPort once the controller has started up. Only used when
// the ControllerAPIPort is non-zero. | [
"APIPortOpenDelay",
"returns",
"the",
"duration",
"to",
"wait",
"before",
"opening",
"the",
"APIPort",
"once",
"the",
"controller",
"has",
"started",
"up",
".",
"Only",
"used",
"when",
"the",
"ControllerAPIPort",
"is",
"non",
"-",
"zero",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L408-L414 | train |
juju/juju | controller/config.go | ControllerAPIPort | func (c Config) ControllerAPIPort() int {
if value, ok := c[ControllerAPIPort].(float64); ok {
return int(value)
}
// If the value isn't an int, this conversion will fail and value
// will be 0, which is what we want here.
value, _ := c[ControllerAPIPort].(int)
return value
} | go | func (c Config) ControllerAPIPort() int {
if value, ok := c[ControllerAPIPort].(float64); ok {
return int(value)
}
// If the value isn't an int, this conversion will fail and value
// will be 0, which is what we want here.
value, _ := c[ControllerAPIPort].(int)
return value
} | [
"func",
"(",
"c",
"Config",
")",
"ControllerAPIPort",
"(",
")",
"int",
"{",
"if",
"value",
",",
"ok",
":=",
"c",
"[",
"ControllerAPIPort",
"]",
".",
"(",
"float64",
")",
";",
"ok",
"{",
"return",
"int",
"(",
"value",
")",
"\n",
"}",
"\n",
"// If th... | // ControllerAPIPort returns the optional API port to be used for
// the controllers to talk to each other. A zero value means that
// it is not set. | [
"ControllerAPIPort",
"returns",
"the",
"optional",
"API",
"port",
"to",
"be",
"used",
"for",
"the",
"controllers",
"to",
"talk",
"to",
"each",
"other",
".",
"A",
"zero",
"value",
"means",
"that",
"it",
"is",
"not",
"set",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L419-L427 | train |
juju/juju | controller/config.go | AuditingEnabled | func (c Config) AuditingEnabled() bool {
if v, ok := c[AuditingEnabled]; ok {
return v.(bool)
}
return DefaultAuditingEnabled
} | go | func (c Config) AuditingEnabled() bool {
if v, ok := c[AuditingEnabled]; ok {
return v.(bool)
}
return DefaultAuditingEnabled
} | [
"func",
"(",
"c",
"Config",
")",
"AuditingEnabled",
"(",
")",
"bool",
"{",
"if",
"v",
",",
"ok",
":=",
"c",
"[",
"AuditingEnabled",
"]",
";",
"ok",
"{",
"return",
"v",
".",
"(",
"bool",
")",
"\n",
"}",
"\n",
"return",
"DefaultAuditingEnabled",
"\n",
... | // AuditingEnabled returns whether or not auditing has been enabled
// for the environment. The default is false. | [
"AuditingEnabled",
"returns",
"whether",
"or",
"not",
"auditing",
"has",
"been",
"enabled",
"for",
"the",
"environment",
".",
"The",
"default",
"is",
"false",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L431-L436 | train |
juju/juju | controller/config.go | AuditLogCaptureArgs | func (c Config) AuditLogCaptureArgs() bool {
if v, ok := c[AuditLogCaptureArgs]; ok {
return v.(bool)
}
return DefaultAuditLogCaptureArgs
} | go | func (c Config) AuditLogCaptureArgs() bool {
if v, ok := c[AuditLogCaptureArgs]; ok {
return v.(bool)
}
return DefaultAuditLogCaptureArgs
} | [
"func",
"(",
"c",
"Config",
")",
"AuditLogCaptureArgs",
"(",
")",
"bool",
"{",
"if",
"v",
",",
"ok",
":=",
"c",
"[",
"AuditLogCaptureArgs",
"]",
";",
"ok",
"{",
"return",
"v",
".",
"(",
"bool",
")",
"\n",
"}",
"\n",
"return",
"DefaultAuditLogCaptureArg... | // AuditLogCaptureArgs returns whether audit logging should capture
// the arguments to API methods. The default is false. | [
"AuditLogCaptureArgs",
"returns",
"whether",
"audit",
"logging",
"should",
"capture",
"the",
"arguments",
"to",
"API",
"methods",
".",
"The",
"default",
"is",
"false",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L440-L445 | train |
juju/juju | controller/config.go | AuditLogMaxSizeMB | func (c Config) AuditLogMaxSizeMB() int {
// Value has already been validated.
value, _ := utils.ParseSize(c.asString(AuditLogMaxSize))
return int(value)
} | go | func (c Config) AuditLogMaxSizeMB() int {
// Value has already been validated.
value, _ := utils.ParseSize(c.asString(AuditLogMaxSize))
return int(value)
} | [
"func",
"(",
"c",
"Config",
")",
"AuditLogMaxSizeMB",
"(",
")",
"int",
"{",
"// Value has already been validated.",
"value",
",",
"_",
":=",
"utils",
".",
"ParseSize",
"(",
"c",
".",
"asString",
"(",
"AuditLogMaxSize",
")",
")",
"\n",
"return",
"int",
"(",
... | // AuditLogMaxSizeMB returns the maximum size for an audit log file in
// MB. | [
"AuditLogMaxSizeMB",
"returns",
"the",
"maximum",
"size",
"for",
"an",
"audit",
"log",
"file",
"in",
"MB",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L449-L453 | train |
juju/juju | controller/config.go | AuditLogExcludeMethods | func (c Config) AuditLogExcludeMethods() set.Strings {
if value, ok := c[AuditLogExcludeMethods]; ok {
value := value.([]interface{})
items := set.NewStrings()
for _, item := range value {
items.Add(item.(string))
}
return items
}
return set.NewStrings(DefaultAuditLogExcludeMethods...)
} | go | func (c Config) AuditLogExcludeMethods() set.Strings {
if value, ok := c[AuditLogExcludeMethods]; ok {
value := value.([]interface{})
items := set.NewStrings()
for _, item := range value {
items.Add(item.(string))
}
return items
}
return set.NewStrings(DefaultAuditLogExcludeMethods...)
} | [
"func",
"(",
"c",
"Config",
")",
"AuditLogExcludeMethods",
"(",
")",
"set",
".",
"Strings",
"{",
"if",
"value",
",",
"ok",
":=",
"c",
"[",
"AuditLogExcludeMethods",
"]",
";",
"ok",
"{",
"value",
":=",
"value",
".",
"(",
"[",
"]",
"interface",
"{",
"}... | // AuditLogExcludeMethods returns the set of method names that are
// considered uninteresting for audit logging. Conversations
// containing only these will be excluded from the audit log. | [
"AuditLogExcludeMethods",
"returns",
"the",
"set",
"of",
"method",
"names",
"that",
"are",
"considered",
"uninteresting",
"for",
"audit",
"logging",
".",
"Conversations",
"containing",
"only",
"these",
"will",
"be",
"excluded",
"from",
"the",
"audit",
"log",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L464-L474 | train |
juju/juju | controller/config.go | Features | func (c Config) Features() set.Strings {
features := set.NewStrings()
if value, ok := c[Features]; ok {
value := value.([]interface{})
for _, item := range value {
features.Add(item.(string))
}
}
return features
} | go | func (c Config) Features() set.Strings {
features := set.NewStrings()
if value, ok := c[Features]; ok {
value := value.([]interface{})
for _, item := range value {
features.Add(item.(string))
}
}
return features
} | [
"func",
"(",
"c",
"Config",
")",
"Features",
"(",
")",
"set",
".",
"Strings",
"{",
"features",
":=",
"set",
".",
"NewStrings",
"(",
")",
"\n",
"if",
"value",
",",
"ok",
":=",
"c",
"[",
"Features",
"]",
";",
"ok",
"{",
"value",
":=",
"value",
".",... | // Features returns the controller config set features flags. | [
"Features",
"returns",
"the",
"controller",
"config",
"set",
"features",
"flags",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L477-L486 | train |
juju/juju | controller/config.go | CharmStoreURL | func (c Config) CharmStoreURL() string {
url := c.asString(CharmStoreURL)
if url == "" {
return csclient.ServerURL
}
return url
} | go | func (c Config) CharmStoreURL() string {
url := c.asString(CharmStoreURL)
if url == "" {
return csclient.ServerURL
}
return url
} | [
"func",
"(",
"c",
"Config",
")",
"CharmStoreURL",
"(",
")",
"string",
"{",
"url",
":=",
"c",
".",
"asString",
"(",
"CharmStoreURL",
")",
"\n",
"if",
"url",
"==",
"\"",
"\"",
"{",
"return",
"csclient",
".",
"ServerURL",
"\n",
"}",
"\n",
"return",
"url... | // CharmStoreURL returns the URL to use for charmstore api calls. | [
"CharmStoreURL",
"returns",
"the",
"URL",
"to",
"use",
"for",
"charmstore",
"api",
"calls",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L489-L495 | train |
juju/juju | controller/config.go | IdentityPublicKey | func (c Config) IdentityPublicKey() *bakery.PublicKey {
key := c.asString(IdentityPublicKey)
if key == "" {
return nil
}
var pubKey bakery.PublicKey
err := pubKey.UnmarshalText([]byte(key))
if err != nil {
// We check if the key string can be unmarshalled into a PublicKey in the
// Validate function, so we really do not expect this to fail.
panic(err)
}
return &pubKey
} | go | func (c Config) IdentityPublicKey() *bakery.PublicKey {
key := c.asString(IdentityPublicKey)
if key == "" {
return nil
}
var pubKey bakery.PublicKey
err := pubKey.UnmarshalText([]byte(key))
if err != nil {
// We check if the key string can be unmarshalled into a PublicKey in the
// Validate function, so we really do not expect this to fail.
panic(err)
}
return &pubKey
} | [
"func",
"(",
"c",
"Config",
")",
"IdentityPublicKey",
"(",
")",
"*",
"bakery",
".",
"PublicKey",
"{",
"key",
":=",
"c",
".",
"asString",
"(",
"IdentityPublicKey",
")",
"\n",
"if",
"key",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"var",... | // IdentityPublicKey returns the public key of the identity manager. | [
"IdentityPublicKey",
"returns",
"the",
"public",
"key",
"of",
"the",
"identity",
"manager",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L533-L546 | train |
juju/juju | controller/config.go | MongoMemoryProfile | func (c Config) MongoMemoryProfile() string {
if profile, ok := c[MongoMemoryProfile]; ok {
return profile.(string)
}
return DefaultMongoMemoryProfile
} | go | func (c Config) MongoMemoryProfile() string {
if profile, ok := c[MongoMemoryProfile]; ok {
return profile.(string)
}
return DefaultMongoMemoryProfile
} | [
"func",
"(",
"c",
"Config",
")",
"MongoMemoryProfile",
"(",
")",
"string",
"{",
"if",
"profile",
",",
"ok",
":=",
"c",
"[",
"MongoMemoryProfile",
"]",
";",
"ok",
"{",
"return",
"profile",
".",
"(",
"string",
")",
"\n",
"}",
"\n",
"return",
"DefaultMong... | // MongoMemoryProfile returns the selected profile or low. | [
"MongoMemoryProfile",
"returns",
"the",
"selected",
"profile",
"or",
"low",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L549-L554 | train |
juju/juju | controller/config.go | NUMACtlPreference | func (c Config) NUMACtlPreference() bool {
if numa, ok := c[SetNUMAControlPolicyKey]; ok {
return numa.(bool)
}
return DefaultNUMAControlPolicy
} | go | func (c Config) NUMACtlPreference() bool {
if numa, ok := c[SetNUMAControlPolicyKey]; ok {
return numa.(bool)
}
return DefaultNUMAControlPolicy
} | [
"func",
"(",
"c",
"Config",
")",
"NUMACtlPreference",
"(",
")",
"bool",
"{",
"if",
"numa",
",",
"ok",
":=",
"c",
"[",
"SetNUMAControlPolicyKey",
"]",
";",
"ok",
"{",
"return",
"numa",
".",
"(",
"bool",
")",
"\n",
"}",
"\n",
"return",
"DefaultNUMAContro... | // NUMACtlPreference returns if numactl is preferred. | [
"NUMACtlPreference",
"returns",
"if",
"numactl",
"is",
"preferred",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L557-L562 | train |
juju/juju | controller/config.go | AllowModelAccess | func (c Config) AllowModelAccess() bool {
value, _ := c[AllowModelAccessKey].(bool)
return value
} | go | func (c Config) AllowModelAccess() bool {
value, _ := c[AllowModelAccessKey].(bool)
return value
} | [
"func",
"(",
"c",
"Config",
")",
"AllowModelAccess",
"(",
")",
"bool",
"{",
"value",
",",
"_",
":=",
"c",
"[",
"AllowModelAccessKey",
"]",
".",
"(",
"bool",
")",
"\n",
"return",
"value",
"\n",
"}"
] | // AllowModelAccess reports whether users are allowed to access models
// they have been granted permission for even when they can't access
// the controller. | [
"AllowModelAccess",
"reports",
"whether",
"users",
"are",
"allowed",
"to",
"access",
"models",
"they",
"have",
"been",
"granted",
"permission",
"for",
"even",
"when",
"they",
"can",
"t",
"access",
"the",
"controller",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L567-L570 | train |
juju/juju | controller/config.go | MaxLogSizeMB | func (c Config) MaxLogSizeMB() int {
// Value has already been validated.
val, _ := utils.ParseSize(c.mustString(MaxLogsSize))
return int(val)
} | go | func (c Config) MaxLogSizeMB() int {
// Value has already been validated.
val, _ := utils.ParseSize(c.mustString(MaxLogsSize))
return int(val)
} | [
"func",
"(",
"c",
"Config",
")",
"MaxLogSizeMB",
"(",
")",
"int",
"{",
"// Value has already been validated.",
"val",
",",
"_",
":=",
"utils",
".",
"ParseSize",
"(",
"c",
".",
"mustString",
"(",
"MaxLogsSize",
")",
")",
"\n",
"return",
"int",
"(",
"val",
... | // MaxLogSizeMB is the maximum size in MiB which the log collection
// can grow to before being pruned. | [
"MaxLogSizeMB",
"is",
"the",
"maximum",
"size",
"in",
"MiB",
"which",
"the",
"log",
"collection",
"can",
"grow",
"to",
"before",
"being",
"pruned",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L581-L585 | train |
juju/juju | controller/config.go | MaxTxnLogSizeMB | func (c Config) MaxTxnLogSizeMB() int {
// Value has already been validated.
val, _ := utils.ParseSize(c.mustString(MaxTxnLogSize))
return int(val)
} | go | func (c Config) MaxTxnLogSizeMB() int {
// Value has already been validated.
val, _ := utils.ParseSize(c.mustString(MaxTxnLogSize))
return int(val)
} | [
"func",
"(",
"c",
"Config",
")",
"MaxTxnLogSizeMB",
"(",
")",
"int",
"{",
"// Value has already been validated.",
"val",
",",
"_",
":=",
"utils",
".",
"ParseSize",
"(",
"c",
".",
"mustString",
"(",
"MaxTxnLogSize",
")",
")",
"\n",
"return",
"int",
"(",
"va... | // MaxTxnLogSizeMB is the maximum size in MiB of the txn log collection. | [
"MaxTxnLogSizeMB",
"is",
"the",
"maximum",
"size",
"in",
"MiB",
"of",
"the",
"txn",
"log",
"collection",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L588-L592 | train |
juju/juju | controller/config.go | PruneTxnSleepTime | func (c Config) PruneTxnSleepTime() time.Duration {
asInterface, ok := c[PruneTxnSleepTime]
if !ok {
asInterface = DefaultPruneTxnSleepTime
}
asStr, ok := asInterface.(string)
if !ok {
asStr = DefaultPruneTxnSleepTime
}
val, _ := time.ParseDuration(asStr)
return val
} | go | func (c Config) PruneTxnSleepTime() time.Duration {
asInterface, ok := c[PruneTxnSleepTime]
if !ok {
asInterface = DefaultPruneTxnSleepTime
}
asStr, ok := asInterface.(string)
if !ok {
asStr = DefaultPruneTxnSleepTime
}
val, _ := time.ParseDuration(asStr)
return val
} | [
"func",
"(",
"c",
"Config",
")",
"PruneTxnSleepTime",
"(",
")",
"time",
".",
"Duration",
"{",
"asInterface",
",",
"ok",
":=",
"c",
"[",
"PruneTxnSleepTime",
"]",
"\n",
"if",
"!",
"ok",
"{",
"asInterface",
"=",
"DefaultPruneTxnSleepTime",
"\n",
"}",
"\n",
... | // PruneTxnSleepTime is the amount of time to sleep between batches. | [
"PruneTxnSleepTime",
"is",
"the",
"amount",
"of",
"time",
"to",
"sleep",
"between",
"batches",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L610-L621 | train |
juju/juju | controller/config.go | MeteringURL | func (c Config) MeteringURL() string {
url := c.asString(MeteringURL)
if url == "" {
return romulus.DefaultAPIRoot
}
return url
} | go | func (c Config) MeteringURL() string {
url := c.asString(MeteringURL)
if url == "" {
return romulus.DefaultAPIRoot
}
return url
} | [
"func",
"(",
"c",
"Config",
")",
"MeteringURL",
"(",
")",
"string",
"{",
"url",
":=",
"c",
".",
"asString",
"(",
"MeteringURL",
")",
"\n",
"if",
"url",
"==",
"\"",
"\"",
"{",
"return",
"romulus",
".",
"DefaultAPIRoot",
"\n",
"}",
"\n",
"return",
"url... | // MeteringURL returns the URL to use for metering api calls. | [
"MeteringURL",
"returns",
"the",
"URL",
"to",
"use",
"for",
"metering",
"api",
"calls",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L648-L654 | train |
juju/juju | controller/config.go | GenerateControllerCertAndKey | func GenerateControllerCertAndKey(caCert, caKey string, hostAddresses []string) (string, string, error) {
return cert.NewDefaultServer(caCert, caKey, hostAddresses)
} | go | func GenerateControllerCertAndKey(caCert, caKey string, hostAddresses []string) (string, string, error) {
return cert.NewDefaultServer(caCert, caKey, hostAddresses)
} | [
"func",
"GenerateControllerCertAndKey",
"(",
"caCert",
",",
"caKey",
"string",
",",
"hostAddresses",
"[",
"]",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"return",
"cert",
".",
"NewDefaultServer",
"(",
"caCert",
",",
"caKey",
",",
... | // GenerateControllerCertAndKey makes sure that the config has a CACert and
// CAPrivateKey, generates and returns new certificate and key. | [
"GenerateControllerCertAndKey",
"makes",
"sure",
"that",
"the",
"config",
"has",
"a",
"CACert",
"and",
"CAPrivateKey",
"generates",
"and",
"returns",
"new",
"certificate",
"and",
"key",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/controller/config.go#L845-L847 | train |
juju/juju | upgrades/steps_234.go | stateStepsFor234 | func stateStepsFor234() []Step {
return []Step{
&upgradeStep{
description: "delete cloud image metadata cache",
targets: []Target{DatabaseMaster},
run: func(context Context) error {
return context.State().DeleteCloudImageMetadata()
},
},
}
} | go | func stateStepsFor234() []Step {
return []Step{
&upgradeStep{
description: "delete cloud image metadata cache",
targets: []Target{DatabaseMaster},
run: func(context Context) error {
return context.State().DeleteCloudImageMetadata()
},
},
}
} | [
"func",
"stateStepsFor234",
"(",
")",
"[",
"]",
"Step",
"{",
"return",
"[",
"]",
"Step",
"{",
"&",
"upgradeStep",
"{",
"description",
":",
"\"",
"\"",
",",
"targets",
":",
"[",
"]",
"Target",
"{",
"DatabaseMaster",
"}",
",",
"run",
":",
"func",
"(",
... | // stateStepsFor234 returns upgrade steps for Juju 2.3.4 that manipulate state directly. | [
"stateStepsFor234",
"returns",
"upgrade",
"steps",
"for",
"Juju",
"2",
".",
"3",
".",
"4",
"that",
"manipulate",
"state",
"directly",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/upgrades/steps_234.go#L7-L17 | train |
juju/juju | cmd/juju/model/mocks/diff_mock.go | NewMockDiffCommandAPI | func NewMockDiffCommandAPI(ctrl *gomock.Controller) *MockDiffCommandAPI {
mock := &MockDiffCommandAPI{ctrl: ctrl}
mock.recorder = &MockDiffCommandAPIMockRecorder{mock}
return mock
} | go | func NewMockDiffCommandAPI(ctrl *gomock.Controller) *MockDiffCommandAPI {
mock := &MockDiffCommandAPI{ctrl: ctrl}
mock.recorder = &MockDiffCommandAPIMockRecorder{mock}
return mock
} | [
"func",
"NewMockDiffCommandAPI",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockDiffCommandAPI",
"{",
"mock",
":=",
"&",
"MockDiffCommandAPI",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockDiffCommandAPIMockRecorder"... | // NewMockDiffCommandAPI creates a new mock instance | [
"NewMockDiffCommandAPI",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/model/mocks/diff_mock.go#L26-L30 | train |
juju/juju | cmd/juju/model/mocks/diff_mock.go | BranchInfo | func (m *MockDiffCommandAPI) BranchInfo(arg0 string, arg1 bool, arg2 func(time.Time) string) (map[string]model.Generation, error) {
ret := m.ctrl.Call(m, "BranchInfo", arg0, arg1, arg2)
ret0, _ := ret[0].(map[string]model.Generation)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockDiffCommandAPI) BranchInfo(arg0 string, arg1 bool, arg2 func(time.Time) string) (map[string]model.Generation, error) {
ret := m.ctrl.Call(m, "BranchInfo", arg0, arg1, arg2)
ret0, _ := ret[0].(map[string]model.Generation)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockDiffCommandAPI",
")",
"BranchInfo",
"(",
"arg0",
"string",
",",
"arg1",
"bool",
",",
"arg2",
"func",
"(",
"time",
".",
"Time",
")",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"model",
".",
"Generation",
",",
"error",
"... | // BranchInfo mocks base method | [
"BranchInfo",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/model/mocks/diff_mock.go#L38-L43 | train |
juju/juju | cmd/juju/model/mocks/diff_mock.go | BranchInfo | func (mr *MockDiffCommandAPIMockRecorder) BranchInfo(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BranchInfo", reflect.TypeOf((*MockDiffCommandAPI)(nil).BranchInfo), arg0, arg1, arg2)
} | go | func (mr *MockDiffCommandAPIMockRecorder) BranchInfo(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BranchInfo", reflect.TypeOf((*MockDiffCommandAPI)(nil).BranchInfo), arg0, arg1, arg2)
} | [
"func",
"(",
"mr",
"*",
"MockDiffCommandAPIMockRecorder",
")",
"BranchInfo",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",... | // BranchInfo indicates an expected call of BranchInfo | [
"BranchInfo",
"indicates",
"an",
"expected",
"call",
"of",
"BranchInfo"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/model/mocks/diff_mock.go#L46-L48 | train |
juju/juju | apiserver/facades/client/charms/client.go | List | func (a *API) List(args params.CharmsList) (params.CharmsListResult, error) {
if err := a.checkCanRead(); err != nil {
return params.CharmsListResult{}, errors.Trace(err)
}
charms, err := a.backend.AllCharms()
if err != nil {
return params.CharmsListResult{}, errors.Annotatef(err, " listing charms ")
}
names := set.NewStrings(args.Names...)
checkName := !names.IsEmpty()
charmURLs := []string{}
for _, aCharm := range charms {
charmURL := aCharm.URL()
if checkName {
if !names.Contains(charmURL.Name) {
continue
}
}
charmURLs = append(charmURLs, charmURL.String())
}
return params.CharmsListResult{CharmURLs: charmURLs}, nil
} | go | func (a *API) List(args params.CharmsList) (params.CharmsListResult, error) {
if err := a.checkCanRead(); err != nil {
return params.CharmsListResult{}, errors.Trace(err)
}
charms, err := a.backend.AllCharms()
if err != nil {
return params.CharmsListResult{}, errors.Annotatef(err, " listing charms ")
}
names := set.NewStrings(args.Names...)
checkName := !names.IsEmpty()
charmURLs := []string{}
for _, aCharm := range charms {
charmURL := aCharm.URL()
if checkName {
if !names.Contains(charmURL.Name) {
continue
}
}
charmURLs = append(charmURLs, charmURL.String())
}
return params.CharmsListResult{CharmURLs: charmURLs}, nil
} | [
"func",
"(",
"a",
"*",
"API",
")",
"List",
"(",
"args",
"params",
".",
"CharmsList",
")",
"(",
"params",
".",
"CharmsListResult",
",",
"error",
")",
"{",
"if",
"err",
":=",
"a",
".",
"checkCanRead",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",... | // List returns a list of charm URLs currently in the state.
// If supplied parameter contains any names, the result will be filtered
// to return only the charms with supplied names. | [
"List",
"returns",
"a",
"list",
"of",
"charm",
"URLs",
"currently",
"in",
"the",
"state",
".",
"If",
"supplied",
"parameter",
"contains",
"any",
"names",
"the",
"result",
"will",
"be",
"filtered",
"to",
"return",
"only",
"the",
"charms",
"with",
"supplied",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/charms/client.go#L110-L133 | train |
juju/juju | container/network.go | FallbackInterfaceInfo | func FallbackInterfaceInfo() []network.InterfaceInfo {
return []network.InterfaceInfo{{
InterfaceName: "eth0",
InterfaceType: network.EthernetInterface,
ConfigType: network.ConfigDHCP,
}}
} | go | func FallbackInterfaceInfo() []network.InterfaceInfo {
return []network.InterfaceInfo{{
InterfaceName: "eth0",
InterfaceType: network.EthernetInterface,
ConfigType: network.ConfigDHCP,
}}
} | [
"func",
"FallbackInterfaceInfo",
"(",
")",
"[",
"]",
"network",
".",
"InterfaceInfo",
"{",
"return",
"[",
"]",
"network",
".",
"InterfaceInfo",
"{",
"{",
"InterfaceName",
":",
"\"",
"\"",
",",
"InterfaceType",
":",
"network",
".",
"EthernetInterface",
",",
"... | // FallbackInterfaceInfo returns a single "eth0" interface configured with DHCP. | [
"FallbackInterfaceInfo",
"returns",
"a",
"single",
"eth0",
"interface",
"configured",
"with",
"DHCP",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/network.go#L25-L31 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | SetAttr | func (cfg *cloudConfig) SetAttr(name string, value interface{}) {
cfg.attrs[name] = value
} | go | func (cfg *cloudConfig) SetAttr(name string, value interface{}) {
cfg.attrs[name] = value
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"SetAttr",
"(",
"name",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"cfg",
".",
"attrs",
"[",
"name",
"]",
"=",
"value",
"\n",
"}"
] | // SetAttr is defined on the CloudConfig interface. | [
"SetAttr",
"is",
"defined",
"on",
"the",
"CloudConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L92-L94 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | AddUser | func (cfg *cloudConfig) AddUser(user *User) {
users, _ := cfg.attrs["users"].([]map[string]interface{})
newUser := map[string]interface{}{
"name": user.Name,
"lock_passwd": true,
}
if user.Groups != nil {
newUser["groups"] = user.Groups
}
if user.Shell != "" {
newUser["shell"] = user.Shell
}
if user.SSHAuthorizedKeys != "" {
newUser["ssh-authorized-keys"] = annotateKeys(user.SSHAuthorizedKeys)
}
if user.Sudo != nil {
newUser["sudo"] = user.Sudo
}
cfg.SetAttr("users", append(users, newUser))
} | go | func (cfg *cloudConfig) AddUser(user *User) {
users, _ := cfg.attrs["users"].([]map[string]interface{})
newUser := map[string]interface{}{
"name": user.Name,
"lock_passwd": true,
}
if user.Groups != nil {
newUser["groups"] = user.Groups
}
if user.Shell != "" {
newUser["shell"] = user.Shell
}
if user.SSHAuthorizedKeys != "" {
newUser["ssh-authorized-keys"] = annotateKeys(user.SSHAuthorizedKeys)
}
if user.Sudo != nil {
newUser["sudo"] = user.Sudo
}
cfg.SetAttr("users", append(users, newUser))
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"AddUser",
"(",
"user",
"*",
"User",
")",
"{",
"users",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"[",
"]",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"... | // AddUser is defined on the UsersConfig interface. | [
"AddUser",
"is",
"defined",
"on",
"the",
"UsersConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L114-L133 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | SystemUpdate | func (cfg *cloudConfig) SystemUpdate() bool {
update, _ := cfg.attrs["package_update"].(bool)
return update
} | go | func (cfg *cloudConfig) SystemUpdate() bool {
update, _ := cfg.attrs["package_update"].(bool)
return update
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"SystemUpdate",
"(",
")",
"bool",
"{",
"update",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"bool",
")",
"\n",
"return",
"update",
"\n",
"}"
] | // SystemUpdate is defined on the SystemUpdateConfig interface. | [
"SystemUpdate",
"is",
"defined",
"on",
"the",
"SystemUpdateConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L151-L154 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | SystemUpgrade | func (cfg *cloudConfig) SystemUpgrade() bool {
upgrade, _ := cfg.attrs["package_upgrade"].(bool)
return upgrade
} | go | func (cfg *cloudConfig) SystemUpgrade() bool {
upgrade, _ := cfg.attrs["package_upgrade"].(bool)
return upgrade
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"SystemUpgrade",
"(",
")",
"bool",
"{",
"upgrade",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"bool",
")",
"\n",
"return",
"upgrade",
"\n",
"}"
] | // SystemUpgrade is defined on the SystemUpgradeConfig interface. | [
"SystemUpgrade",
"is",
"defined",
"on",
"the",
"SystemUpgradeConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L167-L170 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | AddPackage | func (cfg *cloudConfig) AddPackage(pack string) {
cfg.attrs["packages"] = append(cfg.Packages(), pack)
} | go | func (cfg *cloudConfig) AddPackage(pack string) {
cfg.attrs["packages"] = append(cfg.Packages(), pack)
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"AddPackage",
"(",
"pack",
"string",
")",
"{",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
"=",
"append",
"(",
"cfg",
".",
"Packages",
"(",
")",
",",
"pack",
")",
"\n",
"}"
] | // AddPackage is defined on the PackagingConfig interface. | [
"AddPackage",
"is",
"defined",
"on",
"the",
"PackagingConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L173-L175 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | RemovePackage | func (cfg *cloudConfig) RemovePackage(pack string) {
cfg.attrs["packages"] = removeStringFromSlice(cfg.Packages(), pack)
} | go | func (cfg *cloudConfig) RemovePackage(pack string) {
cfg.attrs["packages"] = removeStringFromSlice(cfg.Packages(), pack)
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"RemovePackage",
"(",
"pack",
"string",
")",
"{",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
"=",
"removeStringFromSlice",
"(",
"cfg",
".",
"Packages",
"(",
")",
",",
"pack",
")",
"\n",
"}"
] | // RemovePackage is defined on the PackagingConfig interface. | [
"RemovePackage",
"is",
"defined",
"on",
"the",
"PackagingConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L178-L180 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | Packages | func (cfg *cloudConfig) Packages() []string {
packs, _ := cfg.attrs["packages"].([]string)
return packs
} | go | func (cfg *cloudConfig) Packages() []string {
packs, _ := cfg.attrs["packages"].([]string)
return packs
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"Packages",
"(",
")",
"[",
"]",
"string",
"{",
"packs",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"[",
"]",
"string",
")",
"\n",
"return",
"packs",
"\n",
"}"
] | // Packages is defined on the PackagingConfig interface. | [
"Packages",
"is",
"defined",
"on",
"the",
"PackagingConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L183-L186 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | AddRunCmd | func (cfg *cloudConfig) AddRunCmd(args ...string) {
cfg.attrs["runcmd"] = append(cfg.RunCmds(), strings.Join(args, " "))
} | go | func (cfg *cloudConfig) AddRunCmd(args ...string) {
cfg.attrs["runcmd"] = append(cfg.RunCmds(), strings.Join(args, " "))
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"AddRunCmd",
"(",
"args",
"...",
"string",
")",
"{",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
"=",
"append",
"(",
"cfg",
".",
"RunCmds",
"(",
")",
",",
"strings",
".",
"Join",
"(",
"args",
",",
"\"",... | // AddRunCmd is defined on the RunCmdsConfig interface. | [
"AddRunCmd",
"is",
"defined",
"on",
"the",
"RunCmdsConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L189-L191 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | AddScripts | func (cfg *cloudConfig) AddScripts(script ...string) {
for _, line := range script {
cfg.AddRunCmd(line)
}
} | go | func (cfg *cloudConfig) AddScripts(script ...string) {
for _, line := range script {
cfg.AddRunCmd(line)
}
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"AddScripts",
"(",
"script",
"...",
"string",
")",
"{",
"for",
"_",
",",
"line",
":=",
"range",
"script",
"{",
"cfg",
".",
"AddRunCmd",
"(",
"line",
")",
"\n",
"}",
"\n",
"}"
] | // AddScripts is defined on the RunCmdsConfig interface. | [
"AddScripts",
"is",
"defined",
"on",
"the",
"RunCmdsConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L194-L198 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | RemoveRunCmd | func (cfg *cloudConfig) RemoveRunCmd(cmd string) {
cfg.attrs["runcmd"] = removeStringFromSlice(cfg.RunCmds(), cmd)
} | go | func (cfg *cloudConfig) RemoveRunCmd(cmd string) {
cfg.attrs["runcmd"] = removeStringFromSlice(cfg.RunCmds(), cmd)
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"RemoveRunCmd",
"(",
"cmd",
"string",
")",
"{",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
"=",
"removeStringFromSlice",
"(",
"cfg",
".",
"RunCmds",
"(",
")",
",",
"cmd",
")",
"\n",
"}"
] | // RemoveRunCmd is defined on the RunCmdsConfig interface. | [
"RemoveRunCmd",
"is",
"defined",
"on",
"the",
"RunCmdsConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L206-L208 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | RunCmds | func (cfg *cloudConfig) RunCmds() []string {
cmds, _ := cfg.attrs["runcmd"].([]string)
return cmds
} | go | func (cfg *cloudConfig) RunCmds() []string {
cmds, _ := cfg.attrs["runcmd"].([]string)
return cmds
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"RunCmds",
"(",
")",
"[",
"]",
"string",
"{",
"cmds",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"[",
"]",
"string",
")",
"\n",
"return",
"cmds",
"\n",
"}"
] | // RunCmds is defined on the RunCmdsConfig interface. | [
"RunCmds",
"is",
"defined",
"on",
"the",
"RunCmdsConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L211-L214 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | AddBootCmd | func (cfg *cloudConfig) AddBootCmd(args ...string) {
cfg.attrs["bootcmd"] = append(cfg.BootCmds(), strings.Join(args, " "))
} | go | func (cfg *cloudConfig) AddBootCmd(args ...string) {
cfg.attrs["bootcmd"] = append(cfg.BootCmds(), strings.Join(args, " "))
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"AddBootCmd",
"(",
"args",
"...",
"string",
")",
"{",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
"=",
"append",
"(",
"cfg",
".",
"BootCmds",
"(",
")",
",",
"strings",
".",
"Join",
"(",
"args",
",",
"\"... | // AddBootCmd is defined on the BootCmdsConfig interface. | [
"AddBootCmd",
"is",
"defined",
"on",
"the",
"BootCmdsConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L217-L219 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | RemoveBootCmd | func (cfg *cloudConfig) RemoveBootCmd(cmd string) {
cfg.attrs["bootcmd"] = removeStringFromSlice(cfg.BootCmds(), cmd)
} | go | func (cfg *cloudConfig) RemoveBootCmd(cmd string) {
cfg.attrs["bootcmd"] = removeStringFromSlice(cfg.BootCmds(), cmd)
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"RemoveBootCmd",
"(",
"cmd",
"string",
")",
"{",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
"=",
"removeStringFromSlice",
"(",
"cfg",
".",
"BootCmds",
"(",
")",
",",
"cmd",
")",
"\n",
"}"
] | // RemoveBootCmd is defined on the BootCmdsConfig interface. | [
"RemoveBootCmd",
"is",
"defined",
"on",
"the",
"BootCmdsConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L222-L224 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | BootCmds | func (cfg *cloudConfig) BootCmds() []string {
cmds, _ := cfg.attrs["bootcmd"].([]string)
return cmds
} | go | func (cfg *cloudConfig) BootCmds() []string {
cmds, _ := cfg.attrs["bootcmd"].([]string)
return cmds
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"BootCmds",
"(",
")",
"[",
"]",
"string",
"{",
"cmds",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"[",
"]",
"string",
")",
"\n",
"return",
"cmds",
"\n",
"}"
] | // BootCmds is defined on the BootCmdsConfig interface. | [
"BootCmds",
"is",
"defined",
"on",
"the",
"BootCmdsConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L227-L230 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | DisableEC2Metadata | func (cfg *cloudConfig) DisableEC2Metadata() bool {
disEC2, _ := cfg.attrs["disable_ec2_metadata"].(bool)
return disEC2
} | go | func (cfg *cloudConfig) DisableEC2Metadata() bool {
disEC2, _ := cfg.attrs["disable_ec2_metadata"].(bool)
return disEC2
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"DisableEC2Metadata",
"(",
")",
"bool",
"{",
"disEC2",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"bool",
")",
"\n",
"return",
"disEC2",
"\n",
"}"
] | // DisableEC2Metadata is defined on the EC2MetadataConfig interface. | [
"DisableEC2Metadata",
"is",
"defined",
"on",
"the",
"EC2MetadataConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L243-L246 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | FinalMessage | func (cfg *cloudConfig) FinalMessage() string {
message, _ := cfg.attrs["final_message"].(string)
return message
} | go | func (cfg *cloudConfig) FinalMessage() string {
message, _ := cfg.attrs["final_message"].(string)
return message
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"FinalMessage",
"(",
")",
"string",
"{",
"message",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"return",
"message",
"\n",
"}"
] | // FinalMessage is defined on the FinalMessageConfig interface. | [
"FinalMessage",
"is",
"defined",
"on",
"the",
"FinalMessageConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L259-L262 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | Locale | func (cfg *cloudConfig) Locale() string {
locale, _ := cfg.attrs["locale"].(string)
return locale
} | go | func (cfg *cloudConfig) Locale() string {
locale, _ := cfg.attrs["locale"].(string)
return locale
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"Locale",
"(",
")",
"string",
"{",
"locale",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"string",
")",
"\n",
"return",
"locale",
"\n",
"}"
] | // Locale is defined on the LocaleConfig interface. | [
"Locale",
"is",
"defined",
"on",
"the",
"LocaleConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L275-L278 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | SetOutput | func (cfg *cloudConfig) SetOutput(kind OutputKind, stdout, stderr string) {
out, _ := cfg.attrs["output"].(map[string]interface{})
if out == nil {
out = make(map[string]interface{})
}
if stderr == "" {
out[string(kind)] = stdout
} else {
out[string(kind)] = []string{stdout, stderr}
}
cfg.SetAttr("output", out)
} | go | func (cfg *cloudConfig) SetOutput(kind OutputKind, stdout, stderr string) {
out, _ := cfg.attrs["output"].(map[string]interface{})
if out == nil {
out = make(map[string]interface{})
}
if stderr == "" {
out[string(kind)] = stdout
} else {
out[string(kind)] = []string{stdout, stderr}
}
cfg.SetAttr("output", out)
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"SetOutput",
"(",
"kind",
"OutputKind",
",",
"stdout",
",",
"stderr",
"string",
")",
"{",
"out",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"map",
"[",
"string",
"]",
"interface... | // SetOutput is defined on the OutputConfig interface. | [
"SetOutput",
"is",
"defined",
"on",
"the",
"OutputConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L289-L302 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | Output | func (cfg *cloudConfig) Output(kind OutputKind) (stdout, stderr string) {
if out, ok := cfg.attrs["output"].(map[string]interface{}); ok {
switch out := out[string(kind)].(type) {
case string:
stdout = out
case []string:
stdout, stderr = out[0], out[1]
}
}
return stdout, stderr
} | go | func (cfg *cloudConfig) Output(kind OutputKind) (stdout, stderr string) {
if out, ok := cfg.attrs["output"].(map[string]interface{}); ok {
switch out := out[string(kind)].(type) {
case string:
stdout = out
case []string:
stdout, stderr = out[0], out[1]
}
}
return stdout, stderr
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"Output",
"(",
"kind",
"OutputKind",
")",
"(",
"stdout",
",",
"stderr",
"string",
")",
"{",
"if",
"out",
",",
"ok",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"map",
"[",
"string",
"]",... | // Output is defined on the OutputConfig interface. | [
"Output",
"is",
"defined",
"on",
"the",
"OutputConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L305-L316 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | SetSSHAuthorizedKeys | func (cfg *cloudConfig) SetSSHAuthorizedKeys(rawKeys string) {
keys := annotateKeys(rawKeys)
if len(keys) != 0 {
cfg.SetAttr("ssh_authorized_keys", keys)
} else {
cfg.UnsetAttr("ssh_authorized_keys")
}
} | go | func (cfg *cloudConfig) SetSSHAuthorizedKeys(rawKeys string) {
keys := annotateKeys(rawKeys)
if len(keys) != 0 {
cfg.SetAttr("ssh_authorized_keys", keys)
} else {
cfg.UnsetAttr("ssh_authorized_keys")
}
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"SetSSHAuthorizedKeys",
"(",
"rawKeys",
"string",
")",
"{",
"keys",
":=",
"annotateKeys",
"(",
"rawKeys",
")",
"\n",
"if",
"len",
"(",
"keys",
")",
"!=",
"0",
"{",
"cfg",
".",
"SetAttr",
"(",
"\"",
"\"",
"... | // SetSSHAuthorizedKeys is defined on the SSHAuthorizedKeysConfig interface. | [
"SetSSHAuthorizedKeys",
"is",
"defined",
"on",
"the",
"SSHAuthorizedKeysConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L319-L326 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | SetSSHKeys | func (cfg *cloudConfig) SetSSHKeys(keys SSHKeys) {
if keys.RSA != nil {
cfg.SetAttr("ssh_keys", map[string]interface{}{
string(RSAPrivate): keys.RSA.Private,
string(RSAPublic): keys.RSA.Public,
})
} else {
cfg.UnsetAttr("ssh_keys")
}
} | go | func (cfg *cloudConfig) SetSSHKeys(keys SSHKeys) {
if keys.RSA != nil {
cfg.SetAttr("ssh_keys", map[string]interface{}{
string(RSAPrivate): keys.RSA.Private,
string(RSAPublic): keys.RSA.Public,
})
} else {
cfg.UnsetAttr("ssh_keys")
}
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"SetSSHKeys",
"(",
"keys",
"SSHKeys",
")",
"{",
"if",
"keys",
".",
"RSA",
"!=",
"nil",
"{",
"cfg",
".",
"SetAttr",
"(",
"\"",
"\"",
",",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"string",
... | // SetSSHKeys is defined on the SSHKeysConfig interface. | [
"SetSSHKeys",
"is",
"defined",
"on",
"the",
"SSHKeysConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L329-L338 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | DisableRoot | func (cfg *cloudConfig) DisableRoot() bool {
disable, _ := cfg.attrs["disable_root"].(bool)
return disable
} | go | func (cfg *cloudConfig) DisableRoot() bool {
disable, _ := cfg.attrs["disable_root"].(bool)
return disable
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"DisableRoot",
"(",
")",
"bool",
"{",
"disable",
",",
"_",
":=",
"cfg",
".",
"attrs",
"[",
"\"",
"\"",
"]",
".",
"(",
"bool",
")",
"\n",
"return",
"disable",
"\n",
"}"
] | // DisableRoot is defined on the RootUserConfig interface. | [
"DisableRoot",
"is",
"defined",
"on",
"the",
"RootUserConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L351-L354 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | AddRunTextFile | func (cfg *cloudConfig) AddRunTextFile(filename, contents string, perm uint) {
cfg.AddScripts(addFileCmds(filename, []byte(contents), perm, false)...)
} | go | func (cfg *cloudConfig) AddRunTextFile(filename, contents string, perm uint) {
cfg.AddScripts(addFileCmds(filename, []byte(contents), perm, false)...)
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"AddRunTextFile",
"(",
"filename",
",",
"contents",
"string",
",",
"perm",
"uint",
")",
"{",
"cfg",
".",
"AddScripts",
"(",
"addFileCmds",
"(",
"filename",
",",
"[",
"]",
"byte",
"(",
"contents",
")",
",",
"... | // AddRunTextFile is defined on the WrittenFilesConfig interface. | [
"AddRunTextFile",
"is",
"defined",
"on",
"the",
"WrittenFilesConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L366-L368 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | AddBootTextFile | func (cfg *cloudConfig) AddBootTextFile(filename, contents string, perm uint) {
for _, cmd := range addFileCmds(filename, []byte(contents), perm, false) {
cfg.AddBootCmd(cmd)
}
} | go | func (cfg *cloudConfig) AddBootTextFile(filename, contents string, perm uint) {
for _, cmd := range addFileCmds(filename, []byte(contents), perm, false) {
cfg.AddBootCmd(cmd)
}
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"AddBootTextFile",
"(",
"filename",
",",
"contents",
"string",
",",
"perm",
"uint",
")",
"{",
"for",
"_",
",",
"cmd",
":=",
"range",
"addFileCmds",
"(",
"filename",
",",
"[",
"]",
"byte",
"(",
"contents",
")... | // AddBootTextFile is defined on the WrittenFilesConfig interface. | [
"AddBootTextFile",
"is",
"defined",
"on",
"the",
"WrittenFilesConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L371-L375 | train |
juju/juju | cloudconfig/cloudinit/cloudinit.go | AddRunBinaryFile | func (cfg *cloudConfig) AddRunBinaryFile(filename string, data []byte, mode uint) {
cfg.AddScripts(addFileCmds(filename, data, mode, true)...)
} | go | func (cfg *cloudConfig) AddRunBinaryFile(filename string, data []byte, mode uint) {
cfg.AddScripts(addFileCmds(filename, data, mode, true)...)
} | [
"func",
"(",
"cfg",
"*",
"cloudConfig",
")",
"AddRunBinaryFile",
"(",
"filename",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"mode",
"uint",
")",
"{",
"cfg",
".",
"AddScripts",
"(",
"addFileCmds",
"(",
"filename",
",",
"data",
",",
"mode",
",",
"tru... | // AddRunBinaryFile is defined on the WrittenFilesConfig interface. | [
"AddRunBinaryFile",
"is",
"defined",
"on",
"the",
"WrittenFilesConfig",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit.go#L378-L380 | train |
juju/juju | storage/provider/rootfs.go | ensureDir | func ensureDir(d dirFuncs, path string) error {
// If path already exists, we check that it is empty.
// It is up to the storage provisioner to ensure that any
// shared storage constraints and attachments with the same
// path are validated etc. So the check here is more a sanity check.
fi, err := d.lstat(path)
if err == nil {
if !fi.IsDir() {
return errors.Errorf("path %q must be a directory", path)
}
return nil
}
if !os.IsNotExist(err) {
return errors.Trace(err)
}
if err := d.mkDirAll(path, 0755); err != nil {
return errors.Annotate(err, "could not create directory")
}
return nil
} | go | func ensureDir(d dirFuncs, path string) error {
// If path already exists, we check that it is empty.
// It is up to the storage provisioner to ensure that any
// shared storage constraints and attachments with the same
// path are validated etc. So the check here is more a sanity check.
fi, err := d.lstat(path)
if err == nil {
if !fi.IsDir() {
return errors.Errorf("path %q must be a directory", path)
}
return nil
}
if !os.IsNotExist(err) {
return errors.Trace(err)
}
if err := d.mkDirAll(path, 0755); err != nil {
return errors.Annotate(err, "could not create directory")
}
return nil
} | [
"func",
"ensureDir",
"(",
"d",
"dirFuncs",
",",
"path",
"string",
")",
"error",
"{",
"// If path already exists, we check that it is empty.",
"// It is up to the storage provisioner to ensure that any",
"// shared storage constraints and attachments with the same",
"// path are validated... | // ensureDir ensures the specified path is a directory, or
// if it does not exist, that a directory can be created there. | [
"ensureDir",
"ensures",
"the",
"specified",
"path",
"is",
"a",
"directory",
"or",
"if",
"it",
"does",
"not",
"exist",
"that",
"a",
"directory",
"can",
"be",
"created",
"there",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/provider/rootfs.go#L103-L122 | train |
juju/juju | storage/provider/rootfs.go | ensureEmptyDir | func ensureEmptyDir(d dirFuncs, path string) error {
fileCount, err := d.fileCount(path)
if err != nil {
return errors.Annotate(err, "could not read directory")
}
if fileCount > 0 {
return errors.Errorf("%q is not empty", path)
}
return nil
} | go | func ensureEmptyDir(d dirFuncs, path string) error {
fileCount, err := d.fileCount(path)
if err != nil {
return errors.Annotate(err, "could not read directory")
}
if fileCount > 0 {
return errors.Errorf("%q is not empty", path)
}
return nil
} | [
"func",
"ensureEmptyDir",
"(",
"d",
"dirFuncs",
",",
"path",
"string",
")",
"error",
"{",
"fileCount",
",",
"err",
":=",
"d",
".",
"fileCount",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Annotate",
"(",
"err",
",... | // ensureEmptyDir ensures the specified directory is empty. | [
"ensureEmptyDir",
"ensures",
"the",
"specified",
"directory",
"is",
"empty",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/provider/rootfs.go#L125-L134 | train |
juju/juju | storage/provider/rootfs.go | CreateFilesystems | func (s *rootfsFilesystemSource) CreateFilesystems(ctx context.ProviderCallContext, args []storage.FilesystemParams) ([]storage.CreateFilesystemsResult, error) {
results := make([]storage.CreateFilesystemsResult, len(args))
for i, arg := range args {
filesystem, err := s.createFilesystem(arg)
if err != nil {
results[i].Error = err
continue
}
results[i].Filesystem = filesystem
}
return results, nil
} | go | func (s *rootfsFilesystemSource) CreateFilesystems(ctx context.ProviderCallContext, args []storage.FilesystemParams) ([]storage.CreateFilesystemsResult, error) {
results := make([]storage.CreateFilesystemsResult, len(args))
for i, arg := range args {
filesystem, err := s.createFilesystem(arg)
if err != nil {
results[i].Error = err
continue
}
results[i].Filesystem = filesystem
}
return results, nil
} | [
"func",
"(",
"s",
"*",
"rootfsFilesystemSource",
")",
"CreateFilesystems",
"(",
"ctx",
"context",
".",
"ProviderCallContext",
",",
"args",
"[",
"]",
"storage",
".",
"FilesystemParams",
")",
"(",
"[",
"]",
"storage",
".",
"CreateFilesystemsResult",
",",
"error",
... | // CreateFilesystems is defined on the FilesystemSource interface. | [
"CreateFilesystems",
"is",
"defined",
"on",
"the",
"FilesystemSource",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/provider/rootfs.go#L147-L158 | train |
juju/juju | storage/provider/rootfs.go | AttachFilesystems | func (s *rootfsFilesystemSource) AttachFilesystems(ctx context.ProviderCallContext, args []storage.FilesystemAttachmentParams) ([]storage.AttachFilesystemsResult, error) {
results := make([]storage.AttachFilesystemsResult, len(args))
for i, arg := range args {
attachment, err := s.attachFilesystem(arg)
if err != nil {
results[i].Error = err
continue
}
results[i].FilesystemAttachment = attachment
}
return results, nil
} | go | func (s *rootfsFilesystemSource) AttachFilesystems(ctx context.ProviderCallContext, args []storage.FilesystemAttachmentParams) ([]storage.AttachFilesystemsResult, error) {
results := make([]storage.AttachFilesystemsResult, len(args))
for i, arg := range args {
attachment, err := s.attachFilesystem(arg)
if err != nil {
results[i].Error = err
continue
}
results[i].FilesystemAttachment = attachment
}
return results, nil
} | [
"func",
"(",
"s",
"*",
"rootfsFilesystemSource",
")",
"AttachFilesystems",
"(",
"ctx",
"context",
".",
"ProviderCallContext",
",",
"args",
"[",
"]",
"storage",
".",
"FilesystemAttachmentParams",
")",
"(",
"[",
"]",
"storage",
".",
"AttachFilesystemsResult",
",",
... | // AttachFilesystems is defined on the FilesystemSource interface. | [
"AttachFilesystems",
"is",
"defined",
"on",
"the",
"FilesystemSource",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/provider/rootfs.go#L203-L214 | train |
juju/juju | worker/meterstatus/context.go | NewLimitedContext | func NewLimitedContext(unitName string) *limitedContext {
// TODO(fwereade): 2016-03-17 lp:1558657
id := fmt.Sprintf("%s-%s-%d", unitName, "meter-status", rand.New(rand.NewSource(time.Now().Unix())).Int63())
return &limitedContext{unitName: unitName, id: id}
} | go | func NewLimitedContext(unitName string) *limitedContext {
// TODO(fwereade): 2016-03-17 lp:1558657
id := fmt.Sprintf("%s-%s-%d", unitName, "meter-status", rand.New(rand.NewSource(time.Now().Unix())).Int63())
return &limitedContext{unitName: unitName, id: id}
} | [
"func",
"NewLimitedContext",
"(",
"unitName",
"string",
")",
"*",
"limitedContext",
"{",
"// TODO(fwereade): 2016-03-17 lp:1558657",
"id",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"unitName",
",",
"\"",
"\"",
",",
"rand",
".",
"New",
"(",
"rand",
"... | // NewLimitedContext creates a new context that implements just the bare minimum
// of the hooks.Context interface. | [
"NewLimitedContext",
"creates",
"a",
"new",
"context",
"that",
"implements",
"just",
"the",
"bare",
"minimum",
"of",
"the",
"hooks",
".",
"Context",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/meterstatus/context.go#L28-L32 | train |
juju/juju | worker/meterstatus/context.go | SetEnvVars | func (ctx *limitedContext) SetEnvVars(vars map[string]string) {
if ctx.env == nil {
ctx.env = vars
return
}
for key, val := range vars {
ctx.env[key] = val
}
} | go | func (ctx *limitedContext) SetEnvVars(vars map[string]string) {
if ctx.env == nil {
ctx.env = vars
return
}
for key, val := range vars {
ctx.env[key] = val
}
} | [
"func",
"(",
"ctx",
"*",
"limitedContext",
")",
"SetEnvVars",
"(",
"vars",
"map",
"[",
"string",
"]",
"string",
")",
"{",
"if",
"ctx",
".",
"env",
"==",
"nil",
"{",
"ctx",
".",
"env",
"=",
"vars",
"\n",
"return",
"\n",
"}",
"\n",
"for",
"key",
",... | // SetEnvVars sets additional environment variables to be exported by the context. | [
"SetEnvVars",
"sets",
"additional",
"environment",
"variables",
"to",
"be",
"exported",
"by",
"the",
"context",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/meterstatus/context.go#L50-L58 | train |
juju/juju | cloud/clouds.go | Contains | func (a AuthTypes) Contains(t AuthType) bool {
for _, v := range a {
if v == t {
return true
}
}
return false
} | go | func (a AuthTypes) Contains(t AuthType) bool {
for _, v := range a {
if v == t {
return true
}
}
return false
} | [
"func",
"(",
"a",
"AuthTypes",
")",
"Contains",
"(",
"t",
"AuthType",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"a",
"{",
"if",
"v",
"==",
"t",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] | // Contains checks if AuthType t is in a AuthTypes. | [
"Contains",
"checks",
"if",
"AuthType",
"t",
"is",
"in",
"a",
"AuthTypes",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloud/clouds.go#L36-L43 | train |
juju/juju | cloud/clouds.go | RegionByName | func RegionByName(regions []Region, name string) (*Region, error) {
for _, region := range regions {
if !strings.EqualFold(region.Name, name) {
continue
}
return ®ion, nil
}
return nil, errors.NewNotFound(nil, fmt.Sprintf(
"region %q not found (expected one of %q)",
name, RegionNames(regions),
))
} | go | func RegionByName(regions []Region, name string) (*Region, error) {
for _, region := range regions {
if !strings.EqualFold(region.Name, name) {
continue
}
return ®ion, nil
}
return nil, errors.NewNotFound(nil, fmt.Sprintf(
"region %q not found (expected one of %q)",
name, RegionNames(regions),
))
} | [
"func",
"RegionByName",
"(",
"regions",
"[",
"]",
"Region",
",",
"name",
"string",
")",
"(",
"*",
"Region",
",",
"error",
")",
"{",
"for",
"_",
",",
"region",
":=",
"range",
"regions",
"{",
"if",
"!",
"strings",
".",
"EqualFold",
"(",
"region",
".",
... | // RegionByName finds the region in the given slice with the
// specified name, with case folding. | [
"RegionByName",
"finds",
"the",
"region",
"in",
"the",
"given",
"slice",
"with",
"the",
"specified",
"name",
"with",
"case",
"folding",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloud/clouds.go#L282-L293 | train |
juju/juju | cloud/clouds.go | RegionNames | func RegionNames(regions []Region) []string {
names := make([]string, len(regions))
for i, region := range regions {
names[i] = region.Name
}
sort.Strings(names)
return names
} | go | func RegionNames(regions []Region) []string {
names := make([]string, len(regions))
for i, region := range regions {
names[i] = region.Name
}
sort.Strings(names)
return names
} | [
"func",
"RegionNames",
"(",
"regions",
"[",
"]",
"Region",
")",
"[",
"]",
"string",
"{",
"names",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"regions",
")",
")",
"\n",
"for",
"i",
",",
"region",
":=",
"range",
"regions",
"{",
"names",
... | // RegionNames returns a sorted list of the names of the given regions. | [
"RegionNames",
"returns",
"a",
"sorted",
"list",
"of",
"the",
"names",
"of",
"the",
"given",
"regions",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloud/clouds.go#L296-L303 | train |
juju/juju | cloud/clouds.go | PublicCloudMetadata | func PublicCloudMetadata(searchPath ...string) (result map[string]Cloud, fallbackUsed bool, err error) {
for _, file := range searchPath {
data, err := ioutil.ReadFile(file)
if err != nil && os.IsNotExist(err) {
continue
}
if err != nil {
return nil, false, errors.Trace(err)
}
clouds, err := ParseCloudMetadata(data)
if err != nil {
return nil, false, errors.Trace(err)
}
return clouds, false, err
}
clouds, err := ParseCloudMetadata([]byte(fallbackPublicCloudInfo))
return clouds, true, err
} | go | func PublicCloudMetadata(searchPath ...string) (result map[string]Cloud, fallbackUsed bool, err error) {
for _, file := range searchPath {
data, err := ioutil.ReadFile(file)
if err != nil && os.IsNotExist(err) {
continue
}
if err != nil {
return nil, false, errors.Trace(err)
}
clouds, err := ParseCloudMetadata(data)
if err != nil {
return nil, false, errors.Trace(err)
}
return clouds, false, err
}
clouds, err := ParseCloudMetadata([]byte(fallbackPublicCloudInfo))
return clouds, true, err
} | [
"func",
"PublicCloudMetadata",
"(",
"searchPath",
"...",
"string",
")",
"(",
"result",
"map",
"[",
"string",
"]",
"Cloud",
",",
"fallbackUsed",
"bool",
",",
"err",
"error",
")",
"{",
"for",
"_",
",",
"file",
":=",
"range",
"searchPath",
"{",
"data",
",",... | // PublicCloudMetadata looks in searchPath for cloud metadata files and if none
// are found, returns the fallback public cloud metadata. | [
"PublicCloudMetadata",
"looks",
"in",
"searchPath",
"for",
"cloud",
"metadata",
"files",
"and",
"if",
"none",
"are",
"found",
"returns",
"the",
"fallback",
"public",
"cloud",
"metadata",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloud/clouds.go#L313-L330 | train |
juju/juju | cloud/clouds.go | ParseOneCloud | func ParseOneCloud(data []byte) (Cloud, error) {
c := &cloud{}
if err := yaml.Unmarshal(data, &c); err != nil {
return Cloud{}, errors.Annotate(err, "cannot unmarshal yaml cloud metadata")
}
return cloudFromInternal(c), nil
} | go | func ParseOneCloud(data []byte) (Cloud, error) {
c := &cloud{}
if err := yaml.Unmarshal(data, &c); err != nil {
return Cloud{}, errors.Annotate(err, "cannot unmarshal yaml cloud metadata")
}
return cloudFromInternal(c), nil
} | [
"func",
"ParseOneCloud",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"Cloud",
",",
"error",
")",
"{",
"c",
":=",
"&",
"cloud",
"{",
"}",
"\n",
"if",
"err",
":=",
"yaml",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"c",
")",
";",
"err",
"!=",
"nil",
... | // ParseOneCloud parses the given yaml bytes into a single Cloud metadata. | [
"ParseOneCloud",
"parses",
"the",
"given",
"yaml",
"bytes",
"into",
"a",
"single",
"Cloud",
"metadata",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloud/clouds.go#L333-L339 | train |
juju/juju | cloud/clouds.go | ParseCloudMetadata | func ParseCloudMetadata(data []byte) (map[string]Cloud, error) {
var metadata cloudSet
if err := yaml.Unmarshal(data, &metadata); err != nil {
return nil, errors.Annotate(err, "cannot unmarshal yaml cloud metadata")
}
// Translate to the exported type. For each cloud, we store
// the first region for the cloud as its default region.
clouds := make(map[string]Cloud)
for name, cloud := range metadata.Clouds {
details := cloudFromInternal(cloud)
details.Name = name
if details.Description == "" {
var ok bool
if details.Description, ok = defaultCloudDescription[name]; !ok {
details.Description = defaultCloudDescription[cloud.Type]
}
}
clouds[name] = details
}
return clouds, nil
} | go | func ParseCloudMetadata(data []byte) (map[string]Cloud, error) {
var metadata cloudSet
if err := yaml.Unmarshal(data, &metadata); err != nil {
return nil, errors.Annotate(err, "cannot unmarshal yaml cloud metadata")
}
// Translate to the exported type. For each cloud, we store
// the first region for the cloud as its default region.
clouds := make(map[string]Cloud)
for name, cloud := range metadata.Clouds {
details := cloudFromInternal(cloud)
details.Name = name
if details.Description == "" {
var ok bool
if details.Description, ok = defaultCloudDescription[name]; !ok {
details.Description = defaultCloudDescription[cloud.Type]
}
}
clouds[name] = details
}
return clouds, nil
} | [
"func",
"ParseCloudMetadata",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"map",
"[",
"string",
"]",
"Cloud",
",",
"error",
")",
"{",
"var",
"metadata",
"cloudSet",
"\n",
"if",
"err",
":=",
"yaml",
".",
"Unmarshal",
"(",
"data",
",",
"&",
"metadata",
")... | // ParseCloudMetadata parses the given yaml bytes into Clouds metadata. | [
"ParseCloudMetadata",
"parses",
"the",
"given",
"yaml",
"bytes",
"into",
"Clouds",
"metadata",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloud/clouds.go#L342-L363 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.