From f9d7d688d89f35cff49481ea0939267c875105a5 Mon Sep 17 00:00:00 2001 From: Matt Fellows Date: Sun, 14 Mar 2021 16:16:43 +1100 Subject: [PATCH] chore: allow overriding of the lib install path --- .github/workflows/test.yml | 3 +++ Makefile | 2 +- command/install.go | 10 +++++++++- v3/installer/installer.go | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c7f29762..53face88f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,9 @@ jobs: os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: + - name: Set Golang shared lib variable + run: echo '::set-env name=LD_LIBRARY_PATH::/tmp' + - name: Install Go uses: actions/setup-go@v2 with: diff --git a/Makefile b/Makefile index 0b9cdb158..0a43d8f72 100755 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ install: fi installv3: - ./build/pact-go_linux_amd64 -l DEBUG install + ./build/pact-go_linux_amd64 -l DEBUG install --libDir /tmp pact: install docker @echo "--- 🔨 Running Pact examples" diff --git a/command/install.go b/command/install.go index ee2b5b476..c66b78f19 100644 --- a/command/install.go +++ b/command/install.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cobra" ) -var path string +var libDir = "" var installCmd = &cobra.Command{ Use: "install", Short: "Check required tools", @@ -19,6 +19,13 @@ var installCmd = &cobra.Command{ // Run the installer i, err := installer.NewInstaller() + + // + if libDir != "" { + log.Println("[INFO] set lib dir target to", libDir) + i.SetLibDir(libDir) + } + if err != nil { log.Println("[ERROR] Your Pact library installation is out of date and we were unable to download a newer one for you:", err) os.Exit(1) @@ -32,5 +39,6 @@ var installCmd = &cobra.Command{ } func init() { + installCmd.Flags().StringVarP(&libDir, "libDir", "d", "", "Target directory to install the library") RootCmd.AddCommand(installCmd) } diff --git a/v3/installer/installer.go b/v3/installer/installer.go index 26df9a123..22a59839b 100644 --- a/v3/installer/installer.go +++ b/v3/installer/installer.go @@ -64,6 +64,11 @@ func NewInstaller(opts ...installerConfig) (*Installer, error) { return i, nil } +// SetLibDir overrides the default library dir +func (i *Installer) SetLibDir(dir string) { + i.libDir = dir +} + // CheckInstallation checks installation of all of the required libraries // and downloads if they aren't present func (i *Installer) CheckInstallation() error {