...

Package openapitest

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

Overview ▾

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`.

type FakeClient

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

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

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

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.

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

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.