From 6329cd6500a94cd0de6d09f78ef187c986619328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Mon, 1 Mar 2021 14:09:36 +0100 Subject: [PATCH 1/2] feat: add support for -- on windows --- strategy/credentials/credentials.go | 4 +--- strategy/credentials/credentials_nonwin.go | 9 +++++++++ strategy/credentials/credentials_win.go | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 strategy/credentials/credentials_nonwin.go create mode 100644 strategy/credentials/credentials_win.go diff --git a/strategy/credentials/credentials.go b/strategy/credentials/credentials.go index 7915411..811d356 100644 --- a/strategy/credentials/credentials.go +++ b/strategy/credentials/credentials.go @@ -8,7 +8,6 @@ import ( "os/exec" "path/filepath" "strings" - "syscall" "time" "github.com/aws/aws-sdk-go/aws" @@ -115,8 +114,7 @@ func (c *Credentials) Exec(app string, args []string) error { log.Debug(logExec, cmd, args) - return syscall.Exec(cmd, args, env.ToEnv()) - + return exec_(cmd, args, env.ToEnv()) } // IsValid indicates if a loaded credential is (still) valid diff --git a/strategy/credentials/credentials_nonwin.go b/strategy/credentials/credentials_nonwin.go new file mode 100644 index 0000000..a8b0cd9 --- /dev/null +++ b/strategy/credentials/credentials_nonwin.go @@ -0,0 +1,9 @@ +// +build !windows + +package credentials + +import "syscall" + +func exec_(cmd string, args []string, env []string) error { + return syscall.Exec(cmd, args, env) +} diff --git a/strategy/credentials/credentials_win.go b/strategy/credentials/credentials_win.go new file mode 100644 index 0000000..e8fb9c9 --- /dev/null +++ b/strategy/credentials/credentials_win.go @@ -0,0 +1,17 @@ +// +build windows + +package credentials + +import ( + "os" + "os/exec" +) + +func exec_(cmd string, args []string, env []string) error { + c := exec.Command(cmd, args[1:]...) + c.Env = env + c.Stdin = os.Stdin + c.Stdout = os.Stdout + c.Stderr = os.Stderr + return c.Run() +} From 7806f05cce9001cf2896a06f1f2cfb8205ad2ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Wed, 20 Oct 2021 11:00:49 +0200 Subject: [PATCH 2/2] ci(test): add windows os target --- .github/workflows/test.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb08598..d693f5a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - main paths-ignore: - 'README.md' pull_request: @@ -12,7 +13,11 @@ on: - 'README.md' jobs: unit: - runs-on: ubuntu-20.04 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04, windows-latest] steps: - name: Checkout uses: actions/checkout@v2 @@ -23,8 +28,9 @@ jobs: with: go-version: 1.17 - name: Setup Dependencies + if: matrix.os == 'ubuntu-20.04' run: | sudo apt-get update -q sudo apt-get install -qqy libpcsclite-dev - name: Run tests - run: make test \ No newline at end of file + run: go test ./... -cover \ No newline at end of file