Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,25 @@ require (
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/minio/crc64nvme v1.0.2 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/tinylib/msgp v1.3.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect
golang.org/x/mod v0.27.0 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/tools v0.35.0 // indirect
golang.org/x/tools/go/expect v0.1.1-deprecated // indirect
Expand All @@ -61,8 +72,9 @@ require (
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/minio/minio-go/v7 v7.0.95
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/text v0.26.0 // indirect
golang.org/x/text v0.27.0 // indirect
)
29 changes: 29 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/google/addlicense v1.2.0 h1:W+DP4A639JGkcwBGMDvjSurZHvaq2FN0pP7se9czsKA=
Expand All @@ -76,10 +82,23 @@ github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU=
github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/minio/crc64nvme v1.0.2 h1:6uO1UxGAD+kwqWWp7mBFsi5gAse66C4NXO8cmcVculg=
github.com/minio/crc64nvme v1.0.2/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.95 h1:ywOUPg+PebTMTzn9VDsoFJy32ZuARN9zhB+K3IYEvYU=
github.com/minio/minio-go/v7 v7.0.95/go.mod h1:wOOX3uxS334vImCNRVyIDdXX9OsXDm89ToynKgqUKlo=
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand All @@ -90,18 +109,24 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tinylib/msgp v1.3.0 h1:ULuf7GPooDaIlbyvgAxBV/FI7ynli6LZ1/nVUNu+0ww=
github.com/tinylib/msgp v1.3.0/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/lint v0.0.0-20241112194109-818c5a804067 h1:adDmSQyFTCiv19j015EGKJBoaa7ElV0Q1Wovb/4G7NA=
Expand All @@ -115,6 +140,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -129,6 +156,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
Expand Down
18 changes: 9 additions & 9 deletions internal/store/s3.go → internal/blob/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package store
package blob

import (
"context"
Expand Down Expand Up @@ -60,7 +60,7 @@ const (
DefaultRegion = "aws-global"
)

// ValidParams lists the valid parameters for the S3 store.
// ValidParams lists the valid parameters for the S3 object storage.
var ValidParams = []string{
AccountParam, SecretParam, TokenParam, EndPointParam,
RegionParam, UsePathStyleParam, SkipChecksum, SkipTLSVerify,
Expand All @@ -86,7 +86,7 @@ type s3Store struct {
// S3FromEnv creates a new S3 store from the environment.
// It will try to connect to the S3 service using the environment variables provided,
// and adding any parameters that are required.
func S3FromEnv(ctx *stopper.Context, env *env.Env) (Store, error) {
func S3FromEnv(ctx *stopper.Context, env *env.Env) (Storage, error) {
creds, ok := lookupEnv(env, []string{AccountParam, SecretParam}, []string{TokenParam, RegionParam})
if !ok {
return nil, ErrMissingParam
Expand All @@ -105,7 +105,7 @@ func S3FromEnv(ctx *stopper.Context, env *env.Env) (Store, error) {
return initial.try(ctx, initial.BucketName())
}

// BucketName implements Store.
// BucketName implements BlobStorage.
func (s *s3Store) BucketName() string {
cleanedPath := path.Clean(s.dest)
components := strings.Split(cleanedPath, "/")
Expand All @@ -115,7 +115,7 @@ func (s *s3Store) BucketName() string {
return components[0]
}

// Params implements Store.
// Params implements BlobStorage.
func (s *s3Store) Params() Params {
params := maps.Clone(s.params)
for param := range params {
Expand All @@ -126,7 +126,7 @@ func (s *s3Store) Params() Params {
return params
}

// URL implements Store.
// URL implements BlobStorage.
func (s *s3Store) URL() string {
res := s.escapeValues()
res = fmt.Sprintf("s3://%s?%s", s.dest, res)
Expand All @@ -144,8 +144,8 @@ func (s *s3Store) addParam(key string, value string) error {

// candidateConfigs provides a set of candidate configurations for the S3 store.
// TODO(silvano): consider making this public.
func (s *s3Store) candidateConfigs() iter.Seq[Store] {
return func(yield func(Store) bool) {
func (s *s3Store) candidateConfigs() iter.Seq[Storage] {
return func(yield func(Storage) bool) {
combos := [][]string{
{}, // baseline first
{SkipChecksum},
Expand Down Expand Up @@ -211,7 +211,7 @@ const (
)

// try attempts to connect to the S3 store using alternative configurations.
func (s *s3Store) try(ctx context.Context, bucketName string) (Store, error) {
func (s *s3Store) try(ctx context.Context, bucketName string) (Storage, error) {
var clientMode aws.ClientLogMode
if s.verbose {
clientMode |= aws.LogRetries | aws.LogRequestWithBody | aws.LogRequestEventMessage | aws.LogResponse | aws.LogResponseEventMessage | aws.LogSigning
Expand Down
10 changes: 5 additions & 5 deletions internal/store/s3_test.go → internal/blob/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package store
package blob

import (
"fmt"
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestS3Alternates(t *testing.T) {
}
gotSeq := s.candidateConfigs()
var got []Params
gotSeq(func(d Store) bool {
gotSeq(func(d Storage) bool {
if alt, ok := d.(*s3Store); ok {
got = append(got, alt.params)
}
Expand Down Expand Up @@ -269,14 +269,14 @@ func TestMinioFromEnv(t *testing.T) {
Testing: true,
}

store, err := S3FromEnv(ctx, env)
blobStorage, err := S3FromEnv(ctx, env)
if tt.wantErr != nil {
assert.Nil(t, store)
assert.Nil(t, blobStorage)
assert.ErrorIs(t, err, tt.wantErr)
return
}
require.NoError(t, err)
s3 := (store.(*s3Store))
s3 := (blobStorage.(*s3Store))
assert.Equal(t, tt.want, s3.params)
assert.Regexp(t, fmt.Sprintf("^%s", testPath), s3.dest)
})
Expand Down
8 changes: 4 additions & 4 deletions internal/store/store.go → internal/blob/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// TODO(silvano): rename this package to "externalStorage"/"blobStorage"
package store
// Package blob provides an interface for interacting with blob storage.
package blob

import (
"iter"
Expand Down Expand Up @@ -43,8 +43,8 @@ func (p Params) Iter() iter.Seq2[string, string] {
}
}

// Store represents a destination to perform a backup/restore.
type Store interface {
// Storage represents a destination to perform a backup/restore.
type Storage interface {
// Params returns a copy of the params.
Params() Params
// URL returns a escaped URL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package store
package blob

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion internal/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const dropDbStmt = `DROP database IF EXISTS %[1]s CASCADE;`

// Drop removes the database.
func (d *Database) Drop(ctx *stopper.Context, conn *pgxpool.Conn) error {
slog.Info("Dropping database", slog.String("database", d.Name.String()))
slog.Debug("Dropping database", slog.String("database", d.Name.String()))
_, err := conn.Exec(ctx, fmt.Sprintf(dropDbStmt, d.Name))
return err
}
Expand Down
35 changes: 17 additions & 18 deletions internal/db/ext_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ import (
"github.com/cockroachdb/errors"
"github.com/cockroachdb/field-eng-powertools/semver"
"github.com/cockroachdb/field-eng-powertools/stopper"
"github.com/cockroachlabs-field/blobcheck/internal/store"
"github.com/cockroachlabs-field/blobcheck/internal/blob"
)

// MinVersionForStats is the minimum version required for retrieving statistics.
var MinVersionForStats = semver.MustSemver("v25.1.0")

// ExternalConn represents an external connection to an object store.
// ExternalConn represents an external connection to blob storage.
type ExternalConn struct {
name Ident
store store.Store
name Ident
blob blob.Storage
}

// Stats represents statistics about the external connection.
Expand All @@ -58,11 +58,11 @@ type TableBackup struct {

// NewExternalConn creates a new external connection.
func NewExternalConn(
ctx *stopper.Context, conn *pgxpool.Conn, store store.Store,
ctx *stopper.Context, conn *pgxpool.Conn, blob blob.Storage,
) (*ExternalConn, error) {
extConn := &ExternalConn{
name: "_blobcheck_backup",
store: store,
name: "_blobcheck_backup",
blob: blob,
}
err := extConn.Drop(ctx, conn)
if err != nil {
Expand All @@ -79,7 +79,6 @@ func (c *ExternalConn) ListTableBackups(
) ([]string, error) {
res := make([]string, 0)
stmt := fmt.Sprintf(backupsStmt, c.String())
slog.Info(stmt)
rows, err := conn.Query(ctx, stmt)
if err != nil {
return nil, err
Expand Down Expand Up @@ -119,7 +118,7 @@ func (c *ExternalConn) BackupInfo(
return nil, err
}
t.Full = (backupType == "full")
slog.Info("backup info", "type", backupType, "full",
slog.Debug("backup info", "type", backupType, "full",
t.Full, "table", tableName, "schema", schemeName)
res = append(res, t)
}
Expand All @@ -129,22 +128,22 @@ func (c *ExternalConn) BackupInfo(
const createExtConnStmt = `CREATE EXTERNAL CONNECTION '%[1]s' AS '%[2]s'`

func (c *ExternalConn) create(ctx *stopper.Context, conn *pgxpool.Conn) error {
destURL := c.store.URL()
destURL := c.blob.URL()
stmt := fmt.Sprintf(createExtConnStmt, c.name, destURL)
slog.Info("trying", slog.String("url", destURL))
slog.Debug("trying", slog.String("url", destURL))
if _, err := conn.Exec(ctx, stmt); err != nil {
slog.Info("failed", slog.Any("error", err))
slog.Error("failed", slog.Any("error", err))
return err
}
slog.Info("checking existing backups")
slog.Debug("checking existing backups")
backups, err := c.ListTableBackups(ctx, conn)
if err == nil {
slog.Info("success",
slog.Debug("success",
slog.String("url", destURL),
slog.Any("existing", backups))
return nil
}
slog.Info("failed", slog.Any("error", err))
slog.Error("failed", slog.Any("error", err))
return errors.Newf("external connection failed")
}

Expand All @@ -156,7 +155,7 @@ func (c *ExternalConn) Drop(ctx *stopper.Context, conn *pgxpool.Conn) error {
var name string
err := conn.QueryRow(ctx, fmt.Sprintf(showExtConnStmt, c.name)).Scan(&name)
if err == pgx.ErrNoRows {
slog.Info("external connection not found", slog.String("name", name))
slog.Debug("external connection not found", slog.String("name", name))
return nil
}
if err != nil {
Expand Down Expand Up @@ -204,6 +203,6 @@ func (c *ExternalConn) String() string {
}

// SuggestedParams returns the suggested parameters for the external connection.
func (c *ExternalConn) SuggestedParams() map[string]string {
return c.store.Params()
func (c *ExternalConn) SuggestedParams() blob.Params {
return c.blob.Params()
}
4 changes: 2 additions & 2 deletions internal/db/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func TestIntegration(t *testing.T) {
r.NoError(err)

extConn := &ExternalConn{
name: "test-conn",
store: &testStore{},
name: "test-conn",
blob: &testBlobStorage{},
}
extConn.create(ctx, conn)
defer func() { a.NoError(extConn.Drop(ctx, conn)) }()
Expand Down
Loading