// NewCouchbaseDatasource creates a new datasource instance.
NewCouchbaseDatasource creates a new datasource instance.
// NewCouchbaseDatasource creates a new datasource instance .
func NewCouchbaseDatasource(instance backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
  var settings map[string]string
  if e := json.Unmarshal(instance.JSONData, &settings); e != nil {
    return &backend.CheckHealthResult{
      Status: backend.HealthStatusError,
      Message: "failed to parse settings",
    }, e
  }
  password := instance.DecryptedSecureJSONData["password"]
  if cluster, err := gocb.Connect(
    settings["host"],
    gocb.ClusterOptions{
      Authenticator: gocb.PasswordAuthenticator{
        Username: settings["username"],
        Password: password,
      },
    },
  ); err != nil {
    log.DefaultLogger.Error("Failed to connect to cluster", err)
    return nil, err
  } else {
    return &CouchbaseDatasource{
      *cluster,
      instance,
    }, nil
  }
}
func NewCouchbaseDatasource ( instance backend . DataSourceInstanceSettings ) ( instancemgmt . Instance , error ) { var settings map [ string ] string if e := json . Unmarshal ( instance . JSONData , & settings ) ; e != nil { return & backend . CheckHealthResult { Status : backend . HealthStatusError , Message : " " , } , e } password := instance . DecryptedSecureJSONData [ " " ] if cluster , err := gocb . Connect ( settings [ " " ] , gocb . ClusterOptions { Authenticator : gocb . PasswordAuthenticator { Username : settings [ " " ] , Password : password , } , } , ) ; err != nil { log . DefaultLogger . Error ( " " , err ) return nil , err } else { return & CouchbaseDatasource { * cluster , instance , } , nil } }
NewCouchbaseDatasource creates a new datasource instance.
NewCouchbaseDatasource creates a new datasource instance .