aboutsummaryrefslogtreecommitdiff
path: root/executor/plugins.go
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-11-28 17:15:12 +0100
committerAlex Auvolat <alex@adnab.me>2022-11-28 17:15:12 +0100
commitbf3165a7069fc6dcf9ae3a28be3af07fe8b4e1c2 (patch)
tree32f52eeb5d60ae33e8a40c2d8b26d70cac19a473 /executor/plugins.go
parent63e31b9ed97f34f4ea709f505c37f5e8968a0f36 (diff)
downloadnomad-driver-nix2-bf3165a7069fc6dcf9ae3a28be3af07fe8b4e1c2.tar.gz
nomad-driver-nix2-bf3165a7069fc6dcf9ae3a28be3af07fe8b4e1c2.zip
Vendor executor module so that we can patch it
Diffstat (limited to 'executor/plugins.go')
-rw-r--r--executor/plugins.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/executor/plugins.go b/executor/plugins.go
new file mode 100644
index 0000000..0e3b977
--- /dev/null
+++ b/executor/plugins.go
@@ -0,0 +1,55 @@
+package executor
+
+import (
+ "net"
+
+ hclog "github.com/hashicorp/go-hclog"
+ plugin "github.com/hashicorp/go-plugin"
+)
+
+// ExecutorConfig is the config that Nomad passes to the executor
+type ExecutorConfig struct {
+
+ // LogFile is the file to which Executor logs
+ LogFile string
+
+ // LogLevel is the level of the logs to putout
+ LogLevel string
+
+ // FSIsolation if set will use an executor implementation that support
+ // filesystem isolation
+ FSIsolation bool
+}
+
+func GetPluginMap(logger hclog.Logger, fsIsolation bool) map[string]plugin.Plugin {
+ return map[string]plugin.Plugin{
+ "executor": &ExecutorPlugin{
+ logger: logger,
+ fsIsolation: fsIsolation,
+ },
+ }
+}
+
+// ExecutorReattachConfig is the config that we serialize and de-serialize and
+// store in disk
+type PluginReattachConfig struct {
+ Pid int
+ AddrNet string
+ AddrName string
+}
+
+// PluginConfig returns a config from an ExecutorReattachConfig
+func (c *PluginReattachConfig) PluginConfig() *plugin.ReattachConfig {
+ var addr net.Addr
+ switch c.AddrNet {
+ case "unix", "unixgram", "unixpacket":
+ addr, _ = net.ResolveUnixAddr(c.AddrNet, c.AddrName)
+ case "tcp", "tcp4", "tcp6":
+ addr, _ = net.ResolveTCPAddr(c.AddrNet, c.AddrName)
+ }
+ return &plugin.ReattachConfig{Pid: c.Pid, Addr: addr}
+}
+
+func NewPluginReattachConfig(c *plugin.ReattachConfig) *PluginReattachConfig {
+ return &PluginReattachConfig{Pid: c.Pid, AddrNet: c.Addr.Network(), AddrName: c.Addr.String()}
+}