From e133eb175232f1346ecd5a1318ff13eceeb45cee Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Sun, 19 Nov 2023 21:55:06 +0100 Subject: [PATCH 1/4] Import proxydb --- x/proxydb/.gitignore | 1 + x/proxydb/.gitlab-ci.yml | 45 ++++++++ x/proxydb/.golangci.toml | 20 ++++ x/proxydb/LICENSE.md | 13 +++ x/proxydb/README.md | 11 ++ x/proxydb/go.mod | 7 ++ x/proxydb/go.sum | 14 +++ x/proxydb/proxy.go | 215 +++++++++++++++++++++++++++++++++++ x/proxydb/rows.go | 70 ++++++++++++ x/proxydb/script/coverage.sh | 39 +++++++ 10 files changed, 435 insertions(+) create mode 100644 x/proxydb/.gitignore create mode 100644 x/proxydb/.gitlab-ci.yml create mode 100644 x/proxydb/.golangci.toml create mode 100644 x/proxydb/LICENSE.md create mode 100644 x/proxydb/README.md create mode 100644 x/proxydb/go.mod create mode 100644 x/proxydb/go.sum create mode 100644 x/proxydb/proxy.go create mode 100644 x/proxydb/rows.go create mode 100755 x/proxydb/script/coverage.sh diff --git a/x/proxydb/.gitignore b/x/proxydb/.gitignore new file mode 100644 index 000000000..48b8bf907 --- /dev/null +++ b/x/proxydb/.gitignore @@ -0,0 +1 @@ +vendor/ diff --git a/x/proxydb/.gitlab-ci.yml b/x/proxydb/.gitlab-ci.yml new file mode 100644 index 000000000..ab0c11bb8 --- /dev/null +++ b/x/proxydb/.gitlab-ci.yml @@ -0,0 +1,45 @@ +stages: + - test + +variables: + GO111MODULE: "on" + +.test: &test_template + stage: test + script: + - go mod download + - go test -race -tags=livetest ./... + +lint: + stage: test + image: golangci/golangci-lint:v1.55.2 + script: + - go mod download + - golangci-lint run ./... + +coverage: + stage: test + image: golang:1.21 + script: + - go mod download + - ./script/coverage.sh + +go-1.17: + <<: *test_template + image: golang:1.17 + +go-1.18: + <<: *test_template + image: golang:1.18 + +go-1.19: + <<: *test_template + image: golang:1.19 + +go-1.20: + <<: *test_template + image: golang:1.20 + +go-1.21: + <<: *test_template + image: golang:1.21 diff --git a/x/proxydb/.golangci.toml b/x/proxydb/.golangci.toml new file mode 100644 index 000000000..31b932a34 --- /dev/null +++ b/x/proxydb/.golangci.toml @@ -0,0 +1,20 @@ +[output] +format = "colored-line-number" + +[linters] +enable = [ + "gocyclo", + "unconvert", + "goimports", + "unused", + "vetshadow", + "misspell", + "nakedret", + "errcheck", + "revive", + "ineffassign", + "goconst", + "vet", + "unparam", + "gofumpt", +] diff --git a/x/proxydb/LICENSE.md b/x/proxydb/LICENSE.md new file mode 100644 index 000000000..0a2865e54 --- /dev/null +++ b/x/proxydb/LICENSE.md @@ -0,0 +1,13 @@ +Copyright (c) 2017 Jonathan Hall + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/x/proxydb/README.md b/x/proxydb/README.md new file mode 100644 index 000000000..1d97b5ce2 --- /dev/null +++ b/x/proxydb/README.md @@ -0,0 +1,11 @@ +[![Build Status](https://travis-ci.org/go-kivik/proxydb.svg?branch=master)](https://travis-ci.org/go-kivik/proxydb) [![Codecov](https://img.shields.io/codecov/c/github/go-kivik/proxydb.svg?style=flat)](https://codecov.io/gh/go-kivik/proxydb) [![Go Report Card](https://goreportcard.com/badge/github.com/go-kivik/proxydb)](https://goreportcard.com/report/github.com/go-kivik/proxydb) [![GoDoc](https://godoc.org/github.com/go-kivik/proxydb?status.svg)](http://godoc.org/github.com/go-kivik/proxydb) + +# Kivik Proxydb + +Package proxydb provides a proxy Kivik driver. It is used primarily by the +[kivikd](https://github.com/go-kivik/kivikd) server. + +## What license is Kivik released under? + +This software is released under the terms of the Apache 2.0 license. See +LICENCE.md, or read the [full license](http://www.apache.org/licenses/LICENSE-2.0). diff --git a/x/proxydb/go.mod b/x/proxydb/go.mod new file mode 100644 index 000000000..b44127d46 --- /dev/null +++ b/x/proxydb/go.mod @@ -0,0 +1,7 @@ +module github.com/go-kivik/proxydb/v4 + +go 1.17 + +require github.com/go-kivik/kivik/v4 v4.0.1 + +require golang.org/x/sync v0.4.0 // indirect diff --git a/x/proxydb/go.sum b/x/proxydb/go.sum new file mode 100644 index 000000000..fd0097a26 --- /dev/null +++ b/x/proxydb/go.sum @@ -0,0 +1,14 @@ +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/go-kivik/kivik/v4 v4.0.1 h1:gyUc9sNTdi3ZZBAbbrx9MrJTZZ/q7t+N50lblnULJ5c= +github.com/go-kivik/kivik/v4 v4.0.1/go.mod h1:QRXiwfpHOV/+hnM3bpiIrE2zxa8nvX1SS/N3TCkEkf0= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/icza/dyno v0.0.0-20230330125955-09f820a8d9c0 h1:nHoRIX8iXob3Y2kdt9KsjyIb7iApSvb3vgsd93xb5Ow= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +gitlab.com/flimzy/testy v0.13.0 h1:6I9TEzU9OCkN0qUVLPbREBXaj0b8/TKfU+FkfUHfapg= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= +golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/x/proxydb/proxy.go b/x/proxydb/proxy.go new file mode 100644 index 000000000..8e12e48c4 --- /dev/null +++ b/x/proxydb/proxy.go @@ -0,0 +1,215 @@ +package proxydb + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "io" + "net/http" + + "github.com/go-kivik/kivik/v4" + "github.com/go-kivik/kivik/v4/driver" +) + +type statusError struct { + error + status int +} + +func (e statusError) Unwrap() error { return e.error } +func (e statusError) HTTPStatus() int { return e.status } + +var notYetImplemented = statusError{status: http.StatusNotImplemented, error: errors.New("kivik: not yet implemented in proxy driver")} + +// CompleteClient is a composite of all compulsory and optional driver.* client +// interfaces. +type CompleteClient interface { + driver.Client +} + +// NewClient wraps an existing *kivik.Client connection, allowing it to be used +// as a driver.Client +func NewClient(c *kivik.Client) driver.Client { + return &client{c} +} + +type client struct { + *kivik.Client +} + +var _ CompleteClient = &client{} + +func (c *client) AllDBs(ctx context.Context, options driver.Options) ([]string, error) { + return c.Client.AllDBs(ctx, options) +} + +func (c *client) CreateDB(ctx context.Context, dbname string, options driver.Options) error { + return c.Client.CreateDB(ctx, dbname, options) +} + +func (c *client) DBExists(ctx context.Context, dbname string, options driver.Options) (bool, error) { + return c.Client.DBExists(ctx, dbname, options) +} + +func (c *client) DestroyDB(ctx context.Context, dbname string, options driver.Options) error { + return c.Client.DestroyDB(ctx, dbname, options) +} + +func (c *client) Version(ctx context.Context) (*driver.Version, error) { + ver, err := c.Client.Version(ctx) + if err != nil { + return nil, err + } + return &driver.Version{ + Version: ver.Version, + Vendor: ver.Vendor, + RawResponse: ver.RawResponse, + }, nil +} + +func (c *client) DB(name string, options driver.Options) (driver.DB, error) { + d := c.Client.DB(name, options) + return &db{d}, nil +} + +type db struct { + *kivik.DB +} + +var _ driver.DB = &db{} + +func (d *db) AllDocs(ctx context.Context, opts driver.Options) (driver.Rows, error) { + kivikRows := d.DB.AllDocs(ctx, opts) + return &rows{kivikRows}, kivikRows.Err() +} + +func (d *db) Query(ctx context.Context, ddoc, view string, opts driver.Options) (driver.Rows, error) { + kivikRows := d.DB.Query(ctx, ddoc, view, opts) + return &rows{kivikRows}, kivikRows.Err() +} + +type atts struct { + *kivik.AttachmentsIterator +} + +var _ driver.Attachments = &atts{} + +func (a *atts) Close() error { return nil } +func (a *atts) Next(att *driver.Attachment) error { + next, err := a.AttachmentsIterator.Next() + if err != nil { + return err + } + *att = driver.Attachment(*next) + return nil +} + +func (d *db) Get(ctx context.Context, id string, opts driver.Options) (*driver.Document, error) { + row := d.DB.Get(ctx, id, opts) + rev, err := row.Rev() + if err != nil { + return nil, err + } + var doc json.RawMessage + if err := row.ScanDoc(&doc); err != nil { + return nil, err + } + attIter, err := row.Attachments() + if err != nil && kivik.HTTPStatus(err) != http.StatusNotFound { + return nil, err + } + + var attachments *atts + if attIter != nil { + attachments = &atts{attIter} + } + + return &driver.Document{ + Rev: rev, + Body: io.NopCloser(bytes.NewReader(doc)), + Attachments: attachments, + }, nil +} + +func (d *db) Stats(ctx context.Context) (*driver.DBStats, error) { + i, err := d.DB.Stats(ctx) + if err != nil { + return nil, err + } + var cluster *driver.ClusterStats + if i.Cluster != nil { + c := driver.ClusterStats(*i.Cluster) + cluster = &c + } + return &driver.DBStats{ + Name: i.Name, + CompactRunning: i.CompactRunning, + DocCount: i.DocCount, + DeletedCount: i.DeletedCount, + UpdateSeq: i.UpdateSeq, + DiskSize: i.DiskSize, + ActiveSize: i.ActiveSize, + ExternalSize: i.ExternalSize, + Cluster: cluster, + RawResponse: i.RawResponse, + }, nil +} + +func (d *db) Security(ctx context.Context) (*driver.Security, error) { + s, err := d.DB.Security(ctx) + if err != nil { + return nil, err + } + sec := driver.Security{ + Admins: driver.Members(s.Admins), + Members: driver.Members(s.Members), + } + return &sec, err +} + +func (d *db) SetSecurity(ctx context.Context, security *driver.Security) error { + sec := &kivik.Security{ + Admins: kivik.Members(security.Admins), + Members: kivik.Members(security.Members), + } + return d.DB.SetSecurity(ctx, sec) +} + +func (d *db) Changes(context.Context, driver.Options) (driver.Changes, error) { + return nil, notYetImplemented +} + +func (d *db) BulkDocs(_ context.Context, _ []interface{}) ([]driver.BulkResult, error) { + // FIXME: Unimplemented + return nil, notYetImplemented +} + +func (d *db) PutAttachment(_ context.Context, _ string, _ *driver.Attachment, _ driver.Options) (string, error) { + panic("PutAttachment should never be called") +} + +func (d *db) GetAttachment(_ context.Context, _, _ string, _ driver.Options) (*driver.Attachment, error) { + panic("GetAttachment should never be called") +} + +func (d *db) GetAttachmentMeta(_ context.Context, _, _, _ string, _ driver.Options) (*driver.Attachment, error) { + // FIXME: Unimplemented + return nil, notYetImplemented +} + +func (d *db) CreateDoc(_ context.Context, _ interface{}, _ driver.Options) (string, string, error) { + panic("CreateDoc should never be called") +} + +func (d *db) Delete(_ context.Context, _ string, _ driver.Options) (string, error) { + panic("Delete should never be called") +} + +func (d *db) DeleteAttachment(_ context.Context, _, _ string, _ driver.Options) (string, error) { + panic("DeleteAttachment should never be called") +} + +func (d *db) Put(_ context.Context, _ string, _ interface{}, _ driver.Options) (string, error) { + panic("Put should never be called") +} diff --git a/x/proxydb/rows.go b/x/proxydb/rows.go new file mode 100644 index 000000000..77b11d459 --- /dev/null +++ b/x/proxydb/rows.go @@ -0,0 +1,70 @@ +package proxydb + +import ( + "bytes" + "encoding/json" + + "github.com/go-kivik/kivik/v4" + "github.com/go-kivik/kivik/v4/driver" +) + +type rows struct { + *kivik.ResultSet +} + +var _ driver.Rows = &rows{} + +func (r *rows) Next(row *driver.Row) error { + if !r.ResultSet.Next() { + return r.ResultSet.Err() + } + var value json.RawMessage + if err := r.ResultSet.ScanValue(&value); err != nil { + return err + } + var doc json.RawMessage + if err := r.ResultSet.ScanDoc(&doc); err != nil { + return err + } + var err error + row.ID, err = r.ResultSet.ID() + if err != nil { + return err + } + key, err := r.ResultSet.Key() + if err != nil { + return err + } + row.Key = json.RawMessage(key) + row.Value = bytes.NewReader(value) + row.Doc = bytes.NewReader(doc) + return nil +} + +func (r *rows) Close() error { + return r.ResultSet.Close() +} + +func (r *rows) Offset() int64 { + md, err := r.ResultSet.Metadata() + if err != nil { + return 0 + } + return md.Offset +} + +func (r *rows) TotalRows() int64 { + md, err := r.ResultSet.Metadata() + if err != nil { + return 0 + } + return md.TotalRows +} + +func (r *rows) UpdateSeq() string { + md, err := r.ResultSet.Metadata() + if err != nil { + return "" + } + return md.UpdateSeq +} diff --git a/x/proxydb/script/coverage.sh b/x/proxydb/script/coverage.sh new file mode 100755 index 000000000..74804d18b --- /dev/null +++ b/x/proxydb/script/coverage.sh @@ -0,0 +1,39 @@ +#!/bin/bash -euC + +pkgname=github.com/${CI_PROJECT_PATH} + +# Find all packages that depend on this package. We can pass this to -coverpkg +# so that lines in these packages are counted as well. +find_deps() { + ( + echo "$1" + go list -f $'{{range $f := .Deps}}{{$f}}\n{{end}}' "$1" + go list -f $'{{range $f := .TestImports}}{{$f}}\n{{end}}' "$1" | + while read imp; do + go list -f $'{{range $f := .Deps}}{{$f}}\n{{end}}' "$imp"; + done + ) | sort -u | grep ^$pkgname | grep -Ev "^$pkgname/(vendor|test)" | + tr '\n' ' ' | sed 's/ $//' | tr ' ' ',' +} + +echo "" > coverage.txt + +TEST_PKGS=$(go list ./... | grep -v /test) + +# Cache +go test -i -cover -covermode=set $(go list ./...) + +for pkg in $TEST_PKGS; do + go test \ + -coverprofile=profile.out \ + -covermode=set \ + -coverpkg=$(find_deps "$pkg") \ + "$pkg" | grep -v "warning: no packages being tested depend on " + + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi +done + +curl -fs https://codecov.io/bash | bash -s -- -Z From 28a768bd00a5a16f16a562345b0a055f321ec999 Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Sun, 19 Nov 2023 21:56:03 +0100 Subject: [PATCH 2/4] Remove redundant files --- x/proxydb/.gitignore | 1 - x/proxydb/.gitlab-ci.yml | 45 ------------------------------------ x/proxydb/.golangci.toml | 20 ---------------- x/proxydb/LICENSE.md | 13 ----------- x/proxydb/go.mod | 7 ------ x/proxydb/go.sum | 14 ----------- x/proxydb/script/coverage.sh | 39 ------------------------------- 7 files changed, 139 deletions(-) delete mode 100644 x/proxydb/.gitignore delete mode 100644 x/proxydb/.gitlab-ci.yml delete mode 100644 x/proxydb/.golangci.toml delete mode 100644 x/proxydb/LICENSE.md delete mode 100644 x/proxydb/go.mod delete mode 100644 x/proxydb/go.sum delete mode 100755 x/proxydb/script/coverage.sh diff --git a/x/proxydb/.gitignore b/x/proxydb/.gitignore deleted file mode 100644 index 48b8bf907..000000000 --- a/x/proxydb/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendor/ diff --git a/x/proxydb/.gitlab-ci.yml b/x/proxydb/.gitlab-ci.yml deleted file mode 100644 index ab0c11bb8..000000000 --- a/x/proxydb/.gitlab-ci.yml +++ /dev/null @@ -1,45 +0,0 @@ -stages: - - test - -variables: - GO111MODULE: "on" - -.test: &test_template - stage: test - script: - - go mod download - - go test -race -tags=livetest ./... - -lint: - stage: test - image: golangci/golangci-lint:v1.55.2 - script: - - go mod download - - golangci-lint run ./... - -coverage: - stage: test - image: golang:1.21 - script: - - go mod download - - ./script/coverage.sh - -go-1.17: - <<: *test_template - image: golang:1.17 - -go-1.18: - <<: *test_template - image: golang:1.18 - -go-1.19: - <<: *test_template - image: golang:1.19 - -go-1.20: - <<: *test_template - image: golang:1.20 - -go-1.21: - <<: *test_template - image: golang:1.21 diff --git a/x/proxydb/.golangci.toml b/x/proxydb/.golangci.toml deleted file mode 100644 index 31b932a34..000000000 --- a/x/proxydb/.golangci.toml +++ /dev/null @@ -1,20 +0,0 @@ -[output] -format = "colored-line-number" - -[linters] -enable = [ - "gocyclo", - "unconvert", - "goimports", - "unused", - "vetshadow", - "misspell", - "nakedret", - "errcheck", - "revive", - "ineffassign", - "goconst", - "vet", - "unparam", - "gofumpt", -] diff --git a/x/proxydb/LICENSE.md b/x/proxydb/LICENSE.md deleted file mode 100644 index 0a2865e54..000000000 --- a/x/proxydb/LICENSE.md +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2017 Jonathan Hall - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/x/proxydb/go.mod b/x/proxydb/go.mod deleted file mode 100644 index b44127d46..000000000 --- a/x/proxydb/go.mod +++ /dev/null @@ -1,7 +0,0 @@ -module github.com/go-kivik/proxydb/v4 - -go 1.17 - -require github.com/go-kivik/kivik/v4 v4.0.1 - -require golang.org/x/sync v0.4.0 // indirect diff --git a/x/proxydb/go.sum b/x/proxydb/go.sum deleted file mode 100644 index fd0097a26..000000000 --- a/x/proxydb/go.sum +++ /dev/null @@ -1,14 +0,0 @@ -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= -github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/go-kivik/kivik/v4 v4.0.1 h1:gyUc9sNTdi3ZZBAbbrx9MrJTZZ/q7t+N50lblnULJ5c= -github.com/go-kivik/kivik/v4 v4.0.1/go.mod h1:QRXiwfpHOV/+hnM3bpiIrE2zxa8nvX1SS/N3TCkEkf0= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/icza/dyno v0.0.0-20230330125955-09f820a8d9c0 h1:nHoRIX8iXob3Y2kdt9KsjyIb7iApSvb3vgsd93xb5Ow= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -gitlab.com/flimzy/testy v0.13.0 h1:6I9TEzU9OCkN0qUVLPbREBXaj0b8/TKfU+FkfUHfapg= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/x/proxydb/script/coverage.sh b/x/proxydb/script/coverage.sh deleted file mode 100755 index 74804d18b..000000000 --- a/x/proxydb/script/coverage.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -euC - -pkgname=github.com/${CI_PROJECT_PATH} - -# Find all packages that depend on this package. We can pass this to -coverpkg -# so that lines in these packages are counted as well. -find_deps() { - ( - echo "$1" - go list -f $'{{range $f := .Deps}}{{$f}}\n{{end}}' "$1" - go list -f $'{{range $f := .TestImports}}{{$f}}\n{{end}}' "$1" | - while read imp; do - go list -f $'{{range $f := .Deps}}{{$f}}\n{{end}}' "$imp"; - done - ) | sort -u | grep ^$pkgname | grep -Ev "^$pkgname/(vendor|test)" | - tr '\n' ' ' | sed 's/ $//' | tr ' ' ',' -} - -echo "" > coverage.txt - -TEST_PKGS=$(go list ./... | grep -v /test) - -# Cache -go test -i -cover -covermode=set $(go list ./...) - -for pkg in $TEST_PKGS; do - go test \ - -coverprofile=profile.out \ - -covermode=set \ - -coverpkg=$(find_deps "$pkg") \ - "$pkg" | grep -v "warning: no packages being tested depend on " - - if [ -f profile.out ]; then - cat profile.out >> coverage.txt - rm profile.out - fi -done - -curl -fs https://codecov.io/bash | bash -s -- -Z From 0cfb5e38f7123367930a9995db85fac2ce1e08a4 Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Sun, 19 Nov 2023 21:58:14 +0100 Subject: [PATCH 3/4] Update README --- x/proxydb/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/proxydb/README.md b/x/proxydb/README.md index 1d97b5ce2..cffba4c27 100644 --- a/x/proxydb/README.md +++ b/x/proxydb/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/go-kivik/proxydb.svg?branch=master)](https://travis-ci.org/go-kivik/proxydb) [![Codecov](https://img.shields.io/codecov/c/github/go-kivik/proxydb.svg?style=flat)](https://codecov.io/gh/go-kivik/proxydb) [![Go Report Card](https://goreportcard.com/badge/github.com/go-kivik/proxydb)](https://goreportcard.com/report/github.com/go-kivik/proxydb) [![GoDoc](https://godoc.org/github.com/go-kivik/proxydb?status.svg)](http://godoc.org/github.com/go-kivik/proxydb) +[![GoDoc](https://godoc.org/github.com/go-kivik/kivik/v4/x/proxydb?status.svg)](http://godoc.org/github.com/go-kivik/kivik/v4/x/proxydb) # Kivik Proxydb From e7bea2407b60c4e0229d8a09dc93476eb420ea11 Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Sun, 19 Nov 2023 22:00:37 +0100 Subject: [PATCH 4/4] Fix lint --- x/proxydb/doc.go | 14 ++++++++++++++ x/proxydb/proxy.go | 12 ++++++++++++ x/proxydb/rows.go | 12 ++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 x/proxydb/doc.go diff --git a/x/proxydb/doc.go b/x/proxydb/doc.go new file mode 100644 index 000000000..294eed9ed --- /dev/null +++ b/x/proxydb/doc.go @@ -0,0 +1,14 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + +// Package proxydb allows using an arbitrary Kivik client as a Kivik driver. +package proxydb diff --git a/x/proxydb/proxy.go b/x/proxydb/proxy.go index 8e12e48c4..1e2f0cf8c 100644 --- a/x/proxydb/proxy.go +++ b/x/proxydb/proxy.go @@ -1,3 +1,15 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + package proxydb import ( diff --git a/x/proxydb/rows.go b/x/proxydb/rows.go index 77b11d459..04c99823d 100644 --- a/x/proxydb/rows.go +++ b/x/proxydb/rows.go @@ -1,3 +1,15 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. + package proxydb import (