From 00a8b53b1fdad57a670896d71e35f0221ebd6e43 Mon Sep 17 00:00:00 2001 From: Noel Georgi Date: Tue, 10 May 2022 15:58:04 +0530 Subject: [PATCH] chore: use golang.org/x/sys over syscall Use `golang.org/x/sys` over deprecated `syscall` package Signed-off-by: Noel Georgi --- storage/iscsi-tools/iscsid-wrapper/go.mod | 5 +++++ storage/iscsi-tools/iscsid-wrapper/go.sum | 2 ++ .../iscsi-tools/{ => iscsid-wrapper}/main.go | 5 +++-- storage/iscsi-tools/iscsid-wrapper/pkg.yaml | 21 +++++++++++++++++++ storage/iscsi-tools/pkg.yaml | 12 ++--------- 5 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 storage/iscsi-tools/iscsid-wrapper/go.mod create mode 100644 storage/iscsi-tools/iscsid-wrapper/go.sum rename storage/iscsi-tools/{ => iscsid-wrapper}/main.go (89%) create mode 100644 storage/iscsi-tools/iscsid-wrapper/pkg.yaml diff --git a/storage/iscsi-tools/iscsid-wrapper/go.mod b/storage/iscsi-tools/iscsid-wrapper/go.mod new file mode 100644 index 00000000..800aa4b5 --- /dev/null +++ b/storage/iscsi-tools/iscsid-wrapper/go.mod @@ -0,0 +1,5 @@ +module iscsid-wrapper + +go 1.18 + +require golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 diff --git a/storage/iscsi-tools/iscsid-wrapper/go.sum b/storage/iscsi-tools/iscsid-wrapper/go.sum new file mode 100644 index 00000000..67ddd694 --- /dev/null +++ b/storage/iscsi-tools/iscsid-wrapper/go.sum @@ -0,0 +1,2 @@ +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/storage/iscsi-tools/main.go b/storage/iscsi-tools/iscsid-wrapper/main.go similarity index 89% rename from storage/iscsi-tools/main.go rename to storage/iscsi-tools/iscsid-wrapper/main.go index 4d304afc..01567b15 100644 --- a/storage/iscsi-tools/main.go +++ b/storage/iscsi-tools/iscsid-wrapper/main.go @@ -8,7 +8,8 @@ import ( "log" "os" "os/exec" - "syscall" + + "golang.org/x/sys/unix" ) func main() { @@ -36,7 +37,7 @@ func main() { } log.Println("iscsid-wrapper: completed..., execing into iscsid") - if err := syscall.Exec("/usr/local/sbin/iscsid", []string{"iscsid", "-f"}, os.Environ()); err != nil { + if err := unix.Exec("/usr/local/sbin/iscsid", []string{"iscsid", "-f"}, os.Environ()); err != nil { log.Fatalf("iscsid: error execing /usr/local/sbin/iscsid %v\n", err) } } diff --git a/storage/iscsi-tools/iscsid-wrapper/pkg.yaml b/storage/iscsi-tools/iscsid-wrapper/pkg.yaml new file mode 100644 index 00000000..4ed56a18 --- /dev/null +++ b/storage/iscsi-tools/iscsid-wrapper/pkg.yaml @@ -0,0 +1,21 @@ +name: iscsid-wrapper +variant: scratch +shell: /toolchain/bin/bash +dependencies: + - stage: base +steps: + - build: + - | + export PATH=${PATH}:${TOOLCHAIN}/go/bin + + cp -r /pkg/* . + + CGO_ENABLED=0 go build -o iscsid-wrapper main.go + install: + - | + mkdir -p /rootfs/usr/local/sbin + + cp iscsid-wrapper /rootfs/usr/local/sbin/iscsid-wrapper +finalize: + - from: /rootfs + to: /rootfs diff --git a/storage/iscsi-tools/pkg.yaml b/storage/iscsi-tools/pkg.yaml index 7c3bb810..cb414ccd 100644 --- a/storage/iscsi-tools/pkg.yaml +++ b/storage/iscsi-tools/pkg.yaml @@ -8,19 +8,11 @@ dependencies: - stage: open-isns - stage: open-iscsi - stage: tgt + - stage: iscsid-wrapper steps: - - build: - - | - cp /pkg/main.go main.go - - export PATH=${PATH}:${TOOLCHAIN}/go/bin - - CGO_ENABLED=0 go build -o iscsid-wrapper main.go - install: + - install: - | mkdir -p /rootfs/usr/local/lib/containers/{iscsid,tgtd} - - cp iscsid-wrapper /rootfs/usr/local/sbin/iscsid-wrapper sed -i 's#$VERSION#{{ .VERSION }}#' /pkg/manifest.yaml