X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2ba137a3ccc524cd85db4f001a7ee966539b338e..7f0f12c40238f3eb12a51877a755cf22357e0767:/lib/config/load.go diff --git a/lib/config/load.go b/lib/config/load.go index 9269ddf27f..93c175062e 100644 --- a/lib/config/load.go +++ b/lib/config/load.go @@ -21,11 +21,12 @@ import ( "strings" "time" + "dario.cat/mergo" "git.arvados.org/arvados.git/sdk/go/arvados" "github.com/ghodss/yaml" - "github.com/imdario/mergo" "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" + "golang.org/x/crypto/ssh" "golang.org/x/sys/unix" ) @@ -47,7 +48,6 @@ type Loader struct { CrunchDispatchSlurmPath string WebsocketPath string KeepproxyPath string - GitHttpdPath string KeepBalancePath string configdata []byte @@ -87,7 +87,6 @@ func (ldr *Loader) SetupFlags(flagset *flag.FlagSet) { flagset.StringVar(&ldr.CrunchDispatchSlurmPath, "legacy-crunch-dispatch-slurm-config", defaultCrunchDispatchSlurmConfigPath, "Legacy crunch-dispatch-slurm configuration `file`") flagset.StringVar(&ldr.WebsocketPath, "legacy-ws-config", defaultWebsocketConfigPath, "Legacy arvados-ws configuration `file`") flagset.StringVar(&ldr.KeepproxyPath, "legacy-keepproxy-config", defaultKeepproxyConfigPath, "Legacy keepproxy configuration `file`") - flagset.StringVar(&ldr.GitHttpdPath, "legacy-git-httpd-config", defaultGitHttpdConfigPath, "Legacy arvados-git-httpd configuration `file`") flagset.StringVar(&ldr.KeepBalancePath, "legacy-keepbalance-config", defaultKeepBalanceConfigPath, "Legacy keep-balance configuration `file`") flagset.BoolVar(&ldr.SkipLegacy, "skip-legacy", false, "Don't load legacy config files") } @@ -167,9 +166,6 @@ func (ldr *Loader) MungeLegacyConfigArgs(lgr logrus.FieldLogger, args []string, if legacyConfigArg != "-legacy-keepproxy-config" { ldr.KeepproxyPath = "" } - if legacyConfigArg != "-legacy-git-httpd-config" { - ldr.GitHttpdPath = "" - } if legacyConfigArg != "-legacy-keepbalance-config" { ldr.KeepBalancePath = "" } @@ -295,7 +291,6 @@ func (ldr *Loader) Load() (*arvados.Config, error) { ldr.loadOldCrunchDispatchSlurmConfig, ldr.loadOldWebsocketConfig, ldr.loadOldKeepproxyConfig, - ldr.loadOldGitHttpdConfig, ldr.loadOldKeepBalanceConfig, ) } @@ -690,3 +685,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)) + } +}