util

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 29 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OSToOSTypeMap map[string]params.OSType = map[string]params.OSType{
		"almalinux":  params.Linux,
		"alma":       params.Linux,
		"alpine":     params.Linux,
		"archlinux":  params.Linux,
		"arch":       params.Linux,
		"centos":     params.Linux,
		"ubuntu":     params.Linux,
		"rhel":       params.Linux,
		"suse":       params.Linux,
		"opensuse":   params.Linux,
		"fedora":     params.Linux,
		"debian":     params.Linux,
		"flatcar":    params.Linux,
		"gentoo":     params.Linux,
		"rockylinux": params.Linux,
		"rocky":      params.Linux,
		"windows":    params.Windows,
	}
)

Functions

func Aes256Decode

func Aes256Decode(target []byte, passphrase string) ([]byte, error)

func Aes256DecodeString

func Aes256DecodeString(target []byte, passphrase string) (string, error)

func Aes256Encode

func Aes256Encode(target []byte, passphrase string) ([]byte, error)

func Aes256EncodeString

func Aes256EncodeString(target string, passphrase string) ([]byte, error)

func CompressData

func CompressData(data []byte) ([]byte, error)

func ConvertFileToBase64

func ConvertFileToBase64(file string) (string, error)

func GetLoggingWriter

func GetLoggingWriter(logFile string) (io.Writer, error)

GetLoggingWriter returns a new io.Writer suitable for logging.

func GetRandomString

func GetRandomString(n int) (string, error)

GetRandomString returns a secure random string

func IsAlphanumeric

func IsAlphanumeric(s string) bool

func IsValidEmail

func IsValidEmail(email string) bool

IsValidEmail returs a bool indicating if an email is valid

func NewID

func NewID() string

func NewLoggingMiddleware

func NewLoggingMiddleware(writer io.Writer) func(http.Handler) http.Handler

func OSToOSType

func OSToOSType(os string) (params.OSType, error)

func PaswsordToBcrypt

func PaswsordToBcrypt(password string) (string, error)

PaswsordToBcrypt returns a bcrypt hash of the specified password using the default cost

func ResolveToGithubArch

func ResolveToGithubArch(arch string) (string, error)

ResolveToGithubArch returns the cpu architecture as it is defined in the GitHub tools download list. We use it to find the proper tools for the OS/Arch combo we're deploying.

func ResolveToGithubOSType

func ResolveToGithubOSType(osType string) (string, error)

ResolveToGithubArch returns the OS type as it is defined in the GitHub tools download list. We use it to find the proper tools for the OS/Arch combo we're deploying.

func ResolveToGithubTag

func ResolveToGithubTag(os params.OSType) (string, error)

ResolveToGithubTag returns the default OS tag that self hosted runners automatically (and forcefully) adds to every runner that gets deployed. We need to keep track of those tags internally as well.

func SanitizeLogEntry

func SanitizeLogEntry(entry string) string

func Seal

func Seal(data []byte, passphrase []byte) ([]byte, error)

Seal will encrypt the given data using a derived key from the given passphrase. This function is meant to be used with small datasets like passwords, keys and secrets of any type, before they are saved to disk.

func UTF16EncodedByteArrayFromString

func UTF16EncodedByteArrayFromString(s string) ([]byte, error)

func UTF16FromString

func UTF16FromString(s string) ([]uint16, error)

func UTF16ToString

func UTF16ToString(s []uint16) string

func Uint16ToByteArray

func Uint16ToByteArray(u []uint16) []byte

func Unseal

func Unseal(data []byte, passphrase []byte) ([]byte, error)

Unseal will decrypt the given data using a derived key from the given passphrase. This function is meant to be used with small datasets like passwords, keys and secrets of any type, after they are read from disk.

Types

type Envelope

type Envelope struct {
	Nonce [32]byte `json:"nonce"`
	Data  []byte   `json:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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