feat(config) Add env and file support to Plugins execution dir
This commit is contained in:
1 parent
ae4aff85ca
commit
5601f2bc5f
4 files changed
+63
-6
No files matched your search
@@ -5,6 +5,8 @@ Canonical reference for changes, improvements, and bugfixes for Boundary.
|
||||
## Next
|
||||
|
||||
### New and Improved
|
||||
* config: The `execution_dir` field for plugins now supports being set from environment variables
|
||||
or a file on disk.([PR](https://github.com/hashicorp/boundary/pull/1772))
|
||||
* config: The `description` field for controllers now supports being set
|
||||
from environment variables or a file on disk
|
||||
([PR](https://github.com/hashicorp/boundary/pull/1766))
|
||||
|
||||
@@ -496,6 +496,13 @@ func Parse(d string) (*Config, error) {
|
||||
return nil, fmt.Errorf(`too many "events" nodes (max 1, got %d)`, len(eventList.Items))
|
||||
}
|
||||
|
||||
if result.Plugins.ExecutionDir != "" {
|
||||
result.Plugins.ExecutionDir, err = parseutil.ParsePath(result.Plugins.ExecutionDir)
|
||||
if err != nil && !errors.Is(err, parseutil.ErrNotAUrl) {
|
||||
return nil, fmt.Errorf("Error parsing plugins execution dir: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -837,13 +837,13 @@ func TestControllerDescription(t *testing.T) {
|
||||
}`,
|
||||
expErr: true,
|
||||
expErrStr: "At 3:22: illegal char escape",
|
||||
},{
|
||||
}, {
|
||||
name: "Not a URL, non-printable description",
|
||||
in: `
|
||||
controller {
|
||||
description = "\x00"
|
||||
}`,
|
||||
expErr: true,
|
||||
expErr: true,
|
||||
expErrStr: "Controller description contains non-printable characters",
|
||||
},
|
||||
}
|
||||
@@ -863,4 +863,50 @@ func TestControllerDescription(t *testing.T) {
|
||||
require.Equal(t, tt.expDescription, c.Controller.Description)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPluginExecutionDir(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
in string
|
||||
envPluginExecutionDir string
|
||||
expPluginExecutionDir string
|
||||
expErr bool
|
||||
expErrStr string
|
||||
}{
|
||||
{
|
||||
name: "Valid plugin execution dir from env var",
|
||||
in: `
|
||||
plugins {
|
||||
execution_dir = "env://PLUGIN_EXEC_DIR"
|
||||
}`,
|
||||
envPluginExecutionDir: `/var/run/boundary/plugin-exec`,
|
||||
expPluginExecutionDir: `/var/run/boundary/plugin-exec`,
|
||||
expErr: false,
|
||||
}, {
|
||||
name: "Invalid plugin execution dir from env var",
|
||||
in: `
|
||||
plugins {
|
||||
execution_dir ="\ubad plugin directory"
|
||||
}`,
|
||||
expErr: true,
|
||||
expErrStr: "At 3:28: illegal char escape",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Setenv("PLUGIN_EXEC_DIR", tt.envPluginExecutionDir)
|
||||
p, err := Parse(tt.in)
|
||||
if tt.expErr {
|
||||
require.EqualError(t, err, tt.expErrStr)
|
||||
require.Nil(t, p)
|
||||
return
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, p)
|
||||
require.NotNil(t, p.Plugins)
|
||||
require.Equal(t, tt.expPluginExecutionDir, p.Plugins.ExecutionDir)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,8 @@ plugins {
|
||||
```
|
||||
|
||||
- `execution_dir` - Specifies a directory that Boundary can use to write and
|
||||
execute its built-in plugins. This directory must be writeable by the Boundary
|
||||
user. If not set, Boundary will attempt to create a suitable directory in the
|
||||
system temporary folder.
|
||||
execute its built-in plugins. This value can be a direct directory string,
|
||||
can refer to a file on disk (file://) from which a directory location will be
|
||||
read; or an env var (env://) from which the directory location will be read.
|
||||
This directory must be writeable by the Boundary user. If not set, Boundary will
|
||||
attempt to create a suitable directory in the system temporary folder.
|
||||
Reference in new issue
Block a user