fakekubeapi

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package fakekubeapi contains a *very* simple httptest.Server that can be used to stand in for a real Kube API server in tests.

Usage:

func TestSomething(t *testing.T) {
  resources := map[string]kubeclient.Object{
    // store preexisting resources here
    "/api/v1/namespaces/default/pods/some-pod-name": &corev1.Pod{...},
  }
  server, restConfig := fakekubeapi.Start(t, resources)
  defer server.Close()
  client := kubeclient.New(kubeclient.WithConfig(restConfig))
  // do stuff with client...
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(t *testing.T, resources map[string]runtime.Object) (*httptest.Server, *restclient.Config)

Start starts an httptest.Server (with TLS) that pretends to be a Kube API server.

The server uses the provided resources map to store API Object's. The map should be from API path to Object (e.g., /api/v1/namespaces/default/pods/some-pod-name => &corev1.Pod{}).

Start returns an already started httptest.Server and a restclient.Config that can be used to talk to the server.

Note! Only these following verbs are (partially) supported: create, get, update, delete.

Types

This section is empty.

Jump to

Keyboard shortcuts

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