util

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToReadBundleFile = errors.New("failed to read bundle file")
	ErrNoCertBundleFound      = errors.New("no ca bundle found")
	ErrFailedToCreateCertDir  = errors.New("failed to create cert dir")
	ErrFailedToWriteCertFile  = errors.New("failed to write cert file")
	ErrUnknownCertFileType    = errors.New("unknown cert file type")
)
View Source
var CaBundles = [][]string{
	{"/etc/ssl/certs/ca-certificates.crt"},
	{"/etc/pki/tls/certs/ca-bundle.crt", "/etc/pki/tls/certs/ca-extra.crt"},
	{"/etc/ssl/ca-bundle.pem"},
	{"/etc/pki/tls/cacert.pem"},
	{"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"},
	{"/etc/ssl/cert.pem"},
}

CaBundles paths on various systems, see https://go.dev/src/crypto/x509/root_linux.go

Functions

func CIDConfigDir

func CIDConfigDir() string

func CIDStateDir

func CIDStateDir() string

func CITempDir added in v0.6.0

func CITempDir(serviceSlug string) (string, error)

CITempDir returns a temp directory path for the given ci service slug.

func CloneMap added in v0.6.0

func CloneMap[K comparable, V any](src map[K]V) map[K]V

CloneMap returns a shallow copy of a map[K]V.

func CompactAndSort added in v0.6.0

func CompactAndSort(data []string) []string

CompactAndSort will compact and sort the given slice of strings

func DirectorySetup added in v0.6.0

func DirectorySetup()

func ExportMachineCACertsToFile

func ExportMachineCACertsToFile(target string) error

ExportMachineCACertsToFile exports the machine CA certificates to a file

func FirstNonEmpty added in v0.6.0

func FirstNonEmpty(strings []string) string

func GetCertFileByType

func GetCertFileByType(certFileType string) (string, error)

GetCertFileByType returns the cert file by type (ca-bundle, java-keystore)

func GetContainerUser

func GetContainerUser() string

GetContainerUser returns the user id and group id of the current user to mirror it in the container

func GetCurrentUser added in v0.6.0

func GetCurrentUser() user.User

func GetStringOrDefault

func GetStringOrDefault(value string, defaultValue string) string

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

MergeMaps merges multiple maps into one

func RandomUUIDWithoutDashes

func RandomUUIDWithoutDashes() string

func RegexFormat

func RegexFormat(input string, regexExpr string, outputTemplate string) (string, error)

RegexFormat will evaluate a regex expr to render a template

func ResolveEnvMap

func ResolveEnvMap(env map[string]string) map[string]string

func ResolveEnvPlaceholders added in v0.6.0

func ResolveEnvPlaceholders(value string, env map[string]string) string

func StructToJsonFile added in v0.6.0

func StructToJsonFile(registry interface{}, file string) error

func ToSemanticVersion added in v0.6.0

func ToSemanticVersion(version string) string

ToSemanticVersion converts a version string to a semantic version string.

func TrimLeftEachLine added in v0.6.0

func TrimLeftEachLine(s string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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