apis

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 34 Imported by: 0

README

K8s integration tests

This directory contains integration tests the k8s api services

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnyResource

type AnyResource struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// Generic object
	Spec map[string]any `json:"spec,omitempty"`
}

type AnyResourceList

type AnyResourceList struct {
	metav1.TypeMeta `json:",inline"`
	// +optional
	metav1.ListMeta `json:"metadata,omitempty"`

	Items []map[string]any `json:"items,omitempty"`
}

type AnyResourceListResponse

type AnyResourceListResponse = K8sResponse[AnyResourceList]

type AnyResourceResponse

type AnyResourceResponse = K8sResponse[AnyResource]

type K8sResourceClient

type K8sResourceClient struct {
	Args     ResourceClientArgs
	Resource dynamic.ResourceInterface
	// contains filtered or unexported fields
}

func (*K8sResourceClient) SanitizeJSON

func (c *K8sResourceClient) SanitizeJSON(v *unstructured.Unstructured) string

remove the meta keys that are expected to change each time

type K8sResponse

type K8sResponse[T any] struct {
	Response *http.Response
	Body     []byte
	Result   *T
	Status   *metav1.Status
}

func DoRequest

func DoRequest[T any](c *K8sTestHelper, params RequestParams, result *T) K8sResponse[T]

type K8sTestHelper

type K8sTestHelper struct {
	Org1 OrgUsers // default
	OrgB OrgUsers // some other id
	// contains filtered or unexported fields
}

func NewK8sTestHelper

func NewK8sTestHelper(t *testing.T, opts testinfra.GrafanaOpts) *K8sTestHelper

func (*K8sTestHelper) AsStatusError

func (c *K8sTestHelper) AsStatusError(err error) *errors.StatusError

Cast the error to status error

func (*K8sTestHelper) CreateDS

func (*K8sTestHelper) GetGroupVersionInfoJSON

func (c *K8sTestHelper) GetGroupVersionInfoJSON(group string) string

func (*K8sTestHelper) GetResourceClient

func (c *K8sTestHelper) GetResourceClient(args ResourceClientArgs) *K8sResourceClient

This will set the expected Group/Version/Resource and return the discovery info if found

func (*K8sTestHelper) List

func (*K8sTestHelper) LoadYAMLOrJSON

func (c *K8sTestHelper) LoadYAMLOrJSON(body string) *unstructured.Unstructured

Read local JSON or YAML file into a resource

func (*K8sTestHelper) LoadYAMLOrJSONFile

func (c *K8sTestHelper) LoadYAMLOrJSONFile(fpath string) *unstructured.Unstructured

Read local JSON or YAML file into a resource

func (*K8sTestHelper) NewDiscoveryClient

func (c *K8sTestHelper) NewDiscoveryClient() *discovery.DiscoveryClient

func (*K8sTestHelper) PostResource

func (c *K8sTestHelper) PostResource(user User, resource string, payload AnyResource) AnyResourceResponse

func (*K8sTestHelper) PutResource

func (c *K8sTestHelper) PutResource(user User, resource string, payload AnyResource) AnyResourceResponse

func (*K8sTestHelper) Shutdown

func (c *K8sTestHelper) Shutdown()

type OrgUsers

type OrgUsers struct {
	Admin  User
	Editor User
	Viewer User
}

type RequestParams

type RequestParams struct {
	User        User
	Method      string // GET, POST, PATCH, etc
	Path        string
	Body        []byte
	ContentType string
	Accept      string
}

type ResourceClientArgs

type ResourceClientArgs struct {
	User      User
	Namespace string
	GVR       schema.GroupVersionResource
}

type User

type User struct {
	Identity identity.Requester
	// contains filtered or unexported fields
}

func (*User) NewRestConfig

func (c *User) NewRestConfig() *rest.Config

func (*User) RESTClient

func (c *User) RESTClient(t *testing.T, gv *schema.GroupVersion) *rest.RESTClient

Jump to

Keyboard shortcuts

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