testing

package
v0.0.0-...-d92af70 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureCIDR

func EnsureCIDR(cidr string) *net.IPNet

EnsureCIDR parses/verify CIDR ip string and convert to net.IPNet

func NewFakePod

func NewFakePod(name string, netAnnotation string, defaultNetAnnotation string) *v1.Pod

NewFakePod creates fake Pod object

Types

type FakeKubeClient

type FakeKubeClient struct {
	PodCount int

	NetCount int
	// contains filtered or unexported fields
}

FakeKubeClient is stub KubeClient for testing

func NewFakeKubeClient

func NewFakeKubeClient() *FakeKubeClient

NewFakeKubeClient creates FakeKubeClient for testing

func (*FakeKubeClient) AddNetConfig

func (f *FakeKubeClient) AddNetConfig(namespace, name, data string)

AddNetConfig adds net-attach-def into its client

func (*FakeKubeClient) AddNetConfigAnnotation

func (f *FakeKubeClient) AddNetConfigAnnotation(namespace, name, data string)

AddNetConfigAnnotation adds net-attach-def into its client with an annotation

func (*FakeKubeClient) AddNetFile

func (f *FakeKubeClient) AddNetFile(namespace, name, filePath, fileData string)

AddNetFile puts config file as net-attach-def

func (*FakeKubeClient) AddPod

func (f *FakeKubeClient) AddPod(pod *v1.Pod)

AddPod adds pod into fake client

func (*FakeKubeClient) DeletePod

func (f *FakeKubeClient) DeletePod(pod *v1.Pod)

DeletePod remove pod from fake client

func (*FakeKubeClient) GetPod

func (f *FakeKubeClient) GetPod(namespace, name string) (*v1.Pod, error)

GetPod query pod by namespace/pod and return it if exists

func (*FakeKubeClient) GetRawWithPath

func (f *FakeKubeClient) GetRawWithPath(path string) ([]byte, error)

GetRawWithPath returns k8s raw data from its path

func (*FakeKubeClient) UpdatePodStatus

func (f *FakeKubeClient) UpdatePodStatus(pod *v1.Pod) (*v1.Pod, error)

UpdatePodStatus update pod status

type Result

type Result struct {
	CNIVersion string             `json:"cniVersion,omitempty"`
	IP4        *types020.IPConfig `json:"ip4,omitempty"`
	IP6        *types020.IPConfig `json:"ip6,omitempty"`
	DNS        types.DNS          `json:"dns,omitempty"`
}

Result is stub Result for testing

func (*Result) GetAsVersion

func (r *Result) GetAsVersion(version string) (types.Result, error)

GetAsVersion returns a Result object given a version

func (*Result) Print

func (r *Result) Print() error

Print prints a Result's information to std out

func (*Result) PrintTo

func (r *Result) PrintTo(writer io.Writer) error

PrintTo prints a Result's information to the provided writer

func (*Result) String

func (r *Result) String() string

String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where $1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string.

func (*Result) Version

func (r *Result) Version() string

Version returns current CNIVersion of the given Result

Jump to

Keyboard shortcuts

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