Skip to content

Commit

Permalink
Merge branch 'master' into describe-unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushrakesh committed Jul 11, 2024
2 parents b971e59 + f3af398 commit b8ed227
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 b8ed227

Please sign in to comment.