util

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 36 Imported by: 11

Documentation

Index

Constants

View Source
const EnvVarFileRefPrefix = "env://"

Variables

View Source
var (
	GitVersion = "develop" // major and minor version are obtained by parsing this (e.g. v1.2.3 -> major: 1, minor: 2)

)

Functions

func CmdExec

func CmdExec(baseCmd string, args ...string) (string, error)

func ConcatenateYAMLs

func ConcatenateYAMLs(yamls [][]byte) []byte

func ExactMatch

func ExactMatch(pattern, value string) bool

func ExactMatchWithPatternArray

func ExactMatchWithPatternArray(value string, patternArray []string) bool

func FindManifestYAML

func FindManifestYAML(concatYamlBytes, objBytes []byte, maxResourceManifestNum *int, ignoreFields []string) (bool, [][]byte)

Out of `concatYamlBytes`, find YAML manifests that are corresponding to the `objBytes`. `maxResourceManifestNum` determines how many candidate manifests can be returned. If empty, default to 3. `ignoreFields` is used for value based search, the specified fields are ignored on the comparison.

func FindYAMLsInDir

func FindYAMLsInDir(dirPath string) ([][]byte, error)

func GenerateConcatYAMLsFromImage

func GenerateConcatYAMLsFromImage(img v1.Image) ([]byte, error)

func GetAnnotationsInYAML

func GetAnnotationsInYAML(yamlBytes []byte) map[string]string

func GetBlob

func GetBlob(layer v1.Layer) ([]byte, error)

func GetCache

func GetCache(key string) ([]interface{}, error)

func GetCacheBaseDir

func GetCacheBaseDir() string

func GetHomeDir

func GetHomeDir() string

func GetImageDigest

func GetImageDigest(resBundleRef string, allowInsecure bool) (string, error)

func GetNameInfoFromCert

func GetNameInfoFromCert(cert *x509.Certificate) string

TODO: support other attributes

func GetUnionOfArrays

func GetUnionOfArrays(array1, array2 []string) []string

func GetYAMLsInArtifact

func GetYAMLsInArtifact(blob []byte) ([][]byte, error)

func GzipCompress

func GzipCompress(in []byte) []byte

func GzipDecompress

func GzipDecompress(in []byte) []byte

func IsConcatYAMLs

func IsConcatYAMLs(yaml []byte) bool

func IsDir

func IsDir(path string) (bool, error)

func IsLocalCacheEnabeld

func IsLocalCacheEnabeld() bool

func LoadFileDataInEnvVar added in v0.3.0

func LoadFileDataInEnvVar(envVarRef string) ([]byte, error)

func LoadYAMLsInDirWithMutationOptions added in v0.4.0

func LoadYAMLsInDirWithMutationOptions(dirPath string, moList ...*MutateOptions) ([][]byte, error)

func ManifestSearchByGVKNameNamespace

func ManifestSearchByGVKNameNamespace(concatYamlBytes []byte, apiVersion, kind, name, namespace string) (bool, []byte)

func ManifestSearchByValue

func ManifestSearchByValue(concatYamlBytes, objBytes []byte, maxResourceManifests *int, ignoreFields []string) (bool, [][]byte)

func MatchBigInt

func MatchBigInt(pattern string, value *big.Int) bool

func MatchPattern

func MatchPattern(pattern, value string) bool

func MatchPatternWithArray

func MatchPatternWithArray(pattern string, valueArray []string) bool

func MatchSinglePattern

func MatchSinglePattern(pattern, value string) bool

func MatchWithPatternArray

func MatchWithPatternArray(value string, patternArray []string) bool

func PullImage

func PullImage(resBundleRef string, allowInsecure bool) (v1.Image, error)

func SetCache

func SetCache(key string, value ...interface{}) error

func SplitCommaSeparatedString

func SplitCommaSeparatedString(in string) []string

func SplitConcatYAMLs

func SplitConcatYAMLs(yaml []byte) [][]byte

func SplitRule

func SplitRule(rules string) []string

func TarGzCompress

func TarGzCompress(src string, buf io.Writer, moList ...*MutateOptions) error

func TarGzDecompress

func TarGzDecompress(src io.Reader, dst string) error

Types

type AnnotationWriter

type AnnotationWriter func([]byte, map[string]interface{}) ([]byte, error)

AnnotationWriter represents the embedAnnotation function

type Cache

type Cache interface {
	Set(key string, value ...interface{}) error
	Get(key string) ([]interface{}, error)
}

type CacheType

type CacheType string
const (
	CacheTypeUnknown CacheType = ""
	CacheTypeMemory  CacheType = "memory"
	CacheTypeFile    CacheType = "file"
)

type LocalFileCache

type LocalFileCache struct {
	TTL time.Duration
	// contains filtered or unexported fields
}

func (*LocalFileCache) Get

func (c *LocalFileCache) Get(key string) ([]interface{}, error)

func (*LocalFileCache) Set

func (c *LocalFileCache) Set(key string, value ...interface{}) error

type MutateOptions

type MutateOptions struct {
	AW          AnnotationWriter
	Annotations map[string]interface{}
}

type OnMemoryCache

type OnMemoryCache struct {
	TTL time.Duration
	// contains filtered or unexported fields
}

func (*OnMemoryCache) Get

func (c *OnMemoryCache) Get(key string) ([]interface{}, error)

func (*OnMemoryCache) Set

func (c *OnMemoryCache) Set(key string, value ...interface{}) error

type ResourceInfo

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

func (ResourceInfo) Map

func (ri ResourceInfo) Map() map[string]string

type VersionInfo

type VersionInfo struct {
	Major        string `json:"Major"`
	Minor        string `json:"Minor"`
	GitVersion   string `json:"GitVersion"`
	GitCommit    string `json:"GitCommit"`
	GitTreeState string `json:"GitTreeState"`
	BuildDate    string `json:"BuildDate"`
	GoVersion    string `json:"GoVersion"`
	Compiler     string `json:"Compiler"`
	Platform     string `json:"Platform"`
}

func GetVersionInfo

func GetVersionInfo() *VersionInfo

Directories

Path Synopsis
manifestbuild
pgp

Jump to

Keyboard shortcuts

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