From ccff54d062f058faef0c142b72c85e140211afd5 Mon Sep 17 00:00:00 2001 From: Pieszka Date: Wed, 10 Jul 2024 16:23:48 +0200 Subject: [PATCH] logging yaml in dryRun mode --- .../create_runtime_resource_step.go | 23 +++++++++++++++++++ .../create_runtime_resource_step_test.go | 1 + 2 files changed, 24 insertions(+) diff --git a/internal/process/provisioning/create_runtime_resource_step.go b/internal/process/provisioning/create_runtime_resource_step.go index 22ecfd09fc..42a42dde8a 100644 --- a/internal/process/provisioning/create_runtime_resource_step.go +++ b/internal/process/provisioning/create_runtime_resource_step.go @@ -44,10 +44,33 @@ func (s *CreateRuntimeResourceStep) Run(operation internal.Operation, log logrus log.Infof("KIM is not enabled for plan %s, skipping", broker.PlanNamesMapping[operation.ProvisioningParameters.PlanID]) } + runtimeCR, err := s.createRuntimeResourceObject(operation) + if err != nil { + return s.operationManager.OperationFailed(operation, fmt.Sprintf("while creating Runtime CR object: %s", err), err, log) + } + + if s.kimConfig.DryRun { + yaml, err := EncodeRuntimeCR(runtimeCR) + if err != nil { + log.Infof("Runtime CR yaml:%s", yaml) + } else { + log.Errorf("failed to encode Runtime CR to yaml: %s", err) + } + } else { + err := s.CreateResource(runtimeCR) + if err != nil { + return s.operationManager.OperationFailed(operation, fmt.Sprintf("while creating Runtime CR object: %s", err), err, log) + + } + } log.Info("Runtime CR creation process finished successfully") return operation, 0, nil } +func (s *CreateRuntimeResourceStep) CreateResource(cr imv1.Runtime) error { + return nil +} + //TODO remember - labels and annotations func (s *CreateRuntimeResourceStep) createRuntimeResourceObject(operation internal.Operation) (imv1.Runtime, error) { diff --git a/internal/process/provisioning/create_runtime_resource_step_test.go b/internal/process/provisioning/create_runtime_resource_step_test.go index 5243543d9c..466f01a660 100644 --- a/internal/process/provisioning/create_runtime_resource_step_test.go +++ b/internal/process/provisioning/create_runtime_resource_step_test.go @@ -28,6 +28,7 @@ func TestCreateRuntimeResourceStep_HappyPath_YamlOnly(t *testing.T) { ViewOnly: false, DryRun: true, } + step := NewCreateRuntimeResourceStep(memoryStorage.Operations(), memoryStorage.RuntimeStates(), memoryStorage.Instances(), kimConfig) // when