Skip to content

Commit 7237e32

Browse files
committed
Changes in sugar package:
* Changed a type of database arg in `sugar.{MakeRecursive,RemoveRecursive}` from `ydb.Connection` to minimal required local interface
1 parent 3c08e9a commit 7237e32

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Changes in ydb connection:
1414
* Changed argument type for ydb.GRPCConn from `ydb.Connection` to `*ydb.Driver`
1515
* Removed method `With` from `ydb.Connection` (use *Driver.With) if need.
1616

17+
Changes in sugar package:
18+
* Changed a type of database arg in `sugar.{MakeRecursive,RemoveRecursive}` from `ydb.Connection` to minimal required local interface
19+
1720
Dependencies:
1821
* Up minimal supported version of go to 1.17 for update dependencies (new golang.org/x doesn't compiled for go 1.16)
1922
* Upgrade golang.org/x/... for prevent issues: CVE-2021-33194, CVE-2022-27664, CVE-2021-31525, CVE-2022-41723

sugar/path.go

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,34 @@ const (
1919
sysTable = ".sys"
2020
)
2121

22+
type dbNamer interface {
23+
Name() string
24+
}
25+
26+
type dbSchemer interface {
27+
Scheme() scheme.Client
28+
}
29+
30+
type dbTabler interface {
31+
Table() table.Client
32+
}
33+
34+
type dbForMakeRecursive interface {
35+
dbNamer
36+
dbSchemer
37+
}
38+
39+
type dbFoRemoveRecursive interface {
40+
dbNamer
41+
dbSchemer
42+
dbTabler
43+
}
44+
2245
// MakeRecursive creates path inside database
2346
// pathToCreate is a database root relative path
2447
// MakeRecursive method equal bash command `mkdir -p ~/path/to/create`
2548
// where `~` - is a root of database
26-
//
27-
// Use deprecated ydb.Connection as param for backward compatibility
28-
// Usually use *ydb.Driver, that implement ydb.Connection
29-
func MakeRecursive(ctx context.Context, db ydb.Connection, pathToCreate string) error { //nolint:staticcheck
49+
func MakeRecursive(ctx context.Context, db dbForMakeRecursive, pathToCreate string) error {
3050
pathToCreate = path.Join(db.Name(), pathToCreate)
3151
for i := len(db.Name()) + 1; i < len(pathToCreate); i++ {
3252
x := strings.IndexByte(pathToCreate[i:], '/')
@@ -81,10 +101,7 @@ func MakeRecursive(ctx context.Context, db ydb.Connection, pathToCreate string)
81101
// Empty prefix means than use root of database.
82102
// RemoveRecursive method equal bash command `rm -rf ~/path/to/remove`
83103
// where `~` - is a root of database
84-
//
85-
// Use deprecated ydb.Connection as param for backward compatibility
86-
// Usually use *ydb.Driver, that implement ydb.Connection
87-
func RemoveRecursive(ctx context.Context, db ydb.Connection, pathToRemove string) error { //nolint:staticcheck
104+
func RemoveRecursive(ctx context.Context, db dbFoRemoveRecursive, pathToRemove string) error {
88105
fullSysTablePath := path.Join(db.Name(), sysTable)
89106
var list func(int, string) error
90107
list = func(i int, p string) error {

0 commit comments

Comments
 (0)