MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / getClusterUUID

Method getClusterUUID

rest/server_context.go:2310–2336  ·  view source on GitHub ↗

getClusterUUID returns the cluster UUID. rosmar does not have a ClusterUUID, so this will return an empty cluster UUID and no error in this case.

(ctx context.Context)

Source from the content-addressed store, hash-verified

2308
2309// getClusterUUID returns the cluster UUID. rosmar does not have a ClusterUUID, so this will return an empty cluster UUID and no error in this case.
2310func (sc *ServerContext) getClusterUUID(ctx context.Context) (string, error) {
2311 allDbNames := sc.AllDatabaseNames()
2312 // we can use db context to retrieve clusterUUID
2313 if len(allDbNames) > 0 {
2314 db, err := sc.GetDatabase(ctx, allDbNames[0])
2315 if err == nil {
2316 return db.ServerUUID, nil
2317 }
2318 }
2319 // no cluster uuid for rosmar cluster
2320 if base.ServerIsWalrus(sc.Config.Bootstrap.Server) {
2321 return "", nil
2322 }
2323 // request server for cluster uuid
2324 eps, client, err := sc.ObtainManagementEndpointsAndHTTPClient()
2325 if err != nil {
2326 return "", err
2327 }
2328 statusCode, output, err := doHTTPAuthRequest(ctx, client, sc.Config.Bootstrap.Username, sc.Config.Bootstrap.Password, http.MethodGet, "/pools", eps, nil)
2329 if err != nil {
2330 return "", err
2331 }
2332 if statusCode != http.StatusOK {
2333 return "", fmt.Errorf("unable to get cluster UUID from server: %s", output)
2334 }
2335 return base.ParseClusterUUID(output)
2336}
2337
2338func (sc *ServerContext) getBucketCCVSettings() map[string]bool {
2339 bucketCCVSettings := make(map[string]bool)

Callers 1

handleGetConfigMethod · 0.80

Calls 7

AllDatabaseNamesMethod · 0.95
GetDatabaseMethod · 0.95
ServerIsWalrusFunction · 0.92
ParseClusterUUIDFunction · 0.92
doHTTPAuthRequestFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected