id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
157,700 | juju/juju | state/application.go | SetAgentPresence | func (a *Application) SetAgentPresence() (*presence.Pinger, error) {
presenceCollection := a.st.getPresenceCollection()
recorder := a.st.getPingBatcher()
m, err := a.st.Model()
if err != nil {
return nil, errors.Trace(err)
}
p := presence.NewPinger(presenceCollection, m.ModelTag(), a.globalKey(),
func() prese... | go | func (a *Application) SetAgentPresence() (*presence.Pinger, error) {
presenceCollection := a.st.getPresenceCollection()
recorder := a.st.getPingBatcher()
m, err := a.st.Model()
if err != nil {
return nil, errors.Trace(err)
}
p := presence.NewPinger(presenceCollection, m.ModelTag(), a.globalKey(),
func() prese... | [
"func",
"(",
"a",
"*",
"Application",
")",
"SetAgentPresence",
"(",
")",
"(",
"*",
"presence",
".",
"Pinger",
",",
"error",
")",
"{",
"presenceCollection",
":=",
"a",
".",
"st",
".",
"getPresenceCollection",
"(",
")",
"\n",
"recorder",
":=",
"a",
".",
... | // SetAgentPresence signals that the agent for application a is alive.
// It returns the started pinger. | [
"SetAgentPresence",
"signals",
"that",
"the",
"agent",
"for",
"application",
"a",
"is",
"alive",
".",
"It",
"returns",
"the",
"started",
"pinger",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/application.go#L2982-L2998 |
157,701 | juju/juju | state/application.go | UpdateCloudService | func (a *Application) UpdateCloudService(providerId string, addresses []network.Address) error {
_, err := a.st.SaveCloudService(SaveCloudServiceArgs{
Id: a.Name(),
ProviderId: providerId,
Addresses: addresses,
})
return errors.Trace(err)
} | go | func (a *Application) UpdateCloudService(providerId string, addresses []network.Address) error {
_, err := a.st.SaveCloudService(SaveCloudServiceArgs{
Id: a.Name(),
ProviderId: providerId,
Addresses: addresses,
})
return errors.Trace(err)
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"UpdateCloudService",
"(",
"providerId",
"string",
",",
"addresses",
"[",
"]",
"network",
".",
"Address",
")",
"error",
"{",
"_",
",",
"err",
":=",
"a",
".",
"st",
".",
"SaveCloudService",
"(",
"SaveCloudServiceAr... | // UpdateCloudService updates the cloud service details for the application. | [
"UpdateCloudService",
"updates",
"the",
"cloud",
"service",
"details",
"for",
"the",
"application",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/application.go#L3001-L3008 |
157,702 | juju/juju | state/application.go | ServiceInfo | func (a *Application) ServiceInfo() (CloudService, error) {
svc, err := a.st.CloudService(a.Name())
if err != nil {
return CloudService{}, errors.Trace(err)
}
return *svc, nil
} | go | func (a *Application) ServiceInfo() (CloudService, error) {
svc, err := a.st.CloudService(a.Name())
if err != nil {
return CloudService{}, errors.Trace(err)
}
return *svc, nil
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"ServiceInfo",
"(",
")",
"(",
"CloudService",
",",
"error",
")",
"{",
"svc",
",",
"err",
":=",
"a",
".",
"st",
".",
"CloudService",
"(",
"a",
".",
"Name",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // ServiceInfo returns information about this application's cloud service.
// This is only used for CAAS models. | [
"ServiceInfo",
"returns",
"information",
"about",
"this",
"application",
"s",
"cloud",
"service",
".",
"This",
"is",
"only",
"used",
"for",
"CAAS",
"models",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/application.go#L3012-L3018 |
157,703 | juju/juju | state/application.go | UnitNames | func (a *Application) UnitNames() ([]string, error) {
u, err := appUnitNames(a.st, a.Name())
return u, errors.Trace(err)
} | go | func (a *Application) UnitNames() ([]string, error) {
u, err := appUnitNames(a.st, a.Name())
return u, errors.Trace(err)
} | [
"func",
"(",
"a",
"*",
"Application",
")",
"UnitNames",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"u",
",",
"err",
":=",
"appUnitNames",
"(",
"a",
".",
"st",
",",
"a",
".",
"Name",
"(",
")",
")",
"\n",
"return",
"u",
",",
"er... | // UnitNames returns the of this application's units. | [
"UnitNames",
"returns",
"the",
"of",
"this",
"application",
"s",
"units",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/application.go#L3032-L3035 |
157,704 | juju/juju | apiserver/facades/client/modelgeneration/shim.go | Branch | func (g *modelShim) Branch(name string) (Generation, error) {
m, err := g.Model.Branch(name)
return m, errors.Trace(err)
} | go | func (g *modelShim) Branch(name string) (Generation, error) {
m, err := g.Model.Branch(name)
return m, errors.Trace(err)
} | [
"func",
"(",
"g",
"*",
"modelShim",
")",
"Branch",
"(",
"name",
"string",
")",
"(",
"Generation",
",",
"error",
")",
"{",
"m",
",",
"err",
":=",
"g",
".",
"Model",
".",
"Branch",
"(",
"name",
")",
"\n",
"return",
"m",
",",
"errors",
".",
"Trace",... | // Branch wraps the state model branch method,
// returning the locally defined Generation interface. | [
"Branch",
"wraps",
"the",
"state",
"model",
"branch",
"method",
"returning",
"the",
"locally",
"defined",
"Generation",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/modelgeneration/shim.go#L19-L22 |
157,705 | juju/juju | apiserver/facades/client/modelgeneration/shim.go | Branches | func (g *modelShim) Branches() ([]Generation, error) {
branches, err := g.Model.Branches()
if err != nil {
return nil, errors.Trace(err)
}
res := make([]Generation, len(branches))
for i, b := range branches {
res[i] = b
}
return res, nil
} | go | func (g *modelShim) Branches() ([]Generation, error) {
branches, err := g.Model.Branches()
if err != nil {
return nil, errors.Trace(err)
}
res := make([]Generation, len(branches))
for i, b := range branches {
res[i] = b
}
return res, nil
} | [
"func",
"(",
"g",
"*",
"modelShim",
")",
"Branches",
"(",
")",
"(",
"[",
"]",
"Generation",
",",
"error",
")",
"{",
"branches",
",",
"err",
":=",
"g",
".",
"Model",
".",
"Branches",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // Branches wraps the state model branches method,
// returning a collection of the Generation interface. | [
"Branches",
"wraps",
"the",
"state",
"model",
"branches",
"method",
"returning",
"a",
"collection",
"of",
"the",
"Generation",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/modelgeneration/shim.go#L26-L37 |
157,706 | juju/juju | apiserver/facades/client/modelgeneration/shim.go | DefaultCharmConfig | func (a *applicationShim) DefaultCharmConfig() (charm.Settings, error) {
ch, _, err := a.Charm()
if err != nil {
return nil, errors.Trace(err)
}
return ch.Config().DefaultSettings(), nil
} | go | func (a *applicationShim) DefaultCharmConfig() (charm.Settings, error) {
ch, _, err := a.Charm()
if err != nil {
return nil, errors.Trace(err)
}
return ch.Config().DefaultSettings(), nil
} | [
"func",
"(",
"a",
"*",
"applicationShim",
")",
"DefaultCharmConfig",
"(",
")",
"(",
"charm",
".",
"Settings",
",",
"error",
")",
"{",
"ch",
",",
"_",
",",
"err",
":=",
"a",
".",
"Charm",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"n... | // DefaultCharmConfig returns the default configuration
// for this application's charm. | [
"DefaultCharmConfig",
"returns",
"the",
"default",
"configuration",
"for",
"this",
"application",
"s",
"charm",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/modelgeneration/shim.go#L45-L51 |
157,707 | juju/juju | provider/joyent/environ_instance.go | FindInstanceSpec | func (env *joyentEnviron) FindInstanceSpec(
ic *instances.InstanceConstraint,
imageMetadata []*imagemetadata.ImageMetadata,
) (*instances.InstanceSpec, error) {
// Require at least one VCPU so we get KVM rather than smart package.
if ic.Constraints.CpuCores == nil {
ic.Constraints.CpuCores = &defaultCpuCores
}
... | go | func (env *joyentEnviron) FindInstanceSpec(
ic *instances.InstanceConstraint,
imageMetadata []*imagemetadata.ImageMetadata,
) (*instances.InstanceSpec, error) {
// Require at least one VCPU so we get KVM rather than smart package.
if ic.Constraints.CpuCores == nil {
ic.Constraints.CpuCores = &defaultCpuCores
}
... | [
"func",
"(",
"env",
"*",
"joyentEnviron",
")",
"FindInstanceSpec",
"(",
"ic",
"*",
"instances",
".",
"InstanceConstraint",
",",
"imageMetadata",
"[",
"]",
"*",
"imagemetadata",
".",
"ImageMetadata",
",",
")",
"(",
"*",
"instances",
".",
"InstanceSpec",
",",
... | // FindInstanceSpec returns an InstanceSpec satisfying the supplied instanceConstraint. | [
"FindInstanceSpec",
"returns",
"an",
"InstanceSpec",
"satisfying",
"the",
"supplied",
"instanceConstraint",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/joyent/environ_instance.go#L338-L356 |
157,708 | juju/juju | apiserver/facades/client/applicationoffers/base.go | checkPermission | func (api *BaseAPI) checkPermission(tag names.Tag, perm permission.Access) error {
allowed, err := api.Authorizer.HasPermission(perm, tag)
if err != nil {
return errors.Trace(err)
}
if !allowed {
return common.ErrPerm
}
return nil
} | go | func (api *BaseAPI) checkPermission(tag names.Tag, perm permission.Access) error {
allowed, err := api.Authorizer.HasPermission(perm, tag)
if err != nil {
return errors.Trace(err)
}
if !allowed {
return common.ErrPerm
}
return nil
} | [
"func",
"(",
"api",
"*",
"BaseAPI",
")",
"checkPermission",
"(",
"tag",
"names",
".",
"Tag",
",",
"perm",
"permission",
".",
"Access",
")",
"error",
"{",
"allowed",
",",
"err",
":=",
"api",
".",
"Authorizer",
".",
"HasPermission",
"(",
"perm",
",",
"ta... | // checkPermission ensures that the logged in user holds the given permission on an entity. | [
"checkPermission",
"ensures",
"that",
"the",
"logged",
"in",
"user",
"holds",
"the",
"given",
"permission",
"on",
"an",
"entity",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/applicationoffers/base.go#L37-L46 |
157,709 | juju/juju | apiserver/facades/client/applicationoffers/base.go | checkAdmin | func (api *BaseAPI) checkAdmin(backend Backend) error {
allowed, err := api.Authorizer.HasPermission(permission.AdminAccess, backend.ModelTag())
if err != nil {
return errors.Trace(err)
}
if !allowed {
allowed, err = api.Authorizer.HasPermission(permission.SuperuserAccess, backend.ControllerTag())
}
if err !=... | go | func (api *BaseAPI) checkAdmin(backend Backend) error {
allowed, err := api.Authorizer.HasPermission(permission.AdminAccess, backend.ModelTag())
if err != nil {
return errors.Trace(err)
}
if !allowed {
allowed, err = api.Authorizer.HasPermission(permission.SuperuserAccess, backend.ControllerTag())
}
if err !=... | [
"func",
"(",
"api",
"*",
"BaseAPI",
")",
"checkAdmin",
"(",
"backend",
"Backend",
")",
"error",
"{",
"allowed",
",",
"err",
":=",
"api",
".",
"Authorizer",
".",
"HasPermission",
"(",
"permission",
".",
"AdminAccess",
",",
"backend",
".",
"ModelTag",
"(",
... | // checkAdmin ensures that the logged in user is a model or controller admin. | [
"checkAdmin",
"ensures",
"that",
"the",
"logged",
"in",
"user",
"is",
"a",
"model",
"or",
"controller",
"admin",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/applicationoffers/base.go#L49-L64 |
157,710 | juju/juju | apiserver/facades/client/applicationoffers/base.go | applicationOffersFromModel | func (api *BaseAPI) applicationOffersFromModel(
modelUUID string,
requiredAccess permission.Access,
filters ...jujucrossmodel.ApplicationOfferFilter,
) ([]params.ApplicationOfferAdminDetails, error) {
// Get the relevant backend for the specified model.
backend, releaser, err := api.StatePool.Get(modelUUID)
if er... | go | func (api *BaseAPI) applicationOffersFromModel(
modelUUID string,
requiredAccess permission.Access,
filters ...jujucrossmodel.ApplicationOfferFilter,
) ([]params.ApplicationOfferAdminDetails, error) {
// Get the relevant backend for the specified model.
backend, releaser, err := api.StatePool.Get(modelUUID)
if er... | [
"func",
"(",
"api",
"*",
"BaseAPI",
")",
"applicationOffersFromModel",
"(",
"modelUUID",
"string",
",",
"requiredAccess",
"permission",
".",
"Access",
",",
"filters",
"...",
"jujucrossmodel",
".",
"ApplicationOfferFilter",
",",
")",
"(",
"[",
"]",
"params",
".",... | // applicationOffersFromModel gets details about remote applications that match given filters. | [
"applicationOffersFromModel",
"gets",
"details",
"about",
"remote",
"applications",
"that",
"match",
"given",
"filters",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/applicationoffers/base.go#L106-L179 |
157,711 | juju/juju | apiserver/facades/client/applicationoffers/base.go | checkOfferAccess | func (api *BaseAPI) checkOfferAccess(backend Backend, offerUUID string, perm permission.Access) (permission.Access, error) {
apiUser := api.Authorizer.GetAuthTag().(names.UserTag)
access, err := backend.GetOfferAccess(offerUUID, apiUser)
if err != nil && !errors.IsNotFound(err) {
return permission.NoAccess, errors... | go | func (api *BaseAPI) checkOfferAccess(backend Backend, offerUUID string, perm permission.Access) (permission.Access, error) {
apiUser := api.Authorizer.GetAuthTag().(names.UserTag)
access, err := backend.GetOfferAccess(offerUUID, apiUser)
if err != nil && !errors.IsNotFound(err) {
return permission.NoAccess, errors... | [
"func",
"(",
"api",
"*",
"BaseAPI",
")",
"checkOfferAccess",
"(",
"backend",
"Backend",
",",
"offerUUID",
"string",
",",
"perm",
"permission",
".",
"Access",
")",
"(",
"permission",
".",
"Access",
",",
"error",
")",
"{",
"apiUser",
":=",
"api",
".",
"Aut... | // checkOfferAccess returns the level of access the authenticated user has to the offer,
// so long as it is greater than the requested perm. | [
"checkOfferAccess",
"returns",
"the",
"level",
"of",
"access",
"the",
"authenticated",
"user",
"has",
"to",
"the",
"offer",
"so",
"long",
"as",
"it",
"is",
"greater",
"than",
"the",
"requested",
"perm",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/applicationoffers/base.go#L249-L259 |
157,712 | juju/juju | apiserver/facades/client/applicationoffers/base.go | getModelsFromOffers | func (api *BaseAPI) getModelsFromOffers(offerURLs ...string) ([]offerModel, error) {
// Cache the models found so far so we don't look them up more than once.
modelsCache := make(map[string]Model)
oneModel := func(offerURL string) (Model, error) {
url, err := jujucrossmodel.ParseOfferURL(offerURL)
if err != nil ... | go | func (api *BaseAPI) getModelsFromOffers(offerURLs ...string) ([]offerModel, error) {
// Cache the models found so far so we don't look them up more than once.
modelsCache := make(map[string]Model)
oneModel := func(offerURL string) (Model, error) {
url, err := jujucrossmodel.ParseOfferURL(offerURL)
if err != nil ... | [
"func",
"(",
"api",
"*",
"BaseAPI",
")",
"getModelsFromOffers",
"(",
"offerURLs",
"...",
"string",
")",
"(",
"[",
"]",
"offerModel",
",",
"error",
")",
"{",
"// Cache the models found so far so we don't look them up more than once.",
"modelsCache",
":=",
"make",
"(",
... | // getModelsFromOffers returns a slice of models corresponding to the
// specified offer URLs. Each result item has either a model or an error. | [
"getModelsFromOffers",
"returns",
"a",
"slice",
"of",
"models",
"corresponding",
"to",
"the",
"specified",
"offer",
"URLs",
".",
"Each",
"result",
"item",
"has",
"either",
"a",
"model",
"or",
"an",
"error",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/applicationoffers/base.go#L268-L298 |
157,713 | juju/juju | apiserver/facades/client/applicationoffers/base.go | getModelFilters | func (api *BaseAPI) getModelFilters(filters params.OfferFilters) (
models map[string]Model,
filtersPerModel map[string][]jujucrossmodel.ApplicationOfferFilter,
_ error,
) {
models = make(map[string]Model)
filtersPerModel = make(map[string][]jujucrossmodel.ApplicationOfferFilter)
// Group the filters per model an... | go | func (api *BaseAPI) getModelFilters(filters params.OfferFilters) (
models map[string]Model,
filtersPerModel map[string][]jujucrossmodel.ApplicationOfferFilter,
_ error,
) {
models = make(map[string]Model)
filtersPerModel = make(map[string][]jujucrossmodel.ApplicationOfferFilter)
// Group the filters per model an... | [
"func",
"(",
"api",
"*",
"BaseAPI",
")",
"getModelFilters",
"(",
"filters",
"params",
".",
"OfferFilters",
")",
"(",
"models",
"map",
"[",
"string",
"]",
"Model",
",",
"filtersPerModel",
"map",
"[",
"string",
"]",
"[",
"]",
"jujucrossmodel",
".",
"Applicat... | // getModelFilters splits the specified filters per model and returns
// the model and filter details for each. | [
"getModelFilters",
"splits",
"the",
"specified",
"filters",
"per",
"model",
"and",
"returns",
"the",
"model",
"and",
"filter",
"details",
"for",
"each",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/applicationoffers/base.go#L302-L347 |
157,714 | juju/juju | apiserver/facades/client/applicationoffers/base.go | getApplicationOffersDetails | func (api *BaseAPI) getApplicationOffersDetails(
filters params.OfferFilters,
requiredPermission permission.Access,
) ([]params.ApplicationOfferAdminDetails, error) {
// If there are no filters specified, that's an error since the
// caller is expected to specify at the least one or more models
// to avoid an unb... | go | func (api *BaseAPI) getApplicationOffersDetails(
filters params.OfferFilters,
requiredPermission permission.Access,
) ([]params.ApplicationOfferAdminDetails, error) {
// If there are no filters specified, that's an error since the
// caller is expected to specify at the least one or more models
// to avoid an unb... | [
"func",
"(",
"api",
"*",
"BaseAPI",
")",
"getApplicationOffersDetails",
"(",
"filters",
"params",
".",
"OfferFilters",
",",
"requiredPermission",
"permission",
".",
"Access",
",",
")",
"(",
"[",
"]",
"params",
".",
"ApplicationOfferAdminDetails",
",",
"error",
"... | // getApplicationOffersDetails gets details about remote applications that match given filter. | [
"getApplicationOffersDetails",
"gets",
"details",
"about",
"remote",
"applications",
"that",
"match",
"given",
"filter",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/applicationoffers/base.go#L350-L391 |
157,715 | juju/juju | container/directory.go | NewDirectory | func NewDirectory(containerName string) (directory string, err error) {
directory = dirForName(containerName)
logger.Tracef("create directory: %s", directory)
if err = os.MkdirAll(directory, 0755); err != nil {
logger.Errorf("failed to create container directory: %v", err)
return "", err
}
return directory, ni... | go | func NewDirectory(containerName string) (directory string, err error) {
directory = dirForName(containerName)
logger.Tracef("create directory: %s", directory)
if err = os.MkdirAll(directory, 0755); err != nil {
logger.Errorf("failed to create container directory: %v", err)
return "", err
}
return directory, ni... | [
"func",
"NewDirectory",
"(",
"containerName",
"string",
")",
"(",
"directory",
"string",
",",
"err",
"error",
")",
"{",
"directory",
"=",
"dirForName",
"(",
"containerName",
")",
"\n",
"logger",
".",
"Tracef",
"(",
"\"",
"\"",
",",
"directory",
")",
"\n",
... | // NewDirectory creates a new directory for the container name in the
// directory identified by `ContainerDir`. | [
"NewDirectory",
"creates",
"a",
"new",
"directory",
"for",
"the",
"container",
"name",
"in",
"the",
"directory",
"identified",
"by",
"ContainerDir",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/directory.go#L22-L30 |
157,716 | juju/juju | container/directory.go | RemoveDirectory | func RemoveDirectory(containerName string) error {
// Move the directory.
logger.Tracef("create old container dir: %s", RemovedContainerDir)
if err := os.MkdirAll(RemovedContainerDir, 0755); err != nil {
logger.Errorf("failed to create removed container directory: %v", err)
return err
}
removedDir, err := util... | go | func RemoveDirectory(containerName string) error {
// Move the directory.
logger.Tracef("create old container dir: %s", RemovedContainerDir)
if err := os.MkdirAll(RemovedContainerDir, 0755); err != nil {
logger.Errorf("failed to create removed container directory: %v", err)
return err
}
removedDir, err := util... | [
"func",
"RemoveDirectory",
"(",
"containerName",
"string",
")",
"error",
"{",
"// Move the directory.",
"logger",
".",
"Tracef",
"(",
"\"",
"\"",
",",
"RemovedContainerDir",
")",
"\n",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"RemovedContainerDir",
",",
... | // RemoveDirectory moves the container directory from `ContainerDir`
// to `RemovedContainerDir` and makes sure that the names don't clash. | [
"RemoveDirectory",
"moves",
"the",
"container",
"directory",
"from",
"ContainerDir",
"to",
"RemovedContainerDir",
"and",
"makes",
"sure",
"that",
"the",
"names",
"don",
"t",
"clash",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/directory.go#L34-L52 |
157,717 | juju/juju | api/machiner/machiner.go | NewState | func NewState(caller base.APICaller) *State {
facadeCaller := base.NewFacadeCaller(caller, machinerFacade)
return &State{
facade: facadeCaller,
APIAddresser: common.NewAPIAddresser(facadeCaller),
}
} | go | func NewState(caller base.APICaller) *State {
facadeCaller := base.NewFacadeCaller(caller, machinerFacade)
return &State{
facade: facadeCaller,
APIAddresser: common.NewAPIAddresser(facadeCaller),
}
} | [
"func",
"NewState",
"(",
"caller",
"base",
".",
"APICaller",
")",
"*",
"State",
"{",
"facadeCaller",
":=",
"base",
".",
"NewFacadeCaller",
"(",
"caller",
",",
"machinerFacade",
")",
"\n",
"return",
"&",
"State",
"{",
"facade",
":",
"facadeCaller",
",",
"AP... | // NewState creates a new client-side Machiner facade. | [
"NewState",
"creates",
"a",
"new",
"client",
"-",
"side",
"Machiner",
"facade",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/machiner/machiner.go#L24-L30 |
157,718 | juju/juju | api/uniter/relationunit.go | Watch | func (ru *RelationUnit) Watch() (watcher.RelationUnitsWatcher, error) {
return ru.st.WatchRelationUnits(ru.relation.tag, ru.unit.tag)
} | go | func (ru *RelationUnit) Watch() (watcher.RelationUnitsWatcher, error) {
return ru.st.WatchRelationUnits(ru.relation.tag, ru.unit.tag)
} | [
"func",
"(",
"ru",
"*",
"RelationUnit",
")",
"Watch",
"(",
")",
"(",
"watcher",
".",
"RelationUnitsWatcher",
",",
"error",
")",
"{",
"return",
"ru",
".",
"st",
".",
"WatchRelationUnits",
"(",
"ru",
".",
"relation",
".",
"tag",
",",
"ru",
".",
"unit",
... | // Watch returns a watcher that notifies of changes to counterpart
// units in the relation. | [
"Watch",
"returns",
"a",
"watcher",
"that",
"notifies",
"of",
"changes",
"to",
"counterpart",
"units",
"in",
"the",
"relation",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/uniter/relationunit.go#L157-L159 |
157,719 | juju/juju | state/cleanup.go | SetBSON | func (a *cleanupArg) SetBSON(raw bson.Raw) error {
a.Value = raw
return nil
} | go | func (a *cleanupArg) SetBSON(raw bson.Raw) error {
a.Value = raw
return nil
} | [
"func",
"(",
"a",
"*",
"cleanupArg",
")",
"SetBSON",
"(",
"raw",
"bson",
".",
"Raw",
")",
"error",
"{",
"a",
".",
"Value",
"=",
"raw",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetBSON is part of the bson.Setter interface. | [
"SetBSON",
"is",
"part",
"of",
"the",
"bson",
".",
"Setter",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L80-L83 |
157,720 | juju/juju | state/cleanup.go | newCleanupOp | func newCleanupOp(kind cleanupKind, prefix string, args ...interface{}) txn.Op {
return newCleanupAtOp(asap, kind, prefix, args...)
} | go | func newCleanupOp(kind cleanupKind, prefix string, args ...interface{}) txn.Op {
return newCleanupAtOp(asap, kind, prefix, args...)
} | [
"func",
"newCleanupOp",
"(",
"kind",
"cleanupKind",
",",
"prefix",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"txn",
".",
"Op",
"{",
"return",
"newCleanupAtOp",
"(",
"asap",
",",
"kind",
",",
"prefix",
",",
"args",
"...",
")",
"\n",
"}"
... | // newCleanupOp returns a txn.Op that creates a cleanup document with a unique
// id and the supplied kind and prefix. | [
"newCleanupOp",
"returns",
"a",
"txn",
".",
"Op",
"that",
"creates",
"a",
"cleanup",
"document",
"with",
"a",
"unique",
"id",
"and",
"the",
"supplied",
"kind",
"and",
"prefix",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L87-L89 |
157,721 | juju/juju | state/cleanup.go | NeedsCleanup | func (st *State) NeedsCleanup() (bool, error) {
cleanups, closer := st.db().GetCollection(cleanupsC)
defer closer()
count, err := cleanups.Count()
if err != nil {
return false, err
}
return count > 0, nil
} | go | func (st *State) NeedsCleanup() (bool, error) {
cleanups, closer := st.db().GetCollection(cleanupsC)
defer closer()
count, err := cleanups.Count()
if err != nil {
return false, err
}
return count > 0, nil
} | [
"func",
"(",
"st",
"*",
"State",
")",
"NeedsCleanup",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"cleanups",
",",
"closer",
":=",
"st",
".",
"db",
"(",
")",
".",
"GetCollection",
"(",
"cleanupsC",
")",
"\n",
"defer",
"closer",
"(",
")",
"\n",
... | // NeedsCleanup returns true if documents previously marked for removal exist. | [
"NeedsCleanup",
"returns",
"true",
"if",
"documents",
"previously",
"marked",
"for",
"removal",
"exist",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L114-L122 |
157,722 | juju/juju | state/cleanup.go | cleanupModelsForDyingController | func (st *State) cleanupModelsForDyingController(cleanupArgs []bson.Raw) (err error) {
var args DestroyModelParams
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
destroyStorage := true
args.DestroyStorage = &destroyStorage
case 1:
if err := cleanupArgs[0... | go | func (st *State) cleanupModelsForDyingController(cleanupArgs []bson.Raw) (err error) {
var args DestroyModelParams
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
destroyStorage := true
args.DestroyStorage = &destroyStorage
case 1:
if err := cleanupArgs[0... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupModelsForDyingController",
"(",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"(",
"err",
"error",
")",
"{",
"var",
"args",
"DestroyModelParams",
"\n",
"switch",
"n",
":=",
"len",
"(",
"cleanupArgs",
")",
... | // cleanupModelsForDyingController sets all models to dying, if
// they are not already Dying or Dead. It's expected to be used when a
// controller is destroyed. | [
"cleanupModelsForDyingController",
"sets",
"all",
"models",
"to",
"dying",
"if",
"they",
"are",
"not",
"already",
"Dying",
"or",
"Dead",
".",
"It",
"s",
"expected",
"to",
"be",
"used",
"when",
"a",
"controller",
"is",
"destroyed",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L240-L280 |
157,723 | juju/juju | state/cleanup.go | cleanupMachinesForDyingModel | func (st *State) cleanupMachinesForDyingModel(cleanupArgs []bson.Raw) (err error) {
var args DestroyModelParams
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := cleanupArgs[0].Unmarshal(&args); err != nil {
return errors.Annotate(err, "unma... | go | func (st *State) cleanupMachinesForDyingModel(cleanupArgs []bson.Raw) (err error) {
var args DestroyModelParams
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := cleanupArgs[0].Unmarshal(&args); err != nil {
return errors.Annotate(err, "unma... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupMachinesForDyingModel",
"(",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"(",
"err",
"error",
")",
"{",
"var",
"args",
"DestroyModelParams",
"\n",
"switch",
"n",
":=",
"len",
"(",
"cleanupArgs",
")",
";... | // cleanupMachinesForDyingModel sets all non-manager machines to Dying,
// if they are not already Dying or Dead. It's expected to be used when
// a model is destroyed. | [
"cleanupMachinesForDyingModel",
"sets",
"all",
"non",
"-",
"manager",
"machines",
"to",
"Dying",
"if",
"they",
"are",
"not",
"already",
"Dying",
"or",
"Dead",
".",
"It",
"s",
"expected",
"to",
"be",
"used",
"when",
"a",
"model",
"is",
"destroyed",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L285-L343 |
157,724 | juju/juju | state/cleanup.go | cleanupStorageForDyingModel | func (st *State) cleanupStorageForDyingModel(cleanupArgs []bson.Raw) (err error) {
sb, err := NewStorageBackend(st)
if err != nil {
return errors.Trace(err)
}
var args DestroyModelParams
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := c... | go | func (st *State) cleanupStorageForDyingModel(cleanupArgs []bson.Raw) (err error) {
sb, err := NewStorageBackend(st)
if err != nil {
return errors.Trace(err)
}
var args DestroyModelParams
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := c... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupStorageForDyingModel",
"(",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"(",
"err",
"error",
")",
"{",
"sb",
",",
"err",
":=",
"NewStorageBackend",
"(",
"st",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{... | // cleanupStorageForDyingModel sets all storage to Dying, if they are not
// already Dying or Dead. It's expected to be used when a model is destroyed. | [
"cleanupStorageForDyingModel",
"sets",
"all",
"storage",
"to",
"Dying",
"if",
"they",
"are",
"not",
"already",
"Dying",
"or",
"Dead",
".",
"It",
"s",
"expected",
"to",
"be",
"used",
"when",
"a",
"model",
"is",
"destroyed",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L347-L384 |
157,725 | juju/juju | state/cleanup.go | cleanupApplication | func (st *State) cleanupApplication(applicationname string, cleanupArgs []bson.Raw) (err error) {
app, err := st.Application(applicationname)
if err != nil {
if errors.IsNotFound(err) {
// Nothing to do, the application is already gone.
logger.Tracef("cleanupApplication(%s): application already gone", applica... | go | func (st *State) cleanupApplication(applicationname string, cleanupArgs []bson.Raw) (err error) {
app, err := st.Application(applicationname)
if err != nil {
if errors.IsNotFound(err) {
// Nothing to do, the application is already gone.
logger.Tracef("cleanupApplication(%s): application already gone", applica... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupApplication",
"(",
"applicationname",
"string",
",",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"(",
"err",
"error",
")",
"{",
"app",
",",
"err",
":=",
"st",
".",
"Application",
"(",
"applicationname",... | // cleanupApplication checks if all references to a dying application have been removed,
// and if so, removes the application. | [
"cleanupApplication",
"checks",
"if",
"all",
"references",
"to",
"a",
"dying",
"application",
"have",
"been",
"removed",
"and",
"if",
"so",
"removes",
"the",
"application",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L388-L424 |
157,726 | juju/juju | state/cleanup.go | cleanupApplicationsForDyingModel | func (st *State) cleanupApplicationsForDyingModel(cleanupArgs []bson.Raw) (err error) {
var args DestroyModelParams
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := cleanupArgs[0].Unmarshal(&args); err != nil {
return errors.Annotate(err, ... | go | func (st *State) cleanupApplicationsForDyingModel(cleanupArgs []bson.Raw) (err error) {
var args DestroyModelParams
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := cleanupArgs[0].Unmarshal(&args); err != nil {
return errors.Annotate(err, ... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupApplicationsForDyingModel",
"(",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"(",
"err",
"error",
")",
"{",
"var",
"args",
"DestroyModelParams",
"\n",
"switch",
"n",
":=",
"len",
"(",
"cleanupArgs",
")",
... | // cleanupApplicationsForDyingModel sets all applications to Dying, if they are
// not already Dying or Dead. It's expected to be used when a model is
// destroyed. | [
"cleanupApplicationsForDyingModel",
"sets",
"all",
"applications",
"to",
"Dying",
"if",
"they",
"are",
"not",
"already",
"Dying",
"or",
"Dead",
".",
"It",
"s",
"expected",
"to",
"be",
"used",
"when",
"a",
"model",
"is",
"destroyed",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L429-L445 |
157,727 | juju/juju | state/cleanup.go | cleanupUnitsForDyingApplication | func (st *State) cleanupUnitsForDyingApplication(applicationname string, cleanupArgs []bson.Raw) (err error) {
var destroyStorage bool
destroyStorageArg := func() error {
err := cleanupArgs[0].Unmarshal(&destroyStorage)
return errors.Annotate(err, "unmarshalling cleanup arg 'destroyStorage'")
}
var force bool
... | go | func (st *State) cleanupUnitsForDyingApplication(applicationname string, cleanupArgs []bson.Raw) (err error) {
var destroyStorage bool
destroyStorageArg := func() error {
err := cleanupArgs[0].Unmarshal(&destroyStorage)
return errors.Annotate(err, "unmarshalling cleanup arg 'destroyStorage'")
}
var force bool
... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupUnitsForDyingApplication",
"(",
"applicationname",
"string",
",",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"(",
"err",
"error",
")",
"{",
"var",
"destroyStorage",
"bool",
"\n",
"destroyStorageArg",
":=",
... | // cleanupUnitsForDyingApplication sets all units with the given prefix to Dying,
// if they are not already Dying or Dead. It's expected to be used when a
// application is destroyed. | [
"cleanupUnitsForDyingApplication",
"sets",
"all",
"units",
"with",
"the",
"given",
"prefix",
"to",
"Dying",
"if",
"they",
"are",
"not",
"already",
"Dying",
"or",
"Dead",
".",
"It",
"s",
"expected",
"to",
"be",
"used",
"when",
"a",
"application",
"is",
"destr... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L498-L547 |
157,728 | juju/juju | state/cleanup.go | cleanupDyingUnit | func (st *State) cleanupDyingUnit(name string, cleanupArgs []bson.Raw) error {
var destroyStorage bool
destroyStorageArg := func() error {
err := cleanupArgs[0].Unmarshal(&destroyStorage)
return errors.Annotate(err, "unmarshalling cleanup arg 'destroyStorage'")
}
var force bool
var maxWait time.Duration
switc... | go | func (st *State) cleanupDyingUnit(name string, cleanupArgs []bson.Raw) error {
var destroyStorage bool
destroyStorageArg := func() error {
err := cleanupArgs[0].Unmarshal(&destroyStorage)
return errors.Annotate(err, "unmarshalling cleanup arg 'destroyStorage'")
}
var force bool
var maxWait time.Duration
switc... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupDyingUnit",
"(",
"name",
"string",
",",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"error",
"{",
"var",
"destroyStorage",
"bool",
"\n",
"destroyStorageArg",
":=",
"func",
"(",
")",
"error",
"{",
"err",... | // cleanupDyingUnit marks resources owned by the unit as dying, to ensure
// they are cleaned up as well. | [
"cleanupDyingUnit",
"marks",
"resources",
"owned",
"by",
"the",
"unit",
"as",
"dying",
"to",
"ensure",
"they",
"are",
"cleaned",
"up",
"as",
"well",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L588-L669 |
157,729 | juju/juju | state/cleanup.go | cleanupRemovedUnit | func (st *State) cleanupRemovedUnit(unitId string, cleanupArgs []bson.Raw) error {
var force bool
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := cleanupArgs[0].Unmarshal(&force); err != nil {
return errors.Annotate(err, "unmarshalling cl... | go | func (st *State) cleanupRemovedUnit(unitId string, cleanupArgs []bson.Raw) error {
var force bool
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := cleanupArgs[0].Unmarshal(&force); err != nil {
return errors.Annotate(err, "unmarshalling cl... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupRemovedUnit",
"(",
"unitId",
"string",
",",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"error",
"{",
"var",
"force",
"bool",
"\n",
"switch",
"n",
":=",
"len",
"(",
"cleanupArgs",
")",
";",
"n",
"{"... | // cleanupRemovedUnit takes care of all the final cleanup required when
// a unit is removed. | [
"cleanupRemovedUnit",
"takes",
"care",
"of",
"all",
"the",
"final",
"cleanup",
"required",
"when",
"a",
"unit",
"is",
"removed",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L903-L951 |
157,730 | juju/juju | state/cleanup.go | cleanupDyingMachine | func (st *State) cleanupDyingMachine(machineId string, cleanupArgs []bson.Raw) error {
var force bool
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := cleanupArgs[0].Unmarshal(&force); err != nil {
return errors.Annotate(err, "unmarshallin... | go | func (st *State) cleanupDyingMachine(machineId string, cleanupArgs []bson.Raw) error {
var force bool
switch n := len(cleanupArgs); n {
case 0:
// Old cleanups have no args, so follow the old behaviour.
case 1:
if err := cleanupArgs[0].Unmarshal(&force); err != nil {
return errors.Annotate(err, "unmarshallin... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupDyingMachine",
"(",
"machineId",
"string",
",",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"error",
"{",
"var",
"force",
"bool",
"\n",
"switch",
"n",
":=",
"len",
"(",
"cleanupArgs",
")",
";",
"n",
... | // cleanupDyingMachine marks resources owned by the machine as dying, to ensure
// they are cleaned up as well. | [
"cleanupDyingMachine",
"marks",
"resources",
"owned",
"by",
"the",
"machine",
"as",
"dying",
"to",
"ensure",
"they",
"are",
"cleaned",
"up",
"as",
"well",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L955-L974 |
157,731 | juju/juju | state/cleanup.go | cleanupContainers | func (st *State) cleanupContainers(machine *Machine, maxWait time.Duration) error {
containerIds, err := machine.Containers()
if errors.IsNotFound(err) {
return nil
} else if err != nil {
return err
}
for _, containerId := range containerIds {
if err := st.cleanupForceDestroyedMachineInternal(containerId, ma... | go | func (st *State) cleanupContainers(machine *Machine, maxWait time.Duration) error {
containerIds, err := machine.Containers()
if errors.IsNotFound(err) {
return nil
} else if err != nil {
return err
}
for _, containerId := range containerIds {
if err := st.cleanupForceDestroyedMachineInternal(containerId, ma... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupContainers",
"(",
"machine",
"*",
"Machine",
",",
"maxWait",
"time",
".",
"Duration",
")",
"error",
"{",
"containerIds",
",",
"err",
":=",
"machine",
".",
"Containers",
"(",
")",
"\n",
"if",
"errors",
".",
... | // cleanupContainers recursively calls cleanupForceDestroyedMachine on the supplied
// machine's containers, and removes them from state entirely. | [
"cleanupContainers",
"recursively",
"calls",
"cleanupForceDestroyedMachine",
"on",
"the",
"supplied",
"machine",
"s",
"containers",
"and",
"removes",
"them",
"from",
"state",
"entirely",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L1090-L1112 |
157,732 | juju/juju | state/cleanup.go | obliterateUnit | func (st *State) obliterateUnit(unitName string, force bool, maxWait time.Duration) ([]error, error) {
var opErrs []error
unit, err := st.Unit(unitName)
if errors.IsNotFound(err) {
return opErrs, nil
} else if err != nil {
return opErrs, err
}
// Unlike the machine, we *can* always destroy the unit, and (at l... | go | func (st *State) obliterateUnit(unitName string, force bool, maxWait time.Duration) ([]error, error) {
var opErrs []error
unit, err := st.Unit(unitName)
if errors.IsNotFound(err) {
return opErrs, nil
} else if err != nil {
return opErrs, err
}
// Unlike the machine, we *can* always destroy the unit, and (at l... | [
"func",
"(",
"st",
"*",
"State",
")",
"obliterateUnit",
"(",
"unitName",
"string",
",",
"force",
"bool",
",",
"maxWait",
"time",
".",
"Duration",
")",
"(",
"[",
"]",
"error",
",",
"error",
")",
"{",
"var",
"opErrs",
"[",
"]",
"error",
"\n",
"unit",
... | // obliterateUnit removes a unit from state completely. It is not safe or
// sane to obliterate any unit in isolation; its only reasonable use is in
// the context of machine obliteration, in which we can be sure that unclean
// shutdown of units is not going to leave a machine in a difficult state. | [
"obliterateUnit",
"removes",
"a",
"unit",
"from",
"state",
"completely",
".",
"It",
"is",
"not",
"safe",
"or",
"sane",
"to",
"obliterate",
"any",
"unit",
"in",
"isolation",
";",
"its",
"only",
"reasonable",
"use",
"is",
"in",
"the",
"context",
"of",
"machi... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L1291-L1345 |
157,733 | juju/juju | state/cleanup.go | cleanupAttachmentsForDyingStorage | func (st *State) cleanupAttachmentsForDyingStorage(storageId string, cleanupArgs []bson.Raw) (err error) {
var force bool
var maxWait time.Duration
switch n := len(cleanupArgs); n {
case 0:
// It's valid to have no args: old cleanups have no args, so follow the old behaviour.
case 2:
if err := cleanupArgs[0].Un... | go | func (st *State) cleanupAttachmentsForDyingStorage(storageId string, cleanupArgs []bson.Raw) (err error) {
var force bool
var maxWait time.Duration
switch n := len(cleanupArgs); n {
case 0:
// It's valid to have no args: old cleanups have no args, so follow the old behaviour.
case 2:
if err := cleanupArgs[0].Un... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupAttachmentsForDyingStorage",
"(",
"storageId",
"string",
",",
"cleanupArgs",
"[",
"]",
"bson",
".",
"Raw",
")",
"(",
"err",
"error",
")",
"{",
"var",
"force",
"bool",
"\n",
"var",
"maxWait",
"time",
".",
"Dur... | // cleanupAttachmentsForDyingStorage sets all storage attachments related
// to the specified storage instance to Dying, if they are not already Dying
// or Dead. It's expected to be used when a storage instance is destroyed. | [
"cleanupAttachmentsForDyingStorage",
"sets",
"all",
"storage",
"attachments",
"related",
"to",
"the",
"specified",
"storage",
"instance",
"to",
"Dying",
"if",
"they",
"are",
"not",
"already",
"Dying",
"or",
"Dead",
".",
"It",
"s",
"expected",
"to",
"be",
"used",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L1350-L1396 |
157,734 | juju/juju | state/cleanup.go | cleanupAttachmentsForDyingVolume | func (st *State) cleanupAttachmentsForDyingVolume(volumeId string) (err error) {
volumeTag := names.NewVolumeTag(volumeId)
// This won't miss attachments, because a Dying volume cannot have
// attachments added to it. But we do have to remove the attachments
// themselves via individual transactions, because they ... | go | func (st *State) cleanupAttachmentsForDyingVolume(volumeId string) (err error) {
volumeTag := names.NewVolumeTag(volumeId)
// This won't miss attachments, because a Dying volume cannot have
// attachments added to it. But we do have to remove the attachments
// themselves via individual transactions, because they ... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupAttachmentsForDyingVolume",
"(",
"volumeId",
"string",
")",
"(",
"err",
"error",
")",
"{",
"volumeTag",
":=",
"names",
".",
"NewVolumeTag",
"(",
"volumeId",
")",
"\n\n",
"// This won't miss attachments, because a Dying v... | // cleanupAttachmentsForDyingVolume sets all volume attachments related
// to the specified volume to Dying, if they are not already Dying or
// Dead. It's expected to be used when a volume is destroyed. | [
"cleanupAttachmentsForDyingVolume",
"sets",
"all",
"volume",
"attachments",
"related",
"to",
"the",
"specified",
"volume",
"to",
"Dying",
"if",
"they",
"are",
"not",
"already",
"Dying",
"or",
"Dead",
".",
"It",
"s",
"expected",
"to",
"be",
"used",
"when",
"a",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L1401-L1427 |
157,735 | juju/juju | state/cleanup.go | cleanupAttachmentsForDyingFilesystem | func (st *State) cleanupAttachmentsForDyingFilesystem(filesystemId string) (err error) {
sb, err := NewStorageBackend(st)
if err != nil {
return errors.Trace(err)
}
filesystemTag := names.NewFilesystemTag(filesystemId)
// This won't miss attachments, because a Dying filesystem cannot have
// attachments added... | go | func (st *State) cleanupAttachmentsForDyingFilesystem(filesystemId string) (err error) {
sb, err := NewStorageBackend(st)
if err != nil {
return errors.Trace(err)
}
filesystemTag := names.NewFilesystemTag(filesystemId)
// This won't miss attachments, because a Dying filesystem cannot have
// attachments added... | [
"func",
"(",
"st",
"*",
"State",
")",
"cleanupAttachmentsForDyingFilesystem",
"(",
"filesystemId",
"string",
")",
"(",
"err",
"error",
")",
"{",
"sb",
",",
"err",
":=",
"NewStorageBackend",
"(",
"st",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"... | // cleanupAttachmentsForDyingFilesystem sets all filesystem attachments related
// to the specified filesystem to Dying, if they are not already Dying or
// Dead. It's expected to be used when a filesystem is destroyed. | [
"cleanupAttachmentsForDyingFilesystem",
"sets",
"all",
"filesystem",
"attachments",
"related",
"to",
"the",
"specified",
"filesystem",
"to",
"Dying",
"if",
"they",
"are",
"not",
"already",
"Dying",
"or",
"Dead",
".",
"It",
"s",
"expected",
"to",
"be",
"used",
"w... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cleanup.go#L1432-L1458 |
157,736 | juju/juju | state/charm.go | Set | func (m MacaroonCache) Set(u *charm.URL, ms macaroon.Slice) error {
c, err := m.Charm(u)
if err != nil {
return errors.Trace(err)
}
return c.UpdateMacaroon(ms)
} | go | func (m MacaroonCache) Set(u *charm.URL, ms macaroon.Slice) error {
c, err := m.Charm(u)
if err != nil {
return errors.Trace(err)
}
return c.UpdateMacaroon(ms)
} | [
"func",
"(",
"m",
"MacaroonCache",
")",
"Set",
"(",
"u",
"*",
"charm",
".",
"URL",
",",
"ms",
"macaroon",
".",
"Slice",
")",
"error",
"{",
"c",
",",
"err",
":=",
"m",
".",
"Charm",
"(",
"u",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // Set stores the macaroon on the charm. | [
"Set",
"stores",
"the",
"macaroon",
"on",
"the",
"charm",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L33-L39 |
157,737 | juju/juju | state/charm.go | insertCharmOps | func insertCharmOps(mb modelBackend, info CharmInfo) ([]txn.Op, error) {
if info.ID == nil {
return nil, errors.New("*charm.URL was nil")
}
doc := charmDoc{
DocID: info.ID.String(),
URL: info.ID,
CharmVersion: info.Version,
Meta: info.Charm.Meta(),
Config: safeConfig(info.C... | go | func insertCharmOps(mb modelBackend, info CharmInfo) ([]txn.Op, error) {
if info.ID == nil {
return nil, errors.New("*charm.URL was nil")
}
doc := charmDoc{
DocID: info.ID.String(),
URL: info.ID,
CharmVersion: info.Version,
Meta: info.Charm.Meta(),
Config: safeConfig(info.C... | [
"func",
"insertCharmOps",
"(",
"mb",
"modelBackend",
",",
"info",
"CharmInfo",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"if",
"info",
".",
"ID",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
"... | // insertCharmOps returns the txn operations necessary to insert the supplied
// charm data. If curl is nil, an error will be returned. | [
"insertCharmOps",
"returns",
"the",
"txn",
"operations",
"necessary",
"to",
"insert",
"the",
"supplied",
"charm",
"data",
".",
"If",
"curl",
"is",
"nil",
"an",
"error",
"will",
"be",
"returned",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L103-L137 |
157,738 | juju/juju | state/charm.go | insertPlaceholderCharmOps | func insertPlaceholderCharmOps(mb modelBackend, curl *charm.URL) ([]txn.Op, error) {
if curl == nil {
return nil, errors.New("*charm.URL was nil")
}
return insertAnyCharmOps(mb, &charmDoc{
DocID: curl.String(),
URL: curl,
Placeholder: true,
})
} | go | func insertPlaceholderCharmOps(mb modelBackend, curl *charm.URL) ([]txn.Op, error) {
if curl == nil {
return nil, errors.New("*charm.URL was nil")
}
return insertAnyCharmOps(mb, &charmDoc{
DocID: curl.String(),
URL: curl,
Placeholder: true,
})
} | [
"func",
"insertPlaceholderCharmOps",
"(",
"mb",
"modelBackend",
",",
"curl",
"*",
"charm",
".",
"URL",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"if",
"curl",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\... | // insertPlaceholderCharmOps returns the txn operations necessary to insert a
// charm document referencing a store charm that is not yet directly accessible
// within the model. If curl is nil, an error will be returned. | [
"insertPlaceholderCharmOps",
"returns",
"the",
"txn",
"operations",
"necessary",
"to",
"insert",
"a",
"charm",
"document",
"referencing",
"a",
"store",
"charm",
"that",
"is",
"not",
"yet",
"directly",
"accessible",
"within",
"the",
"model",
".",
"If",
"curl",
"i... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L142-L151 |
157,739 | juju/juju | state/charm.go | insertAnyCharmOps | func insertAnyCharmOps(mb modelBackend, cdoc *charmDoc) ([]txn.Op, error) {
charms, closer := mb.db().GetCollection(charmsC)
defer closer()
life, err := nsLife.read(charms, cdoc.DocID)
if errors.IsNotFound(err) {
// everything is as it should be
} else if err != nil {
return nil, errors.Trace(err)
} else if ... | go | func insertAnyCharmOps(mb modelBackend, cdoc *charmDoc) ([]txn.Op, error) {
charms, closer := mb.db().GetCollection(charmsC)
defer closer()
life, err := nsLife.read(charms, cdoc.DocID)
if errors.IsNotFound(err) {
// everything is as it should be
} else if err != nil {
return nil, errors.Trace(err)
} else if ... | [
"func",
"insertAnyCharmOps",
"(",
"mb",
"modelBackend",
",",
"cdoc",
"*",
"charmDoc",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"charms",
",",
"closer",
":=",
"mb",
".",
"db",
"(",
")",
".",
"GetCollection",
"(",
"charmsC",
")",
... | // insertAnyCharmOps returns the txn operations necessary to insert the supplied
// charm document. | [
"insertAnyCharmOps",
"returns",
"the",
"txn",
"operations",
"necessary",
"to",
"insert",
"the",
"supplied",
"charm",
"document",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L169-L201 |
157,740 | juju/juju | state/charm.go | updateCharmOps | func updateCharmOps(mb modelBackend, info CharmInfo, assert bson.D) ([]txn.Op, error) {
charms, closer := mb.db().GetCollection(charmsC)
defer closer()
charmKey := info.ID.String()
op, err := nsLife.aliveOp(charms, charmKey)
if err != nil {
return nil, errors.Annotate(err, "charm")
}
lifeAssert, ok := op.Asse... | go | func updateCharmOps(mb modelBackend, info CharmInfo, assert bson.D) ([]txn.Op, error) {
charms, closer := mb.db().GetCollection(charmsC)
defer closer()
charmKey := info.ID.String()
op, err := nsLife.aliveOp(charms, charmKey)
if err != nil {
return nil, errors.Annotate(err, "charm")
}
lifeAssert, ok := op.Asse... | [
"func",
"updateCharmOps",
"(",
"mb",
"modelBackend",
",",
"info",
"CharmInfo",
",",
"assert",
"bson",
".",
"D",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"charms",
",",
"closer",
":=",
"mb",
".",
"db",
"(",
")",
".",
"GetCollect... | // updateCharmOps returns the txn operations necessary to update the charm
// document with the supplied data, so long as the supplied assert still holds
// true. | [
"updateCharmOps",
"returns",
"the",
"txn",
"operations",
"necessary",
"to",
"update",
"the",
"charm",
"document",
"with",
"the",
"supplied",
"data",
"so",
"long",
"as",
"the",
"supplied",
"assert",
"still",
"holds",
"true",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L206-L253 |
157,741 | juju/juju | state/charm.go | convertPlaceholderCharmOps | func convertPlaceholderCharmOps(docID string) ([]txn.Op, error) {
return []txn.Op{{
C: charmsC,
Id: docID,
Assert: bson.D{
{"bundlesha256", ""},
{"pendingupload", false},
{"placeholder", true},
},
Update: bson.D{{"$set", bson.D{
{"pendingupload", true},
{"placeholder", false},
}}},
}}, nil... | go | func convertPlaceholderCharmOps(docID string) ([]txn.Op, error) {
return []txn.Op{{
C: charmsC,
Id: docID,
Assert: bson.D{
{"bundlesha256", ""},
{"pendingupload", false},
{"placeholder", true},
},
Update: bson.D{{"$set", bson.D{
{"pendingupload", true},
{"placeholder", false},
}}},
}}, nil... | [
"func",
"convertPlaceholderCharmOps",
"(",
"docID",
"string",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"return",
"[",
"]",
"txn",
".",
"Op",
"{",
"{",
"C",
":",
"charmsC",
",",
"Id",
":",
"docID",
",",
"Assert",
":",
"bson",
... | // convertPlaceholderCharmOps returns the txn operations necessary to convert
// the charm with the supplied docId from a placeholder to one marked for
// pending upload. | [
"convertPlaceholderCharmOps",
"returns",
"the",
"txn",
"operations",
"necessary",
"to",
"convert",
"the",
"charm",
"with",
"the",
"supplied",
"docId",
"from",
"a",
"placeholder",
"to",
"one",
"marked",
"for",
"pending",
"upload",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L258-L273 |
157,742 | juju/juju | state/charm.go | deleteOldPlaceholderCharmsOps | func deleteOldPlaceholderCharmsOps(mb modelBackend, charms mongo.Collection, curl *charm.URL) ([]txn.Op, error) {
// Get a regex with the charm URL and no revision.
noRevURL := curl.WithRevision(-1)
curlRegex := "^" + regexp.QuoteMeta(mb.docID(noRevURL.String()))
var docs []charmDoc
query := bson.D{{"_id", bson.D... | go | func deleteOldPlaceholderCharmsOps(mb modelBackend, charms mongo.Collection, curl *charm.URL) ([]txn.Op, error) {
// Get a regex with the charm URL and no revision.
noRevURL := curl.WithRevision(-1)
curlRegex := "^" + regexp.QuoteMeta(mb.docID(noRevURL.String()))
var docs []charmDoc
query := bson.D{{"_id", bson.D... | [
"func",
"deleteOldPlaceholderCharmsOps",
"(",
"mb",
"modelBackend",
",",
"charms",
"mongo",
".",
"Collection",
",",
"curl",
"*",
"charm",
".",
"URL",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"// Get a regex with the charm URL and no revision... | // deleteOldPlaceholderCharmsOps returns the txn ops required to delete all placeholder charm
// records older than the specified charm URL. | [
"deleteOldPlaceholderCharmsOps",
"returns",
"the",
"txn",
"ops",
"required",
"to",
"delete",
"all",
"placeholder",
"charm",
"records",
"older",
"than",
"the",
"specified",
"charm",
"URL",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L277-L310 |
157,743 | juju/juju | state/charm.go | safeLXDProfile | func safeLXDProfile(profile *charm.LXDProfile) *charm.LXDProfile {
if profile == nil {
return nil
}
escapedProfile := charm.NewLXDProfile()
escapedProfile.Description = profile.Description
// we know the size and shape of the type, so let's use EscapeKey
escapedConfig := make(map[string]string, len(profile.Conf... | go | func safeLXDProfile(profile *charm.LXDProfile) *charm.LXDProfile {
if profile == nil {
return nil
}
escapedProfile := charm.NewLXDProfile()
escapedProfile.Description = profile.Description
// we know the size and shape of the type, so let's use EscapeKey
escapedConfig := make(map[string]string, len(profile.Conf... | [
"func",
"safeLXDProfile",
"(",
"profile",
"*",
"charm",
".",
"LXDProfile",
")",
"*",
"charm",
".",
"LXDProfile",
"{",
"if",
"profile",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"escapedProfile",
":=",
"charm",
".",
"NewLXDProfile",
"(",
")",
"\... | // safeLXDProfile ensures that the LXDProfile that we put into the mongo data
// store, can in fact store the profile safely by escaping mongo-
// significant characters in config options. | [
"safeLXDProfile",
"ensures",
"that",
"the",
"LXDProfile",
"that",
"we",
"put",
"into",
"the",
"mongo",
"data",
"store",
"can",
"in",
"fact",
"store",
"the",
"profile",
"safely",
"by",
"escaping",
"mongo",
"-",
"significant",
"characters",
"in",
"config",
"opti... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L335-L359 |
157,744 | juju/juju | state/charm.go | unescapeLXDProfile | func unescapeLXDProfile(profile *charm.LXDProfile) *charm.LXDProfile {
if profile == nil {
return nil
}
unescapedProfile := charm.NewLXDProfile()
unescapedProfile.Description = profile.Description
// we know the size and shape of the type, so let's use UnescapeKey
unescapedConfig := make(map[string]string, len(... | go | func unescapeLXDProfile(profile *charm.LXDProfile) *charm.LXDProfile {
if profile == nil {
return nil
}
unescapedProfile := charm.NewLXDProfile()
unescapedProfile.Description = profile.Description
// we know the size and shape of the type, so let's use UnescapeKey
unescapedConfig := make(map[string]string, len(... | [
"func",
"unescapeLXDProfile",
"(",
"profile",
"*",
"charm",
".",
"LXDProfile",
")",
"*",
"charm",
".",
"LXDProfile",
"{",
"if",
"profile",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"unescapedProfile",
":=",
"charm",
".",
"NewLXDProfile",
"(",
")"... | // unescapeLXDProfile returns the LXDProfile back to normal after
// reading from state. | [
"unescapeLXDProfile",
"returns",
"the",
"LXDProfile",
"back",
"to",
"normal",
"after",
"reading",
"from",
"state",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L392-L416 |
157,745 | juju/juju | state/charm.go | Tag | func (c *Charm) Tag() names.Tag {
return names.NewCharmTag(c.URL().String())
} | go | func (c *Charm) Tag() names.Tag {
return names.NewCharmTag(c.URL().String())
} | [
"func",
"(",
"c",
"*",
"Charm",
")",
"Tag",
"(",
")",
"names",
".",
"Tag",
"{",
"return",
"names",
".",
"NewCharmTag",
"(",
"c",
".",
"URL",
"(",
")",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // Tag returns a tag identifying the charm.
// Implementing state.GlobalEntity interface. | [
"Tag",
"returns",
"a",
"tag",
"identifying",
"the",
"charm",
".",
"Implementing",
"state",
".",
"GlobalEntity",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L420-L422 |
157,746 | juju/juju | state/charm.go | Refresh | func (c *Charm) Refresh() error {
ch, err := c.st.Charm(c.doc.URL)
if err != nil {
return errors.Trace(err)
}
c.doc = ch.doc
return nil
} | go | func (c *Charm) Refresh() error {
ch, err := c.st.Charm(c.doc.URL)
if err != nil {
return errors.Trace(err)
}
c.doc = ch.doc
return nil
} | [
"func",
"(",
"c",
"*",
"Charm",
")",
"Refresh",
"(",
")",
"error",
"{",
"ch",
",",
"err",
":=",
"c",
".",
"st",
".",
"Charm",
"(",
"c",
".",
"doc",
".",
"URL",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Trace",
"(",
... | // Refresh loads fresh charm data from the database. In practice, the
// only observable change should be to its Life value. | [
"Refresh",
"loads",
"fresh",
"charm",
"data",
"from",
"the",
"database",
".",
"In",
"practice",
"the",
"only",
"observable",
"change",
"should",
"be",
"to",
"its",
"Life",
"value",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L431-L438 |
157,747 | juju/juju | state/charm.go | Destroy | func (c *Charm) Destroy() error {
buildTxn := func(_ int) ([]txn.Op, error) {
ops, err := charmDestroyOps(c.st, c.doc.URL)
if IsNotAlive(err) {
return nil, jujutxn.ErrNoOperations
} else if err != nil {
return nil, errors.Trace(err)
}
return ops, nil
}
if err := c.st.db().Run(buildTxn); err != nil {
... | go | func (c *Charm) Destroy() error {
buildTxn := func(_ int) ([]txn.Op, error) {
ops, err := charmDestroyOps(c.st, c.doc.URL)
if IsNotAlive(err) {
return nil, jujutxn.ErrNoOperations
} else if err != nil {
return nil, errors.Trace(err)
}
return ops, nil
}
if err := c.st.db().Run(buildTxn); err != nil {
... | [
"func",
"(",
"c",
"*",
"Charm",
")",
"Destroy",
"(",
")",
"error",
"{",
"buildTxn",
":=",
"func",
"(",
"_",
"int",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"ops",
",",
"err",
":=",
"charmDestroyOps",
"(",
"c",
".",
"st",
... | // Destroy sets the charm to Dying and prevents it from being used by
// applications or units. It only works on local charms, and only when
// the charm is not referenced by any application. | [
"Destroy",
"sets",
"the",
"charm",
"to",
"Dying",
"and",
"prevents",
"it",
"from",
"being",
"used",
"by",
"applications",
"or",
"units",
".",
"It",
"only",
"works",
"on",
"local",
"charms",
"and",
"only",
"when",
"the",
"charm",
"is",
"not",
"referenced",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L443-L458 |
157,748 | juju/juju | state/charm.go | URL | func (c *Charm) URL() *charm.URL {
clone := *c.doc.URL
return &clone
} | go | func (c *Charm) URL() *charm.URL {
clone := *c.doc.URL
return &clone
} | [
"func",
"(",
"c",
"*",
"Charm",
")",
"URL",
"(",
")",
"*",
"charm",
".",
"URL",
"{",
"clone",
":=",
"*",
"c",
".",
"doc",
".",
"URL",
"\n",
"return",
"&",
"clone",
"\n",
"}"
] | // URL returns the URL that identifies the charm. | [
"URL",
"returns",
"the",
"URL",
"that",
"identifies",
"the",
"charm",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L509-L512 |
157,749 | juju/juju | state/charm.go | Macaroon | func (c *Charm) Macaroon() (macaroon.Slice, error) {
if len(c.doc.Macaroon) == 0 {
return nil, nil
}
var m macaroon.Slice
if err := m.UnmarshalBinary(c.doc.Macaroon); err != nil {
return nil, errors.Trace(err)
}
return m, nil
} | go | func (c *Charm) Macaroon() (macaroon.Slice, error) {
if len(c.doc.Macaroon) == 0 {
return nil, nil
}
var m macaroon.Slice
if err := m.UnmarshalBinary(c.doc.Macaroon); err != nil {
return nil, errors.Trace(err)
}
return m, nil
} | [
"func",
"(",
"c",
"*",
"Charm",
")",
"Macaroon",
"(",
")",
"(",
"macaroon",
".",
"Slice",
",",
"error",
")",
"{",
"if",
"len",
"(",
"c",
".",
"doc",
".",
"Macaroon",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"var",
"m... | // Macaroon return the macaroon that can be used to request data about the charm
// from the charmstore, or nil if the charm is not private. | [
"Macaroon",
"return",
"the",
"macaroon",
"that",
"can",
"be",
"used",
"to",
"request",
"data",
"about",
"the",
"charm",
"from",
"the",
"charmstore",
"or",
"nil",
"if",
"the",
"charm",
"is",
"not",
"private",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L574-L584 |
157,750 | juju/juju | state/charm.go | UpdateMacaroon | func (c *Charm) UpdateMacaroon(m macaroon.Slice) error {
info := CharmInfo{
Charm: c,
ID: c.URL(),
StoragePath: c.StoragePath(),
SHA256: c.BundleSha256(),
Macaroon: m,
}
ops, err := updateCharmOps(c.st, info, nil)
if err != nil {
return errors.Trace(err)
}
if err := c.st.db().Ru... | go | func (c *Charm) UpdateMacaroon(m macaroon.Slice) error {
info := CharmInfo{
Charm: c,
ID: c.URL(),
StoragePath: c.StoragePath(),
SHA256: c.BundleSha256(),
Macaroon: m,
}
ops, err := updateCharmOps(c.st, info, nil)
if err != nil {
return errors.Trace(err)
}
if err := c.st.db().Ru... | [
"func",
"(",
"c",
"*",
"Charm",
")",
"UpdateMacaroon",
"(",
"m",
"macaroon",
".",
"Slice",
")",
"error",
"{",
"info",
":=",
"CharmInfo",
"{",
"Charm",
":",
"c",
",",
"ID",
":",
"c",
".",
"URL",
"(",
")",
",",
"StoragePath",
":",
"c",
".",
"Storag... | // UpdateMacaroon updates the stored macaroon for this charm. | [
"UpdateMacaroon",
"updates",
"the",
"stored",
"macaroon",
"for",
"this",
"charm",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L587-L603 |
157,751 | juju/juju | state/charm.go | AddCharm | func (st *State) AddCharm(info CharmInfo) (stch *Charm, err error) {
charms, closer := st.db().GetCollection(charmsC)
defer closer()
if err := validateCharmVersion(info.Charm); err != nil {
return nil, errors.Trace(err)
}
model, err := st.Model()
if err != nil {
return nil, errors.Trace(err)
}
if err := va... | go | func (st *State) AddCharm(info CharmInfo) (stch *Charm, err error) {
charms, closer := st.db().GetCollection(charmsC)
defer closer()
if err := validateCharmVersion(info.Charm); err != nil {
return nil, errors.Trace(err)
}
model, err := st.Model()
if err != nil {
return nil, errors.Trace(err)
}
if err := va... | [
"func",
"(",
"st",
"*",
"State",
")",
"AddCharm",
"(",
"info",
"CharmInfo",
")",
"(",
"stch",
"*",
"Charm",
",",
"err",
"error",
")",
"{",
"charms",
",",
"closer",
":=",
"st",
".",
"db",
"(",
")",
".",
"GetCollection",
"(",
"charmsC",
")",
"\n",
... | // AddCharm adds the ch charm with curl to the state.
// On success the newly added charm state is returned. | [
"AddCharm",
"adds",
"the",
"ch",
"charm",
"with",
"curl",
"to",
"the",
"state",
".",
"On",
"success",
"the",
"newly",
"added",
"charm",
"state",
"is",
"returned",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L607-L651 |
157,752 | juju/juju | state/charm.go | AllCharms | func (st *State) AllCharms() ([]*Charm, error) {
charmsCollection, closer := st.db().GetCollection(charmsC)
defer closer()
var cdoc charmDoc
var charms []*Charm
iter := charmsCollection.Find(nsLife.notDead()).Iter()
for iter.Next(&cdoc) {
ch := newCharm(st, &cdoc)
charms = append(charms, ch)
}
return charms... | go | func (st *State) AllCharms() ([]*Charm, error) {
charmsCollection, closer := st.db().GetCollection(charmsC)
defer closer()
var cdoc charmDoc
var charms []*Charm
iter := charmsCollection.Find(nsLife.notDead()).Iter()
for iter.Next(&cdoc) {
ch := newCharm(st, &cdoc)
charms = append(charms, ch)
}
return charms... | [
"func",
"(",
"st",
"*",
"State",
")",
"AllCharms",
"(",
")",
"(",
"[",
"]",
"*",
"Charm",
",",
"error",
")",
"{",
"charmsCollection",
",",
"closer",
":=",
"st",
".",
"db",
"(",
")",
".",
"GetCollection",
"(",
"charmsC",
")",
"\n",
"defer",
"closer"... | // AllCharms returns all charms in state. | [
"AllCharms",
"returns",
"all",
"charms",
"in",
"state",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L683-L694 |
157,753 | juju/juju | state/charm.go | Charm | func (st *State) Charm(curl *charm.URL) (*Charm, error) {
charms, closer := st.db().GetCollection(charmsC)
defer closer()
cdoc := &charmDoc{}
what := bson.D{
{"_id", curl.String()},
{"placeholder", bson.D{{"$ne", true}}},
{"pendingupload", bson.D{{"$ne", true}}},
}
what = append(what, nsLife.notDead()...)
... | go | func (st *State) Charm(curl *charm.URL) (*Charm, error) {
charms, closer := st.db().GetCollection(charmsC)
defer closer()
cdoc := &charmDoc{}
what := bson.D{
{"_id", curl.String()},
{"placeholder", bson.D{{"$ne", true}}},
{"pendingupload", bson.D{{"$ne", true}}},
}
what = append(what, nsLife.notDead()...)
... | [
"func",
"(",
"st",
"*",
"State",
")",
"Charm",
"(",
"curl",
"*",
"charm",
".",
"URL",
")",
"(",
"*",
"Charm",
",",
"error",
")",
"{",
"charms",
",",
"closer",
":=",
"st",
".",
"db",
"(",
")",
".",
"GetCollection",
"(",
"charmsC",
")",
"\n",
"de... | // Charm returns the charm with the given URL. Charms pending upload
// to storage and placeholders are never returned. | [
"Charm",
"returns",
"the",
"charm",
"with",
"the",
"given",
"URL",
".",
"Charms",
"pending",
"upload",
"to",
"storage",
"and",
"placeholders",
"are",
"never",
"returned",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L698-L720 |
157,754 | juju/juju | state/charm.go | PrepareLocalCharmUpload | func (st *State) PrepareLocalCharmUpload(curl *charm.URL) (chosenURL *charm.URL, err error) {
// Perform a few sanity checks first.
if curl.Schema != "local" {
return nil, errors.Errorf("expected charm URL with local schema, got %q", curl)
}
if curl.Revision < 0 {
return nil, errors.Errorf("expected charm URL w... | go | func (st *State) PrepareLocalCharmUpload(curl *charm.URL) (chosenURL *charm.URL, err error) {
// Perform a few sanity checks first.
if curl.Schema != "local" {
return nil, errors.Errorf("expected charm URL with local schema, got %q", curl)
}
if curl.Revision < 0 {
return nil, errors.Errorf("expected charm URL w... | [
"func",
"(",
"st",
"*",
"State",
")",
"PrepareLocalCharmUpload",
"(",
"curl",
"*",
"charm",
".",
"URL",
")",
"(",
"chosenURL",
"*",
"charm",
".",
"URL",
",",
"err",
"error",
")",
"{",
"// Perform a few sanity checks first.",
"if",
"curl",
".",
"Schema",
"!... | // PrepareLocalCharmUpload must be called before a local charm is
// uploaded to the provider storage in order to create a charm
// document in state. It returns the chosen unique charm URL reserved
// in state for the charm.
//
// The url's schema must be "local" and it must include a revision. | [
"PrepareLocalCharmUpload",
"must",
"be",
"called",
"before",
"a",
"local",
"charm",
"is",
"uploaded",
"to",
"the",
"provider",
"storage",
"in",
"order",
"to",
"create",
"a",
"charm",
"document",
"in",
"state",
".",
"It",
"returns",
"the",
"chosen",
"unique",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L754-L779 |
157,755 | juju/juju | state/charm.go | AddStoreCharmPlaceholder | func (st *State) AddStoreCharmPlaceholder(curl *charm.URL) (err error) {
// Perform sanity checks first.
if curl.Schema != "cs" {
return errors.Errorf("expected charm URL with cs schema, got %q", curl)
}
if curl.Revision < 0 {
return errors.Errorf("expected charm URL with revision, got %q", curl)
}
charms, cl... | go | func (st *State) AddStoreCharmPlaceholder(curl *charm.URL) (err error) {
// Perform sanity checks first.
if curl.Schema != "cs" {
return errors.Errorf("expected charm URL with cs schema, got %q", curl)
}
if curl.Revision < 0 {
return errors.Errorf("expected charm URL with revision, got %q", curl)
}
charms, cl... | [
"func",
"(",
"st",
"*",
"State",
")",
"AddStoreCharmPlaceholder",
"(",
"curl",
"*",
"charm",
".",
"URL",
")",
"(",
"err",
"error",
")",
"{",
"// Perform sanity checks first.",
"if",
"curl",
".",
"Schema",
"!=",
"\"",
"\"",
"{",
"return",
"errors",
".",
"... | // AddStoreCharmPlaceholder creates a charm document in state for the given charm URL which
// must reference a charm from the store. The charm document is marked as a placeholder which
// means that if the charm is to be deployed, it will need to first be uploaded to model storage. | [
"AddStoreCharmPlaceholder",
"creates",
"a",
"charm",
"document",
"in",
"state",
"for",
"the",
"given",
"charm",
"URL",
"which",
"must",
"reference",
"a",
"charm",
"from",
"the",
"store",
".",
"The",
"charm",
"document",
"is",
"marked",
"as",
"a",
"placeholder"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/charm.go#L855-L890 |
157,756 | juju/juju | resource/context/internal/download.go | Download | func Download(target DownloadTarget, remote ContentSource) error {
resDir, err := target.Initialize()
if err != nil {
return errors.Trace(err)
}
if err := resDir.Write(remote); err != nil {
return errors.Trace(err)
}
return nil
} | go | func Download(target DownloadTarget, remote ContentSource) error {
resDir, err := target.Initialize()
if err != nil {
return errors.Trace(err)
}
if err := resDir.Write(remote); err != nil {
return errors.Trace(err)
}
return nil
} | [
"func",
"Download",
"(",
"target",
"DownloadTarget",
",",
"remote",
"ContentSource",
")",
"error",
"{",
"resDir",
",",
"err",
":=",
"target",
".",
"Initialize",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Trace",
"(",
"err",
... | // Download downloads the resource from the provied source to the target. | [
"Download",
"downloads",
"the",
"resource",
"from",
"the",
"provied",
"source",
"to",
"the",
"target",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/resource/context/internal/download.go#L14-L25 |
157,757 | juju/juju | provider/gce/google/config.go | NewCredentials | func NewCredentials(values map[string]string) (*Credentials, error) {
var creds Credentials
for k, v := range values {
switch k {
case OSEnvClientID:
creds.ClientID = v
case OSEnvClientEmail:
creds.ClientEmail = v
case OSEnvProjectID:
creds.ProjectID = v
case OSEnvPrivateKey:
creds.PrivateKey = ... | go | func NewCredentials(values map[string]string) (*Credentials, error) {
var creds Credentials
for k, v := range values {
switch k {
case OSEnvClientID:
creds.ClientID = v
case OSEnvClientEmail:
creds.ClientEmail = v
case OSEnvProjectID:
creds.ProjectID = v
case OSEnvPrivateKey:
creds.PrivateKey = ... | [
"func",
"NewCredentials",
"(",
"values",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"Credentials",
",",
"error",
")",
"{",
"var",
"creds",
"Credentials",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"values",
"{",
"switch",
"k",
"{",
"case",
"... | // NewCredentials returns a new Credentials based on the provided
// values. The keys must be recognized OS env var names for the
// different credential fields. | [
"NewCredentials",
"returns",
"a",
"new",
"Credentials",
"based",
"on",
"the",
"provided",
"values",
".",
"The",
"keys",
"must",
"be",
"recognized",
"OS",
"env",
"var",
"names",
"for",
"the",
"different",
"credential",
"fields",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/google/config.go#L59-L84 |
157,758 | juju/juju | provider/gce/google/config.go | ParseJSONKey | func ParseJSONKey(jsonKeyFile io.Reader) (*Credentials, error) {
jsonKey, err := ioutil.ReadAll(jsonKeyFile)
if err != nil {
return nil, errors.Trace(err)
}
values, err := parseJSONKey(jsonKey)
if err != nil {
return nil, errors.Trace(err)
}
creds, err := NewCredentials(values)
if err != nil {
return nil,... | go | func ParseJSONKey(jsonKeyFile io.Reader) (*Credentials, error) {
jsonKey, err := ioutil.ReadAll(jsonKeyFile)
if err != nil {
return nil, errors.Trace(err)
}
values, err := parseJSONKey(jsonKey)
if err != nil {
return nil, errors.Trace(err)
}
creds, err := NewCredentials(values)
if err != nil {
return nil,... | [
"func",
"ParseJSONKey",
"(",
"jsonKeyFile",
"io",
".",
"Reader",
")",
"(",
"*",
"Credentials",
",",
"error",
")",
"{",
"jsonKey",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"jsonKeyFile",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",... | // ParseJSONKey returns a new Credentials with values based on the
// provided JSON key file contents. | [
"ParseJSONKey",
"returns",
"a",
"new",
"Credentials",
"with",
"values",
"based",
"on",
"the",
"provided",
"JSON",
"key",
"file",
"contents",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/google/config.go#L88-L103 |
157,759 | juju/juju | provider/gce/google/config.go | buildJSONKey | func (gc Credentials) buildJSONKey() ([]byte, error) {
return json.Marshal(&map[string]string{
"type": jsonKeyTypeServiceAccount,
"client_id": gc.ClientID,
"client_email": gc.ClientEmail,
"private_key": string(gc.PrivateKey),
})
} | go | func (gc Credentials) buildJSONKey() ([]byte, error) {
return json.Marshal(&map[string]string{
"type": jsonKeyTypeServiceAccount,
"client_id": gc.ClientID,
"client_email": gc.ClientEmail,
"private_key": string(gc.PrivateKey),
})
} | [
"func",
"(",
"gc",
"Credentials",
")",
"buildJSONKey",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"json",
".",
"Marshal",
"(",
"&",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
"jsonKeyTypeServiceAccount",
",",
"... | // buildJSONKey returns the content of the JSON key file for the
// credential values. | [
"buildJSONKey",
"returns",
"the",
"content",
"of",
"the",
"JSON",
"key",
"file",
"for",
"the",
"credential",
"values",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/google/config.go#L140-L147 |
157,760 | juju/juju | provider/gce/google/config.go | Values | func (gc Credentials) Values() map[string]string {
return map[string]string{
OSEnvClientID: gc.ClientID,
OSEnvClientEmail: gc.ClientEmail,
OSEnvPrivateKey: string(gc.PrivateKey),
OSEnvProjectID: gc.ProjectID,
}
} | go | func (gc Credentials) Values() map[string]string {
return map[string]string{
OSEnvClientID: gc.ClientID,
OSEnvClientEmail: gc.ClientEmail,
OSEnvPrivateKey: string(gc.PrivateKey),
OSEnvProjectID: gc.ProjectID,
}
} | [
"func",
"(",
"gc",
"Credentials",
")",
"Values",
"(",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"return",
"map",
"[",
"string",
"]",
"string",
"{",
"OSEnvClientID",
":",
"gc",
".",
"ClientID",
",",
"OSEnvClientEmail",
":",
"gc",
".",
"ClientEmail",
... | // Values returns the credentials as a simple mapping with the
// corresponding OS env variable names as the keys. | [
"Values",
"returns",
"the",
"credentials",
"as",
"a",
"simple",
"mapping",
"with",
"the",
"corresponding",
"OS",
"env",
"variable",
"names",
"as",
"the",
"keys",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/google/config.go#L151-L158 |
157,761 | juju/juju | provider/gce/google/config.go | Validate | func (gc Credentials) Validate() error {
if gc.ClientID == "" {
return NewMissingConfigValue(OSEnvClientID, "ClientID")
}
if gc.ClientEmail == "" {
return NewMissingConfigValue(OSEnvClientEmail, "ClientEmail")
}
if _, err := mail.ParseAddress(gc.ClientEmail); err != nil {
return NewInvalidConfigValueError(OS... | go | func (gc Credentials) Validate() error {
if gc.ClientID == "" {
return NewMissingConfigValue(OSEnvClientID, "ClientID")
}
if gc.ClientEmail == "" {
return NewMissingConfigValue(OSEnvClientEmail, "ClientEmail")
}
if _, err := mail.ParseAddress(gc.ClientEmail); err != nil {
return NewInvalidConfigValueError(OS... | [
"func",
"(",
"gc",
"Credentials",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"gc",
".",
"ClientID",
"==",
"\"",
"\"",
"{",
"return",
"NewMissingConfigValue",
"(",
"OSEnvClientID",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"gc",
".",
"ClientEmail... | // Validate checks the credentialss for invalid values. If the values
// are not valid, it returns errors.NotValid with the message set to
// the corresponding OS environment variable name.
//
// To be considered valid, each of the credentials must be set to some
// non-empty value. Furthermore, ClientEmail must be a p... | [
"Validate",
"checks",
"the",
"credentialss",
"for",
"invalid",
"values",
".",
"If",
"the",
"values",
"are",
"not",
"valid",
"it",
"returns",
"errors",
".",
"NotValid",
"with",
"the",
"message",
"set",
"to",
"the",
"corresponding",
"OS",
"environment",
"variabl... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/google/config.go#L167-L181 |
157,762 | juju/juju | provider/gce/google/config.go | Validate | func (gc ConnectionConfig) Validate() error {
if gc.Region == "" {
return NewMissingConfigValue(OSEnvRegion, "Region")
}
if gc.ProjectID == "" {
return NewMissingConfigValue(OSEnvProjectID, "ProjectID")
}
return nil
} | go | func (gc ConnectionConfig) Validate() error {
if gc.Region == "" {
return NewMissingConfigValue(OSEnvRegion, "Region")
}
if gc.ProjectID == "" {
return NewMissingConfigValue(OSEnvProjectID, "ProjectID")
}
return nil
} | [
"func",
"(",
"gc",
"ConnectionConfig",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"gc",
".",
"Region",
"==",
"\"",
"\"",
"{",
"return",
"NewMissingConfigValue",
"(",
"OSEnvRegion",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"gc",
".",
"ProjectID"... | // Validate checks the connection's fields for invalid values.
// If the values are not valid, it returns a config.InvalidConfigValueError
// error with the key set to the corresponding OS environment variable
// name.
//
// To be considered valid, each of the connection's must be set to some
// non-empty value. | [
"Validate",
"checks",
"the",
"connection",
"s",
"fields",
"for",
"invalid",
"values",
".",
"If",
"the",
"values",
"are",
"not",
"valid",
"it",
"returns",
"a",
"config",
".",
"InvalidConfigValueError",
"error",
"with",
"the",
"key",
"set",
"to",
"the",
"corre... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/google/config.go#L201-L209 |
157,763 | juju/juju | provider/ec2/subnet.go | CreateSubnetMatcher | func CreateSubnetMatcher(subnetQuery string) SubnetMatcher {
logger.Debugf("searching for subnet matching placement directive %q", subnetQuery)
_, ipNet, err := net.ParseCIDR(subnetQuery)
if err == nil {
return &cidrSubnetMatcher{
ipNet: ipNet,
CIDR: ipNet.String(),
}
}
if strings.HasPrefix(subnetQuery,... | go | func CreateSubnetMatcher(subnetQuery string) SubnetMatcher {
logger.Debugf("searching for subnet matching placement directive %q", subnetQuery)
_, ipNet, err := net.ParseCIDR(subnetQuery)
if err == nil {
return &cidrSubnetMatcher{
ipNet: ipNet,
CIDR: ipNet.String(),
}
}
if strings.HasPrefix(subnetQuery,... | [
"func",
"CreateSubnetMatcher",
"(",
"subnetQuery",
"string",
")",
"SubnetMatcher",
"{",
"logger",
".",
"Debugf",
"(",
"\"",
"\"",
",",
"subnetQuery",
")",
"\n",
"_",
",",
"ipNet",
",",
"err",
":=",
"net",
".",
"ParseCIDR",
"(",
"subnetQuery",
")",
"\n",
... | // CreateSubnetMatcher creates a SubnetMatcher that handles a particular method
// of comparison based on the content of the subnet query. If the query looks
// like a CIDR, then we will match subnets with the same CIDR. If it follows
// the syntax of a "subnet-XXXX" then we will match the Subnet ID. Everything
// else... | [
"CreateSubnetMatcher",
"creates",
"a",
"SubnetMatcher",
"that",
"handles",
"a",
"particular",
"method",
"of",
"comparison",
"based",
"on",
"the",
"content",
"of",
"the",
"subnet",
"query",
".",
"If",
"the",
"query",
"looks",
"like",
"a",
"CIDR",
"then",
"we",
... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/ec2/subnet.go#L22-L39 |
157,764 | juju/juju | worker/metrics/collect/context.go | Flush | func (ctx *hookContext) Flush(process string, ctxErr error) (err error) {
return ctx.recorder.Close()
} | go | func (ctx *hookContext) Flush(process string, ctxErr error) (err error) {
return ctx.recorder.Close()
} | [
"func",
"(",
"ctx",
"*",
"hookContext",
")",
"Flush",
"(",
"process",
"string",
",",
"ctxErr",
"error",
")",
"(",
"err",
"error",
")",
"{",
"return",
"ctx",
".",
"recorder",
".",
"Close",
"(",
")",
"\n",
"}"
] | // Flush implements runner.Context. | [
"Flush",
"implements",
"runner",
".",
"Context",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/metrics/collect/context.go#L50-L52 |
157,765 | juju/juju | worker/metrics/collect/context.go | AddMetric | func (ctx *hookContext) AddMetric(key string, value string, created time.Time) error {
return ctx.recorder.AddMetric(key, value, created, nil)
} | go | func (ctx *hookContext) AddMetric(key string, value string, created time.Time) error {
return ctx.recorder.AddMetric(key, value, created, nil)
} | [
"func",
"(",
"ctx",
"*",
"hookContext",
")",
"AddMetric",
"(",
"key",
"string",
",",
"value",
"string",
",",
"created",
"time",
".",
"Time",
")",
"error",
"{",
"return",
"ctx",
".",
"recorder",
".",
"AddMetric",
"(",
"key",
",",
"value",
",",
"created"... | // AddMetric implements runner.Context. | [
"AddMetric",
"implements",
"runner",
".",
"Context",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/metrics/collect/context.go#L55-L57 |
157,766 | juju/juju | worker/metrics/collect/context.go | AddMetricLabels | func (ctx *hookContext) AddMetricLabels(key string, value string, created time.Time, labels map[string]string) error {
return ctx.recorder.AddMetric(key, value, created, labels)
} | go | func (ctx *hookContext) AddMetricLabels(key string, value string, created time.Time, labels map[string]string) error {
return ctx.recorder.AddMetric(key, value, created, labels)
} | [
"func",
"(",
"ctx",
"*",
"hookContext",
")",
"AddMetricLabels",
"(",
"key",
"string",
",",
"value",
"string",
",",
"created",
"time",
".",
"Time",
",",
"labels",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"return",
"ctx",
".",
"recorder",
... | // AddMetricLabels implements runner.Context. | [
"AddMetricLabels",
"implements",
"runner",
".",
"Context",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/metrics/collect/context.go#L60-L62 |
157,767 | juju/juju | worker/metrics/collect/context.go | addJujuUnitsMetric | func (ctx *hookContext) addJujuUnitsMetric() error {
if ctx.recorder.IsDeclaredMetric("juju-units") {
// TODO(fwereade): 2016-03-17 lp:1558657
err := ctx.recorder.AddMetric("juju-units", "1", time.Now().UTC(), nil)
if err != nil {
return errors.Trace(err)
}
}
return nil
} | go | func (ctx *hookContext) addJujuUnitsMetric() error {
if ctx.recorder.IsDeclaredMetric("juju-units") {
// TODO(fwereade): 2016-03-17 lp:1558657
err := ctx.recorder.AddMetric("juju-units", "1", time.Now().UTC(), nil)
if err != nil {
return errors.Trace(err)
}
}
return nil
} | [
"func",
"(",
"ctx",
"*",
"hookContext",
")",
"addJujuUnitsMetric",
"(",
")",
"error",
"{",
"if",
"ctx",
".",
"recorder",
".",
"IsDeclaredMetric",
"(",
"\"",
"\"",
")",
"{",
"// TODO(fwereade): 2016-03-17 lp:1558657",
"err",
":=",
"ctx",
".",
"recorder",
".",
... | // addJujuUnitsMetric adds the juju-units built in metric if it
// is defined for this context. | [
"addJujuUnitsMetric",
"adds",
"the",
"juju",
"-",
"units",
"built",
"in",
"metric",
"if",
"it",
"is",
"defined",
"for",
"this",
"context",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/metrics/collect/context.go#L66-L75 |
157,768 | juju/juju | worker/metrics/collect/context.go | Component | func (ctx *hookContext) Component(name string) (jujuc.ContextComponent, error) {
return nil, errors.NotFoundf("context component %q", name)
} | go | func (ctx *hookContext) Component(name string) (jujuc.ContextComponent, error) {
return nil, errors.NotFoundf("context component %q", name)
} | [
"func",
"(",
"ctx",
"*",
"hookContext",
")",
"Component",
"(",
"name",
"string",
")",
"(",
"jujuc",
".",
"ContextComponent",
",",
"error",
")",
"{",
"return",
"nil",
",",
"errors",
".",
"NotFoundf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n",
"}"
] | // Component implements runner.Context. | [
"Component",
"implements",
"runner",
".",
"Context",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/metrics/collect/context.go#L100-L102 |
157,769 | juju/juju | provider/azure/init.go | NewProvider | func NewProvider(config ProviderConfig) (environs.CloudEnvironProvider, error) {
environProvider, err := NewEnvironProvider(config)
if err != nil {
return nil, errors.Trace(err)
}
return environProvider, nil
} | go | func NewProvider(config ProviderConfig) (environs.CloudEnvironProvider, error) {
environProvider, err := NewEnvironProvider(config)
if err != nil {
return nil, errors.Trace(err)
}
return environProvider, nil
} | [
"func",
"NewProvider",
"(",
"config",
"ProviderConfig",
")",
"(",
"environs",
".",
"CloudEnvironProvider",
",",
"error",
")",
"{",
"environProvider",
",",
"err",
":=",
"NewEnvironProvider",
"(",
"config",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"... | // NewProvider instantiates and returns the Azure EnvironProvider using the
// given configuration. | [
"NewProvider",
"instantiates",
"and",
"returns",
"the",
"Azure",
"EnvironProvider",
"using",
"the",
"given",
"configuration",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/init.go#L23-L29 |
157,770 | juju/juju | api/migrationflag/facade.go | NewFacade | func NewFacade(apiCaller base.APICaller, newWatcher NewWatcherFunc) *Facade {
facadeCaller := base.NewFacadeCaller(apiCaller, "MigrationFlag")
return &Facade{
caller: facadeCaller,
newWatcher: newWatcher,
}
} | go | func NewFacade(apiCaller base.APICaller, newWatcher NewWatcherFunc) *Facade {
facadeCaller := base.NewFacadeCaller(apiCaller, "MigrationFlag")
return &Facade{
caller: facadeCaller,
newWatcher: newWatcher,
}
} | [
"func",
"NewFacade",
"(",
"apiCaller",
"base",
".",
"APICaller",
",",
"newWatcher",
"NewWatcherFunc",
")",
"*",
"Facade",
"{",
"facadeCaller",
":=",
"base",
".",
"NewFacadeCaller",
"(",
"apiCaller",
",",
"\"",
"\"",
")",
"\n",
"return",
"&",
"Facade",
"{",
... | // NewFacade returns a Facade backed by the supplied api caller. | [
"NewFacade",
"returns",
"a",
"Facade",
"backed",
"by",
"the",
"supplied",
"api",
"caller",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/migrationflag/facade.go#L20-L26 |
157,771 | juju/juju | api/migrationflag/facade.go | Phase | func (facade *Facade) Phase(uuid string) (migration.Phase, error) {
results := params.PhaseResults{}
err := facade.call("Phase", uuid, &results)
if err != nil {
return migration.UNKNOWN, errors.Trace(err)
}
if count := len(results.Results); count != 1 {
return migration.UNKNOWN, countError(count)
}
result :=... | go | func (facade *Facade) Phase(uuid string) (migration.Phase, error) {
results := params.PhaseResults{}
err := facade.call("Phase", uuid, &results)
if err != nil {
return migration.UNKNOWN, errors.Trace(err)
}
if count := len(results.Results); count != 1 {
return migration.UNKNOWN, countError(count)
}
result :=... | [
"func",
"(",
"facade",
"*",
"Facade",
")",
"Phase",
"(",
"uuid",
"string",
")",
"(",
"migration",
".",
"Phase",
",",
"error",
")",
"{",
"results",
":=",
"params",
".",
"PhaseResults",
"{",
"}",
"\n",
"err",
":=",
"facade",
".",
"call",
"(",
"\"",
"... | // Phase returns the current migration.Phase for the supplied model UUID. | [
"Phase",
"returns",
"the",
"current",
"migration",
".",
"Phase",
"for",
"the",
"supplied",
"model",
"UUID",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/migrationflag/facade.go#L35-L54 |
157,772 | juju/juju | api/migrationflag/facade.go | Watch | func (facade *Facade) Watch(uuid string) (watcher.NotifyWatcher, error) {
results := params.NotifyWatchResults{}
err := facade.call("Watch", uuid, &results)
if err != nil {
return nil, errors.Trace(err)
}
if count := len(results.Results); count != 1 {
return nil, countError(count)
}
result := results.Results... | go | func (facade *Facade) Watch(uuid string) (watcher.NotifyWatcher, error) {
results := params.NotifyWatchResults{}
err := facade.call("Watch", uuid, &results)
if err != nil {
return nil, errors.Trace(err)
}
if count := len(results.Results); count != 1 {
return nil, countError(count)
}
result := results.Results... | [
"func",
"(",
"facade",
"*",
"Facade",
")",
"Watch",
"(",
"uuid",
"string",
")",
"(",
"watcher",
".",
"NotifyWatcher",
",",
"error",
")",
"{",
"results",
":=",
"params",
".",
"NotifyWatchResults",
"{",
"}",
"\n",
"err",
":=",
"facade",
".",
"call",
"(",... | // Watch returns a NotifyWatcher that will inform of potential changes
// to the result of Phase for the supplied model UUID. | [
"Watch",
"returns",
"a",
"NotifyWatcher",
"that",
"will",
"inform",
"of",
"potential",
"changes",
"to",
"the",
"result",
"of",
"Phase",
"for",
"the",
"supplied",
"model",
"UUID",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/migrationflag/facade.go#L58-L74 |
157,773 | juju/juju | api/migrationflag/facade.go | call | func (facade *Facade) call(name, uuid string, results interface{}) error {
model := names.NewModelTag(uuid).String()
args := params.Entities{[]params.Entity{{model}}}
err := facade.caller.FacadeCall(name, args, results)
return errors.Trace(err)
} | go | func (facade *Facade) call(name, uuid string, results interface{}) error {
model := names.NewModelTag(uuid).String()
args := params.Entities{[]params.Entity{{model}}}
err := facade.caller.FacadeCall(name, args, results)
return errors.Trace(err)
} | [
"func",
"(",
"facade",
"*",
"Facade",
")",
"call",
"(",
"name",
",",
"uuid",
"string",
",",
"results",
"interface",
"{",
"}",
")",
"error",
"{",
"model",
":=",
"names",
".",
"NewModelTag",
"(",
"uuid",
")",
".",
"String",
"(",
")",
"\n",
"args",
":... | // call converts the supplied model uuid into a params.Entities and
// invokes the facade caller. | [
"call",
"converts",
"the",
"supplied",
"model",
"uuid",
"into",
"a",
"params",
".",
"Entities",
"and",
"invokes",
"the",
"facade",
"caller",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/migrationflag/facade.go#L78-L83 |
157,774 | juju/juju | apiserver/debuglog.go | sendError | func (s *debugLogSocketImpl) sendError(err error) {
if sendErr := s.conn.SendInitialErrorV0(err); sendErr != nil {
logger.Errorf("closing websocket, %v", err)
s.conn.Close()
return
}
} | go | func (s *debugLogSocketImpl) sendError(err error) {
if sendErr := s.conn.SendInitialErrorV0(err); sendErr != nil {
logger.Errorf("closing websocket, %v", err)
s.conn.Close()
return
}
} | [
"func",
"(",
"s",
"*",
"debugLogSocketImpl",
")",
"sendError",
"(",
"err",
"error",
")",
"{",
"if",
"sendErr",
":=",
"s",
".",
"conn",
".",
"SendInitialErrorV0",
"(",
"err",
")",
";",
"sendErr",
"!=",
"nil",
"{",
"logger",
".",
"Errorf",
"(",
"\"",
"... | // sendError implements debugLogSocket. | [
"sendError",
"implements",
"debugLogSocket",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/debuglog.go#L163-L169 |
157,775 | juju/juju | apiserver/facades/agent/meterstatus/mocks/meterstatus_mock.go | NewMockMeterStatusState | func NewMockMeterStatusState(ctrl *gomock.Controller) *MockMeterStatusState {
mock := &MockMeterStatusState{ctrl: ctrl}
mock.recorder = &MockMeterStatusStateMockRecorder{mock}
return mock
} | go | func NewMockMeterStatusState(ctrl *gomock.Controller) *MockMeterStatusState {
mock := &MockMeterStatusState{ctrl: ctrl}
mock.recorder = &MockMeterStatusStateMockRecorder{mock}
return mock
} | [
"func",
"NewMockMeterStatusState",
"(",
"ctrl",
"*",
"gomock",
".",
"Controller",
")",
"*",
"MockMeterStatusState",
"{",
"mock",
":=",
"&",
"MockMeterStatusState",
"{",
"ctrl",
":",
"ctrl",
"}",
"\n",
"mock",
".",
"recorder",
"=",
"&",
"MockMeterStatusStateMockR... | // NewMockMeterStatusState creates a new mock instance | [
"NewMockMeterStatusState",
"creates",
"a",
"new",
"mock",
"instance"
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/meterstatus/mocks/meterstatus_mock.go#L26-L30 |
157,776 | juju/juju | worker/metricworker/metricmanager.go | newMetricsManager | func newMetricsManager(client metricsmanager.MetricsManagerClient, notify chan string) (*worker.Runner, error) {
// TODO(fwereade): break this out into separate manifolds (with their own facades).
// Periodic workers automatically retry so none should return an error. If they do
// it's ok to restart them individua... | go | func newMetricsManager(client metricsmanager.MetricsManagerClient, notify chan string) (*worker.Runner, error) {
// TODO(fwereade): break this out into separate manifolds (with their own facades).
// Periodic workers automatically retry so none should return an error. If they do
// it's ok to restart them individua... | [
"func",
"newMetricsManager",
"(",
"client",
"metricsmanager",
".",
"MetricsManagerClient",
",",
"notify",
"chan",
"string",
")",
"(",
"*",
"worker",
".",
"Runner",
",",
"error",
")",
"{",
"// TODO(fwereade): break this out into separate manifolds (with their own facades).",... | // NewMetricsManager creates a runner that will run the metricsmanagement workers. | [
"NewMetricsManager",
"creates",
"a",
"runner",
"that",
"will",
"run",
"the",
"metricsmanagement",
"workers",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/metricworker/metricmanager.go#L15-L42 |
157,777 | juju/juju | apiserver/facades/agent/leadership/leadership.go | NewLeadershipServiceFacade | func NewLeadershipServiceFacade(context facade.Context) (LeadershipService, error) {
claimer, err := context.LeadershipClaimer(context.State().ModelUUID())
if err != nil {
return nil, errors.Trace(err)
}
return NewLeadershipService(claimer, context.Auth())
} | go | func NewLeadershipServiceFacade(context facade.Context) (LeadershipService, error) {
claimer, err := context.LeadershipClaimer(context.State().ModelUUID())
if err != nil {
return nil, errors.Trace(err)
}
return NewLeadershipService(claimer, context.Auth())
} | [
"func",
"NewLeadershipServiceFacade",
"(",
"context",
"facade",
".",
"Context",
")",
"(",
"LeadershipService",
",",
"error",
")",
"{",
"claimer",
",",
"err",
":=",
"context",
".",
"LeadershipClaimer",
"(",
"context",
".",
"State",
"(",
")",
".",
"ModelUUID",
... | // NewLeadershipServiceFacade constructs a new LeadershipService and presents
// a signature that can be used for facade registration. | [
"NewLeadershipServiceFacade",
"constructs",
"a",
"new",
"LeadershipService",
"and",
"presents",
"a",
"signature",
"that",
"can",
"be",
"used",
"for",
"facade",
"registration",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/leadership/leadership.go#L36-L42 |
157,778 | juju/juju | apiserver/facades/agent/leadership/leadership.go | NewLeadershipService | func NewLeadershipService(
claimer leadership.Claimer, authorizer facade.Authorizer,
) (LeadershipService, error) {
if !authorizer.AuthUnitAgent() && !authorizer.AuthApplicationAgent() {
return nil, errors.Unauthorizedf("permission denied")
}
return &leadershipService{
claimer: claimer,
authorizer: autho... | go | func NewLeadershipService(
claimer leadership.Claimer, authorizer facade.Authorizer,
) (LeadershipService, error) {
if !authorizer.AuthUnitAgent() && !authorizer.AuthApplicationAgent() {
return nil, errors.Unauthorizedf("permission denied")
}
return &leadershipService{
claimer: claimer,
authorizer: autho... | [
"func",
"NewLeadershipService",
"(",
"claimer",
"leadership",
".",
"Claimer",
",",
"authorizer",
"facade",
".",
"Authorizer",
",",
")",
"(",
"LeadershipService",
",",
"error",
")",
"{",
"if",
"!",
"authorizer",
".",
"AuthUnitAgent",
"(",
")",
"&&",
"!",
"aut... | // NewLeadershipService constructs a new LeadershipService. | [
"NewLeadershipService",
"constructs",
"a",
"new",
"LeadershipService",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/leadership/leadership.go#L45-L57 |
157,779 | juju/juju | apiserver/facades/agent/leadership/leadership.go | ClaimLeadership | func (m *leadershipService) ClaimLeadership(args params.ClaimLeadershipBulkParams) (params.ClaimLeadershipBulkResults, error) {
results := make([]params.ErrorResult, len(args.Params))
for pIdx, p := range args.Params {
result := &results[pIdx]
applicationTag, unitTag, err := parseApplicationAndUnitTags(p.Applic... | go | func (m *leadershipService) ClaimLeadership(args params.ClaimLeadershipBulkParams) (params.ClaimLeadershipBulkResults, error) {
results := make([]params.ErrorResult, len(args.Params))
for pIdx, p := range args.Params {
result := &results[pIdx]
applicationTag, unitTag, err := parseApplicationAndUnitTags(p.Applic... | [
"func",
"(",
"m",
"*",
"leadershipService",
")",
"ClaimLeadership",
"(",
"args",
"params",
".",
"ClaimLeadershipBulkParams",
")",
"(",
"params",
".",
"ClaimLeadershipBulkResults",
",",
"error",
")",
"{",
"results",
":=",
"make",
"(",
"[",
"]",
"params",
".",
... | // ClaimLeadership is part of the LeadershipService interface. | [
"ClaimLeadership",
"is",
"part",
"of",
"the",
"LeadershipService",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/leadership/leadership.go#L67-L105 |
157,780 | juju/juju | apiserver/facades/agent/leadership/leadership.go | BlockUntilLeadershipReleased | func (m *leadershipService) BlockUntilLeadershipReleased(ctx context.Context, applicationTag names.ApplicationTag) (params.ErrorResult, error) {
authTag := m.authorizer.GetAuthTag()
hasPerm := false
switch authTag.(type) {
case names.UnitTag:
hasPerm = m.authMember(applicationTag)
case names.ApplicationTag:
ha... | go | func (m *leadershipService) BlockUntilLeadershipReleased(ctx context.Context, applicationTag names.ApplicationTag) (params.ErrorResult, error) {
authTag := m.authorizer.GetAuthTag()
hasPerm := false
switch authTag.(type) {
case names.UnitTag:
hasPerm = m.authMember(applicationTag)
case names.ApplicationTag:
ha... | [
"func",
"(",
"m",
"*",
"leadershipService",
")",
"BlockUntilLeadershipReleased",
"(",
"ctx",
"context",
".",
"Context",
",",
"applicationTag",
"names",
".",
"ApplicationTag",
")",
"(",
"params",
".",
"ErrorResult",
",",
"error",
")",
"{",
"authTag",
":=",
"m",... | // BlockUntilLeadershipReleased implements the LeadershipService interface. | [
"BlockUntilLeadershipReleased",
"implements",
"the",
"LeadershipService",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/leadership/leadership.go#L108-L126 |
157,781 | juju/juju | apiserver/facades/agent/leadership/leadership.go | parseApplicationAndUnitTags | func parseApplicationAndUnitTags(
applicationTagString, unitTagString string,
) (
names.ApplicationTag, names.UnitTag, error,
) {
// TODO(fwereade) 2015-02-25 bug #1425506
// These permissions errors are not appropriate -- there's no permission or
// security issue in play here, because our tag format is public, a... | go | func parseApplicationAndUnitTags(
applicationTagString, unitTagString string,
) (
names.ApplicationTag, names.UnitTag, error,
) {
// TODO(fwereade) 2015-02-25 bug #1425506
// These permissions errors are not appropriate -- there's no permission or
// security issue in play here, because our tag format is public, a... | [
"func",
"parseApplicationAndUnitTags",
"(",
"applicationTagString",
",",
"unitTagString",
"string",
",",
")",
"(",
"names",
".",
"ApplicationTag",
",",
"names",
".",
"UnitTag",
",",
"error",
",",
")",
"{",
"// TODO(fwereade) 2015-02-25 bug #1425506",
"// These permissio... | // parseApplicationAndUnitTags takes in string representations of application
// and unit tags and returns their corresponding tags. | [
"parseApplicationAndUnitTags",
"takes",
"in",
"string",
"representations",
"of",
"application",
"and",
"unit",
"tags",
"and",
"returns",
"their",
"corresponding",
"tags",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/leadership/leadership.go#L144-L164 |
157,782 | juju/juju | state/relationunit.go | subordinateOps | func (ru *RelationUnit) subordinateOps() ([]txn.Op, string, error) {
units, closer := ru.st.db().GetCollection(unitsC)
defer closer()
if !ru.isPrincipal || ru.endpoint.Scope != charm.ScopeContainer {
return nil, "", nil
}
related, err := ru.relation.RelatedEndpoints(ru.endpoint.ApplicationName)
if err != nil {... | go | func (ru *RelationUnit) subordinateOps() ([]txn.Op, string, error) {
units, closer := ru.st.db().GetCollection(unitsC)
defer closer()
if !ru.isPrincipal || ru.endpoint.Scope != charm.ScopeContainer {
return nil, "", nil
}
related, err := ru.relation.RelatedEndpoints(ru.endpoint.ApplicationName)
if err != nil {... | [
"func",
"(",
"ru",
"*",
"RelationUnit",
")",
"subordinateOps",
"(",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"string",
",",
"error",
")",
"{",
"units",
",",
"closer",
":=",
"ru",
".",
"st",
".",
"db",
"(",
")",
".",
"GetCollection",
"(",
"units... | // subordinateOps returns any txn operations necessary to ensure sane
// subordinate state when entering scope. If a required subordinate unit
// exists and is Alive, its name will be returned as well; if one exists
// but is not Alive, ErrCannotEnterScopeYet is returned. | [
"subordinateOps",
"returns",
"any",
"txn",
"operations",
"necessary",
"to",
"ensure",
"sane",
"subordinate",
"state",
"when",
"entering",
"scope",
".",
"If",
"a",
"required",
"subordinate",
"unit",
"exists",
"and",
"is",
"Alive",
"its",
"name",
"will",
"be",
"... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationunit.go#L217-L251 |
157,783 | juju/juju | state/relationunit.go | LeaveScopeOperation | func (ru *RelationUnit) LeaveScopeOperation(force bool) *LeaveScopeOperation {
return &LeaveScopeOperation{
ru: &RelationUnit{
st: ru.st,
relation: ru.relation,
unitName: ru.unitName,
isPrincipal: ru.isPrincipal,
endpoint: ru.endpoint,
scope: ru.scope,
isLocalUnit: ru.isL... | go | func (ru *RelationUnit) LeaveScopeOperation(force bool) *LeaveScopeOperation {
return &LeaveScopeOperation{
ru: &RelationUnit{
st: ru.st,
relation: ru.relation,
unitName: ru.unitName,
isPrincipal: ru.isPrincipal,
endpoint: ru.endpoint,
scope: ru.scope,
isLocalUnit: ru.isL... | [
"func",
"(",
"ru",
"*",
"RelationUnit",
")",
"LeaveScopeOperation",
"(",
"force",
"bool",
")",
"*",
"LeaveScopeOperation",
"{",
"return",
"&",
"LeaveScopeOperation",
"{",
"ru",
":",
"&",
"RelationUnit",
"{",
"st",
":",
"ru",
".",
"st",
",",
"relation",
":"... | // LeaveScopeOperation returns a model operation that will allow relation to leave scope. | [
"LeaveScopeOperation",
"returns",
"a",
"model",
"operation",
"that",
"will",
"allow",
"relation",
"to",
"leave",
"scope",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationunit.go#L275-L288 |
157,784 | juju/juju | state/relationunit.go | leaveScopeForcedOps | func (ru *RelationUnit) leaveScopeForcedOps(existingOperation *ForcedOperation) ([]txn.Op, error) {
// It does not matter that we are say false to force here- we'll overwrite the whole ForcedOperation.
leaveScopeOperation := ru.LeaveScopeOperation(false)
leaveScopeOperation.ForcedOperation = *existingOperation
retu... | go | func (ru *RelationUnit) leaveScopeForcedOps(existingOperation *ForcedOperation) ([]txn.Op, error) {
// It does not matter that we are say false to force here- we'll overwrite the whole ForcedOperation.
leaveScopeOperation := ru.LeaveScopeOperation(false)
leaveScopeOperation.ForcedOperation = *existingOperation
retu... | [
"func",
"(",
"ru",
"*",
"RelationUnit",
")",
"leaveScopeForcedOps",
"(",
"existingOperation",
"*",
"ForcedOperation",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"// It does not matter that we are say false to force here- we'll overwrite the whole Forced... | // leaveScopeForcedOps is an internal method used by other state objects when they just want
// to get database operations that are involved in leaving scop without
// the actual immeiate act of leaving scope. | [
"leaveScopeForcedOps",
"is",
"an",
"internal",
"method",
"used",
"by",
"other",
"state",
"objects",
"when",
"they",
"just",
"want",
"to",
"get",
"database",
"operations",
"that",
"are",
"involved",
"in",
"leaving",
"scop",
"without",
"the",
"actual",
"immeiate",... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationunit.go#L365-L370 |
157,785 | juju/juju | state/relationunit.go | internalLeaveScope | func (op *LeaveScopeOperation) internalLeaveScope() ([]txn.Op, error) {
relationScopes, closer := op.ru.st.db().GetCollection(relationScopesC)
defer closer()
key := op.ru.key()
// The logic below is involved because we remove a dying relation
// with the last unit that leaves a scope in it. It handles three
// p... | go | func (op *LeaveScopeOperation) internalLeaveScope() ([]txn.Op, error) {
relationScopes, closer := op.ru.st.db().GetCollection(relationScopesC)
defer closer()
key := op.ru.key()
// The logic below is involved because we remove a dying relation
// with the last unit that leaves a scope in it. It handles three
// p... | [
"func",
"(",
"op",
"*",
"LeaveScopeOperation",
")",
"internalLeaveScope",
"(",
")",
"(",
"[",
"]",
"txn",
".",
"Op",
",",
"error",
")",
"{",
"relationScopes",
",",
"closer",
":=",
"op",
".",
"ru",
".",
"st",
".",
"db",
"(",
")",
".",
"GetCollection",... | // When 'force' is set, this call will return needed operations
// and will accumulate all operational errors encountered in the operation.
// If the 'force' is not set, any error will be fatal and no operations will be applied. | [
"When",
"force",
"is",
"set",
"this",
"call",
"will",
"return",
"needed",
"operations",
"and",
"will",
"accumulate",
"all",
"operational",
"errors",
"encountered",
"in",
"the",
"operation",
".",
"If",
"the",
"force",
"is",
"not",
"set",
"any",
"error",
"will... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationunit.go#L375-L447 |
157,786 | juju/juju | state/relationunit.go | Joined | func (ru *RelationUnit) Joined() (bool, error) {
return ru.inScope(bson.D{{"departing", bson.D{{"$ne", true}}}})
} | go | func (ru *RelationUnit) Joined() (bool, error) {
return ru.inScope(bson.D{{"departing", bson.D{{"$ne", true}}}})
} | [
"func",
"(",
"ru",
"*",
"RelationUnit",
")",
"Joined",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"return",
"ru",
".",
"inScope",
"(",
"bson",
".",
"D",
"{",
"{",
"\"",
"\"",
",",
"bson",
".",
"D",
"{",
"{",
"\"",
"\"",
",",
"true",
"}",
... | // Joined returns whether the relation unit has entered scope and neither left
// it nor prepared to leave it. | [
"Joined",
"returns",
"whether",
"the",
"relation",
"unit",
"has",
"entered",
"scope",
"and",
"neither",
"left",
"it",
"nor",
"prepared",
"to",
"leave",
"it",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationunit.go#L512-L514 |
157,787 | juju/juju | state/relationunit.go | inScope | func (ru *RelationUnit) inScope(sel bson.D) (bool, error) {
relationScopes, closer := ru.st.db().GetCollection(relationScopesC)
defer closer()
sel = append(sel, bson.D{{"_id", ru.key()}}...)
count, err := relationScopes.Find(sel).Count()
if err != nil {
return false, err
}
return count > 0, nil
} | go | func (ru *RelationUnit) inScope(sel bson.D) (bool, error) {
relationScopes, closer := ru.st.db().GetCollection(relationScopesC)
defer closer()
sel = append(sel, bson.D{{"_id", ru.key()}}...)
count, err := relationScopes.Find(sel).Count()
if err != nil {
return false, err
}
return count > 0, nil
} | [
"func",
"(",
"ru",
"*",
"RelationUnit",
")",
"inScope",
"(",
"sel",
"bson",
".",
"D",
")",
"(",
"bool",
",",
"error",
")",
"{",
"relationScopes",
",",
"closer",
":=",
"ru",
".",
"st",
".",
"db",
"(",
")",
".",
"GetCollection",
"(",
"relationScopesC",... | // inScope returns whether a scope document exists satisfying the supplied
// selector. | [
"inScope",
"returns",
"whether",
"a",
"scope",
"document",
"exists",
"satisfying",
"the",
"supplied",
"selector",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationunit.go#L518-L528 |
157,788 | juju/juju | state/relationunit.go | WatchScope | func (ru *RelationUnit) WatchScope() *RelationScopeWatcher {
role := counterpartRole(ru.endpoint.Role)
return watchRelationScope(ru.st, ru.scope, role, ru.unitName)
} | go | func (ru *RelationUnit) WatchScope() *RelationScopeWatcher {
role := counterpartRole(ru.endpoint.Role)
return watchRelationScope(ru.st, ru.scope, role, ru.unitName)
} | [
"func",
"(",
"ru",
"*",
"RelationUnit",
")",
"WatchScope",
"(",
")",
"*",
"RelationScopeWatcher",
"{",
"role",
":=",
"counterpartRole",
"(",
"ru",
".",
"endpoint",
".",
"Role",
")",
"\n",
"return",
"watchRelationScope",
"(",
"ru",
".",
"st",
",",
"ru",
"... | // WatchScope returns a watcher which notifies of counterpart units
// entering and leaving the unit's scope. | [
"WatchScope",
"returns",
"a",
"watcher",
"which",
"notifies",
"of",
"counterpart",
"units",
"entering",
"and",
"leaving",
"the",
"unit",
"s",
"scope",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationunit.go#L532-L535 |
157,789 | juju/juju | state/relationunit.go | unitKey | func (ru *RelationUnit) unitKey(uname string) (string, error) {
uparts := strings.Split(uname, "/")
sname := uparts[0]
ep, err := ru.relation.Endpoint(sname)
if err != nil {
return "", err
}
return ru._key(string(ep.Role), uname), nil
} | go | func (ru *RelationUnit) unitKey(uname string) (string, error) {
uparts := strings.Split(uname, "/")
sname := uparts[0]
ep, err := ru.relation.Endpoint(sname)
if err != nil {
return "", err
}
return ru._key(string(ep.Role), uname), nil
} | [
"func",
"(",
"ru",
"*",
"RelationUnit",
")",
"unitKey",
"(",
"uname",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"uparts",
":=",
"strings",
".",
"Split",
"(",
"uname",
",",
"\"",
"\"",
")",
"\n",
"sname",
":=",
"uparts",
"[",
"0",
"]",
... | // unitKey returns a string, based on the relation and the supplied unit name,
// which is used as a key for that unit within this relation in the settings,
// presence, and relationScopes collections. | [
"unitKey",
"returns",
"a",
"string",
"based",
"on",
"the",
"relation",
"and",
"the",
"supplied",
"unit",
"name",
"which",
"is",
"used",
"as",
"a",
"key",
"for",
"that",
"unit",
"within",
"this",
"relation",
"in",
"the",
"settings",
"presence",
"and",
"rela... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationunit.go#L696-L704 |
157,790 | juju/juju | state/relationunit.go | key | func (ru *RelationUnit) key() string {
return ru._key(string(ru.endpoint.Role), ru.unitName)
} | go | func (ru *RelationUnit) key() string {
return ru._key(string(ru.endpoint.Role), ru.unitName)
} | [
"func",
"(",
"ru",
"*",
"RelationUnit",
")",
"key",
"(",
")",
"string",
"{",
"return",
"ru",
".",
"_key",
"(",
"string",
"(",
"ru",
".",
"endpoint",
".",
"Role",
")",
",",
"ru",
".",
"unitName",
")",
"\n",
"}"
] | // key returns a string, based on the relation and the current unit name,
// which is used as a key for that unit within this relation in the settings,
// presence, and relationScopes collections. | [
"key",
"returns",
"a",
"string",
"based",
"on",
"the",
"relation",
"and",
"the",
"current",
"unit",
"name",
"which",
"is",
"used",
"as",
"a",
"key",
"for",
"that",
"unit",
"within",
"this",
"relation",
"in",
"the",
"settings",
"presence",
"and",
"relationS... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/relationunit.go#L709-L711 |
157,791 | juju/juju | worker/uniter/paths.go | ComponentDir | func (paths Paths) ComponentDir(name string) string {
return filepath.Join(paths.State.BaseDir, name)
} | go | func (paths Paths) ComponentDir(name string) string {
return filepath.Join(paths.State.BaseDir, name)
} | [
"func",
"(",
"paths",
"Paths",
")",
"ComponentDir",
"(",
"name",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"paths",
".",
"State",
".",
"BaseDir",
",",
"name",
")",
"\n",
"}"
] | // ComponentDir returns the filesystem path to the directory
// containing all data files for a component. | [
"ComponentDir",
"returns",
"the",
"filesystem",
"path",
"to",
"the",
"directory",
"containing",
"all",
"data",
"files",
"for",
"a",
"component",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/paths.go#L58-L60 |
157,792 | juju/juju | worker/uniter/paths.go | NewWorkerPaths | func NewWorkerPaths(dataDir string, unitTag names.UnitTag, worker string) Paths {
join := filepath.Join
baseDir := join(dataDir, "agents", unitTag.String())
stateDir := join(baseDir, "state")
socket := func(name string, abstract bool) string {
if os.HostOS() == os.Windows {
base := fmt.Sprintf("%s", unitTag)
... | go | func NewWorkerPaths(dataDir string, unitTag names.UnitTag, worker string) Paths {
join := filepath.Join
baseDir := join(dataDir, "agents", unitTag.String())
stateDir := join(baseDir, "state")
socket := func(name string, abstract bool) string {
if os.HostOS() == os.Windows {
base := fmt.Sprintf("%s", unitTag)
... | [
"func",
"NewWorkerPaths",
"(",
"dataDir",
"string",
",",
"unitTag",
"names",
".",
"UnitTag",
",",
"worker",
"string",
")",
"Paths",
"{",
"join",
":=",
"filepath",
".",
"Join",
"\n",
"baseDir",
":=",
"join",
"(",
"dataDir",
",",
"\"",
"\"",
",",
"unitTag"... | // NewWorkerPaths returns the set of filesystem paths that the supplied unit worker should
// use, given the supplied root juju data directory path and worker identifier.
// Distinct worker identifiers ensure that runtime paths of different worker do not interfere. | [
"NewWorkerPaths",
"returns",
"the",
"set",
"of",
"filesystem",
"paths",
"that",
"the",
"supplied",
"unit",
"worker",
"should",
"use",
"given",
"the",
"supplied",
"root",
"juju",
"data",
"directory",
"path",
"and",
"worker",
"identifier",
".",
"Distinct",
"worker... | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/paths.go#L117-L158 |
157,793 | juju/juju | api/meterstatus/client.go | NewClient | func NewClient(caller base.APICaller, tag names.UnitTag) MeterStatusClient {
return &Client{
facade: base.NewFacadeCaller(caller, "MeterStatus"),
tag: tag,
}
} | go | func NewClient(caller base.APICaller, tag names.UnitTag) MeterStatusClient {
return &Client{
facade: base.NewFacadeCaller(caller, "MeterStatus"),
tag: tag,
}
} | [
"func",
"NewClient",
"(",
"caller",
"base",
".",
"APICaller",
",",
"tag",
"names",
".",
"UnitTag",
")",
"MeterStatusClient",
"{",
"return",
"&",
"Client",
"{",
"facade",
":",
"base",
".",
"NewFacadeCaller",
"(",
"caller",
",",
"\"",
"\"",
")",
",",
"tag"... | // NewClient creates a new client for accessing the MeterStatus API. | [
"NewClient",
"creates",
"a",
"new",
"client",
"for",
"accessing",
"the",
"MeterStatus",
"API",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/meterstatus/client.go#L29-L34 |
157,794 | juju/juju | api/meterstatus/client.go | MeterStatus | func (c *Client) MeterStatus() (statusCode, statusInfo string, rErr error) {
var results params.MeterStatusResults
args := params.Entities{
Entities: []params.Entity{{Tag: c.tag.String()}},
}
err := c.facade.FacadeCall("GetMeterStatus", args, &results)
if err != nil {
return "", "", errors.Trace(err)
}
if le... | go | func (c *Client) MeterStatus() (statusCode, statusInfo string, rErr error) {
var results params.MeterStatusResults
args := params.Entities{
Entities: []params.Entity{{Tag: c.tag.String()}},
}
err := c.facade.FacadeCall("GetMeterStatus", args, &results)
if err != nil {
return "", "", errors.Trace(err)
}
if le... | [
"func",
"(",
"c",
"*",
"Client",
")",
"MeterStatus",
"(",
")",
"(",
"statusCode",
",",
"statusInfo",
"string",
",",
"rErr",
"error",
")",
"{",
"var",
"results",
"params",
".",
"MeterStatusResults",
"\n",
"args",
":=",
"params",
".",
"Entities",
"{",
"Ent... | // MeterStatus is part of the MeterStatusClient interface. | [
"MeterStatus",
"is",
"part",
"of",
"the",
"MeterStatusClient",
"interface",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/meterstatus/client.go#L45-L62 |
157,795 | juju/juju | apiserver/facades/client/cloud/backend.go | Get | func (s statePoolShim) Get(modelUUID string) (PooledModelBackend, error) {
m, err := s.StatePool.Get(modelUUID)
return NewPooledModelBackend(m), err
} | go | func (s statePoolShim) Get(modelUUID string) (PooledModelBackend, error) {
m, err := s.StatePool.Get(modelUUID)
return NewPooledModelBackend(m), err
} | [
"func",
"(",
"s",
"statePoolShim",
")",
"Get",
"(",
"modelUUID",
"string",
")",
"(",
"PooledModelBackend",
",",
"error",
")",
"{",
"m",
",",
"err",
":=",
"s",
".",
"StatePool",
".",
"Get",
"(",
"modelUUID",
")",
"\n",
"return",
"NewPooledModelBackend",
"... | // Get implements ModelPoolBackend.Get. | [
"Get",
"implements",
"ModelPoolBackend",
".",
"Get",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/cloud/backend.go#L98-L101 |
157,796 | juju/juju | apiserver/facades/client/cloud/backend.go | Model | func (s modelShim) Model() credentialcommon.PersistentBackend {
return credentialcommon.NewPersistentBackend(s.PooledState.State)
} | go | func (s modelShim) Model() credentialcommon.PersistentBackend {
return credentialcommon.NewPersistentBackend(s.PooledState.State)
} | [
"func",
"(",
"s",
"modelShim",
")",
"Model",
"(",
")",
"credentialcommon",
".",
"PersistentBackend",
"{",
"return",
"credentialcommon",
".",
"NewPersistentBackend",
"(",
"s",
".",
"PooledState",
".",
"State",
")",
"\n",
"}"
] | // Model implements PooledModelBackend.Model. | [
"Model",
"implements",
"PooledModelBackend",
".",
"Model",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/client/cloud/backend.go#L121-L123 |
157,797 | juju/juju | apiserver/params/http.go | EncodeChecksum | func EncodeChecksum(checksum string) string {
return fmt.Sprintf("%s=%s", DigestSHA256, base64.StdEncoding.EncodeToString([]byte(checksum)))
} | go | func EncodeChecksum(checksum string) string {
return fmt.Sprintf("%s=%s", DigestSHA256, base64.StdEncoding.EncodeToString([]byte(checksum)))
} | [
"func",
"EncodeChecksum",
"(",
"checksum",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"DigestSHA256",
",",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"(",
"[",
"]",
"byte",
"(",
"checksum",
")",
")",
")... | // EncodeChecksum base64 encodes a sha256 checksum according to RFC 4648 and
// returns a value that can be added to the "Digest" http header. | [
"EncodeChecksum",
"base64",
"encodes",
"a",
"sha256",
"checksum",
"according",
"to",
"RFC",
"4648",
"and",
"returns",
"a",
"value",
"that",
"can",
"be",
"added",
"to",
"the",
"Digest",
"http",
"header",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/params/http.go#L36-L38 |
157,798 | juju/juju | api/base/caller.go | NewFacadeCaller | func NewFacadeCaller(caller APICaller, facadeName string) FacadeCaller {
return NewFacadeCallerForVersion(caller, facadeName, caller.BestFacadeVersion(facadeName))
} | go | func NewFacadeCaller(caller APICaller, facadeName string) FacadeCaller {
return NewFacadeCallerForVersion(caller, facadeName, caller.BestFacadeVersion(facadeName))
} | [
"func",
"NewFacadeCaller",
"(",
"caller",
"APICaller",
",",
"facadeName",
"string",
")",
"FacadeCaller",
"{",
"return",
"NewFacadeCallerForVersion",
"(",
"caller",
",",
"facadeName",
",",
"caller",
".",
"BestFacadeVersion",
"(",
"facadeName",
")",
")",
"\n",
"}"
] | // NewFacadeCaller wraps an APICaller for a given facade name and the
// best available version. | [
"NewFacadeCaller",
"wraps",
"an",
"APICaller",
"for",
"a",
"given",
"facade",
"name",
"and",
"the",
"best",
"available",
"version",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/base/caller.go#L155-L157 |
157,799 | juju/juju | api/base/caller.go | NewFacadeCallerForVersion | func NewFacadeCallerForVersion(caller APICaller, facadeName string, version int) FacadeCaller {
return facadeCaller{
facadeName: facadeName,
bestVersion: version,
caller: caller,
}
} | go | func NewFacadeCallerForVersion(caller APICaller, facadeName string, version int) FacadeCaller {
return facadeCaller{
facadeName: facadeName,
bestVersion: version,
caller: caller,
}
} | [
"func",
"NewFacadeCallerForVersion",
"(",
"caller",
"APICaller",
",",
"facadeName",
"string",
",",
"version",
"int",
")",
"FacadeCaller",
"{",
"return",
"facadeCaller",
"{",
"facadeName",
":",
"facadeName",
",",
"bestVersion",
":",
"version",
",",
"caller",
":",
... | // NewFacadeCallerForVersion wraps an APICaller for a given facade
// name and version. | [
"NewFacadeCallerForVersion",
"wraps",
"an",
"APICaller",
"for",
"a",
"given",
"facade",
"name",
"and",
"version",
"."
] | ba728eedb1e44937c7bdc59f374b06400d0c7133 | https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/base/caller.go#L161-L167 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.