github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/domain/bundle/entity.go (about) 1 package bundle 2 3 import ( 4 "database/sql" 5 6 "github.com/kyma-incubator/compass/components/director/pkg/resource" 7 8 "github.com/kyma-incubator/compass/components/director/internal/repo" 9 ) 10 11 // Entity is a bundle entity 12 type Entity struct { 13 ApplicationID sql.NullString `db:"app_id"` 14 ApplicationTemplateVersionID sql.NullString `db:"app_template_version_id"` 15 Name string `db:"name"` 16 Description sql.NullString `db:"description"` 17 InstanceAuthRequestJSONSchema sql.NullString `db:"instance_auth_request_json_schema"` 18 Version sql.NullString `db:"version"` 19 ResourceHash sql.NullString `db:"resource_hash"` 20 DefaultInstanceAuth sql.NullString `db:"default_instance_auth"` 21 OrdID sql.NullString `db:"ord_id"` 22 LocalTenantID sql.NullString `db:"local_tenant_id"` 23 ShortDescription sql.NullString `db:"short_description"` 24 Links sql.NullString `db:"links"` 25 Labels sql.NullString `db:"labels"` 26 CredentialExchangeStrategies sql.NullString `db:"credential_exchange_strategies"` 27 CorrelationIDs sql.NullString `db:"correlation_ids"` 28 Tags sql.NullString `db:"tags"` 29 DocumentationLabels sql.NullString `db:"documentation_labels"` 30 *repo.BaseEntity 31 } 32 33 // GetParent returns the parent type and the parent ID of the entity. 34 func (e *Entity) GetParent(_ resource.Type) (resource.Type, string) { 35 if e.ApplicationID.Valid { 36 return resource.Application, e.ApplicationID.String 37 } else if e.ApplicationTemplateVersionID.Valid { 38 return resource.ApplicationTemplateVersion, e.ApplicationTemplateVersionID.String 39 } 40 41 return "", "" 42 } 43 44 // DecorateWithTenantID decorates the entity with the given tenant ID. 45 func (e *Entity) DecorateWithTenantID(tenant string) interface{} { 46 return struct { 47 *Entity 48 TenantID string `db:"tenant_id"` 49 }{ 50 Entity: e, 51 TenantID: tenant, 52 } 53 }