client-gok8s.io/client-go/openapi/openapitest Index | Files

package openapitest

import "k8s.io/client-go/openapi/openapitest"

Index

Functions

func NewEmbeddedFileClient

func NewEmbeddedFileClient() openapi.Client

NewEmbeddedFileClient returns a test client that uses the embedded `testdata` openapi files.

func NewFileClient

func NewFileClient(path string) openapi.Client

NewFileClient returns a test client implementing the openapi.Client interface, which serves Open API V3 specifications files from the given path, as prepared in `api/openapi-spec/v3`.

Types

type FakeClient

type FakeClient struct {
	// Hard-coded paths to return from Paths() function.
	PathsMap map[string]openapi.GroupVersion
	// Hard-coded returned error.
	ForcedErr error
}

FakeClient implements openapi.Client interface, with hard-coded return values, including the possibility to force errors.

func NewFakeClient

func NewFakeClient() *FakeClient

NewFakeClient returns a fake openapi client with an empty PathsMap.

func (FakeClient) Paths

func (f FakeClient) Paths() (map[string]openapi.GroupVersion, error)

Paths returns stored PathsMap field, creating an empty one if it does not already exist. If ForcedErr is set, this function returns the error instead.

type FakeGroupVersion

type FakeGroupVersion struct {
	// Hard-coded GroupVersion specification
	GVSpec []byte
	// Hard-coded returned error.
	ForcedErr error
}

FakeGroupVersion implements openapi.GroupVersion with hard-coded return GroupVersion specification bytes. If ForcedErr is set, then "Schema()" function returns the error instead of the GVSpec.

func (FakeGroupVersion) Schema

func (f FakeGroupVersion) Schema(contentType string) ([]byte, error)

Schema returns the hard-coded byte slice, including creating an empty slice if it has not been set yet. If the ForcedErr is set, this function returns the error instead of the GVSpec field. If content type other than application/json is passed, and error is returned.

Source Files

fakeclient.go fileclient.go

Version
v0.29.3
Published
Mar 15, 2024
Platform
js/wasm
Imports
8 packages
Last checked
6 minutes ago

Tools for package owners.