fields

package
v0.0.0-...-8223eb1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AvailabilityZoneLabel = types.AvailabilityZoneLabel
	ClusterNameLabel      = types.ClusterNameLabel
	PodIDLabel            = types.PodIDLabel
)

label keys used by pod selector

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotations

type Annotations map[string]interface{}

type AvailabilityZone

type AvailabilityZone string

func (AvailabilityZone) String

func (az AvailabilityZone) String() string

type ClusterName

type ClusterName string

func (ClusterName) String

func (cn ClusterName) String() string

type ID

type ID string

Types stored in the actual pod cluster document

func (ID) String

func (id ID) String() string

type MinHealthPercentage

type MinHealthPercentage int

type PodCluster

type PodCluster struct {
	// GUID for this cluster
	ID ID

	// The ID of the pods that the cluster contains
	PodID types.PodID

	// Represents a region the pod cluster inhabits. P2 doesn't use this
	// value but it is useful for implementations that care about
	// geographical location of pod clusters
	AvailabilityZone AvailabilityZone

	// Human-readable name for the pod cluster. Must be unique within a
	// (PodID, AvailabilityZone) space
	Name ClusterName

	// Selector to identify the pods that are members of this pod cluster
	PodSelector labels.Selector

	// AllocationStrategy tweaks certain characteristic about how pods
	// within this cluster are managed. For example the "static" strategy will
	// never transfer a pod from one node to another without human
	// intervention whereas the "dynamic" strategy will
	AllocationStrategy rc_fields.Strategy

	// Free-form annotations for implementation-specific information on top
	// of pod clusters
	Annotations Annotations

	// Minimum health percentage that this pod cluster should have
	MinHealthPercentage MinHealthPercentage
}

func (*PodCluster) Equals

func (pc *PodCluster) Equals(other *PodCluster) bool

func (PodCluster) MarshalJSON

func (pc PodCluster) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for serializing the PodCluster to JSON format.

The PodCluster struct contains a labels.Selector interface, and unmarshaling into a nil, non-empty interface is impossible (unless the value is a JSON null), because the unmarshaler doesn't know what structure to allocate there. Since we don't own labels.Selector, we have to implement the json marshaling here to wrap around the interface value

func (PodCluster) ToRaw

func (pc PodCluster) ToRaw() RawPodCluster

Converts a pod cluster to a type that will marshal cleanly to JSON.

func (*PodCluster) UnmarshalJSON

func (pc *PodCluster) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for deserializing the JSON representation of an PodCluster.

type RawPodCluster

type RawPodCluster struct {
	ID                  ID                  `json:"id"`
	PodID               types.PodID         `json:"pod_id"`
	AvailabilityZone    AvailabilityZone    `json:"availability_zone"`
	Name                ClusterName         `json:"name"`
	PodSelector         string              `json:"pod_selector"`
	Annotations         Annotations         `json:"annotations"`
	AllocationStrategy  rc_fields.Strategy  `json:"allocation_strategy"`
	MinHealthPercentage MinHealthPercentage `json:"min_health_percentage"`
}

Unfortunately due to weirdness of marshaling label selectors, we have to implement it ourselves. RawPodCluster mimics PodCluster but has a string type for PodSelector instead of labels.Selector

Jump to

Keyboard shortcuts

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