github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/ias/builder.go (about)

     1  package ias
     2  
     3  //go:generate mockery --name=BundleBuilder --output=automock --outpkg=automock --case=underscore
     4  //go:generate mockery --name=Bundle --output=automock --outpkg=automock --case=underscore
     5  type (
     6  	BundleBuilder interface {
     7  		NewBundle(identifier string, inputID SPInputID) (Bundle, error)
     8  	}
     9  
    10  	Bundle interface {
    11  		FetchServiceProviderData() error
    12  		ServiceProviderName() string
    13  		ServiceProviderType() string
    14  		ServiceProviderExist() bool
    15  		CreateServiceProvider() error
    16  		DeleteServiceProvider() error
    17  		ConfigureServiceProvider() error
    18  		ConfigureServiceProviderType(path string) error
    19  		GenerateSecret() (*ServiceProviderSecret, error)
    20  	}
    21  )
    22  
    23  type Builder struct {
    24  	iasClient IASCLient
    25  	config    Config
    26  }
    27  
    28  func NewBundleBuilder(iasClient IASCLient, config Config) BundleBuilder {
    29  	return &Builder{
    30  		iasClient: iasClient,
    31  		config:    config,
    32  	}
    33  }
    34  
    35  func (b *Builder) NewBundle(identifier string, inputID SPInputID) (Bundle, error) {
    36  	if err := inputID.isValid(); err != nil {
    37  		return nil, err
    38  	}
    39  	return NewServiceProviderBundle(identifier, ServiceProviderInputs[inputID], b.iasClient, b.config), nil
    40  }