util

package
v0.9.4-rc2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Device                    = "device"
	Fleet                     = "fleet"
	EnrollmentRequest         = "enrollmentrequest"
	Repository                = "repository"
	ResourceSync              = "resourcesync"
	CertificateSigningRequest = "certificatesigningrequest"

	//resource related
	ApplyAction    = "apply"
	DeviceYAMLPath = "device.yaml"
	DeviceResource = "Device"
	RepoResource   = "Repository"
	ErResource     = "EnrollmentRequest"
	FleetResource  = "Fleet"

	// events
	ForceFlag    = "-f"
	EventCreated = "created"
	EventDeleted = "deleted"
	EventUpdated = "updated"
)

Resource types

View Source
const DURATION_TIMEOUT = 5 * time.Minute
View Source
const E2E_NAMESPACE = "flightctl-e2e"
View Source
const E2E_REGISTRY_NAME = "registry"
View Source
const KIND = "KIND"
View Source
const LONGTIMEOUT = "10m"
View Source
const OCP = "OCP"
View Source
const POLLING = "250ms"
View Source
const TIMEOUT = "5m"

Variables

View Source
var DefaultSystemInfo = []string{
	"hostname",
	"kernel",
	"distroName",
	"distroVersion",
	"productName",
	"productUuid",
	"productSerial",
	"netInterfaceDefault",
	"netIpDefault",
	"netMacDefault",
}

RequiredSystemInfoKeys defines the required system info keys that should be present

Functions

func BinaryExistsOnPath added in v0.8.1

func BinaryExistsOnPath(binaryName string) bool

func CreateRepositories

func CreateRepositories(ctx context.Context, numRepositories int, storeInst store.Store, orgId uuid.UUID) error

func CreateTestDevice

func CreateTestDevice(ctx context.Context, deviceStore store.Device, orgId uuid.UUID, name string, owner *string, tv *string, labels *map[string]string)

func CreateTestDevices

func CreateTestDevices(ctx context.Context, numDevices int, deviceStore store.Device, orgId uuid.UUID, owner *string, sameVals bool)

func CreateTestDevicesWithOffset

func CreateTestDevicesWithOffset(ctx context.Context, numDevices int, deviceStore store.Device, orgId uuid.UUID, owner *string, sameVals bool, offset int)

func CreateTestEnrolmentRequests added in v0.8.1

func CreateTestEnrolmentRequests(numEnrollmentRequests int, ctx context.Context, store store.Store, orgId uuid.UUID)

func CreateTestFleet

func CreateTestFleet(ctx context.Context, fleetStore store.Fleet, orgId uuid.UUID, name string, selector *map[string]string, owner *string)

func CreateTestFleets

func CreateTestFleets(ctx context.Context, numFleets int, fleetStore store.Fleet, orgId uuid.UUID, namePrefix string, sameVals bool, owner *string)

func CreateTestOrganization added in v0.9.0

func CreateTestOrganization(ctx context.Context, storeInst store.Store, orgId uuid.UUID) error

func CreateTestResourceSyncs added in v0.8.1

func CreateTestResourceSyncs(ctx context.Context, numResourceSyncs int, storeInst store.Store, orgId uuid.UUID)

func CreateTestTemplateVersion

func CreateTestTemplateVersion(ctx context.Context, tvStore store.TemplateVersion, orgId uuid.UUID, fleet, name string, status *api.TemplateVersionStatus) error

func CreateTestTemplateVersions

func CreateTestTemplateVersions(ctx context.Context, numTemplateVersions int, tvStore store.TemplateVersion, orgId uuid.UUID, fleet string) error

func GetCurrentYearBounds added in v0.7.0

func GetCurrentYearBounds() (string, string)

GetCurrentYearBounds returns start of current and next year in RFC3339 format.

func GetEnrollmentIdFromText added in v0.2.0

func GetEnrollmentIdFromText(text string) string

GetEnrollmentIdFromText returns the enrollment ID from the given text. The enrollment ID is expected to be part of url path like https://example.com/enroll/1234

func GetExtIP

func GetExtIP() string

func GetScriptPath

func GetScriptPath(script string) string

func GetTestExamplesYamlPath added in v0.6.0

func GetTestExamplesYamlPath(yamlName string) string

