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
33
34
35
36
37
38
39
40
41
42
43
44
package clusterkcp
import (
"context"
"time"
"k8s.io/client-go/rest"
"github.com/johnandersen777/socialweb-computer-kcp/internal/clusterprovider"
"github.com/johnandersen777/socialweb-computer-kcp/internal/vault/openbao"
)
func RestConfig(cred *clusterprovider.Credential) *rest.Config {
if cred == nil {
return nil
}
return &rest.Config{
Host: cred.Host,
TLSClientConfig: rest.TLSClientConfig{
CAData: cred.CAData,
CertData: cred.CertData,
KeyData: cred.KeyData,
},
}
}
func restConfig(cred *clusterprovider.Credential, err error) (*rest.Config, error) {
if err != nil {
return nil, err
}
return RestConfig(cred), nil
}
func MintTenantCredentialForCluster(ctx context.Context, logins *openbao.Logins, stateDir, cluster, server string, source clusterprovider.CredentialSource) (*rest.Config, error) {
return restConfig(clusterprovider.MintTenantCredentialForCluster(ctx, logins, stateDir, cluster, server, source))
}
func MintTenantCredentialForClusterAs(ctx context.Context, stateDir, cluster, server, commonName string, organizations []string, validFor time.Duration) (*rest.Config, error) {
return restConfig(clusterprovider.MintTenantCredentialForClusterAs(ctx, stateDir, cluster, server, commonName, organizations, validFor))
}
func MintTenantCredentialForDataDirAs(dataDir, server, commonName string, organizations []string, validFor time.Duration) (*rest.Config, error) {
return restConfig(clusterprovider.MintTenantCredentialForDataDirAs(dataDir, server, commonName, organizations, validFor))
}