This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
/
named_entity.go
42 lines (36 loc) · 1.56 KB
/
named_entity.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package models
import (
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
)
// NamedEntityMetadata primary key
type NamedEntityMetadataKey struct {
ResourceType core.ResourceType `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx" valid:"length(0|255)"`
Project string `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx" valid:"length(0|255)"`
Domain string `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx" valid:"length(0|255)"`
Name string `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx" valid:"length(0|255)"`
}
// Fields to be composed into any named entity
type NamedEntityMetadataFields struct {
Description string `gorm:"type:varchar(300)"`
// GORM doesn't save the zero value for ints, so we use a pointer for the State field
State *int32 `gorm:"default:0"`
}
// Database model to encapsulate metadata associated with a NamedEntity
type NamedEntityMetadata struct {
BaseModel
NamedEntityMetadataKey
NamedEntityMetadataFields
}
// NamedEntity key. This is used as a lookup for NamedEntityMetadata, so the
// fields here should match the ones in NamedEntityMetadataKey.
type NamedEntityKey struct {
ResourceType core.ResourceType
Project string `valid:"length(0|255)"`
Domain string `valid:"length(0|255)"`
Name string `valid:"length(0|255)"`
}
// Composes an identifier (NamedEntity) and its associated metadata fields
type NamedEntity struct {
NamedEntityKey
NamedEntityMetadataFields
}