mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-07 23:27:07 +02:00
There were weird hacks put into the tests, while each test already runs in a temporary directory as 'working directory', so no hacks are needed. Moreover, using fixed `/tmp/...` paths leads to test failures, as CI runs docker & QEMU tests in parallel conflicting with each other. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package cli
|
|
|
|
import (
|
|
_ "embed"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
var (
|
|
//go:embed "testdata/pki/ca.crt"
|
|
pkiCACrt []byte
|
|
//go:embed "testdata/pki/ca.key"
|
|
pkiCAKey []byte
|
|
//go:embed "testdata/pki/front-proxy-ca.crt"
|
|
pkiFrontProxyCACrt []byte
|
|
//go:embed "testdata/pki/front-proxy-ca.key"
|
|
pkiFrontProxyCAKey []byte
|
|
//go:embed "testdata/pki/sa.key"
|
|
pkiSAKey []byte
|
|
//go:embed "testdata/pki/etcd/ca.crt"
|
|
pkiEtcdCACrt []byte
|
|
//go:embed "testdata/pki/etcd/ca.key"
|
|
pkiEtcdCAKey []byte
|
|
)
|
|
|
|
func writeKubernetesPKIFiles(dir string) error {
|
|
if err := os.Mkdir(dir, 0o777); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.WriteFile(filepath.Join(dir, "ca.crt"), pkiCACrt, 0o777); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.WriteFile(filepath.Join(dir, "ca.key"), pkiCAKey, 0o777); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.WriteFile(filepath.Join(dir, "front-proxy-ca.crt"), pkiFrontProxyCACrt, 0o777); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.WriteFile(filepath.Join(dir, "front-proxy-ca.key"), pkiFrontProxyCAKey, 0o777); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.WriteFile(filepath.Join(dir, "sa.key"), pkiSAKey, 0o777); err != nil {
|
|
return err
|
|
}
|
|
|
|
etcdDir := filepath.Join(dir, "etcd")
|
|
if err := os.Mkdir(etcdDir, 0o777); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.WriteFile(filepath.Join(etcdDir, "ca.crt"), pkiEtcdCACrt, 0o777); err != nil {
|
|
return err
|
|
}
|
|
|
|
return os.WriteFile(filepath.Join(etcdDir, "ca.key"), pkiEtcdCAKey, 0o777)
|
|
}
|