mock

package
v1.14.6 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewExecutableSchema

func NewExecutableSchema(cfg Config) graphql.ExecutableSchema

NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.

func Server

func Server() *httptest.Server

Server creates a mock server that implements sabakan GraphQL API.

Types

type BMC

type BMC struct {
	BmcType string `json:"bmcType"`
	Ipv4    string `json:"ipv4"`
}

BMC represents a Baseboard Management Controller.

type ComplexityRoot

type ComplexityRoot struct {
	Bmc struct {
		BmcType func(childComplexity int) int
		Ipv4    func(childComplexity int) int
	}

	Label struct {
		Name  func(childComplexity int) int
		Value func(childComplexity int) int
	}

	Machine struct {
		Spec   func(childComplexity int) int
		Status func(childComplexity int) int
	}

	MachineSpec struct {
		Serial       func(childComplexity int) int
		Labels       func(childComplexity int) int
		Rack         func(childComplexity int) int
		IndexInRack  func(childComplexity int) int
		Role         func(childComplexity int) int
		Ipv4         func(childComplexity int) int
		RegisterDate func(childComplexity int) int
		RetireDate   func(childComplexity int) int
		Bmc          func(childComplexity int) int
	}

	MachineStatus struct {
		State     func(childComplexity int) int
		Timestamp func(childComplexity int) int
		Duration  func(childComplexity int) int
	}

	Query struct {
		Machine        func(childComplexity int, serial string) int
		SearchMachines func(childComplexity int, having *MachineParams, notHaving *MachineParams) int
	}
}

type Config

type Config struct {
	Resolvers  ResolverRoot
	Directives DirectiveRoot
	Complexity ComplexityRoot
}

type DirectiveRoot

type DirectiveRoot struct {
}

type Label

type Label struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Label represents an arbitrary key-value pairs.

type LabelInput

type LabelInput struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

LabelInput represents a label to search machines.

func UnmarshalLabelInput

func UnmarshalLabelInput(v interface{}) (LabelInput, error)

type Machine

type Machine struct {
	Spec   MachineSpec   `json:"spec"`
	Status MachineStatus `json:"status"`
}

Machine represents a physical server in a datacenter rack.

type MachineParams

type MachineParams struct {
	Labels              []LabelInput   `json:"labels"`
	Racks               []int          `json:"racks"`
	Roles               []string       `json:"roles"`
	States              []MachineState `json:"states"`
	MinDaysBeforeRetire *int           `json:"minDaysBeforeRetire"`
}

MachineParams is a set of input parameters to search machines.

func UnmarshalMachineParams

func UnmarshalMachineParams(v interface{}) (MachineParams, error)

type MachineSpec

type MachineSpec struct {
	Serial       string   `json:"serial"`
	Labels       []Label  `json:"labels"`
	Rack         int      `json:"rack"`
	IndexInRack  int      `json:"indexInRack"`
	Role         string   `json:"role"`
	Ipv4         []string `json:"ipv4"`
	RegisterDate string   `json:"registerDate"`
	RetireDate   string   `json:"retireDate"`
	Bmc          BMC      `json:"bmc"`
}

MachineSpec represents specifications of a machine.

type MachineState

type MachineState string

MachineState enumerates machine states.

const (
	MachineStateUninitialized MachineState = "UNINITIALIZED"
	MachineStateHealthy       MachineState = "HEALTHY"
	MachineStateUnhealthy     MachineState = "UNHEALTHY"
	MachineStateUnreachable   MachineState = "UNREACHABLE"
	MachineStateUpdating      MachineState = "UPDATING"
	MachineStateRetiring      MachineState = "RETIRING"
	MachineStateRetired       MachineState = "RETIRED"
)

func (MachineState) IsValid

func (e MachineState) IsValid() bool

func (MachineState) MarshalGQL

func (e MachineState) MarshalGQL(w io.Writer)

func (MachineState) String

func (e MachineState) String() string

func (*MachineState) UnmarshalGQL

func (e *MachineState) UnmarshalGQL(v interface{}) error

type MachineStatus

type MachineStatus struct {
	State     MachineState `json:"state"`
	Timestamp string       `json:"timestamp"`
	Duration  float64      `json:"duration"`
}

MachineStatus represents status of a Machine.

type QueryResolver

type QueryResolver interface {
	Machine(ctx context.Context, serial string) (Machine, error)
	SearchMachines(ctx context.Context, having *MachineParams, notHaving *MachineParams) ([]Machine, error)
}

type ResolverRoot

type ResolverRoot interface {
	Query() QueryResolver
}

Jump to

Keyboard shortcuts

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