Skip to content

Commit

Permalink
Merge pull request #143 from jacobweinstock/provider-opts
Browse files Browse the repository at this point in the history
Update API with per provider opts:
  • Loading branch information
mergify[bot] authored Sep 14, 2023
2 parents bda0103 + 950d970 commit 357b551
Show file tree
Hide file tree
Showing 11 changed files with 531 additions and 58 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
.PHONY: controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.8.0)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.13.0)

KUSTOMIZE = $(shell pwd)/bin/kustomize
.PHONY: kustomize
Expand Down
22 changes: 22 additions & 0 deletions api/v1alpha1/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ const (
type MachineSpec struct {
// Connection contains connection data for a Baseboard Management Controller.
Connection Connection `json:"connection"`

// ProviderOptions contains provider specific options.
// +optional
ProviderOptions ProviderOptions `json:"providerOptions,omitempty"`
}

type ProviderOptions struct {
// IntelAMT contains the options to customize the IntelAMT provider.
// +optional
IntelAMT *IntelAMTOptions `json:"intelAMT"`

// IPMITOOL contains the options to customize the Ipmitool provider.
// +optional
IPMITOOL *IPMITOOLOptions `json:"ipmitool"`

// Redfish contains the options to customize the Redfish provider.
// +optional
Redfish *RedfishOptions `json:"redfish"`

// RPC contains the options to customize the RPC provider.
// +optional
RPC *RPCOptions `json:"rpc"`
}

// Connection contains connection data for a Baseboard Management Controller.
Expand Down
94 changes: 94 additions & 0 deletions api/v1alpha1/provider_opts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package v1alpha1

import (
"net/http"

corev1 "k8s.io/api/core/v1"
)

// RedfishOptions contains the redfish provider specific options.
type RedfishOptions struct {
// Port that redfish will use for calls.
Port int `json:"port"`
}

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

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

// HMACAlgorithm is a type for HMAC algorithms.
type HMACAlgorithm string

// HMACSecrets holds per Algorithm slice secrets.
// These secrets will be used to create HMAC signatures.
type HMACSecrets map[HMACAlgorithm][]corev1.SecretReference

// RPCOptions defines the configurable options to use when sending rpc notifications.
type RPCOptions struct {
// ConsumerURL is the URL where an rpc consumer/listener is running
// and to which we will send and receive all notifications.
ConsumerURL string `json:"consumerURL"`
// LogNotificationsDisabled determines whether responses from rpc consumer/listeners will be logged or not.
LogNotificationsDisabled bool `json:"logNotificationsDisabled"`
// Request is the options used to create the rpc HTTP request.
Request RequestOpts `json:"request"`
// Signature is the options used for adding an HMAC signature to an HTTP request.
Signature SignatureOpts `json:"signature"`
// HMAC is the options used to create a HMAC signature.
HMAC HMACOpts `json:"hmac"`
// Experimental options.
Experimental ExperimentalOpts `json:"experimental"`
}

// 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.
HTTPContentType string `json:"httpContentType"`
// HTTPMethod is the HTTP method to use for the rpc request notification.
HTTPMethod string `json:"httpMethod"`
// StaticHeaders are predefined headers that will be added to every request.
StaticHeaders http.Header `json:"staticHeaders"`
// TimestampFormat is the time format for the timestamp header.
TimestampFormat string `json:"timestampFormat"`
// TimestampHeader is the header name that should contain the timestamp. Example: X-BMCLIB-Timestamp
TimestampHeader string `json:"timestampHeader"`
}

// 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
HeaderName string `json:"headerName"`
// 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
AppendAlgoToHeaderDisabled bool `json:"appendAlgoToHeaderDisabled"`
// IncludedPayloadHeaders are headers whose values will be included in the signature payload. Example: X-BMCLIB-My-Custom-Header
// All headers will be deduplicated.
IncludedPayloadHeaders []string `json:"includedPayloadHeaders"`
}

// 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
PrefixSigDisabled bool `json:"prefixSigDisabled"`
// Secrets are a map of algorithms to secrets used for signing.
Secrets HMACSecrets `json:"secrets"`
}

// ExperimentalOpts are options we're still learning about and should be used carefully.
type ExperimentalOpts struct {
// CustomRequestPayload must be in json.
CustomRequestPayload string `json:"customRequestPayload"`
// DotPath is the path to the json object where the bmclib RequestPayload{} struct will be embedded. For example: object.data.body
DotPath string `json:"dotPath"`
}
Loading

0 comments on commit 357b551

Please sign in to comment.