github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/model/bundle_references.go (about)

     1  package model
     2  
     3  import "github.com/pkg/errors"
     4  
     5  // BundleReference missing godoc
     6  type BundleReference struct {
     7  	ID                  string
     8  	BundleID            *string
     9  	ObjectType          BundleReferenceObjectType
    10  	ObjectID            *string
    11  	APIDefaultTargetURL *string
    12  	IsDefaultBundle     *bool
    13  }
    14  
    15  // BundleReferenceObjectType missing godoc
    16  type BundleReferenceObjectType string
    17  
    18  const (
    19  	// BundleAPIReference missing godoc
    20  	BundleAPIReference BundleReferenceObjectType = "API"
    21  	// BundleEventReference missing godoc
    22  	BundleEventReference BundleReferenceObjectType = "Event"
    23  )
    24  
    25  // BundleReferenceInput missing godoc
    26  type BundleReferenceInput struct {
    27  	APIDefaultTargetURL *string
    28  	IsDefaultBundle     *bool
    29  }
    30  
    31  // ToBundleReference missing godoc
    32  func (b *BundleReferenceInput) ToBundleReference(id string, objectType BundleReferenceObjectType, bundleID, objectID *string) (*BundleReference, error) {
    33  	if b == nil {
    34  		return nil, nil
    35  	}
    36  
    37  	if objectType == BundleAPIReference && b.APIDefaultTargetURL == nil {
    38  		return nil, errors.New("default targetURL for API cannot be empty")
    39  	}
    40  
    41  	return &BundleReference{
    42  		ID:                  id,
    43  		BundleID:            bundleID,
    44  		ObjectType:          objectType,
    45  		ObjectID:            objectID,
    46  		APIDefaultTargetURL: b.APIDefaultTargetURL,
    47  		IsDefaultBundle:     b.IsDefaultBundle,
    48  	}, nil
    49  }