Skip to content

Commit

Permalink
logging yaml in dryRun mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslaw-pieszka committed Jul 10, 2024
1 parent af99fa7 commit ccff54d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/process/provisioning/create_runtime_resource_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ccff54d

Please sign in to comment.