Skip to content

Commit

Permalink
Merge pull request #536 from Jougan-0/modelImportUpdate
Browse files Browse the repository at this point in the history
support for model and policies w/signoff
  • Loading branch information
MUzairS15 committed Jul 11, 2024
2 parents cc30fc1 + 106670f commit f3af398
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,23 @@ func FindEntityType(content []byte) (entity.EntityType, error) {
if err := json.Unmarshal(content, &tempMap); err != nil {
return "", ErrUnmarshal(err)
}
if schemaVersion, ok := tempMap["schemaVersion"].(string); ok {
lastIndex := strings.LastIndex(schemaVersion, "/")
if lastIndex != -1 {
schemaVersion = schemaVersion[:lastIndex]
}
switch schemaVersion {
case "relationships.meshery.io":
return entity.RelationshipDefinition, nil
case "components.meshery.io":
return entity.ComponentDefinition, nil
}
}
return "", nil
schemaVersion, err := Cast[string](tempMap["schemaVersion"])
if err != nil {
return "", ErrInvalidSchemaVersion
}
lastIndex := strings.LastIndex(schemaVersion, "/")
if lastIndex != -1 {
schemaVersion = schemaVersion[:lastIndex]
}
switch schemaVersion {
case "relationships.meshery.io":
return entity.RelationshipDefinition, nil
case "components.meshery.io":
return entity.ComponentDefinition, nil
case "models.meshery.io":
return entity.Model, nil
case "policies.meshery.io":
return entity.PolicyDefinition, nil
}
return "", ErrInvalidSchemaVersion
}

0 comments on commit f3af398

Please sign in to comment.