github.com/criteo/command-launcher@v0.0.0-20230407142452-fb616f546e98/internal/helper/password.go (about)

     1  package helper
     2  
     3  import (
     4  	"os"
     5  	"syscall"
     6  
     7  	"golang.org/x/crypto/ssh/terminal"
     8  )
     9  
    10  func ReadPassword() ([]byte, error) {
    11  	passwd := os.Getenv("CDT_JENKINS_PASSWORD")
    12  	if passwd != "" {
    13  		return []byte(passwd), nil
    14  	}
    15  
    16  	return terminal.ReadPassword(int(syscall.Stdin))
    17  }