Skip to content

Commit

Permalink
Merge pull request #244 from Revolyssup/addfunc
Browse files Browse the repository at this point in the history
Add functionality to get registrant in MeshModel
  • Loading branch information
Revolyssup authored Dec 18, 2022
2 parents cafe42a + 070f5ce commit 84da59d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions models/meshmodel/core/v1alpha1/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type Models struct {
func (c ComponentDefinition) Type() types.CapabilityType {
return types.ComponentDefinition
}
func (c ComponentDefinition) GetID() uuid.UUID {
return c.ID
}

var componentCreationLock sync.Mutex

Expand Down
3 changes: 3 additions & 0 deletions models/meshmodel/core/v1alpha1/relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func (rdb *RelationshipDefinitionDB) GetRelationshipDefinition() (r Relationship
func (r RelationshipDefinition) Type() types.CapabilityType {
return types.RelationshipDefinition
}
func (r RelationshipDefinition) GetID() uuid.UUID {
return r.ID
}

func CreateRelationship(db *database.Handler, r RelationshipDefinition) (uuid.UUID, error) {
r.ID = uuid.New()
Expand Down
10 changes: 10 additions & 0 deletions models/meshmodel/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func createHost(db *database.Handler, h Host) (uuid.UUID, error) {
// ComponentDefinitions and PolicyDefinitions are examples of entities
type Entity interface {
Type() types.CapabilityType
GetID() uuid.UUID
}

// RegistryManager instance will expose methods for registry operations & sits between the database level operations and user facing API handlers.
Expand Down Expand Up @@ -149,3 +150,12 @@ func (rm *RegistryManager) GetEntities(f types.Filter) []Entity {
return nil
}
}

func (rm *RegistryManager) GetRegistrant(e Entity) Host {
eID := e.GetID()
var reg Registry
_ = rm.db.Where("entity = ?", eID).Find(&reg).Error
var h Host
_ = rm.db.Where("id = ?", reg.RegistrantID).Find(&h).Error
return h
}
2 changes: 2 additions & 0 deletions models/oam/core/v1alpha1/application_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Component struct {
type ComponentSpec struct {
Type string `json:"type"`
Version string `json:"version"`
APIVersion string `json:"apiVersion"`
Model string `json:"model"`
Settings map[string]interface{} `json:"settings"`
Parameters []ComponentParameter `json:"parameters"`
}
Expand Down

0 comments on commit 84da59d

Please sign in to comment.