From 2fc3dc94186a47bd54bbea156fcc98b51763caf6 Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Wed, 20 Sep 2023 09:49:00 -0600 Subject: [PATCH] Add provider opts to task controller: Implements provider options defined in the connection of a task CR. Signed-off-by: Jacob Weinstock --- controller/task.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/controller/task.go b/controller/task.go index 8b9b177..5894a20 100644 --- a/controller/task.go +++ b/controller/task.go @@ -94,8 +94,20 @@ func (r *TaskReconciler) doReconcile(ctx context.Context, task *v1alpha1.Task, t return ctrl.Result{}, fmt.Errorf("resolving connection secret for task %s/%s: %w", task.Namespace, task.Name, err) } + opts := &BMCOptions{} + if task.Spec.Connection.ProviderOptions != nil && task.Spec.Connection.ProviderOptions.RPC != nil { + opts.ProviderOptions = task.Spec.Connection.ProviderOptions + if len(task.Spec.Connection.ProviderOptions.RPC.HMAC.Secrets) > 0 { + se, err := retrieveHMACSecrets(ctx, r.client, task.Spec.Connection.ProviderOptions.RPC.HMAC.Secrets) + if err != nil { + return ctrl.Result{}, fmt.Errorf("unable to get hmac secrets: %w", err) + } + opts.rpcSecrets = se + } + } + // Initializing BMC Client - bmcClient, err := r.bmcClientFactory(ctx, logger, task.Spec.Connection.Host, username, password, nil) + bmcClient, err := r.bmcClientFactory(ctx, logger, task.Spec.Connection.Host, username, password, opts) if err != nil { logger.Error(err, "BMC connection failed", "host", task.Spec.Connection.Host) task.SetCondition(v1alpha1.TaskFailed, v1alpha1.ConditionTrue, v1alpha1.WithTaskConditionMessage(fmt.Sprintf("Failed to connect to BMC: %v", err)))