func GetTopLevelDir

func GetTopLevelDir() string

func InitSuiteTracerForGinkgo added in v0.8.1

func InitSuiteTracerForGinkgo(description string) context.Context

func InitTracerForTests added in v0.8.1

func InitTracerForTests() func(context.Context) error

func NewAgentClient

func NewAgentClient(serverUrl string, caBundle []*x509.Certificate, clientCert *crypto.TLSCertificateConfig) (*agentclient.ClientWithResponses, error)

NewClient creates a new client with the given server URL and certificates. If the certs are nil a http client will be created.

func NewBackoff added in v0.6.0

func NewBackoff() wait.Backoff

func NewBareHTTPsClient

func NewBareHTTPsClient(caBundle []*x509.Certificate, clientCert *crypto.TLSCertificateConfig) (*http.Client, error)

func NewClient

func NewClient(serverUrl string, caBundle []*x509.Certificate) (*client.ClientWithResponses, error)

NewClient creates a new client with the given server URL and certificates. If the certs are nil a http client will be created.

func NewComposeSpec added in v0.6.0

func NewComposeSpec(images ...string) string

func NewPollConfig added in v0.9.0

func NewPollConfig() poll.Config

func NewTestAgentServer

func NewTestAgentServer(log logrus.FieldLogger, cfg *config.Config, store store.Store, ca *crypto.CAClient, serverCerts *crypto.TLSCertificateConfig, queuesProvider queues.Provider) (*agentserver.AgentServer, net.Listener, error)

NewTestServer creates a new test server and returns the server and the listener listening on localhost's next available port.

func NewTestApiServer

func NewTestApiServer(log logrus.FieldLogger, cfg *config.Config, store store.Store, ca *crypto.CAClient, serverCerts *crypto.TLSCertificateConfig, queuesProvider queues.Provider) (*apiserver.Server, net.Listener, error)

NewTestServer creates a new test server and returns the server and the listener listening on localhost's next available port.

func NewTestCerts

NewTestCerts creates new test certificates in the service certstore and returns the CA, server certificate, and enrollment certificate.

func NewTestProvider

func NewTestProvider(log logrus.FieldLogger) queues.Provider

func NewTestStore

func NewTestStore(ctx context.Context, cfg config.Config, log *logrus.Logger) (store.Store, string, error)

NewTestStore creates a new test store and returns the store and the database name.

func ParseURIForIPAndPort added in v0.8.1

func ParseURIForIPAndPort(rawURI string) (string, string, error)

ParseURIForIPAndPort parses a string URI and attempts to extract the IP address and port. It handles URIs with or without a scheme. If no port is specified, it attempts to deduce it from common schemes (http: 80, https: 443). If no scheme is supplied, http is assumed

func RandString added in v0.7.0

func RandString(n int) (string, error)

RandString generates a random string of length 'n' using lowercase alphabetic characters.

func ReturnTestDevice added in v0.3.0

func ReturnTestDevice(orgId uuid.UUID, name string, owner *string, tv *string, labels *map[string]string) api.Device

func RunTable added in v0.8.1

func RunTable[T any](cases []TestCase[T], runFunc func(T))

RunTable executes the provided run function for each test case in the cases slice.

func StartSpecTracerForGinkgo added in v0.8.1

func StartSpecTracerForGinkgo(parent context.Context) context.Context

func TestEnrollmentApproval

func TestEnrollmentApproval() *v1alpha1.EnrollmentRequestApproval

func TestTempEnv

func TestTempEnv(key, value string) func()

TestTempEnv sets the environment variable key to value and returns a function that will reset the environment variable to its original value.

Types

type Message added in v0.4.0

type Message string

Define a type for messages.

const (
	UpdateRenderedVersionSuccess  Message = "Updated to desired renderedVersion:"
	UpdateRenderedVersionProgress Message = "the device is upgrading to renderedVersion:"
)

func (Message) String added in v0.4.0

func (m Message) String() string

type TestCase added in v0.8.1

type TestCase[T any] struct {
	Description string
	Params      T
}

RunTable runs a table of test cases with the given run function. Each test case has a description and parameters of type T.

func Cases added in v0.8.1

func Cases[T any](items ...TestCase[T]) []TestCase[T]

Jump to

Keyboard shortcuts

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