utils

package
v2.6.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ErrorCommandSpecific is reserved for command specific indications
	ErrorCommandSpecific = 1
	// ErrorConnectionFailure is returned on connection failure to API endpoint
	ErrorConnectionFailure = 11
	// ErrorAPIResponse is returned on unexpected API response, i.e. authorization failure
	ErrorAPIResponse = 12
	// ErrorResourceDoesNotExist is returned when the requested resource does not exist
	ErrorResourceDoesNotExist = 13
	// ErrorGeneric is returned for generic error
	ErrorGeneric = 20
)
View Source
const (
	// ArgoCDNamespace is the namespace into which Argo CD and ApplicationSet controller are deployed,
	// and in which Application resources should be created.
	ArgoCDNamespace = "argocd-e2e"

	// ApplicationSetNamespace is the namespace into which temporary resources (such as Deployments/Pods/etc)
	// can be deployed, such as using it as the target namespace in an Application resource.
	// Note: this is NOT the namespace the ApplicationSet controller is deployed to; see ArgoCDNamespace.
	ApplicationSetNamespace = "applicationset-e2e"

	TmpDir       = "/tmp/applicationset-e2e"
	TestingLabel = "e2e.argoproj.io"
)

Variables

This section is empty.

Functions

func CheckError

func CheckError(err error)

CheckError logs a fatal message and exits with ErrorGeneric if err is not nil

func CheckErrorWithCode

func CheckErrorWithCode(err error, exitcode int)

CheckErrorWithCode is a convenience function to exit if an error is non-nil and exit if it was

func DnsFriendly

func DnsFriendly(str string, postfix string) string

returns dns friends string which is no longer than 63 characters and has specified postfix at the end

func EnsureCleanState

func EnsureCleanState(t *testing.T)

EnsureCleanSlate ensures that the Kubernetes resources on the cluster are are in a 'clean' state, before a test is run.

func FailOnErr

func FailOnErr(v interface{}, err error) interface{}

FailOnErr panics if there is an error. It returns the first value so you can use it if you cast it: text := FailOrErr(Foo)).(string)

func Fatal

func Fatal(exitcode int, args ...interface{})

Fatal is a wrapper for logrus.Fatal() to exit with custom code

func Fatalf

func Fatalf(exitcode int, format string, args ...interface{})

Fatalf is a wrapper for logrus.Fatalf() to exit with custom code

func IsGitHubAPISkippedTest

func IsGitHubAPISkippedTest(t *testing.T) bool

IsGitHubSkippedTest returns true if the test should be skipped because it requires a GitHub API Token and one has not been provided. Unfortunately, GitHub Actions cannot use repository secrets, so we need to skip these tests for PRs.

Tests that call this function require a GITHUB_TOKEN to be present, otherwise they will fail, due to GitHub's rate limiting on anonymous API requests.

Note: This only applies to tests that use the GitHub API (different from GitHub's Git service)

func MustToUnstructured

func MustToUnstructured(obj interface{}) *unstructured.Unstructured

func PrettyPrintJson

func PrettyPrintJson(obj interface{}) string

PrettyPrintJson is a utility function for debugging purposes

func Run

func Run(workDir, name string, args ...string) (string, error)

func RunWithStdin

func RunWithStdin(stdin, workDir, name string, args ...string) (string, error)

func ToUnstructured

func ToUnstructured(obj interface{}) (*unstructured.Unstructured, error)

ToUnstructured converts a concrete K8s API type to an unstructured object

Types

type E2EFixtureK8sClient

type E2EFixtureK8sClient struct {
	KubeClientset    kubernetes.Interface
	DynamicClientset dynamic.Interface
	AppClientset     appclientset.Interface
	AppSetClientset  dynamic.ResourceInterface
}

E2EFixtureK8sClient contains Kubernetes clients initialized from local k8s configuration

func GetE2EFixtureK8sClient

func GetE2EFixtureK8sClient() *E2EFixtureK8sClient

GetE2EFixtureK8sClient initializes the Kubernetes clients (if needed), and returns the most recently initalized value. Note: this requires a local Kubernetes configuration (for example, while running the E2E tests).

Jump to

Keyboard shortcuts

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