From 8096773609ddbc25a5bb6c8e6545d9e0a8abb3aa Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Wed, 23 Oct 2024 15:45:53 -0600 Subject: [PATCH] Update Machine CRD: Update most all provider options to be optional and to have the json struct tags with `omitempty`. Signed-off-by: Jacob Weinstock --- api/v1alpha1/provider_opts.go | 52 ++++++++++--------- .../bases/bmc.tinkerbell.org_machines.yaml | 6 --- .../crd/bases/bmc.tinkerbell.org_tasks.yaml | 6 --- 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/api/v1alpha1/provider_opts.go b/api/v1alpha1/provider_opts.go index c7d473a..3bc2bd8 100644 --- a/api/v1alpha1/provider_opts.go +++ b/api/v1alpha1/provider_opts.go @@ -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. @@ -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"` } diff --git a/config/crd/bases/bmc.tinkerbell.org_machines.yaml b/config/crd/bases/bmc.tinkerbell.org_machines.yaml index 39ea2b2..b52897a 100644 --- a/config/crd/bases/bmc.tinkerbell.org_machines.yaml +++ b/config/crd/bases/bmc.tinkerbell.org_machines.yaml @@ -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 @@ -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 diff --git a/config/crd/bases/bmc.tinkerbell.org_tasks.yaml b/config/crd/bases/bmc.tinkerbell.org_tasks.yaml index fffe103..76d6753 100644 --- a/config/crd/bases/bmc.tinkerbell.org_tasks.yaml +++ b/config/crd/bases/bmc.tinkerbell.org_tasks.yaml @@ -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 @@ -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