github.com/argoproj/argo-cd/v2@v2.10.5/test/fixture/path/hack_path.go (about)

     1  package path
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"path/filepath"
     7  
     8  	"github.com/argoproj/argo-cd/v2/util/errors"
     9  )
    10  
    11  type AddBinDirToPath struct {
    12  	originalPath string
    13  }
    14  
    15  func (h AddBinDirToPath) Close() {
    16  	_ = os.Setenv("PATH", h.originalPath)
    17  }
    18  
    19  // add the hack path which has the argocd binary
    20  func NewBinDirToPath() AddBinDirToPath {
    21  	originalPath := os.Getenv("PATH")
    22  	binDir, err := filepath.Abs("../../dist")
    23  	errors.CheckError(err)
    24  	err = os.Setenv("PATH", fmt.Sprintf("%s:%s", originalPath, binDir))
    25  	errors.CheckError(err)
    26  	return AddBinDirToPath{originalPath}
    27  }