Skip to content

Commit

Permalink
formatted code
Browse files Browse the repository at this point in the history
Signed-off-by: 26tanishabanik <[email protected]>
  • Loading branch information
26tanishabanik committed Nov 1, 2022
1 parent e797936 commit f585b8d
Show file tree
Hide file tree
Showing 4 changed files with 493 additions and 114 deletions.
9 changes: 4 additions & 5 deletions pkg/scalers/couchdb_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ package scalers

import (
"context"
"fmt"
"strconv"
"encoding/json"
"fmt"
couchdb "github.com/go-kivik/couchdb/v3"
"github.com/go-kivik/kivik/v3"
"github.com/go-logr/logr"
v2 "k8s.io/api/autoscaling/v2"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/metrics/pkg/apis/external_metrics"

"strconv"
kedautil "github.com/kedacore/keda/v2/pkg/util"
// kedascaler "couchbase/keda/pkg/scalers"
)
Expand Down Expand Up @@ -71,7 +70,7 @@ func (s couchDBScaler) Close(ctx context.Context) error {
func (s *couchDBScaler) getQueryResult(ctx context.Context) (int64, error) {
db := s.client.DB(ctx, s.metadata.dbName)
var request couchDBQueryRequest
err := json.Unmarshal([]byte (s.metadata.query),&request)
err := json.Unmarshal([]byte(s.metadata.query), &request)
if err != nil {
fmt.Println("Couldn't unmarshal query string: ", err)
s.logger.Error(err, fmt.Sprintf("Couldn't unmarshal query string because of %v", err))
Expand All @@ -83,7 +82,7 @@ func (s *couchDBScaler) getQueryResult(ctx context.Context) (int64, error) {
s.logger.Error(err, fmt.Sprintf("failed to fetch rows because of %v", err))
return 0, err
}
var count int64 = 0
var count int64
for rows.Next() {
count++
res := Res{}
Expand Down
6 changes: 3 additions & 3 deletions pkg/scalers/couchdb_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package scalers

import (
"context"
"testing"
_ "github.com/go-kivik/couchdb/v3"
"github.com/go-kivik/kivik/v3"
"github.com/go-logr/logr"
"testing"
)

var testCouchDBResolvedEnv = map[string]string{
Expand Down Expand Up @@ -44,7 +44,7 @@ var testCOUCHDBMetadata = []parseCouchDBMetadataTestData{
},
// with metric name
{
metadata: map[string]string{"query": `{ "selector": { "feet": { "$gt": 0 } }, "fields": ["_id", "feet", "greeting"] }`, "queryValue": "1", "connectionStringFromEnv": "CouchDB_CONN_STR", "dbName": "animals"},
metadata: map[string]string{"query": `{ "selector": { "feet": { "$gt": 0 } }, "fields": ["_id", "feet", "greeting"] }`, "queryValue": "1", "connectionStringFromEnv": "CouchDB_CONN_STR", "dbName": "animals"},
authParams: map[string]string{},
resolvedEnv: testCouchDBResolvedEnv,
raisesError: false,
Expand Down Expand Up @@ -95,4 +95,4 @@ func TestCouchDBGetMetricSpecForScaling(t *testing.T) {
t.Error("Wrong External metric source name:", metricName)
}
}
}
}
Loading

0 comments on commit f585b8d

Please sign in to comment.