github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/process/deprovisioning/ias_deregistration.go (about) 1 package deprovisioning 2 3 import ( 4 "fmt" 5 "time" 6 7 "github.com/kyma-project/kyma-environment-broker/internal" 8 "github.com/kyma-project/kyma-environment-broker/internal/ias" 9 "github.com/kyma-project/kyma-environment-broker/internal/process" 10 "github.com/kyma-project/kyma-environment-broker/internal/storage" 11 12 "github.com/sirupsen/logrus" 13 ) 14 15 type IASDeregistrationStep struct { 16 operationManager *process.OperationManager 17 bundleBuilder ias.BundleBuilder 18 } 19 20 func NewIASDeregistrationStep(os storage.Operations, bundleBuilder ias.BundleBuilder) *IASDeregistrationStep { 21 return &IASDeregistrationStep{ 22 operationManager: process.NewOperationManager(os), 23 bundleBuilder: bundleBuilder, 24 } 25 } 26 27 func (s *IASDeregistrationStep) Name() string { 28 return "IAS_Deregistration" 29 } 30 31 func (s *IASDeregistrationStep) Run(operation internal.Operation, log logrus.FieldLogger) (internal.Operation, time.Duration, error) { 32 for spID := range ias.ServiceProviderInputs { 33 spb, err := s.bundleBuilder.NewBundle(operation.InstanceID, spID) 34 if err != nil { 35 log.Errorf("%s: %s", "Failed to create ServiceProvider Bundle", err) 36 return operation, 0, nil 37 } 38 39 log.Infof("Removing ServiceProvider %q from IAS", spb.ServiceProviderName()) 40 err = spb.DeleteServiceProvider() 41 if err != nil { 42 msg := fmt.Sprintf("cannot delete ServiceProvider %s", spb.ServiceProviderName()) 43 log.Errorf("%s: %s", msg, err) 44 return s.operationManager.RetryOperationWithoutFail(operation, s.Name(), msg, 5*time.Second, 5*time.Minute, log) 45 } 46 } 47 48 return operation, 0, nil 49 }