Skip to content

Commit 86dd535

Browse files
committed
test(sdk): make the plugin spec dir customizable
1 parent 2c557dc commit 86dd535

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ _testmain.go
2222
*.exe
2323
*.test
2424
*.prof
25+
26+
_dev/plugins

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,21 @@ A collection of helper packages to extend Docker Engine in Go
1212

1313
See the [understand Docker plugins documentation section](https://docs.docker.com/engine/extend/plugins/).
1414

15-
### Release a New Version
15+
## Test Environment
16+
17+
It is possible to execute the tests in a Docker environment by running:
18+
19+
```shell
20+
make test
21+
```
22+
23+
In a non-Docker environment, you may want to define the environment variable `PLUGIN_SPEC_DIR` to a user-writable folder such as:
24+
25+
```shell
26+
PLUGIN_SPEC_DIR=$(pwd)/_dev go test -v ./...
27+
```
28+
29+
## Release a New Version
1630

1731
Bump new version number in:
1832

_dev/.gitkeep

Whitespace-only changes.

sdk/spec_file_generator.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ func createPluginSpecDirWindows(name, address, daemonRoot string) (string, error
3939
}
4040

4141
func createPluginSpecDirUnix(name, address string) (string, error) {
42-
pluginSpecDir := PluginSpecDir("/etc/docker")
42+
myPluginSpecDir := os.Getenv("PLUGIN_SPEC_DIR")
43+
if myPluginSpecDir == "" {
44+
myPluginSpecDir = "/etc/docker"
45+
}
46+
pluginSpecDir := PluginSpecDir(myPluginSpecDir)
4347
if err := os.MkdirAll(pluginSpecDir, 0755); err != nil {
4448
return "", err
4549
}

0 commit comments

Comments
 (0)