Documentation
¶
Index ¶
- Constants
- func CreateBundle(ctx context.Context, k8sClient client.Client, name, namespace string, ...) (*v1alpha1.Bundle, error)
- func CreateCluster(ctx context.Context, k8sClient client.Client, name, controllerNs string, ...) (*v1alpha1.Cluster, error)
- func CreateGogsContainerWithHTTPS(ctx context.Context, assetPath string) (testcontainers.Container, []byte, *gogs.Client, error)
- func CreateTempFolder(prefix string) string
- func DisableReaper()
- func ExtractResourceLogs(allLogs, resourceName string) string
- func FromEnvTestConfig(cfg *rest.Config) []byte
- func GetGogsHTTPSURL(ctx context.Context, container testcontainers.Container) (string, error)
- func GetGogsKnownHostEntry(ctx context.Context, container testcontainers.Container) (string, error)
- func GetGogsSSHURL(ctx context.Context, container testcontainers.Container) (string, error)
- func MakeSSHKeyPair() (publicKey, privateKey string, _ error)
- func NewClient(cfg *rest.Config) (client.Client, error)
- func NewEnvTest(root string) *envtest.Environment
- func NewManager(cfg *rest.Config) (ctrl.Manager, error)
- func NewNamespaceName() (string, error)
- func ShouldSuppressLogs() bool
- func StartTestEnv(testEnv *envtest.Environment) (*rest.Config, error)
- func SuppressLogs()
- func WriteKubeConfig(cfg *rest.Config, path string) error
Constants ¶
const ( Timeout = 30 * time.Second PollingInterval = 3 * time.Second )
const ( GogsUser = "test" GogsPass = "pass" GogsHTTPSPort = "3000" GogsSSHPort = "22" )
Variables ¶
This section is empty.
Functions ¶
func CreateBundle ¶
func CreateCluster ¶
func CreateGogsContainerWithHTTPS ¶
func CreateGogsContainerWithHTTPS(ctx context.Context, assetPath string) (testcontainers.Container, []byte, *gogs.Client, error)
CreateGogsContainerWithHTTPS starts a gogs container backed by assetPath, generates a TLS certificate, and waits until the HTTPS endpoint accepts connections. It returns the container, the CA bundle PEM bytes, and an authenticated gogs client. assetPath must be the gitserver directory to bind-mount into the container at /data.
func CreateTempFolder ¶
CreateTempFolder returns a temporary directory for test data. On GitHub Actions, os.MkdirTemp is used to avoid cleanup failures; locally GinkgoT().TempDir() is used so Ginkgo cleans up automatically.
func DisableReaper ¶
func DisableReaper()
DisableReaper disables the testcontainers reaper (Ryuk) to avoid issues with Docker container state in local development environments. The reaper is mainly useful in CI but often causes race conditions locally. This should be called in init() functions of test packages that use testcontainers.
func ExtractResourceLogs ¶
ExtractResourceLogs extracts log lines related to a specific resource name
func FromEnvTestConfig ¶
FromEnvTestConfig returns a new Kubeconfig in byte form when running in envtest.
func GetGogsHTTPSURL ¶
GetGogsHTTPSURL returns the mapped HTTPS base URL for a running gogs container.
func GetGogsKnownHostEntry ¶
GetGogsKnownHostEntry reads the container's SSH ECDSA host public key and returns a known_hosts format line suitable for use with CreateKnownHostsCallBack.
func GetGogsSSHURL ¶
GetGogsSSHURL returns the mapped SSH base URL for a running gogs container.
func MakeSSHKeyPair ¶
MakeSSHKeyPair generates an RSA-4096 key pair for git SSH authentication. Returns the public key in authorized_keys format and the private key in PEM format.
func NewEnvTest ¶
func NewEnvTest(root string) *envtest.Environment
NewEnvTest returns a new envtest with the Fleet CRDs loaded. Run ginkgo with the -v flag to see the logs in real time.
func NewManager ¶
NewManager returns a new controller-runtime manager suitable for testing.
func NewNamespaceName ¶
func ShouldSuppressLogs ¶
func ShouldSuppressLogs() bool
ShouldSuppressLogs checks if logs should be suppressed based on the VERBOSE environment variable. Returns true when VERBOSE is not set (suppress logs), false when VERBOSE=1 (show all logs).
func StartTestEnv ¶
func StartTestEnv(testEnv *envtest.Environment) (*rest.Config, error)
func SuppressLogs ¶
func SuppressLogs()
SuppressLogs suppresses log output during integration tests unless VERBOSE=1 is set. This filters expected test warnings and informational messages to keep test output clean. To see all logs during debugging, run tests with: VERBOSE=1 go test ...
This suppresses: - Go standard library logger (log package) - used by Helm SDK for warnings - Logrus logger - used by Fleet components for info/debug messages
Types ¶
This section is empty.