Skip to content

Commit e251aa2

Browse files
committed
refactor: localstorage config key Remote -> Root
1 parent 93d77ab commit e251aa2

File tree

31 files changed

+95
-85
lines changed

31 files changed

+95
-85
lines changed

README.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ import (
9494

9595
func main() {
9696
disk, err := storage.Build(localstorage.Config{
97-
Remote: "/tmp/storage",
97+
Root: "/tmp/storage",
9898
})
9999
if err != nil {
100100
log.Fatal(err)
@@ -163,7 +163,7 @@ import (
163163
func main() {
164164
// Build one disk through the shared storage API.
165165
built, err := storage.Build(localstorage.Config{
166-
Remote: "/tmp/storage",
166+
Root: "/tmp/storage",
167167
Prefix: "scratch",
168168
})
169169
if err != nil {
@@ -172,7 +172,7 @@ func main() {
172172

173173
// Or construct the driver directly.
174174
direct, err := localstorage.New(localstorage.Config{
175-
Remote: "/tmp/storage",
175+
Root: "/tmp/storage",
176176
Prefix: "scratch",
177177
})
178178
if err != nil {
@@ -202,7 +202,7 @@ func main() {
202202
Default: "assets",
203203
Disks: map[storage.DiskName]storage.DriverConfig{
204204
"assets": localstorage.Config{
205-
Remote: "/tmp/storage",
205+
Root: "/tmp/storage",
206206
Prefix: "assets",
207207
},
208208
"uploads": s3storage.Config{
@@ -524,7 +524,7 @@ a Manager.
524524

525525
```go
526526
fs, _ := storage.Build(localstorage.Config{
527-
Remote: "/tmp/storage-example",
527+
Root: "/tmp/storage-example",
528528
Prefix: "assets",
529529
})
530530
```
@@ -536,7 +536,7 @@ s3storage.Config. It is the public config boundary for Manager and Build.
536536

537537
```go
538538
var cfg storage.DriverConfig = localstorage.Config{
539-
Remote: "/tmp/storage-config",
539+
Root: "/tmp/storage-config",
540540
}
541541
```
542542

@@ -596,7 +596,7 @@ GetContext reads the object at path using the caller-provided context.
596596

597597
```go
598598
disk, _ := storage.Build(localstorage.Config{
599-
Remote: "/tmp/storage-get-context",
599+
Root: "/tmp/storage-get-context",
600600
})
601601
_ = disk.Put("docs/readme.txt", []byte("hello"))
602602

@@ -680,7 +680,7 @@ Semantics:
680680
```go
681681
var disk storage.Storage
682682
disk, _ = storage.Build(localstorage.Config{
683-
Remote: "/tmp/storage-interface",
683+
Root: "/tmp/storage-interface",
684684
})
685685
```
686686

@@ -690,7 +690,7 @@ Copy copies the object at src to dst.
690690

691691
```go
692692
disk, _ := storage.Build(localstorage.Config{
693-
Remote: "/tmp/storage-copy",
693+
Root: "/tmp/storage-copy",
694694
})
695695
_ = disk.Put("docs/readme.txt", []byte("hello"))
696696
_ = disk.Copy("docs/readme.txt", "docs/copy.txt")
@@ -706,7 +706,7 @@ Delete removes the object at path.
706706

707707
```go
708708
disk, _ := storage.Build(localstorage.Config{
709-
Remote: "/tmp/storage-delete",
709+
Root: "/tmp/storage-delete",
710710
})
711711
_ = disk.Put("docs/readme.txt", []byte("hello"))
712712
_ = disk.Delete("docs/readme.txt")
@@ -722,7 +722,7 @@ Exists reports whether an object exists at path.
722722

723723
```go
724724
disk, _ := storage.Build(localstorage.Config{
725-
Remote: "/tmp/storage-exists",
725+
Root: "/tmp/storage-exists",
726726
})
727727
_ = disk.Put("docs/readme.txt", []byte("hello"))
728728

@@ -737,7 +737,7 @@ Get reads the object at path.
737737

738738
```go
739739
disk, _ := storage.Build(localstorage.Config{
740-
Remote: "/tmp/storage-get",
740+
Root: "/tmp/storage-get",
741741
})
742742
_ = disk.Put("docs/readme.txt", []byte("hello"))
743743

@@ -752,7 +752,7 @@ List returns the immediate children under path.
752752

753753
```go
754754
disk, _ := storage.Build(localstorage.Config{
755-
Remote: "/tmp/storage-list",
755+
Root: "/tmp/storage-list",
756756
})
757757
_ = disk.Put("docs/readme.txt", []byte("hello"))
758758

@@ -767,7 +767,7 @@ Move moves the object at src to dst.
767767

768768
```go
769769
disk, _ := storage.Build(localstorage.Config{
770-
Remote: "/tmp/storage-move",
770+
Root: "/tmp/storage-move",
771771
})
772772
_ = disk.Put("docs/readme.txt", []byte("hello"))
773773
_ = disk.Move("docs/readme.txt", "docs/archive.txt")
@@ -783,7 +783,7 @@ Put writes an object at path, overwriting any existing object.
783783

784784
```go
785785
disk, _ := storage.Build(localstorage.Config{
786-
Remote: "/tmp/storage-put",
786+
Root: "/tmp/storage-put",
787787
})
788788
_ = disk.Put("docs/readme.txt", []byte("hello"))
789789
fmt.Println("stored")
@@ -796,7 +796,7 @@ Stat returns the entry at path.
796796

797797
```go
798798
disk, _ := storage.Build(localstorage.Config{
799-
Remote: "/tmp/storage-stat",
799+
Root: "/tmp/storage-stat",
800800
})
801801
_ = disk.Put("docs/readme.txt", []byte("hello"))
802802

@@ -824,7 +824,7 @@ _Example: handle unsupported url generation_
824824

825825
```go
826826
disk, _ := storage.Build(localstorage.Config{
827-
Remote: "/tmp/storage-url",
827+
Root: "/tmp/storage-url",
828828
})
829829

830830
_, err := disk.URL("docs/readme.txt")
@@ -838,7 +838,7 @@ Walk visits entries recursively when the backend supports it.
838838

839839
```go
840840
disk, _ := storage.Build(localstorage.Config{
841-
Remote: "/tmp/storage-walk",
841+
Root: "/tmp/storage-walk",
842842
})
843843

844844
err := disk.Walk("", func(entry storage.Entry) error {
@@ -931,7 +931,7 @@ _Example: define local storage config_
931931

932932
```go
933933
cfg := localstorage.Config{
934-
Remote: "/tmp/storage-local",
934+
Root: "/tmp/storage-local",
935935
Prefix: "sandbox",
936936
}
937937
```
@@ -940,7 +940,7 @@ _Example: define local storage config with all fields_
940940

941941
```go
942942
cfg := localstorage.Config{
943-
Remote: "/tmp/storage-local",
943+
Root: "/tmp/storage-local",
944944
Prefix: "sandbox", // default: ""
945945
}
946946
```
@@ -1080,11 +1080,11 @@ fs, _ := gcsstorage.New(gcsstorage.Config{
10801080

10811081
### <a id="localstorage-new"></a>localstorage.New
10821082

1083-
New constructs local storage rooted at cfg.Remote with an optional prefix.
1083+
New constructs local storage rooted at cfg.Root with an optional prefix.
10841084

10851085
```go
10861086
fs, _ := localstorage.New(localstorage.Config{
1087-
Remote: "/tmp/storage-local",
1087+
Root: "/tmp/storage-local",
10881088
Prefix: "sandbox",
10891089
})
10901090
```
@@ -1159,7 +1159,7 @@ Config defines named disks using typed driver configs.
11591159
cfg := storage.Config{
11601160
Default: "local",
11611161
Disks: map[storage.DiskName]storage.DriverConfig{
1162-
"local": localstorage.Config{Remote: "/tmp/storage-manager"},
1162+
"local": localstorage.Config{Root: "/tmp/storage-manager"},
11631163
},
11641164
}
11651165
```
@@ -1172,7 +1172,7 @@ Manager holds named storage disks.
11721172
mgr, _ := storage.New(storage.Config{
11731173
Default: "local",
11741174
Disks: map[storage.DiskName]storage.DriverConfig{
1175-
"local": localstorage.Config{Remote: "/tmp/storage-manager"},
1175+
"local": localstorage.Config{Root: "/tmp/storage-manager"},
11761176
},
11771177
})
11781178
```
@@ -1185,7 +1185,7 @@ Default returns the default disk or panics if misconfigured.
11851185
mgr, _ := storage.New(storage.Config{
11861186
Default: "local",
11871187
Disks: map[storage.DiskName]storage.DriverConfig{
1188-
"local": localstorage.Config{Remote: "/tmp/storage-default"},
1188+
"local": localstorage.Config{Root: "/tmp/storage-default"},
11891189
},
11901190
})
11911191

@@ -1202,8 +1202,8 @@ Disk returns a named disk or an error if it does not exist.
12021202
mgr, _ := storage.New(storage.Config{
12031203
Default: "local",
12041204
Disks: map[storage.DiskName]storage.DriverConfig{
1205-
"local": localstorage.Config{Remote: "/tmp/storage-default"},
1206-
"uploads": localstorage.Config{Remote: "/tmp/storage-uploads"},
1205+
"local": localstorage.Config{Root: "/tmp/storage-default"},
1206+
"uploads": localstorage.Config{Root: "/tmp/storage-uploads"},
12071207
},
12081208
})
12091209

@@ -1220,8 +1220,8 @@ New constructs a Manager and eagerly initializes all disks.
12201220
mgr, _ := storage.New(storage.Config{
12211221
Default: "local",
12221222
Disks: map[storage.DiskName]storage.DriverConfig{
1223-
"local": localstorage.Config{Remote: "/tmp/storage-local"},
1224-
"assets": localstorage.Config{Remote: "/tmp/storage-assets", Prefix: "public"},
1223+
"local": localstorage.Config{Root: "/tmp/storage-local"},
1224+
"assets": localstorage.Config{Root: "/tmp/storage-assets", Prefix: "public"},
12251225
},
12261226
})
12271227
```

build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import "context"
99
// Example: build a single disk
1010
//
1111
// fs, _ := storage.Build(localstorage.Config{
12-
// Remote: "/tmp/storage-example",
12+
// Root: "/tmp/storage-example",
1313
// Prefix: "assets",
1414
// })
1515
// _ = fs

docs/bench/render.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func benchmarkCases(ctx context.Context) []benchmarkCase {
143143
}
144144
return &benchmarkFixture{
145145
newStore: func(context.Context) (storage.Storage, func(), error) {
146-
store, err := storage.Build(localstorage.Config{Remote: root, Prefix: "bench"})
146+
store, err := storage.Build(localstorage.Config{Root: root, Prefix: "bench"})
147147
return store, func() {}, err
148148
},
149149
cleanup: func() { _ = os.RemoveAll(root) },

driver/localstorage/local.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ type driver struct {
3131
// Example: define local storage config
3232
//
3333
// cfg := localstorage.Config{
34-
// Remote: "/tmp/storage-local",
34+
// Root: "/tmp/storage-local",
3535
// Prefix: "sandbox",
3636
// }
3737
// _ = cfg
3838
//
3939
// Example: define local storage config with all fields
4040
//
4141
// cfg := localstorage.Config{
42-
// Remote: "/tmp/storage-local",
42+
// Root: "/tmp/storage-local",
4343
// Prefix: "sandbox", // default: ""
4444
// }
4545
// _ = cfg
4646
type Config struct {
47-
Remote string
47+
Root string
4848
Prefix string
4949
}
5050

@@ -53,18 +53,18 @@ func (Config) DriverName() string { return "local" }
5353
func (c Config) ResolvedConfig() storage.ResolvedConfig {
5454
return storage.ResolvedConfig{
5555
Driver: "local",
56-
Remote: c.Remote,
56+
Remote: c.Root,
5757
Prefix: c.Prefix,
5858
}
5959
}
6060

61-
// New constructs local storage rooted at cfg.Remote with an optional prefix.
61+
// New constructs local storage rooted at cfg.Root with an optional prefix.
6262
// @group Driver Constructors
6363
//
6464
// Example: local storage
6565
//
6666
// fs, _ := localstorage.New(localstorage.Config{
67-
// Remote: "/tmp/storage-local",
67+
// Root: "/tmp/storage-local",
6868
// Prefix: "sandbox",
6969
// })
7070
// _ = fs
@@ -78,7 +78,7 @@ func NewContext(ctx context.Context, cfg Config) (storage.Storage, error) {
7878

7979
func newFromDiskConfig(_ context.Context, cfg storage.ResolvedConfig) (storage.Storage, error) {
8080
if cfg.Remote == "" {
81-
return nil, fmt.Errorf("storage: local storage requires remote path")
81+
return nil, fmt.Errorf("storage: local storage requires root path")
8282
}
8383
cleanPrefix, err := storage.NormalizePath(cfg.Prefix)
8484
if err != nil {

driver/localstorage/local_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestLocalStorageContract(t *testing.T) {
1414
cfg := storage.Config{
1515
Default: "local",
1616
Disks: map[storage.DiskName]storage.DriverConfig{
17-
"local": Config{Remote: root, Prefix: "sandbox"},
17+
"local": Config{Root: root, Prefix: "sandbox"},
1818
},
1919
}
2020

@@ -37,7 +37,7 @@ func TestLocalPrefixIsolation(t *testing.T) {
3737
cfg := storage.Config{
3838
Default: "local",
3939
Disks: map[storage.DiskName]storage.DriverConfig{
40-
"local": Config{Remote: root, Prefix: "sandbox"},
40+
"local": Config{Root: root, Prefix: "sandbox"},
4141
},
4242
}
4343
manager, err := storage.New(cfg)

driver/localstorage/local_unit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestLocalConstructors(t *testing.T) {
2121

2222
t.Run("new context success", func(t *testing.T) {
2323
root := t.TempDir()
24-
got, err := NewContext(context.Background(), Config{Remote: root, Prefix: "pre"})
24+
got, err := NewContext(context.Background(), Config{Root: root, Prefix: "pre"})
2525
if err != nil {
2626
t.Fatalf("NewContext: %v", err)
2727
}

examples/build/main.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/config/main.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/contextstorage_getcontext/main.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/driverconfig/main.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)