Skip to content

Commit

Permalink
Add provider opts to task controller:
Browse files Browse the repository at this point in the history
Implements provider options defined in
the connection of a task CR.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Sep 20, 2023
1 parent 70c2f54 commit 2fc3dc9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion controller/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 2fc3dc9

Please sign in to comment.