Skip to content

Commit 76d0edb

Browse files
authored
Merge pull request #5885 from opsmill/dga-20250227-split-schema
Reorganize core schema into multiple files
2 parents a15a808 + edd1c2e commit 76d0edb

File tree

19 files changed

+2197
-1962
lines changed

19 files changed

+2197
-1962
lines changed

backend/infrahub/core/schema/definitions/core/__init__.py

Lines changed: 130 additions & 1962 deletions
Large diffs are not rendered by default.
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
from infrahub.core.constants import (
2+
AccountStatus,
3+
AccountType,
4+
BranchSupportType,
5+
InfrahubKind,
6+
)
7+
8+
core_account = {
9+
"name": "Account",
10+
"namespace": "Core",
11+
"description": "User Account for Infrahub",
12+
"include_in_menu": False,
13+
"label": "Account",
14+
"icon": "mdi:account",
15+
"default_filter": "name__value",
16+
"order_by": ["name__value"],
17+
"display_labels": ["label__value"],
18+
"generate_profile": False,
19+
"branch": BranchSupportType.AGNOSTIC.value,
20+
"inherit_from": [InfrahubKind.LINEAGEOWNER, InfrahubKind.LINEAGESOURCE, InfrahubKind.GENERICACCOUNT],
21+
}
22+
23+
core_account_token = {
24+
"name": "AccountToken",
25+
"namespace": "Internal",
26+
"description": "Token for User Account",
27+
"include_in_menu": False,
28+
"label": "Account Token",
29+
"default_filter": "token__value",
30+
"display_labels": ["token__value"],
31+
"generate_profile": False,
32+
"branch": BranchSupportType.AGNOSTIC.value,
33+
"uniqueness_constraints": [["token__value"]],
34+
"documentation": "/topics/auth",
35+
"attributes": [
36+
{"name": "name", "kind": "Text", "optional": True},
37+
{"name": "token", "kind": "Text", "unique": True},
38+
{"name": "expiration", "kind": "DateTime", "optional": True},
39+
],
40+
"relationships": [
41+
{
42+
"name": "account",
43+
"peer": InfrahubKind.GENERICACCOUNT,
44+
"optional": False,
45+
"cardinality": "one",
46+
"identifier": "account__token",
47+
},
48+
],
49+
}
50+
51+
core_password_credential = {
52+
"name": "PasswordCredential",
53+
"namespace": "Core",
54+
"description": "Username/Password based credential",
55+
"include_in_menu": False,
56+
"label": "Username / Password",
57+
"generate_profile": False,
58+
"branch": BranchSupportType.AGNOSTIC.value,
59+
"inherit_from": [InfrahubKind.CREDENTIAL],
60+
"attributes": [
61+
{
62+
"name": "username",
63+
"kind": "Text",
64+
"optional": True,
65+
"branch": BranchSupportType.AGNOSTIC.value,
66+
"order_weight": 6000,
67+
},
68+
{
69+
"name": "password",
70+
"kind": "Password",
71+
"optional": True,
72+
"branch": BranchSupportType.AGNOSTIC.value,
73+
"order_weight": 7000,
74+
},
75+
],
76+
}
77+
78+
core_refresh_token = {
79+
"name": "RefreshToken",
80+
"namespace": "Internal",
81+
"description": "Refresh Token",
82+
"include_in_menu": False,
83+
"label": "Refresh Token",
84+
"display_labels": [],
85+
"generate_profile": False,
86+
"branch": BranchSupportType.AGNOSTIC.value,
87+
"attributes": [
88+
{"name": "expiration", "kind": "DateTime", "optional": False},
89+
],
90+
"relationships": [
91+
{
92+
"name": "account",
93+
"peer": InfrahubKind.GENERICACCOUNT,
94+
"optional": False,
95+
"cardinality": "one",
96+
"identifier": "account__refreshtoken",
97+
},
98+
],
99+
}
100+
101+
core_credential = {
102+
"name": "Credential",
103+
"namespace": "Core",
104+
"description": "A credential that could be referenced to access external services.",
105+
"include_in_menu": False,
106+
"label": "Credential",
107+
"default_filter": "name__value",
108+
"order_by": ["name__value"],
109+
"display_labels": ["label__value"],
110+
"icon": "mdi:key-variant",
111+
"human_friendly_id": ["name__value"],
112+
"branch": BranchSupportType.AGNOSTIC.value,
113+
"uniqueness_constraints": [["name__value"]],
114+
"documentation": "/topics/auth",
115+
"attributes": [
116+
{"name": "name", "kind": "Text", "unique": True, "order_weight": 1000},
117+
{"name": "label", "kind": "Text", "optional": True, "order_weight": 2000},
118+
{"name": "description", "kind": "Text", "optional": True, "order_weight": 3000},
119+
],
120+
}
121+
122+
core_generic_account = {
123+
"name": "GenericAccount",
124+
"namespace": "Core",
125+
"description": "User Account for Infrahub",
126+
"include_in_menu": False,
127+
"label": "Account",
128+
"icon": "mdi:account",
129+
"default_filter": "name__value",
130+
"order_by": ["name__value"],
131+
"display_labels": ["label__value"],
132+
"human_friendly_id": ["name__value"],
133+
"branch": BranchSupportType.AGNOSTIC.value,
134+
"documentation": "/topics/auth",
135+
"uniqueness_constraints": [["name__value"]],
136+
"attributes": [
137+
{"name": "name", "kind": "Text", "unique": True},
138+
{"name": "password", "kind": "HashedPassword", "unique": False},
139+
{"name": "label", "kind": "Text", "optional": True},
140+
{"name": "description", "kind": "Text", "optional": True},
141+
{
142+
"name": "account_type",
143+
"kind": "Text",
144+
"default_value": AccountType.USER.value,
145+
"enum": AccountType.available_types(),
146+
},
147+
{
148+
"name": "status",
149+
"kind": "Dropdown",
150+
"choices": [
151+
{
152+
"name": AccountStatus.ACTIVE.value,
153+
"label": "Active",
154+
"description": "Account is allowed to login",
155+
"color": "#52be80",
156+
},
157+
{
158+
"name": AccountStatus.INACTIVE.value,
159+
"label": "Inactive",
160+
"description": "Account is not allowed to login",
161+
"color": "#e74c3c",
162+
},
163+
],
164+
"default_value": AccountStatus.ACTIVE.value,
165+
},
166+
],
167+
"relationships": [{"name": "tokens", "peer": InfrahubKind.ACCOUNTTOKEN, "optional": True, "cardinality": "many"}],
168+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
from infrahub.core.constants import (
2+
ArtifactStatus,
3+
BranchSupportType,
4+
ContentType,
5+
InfrahubKind,
6+
)
7+
8+
core_artifact_target = {
9+
"name": "ArtifactTarget",
10+
"include_in_menu": False,
11+
"namespace": "Core",
12+
"description": "Extend a node to be associated with artifacts",
13+
"label": "Artifact Target",
14+
"relationships": [
15+
{
16+
"name": "artifacts",
17+
"peer": InfrahubKind.ARTIFACT,
18+
"optional": True,
19+
"cardinality": "many",
20+
"kind": "Generic",
21+
"identifier": "artifact__node",
22+
},
23+
],
24+
}
25+
26+
core_artifact = {
27+
"name": "Artifact",
28+
"namespace": "Core",
29+
"label": "Artifact",
30+
"include_in_menu": False,
31+
"icon": "mdi:file-document-outline",
32+
"default_filter": "name__value",
33+
"order_by": ["name__value"],
34+
"display_labels": ["name__value"],
35+
"branch": BranchSupportType.LOCAL.value,
36+
"generate_profile": False,
37+
"inherit_from": [InfrahubKind.TASKTARGET],
38+
"documentation": "/topics/artifact",
39+
"attributes": [
40+
{"name": "name", "kind": "Text"},
41+
{
42+
"name": "status",
43+
"kind": "Text",
44+
"enum": ArtifactStatus.available_types(),
45+
},
46+
{
47+
"name": "content_type",
48+
"kind": "Text",
49+
"enum": ContentType.available_types(),
50+
},
51+
{
52+
"name": "checksum",
53+
"kind": "Text",
54+
"optional": True,
55+
},
56+
{
57+
"name": "storage_id",
58+
"kind": "Text",
59+
"optional": True,
60+
"description": "ID of the file in the object store",
61+
},
62+
{"name": "parameters", "kind": "JSON", "optional": True},
63+
],
64+
"relationships": [
65+
{
66+
"name": "object",
67+
"peer": InfrahubKind.ARTIFACTTARGET,
68+
"kind": "Attribute",
69+
"identifier": "artifact__node",
70+
"cardinality": "one",
71+
"optional": False,
72+
},
73+
{
74+
"name": "definition",
75+
"peer": InfrahubKind.ARTIFACTDEFINITION,
76+
"kind": "Attribute",
77+
"identifier": "artifact__artifact_definition",
78+
"cardinality": "one",
79+
"optional": False,
80+
},
81+
],
82+
}
83+
84+
core_artifact_definition = {
85+
"name": "ArtifactDefinition",
86+
"namespace": "Core",
87+
"include_in_menu": False,
88+
"icon": "mdi:file-document-multiple-outline",
89+
"label": "Artifact Definition",
90+
"default_filter": "name__value",
91+
"order_by": ["name__value"],
92+
"display_labels": ["name__value"],
93+
"branch": BranchSupportType.AWARE.value,
94+
"generate_profile": False,
95+
"uniqueness_constraints": [["name__value"]],
96+
"inherit_from": [InfrahubKind.TASKTARGET],
97+
"documentation": "/topics/artifact",
98+
"attributes": [
99+
{"name": "name", "kind": "Text", "unique": True},
100+
{"name": "artifact_name", "kind": "Text"},
101+
{"name": "description", "kind": "Text", "optional": True},
102+
{"name": "parameters", "kind": "JSON"},
103+
{
104+
"name": "content_type",
105+
"kind": "Text",
106+
"enum": ContentType.available_types(),
107+
},
108+
],
109+
"relationships": [
110+
{
111+
"name": "targets",
112+
"peer": InfrahubKind.GENERICGROUP,
113+
"kind": "Attribute",
114+
"identifier": "artifact_definition___group",
115+
"cardinality": "one",
116+
"optional": False,
117+
},
118+
{
119+
"name": "transformation",
120+
"peer": InfrahubKind.TRANSFORM,
121+
"kind": "Attribute",
122+
"identifier": "artifact_definition___transformation",
123+
"cardinality": "one",
124+
"optional": False,
125+
},
126+
],
127+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from infrahub.core.constants import (
2+
BranchSupportType,
3+
)
4+
5+
builtin_tag = {
6+
"name": "Tag",
7+
"namespace": "Builtin",
8+
"description": "Standard Tag object to attached to other objects to provide some context.",
9+
"include_in_menu": True,
10+
"icon": "mdi:tag-multiple",
11+
"label": "Tag",
12+
"default_filter": "name__value",
13+
"order_by": ["name__value"],
14+
"display_labels": ["name__value"],
15+
"branch": BranchSupportType.AWARE.value,
16+
"uniqueness_constraints": [["name__value"]],
17+
"attributes": [
18+
{"name": "name", "kind": "Text", "unique": True},
19+
{"name": "description", "kind": "Text", "optional": True},
20+
],
21+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from infrahub.core.constants import (
2+
BranchSupportType,
3+
InfrahubKind,
4+
)
5+
6+
core_check_definition = {
7+
"name": "CheckDefinition",
8+
"namespace": "Core",
9+
"include_in_menu": False,
10+
"icon": "mdi:check-all",
11+
"label": "Check Definition",
12+
"default_filter": "name__value",
13+
"order_by": ["name__value"],
14+
"display_labels": ["name__value"],
15+
"branch": BranchSupportType.AWARE.value,
16+
"uniqueness_constraints": [["name__value"]],
17+
"generate_profile": False,
18+
"inherit_from": [InfrahubKind.TASKTARGET],
19+
"attributes": [
20+
{"name": "name", "kind": "Text", "unique": True},
21+
{"name": "description", "kind": "Text", "optional": True},
22+
{"name": "file_path", "kind": "Text"},
23+
{"name": "class_name", "kind": "Text"},
24+
{"name": "timeout", "kind": "Number", "default_value": 10},
25+
{"name": "parameters", "kind": "JSON", "optional": True},
26+
],
27+
"relationships": [
28+
{
29+
"name": "repository",
30+
"peer": InfrahubKind.GENERICREPOSITORY,
31+
"kind": "Attribute",
32+
"cardinality": "one",
33+
"identifier": "check_definition__repository",
34+
"optional": False,
35+
},
36+
{
37+
"name": "query",
38+
"peer": InfrahubKind.GRAPHQLQUERY,
39+
"kind": "Attribute",
40+
"identifier": "check_definition__graphql_query",
41+
"cardinality": "one",
42+
"optional": True,
43+
},
44+
{
45+
"name": "targets",
46+
"peer": InfrahubKind.GENERICGROUP,
47+
"kind": "Attribute",
48+
"identifier": "check_definition___group",
49+
"cardinality": "one",
50+
"optional": True,
51+
},
52+
{
53+
"name": "tags",
54+
"peer": InfrahubKind.TAG,
55+
"kind": "Attribute",
56+
"optional": True,
57+
"cardinality": "many",
58+
},
59+
],
60+
}

0 commit comments

Comments
 (0)