File: provider.go

package info (click to toggle)
golang-github-viant-toolbox 0.33.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,280 kB
  • sloc: makefile: 16
file content (32 lines) | stat: -rw-r--r-- 795 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package scp

import (
	"github.com/viant/toolbox/cred"
	"github.com/viant/toolbox/secret"
	"github.com/viant/toolbox/storage"
	"strings"
)

//ProviderScheme represents scp URL scheme for this provider
const ProviderScheme = "scp"

//SSHProviderScheme represents ssh URL scheme for this provider
const SSHProviderScheme = "ssh"

func init() {
	storage.Registry().Registry[ProviderScheme] = serviceProvider
	storage.Registry().Registry[SSHProviderScheme] = serviceProvider
}

func serviceProvider(credentials string) (storage.Service, error) {
	var config = &cred.Config{}
	if strings.TrimSpace(credentials) != "" {
		var err error
		secrets := secret.New("", false)
		config, err = secrets.GetCredentials(credentials)
		if err != nil {
			return nil, err
		}
	}
	return NewService(config), nil
}