util

package
v0.0.0-...-ce7a364 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MPL-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsPath

func AbsPath(base string, path string) string

func AppendStringIfAbsent

func AppendStringIfAbsent(slice *[]string, valueToAdd string) bool

func AtomicWriteFile

func AtomicWriteFile(path string, writeFunc func(io.Writer) error, perm FilePerms) error

func AtomicWriteFileBytes

func AtomicWriteFileBytes(path string, content []byte, perm FilePerms) error

func Bindir

func Bindir() string

func ContainsString

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

func EllipticCurveFromString

func EllipticCurveFromString(curveName string) (elliptic.Curve, error)

func EncodeChainPem

func EncodeChainPem(writer io.Writer, crts [][]byte) error

func EncodeCombinedPem

func EncodeCombinedPem(writer io.Writer, privateKey []byte, crts [][]byte) error

func EncodeJks

func EncodeJks(rand io.Reader, writer io.Writer, creationDate time.Time, password string, privateKey []byte, leaf []byte, chain [][]byte) error

func EncodePem

func EncodePem(writer io.Writer, pemType string, bytes []byte) error

func EncodePkcs12

func EncodePkcs12(rand io.Reader, writer io.Writer, password string, privateKeyBytes []byte, leafBytes []byte, chainBytes [][]byte) error

func FileContentsAre

func FileContentsAre(path string, content []byte) bool

func FileExists

func FileExists(path string) bool

func FormatDuration

func FormatDuration(value uint, unit string) string

func FormatMoney

func FormatMoney(amount uint, currency string) string

func GetEnvDefault

func GetEnvDefault(key string, defaultValue string) string

func Getfacl

func Getfacl(path string) []string

func Homedir

func Homedir() string

func Hostname

func Hostname() string

func IsRoot

func IsRoot() bool

func JoinProse

func JoinProse(conj string, items []string) string

func LinkHeader

func LinkHeader(h http.Header, rel string) []string

LinkHeader returns URI-Reference values of all Link headers with relation-type rel. See https://tools.ietf.org/html/rfc5988#section-5 for details. This code is hardly RFC5988 compliant but if it's good enough for the Go developers I guess it's good enough for me?

func NeedsShellQuote

func NeedsShellQuote(arg string) bool

func ParseCertificates

func ParseCertificates(certsBytes [][]byte) ([]*x509.Certificate, error)

func Pluralize

func Pluralize(count uint, singular string, plural string) string

func PrintTable

func PrintTable(out io.Writer, table [][]string, columnSeparator string, firstRowIsHeader bool, alignments []int)

func PromptForBool

func PromptForBool(message string) (bool, error)

func PromptForOption

func PromptForOption(options []string) (int, error)

func PromptForPassword

func PromptForPassword(message string) (string, error)

func PromptForString

func PromptForString(message string) (string, error)

func QuoteShellArg

func QuoteShellArg(arg string) string

func QuoteShellArgIfNecessary

func QuoteShellArgIfNecessary(arg string) string

func ReadFileLines

func ReadFileLines(path string) ([]string, error)

func ReadPemFile

func ReadPemFile(filename string) (*pem.Block, error)

func ReadPrivateKeyPemFileIfExists

func ReadPrivateKeyPemFileIfExists(filename string) (*pem.Block, error)

func RemoveString

func RemoveString(slice *[]string, valueToRemove string) bool
func ReplaceSymlink(symlinkTarget string, symlinkPath string) error

func ResolveGroupname

func ResolveGroupname(groupname string) (int, error)

func ResolveUsername

func ResolveUsername(username string) (int, error)

func SelfSignCertificate

func SelfSignCertificate(key *KeyPair, request *x509.CertificateRequest, notBefore time.Time, notAfter time.Time) ([]byte, error)

func SetPermissions

func SetPermissions(path string, perm FilePerms) error

func SetSaneUmask

func SetSaneUmask()

func Setfacl

func Setfacl(path string, facls []string) error

func SortIdentifiers

func SortIdentifiers(a []Identifier)

func TryReadFile

func TryReadFile(path string) []byte

func UniqueStrings

func UniqueStrings(sortedSlice []string) []string

func UpdateFileContents

func UpdateFileContents(path string, content []byte, perm FilePerms) (bool, error)

