github.com/argoproj/argo-cd@v1.8.7/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/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 git-ask-pass.sh shell script
    20  func NewBinDirToPath() AddBinDirToPath {
    21  	originalPath := os.Getenv("PATH")
    22  	binDir, err := filepath.Abs("../../hack")
    23  	errors.CheckError(err)
    24  	err = os.Setenv("PATH", fmt.Sprintf("%s:%s", originalPath, binDir))
    25  	errors.CheckError(err)
    26  	return AddBinDirToPath{originalPath}
    27  }