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

Design schema #97

Merged
merged 14 commits into from
Jul 25, 2024
39 changes: 39 additions & 0 deletions schemas/constructs/core.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$id": "https://schemas.meshery.io/core.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Reusable core schema elements",
"definitions": {
"inputString": {
"type": "string",
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
leecalcote marked this conversation as resolved.
Show resolved Hide resolved
},
"versionString": {
"type": "string",
"minLength": 2,
"maxLength": 100,
"description": "API version of the object",
"pattern": "([a-z.])*(?!^\/)v(alpha|beta|[0-9]+)([.-]*[a-z0-9]+)*$",
"example": [
"v1",
"v1alpha1",
"v2beta3",
"v1.custom-suffix"
]
},
"semverString": {
"type": "string",
"minLength": 5,
"maxLength": 100,
"pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$",
"description": "A valid semantic version string between 5 and 256 characters. The pattern allows for a major.minor.patch version followed by an optional pre-release tag like '-alpha' or '-beta.2' and an optional build metadata tag like '+build.1."
},
"declarationID": {
"$ref": "#/definitions/uuid",
"description": "Uniquely identifies the component/relationship declaration in the deisgn file."
Copy link
Member

Choose a reason for hiding this comment

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

Remove declarationID entirely.

},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"declarationID": {
"$ref": "#/definitions/uuid",
"description": "Uniquely identifies the component/relationship declaration in the deisgn file."
},

"uuid": {
"type": "string",
"format": "uuid"
}
}
}
15 changes: 0 additions & 15 deletions schemas/constructs/v1alpha1/core.json

This file was deleted.

