mirror of
https://gerrit.hackerspace.pl/hscloud
synced 2025-01-24 16:33:54 +00:00
radex
63f0adde2f
- allow passing -cluster to select another cluster (k0 remains the default for the time being) - default prodvider dns to prodvider.<cluster>.hswaw.net - scope kube config username and certs storage by cluster name additionally: - force username to be lowercase (LDAP is case-insensitive, but e.g. kubernetes namespaces are not) - fix some Go deprecations Change-Id: Ibf4a6ced7a635940f6a7c568c79714cd8ac60ce9 Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/2101 Reviewed-by: radex <radex@hackerspace.pl>
35 lines
720 B
Go
35 lines
720 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/golang/glog"
|
|
|
|
pb "code.hackerspace.pl/hscloud/cluster/prodvider/proto"
|
|
"code.hackerspace.pl/hscloud/go/pki"
|
|
)
|
|
|
|
func useHSPKIKeys(keys *pb.HSPKIKeys) {
|
|
path, err := pki.DeveloperCredentialsLocation()
|
|
if err != nil {
|
|
glog.Exitf("Could not get location of HSPKI creds: %v", err)
|
|
}
|
|
err = os.MkdirAll(path, 0700)
|
|
if err != nil {
|
|
glog.Exitf("mkdir %q: %v", path, err)
|
|
}
|
|
|
|
for _, el := range []struct {
|
|
target string
|
|
data []byte
|
|
}{
|
|
{path + "/ca.crt", keys.Ca},
|
|
{path + "/tls.crt", keys.Cert},
|
|
{path + "/tls.key", keys.Key},
|
|
} {
|
|
err := os.WriteFile(el.target, el.data, 400)
|
|
if err != nil {
|
|
glog.Exitf("Failed to write %q: %v", el.target, err)
|
|
}
|
|
}
|
|
}
|