[lxc-devel] [lxd/master] lxd/callhook: Respect LXD_SOCKET environment variable
ganto on Github
lxc-bot at linuxcontainers.org
Thu May 10 08:55:59 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 674 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180510/24bf950c/attachment.bin>
-------------- next part --------------
From 3186b980f36eafdc8d3054429ca2dd76a5f2c595 Mon Sep 17 00:00:00 2001
From: Reto Gantenbein <reto.gantenbein at linuxmonk.ch>
Date: Thu, 10 May 2018 07:23:43 +0200
Subject: [PATCH] lxd/callhook: Respect LXD_SOCKET environment variable
First check the LXD_SOCKET environment variable which might
contain a user provided Unix socket before trying to connect
to default LXD socket.
Signed-off-by: Reto Gantenbein <reto.gantenbein at linuxmonk.ch>
---
lxd/main_callhook.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lxd/main_callhook.go b/lxd/main_callhook.go
index 7d463808a..cf64860f4 100644
--- a/lxd/main_callhook.go
+++ b/lxd/main_callhook.go
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
+ "path/filepath"
"time"
"github.com/spf13/cobra"
@@ -54,7 +55,11 @@ func (c *cmdCallhook) Run(cmd *cobra.Command, args []string) error {
}
// Connect to LXD
- d, err := lxd.ConnectLXDUnix(fmt.Sprintf("%s/unix.socket", path), nil)
+ socket := os.Getenv("LXD_SOCKET")
+ if socket == "" {
+ socket = filepath.Join(path, "unix.socket")
+ }
+ d, err := lxd.ConnectLXDUnix(socket, nil)
if err != nil {
return err
}
More information about the lxc-devel
mailing list