Skip to content

Commit

Permalink
Merge pull request #257 from jacobweinstock/update-crd-generation
Browse files Browse the repository at this point in the history
Update Machine CRD:

## Description

<!--- Please describe what this PR is going to change -->
Update most all provider options to be optional and to have the json struct tags with `omitempty`.

## Why is this needed

<!--- Link to issue you have raised -->

Fixes: #

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->


## How are existing users impacted? What migration steps/scripts do we need?

<!--- Fixes a bug, unblocks installation, removes a component of the stack etc -->
<!--- Requires a DB migration script, etc. -->


## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
  • Loading branch information
jacobweinstock authored Oct 23, 2024
2 parents c5afdbb + 8096773 commit adbecd0
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 adbecd0

Please sign in to comment.