Documentation ¶
Index ¶
- Constants
- Variables
- func CreateDefaultJsonDir(basepath string) (string, error)
- func CreateManifestDir(path string) (string, error)
- func RegisterTinkerbellHardware(ctx context.Context, client TinkerbellHardwarePusher, serializedJsons [][]byte) error
- func Translate(reader MachineReader, writer MachineWriter, validator MachineValidator) error
- func TranslateAll(reader MachineReader, writer MachineWriter, validator MachineValidator) error
- func WithDefaultAssertions(validator *DefaultMachineValidator)
- type CsvReader
- type DefaultMachineValidator
- type Hardware
- type HardwareConfig
- func (hc *HardwareConfig) ParseHardwareConfig(hardwareFileName string) error
- func (hc *HardwareConfig) ValidateBMC() error
- func (hc *HardwareConfig) ValidateBmcSecretRefs() error
- func (hc *HardwareConfig) ValidateHardware(skipPowerActions bool, tinkHardwareMap map[string]*tinkhardware.Hardware, ...) error
- type Journal
- type Machine
- type MachineAssertion
- type MachineReader
- type MachineValidator
- type MachineWriter
- type Nameservers
- type TinkerbellHardwareJson
- type TinkerbellHardwareJsonFactory
- type TinkerbellHardwareJsonWriter
- type TinkerbellHardwarePusher
- type TinkerbellManifestYaml
Constants ¶
const DefaultHardwareManifestYamlFilename = "hardware.yaml"
DefaultHardwareManifestYamlFilename is the default file for writing yinkerbell yaml manifests
const DefaultJsonDir = "json"
DefaultJsonDir is the default directory for writing hardware json files.
const DefaultManifestDir = "hardware-manifests"
DefaultManifestDir is the default directory for writing Tinkerbell hardware files.
const NameserversSeparator = "|"
NameserversSeparator is used to unmarshal Nameservers.
Variables ¶
var ErrTinkebellHardwareJsonRepeatWrites = errors.New("TinkerbellHardwareJson can only be written to once")
ErrTinkebellHardwareJsonRepeatWrites occurs when a TinkerbellHardwareJson receives multiple calls to Write().
Functions ¶
func CreateDefaultJsonDir ¶
CreateDefaultJsonDir creates the defaut directory where hardware json files are written returning it as the string parameter.
func CreateManifestDir ¶
CreateDefaultManifestDir creates the defaut directory where hardware files are written returning it as the string parameter.
func RegisterTinkerbellHardware ¶
func RegisterTinkerbellHardware(ctx context.Context, client TinkerbellHardwarePusher, serializedJsons [][]byte) error
RegisterTinkerbellHardware uses client to push all serializedJsons representing TinkerbellHardwareJson to a Tinkerbell server.
func Translate ¶
func Translate(reader MachineReader, writer MachineWriter, validator MachineValidator) error
Translate reads 1 entry from reader and writes it to writer. When reader returns io.EOF Translate returns io.EOF to the caller.
func TranslateAll ¶
func TranslateAll(reader MachineReader, writer MachineWriter, validator MachineValidator) error
TranslateAll reads entries 1 at a time from reader and writes them to writer. When reader returns io.EOF, TranslateAll returns nil. Failure to return io.EOF from reader will result in an infinite loop.
func WithDefaultAssertions ¶
func WithDefaultAssertions(validator *DefaultMachineValidator)
WithDefaultAssertions applies a set of default assertions to validator. The default assertions include UniqueHostnames and UniqueIds.
Types ¶
type CsvReader ¶
type CsvReader struct {
// contains filtered or unexported fields
}
CsvReader reads a CSV file and provides Machine instances. It satisfies the MachineReader interface. The Id field of the Machine is optional in the CSV. If unspecified, CsvReader will generate a UUID and apply it to the machine.
func NewCsvReader ¶
NewCsvReader returns a new CsvReader instance that consumes csv data from r. r should return io.EOF when no more records are available.
func NewCsvReaderWithUUIDGenerator ¶
NewCsvReaderWithUUIDGenerator returns a new CsvReader instance as defined in NewCsvReader with its internal UUID generator configured as generator.
type DefaultMachineValidator ¶
type DefaultMachineValidator struct {
// contains filtered or unexported fields
}
DefaultMachineValidator validated Machine instances.
func NewDefaultMachineValidator ¶
func NewDefaultMachineValidator() *DefaultMachineValidator
NewDefaultMachineValidator creates a machineValidator instance with default assertions registered.
func (*DefaultMachineValidator) Register ¶
func (mv *DefaultMachineValidator) Register(v ...MachineAssertion)
Register registers v MachineAssertions with m.
func (*DefaultMachineValidator) Validate ¶
func (mv *DefaultMachineValidator) Validate(machine Machine) error
Validate validates machine by executing its Validate() method and passing it to all registered MachineAssertions.
type Hardware ¶
type Hardware struct { Id string `json:"id"` Metadata *packet.Metadata `json:"metadata"` Network *hardware.Hardware_Network `json:"network"` }
Hardware describes the hardware json structure required by the Tinkerbell API when registering hardware.
type HardwareConfig ¶
type HardwareConfig struct { Hardwares []tinkv1alpha1.Hardware Bmcs []pbnjv1alpha1.BMC Secrets []corev1.Secret }
func (*HardwareConfig) ParseHardwareConfig ¶
func (hc *HardwareConfig) ParseHardwareConfig(hardwareFileName string) error
func (*HardwareConfig) ValidateBMC ¶
func (hc *HardwareConfig) ValidateBMC() error
func (*HardwareConfig) ValidateBmcSecretRefs ¶
func (hc *HardwareConfig) ValidateBmcSecretRefs() error
func (*HardwareConfig) ValidateHardware ¶
func (hc *HardwareConfig) ValidateHardware(skipPowerActions bool, tinkHardwareMap map[string]*tinkhardware.Hardware, tinkWorkflowMap map[string]*tinkworkflow.Workflow) error
type Journal ¶
type Journal [][]byte
Journal is an io.Writer that records the byte data passed to Write() as distinct chunks.
type Machine ¶
type Machine struct { Id string `csv:"id"` IpAddress string `csv:"ip_address"` Gateway string `csv:"gateway"` Nameservers Nameservers `csv:"nameservers"` Netmask string `csv:"netmask"` MacAddress string `csv:"mac"` Hostname string `csv:"hostname"` BmcIpAddress string `csv:"bmc_ip"` BmcUsername string `csv:"bmc_username"` BmcPassword string `csv:"bmc_password"` BmcVendor string `csv:"vendor"` }
Machine is a machine configuration with optional BMC interface configuration.
type MachineAssertion ¶
MachineAssertion defines a condition that Machine must meet.
func UniqueBmcIpAddress ¶
func UniqueBmcIpAddress() MachineAssertion
UniqueBmcIpAddress asserts a given Machine instance has a unique BmcIpAddress field relative to previously seen Machine instances. If there is no Bmc configuration as defined by machine.HasBmc() the check is a noop. It is not thread safe. It has a 1 time use.
func UniqueHostnames ¶
func UniqueHostnames() MachineAssertion
UniqueHostnames asserts a given Machine instance has a unique Hostname field relative to previously seen Machine instances. It is not thread safe. It has a 1 time use.
func UniqueIds ¶
func UniqueIds() MachineAssertion
UniqueIds asserts a given Machine instance has a unique Id field relative to previously seen Machine instances. It is not thread safe. It has a 1 time use.
func UniqueIpAddress ¶
func UniqueIpAddress() MachineAssertion
UniqueIpAddress asserts a given Machine instance has a unique IpAddress field relative to previously seen Machine instances. It is not thread safe. It has a 1 time use.
func UniqueMacAddress ¶
func UniqueMacAddress() MachineAssertion
UniqueMacAddress asserts a given Machine instance has a unique MacAddress field relative to previously seen Machine instances. It is not thread safe. It has a 1 time use.
type MachineReader ¶
MachineReader reads single Machine configuration at a time. When there are no more Machine entries to be read, Read() returns io.EOF.
type MachineValidator ¶
MachineValidator validates an instance of Machine.
type MachineWriter ¶
MachineWriter writes Machine entries.
func MultiMachineWriter ¶
func MultiMachineWriter(writers ...MachineWriter) MachineWriter
MultiMachineWriter combines writers into a single MachineWriter instance. Passing no writers effectively creates a noop MachineWriter.
type Nameservers ¶
type Nameservers []string
Nameservers is a custom type that can unmarshal a CSV representation of nameservers.
func (*Nameservers) MarshalCSV ¶
func (n *Nameservers) MarshalCSV() (string, error)
MarshalCSV marshalls Nameservers into a string list of nameservers separated by NameserversSeparator.
func (*Nameservers) String ¶
func (n *Nameservers) String() string
func (*Nameservers) UnmarshalCSV ¶
func (n *Nameservers) UnmarshalCSV(s string) error
UnmarshalCSV unmarshalls s where is is a list of nameservers separated by NameserversSeparator.
type TinkerbellHardwareJson ¶
type TinkerbellHardwareJson struct {
// contains filtered or unexported fields
}
TinkerbellHardwareJson represents a discrete Tinkerbell hardware json file. It can only be written to once.
func NewTinkerbellHardwareJson ¶
func NewTinkerbellHardwareJson(w io.WriteCloser) *TinkerbellHardwareJson
NewTinkerbellHardwareJson creates a new TinkerbellHardwareJson instance that uses w as its destination for Write calls.
func (*TinkerbellHardwareJson) Write ¶
func (tj *TinkerbellHardwareJson) Write(m Machine) error
Write marshals m as a Tinkerbell hardware json object and writes it to tj's writer. Upon successfully completing the write, tj will close its writer. Subsequent calls to Write will return ErrTinkebellHardwareJsonRepeatWrites.
type TinkerbellHardwareJsonFactory ¶
type TinkerbellHardwareJsonFactory interface {
Create(name string) (*TinkerbellHardwareJson, error)
}
TinkerbellHardwareJsonFactory creates new TinkerbellHardwareJson instances.
func RecordingTinkerbellHardwareJsonFactory ¶
func RecordingTinkerbellHardwareJsonFactory(basepath string, journal *Journal) (TinkerbellHardwareJsonFactory, error)
RecordingTinkerbellHardwareJsonFactory creates a new TinkerbellHardwareJson where all writes to the TinkerbellHardwareJson are recorded in journal.
type TinkerbellHardwareJsonWriter ¶
type TinkerbellHardwareJsonWriter struct {
// contains filtered or unexported fields
}
TinkerbellHardwareJsonWriter writes discrete instances of TinkerbellHardwareJson's. Paths for files that were successfully written can be retrieved from Journal().
func NewTinkerbellHardwareJsonWriter ¶
func NewTinkerbellHardwareJsonWriter(factory TinkerbellHardwareJsonFactory) *TinkerbellHardwareJsonWriter
NewTinkerbellHardwareJsonWriter creates a newTinkerbellHardwareJsonWriter instance that uses factory to create TinkerbellHardwareJson instances and write to them.
func (*TinkerbellHardwareJsonWriter) Write ¶
func (tw *TinkerbellHardwareJsonWriter) Write(m Machine) error
Write creates a new TinkerbellHardwareJson instance and writes m to it.
type TinkerbellHardwarePusher ¶
type TinkerbellHardwarePusher interface {
PushHardware(ctx context.Context, hardware []byte) error
}
TinkerbellHardwarePusher registers hardware with a Tinkerbell stack.
type TinkerbellManifestYaml ¶
type TinkerbellManifestYaml struct {
// contains filtered or unexported fields
}
TinkerbellManifestYaml is a MachineWriter that writes Tinkerbell manifests to a destination.
func NewTinkerbellManifestYaml ¶
func NewTinkerbellManifestYaml(w io.Writer) *TinkerbellManifestYaml
NewTinkerbellManifestYaml creates a TinkerbellManifestYaml instance that writes its manifests to w.
func (*TinkerbellManifestYaml) Write ¶
func (yw *TinkerbellManifestYaml) Write(m Machine) error
Write m as a set of Kubernetes manifests for use with Cluster API Tinkerbell Provider. This includes writing a Hardware, BMC and Secret (for the BMC).