util

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package untar untars a tarball to disk.

Index

Constants

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

Variables

View Source
var Domain string

Functions

func CancelWhenSignaled

func CancelWhenSignaled(parent context.Context) context.Context

func CertsFromFile

func CertsFromFile(file string) ([]*x509.Certificate, error)

CertsFromFile returns the x509.Certificates contained in the given PEM-encoded file. Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates

func CheckInstall

func CheckInstall()

func DoCmd

func DoCmd(cmd string, args ...string)

func EncodeCertPEM

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

EncodeCertPEM returns PEM-endcoded certificate data

func EncodePrivateKeyPEM

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

EncodePrivateKeyPEM returns PEM-encoded private key data

func GetCopyright

func GetCopyright(file string) string

func GetDomain

func GetDomain() string

func GetRepo

func GetRepo() string

func LoadRepoFromGoMod

func LoadRepoFromGoMod() error

func LoadRepoFromGoPath

func LoadRepoFromGoPath() error

func LoadRepoFromGoPathOrGoMod

func LoadRepoFromGoPathOrGoMod() error

func NewCertAndKey

func NewCertAndKey(caCert *x509.Certificate, caKey *rsa.PrivateKey, config Config) (*x509.Certificate, *rsa.PrivateKey, error)

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

func NewPrivateKey

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

NewPrivateKey creates an RSA private key

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 Overwrite

func Overwrite(path, templateName, templateValue string, data interface{}) bool

Overwrite always updates the target file with the new content.

func ParseCertsPEM

func ParseCertsPEM(pemCerts []byte) ([]*x509.Certificate, error)

ParseCertsPEM returns the x509.Certificates contained in the given PEM-encoded byte array Returns an error if a certificate could not be parsed, or if the data does not contain any certificates

func ParsePrivateKeyPEM

func ParsePrivateKeyPEM(keyData []byte) (interface{}, error)

ParsePrivateKeyPEM returns a private key parsed from a PEM block in the supplied data. Recognizes PEM blocks for "EC PRIVATE KEY", "RSA PRIVATE KEY", or "PRIVATE KEY"

func PrivateKeyFromFile

func PrivateKeyFromFile(file string) (interface{}, error)

PrivateKeyFromFile returns the private key in rsa.PrivateKey or ecdsa.PrivateKey format from a given PEM-encoded file. Returns an error if the file could not be read or if the private key could not be parsed.

func SetRepo

func SetRepo(r string)

func TryLoadCertAndKeyFromDisk

func TryLoadCertAndKeyFromDisk(pkiPath, name string) (*x509.Certificate, *rsa.PrivateKey, error)

TryLoadCertAndKeyFromDisk tries to load a cert and a key from the disk and validates that they are valid

func TryLoadCertFromDisk

func TryLoadCertFromDisk(pkiPath, name string) (*x509.Certificate, error)

TryLoadCertFromDisk tries to load the cert from the disk and validates that it is valid

func TryLoadKeyFromDisk

func TryLoadKeyFromDisk(pkiPath, name string) (*rsa.PrivateKey, error)

TryLoadKeyFromDisk tries to load the key from the disk and validates that it is valid

func Untar

func Untar(r io.Reader, dir string, renderFunc map[string]func(reader io.Reader) io.Reader) error

Untar reads the gzip-compressed tar file from r and writes it into dir.

func WriteIfNotFound

func WriteIfNotFound(path, templateName, templateValue string, data interface{}) bool

writeIfNotFound returns true if the file was created and false if it already exists

Types

type AltNames

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

AltNames contains the domain names and IP addresses that will be added to the API Server's x509 certificate SubAltNames field. The values will be passed directly to the x509.Certificate object.

type Config

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

Config containes the basic fields required for creating a certificate

Jump to

Keyboard shortcuts

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