github.com/kyma-project/kyma-environment-broker@v0.0.1/cmd/subscriptioncleanup/cloudprovider/factory.go (about)

     1  package cloudprovider
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/kyma-project/kyma-environment-broker/cmd/subscriptioncleanup/model"
     7  )
     8  
     9  type ResourceCleaner interface {
    10  	Do() error
    11  }
    12  
    13  //go:generate mockery --name=ProviderFactory
    14  type ProviderFactory interface {
    15  	New(hyperscalerType model.HyperscalerType, secretData map[string][]byte) (ResourceCleaner, error)
    16  }
    17  
    18  type providerFactory struct{}
    19  
    20  func NewProviderFactory() ProviderFactory {
    21  	return &providerFactory{}
    22  }
    23  
    24  func (pf *providerFactory) New(hyperscalerType model.HyperscalerType, secretData map[string][]byte) (ResourceCleaner, error) {
    25  	switch hyperscalerType {
    26  	case model.GCP:
    27  		{
    28  			return NewGCPeResourcesCleaner(secretData), nil
    29  		}
    30  	case model.Azure:
    31  		{
    32  			return NewAzureResourcesCleaner(secretData)
    33  		}
    34  	case model.AWS:
    35  		{
    36  			return NewAwsResourcesCleaner(secretData)
    37  		}
    38  	default:
    39  		return nil, fmt.Errorf("unknown hyperscaler type")
    40  	}
    41  }