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/controller/remoterelations/remoterelations.go | SetRemoteApplicationsStatus | func (f *RemoteRelationsAPI) SetRemoteApplicationsStatus(args params.SetStatus) (params.ErrorResults, error) {
var result params.ErrorResults
result.Results = make([]params.ErrorResult, len(args.Entities))
for i, entity := range args.Entities {
remoteAppTag, err := names.ParseApplicationTag(entity.Tag)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
app, err := f.st.RemoteApplication(remoteAppTag.Id())
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
err = app.SetStatus(status.StatusInfo{
Status: status.Status(entity.Status),
Message: entity.Info,
})
result.Results[i].Error = common.ServerError(err)
}
return result, nil
} | go | func (f *RemoteRelationsAPI) SetRemoteApplicationsStatus(args params.SetStatus) (params.ErrorResults, error) {
var result params.ErrorResults
result.Results = make([]params.ErrorResult, len(args.Entities))
for i, entity := range args.Entities {
remoteAppTag, err := names.ParseApplicationTag(entity.Tag)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
app, err := f.st.RemoteApplication(remoteAppTag.Id())
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
err = app.SetStatus(status.StatusInfo{
Status: status.Status(entity.Status),
Message: entity.Info,
})
result.Results[i].Error = common.ServerError(err)
}
return result, nil
} | [
"func",
"(",
"f",
"*",
"RemoteRelationsAPI",
")",
"SetRemoteApplicationsStatus",
"(",
"args",
"params",
".",
"SetStatus",
")",
"(",
"params",
".",
"ErrorResults",
",",
"error",
")",
"{",
"var",
"result",
"params",
".",
"ErrorResults",
"\n",
"result",
".",
"R... | // SetRemoteApplicationsStatus sets the status for the specified remote applications. | [
"SetRemoteApplicationsStatus",
"sets",
"the",
"status",
"for",
"the",
"specified",
"remote",
"applications",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/controller/remoterelations/remoterelations.go#L400-L421 | train |
juju/juju | cloudconfig/cloudinit/cloudinit_centos.go | addPackageMirrorCmd | func addPackageMirrorCmd(cfg CloudConfig, url string) string {
return fmt.Sprintf(config.ReplaceCentOSMirror, url)
} | go | func addPackageMirrorCmd(cfg CloudConfig, url string) string {
return fmt.Sprintf(config.ReplaceCentOSMirror, url)
} | [
"func",
"addPackageMirrorCmd",
"(",
"cfg",
"CloudConfig",
",",
"url",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"config",
".",
"ReplaceCentOSMirror",
",",
"url",
")",
"\n",
"}"
] | // addPackageMirrorCmd is a helper function that returns the corresponding runcmds
// to apply the package mirror settings on a CentOS machine. | [
"addPackageMirrorCmd",
"is",
"a",
"helper",
"function",
"that",
"returns",
"the",
"corresponding",
"runcmds",
"to",
"apply",
"the",
"package",
"mirror",
"settings",
"on",
"a",
"CentOS",
"machine",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit_centos.go#L82-L84 | train |
juju/juju | cloudconfig/cloudinit/cloudinit_centos.go | RenderYAML | func (cfg *centOSCloudConfig) RenderYAML() ([]byte, error) {
// Save the fields that we will modify
var oldruncmds []string
oldruncmds = copyStringSlice(cfg.RunCmds())
// check for package proxy setting and add commands:
var proxy string
if proxy = cfg.PackageProxy(); proxy != "" {
cfg.AddRunCmd(cfg.helper.addPackageProxyCmd(proxy))
cfg.UnsetPackageProxy()
}
// check for package mirror settings and add commands:
var mirror string
if mirror = cfg.PackageMirror(); mirror != "" {
cfg.AddRunCmd(addPackageMirrorCmd(cfg, mirror))
cfg.UnsetPackageMirror()
}
// add appropriate commands for package sources configuration:
srcs := cfg.PackageSources()
for _, src := range srcs {
cfg.AddScripts(addPackageSourceCmds(cfg, src)...)
}
cfg.UnsetAttr("package_sources")
data, err := yaml.Marshal(cfg.attrs)
if err != nil {
return nil, err
}
// Restore the modified fields
cfg.SetPackageProxy(proxy)
cfg.SetPackageMirror(mirror)
cfg.SetAttr("package_sources", srcs)
if oldruncmds != nil {
cfg.SetAttr("runcmd", oldruncmds)
} else {
cfg.UnsetAttr("runcmd")
}
return append([]byte("#cloud-config\n"), data...), nil
} | go | func (cfg *centOSCloudConfig) RenderYAML() ([]byte, error) {
// Save the fields that we will modify
var oldruncmds []string
oldruncmds = copyStringSlice(cfg.RunCmds())
// check for package proxy setting and add commands:
var proxy string
if proxy = cfg.PackageProxy(); proxy != "" {
cfg.AddRunCmd(cfg.helper.addPackageProxyCmd(proxy))
cfg.UnsetPackageProxy()
}
// check for package mirror settings and add commands:
var mirror string
if mirror = cfg.PackageMirror(); mirror != "" {
cfg.AddRunCmd(addPackageMirrorCmd(cfg, mirror))
cfg.UnsetPackageMirror()
}
// add appropriate commands for package sources configuration:
srcs := cfg.PackageSources()
for _, src := range srcs {
cfg.AddScripts(addPackageSourceCmds(cfg, src)...)
}
cfg.UnsetAttr("package_sources")
data, err := yaml.Marshal(cfg.attrs)
if err != nil {
return nil, err
}
// Restore the modified fields
cfg.SetPackageProxy(proxy)
cfg.SetPackageMirror(mirror)
cfg.SetAttr("package_sources", srcs)
if oldruncmds != nil {
cfg.SetAttr("runcmd", oldruncmds)
} else {
cfg.UnsetAttr("runcmd")
}
return append([]byte("#cloud-config\n"), data...), nil
} | [
"func",
"(",
"cfg",
"*",
"centOSCloudConfig",
")",
"RenderYAML",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Save the fields that we will modify",
"var",
"oldruncmds",
"[",
"]",
"string",
"\n",
"oldruncmds",
"=",
"copyStringSlice",
"(",
"cfg",... | // Render is defined on the the Renderer interface. | [
"Render",
"is",
"defined",
"on",
"the",
"the",
"Renderer",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cloudconfig/cloudinit/cloudinit_centos.go#L121-L163 | train |
juju/juju | provider/common/availabilityzones.go | AvailabilityZoneAllocations | func AvailabilityZoneAllocations(
env ZonedEnviron, ctx context.ProviderCallContext, group []instance.Id,
) ([]AvailabilityZoneInstances, error) {
if len(group) == 0 {
instances, err := env.AllInstances(ctx)
if err != nil {
return nil, err
}
group = make([]instance.Id, len(instances))
for i, inst := range instances {
group[i] = inst.Id()
}
}
instanceZones, err := env.InstanceAvailabilityZoneNames(ctx, group)
switch err {
case nil, environs.ErrPartialInstances:
case environs.ErrNoInstances:
group = nil
default:
return nil, err
}
// Get the list of all "available" availability zones,
// and then initialise a tally for each one.
zones, err := env.AvailabilityZones(ctx)
if err != nil {
return nil, err
}
instancesByZoneName := make(map[string][]instance.Id)
for _, zone := range zones {
if !zone.Available() {
continue
}
name := zone.Name()
instancesByZoneName[name] = nil
}
if len(instancesByZoneName) == 0 {
return nil, nil
}
for i, id := range group {
zone := instanceZones[i]
if zone == "" {
continue
}
if _, ok := instancesByZoneName[zone]; !ok {
// zone is not available
continue
}
instancesByZoneName[zone] = append(instancesByZoneName[zone], id)
}
zoneInstances := make([]AvailabilityZoneInstances, 0, len(instancesByZoneName))
for zoneName, instances := range instancesByZoneName {
zoneInstances = append(zoneInstances, AvailabilityZoneInstances{
ZoneName: zoneName,
Instances: instances,
})
}
sort.Sort(byPopulationThenName(zoneInstances))
return zoneInstances, nil
} | go | func AvailabilityZoneAllocations(
env ZonedEnviron, ctx context.ProviderCallContext, group []instance.Id,
) ([]AvailabilityZoneInstances, error) {
if len(group) == 0 {
instances, err := env.AllInstances(ctx)
if err != nil {
return nil, err
}
group = make([]instance.Id, len(instances))
for i, inst := range instances {
group[i] = inst.Id()
}
}
instanceZones, err := env.InstanceAvailabilityZoneNames(ctx, group)
switch err {
case nil, environs.ErrPartialInstances:
case environs.ErrNoInstances:
group = nil
default:
return nil, err
}
// Get the list of all "available" availability zones,
// and then initialise a tally for each one.
zones, err := env.AvailabilityZones(ctx)
if err != nil {
return nil, err
}
instancesByZoneName := make(map[string][]instance.Id)
for _, zone := range zones {
if !zone.Available() {
continue
}
name := zone.Name()
instancesByZoneName[name] = nil
}
if len(instancesByZoneName) == 0 {
return nil, nil
}
for i, id := range group {
zone := instanceZones[i]
if zone == "" {
continue
}
if _, ok := instancesByZoneName[zone]; !ok {
// zone is not available
continue
}
instancesByZoneName[zone] = append(instancesByZoneName[zone], id)
}
zoneInstances := make([]AvailabilityZoneInstances, 0, len(instancesByZoneName))
for zoneName, instances := range instancesByZoneName {
zoneInstances = append(zoneInstances, AvailabilityZoneInstances{
ZoneName: zoneName,
Instances: instances,
})
}
sort.Sort(byPopulationThenName(zoneInstances))
return zoneInstances, nil
} | [
"func",
"AvailabilityZoneAllocations",
"(",
"env",
"ZonedEnviron",
",",
"ctx",
"context",
".",
"ProviderCallContext",
",",
"group",
"[",
"]",
"instance",
".",
"Id",
",",
")",
"(",
"[",
"]",
"AvailabilityZoneInstances",
",",
"error",
")",
"{",
"if",
"len",
"(... | // AvailabilityZoneAllocations returns the availability zones and their
// instance allocations from the specified group, in ascending order of
// population. Availability zones with the same population size are
// ordered by name.
//
// If the specified group is empty, then it will behave as if the result of
// AllInstances were provided. | [
"AvailabilityZoneAllocations",
"returns",
"the",
"availability",
"zones",
"and",
"their",
"instance",
"allocations",
"from",
"the",
"specified",
"group",
"in",
"ascending",
"order",
"of",
"population",
".",
"Availability",
"zones",
"with",
"the",
"same",
"population",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/availabilityzones.go#L88-L149 | train |
juju/juju | provider/common/availabilityzones.go | ValidateAvailabilityZone | func ValidateAvailabilityZone(env ZonedEnviron, ctx context.ProviderCallContext, zone string) error {
zones, err := env.AvailabilityZones(ctx)
if err != nil {
return err
}
for _, z := range zones {
if z.Name() == zone {
if z.Available() {
return nil
}
return errors.Errorf("availability zone %q is unavailable", zone)
}
}
return errors.NotValidf("availability zone %q", zone)
} | go | func ValidateAvailabilityZone(env ZonedEnviron, ctx context.ProviderCallContext, zone string) error {
zones, err := env.AvailabilityZones(ctx)
if err != nil {
return err
}
for _, z := range zones {
if z.Name() == zone {
if z.Available() {
return nil
}
return errors.Errorf("availability zone %q is unavailable", zone)
}
}
return errors.NotValidf("availability zone %q", zone)
} | [
"func",
"ValidateAvailabilityZone",
"(",
"env",
"ZonedEnviron",
",",
"ctx",
"context",
".",
"ProviderCallContext",
",",
"zone",
"string",
")",
"error",
"{",
"zones",
",",
"err",
":=",
"env",
".",
"AvailabilityZones",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",... | // ValidateAvailabilityZone returns nil iff the availability
// zone exists and is available, otherwise returns a NotValid
// error. | [
"ValidateAvailabilityZone",
"returns",
"nil",
"iff",
"the",
"availability",
"zone",
"exists",
"and",
"is",
"available",
"otherwise",
"returns",
"a",
"NotValid",
"error",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/common/availabilityzones.go#L210-L224 | train |
juju/juju | core/instance/namespace.go | NewNamespace | func NewNamespace(modelUUID string) (Namespace, error) {
if !names.IsValidModel(modelUUID) {
return nil, errors.Errorf("model ID %q is not a valid model", modelUUID)
}
// The suffix is the last six hex digits of the model uuid.
suffix := modelUUID[len(modelUUID)-uuidSuffixDigits:]
return &namespace{name: suffix}, nil
} | go | func NewNamespace(modelUUID string) (Namespace, error) {
if !names.IsValidModel(modelUUID) {
return nil, errors.Errorf("model ID %q is not a valid model", modelUUID)
}
// The suffix is the last six hex digits of the model uuid.
suffix := modelUUID[len(modelUUID)-uuidSuffixDigits:]
return &namespace{name: suffix}, nil
} | [
"func",
"NewNamespace",
"(",
"modelUUID",
"string",
")",
"(",
"Namespace",
",",
"error",
")",
"{",
"if",
"!",
"names",
".",
"IsValidModel",
"(",
"modelUUID",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"modelUUID",
")... | // NewNamespace returns a Namespace identified by the last six hex digits of the
// model UUID. NewNamespace returns an error if the model tag is invalid. | [
"NewNamespace",
"returns",
"a",
"Namespace",
"identified",
"by",
"the",
"last",
"six",
"hex",
"digits",
"of",
"the",
"model",
"UUID",
".",
"NewNamespace",
"returns",
"an",
"error",
"if",
"the",
"model",
"tag",
"is",
"invalid",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/instance/namespace.go#L41-L49 | train |
juju/juju | cmd/modelcmd/base.go | IsModelMigratedError | func IsModelMigratedError(err error) bool {
_, ok := errors.Cause(err).(modelMigratedError)
return ok
} | go | func IsModelMigratedError(err error) bool {
_, ok := errors.Cause(err).(modelMigratedError)
return ok
} | [
"func",
"IsModelMigratedError",
"(",
"err",
"error",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"errors",
".",
"Cause",
"(",
"err",
")",
".",
"(",
"modelMigratedError",
")",
"\n",
"return",
"ok",
"\n",
"}"
] | // IsModelMigratedError returns true if err is of type modelMigratedError. | [
"IsModelMigratedError",
"returns",
"true",
"if",
"err",
"is",
"of",
"type",
"modelMigratedError",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L44-L47 | train |
juju/juju | cmd/modelcmd/base.go | closeAPIContexts | func (c *CommandBase) closeAPIContexts() {
for name, ctx := range c.apiContexts {
if err := ctx.Close(); err != nil {
logger.Errorf("%v", err)
}
delete(c.apiContexts, name)
}
} | go | func (c *CommandBase) closeAPIContexts() {
for name, ctx := range c.apiContexts {
if err := ctx.Close(); err != nil {
logger.Errorf("%v", err)
}
delete(c.apiContexts, name)
}
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"closeAPIContexts",
"(",
")",
"{",
"for",
"name",
",",
"ctx",
":=",
"range",
"c",
".",
"apiContexts",
"{",
"if",
"err",
":=",
"ctx",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"logger",
".",
"... | // closeAPIContexts closes any API contexts that have
// been created. | [
"closeAPIContexts",
"closes",
"any",
"API",
"contexts",
"that",
"have",
"been",
"created",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L100-L107 | train |
juju/juju | cmd/modelcmd/base.go | SetModelRefresh | func (c *CommandBase) SetModelRefresh(refresh func(jujuclient.ClientStore, string) error) {
c.refreshModels = refresh
} | go | func (c *CommandBase) SetModelRefresh(refresh func(jujuclient.ClientStore, string) error) {
c.refreshModels = refresh
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"SetModelRefresh",
"(",
"refresh",
"func",
"(",
"jujuclient",
".",
"ClientStore",
",",
"string",
")",
"error",
")",
"{",
"c",
".",
"refreshModels",
"=",
"refresh",
"\n",
"}"
] | // SetModelRefresh sets the function used for refreshing models. | [
"SetModelRefresh",
"sets",
"the",
"function",
"used",
"for",
"refreshing",
"models",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L125-L127 | train |
juju/juju | cmd/modelcmd/base.go | NewAPIRoot | func (c *CommandBase) NewAPIRoot(
store jujuclient.ClientStore,
controllerName, modelName string,
) (api.Connection, error) {
c.assertRunStarted()
accountDetails, err := store.AccountDetails(controllerName)
if err != nil && !errors.IsNotFound(err) {
return nil, errors.Trace(err)
}
// If there are no account details or there's no logged-in
// user or the user is external, then trigger macaroon authentication
// by using an empty AccountDetails.
if accountDetails == nil || accountDetails.User == "" {
accountDetails = &jujuclient.AccountDetails{}
} else {
u := names.NewUserTag(accountDetails.User)
if !u.IsLocal() {
accountDetails = &jujuclient.AccountDetails{}
}
}
param, err := c.NewAPIConnectionParams(
store, controllerName, modelName, accountDetails,
)
if err != nil {
return nil, errors.Trace(err)
}
conn, err := juju.NewAPIConnection(param)
if modelName != "" && params.ErrCode(err) == params.CodeModelNotFound {
return nil, c.missingModelError(store, controllerName, modelName)
}
if redirErr, ok := errors.Cause(err).(*api.RedirectError); ok {
return nil, c.modelMigratedError(store, modelName, redirErr)
}
return conn, err
} | go | func (c *CommandBase) NewAPIRoot(
store jujuclient.ClientStore,
controllerName, modelName string,
) (api.Connection, error) {
c.assertRunStarted()
accountDetails, err := store.AccountDetails(controllerName)
if err != nil && !errors.IsNotFound(err) {
return nil, errors.Trace(err)
}
// If there are no account details or there's no logged-in
// user or the user is external, then trigger macaroon authentication
// by using an empty AccountDetails.
if accountDetails == nil || accountDetails.User == "" {
accountDetails = &jujuclient.AccountDetails{}
} else {
u := names.NewUserTag(accountDetails.User)
if !u.IsLocal() {
accountDetails = &jujuclient.AccountDetails{}
}
}
param, err := c.NewAPIConnectionParams(
store, controllerName, modelName, accountDetails,
)
if err != nil {
return nil, errors.Trace(err)
}
conn, err := juju.NewAPIConnection(param)
if modelName != "" && params.ErrCode(err) == params.CodeModelNotFound {
return nil, c.missingModelError(store, controllerName, modelName)
}
if redirErr, ok := errors.Cause(err).(*api.RedirectError); ok {
return nil, c.modelMigratedError(store, modelName, redirErr)
}
return conn, err
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"NewAPIRoot",
"(",
"store",
"jujuclient",
".",
"ClientStore",
",",
"controllerName",
",",
"modelName",
"string",
",",
")",
"(",
"api",
".",
"Connection",
",",
"error",
")",
"{",
"c",
".",
"assertRunStarted",
"(",
... | // NewAPIRoot returns a new connection to the API server for the given
// model or controller. | [
"NewAPIRoot",
"returns",
"a",
"new",
"connection",
"to",
"the",
"API",
"server",
"for",
"the",
"given",
"model",
"or",
"controller",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L144-L179 | train |
juju/juju | cmd/modelcmd/base.go | NewAPIConnectionParams | func (c *CommandBase) NewAPIConnectionParams(
store jujuclient.ClientStore,
controllerName, modelName string,
accountDetails *jujuclient.AccountDetails,
) (juju.NewAPIConnectionParams, error) {
c.assertRunStarted()
bakeryClient, err := c.BakeryClient(store, controllerName)
if err != nil {
return juju.NewAPIConnectionParams{}, errors.Trace(err)
}
var getPassword func(username string) (string, error)
if c.cmdContext != nil {
getPassword = func(username string) (string, error) {
fmt.Fprintf(c.cmdContext.Stderr, "please enter password for %s on %s: ", username, controllerName)
defer fmt.Fprintln(c.cmdContext.Stderr)
return readPassword(c.cmdContext.Stdin)
}
} else {
getPassword = func(username string) (string, error) {
return "", errors.New("no context to prompt for password")
}
}
return newAPIConnectionParams(
store, controllerName, modelName,
accountDetails,
bakeryClient,
c.apiOpen,
getPassword,
)
} | go | func (c *CommandBase) NewAPIConnectionParams(
store jujuclient.ClientStore,
controllerName, modelName string,
accountDetails *jujuclient.AccountDetails,
) (juju.NewAPIConnectionParams, error) {
c.assertRunStarted()
bakeryClient, err := c.BakeryClient(store, controllerName)
if err != nil {
return juju.NewAPIConnectionParams{}, errors.Trace(err)
}
var getPassword func(username string) (string, error)
if c.cmdContext != nil {
getPassword = func(username string) (string, error) {
fmt.Fprintf(c.cmdContext.Stderr, "please enter password for %s on %s: ", username, controllerName)
defer fmt.Fprintln(c.cmdContext.Stderr)
return readPassword(c.cmdContext.Stdin)
}
} else {
getPassword = func(username string) (string, error) {
return "", errors.New("no context to prompt for password")
}
}
return newAPIConnectionParams(
store, controllerName, modelName,
accountDetails,
bakeryClient,
c.apiOpen,
getPassword,
)
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"NewAPIConnectionParams",
"(",
"store",
"jujuclient",
".",
"ClientStore",
",",
"controllerName",
",",
"modelName",
"string",
",",
"accountDetails",
"*",
"jujuclient",
".",
"AccountDetails",
",",
")",
"(",
"juju",
".",
... | // NewAPIConnectionParams returns a juju.NewAPIConnectionParams with the
// given arguments such that a call to juju.NewAPIConnection with the
// result behaves the same as a call to CommandBase.NewAPIRoot with
// the same arguments. | [
"NewAPIConnectionParams",
"returns",
"a",
"juju",
".",
"NewAPIConnectionParams",
"with",
"the",
"given",
"arguments",
"such",
"that",
"a",
"call",
"to",
"juju",
".",
"NewAPIConnection",
"with",
"the",
"result",
"behaves",
"the",
"same",
"as",
"a",
"call",
"to",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L254-L284 | train |
juju/juju | cmd/modelcmd/base.go | HTTPClient | func (c *CommandBase) HTTPClient(store jujuclient.ClientStore, controllerName string) (*http.Client, error) {
c.assertRunStarted()
bakeryClient, err := c.BakeryClient(store, controllerName)
if err != nil {
return nil, errors.Trace(err)
}
return bakeryClient.Client, nil
} | go | func (c *CommandBase) HTTPClient(store jujuclient.ClientStore, controllerName string) (*http.Client, error) {
c.assertRunStarted()
bakeryClient, err := c.BakeryClient(store, controllerName)
if err != nil {
return nil, errors.Trace(err)
}
return bakeryClient.Client, nil
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"HTTPClient",
"(",
"store",
"jujuclient",
".",
"ClientStore",
",",
"controllerName",
"string",
")",
"(",
"*",
"http",
".",
"Client",
",",
"error",
")",
"{",
"c",
".",
"assertRunStarted",
"(",
")",
"\n",
"bakeryC... | // HTTPClient returns an http.Client that contains the loaded
// persistent cookie jar. Note that this client is not good for
// connecting to the Juju API itself because it does not
// have the correct TLS setup - use api.Connection.HTTPClient
// for that. | [
"HTTPClient",
"returns",
"an",
"http",
".",
"Client",
"that",
"contains",
"the",
"loaded",
"persistent",
"cookie",
"jar",
".",
"Note",
"that",
"this",
"client",
"is",
"not",
"good",
"for",
"connecting",
"to",
"the",
"Juju",
"API",
"itself",
"because",
"it",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L291-L298 | train |
juju/juju | cmd/modelcmd/base.go | BakeryClient | func (c *CommandBase) BakeryClient(store jujuclient.CookieStore, controllerName string) (*httpbakery.Client, error) {
c.assertRunStarted()
ctx, err := c.getAPIContext(store, controllerName)
if err != nil {
return nil, errors.Trace(err)
}
return ctx.NewBakeryClient(), nil
} | go | func (c *CommandBase) BakeryClient(store jujuclient.CookieStore, controllerName string) (*httpbakery.Client, error) {
c.assertRunStarted()
ctx, err := c.getAPIContext(store, controllerName)
if err != nil {
return nil, errors.Trace(err)
}
return ctx.NewBakeryClient(), nil
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"BakeryClient",
"(",
"store",
"jujuclient",
".",
"CookieStore",
",",
"controllerName",
"string",
")",
"(",
"*",
"httpbakery",
".",
"Client",
",",
"error",
")",
"{",
"c",
".",
"assertRunStarted",
"(",
")",
"\n",
... | // BakeryClient returns a macaroon bakery client that
// uses the same HTTP client returned by HTTPClient. | [
"BakeryClient",
"returns",
"a",
"macaroon",
"bakery",
"client",
"that",
"uses",
"the",
"same",
"HTTP",
"client",
"returned",
"by",
"HTTPClient",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L302-L309 | train |
juju/juju | cmd/modelcmd/base.go | APIOpen | func (c *CommandBase) APIOpen(info *api.Info, opts api.DialOpts) (api.Connection, error) {
c.assertRunStarted()
return c.apiOpen(info, opts)
} | go | func (c *CommandBase) APIOpen(info *api.Info, opts api.DialOpts) (api.Connection, error) {
c.assertRunStarted()
return c.apiOpen(info, opts)
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"APIOpen",
"(",
"info",
"*",
"api",
".",
"Info",
",",
"opts",
"api",
".",
"DialOpts",
")",
"(",
"api",
".",
"Connection",
",",
"error",
")",
"{",
"c",
".",
"assertRunStarted",
"(",
")",
"\n",
"return",
"c"... | // APIOpen establishes a connection to the API server using the
// the given api.Info and api.DialOpts, and associating any stored
// authorization tokens with the given controller name. | [
"APIOpen",
"establishes",
"a",
"connection",
"to",
"the",
"API",
"server",
"using",
"the",
"the",
"given",
"api",
".",
"Info",
"and",
"api",
".",
"DialOpts",
"and",
"associating",
"any",
"stored",
"authorization",
"tokens",
"with",
"the",
"given",
"controller"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L314-L317 | train |
juju/juju | cmd/modelcmd/base.go | apiOpen | func (c *CommandBase) apiOpen(info *api.Info, opts api.DialOpts) (api.Connection, error) {
if c.apiOpenFunc != nil {
return c.apiOpenFunc(info, opts)
}
return api.Open(info, opts)
} | go | func (c *CommandBase) apiOpen(info *api.Info, opts api.DialOpts) (api.Connection, error) {
if c.apiOpenFunc != nil {
return c.apiOpenFunc(info, opts)
}
return api.Open(info, opts)
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"apiOpen",
"(",
"info",
"*",
"api",
".",
"Info",
",",
"opts",
"api",
".",
"DialOpts",
")",
"(",
"api",
".",
"Connection",
",",
"error",
")",
"{",
"if",
"c",
".",
"apiOpenFunc",
"!=",
"nil",
"{",
"return",
... | // apiOpen establishes a connection to the API server using the
// the give api.Info and api.DialOpts. | [
"apiOpen",
"establishes",
"a",
"connection",
"to",
"the",
"API",
"server",
"using",
"the",
"the",
"give",
"api",
".",
"Info",
"and",
"api",
".",
"DialOpts",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L321-L326 | train |
juju/juju | cmd/modelcmd/base.go | RefreshModels | func (c *CommandBase) RefreshModels(store jujuclient.ClientStore, controllerName string) error {
if c.refreshModels == nil {
return c.doRefreshModels(store, controllerName)
}
return c.refreshModels(store, controllerName)
} | go | func (c *CommandBase) RefreshModels(store jujuclient.ClientStore, controllerName string) error {
if c.refreshModels == nil {
return c.doRefreshModels(store, controllerName)
}
return c.refreshModels(store, controllerName)
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"RefreshModels",
"(",
"store",
"jujuclient",
".",
"ClientStore",
",",
"controllerName",
"string",
")",
"error",
"{",
"if",
"c",
".",
"refreshModels",
"==",
"nil",
"{",
"return",
"c",
".",
"doRefreshModels",
"(",
"... | // RefreshModels refreshes the local models cache for the current user
// on the specified controller. | [
"RefreshModels",
"refreshes",
"the",
"local",
"models",
"cache",
"for",
"the",
"current",
"user",
"on",
"the",
"specified",
"controller",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L330-L335 | train |
juju/juju | cmd/modelcmd/base.go | ControllerUUID | func (c *CommandBase) ControllerUUID(store jujuclient.ClientStore, controllerName string) (string, error) {
ctrl, err := store.ControllerByName(controllerName)
if err != nil {
return "", errors.Annotate(err, "resolving controller name")
}
return ctrl.ControllerUUID, nil
} | go | func (c *CommandBase) ControllerUUID(store jujuclient.ClientStore, controllerName string) (string, error) {
ctrl, err := store.ControllerByName(controllerName)
if err != nil {
return "", errors.Annotate(err, "resolving controller name")
}
return ctrl.ControllerUUID, nil
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"ControllerUUID",
"(",
"store",
"jujuclient",
".",
"ClientStore",
",",
"controllerName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"ctrl",
",",
"err",
":=",
"store",
".",
"ControllerByName",
"(",
"cont... | // ControllerUUID returns the controller UUID for specified controller name. | [
"ControllerUUID",
"returns",
"the",
"controller",
"UUID",
"for",
"specified",
"controller",
"name",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L396-L402 | train |
juju/juju | cmd/modelcmd/base.go | getAPIContext | func (c *CommandBase) getAPIContext(store jujuclient.CookieStore, controllerName string) (*apiContext, error) {
c.assertRunStarted()
if ctx := c.apiContexts[controllerName]; ctx != nil {
return ctx, nil
}
if controllerName == "" {
return nil, errors.New("cannot get API context from empty controller name")
}
ctx, err := newAPIContext(c.cmdContext, &c.authOpts, store, controllerName)
if err != nil {
return nil, errors.Trace(err)
}
c.apiContexts[controllerName] = ctx
return ctx, nil
} | go | func (c *CommandBase) getAPIContext(store jujuclient.CookieStore, controllerName string) (*apiContext, error) {
c.assertRunStarted()
if ctx := c.apiContexts[controllerName]; ctx != nil {
return ctx, nil
}
if controllerName == "" {
return nil, errors.New("cannot get API context from empty controller name")
}
ctx, err := newAPIContext(c.cmdContext, &c.authOpts, store, controllerName)
if err != nil {
return nil, errors.Trace(err)
}
c.apiContexts[controllerName] = ctx
return ctx, nil
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"getAPIContext",
"(",
"store",
"jujuclient",
".",
"CookieStore",
",",
"controllerName",
"string",
")",
"(",
"*",
"apiContext",
",",
"error",
")",
"{",
"c",
".",
"assertRunStarted",
"(",
")",
"\n",
"if",
"ctx",
"... | // getAPIContext returns an apiContext for the given controller.
// It will return the same context if called twice for the same controller.
// The context will be closed when closeAPIContexts is called. | [
"getAPIContext",
"returns",
"an",
"apiContext",
"for",
"the",
"given",
"controller",
".",
"It",
"will",
"return",
"the",
"same",
"context",
"if",
"called",
"twice",
"for",
"the",
"same",
"controller",
".",
"The",
"context",
"will",
"be",
"closed",
"when",
"c... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L407-L421 | train |
juju/juju | cmd/modelcmd/base.go | CookieJar | func (c *CommandBase) CookieJar(store jujuclient.CookieStore, controllerName string) (http.CookieJar, error) {
ctx, err := c.getAPIContext(store, controllerName)
if err != nil {
return nil, errors.Trace(err)
}
return ctx.CookieJar(), nil
} | go | func (c *CommandBase) CookieJar(store jujuclient.CookieStore, controllerName string) (http.CookieJar, error) {
ctx, err := c.getAPIContext(store, controllerName)
if err != nil {
return nil, errors.Trace(err)
}
return ctx.CookieJar(), nil
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"CookieJar",
"(",
"store",
"jujuclient",
".",
"CookieStore",
",",
"controllerName",
"string",
")",
"(",
"http",
".",
"CookieJar",
",",
"error",
")",
"{",
"ctx",
",",
"err",
":=",
"c",
".",
"getAPIContext",
"(",
... | // CookieJar returns the cookie jar that is used to store auth credentials
// when connecting to the API. | [
"CookieJar",
"returns",
"the",
"cookie",
"jar",
"that",
"is",
"used",
"to",
"store",
"auth",
"credentials",
"when",
"connecting",
"to",
"the",
"API",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L425-L431 | train |
juju/juju | cmd/modelcmd/base.go | ClearControllerMacaroons | func (c *CommandBase) ClearControllerMacaroons(store jujuclient.CookieStore, controllerName string) error {
ctx, err := c.getAPIContext(store, controllerName)
if err != nil {
return errors.Trace(err)
}
ctx.jar.RemoveAll()
return nil
} | go | func (c *CommandBase) ClearControllerMacaroons(store jujuclient.CookieStore, controllerName string) error {
ctx, err := c.getAPIContext(store, controllerName)
if err != nil {
return errors.Trace(err)
}
ctx.jar.RemoveAll()
return nil
} | [
"func",
"(",
"c",
"*",
"CommandBase",
")",
"ClearControllerMacaroons",
"(",
"store",
"jujuclient",
".",
"CookieStore",
",",
"controllerName",
"string",
")",
"error",
"{",
"ctx",
",",
"err",
":=",
"c",
".",
"getAPIContext",
"(",
"store",
",",
"controllerName",
... | // ClearControllerMacaroons will remove all macaroons stored
// for the given controller from the persistent cookie jar.
// This is called both from 'juju logout' and a failed 'juju register'. | [
"ClearControllerMacaroons",
"will",
"remove",
"all",
"macaroons",
"stored",
"for",
"the",
"given",
"controller",
"from",
"the",
"persistent",
"cookie",
"jar",
".",
"This",
"is",
"called",
"both",
"from",
"juju",
"logout",
"and",
"a",
"failed",
"juju",
"register"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L436-L443 | train |
juju/juju | cmd/modelcmd/base.go | NewGetBootstrapConfigParamsFunc | func NewGetBootstrapConfigParamsFunc(
ctx *cmd.Context,
store jujuclient.ClientStore,
providerRegistry environs.ProviderRegistry,
) func(string) (*jujuclient.BootstrapConfig, *environs.PrepareConfigParams, error) {
return bootstrapConfigGetter{ctx, store, providerRegistry}.getBootstrapConfigParams
} | go | func NewGetBootstrapConfigParamsFunc(
ctx *cmd.Context,
store jujuclient.ClientStore,
providerRegistry environs.ProviderRegistry,
) func(string) (*jujuclient.BootstrapConfig, *environs.PrepareConfigParams, error) {
return bootstrapConfigGetter{ctx, store, providerRegistry}.getBootstrapConfigParams
} | [
"func",
"NewGetBootstrapConfigParamsFunc",
"(",
"ctx",
"*",
"cmd",
".",
"Context",
",",
"store",
"jujuclient",
".",
"ClientStore",
",",
"providerRegistry",
"environs",
".",
"ProviderRegistry",
",",
")",
"func",
"(",
"string",
")",
"(",
"*",
"jujuclient",
".",
... | // NewGetBootstrapConfigParamsFunc returns a function that, given a controller name,
// returns the params needed to bootstrap a fresh copy of that controller in the given client store. | [
"NewGetBootstrapConfigParamsFunc",
"returns",
"a",
"function",
"that",
"given",
"a",
"controller",
"name",
"returns",
"the",
"params",
"needed",
"to",
"bootstrap",
"a",
"fresh",
"copy",
"of",
"that",
"controller",
"in",
"the",
"given",
"client",
"store",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L517-L523 | train |
juju/juju | cmd/modelcmd/base.go | InnerCommand | func InnerCommand(c cmd.Command) cmd.Command {
for {
c1, ok := c.(wrapper)
if !ok {
return c
}
c = c1.inner()
}
} | go | func InnerCommand(c cmd.Command) cmd.Command {
for {
c1, ok := c.(wrapper)
if !ok {
return c
}
c = c1.inner()
}
} | [
"func",
"InnerCommand",
"(",
"c",
"cmd",
".",
"Command",
")",
"cmd",
".",
"Command",
"{",
"for",
"{",
"c1",
",",
"ok",
":=",
"c",
".",
"(",
"wrapper",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"c",
"\n",
"}",
"\n",
"c",
"=",
"c1",
".",
"inne... | // InnerCommand returns the command that has been wrapped
// by one of the Wrap functions. This is useful for
// tests that wish to inspect internal details of a command
// instance. If c isn't wrapping anything, it returns c. | [
"InnerCommand",
"returns",
"the",
"command",
"that",
"has",
"been",
"wrapped",
"by",
"one",
"of",
"the",
"Wrap",
"functions",
".",
"This",
"is",
"useful",
"for",
"tests",
"that",
"wish",
"to",
"inspect",
"internal",
"details",
"of",
"a",
"command",
"instance... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/modelcmd/base.go#L666-L674 | train |
juju/juju | jujuclient/bootstrapconfig.go | ReadBootstrapConfigFile | func ReadBootstrapConfigFile(file string) (map[string]BootstrapConfig, error) {
data, err := ioutil.ReadFile(file)
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, err
}
configs, err := ParseBootstrapConfig(data)
if err != nil {
return nil, err
}
return configs, nil
} | go | func ReadBootstrapConfigFile(file string) (map[string]BootstrapConfig, error) {
data, err := ioutil.ReadFile(file)
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, err
}
configs, err := ParseBootstrapConfig(data)
if err != nil {
return nil, err
}
return configs, nil
} | [
"func",
"ReadBootstrapConfigFile",
"(",
"file",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"BootstrapConfig",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
... | // ReadBootstrapConfigFile loads all bootstrap configurations defined in a
// given file. If the file is not found, it is not an error. | [
"ReadBootstrapConfigFile",
"loads",
"all",
"bootstrap",
"configurations",
"defined",
"in",
"a",
"given",
"file",
".",
"If",
"the",
"file",
"is",
"not",
"found",
"it",
"is",
"not",
"an",
"error",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/jujuclient/bootstrapconfig.go#L25-L38 | train |
juju/juju | jujuclient/bootstrapconfig.go | WriteBootstrapConfigFile | func WriteBootstrapConfigFile(configs map[string]BootstrapConfig) error {
data, err := yaml.Marshal(bootstrapConfigCollection{configs})
if err != nil {
return errors.Annotate(err, "cannot marshal bootstrap configurations")
}
return utils.AtomicWriteFile(JujuBootstrapConfigPath(), data, os.FileMode(0600))
} | go | func WriteBootstrapConfigFile(configs map[string]BootstrapConfig) error {
data, err := yaml.Marshal(bootstrapConfigCollection{configs})
if err != nil {
return errors.Annotate(err, "cannot marshal bootstrap configurations")
}
return utils.AtomicWriteFile(JujuBootstrapConfigPath(), data, os.FileMode(0600))
} | [
"func",
"WriteBootstrapConfigFile",
"(",
"configs",
"map",
"[",
"string",
"]",
"BootstrapConfig",
")",
"error",
"{",
"data",
",",
"err",
":=",
"yaml",
".",
"Marshal",
"(",
"bootstrapConfigCollection",
"{",
"configs",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",... | // WriteBootstrapConfigFile marshals to YAML details of the given bootstrap
// configurations and writes it to the bootstrap config file. | [
"WriteBootstrapConfigFile",
"marshals",
"to",
"YAML",
"details",
"of",
"the",
"given",
"bootstrap",
"configurations",
"and",
"writes",
"it",
"to",
"the",
"bootstrap",
"config",
"file",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/jujuclient/bootstrapconfig.go#L42-L48 | train |
juju/juju | jujuclient/bootstrapconfig.go | ParseBootstrapConfig | func ParseBootstrapConfig(data []byte) (map[string]BootstrapConfig, error) {
var result bootstrapConfigCollection
err := yaml.Unmarshal(data, &result)
if err != nil {
return nil, errors.Annotate(err, "cannot unmarshal bootstrap config")
}
return result.ControllerBootstrapConfig, nil
} | go | func ParseBootstrapConfig(data []byte) (map[string]BootstrapConfig, error) {
var result bootstrapConfigCollection
err := yaml.Unmarshal(data, &result)
if err != nil {
return nil, errors.Annotate(err, "cannot unmarshal bootstrap config")
}
return result.ControllerBootstrapConfig, nil
} | [
"func",
"ParseBootstrapConfig",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"map",
"[",
"string",
"]",
"BootstrapConfig",
",",
"error",
")",
"{",
"var",
"result",
"bootstrapConfigCollection",
"\n",
"err",
":=",
"yaml",
".",
"Unmarshal",
"(",
"data",
",",
"&",... | // ParseBootstrapConfig parses the given YAML bytes into bootstrap config
// metadata. | [
"ParseBootstrapConfig",
"parses",
"the",
"given",
"YAML",
"bytes",
"into",
"bootstrap",
"config",
"metadata",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/jujuclient/bootstrapconfig.go#L52-L59 | train |
juju/juju | cmd/juju/resource/output_tabular.go | FormatCharmTabular | func FormatCharmTabular(writer io.Writer, value interface{}) error {
resources, valueConverted := value.([]FormattedCharmResource)
if !valueConverted {
return errors.Errorf("expected value of type %T, got %T", resources, value)
}
// Sort by resource name
names, resourcesByName := groupCharmResourcesByName(resources)
// To format things into columns.
tw := output.TabWriter(writer)
// Write the header.
// We do not print a section label.
fmt.Fprintln(tw, "Resource\tRevision")
// Print each info to its own row.
for _, name := range names {
for _, res := range resourcesByName[name] {
// the column headers must be kept in sync with these.
fmt.Fprintf(tw, "%s\t%d\n",
name,
res.Revision,
)
}
}
tw.Flush()
return nil
} | go | func FormatCharmTabular(writer io.Writer, value interface{}) error {
resources, valueConverted := value.([]FormattedCharmResource)
if !valueConverted {
return errors.Errorf("expected value of type %T, got %T", resources, value)
}
// Sort by resource name
names, resourcesByName := groupCharmResourcesByName(resources)
// To format things into columns.
tw := output.TabWriter(writer)
// Write the header.
// We do not print a section label.
fmt.Fprintln(tw, "Resource\tRevision")
// Print each info to its own row.
for _, name := range names {
for _, res := range resourcesByName[name] {
// the column headers must be kept in sync with these.
fmt.Fprintf(tw, "%s\t%d\n",
name,
res.Revision,
)
}
}
tw.Flush()
return nil
} | [
"func",
"FormatCharmTabular",
"(",
"writer",
"io",
".",
"Writer",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"resources",
",",
"valueConverted",
":=",
"value",
".",
"(",
"[",
"]",
"FormattedCharmResource",
")",
"\n",
"if",
"!",
"valueConverted",... | // FormatCharmTabular returns a tabular summary of charm resources. | [
"FormatCharmTabular",
"returns",
"a",
"tabular",
"summary",
"of",
"charm",
"resources",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/resource/output_tabular.go#L18-L47 | train |
juju/juju | cmd/juju/resource/output_tabular.go | FormatAppTabular | func FormatAppTabular(writer io.Writer, value interface{}) error {
switch resources := value.(type) {
case FormattedApplicationInfo:
formatApplicationTabular(writer, resources)
return nil
case []FormattedAppResource:
formatUnitTabular(writer, resources)
return nil
case FormattedApplicationDetails:
formatApplicationDetailTabular(writer, resources)
return nil
case FormattedUnitDetails:
formatUnitDetailTabular(writer, resources)
return nil
default:
return errors.Errorf("unexpected type for data: %T", resources)
}
} | go | func FormatAppTabular(writer io.Writer, value interface{}) error {
switch resources := value.(type) {
case FormattedApplicationInfo:
formatApplicationTabular(writer, resources)
return nil
case []FormattedAppResource:
formatUnitTabular(writer, resources)
return nil
case FormattedApplicationDetails:
formatApplicationDetailTabular(writer, resources)
return nil
case FormattedUnitDetails:
formatUnitDetailTabular(writer, resources)
return nil
default:
return errors.Errorf("unexpected type for data: %T", resources)
}
} | [
"func",
"FormatAppTabular",
"(",
"writer",
"io",
".",
"Writer",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"resources",
":=",
"value",
".",
"(",
"type",
")",
"{",
"case",
"FormattedApplicationInfo",
":",
"formatApplicationTabular",
"(",
... | // FormatAppTabular returns a tabular summary of resources. | [
"FormatAppTabular",
"returns",
"a",
"tabular",
"summary",
"of",
"resources",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/resource/output_tabular.go#L66-L83 | train |
juju/juju | apiserver/httpcontext/auth.go | sendStatusAndJSON | func sendStatusAndJSON(w http.ResponseWriter, statusCode int, response interface{}) error {
body, err := json.Marshal(response)
if err != nil {
return errors.Errorf("cannot marshal JSON result %#v: %v", response, err)
}
if statusCode == http.StatusUnauthorized {
w.Header().Set("WWW-Authenticate", `Basic realm="juju"`)
}
w.Header().Set("Content-Type", params.ContentTypeJSON)
w.Header().Set("Content-Length", fmt.Sprint(len(body)))
w.WriteHeader(statusCode)
if _, err := w.Write(body); err != nil {
return errors.Annotate(err, "cannot write response")
}
return nil
} | go | func sendStatusAndJSON(w http.ResponseWriter, statusCode int, response interface{}) error {
body, err := json.Marshal(response)
if err != nil {
return errors.Errorf("cannot marshal JSON result %#v: %v", response, err)
}
if statusCode == http.StatusUnauthorized {
w.Header().Set("WWW-Authenticate", `Basic realm="juju"`)
}
w.Header().Set("Content-Type", params.ContentTypeJSON)
w.Header().Set("Content-Length", fmt.Sprint(len(body)))
w.WriteHeader(statusCode)
if _, err := w.Write(body); err != nil {
return errors.Annotate(err, "cannot write response")
}
return nil
} | [
"func",
"sendStatusAndJSON",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"statusCode",
"int",
",",
"response",
"interface",
"{",
"}",
")",
"error",
"{",
"body",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"response",
")",
"\n",
"if",
"err",
"!=",
... | // sendStatusAndJSON sends an HTTP status code and
// a JSON-encoded response to a client. | [
"sendStatusAndJSON",
"sends",
"an",
"HTTP",
"status",
"code",
"and",
"a",
"JSON",
"-",
"encoded",
"response",
"to",
"a",
"client",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/httpcontext/auth.go#L115-L131 | train |
juju/juju | apiserver/httpcontext/auth.go | sendError | func sendError(w http.ResponseWriter, errToSend error) error {
paramsErr, statusCode := common.ServerErrorAndStatus(errToSend)
logger.Debugf("sending error: %d %v", statusCode, paramsErr)
return errors.Trace(sendStatusAndJSON(w, statusCode, ¶ms.ErrorResult{
Error: paramsErr,
}))
} | go | func sendError(w http.ResponseWriter, errToSend error) error {
paramsErr, statusCode := common.ServerErrorAndStatus(errToSend)
logger.Debugf("sending error: %d %v", statusCode, paramsErr)
return errors.Trace(sendStatusAndJSON(w, statusCode, ¶ms.ErrorResult{
Error: paramsErr,
}))
} | [
"func",
"sendError",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"errToSend",
"error",
")",
"error",
"{",
"paramsErr",
",",
"statusCode",
":=",
"common",
".",
"ServerErrorAndStatus",
"(",
"errToSend",
")",
"\n",
"logger",
".",
"Debugf",
"(",
"\"",
"\"",
... | // sendError sends a JSON-encoded error response
// for errors encountered during processing. | [
"sendError",
"sends",
"a",
"JSON",
"-",
"encoded",
"error",
"response",
"for",
"errors",
"encountered",
"during",
"processing",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/httpcontext/auth.go#L135-L141 | train |
juju/juju | apiserver/httpcontext/auth.go | RequestAuthInfo | func RequestAuthInfo(req *http.Request) (AuthInfo, bool) {
authInfo, ok := req.Context().Value(authInfoKey{}).(AuthInfo)
return authInfo, ok
} | go | func RequestAuthInfo(req *http.Request) (AuthInfo, bool) {
authInfo, ok := req.Context().Value(authInfoKey{}).(AuthInfo)
return authInfo, ok
} | [
"func",
"RequestAuthInfo",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"(",
"AuthInfo",
",",
"bool",
")",
"{",
"authInfo",
",",
"ok",
":=",
"req",
".",
"Context",
"(",
")",
".",
"Value",
"(",
"authInfoKey",
"{",
"}",
")",
".",
"(",
"AuthInfo",
")... | // RequestAuthInfo returns the AuthInfo associated with the request,
// if any, and a boolean indicating whether or not the request was
// authenticated. | [
"RequestAuthInfo",
"returns",
"the",
"AuthInfo",
"associated",
"with",
"the",
"request",
"if",
"any",
"and",
"a",
"boolean",
"indicating",
"whether",
"or",
"not",
"the",
"request",
"was",
"authenticated",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/httpcontext/auth.go#L180-L183 | train |
juju/juju | cmd/juju/application/removerelation.go | NewRemoveRelationCommand | func NewRemoveRelationCommand() cmd.Command {
command := &removeRelationCommand{}
command.newAPIFunc = func() (ApplicationDestroyRelationAPI, error) {
root, err := command.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
return application.NewClient(root), nil
}
return modelcmd.Wrap(command)
} | go | func NewRemoveRelationCommand() cmd.Command {
command := &removeRelationCommand{}
command.newAPIFunc = func() (ApplicationDestroyRelationAPI, error) {
root, err := command.NewAPIRoot()
if err != nil {
return nil, errors.Trace(err)
}
return application.NewClient(root), nil
}
return modelcmd.Wrap(command)
} | [
"func",
"NewRemoveRelationCommand",
"(",
")",
"cmd",
".",
"Command",
"{",
"command",
":=",
"&",
"removeRelationCommand",
"{",
"}",
"\n",
"command",
".",
"newAPIFunc",
"=",
"func",
"(",
")",
"(",
"ApplicationDestroyRelationAPI",
",",
"error",
")",
"{",
"root",
... | // NewRemoveRelationCommand returns a command to remove a relation between 2 applications. | [
"NewRemoveRelationCommand",
"returns",
"a",
"command",
"to",
"remove",
"a",
"relation",
"between",
"2",
"applications",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/removerelation.go#L61-L72 | train |
juju/juju | api/migrationminion/client.go | Watch | func (c *Client) Watch() (watcher.MigrationStatusWatcher, error) {
var result params.NotifyWatchResult
err := c.caller.FacadeCall("Watch", nil, &result)
if err != nil {
return nil, errors.Trace(err)
}
if result.Error != nil {
return nil, result.Error
}
w := apiwatcher.NewMigrationStatusWatcher(c.caller.RawAPICaller(), result.NotifyWatcherId)
return w, nil
} | go | func (c *Client) Watch() (watcher.MigrationStatusWatcher, error) {
var result params.NotifyWatchResult
err := c.caller.FacadeCall("Watch", nil, &result)
if err != nil {
return nil, errors.Trace(err)
}
if result.Error != nil {
return nil, result.Error
}
w := apiwatcher.NewMigrationStatusWatcher(c.caller.RawAPICaller(), result.NotifyWatcherId)
return w, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Watch",
"(",
")",
"(",
"watcher",
".",
"MigrationStatusWatcher",
",",
"error",
")",
"{",
"var",
"result",
"params",
".",
"NotifyWatchResult",
"\n",
"err",
":=",
"c",
".",
"caller",
".",
"FacadeCall",
"(",
"\"",
"\... | // Watch returns a watcher which reports when the status changes for
// the migration for the model associated with the API connection. | [
"Watch",
"returns",
"a",
"watcher",
"which",
"reports",
"when",
"the",
"status",
"changes",
"for",
"the",
"migration",
"for",
"the",
"model",
"associated",
"with",
"the",
"API",
"connection",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/migrationminion/client.go#L27-L38 | train |
juju/juju | api/migrationminion/client.go | Report | func (c *Client) Report(migrationId string, phase migration.Phase, success bool) error {
args := params.MinionReport{
MigrationId: migrationId,
Phase: phase.String(),
Success: success,
}
err := c.caller.FacadeCall("Report", args, nil)
return errors.Trace(err)
} | go | func (c *Client) Report(migrationId string, phase migration.Phase, success bool) error {
args := params.MinionReport{
MigrationId: migrationId,
Phase: phase.String(),
Success: success,
}
err := c.caller.FacadeCall("Report", args, nil)
return errors.Trace(err)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Report",
"(",
"migrationId",
"string",
",",
"phase",
"migration",
".",
"Phase",
",",
"success",
"bool",
")",
"error",
"{",
"args",
":=",
"params",
".",
"MinionReport",
"{",
"MigrationId",
":",
"migrationId",
",",
"P... | // Report allows a migration minion to report if it successfully
// completed its activities for a given migration phase. | [
"Report",
"allows",
"a",
"migration",
"minion",
"to",
"report",
"if",
"it",
"successfully",
"completed",
"its",
"activities",
"for",
"a",
"given",
"migration",
"phase",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/migrationminion/client.go#L42-L50 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | NewMockSystemdServiceManager | func NewMockSystemdServiceManager(ctrl *gomock.Controller) *MockSystemdServiceManager {
mock := &MockSystemdServiceManager{ctrl: ctrl}
mock.recorder = &MockSystemdServiceManagerMockRecorder{mock}
return mock
} | go | func NewMockSystemdServiceManager(ctrl *gomock.Controller) *MockSystemdServiceManager {
mock := &MockSystemdServiceManager{ctrl: ctrl}
mock.recorder = &MockSystemdServiceManagerMockRecorder{mock}
return mock
} | [
"func",
"NewMockSystemdServiceManager",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockSystemdServiceManager",
"{",
"mock",
":=",
"&",
"MockSystemdServiceManager",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockSystem... | // NewMockSystemdServiceManager creates a new mock instance | [
"NewMockSystemdServiceManager",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L27-L31 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | CopyAgentBinary | func (m *MockSystemdServiceManager) CopyAgentBinary(arg0 string, arg1 []string, arg2, arg3, arg4 string, arg5 version.Number) error {
ret := m.ctrl.Call(m, "CopyAgentBinary", arg0, arg1, arg2, arg3, arg4, arg5)
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockSystemdServiceManager) CopyAgentBinary(arg0 string, arg1 []string, arg2, arg3, arg4 string, arg5 version.Number) error {
ret := m.ctrl.Call(m, "CopyAgentBinary", arg0, arg1, arg2, arg3, arg4, arg5)
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockSystemdServiceManager",
")",
"CopyAgentBinary",
"(",
"arg0",
"string",
",",
"arg1",
"[",
"]",
"string",
",",
"arg2",
",",
"arg3",
",",
"arg4",
"string",
",",
"arg5",
"version",
".",
"Number",
")",
"error",
"{",
"ret",
":=",
... | // CopyAgentBinary mocks base method | [
"CopyAgentBinary",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L39-L43 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | CopyAgentBinary | func (mr *MockSystemdServiceManagerMockRecorder) CopyAgentBinary(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CopyAgentBinary", reflect.TypeOf((*MockSystemdServiceManager)(nil).CopyAgentBinary), arg0, arg1, arg2, arg3, arg4, arg5)
} | go | func (mr *MockSystemdServiceManagerMockRecorder) CopyAgentBinary(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CopyAgentBinary", reflect.TypeOf((*MockSystemdServiceManager)(nil).CopyAgentBinary), arg0, arg1, arg2, arg3, arg4, arg5)
} | [
"func",
"(",
"mr",
"*",
"MockSystemdServiceManagerMockRecorder",
")",
"CopyAgentBinary",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
",",
"arg3",
",",
"arg4",
",",
"arg5",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock... | // CopyAgentBinary indicates an expected call of CopyAgentBinary | [
"CopyAgentBinary",
"indicates",
"an",
"expected",
"call",
"of",
"CopyAgentBinary"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L46-L48 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | CreateAgentConf | func (m *MockSystemdServiceManager) CreateAgentConf(arg0, arg1 string) (common.Conf, error) {
ret := m.ctrl.Call(m, "CreateAgentConf", arg0, arg1)
ret0, _ := ret[0].(common.Conf)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockSystemdServiceManager) CreateAgentConf(arg0, arg1 string) (common.Conf, error) {
ret := m.ctrl.Call(m, "CreateAgentConf", arg0, arg1)
ret0, _ := ret[0].(common.Conf)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockSystemdServiceManager",
")",
"CreateAgentConf",
"(",
"arg0",
",",
"arg1",
"string",
")",
"(",
"common",
".",
"Conf",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"ar... | // CreateAgentConf mocks base method | [
"CreateAgentConf",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L51-L56 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | FindAgents | func (m *MockSystemdServiceManager) FindAgents(arg0 string) (string, []string, []string, error) {
ret := m.ctrl.Call(m, "FindAgents", arg0)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].([]string)
ret2, _ := ret[2].([]string)
ret3, _ := ret[3].(error)
return ret0, ret1, ret2, ret3
} | go | func (m *MockSystemdServiceManager) FindAgents(arg0 string) (string, []string, []string, error) {
ret := m.ctrl.Call(m, "FindAgents", arg0)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].([]string)
ret2, _ := ret[2].([]string)
ret3, _ := ret[3].(error)
return ret0, ret1, ret2, ret3
} | [
"func",
"(",
"m",
"*",
"MockSystemdServiceManager",
")",
"FindAgents",
"(",
"arg0",
"string",
")",
"(",
"string",
",",
"[",
"]",
"string",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
... | // FindAgents mocks base method | [
"FindAgents",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L64-L71 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | StartAllAgents | func (m *MockSystemdServiceManager) StartAllAgents(arg0 string, arg1 []string, arg2 string) (string, []string, error) {
ret := m.ctrl.Call(m, "StartAllAgents", arg0, arg1, arg2)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].([]string)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
} | go | func (m *MockSystemdServiceManager) StartAllAgents(arg0 string, arg1 []string, arg2 string) (string, []string, error) {
ret := m.ctrl.Call(m, "StartAllAgents", arg0, arg1, arg2)
ret0, _ := ret[0].(string)
ret1, _ := ret[1].([]string)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
} | [
"func",
"(",
"m",
"*",
"MockSystemdServiceManager",
")",
"StartAllAgents",
"(",
"arg0",
"string",
",",
"arg1",
"[",
"]",
"string",
",",
"arg2",
"string",
")",
"(",
"string",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctr... | // StartAllAgents mocks base method | [
"StartAllAgents",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L79-L85 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | StartAllAgents | func (mr *MockSystemdServiceManagerMockRecorder) StartAllAgents(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartAllAgents", reflect.TypeOf((*MockSystemdServiceManager)(nil).StartAllAgents), arg0, arg1, arg2)
} | go | func (mr *MockSystemdServiceManagerMockRecorder) StartAllAgents(arg0, arg1, arg2 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartAllAgents", reflect.TypeOf((*MockSystemdServiceManager)(nil).StartAllAgents), arg0, arg1, arg2)
} | [
"func",
"(",
"mr",
"*",
"MockSystemdServiceManagerMockRecorder",
")",
"StartAllAgents",
"(",
"arg0",
",",
"arg1",
",",
"arg2",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodTy... | // StartAllAgents indicates an expected call of StartAllAgents | [
"StartAllAgents",
"indicates",
"an",
"expected",
"call",
"of",
"StartAllAgents"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L88-L90 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | WriteServiceFiles | func (m *MockSystemdServiceManager) WriteServiceFiles() error {
ret := m.ctrl.Call(m, "WriteServiceFiles")
ret0, _ := ret[0].(error)
return ret0
} | go | func (m *MockSystemdServiceManager) WriteServiceFiles() error {
ret := m.ctrl.Call(m, "WriteServiceFiles")
ret0, _ := ret[0].(error)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockSystemdServiceManager",
")",
"WriteServiceFiles",
"(",
")",
"error",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"error... | // WriteServiceFiles mocks base method | [
"WriteServiceFiles",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L93-L97 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | WriteServiceFiles | func (mr *MockSystemdServiceManagerMockRecorder) WriteServiceFiles() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteServiceFiles", reflect.TypeOf((*MockSystemdServiceManager)(nil).WriteServiceFiles))
} | go | func (mr *MockSystemdServiceManagerMockRecorder) WriteServiceFiles() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteServiceFiles", reflect.TypeOf((*MockSystemdServiceManager)(nil).WriteServiceFiles))
} | [
"func",
"(",
"mr",
"*",
"MockSystemdServiceManagerMockRecorder",
")",
"WriteServiceFiles",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"... | // WriteServiceFiles indicates an expected call of WriteServiceFiles | [
"WriteServiceFiles",
"indicates",
"an",
"expected",
"call",
"of",
"WriteServiceFiles"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L100-L102 | train |
juju/juju | worker/upgradeseries/mocks/servicemanager_mock.go | WriteSystemdAgents | func (m *MockSystemdServiceManager) WriteSystemdAgents(arg0 string, arg1 []string, arg2, arg3, arg4 string) ([]string, []string, []string, error) {
ret := m.ctrl.Call(m, "WriteSystemdAgents", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].([]string)
ret2, _ := ret[2].([]string)
ret3, _ := ret[3].(error)
return ret0, ret1, ret2, ret3
} | go | func (m *MockSystemdServiceManager) WriteSystemdAgents(arg0 string, arg1 []string, arg2, arg3, arg4 string) ([]string, []string, []string, error) {
ret := m.ctrl.Call(m, "WriteSystemdAgents", arg0, arg1, arg2, arg3, arg4)
ret0, _ := ret[0].([]string)
ret1, _ := ret[1].([]string)
ret2, _ := ret[2].([]string)
ret3, _ := ret[3].(error)
return ret0, ret1, ret2, ret3
} | [
"func",
"(",
"m",
"*",
"MockSystemdServiceManager",
")",
"WriteSystemdAgents",
"(",
"arg0",
"string",
",",
"arg1",
"[",
"]",
"string",
",",
"arg2",
",",
"arg3",
",",
"arg4",
"string",
")",
"(",
"[",
"]",
"string",
",",
"[",
"]",
"string",
",",
"[",
"... | // WriteSystemdAgents mocks base method | [
"WriteSystemdAgents",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/upgradeseries/mocks/servicemanager_mock.go#L105-L112 | train |
juju/juju | apiserver/facades/controller/charmrevisionupdater/updater.go | NewCharmRevisionUpdaterAPI | func NewCharmRevisionUpdaterAPI(
st *state.State,
resources facade.Resources,
authorizer facade.Authorizer,
) (*CharmRevisionUpdaterAPI, error) {
if !authorizer.AuthController() {
return nil, common.ErrPerm
}
return &CharmRevisionUpdaterAPI{
state: st, resources: resources, authorizer: authorizer}, nil
} | go | func NewCharmRevisionUpdaterAPI(
st *state.State,
resources facade.Resources,
authorizer facade.Authorizer,
) (*CharmRevisionUpdaterAPI, error) {
if !authorizer.AuthController() {
return nil, common.ErrPerm
}
return &CharmRevisionUpdaterAPI{
state: st, resources: resources, authorizer: authorizer}, nil
} | [
"func",
"NewCharmRevisionUpdaterAPI",
"(",
"st",
"*",
"state",
".",
"State",
",",
"resources",
"facade",
".",
"Resources",
",",
"authorizer",
"facade",
".",
"Authorizer",
",",
")",
"(",
"*",
"CharmRevisionUpdaterAPI",
",",
"error",
")",
"{",
"if",
"!",
"auth... | // NewCharmRevisionUpdaterAPI creates a new server-side charmrevisionupdater API end point. | [
"NewCharmRevisionUpdaterAPI",
"creates",
"a",
"new",
"server",
"-",
"side",
"charmrevisionupdater",
"API",
"end",
"point",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/controller/charmrevisionupdater/updater.go#L40-L50 | train |
juju/juju | state/dump.go | DumpAll | func (st *State) DumpAll() (map[string]interface{}, error) {
result := make(map[string]interface{})
// Add in the model document itself.
doc, err := getModelDoc(st)
if err != nil {
return nil, err
}
result[modelsC] = doc
for name, info := range allCollections() {
if !info.global {
docs, err := getAllModelDocs(st, name)
if err != nil {
return nil, errors.Trace(err)
}
if len(docs) > 0 {
result[name] = docs
}
}
}
return result, nil
} | go | func (st *State) DumpAll() (map[string]interface{}, error) {
result := make(map[string]interface{})
// Add in the model document itself.
doc, err := getModelDoc(st)
if err != nil {
return nil, err
}
result[modelsC] = doc
for name, info := range allCollections() {
if !info.global {
docs, err := getAllModelDocs(st, name)
if err != nil {
return nil, errors.Trace(err)
}
if len(docs) > 0 {
result[name] = docs
}
}
}
return result, nil
} | [
"func",
"(",
"st",
"*",
"State",
")",
"DumpAll",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"result",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"// Add in the model... | // DumpAll returns a map of collection names to a slice of documents
// in that collection. Every document that is related to the current
// model is returned in the map. | [
"DumpAll",
"returns",
"a",
"map",
"of",
"collection",
"names",
"to",
"a",
"slice",
"of",
"documents",
"in",
"that",
"collection",
".",
"Every",
"document",
"that",
"is",
"related",
"to",
"the",
"current",
"model",
"is",
"returned",
"in",
"the",
"map",
"."
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/dump.go#L11-L31 | train |
juju/juju | cmd/juju/application/show.go | NewShowApplicationCommand | func NewShowApplicationCommand() cmd.Command {
s := &showApplicationCommand{}
s.newAPIFunc = func() (ApplicationsInfoAPI, error) {
return s.newApplicationAPI()
}
return modelcmd.Wrap(s)
} | go | func NewShowApplicationCommand() cmd.Command {
s := &showApplicationCommand{}
s.newAPIFunc = func() (ApplicationsInfoAPI, error) {
return s.newApplicationAPI()
}
return modelcmd.Wrap(s)
} | [
"func",
"NewShowApplicationCommand",
"(",
")",
"cmd",
".",
"Command",
"{",
"s",
":=",
"&",
"showApplicationCommand",
"{",
"}",
"\n",
"s",
".",
"newAPIFunc",
"=",
"func",
"(",
")",
"(",
"ApplicationsInfoAPI",
",",
"error",
")",
"{",
"return",
"s",
".",
"n... | // NewShowApplicationCommand returns a command that displays applications info. | [
"NewShowApplicationCommand",
"returns",
"a",
"command",
"that",
"displays",
"applications",
"info",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/show.go#L36-L42 | train |
juju/juju | cmd/juju/application/show.go | formatApplicationInfos | func formatApplicationInfos(all []params.ApplicationInfo) (map[string]ApplicationInfo, error) {
if len(all) == 0 {
return nil, nil
}
output := make(map[string]ApplicationInfo)
for _, one := range all {
tag, info, err := createApplicationInfo(one)
if err != nil {
return nil, errors.Trace(err)
}
output[tag.Name] = info
}
return output, nil
} | go | func formatApplicationInfos(all []params.ApplicationInfo) (map[string]ApplicationInfo, error) {
if len(all) == 0 {
return nil, nil
}
output := make(map[string]ApplicationInfo)
for _, one := range all {
tag, info, err := createApplicationInfo(one)
if err != nil {
return nil, errors.Trace(err)
}
output[tag.Name] = info
}
return output, nil
} | [
"func",
"formatApplicationInfos",
"(",
"all",
"[",
"]",
"params",
".",
"ApplicationInfo",
")",
"(",
"map",
"[",
"string",
"]",
"ApplicationInfo",
",",
"error",
")",
"{",
"if",
"len",
"(",
"all",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"nil",
"\n",
... | // formatApplicationInfos takes a set of params.ApplicationInfo and
// creates a mapping from storage ID application name to application info. | [
"formatApplicationInfos",
"takes",
"a",
"set",
"of",
"params",
".",
"ApplicationInfo",
"and",
"creates",
"a",
"mapping",
"from",
"storage",
"ID",
"application",
"name",
"to",
"application",
"info",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/application/show.go#L162-L175 | train |
juju/juju | api/common/cloudspec/cloudspec.go | NewCloudSpecAPI | func NewCloudSpecAPI(facade base.FacadeCaller, modelTag names.ModelTag) *CloudSpecAPI {
return &CloudSpecAPI{facade, modelTag}
} | go | func NewCloudSpecAPI(facade base.FacadeCaller, modelTag names.ModelTag) *CloudSpecAPI {
return &CloudSpecAPI{facade, modelTag}
} | [
"func",
"NewCloudSpecAPI",
"(",
"facade",
"base",
".",
"FacadeCaller",
",",
"modelTag",
"names",
".",
"ModelTag",
")",
"*",
"CloudSpecAPI",
"{",
"return",
"&",
"CloudSpecAPI",
"{",
"facade",
",",
"modelTag",
"}",
"\n",
"}"
] | // NewCloudSpecAPI creates a CloudSpecAPI using the provided
// FacadeCaller. | [
"NewCloudSpecAPI",
"creates",
"a",
"CloudSpecAPI",
"using",
"the",
"provided",
"FacadeCaller",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/cloudspec/cloudspec.go#L27-L29 | train |
juju/juju | api/common/cloudspec/cloudspec.go | WatchCloudSpecChanges | func (api *CloudSpecAPI) WatchCloudSpecChanges() (watcher.NotifyWatcher, error) {
var results params.NotifyWatchResults
args := params.Entities{Entities: []params.Entity{{api.modelTag.String()}}}
err := api.facade.FacadeCall("WatchCloudSpecsChanges", args, &results)
if err != nil {
return nil, err
}
if n := len(results.Results); n != 1 {
return nil, errors.Errorf("expected 1 result, got %d", n)
}
result := results.Results[0]
if result.Error != nil {
return nil, errors.Annotate(result.Error, "API request failed")
}
return apiwatcher.NewNotifyWatcher(api.facade.RawAPICaller(), result), nil
} | go | func (api *CloudSpecAPI) WatchCloudSpecChanges() (watcher.NotifyWatcher, error) {
var results params.NotifyWatchResults
args := params.Entities{Entities: []params.Entity{{api.modelTag.String()}}}
err := api.facade.FacadeCall("WatchCloudSpecsChanges", args, &results)
if err != nil {
return nil, err
}
if n := len(results.Results); n != 1 {
return nil, errors.Errorf("expected 1 result, got %d", n)
}
result := results.Results[0]
if result.Error != nil {
return nil, errors.Annotate(result.Error, "API request failed")
}
return apiwatcher.NewNotifyWatcher(api.facade.RawAPICaller(), result), nil
} | [
"func",
"(",
"api",
"*",
"CloudSpecAPI",
")",
"WatchCloudSpecChanges",
"(",
")",
"(",
"watcher",
".",
"NotifyWatcher",
",",
"error",
")",
"{",
"var",
"results",
"params",
".",
"NotifyWatchResults",
"\n",
"args",
":=",
"params",
".",
"Entities",
"{",
"Entitie... | // WatchCloudSpecChanges returns a NotifyWatcher waiting for the
// model's cloud to change. | [
"WatchCloudSpecChanges",
"returns",
"a",
"NotifyWatcher",
"waiting",
"for",
"the",
"model",
"s",
"cloud",
"to",
"change",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/cloudspec/cloudspec.go#L33-L48 | train |
juju/juju | api/common/cloudspec/cloudspec.go | CloudSpec | func (api *CloudSpecAPI) CloudSpec() (environs.CloudSpec, error) {
var results params.CloudSpecResults
args := params.Entities{Entities: []params.Entity{{api.modelTag.String()}}}
err := api.facade.FacadeCall("CloudSpec", args, &results)
if err != nil {
return environs.CloudSpec{}, err
}
if n := len(results.Results); n != 1 {
return environs.CloudSpec{}, errors.Errorf("expected 1 result, got %d", n)
}
result := results.Results[0]
if result.Error != nil {
return environs.CloudSpec{}, errors.Annotate(result.Error, "API request failed")
}
return api.MakeCloudSpec(result.Result)
} | go | func (api *CloudSpecAPI) CloudSpec() (environs.CloudSpec, error) {
var results params.CloudSpecResults
args := params.Entities{Entities: []params.Entity{{api.modelTag.String()}}}
err := api.facade.FacadeCall("CloudSpec", args, &results)
if err != nil {
return environs.CloudSpec{}, err
}
if n := len(results.Results); n != 1 {
return environs.CloudSpec{}, errors.Errorf("expected 1 result, got %d", n)
}
result := results.Results[0]
if result.Error != nil {
return environs.CloudSpec{}, errors.Annotate(result.Error, "API request failed")
}
return api.MakeCloudSpec(result.Result)
} | [
"func",
"(",
"api",
"*",
"CloudSpecAPI",
")",
"CloudSpec",
"(",
")",
"(",
"environs",
".",
"CloudSpec",
",",
"error",
")",
"{",
"var",
"results",
"params",
".",
"CloudSpecResults",
"\n",
"args",
":=",
"params",
".",
"Entities",
"{",
"Entities",
":",
"[",... | // CloudSpec returns the cloud specification for the model associated
// with the API facade. | [
"CloudSpec",
"returns",
"the",
"cloud",
"specification",
"for",
"the",
"model",
"associated",
"with",
"the",
"API",
"facade",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/cloudspec/cloudspec.go#L52-L67 | train |
juju/juju | api/common/cloudspec/cloudspec.go | MakeCloudSpec | func (api *CloudSpecAPI) MakeCloudSpec(pSpec *params.CloudSpec) (environs.CloudSpec, error) {
if pSpec == nil {
return environs.CloudSpec{}, errors.NotValidf("nil value")
}
var credential *cloud.Credential
if pSpec.Credential != nil {
credentialValue := cloud.NewCredential(
cloud.AuthType(pSpec.Credential.AuthType),
pSpec.Credential.Attributes,
)
credential = &credentialValue
}
spec := environs.CloudSpec{
Type: pSpec.Type,
Name: pSpec.Name,
Region: pSpec.Region,
Endpoint: pSpec.Endpoint,
IdentityEndpoint: pSpec.IdentityEndpoint,
StorageEndpoint: pSpec.StorageEndpoint,
CACertificates: pSpec.CACertificates,
Credential: credential,
}
if err := spec.Validate(); err != nil {
return environs.CloudSpec{}, errors.Annotate(err, "validating CloudSpec")
}
return spec, nil
} | go | func (api *CloudSpecAPI) MakeCloudSpec(pSpec *params.CloudSpec) (environs.CloudSpec, error) {
if pSpec == nil {
return environs.CloudSpec{}, errors.NotValidf("nil value")
}
var credential *cloud.Credential
if pSpec.Credential != nil {
credentialValue := cloud.NewCredential(
cloud.AuthType(pSpec.Credential.AuthType),
pSpec.Credential.Attributes,
)
credential = &credentialValue
}
spec := environs.CloudSpec{
Type: pSpec.Type,
Name: pSpec.Name,
Region: pSpec.Region,
Endpoint: pSpec.Endpoint,
IdentityEndpoint: pSpec.IdentityEndpoint,
StorageEndpoint: pSpec.StorageEndpoint,
CACertificates: pSpec.CACertificates,
Credential: credential,
}
if err := spec.Validate(); err != nil {
return environs.CloudSpec{}, errors.Annotate(err, "validating CloudSpec")
}
return spec, nil
} | [
"func",
"(",
"api",
"*",
"CloudSpecAPI",
")",
"MakeCloudSpec",
"(",
"pSpec",
"*",
"params",
".",
"CloudSpec",
")",
"(",
"environs",
".",
"CloudSpec",
",",
"error",
")",
"{",
"if",
"pSpec",
"==",
"nil",
"{",
"return",
"environs",
".",
"CloudSpec",
"{",
... | // MakeCloudSpec creates an environs.CloudSpec from a params.CloudSpec
// that has been returned from the apiserver. | [
"MakeCloudSpec",
"creates",
"an",
"environs",
".",
"CloudSpec",
"from",
"a",
"params",
".",
"CloudSpec",
"that",
"has",
"been",
"returned",
"from",
"the",
"apiserver",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/cloudspec/cloudspec.go#L71-L97 | train |
juju/juju | state/images.go | ImageStorage | func (st *State) ImageStorage() imagestorage.Storage {
return imageStorageNewStorage(st.session, st.ModelUUID())
} | go | func (st *State) ImageStorage() imagestorage.Storage {
return imageStorageNewStorage(st.session, st.ModelUUID())
} | [
"func",
"(",
"st",
"*",
"State",
")",
"ImageStorage",
"(",
")",
"imagestorage",
".",
"Storage",
"{",
"return",
"imageStorageNewStorage",
"(",
"st",
".",
"session",
",",
"st",
".",
"ModelUUID",
"(",
")",
")",
"\n",
"}"
] | // ImageStorage returns a new imagestorage.Storage
// that stores image metadata. | [
"ImageStorage",
"returns",
"a",
"new",
"imagestorage",
".",
"Storage",
"that",
"stores",
"image",
"metadata",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/images.go#L16-L18 | train |
juju/juju | api/diskmanager/diskmanager.go | NewState | func NewState(caller base.APICaller, authTag names.MachineTag) *State {
return &State{
base.NewFacadeCaller(caller, diskManagerFacade),
authTag,
}
} | go | func NewState(caller base.APICaller, authTag names.MachineTag) *State {
return &State{
base.NewFacadeCaller(caller, diskManagerFacade),
authTag,
}
} | [
"func",
"NewState",
"(",
"caller",
"base",
".",
"APICaller",
",",
"authTag",
"names",
".",
"MachineTag",
")",
"*",
"State",
"{",
"return",
"&",
"State",
"{",
"base",
".",
"NewFacadeCaller",
"(",
"caller",
",",
"diskManagerFacade",
")",
",",
"authTag",
",",... | // NewState creates a new client-side DiskManager facade. | [
"NewState",
"creates",
"a",
"new",
"client",
"-",
"side",
"DiskManager",
"facade",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/diskmanager/diskmanager.go#L23-L28 | train |
juju/juju | api/diskmanager/diskmanager.go | SetMachineBlockDevices | func (st *State) SetMachineBlockDevices(devices []storage.BlockDevice) error {
args := params.SetMachineBlockDevices{
MachineBlockDevices: []params.MachineBlockDevices{{
Machine: st.tag.String(),
BlockDevices: devices,
}},
}
var results params.ErrorResults
err := st.facade.FacadeCall("SetMachineBlockDevices", args, &results)
if err != nil {
return err
}
return results.OneError()
} | go | func (st *State) SetMachineBlockDevices(devices []storage.BlockDevice) error {
args := params.SetMachineBlockDevices{
MachineBlockDevices: []params.MachineBlockDevices{{
Machine: st.tag.String(),
BlockDevices: devices,
}},
}
var results params.ErrorResults
err := st.facade.FacadeCall("SetMachineBlockDevices", args, &results)
if err != nil {
return err
}
return results.OneError()
} | [
"func",
"(",
"st",
"*",
"State",
")",
"SetMachineBlockDevices",
"(",
"devices",
"[",
"]",
"storage",
".",
"BlockDevice",
")",
"error",
"{",
"args",
":=",
"params",
".",
"SetMachineBlockDevices",
"{",
"MachineBlockDevices",
":",
"[",
"]",
"params",
".",
"Mach... | // SetMachineBlockDevices sets the block devices attached to the machine
// identified by the authenticated machine tag. | [
"SetMachineBlockDevices",
"sets",
"the",
"block",
"devices",
"attached",
"to",
"the",
"machine",
"identified",
"by",
"the",
"authenticated",
"machine",
"tag",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/diskmanager/diskmanager.go#L32-L45 | train |
juju/juju | storage/provider/dummy/filesystemsource.go | ValidateFilesystemParams | func (s *FilesystemSource) ValidateFilesystemParams(params storage.FilesystemParams) error {
s.MethodCall(s, "ValidateFilesystemParams", params)
if s.ValidateFilesystemParamsFunc != nil {
return s.ValidateFilesystemParamsFunc(params)
}
return nil
} | go | func (s *FilesystemSource) ValidateFilesystemParams(params storage.FilesystemParams) error {
s.MethodCall(s, "ValidateFilesystemParams", params)
if s.ValidateFilesystemParamsFunc != nil {
return s.ValidateFilesystemParamsFunc(params)
}
return nil
} | [
"func",
"(",
"s",
"*",
"FilesystemSource",
")",
"ValidateFilesystemParams",
"(",
"params",
"storage",
".",
"FilesystemParams",
")",
"error",
"{",
"s",
".",
"MethodCall",
"(",
"s",
",",
"\"",
"\"",
",",
"params",
")",
"\n",
"if",
"s",
".",
"ValidateFilesyst... | // ValidateFilesystemParams is defined on storage.FilesystemSource. | [
"ValidateFilesystemParams",
"is",
"defined",
"on",
"storage",
".",
"FilesystemSource",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/storage/provider/dummy/filesystemsource.go#L56-L62 | train |
juju/juju | apiserver/facades/client/application/mocks/charm_mock.go | NewMockStateCharm | func NewMockStateCharm(ctrl *gomock.Controller) *MockStateCharm {
mock := &MockStateCharm{ctrl: ctrl}
mock.recorder = &MockStateCharmMockRecorder{mock}
return mock
} | go | func NewMockStateCharm(ctrl *gomock.Controller) *MockStateCharm {
mock := &MockStateCharm{ctrl: ctrl}
mock.recorder = &MockStateCharmMockRecorder{mock}
return mock
} | [
"func",
"NewMockStateCharm",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockStateCharm",
"{",
"mock",
":=",
"&",
"MockStateCharm",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockStateCharmMockRecorder",
"{",
"mock... | // NewMockStateCharm creates a new mock instance | [
"NewMockStateCharm",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/mocks/charm_mock.go#L24-L28 | train |
juju/juju | apiserver/facades/client/application/mocks/charm_mock.go | IsUploaded | func (m *MockStateCharm) IsUploaded() bool {
ret := m.ctrl.Call(m, "IsUploaded")
ret0, _ := ret[0].(bool)
return ret0
} | go | func (m *MockStateCharm) IsUploaded() bool {
ret := m.ctrl.Call(m, "IsUploaded")
ret0, _ := ret[0].(bool)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockStateCharm",
")",
"IsUploaded",
"(",
")",
"bool",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"bool",
")",
"\n",
... | // IsUploaded mocks base method | [
"IsUploaded",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/mocks/charm_mock.go#L36-L40 | train |
juju/juju | apiserver/facades/client/application/mocks/charm_mock.go | IsUploaded | func (mr *MockStateCharmMockRecorder) IsUploaded() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUploaded", reflect.TypeOf((*MockStateCharm)(nil).IsUploaded))
} | go | func (mr *MockStateCharmMockRecorder) IsUploaded() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUploaded", reflect.TypeOf((*MockStateCharm)(nil).IsUploaded))
} | [
"func",
"(",
"mr",
"*",
"MockStateCharmMockRecorder",
")",
"IsUploaded",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
... | // IsUploaded indicates an expected call of IsUploaded | [
"IsUploaded",
"indicates",
"an",
"expected",
"call",
"of",
"IsUploaded"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/mocks/charm_mock.go#L43-L45 | train |
juju/juju | apiserver/facades/client/application/mocks/charmstore_mock.go | ControllerConfig | func (m *MockState) ControllerConfig() (controller.Config, error) {
ret := m.ctrl.Call(m, "ControllerConfig")
ret0, _ := ret[0].(controller.Config)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockState) ControllerConfig() (controller.Config, error) {
ret := m.ctrl.Call(m, "ControllerConfig")
ret0, _ := ret[0].(controller.Config)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockState",
")",
"ControllerConfig",
"(",
")",
"(",
"controller",
".",
"Config",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[... | // ControllerConfig mocks base method | [
"ControllerConfig",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/mocks/charmstore_mock.go#L41-L46 | train |
juju/juju | apiserver/facades/client/application/mocks/charmstore_mock.go | ModelUUID | func (m *MockState) ModelUUID() string {
ret := m.ctrl.Call(m, "ModelUUID")
ret0, _ := ret[0].(string)
return ret0
} | go | func (m *MockState) ModelUUID() string {
ret := m.ctrl.Call(m, "ModelUUID")
ret0, _ := ret[0].(string)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockState",
")",
"ModelUUID",
"(",
")",
"string",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
"string",
")",
"\n",
"r... | // ModelUUID mocks base method | [
"ModelUUID",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/mocks/charmstore_mock.go#L67-L71 | train |
juju/juju | apiserver/facades/client/application/mocks/charmstore_mock.go | ModelUUID | func (mr *MockStateMockRecorder) ModelUUID() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModelUUID", reflect.TypeOf((*MockState)(nil).ModelUUID))
} | go | func (mr *MockStateMockRecorder) ModelUUID() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ModelUUID", reflect.TypeOf((*MockState)(nil).ModelUUID))
} | [
"func",
"(",
"mr",
"*",
"MockStateMockRecorder",
")",
"ModelUUID",
"(",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
"\"",
"\"",
",",
"reflect",
".",
"Type... | // ModelUUID indicates an expected call of ModelUUID | [
"ModelUUID",
"indicates",
"an",
"expected",
"call",
"of",
"ModelUUID"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/mocks/charmstore_mock.go#L74-L76 | train |
juju/juju | apiserver/facades/client/application/mocks/charmstore_mock.go | MongoSession | func (m *MockState) MongoSession() *mgo_v2.Session {
ret := m.ctrl.Call(m, "MongoSession")
ret0, _ := ret[0].(*mgo_v2.Session)
return ret0
} | go | func (m *MockState) MongoSession() *mgo_v2.Session {
ret := m.ctrl.Call(m, "MongoSession")
ret0, _ := ret[0].(*mgo_v2.Session)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockState",
")",
"MongoSession",
"(",
")",
"*",
"mgo_v2",
".",
"Session",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
")",
"\n",
"ret0",
",",
"_",
":=",
"ret",
"[",
"0",
"]",
".",
"(",
... | // MongoSession mocks base method | [
"MongoSession",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/mocks/charmstore_mock.go#L79-L83 | train |
juju/juju | apiserver/facades/client/application/mocks/charmstore_mock.go | PrepareStoreCharmUpload | func (m *MockState) PrepareStoreCharmUpload(arg0 *charm_v6.URL) (application.StateCharm, error) {
ret := m.ctrl.Call(m, "PrepareStoreCharmUpload", arg0)
ret0, _ := ret[0].(application.StateCharm)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockState) PrepareStoreCharmUpload(arg0 *charm_v6.URL) (application.StateCharm, error) {
ret := m.ctrl.Call(m, "PrepareStoreCharmUpload", arg0)
ret0, _ := ret[0].(application.StateCharm)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockState",
")",
"PrepareStoreCharmUpload",
"(",
"arg0",
"*",
"charm_v6",
".",
"URL",
")",
"(",
"application",
".",
"StateCharm",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
... | // PrepareStoreCharmUpload mocks base method | [
"PrepareStoreCharmUpload",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/mocks/charmstore_mock.go#L91-L96 | train |
juju/juju | apiserver/facades/client/application/mocks/charmstore_mock.go | UpdateUploadedCharm | func (m *MockState) UpdateUploadedCharm(arg0 state.CharmInfo) (*state.Charm, error) {
ret := m.ctrl.Call(m, "UpdateUploadedCharm", arg0)
ret0, _ := ret[0].(*state.Charm)
ret1, _ := ret[1].(error)
return ret0, ret1
} | go | func (m *MockState) UpdateUploadedCharm(arg0 state.CharmInfo) (*state.Charm, error) {
ret := m.ctrl.Call(m, "UpdateUploadedCharm", arg0)
ret0, _ := ret[0].(*state.Charm)
ret1, _ := ret[1].(error)
return ret0, ret1
} | [
"func",
"(",
"m",
"*",
"MockState",
")",
"UpdateUploadedCharm",
"(",
"arg0",
"state",
".",
"CharmInfo",
")",
"(",
"*",
"state",
".",
"Charm",
",",
"error",
")",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg... | // UpdateUploadedCharm mocks base method | [
"UpdateUploadedCharm",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/mocks/charmstore_mock.go#L104-L109 | train |
juju/juju | worker/httpserver/worker.go | Report | func (w *Worker) Report() map[string]interface{} {
w.mu.Lock()
result := map[string]interface{}{
"api-port": w.config.APIPort,
"status": w.status,
"ports": w.holdable.report(),
}
if w.config.ControllerAPIPort != 0 {
result["api-port-open-delay"] = w.config.APIPortOpenDelay
result["controller-api-port"] = w.config.ControllerAPIPort
}
w.mu.Unlock()
return result
} | go | func (w *Worker) Report() map[string]interface{} {
w.mu.Lock()
result := map[string]interface{}{
"api-port": w.config.APIPort,
"status": w.status,
"ports": w.holdable.report(),
}
if w.config.ControllerAPIPort != 0 {
result["api-port-open-delay"] = w.config.APIPortOpenDelay
result["controller-api-port"] = w.config.ControllerAPIPort
}
w.mu.Unlock()
return result
} | [
"func",
"(",
"w",
"*",
"Worker",
")",
"Report",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"w",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"result",
":=",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"\"",
"\"",
"... | // Report provides information for the engine report. | [
"Report",
"provides",
"information",
"for",
"the",
"engine",
"report",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/httpserver/worker.go#L125-L138 | train |
juju/juju | worker/httpserver/worker.go | Close | func (d *dualListener) Close() error {
// Only close the channel once.
d.closer.Do(func() { close(d.done) })
err := d.controllerListener.Close()
d.mu.Lock()
defer d.mu.Unlock()
if d.apiListener != nil {
err2 := d.apiListener.Close()
if err == nil {
err = err2
}
// If we already have a close error, we don't really care
// about this one.
}
d.status = "closed ports"
return errors.Trace(err)
} | go | func (d *dualListener) Close() error {
// Only close the channel once.
d.closer.Do(func() { close(d.done) })
err := d.controllerListener.Close()
d.mu.Lock()
defer d.mu.Unlock()
if d.apiListener != nil {
err2 := d.apiListener.Close()
if err == nil {
err = err2
}
// If we already have a close error, we don't really care
// about this one.
}
d.status = "closed ports"
return errors.Trace(err)
} | [
"func",
"(",
"d",
"*",
"dualListener",
")",
"Close",
"(",
")",
"error",
"{",
"// Only close the channel once.",
"d",
".",
"closer",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"close",
"(",
"d",
".",
"done",
")",
"}",
")",
"\n",
"err",
":=",
"d",
".",
... | // Close implements net.Listener. Closes all the open listeners. | [
"Close",
"implements",
"net",
".",
"Listener",
".",
"Closes",
"all",
"the",
"open",
"listeners",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/httpserver/worker.go#L428-L444 | train |
juju/juju | worker/httpserver/worker.go | Addr | func (d *dualListener) Addr() net.Addr {
d.mu.Lock()
defer d.mu.Unlock()
if d.apiListener != nil {
return d.apiListener.Addr()
}
return d.controllerListener.Addr()
} | go | func (d *dualListener) Addr() net.Addr {
d.mu.Lock()
defer d.mu.Unlock()
if d.apiListener != nil {
return d.apiListener.Addr()
}
return d.controllerListener.Addr()
} | [
"func",
"(",
"d",
"*",
"dualListener",
")",
"Addr",
"(",
")",
"net",
".",
"Addr",
"{",
"d",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"d",
".",
"apiListener",
"!=",
"nil",
"{",
"retu... | // Addr implements net.Listener. If the api port has been opened, we
// return that, otherwise we return the controller port address. | [
"Addr",
"implements",
"net",
".",
"Listener",
".",
"If",
"the",
"api",
"port",
"has",
"been",
"opened",
"we",
"return",
"that",
"otherwise",
"we",
"return",
"the",
"controller",
"port",
"address",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/httpserver/worker.go#L448-L455 | train |
juju/juju | worker/httpserver/worker.go | openAPIPort | func (d *dualListener) openAPIPort(topic string, conn apiserver.APIConnection, err error) {
if err != nil {
logger.Errorf("programming error: %v", err)
return
}
// We are wanting to make sure that the api-caller has connected before we
// open the api port. Each api connection is published with the origin tag.
// Any origin that matches our agent name means that someone has connected
// to us. We need to also check which agent connected as it is possible that
// one of the other HA controller could connect before we connect to
// ourselves.
if conn.Origin != d.agentName || conn.AgentTag != d.agentName {
return
}
d.unsub()
if d.delay > 0 {
d.mu.Lock()
d.status = "waiting prior to opening agent port"
d.mu.Unlock()
logger.Infof("waiting for %s before allowing api connections", d.delay)
<-d.clock.After(d.delay)
}
d.mu.Lock()
defer d.mu.Unlock()
// Make sure we haven't been closed already.
select {
case <-d.done:
return
default:
// We are all good.
}
listenAddr := net.JoinHostPort("", strconv.Itoa(d.apiPort))
listener, err := net.Listen("tcp", listenAddr)
if err != nil {
select {
case d.errors <- err:
case <-d.done:
logger.Errorf("can't open api port: %v, but worker exiting already", err)
}
return
}
logger.Infof("listening for api connections on %q", listener.Addr())
d.apiListener = listener
go d.accept(listener)
d.status = ""
} | go | func (d *dualListener) openAPIPort(topic string, conn apiserver.APIConnection, err error) {
if err != nil {
logger.Errorf("programming error: %v", err)
return
}
// We are wanting to make sure that the api-caller has connected before we
// open the api port. Each api connection is published with the origin tag.
// Any origin that matches our agent name means that someone has connected
// to us. We need to also check which agent connected as it is possible that
// one of the other HA controller could connect before we connect to
// ourselves.
if conn.Origin != d.agentName || conn.AgentTag != d.agentName {
return
}
d.unsub()
if d.delay > 0 {
d.mu.Lock()
d.status = "waiting prior to opening agent port"
d.mu.Unlock()
logger.Infof("waiting for %s before allowing api connections", d.delay)
<-d.clock.After(d.delay)
}
d.mu.Lock()
defer d.mu.Unlock()
// Make sure we haven't been closed already.
select {
case <-d.done:
return
default:
// We are all good.
}
listenAddr := net.JoinHostPort("", strconv.Itoa(d.apiPort))
listener, err := net.Listen("tcp", listenAddr)
if err != nil {
select {
case d.errors <- err:
case <-d.done:
logger.Errorf("can't open api port: %v, but worker exiting already", err)
}
return
}
logger.Infof("listening for api connections on %q", listener.Addr())
d.apiListener = listener
go d.accept(listener)
d.status = ""
} | [
"func",
"(",
"d",
"*",
"dualListener",
")",
"openAPIPort",
"(",
"topic",
"string",
",",
"conn",
"apiserver",
".",
"APIConnection",
",",
"err",
"error",
")",
"{",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")"... | // openAPIPort opens the api port and starts accepting connections. | [
"openAPIPort",
"opens",
"the",
"api",
"port",
"and",
"starts",
"accepting",
"connections",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/httpserver/worker.go#L463-L512 | train |
juju/juju | cmd/juju/romulus/listplans/list_plans.go | Init | func (c *ListPlansCommand) Init(args []string) error {
if len(args) == 0 {
return errors.New("missing arguments")
}
charmURL, args := args[0], args[1:]
if err := cmd.CheckEmpty(args); err != nil {
return errors.Errorf("unknown command line arguments: " + strings.Join(args, ","))
}
c.CharmURL = charmURL
return c.CommandBase.Init(args)
} | go | func (c *ListPlansCommand) Init(args []string) error {
if len(args) == 0 {
return errors.New("missing arguments")
}
charmURL, args := args[0], args[1:]
if err := cmd.CheckEmpty(args); err != nil {
return errors.Errorf("unknown command line arguments: " + strings.Join(args, ","))
}
c.CharmURL = charmURL
return c.CommandBase.Init(args)
} | [
"func",
"(",
"c",
"*",
"ListPlansCommand",
")",
"Init",
"(",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"charmURL",
",",
"... | // Init reads and verifies the cli arguments for the ListPlansCommand | [
"Init",
"reads",
"and",
"verifies",
"the",
"cli",
"arguments",
"for",
"the",
"ListPlansCommand"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/romulus/listplans/list_plans.go#L72-L82 | train |
juju/juju | cmd/juju/romulus/listplans/list_plans.go | Run | func (c *ListPlansCommand) Run(ctx *cmd.Context) (rErr error) {
client, err := c.BakeryClient()
if err != nil {
return errors.Annotate(err, "failed to create an http client")
}
resolver, err := rcmd.NewCharmStoreResolverForControllerCmd(&c.ControllerCommandBase)
if err != nil {
return errors.Trace(err)
}
resolvedURL, err := resolver.Resolve(client, c.CharmURL)
if err != nil {
return errors.Annotatef(err, "failed to resolve charmURL %v", c.CharmURL)
}
c.CharmURL = resolvedURL
apiRoot, err := rcmd.GetMeteringURLForControllerCmd(&c.ControllerCommandBase)
if err != nil {
return errors.Trace(err)
}
apiClient, err := newClient(apiRoot, client)
if err != nil {
return errors.Annotate(err, "failed to create a plan API client")
}
plans, err := apiClient.GetAssociatedPlans(c.CharmURL)
if err != nil {
return errors.Annotate(err, "failed to retrieve plans")
}
output := make([]plan, len(plans))
for i, p := range plans {
outputPlan := plan{
URL: p.URL,
}
def, err := readPlan(bytes.NewBufferString(p.Definition))
if err != nil {
return errors.Annotate(err, "failed to parse plan definition")
}
if def.Description != nil {
outputPlan.Price = def.Description.Price
outputPlan.Description = def.Description.Text
}
output[i] = outputPlan
}
if len(output) == 0 && c.out.Name() == "tabular" {
ctx.Infof("No plans to display.")
}
err = c.out.Write(ctx, output)
if err != nil {
return errors.Trace(err)
}
return nil
} | go | func (c *ListPlansCommand) Run(ctx *cmd.Context) (rErr error) {
client, err := c.BakeryClient()
if err != nil {
return errors.Annotate(err, "failed to create an http client")
}
resolver, err := rcmd.NewCharmStoreResolverForControllerCmd(&c.ControllerCommandBase)
if err != nil {
return errors.Trace(err)
}
resolvedURL, err := resolver.Resolve(client, c.CharmURL)
if err != nil {
return errors.Annotatef(err, "failed to resolve charmURL %v", c.CharmURL)
}
c.CharmURL = resolvedURL
apiRoot, err := rcmd.GetMeteringURLForControllerCmd(&c.ControllerCommandBase)
if err != nil {
return errors.Trace(err)
}
apiClient, err := newClient(apiRoot, client)
if err != nil {
return errors.Annotate(err, "failed to create a plan API client")
}
plans, err := apiClient.GetAssociatedPlans(c.CharmURL)
if err != nil {
return errors.Annotate(err, "failed to retrieve plans")
}
output := make([]plan, len(plans))
for i, p := range plans {
outputPlan := plan{
URL: p.URL,
}
def, err := readPlan(bytes.NewBufferString(p.Definition))
if err != nil {
return errors.Annotate(err, "failed to parse plan definition")
}
if def.Description != nil {
outputPlan.Price = def.Description.Price
outputPlan.Description = def.Description.Text
}
output[i] = outputPlan
}
if len(output) == 0 && c.out.Name() == "tabular" {
ctx.Infof("No plans to display.")
}
err = c.out.Write(ctx, output)
if err != nil {
return errors.Trace(err)
}
return nil
} | [
"func",
"(",
"c",
"*",
"ListPlansCommand",
")",
"Run",
"(",
"ctx",
"*",
"cmd",
".",
"Context",
")",
"(",
"rErr",
"error",
")",
"{",
"client",
",",
"err",
":=",
"c",
".",
"BakeryClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"er... | // Run implements Command.Run.
// Retrieves the plan from the plans service. The set of plans to be
// retrieved can be limited using the plan and isv flags. | [
"Run",
"implements",
"Command",
".",
"Run",
".",
"Retrieves",
"the",
"plan",
"from",
"the",
"plans",
"service",
".",
"The",
"set",
"of",
"plans",
"to",
"be",
"retrieved",
"can",
"be",
"limited",
"using",
"the",
"plan",
"and",
"isv",
"flags",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/romulus/listplans/list_plans.go#L100-L156 | train |
juju/juju | cmd/juju/romulus/listplans/list_plans.go | formatSummary | func formatSummary(writer io.Writer, value interface{}) error {
plans, ok := value.([]plan)
if !ok {
return errors.Errorf("expected value of type %T, got %T", plans, value)
}
tw := output.TabWriter(writer)
p := func(values ...interface{}) {
for _, v := range values {
fmt.Fprintf(tw, "%s\t", v)
}
fmt.Fprintln(tw)
}
p("Plan", "Price")
for _, plan := range plans {
p(plan.URL, plan.Price)
}
tw.Flush()
return nil
} | go | func formatSummary(writer io.Writer, value interface{}) error {
plans, ok := value.([]plan)
if !ok {
return errors.Errorf("expected value of type %T, got %T", plans, value)
}
tw := output.TabWriter(writer)
p := func(values ...interface{}) {
for _, v := range values {
fmt.Fprintf(tw, "%s\t", v)
}
fmt.Fprintln(tw)
}
p("Plan", "Price")
for _, plan := range plans {
p(plan.URL, plan.Price)
}
tw.Flush()
return nil
} | [
"func",
"formatSummary",
"(",
"writer",
"io",
".",
"Writer",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"plans",
",",
"ok",
":=",
"value",
".",
"(",
"[",
"]",
"plan",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"errors",
".",
"Errorf",
... | // formatSummary returns a summary of available plans. | [
"formatSummary",
"returns",
"a",
"summary",
"of",
"available",
"plans",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/romulus/listplans/list_plans.go#L165-L183 | train |
juju/juju | cmd/juju/romulus/listplans/list_plans.go | formatTabular | func formatTabular(writer io.Writer, value interface{}) error {
plans, ok := value.([]plan)
if !ok {
return errors.Errorf("expected value of type %T, got %T", plans, value)
}
table := uitable.New()
table.MaxColWidth = 50
table.Wrap = true
table.AddRow("Plan", "Price", "Description")
for _, plan := range plans {
table.AddRow(plan.URL, plan.Price, plan.Description)
}
fmt.Fprint(writer, table)
return nil
} | go | func formatTabular(writer io.Writer, value interface{}) error {
plans, ok := value.([]plan)
if !ok {
return errors.Errorf("expected value of type %T, got %T", plans, value)
}
table := uitable.New()
table.MaxColWidth = 50
table.Wrap = true
table.AddRow("Plan", "Price", "Description")
for _, plan := range plans {
table.AddRow(plan.URL, plan.Price, plan.Description)
}
fmt.Fprint(writer, table)
return nil
} | [
"func",
"formatTabular",
"(",
"writer",
"io",
".",
"Writer",
",",
"value",
"interface",
"{",
"}",
")",
"error",
"{",
"plans",
",",
"ok",
":=",
"value",
".",
"(",
"[",
"]",
"plan",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"errors",
".",
"Errorf",
... | // formatTabular returns a tabular summary of available plans. | [
"formatTabular",
"returns",
"a",
"tabular",
"summary",
"of",
"available",
"plans",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/romulus/listplans/list_plans.go#L186-L202 | train |
juju/juju | cmd/juju/romulus/listplans/list_plans.go | readPlan | func readPlan(r io.Reader) (plan *planModel, err error) {
data, err := ioutil.ReadAll(r)
if err != nil {
return
}
var doc planModel
err = yaml.Unmarshal(data, &doc)
if err != nil {
return
}
return &doc, nil
} | go | func readPlan(r io.Reader) (plan *planModel, err error) {
data, err := ioutil.ReadAll(r)
if err != nil {
return
}
var doc planModel
err = yaml.Unmarshal(data, &doc)
if err != nil {
return
}
return &doc, nil
} | [
"func",
"readPlan",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"plan",
"*",
"planModel",
",",
"err",
"error",
")",
"{",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\n",
"}",
"... | // readPlan reads, parses and returns a planModel struct representation. | [
"readPlan",
"reads",
"parses",
"and",
"returns",
"a",
"planModel",
"struct",
"representation",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/romulus/listplans/list_plans.go#L215-L227 | train |
juju/juju | caas/kubernetes/provider/mocks/appv1_mock.go | NewMockAppsV1Interface | func NewMockAppsV1Interface(ctrl *gomock.Controller) *MockAppsV1Interface {
mock := &MockAppsV1Interface{ctrl: ctrl}
mock.recorder = &MockAppsV1InterfaceMockRecorder{mock}
return mock
} | go | func NewMockAppsV1Interface(ctrl *gomock.Controller) *MockAppsV1Interface {
mock := &MockAppsV1Interface{ctrl: ctrl}
mock.recorder = &MockAppsV1InterfaceMockRecorder{mock}
return mock
} | [
"func",
"NewMockAppsV1Interface",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockAppsV1Interface",
"{",
"mock",
":=",
"&",
"MockAppsV1Interface",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockAppsV1InterfaceMockRecor... | // NewMockAppsV1Interface creates a new mock instance | [
"NewMockAppsV1Interface",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/appv1_mock.go#L31-L35 | train |
juju/juju | caas/kubernetes/provider/mocks/appv1_mock.go | ControllerRevisions | func (m *MockAppsV1Interface) ControllerRevisions(arg0 string) v11.ControllerRevisionInterface {
ret := m.ctrl.Call(m, "ControllerRevisions", arg0)
ret0, _ := ret[0].(v11.ControllerRevisionInterface)
return ret0
} | go | func (m *MockAppsV1Interface) ControllerRevisions(arg0 string) v11.ControllerRevisionInterface {
ret := m.ctrl.Call(m, "ControllerRevisions", arg0)
ret0, _ := ret[0].(v11.ControllerRevisionInterface)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAppsV1Interface",
")",
"ControllerRevisions",
"(",
"arg0",
"string",
")",
"v11",
".",
"ControllerRevisionInterface",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
... | // ControllerRevisions mocks base method | [
"ControllerRevisions",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/appv1_mock.go#L43-L47 | train |
juju/juju | caas/kubernetes/provider/mocks/appv1_mock.go | ControllerRevisions | func (mr *MockAppsV1InterfaceMockRecorder) ControllerRevisions(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ControllerRevisions", reflect.TypeOf((*MockAppsV1Interface)(nil).ControllerRevisions), arg0)
} | go | func (mr *MockAppsV1InterfaceMockRecorder) ControllerRevisions(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ControllerRevisions", reflect.TypeOf((*MockAppsV1Interface)(nil).ControllerRevisions), arg0)
} | [
"func",
"(",
"mr",
"*",
"MockAppsV1InterfaceMockRecorder",
")",
"ControllerRevisions",
"(",
"arg0",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock"... | // ControllerRevisions indicates an expected call of ControllerRevisions | [
"ControllerRevisions",
"indicates",
"an",
"expected",
"call",
"of",
"ControllerRevisions"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/appv1_mock.go#L50-L52 | train |
juju/juju | caas/kubernetes/provider/mocks/appv1_mock.go | StatefulSets | func (m *MockAppsV1Interface) StatefulSets(arg0 string) v11.StatefulSetInterface {
ret := m.ctrl.Call(m, "StatefulSets", arg0)
ret0, _ := ret[0].(v11.StatefulSetInterface)
return ret0
} | go | func (m *MockAppsV1Interface) StatefulSets(arg0 string) v11.StatefulSetInterface {
ret := m.ctrl.Call(m, "StatefulSets", arg0)
ret0, _ := ret[0].(v11.StatefulSetInterface)
return ret0
} | [
"func",
"(",
"m",
"*",
"MockAppsV1Interface",
")",
"StatefulSets",
"(",
"arg0",
"string",
")",
"v11",
".",
"StatefulSetInterface",
"{",
"ret",
":=",
"m",
".",
"ctrl",
".",
"Call",
"(",
"m",
",",
"\"",
"\"",
",",
"arg0",
")",
"\n",
"ret0",
",",
"_",
... | // StatefulSets mocks base method | [
"StatefulSets",
"mocks",
"base",
"method"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/appv1_mock.go#L103-L107 | train |
juju/juju | caas/kubernetes/provider/mocks/appv1_mock.go | NewMockDeploymentInterface | func NewMockDeploymentInterface(ctrl *gomock.Controller) *MockDeploymentInterface {
mock := &MockDeploymentInterface{ctrl: ctrl}
mock.recorder = &MockDeploymentInterfaceMockRecorder{mock}
return mock
} | go | func NewMockDeploymentInterface(ctrl *gomock.Controller) *MockDeploymentInterface {
mock := &MockDeploymentInterface{ctrl: ctrl}
mock.recorder = &MockDeploymentInterfaceMockRecorder{mock}
return mock
} | [
"func",
"NewMockDeploymentInterface",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockDeploymentInterface",
"{",
"mock",
":=",
"&",
"MockDeploymentInterface",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockDeploymentIn... | // NewMockDeploymentInterface creates a new mock instance | [
"NewMockDeploymentInterface",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/appv1_mock.go#L126-L130 | train |
juju/juju | caas/kubernetes/provider/mocks/appv1_mock.go | Watch | func (mr *MockDeploymentInterfaceMockRecorder) Watch(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Watch", reflect.TypeOf((*MockDeploymentInterface)(nil).Watch), arg0)
} | go | func (mr *MockDeploymentInterfaceMockRecorder) Watch(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Watch", reflect.TypeOf((*MockDeploymentInterface)(nil).Watch), arg0)
} | [
"func",
"(",
"mr",
"*",
"MockDeploymentInterfaceMockRecorder",
")",
"Watch",
"(",
"arg0",
"interface",
"{",
"}",
")",
"*",
"gomock",
".",
"Call",
"{",
"return",
"mr",
".",
"mock",
".",
"ctrl",
".",
"RecordCallWithMethodType",
"(",
"mr",
".",
"mock",
",",
... | // Watch indicates an expected call of Watch | [
"Watch",
"indicates",
"an",
"expected",
"call",
"of",
"Watch"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/appv1_mock.go#L253-L255 | train |
juju/juju | caas/kubernetes/provider/mocks/appv1_mock.go | NewMockStatefulSetInterface | func NewMockStatefulSetInterface(ctrl *gomock.Controller) *MockStatefulSetInterface {
mock := &MockStatefulSetInterface{ctrl: ctrl}
mock.recorder = &MockStatefulSetInterfaceMockRecorder{mock}
return mock
} | go | func NewMockStatefulSetInterface(ctrl *gomock.Controller) *MockStatefulSetInterface {
mock := &MockStatefulSetInterface{ctrl: ctrl}
mock.recorder = &MockStatefulSetInterfaceMockRecorder{mock}
return mock
} | [
"func",
"NewMockStatefulSetInterface",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockStatefulSetInterface",
"{",
"mock",
":=",
"&",
"MockStatefulSetInterface",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockStatefulS... | // NewMockStatefulSetInterface creates a new mock instance | [
"NewMockStatefulSetInterface",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/appv1_mock.go#L269-L273 | train |
juju/juju | rpc/rpcreflect/value.go | ValueOf | func ValueOf(rootValue reflect.Value) Value {
if !rootValue.IsValid() {
return Value{}
}
return Value{
rootValue: rootValue,
rootType: TypeOf(rootValue.Type()),
}
} | go | func ValueOf(rootValue reflect.Value) Value {
if !rootValue.IsValid() {
return Value{}
}
return Value{
rootValue: rootValue,
rootType: TypeOf(rootValue.Type()),
}
} | [
"func",
"ValueOf",
"(",
"rootValue",
"reflect",
".",
"Value",
")",
"Value",
"{",
"if",
"!",
"rootValue",
".",
"IsValid",
"(",
")",
"{",
"return",
"Value",
"{",
"}",
"\n",
"}",
"\n",
"return",
"Value",
"{",
"rootValue",
":",
"rootValue",
",",
"rootType"... | // ValueOf returns a value that can be used to call RPC-style
// methods on the given root value. It returns the zero
// Value if rootValue.IsValid is false. | [
"ValueOf",
"returns",
"a",
"value",
"that",
"can",
"be",
"used",
"to",
"call",
"RPC",
"-",
"style",
"methods",
"on",
"the",
"given",
"root",
"value",
".",
"It",
"returns",
"the",
"zero",
"Value",
"if",
"rootValue",
".",
"IsValid",
"is",
"false",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/rpcreflect/value.go#L56-L64 | train |
juju/juju | rpc/rpcreflect/value.go | FindMethod | func (v Value) FindMethod(rootMethodName string, version int, objMethodName string) (MethodCaller, error) {
if !v.IsValid() {
panic("FindMethod called on invalid Value")
}
caller := methodCaller{
rootValue: v.rootValue,
}
var err error
caller.rootMethod, err = v.rootType.Method(rootMethodName)
if err != nil {
return nil, &CallNotImplementedError{
RootMethod: rootMethodName,
}
}
caller.objMethod, err = caller.rootMethod.ObjType.Method(objMethodName)
if err != nil {
return nil, &CallNotImplementedError{
RootMethod: rootMethodName,
Method: objMethodName,
}
}
return caller, nil
} | go | func (v Value) FindMethod(rootMethodName string, version int, objMethodName string) (MethodCaller, error) {
if !v.IsValid() {
panic("FindMethod called on invalid Value")
}
caller := methodCaller{
rootValue: v.rootValue,
}
var err error
caller.rootMethod, err = v.rootType.Method(rootMethodName)
if err != nil {
return nil, &CallNotImplementedError{
RootMethod: rootMethodName,
}
}
caller.objMethod, err = caller.rootMethod.ObjType.Method(objMethodName)
if err != nil {
return nil, &CallNotImplementedError{
RootMethod: rootMethodName,
Method: objMethodName,
}
}
return caller, nil
} | [
"func",
"(",
"v",
"Value",
")",
"FindMethod",
"(",
"rootMethodName",
"string",
",",
"version",
"int",
",",
"objMethodName",
"string",
")",
"(",
"MethodCaller",
",",
"error",
")",
"{",
"if",
"!",
"v",
".",
"IsValid",
"(",
")",
"{",
"panic",
"(",
"\"",
... | // FindMethod returns an object that can be used to make calls on
// the given root value to the given root method and object method.
// It returns an error if either the root method or the object
// method were not found.
// It panics if called on the zero Value.
// The version argument is ignored - all versions will find
// the same method. | [
"FindMethod",
"returns",
"an",
"object",
"that",
"can",
"be",
"used",
"to",
"make",
"calls",
"on",
"the",
"given",
"root",
"value",
"to",
"the",
"given",
"root",
"method",
"and",
"object",
"method",
".",
"It",
"returns",
"an",
"error",
"if",
"either",
"t... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/rpcreflect/value.go#L83-L105 | train |
juju/juju | rpc/rpcreflect/value.go | Kill | func (v Value) Kill() {
if killer, ok := v.rootValue.Interface().(killer); ok {
killer.Kill()
}
} | go | func (v Value) Kill() {
if killer, ok := v.rootValue.Interface().(killer); ok {
killer.Kill()
}
} | [
"func",
"(",
"v",
"Value",
")",
"Kill",
"(",
")",
"{",
"if",
"killer",
",",
"ok",
":=",
"v",
".",
"rootValue",
".",
"Interface",
"(",
")",
".",
"(",
"killer",
")",
";",
"ok",
"{",
"killer",
".",
"Kill",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // Kill implements rpc.Killer.Kill by calling Kill on the root
// value if it implements Killer. | [
"Kill",
"implements",
"rpc",
".",
"Killer",
".",
"Kill",
"by",
"calling",
"Kill",
"on",
"the",
"root",
"value",
"if",
"it",
"implements",
"Killer",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/rpc/rpcreflect/value.go#L115-L119 | train |
juju/juju | worker/uniter/agent.go | setAgentStatus | func setAgentStatus(u *Uniter, agentStatus status.Status, info string, data map[string]interface{}) error {
u.setStatusMutex.Lock()
defer u.setStatusMutex.Unlock()
if u.lastReportedStatus == agentStatus && u.lastReportedMessage == info {
return nil
}
u.lastReportedStatus = agentStatus
u.lastReportedMessage = info
logger.Debugf("[AGENT-STATUS] %s: %s", agentStatus, info)
return u.unit.SetAgentStatus(agentStatus, info, data)
} | go | func setAgentStatus(u *Uniter, agentStatus status.Status, info string, data map[string]interface{}) error {
u.setStatusMutex.Lock()
defer u.setStatusMutex.Unlock()
if u.lastReportedStatus == agentStatus && u.lastReportedMessage == info {
return nil
}
u.lastReportedStatus = agentStatus
u.lastReportedMessage = info
logger.Debugf("[AGENT-STATUS] %s: %s", agentStatus, info)
return u.unit.SetAgentStatus(agentStatus, info, data)
} | [
"func",
"setAgentStatus",
"(",
"u",
"*",
"Uniter",
",",
"agentStatus",
"status",
".",
"Status",
",",
"info",
"string",
",",
"data",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"error",
"{",
"u",
".",
"setStatusMutex",
".",
"Lock",
"(",
")",
... | // setAgentStatus sets the unit's status if it has changed since last time this method was called. | [
"setAgentStatus",
"sets",
"the",
"unit",
"s",
"status",
"if",
"it",
"has",
"changed",
"since",
"last",
"time",
"this",
"method",
"was",
"called",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/agent.go#L12-L22 | train |
juju/juju | worker/uniter/agent.go | reportAgentError | func reportAgentError(u *Uniter, userMessage string, err error) {
// If a non-nil error is reported (e.g. due to an operation failing),
// set the agent status to Failed.
if err == nil {
return
}
logger.Errorf("%s: %v", userMessage, err)
err2 := setAgentStatus(u, status.Failed, userMessage, nil)
if err2 != nil {
logger.Errorf("updating agent status: %v", err2)
}
} | go | func reportAgentError(u *Uniter, userMessage string, err error) {
// If a non-nil error is reported (e.g. due to an operation failing),
// set the agent status to Failed.
if err == nil {
return
}
logger.Errorf("%s: %v", userMessage, err)
err2 := setAgentStatus(u, status.Failed, userMessage, nil)
if err2 != nil {
logger.Errorf("updating agent status: %v", err2)
}
} | [
"func",
"reportAgentError",
"(",
"u",
"*",
"Uniter",
",",
"userMessage",
"string",
",",
"err",
"error",
")",
"{",
"// If a non-nil error is reported (e.g. due to an operation failing),",
"// set the agent status to Failed.",
"if",
"err",
"==",
"nil",
"{",
"return",
"\n",
... | // reportAgentError reports if there was an error performing an agent operation. | [
"reportAgentError",
"reports",
"if",
"there",
"was",
"an",
"error",
"performing",
"an",
"agent",
"operation",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/agent.go#L25-L36 | train |
juju/juju | worker/uniter/agent.go | setUpgradeSeriesStatus | func setUpgradeSeriesStatus(u *Uniter, status model.UpgradeSeriesStatus, reason string) error {
return u.unit.SetUpgradeSeriesStatus(status, reason)
} | go | func setUpgradeSeriesStatus(u *Uniter, status model.UpgradeSeriesStatus, reason string) error {
return u.unit.SetUpgradeSeriesStatus(status, reason)
} | [
"func",
"setUpgradeSeriesStatus",
"(",
"u",
"*",
"Uniter",
",",
"status",
"model",
".",
"UpgradeSeriesStatus",
",",
"reason",
"string",
")",
"error",
"{",
"return",
"u",
".",
"unit",
".",
"SetUpgradeSeriesStatus",
"(",
"status",
",",
"reason",
")",
"\n",
"}"... | // setUpgradeSeriesStatus sets the upgrade series status. | [
"setUpgradeSeriesStatus",
"sets",
"the",
"upgrade",
"series",
"status",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/agent.go#L39-L41 | train |
juju/juju | caas/kubernetes/provider/k8stypes.go | parseK8sPodSpec | func parseK8sPodSpec(in string) (*caas.PodSpec, error) {
// Do the common fields.
var spec caas.PodSpec
if err := yaml.Unmarshal([]byte(in), &spec); err != nil {
return nil, errors.Trace(err)
}
// Do the k8s pod attributes.
var pod k8sPod
decoder := k8syaml.NewYAMLOrJSONDecoder(strings.NewReader(in), len(in))
if err := decoder.Decode(&pod); err != nil {
return nil, errors.Trace(err)
}
if pod.K8sPodSpec != nil {
spec.ProviderPod = pod.K8sPodSpec
}
// Do the k8s containers.
var containers k8sContainers
decoder = k8syaml.NewYAMLOrJSONDecoder(strings.NewReader(in), len(in))
if err := decoder.Decode(&containers); err != nil {
return nil, errors.Trace(err)
}
if len(containers.Containers) == 0 {
return nil, errors.New("require at least one container spec")
}
quoteBoolStrings(containers.Containers)
quoteBoolStrings(containers.InitContainers)
// Compose the result.
spec.Containers = make([]caas.ContainerSpec, len(containers.Containers))
for i, c := range containers.Containers {
if err := c.Validate(); err != nil {
return nil, errors.Trace(err)
}
spec.Containers[i] = containerFromK8sSpec(c)
}
spec.InitContainers = make([]caas.ContainerSpec, len(containers.InitContainers))
for i, c := range containers.InitContainers {
if err := c.Validate(); err != nil {
return nil, errors.Trace(err)
}
spec.InitContainers[i] = containerFromK8sSpec(c)
}
spec.CustomResourceDefinitions = containers.CustomResourceDefinitions
return &spec, nil
} | go | func parseK8sPodSpec(in string) (*caas.PodSpec, error) {
// Do the common fields.
var spec caas.PodSpec
if err := yaml.Unmarshal([]byte(in), &spec); err != nil {
return nil, errors.Trace(err)
}
// Do the k8s pod attributes.
var pod k8sPod
decoder := k8syaml.NewYAMLOrJSONDecoder(strings.NewReader(in), len(in))
if err := decoder.Decode(&pod); err != nil {
return nil, errors.Trace(err)
}
if pod.K8sPodSpec != nil {
spec.ProviderPod = pod.K8sPodSpec
}
// Do the k8s containers.
var containers k8sContainers
decoder = k8syaml.NewYAMLOrJSONDecoder(strings.NewReader(in), len(in))
if err := decoder.Decode(&containers); err != nil {
return nil, errors.Trace(err)
}
if len(containers.Containers) == 0 {
return nil, errors.New("require at least one container spec")
}
quoteBoolStrings(containers.Containers)
quoteBoolStrings(containers.InitContainers)
// Compose the result.
spec.Containers = make([]caas.ContainerSpec, len(containers.Containers))
for i, c := range containers.Containers {
if err := c.Validate(); err != nil {
return nil, errors.Trace(err)
}
spec.Containers[i] = containerFromK8sSpec(c)
}
spec.InitContainers = make([]caas.ContainerSpec, len(containers.InitContainers))
for i, c := range containers.InitContainers {
if err := c.Validate(); err != nil {
return nil, errors.Trace(err)
}
spec.InitContainers[i] = containerFromK8sSpec(c)
}
spec.CustomResourceDefinitions = containers.CustomResourceDefinitions
return &spec, nil
} | [
"func",
"parseK8sPodSpec",
"(",
"in",
"string",
")",
"(",
"*",
"caas",
".",
"PodSpec",
",",
"error",
")",
"{",
"// Do the common fields.",
"var",
"spec",
"caas",
".",
"PodSpec",
"\n",
"if",
"err",
":=",
"yaml",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
... | // parseK8sPodSpec parses a YAML file which defines how to
// configure a CAAS pod. We allow for generic container
// set up plus k8s select specific features. | [
"parseK8sPodSpec",
"parses",
"a",
"YAML",
"file",
"which",
"defines",
"how",
"to",
"configure",
"a",
"CAAS",
"pod",
".",
"We",
"allow",
"for",
"generic",
"container",
"set",
"up",
"plus",
"k8s",
"select",
"specific",
"features",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/k8stypes.go#L90-L137 | train |
juju/juju | worker/toolsversionchecker/manifold.go | Manifold | func Manifold(config ManifoldConfig) dependency.Manifold {
typedConfig := engine.AgentAPIManifoldConfig(config)
return engine.AgentAPIManifold(typedConfig, newWorker)
} | go | func Manifold(config ManifoldConfig) dependency.Manifold {
typedConfig := engine.AgentAPIManifoldConfig(config)
return engine.AgentAPIManifold(typedConfig, newWorker)
} | [
"func",
"Manifold",
"(",
"config",
"ManifoldConfig",
")",
"dependency",
".",
"Manifold",
"{",
"typedConfig",
":=",
"engine",
".",
"AgentAPIManifoldConfig",
"(",
"config",
")",
"\n",
"return",
"engine",
".",
"AgentAPIManifold",
"(",
"typedConfig",
",",
"newWorker",... | // Manifold returns a dependency manifold that runs a toolsversionchecker worker,
// using the api connection resource named in the supplied config. | [
"Manifold",
"returns",
"a",
"dependency",
"manifold",
"that",
"runs",
"a",
"toolsversionchecker",
"worker",
"using",
"the",
"api",
"connection",
"resource",
"named",
"in",
"the",
"supplied",
"config",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/toolsversionchecker/manifold.go#L27-L30 | train |
juju/juju | state/annotations.go | Annotations | func (m *Model) Annotations(entity GlobalEntity) (map[string]string, error) {
doc := new(annotatorDoc)
annotations, closer := m.st.db().GetCollection(annotationsC)
defer closer()
err := annotations.FindId(entity.globalKey()).One(doc)
if err == mgo.ErrNotFound {
// Returning an empty map if there are no annotations.
return make(map[string]string), nil
}
if err != nil {
return nil, errors.Trace(err)
}
return doc.Annotations, nil
} | go | func (m *Model) Annotations(entity GlobalEntity) (map[string]string, error) {
doc := new(annotatorDoc)
annotations, closer := m.st.db().GetCollection(annotationsC)
defer closer()
err := annotations.FindId(entity.globalKey()).One(doc)
if err == mgo.ErrNotFound {
// Returning an empty map if there are no annotations.
return make(map[string]string), nil
}
if err != nil {
return nil, errors.Trace(err)
}
return doc.Annotations, nil
} | [
"func",
"(",
"m",
"*",
"Model",
")",
"Annotations",
"(",
"entity",
"GlobalEntity",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"doc",
":=",
"new",
"(",
"annotatorDoc",
")",
"\n",
"annotations",
",",
"closer",
":=",
"m",
"."... | // Annotations returns all the annotations corresponding to an entity. | [
"Annotations",
"returns",
"all",
"the",
"annotations",
"corresponding",
"to",
"an",
"entity",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/annotations.go#L74-L87 | train |
juju/juju | state/annotations.go | Annotation | func (m *Model) Annotation(entity GlobalEntity, key string) (string, error) {
ann, err := m.Annotations(entity)
if err != nil {
return "", errors.Trace(err)
}
return ann[key], nil
} | go | func (m *Model) Annotation(entity GlobalEntity, key string) (string, error) {
ann, err := m.Annotations(entity)
if err != nil {
return "", errors.Trace(err)
}
return ann[key], nil
} | [
"func",
"(",
"m",
"*",
"Model",
")",
"Annotation",
"(",
"entity",
"GlobalEntity",
",",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"ann",
",",
"err",
":=",
"m",
".",
"Annotations",
"(",
"entity",
")",
"\n",
"if",
"err",
"!=",
"nil"... | // Annotation returns the annotation value corresponding to the given key.
// If the requested annotation is not found, an empty string is returned. | [
"Annotation",
"returns",
"the",
"annotation",
"value",
"corresponding",
"to",
"the",
"given",
"key",
".",
"If",
"the",
"requested",
"annotation",
"is",
"not",
"found",
"an",
"empty",
"string",
"is",
"returned",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/annotations.go#L91-L97 | train |
juju/juju | state/annotations.go | insertAnnotationsOps | func insertAnnotationsOps(st *State, entity GlobalEntity, toInsert map[string]string) ([]txn.Op, error) {
tag := entity.Tag()
ops := []txn.Op{{
C: annotationsC,
Id: st.docID(entity.globalKey()),
Assert: txn.DocMissing,
Insert: &annotatorDoc{
GlobalKey: entity.globalKey(),
Tag: tag.String(),
Annotations: toInsert,
},
}}
switch tag := tag.(type) {
case names.ModelTag:
if tag.Id() == st.ControllerModelUUID() {
// This is the controller model, and cannot be removed.
// Ergo, we can skip the existence check below.
return ops, nil
}
}
// If the entity is not the controller model, add a DocExists check on the
// entity document, in order to avoid possible races between entity
// removal and annotation creation.
coll, id, err := st.tagToCollectionAndId(tag)
if err != nil {
return nil, errors.Trace(err)
}
return append(ops, txn.Op{
C: coll,
Id: id,
Assert: txn.DocExists,
}), nil
} | go | func insertAnnotationsOps(st *State, entity GlobalEntity, toInsert map[string]string) ([]txn.Op, error) {
tag := entity.Tag()
ops := []txn.Op{{
C: annotationsC,
Id: st.docID(entity.globalKey()),
Assert: txn.DocMissing,
Insert: &annotatorDoc{
GlobalKey: entity.globalKey(),
Tag: tag.String(),
Annotations: toInsert,
},
}}
switch tag := tag.(type) {
case names.ModelTag:
if tag.Id() == st.ControllerModelUUID() {
// This is the controller model, and cannot be removed.
// Ergo, we can skip the existence check below.
return ops, nil
}
}
// If the entity is not the controller model, add a DocExists check on the
// entity document, in order to avoid possible races between entity
// removal and annotation creation.
coll, id, err := st.tagToCollectionAndId(tag)
if err != nil {
return nil, errors.Trace(err)
}
return append(ops, txn.Op{
C: coll,
Id: id,
Assert: txn.DocExists,
}), nil
} | [
"func",
"insertAnnotationsOps",
"(",
"st",
"*",
"State",
",",
"entity",
"GlobalEntity",
",",
"toInsert",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"tag",
":=",
"entity",
".",
"Tag",
"(",
")",
... | // insertAnnotationsOps returns the operations required to insert annotations in MongoDB. | [
"insertAnnotationsOps",
"returns",
"the",
"operations",
"required",
"to",
"insert",
"annotations",
"in",
"MongoDB",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/annotations.go#L100-L134 | train |
juju/juju | state/annotations.go | updateAnnotations | func updateAnnotations(mb modelBackend, entity GlobalEntity, toUpdate, toRemove bson.M) []txn.Op {
return []txn.Op{{
C: annotationsC,
Id: mb.docID(entity.globalKey()),
Assert: txn.DocExists,
Update: setUnsetUpdateAnnotations(toUpdate, toRemove),
}}
} | go | func updateAnnotations(mb modelBackend, entity GlobalEntity, toUpdate, toRemove bson.M) []txn.Op {
return []txn.Op{{
C: annotationsC,
Id: mb.docID(entity.globalKey()),
Assert: txn.DocExists,
Update: setUnsetUpdateAnnotations(toUpdate, toRemove),
}}
} | [
"func",
"updateAnnotations",
"(",
"mb",
"modelBackend",
",",
"entity",
"GlobalEntity",
",",
"toUpdate",
",",
"toRemove",
"bson",
".",
"M",
")",
"[",
"]",
"txn",
".",
"Op",
"{",
"return",
"[",
"]",
"txn",
".",
"Op",
"{",
"{",
"C",
":",
"annotationsC",
... | // updateAnnotations returns the operations required to update or remove annotations in MongoDB. | [
"updateAnnotations",
"returns",
"the",
"operations",
"required",
"to",
"update",
"or",
"remove",
"annotations",
"in",
"MongoDB",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/annotations.go#L137-L144 | train |
juju/juju | state/annotations.go | annotationRemoveOp | func annotationRemoveOp(mb modelBackend, id string) txn.Op {
return txn.Op{
C: annotationsC,
Id: mb.docID(id),
Remove: true,
}
} | go | func annotationRemoveOp(mb modelBackend, id string) txn.Op {
return txn.Op{
C: annotationsC,
Id: mb.docID(id),
Remove: true,
}
} | [
"func",
"annotationRemoveOp",
"(",
"mb",
"modelBackend",
",",
"id",
"string",
")",
"txn",
".",
"Op",
"{",
"return",
"txn",
".",
"Op",
"{",
"C",
":",
"annotationsC",
",",
"Id",
":",
"mb",
".",
"docID",
"(",
"id",
")",
",",
"Remove",
":",
"true",
","... | // annotationRemoveOp returns an operation to remove a given annotation
// document from MongoDB. | [
"annotationRemoveOp",
"returns",
"an",
"operation",
"to",
"remove",
"a",
"given",
"annotation",
"document",
"from",
"MongoDB",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/annotations.go#L148-L154 | train |
juju/juju | apiserver/facades/client/application/application.go | NewFacadeV4 | func NewFacadeV4(ctx facade.Context) (*APIv4, error) {
api, err := NewFacadeV5(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv4{api}, nil
} | go | func NewFacadeV4(ctx facade.Context) (*APIv4, error) {
api, err := NewFacadeV5(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv4{api}, nil
} | [
"func",
"NewFacadeV4",
"(",
"ctx",
"facade",
".",
"Context",
")",
"(",
"*",
"APIv4",
",",
"error",
")",
"{",
"api",
",",
"err",
":=",
"NewFacadeV5",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Trace",... | // NewFacadeV4 provides the signature required for facade registration
// for versions 1-4. | [
"NewFacadeV4",
"provides",
"the",
"signature",
"required",
"for",
"facade",
"registration",
"for",
"versions",
"1",
"-",
"4",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L111-L117 | train |
juju/juju | apiserver/facades/client/application/application.go | NewFacadeV5 | func NewFacadeV5(ctx facade.Context) (*APIv5, error) {
api, err := NewFacadeV6(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv5{api}, nil
} | go | func NewFacadeV5(ctx facade.Context) (*APIv5, error) {
api, err := NewFacadeV6(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv5{api}, nil
} | [
"func",
"NewFacadeV5",
"(",
"ctx",
"facade",
".",
"Context",
")",
"(",
"*",
"APIv5",
",",
"error",
")",
"{",
"api",
",",
"err",
":=",
"NewFacadeV6",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Trace",... | // NewFacadeV5 provides the signature required for facade registration
// for version 5. | [
"NewFacadeV5",
"provides",
"the",
"signature",
"required",
"for",
"facade",
"registration",
"for",
"version",
"5",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L121-L127 | train |
juju/juju | apiserver/facades/client/application/application.go | NewFacadeV6 | func NewFacadeV6(ctx facade.Context) (*APIv6, error) {
api, err := NewFacadeV7(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv6{api}, nil
} | go | func NewFacadeV6(ctx facade.Context) (*APIv6, error) {
api, err := NewFacadeV7(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv6{api}, nil
} | [
"func",
"NewFacadeV6",
"(",
"ctx",
"facade",
".",
"Context",
")",
"(",
"*",
"APIv6",
",",
"error",
")",
"{",
"api",
",",
"err",
":=",
"NewFacadeV7",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Trace",... | // NewFacadeV6 provides the signature required for facade registration
// for version 6. | [
"NewFacadeV6",
"provides",
"the",
"signature",
"required",
"for",
"facade",
"registration",
"for",
"version",
"6",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L131-L137 | train |
juju/juju | apiserver/facades/client/application/application.go | NewFacadeV7 | func NewFacadeV7(ctx facade.Context) (*APIv7, error) {
api, err := NewFacadeV8(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv7{api}, nil
} | go | func NewFacadeV7(ctx facade.Context) (*APIv7, error) {
api, err := NewFacadeV8(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv7{api}, nil
} | [
"func",
"NewFacadeV7",
"(",
"ctx",
"facade",
".",
"Context",
")",
"(",
"*",
"APIv7",
",",
"error",
")",
"{",
"api",
",",
"err",
":=",
"NewFacadeV8",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Trace",... | // NewFacadeV7 provides the signature required for facade registration
// for version 7. | [
"NewFacadeV7",
"provides",
"the",
"signature",
"required",
"for",
"facade",
"registration",
"for",
"version",
"7",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L141-L147 | train |
juju/juju | apiserver/facades/client/application/application.go | NewFacadeV8 | func NewFacadeV8(ctx facade.Context) (*APIv8, error) {
api, err := NewFacadeV9(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv8{api}, nil
} | go | func NewFacadeV8(ctx facade.Context) (*APIv8, error) {
api, err := NewFacadeV9(ctx)
if err != nil {
return nil, errors.Trace(err)
}
return &APIv8{api}, nil
} | [
"func",
"NewFacadeV8",
"(",
"ctx",
"facade",
".",
"Context",
")",
"(",
"*",
"APIv8",
",",
"error",
")",
"{",
"api",
",",
"err",
":=",
"NewFacadeV9",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"Trace",... | // NewFacadeV8 provides the signature required for facade registration
// for version 8. | [
"NewFacadeV8",
"provides",
"the",
"signature",
"required",
"for",
"facade",
"registration",
"for",
"version",
"8",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L151-L157 | train |
juju/juju | apiserver/facades/client/application/application.go | NewAPIBase | func NewAPIBase(
backend Backend,
storageAccess storageInterface,
authorizer facade.Authorizer,
blockChecker BlockChecker,
model Model,
stateCharm func(Charm) *state.Charm,
deployApplication func(ApplicationDeployer, DeployApplicationParams) (Application, error),
storagePoolManager poolmanager.PoolManager,
registry storage.ProviderRegistry,
resources facade.Resources,
storageValidator caas.StorageValidator,
) (*APIBase, error) {
if !authorizer.AuthClient() {
return nil, common.ErrPerm
}
return &APIBase{
backend: backend,
storageAccess: storageAccess,
authorizer: authorizer,
check: blockChecker,
model: model,
modelType: model.Type(),
stateCharm: stateCharm,
deployApplicationFunc: deployApplication,
storagePoolManager: storagePoolManager,
registry: registry,
resources: resources,
storageValidator: storageValidator,
}, nil
} | go | func NewAPIBase(
backend Backend,
storageAccess storageInterface,
authorizer facade.Authorizer,
blockChecker BlockChecker,
model Model,
stateCharm func(Charm) *state.Charm,
deployApplication func(ApplicationDeployer, DeployApplicationParams) (Application, error),
storagePoolManager poolmanager.PoolManager,
registry storage.ProviderRegistry,
resources facade.Resources,
storageValidator caas.StorageValidator,
) (*APIBase, error) {
if !authorizer.AuthClient() {
return nil, common.ErrPerm
}
return &APIBase{
backend: backend,
storageAccess: storageAccess,
authorizer: authorizer,
check: blockChecker,
model: model,
modelType: model.Type(),
stateCharm: stateCharm,
deployApplicationFunc: deployApplication,
storagePoolManager: storagePoolManager,
registry: registry,
resources: resources,
storageValidator: storageValidator,
}, nil
} | [
"func",
"NewAPIBase",
"(",
"backend",
"Backend",
",",
"storageAccess",
"storageInterface",
",",
"authorizer",
"facade",
".",
"Authorizer",
",",
"blockChecker",
"BlockChecker",
",",
"model",
"Model",
",",
"stateCharm",
"func",
"(",
"Charm",
")",
"*",
"state",
"."... | // NewAPIBase returns a new application API facade. | [
"NewAPIBase",
"returns",
"a",
"new",
"application",
"API",
"facade",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L211-L241 | train |
juju/juju | apiserver/facades/client/application/application.go | SetMetricCredentials | func (api *APIBase) SetMetricCredentials(args params.ApplicationMetricCredentials) (params.ErrorResults, error) {
if err := api.checkCanWrite(); err != nil {
return params.ErrorResults{}, errors.Trace(err)
}
result := params.ErrorResults{
Results: make([]params.ErrorResult, len(args.Creds)),
}
if len(args.Creds) == 0 {
return result, nil
}
for i, a := range args.Creds {
application, err := api.backend.Application(a.ApplicationName)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
err = application.SetMetricCredentials(a.MetricCredentials)
if err != nil {
result.Results[i].Error = common.ServerError(err)
}
}
return result, nil
} | go | func (api *APIBase) SetMetricCredentials(args params.ApplicationMetricCredentials) (params.ErrorResults, error) {
if err := api.checkCanWrite(); err != nil {
return params.ErrorResults{}, errors.Trace(err)
}
result := params.ErrorResults{
Results: make([]params.ErrorResult, len(args.Creds)),
}
if len(args.Creds) == 0 {
return result, nil
}
for i, a := range args.Creds {
application, err := api.backend.Application(a.ApplicationName)
if err != nil {
result.Results[i].Error = common.ServerError(err)
continue
}
err = application.SetMetricCredentials(a.MetricCredentials)
if err != nil {
result.Results[i].Error = common.ServerError(err)
}
}
return result, nil
} | [
"func",
"(",
"api",
"*",
"APIBase",
")",
"SetMetricCredentials",
"(",
"args",
"params",
".",
"ApplicationMetricCredentials",
")",
"(",
"params",
".",
"ErrorResults",
",",
"error",
")",
"{",
"if",
"err",
":=",
"api",
".",
"checkCanWrite",
"(",
")",
";",
"er... | // SetMetricCredentials sets credentials on the application. | [
"SetMetricCredentials",
"sets",
"credentials",
"on",
"the",
"application",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/application/application.go#L263-L285 | 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.