generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from layer5io/kumarabd/feature/model
MESHSYNC schema modified
- Loading branch information
Showing
3 changed files
with
70 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,65 @@ | ||
package model | ||
|
||
import ( | ||
"github.com/google/uuid" | ||
"gorm.io/gorm" | ||
) | ||
|
||
type Object struct { | ||
Index Index `json:"index,omitempty"` | ||
TypeMeta ResourceTypeMeta `json:"typemeta,omitempty"` | ||
ObjectMeta ResourceObjectMeta `json:"metadata,omitempty"` | ||
Spec ResourceSpec `json:"spec,omitempty"` | ||
Status ResourceStatus `json:"status,omitempty"` | ||
} | ||
gorm.Model | ||
|
||
type Index struct { | ||
ID string `json:"id,omitempty" gorm:"primarykey"` | ||
CreatedAt string `json:"created_at,omitempty" gorm:"index"` | ||
UpdatedAt string `json:"updated_at,omitempty" gorm:"index"` | ||
DeletedAt string `json:"deleted_at,omitempty" gorm:"index"` | ||
|
||
ResourceID string `json:"resource-id,omitempty"` | ||
TypeMetaID string `json:"type-meta-id,omitempty"` | ||
ObjectMetaID string `json:"object-meta-id,omitempty"` | ||
SpecID string `json:"spec-id,omitempty"` | ||
StatusID string `json:"status-id,omitempty"` | ||
ResourceID string `json:"resource_id" gorm:"index"` | ||
TypeMeta *ResourceTypeMeta `json:"typemeta,omitempty" gorm:"foreignkey:ID;references:id"` | ||
ObjectMeta *ResourceObjectMeta `json:"metadata,omitempty" gorm:"foreignkey:ID;references:id"` | ||
Spec *ResourceSpec `json:"spec,omitempty" gorm:"foreignkey:ID;references:id"` | ||
Status *ResourceStatus `json:"status,omitempty" gorm:"foreignkey:ID;references:id"` | ||
} | ||
|
||
type ResourceTypeMeta struct { | ||
ID string `json:"id,omitempty" gorm:"primarykey"` | ||
Kind string `json:"kind,omitempty"` | ||
APIVersion string `json:"apiVersion,omitempty"` | ||
ID uint `json:"id" gorm:"primarykey"` | ||
Kind string `json:"kind,omitempty" gorm:"index"` | ||
APIVersion string `json:"apiVersion,omitempty" gorm:"index"` | ||
} | ||
|
||
type KeyValue struct { | ||
ID uint `json:"id" gorm:"index"` | ||
UniqueID uuid.UUID `json:"unique_id" gorm:"primarykey;type:uuid"` | ||
Key string `json:"key,omitempty" gorm:"index"` | ||
Value string `json:"value,omitempty" gorm:"index"` | ||
} | ||
|
||
type ResourceObjectMeta struct { | ||
ID string `json:"id,omitempty" gorm:"primarykey"` | ||
Name string `json:"name,omitempty"` | ||
GenerateName string `json:"generateName,omitempty"` | ||
Namespace string `json:"namespace,omitempty"` | ||
SelfLink string `json:"selfLink,omitempty"` | ||
UID string `json:"uid,omitempty"` | ||
ResourceVersion string `json:"resourceVersion,omitempty"` | ||
Generation int64 `json:"generation,omitempty"` | ||
CreationTimestamp string `json:"creationTimestamp,omitempty"` | ||
DeletionTimestamp string `json:"deletionTimestamp,omitempty"` | ||
DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty"` | ||
Labels string `json:"labels,omitempty" gorm:"type:json"` | ||
Annotations string `json:"annotations,omitempty" gorm:"type:json"` | ||
ID uint `json:"id" gorm:"primarykey"` | ||
Name string `json:"name,omitempty" gorm:"index"` | ||
GenerateName string `json:"generateName,omitempty"` | ||
Namespace string `json:"namespace,omitempty"` | ||
SelfLink string `json:"selfLink,omitempty"` | ||
UID string `json:"uid"` | ||
ResourceVersion string `json:"resourceVersion,omitempty"` | ||
Generation int64 `json:"generation,omitempty"` | ||
CreationTimestamp string `json:"creationTimestamp,omitempty"` | ||
DeletionTimestamp string `json:"deletionTimestamp,omitempty"` | ||
DeletionGracePeriodSeconds *int64 `json:"deletionGracePeriodSeconds,omitempty"` | ||
Labels []*KeyValue `json:"labels,omitempty" gorm:"foreignkey:ID;references:id"` | ||
Annotations []*KeyValue `json:"annotations,omitempty" gorm:"foreignkey:ID;references:id"` | ||
// OwnerReferences string `json:"ownerReferences,omitempty" gorm:"type:json"` | ||
// Finalizers string `json:"finalizers,omitempty" gorm:"type:json"` | ||
ClusterName string `json:"clusterName,omitempty"` | ||
// ManagedFields string `json:"managedFields,omitempty" gorm:"type:json"` | ||
ClusterID string `json:"cluster-id,omitempty"` | ||
ClusterID string `json:"cluster_id"` | ||
} | ||
|
||
type ResourceSpec struct { | ||
ID string `json:"id,omitempty" gorm:"primarykey"` | ||
ID uint `json:"id" gorm:"primarykey"` | ||
Attribute string `json:"attribute,omitempty" gorm:"type:json"` | ||
} | ||
|
||
type ResourceStatus struct { | ||
ID string `json:"id,omitempty" gorm:"primarykey"` | ||
ID uint `json:"id" gorm:"primarykey"` | ||
Attribute string `json:"attribute,omitempty" gorm:"type:json"` | ||
} | ||
|
||
func (k *KeyValue) BeforeCreate(tx *gorm.DB) (err error) { | ||
k.UniqueID = uuid.New() | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters