utils

package
v0.0.0-...-c8dc4db Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ECPrivateKeyBlockType is a possible value for pem.Block.Type.
	ECPrivateKeyBlockType = "EC PRIVATE KEY"
	// PrivateKeyBlockType is a possible value for pem.Block.Type.
	PrivateKeyBlockType = "PRIVATE KEY"
	// PublicKeyBlockType is a possible value for pem.Block.Type.
	PublicKeyBlockType = "PUBLIC KEY"
	// CertificateBlockType is a possible value for pem.Block.Type.
	CertificateBlockType = "CERTIFICATE"
	// RSAPrivateKeyBlockType is a possible value for pem.Block.Type.
	RSAPrivateKeyBlockType = "RSA PRIVATE KEY"

	// CertificateValidity defines the validity for all the signed certificates generated by kubeadm
	CertificateValidity = time.Hour * 24 * 365 * 10
)
View Source
const DetermRandIter = 2048
View Source
const (
	SystemPrivilegedGroup = "system:masters"
)

Variables

View Source
var ErrInvalidRemoteFormat = errors.New("invalid remote, should be format like LocalHost:LocalPort:RemoteHost:RemotePort")
View Source
var ErrInvalidRemoteValue = errors.New("invalid port number or host")
View Source
var ErrorInvalidConnection = errors.New("invalid connection")

Functions

func BuildKubeConfigFromSpec

func BuildKubeConfigFromSpec(spec *KubeConfigSpec, clustername string) (*clientcmdapi.Config, error)

func CreateBasic

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

CreateBasic creates a basic, general KubeConfig object that then can be extended

func CreateWithCerts

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

CreateWithCerts creates a KubeConfig object with access to the API server with client certificates

func EncodeCertPEM

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

EncodeCertPEM returns PEM-endcoded certificate data

func EncodePublicKeyPEM

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

EncodePublicKeyPEM returns PEM-encoded public data

func FingerprintKey

func FingerprintKey(k ssh.PublicKey) string

func GenerateCACertificateAndWriteToFile

func GenerateCACertificateAndWriteToFile(caCert, caKey string) error

func GenerateKey

func GenerateKey(seed string) ([]byte, error)

func GenerateKubeconfig

func GenerateKubeconfig(clustername string, server string, caFile, keyFile string) (*clientcmdapi.Config, error)

func HandleTCPStream

func HandleTCPStream(src io.ReadWriteCloser, remote string)

func LoadCaAuthorityCertAndKey

func LoadCaAuthorityCertAndKey(caCert, caKey string) (*x509.Certificate, crypto.Signer, error)

func NewCertAndKey

func NewCertAndKey(caCert *x509.Certificate, caKey crypto.Signer, config *certutil.Config) (*x509.Certificate, crypto.Signer, error)

NewCertAndKey creates new certificate and key by passing the certificate authority certificate and key

func NewCertificateAuthority

func NewCertificateAuthority(config *certutil.Config) (*x509.Certificate, crypto.Signer, error)

func NewDetermRand

func NewDetermRand(seed []byte) io.Reader

func NewPrivateKey

func NewPrivateKey() (crypto.Signer, error)

NewPrivateKey creates an RSA private key

func NewSignedCert

func NewSignedCert(cfg *certutil.Config, key crypto.Signer, caCert *x509.Certificate, caKey crypto.Signer) (*x509.Certificate, error)

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

func NewSshConn

func NewSshConn(conn GetSSHConn, remote string) net.Conn

func NewWebSocketConn

func NewWebSocketConn(websocketConn *websocket.Conn) net.Conn

func Pipe

func Pipe(src io.ReadWriteCloser, dst io.ReadWriteCloser) (int64, int64)

Types

type Agents

type Agents struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func FakeAgents

func FakeAgents() *Agents

func NewAgents

func NewAgents() *Agents

func (*Agents) Add

func (g *Agents) Add(agent *v1alpha1.Agent)

Add adds an agent to the list

func (*Agents) Del

func (g *Agents) Del(key string)

Delete an agent from the list

func (*Agents) Get

func (g *Agents) Get(key string) (*v1alpha1.Agent, bool)

Get agent from the index by key

func (*Agents) Len

func (g *Agents) Len() int

Len returns the number of agents

func (*Agents) Set

func (g *Agents) Set(key string, agent *v1alpha1.Agent)

Set an agent into the list by specific key

type DetermRand

type DetermRand struct {
	// contains filtered or unexported fields
}

func (*DetermRand) Read

func (d *DetermRand) Read(b []byte) (int, error)

type GetSSHConn

type GetSSHConn func() ssh.Conn

type KubeConfigIssuer

type KubeConfigIssuer interface {
	IssueKubeConfig(clustername string, proxyPort uint16) ([]byte, error)
}

func NewSimpleKubeConfigIssuer

func NewSimpleKubeConfigIssuer(caCert, caKey, proxyServer string) (KubeConfigIssuer, error)

type KubeConfigSpec

type KubeConfigSpec struct {
	CACert         *x509.Certificate
	APIServer      string
	ClientName     string
	ClientCertAuth *clientCertAuth
}

type Remote

type Remote struct {
	LocalHost, LocalPort, RemoteHost, RemotePort string
}

Remote represents address forwarding, format like following LocalHost:LocalPort:RemoteHost:RemotePort

func DecodeRemote

func DecodeRemote(s string) (*Remote, error)

func (*Remote) Local

func (r *Remote) Local() string

func (*Remote) Remote

func (r *Remote) Remote() string

type SshConn

type SshConn struct {
	// contains filtered or unexported fields
}

func (*SshConn) Close

func (s *SshConn) Close() error

func (*SshConn) LocalAddr

func (s *SshConn) LocalAddr() net.Addr

func (*SshConn) Network

func (s *SshConn) Network() string

func (*SshConn) Read

func (s *SshConn) Read(b []byte) (n int, err error)

func (*SshConn) RemoteAddr

func (s *SshConn) RemoteAddr() net.Addr

func (*SshConn) SetDeadline

func (s *SshConn) SetDeadline(t time.Time) error

func (*SshConn) SetReadDeadline

func (s *SshConn) SetReadDeadline(t time.Time) error

func (*SshConn) SetWriteDeadline

func (s *SshConn) SetWriteDeadline(t time.Time) error

func (*SshConn) String

func (s *SshConn) String() string

func (*SshConn) Write

func (s *SshConn) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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