helpers

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

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

Contains checks if a string `s` is present in the given string slice `slice`. It iterates over each item in the slice and returns true if a match is found. If no match is found, it returns false.

func CreateTempFile added in v0.2.1

func CreateTempFile(fs afero.Fs, content string) (afero.File, error)

CreateTempFile creates a temporary file in the "/tmp" directory with a unique name that has the prefix "compare-" and suffix ".yaml". It then writes the provided content to this temporary file. The function returns a pointer to the created os.File if it succeeds. If the function fails at any step, it returns an error wrapped with context about what step of the process it failed at.

func FindHelmRepoCredentials added in v0.2.1

func FindHelmRepoCredentials(url string, credentials []models.RepoCredentials) (string, string)

FindHelmRepoCredentials scans the provided array of RepoCredentials for a match to the provided repository URL, and returns the associated username and password. If no matching credentials are found, it returns two empty strings.

func GetEnv

func GetEnv(key, fallback string) string

GetEnv retrieves the value of an environment variable specified by the given key. If the environment variable is set, its value is returned. If the environment variable is not set, the provided fallback value is returned.

func StripHelmLabels added in v0.0.5

func StripHelmLabels(file string) ([]byte, error)

StripHelmLabels removes the specified Helm labels from the content of a file. The function takes a file path as input and returns the stripped file content as a byte slice. It removes the labels listed in the `labels` slice using regular expressions. The function returns an error if there is an issue reading the file.

func WriteToFile added in v0.2.1

func WriteToFile(fs afero.Fs, file string, data []byte) error

WriteToFile writes the provided data to a file specified by the file path. It takes a file path and a byte slice of data as input. The function writes the data to the file with the specified file permissions (0644). It returns an error if there is an issue writing to the file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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