util

package
v0.5.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

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

Resource types

View Source
const LONGTIMEOUT = "10m"
View Source
const POLLING = "250ms"
View Source
const TIMEOUT = "5m"

Variables

Functions

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 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 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 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 GetExamplesYamlPath added in v0.4.0

func GetExamplesYamlPath(yamlName string) string

func GetExtIP

func GetExtIP() string

func GetScriptPath

func GetScriptPath(script string) string

func GetTopLevelDir

func GetTopLevelDir() string

func NewAgentClient

func NewAgentClient(serverUrl string, caCert, 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 NewBareHTTPsClient

func NewBareHTTPsClient(caCert, clientCert *crypto.TLSCertificateConfig) (*http.Client, error)

func NewClient

func NewClient(serverUrl string, caCert *crypto.TLSCertificateConfig) (*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 NewTestAgentServer

func NewTestAgentServer(log logrus.FieldLogger, cfg *config.Config, store store.Store, ca *crypto.CA, serverCerts *crypto.TLSCertificateConfig) (*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.CA, serverCerts *crypto.TLSCertificateConfig, provider 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(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 ReturnTestDevice added in v0.3.0

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

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

Jump to

Keyboard shortcuts

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