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
155,600
juju/juju
worker/centralhub/manifold.go
Manifold
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{ config.StateConfigWatcherName, }, Start: func(context dependency.Context) (worker.Worker, error) { // Confirm we're running in a state server by asking the // stateconfigwatcher manifold. var haveStateConfig bool if err := context.Get(config.StateConfigWatcherName, &haveStateConfig); err != nil { return nil, err } if !haveStateConfig { return nil, dependency.ErrMissing } if config.Hub == nil { return nil, errors.NotValidf("missing hub") } w := &centralHub{ hub: config.Hub, } w.tomb.Go(func() error { <-w.tomb.Dying() return nil }) return w, nil }, Output: outputFunc, } }
go
func Manifold(config ManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{ config.StateConfigWatcherName, }, Start: func(context dependency.Context) (worker.Worker, error) { // Confirm we're running in a state server by asking the // stateconfigwatcher manifold. var haveStateConfig bool if err := context.Get(config.StateConfigWatcherName, &haveStateConfig); err != nil { return nil, err } if !haveStateConfig { return nil, dependency.ErrMissing } if config.Hub == nil { return nil, errors.NotValidf("missing hub") } w := &centralHub{ hub: config.Hub, } w.tomb.Go(func() error { <-w.tomb.Dying() return nil }) return w, nil }, Output: outputFunc, } }
[ "func", "Manifold", "(", "config", "ManifoldConfig", ")", "dependency", ".", "Manifold", "{", "return", "dependency", ".", "Manifold", "{", "Inputs", ":", "[", "]", "string", "{", "config", ".", "StateConfigWatcherName", ",", "}", ",", "Start", ":", "func", ...
// Manifold returns a manifold whose worker simply provides the central hub. // This hub is a dependency for any other workers that need the hub.
[ "Manifold", "returns", "a", "manifold", "whose", "worker", "simply", "provides", "the", "central", "hub", ".", "This", "hub", "is", "a", "dependency", "for", "any", "other", "workers", "that", "need", "the", "hub", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/centralhub/manifold.go#L24-L55
155,601
juju/juju
api/http.go
RootHTTPClient
func (s *state) RootHTTPClient() (*httprequest.Client, error) { return s.httpClient(&url.URL{ Scheme: s.serverScheme, Host: s.Addr(), }) }
go
func (s *state) RootHTTPClient() (*httprequest.Client, error) { return s.httpClient(&url.URL{ Scheme: s.serverScheme, Host: s.Addr(), }) }
[ "func", "(", "s", "*", "state", ")", "RootHTTPClient", "(", ")", "(", "*", "httprequest", ".", "Client", ",", "error", ")", "{", "return", "s", ".", "httpClient", "(", "&", "url", ".", "URL", "{", "Scheme", ":", "s", ".", "serverScheme", ",", "Host...
// HTTPClient implements Connection.APICaller.HTTPClient and returns an HTTP // client pointing to the API server root path.
[ "HTTPClient", "implements", "Connection", ".", "APICaller", ".", "HTTPClient", "and", "returns", "an", "HTTP", "client", "pointing", "to", "the", "API", "server", "root", "path", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/http.go#L34-L39
155,602
juju/juju
api/http.go
Do
func (doer httpRequestDoer) Do(req *http.Request) (*http.Response, error) { return doer.DoWithBody(req, nil) }
go
func (doer httpRequestDoer) Do(req *http.Request) (*http.Response, error) { return doer.DoWithBody(req, nil) }
[ "func", "(", "doer", "httpRequestDoer", ")", "Do", "(", "req", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "return", "doer", ".", "DoWithBody", "(", "req", ",", "nil", ")", "\n", "}" ]
// Do implements httprequest.Doer.Do.
[ "Do", "implements", "httprequest", ".", "Doer", ".", "Do", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/http.go#L66-L68
155,603
juju/juju
api/http.go
DoWithBody
func (doer httpRequestDoer) DoWithBody(req *http.Request, body io.ReadSeeker) (*http.Response, error) { if err := authHTTPRequest( req, doer.st.tag, doer.st.password, doer.st.nonce, doer.st.macaroons, ); err != nil { return nil, errors.Trace(err) } return doer.st.bakeryClient.DoWithBodyAndCustomError(req, body, func(resp *http.Response) error { // At this point we are only interested in errors that // the bakery cares about, and the CodeDischargeRequired // error is the only one, and that always comes with a // response code StatusUnauthorized. if resp.StatusCode != http.StatusUnauthorized { return nil } return bakeryError(unmarshalHTTPErrorResponse(resp)) }) }
go
func (doer httpRequestDoer) DoWithBody(req *http.Request, body io.ReadSeeker) (*http.Response, error) { if err := authHTTPRequest( req, doer.st.tag, doer.st.password, doer.st.nonce, doer.st.macaroons, ); err != nil { return nil, errors.Trace(err) } return doer.st.bakeryClient.DoWithBodyAndCustomError(req, body, func(resp *http.Response) error { // At this point we are only interested in errors that // the bakery cares about, and the CodeDischargeRequired // error is the only one, and that always comes with a // response code StatusUnauthorized. if resp.StatusCode != http.StatusUnauthorized { return nil } return bakeryError(unmarshalHTTPErrorResponse(resp)) }) }
[ "func", "(", "doer", "httpRequestDoer", ")", "DoWithBody", "(", "req", "*", "http", ".", "Request", ",", "body", "io", ".", "ReadSeeker", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "if", "err", ":=", "authHTTPRequest", "(", "req", ...
// DoWithBody implements httprequest.DoerWithBody.DoWithBody.
[ "DoWithBody", "implements", "httprequest", ".", "DoerWithBody", ".", "DoWithBody", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/http.go#L71-L91
155,604
juju/juju
api/http.go
encodeMacaroonSlice
func encodeMacaroonSlice(ms macaroon.Slice) (string, error) { data, err := json.Marshal(ms) if err != nil { return "", errors.Trace(err) } return base64.StdEncoding.EncodeToString(data), nil }
go
func encodeMacaroonSlice(ms macaroon.Slice) (string, error) { data, err := json.Marshal(ms) if err != nil { return "", errors.Trace(err) } return base64.StdEncoding.EncodeToString(data), nil }
[ "func", "encodeMacaroonSlice", "(", "ms", "macaroon", ".", "Slice", ")", "(", "string", ",", "error", ")", "{", "data", ",", "err", ":=", "json", ".", "Marshal", "(", "ms", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "error...
// encodeMacaroonSlice base64-JSON-encodes a slice of macaroons.
[ "encodeMacaroonSlice", "base64", "-", "JSON", "-", "encodes", "a", "slice", "of", "macaroons", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/http.go#L124-L130
155,605
juju/juju
api/http.go
unmarshalHTTPErrorResponse
func unmarshalHTTPErrorResponse(resp *http.Response) error { var body json.RawMessage if err := httprequest.UnmarshalJSONResponse(resp, &body); err != nil { return errors.Trace(err) } // genericErrorResponse defines a struct that is compatible with all the // known error types, so that we can know which of the // possible error types has been returned. // // Another possible approach might be to look at resp.Request.URL.Path // and determine the expected error type from that, but that // seems more fragile than this approach. type genericErrorResponse struct { Error json.RawMessage `json:"error"` } var generic genericErrorResponse if err := json.Unmarshal(body, &generic); err != nil { return errors.Annotatef(err, "incompatible error response") } if bytes.HasPrefix(generic.Error, []byte(`"`)) { // The error message is in a string, which means that // the error must be in a params.CharmsResponse var resp params.CharmsResponse if err := json.Unmarshal(body, &resp); err != nil { return errors.Annotatef(err, "incompatible error response") } return &params.Error{ Message: resp.Error, Code: resp.ErrorCode, Info: resp.ErrorInfo, } } var errorBody []byte if len(generic.Error) > 0 { // We have an Error field, therefore the error must be in that. // (it's a params.ErrorResponse) errorBody = generic.Error } else { // There wasn't an Error field, so the error must be directly // in the body of the response. errorBody = body } var perr params.Error if err := json.Unmarshal(errorBody, &perr); err != nil { return errors.Annotatef(err, "incompatible error response") } if perr.Message == "" { return errors.Errorf("error response with no message") } return &perr }
go
func unmarshalHTTPErrorResponse(resp *http.Response) error { var body json.RawMessage if err := httprequest.UnmarshalJSONResponse(resp, &body); err != nil { return errors.Trace(err) } // genericErrorResponse defines a struct that is compatible with all the // known error types, so that we can know which of the // possible error types has been returned. // // Another possible approach might be to look at resp.Request.URL.Path // and determine the expected error type from that, but that // seems more fragile than this approach. type genericErrorResponse struct { Error json.RawMessage `json:"error"` } var generic genericErrorResponse if err := json.Unmarshal(body, &generic); err != nil { return errors.Annotatef(err, "incompatible error response") } if bytes.HasPrefix(generic.Error, []byte(`"`)) { // The error message is in a string, which means that // the error must be in a params.CharmsResponse var resp params.CharmsResponse if err := json.Unmarshal(body, &resp); err != nil { return errors.Annotatef(err, "incompatible error response") } return &params.Error{ Message: resp.Error, Code: resp.ErrorCode, Info: resp.ErrorInfo, } } var errorBody []byte if len(generic.Error) > 0 { // We have an Error field, therefore the error must be in that. // (it's a params.ErrorResponse) errorBody = generic.Error } else { // There wasn't an Error field, so the error must be directly // in the body of the response. errorBody = body } var perr params.Error if err := json.Unmarshal(errorBody, &perr); err != nil { return errors.Annotatef(err, "incompatible error response") } if perr.Message == "" { return errors.Errorf("error response with no message") } return &perr }
[ "func", "unmarshalHTTPErrorResponse", "(", "resp", "*", "http", ".", "Response", ")", "error", "{", "var", "body", "json", ".", "RawMessage", "\n", "if", "err", ":=", "httprequest", ".", "UnmarshalJSONResponse", "(", "resp", ",", "&", "body", ")", ";", "er...
// unmarshalHTTPErrorResponse unmarshals an error response from // an HTTP endpoint. For historical reasons, these endpoints // return several different incompatible error response formats. // We cope with this by accepting all of the possible formats // and unmarshaling accordingly. // // It always returns a non-nil error.
[ "unmarshalHTTPErrorResponse", "unmarshals", "an", "error", "response", "from", "an", "HTTP", "endpoint", ".", "For", "historical", "reasons", "these", "endpoints", "return", "several", "different", "incompatible", "error", "response", "formats", ".", "We", "cope", "...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/http.go#L139-L189
155,606
juju/juju
api/http.go
bakeryError
func bakeryError(err error) error { if params.ErrCode(err) != params.CodeDischargeRequired { return err } errResp := errors.Cause(err).(*params.Error) if errResp.Info == nil { return errors.Annotatef(err, "no error info found in discharge-required response error") } // It's a discharge-required error, so make an appropriate httpbakery // error from it. var info params.DischargeRequiredErrorInfo if errUnmarshal := errResp.UnmarshalInfo(&info); errUnmarshal != nil { return errors.Annotatef(err, "unable to extract macaroon details from discharge-required response error") } return &httpbakery.Error{ Message: err.Error(), Code: httpbakery.ErrDischargeRequired, Info: &httpbakery.ErrorInfo{ Macaroon: info.Macaroon, MacaroonPath: info.MacaroonPath, }, } }
go
func bakeryError(err error) error { if params.ErrCode(err) != params.CodeDischargeRequired { return err } errResp := errors.Cause(err).(*params.Error) if errResp.Info == nil { return errors.Annotatef(err, "no error info found in discharge-required response error") } // It's a discharge-required error, so make an appropriate httpbakery // error from it. var info params.DischargeRequiredErrorInfo if errUnmarshal := errResp.UnmarshalInfo(&info); errUnmarshal != nil { return errors.Annotatef(err, "unable to extract macaroon details from discharge-required response error") } return &httpbakery.Error{ Message: err.Error(), Code: httpbakery.ErrDischargeRequired, Info: &httpbakery.ErrorInfo{ Macaroon: info.Macaroon, MacaroonPath: info.MacaroonPath, }, } }
[ "func", "bakeryError", "(", "err", "error", ")", "error", "{", "if", "params", ".", "ErrCode", "(", "err", ")", "!=", "params", ".", "CodeDischargeRequired", "{", "return", "err", "\n", "}", "\n", "errResp", ":=", "errors", ".", "Cause", "(", "err", ")...
// bakeryError translates any discharge-required error into // an error value that the httpbakery package will recognize. // Other errors are returned unchanged.
[ "bakeryError", "translates", "any", "discharge", "-", "required", "error", "into", "an", "error", "value", "that", "the", "httpbakery", "package", "will", "recognize", ".", "Other", "errors", "are", "returned", "unchanged", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/http.go#L194-L217
155,607
juju/juju
api/http.go
openBlob
func openBlob(httpClient HTTPDoer, endpoint string, args url.Values) (io.ReadCloser, error) { apiURL, err := url.Parse(endpoint) if err != nil { return nil, errors.Trace(err) } apiURL.RawQuery = args.Encode() req, err := http.NewRequest("GET", apiURL.String(), nil) if err != nil { return nil, errors.Annotate(err, "cannot create HTTP request") } var resp *http.Response if err := httpClient.Do(req, nil, &resp); err != nil { return nil, errors.Trace(err) } return resp.Body, nil }
go
func openBlob(httpClient HTTPDoer, endpoint string, args url.Values) (io.ReadCloser, error) { apiURL, err := url.Parse(endpoint) if err != nil { return nil, errors.Trace(err) } apiURL.RawQuery = args.Encode() req, err := http.NewRequest("GET", apiURL.String(), nil) if err != nil { return nil, errors.Annotate(err, "cannot create HTTP request") } var resp *http.Response if err := httpClient.Do(req, nil, &resp); err != nil { return nil, errors.Trace(err) } return resp.Body, nil }
[ "func", "openBlob", "(", "httpClient", "HTTPDoer", ",", "endpoint", "string", ",", "args", "url", ".", "Values", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "apiURL", ",", "err", ":=", "url", ".", "Parse", "(", "endpoint", ")", "\n", "...
// openBlob streams the identified blob from the controller via the // provided HTTP client.
[ "openBlob", "streams", "the", "identified", "blob", "from", "the", "controller", "via", "the", "provided", "HTTP", "client", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/http.go#L227-L243
155,608
juju/juju
provider/azure/internal/azureauth/serviceprincipal.go
Create
func (c *ServicePrincipalCreator) Create(sdkCtx context.Context, params ServicePrincipalParams) (appid, password string, _ error) { servicePrincipalObjectId, password, err := c.createOrUpdateServicePrincipal(params) if err != nil { return "", "", errors.Trace(err) } if err := c.createRoleAssignment(sdkCtx, params, servicePrincipalObjectId); err != nil { return "", "", errors.Trace(err) } return jujuApplicationId, password, nil }
go
func (c *ServicePrincipalCreator) Create(sdkCtx context.Context, params ServicePrincipalParams) (appid, password string, _ error) { servicePrincipalObjectId, password, err := c.createOrUpdateServicePrincipal(params) if err != nil { return "", "", errors.Trace(err) } if err := c.createRoleAssignment(sdkCtx, params, servicePrincipalObjectId); err != nil { return "", "", errors.Trace(err) } return jujuApplicationId, password, nil }
[ "func", "(", "c", "*", "ServicePrincipalCreator", ")", "Create", "(", "sdkCtx", "context", ".", "Context", ",", "params", "ServicePrincipalParams", ")", "(", "appid", ",", "password", "string", ",", "_", "error", ")", "{", "servicePrincipalObjectId", ",", "pas...
// Create creates a new service principal using the values specified in params.
[ "Create", "creates", "a", "new", "service", "principal", "using", "the", "values", "specified", "in", "params", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/internal/azureauth/serviceprincipal.go#L210-L219
155,609
juju/juju
provider/lxd/credentials.go
detectLocalCredentials
func (p environProviderCredentials) detectLocalCredentials(certPEM, keyPEM []byte) (*cloud.Credential, error) { svr, err := p.serverFactory.LocalServer() if err != nil { return nil, errors.NewNotFound(err, "failed to connect to local LXD") } label := fmt.Sprintf("LXD credential %q", lxdnames.DefaultCloud) certCredential, err := p.finalizeLocalCredential( ioutil.Discard, svr, string(certPEM), string(keyPEM), label, ) return certCredential, errors.Trace(err) }
go
func (p environProviderCredentials) detectLocalCredentials(certPEM, keyPEM []byte) (*cloud.Credential, error) { svr, err := p.serverFactory.LocalServer() if err != nil { return nil, errors.NewNotFound(err, "failed to connect to local LXD") } label := fmt.Sprintf("LXD credential %q", lxdnames.DefaultCloud) certCredential, err := p.finalizeLocalCredential( ioutil.Discard, svr, string(certPEM), string(keyPEM), label, ) return certCredential, errors.Trace(err) }
[ "func", "(", "p", "environProviderCredentials", ")", "detectLocalCredentials", "(", "certPEM", ",", "keyPEM", "[", "]", "byte", ")", "(", "*", "cloud", ".", "Credential", ",", "error", ")", "{", "svr", ",", "err", ":=", "p", ".", "serverFactory", ".", "L...
// detectLocalCredentials will use the local server to read and finalize the // cloud credentials.
[ "detectLocalCredentials", "will", "use", "the", "local", "server", "to", "read", "and", "finalize", "the", "cloud", "credentials", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/lxd/credentials.go#L175-L186
155,610
juju/juju
provider/lxd/credentials.go
ShouldFinalizeCredential
func (p environProviderCredentials) ShouldFinalizeCredential(cred cloud.Credential) bool { // The credential is fully formed, so we assume the client // certificate is uploaded to the server already. credAttrs := cred.Attributes() _, ok := credAttrs[credAttrServerCert] return !ok }
go
func (p environProviderCredentials) ShouldFinalizeCredential(cred cloud.Credential) bool { // The credential is fully formed, so we assume the client // certificate is uploaded to the server already. credAttrs := cred.Attributes() _, ok := credAttrs[credAttrServerCert] return !ok }
[ "func", "(", "p", "environProviderCredentials", ")", "ShouldFinalizeCredential", "(", "cred", "cloud", ".", "Credential", ")", "bool", "{", "// The credential is fully formed, so we assume the client", "// certificate is uploaded to the server already.", "credAttrs", ":=", "cred"...
// ShouldFinalizeCredential is part of the environs.RequestFinalizeCredential // interface. // This is an optional interface to check if the server certificate has not // been filled in.
[ "ShouldFinalizeCredential", "is", "part", "of", "the", "environs", ".", "RequestFinalizeCredential", "interface", ".", "This", "is", "an", "optional", "interface", "to", "check", "if", "the", "server", "certificate", "has", "not", "been", "filled", "in", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/lxd/credentials.go#L264-L270
155,611
juju/juju
apiserver/facades/agent/uniter/storage.go
newStorageAPI
func newStorageAPI( backend backend, storage storageAccess, resources facade.Resources, accessUnit common.GetAuthFunc, ) (*StorageAPI, error) { return &StorageAPI{ backend: backend, storage: storage, resources: resources, accessUnit: accessUnit, }, nil }
go
func newStorageAPI( backend backend, storage storageAccess, resources facade.Resources, accessUnit common.GetAuthFunc, ) (*StorageAPI, error) { return &StorageAPI{ backend: backend, storage: storage, resources: resources, accessUnit: accessUnit, }, nil }
[ "func", "newStorageAPI", "(", "backend", "backend", ",", "storage", "storageAccess", ",", "resources", "facade", ".", "Resources", ",", "accessUnit", "common", ".", "GetAuthFunc", ",", ")", "(", "*", "StorageAPI", ",", "error", ")", "{", "return", "&", "Stor...
// newStorageAPI creates a new server-side Storage API facade.
[ "newStorageAPI", "creates", "a", "new", "server", "-", "side", "Storage", "API", "facade", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L27-L40
155,612
juju/juju
apiserver/facades/agent/uniter/storage.go
UnitStorageAttachments
func (s *StorageAPI) UnitStorageAttachments(args params.Entities) (params.StorageAttachmentIdsResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.StorageAttachmentIdsResults{}, err } result := params.StorageAttachmentIdsResults{ Results: make([]params.StorageAttachmentIdsResult, len(args.Entities)), } for i, entity := range args.Entities { storageAttachmentIds, err := s.getOneUnitStorageAttachmentIds(canAccess, entity.Tag) if err == nil { result.Results[i].Result = params.StorageAttachmentIds{ storageAttachmentIds, } } result.Results[i].Error = common.ServerError(err) } return result, nil }
go
func (s *StorageAPI) UnitStorageAttachments(args params.Entities) (params.StorageAttachmentIdsResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.StorageAttachmentIdsResults{}, err } result := params.StorageAttachmentIdsResults{ Results: make([]params.StorageAttachmentIdsResult, len(args.Entities)), } for i, entity := range args.Entities { storageAttachmentIds, err := s.getOneUnitStorageAttachmentIds(canAccess, entity.Tag) if err == nil { result.Results[i].Result = params.StorageAttachmentIds{ storageAttachmentIds, } } result.Results[i].Error = common.ServerError(err) } return result, nil }
[ "func", "(", "s", "*", "StorageAPI", ")", "UnitStorageAttachments", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "StorageAttachmentIdsResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "accessUnit", "(", ")", "\n...
// UnitStorageAttachments returns the IDs of storage attachments for a collection of units.
[ "UnitStorageAttachments", "returns", "the", "IDs", "of", "storage", "attachments", "for", "a", "collection", "of", "units", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L43-L61
155,613
juju/juju
apiserver/facades/agent/uniter/storage.go
DestroyUnitStorageAttachments
func (s *StorageAPI) DestroyUnitStorageAttachments(args params.Entities) (params.ErrorResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.ErrorResults{}, err } result := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Entities)), } one := func(tag string) error { unitTag, err := names.ParseUnitTag(tag) if err != nil { return err } if !canAccess(unitTag) { return common.ErrPerm } return s.storage.DestroyUnitStorageAttachments(unitTag) } for i, entity := range args.Entities { err := one(entity.Tag) result.Results[i].Error = common.ServerError(err) } return result, nil }
go
func (s *StorageAPI) DestroyUnitStorageAttachments(args params.Entities) (params.ErrorResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.ErrorResults{}, err } result := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Entities)), } one := func(tag string) error { unitTag, err := names.ParseUnitTag(tag) if err != nil { return err } if !canAccess(unitTag) { return common.ErrPerm } return s.storage.DestroyUnitStorageAttachments(unitTag) } for i, entity := range args.Entities { err := one(entity.Tag) result.Results[i].Error = common.ServerError(err) } return result, nil }
[ "func", "(", "s", "*", "StorageAPI", ")", "DestroyUnitStorageAttachments", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "accessUnit", "(", ")", "\n", "if...
// DestroyUnitStorageAttachments marks each storage attachment of the // specified units as Dying.
[ "DestroyUnitStorageAttachments", "marks", "each", "storage", "attachment", "of", "the", "specified", "units", "as", "Dying", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L86-L109
155,614
juju/juju
apiserver/facades/agent/uniter/storage.go
StorageAttachments
func (s *StorageAPI) StorageAttachments(args params.StorageAttachmentIds) (params.StorageAttachmentResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.StorageAttachmentResults{}, err } result := params.StorageAttachmentResults{ Results: make([]params.StorageAttachmentResult, len(args.Ids)), } for i, id := range args.Ids { storageAttachment, err := s.getOneStorageAttachment(canAccess, id) if err == nil { result.Results[i].Result = storageAttachment } result.Results[i].Error = common.ServerError(err) } return result, nil }
go
func (s *StorageAPI) StorageAttachments(args params.StorageAttachmentIds) (params.StorageAttachmentResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.StorageAttachmentResults{}, err } result := params.StorageAttachmentResults{ Results: make([]params.StorageAttachmentResult, len(args.Ids)), } for i, id := range args.Ids { storageAttachment, err := s.getOneStorageAttachment(canAccess, id) if err == nil { result.Results[i].Result = storageAttachment } result.Results[i].Error = common.ServerError(err) } return result, nil }
[ "func", "(", "s", "*", "StorageAPI", ")", "StorageAttachments", "(", "args", "params", ".", "StorageAttachmentIds", ")", "(", "params", ".", "StorageAttachmentResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "accessUnit", "(", ")", ...
// StorageAttachments returns the storage attachments with the specified tags.
[ "StorageAttachments", "returns", "the", "storage", "attachments", "with", "the", "specified", "tags", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L112-L128
155,615
juju/juju
apiserver/facades/agent/uniter/storage.go
StorageAttachmentLife
func (s *StorageAPI) StorageAttachmentLife(args params.StorageAttachmentIds) (params.LifeResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.LifeResults{}, err } result := params.LifeResults{ Results: make([]params.LifeResult, len(args.Ids)), } for i, id := range args.Ids { stateStorageAttachment, err := s.getOneStateStorageAttachment(canAccess, id) if err == nil { life := stateStorageAttachment.Life() result.Results[i].Life = params.Life(life.String()) } result.Results[i].Error = common.ServerError(err) } return result, nil }
go
func (s *StorageAPI) StorageAttachmentLife(args params.StorageAttachmentIds) (params.LifeResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.LifeResults{}, err } result := params.LifeResults{ Results: make([]params.LifeResult, len(args.Ids)), } for i, id := range args.Ids { stateStorageAttachment, err := s.getOneStateStorageAttachment(canAccess, id) if err == nil { life := stateStorageAttachment.Life() result.Results[i].Life = params.Life(life.String()) } result.Results[i].Error = common.ServerError(err) } return result, nil }
[ "func", "(", "s", "*", "StorageAPI", ")", "StorageAttachmentLife", "(", "args", "params", ".", "StorageAttachmentIds", ")", "(", "params", ".", "LifeResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "accessUnit", "(", ")", "\n", ...
// StorageAttachmentLife returns the lifecycle state of the storage attachments // with the specified tags.
[ "StorageAttachmentLife", "returns", "the", "lifecycle", "state", "of", "the", "storage", "attachments", "with", "the", "specified", "tags", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L132-L149
155,616
juju/juju
apiserver/facades/agent/uniter/storage.go
WatchUnitStorageAttachments
func (s *StorageAPI) WatchUnitStorageAttachments(args params.Entities) (params.StringsWatchResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.StringsWatchResults{}, err } results := params.StringsWatchResults{ Results: make([]params.StringsWatchResult, len(args.Entities)), } for i, entity := range args.Entities { result, err := s.watchOneUnitStorageAttachments(entity.Tag, canAccess) if err == nil { results.Results[i] = result } results.Results[i].Error = common.ServerError(err) } return results, nil }
go
func (s *StorageAPI) WatchUnitStorageAttachments(args params.Entities) (params.StringsWatchResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.StringsWatchResults{}, err } results := params.StringsWatchResults{ Results: make([]params.StringsWatchResult, len(args.Entities)), } for i, entity := range args.Entities { result, err := s.watchOneUnitStorageAttachments(entity.Tag, canAccess) if err == nil { results.Results[i] = result } results.Results[i].Error = common.ServerError(err) } return results, nil }
[ "func", "(", "s", "*", "StorageAPI", ")", "WatchUnitStorageAttachments", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "StringsWatchResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "accessUnit", "(", ")", "\n", ...
// WatchUnitStorageAttachments creates watchers for a collection of units, // each of which can be used to watch for lifecycle changes to the corresponding // unit's storage attachments.
[ "WatchUnitStorageAttachments", "creates", "watchers", "for", "a", "collection", "of", "units", "each", "of", "which", "can", "be", "used", "to", "watch", "for", "lifecycle", "changes", "to", "the", "corresponding", "unit", "s", "storage", "attachments", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L214-L230
155,617
juju/juju
apiserver/facades/agent/uniter/storage.go
WatchStorageAttachments
func (s *StorageAPI) WatchStorageAttachments(args params.StorageAttachmentIds) (params.NotifyWatchResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.NotifyWatchResults{}, err } results := params.NotifyWatchResults{ Results: make([]params.NotifyWatchResult, len(args.Ids)), } for i, id := range args.Ids { result, err := s.watchOneStorageAttachment(id, canAccess) if err == nil { results.Results[i] = result } results.Results[i].Error = common.ServerError(err) } return results, nil }
go
func (s *StorageAPI) WatchStorageAttachments(args params.StorageAttachmentIds) (params.NotifyWatchResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.NotifyWatchResults{}, err } results := params.NotifyWatchResults{ Results: make([]params.NotifyWatchResult, len(args.Ids)), } for i, id := range args.Ids { result, err := s.watchOneStorageAttachment(id, canAccess) if err == nil { results.Results[i] = result } results.Results[i].Error = common.ServerError(err) } return results, nil }
[ "func", "(", "s", "*", "StorageAPI", ")", "WatchStorageAttachments", "(", "args", "params", ".", "StorageAttachmentIds", ")", "(", "params", ".", "NotifyWatchResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "accessUnit", "(", ")", ...
// WatchStorageAttachments creates watchers for a collection of storage // attachments, each of which can be used to watch changes to storage // attachment info.
[ "WatchStorageAttachments", "creates", "watchers", "for", "a", "collection", "of", "storage", "attachments", "each", "of", "which", "can", "be", "used", "to", "watch", "changes", "to", "storage", "attachment", "info", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L251-L267
155,618
juju/juju
apiserver/facades/agent/uniter/storage.go
RemoveStorageAttachments
func (s *StorageAPI) RemoveStorageAttachments(args params.StorageAttachmentIds) (params.ErrorResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.ErrorResults{}, err } results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Ids)), } for i, id := range args.Ids { err := s.removeOneStorageAttachment(id, canAccess) if err != nil { results.Results[i].Error = common.ServerError(err) } } return results, nil }
go
func (s *StorageAPI) RemoveStorageAttachments(args params.StorageAttachmentIds) (params.ErrorResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.ErrorResults{}, err } results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.Ids)), } for i, id := range args.Ids { err := s.removeOneStorageAttachment(id, canAccess) if err != nil { results.Results[i].Error = common.ServerError(err) } } return results, nil }
[ "func", "(", "s", "*", "StorageAPI", ")", "RemoveStorageAttachments", "(", "args", "params", ".", "StorageAttachmentIds", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "accessUnit", "(", ")", "\n"...
// RemoveStorageAttachments removes the specified storage // attachments from state.
[ "RemoveStorageAttachments", "removes", "the", "specified", "storage", "attachments", "from", "state", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L312-L327
155,619
juju/juju
apiserver/facades/agent/uniter/storage.go
AddUnitStorage
func (s *StorageAPI) AddUnitStorage( args params.StoragesAddParams, ) (params.ErrorResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.ErrorResults{}, err } if len(args.Storages) == 0 { return params.ErrorResults{}, nil } serverErr := func(err error) params.ErrorResult { return params.ErrorResult{common.ServerError(err)} } storageErr := func(err error, s, u string) params.ErrorResult { return serverErr(errors.Annotatef(err, "adding storage %v for %v", s, u)) } result := make([]params.ErrorResult, len(args.Storages)) for i, one := range args.Storages { u, err := accessUnitTag(one.UnitTag, canAccess) if err != nil { result[i] = serverErr(err) continue } cons, err := unitStorageConstraints(s.backend, u) if err != nil { result[i] = serverErr(err) continue } oneCons, err := validConstraints(one, cons) if err != nil { result[i] = storageErr(err, one.StorageName, one.UnitTag) continue } _, err = s.storage.AddStorageForUnit(u, one.StorageName, oneCons) if err != nil { result[i] = storageErr(err, one.StorageName, one.UnitTag) } } return params.ErrorResults{Results: result}, nil }
go
func (s *StorageAPI) AddUnitStorage( args params.StoragesAddParams, ) (params.ErrorResults, error) { canAccess, err := s.accessUnit() if err != nil { return params.ErrorResults{}, err } if len(args.Storages) == 0 { return params.ErrorResults{}, nil } serverErr := func(err error) params.ErrorResult { return params.ErrorResult{common.ServerError(err)} } storageErr := func(err error, s, u string) params.ErrorResult { return serverErr(errors.Annotatef(err, "adding storage %v for %v", s, u)) } result := make([]params.ErrorResult, len(args.Storages)) for i, one := range args.Storages { u, err := accessUnitTag(one.UnitTag, canAccess) if err != nil { result[i] = serverErr(err) continue } cons, err := unitStorageConstraints(s.backend, u) if err != nil { result[i] = serverErr(err) continue } oneCons, err := validConstraints(one, cons) if err != nil { result[i] = storageErr(err, one.StorageName, one.UnitTag) continue } _, err = s.storage.AddStorageForUnit(u, one.StorageName, oneCons) if err != nil { result[i] = storageErr(err, one.StorageName, one.UnitTag) } } return params.ErrorResults{Results: result}, nil }
[ "func", "(", "s", "*", "StorageAPI", ")", "AddUnitStorage", "(", "args", "params", ".", "StoragesAddParams", ",", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "canAccess", ",", "err", ":=", "s", ".", "accessUnit", "(", ")", "\n", "i...
// AddUnitStorage validates and creates additional storage instances for units. // Failures on an individual storage instance do not block remaining // instances from being processed.
[ "AddUnitStorage", "validates", "and", "creates", "additional", "storage", "instances", "for", "units", ".", "Failures", "on", "an", "individual", "storage", "instance", "do", "not", "block", "remaining", "instances", "from", "being", "processed", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L353-L398
155,620
juju/juju
apiserver/facades/agent/uniter/storage.go
watchStorageAttachment
func watchStorageAttachment( st storageInterface, stVolume storageVolumeInterface, stFile storageFilesystemInterface, storageTag names.StorageTag, hostTag names.Tag, unitTag names.UnitTag, ) (state.NotifyWatcher, error) { storageInstance, err := st.StorageInstance(storageTag) if err != nil { return nil, errors.Annotate(err, "getting storage instance") } var watchers []state.NotifyWatcher switch storageInstance.Kind() { case state.StorageKindBlock: if stVolume == nil { return nil, errors.NotImplementedf("BlockStorage instance") } volume, err := stVolume.StorageInstanceVolume(storageTag) if err != nil { return nil, errors.Annotate(err, "getting storage volume") } // We need to watch both the volume attachment, and the // machine's block devices. A volume attachment's block // device could change (most likely, become present). watchers = []state.NotifyWatcher{ stVolume.WatchVolumeAttachment(hostTag, volume.VolumeTag()), } // TODO(caas) - we currently only support block devices on machines. if hostTag.Kind() == names.MachineTagKind { // TODO(axw) 2015-09-30 #1501203 // We should filter the events to only those relevant // to the volume attachment. This means we would need // to either start th block device watcher after we // have provisioned the volume attachment (cleaner?), // or have the filter ignore changes until the volume // attachment is provisioned. watchers = append(watchers, stVolume.WatchBlockDevices(hostTag.(names.MachineTag))) } case state.StorageKindFilesystem: if stFile == nil { return nil, errors.NotImplementedf("FilesystemStorage instance") } filesystem, err := stFile.StorageInstanceFilesystem(storageTag) if err != nil { return nil, errors.Annotate(err, "getting storage filesystem") } watchers = []state.NotifyWatcher{ stFile.WatchFilesystemAttachment(hostTag, filesystem.FilesystemTag()), } default: return nil, errors.Errorf("invalid storage kind %v", storageInstance.Kind()) } watchers = append(watchers, st.WatchStorageAttachment(storageTag, unitTag)) return common.NewMultiNotifyWatcher(watchers...), nil }
go
func watchStorageAttachment( st storageInterface, stVolume storageVolumeInterface, stFile storageFilesystemInterface, storageTag names.StorageTag, hostTag names.Tag, unitTag names.UnitTag, ) (state.NotifyWatcher, error) { storageInstance, err := st.StorageInstance(storageTag) if err != nil { return nil, errors.Annotate(err, "getting storage instance") } var watchers []state.NotifyWatcher switch storageInstance.Kind() { case state.StorageKindBlock: if stVolume == nil { return nil, errors.NotImplementedf("BlockStorage instance") } volume, err := stVolume.StorageInstanceVolume(storageTag) if err != nil { return nil, errors.Annotate(err, "getting storage volume") } // We need to watch both the volume attachment, and the // machine's block devices. A volume attachment's block // device could change (most likely, become present). watchers = []state.NotifyWatcher{ stVolume.WatchVolumeAttachment(hostTag, volume.VolumeTag()), } // TODO(caas) - we currently only support block devices on machines. if hostTag.Kind() == names.MachineTagKind { // TODO(axw) 2015-09-30 #1501203 // We should filter the events to only those relevant // to the volume attachment. This means we would need // to either start th block device watcher after we // have provisioned the volume attachment (cleaner?), // or have the filter ignore changes until the volume // attachment is provisioned. watchers = append(watchers, stVolume.WatchBlockDevices(hostTag.(names.MachineTag))) } case state.StorageKindFilesystem: if stFile == nil { return nil, errors.NotImplementedf("FilesystemStorage instance") } filesystem, err := stFile.StorageInstanceFilesystem(storageTag) if err != nil { return nil, errors.Annotate(err, "getting storage filesystem") } watchers = []state.NotifyWatcher{ stFile.WatchFilesystemAttachment(hostTag, filesystem.FilesystemTag()), } default: return nil, errors.Errorf("invalid storage kind %v", storageInstance.Kind()) } watchers = append(watchers, st.WatchStorageAttachment(storageTag, unitTag)) return common.NewMultiNotifyWatcher(watchers...), nil }
[ "func", "watchStorageAttachment", "(", "st", "storageInterface", ",", "stVolume", "storageVolumeInterface", ",", "stFile", "storageFilesystemInterface", ",", "storageTag", "names", ".", "StorageTag", ",", "hostTag", "names", ".", "Tag", ",", "unitTag", "names", ".", ...
// watchStorageAttachment returns a state.NotifyWatcher that reacts to changes // to the VolumeAttachmentInfo or FilesystemAttachmentInfo corresponding to the // tags specified.
[ "watchStorageAttachment", "returns", "a", "state", ".", "NotifyWatcher", "that", "reacts", "to", "changes", "to", "the", "VolumeAttachmentInfo", "or", "FilesystemAttachmentInfo", "corresponding", "to", "the", "tags", "specified", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/uniter/storage.go#L438-L494
155,621
juju/juju
service/windows/password_windows.go
ensureJujudPasswordHelper
func ensureJujudPasswordHelper(username, newPassword string, mgr ServiceManager, helpers PasswordChangerHelpers) error { err := helpers.ChangeUserPasswordLocalhost(newPassword) if err != nil { return errors.Annotate(err, "could not change user password") } err = helpers.ChangeJujudServicesPassword(newPassword, mgr, ListServices) if err != nil { return errors.Annotate(err, "could not change password for all jujud services") } return nil }
go
func ensureJujudPasswordHelper(username, newPassword string, mgr ServiceManager, helpers PasswordChangerHelpers) error { err := helpers.ChangeUserPasswordLocalhost(newPassword) if err != nil { return errors.Annotate(err, "could not change user password") } err = helpers.ChangeJujudServicesPassword(newPassword, mgr, ListServices) if err != nil { return errors.Annotate(err, "could not change password for all jujud services") } return nil }
[ "func", "ensureJujudPasswordHelper", "(", "username", ",", "newPassword", "string", ",", "mgr", "ServiceManager", ",", "helpers", "PasswordChangerHelpers", ")", "error", "{", "err", ":=", "helpers", ".", "ChangeUserPasswordLocalhost", "(", "newPassword", ")", "\n", ...
// ensureJujudPasswordHelper actually does the heavy lifting of changing the password. It checks the registry for a password. If it doesn't exist // then it writes a new one to the registry, changes the password for the local jujud user and sets the password for all it's services.
[ "ensureJujudPasswordHelper", "actually", "does", "the", "heavy", "lifting", "of", "changing", "the", "password", ".", "It", "checks", "the", "registry", "for", "a", "password", ".", "If", "it", "doesn", "t", "exist", "then", "it", "writes", "a", "new", "one"...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/windows/password_windows.go#L56-L68
155,622
juju/juju
service/windows/password_windows.go
ChangeUserPasswordLocalhost
func (c *PasswordChanger) ChangeUserPasswordLocalhost(newPassword string) error { serverp, err := syscall.UTF16PtrFromString("localhost") if err != nil { return errors.Trace(err) } userp, err := syscall.UTF16PtrFromString("jujud") if err != nil { return errors.Trace(err) } passp, err := syscall.UTF16PtrFromString(newPassword) if err != nil { return errors.Trace(err) } info := netUserSetPassword{passp} err = netUserSetInfo(serverp, userp, changePasswordLevel, &info, nil) if err != nil { return errors.Trace(err) } return nil }
go
func (c *PasswordChanger) ChangeUserPasswordLocalhost(newPassword string) error { serverp, err := syscall.UTF16PtrFromString("localhost") if err != nil { return errors.Trace(err) } userp, err := syscall.UTF16PtrFromString("jujud") if err != nil { return errors.Trace(err) } passp, err := syscall.UTF16PtrFromString(newPassword) if err != nil { return errors.Trace(err) } info := netUserSetPassword{passp} err = netUserSetInfo(serverp, userp, changePasswordLevel, &info, nil) if err != nil { return errors.Trace(err) } return nil }
[ "func", "(", "c", "*", "PasswordChanger", ")", "ChangeUserPasswordLocalhost", "(", "newPassword", "string", ")", "error", "{", "serverp", ",", "err", ":=", "syscall", ".", "UTF16PtrFromString", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "re...
// changeUserPasswordLocalhost changes the password for username on localhost
[ "changeUserPasswordLocalhost", "changes", "the", "password", "for", "username", "on", "localhost" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/service/windows/password_windows.go#L89-L113
155,623
juju/juju
api/block/client.go
List
func (c *Client) List() ([]params.Block, error) { var blocks params.BlockResults if err := c.facade.FacadeCall("List", nil, &blocks); err != nil { return nil, errors.Trace(err) } var all []params.Block var allErr params.ErrorResults for _, result := range blocks.Results { if result.Error != nil { allErr.Results = append(allErr.Results, params.ErrorResult{result.Error}) continue } all = append(all, result.Result) } return all, allErr.Combine() }
go
func (c *Client) List() ([]params.Block, error) { var blocks params.BlockResults if err := c.facade.FacadeCall("List", nil, &blocks); err != nil { return nil, errors.Trace(err) } var all []params.Block var allErr params.ErrorResults for _, result := range blocks.Results { if result.Error != nil { allErr.Results = append(allErr.Results, params.ErrorResult{result.Error}) continue } all = append(all, result.Result) } return all, allErr.Combine() }
[ "func", "(", "c", "*", "Client", ")", "List", "(", ")", "(", "[", "]", "params", ".", "Block", ",", "error", ")", "{", "var", "blocks", "params", ".", "BlockResults", "\n", "if", "err", ":=", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\""...
// List returns blocks that are switched on for current model.
[ "List", "returns", "blocks", "that", "are", "switched", "on", "for", "current", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/block/client.go#L26-L42
155,624
juju/juju
api/block/client.go
SwitchBlockOn
func (c *Client) SwitchBlockOn(blockType, msg string) error { args := params.BlockSwitchParams{ Type: blockType, Message: msg, } var result params.ErrorResult if err := c.facade.FacadeCall("SwitchBlockOn", args, &result); err != nil { return errors.Trace(err) } if result.Error != nil { // cope with typed error return errors.Trace(result.Error) } return nil }
go
func (c *Client) SwitchBlockOn(blockType, msg string) error { args := params.BlockSwitchParams{ Type: blockType, Message: msg, } var result params.ErrorResult if err := c.facade.FacadeCall("SwitchBlockOn", args, &result); err != nil { return errors.Trace(err) } if result.Error != nil { // cope with typed error return errors.Trace(result.Error) } return nil }
[ "func", "(", "c", "*", "Client", ")", "SwitchBlockOn", "(", "blockType", ",", "msg", "string", ")", "error", "{", "args", ":=", "params", ".", "BlockSwitchParams", "{", "Type", ":", "blockType", ",", "Message", ":", "msg", ",", "}", "\n", "var", "resul...
// SwitchBlockOn switches desired block on for the current model. // Valid block types are "BlockDestroy", "BlockRemove" and "BlockChange".
[ "SwitchBlockOn", "switches", "desired", "block", "on", "for", "the", "current", "model", ".", "Valid", "block", "types", "are", "BlockDestroy", "BlockRemove", "and", "BlockChange", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/block/client.go#L46-L60
155,625
juju/juju
provider/gce/environ.go
Bootstrap
func (env *environ) Bootstrap(ctx environs.BootstrapContext, callCtx context.ProviderCallContext, params environs.BootstrapParams) (*environs.BootstrapResult, error) { // Ensure the API server port is open (globally for all instances // on the network, not just for the specific node of the state // server). See LP bug #1436191 for details. rule := network.NewOpenIngressRule( "tcp", params.ControllerConfig.APIPort(), params.ControllerConfig.APIPort(), ) if err := env.gce.OpenPorts(env.globalFirewallName(), rule); err != nil { return nil, google.HandleCredentialError(errors.Trace(err), callCtx) } if params.ControllerConfig.AutocertDNSName() != "" { // Open port 80 as well as it handles Let's Encrypt HTTP challenge. rule = network.NewOpenIngressRule("tcp", 80, 80) if err := env.gce.OpenPorts(env.globalFirewallName(), rule); err != nil { return nil, google.HandleCredentialError(errors.Trace(err), callCtx) } } return bootstrap(ctx, env, callCtx, params) }
go
func (env *environ) Bootstrap(ctx environs.BootstrapContext, callCtx context.ProviderCallContext, params environs.BootstrapParams) (*environs.BootstrapResult, error) { // Ensure the API server port is open (globally for all instances // on the network, not just for the specific node of the state // server). See LP bug #1436191 for details. rule := network.NewOpenIngressRule( "tcp", params.ControllerConfig.APIPort(), params.ControllerConfig.APIPort(), ) if err := env.gce.OpenPorts(env.globalFirewallName(), rule); err != nil { return nil, google.HandleCredentialError(errors.Trace(err), callCtx) } if params.ControllerConfig.AutocertDNSName() != "" { // Open port 80 as well as it handles Let's Encrypt HTTP challenge. rule = network.NewOpenIngressRule("tcp", 80, 80) if err := env.gce.OpenPorts(env.globalFirewallName(), rule); err != nil { return nil, google.HandleCredentialError(errors.Trace(err), callCtx) } } return bootstrap(ctx, env, callCtx, params) }
[ "func", "(", "env", "*", "environ", ")", "Bootstrap", "(", "ctx", "environs", ".", "BootstrapContext", ",", "callCtx", "context", ".", "ProviderCallContext", ",", "params", "environs", ".", "BootstrapParams", ")", "(", "*", "environs", ".", "BootstrapResult", ...
// Bootstrap creates a new instance, chosing the series and arch out of // available tools. The series and arch are returned along with a func // that must be called to finalize the bootstrap process by transferring // the tools and installing the initial juju controller.
[ "Bootstrap", "creates", "a", "new", "instance", "chosing", "the", "series", "and", "arch", "out", "of", "available", "tools", ".", "The", "series", "and", "arch", "are", "returned", "along", "with", "a", "func", "that", "must", "be", "called", "to", "final...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/gce/environ.go#L207-L227
155,626
juju/juju
provider/ec2/internal/ec2instancetypes/instancetypes.go
RegionInstanceTypes
func RegionInstanceTypes(region string) []instances.InstanceType { // NOTE(axw) at the time of writing, there is no cost // information for China (Beijing). For any regions // that we don't know about, we substitute us-east-1 // and hope that they're equivalent. instanceTypes, ok := allInstanceTypes[region] if !ok { instanceTypes = allInstanceTypes["us-east-1"] } return instanceTypes }
go
func RegionInstanceTypes(region string) []instances.InstanceType { // NOTE(axw) at the time of writing, there is no cost // information for China (Beijing). For any regions // that we don't know about, we substitute us-east-1 // and hope that they're equivalent. instanceTypes, ok := allInstanceTypes[region] if !ok { instanceTypes = allInstanceTypes["us-east-1"] } return instanceTypes }
[ "func", "RegionInstanceTypes", "(", "region", "string", ")", "[", "]", "instances", ".", "InstanceType", "{", "// NOTE(axw) at the time of writing, there is no cost", "// information for China (Beijing). For any regions", "// that we don't know about, we substitute us-east-1", "// and ...
// RegionInstanceTypes returns the instance types for the named region.
[ "RegionInstanceTypes", "returns", "the", "instance", "types", "for", "the", "named", "region", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/ec2/internal/ec2instancetypes/instancetypes.go#L15-L25
155,627
juju/juju
worker/uniter/runner/jujuc/storage-id.go
newStorageIdValue
func newStorageIdValue(ctx Context, result *names.StorageTag) (*storageIdValue, error) { v := &storageIdValue{result: result, ctx: ctx} if s, err := ctx.HookStorage(); err == nil { *v.result = s.Tag() } else if !errors.IsNotFound(err) { return nil, errors.Trace(err) } return v, nil }
go
func newStorageIdValue(ctx Context, result *names.StorageTag) (*storageIdValue, error) { v := &storageIdValue{result: result, ctx: ctx} if s, err := ctx.HookStorage(); err == nil { *v.result = s.Tag() } else if !errors.IsNotFound(err) { return nil, errors.Trace(err) } return v, nil }
[ "func", "newStorageIdValue", "(", "ctx", "Context", ",", "result", "*", "names", ".", "StorageTag", ")", "(", "*", "storageIdValue", ",", "error", ")", "{", "v", ":=", "&", "storageIdValue", "{", "result", ":", "result", ",", "ctx", ":", "ctx", "}", "\...
// newStorageIdValue returns a gnuflag.Value for convenient parsing of storage // ids in ctx.
[ "newStorageIdValue", "returns", "a", "gnuflag", ".", "Value", "for", "convenient", "parsing", "of", "storage", "ids", "in", "ctx", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/storage-id.go#L13-L21
155,628
juju/juju
worker/uniter/runner/jujuc/storage-id.go
String
func (v *storageIdValue) String() string { if *v.result == (names.StorageTag{}) { return "" } return v.result.Id() }
go
func (v *storageIdValue) String() string { if *v.result == (names.StorageTag{}) { return "" } return v.result.Id() }
[ "func", "(", "v", "*", "storageIdValue", ")", "String", "(", ")", "string", "{", "if", "*", "v", ".", "result", "==", "(", "names", ".", "StorageTag", "{", "}", ")", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "v", ".", "result", ".", ...
// String returns the current value.
[ "String", "returns", "the", "current", "value", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/storage-id.go#L30-L35
155,629
juju/juju
worker/uniter/runner/jujuc/storage-id.go
Set
func (v *storageIdValue) Set(value string) error { if !names.IsValidStorage(value) { return errors.Errorf("invalid storage ID %q", value) } tag := names.NewStorageTag(value) if _, err := v.ctx.Storage(tag); err != nil { return errors.Trace(err) } *v.result = tag return nil }
go
func (v *storageIdValue) Set(value string) error { if !names.IsValidStorage(value) { return errors.Errorf("invalid storage ID %q", value) } tag := names.NewStorageTag(value) if _, err := v.ctx.Storage(tag); err != nil { return errors.Trace(err) } *v.result = tag return nil }
[ "func", "(", "v", "*", "storageIdValue", ")", "Set", "(", "value", "string", ")", "error", "{", "if", "!", "names", ".", "IsValidStorage", "(", "value", ")", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "value", ")", "\n", "}", "\n...
// Set interprets value as a storage id, if possible, and returns an error // if it is not known to the system. The parsed storage id will be written // to v.result.
[ "Set", "interprets", "value", "as", "a", "storage", "id", "if", "possible", "and", "returns", "an", "error", "if", "it", "is", "not", "known", "to", "the", "system", ".", "The", "parsed", "storage", "id", "will", "be", "written", "to", "v", ".", "resul...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/storage-id.go#L40-L50
155,630
juju/juju
worker/httpserverargs/authenticator.go
NewStateAuthenticator
func NewStateAuthenticator( statePool *state.StatePool, mux *apiserverhttp.Mux, clock clock.Clock, abort <-chan struct{}, ) (httpcontext.LocalMacaroonAuthenticator, error) { stateAuthenticator, err := stateauthenticator.NewAuthenticator(statePool, clock) if err != nil { return nil, errors.Trace(err) } stateAuthenticator.AddHandlers(mux) go stateAuthenticator.Maintain(abort) return stateAuthenticator, nil }
go
func NewStateAuthenticator( statePool *state.StatePool, mux *apiserverhttp.Mux, clock clock.Clock, abort <-chan struct{}, ) (httpcontext.LocalMacaroonAuthenticator, error) { stateAuthenticator, err := stateauthenticator.NewAuthenticator(statePool, clock) if err != nil { return nil, errors.Trace(err) } stateAuthenticator.AddHandlers(mux) go stateAuthenticator.Maintain(abort) return stateAuthenticator, nil }
[ "func", "NewStateAuthenticator", "(", "statePool", "*", "state", ".", "StatePool", ",", "mux", "*", "apiserverhttp", ".", "Mux", ",", "clock", "clock", ".", "Clock", ",", "abort", "<-", "chan", "struct", "{", "}", ",", ")", "(", "httpcontext", ".", "Loca...
// NewStateAuthenticator returns a new LocalMacaroonAuthenticator that // authenticates users and agents using the given state pool. The // authenticator will register handlers into the mux for dealing with // local macaroon logins.
[ "NewStateAuthenticator", "returns", "a", "new", "LocalMacaroonAuthenticator", "that", "authenticates", "users", "and", "agents", "using", "the", "given", "state", "pool", ".", "The", "authenticator", "will", "register", "handlers", "into", "the", "mux", "for", "deal...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/httpserverargs/authenticator.go#L29-L42
155,631
juju/juju
apiserver/common/tools.go
NewToolsGetter
func NewToolsGetter(f state.EntityFinder, c environs.EnvironConfigGetter, s ToolsStorageGetter, t ToolsURLGetter, getCanRead GetAuthFunc) *ToolsGetter { return &ToolsGetter{f, c, s, t, getCanRead} }
go
func NewToolsGetter(f state.EntityFinder, c environs.EnvironConfigGetter, s ToolsStorageGetter, t ToolsURLGetter, getCanRead GetAuthFunc) *ToolsGetter { return &ToolsGetter{f, c, s, t, getCanRead} }
[ "func", "NewToolsGetter", "(", "f", "state", ".", "EntityFinder", ",", "c", "environs", ".", "EnvironConfigGetter", ",", "s", "ToolsStorageGetter", ",", "t", "ToolsURLGetter", ",", "getCanRead", "GetAuthFunc", ")", "*", "ToolsGetter", "{", "return", "&", "ToolsG...
// NewToolsGetter returns a new ToolsGetter. The GetAuthFunc will be // used on each invocation of Tools to determine current permissions.
[ "NewToolsGetter", "returns", "a", "new", "ToolsGetter", ".", "The", "GetAuthFunc", "will", "be", "used", "on", "each", "invocation", "of", "Tools", "to", "determine", "current", "permissions", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/tools.go#L59-L61
155,632
juju/juju
apiserver/common/tools.go
NewToolsSetter
func NewToolsSetter(st state.EntityFinder, getCanWrite GetAuthFunc) *ToolsSetter { return &ToolsSetter{ st: st, getCanWrite: getCanWrite, } }
go
func NewToolsSetter(st state.EntityFinder, getCanWrite GetAuthFunc) *ToolsSetter { return &ToolsSetter{ st: st, getCanWrite: getCanWrite, } }
[ "func", "NewToolsSetter", "(", "st", "state", ".", "EntityFinder", ",", "getCanWrite", "GetAuthFunc", ")", "*", "ToolsSetter", "{", "return", "&", "ToolsSetter", "{", "st", ":", "st", ",", "getCanWrite", ":", "getCanWrite", ",", "}", "\n", "}" ]
// NewToolsSetter returns a new ToolsGetter. The GetAuthFunc will be // used on each invocation of Tools to determine current permissions.
[ "NewToolsSetter", "returns", "a", "new", "ToolsGetter", ".", "The", "GetAuthFunc", "will", "be", "used", "on", "each", "invocation", "of", "Tools", "to", "determine", "current", "permissions", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/tools.go#L153-L158
155,633
juju/juju
apiserver/common/tools.go
SetTools
func (t *ToolsSetter) SetTools(args params.EntitiesVersion) (params.ErrorResults, error) { results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.AgentTools)), } canWrite, err := t.getCanWrite() if err != nil { return results, errors.Trace(err) } for i, agentTools := range args.AgentTools { tag, err := names.ParseTag(agentTools.Tag) if err != nil { results.Results[i].Error = ServerError(ErrPerm) continue } err = t.setOneAgentVersion(tag, agentTools.Tools.Version, canWrite) results.Results[i].Error = ServerError(err) } return results, nil }
go
func (t *ToolsSetter) SetTools(args params.EntitiesVersion) (params.ErrorResults, error) { results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.AgentTools)), } canWrite, err := t.getCanWrite() if err != nil { return results, errors.Trace(err) } for i, agentTools := range args.AgentTools { tag, err := names.ParseTag(agentTools.Tag) if err != nil { results.Results[i].Error = ServerError(ErrPerm) continue } err = t.setOneAgentVersion(tag, agentTools.Tools.Version, canWrite) results.Results[i].Error = ServerError(err) } return results, nil }
[ "func", "(", "t", "*", "ToolsSetter", ")", "SetTools", "(", "args", "params", ".", "EntitiesVersion", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "results", ":=", "params", ".", "ErrorResults", "{", "Results", ":", "make", "(", "[", ...
// SetTools updates the recorded tools version for the agents.
[ "SetTools", "updates", "the", "recorded", "tools", "version", "for", "the", "agents", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/tools.go#L161-L179
155,634
juju/juju
apiserver/common/tools.go
NewToolsFinder
func NewToolsFinder(c environs.EnvironConfigGetter, s ToolsStorageGetter, t ToolsURLGetter) *ToolsFinder { return &ToolsFinder{c, s, t} }
go
func NewToolsFinder(c environs.EnvironConfigGetter, s ToolsStorageGetter, t ToolsURLGetter) *ToolsFinder { return &ToolsFinder{c, s, t} }
[ "func", "NewToolsFinder", "(", "c", "environs", ".", "EnvironConfigGetter", ",", "s", "ToolsStorageGetter", ",", "t", "ToolsURLGetter", ")", "*", "ToolsFinder", "{", "return", "&", "ToolsFinder", "{", "c", ",", "s", ",", "t", "}", "\n", "}" ]
// NewToolsFinder returns a new ToolsFinder, returning tools // with their URLs pointing at the API server.
[ "NewToolsFinder", "returns", "a", "new", "ToolsFinder", "returning", "tools", "with", "their", "URLs", "pointing", "at", "the", "API", "server", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/tools.go#L204-L206
155,635
juju/juju
apiserver/common/tools.go
findTools
func (f *ToolsFinder) findTools(args params.FindToolsParams) (coretools.List, error) { list, err := f.findMatchingTools(args) if err != nil { return nil, err } // Rewrite the URLs so they point at the API servers. If the // tools are not in tools storage, then the API server will // download and cache them if the client requests that version. var fullList coretools.List for _, baseTools := range list { urls, err := f.urlGetter.ToolsURLs(baseTools.Version) if err != nil { return nil, err } for _, url := range urls { tools := *baseTools tools.URL = url fullList = append(fullList, &tools) } } return fullList, nil }
go
func (f *ToolsFinder) findTools(args params.FindToolsParams) (coretools.List, error) { list, err := f.findMatchingTools(args) if err != nil { return nil, err } // Rewrite the URLs so they point at the API servers. If the // tools are not in tools storage, then the API server will // download and cache them if the client requests that version. var fullList coretools.List for _, baseTools := range list { urls, err := f.urlGetter.ToolsURLs(baseTools.Version) if err != nil { return nil, err } for _, url := range urls { tools := *baseTools tools.URL = url fullList = append(fullList, &tools) } } return fullList, nil }
[ "func", "(", "f", "*", "ToolsFinder", ")", "findTools", "(", "args", "params", ".", "FindToolsParams", ")", "(", "coretools", ".", "List", ",", "error", ")", "{", "list", ",", "err", ":=", "f", ".", "findMatchingTools", "(", "args", ")", "\n", "if", ...
// findTools calls findMatchingTools and then rewrites the URLs // using the provided ToolsURLGetter.
[ "findTools", "calls", "findMatchingTools", "and", "then", "rewrites", "the", "URLs", "using", "the", "provided", "ToolsURLGetter", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/tools.go#L222-L243
155,636
juju/juju
apiserver/common/tools.go
matchingStorageTools
func (f *ToolsFinder) matchingStorageTools(args params.FindToolsParams) (coretools.List, error) { storage, err := f.toolsStorageGetter.ToolsStorage() if err != nil { return nil, err } defer storage.Close() allMetadata, err := storage.AllMetadata() if err != nil { return nil, err } list := make(coretools.List, len(allMetadata)) for i, m := range allMetadata { vers, err := version.ParseBinary(m.Version) if err != nil { return nil, errors.Annotatef(err, "unexpected bad version %q of agent binary in storage", m.Version) } list[i] = &coretools.Tools{ Version: vers, Size: m.Size, SHA256: m.SHA256, } } list, err = list.Match(toolsFilter(args)) if err != nil { return nil, err } var matching coretools.List for _, tools := range list { if args.MajorVersion != -1 && tools.Version.Major != args.MajorVersion { continue } if args.MinorVersion != -1 && tools.Version.Minor != args.MinorVersion { continue } matching = append(matching, tools) } if len(matching) == 0 { return nil, coretools.ErrNoMatches } return matching, nil }
go
func (f *ToolsFinder) matchingStorageTools(args params.FindToolsParams) (coretools.List, error) { storage, err := f.toolsStorageGetter.ToolsStorage() if err != nil { return nil, err } defer storage.Close() allMetadata, err := storage.AllMetadata() if err != nil { return nil, err } list := make(coretools.List, len(allMetadata)) for i, m := range allMetadata { vers, err := version.ParseBinary(m.Version) if err != nil { return nil, errors.Annotatef(err, "unexpected bad version %q of agent binary in storage", m.Version) } list[i] = &coretools.Tools{ Version: vers, Size: m.Size, SHA256: m.SHA256, } } list, err = list.Match(toolsFilter(args)) if err != nil { return nil, err } var matching coretools.List for _, tools := range list { if args.MajorVersion != -1 && tools.Version.Major != args.MajorVersion { continue } if args.MinorVersion != -1 && tools.Version.Minor != args.MinorVersion { continue } matching = append(matching, tools) } if len(matching) == 0 { return nil, coretools.ErrNoMatches } return matching, nil }
[ "func", "(", "f", "*", "ToolsFinder", ")", "matchingStorageTools", "(", "args", "params", ".", "FindToolsParams", ")", "(", "coretools", ".", "List", ",", "error", ")", "{", "storage", ",", "err", ":=", "f", ".", "toolsStorageGetter", ".", "ToolsStorage", ...
// matchingStorageTools returns a coretools.List, with an entry for each // metadata entry in the tools storage that matches the given parameters.
[ "matchingStorageTools", "returns", "a", "coretools", ".", "List", "with", "an", "entry", "for", "each", "metadata", "entry", "in", "the", "tools", "storage", "that", "matches", "the", "given", "parameters", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/tools.go#L293-L333
155,637
juju/juju
apiserver/common/tools.go
ToolsURL
func ToolsURL(serverRoot string, v version.Binary) string { return fmt.Sprintf("%s/tools/%s", serverRoot, v.String()) }
go
func ToolsURL(serverRoot string, v version.Binary) string { return fmt.Sprintf("%s/tools/%s", serverRoot, v.String()) }
[ "func", "ToolsURL", "(", "serverRoot", "string", ",", "v", "version", ".", "Binary", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "serverRoot", ",", "v", ".", "String", "(", ")", ")", "\n", "}" ]
// ToolsURL returns a tools URL pointing the API server // specified by the "serverRoot".
[ "ToolsURL", "returns", "a", "tools", "URL", "pointing", "the", "API", "server", "specified", "by", "the", "serverRoot", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/common/tools.go#L373-L375
155,638
juju/juju
resource/context/internal/resource.go
OpenResource
func OpenResource(name string, client OpenedResourceClient) (*OpenedResource, error) { info, reader, err := client.GetResource(name) if err != nil { return nil, errors.Trace(err) } if info.Type == charmresource.TypeContainerImage { info.Path = "content.yaml" // Image data is stored as json but we need to convert to YAMl // as that's what the charm expects. data, err := ioutil.ReadAll(reader) if err != nil { return nil, errors.Trace(err) } if err := reader.Close(); err != nil { return nil, errors.Trace(err) } var yamlBody resources.DockerImageDetails err = json.Unmarshal(data, &yamlBody) if err != nil { return nil, errors.Trace(err) } yamlOut, err := yaml.Marshal(yamlBody) if err != nil { return nil, errors.Trace(err) } reader = httprequest.BytesReaderCloser{bytes.NewReader(yamlOut)} info.Size = int64(len(yamlOut)) } or := &OpenedResource{ Resource: info, ReadCloser: reader, } return or, nil }
go
func OpenResource(name string, client OpenedResourceClient) (*OpenedResource, error) { info, reader, err := client.GetResource(name) if err != nil { return nil, errors.Trace(err) } if info.Type == charmresource.TypeContainerImage { info.Path = "content.yaml" // Image data is stored as json but we need to convert to YAMl // as that's what the charm expects. data, err := ioutil.ReadAll(reader) if err != nil { return nil, errors.Trace(err) } if err := reader.Close(); err != nil { return nil, errors.Trace(err) } var yamlBody resources.DockerImageDetails err = json.Unmarshal(data, &yamlBody) if err != nil { return nil, errors.Trace(err) } yamlOut, err := yaml.Marshal(yamlBody) if err != nil { return nil, errors.Trace(err) } reader = httprequest.BytesReaderCloser{bytes.NewReader(yamlOut)} info.Size = int64(len(yamlOut)) } or := &OpenedResource{ Resource: info, ReadCloser: reader, } return or, nil }
[ "func", "OpenResource", "(", "name", "string", ",", "client", "OpenedResourceClient", ")", "(", "*", "OpenedResource", ",", "error", ")", "{", "info", ",", "reader", ",", "err", ":=", "client", ".", "GetResource", "(", "name", ")", "\n", "if", "err", "!=...
// OpenResource opens the identified resource using the provided client.
[ "OpenResource", "opens", "the", "identified", "resource", "using", "the", "provided", "client", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/resource/context/internal/resource.go#L39-L72
155,639
juju/juju
apiserver/tools.go
getToolsForRequest
func (h *toolsDownloadHandler) getToolsForRequest(r *http.Request, st *state.State) (io.ReadCloser, int64, error) { version, err := version.ParseBinary(r.URL.Query().Get(":version")) if err != nil { return nil, 0, errors.Annotate(err, "error parsing version") } logger.Debugf("request for agent binaries: %s", version) storage, err := st.ToolsStorage() if err != nil { return nil, 0, errors.Annotate(err, "error getting storage for agent binaries") } md, reader, err := storage.Open(version.String()) if errors.IsNotFound(err) { // Tools could not be found in tools storage, // so look for them in simplestreams, // fetch them and cache in tools storage. logger.Infof("%v agent binaries not found locally, fetching", version) md, reader, err = h.fetchAndCacheTools(version, storage, st) if err != nil { err = errors.Annotate(err, "error fetching agent binaries") } } if err != nil { storage.Close() return nil, 0, err } return &toolsReadCloser{f: reader, st: storage}, md.Size, nil }
go
func (h *toolsDownloadHandler) getToolsForRequest(r *http.Request, st *state.State) (io.ReadCloser, int64, error) { version, err := version.ParseBinary(r.URL.Query().Get(":version")) if err != nil { return nil, 0, errors.Annotate(err, "error parsing version") } logger.Debugf("request for agent binaries: %s", version) storage, err := st.ToolsStorage() if err != nil { return nil, 0, errors.Annotate(err, "error getting storage for agent binaries") } md, reader, err := storage.Open(version.String()) if errors.IsNotFound(err) { // Tools could not be found in tools storage, // so look for them in simplestreams, // fetch them and cache in tools storage. logger.Infof("%v agent binaries not found locally, fetching", version) md, reader, err = h.fetchAndCacheTools(version, storage, st) if err != nil { err = errors.Annotate(err, "error fetching agent binaries") } } if err != nil { storage.Close() return nil, 0, err } return &toolsReadCloser{f: reader, st: storage}, md.Size, nil }
[ "func", "(", "h", "*", "toolsDownloadHandler", ")", "getToolsForRequest", "(", "r", "*", "http", ".", "Request", ",", "st", "*", "state", ".", "State", ")", "(", "io", ".", "ReadCloser", ",", "int64", ",", "error", ")", "{", "version", ",", "err", ":...
// getToolsForRequest retrieves the compressed agent binaries tarball from state // based on the input HTTP request. // It is returned with the size of the file as recorded in the stored metadata.
[ "getToolsForRequest", "retrieves", "the", "compressed", "agent", "binaries", "tarball", "from", "state", "based", "on", "the", "input", "HTTP", "request", ".", "It", "is", "returned", "with", "the", "size", "of", "the", "file", "as", "recorded", "in", "the", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/tools.go#L135-L164
155,640
juju/juju
apiserver/tools.go
fetchAndCacheTools
func (h *toolsDownloadHandler) fetchAndCacheTools( v version.Binary, stor binarystorage.Storage, st *state.State, ) (binarystorage.Metadata, io.ReadCloser, error) { md := binarystorage.Metadata{Version: v.String()} newEnviron := stateenvirons.GetNewEnvironFunc(environs.New) env, err := newEnviron(st) if err != nil { return md, nil, err } tools, err := envtools.FindExactTools(env, v.Number, v.Series, v.Arch) if err != nil { return md, nil, err } // No need to verify the server's identity because we verify the SHA-256 hash. logger.Infof("fetching %v agent binaries from %v", v, tools.URL) resp, err := utils.GetNonValidatingHTTPClient().Get(tools.URL) if err != nil { return md, nil, err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { msg := fmt.Sprintf("bad HTTP response: %v", resp.Status) if body, err := ioutil.ReadAll(resp.Body); err == nil { msg += fmt.Sprintf(" (%s)", bytes.TrimSpace(body)) } return md, nil, errors.New(msg) } data, sha256, err := readAndHash(resp.Body) if err != nil { return md, nil, err } if int64(len(data)) != tools.Size { return md, nil, errors.Errorf("size mismatch for %s", tools.URL) } md.Size = tools.Size if sha256 != tools.SHA256 { return md, nil, errors.Errorf("hash mismatch for %s", tools.URL) } md.SHA256 = tools.SHA256 if err := stor.Add(bytes.NewReader(data), md); err != nil { return md, nil, errors.Annotate(err, "error caching agent binaries") } return md, ioutil.NopCloser(bytes.NewReader(data)), nil }
go
func (h *toolsDownloadHandler) fetchAndCacheTools( v version.Binary, stor binarystorage.Storage, st *state.State, ) (binarystorage.Metadata, io.ReadCloser, error) { md := binarystorage.Metadata{Version: v.String()} newEnviron := stateenvirons.GetNewEnvironFunc(environs.New) env, err := newEnviron(st) if err != nil { return md, nil, err } tools, err := envtools.FindExactTools(env, v.Number, v.Series, v.Arch) if err != nil { return md, nil, err } // No need to verify the server's identity because we verify the SHA-256 hash. logger.Infof("fetching %v agent binaries from %v", v, tools.URL) resp, err := utils.GetNonValidatingHTTPClient().Get(tools.URL) if err != nil { return md, nil, err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { msg := fmt.Sprintf("bad HTTP response: %v", resp.Status) if body, err := ioutil.ReadAll(resp.Body); err == nil { msg += fmt.Sprintf(" (%s)", bytes.TrimSpace(body)) } return md, nil, errors.New(msg) } data, sha256, err := readAndHash(resp.Body) if err != nil { return md, nil, err } if int64(len(data)) != tools.Size { return md, nil, errors.Errorf("size mismatch for %s", tools.URL) } md.Size = tools.Size if sha256 != tools.SHA256 { return md, nil, errors.Errorf("hash mismatch for %s", tools.URL) } md.SHA256 = tools.SHA256 if err := stor.Add(bytes.NewReader(data), md); err != nil { return md, nil, errors.Annotate(err, "error caching agent binaries") } return md, ioutil.NopCloser(bytes.NewReader(data)), nil }
[ "func", "(", "h", "*", "toolsDownloadHandler", ")", "fetchAndCacheTools", "(", "v", "version", ".", "Binary", ",", "stor", "binarystorage", ".", "Storage", ",", "st", "*", "state", ".", "State", ",", ")", "(", "binarystorage", ".", "Metadata", ",", "io", ...
// fetchAndCacheTools fetches tools with the specified version by searching for a URL // in simplestreams and GETting it, caching the result in tools storage before returning // to the caller.
[ "fetchAndCacheTools", "fetches", "tools", "with", "the", "specified", "version", "by", "searching", "for", "a", "URL", "in", "simplestreams", "and", "GETting", "it", "caching", "the", "result", "in", "tools", "storage", "before", "returning", "to", "the", "calle...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/tools.go#L169-L218
155,641
juju/juju
apiserver/tools.go
sendTools
func (h *toolsDownloadHandler) sendTools(w http.ResponseWriter, reader io.ReadCloser, size int64) error { logger.Tracef("sending %d bytes", size) w.Header().Set("Content-Type", "application/x-tar-gz") w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) if _, err := io.Copy(w, reader); err != nil { // Having begun writing, it is too late to send an error response here. return errors.Annotatef(err, "failed to send agent binaries") } return nil }
go
func (h *toolsDownloadHandler) sendTools(w http.ResponseWriter, reader io.ReadCloser, size int64) error { logger.Tracef("sending %d bytes", size) w.Header().Set("Content-Type", "application/x-tar-gz") w.Header().Set("Content-Length", strconv.FormatInt(size, 10)) if _, err := io.Copy(w, reader); err != nil { // Having begun writing, it is too late to send an error response here. return errors.Annotatef(err, "failed to send agent binaries") } return nil }
[ "func", "(", "h", "*", "toolsDownloadHandler", ")", "sendTools", "(", "w", "http", ".", "ResponseWriter", ",", "reader", "io", ".", "ReadCloser", ",", "size", "int64", ")", "error", "{", "logger", ".", "Tracef", "(", "\"", "\"", ",", "size", ")", "\n\n...
// sendTools streams the tools tarball to the client.
[ "sendTools", "streams", "the", "tools", "tarball", "to", "the", "client", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/tools.go#L221-L232
155,642
juju/juju
apiserver/tools.go
processPost
func (h *toolsUploadHandler) processPost(r *http.Request, st *state.State) (*tools.Tools, error) { query := r.URL.Query() binaryVersionParam := query.Get("binaryVersion") if binaryVersionParam == "" { return nil, errors.BadRequestf("expected binaryVersion argument") } toolsVersion, err := version.ParseBinary(binaryVersionParam) if err != nil { return nil, errors.NewBadRequest(err, fmt.Sprintf("invalid agent binaries version %q", binaryVersionParam)) } // Make sure the content type is x-tar-gz. contentType := r.Header.Get("Content-Type") if contentType != "application/x-tar-gz" { return nil, errors.BadRequestf("expected Content-Type: application/x-tar-gz, got: %v", contentType) } // We'll clone the tools for each additional series specified. var cloneSeries []string if seriesParam := query.Get("series"); seriesParam != "" { cloneSeries = strings.Split(seriesParam, ",") } logger.Debugf("request to upload agent binaries: %s", toolsVersion) logger.Debugf("additional series: %s", cloneSeries) toolsVersions := []version.Binary{toolsVersion} for _, series := range cloneSeries { if series != toolsVersion.Series { v := toolsVersion v.Series = series toolsVersions = append(toolsVersions, v) } } serverRoot := h.getServerRoot(r, query, st) return h.handleUpload(r.Body, toolsVersions, serverRoot, st) }
go
func (h *toolsUploadHandler) processPost(r *http.Request, st *state.State) (*tools.Tools, error) { query := r.URL.Query() binaryVersionParam := query.Get("binaryVersion") if binaryVersionParam == "" { return nil, errors.BadRequestf("expected binaryVersion argument") } toolsVersion, err := version.ParseBinary(binaryVersionParam) if err != nil { return nil, errors.NewBadRequest(err, fmt.Sprintf("invalid agent binaries version %q", binaryVersionParam)) } // Make sure the content type is x-tar-gz. contentType := r.Header.Get("Content-Type") if contentType != "application/x-tar-gz" { return nil, errors.BadRequestf("expected Content-Type: application/x-tar-gz, got: %v", contentType) } // We'll clone the tools for each additional series specified. var cloneSeries []string if seriesParam := query.Get("series"); seriesParam != "" { cloneSeries = strings.Split(seriesParam, ",") } logger.Debugf("request to upload agent binaries: %s", toolsVersion) logger.Debugf("additional series: %s", cloneSeries) toolsVersions := []version.Binary{toolsVersion} for _, series := range cloneSeries { if series != toolsVersion.Series { v := toolsVersion v.Series = series toolsVersions = append(toolsVersions, v) } } serverRoot := h.getServerRoot(r, query, st) return h.handleUpload(r.Body, toolsVersions, serverRoot, st) }
[ "func", "(", "h", "*", "toolsUploadHandler", ")", "processPost", "(", "r", "*", "http", ".", "Request", ",", "st", "*", "state", ".", "State", ")", "(", "*", "tools", ".", "Tools", ",", "error", ")", "{", "query", ":=", "r", ".", "URL", ".", "Que...
// processPost handles a tools upload POST request after authentication.
[ "processPost", "handles", "a", "tools", "upload", "POST", "request", "after", "authentication", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/tools.go#L235-L271
155,643
juju/juju
apiserver/tools.go
handleUpload
func (h *toolsUploadHandler) handleUpload(r io.Reader, toolsVersions []version.Binary, serverRoot string, st *state.State) (*tools.Tools, error) { // Check if changes are allowed and the command may proceed. blockChecker := common.NewBlockChecker(st) if err := blockChecker.ChangeAllowed(); err != nil { return nil, errors.Trace(err) } storage, err := st.ToolsStorage() if err != nil { return nil, err } defer storage.Close() // Read the tools tarball from the request, calculating the sha256 along the way. data, sha256, err := readAndHash(r) if err != nil { return nil, err } if len(data) == 0 { return nil, errors.BadRequestf("no agent binaries uploaded") } // TODO(wallyworld): check integrity of tools tarball. // Store tools and metadata in tools storage. for _, v := range toolsVersions { metadata := binarystorage.Metadata{ Version: v.String(), Size: int64(len(data)), SHA256: sha256, } logger.Debugf("uploading agent binaries %+v to storage", metadata) if err := storage.Add(bytes.NewReader(data), metadata); err != nil { return nil, err } } tools := &tools.Tools{ Version: toolsVersions[0], Size: int64(len(data)), SHA256: sha256, URL: common.ToolsURL(serverRoot, toolsVersions[0]), } return tools, nil }
go
func (h *toolsUploadHandler) handleUpload(r io.Reader, toolsVersions []version.Binary, serverRoot string, st *state.State) (*tools.Tools, error) { // Check if changes are allowed and the command may proceed. blockChecker := common.NewBlockChecker(st) if err := blockChecker.ChangeAllowed(); err != nil { return nil, errors.Trace(err) } storage, err := st.ToolsStorage() if err != nil { return nil, err } defer storage.Close() // Read the tools tarball from the request, calculating the sha256 along the way. data, sha256, err := readAndHash(r) if err != nil { return nil, err } if len(data) == 0 { return nil, errors.BadRequestf("no agent binaries uploaded") } // TODO(wallyworld): check integrity of tools tarball. // Store tools and metadata in tools storage. for _, v := range toolsVersions { metadata := binarystorage.Metadata{ Version: v.String(), Size: int64(len(data)), SHA256: sha256, } logger.Debugf("uploading agent binaries %+v to storage", metadata) if err := storage.Add(bytes.NewReader(data), metadata); err != nil { return nil, err } } tools := &tools.Tools{ Version: toolsVersions[0], Size: int64(len(data)), SHA256: sha256, URL: common.ToolsURL(serverRoot, toolsVersions[0]), } return tools, nil }
[ "func", "(", "h", "*", "toolsUploadHandler", ")", "handleUpload", "(", "r", "io", ".", "Reader", ",", "toolsVersions", "[", "]", "version", ".", "Binary", ",", "serverRoot", "string", ",", "st", "*", "state", ".", "State", ")", "(", "*", "tools", ".", ...
// handleUpload uploads the tools data from the reader to env storage as the specified version.
[ "handleUpload", "uploads", "the", "tools", "data", "from", "the", "reader", "to", "env", "storage", "as", "the", "specified", "version", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/tools.go#L279-L322
155,644
juju/juju
worker/storageprovisioner/manifold_model.go
ModelManifold
func ModelManifold(config ModelManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{config.APICallerName, config.ClockName, config.StorageRegistryName}, Start: func(context dependency.Context) (worker.Worker, error) { var clock clock.Clock if err := context.Get(config.ClockName, &clock); err != nil { return nil, errors.Trace(err) } var apiCaller base.APICaller if err := context.Get(config.APICallerName, &apiCaller); err != nil { return nil, errors.Trace(err) } var registry storage.ProviderRegistry if err := context.Get(config.StorageRegistryName, &registry); err != nil { return nil, errors.Trace(err) } api, err := storageprovisioner.NewState(apiCaller) if err != nil { return nil, errors.Trace(err) } credentialAPI, err := config.NewCredentialValidatorFacade(apiCaller) if err != nil { return nil, errors.Trace(err) } w, err := config.NewWorker(Config{ Model: config.Model, Scope: config.Model, StorageDir: config.StorageDir, Applications: api, Volumes: api, Filesystems: api, Life: api, Registry: registry, Machines: api, Status: api, Clock: clock, CloudCallContext: common.NewCloudCallContext(credentialAPI, nil), }) if err != nil { return nil, errors.Trace(err) } return w, nil }, } }
go
func ModelManifold(config ModelManifoldConfig) dependency.Manifold { return dependency.Manifold{ Inputs: []string{config.APICallerName, config.ClockName, config.StorageRegistryName}, Start: func(context dependency.Context) (worker.Worker, error) { var clock clock.Clock if err := context.Get(config.ClockName, &clock); err != nil { return nil, errors.Trace(err) } var apiCaller base.APICaller if err := context.Get(config.APICallerName, &apiCaller); err != nil { return nil, errors.Trace(err) } var registry storage.ProviderRegistry if err := context.Get(config.StorageRegistryName, &registry); err != nil { return nil, errors.Trace(err) } api, err := storageprovisioner.NewState(apiCaller) if err != nil { return nil, errors.Trace(err) } credentialAPI, err := config.NewCredentialValidatorFacade(apiCaller) if err != nil { return nil, errors.Trace(err) } w, err := config.NewWorker(Config{ Model: config.Model, Scope: config.Model, StorageDir: config.StorageDir, Applications: api, Volumes: api, Filesystems: api, Life: api, Registry: registry, Machines: api, Status: api, Clock: clock, CloudCallContext: common.NewCloudCallContext(credentialAPI, nil), }) if err != nil { return nil, errors.Trace(err) } return w, nil }, } }
[ "func", "ModelManifold", "(", "config", "ModelManifoldConfig", ")", "dependency", ".", "Manifold", "{", "return", "dependency", ".", "Manifold", "{", "Inputs", ":", "[", "]", "string", "{", "config", ".", "APICallerName", ",", "config", ".", "ClockName", ",", ...
// ModelManifold returns a dependency.Manifold that runs a storage provisioner.
[ "ModelManifold", "returns", "a", "dependency", ".", "Manifold", "that", "runs", "a", "storage", "provisioner", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/storageprovisioner/manifold_model.go#L32-L79
155,645
juju/juju
network/hostport.go
NetAddr
func (hp HostPort) NetAddr() string { return net.JoinHostPort(hp.Value, strconv.Itoa(hp.Port)) }
go
func (hp HostPort) NetAddr() string { return net.JoinHostPort(hp.Value, strconv.Itoa(hp.Port)) }
[ "func", "(", "hp", "HostPort", ")", "NetAddr", "(", ")", "string", "{", "return", "net", ".", "JoinHostPort", "(", "hp", ".", "Value", ",", "strconv", ".", "Itoa", "(", "hp", ".", "Port", ")", ")", "\n", "}" ]
// NetAddr returns the host-port as an address // suitable for calling net.Dial.
[ "NetAddr", "returns", "the", "host", "-", "port", "as", "an", "address", "suitable", "for", "calling", "net", ".", "Dial", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/hostport.go#L24-L26
155,646
juju/juju
network/hostport.go
Less
func (hp1 HostPort) Less(hp2 HostPort) bool { order1 := hp1.sortOrder() order2 := hp2.sortOrder() if order1 == order2 { if hp1.Address.Value == hp2.Address.Value { return hp1.Port < hp2.Port } return hp1.Address.Value < hp2.Address.Value } return order1 < order2 }
go
func (hp1 HostPort) Less(hp2 HostPort) bool { order1 := hp1.sortOrder() order2 := hp2.sortOrder() if order1 == order2 { if hp1.Address.Value == hp2.Address.Value { return hp1.Port < hp2.Port } return hp1.Address.Value < hp2.Address.Value } return order1 < order2 }
[ "func", "(", "hp1", "HostPort", ")", "Less", "(", "hp2", "HostPort", ")", "bool", "{", "order1", ":=", "hp1", ".", "sortOrder", "(", ")", "\n", "order2", ":=", "hp2", ".", "sortOrder", "(", ")", "\n", "if", "order1", "==", "order2", "{", "if", "hp1...
// Less reports whether hp1 is ordered before hp2 // according to the criteria used by SortHostPorts.
[ "Less", "reports", "whether", "hp1", "is", "ordered", "before", "hp2", "according", "to", "the", "criteria", "used", "by", "SortHostPorts", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/hostport.go#L40-L50
155,647
juju/juju
network/hostport.go
AddressesWithPort
func AddressesWithPort(addrs []Address, port int) []HostPort { hps := make([]HostPort, len(addrs)) for i, addr := range addrs { hps[i] = HostPort{ Address: addr, Port: port, } } return hps }
go
func AddressesWithPort(addrs []Address, port int) []HostPort { hps := make([]HostPort, len(addrs)) for i, addr := range addrs { hps[i] = HostPort{ Address: addr, Port: port, } } return hps }
[ "func", "AddressesWithPort", "(", "addrs", "[", "]", "Address", ",", "port", "int", ")", "[", "]", "HostPort", "{", "hps", ":=", "make", "(", "[", "]", "HostPort", ",", "len", "(", "addrs", ")", ")", "\n", "for", "i", ",", "addr", ":=", "range", ...
// AddressesWithPort returns the given addresses all // associated with the given port.
[ "AddressesWithPort", "returns", "the", "given", "addresses", "all", "associated", "with", "the", "given", "port", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/hostport.go#L54-L63
155,648
juju/juju
network/hostport.go
NewHostPorts
func NewHostPorts(port int, addresses ...string) []HostPort { hps := make([]HostPort, len(addresses)) for i, addr := range addresses { hps[i] = HostPort{ Address: NewAddress(addr), Port: port, } } return hps }
go
func NewHostPorts(port int, addresses ...string) []HostPort { hps := make([]HostPort, len(addresses)) for i, addr := range addresses { hps[i] = HostPort{ Address: NewAddress(addr), Port: port, } } return hps }
[ "func", "NewHostPorts", "(", "port", "int", ",", "addresses", "...", "string", ")", "[", "]", "HostPort", "{", "hps", ":=", "make", "(", "[", "]", "HostPort", ",", "len", "(", "addresses", ")", ")", "\n", "for", "i", ",", "addr", ":=", "range", "ad...
// NewHostPorts creates a list of HostPorts from each given string // address and port.
[ "NewHostPorts", "creates", "a", "list", "of", "HostPorts", "from", "each", "given", "string", "address", "and", "port", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/hostport.go#L67-L76
155,649
juju/juju
network/hostport.go
ParseHostPort
func ParseHostPort(hp string) (*HostPort, error) { host, port, err := net.SplitHostPort(hp) if err != nil { return nil, errors.Annotatef(err, "cannot parse %q as address:port", hp) } numPort, err := strconv.Atoi(port) if err != nil { return nil, errors.Annotatef(err, "cannot parse %q port", hp) } return &HostPort{ Address: NewAddress(host), Port: numPort, }, nil }
go
func ParseHostPort(hp string) (*HostPort, error) { host, port, err := net.SplitHostPort(hp) if err != nil { return nil, errors.Annotatef(err, "cannot parse %q as address:port", hp) } numPort, err := strconv.Atoi(port) if err != nil { return nil, errors.Annotatef(err, "cannot parse %q port", hp) } return &HostPort{ Address: NewAddress(host), Port: numPort, }, nil }
[ "func", "ParseHostPort", "(", "hp", "string", ")", "(", "*", "HostPort", ",", "error", ")", "{", "host", ",", "port", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "hp", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors"...
// ParseHostPort converts a string containing a single host and port // value to a HostPort.
[ "ParseHostPort", "converts", "a", "string", "containing", "a", "single", "host", "and", "port", "value", "to", "a", "HostPort", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/hostport.go#L95-L108
155,650
juju/juju
network/hostport.go
HostsWithoutPort
func HostsWithoutPort(hps []HostPort) []Address { addrs := make([]Address, len(hps)) for i, hp := range hps { addrs[i] = hp.Address } return addrs }
go
func HostsWithoutPort(hps []HostPort) []Address { addrs := make([]Address, len(hps)) for i, hp := range hps { addrs[i] = hp.Address } return addrs }
[ "func", "HostsWithoutPort", "(", "hps", "[", "]", "HostPort", ")", "[", "]", "Address", "{", "addrs", ":=", "make", "(", "[", "]", "Address", ",", "len", "(", "hps", ")", ")", "\n", "for", "i", ",", "hp", ":=", "range", "hps", "{", "addrs", "[", ...
// HostsWithoutPort strips the port from each HostPort, returning just // the addresses.
[ "HostsWithoutPort", "strips", "the", "port", "from", "each", "HostPort", "returning", "just", "the", "addresses", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/hostport.go#L112-L118
155,651
juju/juju
network/hostport.go
CollapseHostPorts
func CollapseHostPorts(serversHostPorts [][]HostPort) []HostPort { var collapsed []HostPort for _, hps := range serversHostPorts { collapsed = append(collapsed, hps...) } return collapsed }
go
func CollapseHostPorts(serversHostPorts [][]HostPort) []HostPort { var collapsed []HostPort for _, hps := range serversHostPorts { collapsed = append(collapsed, hps...) } return collapsed }
[ "func", "CollapseHostPorts", "(", "serversHostPorts", "[", "]", "[", "]", "HostPort", ")", "[", "]", "HostPort", "{", "var", "collapsed", "[", "]", "HostPort", "\n", "for", "_", ",", "hps", ":=", "range", "serversHostPorts", "{", "collapsed", "=", "append"...
// CollapseHostPorts returns a flattened list of HostPorts keeping the // same order they appear in serversHostPorts.
[ "CollapseHostPorts", "returns", "a", "flattened", "list", "of", "HostPorts", "keeping", "the", "same", "order", "they", "appear", "in", "serversHostPorts", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/hostport.go#L220-L226
155,652
juju/juju
network/hostport.go
EnsureFirstHostPort
func EnsureFirstHostPort(first HostPort, hps []HostPort) []HostPort { var result []HostPort found := false for _, hp := range hps { if hp.NetAddr() == first.NetAddr() && !found { // Found, so skip it. found = true continue } result = append(result, hp) } // Insert it at the top. result = append([]HostPort{first}, result...) return result }
go
func EnsureFirstHostPort(first HostPort, hps []HostPort) []HostPort { var result []HostPort found := false for _, hp := range hps { if hp.NetAddr() == first.NetAddr() && !found { // Found, so skip it. found = true continue } result = append(result, hp) } // Insert it at the top. result = append([]HostPort{first}, result...) return result }
[ "func", "EnsureFirstHostPort", "(", "first", "HostPort", ",", "hps", "[", "]", "HostPort", ")", "[", "]", "HostPort", "{", "var", "result", "[", "]", "HostPort", "\n", "found", ":=", "false", "\n", "for", "_", ",", "hp", ":=", "range", "hps", "{", "i...
// EnsureFirstHostPort scans the given list of HostPorts and if // "first" is found, it moved to index 0. Otherwise, if "first" is not // in the list, it's inserted at index 0.
[ "EnsureFirstHostPort", "scans", "the", "given", "list", "of", "HostPorts", "and", "if", "first", "is", "found", "it", "moved", "to", "index", "0", ".", "Otherwise", "if", "first", "is", "not", "in", "the", "list", "it", "s", "inserted", "at", "index", "0...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/hostport.go#L231-L245
155,653
juju/juju
network/hostport.go
UniqueHostPorts
func UniqueHostPorts(hostPorts []HostPort) []HostPort { results := make([]HostPort, 0, len(hostPorts)) seen := make(map[HostPort]bool, len(hostPorts)) for _, hostPort := range hostPorts { if seen[hostPort] { continue } seen[hostPort] = true results = append(results, hostPort) } return results }
go
func UniqueHostPorts(hostPorts []HostPort) []HostPort { results := make([]HostPort, 0, len(hostPorts)) seen := make(map[HostPort]bool, len(hostPorts)) for _, hostPort := range hostPorts { if seen[hostPort] { continue } seen[hostPort] = true results = append(results, hostPort) } return results }
[ "func", "UniqueHostPorts", "(", "hostPorts", "[", "]", "HostPort", ")", "[", "]", "HostPort", "{", "results", ":=", "make", "(", "[", "]", "HostPort", ",", "0", ",", "len", "(", "hostPorts", ")", ")", "\n\n", "seen", ":=", "make", "(", "map", "[", ...
// UniqueHostPorts returns the given hostPorts after filtering out any // duplicates, preserving the input order.
[ "UniqueHostPorts", "returns", "the", "given", "hostPorts", "after", "filtering", "out", "any", "duplicates", "preserving", "the", "input", "order", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/hostport.go#L249-L263
155,654
juju/juju
worker/uniter/runner/jujuc/action-get.go
NewActionGetCommand
func NewActionGetCommand(ctx Context) (cmd.Command, error) { return &ActionGetCommand{ctx: ctx}, nil }
go
func NewActionGetCommand(ctx Context) (cmd.Command, error) { return &ActionGetCommand{ctx: ctx}, nil }
[ "func", "NewActionGetCommand", "(", "ctx", "Context", ")", "(", "cmd", ".", "Command", ",", "error", ")", "{", "return", "&", "ActionGetCommand", "{", "ctx", ":", "ctx", "}", ",", "nil", "\n", "}" ]
// NewActionGetCommand returns an ActionGetCommand for use with the given // context.
[ "NewActionGetCommand", "returns", "an", "ActionGetCommand", "for", "use", "with", "the", "given", "context", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/action-get.go#L26-L28
155,655
juju/juju
worker/uniter/runner/jujuc/action-get.go
Init
func (c *ActionGetCommand) Init(args []string) error { if len(args) > 0 { err := cmd.CheckEmpty(args[1:]) if err != nil { return err } c.keys = strings.Split(args[0], ".") } return nil }
go
func (c *ActionGetCommand) Init(args []string) error { if len(args) > 0 { err := cmd.CheckEmpty(args[1:]) if err != nil { return err } c.keys = strings.Split(args[0], ".") } return nil }
[ "func", "(", "c", "*", "ActionGetCommand", ")", "Init", "(", "args", "[", "]", "string", ")", "error", "{", "if", "len", "(", "args", ")", ">", "0", "{", "err", ":=", "cmd", ".", "CheckEmpty", "(", "args", "[", "1", ":", "]", ")", "\n", "if", ...
// Init makes sure there are no additional unknown arguments to action-get.
[ "Init", "makes", "sure", "there", "are", "no", "additional", "unknown", "arguments", "to", "action", "-", "get", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/action-get.go#L52-L61
155,656
juju/juju
worker/uniter/runner/jujuc/action-get.go
Run
func (c *ActionGetCommand) Run(ctx *cmd.Context) error { params, err := c.ctx.ActionParams() if err != nil { return err } var answer interface{} if len(c.keys) == 0 { answer = params } else { answer, _ = recurseMapOnKeys(c.keys, params) } return c.out.Write(ctx, answer) }
go
func (c *ActionGetCommand) Run(ctx *cmd.Context) error { params, err := c.ctx.ActionParams() if err != nil { return err } var answer interface{} if len(c.keys) == 0 { answer = params } else { answer, _ = recurseMapOnKeys(c.keys, params) } return c.out.Write(ctx, answer) }
[ "func", "(", "c", "*", "ActionGetCommand", ")", "Run", "(", "ctx", "*", "cmd", ".", "Context", ")", "error", "{", "params", ",", "err", ":=", "c", ".", "ctx", ".", "ActionParams", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\...
// Run recurses into the params map for the Action, given the list of keys // into the map, and returns either the keyed value, or nothing. // In the case of an empty keys list, the entire params map will be returned.
[ "Run", "recurses", "into", "the", "params", "map", "for", "the", "Action", "given", "the", "list", "of", "keys", "into", "the", "map", "and", "returns", "either", "the", "keyed", "value", "or", "nothing", ".", "In", "the", "case", "of", "an", "empty", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/uniter/runner/jujuc/action-get.go#L110-L125
155,657
juju/juju
api/remoterelations/remoterelations.go
NewClient
func NewClient(caller base.APICaller) *Client { facadeCaller := base.NewFacadeCaller(caller, remoteRelationsFacade) return &Client{facadeCaller} }
go
func NewClient(caller base.APICaller) *Client { facadeCaller := base.NewFacadeCaller(caller, remoteRelationsFacade) return &Client{facadeCaller} }
[ "func", "NewClient", "(", "caller", "base", ".", "APICaller", ")", "*", "Client", "{", "facadeCaller", ":=", "base", ".", "NewFacadeCaller", "(", "caller", ",", "remoteRelationsFacade", ")", "\n", "return", "&", "Client", "{", "facadeCaller", "}", "\n", "}" ...
// NewClient creates a new client-side RemoteRelations facade.
[ "NewClient", "creates", "a", "new", "client", "-", "side", "RemoteRelations", "facade", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/remoterelations/remoterelations.go#L27-L30
155,658
juju/juju
api/remoterelations/remoterelations.go
ImportRemoteEntity
func (c *Client) ImportRemoteEntity(entity names.Tag, token string) error { args := params.RemoteEntityTokenArgs{Args: []params.RemoteEntityTokenArg{ {Tag: entity.String(), Token: token}}, } var results params.ErrorResults err := c.facade.FacadeCall("ImportRemoteEntities", args, &results) if err != nil { return errors.Trace(err) } if len(results.Results) != 1 { return errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return errors.Trace(result.Error) } return nil }
go
func (c *Client) ImportRemoteEntity(entity names.Tag, token string) error { args := params.RemoteEntityTokenArgs{Args: []params.RemoteEntityTokenArg{ {Tag: entity.String(), Token: token}}, } var results params.ErrorResults err := c.facade.FacadeCall("ImportRemoteEntities", args, &results) if err != nil { return errors.Trace(err) } if len(results.Results) != 1 { return errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return errors.Trace(result.Error) } return nil }
[ "func", "(", "c", "*", "Client", ")", "ImportRemoteEntity", "(", "entity", "names", ".", "Tag", ",", "token", "string", ")", "error", "{", "args", ":=", "params", ".", "RemoteEntityTokenArgs", "{", "Args", ":", "[", "]", "params", ".", "RemoteEntityTokenAr...
// ImportRemoteEntity adds an entity to the remote entities collection // with the specified opaque token.
[ "ImportRemoteEntity", "adds", "an", "entity", "to", "the", "remote", "entities", "collection", "with", "the", "specified", "opaque", "token", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/remoterelations/remoterelations.go#L34-L51
155,659
juju/juju
api/remoterelations/remoterelations.go
GetToken
func (c *Client) GetToken(tag names.Tag) (string, error) { args := params.GetTokenArgs{Args: []params.GetTokenArg{ {Tag: tag.String()}}, } var results params.StringResults err := c.facade.FacadeCall("GetTokens", args, &results) if err != nil { return "", errors.Trace(err) } if len(results.Results) != 1 { return "", errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { if params.IsCodeNotFound(result.Error) { return "", errors.NotFoundf("token for %v", tag) } return "", errors.Trace(result.Error) } return result.Result, nil }
go
func (c *Client) GetToken(tag names.Tag) (string, error) { args := params.GetTokenArgs{Args: []params.GetTokenArg{ {Tag: tag.String()}}, } var results params.StringResults err := c.facade.FacadeCall("GetTokens", args, &results) if err != nil { return "", errors.Trace(err) } if len(results.Results) != 1 { return "", errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { if params.IsCodeNotFound(result.Error) { return "", errors.NotFoundf("token for %v", tag) } return "", errors.Trace(result.Error) } return result.Result, nil }
[ "func", "(", "c", "*", "Client", ")", "GetToken", "(", "tag", "names", ".", "Tag", ")", "(", "string", ",", "error", ")", "{", "args", ":=", "params", ".", "GetTokenArgs", "{", "Args", ":", "[", "]", "params", ".", "GetTokenArg", "{", "{", "Tag", ...
// GetToken returns the token associated with the entity with the given tag for the specified model.
[ "GetToken", "returns", "the", "token", "associated", "with", "the", "entity", "with", "the", "given", "tag", "for", "the", "specified", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/remoterelations/remoterelations.go#L71-L91
155,660
juju/juju
api/remoterelations/remoterelations.go
SaveMacaroon
func (c *Client) SaveMacaroon(entity names.Tag, mac *macaroon.Macaroon) error { args := params.EntityMacaroonArgs{Args: []params.EntityMacaroonArg{ {Tag: entity.String(), Macaroon: mac}}, } var results params.ErrorResults err := c.facade.FacadeCall("SaveMacaroons", args, &results) if err != nil { return errors.Trace(err) } if len(results.Results) != 1 { return errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return errors.Trace(result.Error) } return nil }
go
func (c *Client) SaveMacaroon(entity names.Tag, mac *macaroon.Macaroon) error { args := params.EntityMacaroonArgs{Args: []params.EntityMacaroonArg{ {Tag: entity.String(), Macaroon: mac}}, } var results params.ErrorResults err := c.facade.FacadeCall("SaveMacaroons", args, &results) if err != nil { return errors.Trace(err) } if len(results.Results) != 1 { return errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return errors.Trace(result.Error) } return nil }
[ "func", "(", "c", "*", "Client", ")", "SaveMacaroon", "(", "entity", "names", ".", "Tag", ",", "mac", "*", "macaroon", ".", "Macaroon", ")", "error", "{", "args", ":=", "params", ".", "EntityMacaroonArgs", "{", "Args", ":", "[", "]", "params", ".", "...
// SaveMacaroon saves the macaroon for the entity.
[ "SaveMacaroon", "saves", "the", "macaroon", "for", "the", "entity", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/remoterelations/remoterelations.go#L94-L111
155,661
juju/juju
api/remoterelations/remoterelations.go
WatchRemoteApplicationRelations
func (c *Client) WatchRemoteApplicationRelations(application string) (watcher.StringsWatcher, error) { if !names.IsValidApplication(application) { return nil, errors.NotValidf("application name %q", application) } applicationTag := names.NewApplicationTag(application) args := params.Entities{ Entities: []params.Entity{{Tag: applicationTag.String()}}, } var results params.StringsWatchResults err := c.facade.FacadeCall("WatchRemoteApplicationRelations", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, result.Error } w := apiwatcher.NewStringsWatcher(c.facade.RawAPICaller(), result) return w, nil }
go
func (c *Client) WatchRemoteApplicationRelations(application string) (watcher.StringsWatcher, error) { if !names.IsValidApplication(application) { return nil, errors.NotValidf("application name %q", application) } applicationTag := names.NewApplicationTag(application) args := params.Entities{ Entities: []params.Entity{{Tag: applicationTag.String()}}, } var results params.StringsWatchResults err := c.facade.FacadeCall("WatchRemoteApplicationRelations", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, result.Error } w := apiwatcher.NewStringsWatcher(c.facade.RawAPICaller(), result) return w, nil }
[ "func", "(", "c", "*", "Client", ")", "WatchRemoteApplicationRelations", "(", "application", "string", ")", "(", "watcher", ".", "StringsWatcher", ",", "error", ")", "{", "if", "!", "names", ".", "IsValidApplication", "(", "application", ")", "{", "return", ...
// WatchRemoteApplicationRelations returns remote relations watchers that delivers // changes according to the addition, removal, and lifecycle changes of // relations that the specified remote application is involved in; and also // according to the entering, departing, and change of unit settings in // those relations.
[ "WatchRemoteApplicationRelations", "returns", "remote", "relations", "watchers", "that", "delivers", "changes", "according", "to", "the", "addition", "removal", "and", "lifecycle", "changes", "of", "relations", "that", "the", "specified", "remote", "application", "is", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/remoterelations/remoterelations.go#L183-L206
155,662
juju/juju
api/remoterelations/remoterelations.go
WatchLocalRelationUnits
func (c *Client) WatchLocalRelationUnits(relationKey string) (watcher.RelationUnitsWatcher, error) { if !names.IsValidRelation(relationKey) { return nil, errors.NotValidf("relation key %q", relationKey) } relationTag := names.NewRelationTag(relationKey) args := params.Entities{ Entities: []params.Entity{{Tag: relationTag.String()}}, } var results params.RelationUnitsWatchResults err := c.facade.FacadeCall("WatchLocalRelationUnits", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, result.Error } w := apiwatcher.NewRelationUnitsWatcher(c.facade.RawAPICaller(), result) return w, nil }
go
func (c *Client) WatchLocalRelationUnits(relationKey string) (watcher.RelationUnitsWatcher, error) { if !names.IsValidRelation(relationKey) { return nil, errors.NotValidf("relation key %q", relationKey) } relationTag := names.NewRelationTag(relationKey) args := params.Entities{ Entities: []params.Entity{{Tag: relationTag.String()}}, } var results params.RelationUnitsWatchResults err := c.facade.FacadeCall("WatchLocalRelationUnits", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, result.Error } w := apiwatcher.NewRelationUnitsWatcher(c.facade.RawAPICaller(), result) return w, nil }
[ "func", "(", "c", "*", "Client", ")", "WatchLocalRelationUnits", "(", "relationKey", "string", ")", "(", "watcher", ".", "RelationUnitsWatcher", ",", "error", ")", "{", "if", "!", "names", ".", "IsValidRelation", "(", "relationKey", ")", "{", "return", "nil"...
// WatchLocalRelationUnits returns a watcher that notifies of changes to the // local units in the relation with the given key.
[ "WatchLocalRelationUnits", "returns", "a", "watcher", "that", "notifies", "of", "changes", "to", "the", "local", "units", "in", "the", "relation", "with", "the", "given", "key", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/remoterelations/remoterelations.go#L210-L232
155,663
juju/juju
api/remoterelations/remoterelations.go
SetRemoteApplicationStatus
func (c *Client) SetRemoteApplicationStatus(applicationName string, status status.Status, message string) error { args := params.SetStatus{Entities: []params.EntityStatusArgs{ {Tag: names.NewApplicationTag(applicationName).String(), Status: status.String(), Info: message}, }} var results params.ErrorResults err := c.facade.FacadeCall("SetRemoteApplicationsStatus", args, &results) if err != nil { return errors.Trace(err) } return results.OneError() }
go
func (c *Client) SetRemoteApplicationStatus(applicationName string, status status.Status, message string) error { args := params.SetStatus{Entities: []params.EntityStatusArgs{ {Tag: names.NewApplicationTag(applicationName).String(), Status: status.String(), Info: message}, }} var results params.ErrorResults err := c.facade.FacadeCall("SetRemoteApplicationsStatus", args, &results) if err != nil { return errors.Trace(err) } return results.OneError() }
[ "func", "(", "c", "*", "Client", ")", "SetRemoteApplicationStatus", "(", "applicationName", "string", ",", "status", "status", ".", "Status", ",", "message", "string", ")", "error", "{", "args", ":=", "params", ".", "SetStatus", "{", "Entities", ":", "[", ...
// SetRemoteApplicationStatus sets the status for the specified remote application.
[ "SetRemoteApplicationStatus", "sets", "the", "status", "for", "the", "specified", "remote", "application", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/remoterelations/remoterelations.go#L287-L297
155,664
juju/juju
downloader/download.go
StartDownload
func StartDownload(req Request, openBlob func(*url.URL) (io.ReadCloser, error)) *Download { if openBlob == nil { openBlob = NewHTTPBlobOpener(utils.NoVerifySSLHostnames) } dl := &Download{ done: make(chan Status, 1), openBlob: openBlob, } go dl.run(req) return dl }
go
func StartDownload(req Request, openBlob func(*url.URL) (io.ReadCloser, error)) *Download { if openBlob == nil { openBlob = NewHTTPBlobOpener(utils.NoVerifySSLHostnames) } dl := &Download{ done: make(chan Status, 1), openBlob: openBlob, } go dl.run(req) return dl }
[ "func", "StartDownload", "(", "req", "Request", ",", "openBlob", "func", "(", "*", "url", ".", "URL", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", ")", "*", "Download", "{", "if", "openBlob", "==", "nil", "{", "openBlob", "=", "NewHTTPBlobOpen...
// StartDownload starts a new download as specified by `req` using // `openBlob` to actually pull the remote data.
[ "StartDownload", "starts", "a", "new", "download", "as", "specified", "by", "req", "using", "openBlob", "to", "actually", "pull", "the", "remote", "data", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/downloader/download.go#L46-L56
155,665
juju/juju
state/cloud.go
createCloudOp
func createCloudOp(cloud cloud.Cloud) txn.Op { authTypes := make([]string, len(cloud.AuthTypes)) for i, authType := range cloud.AuthTypes { authTypes[i] = string(authType) } regions := make(map[string]cloudRegionSubdoc) for _, region := range cloud.Regions { regions[utils.EscapeKey(region.Name)] = cloudRegionSubdoc{ region.Endpoint, region.IdentityEndpoint, region.StorageEndpoint, } } return txn.Op{ C: cloudsC, Id: cloud.Name, Assert: txn.DocMissing, Insert: &cloudDoc{ Name: cloud.Name, Type: cloud.Type, AuthTypes: authTypes, Endpoint: cloud.Endpoint, IdentityEndpoint: cloud.IdentityEndpoint, StorageEndpoint: cloud.StorageEndpoint, Regions: regions, CACertificates: cloud.CACertificates, }, } }
go
func createCloudOp(cloud cloud.Cloud) txn.Op { authTypes := make([]string, len(cloud.AuthTypes)) for i, authType := range cloud.AuthTypes { authTypes[i] = string(authType) } regions := make(map[string]cloudRegionSubdoc) for _, region := range cloud.Regions { regions[utils.EscapeKey(region.Name)] = cloudRegionSubdoc{ region.Endpoint, region.IdentityEndpoint, region.StorageEndpoint, } } return txn.Op{ C: cloudsC, Id: cloud.Name, Assert: txn.DocMissing, Insert: &cloudDoc{ Name: cloud.Name, Type: cloud.Type, AuthTypes: authTypes, Endpoint: cloud.Endpoint, IdentityEndpoint: cloud.IdentityEndpoint, StorageEndpoint: cloud.StorageEndpoint, Regions: regions, CACertificates: cloud.CACertificates, }, } }
[ "func", "createCloudOp", "(", "cloud", "cloud", ".", "Cloud", ")", "txn", ".", "Op", "{", "authTypes", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "cloud", ".", "AuthTypes", ")", ")", "\n", "for", "i", ",", "authType", ":=", "range", "c...
// createCloudOp returns a txn.Op that will initialize // the cloud definition for the controller.
[ "createCloudOp", "returns", "a", "txn", ".", "Op", "that", "will", "initialize", "the", "cloud", "definition", "for", "the", "controller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L52-L80
155,666
juju/juju
state/cloud.go
updateCloudOps
func updateCloudOps(cloud cloud.Cloud) txn.Op { authTypes := make([]string, len(cloud.AuthTypes)) for i, authType := range cloud.AuthTypes { authTypes[i] = string(authType) } regions := make(map[string]cloudRegionSubdoc) for _, region := range cloud.Regions { regions[utils.EscapeKey(region.Name)] = cloudRegionSubdoc{ region.Endpoint, region.IdentityEndpoint, region.StorageEndpoint, } } updatedCloud := &cloudDoc{ DocID: cloud.Name, Name: cloud.Name, Type: cloud.Type, AuthTypes: authTypes, Endpoint: cloud.Endpoint, IdentityEndpoint: cloud.IdentityEndpoint, StorageEndpoint: cloud.StorageEndpoint, Regions: regions, CACertificates: cloud.CACertificates, } return txn.Op{ C: cloudsC, Id: cloud.Name, Assert: txn.DocExists, Update: bson.M{"$set": updatedCloud}, } }
go
func updateCloudOps(cloud cloud.Cloud) txn.Op { authTypes := make([]string, len(cloud.AuthTypes)) for i, authType := range cloud.AuthTypes { authTypes[i] = string(authType) } regions := make(map[string]cloudRegionSubdoc) for _, region := range cloud.Regions { regions[utils.EscapeKey(region.Name)] = cloudRegionSubdoc{ region.Endpoint, region.IdentityEndpoint, region.StorageEndpoint, } } updatedCloud := &cloudDoc{ DocID: cloud.Name, Name: cloud.Name, Type: cloud.Type, AuthTypes: authTypes, Endpoint: cloud.Endpoint, IdentityEndpoint: cloud.IdentityEndpoint, StorageEndpoint: cloud.StorageEndpoint, Regions: regions, CACertificates: cloud.CACertificates, } return txn.Op{ C: cloudsC, Id: cloud.Name, Assert: txn.DocExists, Update: bson.M{"$set": updatedCloud}, } }
[ "func", "updateCloudOps", "(", "cloud", "cloud", ".", "Cloud", ")", "txn", ".", "Op", "{", "authTypes", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "cloud", ".", "AuthTypes", ")", ")", "\n", "for", "i", ",", "authType", ":=", "range", "...
// updateCloudOp returns a txn.Op that will update // an existing cloud definition for the controller.
[ "updateCloudOp", "returns", "a", "txn", ".", "Op", "that", "will", "update", "an", "existing", "cloud", "definition", "for", "the", "controller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L84-L114
155,667
juju/juju
state/cloud.go
incCloudModelRefOp
func incCloudModelRefOp(mb modelBackend, cloudName string) (txn.Op, error) { refcounts, closer := mb.db().GetCollection(globalRefcountsC) defer closer() cloudModelRefCountKey := cloudModelRefCountKey(cloudName) incRefOp, err := nsRefcounts.CreateOrIncRefOp(refcounts, cloudModelRefCountKey, 1) return incRefOp, errors.Trace(err) }
go
func incCloudModelRefOp(mb modelBackend, cloudName string) (txn.Op, error) { refcounts, closer := mb.db().GetCollection(globalRefcountsC) defer closer() cloudModelRefCountKey := cloudModelRefCountKey(cloudName) incRefOp, err := nsRefcounts.CreateOrIncRefOp(refcounts, cloudModelRefCountKey, 1) return incRefOp, errors.Trace(err) }
[ "func", "incCloudModelRefOp", "(", "mb", "modelBackend", ",", "cloudName", "string", ")", "(", "txn", ".", "Op", ",", "error", ")", "{", "refcounts", ",", "closer", ":=", "mb", ".", "db", "(", ")", ".", "GetCollection", "(", "globalRefcountsC", ")", "\n"...
// incApplicationOffersRefOp returns a txn.Op that increments the reference // count for a cloud model.
[ "incApplicationOffersRefOp", "returns", "a", "txn", ".", "Op", "that", "increments", "the", "reference", "count", "for", "a", "cloud", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L125-L131
155,668
juju/juju
state/cloud.go
countCloudModelRefOp
func countCloudModelRefOp(mb modelBackend, cloudName string) (txn.Op, int, error) { refcounts, closer := mb.db().GetCollection(globalRefcountsC) defer closer() key := cloudModelRefCountKey(cloudName) return nsRefcounts.CurrentOp(refcounts, key) }
go
func countCloudModelRefOp(mb modelBackend, cloudName string) (txn.Op, int, error) { refcounts, closer := mb.db().GetCollection(globalRefcountsC) defer closer() key := cloudModelRefCountKey(cloudName) return nsRefcounts.CurrentOp(refcounts, key) }
[ "func", "countCloudModelRefOp", "(", "mb", "modelBackend", ",", "cloudName", "string", ")", "(", "txn", ".", "Op", ",", "int", ",", "error", ")", "{", "refcounts", ",", "closer", ":=", "mb", ".", "db", "(", ")", ".", "GetCollection", "(", "globalRefcount...
// countCloudModelRefOp returns the number of models for a cloud, // along with a txn.Op that ensures that that does not change.
[ "countCloudModelRefOp", "returns", "the", "number", "of", "models", "for", "a", "cloud", "along", "with", "a", "txn", ".", "Op", "that", "ensures", "that", "that", "does", "not", "change", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L135-L140
155,669
juju/juju
state/cloud.go
decCloudModelRefOp
func decCloudModelRefOp(mb modelBackend, cloudName string) (txn.Op, error) { refcounts, closer := mb.db().GetCollection(globalRefcountsC) defer closer() cloudModelRefCountKey := cloudModelRefCountKey(cloudName) decRefOp, _, err := nsRefcounts.DyingDecRefOp(refcounts, cloudModelRefCountKey) if err != nil { return txn.Op{}, errors.Trace(err) } return decRefOp, nil }
go
func decCloudModelRefOp(mb modelBackend, cloudName string) (txn.Op, error) { refcounts, closer := mb.db().GetCollection(globalRefcountsC) defer closer() cloudModelRefCountKey := cloudModelRefCountKey(cloudName) decRefOp, _, err := nsRefcounts.DyingDecRefOp(refcounts, cloudModelRefCountKey) if err != nil { return txn.Op{}, errors.Trace(err) } return decRefOp, nil }
[ "func", "decCloudModelRefOp", "(", "mb", "modelBackend", ",", "cloudName", "string", ")", "(", "txn", ".", "Op", ",", "error", ")", "{", "refcounts", ",", "closer", ":=", "mb", ".", "db", "(", ")", ".", "GetCollection", "(", "globalRefcountsC", ")", "\n"...
// decCloudModelRefOp returns a txn.Op that decrements the reference // count for a cloud model.
[ "decCloudModelRefOp", "returns", "a", "txn", ".", "Op", "that", "decrements", "the", "reference", "count", "for", "a", "cloud", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L144-L153
155,670
juju/juju
state/cloud.go
Clouds
func (st *State) Clouds() (map[names.CloudTag]cloud.Cloud, error) { coll, cleanup := st.db().GetCollection(cloudsC) defer cleanup() var doc cloudDoc clouds := make(map[names.CloudTag]cloud.Cloud) iter := coll.Find(nil).Iter() for iter.Next(&doc) { clouds[names.NewCloudTag(doc.Name)] = doc.toCloud() } if err := iter.Close(); err != nil { return nil, errors.Annotate(err, "getting clouds") } return clouds, nil }
go
func (st *State) Clouds() (map[names.CloudTag]cloud.Cloud, error) { coll, cleanup := st.db().GetCollection(cloudsC) defer cleanup() var doc cloudDoc clouds := make(map[names.CloudTag]cloud.Cloud) iter := coll.Find(nil).Iter() for iter.Next(&doc) { clouds[names.NewCloudTag(doc.Name)] = doc.toCloud() } if err := iter.Close(); err != nil { return nil, errors.Annotate(err, "getting clouds") } return clouds, nil }
[ "func", "(", "st", "*", "State", ")", "Clouds", "(", ")", "(", "map", "[", "names", ".", "CloudTag", "]", "cloud", ".", "Cloud", ",", "error", ")", "{", "coll", ",", "cleanup", ":=", "st", ".", "db", "(", ")", ".", "GetCollection", "(", "cloudsC"...
// Clouds returns the definitions for all clouds in the controller.
[ "Clouds", "returns", "the", "definitions", "for", "all", "clouds", "in", "the", "controller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L187-L201
155,671
juju/juju
state/cloud.go
Cloud
func (st *State) Cloud(name string) (cloud.Cloud, error) { coll, cleanup := st.db().GetCollection(cloudsC) defer cleanup() var doc cloudDoc err := coll.FindId(name).One(&doc) if err == mgo.ErrNotFound { return cloud.Cloud{}, errors.NotFoundf("cloud %q", name) } if err != nil { return cloud.Cloud{}, errors.Annotatef(err, "cannot get cloud %q", name) } return doc.toCloud(), nil }
go
func (st *State) Cloud(name string) (cloud.Cloud, error) { coll, cleanup := st.db().GetCollection(cloudsC) defer cleanup() var doc cloudDoc err := coll.FindId(name).One(&doc) if err == mgo.ErrNotFound { return cloud.Cloud{}, errors.NotFoundf("cloud %q", name) } if err != nil { return cloud.Cloud{}, errors.Annotatef(err, "cannot get cloud %q", name) } return doc.toCloud(), nil }
[ "func", "(", "st", "*", "State", ")", "Cloud", "(", "name", "string", ")", "(", "cloud", ".", "Cloud", ",", "error", ")", "{", "coll", ",", "cleanup", ":=", "st", ".", "db", "(", ")", ".", "GetCollection", "(", "cloudsC", ")", "\n", "defer", "cle...
// Cloud returns the controller's cloud definition.
[ "Cloud", "returns", "the", "controller", "s", "cloud", "definition", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L204-L217
155,672
juju/juju
state/cloud.go
AddCloud
func (st *State) AddCloud(c cloud.Cloud, owner string) error { if err := validateCloud(c); err != nil { return errors.Annotate(err, "invalid cloud") } ops := []txn.Op{createCloudOp(c)} if err := st.db().RunTransaction(ops); err != nil { if err == txn.ErrAborted { err = errors.AlreadyExistsf("cloud %q", c.Name) } return err } // Ensure the owner has access to the cloud. ownerTag := names.NewUserTag(owner) err := st.CreateCloudAccess(c.Name, ownerTag, permission.AdminAccess) if err != nil { return errors.Annotatef(err, "granting %s permission to the cloud owner", permission.AdminAccess) } return st.updateConfigDefaults(c.Name, c.Config, c.RegionConfig) }
go
func (st *State) AddCloud(c cloud.Cloud, owner string) error { if err := validateCloud(c); err != nil { return errors.Annotate(err, "invalid cloud") } ops := []txn.Op{createCloudOp(c)} if err := st.db().RunTransaction(ops); err != nil { if err == txn.ErrAborted { err = errors.AlreadyExistsf("cloud %q", c.Name) } return err } // Ensure the owner has access to the cloud. ownerTag := names.NewUserTag(owner) err := st.CreateCloudAccess(c.Name, ownerTag, permission.AdminAccess) if err != nil { return errors.Annotatef(err, "granting %s permission to the cloud owner", permission.AdminAccess) } return st.updateConfigDefaults(c.Name, c.Config, c.RegionConfig) }
[ "func", "(", "st", "*", "State", ")", "AddCloud", "(", "c", "cloud", ".", "Cloud", ",", "owner", "string", ")", "error", "{", "if", "err", ":=", "validateCloud", "(", "c", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(",...
// AddCloud creates a cloud with the given name and details. // Note that the Config is deliberately ignored - it's only // relevant when bootstrapping.
[ "AddCloud", "creates", "a", "cloud", "with", "the", "given", "name", "and", "details", ".", "Note", "that", "the", "Config", "is", "deliberately", "ignored", "-", "it", "s", "only", "relevant", "when", "bootstrapping", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L222-L240
155,673
juju/juju
state/cloud.go
UpdateCloud
func (st *State) UpdateCloud(c cloud.Cloud) error { if err := validateCloud(c); err != nil { return errors.Trace(err) } if err := st.db().RunTransaction([]txn.Op{updateCloudOps(c)}); err != nil { if err == txn.ErrAborted { err = errors.NotFoundf("cloud %q", c.Name) } return errors.Trace(err) } return st.updateConfigDefaults(c.Name, c.Config, c.RegionConfig) }
go
func (st *State) UpdateCloud(c cloud.Cloud) error { if err := validateCloud(c); err != nil { return errors.Trace(err) } if err := st.db().RunTransaction([]txn.Op{updateCloudOps(c)}); err != nil { if err == txn.ErrAborted { err = errors.NotFoundf("cloud %q", c.Name) } return errors.Trace(err) } return st.updateConfigDefaults(c.Name, c.Config, c.RegionConfig) }
[ "func", "(", "st", "*", "State", ")", "UpdateCloud", "(", "c", "cloud", ".", "Cloud", ")", "error", "{", "if", "err", ":=", "validateCloud", "(", "c", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}"...
// UpdateCloud updates an existing cloud with the given name and details. // Note that the Config is deliberately ignored - it's only // relevant when bootstrapping.
[ "UpdateCloud", "updates", "an", "existing", "cloud", "with", "the", "given", "name", "and", "details", ".", "Note", "that", "the", "Config", "is", "deliberately", "ignored", "-", "it", "s", "only", "relevant", "when", "bootstrapping", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L245-L257
155,674
juju/juju
state/cloud.go
validateCloud
func validateCloud(cloud cloud.Cloud) error { if cloud.Name == "" { return errors.NotValidf("empty Name") } if cloud.Type == "" { return errors.NotValidf("empty Type") } if len(cloud.AuthTypes) == 0 { return errors.NotValidf("empty auth-types") } // TODO(axw) we should ensure that the cloud auth-types is a subset // of the auth-types supported by the provider. To do that, we'll // need a new "policy". return nil }
go
func validateCloud(cloud cloud.Cloud) error { if cloud.Name == "" { return errors.NotValidf("empty Name") } if cloud.Type == "" { return errors.NotValidf("empty Type") } if len(cloud.AuthTypes) == 0 { return errors.NotValidf("empty auth-types") } // TODO(axw) we should ensure that the cloud auth-types is a subset // of the auth-types supported by the provider. To do that, we'll // need a new "policy". return nil }
[ "func", "validateCloud", "(", "cloud", "cloud", ".", "Cloud", ")", "error", "{", "if", "cloud", ".", "Name", "==", "\"", "\"", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "cloud", ".", "Type", "==", "\"",...
// validateCloud checks that the supplied cloud is valid.
[ "validateCloud", "checks", "that", "the", "supplied", "cloud", "is", "valid", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L287-L301
155,675
juju/juju
state/cloud.go
RemoveCloud
func (st *State) RemoveCloud(name string) error { buildTxn := func(attempt int) ([]txn.Op, error) { if _, err := st.Cloud(name); err != nil { // Fail with not found error on first attempt if cloud doesn't exist. // On subsequent attempts, if cloud not found then // it was deleted by someone else and that's a no-op. if attempt > 1 && errors.IsNotFound(err) { return nil, jujutxn.ErrNoOperations } return nil, errors.Trace(err) } return st.removeCloudOps(name) } return st.db().Run(buildTxn) }
go
func (st *State) RemoveCloud(name string) error { buildTxn := func(attempt int) ([]txn.Op, error) { if _, err := st.Cloud(name); err != nil { // Fail with not found error on first attempt if cloud doesn't exist. // On subsequent attempts, if cloud not found then // it was deleted by someone else and that's a no-op. if attempt > 1 && errors.IsNotFound(err) { return nil, jujutxn.ErrNoOperations } return nil, errors.Trace(err) } return st.removeCloudOps(name) } return st.db().Run(buildTxn) }
[ "func", "(", "st", "*", "State", ")", "RemoveCloud", "(", "name", "string", ")", "error", "{", "buildTxn", ":=", "func", "(", "attempt", "int", ")", "(", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "if", "_", ",", "err", ":=", "st", "."...
// RemoveCloud removes a cloud and any credentials for that cloud. // If the cloud is in use, ie has models deployed to it, the operation fails.
[ "RemoveCloud", "removes", "a", "cloud", "and", "any", "credentials", "for", "that", "cloud", ".", "If", "the", "cloud", "is", "in", "use", "ie", "has", "models", "deployed", "to", "it", "the", "operation", "fails", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L310-L324
155,676
juju/juju
state/cloud.go
removeCloudOps
func (st *State) removeCloudOps(name string) ([]txn.Op, error) { countOp, n, err := countCloudModelRefOp(st, name) if err != nil { return nil, errors.Trace(err) } if n != 0 { return nil, errors.Errorf("cloud is used by %d model%s", n, plural(n)) } ops := []txn.Op{{ C: cloudsC, Id: name, Remove: true, }, countOp} credPattern := bson.M{ "_id": bson.M{"$regex": "^" + name + "#"}, } credOps, err := st.removeInCollectionOps(cloudCredentialsC, credPattern) if err != nil { return nil, errors.Trace(err) } ops = append(ops, credOps...) permPattern := bson.M{ "_id": bson.M{"$regex": "^" + cloudGlobalKey(name) + "#"}, } permOps, err := st.removeInCollectionOps(permissionsC, permPattern) if err != nil { return nil, errors.Trace(err) } ops = append(ops, permOps...) settingsPattern := bson.M{ "_id": bson.M{"$regex": "^(" + cloudGlobalKey(name) + "|" + name + "#.*)"}, } settingsOps, err := st.removeInCollectionOps(globalSettingsC, settingsPattern) if err != nil { return nil, errors.Trace(err) } ops = append(ops, settingsOps...) return ops, nil }
go
func (st *State) removeCloudOps(name string) ([]txn.Op, error) { countOp, n, err := countCloudModelRefOp(st, name) if err != nil { return nil, errors.Trace(err) } if n != 0 { return nil, errors.Errorf("cloud is used by %d model%s", n, plural(n)) } ops := []txn.Op{{ C: cloudsC, Id: name, Remove: true, }, countOp} credPattern := bson.M{ "_id": bson.M{"$regex": "^" + name + "#"}, } credOps, err := st.removeInCollectionOps(cloudCredentialsC, credPattern) if err != nil { return nil, errors.Trace(err) } ops = append(ops, credOps...) permPattern := bson.M{ "_id": bson.M{"$regex": "^" + cloudGlobalKey(name) + "#"}, } permOps, err := st.removeInCollectionOps(permissionsC, permPattern) if err != nil { return nil, errors.Trace(err) } ops = append(ops, permOps...) settingsPattern := bson.M{ "_id": bson.M{"$regex": "^(" + cloudGlobalKey(name) + "|" + name + "#.*)"}, } settingsOps, err := st.removeInCollectionOps(globalSettingsC, settingsPattern) if err != nil { return nil, errors.Trace(err) } ops = append(ops, settingsOps...) return ops, nil }
[ "func", "(", "st", "*", "State", ")", "removeCloudOps", "(", "name", "string", ")", "(", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "countOp", ",", "n", ",", "err", ":=", "countCloudModelRefOp", "(", "st", ",", "name", ")", "\n", "if", "...
// removeCloudOp returns a list of txn.Ops that will remove // the specified cloud and any associated credentials.
[ "removeCloudOp", "returns", "a", "list", "of", "txn", ".", "Ops", "that", "will", "remove", "the", "specified", "cloud", "and", "any", "associated", "credentials", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/cloud.go#L328-L370
155,677
juju/juju
worker/instancepoller/worker.go
NewWorker
func NewWorker(config Config) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } u := &updaterWorker{ config: config, } err := catacomb.Invoke(catacomb.Plan{ Site: &u.catacomb, Work: u.loop, }) if err != nil { return nil, errors.Trace(err) } return u, nil }
go
func NewWorker(config Config) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } u := &updaterWorker{ config: config, } err := catacomb.Invoke(catacomb.Plan{ Site: &u.catacomb, Work: u.loop, }) if err != nil { return nil, errors.Trace(err) } return u, nil }
[ "func", "NewWorker", "(", "config", "Config", ")", "(", "worker", ".", "Worker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err",...
// NewWorker returns a worker that keeps track of // the machines in the state and polls their instance // addresses and status periodically to keep them up to date.
[ "NewWorker", "returns", "a", "worker", "that", "keeps", "track", "of", "the", "machines", "in", "the", "state", "and", "polls", "their", "instance", "addresses", "and", "status", "periodically", "to", "keep", "them", "up", "to", "date", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/instancepoller/worker.go#L57-L72
155,678
juju/juju
worker/instancepoller/worker.go
getMachine
func (u *updaterWorker) getMachine(tag names.MachineTag) (machine, error) { return u.config.Facade.Machine(tag) }
go
func (u *updaterWorker) getMachine(tag names.MachineTag) (machine, error) { return u.config.Facade.Machine(tag) }
[ "func", "(", "u", "*", "updaterWorker", ")", "getMachine", "(", "tag", "names", ".", "MachineTag", ")", "(", "machine", ",", "error", ")", "{", "return", "u", ".", "config", ".", "Facade", ".", "Machine", "(", "tag", ")", "\n", "}" ]
// getMachine is part of the machineContext interface.
[ "getMachine", "is", "part", "of", "the", "machineContext", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/instancepoller/worker.go#L115-L117
155,679
juju/juju
worker/instancepoller/worker.go
instanceInfo
func (u *updaterWorker) instanceInfo(id instance.Id) (instanceInfo, error) { return u.aggregator.instanceInfo(id) }
go
func (u *updaterWorker) instanceInfo(id instance.Id) (instanceInfo, error) { return u.aggregator.instanceInfo(id) }
[ "func", "(", "u", "*", "updaterWorker", ")", "instanceInfo", "(", "id", "instance", ".", "Id", ")", "(", "instanceInfo", ",", "error", ")", "{", "return", "u", ".", "aggregator", ".", "instanceInfo", "(", "id", ")", "\n", "}" ]
// instanceInfo is part of the machineContext interface.
[ "instanceInfo", "is", "part", "of", "the", "machineContext", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/instancepoller/worker.go#L120-L122
155,680
juju/juju
upgrades/steps_236.go
stateStepsFor236
func stateStepsFor236() []Step { return []Step{ &upgradeStep{ description: "ensure container-image-stream config defaults to released", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().EnsureContainerImageStreamDefault() }, }, } }
go
func stateStepsFor236() []Step { return []Step{ &upgradeStep{ description: "ensure container-image-stream config defaults to released", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().EnsureContainerImageStreamDefault() }, }, } }
[ "func", "stateStepsFor236", "(", ")", "[", "]", "Step", "{", "return", "[", "]", "Step", "{", "&", "upgradeStep", "{", "description", ":", "\"", "\"", ",", "targets", ":", "[", "]", "Target", "{", "DatabaseMaster", "}", ",", "run", ":", "func", "(", ...
// stateStepsFor236 returns upgrade steps for Juju 2.3.6 that manipulate state directly.
[ "stateStepsFor236", "returns", "upgrade", "steps", "for", "Juju", "2", ".", "3", ".", "6", "that", "manipulate", "state", "directly", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/upgrades/steps_236.go#L7-L17
155,681
juju/juju
api/common/controllerconfig.go
ControllerConfig
func (e *ControllerConfigAPI) ControllerConfig() (controller.Config, error) { var result params.ControllerConfigResult err := e.facade.FacadeCall("ControllerConfig", nil, &result) if err != nil { return nil, err } return controller.Config(result.Config), nil }
go
func (e *ControllerConfigAPI) ControllerConfig() (controller.Config, error) { var result params.ControllerConfigResult err := e.facade.FacadeCall("ControllerConfig", nil, &result) if err != nil { return nil, err } return controller.Config(result.Config), nil }
[ "func", "(", "e", "*", "ControllerConfigAPI", ")", "ControllerConfig", "(", ")", "(", "controller", ".", "Config", ",", "error", ")", "{", "var", "result", "params", ".", "ControllerConfigResult", "\n", "err", ":=", "e", ".", "facade", ".", "FacadeCall", "...
// ControllerConfig returns the current controller configuration.
[ "ControllerConfig", "returns", "the", "current", "controller", "configuration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/controllerconfig.go#L25-L32
155,682
juju/juju
api/common/modelwatcher.go
WatchForModelConfigChanges
func (e *ModelWatcher) WatchForModelConfigChanges() (watcher.NotifyWatcher, error) { var result params.NotifyWatchResult err := e.facade.FacadeCall("WatchForModelConfigChanges", nil, &result) if err != nil { return nil, err } return apiwatcher.NewNotifyWatcher(e.facade.RawAPICaller(), result), nil }
go
func (e *ModelWatcher) WatchForModelConfigChanges() (watcher.NotifyWatcher, error) { var result params.NotifyWatchResult err := e.facade.FacadeCall("WatchForModelConfigChanges", nil, &result) if err != nil { return nil, err } return apiwatcher.NewNotifyWatcher(e.facade.RawAPICaller(), result), nil }
[ "func", "(", "e", "*", "ModelWatcher", ")", "WatchForModelConfigChanges", "(", ")", "(", "watcher", ".", "NotifyWatcher", ",", "error", ")", "{", "var", "result", "params", ".", "NotifyWatchResult", "\n", "err", ":=", "e", ".", "facade", ".", "FacadeCall", ...
// WatchForModelConfigChanges return a NotifyWatcher waiting for the // model configuration to change.
[ "WatchForModelConfigChanges", "return", "a", "NotifyWatcher", "waiting", "for", "the", "model", "configuration", "to", "change", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/modelwatcher.go#L33-L40
155,683
juju/juju
api/common/modelwatcher.go
ModelConfig
func (e *ModelWatcher) ModelConfig() (*config.Config, error) { var result params.ModelConfigResult err := e.facade.FacadeCall("ModelConfig", nil, &result) if err != nil { return nil, errors.Trace(err) } conf, err := config.New(config.NoDefaults, result.Config) if err != nil { return nil, errors.Trace(err) } return conf, nil }
go
func (e *ModelWatcher) ModelConfig() (*config.Config, error) { var result params.ModelConfigResult err := e.facade.FacadeCall("ModelConfig", nil, &result) if err != nil { return nil, errors.Trace(err) } conf, err := config.New(config.NoDefaults, result.Config) if err != nil { return nil, errors.Trace(err) } return conf, nil }
[ "func", "(", "e", "*", "ModelWatcher", ")", "ModelConfig", "(", ")", "(", "*", "config", ".", "Config", ",", "error", ")", "{", "var", "result", "params", ".", "ModelConfigResult", "\n", "err", ":=", "e", ".", "facade", ".", "FacadeCall", "(", "\"", ...
// ModelConfig returns the current model configuration.
[ "ModelConfig", "returns", "the", "current", "model", "configuration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/modelwatcher.go#L43-L54
155,684
juju/juju
api/common/modelwatcher.go
LogForwardConfig
func (e *ModelWatcher) LogForwardConfig() (*syslog.RawConfig, bool, error) { // TODO(wallyworld) - lp:1602237 - this needs to have it's own backend implementation. // For now, we'll piggyback off the ModelConfig API. modelConfig, err := e.ModelConfig() if err != nil { return nil, false, err } cfg, ok := modelConfig.LogFwdSyslog() return cfg, ok, nil }
go
func (e *ModelWatcher) LogForwardConfig() (*syslog.RawConfig, bool, error) { // TODO(wallyworld) - lp:1602237 - this needs to have it's own backend implementation. // For now, we'll piggyback off the ModelConfig API. modelConfig, err := e.ModelConfig() if err != nil { return nil, false, err } cfg, ok := modelConfig.LogFwdSyslog() return cfg, ok, nil }
[ "func", "(", "e", "*", "ModelWatcher", ")", "LogForwardConfig", "(", ")", "(", "*", "syslog", ".", "RawConfig", ",", "bool", ",", "error", ")", "{", "// TODO(wallyworld) - lp:1602237 - this needs to have it's own backend implementation.", "// For now, we'll piggyback off th...
// LogForwardConfig returns the current log forward syslog configuration.
[ "LogForwardConfig", "returns", "the", "current", "log", "forward", "syslog", "configuration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/modelwatcher.go#L65-L74
155,685
juju/juju
api/common/modelwatcher.go
UpdateStatusHookInterval
func (e *ModelWatcher) UpdateStatusHookInterval() (time.Duration, error) { // TODO(wallyworld) - lp:1602237 - this needs to have it's own backend implementation. // For now, we'll piggyback off the ModelConfig API. modelConfig, err := e.ModelConfig() if err != nil { return 0, err } return modelConfig.UpdateStatusHookInterval(), nil }
go
func (e *ModelWatcher) UpdateStatusHookInterval() (time.Duration, error) { // TODO(wallyworld) - lp:1602237 - this needs to have it's own backend implementation. // For now, we'll piggyback off the ModelConfig API. modelConfig, err := e.ModelConfig() if err != nil { return 0, err } return modelConfig.UpdateStatusHookInterval(), nil }
[ "func", "(", "e", "*", "ModelWatcher", ")", "UpdateStatusHookInterval", "(", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "// TODO(wallyworld) - lp:1602237 - this needs to have it's own backend implementation.", "// For now, we'll piggyback off the ModelConfig API."...
// UpdateStatusHookInterval returns the current update status hook interval.
[ "UpdateStatusHookInterval", "returns", "the", "current", "update", "status", "hook", "interval", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/common/modelwatcher.go#L77-L85
155,686
juju/juju
state/addmachine.go
AddMachineInsideNewMachine
func (st *State) AddMachineInsideNewMachine(template, parentTemplate MachineTemplate, containerType instance.ContainerType) (*Machine, error) { mdoc, ops, err := st.addMachineInsideNewMachineOps(template, parentTemplate, containerType) if err != nil { return nil, errors.Annotate(err, "cannot add a new machine") } return st.addMachine(mdoc, ops) }
go
func (st *State) AddMachineInsideNewMachine(template, parentTemplate MachineTemplate, containerType instance.ContainerType) (*Machine, error) { mdoc, ops, err := st.addMachineInsideNewMachineOps(template, parentTemplate, containerType) if err != nil { return nil, errors.Annotate(err, "cannot add a new machine") } return st.addMachine(mdoc, ops) }
[ "func", "(", "st", "*", "State", ")", "AddMachineInsideNewMachine", "(", "template", ",", "parentTemplate", "MachineTemplate", ",", "containerType", "instance", ".", "ContainerType", ")", "(", "*", "Machine", ",", "error", ")", "{", "mdoc", ",", "ops", ",", ...
// AddMachineInsideNewMachine creates a new machine within a container // of the given type inside another new machine. The two given templates // specify the form of the child and parent respectively.
[ "AddMachineInsideNewMachine", "creates", "a", "new", "machine", "within", "a", "container", "of", "the", "given", "type", "inside", "another", "new", "machine", ".", "The", "two", "given", "templates", "specify", "the", "form", "of", "the", "child", "and", "pa...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L114-L120
155,687
juju/juju
state/addmachine.go
AddMachineInsideMachine
func (st *State) AddMachineInsideMachine(template MachineTemplate, parentId string, containerType instance.ContainerType) (*Machine, error) { mdoc, ops, err := st.addMachineInsideMachineOps(template, parentId, containerType) if err != nil { return nil, errors.Annotate(err, "cannot add a new machine") } return st.addMachine(mdoc, ops) }
go
func (st *State) AddMachineInsideMachine(template MachineTemplate, parentId string, containerType instance.ContainerType) (*Machine, error) { mdoc, ops, err := st.addMachineInsideMachineOps(template, parentId, containerType) if err != nil { return nil, errors.Annotate(err, "cannot add a new machine") } return st.addMachine(mdoc, ops) }
[ "func", "(", "st", "*", "State", ")", "AddMachineInsideMachine", "(", "template", "MachineTemplate", ",", "parentId", "string", ",", "containerType", "instance", ".", "ContainerType", ")", "(", "*", "Machine", ",", "error", ")", "{", "mdoc", ",", "ops", ",",...
// AddMachineInsideMachine adds a machine inside a container of the // given type on the existing machine with id=parentId.
[ "AddMachineInsideMachine", "adds", "a", "machine", "inside", "a", "container", "of", "the", "given", "type", "on", "the", "existing", "machine", "with", "id", "=", "parentId", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L124-L130
155,688
juju/juju
state/addmachine.go
AddMachine
func (st *State) AddMachine(series string, jobs ...MachineJob) (*Machine, error) { ms, err := st.AddMachines(MachineTemplate{ Series: series, Jobs: jobs, }) if err != nil { return nil, err } return ms[0], nil }
go
func (st *State) AddMachine(series string, jobs ...MachineJob) (*Machine, error) { ms, err := st.AddMachines(MachineTemplate{ Series: series, Jobs: jobs, }) if err != nil { return nil, err } return ms[0], nil }
[ "func", "(", "st", "*", "State", ")", "AddMachine", "(", "series", "string", ",", "jobs", "...", "MachineJob", ")", "(", "*", "Machine", ",", "error", ")", "{", "ms", ",", "err", ":=", "st", ".", "AddMachines", "(", "MachineTemplate", "{", "Series", ...
// AddMachine adds a machine with the given series and jobs. // It is deprecated and around for testing purposes only.
[ "AddMachine", "adds", "a", "machine", "with", "the", "given", "series", "and", "jobs", ".", "It", "is", "deprecated", "and", "around", "for", "testing", "purposes", "only", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L134-L143
155,689
juju/juju
state/addmachine.go
AddOneMachine
func (st *State) AddOneMachine(template MachineTemplate) (*Machine, error) { ms, err := st.AddMachines(template) if err != nil { return nil, err } return ms[0], nil }
go
func (st *State) AddOneMachine(template MachineTemplate) (*Machine, error) { ms, err := st.AddMachines(template) if err != nil { return nil, err } return ms[0], nil }
[ "func", "(", "st", "*", "State", ")", "AddOneMachine", "(", "template", "MachineTemplate", ")", "(", "*", "Machine", ",", "error", ")", "{", "ms", ",", "err", ":=", "st", ".", "AddMachines", "(", "template", ")", "\n", "if", "err", "!=", "nil", "{", ...
// AddOneMachine machine adds a new machine configured according to the // given template.
[ "AddOneMachine", "machine", "adds", "a", "new", "machine", "configured", "according", "to", "the", "given", "template", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L147-L153
155,690
juju/juju
state/addmachine.go
AddMachines
func (st *State) AddMachines(templates ...MachineTemplate) (_ []*Machine, err error) { defer errors.DeferredAnnotatef(&err, "cannot add a new machine") var ms []*Machine var ops []txn.Op var mdocs []*machineDoc for _, template := range templates { mdoc, addOps, err := st.addMachineOps(template) if err != nil { return nil, errors.Trace(err) } mdocs = append(mdocs, mdoc) ms = append(ms, newMachine(st, mdoc)) ops = append(ops, addOps...) } ssOps, err := st.maintainControllersOps(mdocs, nil) if err != nil { return nil, errors.Trace(err) } ops = append(ops, ssOps...) ops = append(ops, assertModelActiveOp(st.ModelUUID())) if err := st.db().RunTransaction(ops); err != nil { if errors.Cause(err) == txn.ErrAborted { if err := checkModelActive(st); err != nil { return nil, errors.Trace(err) } } return nil, errors.Trace(err) } return ms, nil }
go
func (st *State) AddMachines(templates ...MachineTemplate) (_ []*Machine, err error) { defer errors.DeferredAnnotatef(&err, "cannot add a new machine") var ms []*Machine var ops []txn.Op var mdocs []*machineDoc for _, template := range templates { mdoc, addOps, err := st.addMachineOps(template) if err != nil { return nil, errors.Trace(err) } mdocs = append(mdocs, mdoc) ms = append(ms, newMachine(st, mdoc)) ops = append(ops, addOps...) } ssOps, err := st.maintainControllersOps(mdocs, nil) if err != nil { return nil, errors.Trace(err) } ops = append(ops, ssOps...) ops = append(ops, assertModelActiveOp(st.ModelUUID())) if err := st.db().RunTransaction(ops); err != nil { if errors.Cause(err) == txn.ErrAborted { if err := checkModelActive(st); err != nil { return nil, errors.Trace(err) } } return nil, errors.Trace(err) } return ms, nil }
[ "func", "(", "st", "*", "State", ")", "AddMachines", "(", "templates", "...", "MachineTemplate", ")", "(", "_", "[", "]", "*", "Machine", ",", "err", "error", ")", "{", "defer", "errors", ".", "DeferredAnnotatef", "(", "&", "err", ",", "\"", "\"", ")...
// AddMachines adds new machines configured according to the // given templates.
[ "AddMachines", "adds", "new", "machines", "configured", "according", "to", "the", "given", "templates", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L157-L186
155,691
juju/juju
state/addmachine.go
effectiveMachineTemplate
func (st *State) effectiveMachineTemplate(p MachineTemplate, allowController bool) (tmpl MachineTemplate, err error) { // First check for obvious errors. if p.Series == "" { return tmpl, errors.New("no series specified") } if p.InstanceId != "" { if p.Nonce == "" { return tmpl, errors.New("cannot add a machine with an instance id and no nonce") } } else if p.Nonce != "" { return tmpl, errors.New("cannot specify a nonce without an instance id") } // We ignore all constraints if there's a placement directive. if p.Placement == "" { p.Constraints, err = st.resolveMachineConstraints(p.Constraints) if err != nil { return tmpl, err } } if len(p.Jobs) == 0 { return tmpl, errors.New("no jobs specified") } jset := make(map[MachineJob]bool) for _, j := range p.Jobs { if jset[j] { return MachineTemplate{}, errors.Errorf("duplicate job: %s", j) } jset[j] = true } if jset[JobManageModel] { if !allowController { return tmpl, errControllerNotAllowed } } return p, nil }
go
func (st *State) effectiveMachineTemplate(p MachineTemplate, allowController bool) (tmpl MachineTemplate, err error) { // First check for obvious errors. if p.Series == "" { return tmpl, errors.New("no series specified") } if p.InstanceId != "" { if p.Nonce == "" { return tmpl, errors.New("cannot add a machine with an instance id and no nonce") } } else if p.Nonce != "" { return tmpl, errors.New("cannot specify a nonce without an instance id") } // We ignore all constraints if there's a placement directive. if p.Placement == "" { p.Constraints, err = st.resolveMachineConstraints(p.Constraints) if err != nil { return tmpl, err } } if len(p.Jobs) == 0 { return tmpl, errors.New("no jobs specified") } jset := make(map[MachineJob]bool) for _, j := range p.Jobs { if jset[j] { return MachineTemplate{}, errors.Errorf("duplicate job: %s", j) } jset[j] = true } if jset[JobManageModel] { if !allowController { return tmpl, errControllerNotAllowed } } return p, nil }
[ "func", "(", "st", "*", "State", ")", "effectiveMachineTemplate", "(", "p", "MachineTemplate", ",", "allowController", "bool", ")", "(", "tmpl", "MachineTemplate", ",", "err", "error", ")", "{", "// First check for obvious errors.", "if", "p", ".", "Series", "==...
// effectiveMachineTemplate verifies that the given template is // valid and combines it with values from the state // to produce a resulting template that more accurately // represents the data that will be inserted into the state.
[ "effectiveMachineTemplate", "verifies", "that", "the", "given", "template", "is", "valid", "and", "combines", "it", "with", "values", "from", "the", "state", "to", "produce", "a", "resulting", "template", "that", "more", "accurately", "represents", "the", "data", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L219-L256
155,692
juju/juju
state/addmachine.go
addMachineOps
func (st *State) addMachineOps(template MachineTemplate) (*machineDoc, []txn.Op, error) { template, err := st.effectiveMachineTemplate(template, st.IsController()) if err != nil { return nil, nil, err } if template.InstanceId == "" { volumeAttachments, err := st.machineTemplateVolumeAttachmentParams(template) if err != nil { return nil, nil, err } if err := st.precheckInstance( template.Series, template.Constraints, template.Placement, volumeAttachments, ); err != nil { return nil, nil, err } } seq, err := sequence(st, "machine") if err != nil { return nil, nil, err } mdoc := st.machineDocForTemplate(template, strconv.Itoa(seq)) prereqOps, machineOp, err := st.insertNewMachineOps(mdoc, template) if err != nil { return nil, nil, errors.Trace(err) } prereqOps = append(prereqOps, assertModelActiveOp(st.ModelUUID())) prereqOps = append(prereqOps, insertNewContainerRefOp(st, mdoc.Id)) if template.InstanceId != "" { prereqOps = append(prereqOps, txn.Op{ C: instanceDataC, Id: mdoc.DocID, Assert: txn.DocMissing, Insert: &instanceData{ DocID: mdoc.DocID, MachineId: mdoc.Id, InstanceId: template.InstanceId, ModelUUID: mdoc.ModelUUID, Arch: template.HardwareCharacteristics.Arch, Mem: template.HardwareCharacteristics.Mem, RootDisk: template.HardwareCharacteristics.RootDisk, RootDiskSource: template.HardwareCharacteristics.RootDiskSource, CpuCores: template.HardwareCharacteristics.CpuCores, CpuPower: template.HardwareCharacteristics.CpuPower, Tags: template.HardwareCharacteristics.Tags, AvailZone: template.HardwareCharacteristics.AvailabilityZone, }, }) } return mdoc, append(prereqOps, machineOp), nil }
go
func (st *State) addMachineOps(template MachineTemplate) (*machineDoc, []txn.Op, error) { template, err := st.effectiveMachineTemplate(template, st.IsController()) if err != nil { return nil, nil, err } if template.InstanceId == "" { volumeAttachments, err := st.machineTemplateVolumeAttachmentParams(template) if err != nil { return nil, nil, err } if err := st.precheckInstance( template.Series, template.Constraints, template.Placement, volumeAttachments, ); err != nil { return nil, nil, err } } seq, err := sequence(st, "machine") if err != nil { return nil, nil, err } mdoc := st.machineDocForTemplate(template, strconv.Itoa(seq)) prereqOps, machineOp, err := st.insertNewMachineOps(mdoc, template) if err != nil { return nil, nil, errors.Trace(err) } prereqOps = append(prereqOps, assertModelActiveOp(st.ModelUUID())) prereqOps = append(prereqOps, insertNewContainerRefOp(st, mdoc.Id)) if template.InstanceId != "" { prereqOps = append(prereqOps, txn.Op{ C: instanceDataC, Id: mdoc.DocID, Assert: txn.DocMissing, Insert: &instanceData{ DocID: mdoc.DocID, MachineId: mdoc.Id, InstanceId: template.InstanceId, ModelUUID: mdoc.ModelUUID, Arch: template.HardwareCharacteristics.Arch, Mem: template.HardwareCharacteristics.Mem, RootDisk: template.HardwareCharacteristics.RootDisk, RootDiskSource: template.HardwareCharacteristics.RootDiskSource, CpuCores: template.HardwareCharacteristics.CpuCores, CpuPower: template.HardwareCharacteristics.CpuPower, Tags: template.HardwareCharacteristics.Tags, AvailZone: template.HardwareCharacteristics.AvailabilityZone, }, }) } return mdoc, append(prereqOps, machineOp), nil }
[ "func", "(", "st", "*", "State", ")", "addMachineOps", "(", "template", "MachineTemplate", ")", "(", "*", "machineDoc", ",", "[", "]", "txn", ".", "Op", ",", "error", ")", "{", "template", ",", "err", ":=", "st", ".", "effectiveMachineTemplate", "(", "...
// addMachineOps returns operations to add a new top level machine // based on the given template. It also returns the machine document // that will be inserted.
[ "addMachineOps", "returns", "operations", "to", "add", "a", "new", "top", "level", "machine", "based", "on", "the", "given", "template", ".", "It", "also", "returns", "the", "machine", "document", "that", "will", "be", "inserted", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L261-L314
155,693
juju/juju
state/addmachine.go
supportsContainerType
func (m *Machine) supportsContainerType(ctype instance.ContainerType) bool { supportedContainers, ok := m.SupportedContainers() if !ok { // We don't know yet, so we report that we support the container. return true } for _, ct := range supportedContainers { if ct == ctype { return true } } return false }
go
func (m *Machine) supportsContainerType(ctype instance.ContainerType) bool { supportedContainers, ok := m.SupportedContainers() if !ok { // We don't know yet, so we report that we support the container. return true } for _, ct := range supportedContainers { if ct == ctype { return true } } return false }
[ "func", "(", "m", "*", "Machine", ")", "supportsContainerType", "(", "ctype", "instance", ".", "ContainerType", ")", "bool", "{", "supportedContainers", ",", "ok", ":=", "m", ".", "SupportedContainers", "(", ")", "\n", "if", "!", "ok", "{", "// We don't know...
// supportsContainerType reports whether the machine supports the given // container type. If the machine's supportedContainers attribute is // set, this decision can be made right here, otherwise we assume that // everything will be ok and later on put the container into an error // state if necessary.
[ "supportsContainerType", "reports", "whether", "the", "machine", "supports", "the", "given", "container", "type", ".", "If", "the", "machine", "s", "supportedContainers", "attribute", "is", "set", "this", "decision", "can", "be", "made", "right", "here", "otherwis...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L321-L333
155,694
juju/juju
state/addmachine.go
addMachineInsideMachineOps
func (st *State) addMachineInsideMachineOps(template MachineTemplate, parentId string, containerType instance.ContainerType) (*machineDoc, []txn.Op, error) { if template.InstanceId != "" { return nil, nil, errors.New("cannot specify instance id for a new container") } template, err := st.effectiveMachineTemplate(template, false) if err != nil { return nil, nil, err } if containerType == "" { return nil, nil, errors.New("no container type specified") } // If a parent machine is specified, make sure it exists // and can support the requested container type. parent, err := st.Machine(parentId) if err != nil { return nil, nil, err } if !parent.supportsContainerType(containerType) { return nil, nil, errors.Errorf("machine %s cannot host %s containers", parentId, containerType) } // Ensure that the machine is not locked for series-upgrade. locked, err := parent.IsLockedForSeriesUpgrade() if err != nil { return nil, nil, err } if locked { return nil, nil, errors.Errorf("machine %s is locked for series upgrade", parentId) } newId, err := st.newContainerId(parentId, containerType) if err != nil { return nil, nil, err } mdoc := st.machineDocForTemplate(template, newId) mdoc.ContainerType = string(containerType) prereqOps, machineOp, err := st.insertNewMachineOps(mdoc, template) if err != nil { return nil, nil, errors.Trace(err) } prereqOps = append(prereqOps, // Update containers record for host machine. addChildToContainerRefOp(st, parentId, mdoc.Id), // Create a containers reference document for the container itself. insertNewContainerRefOp(st, mdoc.Id), ) return mdoc, append(prereqOps, machineOp), nil }
go
func (st *State) addMachineInsideMachineOps(template MachineTemplate, parentId string, containerType instance.ContainerType) (*machineDoc, []txn.Op, error) { if template.InstanceId != "" { return nil, nil, errors.New("cannot specify instance id for a new container") } template, err := st.effectiveMachineTemplate(template, false) if err != nil { return nil, nil, err } if containerType == "" { return nil, nil, errors.New("no container type specified") } // If a parent machine is specified, make sure it exists // and can support the requested container type. parent, err := st.Machine(parentId) if err != nil { return nil, nil, err } if !parent.supportsContainerType(containerType) { return nil, nil, errors.Errorf("machine %s cannot host %s containers", parentId, containerType) } // Ensure that the machine is not locked for series-upgrade. locked, err := parent.IsLockedForSeriesUpgrade() if err != nil { return nil, nil, err } if locked { return nil, nil, errors.Errorf("machine %s is locked for series upgrade", parentId) } newId, err := st.newContainerId(parentId, containerType) if err != nil { return nil, nil, err } mdoc := st.machineDocForTemplate(template, newId) mdoc.ContainerType = string(containerType) prereqOps, machineOp, err := st.insertNewMachineOps(mdoc, template) if err != nil { return nil, nil, errors.Trace(err) } prereqOps = append(prereqOps, // Update containers record for host machine. addChildToContainerRefOp(st, parentId, mdoc.Id), // Create a containers reference document for the container itself. insertNewContainerRefOp(st, mdoc.Id), ) return mdoc, append(prereqOps, machineOp), nil }
[ "func", "(", "st", "*", "State", ")", "addMachineInsideMachineOps", "(", "template", "MachineTemplate", ",", "parentId", "string", ",", "containerType", "instance", ".", "ContainerType", ")", "(", "*", "machineDoc", ",", "[", "]", "txn", ".", "Op", ",", "err...
// addMachineInsideMachineOps returns operations to add a machine inside // a container of the given type on an existing machine.
[ "addMachineInsideMachineOps", "returns", "operations", "to", "add", "a", "machine", "inside", "a", "container", "of", "the", "given", "type", "on", "an", "existing", "machine", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L337-L385
155,695
juju/juju
state/addmachine.go
newContainerId
func (st *State) newContainerId(parentId string, containerType instance.ContainerType) (string, error) { seq, err := sequence(st, fmt.Sprintf("machine%s%sContainer", parentId, containerType)) if err != nil { return "", err } return fmt.Sprintf("%s/%s/%d", parentId, containerType, seq), nil }
go
func (st *State) newContainerId(parentId string, containerType instance.ContainerType) (string, error) { seq, err := sequence(st, fmt.Sprintf("machine%s%sContainer", parentId, containerType)) if err != nil { return "", err } return fmt.Sprintf("%s/%s/%d", parentId, containerType, seq), nil }
[ "func", "(", "st", "*", "State", ")", "newContainerId", "(", "parentId", "string", ",", "containerType", "instance", ".", "ContainerType", ")", "(", "string", ",", "error", ")", "{", "seq", ",", "err", ":=", "sequence", "(", "st", ",", "fmt", ".", "Spr...
// newContainerId returns a new id for a machine within the machine // with id parentId and the given container type.
[ "newContainerId", "returns", "a", "new", "id", "for", "a", "machine", "within", "the", "machine", "with", "id", "parentId", "and", "the", "given", "container", "type", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L389-L395
155,696
juju/juju
state/addmachine.go
addMachineInsideNewMachineOps
func (st *State) addMachineInsideNewMachineOps(template, parentTemplate MachineTemplate, containerType instance.ContainerType) (*machineDoc, []txn.Op, error) { if template.InstanceId != "" || parentTemplate.InstanceId != "" { return nil, nil, errors.New("cannot specify instance id for a new container") } seq, err := sequence(st, "machine") if err != nil { return nil, nil, err } parentTemplate, err = st.effectiveMachineTemplate(parentTemplate, false) if err != nil { return nil, nil, err } if containerType == "" { return nil, nil, errors.New("no container type specified") } if parentTemplate.InstanceId == "" { volumeAttachments, err := st.machineTemplateVolumeAttachmentParams(parentTemplate) if err != nil { return nil, nil, err } if err := st.precheckInstance( parentTemplate.Series, parentTemplate.Constraints, parentTemplate.Placement, volumeAttachments, ); err != nil { return nil, nil, err } } parentDoc := st.machineDocForTemplate(parentTemplate, strconv.Itoa(seq)) newId, err := st.newContainerId(parentDoc.Id, containerType) if err != nil { return nil, nil, err } template, err = st.effectiveMachineTemplate(template, false) if err != nil { return nil, nil, err } mdoc := st.machineDocForTemplate(template, newId) mdoc.ContainerType = string(containerType) parentPrereqOps, parentOp, err := st.insertNewMachineOps(parentDoc, parentTemplate) if err != nil { return nil, nil, errors.Trace(err) } prereqOps, machineOp, err := st.insertNewMachineOps(mdoc, template) if err != nil { return nil, nil, errors.Trace(err) } prereqOps = append(prereqOps, parentPrereqOps...) prereqOps = append(prereqOps, // The host machine doesn't exist yet, create a new containers record. insertNewContainerRefOp(st, mdoc.Id), // Create a containers reference document for the container itself. insertNewContainerRefOp(st, parentDoc.Id, mdoc.Id), ) return mdoc, append(prereqOps, parentOp, machineOp), nil }
go
func (st *State) addMachineInsideNewMachineOps(template, parentTemplate MachineTemplate, containerType instance.ContainerType) (*machineDoc, []txn.Op, error) { if template.InstanceId != "" || parentTemplate.InstanceId != "" { return nil, nil, errors.New("cannot specify instance id for a new container") } seq, err := sequence(st, "machine") if err != nil { return nil, nil, err } parentTemplate, err = st.effectiveMachineTemplate(parentTemplate, false) if err != nil { return nil, nil, err } if containerType == "" { return nil, nil, errors.New("no container type specified") } if parentTemplate.InstanceId == "" { volumeAttachments, err := st.machineTemplateVolumeAttachmentParams(parentTemplate) if err != nil { return nil, nil, err } if err := st.precheckInstance( parentTemplate.Series, parentTemplate.Constraints, parentTemplate.Placement, volumeAttachments, ); err != nil { return nil, nil, err } } parentDoc := st.machineDocForTemplate(parentTemplate, strconv.Itoa(seq)) newId, err := st.newContainerId(parentDoc.Id, containerType) if err != nil { return nil, nil, err } template, err = st.effectiveMachineTemplate(template, false) if err != nil { return nil, nil, err } mdoc := st.machineDocForTemplate(template, newId) mdoc.ContainerType = string(containerType) parentPrereqOps, parentOp, err := st.insertNewMachineOps(parentDoc, parentTemplate) if err != nil { return nil, nil, errors.Trace(err) } prereqOps, machineOp, err := st.insertNewMachineOps(mdoc, template) if err != nil { return nil, nil, errors.Trace(err) } prereqOps = append(prereqOps, parentPrereqOps...) prereqOps = append(prereqOps, // The host machine doesn't exist yet, create a new containers record. insertNewContainerRefOp(st, mdoc.Id), // Create a containers reference document for the container itself. insertNewContainerRefOp(st, parentDoc.Id, mdoc.Id), ) return mdoc, append(prereqOps, parentOp, machineOp), nil }
[ "func", "(", "st", "*", "State", ")", "addMachineInsideNewMachineOps", "(", "template", ",", "parentTemplate", "MachineTemplate", ",", "containerType", "instance", ".", "ContainerType", ")", "(", "*", "machineDoc", ",", "[", "]", "txn", ".", "Op", ",", "error"...
// addMachineInsideNewMachineOps returns operations to create a new // machine within a container of the given type inside another // new machine. The two given templates specify the form // of the child and parent respectively.
[ "addMachineInsideNewMachineOps", "returns", "operations", "to", "create", "a", "new", "machine", "within", "a", "container", "of", "the", "given", "type", "inside", "another", "new", "machine", ".", "The", "two", "given", "templates", "specify", "the", "form", "...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L401-L458
155,697
juju/juju
state/addmachine.go
insertNewMachineOps
func (st *State) insertNewMachineOps(mdoc *machineDoc, template MachineTemplate) (prereqOps []txn.Op, machineOp txn.Op, err error) { now := st.clock().Now() machineStatusDoc := statusDoc{ Status: status.Pending, ModelUUID: st.ModelUUID(), Updated: now.UnixNano(), } instanceStatusDoc := statusDoc{ Status: status.Pending, ModelUUID: st.ModelUUID(), Updated: now.UnixNano(), } modificationStatusDoc := statusDoc{ Status: status.Idle, ModelUUID: st.ModelUUID(), Updated: now.UnixNano(), } prereqOps, machineOp = st.baseNewMachineOps( mdoc, machineStatusDoc, instanceStatusDoc, modificationStatusDoc, template.Constraints, ) sb, err := NewStorageBackend(st) if err != nil { return nil, txn.Op{}, errors.Trace(err) } storageOps, volumeAttachments, filesystemAttachments, err := sb.hostStorageOps( mdoc.Id, &storageParams{ filesystems: template.Filesystems, filesystemAttachments: template.FilesystemAttachments, volumes: template.Volumes, volumeAttachments: template.VolumeAttachments, }, ) if err != nil { return nil, txn.Op{}, errors.Trace(err) } for _, a := range volumeAttachments { mdoc.Volumes = append(mdoc.Volumes, a.tag.Id()) } for _, a := range filesystemAttachments { mdoc.Filesystems = append(mdoc.Filesystems, a.tag.Id()) } prereqOps = append(prereqOps, storageOps...) // At the last moment we still have statusDoc in scope, set the initial // history entry. This is risky, and may lead to extra entries, but that's // an intrinsic problem with mixing txn and non-txn ops -- we can't sync // them cleanly. probablyUpdateStatusHistory(st.db(), machineGlobalKey(mdoc.Id), machineStatusDoc) probablyUpdateStatusHistory(st.db(), machineGlobalInstanceKey(mdoc.Id), instanceStatusDoc) probablyUpdateStatusHistory(st.db(), machineGlobalModificationKey(mdoc.Id), modificationStatusDoc) return prereqOps, machineOp, nil }
go
func (st *State) insertNewMachineOps(mdoc *machineDoc, template MachineTemplate) (prereqOps []txn.Op, machineOp txn.Op, err error) { now := st.clock().Now() machineStatusDoc := statusDoc{ Status: status.Pending, ModelUUID: st.ModelUUID(), Updated: now.UnixNano(), } instanceStatusDoc := statusDoc{ Status: status.Pending, ModelUUID: st.ModelUUID(), Updated: now.UnixNano(), } modificationStatusDoc := statusDoc{ Status: status.Idle, ModelUUID: st.ModelUUID(), Updated: now.UnixNano(), } prereqOps, machineOp = st.baseNewMachineOps( mdoc, machineStatusDoc, instanceStatusDoc, modificationStatusDoc, template.Constraints, ) sb, err := NewStorageBackend(st) if err != nil { return nil, txn.Op{}, errors.Trace(err) } storageOps, volumeAttachments, filesystemAttachments, err := sb.hostStorageOps( mdoc.Id, &storageParams{ filesystems: template.Filesystems, filesystemAttachments: template.FilesystemAttachments, volumes: template.Volumes, volumeAttachments: template.VolumeAttachments, }, ) if err != nil { return nil, txn.Op{}, errors.Trace(err) } for _, a := range volumeAttachments { mdoc.Volumes = append(mdoc.Volumes, a.tag.Id()) } for _, a := range filesystemAttachments { mdoc.Filesystems = append(mdoc.Filesystems, a.tag.Id()) } prereqOps = append(prereqOps, storageOps...) // At the last moment we still have statusDoc in scope, set the initial // history entry. This is risky, and may lead to extra entries, but that's // an intrinsic problem with mixing txn and non-txn ops -- we can't sync // them cleanly. probablyUpdateStatusHistory(st.db(), machineGlobalKey(mdoc.Id), machineStatusDoc) probablyUpdateStatusHistory(st.db(), machineGlobalInstanceKey(mdoc.Id), instanceStatusDoc) probablyUpdateStatusHistory(st.db(), machineGlobalModificationKey(mdoc.Id), modificationStatusDoc) return prereqOps, machineOp, nil }
[ "func", "(", "st", "*", "State", ")", "insertNewMachineOps", "(", "mdoc", "*", "machineDoc", ",", "template", "MachineTemplate", ")", "(", "prereqOps", "[", "]", "txn", ".", "Op", ",", "machineOp", "txn", ".", "Op", ",", "err", "error", ")", "{", "now"...
// insertNewMachineOps returns operations to insert the given machine document // into the database, based on the given template. Only the constraints are // taken from the template.
[ "insertNewMachineOps", "returns", "operations", "to", "insert", "the", "given", "machine", "document", "into", "the", "database", "based", "on", "the", "given", "template", ".", "Only", "the", "constraints", "are", "taken", "from", "the", "template", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/addmachine.go#L523-L580
155,698
juju/juju
provider/azure/internal/azurestorage/interface.go
NewClient
func NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion string, useHTTPS bool) (Client, error) { client, err := storage.NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion, useHTTPS) if err != nil { return nil, errors.Trace(err) } return clientWrapper{client}, nil }
go
func NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion string, useHTTPS bool) (Client, error) { client, err := storage.NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion, useHTTPS) if err != nil { return nil, errors.Trace(err) } return clientWrapper{client}, nil }
[ "func", "NewClient", "(", "accountName", ",", "accountKey", ",", "blobServiceBaseURL", ",", "apiVersion", "string", ",", "useHTTPS", "bool", ")", "(", "Client", ",", "error", ")", "{", "client", ",", "err", ":=", "storage", ".", "NewClient", "(", "accountNam...
// NewClient returns a Client that is backed by a storage.Client created with // storage.NewClient
[ "NewClient", "returns", "a", "Client", "that", "is", "backed", "by", "a", "storage", ".", "Client", "created", "with", "storage", ".", "NewClient" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/internal/azurestorage/interface.go#L62-L68
155,699
juju/juju
provider/azure/internal/azurestorage/interface.go
GetContainerReference
func (c *blobStorageClient) GetContainerReference(name string) Container { return container{c.BlobStorageClient.GetContainerReference(name)} }
go
func (c *blobStorageClient) GetContainerReference(name string) Container { return container{c.BlobStorageClient.GetContainerReference(name)} }
[ "func", "(", "c", "*", "blobStorageClient", ")", "GetContainerReference", "(", "name", "string", ")", "Container", "{", "return", "container", "{", "c", ".", "BlobStorageClient", ".", "GetContainerReference", "(", "name", ")", "}", "\n", "}" ]
// GetContainerReference is part of the BlobStorageClient interface.
[ "GetContainerReference", "is", "part", "of", "the", "BlobStorageClient", "interface", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/internal/azurestorage/interface.go#L84-L86