9 changes: 5 additions & 4 deletions schemas/constructs/v1alpha1/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@
"description": "Meshery Models serve as a portable unit of packaging to define managed entities, their relationships, and capabilities.",
"additionalProperties": false,
"type": "object",
"required": ["status",
"required": [
"status",
"name",
"version",
"category"
],
"properties": {
"name": {
"$ref": "https://schemas.meshery.io/v1alpha1/core.json#inputString",
"$ref": "../core.json#inputString",
"description": "The name for the model."
},
"displayName": {
"$ref": "https://schemas.meshery.io/v1alpha1/core.json#inputString",
"$ref": "../core.json#inputString",
"description": "The display name for the model."
},
"status": {
"type": "string",
"description": "Status of model, e.g. Registered, Ignored, Enabled ..."
},
"version": {
"$ref": "https://schemas.meshery.io/v1alpha1/core.json#versionString",
"$ref": "../core.json#versionString",
"description": "Version of the model."
},
"category": {
Expand Down
4 changes: 2 additions & 2 deletions schemas/constructs/v1alpha1/selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "string"
},
"version": {
"$ref": "https://schemas.meshery.io/v1alpha1/core.json#versionString"
"$ref": "../core.json#/definitions/versionString"
},
"match": {
"type": "object",
Expand Down Expand Up @@ -77,7 +77,7 @@
"type": "string"
},
"version": {
"$ref": "https://schemas.meshery.io/v1alpha1/core.json#versionString"
"$ref": "../core.json#/definitions/versionString"
},
"match": {
"type": "object",
Expand Down
32 changes: 0 additions & 32 deletions schemas/constructs/v1alpha2/core.json

This file was deleted.

14 changes: 7 additions & 7 deletions schemas/constructs/v1alpha2/relationship.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"type": "object",
"properties": {
"schemaVersion": {
"$ref": "./core.json#/definitions/versionString",
"$ref": "../core.json#/definitions/versionString",
"description": "Specifies the version of the schema used for the definition."
},
"version": {
"$ref": "./core.json#/definitions/semverString",
"$ref": "../core.json#/definitions/semverString",
"description": "Specifies the version of the definition."
},
"kind": {
"$ref": "./core.json#/definitions/inputString",
"$ref": "../core.json#/definitions/inputString",
"description": "Kind of the Relationship.",
"enum": [
"hierarchical",
Copy link
Member

Choose a reason for hiding this comment

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

Do these enums need to be Capitalized?

Expand All @@ -32,23 +32,23 @@
]
},
"type": {
"$ref": "./core.json#/definitions/inputString",
"$ref": "../core.json#/definitions/inputString",
"description": "Classification of relationships. Used to group relationships similar in nature."
},
"subType": {
"$ref": "./core.json#/definitions/inputString",
"$ref": "../core.json#/definitions/inputString",
"description": "Used for further classification of Relationships. Type and SubType together identifies a Relationship."
},
"evaluationQuery": {
"$ref": "./core.json#/definitions/inputString",
"$ref": "../core.json#/definitions/inputString",
"description": "Determines the policy rule to be used for the evaluation of the relationship."
},
"metadata": {
"type": "object",
"description": "Metadata contains additional information associated with the Relationship.",
"properties": {
"description": {
"$ref": "./core.json#/definitions/inputString",
"$ref": "../core.json#/definitions/inputString",
"description": "Description of the Relationship."
}
}
Expand Down
4 changes: 2 additions & 2 deletions schemas/constructs/v1alpha2/selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"description": "Model of the component. Learn more at https://docs.meshery.io/concepts/models"
},
"version": {
"$ref": "./core.json#/definitions/semverString"
"$ref": "../core.json#/definitions/semverString"
},
"match": {
"type": "object",
Expand Down Expand Up @@ -80,7 +80,7 @@
"description": "Model of the component. Learn more at https://docs.meshery.io/concepts/models"
},
"version": {
"$ref": "./core.json#/definitions/semverString"
"$ref": "../core.json#/definitions/semverString"
},
"match": {
"type": "object",
Expand Down
107 changes: 107 additions & 0 deletions schemas/constructs/v1alpha3/relationship.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"$id": "https://schemas.meshery.io/relationship.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Relationships define the nature of interaction between interconnected components in Meshery. The combination of relationship properties kind, type, and subtype characterize various genealogical relations among and between components. Relationships have selectors, selector sets, metadata, and optional parameters. Learn more at https://docs.meshery.io/concepts/logical/relationships.",
"required": [
"schemaVersion",
"version",
"kind",
"type",
"subType",
"model",
],
"additionalProperties": false,
"type": "object",
"properties": {
"schemaVersion": {
"$ref": "../core.json#/definitions/versionString",
"description": "Specifies the version of the schema used for the definition."
},
"version": {
"$ref": "../core.json#/definitions/semverString",
"description": "Specifies the version of the definition."
},
"kind": {
"$ref": "../core.json#/definitions/inputString",
"description": "Kind of the Relationship.",
"enum": [
"Hierarchical",
"Edge",
"Sibling"
]
},
"type": {
"$ref": "../core.json#/definitions/inputString",
"description": "Classification of relationships. Used to group relationships similar in nature."
},
"subType": {
"$ref": "../core.json#/definitions/inputString",
"description": "Used for further classification of Relationships. The combination of Kind, Type and SubType together uniquely identify a Relationship."
},
"evaluationQuery": {
"$ref": "../core.json#/definitions/inputString",
"description": "Optional. Assigns the policy to be used for the evaluation of the relationship. Deprecation Notice: In the future, this property is either to be removed or to it is to be an array of optional policy $refs."
},
"metadata": {
"type": "object",
"description": "Metadata contains additional information associated with the Relationship.",
"properties": {
"description": {
"$ref": "../core.json#/definitions/inputString",
"description": "Description of the Relationship."
leecalcote marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
"model": {
leecalcote marked this conversation as resolved.
Show resolved Hide resolved
"$ref": "../v1beta1/model.json",
"description": "Model of the Relationship."
},
"selectors": {
"type": "array",
"description": "Selectors are organized as an array, with each item containing a distinct set of selectors that share a common functionality. This structure allows for flexibility in defining relationships, even when different components are involved.",
"$comment": "Sets of selectors are interpreted as a locical OR, while sets of allow/deny are interpreted a logical AND.",
leecalcote marked this conversation as resolved.
Show resolved Hide resolved
"items": {
"type": "object",
"description": "Optional selectors used to match Components. Absence of a selector means that it is applied to all Components.",
"additionalProperties": false,
"required": [
"allow"
],
"properties": {
"deny": {
"type": "object",
"description": "Optional selectors used to define relationships which should not be created / is restricted.",
"required": [
"to",
"from"
],
"properties": {
"from": {
"$ref": "./selectors.json#/definitions/from"
},
"to": {
"$ref": "./selectors.json#/definitions/to"
}
}
Comment on lines +72 to +85
Copy link
Member

Choose a reason for hiding this comment

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

This can be replaced with a selector $ref.

},
"allow": {
"type": "object",
"description": "Selectors used to define relationships which are allowed.",
"required": [
"to",
"from"
],
"properties": {
"from": {
"$ref": "./selectors.json#/definitions/from"
},
"to": {
"$ref": "./selectors.json#/definitions/to"
}
}
}
}
}
}
}
}
Loading
Loading