func Username

func Username() string

func WriteFileLines

func WriteFileLines(path string, lines []string, perm FilePerms) error

func WritePemFile

func WritePemFile(filename string, exclusive bool, fileMode os.FileMode, pemBlock *pem.Block) error

Types

type FilePerms

type FilePerms struct {
	Mode  os.FileMode
	Uid   int
	Gid   int
	Facls []string
}

func GetPermissions

func GetPermissions(path string) (FilePerms, error)

type FilesystemJournal

type FilesystemJournal struct {
	BasePath        string
	FileJournalPath string
	DirJournalPath  string
}

func (*FilesystemJournal) Prepare

func (fs *FilesystemJournal) Prepare(wantedFiles map[string]bool) error

type Identifier

type Identifier struct {
	Type  string // "dns"
	Value string
}

func (*Identifier) AddToRequest

func (identifier *Identifier) AddToRequest(request *x509.CertificateRequest)

func (*Identifier) Compare

func (a *Identifier) Compare(b *Identifier) int

func (*Identifier) DNSName

func (identifier *Identifier) DNSName() string

type IdentifierSlice

type IdentifierSlice []Identifier

func (IdentifierSlice) Len

func (p IdentifierSlice) Len() int

func (IdentifierSlice) Less

func (p IdentifierSlice) Less(i, j int) bool

func (IdentifierSlice) Swap

func (p IdentifierSlice) Swap(i, j int)

type KeyPair

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

func GenerateECDSA

func GenerateECDSA(curve elliptic.Curve) *KeyPair

func GenerateRSA

func GenerateRSA(nbits int) *KeyPair

func MakeKeyPair

func MakeKeyPair(private crypto.PrivateKey) (*KeyPair, error)

func ParseAnyPrivateKey

func ParseAnyPrivateKey(der []byte) (*KeyPair, error)

func ReadAndParsePrivateKeyPemFileIfExists

func ReadAndParsePrivateKeyPemFileIfExists(filename string) (*KeyPair, error)

func (*KeyPair) Private

func (p *KeyPair) Private() crypto.PrivateKey

func (*KeyPair) PrivateBytes

func (p *KeyPair) PrivateBytes() []byte

func (*KeyPair) Public

func (p *KeyPair) Public() crypto.PublicKey

func (*KeyPair) PublicBytes

func (p *KeyPair) PublicBytes() []byte

func (*KeyPair) PublicSHA256

func (p *KeyPair) PublicSHA256() SHA256Digest

func (*KeyPair) Type

func (p *KeyPair) Type() KeyType

type KeyType

type KeyType int
const (
	KeyTypeRSA   KeyType = 0
	KeyTypeECDSA KeyType = 1
)

func KeyTypeFromString

func KeyTypeFromString(str string) (KeyType, error)

func (KeyType) Compare

func (keytype KeyType) Compare(other KeyType) int

func (KeyType) HumanString

func (keytype KeyType) HumanString() string

func (KeyType) MarshalJSON

func (keytype KeyType) MarshalJSON() ([]byte, error)

func (KeyType) String

func (keytype KeyType) String() string

func (*KeyType) UnmarshalJSON

func (keytypePtr *KeyType) UnmarshalJSON(data []byte) error

func (KeyType) X509PublicKeyAlgorithm

func (keytype KeyType) X509PublicKeyAlgorithm() x509.PublicKeyAlgorithm

type SHA256Digest

type SHA256Digest [32]byte

func Sha256sum

func Sha256sum(data []byte) SHA256Digest

func (SHA256Digest) Base64

func (digest SHA256Digest) Base64() string

func (SHA256Digest) Bytes

func (digest SHA256Digest) Bytes() []byte

func (SHA256Digest) Compare

func (digest SHA256Digest) Compare(other SHA256Digest) int

func (SHA256Digest) Equals

func (digest SHA256Digest) Equals(other SHA256Digest) bool

func (SHA256Digest) Hex

func (digest SHA256Digest) Hex() string

func (SHA256Digest) MarshalJSON

func (digest SHA256Digest) MarshalJSON() ([]byte, error)

func (*SHA256Digest) UnmarshalJSON

func (digest *SHA256Digest) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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