mock

package
v0.0.1-0...-4a2c530 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package mock implements helpers to mock infractl calls and outputs for tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InfractlCreateCluster

func InfractlCreateCluster(args ...string) (string, error)

InfractlCreateCluster is a wrapper for 'infractl create ...'.

func InfractlDeleteCluster

func InfractlDeleteCluster(clusterID string) error

InfractlDeleteCluster is a wrapper for 'infractl delete <clusterID>'.

func InfractlGetStatusForID

func InfractlGetStatusForID(clusterID string) (string, error)

InfractlGetStatusForID is a wrapper for 'infractl get <clusterID> --json'.

func InfractlLifespan

func InfractlLifespan(clusterID string, lifespanUpdate string) error

InfractlLifespan is a wrapper for 'infractl lifespan <clusterID> <lifespanUpdate>'.

func InfractlLogs

func InfractlLogs(clusterID string) (*v1.LogsResponse, error)

InfractlLogs is a wrapper for 'infractl logs <clusterID> --json'.

func InfractlWhoami

func InfractlWhoami() (string, error)

InfractlWhoami is a wrapper for 'infractl whoami'.

func PrepareCommand

func PrepareCommand(cmd *cobra.Command, asJSON bool, args ...string) *bytes.Buffer

PrepareCommand adds common flags and default args to a cobra.Command for test simulation.

func RetrieveCommandOutput

func RetrieveCommandOutput(buf *bytes.Buffer) (string, error)

RetrieveCommandOutput stringifies the contents of a buffer to read a command's output.

func RetrieveCommandOutputJSON

func RetrieveCommandOutputJSON(buf *bytes.Buffer, outJSON interface{}) error

RetrieveCommandOutputJSON parses the contents of a buffer to a map.

Types

type ClusterResponse

type ClusterResponse struct {
	ID         string
	Status     string
	Flavor     string
	Parameters []v1.Parameter
}

ClusterResponse helper maps to the JSON response for infractl operations related to clusters. We use this instead of v1.Cluster because Go cannot parse the Status string back to the enum.

func InfractlGetCluster

func InfractlGetCluster(clusterID string) (ClusterResponse, error)

InfractlGetCluster is a wrapper for 'infractl get <clusterID' --json'.

type FlavorListResponse

type FlavorListResponse struct {
	Flavors []FlavorResponse
}

FlavorListResponse maps to the JSON response for infractl flavor list operations.

func InfractlFlavorList

func InfractlFlavorList(all bool) (FlavorListResponse, error)

InfractlFlavorList is a wrapper for 'infractl flavor list --json'.

type FlavorResponse

type FlavorResponse struct {
	ID           string
	Name         string
	Description  string
	Availability string
	Parameters   map[string]v1.Parameter
	Artifacts    map[string]v1.FlavorArtifact
}

FlavorResponse maps to the JSON response for infractl flavor get operations.

func InfractlFlavorGet

func InfractlFlavorGet(flavorID string) (FlavorResponse, error)

InfractlFlavorGet is a wrapper for 'infractl flavor get <flavorID> --json'.

type JanitorFindResponse

type JanitorFindResponse struct {
	Instances map[string][]*v1.Cluster
}

JanitorFindResponse maps to the JSON response for infractl janitor find-gcp operations.

func InfractlJanitorFindGCP

func InfractlJanitorFindGCP(quiet bool) (JanitorFindResponse, error)

InfractlJanitorFindGCP is a wrapper for infractl janitor find-gcp'.

type ListClusterReponse

type ListClusterReponse struct {
	Clusters []struct {
		ID string
	}
}

ListClusterReponse maps to the JSON response for infractl list operations.

func InfractlList

func InfractlList(args ...string) (ListClusterReponse, error)

InfractlList is a wrapper for 'infractl list <args>'.

type StatusResponse

type StatusResponse struct {
	Status v1.InfraStatus
}

StatusResponse helper maps to the JSON response for infractl status operations.

type WhoamiResponse

type WhoamiResponse struct {
	Principal v1.WhoamiResponse_ServiceAccount
}

WhoamiResponse helper maps to the JSON response for infractl whoami operations.

Jump to

Keyboard shortcuts

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