github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/process/steps/kyma_template.go (about) 1 package steps 2 3 import ( 4 "time" 5 6 "github.com/sirupsen/logrus" 7 8 "github.com/kyma-project/kyma-environment-broker/internal" 9 "github.com/kyma-project/kyma-environment-broker/internal/process" 10 "github.com/kyma-project/kyma-environment-broker/internal/storage" 11 ) 12 13 type InitKymaTemplate struct { 14 operationManager *process.OperationManager 15 } 16 17 var _ process.Step = &InitKymaTemplate{} 18 19 func NewInitKymaTemplate(os storage.Operations) *InitKymaTemplate { 20 return &InitKymaTemplate{operationManager: process.NewOperationManager(os)} 21 } 22 23 func (s *InitKymaTemplate) Name() string { 24 return "Init_Kyma_Template" 25 } 26 27 func (s *InitKymaTemplate) Run(operation internal.Operation, logger logrus.FieldLogger) (internal.Operation, time.Duration, error) { 28 tmpl := operation.InputCreator.Configuration().KymaTemplate 29 obj, err := DecodeKymaTemplate(tmpl) 30 if err != nil { 31 logger.Errorf("Unable to create kyma template: %s", err.Error()) 32 return s.operationManager.OperationFailed(operation, "unable to create a kyma template", err, logger) 33 } 34 logger.Infof("Decoded kyma template: %v", obj) 35 return s.operationManager.UpdateOperation(operation, func(op *internal.Operation) { 36 op.KymaResourceNamespace = obj.GetNamespace() 37 op.KymaTemplate = tmpl 38 }, logger) 39 } 40 41 // NOTE: adapter for upgrade_kyma which is currently not using shared staged_manager 42 type initKymaTemplateUpgradeKyma struct { 43 *InitKymaTemplate 44 } 45 46 func InitKymaTemplateUpgradeKyma(os storage.Operations) initKymaTemplateUpgradeKyma { 47 return initKymaTemplateUpgradeKyma{NewInitKymaTemplate(os)} 48 } 49 50 func (s initKymaTemplateUpgradeKyma) Run(o internal.UpgradeKymaOperation, logger logrus.FieldLogger) (internal.UpgradeKymaOperation, time.Duration, error) { 51 operation, w, err := s.InitKymaTemplate.Run(o.Operation, logger) 52 return internal.UpgradeKymaOperation{operation}, w, err 53 }