mock

package
v1.28.7 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 added in v1.14.15

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 {
		Bmc          func(childComplexity int) int
		IndexInRack  func(childComplexity int) int
		Ipv4         func(childComplexity int) int
		Labels       func(childComplexity int) int
		Rack         func(childComplexity int) int
		RegisterDate func(childComplexity int) int
		RetireDate   func(childComplexity int) int
		Role         func(childComplexity int) int
		Serial       func(childComplexity int) int
	}

	MachineStatus struct {
		Duration  func(childComplexity int) int
		State     func(childComplexity int) int
		Timestamp 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 {
	Schema     *ast.Schema
	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.

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,omitempty"`
	Racks               []int          `json:"racks,omitempty"`
	Roles               []string       `json:"roles,omitempty"`
	States              []MachineState `json:"states,omitempty"`
	MinDaysBeforeRetire *int           `json:"minDaysBeforeRetire,omitempty"`
}

MachineParams is a set of input parameters to search machines.

type MachineSpec

type MachineSpec struct {
	Serial       string   `json:"serial"`
	Labels       []*Label `json:"labels,omitempty"`
	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 Query added in v1.27.3

type Query struct {
}

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