common

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KiloByte = 1000                      // kB
	KibiByte = 1024                      // KiB
	MegaByte = 1000 * 1000               // MB
	MebiByte = 1024 * 1024               // MiB
	GigaByte = 1000 * 1000 * 1000        // GB
	GibiByte = 1024 * 1024 * 1024        // GiB
	TeraByte = 1000 * 1000 * 1000 * 1000 // TB
	TebiByte = 1024 * 1024 * 1024 * 1024 // TiB

	// shorthands
	KiB = KibiByte
	MB  = MegaByte
	MiB = MebiByte
	GB  = GigaByte
	GiB = GibiByte
	TiB = TebiByte
)
View Source
const (
	FIPSEnabledImageWarning = `The host building this image is not ` +
		`running in FIPS mode. The image will still be FIPS compliant. ` +
		`If you have custom steps that generate keys or perform ` +
		`cryptographic operations, those must be considered non-compliant.`
)

Variables

View Source
var (
	// Git revision from which this code was built
	GitRev = "undefined"

	// RPM Version
	RpmVersion = "undefined"
)

These constants are set during buildtime using additional compiler flags. Not all of them are necessarily defined because RPMs can be build from a tarball and spec file without being in a git repository. On the other hand when building composer inside of a container, there is no RPM layer so in that case the RPM version doesn't exist at all.

View Source
var (
	FIPSEnabledFilePath = "/proc/sys/crypto/fips_enabled"
)

Functions

func BuildVersion

func BuildVersion() string

func DataSizeToUint64

func DataSizeToUint64(size string) (uint64, error)

DataSizeToUint64 converts a size specified as a string in KB/KiB/MB/etc. to a number of bytes represented by uint64.

func ExecError added in v0.65.0

func ExecError(err error) error

ExecError handles the error from an exec.Command().Output() call. It returns a formatted error that includes StdErr when the error is of type exec.ExitError.

func IsBuildHostFIPSEnabled added in v0.32.0

func IsBuildHostFIPSEnabled() (enabled bool)

func IsStringInSortedSlice

func IsStringInSortedSlice(slice []string, s string) bool

IsStringInSortedSlice returns true if the string is present, false if not slice must be sorted

func MountUnitNameFor added in v0.65.0

func MountUnitNameFor(mountpoint string) (string, error)

MountUnitNameFor returns the escaped name of the mount unit for a given mountpoint by calling:

systemd-escape --path --suffix=mount "mountpoint"

func NopSeekCloser

func NopSeekCloser(r io.ReadSeeker) io.ReadSeekCloser

NopSeekCloser returns an io.ReadSeekCloser with a no-op Close method wrapping the provided io.ReadSeeker r.

func PanicOnError

func PanicOnError(err error)

func ToPtr

func ToPtr[T any](x T) *T

func VersionGreaterThanOrEqual added in v0.41.0

func VersionGreaterThanOrEqual(a, b string) bool

func VersionLessThan

func VersionLessThan(a, b string) bool

Returns true if the version represented by the first argument is semantically older than the second.

Meant to be used for comparing distro versions for differences between minor releases.

Provided version strings are of any characters which are not digits or periods, and then split on periods. Assumes any missing components are 0, so 8 < 8.1. Evaluates to false if a and b are equal.

Types

type CustomJsonConversionError

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

CustomJsonConversionError is thrown when parsing strings into enumerations

func (*CustomJsonConversionError) Error

func (err *CustomJsonConversionError) Error() string

Error returns the error as a string

type CustomTypeError

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

CustomTypeError is thrown when parsing strings into enumerations

func (*CustomTypeError) Error

func (err *CustomTypeError) Error() string

Error returns the error as a string

type ImageBuildState

type ImageBuildState int
const (
	IBWaiting ImageBuildState = iota
	IBRunning
	IBFinished
	IBFailed
)

func (ImageBuildState) MarshalJSON

func (ibs ImageBuildState) MarshalJSON() ([]byte, error)

func (ImageBuildState) ToString

func (ibs ImageBuildState) ToString() string

ToString converts ImageBuildState into a human readable string

func (*ImageBuildState) UnmarshalJSON

func (ibs *ImageBuildState) UnmarshalJSON(data []byte) error

UnmarshalJSON converts a JSON string into an ImageBuildState

Jump to

Keyboard shortcuts

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