From 71a983dac0b00804a00dd1fbc801b93ff8e433fd Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Thu, 28 Sep 2023 17:40:01 -0600 Subject: [PATCH] Make RPCOptions fields pointers: This allows for the fields to not be included when nil is various applications. Signed-off-by: Jacob Weinstock --- api/v1alpha1/provider_opts.go | 8 ++++---- api/v1alpha1/zz_generated.deepcopy.go | 24 ++++++++++++++++++++---- controller/machine_test.go | 2 +- controller/task_test.go | 2 +- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/api/v1alpha1/provider_opts.go b/api/v1alpha1/provider_opts.go index 2e8c5c2..12e01d7 100644 --- a/api/v1alpha1/provider_opts.go +++ b/api/v1alpha1/provider_opts.go @@ -45,16 +45,16 @@ type RPCOptions struct { LogNotificationsDisabled bool `json:"logNotificationsDisabled"` // Request is the options used to create the rpc HTTP request. // +optional - Request RequestOpts `json:"request"` + Request *RequestOpts `json:"request"` // Signature is the options used for adding an HMAC signature to an HTTP request. // +optional - Signature SignatureOpts `json:"signature"` + Signature *SignatureOpts `json:"signature"` // HMAC is the options used to create a HMAC signature. // +optional - HMAC HMACOpts `json:"hmac"` + HMAC *HMACOpts `json:"hmac"` // Experimental options. // +optional - Experimental ExperimentalOpts `json:"experimental"` + Experimental *ExperimentalOpts `json:"experimental"` } // RequestOpts are the options used when creating an HTTP request. diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index afea220..3b5ccfa 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -495,10 +495,26 @@ func (in *ProviderOptions) DeepCopy() *ProviderOptions { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RPCOptions) DeepCopyInto(out *RPCOptions) { *out = *in - in.Request.DeepCopyInto(&out.Request) - in.Signature.DeepCopyInto(&out.Signature) - in.HMAC.DeepCopyInto(&out.HMAC) - out.Experimental = in.Experimental + if in.Request != nil { + in, out := &in.Request, &out.Request + *out = new(RequestOpts) + (*in).DeepCopyInto(*out) + } + if in.Signature != nil { + in, out := &in.Signature, &out.Signature + *out = new(SignatureOpts) + (*in).DeepCopyInto(*out) + } + if in.HMAC != nil { + in, out := &in.HMAC, &out.HMAC + *out = new(HMACOpts) + (*in).DeepCopyInto(*out) + } + if in.Experimental != nil { + in, out := &in.Experimental, &out.Experimental + *out = new(ExperimentalOpts) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RPCOptions. diff --git a/controller/machine_test.go b/controller/machine_test.go index 027ba63..10992f4 100644 --- a/controller/machine_test.go +++ b/controller/machine_test.go @@ -161,7 +161,7 @@ func createMachineWithRPC(secret *corev1.Secret) *v1alpha1.Machine { ProviderOptions: &v1alpha1.ProviderOptions{ RPC: &v1alpha1.RPCOptions{ ConsumerURL: "http://127.0.0.1:7777", - HMAC: v1alpha1.HMACOpts{ + HMAC: &v1alpha1.HMACOpts{ Secrets: v1alpha1.HMACSecrets{ "sha256": []corev1.SecretReference{ { diff --git a/controller/task_test.go b/controller/task_test.go index f49c0a3..84b51b5 100644 --- a/controller/task_test.go +++ b/controller/task_test.go @@ -276,7 +276,7 @@ func createTaskWithRPC(name string, action v1alpha1.Action, secret *corev1.Secre ProviderOptions: &v1alpha1.ProviderOptions{ RPC: &v1alpha1.RPCOptions{ ConsumerURL: "http://127.0.0.1:7777", - HMAC: v1alpha1.HMACOpts{ + HMAC: &v1alpha1.HMACOpts{ Secrets: v1alpha1.HMACSecrets{ "sha256": []corev1.SecretReference{ {