mockkubeapiserver

package module
v0.0.0-...-91e5903 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Overview

Copyright 2022 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2022 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeforeHTTPOperation

type BeforeHTTPOperation interface {
	BeforeHTTPOperation(op *HTTPOperation)
}

BeforeHTTPOperation is implemented by hooks that want to be called before every HTTP operation

type Clock

type Clock interface {
	Now() metav1.Time
}

type HTTPOperation

type HTTPOperation struct {
	Request *http.Request
}

HTTPOperation contains the details of an HTTP operation

type Hook

type Hook interface {
}

Hook is the base interface implemented by a hook

type ListFilter

type ListFilter struct {
	Namespace string
}

type MemoryStorage

type MemoryStorage struct {
	// contains filtered or unexported fields
}

func NewMemoryStorage

func NewMemoryStorage(clock Clock, uidGenerator UIDGenerator) *MemoryStorage

func (*MemoryStorage) AddObject

func (s *MemoryStorage) AddObject(obj *unstructured.Unstructured) error

AddObject pre-creates an object

func (*MemoryStorage) AllResources

func (s *MemoryStorage) AllResources() []metav1.APIResource

func (*MemoryStorage) CreateObject

func (*MemoryStorage) DeleteObject

func (*MemoryStorage) FindResource

func (s *MemoryStorage) FindResource(gr schema.GroupResource) *ResourceInfo

func (*MemoryStorage) GetObject

func (*MemoryStorage) ListObjects

func (s *MemoryStorage) ListObjects(ctx context.Context, resource *ResourceInfo, filter ListFilter) (*unstructured.UnstructuredList, error)

func (*MemoryStorage) RegisterType

func (s *MemoryStorage) RegisterType(gvk schema.GroupVersionKind, resource string, scope meta.RESTScope)

RegisterType registers a type with the schema for the mock kubeapiserver

func (*MemoryStorage) UpdateObject

func (*MemoryStorage) Watch

func (s *MemoryStorage) Watch(ctx context.Context, resource *ResourceInfo, opt WatchOptions, callback WatchCallback) error

type MockKubeAPIServer

type MockKubeAPIServer struct {
	// contains filtered or unexported fields
}

func NewMockKubeAPIServer

func NewMockKubeAPIServer(addr string) (*MockKubeAPIServer, error)

func (*MockKubeAPIServer) AddHook

func (s *MockKubeAPIServer) AddHook(hook Hook)

func (*MockKubeAPIServer) AddObject

func (s *MockKubeAPIServer) AddObject(obj *unstructured.Unstructured) error

AddObject pre-creates an object

func (*MockKubeAPIServer) AddObjectsFromManifest

func (s *MockKubeAPIServer) AddObjectsFromManifest(y string) error

AddObjectsFromManifest pre-creates the objects in the manifest

func (*MockKubeAPIServer) RegisterType

func (s *MockKubeAPIServer) RegisterType(gvk schema.GroupVersionKind, resource string, scope meta.RESTScope)

RegisterType registers a type with the schema for the mock kubeapiserver

func (*MockKubeAPIServer) ServeHTTP

func (s *MockKubeAPIServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*MockKubeAPIServer) StartServing

func (s *MockKubeAPIServer) StartServing() (net.Addr, error)

func (*MockKubeAPIServer) Stop

func (s *MockKubeAPIServer) Stop() error

type RandomUIDGenerator

type RandomUIDGenerator struct {
}

func (*RandomUIDGenerator) NewUID

func (c *RandomUIDGenerator) NewUID() types.UID

type RealClock

type RealClock struct {
}

func (*RealClock) Now

func (c *RealClock) Now() metav1.Time

type Request

type Request interface {
	Run(ctx context.Context, s *MockKubeAPIServer) error
	Init(w http.ResponseWriter, r *http.Request)
}

type ResourceInfo

type ResourceInfo struct {
	API     metav1.APIResource
	GVR     schema.GroupVersionResource
	GVK     schema.GroupVersionKind
	ListGVK schema.GroupVersionKind
	// contains filtered or unexported fields
}

type TestClock

type TestClock struct {
	// contains filtered or unexported fields
}

func NewTestClock

func NewTestClock() *TestClock

func (*TestClock) Now

func (c *TestClock) Now() metav1.Time

type TestUIDGenerator

type TestUIDGenerator struct {
	// contains filtered or unexported fields
}

func NewTestUIDGenerator

func NewTestUIDGenerator() *TestUIDGenerator

func (*TestUIDGenerator) NewUID

func (c *TestUIDGenerator) NewUID() types.UID

type UIDGenerator

type UIDGenerator interface {
	NewUID() types.UID
}

type WatchCallback

type WatchCallback func(ev *watchEvent) error

type WatchOptions

type WatchOptions struct {
	Namespace string
}

Jump to

Keyboard shortcuts

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