Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add class description in v1alpha1 catalog data schema #108

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions schema.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
package schemas

import "embed"

//go:embed schemas/openapi.yml
import (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this appropriate for the schemas repo or more so for meshkit repo?

Other golang components that use these schemas will import the schemas as packages and have full access to the content of each schema. Is that right?

I'm trying to understand the need for this utility function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this will allow other components to have full access to the content of each schema

"embed"
"encoding/json"
"fmt"
)

// Embedding the file system for schema files
//go:embed schemas
var Schemas embed.FS

// LoadSchema loads and parses the JSON schema file from the embedded filesystem.
func LoadSchema(fileName string) (map[string]interface{}, error) {
// Read the file from the embedded filesystem
data, err := Schemas.ReadFile(fileName)
if err != nil {
return nil, fmt.Errorf("error reading file: %w", err)
}

// Unmarshal JSON data into a map
var schema map[string]interface{}
if err := json.Unmarshal(data, &schema); err != nil {
return nil, fmt.Errorf("error unmarshalling JSON: %w", err)
}

return schema, nil
}
5 changes: 5 additions & 0 deletions schemas/constructs/v1alpha1/catalog_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"official",
"verified",
"community"
],
"enumDescriptions": [
"Content produced and fully supported by Meshery maintainers. This represents the highest level of support and is considered the most reliable.",
"Content produced by partners and verified by Meshery maintainers. While not directly maintained by Meshery, content has undergone a verification process to ensure quality and compatibility.",
"Content produced and shared by Meshery users. This includes a wide range of content, such as performance profiles, test results, filters, patterns, and applications. Community content may have varying levels of support and reliability."
]
},
"compatibility": {
Expand Down
Loading