Skip to content

Commit

Permalink
Update Machine CRD:
Browse files Browse the repository at this point in the history
Update most all provider options to
be optional and to have the json struct tags
with `omitempty`.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Oct 23, 2024
1 parent c5afdbb commit 8096773
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 36 deletions.
52 changes: 28 additions & 24 deletions api/v1alpha1/provider_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,38 @@ import (
// RedfishOptions contains the redfish provider specific options.
type RedfishOptions struct {
// Port that redfish will use for calls.
Port int `json:"port"`
// +optional
Port int `json:"port,omitempty"`
// UseBasicAuth for redfish calls. The default is false which means token based auth is used.
UseBasicAuth bool `json:"useBasicAuth"`
// +optional
UseBasicAuth bool `json:"useBasicAuth,omitempty"`
// SystemName is the name of the system to use for redfish calls.
// With redfish implementations that manage multiple systems via a single endpoint, this allows for specifying the system to manage.
SystemName string `json:"systemName"`
// +optional
SystemName string `json:"systemName,omitempty"`
}

// IPMITOOLOptions contains the ipmitool provider specific options.
type IPMITOOLOptions struct {
// Port that ipmitool will use for calls.
// +optional
Port int `json:"port"`
Port int `json:"port,omitempty"`
// CipherSuite that ipmitool will use for calls.
// +optional
CipherSuite string `json:"cipherSuite"`
CipherSuite string `json:"cipherSuite,omitempty"`
}

// IntelAMTOptions contains the intelAMT provider specific options.
type IntelAMTOptions struct {
// Port that intelAMT will use for calls.
Port int `json:"port"`
// +optional
Port int `json:"port,omitempty"`

// HostScheme determines whether to use http or https for intelAMT calls.
// +optional
// +kubebuilder:validation:Enum=http;https
// +kubebuilder:default:=http
HostScheme string `json:"hostScheme"`
HostScheme string `json:"hostScheme,omitempty"`
}

// HMACAlgorithm is a type for HMAC algorithms.
Expand All @@ -53,72 +57,72 @@ type RPCOptions struct {
ConsumerURL string `json:"consumerURL"`
// LogNotificationsDisabled determines whether responses from rpc consumer/listeners will be logged or not.
// +optional
LogNotificationsDisabled bool `json:"logNotificationsDisabled"`
LogNotificationsDisabled bool `json:"logNotificationsDisabled,omitempty"`
// Request is the options used to create the rpc HTTP request.
// +optional
Request *RequestOpts `json:"request"`
Request *RequestOpts `json:"request,omitempty"`
// Signature is the options used for adding an HMAC signature to an HTTP request.
// +optional
Signature *SignatureOpts `json:"signature"`
Signature *SignatureOpts `json:"signature,omitempty"`
// HMAC is the options used to create a HMAC signature.
// +optional
HMAC *HMACOpts `json:"hmac"`
HMAC *HMACOpts `json:"hmac,omitempty"`
// Experimental options.
// +optional
Experimental *ExperimentalOpts `json:"experimental"`
Experimental *ExperimentalOpts `json:"experimental,omitempty"`
}

// RequestOpts are the options used when creating an HTTP request.
type RequestOpts struct {
// HTTPContentType is the content type to use for the rpc request notification.
// +optional
HTTPContentType string `json:"httpContentType"`
HTTPContentType string `json:"httpContentType,omitempty"`
// HTTPMethod is the HTTP method to use for the rpc request notification.
// +optional
HTTPMethod string `json:"httpMethod"`
HTTPMethod string `json:"httpMethod,omitempty"`
// StaticHeaders are predefined headers that will be added to every request.
// +optional
StaticHeaders http.Header `json:"staticHeaders"`
StaticHeaders http.Header `json:"staticHeaders,omitempty"`
// TimestampFormat is the time format for the timestamp header.
// +optional
TimestampFormat string `json:"timestampFormat"`
TimestampFormat string `json:"timestampFormat,omitempty"`
// TimestampHeader is the header name that should contain the timestamp. Example: X-BMCLIB-Timestamp
// +optional
TimestampHeader string `json:"timestampHeader"`
TimestampHeader string `json:"timestampHeader,omitempty"`
}

// SignatureOpts are the options used for adding an HMAC signature to an HTTP request.
type SignatureOpts struct {
// HeaderName is the header name that should contain the signature(s). Example: X-BMCLIB-Signature
// +optional
HeaderName string `json:"headerName"`
HeaderName string `json:"headerName,omitempty"`
// AppendAlgoToHeaderDisabled decides whether to append the algorithm to the signature header or not.
// Example: X-BMCLIB-Signature becomes X-BMCLIB-Signature-256
// When set to true, a header will be added for each algorithm. Example: X-BMCLIB-Signature-256 and X-BMCLIB-Signature-512
// +optional
AppendAlgoToHeaderDisabled bool `json:"appendAlgoToHeaderDisabled"`
AppendAlgoToHeaderDisabled bool `json:"appendAlgoToHeaderDisabled,omitempty"`
// IncludedPayloadHeaders are headers whose values will be included in the signature payload. Example: X-BMCLIB-My-Custom-Header
// All headers will be deduplicated.
// +optional
IncludedPayloadHeaders []string `json:"includedPayloadHeaders"`
IncludedPayloadHeaders []string `json:"includedPayloadHeaders,omitempty"`
}

// HMACOpts are the options used to create an HMAC signature.
type HMACOpts struct {
// PrefixSigDisabled determines whether the algorithm will be prefixed to the signature. Example: sha256=abc123
// +optional
PrefixSigDisabled bool `json:"prefixSigDisabled"`
PrefixSigDisabled bool `json:"prefixSigDisabled,omitempty"`
// Secrets are a map of algorithms to secrets used for signing.
// +optional
Secrets HMACSecrets `json:"secrets"`
Secrets HMACSecrets `json:"secrets,omitempty"`
}

// ExperimentalOpts are options we're still learning about and should be used carefully.
type ExperimentalOpts struct {
// CustomRequestPayload must be in json.
// +optional
CustomRequestPayload string `json:"customRequestPayload"`
CustomRequestPayload string `json:"customRequestPayload,omitempty"`
// DotPath is the path to the json object where the bmclib RequestPayload{} struct will be embedded. For example: object.data.body
// +optional
DotPath string `json:"dotPath"`
DotPath string `json:"dotPath,omitempty"`
}
6 changes: 0 additions & 6 deletions config/crd/bases/bmc.tinkerbell.org_machines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ spec:
port:
description: Port that intelAMT will use for calls.
type: integer
required:
- port
type: object
ipmitool:
description: IPMITOOL contains the options to customize the
Expand Down Expand Up @@ -120,10 +118,6 @@ spec:
description: UseBasicAuth for redfish calls. The default
is false which means token based auth is used.
type: boolean
required:
- port
- systemName
- useBasicAuth
type: object
rpc:
description: RPC contains the options to customize the RPC
Expand Down
6 changes: 0 additions & 6 deletions config/crd/bases/bmc.tinkerbell.org_tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ spec:
port:
description: Port that intelAMT will use for calls.
type: integer
required:
- port
type: object
ipmitool:
description: IPMITOOL contains the options to customize the
Expand Down Expand Up @@ -121,10 +119,6 @@ spec:
description: UseBasicAuth for redfish calls. The default
is false which means token based auth is used.
type: boolean
required:
- port
- systemName
- useBasicAuth
type: object
rpc:
description: RPC contains the options to customize the RPC
Expand Down

0 comments on commit 8096773

Please sign in to comment.