utils

package
v1.0.0-alpha.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2020 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ECPrivateKeyBlockType       = "EC PRIVATE KEY"
	RSAPrivateKeyBlockType      = "RSA PRIVATE KEY"
	PrivateKeyBlockType         = "PRIVATE KEY"
	CertificateBlockType        = "CERTIFICATE"
	CertificateRequestBlockType = "CERTIFICATE REQUEST"

	AdminKubeConfigFileName             = "admin.conf"
	ControllerManagerKubeConfigFileName = "controller-manager.conf"
	SchedulerKubeConfigFileName         = "scheduler.conf"
	DefaultServerUrl                    = "https://127.0.0.1:6443"
)

Variables

View Source
var MatrixClient = make(map[string]runtimeclient.Client)

Functions

func Base64Decode

func Base64Decode(str string) ([]byte, error)

func Base64Encode

func Base64Encode(bytes []byte) string

func ContainsString

func ContainsString(slice []string, s string) bool

func CreateAdminKubeconfig

func CreateAdminKubeconfig(caCert *x509.Certificate, caKey *rsa.PrivateKey, serverUrl string) ([]byte, error)

func CreateBasic

func CreateBasic(serverURL, clusterName, userName string, caCert []byte) *clientcmdapi.Config

func CreateControllerManagerKUbeconfig

func CreateControllerManagerKUbeconfig(caCert *x509.Certificate, caKey *rsa.PrivateKey, serverUrl string) ([]byte, error)

func CreateKubeconfigWithCerts

func CreateKubeconfigWithCerts(serverURL, clusterName, userName string, caCert []byte, clientKey []byte, clientCert []byte) *clientcmdapi.Config

func CreateSchedulerKubeconfig

func CreateSchedulerKubeconfig(caCert *x509.Certificate, caKey *rsa.PrivateKey, serverUrl string) ([]byte, error)

func EncodeCertPEM

func EncodeCertPEM(cert *x509.Certificate) []byte

func EncodePrivateKeyPEM

func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte

func EncodePublicKeyPEM

func EncodePublicKeyPEM(key *rsa.PublicKey) ([]byte, error)

func ExecCmd

func ExecCmd(shell string, cmdStr string) (string, error)

func Exists

func Exists(path string) bool

func GenerateCaCert

func GenerateCaCert(cfg Config) (*x509.Certificate, *rsa.PrivateKey, error)

func GenerateCert

func GenerateCert(cfg Config, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*x509.Certificate, *rsa.PrivateKey, error)

func GenerateServiceAccountKey

func GenerateServiceAccountKey() (*rsa.PrivateKey, error)

func GetCrdClient

func GetCrdClient(kubeconfig []byte) (*crdclient.Clientset, error)

func GetRuntimeClient

func GetRuntimeClient(kubeconfig []byte) (runtimeclient.Client, error)

func IgnoreAlreadyExist

func IgnoreAlreadyExist(err error) error

func IgnoreNotFound

func IgnoreNotFound(err error) error

func InitMatrixClient

func InitMatrixClient(mcClient runtimeclient.Client, ctx context.Context, matrixName string, namespace string) error

func NewPrivateKey

func NewPrivateKey() (*rsa.PrivateKey, error)

func NewSelfSignedCACert

func NewSelfSignedCACert(cfg Config, key *rsa.PrivateKey) (*x509.Certificate, error)

NewSelfSignedCACert creates a CA certificate

func NewServiceAccountSigningKey

func NewServiceAccountSigningKey() (*rsa.PrivateKey, error)

func NewSignedCert

func NewSignedCert(cfg Config, key *rsa.PrivateKey, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*x509.Certificate, error)

NewSignedCert creates a signed certificate using the given CA certificate and key

func ParseTemplate

func ParseTemplate(strtmpl string, obj ...interface{}) ([]byte, error)

func RemoveString

func RemoveString(slice []string, s string) (result []string)

func Telnet

func Telnet(host string, port string) bool

func WriteFile

func WriteFile(fileName string, b []byte) error

Types

type AltNames

type AltNames struct {
	DNSNames []string
	IPs      []net.IP
}

type Config

type Config struct {
	CommonName   string
	Organization []string
	AltNames     AltNames
	Usages       []x509.ExtKeyUsage
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL