X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/58e6402a72e9ac1a210b2d318591f973a37e1e57..f79d1cdf7696a3bbcc374df5ce4d1761a28a5ea5:/lib/config/load.go diff --git a/lib/config/load.go b/lib/config/load.go index fbd01488a0..d504f7796c 100644 --- a/lib/config/load.go +++ b/lib/config/load.go @@ -26,6 +26,7 @@ import ( "github.com/imdario/mergo" "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" + "golang.org/x/crypto/ssh" "golang.org/x/sys/unix" ) @@ -448,6 +449,7 @@ func (ldr *Loader) setLoopbackInstanceType(cfg *arvados.Config) error { RAM: hostram, Scratch: scratch, IncludedScratch: scratch, + Price: 1.0, }} cfg.Clusters[id] = cc } @@ -689,3 +691,17 @@ func (ldr *Loader) RegisterMetrics(reg *prometheus.Registry) { vec.WithLabelValues(hash).Set(float64(ldr.loadTimestamp.UnixNano()) / 1e9) reg.MustRegister(vec) } + +// Load an SSH private key from the given confvalue, which is either +// the literal key or an absolute path to a file containing the key. +func LoadSSHKey(confvalue string) (ssh.Signer, error) { + if fnm := strings.TrimPrefix(confvalue, "file://"); fnm != confvalue && strings.HasPrefix(fnm, "/") { + keydata, err := os.ReadFile(fnm) + if err != nil { + return nil, err + } + return ssh.ParsePrivateKey(keydata) + } else { + return ssh.ParsePrivateKey([]byte(confvalue)) + } +}