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

     1  package tombstone
     2  
     3  import (
     4  	"database/sql"
     5  
     6  	"github.com/kyma-incubator/compass/components/director/pkg/resource"
     7  )
     8  
     9  // Entity represents a tombstone entity.
    10  type Entity struct {
    11  	ID                           string         `db:"id"`
    12  	OrdID                        string         `db:"ord_id"`
    13  	ApplicationID                sql.NullString `db:"app_id"`
    14  	ApplicationTemplateVersionID sql.NullString `db:"app_template_version_id"`
    15  	RemovalDate                  string         `db:"removal_date"`
    16  }
    17  
    18  // GetID returns the entity's ID.
    19  func (e *Entity) GetID() string {
    20  	return e.ID
    21  }
    22  
    23  // GetParent returns the parent type and the parent ID of the entity.
    24  func (e *Entity) GetParent(_ resource.Type) (resource.Type, string) {
    25  	if e.ApplicationID.Valid {
    26  		return resource.Application, e.ApplicationID.String
    27  	} else if e.ApplicationTemplateVersionID.Valid {
    28  		return resource.ApplicationTemplateVersion, e.ApplicationTemplateVersionID.String
    29  	}
    30  
    31  	return "", ""
    32  }
    33  
    34  // DecorateWithTenantID decorates the entity with the given tenant ID.
    35  func (e *Entity) DecorateWithTenantID(tenant string) interface{} {
    36  	return struct {
    37  		*Entity
    38  		TenantID string `db:"tenant_id"`
    39  	}{
    40  		Entity:   e,
    41  		TenantID: tenant,
    42  	}
    43  }